0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 12:18:42 +00:00

minor example update

This commit is contained in:
Maria Matejka 2024-01-04 11:22:09 +01:00
parent 9fb61e6034
commit a214035951
2 changed files with 8 additions and 12 deletions

View File

@ -100,20 +100,15 @@ void cbor_add_ipv4_prefix(struct cbor_writer *writer, uint32_t addr, uint32_t pr
} }
void cbor_add_ipv6_prefix(struct cbor_writer *writer, uint32_t addr[4], uint32_t prefix) void cbor_add_ipv6_prefix(struct cbor_writer *writer, net_addr_ip6 *n)
{ {
write_item(writer, 6, 54); // 6 is TAG, 54 is tag number for ipv6 write_item(writer, 6, 54); // 6 is TAG, 54 is tag number for ipv6
cbor_open_block_with_length(writer, 2); cbor_open_block_with_length(writer, 2);
cbor_add_int(writer, prefix); cbor_add_int(writer, n->pxlen);
write_item(writer, 2, 8); // bytestring of length 4
for (int j = 0; j < 4; j++) write_item(writer, 2, 16);
{ put_ip6(&writer->cbor[writer->pt], n->prefix);
for (int i = 3; i>=0; i--) writer->pt += 16;
{
writer->cbor[writer->pt] = (addr[j]>>(i*8)) & 0xff;
writer->pt++;
}
}
} }

View File

@ -1,6 +1,7 @@
#ifndef CBOR_H #ifndef CBOR_H
#define CBOR_H #define CBOR_H
#include <stdint.h>
#include "nest/bird.h"
struct cbor_writer { struct cbor_writer {