1 /* $NetBSD: grammar.y,v 1.6 2015/03/31 21:39:42 christos Exp $ */
5 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that: (1) source code distributions
10 * retain the above copyright notice and this paragraph in its entirety, (2)
11 * distributions including binary code include the above copyright notice and
12 * this paragraph in its entirety in the documentation or other materials
13 * provided with the distribution, and (3) all advertising materials mentioning
14 * features or use of this software display the following acknowledgement:
15 * ``This product includes software developed by the University of California,
16 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
17 * the University nor the names of its contributors may be used to endorse
18 * or promote products derived from this software without specific prior
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 #include <sys/cdefs.h>
26 __RCSID
("$NetBSD: grammar.y,v 1.6 2015/03/31 21:39:42 christos Exp $");
33 #include <pcap-stdinc.h>
35 #include <sys/types.h>
36 #include <sys/socket.h>
47 #include <netinet/in.h>
48 #include <arpa/inet.h>
56 #ifdef HAVE_NET_PFVAR_H
58 #include <net/pfvar.h>
59 #include <net/if_pflog.h>
62 #include "ieee80211.h"
63 #include <pcap/namedb.h>
65 #ifdef HAVE_OS_PROTO_H
69 #define QSET(q, p, d, a) (q).proto = (p),\
75 const char *s
; /* string */
78 static const struct tok ieee80211_types
[] = {
79 { IEEE80211_FC0_TYPE_DATA
, "data" },
80 { IEEE80211_FC0_TYPE_MGT
, "mgt" },
81 { IEEE80211_FC0_TYPE_MGT
, "management" },
82 { IEEE80211_FC0_TYPE_CTL
, "ctl" },
83 { IEEE80211_FC0_TYPE_CTL
, "control" },
86 static const struct tok ieee80211_mgt_subtypes
[] = {
87 { IEEE80211_FC0_SUBTYPE_ASSOC_REQ
, "assocreq" },
88 { IEEE80211_FC0_SUBTYPE_ASSOC_REQ
, "assoc-req" },
89 { IEEE80211_FC0_SUBTYPE_ASSOC_RESP
, "assocresp" },
90 { IEEE80211_FC0_SUBTYPE_ASSOC_RESP
, "assoc-resp" },
91 { IEEE80211_FC0_SUBTYPE_REASSOC_REQ
, "reassocreq" },
92 { IEEE80211_FC0_SUBTYPE_REASSOC_REQ
, "reassoc-req" },
93 { IEEE80211_FC0_SUBTYPE_REASSOC_RESP
, "reassocresp" },
94 { IEEE80211_FC0_SUBTYPE_REASSOC_RESP
, "reassoc-resp" },
95 { IEEE80211_FC0_SUBTYPE_PROBE_REQ
, "probereq" },
96 { IEEE80211_FC0_SUBTYPE_PROBE_REQ
, "probe-req" },
97 { IEEE80211_FC0_SUBTYPE_PROBE_RESP
, "proberesp" },
98 { IEEE80211_FC0_SUBTYPE_PROBE_RESP
, "probe-resp" },
99 { IEEE80211_FC0_SUBTYPE_BEACON
, "beacon" },
100 { IEEE80211_FC0_SUBTYPE_ATIM
, "atim" },
101 { IEEE80211_FC0_SUBTYPE_DISASSOC
, "disassoc" },
102 { IEEE80211_FC0_SUBTYPE_DISASSOC
, "disassociation" },
103 { IEEE80211_FC0_SUBTYPE_AUTH
, "auth" },
104 { IEEE80211_FC0_SUBTYPE_AUTH
, "authentication" },
105 { IEEE80211_FC0_SUBTYPE_DEAUTH
, "deauth" },
106 { IEEE80211_FC0_SUBTYPE_DEAUTH
, "deauthentication" },
109 static const struct tok ieee80211_ctl_subtypes
[] = {
110 { IEEE80211_FC0_SUBTYPE_PS_POLL
, "ps-poll" },
111 { IEEE80211_FC0_SUBTYPE_RTS
, "rts" },
112 { IEEE80211_FC0_SUBTYPE_CTS
, "cts" },
113 { IEEE80211_FC0_SUBTYPE_ACK
, "ack" },
114 { IEEE80211_FC0_SUBTYPE_CF_END
, "cf-end" },
115 { IEEE80211_FC0_SUBTYPE_CF_END_ACK
, "cf-end-ack" },
118 static const struct tok ieee80211_data_subtypes
[] = {
119 { IEEE80211_FC0_SUBTYPE_DATA
, "data" },
120 { IEEE80211_FC0_SUBTYPE_CF_ACK
, "data-cf-ack" },
121 { IEEE80211_FC0_SUBTYPE_CF_POLL
, "data-cf-poll" },
122 { IEEE80211_FC0_SUBTYPE_CF_ACPL
, "data-cf-ack-poll" },
123 { IEEE80211_FC0_SUBTYPE_NODATA
, "null" },
124 { IEEE80211_FC0_SUBTYPE_NODATA_CF_ACK
, "cf-ack" },
125 { IEEE80211_FC0_SUBTYPE_NODATA_CF_POLL
, "cf-poll" },
126 { IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL
, "cf-ack-poll" },
127 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_DATA
, "qos-data" },
128 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_CF_ACK
, "qos-data-cf-ack" },
129 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_CF_POLL
, "qos-data-cf-poll" },
130 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_CF_ACPL
, "qos-data-cf-ack-poll" },
131 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA
, "qos" },
132 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA_CF_POLL
, "qos-cf-poll" },
133 { IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL
, "qos-cf-ack-poll" },
136 static const struct tok llc_s_subtypes
[] = {
142 static const struct tok llc_u_subtypes
[] = {
145 { LLC_DISC
, "disc" },
147 { LLC_SABME
, "sabme" },
148 { LLC_TEST
, "test" },
150 { LLC_FRMR
, "frmr" },
155 const struct tok
*tok
;
157 static const struct type2tok ieee80211_type_subtypes
[] = {
158 { IEEE80211_FC0_TYPE_MGT
, ieee80211_mgt_subtypes
},
159 { IEEE80211_FC0_TYPE_CTL
, ieee80211_ctl_subtypes
},
160 { IEEE80211_FC0_TYPE_DATA
, ieee80211_data_subtypes
},
165 str2tok
(const char *str
, const struct tok
*toks
)
169 for
(i
= 0; toks
[i
].s
!= NULL
; i
++) {
170 if
(pcap_strcasecmp
(toks
[i
].s
, str
) == 0)
178 static struct qual qerr
= { Q_UNDEF
, Q_UNDEF
, Q_UNDEF
, Q_UNDEF
};
181 yyerror(const char *msg
)
184 bpf_error
("%s", msg
);
188 #ifdef NEED_YYPARSE_WRAPPER
198 #ifdef HAVE_NET_PFVAR_H
200 pfreason_to_num
(const char *reason
)
202 const char *reasons
[] = PFRES_NAMES
;
205 for
(i
= 0; reasons
[i
]; i
++) {
206 if
(pcap_strcasecmp
(reason
, reasons
[i
]) == 0)
209 bpf_error
("unknown PF reason");
214 pfaction_to_num
(const char *action
)
216 if
(pcap_strcasecmp
(action
, "pass") == 0 ||
217 pcap_strcasecmp
(action
, "accept") == 0)
219 else if
(pcap_strcasecmp
(action
, "drop") == 0 ||
220 pcap_strcasecmp
(action
, "block") == 0)
222 #if HAVE_PF_NAT_THROUGH_PF_NORDR
223 else if
(pcap_strcasecmp
(action
, "rdr") == 0)
225 else if
(pcap_strcasecmp
(action
, "nat") == 0)
227 else if
(pcap_strcasecmp
(action
, "binat") == 0)
229 else if
(pcap_strcasecmp
(action
, "nordr") == 0)
233 bpf_error
("unknown PF action");
237 #else /* !HAVE_NET_PFVAR_H */
239 pfreason_to_num
(const char *reason
)
241 bpf_error
("libpcap was compiled on a machine without pf support");
244 /* this is to make the VC compiler happy */
249 pfaction_to_num
(const char *action
)
251 bpf_error
("libpcap was compiled on a machine without pf support");
254 /* this is to make the VC compiler happy */
257 #endif /* HAVE_NET_PFVAR_H */
276 %type
<blk
> expr id nid pid term rterm qid
278 %type
<i
> pqual dqual aqual ndaqual
280 %type
<i
> byteop pname pnum relop irelop
281 %type
<blk
> and or paren not null prog
282 %type
<rblk
> other pfvar p80211 pllc
283 %type
<i
> atmtype atmmultitype
285 %type
<blk
> atmfieldvalue atmvalue atmlistvalue
287 %type
<blk
> mtp3field
288 %type
<blk
> mtp3fieldvalue mtp3value mtp3listvalue
291 %token DST SRC HOST GATEWAY
292 %token NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
293 %token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP CARP
294 %token ATALK AARP DECNET LAT SCA MOPRC MOPDL
295 %token TK_BROADCAST TK_MULTICAST
296 %token NUM INBOUND OUTBOUND
297 %token PF_IFNAME PF_RSET PF_RNR PF_SRNR PF_REASON PF_ACTION
298 %token TYPE SUBTYPE
DIR ADDR1 ADDR2 ADDR3 ADDR4 RA TA
301 %token ID EID HID HID6 AID
304 %token IPV6 ICMPV6 AH ESP
306 %token PPPOED PPPOES GENEVE
307 %token ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP
311 %token LANE LLC METAC BCC SC ILMIC OAMF4EC OAMF4SC
312 %token OAM OAMF4 CONNECTMSG METACONNECT
315 %token FISU LSSU MSU HFISU HLSSU HMSU
316 %token SIO OPC DPC SLS HSIO HOPC HDPC HSLS
323 %type
<i
> NUM action reason type subtype type_subtype dir
340 null: /* null */ { $$.q
= qerr
; }
343 | expr and term
{ gen_and
($1.b
, $3.b
); $$
= $3; }
344 | expr and id
{ gen_and
($1.b
, $3.b
); $$
= $3; }
345 | expr or term
{ gen_or
($1.b
, $3.b
); $$
= $3; }
346 | expr or id
{ gen_or
($1.b
, $3.b
); $$
= $3; }
348 and: AND
{ $$
= $
<blk
>0; }
350 or: OR
{ $$
= $
<blk
>0; }
353 | pnum
{ $$.b
= gen_ncode
(NULL
, (bpf_u_int32
)$1,
355 | paren pid
')' { $$
= $2; }
357 nid: ID
{ $$.b
= gen_scode
($1, $$.q
= $
<blk
>0.q
); }
358 | HID
'/' NUM
{ $$.b
= gen_mcode
($1, NULL
, $3,
360 | HID NETMASK HID
{ $$.b
= gen_mcode
($1, $3, 0,
363 /* Decide how to parse HID based on proto */
365 if
($$.q.addr
== Q_PORT
)
366 bpf_error
("'port' modifier applied to ip host");
367 else if
($$.q.addr
== Q_PORTRANGE
)
368 bpf_error
("'portrange' modifier applied to ip host");
369 else if
($$.q.addr
== Q_PROTO
)
370 bpf_error
("'proto' modifier applied to ip host");
371 else if
($$.q.addr
== Q_PROTOCHAIN
)
372 bpf_error
("'protochain' modifier applied to ip host");
373 $$.b
= gen_ncode
($1, 0, $$.q
);
377 $$.b
= gen_mcode6
($1, NULL
, $3,
380 bpf_error
("'ip6addr/prefixlen' not supported "
381 "in this configuration");
386 $$.b
= gen_mcode6
($1, 0, 128,
389 bpf_error
("'ip6addr' not supported "
390 "in this configuration");
394 $$.b
= gen_ecode
($1, $$.q
= $
<blk
>0.q
);
396 * $1 was allocated by "pcap_ether_aton()",
397 * so we must free it now that we're done
403 $$.b
= gen_acode
($1, $$.q
= $
<blk
>0.q
);
405 * $1 was allocated by "pcap_ether_aton()",
406 * so we must free it now that we're done
411 | not id
{ gen_not
($2.b
); $$
= $2; }
413 not: '!' { $$
= $
<blk
>0; }
415 paren: '(' { $$
= $
<blk
>0; }
418 | qid and id
{ gen_and
($1.b
, $3.b
); $$
= $3; }
419 | qid or id
{ gen_or
($1.b
, $3.b
); $$
= $3; }
421 qid: pnum
{ $$.b
= gen_ncode
(NULL
, (bpf_u_int32
)$1,
426 | not term
{ gen_not
($2.b
); $$
= $2; }
428 head: pqual dqual aqual
{ QSET
($$.q
, $1, $2, $3); }
429 | pqual dqual
{ QSET
($$.q
, $1, $2, Q_DEFAULT
); }
430 | pqual aqual
{ QSET
($$.q
, $1, Q_DEFAULT
, $2); }
431 | pqual PROTO
{ QSET
($$.q
, $1, Q_DEFAULT
, Q_PROTO
); }
432 | pqual PROTOCHAIN
{ QSET
($$.q
, $1, Q_DEFAULT
, Q_PROTOCHAIN
); }
433 | pqual ndaqual
{ QSET
($$.q
, $1, Q_DEFAULT
, $2); }
435 rterm: head id
{ $$
= $2; }
436 | paren expr
')' { $$.b
= $2.b
; $$.q
= $1.q
; }
437 | pname
{ $$.b
= gen_proto_abbrev
($1); $$.q
= qerr
; }
438 | arth relop arth
{ $$.b
= gen_relation
($2, $1, $3, 0);
440 | arth irelop arth
{ $$.b
= gen_relation
($2, $1, $3, 1);
442 | other
{ $$.b
= $1; $$.q
= qerr
; }
443 | atmtype
{ $$.b
= gen_atmtype_abbrev
($1); $$.q
= qerr
; }
444 | atmmultitype
{ $$.b
= gen_atmmulti_abbrev
($1); $$.q
= qerr
; }
445 | atmfield atmvalue
{ $$.b
= $2.b
; $$.q
= qerr
; }
446 | mtp2type
{ $$.b
= gen_mtp2type_abbrev
($1); $$.q
= qerr
; }
447 | mtp3field mtp3value
{ $$.b
= $2.b
; $$.q
= qerr
; }
449 /* protocol level qualifiers */
451 |
{ $$
= Q_DEFAULT
; }
453 /* 'direction' qualifiers */
454 dqual: SRC
{ $$
= Q_SRC
; }
455 | DST
{ $$
= Q_DST
; }
456 | SRC OR DST
{ $$
= Q_OR
; }
457 | DST OR SRC
{ $$
= Q_OR
; }
458 | SRC AND DST
{ $$
= Q_AND
; }
459 | DST AND SRC
{ $$
= Q_AND
; }
460 | ADDR1
{ $$
= Q_ADDR1
; }
461 | ADDR2
{ $$
= Q_ADDR2
; }
462 | ADDR3
{ $$
= Q_ADDR3
; }
463 | ADDR4
{ $$
= Q_ADDR4
; }
467 /* address type qualifiers */
468 aqual: HOST
{ $$
= Q_HOST
; }
469 | NET
{ $$
= Q_NET
; }
470 | PORT
{ $$
= Q_PORT
; }
471 | PORTRANGE
{ $$
= Q_PORTRANGE
; }
473 /* non-directional address type qualifiers */
474 ndaqual: GATEWAY
{ $$
= Q_GATEWAY
; }
476 pname: LINK
{ $$
= Q_LINK
; }
478 | ARP
{ $$
= Q_ARP
; }
479 | RARP
{ $$
= Q_RARP
; }
480 | SCTP
{ $$
= Q_SCTP
; }
481 | TCP
{ $$
= Q_TCP
; }
482 | UDP
{ $$
= Q_UDP
; }
483 | ICMP
{ $$
= Q_ICMP
; }
484 | IGMP
{ $$
= Q_IGMP
; }
485 | IGRP
{ $$
= Q_IGRP
; }
486 | PIM
{ $$
= Q_PIM
; }
487 | VRRP
{ $$
= Q_VRRP
; }
488 | CARP
{ $$
= Q_CARP
; }
489 | ATALK
{ $$
= Q_ATALK
; }
490 | AARP
{ $$
= Q_AARP
; }
491 | DECNET
{ $$
= Q_DECNET
; }
492 | LAT
{ $$
= Q_LAT
; }
493 | SCA
{ $$
= Q_SCA
; }
494 | MOPDL
{ $$
= Q_MOPDL
; }
495 | MOPRC
{ $$
= Q_MOPRC
; }
496 | IPV6
{ $$
= Q_IPV6
; }
497 | ICMPV6
{ $$
= Q_ICMPV6
; }
499 | ESP
{ $$
= Q_ESP
; }
500 | ISO
{ $$
= Q_ISO
; }
501 | ESIS
{ $$
= Q_ESIS
; }
502 | ISIS
{ $$
= Q_ISIS
; }
503 | L1
{ $$
= Q_ISIS_L1
; }
504 | L2
{ $$
= Q_ISIS_L2
; }
505 | IIH
{ $$
= Q_ISIS_IIH
; }
506 | LSP
{ $$
= Q_ISIS_LSP
; }
507 | SNP
{ $$
= Q_ISIS_SNP
; }
508 | PSNP
{ $$
= Q_ISIS_PSNP
; }
509 | CSNP
{ $$
= Q_ISIS_CSNP
; }
510 | CLNP
{ $$
= Q_CLNP
; }
511 | STP
{ $$
= Q_STP
; }
512 | IPX
{ $$
= Q_IPX
; }
513 | NETBEUI
{ $$
= Q_NETBEUI
; }
514 | RADIO
{ $$
= Q_RADIO
; }
516 other: pqual TK_BROADCAST
{ $$
= gen_broadcast
($1); }
517 | pqual TK_MULTICAST
{ $$
= gen_multicast
($1); }
518 | LESS NUM
{ $$
= gen_less
($2); }
519 | GREATER NUM
{ $$
= gen_greater
($2); }
520 | CBYTE NUM byteop NUM
{ $$
= gen_byteop
($3, $2, $4); }
521 | INBOUND
{ $$
= gen_inbound
(0); }
522 | OUTBOUND
{ $$
= gen_inbound
(1); }
523 | VLAN pnum
{ $$
= gen_vlan
($2); }
524 | VLAN
{ $$
= gen_vlan
(-1); }
525 | MPLS pnum
{ $$
= gen_mpls
($2); }
526 | MPLS
{ $$
= gen_mpls
(-1); }
527 | PPPOED
{ $$
= gen_pppoed
(); }
528 | PPPOES pnum
{ $$
= gen_pppoes
($2); }
529 | PPPOES
{ $$
= gen_pppoes
(-1); }
530 | GENEVE pnum
{ $$
= gen_geneve
($2); }
531 | GENEVE
{ $$
= gen_geneve
(-1); }
533 | pqual p80211
{ $$
= $2; }
537 pfvar: PF_IFNAME ID
{ $$
= gen_pf_ifname
($2); }
538 | PF_RSET ID
{ $$
= gen_pf_ruleset
($2); }
539 | PF_RNR NUM
{ $$
= gen_pf_rnr
($2); }
540 | PF_SRNR NUM
{ $$
= gen_pf_srnr
($2); }
541 | PF_REASON reason
{ $$
= gen_pf_reason
($2); }
542 | PF_ACTION action
{ $$
= gen_pf_action
($2); }
545 p80211: TYPE type SUBTYPE subtype
546 { $$
= gen_p80211_type
($2 |
$4,
547 IEEE80211_FC0_TYPE_MASK |
548 IEEE80211_FC0_SUBTYPE_MASK
);
550 | TYPE type
{ $$
= gen_p80211_type
($2,
551 IEEE80211_FC0_TYPE_MASK
);
553 | SUBTYPE type_subtype
{ $$
= gen_p80211_type
($2,
554 IEEE80211_FC0_TYPE_MASK |
555 IEEE80211_FC0_SUBTYPE_MASK
);
557 |
DIR dir
{ $$
= gen_p80211_fcdir
($2); }
561 | ID
{ $$
= str2tok
($1, ieee80211_types
);
563 bpf_error
("unknown 802.11 type name");
568 | ID
{ const struct tok
*types
= NULL
;
571 if
(ieee80211_type_subtypes
[i
].tok
== NULL
) {
572 /* Ran out of types */
573 bpf_error
("unknown 802.11 type");
576 if
($
<i
>-1 == ieee80211_type_subtypes
[i
].type
) {
577 types
= ieee80211_type_subtypes
[i
].tok
;
582 $$
= str2tok
($1, types
);
584 bpf_error
("unknown 802.11 subtype name");
588 type_subtype: ID
{ int i
;
590 if
(ieee80211_type_subtypes
[i
].tok
== NULL
) {
591 /* Ran out of types */
592 bpf_error
("unknown 802.11 type name");
595 $$
= str2tok
($1, ieee80211_type_subtypes
[i
].tok
);
597 $$ |
= ieee80211_type_subtypes
[i
].type
;
604 pllc: LLC
{ $$
= gen_llc
(); }
605 | LLC ID
{ if
(pcap_strcasecmp
($2, "i") == 0)
607 else if
(pcap_strcasecmp
($2, "s") == 0)
609 else if
(pcap_strcasecmp
($2, "u") == 0)
614 subtype
= str2tok
($2, llc_s_subtypes
);
615 if
(subtype
!= (u_int
)-1)
616 $$
= gen_llc_s_subtype
(subtype
);
618 subtype
= str2tok
($2, llc_u_subtypes
);
619 if
(subtype
== (u_int
)-1)
620 bpf_error
("unknown LLC type name \"%s\"", $2);
621 $$
= gen_llc_u_subtype
(subtype
);
625 /* sigh, "rnr" is already a keyword for PF */
626 | LLC PF_RNR
{ $$
= gen_llc_s_subtype
(LLC_RNR
); }
630 | ID
{ if
(pcap_strcasecmp
($1, "nods") == 0)
631 $$
= IEEE80211_FC1_DIR_NODS
;
632 else if
(pcap_strcasecmp
($1, "tods") == 0)
633 $$
= IEEE80211_FC1_DIR_TODS
;
634 else if
(pcap_strcasecmp
($1, "fromds") == 0)
635 $$
= IEEE80211_FC1_DIR_FROMDS
;
636 else if
(pcap_strcasecmp
($1, "dstods") == 0)
637 $$
= IEEE80211_FC1_DIR_DSTODS
;
639 bpf_error
("unknown 802.11 direction");
643 reason: NUM
{ $$
= $1; }
644 | ID
{ $$
= pfreason_to_num
($1); }
647 action: ID
{ $$
= pfaction_to_num
($1); }
650 relop: '>' { $$
= BPF_JGT
; }
651 | GEQ
{ $$
= BPF_JGE
; }
652 |
'=' { $$
= BPF_JEQ
; }
654 irelop: LEQ
{ $$
= BPF_JGT
; }
655 |
'<' { $$
= BPF_JGE
; }
656 | NEQ
{ $$
= BPF_JEQ
; }
658 arth: pnum
{ $$
= gen_loadi
($1); }
661 narth: pname
'[' arth
']' { $$
= gen_load
($1, $3, 1); }
662 | pname
'[' arth
':' NUM
']' { $$
= gen_load
($1, $3, $5); }
663 | arth
'+' arth
{ $$
= gen_arth
(BPF_ADD
, $1, $3); }
664 | arth
'-' arth
{ $$
= gen_arth
(BPF_SUB
, $1, $3); }
665 | arth
'*' arth
{ $$
= gen_arth
(BPF_MUL
, $1, $3); }
666 | arth
'/' arth
{ $$
= gen_arth
(BPF_DIV
, $1, $3); }
667 | arth
'%' arth
{ $$
= gen_arth
(BPF_MOD
, $1, $3); }
668 | arth
'&' arth
{ $$
= gen_arth
(BPF_AND
, $1, $3); }
669 | arth
'|' arth
{ $$
= gen_arth
(BPF_OR
, $1, $3); }
670 | arth
'^' arth
{ $$
= gen_arth
(BPF_XOR
, $1, $3); }
671 | arth LSH arth
{ $$
= gen_arth
(BPF_LSH
, $1, $3); }
672 | arth RSH arth
{ $$
= gen_arth
(BPF_RSH
, $1, $3); }
673 |
'-' arth %prec UMINUS
{ $$
= gen_neg
($2); }
674 | paren narth
')' { $$
= $2; }
675 | LEN
{ $$
= gen_loadlen
(); }
677 byteop: '&' { $$
= '&'; }
684 | paren pnum
')' { $$
= $2; }
686 atmtype: LANE
{ $$
= A_LANE
; }
687 | METAC
{ $$
= A_METAC
; }
688 | BCC
{ $$
= A_BCC
; }
689 | OAMF4EC
{ $$
= A_OAMF4EC
; }
690 | OAMF4SC
{ $$
= A_OAMF4SC
; }
692 | ILMIC
{ $$
= A_ILMIC
; }
694 atmmultitype: OAM
{ $$
= A_OAM
; }
695 | OAMF4
{ $$
= A_OAMF4
; }
696 | CONNECTMSG
{ $$
= A_CONNECTMSG
; }
697 | METACONNECT
{ $$
= A_METACONNECT
; }
699 /* ATM field types quantifier */
700 atmfield: VPI
{ $$.atmfieldtype
= A_VPI
; }
701 | VCI
{ $$.atmfieldtype
= A_VCI
; }
703 atmvalue: atmfieldvalue
704 | relop NUM
{ $$.b
= gen_atmfield_code
($
<blk
>0.atmfieldtype
, (bpf_int32
)$2, (bpf_u_int32
)$1, 0); }
705 | irelop NUM
{ $$.b
= gen_atmfield_code
($
<blk
>0.atmfieldtype
, (bpf_int32
)$2, (bpf_u_int32
)$1, 1); }
706 | paren atmlistvalue
')' { $$.b
= $2.b
; $$.q
= qerr
; }
709 $$.atmfieldtype
= $
<blk
>0.atmfieldtype
;
710 if
($$.atmfieldtype
== A_VPI ||
711 $$.atmfieldtype
== A_VCI
)
712 $$.b
= gen_atmfield_code
($$.atmfieldtype
, (bpf_int32
) $1, BPF_JEQ
, 0);
715 atmlistvalue: atmfieldvalue
716 | atmlistvalue or atmfieldvalue
{ gen_or
($1.b
, $3.b
); $$
= $3; }
718 /* MTP2 types quantifier */
719 mtp2type: FISU
{ $$
= M_FISU
; }
720 | LSSU
{ $$
= M_LSSU
; }
721 | MSU
{ $$
= M_MSU
; }
722 | HFISU
{ $$
= MH_FISU
; }
723 | HLSSU
{ $$
= MH_LSSU
; }
724 | HMSU
{ $$
= MH_MSU
; }
726 /* MTP3 field types quantifier */
727 mtp3field: SIO
{ $$.mtp3fieldtype
= M_SIO
; }
728 | OPC
{ $$.mtp3fieldtype
= M_OPC
; }
729 | DPC
{ $$.mtp3fieldtype
= M_DPC
; }
730 | SLS
{ $$.mtp3fieldtype
= M_SLS
; }
731 | HSIO
{ $$.mtp3fieldtype
= MH_SIO
; }
732 | HOPC
{ $$.mtp3fieldtype
= MH_OPC
; }
733 | HDPC
{ $$.mtp3fieldtype
= MH_DPC
; }
734 | HSLS
{ $$.mtp3fieldtype
= MH_SLS
; }
736 mtp3value: mtp3fieldvalue
737 | relop NUM
{ $$.b
= gen_mtp3field_code
($
<blk
>0.mtp3fieldtype
, (u_int
)$2, (u_int
)$1, 0); }
738 | irelop NUM
{ $$.b
= gen_mtp3field_code
($
<blk
>0.mtp3fieldtype
, (u_int
)$2, (u_int
)$1, 1); }
739 | paren mtp3listvalue
')' { $$.b
= $2.b
; $$.q
= qerr
; }
741 mtp3fieldvalue: NUM
{
742 $$.mtp3fieldtype
= $
<blk
>0.mtp3fieldtype
;
743 if
($$.mtp3fieldtype
== M_SIO ||
744 $$.mtp3fieldtype
== M_OPC ||
745 $$.mtp3fieldtype
== M_DPC ||
746 $$.mtp3fieldtype
== M_SLS ||
747 $$.mtp3fieldtype
== MH_SIO ||
748 $$.mtp3fieldtype
== MH_OPC ||
749 $$.mtp3fieldtype
== MH_DPC ||
750 $$.mtp3fieldtype
== MH_SLS
)
751 $$.b
= gen_mtp3field_code
($$.mtp3fieldtype
, (u_int
) $1, BPF_JEQ
, 0);
754 mtp3listvalue: mtp3fieldvalue
755 | mtp3listvalue or mtp3fieldvalue
{ gen_or
($1.b
, $3.b
); $$
= $3; }