]> The Tcpdump Group git mirrors - libpcap/commitdiff
Add DLT_IPV4 and DLT_IPV6.
authorGuy Harris <[email protected]>
Mon, 4 Jan 2010 20:06:40 +0000 (12:06 -0800)
committerGuy Harris <[email protected]>
Mon, 4 Jan 2010 20:06:40 +0000 (12:06 -0800)
DLT_IPV4 and DLT_IPV6 are like DLT_RAW, except that you know the version
of IP.

Also, get rid of some duplicate stuff for DLT_IPNET in savefile.c.

gencode.c
pcap.c
pcap/bpf.h
savefile.c

index 7c0702ed200149bae85e3819e2cc3d5119733f82..629ef5c7566ffd9386037c4458b4036a20071baa 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -1155,6 +1155,8 @@ init_linktype(p)
                return;
 
        case DLT_RAW:
+       case DLT_IPV4:
+       case DLT_IPV6:
                off_linktype = -1;
                off_macpl = 0;
                off_nl = 0;
@@ -3176,6 +3178,32 @@ gen_linktype(proto)
                /*NOTREACHED*/
                break;
 
+       case DLT_IPV4:
+               /*
+                * Raw IPv4, so no type field.
+                */
+               if (proto == ETHERTYPE_IP)
+                       return gen_true();              /* always true */
+
+               /* Checking for something other than IPv4; always false */
+               return gen_false();
+               /*NOTREACHED*/
+               break;
+
+       case DLT_IPV6:
+               /*
+                * Raw IPv6, so no type field.
+                */
+#ifdef INET6
+               if (proto == ETHERTYPE_IPV6)
+                       return gen_true();              /* always true */
+#endif
+
+               /* Checking for something other than IPv6; always false */
+               return gen_false();
+               /*NOTREACHED*/
+               break;
+
        case DLT_PPP:
        case DLT_PPP_PPPD:
        case DLT_PPP_SERIAL:
diff --git a/pcap.c b/pcap.c
index e81cc0149f133aa98689707b7424c1c48051c769..b0cf5f07cfb1e5c966389bee442a56acd9c9401e 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -663,6 +663,8 @@ static struct dlt_choice dlt_choices[] = {
        DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
        DLT_CHOICE(DLT_IPNET, "Solaris ipnet"),
        DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
+       DLT_CHOICE(DLT_IPV4, "Raw IPv4"),
+       DLT_CHOICE(DLT_IPV6, "Raw IPv6"),
        DLT_CHOICE_SENTINEL
 };
 
index 9df1011bc7d98cdb41081fc83cbd2550ceebc20d..706ed2372ea7dc9f724c60452d4f633f07e6b7cd 100644 (file)
@@ -953,13 +953,19 @@ struct bpf_version {
  */
 #define DLT_CAN_SOCKETCAN              227
 
+/*
+ * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
+ * whether it's v4 or v6.  Requested by Darren Reed <[email protected]>.
+ */
+#define DLT_IPV4                       228
+#define DLT_IPV6                       229
+
 /*
  * IPNET
  */
 #define        IPNET_OUTBOUND          1
 #define        IPNET_INBOUND           2
 
-
 /*
  * DLT and savefile link type values are split into a class and
  * a member of that class.  A class value of 0 indicates a regular
index 1a2f2bec60def8d88d32b718cb087e80f65a96fe..970462534ed98eb70a80f816b99fd8aa8e736d34 100644 (file)
@@ -793,7 +793,12 @@ static const char rcsid[] _U_ =
  */
 #define LINKTYPE_CAN_SOCKETCAN                 227
 
-#define        LINKTYPE_IPNET          226
+/*
+ * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
+ * whether it's v4 or v6.  Requested by Darren Reed <[email protected]>.
+ */
+#define LINKTYPE_IPV4                          228
+#define LINKTYPE_IPV6                          229
 
 
 static struct linktype_map {
@@ -1137,8 +1142,9 @@ static struct linktype_map {
        /* CAN frames with SocketCAN headers */
        { DLT_CAN_SOCKETCAN,    LINKTYPE_CAN_SOCKETCAN },
 
-       /* Solaris IPNET */
-       { DLT_IPNET,            LINKTYPE_IPNET },
+       /* Raw IPv4/IPv6 */
+       { DLT_IPV4,             LINKTYPE_IPV4 },
+       { DLT_IPV6,             LINKTYPE_IPV6 },
 
        { -1,                   -1 }
 };