Permalink
Browse files

Add support for CARP.

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 <guy@alum.mit.edu>
  • Loading branch information...
1 parent b107f95 commit 7af986fc6de4a522e7c844a36568aceaebc8fbaa @gvnn3 gvnn3 committed with guyharris Nov 20, 2011
Showing with 24 additions and 1 deletion.
  1. +19 −0 gencode.c
  2. +2 −0 gencode.h
  3. +2 −1 grammar.y
  4. +1 −0 scanner.l
View
@@ -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;
@@ -6164,6 +6178,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);
@@ -7033,6 +7051,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.
View
@@ -126,6 +126,8 @@
#define Q_RADIO 40
+#define Q_CARP 41
+
/* Directional qualifiers. */
#define Q_SRC 1
View
@@ -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; }
View
@@ -203,6 +203,7 @@ igmp return IGMP;
igrp return IGRP;
pim return PIM;
vrrp return VRRP;
+carp return CARP;
radio return RADIO;
ip6 {

0 comments on commit 7af986f

Please sign in to comment.