]> The Tcpdump Group git mirrors - libpcap/commitdiff
npf: group the NdisMedium values into two sorted groups.
authorGuy Harris <[email protected]>
Sat, 26 Jun 2021 10:10:13 +0000 (03:10 -0700)
committerGuy Harris <[email protected]>
Sat, 26 Jun 2021 10:10:45 +0000 (03:10 -0700)
The first group is the group of NdisMedium values defined by Microsoft
as part of the enum; the second gropu is the group of values defined by
Npcap for its own purposes.  Both are sorted numerically, to make it
easier to determine which ones we have DLT_ values to which to map them.

(cherry picked from commit 728f4339fac6bddb0350e69cb62a862b917ad3e3)

pcap-npf.c

index bf309baafc8578ac08696b5793f4661459084a57..8efebce5bab11097e042ef50e23d19710f26c2fe 100644 (file)
@@ -1052,10 +1052,9 @@ pcap_activate_npf(pcap_t *p)
        /*Set the linktype*/
        switch (type.LinkType)
        {
-       case NdisMediumWan:
-               p->linktype = DLT_EN10MB;
-               break;
-
+       /*
+        * NDIS-defined medium types.
+        */
        case NdisMedium802_3:
                p->linktype = DLT_EN10MB;
                /*
@@ -1079,12 +1078,19 @@ pcap_activate_npf(pcap_t *p)
                }
                break;
 
+       case NdisMedium802_5:
+               /*
+                * Token Ring.
+                */
+               p->linktype = DLT_IEEE802;
+               break;
+
        case NdisMediumFddi:
                p->linktype = DLT_FDDI;
                break;
 
-       case NdisMedium802_5:
-               p->linktype = DLT_IEEE802;
+       case NdisMediumWan:
+               p->linktype = DLT_EN10MB;
                break;
 
        case NdisMediumArcnetRaw:
@@ -1099,18 +1105,29 @@ pcap_activate_npf(pcap_t *p)
                p->linktype = DLT_ATM_RFC1483;
                break;
 
-       case NdisMediumCHDLC:
-               p->linktype = DLT_CHDLC;
+       case NdisMediumWirelessWan:
+               p->linktype = DLT_RAW;
                break;
 
-       case NdisMediumPPPSerial:
-               p->linktype = DLT_PPP_SERIAL;
+       case NdisMediumIP:
+               p->linktype = DLT_RAW;
                break;
 
+       /*
+        * Npcap-defined medium types.
+        */
        case NdisMediumNull:
                p->linktype = DLT_NULL;
                break;
 
+       case NdisMediumCHDLC:
+               p->linktype = DLT_CHDLC;
+               break;
+
+       case NdisMediumPPPSerial:
+               p->linktype = DLT_PPP_SERIAL;
+               break;
+
        case NdisMediumBare80211:
                p->linktype = DLT_IEEE802_11;
                break;
@@ -1123,14 +1140,6 @@ pcap_activate_npf(pcap_t *p)
                p->linktype = DLT_PPI;
                break;
 
-       case NdisMediumWirelessWan:
-               p->linktype = DLT_RAW;
-               break;
-
-       case NdisMediumIP:
-               p->linktype = DLT_RAW;
-               break;
-
        default:
                /*
                 * An unknown medium type is assumed to supply Ethernet