]> The Tcpdump Group git mirrors - libpcap/commitdiff
add support for DLT_JUNIPER_ATM1 (137) and DLT_JUNIPER_ATM2 (135)
authorhannes <hannes>
Tue, 19 Oct 2004 15:55:28 +0000 (15:55 +0000)
committerhannes <hannes>
Tue, 19 Oct 2004 15:55:28 +0000 (15:55 +0000)
gencode.c
pcap.c

index e8c5fb0f70ed7ea6638b38986b766a1838a47be6..3889ba363b7b537ec127c8225e25438704d39aae 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -21,7 +21,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.209 2004-08-27 07:37:10 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.210 2004-10-19 15:55:28 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -1016,6 +1016,18 @@ init_linktype(type)
                off_nl_nosnap = PFLOG_HDRLEN;
                return;
 
+       case DLT_JUNIPER_ATM1:
+                off_linktype = 4; /* in reality variable between 4-8 */
+               off_nl = 4;
+               off_nl_nosnap = 14;
+               return;
+
+       case DLT_JUNIPER_ATM2:
+                off_linktype = 8; /* in reality variable between 8-12 */
+               off_nl = 8;
+               off_nl_nosnap = 18;
+               return;
+
 #ifdef DLT_PFSYNC
        case DLT_PFSYNC:
                off_linktype = -1;
@@ -1794,6 +1806,17 @@ gen_linktype(proto)
                /*NOTREACHED*/
                break;
 
+        case DLT_JUNIPER_ATM1:
+        case DLT_JUNIPER_ATM2:
+            /* just lets verify the magic number for now - 
+             * we may have upto 6 different encapsulations on the wire
+             * and need a lot of heuristics to figure out that the payload
+             * might be;
+             *
+             * FIXME encapsulation specific BPF_ filters
+             */
+            return gen_mcmp(0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
+
        case DLT_LINUX_IRDA:
                bpf_error("IrDA link-layer type filtering not implemented");
 
@@ -5079,6 +5102,19 @@ gen_inbound(dir)
                 }
                 break;
 
+        case DLT_JUNIPER_ATM1:
+        case DLT_JUNIPER_ATM2:
+                /* juniper flags (including direction) are stored
+                 * the byte after the 3-byte magic number */
+                if (dir) {
+                    /* match outgoing packets */
+                    b0 = gen_mcmp(3, BPF_B, 0, 0x01);
+                } else {
+                    /* match incoming packets */
+                    b0 = gen_mcmp(3, BPF_B, 1, 0x01);
+                }
+            break;
+
        default:
                bpf_error("inbound/outbound not supported on linktype %d",
                    linktype);
diff --git a/pcap.c b/pcap.c
index 7bf337449951164f59c252f4434e41c7deb7c360..eb4cd957f6b33e399d15055cc72424661efe738a 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -33,7 +33,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.75 2004-10-19 07:06:14 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.76 2004-10-19 15:55:28 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -352,6 +352,8 @@ static struct dlt_choice dlt_choices[] = {
        DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
        DLT_CHOICE(DLT_IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
         DLT_CHOICE(DLT_SYMANTEC_FIREWALL, "Symantec Firewall"),
+        DLT_CHOICE(DLT_JUNIPER_ATM1, "Juniper ATM1 PIC"),
+        DLT_CHOICE(DLT_JUNIPER_ATM2, "Juniper ATM2 PIC"),
        DLT_CHOICE_SENTINEL
 };