]> The Tcpdump Group git mirrors - libpcap/commitdiff
SCTP support from Armando L. Caro Jr. <[email protected]>
authorfenner <fenner>
Thu, 10 May 2001 14:48:01 +0000 (14:48 +0000)
committerfenner <fenner>
Thu, 10 May 2001 14:48:01 +0000 (14:48 +0000)
CREDITS
gencode.c
gencode.h
grammar.y
scanner.l

diff --git a/CREDITS b/CREDITS
index 8f2da760fe8a7cd2cfed4b8daecd68d0aa7f978b..62a9e34ab0e73594709d28f9a6dfea26afa55206 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -13,6 +13,7 @@ The current maintainers:
 Additional people who have contributed patches:
 
        Arkadiusz Miskiewicz            <[email protected]>
+       Armando L. Caro Jr.             <[email protected]>
        Fulvio Risso                    <[email protected]>
        Charles M. Hannum               <[email protected]>
        Chris G. Demetriou              <[email protected]>
index 642a484284215ac421f9eeb6f4bc577f84590c0c..e85f6cfd07e056796ce9816c632055fc9ccbb9e9 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.151 2001-04-17 08:25:21 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.152 2001-05-10 14:48:01 fenner Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -64,6 +64,10 @@ struct rtentry;
 
 #define ETHERMTU       1500
 
+#ifndef IPPROTO_SCTP
+#define IPPROTO_SCTP 132
+#endif
+
 #ifdef HAVE_OS_PROTO_H
 #include "os-proto.h"
 #endif
@@ -1734,6 +1738,9 @@ gen_host(addr, mask, proto, dir)
        case Q_TCP:
                bpf_error("'tcp' modifier applied to host");
 
+       case Q_SCTP:
+               bpf_error("'sctp' modifier applied to host");
+
        case Q_UDP:
                bpf_error("'udp' modifier applied to host");
 
@@ -1836,6 +1843,9 @@ gen_host6(addr, mask, proto, dir)
        case Q_ARP:
                bpf_error("'arp' modifier applied to ip6 host");
 
+       case Q_SCTP:
+               bpf_error("'sctp' modifier applied to host");
+
        case Q_TCP:
                bpf_error("'tcp' modifier applied to host");
 
@@ -1973,6 +1983,14 @@ gen_proto_abbrev(proto)
 
        switch (proto) {
 
+       case Q_SCTP:
+               b1 = gen_proto(IPPROTO_SCTP, Q_IP, Q_DEFAULT);
+#ifdef INET6
+               b0 = gen_proto(IPPROTO_SCTP, Q_IPV6, Q_DEFAULT);
+               gen_or(b0, b1);
+#endif
+               break;
+
        case Q_TCP:
                b1 = gen_proto(IPPROTO_TCP, Q_IP, Q_DEFAULT);
 #ifdef INET6
@@ -2243,6 +2261,7 @@ gen_port(port, ip_proto, dir)
        switch (ip_proto) {
        case IPPROTO_UDP:
        case IPPROTO_TCP:
+       case IPPROTO_SCTP:
                b1 = gen_portop(port, ip_proto, dir);
                break;
 
@@ -2250,6 +2269,8 @@ gen_port(port, ip_proto, dir)
                tmp = gen_portop(port, IPPROTO_TCP, dir);
                b1 = gen_portop(port, IPPROTO_UDP, dir);
                gen_or(tmp, b1);
+               tmp = gen_portop(port, IPPROTO_SCTP, dir);
+               gen_or(tmp, b1);
                break;
 
        default:
@@ -2313,6 +2334,7 @@ gen_port6(port, ip_proto, dir)
        switch (ip_proto) {
        case IPPROTO_UDP:
        case IPPROTO_TCP:
+       case IPPROTO_SCTP:
                b1 = gen_portop6(port, ip_proto, dir);
                break;
 
@@ -2320,6 +2342,8 @@ gen_port6(port, ip_proto, dir)
                tmp = gen_portop6(port, IPPROTO_TCP, dir);
                b1 = gen_portop6(port, IPPROTO_UDP, dir);
                gen_or(tmp, b1);
+               tmp = gen_portop6(port, IPPROTO_SCTP, dir);
+               gen_or(tmp, b1);
                break;
 
        default:
@@ -2753,6 +2777,10 @@ gen_proto(v, proto, dir)
                bpf_error("'tcp proto' is bogus");
                /* NOTREACHED */
 
+       case Q_SCTP:
+               bpf_error("'sctp proto' is bogus");
+               /* NOTREACHED */
+
        case Q_ICMP:
                bpf_error("'icmp proto' is bogus");
                /* NOTREACHED */
@@ -2950,13 +2978,16 @@ gen_scode(name, q)
                }
 
        case Q_PORT:
-               if (proto != Q_DEFAULT && proto != Q_UDP && proto != Q_TCP)
+               if (proto != Q_DEFAULT &&
+                   proto != Q_UDP && proto != Q_TCP && proto != Q_SCTP)
                        bpf_error("illegal qualifier of 'port'");
                if (pcap_nametoport(name, &port, &real_proto) == 0)
                        bpf_error("unknown port '%s'", name);
                if (proto == Q_UDP) {
                        if (real_proto == IPPROTO_TCP)
                                bpf_error("port '%s' is tcp", name);
+                       else if (real_proto == IPPROTO_SCTP)
+                               bpf_error("port '%s' is sctp", name);
                        else
                                /* override PROTO_UNDEF */
                                real_proto = IPPROTO_UDP;
@@ -2964,10 +2995,23 @@ gen_scode(name, q)
                if (proto == Q_TCP) {
                        if (real_proto == IPPROTO_UDP)
                                bpf_error("port '%s' is udp", name);
+
+                       else if (real_proto == IPPROTO_SCTP)
+                               bpf_error("port '%s' is sctp", name);
                        else
                                /* override PROTO_UNDEF */
                                real_proto = IPPROTO_TCP;
                }
+               if (proto == Q_SCTP) {
+                       if (real_proto == IPPROTO_UDP)
+                               bpf_error("port '%s' is udp", name);
+
+                       else if (real_proto == IPPROTO_TCP)
+                               bpf_error("port '%s' is tcp", name);
+                       else
+                               /* override PROTO_UNDEF */
+                               real_proto = IPPROTO_SCTP;
+               }
 #ifndef INET6
                return gen_port(port, real_proto, dir);
 #else
@@ -3105,6 +3149,8 @@ gen_ncode(s, v, q)
                        proto = IPPROTO_UDP;
                else if (proto == Q_TCP)
                        proto = IPPROTO_TCP;
+               else if (proto == Q_SCTP)
+                       proto = IPPROTO_SCTP;
                else if (proto == Q_DEFAULT)
                        proto = PROTO_UNDEF;
                else
@@ -3317,6 +3363,7 @@ gen_load(proto, index, size)
                index->b = b;
                break;
 
+       case Q_SCTP:
        case Q_TCP:
        case Q_UDP:
        case Q_ICMP:
index 87d9bf5f63d9730bef7f336852d8513118c40a9d..a1ad10fc25742768ba9f9f3d121ae73a1d342de8 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.52 2001-04-17 08:25:22 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.53 2001-05-10 14:48:02 fenner Exp $ (LBL)
  */
 
 /* Address qualifiers. */
 #define Q_IP           2
 #define Q_ARP          3
 #define Q_RARP         4
-#define Q_TCP          5
-#define Q_UDP          6
-#define Q_ICMP         7
-#define Q_IGMP         8
-#define Q_IGRP         9
+#define Q_SCTP         5
+#define Q_TCP          6
+#define Q_UDP          7
+#define Q_ICMP         8
+#define Q_IGMP         9
+#define Q_IGRP         10
 
 
-#define        Q_ATALK         10
-#define        Q_DECNET        11
-#define        Q_LAT           12
-#define Q_SCA          13
-#define        Q_MOPRC         14
-#define        Q_MOPDL         15
+#define        Q_ATALK         11
+#define        Q_DECNET        12
+#define        Q_LAT           13
+#define Q_SCA          14
+#define        Q_MOPRC         15
+#define        Q_MOPDL         16
 
 
-#define Q_IPV6         16
-#define Q_ICMPV6       17
-#define Q_AH           18
-#define Q_ESP          19
+#define Q_IPV6         17
+#define Q_ICMPV6       18
+#define Q_AH           19
+#define Q_ESP          20
 
-#define Q_PIM          20
-#define Q_VRRP         21
+#define Q_PIM          21
+#define Q_VRRP         22
 
-#define Q_AARP         22
+#define Q_AARP         23
 
-#define Q_ISO          23
-#define Q_ESIS         24
-#define Q_ISIS         25
-#define Q_CLNP         26
+#define Q_ISO          24
+#define Q_ESIS         25
+#define Q_ISIS         26
+#define Q_CLNP         27
 
-#define Q_STP          27
+#define Q_STP          28
 
-#define Q_IPX          28
+#define Q_IPX          29
 
-#define Q_NETBEUI      29
+#define Q_NETBEUI      30
 
 /* Directional qualifiers. */
 
index 1fceb5532a352403db846f35a44554d0b045d1ac..c554cc64b87d9a9c553137151ac4599e984ed3fc 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.69 2001-04-17 08:25:23 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.70 2001-05-10 14:48:03 fenner Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -106,7 +106,7 @@ pcap_parse()
 
 %token  DST SRC HOST GATEWAY
 %token  NET MASK PORT LESS GREATER PROTO PROTOCHAIN BYTE
-%token  ARP RARP IP TCP UDP ICMP IGMP IGRP PIM VRRP
+%token  ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP
 %token  ATALK AARP DECNET LAT SCA MOPRC MOPDL
 %token  TK_BROADCAST TK_MULTICAST
 %token  NUM INBOUND OUTBOUND
@@ -247,6 +247,7 @@ pname:        LINK                  { $$ = Q_LINK; }
        | IP                    { $$ = Q_IP; }
        | ARP                   { $$ = Q_ARP; }
        | RARP                  { $$ = Q_RARP; }
+       | SCTP                  { $$ = Q_SCTP; }
        | TCP                   { $$ = Q_TCP; }
        | UDP                   { $$ = Q_UDP; }
        | ICMP                  { $$ = Q_ICMP; }
index f0c733a6b3a227f03fc4c2f50b822927dcbbf5ba..03e3fe2051a79752a778b1724b77c16b245829e2 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.76 2001-04-17 08:25:23 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.77 2001-05-10 14:48:03 fenner Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -170,6 +170,7 @@ fddi|tr             return LINK;
 arp            return ARP;
 rarp           return RARP;
 ip             return IP;
+sctp           return SCTP;
 tcp            return TCP;
 udp            return UDP;
 icmp           return ICMP;