diff options
Diffstat (limited to 'freebsd/contrib/libpcap/scanner.l')
-rw-r--r-- | freebsd/contrib/libpcap/scanner.l | 93 |
1 files changed, 69 insertions, 24 deletions
diff --git a/freebsd/contrib/libpcap/scanner.l b/freebsd/contrib/libpcap/scanner.l index d71a9bed..e0890b43 100644 --- a/freebsd/contrib/libpcap/scanner.l +++ b/freebsd/contrib/libpcap/scanner.l @@ -1,8 +1,30 @@ %top { /* Must come first for _LARGE_FILE_API on AIX. */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif + +/* + * 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" } /* @@ -61,24 +83,8 @@ * 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. - * - * $FreeBSD$ */ -#ifdef _WIN32 - #include <pcap-stdinc.h> -#else - #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 - #include <ctype.h> #include <string.h> @@ -98,6 +104,8 @@ void pcap_set_column(int, yyscan_t); #ifdef INET6 #ifdef _WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> /* * To quote the MSDN page for getaddrinfo() at * @@ -117,10 +125,9 @@ void pcap_set_column(int, yyscan_t); * Wspiapi.h header file. This inline code will be used on older Windows * platforms that do not natively support the getaddrinfo function." * - * We use getaddrinfo(), so we include Wspiapi.h here. pcap-stdinc.h - * includes Ws2tcpip.h, so we don't need to include it ourselves. + * We use getaddrinfo(), so we include Wspiapi.h here. */ -#include <Wspiapi.h> +#include <wspiapi.h> #else /* _WIN32 */ #include <sys/socket.h> /* for "struct sockaddr" in "struct addrinfo" */ #include <netdb.h> /* for "struct addrinfo" */ @@ -143,6 +150,11 @@ void pcap_set_column(int, yyscan_t); static int stoi(char *); static inline int xdtoi(int); +/* + * Disable diagnostics in the code generated by Flex. + */ +DIAG_OFF_FLEX + %} N ([0-9]+|(0X|0x)[0-9A-Fa-f]+) @@ -430,6 +442,36 @@ 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; } + +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; } + tcpflags { yylval->i = 13; return NUM; } tcp-fin { yylval->i = 0x01; return NUM; } tcp-syn { yylval->i = 0x02; return NUM; } @@ -447,10 +489,14 @@ tcp-cwr { yylval->i = 0x80; return NUM; } . { bpf_error(yyextra, "illegal char '%c'", *yytext); } %% +/* + * Turn diagnostics back on, so we check the code that we've written. + */ +DIAG_ON_FLEX + /* Hex digit to integer. */ static inline int -xdtoi(c) - register int c; +xdtoi(int c) { if (isdigit(c)) return c - '0'; @@ -465,8 +511,7 @@ xdtoi(c) * preceding 0x or 0 and uses hex or octal instead of decimal. */ static int -stoi(s) - char *s; +stoi(char *s) { int base = 10; int n = 0; |