#endif
#ifndef INET6
static struct block *gen_gateway(compiler_state_t *, const u_char *,
- struct addrinfo *, int, int);
+ struct addrinfo *, int);
#endif
static struct block *gen_ipfrag(compiler_state_t *);
static struct block *gen_portatom(compiler_state_t *, int, bpf_u_int32);
#if !defined(NO_PROTOCHAIN)
static struct block *gen_protochain(compiler_state_t *, bpf_u_int32, int);
#endif /* !defined(NO_PROTOCHAIN) */
-static struct block *gen_proto(compiler_state_t *, bpf_u_int32, int, int);
+static struct block *gen_proto(compiler_state_t *, bpf_u_int32, int);
static struct slist *xfer_to_x(compiler_state_t *, struct arth *);
static struct slist *xfer_to_a(compiler_state_t *, struct arth *);
static struct block *gen_mac_multicast(compiler_state_t *, int);
#endif
#ifndef INET6
+/*
+ * This primitive is non-directional by design, so the grammar does not allow
+ * to qualify it with a direction.
+ */
static struct block *
gen_gateway(compiler_state_t *cstate, const u_char *eaddr,
- struct addrinfo *alist, int proto, int dir)
+ struct addrinfo *alist, int proto)
{
struct block *b0, *b1, *tmp;
struct addrinfo *ai;
struct sockaddr_in *sin;
- if (dir != 0)
- bpf_error(cstate, "direction applied to 'gateway'");
-
switch (proto) {
case Q_DEFAULT:
case Q_IP:
switch (proto) {
case Q_SCTP:
- b1 = gen_proto(cstate, IPPROTO_SCTP, Q_DEFAULT, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_SCTP, Q_DEFAULT);
break;
case Q_TCP:
- b1 = gen_proto(cstate, IPPROTO_TCP, Q_DEFAULT, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_TCP, Q_DEFAULT);
break;
case Q_UDP:
- b1 = gen_proto(cstate, IPPROTO_UDP, Q_DEFAULT, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_UDP, Q_DEFAULT);
break;
case Q_ICMP:
- b1 = gen_proto(cstate, IPPROTO_ICMP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_ICMP, Q_IP);
break;
#ifndef IPPROTO_IGMP
#endif
case Q_IGMP:
- b1 = gen_proto(cstate, IPPROTO_IGMP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_IGMP, Q_IP);
break;
#ifndef IPPROTO_IGRP
#define IPPROTO_IGRP 9
#endif
case Q_IGRP:
- b1 = gen_proto(cstate, IPPROTO_IGRP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_IGRP, Q_IP);
break;
#ifndef IPPROTO_PIM
#endif
case Q_PIM:
- b1 = gen_proto(cstate, IPPROTO_PIM, Q_DEFAULT, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_PIM, Q_DEFAULT);
break;
#ifndef IPPROTO_VRRP
#endif
case Q_VRRP:
- b1 = gen_proto(cstate, IPPROTO_VRRP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_VRRP, Q_IP);
break;
#ifndef IPPROTO_CARP
#endif
case Q_CARP:
- b1 = gen_proto(cstate, IPPROTO_CARP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_CARP, Q_IP);
break;
case Q_IP:
#define IPPROTO_ICMPV6 58
#endif
case Q_ICMPV6:
- b1 = gen_proto(cstate, IPPROTO_ICMPV6, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_ICMPV6, Q_IPV6);
break;
#ifndef IPPROTO_AH
#define IPPROTO_AH 51
#endif
case Q_AH:
- b1 = gen_proto(cstate, IPPROTO_AH, Q_DEFAULT, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_AH, Q_DEFAULT);
break;
#ifndef IPPROTO_ESP
#define IPPROTO_ESP 50
#endif
case Q_ESP:
- b1 = gen_proto(cstate, IPPROTO_ESP, Q_DEFAULT, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_ESP, Q_DEFAULT);
break;
case Q_ISO:
break;
case Q_ESIS:
- b1 = gen_proto(cstate, ISO9542_ESIS, Q_ISO, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISO9542_ESIS, Q_ISO);
break;
case Q_ISIS:
- b1 = gen_proto(cstate, ISO10589_ISIS, Q_ISO, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISO10589_ISIS, Q_ISO);
break;
case Q_ISIS_L1: /* all IS-IS Level1 PDU-Types */
- b0 = gen_proto(cstate, ISIS_L1_LAN_IIH, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT); /* FIXME extract the circuit-type bits */
+ b0 = gen_proto(cstate, ISIS_L1_LAN_IIH, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS); /* FIXME extract the circuit-type bits */
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L1_LSP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_LSP, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS);
gen_or(b0, b1);
break;
case Q_ISIS_L2: /* all IS-IS Level2 PDU-Types */
- b0 = gen_proto(cstate, ISIS_L2_LAN_IIH, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT); /* FIXME extract the circuit-type bits */
+ b0 = gen_proto(cstate, ISIS_L2_LAN_IIH, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS); /* FIXME extract the circuit-type bits */
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L2_LSP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_LSP, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS);
gen_or(b0, b1);
break;
case Q_ISIS_IIH: /* all IS-IS Hello PDU-Types */
- b0 = gen_proto(cstate, ISIS_L1_LAN_IIH, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_L2_LAN_IIH, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_LAN_IIH, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_L2_LAN_IIH, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS);
gen_or(b0, b1);
break;
case Q_ISIS_LSP:
- b0 = gen_proto(cstate, ISIS_L1_LSP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_L2_LSP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_LSP, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_L2_LSP, Q_ISIS);
gen_or(b0, b1);
break;
case Q_ISIS_SNP:
- b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS);
gen_or(b0, b1);
- b0 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS);
gen_or(b0, b1);
break;
case Q_ISIS_CSNP:
- b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS);
gen_or(b0, b1);
break;
case Q_ISIS_PSNP:
- b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS);
+ b1 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS);
gen_or(b0, b1);
break;
case Q_CLNP:
- b1 = gen_proto(cstate, ISO8473_CLNP, Q_ISO, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISO8473_CLNP, Q_ISO);
break;
case Q_STP:
}
#if !defined(NO_PROTOCHAIN)
+/*
+ * This primitive is non-directional by design, so the grammar does not allow
+ * to qualify it with a direction.
+ */
static struct block *
gen_protochain(compiler_state_t *cstate, bpf_u_int32 v, int proto)
{
*
* If <proto> is Q_DEFAULT, i.e. just "proto" was specified, it checks
* against Q_IP and Q_IPV6.
+ *
+ * This primitive is non-directional by design, so the grammar does not allow
+ * to qualify it with a direction.
*/
static struct block *
-gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir)
+gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto)
{
struct block *b0, *b1;
struct block *b2;
- if (dir != Q_DEFAULT)
- bpf_error(cstate, "direction applied to 'proto'");
-
switch (proto) {
case Q_DEFAULT:
- b0 = gen_proto(cstate, v, Q_IP, dir);
- b1 = gen_proto(cstate, v, Q_IPV6, dir);
+ b0 = gen_proto(cstate, v, Q_IP);
+ b1 = gen_proto(cstate, v, Q_IPV6);
gen_or(b0, b1);
return b1;
break; // invalid qualifier
case Q_ISIS:
- b0 = gen_proto(cstate, ISO10589_ISIS, Q_ISO, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISO10589_ISIS, Q_ISO);
/*
* 4 is the offset of the PDU type relative to the IS-IS
* header.
cstate->ai = res;
if (res == NULL)
bpf_error(cstate, "unknown host '%s'", name);
- b = gen_gateway(cstate, eaddr, res, proto, dir);
+ b = gen_gateway(cstate, eaddr, res, proto);
cstate->ai = NULL;
freeaddrinfo(res);
free(eaddr);
case Q_PROTO:
real_proto = lookup_proto(cstate, name, proto);
if (real_proto >= 0)
- return gen_proto(cstate, real_proto, proto, dir);
+ return gen_proto(cstate, real_proto, proto);
else
bpf_error(cstate, "unknown protocol: %s", name);
/*NOTREACHED*/
case Q_PROTO:
- return gen_proto(cstate, v, proto, dir);
+ return gen_proto(cstate, v, proto);
#if !defined(NO_PROTOCHAIN)
case Q_PROTOCHAIN: