File libpcap-netlink.patch of Package libpcap.2975

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