Merge remote-tracking branch 'goog/tcpdump'
* goog/tcpdump: (1872 commits)
Remove old version. Getting ready for new libpcap 1.5
Remove commas from clauses in a comma-separated list.
Fix typo.
Describe all NFLOG TLV types and define structures for some of them.
Check caplen in the NFLOG TLV loop.
Have nflog_tlv_t include only the TLV header.
Byte-swap the T and L in TLVs as necessary when reading an NFLOG file.
Don't support D-Bus sniffing on OS X.
Add post-1.5.2 bug fixes.
Tag some changes with a bug identifier.
Add items for 1.5.1 and 1.5.2.
Formatting tweak.
Count *ring buffer blocks*, not *packets* to be filtered in userland.
Add a PACKET_COUNT_IS_UNLIMITED() to test for a packet count <= 0.
Use HAVE_TPACKET3 rather than TPACKET_V3 to test for TPACKET_V3 support.
Fix builds on systems without TPACKET_V3.
tweak manpages formatting
Fix pcap_loop() with a count of 0 and TPACKET_V3.
Discourage the use of a zero timeout.
We can't use TPACKET_V3 in immediate mode, so fall back on TPACKET_V2.
...
Change-Id: I2aa9bd87673c56aee439e1154b96a14026ca7985
diff --git a/scanner.l b/scanner.l
index 01face1..daa5eae 100644
--- a/scanner.l
+++ b/scanner.l
@@ -22,13 +22,27 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.99.2.9 2007/06/11 09:52:05 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.112 2008-02-06 10:21:30 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#ifdef WIN32
+#include <pcap-stdinc.h>
+#else /* WIN32 */
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#elif HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif
+#include <sys/types.h>
+#endif /* WIN32 */
+
#include <ctype.h>
#include <string.h>
@@ -40,7 +54,7 @@
#include <pcap-stdinc.h>
#ifdef __MINGW32__
-#include "IP6_misc.h"
+#include "ip6_misc.h"
#endif
#else /* WIN32 */
#include <sys/socket.h> /* for "struct sockaddr" in "struct addrinfo" */
@@ -52,7 +66,7 @@
#define AI_NUMERICHOST 0x04
#endif
#endif /*INET6*/
-#include <pcap-namedb.h>
+#include <pcap/namedb.h>
#include "tokdefs.h"
#ifdef HAVE_OS_PROTO_H
@@ -63,10 +77,11 @@
static inline int xdtoi(int);
#ifdef FLEX_SCANNER
+#define YY_NO_INPUT
#define YY_NO_UNPUT
static YY_BUFFER_STATE in_buffer;
#else
-static char *in_buffer;
+static const char *in_buffer;
#undef getc
#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
@@ -79,6 +94,7 @@
N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
B ([0-9A-Fa-f][0-9A-Fa-f]?)
+B2 ([0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])
W ([0-9A-Fa-f][0-9A-Fa-f]?[0-9A-Fa-f]?[0-9A-Fa-f]?)
%a 18400
@@ -166,6 +182,10 @@
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})
+MAC ({B}:{B}:{B}:{B}:{B}:{B}|{B}\-{B}\-{B}\-{B}\-{B}\-{B}|{B}\.{B}\.{B}\.{B}\.{B}\.{B}|{B2}\.{B2}\.{B2}|{B2}{3})
+
+
+
%%
dst return DST;
src return SRC;
@@ -183,22 +203,11 @@
igrp return IGRP;
pim return PIM;
vrrp return VRRP;
+carp return CARP;
radio return RADIO;
-ip6 {
-#ifdef INET6
- return IPV6;
-#else
- bpf_error("%s not supported", yytext);
-#endif
- }
-icmp6 {
-#ifdef INET6
- return ICMPV6;
-#else
- bpf_error("%s not supported", yytext);
-#endif
- }
+ip6 return IPV6;
+icmp6 return ICMPV6;
ah return AH;
esp return ESP;
@@ -247,6 +256,16 @@
gateway return GATEWAY;
+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;
+ra return RA;
+ta return TA;
+
less return LESS;
greater return GREATER;
byte return CBYTE;
@@ -292,10 +311,17 @@
lssu return LSSU;
lsu return LSSU;
msu return MSU;
+hfisu return HFISU;
+hlssu return HLSSU;
+hmsu return HMSU;
sio return SIO;
opc return OPC;
dpc return DPC;
sls return SLS;
+hsio return HSIO;
+hopc return HOPC;
+hdpc return HDPC;
+hsls return HSLS;
[ \r\n\t] ;
[+\-*/:\[\]!<>()&|=] return yytext[0];
@@ -306,12 +332,16 @@
"<<" return LSH;
">>" return RSH;
${B} { yylval.e = pcap_ether_aton(((char *)yytext)+1);
+ if (yylval.e == NULL)
+ bpf_error("malloc");
return AID; }
+{MAC} { yylval.e = pcap_ether_aton((char *)yytext);
+ if (yylval.e == NULL)
+ bpf_error("malloc");
+ return EID; }
{N} { yylval.i = stoi((char *)yytext); return NUM; }
({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N}) {
yylval.s = sdup((char *)yytext); return HID; }
-{B}:{B}:{B}:{B}:{B}:{B} { yylval.e = pcap_ether_aton((char *)yytext);
- return EID; }
{V6} {
#ifdef INET6
struct addrinfo hints, *res;
@@ -321,6 +351,7 @@
if (getaddrinfo(yytext, NULL, &hints, &res))
bpf_error("bogus IPv6 address %s", yytext);
else {
+ freeaddrinfo(res);
yylval.s = sdup((char *)yytext); return HID6;
}
#else