Deleted Added
sdiff udiff text old ( 162015 ) new ( 172680 )
full compact
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)

--- 5 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/contrib/libpcap/grammar.y 162015 2006-09-04 19:54:21Z sam $
23 */
24#ifndef lint
25static const char rcsid[] _U_ =
26 "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.5 2005/09/05 09:08:06 guy Exp $ (LBL)";
27#endif
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#ifdef WIN32
34#include <pcap-stdinc.h>

--- 13 unchanged lines hidden (view full) ---

48#include <netinet/in.h>
49#endif /* WIN32 */
50
51#include <stdio.h>
52
53#include "pcap-int.h"
54
55#include "gencode.h"
56#include "pf.h"
57#include <pcap-namedb.h>
58
59#ifdef HAVE_OS_PROTO_H
60#include "os-proto.h"
61#endif
62
63#define QSET(q, p, d, a) (q).proto = (p),\
64 (q).dir = (d),\
65 (q).addr = (a)
66
67int n_errors = 0;
68
69static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
70
71static void
72yyerror(char *msg)
73{
74 ++n_errors;
75 bpf_error("%s", msg);
76 /* NOTREACHED */
77}
78
79#ifndef YYBISON
80int yyparse(void);
81
82int
83pcap_parse()
84{
85 return (yyparse());
86}
87#endif
88
89%}
90
91%union {
92 int i;
93 bpf_u_int32 h;
94 u_char *e;
95 char *s;
96 struct stmt *stmt;

--- 12 unchanged lines hidden (view full) ---

109%type <i> pqual dqual aqual ndaqual
110%type <a> arth narth
111%type <i> byteop pname pnum relop irelop
112%type <blk> and or paren not null prog
113%type <rblk> other pfvar
114%type <i> atmtype atmmultitype
115%type <blk> atmfield
116%type <blk> atmfieldvalue atmvalue atmlistvalue
117%type <blk> mtp3field
118%type <blk> mtp3fieldvalue mtp3value mtp3listvalue
119
120
121%token DST SRC HOST GATEWAY
122%token NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
123%token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP
124%token ATALK AARP DECNET LAT SCA MOPRC MOPDL
125%token TK_BROADCAST TK_MULTICAST
126%token NUM INBOUND OUTBOUND

--- 9 unchanged lines hidden (view full) ---

136%token ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP
137%token STP
138%token IPX
139%token NETBEUI
140%token LANE LLC METAC BCC SC ILMIC OAMF4EC OAMF4SC
141%token OAM OAMF4 CONNECTMSG METACONNECT
142%token VPI VCI
143%token RADIO
144%token SIO OPC DPC SLS
145
146%type <s> ID
147%type <e> EID
148%type <e> AID
149%type <s> HID HID6
150%type <i> NUM action reason
151
152%left OR AND

--- 104 unchanged lines hidden (view full) ---

257 | arth relop arth { $$.b = gen_relation($2, $1, $3, 0);
258 $$.q = qerr; }
259 | arth irelop arth { $$.b = gen_relation($2, $1, $3, 1);
260 $$.q = qerr; }
261 | other { $$.b = $1; $$.q = qerr; }
262 | atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
263 | atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
264 | atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
265 | mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
266 ;
267/* protocol level qualifiers */
268pqual: pname
269 | { $$ = Q_DEFAULT; }
270 ;
271/* 'direction' qualifiers */
272dqual: SRC { $$ = Q_SRC; }

--- 71 unchanged lines hidden (view full) ---

344 | PF_RSET ID { $$ = gen_pf_ruleset($2); }
345 | PF_RNR NUM { $$ = gen_pf_rnr($2); }
346 | PF_SRNR NUM { $$ = gen_pf_srnr($2); }
347 | PF_REASON reason { $$ = gen_pf_reason($2); }
348 | PF_ACTION action { $$ = gen_pf_action($2); }
349 ;
350
351reason: NUM { $$ = $1; }
352 | ID { const char *reasons[] = PFRES_NAMES;
353 int i;
354 for (i = 0; reasons[i]; i++) {
355 if (pcap_strcasecmp($1, reasons[i]) == 0) {
356 $$ = i;
357 break;
358 }
359 }
360 if (reasons[i] == NULL)
361 bpf_error("unknown PF reason");
362 }
363 ;
364
365action: ID { if (pcap_strcasecmp($1, "pass") == 0 ||
366 pcap_strcasecmp($1, "accept") == 0)
367 $$ = PF_PASS;
368 else if (pcap_strcasecmp($1, "drop") == 0 ||
369 pcap_strcasecmp($1, "block") == 0)
370 $$ = PF_DROP;
371 else
372 bpf_error("unknown PF action");
373 }
374 ;
375
376relop: '>' { $$ = BPF_JGT; }
377 | GEQ { $$ = BPF_JGE; }
378 | '=' { $$ = BPF_JEQ; }
379 ;
380irelop: LEQ { $$ = BPF_JGT; }
381 | '<' { $$ = BPF_JGE; }

--- 53 unchanged lines hidden (view full) ---

435 if ($$.atmfieldtype == A_VPI ||
436 $$.atmfieldtype == A_VCI)
437 $$.b = gen_atmfield_code($$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
438 }
439 ;
440atmlistvalue: atmfieldvalue
441 | atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
442 ;
443 /* MTP3 field types quantifier */
444mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
445 | OPC { $$.mtp3fieldtype = M_OPC; }
446 | DPC { $$.mtp3fieldtype = M_DPC; }
447 | SLS { $$.mtp3fieldtype = M_SLS; }
448 ;
449mtp3value: mtp3fieldvalue
450 | relop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }

--- 16 unchanged lines hidden ---