]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use inet_pton() rather than inet_addr().
authorGuy Harris <[email protected]>
Fri, 10 Nov 2017 22:35:07 +0000 (14:35 -0800)
committerGuy Harris <[email protected]>
Fri, 10 Nov 2017 22:35:07 +0000 (14:35 -0800)
Modern UN*Xes should have it, and MSVC whines about inet_addr() being
deprecated in the Appveyor builds.

tests/filtertest.c

index 91f942852231ec5eee43b09822dc2dbd43f2073c..746cc9440778994a058a43fc99ffd800442f1d95 100644 (file)
@@ -240,10 +240,21 @@ main(int argc, char **argv)
                case 'm': {
                        in_addr_t addr;
 
-                       addr = inet_addr(optarg);
-                       if (addr == (in_addr_t)(-1))
+                       switch (inet_pton(AF_INET, optarg, &addr)) {
+
+                       case 0:                        
                                error("invalid netmask %s", optarg);
-                       netmask = addr;
+                               break;
+
+                       case -1:
+                               error("invalid netmask %s: %s", optarg,
+                                   pcap_strerror(errno));
+                               break;
+
+                       case 1:
+                               netmask = addr;
+                               break;
+                       }
                        break;
                }