Resolve conflicts.
[games.git] / contrib / libpcap-0.9 / grammar.y
1 %{
2 /*
3  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
4  *      The Regents of the University of California.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that: (1) source code distributions
8  * retain the above copyright notice and this paragraph in its entirety, (2)
9  * distributions including binary code include the above copyright notice and
10  * this paragraph in its entirety in the documentation or other materials
11  * provided with the distribution, and (3) all advertising materials mentioning
12  * features or use of this software display the following acknowledgement:
13  * ``This product includes software developed by the University of California,
14  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15  * the University nor the names of its contributors may be used to endorse
16  * or promote products derived from this software without specific prior
17  * written permission.
18  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  */
23 #ifndef lint
24 static const char rcsid[] _U_ =
25     "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.9 2007/09/12 19:17:25 guy Exp $ (LBL)";
26 #endif
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #ifdef WIN32
33 #include <pcap-stdinc.h>
34 #else /* WIN32 */
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #endif /* WIN32 */
38
39 #include <stdlib.h>
40
41 #ifndef WIN32
42 #if __STDC__
43 struct mbuf;
44 struct rtentry;
45 #endif
46
47 #include <netinet/in.h>
48 #endif /* WIN32 */
49
50 #include <stdio.h>
51
52 #include "pcap-int.h"
53
54 #include "gencode.h"
55 #ifdef HAVE_NET_PFVAR_H
56 #include <net/if.h>
57 #include <net/pfvar.h>
58 #include <net/if_pflog.h>
59 #endif
60 #include <pcap-namedb.h>
61
62 #include <netproto/802_11/ieee80211.h>
63
64 #ifdef HAVE_OS_PROTO_H
65 #include "os-proto.h"
66 #endif
67
68 #define QSET(q, p, d, a) (q).proto = (p),\
69                          (q).dir = (d),\
70                          (q).addr = (a)
71
72 static const char *ieee80211_mgt_names[] = IEEE80211_MGT_SUBTYPE_NAMES;
73 static const char *ieee80211_ctl_names[] = IEEE80211_CTL_SUBTYPE_NAMES;
74 static const char *ieee80211_data_names[] = IEEE80211_DATA_SUBTYPE_NAMES;
75
76 int n_errors = 0;
77
78 static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
79
80 static void
81 yyerror(const char *msg)
82 {
83         ++n_errors;
84         bpf_error("%s", msg);
85         /* NOTREACHED */
86 }
87
88 #ifndef YYBISON
89 int yyparse(void);
90
91 int
92 pcap_parse()
93 {
94         return (yyparse());
95 }
96 #endif
97
98 #ifdef HAVE_NET_PFVAR_H
99 static int
100 pfreason_to_num(const char *reason)
101 {
102         const char *reasons[] = PFRES_NAMES;
103         int i;
104
105         for (i = 0; reasons[i]; i++) {
106                 if (pcap_strcasecmp(reason, reasons[i]) == 0)
107                         return (i);
108         }
109         bpf_error("unknown PF reason");
110         /*NOTREACHED*/
111 }
112
113 static int
114 pfaction_to_num(const char *action)
115 {
116         if (pcap_strcasecmp(action, "pass") == 0 ||
117             pcap_strcasecmp(action, "accept") == 0)
118                 return (PF_PASS);
119         else if (pcap_strcasecmp(action, "drop") == 0 ||
120                 pcap_strcasecmp(action, "block") == 0)
121                 return (PF_DROP);
122         else {
123                 bpf_error("unknown PF action");
124                 /*NOTREACHED*/
125         }
126 }
127 #else /* !HAVE_NET_PFVAR_H */
128 static int
129 pfreason_to_num(const char *reason)
130 {
131         bpf_error("libpcap was compiled on a machine without pf support");
132         /*NOTREACHED*/
133 }
134
135 static int
136 pfaction_to_num(const char *action)
137 {
138         bpf_error("libpcap was compiled on a machine without pf support");
139         /*NOTREACHED*/
140 }
141 #endif /* HAVE_NET_PFVAR_H */
142 %}
143
144 %union {
145         int i;
146         bpf_u_int32 h;
147         u_char *e;
148         char *s;
149         struct stmt *stmt;
150         struct arth *a;
151         struct {
152                 struct qual q;
153                 int atmfieldtype;
154                 int mtp3fieldtype;
155                 struct block *b;
156         } blk;
157         struct block *rblk;
158 }
159
160 %type   <blk>   expr id nid pid term rterm qid
161 %type   <blk>   head
162 %type   <i>     pqual dqual aqual ndaqual
163 %type   <a>     arth narth
164 %type   <i>     byteop pname pnum relop irelop
165 %type   <blk>   and or paren not null prog
166 %type   <rblk>  other pfvar p80211
167 %type   <i>     atmtype atmmultitype
168 %type   <blk>   atmfield
169 %type   <blk>   atmfieldvalue atmvalue atmlistvalue
170 %type   <i>     mtp2type
171 %type   <blk>   mtp3field
172 %type   <blk>   mtp3fieldvalue mtp3value mtp3listvalue
173
174
175 %token  DST SRC HOST GATEWAY
176 %token  NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
177 %token  ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP
178 %token  ATALK AARP DECNET LAT SCA MOPRC MOPDL
179 %token  TK_BROADCAST TK_MULTICAST
180 %token  NUM INBOUND OUTBOUND
181 %token  PF_IFNAME PF_RSET PF_RNR PF_SRNR PF_REASON PF_ACTION
182 %token  LINK
183 %token  GEQ LEQ NEQ
184 %token  ID EID HID HID6 AID
185 %token  LSH RSH
186 %token  LEN
187 %token  IPV6 ICMPV6 AH ESP
188 %token  VLAN MPLS
189 %token  PPPOED PPPOES
190 %token  ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP 
191 %token  STP
192 %token  IPX
193 %token  NETBEUI
194 %token  LANE LLC METAC BCC SC ILMIC OAMF4EC OAMF4SC
195 %token  OAM OAMF4 CONNECTMSG METACONNECT
196 %token  VPI VCI
197 %token  RADIO
198 %token  FISU LSSU MSU
199 %token  SIO OPC DPC SLS
200 %token  TYPE SUBTYPE
201
202 %type   <s> ID
203 %type   <e> EID
204 %type   <e> AID
205 %type   <s> HID HID6
206 %type   <i> NUM action reason type subtype type_subtype
207
208 %left OR AND
209 %nonassoc  '!'
210 %left '|'
211 %left '&'
212 %left LSH RSH
213 %left '+' '-'
214 %left '*' '/'
215 %nonassoc UMINUS
216 %%
217 prog:     null expr
218 {
219         finish_parse($2.b);
220 }
221         | null
222         ;
223 null:     /* null */            { $$.q = qerr; }
224         ;
225 expr:     term
226         | expr and term         { gen_and($1.b, $3.b); $$ = $3; }
227         | expr and id           { gen_and($1.b, $3.b); $$ = $3; }
228         | expr or term          { gen_or($1.b, $3.b); $$ = $3; }
229         | expr or id            { gen_or($1.b, $3.b); $$ = $3; }
230         ;
231 and:      AND                   { $$ = $<blk>0; }
232         ;
233 or:       OR                    { $$ = $<blk>0; }
234         ;
235 id:       nid
236         | pnum                  { $$.b = gen_ncode(NULL, (bpf_u_int32)$1,
237                                                    $$.q = $<blk>0.q); }
238         | paren pid ')'         { $$ = $2; }
239         ;
240 nid:      ID                    { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
241         | HID '/' NUM           { $$.b = gen_mcode($1, NULL, $3,
242                                     $$.q = $<blk>0.q); }
243         | HID NETMASK HID       { $$.b = gen_mcode($1, $3, 0,
244                                     $$.q = $<blk>0.q); }
245         | HID                   {
246                                   /* Decide how to parse HID based on proto */
247                                   $$.q = $<blk>0.q;
248                                   $$.b = gen_ncode($1, 0, $$.q);
249                                 }
250         | HID6 '/' NUM          {
251 #ifdef INET6
252                                   $$.b = gen_mcode6($1, NULL, $3,
253                                     $$.q = $<blk>0.q);
254 #else
255                                   bpf_error("'ip6addr/prefixlen' not supported "
256                                         "in this configuration");
257 #endif /*INET6*/
258                                 }
259         | HID6                  {
260 #ifdef INET6
261                                   $$.b = gen_mcode6($1, 0, 128,
262                                     $$.q = $<blk>0.q);
263 #else
264                                   bpf_error("'ip6addr' not supported "
265                                         "in this configuration");
266 #endif /*INET6*/
267                                 }
268         | EID                   { 
269                                   $$.b = gen_ecode($1, $$.q = $<blk>0.q);
270                                   /*
271                                    * $1 was allocated by "pcap_ether_aton()",
272                                    * so we must free it now that we're done
273                                    * with it.
274                                    */
275                                   free($1);
276                                 }
277         | AID                   {
278                                   $$.b = gen_acode($1, $$.q = $<blk>0.q);
279                                   /*
280                                    * $1 was allocated by "pcap_ether_aton()",
281                                    * so we must free it now that we're done
282                                    * with it.
283                                    */
284                                   free($1);
285                                 }
286         | not id                { gen_not($2.b); $$ = $2; }
287         ;
288 not:      '!'                   { $$ = $<blk>0; }
289         ;
290 paren:    '('                   { $$ = $<blk>0; }
291         ;
292 pid:      nid
293         | qid and id            { gen_and($1.b, $3.b); $$ = $3; }
294         | qid or id             { gen_or($1.b, $3.b); $$ = $3; }
295         ;
296 qid:      pnum                  { $$.b = gen_ncode(NULL, (bpf_u_int32)$1,
297                                                    $$.q = $<blk>0.q); }
298         | pid
299         ;
300 term:     rterm
301         | not term              { gen_not($2.b); $$ = $2; }
302         ;
303 head:     pqual dqual aqual     { QSET($$.q, $1, $2, $3); }
304         | pqual dqual           { QSET($$.q, $1, $2, Q_DEFAULT); }
305         | pqual aqual           { QSET($$.q, $1, Q_DEFAULT, $2); }
306         | pqual PROTO           { QSET($$.q, $1, Q_DEFAULT, Q_PROTO); }
307         | pqual PROTOCHAIN      { QSET($$.q, $1, Q_DEFAULT, Q_PROTOCHAIN); }
308         | pqual ndaqual         { QSET($$.q, $1, Q_DEFAULT, $2); }
309         ;
310 rterm:    head id               { $$ = $2; }
311         | paren expr ')'        { $$.b = $2.b; $$.q = $1.q; }
312         | pname                 { $$.b = gen_proto_abbrev($1); $$.q = qerr; }
313         | arth relop arth       { $$.b = gen_relation($2, $1, $3, 0);
314                                   $$.q = qerr; }
315         | arth irelop arth      { $$.b = gen_relation($2, $1, $3, 1);
316                                   $$.q = qerr; }
317         | other                 { $$.b = $1; $$.q = qerr; }
318         | atmtype               { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
319         | atmmultitype          { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
320         | atmfield atmvalue     { $$.b = $2.b; $$.q = qerr; }
321         | mtp2type              { $$.b = gen_mtp2type_abbrev($1); $$.q = qerr; }
322         | mtp3field mtp3value   { $$.b = $2.b; $$.q = qerr; }
323         ;
324 /* protocol level qualifiers */
325 pqual:    pname
326         |                       { $$ = Q_DEFAULT; }
327         ;
328 /* 'direction' qualifiers */
329 dqual:    SRC                   { $$ = Q_SRC; }
330         | DST                   { $$ = Q_DST; }
331         | SRC OR DST            { $$ = Q_OR; }
332         | DST OR SRC            { $$ = Q_OR; }
333         | SRC AND DST           { $$ = Q_AND; }
334         | DST AND SRC           { $$ = Q_AND; }
335         ;
336 /* address type qualifiers */
337 aqual:    HOST                  { $$ = Q_HOST; }
338         | NET                   { $$ = Q_NET; }
339         | PORT                  { $$ = Q_PORT; }
340         | PORTRANGE             { $$ = Q_PORTRANGE; }
341         ;
342 /* non-directional address type qualifiers */
343 ndaqual:  GATEWAY               { $$ = Q_GATEWAY; }
344         ;
345 pname:    LINK                  { $$ = Q_LINK; }
346         | IP                    { $$ = Q_IP; }
347         | ARP                   { $$ = Q_ARP; }
348         | RARP                  { $$ = Q_RARP; }
349         | SCTP                  { $$ = Q_SCTP; }
350         | TCP                   { $$ = Q_TCP; }
351         | UDP                   { $$ = Q_UDP; }
352         | ICMP                  { $$ = Q_ICMP; }
353         | IGMP                  { $$ = Q_IGMP; }
354         | IGRP                  { $$ = Q_IGRP; }
355         | PIM                   { $$ = Q_PIM; }
356         | VRRP                  { $$ = Q_VRRP; }
357         | ATALK                 { $$ = Q_ATALK; }
358         | AARP                  { $$ = Q_AARP; }
359         | DECNET                { $$ = Q_DECNET; }
360         | LAT                   { $$ = Q_LAT; }
361         | SCA                   { $$ = Q_SCA; }
362         | MOPDL                 { $$ = Q_MOPDL; }
363         | MOPRC                 { $$ = Q_MOPRC; }
364         | IPV6                  { $$ = Q_IPV6; }
365         | ICMPV6                { $$ = Q_ICMPV6; }
366         | AH                    { $$ = Q_AH; }
367         | ESP                   { $$ = Q_ESP; }
368         | ISO                   { $$ = Q_ISO; }
369         | ESIS                  { $$ = Q_ESIS; }
370         | ISIS                  { $$ = Q_ISIS; }
371         | L1                    { $$ = Q_ISIS_L1; }
372         | L2                    { $$ = Q_ISIS_L2; }
373         | IIH                   { $$ = Q_ISIS_IIH; }
374         | LSP                   { $$ = Q_ISIS_LSP; }
375         | SNP                   { $$ = Q_ISIS_SNP; }
376         | PSNP                  { $$ = Q_ISIS_PSNP; }
377         | CSNP                  { $$ = Q_ISIS_CSNP; }
378         | CLNP                  { $$ = Q_CLNP; }
379         | STP                   { $$ = Q_STP; }
380         | IPX                   { $$ = Q_IPX; }
381         | NETBEUI               { $$ = Q_NETBEUI; }
382         | RADIO                 { $$ = Q_RADIO; }
383         ;
384 other:    pqual TK_BROADCAST    { $$ = gen_broadcast($1); }
385         | pqual TK_MULTICAST    { $$ = gen_multicast($1); }
386         | LESS NUM              { $$ = gen_less($2); }
387         | GREATER NUM           { $$ = gen_greater($2); }
388         | CBYTE NUM byteop NUM  { $$ = gen_byteop($3, $2, $4); }
389         | INBOUND               { $$ = gen_inbound(0); }
390         | OUTBOUND              { $$ = gen_inbound(1); }
391         | VLAN pnum             { $$ = gen_vlan($2); }
392         | VLAN                  { $$ = gen_vlan(-1); }
393         | MPLS pnum             { $$ = gen_mpls($2); }
394         | MPLS                  { $$ = gen_mpls(-1); }
395         | PPPOED                { $$ = gen_pppoed(); }
396         | PPPOES                { $$ = gen_pppoes(); }
397         | pfvar                 { $$ = $1; }
398         | pqual p80211          { $$ = $2; }
399         ;
400
401 pfvar:    PF_IFNAME ID          { $$ = gen_pf_ifname($2); }
402         | PF_RSET ID            { $$ = gen_pf_ruleset($2); }
403         | PF_RNR NUM            { $$ = gen_pf_rnr($2); }
404         | PF_SRNR NUM           { $$ = gen_pf_srnr($2); }
405         | PF_REASON reason      { $$ = gen_pf_reason($2); }
406         | PF_ACTION action      { $$ = gen_pf_action($2); }
407         ;
408
409 p80211:   TYPE type SUBTYPE subtype
410                                 { $$ = gen_p80211_type($2 | $4,
411                                         IEEE80211_FC0_TYPE_MASK |
412                                         IEEE80211_FC0_SUBTYPE_MASK);
413                                 }
414         | TYPE type             { $$ = gen_p80211_type($2,
415                                         IEEE80211_FC0_TYPE_MASK);
416                                 }
417         | SUBTYPE type_subtype  { $$ = gen_p80211_type($2,
418                                         IEEE80211_FC0_TYPE_MASK |
419                                         IEEE80211_FC0_SUBTYPE_MASK);
420                                 }
421         ;
422
423 type:     NUM
424         | ID                    { const char *names[] = IEEE80211_TYPE_NAMES;
425                                   int i, lim;
426                                   lim = (IEEE80211_FC0_TYPE_MASK >> IEEE80211_FC0_TYPE_SHIFT) + 1;
427                                   for (i = 0; i < lim; ++i) {
428                                         if (pcap_strcasecmp($1, names[i]) == 0) {
429                                                 $$ = i << IEEE80211_FC0_TYPE_SHIFT;
430                                                 break;
431                                         }
432                                   }
433                                   if (i == lim)
434                                         bpf_error("unknown 802.11 type name");
435                                 }
436         ;
437
438 subtype:  NUM
439         | ID                    { const char **names;
440                                   int i, lim;
441                                   if ($<i>-1 == IEEE80211_FC0_TYPE_MGT)
442                                         names = ieee80211_mgt_names;
443                                   else if ($<i>-1 == IEEE80211_FC0_TYPE_CTL)
444                                         names = ieee80211_ctl_names;
445                                   else if ($<i>-1 == IEEE80211_FC0_TYPE_DATA)
446                                         names = ieee80211_data_names;
447                                   else
448                                         bpf_error("unknown 802.11 type");
449                                   lim = (IEEE80211_FC0_SUBTYPE_MASK >> IEEE80211_FC0_SUBTYPE_SHIFT) + 1;
450                                   for (i = 0; i < lim; ++i) {
451                                         if (pcap_strcasecmp($1, names[i]) == 0) {
452                                                 $$ = i << IEEE80211_FC0_SUBTYPE_SHIFT;
453                                                 break;
454                                         }
455                                   }
456                                   if (i == lim)
457                                         bpf_error("unknown 802.11 subtype name");
458                                 }
459         ;
460
461 type_subtype:   ID              { const char **sub_names[] = {
462                                         ieee80211_mgt_names,
463                                         ieee80211_ctl_names,
464                                         ieee80211_data_names
465                                   };
466                                   int i, j, lim, sub_lim;
467                                   sub_lim = sizeof(sub_names) / sizeof(sub_names[0]);
468                                   lim = (IEEE80211_FC0_SUBTYPE_MASK >> IEEE80211_FC0_SUBTYPE_SHIFT) + 1;
469                                   for (i = 0; i < sub_lim; ++i) {
470                                         const char **names = sub_names[i];
471                                         for (j = 0; j < lim; ++j) {
472                                                 if (pcap_strcasecmp($1, names[j]) == 0)
473                                                         break;
474                                         }
475                                         if (j != lim) {
476                                                 $$ = (i << IEEE80211_FC0_TYPE_SHIFT) |
477                                                      (j << IEEE80211_FC0_SUBTYPE_SHIFT);
478                                                 break;
479                                         }
480                                   }
481                                   if (i == sub_lim)
482                                         bpf_error("unknown 802.11 subtype name");
483                                 }
484                 ;
485
486 reason:   NUM                   { $$ = $1; }
487         | ID                    { $$ = pfreason_to_num($1); }
488         ;
489
490 action:   ID                    { $$ = pfaction_to_num($1); }
491         ;
492
493 relop:    '>'                   { $$ = BPF_JGT; }
494         | GEQ                   { $$ = BPF_JGE; }
495         | '='                   { $$ = BPF_JEQ; }
496         ;
497 irelop:   LEQ                   { $$ = BPF_JGT; }
498         | '<'                   { $$ = BPF_JGE; }
499         | NEQ                   { $$ = BPF_JEQ; }
500         ;
501 arth:     pnum                  { $$ = gen_loadi($1); }
502         | narth
503         ;
504 narth:    pname '[' arth ']'            { $$ = gen_load($1, $3, 1); }
505         | pname '[' arth ':' NUM ']'    { $$ = gen_load($1, $3, $5); }
506         | arth '+' arth                 { $$ = gen_arth(BPF_ADD, $1, $3); }
507         | arth '-' arth                 { $$ = gen_arth(BPF_SUB, $1, $3); }
508         | arth '*' arth                 { $$ = gen_arth(BPF_MUL, $1, $3); }
509         | arth '/' arth                 { $$ = gen_arth(BPF_DIV, $1, $3); }
510         | arth '&' arth                 { $$ = gen_arth(BPF_AND, $1, $3); }
511         | arth '|' arth                 { $$ = gen_arth(BPF_OR, $1, $3); }
512         | arth LSH arth                 { $$ = gen_arth(BPF_LSH, $1, $3); }
513         | arth RSH arth                 { $$ = gen_arth(BPF_RSH, $1, $3); }
514         | '-' arth %prec UMINUS         { $$ = gen_neg($2); }
515         | paren narth ')'               { $$ = $2; }
516         | LEN                           { $$ = gen_loadlen(); }
517         ;
518 byteop:   '&'                   { $$ = '&'; }
519         | '|'                   { $$ = '|'; }
520         | '<'                   { $$ = '<'; }
521         | '>'                   { $$ = '>'; }
522         | '='                   { $$ = '='; }
523         ;
524 pnum:     NUM
525         | paren pnum ')'        { $$ = $2; }
526         ;
527 atmtype: LANE                   { $$ = A_LANE; }
528         | LLC                   { $$ = A_LLC; }
529         | METAC                 { $$ = A_METAC; }
530         | BCC                   { $$ = A_BCC; }
531         | OAMF4EC               { $$ = A_OAMF4EC; }
532         | OAMF4SC               { $$ = A_OAMF4SC; }
533         | SC                    { $$ = A_SC; }
534         | ILMIC                 { $$ = A_ILMIC; }
535         ;
536 atmmultitype: OAM               { $$ = A_OAM; }
537         | OAMF4                 { $$ = A_OAMF4; }
538         | CONNECTMSG            { $$ = A_CONNECTMSG; }
539         | METACONNECT           { $$ = A_METACONNECT; }
540         ;
541         /* ATM field types quantifier */
542 atmfield: VPI                   { $$.atmfieldtype = A_VPI; }
543         | VCI                   { $$.atmfieldtype = A_VCI; }
544         ;
545 atmvalue: atmfieldvalue
546         | relop NUM             { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
547         | irelop NUM            { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
548         | paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
549         ;
550 atmfieldvalue: NUM {
551         $$.atmfieldtype = $<blk>0.atmfieldtype;
552         if ($$.atmfieldtype == A_VPI ||
553             $$.atmfieldtype == A_VCI)
554                 $$.b = gen_atmfield_code($$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
555         }
556         ;
557 atmlistvalue: atmfieldvalue
558         | atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
559         ;
560         /* MTP2 types quantifier */
561 mtp2type: FISU                  { $$ = M_FISU; }
562         | LSSU                  { $$ = M_LSSU; }
563         | MSU                   { $$ = M_MSU; }
564         ;
565         /* MTP3 field types quantifier */
566 mtp3field: SIO                  { $$.mtp3fieldtype = M_SIO; }
567         | OPC                   { $$.mtp3fieldtype = M_OPC; }
568         | DPC                   { $$.mtp3fieldtype = M_DPC; }
569         | SLS                   { $$.mtp3fieldtype = M_SLS; }
570         ;
571 mtp3value: mtp3fieldvalue
572         | relop NUM             { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
573         | irelop NUM            { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
574         | paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
575         ;
576 mtp3fieldvalue: NUM {
577         $$.mtp3fieldtype = $<blk>0.mtp3fieldtype;
578         if ($$.mtp3fieldtype == M_SIO ||
579             $$.mtp3fieldtype == M_OPC ||
580             $$.mtp3fieldtype == M_DPC ||
581             $$.mtp3fieldtype == M_SLS )
582                 $$.b = gen_mtp3field_code($$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
583         }
584         ;
585 mtp3listvalue: mtp3fieldvalue
586         | mtp3listvalue or mtp3fieldvalue { gen_or($1.b, $3.b); $$ = $3; }
587         ;
588 %%