]> The Tcpdump Group git mirrors - libpcap/commitdiff
Add support for CARP.
authorGeorge Neville-Neil <[email protected]>
Sun, 20 Nov 2011 00:57:03 +0000 (16:57 -0800)
committerGuy Harris <[email protected]>
Sun, 20 Nov 2011 00:57:40 +0000 (16:57 -0800)
Allow "carp" to be used as a filter, rather than requiring "ip proto
112" or one of "ip proto {vrrp,carp}" depending on whether you're
running an OS that chooses to have 112 as CARP rather than VRRP in
/etc/protocols.  (Yes, that means that "carp" will capture VRRP
packets.  So it goes....)

Reviewed-By: Guy Harris <[email protected]>
gencode.c
gencode.h
grammar.y
scanner.l

index b3d36a8c4e928beb99e0fce459e35e0cb4060561..ff90fbb8333a4d4e6529813f9e2dd3c070d9479f 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -4666,6 +4666,9 @@ gen_host(addr, mask, proto, dir, type)
        case Q_VRRP:
                bpf_error("'vrrp' modifier applied to %s", typestr);
 
+       case Q_CARP:
+               bpf_error("'carp' modifier applied to %s", typestr);
+
        case Q_ATALK:
                bpf_error("ATALK host filtering not implemented");
 
@@ -4785,6 +4788,9 @@ gen_host6(addr, mask, proto, dir, type)
        case Q_VRRP:
                bpf_error("'vrrp' modifier applied to %s", typestr);
 
+       case Q_CARP:
+               bpf_error("'carp' modifier applied to %s", typestr);
+
        case Q_ATALK:
                bpf_error("ATALK host filtering not implemented");
 
@@ -5000,6 +5006,14 @@ gen_proto_abbrev(proto)
                b1 = gen_proto(IPPROTO_VRRP, Q_IP, Q_DEFAULT);
                break;
 
+#ifndef IPPROTO_CARP
+#define IPPROTO_CARP   112
+#endif
+
+       case Q_CARP:
+               b1 = gen_proto(IPPROTO_CARP, Q_IP, Q_DEFAULT);
+               break;
+
        case Q_IP:
                b1 =  gen_linktype(ETHERTYPE_IP);
                break;
@@ -6159,6 +6173,10 @@ gen_proto(v, proto, dir)
                bpf_error("'vrrp proto' is bogus");
                /* NOTREACHED */
 
+       case Q_CARP:
+               bpf_error("'carp proto' is bogus");
+               /* NOTREACHED */
+
 #ifdef INET6
        case Q_IPV6:
                b0 = gen_linktype(ETHERTYPE_IPV6);
@@ -7020,6 +7038,7 @@ gen_load(proto, inst, size)
        case Q_IGRP:
        case Q_PIM:
        case Q_VRRP:
+       case Q_CARP:
                /*
                 * The offset is relative to the beginning of
                 * the transport-layer header.
index 4f710038b3155b3ca84a89b8c40e642c8660b2cd..e8b0593da9a3ca1000f766a5cc4cddbb9f5fd6ea 100644 (file)
--- a/gencode.h
+++ b/gencode.h
 
 #define Q_RADIO                40
 
+#define Q_CARP         41
+
 /* Directional qualifiers. */
 
 #define Q_SRC          1
index cbb93639bed4f68b6febb6029512ea34574a57e9..f2ba28b1e5f7984dae54ab4619104f889c917567 100644 (file)
--- a/grammar.y
+++ b/grammar.y
@@ -272,7 +272,7 @@ pfaction_to_num(const char *action)
 
 %token  DST SRC HOST GATEWAY
 %token  NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
-%token  ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP
+%token  ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP CARP
 %token  ATALK AARP DECNET LAT SCA MOPRC MOPDL
 %token  TK_BROADCAST TK_MULTICAST
 %token  NUM INBOUND OUTBOUND
@@ -466,6 +466,7 @@ pname:        LINK                  { $$ = Q_LINK; }
        | IGRP                  { $$ = Q_IGRP; }
        | PIM                   { $$ = Q_PIM; }
        | VRRP                  { $$ = Q_VRRP; }
+       | CARP                  { $$ = Q_CARP; }
        | ATALK                 { $$ = Q_ATALK; }
        | AARP                  { $$ = Q_AARP; }
        | DECNET                { $$ = Q_DECNET; }
index 2b1f729d55b93dfac79672bcffda55e020e55ae8..064e9c885fbc264e63efae27e60e1bc01178bd2c 100644 (file)
--- a/scanner.l
+++ b/scanner.l
@@ -203,6 +203,7 @@ igmp                return IGMP;
 igrp           return IGRP;
 pim            return PIM;
 vrrp           return VRRP;
+carp           return CARP;
 radio          return RADIO;
 
 ip6            {