]> The Tcpdump Group git mirrors - libpcap/commitdiff
Tony Li's changes, from FreeBSD, to support filtering for OSI packets
authorguy <guy>
Sat, 28 Oct 2000 09:30:20 +0000 (09:30 +0000)
committerguy <guy>
Sat, 28 Oct 2000 09:30:20 +0000 (09:30 +0000)
and for ESIS and ISIS packets.

CREDITS
FILES
gencode.c
gencode.h
grammar.y
nlpid.h [new file with mode: 0644]
scanner.l

diff --git a/CREDITS b/CREDITS
index 24c76c0751fe5e5e467f35b94fe3ad31aab7732a..56eb8703ad1ea719913ec83d3f1d2b2c815b2b8a 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -23,6 +23,7 @@ Additional people who have contributed patches:
        Peter Jeremy                    <[email protected]>
        Rafal Maszkowski                <[email protected]>
        Rick Jones                      <[email protected]>
+       Tony Li                         <[email protected]>
 
 The original LBL crew:
        Steve McCanne
diff --git a/FILES b/FILES
index 2588bb4b8eacc62f6e5c4e3b3011e8acc4411886..d558b294187a234a47209fb33fa5299554bfcc1c 100644 (file)
--- a/FILES
+++ b/FILES
@@ -35,6 +35,7 @@ linux-include/netinet/if_ether.h
 linux-include/netinet/ip_var.h
 mkdep
 nametoaddr.c
+nlpid.h
 optimize.c
 pcap-bpf.c
 pcap-dlpi.c
index 394290b5fa6769cb7a8d41300ab2d9d5dedee25a..ea844903b1a8b74c85109358f532d1565ef29abb 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -21,7 +21,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.128 2000-10-28 09:06:06 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.129 2000-10-28 09:30:21 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -50,6 +50,7 @@ struct rtentry;
 #include "pcap-int.h"
 
 #include "ethertype.h"
+#include "nlpid.h"
 #include "gencode.h"
 #include "ppp.h"
 #include <pcap-namedb.h>
@@ -58,6 +59,10 @@ struct rtentry;
 #include <sys/socket.h>
 #endif /*INET6*/
 
+#define LLC_ISO_LSAP   0xfe
+
+#define ETHERMTU       1500
+
 #ifdef HAVE_OS_PROTO_H
 #include "os-proto.h"
 #endif
@@ -730,6 +735,17 @@ gen_linktype(proto)
                 */
                switch (proto) {
 
+               case LLC_ISO_LSAP:
+                       /*
+                        * OSI protocols always use 802.2 encapsulation.
+                        */
+                       b0 = gen_cmp_gt(off_linktype, BPF_H, ETHERMTU);
+                       gen_not(b0);
+                       b1 = gen_cmp(off_linktype + 2, BPF_H, (long)
+                                    ((LLC_ISO_LSAP << 8) | LLC_ISO_LSAP));
+                       gen_and(b0, b1);
+                       return b1;
+
                case ETHERTYPE_ATALK:
                case ETHERTYPE_AARP:
                        /*
@@ -742,7 +758,7 @@ gen_linktype(proto)
                         * we check for an Ethernet type field less than
                         * 1500, which means it's an 802.3 length field.
                         */
-                       b0 = gen_cmp_gt(off_linktype, BPF_H, 1500);
+                       b0 = gen_cmp_gt(off_linktype, BPF_H, ETHERMTU);
                        gen_not(b0);
 
                        /*
@@ -1143,6 +1159,9 @@ gen_dnhostop(addr, dir, base_off)
                gen_or(b0, b1);
                return b1;
 
+       case Q_ISO:
+               bpf_error("ISO host filtering not implemented");
+               
        default:
                abort();
        }
@@ -1528,6 +1547,18 @@ gen_proto_abbrev(proto)
 #endif
                break;
 
+       case Q_ISO:
+               b1 = gen_linktype(LLC_ISO_LSAP);
+               break;
+
+       case Q_ESIS:
+               b1 = gen_proto(ISO9542_ESIS, Q_ISO, Q_DEFAULT);
+               break;
+
+       case Q_ISIS:
+               b1 = gen_proto(ISO10589_ISIS, Q_ISO, Q_DEFAULT);
+               break;
+
        default:
                abort();
        }
@@ -2099,6 +2130,12 @@ gen_proto(v, proto, dir)
                gen_and(b0, b1);
                return b1;
 
+       case Q_ISO:
+               b0 = gen_linktype(LLC_ISO_LSAP);
+               b1 = gen_cmp(off_nl + 3, BPF_B, (long)v);
+               gen_and(b0, b1);
+               return b1;
+
        case Q_ARP:
                bpf_error("arp does not encapsulate another protocol");
                /* NOTREACHED */
@@ -2914,6 +2951,9 @@ gen_greater(n)
        return gen_len(BPF_JGE, n);
 }
 
+/*
+ * Actually, this is less than or equal.
+ */
 struct block *
 gen_less(n)
        int n;
index d022d9011f12d76dcea2f0c74640001c2bbc343b..345fe62e64d3e84e1d5ed5e66e09f857faf1a255 100644 (file)
--- a/gencode.h
+++ b/gencode.h
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.44 2000-10-28 08:19:29 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.45 2000-10-28 09:30:21 guy Exp $ (LBL)
  */
 
 /* Address qualifiers. */
 
 #define        Q_AARP          21
 
+#define Q_ISO          22
+#define Q_ESIS         23
+#define Q_ISIS         24
+
 /* Directional qualifiers. */
 
 #define Q_SRC          1
index f441ad3388e8891d3024af4155bd2f3127cc5341..9ca8e02f5551842e3b8111fbb8b43172f7273413 100644 (file)
--- a/grammar.y
+++ b/grammar.y
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.62 2000-10-28 08:19:30 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.63 2000-10-28 09:30:22 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -117,6 +117,7 @@ pcap_parse()
 %token  LEN
 %token  IPV6 ICMPV6 AH ESP
 %token VLAN
+%token  ISO ESIS ISIS
 
 %type  <s> ID
 %type  <e> EID
@@ -258,6 +259,9 @@ pname:        LINK                  { $$ = Q_LINK; }
        | ICMPV6                { $$ = Q_ICMPV6; }
        | AH                    { $$ = Q_AH; }
        | ESP                   { $$ = Q_ESP; }
+       | ISO                   { $$ = Q_ISO; }
+       | ESIS                  { $$ = Q_ESIS; }
+       | ISIS                  { $$ = Q_ISIS; }
        ;
 other:   pqual TK_BROADCAST    { $$ = gen_broadcast($1); }
        | pqual TK_MULTICAST    { $$ = gen_multicast($1); }
diff --git a/nlpid.h b/nlpid.h
new file mode 100644 (file)
index 0000000..87ee381
--- /dev/null
+++ b/nlpid.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1996
+ *     Juniper Networks, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution.  The name of Juniper Networks may not
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#) $Header: /tcpdump/master/libpcap/nlpid.h,v 1.1 2000-10-28 09:30:22 guy Exp $ (Juniper)
+ */
+
+/* Types missing from some systems */
+
+/*
+ * Network layer prototocol identifiers
+ */
+#ifndef ISO8473_CLNP
+#define ISO8473_CLNP           0x81
+#endif
+#ifndef        ISO9542_ESIS
+#define        ISO9542_ESIS            0x82
+#endif
+#ifndef ISO9542X25_ESIS
+#define ISO9542X25_ESIS                0x8a
+#endif
+#ifndef        ISO10589_ISIS
+#define        ISO10589_ISIS           0x83
+#endif
+#ifndef ISO8878A_CONS
+#define        ISO8878A_CONS           0x84
+#endif
+#ifndef        ISO10747_IDRP
+#define        ISO10747_IDRP           0x85
+#endif
index 98841c5354ef11ac765dcfd054a9ffe8bf8abaa4..1bf1965c4d926d4f7c5f2a24d4c6e4bf08ea162e 100644 (file)
--- a/scanner.l
+++ b/scanner.l
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.68 2000-10-28 08:19:30 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.69 2000-10-28 09:30:22 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -190,6 +190,12 @@ sca                return SCA;
 moprc          return MOPRC;
 mopdl          return MOPDL;
 
+iso            return ISO;
+esis           return ESIS;
+es-is          return ESIS;
+isis           return ISIS;
+is-is          return ISIS;
+
 host           return HOST;
 net            return NET;
 mask           return MASK;