summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/unix-formats.c
diff options
context:
space:
mode:
authorNathan Moos <nmoos@cisco.com>2021-01-15 16:45:14 -0800
committerDamjan Marion <dmarion@me.com>2021-01-21 13:08:57 +0000
commit323418dd1c7825d38e8b1f83d5a8c23766a26de2 (patch)
tree8db40b41eccf9e122e3ec25637e4ce94edca6e9d /src/vppinfra/unix-formats.c
parent1523c96deb2bc2f03e7823be4545342309da18fc (diff)
vppinfra: ensure _GNU_SOURCE is present
Type: fix When building with musl, _GNU_SOURCE is required to be defined in more places. This patch defines it in those required places. Additionally, this patch changes the udphdr field names to the standard names. Change-Id: I0fec54214ccc8458289176488afb4218761e9d51 Signed-off-by: Nathan Moos <nmoos@cisco.com>
Diffstat (limited to 'src/vppinfra/unix-formats.c')
-rw-r--r--src/vppinfra/unix-formats.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/vppinfra/unix-formats.c b/src/vppinfra/unix-formats.c
index fd0539c7d2b..678700e6129 100644
--- a/src/vppinfra/unix-formats.c
+++ b/src/vppinfra/unix-formats.c
@@ -50,7 +50,6 @@
#define _GNU_SOURCE /* to get REG_* in ucontext.h */
#include <ucontext.h>
-#undef _GNU_SOURCE
#undef __USE_GNU
#include <unistd.h>
@@ -317,11 +316,13 @@ u8 * format_udp4_packet (u8 * s, va_list * args)
struct iphdr * ip = (void *) p;
struct udphdr * udp = (void *) (ip + 1);
- s = format (s, "udp %U:%U -> %U:%U",
- format_network_address, AF_INET, &ip->saddr,
- format_network_port, IPPROTO_UDP, ntohs (udp->source),
- format_network_address, AF_INET, &ip->daddr,
- format_network_port, IPPROTO_UDP, ntohs (udp->dest));
+ u16 source = udp->uh_sport;
+ u16 dest = udp->uh_dport;
+
+ s = format (s, "udp %U:%U -> %U:%U", format_network_address, AF_INET,
+ &ip->saddr, format_network_port, IPPROTO_UDP, ntohs (source),
+ format_network_address, AF_INET, &ip->daddr, format_network_port,
+ IPPROTO_UDP, ntohs (dest));
return s;
}