]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-linux.c
Add support for capturing from Linux iptables NFLOG log groups.
[libpcap] / pcap-linux.c
index fa1d028dba9b4a29ac0c1fdd4f10fe4eb2471a1a..a70d585f6c965203e4ab95a9bcb74702891e0826 100644 (file)
@@ -199,6 +199,11 @@ static const char rcsid[] _U_ =
 #include "pcap-can-linux.h"
 #endif
 
+#ifdef PCAP_SUPPORT_NETFILTER
+int netfilter_platform_finddevs(pcap_if_t **alldevsp, char *err_str);
+pcap_t *nflog_create(const char *device, char *ebuf);
+#endif
+
 /*
  * If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET
  * sockets rather than SOCK_PACKET sockets.
@@ -419,6 +424,12 @@ pcap_create(const char *device, char *ebuf)
        }
 #endif
 
+#ifdef PCAP_SUPPORT_NETFILTER
+       if (strncmp(device, "nflog", strlen("nflog")) == 0) {
+               return nflog_create(device, ebuf);
+       }
+#endif
+
        handle = pcap_create_common(device, ebuf);
        if (handle == NULL)
                return NULL;
@@ -2199,6 +2210,14 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
                return (-1);
 #endif
 
+#ifdef PCAP_SUPPORT_NETFILTER
+       /*
+        * Add netfilter devices.
+        */
+       if (netfilter_platform_finddevs(alldevsp, errbuf) < 0)
+               return (-1);
+#endif
+
        return (0);
 }