From 8b419273476a50bad00e29320b9a3eacc88fcae6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 21 Jul 2017 09:53:11 -0400 Subject: [PATCH] Add a formatter for Dns() device types. This re-organizes the IPv4 and IPv6 formatters so they can be used to print Dns() entries, and then uses them to do that. Maybe? Not sure if I've got endianness right. Signed-off-by: Peter Jones --- src/dp-message.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/dp-message.c b/src/dp-message.c index a7d1f00..6fe20b4 100644 --- a/src/dp-message.c +++ b/src/dp-message.c @@ -28,9 +28,8 @@ #include "dp.h" static ssize_t -format_ipv4_addr_helper(char *buf, size_t size, - const char *dp_type __attribute__((__unused__)), - uint8_t const *ipaddr, int32_t port) +format_ipv4_addr_helper(char *buf, size_t size, const char *dp_type, + const uint8_t *ipaddr, int32_t port) { ssize_t off = 0; format(buf, size, off, dp_type, "%hhu.%hhu.%hhu.%hhu", @@ -41,9 +40,8 @@ format_ipv4_addr_helper(char *buf, size_t size, } static ssize_t -format_ipv6_addr_helper(char *buf, size_t size, - const char *dp_type __attribute__((__unused__)), - uint8_t const *ipaddr, int32_t port) +format_ipv6_addr_helper(char *buf, size_t size, const char *dp_type, + const uint8_t *ipaddr, int32_t port) { uint16_t *ip = (uint16_t *)ipaddr; ssize_t off = 0; @@ -92,17 +90,17 @@ format_ipv6_addr_helper(char *buf, size_t size, for (i = 0; i < 8; i++) { if (largest_zero_block_offset == i) { - format(buf, size, off, "IPv6", "::"); + format(buf, size, off, "dp_type", "::"); i += largest_zero_block_size -1; continue; } else if (i > 0) { - format(buf, size, off, "IPv6", ":"); + format(buf, size, off, "dp_type", ":"); } - format(buf, size, off, "IPv6", "%x", ip[i]); + format(buf, size, off, "dp_type", "%x", ip[i]); } - format(buf, size, off, "IPv6", "]"); + format(buf, size, off, "dp_type", "]"); if (port >= 0) format(buf, size, off, "Ipv6", ":%hu", port); @@ -621,6 +619,7 @@ _format_message_dn(char *buf, size_t size, const_efidp dp) format_ip_addr(buf, size, off, "Dns", dp->dns.is_ipv6, addr); } + format(buf, size, off, "Dns", ")"); break; } default: -- 2.11.0