]> The Tcpdump Group git mirrors - libpcap/commitdiff
Handle no -i argument, report success.
authorGuy Harris <[email protected]>
Mon, 27 Jun 2016 19:13:29 +0000 (12:13 -0700)
committerGuy Harris <[email protected]>
Mon, 27 Jun 2016 19:13:29 +0000 (12:13 -0700)
If no -i argument was given, use pcap_lookupdev().

If the open succeeds, report it.

tests/opentest.c

index f9834071231f4ef9ff28f2d027a0dfc91474a452..b6d634f0d901eaf42199f3c8536ce4a3d5995c32 100644 (file)
@@ -162,10 +162,15 @@ main(int argc, char **argv)
                }
        }
 
+       if (device == NULL) {
+               device = pcap_lookupdev(ebuf);
+               if (device == NULL)
+                       error("pcap_lookupdev failed: %s", ebuf);
+       }
        if (useactivate) {
                pd = pcap_create(device, ebuf);
                if (pd == NULL)
-                       error("%s", ebuf);
+                       error("%s: pcap_create failed: %s", device, ebuf);
                status = pcap_set_snaplen(pd, snaplen);
                if (status != 0)
                        error("%s: pcap_set_snaplen failed: %s",
@@ -206,7 +211,8 @@ main(int argc, char **argv)
                         */
                        warning("%s: %s\n(%s)", device,
                            pcap_statustostr(status), pcap_geterr(pd));
-               }
+               } else
+                       printf("%s opened successfully\n", device);
        } else {
                *ebuf = '\0';
                pd = pcap_open_live(device, 65535, 0, 1000, ebuf);
@@ -214,6 +220,8 @@ main(int argc, char **argv)
                        error("%s", ebuf);
                else if (*ebuf)
                        warning("%s", ebuf);
+               else
+                       printf("%s opened successfully\n", device);
        }
        pcap_close(pd);
        exit(status < 0 ? 1 : 0);