- added support for netlink (bnc#863823) * libpcap-netlink.patch - update to 1.5.3 * Don't let packets that don't match the current filter get to the application when TPACKET_V3 is used. (GitHub issue #331) * Fix handling of pcap_loop()/pcap_dispatch() with a packet count of 0 on some platforms (including Linux with TPACKET_V3). (GitHub issue #333) * Work around TPACKET_V3 deficiency that causes packets to be lost when a timeout of 0 is specified. (GitHub issue #335) * Man page formatting fixes. - refreshed libpcap-1.5.2-filter-fix.patch OBS-URL: https://build.opensuse.org/request/show/222227 OBS-URL: https://build.opensuse.org/package/show/Base:System/libpcap?expand=0&rev=36
92 lines
2.6 KiB
Diff
92 lines
2.6 KiB
Diff
diff --git a/pcap-common.c b/pcap-common.c
|
|
index 6175a5a..f26d22e 100644
|
|
--- a/pcap-common.c
|
|
+++ b/pcap-common.c
|
|
@@ -932,7 +932,12 @@
|
|
*/
|
|
#define LINKTYPE_WIRESHARK_UPPER_PDU 252
|
|
|
|
-#define LINKTYPE_MATCHING_MAX 252 /* highest value in the "matching" range */
|
|
+/*
|
|
+ * Link-layer header type for the netlink protocol (nlmon devices).
|
|
+ */
|
|
+#define LINKTYPE_NETLINK 253
|
|
+
|
|
+#define LINKTYPE_MATCHING_MAX 253 /* highest value in the "matching" range */
|
|
|
|
static struct linktype_map {
|
|
int dlt;
|
|
diff --git a/pcap-linux.c b/pcap-linux.c
|
|
index c6fd076..1d2c130 100644
|
|
--- a/pcap-linux.c
|
|
+++ b/pcap-linux.c
|
|
@@ -2604,6 +2604,8 @@ map_packet_type_to_sll_type(short int sll_pkttype)
|
|
*/
|
|
static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
|
|
{
|
|
+ struct pcap_linux *handlep = handle->priv;
|
|
+
|
|
switch (arptype) {
|
|
|
|
case ARPHRD_ETHER:
|
|
@@ -2976,6 +2976,19 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
|
|
handle->linktype = DLT_IEEE802_15_4_NOFCS;
|
|
break;
|
|
|
|
+#ifndef ARPHRD_NETLINK
|
|
+#define ARPHRD_NETLINK 824
|
|
+#endif
|
|
+ case ARPHRD_NETLINK:
|
|
+ handle->linktype = DLT_NETLINK;
|
|
+ /*
|
|
+ * We need to use cooked mode, so that in sll_protocol we
|
|
+ * pick up the netlink protocol type such as NETLINK_ROUTE,
|
|
+ * NETLINK_GENERIC, NETLINK_FIB_LOOKUP, etc.
|
|
+ */
|
|
+ handlep->cooked = 1;
|
|
+ break;
|
|
+
|
|
default:
|
|
handle->linktype = -1;
|
|
break;
|
|
@@ -3181,7 +3194,8 @@ activate_new(pcap_t *handle)
|
|
* same applies to LAPD capture.
|
|
*/
|
|
if (handle->linktype != DLT_LINUX_IRDA &&
|
|
- handle->linktype != DLT_LINUX_LAPD)
|
|
+ handle->linktype != DLT_LINUX_LAPD &&
|
|
+ handle->linktype != DLT_NETLINK)
|
|
handle->linktype = DLT_LINUX_SLL;
|
|
}
|
|
|
|
diff --git a/pcap.c b/pcap.c
|
|
index 6b16cea..83d4bb1 100644
|
|
--- a/pcap.c
|
|
+++ b/pcap.c
|
|
@@ -1203,6 +1203,7 @@ static struct dlt_choice dlt_choices[] = {
|
|
DLT_CHOICE(DLT_NETANALYZER_TRANSPARENT, "Ethernet with Hilscher netANALYZER pseudo-header and with preamble and SFD"),
|
|
DLT_CHOICE(DLT_IPOIB, "RFC 4391 IP-over-Infiniband"),
|
|
DLT_CHOICE(DLT_DBUS, "D-Bus"),
|
|
+ DLT_CHOICE(DLT_NETLINK, "Linux netlink"),
|
|
DLT_CHOICE_SENTINEL
|
|
};
|
|
|
|
diff --git a/pcap/bpf.h b/pcap/bpf.h
|
|
index 608ef39..d30bf95 100644
|
|
--- a/pcap/bpf.h
|
|
+++ b/pcap/bpf.h
|
|
@@ -1243,7 +1243,12 @@ struct bpf_program {
|
|
*/
|
|
#define DLT_WIRESHARK_UPPER_PDU 252
|
|
|
|
-#define DLT_MATCHING_MAX 252 /* highest value in the "matching" range */
|
|
+/*
|
|
+ * DLT type for the netlink protocol (nlmon devices).
|
|
+ */
|
|
+#define DLT_NETLINK 253
|
|
+
|
|
+#define DLT_MATCHING_MAX 253 /* highest value in the "matching" range */
|
|
|
|
/*
|
|
* DLT and savefile link type values are split into a class and
|