diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-08-21 13:47:02 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-21 10:29:41 +0200 |
commit | bcdce02d9bc8150e1d191ed5ca9da45b7604964a (patch) | |
tree | 3b2faf509db7672ee1fc98857736470be97e7ed8 /freebsd/contrib | |
parent | Update to FreeBSD head 2018-04-01 (diff) | |
download | rtems-libbsd-bcdce02d9bc8150e1d191ed5ca9da45b7604964a.tar.bz2 |
Update to FreeBSD head 2018-06-01
Git mirror commit fb63610a69b0eb7f69a201ba05c4c1a7a2739cf9.
Update #3472.
Diffstat (limited to 'freebsd/contrib')
45 files changed, 8980 insertions, 5657 deletions
diff --git a/freebsd/contrib/libpcap/bpf_image.c b/freebsd/contrib/libpcap/bpf_image.c index 5ab1b2a8..2bf71c6d 100644 --- a/freebsd/contrib/libpcap/bpf_image.c +++ b/freebsd/contrib/libpcap/bpf_image.c @@ -22,22 +22,10 @@ */ #ifdef HAVE_CONFIG_H -#include "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 <pcap-types.h> #include <stdio.h> #include <string.h> @@ -49,266 +37,290 @@ #endif char * -bpf_image(p, n) - const struct bpf_insn *p; - int n; +bpf_image(const struct bpf_insn *p, int n) { - int v; - const char *fmt, *op; + const char *op; static char image[256]; - char operand[64]; + char operand_buf[64]; + const char *operand; - v = p->k; switch (p->code) { default: op = "unimp"; - fmt = "0x%x"; - v = p->code; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "0x%x", p->code); + operand = operand_buf; break; case BPF_RET|BPF_K: op = "ret"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_RET|BPF_A: op = "ret"; - fmt = ""; + operand = ""; break; case BPF_LD|BPF_W|BPF_ABS: op = "ld"; - fmt = "[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_H|BPF_ABS: op = "ldh"; - fmt = "[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_B|BPF_ABS: op = "ldb"; - fmt = "[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_W|BPF_LEN: op = "ld"; - fmt = "#pktlen"; + operand = "#pktlen"; break; case BPF_LD|BPF_W|BPF_IND: op = "ld"; - fmt = "[x + %d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_H|BPF_IND: op = "ldh"; - fmt = "[x + %d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_B|BPF_IND: op = "ldb"; - fmt = "[x + %d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_IMM: op = "ld"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_LDX|BPF_IMM: op = "ldx"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_LDX|BPF_MSH|BPF_B: op = "ldxb"; - fmt = "4*([%d]&0xf)"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "4*([%d]&0xf)", p->k); + operand = operand_buf; break; case BPF_LD|BPF_MEM: op = "ld"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_LDX|BPF_MEM: op = "ldx"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_ST: op = "st"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_STX: op = "stx"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JA: op = "ja"; - fmt = "%d"; - v = n + 1 + p->k; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "%d", n + 1 + p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JGT|BPF_K: op = "jgt"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JGE|BPF_K: op = "jge"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JEQ|BPF_K: op = "jeq"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JSET|BPF_K: op = "jset"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JGT|BPF_X: op = "jgt"; - fmt = "x"; + operand = "x"; break; case BPF_JMP|BPF_JGE|BPF_X: op = "jge"; - fmt = "x"; + operand = "x"; break; case BPF_JMP|BPF_JEQ|BPF_X: op = "jeq"; - fmt = "x"; + operand = "x"; break; case BPF_JMP|BPF_JSET|BPF_X: op = "jset"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_ADD|BPF_X: op = "add"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_SUB|BPF_X: op = "sub"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_MUL|BPF_X: op = "mul"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_DIV|BPF_X: op = "div"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_MOD|BPF_X: op = "mod"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_AND|BPF_X: op = "and"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_OR|BPF_X: op = "or"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_XOR|BPF_X: op = "xor"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_LSH|BPF_X: op = "lsh"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_RSH|BPF_X: op = "rsh"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_ADD|BPF_K: op = "add"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_SUB|BPF_K: op = "sub"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_MUL|BPF_K: op = "mul"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_DIV|BPF_K: op = "div"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_MOD|BPF_K: op = "mod"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_AND|BPF_K: op = "and"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_OR|BPF_K: op = "or"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_XOR|BPF_K: op = "xor"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_LSH|BPF_K: op = "lsh"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_RSH|BPF_K: op = "rsh"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_NEG: op = "neg"; - fmt = ""; + operand = ""; break; case BPF_MISC|BPF_TAX: op = "tax"; - fmt = ""; + operand = ""; break; case BPF_MISC|BPF_TXA: op = "txa"; - fmt = ""; + operand = ""; break; } - (void)pcap_snprintf(operand, sizeof operand, fmt, v); if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) { (void)pcap_snprintf(image, sizeof image, "(%03d) %-8s %-16s jt %d\tjf %d", diff --git a/freebsd/contrib/libpcap/diag-control.h b/freebsd/contrib/libpcap/diag-control.h new file mode 100644 index 00000000..12770361 --- /dev/null +++ b/freebsd/contrib/libpcap/diag-control.h @@ -0,0 +1,215 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _diag_control_h +#define _diag_control_h + +#include "pcap/compiler-tests.h" + +#ifndef _MSC_VER + /* + * Clang and GCC both support this way of putting pragmas into #defines. + * We don't use it unless we have a compiler that supports it; the + * warning-suppressing pragmas differ between Clang and GCC, so we test + * for both of those separately. + */ + #define PCAP_DO_PRAGMA(x) _Pragma (#x) +#endif + +/* + * Suppress Flex warnings. + */ +#if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX)) + * and __pragma(warning(push/pop)). + * + * Suppress signed-vs-unsigned comparison, narrowing, and unreachable + * code warnings. + */ + #define DIAG_OFF_FLEX \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + __pragma(warning(disable:4242)) \ + __pragma(warning(disable:4244)) \ + __pragma(warning(disable:4702)) + #define DIAG_ON_FLEX __pragma(warning(pop)) +#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later; we can use "clang diagnostic + * ignored -Wxxx" and "clang diagnostic push/pop". + * + * Suppress -Wdocumentation warnings; GCC doesn't support -Wdocumentation, + * at least according to the GCC 7.3 documentation. Apparently, Flex + * generates code that upsets at least some versions of Clang's + * -Wdocumentation. + */ + #define DIAG_OFF_FLEX \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wsign-compare") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdocumentation") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wmissing-noreturn") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunused-parameter") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_FLEX \ + PCAP_DO_PRAGMA(clang diagnostic pop) +#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * This is GCC 4.6 or later, or a compiler claiming to be that. + * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2) + * and "GCC diagnostic push/pop" (introduced in 4.6). + */ + #define DIAG_OFF_FLEX \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wsign-compare") \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunused-parameter") \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_FLEX \ + PCAP_DO_PRAGMA(GCC diagnostic pop) +#else + /* + * Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later + * or a compiler claiming to be that; there's nothing we know of that + * we can do. + */ + #define DIAG_OFF_FLEX + #define DIAG_ON_FLEX +#endif + +#ifdef YYBYACC + /* + * Berkeley YACC. + * + * It generates a global declaration of yylval, or the appropriately + * prefixed version of yylval, in grammar.h, *even though it's been + * told to generate a pure parser, meaning it doesn't have any global + * variables*. Bison doesn't do this. + * + * That causes a warning due to the local declaration in the parser + * shadowing the global declaration. + * + * So, if the compiler warns about that, we turn off -Wshadow warnings. + */ + #if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use + * __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)). + * + * Suppress unreachable code warnings. + */ + #define DIAG_OFF_BISON_BYACC \ + __pragma(warning(push)) \ + __pragma(warning(disable:4702)) + #define DIAG_ON_BISON_BYACC __pragma(warning(pop)) + #elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later; we can use "clang diagnostic + * ignored -Wxxx" and "clang diagnostic push/pop". + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic pop) + #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * This is GCC 4.6 or later, or a compiler claiming to be that. + * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2) + * and "GCC diagnostic push/pop" (introduced in 4.6). + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wshadow") \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic pop) + #else + /* + * Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler + * claiming to be that; there's nothing we know of that we can do. + */ + #define DIAG_OFF_BISON_BYACC + #define DIAG_ON_BISON_BYACC + #endif +#else + /* + * Bison. + */ + #if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use + * __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)). + * + * Suppress some /Wall warnings. + */ + #define DIAG_OFF_BISON_BYACC \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + __pragma(warning(disable:4242)) \ + __pragma(warning(disable:4244)) \ + __pragma(warning(disable:4702)) + #define DIAG_ON_BISON_BYACC __pragma(warning(pop)) + #elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later; we can use "clang diagnostic + * ignored -Wxxx" and "clang diagnostic push/pop". + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic pop) + #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * This is GCC 4.6 or later, or a compiler claiming to be that. + * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2) + * and "GCC diagnostic push/pop" (introduced in 4.6). + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic pop) + #else + /* + * Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler + * claiming to be that; there's nothing we know of that we can do. + */ + #define DIAG_OFF_BISON_BYACC + #define DIAG_ON_BISON_BYACC + #endif +#endif + +#endif /* _diag_control_h */ diff --git a/freebsd/contrib/libpcap/etherent.c b/freebsd/contrib/libpcap/etherent.c index 0291acc1..0522ac9b 100644 --- a/freebsd/contrib/libpcap/etherent.c +++ b/freebsd/contrib/libpcap/etherent.c @@ -22,22 +22,10 @@ */ #ifdef HAVE_CONFIG_H -#include "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 <pcap-types.h> #include <ctype.h> #include <memory.h> @@ -52,26 +40,23 @@ #include "os-proto.h" #endif -static inline int xdtoi(int); static inline int skip_space(FILE *); static inline int skip_line(FILE *); /* Hex digit to integer. */ -static inline int -xdtoi(c) - register int c; +static inline u_char +xdtoi(u_char c) { if (isdigit(c)) - return c - '0'; + return (u_char)(c - '0'); else if (islower(c)) - return c - 'a' + 10; + return (u_char)(c - 'a' + 10); else - return c - 'A' + 10; + return (u_char)(c - 'A' + 10); } static inline int -skip_space(f) - FILE *f; +skip_space(FILE *f) { int c; @@ -83,8 +68,7 @@ skip_space(f) } static inline int -skip_line(f) - FILE *f; +skip_line(FILE *f) { int c; @@ -98,47 +82,61 @@ skip_line(f) struct pcap_etherent * pcap_next_etherent(FILE *fp) { - register int c, d, i; + register int c, i; + u_char d; char *bp; + size_t namesize; static struct pcap_etherent e; memset((char *)&e, 0, sizeof(e)); - do { + for (;;) { /* Find addr */ c = skip_space(fp); + if (c == EOF) + return (NULL); if (c == '\n') continue; /* If this is a comment, or first thing on line - cannot be etehrnet address, skip the line. */ + cannot be Ethernet address, skip the line. */ if (!isxdigit(c)) { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } /* must be the start of an address */ for (i = 0; i < 6; i += 1) { - d = xdtoi(c); + d = xdtoi((u_char)c); c = getc(fp); + if (c == EOF) + return (NULL); if (isxdigit(c)) { d <<= 4; - d |= xdtoi(c); + d |= xdtoi((u_char)c); c = getc(fp); + if (c == EOF) + return (NULL); } e.addr[i] = d; if (c != ':') break; c = getc(fp); + if (c == EOF) + return (NULL); } - if (c == EOF) - break; /* Must be whitespace */ if (!isspace(c)) { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } c = skip_space(fp); + if (c == EOF) + return (NULL); /* hit end of line... */ if (c == '\n') @@ -146,17 +144,21 @@ pcap_next_etherent(FILE *fp) if (c == '#') { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } /* pick up name */ bp = e.name; - /* Use 'd' to prevent buffer overflow. */ - d = sizeof(e.name) - 1; + /* Use 'namesize' to prevent buffer overflow. */ + namesize = sizeof(e.name) - 1; do { - *bp++ = c; + *bp++ = (u_char)c; c = getc(fp); - } while (!isspace(c) && c != EOF && --d > 0); + if (c == EOF) + return (NULL); + } while (!isspace(c) && --namesize != 0); *bp = '\0'; /* Eat trailing junk */ @@ -164,8 +166,5 @@ pcap_next_etherent(FILE *fp) (void)skip_line(fp); return &e; - - } while (c != EOF); - - return (NULL); + } } diff --git a/freebsd/contrib/libpcap/extract.h b/freebsd/contrib/libpcap/extract.h index face5b7e..aa3ff991 100644 --- a/freebsd/contrib/libpcap/extract.h +++ b/freebsd/contrib/libpcap/extract.h @@ -23,6 +23,9 @@ #include <arpa/inet.h> #endif +#include <pcap/pcap-inttypes.h> +#include <pcap/compiler-tests.h> + /* * Macros to extract possibly-unaligned big-endian integral values. */ @@ -30,15 +33,16 @@ /* * The processor doesn't natively handle unaligned loads. */ -#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \ +#if PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) && \ (defined(__alpha) || defined(__alpha__) || \ defined(__mips) || defined(__mips__)) - /* - * This is a GCC-compatible compiler and we have __attribute__, which - * we assume that mean we have __attribute__((packed)), and this is - * MIPS or Alpha, which has instructions that can help when doing - * unaligned loads. + * This is MIPS or Alpha, which don't natively handle unaligned loads, + * but which have instructions that can help when doing unaligned + * loads, and this is GCC 2.0 or later or a compiler that claims to + * be GCC 2.0 or later, which we assume that mean we have + * __attribute__((packed)), which we can use to convince the compiler + * to generate those instructions. * * Declare packed structures containing a uint16_t and a uint32_t, * cast the pointer to point to one of those, and fetch through it; diff --git a/freebsd/contrib/libpcap/fad-getad.c b/freebsd/contrib/libpcap/fad-getad.c index cd7ac3e6..620f0d52 100644 --- a/freebsd/contrib/libpcap/fad-getad.c +++ b/freebsd/contrib/libpcap/fad-getad.c @@ -35,7 +35,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <sys/types.h> @@ -104,10 +104,10 @@ * all those systems we have "struct sockaddr_storage". */ #ifndef SA_LEN -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #define SA_LEN(addr) ((addr)->sa_len) -#else /* HAVE_SOCKADDR_SA_LEN */ -#ifdef HAVE_SOCKADDR_STORAGE +#else /* HAVE_STRUCT_SOCKADDR_SA_LEN */ +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE static size_t get_sa_len(struct sockaddr *addr) { @@ -133,10 +133,10 @@ get_sa_len(struct sockaddr *addr) } } #define SA_LEN(addr) (get_sa_len(addr)) -#else /* HAVE_SOCKADDR_STORAGE */ +#else /* HAVE_STRUCT_SOCKADDR_STORAGE */ #define SA_LEN(addr) (sizeof (struct sockaddr)) -#endif /* HAVE_SOCKADDR_STORAGE */ -#endif /* HAVE_SOCKADDR_SA_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ +#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #endif /* SA_LEN */ /* @@ -146,10 +146,9 @@ get_sa_len(struct sockaddr *addr) * could be opened. */ int -pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, - int (*check_usable)(const char *)) +pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf, + int (*check_usable)(const char *), get_if_flags_func get_flags_func) { - pcap_if_t *devlist = NULL; struct ifaddrs *ifap, *ifa; struct sockaddr *addr, *netmask, *broadaddr, *dstaddr; size_t addr_size, broadaddr_size, dstaddr_size; @@ -171,8 +170,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, * those. */ if (getifaddrs(&ifap) != 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "getifaddrs: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "getifaddrs"); return (-1); } for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { @@ -235,7 +234,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, /* * Note that, on some platforms, ifa_broadaddr and * ifa_dstaddr could be the same field (true on at - * least some versions of *BSD and OS X), so we + * least some versions of *BSD and macOS), so we * can't just check whether the broadcast address * is null and add it if so and check whether the * destination address is null and add it if so. @@ -267,8 +266,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, /* * Add information for this address to the list. */ - if (add_addr_to_iflist(&devlist, ifa->ifa_name, - if_flags_to_pcap_flags(ifa->ifa_name, ifa->ifa_flags), + if (add_addr_to_if(devlistp, ifa->ifa_name, ifa->ifa_flags, + get_flags_func, addr, addr_size, netmask, addr_size, broadaddr, broadaddr_size, dstaddr, dstaddr_size, errbuf) < 0) { @@ -279,16 +278,5 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, freeifaddrs(ifap); - if (ret == -1) { - /* - * We had an error; free the list we've been constructing. - */ - if (devlist != NULL) { - pcap_freealldevs(devlist); - devlist = NULL; - } - } - - *alldevsp = devlist; return (ret); } diff --git a/freebsd/contrib/libpcap/fad-helpers.c b/freebsd/contrib/libpcap/fad-helpers.c deleted file mode 100644 index 0b98b484..00000000 --- a/freebsd/contrib/libpcap/fad-helpers.c +++ /dev/null @@ -1,890 +0,0 @@ -#include <machine/rtems-bsd-user-space.h> - -/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ -/* - * Copyright (c) 1994, 1995, 1996, 1997, 1998 - * 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 the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef _WIN32 -#include <pcap-stdinc.h> -#else /* _WIN32 */ - -#include <sys/param.h> -#ifndef MSDOS -#include <sys/file.h> -#endif -#include <sys/ioctl.h> -#include <sys/socket.h> -#ifdef HAVE_SYS_SOCKIO_H -#include <sys/sockio.h> -#endif - -struct mbuf; /* Squelch compiler warnings on some platforms for */ -struct rtentry; /* declarations in <net/if.h> */ -#include <net/if.h> -#include <netinet/in.h> -#endif /* _WIN32 */ - -#include <ctype.h> -#include <errno.h> -#include <memory.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#if !defined(_WIN32) && !defined(__BORLANDC__) -#include <unistd.h> -#endif /* !_WIN32 && !__BORLANDC__ */ -#ifdef HAVE_LIMITS_H -#include <limits.h> -#else -#define INT_MAX 2147483647 -#endif - -#include "pcap-int.h" - -#ifdef HAVE_OS_PROTO_H -#include "os-proto.h" -#endif - -#ifndef _WIN32 -/* Not all systems have IFF_LOOPBACK */ -#ifdef IFF_LOOPBACK -#define ISLOOPBACK(name, flags) ((flags) & IFF_LOOPBACK) -#else -#define ISLOOPBACK(name, flags) ((name)[0] == 'l' && (name)[1] == 'o' && \ - (isdigit((unsigned char)((name)[2])) || (name)[2] == '\0')) -#endif - -#ifdef IFF_UP -#define ISUP(flags) ((flags) & IFF_UP) -#else -#define ISUP(flags) 0 -#endif - -#ifdef IFF_RUNNING -#define ISRUNNING(flags) ((flags) & IFF_RUNNING) -#else -#define ISRUNNING(flags) 0 -#endif - -/* - * Map UN*X-style interface flags to libpcap flags. - */ -bpf_u_int32 -if_flags_to_pcap_flags(const char *name _U_, u_int if_flags) -{ - bpf_u_int32 pcap_flags; - - pcap_flags = 0; - if (ISLOOPBACK(name, if_flags)) - pcap_flags |= PCAP_IF_LOOPBACK; - if (ISUP(if_flags)) - pcap_flags |= PCAP_IF_UP; - if (ISRUNNING(if_flags)) - pcap_flags |= PCAP_IF_RUNNING; - return (pcap_flags); -} -#endif - -static struct sockaddr * -dup_sockaddr(struct sockaddr *sa, size_t sa_length) -{ - struct sockaddr *newsa; - - if ((newsa = malloc(sa_length)) == NULL) - return (NULL); - return (memcpy(newsa, sa, sa_length)); -} - -/* - * Construct a "figure of merit" for an interface, for use when sorting - * the list of interfaces, in which interfaces that are up are superior - * to interfaces that aren't up, interfaces that are up and running are - * superior to interfaces that are up but not running, and non-loopback - * interfaces that are up and running are superior to loopback interfaces, - * and interfaces with the same flags have a figure of merit that's higher - * the lower the instance number. - * - * The goal is to try to put the interfaces most likely to be useful for - * capture at the beginning of the list. - * - * The figure of merit, which is lower the "better" the interface is, - * has the uppermost bit set if the interface isn't running, the bit - * below that set if the interface isn't up, the bit below that set - * if the interface is a loopback interface, and the interface index - * in the 29 bits below that. (Yes, we assume u_int is 32 bits.) - */ -static u_int -get_figure_of_merit(pcap_if_t *dev) -{ - const char *cp; - u_int n; - - if (strcmp(dev->name, "any") == 0) { - /* - * Give the "any" device an artificially high instance - * number, so it shows up after all other non-loopback - * interfaces. - */ - n = 0x1FFFFFFF; /* 29 all-1 bits */ - } else { - /* - * A number at the end of the device name string is - * assumed to be a unit number. - */ - cp = dev->name + strlen(dev->name) - 1; - while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9') - cp--; - if (*cp >= '0' && *cp <= '9') - n = atoi(cp); - else - n = 0; - } - if (!(dev->flags & PCAP_IF_RUNNING)) - n |= 0x80000000; - if (!(dev->flags & PCAP_IF_UP)) - n |= 0x40000000; - if (dev->flags & PCAP_IF_LOOPBACK) - n |= 0x20000000; - return (n); -} - -/* - * Try to get a description for a given device. - * Returns a mallocated description if it could and NULL if it couldn't. - * - * XXX - on FreeBSDs that support it, should it get the sysctl named - * "dev.{adapter family name}.{adapter unit}.%desc" to get a description - * of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800" - * with my Cisco 350 card, so the name isn't entirely descriptive. The - * "dev.an.0.%pnpinfo" has a better description, although one might argue - * that the problem is really a driver bug - if it can find out that it's - * a Cisco 340 or 350, rather than an old Aironet card, it should use - * that in the description. - * - * Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD - * and OpenBSD let you get a description, but it's not generated by the OS, - * it's set with another ioctl that ifconfig supports; we use that to get - * a description in FreeBSD and OpenBSD, but if there is no such - * description available, it still might be nice to get some description - * string based on the device type or something such as that. - * - * In OS X, the System Configuration framework can apparently return - * names in 10.4 and later. - * - * It also appears that freedesktop.org's HAL offers an "info.product" - * string, but the HAL specification says it "should not be used in any - * UI" and "subsystem/capability specific properties" should be used - * instead and, in any case, I think HAL is being deprecated in - * favor of other stuff such as DeviceKit. DeviceKit doesn't appear - * to have any obvious product information for devices, but maybe - * I haven't looked hard enough. - * - * Using the System Configuration framework, or HAL, or DeviceKit, or - * whatever, would require that libpcap applications be linked with - * the frameworks/libraries in question. That shouldn't be a problem - * for programs linking with the shared version of libpcap (unless - * you're running on AIX - which I think is the only UN*X that doesn't - * support linking a shared library with other libraries on which it - * depends, and having an executable linked only with the first shared - * library automatically pick up the other libraries when started - - * and using HAL or whatever). Programs linked with the static - * version of libpcap would have to use pcap-config with the --static - * flag in order to get the right linker flags in order to pick up - * the additional libraries/frameworks; those programs need that anyway - * for libpcap 1.1 and beyond on Linux, as, by default, it requires - * -lnl. - * - * Do any other UN*Xes, or desktop environments support getting a - * description? - */ -static char * -get_if_description(const char *name) -{ -#ifdef SIOCGIFDESCR - char *description = NULL; - int s; - struct ifreq ifrdesc; -#ifndef IFDESCRSIZE - size_t descrlen = 64; -#else - size_t descrlen = IFDESCRSIZE; -#endif /* IFDESCRSIZE */ - - /* - * Get the description for the interface. - */ - memset(&ifrdesc, 0, sizeof ifrdesc); - strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name); - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s >= 0) { -#ifdef __FreeBSD__ - /* - * On FreeBSD, if the buffer isn't big enough for the - * description, the ioctl succeeds, but the description - * isn't copied, ifr_buffer.length is set to the description - * length, and ifr_buffer.buffer is set to NULL. - */ - for (;;) { - free(description); - if ((description = malloc(descrlen)) != NULL) { - ifrdesc.ifr_buffer.buffer = description; - ifrdesc.ifr_buffer.length = descrlen; - if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0) { - if (ifrdesc.ifr_buffer.buffer == - description) - break; - else - descrlen = ifrdesc.ifr_buffer.length; - } else { - /* - * Failed to get interface description. - */ - free(description); - description = NULL; - break; - } - } else - break; - } -#else /* __FreeBSD__ */ - /* - * The only other OS that currently supports - * SIOCGIFDESCR is OpenBSD, and it has no way - * to get the description length - it's clamped - * to a maximum of IFDESCRSIZE. - */ - if ((description = malloc(descrlen)) != NULL) { - ifrdesc.ifr_data = (caddr_t)description; - if (ioctl(s, SIOCGIFDESCR, &ifrdesc) != 0) { - /* - * Failed to get interface description. - */ - free(description); - description = NULL; - } - } -#endif /* __FreeBSD__ */ - close(s); - if (description != NULL && strlen(description) == 0) { - /* - * Description is empty, so discard it. - */ - free(description); - description = NULL; - } - } - -#ifdef __FreeBSD__ - /* - * For FreeBSD, if we didn't get a description, and this is - * a device with a name of the form usbusN, label it as a USB - * bus. - */ - if (description == NULL) { - if (strncmp(name, "usbus", 5) == 0) { - /* - * OK, it begins with "usbus". - */ - long busnum; - char *p; - - errno = 0; - busnum = strtol(name + 5, &p, 10); - if (errno == 0 && p != name + 5 && *p == '\0' && - busnum >= 0 && busnum <= INT_MAX) { - /* - * OK, it's a valid number that's not - * bigger than INT_MAX. Construct - * a description from it. - */ - static const char descr_prefix[] = "USB bus number "; - size_t descr_size; - - /* - * Allow enough room for a 32-bit bus number. - * sizeof (descr_prefix) includes the - * terminating NUL. - */ - descr_size = sizeof (descr_prefix) + 10; - description = malloc(descr_size); - if (description != NULL) { - pcap_snprintf(description, descr_size, - "%s%ld", descr_prefix, busnum); - } - } - } - } -#endif - return (description); -#else /* SIOCGIFDESCR */ - return (NULL); -#endif /* SIOCGIFDESCR */ -} - -/* - * Look for a given device in the specified list of devices. - * - * If we find it, return 0 and set *curdev_ret to point to it. - * - * If we don't find it, check whether we can open it: - * - * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or - * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for - * it, as that probably means it exists but doesn't support - * packet capture. - * - * Otherwise, attempt to add an entry for it, with the specified - * ifnet flags and description, and, if that succeeds, return 0 - * and set *curdev_ret to point to the new entry, otherwise - * return PCAP_ERROR and set errbuf to an error message. If we - * weren't given a description, try to get one. - */ -int -add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, - bpf_u_int32 flags, const char *description, char *errbuf) -{ - pcap_t *p; - pcap_if_t *curdev, *prevdev, *nextdev; - u_int this_figure_of_merit, nextdev_figure_of_merit; - char open_errbuf[PCAP_ERRBUF_SIZE]; - int ret; - - /* - * Is there already an entry in the list for this interface? - */ - for (curdev = *alldevs; curdev != NULL; curdev = curdev->next) { - if (strcmp(name, curdev->name) == 0) - break; /* yes, we found it */ - } - - if (curdev == NULL) { - /* - * No, we didn't find it. - * - * Can we open this interface for live capture? - * - * We do this check so that interfaces that are - * supplied by the interface enumeration mechanism - * we're using but that don't support packet capture - * aren't included in the list. Loopback interfaces - * on Solaris are an example of this; we don't just - * omit loopback interfaces on all platforms because - * you *can* capture on loopback interfaces on some - * OSes. - * - * On OS X, we don't do this check if the device - * name begins with "wlt"; at least some versions - * of OS X offer monitor mode capturing by having - * a separate "monitor mode" device for each wireless - * adapter, rather than by implementing the ioctls - * that {Free,Net,Open,DragonFly}BSD provide. - * Opening that device puts the adapter into monitor - * mode, which, at least for some adapters, causes - * them to deassociate from the network with which - * they're associated. - * - * Instead, we try to open the corresponding "en" - * device (so that we don't end up with, for users - * without sufficient privilege to open capture - * devices, a list of adapters that only includes - * the wlt devices). - */ -#ifdef __APPLE__ - if (strncmp(name, "wlt", 3) == 0) { - char *en_name; - size_t en_name_len; - - /* - * Try to allocate a buffer for the "en" - * device's name. - */ - en_name_len = strlen(name) - 1; - en_name = malloc(en_name_len + 1); - if (en_name == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - strcpy(en_name, "en"); - strcat(en_name, name + 3); - p = pcap_create(en_name, open_errbuf); - free(en_name); - } else -#endif /* __APPLE */ - p = pcap_create(name, open_errbuf); - if (p == NULL) { - /* - * The attempt to create the pcap_t failed; - * that's probably an indication that we're - * out of memory. - * - * Don't bother including this interface, - * but don't treat it as an error. - */ - *curdev_ret = NULL; - return (0); - } - /* Small snaplen, so we don't try to allocate much memory. */ - pcap_set_snaplen(p, 68); - ret = pcap_activate(p); - pcap_close(p); - switch (ret) { - - case PCAP_ERROR_NO_SUCH_DEVICE: - case PCAP_ERROR_IFACE_NOT_UP: - /* - * We expect these two errors - they're the - * reason we try to open the device. - * - * PCAP_ERROR_NO_SUCH_DEVICE typically means - * "there's no such device *known to the - * OS's capture mechanism*", so, even though - * it might be a valid network interface, you - * can't capture on it (e.g., the loopback - * device in Solaris up to Solaris 10, or - * the vmnet devices in OS X with VMware - * Fusion). We don't include those devices - * in our list of devices, as there's no - * point in doing so - they're not available - * for capture. - * - * PCAP_ERROR_IFACE_NOT_UP means that the - * OS's capture mechanism doesn't work on - * interfaces not marked as up; some capture - * mechanisms *do* support that, so we no - * longer reject those interfaces out of hand, - * but we *do* want to reject them if they - * can't be opened for capture. - */ - *curdev_ret = NULL; - return (0); - } - - /* - * Yes, we can open it, or we can't, for some other - * reason. - * - * If we can open it, we want to offer it for - * capture, as you can capture on it. If we can't, - * we want to offer it for capture, so that, if - * the user tries to capture on it, they'll get - * an error and they'll know why they can't - * capture on it (e.g., insufficient permissions) - * or they'll report it as a problem (and then - * have the error message to provide as information). - * - * Allocate a new entry. - */ - curdev = malloc(sizeof(pcap_if_t)); - if (curdev == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - - /* - * Fill in the entry. - */ - curdev->next = NULL; - curdev->name = strdup(name); - if (curdev->name == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curdev); - return (-1); - } - if (description == NULL) { - /* - * We weren't handed a description for the - * interface, so see if we can generate one - * ourselves. - */ - curdev->description = get_if_description(name); - } else { - /* - * We were handed a description; make a copy. - */ - curdev->description = strdup(description); - if (curdev->description == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curdev->name); - free(curdev); - return (-1); - } - } - curdev->addresses = NULL; /* list starts out as empty */ - curdev->flags = flags; - - /* - * Add it to the list, in the appropriate location. - * First, get the "figure of merit" for this - * interface. - */ - this_figure_of_merit = get_figure_of_merit(curdev); - - /* - * Now look for the last interface with an figure of merit - * less than or equal to the new interface's figure of - * merit. - * - * We start with "prevdev" being NULL, meaning we're before - * the first element in the list. - */ - prevdev = NULL; - for (;;) { - /* - * Get the interface after this one. - */ - if (prevdev == NULL) { - /* - * The next element is the first element. - */ - nextdev = *alldevs; - } else - nextdev = prevdev->next; - - /* - * Are we at the end of the list? - */ - if (nextdev == NULL) { - /* - * Yes - we have to put the new entry - * after "prevdev". - */ - break; - } - - /* - * Is the new interface's figure of merit less - * than the next interface's figure of merit, - * meaning that the new interface is better - * than the next interface? - */ - nextdev_figure_of_merit = get_figure_of_merit(nextdev); - if (this_figure_of_merit < nextdev_figure_of_merit) { - /* - * Yes - we should put the new entry - * before "nextdev", i.e. after "prevdev". - */ - break; - } - - prevdev = nextdev; - } - - /* - * Insert before "nextdev". - */ - curdev->next = nextdev; - - /* - * Insert after "prevdev" - unless "prevdev" is null, - * in which case this is the first interface. - */ - if (prevdev == NULL) { - /* - * This is the first interface. Pass back a - * pointer to it, and put "curdev" before - * "nextdev". - */ - *alldevs = curdev; - } else - prevdev->next = curdev; - } - - *curdev_ret = curdev; - return (0); -} - -/* - * Try to get a description for a given device, and then look for that - * device in the specified list of devices. - * - * If we find it, then, if the specified address isn't null, add it to - * the list of addresses for the device and return 0. - * - * If we don't find it, check whether we can open it: - * - * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or - * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for - * it, as that probably means it exists but doesn't support - * packet capture. - * - * Otherwise, attempt to add an entry for it, with the specified - * ifnet flags, and, if that succeeds, add the specified address - * to its list of addresses if that address is non-null, set - * *curdev_ret to point to the new entry, and return 0, otherwise - * return PCAP_ERROR and set errbuf to an error message. - * - * (We can get called with a null address because we might get a list - * of interface name/address combinations from the underlying OS, with - * the address being absent in some cases, rather than a list of - * interfaces with each interface having a list of addresses, so this - * call may be the only call made to add to the list, and we want to - * add interfaces even if they have no addresses.) - */ -int -add_addr_to_iflist(pcap_if_t **alldevs, const char *name, bpf_u_int32 flags, - struct sockaddr *addr, size_t addr_size, - struct sockaddr *netmask, size_t netmask_size, - struct sockaddr *broadaddr, size_t broadaddr_size, - struct sockaddr *dstaddr, size_t dstaddr_size, - char *errbuf) -{ - pcap_if_t *curdev; - - if (add_or_find_if(&curdev, alldevs, name, flags, NULL, errbuf) == -1) { - /* - * Error - give up. - */ - return (-1); - } - if (curdev == NULL) { - /* - * Device wasn't added because it can't be opened. - * Not a fatal error. - */ - return (0); - } - - if (addr == NULL) { - /* - * There's no address to add; this entry just meant - * "here's a new interface". - */ - return (0); - } - - /* - * "curdev" is an entry for this interface, and we have an - * address for it; add an entry for that address to the - * interface's list of addresses. - * - * Allocate the new entry and fill it in. - */ - return (add_addr_to_dev(curdev, addr, addr_size, netmask, - netmask_size, broadaddr, broadaddr_size, dstaddr, - dstaddr_size, errbuf)); -} - -/* - * Add an entry to the list of addresses for an interface. - * "curdev" is the entry for that interface. - * If this is the first IP address added to the interface, move it - * in the list as appropriate. - */ -int -add_addr_to_dev(pcap_if_t *curdev, - struct sockaddr *addr, size_t addr_size, - struct sockaddr *netmask, size_t netmask_size, - struct sockaddr *broadaddr, size_t broadaddr_size, - struct sockaddr *dstaddr, size_t dstaddr_size, - char *errbuf) -{ - pcap_addr_t *curaddr, *prevaddr, *nextaddr; - - curaddr = malloc(sizeof(pcap_addr_t)); - if (curaddr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - - curaddr->next = NULL; - if (addr != NULL) { - curaddr->addr = dup_sockaddr(addr, addr_size); - if (curaddr->addr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curaddr); - return (-1); - } - } else - curaddr->addr = NULL; - - if (netmask != NULL) { - curaddr->netmask = dup_sockaddr(netmask, netmask_size); - if (curaddr->netmask == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - if (curaddr->addr != NULL) - free(curaddr->addr); - free(curaddr); - return (-1); - } - } else - curaddr->netmask = NULL; - - if (broadaddr != NULL) { - curaddr->broadaddr = dup_sockaddr(broadaddr, broadaddr_size); - if (curaddr->broadaddr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - if (curaddr->netmask != NULL) - free(curaddr->netmask); - if (curaddr->addr != NULL) - free(curaddr->addr); - free(curaddr); - return (-1); - } - } else - curaddr->broadaddr = NULL; - - if (dstaddr != NULL) { - curaddr->dstaddr = dup_sockaddr(dstaddr, dstaddr_size); - if (curaddr->dstaddr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - if (curaddr->broadaddr != NULL) - free(curaddr->broadaddr); - if (curaddr->netmask != NULL) - free(curaddr->netmask); - if (curaddr->addr != NULL) - free(curaddr->addr); - free(curaddr); - return (-1); - } - } else - curaddr->dstaddr = NULL; - - /* - * Find the end of the list of addresses. - */ - for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) { - nextaddr = prevaddr->next; - if (nextaddr == NULL) { - /* - * This is the end of the list. - */ - break; - } - } - - if (prevaddr == NULL) { - /* - * The list was empty; this is the first member. - */ - curdev->addresses = curaddr; - } else { - /* - * "prevaddr" is the last member of the list; append - * this member to it. - */ - prevaddr->next = curaddr; - } - - return (0); -} - -/* - * Look for a given device in the specified list of devices. - * - * If we find it, return 0. - * - * If we don't find it, check whether we can open it: - * - * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or - * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for - * it, as that probably means it exists but doesn't support - * packet capture. - * - * Otherwise, attempt to add an entry for it, with the specified - * ifnet flags and description, and, if that succeeds, return 0 - * and set *curdev_ret to point to the new entry, otherwise - * return PCAP_ERROR and set errbuf to an error message. - */ -int -#ifndef __rtems__ -pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags, -#else /* __rtems__ */ -pcap_add_if(pcap_if_t **devlist, const char *name, bpf_u_int32 flags, -#endif /* __rtems__ */ - const char *description, char *errbuf) -{ - pcap_if_t *curdev; - - return (add_or_find_if(&curdev, devlist, name, flags, description, - errbuf)); -} - - -/* - * Free a list of interfaces. - */ -void -pcap_freealldevs(pcap_if_t *alldevs) -{ - pcap_if_t *curdev, *nextdev; - pcap_addr_t *curaddr, *nextaddr; - - for (curdev = alldevs; curdev != NULL; curdev = nextdev) { - nextdev = curdev->next; - - /* - * Free all addresses. - */ - for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) { - nextaddr = curaddr->next; - if (curaddr->addr) - free(curaddr->addr); - if (curaddr->netmask) - free(curaddr->netmask); - if (curaddr->broadaddr) - free(curaddr->broadaddr); - if (curaddr->dstaddr) - free(curaddr->dstaddr); - free(curaddr); - } - - /* - * Free the name string. - */ - free(curdev->name); - - /* - * Free the description string, if any. - */ - if (curdev->description != NULL) - free(curdev->description); - - /* - * Free the interface. - */ - free(curdev); - } -} diff --git a/freebsd/contrib/libpcap/fmtutils.c b/freebsd/contrib/libpcap/fmtutils.c new file mode 100644 index 00000000..ae550e24 --- /dev/null +++ b/freebsd/contrib/libpcap/fmtutils.c @@ -0,0 +1,133 @@ +#include <machine/rtems-bsd-user-space.h> + +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Utilities for message formatting used both by libpcap and rpcapd. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "ftmacros.h" + +#include <stddef.h> +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#include <pcap/pcap.h> + +#include "portability.h" + +#include "fmtutils.h" + +/* + * Generate an error message based on a format, arguments, and an + * errno, with a message for the errno after the formatted output. + */ +void +pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, + const char *fmt, ...) +{ + va_list ap; + size_t msglen; + char *p; + size_t errbuflen_remaining; +#if defined(HAVE_STRERROR_S) + errno_t err; +#elif defined(HAVE_STRERROR_R) + int err; +#endif + + va_start(ap, fmt); + pcap_vsnprintf(errbuf, errbuflen, fmt, ap); + va_end(ap); + msglen = strlen(errbuf); + + /* + * Do we have enough space to append ": "? + * Including the terminating '\0', that's 3 bytes. + */ + if (msglen + 3 > errbuflen) { + /* No - just give them what we've produced. */ + return; + } + p = errbuf + msglen; + errbuflen_remaining = errbuflen - msglen; + *p++ = ':'; + *p++ = ' '; + *p = '\0'; + msglen += 2; + errbuflen_remaining -= 2; + + /* + * Now append the string for the error code. + */ +#if defined(HAVE_STRERROR_S) + err = strerror_s(p, errbuflen_remaining, errnum); + if (err != 0) { + /* + * It doesn't appear to be documented anywhere obvious + * what the error returns from strerror_s(). + */ + pcap_snprintf(p, errbuflen_remaining, "Error %d", errnum); + } +#elif defined(HAVE_STRERROR_R) + err = strerror_r(errnum, p, errbuflen_remaining); + if (err == EINVAL) { + /* + * UNIX 03 says this isn't guaranteed to produce a + * fallback error message. + */ + pcap_snprintf(p, errbuflen_remaining, "Unknown error: %d", + errnum); + } else if (err == ERANGE) { + /* + * UNIX 03 says this isn't guaranteed to produce a + * fallback error message. + */ + pcap_snprintf(p, errbuflen_remaining, + "Message for error %d is too long", errnum); + } +#else + /* + * We have neither strerror_s() nor strerror_r(), so we're + * stuck with using pcap_strerror(). + */ + pcap_snprintf(p, errbuflen_remaining, "%s", pcap_strerror(errnum)); +#endif +} diff --git a/freebsd/contrib/libpcap/fmtutils.h b/freebsd/contrib/libpcap/fmtutils.h new file mode 100644 index 00000000..62c78fdb --- /dev/null +++ b/freebsd/contrib/libpcap/fmtutils.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1994, 1995, 1996 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef fmtutils_h +#define fmtutils_h + +#include "pcap/funcattrs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void pcap_fmt_errmsg_for_errno(char *, size_t, int, + PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/freebsd/contrib/libpcap/ftmacros.h b/freebsd/contrib/libpcap/ftmacros.h new file mode 100644 index 00000000..de8da98e --- /dev/null +++ b/freebsd/contrib/libpcap/ftmacros.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1994, 1995, 1996 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef ftmacros_h +#define ftmacros_h + +/* + * Define some feature test macros to make sure that everything we want + * to be declared gets declared. + * + * On some UN*Xes we need to force strtok_r() to be declared. + * We do *NOT* want to define _POSIX_C_SOURCE, as that tends + * to make non-POSIX APIs that we use unavailable. + * XXX - is there no portable way to say "please pollute the + * namespace to the maximum extent possible"? + */ +#if defined(sun) || defined(__sun) + #define __EXTENSIONS__ + + /* + * We also need to define _XPG4_2 in order to get + * the Single UNIX Specification version of + * recvmsg(). + */ + #define _XPG4_2 +#elif defined(_hpux) || defined(hpux) || defined(__hpux) + #define _REENTRANT + + /* + * We need this to get the versions of socket functions that + * use socklen_t. Define it only if it's not already defined, + * so we don't get redefiniton warnings. + */ + #ifndef _XOPEN_SOURCE_EXTENDED + #define _XOPEN_SOURCE_EXTENDED + #endif + + /* + * XXX - the list of PA-RISC options for GCC makes it sound as if + * building code that uses a particular vintage of UNIX API/ABI + * is complicated: + * + * https://gcc.gnu.org/onlinedocs/gcc/HPPA-Options.html + * + * See the description of the -munix flag. + * + * We probably want libpcap to work with programs built for any + * UN*X standard. I'm not sure whether that's possible and, if + * it is, what sort of stuff it'd have to do. + * + * It might also be a requirement that we build with a special + * flag to allow the library to be used with threaded code, at + * least with HP's C compiler; hopefully doing so won't make it + * *not* work with *un*-threaded code. + */ +#elif defined(__linux__) || defined(linux) || defined(__linux) + /* + * We can't turn _GNU_SOURCE on because some versions of GNU Libc + * will give the GNU version of strerror_r(), which returns a + * string pointer and doesn't necessarily fill in the buffer, + * rather than the standard version of strerror_r(), which + * returns 0 or an errno and always fills in the buffer. We + * require both of the latter behaviors. + * + * So we try turning everything else on that we can. This includes + * defining _XOPEN_SOURCE as 600, because we want to force crypt() + * to be declared on systems that use GNU libc, such as most Linux + * distributions. + */ + #define _POSIX_C_SOURCE 200809L + #define _XOPEN_SOURCE 600 + + /* + * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get + * the BSD u_XXX types, such as u_int and u_short, defined. We + * define _DEFAULT_SOURCE first, so that newer versions of GNU libc + * don't whine about _BSD_SOURCE being deprecated; we still have + * to define _BSD_SOURCE to handle older versions of GNU libc that + * don't support _DEFAULT_SOURCE. + */ + #define _DEFAULT_SOURCE + #define _BSD_SOURCE +#endif + +#endif diff --git a/freebsd/contrib/libpcap/gencode.c b/freebsd/contrib/libpcap/gencode.c index 8c303415..df75cacd 100644 --- a/freebsd/contrib/libpcap/gencode.c +++ b/freebsd/contrib/libpcap/gencode.c @@ -20,38 +20,24 @@ * 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 HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif +#include <pcap-types.h> #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> -#include <sys/socket.h> -#endif /* _WIN32 */ - -#ifndef _WIN32 - -#ifdef __NetBSD__ -#include <sys/param.h> -#endif + #include <ws2tcpip.h> +#else + #include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> + #ifdef __NetBSD__ + #include <sys/param.h> + #endif + #include <netinet/in.h> + #include <arpa/inet.h> #endif /* _WIN32 */ #include <stdlib.h> @@ -98,17 +84,17 @@ #define offsetof(s, e) ((size_t)&((s *)0)->e) #endif -#ifdef INET6 #ifdef _WIN32 -#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) + #ifdef INET6 + #if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) /* IPv6 address */ struct in6_addr { union { - u_int8_t u6_addr8[16]; - u_int16_t u6_addr16[8]; - u_int32_t u6_addr32[4]; + uint8_t u6_addr8[16]; + uint16_t u6_addr16[8]; + uint32_t u6_addr32[4]; } in6_u; #define s6_addr in6_u.u6_addr8 #define s6_addr16 in6_u.u6_addr16 @@ -125,12 +111,12 @@ typedef unsigned short sa_family_t; struct sockaddr_in6 { __SOCKADDR_COMMON (sin6_); - u_int16_t sin6_port; /* Transport layer port # */ - u_int32_t sin6_flowinfo; /* IPv6 flow information */ + uint16_t sin6_port; /* Transport layer port # */ + uint32_t sin6_flowinfo; /* IPv6 flow information */ struct in6_addr sin6_addr; /* IPv6 address */ }; -#ifndef EAI_ADDRFAMILY + #ifndef EAI_ADDRFAMILY struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* PF_xxx */ @@ -141,12 +127,12 @@ struct addrinfo { struct sockaddr *ai_addr; /* binary address */ struct addrinfo *ai_next; /* next structure in linked list */ }; -#endif /* EAI_ADDRFAMILY */ -#endif /* defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) */ + #endif /* EAI_ADDRFAMILY */ + #endif /* defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) */ + #endif /* INET6 */ #else /* _WIN32 */ -#include <netdb.h> /* for "struct addrinfo" */ + #include <netdb.h> /* for "struct addrinfo" */ #endif /* _WIN32 */ -#endif /* INET6 */ #include <pcap/namedb.h> #include "nametoaddr.h" @@ -281,7 +267,6 @@ struct _compiler_state { /* XXX */ u_int pcap_fddipad; -#ifdef INET6 /* * As errors are handled by a longjmp, anything allocated must * be freed in the longjmp handler, so it must be reachable @@ -292,7 +277,6 @@ struct _compiler_state { * any addrinfo structure that would need to be freed. */ struct addrinfo *ai; -#endif /* * Various code constructs need to know the layout of the packet. @@ -362,6 +346,11 @@ struct _compiler_state { int is_geneve; /* + * TRUE if we need variable length part of VLAN offset + */ + int is_vlan_vloffset; + + /* * These are offsets for the ATM pseudo-header. */ u_int off_vpi; @@ -430,7 +419,7 @@ struct _compiler_state { int cur_chunk; }; -void +void PCAP_NORETURN bpf_syntax_error(compiler_state_t *cstate, const char *msg) { bpf_error(cstate, "syntax error in filter expression: %s", msg); @@ -438,7 +427,7 @@ bpf_syntax_error(compiler_state_t *cstate, const char *msg) } /* VARARGS */ -void +void PCAP_NORETURN bpf_error(compiler_state_t *cstate, const char *fmt, ...) { va_list ap; @@ -528,7 +517,7 @@ static struct block *gen_host6(compiler_state_t *, struct in6_addr *, #endif #ifndef INET6 static struct block *gen_gateway(compiler_state_t *, const u_char *, - bpf_u_int32 **, int, int); + struct addrinfo *, int, int); #endif static struct block *gen_ipfrag(compiler_state_t *); static struct block *gen_portatom(compiler_state_t *, int, bpf_int32); @@ -587,7 +576,8 @@ newchunk(compiler_state_t *cstate, size_t n) cp = &cstate->chunks[cstate->cur_chunk]; if (n > cp->n_left) { - ++cp, k = ++cstate->cur_chunk; + ++cp; + k = ++cstate->cur_chunk; if (k >= NCHUNKS) bpf_error(cstate, "out of memory"); size = CHUNK0SIZE << k; @@ -658,7 +648,7 @@ gen_retblk(compiler_state_t *cstate, int v) return b; } -static inline void +static inline PCAP_NORETURN_DEF void syntax(compiler_state_t *cstate) { bpf_error(cstate, "syntax error in filter expression"); @@ -668,6 +658,9 @@ int pcap_compile(pcap_t *p, struct bpf_program *program, const char *buf, int optimize, bpf_u_int32 mask) { +#ifdef _WIN32 + static int done = 0; +#endif compiler_state_t cstate; const char * volatile xbuf = buf; yyscan_t scanner = NULL; @@ -675,14 +668,6 @@ pcap_compile(pcap_t *p, struct bpf_program *program, u_int len; int rc; -#ifdef _WIN32 - static int done = 0; - - if (!done) - pcap_wsockinit(); - done = 1; -#endif - /* * If this pcap_t hasn't been activated, it doesn't have a * link-layer type, so we can't use it. @@ -690,9 +675,36 @@ pcap_compile(pcap_t *p, struct bpf_program *program, if (!p->activated) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "not-yet-activated pcap_t passed to pcap_compile"); - rc = -1; - goto quit; + return (-1); } + +#ifdef _WIN32 + if (!done) + pcap_wsockinit(); + done = 1; +#endif + +#ifdef ENABLE_REMOTE + /* + * If the device on which we're capturing need to be notified + * that a new filter is being compiled, do so. + * + * This allows them to save a copy of it, in case, for example, + * they're implementing a form of remote packet capture, and + * want the remote machine to filter out the packets in which + * it's sending the packets it's captured. + * + * XXX - the fact that we happen to be compiling a filter + * doesn't necessarily mean we'll be installing it as the + * filter for this pcap_t; we might be running it from userland + * on captured packets to do packet classification. We really + * need a better way of handling this, but this is all that + * the WinPcap code did. + */ + if (p->save_current_filter_op != NULL) + (p->save_current_filter_op)(p, buf); +#endif + initchunks(&cstate); cstate.no_optimize = 0; #ifdef INET6 @@ -723,7 +735,8 @@ pcap_compile(pcap_t *p, struct bpf_program *program, } if (pcap_lex_init(&scanner) != 0) - bpf_error(&cstate, "can't initialize scanner: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "can't initialize scanner"); in_buffer = pcap__scan_string(xbuf ? xbuf : "", scanner); /* @@ -807,8 +820,7 @@ pcap_freecode(struct bpf_program *program) * in each block is already resolved. */ static void -backpatch(list, target) - struct block *list, *target; +backpatch(struct block *list, struct block *target) { struct block *next; @@ -829,8 +841,7 @@ backpatch(list, target) * which of jt and jf is the link. */ static void -merge(b0, b1) - struct block *b0, *b1; +merge(struct block *b0, struct block *b1) { register struct block **p = &b0; @@ -892,8 +903,7 @@ finish_parse(compiler_state_t *cstate, struct block *p) } void -gen_and(b0, b1) - struct block *b0, *b1; +gen_and(struct block *b0, struct block *b1) { backpatch(b0, b1->head); b0->sense = !b0->sense; @@ -904,8 +914,7 @@ gen_and(b0, b1) } void -gen_or(b0, b1) - struct block *b0, *b1; +gen_or(struct block *b0, struct block *b1) { b0->sense = !b0->sense; backpatch(b0, b1->head); @@ -915,8 +924,7 @@ gen_or(b0, b1) } void -gen_not(b) - struct block *b; +gen_not(struct block *b) { b->sense = !b->sense; } @@ -1068,10 +1076,10 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) * Assume it's not raw ATM with a pseudo-header, for now. */ cstate->is_atm = 0; - cstate->off_vpi = -1; - cstate->off_vci = -1; - cstate->off_proto = -1; - cstate->off_payload = -1; + cstate->off_vpi = OFFSET_NOT_SET; + cstate->off_vci = OFFSET_NOT_SET; + cstate->off_proto = OFFSET_NOT_SET; + cstate->off_payload = OFFSET_NOT_SET; /* * And not Geneve. @@ -1079,14 +1087,19 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->is_geneve = 0; /* + * No variable length VLAN offset by default + */ + cstate->is_vlan_vloffset = 0; + + /* * And assume we're not doing SS7. */ - cstate->off_li = -1; - cstate->off_li_hsl = -1; - cstate->off_sio = -1; - cstate->off_opc = -1; - cstate->off_dpc = -1; - cstate->off_sls = -1; + cstate->off_li = OFFSET_NOT_SET; + cstate->off_li_hsl = OFFSET_NOT_SET; + cstate->off_sio = OFFSET_NOT_SET; + cstate->off_opc = OFFSET_NOT_SET; + cstate->off_dpc = OFFSET_NOT_SET; + cstate->off_sls = OFFSET_NOT_SET; cstate->label_stack_depth = 0; cstate->vlan_stack_depth = 0; @@ -1096,7 +1109,7 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) case DLT_ARCNET: cstate->off_linktype.constant_part = 2; cstate->off_linkpl.constant_part = 6; - cstate->off_nl = 0; /* XXX in reality, variable! */ + cstate->off_nl = 0; /* XXX in reality, variable! */ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */ break; @@ -1410,7 +1423,7 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_linktype.constant_part = 4; cstate->off_linkpl.constant_part = 4; cstate->off_nl = 0; - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_JUNIPER_ATM1: @@ -1441,63 +1454,63 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_linktype.constant_part = 4; cstate->off_linkpl.constant_part = 6; cstate->off_nl = 0; - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_JUNIPER_GGSN: cstate->off_linktype.constant_part = 6; cstate->off_linkpl.constant_part = 12; cstate->off_nl = 0; - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_JUNIPER_ES: cstate->off_linktype.constant_part = 6; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; /* not really a network layer but raw IP addresses */ - cstate->off_nl = -1; /* not really a network layer but raw IP addresses */ - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl = OFFSET_NOT_SET; /* not really a network layer but raw IP addresses */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_JUNIPER_MONITOR: cstate->off_linktype.constant_part = 12; cstate->off_linkpl.constant_part = 12; - cstate->off_nl = 0; /* raw IP/IP6 header */ - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl = 0; /* raw IP/IP6 header */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_BACNET_MS_TP: cstate->off_linktype.constant_part = OFFSET_NOT_SET; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_JUNIPER_SERVICES: cstate->off_linktype.constant_part = 12; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; /* L3 proto location dep. on cookie type */ - cstate->off_nl = -1; /* L3 proto location dep. on cookie type */ - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl = OFFSET_NOT_SET; /* L3 proto location dep. on cookie type */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_JUNIPER_VP: cstate->off_linktype.constant_part = 18; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_JUNIPER_ST: cstate->off_linktype.constant_part = 18; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_JUNIPER_ISM: cstate->off_linktype.constant_part = 8; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_JUNIPER_VS: @@ -1506,8 +1519,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) case DLT_JUNIPER_ATM_CEMIC: cstate->off_linktype.constant_part = 8; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_MTP2: @@ -1519,8 +1532,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_sls = 7; cstate->off_linktype.constant_part = OFFSET_NOT_SET; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_MTP2_WITH_PHDR: @@ -1532,8 +1545,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_sls = 11; cstate->off_linktype.constant_part = OFFSET_NOT_SET; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_ERF: @@ -1545,8 +1558,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_sls = 27; cstate->off_linktype.constant_part = OFFSET_NOT_SET; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_PFSYNC: @@ -1562,15 +1575,15 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) */ cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */ cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; /* variable, min 16, max 71 steps of 7 */ - cstate->off_nl_nosnap = -1; /* no 802.2 LLC */ + cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */ + cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */ break; case DLT_IPNET: cstate->off_linktype.constant_part = 1; cstate->off_linkpl.constant_part = 24; /* ipnet header length */ cstate->off_nl = 0; - cstate->off_nl_nosnap = -1; + cstate->off_nl_nosnap = OFFSET_NOT_SET; break; case DLT_NETANALYZER: @@ -1598,8 +1611,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->linktype <= DLT_MATCHING_MAX) { cstate->off_linktype.constant_part = OFFSET_NOT_SET; cstate->off_linkpl.constant_part = OFFSET_NOT_SET; - cstate->off_nl = -1; - cstate->off_nl_nosnap = -1; + cstate->off_nl = OFFSET_NOT_SET; + cstate->off_nl_nosnap = OFFSET_NOT_SET; } else { bpf_error(cstate, "unknown data link type %d", cstate->linktype); } @@ -1724,7 +1737,7 @@ gen_load_a(compiler_state_t *cstate, enum e_offrel offrel, u_int offset, default: abort(); - return NULL; + /* NOTREACHED */ } return s; } @@ -1788,6 +1801,7 @@ gen_loadx_iphdrlen(compiler_state_t *cstate) return s; } + static struct block * gen_uncond(compiler_state_t *cstate, int rsense) { @@ -2805,6 +2819,28 @@ insert_compute_vloffsets(compiler_state_t *cstate, struct block *b) } /* + * If there there is no initialization yet and we need variable + * length offsets for VLAN, initialize them to zero + */ + if (s == NULL && cstate->is_vlan_vloffset) { + struct slist *s2; + + if (cstate->off_linkpl.reg == -1) + cstate->off_linkpl.reg = alloc_reg(cstate); + if (cstate->off_linktype.reg == -1) + cstate->off_linktype.reg = alloc_reg(cstate); + + s = new_stmt(cstate, BPF_LD|BPF_W|BPF_IMM); + s->s.k = 0; + s2 = new_stmt(cstate, BPF_ST); + s2->s.k = cstate->off_linkpl.reg; + sappend(s, s2); + s2 = new_stmt(cstate, BPF_ST); + s2->s.k = cstate->off_linktype.reg; + sappend(s, s2); + } + + /* * If we have any offset-loading code, append all the * existing statements in the block to those statements, * and make the resulting list the list of statements @@ -2890,8 +2926,7 @@ gen_abs_offset_varpart(compiler_state_t *cstate, bpf_abs_offset *off) * Map an Ethernet type to the equivalent PPP type. */ static int -ethertype_to_ppptype(proto) - int proto; +ethertype_to_ppptype(int proto) { switch (proto) { @@ -2978,7 +3013,7 @@ gen_prevlinkhdr_check(compiler_state_t *cstate) */ #define BSD_AFNUM_INET6_BSD 24 /* NetBSD, OpenBSD, BSD/OS, Npcap */ #define BSD_AFNUM_INET6_FREEBSD 28 /* FreeBSD */ -#define BSD_AFNUM_INET6_DARWIN 30 /* OS X, iOS, other Darwin-based OSes */ +#define BSD_AFNUM_INET6_DARWIN 30 /* macOS, iOS, other Darwin-based OSes */ /* * Generate code to match a particular packet type by matching the @@ -3534,14 +3569,14 @@ gen_snap(compiler_state_t *cstate, bpf_u_int32 orgcode, bpf_u_int32 ptype) { u_char snapblock[8]; - snapblock[0] = LLCSAP_SNAP; /* DSAP = SNAP */ - snapblock[1] = LLCSAP_SNAP; /* SSAP = SNAP */ - snapblock[2] = 0x03; /* control = UI */ - snapblock[3] = (orgcode >> 16); /* upper 8 bits of organization code */ - snapblock[4] = (orgcode >> 8); /* middle 8 bits of organization code */ - snapblock[5] = (orgcode >> 0); /* lower 8 bits of organization code */ - snapblock[6] = (ptype >> 8); /* upper 8 bits of protocol type */ - snapblock[7] = (ptype >> 0); /* lower 8 bits of protocol type */ + snapblock[0] = LLCSAP_SNAP; /* DSAP = SNAP */ + snapblock[1] = LLCSAP_SNAP; /* SSAP = SNAP */ + snapblock[2] = 0x03; /* control = UI */ + snapblock[3] = (u_char)(orgcode >> 16); /* upper 8 bits of organization code */ + snapblock[4] = (u_char)(orgcode >> 8); /* middle 8 bits of organization code */ + snapblock[5] = (u_char)(orgcode >> 0); /* lower 8 bits of organization code */ + snapblock[6] = (u_char)(ptype >> 8); /* upper 8 bits of protocol type */ + snapblock[7] = (u_char)(ptype >> 0); /* lower 8 bits of protocol type */ return gen_bcmp(cstate, OR_LLC, 0, 8, snapblock); } @@ -3834,6 +3869,30 @@ gen_hostop(compiler_state_t *cstate, bpf_u_int32 addr, bpf_u_int32 mask, gen_or(b0, b1); return b1; + case Q_ADDR1: + bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_ADDR2: + bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_ADDR3: + bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_ADDR4: + bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_RA: + bpf_error(cstate, "'ra' is not a valid qualifier for addresses other than 802.11 MAC addresses"); + break; + + case Q_TA: + bpf_error(cstate, "'ta' is not a valid qualifier for addresses other than 802.11 MAC addresses"); + break; + default: abort(); } @@ -3850,7 +3909,7 @@ gen_hostop6(compiler_state_t *cstate, struct in6_addr *addr, { struct block *b0, *b1; u_int offset; - u_int32_t *a, *m; + uint32_t *a, *m; switch (dir) { @@ -3875,12 +3934,36 @@ gen_hostop6(compiler_state_t *cstate, struct in6_addr *addr, gen_or(b0, b1); return b1; + case Q_ADDR1: + bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_ADDR2: + bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_ADDR3: + bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_ADDR4: + bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for addresses other than 802.11 MAC addresses"); + break; + + case Q_RA: + bpf_error(cstate, "'ra' is not a valid qualifier for addresses other than 802.11 MAC addresses"); + break; + + case Q_TA: + bpf_error(cstate, "'ta' is not a valid qualifier for addresses other than 802.11 MAC addresses"); + break; + default: abort(); } /* this order is important */ - a = (u_int32_t *)addr; - m = (u_int32_t *)mask; + a = (uint32_t *)addr; + m = (uint32_t *)mask; b1 = gen_mcmp(cstate, OR_LINKPL, offset + 12, BPF_W, ntohl(a[3]), ntohl(m[3])); b0 = gen_mcmp(cstate, OR_LINKPL, offset + 8, BPF_W, ntohl(a[2]), ntohl(m[2])); gen_and(b0, b1); @@ -3920,19 +4003,19 @@ gen_ehostop(compiler_state_t *cstate, const u_char *eaddr, int dir) return b1; case Q_ADDR1: - bpf_error(cstate, "'addr1' is only supported on 802.11 with 802.11 headers"); + bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11 with 802.11 headers"); break; case Q_ADDR2: - bpf_error(cstate, "'addr2' is only supported on 802.11 with 802.11 headers"); + bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11 with 802.11 headers"); break; case Q_ADDR3: - bpf_error(cstate, "'addr3' is only supported on 802.11 with 802.11 headers"); + bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11 with 802.11 headers"); break; case Q_ADDR4: - bpf_error(cstate, "'addr4' is only supported on 802.11 with 802.11 headers"); + bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11 with 802.11 headers"); break; case Q_RA: @@ -3976,19 +4059,19 @@ gen_fhostop(compiler_state_t *cstate, const u_char *eaddr, int dir) return b1; case Q_ADDR1: - bpf_error(cstate, "'addr1' is only supported on 802.11"); + bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11"); break; case Q_ADDR2: - bpf_error(cstate, "'addr2' is only supported on 802.11"); + bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11"); break; case Q_ADDR3: - bpf_error(cstate, "'addr3' is only supported on 802.11"); + bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11"); break; case Q_ADDR4: - bpf_error(cstate, "'addr4' is only supported on 802.11"); + bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11"); break; case Q_RA: @@ -4032,19 +4115,19 @@ gen_thostop(compiler_state_t *cstate, const u_char *eaddr, int dir) return b1; case Q_ADDR1: - bpf_error(cstate, "'addr1' is only supported on 802.11"); + bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11"); break; case Q_ADDR2: - bpf_error(cstate, "'addr2' is only supported on 802.11"); + bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11"); break; case Q_ADDR3: - bpf_error(cstate, "'addr3' is only supported on 802.11"); + bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11"); break; case Q_ADDR4: - bpf_error(cstate, "'addr4' is only supported on 802.11"); + bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11"); break; case Q_RA: @@ -4513,19 +4596,19 @@ gen_ipfchostop(compiler_state_t *cstate, const u_char *eaddr, int dir) return b1; case Q_ADDR1: - bpf_error(cstate, "'addr1' is only supported on 802.11"); + bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11"); break; case Q_ADDR2: - bpf_error(cstate, "'addr2' is only supported on 802.11"); + bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11"); break; case Q_ADDR3: - bpf_error(cstate, "'addr3' is only supported on 802.11"); + bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11"); break; case Q_ADDR4: - bpf_error(cstate, "'addr4' is only supported on 802.11"); + bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11"); break; case Q_RA: @@ -4641,7 +4724,7 @@ gen_mpls_linktype(compiler_state_t *cstate, int proto) case Q_IP: /* match the bottom-of-stack bit */ - b0 = gen_mcmp(cstate, OR_LINKPL, -2, BPF_B, 0x01, 0x01); + b0 = gen_mcmp(cstate, OR_LINKPL, (u_int)-2, BPF_B, 0x01, 0x01); /* match the IPv4 version number */ b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_B, 0x40, 0xf0); gen_and(b0, b1); @@ -4649,7 +4732,7 @@ gen_mpls_linktype(compiler_state_t *cstate, int proto) case Q_IPV6: /* match the bottom-of-stack bit */ - b0 = gen_mcmp(cstate, OR_LINKPL, -2, BPF_B, 0x01, 0x01); + b0 = gen_mcmp(cstate, OR_LINKPL, (u_int)-2, BPF_B, 0x01, 0x01); /* match the IPv4 version number */ b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_B, 0x60, 0xf0); gen_and(b0, b1); @@ -4909,10 +4992,12 @@ gen_host6(compiler_state_t *cstate, struct in6_addr *addr, #ifndef INET6 static struct block * -gen_gateway(compiler_state_t *cstate, const u_char *eaddr, bpf_u_int32 **alist, - int proto, int dir) +gen_gateway(compiler_state_t *cstate, const u_char *eaddr, + struct addrinfo *alist, int proto, int dir) { struct block *b0, *b1, *tmp; + struct addrinfo *ai; + struct sockaddr_in *sin; if (dir != 0) bpf_error(cstate, "direction applied to 'gateway'"); @@ -4960,12 +5045,48 @@ gen_gateway(compiler_state_t *cstate, const u_char *eaddr, bpf_u_int32 **alist, bpf_error(cstate, "'gateway' supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel"); } - b1 = gen_host(cstate, **alist++, 0xffffffff, proto, Q_OR, Q_HOST); - while (*alist) { - tmp = gen_host(cstate, **alist++, 0xffffffff, proto, Q_OR, - Q_HOST); - gen_or(b1, tmp); - b1 = tmp; + b1 = NULL; + for (ai = alist; ai != NULL; ai = ai->ai_next) { + /* + * Does it have an address? + */ + if (ai->ai_addr != NULL) { + /* + * Yes. Is it an IPv4 address? + */ + if (ai->ai_addr->sa_family == AF_INET) { + /* + * Generate an entry for it. + */ + sin = (struct sockaddr_in *)ai->ai_addr; + tmp = gen_host(cstate, + ntohl(sin->sin_addr.s_addr), + 0xffffffff, proto, Q_OR, Q_HOST); + /* + * Is it the *first* IPv4 address? + */ + if (b1 == NULL) { + /* + * Yes, so start with it. + */ + b1 = tmp; + } else { + /* + * No, so OR it into the + * existing set of + * addresses. + */ + gen_or(b1, tmp); + b1 = tmp; + } + } + } + } + if (b1 == NULL) { + /* + * No IPv4 addresses found. + */ + return (NULL); } gen_not(b1); gen_and(b0, b1); @@ -5647,9 +5768,7 @@ lookup_proto(compiler_state_t *cstate, const char *name, int proto) #if 0 struct stmt * -gen_joinsp(s, n) - struct stmt **s; - int n; +gen_joinsp(struct stmt **s, int n) { return NULL; } @@ -5699,7 +5818,7 @@ gen_protochain(compiler_state_t *cstate, int v, int proto, int dir) if (cstate->off_linkpl.is_variable) bpf_error(cstate, "'protochain' not supported with variable length headers"); - cstate->no_optimize = 1; /*this code is not compatible with optimzer yet */ + cstate->no_optimize = 1; /* this code is not compatible with optimizer yet */ /* * s[0] is a dummy entry to protect other BPF insn from damage @@ -6203,13 +6322,11 @@ gen_scode(compiler_state_t *cstate, const char *name, struct qual q) int tproto; u_char *eaddr; bpf_u_int32 mask, addr; -#ifndef INET6 - bpf_u_int32 **alist; -#else - int tproto6; + struct addrinfo *res, *res0; struct sockaddr_in *sin4; +#ifdef INET6 + int tproto6; struct sockaddr_in6 *sin6; - struct addrinfo *res, *res0; struct in6_addr mask128; #endif /*INET6*/ struct block *b, *tmp; @@ -6308,46 +6425,39 @@ gen_scode(compiler_state_t *cstate, const char *name, struct qual q) */ return (gen_host(cstate, dn_addr, 0, proto, dir, q.addr)); } else { -#ifndef INET6 - alist = pcap_nametoaddr(name); - if (alist == NULL || *alist == NULL) - bpf_error(cstate, "unknown host '%s'", name); - tproto = proto; - if (cstate->off_linktype.constant_part == OFFSET_NOT_SET && - tproto == Q_DEFAULT) - tproto = Q_IP; - b = gen_host(cstate, **alist++, 0xffffffff, tproto, dir, q.addr); - while (*alist) { - tmp = gen_host(cstate, **alist++, 0xffffffff, - tproto, dir, q.addr); - gen_or(b, tmp); - b = tmp; - } - return b; -#else +#ifdef INET6 memset(&mask128, 0xff, sizeof(mask128)); +#endif res0 = res = pcap_nametoaddrinfo(name); if (res == NULL) bpf_error(cstate, "unknown host '%s'", name); cstate->ai = res; b = tmp = NULL; - tproto = tproto6 = proto; + tproto = proto; +#ifdef INET6 + tproto6 = proto; +#endif if (cstate->off_linktype.constant_part == OFFSET_NOT_SET && tproto == Q_DEFAULT) { tproto = Q_IP; +#ifdef INET6 tproto6 = Q_IPV6; +#endif } for (res = res0; res; res = res->ai_next) { switch (res->ai_family) { case AF_INET: +#ifdef INET6 if (tproto == Q_IPV6) continue; +#endif sin4 = (struct sockaddr_in *) res->ai_addr; tmp = gen_host(cstate, ntohl(sin4->sin_addr.s_addr), 0xffffffff, tproto, dir, q.addr); break; +#ifdef INET6 case AF_INET6: if (tproto6 == Q_IP) continue; @@ -6357,6 +6467,7 @@ gen_scode(compiler_state_t *cstate, const char *name, struct qual q) tmp = gen_host6(cstate, &sin6->sin6_addr, &mask128, tproto6, dir, q.addr); break; +#endif default: continue; } @@ -6373,7 +6484,6 @@ gen_scode(compiler_state_t *cstate, const char *name, struct qual q) : " for specified address family"); } return b; -#endif /*INET6*/ } case Q_PORT: @@ -6471,11 +6581,15 @@ gen_scode(compiler_state_t *cstate, const char *name, struct qual q) if (eaddr == NULL) bpf_error(cstate, "unknown ether host: %s", name); - alist = pcap_nametoaddr(name); - if (alist == NULL || *alist == NULL) + res = pcap_nametoaddrinfo(name); + cstate->ai = res; + if (res == NULL) + bpf_error(cstate, "unknown host '%s'", name); + b = gen_gateway(cstate, eaddr, res, proto, dir); + cstate->ai = NULL; + freeaddrinfo(res); + if (b == NULL) bpf_error(cstate, "unknown host '%s'", name); - b = gen_gateway(cstate, eaddr, alist, proto, dir); - free(eaddr); return b; #else bpf_error(cstate, "'gateway' not supported in this configuration"); @@ -6548,7 +6662,6 @@ gen_mcode(compiler_state_t *cstate, const char *s1, const char *s2, /* NOTREACHED */ } /* NOTREACHED */ - return NULL; } struct block * @@ -6667,7 +6780,7 @@ gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2, struct in6_addr *addr; struct in6_addr mask; struct block *b; - u_int32_t *a, *m; + uint32_t *a, *m; if (s2) bpf_error(cstate, "no mask %s supported", s2); @@ -6689,8 +6802,8 @@ gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2, (0xff << (8 - masklen % 8)) & 0xff; } - a = (u_int32_t *)addr; - m = (u_int32_t *)&mask; + a = (uint32_t *)addr; + m = (uint32_t *)&mask; if ((a[0] & ~m[0]) || (a[1] & ~m[1]) || (a[2] & ~m[2]) || (a[3] & ~m[3])) { bpf_error(cstate, "non-network bits set in \"%s/%d\"", s1, masklen); @@ -6714,7 +6827,6 @@ gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2, bpf_error(cstate, "invalid qualifier against IPv6 address"); /* NOTREACHED */ } - return NULL; } #endif /*INET6*/ @@ -6752,12 +6864,10 @@ gen_ecode(compiler_state_t *cstate, const u_char *eaddr, struct qual q) } bpf_error(cstate, "ethernet address used in non-ether expression"); /* NOTREACHED */ - return NULL; } void -sappend(s0, s1) - struct slist *s0, *s1; +sappend(struct slist *s0, struct slist *s1) { /* * This is definitely not the best way to do this, but the @@ -7007,8 +7117,58 @@ gen_load(compiler_state_t *cstate, int proto, struct arth *inst, int size) inst->b = b; break; case Q_ICMPV6: - bpf_error(cstate, "IPv6 upper-layer protocol is not supported by proto[x]"); - /*NOTREACHED*/ + /* + * Do the computation only if the packet contains + * the protocol in question. + */ + b = gen_proto_abbrev(cstate, Q_IPV6); + if (inst->b) { + gen_and(inst->b, b); + } + inst->b = b; + + /* + * Check if we have an icmp6 next header + */ + b = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, 58); + if (inst->b) { + gen_and(inst->b, b); + } + inst->b = b; + + + s = gen_abs_offset_varpart(cstate, &cstate->off_linkpl); + /* + * If "s" is non-null, it has code to arrange that the + * X register contains the variable part of the offset + * of the link-layer payload. Add to it the offset + * computed into the register specified by "index", + * and move that into the X register. Otherwise, just + * load into the X register the offset computed into + * the register specified by "index". + */ + if (s != NULL) { + sappend(s, xfer_to_a(cstate, inst)); + sappend(s, new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_X)); + sappend(s, new_stmt(cstate, BPF_MISC|BPF_TAX)); + } else { + s = xfer_to_x(cstate, inst); + } + + /* + * Load the item at the sum of the offset we've put in the + * X register, the offset of the start of the network + * layer header from the beginning of the link-layer + * payload, and the constant part of the offset of the + * start of the link-layer payload. + */ + tmp = new_stmt(cstate, BPF_LD|BPF_IND|size); + tmp->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + 40; + + sappend(s, tmp); + sappend(inst->s, s); + + break; } inst->regno = regno; s = new_stmt(cstate, BPF_ST); @@ -7180,7 +7340,6 @@ alloc_reg(compiler_state_t *cstate) } bpf_error(cstate, "too many registers needed to evaluate expression"); /* NOTREACHED */ - return 0; } /* @@ -7335,7 +7494,6 @@ gen_broadcast(compiler_state_t *cstate, int proto) } bpf_error(cstate, "only link-layer/IP broadcast filters supported"); /* NOTREACHED */ - return NULL; } /* @@ -7531,7 +7689,6 @@ gen_multicast(compiler_state_t *cstate, int proto) } bpf_error(cstate, "link-layer multicast filters supported only on ethernet/FDDI/token ring/ARCNET/802.11/ATM LANE/Fibre Channel"); /* NOTREACHED */ - return NULL; } /* @@ -7632,8 +7789,18 @@ gen_inbound(compiler_state_t *cstate, int dir) default: /* * If we have packet meta-data indicating a direction, - * check it, otherwise give up as this link-layer type - * has nothing in the packet data. + * and that metadata can be checked by BPF code, check + * it. Otherwise, give up, as this link-layer type has + * nothing in the packet data. + * + * Currently, the only platform where a BPF filter can + * check that metadata is Linux with the in-kernel + * BPF interpreter. If other packet capture mechanisms + * and BPF filters also supported this, it would be + * nice. It would be even better if they made that + * metadata available so that we could provide it + * with newer capture APIs, allowing it to be saved + * in pcapng files. */ #if defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) /* @@ -7659,7 +7826,6 @@ gen_inbound(compiler_state_t *cstate, int dir) #else /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */ bpf_error(cstate, "inbound/outbound not supported on linktype %d", cstate->linktype); - b0 = NULL; /* NOTREACHED */ #endif /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */ } @@ -7776,51 +7942,45 @@ gen_pf_action(compiler_state_t *cstate, int action) } #else /* !HAVE_NET_PFVAR_H */ struct block * -gen_pf_ifname(compiler_state_t *cstate, const char *ifname) +gen_pf_ifname(compiler_state_t *cstate, const char *ifname _U_) { bpf_error(cstate, "libpcap was compiled without pf support"); /* NOTREACHED */ - return (NULL); } struct block * -gen_pf_ruleset(compiler_state_t *cstate, char *ruleset) +gen_pf_ruleset(compiler_state_t *cstate, char *ruleset _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /* NOTREACHED */ - return (NULL); } struct block * -gen_pf_rnr(compiler_state_t *cstate, int rnr) +gen_pf_rnr(compiler_state_t *cstate, int rnr _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /* NOTREACHED */ - return (NULL); } struct block * -gen_pf_srnr(compiler_state_t *cstate, int srnr) +gen_pf_srnr(compiler_state_t *cstate, int srnr _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /* NOTREACHED */ - return (NULL); } struct block * -gen_pf_reason(compiler_state_t *cstate, int reason) +gen_pf_reason(compiler_state_t *cstate, int reason _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /* NOTREACHED */ - return (NULL); } struct block * -gen_pf_action(compiler_state_t *cstate, int action) +gen_pf_action(compiler_state_t *cstate, int action _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /* NOTREACHED */ - return (NULL); } #endif /* HAVE_NET_PFVAR_H */ @@ -7892,9 +8052,6 @@ gen_acode(compiler_state_t *cstate, const u_char *eaddr, struct qual q) bpf_error(cstate, "aid supported only on ARCnet"); /* NOTREACHED */ } - bpf_error(cstate, "ARCnet address used in non-arc expression"); - /* NOTREACHED */ - return NULL; } static struct block * @@ -7924,19 +8081,19 @@ gen_ahostop(compiler_state_t *cstate, const u_char *eaddr, int dir) return b1; case Q_ADDR1: - bpf_error(cstate, "'addr1' is only supported on 802.11"); + bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11"); break; case Q_ADDR2: - bpf_error(cstate, "'addr2' is only supported on 802.11"); + bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11"); break; case Q_ADDR3: - bpf_error(cstate, "'addr3' is only supported on 802.11"); + bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11"); break; case Q_ADDR4: - bpf_error(cstate, "'addr4' is only supported on 802.11"); + bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11"); break; case Q_RA: @@ -7951,74 +8108,181 @@ gen_ahostop(compiler_state_t *cstate, const u_char *eaddr, int dir) /* NOTREACHED */ } -#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT) static struct block * -gen_vlan_bpf_extensions(compiler_state_t *cstate, int vlan_num) +gen_vlan_tpid_test(compiler_state_t *cstate) { - struct block *b0, *b1; - struct slist *s; - - /* generate new filter code based on extracting packet - * metadata */ - s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); - s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT; - - b0 = new_block(cstate, JMP(BPF_JEQ)); - b0->stmts = s; - b0->s.k = 1; - - if (vlan_num >= 0) { - s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); - s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG; + struct block *b0, *b1; - b1 = new_block(cstate, JMP(BPF_JEQ)); - b1->stmts = s; - b1->s.k = (bpf_int32) vlan_num; + /* check for VLAN, including QinQ */ + b0 = gen_linktype(cstate, ETHERTYPE_8021Q); + b1 = gen_linktype(cstate, ETHERTYPE_8021AD); + gen_or(b0,b1); + b0 = b1; + b1 = gen_linktype(cstate, ETHERTYPE_8021QINQ); + gen_or(b0,b1); - gen_and(b0,b1); - b0 = b1; - } + return b1; +} - return b0; +static struct block * +gen_vlan_vid_test(compiler_state_t *cstate, int vlan_num) +{ + return gen_mcmp(cstate, OR_LINKPL, 0, BPF_H, (bpf_int32)vlan_num, 0x0fff); } -#endif static struct block * gen_vlan_no_bpf_extensions(compiler_state_t *cstate, int vlan_num) { - struct block *b0, *b1; - - /* check for VLAN, including QinQ */ - b0 = gen_linktype(cstate, ETHERTYPE_8021Q); - b1 = gen_linktype(cstate, ETHERTYPE_8021AD); - gen_or(b0,b1); - b0 = b1; - b1 = gen_linktype(cstate, ETHERTYPE_8021QINQ); - gen_or(b0,b1); - b0 = b1; - - /* If a specific VLAN is requested, check VLAN id */ - if (vlan_num >= 0) { - b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_H, - (bpf_int32)vlan_num, 0x0fff); - gen_and(b0, b1); - b0 = b1; - } + struct block *b0, *b1; + + b0 = gen_vlan_tpid_test(cstate); + + if (vlan_num >= 0) { + b1 = gen_vlan_vid_test(cstate, vlan_num); + gen_and(b0, b1); + b0 = b1; + } /* - * The payload follows the full header, including the - * VLAN tags, so skip past this VLAN tag. + * Both payload and link header type follow the VLAN tags so that + * both need to be updated. */ - cstate->off_linkpl.constant_part += 4; + cstate->off_linkpl.constant_part += 4; + cstate->off_linktype.constant_part += 4; + + return b0; +} + +#if defined(SKF_AD_VLAN_TAG_PRESENT) +/* add v to variable part of off */ +static void +gen_vlan_vloffset_add(compiler_state_t *cstate, bpf_abs_offset *off, int v, struct slist *s) +{ + struct slist *s2; + + if (!off->is_variable) + off->is_variable = 1; + if (off->reg == -1) + off->reg = alloc_reg(cstate); + + s2 = new_stmt(cstate, BPF_LD|BPF_MEM); + s2->s.k = off->reg; + sappend(s, s2); + s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_IMM); + s2->s.k = v; + sappend(s, s2); + s2 = new_stmt(cstate, BPF_ST); + s2->s.k = off->reg; + sappend(s, s2); +} + +/* + * patch block b_tpid (VLAN TPID test) to update variable parts of link payload + * and link type offsets first + */ +static void +gen_vlan_patch_tpid_test(compiler_state_t *cstate, struct block *b_tpid) +{ + struct slist s; + + /* offset determined at run time, shift variable part */ + s.next = NULL; + cstate->is_vlan_vloffset = 1; + gen_vlan_vloffset_add(cstate, &cstate->off_linkpl, 4, &s); + gen_vlan_vloffset_add(cstate, &cstate->off_linktype, 4, &s); + + /* we get a pointer to a chain of or-ed blocks, patch first of them */ + sappend(s.next, b_tpid->head->stmts); + b_tpid->head->stmts = s.next; +} + +/* + * patch block b_vid (VLAN id test) to load VID value either from packet + * metadata (using BPF extensions) if SKF_AD_VLAN_TAG_PRESENT is true + */ +static void +gen_vlan_patch_vid_test(compiler_state_t *cstate, struct block *b_vid) +{ + struct slist *s, *s2, *sjeq; + unsigned cnt; + + s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); + s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT; + + /* true -> next instructions, false -> beginning of b_vid */ + sjeq = new_stmt(cstate, JMP(BPF_JEQ)); + sjeq->s.k = 1; + sjeq->s.jf = b_vid->stmts; + sappend(s, sjeq); + + s2 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); + s2->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG; + sappend(s, s2); + sjeq->s.jt = s2; + + /* jump to the test in b_vid (bypass loading VID from packet data) */ + cnt = 0; + for (s2 = b_vid->stmts; s2; s2 = s2->next) + cnt++; + s2 = new_stmt(cstate, JMP(BPF_JA)); + s2->s.k = cnt; + sappend(s, s2); + + /* insert our statements at the beginning of b_vid */ + sappend(s, b_vid->stmts); + b_vid->stmts = s; +} + +/* + * Generate check for "vlan" or "vlan <id>" on systems with support for BPF + * extensions. Even if kernel supports VLAN BPF extensions, (outermost) VLAN + * tag can be either in metadata or in packet data; therefore if the + * SKF_AD_VLAN_TAG_PRESENT test is negative, we need to check link + * header for VLAN tag. As the decision is done at run time, we need + * update variable part of the offsets + */ +static struct block * +gen_vlan_bpf_extensions(compiler_state_t *cstate, int vlan_num) +{ + struct block *b0, *b_tpid, *b_vid = NULL; + struct slist *s; + + /* generate new filter code based on extracting packet + * metadata */ + s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); + s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT; + + b0 = new_block(cstate, JMP(BPF_JEQ)); + b0->stmts = s; + b0->s.k = 1; /* - * The link-layer type information follows the VLAN tags, so - * skip past this VLAN tag. + * This is tricky. We need to insert the statements updating variable + * parts of offsets before the the traditional TPID and VID tests so + * that they are called whenever SKF_AD_VLAN_TAG_PRESENT fails but + * we do not want this update to affect those checks. That's why we + * generate both test blocks first and insert the statements updating + * variable parts of both offsets after that. This wouldn't work if + * there already were variable length link header when entering this + * function but gen_vlan_bpf_extensions() isn't called in that case. */ - cstate->off_linktype.constant_part += 4; + b_tpid = gen_vlan_tpid_test(cstate); + if (vlan_num >= 0) + b_vid = gen_vlan_vid_test(cstate, vlan_num); + + gen_vlan_patch_tpid_test(cstate, b_tpid); + gen_or(b0, b_tpid); + b0 = b_tpid; + + if (vlan_num >= 0) { + gen_vlan_patch_vid_test(cstate, b_vid); + gen_and(b0, b_vid); + b0 = b_vid; + } return b0; } +#endif /* * support IEEE 802.1Q VLAN trunk over ethernet @@ -8068,7 +8332,7 @@ gen_vlan(compiler_state_t *cstate, int vlan_num) case DLT_EN10MB: case DLT_NETANALYZER: case DLT_NETANALYZER_TRANSPARENT: -#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT) +#if defined(SKF_AD_VLAN_TAG_PRESENT) /* Verify that this is the outer part of the packet and * not encapsulated somehow. */ if (cstate->vlan_stack_depth == 0 && !cstate->off_linkhdr.is_variable && @@ -8140,7 +8404,6 @@ gen_mpls(compiler_state_t *cstate, int label_num) default: bpf_error(cstate, "no MPLS support for data link type %d", cstate->linktype); - b0 = NULL; /*NOTREACHED*/ break; } @@ -8561,7 +8824,7 @@ gen_atmfield_code(compiler_state_t *cstate, int atmfield, bpf_int32 jvalue, case A_VPI: if (!cstate->is_atm) bpf_error(cstate, "'vpi' supported only on raw ATM"); - if (cstate->off_vpi == (u_int)-1) + if (cstate->off_vpi == OFFSET_NOT_SET) abort(); b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_vpi, BPF_B, 0xffffffff, jtype, reverse, jvalue); @@ -8570,21 +8833,21 @@ gen_atmfield_code(compiler_state_t *cstate, int atmfield, bpf_int32 jvalue, case A_VCI: if (!cstate->is_atm) bpf_error(cstate, "'vci' supported only on raw ATM"); - if (cstate->off_vci == (u_int)-1) + if (cstate->off_vci == OFFSET_NOT_SET) abort(); b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_vci, BPF_H, 0xffffffff, jtype, reverse, jvalue); break; case A_PROTOTYPE: - if (cstate->off_proto == (u_int)-1) + if (cstate->off_proto == OFFSET_NOT_SET) abort(); /* XXX - this isn't on FreeBSD */ b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_proto, BPF_B, 0x0f, jtype, reverse, jvalue); break; case A_MSGTYPE: - if (cstate->off_payload == (u_int)-1) + if (cstate->off_payload == OFFSET_NOT_SET) abort(); b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_payload + MSG_TYPE_POS, BPF_B, 0xffffffff, jtype, reverse, jvalue); @@ -8593,7 +8856,7 @@ gen_atmfield_code(compiler_state_t *cstate, int atmfield, bpf_int32 jvalue, case A_CALLREFTYPE: if (!cstate->is_atm) bpf_error(cstate, "'callref' supported only on raw ATM"); - if (cstate->off_proto == (u_int)-1) + if (cstate->off_proto == OFFSET_NOT_SET) abort(); b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_proto, BPF_B, 0xffffffff, jtype, reverse, jvalue); @@ -8795,7 +9058,7 @@ gen_mtp3field_code(compiler_state_t *cstate, int mtp3field, bpf_u_int32 jvalue, /* FALLTHROUGH */ case M_SIO: - if (cstate->off_sio == (u_int)-1) + if (cstate->off_sio == OFFSET_NOT_SET) bpf_error(cstate, "'sio' supported only on SS7"); /* sio coded on 1 byte so max value 255 */ if(jvalue > 255) @@ -8808,7 +9071,7 @@ gen_mtp3field_code(compiler_state_t *cstate, int mtp3field, bpf_u_int32 jvalue, case MH_OPC: newoff_opc+=3; case M_OPC: - if (cstate->off_opc == (u_int)-1) + if (cstate->off_opc == OFFSET_NOT_SET) bpf_error(cstate, "'opc' supported only on SS7"); /* opc coded on 14 bits so max value 16383 */ if (jvalue > 16383) @@ -8832,7 +9095,7 @@ gen_mtp3field_code(compiler_state_t *cstate, int mtp3field, bpf_u_int32 jvalue, /* FALLTHROUGH */ case M_DPC: - if (cstate->off_dpc == (u_int)-1) + if (cstate->off_dpc == OFFSET_NOT_SET) bpf_error(cstate, "'dpc' supported only on SS7"); /* dpc coded on 14 bits so max value 16383 */ if (jvalue > 16383) @@ -8852,7 +9115,7 @@ gen_mtp3field_code(compiler_state_t *cstate, int mtp3field, bpf_u_int32 jvalue, case MH_SLS: newoff_sls+=3; case M_SLS: - if (cstate->off_sls == (u_int)-1) + if (cstate->off_sls == OFFSET_NOT_SET) bpf_error(cstate, "'sls' supported only on SS7"); /* sls coded on 4 bits so max value 15 */ if (jvalue > 15) diff --git a/freebsd/contrib/libpcap/gencode.h b/freebsd/contrib/libpcap/gencode.h index 2b089d21..88def5a8 100644 --- a/freebsd/contrib/libpcap/gencode.h +++ b/freebsd/contrib/libpcap/gencode.h @@ -19,6 +19,8 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include "pcap/funcattrs.h" + /* * ATM support: * @@ -53,10 +55,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HAVE___ATTRIBUTE__ -#define __attribute__(x) -#endif /* HAVE___ATTRIBUTE__ */ - /* Address qualifiers. */ #define Q_HOST 1 @@ -268,6 +266,11 @@ struct block { int val[N_ATOMS]; }; +/* + * A value of 0 for val[i] means the value is unknown. + */ +#define VAL_UNKNOWN 0 + struct arth { struct block *b; /* protocol checks */ struct slist *s; /* stmt list */ @@ -340,11 +343,29 @@ struct block *gen_mtp2type_abbrev(compiler_state_t *, int type); struct block *gen_mtp3field_code(compiler_state_t *, int, bpf_u_int32, bpf_u_int32, int); +#ifndef HAVE_NET_PFVAR_H +PCAP_NORETURN +#endif struct block *gen_pf_ifname(compiler_state_t *, const char *); +#ifndef HAVE_NET_PFVAR_H +PCAP_NORETURN +#endif struct block *gen_pf_rnr(compiler_state_t *, int); +#ifndef HAVE_NET_PFVAR_H +PCAP_NORETURN +#endif struct block *gen_pf_srnr(compiler_state_t *, int); +#ifndef HAVE_NET_PFVAR_H +PCAP_NORETURN +#endif struct block *gen_pf_ruleset(compiler_state_t *, char *); +#ifndef HAVE_NET_PFVAR_H +PCAP_NORETURN +#endif struct block *gen_pf_reason(compiler_state_t *, int); +#ifndef HAVE_NET_PFVAR_H +PCAP_NORETURN +#endif struct block *gen_pf_action(compiler_state_t *, int); struct block *gen_p80211_type(compiler_state_t *, int, int); @@ -366,20 +387,13 @@ struct icode { }; void bpf_optimize(compiler_state_t *, struct icode *ic); -void bpf_syntax_error(compiler_state_t *, const char *); -void bpf_error(compiler_state_t *, const char *, ...) - __attribute__((noreturn)) -#ifdef __ATTRIBUTE___FORMAT_OK - __attribute__((format (printf, 2, 3))) -#endif /* __ATTRIBUTE___FORMAT_OK */ - ; +void PCAP_NORETURN bpf_syntax_error(compiler_state_t *, const char *); +void PCAP_NORETURN bpf_error(compiler_state_t *, const char *, ...) + PCAP_PRINTFLIKE(2, 3); void finish_parse(compiler_state_t *, struct block *); char *sdup(compiler_state_t *, const char *); -struct _opt_state; -typedef struct _opt_state opt_state_t; - struct bpf_insn *icode_to_fcode(compiler_state_t *, struct icode *, struct block *, u_int *); void sappend(struct slist *, struct slist *); diff --git a/freebsd/contrib/libpcap/grammar.c b/freebsd/contrib/libpcap/grammar.c index a04f770c..4672c0b6 100644 --- a/freebsd/contrib/libpcap/grammar.c +++ b/freebsd/contrib/libpcap/grammar.c @@ -118,23 +118,18 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $FreeBSD$ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif -#ifdef _WIN32 -#include <pcap-stdinc.h> -#else /* _WIN32 */ -#include <sys/types.h> -#include <sys/socket.h> -#endif /* _WIN32 */ - #include <stdlib.h> #ifndef _WIN32 +#include <sys/types.h> +#include <sys/socket.h> + #if __STDC__ struct mbuf; struct rtentry; @@ -146,6 +141,8 @@ struct rtentry; #include <stdio.h> +#include "diag-control.h" + #include "pcap-int.h" #include "gencode.h" @@ -154,7 +151,7 @@ struct rtentry; #ifdef HAVE_NET_PFVAR_H #include <net/if.h> -#include <netpfil/pf/pf.h> +#include <net/pfvar.h> #include <net/if_pflog.h> #endif #include "llc.h" @@ -165,9 +162,30 @@ struct rtentry; #include "os-proto.h" #endif -#define QSET(q, p, d, a) (q).proto = (p),\ - (q).dir = (d),\ - (q).addr = (a) +#ifdef YYBYACC +/* + * Both Berkeley YACC and Bison define yydebug (under whatever name + * it has) as a global, but Bison does so only if YYDEBUG is defined. + * Berkeley YACC define it even if YYDEBUG isn't defined; declare it + * here to suppress a warning. + */ +#if !defined(YYDEBUG) +extern int yydebug; +#endif + +/* + * In Berkeley YACC, yynerrs (under whatever name it has) is global, + * even if it's building a reentrant parser. In Bison, it's local + * in reentrant parsers. + * + * Declare it to squelch a warning. + */ +extern int yynerrs; +#endif + +#define QSET(q, p, d, a) (q).proto = (unsigned char)(p),\ + (q).dir = (unsigned char)(d),\ + (q).addr = (unsigned char)(a) struct tok { int v; /* value */ @@ -274,8 +292,8 @@ str2tok(const char *str, const struct tok *toks) static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF }; -static void -yyerror(void *yyscanner, compiler_state_t *cstate, const char *msg) +static PCAP_NORETURN_DEF void +yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg) { bpf_syntax_error(cstate, msg); /* NOTREACHED */ @@ -321,33 +339,29 @@ pfaction_to_num(compiler_state_t *cstate, const char *action) } } #else /* !HAVE_NET_PFVAR_H */ -static int -pfreason_to_num(compiler_state_t *cstate, const char *reason) +static PCAP_NORETURN_DEF int +pfreason_to_num(compiler_state_t *cstate, const char *reason _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /*NOTREACHED*/ - - /* this is to make the VC compiler happy */ - return -1; } -static int -pfaction_to_num(compiler_state_t *cstate, const char *action) +static PCAP_NORETURN_DEF int +pfaction_to_num(compiler_state_t *cstate, const char *action _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /*NOTREACHED*/ - - /* this is to make the VC compiler happy */ - return -1; } #endif /* HAVE_NET_PFVAR_H */ + +DIAG_OFF_BISON_BYACC #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -#line 272 "grammar.y" +#line 286 "grammar.y" typedef union { int i; bpf_u_int32 h; @@ -364,7 +378,7 @@ typedef union { struct block *rblk; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ -#line 368 "grammar.c" +#line 382 "grammar.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -1434,64 +1448,64 @@ yyreduce: switch (yyn) { case 1: -#line 347 "grammar.y" +#line 361 "grammar.y" { finish_parse(cstate, yystack.l_mark[0].blk.b); } break; case 3: -#line 352 "grammar.y" +#line 366 "grammar.y" { yyval.blk.q = qerr; } break; case 5: -#line 355 "grammar.y" +#line 369 "grammar.y" { gen_and(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 6: -#line 356 "grammar.y" +#line 370 "grammar.y" { gen_and(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 7: -#line 357 "grammar.y" +#line 371 "grammar.y" { gen_or(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 8: -#line 358 "grammar.y" +#line 372 "grammar.y" { gen_or(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 9: -#line 360 "grammar.y" +#line 374 "grammar.y" { yyval.blk = yystack.l_mark[-1].blk; } break; case 10: -#line 362 "grammar.y" +#line 376 "grammar.y" { yyval.blk = yystack.l_mark[-1].blk; } break; case 12: -#line 365 "grammar.y" +#line 379 "grammar.y" { yyval.blk.b = gen_ncode(cstate, NULL, (bpf_u_int32)yystack.l_mark[0].i, yyval.blk.q = yystack.l_mark[-1].blk.q); } break; case 13: -#line 367 "grammar.y" +#line 381 "grammar.y" { yyval.blk = yystack.l_mark[-1].blk; } break; case 14: -#line 369 "grammar.y" +#line 383 "grammar.y" { yyval.blk.b = gen_scode(cstate, yystack.l_mark[0].s, yyval.blk.q = yystack.l_mark[-1].blk.q); } break; case 15: -#line 370 "grammar.y" +#line 384 "grammar.y" { yyval.blk.b = gen_mcode(cstate, yystack.l_mark[-2].s, NULL, yystack.l_mark[0].i, yyval.blk.q = yystack.l_mark[-3].blk.q); } break; case 16: -#line 372 "grammar.y" +#line 386 "grammar.y" { yyval.blk.b = gen_mcode(cstate, yystack.l_mark[-2].s, yystack.l_mark[0].s, 0, yyval.blk.q = yystack.l_mark[-3].blk.q); } break; case 17: -#line 374 "grammar.y" +#line 388 "grammar.y" { /* Decide how to parse HID based on proto */ yyval.blk.q = yystack.l_mark[-1].blk.q; @@ -1507,7 +1521,7 @@ case 17: } break; case 18: -#line 387 "grammar.y" +#line 401 "grammar.y" { #ifdef INET6 yyval.blk.b = gen_mcode6(cstate, yystack.l_mark[-2].s, NULL, yystack.l_mark[0].i, @@ -1519,7 +1533,7 @@ case 18: } break; case 19: -#line 396 "grammar.y" +#line 410 "grammar.y" { #ifdef INET6 yyval.blk.b = gen_mcode6(cstate, yystack.l_mark[0].s, 0, 128, @@ -1531,7 +1545,7 @@ case 19: } break; case 20: -#line 405 "grammar.y" +#line 419 "grammar.y" { yyval.blk.b = gen_ecode(cstate, yystack.l_mark[0].e, yyval.blk.q = yystack.l_mark[-1].blk.q); /* @@ -1543,7 +1557,7 @@ case 20: } break; case 21: -#line 414 "grammar.y" +#line 428 "grammar.y" { yyval.blk.b = gen_acode(cstate, yystack.l_mark[0].e, yyval.blk.q = yystack.l_mark[-1].blk.q); /* @@ -1555,465 +1569,465 @@ case 21: } break; case 22: -#line 423 "grammar.y" +#line 437 "grammar.y" { gen_not(yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 23: -#line 425 "grammar.y" +#line 439 "grammar.y" { yyval.blk = yystack.l_mark[-1].blk; } break; case 24: -#line 427 "grammar.y" +#line 441 "grammar.y" { yyval.blk = yystack.l_mark[-1].blk; } break; case 26: -#line 430 "grammar.y" +#line 444 "grammar.y" { gen_and(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 27: -#line 431 "grammar.y" +#line 445 "grammar.y" { gen_or(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 28: -#line 433 "grammar.y" +#line 447 "grammar.y" { yyval.blk.b = gen_ncode(cstate, NULL, (bpf_u_int32)yystack.l_mark[0].i, yyval.blk.q = yystack.l_mark[-1].blk.q); } break; case 31: -#line 438 "grammar.y" +#line 452 "grammar.y" { gen_not(yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 32: -#line 440 "grammar.y" +#line 454 "grammar.y" { QSET(yyval.blk.q, yystack.l_mark[-2].i, yystack.l_mark[-1].i, yystack.l_mark[0].i); } break; case 33: -#line 441 "grammar.y" +#line 455 "grammar.y" { QSET(yyval.blk.q, yystack.l_mark[-1].i, yystack.l_mark[0].i, Q_DEFAULT); } break; case 34: -#line 442 "grammar.y" +#line 456 "grammar.y" { QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, yystack.l_mark[0].i); } break; case 35: -#line 443 "grammar.y" +#line 457 "grammar.y" { QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, Q_PROTO); } break; case 36: -#line 444 "grammar.y" +#line 458 "grammar.y" { QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, Q_PROTOCHAIN); } break; case 37: -#line 445 "grammar.y" +#line 459 "grammar.y" { QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, yystack.l_mark[0].i); } break; case 38: -#line 447 "grammar.y" +#line 461 "grammar.y" { yyval.blk = yystack.l_mark[0].blk; } break; case 39: -#line 448 "grammar.y" +#line 462 "grammar.y" { yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = yystack.l_mark[-2].blk.q; } break; case 40: -#line 449 "grammar.y" +#line 463 "grammar.y" { yyval.blk.b = gen_proto_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; } break; case 41: -#line 450 "grammar.y" +#line 464 "grammar.y" { yyval.blk.b = gen_relation(cstate, yystack.l_mark[-1].i, yystack.l_mark[-2].a, yystack.l_mark[0].a, 0); yyval.blk.q = qerr; } break; case 42: -#line 452 "grammar.y" +#line 466 "grammar.y" { yyval.blk.b = gen_relation(cstate, yystack.l_mark[-1].i, yystack.l_mark[-2].a, yystack.l_mark[0].a, 1); yyval.blk.q = qerr; } break; case 43: -#line 454 "grammar.y" +#line 468 "grammar.y" { yyval.blk.b = yystack.l_mark[0].rblk; yyval.blk.q = qerr; } break; case 44: -#line 455 "grammar.y" +#line 469 "grammar.y" { yyval.blk.b = gen_atmtype_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; } break; case 45: -#line 456 "grammar.y" +#line 470 "grammar.y" { yyval.blk.b = gen_atmmulti_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; } break; case 46: -#line 457 "grammar.y" +#line 471 "grammar.y" { yyval.blk.b = yystack.l_mark[0].blk.b; yyval.blk.q = qerr; } break; case 47: -#line 458 "grammar.y" +#line 472 "grammar.y" { yyval.blk.b = gen_mtp2type_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; } break; case 48: -#line 459 "grammar.y" +#line 473 "grammar.y" { yyval.blk.b = yystack.l_mark[0].blk.b; yyval.blk.q = qerr; } break; case 50: -#line 463 "grammar.y" +#line 477 "grammar.y" { yyval.i = Q_DEFAULT; } break; case 51: -#line 466 "grammar.y" +#line 480 "grammar.y" { yyval.i = Q_SRC; } break; case 52: -#line 467 "grammar.y" +#line 481 "grammar.y" { yyval.i = Q_DST; } break; case 53: -#line 468 "grammar.y" +#line 482 "grammar.y" { yyval.i = Q_OR; } break; case 54: -#line 469 "grammar.y" +#line 483 "grammar.y" { yyval.i = Q_OR; } break; case 55: -#line 470 "grammar.y" +#line 484 "grammar.y" { yyval.i = Q_AND; } break; case 56: -#line 471 "grammar.y" +#line 485 "grammar.y" { yyval.i = Q_AND; } break; case 57: -#line 472 "grammar.y" +#line 486 "grammar.y" { yyval.i = Q_ADDR1; } break; case 58: -#line 473 "grammar.y" +#line 487 "grammar.y" { yyval.i = Q_ADDR2; } break; case 59: -#line 474 "grammar.y" +#line 488 "grammar.y" { yyval.i = Q_ADDR3; } break; case 60: -#line 475 "grammar.y" +#line 489 "grammar.y" { yyval.i = Q_ADDR4; } break; case 61: -#line 476 "grammar.y" +#line 490 "grammar.y" { yyval.i = Q_RA; } break; case 62: -#line 477 "grammar.y" +#line 491 "grammar.y" { yyval.i = Q_TA; } break; case 63: -#line 480 "grammar.y" +#line 494 "grammar.y" { yyval.i = Q_HOST; } break; case 64: -#line 481 "grammar.y" +#line 495 "grammar.y" { yyval.i = Q_NET; } break; case 65: -#line 482 "grammar.y" +#line 496 "grammar.y" { yyval.i = Q_PORT; } break; case 66: -#line 483 "grammar.y" +#line 497 "grammar.y" { yyval.i = Q_PORTRANGE; } break; case 67: -#line 486 "grammar.y" +#line 500 "grammar.y" { yyval.i = Q_GATEWAY; } break; case 68: -#line 488 "grammar.y" +#line 502 "grammar.y" { yyval.i = Q_LINK; } break; case 69: -#line 489 "grammar.y" +#line 503 "grammar.y" { yyval.i = Q_IP; } break; case 70: -#line 490 "grammar.y" +#line 504 "grammar.y" { yyval.i = Q_ARP; } break; case 71: -#line 491 "grammar.y" +#line 505 "grammar.y" { yyval.i = Q_RARP; } break; case 72: -#line 492 "grammar.y" +#line 506 "grammar.y" { yyval.i = Q_SCTP; } break; case 73: -#line 493 "grammar.y" +#line 507 "grammar.y" { yyval.i = Q_TCP; } break; case 74: -#line 494 "grammar.y" +#line 508 "grammar.y" { yyval.i = Q_UDP; } break; case 75: -#line 495 "grammar.y" +#line 509 "grammar.y" { yyval.i = Q_ICMP; } break; case 76: -#line 496 "grammar.y" +#line 510 "grammar.y" { yyval.i = Q_IGMP; } break; case 77: -#line 497 "grammar.y" +#line 511 "grammar.y" { yyval.i = Q_IGRP; } break; case 78: -#line 498 "grammar.y" +#line 512 "grammar.y" { yyval.i = Q_PIM; } break; case 79: -#line 499 "grammar.y" +#line 513 "grammar.y" { yyval.i = Q_VRRP; } break; case 80: -#line 500 "grammar.y" +#line 514 "grammar.y" { yyval.i = Q_CARP; } break; case 81: -#line 501 "grammar.y" +#line 515 "grammar.y" { yyval.i = Q_ATALK; } break; case 82: -#line 502 "grammar.y" +#line 516 "grammar.y" { yyval.i = Q_AARP; } break; case 83: -#line 503 "grammar.y" +#line 517 "grammar.y" { yyval.i = Q_DECNET; } break; case 84: -#line 504 "grammar.y" +#line 518 "grammar.y" { yyval.i = Q_LAT; } break; case 85: -#line 505 "grammar.y" +#line 519 "grammar.y" { yyval.i = Q_SCA; } break; case 86: -#line 506 "grammar.y" +#line 520 "grammar.y" { yyval.i = Q_MOPDL; } break; case 87: -#line 507 "grammar.y" +#line 521 "grammar.y" { yyval.i = Q_MOPRC; } break; case 88: -#line 508 "grammar.y" +#line 522 "grammar.y" { yyval.i = Q_IPV6; } break; case 89: -#line 509 "grammar.y" +#line 523 "grammar.y" { yyval.i = Q_ICMPV6; } break; case 90: -#line 510 "grammar.y" +#line 524 "grammar.y" { yyval.i = Q_AH; } break; case 91: -#line 511 "grammar.y" +#line 525 "grammar.y" { yyval.i = Q_ESP; } break; case 92: -#line 512 "grammar.y" +#line 526 "grammar.y" { yyval.i = Q_ISO; } break; case 93: -#line 513 "grammar.y" +#line 527 "grammar.y" { yyval.i = Q_ESIS; } break; case 94: -#line 514 "grammar.y" +#line 528 "grammar.y" { yyval.i = Q_ISIS; } break; case 95: -#line 515 "grammar.y" +#line 529 "grammar.y" { yyval.i = Q_ISIS_L1; } break; case 96: -#line 516 "grammar.y" +#line 530 "grammar.y" { yyval.i = Q_ISIS_L2; } break; case 97: -#line 517 "grammar.y" +#line 531 "grammar.y" { yyval.i = Q_ISIS_IIH; } break; case 98: -#line 518 "grammar.y" +#line 532 "grammar.y" { yyval.i = Q_ISIS_LSP; } break; case 99: -#line 519 "grammar.y" +#line 533 "grammar.y" { yyval.i = Q_ISIS_SNP; } break; case 100: -#line 520 "grammar.y" +#line 534 "grammar.y" { yyval.i = Q_ISIS_PSNP; } break; case 101: -#line 521 "grammar.y" +#line 535 "grammar.y" { yyval.i = Q_ISIS_CSNP; } break; case 102: -#line 522 "grammar.y" +#line 536 "grammar.y" { yyval.i = Q_CLNP; } break; case 103: -#line 523 "grammar.y" +#line 537 "grammar.y" { yyval.i = Q_STP; } break; case 104: -#line 524 "grammar.y" +#line 538 "grammar.y" { yyval.i = Q_IPX; } break; case 105: -#line 525 "grammar.y" +#line 539 "grammar.y" { yyval.i = Q_NETBEUI; } break; case 106: -#line 526 "grammar.y" +#line 540 "grammar.y" { yyval.i = Q_RADIO; } break; case 107: -#line 528 "grammar.y" +#line 542 "grammar.y" { yyval.rblk = gen_broadcast(cstate, yystack.l_mark[-1].i); } break; case 108: -#line 529 "grammar.y" +#line 543 "grammar.y" { yyval.rblk = gen_multicast(cstate, yystack.l_mark[-1].i); } break; case 109: -#line 530 "grammar.y" +#line 544 "grammar.y" { yyval.rblk = gen_less(cstate, yystack.l_mark[0].i); } break; case 110: -#line 531 "grammar.y" +#line 545 "grammar.y" { yyval.rblk = gen_greater(cstate, yystack.l_mark[0].i); } break; case 111: -#line 532 "grammar.y" +#line 546 "grammar.y" { yyval.rblk = gen_byteop(cstate, yystack.l_mark[-1].i, yystack.l_mark[-2].i, yystack.l_mark[0].i); } break; case 112: -#line 533 "grammar.y" +#line 547 "grammar.y" { yyval.rblk = gen_inbound(cstate, 0); } break; case 113: -#line 534 "grammar.y" +#line 548 "grammar.y" { yyval.rblk = gen_inbound(cstate, 1); } break; case 114: -#line 535 "grammar.y" +#line 549 "grammar.y" { yyval.rblk = gen_vlan(cstate, yystack.l_mark[0].i); } break; case 115: -#line 536 "grammar.y" +#line 550 "grammar.y" { yyval.rblk = gen_vlan(cstate, -1); } break; case 116: -#line 537 "grammar.y" +#line 551 "grammar.y" { yyval.rblk = gen_mpls(cstate, yystack.l_mark[0].i); } break; case 117: -#line 538 "grammar.y" +#line 552 "grammar.y" { yyval.rblk = gen_mpls(cstate, -1); } break; case 118: -#line 539 "grammar.y" +#line 553 "grammar.y" { yyval.rblk = gen_pppoed(cstate); } break; case 119: -#line 540 "grammar.y" +#line 554 "grammar.y" { yyval.rblk = gen_pppoes(cstate, yystack.l_mark[0].i); } break; case 120: -#line 541 "grammar.y" +#line 555 "grammar.y" { yyval.rblk = gen_pppoes(cstate, -1); } break; case 121: -#line 542 "grammar.y" +#line 556 "grammar.y" { yyval.rblk = gen_geneve(cstate, yystack.l_mark[0].i); } break; case 122: -#line 543 "grammar.y" +#line 557 "grammar.y" { yyval.rblk = gen_geneve(cstate, -1); } break; case 123: -#line 544 "grammar.y" +#line 558 "grammar.y" { yyval.rblk = yystack.l_mark[0].rblk; } break; case 124: -#line 545 "grammar.y" +#line 559 "grammar.y" { yyval.rblk = yystack.l_mark[0].rblk; } break; case 125: -#line 546 "grammar.y" +#line 560 "grammar.y" { yyval.rblk = yystack.l_mark[0].rblk; } break; case 126: -#line 549 "grammar.y" +#line 563 "grammar.y" { yyval.rblk = gen_pf_ifname(cstate, yystack.l_mark[0].s); } break; case 127: -#line 550 "grammar.y" +#line 564 "grammar.y" { yyval.rblk = gen_pf_ruleset(cstate, yystack.l_mark[0].s); } break; case 128: -#line 551 "grammar.y" +#line 565 "grammar.y" { yyval.rblk = gen_pf_rnr(cstate, yystack.l_mark[0].i); } break; case 129: -#line 552 "grammar.y" +#line 566 "grammar.y" { yyval.rblk = gen_pf_srnr(cstate, yystack.l_mark[0].i); } break; case 130: -#line 553 "grammar.y" +#line 567 "grammar.y" { yyval.rblk = gen_pf_reason(cstate, yystack.l_mark[0].i); } break; case 131: -#line 554 "grammar.y" +#line 568 "grammar.y" { yyval.rblk = gen_pf_action(cstate, yystack.l_mark[0].i); } break; case 132: -#line 558 "grammar.y" +#line 572 "grammar.y" { yyval.rblk = gen_p80211_type(cstate, yystack.l_mark[-2].i | yystack.l_mark[0].i, IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK); } break; case 133: -#line 562 "grammar.y" +#line 576 "grammar.y" { yyval.rblk = gen_p80211_type(cstate, yystack.l_mark[0].i, IEEE80211_FC0_TYPE_MASK); } break; case 134: -#line 565 "grammar.y" +#line 579 "grammar.y" { yyval.rblk = gen_p80211_type(cstate, yystack.l_mark[0].i, IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK); } break; case 135: -#line 569 "grammar.y" +#line 583 "grammar.y" { yyval.rblk = gen_p80211_fcdir(cstate, yystack.l_mark[0].i); } break; case 137: -#line 573 "grammar.y" +#line 587 "grammar.y" { yyval.i = str2tok(yystack.l_mark[0].s, ieee80211_types); if (yyval.i == -1) bpf_error(cstate, "unknown 802.11 type name"); } break; case 139: -#line 580 "grammar.y" +#line 594 "grammar.y" { const struct tok *types = NULL; int i; for (i = 0;; i++) { @@ -2034,7 +2048,7 @@ case 139: } break; case 140: -#line 600 "grammar.y" +#line 614 "grammar.y" { int i; for (i = 0;; i++) { if (ieee80211_type_subtypes[i].tok == NULL) { @@ -2051,11 +2065,11 @@ case 140: } break; case 141: -#line 616 "grammar.y" +#line 630 "grammar.y" { yyval.rblk = gen_llc(cstate); } break; case 142: -#line 617 "grammar.y" +#line 631 "grammar.y" { if (pcap_strcasecmp(yystack.l_mark[0].s, "i") == 0) yyval.rblk = gen_llc_i(cstate); else if (pcap_strcasecmp(yystack.l_mark[0].s, "s") == 0) @@ -2078,11 +2092,11 @@ case 142: } break; case 143: -#line 638 "grammar.y" +#line 652 "grammar.y" { yyval.rblk = gen_llc_s_subtype(cstate, LLC_RNR); } break; case 145: -#line 642 "grammar.y" +#line 656 "grammar.y" { if (pcap_strcasecmp(yystack.l_mark[0].s, "nods") == 0) yyval.i = IEEE80211_FC1_DIR_NODS; else if (pcap_strcasecmp(yystack.l_mark[0].s, "tods") == 0) @@ -2096,195 +2110,195 @@ case 145: } break; case 146: -#line 655 "grammar.y" +#line 669 "grammar.y" { yyval.i = yystack.l_mark[0].i; } break; case 147: -#line 656 "grammar.y" +#line 670 "grammar.y" { yyval.i = pfreason_to_num(cstate, yystack.l_mark[0].s); } break; case 148: -#line 659 "grammar.y" +#line 673 "grammar.y" { yyval.i = pfaction_to_num(cstate, yystack.l_mark[0].s); } break; case 149: -#line 662 "grammar.y" +#line 676 "grammar.y" { yyval.i = BPF_JGT; } break; case 150: -#line 663 "grammar.y" +#line 677 "grammar.y" { yyval.i = BPF_JGE; } break; case 151: -#line 664 "grammar.y" +#line 678 "grammar.y" { yyval.i = BPF_JEQ; } break; case 152: -#line 666 "grammar.y" +#line 680 "grammar.y" { yyval.i = BPF_JGT; } break; case 153: -#line 667 "grammar.y" +#line 681 "grammar.y" { yyval.i = BPF_JGE; } break; case 154: -#line 668 "grammar.y" +#line 682 "grammar.y" { yyval.i = BPF_JEQ; } break; case 155: -#line 670 "grammar.y" +#line 684 "grammar.y" { yyval.a = gen_loadi(cstate, yystack.l_mark[0].i); } break; case 157: -#line 673 "grammar.y" +#line 687 "grammar.y" { yyval.a = gen_load(cstate, yystack.l_mark[-3].i, yystack.l_mark[-1].a, 1); } break; case 158: -#line 674 "grammar.y" +#line 688 "grammar.y" { yyval.a = gen_load(cstate, yystack.l_mark[-5].i, yystack.l_mark[-3].a, yystack.l_mark[-1].i); } break; case 159: -#line 675 "grammar.y" +#line 689 "grammar.y" { yyval.a = gen_arth(cstate, BPF_ADD, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 160: -#line 676 "grammar.y" +#line 690 "grammar.y" { yyval.a = gen_arth(cstate, BPF_SUB, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 161: -#line 677 "grammar.y" +#line 691 "grammar.y" { yyval.a = gen_arth(cstate, BPF_MUL, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 162: -#line 678 "grammar.y" +#line 692 "grammar.y" { yyval.a = gen_arth(cstate, BPF_DIV, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 163: -#line 679 "grammar.y" +#line 693 "grammar.y" { yyval.a = gen_arth(cstate, BPF_MOD, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 164: -#line 680 "grammar.y" +#line 694 "grammar.y" { yyval.a = gen_arth(cstate, BPF_AND, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 165: -#line 681 "grammar.y" +#line 695 "grammar.y" { yyval.a = gen_arth(cstate, BPF_OR, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 166: -#line 682 "grammar.y" +#line 696 "grammar.y" { yyval.a = gen_arth(cstate, BPF_XOR, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 167: -#line 683 "grammar.y" +#line 697 "grammar.y" { yyval.a = gen_arth(cstate, BPF_LSH, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 168: -#line 684 "grammar.y" +#line 698 "grammar.y" { yyval.a = gen_arth(cstate, BPF_RSH, yystack.l_mark[-2].a, yystack.l_mark[0].a); } break; case 169: -#line 685 "grammar.y" +#line 699 "grammar.y" { yyval.a = gen_neg(cstate, yystack.l_mark[0].a); } break; case 170: -#line 686 "grammar.y" +#line 700 "grammar.y" { yyval.a = yystack.l_mark[-1].a; } break; case 171: -#line 687 "grammar.y" +#line 701 "grammar.y" { yyval.a = gen_loadlen(cstate); } break; case 172: -#line 689 "grammar.y" +#line 703 "grammar.y" { yyval.i = '&'; } break; case 173: -#line 690 "grammar.y" +#line 704 "grammar.y" { yyval.i = '|'; } break; case 174: -#line 691 "grammar.y" +#line 705 "grammar.y" { yyval.i = '<'; } break; case 175: -#line 692 "grammar.y" +#line 706 "grammar.y" { yyval.i = '>'; } break; case 176: -#line 693 "grammar.y" +#line 707 "grammar.y" { yyval.i = '='; } break; case 178: -#line 696 "grammar.y" +#line 710 "grammar.y" { yyval.i = yystack.l_mark[-1].i; } break; case 179: -#line 698 "grammar.y" +#line 712 "grammar.y" { yyval.i = A_LANE; } break; case 180: -#line 699 "grammar.y" +#line 713 "grammar.y" { yyval.i = A_METAC; } break; case 181: -#line 700 "grammar.y" +#line 714 "grammar.y" { yyval.i = A_BCC; } break; case 182: -#line 701 "grammar.y" +#line 715 "grammar.y" { yyval.i = A_OAMF4EC; } break; case 183: -#line 702 "grammar.y" +#line 716 "grammar.y" { yyval.i = A_OAMF4SC; } break; case 184: -#line 703 "grammar.y" +#line 717 "grammar.y" { yyval.i = A_SC; } break; case 185: -#line 704 "grammar.y" +#line 718 "grammar.y" { yyval.i = A_ILMIC; } break; case 186: -#line 706 "grammar.y" +#line 720 "grammar.y" { yyval.i = A_OAM; } break; case 187: -#line 707 "grammar.y" +#line 721 "grammar.y" { yyval.i = A_OAMF4; } break; case 188: -#line 708 "grammar.y" +#line 722 "grammar.y" { yyval.i = A_CONNECTMSG; } break; case 189: -#line 709 "grammar.y" +#line 723 "grammar.y" { yyval.i = A_METACONNECT; } break; case 190: -#line 712 "grammar.y" +#line 726 "grammar.y" { yyval.blk.atmfieldtype = A_VPI; } break; case 191: -#line 713 "grammar.y" +#line 727 "grammar.y" { yyval.blk.atmfieldtype = A_VCI; } break; case 193: -#line 716 "grammar.y" +#line 730 "grammar.y" { yyval.blk.b = gen_atmfield_code(cstate, yystack.l_mark[-2].blk.atmfieldtype, (bpf_int32)yystack.l_mark[0].i, (bpf_u_int32)yystack.l_mark[-1].i, 0); } break; case 194: -#line 717 "grammar.y" +#line 731 "grammar.y" { yyval.blk.b = gen_atmfield_code(cstate, yystack.l_mark[-2].blk.atmfieldtype, (bpf_int32)yystack.l_mark[0].i, (bpf_u_int32)yystack.l_mark[-1].i, 1); } break; case 195: -#line 718 "grammar.y" +#line 732 "grammar.y" { yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = qerr; } break; case 196: -#line 720 "grammar.y" +#line 734 "grammar.y" { yyval.blk.atmfieldtype = yystack.l_mark[-1].blk.atmfieldtype; if (yyval.blk.atmfieldtype == A_VPI || @@ -2293,79 +2307,79 @@ case 196: } break; case 198: -#line 728 "grammar.y" +#line 742 "grammar.y" { gen_or(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; case 199: -#line 731 "grammar.y" +#line 745 "grammar.y" { yyval.i = M_FISU; } break; case 200: -#line 732 "grammar.y" +#line 746 "grammar.y" { yyval.i = M_LSSU; } break; case 201: -#line 733 "grammar.y" +#line 747 "grammar.y" { yyval.i = M_MSU; } break; case 202: -#line 734 "grammar.y" +#line 748 "grammar.y" { yyval.i = MH_FISU; } break; case 203: -#line 735 "grammar.y" +#line 749 "grammar.y" { yyval.i = MH_LSSU; } break; case 204: -#line 736 "grammar.y" +#line 750 "grammar.y" { yyval.i = MH_MSU; } break; case 205: -#line 739 "grammar.y" +#line 753 "grammar.y" { yyval.blk.mtp3fieldtype = M_SIO; } break; case 206: -#line 740 "grammar.y" +#line 754 "grammar.y" { yyval.blk.mtp3fieldtype = M_OPC; } break; case 207: -#line 741 "grammar.y" +#line 755 "grammar.y" { yyval.blk.mtp3fieldtype = M_DPC; } break; case 208: -#line 742 "grammar.y" +#line 756 "grammar.y" { yyval.blk.mtp3fieldtype = M_SLS; } break; case 209: -#line 743 "grammar.y" +#line 757 "grammar.y" { yyval.blk.mtp3fieldtype = MH_SIO; } break; case 210: -#line 744 "grammar.y" +#line 758 "grammar.y" { yyval.blk.mtp3fieldtype = MH_OPC; } break; case 211: -#line 745 "grammar.y" +#line 759 "grammar.y" { yyval.blk.mtp3fieldtype = MH_DPC; } break; case 212: -#line 746 "grammar.y" +#line 760 "grammar.y" { yyval.blk.mtp3fieldtype = MH_SLS; } break; case 214: -#line 749 "grammar.y" +#line 763 "grammar.y" { yyval.blk.b = gen_mtp3field_code(cstate, yystack.l_mark[-2].blk.mtp3fieldtype, (u_int)yystack.l_mark[0].i, (u_int)yystack.l_mark[-1].i, 0); } break; case 215: -#line 750 "grammar.y" +#line 764 "grammar.y" { yyval.blk.b = gen_mtp3field_code(cstate, yystack.l_mark[-2].blk.mtp3fieldtype, (u_int)yystack.l_mark[0].i, (u_int)yystack.l_mark[-1].i, 1); } break; case 216: -#line 751 "grammar.y" +#line 765 "grammar.y" { yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = qerr; } break; case 217: -#line 753 "grammar.y" +#line 767 "grammar.y" { yyval.blk.mtp3fieldtype = yystack.l_mark[-1].blk.mtp3fieldtype; if (yyval.blk.mtp3fieldtype == M_SIO || @@ -2380,10 +2394,10 @@ case 217: } break; case 219: -#line 767 "grammar.y" +#line 781 "grammar.y" { gen_or(yystack.l_mark[-2].blk.b, yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; } break; -#line 2387 "grammar.c" +#line 2401 "grammar.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/freebsd/contrib/libpcap/grammar.y b/freebsd/contrib/libpcap/grammar.y index ef6a7abb..be80e2bf 100644 --- a/freebsd/contrib/libpcap/grammar.y +++ b/freebsd/contrib/libpcap/grammar.y @@ -21,7 +21,7 @@ /* * And we need to pass the compiler state to the scanner. */ -%parse-param {compiler_state_t *cstate} +%parse-param { compiler_state_t *cstate } %{ /* @@ -44,23 +44,18 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $FreeBSD$ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif -#ifdef _WIN32 -#include <pcap-stdinc.h> -#else /* _WIN32 */ -#include <sys/types.h> -#include <sys/socket.h> -#endif /* _WIN32 */ - #include <stdlib.h> #ifndef _WIN32 +#include <sys/types.h> +#include <sys/socket.h> + #if __STDC__ struct mbuf; struct rtentry; @@ -72,6 +67,8 @@ struct rtentry; #include <stdio.h> +#include "diag-control.h" + #include "pcap-int.h" #include "gencode.h" @@ -80,7 +77,7 @@ struct rtentry; #ifdef HAVE_NET_PFVAR_H #include <net/if.h> -#include <netpfil/pf/pf.h> +#include <net/pfvar.h> #include <net/if_pflog.h> #endif #include "llc.h" @@ -91,9 +88,30 @@ struct rtentry; #include "os-proto.h" #endif -#define QSET(q, p, d, a) (q).proto = (p),\ - (q).dir = (d),\ - (q).addr = (a) +#ifdef YYBYACC +/* + * Both Berkeley YACC and Bison define yydebug (under whatever name + * it has) as a global, but Bison does so only if YYDEBUG is defined. + * Berkeley YACC define it even if YYDEBUG isn't defined; declare it + * here to suppress a warning. + */ +#if !defined(YYDEBUG) +extern int yydebug; +#endif + +/* + * In Berkeley YACC, yynerrs (under whatever name it has) is global, + * even if it's building a reentrant parser. In Bison, it's local + * in reentrant parsers. + * + * Declare it to squelch a warning. + */ +extern int yynerrs; +#endif + +#define QSET(q, p, d, a) (q).proto = (unsigned char)(p),\ + (q).dir = (unsigned char)(d),\ + (q).addr = (unsigned char)(a) struct tok { int v; /* value */ @@ -200,8 +218,8 @@ str2tok(const char *str, const struct tok *toks) static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF }; -static void -yyerror(void *yyscanner, compiler_state_t *cstate, const char *msg) +static PCAP_NORETURN_DEF void +yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg) { bpf_syntax_error(cstate, msg); /* NOTREACHED */ @@ -247,26 +265,22 @@ pfaction_to_num(compiler_state_t *cstate, const char *action) } } #else /* !HAVE_NET_PFVAR_H */ -static int -pfreason_to_num(compiler_state_t *cstate, const char *reason) +static PCAP_NORETURN_DEF int +pfreason_to_num(compiler_state_t *cstate, const char *reason _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /*NOTREACHED*/ - - /* this is to make the VC compiler happy */ - return -1; } -static int -pfaction_to_num(compiler_state_t *cstate, const char *action) +static PCAP_NORETURN_DEF int +pfaction_to_num(compiler_state_t *cstate, const char *action _U_) { bpf_error(cstate, "libpcap was compiled on a machine without pf support"); /*NOTREACHED*/ - - /* this is to make the VC compiler happy */ - return -1; } #endif /* HAVE_NET_PFVAR_H */ + +DIAG_OFF_BISON_BYACC %} %union { diff --git a/freebsd/contrib/libpcap/ieee80211.h b/freebsd/contrib/libpcap/ieee80211.h index 894a9e76..d79f0f8e 100644 --- a/freebsd/contrib/libpcap/ieee80211.h +++ b/freebsd/contrib/libpcap/ieee80211.h @@ -90,7 +90,7 @@ #define IEEE80211_FC1_RETRY 0x08 #define IEEE80211_FC1_PWR_MGT 0x10 #define IEEE80211_FC1_MORE_DATA 0x20 -#define IEEE80211_FC1_PROTECTED 0x40 +#define IEEE80211_FC1_WEP 0x40 #define IEEE80211_FC1_ORDER 0x80 #define IEEE80211_SEQ_FRAG_MASK 0x000f diff --git a/freebsd/contrib/libpcap/inet.c b/freebsd/contrib/libpcap/inet.c deleted file mode 100644 index 1945e4fc..00000000 --- a/freebsd/contrib/libpcap/inet.c +++ /dev/null @@ -1,409 +0,0 @@ -#include <machine/rtems-bsd-user-space.h> - -/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ -/* - * Copyright (c) 1994, 1995, 1996, 1997, 1998 - * 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 the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef _WIN32 -#include <pcap-stdinc.h> -#else /* _WIN32 */ - -#include <sys/param.h> -#ifndef MSDOS -#include <sys/file.h> -#endif -#include <sys/ioctl.h> -#include <sys/socket.h> -#ifdef HAVE_SYS_SOCKIO_H -#include <sys/sockio.h> -#endif - -struct mbuf; /* Squelch compiler warnings on some platforms for */ -struct rtentry; /* declarations in <net/if.h> */ -#include <net/if.h> -#include <netinet/in.h> -#endif /* _WIN32 */ - -#include <errno.h> -#include <memory.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#if !defined(_WIN32) && !defined(__BORLANDC__) -#include <unistd.h> -#endif /* !_WIN32 && !__BORLANDC__ */ - -#include "pcap-int.h" - -#ifdef HAVE_OS_PROTO_H -#include "os-proto.h" -#endif - -#if !defined(_WIN32) && !defined(MSDOS) - -/* - * Return the name of a network interface attached to the system, or NULL - * if none can be found. The interface must be configured up; the - * lowest unit number is preferred; loopback is ignored. - */ -char * -pcap_lookupdev(errbuf) - register char *errbuf; -{ - pcap_if_t *alldevs; -/* for old BSD systems, including bsdi3 */ -#ifndef IF_NAMESIZE -#define IF_NAMESIZE IFNAMSIZ -#endif - static char device[IF_NAMESIZE + 1]; - char *ret; - - if (pcap_findalldevs(&alldevs, errbuf) == -1) - return (NULL); - - if (alldevs == NULL || (alldevs->flags & PCAP_IF_LOOPBACK)) { - /* - * There are no devices on the list, or the first device - * on the list is a loopback device, which means there - * are no non-loopback devices on the list. This means - * we can't return any device. - * - * XXX - why not return a loopback device? If we can't - * capture on it, it won't be on the list, and if it's - * on the list, there aren't any non-loopback devices, - * so why not just supply it as the default device? - */ - (void)strlcpy(errbuf, "no suitable device found", - PCAP_ERRBUF_SIZE); - ret = NULL; - } else { - /* - * Return the name of the first device on the list. - */ - (void)strlcpy(device, alldevs->name, sizeof(device)); - ret = device; - } - - pcap_freealldevs(alldevs); - return (ret); -} - -int -pcap_lookupnet(device, netp, maskp, errbuf) - register const char *device; - register bpf_u_int32 *netp, *maskp; - register char *errbuf; -{ - register int fd; - register struct sockaddr_in *sin4; - struct ifreq ifr; - - /* - * The pseudo-device "any" listens on all interfaces and therefore - * has the network address and -mask "0.0.0.0" therefore catching - * all traffic. Using NULL for the interface is the same as "any". - */ - if (!device || strcmp(device, "any") == 0 -#ifdef HAVE_DAG_API - || strstr(device, "dag") != NULL -#endif -#ifdef HAVE_SEPTEL_API - || strstr(device, "septel") != NULL -#endif -#ifdef PCAP_SUPPORT_BT - || strstr(device, "bluetooth") != NULL -#endif -#ifdef PCAP_SUPPORT_USB - || strstr(device, "usbmon") != NULL -#endif -#ifdef PCAP_SUPPORT_NETMAP - || !strncmp(device, "netmap:", 7) - || !strncmp(device, "vale", 4) -#endif -#ifdef HAVE_SNF_API - || strstr(device, "snf") != NULL -#endif - ) { - *netp = *maskp = 0; - return 0; - } - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s", - pcap_strerror(errno)); - return (-1); - } - memset(&ifr, 0, sizeof(ifr)); -#ifdef linux - /* XXX Work around Linux kernel bug */ - ifr.ifr_addr.sa_family = AF_INET; -#endif - (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); - if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { - if (errno == EADDRNOTAVAIL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "%s: no IPv4 address assigned", device); - } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFADDR: %s: %s", - device, pcap_strerror(errno)); - } - (void)close(fd); - return (-1); - } - sin4 = (struct sockaddr_in *)&ifr.ifr_addr; - *netp = sin4->sin_addr.s_addr; - memset(&ifr, 0, sizeof(ifr)); -#ifdef linux - /* XXX Work around Linux kernel bug */ - ifr.ifr_addr.sa_family = AF_INET; -#endif - (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); - if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno)); - (void)close(fd); - return (-1); - } - (void)close(fd); - *maskp = sin4->sin_addr.s_addr; - if (*maskp == 0) { - if (IN_CLASSA(*netp)) - *maskp = IN_CLASSA_NET; - else if (IN_CLASSB(*netp)) - *maskp = IN_CLASSB_NET; - else if (IN_CLASSC(*netp)) - *maskp = IN_CLASSC_NET; - else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "inet class for 0x%x unknown", *netp); - return (-1); - } - } - *netp &= *maskp; - return (0); -} - -#elif defined(_WIN32) - -/* - * Return the name of a network interface attached to the system, or NULL - * if none can be found. The interface must be configured up; the - * lowest unit number is preferred; loopback is ignored. - * - * In the best of all possible worlds, this would be the same as on - * UN*X, but there may be software that expects this to return a - * full list of devices after the first device. - */ -#define ADAPTERSNAME_LEN 8192 -char * -pcap_lookupdev(errbuf) - register char *errbuf; -{ - DWORD dwVersion; - DWORD dwWindowsMajorVersion; - char our_errbuf[PCAP_ERRBUF_SIZE+1]; - -#pragma warning (push) -#pragma warning (disable: 4996) /* disable MSVC's GetVersion() deprecated warning here */ - dwVersion = GetVersion(); /* get the OS version */ -#pragma warning (pop) - dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); - - if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) { - /* - * Windows 95, 98, ME. - */ - ULONG NameLength = ADAPTERSNAME_LEN; - static char AdaptersName[ADAPTERSNAME_LEN]; - - if (PacketGetAdapterNames(AdaptersName,&NameLength) ) - return (AdaptersName); - else - return NULL; - } else { - /* - * Windows NT (NT 4.0 and later). - * Convert the names to Unicode for backward compatibility. - */ - ULONG NameLength = ADAPTERSNAME_LEN; - static WCHAR AdaptersName[ADAPTERSNAME_LEN]; - size_t BufferSpaceLeft; - char *tAstr; - WCHAR *Unameptr; - char *Adescptr; - size_t namelen, i; - WCHAR *TAdaptersName = (WCHAR*)malloc(ADAPTERSNAME_LEN * sizeof(WCHAR)); - int NAdapts = 0; - - if(TAdaptersName == NULL) - { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "memory allocation failure"); - return NULL; - } - - if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) ) - { - pcap_win32_err_to_str(GetLastError(), our_errbuf); - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "PacketGetAdapterNames: %s", our_errbuf); - free(TAdaptersName); - return NULL; - } - - - BufferSpaceLeft = ADAPTERSNAME_LEN * sizeof(WCHAR); - tAstr = (char*)TAdaptersName; - Unameptr = AdaptersName; - - /* - * Convert the device names to Unicode into AdapterName. - */ - do { - /* - * Length of the name, including the terminating - * NUL. - */ - namelen = strlen(tAstr) + 1; - - /* - * Do we have room for the name in the Unicode - * buffer? - */ - if (BufferSpaceLeft < namelen * sizeof(WCHAR)) { - /* - * No. - */ - goto quit; - } - BufferSpaceLeft -= namelen * sizeof(WCHAR); - - /* - * Copy the name, converting ASCII to Unicode. - * namelen includes the NUL, so we copy it as - * well. - */ - for (i = 0; i < namelen; i++) - *Unameptr++ = *tAstr++; - - /* - * Count this adapter. - */ - NAdapts++; - } while (namelen != 1); - - /* - * Copy the descriptions, but don't convert them from - * ASCII to Unicode. - */ - Adescptr = (char *)Unameptr; - while(NAdapts--) - { - size_t desclen; - - desclen = strlen(tAstr) + 1; - - /* - * Do we have room for the name in the Unicode - * buffer? - */ - if (BufferSpaceLeft < desclen) { - /* - * No. - */ - goto quit; - } - - /* - * Just copy the ASCII string. - * namelen includes the NUL, so we copy it as - * well. - */ - memcpy(Adescptr, tAstr, desclen); - Adescptr += desclen; - tAstr += desclen; - BufferSpaceLeft -= desclen; - } - - quit: - free(TAdaptersName); - return (char *)(AdaptersName); - } -} - - -int -pcap_lookupnet(device, netp, maskp, errbuf) - register const char *device; - register bpf_u_int32 *netp, *maskp; - register char *errbuf; -{ - /* - * We need only the first IPv4 address, so we must scan the array returned by PacketGetNetInfo() - * in order to skip non IPv4 (i.e. IPv6 addresses) - */ - npf_if_addr if_addrs[MAX_NETWORK_ADDRESSES]; - LONG if_addr_size = 1; - struct sockaddr_in *t_addr; - unsigned int i; - - if (!PacketGetNetInfoEx((void *)device, if_addrs, &if_addr_size)) { - *netp = *maskp = 0; - return (0); - } - - for(i=0; i<MAX_NETWORK_ADDRESSES; i++) - { - if(if_addrs[i].IPAddress.ss_family == AF_INET) - { - t_addr = (struct sockaddr_in *) &(if_addrs[i].IPAddress); - *netp = t_addr->sin_addr.S_un.S_addr; - t_addr = (struct sockaddr_in *) &(if_addrs[i].SubnetMask); - *maskp = t_addr->sin_addr.S_un.S_addr; - - *netp &= *maskp; - return (0); - } - - } - - *netp = *maskp = 0; - return (0); -} - -#endif /* !_WIN32 && !MSDOS */ diff --git a/freebsd/contrib/libpcap/nametoaddr.c b/freebsd/contrib/libpcap/nametoaddr.c index 7ef8f4cc..1d47ff9d 100644 --- a/freebsd/contrib/libpcap/nametoaddr.c +++ b/freebsd/contrib/libpcap/nametoaddr.c @@ -22,12 +22,10 @@ * * Name to id translation routines used by the scanner. * These functions are not time critical. - * - * $FreeBSD$ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #ifdef DECNETLIB @@ -36,62 +34,99 @@ #endif #ifdef _WIN32 -#include <pcap-stdinc.h> - -#ifdef INET6 -/* - * 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." - * - * We use getaddrinfo(), so we include Wspiapi.h here. pcap-stdinc.h - * includes Ws2tcpip.h, so we don't need to include it ourselves. - */ -#include <Wspiapi.h> -#endif - + #include <winsock2.h> + #include <ws2tcpip.h> + + #ifdef INET6 + /* + * 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." + * + * We use getaddrinfo(), so we include Wspiapi.h here. + */ + #include <wspiapi.h> + #endif /* INET6 */ #else /* _WIN32 */ - -#include <sys/param.h> -#include <sys/types.h> /* concession to AIX */ -#include <sys/socket.h> -#include <sys/time.h> - -#include <netinet/in.h> -#endif /* _WIN32 */ - -#ifndef _WIN32 -#ifdef HAVE_ETHER_HOSTTON -/* - * XXX - do we need any of this if <netinet/if_ether.h> doesn't declare - * ether_hostton()? - */ -#ifdef HAVE_NETINET_IF_ETHER_H -struct mbuf; /* Squelch compiler warnings on some platforms for */ -struct rtentry; /* declarations in <net/if.h> */ -#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */ -#include <netinet/if_ether.h> -#endif /* HAVE_NETINET_IF_ETHER_H */ -#ifdef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON -#include <netinet/ether.h> -#endif /* NETINET_ETHER_H_DECLARES_ETHER_HOSTTON */ -#endif /* HAVE_ETHER_HOSTTON */ -#include <arpa/inet.h> -#include <netdb.h> + #include <sys/param.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/time.h> + + #include <netinet/in.h> + + #ifdef HAVE_ETHER_HOSTTON + #if defined(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON) + /* + * OK, just include <net/ethernet.h>. + */ + #include <net/ethernet.h> + #elif defined(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON) + /* + * OK, just include <netinet/ether.h> + */ + #include <netinet/ether.h> + #elif defined(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON) + /* + * OK, just include <sys/ethernet.h> + */ + #include <sys/ethernet.h> + #elif defined(ARPA_INET_H_DECLARES_ETHER_HOSTTON) + /* + * OK, just include <arpa/inet.h> + */ + #include <arpa/inet.h> + #elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON) + /* + * OK, include <netinet/if_ether.h>, after all the other stuff we + * need to include or define for its benefit. + */ + #define NEED_NETINET_IF_ETHER_H + #else + /* + * We'll have to declare it ourselves. + * If <netinet/if_ether.h> defines struct ether_addr, include + * it. Otherwise, define it ourselves. + */ + #ifdef HAVE_STRUCT_ETHER_ADDR + #define NEED_NETINET_IF_ETHER_H + #else /* HAVE_STRUCT_ETHER_ADDR */ + struct ether_addr { + unsigned char ether_addr_octet[6]; + }; + #endif /* HAVE_STRUCT_ETHER_ADDR */ + #endif /* what declares ether_hostton() */ + + #ifdef NEED_NETINET_IF_ETHER_H + #include <net/if.h> /* Needed on some platforms */ + #include <netinet/in.h> /* Needed on some platforms */ + #include <netinet/if_ether.h> + #endif /* NEED_NETINET_IF_ETHER_H */ + + #ifndef HAVE_DECL_ETHER_HOSTTON + /* + * No header declares it, so declare it ourselves. + */ + extern int ether_hostton(const char *, struct ether_addr *); + #endif /* !defined(HAVE_DECL_ETHER_HOSTTON) */ + #endif /* HAVE_ETHER_HOSTTON */ + + #include <arpa/inet.h> + #include <netdb.h> #endif /* _WIN32 */ #include <ctype.h> @@ -115,11 +150,10 @@ struct rtentry; /* declarations in <net/if.h> */ #define NTOHS(x) (x) = ntohs(x) #endif -static inline int xdtoi(int); - /* * Convert host name to internet address. * Return 0 upon failure. + * XXX - not thread-safe; don't use it inside libpcap. */ bpf_u_int32 ** pcap_nametoaddr(const char *name) @@ -145,7 +179,6 @@ pcap_nametoaddr(const char *name) return 0; } -#ifdef INET6 struct addrinfo * pcap_nametoaddrinfo(const char *name) { @@ -162,23 +195,17 @@ pcap_nametoaddrinfo(const char *name) else return res; } -#endif /*INET6*/ /* * Convert net name to internet address. * Return 0 upon failure. + * XXX - not guaranteed to be thread-safe! See below for platforms + * on which it is thread-safe and on which it isn't. */ bpf_u_int32 pcap_nametonetaddr(const char *name) { -#ifndef _WIN32 - struct netent *np; - - if ((np = getnetbyname(name)) != NULL) - return np->n_net; - else - return 0; -#else +#ifdef _WIN32 /* * There's no "getnetbyname()" on Windows. * @@ -192,7 +219,66 @@ pcap_nametonetaddr(const char *name) * of *UN*X* machines.) */ return 0; -#endif +#else + /* + * UN*X. + */ + struct netent *np; + #if defined(HAVE_LINUX_GETNETBYNAME_R) + /* + * We have Linux's reentrant getnetbyname_r(). + */ + struct netent result_buf; + char buf[1024]; /* arbitrary size */ + int h_errnoval; + int err; + + err = getnetbyname_r(name, &result_buf, buf, sizeof buf, &np, + &h_errnoval); + if (err != 0) { + /* + * XXX - dynamically allocate the buffer, and make it + * bigger if we get ERANGE back? + */ + return 0; + } + #elif defined(HAVE_SOLARIS_IRIX_GETNETBYNAME_R) + /* + * We have Solaris's and IRIX's reentrant getnetbyname_r(). + */ + struct netent result_buf; + char buf[1024]; /* arbitrary size */ + + np = getnetbyname_r(name, &result_buf, buf, (int)sizeof buf); + #elif defined(HAVE_AIX_GETNETBYNAME_R) + /* + * We have AIX's reentrant getnetbyname_r(). + */ + struct netent result_buf; + struct netent_data net_data; + + if (getnetbyname_r(name, &result_buf, &net_data) == -1) + np = NULL; + else + np = &result_buf; + #else + /* + * We don't have any getnetbyname_r(); either we have a + * getnetbyname() that uses thread-specific data, in which + * case we're thread-safe (sufficiently recent FreeBSD, + * sufficiently recent Darwin-based OS, sufficiently recent + * HP-UX, sufficiently recent Tru64 UNIX), or we have the + * traditional getnetbyname() (everything else, including + * current NetBSD and OpenBSD), in which case we're not + * thread-safe. + */ + np = getnetbyname(name); + #endif + if (np != NULL) + return np->n_net; + else + return 0; +#endif /* _WIN32 */ } /* @@ -203,20 +289,111 @@ pcap_nametonetaddr(const char *name) int pcap_nametoport(const char *name, int *port, int *proto) { - struct servent *sp; + struct addrinfo hints, *res, *ai; + int error; + struct sockaddr_in *in4; +#ifdef INET6 + struct sockaddr_in6 *in6; +#endif int tcp_port = -1; int udp_port = -1; /* + * We check for both TCP and UDP in case there are + * ambiguous entries. + */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + error = getaddrinfo(NULL, name, &hints, &res); + if (error != 0) { + if (error != EAI_NONAME) { + /* + * This is a real error, not just "there's + * no such service name". + * XXX - this doesn't return an error string. + */ + return 0; + } + } else { + /* + * OK, we found it. Did it find anything? + */ + for (ai = res; ai != NULL; ai = ai->ai_next) { + /* + * Does it have an address? + */ + if (ai->ai_addr != NULL) { + /* + * Yes. Get a port number; we're done. + */ + if (ai->ai_addr->sa_family == AF_INET) { + in4 = (struct sockaddr_in *)ai->ai_addr; + tcp_port = ntohs(in4->sin_port); + break; + } +#ifdef INET6 + if (ai->ai_addr->sa_family == AF_INET6) { + in6 = (struct sockaddr_in6 *)ai->ai_addr; + tcp_port = ntohs(in6->sin6_port); + break; + } +#endif + } + } + freeaddrinfo(res); + } + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + error = getaddrinfo(NULL, name, &hints, &res); + if (error != 0) { + if (error != EAI_NONAME) { + /* + * This is a real error, not just "there's + * no such service name". + * XXX - this doesn't return an error string. + */ + return 0; + } + } else { + /* + * OK, we found it. Did it find anything? + */ + for (ai = res; ai != NULL; ai = ai->ai_next) { + /* + * Does it have an address? + */ + if (ai->ai_addr != NULL) { + /* + * Yes. Get a port number; we're done. + */ + if (ai->ai_addr->sa_family == AF_INET) { + in4 = (struct sockaddr_in *)ai->ai_addr; + udp_port = ntohs(in4->sin_port); + break; + } +#ifdef INET6 + if (ai->ai_addr->sa_family == AF_INET6) { + in6 = (struct sockaddr_in6 *)ai->ai_addr; + udp_port = ntohs(in6->sin6_port); + break; + } +#endif + } + } + freeaddrinfo(res); + } + + /* * We need to check /etc/services for ambiguous entries. - * If we find the ambiguous entry, and it has the + * If we find an ambiguous entry, and it has the * same port number, change the proto to PROTO_UNDEF * so both TCP and UDP will be checked. */ - sp = getservbyname(name, "tcp"); - if (sp != NULL) tcp_port = ntohs(sp->s_port); - sp = getservbyname(name, "udp"); - if (sp != NULL) udp_port = ntohs(sp->s_port); if (tcp_port >= 0) { *port = tcp_port; *proto = IPPROTO_TCP; @@ -295,12 +472,62 @@ pcap_nametoportrange(const char *name, int *port1, int *port2, int *proto) return 1; } +/* + * XXX - not guaranteed to be thread-safe! See below for platforms + * on which it is thread-safe and on which it isn't. + */ int pcap_nametoproto(const char *str) { struct protoent *p; + #if defined(HAVE_LINUX_GETNETBYNAME_R) + /* + * We have Linux's reentrant getprotobyname_r(). + */ + struct protoent result_buf; + char buf[1024]; /* arbitrary size */ + int err; + + err = getprotobyname_r(str, &result_buf, buf, sizeof buf, &p); + if (err != 0) { + /* + * XXX - dynamically allocate the buffer, and make it + * bigger if we get ERANGE back? + */ + return 0; + } + #elif defined(HAVE_SOLARIS_IRIX_GETNETBYNAME_R) + /* + * We have Solaris's and IRIX's reentrant getprotobyname_r(). + */ + struct protoent result_buf; + char buf[1024]; /* arbitrary size */ + + p = getprotobyname_r(str, &result_buf, buf, (int)sizeof buf); + #elif defined(HAVE_AIX_GETNETBYNAME_R) + /* + * We have AIX's reentrant getprotobyname_r(). + */ + struct protoent result_buf; + struct protoent_data proto_data; + if (getprotobyname_r(str, &result_buf, &proto_data) == -1) + p = NULL; + else + p = &result_buf; + #else + /* + * We don't have any getprotobyname_r(); either we have a + * getprotobyname() that uses thread-specific data, in which + * case we're thread-safe (sufficiently recent FreeBSD, + * sufficiently recent Darwin-based OS, sufficiently recent + * HP-UX, sufficiently recent Tru64 UNIX, Windows), or we have + * the traditional getprotobyname() (everything else, including + * current NetBSD and OpenBSD), in which case we're not + * thread-safe. + */ p = getprotobyname(str); + #endif if (p != 0) return p->p_proto; else @@ -320,18 +547,14 @@ struct eproto { * Debian, at least, so make it a public symbol, even though we * don't officially export it by declaring it in a header file. * (Programs *should* do this themselves, as tcpdump now does.) + * + * We declare it here, right before defining it, to squelch any + * warnings we might get from compilers about the lack of a + * declaration. */ +PCAP_API struct eproto eproto_db[]; PCAP_API_DEF struct eproto eproto_db[] = { -#if 0 - /* The FreeBSD elf linker generates a request to copy this array - * (including its size) when you link with -lpcap. In order to - * not bump the major version number of this libpcap.so, we need - * to ensure that the array stays the same size. Since PUP is - * likely never seen in real life any more, it's the first to - * be sacrificed (in favor of ip6). - */ { "pup", ETHERTYPE_PUP }, -#endif { "xns", ETHERTYPE_NS }, { "ip", ETHERTYPE_IP }, #ifdef INET6 @@ -393,17 +616,16 @@ pcap_nametollc(const char *s) return PROTO_UNDEF; } -/* Hex digit to integer. */ -static inline int -xdtoi(c) - register int c; +/* Hex digit to 8-bit unsigned integer. */ +static inline u_char +xdtoi(u_char c) { if (isdigit(c)) - return c - '0'; + return (u_char)(c - '0'); else if (islower(c)) - return c - 'a' + 10; + return (u_char)(c - 'a' + 10); else - return c - 'A' + 10; + return (u_char)(c - 'A' + 10); } int @@ -414,7 +636,7 @@ __pcap_atoin(const char *s, bpf_u_int32 *addr) *addr = 0; len = 0; - while (1) { + for (;;) { n = 0; while (*s && *s != '.') n = n * 10 + *s++ - '0'; @@ -462,7 +684,7 @@ u_char * pcap_ether_aton(const char *s) { register u_char *ep, *e; - register u_int d; + register u_char d; e = ep = (u_char *)malloc(6); if (e == NULL) @@ -483,7 +705,11 @@ pcap_ether_aton(const char *s) } #ifndef HAVE_ETHER_HOSTTON -/* Roll our own */ +/* + * Roll our own. + * XXX - not thread-safe, because pcap_next_etherent() isn't thread- + * safe! Needs a mutex or a thread-safe pcap_next_etherent(). + */ u_char * pcap_ether_hostton(const char *name) { @@ -515,17 +741,10 @@ pcap_ether_hostton(const char *name) return (NULL); } #else - -#if !defined(HAVE_DECL_ETHER_HOSTTON) || !HAVE_DECL_ETHER_HOSTTON -#ifndef HAVE_STRUCT_ETHER_ADDR -struct ether_addr { - unsigned char ether_addr_octet[6]; -}; -#endif -extern int ether_hostton(const char *, struct ether_addr *); -#endif - -/* Use the os supplied routines */ +/* + * Use the OS-supplied routine. + * This *should* be thread-safe; the API doesn't have a static buffer. + */ u_char * pcap_ether_hostton(const char *name) { @@ -542,10 +761,13 @@ pcap_ether_hostton(const char *name) } #endif +/* + * XXX - not guaranteed to be thread-safe! + */ int +#ifdef DECNETLIB __pcap_nametodnaddr(const char *name, u_short *res) { -#ifdef DECNETLIB struct nodeent *getnodebyname(); struct nodeent *nep; @@ -556,6 +778,8 @@ __pcap_nametodnaddr(const char *name, u_short *res) memcpy((char *)res, (char *)nep->n_addr, sizeof(unsigned short)); return(1); #else +__pcap_nametodnaddr(const char *name _U_, u_short *res _U_) +{ return(0); #endif } diff --git a/freebsd/contrib/libpcap/optimize.c b/freebsd/contrib/libpcap/optimize.c index b861082d..7d2a1826 100644 --- a/freebsd/contrib/libpcap/optimize.c +++ b/freebsd/contrib/libpcap/optimize.c @@ -20,26 +20,14 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * Optimization module for tcpdump intermediate representation. + * Optimization module for BPF code intermediate representation. */ #ifdef HAVE_CONFIG_H -#include "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 <pcap-types.h> #include <stdio.h> #include <stdlib.h> @@ -51,39 +39,149 @@ #include "pcap-int.h" #include "gencode.h" +#include "optimize.h" #ifdef HAVE_OS_PROTO_H #include "os-proto.h" #endif #ifdef BDEBUG -int pcap_optimizer_debug; -#endif +/* + * The internal "debug printout" flag for the filter expression optimizer. + * The code to print that stuff is present only if BDEBUG is defined, so + * the flag, and the routine to set it, are defined only if BDEBUG is + * defined. + */ +static int pcap_optimizer_debug; -#if defined(MSDOS) && !defined(__DJGPP__) -extern int _w32_ffs (int mask); -#define ffs _w32_ffs -#endif +/* + * Routine to set that flag. + * + * This is intended for libpcap developers, not for general use. + * If you want to set these in a program, you'll have to declare this + * routine yourself, with the appropriate DLL import attribute on Windows; + * it's not declared in any header file, and won't be declared in any + * header file provided by libpcap. + */ +PCAP_API void pcap_set_optimizer_debug(int value); + +PCAP_API_DEF void +pcap_set_optimizer_debug(int value) +{ + pcap_optimizer_debug = value; +} + +/* + * The internal "print dot graph" flag for the filter expression optimizer. + * The code to print that stuff is present only if BDEBUG is defined, so + * the flag, and the routine to set it, are defined only if BDEBUG is + * defined. + */ +static int pcap_print_dot_graph; /* - * So is the check for _MSC_VER done because MinGW has this? + * Routine to set that flag. + * + * This is intended for libpcap developers, not for general use. + * If you want to set these in a program, you'll have to declare this + * routine yourself, with the appropriate DLL import attribute on Windows; + * it's not declared in any header file, and won't be declared in any + * header file provided by libpcap. */ -#if defined(_WIN32) && defined (_MSC_VER) +PCAP_API void pcap_set_print_dot_graph(int value); + +PCAP_API_DEF void +pcap_set_print_dot_graph(int value) +{ + pcap_print_dot_graph = value; +} + +#endif + /* - * ffs -- vax ffs instruction + * lowest_set_bit(). + * + * Takes a 32-bit integer as an argument. * - * XXX - with versions of VS that have it, use _BitScanForward()? + * If handed a non-zero value, returns the index of the lowest set bit, + * counting upwards fro zero. + * + * If handed zero, the results are platform- and compiler-dependent. + * Keep it out of the light, don't give it any water, don't feed it + * after midnight, and don't pass zero to it. + * + * This is the same as the count of trailing zeroes in the word. + */ +#if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) + /* + * GCC 3.4 and later; we have __builtin_ctz(). + */ + #define lowest_set_bit(mask) __builtin_ctz(mask) +#elif defined(_MSC_VER) + /* + * Visual Studio; we support only 2005 and later, so use + * _BitScanForward(). + */ +#include <intrin.h> + +#ifndef __clang__ +#pragma intrinsic(_BitScanForward) +#endif + +static __forceinline int +lowest_set_bit(int mask) +{ + unsigned long bit; + + /* + * Don't sign-extend mask if long is longer than int. + * (It's currently not, in MSVC, even on 64-bit platforms, but....) + */ + if (_BitScanForward(&bit, (unsigned int)mask) == 0) + return -1; /* mask is zero */ + return (int)bit; +} +#elif defined(MSDOS) && defined(__DJGPP__) + /* + * MS-DOS with DJGPP, which declares ffs() in <string.h>, which + * we've already included. + */ + #define lowest_set_bit(mask) (ffs((mask)) - 1) +#elif (defined(MSDOS) && defined(__WATCOMC__)) || defined(STRINGS_H_DECLARES_FFS) + /* + * MS-DOS with Watcom C, which has <strings.h> and declares ffs() there, + * or some other platform (UN*X conforming to a sufficient recent version + * of the Single UNIX Specification). + */ + #include <strings.h> + #define lowest_set_bit(mask) (ffs((mask)) - 1) +#else +/* + * None of the above. + * Use a perfect-hash-function-based function. */ static int -ffs(int mask) +lowest_set_bit(int mask) { - int bit; + unsigned int v = (unsigned int)mask; + + static const int MultiplyDeBruijnBitPosition[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 + }; - if (mask == 0) - return(0); - for (bit = 1; !(mask & 1); bit++) - mask >>= 1; - return(bit); + /* + * We strip off all but the lowermost set bit (v & ~v), + * and perform a minimal perfect hash on it to look up the + * number of low-order zero bits in a table. + * + * See: + * + * http://7ooo.mooo.com/text/ComputingTrailingZerosHOWTO.pdf + * + * http://supertech.csail.mit.edu/papers/debruijn.pdf + */ + return (MultiplyDeBruijnBitPosition[((v & -v) * 0x077CB531U) >> 27]); } #endif @@ -129,7 +227,7 @@ struct vmapinfo { bpf_int32 const_val; }; -struct _opt_state { +typedef struct { /* * A flag to indicate that further optimization is needed. * Iterative passes are continued until a given pass yields no @@ -212,7 +310,7 @@ struct _opt_state { struct vmapinfo *vmap; struct valnode *vnode_base; struct valnode *next_vnode; -}; +} opt_state_t; typedef struct { /* @@ -292,7 +390,7 @@ find_dom(opt_state_t *opt_state, struct block *root) x = opt_state->all_dom_sets; i = opt_state->n_blocks * opt_state->nodewords; while (--i >= 0) - *x++ = ~0; + *x++ = 0xFFFFFFFFU; /* Root starts off empty. */ for (i = opt_state->nodewords; --i >= 0;) root->dom[i] = 0; @@ -332,7 +430,7 @@ find_edom(opt_state_t *opt_state, struct block *root) x = opt_state->all_edge_sets; for (i = opt_state->n_edges * opt_state->edgewords; --i >= 0; ) - x[i] = ~0; + x[i] = 0xFFFFFFFFU; /* root->level is the highest level no found. */ memset(root->et.edom, 0, opt_state->edgewords * sizeof(*(uset)0)); @@ -592,7 +690,7 @@ F(opt_state_t *opt_state, int code, int v0, int v1) static inline void vstore(struct stmt *s, int *valp, int newval, int alter) { - if (alter && *valp == newval) + if (alter && newval != VAL_UNKNOWN && *valp == newval) s->code = NOP; else *valp = newval; @@ -603,7 +701,7 @@ vstore(struct stmt *s, int *valp, int newval, int alter) * (Unary operators are handled elsewhere.) */ static void -fold_op(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, +fold_op(compiler_state_t *cstate, opt_state_t *opt_state, struct stmt *s, int v0, int v1) { bpf_u_int32 a, b; @@ -945,7 +1043,7 @@ opt_peep(opt_state_t *opt_state, struct block *b) * evaluation and code transformations weren't folded together. */ static void -opt_stmt(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, +opt_stmt(compiler_state_t *cstate, opt_state_t *opt_state, struct stmt *s, int val[], int alter) { int op; @@ -1034,7 +1132,7 @@ opt_stmt(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, } } if (opt_state->vmap[val[A_ATOM]].is_const) { - fold_op(cstate, ic, opt_state, s, val[A_ATOM], K(s->k)); + fold_op(cstate, opt_state, s, val[A_ATOM], K(s->k)); val[A_ATOM] = K(s->k); break; } @@ -1055,7 +1153,7 @@ opt_stmt(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, op = BPF_OP(s->code); if (alter && opt_state->vmap[val[X_ATOM]].is_const) { if (opt_state->vmap[val[A_ATOM]].is_const) { - fold_op(cstate, ic, opt_state, s, val[A_ATOM], val[X_ATOM]); + fold_op(cstate, opt_state, s, val[A_ATOM], val[X_ATOM]); val[A_ATOM] = K(s->k); } else { @@ -1179,7 +1277,7 @@ opt_deadstores(opt_state_t *opt_state, register struct block *b) } static void -opt_blk(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, +opt_blk(compiler_state_t *cstate, opt_state_t *opt_state, struct block *b, int do_stmts) { struct slist *s; @@ -1230,7 +1328,7 @@ opt_blk(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, aval = b->val[A_ATOM]; xval = b->val[X_ATOM]; for (s = b->stmts; s; s = s->next) - opt_stmt(cstate, ic, opt_state, &s->s, b->val, do_stmts); + opt_stmt(cstate, opt_state, &s->s, b->val, do_stmts); /* * This is a special case: if we don't use anything from this @@ -1256,8 +1354,9 @@ opt_blk(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state, * block, can we eliminate it? */ if (do_stmts && - ((b->out_use == 0 && aval != 0 && b->val[A_ATOM] == aval && - xval != 0 && b->val[X_ATOM] == xval) || + ((b->out_use == 0 && + aval != VAL_UNKNOWN && b->val[A_ATOM] == aval && + xval != VAL_UNKNOWN && b->val[X_ATOM] == xval) || BPF_CLASS(b->s.code) == BPF_RET)) { if (b->stmts != 0) { b->stmts = 0; @@ -1382,7 +1481,7 @@ opt_j(opt_state_t *opt_state, struct edge *ep) register bpf_u_int32 x = ep->edom[i]; while (x != 0) { - k = ffs(x) - 1; + k = lowest_set_bit(x); x &=~ (1 << k); k += i * BITS_PER_WORD; @@ -1433,7 +1532,7 @@ or_pullup(opt_state_t *opt_state, struct block *b) diffp = &JF(b->in_edges->pred); at_top = 1; - while (1) { + for (;;) { if (*diffp == 0) return; @@ -1450,7 +1549,7 @@ or_pullup(opt_state_t *opt_state, struct block *b) at_top = 0; } samep = &JF(*diffp); - while (1) { + for (;;) { if (*samep == 0) return; @@ -1524,7 +1623,7 @@ and_pullup(opt_state_t *opt_state, struct block *b) diffp = &JF(b->in_edges->pred); at_top = 1; - while (1) { + for (;;) { if (*diffp == 0) return; @@ -1541,7 +1640,7 @@ and_pullup(opt_state_t *opt_state, struct block *b) at_top = 0; } samep = &JT(*diffp); - while (1) { + for (;;) { if (*samep == 0) return; @@ -1602,7 +1701,7 @@ opt_blks(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic, find_inedges(opt_state, ic->root); for (i = maxlevel; i >= 0; --i) for (p = opt_state->levels[i]; p; p = p->link) - opt_blk(cstate, ic, opt_state, p, do_stmts); + opt_blk(cstate, opt_state, p, do_stmts); if (do_stmts) /* @@ -1685,7 +1784,7 @@ opt_loop(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic, { #ifdef BDEBUG - if (pcap_optimizer_debug > 1) { + if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) { printf("opt_loop(root, %d) begin\n", do_stmts); opt_dump(cstate, ic); } @@ -1699,7 +1798,7 @@ opt_loop(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic, find_edom(opt_state, ic->root); opt_blks(cstate, opt_state, ic, do_stmts); #ifdef BDEBUG - if (pcap_optimizer_debug > 1) { + if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) { printf("opt_loop(root, %d) bottom, done=%d\n", do_stmts, opt_state->done); opt_dump(cstate, ic); } @@ -1720,14 +1819,14 @@ bpf_optimize(compiler_state_t *cstate, struct icode *ic) opt_loop(cstate, &opt_state, ic, 1); intern_blocks(&opt_state, ic); #ifdef BDEBUG - if (pcap_optimizer_debug > 1) { + if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) { printf("after intern_blocks()\n"); opt_dump(cstate, ic); } #endif opt_root(&ic->root); #ifdef BDEBUG - if (pcap_optimizer_debug > 1) { + if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) { printf("after opt_root()\n"); opt_dump(cstate, ic); } @@ -1765,7 +1864,7 @@ mark_code(struct icode *ic) static int eq_slist(struct slist *x, struct slist *y) { - while (1) { + for (;;) { while (x && x->s.code == NOP) x = x->next; while (y && y->s.code == NOP) @@ -2015,7 +2114,7 @@ opt_init(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic) * and expect it to provide meaningful information. */ #ifdef BDEBUG -int bids[1000]; +int bids[NBIDS]; #endif /* @@ -2032,7 +2131,7 @@ convert_code_r(compiler_state_t *cstate, conv_state_t *conv_state, struct slist *src; u_int slen; u_int off; - int extrajmps; /* number of extra jumps inserted */ + u_int extrajmps; /* number of extra jumps inserted */ struct slist **offset = NULL; if (p == 0 || isMarked(ic, p)) @@ -2090,7 +2189,7 @@ convert_code_r(compiler_state_t *cstate, conv_state_t *conv_state, { u_int i; int jt, jf; - const char *ljerr = "%s for block-local relative jump: off=%d"; + const char ljerr[] = "%s for block-local relative jump: off=%d"; #if 0 printf("code=%x off=%d %x %x\n", src->s.code, @@ -2110,7 +2209,11 @@ convert_code_r(compiler_state_t *cstate, conv_state_t *conv_state, /*NOTREACHED*/ } - dst->jt = i - off - 1; + if (i - off - 1 >= 256) { + bpf_error(cstate, ljerr, "out-of-range jump", off); + /*NOTREACHED*/ + } + dst->jt = (u_char)(i - off - 1); jt++; } if (offset[i] == src->s.jf) { @@ -2118,7 +2221,11 @@ convert_code_r(compiler_state_t *cstate, conv_state_t *conv_state, bpf_error(cstate, ljerr, "multiple matches", off); /*NOTREACHED*/ } - dst->jf = i - off - 1; + if (i - off - 1 >= 256) { + bpf_error(cstate, ljerr, "out-of-range jump", off); + /*NOTREACHED*/ + } + dst->jf = (u_char)(i - off - 1); jf++; } } @@ -2135,7 +2242,8 @@ filled: free(offset); #ifdef BDEBUG - bids[dst - conv_state->fstart] = p->id + 1; + if (dst - conv_state->fstart < NBIDS) + bids[dst - conv_state->fstart] = p->id + 1; #endif dst->code = (u_short)p->s.code; dst->k = p->s.k; @@ -2150,13 +2258,17 @@ filled: return(0); } /* branch if T to following jump */ - dst->jt = extrajmps; + if (extrajmps >= 256) { + bpf_error(cstate, "too many extra jumps"); + /*NOTREACHED*/ + } + dst->jt = (u_char)extrajmps; extrajmps++; dst[extrajmps].code = BPF_JMP|BPF_JA; dst[extrajmps].k = off - extrajmps; } else - dst->jt = off; + dst->jt = (u_char)off; off = JF(p)->offset - (p->offset + slen) - 1; if (off >= 256) { /* offset too large for branch, must add a jump */ @@ -2167,13 +2279,17 @@ filled: } /* branch if F to following jump */ /* if two jumps are inserted, F goes to second one */ - dst->jf = extrajmps; + if (extrajmps >= 256) { + bpf_error(cstate, "too many extra jumps"); + /*NOTREACHED*/ + } + dst->jf = (u_char)extrajmps; extrajmps++; dst[extrajmps].code = BPF_JMP|BPF_JA; dst[extrajmps].k = off - extrajmps; } else - dst->jf = off; + dst->jf = (u_char)off; } return (1); } @@ -2209,7 +2325,7 @@ icode_to_fcode(compiler_state_t *cstate, struct icode *ic, * Loop doing convert_code_r() until no branches remain * with too-large offsets. */ - while (1) { + for (;;) { unMarkAll(ic); n = *lenp = count_stmts(ic, root); @@ -2260,8 +2376,8 @@ install_bpf_program(pcap_t *p, struct bpf_program *fp) p->fcode.bf_len = fp->bf_len; p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size); if (p->fcode.bf_insns == NULL) { - pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "malloc"); return (-1); } memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size); @@ -2289,7 +2405,7 @@ dot_dump_node(struct icode *ic, struct block *block, struct bpf_program *prog, } fprintf(out, "\" tooltip=\""); for (i = 0; i < BPF_MEMWORDS; i++) - if (block->val[i] != 0) + if (block->val[i] != VAL_UNKNOWN) fprintf(out, "val[%d]=%d ", i, block->val[i]); fprintf(out, "val[A]=%d ", block->val[A_ATOM]); fprintf(out, "val[X]=%d", block->val[X_ATOM]); @@ -2348,10 +2464,8 @@ dot_dump(compiler_state_t *cstate, struct icode *ic) f.bf_insns = icode_to_fcode(cstate, ic, ic->root, &f.bf_len); fprintf(out, "digraph BPF {\n"); - ic->cur_mark = 0; unMarkAll(ic); dot_dump_node(ic, ic->root, &f, out); - ic->cur_mark = 0; unMarkAll(ic); dot_dump_edge(ic, ic->root, out); fprintf(out, "}\n"); @@ -2374,11 +2488,11 @@ plain_dump(compiler_state_t *cstate, struct icode *ic) static void opt_dump(compiler_state_t *cstate, struct icode *ic) { - /* if optimizer debugging is enabled, output DOT graph - * `pcap_optimizer_debug=4' is equivalent to -dddd to follow -d/-dd/-ddd - * convention in tcpdump command line + /* + * If the CFG, in DOT format, is requested, output it rather than + * the code that would be generated from that graph. */ - if (pcap_optimizer_debug > 3) + if (pcap_print_dot_graph) dot_dump(cstate, ic); else plain_dump(cstate, ic); diff --git a/freebsd/contrib/libpcap/optimize.h b/freebsd/contrib/libpcap/optimize.h new file mode 100644 index 00000000..56b31f40 --- /dev/null +++ b/freebsd/contrib/libpcap/optimize.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 + * 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. + */ + +/* + * Some stuff for use when debugging the optimizer. + */ +#ifdef BDEBUG +#define NBIDS 1000 +extern int bids[NBIDS]; +#endif diff --git a/freebsd/contrib/libpcap/pcap-bpf.c b/freebsd/contrib/libpcap/pcap-bpf.c index 60111cf5..dc2942af 100644 --- a/freebsd/contrib/libpcap/pcap-bpf.c +++ b/freebsd/contrib/libpcap/pcap-bpf.c @@ -19,25 +19,20 @@ * 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 HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <sys/param.h> /* optionally get BSD define */ -#ifdef HAVE_ZEROCOPY_BPF -#include <sys/mman.h> -#endif #include <sys/socket.h> #include <time.h> /* * <net/bpf.h> defines ioctls, but doesn't include <sys/ioccom.h>. * * We include <sys/ioctl.h> as it might be necessary to declare ioctl(); - * at least on *BSD and Mac OS X, it also defines various SIOC ioctls - + * at least on *BSD and macOS, it also defines various SIOC ioctls - * we could include <sys/sockio.h>, but if we're already including * <sys/ioctl.h>, which includes <sys/sockio.h> on those platforms, * there's not much point in doing so. @@ -61,10 +56,6 @@ static const char usbus_prefix[] = "usbus"; #include <dirent.h> #endif -#ifdef HAVE_ZEROCOPY_BPF -#include <machine/atomic.h> -#endif - #include <net/if.h> #ifdef _AIX @@ -86,6 +77,16 @@ static const char usbus_prefix[] = "usbus"; #include <net/bpf.h> #define _AIX +/* + * If both BIOCROTZBUF and BPF_BUFMODE_ZBUF are defined, we have + * zero-copy BPF. + */ +#if defined(BIOCROTZBUF) && defined(BPF_BUFMODE_ZBUF) + #define HAVE_ZEROCOPY_BPF + #include <sys/mman.h> + #include <machine/atomic.h> +#endif + #include <net/if_types.h> /* for IFT_ values */ #include <sys/sysconfig.h> #include <sys/device.h> @@ -125,7 +126,7 @@ static int bpf_load(char *errbuf); #include <string.h> #include <unistd.h> -#ifdef HAVE_NET_IF_MEDIA_H +#ifdef SIOCGIFMEDIA # include <net/if_media.h> #endif @@ -228,8 +229,9 @@ static void remove_802_11(pcap_t *); #endif /* - * On OS X, we don't even get any of the 802.11-plus-radio-header DLT_'s - * defined, even though some of them are used by various Airport drivers. + * In some versions of macOS, we might not even get any of the + * 802.11-plus-radio-header DLT_'s defined, even though some + * of them are used by various Airport drivers in those versions. */ #ifndef DLT_PRISM_HEADER #define DLT_PRISM_HEADER 119 @@ -256,7 +258,7 @@ static int pcap_set_datalink_bpf(pcap_t *p, int dlt); * blocking mode. */ static int -pcap_getnonblock_bpf(pcap_t *p, char *errbuf) +pcap_getnonblock_bpf(pcap_t *p) { #ifdef HAVE_ZEROCOPY_BPF struct pcap_bpf *pb = p->priv; @@ -264,11 +266,11 @@ pcap_getnonblock_bpf(pcap_t *p, char *errbuf) if (pb->zerocopy) return (pb->nonblock); #endif - return (pcap_getnonblock_fd(p, errbuf)); + return (pcap_getnonblock_fd(p)); } static int -pcap_setnonblock_bpf(pcap_t *p, int nonblock, char *errbuf) +pcap_setnonblock_bpf(pcap_t *p, int nonblock) { #ifdef HAVE_ZEROCOPY_BPF struct pcap_bpf *pb = p->priv; @@ -278,7 +280,7 @@ pcap_setnonblock_bpf(pcap_t *p, int nonblock, char *errbuf) return (0); } #endif - return (pcap_setnonblock_fd(p, nonblock, errbuf)); + return (pcap_setnonblock_fd(p, nonblock)); } #ifdef HAVE_ZEROCOPY_BPF @@ -369,8 +371,8 @@ pcap_next_zbuf(pcap_t *p, int *cc) if (data) return (data); if (ioctl(p->fd, BIOCROTZBUF, &bz) < 0) { - (void) pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCROTZBUF: %s", strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, "BIOCROTZBUF"); return (PCAP_ERROR); } return (pcap_next_zbuf_shm(p, cc)); @@ -397,8 +399,8 @@ pcap_next_zbuf(pcap_t *p, int *cc) } return (0); } else if (r < 0) { - (void) pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "select: %s", strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "select"); return (PCAP_ERROR); } } @@ -416,8 +418,8 @@ pcap_next_zbuf(pcap_t *p, int *cc) * data. */ if (ioctl(p->fd, BIOCROTZBUF, &bz) < 0) { - (void) pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCROTZBUF: %s", strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCROTZBUF"); return (PCAP_ERROR); } return (pcap_next_zbuf_shm(p, cc)); @@ -459,8 +461,8 @@ pcap_create_interface(const char *device _U_, char *ebuf) p->tstamp_precision_count = 2; p->tstamp_precision_list = malloc(2 * sizeof(u_int)); if (p->tstamp_precision_list == NULL) { - snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, + "malloc"); free(p); return (NULL); } @@ -477,13 +479,11 @@ pcap_create_interface(const char *device _U_, char *ebuf) static int bpf_open(char *errbuf) { - int fd; -#ifdef HAVE_CLONING_BPF - static const char device[] = "/dev/bpf"; -#else + int fd = -1; + static const char cloning_device[] = "/dev/bpf"; int n = 0; char device[sizeof "/dev/bpf0000000000"]; -#endif + static int no_cloning_bpf = 0; #ifdef _AIX /* @@ -495,40 +495,55 @@ bpf_open(char *errbuf) return (PCAP_ERROR); #endif -#ifdef HAVE_CLONING_BPF - if ((fd = open(device, O_RDWR)) == -1 && - (errno != EACCES || (fd = open(device, O_RDONLY)) == -1)) { - if (errno == EACCES) - fd = PCAP_ERROR_PERM_DENIED; - else - fd = PCAP_ERROR; - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "(cannot open device) %s: %s", device, pcap_strerror(errno)); - } -#else /* - * Go through all the minors and find one that isn't in use. + * First, unless we've already tried opening /dev/bpf and + * gotten ENOENT, try opening /dev/bpf. + * If it fails with ENOENT, remember that, so we don't try + * again, and try /dev/bpfN. */ - do { - (void)pcap_snprintf(device, sizeof(device), "/dev/bpf%d", n++); + if (!no_cloning_bpf && + (fd = open(cloning_device, O_RDWR)) == -1 && + ((errno != EACCES && errno != ENOENT) || + (fd = open(cloning_device, O_RDONLY)) == -1)) { + if (errno != ENOENT) { + if (errno == EACCES) + fd = PCAP_ERROR_PERM_DENIED; + else + fd = PCAP_ERROR; + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "(cannot open device) %s", cloning_device); + return (fd); + } + no_cloning_bpf = 1; + } + + if (no_cloning_bpf) { /* - * Initially try a read/write open (to allow the inject - * method to work). If that fails due to permission - * issues, fall back to read-only. This allows a - * non-root user to be granted specific access to pcap - * capabilities via file permissions. - * - * XXX - we should have an API that has a flag that - * controls whether to open read-only or read-write, - * so that denial of permission to send (or inability - * to send, if sending packets isn't supported on - * the device in question) can be indicated at open - * time. + * We don't have /dev/bpf. + * Go through all the /dev/bpfN minors and find one + * that isn't in use. */ - fd = open(device, O_RDWR); - if (fd == -1 && errno == EACCES) - fd = open(device, O_RDONLY); - } while (fd < 0 && errno == EBUSY); + do { + (void)pcap_snprintf(device, sizeof(device), "/dev/bpf%d", n++); + /* + * Initially try a read/write open (to allow the inject + * method to work). If that fails due to permission + * issues, fall back to read-only. This allows a + * non-root user to be granted specific access to pcap + * capabilities via file permissions. + * + * XXX - we should have an API that has a flag that + * controls whether to open read-only or read-write, + * so that denial of permission to send (or inability + * to send, if sending packets isn't supported on + * the device in question) can be indicated at open + * time. + */ + fd = open(device, O_RDWR); + if (fd == -1 && errno == EACCES) + fd = open(device, O_RDONLY); + } while (fd < 0 && errno == EBUSY); + } /* * XXX better message for all minors used @@ -565,9 +580,8 @@ bpf_open(char *errbuf) * if any. */ fd = PCAP_ERROR_PERM_DENIED; - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "(cannot open BPF device) %s: %s", device, - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "(cannot open BPF device) %s", device); break; default: @@ -575,13 +589,11 @@ bpf_open(char *errbuf) * Some other problem. */ fd = PCAP_ERROR; - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "(cannot open BPF device) %s: %s", device, - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "(cannot open BPF device) %s", device); break; } } -#endif return (fd); } @@ -633,8 +645,8 @@ bpf_open_and_bind(const char *name, char *errbuf) return (PCAP_ERROR_IFACE_NOT_UP); default: - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "BIOCSETIF: %s: %s", name, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETIF: %s", name); close(fd); return (PCAP_ERROR); } @@ -657,14 +669,14 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf) bdlp->bfl_list = (u_int *) malloc(sizeof(u_int) * (bdlp->bfl_len + 1)); if (bdlp->bfl_list == NULL) { - (void)pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); return (PCAP_ERROR); } if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) < 0) { - (void)pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, - "BIOCGDLTLIST: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "BIOCGDLTLIST"); free(bdlp->bfl_list); return (PCAP_ERROR); } @@ -718,8 +730,8 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf) * this device"; don't treat it as an error. */ if (errno != EINVAL) { - (void)pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, - "BIOCGDLTLIST: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "BIOCGDLTLIST"); return (PCAP_ERROR); } } @@ -739,7 +751,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p) #endif /* - * The joys of monitor mode on OS X. + * The joys of monitor mode on Mac OS X/OS X/macOS. * * Prior to 10.4, it's not supported at all. * @@ -785,8 +797,8 @@ pcap_can_set_rfmon_bpf(pcap_t *p) } fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) { - (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "socket: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "socket"); return (PCAP_ERROR); } strlcpy(ifr.ifr_name, "wlt", sizeof(ifr.ifr_name)); @@ -840,9 +852,8 @@ pcap_can_set_rfmon_bpf(pcap_t *p) return (PCAP_ERROR_IFACE_NOT_UP); default: - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCSETIF: %s: %s", - p->opt.device, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETIF: %s", p->opt.device); close(fd); return (PCAP_ERROR); } @@ -904,8 +915,8 @@ pcap_stats_bpf(pcap_t *p, struct pcap_stat *ps) * by libpcap, and thus not yet seen by the application. */ if (ioctl(p->fd, BIOCGSTATS, (caddr_t)&s) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGSTATS: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCGSTATS"); return (PCAP_ERROR); } @@ -1032,8 +1043,8 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* fall through */ #endif } - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "read"); return (PCAP_ERROR); } bp = (u_char *)p->buffer; @@ -1186,13 +1197,13 @@ pcap_inject_bpf(pcap_t *p, const void *buf, size_t size) #ifdef __APPLE__ if (ret == -1 && errno == EAFNOSUPPORT) { /* - * In Mac OS X, there's a bug wherein setting the - * BIOCSHDRCMPLT flag causes writes to fail; see, - * for example: + * In some versions of macOS, there's a bug wherein setting + * the BIOCSHDRCMPLT flag causes writes to fail; see, for + * example: * * http://cerberus.sourcefire.com/~jeff/archives/patches/macosx/BIOCSHDRCMPLT-10.3.3.patch * - * So, if, on OS X, we get EAFNOSUPPORT from the write, we + * So, if, on macOS, we get EAFNOSUPPORT from the write, we * assume it's due to that bug, and turn off that flag * and try again. If we succeed, it either means that * somebody applied the fix from that URL, or other patches @@ -1201,14 +1212,13 @@ pcap_inject_bpf(pcap_t *p, const void *buf, size_t size) * http://cerberus.sourcefire.com/~jeff/archives/patches/macosx/ * * and are running a Darwin kernel with those fixes, or - * that Apple fixed the problem in some OS X release. + * that Apple fixed the problem in some macOS release. */ u_int spoof_eth_src = 0; if (ioctl(p->fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1) { - (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "send: can't turn off BIOCSHDRCMPLT: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "send: can't turn off BIOCSHDRCMPLT"); return (PCAP_ERROR); } @@ -1219,8 +1229,8 @@ pcap_inject_bpf(pcap_t *p, const void *buf, size_t size) } #endif /* __APPLE__ */ if (ret == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "send"); return (PCAP_ERROR); } return (ret); @@ -1308,8 +1318,8 @@ bpf_load(char *errbuf) major = genmajor(BPF_NAME); if (major == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bpf_load: genmajor failed: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "bpf_load: genmajor failed"); (void)bpf_odmcleanup(NULL); return (PCAP_ERROR); } @@ -1318,9 +1328,8 @@ bpf_load(char *errbuf) if (!minors) { minors = genminor("bpf", major, 0, BPF_MINORS, 1, 1); if (!minors) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bpf_load: genminor failed: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "bpf_load: genminor failed"); (void)bpf_odmcleanup(NULL); return (PCAP_ERROR); } @@ -1331,20 +1340,19 @@ bpf_load(char *errbuf) rc = stat(BPF_NODE "0", &sbuf); if (rc == -1 && errno != ENOENT) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bpf_load: can't stat %s: %s", - BPF_NODE "0", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "bpf_load: can't stat %s", BPF_NODE "0"); return (PCAP_ERROR); } if (rc == -1 || getmajor(sbuf.st_rdev) != major) { for (i = 0; i < BPF_MINORS; i++) { - sprintf(buf, "%s%d", BPF_NODE, i); + pcap_snprintf(buf, sizeof(buf), "%s%d", BPF_NODE, i); unlink(buf); if (mknod(buf, S_IRUSR | S_IFCHR, domakedev(major, i)) == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bpf_load: can't mknod %s: %s", - buf, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "bpf_load: can't mknod %s", buf); return (PCAP_ERROR); } } @@ -1353,14 +1361,13 @@ bpf_load(char *errbuf) /* Check if the driver is loaded */ memset(&cfg_ld, 0x0, sizeof(cfg_ld)); cfg_ld.path = buf; - sprintf(cfg_ld.path, "%s/%s", DRIVER_PATH, BPF_NAME); + pcap_snprintf(cfg_ld.path, sizeof(cfg_ld.path), "%s/%s", DRIVER_PATH, BPF_NAME); if ((sysconfig(SYS_QUERYLOAD, (void *)&cfg_ld, sizeof(cfg_ld)) == -1) || (cfg_ld.kmid == 0)) { /* Driver isn't loaded, load it now */ if (sysconfig(SYS_SINGLELOAD, (void *)&cfg_ld, sizeof(cfg_ld)) == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bpf_load: could not load driver: %s", - strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "bpf_load: could not load driver"); return (PCAP_ERROR); } } @@ -1373,9 +1380,8 @@ bpf_load(char *errbuf) for (i = 0; i < BPF_MINORS; i++) { cfg_bpf.devno = domakedev(major, i); if (sysconfig(SYS_CFGKMOD, (void *)&cfg_km, sizeof(cfg_km)) == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "bpf_load: could not configure driver: %s", - strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "bpf_load: could not configure driver"); return (PCAP_ERROR); } } @@ -1495,7 +1501,6 @@ pcap_cleanup_bpf(pcap_t *p) if (pb->zbuf2 != MAP_FAILED && pb->zbuf2 != NULL) (void) munmap(pb->zbuf2, pb->zbufsize); p->buffer = NULL; - p->buffer = NULL; } #endif if (pb->device != NULL) { @@ -1540,9 +1545,10 @@ check_setif_failure(pcap_t *p, int error) * exist. */ err = PCAP_ERROR_NO_SUCH_DEVICE; - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFFLAGS on %s failed: %s", - ifr.ifr_name, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGIFFLAGS on %s failed", + ifr.ifr_name); } else { /* * The underlying "enN" device @@ -1564,9 +1570,9 @@ check_setif_failure(pcap_t *p, int error) * just report "no such device". */ err = PCAP_ERROR_NO_SUCH_DEVICE; - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "socket() failed: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + errno, PCAP_ERRBUF_SIZE, + "socket() failed"); } return (err); } @@ -1574,8 +1580,8 @@ check_setif_failure(pcap_t *p, int error) /* * No such device. */ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF failed: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETIF failed"); return (PCAP_ERROR_NO_SUCH_DEVICE); } else if (errno == ENETDOWN) { /* @@ -1591,8 +1597,8 @@ check_setif_failure(pcap_t *p, int error) * Some other error; fill in the error string, and * return PCAP_ERROR. */ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s", - p->opt.device, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETIF: %s", p->opt.device); return (PCAP_ERROR); } } @@ -1649,15 +1655,6 @@ pcap_activate_bpf(pcap_t *p) struct bpf_insn total_insn; struct bpf_program total_prog; struct utsname osinfo; - -#ifdef HAVE_DAG_API - if (strstr(device, "dag")) { - return dag_open_live(device, snaplen, promisc, to_ms, ebuf); - } -#endif /* HAVE_DAG_API */ - -#ifdef BIOCGDLTLIST - memset(&bdl, 0, sizeof(bdl)); int have_osinfo = 0; #ifdef HAVE_ZEROCOPY_BPF struct bpf_zbuf bz; @@ -1673,8 +1670,8 @@ pcap_activate_bpf(pcap_t *p) p->fd = fd; if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCVERSION: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCVERSION"); status = PCAP_ERROR; goto bad; } @@ -1686,13 +1683,24 @@ pcap_activate_bpf(pcap_t *p) goto bad; } + /* + * Turn a negative snapshot value (invalid), a snapshot value of + * 0 (unspecified), or a value bigger than the normal maximum + * value, into the maximum allowed value. + * + * If some application really *needs* a bigger snapshot + * length, we should just increase MAXIMUM_SNAPLEN. + */ + if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN) + p->snapshot = MAXIMUM_SNAPLEN; + #if defined(LIFNAMSIZ) && defined(ZONENAME_MAX) && defined(lifr_zoneid) /* * Retrieve the zoneid of the zone we are currently executing in. */ if ((ifr.lifr_zoneid = getzoneid()) == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "getzoneid(): %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "getzoneid()"); status = PCAP_ERROR; goto bad; } @@ -1718,16 +1726,15 @@ pcap_activate_bpf(pcap_t *p) (void) strlcpy(path_zname, p->opt.device, znamelen + 1); ifr.lifr_zoneid = getzoneidbyname(path_zname); if (ifr.lifr_zoneid == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "getzoneidbyname(%s): %s", path_zname, - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "getzoneidbyname(%s)", path_zname); status = PCAP_ERROR; goto bad; } lnamep = strdup(zonesep + 1); if (lnamep == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "strdup"); status = PCAP_ERROR; goto bad; } @@ -1738,20 +1745,13 @@ pcap_activate_bpf(pcap_t *p) pb->device = strdup(p->opt.device); if (pb->device == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "strdup"); status = PCAP_ERROR; goto bad; } /* - * Try finding a good size for the buffer; 32768 may be too - * big, so keep cutting it in half until we find a size - * that works, or run out of sizes to try. If the default - * is larger, don't make it smaller. - * - * XXX - there should be a user-accessible hook to set the - * initial buffer size. * Attempt to find out the version of the OS on which we're running. */ if (uname(&osinfo) == 0) @@ -1800,10 +1800,10 @@ pcap_activate_bpf(pcap_t *p) * exist. */ status = PCAP_ERROR_NO_SUCH_DEVICE; - pcap_snprintf(p->errbuf, + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFFLAGS failed: %s", - pcap_strerror(errno)); + errno, + "SIOCGIFFLAGS failed"); } else status = PCAP_ERROR_RFMON_NOTSUP; close(sockfd); @@ -1814,18 +1814,17 @@ pcap_activate_bpf(pcap_t *p) * report "no such device". */ status = PCAP_ERROR_NO_SUCH_DEVICE; - pcap_snprintf(p->errbuf, - PCAP_ERRBUF_SIZE, - "socket() failed: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "socket() failed"); } goto bad; } wltdev = malloc(strlen(p->opt.device) + 2); if (wltdev == NULL) { - (void)pcap_snprintf(p->errbuf, - PCAP_ERRBUF_SIZE, "malloc: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "malloc"); status = PCAP_ERROR; goto bad; } @@ -1865,9 +1864,9 @@ pcap_activate_bpf(pcap_t *p) */ s = socket(AF_LOCAL, SOCK_DGRAM, 0); if (s < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "Can't open socket: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "Can't open socket"); status = PCAP_ERROR; goto bad; } @@ -1898,9 +1897,10 @@ pcap_activate_bpf(pcap_t *p) "Invalid USB bus interface %s", p->opt.device); } else { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "Can't create interface for %s: %s", - p->opt.device, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "Can't create interface for %s", + p->opt.device); } close(s); status = PCAP_ERROR; @@ -1943,8 +1943,8 @@ pcap_activate_bpf(pcap_t *p) * size. */ if (ioctl(fd, BIOCGETZMAX, (caddr_t)&zbufmax) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGETZMAX: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCGETZMAX"); status = PCAP_ERROR; goto bad; } @@ -1970,8 +1970,8 @@ pcap_activate_bpf(pcap_t *p) pb->zbuf2 = mmap(NULL, pb->zbufsize, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (pb->zbuf1 == MAP_FAILED || pb->zbuf2 == MAP_FAILED) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "mmap: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "mmap"); status = PCAP_ERROR; goto bad; } @@ -1980,15 +1980,15 @@ pcap_activate_bpf(pcap_t *p) bz.bz_bufb = pb->zbuf2; bz.bz_buflen = pb->zbufsize; if (ioctl(fd, BIOCSETZBUF, (caddr_t)&bz) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETZBUF: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETZBUF"); status = PCAP_ERROR; goto bad; } (void)strncpy(ifrname, p->opt.device, ifnamsiz); if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s", - p->opt.device, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETIF: %s", p->opt.device); status = PCAP_ERROR; goto bad; } @@ -2006,9 +2006,9 @@ pcap_activate_bpf(pcap_t *p) */ if (ioctl(fd, BIOCSBLEN, (caddr_t)&p->opt.buffer_size) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCSBLEN: %s: %s", p->opt.device, - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "BIOCSBLEN: %s", p->opt.device); status = PCAP_ERROR; goto bad; } @@ -2072,12 +2072,11 @@ pcap_activate_bpf(pcap_t *p) } } } -#endif /* Get the data link layer type. */ if (ioctl(fd, BIOCGDLT, (caddr_t)&v) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGDLT: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCGDLT"); status = PCAP_ERROR; goto bad; } @@ -2321,8 +2320,8 @@ pcap_activate_bpf(pcap_t *p) * BSDs - check CVS log for "bpf.c"? */ if (ioctl(fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1) { - (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCSHDRCMPLT: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSHDRCMPLT"); status = PCAP_ERROR; goto bad; } @@ -2363,8 +2362,8 @@ pcap_activate_bpf(pcap_t *p) bpf_to.tv_sec = p->opt.timeout / 1000; bpf_to.tv_usec = (p->opt.timeout * 1000) % 1000000; if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&bpf_to) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCSRTIMEOUT: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + errno, PCAP_ERRBUF_SIZE, "BIOCSRTIMEOUT"); status = PCAP_ERROR; goto bad; } @@ -2373,8 +2372,8 @@ pcap_activate_bpf(pcap_t *p) to.tv_sec = p->opt.timeout / 1000; to.tv_usec = (p->opt.timeout * 1000) % 1000000; if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCSRTIMEOUT: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + errno, PCAP_ERRBUF_SIZE, "BIOCSRTIMEOUT"); status = PCAP_ERROR; goto bad; } @@ -2408,8 +2407,8 @@ pcap_activate_bpf(pcap_t *p) #endif /* _AIX */ v = 1; if (ioctl(p->fd, BIOCIMMEDIATE, &v) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCIMMEDIATE: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCIMMEDIATE"); status = PCAP_ERROR; goto bad; } @@ -2430,8 +2429,8 @@ pcap_activate_bpf(pcap_t *p) if (p->opt.promisc) { /* set promiscuous mode, just warn if it fails */ if (ioctl(p->fd, BIOCPROMISC, NULL) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCPROMISC: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCPROMISC"); status = PCAP_WARNING_PROMISC_NOTSUP; } } @@ -2439,16 +2438,16 @@ pcap_activate_bpf(pcap_t *p) #ifdef BIOCSTSTAMP v = BPF_T_BINTIME; if (ioctl(p->fd, BIOCSTSTAMP, &v) < 0) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSTSTAMP: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSTSTAMP"); status = PCAP_ERROR; goto bad; } #endif /* BIOCSTSTAMP */ if (ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGBLEN: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCGBLEN"); status = PCAP_ERROR; goto bad; } @@ -2458,8 +2457,8 @@ pcap_activate_bpf(pcap_t *p) #endif p->buffer = malloc(p->bufsize); if (p->buffer == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); status = PCAP_ERROR; goto bad; } @@ -2489,8 +2488,8 @@ pcap_activate_bpf(pcap_t *p) total_prog.bf_len = 1; total_prog.bf_insns = &total_insn; if (ioctl(p->fd, BIOCSETF, (caddr_t)&total_prog) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETF"); status = PCAP_ERROR; goto bad; } @@ -2572,6 +2571,44 @@ check_bpf_bindable(const char *name) int fd; char errbuf[PCAP_ERRBUF_SIZE]; + /* + * On macOS, we don't do this check if the device name begins + * with "wlt"; at least some versions of macOS (actually, it + * was called "Mac OS X" then...) offer monitor mode capturing + * by having a separate "monitor mode" device for each wireless + * adapter, rather than by implementing the ioctls that + * {Free,Net,Open,DragonFly}BSD provide. Opening that device + * puts the adapter into monitor mode, which, at least for + * some adapters, causes them to deassociate from the network + * with which they're associated. + * + * Instead, we try to open the corresponding "en" device (so + * that we don't end up with, for users without sufficient + * privilege to open capture devices, a list of adapters that + * only includes the wlt devices). + */ +#ifdef __APPLE__ + if (strncmp(name, "wlt", 3) == 0) { + char *en_name; + size_t en_name_len; + + /* + * Try to allocate a buffer for the "en" + * device's name. + */ + en_name_len = strlen(name) - 1; + en_name = malloc(en_name_len + 1); + if (en_name == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + strcpy(en_name, "en"); + strcat(en_name, name + 3); + fd = bpf_open_and_bind(en_name, errbuf); + free(en_name); + } else +#endif /* __APPLE */ fd = bpf_open_and_bind(name, errbuf); if (fd < 0) { /* @@ -2606,7 +2643,18 @@ check_bpf_bindable(const char *name) #if defined(__FreeBSD__) && defined(SIOCIFCREATE2) static int -finddevs_usb(pcap_if_t **alldevsp, char *errbuf) +get_usb_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_) +{ + /* + * XXX - if there's a way to determine whether there's something + * plugged into a given USB bus, use that to determine whether + * this device is "connected" or not. + */ + return (0); +} + +static int +finddevs_usb(pcap_if_list_t *devlistp, char *errbuf) { DIR *usbdir; struct dirent *usbitem; @@ -2646,7 +2694,6 @@ finddevs_usb(pcap_if_t **alldevsp, char *errbuf) while ((usbitem = readdir(usbdir)) != NULL) { char *p; size_t busnumlen; - int err; if (strcmp(usbitem->d_name, ".") == 0 || strcmp(usbitem->d_name, "..") == 0) { @@ -2662,11 +2709,18 @@ finddevs_usb(pcap_if_t **alldevsp, char *errbuf) memcpy(name, usbus_prefix, USBUS_PREFIX_LEN); memcpy(name + USBUS_PREFIX_LEN, usbitem->d_name, busnumlen); *(name + USBUS_PREFIX_LEN + busnumlen) = '\0'; - err = pcap_add_if(alldevsp, name, PCAP_IF_UP, NULL, errbuf); - if (err != 0) { + /* + * There's an entry in this directory for every USB device, + * not for every bus; if there's more than one device on + * the bus, there'll be more than one entry for that bus, + * so we need to avoid adding multiple capture devices + * for each bus. + */ + if (find_or_add_dev(devlistp, name, PCAP_IF_UP, + get_usb_if_flags, NULL, errbuf) == NULL) { free(name); closedir(usbdir); - return (err); + return (PCAP_ERROR); } } free(name); @@ -2675,17 +2729,116 @@ finddevs_usb(pcap_if_t **alldevsp, char *errbuf) } #endif +/* + * Get additional flags for a device, using SIOCGIFMEDIA. + */ +#ifdef SIOCGIFMEDIA +static int +get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf) +{ + int sock; + struct ifmediareq req; + + sock = socket(AF_INET, SOCK_DGRAM, 0); + if (sock == -1) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, errno, + "Can't create socket to get media information for %s", + name); + return (-1); + } + memset(&req, 0, sizeof(req)); + strncpy(req.ifm_name, name, sizeof(req.ifm_name)); + if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) { + if (errno == EOPNOTSUPP || errno == EINVAL || errno == ENOTTY || + errno == ENODEV) { + /* + * Not supported, so we can't provide any + * additional information. Assume that + * this means that "connected" vs. + * "disconnected" doesn't apply. + */ + *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE; + close(sock); + return (0); + } + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, errno, + "SIOCGIFMEDIA on %s failed", name); + close(sock); + return (-1); + } + close(sock); + + /* + * OK, what type of network is this? + */ + switch (IFM_TYPE(req.ifm_active)) { + + case IFM_IEEE80211: + /* + * Wireless. + */ + *flags |= PCAP_IF_WIRELESS; + break; + } + + /* + * Do we know whether it's connected? + */ + if (req.ifm_status & IFM_AVALID) { + /* + * Yes. + */ + if (req.ifm_status & IFM_ACTIVE) { + /* + * It's connected. + */ + *flags |= PCAP_IF_CONNECTION_STATUS_CONNECTED; + } else { + /* + * It's disconnected. + */ + *flags |= PCAP_IF_CONNECTION_STATUS_DISCONNECTED; + } + } + return (0); +} +#else +static int +get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_) +{ + /* + * Nothing we can do other than mark loopback devices as "the + * connected/disconnected status doesn't apply". + * + * XXX - on Solaris, can we do what the dladm command does, + * i.e. get a connected/disconnected indication from a kstat? + * (Note that you can also get the link speed, and possibly + * other information, from a kstat as well.) + */ + if (*flags & PCAP_IF_LOOPBACK) { + /* + * Loopback devices aren't wireless, and "connected"/ + * "disconnected" doesn't apply to them. + */ + *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE; + return (0); + } + return (0); +} +#endif + int -pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) +pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf) { /* * Get the list of regular interfaces first. */ - if (pcap_findalldevs_interfaces(alldevsp, errbuf, check_bpf_bindable) == -1) + if (pcap_findalldevs_interfaces(devlistp, errbuf, check_bpf_bindable, + get_if_flags) == -1) return (-1); /* failure */ #if defined(__FreeBSD__) && defined(SIOCIFCREATE2) - if (finddevs_usb(alldevsp, errbuf) == -1) + if (finddevs_usb(devlistp, errbuf) == -1) return (-1); #endif @@ -2706,8 +2859,8 @@ monitor_mode(pcap_t *p, int set) sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't open socket: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "can't open socket"); return (PCAP_ERROR); } @@ -2738,8 +2891,8 @@ monitor_mode(pcap_t *p, int set) return (PCAP_ERROR_RFMON_NOTSUP); default: - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFMEDIA 1: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFMEDIA 1"); close(sock); return (PCAP_ERROR); } @@ -2758,15 +2911,15 @@ monitor_mode(pcap_t *p, int set) */ media_list = malloc(req.ifm_count * sizeof(*media_list)); if (media_list == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); close(sock); return (PCAP_ERROR); } req.ifm_ulist = media_list; if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFMEDIA"); free(media_list); close(sock); return (PCAP_ERROR); @@ -2826,8 +2979,8 @@ monitor_mode(pcap_t *p, int set) sizeof(ifr.ifr_name)); ifr.ifr_media = req.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(sock, SIOCSIFMEDIA, &ifr) == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "SIOCSIFMEDIA: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, "SIOCSIFMEDIA"); close(sock); return (PCAP_ERROR); } @@ -3051,8 +3204,8 @@ pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp) * some kernels. */ if (errno != EINVAL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "BIOCSETF"); return (-1); } @@ -3080,11 +3233,10 @@ pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d) direction = (d == PCAP_D_IN) ? BPF_D_IN : ((d == PCAP_D_OUT) ? BPF_D_OUT : BPF_D_INOUT); if (ioctl(p->fd, BIOCSDIRECTION, &direction) == -1) { - (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "Cannot set direction to %s: %s", + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "Cannot set direction to %s", (d == PCAP_D_IN) ? "PCAP_D_IN" : - ((d == PCAP_D_OUT) ? "PCAP_D_OUT" : "PCAP_D_INOUT"), - strerror(errno)); + ((d == PCAP_D_OUT) ? "PCAP_D_OUT" : "PCAP_D_INOUT")); return (-1); } return (0); @@ -3102,10 +3254,9 @@ pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d) seesent = (d == PCAP_D_INOUT); if (ioctl(p->fd, BIOCSSEESENT, &seesent) == -1) { - (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "Cannot set direction to %s: %s", - (d == PCAP_D_INOUT) ? "PCAP_D_INOUT" : "PCAP_D_IN", - strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "Cannot set direction to %s", + (d == PCAP_D_INOUT) ? "PCAP_D_INOUT" : "PCAP_D_IN"); return (-1); } return (0); @@ -3121,10 +3272,23 @@ pcap_set_datalink_bpf(pcap_t *p, int dlt) { #ifdef BIOCSDLT if (ioctl(p->fd, BIOCSDLT, &dlt) == -1) { - (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "Cannot set DLT %d: %s", dlt, strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "Cannot set DLT %d", dlt); return (-1); } #endif return (0); } + +/* + * Platform-specific information. + */ +const char * +pcap_lib_version(void) +{ +#ifdef HAVE_ZEROCOPY_BPF + return (PCAP_VERSION_STRING " (with zerocopy support)"); +#else + return (PCAP_VERSION_STRING); +#endif +} diff --git a/freebsd/contrib/libpcap/pcap-common.c b/freebsd/contrib/libpcap/pcap-common.c index 27fcdcda..8219a031 100644 --- a/freebsd/contrib/libpcap/pcap-common.c +++ b/freebsd/contrib/libpcap/pcap-common.c @@ -20,26 +20,14 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * pcap-common.c - common code for pcap and pcap-ng files + * pcap-common.c - common code for pcap and pcapng files */ #ifdef HAVE_CONFIG_H -#include "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 <pcap-types.h> #include "pcap-int.h" #include "extract.h" @@ -498,9 +486,14 @@ /* * IEEE 802.15.4, exactly as it appears in the spec (no padding, no - * nothing); requested by Mikko Saarnivala <mikko.saarnivala@sensinode.com>. + * nothing), and with the FCS at the end of the frame; requested by + * Mikko Saarnivala <mikko.saarnivala@sensinode.com>. + * + * This should only be used if the FCS is present at the end of the + * frame; if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be + * used. */ -#define LINKTYPE_IEEE802_15_4 195 +#define LINKTYPE_IEEE802_15_4_WITHFCS 195 /* * Various link-layer types, with a pseudo-header, for SITA @@ -705,14 +698,14 @@ * the pseudo-header is: * * struct dl_ipnetinfo { - * u_int8_t dli_version; - * u_int8_t dli_family; - * u_int16_t dli_htype; - * u_int32_t dli_pktlen; - * u_int32_t dli_ifindex; - * u_int32_t dli_grifindex; - * u_int32_t dli_zsrc; - * u_int32_t dli_zdst; + * uint8_t dli_version; + * uint8_t dli_family; + * uint16_t dli_htype; + * uint32_t dli_pktlen; + * uint32_t dli_ifindex; + * uint32_t dli_grifindex; + * uint32_t dli_zsrc; + * uint32_t dli_zdst; * }; * * dli_version is 2 for the current version of the pseudo-header. @@ -889,7 +882,7 @@ /* * pfsync output; DLT_PFSYNC is 18, which collides with DLT_CIP in - * SuSE 6.3, on OpenBSD, NetBSD, DragonFly BSD, and Mac OS X, and + * SuSE 6.3, on OpenBSD, NetBSD, DragonFly BSD, and macOS, and * is 121, which collides with DLT_HHDLC, in FreeBSD. We pick a * shiny new link-layer header type value that doesn't collide with * anything, in the hopes that future pfsync savefiles, if any, @@ -986,7 +979,7 @@ * So I'll just give them one; hopefully this will show up in a * libpcap release in time for them to get this into 10.10 Big Sur * or whatever Mavericks' successor is called. LINKTYPE_PKTAP - * will be 258 *even on OS X*; that is *intentional*, so that + * will be 258 *even on macOS*; that is *intentional*, so that * PKTAP files look the same on *all* OSes (different OSes can have * different numerical values for a given DLT_, but *MUST NOT* have * different values for what goes in a file, as files can be moved @@ -1030,7 +1023,67 @@ */ #define LINKTYPE_RDS 265 -#define LINKTYPE_MATCHING_MAX 265 /* highest value in the "matching" range */ +/* + * USB packets, beginning with a Darwin (macOS, etc.) header. + */ +#define LINKTYPE_USB_DARWIN 266 + +/* + * OpenBSD DLT_OPENFLOW. + */ +#define LINKTYPE_OPENFLOW 267 + +/* + * SDLC frames containing SNA PDUs. + */ +#define LINKTYPE_SDLC 268 + +/* + * per "Selvig, Bjorn" <b.selvig@ti.com> used for + * TI protocol sniffer. + */ +#define LINKTYPE_TI_LLN_SNIFFER 269 + +/* + * per: Erik de Jong <erikdejong at gmail.com> for + * https://github.com/eriknl/LoRaTap/releases/tag/v0.1 + */ +#define LINKTYPE_LORATAP 270 + +/* + * per: Stefanha at gmail.com for + * http://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html + * and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h + * for: http://qemu-project.org/Features/VirtioVsock + */ +#define LINKTYPE_VSOCK 271 + +/* + * Nordic Semiconductor Bluetooth LE sniffer. + */ +#define LINKTYPE_NORDIC_BLE 272 + +/* + * Excentis DOCSIS 3.1 RF sniffer (XRA-31) + * per: bruno.verstuyft at excentis.com + * http://www.xra31.com/xra-header + */ +#define LINKTYPE_DOCSIS31_XRA31 273 + +/* + * mPackets, as specified by IEEE 802.3br Figure 99-4, starting + * with the preamble and always ending with a CRC field. + */ +#define LINKTYPE_ETHERNET_MPACKET 274 + +/* + * DisplayPort AUX channel monitoring data as specified by VESA + * DisplayPort(DP) Standard preceeded by a pseudo-header. + * per dirk.eibach at gdsys.cc + */ +#define LINKTYPE_DISPLAYPORT_AUX 275 + +#define LINKTYPE_MATCHING_MAX 275 /* highest value in the "matching" range */ static struct linktype_map { int dlt; @@ -1177,7 +1230,22 @@ linktype_to_dlt(int linktype) return linktype; } -#define EXTRACT_ +/* + * Return the maximum snapshot length for a given DLT_ value. + * + * For most link-layer types, we use MAXIMUM_SNAPLEN, but for DLT_DBUS, + * the maximum is 134217728, as per + * + * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages + */ +u_int +max_snaplen_for_dlt(int dlt) +{ + if (dlt == DLT_DBUS) + return 134217728; + else + return MAXIMUM_SNAPLEN; +} /* * DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or @@ -1194,7 +1262,7 @@ swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf) u_int caplen = hdr->caplen; u_int length = hdr->len; struct sll_header *shdr = (struct sll_header *)buf; - u_int16_t protocol; + uint16_t protocol; pcap_can_socketcan_hdr *chdr; if (caplen < (u_int) sizeof(struct sll_header) || @@ -1340,7 +1408,7 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, if (uhdr->transfer_type == URB_ISOCHRONOUS) { /* swap the values in struct linux_usb_isodesc */ usb_isodesc *pisodesc; - u_int32_t i; + uint32_t i; pisodesc = (usb_isodesc *)(void *)(buf+offset); for (i = 0; i < uhdr->ndesc; i++) { @@ -1386,7 +1454,7 @@ swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf) nflog_tlv_t *tlv; u_int caplen = hdr->caplen; u_int length = hdr->len; - u_int16_t size; + uint16_t size; if (caplen < (u_int) sizeof(nflog_hdr_t) || length < (u_int) sizeof(nflog_hdr_t)) { diff --git a/freebsd/contrib/libpcap/pcap-common.h b/freebsd/contrib/libpcap/pcap-common.h index 6ac5bcd2..88c057cb 100644 --- a/freebsd/contrib/libpcap/pcap-common.h +++ b/freebsd/contrib/libpcap/pcap-common.h @@ -1,3 +1,25 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * 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. + * + * pcap-common.h - common code for pcap and pcapng files + */ /* * We use the "receiver-makes-right" approach to byte order, @@ -23,3 +45,5 @@ extern int linktype_to_dlt(int linktype); extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data); + +extern u_int max_snaplen_for_dlt(int dlt); diff --git a/freebsd/contrib/libpcap/pcap-int.h b/freebsd/contrib/libpcap/pcap-int.h index 7db7ff5e..5888df72 100644 --- a/freebsd/contrib/libpcap/pcap-int.h +++ b/freebsd/contrib/libpcap/pcap-int.h @@ -34,55 +34,40 @@ #ifndef pcap_int_h #define pcap_int_h +#include <signal.h> + #include <pcap/pcap.h> +#include "varattrs.h" +#include "fmtutils.h" + +/* + * Version string. + * Uses PACKAGE_VERSION from config.h. + */ +#define PCAP_VERSION_STRING "libpcap version " PACKAGE_VERSION + #ifdef __cplusplus extern "C" { #endif -#if defined(_WIN32) - /* - * Make sure Packet32.h doesn't define BPF structures that we've - * probably already defined as a result of including <pcap/pcap.h>. - */ - #define BPF_MAJOR_VERSION - #include <Packet32.h> -#elif defined(MSDOS) +#ifdef MSDOS #include <fcntl.h> #include <io.h> #endif -#if (defined(_MSC_VER) && (_MSC_VER <= 1200)) /* we are compiling with Visual Studio 6, that doesn't support the LL suffix*/ - -/* - * Swap byte ordering of unsigned long long timestamp on a big endian - * machine. - */ -#define SWAPLL(ull) ((ull & 0xff00000000000000) >> 56) | \ - ((ull & 0x00ff000000000000) >> 40) | \ - ((ull & 0x0000ff0000000000) >> 24) | \ - ((ull & 0x000000ff00000000) >> 8) | \ - ((ull & 0x00000000ff000000) << 8) | \ - ((ull & 0x0000000000ff0000) << 24) | \ - ((ull & 0x000000000000ff00) << 40) | \ - ((ull & 0x00000000000000ff) << 56) - -#else /* A recent Visual studio compiler or not VC */ - /* * Swap byte ordering of unsigned long long timestamp on a big endian * machine. */ -#define SWAPLL(ull) ((ull & 0xff00000000000000LL) >> 56) | \ - ((ull & 0x00ff000000000000LL) >> 40) | \ - ((ull & 0x0000ff0000000000LL) >> 24) | \ - ((ull & 0x000000ff00000000LL) >> 8) | \ - ((ull & 0x00000000ff000000LL) << 8) | \ - ((ull & 0x0000000000ff0000LL) << 24) | \ - ((ull & 0x000000000000ff00LL) << 40) | \ - ((ull & 0x00000000000000ffLL) << 56) - -#endif /* _MSC_VER */ +#define SWAPLL(ull) ((ull & 0xff00000000000000ULL) >> 56) | \ + ((ull & 0x00ff000000000000ULL) >> 40) | \ + ((ull & 0x0000ff0000000000ULL) >> 24) | \ + ((ull & 0x000000ff00000000ULL) >> 8) | \ + ((ull & 0x00000000ff000000ULL) << 8) | \ + ((ull & 0x0000000000ff0000ULL) << 24) | \ + ((ull & 0x000000000000ff00ULL) << 40) | \ + ((ull & 0x00000000000000ffULL) << 56) /* * Maximum snapshot length. @@ -114,19 +99,32 @@ struct pcap_opt { int promisc; int rfmon; /* monitor mode */ int immediate; /* immediate mode - deliver packets as soon as they arrive */ + int nonblock; /* non-blocking mode - don't wait for packets to be delivered, return "no packets available" */ int tstamp_type; int tstamp_precision; + + /* + * Platform-dependent options. + */ +#ifdef __linux__ + int protocol; /* protocol to use when creating PF_PACKET socket */ +#endif +#ifdef _WIN32 + int nocapture_local;/* disable NPF loopback */ +#endif }; typedef int (*activate_op_t)(pcap_t *); typedef int (*can_set_rfmon_op_t)(pcap_t *); typedef int (*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *); +typedef int (*next_packet_op_t)(pcap_t *, struct pcap_pkthdr *, u_char **); typedef int (*inject_op_t)(pcap_t *, const void *, size_t); +typedef void (*save_current_filter_op_t)(pcap_t *, const char *); typedef int (*setfilter_op_t)(pcap_t *, struct bpf_program *); typedef int (*setdirection_op_t)(pcap_t *, pcap_direction_t); typedef int (*set_datalink_op_t)(pcap_t *, int); -typedef int (*getnonblock_op_t)(pcap_t *, char *); -typedef int (*setnonblock_op_t)(pcap_t *, int, char *); +typedef int (*getnonblock_op_t)(pcap_t *); +typedef int (*setnonblock_op_t)(pcap_t *, int); typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *); #ifdef _WIN32 typedef struct pcap_stat *(*stats_ex_op_t)(pcap_t *, int *); @@ -155,15 +153,14 @@ struct pcap { read_op_t read_op; /* - * Method to call to read packets from a savefile. + * Method to call to read the next packet from a savefile. */ - int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **); + next_packet_op_t next_packet_op; #ifdef _WIN32 - ADAPTER *adapter; + HANDLE handle; #else int fd; - int selectable_fd; #endif /* _WIN32 */ /* @@ -174,10 +171,14 @@ struct pcap { u_char *bp; int cc; - int break_loop; /* flag set to force break from packet-reading loop */ + sig_atomic_t break_loop; /* flag set to force break from packet-reading loop */ void *priv; /* private data for methods */ +#ifdef ENABLE_REMOTE + struct pcap_samp rmt_samp; /* parameters related to the sampling process. */ +#endif + int swapped; FILE *rfile; /* null if live capture, non-null if savefile */ u_int fddipad; @@ -208,7 +209,7 @@ struct pcap { u_char *pkt; #ifdef _WIN32 - struct pcap_stat stat; /* used for pcap_stats_ex() */ + struct pcap_stat stat; /* used for pcap_stats_ex() */ #endif /* We're accepting only packets in this direction/these directions. */ @@ -219,6 +220,23 @@ struct pcap { */ int bpf_codegen_flags; +#if !defined(_WIN32) && !defined(MSDOS) + int selectable_fd; /* FD on which select()/poll()/epoll_wait()/kevent()/etc. can be done */ + + /* + * In case there either is no selectable FD, or there is but + * it doesn't necessarily work (e.g., if it doesn't get notified + * if the packet capture timeout expires before the buffer + * fills up), this points to a timeout that should be used + * in select()/poll()/epoll_wait()/kevent() call. The pcap_t should + * be put into non-blocking mode, and, if the timeout expires on + * the call, an attempt should be made to read packets from all + * pcap_t's with a required timeout, and the code must be + * prepared not to see any packets from the attempt. + */ + struct timeval *required_select_timeout; +#endif + /* * Placeholder for filter code if bpf not in kernel. */ @@ -240,6 +258,7 @@ struct pcap { activate_op_t activate_op; can_set_rfmon_op_t can_set_rfmon_op; inject_op_t inject_op; + save_current_filter_op_t save_current_filter_op; setfilter_op_t setfilter_op; setdirection_op_t setdirection_op; set_datalink_op_t set_datalink_op; @@ -378,8 +397,8 @@ int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); * Routines that most pcap implementations can use for non-blocking mode. */ #if !defined(_WIN32) && !defined(MSDOS) -int pcap_getnonblock_fd(pcap_t *, char *); -int pcap_setnonblock_fd(pcap_t *p, int, char *); +int pcap_getnonblock_fd(pcap_t *); +int pcap_setnonblock_fd(pcap_t *p, int); #endif /* @@ -404,32 +423,47 @@ int pcap_check_activated(pcap_t *); /* * Internal interfaces for "pcap_findalldevs()". * - * "pcap_platform_finddevs()" is a platform-dependent routine to + * A pcap_if_list_t * is a reference to a list of devices. + * + * A get_if_flags_func is a platform-dependent function called to get + * additional interface flags. + * + * "pcap_platform_finddevs()" is the platform-dependent routine to * find local network interfaces. * * "pcap_findalldevs_interfaces()" is a helper to find those interfaces * using the "standard" mechanisms (SIOCGIFCONF, "getifaddrs()", etc.). * - * "pcap_add_if()" adds an interface to the list of interfaces, for - * use by various "find interfaces" routines. + * "add_dev()" adds an entry to a pcap_if_list_t. + * + * "find_dev()" tries to find a device, by name, in a pcap_if_list_t. + * + * "find_or_add_dev()" checks whether a device is already in a pcap_if_list_t + * and, if not, adds an entry for it. */ -int pcap_platform_finddevs(pcap_if_t **, char *); +struct pcap_if_list; +typedef struct pcap_if_list pcap_if_list_t; +typedef int (*get_if_flags_func)(const char *, bpf_u_int32 *, char *); +int pcap_platform_finddevs(pcap_if_list_t *, char *); #if !defined(_WIN32) && !defined(MSDOS) -int pcap_findalldevs_interfaces(pcap_if_t **, char *, - int (*)(const char *)); +int pcap_findalldevs_interfaces(pcap_if_list_t *, char *, + int (*)(const char *), get_if_flags_func); #endif -int add_addr_to_iflist(pcap_if_t **, const char *, bpf_u_int32, - struct sockaddr *, size_t, struct sockaddr *, size_t, - struct sockaddr *, size_t, struct sockaddr *, size_t, char *); +pcap_if_t *find_or_add_dev(pcap_if_list_t *, const char *, bpf_u_int32, + get_if_flags_func, const char *, char *); +pcap_if_t *find_dev(pcap_if_list_t *, const char *); +pcap_if_t *add_dev(pcap_if_list_t *, const char *, bpf_u_int32, const char *, + char *); int add_addr_to_dev(pcap_if_t *, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *dstaddr, size_t, char *errbuf); -int pcap_add_if(pcap_if_t **, const char *, bpf_u_int32, const char *, - char *); -int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, bpf_u_int32, - const char *, char *); #ifndef _WIN32 -bpf_u_int32 if_flags_to_pcap_flags(const char *, u_int); +pcap_if_t *find_or_add_if(pcap_if_list_t *, const char *, bpf_u_int32, + get_if_flags_func, char *); +int add_addr_to_if(pcap_if_list_t *, const char *, bpf_u_int32, + get_if_flags_func, + struct sockaddr *, size_t, struct sockaddr *, size_t, + struct sockaddr *, size_t, struct sockaddr *, size_t, char *); #endif /* @@ -462,6 +496,10 @@ int install_bpf_program(pcap_t *, struct bpf_program *); int pcap_strcasecmp(const char *, const char *); +#ifdef YYDEBUG +extern int pcap_debug; +#endif + #ifdef __cplusplus } #endif diff --git a/freebsd/contrib/libpcap/pcap-types.h b/freebsd/contrib/libpcap/pcap-types.h new file mode 100644 index 00000000..9614f9f1 --- /dev/null +++ b/freebsd/contrib/libpcap/pcap-types.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef pcap_types_h +#define pcap_types_h + +/* + * Get u_int defined, by hook or by crook. + */ +#ifdef _WIN32 + + /* + * This defines u_int. + */ + #include <winsock2.h> +#else /* _WIN32 */ + /* + * This defines u_int, among other types. + */ + #include <sys/types.h> +#endif + +#endif /* pcap_types_h */ diff --git a/freebsd/contrib/libpcap/pcap.c b/freebsd/contrib/libpcap/pcap.c index c7e7d02e..4cf53b22 100644 --- a/freebsd/contrib/libpcap/pcap.c +++ b/freebsd/contrib/libpcap/pcap.c @@ -34,24 +34,28 @@ */ #ifdef HAVE_CONFIG_H -#include "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> +#include <pcap-types.h> +#ifndef _WIN32 +#include <sys/param.h> +#ifndef MSDOS +#include <sys/file.h> #endif -#ifdef HAVE_SYS_BITYPES_H -#include <sys/bitypes.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#ifdef HAVE_SYS_SOCKIO_H +#include <sys/sockio.h> #endif -#include <sys/types.h> -#include <sys/mman.h> + +struct mbuf; /* Squelch compiler warnings on some platforms for */ +struct rtentry; /* declarations in <net/if.h> */ +#include <net/if.h> +#include <netinet/in.h> #endif /* _WIN32 */ +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -60,6 +64,11 @@ #endif #include <fcntl.h> #include <errno.h> +#ifdef HAVE_LIMITS_H +#include <limits.h> +#else +#define INT_MAX 2147483647 +#endif #ifdef HAVE_OS_PROTO_H #include "os-proto.h" @@ -71,6 +80,8 @@ #include "pcap-int.h" +#include "optimize.h" + #ifdef HAVE_DAG_API #include "pcap-dag.h" #endif /* HAVE_DAG_API */ @@ -104,16 +115,88 @@ #endif #ifdef PCAP_SUPPORT_NETMAP -pcap_t* pcap_netmap_create(const char *device, char *ebuf, int *is_ours); +#include "pcap-netmap.h" #endif #ifdef PCAP_SUPPORT_DBUS #include "pcap-dbus.h" #endif +#ifdef PCAP_SUPPORT_RDMASNIFF +#include "pcap-rdmasniff.h" +#endif + +#ifdef _WIN32 +/* + * DllMain(), required when built as a Windows DLL. + */ +BOOL WINAPI DllMain( + HANDLE hinstDLL, + DWORD dwReason, + LPVOID lpvReserved +) +{ + return (TRUE); +} + +/* + * Start WinSock. + * Exported in case some applications using WinPcap called it, + * even though it wasn't exported. + */ +int +wsockinit(void) +{ + WORD wVersionRequested; + WSADATA wsaData; + static int err = -1; + static int done = 0; + + if (done) + return (err); + + wVersionRequested = MAKEWORD( 1, 1); + err = WSAStartup( wVersionRequested, &wsaData ); + atexit ((void(*)(void))WSACleanup); + done = 1; + + if ( err != 0 ) + err = -1; + return (err); +} + +/* + * This is the exported function; new programs should call this. + */ +int +pcap_wsockinit(void) +{ + return (wsockinit()); +} +#endif /* _WIN32 */ + +/* + * String containing the library version. + * Not explicitly exported via a header file - the right API to use + * is pcap_lib_version() - but some programs included it, so we + * provide it. + * + * We declare it here, right before defining it, to squelch any + * warnings we might get from compilers about the lack of a + * declaration. + */ +PCAP_API char pcap_version[]; +PCAP_API_DEF char pcap_version[] = PACKAGE_VERSION; + static int pcap_not_initialized(pcap_t *pcap) { + if (pcap->activated) { + /* A module probably forgot to set the function pointer */ + (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), + "This operation isn't properly handled by that device"); + return (PCAP_ERROR); + } /* in case the caller doesn't check for PCAP_ERROR_NOT_ACTIVATED */ (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), "This handle hasn't been activated yet"); @@ -125,6 +208,12 @@ pcap_not_initialized(pcap_t *pcap) static void * pcap_not_initialized_ptr(pcap_t *pcap) { + if (pcap->activated) { + /* A module probably forgot to set the function pointer */ + (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), + "This operation isn't properly handled by that device"); + return (NULL); + } (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), "This handle hasn't been activated yet"); return (NULL); @@ -133,6 +222,12 @@ pcap_not_initialized_ptr(pcap_t *pcap) static HANDLE pcap_getevent_not_initialized(pcap_t *pcap) { + if (pcap->activated) { + /* A module probably forgot to set the function pointer */ + (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), + "This operation isn't properly handled by that device"); + return (INVALID_HANDLE_VALUE); + } (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), "This handle hasn't been activated yet"); return (INVALID_HANDLE_VALUE); @@ -141,6 +236,12 @@ pcap_getevent_not_initialized(pcap_t *pcap) static u_int pcap_sendqueue_transmit_not_initialized(pcap_t *pcap, pcap_send_queue* queue, int sync) { + if (pcap->activated) { + /* A module probably forgot to set the function pointer */ + (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), + "This operation isn't properly handled by that device"); + return (0); + } (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), "This handle hasn't been activated yet"); return (0); @@ -149,6 +250,12 @@ pcap_sendqueue_transmit_not_initialized(pcap_t *pcap, pcap_send_queue* queue, in static PAirpcapHandle pcap_get_airpcap_handle_not_initialized(pcap_t *pcap) { + if (pcap->activated) { + /* A module probably forgot to set the function pointer */ + (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), + "This operation isn't properly handled by that device"); + return (NULL); + } (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf), "This handle hasn't been activated yet"); return (NULL); @@ -197,8 +304,8 @@ pcap_list_tstamp_types(pcap_t *p, int **tstamp_typesp) *tstamp_typesp = (int*)calloc(sizeof(**tstamp_typesp), p->tstamp_type_count); if (*tstamp_typesp == NULL) { - (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "malloc"); return (PCAP_ERROR); } (void)memcpy(*tstamp_typesp, p->tstamp_type_list, @@ -302,13 +409,17 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, return (p->read_op(p, 1, p->oneshot_callback, (u_char *)&s)); } +/* + * Implementation of a pcap_if_list_t. + */ +struct pcap_if_list { + pcap_if_t *beginning; +}; + static struct capture_source_type { - int (*findalldevs_op)(pcap_if_t **, char *); + int (*findalldevs_op)(pcap_if_list_t *, char *); pcap_t *(*create_op)(const char *, char *, int *); } capture_source_types[] = { -#ifdef PCAP_SUPPORT_NETMAP - { NULL, pcap_netmap_create }, -#endif #ifdef HAVE_DAG_API { dag_findalldevs, dag_create }, #endif @@ -333,9 +444,15 @@ static struct capture_source_type { #ifdef PCAP_SUPPORT_NETFILTER { netfilter_findalldevs, netfilter_create }, #endif +#ifdef PCAP_SUPPORT_NETMAP + { pcap_netmap_findalldevs, pcap_netmap_create }, +#endif #ifdef PCAP_SUPPORT_DBUS { dbus_findalldevs, dbus_create }, #endif +#ifdef PCAP_SUPPORT_RDMASNIFF + { rdmasniff_findalldevs, rdmasniff_create }, +#endif { NULL, NULL } }; @@ -349,35 +466,1503 @@ int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) { size_t i; + pcap_if_list_t devlist; /* * Find all the local network interfaces on which we * can capture. */ - if (pcap_platform_finddevs(alldevsp, errbuf) == -1) + devlist.beginning = NULL; + if (pcap_platform_finddevs(&devlist, errbuf) == -1) { + /* + * Failed - free all of the entries we were given + * before we failed. + */ + if (devlist.beginning != NULL) + pcap_freealldevs(devlist.beginning); + *alldevsp = NULL; return (-1); + } /* * Ask each of the non-local-network-interface capture * source types what interfaces they have. */ for (i = 0; capture_source_types[i].findalldevs_op != NULL; i++) { - if (capture_source_types[i].findalldevs_op(alldevsp, errbuf) == -1) { + if (capture_source_types[i].findalldevs_op(&devlist, errbuf) == -1) { /* * We had an error; free the list we've been * constructing. */ - if (*alldevsp != NULL) { - pcap_freealldevs(*alldevsp); - *alldevsp = NULL; + if (devlist.beginning != NULL) + pcap_freealldevs(devlist.beginning); + *alldevsp = NULL; + return (-1); + } + } + + /* + * Return the first entry of the list of all devices. + */ + *alldevsp = devlist.beginning; + return (0); +} + +static struct sockaddr * +dup_sockaddr(struct sockaddr *sa, size_t sa_length) +{ + struct sockaddr *newsa; + + if ((newsa = malloc(sa_length)) == NULL) + return (NULL); + return (memcpy(newsa, sa, sa_length)); +} + +/* + * Construct a "figure of merit" for an interface, for use when sorting + * the list of interfaces, in which interfaces that are up are superior + * to interfaces that aren't up, interfaces that are up and running are + * superior to interfaces that are up but not running, and non-loopback + * interfaces that are up and running are superior to loopback interfaces, + * and interfaces with the same flags have a figure of merit that's higher + * the lower the instance number. + * + * The goal is to try to put the interfaces most likely to be useful for + * capture at the beginning of the list. + * + * The figure of merit, which is lower the "better" the interface is, + * has the uppermost bit set if the interface isn't running, the bit + * below that set if the interface isn't up, the bit below that set + * if the interface is a loopback interface, and the interface index + * in the 29 bits below that. (Yes, we assume u_int is 32 bits.) + */ +static u_int +get_figure_of_merit(pcap_if_t *dev) +{ + const char *cp; + u_int n; + + if (strcmp(dev->name, "any") == 0) { + /* + * Give the "any" device an artificially high instance + * number, so it shows up after all other non-loopback + * interfaces. + */ + n = 0x1FFFFFFF; /* 29 all-1 bits */ + } else { + /* + * A number at the end of the device name string is + * assumed to be an instance number. Add 1 to the + * instance number, and use 0 for "no instance + * number", so we don't put "no instance number" + * devices and "instance 0" devices together. + */ + cp = dev->name + strlen(dev->name) - 1; + while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9') + cp--; + if (*cp >= '0' && *cp <= '9') + n = atoi(cp) + 1; + else + n = 0; + } + if (!(dev->flags & PCAP_IF_RUNNING)) + n |= 0x80000000; + if (!(dev->flags & PCAP_IF_UP)) + n |= 0x40000000; + + /* + * Give non-wireless interfaces that aren't disconnected a better + * figure of merit than interfaces that are disconnected, as + * "disconnected" should indicate that the interface isn't + * plugged into a network and thus won't give you any traffic. + * + * For wireless interfaces, it means "associated with a network", + * which we presume not to necessarily prevent capture, as you + * might run the adapter in some flavor of monitor mode. + */ + if (!(dev->flags & PCAP_IF_WIRELESS) && + (dev->flags & PCAP_IF_CONNECTION_STATUS) == PCAP_IF_CONNECTION_STATUS_DISCONNECTED) + n |= 0x20000000; + + /* + * Sort loopback devices after non-loopback devices, *except* for + * disconnected devices. + */ + if (dev->flags & PCAP_IF_LOOPBACK) + n |= 0x10000000; + + return (n); +} + +#ifndef _WIN32 +/* + * Try to get a description for a given device. + * Returns a mallocated description if it could and NULL if it couldn't. + * + * XXX - on FreeBSDs that support it, should it get the sysctl named + * "dev.{adapter family name}.{adapter unit}.%desc" to get a description + * of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800" + * with my Cisco 350 card, so the name isn't entirely descriptive. The + * "dev.an.0.%pnpinfo" has a better description, although one might argue + * that the problem is really a driver bug - if it can find out that it's + * a Cisco 340 or 350, rather than an old Aironet card, it should use + * that in the description. + * + * Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD + * and OpenBSD let you get a description, but it's not generated by the OS, + * it's set with another ioctl that ifconfig supports; we use that to get + * a description in FreeBSD and OpenBSD, but if there is no such + * description available, it still might be nice to get some description + * string based on the device type or something such as that. + * + * In macOS, the System Configuration framework can apparently return + * names in 10.4 and later. + * + * It also appears that freedesktop.org's HAL offers an "info.product" + * string, but the HAL specification says it "should not be used in any + * UI" and "subsystem/capability specific properties" should be used + * instead and, in any case, I think HAL is being deprecated in + * favor of other stuff such as DeviceKit. DeviceKit doesn't appear + * to have any obvious product information for devices, but maybe + * I haven't looked hard enough. + * + * Using the System Configuration framework, or HAL, or DeviceKit, or + * whatever, would require that libpcap applications be linked with + * the frameworks/libraries in question. That shouldn't be a problem + * for programs linking with the shared version of libpcap (unless + * you're running on AIX - which I think is the only UN*X that doesn't + * support linking a shared library with other libraries on which it + * depends, and having an executable linked only with the first shared + * library automatically pick up the other libraries when started - + * and using HAL or whatever). Programs linked with the static + * version of libpcap would have to use pcap-config with the --static + * flag in order to get the right linker flags in order to pick up + * the additional libraries/frameworks; those programs need that anyway + * for libpcap 1.1 and beyond on Linux, as, by default, it requires + * -lnl. + * + * Do any other UN*Xes, or desktop environments support getting a + * description? + */ +static char * +#ifdef SIOCGIFDESCR +get_if_description(const char *name) +{ + char *description = NULL; + int s; + struct ifreq ifrdesc; +#ifndef IFDESCRSIZE + size_t descrlen = 64; +#else + size_t descrlen = IFDESCRSIZE; +#endif /* IFDESCRSIZE */ + + /* + * Get the description for the interface. + */ + memset(&ifrdesc, 0, sizeof ifrdesc); + strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name); + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s >= 0) { +#ifdef __FreeBSD__ + /* + * On FreeBSD, if the buffer isn't big enough for the + * description, the ioctl succeeds, but the description + * isn't copied, ifr_buffer.length is set to the description + * length, and ifr_buffer.buffer is set to NULL. + */ + for (;;) { + free(description); + if ((description = malloc(descrlen)) != NULL) { + ifrdesc.ifr_buffer.buffer = description; + ifrdesc.ifr_buffer.length = descrlen; + if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0) { + if (ifrdesc.ifr_buffer.buffer == + description) + break; + else + descrlen = ifrdesc.ifr_buffer.length; + } else { + /* + * Failed to get interface description. + */ + free(description); + description = NULL; + break; + } + } else + break; + } +#else /* __FreeBSD__ */ + /* + * The only other OS that currently supports + * SIOCGIFDESCR is OpenBSD, and it has no way + * to get the description length - it's clamped + * to a maximum of IFDESCRSIZE. + */ + if ((description = malloc(descrlen)) != NULL) { + ifrdesc.ifr_data = (caddr_t)description; + if (ioctl(s, SIOCGIFDESCR, &ifrdesc) != 0) { + /* + * Failed to get interface description. + */ + free(description); + description = NULL; } + } +#endif /* __FreeBSD__ */ + close(s); + if (description != NULL && strlen(description) == 0) { + /* + * Description is empty, so discard it. + */ + free(description); + description = NULL; + } + } + +#ifdef __FreeBSD__ + /* + * For FreeBSD, if we didn't get a description, and this is + * a device with a name of the form usbusN, label it as a USB + * bus. + */ + if (description == NULL) { + if (strncmp(name, "usbus", 5) == 0) { + /* + * OK, it begins with "usbus". + */ + long busnum; + char *p; + + errno = 0; + busnum = strtol(name + 5, &p, 10); + if (errno == 0 && p != name + 5 && *p == '\0' && + busnum >= 0 && busnum <= INT_MAX) { + /* + * OK, it's a valid number that's not + * bigger than INT_MAX. Construct + * a description from it. + */ + static const char descr_prefix[] = "USB bus number "; + size_t descr_size; + + /* + * Allow enough room for a 32-bit bus number. + * sizeof (descr_prefix) includes the + * terminating NUL. + */ + descr_size = sizeof (descr_prefix) + 10; + description = malloc(descr_size); + if (description != NULL) { + pcap_snprintf(description, descr_size, + "%s%ld", descr_prefix, busnum); + } + } + } + } +#endif + return (description); +#else /* SIOCGIFDESCR */ +get_if_description(const char *name _U_) +{ + return (NULL); +#endif /* SIOCGIFDESCR */ +} + +/* + * Look for a given device in the specified list of devices. + * + * If we find it, return a pointer to its entry. + * + * If we don't find it, attempt to add an entry for it, with the specified + * IFF_ flags and description, and, if that succeeds, return a pointer to + * the new entry, otherwise return NULL and set errbuf to an error message. + */ +pcap_if_t * +find_or_add_if(pcap_if_list_t *devlistp, const char *name, + bpf_u_int32 if_flags, get_if_flags_func get_flags_func, char *errbuf) +{ + bpf_u_int32 pcap_flags; + + /* + * Convert IFF_ flags to pcap flags. + */ + pcap_flags = 0; +#ifdef IFF_LOOPBACK + if (if_flags & IFF_LOOPBACK) + pcap_flags |= PCAP_IF_LOOPBACK; +#else + /* + * We don't have IFF_LOOPBACK, so look at the device name to + * see if it looks like a loopback device. + */ + if (name[0] == 'l' && name[1] == 'o' && + (isdigit((unsigned char)(name[2])) || name[2] == '\0') + pcap_flags |= PCAP_IF_LOOPBACK; +#endif +#ifdef IFF_UP + if (if_flags & IFF_UP) + pcap_flags |= PCAP_IF_UP; +#endif +#ifdef IFF_RUNNING + if (if_flags & IFF_RUNNING) + pcap_flags |= PCAP_IF_RUNNING; +#endif + + /* + * Attempt to find an entry for this device; if we don't find one, + * attempt to add one. + */ + return (find_or_add_dev(devlistp, name, pcap_flags, + get_flags_func, get_if_description(name), errbuf)); +} + +/* + * Look for a given device in the specified list of devices. + * + * If we find it, then, if the specified address isn't null, add it to + * the list of addresses for the device and return 0. + * + * If we don't find it, attempt to add an entry for it, with the specified + * IFF_ flags and description, and, if that succeeds, add the specified + * address to its list of addresses if that address is non-null, and + * return 0, otherwise return -1 and set errbuf to an error message. + * + * (We can get called with a null address because we might get a list + * of interface name/address combinations from the underlying OS, with + * the address being absent in some cases, rather than a list of + * interfaces with each interface having a list of addresses, so this + * call may be the only call made to add to the list, and we want to + * add interfaces even if they have no addresses.) + */ +int +add_addr_to_if(pcap_if_list_t *devlistp, const char *name, + bpf_u_int32 if_flags, get_if_flags_func get_flags_func, + struct sockaddr *addr, size_t addr_size, + struct sockaddr *netmask, size_t netmask_size, + struct sockaddr *broadaddr, size_t broadaddr_size, + struct sockaddr *dstaddr, size_t dstaddr_size, + char *errbuf) +{ + pcap_if_t *curdev; + + /* + * Check whether the device exists and, if not, add it. + */ + curdev = find_or_add_if(devlistp, name, if_flags, get_flags_func, + errbuf); + if (curdev == NULL) { + /* + * Error - give up. + */ + return (-1); + } + + if (addr == NULL) { + /* + * There's no address to add; this entry just meant + * "here's a new interface". + */ + return (0); + } + + /* + * "curdev" is an entry for this interface, and we have an + * address for it; add an entry for that address to the + * interface's list of addresses. + */ + return (add_addr_to_dev(curdev, addr, addr_size, netmask, + netmask_size, broadaddr, broadaddr_size, dstaddr, + dstaddr_size, errbuf)); +} +#endif /* _WIN32 */ + +/* + * Add an entry to the list of addresses for an interface. + * "curdev" is the entry for that interface. + */ +int +add_addr_to_dev(pcap_if_t *curdev, + struct sockaddr *addr, size_t addr_size, + struct sockaddr *netmask, size_t netmask_size, + struct sockaddr *broadaddr, size_t broadaddr_size, + struct sockaddr *dstaddr, size_t dstaddr_size, + char *errbuf) +{ + pcap_addr_t *curaddr, *prevaddr, *nextaddr; + + /* + * Allocate the new entry and fill it in. + */ + curaddr = (pcap_addr_t *)malloc(sizeof(pcap_addr_t)); + if (curaddr == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + + curaddr->next = NULL; + if (addr != NULL && addr_size != 0) { + curaddr->addr = (struct sockaddr *)dup_sockaddr(addr, addr_size); + if (curaddr->addr == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + free(curaddr); + return (-1); + } + } else + curaddr->addr = NULL; + + if (netmask != NULL && netmask_size != 0) { + curaddr->netmask = (struct sockaddr *)dup_sockaddr(netmask, netmask_size); + if (curaddr->netmask == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + if (curaddr->addr != NULL) + free(curaddr->addr); + free(curaddr); + return (-1); + } + } else + curaddr->netmask = NULL; + + if (broadaddr != NULL && broadaddr_size != 0) { + curaddr->broadaddr = (struct sockaddr *)dup_sockaddr(broadaddr, broadaddr_size); + if (curaddr->broadaddr == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + if (curaddr->netmask != NULL) + free(curaddr->netmask); + if (curaddr->addr != NULL) + free(curaddr->addr); + free(curaddr); + return (-1); + } + } else + curaddr->broadaddr = NULL; + + if (dstaddr != NULL && dstaddr_size != 0) { + curaddr->dstaddr = (struct sockaddr *)dup_sockaddr(dstaddr, dstaddr_size); + if (curaddr->dstaddr == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + if (curaddr->broadaddr != NULL) + free(curaddr->broadaddr); + if (curaddr->netmask != NULL) + free(curaddr->netmask); + if (curaddr->addr != NULL) + free(curaddr->addr); + free(curaddr); return (-1); } + } else + curaddr->dstaddr = NULL; + + /* + * Find the end of the list of addresses. + */ + for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) { + nextaddr = prevaddr->next; + if (nextaddr == NULL) { + /* + * This is the end of the list. + */ + break; + } + } + + if (prevaddr == NULL) { + /* + * The list was empty; this is the first member. + */ + curdev->addresses = curaddr; + } else { + /* + * "prevaddr" is the last member of the list; append + * this member to it. + */ + prevaddr->next = curaddr; } return (0); } +/* + * Look for a given device in the specified list of devices. + * + * If we find it, return 0 and set *curdev_ret to point to it. + * + * If we don't find it, attempt to add an entry for it, with the specified + * flags and description, and, if that succeeds, return 0, otherwise + * return -1 and set errbuf to an error message. + */ +pcap_if_t * +find_or_add_dev(pcap_if_list_t *devlistp, const char *name, bpf_u_int32 flags, + get_if_flags_func get_flags_func, const char *description, char *errbuf) +{ + pcap_if_t *curdev; + + /* + * Is there already an entry in the list for this device? + */ + curdev = find_dev(devlistp, name); + if (curdev != NULL) { + /* + * Yes, return it. + */ + return (curdev); + } + + /* + * No, we didn't find it. + */ + + /* + * Try to get additional flags for the device. + */ + if ((*get_flags_func)(name, &flags, errbuf) == -1) { + /* + * Failed. + */ + return (NULL); + } + + /* + * Now, try to add it to the list of devices. + */ + return (add_dev(devlistp, name, flags, description, errbuf)); +} + +/* + * Look for a given device in the specified list of devices, and return + * the entry for it if we find it or NULL if we don't. + */ +pcap_if_t * +find_dev(pcap_if_list_t *devlistp, const char *name) +{ + pcap_if_t *curdev; + + /* + * Is there an entry in the list for this device? + */ + for (curdev = devlistp->beginning; curdev != NULL; + curdev = curdev->next) { + if (strcmp(name, curdev->name) == 0) { + /* + * We found it, so, yes, there is. No need to + * add it. Provide the entry we found to our + * caller. + */ + return (curdev); + } + } + + /* + * No. + */ + return (NULL); +} + +/* + * Attempt to add an entry for a device, with the specified flags + * and description, and, if that succeeds, return 0 and return a pointer + * to the new entry, otherwise return NULL and set errbuf to an error + * message. + * + * If we weren't given a description, try to get one. + */ +pcap_if_t * +add_dev(pcap_if_list_t *devlistp, const char *name, bpf_u_int32 flags, + const char *description, char *errbuf) +{ + pcap_if_t *curdev, *prevdev, *nextdev; + u_int this_figure_of_merit, nextdev_figure_of_merit; + + curdev = malloc(sizeof(pcap_if_t)); + if (curdev == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (NULL); + } + + /* + * Fill in the entry. + */ + curdev->next = NULL; + curdev->name = strdup(name); + if (curdev->name == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + free(curdev); + return (NULL); + } + if (description == NULL) { + /* + * We weren't handed a description for the interface. + */ + curdev->description = NULL; + } else { + /* + * We were handed a description; make a copy. + */ + curdev->description = strdup(description); + if (curdev->description == NULL) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + free(curdev->name); + free(curdev); + return (NULL); + } + } + curdev->addresses = NULL; /* list starts out as empty */ + curdev->flags = flags; + + /* + * Add it to the list, in the appropriate location. + * First, get the "figure of merit" for this interface. + */ + this_figure_of_merit = get_figure_of_merit(curdev); + + /* + * Now look for the last interface with an figure of merit + * less than or equal to the new interface's figure of merit. + * + * We start with "prevdev" being NULL, meaning we're before + * the first element in the list. + */ + prevdev = NULL; + for (;;) { + /* + * Get the interface after this one. + */ + if (prevdev == NULL) { + /* + * The next element is the first element. + */ + nextdev = devlistp->beginning; + } else + nextdev = prevdev->next; + + /* + * Are we at the end of the list? + */ + if (nextdev == NULL) { + /* + * Yes - we have to put the new entry after "prevdev". + */ + break; + } + + /* + * Is the new interface's figure of merit less + * than the next interface's figure of merit, + * meaning that the new interface is better + * than the next interface? + */ + nextdev_figure_of_merit = get_figure_of_merit(nextdev); + if (this_figure_of_merit < nextdev_figure_of_merit) { + /* + * Yes - we should put the new entry + * before "nextdev", i.e. after "prevdev". + */ + break; + } + + prevdev = nextdev; + } + + /* + * Insert before "nextdev". + */ + curdev->next = nextdev; + + /* + * Insert after "prevdev" - unless "prevdev" is null, + * in which case this is the first interface. + */ + if (prevdev == NULL) { + /* + * This is the first interface. Make it + * the first element in the list of devices. + */ + devlistp->beginning = curdev; + } else + prevdev->next = curdev; + return (curdev); +} + +/* + * Free a list of interfaces. + */ +void +pcap_freealldevs(pcap_if_t *alldevs) +{ + pcap_if_t *curdev, *nextdev; + pcap_addr_t *curaddr, *nextaddr; + + for (curdev = alldevs; curdev != NULL; curdev = nextdev) { + nextdev = curdev->next; + + /* + * Free all addresses. + */ + for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) { + nextaddr = curaddr->next; + if (curaddr->addr) + free(curaddr->addr); + if (curaddr->netmask) + free(curaddr->netmask); + if (curaddr->broadaddr) + free(curaddr->broadaddr); + if (curaddr->dstaddr) + free(curaddr->dstaddr); + free(curaddr); + } + + /* + * Free the name string. + */ + free(curdev->name); + + /* + * Free the description string, if any. + */ + if (curdev->description != NULL) + free(curdev->description); + + /* + * Free the interface. + */ + free(curdev); + } +} + +/* + * pcap-npf.c has its own pcap_lookupdev(), for compatibility reasons, as + * it actually returns the names of all interfaces, with a NUL separator + * between them; some callers may depend on that. + * + * MS-DOS has its own pcap_lookupdev(), but that might be useful only + * as an optimization. + * + * In all other cases, we just use pcap_findalldevs() to get a list of + * devices, and pick from that list. + */ +#if !defined(HAVE_PACKET32) && !defined(MSDOS) +/* + * Return the name of a network interface attached to the system, or NULL + * if none can be found. The interface must be configured up; the + * lowest unit number is preferred; loopback is ignored. + */ +char * +pcap_lookupdev(char *errbuf) +{ + pcap_if_t *alldevs; +#ifdef _WIN32 + /* + * Windows - use the same size as the old WinPcap 3.1 code. + * XXX - this is probably bigger than it needs to be. + */ + #define IF_NAMESIZE 8192 +#else + /* + * UN*X - use the system's interface name size. + * XXX - that might not be large enough for capture devices + * that aren't regular network interfaces. + */ + /* for old BSD systems, including bsdi3 */ + #ifndef IF_NAMESIZE + #define IF_NAMESIZE IFNAMSIZ + #endif +#endif + static char device[IF_NAMESIZE + 1]; + char *ret; + + if (pcap_findalldevs(&alldevs, errbuf) == -1) + return (NULL); + + if (alldevs == NULL || (alldevs->flags & PCAP_IF_LOOPBACK)) { + /* + * There are no devices on the list, or the first device + * on the list is a loopback device, which means there + * are no non-loopback devices on the list. This means + * we can't return any device. + * + * XXX - why not return a loopback device? If we can't + * capture on it, it won't be on the list, and if it's + * on the list, there aren't any non-loopback devices, + * so why not just supply it as the default device? + */ + (void)strlcpy(errbuf, "no suitable device found", + PCAP_ERRBUF_SIZE); + ret = NULL; + } else { + /* + * Return the name of the first device on the list. + */ + (void)strlcpy(device, alldevs->name, sizeof(device)); + ret = device; + } + + pcap_freealldevs(alldevs); + return (ret); +} +#endif /* !defined(HAVE_PACKET32) && !defined(MSDOS) */ + +#if !defined(_WIN32) && !defined(MSDOS) +/* + * We don't just fetch the entire list of devices, search for the + * particular device, and use its first IPv4 address, as that's too + * much work to get just one device's netmask. + * + * If we had an API to get attributes for a given device, we could + * use that. + */ +int +pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, + char *errbuf) +{ + register int fd; + register struct sockaddr_in *sin4; + struct ifreq ifr; + + /* + * The pseudo-device "any" listens on all interfaces and therefore + * has the network address and -mask "0.0.0.0" therefore catching + * all traffic. Using NULL for the interface is the same as "any". + */ + if (!device || strcmp(device, "any") == 0 +#ifdef HAVE_DAG_API + || strstr(device, "dag") != NULL +#endif +#ifdef HAVE_SEPTEL_API + || strstr(device, "septel") != NULL +#endif +#ifdef PCAP_SUPPORT_BT + || strstr(device, "bluetooth") != NULL +#endif +#ifdef PCAP_SUPPORT_USB + || strstr(device, "usbmon") != NULL +#endif +#ifdef HAVE_SNF_API + || strstr(device, "snf") != NULL +#endif +#ifdef PCAP_SUPPORT_NETMAP + || strncmp(device, "netmap:", 7) == 0 + || strncmp(device, "vale", 4) == 0 +#endif + ) { + *netp = *maskp = 0; + return 0; + } + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "socket"); + return (-1); + } + memset(&ifr, 0, sizeof(ifr)); +#ifdef linux + /* XXX Work around Linux kernel bug */ + ifr.ifr_addr.sa_family = AF_INET; +#endif + (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { + if (errno == EADDRNOTAVAIL) { + (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + "%s: no IPv4 address assigned", device); + } else { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFADDR: %s", device); + } + (void)close(fd); + return (-1); + } + sin4 = (struct sockaddr_in *)&ifr.ifr_addr; + *netp = sin4->sin_addr.s_addr; + memset(&ifr, 0, sizeof(ifr)); +#ifdef linux + /* XXX Work around Linux kernel bug */ + ifr.ifr_addr.sa_family = AF_INET; +#endif + (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) { + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFNETMASK: %s", device); + (void)close(fd); + return (-1); + } + (void)close(fd); + *maskp = sin4->sin_addr.s_addr; + if (*maskp == 0) { + if (IN_CLASSA(*netp)) + *maskp = IN_CLASSA_NET; + else if (IN_CLASSB(*netp)) + *maskp = IN_CLASSB_NET; + else if (IN_CLASSC(*netp)) + *maskp = IN_CLASSC_NET; + else { + (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + "inet class for 0x%x unknown", *netp); + return (-1); + } + } + *netp &= *maskp; + return (0); +} +#endif /* !defined(_WIN32) && !defined(MSDOS) */ + +#ifdef ENABLE_REMOTE +#include "pcap-rpcap.h" + +/* + * Extract a substring from a string. + */ +static char * +get_substring(const char *p, size_t len, char *ebuf) +{ + char *token; + + token = malloc(len + 1); + if (token == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (NULL); + } + memcpy(token, p, len); + token[len] = '\0'; + return (token); +} + +/* + * Parse a capture source that might be a URL. + * + * If the source is not a URL, *schemep, *userinfop, *hostp, and *portp + * are set to NULL, *pathp is set to point to the source, and 0 is + * returned. + * + * If source is a URL, and the URL refers to a local device (a special + * case of rpcap:), *schemep, *userinfop, *hostp, and *portp are set + * to NULL, *pathp is set to point to the device name, and 0 is returned. + * + * If source is a URL, and it's not a special case that refers to a local + * device, and the parse succeeds: + * + * *schemep is set to point to an allocated string containing the scheme; + * + * if user information is present in the URL, *userinfop is set to point + * to an allocated string containing the user information, otherwise + * it's set to NULL; + * + * if host information is present in the URL, *hostp is set to point + * to an allocated string containing the host information, otherwise + * it's set to NULL; + * + * if a port number is present in the URL, *portp is set to point + * to an allocated string containing the port number, otherwise + * it's set to NULL; + * + * *pathp is set to point to an allocated string containing the + * path; + * + * and 0 is returned. + * + * If the parse fails, ebuf is set to an error string, and -1 is returned. + */ +static int +pcap_parse_source(const char *source, char **schemep, char **userinfop, + char **hostp, char **portp, char **pathp, char *ebuf) +{ + char *colonp; + size_t scheme_len; + char *scheme; + const char *endp; + size_t authority_len; + char *authority; + char *parsep, *atsignp, *bracketp; + char *userinfo, *host, *port, *path; + + /* + * Start out returning nothing. + */ + *schemep = NULL; + *userinfop = NULL; + *hostp = NULL; + *portp = NULL; + *pathp = NULL; + + /* + * RFC 3986 says: + * + * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] + * + * hier-part = "//" authority path-abempty + * / path-absolute + * / path-rootless + * / path-empty + * + * authority = [ userinfo "@" ] host [ ":" port ] + * + * userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) + * + * Step 1: look for the ":" at the end of the scheme. + * A colon in the source is *NOT* sufficient to indicate that + * this is a URL, as interface names on some platforms might + * include colons (e.g., I think some Solaris interfaces + * might). + */ + colonp = strchr(source, ':'); + if (colonp == NULL) { + /* + * The source is the device to open. + * Return a NULL pointer for the scheme, user information, + * host, and port, and return the device as the path. + */ + *pathp = strdup(source); + if (*pathp == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + return (0); + } + + /* + * All schemes must have "//" after them, i.e. we only support + * hier-part = "//" authority path-abempty, not + * hier-part = path-absolute + * hier-part = path-rootless + * hier-part = path-empty + * + * We need that in order to distinguish between a local device + * name that happens to contain a colon and a URI. + */ + if (strncmp(colonp + 1, "//", 2) != 0) { + /* + * The source is the device to open. + * Return a NULL pointer for the scheme, user information, + * host, and port, and return the device as the path. + */ + *pathp = strdup(source); + if (*pathp == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + return (0); + } + + /* + * XXX - check whether the purported scheme could be a scheme? + */ + + /* + * OK, this looks like a URL. + * Get the scheme. + */ + scheme_len = colonp - source; + scheme = malloc(scheme_len + 1); + if (scheme == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + memcpy(scheme, source, scheme_len); + scheme[scheme_len] = '\0'; + + /* + * Treat file: specially - take everything after file:// as + * the pathname. + */ + if (pcap_strcasecmp(scheme, "file") == 0) { + *schemep = scheme; + *pathp = strdup(colonp + 3); + if (*pathp == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + return (0); + } + + /* + * The WinPcap documentation says you can specify a local + * interface with "rpcap://{device}"; we special-case + * that here. If the scheme is "rpcap", and there are + * no slashes past the "//", we just return the device. + * + * XXX - %-escaping? + */ + if (pcap_strcasecmp(scheme, "rpcap") == 0 && + strchr(colonp + 3, '/') == NULL) { + /* + * Local device. + * + * Return a NULL pointer for the scheme, user information, + * host, and port, and return the device as the path. + */ + free(scheme); + *pathp = strdup(colonp + 3); + if (*pathp == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + return (-1); + } + return (0); + } + + /* + * OK, now start parsing the authority. + * Get token, terminated with / or terminated at the end of + * the string. + */ + authority_len = strcspn(colonp + 3, "/"); + authority = get_substring(colonp + 3, authority_len, ebuf); + if (authority == NULL) { + /* + * Error. + */ + free(scheme); + return (-1); + } + endp = colonp + 3 + authority_len; + + /* + * Now carve the authority field into its components. + */ + parsep = authority; + + /* + * Is there a userinfo field? + */ + atsignp = strchr(parsep, '@'); + if (atsignp != NULL) { + /* + * Yes. + */ + size_t userinfo_len; + + userinfo_len = atsignp - parsep; + userinfo = get_substring(parsep, userinfo_len, ebuf); + if (userinfo == NULL) { + /* + * Error. + */ + free(authority); + free(scheme); + return (-1); + } + parsep = atsignp + 1; + } else { + /* + * No. + */ + userinfo = NULL; + } + + /* + * Is there a host field? + */ + if (*parsep == '\0') { + /* + * No; there's no host field or port field. + */ + host = NULL; + port = NULL; + } else { + /* + * Yes. + */ + size_t host_len; + + /* + * Is it an IP-literal? + */ + if (*parsep == '[') { + /* + * Yes. + * Treat verything up to the closing square + * bracket as the IP-Literal; we don't worry + * about whether it's a valid IPv6address or + * IPvFuture. + */ + bracketp = strchr(parsep, ']'); + if (bracketp == NULL) { + /* + * There's no closing square bracket. + */ + pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, + "IP-literal in URL doesn't end with ]"); + free(userinfo); + free(authority); + free(scheme); + return (-1); + } + if (*(bracketp + 1) != '\0' && + *(bracketp + 1) != ':') { + /* + * There's extra crud after the + * closing square bracketn. + */ + pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, + "Extra text after IP-literal in URL"); + free(userinfo); + free(authority); + free(scheme); + return (-1); + } + host_len = (bracketp - 1) - parsep; + host = get_substring(parsep + 1, host_len, ebuf); + if (host == NULL) { + /* + * Error. + */ + free(userinfo); + free(authority); + free(scheme); + return (-1); + } + parsep = bracketp + 1; + } else { + /* + * No. + * Treat everything up to a : or the end of + * the string as the host. + */ + host_len = strcspn(parsep, ":"); + host = get_substring(parsep, host_len, ebuf); + if (host == NULL) { + /* + * Error. + */ + free(userinfo); + free(authority); + free(scheme); + return (-1); + } + parsep = parsep + host_len; + } + + /* + * Is there a port field? + */ + if (*parsep == ':') { + /* + * Yes. It's the rest of the authority field. + */ + size_t port_len; + + parsep++; + port_len = strlen(parsep); + port = get_substring(parsep, port_len, ebuf); + if (port == NULL) { + /* + * Error. + */ + free(host); + free(userinfo); + free(authority); + free(scheme); + return (-1); + } + } else { + /* + * No. + */ + port = NULL; + } + } + free(authority); + + /* + * Everything else is the path. Strip off the leading /. + */ + if (*endp == '\0') + path = strdup(""); + else + path = strdup(endp + 1); + if (path == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + free(port); + free(host); + free(userinfo); + free(scheme); + return (-1); + } + *schemep = scheme; + *userinfop = userinfo; + *hostp = host; + *portp = port; + *pathp = path; + return (0); +} + +int +pcap_createsrcstr(char *source, int type, const char *host, const char *port, + const char *name, char *errbuf) +{ + switch (type) { + + case PCAP_SRC_FILE: + strlcpy(source, PCAP_SRC_FILE_STRING, PCAP_BUF_SIZE); + if (name != NULL && *name != '\0') { + strlcat(source, name, PCAP_BUF_SIZE); + return (0); + } else { + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + "The file name cannot be NULL."); + return (-1); + } + + case PCAP_SRC_IFREMOTE: + strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE); + if (host != NULL && *host != '\0') { + if (strchr(host, ':') != NULL) { + /* + * The host name contains a colon, so it's + * probably an IPv6 address, and needs to + * be included in square brackets. + */ + strlcat(source, "[", PCAP_BUF_SIZE); + strlcat(source, host, PCAP_BUF_SIZE); + strlcat(source, "]", PCAP_BUF_SIZE); + } else + strlcat(source, host, PCAP_BUF_SIZE); + + if (port != NULL && *port != '\0') { + strlcat(source, ":", PCAP_BUF_SIZE); + strlcat(source, port, PCAP_BUF_SIZE); + } + + strlcat(source, "/", PCAP_BUF_SIZE); + } else { + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + "The host name cannot be NULL."); + return (-1); + } + + if (name != NULL && *name != '\0') + strlcat(source, name, PCAP_BUF_SIZE); + + return (0); + + case PCAP_SRC_IFLOCAL: + strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE); + + if (name != NULL && *name != '\0') + strlcat(source, name, PCAP_BUF_SIZE); + + return (0); + + default: + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + "The interface type is not valid."); + return (-1); + } +} + +int +pcap_parsesrcstr(const char *source, int *type, char *host, char *port, + char *name, char *errbuf) +{ + char *scheme, *tmpuserinfo, *tmphost, *tmpport, *tmppath; + + /* Initialization stuff */ + if (host) + *host = '\0'; + if (port) + *port = '\0'; + if (name) + *name = '\0'; + + /* Parse the source string */ + if (pcap_parse_source(source, &scheme, &tmpuserinfo, &tmphost, + &tmpport, &tmppath, errbuf) == -1) { + /* + * Fail. + */ + return (-1); + } + + if (scheme == NULL) { + /* + * Local device. + */ + if (name && tmppath) + strlcpy(name, tmppath, PCAP_BUF_SIZE); + if (type) + *type = PCAP_SRC_IFLOCAL; + free(tmppath); + free(tmpport); + free(tmphost); + free(tmpuserinfo); + return (0); + } + + if (strcmp(scheme, "rpcap") == 0) { + /* + * rpcap:// + * + * pcap_parse_source() has already handled the case of + * rpcap://device + */ + if (host && tmphost) { + if (tmpuserinfo) + pcap_snprintf(host, PCAP_BUF_SIZE, "%s@%s", + tmpuserinfo, tmphost); + else + strlcpy(host, tmphost, PCAP_BUF_SIZE); + } + if (port && tmpport) + strlcpy(port, tmpport, PCAP_BUF_SIZE); + if (name && tmppath) + strlcpy(name, tmppath, PCAP_BUF_SIZE); + if (type) + *type = PCAP_SRC_IFREMOTE; + free(tmppath); + free(tmpport); + free(tmphost); + free(tmpuserinfo); + free(scheme); + return (0); + } + + if (strcmp(scheme, "file") == 0) { + /* + * file:// + */ + if (name && tmppath) + strlcpy(name, tmppath, PCAP_BUF_SIZE); + if (type) + *type = PCAP_SRC_FILE; + free(tmppath); + free(tmpport); + free(tmphost); + free(tmpuserinfo); + free(scheme); + return (0); + } + + /* + * Neither rpcap: nor file:; just treat the entire string + * as a local device. + */ + if (name) + strlcpy(name, source, PCAP_BUF_SIZE); + if (type) + *type = PCAP_SRC_IFLOCAL; + free(tmppath); + free(tmpport); + free(tmphost); + free(tmpuserinfo); + free(scheme); + return (0); +} +#endif + pcap_t * pcap_create(const char *device, char *errbuf) { @@ -410,8 +1995,9 @@ pcap_create(const char *device, char *errbuf) length = wcslen((wchar_t *)device); device_str = (char *)malloc(length + 1); if (device_str == NULL) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "malloc"); return (NULL); } @@ -422,8 +2008,8 @@ pcap_create(const char *device, char *errbuf) device_str = strdup(device); } if (device_str == NULL) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); return (NULL); } @@ -473,6 +2059,18 @@ pcap_create(const char *device, char *errbuf) return (p); } +/* + * Set nonblocking mode on an unactivated pcap_t; this sets a flag + * checked by pcap_activate(), which sets the mode after calling + * the activate routine. + */ +static int +pcap_setnonblock_unactivated(pcap_t *p, int nonblock) +{ + p->opt.nonblock = nonblock; + return (0); +} + static void initialize_ops(pcap_t *p) { @@ -487,7 +2085,6 @@ initialize_ops(pcap_t *p) p->setdirection_op = (setdirection_op_t)pcap_not_initialized; p->set_datalink_op = (set_datalink_op_t)pcap_not_initialized; p->getnonblock_op = (getnonblock_op_t)pcap_not_initialized; - p->setnonblock_op = (setnonblock_op_t)pcap_not_initialized; p->stats_op = (stats_op_t)pcap_not_initialized; #ifdef _WIN32 p->stats_ex_op = (stats_ex_op_t)pcap_not_initialized_ptr; @@ -532,8 +2129,8 @@ pcap_alloc_pcap_t(char *ebuf, size_t size) */ chunk = malloc(sizeof (pcap_t) + size); if (chunk == NULL) { - pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); return (NULL); } memset(chunk, 0, sizeof (pcap_t) + size); @@ -543,10 +2140,15 @@ pcap_alloc_pcap_t(char *ebuf, size_t size) */ p = (pcap_t *)chunk; -#ifndef _WIN32 +#ifdef _WIN32 + p->handle = INVALID_HANDLE_VALUE; /* not opened yet */ +#else /* _WIN32 */ p->fd = -1; /* not opened yet */ +#ifndef MSDOS p->selectable_fd = -1; -#endif + p->required_select_timeout = NULL; +#endif /* MSDOS */ +#endif /* _WIN32 */ if (size == 0) { /* No private data was requested. */ @@ -579,10 +2181,17 @@ pcap_create_common(char *ebuf, size_t size) */ p->can_set_rfmon_op = pcap_cant_set_rfmon; + /* + * If pcap_setnonblock() is called on a not-yet-activated + * pcap_t, default to setting a flag and turning + * on non-blocking mode when activated. + */ + p->setnonblock_op = pcap_setnonblock_unactivated; + initialize_ops(p); /* put in some defaults*/ - p->snapshot = MAXIMUM_SNAPLEN; /* max packet size */ + p->snapshot = 0; /* max packet size unspecified */ p->opt.timeout = 0; /* no timeout specified */ p->opt.buffer_size = 0; /* use the platform's default */ p->opt.promisc = 0; @@ -590,6 +2199,15 @@ pcap_create_common(char *ebuf, size_t size) p->opt.immediate = 0; p->opt.tstamp_type = -1; /* default to not setting time stamp type */ p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO; + /* + * Platform-dependent options. + */ +#ifdef __linux__ + p->opt.protocol = 0; +#endif +#ifdef _WIN32 + p->opt.nocapture_local = 0; +#endif /* * Start out with no BPF code generation flags set. @@ -615,16 +2233,6 @@ pcap_set_snaplen(pcap_t *p, int snaplen) { if (pcap_check_activated(p)) return (PCAP_ERROR_ACTIVATED); - - /* - * Turn invalid values, or excessively large values, into - * the maximum allowed value. - * - * If some application really *needs* a bigger snapshot - * length, we should just increase MAXIMUM_SNAPLEN. - */ - if (snaplen <= 0 || snaplen > MAXIMUM_SNAPLEN) - snaplen = MAXIMUM_SNAPLEN; p->snapshot = snaplen; return (0); } @@ -795,9 +2403,25 @@ pcap_activate(pcap_t *p) if (pcap_check_activated(p)) return (PCAP_ERROR_ACTIVATED); status = p->activate_op(p); - if (status >= 0) + if (status >= 0) { + /* + * If somebody requested non-blocking mode before + * calling pcap_activate(), turn it on now. + */ + if (p->opt.nonblock) { + status = p->setnonblock_op(p, 1); + if (status < 0) { + /* + * Failed. Undo everything done by + * the activate operation. + */ + p->cleanup_op(p); + initialize_ops(p); + return (status); + } + } p->activated = 1; - else { + } else { if (p->errbuf[0] == '\0') { /* * No error message supplied by the activate routine; @@ -823,6 +2447,53 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er { pcap_t *p; int status; +#ifdef ENABLE_REMOTE + char host[PCAP_BUF_SIZE + 1]; + char port[PCAP_BUF_SIZE + 1]; + char name[PCAP_BUF_SIZE + 1]; + int srctype; + + /* + * Retrofit - we have to make older applications compatible with + * remote capture. + * So we're calling pcap_open_remote() from here; this is a very + * dirty hack. + * Obviously, we cannot exploit all the new features; for instance, + * we cannot send authentication, we cannot use a UDP data connection, + * and so on. + */ + if (pcap_parsesrcstr(device, &srctype, host, port, name, errbuf)) + return (NULL); + + if (srctype == PCAP_SRC_IFREMOTE) { + /* + * Although we already have host, port and iface, we prefer + * to pass only 'device' to pcap_open_rpcap(), so that it has + * to call pcap_parsesrcstr() again. + * This is less optimized, but much clearer. + */ + return (pcap_open_rpcap(device, snaplen, + promisc ? PCAP_OPENFLAG_PROMISCUOUS : 0, to_ms, + NULL, errbuf)); + } + if (srctype == PCAP_SRC_FILE) { + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "unknown URL scheme \"file\""); + return (NULL); + } + if (srctype == PCAP_SRC_IFLOCAL) { + /* + * If it starts with rpcap://, that refers to a local device + * (no host part in the URL). Remove the rpcap://, and + * fall through to the regular open path. + */ + if (strncmp(device, PCAP_SRC_IF_STRING, strlen(PCAP_SRC_IF_STRING)) == 0) { + size_t len = strlen(device) - strlen(PCAP_SRC_IF_STRING) + 1; + + if (len > 0) + device += strlen(PCAP_SRC_IF_STRING); + } + } +#endif /* ENABLE_REMOTE */ p = pcap_create(device, errbuf); if (p == NULL) @@ -956,8 +2627,8 @@ pcap_list_datalinks(pcap_t *p, int **dlt_buffer) */ *dlt_buffer = (int*)malloc(sizeof(**dlt_buffer)); if (*dlt_buffer == NULL) { - (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "malloc"); return (PCAP_ERROR); } **dlt_buffer = p->linktype; @@ -965,8 +2636,8 @@ pcap_list_datalinks(pcap_t *p, int **dlt_buffer) } else { *dlt_buffer = (int*)calloc(sizeof(**dlt_buffer), p->dlt_count); if (*dlt_buffer == NULL) { - (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf), - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), + errno, "malloc"); return (PCAP_ERROR); } (void)memcpy(*dlt_buffer, p->dlt_list, @@ -1281,6 +2952,15 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(WATTSTOPPER_DLM, "WattStopper Digital Lighting Management (DLM) and Legrand Nitoo Open protocol"), DLT_CHOICE(ISO_14443, "ISO 14443 messages"), DLT_CHOICE(RDS, "IEC 62106 Radio Data System groups"), + DLT_CHOICE(USB_DARWIN, "USB with Darwin header"), + DLT_CHOICE(OPENFLOW, "OpenBSD DLT_OPENFLOW"), + DLT_CHOICE(SDLC, "IBM SDLC frames"), + DLT_CHOICE(TI_LLN_SNIFFER, "TI LLN sniffer frames"), + DLT_CHOICE(VSOCK, "Linux vsock"), + DLT_CHOICE(NORDIC_BLE, "Nordic Semiconductor Bluetooth LE sniffer frames"), + DLT_CHOICE(DOCSIS31_XRA31, "Excentis XRA-31 DOCSIS 3.1 RF sniffer frames"), + DLT_CHOICE(ETHERNET_MPACKET, "802.3br mPackets"), + DLT_CHOICE(DISPLAYPORT_AUX, "DisplayPort AUX channel monitoring data"), DLT_CHOICE_SENTINEL }; @@ -1403,6 +3083,14 @@ pcap_minor_version(pcap_t *p) return (p->version_minor); } +int +pcap_bufsize(pcap_t *p) +{ + if (!p->activated) + return (PCAP_ERROR_NOT_ACTIVATED); + return (p->bufsize); +} + FILE * pcap_file(pcap_t *p) { @@ -1415,8 +3103,8 @@ pcap_fileno(pcap_t *p) #ifndef _WIN32 return (p->fd); #else - if (p->adapter != NULL) - return ((int)(DWORD)p->adapter->hFile); + if (p->handle != INVALID_HANDLE_VALUE) + return ((int)(DWORD)p->handle); else return (PCAP_ERROR); #endif @@ -1428,6 +3116,12 @@ pcap_get_selectable_fd(pcap_t *p) { return (p->selectable_fd); } + +struct timeval * +pcap_get_required_select_timeout(pcap_t *p) +{ + return (p->required_select_timeout); +} #endif void @@ -1447,14 +3141,18 @@ pcap_getnonblock(pcap_t *p, char *errbuf) { int ret; - ret = p->getnonblock_op(p, errbuf); + ret = p->getnonblock_op(p); if (ret == -1) { /* - * In case somebody depended on the bug wherein - * the error message was put into p->errbuf - * by pcap_getnonblock_fd(). + * The get nonblock operation sets p->errbuf; this + * function *shouldn't* have had a separate errbuf + * argument, as it didn't need one, but I goofed + * when adding it. + * + * We copy the error message to errbuf, so callers + * can find it in either place. */ - strlcpy(p->errbuf, errbuf, PCAP_ERRBUF_SIZE); + strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE); } return (ret); } @@ -1465,14 +3163,14 @@ pcap_getnonblock(pcap_t *p, char *errbuf) */ #if !defined(_WIN32) && !defined(MSDOS) int -pcap_getnonblock_fd(pcap_t *p, char *errbuf) +pcap_getnonblock_fd(pcap_t *p) { int fdflags; fdflags = fcntl(p->fd, F_GETFL, 0); if (fdflags == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_GETFL: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "F_GETFL"); return (-1); } if (fdflags & O_NONBLOCK) @@ -1487,14 +3185,18 @@ pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf) { int ret; - ret = p->setnonblock_op(p, nonblock, errbuf); + ret = p->setnonblock_op(p, nonblock); if (ret == -1) { /* - * In case somebody depended on the bug wherein - * the error message was put into p->errbuf - * by pcap_setnonblock_fd(). + * The set nonblock operation sets p->errbuf; this + * function *shouldn't* have had a separate errbuf + * argument, as it didn't need one, but I goofed + * when adding it. + * + * We copy the error message to errbuf, so callers + * can find it in either place. */ - strlcpy(p->errbuf, errbuf, PCAP_ERRBUF_SIZE); + strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE); } return (ret); } @@ -1507,14 +3209,14 @@ pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf) * needs to do some additional work.) */ int -pcap_setnonblock_fd(pcap_t *p, int nonblock, char *errbuf) +pcap_setnonblock_fd(pcap_t *p, int nonblock) { int fdflags; fdflags = fcntl(p->fd, F_GETFL, 0); if (fdflags == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_GETFL: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "F_GETFL"); return (-1); } if (nonblock) @@ -1522,8 +3224,8 @@ pcap_setnonblock_fd(pcap_t *p, int nonblock, char *errbuf) else fdflags &= ~O_NONBLOCK; if (fcntl(p->fd, F_SETFL, fdflags) == -1) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_SETFL: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "F_SETFL"); return (-1); } return (0); @@ -1627,9 +3329,9 @@ pcap_strerror(int errnum) #ifdef HAVE_STRERROR #ifdef _WIN32 static char errbuf[PCAP_ERRBUF_SIZE]; - errno_t errno; - errno = strerror_s(errbuf, PCAP_ERRBUF_SIZE, errnum); - if (errno != 0) /* errno = 0 if successful */ + errno_t err = strerror_s(errbuf, PCAP_ERRBUF_SIZE, errnum); + + if (err != 0) /* err = 0 if successful */ strlcpy(errbuf, "strerror_s() error", PCAP_ERRBUF_SIZE); return (errbuf); #else @@ -1676,14 +3378,6 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps) return (p->stats_op(p, ps)); } -static int -pcap_stats_dead(pcap_t *p, struct pcap_stat *ps _U_) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "Statistics aren't available from a pcap_open_dead pcap_t"); - return (-1); -} - #ifdef _WIN32 struct pcap_stat * pcap_stats_ex(pcap_t *p, int *pcap_stat_size) @@ -1697,86 +3391,36 @@ pcap_setbuff(pcap_t *p, int dim) return (p->setbuff_op(p, dim)); } -static int -pcap_setbuff_dead(pcap_t *p, int dim) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "The kernel buffer size cannot be set on a pcap_open_dead pcap_t"); - return (-1); -} - int pcap_setmode(pcap_t *p, int mode) { return (p->setmode_op(p, mode)); } -static int -pcap_setmode_dead(pcap_t *p, int mode) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "impossible to set mode on a pcap_open_dead pcap_t"); - return (-1); -} - int pcap_setmintocopy(pcap_t *p, int size) { return (p->setmintocopy_op(p, size)); } -static int -pcap_setmintocopy_dead(pcap_t *p, int size) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "The mintocopy parameter cannot be set on a pcap_open_dead pcap_t"); - return (-1); -} - HANDLE pcap_getevent(pcap_t *p) { return (p->getevent_op(p)); } -static HANDLE -pcap_getevent_dead(pcap_t *p) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "A pcap_open_dead pcap_t has no event handle"); - return (INVALID_HANDLE_VALUE); -} - int pcap_oid_get_request(pcap_t *p, bpf_u_int32 oid, void *data, size_t *lenp) { return (p->oid_get_request_op(p, oid, data, lenp)); } -static int -pcap_oid_get_request_dead(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, - size_t *lenp _U_) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "An OID get request cannot be performed on a pcap_open_dead pcap_t"); - return (PCAP_ERROR); -} - int pcap_oid_set_request(pcap_t *p, bpf_u_int32 oid, const void *data, size_t *lenp) { return (p->oid_set_request_op(p, oid, data, lenp)); } -static int -pcap_oid_set_request_dead(pcap_t *p, bpf_u_int32 oid _U_, const void *data _U_, - size_t *lenp _U_) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "An OID set request cannot be performed on a pcap_open_dead pcap_t"); - return (PCAP_ERROR); -} - pcap_send_queue * pcap_sendqueue_alloc(u_int memsize) { @@ -1832,56 +3476,24 @@ pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue *queue, int sync) return (p->sendqueue_transmit_op(p, queue, sync)); } -static u_int -pcap_sendqueue_transmit_dead(pcap_t *p, pcap_send_queue *queue, int sync) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "Packets cannot be transmitted on a pcap_open_dead pcap_t"); - return (0); -} - int pcap_setuserbuffer(pcap_t *p, int size) { return (p->setuserbuffer_op(p, size)); } -static int -pcap_setuserbuffer_dead(pcap_t *p, int size) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "The user buffer cannot be set on a pcap_open_dead pcap_t"); - return (-1); -} - int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks) { return (p->live_dump_op(p, filename, maxsize, maxpacks)); } -static int -pcap_live_dump_dead(pcap_t *p, char *filename, int maxsize, int maxpacks) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "Live packet dumping cannot be performed on a pcap_open_dead pcap_t"); - return (-1); -} - int pcap_live_dump_ended(pcap_t *p, int sync) { return (p->live_dump_ended_op(p, sync)); } -static int -pcap_live_dump_ended_dead(pcap_t *p, int sync) -{ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "Live packet dumping cannot be performed on a pcap_open_dead pcap_t"); - return (-1); -} - PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p) { @@ -1894,12 +3506,6 @@ pcap_get_airpcap_handle(pcap_t *p) } return (handle); } - -static PAirpcapHandle -pcap_get_airpcap_handle_dead(pcap_t *p) -{ - return (NULL); -} #endif /* @@ -2022,66 +3628,6 @@ pcap_cleanup_live_common(pcap_t *p) #endif } -static void -pcap_cleanup_dead(pcap_t *p _U_) -{ - /* Nothing to do. */ -} - -pcap_t * -pcap_open_dead_with_tstamp_precision(int linktype, int snaplen, u_int precision) -{ - pcap_t *p; - - switch (precision) { - - case PCAP_TSTAMP_PRECISION_MICRO: - case PCAP_TSTAMP_PRECISION_NANO: - break; - - default: - return NULL; - } - p = malloc(sizeof(*p)); - if (p == NULL) - return NULL; - memset (p, 0, sizeof(*p)); - p->snapshot = snaplen; - p->linktype = linktype; - p->opt.tstamp_precision = precision; - p->stats_op = pcap_stats_dead; -#ifdef _WIN32 - p->stats_ex_op = (stats_ex_op_t)pcap_not_initialized_ptr; - p->setbuff_op = pcap_setbuff_dead; - p->setmode_op = pcap_setmode_dead; - p->setmintocopy_op = pcap_setmintocopy_dead; - p->getevent_op = pcap_getevent_dead; - p->oid_get_request_op = pcap_oid_get_request_dead; - p->oid_set_request_op = pcap_oid_set_request_dead; - p->sendqueue_transmit_op = pcap_sendqueue_transmit_dead; - p->setuserbuffer_op = pcap_setuserbuffer_dead; - p->live_dump_op = pcap_live_dump_dead; - p->live_dump_ended_op = pcap_live_dump_ended_dead; - p->get_airpcap_handle_op = pcap_get_airpcap_handle_dead; -#endif - p->cleanup_op = pcap_cleanup_dead; - - /* - * A "dead" pcap_t never requires special BPF code generation. - */ - p->bpf_codegen_flags = 0; - - p->activated = 1; - return (p); -} - -pcap_t * -pcap_open_dead(int linktype, int snaplen) -{ - return (pcap_open_dead_with_tstamp_precision(linktype, snaplen, - PCAP_TSTAMP_PRECISION_MICRO)); -} - /* * API compatible with WinPcap's "send a packet" routine - returns -1 * on error, 0 otherwise. @@ -2133,160 +3679,251 @@ pcap_offline_filter(const struct bpf_program *fp, const struct pcap_pkthdr *h, return (0); } -#include "pcap_version.h" +static int +pcap_can_set_rfmon_dead(pcap_t *p) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Rfmon mode doesn't apply on a pcap_open_dead pcap_t"); + return (PCAP_ERROR); +} + +static int +pcap_read_dead(pcap_t *p, int cnt _U_, pcap_handler callback _U_, + u_char *user _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Packets aren't available from a pcap_open_dead pcap_t"); + return (-1); +} + +static int +pcap_inject_dead(pcap_t *p, const void *buf _U_, size_t size _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Packets can't be sent on a pcap_open_dead pcap_t"); + return (-1); +} + +static int +pcap_setfilter_dead(pcap_t *p, struct bpf_program *fp _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "A filter cannot be set on a pcap_open_dead pcap_t"); + return (-1); +} + +static int +pcap_setdirection_dead(pcap_t *p, pcap_direction_t d _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "The packet direction cannot be set on a pcap_open_dead pcap_t"); + return (-1); +} + +static int +pcap_set_datalink_dead(pcap_t *p, int dlt _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "The link-layer header type cannot be set on a pcap_open_dead pcap_t"); + return (-1); +} + +static int +pcap_getnonblock_dead(pcap_t *p) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "A pcap_open_dead pcap_t does not have a non-blocking mode setting"); + return (-1); +} + +static int +pcap_setnonblock_dead(pcap_t *p, int nonblock _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "A pcap_open_dead pcap_t does not have a non-blocking mode setting"); + return (-1); +} + +static int +pcap_stats_dead(pcap_t *p, struct pcap_stat *ps _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Statistics aren't available from a pcap_open_dead pcap_t"); + return (-1); +} #ifdef _WIN32 +struct pcap_stat * +pcap_stats_ex_dead(pcap_t *p, int *pcap_stat_size _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Statistics aren't available from a pcap_open_dead pcap_t"); + return (NULL); +} -static char *full_pcap_version_string; +static int +pcap_setbuff_dead(pcap_t *p, int dim) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "The kernel buffer size cannot be set on a pcap_open_dead pcap_t"); + return (-1); +} -#ifdef HAVE_VERSION_H -/* - * libpcap being built for Windows, as part of a WinPcap/Npcap source - * tree. Include version.h from that source tree to get the WinPcap/Npcap - * version. - * - * XXX - it'd be nice if we could somehow generate the WinPcap version number - * when building WinPcap. (It'd be nice to do so for the packet.dll version - * number as well.) - */ -#include "../../version.h" +static int +pcap_setmode_dead(pcap_t *p, int mode) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "impossible to set mode on a pcap_open_dead pcap_t"); + return (-1); +} -static const char wpcap_version_string[] = WINPCAP_VER_STRING; -static const char pcap_version_string_fmt[] = - WINPCAP_PRODUCT_NAME " version %s, based on %s"; -static const char pcap_version_string_packet_dll_fmt[] = - WINPCAP_PRODUCT_NAME " version %s (packet.dll version %s), based on %s"; +static int +pcap_setmintocopy_dead(pcap_t *p, int size) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "The mintocopy parameter cannot be set on a pcap_open_dead pcap_t"); + return (-1); +} -const char * -pcap_lib_version(void) +static HANDLE +pcap_getevent_dead(pcap_t *p) { - char *packet_version_string; - size_t full_pcap_version_string_len; + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "A pcap_open_dead pcap_t has no event handle"); + return (INVALID_HANDLE_VALUE); +} - if (full_pcap_version_string == NULL) { - /* - * Generate the version string. - */ - packet_version_string = PacketGetVersion(); - if (strcmp(wpcap_version_string, packet_version_string) == 0) { - /* - * WinPcap version string and packet.dll version - * string are the same; just report the WinPcap - * version. - */ - full_pcap_version_string_len = - (sizeof pcap_version_string_fmt - 4) + - strlen(wpcap_version_string) + - strlen(pcap_version_string); - full_pcap_version_string = - malloc(full_pcap_version_string_len); - if (full_pcap_version_string == NULL) - return (NULL); - pcap_snprintf(full_pcap_version_string, - full_pcap_version_string_len, - pcap_version_string_fmt, - wpcap_version_string, - pcap_version_string); - } else { - /* - * WinPcap version string and packet.dll version - * string are different; that shouldn't be the - * case (the two libraries should come from the - * same version of WinPcap), so we report both - * versions. - */ - full_pcap_version_string_len = - (sizeof pcap_version_string_packet_dll_fmt - 6) + - strlen(wpcap_version_string) + - strlen(packet_version_string) + - strlen(pcap_version_string); - full_pcap_version_string = malloc(full_pcap_version_string_len); - if (full_pcap_version_string == NULL) - return (NULL); - pcap_snprintf(full_pcap_version_string, - full_pcap_version_string_len, - pcap_version_string_packet_dll_fmt, - wpcap_version_string, - packet_version_string, - pcap_version_string); - } - } - return (full_pcap_version_string); +static int +pcap_oid_get_request_dead(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, + size_t *lenp _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "An OID get request cannot be performed on a pcap_open_dead pcap_t"); + return (PCAP_ERROR); } -#else /* HAVE_VERSION_H */ +static int +pcap_oid_set_request_dead(pcap_t *p, bpf_u_int32 oid _U_, const void *data _U_, + size_t *lenp _U_) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "An OID set request cannot be performed on a pcap_open_dead pcap_t"); + return (PCAP_ERROR); +} -/* - * libpcap being built for Windows, not as part of a WinPcap/Npcap source - * tree. - */ -static const char pcap_version_string_packet_dll_fmt[] = - "%s (packet.dll version %s)"; -const char * -pcap_lib_version(void) +static u_int +pcap_sendqueue_transmit_dead(pcap_t *p, pcap_send_queue *queue, int sync) { - char *packet_version_string; - size_t full_pcap_version_string_len; + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Packets cannot be transmitted on a pcap_open_dead pcap_t"); + return (0); +} - if (full_pcap_version_string == NULL) { - /* - * Generate the version string. Report the packet.dll - * version. - */ - packet_version_string = PacketGetVersion(); - full_pcap_version_string_len = - (sizeof pcap_version_string_packet_dll_fmt - 4) + - strlen(pcap_version_string) + - strlen(packet_version_string); - full_pcap_version_string = malloc(full_pcap_version_string_len); - if (full_pcap_version_string == NULL) - return (NULL); - pcap_snprintf(full_pcap_version_string, - full_pcap_version_string_len, - pcap_version_string_packet_dll_fmt, - pcap_version_string, - packet_version_string); - } - return (full_pcap_version_string); +static int +pcap_setuserbuffer_dead(pcap_t *p, int size) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "The user buffer cannot be set on a pcap_open_dead pcap_t"); + return (-1); } -#endif /* HAVE_VERSION_H */ +static int +pcap_live_dump_dead(pcap_t *p, char *filename, int maxsize, int maxpacks) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Live packet dumping cannot be performed on a pcap_open_dead pcap_t"); + return (-1); +} -#elif defined(MSDOS) +static int +pcap_live_dump_ended_dead(pcap_t *p, int sync) +{ + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Live packet dumping cannot be performed on a pcap_open_dead pcap_t"); + return (-1); +} + +static PAirpcapHandle +pcap_get_airpcap_handle_dead(pcap_t *p) +{ + return (NULL); +} +#endif /* _WIN32 */ -static char *full_pcap_version_string; +static void +pcap_cleanup_dead(pcap_t *p _U_) +{ + /* Nothing to do. */ +} -const char * -pcap_lib_version (void) +pcap_t * +pcap_open_dead_with_tstamp_precision(int linktype, int snaplen, u_int precision) { - char *packet_version_string; - size_t full_pcap_version_string_len; - static char dospfx[] = "DOS-"; + pcap_t *p; + + switch (precision) { + + case PCAP_TSTAMP_PRECISION_MICRO: + case PCAP_TSTAMP_PRECISION_NANO: + break; - if (full_pcap_version_string == NULL) { + default: /* - * Generate the version string. + * This doesn't really matter, but we don't have any way + * to report particular errors, so the only failure we + * should have is a memory allocation failure. Just + * pick microsecond precision. */ - full_pcap_version_string_len = - sizeof dospfx + strlen(pcap_version_string); - full_pcap_version_string = - malloc(full_pcap_version_string_len); - if (full_pcap_version_string == NULL) - return (NULL); - strcpy(full_pcap_version_string, dospfx); - strcat(full_pcap_version_string, pcap_version_string); + precision = PCAP_TSTAMP_PRECISION_MICRO; + break; } - return (full_pcap_version_string); -} + p = malloc(sizeof(*p)); + if (p == NULL) + return NULL; + memset (p, 0, sizeof(*p)); + p->snapshot = snaplen; + p->linktype = linktype; + p->opt.tstamp_precision = precision; + p->can_set_rfmon_op = pcap_can_set_rfmon_dead; + p->read_op = pcap_read_dead; + p->inject_op = pcap_inject_dead; + p->setfilter_op = pcap_setfilter_dead; + p->setdirection_op = pcap_setdirection_dead; + p->set_datalink_op = pcap_set_datalink_dead; + p->getnonblock_op = pcap_getnonblock_dead; + p->setnonblock_op = pcap_setnonblock_dead; + p->stats_op = pcap_stats_dead; +#ifdef _WIN32 + p->stats_ex_op = pcap_stats_ex_dead; + p->setbuff_op = pcap_setbuff_dead; + p->setmode_op = pcap_setmode_dead; + p->setmintocopy_op = pcap_setmintocopy_dead; + p->getevent_op = pcap_getevent_dead; + p->oid_get_request_op = pcap_oid_get_request_dead; + p->oid_set_request_op = pcap_oid_set_request_dead; + p->sendqueue_transmit_op = pcap_sendqueue_transmit_dead; + p->setuserbuffer_op = pcap_setuserbuffer_dead; + p->live_dump_op = pcap_live_dump_dead; + p->live_dump_ended_op = pcap_live_dump_ended_dead; + p->get_airpcap_handle_op = pcap_get_airpcap_handle_dead; +#endif + p->cleanup_op = pcap_cleanup_dead; -#else /* UN*X */ + /* + * A "dead" pcap_t never requires special BPF code generation. + */ + p->bpf_codegen_flags = 0; -const char * -pcap_lib_version(void) + p->activated = 1; + return (p); +} + +pcap_t * +pcap_open_dead(int linktype, int snaplen) { - return (pcap_version_string); + return (pcap_open_dead_with_tstamp_precision(linktype, snaplen, + PCAP_TSTAMP_PRECISION_MICRO)); } -#endif #ifdef YYDEBUG /* @@ -2306,32 +3943,6 @@ PCAP_API void pcap_set_parser_debug(int value); PCAP_API_DEF void pcap_set_parser_debug(int value) { - extern int pcap_debug; - pcap_debug = value; } #endif - -#ifdef BDEBUG -/* - * Set the internal "debug printout" flag for the filter expression optimizer. - * The code to print that stuff is present only if BDEBUG is defined, so - * the flag, and the routine to set it, are defined only if BDEBUG is - * defined. - * - * This is intended for libpcap developers, not for general use. - * If you want to set these in a program, you'll have to declare this - * routine yourself, with the appropriate DLL import attribute on Windows; - * it's not declared in any header file, and won't be declared in any - * header file provided by libpcap. - */ -PCAP_API void pcap_set_optimizer_debug(int value); - -PCAP_API_DEF void -pcap_set_optimizer_debug(int value) -{ - extern int pcap_optimizer_debug; - - pcap_optimizer_debug = value; -} -#endif diff --git a/freebsd/contrib/libpcap/pcap/can_socketcan.h b/freebsd/contrib/libpcap/pcap/can_socketcan.h index 68d2a131..332d9ff5 100644 --- a/freebsd/contrib/libpcap/pcap/can_socketcan.h +++ b/freebsd/contrib/libpcap/pcap/can_socketcan.h @@ -39,16 +39,18 @@ #ifndef lib_pcap_can_socketcan_h #define lib_pcap_can_socketcan_h +#include <pcap/pcap-inttypes.h> + /* * SocketCAN header, as per Documentation/networking/can.txt in the * Linux source. */ typedef struct { - u_int32_t can_id; - u_int8_t payload_length; - u_int8_t pad; - u_int8_t reserved1; - u_int8_t reserved2; + uint32_t can_id; + uint8_t payload_length; + uint8_t pad; + uint8_t reserved1; + uint8_t reserved2; } pcap_can_socketcan_hdr; #endif diff --git a/freebsd/contrib/libpcap/pcap/compiler-tests.h b/freebsd/contrib/libpcap/pcap/compiler-tests.h new file mode 100644 index 00000000..5e17853a --- /dev/null +++ b/freebsd/contrib/libpcap/pcap/compiler-tests.h @@ -0,0 +1,163 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_compiler_tests_h +#define lib_pcap_compiler_tests_h + +/* + * This was introduced by Clang: + * + * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute + * + * in some version (which version?); it has been picked up by GCC 5.0. + */ +#ifndef __has_attribute + /* + * It's a macro, so you can check whether it's defined to check + * whether it's supported. + * + * If it's not, define it to always return 0, so that we move on to + * the fallback checks. + */ + #define __has_attribute(x) 0 +#endif + +/* + * Note that the C90 spec's "6.8.1 Conditional inclusion" and the + * C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say: + * + * Prior to evaluation, macro invocations in the list of preprocessing + * tokens that will become the controlling constant expression are + * replaced (except for those macro names modified by the defined unary + * operator), just as in normal text. If the token "defined" is + * generated as a result of this replacement process or use of the + * "defined" unary operator does not match one of the two specified + * forms prior to macro replacement, the behavior is undefined. + * + * so you shouldn't use defined() in a #define that's used in #if or + * #elif. Some versions of Clang, for example, will warn about this. + * + * Instead, we check whether the pre-defined macros for particular + * compilers are defined and, if not, define the "is this version XXX + * or a later version of this compiler" macros as 0. + */ + +/* + * Check whether this is GCC major.minor or a later release, or some + * compiler that claims to be "just like GCC" of that version or a + * later release. + */ + +#if ! defined(__GNUC__) +#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 +#else +#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ + (__GNUC__ > (major) || \ + (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) +#endif + +/* + * Check whether this is Clang major.minor or a later release. + */ + +#if !defined(__clang__) +#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 +#else +#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \ + (__clang_major__ > (major) || \ + (__clang_major__ == (major) && __clang_minor__ >= (minor))) +#endif + +/* + * Check whether this is Sun C/SunPro C/Oracle Studio major.minor + * or a later release. + * + * The version number in __SUNPRO_C is encoded in hex BCD, with the + * uppermost hex digit being the major version number, the next + * one or two hex digits being the minor version number, and + * the last digit being the patch version. + * + * It represents the *compiler* version, not the product version; + * see + * + * https://sourceforge.net/p/predef/wiki/Compilers/ + * + * for a partial mapping, which we assume continues for later + * 12.x product releases. + */ + +#if ! defined(__SUNPRO_C) +#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0 +#else +#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \ + (((minor) >= 10) ? \ + (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \ + (((major) << 8) | ((minor) << 4))) +#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \ + (__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor))) +#endif + +/* + * Check whether this is IBM XL C major.minor or a later release. + * + * The version number in __xlC__ has the major version in the + * upper 8 bits and the minor version in the lower 8 bits. + */ + +#if ! defined(__xlC__) +#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 +#else +#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + (__xlC__ >= (((major) << 8) | (minor))) +#endif + +/* + * Check whether this is HP aC++/HP C major.minor or a later release. + * + * The version number in __HP_aCC is encoded in zero-padded decimal BCD, + * with the "A." stripped off, the uppermost two decimal digits being + * the major version number, the next two decimal digits being the minor + * version number, and the last two decimal digits being the patch version. + * (Strip off the A., remove the . between the major and minor version + * number, and add two digits of patch.) + */ + +#if ! defined(__HP_aCC) +#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0 +#else +#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \ + (__HP_aCC >= ((major)*10000 + (minor)*100)) +#endif + +#endif /* lib_pcap_funcattrs_h */ diff --git a/freebsd/contrib/libpcap/pcap/export-defs.h b/freebsd/contrib/libpcap/pcap/export-defs.h deleted file mode 100644 index a2350579..00000000 --- a/freebsd/contrib/libpcap/pcap/export-defs.h +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ -/* - * Copyright (c) 1993, 1994, 1995, 1996, 1997 - * 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 the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lib_pcap_export_defs_h -#define lib_pcap_export_defs_h - -/* - * PCAP_API_DEF must be used when defining *data* exported from - * libpcap. It can be used when defining *functions* exported - * from libpcap, but it doesn't have to be used there. It - * should not be used in declarations in headers. - * - * PCAP_API must be used when *declaring* data or functions - * exported from libpcap; PCAP_API_DEF won't work on all platforms. - */ - -/* - * Check whether this is GCC major.minor or a later release, or some - * compiler that claims to be "just like GCC" of that version or a - * later release. - */ -#define IS_AT_LEAST_GNUC_VERSION(major, minor) \ - (defined(__GNUC__) && \ - (__GNUC__ > (major) || \ - (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))) - -#if defined(_WIN32) - #ifdef BUILDING_PCAP - /* - * We're compiling libpcap, so we should export functions in our - * API. - */ - #define PCAP_API_DEF __declspec(dllexport) - #else - #define PCAP_API_DEF __declspec(dllimport) - #endif -#elif defined(MSDOS) - /* XXX - does this need special treatment? */ - #define PCAP_API_DEF -#else /* UN*X */ - #ifdef BUILDING_PCAP - /* - * We're compiling libpcap, so we should export functions in our API. - * The compiler might be configured not to export functions from a - * shared library by default, so we might have to explicitly mark - * functions as exported. - */ - #if IS_AT_LEAST_GNUC_VERSION(3, 4) - /* - * GCC 3.4 or later, or some compiler asserting compatibility with - * GCC 3.4 or later, so we have __attribute__((visibility()). - */ - #define PCAP_API_DEF __attribute__((visibility("default"))) - #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) - /* - * Sun C 5.5 or later, so we have __global. - * (Sun C 5.9 and later also have __attribute__((visibility()), - * but there's no reason to prefer it with Sun C.) - */ - #define PCAP_API_DEF __global - #else - /* - * We don't have anything to say. - */ - #define PCAP_API_DEF - #endif - #else - /* - * We're not building libpcap. - */ - #define PCAP_API_DEF - #endif -#endif /* _WIN32/MSDOS/UN*X */ - -#define PCAP_API PCAP_API_DEF extern - -#endif /* lib_pcap_export_defs_h */ diff --git a/freebsd/contrib/libpcap/pcap/funcattrs.h b/freebsd/contrib/libpcap/pcap/funcattrs.h new file mode 100644 index 00000000..a8b1932f --- /dev/null +++ b/freebsd/contrib/libpcap/pcap/funcattrs.h @@ -0,0 +1,261 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lib_pcap_funcattrs_h +#define lib_pcap_funcattrs_h + +#include <pcap/compiler-tests.h> + +/* + * Attributes to apply to functions and their arguments, using various + * compiler-specific extensions. + */ + +/* + * PCAP_API_DEF must be used when defining *data* exported from + * libpcap. It can be used when defining *functions* exported + * from libpcap, but it doesn't have to be used there. It + * should not be used in declarations in headers. + * + * PCAP_API must be used when *declaring* data or functions + * exported from libpcap; PCAP_API_DEF won't work on all platforms. + */ + +#if defined(_WIN32) + /* + * For Windows: + * + * when building libpcap: + * + * if we're building it as a DLL, we have to declare API + * functions with __declspec(dllexport); + * + * if we're building it as a static library, we don't want + * to do so. + * + * when using libpcap: + * + * if we're using the DLL, calls to its functions are a + * little more efficient if they're declared with + * __declspec(dllimport); + * + * if we're not using the dll, we don't want to declare + * them that way. + * + * So: + * + * if pcap_EXPORTS is defined, we define PCAP_API_DEF as + * __declspec(dllexport); + * + * if PCAP_DLL is defined, we define PCAP_API_DEF as + * __declspec(dllimport); + * + * otherwise, we define PCAP_API_DEF as nothing. + */ + #if defined(pcap_EXPORTS) + /* + * We're compiling libpcap as a DLL, so we should export functions + * in our API. + */ + #define PCAP_API_DEF __declspec(dllexport) + #elif defined(PCAP_DLL) + /* + * We're using libpcap as a DLL, so the calls will be a little more + * efficient if we explicitly import the functions. + */ + #define PCAP_API_DEF __declspec(dllimport) + #else + /* + * Either we're building libpcap as a static library, or we're using + * it as a static library, or we don't know for certain that we're + * using it as a dynamic library, so neither import nor export the + * functions explicitly. + */ + #define PCAP_API_DEF + #endif +#elif defined(MSDOS) + /* XXX - does this need special treatment? */ + #define PCAP_API_DEF +#else /* UN*X */ + #ifdef pcap_EXPORTS + /* + * We're compiling libpcap as a (dynamic) shared library, so we should + * export functions in our API. The compiler might be configured not + * to export functions from a shared library by default, so we might + * have to explicitly mark functions as exported. + */ + #if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) \ + || PCAP_IS_AT_LEAST_XL_C_VERSION(12,0) + /* + * GCC 3.4 or later, or some compiler asserting compatibility with + * GCC 3.4 or later, or XL C 13.0 or later, so we have + * __attribute__((visibility()). + */ + #define PCAP_API_DEF __attribute__((visibility("default"))) + #elif PCAP_IS_AT_LEAST_SUNC_VERSION(5,5) + /* + * Sun C 5.5 or later, so we have __global. + * (Sun C 5.9 and later also have __attribute__((visibility()), + * but there's no reason to prefer it with Sun C.) + */ + #define PCAP_API_DEF __global + #else + /* + * We don't have anything to say. + */ + #define PCAP_API_DEF + #endif + #else + /* + * We're not building libpcap. + */ + #define PCAP_API_DEF + #endif +#endif /* _WIN32/MSDOS/UN*X */ + +#define PCAP_API PCAP_API_DEF extern + +/* + * PCAP_NORETURN, before a function declaration, means "this function + * never returns". (It must go before the function declaration, e.g. + * "extern PCAP_NORETURN func(...)" rather than after the function + * declaration, as the MSVC version has to go before the declaration.) + * + * PCAP_NORETURN_DEF, before a function *definition*, means "this + * function never returns"; it would be used only for static functions + * that are defined before any use, and thus have no declaration. + * (MSVC doesn't support that; I guess the "decl" in "__declspec" + * means "declaration", and __declspec doesn't work with definitions.) + */ +#if __has_attribute(noreturn) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(2,5) \ + || PCAP_IS_AT_LEAST_SUNC_VERSION(5,9) \ + || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \ + || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10) + /* + * Compiler with support for __attribute((noreturn)), or GCC 2.5 and + * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1 + * and later (do any earlier versions of XL C support this?), or + * HP aCC A.06.10 and later. + */ + #define PCAP_NORETURN __attribute((noreturn)) + #define PCAP_NORETURN_DEF __attribute((noreturn)) +#elif defined(_MSC_VER) + /* + * MSVC. + */ + #define PCAP_NORETURN __declspec(noreturn) + #define PCAP_NORETURN_DEF +#else + #define PCAP_NORETURN + #define PCAP_NORETURN_DEF +#endif + +/* + * PCAP_PRINTFLIKE(x,y), after a function declaration, means "this function + * does printf-style formatting, with the xth argument being the format + * string and the yth argument being the first argument for the format + * string". + */ +#if __has_attribute(__format__) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(2,3) \ + || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \ + || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10) + /* + * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1 + * and later (do any earlier versions of XL C support this?), + * or HP aCC A.06.10 and later. + */ + #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y))) +#else + #define PCAP_PRINTFLIKE(x,y) +#endif + +/* + * PCAP_DEPRECATED(func, msg), after a function declaration, marks the + * function as deprecated. + * + * The first argument is the name of the function; the second argument is + * a string giving the warning message to use if the compiler supports that. + * + * (Thank you, Microsoft, for requiring the function name.) + */ +#if __has_attribute(deprecated) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(4,5) \ + || PCAP_IS_AT_LEAST_SUNC_VERSION(5,13) + /* + * Compiler that supports __has_attribute and __attribute__((deprecated)), + * or GCC 4.5 and later, or Sun/Oracle C 12.4 (Sun C 5.13) or later. + * + * Those support __attribute__((deprecated(msg))) (we assume, perhaps + * incorrectly, that anything that supports __has_attribute() is + * recent enough to support __attribute__((deprecated(msg)))). + */ + #define PCAP_DEPRECATED(func, msg) __attribute__((deprecated(msg))) +#elif PCAP_IS_AT_LEAST_GNUC_VERSION(3,1) + /* + * GCC 3.1 through 4.4. + * + * Those support __attribute__((deprecated)) but not + * __attribute__((deprecated(msg))). + */ + #define PCAP_DEPRECATED(func, msg) __attribute__((deprecated)) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1500)) && !defined(BUILDING_PCAP) + /* + * MSVC from Visual Studio 2008 or later, and we're not building + * libpcap itself. + * + * If we *are* building libpcap, we don't want this, as it'll warn + * us even if we *define* the function. + */ + #define PCAP_DEPRECATED(func, msg) __pragma(deprecated(func)) +#else + #define PCAP_DEPRECATED(func, msg) +#endif + +/* + * For flagging arguments as format strings in MSVC. + */ +#ifdef _MSC_VER + #include <sal.h> + #if _MSC_VER > 1400 + #define PCAP_FORMAT_STRING(p) _Printf_format_string_ p + #else + #define PCAP_FORMAT_STRING(p) __format_string p + #endif +#else + #define PCAP_FORMAT_STRING(p) p +#endif + +#endif /* lib_pcap_funcattrs_h */ diff --git a/freebsd/contrib/libpcap/pcap/namedb.h b/freebsd/contrib/libpcap/pcap/namedb.h index 73fb40a4..c66846d3 100644 --- a/freebsd/contrib/libpcap/pcap/namedb.h +++ b/freebsd/contrib/libpcap/pcap/namedb.h @@ -60,9 +60,7 @@ PCAP_API u_char *pcap_ether_hostton(const char*); PCAP_API u_char *pcap_ether_aton(const char *); PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *); -#ifdef INET6 PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *); -#endif PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *); PCAP_API int pcap_nametoport(const char *, int *, int *); diff --git a/freebsd/contrib/libpcap/pcap/nflog.h b/freebsd/contrib/libpcap/pcap/nflog.h index a3867cdd..29a71d2d 100644 --- a/freebsd/contrib/libpcap/pcap/nflog.h +++ b/freebsd/contrib/libpcap/pcap/nflog.h @@ -28,6 +28,8 @@ #ifndef lib_pcap_nflog_h #define lib_pcap_nflog_h +#include <pcap/pcap-inttypes.h> + /* * Structure of an NFLOG header and TLV parts, as described at * http://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html @@ -40,32 +42,32 @@ * data, etc.). */ typedef struct nflog_hdr { - u_int8_t nflog_family; /* address family */ - u_int8_t nflog_version; /* version */ - u_int16_t nflog_rid; /* resource ID */ + uint8_t nflog_family; /* address family */ + uint8_t nflog_version; /* version */ + uint16_t nflog_rid; /* resource ID */ } nflog_hdr_t; typedef struct nflog_tlv { - u_int16_t tlv_length; /* tlv length */ - u_int16_t tlv_type; /* tlv type */ + uint16_t tlv_length; /* tlv length */ + uint16_t tlv_type; /* tlv type */ /* value follows this */ } nflog_tlv_t; typedef struct nflog_packet_hdr { - u_int16_t hw_protocol; /* hw protocol */ - u_int8_t hook; /* netfilter hook */ - u_int8_t pad; /* padding to 32 bits */ + uint16_t hw_protocol; /* hw protocol */ + uint8_t hook; /* netfilter hook */ + uint8_t pad; /* padding to 32 bits */ } nflog_packet_hdr_t; typedef struct nflog_hwaddr { - u_int16_t hw_addrlen; /* address length */ - u_int16_t pad; /* padding to 32-bit boundary */ - u_int8_t hw_addr[8]; /* address, up to 8 bytes */ + uint16_t hw_addrlen; /* address length */ + uint16_t pad; /* padding to 32-bit boundary */ + uint8_t hw_addr[8]; /* address, up to 8 bytes */ } nflog_hwaddr_t; typedef struct nflog_timestamp { - u_int64_t sec; - u_int64_t usec; + uint64_t sec; + uint64_t usec; } nflog_timestamp_t; /* diff --git a/freebsd/contrib/libpcap/pcap/pcap-inttypes.h b/freebsd/contrib/libpcap/pcap/pcap-inttypes.h new file mode 100644 index 00000000..af2c23c8 --- /dev/null +++ b/freebsd/contrib/libpcap/pcap/pcap-inttypes.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef pcap_pcap_inttypes_h +#define pcap_pcap_inttypes_h + +/* + * Get the integer types and PRi[doux]64 values from C99 <inttypes.h> + * defined, by hook or by crook. + */ +#if defined(_MSC_VER) + /* + * Compiler is MSVC. + */ + #if _MSC_VER >= 1800 + /* + * VS 2013 or newer; we have <inttypes.h>. + */ + #include <inttypes.h> + #else + /* + * Earlier VS; we have to define this stuff ourselves. + */ + typedef unsigned char uint8_t; + typedef signed char int8_t; + typedef unsigned short uint16_t; + typedef signed short int16_t; + typedef unsigned int uint32_t; + typedef signed int int32_t; + #ifdef _MSC_EXTENSIONS + typedef unsigned _int64 uint64_t; + typedef _int64 int64_t; + #else /* _MSC_EXTENSIONS */ + typedef unsigned long long uint64_t; + typedef long long int64_t; + #endif + #endif + + /* + * These may be defined by <inttypes.h>. + * + * XXX - for MSVC, we always want the _MSC_EXTENSIONS versions. + * What about other compilers? If, as the MinGW Web site says MinGW + * does, the other compilers just use Microsoft's run-time library, + * then they should probably use the _MSC_EXTENSIONS even if the + * compiler doesn't define _MSC_EXTENSIONS. + * + * XXX - we currently aren't using any of these, but this allows + * their use in the future. + */ + #ifndef PRId64 + #ifdef _MSC_EXTENSIONS + #define PRId64 "I64d" + #else + #define PRId64 "lld" + #endif + #endif /* PRId64 */ + + #ifndef PRIo64 + #ifdef _MSC_EXTENSIONS + #define PRIo64 "I64o" + #else + #define PRIo64 "llo" + #endif + #endif /* PRIo64 */ + + #ifndef PRIx64 + #ifdef _MSC_EXTENSIONS + #define PRIx64 "I64x" + #else + #define PRIx64 "llx" + #endif + #endif + + #ifndef PRIu64 + #ifdef _MSC_EXTENSIONS + #define PRIu64 "I64u" + #else + #define PRIu64 "llu" + #endif + #endif +#elif defined(__MINGW32__) || !defined(_WIN32) + /* + * Compiler is MinGW or target is UN*X or MS-DOS. Just use + * <inttypes.h>. + */ + #include <inttypes.h> +#endif + +#endif /* pcap/pcap-inttypes.h */ diff --git a/freebsd/contrib/libpcap/pcap/pcap.h b/freebsd/contrib/libpcap/pcap/pcap.h index 9c277124..dbe70dfd 100644 --- a/freebsd/contrib/libpcap/pcap/pcap.h +++ b/freebsd/contrib/libpcap/pcap/pcap.h @@ -32,18 +32,55 @@ * SUCH DAMAGE. */ +/* + * Remote packet capture mechanisms and extensions from WinPcap: + * + * Copyright (c) 2002 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + #ifndef lib_pcap_pcap_h #define lib_pcap_pcap_h -#include <pcap/export-defs.h> +#include <pcap/funcattrs.h> + +#include <pcap/pcap-inttypes.h> #if defined(_WIN32) - #include <pcap-stdinc.h> + #include <winsock2.h> /* u_int, u_char etc. */ + #include <io.h> /* _get_osfhandle() */ #elif defined(MSDOS) - #include <sys/types.h> - #include <sys/socket.h> /* u_int, u_char etc. */ + #include <sys/types.h> /* u_int, u_char etc. */ + #include <sys/socket.h> #else /* UN*X */ - #include <sys/types.h> + #include <sys/types.h> /* u_int, u_char etc. */ #include <sys/time.h> #endif /* _WIN32/MSDOS/UN*X */ @@ -170,11 +207,11 @@ struct pcap_stat { u_int ps_recv; /* number of packets received */ u_int ps_drop; /* number of packets dropped */ u_int ps_ifdrop; /* drops by interface -- only supported on some platforms */ -#if defined(_WIN32) && defined(HAVE_REMOTE) +#ifdef _WIN32 u_int ps_capt; /* number of packets that reach the application */ u_int ps_sent; /* number of packets sent by the server on the network */ u_int ps_netdrop; /* number of packets lost on the network */ -#endif /* _WIN32 && HAVE_REMOTE */ +#endif /* _WIN32 */ }; #ifdef MSDOS @@ -221,9 +258,15 @@ struct pcap_if { bpf_u_int32 flags; /* PCAP_IF_ interface flags */ }; -#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */ -#define PCAP_IF_UP 0x00000002 /* interface is up */ -#define PCAP_IF_RUNNING 0x00000004 /* interface is running */ +#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */ +#define PCAP_IF_UP 0x00000002 /* interface is up */ +#define PCAP_IF_RUNNING 0x00000004 /* interface is running */ +#define PCAP_IF_WIRELESS 0x00000008 /* interface is wireless (*NOT* necessarily Wi-Fi!) */ +#define PCAP_IF_CONNECTION_STATUS 0x00000030 /* connection status: */ +#define PCAP_IF_CONNECTION_STATUS_UNKNOWN 0x00000000 /* unknown */ +#define PCAP_IF_CONNECTION_STATUS_CONNECTED 0x00000010 /* connected */ +#define PCAP_IF_CONNECTION_STATUS_DISCONNECTED 0x00000020 /* disconnected */ +#define PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE 0x00000030 /* not applicable */ /* * Representation of an interface address. @@ -273,7 +316,14 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, */ #define PCAP_NETMASK_UNKNOWN 0xffffffff -PCAP_API char *pcap_lookupdev(char *); +/* + * We're deprecating pcap_lookupdev() for various reasons (not + * thread-safe, can behave weirdly with WinPcap). Callers + * should use pcap_findalldevs() and use the first device. + */ +PCAP_API char *pcap_lookupdev(char *) +PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device"); + PCAP_API int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *); PCAP_API pcap_t *pcap_create(const char *, char *); @@ -295,6 +345,10 @@ PCAP_API int pcap_tstamp_type_name_to_val(const char *); PCAP_API const char *pcap_tstamp_type_val_to_name(int); PCAP_API const char *pcap_tstamp_type_val_to_description(int); +#ifdef __linux__ +PCAP_API int pcap_set_protocol(pcap_t *, int); +#endif + /* * Time stamp types. * Not all systems and interfaces will necessarily support all of these. @@ -358,7 +412,16 @@ PCAP_API pcap_t *pcap_open_offline(const char *, char *); PCAP_API pcap_t *pcap_hopen_offline(intptr_t, char *); /* * If we're building libpcap, these are internal routines in savefile.c, - * so we mustn't define them as macros. + * so we must not define them as macros. + * + * If we're not building libpcap, given that the version of the C runtime + * with which libpcap was built might be different from the version + * of the C runtime with which an application using libpcap was built, + * and that a FILE structure may differ between the two versions of the + * C runtime, calls to _fileno() must use the version of _fileno() in + * the C runtime used to open the FILE *, not the version in the C + * runtime with which libpcap was built. (Maybe once the Universal CRT + * rules the world, this will cease to be a problem.) */ #ifndef BUILDING_PCAP #define pcap_fopen_offline_with_tstamp_precision(f,p,b) \ @@ -407,6 +470,7 @@ PCAP_API int pcap_snapshot(pcap_t *); PCAP_API int pcap_is_swapped(pcap_t *); PCAP_API int pcap_major_version(pcap_t *); PCAP_API int pcap_minor_version(pcap_t *); +PCAP_API int pcap_bufsize(pcap_t *); /* XXX */ PCAP_API FILE *pcap_file(pcap_t *); @@ -421,6 +485,7 @@ PCAP_API pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp); PCAP_API pcap_dumper_t *pcap_dump_open_append(pcap_t *, const char *); PCAP_API FILE *pcap_dump_file(pcap_dumper_t *); PCAP_API long pcap_dump_ftell(pcap_dumper_t *); +PCAP_API int64_t pcap_dump_ftell64(pcap_dumper_t *); PCAP_API int pcap_dump_flush(pcap_dumper_t *); PCAP_API void pcap_dump_close(pcap_dumper_t *); PCAP_API void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *); @@ -428,6 +493,21 @@ PCAP_API void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *); PCAP_API int pcap_findalldevs(pcap_if_t **, char *); PCAP_API void pcap_freealldevs(pcap_if_t *); +/* + * We return a pointer to the version string, rather than exporting the + * version string directly. + * + * On at least some UNIXes, if you import data from a shared library into + * an program, the data is bound into the program binary, so if the string + * in the version of the library with which the program was linked isn't + * the same as the string in the version of the library with which the + * program is being run, various undesirable things may happen (warnings, + * the string being the one from the version of the library with which the + * program was linked, or even weirder things, such as the string being the + * one from the library but being truncated). + * + * On Windows, the string is constructed at run time. + */ PCAP_API const char *pcap_lib_version(void); /* @@ -455,7 +535,7 @@ PCAP_API void bpf_dump(const struct bpf_program *, int); */ struct pcap_send_queue { - u_int maxlen; /* Maximum size of the the queue, in bytes. This + u_int maxlen; /* Maximum size of the queue, in bytes. This variable contains the size of the buffer field. */ u_int len; /* Current size of the queue, in bytes. */ char *buffer; /* Buffer containing the packets to be sent. */ @@ -521,13 +601,370 @@ PCAP_API void bpf_dump(const struct bpf_program *, int); */ PCAP_API int pcap_get_selectable_fd(pcap_t *); + PCAP_API struct timeval *pcap_get_required_select_timeout(pcap_t *); #endif /* _WIN32/MSDOS/UN*X */ -#ifdef HAVE_REMOTE - /* Includes most of the public stuff that is needed for the remote capture */ - #include <remote-ext.h> -#endif /* HAVE_REMOTE */ +#if 0 /* Remote capture is disabled on FreeBSD */ +/* + * Remote capture definitions. + * + * These routines are only present if libpcap has been configured to + * include remote capture support. + */ + +/* + * The maximum buffer size in which address, port, interface names are kept. + * + * In case the adapter name or such is larger than this value, it is truncated. + * This is not used by the user; however it must be aware that an hostname / interface + * name longer than this value will be truncated. + */ +#define PCAP_BUF_SIZE 1024 + +/* + * The type of input source, passed to pcap_open(). + */ +#define PCAP_SRC_FILE 2 /* local savefile */ +#define PCAP_SRC_IFLOCAL 3 /* local network interface */ +#define PCAP_SRC_IFREMOTE 4 /* interface on a remote host, using RPCAP */ + +/* + * The formats allowed by pcap_open() are the following: + * - file://path_and_filename [opens a local file] + * - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol] + * - rpcap://host/devicename [opens the selected device available on a remote host] + * - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP] + * - adaptername [to open a local adapter; kept for compability, but it is strongly discouraged] + * - (NULL) [to open the first local adapter; kept for compability, but it is strongly discouraged] + * + * The formats allowed by the pcap_findalldevs_ex() are the following: + * - file://folder/ [lists all the files in the given folder] + * - rpcap:// [lists all local adapters] + * - rpcap://host:port/ [lists the devices available on a remote host] + * + * Referring to the 'host' and 'port' parameters, they can be either numeric or literal. Since + * IPv6 is fully supported, these are the allowed formats: + * + * - host (literal): e.g. host.foo.bar + * - host (numeric IPv4): e.g. 10.11.12.13 + * - host (numeric IPv4, IPv6 style): e.g. [10.11.12.13] + * - host (numeric IPv6): e.g. [1:2:3::4] + * - port: can be either numeric (e.g. '80') or literal (e.g. 'http') + * + * Here you find some allowed examples: + * - rpcap://host.foo.bar/devicename [everything literal, no port number] + * - rpcap://host.foo.bar:1234/devicename [everything literal, with port number] + * - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number] + * - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number] + * - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number] + * - rpcap://[1:2:3::4]/devicename [IPv6 numeric, no port number] + * - rpcap://[1:2:3::4]:1234/devicename [IPv6 numeric, with port number] + * - rpcap://[1:2:3::4]:http/devicename [IPv6 numeric, with literal port number] + */ + +/* + * URL schemes for capture source. + */ +/* + * This string indicates that the user wants to open a capture from a + * local file. + */ +#define PCAP_SRC_FILE_STRING "file://" +/* + * This string indicates that the user wants to open a capture from a + * network interface. This string does not necessarily involve the use + * of the RPCAP protocol. If the interface required resides on the local + * host, the RPCAP protocol is not involved and the local functions are used. + */ +#define PCAP_SRC_IF_STRING "rpcap://" + +/* + * Flags to pass to pcap_open(). + */ + +/* + * Specifies whether promiscuous mode is to be used. + */ +#define PCAP_OPENFLAG_PROMISCUOUS 0x00000001 + +/* + * Specifies, for an RPCAP capture, whether the data transfer (in + * case of a remote capture) has to be done with UDP protocol. + * + * If it is '1' if you want a UDP data connection, '0' if you want + * a TCP data connection; control connection is always TCP-based. + * A UDP connection is much lighter, but it does not guarantee that all + * the captured packets arrive to the client workstation. Moreover, + * it could be harmful in case of network congestion. + * This flag is meaningless if the source is not a remote interface. + * In that case, it is simply ignored. + */ +#define PCAP_OPENFLAG_DATATX_UDP 0x00000002 + +/* + * Specifies wheether the remote probe will capture its own generated + * traffic. + * + * In case the remote probe uses the same interface to capture traffic + * and to send data back to the caller, the captured traffic includes + * the RPCAP traffic as well. If this flag is turned on, the RPCAP + * traffic is excluded from the capture, so that the trace returned + * back to the collector is does not include this traffic. + * + * Has no effect on local interfaces or savefiles. + */ +#define PCAP_OPENFLAG_NOCAPTURE_RPCAP 0x00000004 + +/* + * Specifies whether the local adapter will capture its own generated traffic. + * + * This flag tells the underlying capture driver to drop the packets + * that were sent by itself. This is useful when building applications + * such as bridges that should ignore the traffic they just sent. + * + * Supported only on Windows. + */ +#define PCAP_OPENFLAG_NOCAPTURE_LOCAL 0x00000008 + +/* + * This flag configures the adapter for maximum responsiveness. + * + * In presence of a large value for nbytes, WinPcap waits for the arrival + * of several packets before copying the data to the user. This guarantees + * a low number of system calls, i.e. lower processor usage, i.e. better + * performance, which is good for applications like sniffers. If the user + * sets the PCAP_OPENFLAG_MAX_RESPONSIVENESS flag, the capture driver will + * copy the packets as soon as the application is ready to receive them. + * This is suggested for real time applications (such as, for example, + * a bridge) that need the best responsiveness. + * + * The equivalent with pcap_create()/pcap_activate() is "immediate mode". + */ +#define PCAP_OPENFLAG_MAX_RESPONSIVENESS 0x00000010 + +/* + * Remote authentication methods. + * These are used in the 'type' member of the pcap_rmtauth structure. + */ + +/* + * NULL authentication. + * + * The 'NULL' authentication has to be equal to 'zero', so that old + * applications can just put every field of struct pcap_rmtauth to zero, + * and it does work. + */ +#define RPCAP_RMTAUTH_NULL 0 +/* + * Username/password authentication. + * + * With this type of authentication, the RPCAP protocol will use the username/ + * password provided to authenticate the user on the remote machine. If the + * authentication is successful (and the user has the right to open network + * devices) the RPCAP connection will continue; otherwise it will be dropped. + * + * *******NOTE********: the username and password are sent over the network + * to the capture server *IN CLEAR TEXT*. Don't use this on a network + * that you don't completely control! (And be *really* careful in your + * definition of "completely"!) + */ +#define RPCAP_RMTAUTH_PWD 1 + +/* + * This structure keeps the information needed to autheticate the user + * on a remote machine. + * + * The remote machine can either grant or refuse the access according + * to the information provided. + * In case the NULL authentication is required, both 'username' and + * 'password' can be NULL pointers. + * + * This structure is meaningless if the source is not a remote interface; + * in that case, the functions which requires such a structure can accept + * a NULL pointer as well. + */ +struct pcap_rmtauth +{ + /* + * \brief Type of the authentication required. + * + * In order to provide maximum flexibility, we can support different types + * of authentication based on the value of this 'type' variable. The currently + * supported authentication methods are defined into the + * \link remote_auth_methods Remote Authentication Methods Section\endlink. + */ + int type; + /* + * \brief Zero-terminated string containing the username that has to be + * used on the remote machine for authentication. + * + * This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication + * and it can be NULL. + */ + char *username; + /* + * \brief Zero-terminated string containing the password that has to be + * used on the remote machine for authentication. + * + * This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication + * and it can be NULL. + */ + char *password; +}; + +/* + * This routine can open a savefile, a local device, or a device on + * a remote machine running an RPCAP server. + * + * For opening a savefile, the pcap_open_offline routines can be used, + * and will work just as well; code using them will work on more + * platforms than code using pcap_open() to open savefiles. + * + * For opening a local device, pcap_open_live() can be used; it supports + * most of the capabilities that pcap_open() supports, and code using it + * will work on more platforms than code using pcap_open(). pcap_create() + * and pcap_activate() can also be used; they support all capabilities + * that pcap_open() supports, except for the Windows-only + * PCAP_OPENFLAG_NOCAPTURE_LOCAL, and support additional capabilities. + * + * For opening a remote capture, pcap_open() is currently the only + * API available. + */ +PCAP_API pcap_t *pcap_open(const char *source, int snaplen, int flags, + int read_timeout, struct pcap_rmtauth *auth, char *errbuf); +PCAP_API int pcap_createsrcstr(char *source, int type, const char *host, + const char *port, const char *name, char *errbuf); +PCAP_API int pcap_parsesrcstr(const char *source, int *type, char *host, + char *port, char *name, char *errbuf); + +/* + * This routine can scan a directory for savefiles, list local capture + * devices, or list capture devices on a remote machine running an RPCAP + * server. + * + * For scanning for savefiles, it can be used on both UN*X systems and + * Windows systems; for each directory entry it sees, it tries to open + * the file as a savefile using pcap_open_offline(), and only includes + * it in the list of files if the open succeeds, so it filters out + * files for which the user doesn't have read permission, as well as + * files that aren't valid savefiles readable by libpcap. + * + * For listing local capture devices, it's just a wrapper around + * pcap_findalldevs(); code using pcap_findalldevs() will work on more + * platforms than code using pcap_findalldevs_ex(). + * + * For listing remote capture devices, pcap_findalldevs_ex() is currently + * the only API available. + */ +PCAP_API int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, + pcap_if_t **alldevs, char *errbuf); + +/* + * Sampling methods. + * + * These allow pcap_loop(), pcap_dispatch(), pcap_next(), and pcap_next_ex() + * to see only a sample of packets, rather than all packets. + * + * Currently, they work only on Windows local captures. + */ + +/* + * Specifies that no sampling is to be done on the current capture. + * + * In this case, no sampling algorithms are applied to the current capture. + */ +#define PCAP_SAMP_NOSAMP 0 + +/* + * Specifies that only 1 out of N packets must be returned to the user. + * + * In this case, the 'value' field of the 'pcap_samp' structure indicates the + * number of packets (minus 1) that must be discarded before one packet got + * accepted. + * In other words, if 'value = 10', the first packet is returned to the + * caller, while the following 9 are discarded. + */ +#define PCAP_SAMP_1_EVERY_N 1 + +/* + * Specifies that we have to return 1 packet every N milliseconds. + * + * In this case, the 'value' field of the 'pcap_samp' structure indicates + * the 'waiting time' in milliseconds before one packet got accepted. + * In other words, if 'value = 10', the first packet is returned to the + * caller; the next returned one will be the first packet that arrives + * when 10ms have elapsed. + */ +#define PCAP_SAMP_FIRST_AFTER_N_MS 2 + +/* + * This structure defines the information related to sampling. + * + * In case the sampling is requested, the capturing device should read + * only a subset of the packets coming from the source. The returned packets + * depend on the sampling parameters. + * + * WARNING: The sampling process is applied *after* the filtering process. + * In other words, packets are filtered first, then the sampling process + * selects a subset of the 'filtered' packets and it returns them to the + * caller. + */ +struct pcap_samp +{ + /* + * Method used for sampling; see above. + */ + int method; + + /* + * This value depends on the sampling method defined. + * For its meaning, see above. + */ + int value; +}; + +/* + * New functions. + */ +PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p); + +/* + * RPCAP active mode. + */ + +/* Maximum length of an host name (needed for the RPCAP active mode) */ +#define RPCAP_HOSTLIST_SIZE 1024 + +/* + * Some minor differences between UN*X sockets and and Winsock sockets. + */ +#ifndef _WIN32 + /*! + * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's + * a file descriptor, and therefore a signed integer. + * We define SOCKET to be a signed integer on UN*X, so that it can + * be used on both platforms. + */ + #define SOCKET int + + /*! + * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET; + * in UN*X, it's -1. + * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on + * both platforms. + */ + #define INVALID_SOCKET -1 +#endif + +PCAP_API SOCKET pcap_remoteact_accept(const char *address, const char *port, + const char *hostlist, char *connectinghost, + struct pcap_rmtauth *auth, char *errbuf); +PCAP_API int pcap_remoteact_list(char *hostlist, char sep, int size, + char *errbuf); +PCAP_API int pcap_remoteact_close(const char *host, char *errbuf); +PCAP_API void pcap_remoteact_cleanup(void); +#endif /* Remote capture is disabled on FreeBSD */ #ifdef __cplusplus } diff --git a/freebsd/contrib/libpcap/pcap/sll.h b/freebsd/contrib/libpcap/pcap/sll.h index b46d15f2..c4d08862 100644 --- a/freebsd/contrib/libpcap/pcap/sll.h +++ b/freebsd/contrib/libpcap/pcap/sll.h @@ -80,12 +80,14 @@ #define SLL_HDR_LEN 16 /* total header length */ #define SLL_ADDRLEN 8 /* length of address field */ +#include <pcap/pcap-inttypes.h> + struct sll_header { - u_int16_t sll_pkttype; /* packet type */ - u_int16_t sll_hatype; /* link-layer address type */ - u_int16_t sll_halen; /* link-layer address length */ - u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ - u_int16_t sll_protocol; /* protocol */ + uint16_t sll_pkttype; /* packet type */ + uint16_t sll_hatype; /* link-layer address type */ + uint16_t sll_halen; /* link-layer address length */ + uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ + uint16_t sll_protocol; /* protocol */ }; /* diff --git a/freebsd/contrib/libpcap/pcap/usb.h b/freebsd/contrib/libpcap/pcap/usb.h index 26a9046b..e485ec85 100644 --- a/freebsd/contrib/libpcap/pcap/usb.h +++ b/freebsd/contrib/libpcap/pcap/usb.h @@ -34,6 +34,8 @@ #ifndef lib_pcap_usb_h #define lib_pcap_usb_h +#include <pcap/pcap-inttypes.h> + /* * possible transfer mode */ @@ -55,11 +57,11 @@ * Appears at the front of each Control S-type packet in DLT_USB captures. */ typedef struct _usb_setup { - u_int8_t bmRequestType; - u_int8_t bRequest; - u_int16_t wValue; - u_int16_t wIndex; - u_int16_t wLength; + uint8_t bmRequestType; + uint8_t bRequest; + uint16_t wValue; + uint16_t wIndex; + uint16_t wLength; } pcap_usb_setup; /* @@ -75,19 +77,19 @@ typedef struct _iso_rec { * Appears at the front of each packet in DLT_USB_LINUX captures. */ typedef struct _usb_header { - u_int64_t id; - u_int8_t event_type; - u_int8_t transfer_type; - u_int8_t endpoint_number; - u_int8_t device_address; - u_int16_t bus_id; + uint64_t id; + uint8_t event_type; + uint8_t transfer_type; + uint8_t endpoint_number; + uint8_t device_address; + uint16_t bus_id; char setup_flag;/*if !=0 the urb setup header is not present*/ char data_flag; /*if !=0 no urb data is present*/ int64_t ts_sec; int32_t ts_usec; int32_t status; - u_int32_t urb_len; - u_int32_t data_len; /* amount of urb data really present in this event*/ + uint32_t urb_len; + uint32_t data_len; /* amount of urb data really present in this event*/ pcap_usb_setup setup; } pcap_usb_header; @@ -100,27 +102,27 @@ typedef struct _usb_header { * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures. */ typedef struct _usb_header_mmapped { - u_int64_t id; - u_int8_t event_type; - u_int8_t transfer_type; - u_int8_t endpoint_number; - u_int8_t device_address; - u_int16_t bus_id; + uint64_t id; + uint8_t event_type; + uint8_t transfer_type; + uint8_t endpoint_number; + uint8_t device_address; + uint16_t bus_id; char setup_flag;/*if !=0 the urb setup header is not present*/ char data_flag; /*if !=0 no urb data is present*/ int64_t ts_sec; int32_t ts_usec; int32_t status; - u_int32_t urb_len; - u_int32_t data_len; /* amount of urb data really present in this event*/ + uint32_t urb_len; + uint32_t data_len; /* amount of urb data really present in this event*/ union { pcap_usb_setup setup; iso_rec iso; } s; int32_t interval; /* for Interrupt and Isochronous events */ int32_t start_frame; /* for Isochronous events */ - u_int32_t xfer_flags; /* copy of URB's transfer flags */ - u_int32_t ndesc; /* number of isochronous descriptors */ + uint32_t xfer_flags; /* copy of URB's transfer flags */ + uint32_t ndesc; /* number of isochronous descriptors */ } pcap_usb_header_mmapped; /* @@ -133,9 +135,9 @@ typedef struct _usb_header_mmapped { */ typedef struct _usb_isodesc { int32_t status; - u_int32_t offset; - u_int32_t len; - u_int8_t pad[4]; + uint32_t offset; + uint32_t len; + uint8_t pad[4]; } usb_isodesc; #endif diff --git a/freebsd/contrib/libpcap/portability.h b/freebsd/contrib/libpcap/portability.h index 8a6bf40e..b3612542 100644 --- a/freebsd/contrib/libpcap/portability.h +++ b/freebsd/contrib/libpcap/portability.h @@ -39,6 +39,8 @@ * flavors of UN*X. */ +#include "pcap/funcattrs.h" + #ifdef __cplusplus extern "C" { #endif @@ -47,7 +49,7 @@ extern "C" { /* * Macro that does the same thing as strlcpy(). */ - #ifdef _MSC_VER + #if defined(_MSC_VER) || defined(__MINGW32__) /* * strncpy_s() is supported at least back to Visual * Studio 2005. @@ -63,44 +65,37 @@ extern "C" { #endif #endif -/* - * For flagging arguments as format strings in MSVC. - */ -#if _MSC_VER >= 1400 - #include <sal.h> - #if _MSC_VER > 1400 - #define FORMAT_STRING(p) _Printf_format_string_ p - #else - #define FORMAT_STRING(p) __format_string p - #endif -#else - #define FORMAT_STRING(p) p -#endif - -#ifdef _MSC_VER - #define strdup _strdup - #define sscanf sscanf_s - #define setbuf(x, y) \ - setvbuf((x), (y), _IONBF, 0) - #define fopen(x, y) \ - fopen_safe((x), (y)) - FILE *fopen_safe(const char *filename, const char* mode); -#endif - -#if defined(_MSC_VER) || defined(__MINGW32__) +#ifndef HAVE_STRLCAT + /* + * Macro that does the same thing as strlcat(). + */ + #if defined(_MSC_VER) || defined(__MINGW32__) + /* + * strncat_s() is supported at least back to Visual + * Studio 2005. + */ #define strlcat(x, y, z) \ strncat_s((x), (z), (y), _TRUNCATE) + #else + /* + * ANSI C says strncat() always null-terminates its first argument, + * so 1) we don't need to explicitly null-terminate the string + * ourselves and 2) we need to leave room for the null terminator. + */ + #define strlcat(x, y, z) \ + strncat((x), (y), (z) - strlen((x)) - 1) + #endif #endif #ifdef _MSC_VER /* - * MSVC. + * If <crtdbg.h> has been included, and _DEBUG is defined, and + * __STDC__ is zero, <crtdbg.h> will define strdup() to call + * _strdup_dbg(). So if it's already defined, don't redefine + * it. */ - #if _MSC_VER >= 1900 - /* - * VS 2015 or newer; we have snprintf() function. - */ - #define HAVE_SNPRINTF + #ifndef strdup + #define strdup _strdup #endif #endif @@ -129,11 +124,8 @@ extern "C" { #ifdef HAVE_SNPRINTF #define pcap_snprintf snprintf #else -extern int pcap_snprintf(char *, size_t, FORMAT_STRING(const char *), ...) -#ifdef __ATTRIBUTE___FORMAT_OK - __attribute__((format (printf, 3, 4))) -#endif /* __ATTRIBUTE___FORMAT_OK */ - ; +extern int pcap_snprintf(char *, size_t, PCAP_FORMAT_STRING(const char *), ...) + PCAP_PRINTFLIKE(3, 4); #endif #ifdef HAVE_VSNPRINTF @@ -145,7 +137,7 @@ extern int pcap_vsnprintf(char *, size_t, const char *, va_list ap); #ifdef HAVE_STRTOK_R #define pcap_strtok_r strtok_r #else - #ifdef _MSC_VER + #ifdef _WIN32 /* * Microsoft gives it a different name. */ @@ -155,55 +147,11 @@ extern int pcap_vsnprintf(char *, size_t, const char *, va_list ap); * Define it ourselves. */ #define NEED_STRTOK_R - extern int pcap_strtok_r(char *, const char *, char **); + extern char *pcap_strtok_r(char *, const char *, char **); #endif #endif /* HAVE_STRTOK_R */ #ifdef _WIN32 - /* - * These may be defined by <inttypes.h>. - * - * XXX - for MSVC, we always want the _MSC_EXTENSIONS versions. - * What about other compilers? If, as the MinGW Web site says MinGW - * does, the other compilers just use Microsoft's run-time library, - * then they should probably use the _MSC_EXTENSIONS even if the - * compiler doesn't define _MSC_EXTENSIONS. - * - * XXX - we currently aren't using any of these, but this allows - * their use in the future. - */ - #ifndef PRId64 - #ifdef _MSC_EXTENSIONS - #define PRId64 "I64d" - #else - #define PRId64 "lld" - #endif - #endif /* PRId64 */ - - #ifndef PRIo64 - #ifdef _MSC_EXTENSIONS - #define PRIo64 "I64o" - #else - #define PRIo64 "llo" - #endif - #endif /* PRIo64 */ - - #ifndef PRIx64 - #ifdef _MSC_EXTENSIONS - #define PRIx64 "I64x" - #else - #define PRIx64 "llx" - #endif - #endif - - #ifndef PRIu64 - #ifdef _MSC_EXTENSIONS - #define PRIu64 "I64u" - #else - #define PRIu64 "llu" - #endif - #endif - #if !defined(__cplusplus) #define inline __inline #endif diff --git a/freebsd/contrib/libpcap/savefile.c b/freebsd/contrib/libpcap/savefile.c index 8f6b17c7..6b0cc86e 100644 --- a/freebsd/contrib/libpcap/savefile.c +++ b/freebsd/contrib/libpcap/savefile.c @@ -31,21 +31,13 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif +#include <pcap-types.h> #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> +#include <io.h> +#include <fcntl.h> #endif /* _WIN32 */ #include <errno.h> @@ -61,7 +53,7 @@ #endif #include "sf-pcap.h" -#include "sf-pcap-ng.h" +#include "sf-pcapng.h" #ifdef _WIN32 /* @@ -94,7 +86,7 @@ static pcap_t *pcap_fopen_offline(FILE *, char *); #endif static int -sf_getnonblock(pcap_t *p, char *errbuf) +sf_getnonblock(pcap_t *p _U_) { /* * This is a savefile, not a live capture file, so never say @@ -104,7 +96,7 @@ sf_getnonblock(pcap_t *p, char *errbuf) } static int -sf_setnonblock(pcap_t *p, int nonblock, char *errbuf) +sf_setnonblock(pcap_t *p, int nonblock _U_) { /* * This is a savefile, not a live capture file, so reject @@ -120,7 +112,7 @@ sf_setnonblock(pcap_t *p, int nonblock, char *errbuf) } static int -sf_stats(pcap_t *p, struct pcap_stat *ps) +sf_stats(pcap_t *p, struct pcap_stat *ps _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Statistics aren't available from savefiles"); @@ -238,7 +230,7 @@ sf_inject(pcap_t *p, const void *buf _U_, size_t size _U_) * single device? IN, OUT or both? */ static int -sf_setdirection(pcap_t *p, pcap_direction_t d) +sf_setdirection(pcap_t *p, pcap_direction_t d _U_) { pcap_snprintf(p->errbuf, sizeof(p->errbuf), "Setting direction is not supported on savefiles"); @@ -255,22 +247,6 @@ sf_cleanup(pcap_t *p) pcap_freecode(&p->fcode); } -/* -* fopen's safe version on Windows. -*/ -#ifdef _MSC_VER -FILE *fopen_safe(const char *filename, const char* mode) -{ - FILE *fp = NULL; - errno_t errno; - errno = fopen_s(&fp, filename, mode); - if (errno == 0) - return fp; - else - return NULL; -} -#endif - pcap_t * pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision, char *errbuf) @@ -295,14 +271,16 @@ pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision, #endif } else { -#if !defined(_WIN32) && !defined(MSDOS) - fp = fopen(fname, "r"); -#else + /* + * "b" is supported as of C90, so *all* UN*Xes should + * support it, even though it does nothing. It's + * required on Windows, as the file is a binary file + * and must be read in binary mode. + */ fp = fopen(fname, "rb"); -#endif if (fp == NULL) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", fname, - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "%s", fname); return (NULL); } } @@ -331,14 +309,16 @@ pcap_t* pcap_hopen_offline_with_tstamp_precision(intptr_t osfd, u_int precision, fd = _open_osfhandle(osfd, _O_RDONLY); if ( fd < 0 ) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "_open_osfhandle"); return NULL; } file = _fdopen(fd, "rb"); if ( file == NULL ) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "_fdopen"); return NULL; } @@ -375,7 +355,7 @@ pcap_fopen_offline_with_tstamp_precision(FILE *fp, u_int precision, /* * Read the first 4 bytes of the file; the network analyzer dump - * file formats we support (pcap and pcap-ng), and several other + * file formats we support (pcap and pcapng), and several other * formats we might support in the future (such as snoop, DOS and * Windows Sniffer, and Microsoft Network Monitor) all have magic * numbers that are unique in their first 4 bytes. @@ -383,9 +363,8 @@ pcap_fopen_offline_with_tstamp_precision(FILE *fp, u_int precision, amt_read = fread((char *)&magic, 1, sizeof(magic), fp); if (amt_read != sizeof(magic)) { if (ferror(fp)) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "error reading dump file"); } else { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "truncated dump file; tried to read %lu file header bytes, only got %lu", diff --git a/freebsd/contrib/libpcap/scanner.c b/freebsd/contrib/libpcap/scanner.c index aaaa209f..3a477eb5 100644 --- a/freebsd/contrib/libpcap/scanner.c +++ b/freebsd/contrib/libpcap/scanner.c @@ -2,12 +2,34 @@ #line 2 "scanner.l" /* 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" -#line 11 "scanner.c" + +#line 33 "scanner.c" #define YY_INT_ALIGNED short int @@ -369,8 +391,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ) __dead2; *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 157 -#define YY_END_OF_BUFFER 158 +#define YY_NUM_RULES 184 +#define YY_END_OF_BUFFER 185 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -378,143 +400,153 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[1470] = +static yyconst flex_int16_t yy_accept[1729] = { 0, - 0, 0, 158, 155, 113, 113, 113, 114, 155, 114, - 114, 114, 156, 123, 123, 114, 114, 114, 114, 153, - 153, 155, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 114, 155, 117, 121, 67, 0, 153, 123, - 0, 153, 153, 153, 0, 125, 119, 116, 118, 115, - 120, 153, 154, 154, 153, 153, 153, 20, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - - 153, 7, 153, 34, 35, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 92, - 153, 68, 153, 153, 153, 153, 153, 153, 60, 153, - 153, 153, 153, 86, 153, 153, 153, 153, 153, 153, - 61, 153, 4, 153, 153, 153, 153, 153, 153, 153, - 68, 121, 153, 124, 124, 153, 123, 153, 0, 125, - 123, 125, 125, 125, 153, 153, 153, 67, 5, 153, - 81, 153, 153, 153, 153, 153, 153, 153, 55, 107, - 1, 0, 153, 21, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - - 153, 153, 36, 153, 153, 18, 43, 0, 153, 29, - 153, 25, 70, 153, 153, 79, 37, 153, 100, 153, - 153, 153, 153, 101, 153, 46, 69, 82, 106, 153, - 14, 153, 3, 153, 153, 153, 153, 153, 94, 153, - 153, 26, 153, 105, 153, 108, 38, 2, 153, 42, - 153, 9, 153, 10, 89, 153, 88, 153, 153, 0, - 153, 153, 124, 153, 153, 153, 153, 123, 0, 153, + 0, 0, 185, 182, 113, 113, 113, 114, 182, 114, + 114, 114, 183, 123, 123, 114, 114, 114, 114, 180, + 180, 182, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 114, 182, 117, 121, 67, 0, 180, 123, + 0, 180, 180, 180, 0, 125, 119, 116, 118, 115, + 120, 180, 181, 181, 180, 180, 180, 20, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + + 180, 7, 180, 34, 35, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 92, + 180, 68, 180, 180, 180, 180, 180, 180, 60, 180, + 180, 180, 180, 86, 180, 180, 180, 180, 180, 180, + 61, 180, 4, 180, 180, 180, 180, 180, 180, 180, + 68, 121, 180, 124, 124, 180, 123, 180, 0, 125, + 123, 125, 125, 125, 180, 180, 180, 67, 5, 180, + 81, 180, 180, 180, 180, 180, 180, 180, 55, 107, + 1, 0, 180, 21, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + + 180, 180, 36, 180, 180, 18, 43, 0, 180, 29, + 180, 25, 70, 180, 180, 79, 37, 180, 100, 180, + 180, 180, 180, 101, 180, 46, 69, 82, 106, 180, + 14, 180, 3, 180, 180, 180, 180, 180, 94, 180, + 180, 26, 180, 105, 180, 108, 38, 2, 180, 42, + 180, 9, 180, 10, 89, 180, 88, 180, 180, 0, + 180, 180, 124, 180, 180, 180, 180, 123, 0, 180, 0, 126, 125, 125, 0, 125, 0, 125, 0, 125, - 0, 23, 153, 153, 153, 153, 64, 16, 41, 153, - 39, 153, 153, 153, 30, 153, 98, 153, 153, 153, - - 111, 153, 153, 104, 110, 45, 109, 112, 11, 153, - 12, 13, 153, 153, 153, 32, 78, 153, 62, 3, - 99, 47, 153, 153, 153, 74, 153, 153, 153, 153, - 48, 153, 153, 40, 153, 6, 153, 93, 153, 8, - 95, 153, 153, 0, 153, 53, 73, 15, 153, 124, - 124, 153, 124, 124, 124, 153, 123, 153, 0, 125, - 153, 0, 0, 125, 0, 125, 126, 125, 0, 0, - 0, 0, 125, 125, 125, 125, 125, 0, 153, 56, - 57, 58, 59, 153, 22, 153, 153, 153, 153, 31, - 153, 153, 153, 102, 103, 0, 19, 153, 153, 153, - - 87, 153, 33, 153, 80, 28, 27, 153, 153, 83, - 153, 153, 153, 50, 17, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 0, - 153, 153, 124, 153, 153, 153, 153, 124, 124, 153, - 123, 153, 0, 0, 125, 125, 125, 0, 0, 126, + 0, 23, 180, 180, 180, 180, 64, 16, 41, 180, + 39, 180, 180, 180, 30, 180, 98, 180, 180, 180, + + 111, 180, 180, 104, 110, 45, 109, 112, 11, 180, + 12, 13, 180, 180, 180, 32, 78, 180, 62, 3, + 99, 47, 180, 180, 180, 74, 180, 180, 180, 180, + 48, 180, 180, 40, 180, 6, 180, 93, 180, 8, + 95, 180, 180, 0, 180, 53, 73, 15, 180, 124, + 124, 180, 124, 124, 124, 180, 123, 180, 0, 125, + 180, 0, 0, 125, 0, 125, 126, 125, 0, 0, + 0, 0, 125, 125, 125, 125, 125, 0, 180, 56, + 57, 58, 59, 180, 22, 180, 180, 180, 180, 31, + 180, 180, 180, 102, 103, 0, 19, 180, 180, 180, + + 87, 180, 33, 180, 80, 28, 27, 180, 180, 83, + 180, 180, 180, 50, 17, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 0, + 180, 180, 124, 180, 180, 180, 180, 124, 124, 180, + 123, 180, 0, 0, 125, 125, 125, 0, 0, 126, 125, 125, 126, 125, 0, 0, 125, 125, 125, 125, 125, 0, 0, 0, 0, 125, 125, 0, 125, 0, - 125, 0, 97, 153, 153, 153, 24, 153, 153, 77, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 70, 153, 153, 153, 153, 153, 153, 153, - - 75, 76, 153, 96, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 124, 124, - 153, 124, 124, 124, 124, 153, 123, 153, 0, 125, - 125, 0, 125, 0, 0, 125, 0, 125, 126, 125, - 0, 0, 0, 125, 125, 0, 125, 126, 125, 0, - 0, 0, 0, 0, 0, 0, 125, 125, 125, 125, - 125, 0, 153, 153, 153, 153, 52, 63, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 71, 153, 153, 44, 84, 85, 153, 153, 153, 153, - 54, 149, 152, 151, 145, 153, 147, 146, 150, 153, - - 0, 153, 153, 124, 153, 153, 153, 124, 153, 123, - 153, 0, 0, 125, 125, 125, 125, 125, 125, 0, - 0, 126, 125, 125, 125, 0, 0, 125, 125, 125, - 125, 125, 0, 0, 0, 0, 0, 0, 0, 125, - 125, 125, 125, 125, 0, 0, 0, 0, 0, 125, - 125, 0, 125, 0, 125, 0, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 128, - 127, 153, 153, 72, 153, 153, 153, 148, 144, 153, - 153, 124, 124, 124, 124, 153, 123, 153, 0, 125, - 125, 0, 125, 125, 0, 125, 0, 0, 125, 0, + 125, 0, 97, 180, 180, 180, 24, 180, 180, 77, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 0, + 180, 180, 180, 180, 180, 70, 180, 180, 180, 180, + + 180, 180, 180, 75, 76, 180, 96, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 124, 124, 180, 124, 124, 124, 124, 180, 123, + 180, 0, 125, 125, 0, 125, 0, 0, 125, 0, + 125, 126, 125, 0, 0, 0, 125, 125, 0, 125, + 126, 125, 0, 0, 0, 0, 0, 0, 0, 125, + 125, 125, 125, 125, 0, 180, 180, 180, 180, 52, + 63, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 71, 180, 180, 44, 84, 85, 180, 180, + + 180, 180, 54, 176, 179, 178, 172, 180, 174, 173, + 177, 180, 0, 180, 180, 124, 180, 180, 180, 124, + 180, 123, 180, 0, 0, 125, 125, 125, 125, 125, + 125, 0, 0, 126, 125, 125, 125, 0, 0, 125, + 125, 125, 125, 125, 0, 0, 0, 0, 0, 0, + 0, 125, 125, 125, 125, 125, 0, 0, 0, 0, + 0, 125, 125, 0, 125, 0, 125, 0, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 128, 127, 180, 180, 72, 180, 180, + + 180, 175, 171, 180, 180, 124, 124, 124, 124, 180, + 123, 180, 0, 125, 125, 0, 125, 125, 0, 125, + 0, 0, 125, 0, 125, 126, 125, 0, 0, 0, + 125, 125, 0, 125, 126, 125, 0, 0, 0, 0, + 0, 125, 125, 0, 125, 126, 125, 0, 125, 125, + 0, 0, 0, 0, 0, 0, 0, 125, 125, 125, + 125, 125, 0, 65, 180, 55, 133, 140, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 145, 144, 180, 66, + 49, 180, 180, 0, 180, 180, 180, 180, 180, 123, + + 180, 0, 0, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 0, 0, 126, 125, 125, 125, 0, 0, + 125, 125, 125, 125, 125, 0, 0, 0, 0, 0, + 0, 0, 125, 125, 125, 125, 125, 0, 125, 125, + 0, 0, 0, 0, 0, 0, 0, 125, 125, 125, + 125, 125, 0, 0, 0, 0, 0, 0, 125, 125, + 0, 125, 0, 125, 0, 90, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 146, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 51, 122, 122, + 124, 124, 180, 123, 180, 0, 125, 125, 0, 125, + 125, 0, 125, 125, 0, 125, 0, 122, 125, 0, 125, 126, 125, 0, 0, 0, 125, 125, 0, 125, 126, 125, 0, 0, 0, 0, 0, 125, 125, 0, - 125, 126, 125, 0, 125, 125, 0, 0, 0, 0, - 0, 0, 0, 125, 125, 125, 125, 125, 0, 65, - 153, 55, 133, 140, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 66, 49, 153, 153, 0, 153, 153, - 153, 153, 153, 123, 153, 0, 0, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 0, 0, 126, 125, - 125, 125, 0, 0, 125, 125, 125, 125, 125, 0, + 125, 126, 125, 0, 0, 0, 0, 0, 0, 125, + 125, 0, 125, 126, 125, 0, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, 125, 125, 125, 125, + 125, 0, 180, 180, 180, 180, 180, 180, 180, 180, + 138, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 91, 122, 122, 124, 180, 122, 122, 0, + 0, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 0, 125, 125, 0, 0, 0, 0, 0, 0, + 125, 125, 125, 0, 122, 126, 125, 125, 125, 0, 0, 125, 125, 125, 125, 125, 0, 0, 0, 0, - 0, 0, 125, 125, 0, 125, 0, 125, 0, 90, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 51, 122, 122, 124, 124, 153, 123, 153, 0, - 125, 125, 0, 125, 125, 0, 125, 125, 0, 125, - 0, 122, 125, 0, 125, 126, 125, 0, 0, 0, - 125, 125, 0, 125, 126, 125, 0, 0, 0, 0, - 0, 125, 125, 0, 125, 126, 125, 0, 0, 0, + 0, 0, 0, 125, 125, 125, 125, 125, 0, 125, + 125, 0, 0, 0, 0, 0, 0, 0, 125, 125, + 125, 125, 125, 0, 125, 125, 125, 0, 0, 0, + 0, 0, 0, 0, 125, 125, 125, 125, 125, 0, + 0, 0, 0, 0, 0, 125, 125, 0, 125, 0, + 125, 0, 180, 180, 180, 142, 180, 180, 180, 180, + 180, 180, 180, 130, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 124, 180, 123, 0, 125, 125, + + 0, 125, 125, 0, 125, 125, 0, 125, 125, 0, + 125, 0, 0, 0, 125, 0, 0, 125, 126, 125, 0, 0, 0, 125, 125, 0, 125, 126, 125, 0, - + 0, 0, 0, 0, 125, 125, 0, 125, 126, 125, + 0, 0, 0, 0, 0, 0, 125, 125, 0, 125, + 126, 125, 0, 0, 0, 0, 0, 0, 125, 125, + 0, 125, 126, 125, 0, 125, 125, 125, 0, 0, + 0, 0, 0, 0, 0, 125, 125, 125, 125, 125, + 0, 180, 180, 180, 180, 132, 180, 180, 180, 136, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + + 180, 180, 180, 122, 0, 0, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 0, 0, 0, 126, 0, 0, 125, 0, 0, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, - 125, 125, 125, 125, 125, 0, 153, 153, 153, 153, - 153, 153, 153, 153, 138, 153, 91, 122, 122, 124, - 153, 122, 122, 0, 0, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 0, 122, 126, - 125, 125, 125, 0, 0, 125, 125, 125, 125, 125, + 125, 125, 125, 0, 125, 125, 0, 0, 0, 0, + 0, 0, 0, 125, 125, 125, 0, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, 125, 125, 125, - 125, 125, 0, 125, 125, 0, 0, 0, 0, 0, - 0, 0, 125, 125, 125, 125, 125, 0, 125, 125, - 125, 0, 0, 0, 0, 0, 0, 0, 125, 125, - - 125, 125, 125, 0, 0, 0, 0, 0, 0, 125, - 125, 0, 125, 0, 125, 0, 153, 153, 153, 142, - 153, 153, 153, 153, 153, 153, 153, 130, 124, 153, - 123, 0, 125, 125, 0, 125, 125, 0, 125, 125, - 0, 125, 125, 0, 125, 0, 0, 0, 125, 0, - 0, 125, 126, 125, 0, 0, 0, 125, 125, 0, - 125, 126, 125, 0, 0, 0, 0, 0, 125, 125, - 0, 125, 126, 125, 0, 0, 0, 0, 0, 0, - 125, 125, 0, 125, 126, 125, 0, 0, 0, 0, - 0, 0, 125, 125, 0, 125, 126, 125, 0, 125, - - 125, 125, 0, 0, 0, 0, 0, 0, 0, 125, - 125, 125, 125, 125, 0, 153, 153, 153, 153, 132, - 153, 153, 153, 136, 153, 122, 0, 0, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 0, 0, 0, 126, 0, 0, 125, - 0, 0, 125, 125, 125, 0, 0, 0, 0, 0, - 0, 0, 125, 125, 125, 0, 125, 125, 0, 0, - 0, 0, 0, 0, 0, 125, 125, 125, 0, 125, - 125, 125, 0, 0, 0, 0, 0, 0, 0, 125, - 125, 125, 0, 125, 125, 125, 0, 0, 0, 0, + 0, 125, 125, 125, 0, 0, 0, 0, 0, 0, + 0, 125, 125, 125, 0, 0, 0, 0, 0, 0, + 125, 125, 0, 125, 0, 125, 0, 129, 141, 143, - 0, 0, 0, 125, 125, 125, 0, 0, 0, 0, - 0, 0, 125, 125, 0, 125, 0, 125, 0, 129, - 141, 143, 137, 153, 153, 153, 153, 0, 0, 125, + 137, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 155, 180, 180, 180, 0, 0, 125, 0, 125, 0, 125, 125, 0, 125, 125, 0, 125, 125, 0, 125, 125, 0, 125, 0, 0, 0, 0, 125, 125, 0, 125, 0, 0, 125, 125, 125, 0, @@ -522,25 +554,44 @@ static yyconst flex_int16_t yy_accept[1470] = 0, 125, 125, 125, 0, 0, 0, 0, 0, 125, 125, 125, 0, 0, 0, 0, 0, 125, 125, 125, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, + 125, 125, 125, 0, 180, 180, 180, 180, 180, 180, - 125, 125, 125, 0, 153, 153, 153, 153, 0, 0, - 0, 125, 125, 125, 125, 125, 125, 0, 0, 0, - 0, 125, 125, 0, 0, 0, 0, 125, 125, 125, - 0, 0, 0, 0, 0, 125, 125, 125, 125, 0, - 0, 0, 0, 0, 125, 125, 125, 125, 0, 0, - 0, 0, 0, 125, 125, 125, 125, 0, 0, 0, - 0, 0, 125, 0, 0, 0, 0, 0, 125, 125, - 125, 153, 153, 153, 139, 125, 125, 125, 125, 125, - 125, 125, 125, 0, 0, 0, 0, 125, 125, 0, - 0, 125, 0, 0, 0, 125, 0, 0, 0, 125, + 147, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 0, 0, 0, 125, 125, 125, 125, 125, 125, + 0, 0, 0, 0, 125, 125, 0, 0, 0, 0, + 125, 125, 125, 0, 0, 0, 0, 0, 125, 125, + 125, 125, 0, 0, 0, 0, 0, 125, 125, 125, + 125, 0, 0, 0, 0, 0, 125, 125, 125, 125, + 0, 0, 0, 0, 0, 125, 0, 0, 0, 0, + 0, 125, 125, 125, 180, 180, 180, 139, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 125, 125, 125, 125, 125, 125, 125, 125, 0, - 0, 0, 0, 125, 0, 0, 0, 125, 125, 125, - 125, 0, 0, 0, 0, 0, 125, 134, 153, 131, - 125, 0, 0, 125, 125, 0, 125, 125, 125, 0, - 125, 125, 125, 0, 125, 125, 125, 0, 125, 125, - 125, 0, 0, 0, 0, 125, 135, 125, 125, 0, - 0, 0, 0, 0, 0, 125, 125, 125, 0, 0, - 125, 125, 125, 125, 125, 0, 125, 125, 0 + 0, 0, 0, 125, 125, 0, 0, 125, 0, 0, + 0, 125, 0, 0, 0, 125, 0, 0, 0, 125, + 0, 0, 0, 125, 125, 125, 125, 0, 0, 0, + 0, 0, 125, 134, 180, 131, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 156, 180, 125, + 0, 0, 125, 125, 0, 125, 125, 125, 0, 125, + 125, 125, 0, 125, 125, 125, 0, 125, 125, 125, + 0, 0, 0, 0, 125, 135, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 152, 180, 125, 125, + 0, 0, 0, 0, 0, 0, 125, 125, 125, 0, + + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 151, 0, 125, 125, 125, 125, 125, 0, 167, + 180, 180, 180, 180, 180, 180, 180, 154, 180, 180, + 125, 125, 166, 180, 180, 180, 180, 180, 180, 153, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 165, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 164, 180, 180, 180, + 180, 180, 170, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 157, 180, 180, 180, 180, 180, 150, + + 180, 180, 168, 180, 180, 180, 180, 180, 180, 148, + 180, 169, 180, 163, 180, 180, 180, 180, 158, 180, + 160, 180, 180, 162, 159, 149, 161, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -585,231 +636,259 @@ static yyconst flex_int32_t yy_meta[54] = 9, 4, 3 } ; -static yyconst flex_int16_t yy_base[1930] = +static yyconst flex_int16_t yy_base[2189] = { 0, - 0, 0, 3903, 53, 7432, 7432, 57, 3881, 64, 81, - 3893, 7432, 7432, 99, 30, 151, 46, 3879, 52, 168, + 0, 0, 5455, 53, 7856, 7856, 57, 5433, 64, 81, + 5445, 7856, 7856, 99, 30, 151, 46, 5430, 52, 168, 210, 168, 160, 44, 125, 60, 31, 58, 132, 170, - 214, 217, 229, 59, 170, 222, 237, 243, 250, 3867, - 255, 3858, 3843, 300, 7432, 0, 7432, 316, 339, 363, - 3876, 387, 0, 394, 0, 428, 7432, 7432, 7432, 7432, - 7432, 296, 316, 0, 3834, 3831, 3845, 0, 3844, 3832, - 3844, 3841, 3829, 3809, 3810, 3813, 3812, 3811, 3819, 3804, - 3817, 3785, 116, 3795, 3798, 3783, 3781, 3785, 3792, 3781, - 3772, 3762, 3761, 56, 68, 3766, 3764, 80, 3767, 3762, - - 3771, 68, 166, 0, 0, 15, 122, 3744, 3753, 189, - 3737, 3735, 3738, 3739, 3729, 3723, 3714, 3713, 3719, 0, - 3727, 0, 3709, 3715, 3709, 3695, 3695, 3695, 128, 3706, - 3688, 3698, 3676, 159, 3672, 201, 3670, 38, 3669, 3681, - 0, 3666, 0, 3665, 3664, 3654, 3661, 3652, 3643, 3657, - 7432, 7432, 453, 477, 236, 518, 542, 566, 3665, 573, - 3657, 597, 248, 3648, 3623, 3628, 3619, 0, 0, 3623, - 0, 3632, 3627, 3601, 3600, 3601, 3598, 3598, 3605, 0, - 0, 3600, 3575, 0, 3587, 3582, 3570, 3584, 3582, 3585, - 3582, 3566, 3544, 3541, 3556, 3539, 3542, 3537, 3539, 3552, - - 3523, 3522, 0, 3527, 3521, 0, 0, 3523, 3513, 0, - 3525, 0, 3522, 3501, 3488, 0, 0, 3477, 0, 3486, - 3493, 244, 3474, 0, 3472, 3488, 0, 3483, 0, 3471, - 0, 3453, 3457, 3451, 3453, 3458, 3451, 3447, 0, 3431, - 3444, 0, 3432, 0, 3430, 0, 0, 0, 3427, 0, - 153, 156, 3437, 0, 0, 3413, 0, 3410, 3411, 637, - 3440, 660, 684, 3437, 691, 500, 281, 715, 3428, 739, - 3427, 3411, 747, 290, 3410, 3409, 507, 788, 811, 3408, - 0, 0, 3382, 350, 3385, 3380, 0, 0, 0, 3357, - 0, 3356, 3357, 3338, 0, 3338, 0, 3332, 3317, 3318, - - 0, 3316, 3315, 0, 0, 0, 0, 0, 614, 3322, - 0, 0, 3328, 3310, 3301, 0, 0, 3278, 0, 0, - 0, 0, 3293, 3284, 3290, 0, 3281, 3268, 3284, 3257, - 3252, 3262, 3252, 0, 3227, 0, 3225, 0, 275, 0, - 0, 3212, 3207, 817, 3219, 0, 0, 0, 856, 880, - 293, 921, 3224, 3223, 405, 944, 968, 992, 3214, 999, - 621, 3213, 3210, 1022, 770, 1046, 1069, 3209, 0, 3198, - 427, 428, 1093, 3176, 1117, 333, 3175, 3182, 3150, 0, - 0, 0, 0, 3143, 0, 3157, 3156, 3129, 3128, 0, - 3125, 3117, 3114, 0, 0, 1136, 0, 3104, 3083, 3101, - - 0, 3090, 0, 3094, 3086, 0, 0, 3094, 3076, 291, - 3075, 3093, 294, 3090, 0, 3053, 3042, 3056, 3049, 3044, - 3041, 3021, 3039, 3031, 3018, 3018, 2987, 2993, 3008, 1173, - 3026, 1196, 1220, 3023, 1227, 777, 285, 1251, 334, 1291, - 1314, 1338, 3014, 3013, 1346, 336, 2997, 2996, 2995, 2993, - 1387, 363, 2991, 2990, 515, 631, 1428, 2989, 1452, 364, - 2973, 2980, 2967, 840, 0, 371, 2966, 903, 1493, 1516, - 2965, 0, 0, 2922, 2937, 2915, 0, 2924, 2876, 0, - 2882, 2895, 2879, 2893, 2892, 380, 2878, 427, 2863, 2871, - 2859, 2869, 0, 2859, 2869, 2860, 2865, 2849, 2838, 2837, - - 0, 0, 2841, 0, 2836, 2827, 2840, 2839, 2819, 2811, - 2822, 2813, 2807, 2804, 2809, 2814, 2798, 1541, 1565, 423, - 1606, 2821, 2820, 633, 1630, 1654, 1661, 1685, 2811, 1692, - 1716, 1739, 2810, 2808, 2807, 1762, 910, 1786, 1809, 2806, - 0, 1140, 0, 461, 2791, 1147, 1833, 1856, 2790, 0, - 785, 824, 2797, 485, 853, 856, 1880, 2788, 1904, 424, - 2787, 2793, 405, 2757, 2762, 2744, 0, 0, 2749, 2751, - 2737, 2737, 2748, 2731, 2730, 2723, 2715, 2716, 2727, 2726, - 0, 2716, 2710, 0, 0, 0, 2723, 2704, 2709, 2696, - 0, 0, 0, 0, 0, 2700, 0, 0, 0, 2689, - - 1944, 2722, 1967, 1991, 2720, 1998, 425, 2022, 2046, 2053, - 2077, 2697, 2696, 2085, 452, 2695, 2126, 476, 2694, 2693, - 2691, 2690, 2167, 512, 2689, 918, 938, 2208, 2673, 2232, - 513, 2672, 2679, 1167, 1169, 2678, 2676, 1261, 1262, 2273, - 2666, 2297, 517, 2650, 2657, 1276, 0, 1283, 0, 486, - 2648, 1369, 2338, 2361, 2647, 0, 2384, 452, 57, 497, - 150, 641, 205, 610, 2618, 258, 291, 570, 783, 2616, - 2615, 800, 2614, 2598, 1168, 893, 498, 2597, 2596, 2422, - 2459, 2495, 2531, 518, 2555, 551, 2563, 2587, 2623, 2594, - 2618, 2641, 2621, 2665, 2688, 2620, 2619, 2603, 2711, 1376, - - 2735, 2758, 2602, 0, 1410, 0, 582, 2601, 1417, 2782, - 2805, 2600, 0, 1475, 0, 1482, 0, 699, 2599, 1588, - 2829, 2852, 2597, 0, 570, 1595, 2604, 1425, 1490, 2603, - 2602, 1510, 1541, 2876, 2572, 2900, 572, 2571, 2578, 590, - 652, 615, 636, 787, 1427, 1914, 1492, 706, 709, 849, - 2095, 707, 937, 631, 803, 1898, 2122, 2942, 872, 2965, - 873, 2988, 1931, 3012, 3036, 2569, 2568, 3044, 660, 2566, - 3085, 661, 2565, 3126, 690, 2564, 2563, 2540, 2539, 3167, - 717, 2538, 1603, 1733, 3208, 2537, 3232, 718, 2536, 2542, - 1940, 1941, 2541, 2540, 2095, 2096, 3273, 2531, 3297, 787, - - 2484, 2490, 851, 2112, 2476, 2123, 2142, 2475, 2473, 2143, - 2162, 3338, 2462, 3362, 920, 2428, 2435, 0, 2190, 0, - 2255, 0, 756, 2414, 2262, 3403, 3426, 2392, 0, 936, - 960, 962, 1014, 1897, 1015, 1605, 1016, 1040, 1943, 1062, - 1922, 938, 3451, 3474, 3498, 967, 3538, 3562, 3586, 2387, - 3593, 3617, 3640, 2386, 3664, 3687, 2385, 3711, 3734, 2369, - 2368, 2367, 3757, 2320, 3781, 3804, 2366, 0, 2327, 0, - 1008, 2364, 2407, 3828, 3851, 2363, 0, 2445, 0, 2482, - 0, 1055, 2347, 2502, 3875, 3898, 2344, 0, 0, 2509, - 0, 2516, 0, 1078, 2343, 2523, 3922, 3945, 2341, 0, - - 0, 969, 2923, 2348, 2164, 2184, 2347, 2314, 2203, 2205, - 3969, 2305, 3993, 1045, 2304, 2308, 2337, 2398, 2399, 2272, - 1110, 2142, 2400, 1085, 2336, 1109, 1111, 1165, 1167, 4035, - 4059, 4068, 1188, 2299, 2282, 4086, 1066, 2280, 4127, 1119, - 2279, 4168, 1146, 2278, 4209, 1149, 2275, 2274, 2240, 4249, - 4273, 1196, 2239, 2270, 2378, 4314, 2234, 4338, 1197, 2217, - 2222, 2453, 2454, 2221, 2218, 2635, 2682, 4379, 2198, 4403, - 1198, 2193, 2200, 1226, 2930, 2199, 2938, 2939, 2180, 2165, - 2942, 3054, 4444, 2153, 4468, 1227, 2150, 2155, 0, 1228, - 3068, 2154, 3081, 3082, 2153, 2152, 3101, 3102, 4509, 2142, - - 4533, 1285, 2114, 2120, 0, 3149, 0, 3156, 0, 1235, - 2103, 3190, 4574, 4597, 2094, 0, 3081, 3242, 3243, 1189, - 2438, 2402, 1306, 3226, 2959, 1307, 1446, 1305, 4622, 4646, - 4655, 2093, 4672, 4696, 4719, 2092, 4743, 4766, 2090, 4790, - 4813, 2062, 4837, 4860, 2060, 2059, 4884, 1315, 2058, 2056, - 3197, 4925, 2055, 2054, 0, 3260, 0, 1300, 2030, 3320, - 4949, 2029, 2028, 0, 3327, 0, 3385, 0, 1396, 2027, - 3392, 4973, 2025, 2024, 0, 0, 3521, 0, 3528, 0, - 1525, 2023, 4016, 4997, 2005, 2003, 0, 0, 4023, 0, - 4075, 0, 1549, 2001, 4109, 5021, 1922, 1864, 0, 0, - - 1316, 4116, 1870, 3205, 3268, 1847, 1824, 3335, 3400, 5045, - 1814, 5069, 1317, 1811, 1803, 1708, 1709, 1731, 1557, 1385, - 1780, 4125, 1624, 1386, 2440, 5111, 1792, 5128, 5152, 1427, - 1791, 5193, 1429, 1768, 5234, 1489, 1767, 5275, 1492, 1748, - 5316, 1538, 1747, 1746, 4153, 5357, 1744, 1664, 0, 1663, - 3420, 3451, 5381, 1636, 1608, 1615, 3537, 3634, 1582, 1575, - 3681, 3728, 5405, 1565, 1550, 1551, 1540, 4191, 1531, 4137, - 4138, 1527, 1508, 4165, 4185, 5429, 1499, 1494, 1462, 0, - 1600, 4232, 1442, 4204, 4206, 1438, 1437, 4226, 4248, 5453, - 1392, 1390, 1397, 0, 1605, 4296, 1363, 4290, 4309, 1362, - - 1361, 4311, 4348, 5477, 1351, 1299, 1264, 0, 4362, 0, - 4369, 0, 1669, 1252, 4426, 5501, 0, 1251, 0, 1621, - 1710, 1754, 1778, 1779, 2013, 4462, 4478, 5525, 1607, 0, - 1236, 5566, 0, 75, 5590, 0, 102, 5614, 0, 137, - 5638, 0, 143, 5662, 0, 195, 4420, 4441, 5686, 198, - 217, 250, 314, 317, 4495, 0, 1670, 341, 348, 4556, - 0, 4563, 0, 1842, 372, 412, 0, 4662, 0, 4907, - 0, 1865, 414, 431, 0, 4914, 0, 5092, 0, 1953, - 435, 462, 0, 5099, 0, 5118, 0, 1976, 548, 551, - 0, 1660, 5175, 583, 4504, 4571, 608, 629, 4591, 4671, - - 5710, 644, 0, 654, 2457, 1803, 1826, 1849, 5734, 694, - 752, 0, 0, 0, 0, 0, 0, 5182, 0, 2006, - 754, 755, 0, 4713, 4760, 797, 798, 0, 1661, 5216, - 803, 4807, 4854, 826, 828, 0, 0, 1662, 5223, 850, - 4922, 5127, 888, 895, 0, 0, 1689, 5257, 897, 5231, - 5251, 930, 931, 0, 0, 1691, 5298, 976, 5270, 5272, - 985, 1010, 0, 0, 5339, 0, 5346, 0, 2007, 1004, - 0, 3101, 3003, 2224, 1827, 0, 7432, 0, 0, 0, - 0, 0, 0, 5292, 5354, 1035, 1056, 0, 7432, 5548, - 0, 7432, 0, 5555, 0, 7432, 0, 5757, 0, 7432, - - 0, 5764, 0, 7432, 0, 5771, 0, 7432, 0, 1692, - 5778, 1060, 5563, 5786, 1083, 2061, 0, 1850, 3270, 1872, - 0, 5786, 0, 1855, 5800, 1103, 0, 1877, 5807, 1104, - 0, 1879, 5814, 1132, 0, 1880, 5826, 1155, 0, 1938, - 5833, 1156, 0, 5840, 0, 7432, 1960, 1943, 5847, 1161, - 0, 0, 0, 0, 0, 0, 1968, 5854, 1213, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7432, 5872, - 5880, 5884, 5887, 5890, 5893, 5896, 5899, 5902, 5905, 5908, - 5911, 5914, 5917, 5920, 5923, 5926, 5929, 5932, 5936, 5940, - 5943, 5946, 5949, 5952, 5955, 5958, 5961, 5964, 5968, 5972, - - 5975, 5978, 5982, 5984, 5987, 5990, 5993, 5996, 5999, 6002, - 6005, 6008, 6012, 6014, 6017, 6021, 6026, 6030, 6033, 6037, - 6040, 6043, 6046, 6049, 6052, 6055, 6058, 6062, 6066, 6069, - 6073, 6077, 6082, 6086, 6088, 6092, 6095, 6099, 6102, 6105, - 6109, 6111, 6114, 6117, 6120, 6123, 6126, 6129, 6132, 6135, - 6138, 6142, 6144, 6147, 6150, 6153, 6157, 6159, 6162, 6165, - 6170, 6174, 6179, 6183, 6185, 6189, 6192, 6196, 6201, 6205, - 6208, 6211, 6214, 6217, 6220, 6223, 6226, 6230, 6234, 6237, - 6241, 6245, 6250, 6254, 6256, 6260, 6263, 6267, 6270, 6275, - 6279, 6284, 6288, 6290, 6294, 6297, 6301, 6304, 6307, 6310, - - 6314, 6316, 6319, 6324, 6328, 6331, 6334, 6337, 6340, 6343, - 6346, 6349, 6352, 6356, 6358, 6361, 6364, 6367, 6371, 6373, - 6376, 6379, 6382, 6385, 6389, 6391, 6394, 6397, 6400, 6405, - 6409, 6414, 6418, 6420, 6424, 6427, 6431, 6436, 6440, 6443, - 6446, 6449, 6452, 6455, 6458, 6461, 6465, 6469, 6472, 6476, - 6480, 6485, 6489, 6491, 6495, 6498, 6502, 6505, 6510, 6514, - 6519, 6523, 6525, 6529, 6532, 6536, 6539, 6542, 6547, 6551, - 6556, 6560, 6562, 6566, 6569, 6573, 6576, 6579, 6582, 6586, - 6588, 6591, 6596, 6600, 6603, 6606, 6609, 6612, 6615, 6618, - 6621, 6624, 6627, 6630, 6633, 6637, 6639, 6642, 6645, 6648, - - 6651, 6655, 6657, 6660, 6663, 6666, 6669, 6672, 6676, 6678, - 6681, 6684, 6687, 6690, 6693, 6697, 6699, 6702, 6705, 6708, - 6711, 6716, 6720, 6725, 6729, 6731, 6735, 6738, 6742, 6747, - 6751, 6754, 6757, 6760, 6763, 6766, 6769, 6772, 6775, 6778, - 6782, 6786, 6789, 6793, 6797, 6802, 6806, 6808, 6812, 6815, - 6819, 6822, 6827, 6831, 6836, 6840, 6842, 6846, 6849, 6853, - 6856, 6859, 6864, 6868, 6873, 6877, 6879, 6883, 6886, 6890, - 6893, 6896, 6901, 6905, 6910, 6914, 6916, 6920, 6923, 6927, - 6930, 6933, 6936, 6940, 6942, 6945, 6948, 6953, 6957, 6960, - 6963, 6966, 6969, 6972, 6975, 6978, 6981, 6984, 6987, 6990, - - 6994, 6998, 7001, 7004, 7008, 7011, 7014, 7018, 7020, 7023, - 7026, 7030, 7032, 7035, 7038, 7041, 7045, 7047, 7050, 7053, - 7056, 7060, 7062, 7065, 7068, 7071, 7075, 7077, 7080, 7083, - 7088, 7092, 7097, 7101, 7103, 7107, 7110, 7114, 7119, 7123, - 7126, 7129, 7132, 7135, 7138, 7141, 7144, 7147, 7151, 7153, - 7156, 7160, 7165, 7169, 7170, 7173, 7178, 7182, 7187, 7191, - 7192, 7195, 7198, 7203, 7207, 7212, 7216, 7217, 7220, 7223, - 7228, 7232, 7237, 7241, 7242, 7245, 7248, 7253, 7257, 7262, - 7266, 7267, 7270, 7273, 7276, 7280, 7282, 7287, 7291, 7294, - 7297, 7300, 7303, 7306, 7309, 7313, 7318, 7322, 7323, 7326, - - 7329, 7332, 7335, 7338, 7341, 7344, 7347, 7350, 7353, 7358, - 7362, 7365, 7368, 7371, 7375, 7379, 7383, 7387, 7391, 7394, - 7397, 7401, 7404, 7407, 7410, 7413, 7416, 7420, 7423 + 214, 217, 229, 59, 170, 222, 237, 243, 250, 5418, + 255, 5410, 5380, 300, 7856, 0, 7856, 316, 339, 363, + 5413, 387, 0, 394, 0, 428, 7856, 7856, 7856, 7856, + 7856, 296, 316, 0, 5386, 5383, 5397, 0, 5395, 5383, + 5396, 5378, 5366, 5360, 5361, 5362, 5360, 5344, 5352, 5337, + 5350, 5331, 116, 5341, 5312, 5297, 5295, 5299, 5305, 5294, + 5299, 5279, 5278, 56, 68, 5263, 5261, 80, 5265, 5259, + + 5267, 68, 166, 0, 0, 15, 122, 5255, 5264, 189, + 5238, 5236, 5219, 5222, 5212, 5219, 5209, 5208, 5214, 0, + 5212, 0, 5195, 5181, 5175, 5176, 5175, 5174, 128, 5185, + 5168, 5167, 5160, 159, 5147, 201, 5144, 38, 5137, 5149, + 0, 5133, 0, 5112, 5111, 5094, 5090, 5078, 5048, 5062, + 7856, 7856, 453, 477, 236, 518, 542, 566, 5071, 573, + 5078, 597, 248, 5054, 5029, 5034, 5025, 0, 0, 5030, + 0, 5038, 5033, 5022, 5006, 5007, 5004, 5005, 5012, 0, + 0, 5006, 4996, 0, 5008, 4988, 4976, 4990, 4989, 4992, + 4988, 4972, 4971, 4953, 4969, 4952, 4956, 4951, 4952, 4965, + + 4950, 4934, 0, 4939, 4933, 0, 0, 4937, 4927, 0, + 4938, 0, 4935, 4907, 4912, 0, 0, 4901, 0, 4909, + 4917, 244, 4899, 0, 4887, 4882, 0, 4877, 0, 4880, + 0, 4861, 4864, 4857, 4845, 4850, 4843, 4839, 0, 4837, + 4849, 0, 4838, 0, 4837, 0, 0, 0, 4819, 0, + 153, 156, 4830, 0, 0, 4821, 0, 4818, 4818, 637, + 4847, 660, 684, 4830, 691, 500, 281, 715, 4821, 739, + 4820, 4819, 747, 290, 4818, 4816, 507, 788, 811, 4815, + 0, 0, 4775, 350, 4778, 4783, 0, 0, 0, 4781, + 0, 4777, 4762, 4746, 0, 4746, 0, 4740, 4739, 4740, + + 0, 4722, 4721, 0, 0, 0, 0, 0, 614, 4728, + 0, 0, 4736, 4715, 4700, 0, 0, 4698, 0, 0, + 0, 0, 4713, 4704, 4710, 0, 4703, 4706, 4707, 4679, + 4675, 4667, 4639, 0, 4632, 0, 4607, 0, 275, 0, + 0, 4599, 4592, 817, 4585, 0, 0, 0, 856, 880, + 293, 921, 4610, 4608, 405, 944, 968, 992, 4598, 999, + 621, 4581, 4579, 1022, 770, 1046, 1069, 4562, 0, 4553, + 427, 428, 1093, 4552, 1117, 333, 4551, 4550, 4519, 0, + 0, 0, 0, 4491, 0, 4504, 4502, 4469, 4460, 0, + 4477, 4472, 4463, 0, 0, 1136, 293, 4453, 4420, 4437, + + 0, 4427, 0, 4429, 4422, 0, 0, 4420, 4394, 292, + 4393, 4411, 387, 4408, 0, 4390, 4382, 4394, 4368, 4362, + 4372, 4350, 4357, 4338, 4317, 4318, 4310, 4278, 4292, 1173, + 4310, 1196, 1220, 4305, 1227, 777, 285, 1251, 334, 1291, + 1314, 1338, 4294, 4293, 1346, 336, 4291, 4256, 4255, 4254, + 1387, 363, 4252, 4251, 515, 631, 1428, 4250, 1452, 364, + 4240, 4247, 4218, 840, 0, 371, 4214, 903, 1493, 1516, + 4212, 0, 0, 4184, 4200, 4149, 0, 4158, 4140, 0, + 4145, 4158, 4143, 4126, 4125, 380, 4109, 427, 4108, 1121, + 4106, 4095, 4082, 4067, 4076, 0, 4066, 4077, 4025, 4028, + + 4026, 4015, 4014, 0, 0, 4018, 0, 3981, 3973, 3986, + 3984, 3976, 3949, 3960, 3929, 3923, 3918, 3909, 3888, 3885, + 1541, 1565, 423, 1606, 3892, 3888, 633, 1630, 1654, 1661, + 1685, 3877, 1692, 1716, 1739, 3876, 3857, 3856, 1762, 910, + 1786, 1809, 3852, 0, 1274, 0, 461, 3837, 1281, 1833, + 1856, 3833, 0, 785, 824, 3820, 485, 853, 856, 1880, + 3810, 1904, 424, 3809, 3798, 529, 3762, 3765, 3739, 0, + 0, 3742, 3729, 3715, 3691, 3703, 3683, 3666, 3672, 3664, + 3643, 3632, 3633, 3619, 3601, 56, 504, 646, 3609, 3575, + 3584, 3582, 0, 3573, 3567, 0, 0, 0, 3580, 3552, + + 3533, 3519, 0, 0, 0, 0, 0, 3523, 0, 0, + 0, 3512, 1944, 3547, 1967, 1991, 3514, 1998, 325, 2022, + 2046, 2053, 2077, 3505, 3474, 2085, 452, 3434, 2126, 476, + 3393, 3386, 3385, 3365, 2167, 513, 3345, 918, 938, 2208, + 3344, 2232, 542, 3343, 3348, 1142, 1149, 3347, 3314, 1167, + 1169, 2273, 3305, 2297, 543, 3304, 3310, 1369, 0, 1376, + 0, 486, 3282, 1410, 2338, 2361, 3278, 0, 2384, 374, + 115, 389, 150, 672, 205, 610, 3235, 550, 403, 313, + 783, 553, 761, 522, 800, 451, 578, 893, 633, 829, + 571, 1108, 1112, 3231, 3228, 1123, 3206, 3189, 1130, 1128, + + 593, 3186, 3185, 2422, 2459, 2495, 2531, 634, 2555, 258, + 2563, 2587, 3194, 2594, 2618, 2641, 3193, 2665, 2688, 3191, + 3188, 3185, 2711, 1417, 2735, 2758, 3184, 0, 1475, 0, + 723, 3172, 1482, 2782, 2805, 3147, 0, 1588, 0, 1595, + 0, 724, 3146, 1927, 2829, 2852, 3135, 0, 661, 1934, + 3122, 1290, 1425, 3114, 3111, 1490, 1510, 2876, 3101, 2900, + 662, 3090, 3061, 636, 803, 653, 1290, 1427, 1492, 2095, + 1604, 708, 849, 937, 2122, 872, 1605, 1944, 804, 1187, + 1242, 2099, 936, 960, 1532, 2101, 874, 938, 1015, 962, + 1014, 2124, 2163, 2942, 1016, 2965, 1038, 2988, 2154, 3012, + + 3036, 3052, 3051, 3044, 686, 3049, 3085, 967, 3047, 3126, + 969, 3046, 3045, 3020, 3017, 3167, 970, 2967, 1541, 1733, + 3208, 2966, 3232, 1022, 2947, 2953, 2096, 2163, 2951, 2950, + 2164, 2182, 3273, 2909, 3297, 1042, 2908, 2915, 1043, 2255, + 2913, 2183, 2184, 2911, 2892, 2205, 2249, 3338, 2882, 3362, + 1045, 2881, 2886, 0, 2263, 0, 2320, 0, 756, 2857, + 2327, 3403, 3426, 2853, 0, 1061, 1062, 1087, 1111, 2337, + 1188, 1943, 1189, 1244, 2376, 1534, 2377, 2336, 1109, 1243, + 2402, 2013, 1306, 2096, 2378, 1446, 2375, 1245, 3451, 3474, + 3498, 1066, 3538, 3562, 3586, 2834, 3593, 3617, 3640, 2830, + + 3664, 3687, 2811, 3711, 3734, 2810, 2806, 2791, 3757, 2445, + 3781, 3804, 2789, 0, 2482, 0, 1008, 2787, 2502, 3828, + 3851, 2744, 0, 2509, 0, 2516, 0, 1153, 2741, 2523, + 3875, 3898, 2740, 0, 0, 2923, 0, 2930, 0, 1300, + 2718, 3067, 3922, 3945, 2717, 0, 0, 1198, 3074, 2724, + 2399, 2417, 2721, 2701, 2453, 2454, 3969, 2670, 3993, 1285, + 2649, 2655, 2401, 2438, 3083, 2398, 1558, 2457, 2940, 1708, + 3084, 1557, 1385, 1709, 1508, 1754, 1710, 1755, 1778, 3120, + 1779, 3118, 1801, 1803, 1825, 4035, 4059, 4068, 1826, 2646, + 2643, 4086, 1287, 2624, 4127, 1288, 2600, 4168, 1315, 2599, + + 4209, 1345, 2597, 2596, 2595, 4249, 4273, 1427, 2594, 2635, + 2682, 4314, 2572, 4338, 1429, 2571, 2578, 2938, 2942, 2577, + 2576, 3096, 3142, 4379, 2566, 4403, 1489, 2540, 2544, 1600, + 3156, 2542, 3151, 3164, 2541, 2540, 3183, 3184, 4444, 2531, + 4468, 1603, 2468, 2469, 0, 1605, 3255, 2438, 3203, 3205, + 2372, 2371, 3249, 3268, 4509, 2343, 4533, 1606, 2341, 2348, + 0, 3320, 0, 3327, 0, 1396, 2306, 3385, 4574, 4597, + 2299, 0, 3095, 3096, 3178, 1827, 3122, 2399, 1848, 3420, + 2959, 1849, 1850, 1872, 3248, 3380, 1874, 1896, 3490, 2014, + 3492, 1959, 2016, 3337, 4622, 4646, 4655, 2275, 4672, 4696, + + 4719, 2263, 4743, 4766, 2239, 4790, 4813, 2234, 4837, 4860, + 2198, 2194, 4884, 1630, 2192, 2145, 3523, 4925, 2144, 2107, + 0, 3530, 0, 1615, 2106, 4016, 4949, 2103, 2060, 0, + 4023, 0, 4075, 0, 1639, 2059, 4109, 4973, 2058, 2055, + 0, 0, 4116, 0, 4150, 0, 1669, 2000, 4157, 4997, + 1999, 1976, 0, 0, 4191, 0, 4198, 0, 1748, 1951, + 4232, 5021, 1945, 1913, 0, 0, 1660, 4239, 1917, 3335, + 3399, 1914, 1897, 3400, 3420, 5045, 1882, 5069, 1661, 1842, + 1846, 2102, 2177, 2200, 2289, 2103, 2612, 4283, 2226, 2473, + 4266, 2680, 4348, 4267, 4331, 3249, 3271, 4289, 4332, 3399, + + 2610, 2611, 4396, 5111, 1815, 5128, 5152, 1662, 1814, 5193, + 1689, 1811, 5234, 1736, 1795, 5275, 1879, 1791, 5316, 1880, + 1747, 1744, 4365, 5357, 1741, 1698, 0, 1697, 3634, 3681, + 5381, 1670, 1664, 1671, 3728, 4289, 1616, 1580, 4374, 4418, + 5405, 1568, 1565, 1552, 1938, 4432, 1527, 4441, 4478, 1508, + 1506, 4479, 4483, 5429, 1494, 1454, 1442, 0, 1940, 4497, + 1438, 4506, 4543, 1437, 1400, 4544, 4548, 5453, 1390, 1389, + 1363, 0, 1941, 4562, 1362, 4571, 4591, 83, 110, 4666, + 4667, 5477, 195, 198, 225, 0, 4907, 0, 4914, 0, + 2006, 307, 5092, 5501, 0, 348, 0, 2474, 2635, 2657, + + 2659, 2681, 3003, 5107, 5162, 4670, 2703, 4291, 4356, 2682, + 4376, 4923, 4443, 2728, 2729, 5108, 5163, 5525, 1943, 0, + 372, 5566, 0, 399, 5590, 0, 418, 5614, 0, 480, + 5638, 0, 520, 5662, 0, 544, 4671, 4713, 5686, 551, + 580, 582, 610, 604, 5180, 0, 2061, 624, 643, 5216, + 0, 5223, 0, 2062, 696, 697, 0, 5257, 0, 5264, + 0, 2109, 698, 720, 0, 5298, 0, 5305, 0, 2142, + 721, 749, 0, 5339, 0, 5346, 0, 2193, 750, 752, + 0, 1995, 5548, 762, 4760, 4807, 763, 798, 4854, 5086, + 5710, 793, 0, 804, 4508, 2751, 2752, 2774, 2775, 5146, + + 2776, 2799, 2822, 2823, 5720, 2845, 5703, 5722, 2846, 3270, + 3489, 5755, 820, 864, 0, 0, 0, 0, 0, 0, + 5555, 0, 2282, 880, 887, 0, 5127, 5354, 897, 930, + 0, 1997, 5739, 931, 5563, 5724, 934, 976, 0, 0, + 2024, 5778, 985, 5752, 5772, 1012, 1039, 0, 0, 2151, + 5792, 1063, 5787, 5788, 1102, 1103, 0, 0, 2181, 5802, + 1107, 5800, 5810, 1132, 1160, 0, 0, 5814, 0, 5828, + 0, 2347, 1176, 0, 5085, 3553, 2868, 2870, 3103, 5824, + 5827, 5837, 5838, 5839, 5826, 3379, 5843, 2892, 4573, 5736, + 2981, 0, 7856, 0, 0, 0, 0, 0, 0, 5845, + + 5847, 1190, 1235, 0, 7856, 5871, 0, 7856, 0, 5887, + 0, 7856, 0, 5894, 0, 7856, 0, 5901, 0, 7856, + 0, 5908, 0, 7856, 0, 2270, 5915, 1236, 5923, 5924, + 1237, 2414, 0, 2980, 5086, 2982, 3004, 5926, 5356, 5565, + 3201, 5849, 4287, 3005, 5927, 5106, 5850, 3006, 5928, 0, + 5927, 0, 2272, 5954, 1240, 0, 2273, 5964, 1264, 0, + 2338, 5971, 1306, 0, 2396, 5978, 1322, 0, 2531, 5985, + 1356, 0, 5992, 0, 7856, 3177, 6001, 3442, 3444, 3467, + 6002, 6004, 6005, 6008, 3491, 6006, 3378, 6007, 2532, 6007, + 1357, 0, 0, 0, 0, 0, 0, 2533, 6043, 1361, + + 6016, 6037, 5852, 6039, 3554, 6040, 3555, 3556, 6017, 6052, + 6056, 3419, 0, 0, 0, 0, 0, 0, 0, 3466, + 6059, 3611, 3658, 3705, 6060, 6062, 6063, 3468, 6065, 6066, + 0, 0, 3609, 3610, 3634, 3656, 6067, 3680, 6068, 3681, + 6073, 6082, 6092, 6095, 3727, 6101, 3728, 6103, 3749, 5102, + 3773, 3774, 3797, 6106, 6111, 6115, 3775, 6116, 6122, 3820, + 6123, 6126, 6128, 3822, 6114, 6142, 6148, 3844, 3845, 6152, + 6153, 6154, 6155, 3869, 3890, 6158, 3891, 6162, 3914, 6163, + 6167, 3915, 3916, 3938, 6169, 6177, 4737, 6191, 3939, 6182, + 6194, 6197, 6198, 3961, 6204, 6203, 6205, 3963, 6206, 3985, + + 4084, 6213, 3987, 6218, 6227, 4125, 4613, 6219, 4308, 4032, + 6228, 4033, 4615, 4085, 6238, 6229, 6240, 4784, 4166, 6239, + 4207, 6241, 6268, 4208, 4665, 4666, 4669, 7856, 6296, 6304, + 6308, 6311, 6314, 6317, 6320, 6323, 6326, 6329, 6332, 6335, + 6338, 6341, 6344, 6347, 6350, 6353, 6356, 6360, 6364, 6367, + 6370, 6373, 6376, 6379, 6382, 6385, 6388, 6392, 6396, 6399, + 6402, 6406, 6408, 6411, 6414, 6417, 6420, 6423, 6426, 6429, + 6432, 6436, 6438, 6441, 6445, 6450, 6454, 6457, 6461, 6464, + 6467, 6470, 6473, 6476, 6479, 6482, 6486, 6490, 6493, 6497, + 6501, 6506, 6510, 6512, 6516, 6519, 6523, 6526, 6529, 6533, + + 6535, 6538, 6541, 6544, 6547, 6550, 6553, 6556, 6559, 6562, + 6566, 6568, 6571, 6574, 6577, 6581, 6583, 6586, 6589, 6594, + 6598, 6603, 6607, 6609, 6613, 6616, 6620, 6625, 6629, 6632, + 6635, 6638, 6641, 6644, 6647, 6650, 6654, 6658, 6661, 6665, + 6669, 6674, 6678, 6680, 6684, 6687, 6691, 6694, 6699, 6703, + 6708, 6712, 6714, 6718, 6721, 6725, 6728, 6731, 6734, 6738, + 6740, 6743, 6748, 6752, 6755, 6758, 6761, 6764, 6767, 6770, + 6773, 6776, 6780, 6782, 6785, 6788, 6791, 6795, 6797, 6800, + 6803, 6806, 6809, 6813, 6815, 6818, 6821, 6824, 6829, 6833, + 6838, 6842, 6844, 6848, 6851, 6855, 6860, 6864, 6867, 6870, + + 6873, 6876, 6879, 6882, 6885, 6889, 6893, 6896, 6900, 6904, + 6909, 6913, 6915, 6919, 6922, 6926, 6929, 6934, 6938, 6943, + 6947, 6949, 6953, 6956, 6960, 6963, 6966, 6971, 6975, 6980, + 6984, 6986, 6990, 6993, 6997, 7000, 7003, 7006, 7010, 7012, + 7015, 7020, 7024, 7027, 7030, 7033, 7036, 7039, 7042, 7045, + 7048, 7051, 7054, 7057, 7061, 7063, 7066, 7069, 7072, 7075, + 7079, 7081, 7084, 7087, 7090, 7093, 7096, 7100, 7102, 7105, + 7108, 7111, 7114, 7117, 7121, 7123, 7126, 7129, 7132, 7135, + 7140, 7144, 7149, 7153, 7155, 7159, 7162, 7166, 7171, 7175, + 7178, 7181, 7184, 7187, 7190, 7193, 7196, 7199, 7202, 7206, + + 7210, 7213, 7217, 7221, 7226, 7230, 7232, 7236, 7239, 7243, + 7246, 7251, 7255, 7260, 7264, 7266, 7270, 7273, 7277, 7280, + 7283, 7288, 7292, 7297, 7301, 7303, 7307, 7310, 7314, 7317, + 7320, 7325, 7329, 7334, 7338, 7340, 7344, 7347, 7351, 7354, + 7357, 7360, 7364, 7366, 7369, 7372, 7377, 7381, 7384, 7387, + 7390, 7393, 7396, 7399, 7402, 7405, 7408, 7411, 7414, 7418, + 7422, 7425, 7428, 7432, 7435, 7438, 7442, 7444, 7447, 7450, + 7454, 7456, 7459, 7462, 7465, 7469, 7471, 7474, 7477, 7480, + 7484, 7486, 7489, 7492, 7495, 7499, 7501, 7504, 7507, 7512, + 7516, 7521, 7525, 7527, 7531, 7534, 7538, 7543, 7547, 7550, + + 7553, 7556, 7559, 7562, 7565, 7568, 7571, 7575, 7577, 7580, + 7584, 7589, 7593, 7594, 7597, 7602, 7606, 7611, 7615, 7616, + 7619, 7622, 7627, 7631, 7636, 7640, 7641, 7644, 7647, 7652, + 7656, 7661, 7665, 7666, 7669, 7672, 7677, 7681, 7686, 7690, + 7691, 7694, 7697, 7700, 7704, 7706, 7711, 7715, 7718, 7721, + 7724, 7727, 7730, 7733, 7737, 7742, 7746, 7747, 7750, 7753, + 7756, 7759, 7762, 7765, 7768, 7771, 7774, 7777, 7782, 7786, + 7789, 7792, 7795, 7799, 7803, 7807, 7811, 7815, 7818, 7821, + 7825, 7828, 7831, 7834, 7837, 7840, 7844, 7847 } ; -static yyconst flex_int16_t yy_def[1930] = +static yyconst flex_int16_t yy_def[2189] = { 0, - 1469, 1, 1469, 1469, 1469, 1469, 1469, 1469, 1470, 1469, - 1469, 1469, 1469, 1469, 14, 1469, 1469, 1469, 1469, 14, - 20, 1471, 20, 20, 20, 20, 20, 20, 21, 21, + 1728, 1, 1728, 1728, 1728, 1728, 1728, 1728, 1729, 1728, + 1728, 1728, 1728, 1728, 14, 1728, 1728, 1728, 1728, 14, + 20, 1730, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 1469, 1469, 1469, 1472, 1469, 21, 21, 20, - 1473, 50, 21, 21, 21, 1469, 1469, 1469, 1469, 1469, - 1469, 49, 1471, 1471, 52, 52, 52, 21, 21, 21, + 21, 21, 1728, 1728, 1728, 1731, 1728, 21, 21, 20, + 1732, 50, 21, 21, 21, 1728, 1728, 1728, 1728, 1728, + 1728, 49, 1730, 1730, 52, 52, 52, 21, 21, 21, 21, 52, 21, 21, 52, 21, 21, 21, 52, 21, 21, 21, 21, 21, 52, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -819,8 +898,8 @@ static yyconst flex_int16_t yy_def[1930] = 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 1469, 1469, 21, 21, 154, 21, 21, 157, 1474, 1469, - 54, 1469, 162, 1475, 21, 21, 158, 21, 21, 21, + 1728, 1728, 21, 21, 154, 21, 21, 157, 1733, 1728, + 54, 1728, 162, 1734, 21, 21, 158, 21, 21, 21, 158, 21, 21, 21, 21, 21, 21, 158, 21, 21, 21, 21, 21, 21, 21, 158, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -831,9 +910,9 @@ static yyconst flex_int16_t yy_def[1930] = 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 262, 263, 158, 1476, 268, - 1477, 1478, 1469, 273, 1479, 1480, 1469, 1469, 1469, 1481, - 1482, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 262, 263, 158, 1735, 268, + 1736, 1737, 1728, 273, 1738, 1739, 1728, 1728, 1728, 1740, + 1741, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -841,9 +920,9 @@ static yyconst flex_int16_t yy_def[1930] = 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 350, 21, 263, 265, 263, 265, 265, 357, 1483, 1469, - 356, 1484, 1485, 1469, 1469, 1469, 1469, 1486, 1487, 1488, - 1489, 1489, 1469, 1490, 1469, 375, 1491, 1482, 21, 21, + 350, 21, 263, 265, 263, 265, 265, 357, 1742, 1728, + 356, 1743, 1744, 1728, 1728, 1728, 1728, 1745, 1746, 1747, + 1748, 1748, 1728, 1749, 1728, 375, 1750, 1741, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -851,173 +930,201 @@ static yyconst flex_int16_t yy_def[1930] = 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 432, 433, 433, 438, 432, - 357, 441, 1492, 1493, 1469, 445, 1494, 1469, 1495, 1496, - 1469, 451, 1497, 1498, 1499, 1499, 1469, 1500, 1469, 459, - 1501, 1487, 1469, 1469, 1502, 1503, 1469, 1469, 1469, 1469, - 1504, 1505, 21, 21, 21, 21, 21, 21, 21, 21, + 357, 441, 1751, 1752, 1728, 445, 1753, 1728, 1754, 1755, + 1728, 451, 1756, 1757, 1758, 1758, 1728, 1759, 1728, 459, + 1760, 1746, 1728, 1728, 1761, 1762, 1728, 1728, 1728, 1728, + 1763, 1764, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 519, - 21, 433, 435, 433, 433, 525, 441, 527, 1506, 1469, - 1469, 1469, 1507, 1508, 1509, 1469, 1469, 1469, 1469, 1510, - 1511, 1469, 1512, 1513, 1469, 1469, 1469, 1469, 1514, 1515, - 1516, 1516, 1502, 1503, 1517, 1517, 1469, 1518, 1469, 559, - 1519, 1520, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 522, 21, 433, 435, 433, 433, 528, 441, + 530, 1765, 1728, 1728, 1728, 1766, 1767, 1768, 1728, 1728, + 1728, 1728, 1769, 1770, 1728, 1771, 1772, 1728, 1728, 1728, + 1728, 1773, 1774, 1775, 1775, 1761, 1762, 1776, 1776, 1728, + 1777, 1728, 562, 1778, 1779, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 604, 604, 608, 527, - 610, 1521, 1522, 1469, 614, 1523, 1469, 617, 1524, 1469, - 1525, 1526, 1469, 623, 1527, 1528, 1528, 1469, 1529, 1469, - 630, 1530, 1531, 1532, 1532, 1533, 1534, 1535, 1535, 1469, - 1536, 1469, 642, 1537, 1538, 1469, 1539, 1469, 1540, 1541, - 1469, 1469, 1469, 1469, 1542, 1543, 611, 657, 657, 657, - 657, 657, 657, 657, 657, 657, 657, 657, 657, 657, - 657, 657, 657, 657, 657, 657, 657, 657, 657, 657, - 657, 657, 682, 682, 682, 657, 682, 687, 1544, 1469, - 1469, 1469, 1545, 1469, 1469, 1546, 1547, 1548, 1469, 1469, - - 1469, 1469, 1549, 1550, 1469, 1551, 1552, 1469, 1469, 1469, - 1469, 1553, 1554, 1469, 1555, 1469, 1556, 1557, 1469, 1469, - 1469, 1469, 1558, 1559, 1560, 1469, 1561, 1562, 1562, 1563, - 1564, 1565, 1565, 1469, 1566, 1469, 736, 1567, 1568, 1569, - 1569, 1569, 1569, 1569, 1569, 1569, 1569, 1569, 1569, 1569, - 1569, 1569, 1569, 1569, 1569, 1569, 1569, 1569, 1569, 758, - 1569, 758, 762, 762, 764, 1570, 1571, 1469, 768, 1572, - 1469, 771, 1573, 1469, 774, 1574, 1469, 1575, 1576, 1469, - 780, 1577, 1578, 1578, 1469, 1579, 1469, 787, 1580, 1581, - 1582, 1582, 1583, 1584, 1585, 1585, 1469, 1586, 1469, 799, - - 1587, 1588, 1589, 1469, 1590, 1591, 1591, 1592, 1593, 1594, - 1594, 1469, 1595, 1469, 814, 1596, 1597, 1598, 1469, 1599, - 1469, 1600, 1601, 1469, 1469, 1469, 1469, 1602, 1603, 1604, - 1604, 1604, 1604, 1604, 1604, 1604, 1604, 1604, 1604, 1604, - 1604, 1604, 1604, 843, 843, 845, 843, 843, 848, 1605, - 1469, 1469, 1469, 1606, 1469, 1469, 1607, 1469, 1469, 1608, - 1609, 1610, 1469, 1469, 1469, 1469, 1611, 1612, 1469, 1613, - 1614, 1469, 1469, 1469, 1469, 1615, 1616, 1469, 1617, 1469, - 1618, 1619, 1469, 1469, 1469, 1469, 1620, 1621, 1622, 1469, - 1623, 1469, 1624, 1625, 1469, 1469, 1469, 1469, 1626, 1627, - - 1628, 1629, 1469, 1630, 1631, 1631, 1632, 1633, 1634, 1634, - 1469, 1635, 1469, 913, 1636, 1637, 1638, 1638, 1638, 1638, - 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, - 930, 1638, 1638, 1639, 1640, 1469, 936, 1641, 1469, 939, - 1642, 1469, 942, 1643, 1469, 945, 1644, 1469, 1645, 1469, - 1469, 951, 1646, 1647, 1647, 1469, 1648, 1469, 958, 1649, - 1650, 1651, 1651, 1652, 1653, 1654, 1654, 1469, 1655, 1469, - 970, 1656, 1657, 1658, 1469, 1659, 1660, 1660, 1661, 1662, - 1663, 1663, 1469, 1664, 1469, 985, 1665, 1666, 1667, 1668, - 1469, 1669, 1670, 1670, 1671, 1672, 1673, 1673, 1469, 1674, - - 1469, 1001, 1675, 1676, 1677, 1469, 1678, 1469, 1679, 1680, - 1469, 1469, 1469, 1469, 1681, 1682, 1683, 1683, 1683, 1683, - 1683, 1683, 1683, 1683, 1683, 1683, 1683, 1683, 1683, 1029, - 1683, 1684, 1469, 1469, 1469, 1685, 1469, 1469, 1686, 1469, - 1469, 1687, 1469, 1469, 1688, 1689, 1469, 1047, 1690, 1691, - 1469, 1469, 1692, 1693, 1694, 1469, 1695, 1696, 1469, 1469, - 1469, 1697, 1698, 1699, 1469, 1700, 1469, 1701, 1702, 1469, - 1469, 1469, 1703, 1704, 1705, 1706, 1469, 1707, 1469, 1708, - 1709, 1469, 1469, 1469, 1710, 1711, 1712, 1713, 1469, 1714, - 1469, 1715, 1716, 1469, 1469, 1469, 1717, 1718, 1719, 1720, - - 1721, 1469, 1722, 1723, 1723, 1724, 1725, 1726, 1726, 1469, - 1727, 1469, 1112, 1728, 1729, 1730, 1730, 1730, 1730, 1730, - 1730, 1730, 1730, 1730, 1730, 1730, 1731, 1469, 1469, 1129, - 1732, 1469, 1132, 1733, 1469, 1135, 1734, 1469, 1138, 1735, - 1469, 1141, 1736, 1469, 1469, 1469, 1737, 1738, 1739, 1740, - 1741, 1741, 1469, 1742, 1743, 1744, 1745, 1745, 1746, 1747, - 1748, 1748, 1469, 1749, 1750, 1751, 1752, 1469, 1753, 1754, - 1754, 1755, 1756, 1757, 1757, 1469, 1758, 1759, 1760, 1761, - 1762, 1469, 1763, 1764, 1764, 1765, 1766, 1767, 1767, 1469, - 1768, 1769, 1770, 1771, 1772, 1469, 1773, 1774, 1774, 1775, - - 1776, 1777, 1777, 1469, 1778, 1779, 1780, 1781, 1469, 1782, - 1469, 1783, 1784, 1469, 1469, 1469, 1785, 1786, 1787, 1788, - 1788, 1788, 1788, 1788, 1788, 1788, 1788, 1469, 1228, 1789, - 1790, 1469, 1791, 1792, 1469, 1793, 1794, 1469, 1795, 1796, - 1469, 1797, 1798, 1469, 1799, 1800, 1801, 1801, 1469, 1802, - 1803, 1804, 1805, 1806, 1469, 1807, 1808, 1469, 1809, 1469, - 1810, 1469, 1811, 1812, 1469, 1813, 1814, 1469, 1815, 1469, - 1816, 1817, 1469, 1818, 1819, 1469, 1820, 1469, 1821, 1822, - 1469, 1823, 1824, 1469, 1825, 1469, 1826, 1827, 1469, 1828, - 1829, 1830, 1469, 1831, 1832, 1832, 1833, 1834, 1835, 1835, - - 1469, 1836, 1837, 1838, 1839, 1839, 1839, 1839, 1469, 1840, - 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1469, 1848, 1849, - 1469, 1850, 1851, 1852, 1852, 1853, 1854, 1855, 1856, 1469, - 1857, 1858, 1858, 1859, 1860, 1861, 1862, 1863, 1469, 1864, - 1865, 1865, 1866, 1867, 1868, 1869, 1870, 1469, 1871, 1872, - 1872, 1873, 1874, 1875, 1876, 1877, 1469, 1878, 1879, 1879, - 1880, 1881, 1882, 1883, 1469, 1884, 1469, 1885, 1886, 1469, - 1887, 1888, 1888, 1888, 1888, 1889, 1469, 1890, 1891, 1892, - 1893, 1894, 1895, 1896, 1896, 1897, 1898, 1899, 1469, 1469, - 1900, 1469, 1901, 1469, 1902, 1469, 1903, 1469, 1904, 1469, - - 1905, 1469, 1906, 1469, 1907, 1469, 1908, 1469, 1883, 1909, - 1469, 1884, 1910, 1910, 1885, 1886, 1911, 1888, 1888, 1888, - 1912, 1469, 1913, 1914, 1469, 1900, 1901, 1915, 1469, 1902, - 1903, 1916, 1469, 1904, 1905, 1917, 1469, 1906, 1907, 1918, - 1469, 1908, 1919, 1469, 1920, 1469, 1888, 1921, 1469, 1913, - 1922, 1923, 1924, 1925, 1926, 1919, 1927, 1469, 1920, 1928, - 1922, 1923, 1924, 1925, 1926, 1929, 1928, 1929, 0, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469 + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 616, 616, + 620, 530, 622, 1780, 1781, 1728, 626, 1782, 1728, 629, + 1783, 1728, 1784, 1785, 1728, 635, 1786, 1787, 1787, 1728, + 1788, 1728, 642, 1789, 1790, 1791, 1791, 1792, 1793, 1794, + 1794, 1728, 1795, 1728, 654, 1796, 1797, 1728, 1798, 1728, + 1799, 1800, 1728, 1728, 1728, 1728, 1801, 1802, 623, 669, + 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, + 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, + 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, + + 669, 669, 669, 669, 669, 669, 706, 706, 706, 669, + 706, 711, 1803, 1728, 1728, 1728, 1804, 1728, 1728, 1805, + 1806, 1807, 1728, 1728, 1728, 1728, 1808, 1809, 1728, 1810, + 1811, 1728, 1728, 1728, 1728, 1812, 1813, 1728, 1814, 1728, + 1815, 1816, 1728, 1728, 1728, 1728, 1817, 1818, 1819, 1728, + 1820, 1821, 1821, 1822, 1823, 1824, 1824, 1728, 1825, 1728, + 760, 1826, 1827, 1828, 1828, 1828, 1828, 1828, 1828, 1828, + 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, + 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, + 1828, 1828, 1828, 1828, 1828, 794, 1828, 794, 798, 798, + + 800, 1829, 1830, 1728, 804, 1831, 1728, 807, 1832, 1728, + 810, 1833, 1728, 1834, 1835, 1728, 816, 1836, 1837, 1837, + 1728, 1838, 1728, 823, 1839, 1840, 1841, 1841, 1842, 1843, + 1844, 1844, 1728, 1845, 1728, 835, 1846, 1847, 1848, 1728, + 1849, 1850, 1850, 1851, 1852, 1853, 1853, 1728, 1854, 1728, + 850, 1855, 1856, 1857, 1728, 1858, 1728, 1859, 1860, 1728, + 1728, 1728, 1728, 1861, 1862, 1863, 1863, 1863, 1863, 1863, + 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, + 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 889, + 889, 891, 889, 889, 894, 1864, 1728, 1728, 1728, 1865, + + 1728, 1728, 1866, 1728, 1728, 1867, 1868, 1869, 1728, 1728, + 1728, 1728, 1870, 1871, 1728, 1872, 1873, 1728, 1728, 1728, + 1728, 1874, 1875, 1728, 1876, 1728, 1877, 1878, 1728, 1728, + 1728, 1728, 1879, 1880, 1881, 1728, 1882, 1728, 1883, 1884, + 1728, 1728, 1728, 1728, 1885, 1886, 1887, 1888, 1728, 1889, + 1890, 1890, 1891, 1892, 1893, 1893, 1728, 1894, 1728, 959, + 1895, 1896, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, + 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, + 1897, 1897, 1897, 1897, 1897, 1897, 986, 1897, 1897, 1898, + 1899, 1728, 992, 1900, 1728, 995, 1901, 1728, 998, 1902, + + 1728, 1001, 1903, 1728, 1904, 1728, 1728, 1007, 1905, 1906, + 1906, 1728, 1907, 1728, 1014, 1908, 1909, 1910, 1910, 1911, + 1912, 1913, 1913, 1728, 1914, 1728, 1026, 1915, 1916, 1917, + 1728, 1918, 1919, 1919, 1920, 1921, 1922, 1922, 1728, 1923, + 1728, 1041, 1924, 1925, 1926, 1927, 1728, 1928, 1929, 1929, + 1930, 1931, 1932, 1932, 1728, 1933, 1728, 1057, 1934, 1935, + 1936, 1728, 1937, 1728, 1938, 1939, 1728, 1728, 1728, 1728, + 1940, 1941, 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942, + 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942, + 1942, 1942, 1942, 1942, 1942, 1095, 1942, 1943, 1728, 1728, + + 1728, 1944, 1728, 1728, 1945, 1728, 1728, 1946, 1728, 1728, + 1947, 1948, 1728, 1113, 1949, 1950, 1728, 1728, 1951, 1952, + 1953, 1728, 1954, 1955, 1728, 1728, 1728, 1956, 1957, 1958, + 1728, 1959, 1728, 1960, 1961, 1728, 1728, 1728, 1962, 1963, + 1964, 1965, 1728, 1966, 1728, 1967, 1968, 1728, 1728, 1728, + 1969, 1970, 1971, 1972, 1728, 1973, 1728, 1974, 1975, 1728, + 1728, 1728, 1976, 1977, 1978, 1979, 1980, 1728, 1981, 1982, + 1982, 1983, 1984, 1985, 1985, 1728, 1986, 1728, 1178, 1987, + 1988, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, + 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, + + 1989, 1989, 1989, 1989, 1990, 1728, 1728, 1207, 1991, 1728, + 1210, 1992, 1728, 1213, 1993, 1728, 1216, 1994, 1728, 1219, + 1995, 1728, 1728, 1728, 1996, 1997, 1998, 1999, 2000, 2000, + 1728, 2001, 2002, 2003, 2004, 2004, 2005, 2006, 2007, 2007, + 1728, 2008, 2009, 2010, 2011, 1728, 2012, 2013, 2013, 2014, + 2015, 2016, 2016, 1728, 2017, 2018, 2019, 2020, 2021, 1728, + 2022, 2023, 2023, 2024, 2025, 2026, 2026, 1728, 2027, 2028, + 2029, 2030, 2031, 1728, 2032, 2033, 2033, 2034, 2035, 2036, + 2036, 1728, 2037, 2038, 2039, 2040, 1728, 2041, 1728, 2042, + 2043, 1728, 1728, 1728, 2044, 2045, 2046, 2047, 2047, 2047, + + 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, + 2047, 2047, 2047, 2047, 2047, 2047, 2047, 1728, 1318, 2048, + 2049, 1728, 2050, 2051, 1728, 2052, 2053, 1728, 2054, 2055, + 1728, 2056, 2057, 1728, 2058, 2059, 2060, 2060, 1728, 2061, + 2062, 2063, 2064, 2065, 1728, 2066, 2067, 1728, 2068, 1728, + 2069, 1728, 2070, 2071, 1728, 2072, 2073, 1728, 2074, 1728, + 2075, 2076, 1728, 2077, 2078, 1728, 2079, 1728, 2080, 2081, + 1728, 2082, 2083, 1728, 2084, 1728, 2085, 2086, 1728, 2087, + 2088, 2089, 1728, 2090, 2091, 2091, 2092, 2093, 2094, 2094, + 1728, 2095, 2096, 2097, 2098, 2098, 2098, 2098, 2098, 2098, + + 2098, 2098, 2098, 2098, 2098, 2098, 2098, 2098, 2098, 2098, + 2098, 1728, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, + 1728, 2107, 2108, 1728, 2109, 2110, 2111, 2111, 2112, 2113, + 2114, 2115, 1728, 2116, 2117, 2117, 2118, 2119, 2120, 2121, + 2122, 1728, 2123, 2124, 2124, 2125, 2126, 2127, 2128, 2129, + 1728, 2130, 2131, 2131, 2132, 2133, 2134, 2135, 2136, 1728, + 2137, 2138, 2138, 2139, 2140, 2141, 2142, 1728, 2143, 1728, + 2144, 2145, 1728, 2146, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2148, 1728, 2149, 2150, 2151, 2152, 2153, 2154, 2155, + + 2155, 2156, 2157, 2158, 1728, 1728, 2159, 1728, 2160, 1728, + 2161, 1728, 2162, 1728, 2163, 1728, 2164, 1728, 2165, 1728, + 2166, 1728, 2167, 1728, 2142, 2168, 1728, 2143, 2169, 2169, + 2144, 2145, 2170, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2171, + 1728, 2172, 2173, 1728, 2159, 2160, 2174, 1728, 2161, 2162, + 2175, 1728, 2163, 2164, 2176, 1728, 2165, 2166, 2177, 1728, + 2167, 2178, 1728, 2179, 1728, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2180, 1728, + 2172, 2181, 2182, 2183, 2184, 2185, 2178, 2186, 1728, 2179, + + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2187, 2181, 2182, 2183, 2184, 2185, 2188, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2187, 2188, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, + 2147, 2147, 2147, 2147, 2147, 2147, 2147, 0, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728 } ; -static yyconst flex_int16_t yy_nxt[7486] = +static yyconst flex_int16_t yy_nxt[7910] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 14, 15, 15, 15, 15, 15, 15, 16, 17, @@ -1028,823 +1135,870 @@ static yyconst flex_int16_t yy_nxt[7486] = 44, 212, 44, 44, 44, 57, 58, 44, 248, 44, 44, 44, 60, 61, 72, 44, 83, 84, 249, 44, 53, 44, 44, 44, 44, 206, 44, 44, 73, 85, - 44, 117, 79, 1233, 86, 74, 80, 742, 195, 44, + 44, 117, 79, 1157, 86, 74, 80, 686, 195, 44, - 118, 196, 81, 53, 197, 82, 198, 44, 48, 49, + 118, 196, 81, 687, 197, 82, 198, 44, 48, 49, 50, 50, 50, 50, 50, 50, 50, 51, 207, 201, - 1236, 52, 53, 54, 202, 182, 55, 52, 52, 52, + 942, 52, 53, 54, 202, 182, 55, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54, - 53, 44, 183, 75, 44, 1239, 44, 44, 184, 236, - 87, 1242, 213, 76, 88, 344, 77, 214, 63, 56, + 53, 44, 183, 75, 44, 766, 44, 44, 184, 236, + 87, 53, 213, 76, 88, 344, 77, 214, 63, 56, 78, 63, 237, 63, 63, 208, 89, 44, 62, 52, 52, 52, 52, 52, 52, 52, 63, 242, 65, 345, - 66, 67, 53, 744, 63, 68, 53, 342, 119, 343, + 66, 67, 53, 768, 63, 68, 53, 342, 119, 343, 69, 90, 209, 91, 70, 243, 71, 210, 92, 93, - 120, 94, 121, 1245, 122, 95, 1310, 123, 53, 55, - 53, 53, 53, 53, 53, 53, 53, 53, 1469, 104, - 105, 217, 53, 746, 218, 453, 219, 245, 53, 53, + 120, 94, 121, 1335, 122, 95, 453, 123, 53, 55, + 53, 53, 53, 53, 53, 53, 53, 53, 1728, 104, + 105, 217, 53, 770, 218, 1161, 219, 245, 53, 53, 53, 53, 53, 53, 96, 106, 246, 97, 98, 107, 99, 53, 100, 108, 101, 109, 102, 111, 124, 103, - 53, 112, 110, 125, 126, 129, 127, 128, 453, 130, - 113, 114, 1469, 134, 115, 324, 116, 131, 141, 135, + 53, 112, 110, 125, 126, 129, 127, 128, 799, 130, + 113, 114, 1728, 134, 115, 324, 116, 131, 141, 135, 142, 136, 132, 137, 133, 146, 53, 138, 325, 139, - 140, 53, 355, 147, 143, 53, 524, 148, 1469, 149, - - 44, 144, 749, 44, 53, 44, 44, 156, 156, 156, - 156, 156, 156, 156, 1469, 417, 63, 53, 44, 63, - 418, 63, 63, 497, 1145, 501, 44, 153, 153, 153, - 153, 153, 153, 153, 63, 453, 498, 53, 153, 502, - 1469, 750, 63, 53, 153, 153, 153, 153, 153, 153, - 154, 155, 155, 155, 155, 155, 155, 1469, 53, 1233, - 1469, 156, 380, 381, 382, 383, 453, 156, 156, 156, + 140, 53, 355, 147, 143, 53, 527, 148, 1728, 149, + + 44, 144, 490, 44, 53, 44, 44, 156, 156, 156, + 156, 156, 156, 156, 1728, 417, 63, 53, 44, 63, + 418, 63, 63, 491, 500, 1070, 44, 153, 153, 153, + 153, 153, 153, 153, 63, 53, 708, 501, 153, 492, + 1728, 775, 63, 53, 153, 153, 153, 153, 153, 153, + 154, 155, 155, 155, 155, 155, 155, 1728, 53, 53, + 1728, 156, 380, 381, 382, 383, 1295, 156, 156, 156, 156, 156, 156, 49, 157, 157, 157, 157, 157, 157, - 157, 277, 384, 1469, 53, 158, 1469, 1469, 1469, 279, - 1236, 158, 158, 158, 158, 158, 158, 62, 158, 158, + 157, 277, 384, 1728, 53, 158, 1728, 1728, 1728, 279, + 1413, 158, 158, 158, 158, 158, 158, 62, 158, 158, 158, 158, 158, 158, 158, 161, 161, 161, 161, 161, - 161, 161, 573, 1469, 1469, 437, 161, 380, 381, 382, - 383, 574, 161, 161, 161, 161, 161, 161, 44, 265, - 453, 44, 1239, 44, 44, 53, 684, 464, 464, 162, - 163, 163, 163, 163, 163, 163, 44, 53, 1469, 453, - 164, 465, 1469, 1242, 44, 265, 164, 164, 164, 164, - 164, 164, 260, 576, 261, 261, 261, 261, 261, 261, - 261, 365, 577, 53, 1469, 261, 1469, 465, 1469, 532, - 453, 261, 261, 261, 261, 261, 261, 262, 263, 263, - 263, 263, 263, 263, 263, 277, 468, 741, 53, 264, - - 1469, 265, 1469, 1469, 470, 264, 264, 264, 264, 264, + 161, 161, 576, 1728, 1728, 437, 161, 1323, 504, 765, + 53, 577, 161, 161, 161, 161, 161, 161, 44, 265, + 767, 44, 505, 44, 44, 53, 1326, 464, 464, 162, + 163, 163, 163, 163, 163, 163, 44, 53, 1728, 53, + 164, 465, 1728, 774, 44, 265, 164, 164, 164, 164, + 164, 164, 260, 579, 261, 261, 261, 261, 261, 261, + 261, 365, 580, 53, 1728, 261, 1728, 465, 1728, 535, + 781, 261, 261, 261, 261, 261, 261, 262, 263, 263, + 263, 263, 263, 263, 263, 277, 468, 53, 1329, 264, + + 1728, 265, 1728, 1728, 470, 264, 264, 264, 264, 264, 264, 352, 352, 352, 352, 352, 352, 352, 371, 372, - 372, 372, 372, 372, 372, 542, 1469, 265, 266, 264, - 264, 264, 264, 264, 264, 264, 1469, 1469, 743, 543, - 264, 1469, 606, 53, 53, 757, 264, 264, 264, 264, + 372, 372, 372, 372, 372, 545, 1728, 265, 266, 264, + 264, 264, 264, 264, 264, 264, 688, 1728, 1332, 546, + 264, 380, 381, 382, 383, 689, 264, 264, 264, 264, 264, 264, 267, 268, 268, 268, 268, 268, 268, 268, - 269, 763, 1469, 1469, 270, 543, 1245, 1469, 606, 453, + 269, 779, 1335, 1728, 270, 546, 1728, 1728, 53, 1413, 270, 270, 270, 270, 270, 270, 53, 270, 270, 270, 270, 270, 270, 270, 273, 274, 274, 274, 274, 274, - 274, 275, 537, 1209, 818, 276, 1469, 53, 751, 55, - - 692, 276, 276, 276, 276, 276, 276, 277, 278, 278, - 278, 278, 278, 278, 278, 279, 53, 55, 1211, 280, - 818, 281, 1469, 396, 55, 280, 280, 280, 280, 280, - 280, 397, 440, 440, 440, 440, 440, 440, 440, 1012, - 55, 542, 55, 607, 398, 55, 747, 281, 349, 349, - 349, 349, 349, 349, 349, 1469, 53, 435, 55, 349, - 399, 55, 1217, 55, 1215, 349, 349, 349, 349, 349, - 349, 350, 351, 351, 351, 351, 351, 351, 745, 55, - 831, 1469, 352, 435, 1469, 1469, 830, 53, 352, 352, + 274, 275, 1728, 1728, 773, 276, 53, 777, 453, 53, + + 453, 276, 276, 276, 276, 276, 276, 277, 278, 278, + 278, 278, 278, 278, 278, 279, 782, 53, 786, 280, + 1223, 281, 453, 396, 53, 280, 280, 280, 280, 280, + 280, 397, 440, 440, 440, 440, 440, 440, 440, 53, + 793, 545, 1323, 619, 398, 55, 771, 281, 349, 349, + 349, 349, 349, 349, 349, 1728, 53, 435, 618, 349, + 399, 453, 55, 55, 784, 349, 349, 349, 349, 349, + 349, 350, 351, 351, 351, 351, 351, 351, 690, 53, + 55, 1728, 352, 435, 618, 854, 1728, 691, 352, 352, 352, 352, 352, 352, 262, 353, 353, 353, 353, 353, - 353, 353, 354, 354, 354, 354, 354, 354, 354, 546, - 1469, 1469, 1377, 354, 1469, 55, 55, 695, 55, 354, + 353, 353, 354, 354, 354, 354, 354, 354, 354, 769, + 1728, 854, 1728, 354, 1326, 453, 1329, 55, 53, 354, 354, 354, 354, 354, 354, 356, 357, 357, 357, 357, - 357, 357, 357, 55, 55, 840, 55, 358, 836, 837, - 1469, 1469, 1469, 358, 358, 358, 358, 358, 358, 361, + 357, 357, 357, 540, 549, 55, 1728, 358, 453, 1332, + 872, 716, 719, 358, 358, 358, 358, 358, 358, 361, 358, 358, 358, 358, 358, 358, 358, 365, 366, 366, - 366, 366, 366, 366, 366, 367, 652, 1469, 1469, 368, - 1310, 369, 1310, 453, 654, 368, 368, 368, 368, 368, - 368, 455, 456, 456, 456, 456, 456, 456, 521, 521, - 521, 521, 521, 521, 521, 646, 55, 369, 277, 373, + 366, 366, 366, 366, 366, 367, 664, 453, 1335, 368, + 453, 369, 1287, 1289, 666, 368, 368, 368, 368, 368, + 368, 455, 456, 456, 456, 456, 456, 456, 524, 524, + 524, 524, 524, 524, 524, 658, 778, 369, 277, 373, - 373, 373, 373, 373, 373, 373, 279, 1255, 1051, 647, - 374, 1469, 55, 1260, 55, 752, 374, 374, 374, 374, + 373, 373, 373, 373, 373, 373, 279, 53, 1068, 659, + 374, 1295, 55, 55, 1293, 776, 374, 374, 374, 374, 374, 374, 375, 376, 376, 376, 376, 376, 376, 53, - 55, 832, 753, 377, 646, 647, 1262, 1469, 1060, 377, - 377, 377, 377, 377, 377, 421, 53, 422, 1469, 423, - 424, 551, 552, 552, 552, 552, 552, 552, 55, 425, - 1268, 426, 427, 648, 428, 430, 648, 431, 431, 431, - 431, 431, 431, 431, 1469, 889, 55, 649, 431, 838, - 1469, 758, 55, 760, 431, 431, 431, 431, 431, 431, - 432, 433, 433, 433, 433, 433, 433, 433, 1270, 55, - - 55, 889, 434, 649, 435, 1071, 1469, 1276, 434, 434, - 434, 434, 434, 434, 555, 556, 556, 556, 556, 556, - 556, 626, 627, 627, 627, 627, 627, 627, 705, 756, + 55, 55, 780, 377, 658, 659, 879, 866, 1493, 377, + 377, 377, 377, 377, 377, 421, 53, 422, 1728, 423, + 424, 554, 555, 555, 555, 555, 555, 555, 55, 425, + 785, 426, 427, 660, 428, 430, 660, 431, 431, 431, + 431, 431, 431, 431, 1728, 53, 55, 661, 431, 873, + 1728, 55, 1413, 55, 431, 431, 431, 431, 431, 431, + 432, 433, 433, 433, 433, 433, 433, 433, 1413, 55, + + 876, 55, 434, 661, 435, 453, 1728, 1345, 434, 434, + 434, 434, 434, 434, 558, 559, 559, 559, 559, 559, + 559, 638, 639, 639, 639, 639, 639, 639, 729, 783, 435, 436, 434, 434, 434, 434, 434, 434, 434, 53, - 1278, 1083, 706, 434, 1469, 55, 55, 55, 705, 434, + 1117, 1350, 730, 434, 1352, 55, 55, 55, 729, 434, 434, 434, 434, 434, 434, 438, 439, 439, 439, 439, - 439, 439, 1469, 55, 55, 55, 440, 841, 706, 55, - 1469, 55, 440, 440, 440, 440, 440, 440, 267, 441, - 441, 441, 441, 441, 441, 441, 1284, 55, 1469, 55, - 442, 53, 917, 1005, 918, 1286, 442, 442, 442, 442, + 439, 439, 1728, 55, 55, 55, 440, 874, 730, 55, + 883, 55, 440, 440, 440, 440, 440, 440, 267, 441, + 441, 441, 441, 441, 441, 441, 1126, 55, 1728, 55, + 442, 1728, 884, 1728, 1728, 1358, 442, 442, 442, 442, 442, 442, 53, 442, 442, 442, 442, 442, 442, 442, - 445, 446, 446, 446, 446, 446, 446, 53, 700, 1005, - 1095, 447, 1217, 55, 55, 55, 853, 447, 447, 447, + 445, 446, 446, 446, 446, 446, 446, 1728, 724, 1728, + 1728, 447, 1360, 55, 55, 794, 899, 447, 447, 447, 447, 447, 447, 451, 452, 452, 452, 452, 452, 452, - 453, 55, 55, 55, 454, 1318, 919, 921, 923, 55, + 453, 55, 55, 55, 454, 887, 1728, 55, 796, 1137, 454, 454, 454, 454, 454, 454, 365, 457, 457, 457, - 457, 457, 457, 457, 367, 709, 1145, 55, 458, 1469, - 1365, 55, 924, 856, 458, 458, 458, 458, 458, 458, - 459, 460, 460, 460, 460, 460, 460, 453, 720, 55, - 1469, 461, 926, 1367, 55, 1469, 859, 461, 461, 461, + 457, 457, 457, 457, 367, 55, 1728, 935, 458, 1728, + 55, 55, 1728, 1366, 458, 458, 458, 458, 458, 458, + 459, 460, 460, 460, 460, 460, 460, 453, 55, 55, + 53, 461, 1728, 935, 963, 1728, 55, 461, 461, 461, 461, 461, 461, 277, 466, 466, 466, 466, 466, 466, - 466, 279, 55, 1390, 1394, 467, 1469, 1026, 55, 55, + 466, 279, 1368, 1149, 55, 467, 53, 1374, 55, 964, 55, 467, 467, 467, 467, 467, 467, 468, 469, 469, - 469, 469, 469, 469, 469, 470, 55, 55, 55, 471, - 1022, 472, 1398, 1469, 1028, 471, 471, 471, 471, 471, - 471, 634, 635, 635, 635, 635, 635, 635, 638, 639, - 639, 639, 639, 639, 639, 1402, 1406, 472, 482, 1469, - 1469, 1422, 483, 1469, 55, 484, 55, 714, 485, 714, - 486, 487, 488, 489, 518, 518, 518, 518, 518, 518, - 518, 715, 55, 1469, 55, 518, 1469, 55, 55, 1469, - - 755, 518, 518, 518, 518, 518, 518, 519, 520, 520, - 520, 520, 520, 520, 53, 55, 55, 715, 521, 1469, - 1469, 1469, 1469, 1444, 521, 521, 521, 521, 521, 521, - 432, 522, 522, 522, 522, 522, 522, 522, 523, 523, - 523, 523, 523, 523, 523, 825, 1469, 1469, 1469, 523, - 1076, 1469, 1088, 827, 1310, 523, 523, 523, 523, 523, - 523, 437, 525, 525, 525, 525, 525, 525, 525, 1217, - 1014, 716, 716, 526, 1095, 265, 1076, 1469, 1088, 526, - 526, 526, 526, 526, 526, 717, 1469, 725, 726, 726, - 726, 726, 726, 726, 728, 729, 729, 729, 729, 729, - - 729, 265, 526, 526, 526, 526, 526, 526, 526, 1469, - 864, 717, 1469, 526, 55, 55, 55, 453, 1035, 526, - 526, 526, 526, 526, 526, 527, 527, 527, 527, 527, - 527, 527, 55, 55, 55, 1469, 528, 1121, 1124, 1469, - 1208, 1469, 528, 528, 528, 528, 528, 528, 53, 528, - 528, 528, 528, 528, 528, 528, 365, 531, 531, 531, - 531, 531, 531, 531, 532, 1469, 1208, 1469, 533, 1245, - 369, 896, 1091, 1089, 533, 533, 533, 533, 533, 533, - 732, 733, 733, 733, 733, 733, 733, 783, 784, 784, - 784, 784, 784, 784, 55, 55, 369, 537, 538, 538, - - 538, 538, 538, 538, 538, 539, 873, 1083, 453, 540, - 1242, 541, 55, 55, 1038, 540, 540, 540, 540, 540, - 540, 791, 792, 792, 792, 792, 792, 792, 795, 796, - 796, 796, 796, 796, 796, 819, 55, 541, 365, 544, - 544, 544, 544, 544, 544, 544, 532, 884, 1079, 820, - 545, 1469, 1077, 1469, 55, 55, 545, 545, 545, 545, - 545, 545, 546, 547, 547, 547, 547, 547, 547, 547, - 548, 833, 1071, 55, 549, 820, 550, 1469, 1125, 1469, - 549, 549, 549, 549, 549, 549, 803, 804, 804, 804, - 804, 804, 804, 806, 807, 807, 807, 807, 807, 807, - - 819, 55, 550, 468, 557, 557, 557, 557, 557, 557, - 557, 470, 453, 1469, 1469, 558, 1469, 1239, 873, 55, - 821, 558, 558, 558, 558, 558, 558, 559, 560, 560, - 560, 560, 560, 560, 822, 884, 835, 1067, 561, 1469, - 1469, 1065, 1469, 1041, 561, 561, 561, 561, 561, 561, - 601, 821, 602, 602, 602, 602, 602, 602, 602, 896, - 822, 1060, 1469, 602, 1267, 1469, 55, 1044, 453, 602, - 602, 602, 602, 602, 602, 603, 604, 604, 604, 604, - 604, 604, 604, 1236, 55, 864, 1223, 605, 1469, 606, - 1267, 1469, 1056, 605, 605, 605, 605, 605, 605, 810, - - 811, 811, 811, 811, 811, 811, 726, 726, 726, 726, - 726, 726, 726, 869, 55, 606, 603, 605, 605, 605, - 605, 605, 605, 605, 1275, 1051, 453, 870, 605, 1283, - 55, 1469, 55, 55, 605, 605, 605, 605, 605, 605, - 437, 608, 608, 608, 608, 608, 608, 608, 55, 922, - 1275, 55, 609, 870, 1233, 1283, 1226, 1469, 609, 609, - 609, 609, 609, 609, 53, 609, 609, 609, 609, 609, - 609, 609, 610, 610, 610, 610, 610, 610, 610, 1012, - 1051, 453, 1147, 611, 1364, 1393, 1397, 1014, 1233, 611, - 611, 611, 611, 611, 611, 53, 611, 611, 611, 611, - - 611, 611, 611, 614, 615, 615, 615, 615, 615, 615, - 1364, 1393, 1397, 1401, 616, 1405, 1443, 55, 55, 55, - 616, 616, 616, 616, 616, 616, 365, 457, 457, 457, - 457, 457, 457, 457, 532, 55, 55, 55, 458, 1401, - 55, 1405, 1443, 869, 458, 458, 458, 458, 458, 458, - 617, 618, 618, 618, 618, 618, 618, 1469, 55, 1220, - 1221, 619, 1252, 55, 1128, 1245, 1242, 619, 619, 619, - 619, 619, 619, 623, 624, 624, 624, 624, 624, 624, - 453, 55, 1222, 1469, 625, 1239, 1236, 55, 55, 55, - 625, 625, 625, 625, 625, 625, 537, 628, 628, 628, - - 628, 628, 628, 628, 539, 55, 55, 55, 629, 1233, - 1128, 1305, 55, 1012, 629, 629, 629, 629, 629, 629, - 630, 631, 631, 631, 631, 631, 631, 453, 1224, 1217, - 55, 632, 1014, 1373, 825, 55, 55, 632, 632, 632, - 632, 632, 632, 546, 640, 640, 640, 640, 640, 640, - 640, 548, 1060, 55, 55, 641, 1374, 1008, 55, 55, - 1236, 641, 641, 641, 641, 641, 641, 642, 643, 643, - 643, 643, 643, 643, 453, 1071, 55, 55, 644, 1451, - 1006, 55, 1097, 1239, 644, 644, 644, 644, 644, 644, - 468, 650, 650, 650, 650, 650, 650, 650, 470, 55, - - 1375, 1452, 651, 1453, 1454, 1451, 55, 55, 651, 651, - 651, 651, 651, 651, 652, 653, 653, 653, 653, 653, - 653, 653, 654, 55, 55, 55, 655, 1452, 656, 1453, - 1454, 55, 655, 655, 655, 655, 655, 655, 842, 920, - 453, 55, 847, 847, 847, 847, 847, 847, 847, 55, - 878, 878, 55, 834, 656, 680, 680, 680, 680, 680, - 680, 680, 1455, 1083, 879, 1469, 680, 1460, 927, 55, - 55, 1242, 680, 680, 680, 680, 680, 680, 681, 681, - 681, 681, 681, 681, 681, 925, 1095, 55, 1455, 681, - 879, 1469, 1466, 1460, 1245, 681, 681, 681, 681, 681, - - 681, 603, 682, 682, 682, 682, 682, 682, 682, 683, - 683, 683, 683, 683, 683, 683, 1145, 1215, 1466, 1044, - 683, 1085, 55, 453, 1310, 1217, 683, 683, 683, 683, - 683, 683, 437, 685, 685, 685, 685, 685, 685, 685, - 55, 1041, 1073, 453, 686, 1038, 1062, 453, 1035, 1306, - 686, 686, 686, 686, 686, 686, 53, 686, 686, 686, - 686, 686, 686, 686, 687, 687, 687, 687, 687, 687, - 687, 1215, 1053, 453, 1147, 688, 453, 1128, 1044, 1469, - 1041, 688, 688, 688, 688, 688, 688, 53, 688, 688, - 688, 688, 688, 688, 688, 537, 691, 691, 691, 691, - - 691, 691, 691, 692, 55, 880, 880, 693, 1038, 541, - 1035, 1128, 1014, 693, 693, 693, 693, 693, 693, 881, - 1469, 827, 55, 804, 804, 804, 804, 804, 804, 804, - 896, 55, 1097, 890, 839, 541, 546, 694, 694, 694, - 694, 694, 694, 694, 695, 881, 1469, 891, 696, 55, - 550, 55, 890, 892, 696, 696, 696, 696, 696, 696, - 1044, 341, 720, 892, 890, 884, 1469, 893, 1085, 55, - 1023, 1041, 892, 891, 1006, 709, 550, 700, 701, 701, - 701, 701, 701, 701, 701, 702, 1469, 1024, 1007, 703, - 880, 704, 1469, 893, 1006, 703, 703, 703, 703, 703, - - 703, 902, 903, 903, 903, 903, 903, 903, 1469, 878, - 873, 1073, 1469, 1008, 1007, 1008, 1038, 704, 537, 707, - 707, 707, 707, 707, 707, 707, 692, 1009, 700, 1469, - 708, 869, 864, 55, 1469, 1062, 708, 708, 708, 708, - 708, 708, 709, 710, 710, 710, 710, 710, 710, 710, - 711, 55, 1035, 1009, 712, 1469, 713, 1053, 950, 1420, - 712, 712, 712, 712, 712, 712, 905, 906, 906, 906, - 906, 906, 906, 909, 910, 910, 910, 910, 910, 910, - 1056, 55, 713, 546, 718, 718, 718, 718, 718, 718, - 718, 695, 935, 1044, 1057, 719, 1041, 1038, 1035, 55, - - 1033, 719, 719, 719, 719, 719, 719, 720, 721, 721, - 721, 721, 721, 721, 721, 722, 1021, 935, 825, 723, - 1057, 724, 1014, 827, 652, 723, 723, 723, 723, 723, - 723, 954, 955, 955, 955, 955, 955, 955, 962, 963, - 963, 963, 963, 963, 963, 55, 55, 724, 652, 734, - 734, 734, 734, 734, 734, 734, 654, 821, 819, 898, - 735, 859, 886, 55, 55, 856, 735, 735, 735, 735, - 735, 735, 736, 737, 737, 737, 737, 737, 737, 1017, - 1027, 875, 853, 738, 866, 950, 935, 859, 1056, 738, - 738, 738, 738, 738, 738, 53, 53, 53, 53, 53, - - 53, 53, 1469, 856, 853, 935, 53, 55, 55, 55, - 827, 55, 53, 53, 53, 53, 53, 53, 966, 967, - 967, 967, 967, 967, 967, 55, 55, 55, 1469, 55, - 740, 758, 654, 759, 759, 759, 759, 759, 759, 759, - 1018, 1019, 1020, 1025, 759, 720, 898, 55, 1120, 55, - 759, 759, 759, 759, 759, 759, 974, 975, 975, 975, - 975, 975, 975, 1065, 1065, 55, 55, 55, 53, 760, - 761, 761, 761, 761, 761, 761, 761, 1066, 1469, 1119, - 859, 761, 1227, 546, 55, 716, 714, 761, 761, 761, - 761, 761, 761, 977, 978, 978, 978, 978, 978, 978, - - 709, 1372, 886, 1066, 1469, 53, 682, 682, 682, 682, - 682, 682, 682, 981, 982, 982, 982, 982, 982, 982, - 990, 991, 991, 991, 991, 991, 991, 993, 994, 994, - 994, 994, 994, 994, 997, 998, 998, 998, 998, 998, - 998, 53, 683, 683, 683, 683, 683, 683, 683, 856, - 537, 705, 700, 683, 875, 853, 866, 863, 779, 683, - 683, 683, 683, 683, 683, 762, 353, 353, 353, 353, - 353, 353, 353, 267, 764, 764, 764, 764, 764, 764, - 764, 767, 859, 856, 853, 765, 851, 767, 652, 827, - 654, 765, 765, 765, 765, 765, 765, 53, 765, 765, - - 765, 765, 765, 765, 765, 768, 769, 769, 769, 769, - 769, 769, 468, 648, 646, 722, 770, 695, 711, 692, - 702, 779, 770, 770, 770, 770, 770, 770, 537, 628, - 628, 628, 628, 628, 628, 628, 692, 767, 695, 692, - 629, 767, 53, 53, 53, 1067, 629, 629, 629, 629, - 629, 629, 771, 772, 772, 772, 772, 772, 772, 1068, - 754, 53, 53, 773, 748, 654, 470, 546, 722, 773, - 773, 773, 773, 773, 773, 546, 640, 640, 640, 640, - 640, 640, 640, 695, 695, 1068, 365, 641, 542, 537, - 711, 692, 1067, 641, 641, 641, 641, 641, 641, 774, - - 775, 775, 775, 775, 775, 775, 1469, 702, 699, 622, - 776, 613, 695, 692, 690, 613, 776, 776, 776, 776, - 776, 776, 780, 781, 781, 781, 781, 781, 781, 453, - 603, 601, 1469, 782, 679, 678, 677, 676, 675, 782, - 782, 782, 782, 782, 782, 700, 785, 785, 785, 785, - 785, 785, 785, 702, 674, 673, 672, 786, 671, 670, - 669, 668, 667, 786, 786, 786, 786, 786, 786, 787, - 788, 788, 788, 788, 788, 788, 453, 666, 665, 664, - 789, 663, 662, 661, 660, 659, 789, 789, 789, 789, - 789, 789, 709, 797, 797, 797, 797, 797, 797, 797, - - 711, 658, 657, 468, 798, 654, 470, 464, 548, 532, - 798, 798, 798, 798, 798, 798, 799, 800, 800, 800, - 800, 800, 800, 453, 539, 622, 613, 801, 532, 613, - 607, 607, 600, 801, 801, 801, 801, 801, 801, 720, - 812, 812, 812, 812, 812, 812, 812, 722, 599, 598, - 597, 813, 596, 595, 594, 593, 592, 813, 813, 813, - 813, 813, 813, 814, 815, 815, 815, 815, 815, 815, - 453, 591, 590, 338, 816, 239, 589, 588, 587, 586, - 816, 816, 816, 816, 816, 816, 652, 823, 823, 823, - 823, 823, 823, 823, 654, 585, 584, 583, 824, 582, - - 581, 580, 579, 578, 824, 824, 824, 824, 824, 824, - 825, 826, 826, 826, 826, 826, 826, 826, 827, 575, - 572, 571, 828, 570, 829, 569, 568, 567, 828, 828, - 828, 828, 828, 828, 903, 903, 903, 903, 903, 903, - 903, 975, 975, 975, 975, 975, 975, 975, 1077, 1077, - 829, 55, 1079, 843, 843, 843, 843, 843, 843, 843, - 566, 565, 1078, 1469, 843, 564, 1080, 563, 55, 55, - 843, 843, 843, 843, 843, 843, 844, 844, 844, 844, - 844, 844, 844, 470, 279, 453, 55, 844, 1078, 1469, - 365, 548, 1080, 844, 844, 844, 844, 844, 844, 845, - - 846, 846, 846, 846, 846, 846, 1123, 532, 539, 453, - 847, 536, 55, 450, 444, 532, 847, 847, 847, 847, - 847, 847, 267, 848, 848, 848, 848, 848, 848, 848, - 55, 530, 444, 436, 849, 430, 517, 516, 515, 1419, - 849, 849, 849, 849, 849, 849, 53, 849, 849, 849, - 849, 849, 849, 849, 700, 852, 852, 852, 852, 852, - 852, 852, 853, 514, 1079, 513, 854, 512, 704, 511, - 510, 509, 854, 854, 854, 854, 854, 854, 1469, 991, - 991, 991, 991, 991, 991, 991, 508, 507, 506, 505, - 55, 1089, 1089, 504, 704, 709, 855, 855, 855, 855, - - 855, 855, 855, 856, 1469, 1090, 1469, 857, 55, 713, - 55, 1091, 1091, 857, 857, 857, 857, 857, 857, 1116, - 503, 500, 499, 496, 495, 1092, 1469, 494, 55, 493, - 492, 1090, 1469, 120, 491, 713, 720, 858, 858, 858, - 858, 858, 858, 858, 859, 490, 481, 1418, 860, 480, - 724, 1092, 1469, 479, 860, 860, 860, 860, 860, 860, - 1101, 1102, 1102, 1102, 1102, 1102, 1102, 1104, 1105, 1105, - 1105, 1105, 1105, 1105, 478, 477, 724, 864, 865, 865, - 865, 865, 865, 865, 865, 866, 476, 475, 474, 867, - 473, 868, 277, 470, 279, 867, 867, 867, 867, 867, - - 867, 1108, 1109, 1109, 1109, 1109, 1109, 1109, 1151, 1152, - 1152, 1152, 1152, 1152, 1152, 1209, 453, 868, 700, 871, - 871, 871, 871, 871, 871, 871, 853, 367, 450, 1210, - 872, 444, 444, 437, 437, 55, 872, 872, 872, 872, - 872, 872, 873, 874, 874, 874, 874, 874, 874, 874, - 875, 55, 55, 55, 876, 1210, 877, 429, 420, 419, - 876, 876, 876, 876, 876, 876, 416, 1122, 415, 55, - 55, 1157, 1158, 1158, 1158, 1158, 1158, 1158, 1209, 55, - 1117, 1118, 877, 709, 882, 882, 882, 882, 882, 882, - 882, 856, 1469, 414, 413, 883, 412, 55, 411, 410, - - 409, 883, 883, 883, 883, 883, 883, 884, 885, 885, - 885, 885, 885, 885, 885, 886, 1447, 408, 1469, 887, - 407, 888, 406, 405, 404, 887, 887, 887, 887, 887, - 887, 1161, 1162, 1162, 1162, 1162, 1162, 1162, 1167, 1168, - 1168, 1168, 1168, 1168, 1168, 1211, 403, 888, 720, 894, - 894, 894, 894, 894, 894, 894, 859, 402, 401, 1212, - 895, 400, 395, 394, 393, 392, 895, 895, 895, 895, - 895, 895, 896, 897, 897, 897, 897, 897, 897, 897, - 898, 391, 320, 390, 899, 1212, 900, 389, 388, 387, - 899, 899, 899, 899, 899, 899, 1170, 1171, 1171, 1171, - - 1171, 1171, 1171, 1174, 1175, 1175, 1175, 1175, 1175, 1175, - 1211, 386, 900, 825, 911, 911, 911, 911, 911, 911, - 911, 827, 385, 379, 1469, 912, 279, 367, 275, 364, - 1255, 912, 912, 912, 912, 912, 912, 913, 914, 914, - 914, 914, 914, 914, 1256, 272, 360, 266, 915, 260, - 1469, 143, 348, 347, 915, 915, 915, 915, 915, 915, - 55, 1255, 928, 928, 928, 928, 928, 928, 928, 346, - 1256, 341, 320, 928, 340, 1469, 339, 338, 55, 928, - 928, 928, 928, 928, 928, 929, 929, 929, 929, 929, - 929, 929, 337, 336, 335, 334, 929, 333, 332, 331, - - 330, 1469, 929, 929, 929, 929, 929, 929, 607, 930, - 930, 930, 930, 930, 930, 930, 329, 328, 327, 326, - 931, 323, 435, 322, 321, 320, 931, 931, 931, 931, - 931, 931, 1181, 1182, 1182, 1182, 1182, 1182, 1182, 1184, - 1185, 1185, 1185, 1185, 1185, 1185, 319, 1260, 435, 931, - 931, 931, 931, 931, 931, 931, 318, 317, 316, 315, - 931, 1261, 314, 313, 312, 311, 931, 931, 931, 931, - 931, 931, 267, 932, 932, 932, 932, 932, 932, 932, - 310, 309, 308, 307, 933, 306, 305, 1261, 304, 303, - 933, 933, 933, 933, 933, 933, 53, 933, 933, 933, - - 933, 933, 933, 933, 936, 937, 937, 937, 937, 937, - 937, 302, 301, 300, 299, 938, 298, 297, 143, 296, - 295, 938, 938, 938, 938, 938, 938, 700, 785, 785, - 785, 785, 785, 785, 785, 853, 294, 293, 292, 786, - 291, 290, 289, 288, 1260, 786, 786, 786, 786, 786, - 786, 939, 940, 940, 940, 940, 940, 940, 1469, 287, - 286, 285, 941, 284, 283, 282, 279, 267, 941, 941, - 941, 941, 941, 941, 709, 797, 797, 797, 797, 797, - 797, 797, 856, 272, 1469, 259, 798, 258, 257, 256, - 255, 1262, 798, 798, 798, 798, 798, 798, 942, 943, - - 943, 943, 943, 943, 943, 1263, 254, 253, 252, 944, - 251, 250, 247, 244, 241, 944, 944, 944, 944, 944, - 944, 720, 812, 812, 812, 812, 812, 812, 812, 859, - 240, 1263, 239, 813, 238, 235, 234, 233, 1262, 813, - 813, 813, 813, 813, 813, 945, 946, 946, 946, 946, - 946, 946, 1469, 232, 231, 230, 947, 229, 228, 227, - 226, 225, 947, 947, 947, 947, 947, 947, 951, 952, - 952, 952, 952, 952, 952, 453, 224, 223, 1469, 953, - 222, 221, 220, 216, 215, 953, 953, 953, 953, 953, - 953, 864, 956, 956, 956, 956, 956, 956, 956, 866, - - 205, 204, 203, 957, 200, 199, 194, 193, 192, 957, - 957, 957, 957, 957, 957, 958, 959, 959, 959, 959, - 959, 959, 453, 191, 190, 189, 960, 188, 187, 186, - 185, 181, 960, 960, 960, 960, 960, 960, 873, 968, - 968, 968, 968, 968, 968, 968, 875, 180, 179, 178, - 969, 177, 176, 175, 174, 173, 969, 969, 969, 969, - 969, 969, 970, 971, 971, 971, 971, 971, 971, 453, - 172, 171, 170, 972, 169, 168, 167, 166, 165, 972, - 972, 972, 972, 972, 972, 884, 983, 983, 983, 983, - 983, 983, 983, 886, 160, 151, 150, 984, 145, 59, - - 47, 45, 1469, 984, 984, 984, 984, 984, 984, 985, - 986, 986, 986, 986, 986, 986, 453, 1469, 1469, 1469, - 987, 1469, 1469, 1469, 1469, 1469, 987, 987, 987, 987, - 987, 987, 896, 999, 999, 999, 999, 999, 999, 999, - 898, 1469, 1469, 1469, 1000, 1469, 1469, 1469, 1469, 1469, - 1000, 1000, 1000, 1000, 1000, 1000, 1001, 1002, 1002, 1002, - 1002, 1002, 1002, 453, 1469, 1469, 1469, 1003, 1469, 1469, - 1469, 1469, 1469, 1003, 1003, 1003, 1003, 1003, 1003, 825, - 1010, 1010, 1010, 1010, 1010, 1010, 1010, 827, 1469, 1469, - 1469, 1011, 1469, 1469, 1469, 1469, 1469, 1011, 1011, 1011, - - 1011, 1011, 1011, 1012, 1013, 1013, 1013, 1013, 1013, 1013, - 1013, 1014, 1469, 1469, 1469, 1015, 1469, 1016, 1469, 1469, - 1469, 1015, 1015, 1015, 1015, 1015, 1015, 1188, 1189, 1189, - 1189, 1189, 1189, 1189, 1195, 1196, 1196, 1196, 1196, 1196, - 1196, 1469, 1469, 1016, 55, 607, 1029, 1029, 1029, 1029, - 1029, 1029, 1029, 1469, 1469, 1469, 1469, 1030, 1469, 1469, - 1469, 1469, 55, 1030, 1030, 1030, 1030, 1030, 1030, 53, - 1030, 1030, 1030, 1030, 1030, 1030, 1030, 55, 267, 1031, - 1031, 1031, 1031, 1031, 1031, 1031, 1198, 1199, 1199, 1199, - 1199, 1199, 1199, 1469, 1469, 55, 864, 1034, 1034, 1034, - - 1034, 1034, 1034, 1034, 1035, 1469, 1469, 1469, 1036, 1469, - 868, 1469, 1469, 1469, 1036, 1036, 1036, 1036, 1036, 1036, - 1202, 1203, 1203, 1203, 1203, 1203, 1203, 1102, 1102, 1102, - 1102, 1102, 1102, 1102, 55, 1469, 868, 873, 1037, 1037, - 1037, 1037, 1037, 1037, 1037, 1038, 1469, 1268, 1268, 1039, - 1469, 877, 55, 1469, 1469, 1039, 1039, 1039, 1039, 1039, - 1039, 1269, 1469, 1225, 1247, 1248, 1248, 1248, 1248, 1248, - 1248, 1469, 1469, 1469, 1469, 1270, 1469, 877, 884, 1040, - 1040, 1040, 1040, 1040, 1040, 1040, 1041, 1269, 1469, 1271, - 1042, 1469, 888, 1469, 1469, 1270, 1042, 1042, 1042, 1042, - - 1042, 1042, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1469, - 1469, 1469, 1469, 1469, 1276, 1271, 1276, 1469, 888, 896, - 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1044, 1277, 1469, - 1469, 1045, 1469, 900, 1469, 1469, 1278, 1045, 1045, 1045, - 1045, 1045, 1045, 1182, 1182, 1182, 1182, 1182, 1182, 1182, - 1279, 1469, 1469, 1469, 1277, 1469, 1469, 1469, 1278, 900, - 1047, 1048, 1048, 1048, 1048, 1048, 1048, 1049, 1469, 1469, - 1469, 1050, 1469, 1469, 1469, 1469, 1279, 1050, 1050, 1050, - 1050, 1050, 1050, 1051, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1053, 1469, 1469, 1469, 1054, 1469, 1055, 1469, 1469, - - 1284, 1054, 1054, 1054, 1054, 1054, 1054, 1196, 1196, 1196, - 1196, 1196, 1196, 1196, 1285, 1469, 1469, 1469, 1469, 1284, - 1469, 1286, 1469, 1055, 864, 1058, 1058, 1058, 1058, 1058, - 1058, 1058, 1035, 1469, 1469, 1287, 1059, 1469, 1469, 1469, - 1285, 1469, 1059, 1059, 1059, 1059, 1059, 1059, 1060, 1061, - 1061, 1061, 1061, 1061, 1061, 1061, 1062, 1469, 1286, 1469, - 1063, 1287, 1064, 1469, 1469, 1469, 1063, 1063, 1063, 1063, - 1063, 1063, 1469, 1292, 1293, 1293, 1293, 1293, 1293, 1293, - 1295, 1296, 1296, 1296, 1296, 1296, 1296, 1469, 1064, 873, - 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1038, 1469, 1469, - - 1469, 1070, 1469, 1469, 1469, 1469, 1469, 1070, 1070, 1070, - 1070, 1070, 1070, 1071, 1072, 1072, 1072, 1072, 1072, 1072, - 1072, 1073, 1469, 1469, 1469, 1074, 1469, 1075, 1469, 1469, - 1318, 1074, 1074, 1074, 1074, 1074, 1074, 1299, 1300, 1300, - 1300, 1300, 1300, 1300, 1319, 1469, 1469, 1469, 1469, 1469, - 1469, 1318, 1469, 1075, 884, 1081, 1081, 1081, 1081, 1081, - 1081, 1081, 1041, 1469, 1469, 1469, 1082, 1469, 1469, 1469, - 1319, 55, 1082, 1082, 1082, 1082, 1082, 1082, 1083, 1084, - 1084, 1084, 1084, 1084, 1084, 1084, 1085, 55, 1469, 55, - 1086, 1469, 1087, 1469, 1469, 1469, 1086, 1086, 1086, 1086, - - 1086, 1086, 1307, 1469, 1469, 55, 1324, 1325, 1325, 1325, - 1325, 1325, 1325, 1469, 1365, 1469, 1308, 1469, 1087, 896, - 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1044, 1366, 1469, - 1469, 1094, 1469, 1469, 1469, 1469, 1469, 1094, 1094, 1094, - 1094, 1094, 1094, 1095, 1096, 1096, 1096, 1096, 1096, 1096, - 1096, 1097, 1469, 1469, 1366, 1098, 1469, 1099, 1469, 1469, - 1469, 1098, 1098, 1098, 1098, 1098, 1098, 1329, 1330, 1330, - 1330, 1330, 1330, 1330, 1332, 1333, 1333, 1333, 1333, 1333, - 1333, 1365, 1469, 1099, 1012, 1110, 1110, 1110, 1110, 1110, - 1110, 1110, 1014, 1469, 1469, 1469, 1111, 1469, 1469, 1469, - - 1469, 1367, 1111, 1111, 1111, 1111, 1111, 1111, 1112, 1113, - 1113, 1113, 1113, 1113, 1113, 1368, 1469, 1469, 1469, 1114, - 1469, 1469, 1469, 1469, 1469, 1114, 1114, 1114, 1114, 1114, - 1114, 55, 607, 1126, 1126, 1126, 1126, 1126, 1126, 1126, - 1469, 1368, 1469, 1469, 933, 1469, 1469, 1469, 1469, 55, - 933, 933, 933, 933, 933, 933, 53, 933, 933, 933, - 933, 933, 933, 933, 55, 267, 1031, 1031, 1031, 1031, - 1031, 1031, 1031, 1338, 1339, 1339, 1339, 1339, 1339, 1339, - 1469, 1367, 55, 1129, 1130, 1130, 1130, 1130, 1130, 1130, - 1469, 1469, 1469, 1469, 1131, 1469, 1469, 1469, 1469, 1469, - - 1131, 1131, 1131, 1131, 1131, 1131, 864, 956, 956, 956, - 956, 956, 956, 956, 1035, 1469, 1469, 1469, 957, 1469, - 1469, 1469, 1469, 1390, 957, 957, 957, 957, 957, 957, - 1132, 1133, 1133, 1133, 1133, 1133, 1133, 1391, 1469, 1469, - 1469, 1134, 1469, 1469, 1469, 1469, 1469, 1134, 1134, 1134, - 1134, 1134, 1134, 873, 968, 968, 968, 968, 968, 968, - 968, 1038, 1469, 1391, 1469, 969, 1469, 1469, 1469, 1469, - 1390, 969, 969, 969, 969, 969, 969, 1135, 1136, 1136, - 1136, 1136, 1136, 1136, 1469, 1469, 1469, 1469, 1137, 1469, - 1469, 1469, 1469, 1469, 1137, 1137, 1137, 1137, 1137, 1137, - - 884, 983, 983, 983, 983, 983, 983, 983, 1041, 1469, - 1469, 1469, 984, 1469, 1469, 1469, 1469, 1394, 984, 984, - 984, 984, 984, 984, 1138, 1139, 1139, 1139, 1139, 1139, - 1139, 1395, 1469, 1469, 1469, 1140, 1469, 1469, 1469, 1469, - 1469, 1140, 1140, 1140, 1140, 1140, 1140, 896, 999, 999, - 999, 999, 999, 999, 999, 1044, 1469, 1395, 1469, 1000, - 1469, 1469, 1469, 1469, 1394, 1000, 1000, 1000, 1000, 1000, - 1000, 1141, 1142, 1142, 1142, 1142, 1142, 1142, 1469, 1469, - 1469, 1469, 1143, 1469, 1469, 1469, 1469, 1469, 1143, 1143, - 1143, 1143, 1143, 1143, 1145, 1146, 1146, 1146, 1146, 1146, - - 1146, 1146, 1147, 1469, 1469, 1469, 1148, 1469, 1149, 1469, - 1469, 1469, 1148, 1148, 1148, 1148, 1148, 1148, 1341, 1342, - 1342, 1342, 1342, 1342, 1342, 1347, 1348, 1348, 1348, 1348, - 1348, 1348, 1398, 1469, 1149, 1051, 1153, 1153, 1153, 1153, - 1153, 1153, 1153, 1053, 1469, 1469, 1399, 1154, 1469, 1469, - 1469, 1469, 1469, 1154, 1154, 1154, 1154, 1154, 1154, 1060, - 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1062, 1469, 1469, - 1469, 1164, 1399, 1469, 1469, 1469, 1469, 1164, 1164, 1164, - 1164, 1164, 1164, 1071, 1176, 1176, 1176, 1176, 1176, 1176, - 1176, 1073, 1469, 1469, 1469, 1177, 1469, 1469, 1469, 1469, - - 1469, 1177, 1177, 1177, 1177, 1177, 1177, 1083, 1190, 1190, - 1190, 1190, 1190, 1190, 1190, 1085, 1469, 1469, 1469, 1191, - 1469, 1469, 1469, 1469, 1469, 1191, 1191, 1191, 1191, 1191, - 1191, 1095, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1097, - 1469, 1469, 1469, 1205, 1469, 1469, 1469, 1469, 1469, 1205, - 1205, 1205, 1205, 1205, 1205, 1012, 1213, 1213, 1213, 1213, - 1213, 1213, 1213, 1014, 1469, 1469, 1469, 1214, 1469, 1469, - 1469, 1469, 1469, 1214, 1214, 1214, 1214, 1214, 1214, 1215, - 1216, 1216, 1216, 1216, 1216, 1216, 1216, 1217, 1469, 1469, - 1469, 1218, 1469, 1219, 1469, 1469, 1469, 1218, 1218, 1218, - - 1218, 1218, 1218, 1350, 1351, 1351, 1351, 1351, 1351, 1351, - 1356, 1357, 1357, 1357, 1357, 1357, 1357, 1469, 1469, 1219, - 55, 607, 522, 522, 522, 522, 522, 522, 522, 1359, - 1360, 1360, 1360, 1360, 1360, 1360, 1469, 1398, 55, 1228, - 1229, 1229, 1229, 1229, 1229, 1229, 1230, 1469, 1469, 1469, - 1231, 1469, 1469, 1469, 1469, 1469, 1231, 1231, 1231, 1231, - 1231, 1231, 1051, 1232, 1232, 1232, 1232, 1232, 1232, 1232, - 1233, 1469, 1469, 1469, 1234, 1469, 1055, 1469, 1469, 1469, - 1234, 1234, 1234, 1234, 1234, 1234, 1293, 1293, 1293, 1293, - 1293, 1293, 1293, 1384, 1385, 1385, 1385, 1385, 1385, 1385, - - 1469, 1469, 1055, 1060, 1235, 1235, 1235, 1235, 1235, 1235, - 1235, 1236, 1469, 1469, 1469, 1237, 1469, 1064, 1469, 1469, - 1469, 1237, 1237, 1237, 1237, 1237, 1237, 1330, 1330, 1330, - 1330, 1330, 1330, 1330, 1339, 1339, 1339, 1339, 1339, 1339, - 1339, 1402, 1469, 1064, 1071, 1238, 1238, 1238, 1238, 1238, - 1238, 1238, 1239, 1469, 1469, 1403, 1240, 1469, 1075, 1469, - 1469, 1402, 1240, 1240, 1240, 1240, 1240, 1240, 1348, 1348, - 1348, 1348, 1348, 1348, 1348, 1469, 1469, 1469, 1469, 1469, - 1406, 1403, 1406, 1469, 1075, 1083, 1241, 1241, 1241, 1241, - 1241, 1241, 1241, 1242, 1407, 1469, 1469, 1243, 1469, 1087, - - 1469, 1469, 1422, 1243, 1243, 1243, 1243, 1243, 1243, 1357, - 1357, 1357, 1357, 1357, 1357, 1357, 1423, 1469, 1469, 1469, - 1407, 1469, 1469, 1469, 1469, 1087, 1095, 1244, 1244, 1244, - 1244, 1244, 1244, 1244, 1245, 1469, 1469, 1469, 1246, 1469, - 1099, 1469, 1423, 1469, 1246, 1246, 1246, 1246, 1246, 1246, - 1410, 1411, 1411, 1411, 1411, 1411, 1411, 1413, 1414, 1414, - 1414, 1414, 1414, 1414, 1422, 1469, 1099, 1145, 1249, 1249, - 1249, 1249, 1249, 1249, 1249, 1147, 1469, 1469, 1469, 1250, - 1469, 1469, 1469, 1469, 1469, 1250, 1250, 1250, 1250, 1250, - 1250, 1051, 1257, 1257, 1257, 1257, 1257, 1257, 1257, 1233, - - 1469, 1469, 1469, 1258, 1469, 1469, 1469, 1469, 1469, 1258, - 1258, 1258, 1258, 1258, 1258, 1060, 1264, 1264, 1264, 1264, - 1264, 1264, 1264, 1236, 1469, 1469, 1469, 1265, 1469, 1469, - 1469, 1469, 1469, 1265, 1265, 1265, 1265, 1265, 1265, 1071, - 1272, 1272, 1272, 1272, 1272, 1272, 1272, 1239, 1469, 1469, - 1469, 1273, 1469, 1469, 1469, 1469, 1469, 1273, 1273, 1273, - 1273, 1273, 1273, 1083, 1280, 1280, 1280, 1280, 1280, 1280, - 1280, 1242, 1469, 1469, 1469, 1281, 1469, 1469, 1469, 1469, - 1469, 1281, 1281, 1281, 1281, 1281, 1281, 1095, 1288, 1288, - 1288, 1288, 1288, 1288, 1288, 1245, 1469, 1469, 1469, 1289, - - 1469, 1469, 1469, 1469, 1469, 1289, 1289, 1289, 1289, 1289, - 1289, 1215, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1217, - 1469, 1469, 1469, 1302, 1469, 1469, 1469, 1469, 1469, 1302, - 1302, 1302, 1302, 1302, 1302, 1145, 1309, 1309, 1309, 1309, - 1309, 1309, 1309, 1310, 1469, 1469, 1469, 1311, 1469, 1149, - 1469, 1469, 1469, 1311, 1311, 1311, 1311, 1311, 1311, 1424, - 1425, 1425, 1425, 1425, 1425, 1425, 1428, 1429, 1429, 1429, - 1429, 1429, 1429, 1444, 1469, 1149, 1051, 1153, 1153, 1153, - 1153, 1153, 1153, 1153, 1233, 1469, 1469, 1445, 1154, 1469, - 1469, 1469, 1469, 1469, 1154, 1154, 1154, 1154, 1154, 1154, - - 1060, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1236, 1469, - 1469, 1469, 1164, 1445, 1469, 1469, 1469, 1469, 1164, 1164, - 1164, 1164, 1164, 1164, 1071, 1176, 1176, 1176, 1176, 1176, - 1176, 1176, 1239, 1469, 1469, 1469, 1177, 1469, 1469, 1469, - 1469, 1469, 1177, 1177, 1177, 1177, 1177, 1177, 1083, 1190, - 1190, 1190, 1190, 1190, 1190, 1190, 1242, 1469, 1469, 1469, - 1191, 1469, 1469, 1469, 1469, 1469, 1191, 1191, 1191, 1191, - 1191, 1191, 1095, 1204, 1204, 1204, 1204, 1204, 1204, 1204, - 1245, 1469, 1469, 1469, 1205, 1469, 1469, 1469, 1469, 1469, - 1205, 1205, 1205, 1205, 1205, 1205, 1145, 1320, 1320, 1320, - - 1320, 1320, 1320, 1320, 1310, 1469, 1469, 1469, 1321, 1469, - 1469, 1469, 1469, 1469, 1321, 1321, 1321, 1321, 1321, 1321, - 1215, 1369, 1369, 1369, 1369, 1369, 1369, 1369, 1217, 1469, - 1469, 1469, 1370, 1469, 1469, 1469, 1469, 1469, 1370, 1370, - 1370, 1370, 1370, 1370, 1145, 1249, 1249, 1249, 1249, 1249, - 1249, 1249, 1310, 1469, 1469, 1469, 1250, 1469, 1469, 1469, - 1469, 1469, 1250, 1250, 1250, 1250, 1250, 1250, 1432, 1433, - 1433, 1433, 1433, 1433, 1433, 1436, 1437, 1437, 1437, 1437, - 1437, 1437, 1440, 1441, 1441, 1441, 1441, 1441, 1441, 1411, - 1411, 1411, 1411, 1411, 1411, 1411, 1444, 1448, 1449, 1449, - - 1449, 1449, 1449, 1449, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1425, 1425, 1425, 1425, 1425, 1425, 1425, 1429, 1429, - 1429, 1429, 1429, 1429, 1429, 1433, 1433, 1433, 1433, 1433, - 1433, 1433, 1469, 1469, 1469, 1469, 1469, 1437, 1437, 1437, - 1437, 1437, 1437, 1437, 1441, 1441, 1441, 1441, 1441, 1441, - 1441, 1457, 1458, 1458, 1458, 1458, 1458, 1458, 1449, 1449, - 1449, 1449, 1449, 1449, 1449, 1458, 1458, 1458, 1458, 1458, - 1458, 1458, 46, 1469, 1469, 1469, 1469, 46, 46, 46, - 64, 1469, 64, 64, 64, 64, 64, 64, 64, 152, - 1469, 152, 159, 159, 159, 271, 271, 271, 280, 280, - - 280, 359, 359, 359, 362, 362, 362, 363, 363, 363, - 370, 370, 370, 368, 368, 368, 374, 374, 374, 378, - 1469, 378, 443, 443, 443, 448, 448, 448, 449, 449, - 449, 458, 458, 458, 462, 1469, 462, 463, 463, 463, - 372, 372, 1469, 1469, 372, 467, 467, 467, 471, 471, - 471, 362, 362, 362, 529, 529, 529, 533, 533, 533, - 534, 534, 534, 535, 535, 535, 370, 370, 370, 540, - 540, 540, 456, 456, 1469, 1469, 456, 545, 545, 545, - 549, 549, 549, 553, 1469, 553, 554, 554, 554, 558, - 558, 558, 562, 1469, 562, 612, 612, 612, 458, 458, - - 458, 620, 620, 620, 621, 621, 621, 629, 629, 629, - 633, 1469, 633, 636, 1469, 636, 637, 637, 637, 641, - 641, 641, 645, 1469, 645, 552, 552, 1469, 1469, 552, - 556, 556, 1469, 1469, 556, 651, 651, 651, 655, 655, - 655, 562, 562, 1469, 562, 534, 534, 534, 689, 689, - 689, 693, 693, 693, 696, 696, 696, 697, 697, 697, - 698, 698, 698, 703, 703, 703, 627, 627, 1469, 1469, - 627, 708, 708, 708, 712, 712, 712, 633, 633, 1469, - 633, 635, 635, 1469, 1469, 635, 636, 636, 1469, 636, - 637, 637, 639, 639, 1469, 1469, 639, 719, 719, 719, - - 723, 723, 723, 645, 645, 1469, 645, 727, 1469, 727, - 730, 1469, 730, 731, 731, 731, 735, 735, 735, 739, - 1469, 739, 766, 766, 766, 629, 629, 629, 641, 641, - 641, 777, 777, 777, 778, 778, 778, 786, 786, 786, - 790, 1469, 790, 793, 1469, 793, 794, 794, 794, 798, - 798, 798, 802, 1469, 802, 805, 1469, 805, 808, 1469, - 808, 809, 809, 809, 813, 813, 813, 817, 1469, 817, - 726, 1469, 1469, 726, 727, 727, 1469, 727, 729, 729, - 1469, 1469, 729, 730, 730, 1469, 730, 731, 731, 733, - 733, 1469, 1469, 733, 824, 824, 824, 828, 828, 828, - - 739, 739, 1469, 739, 53, 53, 53, 1469, 53, 53, - 697, 697, 697, 850, 850, 850, 854, 854, 854, 857, - 857, 857, 860, 860, 860, 861, 861, 861, 862, 862, - 862, 867, 867, 867, 784, 784, 1469, 1469, 784, 872, - 872, 872, 876, 876, 876, 790, 790, 1469, 790, 792, - 792, 1469, 1469, 792, 793, 793, 1469, 793, 794, 794, - 796, 796, 1469, 1469, 796, 883, 883, 883, 887, 887, - 887, 802, 802, 1469, 802, 804, 1469, 1469, 804, 805, - 805, 1469, 805, 807, 807, 1469, 1469, 807, 808, 808, - 1469, 808, 809, 809, 811, 811, 1469, 1469, 811, 895, - - 895, 895, 899, 899, 899, 817, 817, 1469, 817, 901, - 1469, 901, 904, 1469, 904, 907, 1469, 907, 908, 908, - 908, 912, 912, 912, 916, 1469, 916, 53, 53, 53, - 1469, 53, 53, 934, 934, 934, 786, 786, 786, 798, - 798, 798, 813, 813, 813, 948, 948, 948, 949, 949, - 949, 957, 957, 957, 961, 1469, 961, 964, 1469, 964, - 965, 965, 965, 969, 969, 969, 973, 1469, 973, 976, - 1469, 976, 979, 1469, 979, 980, 980, 980, 984, 984, - 984, 988, 1469, 988, 989, 1469, 989, 992, 1469, 992, - 995, 1469, 995, 996, 996, 996, 1000, 1000, 1000, 1004, - - 1469, 1004, 901, 1469, 901, 903, 1469, 1469, 903, 904, - 904, 1469, 904, 906, 906, 1469, 1469, 906, 907, 907, - 1469, 907, 908, 908, 910, 910, 1469, 1469, 910, 1011, - 1011, 1011, 1015, 1015, 1015, 916, 916, 1469, 916, 53, - 53, 53, 1469, 53, 53, 861, 861, 861, 1032, 1032, - 1032, 1036, 1036, 1036, 1039, 1039, 1039, 1042, 1042, 1042, - 1045, 1045, 1045, 1046, 1046, 1046, 1054, 1054, 1054, 955, - 955, 1469, 1469, 955, 1059, 1059, 1059, 1063, 1063, 1063, - 961, 961, 1469, 961, 963, 963, 1469, 1469, 963, 964, - 964, 1469, 964, 965, 965, 967, 967, 1469, 1469, 967, - - 1070, 1070, 1070, 1074, 1074, 1074, 973, 973, 1469, 973, - 975, 1469, 1469, 975, 976, 976, 1469, 976, 978, 978, - 1469, 1469, 978, 979, 979, 1469, 979, 980, 980, 982, - 982, 1469, 1469, 982, 1082, 1082, 1082, 1086, 1086, 1086, - 988, 988, 1469, 988, 989, 1469, 989, 991, 1469, 1469, - 991, 992, 992, 1469, 992, 994, 994, 1469, 1469, 994, - 995, 995, 1469, 995, 996, 996, 998, 998, 1469, 1469, - 998, 1094, 1094, 1094, 1098, 1098, 1098, 1004, 1004, 1469, - 1004, 1100, 1469, 1100, 1103, 1469, 1103, 1106, 1469, 1106, - 1107, 1107, 1107, 1111, 1111, 1111, 1115, 1469, 1115, 53, - - 53, 53, 1469, 53, 53, 1127, 1127, 1127, 957, 957, - 957, 969, 969, 969, 984, 984, 984, 1000, 1000, 1000, - 1144, 1144, 1144, 1150, 1150, 1150, 1148, 1148, 1148, 1155, - 1155, 1155, 1154, 1154, 1154, 1156, 1469, 1156, 1159, 1469, - 1159, 1160, 1160, 1160, 1165, 1165, 1165, 1164, 1164, 1164, - 1166, 1469, 1166, 1169, 1469, 1169, 1172, 1469, 1172, 1173, - 1173, 1173, 1178, 1178, 1178, 1177, 1177, 1177, 1179, 1469, - 1179, 1180, 1469, 1180, 1183, 1469, 1183, 1186, 1469, 1186, - 1187, 1187, 1187, 1192, 1192, 1192, 1191, 1191, 1191, 1193, - 1469, 1193, 1194, 1469, 1194, 1197, 1469, 1197, 1200, 1469, - - 1200, 1201, 1201, 1201, 1206, 1206, 1206, 1205, 1205, 1205, - 1207, 1469, 1207, 1100, 1469, 1100, 1102, 1469, 1469, 1102, - 1103, 1103, 1469, 1103, 1105, 1105, 1469, 1469, 1105, 1106, - 1106, 1469, 1106, 1107, 1107, 1109, 1109, 1469, 1469, 1109, - 1214, 1214, 1214, 1218, 1218, 1218, 1115, 1115, 1469, 1115, - 53, 53, 53, 1469, 53, 53, 1046, 1046, 1046, 1234, - 1234, 1234, 1237, 1237, 1237, 1240, 1240, 1240, 1243, 1243, - 1243, 1246, 1246, 1246, 1251, 1251, 1251, 1250, 1250, 1250, - 1253, 1469, 1253, 1254, 1254, 1254, 1152, 1152, 1469, 1469, - 1152, 1258, 1258, 1258, 1259, 1259, 1259, 1156, 1156, 1469, - - 1156, 1158, 1158, 1469, 1469, 1158, 1159, 1159, 1469, 1159, - 1160, 1160, 1162, 1162, 1469, 1469, 1162, 1265, 1265, 1265, - 1266, 1266, 1266, 1166, 1166, 1469, 1166, 1168, 1469, 1469, - 1168, 1169, 1169, 1469, 1169, 1171, 1171, 1469, 1469, 1171, - 1172, 1172, 1469, 1172, 1173, 1173, 1175, 1175, 1469, 1469, - 1175, 1273, 1273, 1273, 1274, 1274, 1274, 1179, 1179, 1469, - 1179, 1180, 1469, 1180, 1182, 1469, 1469, 1182, 1183, 1183, - 1469, 1183, 1185, 1185, 1469, 1469, 1185, 1186, 1186, 1469, - 1186, 1187, 1187, 1189, 1189, 1469, 1469, 1189, 1281, 1281, - 1281, 1282, 1282, 1282, 1193, 1193, 1469, 1193, 1194, 1469, - - 1194, 1196, 1469, 1469, 1196, 1197, 1197, 1469, 1197, 1199, - 1199, 1469, 1469, 1199, 1200, 1200, 1469, 1200, 1201, 1201, - 1203, 1203, 1469, 1469, 1203, 1289, 1289, 1289, 1290, 1290, - 1290, 1207, 1207, 1469, 1207, 1291, 1469, 1291, 1294, 1469, - 1294, 1297, 1469, 1297, 1298, 1298, 1298, 1303, 1469, 1303, - 1302, 1302, 1302, 1304, 1469, 1304, 53, 53, 53, 1469, - 53, 53, 1312, 1469, 1312, 1311, 1311, 1311, 1313, 1469, - 1313, 1154, 1154, 1154, 1314, 1469, 1314, 1164, 1164, 1164, - 1315, 1469, 1315, 1177, 1177, 1177, 1316, 1469, 1316, 1191, - 1191, 1191, 1317, 1469, 1317, 1205, 1205, 1205, 1248, 1248, - - 1469, 1469, 1248, 1321, 1321, 1321, 1322, 1322, 1322, 370, - 370, 370, 1253, 1253, 1469, 1253, 1323, 1323, 1323, 1326, - 1469, 1326, 1327, 1327, 1327, 1328, 1328, 1328, 1331, 1469, - 1331, 1334, 1469, 1334, 1335, 1335, 1335, 1336, 1336, 1336, - 1337, 1469, 1337, 1340, 1469, 1340, 1343, 1469, 1343, 1344, - 1344, 1344, 1345, 1345, 1345, 1346, 1469, 1346, 1349, 1469, - 1349, 1352, 1469, 1352, 1353, 1353, 1353, 1354, 1354, 1354, - 1355, 1469, 1355, 1358, 1469, 1358, 1361, 1469, 1361, 1362, - 1362, 1362, 1363, 1363, 1363, 1291, 1469, 1291, 1293, 1469, - 1469, 1293, 1294, 1294, 1469, 1294, 1296, 1296, 1469, 1469, - - 1296, 1297, 1297, 1469, 1297, 1298, 1298, 1300, 1300, 1469, - 1469, 1300, 1370, 1370, 1370, 1371, 1469, 1371, 1304, 1304, - 1469, 1304, 53, 53, 53, 1469, 53, 53, 1376, 1376, - 1376, 1250, 1250, 1250, 1378, 1469, 1378, 1379, 1469, 1379, - 1380, 1469, 1380, 1381, 1469, 1381, 1382, 1469, 1382, 1383, - 1469, 1383, 1386, 1469, 1386, 1387, 1387, 1387, 1388, 1388, - 1388, 1389, 1469, 1389, 1325, 1325, 1469, 1469, 1325, 1326, - 1326, 1469, 1326, 1327, 1327, 1392, 1469, 1392, 1330, 1469, - 1469, 1330, 1331, 1331, 1469, 1331, 1333, 1333, 1469, 1469, - 1333, 1334, 1334, 1469, 1334, 1335, 1335, 1396, 1469, 1396, - - 1337, 1469, 1337, 1339, 1469, 1469, 1339, 1340, 1340, 1469, - 1340, 1342, 1342, 1469, 1469, 1342, 1343, 1343, 1469, 1343, - 1344, 1344, 1400, 1469, 1400, 1346, 1469, 1346, 1348, 1469, - 1469, 1348, 1349, 1349, 1469, 1349, 1351, 1351, 1469, 1469, - 1351, 1352, 1352, 1469, 1352, 1353, 1353, 1404, 1469, 1404, - 1355, 1469, 1355, 1357, 1469, 1469, 1357, 1358, 1358, 1469, - 1358, 1360, 1360, 1469, 1469, 1360, 1361, 1361, 1469, 1361, - 1362, 1362, 1408, 1469, 1408, 1409, 1469, 1409, 1412, 1469, - 1412, 1415, 1469, 1415, 1416, 1416, 1416, 1417, 1469, 1417, - 53, 53, 53, 1469, 53, 53, 1421, 1469, 1421, 1323, - - 1469, 1323, 1328, 1469, 1328, 1336, 1469, 1336, 1345, 1469, - 1345, 1354, 1469, 1354, 1363, 1469, 1363, 1385, 1385, 1469, - 1469, 1385, 1386, 1386, 1469, 1386, 1387, 1387, 1377, 1469, - 1377, 1426, 1469, 1426, 1427, 1469, 1427, 1430, 1469, 1430, - 1431, 1469, 1431, 1434, 1469, 1434, 1435, 1469, 1435, 1438, - 1469, 1438, 1439, 1469, 1439, 1442, 1469, 1442, 1411, 1469, - 1469, 1411, 1414, 1414, 1469, 1469, 1414, 1446, 1469, 1446, - 1388, 1469, 1388, 1450, 1469, 1450, 1425, 1469, 1469, 1425, - 1429, 1469, 1469, 1429, 1433, 1469, 1469, 1433, 1437, 1469, - 1469, 1437, 1441, 1469, 1469, 1441, 1456, 1469, 1456, 1459, - - 1469, 1459, 1449, 1469, 1469, 1449, 1461, 1469, 1461, 1462, - 1469, 1462, 1463, 1469, 1463, 1464, 1469, 1464, 1465, 1469, - 1465, 1458, 1469, 1469, 1458, 1467, 1469, 1467, 1468, 1469, - 1468, 3, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469 + 469, 469, 469, 469, 469, 470, 55, 975, 55, 471, + 787, 472, 1376, 965, 788, 471, 471, 471, 471, 471, + 471, 582, 738, 583, 53, 789, 584, 585, 53, 738, + 586, 587, 791, 733, 792, 588, 739, 472, 482, 53, + 1161, 902, 483, 1728, 53, 484, 53, 740, 485, 740, + 486, 487, 488, 489, 521, 521, 521, 521, 521, 521, + 521, 741, 739, 1728, 1295, 521, 55, 55, 55, 1728, + + 1421, 521, 521, 521, 521, 521, 521, 522, 523, 523, + 523, 523, 523, 523, 55, 55, 55, 741, 524, 1728, + 967, 969, 1061, 880, 524, 524, 524, 524, 524, 524, + 432, 525, 525, 525, 525, 525, 525, 525, 526, 526, + 526, 526, 526, 526, 526, 1223, 1468, 1470, 1061, 526, + 1506, 55, 55, 55, 55, 526, 526, 526, 526, 526, + 526, 437, 528, 528, 528, 528, 528, 528, 528, 55, + 55, 55, 55, 529, 1510, 265, 970, 976, 881, 529, + 529, 529, 529, 529, 529, 646, 647, 647, 647, 647, + 647, 647, 650, 651, 651, 651, 651, 651, 651, 55, + + 855, 265, 529, 529, 529, 529, 529, 529, 529, 1728, + 744, 1728, 1728, 529, 856, 55, 1514, 55, 905, 529, + 529, 529, 529, 529, 529, 530, 530, 530, 530, 530, + 530, 530, 1518, 55, 867, 1728, 531, 1728, 1728, 1728, + 856, 979, 531, 531, 531, 531, 531, 531, 53, 531, + 531, 531, 531, 531, 531, 531, 365, 534, 534, 534, + 534, 534, 534, 534, 535, 1728, 1522, 1551, 536, 1728, + 369, 1573, 1155, 1149, 536, 536, 536, 536, 536, 536, + 749, 750, 750, 750, 750, 750, 750, 752, 753, 753, + 753, 753, 753, 753, 55, 1728, 369, 540, 541, 541, + + 541, 541, 541, 541, 541, 542, 861, 453, 1332, 543, + 930, 544, 55, 1085, 863, 543, 543, 543, 543, 543, + 543, 756, 757, 757, 757, 757, 757, 757, 819, 820, + 820, 820, 820, 820, 820, 855, 55, 544, 365, 547, + 547, 547, 547, 547, 547, 547, 535, 1145, 1143, 1728, + 548, 1728, 1137, 1728, 55, 55, 548, 548, 548, 548, + 548, 548, 549, 550, 550, 550, 550, 550, 550, 550, + 551, 868, 453, 55, 552, 1728, 553, 1728, 982, 1728, + 552, 552, 552, 552, 552, 552, 827, 828, 828, 828, + 828, 828, 828, 831, 832, 832, 832, 832, 832, 832, + + 857, 55, 553, 468, 560, 560, 560, 560, 560, 560, + 560, 470, 1329, 1728, 858, 561, 919, 55, 1133, 55, + 857, 561, 561, 561, 561, 561, 561, 562, 563, 563, + 563, 563, 563, 563, 1728, 55, 869, 1131, 564, 1728, + 858, 55, 1087, 55, 564, 564, 564, 564, 564, 564, + 613, 915, 614, 614, 614, 614, 614, 614, 614, 55, + 1728, 55, 1126, 614, 972, 916, 55, 55, 885, 614, + 614, 614, 614, 614, 614, 615, 616, 616, 616, 616, + 616, 616, 616, 453, 55, 55, 1326, 617, 1078, 618, + 910, 916, 1084, 617, 617, 617, 617, 617, 617, 839, + + 840, 840, 840, 840, 840, 840, 842, 843, 843, 843, + 843, 843, 843, 55, 55, 618, 615, 617, 617, 617, + 617, 617, 617, 617, 1142, 910, 1122, 1728, 617, 1154, + 1728, 55, 55, 1101, 617, 617, 617, 617, 617, 617, + 437, 620, 620, 620, 620, 620, 620, 620, 871, 919, + 1142, 877, 621, 1728, 1728, 1154, 1728, 1104, 621, 621, + 621, 621, 621, 621, 53, 621, 621, 621, 621, 621, + 621, 621, 622, 622, 622, 622, 622, 622, 622, 930, + 1728, 1117, 453, 623, 1286, 1728, 1728, 1107, 1323, 623, + 623, 623, 623, 623, 623, 53, 623, 623, 623, 623, + + 623, 623, 623, 626, 627, 627, 627, 627, 627, 627, + 1286, 1728, 1728, 1728, 628, 453, 1225, 55, 55, 55, + 628, 628, 628, 628, 628, 628, 365, 457, 457, 457, + 457, 457, 457, 457, 535, 55, 55, 55, 458, 1728, + 1082, 1086, 1089, 915, 458, 458, 458, 458, 458, 458, + 629, 630, 630, 630, 630, 630, 630, 1728, 942, 1342, + 1728, 631, 1206, 55, 55, 1335, 1110, 631, 631, 631, + 631, 631, 631, 635, 636, 636, 636, 636, 636, 636, + 453, 55, 55, 1728, 637, 1090, 1728, 55, 55, 1088, + 637, 637, 637, 637, 637, 637, 540, 640, 640, 640, + + 640, 640, 640, 640, 542, 55, 55, 1091, 641, 1332, + 55, 1093, 55, 1329, 641, 641, 641, 641, 641, 641, + 642, 643, 643, 643, 643, 643, 643, 453, 55, 1326, + 55, 644, 1323, 1206, 55, 55, 55, 644, 644, 644, + 644, 644, 644, 549, 652, 652, 652, 652, 652, 652, + 652, 551, 55, 55, 55, 653, 1068, 55, 55, 55, + 1295, 653, 653, 653, 653, 653, 653, 654, 655, 655, + 655, 655, 655, 655, 453, 55, 55, 55, 656, 1187, + 1190, 55, 1191, 55, 656, 656, 656, 656, 656, 656, + 468, 662, 662, 662, 662, 662, 662, 662, 470, 55, + + 1070, 55, 663, 1728, 1728, 55, 1194, 861, 663, 663, + 663, 663, 663, 663, 664, 665, 665, 665, 665, 665, + 665, 665, 666, 55, 1064, 1195, 667, 1062, 668, 1728, + 1728, 1163, 667, 667, 667, 667, 667, 667, 846, 847, + 847, 847, 847, 847, 847, 750, 750, 750, 750, 750, + 750, 750, 55, 55, 668, 704, 704, 704, 704, 704, + 704, 704, 1357, 453, 1365, 1373, 704, 1728, 55, 1110, + 55, 55, 704, 704, 704, 704, 704, 704, 705, 705, + 705, 705, 705, 705, 705, 878, 55, 968, 1357, 705, + 1365, 1373, 1199, 1728, 1151, 705, 705, 705, 705, 705, + + 705, 615, 706, 706, 706, 706, 706, 706, 706, 707, + 707, 707, 707, 707, 707, 707, 1068, 453, 1107, 1467, + 707, 1509, 55, 55, 1070, 55, 707, 707, 707, 707, + 707, 707, 437, 709, 709, 709, 709, 709, 709, 709, + 55, 55, 1197, 55, 710, 1467, 1200, 1509, 1513, 978, + 710, 710, 710, 710, 710, 710, 53, 710, 710, 710, + 710, 710, 710, 710, 711, 711, 711, 711, 711, 711, + 711, 1117, 1126, 1139, 1513, 712, 453, 1104, 1128, 1323, + 1326, 712, 712, 712, 712, 712, 712, 53, 712, 712, + 712, 712, 712, 712, 712, 540, 715, 715, 715, 715, + + 715, 715, 715, 716, 55, 55, 924, 717, 55, 544, + 55, 55, 55, 717, 717, 717, 717, 717, 717, 1137, + 925, 453, 55, 55, 1101, 1119, 55, 1329, 55, 55, + 55, 55, 980, 55, 870, 544, 549, 718, 718, 718, + 718, 718, 718, 718, 719, 882, 925, 886, 720, 55, + 553, 55, 1149, 1298, 720, 720, 720, 720, 720, 720, + 1332, 875, 453, 1225, 888, 893, 893, 893, 893, 893, + 893, 893, 55, 924, 926, 1517, 553, 724, 725, 725, + 725, 725, 725, 725, 725, 726, 55, 1728, 927, 727, + 55, 728, 926, 936, 936, 727, 727, 727, 727, 727, + + 727, 1517, 341, 1161, 55, 1521, 1728, 937, 1728, 55, + 453, 1335, 1206, 1728, 927, 938, 1110, 728, 540, 731, + 731, 731, 731, 731, 731, 731, 716, 55, 1299, 939, + 732, 1521, 1728, 937, 1728, 55, 732, 732, 732, 732, + 732, 732, 733, 734, 734, 734, 734, 734, 734, 734, + 735, 1300, 1107, 55, 736, 939, 737, 1104, 1304, 938, + 736, 736, 736, 736, 736, 736, 840, 840, 840, 840, + 840, 840, 840, 1728, 948, 949, 949, 949, 949, 949, + 949, 1101, 737, 549, 742, 742, 742, 742, 742, 742, + 742, 719, 1223, 1206, 1572, 743, 1592, 1593, 55, 1728, + + 1413, 743, 743, 743, 743, 743, 743, 744, 745, 745, + 745, 745, 745, 745, 745, 746, 55, 1070, 1301, 747, + 1572, 748, 1592, 1593, 863, 747, 747, 747, 747, 747, + 747, 951, 952, 952, 952, 952, 952, 952, 955, 956, + 956, 956, 956, 956, 956, 55, 55, 748, 664, 758, + 758, 758, 758, 758, 758, 758, 666, 1293, 942, 1163, + 759, 1110, 1594, 55, 55, 1295, 759, 759, 759, 759, + 759, 759, 760, 761, 761, 761, 761, 761, 761, 966, + 974, 744, 938, 762, 55, 55, 55, 55, 1594, 762, + 762, 762, 762, 762, 762, 53, 53, 53, 53, 53, + + 53, 53, 55, 55, 55, 55, 53, 55, 55, 1062, + 55, 55, 53, 53, 53, 53, 53, 53, 971, 973, + 1595, 983, 981, 1063, 1293, 55, 55, 1062, 55, 55, + 764, 794, 1728, 795, 795, 795, 795, 795, 795, 795, + 977, 1728, 1077, 1073, 795, 1186, 1595, 55, 936, 1063, + 795, 795, 795, 795, 795, 795, 1010, 1011, 1011, 1011, + 1011, 1011, 1011, 1064, 1064, 55, 55, 1728, 53, 796, + 797, 797, 797, 797, 797, 797, 797, 1065, 1728, 930, + 1074, 797, 55, 55, 55, 1079, 1151, 797, 797, 797, + 797, 797, 797, 1018, 1019, 1019, 1019, 1019, 1019, 1019, + + 55, 55, 1080, 1065, 1728, 53, 706, 706, 706, 706, + 706, 706, 706, 1022, 1023, 1023, 1023, 1023, 1023, 1023, + 1030, 1031, 1031, 1031, 1031, 1031, 1031, 1033, 1034, 1034, + 1034, 1034, 1034, 1034, 1037, 1038, 1038, 1038, 1038, 1038, + 1038, 53, 707, 707, 707, 707, 707, 707, 707, 1107, + 733, 926, 924, 707, 919, 1596, 1613, 1619, 1139, 707, + 707, 707, 707, 707, 707, 798, 353, 353, 353, 353, + 353, 353, 353, 267, 800, 800, 800, 800, 800, 800, + 800, 1596, 1613, 1619, 1104, 801, 724, 915, 910, 1128, + 1101, 801, 801, 801, 801, 801, 801, 53, 801, 801, + + 801, 801, 801, 801, 801, 804, 805, 805, 805, 805, + 805, 805, 1119, 1006, 991, 1110, 806, 1107, 1104, 55, + 55, 55, 806, 806, 806, 806, 806, 806, 540, 640, + 640, 640, 640, 640, 640, 640, 716, 55, 55, 55, + 641, 1315, 1101, 1316, 55, 1122, 641, 641, 641, 641, + 641, 641, 807, 808, 808, 808, 808, 808, 808, 1123, + 1302, 1099, 55, 809, 991, 861, 55, 1070, 55, 809, + 809, 809, 809, 809, 809, 549, 652, 652, 652, 652, + 652, 652, 652, 719, 55, 1123, 55, 653, 863, 55, + 55, 55, 1122, 653, 653, 653, 653, 653, 653, 810, + + 811, 811, 811, 811, 811, 811, 1728, 55, 55, 55, + 812, 664, 55, 1395, 1404, 1306, 812, 812, 812, 812, + 812, 812, 816, 817, 817, 817, 817, 817, 817, 453, + 55, 857, 1728, 818, 855, 944, 905, 55, 55, 818, + 818, 818, 818, 818, 818, 724, 821, 821, 821, 821, + 821, 821, 821, 726, 1401, 55, 55, 822, 932, 902, + 55, 55, 921, 822, 822, 822, 822, 822, 822, 823, + 824, 824, 824, 824, 824, 824, 453, 1409, 55, 55, + 825, 1476, 1477, 55, 55, 55, 825, 825, 825, 825, + 825, 825, 733, 833, 833, 833, 833, 833, 833, 833, + + 735, 55, 55, 55, 834, 899, 1479, 912, 55, 1006, + 834, 834, 834, 834, 834, 834, 835, 836, 836, 836, + 836, 836, 836, 453, 991, 1478, 55, 837, 905, 902, + 1481, 55, 55, 837, 837, 837, 837, 837, 837, 744, + 848, 848, 848, 848, 848, 848, 848, 746, 899, 55, + 55, 849, 991, 1482, 55, 55, 1483, 849, 849, 849, + 849, 849, 849, 850, 851, 851, 851, 851, 851, 851, + 453, 863, 55, 55, 852, 666, 1486, 55, 1489, 55, + 852, 852, 852, 852, 852, 852, 664, 859, 859, 859, + 859, 859, 859, 859, 666, 55, 744, 55, 860, 944, + + 905, 55, 549, 1536, 860, 860, 860, 860, 860, 860, + 861, 862, 862, 862, 862, 862, 862, 862, 863, 55, + 1546, 740, 864, 738, 865, 733, 932, 902, 864, 864, + 864, 864, 864, 864, 1046, 1047, 1047, 1047, 1047, 1047, + 1047, 1049, 1050, 1050, 1050, 1050, 1050, 1050, 1131, 55, + 865, 55, 1131, 889, 889, 889, 889, 889, 889, 889, + 540, 729, 1132, 724, 889, 921, 1728, 55, 55, 55, + 889, 889, 889, 889, 889, 889, 890, 890, 890, 890, + 890, 890, 890, 1081, 899, 912, 55, 890, 1132, 55, + 55, 55, 1728, 890, 890, 890, 890, 890, 890, 891, + + 892, 892, 892, 892, 892, 892, 1189, 55, 55, 55, + 893, 1549, 55, 55, 55, 55, 893, 893, 893, 893, + 893, 893, 267, 894, 894, 894, 894, 894, 894, 894, + 55, 55, 55, 55, 895, 909, 1577, 1584, 815, 1396, + 895, 895, 895, 895, 895, 895, 53, 895, 895, 895, + 895, 895, 895, 895, 724, 898, 898, 898, 898, 898, + 898, 898, 899, 803, 905, 902, 900, 899, 728, 897, + 803, 664, 900, 900, 900, 900, 900, 900, 1053, 1054, + 1054, 1054, 1054, 1054, 1054, 949, 949, 949, 949, 949, + 949, 949, 55, 55, 728, 733, 901, 901, 901, 901, + + 901, 901, 901, 902, 55, 55, 1133, 903, 863, 737, + 55, 55, 55, 903, 903, 903, 903, 903, 903, 666, + 1134, 468, 55, 55, 660, 1075, 1076, 55, 1083, 55, + 55, 55, 658, 1182, 1183, 737, 744, 904, 904, 904, + 904, 904, 904, 904, 905, 55, 1134, 55, 906, 55, + 748, 1537, 1133, 746, 906, 906, 906, 906, 906, 906, + 1092, 1143, 1094, 1185, 719, 735, 1728, 1031, 1031, 1031, + 1031, 1031, 1031, 1031, 1143, 1144, 748, 910, 911, 911, + 911, 911, 911, 911, 911, 912, 55, 55, 1728, 913, + 716, 914, 1728, 1145, 1145, 913, 913, 913, 913, 913, + + 913, 1144, 726, 815, 55, 55, 803, 1146, 1728, 719, + 55, 716, 803, 1155, 1728, 1155, 1184, 914, 724, 917, + 917, 917, 917, 917, 917, 917, 899, 1156, 55, 1728, + 918, 53, 53, 1146, 1728, 53, 918, 918, 918, 918, + 918, 918, 919, 920, 920, 920, 920, 920, 920, 920, + 921, 1581, 790, 1156, 922, 1728, 923, 55, 55, 1157, + 922, 922, 922, 922, 922, 922, 1047, 1047, 1047, 1047, + 1047, 1047, 1047, 1158, 53, 55, 55, 53, 1157, 55, + 55, 772, 923, 733, 928, 928, 928, 928, 928, 928, + 928, 902, 1728, 1310, 1192, 929, 666, 55, 55, 1158, + + 470, 929, 929, 929, 929, 929, 929, 930, 931, 931, + 931, 931, 931, 931, 931, 932, 1311, 1490, 1728, 933, + 549, 934, 746, 719, 365, 933, 933, 933, 933, 933, + 933, 1167, 1168, 1168, 1168, 1168, 1168, 1168, 1170, 1171, + 1171, 1171, 1171, 1171, 1171, 1287, 55, 934, 744, 940, + 940, 940, 940, 940, 940, 940, 905, 545, 540, 1288, + 941, 735, 716, 726, 55, 1201, 941, 941, 941, 941, + 941, 941, 942, 943, 943, 943, 943, 943, 943, 943, + 944, 1202, 1203, 723, 945, 1288, 946, 55, 55, 55, + 945, 945, 945, 945, 945, 945, 1174, 1175, 1175, 1175, + + 1175, 1175, 1175, 634, 625, 55, 55, 55, 55, 1287, + 1289, 719, 946, 861, 957, 957, 957, 957, 957, 957, + 957, 863, 1193, 1728, 1290, 958, 55, 1544, 55, 55, + 1289, 958, 958, 958, 958, 958, 958, 959, 960, 960, + 960, 960, 960, 960, 1728, 1314, 55, 55, 961, 1728, + 1290, 55, 716, 55, 961, 961, 961, 961, 961, 961, + 55, 1188, 984, 984, 984, 984, 984, 984, 984, 55, + 1728, 55, 1602, 984, 1603, 55, 55, 55, 55, 984, + 984, 984, 984, 984, 984, 985, 985, 985, 985, 985, + 985, 985, 714, 55, 55, 55, 985, 1604, 55, 55, + + 55, 55, 985, 985, 985, 985, 985, 985, 619, 986, + 986, 986, 986, 986, 986, 986, 55, 55, 55, 55, + 987, 1610, 435, 625, 615, 1491, 987, 987, 987, 987, + 987, 987, 1196, 1198, 1229, 1230, 1230, 1230, 1230, 1230, + 1230, 1235, 1236, 1236, 1236, 1236, 1236, 1236, 435, 987, + 987, 987, 987, 987, 987, 987, 613, 703, 702, 701, + 987, 700, 55, 55, 55, 55, 987, 987, 987, 987, + 987, 987, 267, 988, 988, 988, 988, 988, 988, 988, + 55, 55, 55, 55, 989, 1624, 699, 1626, 1627, 1535, + 989, 989, 989, 989, 989, 989, 53, 989, 989, 989, + + 989, 989, 989, 989, 992, 993, 993, 993, 993, 993, + 993, 698, 697, 696, 695, 994, 694, 693, 55, 55, + 55, 994, 994, 994, 994, 994, 994, 724, 821, 821, + 821, 821, 821, 821, 821, 899, 55, 55, 55, 822, + 692, 685, 1642, 55, 1345, 822, 822, 822, 822, 822, + 822, 995, 996, 996, 996, 996, 996, 996, 1346, 1634, + 684, 55, 997, 683, 682, 55, 1643, 55, 997, 997, + 997, 997, 997, 997, 733, 833, 833, 833, 833, 833, + 833, 833, 902, 55, 1346, 55, 834, 681, 1644, 55, + 55, 1345, 834, 834, 834, 834, 834, 834, 998, 999, + + 999, 999, 999, 999, 999, 1728, 1635, 55, 55, 1000, + 680, 679, 1646, 678, 55, 1000, 1000, 1000, 1000, 1000, + 1000, 744, 848, 848, 848, 848, 848, 848, 848, 905, + 677, 1728, 55, 849, 676, 675, 55, 55, 1350, 849, + 849, 849, 849, 849, 849, 1001, 1002, 1002, 1002, 1002, + 1002, 1002, 1351, 1636, 55, 55, 1003, 1655, 55, 1657, + 674, 673, 1003, 1003, 1003, 1003, 1003, 1003, 1007, 1008, + 1008, 1008, 1008, 1008, 1008, 453, 55, 672, 1351, 1009, + 671, 1659, 55, 55, 55, 1009, 1009, 1009, 1009, 1009, + 1009, 910, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 912, + + 55, 55, 55, 1013, 670, 1661, 55, 669, 468, 1013, + 1013, 1013, 1013, 1013, 1013, 1014, 1015, 1015, 1015, 1015, + 1015, 1015, 453, 1669, 55, 1662, 1016, 666, 470, 55, + 464, 55, 1016, 1016, 1016, 1016, 1016, 1016, 919, 1024, + 1024, 1024, 1024, 1024, 1024, 1024, 921, 55, 1663, 55, + 1025, 551, 1672, 55, 55, 535, 1025, 1025, 1025, 1025, + 1025, 1025, 1026, 1027, 1027, 1027, 1027, 1027, 1027, 453, + 542, 55, 55, 1028, 634, 625, 1680, 1681, 55, 1028, + 1028, 1028, 1028, 1028, 1028, 930, 1039, 1039, 1039, 1039, + 1039, 1039, 1039, 932, 535, 625, 55, 1040, 619, 55, + + 55, 1686, 619, 1040, 1040, 1040, 1040, 1040, 1040, 1041, + 1042, 1042, 1042, 1042, 1042, 1042, 453, 55, 55, 612, + 1043, 1687, 611, 55, 55, 55, 1043, 1043, 1043, 1043, + 1043, 1043, 942, 1055, 1055, 1055, 1055, 1055, 1055, 1055, + 944, 55, 55, 55, 1056, 1693, 1690, 55, 55, 610, + 1056, 1056, 1056, 1056, 1056, 1056, 1057, 1058, 1058, 1058, + 1058, 1058, 1058, 453, 609, 55, 55, 1059, 608, 607, + 55, 1700, 55, 1059, 1059, 1059, 1059, 1059, 1059, 861, + 1066, 1066, 1066, 1066, 1066, 1066, 1066, 863, 55, 1694, + 55, 1067, 606, 605, 55, 1708, 55, 1067, 1067, 1067, + + 1067, 1067, 1067, 1068, 1069, 1069, 1069, 1069, 1069, 1069, + 1069, 1070, 55, 604, 55, 1071, 603, 1072, 602, 338, + 239, 1071, 1071, 1071, 1071, 1071, 1071, 1239, 1240, 1240, + 1240, 1240, 1240, 1240, 1245, 1246, 1246, 1246, 1246, 1246, + 1246, 55, 55, 1072, 55, 619, 1095, 1095, 1095, 1095, + 1095, 1095, 1095, 601, 600, 599, 598, 1096, 597, 55, + 55, 596, 55, 1096, 1096, 1096, 1096, 1096, 1096, 53, + 1096, 1096, 1096, 1096, 1096, 1096, 1096, 55, 267, 1097, + 1097, 1097, 1097, 1097, 1097, 1097, 1248, 1249, 1249, 1249, + 1249, 1249, 1249, 55, 55, 55, 910, 1100, 1100, 1100, + + 1100, 1100, 1100, 1100, 1101, 595, 594, 593, 1102, 592, + 914, 55, 55, 591, 1102, 1102, 1102, 1102, 1102, 1102, + 1252, 1253, 1253, 1253, 1253, 1253, 1253, 1259, 1260, 1260, + 1260, 1260, 1260, 1260, 55, 1710, 914, 919, 1103, 1103, + 1103, 1103, 1103, 1103, 1103, 1104, 590, 589, 581, 1105, + 578, 923, 55, 575, 574, 1105, 1105, 1105, 1105, 1105, + 1105, 1262, 1263, 1263, 1263, 1263, 1263, 1263, 1266, 1267, + 1267, 1267, 1267, 1267, 1267, 55, 1714, 923, 930, 1106, + 1106, 1106, 1106, 1106, 1106, 1106, 1107, 573, 572, 571, + 1108, 570, 934, 55, 569, 568, 1108, 1108, 1108, 1108, + + 1108, 1108, 1273, 1274, 1274, 1274, 1274, 1274, 1274, 1276, + 1277, 1277, 1277, 1277, 1277, 1277, 55, 55, 934, 942, + 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1110, 567, 566, + 470, 1111, 279, 946, 55, 55, 453, 1111, 1111, 1111, + 1111, 1111, 1111, 1280, 1281, 1281, 1281, 1281, 1281, 1281, + 1168, 1168, 1168, 1168, 1168, 1168, 1168, 365, 551, 946, + 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1115, 535, 542, + 453, 1116, 539, 450, 444, 55, 55, 1116, 1116, 1116, + 1116, 1116, 1116, 1117, 1118, 1118, 1118, 1118, 1118, 1118, + 1118, 1119, 55, 55, 55, 1120, 55, 1121, 55, 1350, + + 55, 1120, 1120, 1120, 1120, 1120, 1120, 1308, 1305, 535, + 55, 533, 444, 1728, 55, 436, 55, 55, 55, 430, + 520, 1303, 519, 1121, 910, 1124, 1124, 1124, 1124, 1124, + 1124, 1124, 1101, 1312, 1583, 55, 1125, 1402, 1717, 1728, + 55, 55, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1127, + 1127, 1127, 1127, 1127, 1127, 1127, 1128, 55, 55, 55, + 1129, 518, 1130, 517, 516, 55, 1129, 1129, 1129, 1129, + 1129, 1129, 1309, 1313, 515, 55, 1337, 1338, 1338, 1338, + 1338, 1338, 1338, 55, 1352, 55, 1307, 514, 1130, 919, + 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1104, 1353, 513, + + 1403, 1136, 512, 55, 511, 55, 510, 1136, 1136, 1136, + 1136, 1136, 1136, 1137, 1138, 1138, 1138, 1138, 1138, 1138, + 1138, 1139, 1405, 55, 1353, 1140, 509, 1141, 1352, 508, + 507, 1140, 1140, 1140, 1140, 1140, 1140, 1317, 506, 503, + 502, 499, 1728, 1246, 1246, 1246, 1246, 1246, 1246, 1246, + 498, 1358, 55, 1141, 930, 1147, 1147, 1147, 1147, 1147, + 1147, 1147, 1107, 497, 496, 1359, 1148, 495, 1728, 120, + 55, 494, 1148, 1148, 1148, 1148, 1148, 1148, 1149, 1150, + 1150, 1150, 1150, 1150, 1150, 1150, 1151, 1408, 1358, 1360, + 1152, 1359, 1153, 1360, 493, 481, 1152, 1152, 1152, 1152, + + 1152, 1152, 1728, 1361, 480, 479, 478, 1728, 1260, 1260, + 1260, 1260, 1260, 1260, 1260, 477, 1366, 55, 1153, 942, + 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1110, 1728, 1361, + 1367, 1160, 476, 1728, 475, 55, 474, 1160, 1160, 1160, + 1160, 1160, 1160, 1161, 1162, 1162, 1162, 1162, 1162, 1162, + 1162, 1163, 1475, 1366, 1368, 1164, 1367, 1165, 1368, 473, + 277, 1164, 1164, 1164, 1164, 1164, 1164, 1728, 1369, 470, + 279, 453, 1728, 1274, 1274, 1274, 1274, 1274, 1274, 1274, + 367, 1374, 55, 1165, 1068, 1176, 1176, 1176, 1176, 1176, + 1176, 1176, 1070, 1728, 1369, 1375, 1177, 450, 1728, 444, + + 55, 1374, 1177, 1177, 1177, 1177, 1177, 1177, 1178, 1179, + 1179, 1179, 1179, 1179, 1179, 1728, 444, 1547, 437, 1180, + 437, 1375, 55, 429, 55, 1180, 1180, 1180, 1180, 1180, + 1180, 55, 619, 1204, 1204, 1204, 1204, 1204, 1204, 1204, + 55, 1728, 55, 420, 989, 1715, 419, 1719, 416, 55, + 989, 989, 989, 989, 989, 989, 53, 989, 989, 989, + 989, 989, 989, 989, 55, 267, 1097, 1097, 1097, 1097, + 1097, 1097, 1097, 415, 55, 55, 1376, 1376, 55, 55, + 414, 1421, 55, 1207, 1208, 1208, 1208, 1208, 1208, 1208, + 1377, 1728, 55, 55, 1209, 1422, 55, 55, 1399, 413, + + 1209, 1209, 1209, 1209, 1209, 1209, 910, 1012, 1012, 1012, + 1012, 1012, 1012, 1012, 1101, 1400, 1377, 1728, 1013, 412, + 411, 1422, 410, 1421, 1013, 1013, 1013, 1013, 1013, 1013, + 1210, 1211, 1211, 1211, 1211, 1211, 1211, 1728, 409, 408, + 407, 1212, 406, 405, 404, 403, 55, 1212, 1212, 1212, + 1212, 1212, 1212, 919, 1024, 1024, 1024, 1024, 1024, 1024, + 1024, 1104, 402, 1728, 55, 1025, 401, 400, 395, 394, + 1468, 1025, 1025, 1025, 1025, 1025, 1025, 1213, 1214, 1214, + 1214, 1214, 1214, 1214, 1469, 1698, 393, 392, 1215, 391, + 320, 390, 389, 55, 1215, 1215, 1215, 1215, 1215, 1215, + + 930, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1107, 388, + 1469, 55, 1040, 387, 386, 385, 379, 1468, 1040, 1040, + 1040, 1040, 1040, 1040, 1216, 1217, 1217, 1217, 1217, 1217, + 1217, 1728, 1723, 279, 367, 1218, 275, 364, 272, 360, + 266, 1218, 1218, 1218, 1218, 1218, 1218, 942, 1055, 1055, + 1055, 1055, 1055, 1055, 1055, 1110, 260, 1728, 143, 1056, + 348, 347, 346, 341, 1470, 1056, 1056, 1056, 1056, 1056, + 1056, 1219, 1220, 1220, 1220, 1220, 1220, 1220, 1471, 320, + 340, 339, 1221, 338, 337, 336, 335, 334, 1221, 1221, + 1221, 1221, 1221, 1221, 1223, 1224, 1224, 1224, 1224, 1224, + + 1224, 1224, 1225, 333, 1471, 332, 1226, 331, 1227, 330, + 329, 328, 1226, 1226, 1226, 1226, 1226, 1226, 1382, 1383, + 1383, 1383, 1383, 1383, 1383, 1385, 1386, 1386, 1386, 1386, + 1386, 1386, 55, 327, 1227, 1117, 1231, 1231, 1231, 1231, + 1231, 1231, 1231, 1119, 326, 323, 322, 1232, 321, 320, + 55, 1406, 319, 1232, 1232, 1232, 1232, 1232, 1232, 1126, + 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1128, 1407, 318, + 317, 1242, 316, 315, 314, 313, 312, 1242, 1242, 1242, + 1242, 1242, 1242, 1137, 1254, 1254, 1254, 1254, 1254, 1254, + 1254, 1139, 311, 310, 309, 1255, 308, 307, 306, 305, + + 304, 1255, 1255, 1255, 1255, 1255, 1255, 1149, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1151, 303, 302, 301, 1269, + 300, 299, 298, 297, 143, 1269, 1269, 1269, 1269, 1269, + 1269, 1161, 1282, 1282, 1282, 1282, 1282, 1282, 1282, 1163, + 296, 295, 294, 1283, 293, 292, 291, 290, 289, 1283, + 1283, 1283, 1283, 1283, 1283, 1068, 1291, 1291, 1291, 1291, + 1291, 1291, 1291, 1070, 288, 287, 286, 1292, 285, 284, + 283, 282, 279, 1292, 1292, 1292, 1292, 1292, 1292, 1293, + 1294, 1294, 1294, 1294, 1294, 1294, 1294, 1295, 267, 272, + 259, 1296, 258, 1297, 55, 55, 1470, 1296, 1296, 1296, + + 1296, 1296, 1296, 1389, 1390, 1390, 1390, 1390, 1390, 1390, + 1728, 55, 55, 55, 257, 55, 55, 55, 256, 1297, + 55, 619, 525, 525, 525, 525, 525, 525, 525, 55, + 255, 1534, 1576, 55, 55, 55, 1728, 1506, 55, 1318, + 1319, 1319, 1319, 1319, 1319, 1319, 1320, 1397, 1410, 1660, + 1321, 1507, 1586, 254, 253, 55, 1321, 1321, 1321, 1321, + 1321, 1321, 1117, 1322, 1322, 1322, 1322, 1322, 1322, 1322, + 1323, 55, 55, 55, 1324, 252, 1121, 1507, 251, 250, + 1324, 1324, 1324, 1324, 1324, 1324, 247, 1480, 244, 55, + 55, 1427, 1428, 1428, 1428, 1428, 1428, 1428, 241, 240, + + 1398, 1411, 1121, 1126, 1325, 1325, 1325, 1325, 1325, 1325, + 1325, 1326, 239, 238, 235, 1327, 234, 1130, 233, 232, + 231, 1327, 1327, 1327, 1327, 1327, 1327, 1432, 1433, 1433, + 1433, 1433, 1433, 1433, 1435, 1436, 1436, 1436, 1436, 1436, + 1436, 230, 229, 1130, 1137, 1328, 1328, 1328, 1328, 1328, + 1328, 1328, 1329, 228, 227, 226, 1330, 225, 1141, 224, + 223, 222, 1330, 1330, 1330, 1330, 1330, 1330, 1441, 1442, + 1442, 1442, 1442, 1442, 1442, 1444, 1445, 1445, 1445, 1445, + 1445, 1445, 221, 220, 1141, 1149, 1331, 1331, 1331, 1331, + 1331, 1331, 1331, 1332, 216, 215, 205, 1333, 204, 1153, + + 203, 200, 199, 1333, 1333, 1333, 1333, 1333, 1333, 1450, + 1451, 1451, 1451, 1451, 1451, 1451, 1453, 1454, 1454, 1454, + 1454, 1454, 1454, 194, 193, 1153, 1161, 1334, 1334, 1334, + 1334, 1334, 1334, 1334, 1335, 192, 191, 190, 1336, 189, + 1165, 188, 187, 186, 1336, 1336, 1336, 1336, 1336, 1336, + 1459, 1460, 1460, 1460, 1460, 1460, 1460, 1462, 1463, 1463, + 1463, 1463, 1463, 1463, 1506, 55, 1165, 1223, 1339, 1339, + 1339, 1339, 1339, 1339, 1339, 1225, 185, 181, 1728, 1340, + 180, 179, 178, 55, 177, 1340, 1340, 1340, 1340, 1340, + 1340, 1117, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1323, + + 176, 1579, 175, 1348, 1728, 174, 173, 172, 171, 1348, + 1348, 1348, 1348, 1348, 1348, 1126, 1354, 1354, 1354, 1354, + 1354, 1354, 1354, 1326, 170, 169, 168, 1355, 167, 166, + 165, 160, 151, 1355, 1355, 1355, 1355, 1355, 1355, 1137, + 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1329, 150, 145, + 59, 1363, 47, 45, 1728, 1728, 1728, 1363, 1363, 1363, + 1363, 1363, 1363, 1149, 1370, 1370, 1370, 1370, 1370, 1370, + 1370, 1332, 1728, 1728, 1728, 1371, 1728, 1728, 1728, 1728, + 1728, 1371, 1371, 1371, 1371, 1371, 1371, 1161, 1378, 1378, + 1378, 1378, 1378, 1378, 1378, 1335, 1728, 1728, 1728, 1379, + + 1728, 1728, 1728, 1728, 1728, 1379, 1379, 1379, 1379, 1379, + 1379, 1293, 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1295, + 1728, 1728, 1728, 1392, 1728, 1728, 1728, 1728, 1728, 1392, + 1392, 1392, 1392, 1392, 1392, 1223, 1412, 1412, 1412, 1412, + 1412, 1412, 1412, 1413, 1728, 1728, 1728, 1414, 1728, 1227, + 1728, 1728, 1728, 1414, 1414, 1414, 1414, 1414, 1414, 1383, + 1383, 1383, 1383, 1383, 1383, 1383, 1500, 1501, 1501, 1501, + 1501, 1501, 1501, 1510, 55, 1227, 1117, 1231, 1231, 1231, + 1231, 1231, 1231, 1231, 1323, 1728, 1728, 1511, 1232, 1728, + 1728, 1728, 55, 1728, 1232, 1232, 1232, 1232, 1232, 1232, + + 1126, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1326, 1728, + 1580, 1728, 1242, 1511, 1728, 1728, 1728, 1728, 1242, 1242, + 1242, 1242, 1242, 1242, 1137, 1254, 1254, 1254, 1254, 1254, + 1254, 1254, 1329, 1728, 1728, 1728, 1255, 1728, 1728, 1728, + 1728, 1728, 1255, 1255, 1255, 1255, 1255, 1255, 1149, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1332, 1728, 1728, 1728, + 1269, 1728, 1728, 1728, 1728, 1728, 1269, 1269, 1269, 1269, + 1269, 1269, 1161, 1282, 1282, 1282, 1282, 1282, 1282, 1282, + 1335, 1728, 1728, 1728, 1283, 1728, 1728, 1728, 1728, 1728, + 1283, 1283, 1283, 1283, 1283, 1283, 1223, 1423, 1423, 1423, + + 1423, 1423, 1423, 1423, 1413, 1728, 1728, 1728, 1424, 1728, + 1728, 1728, 55, 1728, 1424, 1424, 1424, 1424, 1424, 1424, + 1293, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1295, 55, + 55, 55, 1473, 1728, 1510, 1728, 1728, 1728, 1473, 1473, + 1473, 1473, 1473, 1473, 1487, 55, 1728, 55, 1728, 55, + 1433, 1433, 1433, 1433, 1433, 1433, 1433, 1728, 1484, 1728, + 1728, 1488, 1514, 55, 1485, 1223, 1339, 1339, 1339, 1339, + 1339, 1339, 1339, 1413, 1728, 1548, 1515, 1340, 1728, 1728, + 1728, 1728, 1514, 1340, 1340, 1340, 1340, 1340, 1340, 1442, + 1442, 1442, 1442, 1442, 1442, 1442, 1728, 1518, 1518, 1728, + + 1728, 1728, 1515, 1451, 1451, 1451, 1451, 1451, 1451, 1451, + 1522, 1519, 1728, 1460, 1460, 1460, 1460, 1460, 1460, 1460, + 1522, 1728, 1728, 1728, 1523, 1526, 1527, 1527, 1527, 1527, + 1527, 1527, 1728, 55, 1728, 55, 55, 1519, 1728, 1529, + 1530, 1530, 1530, 1530, 1530, 1530, 55, 55, 55, 1728, + 1523, 55, 55, 55, 55, 1551, 1728, 1551, 55, 55, + 1728, 55, 1538, 1539, 55, 55, 55, 1543, 1728, 1552, + 55, 1728, 1728, 1540, 1541, 1542, 55, 55, 1728, 55, + 1728, 1545, 1553, 1554, 1554, 1554, 1554, 1554, 1554, 1728, + 1728, 1728, 1728, 1622, 1582, 1552, 1587, 1728, 1557, 1558, + + 1558, 1558, 1558, 1558, 1558, 1561, 1562, 1562, 1562, 1562, + 1562, 1562, 1565, 1566, 1566, 1566, 1566, 1566, 1566, 1569, + 1570, 1570, 1570, 1570, 1570, 1570, 1527, 1527, 1527, 1527, + 1527, 1527, 1527, 1573, 1573, 55, 55, 55, 1589, 1590, + 1590, 1590, 1590, 1590, 1590, 1728, 1728, 1574, 1728, 1728, + 1728, 1728, 1728, 55, 55, 55, 1728, 1728, 1728, 1728, + 1728, 1728, 1578, 1585, 1588, 1554, 1554, 1554, 1554, 1554, + 1554, 1554, 1728, 1574, 1728, 1558, 1558, 1558, 1558, 1558, + 1558, 1558, 1562, 1562, 1562, 1562, 1562, 1562, 1562, 1566, + 1566, 1566, 1566, 1566, 1566, 1566, 1570, 1570, 1570, 1570, + + 1570, 1570, 1570, 1598, 1599, 1599, 1599, 1599, 1599, 1599, + 55, 55, 1728, 55, 55, 55, 55, 55, 1590, 1590, + 1590, 1590, 1590, 1590, 1590, 55, 55, 1728, 55, 55, + 1605, 55, 55, 55, 55, 55, 1728, 1728, 1728, 1728, + 1728, 1728, 1611, 55, 55, 1601, 55, 1606, 55, 55, + 1607, 1608, 1609, 1612, 1599, 1599, 1599, 1599, 1599, 1599, + 1599, 55, 1620, 1628, 55, 55, 55, 55, 55, 55, + 1728, 55, 55, 1621, 55, 55, 55, 55, 1728, 55, + 1623, 1625, 55, 55, 1728, 1728, 55, 55, 1629, 55, + 55, 55, 55, 55, 55, 55, 1647, 1630, 1637, 1728, + + 55, 55, 1638, 1645, 55, 1633, 1641, 1639, 1728, 55, + 55, 1640, 55, 1648, 1649, 55, 1650, 1651, 1728, 55, + 55, 1728, 55, 55, 55, 55, 1652, 1728, 55, 1728, + 55, 55, 55, 55, 1728, 55, 1653, 55, 55, 1654, + 1728, 55, 55, 55, 1658, 1656, 1666, 1665, 1728, 55, + 55, 55, 1664, 55, 1670, 55, 1675, 55, 1667, 1668, + 1677, 55, 55, 55, 55, 1728, 1671, 55, 1673, 55, + 1674, 55, 55, 1676, 1728, 55, 55, 1728, 55, 55, + 55, 55, 55, 1678, 1728, 55, 55, 1728, 1682, 55, + 55, 55, 1683, 1728, 55, 1679, 55, 1685, 1684, 1688, + + 55, 1728, 1689, 55, 55, 1691, 55, 55, 1728, 55, + 1695, 1692, 55, 55, 55, 55, 1728, 1728, 55, 1696, + 1697, 55, 55, 1728, 55, 55, 1701, 55, 55, 1699, + 55, 55, 55, 55, 1704, 1702, 55, 55, 55, 1728, + 55, 1706, 1709, 1703, 1705, 55, 55, 55, 55, 55, + 55, 1728, 1707, 1728, 55, 55, 55, 1711, 1728, 1728, + 1728, 1728, 1728, 1716, 1712, 55, 55, 55, 55, 1728, + 1728, 1728, 1713, 1728, 1718, 1721, 1722, 55, 1728, 1728, + 1726, 1727, 1728, 1720, 1728, 1724, 1728, 1725, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 55, 46, 1728, 1728, 1728, + + 1728, 46, 46, 46, 64, 1728, 64, 64, 64, 64, + 64, 64, 64, 152, 1728, 152, 159, 159, 159, 271, + 271, 271, 280, 280, 280, 359, 359, 359, 362, 362, + 362, 363, 363, 363, 370, 370, 370, 368, 368, 368, + 374, 374, 374, 378, 1728, 378, 443, 443, 443, 448, + 448, 448, 449, 449, 449, 458, 458, 458, 462, 1728, + 462, 463, 463, 463, 372, 372, 1728, 1728, 372, 467, + 467, 467, 471, 471, 471, 362, 362, 362, 532, 532, + 532, 536, 536, 536, 537, 537, 537, 538, 538, 538, + 370, 370, 370, 543, 543, 543, 456, 456, 1728, 1728, + + 456, 548, 548, 548, 552, 552, 552, 556, 1728, 556, + 557, 557, 557, 561, 561, 561, 565, 1728, 565, 624, + 624, 624, 458, 458, 458, 632, 632, 632, 633, 633, + 633, 641, 641, 641, 645, 1728, 645, 648, 1728, 648, + 649, 649, 649, 653, 653, 653, 657, 1728, 657, 555, + 555, 1728, 1728, 555, 559, 559, 1728, 1728, 559, 663, + 663, 663, 667, 667, 667, 565, 565, 1728, 565, 537, + 537, 537, 713, 713, 713, 717, 717, 717, 720, 720, + 720, 721, 721, 721, 722, 722, 722, 727, 727, 727, + 639, 639, 1728, 1728, 639, 732, 732, 732, 736, 736, + + 736, 645, 645, 1728, 645, 647, 647, 1728, 1728, 647, + 648, 648, 1728, 648, 649, 649, 651, 651, 1728, 1728, + 651, 743, 743, 743, 747, 747, 747, 657, 657, 1728, + 657, 751, 1728, 751, 754, 1728, 754, 755, 755, 755, + 759, 759, 759, 763, 1728, 763, 802, 802, 802, 641, + 641, 641, 653, 653, 653, 813, 813, 813, 814, 814, + 814, 822, 822, 822, 826, 1728, 826, 829, 1728, 829, + 830, 830, 830, 834, 834, 834, 838, 1728, 838, 841, + 1728, 841, 844, 1728, 844, 845, 845, 845, 849, 849, + 849, 853, 1728, 853, 750, 1728, 1728, 750, 751, 751, + + 1728, 751, 753, 753, 1728, 1728, 753, 754, 754, 1728, + 754, 755, 755, 757, 757, 1728, 1728, 757, 860, 860, + 860, 864, 864, 864, 763, 763, 1728, 763, 53, 53, + 53, 1728, 53, 53, 721, 721, 721, 896, 896, 896, + 900, 900, 900, 903, 903, 903, 906, 906, 906, 907, + 907, 907, 908, 908, 908, 913, 913, 913, 820, 820, + 1728, 1728, 820, 918, 918, 918, 922, 922, 922, 826, + 826, 1728, 826, 828, 828, 1728, 1728, 828, 829, 829, + 1728, 829, 830, 830, 832, 832, 1728, 1728, 832, 929, + 929, 929, 933, 933, 933, 838, 838, 1728, 838, 840, + + 1728, 1728, 840, 841, 841, 1728, 841, 843, 843, 1728, + 1728, 843, 844, 844, 1728, 844, 845, 845, 847, 847, + 1728, 1728, 847, 941, 941, 941, 945, 945, 945, 853, + 853, 1728, 853, 947, 1728, 947, 950, 1728, 950, 953, + 1728, 953, 954, 954, 954, 958, 958, 958, 962, 1728, + 962, 53, 53, 53, 1728, 53, 53, 990, 990, 990, + 822, 822, 822, 834, 834, 834, 849, 849, 849, 1004, + 1004, 1004, 1005, 1005, 1005, 1013, 1013, 1013, 1017, 1728, + 1017, 1020, 1728, 1020, 1021, 1021, 1021, 1025, 1025, 1025, + 1029, 1728, 1029, 1032, 1728, 1032, 1035, 1728, 1035, 1036, + + 1036, 1036, 1040, 1040, 1040, 1044, 1728, 1044, 1045, 1728, + 1045, 1048, 1728, 1048, 1051, 1728, 1051, 1052, 1052, 1052, + 1056, 1056, 1056, 1060, 1728, 1060, 947, 1728, 947, 949, + 1728, 1728, 949, 950, 950, 1728, 950, 952, 952, 1728, + 1728, 952, 953, 953, 1728, 953, 954, 954, 956, 956, + 1728, 1728, 956, 1067, 1067, 1067, 1071, 1071, 1071, 962, + 962, 1728, 962, 53, 53, 53, 1728, 53, 53, 907, + 907, 907, 1098, 1098, 1098, 1102, 1102, 1102, 1105, 1105, + 1105, 1108, 1108, 1108, 1111, 1111, 1111, 1112, 1112, 1112, + 1120, 1120, 1120, 1011, 1011, 1728, 1728, 1011, 1125, 1125, + + 1125, 1129, 1129, 1129, 1017, 1017, 1728, 1017, 1019, 1019, + 1728, 1728, 1019, 1020, 1020, 1728, 1020, 1021, 1021, 1023, + 1023, 1728, 1728, 1023, 1136, 1136, 1136, 1140, 1140, 1140, + 1029, 1029, 1728, 1029, 1031, 1728, 1728, 1031, 1032, 1032, + 1728, 1032, 1034, 1034, 1728, 1728, 1034, 1035, 1035, 1728, + 1035, 1036, 1036, 1038, 1038, 1728, 1728, 1038, 1148, 1148, + 1148, 1152, 1152, 1152, 1044, 1044, 1728, 1044, 1045, 1728, + 1045, 1047, 1728, 1728, 1047, 1048, 1048, 1728, 1048, 1050, + 1050, 1728, 1728, 1050, 1051, 1051, 1728, 1051, 1052, 1052, + 1054, 1054, 1728, 1728, 1054, 1160, 1160, 1160, 1164, 1164, + + 1164, 1060, 1060, 1728, 1060, 1166, 1728, 1166, 1169, 1728, + 1169, 1172, 1728, 1172, 1173, 1173, 1173, 1177, 1177, 1177, + 1181, 1728, 1181, 53, 53, 53, 1728, 53, 53, 1205, + 1205, 1205, 1013, 1013, 1013, 1025, 1025, 1025, 1040, 1040, + 1040, 1056, 1056, 1056, 1222, 1222, 1222, 1228, 1228, 1228, + 1226, 1226, 1226, 1233, 1233, 1233, 1232, 1232, 1232, 1234, + 1728, 1234, 1237, 1728, 1237, 1238, 1238, 1238, 1243, 1243, + 1243, 1242, 1242, 1242, 1244, 1728, 1244, 1247, 1728, 1247, + 1250, 1728, 1250, 1251, 1251, 1251, 1256, 1256, 1256, 1255, + 1255, 1255, 1257, 1728, 1257, 1258, 1728, 1258, 1261, 1728, + + 1261, 1264, 1728, 1264, 1265, 1265, 1265, 1270, 1270, 1270, + 1269, 1269, 1269, 1271, 1728, 1271, 1272, 1728, 1272, 1275, + 1728, 1275, 1278, 1728, 1278, 1279, 1279, 1279, 1284, 1284, + 1284, 1283, 1283, 1283, 1285, 1728, 1285, 1166, 1728, 1166, + 1168, 1728, 1728, 1168, 1169, 1169, 1728, 1169, 1171, 1171, + 1728, 1728, 1171, 1172, 1172, 1728, 1172, 1173, 1173, 1175, + 1175, 1728, 1728, 1175, 1292, 1292, 1292, 1296, 1296, 1296, + 1181, 1181, 1728, 1181, 53, 53, 53, 1728, 53, 53, + 1112, 1112, 1112, 1324, 1324, 1324, 1327, 1327, 1327, 1330, + 1330, 1330, 1333, 1333, 1333, 1336, 1336, 1336, 1341, 1341, + + 1341, 1340, 1340, 1340, 1343, 1728, 1343, 1344, 1344, 1344, + 1230, 1230, 1728, 1728, 1230, 1348, 1348, 1348, 1349, 1349, + 1349, 1234, 1234, 1728, 1234, 1236, 1236, 1728, 1728, 1236, + 1237, 1237, 1728, 1237, 1238, 1238, 1240, 1240, 1728, 1728, + 1240, 1355, 1355, 1355, 1356, 1356, 1356, 1244, 1244, 1728, + 1244, 1246, 1728, 1728, 1246, 1247, 1247, 1728, 1247, 1249, + 1249, 1728, 1728, 1249, 1250, 1250, 1728, 1250, 1251, 1251, + 1253, 1253, 1728, 1728, 1253, 1363, 1363, 1363, 1364, 1364, + 1364, 1257, 1257, 1728, 1257, 1258, 1728, 1258, 1260, 1728, + 1728, 1260, 1261, 1261, 1728, 1261, 1263, 1263, 1728, 1728, + + 1263, 1264, 1264, 1728, 1264, 1265, 1265, 1267, 1267, 1728, + 1728, 1267, 1371, 1371, 1371, 1372, 1372, 1372, 1271, 1271, + 1728, 1271, 1272, 1728, 1272, 1274, 1728, 1728, 1274, 1275, + 1275, 1728, 1275, 1277, 1277, 1728, 1728, 1277, 1278, 1278, + 1728, 1278, 1279, 1279, 1281, 1281, 1728, 1728, 1281, 1379, + 1379, 1379, 1380, 1380, 1380, 1285, 1285, 1728, 1285, 1381, + 1728, 1381, 1384, 1728, 1384, 1387, 1728, 1387, 1388, 1388, + 1388, 1393, 1728, 1393, 1392, 1392, 1392, 1394, 1728, 1394, + 53, 53, 53, 1728, 53, 53, 1415, 1728, 1415, 1414, + 1414, 1414, 1416, 1728, 1416, 1232, 1232, 1232, 1417, 1728, + + 1417, 1242, 1242, 1242, 1418, 1728, 1418, 1255, 1255, 1255, + 1419, 1728, 1419, 1269, 1269, 1269, 1420, 1728, 1420, 1283, + 1283, 1283, 1338, 1338, 1728, 1728, 1338, 1424, 1424, 1424, + 1425, 1425, 1425, 370, 370, 370, 1343, 1343, 1728, 1343, + 1426, 1426, 1426, 1429, 1728, 1429, 1430, 1430, 1430, 1431, + 1431, 1431, 1434, 1728, 1434, 1437, 1728, 1437, 1438, 1438, + 1438, 1439, 1439, 1439, 1440, 1728, 1440, 1443, 1728, 1443, + 1446, 1728, 1446, 1447, 1447, 1447, 1448, 1448, 1448, 1449, + 1728, 1449, 1452, 1728, 1452, 1455, 1728, 1455, 1456, 1456, + 1456, 1457, 1457, 1457, 1458, 1728, 1458, 1461, 1728, 1461, + + 1464, 1728, 1464, 1465, 1465, 1465, 1466, 1466, 1466, 1381, + 1728, 1381, 1383, 1728, 1728, 1383, 1384, 1384, 1728, 1384, + 1386, 1386, 1728, 1728, 1386, 1387, 1387, 1728, 1387, 1388, + 1388, 1390, 1390, 1728, 1728, 1390, 1473, 1473, 1473, 1474, + 1728, 1474, 1394, 1394, 1728, 1394, 53, 53, 53, 1728, + 53, 53, 1492, 1492, 1492, 1340, 1340, 1340, 1494, 1728, + 1494, 1495, 1728, 1495, 1496, 1728, 1496, 1497, 1728, 1497, + 1498, 1728, 1498, 1499, 1728, 1499, 1502, 1728, 1502, 1503, + 1503, 1503, 1504, 1504, 1504, 1505, 1728, 1505, 1428, 1428, + 1728, 1728, 1428, 1429, 1429, 1728, 1429, 1430, 1430, 1508, + + 1728, 1508, 1433, 1728, 1728, 1433, 1434, 1434, 1728, 1434, + 1436, 1436, 1728, 1728, 1436, 1437, 1437, 1728, 1437, 1438, + 1438, 1512, 1728, 1512, 1440, 1728, 1440, 1442, 1728, 1728, + 1442, 1443, 1443, 1728, 1443, 1445, 1445, 1728, 1728, 1445, + 1446, 1446, 1728, 1446, 1447, 1447, 1516, 1728, 1516, 1449, + 1728, 1449, 1451, 1728, 1728, 1451, 1452, 1452, 1728, 1452, + 1454, 1454, 1728, 1728, 1454, 1455, 1455, 1728, 1455, 1456, + 1456, 1520, 1728, 1520, 1458, 1728, 1458, 1460, 1728, 1728, + 1460, 1461, 1461, 1728, 1461, 1463, 1463, 1728, 1728, 1463, + 1464, 1464, 1728, 1464, 1465, 1465, 1524, 1728, 1524, 1525, + + 1728, 1525, 1528, 1728, 1528, 1531, 1728, 1531, 1532, 1532, + 1532, 1533, 1728, 1533, 53, 53, 53, 1728, 53, 53, + 1550, 1728, 1550, 1426, 1728, 1426, 1431, 1728, 1431, 1439, + 1728, 1439, 1448, 1728, 1448, 1457, 1728, 1457, 1466, 1728, + 1466, 1501, 1501, 1728, 1728, 1501, 1502, 1502, 1728, 1502, + 1503, 1503, 1493, 1728, 1493, 1555, 1728, 1555, 1556, 1728, + 1556, 1559, 1728, 1559, 1560, 1728, 1560, 1563, 1728, 1563, + 1564, 1728, 1564, 1567, 1728, 1567, 1568, 1728, 1568, 1571, + 1728, 1571, 1527, 1728, 1728, 1527, 1530, 1530, 1728, 1728, + 1530, 1575, 1728, 1575, 1504, 1728, 1504, 1591, 1728, 1591, + + 1554, 1728, 1728, 1554, 1558, 1728, 1728, 1558, 1562, 1728, + 1728, 1562, 1566, 1728, 1728, 1566, 1570, 1728, 1728, 1570, + 1597, 1728, 1597, 1600, 1728, 1600, 1590, 1728, 1728, 1590, + 1614, 1728, 1614, 1615, 1728, 1615, 1616, 1728, 1616, 1617, + 1728, 1617, 1618, 1728, 1618, 1599, 1728, 1728, 1599, 1631, + 1728, 1631, 1632, 1728, 1632, 3, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728 } ; -static yyconst flex_int16_t yy_chk[7486] = +static yyconst flex_int16_t yy_chk[7910] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1855,820 +2009,867 @@ static yyconst flex_int16_t yy_chk[7486] = 7, 106, 7, 7, 9, 17, 17, 9, 138, 9, 9, 4, 19, 19, 24, 7, 27, 27, 138, 4, 15, 10, 9, 7, 10, 102, 10, 10, 24, 28, - 9, 34, 26, 1234, 28, 24, 26, 659, 94, 10, + 9, 34, 26, 1278, 28, 24, 26, 586, 94, 10, - 34, 94, 26, 659, 95, 26, 95, 10, 14, 14, + 34, 94, 26, 586, 95, 26, 95, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 102, 98, - 1237, 14, 14, 14, 98, 83, 14, 14, 14, 14, + 1279, 14, 14, 14, 98, 83, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 16, 83, 25, 16, 1240, 16, 16, 83, 129, - 29, 1243, 107, 25, 29, 252, 25, 107, 22, 16, + 14, 16, 83, 25, 16, 671, 16, 16, 83, 129, + 29, 671, 107, 25, 29, 252, 25, 107, 22, 16, 25, 22, 129, 22, 22, 103, 29, 16, 20, 20, 20, 20, 20, 20, 20, 20, 22, 134, 23, 252, - 23, 23, 20, 661, 22, 23, 661, 251, 35, 251, + 23, 23, 20, 673, 22, 23, 673, 251, 35, 251, 23, 30, 103, 30, 23, 134, 23, 103, 30, 30, - 35, 30, 35, 1246, 35, 30, 1250, 35, 20, 21, + 35, 30, 35, 1283, 35, 30, 1284, 35, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 32, - 32, 110, 21, 663, 110, 1251, 110, 136, 21, 21, + 32, 110, 21, 675, 110, 1285, 110, 136, 21, 21, 21, 21, 21, 21, 31, 32, 136, 31, 31, 32, - 31, 663, 31, 32, 31, 32, 31, 33, 36, 31, - 155, 33, 32, 36, 36, 37, 36, 36, 1252, 37, + 31, 675, 31, 32, 31, 32, 31, 33, 36, 31, + 155, 33, 32, 36, 36, 37, 36, 36, 710, 37, 33, 33, 163, 38, 33, 222, 33, 37, 39, 38, 39, 38, 37, 38, 37, 41, 155, 38, 222, 38, 38, 267, 267, 41, 39, 437, 437, 41, 163, 41, - 44, 39, 666, 44, 666, 44, 44, 62, 62, 62, + 44, 39, 397, 44, 710, 44, 44, 62, 62, 62, 62, 62, 62, 62, 274, 339, 63, 351, 44, 63, - 339, 63, 63, 410, 1253, 413, 44, 48, 48, 48, - 48, 48, 48, 48, 63, 1254, 410, 667, 48, 413, - 274, 667, 63, 351, 48, 48, 48, 48, 48, 48, - 49, 49, 49, 49, 49, 49, 49, 376, 439, 1258, - 446, 49, 284, 284, 284, 284, 1259, 49, 49, 49, + 339, 63, 63, 397, 410, 1292, 44, 48, 48, 48, + 48, 48, 48, 48, 63, 619, 619, 410, 48, 397, + 274, 680, 63, 351, 48, 48, 48, 48, 48, 48, + 49, 49, 49, 49, 49, 49, 49, 376, 439, 680, + 446, 49, 284, 284, 284, 284, 1296, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 466, 284, 376, 439, 50, 446, 452, 460, 466, - 1265, 50, 50, 50, 50, 50, 50, 52, 52, 52, + 1321, 50, 50, 50, 50, 50, 50, 52, 52, 52, 52, 52, 52, 52, 52, 54, 54, 54, 54, 54, - 54, 54, 486, 452, 460, 355, 54, 563, 563, 563, - 563, 486, 54, 54, 54, 54, 54, 54, 56, 355, - 1266, 56, 1273, 56, 56, 607, 607, 371, 372, 56, - 56, 56, 56, 56, 56, 56, 56, 520, 560, 1274, - 56, 371, 372, 1281, 56, 355, 56, 56, 56, 56, + 54, 54, 486, 452, 460, 355, 54, 1324, 413, 670, + 670, 486, 54, 54, 54, 54, 54, 54, 56, 355, + 672, 56, 413, 56, 56, 672, 1327, 371, 372, 56, + 56, 56, 56, 56, 56, 56, 56, 523, 563, 679, + 56, 371, 372, 679, 56, 355, 56, 56, 56, 56, 56, 56, 153, 488, 153, 153, 153, 153, 153, 153, - 153, 544, 488, 520, 560, 153, 615, 371, 372, 544, - 1282, 153, 153, 153, 153, 153, 153, 154, 154, 154, - 154, 154, 154, 154, 154, 554, 650, 658, 658, 154, + 153, 547, 488, 523, 563, 153, 627, 371, 372, 547, + 686, 153, 153, 153, 153, 153, 153, 154, 154, 154, + 154, 154, 154, 154, 154, 557, 662, 686, 1330, 154, - 618, 154, 615, 554, 650, 154, 154, 154, 154, 154, + 630, 154, 627, 557, 662, 154, 154, 154, 154, 154, 154, 266, 266, 266, 266, 266, 266, 266, 277, 277, - 277, 277, 277, 277, 277, 455, 618, 154, 156, 156, - 156, 156, 156, 156, 156, 156, 624, 631, 660, 455, - 156, 643, 684, 660, 677, 677, 156, 156, 156, 156, + 277, 277, 277, 277, 277, 455, 630, 154, 156, 156, + 156, 156, 156, 156, 156, 156, 587, 636, 1333, 455, + 156, 566, 566, 566, 566, 587, 156, 156, 156, 156, 156, 156, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 686, 624, 631, 157, 455, 1289, 643, 684, 1290, + 157, 684, 1336, 636, 157, 455, 643, 655, 684, 1340, 157, 157, 157, 157, 157, 157, 158, 158, 158, 158, 158, 158, 158, 158, 160, 160, 160, 160, 160, 160, - 160, 160, 707, 1294, 725, 160, 737, 686, 668, 740, - - 707, 160, 160, 160, 160, 160, 160, 162, 162, 162, - 162, 162, 162, 162, 162, 162, 668, 740, 1297, 162, - 725, 162, 737, 309, 742, 162, 162, 162, 162, 162, - 162, 309, 361, 361, 361, 361, 361, 361, 361, 1298, - 754, 456, 742, 524, 309, 743, 664, 162, 260, 260, - 260, 260, 260, 260, 260, 456, 664, 524, 754, 260, - 309, 741, 1302, 743, 1304, 260, 260, 260, 260, 260, - 260, 262, 262, 262, 262, 262, 262, 262, 662, 741, - 743, 456, 262, 524, 769, 772, 741, 662, 262, 262, + 160, 160, 643, 655, 678, 160, 678, 682, 1341, 682, + + 1342, 160, 160, 160, 160, 160, 160, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 687, 691, 691, 162, + 1343, 162, 1344, 309, 687, 162, 162, 162, 162, 162, + 162, 309, 361, 361, 361, 361, 361, 361, 361, 701, + 701, 456, 1348, 527, 309, 764, 676, 162, 260, 260, + 260, 260, 260, 260, 260, 456, 676, 527, 708, 260, + 309, 1349, 766, 764, 689, 260, 260, 260, 260, 260, + 260, 262, 262, 262, 262, 262, 262, 262, 588, 689, + 766, 456, 262, 527, 708, 749, 761, 588, 262, 262, 262, 262, 262, 262, 263, 263, 263, 263, 263, 263, - 263, 263, 265, 265, 265, 265, 265, 265, 265, 718, - 769, 772, 1310, 265, 775, 748, 752, 718, 749, 265, + 263, 263, 265, 265, 265, 265, 265, 265, 265, 674, + 805, 749, 761, 265, 1355, 1356, 1363, 772, 674, 265, 265, 265, 265, 265, 265, 268, 268, 268, 268, 268, - 268, 268, 268, 748, 752, 752, 749, 268, 748, 749, - 775, 781, 788, 268, 268, 268, 268, 268, 268, 270, + 268, 268, 268, 731, 742, 772, 805, 268, 1364, 1371, + 772, 731, 742, 268, 268, 268, 268, 268, 268, 270, 270, 270, 270, 270, 270, 270, 270, 273, 273, 273, - 273, 273, 273, 273, 273, 273, 823, 781, 788, 273, - 1311, 273, 1321, 1322, 823, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 859, 1372, 1379, 273, + 1380, 273, 1384, 1387, 859, 273, 273, 273, 273, 273, 273, 365, 365, 365, 365, 365, 365, 365, 436, 436, - 436, 436, 436, 436, 436, 551, 744, 273, 278, 278, - - 278, 278, 278, 278, 278, 278, 278, 1326, 1327, 551, - 278, 800, 755, 1331, 744, 669, 278, 278, 278, 278, - 278, 278, 279, 279, 279, 279, 279, 279, 279, 669, - 755, 744, 672, 279, 552, 551, 1334, 800, 1335, 279, - 279, 279, 279, 279, 279, 344, 672, 344, 552, 344, - 344, 464, 464, 464, 464, 464, 464, 464, 750, 344, - 1340, 344, 344, 555, 344, 349, 556, 349, 349, 349, - 349, 349, 349, 349, 552, 803, 750, 555, 349, 750, - 556, 759, 761, 761, 349, 349, 349, 349, 349, 349, - 350, 350, 350, 350, 350, 350, 350, 350, 1343, 759, - - 761, 803, 350, 555, 350, 1344, 556, 1349, 350, 350, + 436, 436, 436, 436, 436, 554, 683, 273, 278, 278, + + 278, 278, 278, 278, 278, 278, 278, 683, 1388, 554, + 278, 1392, 765, 779, 1394, 681, 278, 278, 278, 278, + 278, 278, 279, 279, 279, 279, 279, 279, 279, 681, + 765, 779, 685, 279, 555, 554, 779, 765, 1413, 279, + 279, 279, 279, 279, 279, 344, 685, 344, 555, 344, + 344, 464, 464, 464, 464, 464, 464, 464, 773, 344, + 690, 344, 344, 558, 344, 349, 559, 349, 349, 349, + 349, 349, 349, 349, 555, 690, 773, 558, 349, 773, + 559, 776, 1414, 787, 349, 349, 349, 349, 349, 349, + 350, 350, 350, 350, 350, 350, 350, 350, 1424, 776, + + 776, 787, 350, 558, 350, 1425, 559, 1429, 350, 350, 350, 350, 350, 350, 468, 468, 468, 468, 468, 468, - 468, 537, 537, 537, 537, 537, 537, 537, 626, 676, - 350, 352, 352, 352, 352, 352, 352, 352, 352, 676, - 1352, 1353, 626, 352, 815, 830, 753, 842, 627, 352, + 468, 540, 540, 540, 540, 540, 540, 540, 638, 688, + 350, 352, 352, 352, 352, 352, 352, 352, 352, 688, + 1430, 1434, 638, 352, 1437, 783, 774, 788, 639, 352, 352, 352, 352, 352, 352, 356, 356, 356, 356, 356, - 356, 356, 627, 830, 753, 842, 356, 753, 626, 831, - 815, 832, 356, 356, 356, 356, 356, 356, 357, 357, - 357, 357, 357, 357, 357, 357, 1358, 831, 627, 832, - 357, 846, 831, 902, 832, 1361, 357, 357, 357, 357, + 356, 356, 639, 783, 774, 788, 356, 774, 638, 784, + 783, 790, 356, 356, 356, 356, 356, 356, 357, 357, + 357, 357, 357, 357, 357, 357, 1438, 784, 639, 790, + 357, 808, 784, 811, 817, 1443, 357, 357, 357, 357, 357, 357, 358, 358, 358, 358, 358, 358, 358, 358, - 360, 360, 360, 360, 360, 360, 360, 846, 871, 902, - 1362, 360, 1370, 833, 835, 837, 871, 360, 360, 360, + 360, 360, 360, 360, 360, 360, 360, 808, 917, 811, + 817, 360, 1446, 791, 789, 795, 917, 360, 360, 360, 360, 360, 360, 364, 364, 364, 364, 364, 364, 364, - 364, 833, 835, 837, 364, 1386, 833, 835, 837, 838, + 364, 791, 789, 795, 364, 789, 824, 797, 797, 1447, 364, 364, 364, 364, 364, 364, 366, 366, 366, 366, - 366, 366, 366, 366, 366, 882, 1387, 838, 366, 914, - 1412, 840, 838, 882, 366, 366, 366, 366, 366, 366, - 367, 367, 367, 367, 367, 367, 367, 367, 894, 840, - 937, 367, 840, 1415, 924, 914, 894, 367, 367, 367, + 366, 366, 366, 366, 366, 797, 836, 839, 366, 851, + 866, 867, 824, 1452, 366, 366, 366, 366, 366, 366, + 367, 367, 367, 367, 367, 367, 367, 367, 866, 867, + 892, 367, 836, 839, 867, 851, 868, 367, 367, 367, 367, 367, 367, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 924, 1426, 1430, 373, 937, 924, 926, 921, - 927, 373, 373, 373, 373, 373, 373, 375, 375, 375, - 375, 375, 375, 375, 375, 375, 926, 921, 927, 375, - 921, 375, 1434, 940, 926, 375, 375, 375, 375, 375, - 375, 542, 542, 542, 542, 542, 542, 542, 546, 546, - 546, 546, 546, 546, 546, 1438, 1442, 375, 396, 940, - 943, 1450, 396, 946, 928, 396, 929, 634, 396, 635, + 373, 373, 1455, 1456, 868, 373, 892, 1461, 879, 868, + 869, 373, 373, 373, 373, 373, 373, 375, 375, 375, + 375, 375, 375, 375, 375, 375, 879, 879, 869, 375, + 692, 375, 1464, 869, 693, 375, 375, 375, 375, 375, + 375, 490, 646, 490, 692, 696, 490, 490, 693, 647, + 490, 490, 699, 928, 700, 490, 646, 375, 396, 696, + 1465, 928, 396, 647, 700, 396, 699, 650, 396, 651, 396, 396, 396, 396, 430, 430, 430, 430, 430, 430, - 430, 634, 928, 635, 929, 430, 943, 933, 1020, 946, + 430, 650, 646, 651, 1473, 430, 780, 871, 873, 647, - 675, 430, 430, 430, 430, 430, 430, 432, 432, 432, - 432, 432, 432, 432, 675, 933, 1020, 634, 432, 635, - 952, 959, 971, 1459, 432, 432, 432, 432, 432, 432, + 1502, 430, 430, 430, 430, 430, 430, 432, 432, 432, + 432, 432, 432, 432, 780, 871, 873, 650, 432, 651, + 871, 873, 948, 780, 432, 432, 432, 432, 432, 432, 433, 433, 433, 433, 433, 433, 433, 433, 435, 435, - 435, 435, 435, 435, 435, 1010, 952, 959, 971, 435, - 974, 986, 990, 1010, 1231, 435, 435, 435, 435, 435, - 435, 438, 438, 438, 438, 438, 438, 438, 438, 1218, - 1214, 638, 639, 438, 1207, 438, 974, 986, 990, 438, - 438, 438, 438, 438, 438, 638, 639, 646, 646, 646, - 646, 646, 646, 646, 648, 648, 648, 648, 648, 648, - - 648, 438, 440, 440, 440, 440, 440, 440, 440, 1002, - 1058, 638, 639, 440, 1028, 1023, 1026, 1206, 1058, 440, + 435, 435, 435, 435, 435, 1503, 1528, 1531, 948, 435, + 1555, 781, 880, 874, 888, 435, 435, 435, 435, 435, + 435, 438, 438, 438, 438, 438, 438, 438, 438, 781, + 880, 874, 888, 438, 1559, 438, 874, 880, 781, 438, + 438, 438, 438, 438, 438, 545, 545, 545, 545, 545, + 545, 545, 549, 549, 549, 549, 549, 549, 549, 767, + + 752, 438, 440, 440, 440, 440, 440, 440, 440, 960, + 940, 993, 996, 440, 752, 883, 1563, 767, 940, 440, 440, 440, 440, 440, 440, 441, 441, 441, 441, 441, - 441, 441, 1028, 1023, 1026, 1002, 441, 1023, 1026, 1048, - 1101, 1113, 441, 441, 441, 441, 441, 441, 442, 442, + 441, 441, 1567, 883, 767, 960, 441, 993, 996, 999, + 752, 883, 441, 441, 441, 441, 441, 441, 442, 442, 442, 442, 442, 442, 442, 442, 445, 445, 445, 445, - 445, 445, 445, 445, 445, 1048, 1101, 1113, 445, 1205, - 445, 1201, 1200, 1197, 445, 445, 445, 445, 445, 445, - 652, 652, 652, 652, 652, 652, 652, 700, 700, 700, - 700, 700, 700, 700, 1120, 1124, 445, 451, 451, 451, - - 451, 451, 451, 451, 451, 451, 1069, 1193, 1192, 451, - 1191, 451, 1120, 1124, 1069, 451, 451, 451, 451, 451, - 451, 705, 705, 705, 705, 705, 705, 705, 709, 709, - 709, 709, 709, 709, 709, 728, 745, 451, 457, 457, - 457, 457, 457, 457, 457, 457, 457, 1187, 1186, 728, - 457, 1130, 1183, 1133, 745, 1027, 457, 457, 457, 457, + 445, 445, 445, 445, 445, 999, 1571, 1591, 445, 1002, + 445, 1600, 1275, 1271, 445, 445, 445, 445, 445, 445, + 658, 658, 658, 658, 658, 658, 658, 660, 660, 660, + 660, 660, 660, 660, 973, 1002, 445, 451, 451, 451, + + 451, 451, 451, 451, 451, 451, 1066, 1270, 1269, 451, + 1265, 451, 973, 973, 1066, 451, 451, 451, 451, 451, + 451, 664, 664, 664, 664, 664, 664, 664, 724, 724, + 724, 724, 724, 724, 724, 753, 768, 451, 457, 457, + 457, 457, 457, 457, 457, 457, 457, 1264, 1261, 753, + 457, 1008, 1257, 1015, 768, 886, 457, 457, 457, 457, 457, 457, 459, 459, 459, 459, 459, 459, 459, 459, - 459, 745, 1179, 1027, 459, 728, 459, 1130, 1027, 1133, - 459, 459, 459, 459, 459, 459, 714, 714, 714, 714, - 714, 714, 714, 716, 716, 716, 716, 716, 716, 716, - - 729, 747, 459, 469, 469, 469, 469, 469, 469, 469, - 469, 469, 1178, 1136, 729, 469, 1139, 1177, 1173, 747, - 732, 469, 469, 469, 469, 469, 469, 470, 470, 470, - 470, 470, 470, 470, 732, 1081, 747, 1172, 470, 1136, - 729, 1169, 1139, 1081, 470, 470, 470, 470, 470, 470, - 518, 733, 518, 518, 518, 518, 518, 518, 518, 1093, - 732, 1166, 1142, 518, 1167, 733, 1119, 1093, 1165, 518, - 518, 518, 518, 518, 518, 519, 519, 519, 519, 519, - 519, 519, 519, 1164, 1119, 1160, 1119, 519, 1142, 519, - 1167, 733, 1159, 519, 519, 519, 519, 519, 519, 720, - - 720, 720, 720, 720, 720, 720, 726, 726, 726, 726, - 726, 726, 726, 783, 836, 519, 521, 521, 521, 521, - 521, 521, 521, 521, 1181, 1156, 1155, 783, 521, 1195, - 1220, 1229, 836, 1123, 521, 521, 521, 521, 521, 521, - 525, 525, 525, 525, 525, 525, 525, 525, 1220, 836, - 1181, 1123, 525, 783, 1154, 1195, 1123, 1229, 525, 525, - 525, 525, 525, 525, 526, 526, 526, 526, 526, 526, - 526, 526, 527, 527, 527, 527, 527, 527, 527, 1213, - 1257, 1150, 1148, 527, 1292, 1329, 1338, 1213, 1257, 527, - 527, 527, 527, 527, 527, 528, 528, 528, 528, 528, - - 528, 528, 528, 530, 530, 530, 530, 530, 530, 530, - 1292, 1329, 1338, 1347, 530, 1356, 1410, 1116, 1117, 1221, - 530, 530, 530, 530, 530, 530, 531, 531, 531, 531, - 531, 531, 531, 531, 531, 1116, 1117, 1221, 531, 1347, - 1118, 1356, 1410, 784, 531, 531, 531, 531, 531, 531, - 532, 532, 532, 532, 532, 532, 532, 784, 1118, 1116, - 1117, 532, 1147, 1222, 1144, 1143, 1140, 532, 532, 532, - 532, 532, 532, 536, 536, 536, 536, 536, 536, 536, - 536, 1222, 1118, 784, 536, 1137, 1134, 1223, 1224, 1121, - 536, 536, 536, 536, 536, 536, 538, 538, 538, 538, - - 538, 538, 538, 538, 538, 1223, 1224, 1121, 538, 1131, - 1127, 1224, 1306, 1115, 538, 538, 538, 538, 538, 538, - 539, 539, 539, 539, 539, 539, 539, 539, 1121, 1114, - 1306, 539, 1111, 1306, 1107, 1307, 1375, 539, 539, 539, - 539, 539, 539, 547, 547, 547, 547, 547, 547, 547, - 547, 547, 1264, 1307, 1375, 547, 1307, 1106, 1308, 1418, - 1264, 547, 547, 547, 547, 547, 547, 548, 548, 548, - 548, 548, 548, 548, 548, 1272, 1308, 1418, 548, 1424, - 1103, 1420, 1098, 1272, 548, 548, 548, 548, 548, 548, - 557, 557, 557, 557, 557, 557, 557, 557, 557, 1420, - - 1308, 1428, 557, 1432, 1436, 1424, 834, 756, 557, 557, - 557, 557, 557, 557, 559, 559, 559, 559, 559, 559, - 559, 559, 559, 746, 834, 756, 559, 1428, 559, 1432, - 1436, 841, 559, 559, 559, 559, 559, 559, 756, 834, - 1097, 746, 763, 763, 763, 763, 763, 763, 763, 841, - 791, 792, 839, 746, 559, 601, 601, 601, 601, 601, - 601, 601, 1440, 1280, 791, 792, 601, 1448, 841, 1447, - 839, 1280, 601, 601, 601, 601, 601, 601, 603, 603, - 603, 603, 603, 603, 603, 839, 1288, 1447, 1440, 603, - 791, 792, 1457, 1448, 1288, 603, 603, 603, 603, 603, - - 603, 604, 604, 604, 604, 604, 604, 604, 604, 606, - 606, 606, 606, 606, 606, 606, 1320, 1369, 1457, 1094, - 606, 1086, 1225, 1085, 1320, 1369, 606, 606, 606, 606, - 606, 606, 608, 608, 608, 608, 608, 608, 608, 608, - 1225, 1082, 1074, 1073, 608, 1070, 1063, 1062, 1059, 1225, - 608, 608, 608, 608, 608, 608, 609, 609, 609, 609, - 609, 609, 609, 609, 610, 610, 610, 610, 610, 610, - 610, 1416, 1054, 1053, 1050, 610, 1049, 1046, 1045, 1416, - 1042, 610, 610, 610, 610, 610, 610, 611, 611, 611, - 611, 611, 611, 611, 611, 614, 614, 614, 614, 614, - - 614, 614, 614, 614, 751, 795, 796, 614, 1039, 614, - 1036, 1032, 1015, 614, 614, 614, 614, 614, 614, 795, - 796, 1011, 751, 804, 804, 804, 804, 804, 804, 804, - 1004, 757, 1003, 806, 751, 614, 617, 617, 617, 617, - 617, 617, 617, 617, 617, 795, 796, 806, 617, 757, - 617, 922, 807, 810, 617, 617, 617, 617, 617, 617, - 1000, 757, 996, 995, 992, 988, 807, 810, 987, 922, - 922, 984, 811, 806, 905, 980, 617, 623, 623, 623, - 623, 623, 623, 623, 623, 623, 811, 922, 905, 623, - 979, 623, 807, 810, 906, 623, 623, 623, 623, 623, - - 623, 819, 819, 819, 819, 819, 819, 819, 906, 976, - 973, 972, 811, 909, 905, 910, 969, 623, 628, 628, - 628, 628, 628, 628, 628, 628, 628, 909, 965, 910, - 628, 964, 961, 1374, 906, 960, 628, 628, 628, 628, - 628, 628, 630, 630, 630, 630, 630, 630, 630, 630, - 630, 1374, 957, 909, 630, 910, 630, 953, 949, 1374, - 630, 630, 630, 630, 630, 630, 821, 821, 821, 821, - 821, 821, 821, 825, 825, 825, 825, 825, 825, 825, - 954, 920, 630, 640, 640, 640, 640, 640, 640, 640, - 640, 640, 948, 947, 954, 640, 944, 941, 938, 920, - - 935, 640, 640, 640, 640, 640, 640, 642, 642, 642, - 642, 642, 642, 642, 642, 642, 920, 934, 916, 642, - 954, 642, 915, 912, 908, 642, 642, 642, 642, 642, - 642, 864, 864, 864, 864, 864, 864, 864, 869, 869, - 869, 869, 869, 869, 869, 925, 917, 642, 653, 653, - 653, 653, 653, 653, 653, 653, 653, 907, 904, 899, - 653, 895, 887, 925, 917, 883, 653, 653, 653, 653, - 653, 653, 654, 654, 654, 654, 654, 654, 654, 917, - 925, 876, 872, 654, 867, 862, 861, 860, 955, 654, - 654, 654, 654, 654, 654, 657, 657, 657, 657, 657, - - 657, 657, 955, 857, 854, 850, 657, 918, 919, 923, - 828, 1022, 657, 657, 657, 657, 657, 657, 873, 873, - 873, 873, 873, 873, 873, 918, 919, 923, 955, 1022, - 657, 680, 824, 680, 680, 680, 680, 680, 680, 680, - 918, 919, 919, 923, 680, 817, 816, 1021, 1022, 1125, - 680, 680, 680, 680, 680, 680, 878, 878, 878, 878, - 878, 878, 878, 962, 963, 1021, 1305, 1125, 680, 681, - 681, 681, 681, 681, 681, 681, 681, 962, 963, 1021, - 813, 681, 1125, 809, 1305, 808, 805, 681, 681, 681, - 681, 681, 681, 880, 880, 880, 880, 880, 880, 880, - - 802, 1305, 801, 962, 963, 681, 682, 682, 682, 682, - 682, 682, 682, 884, 884, 884, 884, 884, 884, 884, - 890, 890, 890, 890, 890, 890, 890, 892, 892, 892, - 892, 892, 892, 892, 896, 896, 896, 896, 896, 896, - 896, 682, 683, 683, 683, 683, 683, 683, 683, 798, - 794, 793, 790, 683, 789, 786, 782, 779, 778, 683, - 683, 683, 683, 683, 683, 685, 685, 685, 685, 685, - 685, 685, 685, 687, 687, 687, 687, 687, 687, 687, - 687, 777, 776, 773, 770, 687, 767, 766, 739, 738, - 735, 687, 687, 687, 687, 687, 687, 688, 688, 688, - - 688, 688, 688, 688, 688, 690, 690, 690, 690, 690, - 690, 690, 731, 730, 727, 723, 690, 719, 712, 708, - 703, 698, 690, 690, 690, 690, 690, 690, 691, 691, - 691, 691, 691, 691, 691, 691, 691, 697, 696, 693, - 691, 689, 679, 678, 674, 966, 691, 691, 691, 691, - 691, 691, 692, 692, 692, 692, 692, 692, 692, 966, - 673, 671, 670, 692, 665, 655, 651, 645, 644, 692, - 692, 692, 692, 692, 692, 694, 694, 694, 694, 694, - 694, 694, 694, 694, 641, 966, 637, 694, 636, 633, - 632, 629, 967, 694, 694, 694, 694, 694, 694, 695, - - 695, 695, 695, 695, 695, 695, 967, 625, 622, 621, - 695, 620, 619, 616, 613, 612, 695, 695, 695, 695, - 695, 695, 699, 699, 699, 699, 699, 699, 699, 699, - 605, 602, 967, 699, 600, 596, 590, 589, 588, 699, - 699, 699, 699, 699, 699, 701, 701, 701, 701, 701, - 701, 701, 701, 701, 587, 583, 582, 701, 580, 579, - 578, 577, 576, 701, 701, 701, 701, 701, 701, 702, - 702, 702, 702, 702, 702, 702, 702, 575, 574, 573, - 702, 572, 571, 570, 569, 566, 702, 702, 702, 702, - 702, 702, 710, 710, 710, 710, 710, 710, 710, 710, - - 710, 565, 564, 562, 710, 561, 558, 553, 549, 545, - 710, 710, 710, 710, 710, 710, 711, 711, 711, 711, - 711, 711, 711, 711, 540, 535, 534, 711, 533, 529, - 523, 522, 517, 711, 711, 711, 711, 711, 711, 721, - 721, 721, 721, 721, 721, 721, 721, 721, 516, 515, - 514, 721, 513, 512, 511, 510, 509, 721, 721, 721, - 721, 721, 721, 722, 722, 722, 722, 722, 722, 722, - 722, 508, 507, 506, 722, 505, 503, 500, 499, 498, - 722, 722, 722, 722, 722, 722, 734, 734, 734, 734, - 734, 734, 734, 734, 734, 497, 496, 495, 734, 494, - - 492, 491, 490, 489, 734, 734, 734, 734, 734, 734, - 736, 736, 736, 736, 736, 736, 736, 736, 736, 487, - 485, 484, 736, 483, 736, 482, 481, 479, 736, 736, - 736, 736, 736, 736, 903, 903, 903, 903, 903, 903, - 903, 975, 975, 975, 975, 975, 975, 975, 977, 978, - 736, 758, 981, 758, 758, 758, 758, 758, 758, 758, - 478, 476, 977, 978, 758, 475, 981, 474, 1025, 758, - 758, 758, 758, 758, 758, 758, 760, 760, 760, 760, - 760, 760, 760, 471, 467, 463, 1025, 760, 977, 978, - 462, 461, 981, 760, 760, 760, 760, 760, 760, 762, - - 762, 762, 762, 762, 762, 762, 1025, 458, 454, 453, - 762, 450, 1373, 449, 448, 447, 762, 762, 762, 762, - 762, 762, 764, 764, 764, 764, 764, 764, 764, 764, - 1373, 444, 443, 434, 764, 431, 429, 428, 427, 1373, - 764, 764, 764, 764, 764, 764, 765, 765, 765, 765, - 765, 765, 765, 765, 768, 768, 768, 768, 768, 768, - 768, 768, 768, 426, 982, 425, 768, 424, 768, 423, - 422, 421, 768, 768, 768, 768, 768, 768, 982, 991, - 991, 991, 991, 991, 991, 991, 420, 419, 418, 417, - 1017, 993, 994, 416, 768, 771, 771, 771, 771, 771, - - 771, 771, 771, 771, 982, 993, 994, 771, 1017, 771, - 1372, 997, 998, 771, 771, 771, 771, 771, 771, 1017, - 414, 412, 411, 409, 408, 997, 998, 405, 1372, 404, - 402, 993, 994, 400, 399, 771, 774, 774, 774, 774, - 774, 774, 774, 774, 774, 398, 393, 1372, 774, 392, - 774, 997, 998, 391, 774, 774, 774, 774, 774, 774, - 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1008, 1008, 1008, - 1008, 1008, 1008, 1008, 389, 388, 774, 780, 780, 780, - 780, 780, 780, 780, 780, 780, 387, 386, 384, 780, - 379, 780, 378, 377, 374, 780, 780, 780, 780, 780, - - 780, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1051, 1051, - 1051, 1051, 1051, 1051, 1051, 1104, 370, 780, 785, 785, - 785, 785, 785, 785, 785, 785, 785, 368, 363, 1104, - 785, 362, 359, 354, 353, 1024, 785, 785, 785, 785, - 785, 785, 787, 787, 787, 787, 787, 787, 787, 787, - 787, 1018, 1019, 1024, 787, 1104, 787, 345, 343, 342, - 787, 787, 787, 787, 787, 787, 337, 1024, 335, 1018, - 1019, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1105, 1419, - 1018, 1019, 787, 797, 797, 797, 797, 797, 797, 797, - 797, 797, 1105, 333, 332, 797, 331, 1419, 330, 329, - - 328, 797, 797, 797, 797, 797, 797, 799, 799, 799, - 799, 799, 799, 799, 799, 799, 1419, 327, 1105, 799, - 325, 799, 324, 323, 318, 799, 799, 799, 799, 799, - 799, 1060, 1060, 1060, 1060, 1060, 1060, 1060, 1065, 1065, - 1065, 1065, 1065, 1065, 1065, 1108, 315, 799, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 314, 313, 1108, - 812, 310, 303, 302, 300, 299, 812, 812, 812, 812, - 812, 812, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 298, 296, 294, 814, 1108, 814, 293, 292, 290, - 814, 814, 814, 814, 814, 814, 1067, 1067, 1067, 1067, - - 1067, 1067, 1067, 1071, 1071, 1071, 1071, 1071, 1071, 1071, - 1109, 286, 814, 826, 826, 826, 826, 826, 826, 826, - 826, 826, 285, 283, 1109, 826, 280, 276, 275, 272, - 1151, 826, 826, 826, 826, 826, 826, 827, 827, 827, - 827, 827, 827, 827, 1151, 271, 269, 264, 827, 261, - 1109, 259, 258, 256, 827, 827, 827, 827, 827, 827, - 843, 1152, 843, 843, 843, 843, 843, 843, 843, 253, - 1151, 249, 245, 843, 243, 1152, 241, 240, 843, 843, - 843, 843, 843, 843, 843, 844, 844, 844, 844, 844, - 844, 844, 238, 237, 236, 235, 844, 234, 233, 232, - - 230, 1152, 844, 844, 844, 844, 844, 844, 845, 845, - 845, 845, 845, 845, 845, 845, 228, 226, 225, 223, - 845, 221, 845, 220, 218, 215, 845, 845, 845, 845, - 845, 845, 1077, 1077, 1077, 1077, 1077, 1077, 1077, 1079, - 1079, 1079, 1079, 1079, 1079, 1079, 214, 1157, 845, 847, - 847, 847, 847, 847, 847, 847, 213, 211, 209, 208, - 847, 1157, 205, 204, 202, 201, 847, 847, 847, 847, - 847, 847, 848, 848, 848, 848, 848, 848, 848, 848, - 200, 199, 198, 197, 848, 196, 195, 1157, 194, 193, - 848, 848, 848, 848, 848, 848, 849, 849, 849, 849, - - 849, 849, 849, 849, 851, 851, 851, 851, 851, 851, - 851, 192, 191, 190, 189, 851, 188, 187, 186, 185, - 183, 851, 851, 851, 851, 851, 851, 852, 852, 852, - 852, 852, 852, 852, 852, 852, 182, 179, 178, 852, - 177, 176, 175, 174, 1158, 852, 852, 852, 852, 852, - 852, 853, 853, 853, 853, 853, 853, 853, 1158, 173, - 172, 170, 853, 167, 166, 165, 164, 161, 853, 853, - 853, 853, 853, 853, 855, 855, 855, 855, 855, 855, - 855, 855, 855, 159, 1158, 150, 855, 149, 148, 147, - 146, 1161, 855, 855, 855, 855, 855, 855, 856, 856, - - 856, 856, 856, 856, 856, 1161, 145, 144, 142, 856, - 140, 139, 137, 135, 133, 856, 856, 856, 856, 856, - 856, 858, 858, 858, 858, 858, 858, 858, 858, 858, - 132, 1161, 131, 858, 130, 128, 127, 126, 1162, 858, - 858, 858, 858, 858, 858, 859, 859, 859, 859, 859, - 859, 859, 1162, 125, 124, 123, 859, 121, 119, 118, - 117, 116, 859, 859, 859, 859, 859, 859, 863, 863, - 863, 863, 863, 863, 863, 863, 115, 114, 1162, 863, - 113, 112, 111, 109, 108, 863, 863, 863, 863, 863, - 863, 865, 865, 865, 865, 865, 865, 865, 865, 865, - - 101, 100, 99, 865, 97, 96, 93, 92, 91, 865, - 865, 865, 865, 865, 865, 866, 866, 866, 866, 866, - 866, 866, 866, 90, 89, 88, 866, 87, 86, 85, - 84, 82, 866, 866, 866, 866, 866, 866, 874, 874, - 874, 874, 874, 874, 874, 874, 874, 81, 80, 79, - 874, 78, 77, 76, 75, 74, 874, 874, 874, 874, - 874, 874, 875, 875, 875, 875, 875, 875, 875, 875, - 73, 72, 71, 875, 70, 69, 67, 66, 65, 875, - 875, 875, 875, 875, 875, 885, 885, 885, 885, 885, - 885, 885, 885, 885, 51, 43, 42, 885, 40, 18, - - 11, 8, 3, 885, 885, 885, 885, 885, 885, 886, - 886, 886, 886, 886, 886, 886, 886, 0, 0, 0, - 886, 0, 0, 0, 0, 0, 886, 886, 886, 886, - 886, 886, 897, 897, 897, 897, 897, 897, 897, 897, - 897, 0, 0, 0, 897, 0, 0, 0, 0, 0, - 897, 897, 897, 897, 897, 897, 898, 898, 898, 898, - 898, 898, 898, 898, 0, 0, 0, 898, 0, 0, - 0, 0, 0, 898, 898, 898, 898, 898, 898, 911, - 911, 911, 911, 911, 911, 911, 911, 911, 0, 0, - 0, 911, 0, 0, 0, 0, 0, 911, 911, 911, - - 911, 911, 911, 913, 913, 913, 913, 913, 913, 913, - 913, 913, 0, 0, 0, 913, 0, 913, 0, 0, - 0, 913, 913, 913, 913, 913, 913, 1083, 1083, 1083, - 1083, 1083, 1083, 1083, 1089, 1089, 1089, 1089, 1089, 1089, - 1089, 0, 0, 913, 930, 930, 930, 930, 930, 930, - 930, 930, 930, 0, 0, 0, 0, 930, 0, 0, - 0, 0, 930, 930, 930, 930, 930, 930, 930, 931, - 931, 931, 931, 931, 931, 931, 931, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 1091, 1091, 1091, 1091, - 1091, 1091, 1091, 0, 0, 932, 936, 936, 936, 936, - - 936, 936, 936, 936, 936, 0, 0, 0, 936, 0, - 936, 0, 0, 0, 936, 936, 936, 936, 936, 936, - 1095, 1095, 1095, 1095, 1095, 1095, 1095, 1102, 1102, 1102, - 1102, 1102, 1102, 1102, 1122, 0, 936, 939, 939, 939, - 939, 939, 939, 939, 939, 939, 0, 1170, 1171, 939, - 0, 939, 1122, 0, 0, 939, 939, 939, 939, 939, - 939, 1170, 1171, 1122, 1145, 1145, 1145, 1145, 1145, 1145, - 1145, 0, 0, 0, 0, 1174, 0, 939, 942, 942, - 942, 942, 942, 942, 942, 942, 942, 1170, 1171, 1174, - 942, 0, 942, 0, 0, 1175, 942, 942, 942, 942, - - 942, 942, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1175, - 0, 0, 0, 0, 1184, 1174, 1185, 0, 942, 945, - 945, 945, 945, 945, 945, 945, 945, 945, 1184, 0, - 1185, 945, 0, 945, 0, 1175, 1188, 945, 945, 945, - 945, 945, 945, 1182, 1182, 1182, 1182, 1182, 1182, 1182, - 1188, 0, 0, 0, 1184, 0, 1185, 0, 1189, 945, - 950, 950, 950, 950, 950, 950, 950, 950, 0, 0, - 0, 950, 1189, 0, 0, 0, 1188, 950, 950, 950, - 950, 950, 950, 951, 951, 951, 951, 951, 951, 951, - 951, 951, 0, 0, 0, 951, 0, 951, 1189, 0, - - 1198, 951, 951, 951, 951, 951, 951, 1196, 1196, 1196, - 1196, 1196, 1196, 1196, 1198, 0, 0, 0, 0, 1199, - 0, 1202, 0, 951, 956, 956, 956, 956, 956, 956, - 956, 956, 956, 1199, 0, 1202, 956, 0, 0, 0, - 1198, 0, 956, 956, 956, 956, 956, 956, 958, 958, - 958, 958, 958, 958, 958, 958, 958, 0, 1203, 1199, - 958, 1202, 958, 0, 0, 0, 958, 958, 958, 958, - 958, 958, 1203, 1209, 1209, 1209, 1209, 1209, 1209, 1209, - 1211, 1211, 1211, 1211, 1211, 1211, 1211, 0, 958, 968, - 968, 968, 968, 968, 968, 968, 968, 968, 1203, 0, - - 0, 968, 0, 0, 0, 0, 0, 968, 968, 968, - 968, 968, 968, 970, 970, 970, 970, 970, 970, 970, - 970, 970, 0, 0, 0, 970, 0, 970, 0, 0, - 1247, 970, 970, 970, 970, 970, 970, 1215, 1215, 1215, - 1215, 1215, 1215, 1215, 1247, 0, 0, 0, 0, 0, - 0, 1248, 0, 970, 983, 983, 983, 983, 983, 983, - 983, 983, 983, 0, 0, 1248, 983, 0, 0, 0, - 1247, 1226, 983, 983, 983, 983, 983, 983, 985, 985, - 985, 985, 985, 985, 985, 985, 985, 1227, 0, 1226, - 985, 1248, 985, 0, 0, 0, 985, 985, 985, 985, - - 985, 985, 1226, 0, 0, 1227, 1255, 1255, 1255, 1255, - 1255, 1255, 1255, 0, 1295, 0, 1227, 0, 985, 999, - 999, 999, 999, 999, 999, 999, 999, 999, 1295, 0, - 0, 999, 0, 0, 0, 0, 0, 999, 999, 999, - 999, 999, 999, 1001, 1001, 1001, 1001, 1001, 1001, 1001, - 1001, 1001, 0, 0, 1295, 1001, 0, 1001, 0, 0, - 0, 1001, 1001, 1001, 1001, 1001, 1001, 1260, 1260, 1260, - 1260, 1260, 1260, 1260, 1262, 1262, 1262, 1262, 1262, 1262, - 1262, 1296, 0, 1001, 1013, 1013, 1013, 1013, 1013, 1013, - 1013, 1013, 1013, 0, 0, 1296, 1013, 0, 0, 0, - - 0, 1299, 1013, 1013, 1013, 1013, 1013, 1013, 1014, 1014, - 1014, 1014, 1014, 1014, 1014, 1299, 0, 0, 0, 1014, - 0, 1296, 0, 0, 0, 1014, 1014, 1014, 1014, 1014, - 1014, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, - 0, 1299, 0, 0, 1029, 0, 0, 0, 0, 1029, - 1029, 1029, 1029, 1029, 1029, 1029, 1030, 1030, 1030, 1030, - 1030, 1030, 1030, 1030, 1031, 1031, 1031, 1031, 1031, 1031, - 1031, 1031, 1031, 1268, 1268, 1268, 1268, 1268, 1268, 1268, - 0, 1300, 1031, 1033, 1033, 1033, 1033, 1033, 1033, 1033, - 0, 0, 0, 0, 1033, 1300, 0, 0, 0, 0, - - 1033, 1033, 1033, 1033, 1033, 1033, 1034, 1034, 1034, 1034, - 1034, 1034, 1034, 1034, 1034, 0, 0, 0, 1034, 0, - 0, 1300, 0, 1324, 1034, 1034, 1034, 1034, 1034, 1034, - 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1324, 0, 0, - 0, 1035, 0, 0, 0, 0, 0, 1035, 1035, 1035, - 1035, 1035, 1035, 1037, 1037, 1037, 1037, 1037, 1037, 1037, - 1037, 1037, 0, 1324, 0, 1037, 0, 0, 0, 0, - 1325, 1037, 1037, 1037, 1037, 1037, 1037, 1038, 1038, 1038, - 1038, 1038, 1038, 1038, 1325, 0, 0, 0, 1038, 0, - 0, 0, 0, 0, 1038, 1038, 1038, 1038, 1038, 1038, - - 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 0, - 1325, 0, 1040, 0, 0, 0, 0, 1332, 1040, 1040, - 1040, 1040, 1040, 1040, 1041, 1041, 1041, 1041, 1041, 1041, - 1041, 1332, 0, 0, 0, 1041, 0, 0, 0, 0, - 0, 1041, 1041, 1041, 1041, 1041, 1041, 1043, 1043, 1043, - 1043, 1043, 1043, 1043, 1043, 1043, 0, 1332, 0, 1043, - 0, 0, 0, 0, 1333, 1043, 1043, 1043, 1043, 1043, - 1043, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1333, 0, - 0, 0, 1044, 0, 0, 0, 0, 0, 1044, 1044, - 1044, 1044, 1044, 1044, 1047, 1047, 1047, 1047, 1047, 1047, - - 1047, 1047, 1047, 0, 1333, 0, 1047, 0, 1047, 0, - 0, 0, 1047, 1047, 1047, 1047, 1047, 1047, 1270, 1270, - 1270, 1270, 1270, 1270, 1270, 1276, 1276, 1276, 1276, 1276, - 1276, 1276, 1341, 0, 1047, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 0, 0, 1341, 1052, 0, 0, - 0, 0, 0, 1052, 1052, 1052, 1052, 1052, 1052, 1061, - 1061, 1061, 1061, 1061, 1061, 1061, 1061, 1061, 0, 0, - 0, 1061, 1341, 0, 0, 0, 0, 1061, 1061, 1061, - 1061, 1061, 1061, 1072, 1072, 1072, 1072, 1072, 1072, 1072, - 1072, 1072, 0, 0, 0, 1072, 0, 0, 0, 0, - - 0, 1072, 1072, 1072, 1072, 1072, 1072, 1084, 1084, 1084, - 1084, 1084, 1084, 1084, 1084, 1084, 0, 0, 0, 1084, - 0, 0, 0, 0, 0, 1084, 1084, 1084, 1084, 1084, - 1084, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, - 0, 0, 0, 1096, 0, 0, 0, 0, 0, 1096, - 1096, 1096, 1096, 1096, 1096, 1110, 1110, 1110, 1110, 1110, - 1110, 1110, 1110, 1110, 0, 0, 0, 1110, 0, 0, - 0, 0, 0, 1110, 1110, 1110, 1110, 1110, 1110, 1112, - 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 0, 0, - 0, 1112, 0, 1112, 0, 0, 0, 1112, 1112, 1112, - - 1112, 1112, 1112, 1278, 1278, 1278, 1278, 1278, 1278, 1278, - 1284, 1284, 1284, 1284, 1284, 1284, 1284, 0, 0, 1112, - 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1286, - 1286, 1286, 1286, 1286, 1286, 1286, 0, 1342, 1126, 1128, - 1128, 1128, 1128, 1128, 1128, 1128, 1128, 0, 0, 0, - 1128, 1342, 0, 0, 0, 0, 1128, 1128, 1128, 1128, - 1128, 1128, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, - 1129, 0, 0, 0, 1129, 0, 1129, 1342, 0, 0, - 1129, 1129, 1129, 1129, 1129, 1129, 1293, 1293, 1293, 1293, - 1293, 1293, 1293, 1318, 1318, 1318, 1318, 1318, 1318, 1318, - - 0, 0, 1129, 1132, 1132, 1132, 1132, 1132, 1132, 1132, - 1132, 1132, 0, 0, 0, 1132, 0, 1132, 0, 0, - 0, 1132, 1132, 1132, 1132, 1132, 1132, 1330, 1330, 1330, - 1330, 1330, 1330, 1330, 1339, 1339, 1339, 1339, 1339, 1339, - 1339, 1350, 0, 1132, 1135, 1135, 1135, 1135, 1135, 1135, - 1135, 1135, 1135, 0, 0, 1350, 1135, 0, 1135, 0, - 0, 1351, 1135, 1135, 1135, 1135, 1135, 1135, 1348, 1348, - 1348, 1348, 1348, 1348, 1348, 1351, 0, 0, 0, 0, - 1359, 1350, 1360, 0, 1135, 1138, 1138, 1138, 1138, 1138, - 1138, 1138, 1138, 1138, 1359, 0, 1360, 1138, 0, 1138, - - 0, 1351, 1384, 1138, 1138, 1138, 1138, 1138, 1138, 1357, - 1357, 1357, 1357, 1357, 1357, 1357, 1384, 0, 0, 0, - 1359, 0, 1360, 0, 0, 1138, 1141, 1141, 1141, 1141, - 1141, 1141, 1141, 1141, 1141, 0, 0, 0, 1141, 0, - 1141, 0, 1384, 0, 1141, 1141, 1141, 1141, 1141, 1141, - 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1367, 1367, 1367, - 1367, 1367, 1367, 1367, 1385, 0, 1141, 1146, 1146, 1146, - 1146, 1146, 1146, 1146, 1146, 1146, 0, 0, 1385, 1146, - 0, 0, 0, 0, 0, 1146, 1146, 1146, 1146, 1146, - 1146, 1153, 1153, 1153, 1153, 1153, 1153, 1153, 1153, 1153, - - 0, 0, 0, 1153, 1385, 0, 0, 0, 0, 1153, - 1153, 1153, 1153, 1153, 1153, 1163, 1163, 1163, 1163, 1163, - 1163, 1163, 1163, 1163, 0, 0, 0, 1163, 0, 0, - 0, 0, 0, 1163, 1163, 1163, 1163, 1163, 1163, 1176, - 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 0, 0, - 0, 1176, 0, 0, 0, 0, 0, 1176, 1176, 1176, - 1176, 1176, 1176, 1190, 1190, 1190, 1190, 1190, 1190, 1190, - 1190, 1190, 0, 0, 0, 1190, 0, 0, 0, 0, - 0, 1190, 1190, 1190, 1190, 1190, 1190, 1204, 1204, 1204, - 1204, 1204, 1204, 1204, 1204, 1204, 0, 0, 0, 1204, - - 0, 0, 0, 0, 0, 1204, 1204, 1204, 1204, 1204, - 1204, 1216, 1216, 1216, 1216, 1216, 1216, 1216, 1216, 1216, - 0, 0, 0, 1216, 0, 0, 0, 0, 0, 1216, - 1216, 1216, 1216, 1216, 1216, 1228, 1228, 1228, 1228, 1228, - 1228, 1228, 1228, 1228, 0, 0, 0, 1228, 0, 1228, - 0, 0, 0, 1228, 1228, 1228, 1228, 1228, 1228, 1390, - 1390, 1390, 1390, 1390, 1390, 1390, 1394, 1394, 1394, 1394, - 1394, 1394, 1394, 1413, 0, 1228, 1232, 1232, 1232, 1232, - 1232, 1232, 1232, 1232, 1232, 0, 0, 1413, 1232, 0, - 0, 0, 0, 0, 1232, 1232, 1232, 1232, 1232, 1232, - - 1235, 1235, 1235, 1235, 1235, 1235, 1235, 1235, 1235, 0, - 0, 0, 1235, 1413, 0, 0, 0, 0, 1235, 1235, - 1235, 1235, 1235, 1235, 1238, 1238, 1238, 1238, 1238, 1238, - 1238, 1238, 1238, 0, 0, 0, 1238, 0, 0, 0, - 0, 0, 1238, 1238, 1238, 1238, 1238, 1238, 1241, 1241, - 1241, 1241, 1241, 1241, 1241, 1241, 1241, 0, 0, 0, - 1241, 0, 0, 0, 0, 0, 1241, 1241, 1241, 1241, - 1241, 1241, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, - 1244, 0, 0, 0, 1244, 0, 0, 0, 0, 0, - 1244, 1244, 1244, 1244, 1244, 1244, 1249, 1249, 1249, 1249, - - 1249, 1249, 1249, 1249, 1249, 0, 0, 0, 1249, 0, - 0, 0, 0, 0, 1249, 1249, 1249, 1249, 1249, 1249, - 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 0, - 0, 0, 1301, 0, 0, 0, 0, 0, 1301, 1301, - 1301, 1301, 1301, 1301, 1309, 1309, 1309, 1309, 1309, 1309, - 1309, 1309, 1309, 0, 0, 0, 1309, 0, 0, 0, - 0, 0, 1309, 1309, 1309, 1309, 1309, 1309, 1398, 1398, - 1398, 1398, 1398, 1398, 1398, 1402, 1402, 1402, 1402, 1402, - 1402, 1402, 1406, 1406, 1406, 1406, 1406, 1406, 1406, 1411, - 1411, 1411, 1411, 1411, 1411, 1411, 1414, 1422, 1422, 1422, - - 1422, 1422, 1422, 1422, 0, 0, 0, 0, 0, 0, - 1414, 1425, 1425, 1425, 1425, 1425, 1425, 1425, 1429, 1429, - 1429, 1429, 1429, 1429, 1429, 1433, 1433, 1433, 1433, 1433, - 1433, 1433, 0, 0, 0, 0, 1414, 1437, 1437, 1437, - 1437, 1437, 1437, 1437, 1441, 1441, 1441, 1441, 1441, 1441, - 1441, 1444, 1444, 1444, 1444, 1444, 1444, 1444, 1449, 1449, - 1449, 1449, 1449, 1449, 1449, 1458, 1458, 1458, 1458, 1458, - 1458, 1458, 1470, 0, 0, 0, 0, 1470, 1470, 1470, - 1471, 0, 1471, 1471, 1471, 1471, 1471, 1471, 1471, 1472, - 0, 1472, 1473, 1473, 1473, 1474, 1474, 1474, 1475, 1475, - - 1475, 1476, 1476, 1476, 1477, 1477, 1477, 1478, 1478, 1478, - 1479, 1479, 1479, 1480, 1480, 1480, 1481, 1481, 1481, 1482, - 0, 1482, 1483, 1483, 1483, 1484, 1484, 1484, 1485, 1485, - 1485, 1486, 1486, 1486, 1487, 0, 1487, 1488, 1488, 1488, - 1489, 1489, 0, 0, 1489, 1490, 1490, 1490, 1491, 1491, - 1491, 1492, 1492, 1492, 1493, 1493, 1493, 1494, 1494, 1494, - 1495, 1495, 1495, 1496, 1496, 1496, 1497, 1497, 1497, 1498, - 1498, 1498, 1499, 1499, 0, 0, 1499, 1500, 1500, 1500, - 1501, 1501, 1501, 1502, 0, 1502, 1503, 1503, 1503, 1504, - 1504, 1504, 1505, 0, 1505, 1506, 1506, 1506, 1507, 1507, - - 1507, 1508, 1508, 1508, 1509, 1509, 1509, 1510, 1510, 1510, - 1511, 0, 1511, 1512, 0, 1512, 1513, 1513, 1513, 1514, - 1514, 1514, 1515, 0, 1515, 1516, 1516, 0, 0, 1516, - 1517, 1517, 0, 0, 1517, 1518, 1518, 1518, 1519, 1519, - 1519, 1520, 1520, 0, 1520, 1521, 1521, 1521, 1522, 1522, - 1522, 1523, 1523, 1523, 1524, 1524, 1524, 1525, 1525, 1525, - 1526, 1526, 1526, 1527, 1527, 1527, 1528, 1528, 0, 0, - 1528, 1529, 1529, 1529, 1530, 1530, 1530, 1531, 1531, 0, - 1531, 1532, 1532, 0, 0, 1532, 1533, 1533, 0, 1533, - 1534, 1534, 1535, 1535, 0, 0, 1535, 1536, 1536, 1536, - - 1537, 1537, 1537, 1538, 1538, 0, 1538, 1539, 0, 1539, - 1540, 0, 1540, 1541, 1541, 1541, 1542, 1542, 1542, 1543, - 0, 1543, 1544, 1544, 1544, 1545, 1545, 1545, 1546, 1546, - 1546, 1547, 1547, 1547, 1548, 1548, 1548, 1549, 1549, 1549, - 1550, 0, 1550, 1551, 0, 1551, 1552, 1552, 1552, 1553, - 1553, 1553, 1554, 0, 1554, 1555, 0, 1555, 1556, 0, - 1556, 1557, 1557, 1557, 1558, 1558, 1558, 1559, 0, 1559, - 1560, 0, 0, 1560, 1561, 1561, 0, 1561, 1562, 1562, - 0, 0, 1562, 1563, 1563, 0, 1563, 1564, 1564, 1565, - 1565, 0, 0, 1565, 1566, 1566, 1566, 1567, 1567, 1567, - - 1568, 1568, 0, 1568, 1569, 1569, 1569, 0, 1569, 1569, - 1570, 1570, 1570, 1571, 1571, 1571, 1572, 1572, 1572, 1573, - 1573, 1573, 1574, 1574, 1574, 1575, 1575, 1575, 1576, 1576, - 1576, 1577, 1577, 1577, 1578, 1578, 0, 0, 1578, 1579, - 1579, 1579, 1580, 1580, 1580, 1581, 1581, 0, 1581, 1582, - 1582, 0, 0, 1582, 1583, 1583, 0, 1583, 1584, 1584, - 1585, 1585, 0, 0, 1585, 1586, 1586, 1586, 1587, 1587, - 1587, 1588, 1588, 0, 1588, 1589, 0, 0, 1589, 1590, - 1590, 0, 1590, 1591, 1591, 0, 0, 1591, 1592, 1592, - 0, 1592, 1593, 1593, 1594, 1594, 0, 0, 1594, 1595, - - 1595, 1595, 1596, 1596, 1596, 1597, 1597, 0, 1597, 1598, - 0, 1598, 1599, 0, 1599, 1600, 0, 1600, 1601, 1601, - 1601, 1602, 1602, 1602, 1603, 0, 1603, 1604, 1604, 1604, - 0, 1604, 1604, 1605, 1605, 1605, 1606, 1606, 1606, 1607, - 1607, 1607, 1608, 1608, 1608, 1609, 1609, 1609, 1610, 1610, - 1610, 1611, 1611, 1611, 1612, 0, 1612, 1613, 0, 1613, - 1614, 1614, 1614, 1615, 1615, 1615, 1616, 0, 1616, 1617, - 0, 1617, 1618, 0, 1618, 1619, 1619, 1619, 1620, 1620, - 1620, 1621, 0, 1621, 1622, 0, 1622, 1623, 0, 1623, - 1624, 0, 1624, 1625, 1625, 1625, 1626, 1626, 1626, 1627, - - 0, 1627, 1628, 0, 1628, 1629, 0, 0, 1629, 1630, - 1630, 0, 1630, 1631, 1631, 0, 0, 1631, 1632, 1632, - 0, 1632, 1633, 1633, 1634, 1634, 0, 0, 1634, 1635, - 1635, 1635, 1636, 1636, 1636, 1637, 1637, 0, 1637, 1638, - 1638, 1638, 0, 1638, 1638, 1639, 1639, 1639, 1640, 1640, - 1640, 1641, 1641, 1641, 1642, 1642, 1642, 1643, 1643, 1643, - 1644, 1644, 1644, 1645, 1645, 1645, 1646, 1646, 1646, 1647, - 1647, 0, 0, 1647, 1648, 1648, 1648, 1649, 1649, 1649, - 1650, 1650, 0, 1650, 1651, 1651, 0, 0, 1651, 1652, - 1652, 0, 1652, 1653, 1653, 1654, 1654, 0, 0, 1654, - - 1655, 1655, 1655, 1656, 1656, 1656, 1657, 1657, 0, 1657, - 1658, 0, 0, 1658, 1659, 1659, 0, 1659, 1660, 1660, - 0, 0, 1660, 1661, 1661, 0, 1661, 1662, 1662, 1663, - 1663, 0, 0, 1663, 1664, 1664, 1664, 1665, 1665, 1665, - 1666, 1666, 0, 1666, 1667, 0, 1667, 1668, 0, 0, - 1668, 1669, 1669, 0, 1669, 1670, 1670, 0, 0, 1670, - 1671, 1671, 0, 1671, 1672, 1672, 1673, 1673, 0, 0, - 1673, 1674, 1674, 1674, 1675, 1675, 1675, 1676, 1676, 0, - 1676, 1677, 0, 1677, 1678, 0, 1678, 1679, 0, 1679, - 1680, 1680, 1680, 1681, 1681, 1681, 1682, 0, 1682, 1683, - - 1683, 1683, 0, 1683, 1683, 1684, 1684, 1684, 1685, 1685, - 1685, 1686, 1686, 1686, 1687, 1687, 1687, 1688, 1688, 1688, - 1689, 1689, 1689, 1690, 1690, 1690, 1691, 1691, 1691, 1692, - 1692, 1692, 1693, 1693, 1693, 1694, 0, 1694, 1695, 0, - 1695, 1696, 1696, 1696, 1697, 1697, 1697, 1698, 1698, 1698, - 1699, 0, 1699, 1700, 0, 1700, 1701, 0, 1701, 1702, - 1702, 1702, 1703, 1703, 1703, 1704, 1704, 1704, 1705, 0, - 1705, 1706, 0, 1706, 1707, 0, 1707, 1708, 0, 1708, - 1709, 1709, 1709, 1710, 1710, 1710, 1711, 1711, 1711, 1712, - 0, 1712, 1713, 0, 1713, 1714, 0, 1714, 1715, 0, - - 1715, 1716, 1716, 1716, 1717, 1717, 1717, 1718, 1718, 1718, - 1719, 0, 1719, 1720, 0, 1720, 1721, 0, 0, 1721, - 1722, 1722, 0, 1722, 1723, 1723, 0, 0, 1723, 1724, - 1724, 0, 1724, 1725, 1725, 1726, 1726, 0, 0, 1726, - 1727, 1727, 1727, 1728, 1728, 1728, 1729, 1729, 0, 1729, - 1730, 1730, 1730, 0, 1730, 1730, 1731, 1731, 1731, 1732, - 1732, 1732, 1733, 1733, 1733, 1734, 1734, 1734, 1735, 1735, - 1735, 1736, 1736, 1736, 1737, 1737, 1737, 1738, 1738, 1738, - 1739, 0, 1739, 1740, 1740, 1740, 1741, 1741, 0, 0, - 1741, 1742, 1742, 1742, 1743, 1743, 1743, 1744, 1744, 0, - - 1744, 1745, 1745, 0, 0, 1745, 1746, 1746, 0, 1746, - 1747, 1747, 1748, 1748, 0, 0, 1748, 1749, 1749, 1749, - 1750, 1750, 1750, 1751, 1751, 0, 1751, 1752, 0, 0, - 1752, 1753, 1753, 0, 1753, 1754, 1754, 0, 0, 1754, - 1755, 1755, 0, 1755, 1756, 1756, 1757, 1757, 0, 0, - 1757, 1758, 1758, 1758, 1759, 1759, 1759, 1760, 1760, 0, - 1760, 1761, 0, 1761, 1762, 0, 0, 1762, 1763, 1763, - 0, 1763, 1764, 1764, 0, 0, 1764, 1765, 1765, 0, - 1765, 1766, 1766, 1767, 1767, 0, 0, 1767, 1768, 1768, - 1768, 1769, 1769, 1769, 1770, 1770, 0, 1770, 1771, 0, - - 1771, 1772, 0, 0, 1772, 1773, 1773, 0, 1773, 1774, - 1774, 0, 0, 1774, 1775, 1775, 0, 1775, 1776, 1776, - 1777, 1777, 0, 0, 1777, 1778, 1778, 1778, 1779, 1779, - 1779, 1780, 1780, 0, 1780, 1781, 0, 1781, 1782, 0, - 1782, 1783, 0, 1783, 1784, 1784, 1784, 1785, 0, 1785, - 1786, 1786, 1786, 1787, 0, 1787, 1788, 1788, 1788, 0, - 1788, 1788, 1789, 0, 1789, 1790, 1790, 1790, 1791, 0, - 1791, 1792, 1792, 1792, 1793, 0, 1793, 1794, 1794, 1794, - 1795, 0, 1795, 1796, 1796, 1796, 1797, 0, 1797, 1798, - 1798, 1798, 1799, 0, 1799, 1800, 1800, 1800, 1801, 1801, - - 0, 0, 1801, 1802, 1802, 1802, 1803, 1803, 1803, 1804, - 1804, 1804, 1805, 1805, 0, 1805, 1806, 1806, 1806, 1807, - 0, 1807, 1808, 1808, 1808, 1809, 1809, 1809, 1810, 0, - 1810, 1811, 0, 1811, 1812, 1812, 1812, 1813, 1813, 1813, - 1814, 0, 1814, 1815, 0, 1815, 1816, 0, 1816, 1817, - 1817, 1817, 1818, 1818, 1818, 1819, 0, 1819, 1820, 0, - 1820, 1821, 0, 1821, 1822, 1822, 1822, 1823, 1823, 1823, - 1824, 0, 1824, 1825, 0, 1825, 1826, 0, 1826, 1827, - 1827, 1827, 1828, 1828, 1828, 1829, 0, 1829, 1830, 0, - 0, 1830, 1831, 1831, 0, 1831, 1832, 1832, 0, 0, - - 1832, 1833, 1833, 0, 1833, 1834, 1834, 1835, 1835, 0, - 0, 1835, 1836, 1836, 1836, 1837, 0, 1837, 1838, 1838, - 0, 1838, 1839, 1839, 1839, 0, 1839, 1839, 1840, 1840, - 1840, 1841, 1841, 1841, 1842, 0, 1842, 1843, 0, 1843, - 1844, 0, 1844, 1845, 0, 1845, 1846, 0, 1846, 1847, - 0, 1847, 1848, 0, 1848, 1849, 1849, 1849, 1850, 1850, - 1850, 1851, 0, 1851, 1852, 1852, 0, 0, 1852, 1853, - 1853, 0, 1853, 1854, 1854, 1855, 0, 1855, 1856, 0, - 0, 1856, 1857, 1857, 0, 1857, 1858, 1858, 0, 0, - 1858, 1859, 1859, 0, 1859, 1860, 1860, 1861, 0, 1861, - - 1862, 0, 1862, 1863, 0, 0, 1863, 1864, 1864, 0, - 1864, 1865, 1865, 0, 0, 1865, 1866, 1866, 0, 1866, - 1867, 1867, 1868, 0, 1868, 1869, 0, 1869, 1870, 0, - 0, 1870, 1871, 1871, 0, 1871, 1872, 1872, 0, 0, - 1872, 1873, 1873, 0, 1873, 1874, 1874, 1875, 0, 1875, - 1876, 0, 1876, 1877, 0, 0, 1877, 1878, 1878, 0, - 1878, 1879, 1879, 0, 0, 1879, 1880, 1880, 0, 1880, - 1881, 1881, 1882, 0, 1882, 1883, 0, 1883, 1884, 0, - 1884, 1885, 0, 1885, 1886, 1886, 1886, 1887, 0, 1887, - 1888, 1888, 1888, 0, 1888, 1888, 1889, 0, 1889, 1890, - - 0, 1890, 1891, 0, 1891, 1892, 0, 1892, 1893, 0, - 1893, 1894, 0, 1894, 1895, 0, 1895, 1896, 1896, 0, - 0, 1896, 1897, 1897, 0, 1897, 1898, 1898, 1899, 0, - 1899, 1900, 0, 1900, 1901, 0, 1901, 1902, 0, 1902, - 1903, 0, 1903, 1904, 0, 1904, 1905, 0, 1905, 1906, - 0, 1906, 1907, 0, 1907, 1908, 0, 1908, 1909, 0, - 0, 1909, 1910, 1910, 0, 0, 1910, 1911, 0, 1911, - 1912, 0, 1912, 1913, 0, 1913, 1914, 0, 0, 1914, - 1915, 0, 0, 1915, 1916, 0, 0, 1916, 1917, 0, - 0, 1917, 1918, 0, 0, 1918, 1919, 0, 1919, 1920, - - 0, 1920, 1921, 0, 0, 1921, 1922, 0, 1922, 1923, - 0, 1923, 1924, 0, 1924, 1925, 0, 1925, 1926, 0, - 1926, 1927, 0, 0, 1927, 1928, 0, 1928, 1929, 0, - 1929, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, - 1469, 1469, 1469, 1469, 1469 + 459, 768, 1256, 886, 459, 753, 459, 1008, 886, 1015, + 459, 459, 459, 459, 459, 459, 729, 729, 729, 729, + 729, 729, 729, 733, 733, 733, 733, 733, 733, 733, + + 756, 769, 459, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 1255, 1027, 756, 469, 1251, 975, 1250, 769, + 757, 469, 469, 469, 469, 469, 469, 470, 470, 470, + 470, 470, 470, 470, 757, 975, 769, 1247, 470, 1027, + 756, 785, 975, 876, 470, 470, 470, 470, 470, 470, + 521, 819, 521, 521, 521, 521, 521, 521, 521, 785, + 757, 876, 1244, 521, 876, 819, 972, 967, 785, 521, + 521, 521, 521, 521, 521, 522, 522, 522, 522, 522, + 522, 522, 522, 1243, 972, 967, 1242, 522, 967, 522, + 1238, 819, 972, 522, 522, 522, 522, 522, 522, 738, + + 738, 738, 738, 738, 738, 738, 740, 740, 740, 740, + 740, 740, 740, 771, 777, 522, 524, 524, 524, 524, + 524, 524, 524, 524, 1030, 1124, 1237, 1042, 524, 1046, + 1058, 771, 777, 1124, 524, 524, 524, 524, 524, 524, + 528, 528, 528, 528, 528, 528, 528, 528, 771, 1135, + 1030, 777, 528, 1042, 1114, 1046, 1058, 1135, 528, 528, + 528, 528, 528, 528, 529, 529, 529, 529, 529, 529, + 529, 529, 530, 530, 530, 530, 530, 530, 530, 1147, + 1114, 1234, 1233, 530, 1167, 1179, 1208, 1147, 1232, 530, + 530, 530, 530, 530, 530, 531, 531, 531, 531, 531, + + 531, 531, 531, 533, 533, 533, 533, 533, 533, 533, + 1167, 1179, 1208, 1211, 533, 1228, 1226, 970, 974, 977, + 533, 533, 533, 533, 533, 533, 534, 534, 534, 534, + 534, 534, 534, 534, 534, 970, 974, 977, 534, 1211, + 970, 974, 977, 820, 534, 534, 534, 534, 534, 534, + 535, 535, 535, 535, 535, 535, 535, 820, 1159, 1225, + 1214, 535, 1222, 976, 978, 1221, 1159, 535, 535, 535, + 535, 535, 535, 539, 539, 539, 539, 539, 539, 539, + 539, 976, 978, 820, 539, 978, 1214, 979, 981, 976, + 539, 539, 539, 539, 539, 539, 541, 541, 541, 541, + + 541, 541, 541, 541, 541, 979, 981, 979, 541, 1218, + 983, 981, 984, 1215, 541, 541, 541, 541, 541, 541, + 542, 542, 542, 542, 542, 542, 542, 542, 983, 1212, + 984, 542, 1209, 1205, 985, 989, 1076, 542, 542, 542, + 542, 542, 542, 550, 550, 550, 550, 550, 550, 550, + 550, 550, 985, 989, 1076, 550, 1181, 1079, 1082, 1083, + 1180, 550, 550, 550, 550, 550, 550, 551, 551, 551, + 551, 551, 551, 551, 551, 1079, 1082, 1083, 551, 1079, + 1082, 1084, 1083, 1087, 551, 551, 551, 551, 551, 551, + 560, 560, 560, 560, 560, 560, 560, 560, 560, 1084, + + 1177, 1087, 560, 1217, 1220, 1088, 1087, 1173, 560, 560, + 560, 560, 560, 560, 562, 562, 562, 562, 562, 562, + 562, 562, 562, 1088, 1172, 1088, 562, 1169, 562, 1217, + 1220, 1164, 562, 562, 562, 562, 562, 562, 744, 744, + 744, 744, 744, 744, 744, 750, 750, 750, 750, 750, + 750, 750, 872, 778, 562, 613, 613, 613, 613, 613, + 613, 613, 1245, 1163, 1259, 1273, 613, 1319, 1092, 1160, + 872, 778, 613, 613, 613, 613, 613, 613, 615, 615, + 615, 615, 615, 615, 615, 778, 1092, 872, 1245, 615, + 1259, 1273, 1092, 1319, 1152, 615, 615, 615, 615, 615, + + 615, 616, 616, 616, 616, 616, 616, 616, 616, 618, + 618, 618, 618, 618, 618, 618, 1291, 1151, 1148, 1382, + 618, 1432, 882, 1090, 1291, 1093, 618, 618, 618, 618, + 618, 618, 620, 620, 620, 620, 620, 620, 620, 620, + 882, 1090, 1090, 1093, 620, 1382, 1093, 1432, 1441, 882, + 620, 620, 620, 620, 620, 620, 621, 621, 621, 621, + 621, 621, 621, 621, 622, 622, 622, 622, 622, 622, + 622, 1347, 1354, 1140, 1441, 622, 1139, 1136, 1129, 1347, + 1354, 622, 622, 622, 622, 622, 622, 623, 623, 623, + 623, 623, 623, 623, 623, 626, 626, 626, 626, 626, + + 626, 626, 626, 626, 770, 884, 827, 626, 782, 626, + 786, 1182, 1186, 626, 626, 626, 626, 626, 626, 1362, + 827, 1128, 770, 884, 1125, 1120, 782, 1362, 786, 1182, + 1186, 775, 884, 792, 770, 626, 629, 629, 629, 629, + 629, 629, 629, 629, 629, 782, 827, 786, 629, 775, + 629, 792, 1370, 1182, 629, 629, 629, 629, 629, 629, + 1370, 775, 1119, 1116, 792, 799, 799, 799, 799, 799, + 799, 799, 793, 828, 831, 1450, 629, 635, 635, 635, + 635, 635, 635, 635, 635, 635, 1183, 828, 831, 635, + 793, 635, 832, 842, 843, 635, 635, 635, 635, 635, + + 635, 1450, 793, 1378, 1183, 1459, 832, 842, 843, 1184, + 1115, 1378, 1112, 828, 831, 846, 1111, 635, 640, 640, + 640, 640, 640, 640, 640, 640, 640, 1184, 1183, 846, + 640, 1459, 832, 842, 843, 1189, 640, 640, 640, 640, + 640, 640, 642, 642, 642, 642, 642, 642, 642, 642, + 642, 1184, 1108, 1189, 642, 846, 642, 1105, 1189, 847, + 642, 642, 642, 642, 642, 642, 840, 840, 840, 840, + 840, 840, 840, 847, 855, 855, 855, 855, 855, 855, + 855, 1102, 642, 652, 652, 652, 652, 652, 652, 652, + 652, 652, 1423, 1098, 1526, 652, 1553, 1557, 1185, 847, + + 1423, 652, 652, 652, 652, 652, 652, 654, 654, 654, + 654, 654, 654, 654, 654, 654, 1185, 1071, 1185, 654, + 1526, 654, 1553, 1557, 1067, 654, 654, 654, 654, 654, + 654, 857, 857, 857, 857, 857, 857, 857, 861, 861, + 861, 861, 861, 861, 861, 878, 870, 654, 665, 665, + 665, 665, 665, 665, 665, 665, 665, 1472, 1060, 1059, + 665, 1056, 1561, 878, 870, 1472, 665, 665, 665, 665, + 665, 665, 666, 666, 666, 666, 666, 666, 666, 870, + 878, 1052, 1051, 666, 887, 875, 877, 885, 1561, 666, + 666, 666, 666, 666, 666, 669, 669, 669, 669, 669, + + 669, 669, 887, 875, 877, 885, 669, 966, 1078, 951, + 963, 881, 669, 669, 669, 669, 669, 669, 875, 877, + 1565, 887, 885, 951, 1532, 966, 1078, 952, 963, 881, + 669, 704, 1532, 704, 704, 704, 704, 704, 704, 704, + 881, 952, 966, 963, 704, 1078, 1565, 964, 1048, 951, + 704, 704, 704, 704, 704, 704, 910, 910, 910, 910, + 910, 910, 910, 955, 956, 964, 968, 952, 704, 705, + 705, 705, 705, 705, 705, 705, 705, 955, 956, 1044, + 964, 705, 1190, 1298, 968, 968, 1043, 705, 705, 705, + 705, 705, 705, 915, 915, 915, 915, 915, 915, 915, + + 1190, 1298, 968, 955, 956, 705, 706, 706, 706, 706, + 706, 706, 706, 919, 919, 919, 919, 919, 919, 919, + 924, 924, 924, 924, 924, 924, 924, 926, 926, 926, + 926, 926, 926, 926, 930, 930, 930, 930, 930, 930, + 930, 706, 707, 707, 707, 707, 707, 707, 707, 1040, + 1036, 1035, 1032, 707, 1029, 1569, 1589, 1598, 1028, 707, + 707, 707, 707, 707, 707, 709, 709, 709, 709, 709, + 709, 709, 709, 711, 711, 711, 711, 711, 711, 711, + 711, 1569, 1589, 1598, 1025, 711, 1021, 1020, 1017, 1016, + 1013, 711, 711, 711, 711, 711, 711, 712, 712, 712, + + 712, 712, 712, 712, 712, 714, 714, 714, 714, 714, + 714, 714, 1009, 1005, 1004, 1003, 714, 1000, 997, 1201, + 1202, 1187, 714, 714, 714, 714, 714, 714, 715, 715, + 715, 715, 715, 715, 715, 715, 715, 1201, 1202, 1187, + 715, 1201, 994, 1202, 1299, 1010, 715, 715, 715, 715, + 715, 715, 716, 716, 716, 716, 716, 716, 716, 1010, + 1187, 991, 1299, 716, 990, 962, 1300, 961, 1301, 716, + 716, 716, 716, 716, 716, 718, 718, 718, 718, 718, + 718, 718, 718, 718, 1300, 1010, 1301, 718, 958, 1192, + 1302, 1310, 1011, 718, 718, 718, 718, 718, 718, 719, + + 719, 719, 719, 719, 719, 719, 1011, 1192, 1302, 1310, + 719, 954, 1307, 1302, 1310, 1192, 719, 719, 719, 719, + 719, 719, 723, 723, 723, 723, 723, 723, 723, 723, + 1307, 953, 1011, 723, 950, 945, 941, 1314, 1315, 723, + 723, 723, 723, 723, 723, 725, 725, 725, 725, 725, + 725, 725, 725, 725, 1307, 1314, 1315, 725, 933, 929, + 1396, 1397, 922, 725, 725, 725, 725, 725, 725, 726, + 726, 726, 726, 726, 726, 726, 726, 1315, 1396, 1397, + 726, 1396, 1397, 1398, 1399, 1401, 726, 726, 726, 726, + 726, 726, 734, 734, 734, 734, 734, 734, 734, 734, + + 734, 1398, 1399, 1401, 734, 918, 1399, 913, 1402, 908, + 734, 734, 734, 734, 734, 734, 735, 735, 735, 735, + 735, 735, 735, 735, 907, 1398, 1402, 735, 906, 903, + 1402, 1403, 1404, 735, 735, 735, 735, 735, 735, 745, + 745, 745, 745, 745, 745, 745, 745, 745, 900, 1403, + 1404, 745, 896, 1403, 1406, 1409, 1404, 745, 745, 745, + 745, 745, 745, 746, 746, 746, 746, 746, 746, 746, + 746, 864, 1406, 1409, 746, 860, 1406, 1477, 1409, 1478, + 746, 746, 746, 746, 746, 746, 758, 758, 758, 758, + 758, 758, 758, 758, 758, 1477, 853, 1478, 758, 852, + + 849, 1488, 845, 1477, 758, 758, 758, 758, 758, 758, + 760, 760, 760, 760, 760, 760, 760, 760, 760, 1488, + 1488, 844, 760, 841, 760, 838, 837, 834, 760, 760, + 760, 760, 760, 760, 936, 936, 936, 936, 936, 936, + 936, 938, 938, 938, 938, 938, 938, 938, 1018, 969, + 760, 794, 1019, 794, 794, 794, 794, 794, 794, 794, + 830, 829, 1018, 826, 794, 825, 1019, 969, 1081, 794, + 794, 794, 794, 794, 794, 794, 796, 796, 796, 796, + 796, 796, 796, 969, 822, 818, 1081, 796, 1018, 1534, + 1491, 1536, 1019, 796, 796, 796, 796, 796, 796, 798, + + 798, 798, 798, 798, 798, 798, 1081, 1534, 1491, 1536, + 798, 1491, 1303, 1537, 1544, 1548, 798, 798, 798, 798, + 798, 798, 800, 800, 800, 800, 800, 800, 800, 800, + 1303, 1537, 1544, 1548, 800, 815, 1537, 1544, 814, 1303, + 800, 800, 800, 800, 800, 800, 801, 801, 801, 801, + 801, 801, 801, 801, 804, 804, 804, 804, 804, 804, + 804, 804, 804, 813, 812, 809, 804, 806, 804, 803, + 802, 763, 804, 804, 804, 804, 804, 804, 942, 942, + 942, 942, 942, 942, 942, 949, 949, 949, 949, 949, + 949, 949, 965, 971, 804, 807, 807, 807, 807, 807, + + 807, 807, 807, 807, 1073, 1074, 1022, 807, 762, 807, + 965, 971, 1479, 807, 807, 807, 807, 807, 807, 759, + 1022, 755, 1073, 1074, 754, 965, 965, 982, 971, 980, + 1479, 1077, 751, 1073, 1074, 807, 810, 810, 810, 810, + 810, 810, 810, 810, 810, 982, 1022, 980, 810, 1077, + 810, 1479, 1023, 747, 810, 810, 810, 810, 810, 810, + 980, 1033, 982, 1077, 743, 736, 1023, 1031, 1031, 1031, + 1031, 1031, 1031, 1031, 1034, 1033, 810, 816, 816, 816, + 816, 816, 816, 816, 816, 816, 1576, 1075, 1034, 816, + 732, 816, 1023, 1037, 1038, 816, 816, 816, 816, 816, + + 816, 1033, 727, 722, 1576, 1075, 721, 1037, 1038, 720, + 1541, 717, 713, 1049, 1034, 1050, 1075, 816, 821, 821, + 821, 821, 821, 821, 821, 821, 821, 1049, 1541, 1050, + 821, 703, 702, 1037, 1038, 698, 821, 821, 821, 821, + 821, 821, 823, 823, 823, 823, 823, 823, 823, 823, + 823, 1541, 697, 1049, 823, 1050, 823, 1085, 1196, 1053, + 823, 823, 823, 823, 823, 823, 1047, 1047, 1047, 1047, + 1047, 1047, 1047, 1053, 695, 1085, 1196, 694, 1054, 1410, + 1197, 677, 823, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 1054, 1196, 1085, 833, 667, 1410, 1197, 1053, + + 663, 833, 833, 833, 833, 833, 833, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 1197, 1410, 1054, 835, + 657, 835, 656, 653, 649, 835, 835, 835, 835, 835, + 835, 1062, 1062, 1062, 1062, 1062, 1062, 1062, 1064, 1064, + 1064, 1064, 1064, 1064, 1064, 1170, 1094, 835, 848, 848, + 848, 848, 848, 848, 848, 848, 848, 648, 645, 1170, + 848, 644, 641, 637, 1094, 1094, 848, 848, 848, 848, + 848, 848, 850, 850, 850, 850, 850, 850, 850, 850, + 850, 1094, 1094, 634, 850, 1170, 850, 1587, 1486, 1086, + 850, 850, 850, 850, 850, 850, 1068, 1068, 1068, 1068, + + 1068, 1068, 1068, 633, 632, 1587, 1486, 1086, 1200, 1171, + 1174, 631, 850, 862, 862, 862, 862, 862, 862, 862, + 862, 862, 1086, 1171, 1174, 862, 1200, 1486, 1612, 1080, + 1175, 862, 862, 862, 862, 862, 862, 863, 863, 863, + 863, 863, 863, 863, 1175, 1200, 1612, 1080, 863, 1171, + 1174, 1578, 628, 1579, 863, 863, 863, 863, 863, 863, + 889, 1080, 889, 889, 889, 889, 889, 889, 889, 1578, + 1175, 1579, 1578, 889, 1579, 1620, 1580, 1628, 889, 889, + 889, 889, 889, 889, 889, 890, 890, 890, 890, 890, + 890, 890, 625, 1620, 1580, 1628, 890, 1580, 1411, 1089, + + 1585, 1091, 890, 890, 890, 890, 890, 890, 891, 891, + 891, 891, 891, 891, 891, 891, 1411, 1089, 1585, 1091, + 891, 1585, 891, 624, 617, 1411, 891, 891, 891, 891, + 891, 891, 1089, 1091, 1117, 1117, 1117, 1117, 1117, 1117, + 1117, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 891, 893, + 893, 893, 893, 893, 893, 893, 614, 612, 608, 602, + 893, 601, 1476, 1605, 1607, 1608, 893, 893, 893, 893, + 893, 893, 894, 894, 894, 894, 894, 894, 894, 894, + 1476, 1605, 1607, 1608, 894, 1605, 600, 1607, 1608, 1476, + 894, 894, 894, 894, 894, 894, 895, 895, 895, 895, + + 895, 895, 895, 895, 897, 897, 897, 897, 897, 897, + 897, 599, 595, 594, 592, 897, 591, 590, 1633, 1634, + 1622, 897, 897, 897, 897, 897, 897, 898, 898, 898, + 898, 898, 898, 898, 898, 898, 1633, 1634, 1622, 898, + 589, 585, 1634, 1635, 1229, 898, 898, 898, 898, 898, + 898, 899, 899, 899, 899, 899, 899, 899, 1229, 1622, + 584, 1635, 899, 583, 582, 1636, 1635, 1623, 899, 899, + 899, 899, 899, 899, 901, 901, 901, 901, 901, 901, + 901, 901, 901, 1636, 1229, 1623, 901, 581, 1636, 1638, + 1640, 1230, 901, 901, 901, 901, 901, 901, 902, 902, + + 902, 902, 902, 902, 902, 1230, 1623, 1638, 1640, 902, + 580, 579, 1638, 578, 1624, 902, 902, 902, 902, 902, + 902, 904, 904, 904, 904, 904, 904, 904, 904, 904, + 577, 1230, 1624, 904, 576, 575, 1645, 1647, 1235, 904, + 904, 904, 904, 904, 904, 905, 905, 905, 905, 905, + 905, 905, 1235, 1624, 1645, 1647, 905, 1645, 1649, 1647, + 574, 573, 905, 905, 905, 905, 905, 905, 909, 909, + 909, 909, 909, 909, 909, 909, 1649, 572, 1235, 909, + 569, 1649, 1651, 1652, 1657, 909, 909, 909, 909, 909, + 909, 911, 911, 911, 911, 911, 911, 911, 911, 911, + + 1651, 1652, 1657, 911, 568, 1651, 1653, 567, 565, 911, + 911, 911, 911, 911, 911, 912, 912, 912, 912, 912, + 912, 912, 912, 1657, 1653, 1652, 912, 564, 561, 1660, + 556, 1664, 912, 912, 912, 912, 912, 912, 920, 920, + 920, 920, 920, 920, 920, 920, 920, 1660, 1653, 1664, + 920, 552, 1660, 1668, 1669, 548, 920, 920, 920, 920, + 920, 920, 921, 921, 921, 921, 921, 921, 921, 921, + 543, 1668, 1669, 921, 538, 537, 1668, 1669, 1674, 921, + 921, 921, 921, 921, 921, 931, 931, 931, 931, 931, + 931, 931, 931, 931, 536, 532, 1674, 931, 526, 1675, + + 1677, 1674, 525, 931, 931, 931, 931, 931, 931, 932, + 932, 932, 932, 932, 932, 932, 932, 1675, 1677, 520, + 932, 1675, 519, 1679, 1682, 1683, 932, 932, 932, 932, + 932, 932, 943, 943, 943, 943, 943, 943, 943, 943, + 943, 1679, 1682, 1683, 943, 1682, 1679, 1684, 1689, 518, + 943, 943, 943, 943, 943, 943, 944, 944, 944, 944, + 944, 944, 944, 944, 517, 1684, 1689, 944, 516, 515, + 1694, 1689, 1698, 944, 944, 944, 944, 944, 944, 957, + 957, 957, 957, 957, 957, 957, 957, 957, 1694, 1684, + 1698, 957, 514, 513, 1700, 1698, 1703, 957, 957, 957, + + 957, 957, 957, 959, 959, 959, 959, 959, 959, 959, + 959, 959, 1700, 512, 1703, 959, 511, 959, 510, 509, + 508, 959, 959, 959, 959, 959, 959, 1126, 1126, 1126, + 1126, 1126, 1126, 1126, 1131, 1131, 1131, 1131, 1131, 1131, + 1131, 1710, 1712, 959, 986, 986, 986, 986, 986, 986, + 986, 986, 986, 506, 503, 502, 501, 986, 500, 1710, + 1712, 499, 986, 986, 986, 986, 986, 986, 986, 987, + 987, 987, 987, 987, 987, 987, 987, 988, 988, 988, + 988, 988, 988, 988, 988, 988, 1133, 1133, 1133, 1133, + 1133, 1133, 1133, 1701, 1714, 988, 992, 992, 992, 992, + + 992, 992, 992, 992, 992, 498, 497, 495, 992, 494, + 992, 1701, 1714, 493, 992, 992, 992, 992, 992, 992, + 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1143, 1143, 1143, + 1143, 1143, 1143, 1143, 1706, 1701, 992, 995, 995, 995, + 995, 995, 995, 995, 995, 995, 492, 491, 489, 995, + 487, 995, 1706, 485, 484, 995, 995, 995, 995, 995, + 995, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1149, 1149, + 1149, 1149, 1149, 1149, 1149, 1719, 1706, 995, 998, 998, + 998, 998, 998, 998, 998, 998, 998, 483, 482, 481, + 998, 479, 998, 1719, 478, 476, 998, 998, 998, 998, + + 998, 998, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1157, + 1157, 1157, 1157, 1157, 1157, 1157, 1721, 1724, 998, 1001, + 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 475, 474, + 471, 1001, 467, 1001, 1721, 1724, 463, 1001, 1001, 1001, + 1001, 1001, 1001, 1161, 1161, 1161, 1161, 1161, 1161, 1161, + 1168, 1168, 1168, 1168, 1168, 1168, 1168, 462, 461, 1001, + 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 458, 454, + 453, 1006, 450, 449, 448, 1191, 1194, 1006, 1006, 1006, + 1006, 1006, 1006, 1007, 1007, 1007, 1007, 1007, 1007, 1007, + 1007, 1007, 1188, 1191, 1194, 1007, 1543, 1007, 1198, 1236, + + 1308, 1007, 1007, 1007, 1007, 1007, 1007, 1194, 1191, 447, + 1188, 444, 443, 1236, 1543, 434, 1198, 1709, 1308, 431, + 429, 1188, 428, 1007, 1012, 1012, 1012, 1012, 1012, 1012, + 1012, 1012, 1012, 1198, 1543, 1709, 1012, 1308, 1709, 1236, + 1195, 1199, 1012, 1012, 1012, 1012, 1012, 1012, 1014, 1014, + 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1193, 1195, 1199, + 1014, 427, 1014, 426, 425, 1309, 1014, 1014, 1014, 1014, + 1014, 1014, 1195, 1199, 424, 1193, 1223, 1223, 1223, 1223, + 1223, 1223, 1223, 1309, 1239, 1311, 1193, 423, 1014, 1024, + 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1239, 422, + + 1309, 1024, 421, 1311, 420, 1203, 419, 1024, 1024, 1024, + 1024, 1024, 1024, 1026, 1026, 1026, 1026, 1026, 1026, 1026, + 1026, 1026, 1311, 1203, 1239, 1026, 418, 1026, 1240, 417, + 416, 1026, 1026, 1026, 1026, 1026, 1026, 1203, 414, 412, + 411, 409, 1240, 1246, 1246, 1246, 1246, 1246, 1246, 1246, + 408, 1248, 1313, 1026, 1039, 1039, 1039, 1039, 1039, 1039, + 1039, 1039, 1039, 405, 404, 1248, 1039, 402, 1240, 400, + 1313, 399, 1039, 1039, 1039, 1039, 1039, 1039, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1313, 1249, 1252, + 1041, 1248, 1041, 1253, 398, 393, 1041, 1041, 1041, 1041, + + 1041, 1041, 1249, 1252, 392, 391, 389, 1253, 1260, 1260, + 1260, 1260, 1260, 1260, 1260, 388, 1262, 1395, 1041, 1055, + 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1249, 1252, + 1262, 1055, 387, 1253, 386, 1395, 384, 1055, 1055, 1055, + 1055, 1055, 1055, 1057, 1057, 1057, 1057, 1057, 1057, 1057, + 1057, 1057, 1395, 1263, 1266, 1057, 1262, 1057, 1267, 379, + 378, 1057, 1057, 1057, 1057, 1057, 1057, 1263, 1266, 377, + 374, 370, 1267, 1274, 1274, 1274, 1274, 1274, 1274, 1274, + 368, 1276, 1489, 1057, 1069, 1069, 1069, 1069, 1069, 1069, + 1069, 1069, 1069, 1263, 1266, 1276, 1069, 363, 1267, 362, + + 1489, 1277, 1069, 1069, 1069, 1069, 1069, 1069, 1070, 1070, + 1070, 1070, 1070, 1070, 1070, 1277, 359, 1489, 354, 1070, + 353, 1276, 1707, 345, 1713, 1070, 1070, 1070, 1070, 1070, + 1070, 1095, 1095, 1095, 1095, 1095, 1095, 1095, 1095, 1095, + 1707, 1277, 1713, 343, 1095, 1707, 342, 1713, 337, 1095, + 1095, 1095, 1095, 1095, 1095, 1095, 1096, 1096, 1096, 1096, + 1096, 1096, 1096, 1096, 1097, 1097, 1097, 1097, 1097, 1097, + 1097, 1097, 1097, 335, 1725, 1726, 1280, 1281, 1727, 1306, + 333, 1337, 1097, 1099, 1099, 1099, 1099, 1099, 1099, 1099, + 1280, 1281, 1725, 1726, 1099, 1337, 1727, 1306, 1306, 332, + + 1099, 1099, 1099, 1099, 1099, 1099, 1100, 1100, 1100, 1100, + 1100, 1100, 1100, 1100, 1100, 1306, 1280, 1281, 1100, 331, + 330, 1337, 329, 1338, 1100, 1100, 1100, 1100, 1100, 1100, + 1101, 1101, 1101, 1101, 1101, 1101, 1101, 1338, 328, 327, + 325, 1101, 324, 323, 318, 315, 1687, 1101, 1101, 1101, + 1101, 1101, 1101, 1103, 1103, 1103, 1103, 1103, 1103, 1103, + 1103, 1103, 314, 1338, 1687, 1103, 313, 310, 303, 302, + 1385, 1103, 1103, 1103, 1103, 1103, 1103, 1104, 1104, 1104, + 1104, 1104, 1104, 1104, 1385, 1687, 300, 299, 1104, 298, + 296, 294, 293, 1718, 1104, 1104, 1104, 1104, 1104, 1104, + + 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 292, + 1385, 1718, 1106, 290, 286, 285, 283, 1386, 1106, 1106, + 1106, 1106, 1106, 1106, 1107, 1107, 1107, 1107, 1107, 1107, + 1107, 1386, 1718, 280, 276, 1107, 275, 272, 271, 269, + 264, 1107, 1107, 1107, 1107, 1107, 1107, 1109, 1109, 1109, + 1109, 1109, 1109, 1109, 1109, 1109, 261, 1386, 259, 1109, + 258, 256, 253, 249, 1389, 1109, 1109, 1109, 1109, 1109, + 1109, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1389, 245, + 243, 241, 1110, 240, 238, 237, 236, 235, 1110, 1110, + 1110, 1110, 1110, 1110, 1113, 1113, 1113, 1113, 1113, 1113, + + 1113, 1113, 1113, 234, 1389, 233, 1113, 232, 1113, 230, + 228, 226, 1113, 1113, 1113, 1113, 1113, 1113, 1287, 1287, + 1287, 1287, 1287, 1287, 1287, 1289, 1289, 1289, 1289, 1289, + 1289, 1289, 1312, 225, 1113, 1118, 1118, 1118, 1118, 1118, + 1118, 1118, 1118, 1118, 223, 221, 220, 1118, 218, 215, + 1312, 1312, 214, 1118, 1118, 1118, 1118, 1118, 1118, 1127, + 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1312, 213, + 211, 1127, 209, 208, 205, 204, 202, 1127, 1127, 1127, + 1127, 1127, 1127, 1138, 1138, 1138, 1138, 1138, 1138, 1138, + 1138, 1138, 201, 200, 199, 1138, 198, 197, 196, 195, + + 194, 1138, 1138, 1138, 1138, 1138, 1138, 1150, 1150, 1150, + 1150, 1150, 1150, 1150, 1150, 1150, 193, 192, 191, 1150, + 190, 189, 188, 187, 186, 1150, 1150, 1150, 1150, 1150, + 1150, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, + 185, 183, 182, 1162, 179, 178, 177, 176, 175, 1162, + 1162, 1162, 1162, 1162, 1162, 1176, 1176, 1176, 1176, 1176, + 1176, 1176, 1176, 1176, 174, 173, 172, 1176, 170, 167, + 166, 165, 164, 1176, 1176, 1176, 1176, 1176, 1176, 1178, + 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 161, 159, + 150, 1178, 149, 1178, 1475, 1535, 1390, 1178, 1178, 1178, + + 1178, 1178, 1178, 1293, 1293, 1293, 1293, 1293, 1293, 1293, + 1390, 1650, 1475, 1535, 148, 1546, 1304, 1316, 147, 1178, + 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1650, + 146, 1475, 1535, 1546, 1304, 1316, 1390, 1427, 1204, 1206, + 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1304, 1316, 1650, + 1206, 1427, 1546, 145, 144, 1400, 1206, 1206, 1206, 1206, + 1206, 1206, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, + 1207, 1305, 1317, 1400, 1207, 142, 1207, 1427, 140, 139, + 1207, 1207, 1207, 1207, 1207, 1207, 137, 1400, 135, 1305, + 1317, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 133, 132, + + 1305, 1317, 1207, 1210, 1210, 1210, 1210, 1210, 1210, 1210, + 1210, 1210, 131, 130, 128, 1210, 127, 1210, 126, 125, + 124, 1210, 1210, 1210, 1210, 1210, 1210, 1350, 1350, 1350, + 1350, 1350, 1350, 1350, 1352, 1352, 1352, 1352, 1352, 1352, + 1352, 123, 121, 1210, 1213, 1213, 1213, 1213, 1213, 1213, + 1213, 1213, 1213, 119, 118, 117, 1213, 116, 1213, 115, + 114, 113, 1213, 1213, 1213, 1213, 1213, 1213, 1358, 1358, + 1358, 1358, 1358, 1358, 1358, 1360, 1360, 1360, 1360, 1360, + 1360, 1360, 112, 111, 1213, 1216, 1216, 1216, 1216, 1216, + 1216, 1216, 1216, 1216, 109, 108, 101, 1216, 100, 1216, + + 99, 97, 96, 1216, 1216, 1216, 1216, 1216, 1216, 1366, + 1366, 1366, 1366, 1366, 1366, 1366, 1368, 1368, 1368, 1368, + 1368, 1368, 1368, 93, 92, 1216, 1219, 1219, 1219, 1219, + 1219, 1219, 1219, 1219, 1219, 91, 90, 89, 1219, 88, + 1219, 87, 86, 85, 1219, 1219, 1219, 1219, 1219, 1219, + 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1376, 1376, 1376, + 1376, 1376, 1376, 1376, 1428, 1539, 1219, 1224, 1224, 1224, + 1224, 1224, 1224, 1224, 1224, 1224, 84, 82, 1428, 1224, + 81, 80, 79, 1539, 78, 1224, 1224, 1224, 1224, 1224, + 1224, 1231, 1231, 1231, 1231, 1231, 1231, 1231, 1231, 1231, + + 77, 1539, 76, 1231, 1428, 75, 74, 73, 72, 1231, + 1231, 1231, 1231, 1231, 1231, 1241, 1241, 1241, 1241, 1241, + 1241, 1241, 1241, 1241, 71, 70, 69, 1241, 67, 66, + 65, 51, 43, 1241, 1241, 1241, 1241, 1241, 1241, 1254, + 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 42, 40, + 18, 1254, 11, 8, 3, 0, 0, 1254, 1254, 1254, + 1254, 1254, 1254, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 0, 0, 0, 1268, 0, 0, 0, 0, + 0, 1268, 1268, 1268, 1268, 1268, 1268, 1282, 1282, 1282, + 1282, 1282, 1282, 1282, 1282, 1282, 0, 0, 0, 1282, + + 0, 0, 0, 0, 0, 1282, 1282, 1282, 1282, 1282, + 1282, 1294, 1294, 1294, 1294, 1294, 1294, 1294, 1294, 1294, + 0, 0, 0, 1294, 0, 0, 0, 0, 0, 1294, + 1294, 1294, 1294, 1294, 1294, 1318, 1318, 1318, 1318, 1318, + 1318, 1318, 1318, 1318, 0, 0, 0, 1318, 0, 1318, + 0, 0, 0, 1318, 1318, 1318, 1318, 1318, 1318, 1383, + 1383, 1383, 1383, 1383, 1383, 1383, 1421, 1421, 1421, 1421, + 1421, 1421, 1421, 1435, 1540, 1318, 1322, 1322, 1322, 1322, + 1322, 1322, 1322, 1322, 1322, 0, 0, 1435, 1322, 0, + 0, 0, 1540, 0, 1322, 1322, 1322, 1322, 1322, 1322, + + 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 0, + 1540, 0, 1325, 1435, 0, 0, 0, 0, 1325, 1325, + 1325, 1325, 1325, 1325, 1328, 1328, 1328, 1328, 1328, 1328, + 1328, 1328, 1328, 0, 0, 0, 1328, 0, 0, 0, + 0, 0, 1328, 1328, 1328, 1328, 1328, 1328, 1331, 1331, + 1331, 1331, 1331, 1331, 1331, 1331, 1331, 0, 0, 0, + 1331, 0, 0, 0, 0, 0, 1331, 1331, 1331, 1331, + 1331, 1331, 1334, 1334, 1334, 1334, 1334, 1334, 1334, 1334, + 1334, 0, 0, 0, 1334, 0, 0, 0, 0, 0, + 1334, 1334, 1334, 1334, 1334, 1334, 1339, 1339, 1339, 1339, + + 1339, 1339, 1339, 1339, 1339, 0, 0, 0, 1339, 0, + 0, 0, 1407, 0, 1339, 1339, 1339, 1339, 1339, 1339, + 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1405, + 1407, 1408, 1391, 0, 1436, 0, 0, 0, 1391, 1391, + 1391, 1391, 1391, 1391, 1407, 1490, 0, 1405, 1436, 1408, + 1433, 1433, 1433, 1433, 1433, 1433, 1433, 0, 1405, 0, + 0, 1408, 1444, 1490, 1405, 1412, 1412, 1412, 1412, 1412, + 1412, 1412, 1412, 1412, 1436, 1490, 1444, 1412, 0, 0, + 0, 0, 1445, 1412, 1412, 1412, 1412, 1412, 1412, 1442, + 1442, 1442, 1442, 1442, 1442, 1442, 1445, 1453, 1454, 0, + + 0, 0, 1444, 1451, 1451, 1451, 1451, 1451, 1451, 1451, + 1462, 1453, 1454, 1460, 1460, 1460, 1460, 1460, 1460, 1460, + 1463, 0, 1445, 0, 1462, 1468, 1468, 1468, 1468, 1468, + 1468, 1468, 0, 1480, 1463, 1485, 1481, 1453, 1454, 1470, + 1470, 1470, 1470, 1470, 1470, 1470, 1482, 1483, 1484, 0, + 1462, 1480, 1487, 1485, 1481, 1500, 0, 1501, 1542, 1547, + 1463, 1603, 1480, 1481, 1482, 1483, 1484, 1485, 0, 1500, + 1487, 1501, 0, 1482, 1483, 1484, 1542, 1547, 0, 1603, + 0, 1487, 1506, 1506, 1506, 1506, 1506, 1506, 1506, 0, + 0, 0, 0, 1603, 1542, 1500, 1547, 1501, 1510, 1510, + + 1510, 1510, 1510, 1510, 1510, 1514, 1514, 1514, 1514, 1514, + 1514, 1514, 1518, 1518, 1518, 1518, 1518, 1518, 1518, 1522, + 1522, 1522, 1522, 1522, 1522, 1522, 1527, 1527, 1527, 1527, + 1527, 1527, 1527, 1529, 1530, 1538, 1545, 1549, 1551, 1551, + 1551, 1551, 1551, 1551, 1551, 0, 0, 1529, 1530, 0, + 0, 0, 0, 1538, 1545, 1549, 0, 0, 0, 0, + 0, 0, 1538, 1545, 1549, 1554, 1554, 1554, 1554, 1554, + 1554, 1554, 0, 1529, 1530, 1558, 1558, 1558, 1558, 1558, + 1558, 1558, 1562, 1562, 1562, 1562, 1562, 1562, 1562, 1566, + 1566, 1566, 1566, 1566, 1566, 1566, 1570, 1570, 1570, 1570, + + 1570, 1570, 1570, 1573, 1573, 1573, 1573, 1573, 1573, 1573, + 1577, 1581, 0, 1582, 1583, 1586, 1588, 1584, 1590, 1590, + 1590, 1590, 1590, 1590, 1590, 1601, 1609, 0, 1577, 1581, + 1581, 1582, 1583, 1586, 1588, 1584, 0, 0, 0, 0, + 0, 0, 1586, 1601, 1609, 1577, 1602, 1581, 1604, 1606, + 1582, 1583, 1584, 1588, 1599, 1599, 1599, 1599, 1599, 1599, + 1599, 1610, 1601, 1609, 1602, 1611, 1604, 1606, 1621, 1625, + 0, 1626, 1627, 1602, 1629, 1630, 1637, 1639, 0, 1610, + 1604, 1606, 1641, 1611, 0, 0, 1621, 1625, 1610, 1626, + 1627, 1642, 1629, 1630, 1637, 1639, 1639, 1611, 1625, 0, + + 1641, 1643, 1626, 1637, 1644, 1621, 1630, 1627, 0, 1642, + 1646, 1629, 1648, 1639, 1639, 1654, 1641, 1641, 0, 1643, + 1655, 0, 1644, 1665, 1656, 1658, 1642, 0, 1646, 0, + 1648, 1659, 1661, 1654, 0, 1662, 1643, 1663, 1655, 1644, + 0, 1665, 1656, 1658, 1648, 1646, 1656, 1655, 0, 1659, + 1661, 1666, 1654, 1662, 1658, 1663, 1663, 1667, 1656, 1656, + 1665, 1670, 1671, 1672, 1673, 0, 1659, 1676, 1661, 1666, + 1662, 1678, 1680, 1663, 0, 1667, 1681, 0, 1685, 1670, + 1671, 1672, 1673, 1666, 0, 1676, 1686, 0, 1670, 1678, + 1680, 1690, 1671, 0, 1681, 1667, 1685, 1673, 1672, 1676, + + 1688, 0, 1678, 1691, 1686, 1680, 1692, 1693, 0, 1690, + 1685, 1681, 1696, 1695, 1697, 1699, 0, 0, 1688, 1686, + 1686, 1691, 1702, 0, 1692, 1693, 1690, 1704, 1708, 1688, + 1696, 1695, 1697, 1699, 1693, 1691, 1705, 1711, 1716, 0, + 1702, 1696, 1699, 1692, 1695, 1704, 1708, 1715, 1720, 1717, + 1722, 0, 1697, 0, 1705, 1711, 1716, 1702, 0, 0, + 0, 0, 0, 1708, 1704, 1715, 1720, 1717, 1722, 0, + 0, 0, 1705, 0, 1711, 1716, 1717, 1723, 0, 0, + 1723, 1723, 0, 1715, 0, 1720, 0, 1722, 0, 0, + 0, 0, 0, 0, 0, 1723, 1729, 0, 0, 0, + + 0, 1729, 1729, 1729, 1730, 0, 1730, 1730, 1730, 1730, + 1730, 1730, 1730, 1731, 0, 1731, 1732, 1732, 1732, 1733, + 1733, 1733, 1734, 1734, 1734, 1735, 1735, 1735, 1736, 1736, + 1736, 1737, 1737, 1737, 1738, 1738, 1738, 1739, 1739, 1739, + 1740, 1740, 1740, 1741, 0, 1741, 1742, 1742, 1742, 1743, + 1743, 1743, 1744, 1744, 1744, 1745, 1745, 1745, 1746, 0, + 1746, 1747, 1747, 1747, 1748, 1748, 0, 0, 1748, 1749, + 1749, 1749, 1750, 1750, 1750, 1751, 1751, 1751, 1752, 1752, + 1752, 1753, 1753, 1753, 1754, 1754, 1754, 1755, 1755, 1755, + 1756, 1756, 1756, 1757, 1757, 1757, 1758, 1758, 0, 0, + + 1758, 1759, 1759, 1759, 1760, 1760, 1760, 1761, 0, 1761, + 1762, 1762, 1762, 1763, 1763, 1763, 1764, 0, 1764, 1765, + 1765, 1765, 1766, 1766, 1766, 1767, 1767, 1767, 1768, 1768, + 1768, 1769, 1769, 1769, 1770, 0, 1770, 1771, 0, 1771, + 1772, 1772, 1772, 1773, 1773, 1773, 1774, 0, 1774, 1775, + 1775, 0, 0, 1775, 1776, 1776, 0, 0, 1776, 1777, + 1777, 1777, 1778, 1778, 1778, 1779, 1779, 0, 1779, 1780, + 1780, 1780, 1781, 1781, 1781, 1782, 1782, 1782, 1783, 1783, + 1783, 1784, 1784, 1784, 1785, 1785, 1785, 1786, 1786, 1786, + 1787, 1787, 0, 0, 1787, 1788, 1788, 1788, 1789, 1789, + + 1789, 1790, 1790, 0, 1790, 1791, 1791, 0, 0, 1791, + 1792, 1792, 0, 1792, 1793, 1793, 1794, 1794, 0, 0, + 1794, 1795, 1795, 1795, 1796, 1796, 1796, 1797, 1797, 0, + 1797, 1798, 0, 1798, 1799, 0, 1799, 1800, 1800, 1800, + 1801, 1801, 1801, 1802, 0, 1802, 1803, 1803, 1803, 1804, + 1804, 1804, 1805, 1805, 1805, 1806, 1806, 1806, 1807, 1807, + 1807, 1808, 1808, 1808, 1809, 0, 1809, 1810, 0, 1810, + 1811, 1811, 1811, 1812, 1812, 1812, 1813, 0, 1813, 1814, + 0, 1814, 1815, 0, 1815, 1816, 1816, 1816, 1817, 1817, + 1817, 1818, 0, 1818, 1819, 0, 0, 1819, 1820, 1820, + + 0, 1820, 1821, 1821, 0, 0, 1821, 1822, 1822, 0, + 1822, 1823, 1823, 1824, 1824, 0, 0, 1824, 1825, 1825, + 1825, 1826, 1826, 1826, 1827, 1827, 0, 1827, 1828, 1828, + 1828, 0, 1828, 1828, 1829, 1829, 1829, 1830, 1830, 1830, + 1831, 1831, 1831, 1832, 1832, 1832, 1833, 1833, 1833, 1834, + 1834, 1834, 1835, 1835, 1835, 1836, 1836, 1836, 1837, 1837, + 0, 0, 1837, 1838, 1838, 1838, 1839, 1839, 1839, 1840, + 1840, 0, 1840, 1841, 1841, 0, 0, 1841, 1842, 1842, + 0, 1842, 1843, 1843, 1844, 1844, 0, 0, 1844, 1845, + 1845, 1845, 1846, 1846, 1846, 1847, 1847, 0, 1847, 1848, + + 0, 0, 1848, 1849, 1849, 0, 1849, 1850, 1850, 0, + 0, 1850, 1851, 1851, 0, 1851, 1852, 1852, 1853, 1853, + 0, 0, 1853, 1854, 1854, 1854, 1855, 1855, 1855, 1856, + 1856, 0, 1856, 1857, 0, 1857, 1858, 0, 1858, 1859, + 0, 1859, 1860, 1860, 1860, 1861, 1861, 1861, 1862, 0, + 1862, 1863, 1863, 1863, 0, 1863, 1863, 1864, 1864, 1864, + 1865, 1865, 1865, 1866, 1866, 1866, 1867, 1867, 1867, 1868, + 1868, 1868, 1869, 1869, 1869, 1870, 1870, 1870, 1871, 0, + 1871, 1872, 0, 1872, 1873, 1873, 1873, 1874, 1874, 1874, + 1875, 0, 1875, 1876, 0, 1876, 1877, 0, 1877, 1878, + + 1878, 1878, 1879, 1879, 1879, 1880, 0, 1880, 1881, 0, + 1881, 1882, 0, 1882, 1883, 0, 1883, 1884, 1884, 1884, + 1885, 1885, 1885, 1886, 0, 1886, 1887, 0, 1887, 1888, + 0, 0, 1888, 1889, 1889, 0, 1889, 1890, 1890, 0, + 0, 1890, 1891, 1891, 0, 1891, 1892, 1892, 1893, 1893, + 0, 0, 1893, 1894, 1894, 1894, 1895, 1895, 1895, 1896, + 1896, 0, 1896, 1897, 1897, 1897, 0, 1897, 1897, 1898, + 1898, 1898, 1899, 1899, 1899, 1900, 1900, 1900, 1901, 1901, + 1901, 1902, 1902, 1902, 1903, 1903, 1903, 1904, 1904, 1904, + 1905, 1905, 1905, 1906, 1906, 0, 0, 1906, 1907, 1907, + + 1907, 1908, 1908, 1908, 1909, 1909, 0, 1909, 1910, 1910, + 0, 0, 1910, 1911, 1911, 0, 1911, 1912, 1912, 1913, + 1913, 0, 0, 1913, 1914, 1914, 1914, 1915, 1915, 1915, + 1916, 1916, 0, 1916, 1917, 0, 0, 1917, 1918, 1918, + 0, 1918, 1919, 1919, 0, 0, 1919, 1920, 1920, 0, + 1920, 1921, 1921, 1922, 1922, 0, 0, 1922, 1923, 1923, + 1923, 1924, 1924, 1924, 1925, 1925, 0, 1925, 1926, 0, + 1926, 1927, 0, 0, 1927, 1928, 1928, 0, 1928, 1929, + 1929, 0, 0, 1929, 1930, 1930, 0, 1930, 1931, 1931, + 1932, 1932, 0, 0, 1932, 1933, 1933, 1933, 1934, 1934, + + 1934, 1935, 1935, 0, 1935, 1936, 0, 1936, 1937, 0, + 1937, 1938, 0, 1938, 1939, 1939, 1939, 1940, 1940, 1940, + 1941, 0, 1941, 1942, 1942, 1942, 0, 1942, 1942, 1943, + 1943, 1943, 1944, 1944, 1944, 1945, 1945, 1945, 1946, 1946, + 1946, 1947, 1947, 1947, 1948, 1948, 1948, 1949, 1949, 1949, + 1950, 1950, 1950, 1951, 1951, 1951, 1952, 1952, 1952, 1953, + 0, 1953, 1954, 0, 1954, 1955, 1955, 1955, 1956, 1956, + 1956, 1957, 1957, 1957, 1958, 0, 1958, 1959, 0, 1959, + 1960, 0, 1960, 1961, 1961, 1961, 1962, 1962, 1962, 1963, + 1963, 1963, 1964, 0, 1964, 1965, 0, 1965, 1966, 0, + + 1966, 1967, 0, 1967, 1968, 1968, 1968, 1969, 1969, 1969, + 1970, 1970, 1970, 1971, 0, 1971, 1972, 0, 1972, 1973, + 0, 1973, 1974, 0, 1974, 1975, 1975, 1975, 1976, 1976, + 1976, 1977, 1977, 1977, 1978, 0, 1978, 1979, 0, 1979, + 1980, 0, 0, 1980, 1981, 1981, 0, 1981, 1982, 1982, + 0, 0, 1982, 1983, 1983, 0, 1983, 1984, 1984, 1985, + 1985, 0, 0, 1985, 1986, 1986, 1986, 1987, 1987, 1987, + 1988, 1988, 0, 1988, 1989, 1989, 1989, 0, 1989, 1989, + 1990, 1990, 1990, 1991, 1991, 1991, 1992, 1992, 1992, 1993, + 1993, 1993, 1994, 1994, 1994, 1995, 1995, 1995, 1996, 1996, + + 1996, 1997, 1997, 1997, 1998, 0, 1998, 1999, 1999, 1999, + 2000, 2000, 0, 0, 2000, 2001, 2001, 2001, 2002, 2002, + 2002, 2003, 2003, 0, 2003, 2004, 2004, 0, 0, 2004, + 2005, 2005, 0, 2005, 2006, 2006, 2007, 2007, 0, 0, + 2007, 2008, 2008, 2008, 2009, 2009, 2009, 2010, 2010, 0, + 2010, 2011, 0, 0, 2011, 2012, 2012, 0, 2012, 2013, + 2013, 0, 0, 2013, 2014, 2014, 0, 2014, 2015, 2015, + 2016, 2016, 0, 0, 2016, 2017, 2017, 2017, 2018, 2018, + 2018, 2019, 2019, 0, 2019, 2020, 0, 2020, 2021, 0, + 0, 2021, 2022, 2022, 0, 2022, 2023, 2023, 0, 0, + + 2023, 2024, 2024, 0, 2024, 2025, 2025, 2026, 2026, 0, + 0, 2026, 2027, 2027, 2027, 2028, 2028, 2028, 2029, 2029, + 0, 2029, 2030, 0, 2030, 2031, 0, 0, 2031, 2032, + 2032, 0, 2032, 2033, 2033, 0, 0, 2033, 2034, 2034, + 0, 2034, 2035, 2035, 2036, 2036, 0, 0, 2036, 2037, + 2037, 2037, 2038, 2038, 2038, 2039, 2039, 0, 2039, 2040, + 0, 2040, 2041, 0, 2041, 2042, 0, 2042, 2043, 2043, + 2043, 2044, 0, 2044, 2045, 2045, 2045, 2046, 0, 2046, + 2047, 2047, 2047, 0, 2047, 2047, 2048, 0, 2048, 2049, + 2049, 2049, 2050, 0, 2050, 2051, 2051, 2051, 2052, 0, + + 2052, 2053, 2053, 2053, 2054, 0, 2054, 2055, 2055, 2055, + 2056, 0, 2056, 2057, 2057, 2057, 2058, 0, 2058, 2059, + 2059, 2059, 2060, 2060, 0, 0, 2060, 2061, 2061, 2061, + 2062, 2062, 2062, 2063, 2063, 2063, 2064, 2064, 0, 2064, + 2065, 2065, 2065, 2066, 0, 2066, 2067, 2067, 2067, 2068, + 2068, 2068, 2069, 0, 2069, 2070, 0, 2070, 2071, 2071, + 2071, 2072, 2072, 2072, 2073, 0, 2073, 2074, 0, 2074, + 2075, 0, 2075, 2076, 2076, 2076, 2077, 2077, 2077, 2078, + 0, 2078, 2079, 0, 2079, 2080, 0, 2080, 2081, 2081, + 2081, 2082, 2082, 2082, 2083, 0, 2083, 2084, 0, 2084, + + 2085, 0, 2085, 2086, 2086, 2086, 2087, 2087, 2087, 2088, + 0, 2088, 2089, 0, 0, 2089, 2090, 2090, 0, 2090, + 2091, 2091, 0, 0, 2091, 2092, 2092, 0, 2092, 2093, + 2093, 2094, 2094, 0, 0, 2094, 2095, 2095, 2095, 2096, + 0, 2096, 2097, 2097, 0, 2097, 2098, 2098, 2098, 0, + 2098, 2098, 2099, 2099, 2099, 2100, 2100, 2100, 2101, 0, + 2101, 2102, 0, 2102, 2103, 0, 2103, 2104, 0, 2104, + 2105, 0, 2105, 2106, 0, 2106, 2107, 0, 2107, 2108, + 2108, 2108, 2109, 2109, 2109, 2110, 0, 2110, 2111, 2111, + 0, 0, 2111, 2112, 2112, 0, 2112, 2113, 2113, 2114, + + 0, 2114, 2115, 0, 0, 2115, 2116, 2116, 0, 2116, + 2117, 2117, 0, 0, 2117, 2118, 2118, 0, 2118, 2119, + 2119, 2120, 0, 2120, 2121, 0, 2121, 2122, 0, 0, + 2122, 2123, 2123, 0, 2123, 2124, 2124, 0, 0, 2124, + 2125, 2125, 0, 2125, 2126, 2126, 2127, 0, 2127, 2128, + 0, 2128, 2129, 0, 0, 2129, 2130, 2130, 0, 2130, + 2131, 2131, 0, 0, 2131, 2132, 2132, 0, 2132, 2133, + 2133, 2134, 0, 2134, 2135, 0, 2135, 2136, 0, 0, + 2136, 2137, 2137, 0, 2137, 2138, 2138, 0, 0, 2138, + 2139, 2139, 0, 2139, 2140, 2140, 2141, 0, 2141, 2142, + + 0, 2142, 2143, 0, 2143, 2144, 0, 2144, 2145, 2145, + 2145, 2146, 0, 2146, 2147, 2147, 2147, 0, 2147, 2147, + 2148, 0, 2148, 2149, 0, 2149, 2150, 0, 2150, 2151, + 0, 2151, 2152, 0, 2152, 2153, 0, 2153, 2154, 0, + 2154, 2155, 2155, 0, 0, 2155, 2156, 2156, 0, 2156, + 2157, 2157, 2158, 0, 2158, 2159, 0, 2159, 2160, 0, + 2160, 2161, 0, 2161, 2162, 0, 2162, 2163, 0, 2163, + 2164, 0, 2164, 2165, 0, 2165, 2166, 0, 2166, 2167, + 0, 2167, 2168, 0, 0, 2168, 2169, 2169, 0, 0, + 2169, 2170, 0, 2170, 2171, 0, 2171, 2172, 0, 2172, + + 2173, 0, 0, 2173, 2174, 0, 0, 2174, 2175, 0, + 0, 2175, 2176, 0, 0, 2176, 2177, 0, 0, 2177, + 2178, 0, 2178, 2179, 0, 2179, 2180, 0, 0, 2180, + 2181, 0, 2181, 2182, 0, 2182, 2183, 0, 2183, 2184, + 0, 2184, 2185, 0, 2185, 2186, 0, 0, 2186, 2187, + 0, 2187, 2188, 0, 2188, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, + + 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728 } ; /* The intent behind this definition is that it'll catch @@ -2703,7 +2904,7 @@ static yyconst flex_int16_t yy_chk[7486] = * We want to generate code that can be used by a reentrant parser * generated by Bison or Berkeley YACC. */ -#line 45 "scanner.l" +#line 67 "scanner.l" /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -2723,24 +2924,8 @@ static yyconst flex_int16_t yy_chk[7486] = * 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> @@ -2760,6 +2945,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 * @@ -2779,10 +2966,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" */ @@ -2805,7 +2991,12 @@ void pcap_set_column(int, yyscan_t); static int stoi(char *); static inline int xdtoi(int); -#line 2809 "scanner.c" +/* + * Disable diagnostics in the code generated by Flex. + */ +DIAG_OFF_FLEX + +#line 3000 "scanner.c" #define INITIAL 0 @@ -3038,9 +3229,9 @@ YY_DECL int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 242 "scanner.l" +#line 254 "scanner.l" -#line 3044 "scanner.c" +#line 3235 "scanner.c" yylval = yylval_param; @@ -3095,13 +3286,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1470 ) + if ( yy_current_state >= 1729 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 1469 ); + while ( yy_current_state != 1728 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -3123,257 +3314,257 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 243 "scanner.l" +#line 255 "scanner.l" return DST; YY_BREAK case 2: YY_RULE_SETUP -#line 244 "scanner.l" +#line 256 "scanner.l" return SRC; YY_BREAK case 3: YY_RULE_SETUP -#line 246 "scanner.l" +#line 258 "scanner.l" return LINK; YY_BREAK case 4: YY_RULE_SETUP -#line 247 "scanner.l" +#line 259 "scanner.l" return LINK; YY_BREAK case 5: YY_RULE_SETUP -#line 248 "scanner.l" +#line 260 "scanner.l" return ARP; YY_BREAK case 6: YY_RULE_SETUP -#line 249 "scanner.l" +#line 261 "scanner.l" return RARP; YY_BREAK case 7: YY_RULE_SETUP -#line 250 "scanner.l" +#line 262 "scanner.l" return IP; YY_BREAK case 8: YY_RULE_SETUP -#line 251 "scanner.l" +#line 263 "scanner.l" return SCTP; YY_BREAK case 9: YY_RULE_SETUP -#line 252 "scanner.l" +#line 264 "scanner.l" return TCP; YY_BREAK case 10: YY_RULE_SETUP -#line 253 "scanner.l" +#line 265 "scanner.l" return UDP; YY_BREAK case 11: YY_RULE_SETUP -#line 254 "scanner.l" +#line 266 "scanner.l" return ICMP; YY_BREAK case 12: YY_RULE_SETUP -#line 255 "scanner.l" +#line 267 "scanner.l" return IGMP; YY_BREAK case 13: YY_RULE_SETUP -#line 256 "scanner.l" +#line 268 "scanner.l" return IGRP; YY_BREAK case 14: YY_RULE_SETUP -#line 257 "scanner.l" +#line 269 "scanner.l" return PIM; YY_BREAK case 15: YY_RULE_SETUP -#line 258 "scanner.l" +#line 270 "scanner.l" return VRRP; YY_BREAK case 16: YY_RULE_SETUP -#line 259 "scanner.l" +#line 271 "scanner.l" return CARP; YY_BREAK case 17: YY_RULE_SETUP -#line 260 "scanner.l" +#line 272 "scanner.l" return RADIO; YY_BREAK case 18: YY_RULE_SETUP -#line 262 "scanner.l" +#line 274 "scanner.l" return IPV6; YY_BREAK case 19: YY_RULE_SETUP -#line 263 "scanner.l" +#line 275 "scanner.l" return ICMPV6; YY_BREAK case 20: YY_RULE_SETUP -#line 264 "scanner.l" +#line 276 "scanner.l" return AH; YY_BREAK case 21: YY_RULE_SETUP -#line 265 "scanner.l" +#line 277 "scanner.l" return ESP; YY_BREAK case 22: YY_RULE_SETUP -#line 267 "scanner.l" +#line 279 "scanner.l" return ATALK; YY_BREAK case 23: YY_RULE_SETUP -#line 268 "scanner.l" +#line 280 "scanner.l" return AARP; YY_BREAK case 24: YY_RULE_SETUP -#line 269 "scanner.l" +#line 281 "scanner.l" return DECNET; YY_BREAK case 25: YY_RULE_SETUP -#line 270 "scanner.l" +#line 282 "scanner.l" return LAT; YY_BREAK case 26: YY_RULE_SETUP -#line 271 "scanner.l" +#line 283 "scanner.l" return SCA; YY_BREAK case 27: YY_RULE_SETUP -#line 272 "scanner.l" +#line 284 "scanner.l" return MOPRC; YY_BREAK case 28: YY_RULE_SETUP -#line 273 "scanner.l" +#line 285 "scanner.l" return MOPDL; YY_BREAK case 29: YY_RULE_SETUP -#line 275 "scanner.l" +#line 287 "scanner.l" return ISO; YY_BREAK case 30: YY_RULE_SETUP -#line 276 "scanner.l" +#line 288 "scanner.l" return ESIS; YY_BREAK case 31: YY_RULE_SETUP -#line 277 "scanner.l" +#line 289 "scanner.l" return ESIS; YY_BREAK case 32: YY_RULE_SETUP -#line 278 "scanner.l" +#line 290 "scanner.l" return ISIS; YY_BREAK case 33: YY_RULE_SETUP -#line 279 "scanner.l" +#line 291 "scanner.l" return ISIS; YY_BREAK case 34: YY_RULE_SETUP -#line 280 "scanner.l" +#line 292 "scanner.l" return L1; YY_BREAK case 35: YY_RULE_SETUP -#line 281 "scanner.l" +#line 293 "scanner.l" return L2; YY_BREAK case 36: YY_RULE_SETUP -#line 282 "scanner.l" +#line 294 "scanner.l" return IIH; YY_BREAK case 37: YY_RULE_SETUP -#line 283 "scanner.l" +#line 295 "scanner.l" return LSP; YY_BREAK case 38: YY_RULE_SETUP -#line 284 "scanner.l" +#line 296 "scanner.l" return SNP; YY_BREAK case 39: YY_RULE_SETUP -#line 285 "scanner.l" +#line 297 "scanner.l" return CSNP; YY_BREAK case 40: YY_RULE_SETUP -#line 286 "scanner.l" +#line 298 "scanner.l" return PSNP; YY_BREAK case 41: YY_RULE_SETUP -#line 288 "scanner.l" +#line 300 "scanner.l" return CLNP; YY_BREAK case 42: YY_RULE_SETUP -#line 290 "scanner.l" +#line 302 "scanner.l" return STP; YY_BREAK case 43: YY_RULE_SETUP -#line 292 "scanner.l" +#line 304 "scanner.l" return IPX; YY_BREAK case 44: YY_RULE_SETUP -#line 294 "scanner.l" +#line 306 "scanner.l" return NETBEUI; YY_BREAK case 45: YY_RULE_SETUP -#line 296 "scanner.l" +#line 308 "scanner.l" return HOST; YY_BREAK case 46: YY_RULE_SETUP -#line 297 "scanner.l" +#line 309 "scanner.l" return NET; YY_BREAK case 47: YY_RULE_SETUP -#line 298 "scanner.l" +#line 310 "scanner.l" return NETMASK; YY_BREAK case 48: YY_RULE_SETUP -#line 299 "scanner.l" +#line 311 "scanner.l" return PORT; YY_BREAK case 49: YY_RULE_SETUP -#line 300 "scanner.l" +#line 312 "scanner.l" return PORTRANGE; YY_BREAK case 50: YY_RULE_SETUP -#line 301 "scanner.l" +#line 313 "scanner.l" return PROTO; YY_BREAK case 51: YY_RULE_SETUP -#line 302 "scanner.l" +#line 314 "scanner.l" { #ifdef NO_PROTOCHAIN bpf_error(yyextra, "%s not supported", yytext); @@ -3384,353 +3575,353 @@ YY_RULE_SETUP YY_BREAK case 52: YY_RULE_SETUP -#line 310 "scanner.l" +#line 322 "scanner.l" return GATEWAY; YY_BREAK case 53: YY_RULE_SETUP -#line 312 "scanner.l" +#line 324 "scanner.l" return TYPE; YY_BREAK case 54: YY_RULE_SETUP -#line 313 "scanner.l" +#line 325 "scanner.l" return SUBTYPE; YY_BREAK case 55: YY_RULE_SETUP -#line 314 "scanner.l" +#line 326 "scanner.l" return DIR; YY_BREAK case 56: YY_RULE_SETUP -#line 315 "scanner.l" +#line 327 "scanner.l" return ADDR1; YY_BREAK case 57: YY_RULE_SETUP -#line 316 "scanner.l" +#line 328 "scanner.l" return ADDR2; YY_BREAK case 58: YY_RULE_SETUP -#line 317 "scanner.l" +#line 329 "scanner.l" return ADDR3; YY_BREAK case 59: YY_RULE_SETUP -#line 318 "scanner.l" +#line 330 "scanner.l" return ADDR4; YY_BREAK case 60: YY_RULE_SETUP -#line 319 "scanner.l" +#line 331 "scanner.l" return RA; YY_BREAK case 61: YY_RULE_SETUP -#line 320 "scanner.l" +#line 332 "scanner.l" return TA; YY_BREAK case 62: YY_RULE_SETUP -#line 322 "scanner.l" +#line 334 "scanner.l" return LESS; YY_BREAK case 63: YY_RULE_SETUP -#line 323 "scanner.l" +#line 335 "scanner.l" return GREATER; YY_BREAK case 64: YY_RULE_SETUP -#line 324 "scanner.l" +#line 336 "scanner.l" return CBYTE; YY_BREAK case 65: YY_RULE_SETUP -#line 325 "scanner.l" +#line 337 "scanner.l" return TK_BROADCAST; YY_BREAK case 66: YY_RULE_SETUP -#line 326 "scanner.l" +#line 338 "scanner.l" return TK_MULTICAST; YY_BREAK case 67: YY_RULE_SETUP -#line 328 "scanner.l" +#line 340 "scanner.l" return AND; YY_BREAK case 68: YY_RULE_SETUP -#line 329 "scanner.l" +#line 341 "scanner.l" return OR; YY_BREAK case 69: YY_RULE_SETUP -#line 330 "scanner.l" +#line 342 "scanner.l" return '!'; YY_BREAK case 70: YY_RULE_SETUP -#line 332 "scanner.l" +#line 344 "scanner.l" return LEN; YY_BREAK case 71: YY_RULE_SETUP -#line 333 "scanner.l" +#line 345 "scanner.l" return INBOUND; YY_BREAK case 72: YY_RULE_SETUP -#line 334 "scanner.l" +#line 346 "scanner.l" return OUTBOUND; YY_BREAK case 73: YY_RULE_SETUP -#line 336 "scanner.l" +#line 348 "scanner.l" return VLAN; YY_BREAK case 74: YY_RULE_SETUP -#line 337 "scanner.l" +#line 349 "scanner.l" return MPLS; YY_BREAK case 75: YY_RULE_SETUP -#line 338 "scanner.l" +#line 350 "scanner.l" return PPPOED; YY_BREAK case 76: YY_RULE_SETUP -#line 339 "scanner.l" +#line 351 "scanner.l" return PPPOES; YY_BREAK case 77: YY_RULE_SETUP -#line 340 "scanner.l" +#line 352 "scanner.l" return GENEVE; YY_BREAK case 78: YY_RULE_SETUP -#line 342 "scanner.l" +#line 354 "scanner.l" return LANE; YY_BREAK case 79: YY_RULE_SETUP -#line 343 "scanner.l" +#line 355 "scanner.l" return LLC; YY_BREAK case 80: YY_RULE_SETUP -#line 344 "scanner.l" +#line 356 "scanner.l" return METAC; YY_BREAK case 81: YY_RULE_SETUP -#line 345 "scanner.l" +#line 357 "scanner.l" return BCC; YY_BREAK case 82: YY_RULE_SETUP -#line 346 "scanner.l" +#line 358 "scanner.l" return OAM; YY_BREAK case 83: YY_RULE_SETUP -#line 347 "scanner.l" +#line 359 "scanner.l" return OAMF4; YY_BREAK case 84: YY_RULE_SETUP -#line 348 "scanner.l" +#line 360 "scanner.l" return OAMF4EC; YY_BREAK case 85: YY_RULE_SETUP -#line 349 "scanner.l" +#line 361 "scanner.l" return OAMF4SC; YY_BREAK case 86: YY_RULE_SETUP -#line 350 "scanner.l" +#line 362 "scanner.l" return SC; YY_BREAK case 87: YY_RULE_SETUP -#line 351 "scanner.l" +#line 363 "scanner.l" return ILMIC; YY_BREAK case 88: YY_RULE_SETUP -#line 352 "scanner.l" +#line 364 "scanner.l" return VPI; YY_BREAK case 89: YY_RULE_SETUP -#line 353 "scanner.l" +#line 365 "scanner.l" return VCI; YY_BREAK case 90: YY_RULE_SETUP -#line 354 "scanner.l" +#line 366 "scanner.l" return CONNECTMSG; YY_BREAK case 91: YY_RULE_SETUP -#line 355 "scanner.l" +#line 367 "scanner.l" return METACONNECT; YY_BREAK case 92: YY_RULE_SETUP -#line 357 "scanner.l" +#line 369 "scanner.l" return PF_IFNAME; YY_BREAK case 93: YY_RULE_SETUP -#line 358 "scanner.l" +#line 370 "scanner.l" return PF_RSET; YY_BREAK case 94: YY_RULE_SETUP -#line 359 "scanner.l" +#line 371 "scanner.l" return PF_RNR; YY_BREAK case 95: YY_RULE_SETUP -#line 360 "scanner.l" +#line 372 "scanner.l" return PF_SRNR; YY_BREAK case 96: YY_RULE_SETUP -#line 361 "scanner.l" +#line 373 "scanner.l" return PF_REASON; YY_BREAK case 97: YY_RULE_SETUP -#line 362 "scanner.l" +#line 374 "scanner.l" return PF_ACTION; YY_BREAK case 98: YY_RULE_SETUP -#line 364 "scanner.l" +#line 376 "scanner.l" return FISU; YY_BREAK case 99: YY_RULE_SETUP -#line 365 "scanner.l" +#line 377 "scanner.l" return LSSU; YY_BREAK case 100: YY_RULE_SETUP -#line 366 "scanner.l" +#line 378 "scanner.l" return LSSU; YY_BREAK case 101: YY_RULE_SETUP -#line 367 "scanner.l" +#line 379 "scanner.l" return MSU; YY_BREAK case 102: YY_RULE_SETUP -#line 368 "scanner.l" +#line 380 "scanner.l" return HFISU; YY_BREAK case 103: YY_RULE_SETUP -#line 369 "scanner.l" +#line 381 "scanner.l" return HLSSU; YY_BREAK case 104: YY_RULE_SETUP -#line 370 "scanner.l" +#line 382 "scanner.l" return HMSU; YY_BREAK case 105: YY_RULE_SETUP -#line 371 "scanner.l" +#line 383 "scanner.l" return SIO; YY_BREAK case 106: YY_RULE_SETUP -#line 372 "scanner.l" +#line 384 "scanner.l" return OPC; YY_BREAK case 107: YY_RULE_SETUP -#line 373 "scanner.l" +#line 385 "scanner.l" return DPC; YY_BREAK case 108: YY_RULE_SETUP -#line 374 "scanner.l" +#line 386 "scanner.l" return SLS; YY_BREAK case 109: YY_RULE_SETUP -#line 375 "scanner.l" +#line 387 "scanner.l" return HSIO; YY_BREAK case 110: YY_RULE_SETUP -#line 376 "scanner.l" +#line 388 "scanner.l" return HOPC; YY_BREAK case 111: YY_RULE_SETUP -#line 377 "scanner.l" +#line 389 "scanner.l" return HDPC; YY_BREAK case 112: YY_RULE_SETUP -#line 378 "scanner.l" +#line 390 "scanner.l" return HSLS; YY_BREAK case 113: /* rule 113 can match eol */ YY_RULE_SETUP -#line 380 "scanner.l" +#line 392 "scanner.l" ; YY_BREAK case 114: YY_RULE_SETUP -#line 381 "scanner.l" +#line 393 "scanner.l" return yytext[0]; YY_BREAK case 115: YY_RULE_SETUP -#line 382 "scanner.l" +#line 394 "scanner.l" return GEQ; YY_BREAK case 116: YY_RULE_SETUP -#line 383 "scanner.l" +#line 395 "scanner.l" return LEQ; YY_BREAK case 117: YY_RULE_SETUP -#line 384 "scanner.l" +#line 396 "scanner.l" return NEQ; YY_BREAK case 118: YY_RULE_SETUP -#line 385 "scanner.l" +#line 397 "scanner.l" return '='; YY_BREAK case 119: YY_RULE_SETUP -#line 386 "scanner.l" +#line 398 "scanner.l" return LSH; YY_BREAK case 120: YY_RULE_SETUP -#line 387 "scanner.l" +#line 399 "scanner.l" return RSH; YY_BREAK case 121: YY_RULE_SETUP -#line 388 "scanner.l" +#line 400 "scanner.l" { yylval->e = pcap_ether_aton(((char *)yytext)+1); if (yylval->e == NULL) bpf_error(yyextra, "malloc"); @@ -3738,7 +3929,7 @@ YY_RULE_SETUP YY_BREAK case 122: YY_RULE_SETUP -#line 392 "scanner.l" +#line 404 "scanner.l" { yylval->e = pcap_ether_aton((char *)yytext); if (yylval->e == NULL) bpf_error(yyextra, "malloc"); @@ -3746,18 +3937,18 @@ YY_RULE_SETUP YY_BREAK case 123: YY_RULE_SETUP -#line 396 "scanner.l" +#line 408 "scanner.l" { yylval->i = stoi((char *)yytext); return NUM; } YY_BREAK case 124: YY_RULE_SETUP -#line 397 "scanner.l" +#line 409 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext); return HID; } YY_BREAK case 125: YY_RULE_SETUP -#line 399 "scanner.l" +#line 411 "scanner.l" { #ifdef INET6 struct addrinfo hints, *res; @@ -3777,167 +3968,302 @@ YY_RULE_SETUP YY_BREAK case 126: YY_RULE_SETUP -#line 415 "scanner.l" +#line 427 "scanner.l" { bpf_error(yyextra, "bogus ethernet address %s", yytext); } YY_BREAK case 127: YY_RULE_SETUP -#line 416 "scanner.l" +#line 428 "scanner.l" { yylval->i = 0; return NUM; } YY_BREAK case 128: YY_RULE_SETUP -#line 417 "scanner.l" +#line 429 "scanner.l" { yylval->i = 1; return NUM; } YY_BREAK case 129: YY_RULE_SETUP -#line 418 "scanner.l" +#line 430 "scanner.l" { yylval->i = 0; return NUM; } YY_BREAK case 130: YY_RULE_SETUP -#line 419 "scanner.l" +#line 431 "scanner.l" { yylval->i = 3; return NUM; } YY_BREAK case 131: YY_RULE_SETUP -#line 420 "scanner.l" +#line 432 "scanner.l" { yylval->i = 4; return NUM; } YY_BREAK case 132: YY_RULE_SETUP -#line 421 "scanner.l" +#line 433 "scanner.l" { yylval->i = 5; return NUM; } YY_BREAK case 133: YY_RULE_SETUP -#line 422 "scanner.l" +#line 434 "scanner.l" { yylval->i = 8; return NUM; } YY_BREAK case 134: YY_RULE_SETUP -#line 423 "scanner.l" +#line 435 "scanner.l" { yylval->i = 9; return NUM; } YY_BREAK case 135: YY_RULE_SETUP -#line 424 "scanner.l" +#line 436 "scanner.l" { yylval->i = 10; return NUM; } YY_BREAK case 136: YY_RULE_SETUP -#line 425 "scanner.l" +#line 437 "scanner.l" { yylval->i = 11; return NUM; } YY_BREAK case 137: YY_RULE_SETUP -#line 426 "scanner.l" +#line 438 "scanner.l" { yylval->i = 12; return NUM; } YY_BREAK case 138: YY_RULE_SETUP -#line 427 "scanner.l" +#line 439 "scanner.l" { yylval->i = 13; return NUM; } YY_BREAK case 139: YY_RULE_SETUP -#line 428 "scanner.l" +#line 440 "scanner.l" { yylval->i = 14; return NUM; } YY_BREAK case 140: YY_RULE_SETUP -#line 429 "scanner.l" +#line 441 "scanner.l" { yylval->i = 15; return NUM; } YY_BREAK case 141: YY_RULE_SETUP -#line 430 "scanner.l" +#line 442 "scanner.l" { yylval->i = 16; return NUM; } YY_BREAK case 142: YY_RULE_SETUP -#line 431 "scanner.l" +#line 443 "scanner.l" { yylval->i = 17; return NUM; } YY_BREAK case 143: YY_RULE_SETUP -#line 432 "scanner.l" +#line 444 "scanner.l" { yylval->i = 18; return NUM; } YY_BREAK case 144: YY_RULE_SETUP -#line 433 "scanner.l" -{ yylval->i = 13; return NUM; } +#line 446 "scanner.l" +{ yylval->i = 0; return NUM; } YY_BREAK case 145: YY_RULE_SETUP -#line 434 "scanner.l" -{ yylval->i = 0x01; return NUM; } +#line 447 "scanner.l" +{ yylval->i = 1; return NUM; } YY_BREAK case 146: YY_RULE_SETUP -#line 435 "scanner.l" -{ yylval->i = 0x02; return NUM; } +#line 449 "scanner.l" +{ yylval->i = 128; return NUM; } YY_BREAK case 147: YY_RULE_SETUP -#line 436 "scanner.l" -{ yylval->i = 0x04; return NUM; } +#line 450 "scanner.l" +{ yylval->i = 129; return NUM; } YY_BREAK case 148: YY_RULE_SETUP -#line 437 "scanner.l" -{ yylval->i = 0x08; return NUM; } +#line 451 "scanner.l" +{ yylval->i = 130; return NUM; } YY_BREAK case 149: YY_RULE_SETUP -#line 438 "scanner.l" -{ yylval->i = 0x10; return NUM; } +#line 452 "scanner.l" +{ yylval->i = 131; return NUM; } YY_BREAK case 150: YY_RULE_SETUP -#line 439 "scanner.l" -{ yylval->i = 0x20; return NUM; } +#line 453 "scanner.l" +{ yylval->i = 132; return NUM; } YY_BREAK case 151: YY_RULE_SETUP -#line 440 "scanner.l" -{ yylval->i = 0x40; return NUM; } +#line 454 "scanner.l" +{ yylval->i = 133; return NUM; } YY_BREAK case 152: YY_RULE_SETUP -#line 441 "scanner.l" -{ yylval->i = 0x80; return NUM; } +#line 455 "scanner.l" +{ yylval->i = 134; return NUM; } YY_BREAK case 153: YY_RULE_SETUP -#line 442 "scanner.l" +#line 456 "scanner.l" +{ yylval->i = 135; return NUM; } + YY_BREAK +case 154: +YY_RULE_SETUP +#line 457 "scanner.l" +{ yylval->i = 136; return NUM; } + YY_BREAK +case 155: +YY_RULE_SETUP +#line 458 "scanner.l" +{ yylval->i = 137; return NUM; } + YY_BREAK +case 156: +YY_RULE_SETUP +#line 459 "scanner.l" +{ yylval->i = 138; return NUM; } + YY_BREAK +case 157: +YY_RULE_SETUP +#line 460 "scanner.l" +{ yylval->i = 139; return NUM; } + YY_BREAK +case 158: +YY_RULE_SETUP +#line 461 "scanner.l" +{ yylval->i = 140; return NUM; } + YY_BREAK +case 159: +YY_RULE_SETUP +#line 462 "scanner.l" +{ yylval->i = 141; return NUM; } + YY_BREAK +case 160: +YY_RULE_SETUP +#line 463 "scanner.l" +{ yylval->i = 142; return NUM; } + YY_BREAK +case 161: +YY_RULE_SETUP +#line 464 "scanner.l" +{ yylval->i = 143; return NUM; } + YY_BREAK +case 162: +YY_RULE_SETUP +#line 465 "scanner.l" +{ yylval->i = 144; return NUM; } + YY_BREAK +case 163: +YY_RULE_SETUP +#line 466 "scanner.l" +{ yylval->i = 145; return NUM; } + YY_BREAK +case 164: +YY_RULE_SETUP +#line 467 "scanner.l" +{ yylval->i = 146; return NUM; } + YY_BREAK +case 165: +YY_RULE_SETUP +#line 468 "scanner.l" +{ yylval->i = 147; return NUM; } + YY_BREAK +case 166: +YY_RULE_SETUP +#line 469 "scanner.l" +{ yylval->i = 148; return NUM; } + YY_BREAK +case 167: +YY_RULE_SETUP +#line 470 "scanner.l" +{ yylval->i = 149; return NUM; } + YY_BREAK +case 168: +YY_RULE_SETUP +#line 471 "scanner.l" +{ yylval->i = 151; return NUM; } + YY_BREAK +case 169: +YY_RULE_SETUP +#line 472 "scanner.l" +{ yylval->i = 152; return NUM; } + YY_BREAK +case 170: +YY_RULE_SETUP +#line 473 "scanner.l" +{ yylval->i = 153; return NUM; } + YY_BREAK +case 171: +YY_RULE_SETUP +#line 475 "scanner.l" +{ yylval->i = 13; return NUM; } + YY_BREAK +case 172: +YY_RULE_SETUP +#line 476 "scanner.l" +{ yylval->i = 0x01; return NUM; } + YY_BREAK +case 173: +YY_RULE_SETUP +#line 477 "scanner.l" +{ yylval->i = 0x02; return NUM; } + YY_BREAK +case 174: +YY_RULE_SETUP +#line 478 "scanner.l" +{ yylval->i = 0x04; return NUM; } + YY_BREAK +case 175: +YY_RULE_SETUP +#line 479 "scanner.l" +{ yylval->i = 0x08; return NUM; } + YY_BREAK +case 176: +YY_RULE_SETUP +#line 480 "scanner.l" +{ yylval->i = 0x10; return NUM; } + YY_BREAK +case 177: +YY_RULE_SETUP +#line 481 "scanner.l" +{ yylval->i = 0x20; return NUM; } + YY_BREAK +case 178: +YY_RULE_SETUP +#line 482 "scanner.l" +{ yylval->i = 0x40; return NUM; } + YY_BREAK +case 179: +YY_RULE_SETUP +#line 483 "scanner.l" +{ yylval->i = 0x80; return NUM; } + YY_BREAK +case 180: +YY_RULE_SETUP +#line 484 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext); return ID; } YY_BREAK -case 154: +case 181: YY_RULE_SETUP -#line 444 "scanner.l" +#line 486 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; } YY_BREAK -case 155: +case 182: YY_RULE_SETUP -#line 445 "scanner.l" +#line 487 "scanner.l" { bpf_error(yyextra, "illegal token: %s", yytext); } YY_BREAK -case 156: +case 183: YY_RULE_SETUP -#line 447 "scanner.l" +#line 489 "scanner.l" { bpf_error(yyextra, "illegal char '%c'", *yytext); } YY_BREAK -case 157: +case 184: YY_RULE_SETUP -#line 448 "scanner.l" +#line 490 "scanner.l" ECHO; YY_BREAK -#line 3941 "scanner.c" +#line 4267 "scanner.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -4232,7 +4558,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1470 ) + if ( yy_current_state >= 1729 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -4261,11 +4587,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1470 ) + if ( yy_current_state >= 1729 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 1469); + yy_is_jam = (yy_current_state == 1728); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -5064,14 +5390,18 @@ void pcap_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 448 "scanner.l" +#line 490 "scanner.l" + +/* + * 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'; @@ -5086,8 +5416,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; diff --git a/freebsd/contrib/libpcap/scanner.h b/freebsd/contrib/libpcap/scanner.h index 1aea2cc7..48ed6ee4 100644 --- a/freebsd/contrib/libpcap/scanner.h +++ b/freebsd/contrib/libpcap/scanner.h @@ -6,12 +6,34 @@ #line 2 "scanner.l" /* 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" + -#line 15 "scanner.h" +#line 37 "scanner.h" #define YY_INT_ALIGNED short int @@ -354,9 +376,9 @@ extern int pcap_lex \ #undef YY_DECL #endif -#line 448 "scanner.l" +#line 490 "scanner.l" -#line 361 "scanner.h" +#line 383 "scanner.h" #undef pcap_IN_HEADER #endif /* pcap_HEADER_H */ 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; diff --git a/freebsd/contrib/libpcap/sf-pcap.c b/freebsd/contrib/libpcap/sf-pcap.c index d7cb806f..c9ac143d 100644 --- a/freebsd/contrib/libpcap/sf-pcap.c +++ b/freebsd/contrib/libpcap/sf-pcap.c @@ -30,27 +30,14 @@ * dependent values so we can print the dump file on any architecture. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header$ (LBL)"; -#endif - #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif +#include <pcap-types.h> #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> +#include <io.h> +#include <fcntl.h> #endif /* _WIN32 */ #include <errno.h> @@ -187,9 +174,8 @@ pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, sizeof(hdr) - sizeof(hdr.magic), fp); if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) { if (ferror(fp)) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "error reading dump file"); } else { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "truncated dump file; tried to read %lu file header bytes, only got %lu", @@ -234,14 +220,6 @@ pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, return NULL; } - if (hdr.snaplen > MAXIMUM_SNAPLEN) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "invalid file capture length %u, bigger than " - "maximum of %u", hdr.snaplen, MAXIMUM_SNAPLEN); - *err = 1; - return NULL; - } - /* * OK, this is a good pcap file. * Allocate a pcap_t for it. @@ -257,6 +235,17 @@ pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, p->version_minor = hdr.version_minor; p->tzoff = hdr.thiszone; p->snapshot = hdr.snaplen; + if (p->snapshot <= 0) { + /* + * Bogus snapshot length; use the maximum for this + * link-layer type as a fallback. + * + * XXX - the only reason why snapshot is signed is + * that pcap_snapshot() returns an int, not an + * unsigned int. + */ + p->snapshot = max_snaplen_for_dlt(hdr.linktype); + } p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype)); p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype); @@ -392,14 +381,16 @@ pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, /* * Allocate a buffer for the packet data. + * Choose the minimum of the file's snapshot length and 2K bytes; + * that should be enough for most network packets - we'll grow it + * if necessary. That way, we don't allocate a huge chunk of + * memory just because there's a huge snapshot length, as the + * snapshot length might be larger than the size of the largest + * packet. */ p->bufsize = p->snapshot; - if (p->bufsize <= 0) { - /* - * Bogus snapshot length; use the maximum as a fallback. - */ - p->bufsize = MAXIMUM_SNAPLEN; - } + if (p->bufsize > 2048) + p->bufsize = 2048; p->buffer = malloc(p->bufsize); if (p->buffer == NULL) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory"); @@ -414,6 +405,24 @@ pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, } /* + * Grow the packet buffer to the specified size. + */ +static int +grow_buffer(pcap_t *p, u_int bufsize) +{ + void *bigger_buffer; + + bigger_buffer = realloc(p->buffer, bufsize); + if (bigger_buffer == NULL) { + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "out of memory"); + return (0); + } + p->buffer = bigger_buffer; + p->bufsize = bufsize; + return (1); +} + +/* * Read and return the next packet from the savefile. Return the header * in hdr and a pointer to the contents in data. Return 0 on success, 1 * if there were no more packets, and -1 on an error. @@ -437,9 +446,8 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) amt_read = fread(&sf_hdr, 1, ps->hdrsize, fp); if (amt_read != ps->hdrsize) { if (ferror(fp)) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "error reading dump file"); return (-1); } else { if (amt_read != 0) { @@ -515,41 +523,87 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) break; } - if (hdr->caplen > p->bufsize) { + /* + * Is the packet bigger than we consider sane? + */ + if (hdr->caplen > max_snaplen_for_dlt(p->linktype)) { + /* + * Yes. This may be a damaged or fuzzed file. + * + * Is it bigger than the snapshot length? + * (We don't treat that as an error if it's not + * bigger than the maximum we consider sane; see + * below.) + */ + if (hdr->caplen > (bpf_u_int32)p->snapshot) { + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "invalid packet capture length %u, bigger than " + "snaplen of %d", hdr->caplen, p->snapshot); + } else { + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "invalid packet capture length %u, bigger than " + "maximum of %u", hdr->caplen, + max_snaplen_for_dlt(p->linktype)); + } + return (-1); + } + + if (hdr->caplen > (bpf_u_int32)p->snapshot) { /* + * The packet is bigger than the snapshot length + * for this file. + * * This can happen due to Solaris 2.3 systems tripping * over the BUFMOD problem and not setting the snapshot - * correctly in the savefile header. - * This can also happen with a corrupted savefile or a - * savefile built/modified by a fuzz tester. - * If the caplen isn't grossly wrong, try to salvage. + * length correctly in the savefile header. + * + * libpcap 0.4 and later on Solaris 2.3 should set the + * snapshot length correctly in the pcap file header, + * even though they don't set a snapshot length in bufmod + * (the buggy bufmod chops off the *beginning* of the + * packet if a snapshot length is specified); they should + * also reduce the captured length, as supplied to the + * per-packet callback, to the snapshot length if it's + * greater than the snapshot length, so the code using + * libpcap should see the packet cut off at the snapshot + * length, even though the full packet is copied up to + * userland. + * + * However, perhaps some versions of libpcap failed to + * set the snapshot length currectly in the file header + * or the per-packet header, or perhaps this is a + * corrupted safefile or a savefile built/modified by a + * fuzz tester, so we check anyway. We grow the buffer + * to be big enough for the snapshot length, read up + * to the snapshot length, discard the rest of the + * packet, and report the snapshot length as the captured + * length; we don't want to hand our caller a packet + * bigger than the snapshot length, because they might + * be assuming they'll never be handed such a packet, + * and might copy the packet into a snapshot-length- + * sized buffer, assuming it'll fit. */ size_t bytes_to_discard; size_t bytes_to_read, bytes_read; char discard_buf[4096]; - if (hdr->caplen > MAXIMUM_SNAPLEN) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "invalid packet capture length %u, bigger than " - "maximum of %u", hdr->caplen, MAXIMUM_SNAPLEN); - return (-1); + if (hdr->caplen > p->bufsize) { + /* + * Grow the buffer to the snapshot length. + */ + if (!grow_buffer(p, p->snapshot)) + return (-1); } /* - * XXX - we don't grow the buffer here because some - * program might assume that it will never get packets - * bigger than the snapshot length; for example, it might - * copy data from our buffer to a buffer of its own, - * allocated based on the return value of pcap_snapshot(). - * - * Read the first p->bufsize bytes into the buffer. + * Read the first p->snapshot bytes into the buffer. */ - amt_read = fread(p->buffer, 1, p->bufsize, fp); - if (amt_read != p->bufsize) { + amt_read = fread(p->buffer, 1, p->snapshot, fp); + if (amt_read != (bpf_u_int32)p->snapshot) { if (ferror(fp)) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "error reading dump file"); } else { /* * Yes, this uses hdr->caplen; technically, @@ -560,7 +614,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) */ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "truncated dump file; tried to read %u captured bytes, only got %lu", - hdr->caplen, (unsigned long)amt_read); + p->snapshot, (unsigned long)amt_read); } return (-1); } @@ -568,7 +622,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) /* * Now read and discard what's left. */ - bytes_to_discard = hdr->caplen - p->bufsize; + bytes_to_discard = hdr->caplen - p->snapshot; bytes_read = amt_read; while (bytes_to_discard != 0) { bytes_to_read = bytes_to_discard; @@ -578,9 +632,9 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) bytes_read += amt_read; if (amt_read != bytes_to_read) { if (ferror(fp)) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "error reading dump file"); } else { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "truncated dump file; tried to read %u captured bytes, only got %lu", @@ -595,15 +649,41 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) * Adjust caplen accordingly, so we don't get confused later * as to how many bytes we have to play with. */ - hdr->caplen = p->bufsize; + hdr->caplen = p->snapshot; } else { + if (hdr->caplen > p->bufsize) { + /* + * Grow the buffer to the next power of 2, or + * the snaplen, whichever is lower. + */ + u_int new_bufsize; + + new_bufsize = hdr->caplen; + /* + * http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 + */ + new_bufsize--; + new_bufsize |= new_bufsize >> 1; + new_bufsize |= new_bufsize >> 2; + new_bufsize |= new_bufsize >> 4; + new_bufsize |= new_bufsize >> 8; + new_bufsize |= new_bufsize >> 16; + new_bufsize++; + + if (new_bufsize > (u_int)p->snapshot) + new_bufsize = p->snapshot; + + if (!grow_buffer(p, new_bufsize)) + return (-1); + } + /* read the packet itself */ amt_read = fread(p->buffer, 1, hdr->caplen, fp); if (amt_read != hdr->caplen) { if (ferror(fp)) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, + PCAP_ERRBUF_SIZE, errno, + "error reading dump file"); } else { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "truncated dump file; tried to read %u captured bytes, only got %lu", @@ -674,11 +754,11 @@ pcap_setup_dump(pcap_t *p, int linktype, FILE *f, const char *fname) if (f == stdout) SET_BINMODE(f); else - setbuf(f, NULL); + setvbuf(f, NULL, _IONBF, 0); #endif if (sf_write_header(p, f, linktype, p->tzoff, p->snapshot) == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't write to %s: %s", - fname, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "Can't write to %s", fname); if (f != stdout) (void)fclose(f); return (NULL); @@ -723,14 +803,16 @@ pcap_dump_open(pcap_t *p, const char *fname) f = stdout; fname = "standard output"; } else { -#if !defined(_WIN32) && !defined(MSDOS) - f = fopen(fname, "w"); -#else + /* + * "b" is supported as of C90, so *all* UN*Xes should + * support it, even though it does nothing. It's + * required on Windows, as the file is a binary file + * and must be written in binary mode. + */ f = fopen(fname, "wb"); -#endif if (f == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", - fname, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "%s", fname); return (NULL); } } @@ -781,14 +863,15 @@ pcap_dump_open_append(pcap_t *p, const char *fname) if (fname[0] == '-' && fname[1] == '\0') return (pcap_setup_dump(p, linktype, stdout, "standard output")); -#if !defined(_WIN32) && !defined(MSDOS) - f = fopen(fname, "r+"); -#else + /* + * "b" is supported as of C90, so *all* UN*Xes should support it, + * even though it does nothing. It's required on Windows, as the + * file is a binary file and must be read in binary mode. + */ f = fopen(fname, "rb+"); -#endif if (f == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", - fname, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "%s", fname); return (NULL); } @@ -798,8 +881,8 @@ pcap_dump_open_append(pcap_t *p, const char *fname) amt_read = fread(&ph, 1, sizeof (ph), f); if (amt_read != sizeof (ph)) { if (ferror(f)) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", - fname, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "%s", fname); fclose(f); return (NULL); } else if (feof(f) && amt_read > 0) { @@ -815,7 +898,7 @@ pcap_dump_open_append(pcap_t *p, const char *fname) * We turn off buffering. * XXX - why? And why not on the standard output? */ - setbuf(f, NULL); + setvbuf(f, NULL, _IONBF, 0); #endif /* @@ -906,8 +989,8 @@ pcap_dump_open_append(pcap_t *p, const char *fname) * A header isn't present; attempt to write it. */ if (sf_write_header(p, f, linktype, p->tzoff, p->snapshot) == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't write to %s: %s", - fname, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "Can't write to %s", fname); (void)fclose(f); return (NULL); } @@ -917,8 +1000,8 @@ pcap_dump_open_append(pcap_t *p, const char *fname) * Start writing at the end of the file. */ if (fseek(f, 0, SEEK_END) == -1) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't seek to end of %s: %s", - fname, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "Can't seek to end of %s", fname); (void)fclose(f); return (NULL); } @@ -937,6 +1020,45 @@ pcap_dump_ftell(pcap_dumper_t *p) return (ftell((FILE *)p)); } +#if defined(HAVE_FSEEKO) +/* + * We have fseeko(), so we have ftello(). + * If we have large file support (files larger than 2^31-1 bytes), + * ftello() will give us a current file position with more than 32 + * bits. + */ +int64_t +pcap_dump_ftell64(pcap_dumper_t *p) +{ + return (ftello((FILE *)p)); +} +#elif defined(_MSC_VER) +/* + * We have Visual Studio; we support only 2005 and later, so we have + * _ftelli64(). + */ +int64_t +pcap_dump_ftell64(pcap_dumper_t *p) +{ + return (_ftelli64((FILE *)p)); +} +#else +/* + * We don't have ftello() or _ftelli64(), so fall back on ftell(). + * Either long is 64 bits, in which case ftell() should suffice, + * or this is probably an older 32-bit UN*X without large file + * support, which means you'll probably get errors trying to + * write files > 2^31-1, so it won't matter anyway. + * + * XXX - what about MinGW? + */ +int64_t +pcap_dump_ftell64(pcap_dumper_t *p) +{ + return (ftell((FILE *)p)); +} +#endif + int pcap_dump_flush(pcap_dumper_t *p) { diff --git a/freebsd/contrib/libpcap/sf-pcap-ng.c b/freebsd/contrib/libpcap/sf-pcapng.c index 209c1424..f5719042 100644 --- a/freebsd/contrib/libpcap/sf-pcap-ng.c +++ b/freebsd/contrib/libpcap/sf-pcapng.c @@ -20,31 +20,14 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * sf-pcap-ng.c - pcap-ng-file-format-specific code from savefile.c + * sf-pcapng.c - pcapng-file-format-specific code from savefile.c */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header$ (LBL)"; -#endif - #ifdef HAVE_CONFIG_H -#include "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 <pcap/pcap-inttypes.h> #include <errno.h> #include <memory.h> @@ -60,7 +43,7 @@ static const char rcsid[] _U_ = #include "os-proto.h" #endif -#include "sf-pcap-ng.h" +#include "sf-pcapng.h" /* * Block types. @@ -109,7 +92,7 @@ struct section_header_block { bpf_u_int32 byte_order_magic; u_short major_version; u_short minor_version; - u_int64_t section_length; + uint64_t section_length; /* followed by options and trailer */ }; @@ -219,16 +202,48 @@ struct pcap_ng_if { u_int tsresol; /* time stamp resolution */ tstamp_scale_type_t scale_type; /* how to scale */ u_int scale_factor; /* time stamp scale factor for power-of-10 tsresol */ - u_int64_t tsoffset; /* time stamp offset */ + uint64_t tsoffset; /* time stamp offset */ }; +/* + * Per-pcap_t private data. + * + * max_blocksize is the maximum size of a block that we'll accept. We + * reject blocks bigger than this, so we don't consume too much memory + * with a truly huge block. It can change as we see IDBs with different + * link-layer header types. (Currently, we don't support IDBs with + * different link-layer header types, but we will support it in the + * future, when we offer file-reading APIs that support it.) + * + * XXX - that's an issue on ILP32 platforms, where the maximum block + * size of 2^31-1 would eat all but one byte of the entire address space. + * It's less of an issue on ILP64/LLP64 platforms, but the actual size + * of the address space may be limited by 1) the number of *significant* + * address bits (currently, x86-64 only supports 48 bits of address), 2) + * any limitations imposed by the operating system; 3) any limitations + * imposed by the amount of available backing store for anonymous pages, + * so we impose a limit regardless of the size of a pointer. + */ struct pcap_ng_sf { u_int user_tsresol; /* time stamp resolution requested by the user */ + u_int max_blocksize; /* don't grow buffer size past this */ bpf_u_int32 ifcount; /* number of interfaces seen in this capture */ bpf_u_int32 ifaces_size; /* size of array below */ struct pcap_ng_if *ifaces; /* array of interface information */ }; +/* + * Maximum block size for a given maximum snapshot length; we calculate + * this based + * + * We define it as the size of an EPB with a max_snaplen-sized + * packet and 128KB of options. + */ +#define MAX_BLOCKSIZE(max_snaplen) (sizeof (struct block_header) + \ + sizeof (struct enhanced_packet_block) + \ + (max_snaplen) + 131072 + \ + sizeof (struct block_trailer)) + static void pcap_ng_cleanup(pcap_t *p); static int pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data); @@ -242,9 +257,8 @@ read_bytes(FILE *fp, void *buf, size_t bytes_to_read, int fail_on_eof, amt_read = fread(buf, 1, bytes_to_read, fp); if (amt_read != bytes_to_read) { if (ferror(fp)) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "error reading dump file"); } else { if (amt_read == 0 && !fail_on_eof) return (0); /* EOF */ @@ -261,11 +275,14 @@ read_bytes(FILE *fp, void *buf, size_t bytes_to_read, int fail_on_eof, static int read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf) { + struct pcap_ng_sf *ps; int status; struct block_header bhdr; u_char *bdata; size_t data_remaining; + ps = p->priv; + status = read_bytes(fp, &bhdr, sizeof(bhdr), 0, errbuf); if (status <= 0) return (status); /* error or EOF */ @@ -284,7 +301,7 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf) */ if (bhdr.total_length > 16*1024*1024) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "pcap-ng block size %u > maximum %u", + "pcapng block size %u > maximum %u", bhdr.total_length, 16*1024*1024); return (-1); } @@ -296,7 +313,7 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf) if (bhdr.total_length < sizeof(struct block_header) + sizeof(struct block_trailer)) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "block in pcap-ng dump file has a length of %u < %lu", + "block in pcapng dump file has a length of %u < %lu", bhdr.total_length, (unsigned long)(sizeof(struct block_header) + sizeof(struct block_trailer))); return (-1); @@ -307,10 +324,15 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf) */ if (p->bufsize < bhdr.total_length) { /* - * No - make it big enough. + * No - make it big enough, unless it's too big. */ void *bigger_buffer; + if (bhdr.total_length > ps->max_blocksize) { + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "block is larger than maximum block size %u", + ps->max_blocksize); + return (-1); + } bigger_buffer = realloc(p->buffer, bhdr.total_length); if (bigger_buffer == NULL) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory"); @@ -350,7 +372,7 @@ get_from_block_data(struct block_cursor *cursor, size_t chunk_size, */ if (cursor->data_remaining < chunk_size) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "block of type %u in pcap-ng dump file is too short", + "block of type %u in pcapng dump file is too short", cursor->block_type); return (NULL); } @@ -412,7 +434,7 @@ get_optvalue_from_block_data(struct block_cursor *cursor, static int process_idb_options(pcap_t *p, struct block_cursor *cursor, u_int *tsresol, - u_int64_t *tsoffset, int *is_binary, char *errbuf) + uint64_t *tsoffset, int *is_binary, char *errbuf) { struct option_header *opthdr; void *optvalue; @@ -535,7 +557,7 @@ add_interface(pcap_t *p, struct block_cursor *cursor, char *errbuf) { struct pcap_ng_sf *ps; u_int tsresol; - u_int64_t tsoffset; + uint64_t tsoffset; int is_binary; ps = p->priv; @@ -569,7 +591,7 @@ add_interface(pcap_t *p, struct block_cursor *cursor, char *errbuf) * However, it doesn't complain that one of the * multiplications below could overflow, which is * a real, albeit extremely unlikely, problem (you'd - * need a pcap-ng file with tens of millions of + * need a pcapng file with tens of millions of * interfaces).) */ new_ifaces_size = 1; @@ -701,7 +723,7 @@ add_interface(pcap_t *p, struct block_cursor *cursor, char *errbuf) } /* - * Check whether this is a pcap-ng savefile and, if it is, extract the + * Check whether this is a pcapng savefile and, if it is, extract the * relevant information from the header. */ pcap_t * @@ -727,7 +749,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, /* * Check whether the first 4 bytes of the file are the block - * type for a pcap-ng savefile. + * type for a pcapng savefile. */ if (magic != BT_SHB) { /* @@ -736,7 +758,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, * UN*X and DOS/Windows text file format and, if it * does, look for the byte-order magic number in * the appropriate place and, if we find it, report - * this as possibly being a pcap-ng file transferred + * this as possibly being a pcapng file transferred * between UN*X and Windows in text file format? */ return (NULL); /* nope */ @@ -756,32 +778,30 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, amt_read = fread(&total_length, 1, sizeof(total_length), fp); if (amt_read < sizeof(total_length)) { if (ferror(fp)) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "error reading dump file"); *err = 1; return (NULL); /* fail */ } /* * Possibly a weird short text file, so just say - * "not pcap-ng". + * "not pcapng". */ return (NULL); } amt_read = fread(&byte_order_magic, 1, sizeof(byte_order_magic), fp); if (amt_read < sizeof(byte_order_magic)) { if (ferror(fp)) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "error reading dump file: %s", - pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "error reading dump file"); *err = 1; return (NULL); /* fail */ } /* * Possibly a weird short text file, so just say - * "not pcap-ng". + * "not pcapng". */ return (NULL); } @@ -789,7 +809,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, byte_order_magic = SWAPLONG(byte_order_magic); if (byte_order_magic != BYTE_ORDER_MAGIC) { /* - * Not a pcap-ng file. + * Not a pcapng file. */ return (NULL); } @@ -802,7 +822,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, */ if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "Section Header Block in pcap-ng dump file has a length of %u < %lu", + "Section Header Block in pcapng dump file has a length of %u < %lu", total_length, (unsigned long)(sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer))); *err = 1; @@ -810,7 +830,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, } /* - * OK, this is a good pcap-ng file. + * OK, this is a good pcapng file. * Allocate a pcap_t for it. */ p = pcap_open_offline_common(errbuf, sizeof (struct pcap_ng_sf)); @@ -855,7 +875,11 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, * Packet Block containing a full-size Ethernet frame, and * leaving room for some options. * - * If we find a bigger block, we reallocate the buffer. + * If we find a bigger block, we reallocate the buffer, up to + * the maximum size. We start out with a maximum size based + * on a maximum snapshot length of MAXIMUM_SNAPLEN; if we see + * any link-layer header types with a larger maximum snapshot + * length, we boost the maximum. */ p->bufsize = 2048; if (p->bufsize < total_length) @@ -867,6 +891,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, *err = 1; return (NULL); } + ps->max_blocksize = MAX_BLOCKSIZE(MAXIMUM_SNAPLEN); /* * Copy the stuff we've read to the buffer, and read the rest @@ -898,7 +923,7 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, if (! (shbp->major_version == PCAP_NG_VERSION_MAJOR && shbp->minor_version == PCAP_NG_VERSION_MINOR)) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "unsupported pcap-ng savefile version %u.%u", + "unsupported pcapng savefile version %u.%u", shbp->major_version, shbp->minor_version); goto fail; } @@ -947,17 +972,6 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, } /* - * Interface capture length sanity check - */ - if (idbp->snaplen > MAXIMUM_SNAPLEN) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "invalid interface capture length %u, " - "bigger than maximum of %u", - idbp->snaplen, MAXIMUM_SNAPLEN); - goto fail; - } - - /* * Try to add this interface. */ if (!add_interface(p, &cursor, errbuf)) @@ -988,9 +1002,28 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, done: p->tzoff = 0; /* XXX - not used in pcap */ p->snapshot = idbp->snaplen; + if (p->snapshot <= 0) { + /* + * Bogus snapshot length; use the maximum for this + * link-layer type as a fallback. + * + * XXX - the only reason why snapshot is signed is + * that pcap_snapshot() returns an int, not an + * unsigned int. + */ + p->snapshot = max_snaplen_for_dlt(idbp->linktype); + } p->linktype = linktype_to_dlt(idbp->linktype); p->linktype_ext = 0; + /* + * If the maximum block size for a packet with the maximum + * snapshot length for this DLT_ is bigger than the current + * maximum block size, increase the maximum. + */ + if (MAX_BLOCKSIZE(max_snaplen_for_dlt(p->linktype)) > ps->max_blocksize) + ps->max_blocksize = MAX_BLOCKSIZE(max_snaplen_for_dlt(p->linktype)); + p->next_packet_op = pcap_ng_next_packet; p->cleanup_op = pcap_ng_cleanup; @@ -1031,7 +1064,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) struct interface_description_block *idbp; struct section_header_block *shbp; FILE *fp = p->rfile; - u_int64_t t, sec, frac; + uint64_t t, sec, frac; /* * Look for an Enhanced Packet Block, a Simple Packet Block, @@ -1067,13 +1100,13 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) interface_id = SWAPLONG(epbp->interface_id); hdr->caplen = SWAPLONG(epbp->caplen); hdr->len = SWAPLONG(epbp->len); - t = ((u_int64_t)SWAPLONG(epbp->timestamp_high)) << 32 | + t = ((uint64_t)SWAPLONG(epbp->timestamp_high)) << 32 | SWAPLONG(epbp->timestamp_low); } else { interface_id = epbp->interface_id; hdr->caplen = epbp->caplen; hdr->len = epbp->len; - t = ((u_int64_t)epbp->timestamp_high) << 32 | + t = ((uint64_t)epbp->timestamp_high) << 32 | epbp->timestamp_low; } goto found; @@ -1132,13 +1165,13 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) interface_id = SWAPSHORT(pbp->interface_id); hdr->caplen = SWAPLONG(pbp->caplen); hdr->len = SWAPLONG(pbp->len); - t = ((u_int64_t)SWAPLONG(pbp->timestamp_high)) << 32 | + t = ((uint64_t)SWAPLONG(pbp->timestamp_high)) << 32 | SWAPLONG(pbp->timestamp_low); } else { interface_id = pbp->interface_id; hdr->caplen = pbp->caplen; hdr->len = pbp->len; - t = ((u_int64_t)pbp->timestamp_high) << 32 | + t = ((uint64_t)pbp->timestamp_high) << 32 | pbp->timestamp_low; } goto found; @@ -1247,7 +1280,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) */ if (shbp->major_version != PCAP_NG_VERSION_MAJOR) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "unknown pcap-ng savefile major version number %u", + "unknown pcapng savefile major version number %u", shbp->major_version); return (-1); } @@ -1286,6 +1319,13 @@ found: return (-1); } + if (hdr->caplen > (bpf_u_int32)p->snapshot) { + pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "invalid packet capture length %u, bigger than " + "snaplen of %d", hdr->caplen, p->snapshot); + return (-1); + } + /* * Convert the time stamp to seconds and fractions of a second, * with the fractions being in units of the file-supplied resolution. diff --git a/freebsd/contrib/libpcap/sf-pcap-ng.h b/freebsd/contrib/libpcap/sf-pcapng.h index 3c93498f..d99b0d4e 100644 --- a/freebsd/contrib/libpcap/sf-pcap-ng.h +++ b/freebsd/contrib/libpcap/sf-pcapng.h @@ -18,13 +18,13 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * sf-pcap-ng.h - pcap-ng-file-format-specific routines + * sf-pcapng.h - pcapng-file-format-specific routines * - * Used to read pcap-ng savefiles. + * Used to read pcapng savefiles. */ -#ifndef sf_pcap_ng_h -#define sf_pcap_ng_h +#ifndef sf_pcapng_h +#define sf_pcapng_h extern pcap_t *pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, int *err); diff --git a/freebsd/contrib/libpcap/varattrs.h b/freebsd/contrib/libpcap/varattrs.h new file mode 100644 index 00000000..05bfe8cd --- /dev/null +++ b/freebsd/contrib/libpcap/varattrs.h @@ -0,0 +1,59 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * 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 the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef varattrs_h +#define varattrs_h + +#include <pcap/compiler-tests.h> + +/* + * Attributes to apply to variables, using various compiler-specific + * extensions. + */ + +#if __has_attribute(unused) \ + || PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) + /* + * Compiler with support for __attribute__((unused)), or GCC 2.0 and + * later, so it supports __attribute__((unused)). + */ + #define _U_ __attribute__((unused)) +#else + /* + * We don't know of any way to mark a variable as unused. + */ + #define _U_ +#endif + +#endif diff --git a/freebsd/contrib/libxo/libxo/libxo.c b/freebsd/contrib/libxo/libxo/libxo.c index 4577adb2..2a78aea1 100644 --- a/freebsd/contrib/libxo/libxo/libxo.c +++ b/freebsd/contrib/libxo/libxo/libxo.c @@ -4182,6 +4182,59 @@ xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip, } } +/* + * strspn() with a string length + */ +static ssize_t +xo_strnspn (const char *str, size_t len, const char *accept) +{ + ssize_t i; + const char *cp, *ep; + + for (i = 0, cp = str, ep = str + len; cp < ep && *cp != '\0'; i++, cp++) { + if (strchr(accept, *cp) == NULL) + break; + } + + return i; +} + +/* + * Decide if a format string should be considered "numeric", + * in the sense that the number does not need to be quoted. + * This means that it consists only of a single numeric field + * with nothing exotic or "interesting". This means that + * static values are never considered numeric. + */ +static int +xo_format_is_numeric (const char *fmt, ssize_t flen) +{ + if (flen <= 0 || *fmt++ != '%') /* Must start with '%' */ + return FALSE; + flen -= 1; + + /* Handle leading flags; don't want "#" since JSON can't handle hex */ + ssize_t spn = xo_strnspn(fmt, flen, "0123456789.*+ -"); + if (spn >= flen) + return FALSE; + + fmt += spn; /* Move along the input string */ + flen -= spn; + + /* Handle the length modifiers */ + spn = xo_strnspn(fmt, flen, "hljtqz"); + if (spn >= flen) + return FALSE; + + fmt += spn; /* Move along the input string */ + flen -= spn; + + if (flen != 1) /* Should only be one character left */ + return FALSE; + + return (strchr("diouDOUeEfFgG", *fmt) == NULL) ? FALSE : TRUE; +} + static void xo_format_prep (xo_handle_t *xop, xo_xff_flags_t flags) { @@ -4410,10 +4463,10 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, quote = 0; fmt = "true"; /* JSON encodes empty tags as a boolean true */ flen = 4; - } else if (strchr("diouDOUeEfFgG", fmt[flen - 1]) == NULL) - quote = 1; - else + } else if (xo_format_is_numeric(fmt, flen)) quote = 0; + else + quote = 1; if (nlen == 0) { static char missing[] = "missing-field-name"; diff --git a/freebsd/contrib/tcpdump/tcpdump.c b/freebsd/contrib/tcpdump/tcpdump.c index 26761ad7..75896da3 100644 --- a/freebsd/contrib/tcpdump/tcpdump.c +++ b/freebsd/contrib/tcpdump/tcpdump.c @@ -89,7 +89,6 @@ The Regents of the University of California. All rights reserved.\n"; */ #ifdef HAVE_CAPSICUM #include <sys/capsicum.h> -#include <sys/sysctl.h> #include <sys/nv.h> #include <sys/ioccom.h> #include <net/bpf.h> @@ -126,6 +125,10 @@ The Regents of the University of California. All rights reserved.\n"; #endif /* HAVE_CAP_NG_H */ #endif /* HAVE_LIBCAP_NG */ +#ifdef __FreeBSD__ +#include <sys/sysctl.h> +#endif /* __FreeBSD__ */ + #include "netdissect.h" #include "interface.h" #include "addrtoname.h" @@ -1129,6 +1132,10 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf) sysctlbyname(sysctl, parent, &s, NULL, 0); strlcpy(newdev, device, sizeof(newdev)); /* Suggest a new wlan device. */ + /* FIXME: incrementing the index this way is not going to work well + * when the index is 9 or greater but the only consequence in this + * specific case would be an error message that looks a bit odd. + */ newdev[strlen(newdev)-1]++; error("%s is not a monitor mode VAP\n" "To create a new monitor mode VAP use:\n" |