summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlixiaoyan <lixiaoyan@google.com>2020-09-25 02:01:52 +0000
committerfxlb <devel.fx.lebail@orange.fr>2020-09-26 11:30:56 +0000
commita45ac8a5f4c893891a67a239753fe078528013e1 (patch)
tree8ed4800206529c29a68f66fcfd7f9d3d64f76678
parent080d63db2f566ad6378069ca24359f3c635cc6e3 (diff)
downloadlibpcap-a45ac8a5f4c893891a67a239753fe078528013e1.tar.gz
added ipv6 socket support
-rw-r--r--pcap-linux.c13
1 files 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);
@@ -1482,6 +1483,14 @@ get_if_ioctl_socket(void)
}
/*
+ * Now try an AF_INET6 socket.
+ */
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (fd != -1) {
+ return (fd);
+ }
+
+ /*
* Now try an AF_INET socket.
*
* XXX - if that fails, is there anything else we should try?