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