From fca9fca3d969ffd0e4c74bf13c7d5f279b7d5f0c Mon Sep 17 00:00:00 2001 From: Katerina Kubecova Date: Thu, 4 Jan 2024 11:46:34 +0100 Subject: [PATCH] includes still broken --- nest/cbor.c | 11 ++++------- nest/cbor.h | 4 ++-- nest/cbor_shortcuts.c | 10 ++-------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/nest/cbor.c b/nest/cbor.c index 2f47bc03..c4887643 100644 --- a/nest/cbor.c +++ b/nest/cbor.c @@ -86,17 +86,14 @@ void cbor_add_ipv6(struct cbor_writer *writer, uint32_t addr[4]) } -void cbor_add_ipv4_prefix(struct cbor_writer *writer, uint32_t addr, uint32_t prefix) +void cbor_add_ipv4_prefix(struct cbor_writer *writer, net_addr_ip4 *n) { write_item(writer, 6, 52); // 6 is TAG, 52 is tag number for ipv4 cbor_open_block_with_length(writer, 2); - cbor_add_int(writer, prefix); + cbor_add_int(writer, n->pxlen); write_item(writer, 2, 4); // bytestring of length 4 - for (int i = 3; i>=0; i--) - { - writer->cbor[writer->pt] = (addr>>(i*8)) & 0xff; - writer->pt++; - } + put_ip4(&writer->cbor[writer->pt], n->prefix); + writer->pt += 4; } diff --git a/nest/cbor.h b/nest/cbor.h index b092a7f9..02988c4c 100644 --- a/nest/cbor.h +++ b/nest/cbor.h @@ -31,10 +31,10 @@ void cbor_add_ipv4(struct cbor_writer *writer, uint32_t addr); void cbor_add_ipv6(struct cbor_writer *writer, uint32_t addr[4]); -void cbor_add_ipv4_prefix(struct cbor_writer *writer, uint32_t addr, uint32_t prefix); +void cbor_add_ipv4_prefix(struct cbor_writer *writer, net_addr_ip4 *n); -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); void cbor_add_uint(struct cbor_writer *writer, uint64_t item); diff --git a/nest/cbor_shortcuts.c b/nest/cbor_shortcuts.c index b59e39d6..0e73f34c 100644 --- a/nest/cbor_shortcuts.c +++ b/nest/cbor_shortcuts.c @@ -58,16 +58,10 @@ void cbor_add_net(struct cbor_writer *writer, const net_addr *N) { switch (n->n.type) { case NET_IP4: - cbor_add_ipv4_prefix(writer, n->ip4.prefix, n->ip4.pxlen); + cbor_add_ipv4_prefix(writer, &n->ip4); return; case NET_IP6: - cbor_add_ipv6_prefix(writer, n->ip6.prefix.addr, n->ip6.pxlen); - return; - case NET_VPN4: - cbor_add_ipv4_prefix(writer, n->vpn4.prefix, n->vpn4.pxlen); - return; - case NET_VPN6: - cbor_add_ipv6_prefix(writer, n->vpn6.prefix.addr, n->vpn6.pxlen); + cbor_add_ipv6_prefix(writer, &n->ip6); return; default: bug("net type unsupported by cbor (yet).");