From: Guy Harris Date: Fri, 10 Nov 2017 22:35:07 +0000 (-0800) Subject: Use inet_pton() rather than inet_addr(). X-Git-Tag: libpcap-1.9-bp~384 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/1c3b8b878fd53786247c4d34c66310f63aff451b?ds=inline Use inet_pton() rather than inet_addr(). Modern UN*Xes should have it, and MSVC whines about inet_addr() being deprecated in the Appveyor builds. --- diff --git a/tests/filtertest.c b/tests/filtertest.c index 91f94285..746cc944 100644 --- a/tests/filtertest.c +++ b/tests/filtertest.c @@ -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; }