2017-02-12 07:04:44 +00:00
|
|
|
%top {
|
|
|
|
/* Must come first for _LARGE_FILE_API on AIX. */
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2018-05-18 12:21:19 +00:00
|
|
|
#include <config.h>
|
2017-02-12 07:04:44 +00:00
|
|
|
#endif
|
2018-05-18 12:21:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Must come first to avoid warnings on Windows.
|
|
|
|
*
|
|
|
|
* Flex-generated scanners may only include <inttypes.h> if __STDC_VERSION__
|
|
|
|
* is defined with a value >= 199901, meaning "full C99", and MSVC may not
|
|
|
|
* define it with that value, because it isn't 100% C99-compliant, even
|
|
|
|
* though it has an <inttypes.h> capable of defining everything the Flex
|
|
|
|
* scanner needs.
|
|
|
|
*
|
|
|
|
* We, however, will include it if we know we have an MSVC version that has
|
|
|
|
* it; this means that we may define the INTn_MAX and UINTn_MAX values in
|
|
|
|
* scanner.c, and then include <stdint.h>, which may define them differently
|
|
|
|
* (same value, but different string of characters), causing compiler warnings.
|
|
|
|
*
|
|
|
|
* If we include it here, and they're defined, that'll prevent scanner.c
|
|
|
|
* from defining them. So we include <pcap/pcap-inttypes.h>, to get
|
|
|
|
* <inttypes.h> if we have it.
|
|
|
|
*/
|
|
|
|
#include <pcap/pcap-inttypes.h>
|
|
|
|
|
|
|
|
#include "diag-control.h"
|
2017-02-12 07:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want a reentrant scanner.
|
|
|
|
*/
|
|
|
|
%option reentrant
|
|
|
|
|
|
|
|
/*
|
|
|
|
* And we need to pass the compiler state to the scanner.
|
|
|
|
*/
|
|
|
|
%option extra-type="compiler_state_t *"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't use input, so don't generate code for it.
|
|
|
|
*/
|
|
|
|
%option noinput
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't use unput, so don't generate code for it.
|
|
|
|
*/
|
|
|
|
%option nounput
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't read from the terminal.
|
|
|
|
*/
|
|
|
|
%option never-interactive
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to stop processing when we get to the end of the input.
|
|
|
|
*/
|
|
|
|
%option noyywrap
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to generate code that can be used by a reentrant parser
|
|
|
|
* generated by Bison or Berkeley YACC.
|
|
|
|
*/
|
|
|
|
%option bison-bridge
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
%{
|
|
|
|
/*
|
1998-09-15 19:28:10 +00:00
|
|
|
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
1996-08-19 20:36:34 +00:00
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
|
|
|
* provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
* features or use of this software display the following acknowledgement:
|
|
|
|
* ``This product includes software developed by the University of California,
|
|
|
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
|
|
* the University nor the names of its contributors may be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
2000-01-30 00:32:56 +00:00
|
|
|
#include <string.h>
|
1996-08-19 20:36:34 +00:00
|
|
|
|
|
|
|
#include "pcap-int.h"
|
|
|
|
|
|
|
|
#include "gencode.h"
|
2017-02-12 07:04:44 +00:00
|
|
|
|
|
|
|
#include "grammar.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Earlier versions of Flex don't declare these, so we declare them
|
|
|
|
* ourselves to squelch warnings.
|
|
|
|
*/
|
|
|
|
int pcap_get_column(yyscan_t);
|
|
|
|
void pcap_set_column(int, yyscan_t);
|
|
|
|
|
2000-01-30 00:32:56 +00:00
|
|
|
#ifdef INET6
|
2004-03-31 09:07:39 +00:00
|
|
|
|
2017-02-12 07:04:44 +00:00
|
|
|
#ifdef _WIN32
|
2018-05-18 12:21:19 +00:00
|
|
|
#include <winsock2.h>
|
|
|
|
#include <ws2tcpip.h>
|
2017-02-12 07:04:44 +00:00
|
|
|
/*
|
|
|
|
* To quote the MSDN page for getaddrinfo() at
|
|
|
|
*
|
|
|
|
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx
|
|
|
|
*
|
|
|
|
* "Support for getaddrinfo on Windows 2000 and older versions
|
|
|
|
* The getaddrinfo function was added to the Ws2_32.dll on Windows XP and
|
|
|
|
* later. To execute an application that uses this function on earlier
|
|
|
|
* versions of Windows, then you need to include the Ws2tcpip.h and
|
|
|
|
* Wspiapi.h files. When the Wspiapi.h include file is added, the
|
|
|
|
* getaddrinfo function is defined to the WspiapiGetAddrInfo inline
|
|
|
|
* function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo
|
|
|
|
* function is implemented in such a way that if the Ws2_32.dll or the
|
|
|
|
* Wship6.dll (the file containing getaddrinfo in the IPv6 Technology
|
|
|
|
* Preview for Windows 2000) does not include getaddrinfo, then a
|
|
|
|
* version of getaddrinfo is implemented inline based on code in the
|
|
|
|
* Wspiapi.h header file. This inline code will be used on older Windows
|
|
|
|
* platforms that do not natively support the getaddrinfo function."
|
|
|
|
*
|
2018-05-18 12:21:19 +00:00
|
|
|
* We use getaddrinfo(), so we include Wspiapi.h here.
|
2017-02-12 07:04:44 +00:00
|
|
|
*/
|
2018-05-18 12:21:19 +00:00
|
|
|
#include <wspiapi.h>
|
2017-02-12 07:04:44 +00:00
|
|
|
#else /* _WIN32 */
|
2004-03-31 09:07:39 +00:00
|
|
|
#include <sys/socket.h> /* for "struct sockaddr" in "struct addrinfo" */
|
|
|
|
#include <netdb.h> /* for "struct addrinfo" */
|
2017-02-12 07:04:44 +00:00
|
|
|
#endif /* _WIN32 */
|
2004-03-31 09:07:39 +00:00
|
|
|
|
2001-04-03 04:18:09 +00:00
|
|
|
/* Workaround for AIX 4.3 */
|
|
|
|
#if !defined(AI_NUMERICHOST)
|
|
|
|
#define AI_NUMERICHOST 0x04
|
|
|
|
#endif
|
2017-02-12 07:04:44 +00:00
|
|
|
|
2000-01-30 00:32:56 +00:00
|
|
|
#endif /*INET6*/
|
2017-02-12 07:04:44 +00:00
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#include <pcap/namedb.h>
|
2017-02-12 07:04:44 +00:00
|
|
|
#include "grammar.h"
|
1996-08-19 20:36:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_OS_PROTO_H
|
|
|
|
#include "os-proto.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int stoi(char *);
|
|
|
|
static inline int xdtoi(int);
|
|
|
|
|
2018-05-18 12:21:19 +00:00
|
|
|
/*
|
|
|
|
* Disable diagnostics in the code generated by Flex.
|
|
|
|
*/
|
|
|
|
DIAG_OFF_FLEX
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
|
|
|
|
B ([0-9A-Fa-f][0-9A-Fa-f]?)
|
2009-03-21 20:43:56 +00:00
|
|
|
B2 ([0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])
|
2000-01-30 00:32:56 +00:00
|
|
|
W ([0-9A-Fa-f][0-9A-Fa-f]?[0-9A-Fa-f]?[0-9A-Fa-f]?)
|
1996-08-19 20:36:34 +00:00
|
|
|
|
2007-10-16 02:02:02 +00:00
|
|
|
%a 18400
|
|
|
|
%o 21500
|
|
|
|
%e 7600
|
|
|
|
%k 4550
|
|
|
|
%p 27600
|
2001-04-03 04:18:09 +00:00
|
|
|
%n 2000
|
2000-01-30 00:32:56 +00:00
|
|
|
|
|
|
|
V680 {W}:{W}:{W}:{W}:{W}:{W}:{W}:{W}
|
|
|
|
|
|
|
|
V670 ::{W}:{W}:{W}:{W}:{W}:{W}:{W}
|
|
|
|
V671 {W}::{W}:{W}:{W}:{W}:{W}:{W}
|
|
|
|
V672 {W}:{W}::{W}:{W}:{W}:{W}:{W}
|
|
|
|
V673 {W}:{W}:{W}::{W}:{W}:{W}:{W}
|
|
|
|
V674 {W}:{W}:{W}:{W}::{W}:{W}:{W}
|
|
|
|
V675 {W}:{W}:{W}:{W}:{W}::{W}:{W}
|
|
|
|
V676 {W}:{W}:{W}:{W}:{W}:{W}::{W}
|
|
|
|
V677 {W}:{W}:{W}:{W}:{W}:{W}:{W}::
|
|
|
|
|
|
|
|
V660 ::{W}:{W}:{W}:{W}:{W}:{W}
|
|
|
|
V661 {W}::{W}:{W}:{W}:{W}:{W}
|
|
|
|
V662 {W}:{W}::{W}:{W}:{W}:{W}
|
|
|
|
V663 {W}:{W}:{W}::{W}:{W}:{W}
|
|
|
|
V664 {W}:{W}:{W}:{W}::{W}:{W}
|
|
|
|
V665 {W}:{W}:{W}:{W}:{W}::{W}
|
|
|
|
V666 {W}:{W}:{W}:{W}:{W}:{W}::
|
|
|
|
|
|
|
|
V650 ::{W}:{W}:{W}:{W}:{W}
|
|
|
|
V651 {W}::{W}:{W}:{W}:{W}
|
|
|
|
V652 {W}:{W}::{W}:{W}:{W}
|
|
|
|
V653 {W}:{W}:{W}::{W}:{W}
|
|
|
|
V654 {W}:{W}:{W}:{W}::{W}
|
|
|
|
V655 {W}:{W}:{W}:{W}:{W}::
|
|
|
|
|
|
|
|
V640 ::{W}:{W}:{W}:{W}
|
|
|
|
V641 {W}::{W}:{W}:{W}
|
|
|
|
V642 {W}:{W}::{W}:{W}
|
|
|
|
V643 {W}:{W}:{W}::{W}
|
|
|
|
V644 {W}:{W}:{W}:{W}::
|
|
|
|
|
|
|
|
V630 ::{W}:{W}:{W}
|
|
|
|
V631 {W}::{W}:{W}
|
|
|
|
V632 {W}:{W}::{W}
|
|
|
|
V633 {W}:{W}:{W}::
|
|
|
|
|
|
|
|
V620 ::{W}:{W}
|
|
|
|
V621 {W}::{W}
|
|
|
|
V622 {W}:{W}::
|
|
|
|
|
|
|
|
V610 ::{W}
|
|
|
|
V611 {W}::
|
|
|
|
|
|
|
|
V600 ::
|
|
|
|
|
|
|
|
V6604 {W}:{W}:{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
V6504 ::{W}:{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6514 {W}::{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6524 {W}:{W}::{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6534 {W}:{W}:{W}::{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6544 {W}:{W}:{W}:{W}::{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6554 {W}:{W}:{W}:{W}:{W}::{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
V6404 ::{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6414 {W}::{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6424 {W}:{W}::{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6434 {W}:{W}:{W}::{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6444 {W}:{W}:{W}:{W}::{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
V6304 ::{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6314 {W}::{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6324 {W}:{W}::{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6334 {W}:{W}:{W}::{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
V6204 ::{W}:{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6214 {W}::{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6224 {W}:{W}::{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
V6104 ::{W}:{N}\.{N}\.{N}\.{N}
|
|
|
|
V6114 {W}::{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
V6004 ::{N}\.{N}\.{N}\.{N}
|
|
|
|
|
|
|
|
|
|
|
|
V6 ({V680}|{V670}|{V671}|{V672}|{V673}|{V674}|{V675}|{V676}|{V677}|{V660}|{V661}|{V662}|{V663}|{V664}|{V665}|{V666}|{V650}|{V651}|{V652}|{V653}|{V654}|{V655}|{V640}|{V641}|{V642}|{V643}|{V644}|{V630}|{V631}|{V632}|{V633}|{V620}|{V621}|{V622}|{V610}|{V611}|{V600}|{V6604}|{V6504}|{V6514}|{V6524}|{V6534}|{V6544}|{V6554}|{V6404}|{V6414}|{V6424}|{V6434}|{V6444}|{V6304}|{V6314}|{V6324}|{V6334}|{V6204}|{V6214}|{V6224}|{V6104}|{V6114}|{V6004})
|
1996-08-19 20:36:34 +00:00
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
MAC ({B}:{B}:{B}:{B}:{B}:{B}|{B}\-{B}\-{B}\-{B}\-{B}\-{B}|{B}\.{B}\.{B}\.{B}\.{B}\.{B}|{B2}\.{B2}\.{B2}|{B2}{3})
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
%%
|
|
|
|
dst return DST;
|
|
|
|
src return SRC;
|
|
|
|
|
|
|
|
link|ether|ppp|slip return LINK;
|
2004-03-31 09:07:39 +00:00
|
|
|
fddi|tr|wlan return LINK;
|
1996-08-19 20:36:34 +00:00
|
|
|
arp return ARP;
|
|
|
|
rarp return RARP;
|
|
|
|
ip return IP;
|
2002-06-21 01:36:27 +00:00
|
|
|
sctp return SCTP;
|
1996-08-19 20:36:34 +00:00
|
|
|
tcp return TCP;
|
|
|
|
udp return UDP;
|
|
|
|
icmp return ICMP;
|
|
|
|
igmp return IGMP;
|
|
|
|
igrp return IGRP;
|
2000-01-30 00:32:56 +00:00
|
|
|
pim return PIM;
|
2002-06-21 01:36:27 +00:00
|
|
|
vrrp return VRRP;
|
2012-01-31 17:22:07 +00:00
|
|
|
carp return CARP;
|
2005-07-11 03:24:53 +00:00
|
|
|
radio return RADIO;
|
2000-01-30 00:32:56 +00:00
|
|
|
|
2013-05-30 06:41:26 +00:00
|
|
|
ip6 return IPV6;
|
|
|
|
icmp6 return ICMPV6;
|
2000-01-30 00:32:56 +00:00
|
|
|
ah return AH;
|
|
|
|
esp return ESP;
|
1996-08-19 20:36:34 +00:00
|
|
|
|
|
|
|
atalk return ATALK;
|
2001-04-03 04:18:09 +00:00
|
|
|
aarp return AARP;
|
1996-08-19 20:36:34 +00:00
|
|
|
decnet return DECNET;
|
|
|
|
lat return LAT;
|
|
|
|
sca return SCA;
|
|
|
|
moprc return MOPRC;
|
|
|
|
mopdl return MOPDL;
|
|
|
|
|
2001-04-03 04:18:09 +00:00
|
|
|
iso return ISO;
|
|
|
|
esis return ESIS;
|
|
|
|
es-is return ESIS;
|
|
|
|
isis return ISIS;
|
|
|
|
is-is return ISIS;
|
2004-03-31 09:07:39 +00:00
|
|
|
l1 return L1;
|
|
|
|
l2 return L2;
|
|
|
|
iih return IIH;
|
|
|
|
lsp return LSP;
|
|
|
|
snp return SNP;
|
|
|
|
csnp return CSNP;
|
|
|
|
psnp return PSNP;
|
|
|
|
|
2001-04-03 04:18:09 +00:00
|
|
|
clnp return CLNP;
|
|
|
|
|
2002-06-21 01:36:27 +00:00
|
|
|
stp return STP;
|
|
|
|
|
|
|
|
ipx return IPX;
|
|
|
|
|
|
|
|
netbeui return NETBEUI;
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
host return HOST;
|
|
|
|
net return NET;
|
2004-03-31 09:07:39 +00:00
|
|
|
mask return NETMASK;
|
1996-08-19 20:36:34 +00:00
|
|
|
port return PORT;
|
2005-07-11 03:24:53 +00:00
|
|
|
portrange return PORTRANGE;
|
1996-08-19 20:36:34 +00:00
|
|
|
proto return PROTO;
|
2000-01-30 00:32:56 +00:00
|
|
|
protochain {
|
|
|
|
#ifdef NO_PROTOCHAIN
|
2017-02-12 07:04:44 +00:00
|
|
|
bpf_error(yyextra, "%s not supported", yytext);
|
2000-01-30 00:32:56 +00:00
|
|
|
#else
|
|
|
|
return PROTOCHAIN;
|
|
|
|
#endif
|
|
|
|
}
|
1996-08-19 20:36:34 +00:00
|
|
|
|
|
|
|
gateway return GATEWAY;
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
type return TYPE;
|
|
|
|
subtype return SUBTYPE;
|
|
|
|
direction|dir return DIR;
|
|
|
|
address1|addr1 return ADDR1;
|
|
|
|
address2|addr2 return ADDR2;
|
|
|
|
address3|addr3 return ADDR3;
|
|
|
|
address4|addr4 return ADDR4;
|
2012-01-31 17:22:07 +00:00
|
|
|
ra return RA;
|
|
|
|
ta return TA;
|
2009-03-21 20:43:56 +00:00
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
less return LESS;
|
|
|
|
greater return GREATER;
|
2004-03-31 09:07:39 +00:00
|
|
|
byte return CBYTE;
|
1996-08-19 20:36:34 +00:00
|
|
|
broadcast return TK_BROADCAST;
|
|
|
|
multicast return TK_MULTICAST;
|
|
|
|
|
|
|
|
and|"&&" return AND;
|
|
|
|
or|"||" return OR;
|
|
|
|
not return '!';
|
|
|
|
|
|
|
|
len|length return LEN;
|
|
|
|
inbound return INBOUND;
|
|
|
|
outbound return OUTBOUND;
|
|
|
|
|
2001-04-03 04:18:09 +00:00
|
|
|
vlan return VLAN;
|
2005-05-29 17:46:52 +00:00
|
|
|
mpls return MPLS;
|
2006-09-04 19:43:23 +00:00
|
|
|
pppoed return PPPOED;
|
|
|
|
pppoes return PPPOES;
|
2017-02-12 07:04:44 +00:00
|
|
|
geneve return GENEVE;
|
2001-04-03 04:18:09 +00:00
|
|
|
|
2004-03-31 09:07:39 +00:00
|
|
|
lane return LANE;
|
|
|
|
llc return LLC;
|
|
|
|
metac return METAC;
|
|
|
|
bcc return BCC;
|
|
|
|
oam return OAM;
|
|
|
|
oamf4 return OAMF4;
|
|
|
|
oamf4ec return OAMF4EC;
|
|
|
|
oamf4sc return OAMF4SC;
|
|
|
|
sc return SC;
|
|
|
|
ilmic return ILMIC;
|
|
|
|
vpi return VPI;
|
|
|
|
vci return VCI;
|
|
|
|
connectmsg return CONNECTMSG;
|
|
|
|
metaconnect return METACONNECT;
|
|
|
|
|
|
|
|
on|ifname return PF_IFNAME;
|
|
|
|
rset|ruleset return PF_RSET;
|
|
|
|
rnr|rulenum return PF_RNR;
|
|
|
|
srnr|subrulenum return PF_SRNR;
|
|
|
|
reason return PF_REASON;
|
|
|
|
action return PF_ACTION;
|
|
|
|
|
2007-10-16 02:02:02 +00:00
|
|
|
fisu return FISU;
|
|
|
|
lssu return LSSU;
|
|
|
|
lsu return LSSU;
|
|
|
|
msu return MSU;
|
2015-01-06 18:58:31 +00:00
|
|
|
hfisu return HFISU;
|
|
|
|
hlssu return HLSSU;
|
|
|
|
hmsu return HMSU;
|
2005-07-11 03:24:53 +00:00
|
|
|
sio return SIO;
|
|
|
|
opc return OPC;
|
|
|
|
dpc return DPC;
|
|
|
|
sls return SLS;
|
2015-01-06 18:58:31 +00:00
|
|
|
hsio return HSIO;
|
|
|
|
hopc return HOPC;
|
|
|
|
hdpc return HDPC;
|
|
|
|
hsls return HSLS;
|
2005-07-11 03:24:53 +00:00
|
|
|
|
2004-03-31 09:07:39 +00:00
|
|
|
[ \r\n\t] ;
|
2015-01-06 18:58:31 +00:00
|
|
|
[+\-*/%:\[\]!<>()&|\^=] return yytext[0];
|
1996-08-19 20:36:34 +00:00
|
|
|
">=" return GEQ;
|
|
|
|
"<=" return LEQ;
|
|
|
|
"!=" return NEQ;
|
|
|
|
"==" return '=';
|
|
|
|
"<<" return LSH;
|
|
|
|
">>" return RSH;
|
2017-02-12 07:04:44 +00:00
|
|
|
${B} { yylval->e = pcap_ether_aton(((char *)yytext)+1);
|
|
|
|
if (yylval->e == NULL)
|
|
|
|
bpf_error(yyextra, "malloc");
|
2002-06-21 01:36:27 +00:00
|
|
|
return AID; }
|
2017-02-12 07:04:44 +00:00
|
|
|
{MAC} { yylval->e = pcap_ether_aton((char *)yytext);
|
|
|
|
if (yylval->e == NULL)
|
|
|
|
bpf_error(yyextra, "malloc");
|
2009-03-21 20:43:56 +00:00
|
|
|
return EID; }
|
2017-02-12 07:04:44 +00:00
|
|
|
{N} { yylval->i = stoi((char *)yytext); return NUM; }
|
1996-08-19 20:36:34 +00:00
|
|
|
({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N}) {
|
2017-02-12 07:04:44 +00:00
|
|
|
yylval->s = sdup(yyextra, (char *)yytext); return HID; }
|
2000-01-30 00:32:56 +00:00
|
|
|
{V6} {
|
|
|
|
#ifdef INET6
|
|
|
|
struct addrinfo hints, *res;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_family = AF_INET6;
|
|
|
|
hints.ai_flags = AI_NUMERICHOST;
|
|
|
|
if (getaddrinfo(yytext, NULL, &hints, &res))
|
2017-02-12 07:04:44 +00:00
|
|
|
bpf_error(yyextra, "bogus IPv6 address %s", yytext);
|
2000-01-30 00:32:56 +00:00
|
|
|
else {
|
Update libpcap to 1.1.1.
Changes:
Thu. April 1, 2010. guy@alum.mit.edu.
Summary for 1.1.1 libpcap release
Update CHANGES to reflect more of the changes in 1.1.0.
Fix build on RHEL5.
Fix shared library build on AIX.
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
Summary for 1.1.0 libpcap release
Add SocketCAN capture support
Add Myricom SNF API support
Update Endace DAG and ERF support
Add support for shared libraries on Solaris, HP-UX, and AIX
Build, install, and un-install shared libraries by default;
don't build/install shared libraries on platforms we don't support
Fix building from a directory other than the source directory
Fix compiler warnings and builds on some platforms
Update config.guess and config.sub
Support monitor mode on mac80211 devices on Linux
Fix USB memory-mapped capturing on Linux; it requires a new DLT_
value
On Linux, scan /sys/class/net for devices if we have it; scan
it, or /proc/net/dev if we don't have /sys/class/net, even if
we have getifaddrs(), as it'll find interfaces with no
addresses
Add limited support for reading pcap-ng files
Fix BPF driver-loading error handling on AIX
Support getting the full-length interface description on FreeBSD
In the lexical analyzer, free up any addrinfo structure we got back
from getaddrinfo().
Add support for BPF and libdlpi in OpenSolaris (and SXCE)
Hyphenate "link-layer" everywhere
Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations
In pcap_read_linux_mmap(), if there are no frames available, call
poll() even if we're in non-blocking mode, so we pick up
errors, and check for the errors in question.
Note that poll() works on BPF devices is Snow Leopard
If an ENXIO or ENETDOWN is received, it may mean the device has
gone away. Deal with it.
For BPF, raise the default capture buffer size to from 32k to 512k
Support ps_ifdrop on Linux
Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile
under cygwin.
Changes to Linux mmapped captures.
Fix bug where create_ring would fail for particular snaplen and
buffer size combinations
Update pcap-config so that it handles libpcap requiring
additional libraries
Add workaround for threadsafeness on Windows
Add missing mapping for DLT_ENC <-> LINKTYPE_ENC
DLT: Add DLT_CAN_SOCKETCAN
DLT: Add Solaris ipnet
Don't check for DLT_IPNET if it's not defined
Add link-layer types for Fibre Channel FC-2
Add link-layer types for Wireless HART
Add link-layer types for AOS
Add link-layer types for DECT
Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups)
Install headers unconditionally, and include vlan.h/bluetooth.h if
enabled
Autoconf fixes+cleanup
Support enabling/disabling bluetooth (--{en,dis}able-bluetooth)
Support disabling SITA support (--without-sita)
Return -1 on failure to create packet ring (if supported but
creation failed)
Fix handling of 'any' device, so that it can be opened, and no longer
attempt to open it in Monitor mode
Add support for snapshot length for USB Memory-Mapped Interface
Fix configure and build on recent Linux kernels
Fix memory-mapped Linux capture to support pcap_next() and
pcap_next_ex()
Fixes for Linux USB capture
DLT: Add DLT_LINUX_EVDEV
DLT: Add DLT_GSMTAP_UM
DLT: Add DLT_GSMTAP_ABIS
2010-10-28 16:22:13 +00:00
|
|
|
freeaddrinfo(res);
|
2017-02-12 07:04:44 +00:00
|
|
|
yylval->s = sdup(yyextra, (char *)yytext); return HID6;
|
2000-01-30 00:32:56 +00:00
|
|
|
}
|
|
|
|
#else
|
2017-02-12 07:04:44 +00:00
|
|
|
bpf_error(yyextra, "IPv6 address %s not supported", yytext);
|
2000-01-30 00:32:56 +00:00
|
|
|
#endif /*INET6*/
|
|
|
|
}
|
2017-02-12 07:04:44 +00:00
|
|
|
{B}:+({B}:+)+ { bpf_error(yyextra, "bogus ethernet address %s", yytext); }
|
|
|
|
icmptype { yylval->i = 0; return NUM; }
|
|
|
|
icmpcode { yylval->i = 1; return NUM; }
|
|
|
|
icmp-echoreply { yylval->i = 0; return NUM; }
|
|
|
|
icmp-unreach { yylval->i = 3; return NUM; }
|
|
|
|
icmp-sourcequench { yylval->i = 4; return NUM; }
|
|
|
|
icmp-redirect { yylval->i = 5; return NUM; }
|
|
|
|
icmp-echo { yylval->i = 8; return NUM; }
|
|
|
|
icmp-routeradvert { yylval->i = 9; return NUM; }
|
|
|
|
icmp-routersolicit { yylval->i = 10; return NUM; }
|
|
|
|
icmp-timxceed { yylval->i = 11; return NUM; }
|
|
|
|
icmp-paramprob { yylval->i = 12; return NUM; }
|
|
|
|
icmp-tstamp { yylval->i = 13; return NUM; }
|
|
|
|
icmp-tstampreply { yylval->i = 14; return NUM; }
|
|
|
|
icmp-ireq { yylval->i = 15; return NUM; }
|
|
|
|
icmp-ireqreply { yylval->i = 16; return NUM; }
|
|
|
|
icmp-maskreq { yylval->i = 17; return NUM; }
|
|
|
|
icmp-maskreply { yylval->i = 18; return NUM; }
|
2018-05-18 12:21:19 +00:00
|
|
|
|
|
|
|
icmp6type { yylval->i = 0; return NUM; }
|
|
|
|
icmp6code { yylval->i = 1; return NUM; }
|
|
|
|
|
|
|
|
icmp6-echo { yylval->i = 128; return NUM; }
|
|
|
|
icmp6-echoreply { yylval->i = 129; return NUM; }
|
|
|
|
icmp6-multicastlistenerquery { yylval->i = 130; return NUM; }
|
|
|
|
icmp6-multicastlistenerreportv1 { yylval->i = 131; return NUM; }
|
|
|
|
icmp6-multicastlistenerdone { yylval->i = 132; return NUM; }
|
|
|
|
icmp6-routersolicit { yylval->i = 133; return NUM; }
|
|
|
|
icmp6-routeradvert { yylval->i = 134; return NUM; }
|
|
|
|
icmp6-neighborsolicit { yylval->i = 135; return NUM; }
|
|
|
|
icmp6-neighboradvert { yylval->i = 136; return NUM; }
|
|
|
|
icmp6-redirect { yylval->i = 137; return NUM; }
|
|
|
|
icmp6-routerrenum { yylval->i = 138; return NUM; }
|
|
|
|
icmp6-nodeinformationquery { yylval->i = 139; return NUM; }
|
|
|
|
icmp6-nodeinformationresponse { yylval->i = 140; return NUM; }
|
|
|
|
icmp6-ineighbordiscoverysolicit { yylval->i = 141; return NUM; }
|
|
|
|
icmp6-ineighbordiscoveryadvert { yylval->i = 142; return NUM; }
|
|
|
|
icmp6-multicastlistenerreportv2 { yylval->i = 143; return NUM; }
|
|
|
|
icmp6-homeagentdiscoveryrequest { yylval->i = 144; return NUM; }
|
|
|
|
icmp6-homeagentdiscoveryreply { yylval->i = 145; return NUM; }
|
|
|
|
icmp6-mobileprefixsolicit { yylval->i = 146; return NUM; }
|
|
|
|
icmp6-mobileprefixadvert { yylval->i = 147; return NUM; }
|
|
|
|
icmp6-certpathsolicit { yylval->i = 148; return NUM; }
|
|
|
|
icmp6-certpathadvert { yylval->i = 149; return NUM; }
|
|
|
|
icmp6-multicastrouteradvert { yylval->i = 151; return NUM; }
|
|
|
|
icmp6-multicastroutersolicit { yylval->i = 152; return NUM; }
|
|
|
|
icmp6-multicastrouterterm { yylval->i = 153; return NUM; }
|
|
|
|
|
2017-02-12 07:04:44 +00:00
|
|
|
tcpflags { yylval->i = 13; return NUM; }
|
|
|
|
tcp-fin { yylval->i = 0x01; return NUM; }
|
|
|
|
tcp-syn { yylval->i = 0x02; return NUM; }
|
|
|
|
tcp-rst { yylval->i = 0x04; return NUM; }
|
|
|
|
tcp-push { yylval->i = 0x08; return NUM; }
|
|
|
|
tcp-ack { yylval->i = 0x10; return NUM; }
|
|
|
|
tcp-urg { yylval->i = 0x20; return NUM; }
|
2018-05-18 12:21:19 +00:00
|
|
|
tcp-ece { yylval->i = 0x40; return NUM; }
|
|
|
|
tcp-cwr { yylval->i = 0x80; return NUM; }
|
2002-06-21 01:36:27 +00:00
|
|
|
[A-Za-z0-9]([-_.A-Za-z0-9]*[.A-Za-z0-9])? {
|
2017-02-12 07:04:44 +00:00
|
|
|
yylval->s = sdup(yyextra, (char *)yytext); return ID; }
|
|
|
|
"\\"[^ !()\n\t]+ { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }
|
2002-06-21 01:36:27 +00:00
|
|
|
[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+ {
|
2017-02-12 07:04:44 +00:00
|
|
|
bpf_error(yyextra, "illegal token: %s", yytext); }
|
|
|
|
. { bpf_error(yyextra, "illegal char '%c'", *yytext); }
|
1996-08-19 20:36:34 +00:00
|
|
|
%%
|
|
|
|
|
2018-05-18 12:21:19 +00:00
|
|
|
/*
|
|
|
|
* Turn diagnostics back on, so we check the code that we've written.
|
|
|
|
*/
|
|
|
|
DIAG_ON_FLEX
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
/* Hex digit to integer. */
|
|
|
|
static inline int
|
2018-05-18 12:21:19 +00:00
|
|
|
xdtoi(int c)
|
1996-08-19 20:36:34 +00:00
|
|
|
{
|
|
|
|
if (isdigit(c))
|
|
|
|
return c - '0';
|
|
|
|
else if (islower(c))
|
|
|
|
return c - 'a' + 10;
|
|
|
|
else
|
|
|
|
return c - 'A' + 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert string to integer. Just like atoi(), but checks for
|
|
|
|
* preceding 0x or 0 and uses hex or octal instead of decimal.
|
|
|
|
*/
|
|
|
|
static int
|
2018-05-18 12:21:19 +00:00
|
|
|
stoi(char *s)
|
1996-08-19 20:36:34 +00:00
|
|
|
{
|
|
|
|
int base = 10;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
if (*s == '0') {
|
|
|
|
if (s[1] == 'x' || s[1] == 'X') {
|
|
|
|
s += 2;
|
|
|
|
base = 16;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
base = 8;
|
|
|
|
s += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (*s)
|
|
|
|
n = n * base + xdtoi(*s++);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|