From a45ac8a5f4c893891a67a239753fe078528013e1 Mon Sep 17 00:00:00 2001 From: lixiaoyan Date: Fri, 25 Sep 2020 02:01:52 +0000 Subject: added ipv6 socket support --- pcap-linux.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pcap-linux.c b/pcap-linux.c index 9b126a3a..0444d574 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -1412,8 +1412,7 @@ get_if_ioctl_socket(void) * kernels without IPv4 support. * * AF_INET6 will work *if* you have IPv6 configured into the - * kernel, but if you don't have AF_INET, you might not have - * AF_INET6, either. + * kernel. * * AF_PACKET would work, except that some of these calls should * work even if you *don't* have capture permission (you should be @@ -1440,6 +1439,8 @@ get_if_ioctl_socket(void) * likely to be configured out on a networking-capable system * than is IP; * + * if that fails, we try an AF_INET6 socket; + * * if that fails, we try an AF_INET socket. */ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); @@ -1481,6 +1482,14 @@ get_if_ioctl_socket(void) return (fd); } + /* + * Now try an AF_INET6 socket. + */ + fd = socket(AF_INET6, SOCK_DGRAM, 0); + if (fd != -1) { + return (fd); + } + /* * Now try an AF_INET socket. * -- cgit v1.2.1