]> The Tcpdump Group git mirrors - tcpdump/commitdiff
fixup status_flags[]
authorDenis Ovsienko <[email protected]>
Sun, 12 Jan 2014 20:52:58 +0000 (00:52 +0400)
committerDenis Ovsienko <[email protected]>
Sun, 12 Jan 2014 20:52:58 +0000 (00:52 +0400)
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

index 3156671bba2ab40410faf21e403f7c075718fcbc..196278946a7b53e585b4486a459fb0afe63260aa 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -346,6 +346,17 @@ static const struct ndo_printer ndo_printers[] = {
        { NULL,                 0 },
 };
 
        { 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)
 {
 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);
                                        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;
                                }
                                        printf("\n");
                                        devpointer = devpointer->next;
                                }