diff options
author | mlaier <mlaier@FreeBSD.org> | 2007-10-16 02:02:02 +0000 |
---|---|---|
committer | mlaier <mlaier@FreeBSD.org> | 2007-10-16 02:02:02 +0000 |
commit | 446242760ec28d8a7634115ac07f647f057e2ed5 (patch) | |
tree | d0ef5ecf5675a568c261ed2198083e6dc6d51e94 /contrib/libpcap/grammar.y | |
parent | ffd4bfbe7bca827ff32b489ba212a49c38c3f224 (diff) | |
download | FreeBSD-src-446242760ec28d8a7634115ac07f647f057e2ed5.zip FreeBSD-src-446242760ec28d8a7634115ac07f647f057e2ed5.tar.gz |
Import of libpcap v0.9.8
Diffstat (limited to 'contrib/libpcap/grammar.y')
-rw-r--r-- | contrib/libpcap/grammar.y | 90 |
1 files changed, 64 insertions, 26 deletions
diff --git a/contrib/libpcap/grammar.y b/contrib/libpcap/grammar.y index c2f96f1..f9b7cb1 100644 --- a/contrib/libpcap/grammar.y +++ b/contrib/libpcap/grammar.y @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.5 2005/09/05 09:08:06 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.9 2007/09/12 19:17:25 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -52,7 +52,11 @@ struct rtentry; #include "pcap-int.h" #include "gencode.h" -#include "pf.h" +#ifdef HAVE_NET_PFVAR_H +#include <net/if.h> +#include <net/pfvar.h> +#include <net/if_pflog.h> +#endif #include <pcap-namedb.h> #ifdef HAVE_OS_PROTO_H @@ -68,7 +72,7 @@ int n_errors = 0; static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF }; static void -yyerror(char *msg) +yyerror(const char *msg) { ++n_errors; bpf_error("%s", msg); @@ -85,6 +89,50 @@ pcap_parse() } #endif +#ifdef HAVE_NET_PFVAR_H +static int +pfreason_to_num(const char *reason) +{ + const char *reasons[] = PFRES_NAMES; + int i; + + for (i = 0; reasons[i]; i++) { + if (pcap_strcasecmp(reason, reasons[i]) == 0) + return (i); + } + bpf_error("unknown PF reason"); + /*NOTREACHED*/ +} + +static int +pfaction_to_num(const char *action) +{ + if (pcap_strcasecmp(action, "pass") == 0 || + pcap_strcasecmp(action, "accept") == 0) + return (PF_PASS); + else if (pcap_strcasecmp(action, "drop") == 0 || + pcap_strcasecmp(action, "block") == 0) + return (PF_DROP); + else { + bpf_error("unknown PF action"); + /*NOTREACHED*/ + } +} +#else /* !HAVE_NET_PFVAR_H */ +static int +pfreason_to_num(const char *reason) +{ + bpf_error("libpcap was compiled on a machine without pf support"); + /*NOTREACHED*/ +} + +static int +pfaction_to_num(const char *action) +{ + bpf_error("libpcap was compiled on a machine without pf support"); + /*NOTREACHED*/ +} +#endif /* HAVE_NET_PFVAR_H */ %} %union { @@ -113,8 +161,9 @@ pcap_parse() %type <i> atmtype atmmultitype %type <blk> atmfield %type <blk> atmfieldvalue atmvalue atmlistvalue -%type <blk> mtp3field -%type <blk> mtp3fieldvalue mtp3value mtp3listvalue +%type <i> mtp2type +%type <blk> mtp3field +%type <blk> mtp3fieldvalue mtp3value mtp3listvalue %token DST SRC HOST GATEWAY @@ -140,7 +189,8 @@ pcap_parse() %token OAM OAMF4 CONNECTMSG METACONNECT %token VPI VCI %token RADIO -%token SIO OPC DPC SLS +%token FISU LSSU MSU +%token SIO OPC DPC SLS %type <s> ID %type <e> EID @@ -261,6 +311,7 @@ rterm: head id { $$ = $2; } | atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; } | atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; } | atmfield atmvalue { $$.b = $2.b; $$.q = qerr; } + | mtp2type { $$.b = gen_mtp2type_abbrev($1); $$.q = qerr; } | mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; } ; /* protocol level qualifiers */ @@ -348,28 +399,10 @@ pfvar: PF_IFNAME ID { $$ = gen_pf_ifname($2); } ; reason: NUM { $$ = $1; } - | ID { const char *reasons[] = PFRES_NAMES; - int i; - for (i = 0; reasons[i]; i++) { - if (pcap_strcasecmp($1, reasons[i]) == 0) { - $$ = i; - break; - } - } - if (reasons[i] == NULL) - bpf_error("unknown PF reason"); - } + | ID { $$ = pfreason_to_num($1); } ; -action: ID { if (pcap_strcasecmp($1, "pass") == 0 || - pcap_strcasecmp($1, "accept") == 0) - $$ = PF_PASS; - else if (pcap_strcasecmp($1, "drop") == 0 || - pcap_strcasecmp($1, "block") == 0) - $$ = PF_DROP; - else - bpf_error("unknown PF action"); - } +action: ID { $$ = pfaction_to_num($1); } ; relop: '>' { $$ = BPF_JGT; } @@ -439,6 +472,11 @@ atmfieldvalue: NUM { atmlistvalue: atmfieldvalue | atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; } ; + /* MTP2 types quantifier */ +mtp2type: FISU { $$ = M_FISU; } + | LSSU { $$ = M_LSSU; } + | MSU { $$ = M_MSU; } + ; /* MTP3 field types quantifier */ mtp3field: SIO { $$.mtp3fieldtype = M_SIO; } | OPC { $$.mtp3fieldtype = M_OPC; } |