From f3f09ec95b01a59b04a224cf00d98fa7d3e7dc83 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Mon, 13 Jan 2014 00:52:58 +0400 Subject: [PATCH] fixup status_flags[] Add guards to fix building against older libpcap versions (PCAP_IF_UP and PCAP_IF_RUNNING belong to the latest libpcap only). Add a terminating element to the array. Justify some indentation. --- tcpdump.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tcpdump.c b/tcpdump.c index 3156671b..19627894 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -346,6 +346,17 @@ static const struct ndo_printer ndo_printers[] = { { NULL, 0 }, }; +static const struct tok status_flags[] = { +#ifdef PCAP_IF_UP + { PCAP_IF_UP, "Up" }, +#endif +#ifdef PCAP_IF_RUNNING + { PCAP_IF_RUNNING, "Running" }, +#endif + { PCAP_IF_LOOPBACK, "Loopback" }, + { 0, NULL } +}; + if_printer lookup_printer(int type) { @@ -801,14 +812,8 @@ main(int argc, char **argv) printf("%d.%s", i+1, devpointer->name); if (devpointer->description != NULL) printf(" (%s)", devpointer->description); - if (devpointer->flags != 0) { - struct tok status_flags[] = { - { PCAP_IF_UP, "Up" }, - { PCAP_IF_RUNNING, "Running" }, - { PCAP_IF_LOOPBACK, "Loopback" } - }; - printf(" [%s]", bittok2str(status_flags, "none", devpointer->flags)); - } + if (devpointer->flags != 0) + printf(" [%s]", bittok2str(status_flags, "none", devpointer->flags)); printf("\n"); devpointer = devpointer->next; } -- 2.39.5