summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-09 09:59:36 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-09 13:58:08 +0200
commit97c5f8e8de8bfc039a48f504b71e2905b224b418 (patch)
treed9745c4479456b1a9c0a5e696f34fb19ec1de82f
parentRegenerate libbsd_waf.py (diff)
downloadrtems-libbsd-97c5f8e8de8bfc039a48f504b71e2905b224b418.tar.bz2
Update libpcap to FreeBSD head 2017-04-04
Update libpcap from Git mirror commit 99a648a912e81e29d9c4c159cbbe263462f2d719 to 642b174daddbd0efd9bb5f242c43f4ab4db6869f.
-rw-r--r--Makefile.todo22
-rw-r--r--freebsd/contrib/libpcap/arcnet.h2
-rw-r--r--freebsd/contrib/libpcap/atmuni31.h2
-rw-r--r--freebsd/contrib/libpcap/bpf_image.c39
-rw-r--r--freebsd/contrib/libpcap/etherent.c11
-rw-r--r--freebsd/contrib/libpcap/ethertype.h5
-rw-r--r--freebsd/contrib/libpcap/extract.h221
-rw-r--r--freebsd/contrib/libpcap/fad-getad.c138
-rw-r--r--freebsd/contrib/libpcap/fad-helpers.c890
-rw-r--r--freebsd/contrib/libpcap/gencode.c5766
-rw-r--r--freebsd/contrib/libpcap/gencode.h172
-rw-r--r--freebsd/contrib/libpcap/grammar.c1782
-rw-r--r--freebsd/contrib/libpcap/grammar.h (renamed from freebsd/contrib/libpcap/tokdefs.h)88
-rw-r--r--freebsd/contrib/libpcap/grammar.y297
-rw-r--r--freebsd/contrib/libpcap/ieee80211.h2
-rw-r--r--freebsd/contrib/libpcap/inet.c748
-rw-r--r--freebsd/contrib/libpcap/llc.h37
-rw-r--r--freebsd/contrib/libpcap/nametoaddr.c80
-rw-r--r--freebsd/contrib/libpcap/nametoaddr.h48
-rw-r--r--freebsd/contrib/libpcap/nlpid.h2
-rw-r--r--freebsd/contrib/libpcap/optimize.c891
-rw-r--r--freebsd/contrib/libpcap/pcap-bpf.c931
-rw-r--r--freebsd/contrib/libpcap/pcap-common.c411
-rw-r--r--freebsd/contrib/libpcap/pcap-common.h4
-rw-r--r--freebsd/contrib/libpcap/pcap-int.h402
-rw-r--r--freebsd/contrib/libpcap/pcap-namedb.h2
-rw-r--r--freebsd/contrib/libpcap/pcap.c1185
-rw-r--r--freebsd/contrib/libpcap/pcap.h2
-rw-r--r--freebsd/contrib/libpcap/pcap/can_socketcan.h54
-rw-r--r--freebsd/contrib/libpcap/pcap/export-defs.h108
-rw-r--r--freebsd/contrib/libpcap/pcap/namedb.h34
-rw-r--r--freebsd/contrib/libpcap/pcap/nflog.h92
-rw-r--r--freebsd/contrib/libpcap/pcap/pcap.h309
-rw-r--r--freebsd/contrib/libpcap/pcap/sll.h4
-rw-r--r--freebsd/contrib/libpcap/pcap/usb.h14
-rw-r--r--freebsd/contrib/libpcap/pcap_version.h13
-rw-r--r--freebsd/contrib/libpcap/portability.h216
-rw-r--r--freebsd/contrib/libpcap/ppp.h1
-rw-r--r--freebsd/contrib/libpcap/savefile.c268
-rw-r--r--freebsd/contrib/libpcap/scanner.c6140
-rw-r--r--freebsd/contrib/libpcap/scanner.h362
-rw-r--r--freebsd/contrib/libpcap/scanner.l259
-rw-r--r--freebsd/contrib/libpcap/sf-pcap-ng.c647
-rw-r--r--freebsd/contrib/libpcap/sf-pcap-ng.h3
-rw-r--r--freebsd/contrib/libpcap/sf-pcap.c540
-rw-r--r--freebsd/contrib/libpcap/sf-pcap.h3
-rw-r--r--freebsd/contrib/libpcap/sunatmpos.h2
-rw-r--r--libbsd.py7
-rw-r--r--libbsd_waf.py1
49 files changed, 14026 insertions, 9231 deletions
diff --git a/Makefile.todo b/Makefile.todo
index 02152f52..c69908bf 100644
--- a/Makefile.todo
+++ b/Makefile.todo
@@ -37,6 +37,11 @@ GENERATED += $(LOCAL_SRC)/rtwn-rtl8188eufw.c
GENERATED += $(LOCAL_SRC)/runfw.c
GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h
GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c
+GENERATED += freebsd/contrib/libpcap/grammar.h
+GENERATED += freebsd/contrib/libpcap/grammar.c
+GENERATED += freebsd/contrib/libpcap/pcap_version.h
+GENERATED += freebsd/contrib/libpcap/scanner.h
+GENERATED += freebsd/contrib/libpcap/scanner.c
all: $(GENERATED)
@@ -198,5 +203,22 @@ rtemsbsd/include/machine/rtems-bsd-regdomain.h: $(FREEBSD_SRC)/etc/regdomain.xml
rtemsbsd/rtems/rtems-bsd-regdomain.c: $(FREEBSD_SRC)/etc/regdomain.xml
rtems-bin2c -C $< $@
+freebsd/contrib/libpcap/grammar.h: freebsd/contrib/libpcap/grammar.c
+
+freebsd/contrib/libpcap/grammar.c: freebsd-org/contrib/libpcap/grammar.y
+ cd freebsd-org/contrib/libpcap && yacc -p pcap_ -o grammar.c -d grammar.y
+ mv freebsd-org/contrib/libpcap/grammar.h freebsd/contrib/libpcap/grammar.h
+ mv freebsd-org/contrib/libpcap/grammar.c $@
+
+freebsd/contrib/libpcap/pcap_version.h: freebsd-org/contrib/libpcap/VERSION
+ freebsd-org/contrib/libpcap/gen_version_header.sh $< freebsd-org/contrib/libpcap/pcap_version.h.in $@
+
+freebsd/contrib/libpcap/scanner.h: freebsd/contrib/libpcap/scanner.c
+
+freebsd/contrib/libpcap/scanner.c: freebsd-org/contrib/libpcap/scanner.l
+ cd freebsd-org/contrib/libpcap && lex -P pcap_ --header-file=scanner.h --nounput -o scanner.c scanner.l
+ mv freebsd-org/contrib/libpcap/scanner.h freebsd/contrib/libpcap/scanner.h
+ mv freebsd-org/contrib/libpcap/scanner.c $@
+
clean:
rm $(GENERATED)
diff --git a/freebsd/contrib/libpcap/arcnet.h b/freebsd/contrib/libpcap/arcnet.h
index 4f86043e..58690985 100644
--- a/freebsd/contrib/libpcap/arcnet.h
+++ b/freebsd/contrib/libpcap/arcnet.h
@@ -30,8 +30,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Id: arcnet.h,v 1.2 2001-04-24 02:17:52 guy Exp $ (LBL)
- *
* from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
*/
diff --git a/freebsd/contrib/libpcap/atmuni31.h b/freebsd/contrib/libpcap/atmuni31.h
index 880cc1a8..0f854300 100644
--- a/freebsd/contrib/libpcap/atmuni31.h
+++ b/freebsd/contrib/libpcap/atmuni31.h
@@ -28,8 +28,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/atmuni31.h,v 1.3 2007-10-22 19:28:58 guy Exp $ (LBL)
*/
/* Based on UNI3.1 standard by ATM Forum */
diff --git a/freebsd/contrib/libpcap/bpf_image.c b/freebsd/contrib/libpcap/bpf_image.c
index 7bdc6ce1..5ab1b2a8 100644
--- a/freebsd/contrib/libpcap/bpf_image.c
+++ b/freebsd/contrib/libpcap/bpf_image.c
@@ -21,18 +21,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/bpf_image.c,v 1.28 2008-01-02 04:16:46 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -42,7 +37,7 @@ static const char rcsid[] _U_ =
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdio.h>
#include <string.h>
@@ -55,7 +50,7 @@ static const char rcsid[] _U_ =
char *
bpf_image(p, n)
- struct bpf_insn *p;
+ const struct bpf_insn *p;
int n;
{
int v;
@@ -218,6 +213,11 @@ bpf_image(p, n)
fmt = "x";
break;
+ case BPF_ALU|BPF_MOD|BPF_X:
+ op = "mod";
+ fmt = "x";
+ break;
+
case BPF_ALU|BPF_AND|BPF_X:
op = "and";
fmt = "x";
@@ -228,6 +228,11 @@ bpf_image(p, n)
fmt = "x";
break;
+ case BPF_ALU|BPF_XOR|BPF_X:
+ op = "xor";
+ fmt = "x";
+ break;
+
case BPF_ALU|BPF_LSH|BPF_X:
op = "lsh";
fmt = "x";
@@ -258,6 +263,11 @@ bpf_image(p, n)
fmt = "#%d";
break;
+ case BPF_ALU|BPF_MOD|BPF_K:
+ op = "mod";
+ fmt = "#%d";
+ break;
+
case BPF_ALU|BPF_AND|BPF_K:
op = "and";
fmt = "#0x%x";
@@ -268,6 +278,11 @@ bpf_image(p, n)
fmt = "#0x%x";
break;
+ case BPF_ALU|BPF_XOR|BPF_K:
+ op = "xor";
+ fmt = "#0x%x";
+ break;
+
case BPF_ALU|BPF_LSH|BPF_K:
op = "lsh";
fmt = "#%d";
@@ -293,13 +308,13 @@ bpf_image(p, n)
fmt = "";
break;
}
- (void)snprintf(operand, sizeof operand, fmt, v);
+ (void)pcap_snprintf(operand, sizeof operand, fmt, v);
if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
- (void)snprintf(image, sizeof image,
+ (void)pcap_snprintf(image, sizeof image,
"(%03d) %-8s %-16s jt %d\tjf %d",
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
} else {
- (void)snprintf(image, sizeof image,
+ (void)pcap_snprintf(image, sizeof image,
"(%03d) %-8s %s",
n, op, operand);
}
diff --git a/freebsd/contrib/libpcap/etherent.c b/freebsd/contrib/libpcap/etherent.c
index 19bac195..0291acc1 100644
--- a/freebsd/contrib/libpcap/etherent.c
+++ b/freebsd/contrib/libpcap/etherent.c
@@ -21,18 +21,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/etherent.c,v 1.23 2006-10-04 18:09:22 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -42,7 +37,7 @@ static const char rcsid[] _U_ =
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <ctype.h>
#include <memory.h>
diff --git a/freebsd/contrib/libpcap/ethertype.h b/freebsd/contrib/libpcap/ethertype.h
index 2d6bbebd..51f63083 100644
--- a/freebsd/contrib/libpcap/ethertype.h
+++ b/freebsd/contrib/libpcap/ethertype.h
@@ -17,8 +17,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/ethertype.h,v 1.14 2005-09-05 09:06:58 guy Exp $ (LBL)
*/
/*
@@ -114,6 +112,9 @@
#ifndef ETHERTYPE_PPPOES
#define ETHERTYPE_PPPOES 0x8864
#endif
+#ifndef ETHERTYPE_8021AD
+#define ETHERTYPE_8021AD 0x88a8
+#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif
diff --git a/freebsd/contrib/libpcap/extract.h b/freebsd/contrib/libpcap/extract.h
new file mode 100644
index 00000000..face5b7e
--- /dev/null
+++ b/freebsd/contrib/libpcap/extract.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#ifndef _WIN32
+#include <arpa/inet.h>
+#endif
+
+/*
+ * Macros to extract possibly-unaligned big-endian integral values.
+ */
+#ifdef LBL_ALIGN
+/*
+ * The processor doesn't natively handle unaligned loads.
+ */
+#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
+ (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.
+ *
+ * Declare packed structures containing a uint16_t and a uint32_t,
+ * cast the pointer to point to one of those, and fetch through it;
+ * the GCC manual doesn't appear to explicitly say that
+ * __attribute__((packed)) causes the compiler to generate unaligned-safe
+ * code, but it apppears to do so.
+ *
+ * We do this in case the compiler can generate code using those
+ * instructions to do an unaligned load and pass stuff to "ntohs()" or
+ * "ntohl()", which might be better than than the code to fetch the
+ * bytes one at a time and assemble them. (That might not be the
+ * case on a little-endian platform, such as DEC's MIPS machines and
+ * Alpha machines, where "ntohs()" and "ntohl()" might not be done
+ * inline.)
+ *
+ * We do this only for specific architectures because, for example,
+ * at least some versions of GCC, when compiling for 64-bit SPARC,
+ * generate code that assumes alignment if we do this.
+ *
+ * XXX - add other architectures and compilers as possible and
+ * appropriate.
+ *
+ * HP's C compiler, indicated by __HP_cc being defined, supports
+ * "#pragma unaligned N" in version A.05.50 and later, where "N"
+ * specifies a number of bytes at which the typedef on the next
+ * line is aligned, e.g.
+ *
+ * #pragma unalign 1
+ * typedef uint16_t unaligned_uint16_t;
+ *
+ * to define unaligned_uint16_t as a 16-bit unaligned data type.
+ * This could be presumably used, in sufficiently recent versions of
+ * the compiler, with macros similar to those below. This would be
+ * useful only if that compiler could generate better code for PA-RISC
+ * or Itanium than would be generated by a bunch of shifts-and-ORs.
+ *
+ * DEC C, indicated by __DECC being defined, has, at least on Alpha,
+ * an __unaligned qualifier that can be applied to pointers to get the
+ * compiler to generate code that does unaligned loads and stores when
+ * dereferencing the pointer in question.
+ *
+ * XXX - what if the native C compiler doesn't support
+ * __attribute__((packed))? How can we get it to generate unaligned
+ * accesses for *specific* items?
+ */
+typedef struct {
+ uint16_t val;
+} __attribute__((packed)) unaligned_uint16_t;
+
+typedef struct {
+ uint32_t val;
+} __attribute__((packed)) unaligned_uint32_t;
+
+static inline uint16_t
+EXTRACT_16BITS(const void *p)
+{
+ return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
+}
+
+static inline uint32_t
+EXTRACT_32BITS(const void *p)
+{
+ return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
+}
+
+static inline uint64_t
+EXTRACT_64BITS(const void *p)
+{
+ return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+ ((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
+}
+
+#else /* have to do it a byte at a time */
+/*
+ * This isn't a GCC-compatible compiler, we don't have __attribute__,
+ * or we do but we don't know of any better way with this instruction
+ * set to do unaligned loads, so do unaligned loads of big-endian
+ * quantities the hard way - fetch the bytes one at a time and
+ * assemble them.
+ */
+#define EXTRACT_16BITS(p) \
+ ((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
+ ((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
+#define EXTRACT_32BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
+#define EXTRACT_64BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
+#endif /* must special-case unaligned accesses */
+#else /* LBL_ALIGN */
+/*
+ * The processor natively handles unaligned loads, so we can just
+ * cast the pointer and fetch through it.
+ */
+static inline uint16_t
+EXTRACT_16BITS(const void *p)
+{
+ return ((uint16_t)ntohs(*(const uint16_t *)(p)));
+}
+
+static inline uint32_t
+EXTRACT_32BITS(const void *p)
+{
+ return ((uint32_t)ntohl(*(const uint32_t *)(p)));
+}
+
+static inline uint64_t
+EXTRACT_64BITS(const void *p)
+{
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+ ((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
+
+}
+
+#endif /* LBL_ALIGN */
+
+#define EXTRACT_24BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
+
+#define EXTRACT_40BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
+
+#define EXTRACT_48BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
+
+#define EXTRACT_56BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
+
+/*
+ * Macros to extract possibly-unaligned little-endian integral values.
+ * XXX - do loads on little-endian machines that support unaligned loads?
+ */
+#define EXTRACT_LE_8BITS(p) (*(p))
+#define EXTRACT_LE_16BITS(p) \
+ ((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
+#define EXTRACT_LE_32BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
+#define EXTRACT_LE_24BITS(p) \
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
+#define EXTRACT_LE_64BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
diff --git a/freebsd/contrib/libpcap/fad-getad.c b/freebsd/contrib/libpcap/fad-getad.c
index dc478fa1..cd7ac3e6 100644
--- a/freebsd/contrib/libpcap/fad-getad.c
+++ b/freebsd/contrib/libpcap/fad-getad.c
@@ -34,11 +34,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/fad-getad.c,v 1.12 2007-09-14 00:44:55 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -62,9 +57,15 @@ static const char rcsid[] _U_ =
#include "os-proto.h"
#endif
-#ifdef AF_PACKET
+/*
+ * We don't do this on Solaris 11 and later, as it appears there aren't
+ * any AF_PACKET addresses on interfaces, so we don't need this, and
+ * we end up including both the OS's <net/bpf.h> and our <pcap/bpf.h>,
+ * and their definitions of some data structures collide.
+ */
+#if (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET)
# ifdef HAVE_NETPACKET_PACKET_H
-/* Solaris 11 and later, Linux distributions with newer glibc */
+/* Linux distributions with newer glibc */
# include <netpacket/packet.h>
# else /* HAVE_NETPACKET_PACKET_H */
/* LynxOS, Linux distributions with older glibc */
@@ -77,7 +78,7 @@ static const char rcsid[] _U_ =
# include <linux/if_packet.h>
# endif /* __Lynx__ */
# endif /* HAVE_NETPACKET_PACKET_H */
-#endif /* AF_PACKET */
+#endif /* (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET) */
/*
* This is fun.
@@ -122,7 +123,7 @@ get_sa_len(struct sockaddr *addr)
return (sizeof (struct sockaddr_in6));
#endif
-#ifdef AF_PACKET
+#if (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET)
case AF_PACKET:
return (sizeof (struct sockaddr_ll));
#endif
@@ -142,10 +143,11 @@ get_sa_len(struct sockaddr *addr)
* Get a list of all interfaces that are up and that we can open.
* Returns -1 on error, 0 otherwise.
* The list, as returned through "alldevsp", may be null if no interfaces
- * were up and could be opened.
+ * could be opened.
*/
int
-pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
+ int (*check_usable)(const char *))
{
pcap_if_t *devlist = NULL;
struct ifaddrs *ifap, *ifa;
@@ -158,10 +160,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
* Get the list of interface addresses.
*
* Note: this won't return information about interfaces
- * with no addresses; are there any such interfaces
- * that would be capable of receiving packets?
- * (Interfaces incapable of receiving packets aren't
- * very interesting from libpcap's point of view.)
+ * with no addresses, so, if a platform has interfaces
+ * with no interfaces on which traffic can be captured,
+ * we must check for those interfaces as well (see, for
+ * example, what's done on Linux).
*
* LAN interfaces will probably have link-layer
* addresses; I don't know whether all implementations
@@ -169,40 +171,56 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
* those.
*/
if (getifaddrs(&ifap) != 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"getifaddrs: %s", pcap_strerror(errno));
return (-1);
}
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
/*
- * Is this interface up?
+ * If this entry has a colon followed by a number at
+ * the end, we assume it's a logical interface. Those
+ * are just the way you assign multiple IP addresses to
+ * a real interface on Linux, so an entry for a logical
+ * interface should be treated like the entry for the
+ * real interface; we do that by stripping off the ":"
+ * and the number.
+ *
+ * XXX - should we do this only on Linux?
*/
- if (!(ifa->ifa_flags & IFF_UP)) {
+ p = strchr(ifa->ifa_name, ':');
+ if (p != NULL) {
/*
- * No, so don't add it to the list.
+ * We have a ":"; is it followed by a number?
+ */
+ q = p + 1;
+ while (isdigit((unsigned char)*q))
+ q++;
+ if (*q == '\0') {
+ /*
+ * All digits after the ":" until the end.
+ * Strip off the ":" and everything after
+ * it.
+ */
+ *p = '\0';
+ }
+ }
+
+ /*
+ * Can we capture on this device?
+ */
+ if (!(*check_usable)(ifa->ifa_name)) {
+ /*
+ * No.
*/
continue;
}
/*
* "ifa_addr" was apparently null on at least one
- * interface on some system.
- *
- * "ifa_broadaddr" may be non-null even on
- * non-broadcast interfaces, and was null on
- * at least one OpenBSD 3.4 system on at least
- * one interface with IFF_BROADCAST set.
- *
- * "ifa_dstaddr" was, on at least one FreeBSD 4.1
- * system, non-null on a non-point-to-point
- * interface.
- *
- * Therefore, we supply the address and netmask only
- * if "ifa_addr" is non-null (if there's no address,
- * there's obviously no netmask), and supply the
- * broadcast and destination addresses if the appropriate
- * flag is set *and* the appropriate "ifa_" entry doesn't
- * evaluate to a null pointer.
+ * interface on some system. Therefore, we supply
+ * the address and netmask only if "ifa_addr" is
+ * non-null (if there's no address, there's obviously
+ * no netmask).
*/
if (ifa->ifa_addr != NULL) {
addr = ifa->ifa_addr;
@@ -213,6 +231,22 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
addr_size = 0;
netmask = NULL;
}
+
+ /*
+ * 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
+ * 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.
+ *
+ * Therefore, we must also check the IFF_BROADCAST
+ * flag, and only add a broadcast address if it's
+ * set, and check the IFF_POINTTOPOINT flag, and
+ * only add a destination address if it's set (as
+ * per man page recommendations on some of those
+ * platforms).
+ */
if (ifa->ifa_flags & IFF_BROADCAST &&
ifa->ifa_broadaddr != NULL) {
broadaddr = ifa->ifa_broadaddr;
@@ -231,39 +265,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
}
/*
- * If this entry has a colon followed by a number at
- * the end, we assume it's a logical interface. Those
- * are just the way you assign multiple IP addresses to
- * a real interface on Linux, so an entry for a logical
- * interface should be treated like the entry for the
- * real interface; we do that by stripping off the ":"
- * and the number.
- *
- * XXX - should we do this only on Linux?
- */
- p = strchr(ifa->ifa_name, ':');
- if (p != NULL) {
- /*
- * We have a ":"; is it followed by a number?
- */
- q = p + 1;
- while (isdigit((unsigned char)*q))
- q++;
- if (*q == '\0') {
- /*
- * All digits after the ":" until the end.
- * Strip off the ":" and everything after
- * it.
- */
- *p = '\0';
- }
- }
-
- /*
* Add information for this address to the list.
*/
if (add_addr_to_iflist(&devlist, ifa->ifa_name,
- ifa->ifa_flags, addr, addr_size, netmask, addr_size,
+ if_flags_to_pcap_flags(ifa->ifa_name, ifa->ifa_flags),
+ addr, addr_size, netmask, addr_size,
broadaddr, broadaddr_size, dstaddr, dstaddr_size,
errbuf) < 0) {
ret = -1;
diff --git a/freebsd/contrib/libpcap/fad-helpers.c b/freebsd/contrib/libpcap/fad-helpers.c
new file mode 100644
index 00000000..0b98b484
--- /dev/null
+++ b/freebsd/contrib/libpcap/fad-helpers.c
@@ -0,0 +1,890 @@
+#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/gencode.c b/freebsd/contrib/libpcap/gencode.c
index 2541ea17..8c303415 100644
--- a/freebsd/contrib/libpcap/gencode.c
+++ b/freebsd/contrib/libpcap/gencode.c
@@ -23,18 +23,14 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.309 2008-12-23 20:13:29 guy Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -45,16 +41,9 @@ static const char rcsid[] _U_ =
#endif
#include <sys/types.h>
#include <sys/socket.h>
-#endif /* WIN32 */
-
-/*
- * XXX - why was this included even on UNIX?
- */
-#ifdef __MINGW32__
-#include "ip6_misc.h"
-#endif
+#endif /* _WIN32 */
-#ifndef WIN32
+#ifndef _WIN32
#ifdef __NetBSD__
#include <sys/param.h>
@@ -63,7 +52,7 @@ static const char rcsid[] _U_ =
#include <netinet/in.h>
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdlib.h>
#include <string.h>
@@ -88,29 +77,86 @@ static const char rcsid[] _U_ =
#include "pcap/sll.h"
#include "pcap/ipnet.h"
#include "arcnet.h"
-#if defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
+
+#include "grammar.h"
+#include "scanner.h"
+
+#if defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
#include <linux/types.h>
#include <linux/if_packet.h>
#include <linux/filter.h>
#endif
+
#ifdef HAVE_NET_PFVAR_H
#include <sys/socket.h>
#include <net/if.h>
#include <net/pfvar.h>
#include <net/if_pflog.h>
#endif
+
#ifndef offsetof
#define offsetof(s, e) ((size_t)&((s *)0)->e)
#endif
+
#ifdef INET6
-#ifndef WIN32
+#ifdef _WIN32
+#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];
+ } in6_u;
+#define s6_addr in6_u.u6_addr8
+#define s6_addr16 in6_u.u6_addr16
+#define s6_addr32 in6_u.u6_addr32
+#define s6_addr64 in6_u.u6_addr64
+ };
+
+typedef unsigned short sa_family_t;
+
+#define __SOCKADDR_COMMON(sa_prefix) \
+ sa_family_t sa_prefix##family
+
+/* Ditto, for IPv6. */
+struct sockaddr_in6
+ {
+ __SOCKADDR_COMMON (sin6_);
+ u_int16_t sin6_port; /* Transport layer port # */
+ u_int32_t sin6_flowinfo; /* IPv6 flow information */
+ struct in6_addr sin6_addr; /* IPv6 address */
+ };
+
+#ifndef EAI_ADDRFAMILY
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for hostname */
+ 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) */
+#else /* _WIN32 */
#include <netdb.h> /* for "struct addrinfo" */
-#endif /* WIN32 */
-#endif /*INET6*/
+#endif /* _WIN32 */
+#endif /* INET6 */
#include <pcap/namedb.h>
+#include "nametoaddr.h"
+
#define ETHERMTU 1500
+#ifndef ETHERTYPE_TEB
+#define ETHERTYPE_TEB 0x6558
+#endif
+
#ifndef IPPROTO_HOPOPTS
#define IPPROTO_HOPOPTS 0
#endif
@@ -127,76 +173,75 @@ static const char rcsid[] _U_ =
#define IPPROTO_SCTP 132
#endif
+#define GENEVE_PORT 6081
+
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
#define JMP(c) ((c)|BPF_JMP|BPF_K)
-/* Locals */
-static jmp_buf top_ctx;
-static pcap_t *bpf_pcap;
-
-/* Hack for updating VLAN, MPLS, and PPPoE offsets. */
-#ifdef WIN32
-static u_int orig_linktype = (u_int)-1, orig_nl = (u_int)-1, label_stack_depth = (u_int)-1;
-#else
-static u_int orig_linktype = -1U, orig_nl = -1U, label_stack_depth = -1U;
-#endif
-
-/* XXX */
-#ifdef PCAP_FDDIPAD
-static int pcap_fddipad;
-#endif
-
-/* VARARGS */
-void
-bpf_error(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (bpf_pcap != NULL)
- (void)vsnprintf(pcap_geterr(bpf_pcap), PCAP_ERRBUF_SIZE,
- fmt, ap);
- va_end(ap);
- longjmp(top_ctx, 1);
- /* NOTREACHED */
+/*
+ * "Push" the current value of the link-layer header type and link-layer
+ * header offset onto a "stack", and set a new value. (It's not a
+ * full-blown stack; we keep only the top two items.)
+ */
+#define PUSH_LINKHDR(cs, new_linktype, new_is_variable, new_constant_part, new_reg) \
+{ \
+ (cs)->prevlinktype = (cs)->linktype; \
+ (cs)->off_prevlinkhdr = (cs)->off_linkhdr; \
+ (cs)->linktype = (new_linktype); \
+ (cs)->off_linkhdr.is_variable = (new_is_variable); \
+ (cs)->off_linkhdr.constant_part = (new_constant_part); \
+ (cs)->off_linkhdr.reg = (new_reg); \
+ (cs)->is_geneve = 0; \
}
-static void init_linktype(pcap_t *);
-
-static void init_regs(void);
-static int alloc_reg(void);
-static void free_reg(int);
+/*
+ * Offset "not set" value.
+ */
+#define OFFSET_NOT_SET 0xffffffffU
-static struct block *root;
+/*
+ * Absolute offsets, which are offsets from the beginning of the raw
+ * packet data, are, in the general case, the sum of a variable value
+ * and a constant value; the variable value may be absent, in which
+ * case the offset is only the constant value, and the constant value
+ * may be zero, in which case the offset is only the variable value.
+ *
+ * bpf_abs_offset is a structure containing all that information:
+ *
+ * is_variable is 1 if there's a variable part.
+ *
+ * constant_part is the constant part of the value, possibly zero;
+ *
+ * if is_variable is 1, reg is the register number for a register
+ * containing the variable value if the register has been assigned,
+ * and -1 otherwise.
+ */
+typedef struct {
+ int is_variable;
+ u_int constant_part;
+ int reg;
+} bpf_abs_offset;
/*
* Value passed to gen_load_a() to indicate what the offset argument
- * is relative to.
+ * is relative to the beginning of.
*/
enum e_offrel {
- OR_PACKET, /* relative to the beginning of the packet */
- OR_LINK, /* relative to the beginning of the link-layer header */
- OR_MACPL, /* relative to the end of the MAC-layer header */
- OR_NET, /* relative to the network-layer header */
- OR_NET_NOSNAP, /* relative to the network-layer header, with no SNAP header at the link layer */
- OR_TRAN_IPV4, /* relative to the transport-layer header, with IPv4 network layer */
- OR_TRAN_IPV6 /* relative to the transport-layer header, with IPv6 network layer */
+ OR_PACKET, /* full packet data */
+ OR_LINKHDR, /* link-layer header */
+ OR_PREVLINKHDR, /* previous link-layer header */
+ OR_LLC, /* 802.2 LLC header */
+ OR_PREVMPLSHDR, /* previous MPLS header */
+ OR_LINKTYPE, /* link-layer type */
+ OR_LINKPL, /* link-layer payload */
+ OR_LINKPL_NOSNAP, /* link-layer payload, with no SNAP header at the link layer */
+ OR_TRAN_IPV4, /* transport-layer header, with IPv4 network layer */
+ OR_TRAN_IPV6 /* transport-layer header, with IPv6 network layer */
};
-#ifdef INET6
-/*
- * As errors are handled by a longjmp, anything allocated must be freed
- * in the longjmp handler, so it must be reachable from that handler.
- * One thing that's allocated is the result of pcap_nametoaddrinfo();
- * it must be freed with freeaddrinfo(). This variable points to any
- * addrinfo structure that would need to be freed.
- */
-static struct addrinfo *ai;
-#endif
-
/*
* We divy out chunks of memory rather than call malloc each time so
* we don't have to worry about leaking memory. It's probably
@@ -208,100 +253,325 @@ static struct addrinfo *ai;
#define NCHUNKS 16
#define CHUNK0SIZE 1024
struct chunk {
- u_int n_left;
+ size_t n_left;
void *m;
};
-static struct chunk chunks[NCHUNKS];
-static int cur_chunk;
+/* Code generator state */
+
+struct _compiler_state {
+ jmp_buf top_ctx;
+ pcap_t *bpf_pcap;
+
+ struct icode ic;
+
+ int snaplen;
+
+ int linktype;
+ int prevlinktype;
+ int outermostlinktype;
+
+ bpf_u_int32 netmask;
+ int no_optimize;
+
+ /* Hack for handling VLAN and MPLS stacks. */
+ u_int label_stack_depth;
+ u_int vlan_stack_depth;
+
+ /* XXX */
+ u_int pcap_fddipad;
-static void *newchunk(u_int);
-static void freechunks(void);
-static inline struct block *new_block(int);
-static inline struct slist *new_stmt(int);
-static struct block *gen_retblk(int);
-static inline void syntax(void);
+#ifdef INET6
+ /*
+ * As errors are handled by a longjmp, anything allocated must
+ * be freed in the longjmp handler, so it must be reachable
+ * from that handler.
+ *
+ * One thing that's allocated is the result of pcap_nametoaddrinfo();
+ * it must be freed with freeaddrinfo(). This variable points to
+ * any addrinfo structure that would need to be freed.
+ */
+ struct addrinfo *ai;
+#endif
+
+ /*
+ * Various code constructs need to know the layout of the packet.
+ * These values give the necessary offsets from the beginning
+ * of the packet data.
+ */
+
+ /*
+ * Absolute offset of the beginning of the link-layer header.
+ */
+ bpf_abs_offset off_linkhdr;
+
+ /*
+ * If we're checking a link-layer header for a packet encapsulated
+ * in another protocol layer, this is the equivalent information
+ * for the previous layers' link-layer header from the beginning
+ * of the raw packet data.
+ */
+ bpf_abs_offset off_prevlinkhdr;
+
+ /*
+ * This is the equivalent information for the outermost layers'
+ * link-layer header.
+ */
+ bpf_abs_offset off_outermostlinkhdr;
+
+ /*
+ * Absolute offset of the beginning of the link-layer payload.
+ */
+ bpf_abs_offset off_linkpl;
+
+ /*
+ * "off_linktype" is the offset to information in the link-layer
+ * header giving the packet type. This is an absolute offset
+ * from the beginning of the packet.
+ *
+ * For Ethernet, it's the offset of the Ethernet type field; this
+ * means that it must have a value that skips VLAN tags.
+ *
+ * For link-layer types that always use 802.2 headers, it's the
+ * offset of the LLC header; this means that it must have a value
+ * that skips VLAN tags.
+ *
+ * For PPP, it's the offset of the PPP type field.
+ *
+ * For Cisco HDLC, it's the offset of the CHDLC type field.
+ *
+ * For BSD loopback, it's the offset of the AF_ value.
+ *
+ * For Linux cooked sockets, it's the offset of the type field.
+ *
+ * off_linktype.constant_part is set to OFFSET_NOT_SET for no
+ * encapsulation, in which case, IP is assumed.
+ */
+ bpf_abs_offset off_linktype;
+
+ /*
+ * TRUE if the link layer includes an ATM pseudo-header.
+ */
+ int is_atm;
+
+ /*
+ * TRUE if "geneve" appeared in the filter; it causes us to
+ * generate code that checks for a Geneve header and assume
+ * that later filters apply to the encapsulated payload.
+ */
+ int is_geneve;
+
+ /*
+ * These are offsets for the ATM pseudo-header.
+ */
+ u_int off_vpi;
+ u_int off_vci;
+ u_int off_proto;
+
+ /*
+ * These are offsets for the MTP2 fields.
+ */
+ u_int off_li;
+ u_int off_li_hsl;
+
+ /*
+ * These are offsets for the MTP3 fields.
+ */
+ u_int off_sio;
+ u_int off_opc;
+ u_int off_dpc;
+ u_int off_sls;
+
+ /*
+ * This is the offset of the first byte after the ATM pseudo_header,
+ * or -1 if there is no ATM pseudo-header.
+ */
+ u_int off_payload;
+
+ /*
+ * These are offsets to the beginning of the network-layer header.
+ * They are relative to the beginning of the link-layer payload
+ * (i.e., they don't include off_linkhdr.constant_part or
+ * off_linkpl.constant_part).
+ *
+ * If the link layer never uses 802.2 LLC:
+ *
+ * "off_nl" and "off_nl_nosnap" are the same.
+ *
+ * If the link layer always uses 802.2 LLC:
+ *
+ * "off_nl" is the offset if there's a SNAP header following
+ * the 802.2 header;
+ *
+ * "off_nl_nosnap" is the offset if there's no SNAP header.
+ *
+ * If the link layer is Ethernet:
+ *
+ * "off_nl" is the offset if the packet is an Ethernet II packet
+ * (we assume no 802.3+802.2+SNAP);
+ *
+ * "off_nl_nosnap" is the offset if the packet is an 802.3 packet
+ * with an 802.2 header following it.
+ */
+ u_int off_nl;
+ u_int off_nl_nosnap;
+
+ /*
+ * Here we handle simple allocation of the scratch registers.
+ * If too many registers are alloc'd, the allocator punts.
+ */
+ int regused[BPF_MEMWORDS];
+ int curreg;
+
+ /*
+ * Memory chunks.
+ */
+ struct chunk chunks[NCHUNKS];
+ int cur_chunk;
+};
+
+void
+bpf_syntax_error(compiler_state_t *cstate, const char *msg)
+{
+ bpf_error(cstate, "syntax error in filter expression: %s", msg);
+ /* NOTREACHED */
+}
+
+/* VARARGS */
+void
+bpf_error(compiler_state_t *cstate, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ if (cstate->bpf_pcap != NULL)
+ (void)pcap_vsnprintf(pcap_geterr(cstate->bpf_pcap),
+ PCAP_ERRBUF_SIZE, fmt, ap);
+ va_end(ap);
+ longjmp(cstate->top_ctx, 1);
+ /* NOTREACHED */
+}
+
+static void init_linktype(compiler_state_t *, pcap_t *);
+
+static void init_regs(compiler_state_t *);
+static int alloc_reg(compiler_state_t *);
+static void free_reg(compiler_state_t *, int);
+
+static void initchunks(compiler_state_t *cstate);
+static void *newchunk(compiler_state_t *cstate, size_t);
+static void freechunks(compiler_state_t *cstate);
+static inline struct block *new_block(compiler_state_t *cstate, int);
+static inline struct slist *new_stmt(compiler_state_t *cstate, int);
+static struct block *gen_retblk(compiler_state_t *cstate, int);
+static inline void syntax(compiler_state_t *cstate);
static void backpatch(struct block *, struct block *);
static void merge(struct block *, struct block *);
-static struct block *gen_cmp(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_gt(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_ge(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_lt(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_cmp_le(enum e_offrel, u_int, u_int, bpf_int32);
-static struct block *gen_mcmp(enum e_offrel, u_int, u_int, bpf_int32,
- bpf_u_int32);
-static struct block *gen_bcmp(enum e_offrel, u_int, u_int, const u_char *);
-static struct block *gen_ncmp(enum e_offrel, bpf_u_int32, bpf_u_int32,
- bpf_u_int32, bpf_u_int32, int, bpf_int32);
-static struct slist *gen_load_llrel(u_int, u_int);
-static struct slist *gen_load_macplrel(u_int, u_int);
-static struct slist *gen_load_a(enum e_offrel, u_int, u_int);
-static struct slist *gen_loadx_iphdrlen(void);
-static struct block *gen_uncond(int);
-static inline struct block *gen_true(void);
-static inline struct block *gen_false(void);
-static struct block *gen_ether_linktype(int);
-static struct block *gen_ipnet_linktype(int);
-static struct block *gen_linux_sll_linktype(int);
-static struct slist *gen_load_prism_llprefixlen(void);
-static struct slist *gen_load_avs_llprefixlen(void);
-static struct slist *gen_load_radiotap_llprefixlen(void);
-static struct slist *gen_load_ppi_llprefixlen(void);
-static void insert_compute_vloffsets(struct block *);
-static struct slist *gen_llprefixlen(void);
-static struct slist *gen_off_macpl(void);
+static struct block *gen_cmp(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_gt(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_ge(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_lt(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_cmp_le(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32);
+static struct block *gen_mcmp(compiler_state_t *, enum e_offrel, u_int,
+ u_int, bpf_int32, bpf_u_int32);
+static struct block *gen_bcmp(compiler_state_t *, enum e_offrel, u_int,
+ u_int, const u_char *);
+static struct block *gen_ncmp(compiler_state_t *, enum e_offrel, bpf_u_int32,
+ bpf_u_int32, bpf_u_int32, bpf_u_int32, int, bpf_int32);
+static struct slist *gen_load_absoffsetrel(compiler_state_t *, bpf_abs_offset *,
+ u_int, u_int);
+static struct slist *gen_load_a(compiler_state_t *, enum e_offrel, u_int,
+ u_int);
+static struct slist *gen_loadx_iphdrlen(compiler_state_t *);
+static struct block *gen_uncond(compiler_state_t *, int);
+static inline struct block *gen_true(compiler_state_t *);
+static inline struct block *gen_false(compiler_state_t *);
+static struct block *gen_ether_linktype(compiler_state_t *, int);
+static struct block *gen_ipnet_linktype(compiler_state_t *, int);
+static struct block *gen_linux_sll_linktype(compiler_state_t *, int);
+static struct slist *gen_load_prism_llprefixlen(compiler_state_t *);
+static struct slist *gen_load_avs_llprefixlen(compiler_state_t *);
+static struct slist *gen_load_radiotap_llprefixlen(compiler_state_t *);
+static struct slist *gen_load_ppi_llprefixlen(compiler_state_t *);
+static void insert_compute_vloffsets(compiler_state_t *, struct block *);
+static struct slist *gen_abs_offset_varpart(compiler_state_t *,
+ bpf_abs_offset *);
static int ethertype_to_ppptype(int);
-static struct block *gen_linktype(int);
-static struct block *gen_snap(bpf_u_int32, bpf_u_int32);
-static struct block *gen_llc_linktype(int);
-static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
+static struct block *gen_linktype(compiler_state_t *, int);
+static struct block *gen_snap(compiler_state_t *, bpf_u_int32, bpf_u_int32);
+static struct block *gen_llc_linktype(compiler_state_t *, int);
+static struct block *gen_hostop(compiler_state_t *, bpf_u_int32, bpf_u_int32,
+ int, int, u_int, u_int);
#ifdef INET6
-static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
+static struct block *gen_hostop6(compiler_state_t *, struct in6_addr *,
+ struct in6_addr *, int, int, u_int, u_int);
#endif
-static struct block *gen_ahostop(const u_char *, int);
-static struct block *gen_ehostop(const u_char *, int);
-static struct block *gen_fhostop(const u_char *, int);
-static struct block *gen_thostop(const u_char *, int);
-static struct block *gen_wlanhostop(const u_char *, int);
-static struct block *gen_ipfchostop(const u_char *, int);
-static struct block *gen_dnhostop(bpf_u_int32, int);
-static struct block *gen_mpls_linktype(int);
-static struct block *gen_host(bpf_u_int32, bpf_u_int32, int, int, int);
+static struct block *gen_ahostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_ehostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_fhostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_thostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_wlanhostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_ipfchostop(compiler_state_t *, const u_char *, int);
+static struct block *gen_dnhostop(compiler_state_t *, bpf_u_int32, int);
+static struct block *gen_mpls_linktype(compiler_state_t *, int);
+static struct block *gen_host(compiler_state_t *, bpf_u_int32, bpf_u_int32,
+ int, int, int);
#ifdef INET6
-static struct block *gen_host6(struct in6_addr *, struct in6_addr *, int, int, int);
+static struct block *gen_host6(compiler_state_t *, struct in6_addr *,
+ struct in6_addr *, int, int, int);
#endif
#ifndef INET6
-static struct block *gen_gateway(const u_char *, bpf_u_int32 **, int, int);
+static struct block *gen_gateway(compiler_state_t *, const u_char *,
+ bpf_u_int32 **, int, int);
#endif
-static struct block *gen_ipfrag(void);
-static struct block *gen_portatom(int, bpf_int32);
-static struct block *gen_portrangeatom(int, bpf_int32, bpf_int32);
-static struct block *gen_portatom6(int, bpf_int32);
-static struct block *gen_portrangeatom6(int, bpf_int32, bpf_int32);
-struct block *gen_portop(int, int, int);
-static struct block *gen_port(int, int, int);
-struct block *gen_portrangeop(int, int, int, int);
-static struct block *gen_portrange(int, int, int, int);
-struct block *gen_portop6(int, int, int);
-static struct block *gen_port6(int, int, int);
-struct block *gen_portrangeop6(int, int, int, int);
-static struct block *gen_portrange6(int, int, int, int);
-static int lookup_proto(const char *, int);
-static struct block *gen_protochain(int, int, int);
-static struct block *gen_proto(int, int, int);
-static struct slist *xfer_to_x(struct arth *);
-static struct slist *xfer_to_a(struct arth *);
-static struct block *gen_mac_multicast(int);
-static struct block *gen_len(int, int);
-static struct block *gen_check_802_11_data_frame(void);
-
-static struct block *gen_ppi_dlt_check(void);
-static struct block *gen_msg_abbrev(int type);
+static struct block *gen_ipfrag(compiler_state_t *);
+static struct block *gen_portatom(compiler_state_t *, int, bpf_int32);
+static struct block *gen_portrangeatom(compiler_state_t *, int, bpf_int32,
+ bpf_int32);
+static struct block *gen_portatom6(compiler_state_t *, int, bpf_int32);
+static struct block *gen_portrangeatom6(compiler_state_t *, int, bpf_int32,
+ bpf_int32);
+struct block *gen_portop(compiler_state_t *, int, int, int);
+static struct block *gen_port(compiler_state_t *, int, int, int);
+struct block *gen_portrangeop(compiler_state_t *, int, int, int, int);
+static struct block *gen_portrange(compiler_state_t *, int, int, int, int);
+struct block *gen_portop6(compiler_state_t *, int, int, int);
+static struct block *gen_port6(compiler_state_t *, int, int, int);
+struct block *gen_portrangeop6(compiler_state_t *, int, int, int, int);
+static struct block *gen_portrange6(compiler_state_t *, int, int, int, int);
+static int lookup_proto(compiler_state_t *, const char *, int);
+static struct block *gen_protochain(compiler_state_t *, int, int, int);
+static struct block *gen_proto(compiler_state_t *, int, int, int);
+static struct slist *xfer_to_x(compiler_state_t *, struct arth *);
+static struct slist *xfer_to_a(compiler_state_t *, struct arth *);
+static struct block *gen_mac_multicast(compiler_state_t *, int);
+static struct block *gen_len(compiler_state_t *, int, int);
+static struct block *gen_check_802_11_data_frame(compiler_state_t *);
+static struct block *gen_geneve_ll_check(compiler_state_t *cstate);
+
+static struct block *gen_ppi_dlt_check(compiler_state_t *);
+static struct block *gen_msg_abbrev(compiler_state_t *, int type);
+
+static void
+initchunks(compiler_state_t *cstate)
+{
+ int i;
+
+ for (i = 0; i < NCHUNKS; i++) {
+ cstate->chunks[i].n_left = 0;
+ cstate->chunks[i].m = NULL;
+ }
+ cstate->cur_chunk = 0;
+}
static void *
-newchunk(n)
- u_int n;
+newchunk(compiler_state_t *cstate, size_t n)
{
struct chunk *cp;
int k;
@@ -315,58 +585,53 @@ newchunk(n)
n = ALIGN(n);
#endif
- cp = &chunks[cur_chunk];
+ cp = &cstate->chunks[cstate->cur_chunk];
if (n > cp->n_left) {
- ++cp, k = ++cur_chunk;
+ ++cp, k = ++cstate->cur_chunk;
if (k >= NCHUNKS)
- bpf_error("out of memory");
+ bpf_error(cstate, "out of memory");
size = CHUNK0SIZE << k;
cp->m = (void *)malloc(size);
if (cp->m == NULL)
- bpf_error("out of memory");
+ bpf_error(cstate, "out of memory");
memset((char *)cp->m, 0, size);
cp->n_left = size;
if (n > size)
- bpf_error("out of memory");
+ bpf_error(cstate, "out of memory");
}
cp->n_left -= n;
return (void *)((char *)cp->m + cp->n_left);
}
static void
-freechunks()
+freechunks(compiler_state_t *cstate)
{
int i;
- cur_chunk = 0;
for (i = 0; i < NCHUNKS; ++i)
- if (chunks[i].m != NULL) {
- free(chunks[i].m);
- chunks[i].m = NULL;
- }
+ if (cstate->chunks[i].m != NULL)
+ free(cstate->chunks[i].m);
}
/*
* A strdup whose allocations are freed after code generation is over.
*/
char *
-sdup(s)
- register const char *s;
+sdup(compiler_state_t *cstate, const char *s)
{
- int n = strlen(s) + 1;
- char *cp = newchunk(n);
+ size_t n = strlen(s) + 1;
+ char *cp = newchunk(cstate, n);
strlcpy(cp, s, n);
return (cp);
}
static inline struct block *
-new_block(code)
- int code;
+new_block(compiler_state_t *cstate, int code)
{
struct block *p;
- p = (struct block *)newchunk(sizeof(*p));
+ p = (struct block *)newchunk(cstate, sizeof(*p));
p->s.code = code;
p->head = p;
@@ -374,130 +639,131 @@ new_block(code)
}
static inline struct slist *
-new_stmt(code)
- int code;
+new_stmt(compiler_state_t *cstate, int code)
{
struct slist *p;
- p = (struct slist *)newchunk(sizeof(*p));
+ p = (struct slist *)newchunk(cstate, sizeof(*p));
p->s.code = code;
return p;
}
static struct block *
-gen_retblk(v)
- int v;
+gen_retblk(compiler_state_t *cstate, int v)
{
- struct block *b = new_block(BPF_RET|BPF_K);
+ struct block *b = new_block(cstate, BPF_RET|BPF_K);
b->s.k = v;
return b;
}
static inline void
-syntax()
+syntax(compiler_state_t *cstate)
{
- bpf_error("syntax error in filter expression");
+ bpf_error(cstate, "syntax error in filter expression");
}
-static bpf_u_int32 netmask;
-static int snaplen;
-int no_optimize;
-#ifdef WIN32
-static int
-pcap_compile_unsafe(pcap_t *p, struct bpf_program *program,
- const char *buf, int optimize, bpf_u_int32 mask);
-
int
pcap_compile(pcap_t *p, struct bpf_program *program,
const char *buf, int optimize, bpf_u_int32 mask)
{
- int result;
-
- EnterCriticalSection(&g_PcapCompileCriticalSection);
-
- result = pcap_compile_unsafe(p, program, buf, optimize, mask);
-
- LeaveCriticalSection(&g_PcapCompileCriticalSection);
-
- return result;
-}
-
-static int
-pcap_compile_unsafe(pcap_t *p, struct bpf_program *program,
- const char *buf, int optimize, bpf_u_int32 mask)
-#else /* WIN32 */
-int
-pcap_compile(pcap_t *p, struct bpf_program *program,
- const char *buf, int optimize, bpf_u_int32 mask)
-#endif /* WIN32 */
-{
-#ifdef __rtems__
- int n_errors;
-#else
- extern int n_errors;
-#endif /* __rtems__ */
+ compiler_state_t cstate;
const char * volatile xbuf = buf;
+ yyscan_t scanner = NULL;
+ YY_BUFFER_STATE in_buffer = NULL;
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.
*/
if (!p->activated) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"not-yet-activated pcap_t passed to pcap_compile");
- return (-1);
+ rc = -1;
+ goto quit;
}
- no_optimize = 0;
- n_errors = 0;
- root = NULL;
- bpf_pcap = p;
- init_regs();
- if (setjmp(top_ctx)) {
+ initchunks(&cstate);
+ cstate.no_optimize = 0;
#ifdef INET6
- if (ai != NULL) {
- freeaddrinfo(ai);
- ai = NULL;
- }
+ cstate.ai = NULL;
#endif
- lex_cleanup();
- freechunks();
- return (-1);
+ cstate.ic.root = NULL;
+ cstate.ic.cur_mark = 0;
+ cstate.bpf_pcap = p;
+ init_regs(&cstate);
+
+ if (setjmp(cstate.top_ctx)) {
+#ifdef INET6
+ if (cstate.ai != NULL)
+ freeaddrinfo(cstate.ai);
+#endif
+ rc = -1;
+ goto quit;
}
- netmask = mask;
+ cstate.netmask = mask;
- snaplen = pcap_snapshot(p);
- if (snaplen == 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ cstate.snaplen = pcap_snapshot(p);
+ if (cstate.snaplen == 0) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"snaplen of 0 rejects all packets");
- return -1;
+ rc = -1;
+ goto quit;
}
- lex_init(xbuf ? xbuf : "");
- init_linktype(p);
- (void)pcap_parse();
+ if (pcap_lex_init(&scanner) != 0)
+ bpf_error(&cstate, "can't initialize scanner: %s", pcap_strerror(errno));
+ in_buffer = pcap__scan_string(xbuf ? xbuf : "", scanner);
+
+ /*
+ * Associate the compiler state with the lexical analyzer
+ * state.
+ */
+ pcap_set_extra(&cstate, scanner);
- if (n_errors)
- syntax();
+ init_linktype(&cstate, p);
+ (void)pcap_parse(scanner, &cstate);
- if (root == NULL)
- root = gen_retblk(snaplen);
+ if (cstate.ic.root == NULL)
+ cstate.ic.root = gen_retblk(&cstate, cstate.snaplen);
- if (optimize && !no_optimize) {
- bpf_optimize(&root);
- if (root == NULL ||
- (root->s.code == (BPF_RET|BPF_K) && root->s.k == 0))
- bpf_error("expression rejects all packets");
+ if (optimize && !cstate.no_optimize) {
+ bpf_optimize(&cstate, &cstate.ic);
+ if (cstate.ic.root == NULL ||
+ (cstate.ic.root->s.code == (BPF_RET|BPF_K) && cstate.ic.root->s.k == 0))
+ bpf_error(&cstate, "expression rejects all packets");
}
- program->bf_insns = icode_to_fcode(root, &len);
+ program->bf_insns = icode_to_fcode(&cstate, &cstate.ic, cstate.ic.root, &len);
program->bf_len = len;
- lex_cleanup();
- freechunks();
- return (0);
+ rc = 0; /* We're all okay */
+
+quit:
+ /*
+ * Clean up everything for the lexical analyzer.
+ */
+ if (in_buffer != NULL)
+ pcap__delete_buffer(in_buffer, scanner);
+ if (scanner != NULL)
+ pcap_lex_destroy(scanner);
+
+ /*
+ * Clean up our own allocated memory.
+ */
+ freechunks(&cstate);
+
+ return (rc);
}
/*
@@ -577,8 +843,7 @@ merge(b0, b1)
}
void
-finish_parse(p)
- struct block *p;
+finish_parse(compiler_state_t *cstate, struct block *p)
{
struct block *ppi_dlt_check;
@@ -601,20 +866,29 @@ finish_parse(p)
* for tests that fail early, and it's not clear that's
* worth the effort.
*/
- insert_compute_vloffsets(p->head);
+ insert_compute_vloffsets(cstate, p->head);
/*
* For DLT_PPI captures, generate a check of the per-packet
* DLT value to make sure it's DLT_IEEE802_11.
+ *
+ * XXX - TurboCap cards use DLT_PPI for Ethernet.
+ * Can we just define some DLT_ETHERNET_WITH_PHDR pseudo-header
+ * with appropriate Ethernet information and use that rather
+ * than using something such as DLT_PPI where you don't know
+ * the link-layer header type until runtime, which, in the
+ * general case, would force us to generate both Ethernet *and*
+ * 802.11 code (*and* anything else for which PPI is used)
+ * and choose between them early in the BPF program?
*/
- ppi_dlt_check = gen_ppi_dlt_check();
+ ppi_dlt_check = gen_ppi_dlt_check(cstate);
if (ppi_dlt_check != NULL)
gen_and(ppi_dlt_check, p);
- backpatch(p, gen_retblk(snaplen));
+ backpatch(p, gen_retblk(cstate, cstate->snaplen));
p->sense = !p->sense;
- backpatch(p, gen_retblk(0));
- root = p->head;
+ backpatch(p, gen_retblk(cstate, 0));
+ cstate->ic.root = p->head;
}
void
@@ -648,65 +922,50 @@ gen_not(b)
}
static struct block *
-gen_cmp(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JEQ, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JEQ, 0, v);
}
static struct block *
-gen_cmp_gt(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_gt(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGT, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGT, 0, v);
}
static struct block *
-gen_cmp_ge(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_ge(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGE, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGE, 0, v);
}
static struct block *
-gen_cmp_lt(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_lt(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGE, 1, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGE, 1, v);
}
static struct block *
-gen_cmp_le(offrel, offset, size, v)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
+gen_cmp_le(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v)
{
- return gen_ncmp(offrel, offset, size, 0xffffffff, BPF_JGT, 1, v);
+ return gen_ncmp(cstate, offrel, offset, size, 0xffffffff, BPF_JGT, 1, v);
}
static struct block *
-gen_mcmp(offrel, offset, size, v, mask)
- enum e_offrel offrel;
- u_int offset, size;
- bpf_int32 v;
- bpf_u_int32 mask;
+gen_mcmp(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, bpf_int32 v, bpf_u_int32 mask)
{
- return gen_ncmp(offrel, offset, size, mask, BPF_JEQ, 0, v);
+ return gen_ncmp(cstate, offrel, offset, size, mask, BPF_JEQ, 0, v);
}
static struct block *
-gen_bcmp(offrel, offset, size, v)
- enum e_offrel offrel;
- register u_int offset, size;
- register const u_char *v;
+gen_bcmp(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size, const u_char *v)
{
register struct block *b, *tmp;
@@ -716,7 +975,7 @@ gen_bcmp(offrel, offset, size, v)
bpf_int32 w = ((bpf_int32)p[0] << 24) |
((bpf_int32)p[1] << 16) | ((bpf_int32)p[2] << 8) | p[3];
- tmp = gen_cmp(offrel, offset + size - 4, BPF_W, w);
+ tmp = gen_cmp(cstate, offrel, offset + size - 4, BPF_W, w);
if (b != NULL)
gen_and(b, tmp);
b = tmp;
@@ -726,14 +985,14 @@ gen_bcmp(offrel, offset, size, v)
register const u_char *p = &v[size - 2];
bpf_int32 w = ((bpf_int32)p[0] << 8) | p[1];
- tmp = gen_cmp(offrel, offset + size - 2, BPF_H, w);
+ tmp = gen_cmp(cstate, offrel, offset + size - 2, BPF_H, w);
if (b != NULL)
gen_and(b, tmp);
b = tmp;
size -= 2;
}
if (size > 0) {
- tmp = gen_cmp(offrel, offset, BPF_B, (bpf_int32)v[0]);
+ tmp = gen_cmp(cstate, offrel, offset, BPF_B, (bpf_int32)v[0]);
if (b != NULL)
gen_and(b, tmp);
b = tmp;
@@ -748,24 +1007,22 @@ gen_bcmp(offrel, offset, size, v)
* should test the opposite of "jtype".
*/
static struct block *
-gen_ncmp(offrel, offset, size, mask, jtype, reverse, v)
- enum e_offrel offrel;
- bpf_int32 v;
- bpf_u_int32 offset, size, mask, jtype;
- int reverse;
+gen_ncmp(compiler_state_t *cstate, enum e_offrel offrel, bpf_u_int32 offset,
+ bpf_u_int32 size, bpf_u_int32 mask, bpf_u_int32 jtype, int reverse,
+ bpf_int32 v)
{
struct slist *s, *s2;
struct block *b;
- s = gen_load_a(offrel, offset, size);
+ s = gen_load_a(cstate, offrel, offset, size);
if (mask != 0xffffffff) {
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
s2->s.k = mask;
sappend(s, s2);
}
- b = new_block(JMP(jtype));
+ b = new_block(cstate, JMP(jtype));
b->stmts = s;
b->s.k = v;
if (reverse && (jtype == BPF_JGT || jtype == BPF_JGE))
@@ -773,294 +1030,152 @@ gen_ncmp(offrel, offset, size, mask, jtype, reverse, v)
return b;
}
-/*
- * Various code constructs need to know the layout of the data link
- * layer. These variables give the necessary offsets from the beginning
- * of the packet data.
- */
-
-/*
- * This is the offset of the beginning of the link-layer header from
- * the beginning of the raw packet data.
- *
- * It's usually 0, except for 802.11 with a fixed-length radio header.
- * (For 802.11 with a variable-length radio header, we have to generate
- * code to compute that offset; off_ll is 0 in that case.)
- */
-static u_int off_ll;
-
-/*
- * If there's a variable-length header preceding the link-layer header,
- * "reg_off_ll" is the register number for a register containing the
- * length of that header, and therefore the offset of the link-layer
- * header from the beginning of the raw packet data. Otherwise,
- * "reg_off_ll" is -1.
- */
-static int reg_off_ll;
-
-/*
- * This is the offset of the beginning of the MAC-layer header from
- * the beginning of the link-layer header.
- * It's usually 0, except for ATM LANE, where it's the offset, relative
- * to the beginning of the raw packet data, of the Ethernet header, and
- * for Ethernet with various additional information.
- */
-static u_int off_mac;
-
-/*
- * This is the offset of the beginning of the MAC-layer payload,
- * from the beginning of the raw packet data.
- *
- * I.e., it's the sum of the length of the link-layer header (without,
- * for example, any 802.2 LLC header, so it's the MAC-layer
- * portion of that header), plus any prefix preceding the
- * link-layer header.
- */
-static u_int off_macpl;
-
-/*
- * This is 1 if the offset of the beginning of the MAC-layer payload
- * from the beginning of the link-layer header is variable-length.
- */
-static int off_macpl_is_variable;
-
-/*
- * If the link layer has variable_length headers, "reg_off_macpl"
- * is the register number for a register containing the length of the
- * link-layer header plus the length of any variable-length header
- * preceding the link-layer header. Otherwise, "reg_off_macpl"
- * is -1.
- */
-static int reg_off_macpl;
-
-/*
- * "off_linktype" is the offset to information in the link-layer header
- * giving the packet type. This offset is relative to the beginning
- * of the link-layer header (i.e., it doesn't include off_ll).
- *
- * For Ethernet, it's the offset of the Ethernet type field.
- *
- * For link-layer types that always use 802.2 headers, it's the
- * offset of the LLC header.
- *
- * For PPP, it's the offset of the PPP type field.
- *
- * For Cisco HDLC, it's the offset of the CHDLC type field.
- *
- * For BSD loopback, it's the offset of the AF_ value.
- *
- * For Linux cooked sockets, it's the offset of the type field.
- *
- * It's set to -1 for no encapsulation, in which case, IP is assumed.
- */
-static u_int off_linktype;
-
-/*
- * TRUE if "pppoes" appeared in the filter; it causes link-layer type
- * checks to check the PPP header, assumed to follow a LAN-style link-
- * layer header and a PPPoE session header.
- */
-static int is_pppoes = 0;
-
-/*
- * TRUE if the link layer includes an ATM pseudo-header.
- */
-static int is_atm = 0;
-
-/*
- * TRUE if "lane" appeared in the filter; it causes us to generate
- * code that assumes LANE rather than LLC-encapsulated traffic in SunATM.
- */
-static int is_lane = 0;
-
-/*
- * These are offsets for the ATM pseudo-header.
- */
-static u_int off_vpi;
-static u_int off_vci;
-static u_int off_proto;
+static void
+init_linktype(compiler_state_t *cstate, pcap_t *p)
+{
+ cstate->pcap_fddipad = p->fddipad;
-/*
- * These are offsets for the MTP2 fields.
- */
-static u_int off_li;
+ /*
+ * We start out with only one link-layer header.
+ */
+ cstate->outermostlinktype = pcap_datalink(p);
+ cstate->off_outermostlinkhdr.constant_part = 0;
+ cstate->off_outermostlinkhdr.is_variable = 0;
+ cstate->off_outermostlinkhdr.reg = -1;
-/*
- * These are offsets for the MTP3 fields.
- */
-static u_int off_sio;
-static u_int off_opc;
-static u_int off_dpc;
-static u_int off_sls;
+ cstate->prevlinktype = cstate->outermostlinktype;
+ cstate->off_prevlinkhdr.constant_part = 0;
+ cstate->off_prevlinkhdr.is_variable = 0;
+ cstate->off_prevlinkhdr.reg = -1;
-/*
- * This is the offset of the first byte after the ATM pseudo_header,
- * or -1 if there is no ATM pseudo-header.
- */
-static u_int off_payload;
+ cstate->linktype = cstate->outermostlinktype;
+ cstate->off_linkhdr.constant_part = 0;
+ cstate->off_linkhdr.is_variable = 0;
+ cstate->off_linkhdr.reg = -1;
-/*
- * These are offsets to the beginning of the network-layer header.
- * They are relative to the beginning of the MAC-layer payload (i.e.,
- * they don't include off_ll or off_macpl).
- *
- * If the link layer never uses 802.2 LLC:
- *
- * "off_nl" and "off_nl_nosnap" are the same.
- *
- * If the link layer always uses 802.2 LLC:
- *
- * "off_nl" is the offset if there's a SNAP header following
- * the 802.2 header;
- *
- * "off_nl_nosnap" is the offset if there's no SNAP header.
- *
- * If the link layer is Ethernet:
- *
- * "off_nl" is the offset if the packet is an Ethernet II packet
- * (we assume no 802.3+802.2+SNAP);
- *
- * "off_nl_nosnap" is the offset if the packet is an 802.3 packet
- * with an 802.2 header following it.
- */
-static u_int off_nl;
-static u_int off_nl_nosnap;
-
-static int linktype;
+ /*
+ * XXX
+ */
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_linkpl.is_variable = 0;
+ cstate->off_linkpl.reg = -1;
-static void
-init_linktype(p)
- pcap_t *p;
-{
- linktype = pcap_datalink(p);
-#ifdef PCAP_FDDIPAD
- pcap_fddipad = p->fddipad;
-#endif
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linktype.is_variable = 0;
+ cstate->off_linktype.reg = -1;
/*
* Assume it's not raw ATM with a pseudo-header, for now.
*/
- off_mac = 0;
- is_atm = 0;
- is_lane = 0;
- off_vpi = -1;
- off_vci = -1;
- off_proto = -1;
- off_payload = -1;
+ cstate->is_atm = 0;
+ cstate->off_vpi = -1;
+ cstate->off_vci = -1;
+ cstate->off_proto = -1;
+ cstate->off_payload = -1;
/*
- * And that we're not doing PPPoE.
+ * And not Geneve.
*/
- is_pppoes = 0;
+ cstate->is_geneve = 0;
/*
* And assume we're not doing SS7.
*/
- off_li = -1;
- off_sio = -1;
- off_opc = -1;
- off_dpc = -1;
- off_sls = -1;
-
- /*
- * Also assume it's not 802.11.
- */
- off_ll = 0;
- off_macpl = 0;
- off_macpl_is_variable = 0;
-
- orig_linktype = -1;
- orig_nl = -1;
- label_stack_depth = 0;
+ 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;
- reg_off_ll = -1;
- reg_off_macpl = -1;
+ cstate->label_stack_depth = 0;
+ cstate->vlan_stack_depth = 0;
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_ARCNET:
- off_linktype = 2;
- off_macpl = 6;
- off_nl = 0; /* XXX in reality, variable! */
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 2;
+ cstate->off_linkpl.constant_part = 6;
+ cstate->off_nl = 0; /* XXX in reality, variable! */
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_ARCNET_LINUX:
- off_linktype = 4;
- off_macpl = 8;
- off_nl = 0; /* XXX in reality, variable! */
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 4;
+ cstate->off_linkpl.constant_part = 8;
+ cstate->off_nl = 0; /* XXX in reality, variable! */
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_EN10MB:
- off_linktype = 12;
- off_macpl = 14; /* Ethernet header length */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
- return;
+ cstate->off_linktype.constant_part = 12;
+ cstate->off_linkpl.constant_part = 14; /* Ethernet header length */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
+ break;
case DLT_SLIP:
/*
* SLIP doesn't have a link level type. The 16 byte
* header is hacked into our SLIP driver.
*/
- off_linktype = -1;
- off_macpl = 16;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 16;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_SLIP_BSDOS:
/* XXX this may be the same as the DLT_PPP_BSDOS case */
- off_linktype = -1;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
/* XXX end */
- off_macpl = 24;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linkpl.constant_part = 24;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_NULL:
case DLT_LOOP:
- off_linktype = 0;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = 4;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_ENC:
- off_linktype = 0;
- off_macpl = 12;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = 12;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_PPP:
case DLT_PPP_PPPD:
case DLT_C_HDLC: /* BSD/OS Cisco HDLC */
case DLT_PPP_SERIAL: /* NetBSD sync/async serial PPP */
- off_linktype = 2;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 2; /* skip HDLC-like framing */
+ cstate->off_linkpl.constant_part = 4; /* skip HDLC-like framing and protocol field */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_PPP_ETHER:
/*
* This does no include the Ethernet header, and
* only covers session state.
*/
- off_linktype = 6;
- off_macpl = 8;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 6;
+ cstate->off_linkpl.constant_part = 8;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_PPP_BSDOS:
- off_linktype = 5;
- off_macpl = 24;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 5;
+ cstate->off_linkpl.constant_part = 24;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_FDDI:
/*
@@ -1071,17 +1186,13 @@ init_linktype(p)
* is being used and pick out the encapsulated Ethernet type.
* XXX - should we generate code to check for SNAP?
*/
- off_linktype = 13;
-#ifdef PCAP_FDDIPAD
- off_linktype += pcap_fddipad;
-#endif
- off_macpl = 13; /* FDDI MAC header length */
-#ifdef PCAP_FDDIPAD
- off_macpl += pcap_fddipad;
-#endif
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 13;
+ cstate->off_linktype.constant_part += cstate->pcap_fddipad;
+ cstate->off_linkpl.constant_part = 13; /* FDDI MAC header length */
+ cstate->off_linkpl.constant_part += cstate->pcap_fddipad;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_IEEE802:
/*
@@ -1107,19 +1218,24 @@ init_linktype(p)
* the 16-bit value at an offset of 14 (shifted right
* 8 - figure out which byte that is).
*/
- off_linktype = 14;
- off_macpl = 14; /* Token Ring MAC header length */
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 14;
+ cstate->off_linkpl.constant_part = 14; /* Token Ring MAC header length */
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
- case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
+ cstate->off_linkhdr.is_variable = 1;
+ /* Fall through, 802.11 doesn't have a variable link
+ * prefix but is otherwise the same. */
+
+ case DLT_IEEE802_11:
/*
* 802.11 doesn't really have a link-level type field.
- * We set "off_linktype" to the offset of the LLC header.
+ * We set "off_linktype.constant_part" to the offset of
+ * the LLC header.
*
* To check for Ethernet types, we assume that SSAP = SNAP
* is being used and pick out the encapsulated Ethernet type.
@@ -1134,12 +1250,12 @@ init_linktype(p)
* header or an AVS header, so, in practice, it's
* variable-length.
*/
- off_linktype = 24;
- off_macpl = 0; /* link-layer header is variable-length */
- off_macpl_is_variable = 1;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 24;
+ cstate->off_linkpl.constant_part = 0; /* link-layer header is variable-length */
+ cstate->off_linkpl.is_variable = 1;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_PPI:
/*
@@ -1151,12 +1267,13 @@ init_linktype(p)
* the encapsulated DLT should be DLT_IEEE802_11) we
* generate code to check for this too.
*/
- off_linktype = 24;
- off_macpl = 0; /* link-layer header is variable-length */
- off_macpl_is_variable = 1;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 24;
+ cstate->off_linkpl.constant_part = 0; /* link-layer header is variable-length */
+ cstate->off_linkpl.is_variable = 1;
+ cstate->off_linkhdr.is_variable = 1;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_ATM_RFC1483:
case DLT_ATM_CLIP: /* Linux ATM defines this */
@@ -1171,44 +1288,43 @@ init_linktype(p)
* or "pppoa and tcp port 80" and have it check for
* PPPo{A,E} and a PPP protocol of IP and....
*/
- off_linktype = 0;
- off_macpl = 0; /* packet begins with LLC header */
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = 0; /* packet begins with LLC header */
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_SUNATM:
/*
* Full Frontal ATM; you get AALn PDUs with an ATM
* pseudo-header.
*/
- is_atm = 1;
- off_vpi = SUNATM_VPI_POS;
- off_vci = SUNATM_VCI_POS;
- off_proto = PROTO_POS;
- off_mac = -1; /* assume LLC-encapsulated, so no MAC-layer header */
- off_payload = SUNATM_PKT_BEGIN_POS;
- off_linktype = off_payload;
- off_macpl = off_payload; /* if LLC-encapsulated */
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->is_atm = 1;
+ cstate->off_vpi = SUNATM_VPI_POS;
+ cstate->off_vci = SUNATM_VCI_POS;
+ cstate->off_proto = PROTO_POS;
+ cstate->off_payload = SUNATM_PKT_BEGIN_POS;
+ cstate->off_linktype.constant_part = cstate->off_payload;
+ cstate->off_linkpl.constant_part = cstate->off_payload; /* if LLC-encapsulated */
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_RAW:
case DLT_IPV4:
case DLT_IPV6:
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_LINUX_SLL: /* fake header for Linux cooked socket */
- off_linktype = 14;
- off_macpl = 16;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 14;
+ cstate->off_linkpl.constant_part = 16;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_LTALK:
/*
@@ -1216,11 +1332,11 @@ init_linktype(p)
* but really it just indicates whether there is a "short" or
* "long" DDP packet following.
*/
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_IP_OVER_FC:
/*
@@ -1233,22 +1349,22 @@ init_linktype(p)
* XXX - should we generate code to check for SNAP? RFC
* 2625 says SNAP should be used.
*/
- off_linktype = 16;
- off_macpl = 16;
- off_nl = 8; /* 802.2+SNAP */
- off_nl_nosnap = 3; /* 802.2 */
- return;
+ cstate->off_linktype.constant_part = 16;
+ cstate->off_linkpl.constant_part = 16;
+ cstate->off_nl = 8; /* 802.2+SNAP */
+ cstate->off_nl_nosnap = 3; /* 802.2 */
+ break;
case DLT_FRELAY:
/*
* XXX - we should set this to handle SNAP-encapsulated
* frames (NLPID of 0x80).
*/
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
/*
* the only BPF-interesting FRF.16 frames are non-control frames;
@@ -1256,33 +1372,33 @@ init_linktype(p)
* so lets start with offset 4 for now and increments later on (FIXME);
*/
case DLT_MFR:
- off_linktype = -1;
- off_macpl = 0;
- off_nl = 4;
- off_nl_nosnap = 0; /* XXX - for now -> no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 0;
+ cstate->off_nl = 4;
+ cstate->off_nl_nosnap = 0; /* XXX - for now -> no 802.2 LLC */
+ break;
case DLT_APPLE_IP_OVER_IEEE1394:
- off_linktype = 16;
- off_macpl = 18;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 16;
+ cstate->off_linkpl.constant_part = 18;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
case DLT_SYMANTEC_FIREWALL:
- off_linktype = 6;
- off_macpl = 44;
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 0; /* XXX - what does it do with 802.3 packets? */
- return;
+ cstate->off_linktype.constant_part = 6;
+ cstate->off_linkpl.constant_part = 44;
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 0; /* XXX - what does it do with 802.3 packets? */
+ break;
#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
- off_linktype = 0;
- off_macpl = PFLOG_HDRLEN;
- off_nl = 0;
- off_nl_nosnap = 0; /* no 802.2 LLC */
- return;
+ cstate->off_linktype.constant_part = 0;
+ cstate->off_linkpl.constant_part = PFLOG_HDRLEN;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+ break;
#endif
case DLT_JUNIPER_MFR:
@@ -1291,279 +1407,244 @@ init_linktype(p)
case DLT_JUNIPER_PPP:
case DLT_JUNIPER_CHDLC:
case DLT_JUNIPER_FRELAY:
- off_linktype = 4;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ 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 */
+ break;
case DLT_JUNIPER_ATM1:
- off_linktype = 4; /* in reality variable between 4-8 */
- off_macpl = 4; /* in reality variable between 4-8 */
- off_nl = 0;
- off_nl_nosnap = 10;
- return;
+ cstate->off_linktype.constant_part = 4; /* in reality variable between 4-8 */
+ cstate->off_linkpl.constant_part = 4; /* in reality variable between 4-8 */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 10;
+ break;
case DLT_JUNIPER_ATM2:
- off_linktype = 8; /* in reality variable between 8-12 */
- off_macpl = 8; /* in reality variable between 8-12 */
- off_nl = 0;
- off_nl_nosnap = 10;
- return;
+ cstate->off_linktype.constant_part = 8; /* in reality variable between 8-12 */
+ cstate->off_linkpl.constant_part = 8; /* in reality variable between 8-12 */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 10;
+ break;
/* frames captured on a Juniper PPPoE service PIC
* contain raw ethernet frames */
case DLT_JUNIPER_PPPOE:
case DLT_JUNIPER_ETHER:
- off_macpl = 14;
- off_linktype = 16;
- off_nl = 18; /* Ethernet II */
- off_nl_nosnap = 21; /* 802.3+802.2 */
- return;
+ cstate->off_linkpl.constant_part = 14;
+ cstate->off_linktype.constant_part = 16;
+ cstate->off_nl = 18; /* Ethernet II */
+ cstate->off_nl_nosnap = 21; /* 802.3+802.2 */
+ break;
case DLT_JUNIPER_PPPOE_ATM:
- off_linktype = 4;
- off_macpl = 6;
- off_nl = 0;
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ 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 */
+ break;
case DLT_JUNIPER_GGSN:
- off_linktype = 6;
- off_macpl = 12;
- off_nl = 0;
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ 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 */
+ break;
case DLT_JUNIPER_ES:
- off_linktype = 6;
- off_macpl = -1; /* not really a network layer but raw IP addresses */
- off_nl = -1; /* not really a network layer but raw IP addresses */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ 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 */
+ break;
case DLT_JUNIPER_MONITOR:
- off_linktype = 12;
- off_macpl = 12;
- off_nl = 0; /* raw IP/IP6 header */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ 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 */
+ 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;
+ break;
case DLT_JUNIPER_SERVICES:
- off_linktype = 12;
- off_macpl = -1; /* L3 proto location dep. on cookie type */
- off_nl = -1; /* L3 proto location dep. on cookie type */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- return;
+ 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 */
+ break;
case DLT_JUNIPER_VP:
- off_linktype = 18;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 18;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_ST:
- off_linktype = 18;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 18;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_ISM:
- off_linktype = 8;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 8;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_JUNIPER_VS:
case DLT_JUNIPER_SRX_E2E:
case DLT_JUNIPER_FIBRECHANNEL:
case DLT_JUNIPER_ATM_CEMIC:
- off_linktype = 8;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 8;
+ cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
+ cstate->off_nl = -1;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_MTP2:
- off_li = 2;
- off_sio = 3;
- off_opc = 4;
- off_dpc = 4;
- off_sls = 7;
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_li = 2;
+ cstate->off_li_hsl = 4;
+ cstate->off_sio = 3;
+ cstate->off_opc = 4;
+ cstate->off_dpc = 4;
+ 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;
+ break;
case DLT_MTP2_WITH_PHDR:
- off_li = 6;
- off_sio = 7;
- off_opc = 8;
- off_dpc = 8;
- off_sls = 11;
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_li = 6;
+ cstate->off_li_hsl = 8;
+ cstate->off_sio = 7;
+ cstate->off_opc = 8;
+ cstate->off_dpc = 8;
+ 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;
+ break;
case DLT_ERF:
- off_li = 22;
- off_sio = 23;
- off_opc = 24;
- off_dpc = 24;
- off_sls = 27;
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ cstate->off_li = 22;
+ cstate->off_li_hsl = 24;
+ cstate->off_sio = 23;
+ cstate->off_opc = 24;
+ cstate->off_dpc = 24;
+ 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;
+ break;
case DLT_PFSYNC:
- off_linktype = -1;
- off_macpl = 4;
- off_nl = 0;
- off_nl_nosnap = 0;
- return;
+ cstate->off_linktype.constant_part = OFFSET_NOT_SET;
+ cstate->off_linkpl.constant_part = 4;
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0;
+ break;
case DLT_AX25_KISS:
/*
* Currently, only raw "link[N:M]" filtering is supported.
*/
- off_linktype = -1; /* variable, min 15, max 71 steps of 7 */
- off_macpl = -1;
- off_nl = -1; /* variable, min 16, max 71 steps of 7 */
- off_nl_nosnap = -1; /* no 802.2 LLC */
- off_mac = 1; /* step over the kiss length byte */
- return;
+ 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 */
+ break;
case DLT_IPNET:
- off_linktype = 1;
- off_macpl = 24; /* ipnet header length */
- off_nl = 0;
- off_nl_nosnap = -1;
- return;
+ cstate->off_linktype.constant_part = 1;
+ cstate->off_linkpl.constant_part = 24; /* ipnet header length */
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = -1;
+ break;
case DLT_NETANALYZER:
- off_mac = 4; /* MAC header is past 4-byte pseudo-header */
- off_linktype = 16; /* includes 4-byte pseudo-header */
- off_macpl = 18; /* pseudo-header+Ethernet header length */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
- return;
+ cstate->off_linkhdr.constant_part = 4; /* Ethernet header is past 4-byte pseudo-header */
+ cstate->off_linktype.constant_part = cstate->off_linkhdr.constant_part + 12;
+ cstate->off_linkpl.constant_part = cstate->off_linkhdr.constant_part + 14; /* pseudo-header+Ethernet header length */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
+ break;
case DLT_NETANALYZER_TRANSPARENT:
- off_mac = 12; /* MAC header is past 4-byte pseudo-header, preamble, and SFD */
- off_linktype = 24; /* includes 4-byte pseudo-header+preamble+SFD */
- off_macpl = 26; /* pseudo-header+preamble+SFD+Ethernet header length */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
- return;
+ cstate->off_linkhdr.constant_part = 12; /* MAC header is past 4-byte pseudo-header, preamble, and SFD */
+ cstate->off_linktype.constant_part = cstate->off_linkhdr.constant_part + 12;
+ cstate->off_linkpl.constant_part = cstate->off_linkhdr.constant_part + 14; /* pseudo-header+preamble+SFD+Ethernet header length */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
+ break;
default:
/*
* For values in the range in which we've assigned new
* DLT_ values, only raw "link[N:M]" filtering is supported.
*/
- if (linktype >= DLT_MATCHING_MIN &&
- linktype <= DLT_MATCHING_MAX) {
- off_linktype = -1;
- off_macpl = -1;
- off_nl = -1;
- off_nl_nosnap = -1;
- return;
+ if (cstate->linktype >= DLT_MATCHING_MIN &&
+ 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;
+ } else {
+ bpf_error(cstate, "unknown data link type %d", cstate->linktype);
}
-
+ break;
}
- bpf_error("unknown data link type %d", linktype);
- /* NOTREACHED */
-}
-
-/*
- * Load a value relative to the beginning of the link-layer header.
- * The link-layer header doesn't necessarily begin at the beginning
- * of the packet data; there might be a variable-length prefix containing
- * radio information.
- */
-static struct slist *
-gen_load_llrel(offset, size)
- u_int offset, size;
-{
- struct slist *s, *s2;
-
- s = gen_llprefixlen();
- /*
- * If "s" is non-null, it has code to arrange that the X register
- * contains the length of the prefix preceding the link-layer
- * header.
- *
- * Otherwise, the length of the prefix preceding the link-layer
- * header is "off_ll".
- */
- if (s != NULL) {
- /*
- * There's a variable-length prefix preceding the
- * link-layer header. "s" points to a list of statements
- * that put the length of that prefix into the X register.
- * do an indirect load, to use the X register as an offset.
- */
- s2 = new_stmt(BPF_LD|BPF_IND|size);
- s2->s.k = offset;
- sappend(s, s2);
- } else {
- /*
- * There is no variable-length header preceding the
- * link-layer header; add in off_ll, which, if there's
- * a fixed-length header preceding the link-layer header,
- * is the length of that header.
- */
- s = new_stmt(BPF_LD|BPF_ABS|size);
- s->s.k = offset + off_ll;
- }
- return s;
+ cstate->off_outermostlinkhdr = cstate->off_prevlinkhdr = cstate->off_linkhdr;
}
/*
- * Load a value relative to the beginning of the MAC-layer payload.
+ * Load a value relative to the specified absolute offset.
*/
static struct slist *
-gen_load_macplrel(offset, size)
- u_int offset, size;
+gen_load_absoffsetrel(compiler_state_t *cstate, bpf_abs_offset *abs_offset,
+ u_int offset, u_int size)
{
struct slist *s, *s2;
- s = gen_off_macpl();
+ s = gen_abs_offset_varpart(cstate, abs_offset);
/*
- * If s is non-null, the offset of the MAC-layer payload is
- * variable, and s points to a list of instructions that
- * arrange that the X register contains that offset.
+ * If "s" is non-null, it has code to arrange that the X register
+ * contains the variable part of the absolute offset, so we
+ * generate a load relative to that, with an offset of
+ * abs_offset->constant_part + offset.
*
- * Otherwise, the offset of the MAC-layer payload is constant,
- * and is in off_macpl.
+ * Otherwise, we can do an absolute load with an offset of
+ * abs_offset->constant_part + offset.
*/
if (s != NULL) {
/*
- * The offset of the MAC-layer payload is in the X
- * register. Do an indirect load, to use the X register
- * as an offset.
+ * "s" points to a list of statements that puts the
+ * variable part of the absolute offset into the X register.
+ * Do an indirect load, to use the X register as an offset.
*/
- s2 = new_stmt(BPF_LD|BPF_IND|size);
- s2->s.k = offset;
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|size);
+ s2->s.k = abs_offset->constant_part + offset;
sappend(s, s2);
} else {
/*
- * The offset of the MAC-layer payload is constant,
- * and is in off_macpl; load the value at that offset
- * plus the specified offset.
+ * There is no variable part of the absolute offset, so
+ * just do an absolute load.
*/
- s = new_stmt(BPF_LD|BPF_ABS|size);
- s->s.k = off_macpl + offset;
+ s = new_stmt(cstate, BPF_LD|BPF_ABS|size);
+ s->s.k = abs_offset->constant_part + offset;
}
return s;
}
@@ -1572,33 +1653,44 @@ gen_load_macplrel(offset, size)
* Load a value relative to the beginning of the specified header.
*/
static struct slist *
-gen_load_a(offrel, offset, size)
- enum e_offrel offrel;
- u_int offset, size;
+gen_load_a(compiler_state_t *cstate, enum e_offrel offrel, u_int offset,
+ u_int size)
{
struct slist *s, *s2;
switch (offrel) {
case OR_PACKET:
- s = new_stmt(BPF_LD|BPF_ABS|size);
+ s = new_stmt(cstate, BPF_LD|BPF_ABS|size);
s->s.k = offset;
break;
- case OR_LINK:
- s = gen_load_llrel(offset, size);
+ case OR_LINKHDR:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkhdr, offset, size);
+ break;
+
+ case OR_PREVLINKHDR:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_prevlinkhdr, offset, size);
+ break;
+
+ case OR_LLC:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, offset, size);
break;
- case OR_MACPL:
- s = gen_load_macplrel(offset, size);
+ case OR_PREVMPLSHDR:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl - 4 + offset, size);
break;
- case OR_NET:
- s = gen_load_macplrel(off_nl + offset, size);
+ case OR_LINKPL:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl + offset, size);
break;
- case OR_NET_NOSNAP:
- s = gen_load_macplrel(off_nl_nosnap + offset, size);
+ case OR_LINKPL_NOSNAP:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl_nosnap + offset, size);
+ break;
+
+ case OR_LINKTYPE:
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linktype, offset, size);
break;
case OR_TRAN_IPV4:
@@ -1608,25 +1700,26 @@ gen_load_a(offrel, offset, size)
* preceded by a variable-length header such as a radio
* header), in bytes.
*/
- s = gen_loadx_iphdrlen();
+ s = gen_loadx_iphdrlen(cstate);
/*
- * Load the item at {offset of the MAC-layer payload} +
- * {offset, relative to the start of the MAC-layer
+ * Load the item at {offset of the link-layer payload} +
+ * {offset, relative to the start of the link-layer
* paylod, of the IPv4 header} + {length of the IPv4 header} +
* {specified offset}.
*
- * (If the offset of the MAC-layer payload is variable,
- * it's included in the value in the X register, and
- * off_macpl is 0.)
+ * If the offset of the link-layer payload is variable,
+ * the variable part of that offset is included in the
+ * value in the X register, and we include the constant
+ * part in the offset of the load.
*/
- s2 = new_stmt(BPF_LD|BPF_IND|size);
- s2->s.k = off_macpl + off_nl + offset;
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|size);
+ s2->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + offset;
sappend(s, s2);
break;
case OR_TRAN_IPV6:
- s = gen_load_macplrel(off_nl + 40 + offset, size);
+ s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl + 40 + offset, size);
break;
default:
@@ -1638,87 +1731,87 @@ gen_load_a(offrel, offset, size)
/*
* Generate code to load into the X register the sum of the length of
- * the IPv4 header and any variable-length header preceding the link-layer
- * header.
+ * the IPv4 header and the variable part of the offset of the link-layer
+ * payload.
*/
static struct slist *
-gen_loadx_iphdrlen()
+gen_loadx_iphdrlen(compiler_state_t *cstate)
{
struct slist *s, *s2;
- s = gen_off_macpl();
+ s = gen_abs_offset_varpart(cstate, &cstate->off_linkpl);
if (s != NULL) {
/*
- * There's a variable-length prefix preceding the
- * link-layer header, or the link-layer header is itself
- * variable-length. "s" points to a list of statements
- * that put the offset of the MAC-layer payload into
- * the X register.
+ * The offset of the link-layer payload has a variable
+ * part. "s" points to a list of statements that put
+ * the variable part of that offset into the X register.
*
* The 4*([k]&0xf) addressing mode can't be used, as we
* don't have a constant offset, so we have to load the
* value in question into the A register and add to it
* the value from the X register.
*/
- s2 = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s2->s.k = off_nl;
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s2->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
s2->s.k = 0xf;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_LSH|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_LSH|BPF_K);
s2->s.k = 2;
sappend(s, s2);
/*
- * The A register now contains the length of the
- * IP header. We need to add to it the offset of
- * the MAC-layer payload, which is still in the X
+ * The A register now contains the length of the IP header.
+ * We need to add to it the variable part of the offset of
+ * the link-layer payload, which is still in the X
* register, and move the result into the X register.
*/
- sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X));
- sappend(s, new_stmt(BPF_MISC|BPF_TAX));
+ sappend(s, new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_X));
+ sappend(s, new_stmt(cstate, BPF_MISC|BPF_TAX));
} else {
/*
- * There is no variable-length header preceding the
- * link-layer header, and the link-layer header is
- * fixed-length; load the length of the IPv4 header,
- * which is at an offset of off_nl from the beginning
- * of the MAC-layer payload, and thus at an offset
- * of off_mac_pl + off_nl from the beginning of the
- * raw packet data.
- */
- s = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
- s->s.k = off_macpl + off_nl;
+ * The offset of the link-layer payload is a constant,
+ * so no code was generated to load the (non-existent)
+ * variable part of that offset.
+ *
+ * This means we can use the 4*([k]&0xf) addressing
+ * mode. Load the length of the IPv4 header, which
+ * is at an offset of cstate->off_nl from the beginning of
+ * the link-layer payload, and thus at an offset of
+ * cstate->off_linkpl.constant_part + cstate->off_nl from the beginning
+ * of the raw packet data, using that addressing mode.
+ */
+ s = new_stmt(cstate, BPF_LDX|BPF_MSH|BPF_B);
+ s->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
}
return s;
}
static struct block *
-gen_uncond(rsense)
- int rsense;
+gen_uncond(compiler_state_t *cstate, int rsense)
{
struct block *b;
struct slist *s;
- s = new_stmt(BPF_LD|BPF_IMM);
+ s = new_stmt(cstate, BPF_LD|BPF_IMM);
s->s.k = !rsense;
- b = new_block(JMP(BPF_JEQ));
+ b = new_block(cstate, JMP(BPF_JEQ));
b->stmts = s;
return b;
}
static inline struct block *
-gen_true()
+gen_true(compiler_state_t *cstate)
{
- return gen_uncond(1);
+ return gen_uncond(cstate, 1);
}
static inline struct block *
-gen_false()
+gen_false(compiler_state_t *cstate)
{
- return gen_uncond(0);
+ return gen_uncond(cstate, 0);
}
/*
@@ -1739,8 +1832,7 @@ gen_false()
* the appropriate test.
*/
static struct block *
-gen_ether_linktype(proto)
- register int proto;
+gen_ether_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1;
@@ -1761,9 +1853,9 @@ gen_ether_linktype(proto)
* DSAP, as we do for other types <= ETHERMTU
* (i.e., other SAP values)?
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)
((proto << 8) | proto));
gen_and(b0, b1);
return b1;
@@ -1801,22 +1893,22 @@ gen_ether_linktype(proto)
* This generates code to check both for the
* IPX LSAP (Ethernet_802.2) and for Ethernet_802.3.
*/
- b0 = gen_cmp(OR_MACPL, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)0xFFFF);
+ b0 = gen_cmp(cstate, OR_LLC, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)0xFFFF);
gen_or(b0, b1);
/*
* Now we add code to check for SNAP frames with
* ETHERTYPE_IPX, i.e. Ethernet_SNAP.
*/
- b0 = gen_snap(0x000000, ETHERTYPE_IPX);
+ b0 = gen_snap(cstate, 0x000000, ETHERTYPE_IPX);
gen_or(b0, b1);
/*
* Now we generate code to check for 802.3
* frames in general.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
/*
@@ -1832,8 +1924,7 @@ gen_ether_linktype(proto)
* do that before checking for the other frame
* types.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)ETHERTYPE_IPX);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)ETHERTYPE_IPX);
gen_or(b0, b1);
return b1;
@@ -1849,7 +1940,7 @@ gen_ether_linktype(proto)
* we check for an Ethernet type field less than
* 1500, which means it's an 802.3 length field.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
/*
@@ -1864,9 +1955,9 @@ gen_ether_linktype(proto)
* type of ETHERTYPE_AARP (Appletalk ARP).
*/
if (proto == ETHERTYPE_ATALK)
- b1 = gen_snap(0x080007, ETHERTYPE_ATALK);
+ b1 = gen_snap(cstate, 0x080007, ETHERTYPE_ATALK);
else /* proto == ETHERTYPE_AARP */
- b1 = gen_snap(0x000000, ETHERTYPE_AARP);
+ b1 = gen_snap(cstate, 0x000000, ETHERTYPE_AARP);
gen_and(b0, b1);
/*
@@ -1874,7 +1965,7 @@ gen_ether_linktype(proto)
* phase 1?); we just check for the Ethernet
* protocol type.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
gen_or(b0, b1);
return b1;
@@ -1889,10 +1980,9 @@ gen_ether_linktype(proto)
* a length field, <= ETHERMTU) and
* then check the DSAP.
*/
- b0 = gen_cmp_gt(OR_LINK, off_linktype, BPF_H, ETHERMTU);
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
gen_not(b0);
- b1 = gen_cmp(OR_LINK, off_linktype + 2, BPF_B,
- (bpf_int32)proto);
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 2, BPF_B, (bpf_int32)proto);
gen_and(b0, b1);
return b1;
} else {
@@ -1905,29 +1995,62 @@ gen_ether_linktype(proto)
* will fail and the frame won't match,
* which is what we want).
*/
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H,
(bpf_int32)proto);
}
}
}
+static struct block *
+gen_loopback_linktype(compiler_state_t *cstate, int proto)
+{
+ /*
+ * For DLT_NULL, the link-layer header is a 32-bit word
+ * containing an AF_ value in *host* byte order, and for
+ * DLT_ENC, the link-layer header begins with a 32-bit
+ * word containing an AF_ value in host byte order.
+ *
+ * In addition, if we're reading a saved capture file,
+ * the host byte order in the capture may not be the
+ * same as the host byte order on this machine.
+ *
+ * For DLT_LOOP, the link-layer header is a 32-bit
+ * word containing an AF_ value in *network* byte order.
+ */
+ if (cstate->linktype == DLT_NULL || cstate->linktype == DLT_ENC) {
+ /*
+ * The AF_ value is in host byte order, but the BPF
+ * interpreter will convert it to network byte order.
+ *
+ * If this is a save file, and it's from a machine
+ * with the opposite byte order to ours, we byte-swap
+ * the AF_ value.
+ *
+ * Then we run it through "htonl()", and generate
+ * code to compare against the result.
+ */
+ if (cstate->bpf_pcap->rfile != NULL && cstate->bpf_pcap->swapped)
+ proto = SWAPLONG(proto);
+ proto = htonl(proto);
+ }
+ return (gen_cmp(cstate, OR_LINKHDR, 0, BPF_W, (bpf_int32)proto));
+}
+
/*
* "proto" is an Ethernet type value and for IPNET, if it is not IPv4
* or IPv6 then we have an error.
*/
static struct block *
-gen_ipnet_linktype(proto)
- register int proto;
+gen_ipnet_linktype(compiler_state_t *cstate, int proto)
{
switch (proto) {
case ETHERTYPE_IP:
- return gen_cmp(OR_LINK, off_linktype, BPF_B,
- (bpf_int32)IPH_AF_INET);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B, (bpf_int32)IPH_AF_INET);
/* NOTREACHED */
case ETHERTYPE_IPV6:
- return gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)IPH_AF_INET6);
/* NOTREACHED */
@@ -1935,7 +2058,7 @@ gen_ipnet_linktype(proto)
break;
}
- return gen_false();
+ return gen_false(cstate);
}
/*
@@ -1947,8 +2070,7 @@ gen_ipnet_linktype(proto)
* LINUX_SLL_P_802_2 value and then do the appropriate test.
*/
static struct block *
-gen_linux_sll_linktype(proto)
- register int proto;
+gen_linux_sll_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1;
@@ -1969,8 +2091,8 @@ gen_linux_sll_linktype(proto)
* DSAP, as we do for other types <= ETHERMTU
* (i.e., other SAP values)?
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_2);
- b1 = gen_cmp(OR_MACPL, 0, BPF_H, (bpf_int32)
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)
((proto << 8) | proto));
gen_and(b0, b1);
return b1;
@@ -2001,17 +2123,17 @@ gen_linux_sll_linktype(proto)
* then put a check for LINUX_SLL_P_802_2 frames
* before it.
*/
- b0 = gen_cmp(OR_MACPL, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
- b1 = gen_snap(0x000000, ETHERTYPE_IPX);
+ b0 = gen_cmp(cstate, OR_LLC, 0, BPF_B, (bpf_int32)LLCSAP_IPX);
+ b1 = gen_snap(cstate, 0x000000, ETHERTYPE_IPX);
gen_or(b0, b1);
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_2);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
gen_and(b0, b1);
/*
* Now check for 802.3 frames and OR that with
* the previous test.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_3);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_3);
gen_or(b0, b1);
/*
@@ -2019,8 +2141,7 @@ gen_linux_sll_linktype(proto)
* do that before checking for the other frame
* types.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)ETHERTYPE_IPX);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)ETHERTYPE_IPX);
gen_or(b0, b1);
return b1;
@@ -2036,7 +2157,7 @@ gen_linux_sll_linktype(proto)
* we check for the 802.2 protocol type in the
* "Ethernet type" field.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, LINUX_SLL_P_802_2);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
/*
* 802.2-encapsulated ETHERTYPE_ATALK packets are
@@ -2050,9 +2171,9 @@ gen_linux_sll_linktype(proto)
* type of ETHERTYPE_AARP (Appletalk ARP).
*/
if (proto == ETHERTYPE_ATALK)
- b1 = gen_snap(0x080007, ETHERTYPE_ATALK);
+ b1 = gen_snap(cstate, 0x080007, ETHERTYPE_ATALK);
else /* proto == ETHERTYPE_AARP */
- b1 = gen_snap(0x000000, ETHERTYPE_AARP);
+ b1 = gen_snap(cstate, 0x000000, ETHERTYPE_AARP);
gen_and(b0, b1);
/*
@@ -2060,7 +2181,7 @@ gen_linux_sll_linktype(proto)
* phase 1?); we just check for the Ethernet
* protocol type.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
gen_or(b0, b1);
return b1;
@@ -2074,9 +2195,8 @@ gen_linux_sll_linktype(proto)
* in the "Ethernet type" field, and
* then check the DSAP.
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- LINUX_SLL_P_802_2);
- b1 = gen_cmp(OR_LINK, off_macpl, BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, LINUX_SLL_P_802_2);
+ b1 = gen_cmp(cstate, OR_LINKHDR, cstate->off_linkpl.constant_part, BPF_B,
(bpf_int32)proto);
gen_and(b0, b1);
return b1;
@@ -2090,14 +2210,13 @@ gen_linux_sll_linktype(proto)
* will fail and the frame won't match,
* which is what we want).
*/
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
}
}
}
static struct slist *
-gen_load_prism_llprefixlen()
+gen_load_prism_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
struct slist *sjeq_avs_cookie;
@@ -2108,7 +2227,7 @@ gen_load_prism_llprefixlen()
* we are generating jmp instructions within a normal
* slist of instructions
*/
- no_optimize = 1;
+ cstate->no_optimize = 1;
/*
* Generate code to load the length of the radio header into
@@ -2129,24 +2248,24 @@ gen_load_prism_llprefixlen()
* but no known software generates headers that aren't 144
* bytes long.
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* Load the cookie.
*/
- s1 = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s1->s.k = 0;
/*
* AND it with 0xFFFFF000.
*/
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
s2->s.k = 0xFFFFF000;
sappend(s1, s2);
/*
* Compare with 0x80211000.
*/
- sjeq_avs_cookie = new_stmt(JMP(BPF_JEQ));
+ sjeq_avs_cookie = new_stmt(cstate, JMP(BPF_JEQ));
sjeq_avs_cookie->s.k = 0x80211000;
sappend(s1, sjeq_avs_cookie);
@@ -2157,7 +2276,7 @@ gen_load_prism_llprefixlen()
* the AVS header are the length of the AVS header.
* That field is big-endian.
*/
- s2 = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s2 = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s2->s.k = 4;
sappend(s1, s2);
sjeq_avs_cookie->s.jt = s2;
@@ -2170,7 +2289,7 @@ gen_load_prism_llprefixlen()
* it's added to the PC, so, as we're jumping
* over a single instruction, it should be 1.)
*/
- sjcommon = new_stmt(JMP(BPF_JA));
+ sjcommon = new_stmt(cstate, JMP(BPF_JA));
sjcommon->s.k = 1;
sappend(s1, sjcommon);
@@ -2180,7 +2299,7 @@ gen_load_prism_llprefixlen()
* into the A register. Have the test for an AVS
* header branch here if we don't have an AVS header.
*/
- s2 = new_stmt(BPF_LD|BPF_W|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_LD|BPF_W|BPF_IMM);
s2->s.k = 144;
sappend(s1, s2);
sjeq_avs_cookie->s.jf = s2;
@@ -2190,15 +2309,15 @@ gen_load_prism_llprefixlen()
* it. The code for the AVS header will jump here after
* loading the length of the AVS header.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
sjcommon->s.jf = s2;
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2207,7 +2326,7 @@ gen_load_prism_llprefixlen()
}
static struct slist *
-gen_load_avs_llprefixlen()
+gen_load_avs_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
@@ -2218,27 +2337,27 @@ gen_load_avs_llprefixlen()
* generated uses that prefix, so we don't need to generate any
* code to load it.)
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* The 4 bytes at an offset of 4 from the beginning of
* the AVS header are the length of the AVS header.
* That field is big-endian.
*/
- s1 = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s1->s.k = 4;
/*
* Now allocate a register to hold that value and store
* it.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2247,7 +2366,7 @@ gen_load_avs_llprefixlen()
}
static struct slist *
-gen_load_radiotap_llprefixlen()
+gen_load_radiotap_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
@@ -2258,7 +2377,7 @@ gen_load_radiotap_llprefixlen()
* generated uses that prefix, so we don't need to generate any
* code to load it.)
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* The 2 bytes at offsets of 2 and 3 from the beginning
* of the radiotap header are the length of the radiotap
@@ -2270,36 +2389,36 @@ gen_load_radiotap_llprefixlen()
* Load the high-order byte, at an offset of 3, shift it
* left a byte, and put the result in the X register.
*/
- s1 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
s1->s.k = 3;
- s2 = new_stmt(BPF_ALU|BPF_LSH|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_LSH|BPF_K);
sappend(s1, s2);
s2->s.k = 8;
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
/*
* Load the next byte, at an offset of 2, and OR the
* value from the X register into it.
*/
- s2 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s2 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
sappend(s1, s2);
s2->s.k = 2;
- s2 = new_stmt(BPF_ALU|BPF_OR|BPF_X);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_OR|BPF_X);
sappend(s1, s2);
/*
* Now allocate a register to hold that value and store
* it.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2317,7 +2436,7 @@ gen_load_radiotap_llprefixlen()
* that's done in finish_parse().
*/
static struct slist *
-gen_load_ppi_llprefixlen()
+gen_load_ppi_llprefixlen(compiler_state_t *cstate)
{
struct slist *s1, *s2;
@@ -2326,7 +2445,7 @@ gen_load_ppi_llprefixlen()
* into the register assigned to hold that length, if one has
* been assigned.
*/
- if (reg_off_ll != -1) {
+ if (cstate->off_linkhdr.reg != -1) {
/*
* The 2 bytes at offsets of 2 and 3 from the beginning
* of the radiotap header are the length of the radiotap
@@ -2338,36 +2457,36 @@ gen_load_ppi_llprefixlen()
* Load the high-order byte, at an offset of 3, shift it
* left a byte, and put the result in the X register.
*/
- s1 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s1 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
s1->s.k = 3;
- s2 = new_stmt(BPF_ALU|BPF_LSH|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_LSH|BPF_K);
sappend(s1, s2);
s2->s.k = 8;
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
/*
* Load the next byte, at an offset of 2, and OR the
* value from the X register into it.
*/
- s2 = new_stmt(BPF_LD|BPF_B|BPF_ABS);
+ s2 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
sappend(s1, s2);
s2->s.k = 2;
- s2 = new_stmt(BPF_ALU|BPF_OR|BPF_X);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_OR|BPF_X);
sappend(s1, s2);
/*
* Now allocate a register to hold that value and store
* it.
*/
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_ll;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkhdr.reg;
sappend(s1, s2);
/*
* Now move it into the X register.
*/
- s2 = new_stmt(BPF_MISC|BPF_TAX);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
sappend(s1, s2);
return (s1);
@@ -2383,21 +2502,22 @@ gen_load_ppi_llprefixlen()
* radio information.
*/
static struct slist *
-gen_load_802_11_header_len(struct slist *s, struct slist *snext)
+gen_load_802_11_header_len(compiler_state_t *cstate, struct slist *s, struct slist *snext)
{
struct slist *s2;
struct slist *sjset_data_frame_1;
struct slist *sjset_data_frame_2;
struct slist *sjset_qos;
- struct slist *sjset_radiotap_flags;
- struct slist *sjset_radiotap_tsft;
+ struct slist *sjset_radiotap_flags_present;
+ struct slist *sjset_radiotap_ext_present;
+ struct slist *sjset_radiotap_tsft_present;
struct slist *sjset_tsft_datapad, *sjset_notsft_datapad;
struct slist *s_roundup;
- if (reg_off_macpl == -1) {
+ if (cstate->off_linkpl.reg == -1) {
/*
* No register has been assigned to the offset of
- * the MAC-layer payload, which means nobody needs
+ * the link-layer payload, which means nobody needs
* it; don't bother computing it - just return
* what we already have.
*/
@@ -2409,7 +2529,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* we are generating jmp instructions within a normal
* slist of instructions
*/
- no_optimize = 1;
+ cstate->no_optimize = 1;
/*
* If "s" is non-null, it has code to arrange that the X register
@@ -2417,7 +2537,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* header.
*
* Otherwise, the length of the prefix preceding the link-layer
- * header is "off_ll".
+ * header is "off_outermostlinkhdr.constant_part".
*/
if (s == NULL) {
/*
@@ -2426,30 +2546,30 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
*
* Load the length of the fixed-length prefix preceding
* the link-layer header (if any) into the X register,
- * and store it in the reg_off_macpl register.
- * That length is off_ll.
+ * and store it in the cstate->off_linkpl.reg register.
+ * That length is off_outermostlinkhdr.constant_part.
*/
- s = new_stmt(BPF_LDX|BPF_IMM);
- s->s.k = off_ll;
+ s = new_stmt(cstate, BPF_LDX|BPF_IMM);
+ s->s.k = cstate->off_outermostlinkhdr.constant_part;
}
/*
* The X register contains the offset of the beginning of the
* link-layer header; add 24, which is the minimum length
* of the MAC header for a data frame, to that, and store it
- * in reg_off_macpl, and then load the Frame Control field,
+ * in cstate->off_linkpl.reg, and then load the Frame Control field,
* which is at the offset in the X register, with an indexed load.
*/
- s2 = new_stmt(BPF_MISC|BPF_TXA);
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TXA);
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s2->s.k = 24;
sappend(s, s2);
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_macpl;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
- s2 = new_stmt(BPF_LD|BPF_IND|BPF_B);
+ s2 = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
s2->s.k = 0;
sappend(s, s2);
@@ -2458,7 +2578,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* a data frame has the 0x08 bit (b3) in that field set and the
* 0x04 bit (b2) clear.
*/
- sjset_data_frame_1 = new_stmt(JMP(BPF_JSET));
+ sjset_data_frame_1 = new_stmt(cstate, JMP(BPF_JSET));
sjset_data_frame_1->s.k = 0x08;
sappend(s, sjset_data_frame_1);
@@ -2466,7 +2586,7 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* If b3 is set, test b2, otherwise go to the first statement of
* the rest of the program.
*/
- sjset_data_frame_1->s.jt = sjset_data_frame_2 = new_stmt(JMP(BPF_JSET));
+ sjset_data_frame_1->s.jt = sjset_data_frame_2 = new_stmt(cstate, JMP(BPF_JSET));
sjset_data_frame_2->s.k = 0x04;
sappend(s, sjset_data_frame_2);
sjset_data_frame_1->s.jf = snext;
@@ -2477,24 +2597,24 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* program.
*/
sjset_data_frame_2->s.jt = snext;
- sjset_data_frame_2->s.jf = sjset_qos = new_stmt(JMP(BPF_JSET));
+ sjset_data_frame_2->s.jf = sjset_qos = new_stmt(cstate, JMP(BPF_JSET));
sjset_qos->s.k = 0x80; /* QoS bit */
sappend(s, sjset_qos);
/*
- * If it's set, add 2 to reg_off_macpl, to skip the QoS
+ * If it's set, add 2 to cstate->off_linkpl.reg, to skip the QoS
* field.
* Otherwise, go to the first statement of the rest of the
* program.
*/
- sjset_qos->s.jt = s2 = new_stmt(BPF_LD|BPF_MEM);
- s2->s.k = reg_off_macpl;
+ sjset_qos->s.jt = s2 = new_stmt(cstate, BPF_LD|BPF_MEM);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_ADD|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_IMM);
s2->s.k = 2;
sappend(s, s2);
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_macpl;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
/*
@@ -2506,32 +2626,54 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* little-endian, so we byte-swap all of the values
* we test against, as they will be loaded as big-endian
* values.
+ *
+ * XXX - in the general case, we would have to scan through
+ * *all* the presence bits, if there's more than one word of
+ * presence bits. That would require a loop, meaning that
+ * we wouldn't be able to run the filter in the kernel.
+ *
+ * We assume here that the Atheros adapters that insert the
+ * annoying padding don't have multiple antennae and therefore
+ * do not generate radiotap headers with multiple presence words.
*/
- if (linktype == DLT_IEEE802_11_RADIO) {
+ if (cstate->linktype == DLT_IEEE802_11_RADIO) {
/*
* Is the IEEE80211_RADIOTAP_FLAGS bit (0x0000002) set
- * in the presence flag?
+ * in the first presence flag word?
*/
- sjset_qos->s.jf = s2 = new_stmt(BPF_LD|BPF_ABS|BPF_W);
+ sjset_qos->s.jf = s2 = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_W);
s2->s.k = 4;
sappend(s, s2);
- sjset_radiotap_flags = new_stmt(JMP(BPF_JSET));
- sjset_radiotap_flags->s.k = SWAPLONG(0x00000002);
- sappend(s, sjset_radiotap_flags);
+ sjset_radiotap_flags_present = new_stmt(cstate, JMP(BPF_JSET));
+ sjset_radiotap_flags_present->s.k = SWAPLONG(0x00000002);
+ sappend(s, sjset_radiotap_flags_present);
/*
* If not, skip all of this.
*/
- sjset_radiotap_flags->s.jf = snext;
+ sjset_radiotap_flags_present->s.jf = snext;
+
+ /*
+ * Otherwise, is the "extension" bit set in that word?
+ */
+ sjset_radiotap_ext_present = new_stmt(cstate, JMP(BPF_JSET));
+ sjset_radiotap_ext_present->s.k = SWAPLONG(0x80000000);
+ sappend(s, sjset_radiotap_ext_present);
+ sjset_radiotap_flags_present->s.jt = sjset_radiotap_ext_present;
+
+ /*
+ * If so, skip all of this.
+ */
+ sjset_radiotap_ext_present->s.jt = snext;
/*
* Otherwise, is the IEEE80211_RADIOTAP_TSFT bit set?
*/
- sjset_radiotap_tsft = sjset_radiotap_flags->s.jt =
- new_stmt(JMP(BPF_JSET));
- sjset_radiotap_tsft->s.k = SWAPLONG(0x00000001);
- sappend(s, sjset_radiotap_tsft);
+ sjset_radiotap_tsft_present = new_stmt(cstate, JMP(BPF_JSET));
+ sjset_radiotap_tsft_present->s.k = SWAPLONG(0x00000001);
+ sappend(s, sjset_radiotap_tsft_present);
+ sjset_radiotap_ext_present->s.jf = sjset_radiotap_tsft_present;
/*
* If IEEE80211_RADIOTAP_TSFT is set, the flags field is
@@ -2542,11 +2684,12 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* Test whether the IEEE80211_RADIOTAP_F_DATAPAD bit (0x20)
* is set.
*/
- sjset_radiotap_tsft->s.jt = s2 = new_stmt(BPF_LD|BPF_ABS|BPF_B);
+ s2 = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_B);
s2->s.k = 16;
sappend(s, s2);
+ sjset_radiotap_tsft_present->s.jt = s2;
- sjset_tsft_datapad = new_stmt(JMP(BPF_JSET));
+ sjset_tsft_datapad = new_stmt(cstate, JMP(BPF_JSET));
sjset_tsft_datapad->s.k = 0x20;
sappend(s, sjset_tsft_datapad);
@@ -2558,11 +2701,12 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* Test whether the IEEE80211_RADIOTAP_F_DATAPAD bit (0x20)
* is set.
*/
- sjset_radiotap_tsft->s.jf = s2 = new_stmt(BPF_LD|BPF_ABS|BPF_B);
+ s2 = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_B);
s2->s.k = 8;
sappend(s, s2);
+ sjset_radiotap_tsft_present->s.jf = s2;
- sjset_notsft_datapad = new_stmt(JMP(BPF_JSET));
+ sjset_notsft_datapad = new_stmt(cstate, JMP(BPF_JSET));
sjset_notsft_datapad->s.k = 0x20;
sappend(s, sjset_notsft_datapad);
@@ -2573,17 +2717,17 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
* dividing by and multiplying by 4, which we do by
* ANDing with ~3.
*/
- s_roundup = new_stmt(BPF_LD|BPF_MEM);
- s_roundup->s.k = reg_off_macpl;
+ s_roundup = new_stmt(cstate, BPF_LD|BPF_MEM);
+ s_roundup->s.k = cstate->off_linkpl.reg;
sappend(s, s_roundup);
- s2 = new_stmt(BPF_ALU|BPF_ADD|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_IMM);
s2->s.k = 3;
sappend(s, s2);
- s2 = new_stmt(BPF_ALU|BPF_AND|BPF_IMM);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_IMM);
s2->s.k = ~3;
sappend(s, s2);
- s2 = new_stmt(BPF_ST);
- s2->s.k = reg_off_macpl;
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
sappend(s, s2);
sjset_tsft_datapad->s.jt = s_roundup;
@@ -2597,33 +2741,46 @@ gen_load_802_11_header_len(struct slist *s, struct slist *snext)
}
static void
-insert_compute_vloffsets(b)
- struct block *b;
+insert_compute_vloffsets(compiler_state_t *cstate, struct block *b)
{
struct slist *s;
+ /* There is an implicit dependency between the link
+ * payload and link header since the payload computation
+ * includes the variable part of the header. Therefore,
+ * if nobody else has allocated a register for the link
+ * header and we need it, do it now. */
+ if (cstate->off_linkpl.reg != -1 && cstate->off_linkhdr.is_variable &&
+ cstate->off_linkhdr.reg == -1)
+ cstate->off_linkhdr.reg = alloc_reg(cstate);
+
/*
* For link-layer types that have a variable-length header
* preceding the link-layer header, generate code to load
* the offset of the link-layer header into the register
* assigned to that offset, if any.
+ *
+ * XXX - this, and the next switch statement, won't handle
+ * encapsulation of 802.11 or 802.11+radio information in
+ * some other protocol stack. That's significantly more
+ * complicated.
*/
- switch (linktype) {
+ switch (cstate->outermostlinktype) {
case DLT_PRISM_HEADER:
- s = gen_load_prism_llprefixlen();
+ s = gen_load_prism_llprefixlen(cstate);
break;
case DLT_IEEE802_11_RADIO_AVS:
- s = gen_load_avs_llprefixlen();
+ s = gen_load_avs_llprefixlen(cstate);
break;
case DLT_IEEE802_11_RADIO:
- s = gen_load_radiotap_llprefixlen();
+ s = gen_load_radiotap_llprefixlen(cstate);
break;
case DLT_PPI:
- s = gen_load_ppi_llprefixlen();
+ s = gen_load_ppi_llprefixlen(cstate);
break;
default:
@@ -2633,17 +2790,17 @@ insert_compute_vloffsets(b)
/*
* For link-layer types that have a variable-length link-layer
- * header, generate code to load the offset of the MAC-layer
+ * header, generate code to load the offset of the link-layer
* payload into the register assigned to that offset, if any.
*/
- switch (linktype) {
+ switch (cstate->outermostlinktype) {
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
case DLT_PPI:
- s = gen_load_802_11_header_len(s, b->stmts);
+ s = gen_load_802_11_header_len(cstate, s, b->stmts);
break;
}
@@ -2660,19 +2817,19 @@ insert_compute_vloffsets(b)
}
static struct block *
-gen_ppi_dlt_check(void)
+gen_ppi_dlt_check(compiler_state_t *cstate)
{
struct slist *s_load_dlt;
struct block *b;
- if (linktype == DLT_PPI)
+ if (cstate->linktype == DLT_PPI)
{
/* Create the statements that check for the DLT
*/
- s_load_dlt = new_stmt(BPF_LD|BPF_W|BPF_ABS);
+ s_load_dlt = new_stmt(cstate, BPF_LD|BPF_W|BPF_ABS);
s_load_dlt->s.k = 4;
- b = new_block(JMP(BPF_JEQ));
+ b = new_block(cstate, JMP(BPF_JEQ));
b->stmts = s_load_dlt;
b->s.k = SWAPLONG(DLT_IEEE802_11);
@@ -2685,160 +2842,45 @@ gen_ppi_dlt_check(void)
return b;
}
-static struct slist *
-gen_prism_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the radio header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the radio length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
-static struct slist *
-gen_avs_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the AVS header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the AVS length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
-static struct slist *
-gen_radiotap_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the radiotap header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the radiotap length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
-/*
- * At the moment we treat PPI as normal Radiotap encoded
- * packets. The difference is in the function that generates
- * the code at the beginning to compute the header length.
- * Since this code generator of PPI supports bare 802.11
- * encapsulation only (i.e. the encapsulated DLT should be
- * DLT_IEEE802_11) we generate code to check for this too.
- */
-static struct slist *
-gen_ppi_llprefixlen(void)
-{
- struct slist *s;
-
- if (reg_off_ll == -1) {
- /*
- * We haven't yet assigned a register for the length
- * of the radiotap header; allocate one.
- */
- reg_off_ll = alloc_reg();
- }
-
- /*
- * Load the register containing the PPI length
- * into the X register.
- */
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_ll;
- return s;
-}
-
/*
- * Generate code to compute the link-layer header length, if necessary,
- * putting it into the X register, and to return either a pointer to a
- * "struct slist" for the list of statements in that code, or NULL if
- * no code is necessary.
- */
-static struct slist *
-gen_llprefixlen(void)
-{
- switch (linktype) {
-
- case DLT_PRISM_HEADER:
- return gen_prism_llprefixlen();
-
- case DLT_IEEE802_11_RADIO_AVS:
- return gen_avs_llprefixlen();
-
- case DLT_IEEE802_11_RADIO:
- return gen_radiotap_llprefixlen();
-
- case DLT_PPI:
- return gen_ppi_llprefixlen();
-
- default:
- return NULL;
- }
-}
-
-/*
- * Generate code to load the register containing the offset of the
- * MAC-layer payload into the X register; if no register for that offset
- * has been allocated, allocate it first.
+ * Take an absolute offset, and:
+ *
+ * if it has no variable part, return NULL;
+ *
+ * if it has a variable part, generate code to load the register
+ * containing that variable part into the X register, returning
+ * a pointer to that code - if no register for that offset has
+ * been allocated, allocate it first.
+ *
+ * (The code to set that register will be generated later, but will
+ * be placed earlier in the code sequence.)
*/
static struct slist *
-gen_off_macpl(void)
+gen_abs_offset_varpart(compiler_state_t *cstate, bpf_abs_offset *off)
{
struct slist *s;
- if (off_macpl_is_variable) {
- if (reg_off_macpl == -1) {
+ if (off->is_variable) {
+ if (off->reg == -1) {
/*
- * We haven't yet assigned a register for the offset
- * of the MAC-layer payload; allocate one.
+ * We haven't yet assigned a register for the
+ * variable part of the offset of the link-layer
+ * header; allocate one.
*/
- reg_off_macpl = alloc_reg();
+ off->reg = alloc_reg(cstate);
}
/*
- * Load the register containing the offset of the MAC-layer
- * payload into the X register.
+ * Load the register containing the variable part of the
+ * offset of the link-layer header into the X register.
*/
- s = new_stmt(BPF_LDX|BPF_MEM);
- s->s.k = reg_off_macpl;
+ s = new_stmt(cstate, BPF_LDX|BPF_MEM);
+ s->s.k = off->reg;
return s;
} else {
/*
- * That offset isn't variable, so we don't need to
- * generate any code.
+ * That offset isn't variable, there's no variable part,
+ * so we don't need to generate any code.
*/
return NULL;
}
@@ -2894,6 +2936,51 @@ ethertype_to_ppptype(proto)
}
/*
+ * Generate any tests that, for encapsulation of a link-layer packet
+ * inside another protocol stack, need to be done to check for those
+ * link-layer packets (and that haven't already been done by a check
+ * for that encapsulation).
+ */
+static struct block *
+gen_prevlinkhdr_check(compiler_state_t *cstate)
+{
+ struct block *b0;
+
+ if (cstate->is_geneve)
+ return gen_geneve_ll_check(cstate);
+
+ switch (cstate->prevlinktype) {
+
+ case DLT_SUNATM:
+ /*
+ * This is LANE-encapsulated Ethernet; check that the LANE
+ * packet doesn't begin with an LE Control marker, i.e.
+ * that it's data, not a control message.
+ *
+ * (We've already generated a test for LANE.)
+ */
+ b0 = gen_cmp(cstate, OR_PREVLINKHDR, SUNATM_PKT_BEGIN_POS, BPF_H, 0xFF00);
+ gen_not(b0);
+ return b0;
+
+ default:
+ /*
+ * No such tests are necessary.
+ */
+ return NULL;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * The three different values we should check for when checking for an
+ * IPv6 packet with DLT_NULL.
+ */
+#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 */
+
+/*
* Generate code to match a particular packet type by matching the
* link-layer type field or fields in the 802.2 LLC header.
*
@@ -2901,55 +2988,46 @@ ethertype_to_ppptype(proto)
* value, if <= ETHERMTU.
*/
static struct block *
-gen_linktype(proto)
- register int proto;
+gen_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1, *b2;
+ const char *description;
/* are we checking MPLS-encapsulated packets? */
- if (label_stack_depth > 0) {
+ if (cstate->label_stack_depth > 0) {
switch (proto) {
case ETHERTYPE_IP:
case PPP_IP:
/* FIXME add other L3 proto IDs */
- return gen_mpls_linktype(Q_IP);
+ return gen_mpls_linktype(cstate, Q_IP);
case ETHERTYPE_IPV6:
case PPP_IPV6:
/* FIXME add other L3 proto IDs */
- return gen_mpls_linktype(Q_IPV6);
+ return gen_mpls_linktype(cstate, Q_IPV6);
default:
- bpf_error("unsupported protocol over mpls");
+ bpf_error(cstate, "unsupported protocol over mpls");
/* NOTREACHED */
}
}
- /*
- * Are we testing PPPoE packets?
- */
- if (is_pppoes) {
- /*
- * The PPPoE session header is part of the
- * MAC-layer payload, so all references
- * should be relative to the beginning of
- * that payload.
- */
-
- /*
- * We use Ethernet protocol types inside libpcap;
- * map them to the corresponding PPP protocol types.
- */
- proto = ethertype_to_ppptype(proto);
- return gen_cmp(OR_MACPL, off_linktype, BPF_H, (bpf_int32)proto);
- }
-
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- return gen_ether_linktype(proto);
+ /* Geneve has an EtherType regardless of whether there is an
+ * L2 header. */
+ if (!cstate->is_geneve)
+ b0 = gen_prevlinkhdr_check(cstate);
+ else
+ b0 = NULL;
+
+ b1 = gen_ether_linktype(cstate, proto);
+ if (b0 != NULL)
+ gen_and(b0, b1);
+ return b1;
/*NOTREACHED*/
break;
@@ -2961,8 +3039,7 @@ gen_linktype(proto)
/* fall through */
default:
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
/*NOTREACHED*/
break;
}
@@ -2976,12 +3053,12 @@ gen_linktype(proto)
/*
* Check that we have a data frame.
*/
- b0 = gen_check_802_11_data_frame();
+ b0 = gen_check_802_11_data_frame(cstate);
/*
* Now check for the specified link-layer type.
*/
- b1 = gen_llc_linktype(proto);
+ b1 = gen_llc_linktype(cstate, proto);
gen_and(b0, b1);
return b1;
/*NOTREACHED*/
@@ -2989,9 +3066,9 @@ gen_linktype(proto)
case DLT_FDDI:
/*
- * XXX - check for asynchronous frames, as per RFC 1103.
+ * XXX - check for LLC frames.
*/
- return gen_llc_linktype(proto);
+ return gen_llc_linktype(cstate, proto);
/*NOTREACHED*/
break;
@@ -2999,56 +3076,34 @@ gen_linktype(proto)
/*
* XXX - check for LLC PDUs, as per IEEE 802.5.
*/
- return gen_llc_linktype(proto);
+ return gen_llc_linktype(cstate, proto);
/*NOTREACHED*/
break;
case DLT_ATM_RFC1483:
case DLT_ATM_CLIP:
case DLT_IP_OVER_FC:
- return gen_llc_linktype(proto);
+ return gen_llc_linktype(cstate, proto);
/*NOTREACHED*/
break;
case DLT_SUNATM:
/*
- * If "is_lane" is set, check for a LANE-encapsulated
- * version of this protocol, otherwise check for an
- * LLC-encapsulated version of this protocol.
+ * Check for an LLC-encapsulated version of this protocol;
+ * if we were checking for LANE, linktype would no longer
+ * be DLT_SUNATM.
*
- * We assume LANE means Ethernet, not Token Ring.
+ * Check for LLC encapsulation and then check the protocol.
*/
- if (is_lane) {
- /*
- * Check that the packet doesn't begin with an
- * LE Control marker. (We've already generated
- * a test for LANE.)
- */
- b0 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS, BPF_H,
- 0xFF00);
- gen_not(b0);
-
- /*
- * Now generate an Ethernet test.
- */
- b1 = gen_ether_linktype(proto);
- gen_and(b0, b1);
- return b1;
- } else {
- /*
- * Check for LLC encapsulation and then check the
- * protocol.
- */
- b0 = gen_atmfield_code(A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
- b1 = gen_llc_linktype(proto);
- gen_and(b0, b1);
- return b1;
- }
+ b0 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
+ b1 = gen_llc_linktype(cstate, proto);
+ gen_and(b0, b1);
+ return b1;
/*NOTREACHED*/
break;
case DLT_LINUX_SLL:
- return gen_linux_sll_linktype(proto);
+ return gen_linux_sll_linktype(cstate, proto);
/*NOTREACHED*/
break;
@@ -3066,14 +3121,14 @@ gen_linktype(proto)
case ETHERTYPE_IP:
/* Check for a version number of 4. */
- return gen_mcmp(OR_LINK, 0, BPF_B, 0x40, 0xF0);
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, 0x40, 0xF0);
case ETHERTYPE_IPV6:
/* Check for a version number of 6. */
- return gen_mcmp(OR_LINK, 0, BPF_B, 0x60, 0xF0);
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, 0x60, 0xF0);
default:
- return gen_false(); /* always false */
+ return gen_false(cstate); /* always false */
}
/*NOTREACHED*/
break;
@@ -3083,10 +3138,10 @@ gen_linktype(proto)
* Raw IPv4, so no type field.
*/
if (proto == ETHERTYPE_IP)
- return gen_true(); /* always true */
+ return gen_true(cstate); /* always true */
/* Checking for something other than IPv4; always false */
- return gen_false();
+ return gen_false(cstate);
/*NOTREACHED*/
break;
@@ -3095,10 +3150,10 @@ gen_linktype(proto)
* Raw IPv6, so no type field.
*/
if (proto == ETHERTYPE_IPV6)
- return gen_true(); /* always true */
+ return gen_true(cstate); /* always true */
/* Checking for something other than IPv6; always false */
- return gen_false();
+ return gen_false(cstate);
/*NOTREACHED*/
break;
@@ -3111,7 +3166,7 @@ gen_linktype(proto)
* map them to the corresponding PPP protocol types.
*/
proto = ethertype_to_ppptype(proto);
- return gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
/*NOTREACHED*/
break;
@@ -3127,16 +3182,16 @@ gen_linktype(proto)
* Also check for Van Jacobson-compressed IP.
* XXX - do this for other forms of PPP?
*/
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, PPP_IP);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_H, PPP_VJC);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, PPP_IP);
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, PPP_VJC);
gen_or(b0, b1);
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H, PPP_VJNC);
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, PPP_VJNC);
gen_or(b1, b0);
return b0;
default:
proto = ethertype_to_ppptype(proto);
- return gen_cmp(OR_LINK, off_linktype, BPF_H,
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H,
(bpf_int32)proto);
}
/*NOTREACHED*/
@@ -3145,39 +3200,71 @@ gen_linktype(proto)
case DLT_NULL:
case DLT_LOOP:
case DLT_ENC:
- /*
- * For DLT_NULL, the link-layer header is a 32-bit
- * word containing an AF_ value in *host* byte order,
- * and for DLT_ENC, the link-layer header begins
- * with a 32-bit work containing an AF_ value in
- * host byte order.
- *
- * In addition, if we're reading a saved capture file,
- * the host byte order in the capture may not be the
- * same as the host byte order on this machine.
- *
- * For DLT_LOOP, the link-layer header is a 32-bit
- * word containing an AF_ value in *network* byte order.
- *
- * XXX - AF_ values may, unfortunately, be platform-
- * dependent; for example, FreeBSD's AF_INET6 is 24
- * whilst NetBSD's and OpenBSD's is 26.
- *
- * This means that, when reading a capture file, just
- * checking for our AF_INET6 value won't work if the
- * capture file came from another OS.
- */
switch (proto) {
case ETHERTYPE_IP:
- proto = AF_INET;
- break;
+ return (gen_loopback_linktype(cstate, AF_INET));
-#ifdef INET6
case ETHERTYPE_IPV6:
- proto = AF_INET6;
- break;
-#endif
+ /*
+ * AF_ values may, unfortunately, be platform-
+ * dependent; AF_INET isn't, because everybody
+ * used 4.2BSD's value, but AF_INET6 is, because
+ * 4.2BSD didn't have a value for it (given that
+ * IPv6 didn't exist back in the early 1980's),
+ * and they all picked their own values.
+ *
+ * This means that, if we're reading from a
+ * savefile, we need to check for all the
+ * possible values.
+ *
+ * If we're doing a live capture, we only need
+ * to check for this platform's value; however,
+ * Npcap uses 24, which isn't Windows's AF_INET6
+ * value. (Given the multiple different values,
+ * programs that read pcap files shouldn't be
+ * checking for their platform's AF_INET6 value
+ * anyway, they should check for all of the
+ * possible values. and they might as well do
+ * that even for live captures.)
+ */
+ if (cstate->bpf_pcap->rfile != NULL) {
+ /*
+ * Savefile - check for all three
+ * possible IPv6 values.
+ */
+ b0 = gen_loopback_linktype(cstate, BSD_AFNUM_INET6_BSD);
+ b1 = gen_loopback_linktype(cstate, BSD_AFNUM_INET6_FREEBSD);
+ gen_or(b0, b1);
+ b0 = gen_loopback_linktype(cstate, BSD_AFNUM_INET6_DARWIN);
+ gen_or(b0, b1);
+ return (b1);
+ } else {
+ /*
+ * Live capture, so we only need to
+ * check for the value used on this
+ * platform.
+ */
+#ifdef _WIN32
+ /*
+ * Npcap doesn't use Windows's AF_INET6,
+ * as that collides with AF_IPX on
+ * some BSDs (both have the value 23).
+ * Instead, it uses 24.
+ */
+ return (gen_loopback_linktype(cstate, 24));
+#else /* _WIN32 */
+#ifdef AF_INET6
+ return (gen_loopback_linktype(cstate, AF_INET6));
+#else /* AF_INET6 */
+ /*
+ * I guess this platform doesn't support
+ * IPv6, so we just reject all packets.
+ */
+ return gen_false(cstate);
+#endif /* AF_INET6 */
+#endif /* _WIN32 */
+ }
default:
/*
@@ -3185,28 +3272,8 @@ gen_linktype(proto)
* XXX - support those that have AF_ values
* #defined on this platform, at least?
*/
- return gen_false();
- }
-
- if (linktype == DLT_NULL || linktype == DLT_ENC) {
- /*
- * The AF_ value is in host byte order, but
- * the BPF interpreter will convert it to
- * network byte order.
- *
- * If this is a save file, and it's from a
- * machine with the opposite byte order to
- * ours, we byte-swap the AF_ value.
- *
- * Then we run it through "htonl()", and
- * generate code to compare against the result.
- */
- if (bpf_pcap->sf.rfile != NULL &&
- bpf_pcap->sf.swapped)
- proto = SWAPLONG(proto);
- proto = htonl(proto);
+ return gen_false(cstate);
}
- return (gen_cmp(OR_LINK, 0, BPF_W, (bpf_int32)proto));
#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
@@ -3215,13 +3282,13 @@ gen_linktype(proto)
* the packet.
*/
if (proto == ETHERTYPE_IP)
- return (gen_cmp(OR_LINK, offsetof(struct pfloghdr, af),
+ return (gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, af),
BPF_B, (bpf_int32)AF_INET));
else if (proto == ETHERTYPE_IPV6)
- return (gen_cmp(OR_LINK, offsetof(struct pfloghdr, af),
+ return (gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, af),
BPF_B, (bpf_int32)AF_INET6));
else
- return gen_false();
+ return gen_false(cstate);
/*NOTREACHED*/
break;
#endif /* HAVE_NET_PFVAR_H */
@@ -3235,34 +3302,34 @@ gen_linktype(proto)
switch (proto) {
default:
- return gen_false();
+ return gen_false(cstate);
case ETHERTYPE_IPV6:
- return (gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return (gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_INET6));
case ETHERTYPE_IP:
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_IP);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_IP_OLD);
gen_or(b0, b1);
return (b1);
case ETHERTYPE_ARP:
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_ARP);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_B,
+ b1 = gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_ARP_OLD);
gen_or(b0, b1);
return (b1);
case ETHERTYPE_REVARP:
- return (gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return (gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_REVARP));
case ETHERTYPE_ATALK:
- return (gen_cmp(OR_LINK, off_linktype, BPF_B,
+ return (gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
(bpf_int32)ARCTYPE_ATALK));
}
/*NOTREACHED*/
@@ -3271,9 +3338,9 @@ gen_linktype(proto)
case DLT_LTALK:
switch (proto) {
case ETHERTYPE_ATALK:
- return gen_true();
+ return gen_true(cstate);
default:
- return gen_false();
+ return gen_false(cstate);
}
/*NOTREACHED*/
break;
@@ -3289,13 +3356,13 @@ gen_linktype(proto)
/*
* Check for the special NLPID for IP.
*/
- return gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | 0xcc);
+ return gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | 0xcc);
case ETHERTYPE_IPV6:
/*
* Check for the special NLPID for IPv6.
*/
- return gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | 0x8e);
+ return gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | 0x8e);
case LLCSAP_ISONS:
/*
@@ -3309,21 +3376,21 @@ gen_linktype(proto)
* control field of UI, i.e. 0x03 followed
* by the NLPID.
*/
- b0 = gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | ISO8473_CLNP);
- b1 = gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | ISO9542_ESIS);
- b2 = gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | ISO10589_ISIS);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | ISO8473_CLNP);
+ b1 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | ISO9542_ESIS);
+ b2 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | ISO10589_ISIS);
gen_or(b1, b2);
gen_or(b0, b2);
return b2;
default:
- return gen_false();
+ return gen_false(cstate);
}
/*NOTREACHED*/
break;
case DLT_MFR:
- bpf_error("Multi-link Frame Relay link-layer type filtering not implemented");
+ bpf_error(cstate, "Multi-link Frame Relay link-layer type filtering not implemented");
case DLT_JUNIPER_MFR:
case DLT_JUNIPER_MLFR:
@@ -3355,83 +3422,104 @@ gen_linktype(proto)
*
* FIXME encapsulation specific BPF_ filters
*/
- return gen_mcmp(OR_LINK, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
+
+ case DLT_BACNET_MS_TP:
+ return gen_mcmp(cstate, OR_LINKHDR, 0, BPF_W, 0x55FF0000, 0xffff0000);
case DLT_IPNET:
- return gen_ipnet_linktype(proto);
+ return gen_ipnet_linktype(cstate, proto);
case DLT_LINUX_IRDA:
- bpf_error("IrDA link-layer type filtering not implemented");
+ bpf_error(cstate, "IrDA link-layer type filtering not implemented");
case DLT_DOCSIS:
- bpf_error("DOCSIS link-layer type filtering not implemented");
+ bpf_error(cstate, "DOCSIS link-layer type filtering not implemented");
case DLT_MTP2:
case DLT_MTP2_WITH_PHDR:
- bpf_error("MTP2 link-layer type filtering not implemented");
+ bpf_error(cstate, "MTP2 link-layer type filtering not implemented");
case DLT_ERF:
- bpf_error("ERF link-layer type filtering not implemented");
+ bpf_error(cstate, "ERF link-layer type filtering not implemented");
case DLT_PFSYNC:
- bpf_error("PFSYNC link-layer type filtering not implemented");
+ bpf_error(cstate, "PFSYNC link-layer type filtering not implemented");
case DLT_LINUX_LAPD:
- bpf_error("LAPD link-layer type filtering not implemented");
+ bpf_error(cstate, "LAPD link-layer type filtering not implemented");
- case DLT_USB:
+ case DLT_USB_FREEBSD:
case DLT_USB_LINUX:
case DLT_USB_LINUX_MMAPPED:
- bpf_error("USB link-layer type filtering not implemented");
+ case DLT_USBPCAP:
+ bpf_error(cstate, "USB link-layer type filtering not implemented");
case DLT_BLUETOOTH_HCI_H4:
case DLT_BLUETOOTH_HCI_H4_WITH_PHDR:
- bpf_error("Bluetooth link-layer type filtering not implemented");
+ bpf_error(cstate, "Bluetooth link-layer type filtering not implemented");
case DLT_CAN20B:
case DLT_CAN_SOCKETCAN:
- bpf_error("CAN link-layer type filtering not implemented");
+ bpf_error(cstate, "CAN link-layer type filtering not implemented");
case DLT_IEEE802_15_4:
case DLT_IEEE802_15_4_LINUX:
case DLT_IEEE802_15_4_NONASK_PHY:
case DLT_IEEE802_15_4_NOFCS:
- bpf_error("IEEE 802.15.4 link-layer type filtering not implemented");
+ bpf_error(cstate, "IEEE 802.15.4 link-layer type filtering not implemented");
case DLT_IEEE802_16_MAC_CPS_RADIO:
- bpf_error("IEEE 802.16 link-layer type filtering not implemented");
+ bpf_error(cstate, "IEEE 802.16 link-layer type filtering not implemented");
case DLT_SITA:
- bpf_error("SITA link-layer type filtering not implemented");
+ bpf_error(cstate, "SITA link-layer type filtering not implemented");
case DLT_RAIF1:
- bpf_error("RAIF1 link-layer type filtering not implemented");
+ bpf_error(cstate, "RAIF1 link-layer type filtering not implemented");
case DLT_IPMB:
- bpf_error("IPMB link-layer type filtering not implemented");
+ bpf_error(cstate, "IPMB link-layer type filtering not implemented");
case DLT_AX25_KISS:
- bpf_error("AX.25 link-layer type filtering not implemented");
- }
+ bpf_error(cstate, "AX.25 link-layer type filtering not implemented");
- /*
- * All the types that have no encapsulation should either be
- * handled as DLT_SLIP, DLT_SLIP_BSDOS, and DLT_RAW are, if
- * all packets are IP packets, or should be handled in some
- * special case, if none of them are (if some are and some
- * aren't, the lack of encapsulation is a problem, as we'd
- * have to find some other way of determining the packet type).
- *
- * Therefore, if "off_linktype" is -1, there's an error.
- */
- if (off_linktype == (u_int)-1)
- abort();
+ case DLT_NFLOG:
+ /* Using the fixed-size NFLOG header it is possible to tell only
+ * the address family of the packet, other meaningful data is
+ * either missing or behind TLVs.
+ */
+ bpf_error(cstate, "NFLOG link-layer type filtering not implemented");
- /*
- * Any type not handled above should always have an Ethernet
- * type at an offset of "off_linktype".
- */
- return gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto);
+ default:
+ /*
+ * Does this link-layer header type have a field
+ * indicating the type of the next protocol? If
+ * so, off_linktype.constant_part will be the offset of that
+ * field in the packet; if not, it will be OFFSET_NOT_SET.
+ */
+ if (cstate->off_linktype.constant_part != OFFSET_NOT_SET) {
+ /*
+ * Yes; assume it's an Ethernet type. (If
+ * it's not, it needs to be handled specially
+ * above.)
+ */
+ return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
+ } else {
+ /*
+ * No; report an error.
+ */
+ description = pcap_datalink_val_to_description(cstate->linktype);
+ if (description != NULL) {
+ bpf_error(cstate, "%s link-layer type filtering not implemented",
+ description);
+ } else {
+ bpf_error(cstate, "DLT %u link-layer type filtering not implemented",
+ cstate->linktype);
+ }
+ }
+ break;
+ }
}
/*
@@ -3442,9 +3530,7 @@ gen_linktype(proto)
* code and protocol type in the SNAP header.
*/
static struct block *
-gen_snap(orgcode, ptype)
- bpf_u_int32 orgcode;
- bpf_u_int32 ptype;
+gen_snap(compiler_state_t *cstate, bpf_u_int32 orgcode, bpf_u_int32 ptype)
{
u_char snapblock[8];
@@ -3456,7 +3542,179 @@ gen_snap(orgcode, ptype)
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 */
- return gen_bcmp(OR_MACPL, 0, 8, snapblock);
+ return gen_bcmp(cstate, OR_LLC, 0, 8, snapblock);
+}
+
+/*
+ * Generate code to match frames with an LLC header.
+ */
+struct block *
+gen_llc(compiler_state_t *cstate)
+{
+ struct block *b0, *b1;
+
+ switch (cstate->linktype) {
+
+ case DLT_EN10MB:
+ /*
+ * We check for an Ethernet type field less than
+ * 1500, which means it's an 802.3 length field.
+ */
+ b0 = gen_cmp_gt(cstate, OR_LINKTYPE, 0, BPF_H, ETHERMTU);
+ gen_not(b0);
+
+ /*
+ * Now check for the purported DSAP and SSAP not being
+ * 0xFF, to rule out NetWare-over-802.3.
+ */
+ b1 = gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_int32)0xFFFF);
+ gen_not(b1);
+ gen_and(b0, b1);
+ return b1;
+
+ case DLT_SUNATM:
+ /*
+ * We check for LLC traffic.
+ */
+ b0 = gen_atmtype_abbrev(cstate, A_LLC);
+ return b0;
+
+ case DLT_IEEE802: /* Token Ring */
+ /*
+ * XXX - check for LLC frames.
+ */
+ return gen_true(cstate);
+
+ case DLT_FDDI:
+ /*
+ * XXX - check for LLC frames.
+ */
+ return gen_true(cstate);
+
+ case DLT_ATM_RFC1483:
+ /*
+ * For LLC encapsulation, these are defined to have an
+ * 802.2 LLC header.
+ *
+ * For VC encapsulation, they don't, but there's no
+ * way to check for that; the protocol used on the VC
+ * is negotiated out of band.
+ */
+ return gen_true(cstate);
+
+ case DLT_IEEE802_11:
+ case DLT_PRISM_HEADER:
+ case DLT_IEEE802_11_RADIO:
+ case DLT_IEEE802_11_RADIO_AVS:
+ case DLT_PPI:
+ /*
+ * Check that we have a data frame.
+ */
+ b0 = gen_check_802_11_data_frame(cstate);
+ return b0;
+
+ default:
+ bpf_error(cstate, "'llc' not supported for linktype %d", cstate->linktype);
+ /* NOTREACHED */
+ }
+}
+
+struct block *
+gen_llc_i(compiler_state_t *cstate)
+{
+ struct block *b0, *b1;
+ struct slist *s;
+
+ /*
+ * Check whether this is an LLC frame.
+ */
+ b0 = gen_llc(cstate);
+
+ /*
+ * Load the control byte and test the low-order bit; it must
+ * be clear for I frames.
+ */
+ s = gen_load_a(cstate, OR_LLC, 2, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
+ b1->s.k = 0x01;
+ b1->stmts = s;
+ gen_not(b1);
+ gen_and(b0, b1);
+ return b1;
+}
+
+struct block *
+gen_llc_s(compiler_state_t *cstate)
+{
+ struct block *b0, *b1;
+
+ /*
+ * Check whether this is an LLC frame.
+ */
+ b0 = gen_llc(cstate);
+
+ /*
+ * Now compare the low-order 2 bit of the control byte against
+ * the appropriate value for S frames.
+ */
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, LLC_S_FMT, 0x03);
+ gen_and(b0, b1);
+ return b1;
+}
+
+struct block *
+gen_llc_u(compiler_state_t *cstate)
+{
+ struct block *b0, *b1;
+
+ /*
+ * Check whether this is an LLC frame.
+ */
+ b0 = gen_llc(cstate);
+
+ /*
+ * Now compare the low-order 2 bit of the control byte against
+ * the appropriate value for U frames.
+ */
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, LLC_U_FMT, 0x03);
+ gen_and(b0, b1);
+ return b1;
+}
+
+struct block *
+gen_llc_s_subtype(compiler_state_t *cstate, bpf_u_int32 subtype)
+{
+ struct block *b0, *b1;
+
+ /*
+ * Check whether this is an LLC frame.
+ */
+ b0 = gen_llc(cstate);
+
+ /*
+ * Now check for an S frame with the appropriate type.
+ */
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, subtype, LLC_S_CMD_MASK);
+ gen_and(b0, b1);
+ return b1;
+}
+
+struct block *
+gen_llc_u_subtype(compiler_state_t *cstate, bpf_u_int32 subtype)
+{
+ struct block *b0, *b1;
+
+ /*
+ * Check whether this is an LLC frame.
+ */
+ b0 = gen_llc(cstate);
+
+ /*
+ * Now check for a U frame with the appropriate type.
+ */
+ b1 = gen_mcmp(cstate, OR_LLC, 2, BPF_B, subtype, LLC_U_CMD_MASK);
+ gen_and(b0, b1);
+ return b1;
}
/*
@@ -3472,8 +3730,7 @@ gen_snap(orgcode, ptype)
* protocol ID in a SNAP header.
*/
static struct block *
-gen_llc_linktype(proto)
- int proto;
+gen_llc_linktype(compiler_state_t *cstate, int proto)
{
/*
* XXX - handle token-ring variable-length header.
@@ -3486,10 +3743,9 @@ gen_llc_linktype(proto)
/*
* XXX - should we check both the DSAP and the
* SSAP, like this, or should we check just the
- * DSAP, as we do for other types <= ETHERMTU
- * (i.e., other SAP values)?
+ * DSAP, as we do for other SAP values?
*/
- return gen_cmp(OR_MACPL, 0, BPF_H, (bpf_u_int32)
+ return gen_cmp(cstate, OR_LLC, 0, BPF_H, (bpf_u_int32)
((proto << 8) | proto));
case LLCSAP_IPX:
@@ -3497,7 +3753,7 @@ gen_llc_linktype(proto)
* XXX - are there ever SNAP frames for IPX on
* non-Ethernet 802.x networks?
*/
- return gen_cmp(OR_MACPL, 0, BPF_B,
+ return gen_cmp(cstate, OR_LLC, 0, BPF_B,
(bpf_int32)LLCSAP_IPX);
case ETHERTYPE_ATALK:
@@ -3510,7 +3766,7 @@ gen_llc_linktype(proto)
* XXX - check for an organization code of
* encapsulated Ethernet as well?
*/
- return gen_snap(0x080007, ETHERTYPE_ATALK);
+ return gen_snap(cstate, 0x080007, ETHERTYPE_ATALK);
default:
/*
@@ -3522,7 +3778,7 @@ gen_llc_linktype(proto)
* This is an LLC SAP value, so check
* the DSAP.
*/
- return gen_cmp(OR_MACPL, 0, BPF_B, (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LLC, 0, BPF_B, (bpf_int32)proto);
} else {
/*
* This is an Ethernet type; we assume that it's
@@ -3537,23 +3793,20 @@ gen_llc_linktype(proto)
* organization code of 0x000000 (encapsulated
* Ethernet), we'd do
*
- * return gen_snap(0x000000, proto);
+ * return gen_snap(cstate, 0x000000, proto);
*
* here; for now, we don't, as per the above.
* I don't know whether it's worth the extra CPU
* time to do the right check or not.
*/
- return gen_cmp(OR_MACPL, 6, BPF_H, (bpf_int32)proto);
+ return gen_cmp(cstate, OR_LLC, 6, BPF_H, (bpf_int32)proto);
}
}
}
static struct block *
-gen_hostop(addr, mask, dir, proto, src_off, dst_off)
- bpf_u_int32 addr;
- bpf_u_int32 mask;
- int dir, proto;
- u_int src_off, dst_off;
+gen_hostop(compiler_state_t *cstate, bpf_u_int32 addr, bpf_u_int32 mask,
+ int dir, int proto, u_int src_off, u_int dst_off)
{
struct block *b0, *b1;
u_int offset;
@@ -3569,34 +3822,31 @@ gen_hostop(addr, mask, dir, proto, src_off, dst_off)
break;
case Q_AND:
- b0 = gen_hostop(addr, mask, Q_SRC, proto, src_off, dst_off);
- b1 = gen_hostop(addr, mask, Q_DST, proto, src_off, dst_off);
+ b0 = gen_hostop(cstate, addr, mask, Q_SRC, proto, src_off, dst_off);
+ b1 = gen_hostop(cstate, addr, mask, Q_DST, proto, src_off, dst_off);
gen_and(b0, b1);
return b1;
case Q_OR:
case Q_DEFAULT:
- b0 = gen_hostop(addr, mask, Q_SRC, proto, src_off, dst_off);
- b1 = gen_hostop(addr, mask, Q_DST, proto, src_off, dst_off);
+ b0 = gen_hostop(cstate, addr, mask, Q_SRC, proto, src_off, dst_off);
+ b1 = gen_hostop(cstate, addr, mask, Q_DST, proto, src_off, dst_off);
gen_or(b0, b1);
return b1;
default:
abort();
}
- b0 = gen_linktype(proto);
- b1 = gen_mcmp(OR_NET, offset, BPF_W, (bpf_int32)addr, mask);
+ b0 = gen_linktype(cstate, proto);
+ b1 = gen_mcmp(cstate, OR_LINKPL, offset, BPF_W, (bpf_int32)addr, mask);
gen_and(b0, b1);
return b1;
}
#ifdef INET6
static struct block *
-gen_hostop6(addr, mask, dir, proto, src_off, dst_off)
- struct in6_addr *addr;
- struct in6_addr *mask;
- int dir, proto;
- u_int src_off, dst_off;
+gen_hostop6(compiler_state_t *cstate, struct in6_addr *addr,
+ struct in6_addr *mask, int dir, int proto, u_int src_off, u_int dst_off)
{
struct block *b0, *b1;
u_int offset;
@@ -3613,15 +3863,15 @@ gen_hostop6(addr, mask, dir, proto, src_off, dst_off)
break;
case Q_AND:
- b0 = gen_hostop6(addr, mask, Q_SRC, proto, src_off, dst_off);
- b1 = gen_hostop6(addr, mask, Q_DST, proto, src_off, dst_off);
+ b0 = gen_hostop6(cstate, addr, mask, Q_SRC, proto, src_off, dst_off);
+ b1 = gen_hostop6(cstate, addr, mask, Q_DST, proto, src_off, dst_off);
gen_and(b0, b1);
return b1;
case Q_OR:
case Q_DEFAULT:
- b0 = gen_hostop6(addr, mask, Q_SRC, proto, src_off, dst_off);
- b1 = gen_hostop6(addr, mask, Q_DST, proto, src_off, dst_off);
+ b0 = gen_hostop6(cstate, addr, mask, Q_SRC, proto, src_off, dst_off);
+ b1 = gen_hostop6(cstate, addr, mask, Q_DST, proto, src_off, dst_off);
gen_or(b0, b1);
return b1;
@@ -3631,68 +3881,66 @@ gen_hostop6(addr, mask, dir, proto, src_off, dst_off)
/* this order is important */
a = (u_int32_t *)addr;
m = (u_int32_t *)mask;
- b1 = gen_mcmp(OR_NET, offset + 12, BPF_W, ntohl(a[3]), ntohl(m[3]));
- b0 = gen_mcmp(OR_NET, offset + 8, BPF_W, ntohl(a[2]), ntohl(m[2]));
+ 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);
- b0 = gen_mcmp(OR_NET, offset + 4, BPF_W, ntohl(a[1]), ntohl(m[1]));
+ b0 = gen_mcmp(cstate, OR_LINKPL, offset + 4, BPF_W, ntohl(a[1]), ntohl(m[1]));
gen_and(b0, b1);
- b0 = gen_mcmp(OR_NET, offset + 0, BPF_W, ntohl(a[0]), ntohl(m[0]));
+ b0 = gen_mcmp(cstate, OR_LINKPL, offset + 0, BPF_W, ntohl(a[0]), ntohl(m[0]));
gen_and(b0, b1);
- b0 = gen_linktype(proto);
+ b0 = gen_linktype(cstate, proto);
gen_and(b0, b1);
return b1;
}
#endif
static struct block *
-gen_ehostop(eaddr, dir)
- register const u_char *eaddr;
- register int dir;
+gen_ehostop(compiler_state_t *cstate, const u_char *eaddr, int dir)
{
register struct block *b0, *b1;
switch (dir) {
case Q_SRC:
- return gen_bcmp(OR_LINK, off_mac + 6, 6, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 6, 6, eaddr);
case Q_DST:
- return gen_bcmp(OR_LINK, off_mac + 0, 6, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 0, 6, eaddr);
case Q_AND:
- b0 = gen_ehostop(eaddr, Q_SRC);
- b1 = gen_ehostop(eaddr, Q_DST);
+ b0 = gen_ehostop(cstate, eaddr, Q_SRC);
+ b1 = gen_ehostop(cstate, eaddr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_DEFAULT:
case Q_OR:
- b0 = gen_ehostop(eaddr, Q_SRC);
- b1 = gen_ehostop(eaddr, Q_DST);
+ b0 = gen_ehostop(cstate, eaddr, Q_SRC);
+ b1 = gen_ehostop(cstate, eaddr, Q_DST);
gen_or(b0, b1);
return b1;
case Q_ADDR1:
- bpf_error("'addr1' is only supported on 802.11 with 802.11 headers");
+ bpf_error(cstate, "'addr1' is only supported on 802.11 with 802.11 headers");
break;
case Q_ADDR2:
- bpf_error("'addr2' is only supported on 802.11 with 802.11 headers");
+ bpf_error(cstate, "'addr2' is only supported on 802.11 with 802.11 headers");
break;
case Q_ADDR3:
- bpf_error("'addr3' is only supported on 802.11 with 802.11 headers");
+ bpf_error(cstate, "'addr3' is only supported on 802.11 with 802.11 headers");
break;
case Q_ADDR4:
- bpf_error("'addr4' is only supported on 802.11 with 802.11 headers");
+ bpf_error(cstate, "'addr4' is only supported on 802.11 with 802.11 headers");
break;
case Q_RA:
- bpf_error("'ra' is only supported on 802.11 with 802.11 headers");
+ bpf_error(cstate, "'ra' is only supported on 802.11 with 802.11 headers");
break;
case Q_TA:
- bpf_error("'ta' is only supported on 802.11 with 802.11 headers");
+ bpf_error(cstate, "'ta' is only supported on 802.11 with 802.11 headers");
break;
}
abort();
@@ -3703,62 +3951,52 @@ gen_ehostop(eaddr, dir)
* Like gen_ehostop, but for DLT_FDDI
*/
static struct block *
-gen_fhostop(eaddr, dir)
- register const u_char *eaddr;
- register int dir;
+gen_fhostop(compiler_state_t *cstate, const u_char *eaddr, int dir)
{
struct block *b0, *b1;
switch (dir) {
case Q_SRC:
-#ifdef PCAP_FDDIPAD
- return gen_bcmp(OR_LINK, 6 + 1 + pcap_fddipad, 6, eaddr);
-#else
- return gen_bcmp(OR_LINK, 6 + 1, 6, eaddr);
-#endif
+ return gen_bcmp(cstate, OR_LINKHDR, 6 + 1 + cstate->pcap_fddipad, 6, eaddr);
case Q_DST:
-#ifdef PCAP_FDDIPAD
- return gen_bcmp(OR_LINK, 0 + 1 + pcap_fddipad, 6, eaddr);
-#else
- return gen_bcmp(OR_LINK, 0 + 1, 6, eaddr);
-#endif
+ return gen_bcmp(cstate, OR_LINKHDR, 0 + 1 + cstate->pcap_fddipad, 6, eaddr);
case Q_AND:
- b0 = gen_fhostop(eaddr, Q_SRC);
- b1 = gen_fhostop(eaddr, Q_DST);
+ b0 = gen_fhostop(cstate, eaddr, Q_SRC);
+ b1 = gen_fhostop(cstate, eaddr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_DEFAULT:
case Q_OR:
- b0 = gen_fhostop(eaddr, Q_SRC);
- b1 = gen_fhostop(eaddr, Q_DST);
+ b0 = gen_fhostop(cstate, eaddr, Q_SRC);
+ b1 = gen_fhostop(cstate, eaddr, Q_DST);
gen_or(b0, b1);
return b1;
case Q_ADDR1:
- bpf_error("'addr1' is only supported on 802.11");
+ bpf_error(cstate, "'addr1' is only supported on 802.11");
break;
case Q_ADDR2:
- bpf_error("'addr2' is only supported on 802.11");
+ bpf_error(cstate, "'addr2' is only supported on 802.11");
break;
case Q_ADDR3:
- bpf_error("'addr3' is only supported on 802.11");
+ bpf_error(cstate, "'addr3' is only supported on 802.11");
break;
case Q_ADDR4:
- bpf_error("'addr4' is only supported on 802.11");
+ bpf_error(cstate, "'addr4' is only supported on 802.11");
break;
case Q_RA:
- bpf_error("'ra' is only supported on 802.11");
+ bpf_error(cstate, "'ra' is only supported on 802.11");
break;
case Q_TA:
- bpf_error("'ta' is only supported on 802.11");
+ bpf_error(cstate, "'ta' is only supported on 802.11");
break;
}
abort();
@@ -3769,54 +4007,52 @@ gen_fhostop(eaddr, dir)
* Like gen_ehostop, but for DLT_IEEE802 (Token Ring)
*/
static struct block *
-gen_thostop(eaddr, dir)
- register const u_char *eaddr;
- register int dir;
+gen_thostop(compiler_state_t *cstate, const u_char *eaddr, int dir)
{
register struct block *b0, *b1;
switch (dir) {
case Q_SRC:
- return gen_bcmp(OR_LINK, 8, 6, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 8, 6, eaddr);
case Q_DST:
- return gen_bcmp(OR_LINK, 2, 6, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 2, 6, eaddr);
case Q_AND:
- b0 = gen_thostop(eaddr, Q_SRC);
- b1 = gen_thostop(eaddr, Q_DST);
+ b0 = gen_thostop(cstate, eaddr, Q_SRC);
+ b1 = gen_thostop(cstate, eaddr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_DEFAULT:
case Q_OR:
- b0 = gen_thostop(eaddr, Q_SRC);
- b1 = gen_thostop(eaddr, Q_DST);
+ b0 = gen_thostop(cstate, eaddr, Q_SRC);
+ b1 = gen_thostop(cstate, eaddr, Q_DST);
gen_or(b0, b1);
return b1;
case Q_ADDR1:
- bpf_error("'addr1' is only supported on 802.11");
+ bpf_error(cstate, "'addr1' is only supported on 802.11");
break;
case Q_ADDR2:
- bpf_error("'addr2' is only supported on 802.11");
+ bpf_error(cstate, "'addr2' is only supported on 802.11");
break;
case Q_ADDR3:
- bpf_error("'addr3' is only supported on 802.11");
+ bpf_error(cstate, "'addr3' is only supported on 802.11");
break;
case Q_ADDR4:
- bpf_error("'addr4' is only supported on 802.11");
+ bpf_error(cstate, "'addr4' is only supported on 802.11");
break;
case Q_RA:
- bpf_error("'ra' is only supported on 802.11");
+ bpf_error(cstate, "'ra' is only supported on 802.11");
break;
case Q_TA:
- bpf_error("'ta' is only supported on 802.11");
+ bpf_error(cstate, "'ta' is only supported on 802.11");
break;
}
abort();
@@ -3828,9 +4064,7 @@ gen_thostop(eaddr, dir)
* various 802.11 + radio headers.
*/
static struct block *
-gen_wlanhostop(eaddr, dir)
- register const u_char *eaddr;
- register int dir;
+gen_wlanhostop(compiler_state_t *cstate, const u_char *eaddr, int dir)
{
register struct block *b0, *b1, *b2;
register struct slist *s;
@@ -3842,7 +4076,7 @@ gen_wlanhostop(eaddr, dir)
* and wipes out some LD instructions generated by the below
* code to validate the Frame Control bits
*/
- no_optimize = 1;
+ cstate->no_optimize = 1;
#endif /* ENABLE_WLAN_FILTERING_PATCH */
switch (dir) {
@@ -3872,23 +4106,23 @@ gen_wlanhostop(eaddr, dir)
*
* First, check for To DS set, i.e. check "link[1] & 0x01".
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x01; /* To DS */
b1->stmts = s;
/*
* If To DS is set, the SA is at 24.
*/
- b0 = gen_bcmp(OR_LINK, 24, 6, eaddr);
+ b0 = gen_bcmp(cstate, OR_LINKHDR, 24, 6, eaddr);
gen_and(b1, b0);
/*
* Now, check for To DS not set, i.e. check
* "!(link[1] & 0x01)".
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x01; /* To DS */
b2->stmts = s;
gen_not(b2);
@@ -3896,7 +4130,7 @@ gen_wlanhostop(eaddr, dir)
/*
* If To DS is not set, the SA is at 16.
*/
- b1 = gen_bcmp(OR_LINK, 16, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 16, 6, eaddr);
gen_and(b2, b1);
/*
@@ -3910,8 +4144,8 @@ gen_wlanhostop(eaddr, dir)
* Now check for From DS being set, and AND that with
* the ORed-together checks.
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x02; /* From DS */
b1->stmts = s;
gen_and(b1, b0);
@@ -3919,8 +4153,8 @@ gen_wlanhostop(eaddr, dir)
/*
* Now check for data frames with From DS not set.
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x02; /* From DS */
b2->stmts = s;
gen_not(b2);
@@ -3928,7 +4162,7 @@ gen_wlanhostop(eaddr, dir)
/*
* If From DS isn't set, the SA is at 10.
*/
- b1 = gen_bcmp(OR_LINK, 10, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
gen_and(b2, b1);
/*
@@ -3942,8 +4176,8 @@ gen_wlanhostop(eaddr, dir)
* Now check for a data frame.
* I.e, check "link[0] & 0x08".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x08;
b1->stmts = s;
@@ -3957,8 +4191,8 @@ gen_wlanhostop(eaddr, dir)
* is a management frame.
* I.e, check "!(link[0] & 0x08)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x08;
b2->stmts = s;
gen_not(b2);
@@ -3966,7 +4200,7 @@ gen_wlanhostop(eaddr, dir)
/*
* For management frames, the SA is at 10.
*/
- b1 = gen_bcmp(OR_LINK, 10, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
gen_and(b2, b1);
/*
@@ -3984,8 +4218,8 @@ gen_wlanhostop(eaddr, dir)
*
* I.e., check "!(link[0] & 0x04)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x04;
b1->stmts = s;
gen_not(b1);
@@ -4019,23 +4253,23 @@ gen_wlanhostop(eaddr, dir)
*
* First, check for To DS set, i.e. "link[1] & 0x01".
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x01; /* To DS */
b1->stmts = s;
/*
* If To DS is set, the DA is at 16.
*/
- b0 = gen_bcmp(OR_LINK, 16, 6, eaddr);
+ b0 = gen_bcmp(cstate, OR_LINKHDR, 16, 6, eaddr);
gen_and(b1, b0);
/*
* Now, check for To DS not set, i.e. check
* "!(link[1] & 0x01)".
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x01; /* To DS */
b2->stmts = s;
gen_not(b2);
@@ -4043,7 +4277,7 @@ gen_wlanhostop(eaddr, dir)
/*
* If To DS is not set, the DA is at 4.
*/
- b1 = gen_bcmp(OR_LINK, 4, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 4, 6, eaddr);
gen_and(b2, b1);
/*
@@ -4056,8 +4290,8 @@ gen_wlanhostop(eaddr, dir)
* Now check for a data frame.
* I.e, check "link[0] & 0x08".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x08;
b1->stmts = s;
@@ -4071,8 +4305,8 @@ gen_wlanhostop(eaddr, dir)
* is a management frame.
* I.e, check "!(link[0] & 0x08)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x08;
b2->stmts = s;
gen_not(b2);
@@ -4080,7 +4314,7 @@ gen_wlanhostop(eaddr, dir)
/*
* For management frames, the DA is at 4.
*/
- b1 = gen_bcmp(OR_LINK, 4, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 4, 6, eaddr);
gen_and(b2, b1);
/*
@@ -4098,8 +4332,8 @@ gen_wlanhostop(eaddr, dir)
*
* I.e., check "!(link[0] & 0x04)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x04;
b1->stmts = s;
gen_not(b1);
@@ -4122,15 +4356,15 @@ gen_wlanhostop(eaddr, dir)
* is a management frame.
* I.e, check "(link[0] & 0x08)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x08;
b1->stmts = s;
/*
* Check addr1.
*/
- b0 = gen_bcmp(OR_LINK, 4, 6, eaddr);
+ b0 = gen_bcmp(cstate, OR_LINKHDR, 4, 6, eaddr);
/*
* AND that with the check of addr1.
@@ -4147,13 +4381,13 @@ gen_wlanhostop(eaddr, dir)
/*
* Not present in CTS or ACK control frames.
*/
- b0 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
IEEE80211_FC0_TYPE_MASK);
gen_not(b0);
- b1 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
+ b1 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
IEEE80211_FC0_SUBTYPE_MASK);
gen_not(b1);
- b2 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
+ b2 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
IEEE80211_FC0_SUBTYPE_MASK);
gen_not(b2);
gen_and(b1, b2);
@@ -4164,8 +4398,8 @@ gen_wlanhostop(eaddr, dir)
* is a management frame.
* I.e, check "(link[0] & 0x08)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x08;
b1->stmts = s;
@@ -4178,7 +4412,7 @@ gen_wlanhostop(eaddr, dir)
/*
* Check addr2.
*/
- b1 = gen_bcmp(OR_LINK, 10, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
gen_and(b2, b1);
return b1;
@@ -4186,24 +4420,24 @@ gen_wlanhostop(eaddr, dir)
* XXX - add BSSID keyword?
*/
case Q_ADDR1:
- return (gen_bcmp(OR_LINK, 4, 6, eaddr));
+ return (gen_bcmp(cstate, OR_LINKHDR, 4, 6, eaddr));
case Q_ADDR2:
/*
* Not present in CTS or ACK control frames.
*/
- b0 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
IEEE80211_FC0_TYPE_MASK);
gen_not(b0);
- b1 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
+ b1 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
IEEE80211_FC0_SUBTYPE_MASK);
gen_not(b1);
- b2 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
+ b2 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
IEEE80211_FC0_SUBTYPE_MASK);
gen_not(b2);
gen_and(b1, b2);
gen_or(b0, b2);
- b1 = gen_bcmp(OR_LINK, 10, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
gen_and(b2, b1);
return b1;
@@ -4211,10 +4445,10 @@ gen_wlanhostop(eaddr, dir)
/*
* Not present in control frames.
*/
- b0 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
IEEE80211_FC0_TYPE_MASK);
gen_not(b0);
- b1 = gen_bcmp(OR_LINK, 16, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 16, 6, eaddr);
gen_and(b0, b1);
return b1;
@@ -4225,22 +4459,22 @@ gen_wlanhostop(eaddr, dir)
* frames should have both of those set, so we don't
* check the frame type.
*/
- b0 = gen_mcmp(OR_LINK, 1, BPF_B,
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 1, BPF_B,
IEEE80211_FC1_DIR_DSTODS, IEEE80211_FC1_DIR_MASK);
- b1 = gen_bcmp(OR_LINK, 24, 6, eaddr);
+ b1 = gen_bcmp(cstate, OR_LINKHDR, 24, 6, eaddr);
gen_and(b0, b1);
return b1;
case Q_AND:
- b0 = gen_wlanhostop(eaddr, Q_SRC);
- b1 = gen_wlanhostop(eaddr, Q_DST);
+ b0 = gen_wlanhostop(cstate, eaddr, Q_SRC);
+ b1 = gen_wlanhostop(cstate, eaddr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_DEFAULT:
case Q_OR:
- b0 = gen_wlanhostop(eaddr, Q_SRC);
- b1 = gen_wlanhostop(eaddr, Q_DST);
+ b0 = gen_wlanhostop(cstate, eaddr, Q_SRC);
+ b1 = gen_wlanhostop(cstate, eaddr, Q_DST);
gen_or(b0, b1);
return b1;
}
@@ -4254,54 +4488,52 @@ gen_wlanhostop(eaddr, dir)
* as the RFC states.)
*/
static struct block *
-gen_ipfchostop(eaddr, dir)
- register const u_char *eaddr;
- register int dir;
+gen_ipfchostop(compiler_state_t *cstate, const u_char *eaddr, int dir)
{
register struct block *b0, *b1;
switch (dir) {
case Q_SRC:
- return gen_bcmp(OR_LINK, 10, 6, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
case Q_DST:
- return gen_bcmp(OR_LINK, 2, 6, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 2, 6, eaddr);
case Q_AND:
- b0 = gen_ipfchostop(eaddr, Q_SRC);
- b1 = gen_ipfchostop(eaddr, Q_DST);
+ b0 = gen_ipfchostop(cstate, eaddr, Q_SRC);
+ b1 = gen_ipfchostop(cstate, eaddr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_DEFAULT:
case Q_OR:
- b0 = gen_ipfchostop(eaddr, Q_SRC);
- b1 = gen_ipfchostop(eaddr, Q_DST);
+ b0 = gen_ipfchostop(cstate, eaddr, Q_SRC);
+ b1 = gen_ipfchostop(cstate, eaddr, Q_DST);
gen_or(b0, b1);
return b1;
case Q_ADDR1:
- bpf_error("'addr1' is only supported on 802.11");
+ bpf_error(cstate, "'addr1' is only supported on 802.11");
break;
case Q_ADDR2:
- bpf_error("'addr2' is only supported on 802.11");
+ bpf_error(cstate, "'addr2' is only supported on 802.11");
break;
case Q_ADDR3:
- bpf_error("'addr3' is only supported on 802.11");
+ bpf_error(cstate, "'addr3' is only supported on 802.11");
break;
case Q_ADDR4:
- bpf_error("'addr4' is only supported on 802.11");
+ bpf_error(cstate, "'addr4' is only supported on 802.11");
break;
case Q_RA:
- bpf_error("'ra' is only supported on 802.11");
+ bpf_error(cstate, "'ra' is only supported on 802.11");
break;
case Q_TA:
- bpf_error("'ta' is only supported on 802.11");
+ bpf_error(cstate, "'ta' is only supported on 802.11");
break;
}
abort();
@@ -4327,9 +4559,7 @@ gen_ipfchostop(eaddr, dir)
* and not generate masking instructions if the mask is 0xFFFF.
*/
static struct block *
-gen_dnhostop(addr, dir)
- bpf_u_int32 addr;
- int dir;
+gen_dnhostop(compiler_state_t *cstate, bpf_u_int32 addr, int dir)
{
struct block *b0, *b1, *b2, *tmp;
u_int offset_lh; /* offset if long header is received */
@@ -4349,50 +4579,50 @@ gen_dnhostop(addr, dir)
case Q_AND:
/* Inefficient because we do our Calvinball dance twice */
- b0 = gen_dnhostop(addr, Q_SRC);
- b1 = gen_dnhostop(addr, Q_DST);
+ b0 = gen_dnhostop(cstate, addr, Q_SRC);
+ b1 = gen_dnhostop(cstate, addr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_OR:
case Q_DEFAULT:
/* Inefficient because we do our Calvinball dance twice */
- b0 = gen_dnhostop(addr, Q_SRC);
- b1 = gen_dnhostop(addr, Q_DST);
+ b0 = gen_dnhostop(cstate, addr, Q_SRC);
+ b1 = gen_dnhostop(cstate, addr, Q_DST);
gen_or(b0, b1);
return b1;
case Q_ISO:
- bpf_error("ISO host filtering not implemented");
+ bpf_error(cstate, "ISO host filtering not implemented");
default:
abort();
}
- b0 = gen_linktype(ETHERTYPE_DN);
+ b0 = gen_linktype(cstate, ETHERTYPE_DN);
/* Check for pad = 1, long header case */
- tmp = gen_mcmp(OR_NET, 2, BPF_H,
+ tmp = gen_mcmp(cstate, OR_LINKPL, 2, BPF_H,
(bpf_int32)ntohs(0x0681), (bpf_int32)ntohs(0x07FF));
- b1 = gen_cmp(OR_NET, 2 + 1 + offset_lh,
+ b1 = gen_cmp(cstate, OR_LINKPL, 2 + 1 + offset_lh,
BPF_H, (bpf_int32)ntohs((u_short)addr));
gen_and(tmp, b1);
/* Check for pad = 0, long header case */
- tmp = gen_mcmp(OR_NET, 2, BPF_B, (bpf_int32)0x06, (bpf_int32)0x7);
- b2 = gen_cmp(OR_NET, 2 + offset_lh, BPF_H, (bpf_int32)ntohs((u_short)addr));
+ tmp = gen_mcmp(cstate, OR_LINKPL, 2, BPF_B, (bpf_int32)0x06, (bpf_int32)0x7);
+ b2 = gen_cmp(cstate, OR_LINKPL, 2 + offset_lh, BPF_H, (bpf_int32)ntohs((u_short)addr));
gen_and(tmp, b2);
gen_or(b2, b1);
/* Check for pad = 1, short header case */
- tmp = gen_mcmp(OR_NET, 2, BPF_H,
+ tmp = gen_mcmp(cstate, OR_LINKPL, 2, BPF_H,
(bpf_int32)ntohs(0x0281), (bpf_int32)ntohs(0x07FF));
- b2 = gen_cmp(OR_NET, 2 + 1 + offset_sh, BPF_H, (bpf_int32)ntohs((u_short)addr));
+ b2 = gen_cmp(cstate, OR_LINKPL, 2 + 1 + offset_sh, BPF_H, (bpf_int32)ntohs((u_short)addr));
gen_and(tmp, b2);
gen_or(b2, b1);
/* Check for pad = 0, short header case */
- tmp = gen_mcmp(OR_NET, 2, BPF_B, (bpf_int32)0x02, (bpf_int32)0x7);
- b2 = gen_cmp(OR_NET, 2 + offset_sh, BPF_H, (bpf_int32)ntohs((u_short)addr));
+ tmp = gen_mcmp(cstate, OR_LINKPL, 2, BPF_B, (bpf_int32)0x02, (bpf_int32)0x7);
+ b2 = gen_cmp(cstate, OR_LINKPL, 2 + offset_sh, BPF_H, (bpf_int32)ntohs((u_short)addr));
gen_and(tmp, b2);
gen_or(b2, b1);
- /* Combine with test for linktype */
+ /* Combine with test for cstate->linktype */
gen_and(b0, b1);
return b1;
}
@@ -4403,8 +4633,7 @@ gen_dnhostop(addr, dir)
* field in the IP header.
*/
static struct block *
-gen_mpls_linktype(proto)
- int proto;
+gen_mpls_linktype(compiler_state_t *cstate, int proto)
{
struct block *b0, *b1;
@@ -4412,17 +4641,17 @@ gen_mpls_linktype(proto)
case Q_IP:
/* match the bottom-of-stack bit */
- b0 = gen_mcmp(OR_NET, -2, BPF_B, 0x01, 0x01);
+ b0 = gen_mcmp(cstate, OR_LINKPL, -2, BPF_B, 0x01, 0x01);
/* match the IPv4 version number */
- b1 = gen_mcmp(OR_NET, 0, BPF_B, 0x40, 0xf0);
+ b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_B, 0x40, 0xf0);
gen_and(b0, b1);
return b1;
case Q_IPV6:
/* match the bottom-of-stack bit */
- b0 = gen_mcmp(OR_NET, -2, BPF_B, 0x01, 0x01);
+ b0 = gen_mcmp(cstate, OR_LINKPL, -2, BPF_B, 0x01, 0x01);
/* match the IPv4 version number */
- b1 = gen_mcmp(OR_NET, 0, BPF_B, 0x60, 0xf0);
+ b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_B, 0x60, 0xf0);
gen_and(b0, b1);
return b1;
@@ -4432,12 +4661,8 @@ gen_mpls_linktype(proto)
}
static struct block *
-gen_host(addr, mask, proto, dir, type)
- bpf_u_int32 addr;
- bpf_u_int32 mask;
- int proto;
- int dir;
- int type;
+gen_host(compiler_state_t *cstate, bpf_u_int32 addr, bpf_u_int32 mask,
+ int proto, int dir, int type)
{
struct block *b0, *b1;
const char *typestr;
@@ -4450,111 +4675,111 @@ gen_host(addr, mask, proto, dir, type)
switch (proto) {
case Q_DEFAULT:
- b0 = gen_host(addr, mask, Q_IP, dir, type);
+ b0 = gen_host(cstate, addr, mask, Q_IP, dir, type);
/*
* Only check for non-IPv4 addresses if we're not
* checking MPLS-encapsulated packets.
*/
- if (label_stack_depth == 0) {
- b1 = gen_host(addr, mask, Q_ARP, dir, type);
+ if (cstate->label_stack_depth == 0) {
+ b1 = gen_host(cstate, addr, mask, Q_ARP, dir, type);
gen_or(b0, b1);
- b0 = gen_host(addr, mask, Q_RARP, dir, type);
+ b0 = gen_host(cstate, addr, mask, Q_RARP, dir, type);
gen_or(b1, b0);
}
return b0;
case Q_IP:
- return gen_hostop(addr, mask, dir, ETHERTYPE_IP, 12, 16);
+ return gen_hostop(cstate, addr, mask, dir, ETHERTYPE_IP, 12, 16);
case Q_RARP:
- return gen_hostop(addr, mask, dir, ETHERTYPE_REVARP, 14, 24);
+ return gen_hostop(cstate, addr, mask, dir, ETHERTYPE_REVARP, 14, 24);
case Q_ARP:
- return gen_hostop(addr, mask, dir, ETHERTYPE_ARP, 14, 24);
+ return gen_hostop(cstate, addr, mask, dir, ETHERTYPE_ARP, 14, 24);
case Q_TCP:
- bpf_error("'tcp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'tcp' modifier applied to %s", typestr);
case Q_SCTP:
- bpf_error("'sctp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'sctp' modifier applied to %s", typestr);
case Q_UDP:
- bpf_error("'udp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'udp' modifier applied to %s", typestr);
case Q_ICMP:
- bpf_error("'icmp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'icmp' modifier applied to %s", typestr);
case Q_IGMP:
- bpf_error("'igmp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'igmp' modifier applied to %s", typestr);
case Q_IGRP:
- bpf_error("'igrp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'igrp' modifier applied to %s", typestr);
case Q_PIM:
- bpf_error("'pim' modifier applied to %s", typestr);
+ bpf_error(cstate, "'pim' modifier applied to %s", typestr);
case Q_VRRP:
- bpf_error("'vrrp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'vrrp' modifier applied to %s", typestr);
case Q_CARP:
- bpf_error("'carp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'carp' modifier applied to %s", typestr);
case Q_ATALK:
- bpf_error("ATALK host filtering not implemented");
+ bpf_error(cstate, "ATALK host filtering not implemented");
case Q_AARP:
- bpf_error("AARP host filtering not implemented");
+ bpf_error(cstate, "AARP host filtering not implemented");
case Q_DECNET:
- return gen_dnhostop(addr, dir);
+ return gen_dnhostop(cstate, addr, dir);
case Q_SCA:
- bpf_error("SCA host filtering not implemented");
+ bpf_error(cstate, "SCA host filtering not implemented");
case Q_LAT:
- bpf_error("LAT host filtering not implemented");
+ bpf_error(cstate, "LAT host filtering not implemented");
case Q_MOPDL:
- bpf_error("MOPDL host filtering not implemented");
+ bpf_error(cstate, "MOPDL host filtering not implemented");
case Q_MOPRC:
- bpf_error("MOPRC host filtering not implemented");
+ bpf_error(cstate, "MOPRC host filtering not implemented");
case Q_IPV6:
- bpf_error("'ip6' modifier applied to ip host");
+ bpf_error(cstate, "'ip6' modifier applied to ip host");
case Q_ICMPV6:
- bpf_error("'icmp6' modifier applied to %s", typestr);
+ bpf_error(cstate, "'icmp6' modifier applied to %s", typestr);
case Q_AH:
- bpf_error("'ah' modifier applied to %s", typestr);
+ bpf_error(cstate, "'ah' modifier applied to %s", typestr);
case Q_ESP:
- bpf_error("'esp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'esp' modifier applied to %s", typestr);
case Q_ISO:
- bpf_error("ISO host filtering not implemented");
+ bpf_error(cstate, "ISO host filtering not implemented");
case Q_ESIS:
- bpf_error("'esis' modifier applied to %s", typestr);
+ bpf_error(cstate, "'esis' modifier applied to %s", typestr);
case Q_ISIS:
- bpf_error("'isis' modifier applied to %s", typestr);
+ bpf_error(cstate, "'isis' modifier applied to %s", typestr);
case Q_CLNP:
- bpf_error("'clnp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'clnp' modifier applied to %s", typestr);
case Q_STP:
- bpf_error("'stp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'stp' modifier applied to %s", typestr);
case Q_IPX:
- bpf_error("IPX host filtering not implemented");
+ bpf_error(cstate, "IPX host filtering not implemented");
case Q_NETBEUI:
- bpf_error("'netbeui' modifier applied to %s", typestr);
+ bpf_error(cstate, "'netbeui' modifier applied to %s", typestr);
case Q_RADIO:
- bpf_error("'radio' modifier applied to %s", typestr);
+ bpf_error(cstate, "'radio' modifier applied to %s", typestr);
default:
abort();
@@ -4564,12 +4789,8 @@ gen_host(addr, mask, proto, dir, type)
#ifdef INET6
static struct block *
-gen_host6(addr, mask, proto, dir, type)
- struct in6_addr *addr;
- struct in6_addr *mask;
- int proto;
- int dir;
- int type;
+gen_host6(compiler_state_t *cstate, struct in6_addr *addr,
+ struct in6_addr *mask, int proto, int dir, int type)
{
const char *typestr;
@@ -4581,100 +4802,103 @@ gen_host6(addr, mask, proto, dir, type)
switch (proto) {
case Q_DEFAULT:
- return gen_host6(addr, mask, Q_IPV6, dir, type);
+ return gen_host6(cstate, addr, mask, Q_IPV6, dir, type);
+
+ case Q_LINK:
+ bpf_error(cstate, "link-layer modifier applied to ip6 %s", typestr);
case Q_IP:
- bpf_error("'ip' modifier applied to ip6 %s", typestr);
+ bpf_error(cstate, "'ip' modifier applied to ip6 %s", typestr);
case Q_RARP:
- bpf_error("'rarp' modifier applied to ip6 %s", typestr);
+ bpf_error(cstate, "'rarp' modifier applied to ip6 %s", typestr);
case Q_ARP:
- bpf_error("'arp' modifier applied to ip6 %s", typestr);
+ bpf_error(cstate, "'arp' modifier applied to ip6 %s", typestr);
case Q_SCTP:
- bpf_error("'sctp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'sctp' modifier applied to %s", typestr);
case Q_TCP:
- bpf_error("'tcp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'tcp' modifier applied to %s", typestr);
case Q_UDP:
- bpf_error("'udp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'udp' modifier applied to %s", typestr);
case Q_ICMP:
- bpf_error("'icmp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'icmp' modifier applied to %s", typestr);
case Q_IGMP:
- bpf_error("'igmp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'igmp' modifier applied to %s", typestr);
case Q_IGRP:
- bpf_error("'igrp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'igrp' modifier applied to %s", typestr);
case Q_PIM:
- bpf_error("'pim' modifier applied to %s", typestr);
+ bpf_error(cstate, "'pim' modifier applied to %s", typestr);
case Q_VRRP:
- bpf_error("'vrrp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'vrrp' modifier applied to %s", typestr);
case Q_CARP:
- bpf_error("'carp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'carp' modifier applied to %s", typestr);
case Q_ATALK:
- bpf_error("ATALK host filtering not implemented");
+ bpf_error(cstate, "ATALK host filtering not implemented");
case Q_AARP:
- bpf_error("AARP host filtering not implemented");
+ bpf_error(cstate, "AARP host filtering not implemented");
case Q_DECNET:
- bpf_error("'decnet' modifier applied to ip6 %s", typestr);
+ bpf_error(cstate, "'decnet' modifier applied to ip6 %s", typestr);
case Q_SCA:
- bpf_error("SCA host filtering not implemented");
+ bpf_error(cstate, "SCA host filtering not implemented");
case Q_LAT:
- bpf_error("LAT host filtering not implemented");
+ bpf_error(cstate, "LAT host filtering not implemented");
case Q_MOPDL:
- bpf_error("MOPDL host filtering not implemented");
+ bpf_error(cstate, "MOPDL host filtering not implemented");
case Q_MOPRC:
- bpf_error("MOPRC host filtering not implemented");
+ bpf_error(cstate, "MOPRC host filtering not implemented");
case Q_IPV6:
- return gen_hostop6(addr, mask, dir, ETHERTYPE_IPV6, 8, 24);
+ return gen_hostop6(cstate, addr, mask, dir, ETHERTYPE_IPV6, 8, 24);
case Q_ICMPV6:
- bpf_error("'icmp6' modifier applied to %s", typestr);
+ bpf_error(cstate, "'icmp6' modifier applied to %s", typestr);
case Q_AH:
- bpf_error("'ah' modifier applied to %s", typestr);
+ bpf_error(cstate, "'ah' modifier applied to %s", typestr);
case Q_ESP:
- bpf_error("'esp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'esp' modifier applied to %s", typestr);
case Q_ISO:
- bpf_error("ISO host filtering not implemented");
+ bpf_error(cstate, "ISO host filtering not implemented");
case Q_ESIS:
- bpf_error("'esis' modifier applied to %s", typestr);
+ bpf_error(cstate, "'esis' modifier applied to %s", typestr);
case Q_ISIS:
- bpf_error("'isis' modifier applied to %s", typestr);
+ bpf_error(cstate, "'isis' modifier applied to %s", typestr);
case Q_CLNP:
- bpf_error("'clnp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'clnp' modifier applied to %s", typestr);
case Q_STP:
- bpf_error("'stp' modifier applied to %s", typestr);
+ bpf_error(cstate, "'stp' modifier applied to %s", typestr);
case Q_IPX:
- bpf_error("IPX host filtering not implemented");
+ bpf_error(cstate, "IPX host filtering not implemented");
case Q_NETBEUI:
- bpf_error("'netbeui' modifier applied to %s", typestr);
+ bpf_error(cstate, "'netbeui' modifier applied to %s", typestr);
case Q_RADIO:
- bpf_error("'radio' modifier applied to %s", typestr);
+ bpf_error(cstate, "'radio' modifier applied to %s", typestr);
default:
abort();
@@ -4685,70 +4909,60 @@ gen_host6(addr, mask, proto, dir, type)
#ifndef INET6
static struct block *
-gen_gateway(eaddr, alist, proto, dir)
- const u_char *eaddr;
- bpf_u_int32 **alist;
- int proto;
- int dir;
+gen_gateway(compiler_state_t *cstate, const u_char *eaddr, bpf_u_int32 **alist,
+ int proto, int dir)
{
struct block *b0, *b1, *tmp;
if (dir != 0)
- bpf_error("direction applied to 'gateway'");
+ bpf_error(cstate, "direction applied to 'gateway'");
switch (proto) {
case Q_DEFAULT:
case Q_IP:
case Q_ARP:
case Q_RARP:
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- b0 = gen_ehostop(eaddr, Q_OR);
+ b1 = gen_prevlinkhdr_check(cstate);
+ b0 = gen_ehostop(cstate, eaddr, Q_OR);
+ if (b1 != NULL)
+ gen_and(b1, b0);
break;
case DLT_FDDI:
- b0 = gen_fhostop(eaddr, Q_OR);
+ b0 = gen_fhostop(cstate, eaddr, Q_OR);
break;
case DLT_IEEE802:
- b0 = gen_thostop(eaddr, Q_OR);
+ b0 = gen_thostop(cstate, eaddr, Q_OR);
break;
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
case DLT_PPI:
- b0 = gen_wlanhostop(eaddr, Q_OR);
+ b0 = gen_wlanhostop(cstate, eaddr, Q_OR);
break;
case DLT_SUNATM:
- if (!is_lane)
- bpf_error(
- "'gateway' supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
/*
- * Check that the packet doesn't begin with an
- * LE Control marker. (We've already generated
- * a test for LANE.)
+ * This is LLC-multiplexed traffic; if it were
+ * LANE, cstate->linktype would have been set to
+ * DLT_EN10MB.
*/
- b1 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS,
- BPF_H, 0xFF00);
- gen_not(b1);
-
- /*
- * Now check the MAC address.
- */
- b0 = gen_ehostop(eaddr, Q_OR);
- gen_and(b1, b0);
+ bpf_error(cstate,
+ "'gateway' supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
break;
case DLT_IP_OVER_FC:
- b0 = gen_ipfchostop(eaddr, Q_OR);
+ b0 = gen_ipfchostop(cstate, eaddr, Q_OR);
break;
default:
- bpf_error(
+ bpf_error(cstate,
"'gateway' supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
}
- b1 = gen_host(**alist++, 0xffffffff, proto, Q_OR, Q_HOST);
+ b1 = gen_host(cstate, **alist++, 0xffffffff, proto, Q_OR, Q_HOST);
while (*alist) {
- tmp = gen_host(**alist++, 0xffffffff, proto, Q_OR,
+ tmp = gen_host(cstate, **alist++, 0xffffffff, proto, Q_OR,
Q_HOST);
gen_or(b1, tmp);
b1 = tmp;
@@ -4757,14 +4971,13 @@ gen_gateway(eaddr, alist, proto, dir)
gen_and(b0, b1);
return b1;
}
- bpf_error("illegal modifier of 'gateway'");
+ bpf_error(cstate, "illegal modifier of 'gateway'");
/* NOTREACHED */
}
#endif
struct block *
-gen_proto_abbrev(proto)
- int proto;
+gen_proto_abbrev(compiler_state_t *cstate, int proto)
{
struct block *b0;
struct block *b1;
@@ -4772,25 +4985,25 @@ gen_proto_abbrev(proto)
switch (proto) {
case Q_SCTP:
- b1 = gen_proto(IPPROTO_SCTP, Q_IP, Q_DEFAULT);
- b0 = gen_proto(IPPROTO_SCTP, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_SCTP, Q_IP, Q_DEFAULT);
+ b0 = gen_proto(cstate, IPPROTO_SCTP, Q_IPV6, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_TCP:
- b1 = gen_proto(IPPROTO_TCP, Q_IP, Q_DEFAULT);
- b0 = gen_proto(IPPROTO_TCP, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_TCP, Q_IP, Q_DEFAULT);
+ b0 = gen_proto(cstate, IPPROTO_TCP, Q_IPV6, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_UDP:
- b1 = gen_proto(IPPROTO_UDP, Q_IP, Q_DEFAULT);
- b0 = gen_proto(IPPROTO_UDP, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_UDP, Q_IP, Q_DEFAULT);
+ b0 = gen_proto(cstate, IPPROTO_UDP, Q_IPV6, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ICMP:
- b1 = gen_proto(IPPROTO_ICMP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_ICMP, Q_IP, Q_DEFAULT);
break;
#ifndef IPPROTO_IGMP
@@ -4798,14 +5011,14 @@ gen_proto_abbrev(proto)
#endif
case Q_IGMP:
- b1 = gen_proto(IPPROTO_IGMP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_IGMP, Q_IP, Q_DEFAULT);
break;
#ifndef IPPROTO_IGRP
#define IPPROTO_IGRP 9
#endif
case Q_IGRP:
- b1 = gen_proto(IPPROTO_IGRP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_IGRP, Q_IP, Q_DEFAULT);
break;
#ifndef IPPROTO_PIM
@@ -4813,8 +5026,8 @@ gen_proto_abbrev(proto)
#endif
case Q_PIM:
- b1 = gen_proto(IPPROTO_PIM, Q_IP, Q_DEFAULT);
- b0 = gen_proto(IPPROTO_PIM, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_PIM, Q_IP, Q_DEFAULT);
+ b0 = gen_proto(cstate, IPPROTO_PIM, Q_IPV6, Q_DEFAULT);
gen_or(b0, b1);
break;
@@ -4823,7 +5036,7 @@ gen_proto_abbrev(proto)
#endif
case Q_VRRP:
- b1 = gen_proto(IPPROTO_VRRP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_VRRP, Q_IP, Q_DEFAULT);
break;
#ifndef IPPROTO_CARP
@@ -4831,69 +5044,69 @@ gen_proto_abbrev(proto)
#endif
case Q_CARP:
- b1 = gen_proto(IPPROTO_CARP, Q_IP, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_CARP, Q_IP, Q_DEFAULT);
break;
case Q_IP:
- b1 = gen_linktype(ETHERTYPE_IP);
+ b1 = gen_linktype(cstate, ETHERTYPE_IP);
break;
case Q_ARP:
- b1 = gen_linktype(ETHERTYPE_ARP);
+ b1 = gen_linktype(cstate, ETHERTYPE_ARP);
break;
case Q_RARP:
- b1 = gen_linktype(ETHERTYPE_REVARP);
+ b1 = gen_linktype(cstate, ETHERTYPE_REVARP);
break;
case Q_LINK:
- bpf_error("link layer applied in wrong context");
+ bpf_error(cstate, "link layer applied in wrong context");
case Q_ATALK:
- b1 = gen_linktype(ETHERTYPE_ATALK);
+ b1 = gen_linktype(cstate, ETHERTYPE_ATALK);
break;
case Q_AARP:
- b1 = gen_linktype(ETHERTYPE_AARP);
+ b1 = gen_linktype(cstate, ETHERTYPE_AARP);
break;
case Q_DECNET:
- b1 = gen_linktype(ETHERTYPE_DN);
+ b1 = gen_linktype(cstate, ETHERTYPE_DN);
break;
case Q_SCA:
- b1 = gen_linktype(ETHERTYPE_SCA);
+ b1 = gen_linktype(cstate, ETHERTYPE_SCA);
break;
case Q_LAT:
- b1 = gen_linktype(ETHERTYPE_LAT);
+ b1 = gen_linktype(cstate, ETHERTYPE_LAT);
break;
case Q_MOPDL:
- b1 = gen_linktype(ETHERTYPE_MOPDL);
+ b1 = gen_linktype(cstate, ETHERTYPE_MOPDL);
break;
case Q_MOPRC:
- b1 = gen_linktype(ETHERTYPE_MOPRC);
+ b1 = gen_linktype(cstate, ETHERTYPE_MOPRC);
break;
case Q_IPV6:
- b1 = gen_linktype(ETHERTYPE_IPV6);
+ b1 = gen_linktype(cstate, ETHERTYPE_IPV6);
break;
#ifndef IPPROTO_ICMPV6
#define IPPROTO_ICMPV6 58
#endif
case Q_ICMPV6:
- b1 = gen_proto(IPPROTO_ICMPV6, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_ICMPV6, Q_IPV6, Q_DEFAULT);
break;
#ifndef IPPROTO_AH
#define IPPROTO_AH 51
#endif
case Q_AH:
- b1 = gen_proto(IPPROTO_AH, Q_IP, Q_DEFAULT);
- b0 = gen_proto(IPPROTO_AH, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_AH, Q_IP, Q_DEFAULT);
+ b0 = gen_proto(cstate, IPPROTO_AH, Q_IPV6, Q_DEFAULT);
gen_or(b0, b1);
break;
@@ -4901,101 +5114,101 @@ gen_proto_abbrev(proto)
#define IPPROTO_ESP 50
#endif
case Q_ESP:
- b1 = gen_proto(IPPROTO_ESP, Q_IP, Q_DEFAULT);
- b0 = gen_proto(IPPROTO_ESP, Q_IPV6, Q_DEFAULT);
+ b1 = gen_proto(cstate, IPPROTO_ESP, Q_IP, Q_DEFAULT);
+ b0 = gen_proto(cstate, IPPROTO_ESP, Q_IPV6, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISO:
- b1 = gen_linktype(LLCSAP_ISONS);
+ b1 = gen_linktype(cstate, LLCSAP_ISONS);
break;
case Q_ESIS:
- b1 = gen_proto(ISO9542_ESIS, Q_ISO, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISO9542_ESIS, Q_ISO, Q_DEFAULT);
break;
case Q_ISIS:
- b1 = gen_proto(ISO10589_ISIS, Q_ISO, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISO10589_ISIS, Q_ISO, Q_DEFAULT);
break;
case Q_ISIS_L1: /* all IS-IS Level1 PDU-Types */
- b0 = gen_proto(ISIS_L1_LAN_IIH, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT); /* FIXME extract the circuit-type bits */
+ b0 = gen_proto(cstate, ISIS_L1_LAN_IIH, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT); /* FIXME extract the circuit-type bits */
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L1_LSP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_LSP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISIS_L2: /* all IS-IS Level2 PDU-Types */
- b0 = gen_proto(ISIS_L2_LAN_IIH, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT); /* FIXME extract the circuit-type bits */
+ b0 = gen_proto(cstate, ISIS_L2_LAN_IIH, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT); /* FIXME extract the circuit-type bits */
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L2_LSP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_LSP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISIS_IIH: /* all IS-IS Hello PDU-Types */
- b0 = gen_proto(ISIS_L1_LAN_IIH, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_L2_LAN_IIH, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_LAN_IIH, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_L2_LAN_IIH, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_PTP_IIH, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISIS_LSP:
- b0 = gen_proto(ISIS_L1_LSP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_L2_LSP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_LSP, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_L2_LSP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISIS_SNP:
- b0 = gen_proto(ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
- b0 = gen_proto(ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISIS_CSNP:
- b0 = gen_proto(ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_CSNP, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_L2_CSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_ISIS_PSNP:
- b0 = gen_proto(ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
- b1 = gen_proto(ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISIS_L1_PSNP, Q_ISIS, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISIS_L2_PSNP, Q_ISIS, Q_DEFAULT);
gen_or(b0, b1);
break;
case Q_CLNP:
- b1 = gen_proto(ISO8473_CLNP, Q_ISO, Q_DEFAULT);
+ b1 = gen_proto(cstate, ISO8473_CLNP, Q_ISO, Q_DEFAULT);
break;
case Q_STP:
- b1 = gen_linktype(LLCSAP_8021D);
+ b1 = gen_linktype(cstate, LLCSAP_8021D);
break;
case Q_IPX:
- b1 = gen_linktype(LLCSAP_IPX);
+ b1 = gen_linktype(cstate, LLCSAP_IPX);
break;
case Q_NETBEUI:
- b1 = gen_linktype(LLCSAP_NETBEUI);
+ b1 = gen_linktype(cstate, LLCSAP_NETBEUI);
break;
case Q_RADIO:
- bpf_error("'radio' is not a valid protocol type");
+ bpf_error(cstate, "'radio' is not a valid protocol type");
default:
abort();
@@ -5004,14 +5217,14 @@ gen_proto_abbrev(proto)
}
static struct block *
-gen_ipfrag()
+gen_ipfrag(compiler_state_t *cstate)
{
struct slist *s;
struct block *b;
/* not IPv4 frag other than the first frag */
- s = gen_load_a(OR_NET, 6, BPF_H);
- b = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKPL, 6, BPF_H);
+ b = new_block(cstate, JMP(BPF_JSET));
b->s.k = 0x1fff;
b->stmts = s;
gen_not(b);
@@ -5029,51 +5242,46 @@ gen_ipfrag()
* headers).
*/
static struct block *
-gen_portatom(off, v)
- int off;
- bpf_int32 v;
+gen_portatom(compiler_state_t *cstate, int off, bpf_int32 v)
{
- return gen_cmp(OR_TRAN_IPV4, off, BPF_H, v);
+ return gen_cmp(cstate, OR_TRAN_IPV4, off, BPF_H, v);
}
static struct block *
-gen_portatom6(off, v)
- int off;
- bpf_int32 v;
+gen_portatom6(compiler_state_t *cstate, int off, bpf_int32 v)
{
- return gen_cmp(OR_TRAN_IPV6, off, BPF_H, v);
+ return gen_cmp(cstate, OR_TRAN_IPV6, off, BPF_H, v);
}
struct block *
-gen_portop(port, proto, dir)
- int port, proto, dir;
+gen_portop(compiler_state_t *cstate, int port, int proto, int dir)
{
struct block *b0, *b1, *tmp;
/* ip proto 'proto' and not a fragment other than the first fragment */
- tmp = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)proto);
- b0 = gen_ipfrag();
+ tmp = gen_cmp(cstate, OR_LINKPL, 9, BPF_B, (bpf_int32)proto);
+ b0 = gen_ipfrag(cstate);
gen_and(tmp, b0);
switch (dir) {
case Q_SRC:
- b1 = gen_portatom(0, (bpf_int32)port);
+ b1 = gen_portatom(cstate, 0, (bpf_int32)port);
break;
case Q_DST:
- b1 = gen_portatom(2, (bpf_int32)port);
+ b1 = gen_portatom(cstate, 2, (bpf_int32)port);
break;
case Q_OR:
case Q_DEFAULT:
- tmp = gen_portatom(0, (bpf_int32)port);
- b1 = gen_portatom(2, (bpf_int32)port);
+ tmp = gen_portatom(cstate, 0, (bpf_int32)port);
+ b1 = gen_portatom(cstate, 2, (bpf_int32)port);
gen_or(tmp, b1);
break;
case Q_AND:
- tmp = gen_portatom(0, (bpf_int32)port);
- b1 = gen_portatom(2, (bpf_int32)port);
+ tmp = gen_portatom(cstate, 0, (bpf_int32)port);
+ b1 = gen_portatom(cstate, 2, (bpf_int32)port);
gen_and(tmp, b1);
break;
@@ -5086,10 +5294,7 @@ gen_portop(port, proto, dir)
}
static struct block *
-gen_port(port, ip_proto, dir)
- int port;
- int ip_proto;
- int dir;
+gen_port(compiler_state_t *cstate, int port, int ip_proto, int dir)
{
struct block *b0, *b1, *tmp;
@@ -5110,20 +5315,20 @@ gen_port(port, ip_proto, dir)
*
* So we always check for ETHERTYPE_IP.
*/
- b0 = gen_linktype(ETHERTYPE_IP);
+ b0 = gen_linktype(cstate, ETHERTYPE_IP);
switch (ip_proto) {
case IPPROTO_UDP:
case IPPROTO_TCP:
case IPPROTO_SCTP:
- b1 = gen_portop(port, ip_proto, dir);
+ b1 = gen_portop(cstate, port, ip_proto, dir);
break;
case PROTO_UNDEF:
- tmp = gen_portop(port, IPPROTO_TCP, dir);
- b1 = gen_portop(port, IPPROTO_UDP, dir);
+ tmp = gen_portop(cstate, port, IPPROTO_TCP, dir);
+ b1 = gen_portop(cstate, port, IPPROTO_UDP, dir);
gen_or(tmp, b1);
- tmp = gen_portop(port, IPPROTO_SCTP, dir);
+ tmp = gen_portop(cstate, port, IPPROTO_SCTP, dir);
gen_or(tmp, b1);
break;
@@ -5135,34 +5340,33 @@ gen_port(port, ip_proto, dir)
}
struct block *
-gen_portop6(port, proto, dir)
- int port, proto, dir;
+gen_portop6(compiler_state_t *cstate, int port, int proto, int dir)
{
struct block *b0, *b1, *tmp;
/* ip6 proto 'proto' */
/* XXX - catch the first fragment of a fragmented packet? */
- b0 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)proto);
+ b0 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, (bpf_int32)proto);
switch (dir) {
case Q_SRC:
- b1 = gen_portatom6(0, (bpf_int32)port);
+ b1 = gen_portatom6(cstate, 0, (bpf_int32)port);
break;
case Q_DST:
- b1 = gen_portatom6(2, (bpf_int32)port);
+ b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
break;
case Q_OR:
case Q_DEFAULT:
- tmp = gen_portatom6(0, (bpf_int32)port);
- b1 = gen_portatom6(2, (bpf_int32)port);
+ tmp = gen_portatom6(cstate, 0, (bpf_int32)port);
+ b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
gen_or(tmp, b1);
break;
case Q_AND:
- tmp = gen_portatom6(0, (bpf_int32)port);
- b1 = gen_portatom6(2, (bpf_int32)port);
+ tmp = gen_portatom6(cstate, 0, (bpf_int32)port);
+ b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
gen_and(tmp, b1);
break;
@@ -5175,28 +5379,25 @@ gen_portop6(port, proto, dir)
}
static struct block *
-gen_port6(port, ip_proto, dir)
- int port;
- int ip_proto;
- int dir;
+gen_port6(compiler_state_t *cstate, int port, int ip_proto, int dir)
{
struct block *b0, *b1, *tmp;
/* link proto ip6 */
- b0 = gen_linktype(ETHERTYPE_IPV6);
+ b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
switch (ip_proto) {
case IPPROTO_UDP:
case IPPROTO_TCP:
case IPPROTO_SCTP:
- b1 = gen_portop6(port, ip_proto, dir);
+ b1 = gen_portop6(cstate, port, ip_proto, dir);
break;
case PROTO_UNDEF:
- tmp = gen_portop6(port, IPPROTO_TCP, dir);
- b1 = gen_portop6(port, IPPROTO_UDP, dir);
+ tmp = gen_portop6(cstate, port, IPPROTO_TCP, dir);
+ b1 = gen_portop6(cstate, port, IPPROTO_UDP, dir);
gen_or(tmp, b1);
- tmp = gen_portop6(port, IPPROTO_SCTP, dir);
+ tmp = gen_portop6(cstate, port, IPPROTO_SCTP, dir);
gen_or(tmp, b1);
break;
@@ -5209,9 +5410,8 @@ gen_port6(port, ip_proto, dir)
/* gen_portrange code */
static struct block *
-gen_portrangeatom(off, v1, v2)
- int off;
- bpf_int32 v1, v2;
+gen_portrangeatom(compiler_state_t *cstate, int off, bpf_int32 v1,
+ bpf_int32 v2)
{
struct block *b1, *b2;
@@ -5226,8 +5426,8 @@ gen_portrangeatom(off, v1, v2)
v2 = vtemp;
}
- b1 = gen_cmp_ge(OR_TRAN_IPV4, off, BPF_H, v1);
- b2 = gen_cmp_le(OR_TRAN_IPV4, off, BPF_H, v2);
+ b1 = gen_cmp_ge(cstate, OR_TRAN_IPV4, off, BPF_H, v1);
+ b2 = gen_cmp_le(cstate, OR_TRAN_IPV4, off, BPF_H, v2);
gen_and(b1, b2);
@@ -5235,37 +5435,35 @@ gen_portrangeatom(off, v1, v2)
}
struct block *
-gen_portrangeop(port1, port2, proto, dir)
- int port1, port2;
- int proto;
- int dir;
+gen_portrangeop(compiler_state_t *cstate, int port1, int port2, int proto,
+ int dir)
{
struct block *b0, *b1, *tmp;
/* ip proto 'proto' and not a fragment other than the first fragment */
- tmp = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)proto);
- b0 = gen_ipfrag();
+ tmp = gen_cmp(cstate, OR_LINKPL, 9, BPF_B, (bpf_int32)proto);
+ b0 = gen_ipfrag(cstate);
gen_and(tmp, b0);
switch (dir) {
case Q_SRC:
- b1 = gen_portrangeatom(0, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
break;
case Q_DST:
- b1 = gen_portrangeatom(2, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
break;
case Q_OR:
case Q_DEFAULT:
- tmp = gen_portrangeatom(0, (bpf_int32)port1, (bpf_int32)port2);
- b1 = gen_portrangeatom(2, (bpf_int32)port1, (bpf_int32)port2);
+ tmp = gen_portrangeatom(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
gen_or(tmp, b1);
break;
case Q_AND:
- tmp = gen_portrangeatom(0, (bpf_int32)port1, (bpf_int32)port2);
- b1 = gen_portrangeatom(2, (bpf_int32)port1, (bpf_int32)port2);
+ tmp = gen_portrangeatom(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
gen_and(tmp, b1);
break;
@@ -5278,28 +5476,26 @@ gen_portrangeop(port1, port2, proto, dir)
}
static struct block *
-gen_portrange(port1, port2, ip_proto, dir)
- int port1, port2;
- int ip_proto;
- int dir;
+gen_portrange(compiler_state_t *cstate, int port1, int port2, int ip_proto,
+ int dir)
{
struct block *b0, *b1, *tmp;
/* link proto ip */
- b0 = gen_linktype(ETHERTYPE_IP);
+ b0 = gen_linktype(cstate, ETHERTYPE_IP);
switch (ip_proto) {
case IPPROTO_UDP:
case IPPROTO_TCP:
case IPPROTO_SCTP:
- b1 = gen_portrangeop(port1, port2, ip_proto, dir);
+ b1 = gen_portrangeop(cstate, port1, port2, ip_proto, dir);
break;
case PROTO_UNDEF:
- tmp = gen_portrangeop(port1, port2, IPPROTO_TCP, dir);
- b1 = gen_portrangeop(port1, port2, IPPROTO_UDP, dir);
+ tmp = gen_portrangeop(cstate, port1, port2, IPPROTO_TCP, dir);
+ b1 = gen_portrangeop(cstate, port1, port2, IPPROTO_UDP, dir);
gen_or(tmp, b1);
- tmp = gen_portrangeop(port1, port2, IPPROTO_SCTP, dir);
+ tmp = gen_portrangeop(cstate, port1, port2, IPPROTO_SCTP, dir);
gen_or(tmp, b1);
break;
@@ -5311,9 +5507,8 @@ gen_portrange(port1, port2, ip_proto, dir)
}
static struct block *
-gen_portrangeatom6(off, v1, v2)
- int off;
- bpf_int32 v1, v2;
+gen_portrangeatom6(compiler_state_t *cstate, int off, bpf_int32 v1,
+ bpf_int32 v2)
{
struct block *b1, *b2;
@@ -5328,8 +5523,8 @@ gen_portrangeatom6(off, v1, v2)
v2 = vtemp;
}
- b1 = gen_cmp_ge(OR_TRAN_IPV6, off, BPF_H, v1);
- b2 = gen_cmp_le(OR_TRAN_IPV6, off, BPF_H, v2);
+ b1 = gen_cmp_ge(cstate, OR_TRAN_IPV6, off, BPF_H, v1);
+ b2 = gen_cmp_le(cstate, OR_TRAN_IPV6, off, BPF_H, v2);
gen_and(b1, b2);
@@ -5337,36 +5532,34 @@ gen_portrangeatom6(off, v1, v2)
}
struct block *
-gen_portrangeop6(port1, port2, proto, dir)
- int port1, port2;
- int proto;
- int dir;
+gen_portrangeop6(compiler_state_t *cstate, int port1, int port2, int proto,
+ int dir)
{
struct block *b0, *b1, *tmp;
/* ip6 proto 'proto' */
/* XXX - catch the first fragment of a fragmented packet? */
- b0 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)proto);
+ b0 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, (bpf_int32)proto);
switch (dir) {
case Q_SRC:
- b1 = gen_portrangeatom6(0, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom6(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
break;
case Q_DST:
- b1 = gen_portrangeatom6(2, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
break;
case Q_OR:
case Q_DEFAULT:
- tmp = gen_portrangeatom6(0, (bpf_int32)port1, (bpf_int32)port2);
- b1 = gen_portrangeatom6(2, (bpf_int32)port1, (bpf_int32)port2);
+ tmp = gen_portrangeatom6(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
gen_or(tmp, b1);
break;
case Q_AND:
- tmp = gen_portrangeatom6(0, (bpf_int32)port1, (bpf_int32)port2);
- b1 = gen_portrangeatom6(2, (bpf_int32)port1, (bpf_int32)port2);
+ tmp = gen_portrangeatom6(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
+ b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
gen_and(tmp, b1);
break;
@@ -5379,28 +5572,26 @@ gen_portrangeop6(port1, port2, proto, dir)
}
static struct block *
-gen_portrange6(port1, port2, ip_proto, dir)
- int port1, port2;
- int ip_proto;
- int dir;
+gen_portrange6(compiler_state_t *cstate, int port1, int port2, int ip_proto,
+ int dir)
{
struct block *b0, *b1, *tmp;
/* link proto ip6 */
- b0 = gen_linktype(ETHERTYPE_IPV6);
+ b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
switch (ip_proto) {
case IPPROTO_UDP:
case IPPROTO_TCP:
case IPPROTO_SCTP:
- b1 = gen_portrangeop6(port1, port2, ip_proto, dir);
+ b1 = gen_portrangeop6(cstate, port1, port2, ip_proto, dir);
break;
case PROTO_UNDEF:
- tmp = gen_portrangeop6(port1, port2, IPPROTO_TCP, dir);
- b1 = gen_portrangeop6(port1, port2, IPPROTO_UDP, dir);
+ tmp = gen_portrangeop6(cstate, port1, port2, IPPROTO_TCP, dir);
+ b1 = gen_portrangeop6(cstate, port1, port2, IPPROTO_UDP, dir);
gen_or(tmp, b1);
- tmp = gen_portrangeop6(port1, port2, IPPROTO_SCTP, dir);
+ tmp = gen_portrangeop6(cstate, port1, port2, IPPROTO_SCTP, dir);
gen_or(tmp, b1);
break;
@@ -5412,9 +5603,7 @@ gen_portrange6(port1, port2, ip_proto, dir)
}
static int
-lookup_proto(name, proto)
- register const char *name;
- register int proto;
+lookup_proto(compiler_state_t *cstate, const char *name, int proto)
{
register int v;
@@ -5425,16 +5614,16 @@ lookup_proto(name, proto)
case Q_IPV6:
v = pcap_nametoproto(name);
if (v == PROTO_UNDEF)
- bpf_error("unknown ip proto '%s'", name);
+ bpf_error(cstate, "unknown ip proto '%s'", name);
break;
case Q_LINK:
- /* XXX should look up h/w protocol type based on linktype */
+ /* XXX should look up h/w protocol type based on cstate->linktype */
v = pcap_nametoeproto(name);
if (v == PROTO_UNDEF) {
v = pcap_nametollc(name);
if (v == PROTO_UNDEF)
- bpf_error("unknown ether proto '%s'", name);
+ bpf_error(cstate, "unknown ether proto '%s'", name);
}
break;
@@ -5446,7 +5635,7 @@ lookup_proto(name, proto)
else if (strcmp(name, "clnp") == 0)
v = ISO8473_CLNP;
else
- bpf_error("unknown osi proto '%s'", name);
+ bpf_error(cstate, "unknown osi proto '%s'", name);
break;
default:
@@ -5467,35 +5656,32 @@ gen_joinsp(s, n)
#endif
static struct block *
-gen_protochain(v, proto, dir)
- int v;
- int proto;
- int dir;
+gen_protochain(compiler_state_t *cstate, int v, int proto, int dir)
{
#ifdef NO_PROTOCHAIN
- return gen_proto(v, proto, dir);
+ return gen_proto(cstate, v, proto, dir);
#else
struct block *b0, *b;
struct slist *s[100];
int fix2, fix3, fix4, fix5;
int ahcheck, again, end;
int i, max;
- int reg2 = alloc_reg();
+ int reg2 = alloc_reg(cstate);
memset(s, 0, sizeof(s));
- fix2 = fix3 = fix4 = fix5 = 0;
+ fix3 = fix4 = fix5 = 0;
switch (proto) {
case Q_IP:
case Q_IPV6:
break;
case Q_DEFAULT:
- b0 = gen_protochain(v, Q_IP, dir);
- b = gen_protochain(v, Q_IPV6, dir);
+ b0 = gen_protochain(cstate, v, Q_IP, dir);
+ b = gen_protochain(cstate, v, Q_IPV6, dir);
gen_or(b0, b);
return b;
default:
- bpf_error("bad protocol applied for 'protochain'");
+ bpf_error(cstate, "bad protocol applied for 'protochain'");
/*NOTREACHED*/
}
@@ -5510,17 +5696,10 @@ gen_protochain(v, proto, dir)
* branches, and backward branch support is unlikely to appear
* in kernel BPF engines.)
*/
- switch (linktype) {
-
- case DLT_IEEE802_11:
- case DLT_PRISM_HEADER:
- case DLT_IEEE802_11_RADIO_AVS:
- case DLT_IEEE802_11_RADIO:
- case DLT_PPI:
- bpf_error("'protochain' not supported with 802.11");
- }
+ if (cstate->off_linkpl.is_variable)
+ bpf_error(cstate, "'protochain' not supported with variable length headers");
- no_optimize = 1; /*this code is not compatible with optimzer yet */
+ cstate->no_optimize = 1; /*this code is not compatible with optimzer yet */
/*
* s[0] is a dummy entry to protect other BPF insn from damage
@@ -5528,44 +5707,44 @@ gen_protochain(v, proto, dir)
* hard to find interdependency made by jump table fixup.
*/
i = 0;
- s[i] = new_stmt(0); /*dummy*/
+ s[i] = new_stmt(cstate, 0); /*dummy*/
i++;
switch (proto) {
case Q_IP:
- b0 = gen_linktype(ETHERTYPE_IP);
+ b0 = gen_linktype(cstate, ETHERTYPE_IP);
/* A = ip->ip_p */
- s[i] = new_stmt(BPF_LD|BPF_ABS|BPF_B);
- s[i]->s.k = off_macpl + off_nl + 9;
+ s[i] = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + 9;
i++;
/* X = ip->ip_hl << 2 */
- s[i] = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
- s[i]->s.k = off_macpl + off_nl;
+ s[i] = new_stmt(cstate, BPF_LDX|BPF_MSH|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
i++;
break;
case Q_IPV6:
- b0 = gen_linktype(ETHERTYPE_IPV6);
+ b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
/* A = ip6->ip_nxt */
- s[i] = new_stmt(BPF_LD|BPF_ABS|BPF_B);
- s[i]->s.k = off_macpl + off_nl + 6;
+ s[i] = new_stmt(cstate, BPF_LD|BPF_ABS|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + 6;
i++;
/* X = sizeof(struct ip6_hdr) */
- s[i] = new_stmt(BPF_LDX|BPF_IMM);
+ s[i] = new_stmt(cstate, BPF_LDX|BPF_IMM);
s[i]->s.k = 40;
i++;
break;
default:
- bpf_error("unsupported proto to gen_protochain");
+ bpf_error(cstate, "unsupported proto to gen_protochain");
/*NOTREACHED*/
}
/* again: if (A == v) goto end; else fall through; */
again = i;
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.k = v;
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*update in next stmt*/
@@ -5576,7 +5755,7 @@ gen_protochain(v, proto, dir)
#define IPPROTO_NONE 59
#endif
/* if (A == IPPROTO_NONE) goto end */
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*update in next stmt*/
s[i]->s.k = IPPROTO_NONE;
@@ -5589,26 +5768,26 @@ gen_protochain(v, proto, dir)
v6start = i;
/* if (A == IPPROTO_HOPOPTS) goto v6advance */
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*update in next stmt*/
s[i]->s.k = IPPROTO_HOPOPTS;
s[fix2]->s.jf = s[i];
i++;
/* if (A == IPPROTO_DSTOPTS) goto v6advance */
- s[i - 1]->s.jf = s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i - 1]->s.jf = s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*update in next stmt*/
s[i]->s.k = IPPROTO_DSTOPTS;
i++;
/* if (A == IPPROTO_ROUTING) goto v6advance */
- s[i - 1]->s.jf = s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i - 1]->s.jf = s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*update in next stmt*/
s[i]->s.k = IPPROTO_ROUTING;
i++;
/* if (A == IPPROTO_FRAGMENT) goto v6advance; else goto ahcheck; */
- s[i - 1]->s.jf = s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i - 1]->s.jf = s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*later*/
s[i]->s.k = IPPROTO_FRAGMENT;
@@ -5625,39 +5804,39 @@ gen_protochain(v, proto, dir)
* X = X + (P[X + packet head + 1] + 1) * 8;
*/
/* A = P[X + packet head] */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_macpl + off_nl;
+ s[i] = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
i++;
/* MEM[reg2] = A */
- s[i] = new_stmt(BPF_ST);
+ s[i] = new_stmt(cstate, BPF_ST);
s[i]->s.k = reg2;
i++;
/* A = P[X + packet head + 1]; */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_macpl + off_nl + 1;
+ s[i] = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + 1;
i++;
/* A += 1 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s[i]->s.k = 1;
i++;
/* A *= 8 */
- s[i] = new_stmt(BPF_ALU|BPF_MUL|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_MUL|BPF_K);
s[i]->s.k = 8;
i++;
/* A += X */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_X);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_X);
s[i]->s.k = 0;
i++;
/* X = A; */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
+ s[i] = new_stmt(cstate, BPF_MISC|BPF_TAX);
i++;
/* A = MEM[reg2] */
- s[i] = new_stmt(BPF_LD|BPF_MEM);
+ s[i] = new_stmt(cstate, BPF_LD|BPF_MEM);
s[i]->s.k = reg2;
i++;
/* goto again; (must use BPF_JA for backward jump) */
- s[i] = new_stmt(BPF_JMP|BPF_JA);
+ s[i] = new_stmt(cstate, BPF_JMP|BPF_JA);
s[i]->s.k = again - i - 1;
s[i - 1]->s.jf = s[i];
i++;
@@ -5667,7 +5846,7 @@ gen_protochain(v, proto, dir)
s[j]->s.jt = s[v6advance];
} else {
/* nop */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s[i]->s.k = 0;
s[fix2]->s.jf = s[i];
i++;
@@ -5676,7 +5855,7 @@ gen_protochain(v, proto, dir)
/* ahcheck: */
ahcheck = i;
/* if (A == IPPROTO_AH) then fall through; else goto end; */
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
+ s[i] = new_stmt(cstate, BPF_JMP|BPF_JEQ|BPF_K);
s[i]->s.jt = NULL; /*later*/
s[i]->s.jf = NULL; /*later*/
s[i]->s.k = IPPROTO_AH;
@@ -5691,54 +5870,54 @@ gen_protochain(v, proto, dir)
* X = X + (P[X + 1] + 2) * 4;
*/
/* A = X */
- s[i - 1]->s.jt = s[i] = new_stmt(BPF_MISC|BPF_TXA);
+ s[i - 1]->s.jt = s[i] = new_stmt(cstate, BPF_MISC|BPF_TXA);
i++;
/* A = P[X + packet head]; */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_macpl + off_nl;
+ s[i] = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
i++;
/* MEM[reg2] = A */
- s[i] = new_stmt(BPF_ST);
+ s[i] = new_stmt(cstate, BPF_ST);
s[i]->s.k = reg2;
i++;
/* A = X */
- s[i - 1]->s.jt = s[i] = new_stmt(BPF_MISC|BPF_TXA);
+ s[i - 1]->s.jt = s[i] = new_stmt(cstate, BPF_MISC|BPF_TXA);
i++;
/* A += 1 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s[i]->s.k = 1;
i++;
/* X = A */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
+ s[i] = new_stmt(cstate, BPF_MISC|BPF_TAX);
i++;
/* A = P[X + packet head] */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_macpl + off_nl;
+ s[i] = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s[i]->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
i++;
/* A += 2 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s[i]->s.k = 2;
i++;
/* A *= 4 */
- s[i] = new_stmt(BPF_ALU|BPF_MUL|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_MUL|BPF_K);
s[i]->s.k = 4;
i++;
/* X = A; */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
+ s[i] = new_stmt(cstate, BPF_MISC|BPF_TAX);
i++;
/* A = MEM[reg2] */
- s[i] = new_stmt(BPF_LD|BPF_MEM);
+ s[i] = new_stmt(cstate, BPF_LD|BPF_MEM);
s[i]->s.k = reg2;
i++;
/* goto again; (must use BPF_JA for backward jump) */
- s[i] = new_stmt(BPF_JMP|BPF_JA);
+ s[i] = new_stmt(cstate, BPF_JMP|BPF_JA);
s[i]->s.k = again - i - 1;
i++;
/* end: nop */
end = i;
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
+ s[i] = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
s[i]->s.k = 0;
s[fix2]->s.jt = s[end];
s[fix4]->s.jf = s[end];
@@ -5756,11 +5935,11 @@ gen_protochain(v, proto, dir)
/*
* emit final check
*/
- b = new_block(JMP(BPF_JEQ));
+ b = new_block(cstate, JMP(BPF_JEQ));
b->stmts = s[1]; /*remember, s[0] is dummy*/
b->s.k = v;
- free_reg(reg2);
+ free_reg(cstate, reg2);
gen_and(b0, b);
return b;
@@ -5768,7 +5947,7 @@ gen_protochain(v, proto, dir)
}
static struct block *
-gen_check_802_11_data_frame()
+gen_check_802_11_data_frame(compiler_state_t *cstate)
{
struct slist *s;
struct block *b0, *b1;
@@ -5777,13 +5956,13 @@ gen_check_802_11_data_frame()
* A data frame has the 0x08 bit (b3) in the frame control field set
* and the 0x04 bit (b2) clear.
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b0 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b0 = new_block(cstate, JMP(BPF_JSET));
b0->s.k = 0x08;
b0->stmts = s;
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x04;
b1->stmts = s;
gen_not(b1);
@@ -5803,10 +5982,7 @@ gen_check_802_11_data_frame()
* against Q_IP and Q_IPV6.
*/
static struct block *
-gen_proto(v, proto, dir)
- int v;
- int proto;
- int dir;
+gen_proto(compiler_state_t *cstate, int v, int proto, int dir)
{
struct block *b0, *b1;
#ifndef CHASE_CHAIN
@@ -5814,12 +5990,12 @@ gen_proto(v, proto, dir)
#endif
if (dir != Q_DEFAULT)
- bpf_error("direction applied to 'proto'");
+ bpf_error(cstate, "direction applied to 'proto'");
switch (proto) {
case Q_DEFAULT:
- b0 = gen_proto(v, Q_IP, dir);
- b1 = gen_proto(v, Q_IPV6, dir);
+ b0 = gen_proto(cstate, v, Q_IP, dir);
+ b1 = gen_proto(cstate, v, Q_IPV6, dir);
gen_or(b0, b1);
return b1;
@@ -5839,22 +6015,22 @@ gen_proto(v, proto, dir)
*
* So we always check for ETHERTYPE_IP.
*/
- b0 = gen_linktype(ETHERTYPE_IP);
+ b0 = gen_linktype(cstate, ETHERTYPE_IP);
#ifndef CHASE_CHAIN
- b1 = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)v);
+ b1 = gen_cmp(cstate, OR_LINKPL, 9, BPF_B, (bpf_int32)v);
#else
- b1 = gen_protochain(v, Q_IP);
+ b1 = gen_protochain(cstate, v, Q_IP);
#endif
gen_and(b0, b1);
return b1;
case Q_ISO:
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_FRELAY:
/*
* Frame Relay packets typically have an OSI
- * NLPID at the beginning; "gen_linktype(LLCSAP_ISONS)"
+ * NLPID at the beginning; "gen_linktype(cstate, LLCSAP_ISONS)"
* generates code to check for all the OSI
* NLPIDs, so calling it and then adding a check
* for the particular NLPID for which we're
@@ -5870,7 +6046,7 @@ gen_proto(v, proto, dir)
*
* XXX - what about SNAP-encapsulated frames?
*/
- return gen_cmp(OR_LINK, 2, BPF_H, (0x03<<8) | v);
+ return gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | v);
/*NOTREACHED*/
break;
@@ -5879,138 +6055,138 @@ gen_proto(v, proto, dir)
* Cisco uses an Ethertype lookalike - for OSI,
* it's 0xfefe.
*/
- b0 = gen_linktype(LLCSAP_ISONS<<8 | LLCSAP_ISONS);
+ b0 = gen_linktype(cstate, LLCSAP_ISONS<<8 | LLCSAP_ISONS);
/* OSI in C-HDLC is stuffed with a fudge byte */
- b1 = gen_cmp(OR_NET_NOSNAP, 1, BPF_B, (long)v);
+ b1 = gen_cmp(cstate, OR_LINKPL_NOSNAP, 1, BPF_B, (long)v);
gen_and(b0, b1);
return b1;
default:
- b0 = gen_linktype(LLCSAP_ISONS);
- b1 = gen_cmp(OR_NET_NOSNAP, 0, BPF_B, (long)v);
+ b0 = gen_linktype(cstate, LLCSAP_ISONS);
+ b1 = gen_cmp(cstate, OR_LINKPL_NOSNAP, 0, BPF_B, (long)v);
gen_and(b0, b1);
return b1;
}
case Q_ISIS:
- b0 = gen_proto(ISO10589_ISIS, Q_ISO, Q_DEFAULT);
+ b0 = gen_proto(cstate, ISO10589_ISIS, Q_ISO, Q_DEFAULT);
/*
* 4 is the offset of the PDU type relative to the IS-IS
* header.
*/
- b1 = gen_cmp(OR_NET_NOSNAP, 4, BPF_B, (long)v);
+ b1 = gen_cmp(cstate, OR_LINKPL_NOSNAP, 4, BPF_B, (long)v);
gen_and(b0, b1);
return b1;
case Q_ARP:
- bpf_error("arp does not encapsulate another protocol");
+ bpf_error(cstate, "arp does not encapsulate another protocol");
/* NOTREACHED */
case Q_RARP:
- bpf_error("rarp does not encapsulate another protocol");
+ bpf_error(cstate, "rarp does not encapsulate another protocol");
/* NOTREACHED */
case Q_ATALK:
- bpf_error("atalk encapsulation is not specifiable");
+ bpf_error(cstate, "atalk encapsulation is not specifiable");
/* NOTREACHED */
case Q_DECNET:
- bpf_error("decnet encapsulation is not specifiable");
+ bpf_error(cstate, "decnet encapsulation is not specifiable");
/* NOTREACHED */
case Q_SCA:
- bpf_error("sca does not encapsulate another protocol");
+ bpf_error(cstate, "sca does not encapsulate another protocol");
/* NOTREACHED */
case Q_LAT:
- bpf_error("lat does not encapsulate another protocol");
+ bpf_error(cstate, "lat does not encapsulate another protocol");
/* NOTREACHED */
case Q_MOPRC:
- bpf_error("moprc does not encapsulate another protocol");
+ bpf_error(cstate, "moprc does not encapsulate another protocol");
/* NOTREACHED */
case Q_MOPDL:
- bpf_error("mopdl does not encapsulate another protocol");
+ bpf_error(cstate, "mopdl does not encapsulate another protocol");
/* NOTREACHED */
case Q_LINK:
- return gen_linktype(v);
+ return gen_linktype(cstate, v);
case Q_UDP:
- bpf_error("'udp proto' is bogus");
+ bpf_error(cstate, "'udp proto' is bogus");
/* NOTREACHED */
case Q_TCP:
- bpf_error("'tcp proto' is bogus");
+ bpf_error(cstate, "'tcp proto' is bogus");
/* NOTREACHED */
case Q_SCTP:
- bpf_error("'sctp proto' is bogus");
+ bpf_error(cstate, "'sctp proto' is bogus");
/* NOTREACHED */
case Q_ICMP:
- bpf_error("'icmp proto' is bogus");
+ bpf_error(cstate, "'icmp proto' is bogus");
/* NOTREACHED */
case Q_IGMP:
- bpf_error("'igmp proto' is bogus");
+ bpf_error(cstate, "'igmp proto' is bogus");
/* NOTREACHED */
case Q_IGRP:
- bpf_error("'igrp proto' is bogus");
+ bpf_error(cstate, "'igrp proto' is bogus");
/* NOTREACHED */
case Q_PIM:
- bpf_error("'pim proto' is bogus");
+ bpf_error(cstate, "'pim proto' is bogus");
/* NOTREACHED */
case Q_VRRP:
- bpf_error("'vrrp proto' is bogus");
+ bpf_error(cstate, "'vrrp proto' is bogus");
/* NOTREACHED */
case Q_CARP:
- bpf_error("'carp proto' is bogus");
+ bpf_error(cstate, "'carp proto' is bogus");
/* NOTREACHED */
case Q_IPV6:
- b0 = gen_linktype(ETHERTYPE_IPV6);
+ b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
#ifndef CHASE_CHAIN
/*
* Also check for a fragment header before the final
* header.
*/
- b2 = gen_cmp(OR_NET, 6, BPF_B, IPPROTO_FRAGMENT);
- b1 = gen_cmp(OR_NET, 40, BPF_B, (bpf_int32)v);
+ b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, IPPROTO_FRAGMENT);
+ b1 = gen_cmp(cstate, OR_LINKPL, 40, BPF_B, (bpf_int32)v);
gen_and(b2, b1);
- b2 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)v);
+ b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, (bpf_int32)v);
gen_or(b2, b1);
#else
- b1 = gen_protochain(v, Q_IPV6);
+ b1 = gen_protochain(cstate, v, Q_IPV6);
#endif
gen_and(b0, b1);
return b1;
case Q_ICMPV6:
- bpf_error("'icmp6 proto' is bogus");
+ bpf_error(cstate, "'icmp6 proto' is bogus");
case Q_AH:
- bpf_error("'ah proto' is bogus");
+ bpf_error(cstate, "'ah proto' is bogus");
case Q_ESP:
- bpf_error("'ah proto' is bogus");
+ bpf_error(cstate, "'ah proto' is bogus");
case Q_STP:
- bpf_error("'stp proto' is bogus");
+ bpf_error(cstate, "'stp proto' is bogus");
case Q_IPX:
- bpf_error("'ipx proto' is bogus");
+ bpf_error(cstate, "'ipx proto' is bogus");
case Q_NETBEUI:
- bpf_error("'netbeui proto' is bogus");
+ bpf_error(cstate, "'netbeui proto' is bogus");
case Q_RADIO:
- bpf_error("'radio proto' is bogus");
+ bpf_error(cstate, "'radio proto' is bogus");
default:
abort();
@@ -6020,9 +6196,7 @@ gen_proto(v, proto, dir)
}
struct block *
-gen_scode(name, q)
- register const char *name;
- struct qual q;
+gen_scode(compiler_state_t *cstate, const char *name, struct qual q)
{
int proto = q.proto;
int dir = q.dir;
@@ -6047,46 +6221,49 @@ gen_scode(name, q)
case Q_NET:
addr = pcap_nametonetaddr(name);
if (addr == 0)
- bpf_error("unknown network '%s'", name);
+ bpf_error(cstate, "unknown network '%s'", name);
/* Left justify network addr and calculate its network mask */
mask = 0xffffffff;
while (addr && (addr & 0xff000000) == 0) {
addr <<= 8;
mask <<= 8;
}
- return gen_host(addr, mask, proto, dir, q.addr);
+ return gen_host(cstate, addr, mask, proto, dir, q.addr);
case Q_DEFAULT:
case Q_HOST:
if (proto == Q_LINK) {
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
- bpf_error(
+ bpf_error(cstate,
"unknown ether host '%s'", name);
- b = gen_ehostop(eaddr, dir);
+ tmp = gen_prevlinkhdr_check(cstate);
+ b = gen_ehostop(cstate, eaddr, dir);
+ if (tmp != NULL)
+ gen_and(tmp, b);
free(eaddr);
return b;
case DLT_FDDI:
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
- bpf_error(
+ bpf_error(cstate,
"unknown FDDI host '%s'", name);
- b = gen_fhostop(eaddr, dir);
+ b = gen_fhostop(cstate, eaddr, dir);
free(eaddr);
return b;
case DLT_IEEE802:
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
- bpf_error(
+ bpf_error(cstate,
"unknown token ring host '%s'", name);
- b = gen_thostop(eaddr, dir);
+ b = gen_thostop(cstate, eaddr, dir);
free(eaddr);
return b;
@@ -6097,63 +6274,51 @@ gen_scode(name, q)
case DLT_PPI:
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
- bpf_error(
+ bpf_error(cstate,
"unknown 802.11 host '%s'", name);
- b = gen_wlanhostop(eaddr, dir);
+ b = gen_wlanhostop(cstate, eaddr, dir);
free(eaddr);
return b;
case DLT_IP_OVER_FC:
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
- bpf_error(
+ bpf_error(cstate,
"unknown Fibre Channel host '%s'", name);
- b = gen_ipfchostop(eaddr, dir);
- free(eaddr);
- return b;
-
- case DLT_SUNATM:
- if (!is_lane)
- break;
-
- /*
- * Check that the packet doesn't begin
- * with an LE Control marker. (We've
- * already generated a test for LANE.)
- */
- tmp = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS,
- BPF_H, 0xFF00);
- gen_not(tmp);
-
- eaddr = pcap_ether_hostton(name);
- if (eaddr == NULL)
- bpf_error(
- "unknown ether host '%s'", name);
- b = gen_ehostop(eaddr, dir);
- gen_and(tmp, b);
+ b = gen_ipfchostop(cstate, eaddr, dir);
free(eaddr);
return b;
}
- bpf_error("only ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel supports link-level host name");
+ bpf_error(cstate, "only ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel supports link-level host name");
} else if (proto == Q_DECNET) {
- unsigned short dn_addr = __pcap_nametodnaddr(name);
+ unsigned short dn_addr;
+
+ if (!__pcap_nametodnaddr(name, &dn_addr)) {
+#ifdef DECNETLIB
+ bpf_error(cstate, "unknown decnet host name '%s'\n", name);
+#else
+ bpf_error(cstate, "decnet name support not included, '%s' cannot be translated\n",
+ name);
+#endif
+ }
/*
* I don't think DECNET hosts can be multihomed, so
* there is no need to build up a list of addresses
*/
- return (gen_host(dn_addr, 0, proto, dir, q.addr));
+ 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("unknown host '%s'", name);
+ bpf_error(cstate, "unknown host '%s'", name);
tproto = proto;
- if (off_linktype == (u_int)-1 && tproto == Q_DEFAULT)
+ if (cstate->off_linktype.constant_part == OFFSET_NOT_SET &&
+ tproto == Q_DEFAULT)
tproto = Q_IP;
- b = gen_host(**alist++, 0xffffffff, tproto, dir, q.addr);
+ b = gen_host(cstate, **alist++, 0xffffffff, tproto, dir, q.addr);
while (*alist) {
- tmp = gen_host(**alist++, 0xffffffff,
+ tmp = gen_host(cstate, **alist++, 0xffffffff,
tproto, dir, q.addr);
gen_or(b, tmp);
b = tmp;
@@ -6163,11 +6328,12 @@ gen_scode(name, q)
memset(&mask128, 0xff, sizeof(mask128));
res0 = res = pcap_nametoaddrinfo(name);
if (res == NULL)
- bpf_error("unknown host '%s'", name);
- ai = res;
+ bpf_error(cstate, "unknown host '%s'", name);
+ cstate->ai = res;
b = tmp = NULL;
tproto = tproto6 = proto;
- if (off_linktype == -1 && tproto == Q_DEFAULT) {
+ if (cstate->off_linktype.constant_part == OFFSET_NOT_SET &&
+ tproto == Q_DEFAULT) {
tproto = Q_IP;
tproto6 = Q_IPV6;
}
@@ -6179,7 +6345,7 @@ gen_scode(name, q)
sin4 = (struct sockaddr_in *)
res->ai_addr;
- tmp = gen_host(ntohl(sin4->sin_addr.s_addr),
+ tmp = gen_host(cstate, ntohl(sin4->sin_addr.s_addr),
0xffffffff, tproto, dir, q.addr);
break;
case AF_INET6:
@@ -6188,7 +6354,7 @@ gen_scode(name, q)
sin6 = (struct sockaddr_in6 *)
res->ai_addr;
- tmp = gen_host6(&sin6->sin6_addr,
+ tmp = gen_host6(cstate, &sin6->sin6_addr,
&mask128, tproto6, dir, q.addr);
break;
default:
@@ -6198,10 +6364,10 @@ gen_scode(name, q)
gen_or(b, tmp);
b = tmp;
}
- ai = NULL;
+ cstate->ai = NULL;
freeaddrinfo(res0);
if (b == NULL) {
- bpf_error("unknown host '%s'%s", name,
+ bpf_error(cstate, "unknown host '%s'%s", name,
(proto == Q_DEFAULT)
? ""
: " for specified address family");
@@ -6213,124 +6379,124 @@ gen_scode(name, q)
case Q_PORT:
if (proto != Q_DEFAULT &&
proto != Q_UDP && proto != Q_TCP && proto != Q_SCTP)
- bpf_error("illegal qualifier of 'port'");
+ bpf_error(cstate, "illegal qualifier of 'port'");
if (pcap_nametoport(name, &port, &real_proto) == 0)
- bpf_error("unknown port '%s'", name);
+ bpf_error(cstate, "unknown port '%s'", name);
if (proto == Q_UDP) {
if (real_proto == IPPROTO_TCP)
- bpf_error("port '%s' is tcp", name);
+ bpf_error(cstate, "port '%s' is tcp", name);
else if (real_proto == IPPROTO_SCTP)
- bpf_error("port '%s' is sctp", name);
+ bpf_error(cstate, "port '%s' is sctp", name);
else
/* override PROTO_UNDEF */
real_proto = IPPROTO_UDP;
}
if (proto == Q_TCP) {
if (real_proto == IPPROTO_UDP)
- bpf_error("port '%s' is udp", name);
+ bpf_error(cstate, "port '%s' is udp", name);
else if (real_proto == IPPROTO_SCTP)
- bpf_error("port '%s' is sctp", name);
+ bpf_error(cstate, "port '%s' is sctp", name);
else
/* override PROTO_UNDEF */
real_proto = IPPROTO_TCP;
}
if (proto == Q_SCTP) {
if (real_proto == IPPROTO_UDP)
- bpf_error("port '%s' is udp", name);
+ bpf_error(cstate, "port '%s' is udp", name);
else if (real_proto == IPPROTO_TCP)
- bpf_error("port '%s' is tcp", name);
+ bpf_error(cstate, "port '%s' is tcp", name);
else
/* override PROTO_UNDEF */
real_proto = IPPROTO_SCTP;
}
if (port < 0)
- bpf_error("illegal port number %d < 0", port);
+ bpf_error(cstate, "illegal port number %d < 0", port);
if (port > 65535)
- bpf_error("illegal port number %d > 65535", port);
- b = gen_port(port, real_proto, dir);
- gen_or(gen_port6(port, real_proto, dir), b);
+ bpf_error(cstate, "illegal port number %d > 65535", port);
+ b = gen_port(cstate, port, real_proto, dir);
+ gen_or(gen_port6(cstate, port, real_proto, dir), b);
return b;
case Q_PORTRANGE:
if (proto != Q_DEFAULT &&
proto != Q_UDP && proto != Q_TCP && proto != Q_SCTP)
- bpf_error("illegal qualifier of 'portrange'");
+ bpf_error(cstate, "illegal qualifier of 'portrange'");
if (pcap_nametoportrange(name, &port1, &port2, &real_proto) == 0)
- bpf_error("unknown port in range '%s'", name);
+ bpf_error(cstate, "unknown port in range '%s'", name);
if (proto == Q_UDP) {
if (real_proto == IPPROTO_TCP)
- bpf_error("port in range '%s' is tcp", name);
+ bpf_error(cstate, "port in range '%s' is tcp", name);
else if (real_proto == IPPROTO_SCTP)
- bpf_error("port in range '%s' is sctp", name);
+ bpf_error(cstate, "port in range '%s' is sctp", name);
else
/* override PROTO_UNDEF */
real_proto = IPPROTO_UDP;
}
if (proto == Q_TCP) {
if (real_proto == IPPROTO_UDP)
- bpf_error("port in range '%s' is udp", name);
+ bpf_error(cstate, "port in range '%s' is udp", name);
else if (real_proto == IPPROTO_SCTP)
- bpf_error("port in range '%s' is sctp", name);
+ bpf_error(cstate, "port in range '%s' is sctp", name);
else
/* override PROTO_UNDEF */
real_proto = IPPROTO_TCP;
}
if (proto == Q_SCTP) {
if (real_proto == IPPROTO_UDP)
- bpf_error("port in range '%s' is udp", name);
+ bpf_error(cstate, "port in range '%s' is udp", name);
else if (real_proto == IPPROTO_TCP)
- bpf_error("port in range '%s' is tcp", name);
+ bpf_error(cstate, "port in range '%s' is tcp", name);
else
/* override PROTO_UNDEF */
real_proto = IPPROTO_SCTP;
}
if (port1 < 0)
- bpf_error("illegal port number %d < 0", port1);
+ bpf_error(cstate, "illegal port number %d < 0", port1);
if (port1 > 65535)
- bpf_error("illegal port number %d > 65535", port1);
+ bpf_error(cstate, "illegal port number %d > 65535", port1);
if (port2 < 0)
- bpf_error("illegal port number %d < 0", port2);
+ bpf_error(cstate, "illegal port number %d < 0", port2);
if (port2 > 65535)
- bpf_error("illegal port number %d > 65535", port2);
+ bpf_error(cstate, "illegal port number %d > 65535", port2);
- b = gen_portrange(port1, port2, real_proto, dir);
- gen_or(gen_portrange6(port1, port2, real_proto, dir), b);
+ b = gen_portrange(cstate, port1, port2, real_proto, dir);
+ gen_or(gen_portrange6(cstate, port1, port2, real_proto, dir), b);
return b;
case Q_GATEWAY:
#ifndef INET6
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
- bpf_error("unknown ether host: %s", name);
+ bpf_error(cstate, "unknown ether host: %s", name);
alist = pcap_nametoaddr(name);
if (alist == NULL || *alist == NULL)
- bpf_error("unknown host '%s'", name);
- b = gen_gateway(eaddr, alist, proto, dir);
+ bpf_error(cstate, "unknown host '%s'", name);
+ b = gen_gateway(cstate, eaddr, alist, proto, dir);
free(eaddr);
return b;
#else
- bpf_error("'gateway' not supported in this configuration");
+ bpf_error(cstate, "'gateway' not supported in this configuration");
#endif /*INET6*/
case Q_PROTO:
- real_proto = lookup_proto(name, proto);
+ real_proto = lookup_proto(cstate, name, proto);
if (real_proto >= 0)
- return gen_proto(real_proto, proto, dir);
+ return gen_proto(cstate, real_proto, proto, dir);
else
- bpf_error("unknown protocol: %s", name);
+ bpf_error(cstate, "unknown protocol: %s", name);
case Q_PROTOCHAIN:
- real_proto = lookup_proto(name, proto);
+ real_proto = lookup_proto(cstate, name, proto);
if (real_proto >= 0)
- return gen_protochain(real_proto, proto, dir);
+ return gen_protochain(cstate, real_proto, proto, dir);
else
- bpf_error("unknown protocol: %s", name);
+ bpf_error(cstate, "unknown protocol: %s", name);
case Q_UNDEF:
- syntax();
+ syntax(cstate);
/* NOTREACHED */
}
abort();
@@ -6338,10 +6504,8 @@ gen_scode(name, q)
}
struct block *
-gen_mcode(s1, s2, masklen, q)
- register const char *s1, *s2;
- register int masklen;
- struct qual q;
+gen_mcode(compiler_state_t *cstate, const char *s1, const char *s2,
+ unsigned int masklen, struct qual q)
{
register int nlen, mlen;
bpf_u_int32 n, m;
@@ -6355,12 +6519,12 @@ gen_mcode(s1, s2, masklen, q)
/* Promote short ipaddr */
m <<= 32 - mlen;
if ((n & ~m) != 0)
- bpf_error("non-network bits set in \"%s mask %s\"",
+ bpf_error(cstate, "non-network bits set in \"%s mask %s\"",
s1, s2);
} else {
/* Convert mask len to mask */
if (masklen > 32)
- bpf_error("mask length must be <= 32");
+ bpf_error(cstate, "mask length must be <= 32");
if (masklen == 0) {
/*
* X << 32 is not guaranteed by C to be 0; it's
@@ -6370,17 +6534,17 @@ gen_mcode(s1, s2, masklen, q)
} else
m = 0xffffffff << (32 - masklen);
if ((n & ~m) != 0)
- bpf_error("non-network bits set in \"%s/%d\"",
+ bpf_error(cstate, "non-network bits set in \"%s/%d\"",
s1, masklen);
}
switch (q.addr) {
case Q_NET:
- return gen_host(n, m, q.proto, q.dir, q.addr);
+ return gen_host(cstate, n, m, q.proto, q.dir, q.addr);
default:
- bpf_error("Mask syntax for networks only");
+ bpf_error(cstate, "Mask syntax for networks only");
/* NOTREACHED */
}
/* NOTREACHED */
@@ -6388,10 +6552,7 @@ gen_mcode(s1, s2, masklen, q)
}
struct block *
-gen_ncode(s, v, q)
- register const char *s;
- bpf_u_int32 v;
- struct qual q;
+gen_ncode(compiler_state_t *cstate, const char *s, bpf_u_int32 v, struct qual q)
{
bpf_u_int32 mask;
int proto = q.proto;
@@ -6400,9 +6561,11 @@ gen_ncode(s, v, q)
if (s == NULL)
vlen = 32;
- else if (q.proto == Q_DECNET)
+ else if (q.proto == Q_DECNET) {
vlen = __pcap_atodn(s, &v);
- else
+ if (vlen == 0)
+ bpf_error(cstate, "malformed decnet address '%s'", s);
+ } else
vlen = __pcap_atoin(s, &v);
switch (q.addr) {
@@ -6411,9 +6574,9 @@ gen_ncode(s, v, q)
case Q_HOST:
case Q_NET:
if (proto == Q_DECNET)
- return gen_host(v, 0, proto, dir, q.addr);
+ return gen_host(cstate, v, 0, proto, dir, q.addr);
else if (proto == Q_LINK) {
- bpf_error("illegal link layer address");
+ bpf_error(cstate, "illegal link layer address");
} else {
mask = 0xffffffff;
if (s == NULL && q.addr == Q_NET) {
@@ -6425,9 +6588,9 @@ gen_ncode(s, v, q)
} else {
/* Promote short ipaddr */
v <<= 32 - vlen;
- mask <<= 32 - vlen;
+ mask <<= 32 - vlen ;
}
- return gen_host(v, mask, proto, dir, q.addr);
+ return gen_host(cstate, v, mask, proto, dir, q.addr);
}
case Q_PORT:
@@ -6440,15 +6603,15 @@ gen_ncode(s, v, q)
else if (proto == Q_DEFAULT)
proto = PROTO_UNDEF;
else
- bpf_error("illegal qualifier of 'port'");
+ bpf_error(cstate, "illegal qualifier of 'port'");
if (v > 65535)
- bpf_error("illegal port number %u > 65535", v);
+ bpf_error(cstate, "illegal port number %u > 65535", v);
{
struct block *b;
- b = gen_port((int)v, proto, dir);
- gen_or(gen_port6((int)v, proto, dir), b);
+ b = gen_port(cstate, (int)v, proto, dir);
+ gen_or(gen_port6(cstate, (int)v, proto, dir), b);
return b;
}
@@ -6462,30 +6625,30 @@ gen_ncode(s, v, q)
else if (proto == Q_DEFAULT)
proto = PROTO_UNDEF;
else
- bpf_error("illegal qualifier of 'portrange'");
+ bpf_error(cstate, "illegal qualifier of 'portrange'");
if (v > 65535)
- bpf_error("illegal port number %u > 65535", v);
+ bpf_error(cstate, "illegal port number %u > 65535", v);
{
struct block *b;
- b = gen_portrange((int)v, (int)v, proto, dir);
- gen_or(gen_portrange6((int)v, (int)v, proto, dir), b);
+ b = gen_portrange(cstate, (int)v, (int)v, proto, dir);
+ gen_or(gen_portrange6(cstate, (int)v, (int)v, proto, dir), b);
return b;
}
case Q_GATEWAY:
- bpf_error("'gateway' requires a name");
+ bpf_error(cstate, "'gateway' requires a name");
/* NOTREACHED */
case Q_PROTO:
- return gen_proto((int)v, proto, dir);
+ return gen_proto(cstate, (int)v, proto, dir);
case Q_PROTOCHAIN:
- return gen_protochain((int)v, proto, dir);
+ return gen_protochain(cstate, (int)v, proto, dir);
case Q_UNDEF:
- syntax();
+ syntax(cstate);
/* NOTREACHED */
default:
@@ -6497,10 +6660,8 @@ gen_ncode(s, v, q)
#ifdef INET6
struct block *
-gen_mcode6(s1, s2, masklen, q)
- register const char *s1, *s2;
- register int masklen;
- struct qual q;
+gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2,
+ unsigned int masklen, struct qual q)
{
struct addrinfo *res;
struct in6_addr *addr;
@@ -6509,18 +6670,18 @@ gen_mcode6(s1, s2, masklen, q)
u_int32_t *a, *m;
if (s2)
- bpf_error("no mask %s supported", s2);
+ bpf_error(cstate, "no mask %s supported", s2);
res = pcap_nametoaddrinfo(s1);
if (!res)
- bpf_error("invalid ip6 address %s", s1);
- ai = res;
+ bpf_error(cstate, "invalid ip6 address %s", s1);
+ cstate->ai = res;
if (res->ai_next)
- bpf_error("%s resolved to multiple address", s1);
+ bpf_error(cstate, "%s resolved to multiple address", s1);
addr = &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
if (sizeof(mask) * 8 < masklen)
- bpf_error("mask length must be <= %u", (unsigned int)(sizeof(mask) * 8));
+ bpf_error(cstate, "mask length must be <= %u", (unsigned int)(sizeof(mask) * 8));
memset(&mask, 0, sizeof(mask));
memset(&mask, 0xff, masklen / 8);
if (masklen % 8) {
@@ -6532,7 +6693,7 @@ gen_mcode6(s1, s2, masklen, q)
m = (u_int32_t *)&mask;
if ((a[0] & ~m[0]) || (a[1] & ~m[1])
|| (a[2] & ~m[2]) || (a[3] & ~m[3])) {
- bpf_error("non-network bits set in \"%s/%d\"", s1, masklen);
+ bpf_error(cstate, "non-network bits set in \"%s/%d\"", s1, masklen);
}
switch (q.addr) {
@@ -6540,17 +6701,17 @@ gen_mcode6(s1, s2, masklen, q)
case Q_DEFAULT:
case Q_HOST:
if (masklen != 128)
- bpf_error("Mask syntax for networks only");
+ bpf_error(cstate, "Mask syntax for networks only");
/* FALLTHROUGH */
case Q_NET:
- b = gen_host6(addr, &mask, q.proto, q.dir, q.addr);
- ai = NULL;
+ b = gen_host6(cstate, addr, &mask, q.proto, q.dir, q.addr);
+ cstate->ai = NULL;
freeaddrinfo(res);
return b;
default:
- bpf_error("invalid qualifier against IPv6 address");
+ bpf_error(cstate, "invalid qualifier against IPv6 address");
/* NOTREACHED */
}
return NULL;
@@ -6558,55 +6719,38 @@ gen_mcode6(s1, s2, masklen, q)
#endif /*INET6*/
struct block *
-gen_ecode(eaddr, q)
- register const u_char *eaddr;
- struct qual q;
+gen_ecode(compiler_state_t *cstate, const u_char *eaddr, struct qual q)
{
struct block *b, *tmp;
if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- return gen_ehostop(eaddr, (int)q.dir);
+ tmp = gen_prevlinkhdr_check(cstate);
+ b = gen_ehostop(cstate, eaddr, (int)q.dir);
+ if (tmp != NULL)
+ gen_and(tmp, b);
+ return b;
case DLT_FDDI:
- return gen_fhostop(eaddr, (int)q.dir);
+ return gen_fhostop(cstate, eaddr, (int)q.dir);
case DLT_IEEE802:
- return gen_thostop(eaddr, (int)q.dir);
+ return gen_thostop(cstate, eaddr, (int)q.dir);
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
case DLT_PPI:
- return gen_wlanhostop(eaddr, (int)q.dir);
- case DLT_SUNATM:
- if (is_lane) {
- /*
- * Check that the packet doesn't begin with an
- * LE Control marker. (We've already generated
- * a test for LANE.)
- */
- tmp = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS, BPF_H,
- 0xFF00);
- gen_not(tmp);
-
- /*
- * Now check the MAC address.
- */
- b = gen_ehostop(eaddr, (int)q.dir);
- gen_and(tmp, b);
- return b;
- }
- break;
+ return gen_wlanhostop(cstate, eaddr, (int)q.dir);
case DLT_IP_OVER_FC:
- return gen_ipfchostop(eaddr, (int)q.dir);
+ return gen_ipfchostop(cstate, eaddr, (int)q.dir);
default:
- bpf_error("ethernet addresses supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
+ bpf_error(cstate, "ethernet addresses supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
break;
}
}
- bpf_error("ethernet address used in non-ether expression");
+ bpf_error(cstate, "ethernet address used in non-ether expression");
/* NOTREACHED */
return NULL;
}
@@ -6625,23 +6769,21 @@ sappend(s0, s1)
}
static struct slist *
-xfer_to_x(a)
- struct arth *a;
+xfer_to_x(compiler_state_t *cstate, struct arth *a)
{
struct slist *s;
- s = new_stmt(BPF_LDX|BPF_MEM);
+ s = new_stmt(cstate, BPF_LDX|BPF_MEM);
s->s.k = a->regno;
return s;
}
static struct slist *
-xfer_to_a(a)
- struct arth *a;
+xfer_to_a(compiler_state_t *cstate, struct arth *a)
{
struct slist *s;
- s = new_stmt(BPF_LD|BPF_MEM);
+ s = new_stmt(cstate, BPF_LD|BPF_MEM);
s->s.k = a->regno;
return s;
}
@@ -6654,20 +6796,17 @@ xfer_to_a(a)
* for "index".
*/
struct arth *
-gen_load(proto, inst, size)
- int proto;
- struct arth *inst;
- int size;
+gen_load(compiler_state_t *cstate, int proto, struct arth *inst, int size)
{
struct slist *s, *tmp;
struct block *b;
- int regno = alloc_reg();
+ int regno = alloc_reg(cstate);
- free_reg(inst->regno);
+ free_reg(cstate, inst->regno);
switch (size) {
default:
- bpf_error("data size must be 1, 2, or 4");
+ bpf_error(cstate, "data size must be 1, 2, or 4");
case 1:
size = BPF_B;
@@ -6683,7 +6822,7 @@ gen_load(proto, inst, size)
}
switch (proto) {
default:
- bpf_error("unsupported index operation");
+ bpf_error(cstate, "unsupported index operation");
case Q_RADIO:
/*
@@ -6691,21 +6830,21 @@ gen_load(proto, inst, size)
* data, if we have a radio header. (If we don't, this
* is an error.)
*/
- if (linktype != DLT_IEEE802_11_RADIO_AVS &&
- linktype != DLT_IEEE802_11_RADIO &&
- linktype != DLT_PRISM_HEADER)
- bpf_error("radio information not present in capture");
+ if (cstate->linktype != DLT_IEEE802_11_RADIO_AVS &&
+ cstate->linktype != DLT_IEEE802_11_RADIO &&
+ cstate->linktype != DLT_PRISM_HEADER)
+ bpf_error(cstate, "radio information not present in capture");
/*
* Load into the X register the offset computed into the
* register specified by "index".
*/
- s = xfer_to_x(inst);
+ s = xfer_to_x(cstate, inst);
/*
* Load the item at that offset.
*/
- tmp = new_stmt(BPF_LD|BPF_IND|size);
+ tmp = new_stmt(cstate, BPF_LD|BPF_IND|size);
sappend(s, tmp);
sappend(inst->s, s);
break;
@@ -6722,7 +6861,7 @@ gen_load(proto, inst, size)
* frame, so that 0 refers, for Ethernet LANE, to
* the beginning of the destination address?
*/
- s = gen_llprefixlen();
+ s = gen_abs_offset_varpart(cstate, &cstate->off_linkhdr);
/*
* If "s" is non-null, it has code to arrange that the
@@ -6734,11 +6873,11 @@ gen_load(proto, inst, size)
* by "index".
*/
if (s != NULL) {
- sappend(s, xfer_to_a(inst));
- sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X));
- sappend(s, new_stmt(BPF_MISC|BPF_TAX));
+ 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(inst);
+ s = xfer_to_x(cstate, inst);
/*
* Load the item at the sum of the offset we've put in the
@@ -6747,8 +6886,8 @@ gen_load(proto, inst, size)
* variable-length; that header length is what we put
* into the X register and then added to the index).
*/
- tmp = new_stmt(BPF_LD|BPF_IND|size);
- tmp->s.k = off_ll;
+ tmp = new_stmt(cstate, BPF_LD|BPF_IND|size);
+ tmp->s.k = cstate->off_linkhdr.constant_part;
sappend(s, tmp);
sappend(inst->s, s);
break;
@@ -6767,40 +6906,35 @@ gen_load(proto, inst, size)
* The offset is relative to the beginning of
* the network-layer header.
* XXX - are there any cases where we want
- * off_nl_nosnap?
+ * cstate->off_nl_nosnap?
*/
- s = gen_off_macpl();
+ 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 offset of the MAC-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".
+ * 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(inst));
- sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X));
- sappend(s, new_stmt(BPF_MISC|BPF_TAX));
+ 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(inst);
+ 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 MAC-layer
- * payload, and the purported offset of the start of the
- * MAC-layer payload (which might be 0 if there's a
- * variable-length prefix before the link-layer header
- * or the link-layer header itself is variable-length;
- * the variable-length offset of the start of the
- * MAC-layer payload is what we put into the X register
- * and then added to the index).
- */
- tmp = new_stmt(BPF_LD|BPF_IND|size);
- tmp->s.k = off_macpl + off_nl;
+ * 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;
sappend(s, tmp);
sappend(inst->s, s);
@@ -6808,7 +6942,7 @@ gen_load(proto, inst, size)
* Do the computation only if the packet contains
* the protocol in question.
*/
- b = gen_proto_abbrev(proto);
+ b = gen_proto_abbrev(cstate, proto);
if (inst->b)
gen_and(inst->b, b);
inst->b = b;
@@ -6832,34 +6966,32 @@ gen_load(proto, inst, size)
* a variable-length header), in bytes.
*
* XXX - are there any cases where we want
- * off_nl_nosnap?
+ * cstate->off_nl_nosnap?
* XXX - we should, if we're built with
* IPv6 support, generate code to load either
* IPv4, IPv6, or both, as appropriate.
*/
- s = gen_loadx_iphdrlen();
+ s = gen_loadx_iphdrlen(cstate);
/*
- * The X register now contains the sum of the length
- * of any variable-length header preceding the link-layer
- * header, any variable-length link-layer header, and the
+ * The X register now contains the sum of the variable
+ * part of the offset of the link-layer payload and the
* length of the network-layer header.
*
* Load into the A register the offset relative to
* the beginning of the transport layer header,
* add the X register to that, move that to the
* X register, and load with an offset from the
- * X register equal to the offset of the network
- * layer header relative to the beginning of
- * the MAC-layer payload plus the fixed-length
- * portion of the offset of the MAC-layer payload
- * from the beginning of the raw packet data.
- */
- sappend(s, xfer_to_a(inst));
- sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X));
- sappend(s, new_stmt(BPF_MISC|BPF_TAX));
- sappend(s, tmp = new_stmt(BPF_LD|BPF_IND|size));
- tmp->s.k = off_macpl + off_nl;
+ * X register equal to the sum of the constant part of
+ * the offset of the link-layer payload and the offset,
+ * relative to the beginning of the link-layer payload,
+ * of the network-layer header.
+ */
+ 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));
+ sappend(s, tmp = new_stmt(cstate, BPF_LD|BPF_IND|size));
+ tmp->s.k = cstate->off_linkpl.constant_part + cstate->off_nl;
sappend(inst->s, s);
/*
@@ -6868,18 +7000,18 @@ gen_load(proto, inst, size)
* if this is an IP datagram and is the first or
* only fragment of that datagram.
*/
- gen_and(gen_proto_abbrev(proto), b = gen_ipfrag());
+ gen_and(gen_proto_abbrev(cstate, proto), b = gen_ipfrag(cstate));
if (inst->b)
gen_and(inst->b, b);
- gen_and(gen_proto_abbrev(Q_IP), b);
+ gen_and(gen_proto_abbrev(cstate, Q_IP), b);
inst->b = b;
break;
case Q_ICMPV6:
- bpf_error("IPv6 upper-layer protocol is not supported by proto[x]");
+ bpf_error(cstate, "IPv6 upper-layer protocol is not supported by proto[x]");
/*NOTREACHED*/
}
inst->regno = regno;
- s = new_stmt(BPF_ST);
+ s = new_stmt(cstate, BPF_ST);
s->s.k = regno;
sappend(inst->s, s);
@@ -6887,23 +7019,21 @@ gen_load(proto, inst, size)
}
struct block *
-gen_relation(code, a0, a1, reversed)
- int code;
- struct arth *a0, *a1;
- int reversed;
+gen_relation(compiler_state_t *cstate, int code, struct arth *a0,
+ struct arth *a1, int reversed)
{
struct slist *s0, *s1, *s2;
struct block *b, *tmp;
- s0 = xfer_to_x(a1);
- s1 = xfer_to_a(a0);
+ s0 = xfer_to_x(cstate, a1);
+ s1 = xfer_to_a(cstate, a0);
if (code == BPF_JEQ) {
- s2 = new_stmt(BPF_ALU|BPF_SUB|BPF_X);
- b = new_block(JMP(code));
+ s2 = new_stmt(cstate, BPF_ALU|BPF_SUB|BPF_X);
+ b = new_block(cstate, JMP(code));
sappend(s1, s2);
}
else
- b = new_block(BPF_JMP|code|BPF_X);
+ b = new_block(cstate, BPF_JMP|code|BPF_X);
if (reversed)
gen_not(b);
@@ -6913,8 +7043,8 @@ gen_relation(code, a0, a1, reversed)
b->stmts = a0->s;
- free_reg(a0->regno);
- free_reg(a1->regno);
+ free_reg(cstate, a0->regno);
+ free_reg(cstate, a1->regno);
/* 'and' together protocol checks */
if (a0->b) {
@@ -6933,14 +7063,14 @@ gen_relation(code, a0, a1, reversed)
}
struct arth *
-gen_loadlen()
+gen_loadlen(compiler_state_t *cstate)
{
- int regno = alloc_reg();
- struct arth *a = (struct arth *)newchunk(sizeof(*a));
+ int regno = alloc_reg(cstate);
+ struct arth *a = (struct arth *)newchunk(cstate, sizeof(*a));
struct slist *s;
- s = new_stmt(BPF_LD|BPF_LEN);
- s->next = new_stmt(BPF_ST);
+ s = new_stmt(cstate, BPF_LD|BPF_LEN);
+ s->next = new_stmt(cstate, BPF_ST);
s->next->s.k = regno;
a->s = s;
a->regno = regno;
@@ -6949,20 +7079,19 @@ gen_loadlen()
}
struct arth *
-gen_loadi(val)
- int val;
+gen_loadi(compiler_state_t *cstate, int val)
{
struct arth *a;
struct slist *s;
int reg;
- a = (struct arth *)newchunk(sizeof(*a));
+ a = (struct arth *)newchunk(cstate, sizeof(*a));
- reg = alloc_reg();
+ reg = alloc_reg(cstate);
- s = new_stmt(BPF_LD|BPF_IMM);
+ s = new_stmt(cstate, BPF_LD|BPF_IMM);
s->s.k = val;
- s->next = new_stmt(BPF_ST);
+ s->next = new_stmt(cstate, BPF_ST);
s->next->s.k = reg;
a->s = s;
a->regno = reg;
@@ -6971,17 +7100,16 @@ gen_loadi(val)
}
struct arth *
-gen_neg(a)
- struct arth *a;
+gen_neg(compiler_state_t *cstate, struct arth *a)
{
struct slist *s;
- s = xfer_to_a(a);
+ s = xfer_to_a(cstate, a);
sappend(a->s, s);
- s = new_stmt(BPF_ALU|BPF_NEG);
+ s = new_stmt(cstate, BPF_ALU|BPF_NEG);
s->s.k = 0;
sappend(a->s, s);
- s = new_stmt(BPF_ST);
+ s = new_stmt(cstate, BPF_ST);
s->s.k = a->regno;
sappend(a->s, s);
@@ -6989,65 +7117,68 @@ gen_neg(a)
}
struct arth *
-gen_arth(code, a0, a1)
- int code;
- struct arth *a0, *a1;
+gen_arth(compiler_state_t *cstate, int code, struct arth *a0,
+ struct arth *a1)
{
struct slist *s0, *s1, *s2;
- s0 = xfer_to_x(a1);
- s1 = xfer_to_a(a0);
- s2 = new_stmt(BPF_ALU|BPF_X|code);
+ /*
+ * Disallow division by, or modulus by, zero; we do this here
+ * so that it gets done even if the optimizer is disabled.
+ */
+ if (code == BPF_DIV) {
+ if (a1->s->s.code == (BPF_LD|BPF_IMM) && a1->s->s.k == 0)
+ bpf_error(cstate, "division by zero");
+ } else if (code == BPF_MOD) {
+ if (a1->s->s.code == (BPF_LD|BPF_IMM) && a1->s->s.k == 0)
+ bpf_error(cstate, "modulus by zero");
+ }
+ s0 = xfer_to_x(cstate, a1);
+ s1 = xfer_to_a(cstate, a0);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_X|code);
sappend(s1, s2);
sappend(s0, s1);
sappend(a1->s, s0);
sappend(a0->s, a1->s);
- free_reg(a0->regno);
- free_reg(a1->regno);
+ free_reg(cstate, a0->regno);
+ free_reg(cstate, a1->regno);
- s0 = new_stmt(BPF_ST);
- a0->regno = s0->s.k = alloc_reg();
+ s0 = new_stmt(cstate, BPF_ST);
+ a0->regno = s0->s.k = alloc_reg(cstate);
sappend(a0->s, s0);
return a0;
}
/*
- * Here we handle simple allocation of the scratch registers.
- * If too many registers are alloc'd, the allocator punts.
- */
-static int regused[BPF_MEMWORDS];
-static int curreg;
-
-/*
* Initialize the table of used registers and the current register.
*/
static void
-init_regs()
+init_regs(compiler_state_t *cstate)
{
- curreg = 0;
- memset(regused, 0, sizeof regused);
+ cstate->curreg = 0;
+ memset(cstate->regused, 0, sizeof cstate->regused);
}
/*
* Return the next free register.
*/
static int
-alloc_reg()
+alloc_reg(compiler_state_t *cstate)
{
int n = BPF_MEMWORDS;
while (--n >= 0) {
- if (regused[curreg])
- curreg = (curreg + 1) % BPF_MEMWORDS;
+ if (cstate->regused[cstate->curreg])
+ cstate->curreg = (cstate->curreg + 1) % BPF_MEMWORDS;
else {
- regused[curreg] = 1;
- return curreg;
+ cstate->regused[cstate->curreg] = 1;
+ return cstate->curreg;
}
}
- bpf_error("too many registers needed to evaluate expression");
+ bpf_error(cstate, "too many registers needed to evaluate expression");
/* NOTREACHED */
return 0;
}
@@ -7057,21 +7188,19 @@ alloc_reg()
* be used later.
*/
static void
-free_reg(n)
- int n;
+free_reg(compiler_state_t *cstate, int n)
{
- regused[n] = 0;
+ cstate->regused[n] = 0;
}
static struct block *
-gen_len(jmp, n)
- int jmp, n;
+gen_len(compiler_state_t *cstate, int jmp, int n)
{
struct slist *s;
struct block *b;
- s = new_stmt(BPF_LD|BPF_LEN);
- b = new_block(JMP(jmp));
+ s = new_stmt(cstate, BPF_LD|BPF_LEN);
+ b = new_block(cstate, JMP(jmp));
b->stmts = s;
b->s.k = n;
@@ -7079,22 +7208,20 @@ gen_len(jmp, n)
}
struct block *
-gen_greater(n)
- int n;
+gen_greater(compiler_state_t *cstate, int n)
{
- return gen_len(BPF_JGE, n);
+ return gen_len(cstate, BPF_JGE, n);
}
/*
* Actually, this is less than or equal.
*/
struct block *
-gen_less(n)
- int n;
+gen_less(compiler_state_t *cstate, int n)
{
struct block *b;
- b = gen_len(BPF_JGT, n);
+ b = gen_len(cstate, BPF_JGT, n);
gen_not(b);
return b;
@@ -7111,8 +7238,7 @@ gen_less(n)
* would generate code appropriate to the radio header in question.
*/
struct block *
-gen_byteop(op, idx, val)
- int op, idx, val;
+gen_byteop(compiler_state_t *cstate, int op, int idx, int val)
{
struct block *b;
struct slist *s;
@@ -7122,87 +7248,71 @@ gen_byteop(op, idx, val)
abort();
case '=':
- return gen_cmp(OR_LINK, (u_int)idx, BPF_B, (bpf_int32)val);
+ return gen_cmp(cstate, OR_LINKHDR, (u_int)idx, BPF_B, (bpf_int32)val);
case '<':
- b = gen_cmp_lt(OR_LINK, (u_int)idx, BPF_B, (bpf_int32)val);
+ b = gen_cmp_lt(cstate, OR_LINKHDR, (u_int)idx, BPF_B, (bpf_int32)val);
return b;
case '>':
- b = gen_cmp_gt(OR_LINK, (u_int)idx, BPF_B, (bpf_int32)val);
+ b = gen_cmp_gt(cstate, OR_LINKHDR, (u_int)idx, BPF_B, (bpf_int32)val);
return b;
case '|':
- s = new_stmt(BPF_ALU|BPF_OR|BPF_K);
+ s = new_stmt(cstate, BPF_ALU|BPF_OR|BPF_K);
break;
case '&':
- s = new_stmt(BPF_ALU|BPF_AND|BPF_K);
+ s = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
break;
}
s->s.k = val;
- b = new_block(JMP(BPF_JEQ));
+ b = new_block(cstate, JMP(BPF_JEQ));
b->stmts = s;
gen_not(b);
return b;
}
-static u_char abroadcast[] = { 0x0 };
+static const u_char abroadcast[] = { 0x0 };
struct block *
-gen_broadcast(proto)
- int proto;
+gen_broadcast(compiler_state_t *cstate, int proto)
{
bpf_u_int32 hostmask;
struct block *b0, *b1, *b2;
- static u_char ebroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+ static const u_char ebroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
switch (proto) {
case Q_DEFAULT:
case Q_LINK:
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_ARCNET:
case DLT_ARCNET_LINUX:
- return gen_ahostop(abroadcast, Q_DST);
+ return gen_ahostop(cstate, abroadcast, Q_DST);
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- return gen_ehostop(ebroadcast, Q_DST);
+ b1 = gen_prevlinkhdr_check(cstate);
+ b0 = gen_ehostop(cstate, ebroadcast, Q_DST);
+ if (b1 != NULL)
+ gen_and(b1, b0);
+ return b0;
case DLT_FDDI:
- return gen_fhostop(ebroadcast, Q_DST);
+ return gen_fhostop(cstate, ebroadcast, Q_DST);
case DLT_IEEE802:
- return gen_thostop(ebroadcast, Q_DST);
+ return gen_thostop(cstate, ebroadcast, Q_DST);
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
case DLT_PPI:
- return gen_wlanhostop(ebroadcast, Q_DST);
+ return gen_wlanhostop(cstate, ebroadcast, Q_DST);
case DLT_IP_OVER_FC:
- return gen_ipfchostop(ebroadcast, Q_DST);
- case DLT_SUNATM:
- if (is_lane) {
- /*
- * Check that the packet doesn't begin with an
- * LE Control marker. (We've already generated
- * a test for LANE.)
- */
- b1 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS,
- BPF_H, 0xFF00);
- gen_not(b1);
-
- /*
- * Now check the MAC address.
- */
- b0 = gen_ehostop(ebroadcast, Q_DST);
- gen_and(b1, b0);
- return b0;
- }
- break;
+ return gen_ipfchostop(cstate, ebroadcast, Q_DST);
default:
- bpf_error("not a broadcast link");
+ bpf_error(cstate, "not a broadcast link");
}
break;
@@ -7212,18 +7322,18 @@ gen_broadcast(proto)
* as an indication that we don't know the netmask, and fail
* in that case.
*/
- if (netmask == PCAP_NETMASK_UNKNOWN)
- bpf_error("netmask not known, so 'ip broadcast' not supported");
- b0 = gen_linktype(ETHERTYPE_IP);
- hostmask = ~netmask;
- b1 = gen_mcmp(OR_NET, 16, BPF_W, (bpf_int32)0, hostmask);
- b2 = gen_mcmp(OR_NET, 16, BPF_W,
+ if (cstate->netmask == PCAP_NETMASK_UNKNOWN)
+ bpf_error(cstate, "netmask not known, so 'ip broadcast' not supported");
+ b0 = gen_linktype(cstate, ETHERTYPE_IP);
+ hostmask = ~cstate->netmask;
+ b1 = gen_mcmp(cstate, OR_LINKPL, 16, BPF_W, (bpf_int32)0, hostmask);
+ b2 = gen_mcmp(cstate, OR_LINKPL, 16, BPF_W,
(bpf_int32)(~0 & hostmask), hostmask);
gen_or(b1, b2);
gen_and(b0, b2);
return b2;
}
- bpf_error("only link-layer/IP broadcast filters supported");
+ bpf_error(cstate, "only link-layer/IP broadcast filters supported");
/* NOTREACHED */
return NULL;
}
@@ -7233,23 +7343,21 @@ gen_broadcast(proto)
* the bottom bit of the *first* byte).
*/
static struct block *
-gen_mac_multicast(offset)
- int offset;
+gen_mac_multicast(compiler_state_t *cstate, int offset)
{
register struct block *b0;
register struct slist *s;
/* link[offset] & 1 != 0 */
- s = gen_load_a(OR_LINK, offset, BPF_B);
- b0 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, offset, BPF_B);
+ b0 = new_block(cstate, JMP(BPF_JSET));
b0->s.k = 1;
b0->stmts = s;
return b0;
}
struct block *
-gen_multicast(proto)
- int proto;
+gen_multicast(compiler_state_t *cstate, int proto)
{
register struct block *b0, *b1, *b2;
register struct slist *s;
@@ -7258,16 +7366,20 @@ gen_multicast(proto)
case Q_DEFAULT:
case Q_LINK:
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_ARCNET:
case DLT_ARCNET_LINUX:
/* all ARCnet multicasts use the same address */
- return gen_ahostop(abroadcast, Q_DST);
+ return gen_ahostop(cstate, abroadcast, Q_DST);
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
+ b1 = gen_prevlinkhdr_check(cstate);
/* ether[0] & 1 != 0 */
- return gen_mac_multicast(0);
+ b0 = gen_mac_multicast(cstate, 0);
+ if (b1 != NULL)
+ gen_and(b1, b0);
+ return b0;
case DLT_FDDI:
/*
* XXX TEST THIS: MIGHT NOT PORT PROPERLY XXX
@@ -7275,10 +7387,10 @@ gen_multicast(proto)
* XXX - was that referring to bit-order issues?
*/
/* fddi[1] & 1 != 0 */
- return gen_mac_multicast(1);
+ return gen_mac_multicast(cstate, 1);
case DLT_IEEE802:
/* tr[2] & 1 != 0 */
- return gen_mac_multicast(2);
+ return gen_mac_multicast(cstate, 2);
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
@@ -7305,23 +7417,23 @@ gen_multicast(proto)
*
* First, check for To DS set, i.e. "link[1] & 0x01".
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x01; /* To DS */
b1->stmts = s;
/*
* If To DS is set, the DA is at 16.
*/
- b0 = gen_mac_multicast(16);
+ b0 = gen_mac_multicast(cstate, 16);
gen_and(b1, b0);
/*
* Now, check for To DS not set, i.e. check
* "!(link[1] & 0x01)".
*/
- s = gen_load_a(OR_LINK, 1, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 1, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x01; /* To DS */
b2->stmts = s;
gen_not(b2);
@@ -7329,7 +7441,7 @@ gen_multicast(proto)
/*
* If To DS is not set, the DA is at 4.
*/
- b1 = gen_mac_multicast(4);
+ b1 = gen_mac_multicast(cstate, 4);
gen_and(b2, b1);
/*
@@ -7342,8 +7454,8 @@ gen_multicast(proto)
* Now check for a data frame.
* I.e, check "link[0] & 0x08".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x08;
b1->stmts = s;
@@ -7357,8 +7469,8 @@ gen_multicast(proto)
* is a management frame.
* I.e, check "!(link[0] & 0x08)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b2 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b2 = new_block(cstate, JMP(BPF_JSET));
b2->s.k = 0x08;
b2->stmts = s;
gen_not(b2);
@@ -7366,7 +7478,7 @@ gen_multicast(proto)
/*
* For management frames, the DA is at 4.
*/
- b1 = gen_mac_multicast(4);
+ b1 = gen_mac_multicast(cstate, 4);
gen_and(b2, b1);
/*
@@ -7384,8 +7496,8 @@ gen_multicast(proto)
*
* I.e., check "!(link[0] & 0x04)".
*/
- s = gen_load_a(OR_LINK, 0, BPF_B);
- b1 = new_block(JMP(BPF_JSET));
+ s = gen_load_a(cstate, OR_LINKHDR, 0, BPF_B);
+ b1 = new_block(cstate, JMP(BPF_JSET));
b1->s.k = 0x04;
b1->stmts = s;
gen_not(b1);
@@ -7397,25 +7509,8 @@ gen_multicast(proto)
gen_and(b1, b0);
return b0;
case DLT_IP_OVER_FC:
- b0 = gen_mac_multicast(2);
+ b0 = gen_mac_multicast(cstate, 2);
return b0;
- case DLT_SUNATM:
- if (is_lane) {
- /*
- * Check that the packet doesn't begin with an
- * LE Control marker. (We've already generated
- * a test for LANE.)
- */
- b1 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS,
- BPF_H, 0xFF00);
- gen_not(b1);
-
- /* ether[off_mac] & 1 != 0 */
- b0 = gen_mac_multicast(off_mac);
- gen_and(b1, b0);
- return b0;
- }
- break;
default:
break;
}
@@ -7423,18 +7518,18 @@ gen_multicast(proto)
break;
case Q_IP:
- b0 = gen_linktype(ETHERTYPE_IP);
- b1 = gen_cmp_ge(OR_NET, 16, BPF_B, (bpf_int32)224);
+ b0 = gen_linktype(cstate, ETHERTYPE_IP);
+ b1 = gen_cmp_ge(cstate, OR_LINKPL, 16, BPF_B, (bpf_int32)224);
gen_and(b0, b1);
return b1;
case Q_IPV6:
- b0 = gen_linktype(ETHERTYPE_IPV6);
- b1 = gen_cmp(OR_NET, 24, BPF_B, (bpf_int32)255);
+ b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
+ b1 = gen_cmp(cstate, OR_LINKPL, 24, BPF_B, (bpf_int32)255);
gen_and(b0, b1);
return b1;
}
- bpf_error("link-layer multicast filters supported only on ethernet/FDDI/token ring/ARCNET/802.11/ATM LANE/Fibre Channel");
+ bpf_error(cstate, "link-layer multicast filters supported only on ethernet/FDDI/token ring/ARCNET/802.11/ATM LANE/Fibre Channel");
/* NOTREACHED */
return NULL;
}
@@ -7449,35 +7544,34 @@ gen_multicast(proto)
* better accomplished using a higher-layer filter.
*/
struct block *
-gen_inbound(dir)
- int dir;
+gen_inbound(compiler_state_t *cstate, int dir)
{
register struct block *b0;
/*
* Only some data link types support inbound/outbound qualifiers.
*/
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_SLIP:
- b0 = gen_relation(BPF_JEQ,
- gen_load(Q_LINK, gen_loadi(0), 1),
- gen_loadi(0),
+ b0 = gen_relation(cstate, BPF_JEQ,
+ gen_load(cstate, Q_LINK, gen_loadi(cstate, 0), 1),
+ gen_loadi(cstate, 0),
dir);
break;
case DLT_IPNET:
if (dir) {
/* match outgoing packets */
- b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_OUTBOUND);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, IPNET_OUTBOUND);
} else {
/* match incoming packets */
- b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_INBOUND);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, IPNET_INBOUND);
}
break;
case DLT_LINUX_SLL:
/* match outgoing packets */
- b0 = gen_cmp(OR_LINK, 0, BPF_H, LINUX_SLL_OUTGOING);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 0, BPF_H, LINUX_SLL_OUTGOING);
if (!dir) {
/* to filter on inbound traffic, invert the match */
gen_not(b0);
@@ -7486,7 +7580,7 @@ gen_inbound(dir)
#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
- b0 = gen_cmp(OR_LINK, offsetof(struct pfloghdr, dir), BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, dir), BPF_B,
(bpf_int32)((dir == 0) ? PF_IN : PF_OUT));
break;
#endif
@@ -7494,10 +7588,10 @@ gen_inbound(dir)
case DLT_PPP_PPPD:
if (dir) {
/* match outgoing packets */
- b0 = gen_cmp(OR_LINK, 0, BPF_B, PPP_PPPD_OUT);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 0, BPF_B, PPP_PPPD_OUT);
} else {
/* match incoming packets */
- b0 = gen_cmp(OR_LINK, 0, BPF_B, PPP_PPPD_IN);
+ b0 = gen_cmp(cstate, OR_LINKHDR, 0, BPF_B, PPP_PPPD_IN);
}
break;
@@ -7528,10 +7622,10 @@ gen_inbound(dir)
* the byte after the 3-byte magic number */
if (dir) {
/* match outgoing packets */
- b0 = gen_mcmp(OR_LINK, 3, BPF_B, 0, 0x01);
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 3, BPF_B, 0, 0x01);
} else {
/* match incoming packets */
- b0 = gen_mcmp(OR_LINK, 3, BPF_B, 1, 0x01);
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 3, BPF_B, 1, 0x01);
}
break;
@@ -7541,33 +7635,33 @@ gen_inbound(dir)
* check it, otherwise give up as this link-layer type
* has nothing in the packet data.
*/
-#if defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
+#if defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
/*
- * We infer that this is Linux with PF_PACKET support.
+ * This is Linux with PF_PACKET support.
* If this is a *live* capture, we can look at
* special meta-data in the filter expression;
* if it's a savefile, we can't.
*/
- if (bpf_pcap->sf.rfile != NULL) {
+ if (cstate->bpf_pcap->rfile != NULL) {
/* We have a FILE *, so this is a savefile */
- bpf_error("inbound/outbound not supported on linktype %d when reading savefiles",
- linktype);
+ bpf_error(cstate, "inbound/outbound not supported on linktype %d when reading savefiles",
+ cstate->linktype);
b0 = NULL;
/* NOTREACHED */
}
/* match outgoing packets */
- b0 = gen_cmp(OR_LINK, SKF_AD_OFF + SKF_AD_PKTTYPE, BPF_H,
+ b0 = gen_cmp(cstate, OR_LINKHDR, SKF_AD_OFF + SKF_AD_PKTTYPE, BPF_H,
PACKET_OUTGOING);
if (!dir) {
/* to filter on inbound traffic, invert the match */
gen_not(b0);
}
-#else /* defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */
- bpf_error("inbound/outbound not supported on linktype %d",
- linktype);
+#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(PF_PACKET) && defined(SO_ATTACH_FILTER) */
+#endif /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */
}
return (b0);
}
@@ -7575,156 +7669,156 @@ gen_inbound(dir)
#ifdef HAVE_NET_PFVAR_H
/* PF firewall log matched interface */
struct block *
-gen_pf_ifname(const char *ifname)
+gen_pf_ifname(compiler_state_t *cstate, const char *ifname)
{
struct block *b0;
u_int len, off;
- if (linktype != DLT_PFLOG) {
- bpf_error("ifname supported only on PF linktype");
+ if (cstate->linktype != DLT_PFLOG) {
+ bpf_error(cstate, "ifname supported only on PF linktype");
/* NOTREACHED */
}
len = sizeof(((struct pfloghdr *)0)->ifname);
off = offsetof(struct pfloghdr, ifname);
if (strlen(ifname) >= len) {
- bpf_error("ifname interface names can only be %d characters",
+ bpf_error(cstate, "ifname interface names can only be %d characters",
len-1);
/* NOTREACHED */
}
- b0 = gen_bcmp(OR_LINK, off, strlen(ifname), (const u_char *)ifname);
+ b0 = gen_bcmp(cstate, OR_LINKHDR, off, strlen(ifname), (const u_char *)ifname);
return (b0);
}
/* PF firewall log ruleset name */
struct block *
-gen_pf_ruleset(char *ruleset)
+gen_pf_ruleset(compiler_state_t *cstate, char *ruleset)
{
struct block *b0;
- if (linktype != DLT_PFLOG) {
- bpf_error("ruleset supported only on PF linktype");
+ if (cstate->linktype != DLT_PFLOG) {
+ bpf_error(cstate, "ruleset supported only on PF linktype");
/* NOTREACHED */
}
if (strlen(ruleset) >= sizeof(((struct pfloghdr *)0)->ruleset)) {
- bpf_error("ruleset names can only be %ld characters",
+ bpf_error(cstate, "ruleset names can only be %ld characters",
(long)(sizeof(((struct pfloghdr *)0)->ruleset) - 1));
/* NOTREACHED */
}
- b0 = gen_bcmp(OR_LINK, offsetof(struct pfloghdr, ruleset),
+ b0 = gen_bcmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, ruleset),
strlen(ruleset), (const u_char *)ruleset);
return (b0);
}
/* PF firewall log rule number */
struct block *
-gen_pf_rnr(int rnr)
+gen_pf_rnr(compiler_state_t *cstate, int rnr)
{
struct block *b0;
- if (linktype != DLT_PFLOG) {
- bpf_error("rnr supported only on PF linktype");
+ if (cstate->linktype != DLT_PFLOG) {
+ bpf_error(cstate, "rnr supported only on PF linktype");
/* NOTREACHED */
}
- b0 = gen_cmp(OR_LINK, offsetof(struct pfloghdr, rulenr), BPF_W,
+ b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, rulenr), BPF_W,
(bpf_int32)rnr);
return (b0);
}
/* PF firewall log sub-rule number */
struct block *
-gen_pf_srnr(int srnr)
+gen_pf_srnr(compiler_state_t *cstate, int srnr)
{
struct block *b0;
- if (linktype != DLT_PFLOG) {
- bpf_error("srnr supported only on PF linktype");
+ if (cstate->linktype != DLT_PFLOG) {
+ bpf_error(cstate, "srnr supported only on PF linktype");
/* NOTREACHED */
}
- b0 = gen_cmp(OR_LINK, offsetof(struct pfloghdr, subrulenr), BPF_W,
+ b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, subrulenr), BPF_W,
(bpf_int32)srnr);
return (b0);
}
/* PF firewall log reason code */
struct block *
-gen_pf_reason(int reason)
+gen_pf_reason(compiler_state_t *cstate, int reason)
{
struct block *b0;
- if (linktype != DLT_PFLOG) {
- bpf_error("reason supported only on PF linktype");
+ if (cstate->linktype != DLT_PFLOG) {
+ bpf_error(cstate, "reason supported only on PF linktype");
/* NOTREACHED */
}
- b0 = gen_cmp(OR_LINK, offsetof(struct pfloghdr, reason), BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, reason), BPF_B,
(bpf_int32)reason);
return (b0);
}
/* PF firewall log action */
struct block *
-gen_pf_action(int action)
+gen_pf_action(compiler_state_t *cstate, int action)
{
struct block *b0;
- if (linktype != DLT_PFLOG) {
- bpf_error("action supported only on PF linktype");
+ if (cstate->linktype != DLT_PFLOG) {
+ bpf_error(cstate, "action supported only on PF linktype");
/* NOTREACHED */
}
- b0 = gen_cmp(OR_LINK, offsetof(struct pfloghdr, action), BPF_B,
+ b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, action), BPF_B,
(bpf_int32)action);
return (b0);
}
#else /* !HAVE_NET_PFVAR_H */
struct block *
-gen_pf_ifname(const char *ifname)
+gen_pf_ifname(compiler_state_t *cstate, const char *ifname)
{
- bpf_error("libpcap was compiled without pf support");
+ bpf_error(cstate, "libpcap was compiled without pf support");
/* NOTREACHED */
return (NULL);
}
struct block *
-gen_pf_ruleset(char *ruleset)
+gen_pf_ruleset(compiler_state_t *cstate, char *ruleset)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/* NOTREACHED */
return (NULL);
}
struct block *
-gen_pf_rnr(int rnr)
+gen_pf_rnr(compiler_state_t *cstate, int rnr)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/* NOTREACHED */
return (NULL);
}
struct block *
-gen_pf_srnr(int srnr)
+gen_pf_srnr(compiler_state_t *cstate, int srnr)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/* NOTREACHED */
return (NULL);
}
struct block *
-gen_pf_reason(int reason)
+gen_pf_reason(compiler_state_t *cstate, int reason)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/* NOTREACHED */
return (NULL);
}
struct block *
-gen_pf_action(int action)
+gen_pf_action(compiler_state_t *cstate, int action)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/* NOTREACHED */
return (NULL);
}
@@ -7732,22 +7826,22 @@ gen_pf_action(int action)
/* IEEE 802.11 wireless header */
struct block *
-gen_p80211_type(int type, int mask)
+gen_p80211_type(compiler_state_t *cstate, int type, int mask)
{
struct block *b0;
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
case DLT_IEEE802_11_RADIO_AVS:
case DLT_IEEE802_11_RADIO:
- b0 = gen_mcmp(OR_LINK, 0, BPF_B, (bpf_int32)type,
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, (bpf_int32)type,
(bpf_int32)mask);
break;
default:
- bpf_error("802.11 link-layer types supported only on 802.11");
+ bpf_error(cstate, "802.11 link-layer types supported only on 802.11");
/* NOTREACHED */
}
@@ -7755,11 +7849,11 @@ gen_p80211_type(int type, int mask)
}
struct block *
-gen_p80211_fcdir(int fcdir)
+gen_p80211_fcdir(compiler_state_t *cstate, int fcdir)
{
struct block *b0;
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_IEEE802_11:
case DLT_PRISM_HEADER:
@@ -7768,111 +7862,175 @@ gen_p80211_fcdir(int fcdir)
break;
default:
- bpf_error("frame direction supported only with 802.11 headers");
+ bpf_error(cstate, "frame direction supported only with 802.11 headers");
/* NOTREACHED */
}
- b0 = gen_mcmp(OR_LINK, 1, BPF_B, (bpf_int32)fcdir,
+ b0 = gen_mcmp(cstate, OR_LINKHDR, 1, BPF_B, (bpf_int32)fcdir,
(bpf_u_int32)IEEE80211_FC1_DIR_MASK);
return (b0);
}
struct block *
-gen_acode(eaddr, q)
- register const u_char *eaddr;
- struct qual q;
+gen_acode(compiler_state_t *cstate, const u_char *eaddr, struct qual q)
{
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_ARCNET:
case DLT_ARCNET_LINUX:
if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) &&
q.proto == Q_LINK)
- return (gen_ahostop(eaddr, (int)q.dir));
+ return (gen_ahostop(cstate, eaddr, (int)q.dir));
else {
- bpf_error("ARCnet address used in non-arc expression");
+ bpf_error(cstate, "ARCnet address used in non-arc expression");
/* NOTREACHED */
}
break;
default:
- bpf_error("aid supported only on ARCnet");
+ bpf_error(cstate, "aid supported only on ARCnet");
/* NOTREACHED */
}
- bpf_error("ARCnet address used in non-arc expression");
+ bpf_error(cstate, "ARCnet address used in non-arc expression");
/* NOTREACHED */
return NULL;
}
static struct block *
-gen_ahostop(eaddr, dir)
- register const u_char *eaddr;
- register int dir;
+gen_ahostop(compiler_state_t *cstate, const u_char *eaddr, int dir)
{
register struct block *b0, *b1;
switch (dir) {
/* src comes first, different from Ethernet */
case Q_SRC:
- return gen_bcmp(OR_LINK, 0, 1, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 0, 1, eaddr);
case Q_DST:
- return gen_bcmp(OR_LINK, 1, 1, eaddr);
+ return gen_bcmp(cstate, OR_LINKHDR, 1, 1, eaddr);
case Q_AND:
- b0 = gen_ahostop(eaddr, Q_SRC);
- b1 = gen_ahostop(eaddr, Q_DST);
+ b0 = gen_ahostop(cstate, eaddr, Q_SRC);
+ b1 = gen_ahostop(cstate, eaddr, Q_DST);
gen_and(b0, b1);
return b1;
case Q_DEFAULT:
case Q_OR:
- b0 = gen_ahostop(eaddr, Q_SRC);
- b1 = gen_ahostop(eaddr, Q_DST);
+ b0 = gen_ahostop(cstate, eaddr, Q_SRC);
+ b1 = gen_ahostop(cstate, eaddr, Q_DST);
gen_or(b0, b1);
return b1;
case Q_ADDR1:
- bpf_error("'addr1' is only supported on 802.11");
+ bpf_error(cstate, "'addr1' is only supported on 802.11");
break;
case Q_ADDR2:
- bpf_error("'addr2' is only supported on 802.11");
+ bpf_error(cstate, "'addr2' is only supported on 802.11");
break;
case Q_ADDR3:
- bpf_error("'addr3' is only supported on 802.11");
+ bpf_error(cstate, "'addr3' is only supported on 802.11");
break;
case Q_ADDR4:
- bpf_error("'addr4' is only supported on 802.11");
+ bpf_error(cstate, "'addr4' is only supported on 802.11");
break;
case Q_RA:
- bpf_error("'ra' is only supported on 802.11");
+ bpf_error(cstate, "'ra' is only supported on 802.11");
break;
case Q_TA:
- bpf_error("'ta' is only supported on 802.11");
+ bpf_error(cstate, "'ta' is only supported on 802.11");
break;
}
abort();
/* 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)
+{
+ 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;
+
+ b1 = new_block(cstate, JMP(BPF_JEQ));
+ b1->stmts = s;
+ b1->s.k = (bpf_int32) vlan_num;
+
+ gen_and(b0,b1);
+ b0 = b1;
+ }
+
+ return b0;
+}
+#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;
+ }
+
+ /*
+ * The payload follows the full header, including the
+ * VLAN tags, so skip past this VLAN tag.
+ */
+ cstate->off_linkpl.constant_part += 4;
+
+ /*
+ * The link-layer type information follows the VLAN tags, so
+ * skip past this VLAN tag.
+ */
+ cstate->off_linktype.constant_part += 4;
+
+ return b0;
+}
+
/*
* support IEEE 802.1Q VLAN trunk over ethernet
*/
struct block *
-gen_vlan(vlan_num)
- int vlan_num;
+gen_vlan(compiler_state_t *cstate, int vlan_num)
{
- struct block *b0, *b1;
+ struct block *b0;
/* can't check for VLAN-encapsulated packets inside MPLS */
- if (label_stack_depth > 0)
- bpf_error("no VLAN match after MPLS");
+ if (cstate->label_stack_depth > 0)
+ bpf_error(cstate, "no VLAN match after MPLS");
/*
* Check for a VLAN packet, and then change the offsets to point
@@ -7905,43 +8063,44 @@ gen_vlan(vlan_num)
* be done assuming a VLAN, even though the "or" could be viewed
* as meaning "or, if this isn't a VLAN packet...".
*/
- orig_nl = off_nl;
-
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- /* check for VLAN, including QinQ */
- b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)ETHERTYPE_8021Q);
- b1 = gen_cmp(OR_LINK, off_linktype, BPF_H,
- (bpf_int32)ETHERTYPE_8021QINQ);
- gen_or(b0,b1);
- b0 = b1;
-
- /* If a specific VLAN is requested, check VLAN id */
- if (vlan_num >= 0) {
- b1 = gen_mcmp(OR_MACPL, 0, BPF_H,
- (bpf_int32)vlan_num, 0x0fff);
- gen_and(b0, b1);
- b0 = b1;
- }
-
- off_macpl += 4;
- off_linktype += 4;
-#if 0
- off_nl_nosnap += 4;
- off_nl += 4;
+#if defined(SKF_AD_VLAN_TAG) && 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 &&
+ cstate->off_linkhdr.constant_part ==
+ cstate->off_outermostlinkhdr.constant_part) {
+ /*
+ * Do we need special VLAN handling?
+ */
+ if (cstate->bpf_pcap->bpf_codegen_flags & BPF_SPECIAL_VLAN_HANDLING)
+ b0 = gen_vlan_bpf_extensions(cstate, vlan_num);
+ else
+ b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num);
+ } else
#endif
+ b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num);
+ break;
+
+ case DLT_IEEE802_11:
+ case DLT_PRISM_HEADER:
+ case DLT_IEEE802_11_RADIO_AVS:
+ case DLT_IEEE802_11_RADIO:
+ b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num);
break;
default:
- bpf_error("no VLAN support for data link type %d",
- linktype);
+ bpf_error(cstate, "no VLAN support for data link type %d",
+ cstate->linktype);
/*NOTREACHED*/
}
+ cstate->vlan_stack_depth++;
+
return (b0);
}
@@ -7949,43 +8108,29 @@ gen_vlan(vlan_num)
* support for MPLS
*/
struct block *
-gen_mpls(label_num)
- int label_num;
+gen_mpls(compiler_state_t *cstate, int label_num)
{
- struct block *b0,*b1;
-
- /*
- * Change the offsets to point to the type and data fields within
- * the MPLS packet. Just increment the offsets, so that we
- * can support a hierarchy, e.g. "mpls 100000 && mpls 1024" to
- * capture packets with an outer label of 100000 and an inner
- * label of 1024.
- *
- * XXX - this is a bit of a kludge. See comments in gen_vlan().
- */
- orig_nl = off_nl;
+ struct block *b0, *b1;
- if (label_stack_depth > 0) {
+ if (cstate->label_stack_depth > 0) {
/* just match the bottom-of-stack bit clear */
- b0 = gen_mcmp(OR_MACPL, orig_nl-2, BPF_B, 0, 0x01);
+ b0 = gen_mcmp(cstate, OR_PREVMPLSHDR, 2, BPF_B, 0, 0x01);
} else {
/*
- * Indicate that we're checking MPLS-encapsulated headers,
- * to make sure higher level code generators don't try to
- * match against IP-related protocols such as Q_ARP, Q_RARP
- * etc.
+ * We're not in an MPLS stack yet, so check the link-layer
+ * type against MPLS.
*/
- switch (linktype) {
+ switch (cstate->linktype) {
case DLT_C_HDLC: /* fall through */
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
- b0 = gen_linktype(ETHERTYPE_MPLS);
+ b0 = gen_linktype(cstate, ETHERTYPE_MPLS);
break;
case DLT_PPP:
- b0 = gen_linktype(PPP_MPLS_UCAST);
+ b0 = gen_linktype(cstate, PPP_MPLS_UCAST);
break;
/* FIXME add other DLT_s ...
@@ -7993,8 +8138,8 @@ gen_mpls(label_num)
* leave it for now */
default:
- bpf_error("no MPLS support for data link type %d",
- linktype);
+ bpf_error(cstate, "no MPLS support for data link type %d",
+ cstate->linktype);
b0 = NULL;
/*NOTREACHED*/
break;
@@ -8004,15 +8149,29 @@ gen_mpls(label_num)
/* If a specific MPLS label is requested, check it */
if (label_num >= 0) {
label_num = label_num << 12; /* label is shifted 12 bits on the wire */
- b1 = gen_mcmp(OR_MACPL, orig_nl, BPF_W, (bpf_int32)label_num,
+ b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_W, (bpf_int32)label_num,
0xfffff000); /* only compare the first 20 bits */
gen_and(b0, b1);
b0 = b1;
}
- off_nl_nosnap += 4;
- off_nl += 4;
- label_stack_depth++;
+ /*
+ * Change the offsets to point to the type and data fields within
+ * the MPLS packet. Just increment the offsets, so that we
+ * can support a hierarchy, e.g. "mpls 100000 && mpls 1024" to
+ * capture packets with an outer label of 100000 and an inner
+ * label of 1024.
+ *
+ * Increment the MPLS stack depth as well; this indicates that
+ * we're checking MPLS-encapsulated headers, to make sure higher
+ * level code generators don't try to match against IP-related
+ * protocols such as Q_ARP, Q_RARP etc.
+ *
+ * XXX - this is a bit of a kludge. See comments in gen_vlan().
+ */
+ cstate->off_nl_nosnap += 4;
+ cstate->off_nl += 4;
+ cstate->label_stack_depth++;
return (b0);
}
@@ -8020,21 +8179,29 @@ gen_mpls(label_num)
* Support PPPOE discovery and session.
*/
struct block *
-gen_pppoed()
+gen_pppoed(compiler_state_t *cstate)
{
/* check for PPPoE discovery */
- return gen_linktype((bpf_int32)ETHERTYPE_PPPOED);
+ return gen_linktype(cstate, (bpf_int32)ETHERTYPE_PPPOED);
}
struct block *
-gen_pppoes()
+gen_pppoes(compiler_state_t *cstate, int sess_num)
{
- struct block *b0;
+ struct block *b0, *b1;
/*
* Test against the PPPoE session link-layer type.
*/
- b0 = gen_linktype((bpf_int32)ETHERTYPE_PPPOES);
+ b0 = gen_linktype(cstate, (bpf_int32)ETHERTYPE_PPPOES);
+
+ /* If a specific session is requested, check PPPoE session id */
+ if (sess_num >= 0) {
+ b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_W,
+ (bpf_int32)sess_num, 0x0000ffff);
+ gen_and(b0, b1);
+ b0 = b1;
+ }
/*
* Change the offsets to point to the type and data fields within
@@ -8064,12 +8231,7 @@ gen_pppoes()
* as all the "or ..." tests would be done assuming PPPoE, even
* though the "or" could be viewed as meaning "or, if this isn't
* a PPPoE packet...".
- */
- orig_linktype = off_linktype; /* save original values */
- orig_nl = off_nl;
- is_pppoes = 1;
-
- /*
+ *
* The "network-layer" protocol is PPPoE, which has a 6-byte
* PPPoE header, followed by a PPP packet.
*
@@ -8078,70 +8240,362 @@ gen_pppoes()
* starts at the first byte of the PPP packet. For PPPoE,
* that offset is relative to the beginning of the total
* link-layer payload, including any 802.2 LLC header, so
- * it's 6 bytes past off_nl.
+ * it's 6 bytes past cstate->off_nl.
*/
- off_linktype = off_nl + 6;
+ PUSH_LINKHDR(cstate, DLT_PPP, cstate->off_linkpl.is_variable,
+ cstate->off_linkpl.constant_part + cstate->off_nl + 6, /* 6 bytes past the PPPoE header */
+ cstate->off_linkpl.reg);
- /*
- * The network-layer offsets are relative to the beginning
- * of the MAC-layer payload; that's past the 6-byte
- * PPPoE header and the 2-byte PPP header.
- */
- off_nl = 6+2;
- off_nl_nosnap = 6+2;
+ cstate->off_linktype = cstate->off_linkhdr;
+ cstate->off_linkpl.constant_part = cstate->off_linkhdr.constant_part + 2;
+
+ cstate->off_nl = 0;
+ cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
+
+ return b0;
+}
+
+/* Check that this is Geneve and the VNI is correct if
+ * specified. Parameterized to handle both IPv4 and IPv6. */
+static struct block *
+gen_geneve_check(compiler_state_t *cstate,
+ struct block *(*gen_portfn)(compiler_state_t *, int, int, int),
+ enum e_offrel offrel, int vni)
+{
+ struct block *b0, *b1;
+
+ b0 = gen_portfn(cstate, GENEVE_PORT, IPPROTO_UDP, Q_DST);
+
+ /* Check that we are operating on version 0. Otherwise, we
+ * can't decode the rest of the fields. The version is 2 bits
+ * in the first byte of the Geneve header. */
+ b1 = gen_mcmp(cstate, offrel, 8, BPF_B, (bpf_int32)0, 0xc0);
+ gen_and(b0, b1);
+ b0 = b1;
+
+ if (vni >= 0) {
+ vni <<= 8; /* VNI is in the upper 3 bytes */
+ b1 = gen_mcmp(cstate, offrel, 12, BPF_W, (bpf_int32)vni,
+ 0xffffff00);
+ gen_and(b0, b1);
+ b0 = b1;
+ }
+
+ return b0;
+}
+
+/* The IPv4 and IPv6 Geneve checks need to do two things:
+ * - Verify that this actually is Geneve with the right VNI.
+ * - Place the IP header length (plus variable link prefix if
+ * needed) into register A to be used later to compute
+ * the inner packet offsets. */
+static struct block *
+gen_geneve4(compiler_state_t *cstate, int vni)
+{
+ struct block *b0, *b1;
+ struct slist *s, *s1;
+
+ b0 = gen_geneve_check(cstate, gen_port, OR_TRAN_IPV4, vni);
+
+ /* Load the IP header length into A. */
+ s = gen_loadx_iphdrlen(cstate);
+
+ s1 = new_stmt(cstate, BPF_MISC|BPF_TXA);
+ sappend(s, s1);
+
+ /* Forcibly append these statements to the true condition
+ * of the protocol check by creating a new block that is
+ * always true and ANDing them. */
+ b1 = new_block(cstate, BPF_JMP|BPF_JEQ|BPF_X);
+ b1->stmts = s;
+ b1->s.k = 0;
+
+ gen_and(b0, b1);
+
+ return b1;
+}
+
+static struct block *
+gen_geneve6(compiler_state_t *cstate, int vni)
+{
+ struct block *b0, *b1;
+ struct slist *s, *s1;
+
+ b0 = gen_geneve_check(cstate, gen_port6, OR_TRAN_IPV6, vni);
+
+ /* Load the IP header length. We need to account for a
+ * variable length link prefix if there is one. */
+ s = gen_abs_offset_varpart(cstate, &cstate->off_linkpl);
+ if (s) {
+ s1 = new_stmt(cstate, BPF_LD|BPF_IMM);
+ s1->s.k = 40;
+ sappend(s, s1);
+
+ s1 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_X);
+ s1->s.k = 0;
+ sappend(s, s1);
+ } else {
+ s = new_stmt(cstate, BPF_LD|BPF_IMM);
+ s->s.k = 40;
+ }
+
+ /* Forcibly append these statements to the true condition
+ * of the protocol check by creating a new block that is
+ * always true and ANDing them. */
+ s1 = new_stmt(cstate, BPF_MISC|BPF_TAX);
+ sappend(s, s1);
+
+ b1 = new_block(cstate, BPF_JMP|BPF_JEQ|BPF_X);
+ b1->stmts = s;
+ b1->s.k = 0;
+
+ gen_and(b0, b1);
+
+ return b1;
+}
+
+/* We need to store three values based on the Geneve header::
+ * - The offset of the linktype.
+ * - The offset of the end of the Geneve header.
+ * - The offset of the end of the encapsulated MAC header. */
+static struct slist *
+gen_geneve_offsets(compiler_state_t *cstate)
+{
+ struct slist *s, *s1, *s_proto;
+
+ /* First we need to calculate the offset of the Geneve header
+ * itself. This is composed of the IP header previously calculated
+ * (include any variable link prefix) and stored in A plus the
+ * fixed sized headers (fixed link prefix, MAC length, and UDP
+ * header). */
+ s = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
+ s->s.k = cstate->off_linkpl.constant_part + cstate->off_nl + 8;
+
+ /* Stash this in X since we'll need it later. */
+ s1 = new_stmt(cstate, BPF_MISC|BPF_TAX);
+ sappend(s, s1);
+
+ /* The EtherType in Geneve is 2 bytes in. Calculate this and
+ * store it. */
+ s1 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
+ s1->s.k = 2;
+ sappend(s, s1);
+
+ cstate->off_linktype.reg = alloc_reg(cstate);
+ cstate->off_linktype.is_variable = 1;
+ cstate->off_linktype.constant_part = 0;
+
+ s1 = new_stmt(cstate, BPF_ST);
+ s1->s.k = cstate->off_linktype.reg;
+ sappend(s, s1);
+
+ /* Load the Geneve option length and mask and shift to get the
+ * number of bytes. It is stored in the first byte of the Geneve
+ * header. */
+ s1 = new_stmt(cstate, BPF_LD|BPF_IND|BPF_B);
+ s1->s.k = 0;
+ sappend(s, s1);
+
+ s1 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
+ s1->s.k = 0x3f;
+ sappend(s, s1);
+
+ s1 = new_stmt(cstate, BPF_ALU|BPF_MUL|BPF_K);
+ s1->s.k = 4;
+ sappend(s, s1);
+
+ /* Add in the rest of the Geneve base header. */
+ s1 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
+ s1->s.k = 8;
+ sappend(s, s1);
+
+ /* Add the Geneve header length to its offset and store. */
+ s1 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_X);
+ s1->s.k = 0;
+ sappend(s, s1);
+
+ /* Set the encapsulated type as Ethernet. Even though we may
+ * not actually have Ethernet inside there are two reasons this
+ * is useful:
+ * - The linktype field is always in EtherType format regardless
+ * of whether it is in Geneve or an inner Ethernet frame.
+ * - The only link layer that we have specific support for is
+ * Ethernet. We will confirm that the packet actually is
+ * Ethernet at runtime before executing these checks. */
+ PUSH_LINKHDR(cstate, DLT_EN10MB, 1, 0, alloc_reg(cstate));
+
+ s1 = new_stmt(cstate, BPF_ST);
+ s1->s.k = cstate->off_linkhdr.reg;
+ sappend(s, s1);
+
+ /* Calculate whether we have an Ethernet header or just raw IP/
+ * MPLS/etc. If we have Ethernet, advance the end of the MAC offset
+ * and linktype by 14 bytes so that the network header can be found
+ * seamlessly. Otherwise, keep what we've calculated already. */
+
+ /* We have a bare jmp so we can't use the optimizer. */
+ cstate->no_optimize = 1;
+
+ /* Load the EtherType in the Geneve header, 2 bytes in. */
+ s1 = new_stmt(cstate, BPF_LD|BPF_IND|BPF_H);
+ s1->s.k = 2;
+ sappend(s, s1);
+
+ /* Load X with the end of the Geneve header. */
+ s1 = new_stmt(cstate, BPF_LDX|BPF_MEM);
+ s1->s.k = cstate->off_linkhdr.reg;
+ sappend(s, s1);
+
+ /* Check if the EtherType is Transparent Ethernet Bridging. At the
+ * end of this check, we should have the total length in X. In
+ * the non-Ethernet case, it's already there. */
+ s_proto = new_stmt(cstate, JMP(BPF_JEQ));
+ s_proto->s.k = ETHERTYPE_TEB;
+ sappend(s, s_proto);
+
+ s1 = new_stmt(cstate, BPF_MISC|BPF_TXA);
+ sappend(s, s1);
+ s_proto->s.jt = s1;
+
+ /* Since this is Ethernet, use the EtherType of the payload
+ * directly as the linktype. Overwrite what we already have. */
+ s1 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
+ s1->s.k = 12;
+ sappend(s, s1);
+
+ s1 = new_stmt(cstate, BPF_ST);
+ s1->s.k = cstate->off_linktype.reg;
+ sappend(s, s1);
+
+ /* Advance two bytes further to get the end of the Ethernet
+ * header. */
+ s1 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
+ s1->s.k = 2;
+ sappend(s, s1);
+
+ /* Move the result to X. */
+ s1 = new_stmt(cstate, BPF_MISC|BPF_TAX);
+ sappend(s, s1);
+
+ /* Store the final result of our linkpl calculation. */
+ cstate->off_linkpl.reg = alloc_reg(cstate);
+ cstate->off_linkpl.is_variable = 1;
+ cstate->off_linkpl.constant_part = 0;
+
+ s1 = new_stmt(cstate, BPF_STX);
+ s1->s.k = cstate->off_linkpl.reg;
+ sappend(s, s1);
+ s_proto->s.jf = s1;
+
+ cstate->off_nl = 0;
+
+ return s;
+}
+
+/* Check to see if this is a Geneve packet. */
+struct block *
+gen_geneve(compiler_state_t *cstate, int vni)
+{
+ struct block *b0, *b1;
+ struct slist *s;
+
+ b0 = gen_geneve4(cstate, vni);
+ b1 = gen_geneve6(cstate, vni);
+
+ gen_or(b0, b1);
+ b0 = b1;
+
+ /* Later filters should act on the payload of the Geneve frame,
+ * update all of the header pointers. Attach this code so that
+ * it gets executed in the event that the Geneve filter matches. */
+ s = gen_geneve_offsets(cstate);
+
+ b1 = gen_true(cstate);
+ sappend(s, b1->stmts);
+ b1->stmts = s;
+
+ gen_and(b0, b1);
+
+ cstate->is_geneve = 1;
+
+ return b1;
+}
+
+/* Check that the encapsulated frame has a link layer header
+ * for Ethernet filters. */
+static struct block *
+gen_geneve_ll_check(compiler_state_t *cstate)
+{
+ struct block *b0;
+ struct slist *s, *s1;
+
+ /* The easiest way to see if there is a link layer present
+ * is to check if the link layer header and payload are not
+ * the same. */
+
+ /* Geneve always generates pure variable offsets so we can
+ * compare only the registers. */
+ s = new_stmt(cstate, BPF_LD|BPF_MEM);
+ s->s.k = cstate->off_linkhdr.reg;
+
+ s1 = new_stmt(cstate, BPF_LDX|BPF_MEM);
+ s1->s.k = cstate->off_linkpl.reg;
+ sappend(s, s1);
+
+ b0 = new_block(cstate, BPF_JMP|BPF_JEQ|BPF_X);
+ b0->stmts = s;
+ b0->s.k = 0;
+ gen_not(b0);
return b0;
}
struct block *
-gen_atmfield_code(atmfield, jvalue, jtype, reverse)
- int atmfield;
- bpf_int32 jvalue;
- bpf_u_int32 jtype;
- int reverse;
+gen_atmfield_code(compiler_state_t *cstate, int atmfield, bpf_int32 jvalue,
+ bpf_u_int32 jtype, int reverse)
{
struct block *b0;
switch (atmfield) {
case A_VPI:
- if (!is_atm)
- bpf_error("'vpi' supported only on raw ATM");
- if (off_vpi == (u_int)-1)
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'vpi' supported only on raw ATM");
+ if (cstate->off_vpi == (u_int)-1)
abort();
- b0 = gen_ncmp(OR_LINK, off_vpi, BPF_B, 0xffffffff, jtype,
+ b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_vpi, BPF_B, 0xffffffff, jtype,
reverse, jvalue);
break;
case A_VCI:
- if (!is_atm)
- bpf_error("'vci' supported only on raw ATM");
- if (off_vci == (u_int)-1)
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'vci' supported only on raw ATM");
+ if (cstate->off_vci == (u_int)-1)
abort();
- b0 = gen_ncmp(OR_LINK, off_vci, BPF_H, 0xffffffff, jtype,
+ b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_vci, BPF_H, 0xffffffff, jtype,
reverse, jvalue);
break;
case A_PROTOTYPE:
- if (off_proto == (u_int)-1)
+ if (cstate->off_proto == (u_int)-1)
abort(); /* XXX - this isn't on FreeBSD */
- b0 = gen_ncmp(OR_LINK, off_proto, BPF_B, 0x0f, jtype,
+ b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_proto, BPF_B, 0x0f, jtype,
reverse, jvalue);
break;
case A_MSGTYPE:
- if (off_payload == (u_int)-1)
+ if (cstate->off_payload == (u_int)-1)
abort();
- b0 = gen_ncmp(OR_LINK, off_payload + MSG_TYPE_POS, BPF_B,
+ b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_payload + MSG_TYPE_POS, BPF_B,
0xffffffff, jtype, reverse, jvalue);
break;
case A_CALLREFTYPE:
- if (!is_atm)
- bpf_error("'callref' supported only on raw ATM");
- if (off_proto == (u_int)-1)
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'callref' supported only on raw ATM");
+ if (cstate->off_proto == (u_int)-1)
abort();
- b0 = gen_ncmp(OR_LINK, off_proto, BPF_B, 0xffffffff,
+ b0 = gen_ncmp(cstate, OR_LINKHDR, cstate->off_proto, BPF_B, 0xffffffff,
jtype, reverse, jvalue);
break;
@@ -8152,8 +8606,7 @@ gen_atmfield_code(atmfield, jvalue, jtype, reverse)
}
struct block *
-gen_atmtype_abbrev(type)
- int type;
+gen_atmtype_abbrev(compiler_state_t *cstate, int type)
{
struct block *b0, *b1;
@@ -8161,63 +8614,63 @@ gen_atmtype_abbrev(type)
case A_METAC:
/* Get all packets in Meta signalling Circuit */
- if (!is_atm)
- bpf_error("'metac' supported only on raw ATM");
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 1, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'metac' supported only on raw ATM");
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 1, BPF_JEQ, 0);
gen_and(b0, b1);
break;
case A_BCC:
/* Get all packets in Broadcast Circuit*/
- if (!is_atm)
- bpf_error("'bcc' supported only on raw ATM");
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 2, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'bcc' supported only on raw ATM");
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 2, BPF_JEQ, 0);
gen_and(b0, b1);
break;
case A_OAMF4SC:
/* Get all cells in Segment OAM F4 circuit*/
- if (!is_atm)
- bpf_error("'oam4sc' supported only on raw ATM");
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 3, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'oam4sc' supported only on raw ATM");
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 3, BPF_JEQ, 0);
gen_and(b0, b1);
break;
case A_OAMF4EC:
/* Get all cells in End-to-End OAM F4 Circuit*/
- if (!is_atm)
- bpf_error("'oam4ec' supported only on raw ATM");
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 4, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'oam4ec' supported only on raw ATM");
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 4, BPF_JEQ, 0);
gen_and(b0, b1);
break;
case A_SC:
/* Get all packets in connection Signalling Circuit */
- if (!is_atm)
- bpf_error("'sc' supported only on raw ATM");
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 5, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'sc' supported only on raw ATM");
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 5, BPF_JEQ, 0);
gen_and(b0, b1);
break;
case A_ILMIC:
/* Get all packets in ILMI Circuit */
- if (!is_atm)
- bpf_error("'ilmic' supported only on raw ATM");
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 16, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'ilmic' supported only on raw ATM");
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 16, BPF_JEQ, 0);
gen_and(b0, b1);
break;
case A_LANE:
/* Get all LANE packets */
- if (!is_atm)
- bpf_error("'lane' supported only on raw ATM");
- b1 = gen_atmfield_code(A_PROTOTYPE, PT_LANE, BPF_JEQ, 0);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'lane' supported only on raw ATM");
+ b1 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LANE, BPF_JEQ, 0);
/*
* Arrange that all subsequent tests assume LANE
@@ -8225,26 +8678,23 @@ gen_atmtype_abbrev(type)
* the offsets appropriately for LANE-encapsulated
* Ethernet.
*
- * "off_mac" is the offset of the Ethernet header,
- * which is 2 bytes past the ATM pseudo-header
- * (skipping the pseudo-header and 2-byte LE Client
- * field). The other offsets are Ethernet offsets
- * relative to "off_mac".
+ * We assume LANE means Ethernet, not Token Ring.
*/
- is_lane = 1;
- off_mac = off_payload + 2; /* MAC header */
- off_linktype = off_mac + 12;
- off_macpl = off_mac + 14; /* Ethernet */
- off_nl = 0; /* Ethernet II */
- off_nl_nosnap = 3; /* 802.3+802.2 */
+ PUSH_LINKHDR(cstate, DLT_EN10MB, 0,
+ cstate->off_payload + 2, /* Ethernet header */
+ -1);
+ cstate->off_linktype.constant_part = cstate->off_linkhdr.constant_part + 12;
+ cstate->off_linkpl.constant_part = cstate->off_linkhdr.constant_part + 14; /* Ethernet */
+ cstate->off_nl = 0; /* Ethernet II */
+ cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
break;
case A_LLC:
/* Get all LLC-encapsulated packets */
- if (!is_atm)
- bpf_error("'llc' supported only on raw ATM");
- b1 = gen_atmfield_code(A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
- is_lane = 0;
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'llc' supported only on raw ATM");
+ b1 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
+ cstate->linktype = cstate->prevlinktype;
break;
default:
@@ -8258,40 +8708,67 @@ gen_atmtype_abbrev(type)
* FISU, length is null
* LSSU, length is 1 or 2
* MSU, length is 3 or more
+ * For MTP2_HSL, sequences are on 2 bytes, and length on 9 bits
*/
struct block *
-gen_mtp2type_abbrev(type)
- int type;
+gen_mtp2type_abbrev(compiler_state_t *cstate, int type)
{
struct block *b0, *b1;
switch (type) {
case M_FISU:
- if ( (linktype != DLT_MTP2) &&
- (linktype != DLT_ERF) &&
- (linktype != DLT_MTP2_WITH_PHDR) )
- bpf_error("'fisu' supported only on MTP2");
- /* gen_ncmp(offrel, offset, size, mask, jtype, reverse, value) */
- b0 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JEQ, 0, 0);
+ if ( (cstate->linktype != DLT_MTP2) &&
+ (cstate->linktype != DLT_ERF) &&
+ (cstate->linktype != DLT_MTP2_WITH_PHDR) )
+ bpf_error(cstate, "'fisu' supported only on MTP2");
+ /* gen_ncmp(cstate, offrel, offset, size, mask, jtype, reverse, value) */
+ b0 = gen_ncmp(cstate, OR_PACKET, cstate->off_li, BPF_B, 0x3f, BPF_JEQ, 0, 0);
break;
case M_LSSU:
- if ( (linktype != DLT_MTP2) &&
- (linktype != DLT_ERF) &&
- (linktype != DLT_MTP2_WITH_PHDR) )
- bpf_error("'lssu' supported only on MTP2");
- b0 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JGT, 1, 2);
- b1 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JGT, 0, 0);
+ if ( (cstate->linktype != DLT_MTP2) &&
+ (cstate->linktype != DLT_ERF) &&
+ (cstate->linktype != DLT_MTP2_WITH_PHDR) )
+ bpf_error(cstate, "'lssu' supported only on MTP2");
+ b0 = gen_ncmp(cstate, OR_PACKET, cstate->off_li, BPF_B, 0x3f, BPF_JGT, 1, 2);
+ b1 = gen_ncmp(cstate, OR_PACKET, cstate->off_li, BPF_B, 0x3f, BPF_JGT, 0, 0);
gen_and(b1, b0);
break;
case M_MSU:
- if ( (linktype != DLT_MTP2) &&
- (linktype != DLT_ERF) &&
- (linktype != DLT_MTP2_WITH_PHDR) )
- bpf_error("'msu' supported only on MTP2");
- b0 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JGT, 0, 2);
+ if ( (cstate->linktype != DLT_MTP2) &&
+ (cstate->linktype != DLT_ERF) &&
+ (cstate->linktype != DLT_MTP2_WITH_PHDR) )
+ bpf_error(cstate, "'msu' supported only on MTP2");
+ b0 = gen_ncmp(cstate, OR_PACKET, cstate->off_li, BPF_B, 0x3f, BPF_JGT, 0, 2);
+ break;
+
+ case MH_FISU:
+ if ( (cstate->linktype != DLT_MTP2) &&
+ (cstate->linktype != DLT_ERF) &&
+ (cstate->linktype != DLT_MTP2_WITH_PHDR) )
+ bpf_error(cstate, "'hfisu' supported only on MTP2_HSL");
+ /* gen_ncmp(cstate, offrel, offset, size, mask, jtype, reverse, value) */
+ b0 = gen_ncmp(cstate, OR_PACKET, cstate->off_li_hsl, BPF_H, 0xff80, BPF_JEQ, 0, 0);
+ break;
+
+ case MH_LSSU:
+ if ( (cstate->linktype != DLT_MTP2) &&
+ (cstate->linktype != DLT_ERF) &&
+ (cstate->linktype != DLT_MTP2_WITH_PHDR) )
+ bpf_error(cstate, "'hlssu' supported only on MTP2_HSL");
+ b0 = gen_ncmp(cstate, OR_PACKET, cstate->off_li_hsl, BPF_H, 0xff80, BPF_JGT, 1, 0x0100);
+ b1 = gen_ncmp(cstate, OR_PACKET, cstate->off_li_hsl, BPF_H, 0xff80, BPF_JGT, 0, 0);
+ gen_and(b1, b0);
+ break;
+
+ case MH_MSU:
+ if ( (cstate->linktype != DLT_MTP2) &&
+ (cstate->linktype != DLT_ERF) &&
+ (cstate->linktype != DLT_MTP2_WITH_PHDR) )
+ bpf_error(cstate, "'hmsu' supported only on MTP2_HSL");
+ b0 = gen_ncmp(cstate, OR_PACKET, cstate->off_li_hsl, BPF_H, 0xff80, BPF_JGT, 0, 0x0100);
break;
default:
@@ -8301,34 +8778,41 @@ gen_mtp2type_abbrev(type)
}
struct block *
-gen_mtp3field_code(mtp3field, jvalue, jtype, reverse)
- int mtp3field;
- bpf_u_int32 jvalue;
- bpf_u_int32 jtype;
- int reverse;
+gen_mtp3field_code(compiler_state_t *cstate, int mtp3field, bpf_u_int32 jvalue,
+ bpf_u_int32 jtype, int reverse)
{
struct block *b0;
bpf_u_int32 val1 , val2 , val3;
+ u_int newoff_sio = cstate->off_sio;
+ u_int newoff_opc = cstate->off_opc;
+ u_int newoff_dpc = cstate->off_dpc;
+ u_int newoff_sls = cstate->off_sls;
switch (mtp3field) {
+ case MH_SIO:
+ newoff_sio += 3; /* offset for MTP2_HSL */
+ /* FALLTHROUGH */
+
case M_SIO:
- if (off_sio == (u_int)-1)
- bpf_error("'sio' supported only on SS7");
+ if (cstate->off_sio == (u_int)-1)
+ bpf_error(cstate, "'sio' supported only on SS7");
/* sio coded on 1 byte so max value 255 */
if(jvalue > 255)
- bpf_error("sio value %u too big; max value = 255",
+ bpf_error(cstate, "sio value %u too big; max value = 255",
jvalue);
- b0 = gen_ncmp(OR_PACKET, off_sio, BPF_B, 0xffffffff,
+ b0 = gen_ncmp(cstate, OR_PACKET, newoff_sio, BPF_B, 0xffffffff,
(u_int)jtype, reverse, (u_int)jvalue);
break;
+ case MH_OPC:
+ newoff_opc+=3;
case M_OPC:
- if (off_opc == (u_int)-1)
- bpf_error("'opc' supported only on SS7");
+ if (cstate->off_opc == (u_int)-1)
+ bpf_error(cstate, "'opc' supported only on SS7");
/* opc coded on 14 bits so max value 16383 */
if (jvalue > 16383)
- bpf_error("opc value %u too big; max value = 16383",
+ bpf_error(cstate, "opc value %u too big; max value = 16383",
jvalue);
/* the following instructions are made to convert jvalue
* to the form used to write opc in an ss7 message*/
@@ -8339,16 +8823,20 @@ gen_mtp3field_code(mtp3field, jvalue, jtype, reverse)
val3 = jvalue & 0x00000003;
val3 = val3 <<22;
jvalue = val1 + val2 + val3;
- b0 = gen_ncmp(OR_PACKET, off_opc, BPF_W, 0x00c0ff0f,
+ b0 = gen_ncmp(cstate, OR_PACKET, newoff_opc, BPF_W, 0x00c0ff0f,
(u_int)jtype, reverse, (u_int)jvalue);
break;
+ case MH_DPC:
+ newoff_dpc += 3;
+ /* FALLTHROUGH */
+
case M_DPC:
- if (off_dpc == (u_int)-1)
- bpf_error("'dpc' supported only on SS7");
+ if (cstate->off_dpc == (u_int)-1)
+ bpf_error(cstate, "'dpc' supported only on SS7");
/* dpc coded on 14 bits so max value 16383 */
if (jvalue > 16383)
- bpf_error("dpc value %u too big; max value = 16383",
+ bpf_error(cstate, "dpc value %u too big; max value = 16383",
jvalue);
/* the following instructions are made to convert jvalue
* to the forme used to write dpc in an ss7 message*/
@@ -8357,21 +8845,23 @@ gen_mtp3field_code(mtp3field, jvalue, jtype, reverse)
val2 = jvalue & 0x00003f00;
val2 = val2 << 8;
jvalue = val1 + val2;
- b0 = gen_ncmp(OR_PACKET, off_dpc, BPF_W, 0xff3f0000,
+ b0 = gen_ncmp(cstate, OR_PACKET, newoff_dpc, BPF_W, 0xff3f0000,
(u_int)jtype, reverse, (u_int)jvalue);
break;
+ case MH_SLS:
+ newoff_sls+=3;
case M_SLS:
- if (off_sls == (u_int)-1)
- bpf_error("'sls' supported only on SS7");
+ if (cstate->off_sls == (u_int)-1)
+ bpf_error(cstate, "'sls' supported only on SS7");
/* sls coded on 4 bits so max value 15 */
if (jvalue > 15)
- bpf_error("sls value %u too big; max value = 15",
+ bpf_error(cstate, "sls value %u too big; max value = 15",
jvalue);
/* the following instruction is made to convert jvalue
* to the forme used to write sls in an ss7 message*/
jvalue = jvalue << 4;
- b0 = gen_ncmp(OR_PACKET, off_sls, BPF_B, 0xf0,
+ b0 = gen_ncmp(cstate, OR_PACKET, newoff_sls, BPF_B, 0xf0,
(u_int)jtype,reverse, (u_int)jvalue);
break;
@@ -8382,8 +8872,7 @@ gen_mtp3field_code(mtp3field, jvalue, jtype, reverse)
}
static struct block *
-gen_msg_abbrev(type)
- int type;
+gen_msg_abbrev(compiler_state_t *cstate, int type)
{
struct block *b1;
@@ -8394,27 +8883,27 @@ gen_msg_abbrev(type)
switch (type) {
case A_SETUP:
- b1 = gen_atmfield_code(A_MSGTYPE, SETUP, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_MSGTYPE, SETUP, BPF_JEQ, 0);
break;
case A_CALLPROCEED:
- b1 = gen_atmfield_code(A_MSGTYPE, CALL_PROCEED, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_MSGTYPE, CALL_PROCEED, BPF_JEQ, 0);
break;
case A_CONNECT:
- b1 = gen_atmfield_code(A_MSGTYPE, CONNECT, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_MSGTYPE, CONNECT, BPF_JEQ, 0);
break;
case A_CONNECTACK:
- b1 = gen_atmfield_code(A_MSGTYPE, CONNECT_ACK, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_MSGTYPE, CONNECT_ACK, BPF_JEQ, 0);
break;
case A_RELEASE:
- b1 = gen_atmfield_code(A_MSGTYPE, RELEASE, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_MSGTYPE, RELEASE, BPF_JEQ, 0);
break;
case A_RELEASE_DONE:
- b1 = gen_atmfield_code(A_MSGTYPE, RELEASE_DONE, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_MSGTYPE, RELEASE_DONE, BPF_JEQ, 0);
break;
default:
@@ -8424,27 +8913,26 @@ gen_msg_abbrev(type)
}
struct block *
-gen_atmmulti_abbrev(type)
- int type;
+gen_atmmulti_abbrev(compiler_state_t *cstate, int type)
{
struct block *b0, *b1;
switch (type) {
case A_OAM:
- if (!is_atm)
- bpf_error("'oam' supported only on raw ATM");
- b1 = gen_atmmulti_abbrev(A_OAMF4);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'oam' supported only on raw ATM");
+ b1 = gen_atmmulti_abbrev(cstate, A_OAMF4);
break;
case A_OAMF4:
- if (!is_atm)
- bpf_error("'oamf4' supported only on raw ATM");
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'oamf4' supported only on raw ATM");
/* OAM F4 type */
- b0 = gen_atmfield_code(A_VCI, 3, BPF_JEQ, 0);
- b1 = gen_atmfield_code(A_VCI, 4, BPF_JEQ, 0);
+ b0 = gen_atmfield_code(cstate, A_VCI, 3, BPF_JEQ, 0);
+ b1 = gen_atmfield_code(cstate, A_VCI, 4, BPF_JEQ, 0);
gen_or(b0, b1);
- b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
+ b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
gen_and(b0, b1);
break;
@@ -8453,36 +8941,36 @@ gen_atmmulti_abbrev(type)
* Get Q.2931 signalling messages for switched
* virtual connection
*/
- if (!is_atm)
- bpf_error("'connectmsg' supported only on raw ATM");
- b0 = gen_msg_abbrev(A_SETUP);
- b1 = gen_msg_abbrev(A_CALLPROCEED);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'connectmsg' supported only on raw ATM");
+ b0 = gen_msg_abbrev(cstate, A_SETUP);
+ b1 = gen_msg_abbrev(cstate, A_CALLPROCEED);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_CONNECT);
+ b0 = gen_msg_abbrev(cstate, A_CONNECT);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_CONNECTACK);
+ b0 = gen_msg_abbrev(cstate, A_CONNECTACK);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_RELEASE);
+ b0 = gen_msg_abbrev(cstate, A_RELEASE);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_RELEASE_DONE);
+ b0 = gen_msg_abbrev(cstate, A_RELEASE_DONE);
gen_or(b0, b1);
- b0 = gen_atmtype_abbrev(A_SC);
+ b0 = gen_atmtype_abbrev(cstate, A_SC);
gen_and(b0, b1);
break;
case A_METACONNECT:
- if (!is_atm)
- bpf_error("'metaconnect' supported only on raw ATM");
- b0 = gen_msg_abbrev(A_SETUP);
- b1 = gen_msg_abbrev(A_CALLPROCEED);
+ if (!cstate->is_atm)
+ bpf_error(cstate, "'metaconnect' supported only on raw ATM");
+ b0 = gen_msg_abbrev(cstate, A_SETUP);
+ b1 = gen_msg_abbrev(cstate, A_CALLPROCEED);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_CONNECT);
+ b0 = gen_msg_abbrev(cstate, A_CONNECT);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_RELEASE);
+ b0 = gen_msg_abbrev(cstate, A_RELEASE);
gen_or(b0, b1);
- b0 = gen_msg_abbrev(A_RELEASE_DONE);
+ b0 = gen_msg_abbrev(cstate, A_RELEASE_DONE);
gen_or(b0, b1);
- b0 = gen_atmtype_abbrev(A_METAC);
+ b0 = gen_atmtype_abbrev(cstate, A_METAC);
gen_and(b0, b1);
break;
diff --git a/freebsd/contrib/libpcap/gencode.h b/freebsd/contrib/libpcap/gencode.h
index 29d2d10f..2b089d21 100644
--- a/freebsd/contrib/libpcap/gencode.h
+++ b/freebsd/contrib/libpcap/gencode.h
@@ -17,8 +17,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.71 2007-11-18 02:03:52 guy Exp $ (LBL)
*/
/*
@@ -163,7 +161,7 @@
#define A_CONNECTACK 44 /* Connect Ack message */
#define A_RELEASE 45 /* Release message */
#define A_RELEASE_DONE 46 /* Release message */
-
+
/* ATM field types */
#define A_VPI 51
#define A_VCI 52
@@ -186,12 +184,23 @@
#define M_LSSU 23 /* LSSU */
#define M_MSU 24 /* MSU */
+/* MTP2 HSL types */
+#define MH_FISU 25 /* FISU for HSL */
+#define MH_LSSU 26 /* LSSU */
+#define MH_MSU 27 /* MSU */
+
/* MTP3 field types */
#define M_SIO 1
#define M_OPC 2
#define M_DPC 3
#define M_SLS 4
+/* MTP3 field types in case of MTP2 HSL */
+#define MH_SIO 5
+#define MH_OPC 6
+#define MH_DPC 7
+#define MH_SLS 8
+
struct slist;
@@ -272,72 +281,115 @@ struct qual {
unsigned char pad;
};
-struct arth *gen_loadi(int);
-struct arth *gen_load(int, struct arth *, int);
-struct arth *gen_loadlen(void);
-struct arth *gen_neg(struct arth *);
-struct arth *gen_arth(int, struct arth *, struct arth *);
+struct _compiler_state;
+
+typedef struct _compiler_state compiler_state_t;
+
+struct arth *gen_loadi(compiler_state_t *, int);
+struct arth *gen_load(compiler_state_t *, int, struct arth *, int);
+struct arth *gen_loadlen(compiler_state_t *);
+struct arth *gen_neg(compiler_state_t *, struct arth *);
+struct arth *gen_arth(compiler_state_t *, int, struct arth *, struct arth *);
void gen_and(struct block *, struct block *);
void gen_or(struct block *, struct block *);
void gen_not(struct block *);
-struct block *gen_scode(const char *, struct qual);
-struct block *gen_ecode(const u_char *, struct qual);
-struct block *gen_acode(const u_char *, struct qual);
-struct block *gen_mcode(const char *, const char *, int, struct qual);
+struct block *gen_scode(compiler_state_t *, const char *, struct qual);
+struct block *gen_ecode(compiler_state_t *, const u_char *, struct qual);
+struct block *gen_acode(compiler_state_t *, const u_char *, struct qual);
+struct block *gen_mcode(compiler_state_t *, const char *, const char *,
+ unsigned int, struct qual);
#ifdef INET6
-struct block *gen_mcode6(const char *, const char *, int, struct qual);
+struct block *gen_mcode6(compiler_state_t *, const char *, const char *,
+ unsigned int, struct qual);
#endif
-struct block *gen_ncode(const char *, bpf_u_int32, struct qual);
-struct block *gen_proto_abbrev(int);
-struct block *gen_relation(int, struct arth *, struct arth *, int);
-struct block *gen_less(int);
-struct block *gen_greater(int);
-struct block *gen_byteop(int, int, int);
-struct block *gen_broadcast(int);
-struct block *gen_multicast(int);
-struct block *gen_inbound(int);
-
-struct block *gen_vlan(int);
-struct block *gen_mpls(int);
-
-struct block *gen_pppoed(void);
-struct block *gen_pppoes(void);
-
-struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtype, int reverse);
-struct block *gen_atmtype_abbrev(int type);
-struct block *gen_atmmulti_abbrev(int type);
-
-struct block *gen_mtp2type_abbrev(int type);
-struct block *gen_mtp3field_code(int mtp3field, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
-
-struct block *gen_pf_ifname(const char *);
-struct block *gen_pf_rnr(int);
-struct block *gen_pf_srnr(int);
-struct block *gen_pf_ruleset(char *);
-struct block *gen_pf_reason(int);
-struct block *gen_pf_action(int);
-struct block *gen_pf_dir(int);
-
-struct block *gen_p80211_type(int, int);
-struct block *gen_p80211_fcdir(int);
-
-void bpf_optimize(struct block **);
-void bpf_error(const char *, ...)
- __attribute__((noreturn, format (printf, 1, 2)));
-
-void finish_parse(struct block *);
-char *sdup(const char *);
-
-struct bpf_insn *icode_to_fcode(struct block *, u_int *);
-int pcap_parse(void);
-void lex_init(const char *);
-void lex_cleanup(void);
+struct block *gen_ncode(compiler_state_t *, const char *, bpf_u_int32,
+ struct qual);
+struct block *gen_proto_abbrev(compiler_state_t *, int);
+struct block *gen_relation(compiler_state_t *, int, struct arth *,
+ struct arth *, int);
+struct block *gen_less(compiler_state_t *, int);
+struct block *gen_greater(compiler_state_t *, int);
+struct block *gen_byteop(compiler_state_t *, int, int, int);
+struct block *gen_broadcast(compiler_state_t *, int);
+struct block *gen_multicast(compiler_state_t *, int);
+struct block *gen_inbound(compiler_state_t *, int);
+
+struct block *gen_llc(compiler_state_t *);
+struct block *gen_llc_i(compiler_state_t *);
+struct block *gen_llc_s(compiler_state_t *);
+struct block *gen_llc_u(compiler_state_t *);
+struct block *gen_llc_s_subtype(compiler_state_t *, bpf_u_int32);
+struct block *gen_llc_u_subtype(compiler_state_t *, bpf_u_int32);
+
+struct block *gen_vlan(compiler_state_t *, int);
+struct block *gen_mpls(compiler_state_t *, int);
+
+struct block *gen_pppoed(compiler_state_t *);
+struct block *gen_pppoes(compiler_state_t *, int);
+
+struct block *gen_geneve(compiler_state_t *, int);
+
+struct block *gen_atmfield_code(compiler_state_t *, int, bpf_int32,
+ bpf_u_int32, int);
+struct block *gen_atmtype_abbrev(compiler_state_t *, int type);
+struct block *gen_atmmulti_abbrev(compiler_state_t *, int type);
+
+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);
+
+struct block *gen_pf_ifname(compiler_state_t *, const char *);
+struct block *gen_pf_rnr(compiler_state_t *, int);
+struct block *gen_pf_srnr(compiler_state_t *, int);
+struct block *gen_pf_ruleset(compiler_state_t *, char *);
+struct block *gen_pf_reason(compiler_state_t *, int);
+struct block *gen_pf_action(compiler_state_t *, int);
+
+struct block *gen_p80211_type(compiler_state_t *, int, int);
+struct block *gen_p80211_fcdir(compiler_state_t *, int);
+
+/*
+ * Representation of a program as a tree of blocks, plus current mark.
+ * A block is marked if only if its mark equals the current mark.
+ * Rather than traverse the code array, marking each item, 'cur_mark'
+ * is incremented. This automatically makes each element unmarked.
+ */
+#define isMarked(icp, p) ((p)->mark == (icp)->cur_mark)
+#define unMarkAll(icp) (icp)->cur_mark += 1
+#define Mark(icp, p) ((p)->mark = (icp)->cur_mark)
+
+struct icode {
+ struct block *root;
+ int cur_mark;
+};
+
+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 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 *);
+/*
+ * Older versions of Bison don't put this declaration in
+ * grammar.h.
+ */
+int pcap_parse(void *, compiler_state_t *);
+
/* XXX */
#define JT(b) ((b)->et.succ)
#define JF(b) ((b)->ef.succ)
-
-extern int no_optimize;
diff --git a/freebsd/contrib/libpcap/grammar.c b/freebsd/contrib/libpcap/grammar.c
index a0853614..a04f770c 100644
--- a/freebsd/contrib/libpcap/grammar.c
+++ b/freebsd/contrib/libpcap/grammar.c
@@ -5,7 +5,7 @@
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
-#define YYPATCH 20160324
+#define YYPATCH 20170201
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
@@ -15,89 +15,89 @@
#define YYEOF 0
#ifndef yyparse
-#define yyparse pcapparse
+#define yyparse pcap_parse
#endif /* yyparse */
#ifndef yylex
-#define yylex pcaplex
+#define yylex pcap_lex
#endif /* yylex */
#ifndef yyerror
-#define yyerror pcaperror
+#define yyerror pcap_error
#endif /* yyerror */
#ifndef yychar
-#define yychar pcapchar
+#define yychar pcap_char
#endif /* yychar */
#ifndef yyval
-#define yyval pcapval
+#define yyval pcap_val
#endif /* yyval */
#ifndef yylval
-#define yylval pcaplval
+#define yylval pcap_lval
#endif /* yylval */
#ifndef yydebug
-#define yydebug pcapdebug
+#define yydebug pcap_debug
#endif /* yydebug */
#ifndef yynerrs
-#define yynerrs pcapnerrs
+#define yynerrs pcap_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
-#define yyerrflag pcaperrflag
+#define yyerrflag pcap_errflag
#endif /* yyerrflag */
#ifndef yylhs
-#define yylhs pcaplhs
+#define yylhs pcap_lhs
#endif /* yylhs */
#ifndef yylen
-#define yylen pcaplen
+#define yylen pcap_len
#endif /* yylen */
#ifndef yydefred
-#define yydefred pcapdefred
+#define yydefred pcap_defred
#endif /* yydefred */
#ifndef yydgoto
-#define yydgoto pcapdgoto
+#define yydgoto pcap_dgoto
#endif /* yydgoto */
#ifndef yysindex
-#define yysindex pcapsindex
+#define yysindex pcap_sindex
#endif /* yysindex */
#ifndef yyrindex
-#define yyrindex pcaprindex
+#define yyrindex pcap_rindex
#endif /* yyrindex */
#ifndef yygindex
-#define yygindex pcapgindex
+#define yygindex pcap_gindex
#endif /* yygindex */
#ifndef yytable
-#define yytable pcaptable
+#define yytable pcap_table
#endif /* yytable */
#ifndef yycheck
-#define yycheck pcapcheck
+#define yycheck pcap_check
#endif /* yycheck */
#ifndef yyname
-#define yyname pcapname
+#define yyname pcap_name
#endif /* yyname */
#ifndef yyrule
-#define yyrule pcaprule
+#define yyrule pcap_rule
#endif /* yyrule */
-#define YYPREFIX "pcap"
+#define YYPREFIX "pcap_"
-#define YYPURE 0
+#define YYPURE 1
-#line 2 "../../freebsd/contrib/libpcap/grammar.y"
+#line 27 "grammar.y"
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -120,25 +120,21 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.101 2007-11-18 02:03:52 guy Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdlib.h>
-#ifndef WIN32
+#ifndef _WIN32
#if __STDC__
struct mbuf;
struct rtentry;
@@ -146,18 +142,22 @@ struct rtentry;
#include <netinet/in.h>
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdio.h>
#include "pcap-int.h"
#include "gencode.h"
+#include "grammar.h"
+#include "scanner.h"
+
#ifdef HAVE_NET_PFVAR_H
#include <net/if.h>
-#include <net/pfvar.h>
+#include <netpfil/pf/pf.h>
#include <net/if_pflog.h>
#endif
+#include "llc.h"
#include "ieee80211.h"
#include <pcap/namedb.h>
@@ -232,6 +232,23 @@ static const struct tok ieee80211_data_subtypes[] = {
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL, "qos-cf-ack-poll" },
{ 0, NULL }
};
+static const struct tok llc_s_subtypes[] = {
+ { LLC_RR, "rr" },
+ { LLC_RNR, "rnr" },
+ { LLC_REJ, "rej" },
+ { 0, NULL }
+};
+static const struct tok llc_u_subtypes[] = {
+ { LLC_UI, "ui" },
+ { LLC_UA, "ua" },
+ { LLC_DISC, "disc" },
+ { LLC_DM, "dm" },
+ { LLC_SABME, "sabme" },
+ { LLC_TEST, "test" },
+ { LLC_XID, "xid" },
+ { LLC_FRMR, "frmr" },
+ { 0, NULL }
+};
struct type2tok {
int type;
const struct tok *tok;
@@ -255,31 +272,18 @@ str2tok(const char *str, const struct tok *toks)
return (-1);
}
-int n_errors = 0;
-
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
static void
-yyerror(const char *msg)
+yyerror(void *yyscanner, compiler_state_t *cstate, const char *msg)
{
- ++n_errors;
- bpf_error("%s", msg);
+ bpf_syntax_error(cstate, msg);
/* NOTREACHED */
}
-#ifdef NEED_YYPARSE_WRAPPER
-int yyparse(void);
-
-int
-pcap_parse()
-{
- return (yyparse());
-}
-#endif
-
#ifdef HAVE_NET_PFVAR_H
static int
-pfreason_to_num(const char *reason)
+pfreason_to_num(compiler_state_t *cstate, const char *reason)
{
const char *reasons[] = PFRES_NAMES;
int i;
@@ -288,12 +292,12 @@ pfreason_to_num(const char *reason)
if (pcap_strcasecmp(reason, reasons[i]) == 0)
return (i);
}
- bpf_error("unknown PF reason");
+ bpf_error(cstate, "unknown PF reason");
/*NOTREACHED*/
}
static int
-pfaction_to_num(const char *action)
+pfaction_to_num(compiler_state_t *cstate, const char *action)
{
if (pcap_strcasecmp(action, "pass") == 0 ||
pcap_strcasecmp(action, "accept") == 0)
@@ -312,15 +316,15 @@ pfaction_to_num(const char *action)
return (PF_NORDR);
#endif
else {
- bpf_error("unknown PF action");
+ bpf_error(cstate, "unknown PF action");
/*NOTREACHED*/
}
}
#else /* !HAVE_NET_PFVAR_H */
static int
-pfreason_to_num(const char *reason)
+pfreason_to_num(compiler_state_t *cstate, const char *reason)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/*NOTREACHED*/
/* this is to make the VC compiler happy */
@@ -328,22 +332,22 @@ pfreason_to_num(const char *reason)
}
static int
-pfaction_to_num(const char *action)
+pfaction_to_num(compiler_state_t *cstate, const char *action)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ 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 */
-#line 243 "../../freebsd/contrib/libpcap/grammar.y"
#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"
typedef union {
int i;
bpf_u_int32 h;
@@ -360,7 +364,7 @@ typedef union {
struct block *rblk;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
-#line 364 "pcap.tab.c"
+#line 368 "grammar.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -371,24 +375,28 @@ typedef union {
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
-# define YYPARSE_DECL() yyparse(void)
+# define YYPARSE_DECL() yyparse(void *yyscanner, compiler_state_t *cstate)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
-# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
-# define YYLEX yylex(YYLEX_PARAM)
+# ifdef YYLEX_PARAM_TYPE
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
+# else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
+# endif
+# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
-# define YYLEX_DECL() yylex(void)
-# define YYLEX yylex()
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *yyscanner)
+# define YYLEX yylex(&yylval, yyscanner)
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
-#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_DECL() yyerror(void *yyscanner, compiler_state_t *cstate, const char *s)
#endif
#ifndef YYERROR_CALL
-#define YYERROR_CALL(msg) yyerror(msg)
+#define YYERROR_CALL(msg) yyerror(yyscanner, cstate, msg)
#endif
extern int YYPARSE_DECL();
@@ -465,48 +473,56 @@ extern int YYPARSE_DECL();
#define MPLS 326
#define PPPOED 327
#define PPPOES 328
-#define ISO 329
-#define ESIS 330
-#define CLNP 331
-#define ISIS 332
-#define L1 333
-#define L2 334
-#define IIH 335
-#define LSP 336
-#define SNP 337
-#define CSNP 338
-#define PSNP 339
-#define STP 340
-#define IPX 341
-#define NETBEUI 342
-#define LANE 343
-#define LLC 344
-#define METAC 345
-#define BCC 346
-#define SC 347
-#define ILMIC 348
-#define OAMF4EC 349
-#define OAMF4SC 350
-#define OAM 351
-#define OAMF4 352
-#define CONNECTMSG 353
-#define METACONNECT 354
-#define VPI 355
-#define VCI 356
-#define RADIO 357
-#define FISU 358
-#define LSSU 359
-#define MSU 360
-#define SIO 361
-#define OPC 362
-#define DPC 363
-#define SLS 364
-#define OR 365
-#define AND 366
-#define UMINUS 367
+#define GENEVE 329
+#define ISO 330
+#define ESIS 331
+#define CLNP 332
+#define ISIS 333
+#define L1 334
+#define L2 335
+#define IIH 336
+#define LSP 337
+#define SNP 338
+#define CSNP 339
+#define PSNP 340
+#define STP 341
+#define IPX 342
+#define NETBEUI 343
+#define LANE 344
+#define LLC 345
+#define METAC 346
+#define BCC 347
+#define SC 348
+#define ILMIC 349
+#define OAMF4EC 350
+#define OAMF4SC 351
+#define OAM 352
+#define OAMF4 353
+#define CONNECTMSG 354
+#define METACONNECT 355
+#define VPI 356
+#define VCI 357
+#define RADIO 358
+#define FISU 359
+#define LSSU 360
+#define MSU 361
+#define HFISU 362
+#define HLSSU 363
+#define HMSU 364
+#define SIO 365
+#define OPC 366
+#define DPC 367
+#define SLS 368
+#define HSIO 369
+#define HOPC 370
+#define HDPC 371
+#define HSLS 372
+#define OR 373
+#define AND 374
+#define UMINUS 375
#define YYERRCODE 256
typedef int YYINT;
-static const YYINT pcaplhs[] = { -1,
+static const YYINT pcap_lhs[] = { -1,
0, 0, 24, 1, 1, 1, 1, 1, 20, 21,
2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
3, 3, 23, 22, 4, 4, 4, 7, 7, 5,
@@ -519,17 +535,18 @@ static const YYINT pcaplhs[] = { -1,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 26, 26, 26, 26, 26, 26, 27, 27, 27,
- 27, 41, 41, 42, 42, 43, 44, 44, 40, 40,
- 39, 18, 18, 18, 19, 19, 19, 13, 13, 14,
+ 25, 25, 25, 25, 25, 26, 26, 26, 26, 26,
+ 26, 27, 27, 27, 27, 42, 42, 43, 43, 44,
+ 28, 28, 28, 45, 45, 41, 41, 40, 18, 18,
+ 18, 19, 19, 19, 13, 13, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 15, 15, 15, 15, 15, 17, 17, 28,
- 28, 28, 28, 28, 28, 28, 28, 29, 29, 29,
- 29, 30, 30, 32, 32, 32, 32, 31, 33, 33,
- 34, 34, 34, 35, 35, 35, 35, 37, 37, 37,
- 37, 36, 38, 38,
+ 14, 15, 15, 15, 15, 15, 17, 17, 29, 29,
+ 29, 29, 29, 29, 29, 30, 30, 30, 30, 31,
+ 31, 33, 33, 33, 33, 32, 34, 34, 35, 35,
+ 35, 35, 35, 35, 36, 36, 36, 36, 36, 36,
+ 36, 36, 38, 38, 38, 38, 37, 39, 39,
};
-static const YYINT pcaplen[] = { 2,
+static const YYINT pcap_len[] = { 2,
2, 1, 0, 1, 3, 3, 3, 3, 1, 1,
1, 1, 3, 1, 3, 3, 1, 3, 1, 1,
1, 2, 1, 1, 1, 3, 3, 1, 1, 1,
@@ -541,374 +558,426 @@ static const YYINT pcaplen[] = { 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
- 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 4, 2, 2,
- 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 4,
- 6, 3, 3, 3, 3, 3, 3, 3, 3, 2,
- 3, 1, 1, 1, 1, 1, 1, 1, 3, 1,
+ 4, 1, 1, 2, 1, 2, 1, 1, 2, 1,
+ 2, 1, 1, 2, 1, 2, 2, 2, 2, 2,
+ 2, 4, 2, 2, 2, 1, 1, 1, 1, 1,
+ 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 4, 6, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 2, 3,
+ 1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 2, 2, 3, 1, 1, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
- 3, 1, 1, 3,
+ 1, 1, 2, 2, 3, 1, 1, 3, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 2, 2, 3, 1, 1, 3,
};
-static const YYINT pcapdefred[] = { 3,
+static const YYINT pcap_defred[] = { 3,
0, 0, 0, 0, 0, 70, 71, 69, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
- 84, 85, 87, 86, 168, 112, 113, 0, 0, 0,
- 0, 0, 0, 68, 162, 88, 89, 90, 91, 0,
- 0, 118, 119, 92, 93, 102, 94, 95, 96, 97,
- 98, 99, 101, 100, 103, 104, 105, 170, 171, 172,
- 173, 176, 177, 174, 175, 178, 179, 180, 181, 182,
- 183, 106, 191, 192, 193, 194, 195, 196, 197, 23,
- 0, 24, 0, 4, 30, 0, 0, 0, 149, 0,
- 148, 0, 0, 43, 120, 44, 45, 0, 47, 0,
- 109, 110, 0, 122, 123, 124, 125, 139, 140, 126,
- 141, 127, 114, 0, 116, 160, 0, 0, 10, 9,
- 0, 0, 14, 20, 0, 0, 21, 38, 11, 12,
- 0, 0, 0, 0, 63, 67, 64, 65, 66, 35,
- 36, 107, 108, 0, 0, 0, 57, 58, 59, 60,
- 61, 62, 0, 34, 37, 121, 143, 145, 147, 0,
- 0, 0, 0, 0, 0, 0, 0, 142, 144, 146,
- 0, 0, 0, 0, 0, 0, 31, 188, 0, 0,
- 0, 184, 46, 202, 0, 0, 0, 198, 48, 164,
- 163, 166, 167, 165, 0, 0, 0, 6, 5, 0,
- 0, 0, 8, 7, 0, 0, 0, 25, 0, 0,
- 0, 22, 0, 0, 0, 0, 132, 133, 0, 136,
- 130, 137, 138, 131, 32, 0, 0, 0, 0, 0,
- 0, 154, 155, 0, 0, 0, 39, 161, 169, 185,
- 186, 189, 0, 199, 200, 203, 0, 111, 0, 16,
- 15, 18, 13, 0, 0, 54, 56, 53, 55, 0,
- 150, 0, 187, 0, 201, 0, 26, 27, 134, 135,
- 128, 0, 190, 204, 151,
+ 84, 85, 87, 86, 177, 112, 113, 0, 0, 0,
+ 0, 0, 0, 68, 171, 88, 89, 90, 91, 0,
+ 0, 118, 0, 0, 92, 93, 102, 94, 95, 96,
+ 97, 98, 99, 101, 100, 103, 104, 105, 179, 0,
+ 180, 181, 184, 185, 182, 183, 186, 187, 188, 189,
+ 190, 191, 106, 199, 200, 201, 202, 203, 204, 205,
+ 206, 207, 208, 209, 210, 211, 212, 23, 0, 24,
+ 0, 4, 30, 0, 0, 0, 156, 0, 155, 0,
+ 0, 43, 123, 125, 44, 45, 0, 47, 0, 109,
+ 110, 0, 126, 127, 128, 129, 146, 147, 130, 148,
+ 131, 114, 0, 116, 119, 121, 143, 142, 0, 0,
+ 0, 10, 9, 0, 0, 14, 20, 0, 0, 21,
+ 38, 11, 12, 0, 0, 0, 0, 63, 67, 64,
+ 65, 66, 35, 36, 107, 108, 0, 0, 0, 57,
+ 58, 59, 60, 61, 62, 0, 34, 37, 124, 150,
+ 152, 154, 0, 0, 0, 0, 0, 0, 0, 0,
+ 149, 151, 153, 0, 0, 0, 0, 0, 0, 0,
+ 0, 31, 196, 0, 0, 0, 192, 46, 217, 0,
+ 0, 0, 213, 48, 173, 172, 175, 176, 174, 0,
+ 0, 0, 6, 5, 0, 0, 0, 8, 7, 0,
+ 0, 0, 25, 0, 0, 0, 22, 0, 0, 0,
+ 0, 136, 137, 0, 140, 134, 144, 145, 135, 32,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 39, 170, 178, 193, 194, 197, 0,
+ 214, 215, 218, 0, 111, 0, 16, 15, 18, 13,
+ 0, 0, 54, 56, 53, 55, 0, 157, 0, 195,
+ 0, 216, 0, 26, 27, 138, 139, 132, 0, 198,
+ 219, 158,
};
-static const YYINT pcapdgoto[] = { 1,
- 174, 212, 129, 209, 84, 85, 210, 86, 87, 153,
- 154, 155, 88, 89, 195, 117, 91, 171, 172, 121,
- 122, 118, 132, 2, 94, 95, 156, 96, 97, 98,
- 182, 183, 243, 99, 100, 188, 189, 247, 112, 110,
- 219, 271, 221, 224,
+static const YYINT pcap_dgoto[] = { 1,
+ 189, 227, 142, 224, 92, 93, 225, 94, 95, 166,
+ 167, 168, 96, 97, 210, 130, 99, 186, 187, 134,
+ 135, 131, 145, 2, 102, 103, 169, 104, 105, 106,
+ 107, 197, 198, 260, 108, 109, 203, 204, 264, 121,
+ 119, 234, 288, 236, 239,
};
-static const YYINT pcapsindex[] = { 0,
- 0, 296, -268, -231, -223, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, -216, -204, -174,
- -169, -284, -193, 0, 0, 0, 0, 0, 0, -40,
- -40, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+static const YYINT pcap_sindex[] = { 0,
+ 0, 431, -281, -278, -273, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, -279, -259, -221,
+ -186, -286, -216, 0, 0, 0, 0, 0, 0, -24,
+ -24, 0, -24, -24, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -274,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 396, 0, -334, 0, 0, -19, 611, 647, 0, 34,
- 0, 296, 296, 0, 0, 0, 0, 42, 0, 651,
- 0, 0, 96, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, -40, 0, 0, 34, 396, 0, 0,
- 185, 185, 0, 0, -38, 88, 0, 0, 0, 0,
- -19, -19, -236, -233, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, -258, -172, -251, 0, 0, 0, 0,
- 0, 0, -85, 0, 0, 0, 0, 0, 0, 396,
- 396, 396, 396, 396, 396, 396, 396, 0, 0, 0,
- 396, 396, 396, -39, 113, 126, 0, 0, -122, -121,
- -118, 0, 0, 0, -99, -98, -91, 0, 0, 0,
- 0, 0, 0, 0, -86, 126, 236, 0, 0, 0,
- 185, 185, 0, 0, -140, -84, -81, 0, 165, -334,
- 126, 0, -42, -36, -34, -31, 0, 0, -82, 0,
- 0, 0, 0, 0, 0, 170, 170, -8, 108, -23,
- -23, 0, 0, 236, 236, 156, 0, 0, 0, 0,
- 0, 0, -37, 0, 0, 0, -35, 0, 126, 0,
- 0, 0, 0, -19, -19, 0, 0, 0, 0, -221,
- 0, -70, 0, -118, 0, -91, 0, 0, 0, 0,
- 0, 134, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 653, 0,
+ -336, 0, 0, -21, 936, 855, 0, 16, 0, 431,
+ 431, 0, 0, 0, 0, 0, 237, 0, 782, 0,
+ 0, 114, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, -24, 0, 0, 0, 0, 0, -14, 16,
+ 653, 0, 0, 320, 320, 0, 0, -30, 64, 0,
+ 0, 0, 0, -21, -21, -245, -194, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, -280, -191, -270, 0,
+ 0, 0, 0, 0, 0, -118, 0, 0, 0, 0,
+ 0, 0, 653, 653, 653, 653, 653, 653, 653, 653,
+ 0, 0, 0, 653, 653, 653, 653, 653, -37, 85,
+ 90, 0, 0, -153, -141, -135, 0, 0, 0, -128,
+ -125, -122, 0, 0, 0, 0, 0, 0, 0, -114,
+ 90, 159, 0, 0, 0, 320, 320, 0, 0, -142,
+ -110, -100, 0, 152, -336, 90, 0, -63, -58, -52,
+ -49, 0, 0, -76, 0, 0, 0, 0, 0, 0,
+ 443, 443, 184, 529, 336, 336, -14, -14, 159, 159,
+ 159, 159, 972, 0, 0, 0, 0, 0, 0, -41,
+ 0, 0, 0, -34, 0, 90, 0, 0, 0, 0,
+ -21, -21, 0, 0, 0, 0, -262, 0, -61, 0,
+ -135, 0, -122, 0, 0, 0, 0, 0, 135, 0,
+ 0, 0,
};
-static const YYINT pcaprindex[] = { 0,
- 0, 488, 0, 0, 0, 0, 0, 0, 0, 0,
+static const YYINT pcap_rindex[] = { 0,
+ 0, 573, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
- 11, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
+ 8, 0, 25, 28, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 228, 0, 0, 0, 0, 0, 0, 1,
- 0, 686, 686, 0, 0, 0, 0, 0, 0, 0,
+ 233, 0, 0, 0, 0, 0, 0, 1, 0, 992,
+ 992, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 3, 0,
+ 0, 0, 0, 992, 992, 0, 0, 67, 72, 0,
+ 0, 0, 0, 0, 0, 248, 591, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 686, 686, 0, 0, 16, 18, 0, 0, 0, 0,
- 0, 0, -28, 520, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 53, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 132, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 905,
+ 960, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 725, 759, 0, 0, 0, 0,
+ 0, 0, 0, 0, 15, 992, 992, 0, 0, 0,
+ 0, 0, 0, -185, 0, -159, 0, 0, 0, 0,
+ 0, 0, 0, 79, 0, 0, 0, 0, 0, 0,
+ 30, 124, 158, 149, 99, 110, 40, 74, 183, 194,
+ 84, 89, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 767, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
- 686, 686, 0, 0, 0, 0, 0, 0, -222, 0,
- -205, 0, 0, 0, 0, 0, 0, 0, 20, 0,
- 0, 0, 0, 0, 0, 28, 53, 87, 78, 13,
- 38, 0, 0, 26, 36, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 121, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
+ 0, 0,
};
-static const YYINT pcapgindex[] = { 0,
- 227, -14, -116, 0, 2, 0, 0, 0, 0, 0,
- 79, 0, 24, -75, 0, 116, 724, -73, 12, 29,
- -163, 767, 722, 0, 0, 0, 0, 0, 0, 0,
- -171, 0, 0, 0, 0, -165, 0, 0, 0, 0,
- 0, 0, 0, 0,
+static const YYINT pcap_gindex[] = { 0,
+ 234, 229, -113, 0, -99, 0, 0, 0, 0, 0,
+ 71, 0, 944, 47, 0, 112, 1012, -83, -3, 14,
+ -205, 1004, 811, 0, 0, 0, 0, 0, 0, 0,
+ 0, -187, 0, 0, 0, 0, -188, 0, 0, 0,
+ 0, 0, 0, 0, 0,
};
-#define YYTABLESIZE 1078
-static const YYINT pcaptable[] = { 82,
- 40, 237, 12, 263, 52, 265, 108, 115, 206, 242,
- 117, 52, 152, 80, 208, 17, 175, 19, 166, 129,
- 82, 246, 101, 167, 179, 41, 185, 158, 109, 163,
- 119, 120, 217, 166, 164, 42, 165, 153, 167, 222,
- 148, 40, 175, 12, 148, 148, 255, 148, 115, 148,
- 152, 117, 159, 152, 218, 152, 17, 152, 19, 102,
- 129, 223, 148, 148, 148, 158, 41, 103, 158, 269,
- 152, 128, 152, 152, 152, 153, 42, 156, 153, 264,
- 153, 82, 153, 266, 208, 158, 157, 158, 158, 158,
- 159, 270, 273, 159, 177, 153, 104, 153, 153, 153,
- 274, 170, 169, 168, 116, 152, 198, 203, 105, 180,
- 159, 186, 159, 159, 159, 156, 106, 90, 156, 111,
- 158, 107, 199, 204, 173, 175, 148, 157, 213, 214,
- 153, 215, 216, 191, 207, 156, 152, 156, 156, 156,
- 220, 197, 29, 29, 157, 159, 157, 157, 157, 166,
- 164, 158, 165, 238, 167, 194, 193, 192, 148, 28,
- 28, 153, 148, 148, 33, 148, 239, 148, 240, 241,
- 156, 33, 178, 135, 250, 137, 159, 138, 139, 157,
- 148, 148, 148, 226, 227, 228, 229, 230, 231, 232,
- 233, 244, 245, 163, 234, 235, 236, 166, 164, 184,
- 165, 156, 167, 177, 248, 253, 251, 90, 90, 252,
- 157, 166, 164, 262, 165, 256, 167, 80, 260, 190,
- 272, 257, 258, 205, 82, 259, 275, 1, 83, 81,
- 52, 225, 52, 0, 52, 52, 90, 90, 254, 267,
- 268, 0, 0, 0, 148, 0, 0, 0, 261, 0,
- 25, 0, 0, 0, 0, 0, 0, 49, 49, 49,
- 49, 49, 52, 49, 49, 0, 0, 49, 49, 0,
- 0, 25, 0, 163, 0, 0, 0, 166, 164, 162,
- 165, 0, 167, 0, 52, 52, 52, 52, 52, 49,
- 49, 0, 0, 123, 124, 125, 126, 127, 0, 0,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 160,
- 161, 0, 148, 148, 148, 0, 90, 90, 0, 0,
- 148, 148, 152, 152, 152, 119, 120, 119, 80, 119,
- 152, 152, 178, 0, 0, 82, 0, 158, 158, 158,
- 81, 0, 0, 0, 0, 158, 158, 153, 153, 153,
- 0, 157, 158, 159, 0, 153, 153, 0, 0, 162,
- 0, 0, 159, 159, 159, 40, 40, 12, 12, 0,
- 159, 159, 115, 115, 0, 117, 117, 152, 152, 0,
- 17, 17, 19, 19, 129, 129, 0, 156, 156, 156,
- 41, 41, 158, 158, 0, 0, 157, 157, 157, 0,
- 42, 42, 153, 153, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 159, 159, 0,
- 0, 0, 33, 0, 0, 160, 161, 0, 0, 0,
- 148, 148, 148, 0, 0, 82, 0, 0, 148, 148,
- 81, 0, 156, 156, 33, 33, 33, 33, 33, 3,
- 4, 157, 157, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 160, 161, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 0, 28, 28, 2, 0, 0,
- 0, 0, 0, 34, 0, 0, 0, 123, 124, 125,
- 126, 127, 0, 0, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, 79, 0,
- 0, 0, 51, 160, 161, 0, 0, 0, 0, 51,
- 3, 4, 0, 0, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 0, 0, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 34, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 0, 0, 0, 0, 0, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 163, 0, 25, 0, 166, 164,
- 82, 165, 0, 167, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 34, 0, 170, 169, 168, 0,
- 170, 169, 168, 0, 0, 35, 36, 37, 38, 39,
- 0, 0, 0, 93, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 0, 0,
- 0, 0, 0, 0, 50, 50, 50, 50, 50, 0,
- 50, 50, 72, 0, 50, 50, 0, 0, 0, 0,
- 0, 0, 149, 113, 115, 0, 149, 149, 92, 149,
- 162, 149, 0, 0, 0, 0, 50, 50, 51, 0,
- 51, 0, 51, 51, 149, 149, 149, 50, 50, 50,
- 50, 50, 50, 50, 50, 50, 148, 0, 0, 0,
- 148, 148, 0, 148, 0, 148, 114, 114, 0, 130,
- 51, 0, 0, 93, 93, 176, 0, 0, 148, 148,
- 148, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 51, 51, 51, 51, 51, 196, 0, 0,
- 0, 176, 202, 202, 200, 200, 0, 0, 149, 0,
- 0, 0, 131, 0, 211, 130, 0, 0, 92, 92,
- 0, 0, 0, 0, 181, 0, 187, 133, 134, 135,
- 136, 137, 0, 138, 139, 0, 0, 140, 141, 0,
- 114, 0, 148, 0, 0, 0, 0, 201, 201, 0,
- 0, 0, 0, 0, 0, 0, 0, 114, 131, 142,
- 143, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 144, 145, 146, 147, 148, 149, 150, 151, 152, 0,
- 0, 0, 202, 202, 249, 200, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 184, 50, 50, 50, 50, 50, 0, 50, 50,
- 0, 0, 50, 50, 0, 0, 157, 158, 159, 0,
- 157, 158, 159, 0, 160, 161, 0, 92, 201, 0,
- 0, 0, 0, 0, 50, 50, 0, 130, 130, 0,
- 0, 0, 0, 0, 0, 50, 50, 50, 50, 50,
- 50, 50, 50, 50, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#define YYTABLESIZE 1300
+static const YYINT pcap_table[] = { 280,
+ 40, 192, 169, 254, 117, 115, 282, 117, 259, 110,
+ 232, 88, 111, 263, 12, 90, 221, 112, 90, 272,
+ 237, 127, 184, 194, 120, 200, 118, 122, 286, 167,
+ 223, 141, 233, 113, 214, 219, 132, 133, 128, 161,
+ 169, 40, 238, 169, 169, 169, 115, 169, 117, 169,
+ 287, 155, 155, 114, 281, 12, 155, 155, 283, 155,
+ 169, 155, 169, 169, 169, 120, 17, 167, 122, 115,
+ 167, 19, 141, 162, 155, 155, 155, 161, 133, 185,
+ 161, 161, 161, 41, 161, 33, 161, 167, 42, 167,
+ 167, 167, 33, 290, 291, 169, 120, 161, 159, 161,
+ 161, 161, 223, 195, 116, 201, 188, 17, 155, 160,
+ 222, 162, 19, 98, 162, 162, 162, 192, 162, 133,
+ 162, 235, 167, 168, 41, 255, 169, 228, 229, 42,
+ 256, 162, 161, 162, 162, 162, 159, 257, 155, 159,
+ 148, 159, 150, 159, 151, 152, 190, 160, 164, 258,
+ 160, 206, 160, 167, 160, 193, 159, 165, 159, 159,
+ 159, 168, 261, 161, 168, 262, 162, 160, 199, 160,
+ 160, 160, 267, 209, 208, 207, 265, 190, 230, 231,
+ 268, 168, 163, 168, 168, 168, 164, 29, 29, 164,
+ 269, 159, 270, 166, 273, 184, 176, 162, 165, 274,
+ 179, 177, 160, 178, 275, 180, 164, 276, 164, 164,
+ 164, 98, 98, 28, 28, 165, 168, 165, 165, 165,
+ 184, 176, 159, 163, 277, 179, 177, 292, 178, 289,
+ 180, 220, 1, 160, 166, 91, 240, 205, 271, 0,
+ 163, 164, 163, 163, 163, 98, 98, 168, 0, 0,
+ 165, 166, 185, 166, 166, 166, 0, 49, 49, 49,
+ 49, 49, 190, 49, 49, 0, 25, 49, 49, 25,
+ 0, 0, 164, 0, 0, 163, 90, 185, 0, 0,
+ 52, 165, 175, 0, 0, 0, 166, 52, 0, 49,
+ 49, 136, 137, 138, 139, 140, 183, 182, 181, 0,
+ 49, 49, 49, 49, 49, 49, 49, 49, 49, 0,
+ 0, 0, 169, 169, 169, 0, 0, 0, 0, 0,
+ 169, 169, 141, 0, 155, 155, 155, 98, 98, 0,
+ 0, 132, 155, 155, 0, 132, 133, 0, 132, 167,
+ 167, 167, 0, 33, 0, 0, 0, 167, 167, 161,
+ 161, 161, 88, 0, 0, 0, 0, 161, 161, 90,
+ 0, 0, 213, 218, 89, 33, 33, 33, 33, 33,
+ 0, 0, 184, 40, 40, 169, 169, 179, 115, 115,
+ 117, 117, 180, 162, 162, 162, 0, 12, 12, 0,
+ 0, 162, 162, 0, 0, 0, 0, 120, 120, 0,
+ 122, 122, 167, 167, 141, 141, 0, 0, 159, 159,
+ 159, 0, 161, 161, 0, 0, 159, 159, 0, 160,
+ 160, 160, 0, 0, 0, 0, 0, 160, 160, 185,
+ 0, 0, 0, 168, 168, 168, 0, 0, 0, 17,
+ 17, 168, 168, 0, 19, 19, 162, 162, 0, 0,
+ 0, 133, 133, 0, 0, 0, 41, 41, 164, 164,
+ 164, 42, 42, 88, 0, 0, 0, 165, 165, 165,
+ 90, 159, 159, 0, 0, 89, 173, 174, 0, 184,
+ 0, 0, 160, 160, 179, 177, 0, 178, 0, 180,
+ 0, 0, 163, 163, 163, 0, 168, 168, 0, 284,
+ 285, 173, 174, 166, 166, 166, 52, 0, 52, 0,
+ 52, 52, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 164, 164, 0, 0, 0, 0, 193, 0, 0,
+ 165, 165, 0, 0, 0, 0, 185, 0, 52, 0,
+ 0, 0, 0, 0, 0, 0, 170, 171, 172, 0,
+ 0, 0, 0, 0, 0, 163, 163, 0, 0, 0,
+ 52, 52, 52, 52, 52, 184, 166, 166, 0, 0,
+ 179, 177, 2, 178, 0, 180, 0, 0, 0, 0,
+ 0, 0, 0, 0, 3, 4, 0, 0, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 0, 0,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 0,
+ 0, 0, 185, 51, 0, 0, 0, 0, 34, 0,
+ 51, 0, 136, 137, 138, 139, 140, 0, 0, 35,
+ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
+ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
+ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
+ 86, 87, 90, 0, 0, 3, 4, 89, 0, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 0,
+ 0, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 34,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 131, 131, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 149, 149, 149, 0, 0, 0,
- 0, 0, 149, 149, 0, 0, 0, 0, 0, 0,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, 87, 155, 155, 0, 0, 0, 155, 155,
+ 0, 155, 101, 155, 0, 0, 0, 0, 0, 0,
+ 0, 90, 0, 0, 0, 0, 155, 155, 155, 50,
+ 50, 50, 50, 50, 0, 50, 50, 0, 0, 50,
+ 50, 183, 182, 181, 0, 0, 173, 174, 0, 51,
+ 0, 51, 0, 51, 51, 0, 0, 0, 0, 0,
+ 155, 50, 50, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 51, 0, 0, 0, 0, 0, 0, 0, 0,
+ 155, 184, 176, 0, 0, 0, 179, 177, 0, 178,
+ 0, 180, 0, 51, 51, 51, 51, 51, 0, 0,
+ 101, 101, 0, 0, 183, 182, 181, 0, 0, 0,
+ 0, 0, 6, 7, 8, 9, 10, 11, 12, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 156, 156, 25, 217, 217, 156, 156, 185, 156,
+ 0, 156, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 156, 156, 156, 0, 0, 0,
+ 0, 0, 35, 36, 37, 38, 39, 0, 175, 0,
+ 0, 0, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 56, 57, 58, 155, 155, 156, 0,
+ 0, 155, 155, 0, 155, 100, 155, 0, 184, 176,
+ 73, 0, 0, 179, 177, 0, 178, 0, 180, 155,
+ 155, 155, 0, 0, 0, 0, 217, 217, 156, 279,
+ 0, 0, 129, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 123, 123, 0, 123, 123, 0, 0,
+ 0, 122, 124, 155, 125, 126, 0, 0, 0, 0,
+ 0, 0, 0, 0, 278, 185, 0, 0, 0, 0,
+ 0, 0, 199, 0, 212, 0, 155, 155, 155, 0,
+ 0, 0, 0, 155, 155, 155, 0, 0, 0, 0,
+ 0, 170, 171, 172, 0, 175, 0, 144, 0, 0,
+ 0, 0, 0, 100, 100, 143, 0, 0, 0, 0,
+ 196, 191, 202, 0, 0, 0, 241, 242, 243, 244,
+ 245, 246, 247, 248, 0, 0, 123, 249, 250, 251,
+ 252, 253, 0, 0, 211, 0, 0, 216, 216, 28,
+ 28, 0, 191, 0, 0, 215, 215, 123, 144, 0,
+ 0, 0, 0, 0, 0, 226, 143, 0, 0, 0,
+ 0, 0, 0, 0, 170, 171, 172, 0, 0, 0,
+ 0, 0, 173, 174, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 148, 148,
- 148, 0, 0, 0, 0, 0, 148, 148,
+ 0, 0, 146, 147, 148, 149, 150, 0, 151, 152,
+ 0, 0, 153, 154, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 156, 156, 156, 0, 0, 100,
+ 216, 0, 156, 156, 155, 156, 0, 266, 215, 0,
+ 0, 0, 0, 0, 0, 157, 158, 159, 160, 161,
+ 162, 163, 164, 165, 0, 0, 0, 0, 50, 50,
+ 50, 50, 50, 0, 50, 50, 0, 0, 50, 50,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 155,
+ 155, 155, 0, 0, 144, 144, 0, 155, 155, 0,
+ 50, 50, 143, 143, 0, 0, 0, 0, 0, 173,
+ 174, 50, 50, 50, 50, 50, 50, 50, 50, 50,
};
-static const YYINT pcapcheck[] = { 40,
- 0, 41, 0, 41, 33, 41, 291, 0, 47, 181,
- 0, 40, 0, 33, 131, 0, 92, 0, 42, 0,
- 40, 187, 291, 47, 98, 0, 100, 0, 313, 38,
- 365, 366, 291, 42, 43, 0, 45, 0, 47, 291,
- 38, 41, 118, 41, 42, 43, 210, 45, 41, 47,
- 38, 41, 0, 41, 313, 43, 41, 45, 41, 291,
- 41, 313, 60, 61, 62, 38, 41, 291, 41, 291,
- 58, 86, 60, 61, 62, 38, 41, 0, 41, 243,
- 43, 40, 45, 247, 201, 58, 0, 60, 61, 62,
- 38, 313, 264, 41, 93, 58, 313, 60, 61, 62,
- 266, 60, 61, 62, 81, 93, 121, 122, 313, 98,
- 58, 100, 60, 61, 62, 38, 291, 2, 41, 313,
- 93, 291, 121, 122, 91, 201, 124, 41, 365, 366,
- 93, 365, 366, 38, 47, 58, 124, 60, 61, 62,
- 313, 118, 365, 366, 58, 93, 60, 61, 62, 42,
- 43, 124, 45, 41, 47, 60, 61, 62, 38, 365,
- 366, 124, 42, 43, 33, 45, 41, 47, 291, 291,
- 93, 40, 291, 259, 315, 261, 124, 263, 264, 93,
- 60, 61, 62, 160, 161, 162, 163, 164, 165, 166,
- 167, 291, 291, 38, 171, 172, 173, 42, 43, 291,
- 45, 124, 47, 202, 291, 41, 291, 92, 93, 291,
- 124, 42, 43, 58, 45, 258, 47, 33, 301, 124,
- 291, 258, 257, 262, 40, 257, 93, 0, 2, 45,
- 259, 153, 261, -1, 263, 264, 121, 122, 210, 254,
- 255, -1, -1, -1, 124, -1, -1, -1, 93, -1,
- 291, -1, -1, -1, -1, -1, -1, 257, 258, 259,
- 260, 261, 291, 263, 264, -1, -1, 267, 268, -1,
- -1, 291, -1, 38, -1, -1, -1, 42, 43, 124,
- 45, -1, 47, -1, 313, 314, 315, 316, 317, 289,
- 290, -1, -1, 313, 314, 315, 316, 317, -1, -1,
- 300, 301, 302, 303, 304, 305, 306, 307, 308, 318,
- 319, -1, 310, 311, 312, -1, 201, 202, -1, -1,
- 318, 319, 310, 311, 312, 365, 366, 365, 33, 365,
- 318, 319, 291, -1, -1, 40, -1, 310, 311, 312,
- 45, -1, -1, -1, -1, 318, 319, 310, 311, 312,
- -1, 310, 311, 312, -1, 318, 319, -1, -1, 124,
- -1, -1, 310, 311, 312, 365, 366, 365, 366, -1,
- 318, 319, 365, 366, -1, 365, 366, 365, 366, -1,
- 365, 366, 365, 366, 365, 366, -1, 310, 311, 312,
- 365, 366, 365, 366, -1, -1, 310, 311, 312, -1,
- 365, 366, 365, 366, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 365, 366, -1,
- -1, -1, 291, -1, -1, 318, 319, -1, -1, -1,
- 310, 311, 312, -1, -1, 40, -1, -1, 318, 319,
- 45, -1, 365, 366, 313, 314, 315, 316, 317, 265,
- 266, 365, 366, 269, 270, 271, 272, 273, 274, 275,
- 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
- 286, 287, 288, 318, 319, 291, 292, 293, 294, 295,
- 296, 297, 298, 299, -1, 365, 366, 0, -1, -1,
- -1, -1, -1, 309, -1, -1, -1, 313, 314, 315,
- 316, 317, -1, -1, 320, 321, 322, 323, 324, 325,
- 326, 327, 328, 329, 330, 331, 332, 333, 334, 335,
- 336, 337, 338, 339, 340, 341, 342, 343, 344, 345,
- 346, 347, 348, 349, 350, 351, 352, 353, 354, 355,
- 356, 357, 358, 359, 360, 361, 362, 363, 364, -1,
- -1, -1, 33, 318, 319, -1, -1, -1, -1, 40,
- 265, 266, -1, -1, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, -1, -1, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 309, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 320, 321, 322, 323, 324,
- 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
- 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
- 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
- 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
- -1, -1, -1, -1, -1, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 38, -1, 291, -1, 42, 43,
- 40, 45, -1, 47, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 309, -1, 60, 61, 62, -1,
- 60, 61, 62, -1, -1, 320, 321, 322, 323, 324,
- -1, -1, -1, 2, 329, 330, 331, 332, 333, 334,
- 335, 336, 337, 338, 339, 340, 341, 342, -1, -1,
- -1, -1, -1, -1, 257, 258, 259, 260, 261, -1,
- 263, 264, 357, -1, 267, 268, -1, -1, -1, -1,
- -1, -1, 38, 40, 41, -1, 42, 43, 2, 45,
- 124, 47, -1, -1, -1, -1, 289, 290, 259, -1,
- 261, -1, 263, 264, 60, 61, 62, 300, 301, 302,
- 303, 304, 305, 306, 307, 308, 38, -1, -1, -1,
- 42, 43, -1, 45, -1, 47, 40, 41, -1, 86,
- 291, -1, -1, 92, 93, 92, -1, -1, 60, 61,
- 62, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 313, 314, 315, 316, 317, 114, -1, -1,
- -1, 118, 121, 122, 121, 122, -1, -1, 124, -1,
- -1, -1, 86, -1, 131, 132, -1, -1, 92, 93,
- -1, -1, -1, -1, 98, -1, 100, 257, 258, 259,
- 260, 261, -1, 263, 264, -1, -1, 267, 268, -1,
- 114, -1, 124, -1, -1, -1, -1, 121, 122, -1,
- -1, -1, -1, -1, -1, -1, -1, 131, 132, 289,
- 290, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+static const YYINT pcap_check[] = { 41,
+ 0, 101, 0, 41, 291, 0, 41, 0, 196, 291,
+ 291, 33, 291, 202, 0, 40, 47, 291, 40, 225,
+ 291, 296, 37, 107, 0, 109, 313, 0, 291, 0,
+ 144, 0, 313, 313, 134, 135, 373, 374, 313, 0,
+ 38, 41, 313, 41, 42, 43, 41, 45, 41, 47,
+ 313, 37, 38, 313, 260, 41, 42, 43, 264, 45,
+ 58, 47, 60, 61, 62, 41, 0, 38, 41, 291,
+ 41, 0, 41, 0, 60, 61, 62, 38, 0, 94,
+ 41, 42, 43, 0, 45, 33, 47, 58, 0, 60,
+ 61, 62, 40, 281, 283, 93, 313, 58, 0, 60,
+ 61, 62, 216, 107, 291, 109, 91, 41, 94, 0,
+ 47, 38, 41, 2, 41, 42, 43, 217, 45, 41,
+ 47, 313, 93, 0, 41, 41, 124, 373, 374, 41,
+ 41, 58, 93, 60, 61, 62, 38, 291, 124, 41,
+ 259, 43, 261, 45, 263, 264, 100, 38, 0, 291,
+ 41, 38, 43, 124, 45, 291, 58, 0, 60, 61,
+ 62, 38, 291, 124, 41, 291, 93, 58, 291, 60,
+ 61, 62, 315, 60, 61, 62, 291, 131, 373, 374,
+ 291, 58, 0, 60, 61, 62, 38, 373, 374, 41,
+ 291, 93, 41, 0, 258, 37, 38, 124, 41, 258,
+ 42, 43, 93, 45, 257, 47, 58, 257, 60, 61,
+ 62, 100, 101, 373, 374, 58, 93, 60, 61, 62,
+ 37, 38, 124, 41, 301, 42, 43, 93, 45, 291,
+ 47, 262, 0, 124, 41, 2, 166, 124, 225, -1,
+ 58, 93, 60, 61, 62, 134, 135, 124, -1, -1,
+ 93, 58, 94, 60, 61, 62, -1, 257, 258, 259,
+ 260, 261, 216, 263, 264, -1, 291, 267, 268, 291,
+ -1, -1, 124, -1, -1, 93, 40, 94, -1, -1,
+ 33, 124, 124, -1, -1, -1, 93, 40, -1, 289,
+ 290, 313, 314, 315, 316, 317, 60, 61, 62, -1,
300, 301, 302, 303, 304, 305, 306, 307, 308, -1,
- -1, -1, 201, 202, 201, 202, -1, -1, -1, -1,
+ -1, -1, 310, 311, 312, -1, -1, -1, -1, -1,
+ 318, 319, 94, -1, 310, 311, 312, 216, 217, -1,
+ -1, 373, 318, 319, -1, 373, 374, -1, 373, 310,
+ 311, 312, -1, 291, -1, -1, -1, 318, 319, 310,
+ 311, 312, 33, -1, -1, -1, -1, 318, 319, 40,
+ -1, -1, 134, 135, 45, 313, 314, 315, 316, 317,
+ -1, -1, 37, 373, 374, 373, 374, 42, 373, 374,
+ 373, 374, 47, 310, 311, 312, -1, 373, 374, -1,
+ -1, 318, 319, -1, -1, -1, -1, 373, 374, -1,
+ 373, 374, 373, 374, 373, 374, -1, -1, 310, 311,
+ 312, -1, 373, 374, -1, -1, 318, 319, -1, 310,
+ 311, 312, -1, -1, -1, -1, -1, 318, 319, 94,
+ -1, -1, -1, 310, 311, 312, -1, -1, -1, 373,
+ 374, 318, 319, -1, 373, 374, 373, 374, -1, -1,
+ -1, 373, 374, -1, -1, -1, 373, 374, 310, 311,
+ 312, 373, 374, 33, -1, -1, -1, 310, 311, 312,
+ 40, 373, 374, -1, -1, 45, 318, 319, -1, 37,
+ -1, -1, 373, 374, 42, 43, -1, 45, -1, 47,
+ -1, -1, 310, 311, 312, -1, 373, 374, -1, 271,
+ 272, 318, 319, 310, 311, 312, 259, -1, 261, -1,
+ 263, 264, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 373, 374, -1, -1, -1, -1, 291, -1, -1,
+ 373, 374, -1, -1, -1, -1, 94, -1, 291, -1,
+ -1, -1, -1, -1, -1, -1, 310, 311, 312, -1,
+ -1, -1, -1, -1, -1, 373, 374, -1, -1, -1,
+ 313, 314, 315, 316, 317, 37, 373, 374, -1, -1,
+ 42, 43, 0, 45, -1, 47, -1, -1, -1, -1,
+ -1, -1, -1, -1, 265, 266, -1, -1, 269, 270,
+ 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
+ 281, 282, 283, 284, 285, 286, 287, 288, -1, -1,
+ 291, 292, 293, 294, 295, 296, 297, 298, 299, -1,
+ -1, -1, 94, 33, -1, -1, -1, -1, 309, -1,
+ 40, -1, 313, 314, 315, 316, 317, -1, -1, 320,
+ 321, 322, 323, 324, 325, 326, 327, 328, 329, 330,
+ 331, 332, 333, 334, 335, 336, 337, 338, 339, 340,
+ 341, 342, 343, 344, 345, 346, 347, 348, 349, 350,
+ 351, 352, 353, 354, 355, 356, 357, 358, 359, 360,
+ 361, 362, 363, 364, 365, 366, 367, 368, 369, 370,
+ 371, 372, 40, -1, -1, 265, 266, 45, -1, 269,
+ 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
+ 280, 281, 282, 283, 284, 285, 286, 287, 288, -1,
+ -1, 291, 292, 293, 294, 295, 296, 297, 298, 299,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 309,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 291, 257, 258, 259, 260, 261, -1, 263, 264,
- -1, -1, 267, 268, -1, -1, 310, 311, 312, -1,
- 310, 311, 312, -1, 318, 319, -1, 201, 202, -1,
- -1, -1, -1, -1, 289, 290, -1, 254, 255, -1,
- -1, -1, -1, -1, -1, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 254, 255, -1, -1, -1, -1, -1, -1, -1, -1,
+ 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
+ 330, 331, 332, 333, 334, 335, 336, 337, 338, 339,
+ 340, 341, 342, 343, 344, 345, 346, 347, 348, 349,
+ 350, 351, 352, 353, 354, 355, 356, 357, 358, 359,
+ 360, 361, 362, 363, 364, 365, 366, 367, 368, 369,
+ 370, 371, 372, 37, 38, -1, -1, -1, 42, 43,
+ -1, 45, 2, 47, -1, -1, -1, -1, -1, -1,
+ -1, 40, -1, -1, -1, -1, 60, 61, 62, 257,
+ 258, 259, 260, 261, -1, 263, 264, -1, -1, 267,
+ 268, 60, 61, 62, -1, -1, 318, 319, -1, 259,
+ -1, 261, -1, 263, 264, -1, -1, -1, -1, -1,
+ 94, 289, 290, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 300, 301, 302, 303, 304, 305, 306, 307,
+ 308, 291, -1, -1, -1, -1, -1, -1, -1, -1,
+ 124, 37, 38, -1, -1, -1, 42, 43, -1, 45,
+ -1, 47, -1, 313, 314, 315, 316, 317, -1, -1,
+ 100, 101, -1, -1, 60, 61, 62, -1, -1, -1,
+ -1, -1, 270, 271, 272, 273, 274, 275, 276, 277,
+ 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
+ 288, 37, 38, 291, 134, 135, 42, 43, 94, 45,
+ -1, 47, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 309, -1, -1, 60, 61, 62, -1, -1, -1,
+ -1, -1, 320, 321, 322, 323, 324, -1, 124, -1,
+ -1, -1, 330, 331, 332, 333, 334, 335, 336, 337,
+ 338, 339, 340, 341, 342, 343, 37, 38, 94, -1,
+ -1, 42, 43, -1, 45, 2, 47, -1, 37, 38,
+ 358, -1, -1, 42, 43, -1, 45, -1, 47, 60,
+ 61, 62, -1, -1, -1, -1, 216, 217, 124, 58,
+ -1, -1, 89, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 40, 41, -1, 43, 44, -1, -1,
+ -1, 40, 41, 94, 43, 44, -1, -1, -1, -1,
+ -1, -1, -1, -1, 93, 94, -1, -1, -1, -1,
+ -1, -1, 291, -1, 131, -1, 310, 311, 312, -1,
+ -1, -1, -1, 124, 318, 319, -1, -1, -1, -1,
+ -1, 310, 311, 312, -1, 124, -1, 94, -1, -1,
+ -1, -1, -1, 100, 101, 94, -1, -1, -1, -1,
+ 107, 100, 109, -1, -1, -1, 173, 174, 175, 176,
+ 177, 178, 179, 180, -1, -1, 123, 184, 185, 186,
+ 187, 188, -1, -1, 123, -1, -1, 134, 135, 373,
+ 374, -1, 131, -1, -1, 134, 135, 144, 145, -1,
+ -1, -1, -1, -1, -1, 144, 145, -1, -1, -1,
-1, -1, -1, -1, 310, 311, 312, -1, -1, -1,
-1, -1, 318, 319, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 310, 311,
- 312, -1, -1, -1, -1, -1, 318, 319,
+ -1, -1, 257, 258, 259, 260, 261, -1, 263, 264,
+ -1, -1, 267, 268, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 310, 311, 312, -1, -1, 216,
+ 217, -1, 318, 319, 289, 290, -1, 216, 217, -1,
+ -1, -1, -1, -1, -1, 300, 301, 302, 303, 304,
+ 305, 306, 307, 308, -1, -1, -1, -1, 257, 258,
+ 259, 260, 261, -1, 263, 264, -1, -1, 267, 268,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 310,
+ 311, 312, -1, -1, 271, 272, -1, 318, 319, -1,
+ 289, 290, 271, 272, -1, -1, -1, -1, -1, 318,
+ 319, 300, 301, 302, 303, 304, 305, 306, 307, 308,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
-#define YYMAXTOKEN 367
-#define YYUNDFTOKEN 414
+#define YYMAXTOKEN 375
+#define YYUNDFTOKEN 423
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
#if YYDEBUG
-static const char *const pcapname[] = {
+static const char *const pcap_name[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-"'!'",0,0,0,0,"'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,
-0,"':'",0,"'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-"'|'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,"':'",0,"'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,"'|'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"DST","SRC","HOST","GATEWAY","NET","NETMASK",
-"PORT","PORTRANGE","LESS","GREATER","PROTO","PROTOCHAIN","CBYTE","ARP","RARP",
-"IP","SCTP","TCP","UDP","ICMP","IGMP","IGRP","PIM","VRRP","CARP","ATALK","AARP",
-"DECNET","LAT","SCA","MOPRC","MOPDL","TK_BROADCAST","TK_MULTICAST","NUM",
-"INBOUND","OUTBOUND","PF_IFNAME","PF_RSET","PF_RNR","PF_SRNR","PF_REASON",
-"PF_ACTION","TYPE","SUBTYPE","DIR","ADDR1","ADDR2","ADDR3","ADDR4","RA","TA",
-"LINK","GEQ","LEQ","NEQ","ID","EID","HID","HID6","AID","LSH","RSH","LEN","IPV6",
-"ICMPV6","AH","ESP","VLAN","MPLS","PPPOED","PPPOES","ISO","ESIS","CLNP","ISIS",
-"L1","L2","IIH","LSP","SNP","CSNP","PSNP","STP","IPX","NETBEUI","LANE","LLC",
-"METAC","BCC","SC","ILMIC","OAMF4EC","OAMF4SC","OAM","OAMF4","CONNECTMSG",
-"METACONNECT","VPI","VCI","RADIO","FISU","LSSU","MSU","SIO","OPC","DPC","SLS",
-"OR","AND","UMINUS",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol",
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"DST","SRC","HOST","GATEWAY","NET",
+"NETMASK","PORT","PORTRANGE","LESS","GREATER","PROTO","PROTOCHAIN","CBYTE",
+"ARP","RARP","IP","SCTP","TCP","UDP","ICMP","IGMP","IGRP","PIM","VRRP","CARP",
+"ATALK","AARP","DECNET","LAT","SCA","MOPRC","MOPDL","TK_BROADCAST",
+"TK_MULTICAST","NUM","INBOUND","OUTBOUND","PF_IFNAME","PF_RSET","PF_RNR",
+"PF_SRNR","PF_REASON","PF_ACTION","TYPE","SUBTYPE","DIR","ADDR1","ADDR2",
+"ADDR3","ADDR4","RA","TA","LINK","GEQ","LEQ","NEQ","ID","EID","HID","HID6",
+"AID","LSH","RSH","LEN","IPV6","ICMPV6","AH","ESP","VLAN","MPLS","PPPOED",
+"PPPOES","GENEVE","ISO","ESIS","CLNP","ISIS","L1","L2","IIH","LSP","SNP","CSNP",
+"PSNP","STP","IPX","NETBEUI","LANE","LLC","METAC","BCC","SC","ILMIC","OAMF4EC",
+"OAMF4SC","OAM","OAMF4","CONNECTMSG","METACONNECT","VPI","VCI","RADIO","FISU",
+"LSSU","MSU","HFISU","HLSSU","HMSU","SIO","OPC","DPC","SLS","HSIO","HOPC",
+"HDPC","HSLS","OR","AND","UMINUS",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol",
};
-static const char *const pcaprule[] = {
+static const char *const pcap_rule[] = {
"$accept : prog",
"prog : null expr",
"prog : null",
@@ -1028,9 +1097,13 @@ static const char *const pcaprule[] = {
"other : MPLS pnum",
"other : MPLS",
"other : PPPOED",
+"other : PPPOES pnum",
"other : PPPOES",
+"other : GENEVE pnum",
+"other : GENEVE",
"other : pfvar",
"other : pqual p80211",
+"other : pllc",
"pfvar : PF_IFNAME ID",
"pfvar : PF_RSET ID",
"pfvar : PF_RNR NUM",
@@ -1046,6 +1119,9 @@ static const char *const pcaprule[] = {
"subtype : NUM",
"subtype : ID",
"type_subtype : ID",
+"pllc : LLC",
+"pllc : LLC ID",
+"pllc : LLC PF_RNR",
"dir : NUM",
"dir : ID",
"reason : NUM",
@@ -1065,8 +1141,10 @@ static const char *const pcaprule[] = {
"narth : arth '-' arth",
"narth : arth '*' arth",
"narth : arth '/' arth",
+"narth : arth '%' arth",
"narth : arth '&' arth",
"narth : arth '|' arth",
+"narth : arth '^' arth",
"narth : arth LSH arth",
"narth : arth RSH arth",
"narth : '-' arth",
@@ -1080,7 +1158,6 @@ static const char *const pcaprule[] = {
"pnum : NUM",
"pnum : paren pnum ')'",
"atmtype : LANE",
-"atmtype : LLC",
"atmtype : METAC",
"atmtype : BCC",
"atmtype : OAMF4EC",
@@ -1103,10 +1180,17 @@ static const char *const pcaprule[] = {
"mtp2type : FISU",
"mtp2type : LSSU",
"mtp2type : MSU",
+"mtp2type : HFISU",
+"mtp2type : HLSSU",
+"mtp2type : HMSU",
"mtp3field : SIO",
"mtp3field : OPC",
"mtp3field : DPC",
"mtp3field : SLS",
+"mtp3field : HSIO",
+"mtp3field : HOPC",
+"mtp3field : HDPC",
+"mtp3field : HSLS",
"mtp3value : mtp3fieldvalue",
"mtp3value : relop NUM",
"mtp3value : irelop NUM",
@@ -1121,11 +1205,6 @@ static const char *const pcaprule[] = {
int yydebug;
int yynerrs;
-int yyerrflag;
-int yychar;
-YYSTYPE yyval;
-YYSTYPE yylval;
-
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
@@ -1149,11 +1228,9 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-/* variables for the parser stack */
-static YYSTACKDATA yystack;
#if YYDEBUG
-#include <stdio.h> /* needed for printf */
+#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
@@ -1213,6 +1290,13 @@ static void yyfreestack(YYSTACKDATA *data)
int
YYPARSE_DECL()
{
+ int yyerrflag;
+ int yychar;
+ YYSTYPE yyval;
+ YYSTYPE yylval;
+
+ /* variables for the parser stack */
+ YYSTACKDATA yystack;
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
@@ -1225,6 +1309,8 @@ YYPARSE_DECL()
}
#endif
+ yym = 0;
+ yyn = 0;
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
@@ -1244,28 +1330,26 @@ yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
- if ((yychar = YYLEX) < 0) yychar = YYEOF;
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
#if YYDEBUG
if (yydebug)
{
- yys = yyname[YYTRANSLATE(yychar)];
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
- if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
- {
- goto yyoverflow;
- }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
@@ -1273,18 +1357,17 @@ yyloop:
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
- if (yyerrflag) goto yyinrecovery;
+ if (yyerrflag != 0) goto yyinrecovery;
YYERROR_CALL("syntax error");
- goto yyerrlab;
-
+ goto yyerrlab; /* redundant goto avoids 'unused label' warning */
yyerrlab:
++yynerrs;
@@ -1294,18 +1377,15 @@ yyinrecovery:
yyerrflag = 3;
for (;;)
{
- if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
- if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
- {
- goto yyoverflow;
- }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
@@ -1330,7 +1410,7 @@ yyinrecovery:
#if YYDEBUG
if (yydebug)
{
- yys = yyname[YYTRANSLATE(yychar)];
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
@@ -1346,113 +1426,114 @@ yyreduce:
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
- if (yym)
+ if (yym > 0)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
+
switch (yyn)
{
case 1:
-#line 317 "../../freebsd/contrib/libpcap/grammar.y"
+#line 347 "grammar.y"
{
- finish_parse(yystack.l_mark[0].blk.b);
+ finish_parse(cstate, yystack.l_mark[0].blk.b);
}
break;
case 3:
-#line 322 "../../freebsd/contrib/libpcap/grammar.y"
+#line 352 "grammar.y"
{ yyval.blk.q = qerr; }
break;
case 5:
-#line 325 "../../freebsd/contrib/libpcap/grammar.y"
+#line 355 "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 326 "../../freebsd/contrib/libpcap/grammar.y"
+#line 356 "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 327 "../../freebsd/contrib/libpcap/grammar.y"
+#line 357 "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 328 "../../freebsd/contrib/libpcap/grammar.y"
+#line 358 "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 330 "../../freebsd/contrib/libpcap/grammar.y"
+#line 360 "grammar.y"
{ yyval.blk = yystack.l_mark[-1].blk; }
break;
case 10:
-#line 332 "../../freebsd/contrib/libpcap/grammar.y"
+#line 362 "grammar.y"
{ yyval.blk = yystack.l_mark[-1].blk; }
break;
case 12:
-#line 335 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_ncode(NULL, (bpf_u_int32)yystack.l_mark[0].i,
+#line 365 "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 337 "../../freebsd/contrib/libpcap/grammar.y"
+#line 367 "grammar.y"
{ yyval.blk = yystack.l_mark[-1].blk; }
break;
case 14:
-#line 339 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_scode(yystack.l_mark[0].s, yyval.blk.q = yystack.l_mark[-1].blk.q); }
+#line 369 "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 340 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_mcode(yystack.l_mark[-2].s, NULL, yystack.l_mark[0].i,
+#line 370 "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 342 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_mcode(yystack.l_mark[-2].s, yystack.l_mark[0].s, 0,
+#line 372 "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 344 "../../freebsd/contrib/libpcap/grammar.y"
+#line 374 "grammar.y"
{
/* Decide how to parse HID based on proto */
yyval.blk.q = yystack.l_mark[-1].blk.q;
if (yyval.blk.q.addr == Q_PORT)
- bpf_error("'port' modifier applied to ip host");
+ bpf_error(cstate, "'port' modifier applied to ip host");
else if (yyval.blk.q.addr == Q_PORTRANGE)
- bpf_error("'portrange' modifier applied to ip host");
+ bpf_error(cstate, "'portrange' modifier applied to ip host");
else if (yyval.blk.q.addr == Q_PROTO)
- bpf_error("'proto' modifier applied to ip host");
+ bpf_error(cstate, "'proto' modifier applied to ip host");
else if (yyval.blk.q.addr == Q_PROTOCHAIN)
- bpf_error("'protochain' modifier applied to ip host");
- yyval.blk.b = gen_ncode(yystack.l_mark[0].s, 0, yyval.blk.q);
+ bpf_error(cstate, "'protochain' modifier applied to ip host");
+ yyval.blk.b = gen_ncode(cstate, yystack.l_mark[0].s, 0, yyval.blk.q);
}
break;
case 18:
-#line 357 "../../freebsd/contrib/libpcap/grammar.y"
+#line 387 "grammar.y"
{
#ifdef INET6
- yyval.blk.b = gen_mcode6(yystack.l_mark[-2].s, NULL, yystack.l_mark[0].i,
+ yyval.blk.b = gen_mcode6(cstate, yystack.l_mark[-2].s, NULL, yystack.l_mark[0].i,
yyval.blk.q = yystack.l_mark[-3].blk.q);
#else
- bpf_error("'ip6addr/prefixlen' not supported "
+ bpf_error(cstate, "'ip6addr/prefixlen' not supported "
"in this configuration");
#endif /*INET6*/
}
break;
case 19:
-#line 366 "../../freebsd/contrib/libpcap/grammar.y"
+#line 396 "grammar.y"
{
#ifdef INET6
- yyval.blk.b = gen_mcode6(yystack.l_mark[0].s, 0, 128,
+ yyval.blk.b = gen_mcode6(cstate, yystack.l_mark[0].s, 0, 128,
yyval.blk.q = yystack.l_mark[-1].blk.q);
#else
- bpf_error("'ip6addr' not supported "
+ bpf_error(cstate, "'ip6addr' not supported "
"in this configuration");
#endif /*INET6*/
}
break;
case 20:
-#line 375 "../../freebsd/contrib/libpcap/grammar.y"
- {
- yyval.blk.b = gen_ecode(yystack.l_mark[0].e, yyval.blk.q = yystack.l_mark[-1].blk.q);
+#line 405 "grammar.y"
+ {
+ yyval.blk.b = gen_ecode(cstate, yystack.l_mark[0].e, yyval.blk.q = yystack.l_mark[-1].blk.q);
/*
* $1 was allocated by "pcap_ether_aton()",
* so we must free it now that we're done
@@ -1462,9 +1543,9 @@ case 20:
}
break;
case 21:
-#line 384 "../../freebsd/contrib/libpcap/grammar.y"
+#line 414 "grammar.y"
{
- yyval.blk.b = gen_acode(yystack.l_mark[0].e, yyval.blk.q = yystack.l_mark[-1].blk.q);
+ yyval.blk.b = gen_acode(cstate, yystack.l_mark[0].e, yyval.blk.q = yystack.l_mark[-1].blk.q);
/*
* $1 was allocated by "pcap_ether_aton()",
* so we must free it now that we're done
@@ -1474,455 +1555,471 @@ case 21:
}
break;
case 22:
-#line 393 "../../freebsd/contrib/libpcap/grammar.y"
+#line 423 "grammar.y"
{ gen_not(yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; }
break;
case 23:
-#line 395 "../../freebsd/contrib/libpcap/grammar.y"
+#line 425 "grammar.y"
{ yyval.blk = yystack.l_mark[-1].blk; }
break;
case 24:
-#line 397 "../../freebsd/contrib/libpcap/grammar.y"
+#line 427 "grammar.y"
{ yyval.blk = yystack.l_mark[-1].blk; }
break;
case 26:
-#line 400 "../../freebsd/contrib/libpcap/grammar.y"
+#line 430 "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 401 "../../freebsd/contrib/libpcap/grammar.y"
+#line 431 "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 403 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_ncode(NULL, (bpf_u_int32)yystack.l_mark[0].i,
+#line 433 "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 408 "../../freebsd/contrib/libpcap/grammar.y"
+#line 438 "grammar.y"
{ gen_not(yystack.l_mark[0].blk.b); yyval.blk = yystack.l_mark[0].blk; }
break;
case 32:
-#line 410 "../../freebsd/contrib/libpcap/grammar.y"
+#line 440 "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 411 "../../freebsd/contrib/libpcap/grammar.y"
+#line 441 "grammar.y"
{ QSET(yyval.blk.q, yystack.l_mark[-1].i, yystack.l_mark[0].i, Q_DEFAULT); }
break;
case 34:
-#line 412 "../../freebsd/contrib/libpcap/grammar.y"
+#line 442 "grammar.y"
{ QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, yystack.l_mark[0].i); }
break;
case 35:
-#line 413 "../../freebsd/contrib/libpcap/grammar.y"
+#line 443 "grammar.y"
{ QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, Q_PROTO); }
break;
case 36:
-#line 414 "../../freebsd/contrib/libpcap/grammar.y"
+#line 444 "grammar.y"
{ QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, Q_PROTOCHAIN); }
break;
case 37:
-#line 415 "../../freebsd/contrib/libpcap/grammar.y"
+#line 445 "grammar.y"
{ QSET(yyval.blk.q, yystack.l_mark[-1].i, Q_DEFAULT, yystack.l_mark[0].i); }
break;
case 38:
-#line 417 "../../freebsd/contrib/libpcap/grammar.y"
+#line 447 "grammar.y"
{ yyval.blk = yystack.l_mark[0].blk; }
break;
case 39:
-#line 418 "../../freebsd/contrib/libpcap/grammar.y"
+#line 448 "grammar.y"
{ yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = yystack.l_mark[-2].blk.q; }
break;
case 40:
-#line 419 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_proto_abbrev(yystack.l_mark[0].i); yyval.blk.q = qerr; }
+#line 449 "grammar.y"
+ { yyval.blk.b = gen_proto_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; }
break;
case 41:
-#line 420 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_relation(yystack.l_mark[-1].i, yystack.l_mark[-2].a, yystack.l_mark[0].a, 0);
+#line 450 "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 422 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_relation(yystack.l_mark[-1].i, yystack.l_mark[-2].a, yystack.l_mark[0].a, 1);
+#line 452 "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 424 "../../freebsd/contrib/libpcap/grammar.y"
+#line 454 "grammar.y"
{ yyval.blk.b = yystack.l_mark[0].rblk; yyval.blk.q = qerr; }
break;
case 44:
-#line 425 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_atmtype_abbrev(yystack.l_mark[0].i); yyval.blk.q = qerr; }
+#line 455 "grammar.y"
+ { yyval.blk.b = gen_atmtype_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; }
break;
case 45:
-#line 426 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_atmmulti_abbrev(yystack.l_mark[0].i); yyval.blk.q = qerr; }
+#line 456 "grammar.y"
+ { yyval.blk.b = gen_atmmulti_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; }
break;
case 46:
-#line 427 "../../freebsd/contrib/libpcap/grammar.y"
+#line 457 "grammar.y"
{ yyval.blk.b = yystack.l_mark[0].blk.b; yyval.blk.q = qerr; }
break;
case 47:
-#line 428 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_mtp2type_abbrev(yystack.l_mark[0].i); yyval.blk.q = qerr; }
+#line 458 "grammar.y"
+ { yyval.blk.b = gen_mtp2type_abbrev(cstate, yystack.l_mark[0].i); yyval.blk.q = qerr; }
break;
case 48:
-#line 429 "../../freebsd/contrib/libpcap/grammar.y"
+#line 459 "grammar.y"
{ yyval.blk.b = yystack.l_mark[0].blk.b; yyval.blk.q = qerr; }
break;
case 50:
-#line 433 "../../freebsd/contrib/libpcap/grammar.y"
+#line 463 "grammar.y"
{ yyval.i = Q_DEFAULT; }
break;
case 51:
-#line 436 "../../freebsd/contrib/libpcap/grammar.y"
+#line 466 "grammar.y"
{ yyval.i = Q_SRC; }
break;
case 52:
-#line 437 "../../freebsd/contrib/libpcap/grammar.y"
+#line 467 "grammar.y"
{ yyval.i = Q_DST; }
break;
case 53:
-#line 438 "../../freebsd/contrib/libpcap/grammar.y"
+#line 468 "grammar.y"
{ yyval.i = Q_OR; }
break;
case 54:
-#line 439 "../../freebsd/contrib/libpcap/grammar.y"
+#line 469 "grammar.y"
{ yyval.i = Q_OR; }
break;
case 55:
-#line 440 "../../freebsd/contrib/libpcap/grammar.y"
+#line 470 "grammar.y"
{ yyval.i = Q_AND; }
break;
case 56:
-#line 441 "../../freebsd/contrib/libpcap/grammar.y"
+#line 471 "grammar.y"
{ yyval.i = Q_AND; }
break;
case 57:
-#line 442 "../../freebsd/contrib/libpcap/grammar.y"
+#line 472 "grammar.y"
{ yyval.i = Q_ADDR1; }
break;
case 58:
-#line 443 "../../freebsd/contrib/libpcap/grammar.y"
+#line 473 "grammar.y"
{ yyval.i = Q_ADDR2; }
break;
case 59:
-#line 444 "../../freebsd/contrib/libpcap/grammar.y"
+#line 474 "grammar.y"
{ yyval.i = Q_ADDR3; }
break;
case 60:
-#line 445 "../../freebsd/contrib/libpcap/grammar.y"
+#line 475 "grammar.y"
{ yyval.i = Q_ADDR4; }
break;
case 61:
-#line 446 "../../freebsd/contrib/libpcap/grammar.y"
+#line 476 "grammar.y"
{ yyval.i = Q_RA; }
break;
case 62:
-#line 447 "../../freebsd/contrib/libpcap/grammar.y"
+#line 477 "grammar.y"
{ yyval.i = Q_TA; }
break;
case 63:
-#line 450 "../../freebsd/contrib/libpcap/grammar.y"
+#line 480 "grammar.y"
{ yyval.i = Q_HOST; }
break;
case 64:
-#line 451 "../../freebsd/contrib/libpcap/grammar.y"
+#line 481 "grammar.y"
{ yyval.i = Q_NET; }
break;
case 65:
-#line 452 "../../freebsd/contrib/libpcap/grammar.y"
+#line 482 "grammar.y"
{ yyval.i = Q_PORT; }
break;
case 66:
-#line 453 "../../freebsd/contrib/libpcap/grammar.y"
+#line 483 "grammar.y"
{ yyval.i = Q_PORTRANGE; }
break;
case 67:
-#line 456 "../../freebsd/contrib/libpcap/grammar.y"
+#line 486 "grammar.y"
{ yyval.i = Q_GATEWAY; }
break;
case 68:
-#line 458 "../../freebsd/contrib/libpcap/grammar.y"
+#line 488 "grammar.y"
{ yyval.i = Q_LINK; }
break;
case 69:
-#line 459 "../../freebsd/contrib/libpcap/grammar.y"
+#line 489 "grammar.y"
{ yyval.i = Q_IP; }
break;
case 70:
-#line 460 "../../freebsd/contrib/libpcap/grammar.y"
+#line 490 "grammar.y"
{ yyval.i = Q_ARP; }
break;
case 71:
-#line 461 "../../freebsd/contrib/libpcap/grammar.y"
+#line 491 "grammar.y"
{ yyval.i = Q_RARP; }
break;
case 72:
-#line 462 "../../freebsd/contrib/libpcap/grammar.y"
+#line 492 "grammar.y"
{ yyval.i = Q_SCTP; }
break;
case 73:
-#line 463 "../../freebsd/contrib/libpcap/grammar.y"
+#line 493 "grammar.y"
{ yyval.i = Q_TCP; }
break;
case 74:
-#line 464 "../../freebsd/contrib/libpcap/grammar.y"
+#line 494 "grammar.y"
{ yyval.i = Q_UDP; }
break;
case 75:
-#line 465 "../../freebsd/contrib/libpcap/grammar.y"
+#line 495 "grammar.y"
{ yyval.i = Q_ICMP; }
break;
case 76:
-#line 466 "../../freebsd/contrib/libpcap/grammar.y"
+#line 496 "grammar.y"
{ yyval.i = Q_IGMP; }
break;
case 77:
-#line 467 "../../freebsd/contrib/libpcap/grammar.y"
+#line 497 "grammar.y"
{ yyval.i = Q_IGRP; }
break;
case 78:
-#line 468 "../../freebsd/contrib/libpcap/grammar.y"
+#line 498 "grammar.y"
{ yyval.i = Q_PIM; }
break;
case 79:
-#line 469 "../../freebsd/contrib/libpcap/grammar.y"
+#line 499 "grammar.y"
{ yyval.i = Q_VRRP; }
break;
case 80:
-#line 470 "../../freebsd/contrib/libpcap/grammar.y"
+#line 500 "grammar.y"
{ yyval.i = Q_CARP; }
break;
case 81:
-#line 471 "../../freebsd/contrib/libpcap/grammar.y"
+#line 501 "grammar.y"
{ yyval.i = Q_ATALK; }
break;
case 82:
-#line 472 "../../freebsd/contrib/libpcap/grammar.y"
+#line 502 "grammar.y"
{ yyval.i = Q_AARP; }
break;
case 83:
-#line 473 "../../freebsd/contrib/libpcap/grammar.y"
+#line 503 "grammar.y"
{ yyval.i = Q_DECNET; }
break;
case 84:
-#line 474 "../../freebsd/contrib/libpcap/grammar.y"
+#line 504 "grammar.y"
{ yyval.i = Q_LAT; }
break;
case 85:
-#line 475 "../../freebsd/contrib/libpcap/grammar.y"
+#line 505 "grammar.y"
{ yyval.i = Q_SCA; }
break;
case 86:
-#line 476 "../../freebsd/contrib/libpcap/grammar.y"
+#line 506 "grammar.y"
{ yyval.i = Q_MOPDL; }
break;
case 87:
-#line 477 "../../freebsd/contrib/libpcap/grammar.y"
+#line 507 "grammar.y"
{ yyval.i = Q_MOPRC; }
break;
case 88:
-#line 478 "../../freebsd/contrib/libpcap/grammar.y"
+#line 508 "grammar.y"
{ yyval.i = Q_IPV6; }
break;
case 89:
-#line 479 "../../freebsd/contrib/libpcap/grammar.y"
+#line 509 "grammar.y"
{ yyval.i = Q_ICMPV6; }
break;
case 90:
-#line 480 "../../freebsd/contrib/libpcap/grammar.y"
+#line 510 "grammar.y"
{ yyval.i = Q_AH; }
break;
case 91:
-#line 481 "../../freebsd/contrib/libpcap/grammar.y"
+#line 511 "grammar.y"
{ yyval.i = Q_ESP; }
break;
case 92:
-#line 482 "../../freebsd/contrib/libpcap/grammar.y"
+#line 512 "grammar.y"
{ yyval.i = Q_ISO; }
break;
case 93:
-#line 483 "../../freebsd/contrib/libpcap/grammar.y"
+#line 513 "grammar.y"
{ yyval.i = Q_ESIS; }
break;
case 94:
-#line 484 "../../freebsd/contrib/libpcap/grammar.y"
+#line 514 "grammar.y"
{ yyval.i = Q_ISIS; }
break;
case 95:
-#line 485 "../../freebsd/contrib/libpcap/grammar.y"
+#line 515 "grammar.y"
{ yyval.i = Q_ISIS_L1; }
break;
case 96:
-#line 486 "../../freebsd/contrib/libpcap/grammar.y"
+#line 516 "grammar.y"
{ yyval.i = Q_ISIS_L2; }
break;
case 97:
-#line 487 "../../freebsd/contrib/libpcap/grammar.y"
+#line 517 "grammar.y"
{ yyval.i = Q_ISIS_IIH; }
break;
case 98:
-#line 488 "../../freebsd/contrib/libpcap/grammar.y"
+#line 518 "grammar.y"
{ yyval.i = Q_ISIS_LSP; }
break;
case 99:
-#line 489 "../../freebsd/contrib/libpcap/grammar.y"
+#line 519 "grammar.y"
{ yyval.i = Q_ISIS_SNP; }
break;
case 100:
-#line 490 "../../freebsd/contrib/libpcap/grammar.y"
+#line 520 "grammar.y"
{ yyval.i = Q_ISIS_PSNP; }
break;
case 101:
-#line 491 "../../freebsd/contrib/libpcap/grammar.y"
+#line 521 "grammar.y"
{ yyval.i = Q_ISIS_CSNP; }
break;
case 102:
-#line 492 "../../freebsd/contrib/libpcap/grammar.y"
+#line 522 "grammar.y"
{ yyval.i = Q_CLNP; }
break;
case 103:
-#line 493 "../../freebsd/contrib/libpcap/grammar.y"
+#line 523 "grammar.y"
{ yyval.i = Q_STP; }
break;
case 104:
-#line 494 "../../freebsd/contrib/libpcap/grammar.y"
+#line 524 "grammar.y"
{ yyval.i = Q_IPX; }
break;
case 105:
-#line 495 "../../freebsd/contrib/libpcap/grammar.y"
+#line 525 "grammar.y"
{ yyval.i = Q_NETBEUI; }
break;
case 106:
-#line 496 "../../freebsd/contrib/libpcap/grammar.y"
+#line 526 "grammar.y"
{ yyval.i = Q_RADIO; }
break;
case 107:
-#line 498 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_broadcast(yystack.l_mark[-1].i); }
+#line 528 "grammar.y"
+ { yyval.rblk = gen_broadcast(cstate, yystack.l_mark[-1].i); }
break;
case 108:
-#line 499 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_multicast(yystack.l_mark[-1].i); }
+#line 529 "grammar.y"
+ { yyval.rblk = gen_multicast(cstate, yystack.l_mark[-1].i); }
break;
case 109:
-#line 500 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_less(yystack.l_mark[0].i); }
+#line 530 "grammar.y"
+ { yyval.rblk = gen_less(cstate, yystack.l_mark[0].i); }
break;
case 110:
-#line 501 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_greater(yystack.l_mark[0].i); }
+#line 531 "grammar.y"
+ { yyval.rblk = gen_greater(cstate, yystack.l_mark[0].i); }
break;
case 111:
-#line 502 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_byteop(yystack.l_mark[-1].i, yystack.l_mark[-2].i, yystack.l_mark[0].i); }
+#line 532 "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 503 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_inbound(0); }
+#line 533 "grammar.y"
+ { yyval.rblk = gen_inbound(cstate, 0); }
break;
case 113:
-#line 504 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_inbound(1); }
+#line 534 "grammar.y"
+ { yyval.rblk = gen_inbound(cstate, 1); }
break;
case 114:
-#line 505 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_vlan(yystack.l_mark[0].i); }
+#line 535 "grammar.y"
+ { yyval.rblk = gen_vlan(cstate, yystack.l_mark[0].i); }
break;
case 115:
-#line 506 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_vlan(-1); }
+#line 536 "grammar.y"
+ { yyval.rblk = gen_vlan(cstate, -1); }
break;
case 116:
-#line 507 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_mpls(yystack.l_mark[0].i); }
+#line 537 "grammar.y"
+ { yyval.rblk = gen_mpls(cstate, yystack.l_mark[0].i); }
break;
case 117:
-#line 508 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_mpls(-1); }
+#line 538 "grammar.y"
+ { yyval.rblk = gen_mpls(cstate, -1); }
break;
case 118:
-#line 509 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pppoed(); }
+#line 539 "grammar.y"
+ { yyval.rblk = gen_pppoed(cstate); }
break;
case 119:
-#line 510 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pppoes(); }
+#line 540 "grammar.y"
+ { yyval.rblk = gen_pppoes(cstate, yystack.l_mark[0].i); }
break;
case 120:
-#line 511 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = yystack.l_mark[0].rblk; }
+#line 541 "grammar.y"
+ { yyval.rblk = gen_pppoes(cstate, -1); }
break;
case 121:
-#line 512 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = yystack.l_mark[0].rblk; }
+#line 542 "grammar.y"
+ { yyval.rblk = gen_geneve(cstate, yystack.l_mark[0].i); }
break;
case 122:
-#line 515 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pf_ifname(yystack.l_mark[0].s); }
+#line 543 "grammar.y"
+ { yyval.rblk = gen_geneve(cstate, -1); }
break;
case 123:
-#line 516 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pf_ruleset(yystack.l_mark[0].s); }
+#line 544 "grammar.y"
+ { yyval.rblk = yystack.l_mark[0].rblk; }
break;
case 124:
-#line 517 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pf_rnr(yystack.l_mark[0].i); }
+#line 545 "grammar.y"
+ { yyval.rblk = yystack.l_mark[0].rblk; }
break;
case 125:
-#line 518 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pf_srnr(yystack.l_mark[0].i); }
+#line 546 "grammar.y"
+ { yyval.rblk = yystack.l_mark[0].rblk; }
break;
case 126:
-#line 519 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pf_reason(yystack.l_mark[0].i); }
+#line 549 "grammar.y"
+ { yyval.rblk = gen_pf_ifname(cstate, yystack.l_mark[0].s); }
break;
case 127:
-#line 520 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_pf_action(yystack.l_mark[0].i); }
+#line 550 "grammar.y"
+ { yyval.rblk = gen_pf_ruleset(cstate, yystack.l_mark[0].s); }
break;
case 128:
-#line 524 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_p80211_type(yystack.l_mark[-2].i | yystack.l_mark[0].i,
+#line 551 "grammar.y"
+ { yyval.rblk = gen_pf_rnr(cstate, yystack.l_mark[0].i); }
+break;
+case 129:
+#line 552 "grammar.y"
+ { yyval.rblk = gen_pf_srnr(cstate, yystack.l_mark[0].i); }
+break;
+case 130:
+#line 553 "grammar.y"
+ { yyval.rblk = gen_pf_reason(cstate, yystack.l_mark[0].i); }
+break;
+case 131:
+#line 554 "grammar.y"
+ { yyval.rblk = gen_pf_action(cstate, yystack.l_mark[0].i); }
+break;
+case 132:
+#line 558 "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 129:
-#line 528 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_p80211_type(yystack.l_mark[0].i,
+case 133:
+#line 562 "grammar.y"
+ { yyval.rblk = gen_p80211_type(cstate, yystack.l_mark[0].i,
IEEE80211_FC0_TYPE_MASK);
}
break;
-case 130:
-#line 531 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_p80211_type(yystack.l_mark[0].i,
+case 134:
+#line 565 "grammar.y"
+ { yyval.rblk = gen_p80211_type(cstate, yystack.l_mark[0].i,
IEEE80211_FC0_TYPE_MASK |
IEEE80211_FC0_SUBTYPE_MASK);
}
break;
-case 131:
-#line 535 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.rblk = gen_p80211_fcdir(yystack.l_mark[0].i); }
+case 135:
+#line 569 "grammar.y"
+ { yyval.rblk = gen_p80211_fcdir(cstate, yystack.l_mark[0].i); }
break;
-case 133:
-#line 539 "../../freebsd/contrib/libpcap/grammar.y"
+case 137:
+#line 573 "grammar.y"
{ yyval.i = str2tok(yystack.l_mark[0].s, ieee80211_types);
if (yyval.i == -1)
- bpf_error("unknown 802.11 type name");
+ bpf_error(cstate, "unknown 802.11 type name");
}
break;
-case 135:
-#line 546 "../../freebsd/contrib/libpcap/grammar.y"
+case 139:
+#line 580 "grammar.y"
{ const struct tok *types = NULL;
int i;
for (i = 0;; i++) {
if (ieee80211_type_subtypes[i].tok == NULL) {
/* Ran out of types */
- bpf_error("unknown 802.11 type");
+ bpf_error(cstate, "unknown 802.11 type");
break;
}
if (yystack.l_mark[-2].i == ieee80211_type_subtypes[i].type) {
@@ -1933,16 +2030,16 @@ case 135:
yyval.i = str2tok(yystack.l_mark[0].s, types);
if (yyval.i == -1)
- bpf_error("unknown 802.11 subtype name");
+ bpf_error(cstate, "unknown 802.11 subtype name");
}
break;
-case 136:
-#line 566 "../../freebsd/contrib/libpcap/grammar.y"
+case 140:
+#line 600 "grammar.y"
{ int i;
for (i = 0;; i++) {
if (ieee80211_type_subtypes[i].tok == NULL) {
/* Ran out of types */
- bpf_error("unknown 802.11 type name");
+ bpf_error(cstate, "unknown 802.11 type name");
break;
}
yyval.i = str2tok(yystack.l_mark[0].s, ieee80211_type_subtypes[i].tok);
@@ -1953,8 +2050,39 @@ case 136:
}
}
break;
-case 138:
-#line 583 "../../freebsd/contrib/libpcap/grammar.y"
+case 141:
+#line 616 "grammar.y"
+ { yyval.rblk = gen_llc(cstate); }
+break;
+case 142:
+#line 617 "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)
+ yyval.rblk = gen_llc_s(cstate);
+ else if (pcap_strcasecmp(yystack.l_mark[0].s, "u") == 0)
+ yyval.rblk = gen_llc_u(cstate);
+ else {
+ int subtype;
+
+ subtype = str2tok(yystack.l_mark[0].s, llc_s_subtypes);
+ if (subtype != -1)
+ yyval.rblk = gen_llc_s_subtype(cstate, subtype);
+ else {
+ subtype = str2tok(yystack.l_mark[0].s, llc_u_subtypes);
+ if (subtype == -1)
+ bpf_error(cstate, "unknown LLC type name \"%s\"", yystack.l_mark[0].s);
+ yyval.rblk = gen_llc_u_subtype(cstate, subtype);
+ }
+ }
+ }
+break;
+case 143:
+#line 638 "grammar.y"
+ { yyval.rblk = gen_llc_s_subtype(cstate, LLC_RNR); }
+break;
+case 145:
+#line 642 "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)
@@ -1964,262 +2092,298 @@ case 138:
else if (pcap_strcasecmp(yystack.l_mark[0].s, "dstods") == 0)
yyval.i = IEEE80211_FC1_DIR_DSTODS;
else
- bpf_error("unknown 802.11 direction");
+ bpf_error(cstate, "unknown 802.11 direction");
}
break;
-case 139:
-#line 596 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = yystack.l_mark[0].i; }
-break;
-case 140:
-#line 597 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = pfreason_to_num(yystack.l_mark[0].s); }
-break;
-case 141:
-#line 600 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = pfaction_to_num(yystack.l_mark[0].s); }
-break;
-case 142:
-#line 603 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = BPF_JGT; }
-break;
-case 143:
-#line 604 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = BPF_JGE; }
-break;
-case 144:
-#line 605 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = BPF_JEQ; }
-break;
-case 145:
-#line 607 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = BPF_JGT; }
-break;
case 146:
-#line 608 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = BPF_JGE; }
+#line 655 "grammar.y"
+ { yyval.i = yystack.l_mark[0].i; }
break;
case 147:
-#line 609 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = BPF_JEQ; }
+#line 656 "grammar.y"
+ { yyval.i = pfreason_to_num(cstate, yystack.l_mark[0].s); }
break;
case 148:
-#line 611 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_loadi(yystack.l_mark[0].i); }
+#line 659 "grammar.y"
+ { yyval.i = pfaction_to_num(cstate, yystack.l_mark[0].s); }
+break;
+case 149:
+#line 662 "grammar.y"
+ { yyval.i = BPF_JGT; }
break;
case 150:
-#line 614 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_load(yystack.l_mark[-3].i, yystack.l_mark[-1].a, 1); }
+#line 663 "grammar.y"
+ { yyval.i = BPF_JGE; }
break;
case 151:
-#line 615 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_load(yystack.l_mark[-5].i, yystack.l_mark[-3].a, yystack.l_mark[-1].i); }
+#line 664 "grammar.y"
+ { yyval.i = BPF_JEQ; }
break;
case 152:
-#line 616 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_ADD, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 666 "grammar.y"
+ { yyval.i = BPF_JGT; }
break;
case 153:
-#line 617 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_SUB, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 667 "grammar.y"
+ { yyval.i = BPF_JGE; }
break;
case 154:
-#line 618 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_MUL, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 668 "grammar.y"
+ { yyval.i = BPF_JEQ; }
break;
case 155:
-#line 619 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_DIV, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
-break;
-case 156:
-#line 620 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_AND, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 670 "grammar.y"
+ { yyval.a = gen_loadi(cstate, yystack.l_mark[0].i); }
break;
case 157:
-#line 621 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_OR, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 673 "grammar.y"
+ { yyval.a = gen_load(cstate, yystack.l_mark[-3].i, yystack.l_mark[-1].a, 1); }
break;
case 158:
-#line 622 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_LSH, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 674 "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 623 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_arth(BPF_RSH, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
+#line 675 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_ADD, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 160:
-#line 624 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_neg(yystack.l_mark[0].a); }
+#line 676 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_SUB, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 161:
-#line 625 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = yystack.l_mark[-1].a; }
+#line 677 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_MUL, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 162:
-#line 626 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.a = gen_loadlen(); }
+#line 678 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_DIV, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 163:
-#line 628 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = '&'; }
+#line 679 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_MOD, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 164:
-#line 629 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = '|'; }
+#line 680 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_AND, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 165:
-#line 630 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = '<'; }
+#line 681 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_OR, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 166:
-#line 631 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = '>'; }
+#line 682 "grammar.y"
+ { yyval.a = gen_arth(cstate, BPF_XOR, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 167:
-#line 632 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = '='; }
+#line 683 "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"
+ { yyval.a = gen_arth(cstate, BPF_RSH, yystack.l_mark[-2].a, yystack.l_mark[0].a); }
break;
case 169:
-#line 635 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = yystack.l_mark[-1].i; }
+#line 685 "grammar.y"
+ { yyval.a = gen_neg(cstate, yystack.l_mark[0].a); }
break;
case 170:
-#line 637 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_LANE; }
+#line 686 "grammar.y"
+ { yyval.a = yystack.l_mark[-1].a; }
break;
case 171:
-#line 638 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_LLC; }
+#line 687 "grammar.y"
+ { yyval.a = gen_loadlen(cstate); }
break;
case 172:
-#line 639 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_METAC; }
+#line 689 "grammar.y"
+ { yyval.i = '&'; }
break;
case 173:
-#line 640 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_BCC; }
+#line 690 "grammar.y"
+ { yyval.i = '|'; }
break;
case 174:
-#line 641 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_OAMF4EC; }
+#line 691 "grammar.y"
+ { yyval.i = '<'; }
break;
case 175:
-#line 642 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_OAMF4SC; }
+#line 692 "grammar.y"
+ { yyval.i = '>'; }
break;
case 176:
-#line 643 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_SC; }
-break;
-case 177:
-#line 644 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_ILMIC; }
+#line 693 "grammar.y"
+ { yyval.i = '='; }
break;
case 178:
-#line 646 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_OAM; }
+#line 696 "grammar.y"
+ { yyval.i = yystack.l_mark[-1].i; }
break;
case 179:
-#line 647 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_OAMF4; }
+#line 698 "grammar.y"
+ { yyval.i = A_LANE; }
break;
case 180:
-#line 648 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_CONNECTMSG; }
+#line 699 "grammar.y"
+ { yyval.i = A_METAC; }
break;
case 181:
-#line 649 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.i = A_METACONNECT; }
+#line 700 "grammar.y"
+ { yyval.i = A_BCC; }
break;
case 182:
-#line 652 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.atmfieldtype = A_VPI; }
+#line 701 "grammar.y"
+ { yyval.i = A_OAMF4EC; }
break;
case 183:
-#line 653 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.atmfieldtype = A_VCI; }
+#line 702 "grammar.y"
+ { yyval.i = A_OAMF4SC; }
+break;
+case 184:
+#line 703 "grammar.y"
+ { yyval.i = A_SC; }
break;
case 185:
-#line 656 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_atmfield_code(yystack.l_mark[-2].blk.atmfieldtype, (bpf_int32)yystack.l_mark[0].i, (bpf_u_int32)yystack.l_mark[-1].i, 0); }
+#line 704 "grammar.y"
+ { yyval.i = A_ILMIC; }
break;
case 186:
-#line 657 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_atmfield_code(yystack.l_mark[-2].blk.atmfieldtype, (bpf_int32)yystack.l_mark[0].i, (bpf_u_int32)yystack.l_mark[-1].i, 1); }
+#line 706 "grammar.y"
+ { yyval.i = A_OAM; }
break;
case 187:
-#line 658 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = qerr; }
+#line 707 "grammar.y"
+ { yyval.i = A_OAMF4; }
break;
case 188:
-#line 660 "../../freebsd/contrib/libpcap/grammar.y"
+#line 708 "grammar.y"
+ { yyval.i = A_CONNECTMSG; }
+break;
+case 189:
+#line 709 "grammar.y"
+ { yyval.i = A_METACONNECT; }
+break;
+case 190:
+#line 712 "grammar.y"
+ { yyval.blk.atmfieldtype = A_VPI; }
+break;
+case 191:
+#line 713 "grammar.y"
+ { yyval.blk.atmfieldtype = A_VCI; }
+break;
+case 193:
+#line 716 "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"
+ { 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"
+ { yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = qerr; }
+break;
+case 196:
+#line 720 "grammar.y"
{
yyval.blk.atmfieldtype = yystack.l_mark[-1].blk.atmfieldtype;
if (yyval.blk.atmfieldtype == A_VPI ||
yyval.blk.atmfieldtype == A_VCI)
- yyval.blk.b = gen_atmfield_code(yyval.blk.atmfieldtype, (bpf_int32) yystack.l_mark[0].i, BPF_JEQ, 0);
+ yyval.blk.b = gen_atmfield_code(cstate, yyval.blk.atmfieldtype, (bpf_int32) yystack.l_mark[0].i, BPF_JEQ, 0);
}
break;
-case 190:
-#line 668 "../../freebsd/contrib/libpcap/grammar.y"
+case 198:
+#line 728 "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 191:
-#line 671 "../../freebsd/contrib/libpcap/grammar.y"
+case 199:
+#line 731 "grammar.y"
{ yyval.i = M_FISU; }
break;
-case 192:
-#line 672 "../../freebsd/contrib/libpcap/grammar.y"
+case 200:
+#line 732 "grammar.y"
{ yyval.i = M_LSSU; }
break;
-case 193:
-#line 673 "../../freebsd/contrib/libpcap/grammar.y"
+case 201:
+#line 733 "grammar.y"
{ yyval.i = M_MSU; }
break;
-case 194:
-#line 676 "../../freebsd/contrib/libpcap/grammar.y"
+case 202:
+#line 734 "grammar.y"
+ { yyval.i = MH_FISU; }
+break;
+case 203:
+#line 735 "grammar.y"
+ { yyval.i = MH_LSSU; }
+break;
+case 204:
+#line 736 "grammar.y"
+ { yyval.i = MH_MSU; }
+break;
+case 205:
+#line 739 "grammar.y"
{ yyval.blk.mtp3fieldtype = M_SIO; }
break;
-case 195:
-#line 677 "../../freebsd/contrib/libpcap/grammar.y"
+case 206:
+#line 740 "grammar.y"
{ yyval.blk.mtp3fieldtype = M_OPC; }
break;
-case 196:
-#line 678 "../../freebsd/contrib/libpcap/grammar.y"
+case 207:
+#line 741 "grammar.y"
{ yyval.blk.mtp3fieldtype = M_DPC; }
break;
-case 197:
-#line 679 "../../freebsd/contrib/libpcap/grammar.y"
+case 208:
+#line 742 "grammar.y"
{ yyval.blk.mtp3fieldtype = M_SLS; }
break;
-case 199:
-#line 682 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_mtp3field_code(yystack.l_mark[-2].blk.mtp3fieldtype, (u_int)yystack.l_mark[0].i, (u_int)yystack.l_mark[-1].i, 0); }
+case 209:
+#line 743 "grammar.y"
+ { yyval.blk.mtp3fieldtype = MH_SIO; }
break;
-case 200:
-#line 683 "../../freebsd/contrib/libpcap/grammar.y"
- { yyval.blk.b = gen_mtp3field_code(yystack.l_mark[-2].blk.mtp3fieldtype, (u_int)yystack.l_mark[0].i, (u_int)yystack.l_mark[-1].i, 1); }
+case 210:
+#line 744 "grammar.y"
+ { yyval.blk.mtp3fieldtype = MH_OPC; }
break;
-case 201:
-#line 684 "../../freebsd/contrib/libpcap/grammar.y"
+case 211:
+#line 745 "grammar.y"
+ { yyval.blk.mtp3fieldtype = MH_DPC; }
+break;
+case 212:
+#line 746 "grammar.y"
+ { yyval.blk.mtp3fieldtype = MH_SLS; }
+break;
+case 214:
+#line 749 "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"
+ { 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"
{ yyval.blk.b = yystack.l_mark[-1].blk.b; yyval.blk.q = qerr; }
break;
-case 202:
-#line 686 "../../freebsd/contrib/libpcap/grammar.y"
+case 217:
+#line 753 "grammar.y"
{
yyval.blk.mtp3fieldtype = yystack.l_mark[-1].blk.mtp3fieldtype;
if (yyval.blk.mtp3fieldtype == M_SIO ||
yyval.blk.mtp3fieldtype == M_OPC ||
yyval.blk.mtp3fieldtype == M_DPC ||
- yyval.blk.mtp3fieldtype == M_SLS )
- yyval.blk.b = gen_mtp3field_code(yyval.blk.mtp3fieldtype, (u_int) yystack.l_mark[0].i, BPF_JEQ, 0);
+ yyval.blk.mtp3fieldtype == M_SLS ||
+ yyval.blk.mtp3fieldtype == MH_SIO ||
+ yyval.blk.mtp3fieldtype == MH_OPC ||
+ yyval.blk.mtp3fieldtype == MH_DPC ||
+ yyval.blk.mtp3fieldtype == MH_SLS)
+ yyval.blk.b = gen_mtp3field_code(cstate, yyval.blk.mtp3fieldtype, (u_int) yystack.l_mark[0].i, BPF_JEQ, 0);
}
break;
-case 204:
-#line 696 "../../freebsd/contrib/libpcap/grammar.y"
+case 219:
+#line 767 "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 2223 "pcap.tab.c"
+#line 2387 "grammar.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
@@ -2237,11 +2401,12 @@ break;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
- if ((yychar = YYLEX) < 0) yychar = YYEOF;
+ yychar = YYLEX;
+ if (yychar < 0) yychar = YYEOF;
#if YYDEBUG
if (yydebug)
{
- yys = yyname[YYTRANSLATE(yychar)];
+ if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
@@ -2250,8 +2415,8 @@ break;
if (yychar == YYEOF) goto yyaccept;
goto yyloop;
}
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
@@ -2260,10 +2425,7 @@ break;
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
- if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
- {
- goto yyoverflow;
- }
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
*++yystack.s_mark = (YYINT) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
diff --git a/freebsd/contrib/libpcap/tokdefs.h b/freebsd/contrib/libpcap/grammar.h
index 24a88040..35019dd2 100644
--- a/freebsd/contrib/libpcap/tokdefs.h
+++ b/freebsd/contrib/libpcap/grammar.h
@@ -70,45 +70,53 @@
#define MPLS 326
#define PPPOED 327
#define PPPOES 328
-#define ISO 329
-#define ESIS 330
-#define CLNP 331
-#define ISIS 332
-#define L1 333
-#define L2 334
-#define IIH 335
-#define LSP 336
-#define SNP 337
-#define CSNP 338
-#define PSNP 339
-#define STP 340
-#define IPX 341
-#define NETBEUI 342
-#define LANE 343
-#define LLC 344
-#define METAC 345
-#define BCC 346
-#define SC 347
-#define ILMIC 348
-#define OAMF4EC 349
-#define OAMF4SC 350
-#define OAM 351
-#define OAMF4 352
-#define CONNECTMSG 353
-#define METACONNECT 354
-#define VPI 355
-#define VCI 356
-#define RADIO 357
-#define FISU 358
-#define LSSU 359
-#define MSU 360
-#define SIO 361
-#define OPC 362
-#define DPC 363
-#define SLS 364
-#define OR 365
-#define AND 366
-#define UMINUS 367
+#define GENEVE 329
+#define ISO 330
+#define ESIS 331
+#define CLNP 332
+#define ISIS 333
+#define L1 334
+#define L2 335
+#define IIH 336
+#define LSP 337
+#define SNP 338
+#define CSNP 339
+#define PSNP 340
+#define STP 341
+#define IPX 342
+#define NETBEUI 343
+#define LANE 344
+#define LLC 345
+#define METAC 346
+#define BCC 347
+#define SC 348
+#define ILMIC 349
+#define OAMF4EC 350
+#define OAMF4SC 351
+#define OAM 352
+#define OAMF4 353
+#define CONNECTMSG 354
+#define METACONNECT 355
+#define VPI 356
+#define VCI 357
+#define RADIO 358
+#define FISU 359
+#define LSSU 360
+#define MSU 361
+#define HFISU 362
+#define HLSSU 363
+#define HMSU 364
+#define SIO 365
+#define OPC 366
+#define DPC 367
+#define SLS 368
+#define HSIO 369
+#define HOPC 370
+#define HDPC 371
+#define HSLS 372
+#define OR 373
+#define AND 374
+#define UMINUS 375
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
@@ -131,4 +139,4 @@ typedef union {
struct block *rblk;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
-extern YYSTYPE pcaplval;
+extern YYSTYPE pcap_lval;
diff --git a/freebsd/contrib/libpcap/grammar.y b/freebsd/contrib/libpcap/grammar.y
index ac69db9f..ef6a7abb 100644
--- a/freebsd/contrib/libpcap/grammar.y
+++ b/freebsd/contrib/libpcap/grammar.y
@@ -1,3 +1,28 @@
+/*
+ * We want a reentrant parser.
+ */
+%pure-parser
+
+/*
+ * We also want a reentrant scanner, so we have to pass the
+ * handle for the reentrant scanner to the parser, and the
+ * parser has to pass it to the lexical analyzer.
+ *
+ * We use void * rather than yyscan_t because, at least with some
+ * versions of Flex and Bison, if you use yyscan_t in %parse-param and
+ * %lex-param, you have to include scanner.h before grammar.h to get
+ * yyscan_t declared, and you have to include grammar.h before scanner.h
+ * to get YYSTYPE declared. Using void * breaks the cycle; the Flex
+ * documentation says yyscan_t is just a void *.
+ */
+%parse-param {void *yyscanner}
+%lex-param {void *yyscanner}
+
+/*
+ * And we need to pass the compiler state to the scanner.
+ */
+%parse-param {compiler_state_t *cstate}
+
%{
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
@@ -21,25 +46,21 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.101 2007-11-18 02:03:52 guy Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdlib.h>
-#ifndef WIN32
+#ifndef _WIN32
#if __STDC__
struct mbuf;
struct rtentry;
@@ -47,18 +68,22 @@ struct rtentry;
#include <netinet/in.h>
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdio.h>
#include "pcap-int.h"
#include "gencode.h"
+#include "grammar.h"
+#include "scanner.h"
+
#ifdef HAVE_NET_PFVAR_H
#include <net/if.h>
-#include <net/pfvar.h>
+#include <netpfil/pf/pf.h>
#include <net/if_pflog.h>
#endif
+#include "llc.h"
#include "ieee80211.h"
#include <pcap/namedb.h>
@@ -133,6 +158,23 @@ static const struct tok ieee80211_data_subtypes[] = {
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL, "qos-cf-ack-poll" },
{ 0, NULL }
};
+static const struct tok llc_s_subtypes[] = {
+ { LLC_RR, "rr" },
+ { LLC_RNR, "rnr" },
+ { LLC_REJ, "rej" },
+ { 0, NULL }
+};
+static const struct tok llc_u_subtypes[] = {
+ { LLC_UI, "ui" },
+ { LLC_UA, "ua" },
+ { LLC_DISC, "disc" },
+ { LLC_DM, "dm" },
+ { LLC_SABME, "sabme" },
+ { LLC_TEST, "test" },
+ { LLC_XID, "xid" },
+ { LLC_FRMR, "frmr" },
+ { 0, NULL }
+};
struct type2tok {
int type;
const struct tok *tok;
@@ -156,31 +198,18 @@ str2tok(const char *str, const struct tok *toks)
return (-1);
}
-int n_errors = 0;
-
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
static void
-yyerror(const char *msg)
+yyerror(void *yyscanner, compiler_state_t *cstate, const char *msg)
{
- ++n_errors;
- bpf_error("%s", msg);
+ bpf_syntax_error(cstate, msg);
/* NOTREACHED */
}
-#ifdef NEED_YYPARSE_WRAPPER
-int yyparse(void);
-
-int
-pcap_parse()
-{
- return (yyparse());
-}
-#endif
-
#ifdef HAVE_NET_PFVAR_H
static int
-pfreason_to_num(const char *reason)
+pfreason_to_num(compiler_state_t *cstate, const char *reason)
{
const char *reasons[] = PFRES_NAMES;
int i;
@@ -189,12 +218,12 @@ pfreason_to_num(const char *reason)
if (pcap_strcasecmp(reason, reasons[i]) == 0)
return (i);
}
- bpf_error("unknown PF reason");
+ bpf_error(cstate, "unknown PF reason");
/*NOTREACHED*/
}
static int
-pfaction_to_num(const char *action)
+pfaction_to_num(compiler_state_t *cstate, const char *action)
{
if (pcap_strcasecmp(action, "pass") == 0 ||
pcap_strcasecmp(action, "accept") == 0)
@@ -213,15 +242,15 @@ pfaction_to_num(const char *action)
return (PF_NORDR);
#endif
else {
- bpf_error("unknown PF action");
+ bpf_error(cstate, "unknown PF action");
/*NOTREACHED*/
}
}
#else /* !HAVE_NET_PFVAR_H */
static int
-pfreason_to_num(const char *reason)
+pfreason_to_num(compiler_state_t *cstate, const char *reason)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/*NOTREACHED*/
/* this is to make the VC compiler happy */
@@ -229,9 +258,9 @@ pfreason_to_num(const char *reason)
}
static int
-pfaction_to_num(const char *action)
+pfaction_to_num(compiler_state_t *cstate, const char *action)
{
- bpf_error("libpcap was compiled on a machine without pf support");
+ bpf_error(cstate, "libpcap was compiled on a machine without pf support");
/*NOTREACHED*/
/* this is to make the VC compiler happy */
@@ -262,7 +291,7 @@ pfaction_to_num(const char *action)
%type <a> arth narth
%type <i> byteop pname pnum relop irelop
%type <blk> and or paren not null prog
-%type <rblk> other pfvar p80211
+%type <rblk> other pfvar p80211 pllc
%type <i> atmtype atmmultitype
%type <blk> atmfield
%type <blk> atmfieldvalue atmvalue atmlistvalue
@@ -286,8 +315,8 @@ pfaction_to_num(const char *action)
%token LEN
%token IPV6 ICMPV6 AH ESP
%token VLAN MPLS
-%token PPPOED PPPOES
-%token ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP
+%token PPPOED PPPOES GENEVE
+%token ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP
%token STP
%token IPX
%token NETBEUI
@@ -295,8 +324,9 @@ pfaction_to_num(const char *action)
%token OAM OAMF4 CONNECTMSG METACONNECT
%token VPI VCI
%token RADIO
-%token FISU LSSU MSU
-%token SIO OPC DPC SLS
+%token FISU LSSU MSU HFISU HLSSU HMSU
+%token SIO OPC DPC SLS HSIO HOPC HDPC HSLS
+
%type <s> ID
%type <e> EID
@@ -315,7 +345,7 @@ pfaction_to_num(const char *action)
%%
prog: null expr
{
- finish_parse($2.b);
+ finish_parse(cstate, $2.b);
}
| null
;
@@ -332,48 +362,48 @@ and: AND { $$ = $<blk>0; }
or: OR { $$ = $<blk>0; }
;
id: nid
- | pnum { $$.b = gen_ncode(NULL, (bpf_u_int32)$1,
+ | pnum { $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
$$.q = $<blk>0.q); }
| paren pid ')' { $$ = $2; }
;
-nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
- | HID '/' NUM { $$.b = gen_mcode($1, NULL, $3,
+nid: ID { $$.b = gen_scode(cstate, $1, $$.q = $<blk>0.q); }
+ | HID '/' NUM { $$.b = gen_mcode(cstate, $1, NULL, $3,
$$.q = $<blk>0.q); }
- | HID NETMASK HID { $$.b = gen_mcode($1, $3, 0,
+ | HID NETMASK HID { $$.b = gen_mcode(cstate, $1, $3, 0,
$$.q = $<blk>0.q); }
| HID {
/* Decide how to parse HID based on proto */
$$.q = $<blk>0.q;
if ($$.q.addr == Q_PORT)
- bpf_error("'port' modifier applied to ip host");
+ bpf_error(cstate, "'port' modifier applied to ip host");
else if ($$.q.addr == Q_PORTRANGE)
- bpf_error("'portrange' modifier applied to ip host");
+ bpf_error(cstate, "'portrange' modifier applied to ip host");
else if ($$.q.addr == Q_PROTO)
- bpf_error("'proto' modifier applied to ip host");
+ bpf_error(cstate, "'proto' modifier applied to ip host");
else if ($$.q.addr == Q_PROTOCHAIN)
- bpf_error("'protochain' modifier applied to ip host");
- $$.b = gen_ncode($1, 0, $$.q);
+ bpf_error(cstate, "'protochain' modifier applied to ip host");
+ $$.b = gen_ncode(cstate, $1, 0, $$.q);
}
| HID6 '/' NUM {
#ifdef INET6
- $$.b = gen_mcode6($1, NULL, $3,
+ $$.b = gen_mcode6(cstate, $1, NULL, $3,
$$.q = $<blk>0.q);
#else
- bpf_error("'ip6addr/prefixlen' not supported "
+ bpf_error(cstate, "'ip6addr/prefixlen' not supported "
"in this configuration");
#endif /*INET6*/
}
| HID6 {
#ifdef INET6
- $$.b = gen_mcode6($1, 0, 128,
+ $$.b = gen_mcode6(cstate, $1, 0, 128,
$$.q = $<blk>0.q);
#else
- bpf_error("'ip6addr' not supported "
+ bpf_error(cstate, "'ip6addr' not supported "
"in this configuration");
#endif /*INET6*/
}
- | EID {
- $$.b = gen_ecode($1, $$.q = $<blk>0.q);
+ | EID {
+ $$.b = gen_ecode(cstate, $1, $$.q = $<blk>0.q);
/*
* $1 was allocated by "pcap_ether_aton()",
* so we must free it now that we're done
@@ -382,7 +412,7 @@ nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
free($1);
}
| AID {
- $$.b = gen_acode($1, $$.q = $<blk>0.q);
+ $$.b = gen_acode(cstate, $1, $$.q = $<blk>0.q);
/*
* $1 was allocated by "pcap_ether_aton()",
* so we must free it now that we're done
@@ -400,7 +430,7 @@ pid: nid
| qid and id { gen_and($1.b, $3.b); $$ = $3; }
| qid or id { gen_or($1.b, $3.b); $$ = $3; }
;
-qid: pnum { $$.b = gen_ncode(NULL, (bpf_u_int32)$1,
+qid: pnum { $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
$$.q = $<blk>0.q); }
| pid
;
@@ -416,16 +446,16 @@ head: pqual dqual aqual { QSET($$.q, $1, $2, $3); }
;
rterm: head id { $$ = $2; }
| paren expr ')' { $$.b = $2.b; $$.q = $1.q; }
- | pname { $$.b = gen_proto_abbrev($1); $$.q = qerr; }
- | arth relop arth { $$.b = gen_relation($2, $1, $3, 0);
+ | pname { $$.b = gen_proto_abbrev(cstate, $1); $$.q = qerr; }
+ | arth relop arth { $$.b = gen_relation(cstate, $2, $1, $3, 0);
$$.q = qerr; }
- | arth irelop arth { $$.b = gen_relation($2, $1, $3, 1);
+ | arth irelop arth { $$.b = gen_relation(cstate, $2, $1, $3, 1);
$$.q = qerr; }
| other { $$.b = $1; $$.q = qerr; }
- | atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
- | atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
+ | atmtype { $$.b = gen_atmtype_abbrev(cstate, $1); $$.q = qerr; }
+ | atmmultitype { $$.b = gen_atmmulti_abbrev(cstate, $1); $$.q = qerr; }
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
- | mtp2type { $$.b = gen_mtp2type_abbrev($1); $$.q = qerr; }
+ | mtp2type { $$.b = gen_mtp2type_abbrev(cstate, $1); $$.q = qerr; }
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
;
/* protocol level qualifiers */
@@ -495,50 +525,54 @@ pname: LINK { $$ = Q_LINK; }
| NETBEUI { $$ = Q_NETBEUI; }
| RADIO { $$ = Q_RADIO; }
;
-other: pqual TK_BROADCAST { $$ = gen_broadcast($1); }
- | pqual TK_MULTICAST { $$ = gen_multicast($1); }
- | LESS NUM { $$ = gen_less($2); }
- | GREATER NUM { $$ = gen_greater($2); }
- | CBYTE NUM byteop NUM { $$ = gen_byteop($3, $2, $4); }
- | INBOUND { $$ = gen_inbound(0); }
- | OUTBOUND { $$ = gen_inbound(1); }
- | VLAN pnum { $$ = gen_vlan($2); }
- | VLAN { $$ = gen_vlan(-1); }
- | MPLS pnum { $$ = gen_mpls($2); }
- | MPLS { $$ = gen_mpls(-1); }
- | PPPOED { $$ = gen_pppoed(); }
- | PPPOES { $$ = gen_pppoes(); }
+other: pqual TK_BROADCAST { $$ = gen_broadcast(cstate, $1); }
+ | pqual TK_MULTICAST { $$ = gen_multicast(cstate, $1); }
+ | LESS NUM { $$ = gen_less(cstate, $2); }
+ | GREATER NUM { $$ = gen_greater(cstate, $2); }
+ | CBYTE NUM byteop NUM { $$ = gen_byteop(cstate, $3, $2, $4); }
+ | INBOUND { $$ = gen_inbound(cstate, 0); }
+ | OUTBOUND { $$ = gen_inbound(cstate, 1); }
+ | VLAN pnum { $$ = gen_vlan(cstate, $2); }
+ | VLAN { $$ = gen_vlan(cstate, -1); }
+ | MPLS pnum { $$ = gen_mpls(cstate, $2); }
+ | MPLS { $$ = gen_mpls(cstate, -1); }
+ | PPPOED { $$ = gen_pppoed(cstate); }
+ | PPPOES pnum { $$ = gen_pppoes(cstate, $2); }
+ | PPPOES { $$ = gen_pppoes(cstate, -1); }
+ | GENEVE pnum { $$ = gen_geneve(cstate, $2); }
+ | GENEVE { $$ = gen_geneve(cstate, -1); }
| pfvar { $$ = $1; }
| pqual p80211 { $$ = $2; }
+ | pllc { $$ = $1; }
;
-pfvar: PF_IFNAME ID { $$ = gen_pf_ifname($2); }
- | PF_RSET ID { $$ = gen_pf_ruleset($2); }
- | PF_RNR NUM { $$ = gen_pf_rnr($2); }
- | PF_SRNR NUM { $$ = gen_pf_srnr($2); }
- | PF_REASON reason { $$ = gen_pf_reason($2); }
- | PF_ACTION action { $$ = gen_pf_action($2); }
+pfvar: PF_IFNAME ID { $$ = gen_pf_ifname(cstate, $2); }
+ | PF_RSET ID { $$ = gen_pf_ruleset(cstate, $2); }
+ | PF_RNR NUM { $$ = gen_pf_rnr(cstate, $2); }
+ | PF_SRNR NUM { $$ = gen_pf_srnr(cstate, $2); }
+ | PF_REASON reason { $$ = gen_pf_reason(cstate, $2); }
+ | PF_ACTION action { $$ = gen_pf_action(cstate, $2); }
;
p80211: TYPE type SUBTYPE subtype
- { $$ = gen_p80211_type($2 | $4,
+ { $$ = gen_p80211_type(cstate, $2 | $4,
IEEE80211_FC0_TYPE_MASK |
IEEE80211_FC0_SUBTYPE_MASK);
}
- | TYPE type { $$ = gen_p80211_type($2,
+ | TYPE type { $$ = gen_p80211_type(cstate, $2,
IEEE80211_FC0_TYPE_MASK);
}
- | SUBTYPE type_subtype { $$ = gen_p80211_type($2,
+ | SUBTYPE type_subtype { $$ = gen_p80211_type(cstate, $2,
IEEE80211_FC0_TYPE_MASK |
IEEE80211_FC0_SUBTYPE_MASK);
}
- | DIR dir { $$ = gen_p80211_fcdir($2); }
+ | DIR dir { $$ = gen_p80211_fcdir(cstate, $2); }
;
type: NUM
| ID { $$ = str2tok($1, ieee80211_types);
if ($$ == -1)
- bpf_error("unknown 802.11 type name");
+ bpf_error(cstate, "unknown 802.11 type name");
}
;
@@ -548,7 +582,7 @@ subtype: NUM
for (i = 0;; i++) {
if (ieee80211_type_subtypes[i].tok == NULL) {
/* Ran out of types */
- bpf_error("unknown 802.11 type");
+ bpf_error(cstate, "unknown 802.11 type");
break;
}
if ($<i>-1 == ieee80211_type_subtypes[i].type) {
@@ -559,7 +593,7 @@ subtype: NUM
$$ = str2tok($1, types);
if ($$ == -1)
- bpf_error("unknown 802.11 subtype name");
+ bpf_error(cstate, "unknown 802.11 subtype name");
}
;
@@ -567,7 +601,7 @@ type_subtype: ID { int i;
for (i = 0;; i++) {
if (ieee80211_type_subtypes[i].tok == NULL) {
/* Ran out of types */
- bpf_error("unknown 802.11 type name");
+ bpf_error(cstate, "unknown 802.11 type name");
break;
}
$$ = str2tok($1, ieee80211_type_subtypes[i].tok);
@@ -579,6 +613,31 @@ type_subtype: ID { int i;
}
;
+pllc: LLC { $$ = gen_llc(cstate); }
+ | LLC ID { if (pcap_strcasecmp($2, "i") == 0)
+ $$ = gen_llc_i(cstate);
+ else if (pcap_strcasecmp($2, "s") == 0)
+ $$ = gen_llc_s(cstate);
+ else if (pcap_strcasecmp($2, "u") == 0)
+ $$ = gen_llc_u(cstate);
+ else {
+ int subtype;
+
+ subtype = str2tok($2, llc_s_subtypes);
+ if (subtype != -1)
+ $$ = gen_llc_s_subtype(cstate, subtype);
+ else {
+ subtype = str2tok($2, llc_u_subtypes);
+ if (subtype == -1)
+ bpf_error(cstate, "unknown LLC type name \"%s\"", $2);
+ $$ = gen_llc_u_subtype(cstate, subtype);
+ }
+ }
+ }
+ /* sigh, "rnr" is already a keyword for PF */
+ | LLC PF_RNR { $$ = gen_llc_s_subtype(cstate, LLC_RNR); }
+ ;
+
dir: NUM
| ID { if (pcap_strcasecmp($1, "nods") == 0)
$$ = IEEE80211_FC1_DIR_NODS;
@@ -589,15 +648,15 @@ dir: NUM
else if (pcap_strcasecmp($1, "dstods") == 0)
$$ = IEEE80211_FC1_DIR_DSTODS;
else
- bpf_error("unknown 802.11 direction");
+ bpf_error(cstate, "unknown 802.11 direction");
}
;
reason: NUM { $$ = $1; }
- | ID { $$ = pfreason_to_num($1); }
+ | ID { $$ = pfreason_to_num(cstate, $1); }
;
-action: ID { $$ = pfaction_to_num($1); }
+action: ID { $$ = pfaction_to_num(cstate, $1); }
;
relop: '>' { $$ = BPF_JGT; }
@@ -608,22 +667,24 @@ irelop: LEQ { $$ = BPF_JGT; }
| '<' { $$ = BPF_JGE; }
| NEQ { $$ = BPF_JEQ; }
;
-arth: pnum { $$ = gen_loadi($1); }
+arth: pnum { $$ = gen_loadi(cstate, $1); }
| narth
;
-narth: pname '[' arth ']' { $$ = gen_load($1, $3, 1); }
- | pname '[' arth ':' NUM ']' { $$ = gen_load($1, $3, $5); }
- | arth '+' arth { $$ = gen_arth(BPF_ADD, $1, $3); }
- | arth '-' arth { $$ = gen_arth(BPF_SUB, $1, $3); }
- | arth '*' arth { $$ = gen_arth(BPF_MUL, $1, $3); }
- | arth '/' arth { $$ = gen_arth(BPF_DIV, $1, $3); }
- | arth '&' arth { $$ = gen_arth(BPF_AND, $1, $3); }
- | arth '|' arth { $$ = gen_arth(BPF_OR, $1, $3); }
- | arth LSH arth { $$ = gen_arth(BPF_LSH, $1, $3); }
- | arth RSH arth { $$ = gen_arth(BPF_RSH, $1, $3); }
- | '-' arth %prec UMINUS { $$ = gen_neg($2); }
+narth: pname '[' arth ']' { $$ = gen_load(cstate, $1, $3, 1); }
+ | pname '[' arth ':' NUM ']' { $$ = gen_load(cstate, $1, $3, $5); }
+ | arth '+' arth { $$ = gen_arth(cstate, BPF_ADD, $1, $3); }
+ | arth '-' arth { $$ = gen_arth(cstate, BPF_SUB, $1, $3); }
+ | arth '*' arth { $$ = gen_arth(cstate, BPF_MUL, $1, $3); }
+ | arth '/' arth { $$ = gen_arth(cstate, BPF_DIV, $1, $3); }
+ | arth '%' arth { $$ = gen_arth(cstate, BPF_MOD, $1, $3); }
+ | arth '&' arth { $$ = gen_arth(cstate, BPF_AND, $1, $3); }
+ | arth '|' arth { $$ = gen_arth(cstate, BPF_OR, $1, $3); }
+ | arth '^' arth { $$ = gen_arth(cstate, BPF_XOR, $1, $3); }
+ | arth LSH arth { $$ = gen_arth(cstate, BPF_LSH, $1, $3); }
+ | arth RSH arth { $$ = gen_arth(cstate, BPF_RSH, $1, $3); }
+ | '-' arth %prec UMINUS { $$ = gen_neg(cstate, $2); }
| paren narth ')' { $$ = $2; }
- | LEN { $$ = gen_loadlen(); }
+ | LEN { $$ = gen_loadlen(cstate); }
;
byteop: '&' { $$ = '&'; }
| '|' { $$ = '|'; }
@@ -635,7 +696,6 @@ pnum: NUM
| paren pnum ')' { $$ = $2; }
;
atmtype: LANE { $$ = A_LANE; }
- | LLC { $$ = A_LLC; }
| METAC { $$ = A_METAC; }
| BCC { $$ = A_BCC; }
| OAMF4EC { $$ = A_OAMF4EC; }
@@ -653,15 +713,15 @@ atmfield: VPI { $$.atmfieldtype = A_VPI; }
| VCI { $$.atmfieldtype = A_VCI; }
;
atmvalue: atmfieldvalue
- | relop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
- | irelop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
+ | relop NUM { $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
+ | irelop NUM { $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
;
atmfieldvalue: NUM {
$$.atmfieldtype = $<blk>0.atmfieldtype;
if ($$.atmfieldtype == A_VPI ||
$$.atmfieldtype == A_VCI)
- $$.b = gen_atmfield_code($$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
+ $$.b = gen_atmfield_code(cstate, $$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
}
;
atmlistvalue: atmfieldvalue
@@ -671,16 +731,23 @@ atmlistvalue: atmfieldvalue
mtp2type: FISU { $$ = M_FISU; }
| LSSU { $$ = M_LSSU; }
| MSU { $$ = M_MSU; }
+ | HFISU { $$ = MH_FISU; }
+ | HLSSU { $$ = MH_LSSU; }
+ | HMSU { $$ = MH_MSU; }
;
/* MTP3 field types quantifier */
mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
| OPC { $$.mtp3fieldtype = M_OPC; }
| DPC { $$.mtp3fieldtype = M_DPC; }
| SLS { $$.mtp3fieldtype = M_SLS; }
+ | HSIO { $$.mtp3fieldtype = MH_SIO; }
+ | HOPC { $$.mtp3fieldtype = MH_OPC; }
+ | HDPC { $$.mtp3fieldtype = MH_DPC; }
+ | HSLS { $$.mtp3fieldtype = MH_SLS; }
;
mtp3value: mtp3fieldvalue
- | relop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
- | irelop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
+ | relop NUM { $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
+ | irelop NUM { $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
;
mtp3fieldvalue: NUM {
@@ -688,8 +755,12 @@ mtp3fieldvalue: NUM {
if ($$.mtp3fieldtype == M_SIO ||
$$.mtp3fieldtype == M_OPC ||
$$.mtp3fieldtype == M_DPC ||
- $$.mtp3fieldtype == M_SLS )
- $$.b = gen_mtp3field_code($$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
+ $$.mtp3fieldtype == M_SLS ||
+ $$.mtp3fieldtype == MH_SIO ||
+ $$.mtp3fieldtype == MH_OPC ||
+ $$.mtp3fieldtype == MH_DPC ||
+ $$.mtp3fieldtype == MH_SLS)
+ $$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
}
;
mtp3listvalue: mtp3fieldvalue
diff --git a/freebsd/contrib/libpcap/ieee80211.h b/freebsd/contrib/libpcap/ieee80211.h
index d79f0f8e..894a9e76 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_WEP 0x40
+#define IEEE80211_FC1_PROTECTED 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
index 92ae3ab8..1945e4fc 100644
--- a/freebsd/contrib/libpcap/inet.c
+++ b/freebsd/contrib/libpcap/inet.c
@@ -34,18 +34,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.79 2008-04-20 18:19:02 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#include <sys/param.h>
#ifndef MSDOS
@@ -61,22 +56,16 @@ 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 */
+#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__)
+#if !defined(_WIN32) && !defined(__BORLANDC__)
#include <unistd.h>
-#endif /* !WIN32 && !__BORLANDC__ */
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-#define INT_MAX 2147483647
-#endif
+#endif /* !_WIN32 && !__BORLANDC__ */
#include "pcap-int.h"
@@ -84,585 +73,7 @@ struct rtentry; /* declarations in <net/if.h> */
#include "os-proto.h"
#endif
-/* 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
-
-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));
-}
-
-static int
-get_instance(const char *name)
-{
- const char *cp, *endcp;
- int n;
-
- if (strcmp(name, "any") == 0) {
- /*
- * Give the "any" device an artificially high instance
- * number, so it shows up after all other non-loopback
- * interfaces.
- */
- return INT_MAX;
- }
-
- endcp = name + strlen(name);
- for (cp = name; cp < endcp && !isdigit((unsigned char)*cp); ++cp)
- continue;
-
- if (isdigit((unsigned char)*cp))
- n = atoi(cp);
- else
- n = 0;
- return (n);
-}
-
-int
-add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
- u_int flags, const char *description, char *errbuf)
-{
- pcap_t *p;
- pcap_if_t *curdev, *prevdev, *nextdev;
- int this_instance;
- char open_errbuf[PCAP_ERRBUF_SIZE];
-
- /*
- * 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)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "malloc: %s", pcap_strerror(errno));
- return (-1);
- }
- strcpy(en_name, "en");
- strcat(en_name, name + 3);
- p = pcap_open_live(en_name, 68, 0, 0, open_errbuf);
- free(en_name);
- } else
-#endif /* __APPLE */
- p = pcap_open_live(name, 68, 0, 0, open_errbuf);
- if (p == NULL) {
- /*
- * No. Don't bother including it.
- * Don't treat this as an error, though.
- */
- *curdev_ret = NULL;
- return (0);
- }
- pcap_close(p);
-
- /*
- * Yes, we can open it.
- * Allocate a new entry.
- */
- curdev = malloc(sizeof(pcap_if_t));
- if (curdev == NULL) {
- (void)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)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "malloc: %s", pcap_strerror(errno));
- free(curdev);
- return (-1);
- }
- if (description != NULL) {
- /*
- * We have a description for this interface.
- */
- curdev->description = strdup(description);
- if (curdev->description == NULL) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "malloc: %s", pcap_strerror(errno));
- free(curdev->name);
- free(curdev);
- return (-1);
- }
- } else {
- /*
- * We don't.
- */
- curdev->description = NULL;
- }
- curdev->addresses = NULL; /* list starts out as empty */
- curdev->flags = 0;
- if (ISLOOPBACK(name, flags))
- curdev->flags |= PCAP_IF_LOOPBACK;
-
- /*
- * Add it to the list, in the appropriate location.
- * First, get the instance number of this interface.
- */
- this_instance = get_instance(name);
-
- /*
- * Now look for the last interface with an instance number
- * less than or equal to the new interface's instance
- * number - except that non-loopback interfaces are
- * arbitrarily treated as having interface numbers less
- * than those of loopback interfaces, so the loopback
- * interfaces are put at the end of the list.
- *
- * 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 a non-loopback interface
- * and the next interface a loopback interface?
- */
- if (!(curdev->flags & PCAP_IF_LOOPBACK) &&
- (nextdev->flags & PCAP_IF_LOOPBACK)) {
- /*
- * Yes, we should put the new entry
- * before "nextdev", i.e. after "prevdev".
- */
- break;
- }
-
- /*
- * Is the new interface's instance number less
- * than the next interface's instance number,
- * and is it the case that the new interface is a
- * non-loopback interface or the next interface is
- * a loopback interface?
- *
- * (The goal of both loopback tests is to make
- * sure that we never put a loopback interface
- * before any non-loopback interface and that we
- * always put a non-loopback interface before all
- * loopback interfaces.)
- */
- if (this_instance < get_instance(nextdev->name) &&
- (!(curdev->flags & PCAP_IF_LOOPBACK) ||
- (nextdev->flags & PCAP_IF_LOOPBACK))) {
- /*
- * 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);
-}
-
-/*
- * 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?
- */
-int
-add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int 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;
- char *description = NULL;
- pcap_addr_t *curaddr, *prevaddr, *nextaddr;
-#ifdef SIOCGIFDESCR
- int s;
- struct ifreq ifrdesc;
-#ifndef IFDESCRSIZE
- size_t descrlen = 64;
-#else
- size_t descrlen = IFDESCRSIZE;
-#endif /* IFDESCRSIZE */
-#endif /* SIOCGIFDESCR */
-
-#ifdef SIOCGIFDESCR
- /*
- * 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) {
- free(description);
- description = NULL;
- }
- }
-#endif /* SIOCGIFDESCR */
-
- if (add_or_find_if(&curdev, alldevs, name, flags, description,
- errbuf) == -1) {
- free(description);
- /*
- * Error - give up.
- */
- return (-1);
- }
- free(description);
- if (curdev == NULL) {
- /*
- * Device wasn't added because it can't be opened.
- * Not a fatal error.
- */
- return (0);
- }
-
- /*
- * "curdev" is an entry for this interface; add an entry for this
- * address to its list of addresses.
- *
- * Allocate the new entry and fill it in.
- */
- curaddr = malloc(sizeof(pcap_addr_t));
- if (curaddr == NULL) {
- (void)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)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)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)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)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);
-}
-
-int
-pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags,
- 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);
- }
-}
-
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
/*
* Return the name of a network interface attached to the system, or NULL
@@ -739,6 +150,10 @@ pcap_lookupnet(device, netp, maskp, errbuf)
#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
@@ -749,7 +164,7 @@ pcap_lookupnet(device, netp, maskp, errbuf)
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
pcap_strerror(errno));
return (-1);
}
@@ -758,13 +173,13 @@ pcap_lookupnet(device, netp, maskp, errbuf)
/* XXX Work around Linux kernel bug */
ifr.ifr_addr.sa_family = AF_INET;
#endif
- (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+ (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
if (errno == EADDRNOTAVAIL) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"%s: no IPv4 address assigned", device);
} else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFADDR: %s: %s",
device, pcap_strerror(errno));
}
@@ -778,9 +193,9 @@ pcap_lookupnet(device, netp, maskp, errbuf)
/* XXX Work around Linux kernel bug */
ifr.ifr_addr.sa_family = AF_INET;
#endif
- (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+ (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));
(void)close(fd);
return (-1);
@@ -795,7 +210,7 @@ pcap_lookupnet(device, netp, maskp, errbuf)
else if (IN_CLASSC(*netp))
*maskp = IN_CLASSC_NET;
else {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"inet class for 0x%x unknown", *netp);
return (-1);
}
@@ -804,92 +219,151 @@ pcap_lookupnet(device, netp, maskp, errbuf)
return (0);
}
-#elif defined(WIN32)
+#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 = 8192;
- static char AdaptersName[8192];
-
+ ULONG NameLength = ADAPTERSNAME_LEN;
+ static char AdaptersName[ADAPTERSNAME_LEN];
+
if (PacketGetAdapterNames(AdaptersName,&NameLength) )
return (AdaptersName);
else
return NULL;
} else {
/*
- * Windows NT (NT 4.0, W2K, WXP). Convert the names to UNICODE for backward compatibility
+ * Windows NT (NT 4.0 and later).
+ * Convert the names to Unicode for backward compatibility.
*/
- ULONG NameLength = 8192;
- static WCHAR AdaptersName[8192];
+ ULONG NameLength = ADAPTERSNAME_LEN;
+ static WCHAR AdaptersName[ADAPTERSNAME_LEN];
+ size_t BufferSpaceLeft;
char *tAstr;
- WCHAR *tUstr;
- WCHAR *TAdaptersName = (WCHAR*)malloc(8192 * sizeof(WCHAR));
+ WCHAR *Unameptr;
+ char *Adescptr;
+ size_t namelen, i;
+ WCHAR *TAdaptersName = (WCHAR*)malloc(ADAPTERSNAME_LEN * sizeof(WCHAR));
int NAdapts = 0;
if(TAdaptersName == NULL)
{
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "memory allocation failure");
+ (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "memory allocation failure");
return NULL;
}
if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) )
{
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "PacketGetAdapterNames: %s",
- pcap_win32strerror());
+ 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;
- tUstr = (WCHAR*)AdaptersName;
+ Unameptr = AdaptersName;
/*
- * Convert and copy the device names
+ * Convert the device names to Unicode into AdapterName.
*/
- while(sscanf(tAstr, "%S", tUstr) > 0)
- {
- tAstr += strlen(tAstr) + 1;
- tUstr += wcslen(tUstr) + 1;
- NAdapts ++;
- }
+ 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);
- tAstr++;
- *tUstr = 0;
- tUstr++;
+ /*
+ * 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
+ * Copy the descriptions, but don't convert them from
+ * ASCII to Unicode.
*/
+ Adescptr = (char *)Unameptr;
while(NAdapts--)
{
- char* tmp = (char*)tUstr;
- strcpy(tmp, tAstr);
- tmp += strlen(tAstr) + 1;
- tUstr = (WCHAR*)tmp;
- tAstr += strlen(tAstr) + 1;
+ 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);
- }
+ }
}
@@ -899,7 +373,7 @@ pcap_lookupnet(device, netp, maskp, errbuf)
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)
*/
@@ -925,11 +399,11 @@ pcap_lookupnet(device, netp, maskp, errbuf)
*netp &= *maskp;
return (0);
}
-
+
}
*netp = *maskp = 0;
return (0);
}
-#endif /* !WIN32 && !MSDOS */
+#endif /* !_WIN32 && !MSDOS */
diff --git a/freebsd/contrib/libpcap/llc.h b/freebsd/contrib/libpcap/llc.h
index b8c221fa..b0cf881c 100644
--- a/freebsd/contrib/libpcap/llc.h
+++ b/freebsd/contrib/libpcap/llc.h
@@ -17,11 +17,40 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/llc.h,v 1.2 2001-01-28 09:44:50 guy Exp $ (LBL)
*/
/*
+ * Definitions for information in the LLC header.
+ */
+
+#define LLC_U_FMT 3
+#define LLC_GSAP 1
+#define LLC_IG 1 /* Individual / Group */
+#define LLC_S_FMT 1
+
+#define LLC_U_POLL 0x10
+#define LLC_IS_POLL 0x0100
+#define LLC_XID_FI 0x81
+
+#define LLC_U_CMD_MASK 0xef
+#define LLC_UI 0x03
+#define LLC_UA 0x63
+#define LLC_DISC 0x43
+#define LLC_DM 0x0f
+#define LLC_SABME 0x6f
+#define LLC_TEST 0xe3
+#define LLC_XID 0xaf
+#define LLC_FRMR 0x87
+
+#define LLC_S_CMD_MASK 0x0f
+#define LLC_RR 0x0001
+#define LLC_RNR 0x0005
+#define LLC_REJ 0x0009
+
+#define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
+#define LLC_I_NS(is) (((is) >> 1) & 0x7f)
+
+/*
* 802.2 LLC SAP values.
*/
@@ -31,10 +60,10 @@
#ifndef LLCSAP_GLOBAL
#define LLCSAP_GLOBAL 0xff
#endif
-#ifndef LLCSAP_8021B
+#ifndef LLCSAP_8021B_I
#define LLCSAP_8021B_I 0x02
#endif
-#ifndef LLCSAP_8021B
+#ifndef LLCSAP_8021B_G
#define LLCSAP_8021B_G 0x03
#endif
#ifndef LLCSAP_IP
diff --git a/freebsd/contrib/libpcap/nametoaddr.c b/freebsd/contrib/libpcap/nametoaddr.c
index b0940374..7ef8f4cc 100644
--- a/freebsd/contrib/libpcap/nametoaddr.c
+++ b/freebsd/contrib/libpcap/nametoaddr.c
@@ -26,11 +26,6 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.83 2008-02-06 10:21:30 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -40,10 +35,36 @@ static const char rcsid[] _U_ =
#include <netdnet/dnetdb.h>
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#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
+
+#else /* _WIN32 */
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */
@@ -51,9 +72,9 @@ static const char rcsid[] _U_ =
#include <sys/time.h>
#include <netinet/in.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
-#ifndef WIN32
+#ifndef _WIN32
#ifdef HAVE_ETHER_HOSTTON
/*
* XXX - do we need any of this if <netinet/if_ether.h> doesn't declare
@@ -71,7 +92,7 @@ struct rtentry; /* declarations in <net/if.h> */
#endif /* HAVE_ETHER_HOSTTON */
#include <arpa/inet.h>
#include <netdb.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <ctype.h>
#include <errno.h>
@@ -83,6 +104,7 @@ struct rtentry; /* declarations in <net/if.h> */
#include "gencode.h"
#include <pcap/namedb.h>
+#include "nametoaddr.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
@@ -149,7 +171,7 @@ pcap_nametoaddrinfo(const char *name)
bpf_u_int32
pcap_nametonetaddr(const char *name)
{
-#ifndef WIN32
+#ifndef _WIN32
struct netent *np;
if ((np = getnetbyname(name)) != NULL)
@@ -159,6 +181,15 @@ pcap_nametonetaddr(const char *name)
#else
/*
* There's no "getnetbyname()" on Windows.
+ *
+ * XXX - I guess we could use the BSD code to read
+ * C:\Windows\System32\drivers\etc/networks, assuming
+ * that's its home on all the versions of Windows
+ * we use, but that file probably just has the loopback
+ * network on 127/24 on 99 44/100% of Windows machines.
+ *
+ * (Heck, these days it probably just has that on 99 44/100%
+ * of *UN*X* machines.)
*/
return 0;
#endif
@@ -283,8 +314,14 @@ struct eproto {
u_short p;
};
-/* Static data base of ether protocol types. */
-struct eproto eproto_db[] = {
+/*
+ * Static data base of ether protocol types.
+ * tcpdump used to import this, and it's declared as an export on
+ * 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.)
+ */
+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
@@ -401,7 +438,7 @@ __pcap_atodn(const char *s, bpf_u_int32 *addr)
u_int node, area;
if (sscanf(s, "%d.%d", &area, &node) != 2)
- bpf_error("malformed decnet address '%s'", s);
+ return(0);
*addr = (area << AREASHIFT) & AREAMASK;
*addr |= (node & NODEMASK);
@@ -428,6 +465,8 @@ pcap_ether_aton(const char *s)
register u_int d;
e = ep = (u_char *)malloc(6);
+ if (e == NULL)
+ return (NULL);
while (*s) {
if (*s == ':' || *s == '.' || *s == '-')
@@ -503,23 +542,20 @@ pcap_ether_hostton(const char *name)
}
#endif
-u_short
-__pcap_nametodnaddr(const char *name)
+int
+__pcap_nametodnaddr(const char *name, u_short *res)
{
#ifdef DECNETLIB
struct nodeent *getnodebyname();
struct nodeent *nep;
- unsigned short res;
nep = getnodebyname(name);
if (nep == ((struct nodeent *)0))
- bpf_error("unknown decnet host name '%s'\n", name);
+ return(0);
- memcpy((char *)&res, (char *)nep->n_addr, sizeof(unsigned short));
- return(res);
+ memcpy((char *)res, (char *)nep->n_addr, sizeof(unsigned short));
+ return(1);
#else
- bpf_error("decnet name support not included, '%s' cannot be translated\n",
- name);
return(0);
#endif
}
diff --git a/freebsd/contrib/libpcap/nametoaddr.h b/freebsd/contrib/libpcap/nametoaddr.h
new file mode 100644
index 00000000..fd6b7e10
--- /dev/null
+++ b/freebsd/contrib/libpcap/nametoaddr.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1994, 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Routines used for name-or-address-string-to-address resolution
+ * that are *not* exported to code using libpcap.
+ */
+int __pcap_atodn(const char *, bpf_u_int32 *);
+int __pcap_atoin(const char *, bpf_u_int32 *);
+int __pcap_nametodnaddr(const char *, u_short *);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/freebsd/contrib/libpcap/nlpid.h b/freebsd/contrib/libpcap/nlpid.h
index 5327a362..9dfa752b 100644
--- a/freebsd/contrib/libpcap/nlpid.h
+++ b/freebsd/contrib/libpcap/nlpid.h
@@ -14,8 +14,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/nlpid.h,v 1.2 2002-12-06 00:01:34 hannes Exp $ (Juniper)
*/
/* Types missing from some systems */
diff --git a/freebsd/contrib/libpcap/optimize.c b/freebsd/contrib/libpcap/optimize.c
index b2ffc527..b861082d 100644
--- a/freebsd/contrib/libpcap/optimize.c
+++ b/freebsd/contrib/libpcap/optimize.c
@@ -22,18 +22,14 @@
*
* Optimization module for tcpdump intermediate representation.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.91 2008-01-02 04:16:46 guy Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -43,7 +39,7 @@ static const char rcsid[] _U_ =
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdio.h>
#include <stdlib.h>
@@ -61,7 +57,7 @@ static const char rcsid[] _U_ =
#endif
#ifdef BDEBUG
-extern int dflag;
+int pcap_optimizer_debug;
#endif
#if defined(MSDOS) && !defined(__DJGPP__)
@@ -69,8 +65,26 @@ extern int _w32_ffs (int mask);
#define ffs _w32_ffs
#endif
-#if defined(WIN32) && defined (_MSC_VER)
-int ffs(int mask);
+/*
+ * So is the check for _MSC_VER done because MinGW has this?
+ */
+#if defined(_WIN32) && defined (_MSC_VER)
+/*
+ * ffs -- vax ffs instruction
+ *
+ * XXX - with versions of VS that have it, use _BitScanForward()?
+ */
+static int
+ffs(int mask)
+{
+ int bit;
+
+ if (mask == 0)
+ return(0);
+ for (bit = 1; !(mask & 1); bit++)
+ mask >>= 1;
+ return(bit);
+}
#endif
/*
@@ -95,45 +109,48 @@ int ffs(int mask);
#define AX_ATOM N_ATOMS
/*
- * A flag to indicate that further optimization is needed.
- * Iterative passes are continued until a given pass yields no
- * branch movement.
+ * These data structures are used in a Cocke and Shwarz style
+ * value numbering scheme. Since the flowgraph is acyclic,
+ * exit values can be propagated from a node's predecessors
+ * provided it is uniquely defined.
*/
-static int done;
+struct valnode {
+ int code;
+ int v0, v1;
+ int val;
+ struct valnode *next;
+};
-/*
- * A block is marked if only if its mark equals the current mark.
- * Rather than traverse the code array, marking each item, 'cur_mark' is
- * incremented. This automatically makes each element unmarked.
- */
-static int cur_mark;
-#define isMarked(p) ((p)->mark == cur_mark)
-#define unMarkAll() cur_mark += 1
-#define Mark(p) ((p)->mark = cur_mark)
+/* Integer constants mapped with the load immediate opcode. */
+#define K(i) F(opt_state, BPF_LD|BPF_IMM|BPF_W, i, 0L)
-static void opt_init(struct block *);
-static void opt_cleanup(void);
+struct vmapinfo {
+ int is_const;
+ bpf_int32 const_val;
+};
-static void intern_blocks(struct block *);
+struct _opt_state {
+ /*
+ * A flag to indicate that further optimization is needed.
+ * Iterative passes are continued until a given pass yields no
+ * branch movement.
+ */
+ int done;
-static void find_inedges(struct block *);
-#ifdef BDEBUG
-static void opt_dump(struct block *);
-#endif
+ int n_blocks;
+ struct block **blocks;
+ int n_edges;
+ struct edge **edges;
-static int n_blocks;
-struct block **blocks;
-static int n_edges;
-struct edge **edges;
+ /*
+ * A bit vector set representation of the dominators.
+ * We round up the set size to the next power of two.
+ */
+ int nodewords;
+ int edgewords;
+ struct block **levels;
+ bpf_u_int32 *space;
-/*
- * A bit vector set representation of the dominators.
- * We round up the set size to the next power of two.
- */
-static int nodewords;
-static int edgewords;
-struct block **levels;
-bpf_u_int32 *space;
#define BITS_PER_WORD (8*sizeof(bpf_u_int32))
/*
* True if a is in uset {p}
@@ -183,48 +200,79 @@ bpf_u_int32 *space;
while (--_n >= 0) *_x++ |= *_y++;\
}
-static uset all_dom_sets;
-static uset all_closure_sets;
-static uset all_edge_sets;
+ uset all_dom_sets;
+ uset all_closure_sets;
+ uset all_edge_sets;
+
+#define MODULUS 213
+ struct valnode *hashtbl[MODULUS];
+ int curval;
+ int maxval;
+
+ struct vmapinfo *vmap;
+ struct valnode *vnode_base;
+ struct valnode *next_vnode;
+};
+
+typedef struct {
+ /*
+ * Some pointers used to convert the basic block form of the code,
+ * into the array form that BPF requires. 'fstart' will point to
+ * the malloc'd array while 'ftail' is used during the recursive
+ * traversal.
+ */
+ struct bpf_insn *fstart;
+ struct bpf_insn *ftail;
+} conv_state_t;
+
+static void opt_init(compiler_state_t *, opt_state_t *, struct icode *);
+static void opt_cleanup(opt_state_t *);
+
+static void intern_blocks(opt_state_t *, struct icode *);
+
+static void find_inedges(opt_state_t *, struct block *);
+#ifdef BDEBUG
+static void opt_dump(compiler_state_t *, struct icode *);
+#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
static void
-find_levels_r(struct block *b)
+find_levels_r(opt_state_t *opt_state, struct icode *ic, struct block *b)
{
int level;
- if (isMarked(b))
+ if (isMarked(ic, b))
return;
- Mark(b);
+ Mark(ic, b);
b->link = 0;
if (JT(b)) {
- find_levels_r(JT(b));
- find_levels_r(JF(b));
+ find_levels_r(opt_state, ic, JT(b));
+ find_levels_r(opt_state, ic, JF(b));
level = MAX(JT(b)->level, JF(b)->level) + 1;
} else
level = 0;
b->level = level;
- b->link = levels[level];
- levels[level] = b;
+ b->link = opt_state->levels[level];
+ opt_state->levels[level] = b;
}
/*
* Level graph. The levels go from 0 at the leaves to
- * N_LEVELS at the root. The levels[] array points to the
+ * N_LEVELS at the root. The opt_state->levels[] array points to the
* first node of the level list, whose elements are linked
* with the 'link' field of the struct block.
*/
static void
-find_levels(struct block *root)
+find_levels(opt_state_t *opt_state, struct icode *ic)
{
- memset((char *)levels, 0, n_blocks * sizeof(*levels));
- unMarkAll();
- find_levels_r(root);
+ memset((char *)opt_state->levels, 0, opt_state->n_blocks * sizeof(*opt_state->levels));
+ unMarkAll(ic);
+ find_levels_r(opt_state, ic, ic->root);
}
/*
@@ -232,7 +280,7 @@ find_levels(struct block *root)
* Assumes graph has been leveled.
*/
static void
-find_dom(struct block *root)
+find_dom(opt_state_t *opt_state, struct block *root)
{
int i;
struct block *b;
@@ -241,33 +289,33 @@ find_dom(struct block *root)
/*
* Initialize sets to contain all nodes.
*/
- x = all_dom_sets;
- i = n_blocks * nodewords;
+ x = opt_state->all_dom_sets;
+ i = opt_state->n_blocks * opt_state->nodewords;
while (--i >= 0)
*x++ = ~0;
/* Root starts off empty. */
- for (i = nodewords; --i >= 0;)
+ for (i = opt_state->nodewords; --i >= 0;)
root->dom[i] = 0;
/* root->level is the highest level no found. */
for (i = root->level; i >= 0; --i) {
- for (b = levels[i]; b; b = b->link) {
+ for (b = opt_state->levels[i]; b; b = b->link) {
SET_INSERT(b->dom, b->id);
if (JT(b) == 0)
continue;
- SET_INTERSECT(JT(b)->dom, b->dom, nodewords);
- SET_INTERSECT(JF(b)->dom, b->dom, nodewords);
+ SET_INTERSECT(JT(b)->dom, b->dom, opt_state->nodewords);
+ SET_INTERSECT(JF(b)->dom, b->dom, opt_state->nodewords);
}
}
}
static void
-propedom(struct edge *ep)
+propedom(opt_state_t *opt_state, struct edge *ep)
{
SET_INSERT(ep->edom, ep->id);
if (ep->succ) {
- SET_INTERSECT(ep->succ->et.edom, ep->edom, edgewords);
- SET_INTERSECT(ep->succ->ef.edom, ep->edom, edgewords);
+ SET_INTERSECT(ep->succ->et.edom, ep->edom, opt_state->edgewords);
+ SET_INTERSECT(ep->succ->ef.edom, ep->edom, opt_state->edgewords);
}
}
@@ -276,23 +324,23 @@ propedom(struct edge *ep)
* Assumes graph has been leveled and predecessors established.
*/
static void
-find_edom(struct block *root)
+find_edom(opt_state_t *opt_state, struct block *root)
{
int i;
uset x;
struct block *b;
- x = all_edge_sets;
- for (i = n_edges * edgewords; --i >= 0; )
+ x = opt_state->all_edge_sets;
+ for (i = opt_state->n_edges * opt_state->edgewords; --i >= 0; )
x[i] = ~0;
/* root->level is the highest level no found. */
- memset(root->et.edom, 0, edgewords * sizeof(*(uset)0));
- memset(root->ef.edom, 0, edgewords * sizeof(*(uset)0));
+ memset(root->et.edom, 0, opt_state->edgewords * sizeof(*(uset)0));
+ memset(root->ef.edom, 0, opt_state->edgewords * sizeof(*(uset)0));
for (i = root->level; i >= 0; --i) {
- for (b = levels[i]; b != 0; b = b->link) {
- propedom(&b->et);
- propedom(&b->ef);
+ for (b = opt_state->levels[i]; b != 0; b = b->link) {
+ propedom(opt_state, &b->et);
+ propedom(opt_state, &b->ef);
}
}
}
@@ -305,7 +353,7 @@ find_edom(struct block *root)
* Assumes graph has been leveled.
*/
static void
-find_closure(struct block *root)
+find_closure(opt_state_t *opt_state, struct block *root)
{
int i;
struct block *b;
@@ -313,17 +361,17 @@ find_closure(struct block *root)
/*
* Initialize sets to contain no nodes.
*/
- memset((char *)all_closure_sets, 0,
- n_blocks * nodewords * sizeof(*all_closure_sets));
+ memset((char *)opt_state->all_closure_sets, 0,
+ opt_state->n_blocks * opt_state->nodewords * sizeof(*opt_state->all_closure_sets));
/* root->level is the highest level no found. */
for (i = root->level; i >= 0; --i) {
- for (b = levels[i]; b; b = b->link) {
+ for (b = opt_state->levels[i]; b; b = b->link) {
SET_INSERT(b->closure, b->id);
if (JT(b) == 0)
continue;
- SET_UNION(JT(b)->closure, b->closure, nodewords);
- SET_UNION(JF(b)->closure, b->closure, nodewords);
+ SET_UNION(JT(b)->closure, b->closure, opt_state->nodewords);
+ SET_UNION(JF(b)->closure, b->closure, opt_state->nodewords);
}
}
}
@@ -419,7 +467,7 @@ static void
compute_local_ud(struct block *b)
{
struct slist *s;
- atomset def = 0, use = 0, kill = 0;
+ atomset def = 0, use = 0, killed = 0;
int atom;
for (s = b->stmts; s; s = s->next) {
@@ -443,7 +491,7 @@ compute_local_ud(struct block *b)
atom = atomdef(&s->s);
if (atom >= 0) {
if (!ATOMELEM(use, atom))
- kill |= ATOMMASK(atom);
+ killed |= ATOMMASK(atom);
def |= ATOMMASK(atom);
}
}
@@ -469,7 +517,7 @@ compute_local_ud(struct block *b)
}
b->def = def;
- b->kill = kill;
+ b->kill = killed;
b->in_use = use;
}
@@ -477,7 +525,7 @@ compute_local_ud(struct block *b)
* Assume graph is already leveled.
*/
static void
-find_ud(struct block *root)
+find_ud(opt_state_t *opt_state, struct block *root)
{
int i, maxlevel;
struct block *p;
@@ -488,61 +536,30 @@ find_ud(struct block *root)
*/
maxlevel = root->level;
for (i = maxlevel; i >= 0; --i)
- for (p = levels[i]; p; p = p->link) {
+ for (p = opt_state->levels[i]; p; p = p->link) {
compute_local_ud(p);
p->out_use = 0;
}
for (i = 1; i <= maxlevel; ++i) {
- for (p = levels[i]; p; p = p->link) {
+ for (p = opt_state->levels[i]; p; p = p->link) {
p->out_use |= JT(p)->in_use | JF(p)->in_use;
p->in_use |= p->out_use &~ p->kill;
}
}
}
-
-/*
- * These data structures are used in a Cocke and Shwarz style
- * value numbering scheme. Since the flowgraph is acyclic,
- * exit values can be propagated from a node's predecessors
- * provided it is uniquely defined.
- */
-struct valnode {
- int code;
- int v0, v1;
- int val;
- struct valnode *next;
-};
-
-#define MODULUS 213
-static struct valnode *hashtbl[MODULUS];
-static int curval;
-static int maxval;
-
-/* Integer constants mapped with the load immediate opcode. */
-#define K(i) F(BPF_LD|BPF_IMM|BPF_W, i, 0L)
-
-struct vmapinfo {
- int is_const;
- bpf_int32 const_val;
-};
-
-struct vmapinfo *vmap;
-struct valnode *vnode_base;
-struct valnode *next_vnode;
-
static void
-init_val(void)
+init_val(opt_state_t *opt_state)
{
- curval = 0;
- next_vnode = vnode_base;
- memset((char *)vmap, 0, maxval * sizeof(*vmap));
- memset((char *)hashtbl, 0, sizeof hashtbl);
+ opt_state->curval = 0;
+ opt_state->next_vnode = opt_state->vnode_base;
+ memset((char *)opt_state->vmap, 0, opt_state->maxval * sizeof(*opt_state->vmap));
+ memset((char *)opt_state->hashtbl, 0, sizeof opt_state->hashtbl);
}
/* Because we really don't have an IR, this stuff is a little messy. */
static int
-F(int code, int v0, int v1)
+F(opt_state_t *opt_state, int code, int v0, int v1)
{
u_int hash;
int val;
@@ -551,23 +568,23 @@ F(int code, int v0, int v1)
hash = (u_int)code ^ (v0 << 4) ^ (v1 << 8);
hash %= MODULUS;
- for (p = hashtbl[hash]; p; p = p->next)
+ for (p = opt_state->hashtbl[hash]; p; p = p->next)
if (p->code == code && p->v0 == v0 && p->v1 == v1)
return p->val;
- val = ++curval;
+ val = ++opt_state->curval;
if (BPF_MODE(code) == BPF_IMM &&
(BPF_CLASS(code) == BPF_LD || BPF_CLASS(code) == BPF_LDX)) {
- vmap[val].const_val = v0;
- vmap[val].is_const = 1;
+ opt_state->vmap[val].const_val = v0;
+ opt_state->vmap[val].is_const = 1;
}
- p = next_vnode++;
+ p = opt_state->next_vnode++;
p->val = val;
p->code = code;
p->v0 = v0;
p->v1 = v1;
- p->next = hashtbl[hash];
- hashtbl[hash] = p;
+ p->next = opt_state->hashtbl[hash];
+ opt_state->hashtbl[hash] = p;
return val;
}
@@ -581,13 +598,18 @@ vstore(struct stmt *s, int *valp, int newval, int alter)
*valp = newval;
}
+/*
+ * Do constant-folding on binary operators.
+ * (Unary operators are handled elsewhere.)
+ */
static void
-fold_op(struct stmt *s, int v0, int v1)
+fold_op(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state,
+ struct stmt *s, int v0, int v1)
{
bpf_u_int32 a, b;
- a = vmap[v0].const_val;
- b = vmap[v1].const_val;
+ a = opt_state->vmap[v0].const_val;
+ b = opt_state->vmap[v1].const_val;
switch (BPF_OP(s->code)) {
case BPF_ADD:
@@ -604,10 +626,16 @@ fold_op(struct stmt *s, int v0, int v1)
case BPF_DIV:
if (b == 0)
- bpf_error("division by zero");
+ bpf_error(cstate, "division by zero");
a /= b;
break;
+ case BPF_MOD:
+ if (b == 0)
+ bpf_error(cstate, "modulus by zero");
+ a %= b;
+ break;
+
case BPF_AND:
a &= b;
break;
@@ -616,6 +644,10 @@ fold_op(struct stmt *s, int v0, int v1)
a |= b;
break;
+ case BPF_XOR:
+ a ^= b;
+ break;
+
case BPF_LSH:
a <<= b;
break;
@@ -624,16 +656,12 @@ fold_op(struct stmt *s, int v0, int v1)
a >>= b;
break;
- case BPF_NEG:
- a = -a;
- break;
-
default:
abort();
}
s->k = a;
s->code = BPF_LD|BPF_IMM;
- done = 0;
+ opt_state->done = 0;
}
static inline struct slist *
@@ -654,7 +682,7 @@ opt_not(struct block *b)
}
static void
-opt_peep(struct block *b)
+opt_peep(opt_state_t *opt_state, struct block *b)
{
struct slist *s;
struct slist *next, *last;
@@ -689,7 +717,7 @@ opt_peep(struct block *b)
if (s->s.code == BPF_ST &&
next->s.code == (BPF_LDX|BPF_MEM) &&
s->s.k == next->s.k) {
- done = 0;
+ opt_state->done = 0;
next->s.code = BPF_MISC|BPF_TAX;
}
/*
@@ -700,7 +728,7 @@ opt_peep(struct block *b)
next->s.code == (BPF_MISC|BPF_TAX)) {
s->s.code = BPF_LDX|BPF_IMM;
next->s.code = BPF_MISC|BPF_TXA;
- done = 0;
+ opt_state->done = 0;
}
/*
* This is an ugly special case, but it happens
@@ -779,7 +807,7 @@ opt_peep(struct block *b)
s->s.code = NOP;
add->s.code = NOP;
tax->s.code = NOP;
- done = 0;
+ opt_state->done = 0;
}
}
/*
@@ -797,7 +825,7 @@ opt_peep(struct block *b)
*/
if (last->s.code == (BPF_ALU|BPF_SUB|BPF_X)) {
val = b->val[X_ATOM];
- if (vmap[val].is_const) {
+ if (opt_state->vmap[val].is_const) {
/*
* If we have a subtract to do a comparison,
* and the X register is a known constant,
@@ -807,9 +835,9 @@ opt_peep(struct block *b)
* sub x -> nop
* jeq #y jeq #(x+y)
*/
- b->s.k += vmap[val].const_val;
+ b->s.k += opt_state->vmap[val].const_val;
last->s.code = NOP;
- done = 0;
+ opt_state->done = 0;
} else if (b->s.k == 0) {
/*
* If the X register isn't a constant,
@@ -822,7 +850,7 @@ opt_peep(struct block *b)
*/
last->s.code = NOP;
b->s.code = BPF_JMP|BPF_JEQ|BPF_X;
- done = 0;
+ opt_state->done = 0;
}
}
/*
@@ -834,7 +862,7 @@ opt_peep(struct block *b)
else if (last->s.code == (BPF_ALU|BPF_SUB|BPF_K)) {
last->s.code = NOP;
b->s.k += last->s.k;
- done = 0;
+ opt_state->done = 0;
}
/*
* And, similarly, a constant AND can be simplified
@@ -848,7 +876,7 @@ opt_peep(struct block *b)
b->s.k = last->s.k;
b->s.code = BPF_JMP|BPF_K|BPF_JSET;
last->s.code = NOP;
- done = 0;
+ opt_state->done = 0;
opt_not(b);
}
}
@@ -859,7 +887,7 @@ opt_peep(struct block *b)
if (b->s.code == (BPF_JMP|BPF_K|BPF_JSET)) {
if (b->s.k == 0)
JT(b) = JF(b);
- if (b->s.k == 0xffffffff)
+ if ((u_int)b->s.k == 0xffffffffU)
JF(b) = JT(b);
}
/*
@@ -868,8 +896,8 @@ opt_peep(struct block *b)
* constant.
*/
val = b->val[X_ATOM];
- if (vmap[val].is_const && BPF_SRC(b->s.code) == BPF_X) {
- bpf_int32 v = vmap[val].const_val;
+ if (opt_state->vmap[val].is_const && BPF_SRC(b->s.code) == BPF_X) {
+ bpf_int32 v = opt_state->vmap[val].const_val;
b->s.code &= ~BPF_X;
b->s.k = v;
}
@@ -878,8 +906,8 @@ opt_peep(struct block *b)
* comparison result.
*/
val = b->val[A_ATOM];
- if (vmap[val].is_const && BPF_SRC(b->s.code) == BPF_K) {
- bpf_int32 v = vmap[val].const_val;
+ if (opt_state->vmap[val].is_const && BPF_SRC(b->s.code) == BPF_K) {
+ bpf_int32 v = opt_state->vmap[val].const_val;
switch (BPF_OP(b->s.code)) {
case BPF_JEQ:
@@ -887,11 +915,11 @@ opt_peep(struct block *b)
break;
case BPF_JGT:
- v = (unsigned)v > b->s.k;
+ v = (unsigned)v > (unsigned)b->s.k;
break;
case BPF_JGE:
- v = (unsigned)v >= b->s.k;
+ v = (unsigned)v >= (unsigned)b->s.k;
break;
case BPF_JSET:
@@ -902,7 +930,7 @@ opt_peep(struct block *b)
abort();
}
if (JF(b) != JT(b))
- done = 0;
+ opt_state->done = 0;
if (v)
JF(b) = JT(b);
else
@@ -917,7 +945,8 @@ opt_peep(struct block *b)
* evaluation and code transformations weren't folded together.
*/
static void
-opt_stmt(struct stmt *s, int val[], int alter)
+opt_stmt(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state,
+ struct stmt *s, int val[], int alter)
{
int op;
int v;
@@ -927,7 +956,7 @@ opt_stmt(struct stmt *s, int val[], int alter)
case BPF_LD|BPF_ABS|BPF_W:
case BPF_LD|BPF_ABS|BPF_H:
case BPF_LD|BPF_ABS|BPF_B:
- v = F(s->code, s->k, 0L);
+ v = F(opt_state, s->code, s->k, 0L);
vstore(s, &val[A_ATOM], v, alter);
break;
@@ -935,19 +964,19 @@ opt_stmt(struct stmt *s, int val[], int alter)
case BPF_LD|BPF_IND|BPF_H:
case BPF_LD|BPF_IND|BPF_B:
v = val[X_ATOM];
- if (alter && vmap[v].is_const) {
+ if (alter && opt_state->vmap[v].is_const) {
s->code = BPF_LD|BPF_ABS|BPF_SIZE(s->code);
- s->k += vmap[v].const_val;
- v = F(s->code, s->k, 0L);
- done = 0;
+ s->k += opt_state->vmap[v].const_val;
+ v = F(opt_state, s->code, s->k, 0L);
+ opt_state->done = 0;
}
else
- v = F(s->code, s->k, v);
+ v = F(opt_state, s->code, s->k, v);
vstore(s, &val[A_ATOM], v, alter);
break;
case BPF_LD|BPF_LEN:
- v = F(s->code, 0L, 0L);
+ v = F(opt_state, s->code, 0L, 0L);
vstore(s, &val[A_ATOM], v, alter);
break;
@@ -962,26 +991,28 @@ opt_stmt(struct stmt *s, int val[], int alter)
break;
case BPF_LDX|BPF_MSH|BPF_B:
- v = F(s->code, s->k, 0L);
+ v = F(opt_state, s->code, s->k, 0L);
vstore(s, &val[X_ATOM], v, alter);
break;
case BPF_ALU|BPF_NEG:
- if (alter && vmap[val[A_ATOM]].is_const) {
+ if (alter && opt_state->vmap[val[A_ATOM]].is_const) {
s->code = BPF_LD|BPF_IMM;
- s->k = -vmap[val[A_ATOM]].const_val;
+ s->k = -opt_state->vmap[val[A_ATOM]].const_val;
val[A_ATOM] = K(s->k);
}
else
- val[A_ATOM] = F(s->code, val[A_ATOM], 0L);
+ val[A_ATOM] = F(opt_state, s->code, val[A_ATOM], 0L);
break;
case BPF_ALU|BPF_ADD|BPF_K:
case BPF_ALU|BPF_SUB|BPF_K:
case BPF_ALU|BPF_MUL|BPF_K:
case BPF_ALU|BPF_DIV|BPF_K:
+ case BPF_ALU|BPF_MOD|BPF_K:
case BPF_ALU|BPF_AND|BPF_K:
case BPF_ALU|BPF_OR|BPF_K:
+ case BPF_ALU|BPF_XOR|BPF_K:
case BPF_ALU|BPF_LSH|BPF_K:
case BPF_ALU|BPF_RSH|BPF_K:
op = BPF_OP(s->code);
@@ -992,7 +1023,7 @@ opt_stmt(struct stmt *s, int val[], int alter)
* fixup the generated math code */
if (op == BPF_ADD ||
op == BPF_LSH || op == BPF_RSH ||
- op == BPF_OR) {
+ op == BPF_OR || op == BPF_XOR) {
s->code = NOP;
break;
}
@@ -1002,35 +1033,37 @@ opt_stmt(struct stmt *s, int val[], int alter)
break;
}
}
- if (vmap[val[A_ATOM]].is_const) {
- fold_op(s, val[A_ATOM], K(s->k));
+ if (opt_state->vmap[val[A_ATOM]].is_const) {
+ fold_op(cstate, ic, opt_state, s, val[A_ATOM], K(s->k));
val[A_ATOM] = K(s->k);
break;
}
}
- val[A_ATOM] = F(s->code, val[A_ATOM], K(s->k));
+ val[A_ATOM] = F(opt_state, s->code, val[A_ATOM], K(s->k));
break;
case BPF_ALU|BPF_ADD|BPF_X:
case BPF_ALU|BPF_SUB|BPF_X:
case BPF_ALU|BPF_MUL|BPF_X:
case BPF_ALU|BPF_DIV|BPF_X:
+ case BPF_ALU|BPF_MOD|BPF_X:
case BPF_ALU|BPF_AND|BPF_X:
case BPF_ALU|BPF_OR|BPF_X:
+ case BPF_ALU|BPF_XOR|BPF_X:
case BPF_ALU|BPF_LSH|BPF_X:
case BPF_ALU|BPF_RSH|BPF_X:
op = BPF_OP(s->code);
- if (alter && vmap[val[X_ATOM]].is_const) {
- if (vmap[val[A_ATOM]].is_const) {
- fold_op(s, val[A_ATOM], val[X_ATOM]);
+ 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]);
val[A_ATOM] = K(s->k);
}
else {
s->code = BPF_ALU|BPF_K|op;
- s->k = vmap[val[X_ATOM]].const_val;
- done = 0;
+ s->k = opt_state->vmap[val[X_ATOM]].const_val;
+ opt_state->done = 0;
val[A_ATOM] =
- F(s->code, val[A_ATOM], K(s->k));
+ F(opt_state, s->code, val[A_ATOM], K(s->k));
}
break;
}
@@ -1041,14 +1074,14 @@ opt_stmt(struct stmt *s, int val[], int alter)
* optimizations.
* XXX We could also check for mul by 1, etc.
*/
- if (alter && vmap[val[A_ATOM]].is_const
- && vmap[val[A_ATOM]].const_val == 0) {
- if (op == BPF_ADD || op == BPF_OR) {
+ if (alter && opt_state->vmap[val[A_ATOM]].is_const
+ && opt_state->vmap[val[A_ATOM]].const_val == 0) {
+ if (op == BPF_ADD || op == BPF_OR || op == BPF_XOR) {
s->code = BPF_MISC|BPF_TXA;
vstore(s, &val[A_ATOM], val[X_ATOM], alter);
break;
}
- else if (op == BPF_MUL || op == BPF_DIV ||
+ else if (op == BPF_MUL || op == BPF_DIV || op == BPF_MOD ||
op == BPF_AND || op == BPF_LSH || op == BPF_RSH) {
s->code = BPF_LD|BPF_IMM;
s->k = 0;
@@ -1060,7 +1093,7 @@ opt_stmt(struct stmt *s, int val[], int alter)
break;
}
}
- val[A_ATOM] = F(s->code, val[A_ATOM], val[X_ATOM]);
+ val[A_ATOM] = F(opt_state, s->code, val[A_ATOM], val[X_ATOM]);
break;
case BPF_MISC|BPF_TXA:
@@ -1069,10 +1102,10 @@ opt_stmt(struct stmt *s, int val[], int alter)
case BPF_LD|BPF_MEM:
v = val[s->k];
- if (alter && vmap[v].is_const) {
+ if (alter && opt_state->vmap[v].is_const) {
s->code = BPF_LD|BPF_IMM;
- s->k = vmap[v].const_val;
- done = 0;
+ s->k = opt_state->vmap[v].const_val;
+ opt_state->done = 0;
}
vstore(s, &val[A_ATOM], v, alter);
break;
@@ -1083,10 +1116,10 @@ opt_stmt(struct stmt *s, int val[], int alter)
case BPF_LDX|BPF_MEM:
v = val[s->k];
- if (alter && vmap[v].is_const) {
+ if (alter && opt_state->vmap[v].is_const) {
s->code = BPF_LDX|BPF_IMM;
- s->k = vmap[v].const_val;
- done = 0;
+ s->k = opt_state->vmap[v].const_val;
+ opt_state->done = 0;
}
vstore(s, &val[X_ATOM], v, alter);
break;
@@ -1102,7 +1135,7 @@ opt_stmt(struct stmt *s, int val[], int alter)
}
static void
-deadstmt(register struct stmt *s, register struct stmt *last[])
+deadstmt(opt_state_t *opt_state, register struct stmt *s, register struct stmt *last[])
{
register int atom;
@@ -1118,7 +1151,7 @@ deadstmt(register struct stmt *s, register struct stmt *last[])
atom = atomdef(s);
if (atom >= 0) {
if (last[atom]) {
- done = 0;
+ opt_state->done = 0;
last[atom]->code = NOP;
}
last[atom] = s;
@@ -1126,7 +1159,7 @@ deadstmt(register struct stmt *s, register struct stmt *last[])
}
static void
-opt_deadstores(register struct block *b)
+opt_deadstores(opt_state_t *opt_state, register struct block *b)
{
register struct slist *s;
register int atom;
@@ -1135,18 +1168,19 @@ opt_deadstores(register struct block *b)
memset((char *)last, 0, sizeof last);
for (s = b->stmts; s != 0; s = s->next)
- deadstmt(&s->s, last);
- deadstmt(&b->s, last);
+ deadstmt(opt_state, &s->s, last);
+ deadstmt(opt_state, &b->s, last);
for (atom = 0; atom < N_ATOMS; ++atom)
if (last[atom] && !ATOMELEM(b->out_use, atom)) {
last[atom]->code = NOP;
- done = 0;
+ opt_state->done = 0;
}
}
static void
-opt_blk(struct block *b, int do_stmts)
+opt_blk(compiler_state_t *cstate, struct icode *ic, opt_state_t *opt_state,
+ struct block *b, int do_stmts)
{
struct slist *s;
struct edge *p;
@@ -1196,7 +1230,7 @@ opt_blk(struct block *b, int do_stmts)
aval = b->val[A_ATOM];
xval = b->val[X_ATOM];
for (s = b->stmts; s; s = s->next)
- opt_stmt(&s->s, b->val, do_stmts);
+ opt_stmt(cstate, ic, opt_state, &s->s, b->val, do_stmts);
/*
* This is a special case: if we don't use anything from this
@@ -1227,11 +1261,11 @@ opt_blk(struct block *b, int do_stmts)
BPF_CLASS(b->s.code) == BPF_RET)) {
if (b->stmts != 0) {
b->stmts = 0;
- done = 0;
+ opt_state->done = 0;
}
} else {
- opt_peep(b);
- opt_deadstores(b);
+ opt_peep(opt_state, b);
+ opt_deadstores(opt_state, b);
}
/*
* Set up values for branch optimizer.
@@ -1318,7 +1352,7 @@ fold_edge(struct block *child, struct edge *ep)
}
static void
-opt_j(struct edge *ep)
+opt_j(opt_state_t *opt_state, struct edge *ep)
{
register int i, k;
register struct block *target;
@@ -1332,7 +1366,7 @@ opt_j(struct edge *ep)
* there is no data dependency.
*/
if (!use_conflict(ep->pred, ep->succ->et.succ)) {
- done = 0;
+ opt_state->done = 0;
ep->succ = JT(ep->succ);
}
}
@@ -1344,7 +1378,7 @@ opt_j(struct edge *ep)
* efficient loop.
*/
top:
- for (i = 0; i < edgewords; ++i) {
+ for (i = 0; i < opt_state->edgewords; ++i) {
register bpf_u_int32 x = ep->edom[i];
while (x != 0) {
@@ -1352,13 +1386,13 @@ opt_j(struct edge *ep)
x &=~ (1 << k);
k += i * BITS_PER_WORD;
- target = fold_edge(ep->succ, edges[k]);
+ target = fold_edge(ep->succ, opt_state->edges[k]);
/*
* Check that there is no data dependency between
* nodes that will be violated if we move the edge.
*/
if (target != 0 && !use_conflict(ep->pred, target)) {
- done = 0;
+ opt_state->done = 0;
ep->succ = target;
if (JT(target) != 0)
/*
@@ -1373,7 +1407,7 @@ opt_j(struct edge *ep)
static void
-or_pullup(struct block *b)
+or_pullup(opt_state_t *opt_state, struct block *b)
{
int val, at_top;
struct block *pull;
@@ -1461,11 +1495,11 @@ or_pullup(struct block *b)
else
*diffp = pull;
- done = 0;
+ opt_state->done = 0;
}
static void
-and_pullup(struct block *b)
+and_pullup(opt_state_t *opt_state, struct block *b)
{
int val, at_top;
struct block *pull;
@@ -1552,22 +1586,23 @@ and_pullup(struct block *b)
else
*diffp = pull;
- done = 0;
+ opt_state->done = 0;
}
static void
-opt_blks(struct block *root, int do_stmts)
+opt_blks(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic,
+ int do_stmts)
{
int i, maxlevel;
struct block *p;
- init_val();
- maxlevel = root->level;
+ init_val(opt_state);
+ maxlevel = ic->root->level;
- find_inedges(root);
+ find_inedges(opt_state, ic->root);
for (i = maxlevel; i >= 0; --i)
- for (p = levels[i]; p; p = p->link)
- opt_blk(p, do_stmts);
+ for (p = opt_state->levels[i]; p; p = p->link)
+ opt_blk(cstate, ic, opt_state, p, do_stmts);
if (do_stmts)
/*
@@ -1577,17 +1612,17 @@ opt_blks(struct block *root, int do_stmts)
return;
for (i = 1; i <= maxlevel; ++i) {
- for (p = levels[i]; p; p = p->link) {
- opt_j(&p->et);
- opt_j(&p->ef);
+ for (p = opt_state->levels[i]; p; p = p->link) {
+ opt_j(opt_state, &p->et);
+ opt_j(opt_state, &p->ef);
}
}
- find_inedges(root);
+ find_inedges(opt_state, ic->root);
for (i = 1; i <= maxlevel; ++i) {
- for (p = levels[i]; p; p = p->link) {
- or_pullup(p);
- and_pullup(p);
+ for (p = opt_state->levels[i]; p; p = p->link) {
+ or_pullup(opt_state, p);
+ and_pullup(opt_state, p);
}
}
}
@@ -1600,20 +1635,20 @@ link_inedge(struct edge *parent, struct block *child)
}
static void
-find_inedges(struct block *root)
+find_inedges(opt_state_t *opt_state, struct block *root)
{
int i;
struct block *b;
- for (i = 0; i < n_blocks; ++i)
- blocks[i]->in_edges = 0;
+ for (i = 0; i < opt_state->n_blocks; ++i)
+ opt_state->blocks[i]->in_edges = 0;
/*
* Traverse the graph, adding each edge to the predecessor
* list of its successors. Skip the leaves (i.e. level 0).
*/
for (i = root->level; i > 0; --i) {
- for (b = levels[i]; b != 0; b = b->link) {
+ for (b = opt_state->levels[i]; b != 0; b = b->link) {
link_inedge(&b->et, JT(b));
link_inedge(&b->ef, JF(b));
}
@@ -1645,83 +1680,82 @@ opt_root(struct block **b)
}
static void
-opt_loop(struct block *root, int do_stmts)
+opt_loop(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic,
+ int do_stmts)
{
#ifdef BDEBUG
- if (dflag > 1) {
+ if (pcap_optimizer_debug > 1) {
printf("opt_loop(root, %d) begin\n", do_stmts);
- opt_dump(root);
+ opt_dump(cstate, ic);
}
#endif
do {
- done = 1;
- find_levels(root);
- find_dom(root);
- find_closure(root);
- find_ud(root);
- find_edom(root);
- opt_blks(root, do_stmts);
+ opt_state->done = 1;
+ find_levels(opt_state, ic);
+ find_dom(opt_state, ic->root);
+ find_closure(opt_state, ic->root);
+ find_ud(opt_state, ic->root);
+ find_edom(opt_state, ic->root);
+ opt_blks(cstate, opt_state, ic, do_stmts);
#ifdef BDEBUG
- if (dflag > 1) {
- printf("opt_loop(root, %d) bottom, done=%d\n", do_stmts, done);
- opt_dump(root);
+ if (pcap_optimizer_debug > 1) {
+ printf("opt_loop(root, %d) bottom, done=%d\n", do_stmts, opt_state->done);
+ opt_dump(cstate, ic);
}
#endif
- } while (!done);
+ } while (!opt_state->done);
}
/*
* Optimize the filter code in its dag representation.
*/
void
-bpf_optimize(struct block **rootp)
+bpf_optimize(compiler_state_t *cstate, struct icode *ic)
{
- struct block *root;
+ opt_state_t opt_state;
- root = *rootp;
-
- opt_init(root);
- opt_loop(root, 0);
- opt_loop(root, 1);
- intern_blocks(root);
+ opt_init(cstate, &opt_state, ic);
+ opt_loop(cstate, &opt_state, ic, 0);
+ opt_loop(cstate, &opt_state, ic, 1);
+ intern_blocks(&opt_state, ic);
#ifdef BDEBUG
- if (dflag > 1) {
+ if (pcap_optimizer_debug > 1) {
printf("after intern_blocks()\n");
- opt_dump(root);
+ opt_dump(cstate, ic);
}
#endif
- opt_root(rootp);
+ opt_root(&ic->root);
#ifdef BDEBUG
- if (dflag > 1) {
+ if (pcap_optimizer_debug > 1) {
printf("after opt_root()\n");
- opt_dump(root);
+ opt_dump(cstate, ic);
}
#endif
- opt_cleanup();
+ opt_cleanup(&opt_state);
}
static void
-make_marks(struct block *p)
+make_marks(struct icode *ic, struct block *p)
{
- if (!isMarked(p)) {
- Mark(p);
+ if (!isMarked(ic, p)) {
+ Mark(ic, p);
if (BPF_CLASS(p->s.code) != BPF_RET) {
- make_marks(JT(p));
- make_marks(JF(p));
+ make_marks(ic, JT(p));
+ make_marks(ic, JF(p));
}
}
}
/*
- * Mark code array such that isMarked(i) is true
+ * Mark code array such that isMarked(ic->cur_mark, i) is true
* only for nodes that are alive.
*/
static void
-mark_code(struct block *p)
+mark_code(struct icode *ic)
{
- cur_mark += 1;
- make_marks(p);
+ ic->cur_mark += 1;
+ make_marks(ic, ic->root);
}
/*
@@ -1759,33 +1793,33 @@ eq_blk(struct block *b0, struct block *b1)
}
static void
-intern_blocks(struct block *root)
+intern_blocks(opt_state_t *opt_state, struct icode *ic)
{
struct block *p;
int i, j;
int done1; /* don't shadow global */
top:
done1 = 1;
- for (i = 0; i < n_blocks; ++i)
- blocks[i]->link = 0;
+ for (i = 0; i < opt_state->n_blocks; ++i)
+ opt_state->blocks[i]->link = 0;
- mark_code(root);
+ mark_code(ic);
- for (i = n_blocks - 1; --i >= 0; ) {
- if (!isMarked(blocks[i]))
+ for (i = opt_state->n_blocks - 1; --i >= 0; ) {
+ if (!isMarked(ic, opt_state->blocks[i]))
continue;
- for (j = i + 1; j < n_blocks; ++j) {
- if (!isMarked(blocks[j]))
+ for (j = i + 1; j < opt_state->n_blocks; ++j) {
+ if (!isMarked(ic, opt_state->blocks[j]))
continue;
- if (eq_blk(blocks[i], blocks[j])) {
- blocks[i]->link = blocks[j]->link ?
- blocks[j]->link : blocks[j];
+ if (eq_blk(opt_state->blocks[i], opt_state->blocks[j])) {
+ opt_state->blocks[i]->link = opt_state->blocks[j]->link ?
+ opt_state->blocks[j]->link : opt_state->blocks[j];
break;
}
}
}
- for (i = 0; i < n_blocks; ++i) {
- p = blocks[i];
+ for (i = 0; i < opt_state->n_blocks; ++i) {
+ p = opt_state->blocks[i];
if (JT(p) == 0)
continue;
if (JT(p)->link) {
@@ -1802,14 +1836,14 @@ intern_blocks(struct block *root)
}
static void
-opt_cleanup(void)
+opt_cleanup(opt_state_t *opt_state)
{
- free((void *)vnode_base);
- free((void *)vmap);
- free((void *)edges);
- free((void *)space);
- free((void *)levels);
- free((void *)blocks);
+ free((void *)opt_state->vnode_base);
+ free((void *)opt_state->vmap);
+ free((void *)opt_state->edges);
+ free((void *)opt_state->space);
+ free((void *)opt_state->levels);
+ free((void *)opt_state->blocks);
}
/*
@@ -1831,12 +1865,12 @@ slength(struct slist *s)
* All nodes should be initially unmarked.
*/
static int
-count_blocks(struct block *p)
+count_blocks(struct icode *ic, struct block *p)
{
- if (p == 0 || isMarked(p))
+ if (p == 0 || isMarked(ic, p))
return 0;
- Mark(p);
- return count_blocks(JT(p)) + count_blocks(JF(p)) + 1;
+ Mark(ic, p);
+ return count_blocks(ic, JT(p)) + count_blocks(ic, JF(p)) + 1;
}
/*
@@ -1844,20 +1878,20 @@ count_blocks(struct block *p)
* the basic blocks, and entering them into the 'blocks' array.`
*/
static void
-number_blks_r(struct block *p)
+number_blks_r(opt_state_t *opt_state, struct icode *ic, struct block *p)
{
int n;
- if (p == 0 || isMarked(p))
+ if (p == 0 || isMarked(ic, p))
return;
- Mark(p);
- n = n_blocks++;
+ Mark(ic, p);
+ n = opt_state->n_blocks++;
p->id = n;
- blocks[n] = p;
+ opt_state->blocks[n] = p;
- number_blks_r(JT(p));
- number_blks_r(JF(p));
+ number_blks_r(opt_state, ic, JT(p));
+ number_blks_r(opt_state, ic, JF(p));
}
/*
@@ -1879,14 +1913,14 @@ number_blks_r(struct block *p)
* an extra long jump if the false branch requires it (p->longjf).
*/
static u_int
-count_stmts(struct block *p)
+count_stmts(struct icode *ic, struct block *p)
{
u_int n;
- if (p == 0 || isMarked(p))
+ if (p == 0 || isMarked(ic, p))
return 0;
- Mark(p);
- n = count_stmts(JT(p)) + count_stmts(JF(p));
+ Mark(ic, p);
+ n = count_stmts(ic, JT(p)) + count_stmts(ic, JF(p));
return slength(p->stmts) + n + 1 + p->longjt + p->longjf;
}
@@ -1896,7 +1930,7 @@ count_stmts(struct block *p)
* from the total number of blocks and/or statements.
*/
static void
-opt_init(struct block *root)
+opt_init(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic)
{
bpf_u_int32 *p;
int i, n, max_stmts;
@@ -1905,84 +1939,81 @@ opt_init(struct block *root)
* First, count the blocks, so we can malloc an array to map
* block number to block. Then, put the blocks into the array.
*/
- unMarkAll();
- n = count_blocks(root);
- blocks = (struct block **)calloc(n, sizeof(*blocks));
- if (blocks == NULL)
- bpf_error("malloc");
- unMarkAll();
- n_blocks = 0;
- number_blks_r(root);
-
- n_edges = 2 * n_blocks;
- edges = (struct edge **)calloc(n_edges, sizeof(*edges));
- if (edges == NULL)
- bpf_error("malloc");
+ unMarkAll(ic);
+ n = count_blocks(ic, ic->root);
+ opt_state->blocks = (struct block **)calloc(n, sizeof(*opt_state->blocks));
+ if (opt_state->blocks == NULL)
+ bpf_error(cstate, "malloc");
+ unMarkAll(ic);
+ opt_state->n_blocks = 0;
+ number_blks_r(opt_state, ic, ic->root);
+
+ opt_state->n_edges = 2 * opt_state->n_blocks;
+ opt_state->edges = (struct edge **)calloc(opt_state->n_edges, sizeof(*opt_state->edges));
+ if (opt_state->edges == NULL)
+ bpf_error(cstate, "malloc");
/*
* The number of levels is bounded by the number of nodes.
*/
- levels = (struct block **)calloc(n_blocks, sizeof(*levels));
- if (levels == NULL)
- bpf_error("malloc");
+ opt_state->levels = (struct block **)calloc(opt_state->n_blocks, sizeof(*opt_state->levels));
+ if (opt_state->levels == NULL)
+ bpf_error(cstate, "malloc");
- edgewords = n_edges / (8 * sizeof(bpf_u_int32)) + 1;
- nodewords = n_blocks / (8 * sizeof(bpf_u_int32)) + 1;
+ opt_state->edgewords = opt_state->n_edges / (8 * sizeof(bpf_u_int32)) + 1;
+ opt_state->nodewords = opt_state->n_blocks / (8 * sizeof(bpf_u_int32)) + 1;
/* XXX */
- space = (bpf_u_int32 *)malloc(2 * n_blocks * nodewords * sizeof(*space)
- + n_edges * edgewords * sizeof(*space));
- if (space == NULL)
- bpf_error("malloc");
- p = space;
- all_dom_sets = p;
+ opt_state->space = (bpf_u_int32 *)malloc(2 * opt_state->n_blocks * opt_state->nodewords * sizeof(*opt_state->space)
+ + opt_state->n_edges * opt_state->edgewords * sizeof(*opt_state->space));
+ if (opt_state->space == NULL)
+ bpf_error(cstate, "malloc");
+ p = opt_state->space;
+ opt_state->all_dom_sets = p;
for (i = 0; i < n; ++i) {
- blocks[i]->dom = p;
- p += nodewords;
+ opt_state->blocks[i]->dom = p;
+ p += opt_state->nodewords;
}
- all_closure_sets = p;
+ opt_state->all_closure_sets = p;
for (i = 0; i < n; ++i) {
- blocks[i]->closure = p;
- p += nodewords;
+ opt_state->blocks[i]->closure = p;
+ p += opt_state->nodewords;
}
- all_edge_sets = p;
+ opt_state->all_edge_sets = p;
for (i = 0; i < n; ++i) {
- register struct block *b = blocks[i];
+ register struct block *b = opt_state->blocks[i];
b->et.edom = p;
- p += edgewords;
+ p += opt_state->edgewords;
b->ef.edom = p;
- p += edgewords;
+ p += opt_state->edgewords;
b->et.id = i;
- edges[i] = &b->et;
- b->ef.id = n_blocks + i;
- edges[n_blocks + i] = &b->ef;
+ opt_state->edges[i] = &b->et;
+ b->ef.id = opt_state->n_blocks + i;
+ opt_state->edges[opt_state->n_blocks + i] = &b->ef;
b->et.pred = b;
b->ef.pred = b;
}
max_stmts = 0;
for (i = 0; i < n; ++i)
- max_stmts += slength(blocks[i]->stmts) + 1;
+ max_stmts += slength(opt_state->blocks[i]->stmts) + 1;
/*
* We allocate at most 3 value numbers per statement,
* so this is an upper bound on the number of valnodes
* we'll need.
*/
- maxval = 3 * max_stmts;
- vmap = (struct vmapinfo *)calloc(maxval, sizeof(*vmap));
- vnode_base = (struct valnode *)calloc(maxval, sizeof(*vnode_base));
- if (vmap == NULL || vnode_base == NULL)
- bpf_error("malloc");
+ opt_state->maxval = 3 * max_stmts;
+ opt_state->vmap = (struct vmapinfo *)calloc(opt_state->maxval, sizeof(*opt_state->vmap));
+ opt_state->vnode_base = (struct valnode *)calloc(opt_state->maxval, sizeof(*opt_state->vnode_base));
+ if (opt_state->vmap == NULL || opt_state->vnode_base == NULL)
+ bpf_error(cstate, "malloc");
}
/*
- * Some pointers used to convert the basic block form of the code,
- * into the array form that BPF requires. 'fstart' will point to
- * the malloc'd array while 'ftail' is used during the recursive traversal.
+ * This is only used when supporting optimizer debugging. It is
+ * global state, so do *not* do more than one compile in parallel
+ * and expect it to provide meaningful information.
*/
-static struct bpf_insn *fstart;
-static struct bpf_insn *ftail;
-
#ifdef BDEBUG
int bids[1000];
#endif
@@ -1994,35 +2025,36 @@ int bids[1000];
* properly.
*/
static int
-convert_code_r(struct block *p)
+convert_code_r(compiler_state_t *cstate, conv_state_t *conv_state,
+ struct icode *ic, struct block *p)
{
struct bpf_insn *dst;
struct slist *src;
- int slen;
+ u_int slen;
u_int off;
int extrajmps; /* number of extra jumps inserted */
struct slist **offset = NULL;
- if (p == 0 || isMarked(p))
+ if (p == 0 || isMarked(ic, p))
return (1);
- Mark(p);
+ Mark(ic, p);
- if (convert_code_r(JF(p)) == 0)
+ if (convert_code_r(cstate, conv_state, ic, JF(p)) == 0)
return (0);
- if (convert_code_r(JT(p)) == 0)
+ if (convert_code_r(cstate, conv_state, ic, JT(p)) == 0)
return (0);
slen = slength(p->stmts);
- dst = ftail -= (slen + 1 + p->longjt + p->longjf);
+ dst = conv_state->ftail -= (slen + 1 + p->longjt + p->longjf);
/* inflate length by any extra jumps */
- p->offset = dst - fstart;
+ p->offset = (int)(dst - conv_state->fstart);
/* generate offset[] for convenience */
if (slen) {
offset = (struct slist **)calloc(slen, sizeof(struct slist *));
if (!offset) {
- bpf_error("not enough core");
+ bpf_error(cstate, "not enough core");
/*NOTREACHED*/
}
}
@@ -2046,7 +2078,7 @@ convert_code_r(struct block *p)
if (BPF_CLASS(src->s.code) != BPF_JMP || src->s.code == (BPF_JMP|BPF_JA)) {
#if 0
if (src->s.jt || src->s.jf) {
- bpf_error("illegal jmp destination");
+ bpf_error(cstate, "illegal jmp destination");
/*NOTREACHED*/
}
#endif
@@ -2056,7 +2088,7 @@ convert_code_r(struct block *p)
goto filled;
{
- int i;
+ u_int i;
int jt, jf;
const char *ljerr = "%s for block-local relative jump: off=%d";
@@ -2066,7 +2098,7 @@ convert_code_r(struct block *p)
#endif
if (!src->s.jt || !src->s.jf) {
- bpf_error(ljerr, "no jmp destination", off);
+ bpf_error(cstate, ljerr, "no jmp destination", off);
/*NOTREACHED*/
}
@@ -2074,7 +2106,7 @@ convert_code_r(struct block *p)
for (i = 0; i < slen; i++) {
if (offset[i] == src->s.jt) {
if (jt) {
- bpf_error(ljerr, "multiple matches", off);
+ bpf_error(cstate, ljerr, "multiple matches", off);
/*NOTREACHED*/
}
@@ -2083,7 +2115,7 @@ convert_code_r(struct block *p)
}
if (offset[i] == src->s.jf) {
if (jf) {
- bpf_error(ljerr, "multiple matches", off);
+ bpf_error(cstate, ljerr, "multiple matches", off);
/*NOTREACHED*/
}
dst->jf = i - off - 1;
@@ -2091,7 +2123,7 @@ convert_code_r(struct block *p)
}
}
if (!jt || !jf) {
- bpf_error(ljerr, "no destination found", off);
+ bpf_error(cstate, ljerr, "no destination found", off);
/*NOTREACHED*/
}
}
@@ -2103,7 +2135,7 @@ filled:
free(offset);
#ifdef BDEBUG
- bids[dst - fstart] = p->id + 1;
+ bids[dst - conv_state->fstart] = p->id + 1;
#endif
dst->code = (u_short)p->s.code;
dst->k = p->s.k;
@@ -2166,28 +2198,30 @@ filled:
* done with the filter program. See the pcap man page.
*/
struct bpf_insn *
-icode_to_fcode(struct block *root, u_int *lenp)
+icode_to_fcode(compiler_state_t *cstate, struct icode *ic,
+ struct block *root, u_int *lenp)
{
u_int n;
struct bpf_insn *fp;
+ conv_state_t conv_state;
/*
* Loop doing convert_code_r() until no branches remain
* with too-large offsets.
*/
while (1) {
- unMarkAll();
- n = *lenp = count_stmts(root);
+ unMarkAll(ic);
+ n = *lenp = count_stmts(ic, root);
fp = (struct bpf_insn *)malloc(sizeof(*fp) * n);
if (fp == NULL)
- bpf_error("malloc");
+ bpf_error(cstate, "malloc");
memset((char *)fp, 0, sizeof(*fp) * n);
- fstart = fp;
- ftail = fp + n;
+ conv_state.fstart = fp;
+ conv_state.ftail = fp + n;
- unMarkAll();
- if (convert_code_r(root))
+ unMarkAll(ic);
+ if (convert_code_r(cstate, &conv_state, ic, root))
break;
free(fp);
}
@@ -2212,7 +2246,7 @@ install_bpf_program(pcap_t *p, struct bpf_program *fp)
* Validate the program.
*/
if (!bpf_validate(fp->bf_insns, fp->bf_len)) {
- snprintf(p->errbuf, sizeof(p->errbuf),
+ pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"BPF program is not valid");
return (-1);
}
@@ -2226,7 +2260,7 @@ 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) {
- snprintf(p->errbuf, sizeof(p->errbuf),
+ pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"malloc: %s", pcap_strerror(errno));
return (-1);
}
@@ -2236,14 +2270,117 @@ install_bpf_program(pcap_t *p, struct bpf_program *fp)
#ifdef BDEBUG
static void
-opt_dump(struct block *root)
+dot_dump_node(struct icode *ic, struct block *block, struct bpf_program *prog,
+ FILE *out)
+{
+ int icount, noffset;
+ int i;
+
+ if (block == NULL || isMarked(ic, block))
+ return;
+ Mark(ic, block);
+
+ icount = slength(block->stmts) + 1 + block->longjt + block->longjf;
+ noffset = min(block->offset + icount, (int)prog->bf_len);
+
+ fprintf(out, "\tblock%d [shape=ellipse, id=\"block-%d\" label=\"BLOCK%d\\n", block->id, block->id, block->id);
+ for (i = block->offset; i < noffset; i++) {
+ fprintf(out, "\\n%s", bpf_image(prog->bf_insns + i, i));
+ }
+ fprintf(out, "\" tooltip=\"");
+ for (i = 0; i < BPF_MEMWORDS; i++)
+ if (block->val[i] != 0)
+ 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]);
+ fprintf(out, "\"");
+ if (JT(block) == NULL)
+ fprintf(out, ", peripheries=2");
+ fprintf(out, "];\n");
+
+ dot_dump_node(ic, JT(block), prog, out);
+ dot_dump_node(ic, JF(block), prog, out);
+}
+
+static void
+dot_dump_edge(struct icode *ic, struct block *block, FILE *out)
+{
+ if (block == NULL || isMarked(ic, block))
+ return;
+ Mark(ic, block);
+
+ if (JT(block)) {
+ fprintf(out, "\t\"block%d\":se -> \"block%d\":n [label=\"T\"]; \n",
+ block->id, JT(block)->id);
+ fprintf(out, "\t\"block%d\":sw -> \"block%d\":n [label=\"F\"]; \n",
+ block->id, JF(block)->id);
+ }
+ dot_dump_edge(ic, JT(block), out);
+ dot_dump_edge(ic, JF(block), out);
+}
+
+/* Output the block CFG using graphviz/DOT language
+ * In the CFG, block's code, value index for each registers at EXIT,
+ * and the jump relationship is show.
+ *
+ * example DOT for BPF `ip src host 1.1.1.1' is:
+ digraph BPF {
+ block0 [shape=ellipse, id="block-0" label="BLOCK0\n\n(000) ldh [12]\n(001) jeq #0x800 jt 2 jf 5" tooltip="val[A]=0 val[X]=0"];
+ block1 [shape=ellipse, id="block-1" label="BLOCK1\n\n(002) ld [26]\n(003) jeq #0x1010101 jt 4 jf 5" tooltip="val[A]=0 val[X]=0"];
+ block2 [shape=ellipse, id="block-2" label="BLOCK2\n\n(004) ret #68" tooltip="val[A]=0 val[X]=0", peripheries=2];
+ block3 [shape=ellipse, id="block-3" label="BLOCK3\n\n(005) ret #0" tooltip="val[A]=0 val[X]=0", peripheries=2];
+ "block0":se -> "block1":n [label="T"];
+ "block0":sw -> "block3":n [label="F"];
+ "block1":se -> "block2":n [label="T"];
+ "block1":sw -> "block3":n [label="F"];
+ }
+ *
+ * After install graphviz on http://www.graphviz.org/, save it as bpf.dot
+ * and run `dot -Tpng -O bpf.dot' to draw the graph.
+ */
+static void
+dot_dump(compiler_state_t *cstate, struct icode *ic)
{
struct bpf_program f;
+ FILE *out = stdout;
memset(bids, 0, sizeof bids);
- f.bf_insns = icode_to_fcode(root, &f.bf_len);
+ 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");
+
+ free((char *)f.bf_insns);
+}
+
+static void
+plain_dump(compiler_state_t *cstate, struct icode *ic)
+{
+ struct bpf_program f;
+
+ memset(bids, 0, sizeof bids);
+ f.bf_insns = icode_to_fcode(cstate, ic, ic->root, &f.bf_len);
bpf_dump(&f, 1);
putchar('\n');
free((char *)f.bf_insns);
}
+
+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 (pcap_optimizer_debug > 3)
+ dot_dump(cstate, ic);
+ else
+ plain_dump(cstate, ic);
+}
#endif
diff --git a/freebsd/contrib/libpcap/pcap-bpf.c b/freebsd/contrib/libpcap/pcap-bpf.c
index 8375308f..60111cf5 100644
--- a/freebsd/contrib/libpcap/pcap-bpf.c
+++ b/freebsd/contrib/libpcap/pcap-bpf.c
@@ -22,10 +22,6 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.116 2008-09-16 18:42:29 guy Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -56,6 +52,15 @@ static const char rcsid[] _U_ =
#endif
#include <sys/utsname.h>
+#if defined(__FreeBSD__) && defined(SIOCIFCREATE2)
+/*
+ * Add support for capturing on FreeBSD usbusN interfaces.
+ */
+static const char usbus_prefix[] = "usbus";
+#define USBUS_PREFIX_LEN (sizeof(usbus_prefix) - 1)
+#include <dirent.h>
+#endif
+
#ifdef HAVE_ZEROCOPY_BPF
#include <machine/atomic.h>
#endif
@@ -130,9 +135,68 @@ static int bpf_load(char *errbuf);
#include "os-proto.h"
#endif
+/*
+ * Later versions of NetBSD stick padding in front of FDDI frames
+ * to align the IP header on a 4-byte boundary.
+ */
+#if defined(__NetBSD__) && __NetBSD_Version__ > 106000000
+#define PCAP_FDDIPAD 3
+#endif
+
+/*
+ * Private data for capturing on BPF devices.
+ */
+struct pcap_bpf {
+#ifdef HAVE_ZEROCOPY_BPF
+ /*
+ * Zero-copy read buffer -- for zero-copy BPF. 'buffer' above will
+ * alternative between these two actual mmap'd buffers as required.
+ * As there is a header on the front size of the mmap'd buffer, only
+ * some of the buffer is exposed to libpcap as a whole via bufsize;
+ * zbufsize is the true size. zbuffer tracks the current zbuf
+ * assocated with buffer so that it can be used to decide which the
+ * next buffer to read will be.
+ */
+ u_char *zbuf1, *zbuf2, *zbuffer;
+ u_int zbufsize;
+ u_int zerocopy;
+ u_int interrupted;
+ struct timespec firstsel;
+ /*
+ * If there's currently a buffer being actively processed, then it is
+ * referenced here; 'buffer' is also pointed at it, but offset by the
+ * size of the header.
+ */
+ struct bpf_zbuf_header *bzh;
+ int nonblock; /* true if in nonblocking mode */
+#endif /* HAVE_ZEROCOPY_BPF */
+
+ char *device; /* device name */
+ int filtering_in_kernel; /* using kernel filter */
+ int must_do_on_close; /* stuff we must do when we close */
+};
+
+/*
+ * Stuff to do when we close.
+ */
+#define MUST_CLEAR_RFMON 0x00000001 /* clear rfmon (monitor) mode */
+#define MUST_DESTROY_USBUS 0x00000002 /* destroy usbusN interface */
+
#ifdef BIOCGDLTLIST
# if (defined(HAVE_NET_IF_MEDIA_H) && defined(IFM_IEEE80211)) && !defined(__APPLE__)
#define HAVE_BSD_IEEE80211
+
+/*
+ * The ifm_ulist member of a struct ifmediareq is an int * on most systems,
+ * but it's a uint64_t on newer versions of OpenBSD.
+ *
+ * We check this by checking whether IFM_GMASK is defined and > 2^32-1.
+ */
+# if defined(IFM_GMASK) && IFM_GMASK > 0xFFFFFFFF
+# define IFM_ULIST_TYPE uint64_t
+# else
+# define IFM_ULIST_TYPE int
+# endif
# endif
# if defined(__APPLE__) || defined(HAVE_BSD_IEEE80211)
@@ -188,49 +252,29 @@ static int pcap_set_datalink_bpf(pcap_t *p, int dlt);
/*
* For zerocopy bpf, the setnonblock/getnonblock routines need to modify
- * p->md.timeout so we don't call select(2) if the pcap handle is in non-
- * blocking mode. We preserve the timeout supplied by pcap_open functions
- * to make sure it does not get clobbered if the pcap handle moves between
- * blocking and non-blocking mode.
+ * pb->nonblock so we don't call select(2) if the pcap handle is in non-
+ * blocking mode.
*/
static int
pcap_getnonblock_bpf(pcap_t *p, char *errbuf)
-{
+{
#ifdef HAVE_ZEROCOPY_BPF
- if (p->md.zerocopy) {
- /*
- * Use a negative value for the timeout to represent that the
- * pcap handle is in non-blocking mode.
- */
- return (p->md.timeout < 0);
- }
+ struct pcap_bpf *pb = p->priv;
+
+ if (pb->zerocopy)
+ return (pb->nonblock);
#endif
return (pcap_getnonblock_fd(p, errbuf));
}
static int
pcap_setnonblock_bpf(pcap_t *p, int nonblock, char *errbuf)
-{
+{
#ifdef HAVE_ZEROCOPY_BPF
- if (p->md.zerocopy) {
- /*
- * Map each value to their corresponding negation to
- * preserve the timeout value provided with pcap_set_timeout.
- * (from pcap-linux.c).
- */
- if (nonblock) {
- if (p->md.timeout >= 0) {
- /*
- * Indicate that we're switching to
- * non-blocking mode.
- */
- p->md.timeout = ~p->md.timeout;
- }
- } else {
- if (p->md.timeout < 0) {
- p->md.timeout = ~p->md.timeout;
- }
- }
+ struct pcap_bpf *pb = p->priv;
+
+ if (pb->zerocopy) {
+ pb->nonblock = nonblock;
return (0);
}
#endif
@@ -250,25 +294,26 @@ pcap_setnonblock_bpf(pcap_t *p, int nonblock, char *errbuf)
static int
pcap_next_zbuf_shm(pcap_t *p, int *cc)
{
+ struct pcap_bpf *pb = p->priv;
struct bpf_zbuf_header *bzh;
- if (p->md.zbuffer == p->md.zbuf2 || p->md.zbuffer == NULL) {
- bzh = (struct bpf_zbuf_header *)p->md.zbuf1;
+ if (pb->zbuffer == pb->zbuf2 || pb->zbuffer == NULL) {
+ bzh = (struct bpf_zbuf_header *)pb->zbuf1;
if (bzh->bzh_user_gen !=
atomic_load_acq_int(&bzh->bzh_kernel_gen)) {
- p->md.bzh = bzh;
- p->md.zbuffer = (u_char *)p->md.zbuf1;
- p->buffer = p->md.zbuffer + sizeof(*bzh);
+ pb->bzh = bzh;
+ pb->zbuffer = (u_char *)pb->zbuf1;
+ p->buffer = pb->zbuffer + sizeof(*bzh);
*cc = bzh->bzh_kernel_len;
return (1);
}
- } else if (p->md.zbuffer == p->md.zbuf1) {
- bzh = (struct bpf_zbuf_header *)p->md.zbuf2;
+ } else if (pb->zbuffer == pb->zbuf1) {
+ bzh = (struct bpf_zbuf_header *)pb->zbuf2;
if (bzh->bzh_user_gen !=
atomic_load_acq_int(&bzh->bzh_kernel_gen)) {
- p->md.bzh = bzh;
- p->md.zbuffer = (u_char *)p->md.zbuf2;
- p->buffer = p->md.zbuffer + sizeof(*bzh);
+ pb->bzh = bzh;
+ pb->zbuffer = (u_char *)pb->zbuf2;
+ p->buffer = pb->zbuffer + sizeof(*bzh);
*cc = bzh->bzh_kernel_len;
return (1);
}
@@ -287,6 +332,7 @@ pcap_next_zbuf_shm(pcap_t *p, int *cc)
static int
pcap_next_zbuf(pcap_t *p, int *cc)
{
+ struct pcap_bpf *pb = p->priv;
struct bpf_zbuf bz;
struct timeval tv;
struct timespec cur;
@@ -310,20 +356,20 @@ pcap_next_zbuf(pcap_t *p, int *cc)
* our timeout is less then or equal to zero, handle it like a
* regular timeout.
*/
- tmout = p->md.timeout;
+ tmout = p->opt.timeout;
if (tmout)
(void) clock_gettime(CLOCK_MONOTONIC, &cur);
- if (p->md.interrupted && p->md.timeout) {
- expire = TSTOMILLI(&p->md.firstsel) + p->md.timeout;
+ if (pb->interrupted && p->opt.timeout) {
+ expire = TSTOMILLI(&pb->firstsel) + p->opt.timeout;
tmout = expire - TSTOMILLI(&cur);
#undef TSTOMILLI
if (tmout <= 0) {
- p->md.interrupted = 0;
+ pb->interrupted = 0;
data = pcap_next_zbuf_shm(p, cc);
if (data)
return (data);
if (ioctl(p->fd, BIOCROTZBUF, &bz) < 0) {
- (void) snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ (void) pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCROTZBUF: %s", strerror(errno));
return (PCAP_ERROR);
}
@@ -335,7 +381,7 @@ pcap_next_zbuf(pcap_t *p, int *cc)
* the next timeout. Note that we only call select if the handle
* is in blocking mode.
*/
- if (p->md.timeout >= 0) {
+ if (!pb->nonblock) {
FD_ZERO(&r_set);
FD_SET(p->fd, &r_set);
if (tmout != 0) {
@@ -343,20 +389,20 @@ pcap_next_zbuf(pcap_t *p, int *cc)
tv.tv_usec = (tmout * 1000) % 1000000;
}
r = select(p->fd + 1, &r_set, NULL, NULL,
- p->md.timeout != 0 ? &tv : NULL);
+ p->opt.timeout != 0 ? &tv : NULL);
if (r < 0 && errno == EINTR) {
- if (!p->md.interrupted && p->md.timeout) {
- p->md.interrupted = 1;
- p->md.firstsel = cur;
+ if (!pb->interrupted && p->opt.timeout) {
+ pb->interrupted = 1;
+ pb->firstsel = cur;
}
return (0);
} else if (r < 0) {
- (void) snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ (void) pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"select: %s", strerror(errno));
return (PCAP_ERROR);
}
}
- p->md.interrupted = 0;
+ pb->interrupted = 0;
/*
* Check again for data, which may exist now that we've either been
* woken up as a result of data or timed out. Try the "there's data"
@@ -370,7 +416,7 @@ pcap_next_zbuf(pcap_t *p, int *cc)
* data.
*/
if (ioctl(p->fd, BIOCROTZBUF, &bz) < 0) {
- (void) snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ (void) pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCROTZBUF: %s", strerror(errno));
return (PCAP_ERROR);
}
@@ -384,26 +430,43 @@ pcap_next_zbuf(pcap_t *p, int *cc)
static int
pcap_ack_zbuf(pcap_t *p)
{
+ struct pcap_bpf *pb = p->priv;
- atomic_store_rel_int(&p->md.bzh->bzh_user_gen,
- p->md.bzh->bzh_kernel_gen);
- p->md.bzh = NULL;
+ atomic_store_rel_int(&pb->bzh->bzh_user_gen,
+ pb->bzh->bzh_kernel_gen);
+ pb->bzh = NULL;
p->buffer = NULL;
return (0);
}
#endif /* HAVE_ZEROCOPY_BPF */
pcap_t *
-pcap_create_interface(const char *device, char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(ebuf, sizeof (struct pcap_bpf));
if (p == NULL)
return (NULL);
p->activate_op = pcap_activate_bpf;
p->can_set_rfmon_op = pcap_can_set_rfmon_bpf;
+#ifdef BIOCSTSTAMP
+ /*
+ * We claim that we support microsecond and nanosecond time
+ * stamps.
+ */
+ 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));
+ free(p);
+ return (NULL);
+ }
+ p->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;
+ p->tstamp_precision_list[1] = PCAP_TSTAMP_PRECISION_NANO;
+#endif /* BIOCSTSTAMP */
return (p);
}
@@ -412,7 +475,7 @@ pcap_create_interface(const char *device, char *ebuf)
* On failure, returns a PCAP_ERROR_ value, and sets p->errbuf.
*/
static int
-bpf_open(pcap_t *p)
+bpf_open(char *errbuf)
{
int fd;
#ifdef HAVE_CLONING_BPF
@@ -428,7 +491,7 @@ bpf_open(pcap_t *p)
* and create the BPF device entries, if they don't
* already exist.
*/
- if (bpf_load(p->errbuf) == PCAP_ERROR)
+ if (bpf_load(errbuf) == PCAP_ERROR)
return (PCAP_ERROR);
#endif
@@ -439,7 +502,7 @@ bpf_open(pcap_t *p)
fd = PCAP_ERROR_PERM_DENIED;
else
fd = PCAP_ERROR;
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"(cannot open device) %s: %s", device, pcap_strerror(errno));
}
#else
@@ -447,7 +510,7 @@ bpf_open(pcap_t *p)
* Go through all the minors and find one that isn't in use.
*/
do {
- (void)snprintf(device, sizeof(device), "/dev/bpf%d", n++);
+ (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
@@ -481,7 +544,7 @@ bpf_open(pcap_t *p)
* means we probably have no BPF
* devices.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"(there are no BPF devices)");
} else {
/*
@@ -490,7 +553,7 @@ bpf_open(pcap_t *p)
* devices, but all the ones
* that exist are busy.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"(all BPF devices are busy)");
}
break;
@@ -502,7 +565,7 @@ bpf_open(pcap_t *p)
* if any.
*/
fd = PCAP_ERROR_PERM_DENIED;
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"(cannot open BPF device) %s: %s", device,
pcap_strerror(errno));
break;
@@ -512,7 +575,7 @@ bpf_open(pcap_t *p)
* Some other problem.
*/
fd = PCAP_ERROR;
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"(cannot open BPF device) %s: %s", device,
pcap_strerror(errno));
break;
@@ -523,6 +586,66 @@ bpf_open(pcap_t *p)
return (fd);
}
+/*
+ * Open and bind to a device; used if we're not actually going to use
+ * the device, but are just testing whether it can be opened, or opening
+ * it to get information about it.
+ *
+ * Returns an error code on failure (always negative), and an FD for
+ * the now-bound BPF device on success (always non-negative).
+ */
+static int
+bpf_open_and_bind(const char *name, char *errbuf)
+{
+ int fd;
+ struct ifreq ifr;
+
+ /*
+ * First, open a BPF device.
+ */
+ fd = bpf_open(errbuf);
+ if (fd < 0)
+ return (fd); /* fd is the appropriate error code */
+
+ /*
+ * Now bind to the device.
+ */
+ (void)strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
+ switch (errno) {
+
+ case ENXIO:
+ /*
+ * There's no such device.
+ */
+ close(fd);
+ return (PCAP_ERROR_NO_SUCH_DEVICE);
+
+ case ENETDOWN:
+ /*
+ * Return a "network down" indication, so that
+ * the application can report that rather than
+ * saying we had a mysterious failure and
+ * suggest that they report a problem to the
+ * libpcap developers.
+ */
+ close(fd);
+ return (PCAP_ERROR_IFACE_NOT_UP);
+
+ default:
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "BIOCSETIF: %s: %s", name, pcap_strerror(errno));
+ close(fd);
+ return (PCAP_ERROR);
+ }
+ }
+
+ /*
+ * Success.
+ */
+ return (fd);
+}
+
#ifdef BIOCGDLTLIST
static int
get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf)
@@ -534,13 +657,13 @@ 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)snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
+ (void)pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
}
if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) < 0) {
- (void)snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
"BIOCGDLTLIST: %s", pcap_strerror(errno));
free(bdlp->bfl_list);
return (PCAP_ERROR);
@@ -595,7 +718,7 @@ 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)snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
"BIOCGDLTLIST: %s", pcap_strerror(errno));
return (PCAP_ERROR);
}
@@ -654,7 +777,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
* 10.4 (Darwin 8.x). s/en/wlt/, and check
* whether the device exists.
*/
- if (strncmp(p->opt.source, "en", 2) != 0) {
+ if (strncmp(p->opt.device, "en", 2) != 0) {
/*
* Not an enN device; no monitor mode.
*/
@@ -662,12 +785,12 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
}
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) {
- (void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"socket: %s", pcap_strerror(errno));
return (PCAP_ERROR);
}
strlcpy(ifr.ifr_name, "wlt", sizeof(ifr.ifr_name));
- strlcat(ifr.ifr_name, p->opt.source + 2, sizeof(ifr.ifr_name));
+ strlcat(ifr.ifr_name, p->opt.device + 2, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
/*
* No such device?
@@ -687,14 +810,14 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
*
* First, open a BPF device.
*/
- fd = bpf_open(p);
+ fd = bpf_open(p->errbuf);
if (fd < 0)
return (fd); /* fd is the appropriate error code */
/*
* Now bind to the device.
*/
- (void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name));
+ (void)strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
switch (errno) {
@@ -717,9 +840,9 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
return (PCAP_ERROR_IFACE_NOT_UP);
default:
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSETIF: %s: %s",
- p->opt.source, pcap_strerror(errno));
+ p->opt.device, pcap_strerror(errno));
close(fd);
return (PCAP_ERROR);
}
@@ -745,6 +868,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
return (1);
}
free(bdl.bfl_list);
+ close(fd);
#endif /* BIOCGDLTLIST */
return (0);
#elif defined(HAVE_BSD_IEEE80211)
@@ -780,7 +904,7 @@ 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) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGSTATS: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGSTATS: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
}
@@ -794,12 +918,13 @@ pcap_stats_bpf(pcap_t *p, struct pcap_stat *ps)
static int
pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_bpf *pb = p->priv;
int cc;
int n = 0;
register u_char *bp, *ep;
u_char *datap;
#ifdef PCAP_FDDIPAD
- register int pad;
+ register u_int pad;
#endif
#ifdef HAVE_ZEROCOPY_BPF
int i;
@@ -829,7 +954,7 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
* buffer.
*/
#ifdef HAVE_ZEROCOPY_BPF
- if (p->md.zerocopy) {
+ if (pb->zerocopy) {
if (p->buffer != NULL)
pcap_ack_zbuf(p);
i = pcap_next_zbuf(p, &cc);
@@ -840,7 +965,7 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
} else
#endif
{
- cc = read(p->fd, (char *)p->buffer, p->bufsize);
+ cc = read(p->fd, p->buffer, p->bufsize);
}
if (cc < 0) {
/* Don't choke when we get ptraced */
@@ -888,7 +1013,7 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
* pcap_dispatch() etc. aren't
* defined to retur that.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"The interface went down");
return (PCAP_ERROR);
@@ -907,24 +1032,28 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
/* fall through */
#endif
}
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
}
- bp = p->buffer;
+ bp = (u_char *)p->buffer;
} else
bp = p->bp;
/*
* Loop through each packet.
*/
+#ifdef BIOCSTSTAMP
+#define bhp ((struct bpf_xhdr *)bp)
+#else
#define bhp ((struct bpf_hdr *)bp)
+#endif
ep = bp + cc;
#ifdef PCAP_FDDIPAD
pad = p->fddipad;
#endif
while (bp < ep) {
- register int caplen, hdrlen;
+ register u_int caplen, hdrlen;
/*
* Has "pcap_breakloop()" been called?
@@ -977,10 +1106,28 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
* skipping that padding.
#endif
*/
- if (p->md.use_bpf ||
+ if (pb->filtering_in_kernel ||
bpf_filter(p->fcode.bf_insns, datap, bhp->bh_datalen, caplen)) {
struct pcap_pkthdr pkthdr;
+#ifdef BIOCSTSTAMP
+ struct bintime bt;
+ bt.sec = bhp->bh_tstamp.bt_sec;
+ bt.frac = bhp->bh_tstamp.bt_frac;
+ if (p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO) {
+ struct timespec ts;
+
+ bintime2timespec(&bt, &ts);
+ pkthdr.ts.tv_sec = ts.tv_sec;
+ pkthdr.ts.tv_usec = ts.tv_nsec;
+ } else {
+ struct timeval tv;
+
+ bintime2timeval(&bt, &tv);
+ pkthdr.ts.tv_sec = tv.tv_sec;
+ pkthdr.ts.tv_usec = tv.tv_usec;
+ }
+#else
pkthdr.ts.tv_sec = bhp->bh_tstamp.tv_sec;
#ifdef _AIX
/*
@@ -991,6 +1138,7 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
#else
pkthdr.ts.tv_usec = bhp->bh_tstamp.tv_usec;
#endif
+#endif /* BIOCSTSTAMP */
#ifdef PCAP_FDDIPAD
if (caplen > pad)
pkthdr.caplen = caplen - pad;
@@ -1007,7 +1155,7 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
#endif
(*callback)(user, &pkthdr, datap);
bp += BPF_WORDALIGN(caplen + hdrlen);
- if (++n >= cnt && cnt > 0) {
+ if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) {
p->bp = bp;
p->cc = ep - bp;
/*
@@ -1058,7 +1206,7 @@ pcap_inject_bpf(pcap_t *p, const void *buf, size_t size)
u_int spoof_eth_src = 0;
if (ioctl(p->fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1) {
- (void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"send: can't turn off BIOCSHDRCMPLT: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
@@ -1071,7 +1219,7 @@ pcap_inject_bpf(pcap_t *p, const void *buf, size_t size)
}
#endif /* __APPLE__ */
if (ret == -1) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
}
@@ -1087,7 +1235,7 @@ bpf_odminit(char *errbuf)
if (odm_initialize() == -1) {
if (odm_err_msg(odmerrno, &errstr) == -1)
errstr = "Unknown error";
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: odm_initialize failed: %s",
errstr);
return (PCAP_ERROR);
@@ -1096,7 +1244,7 @@ bpf_odminit(char *errbuf)
if ((odmlockid = odm_lock("/etc/objrepos/config_lock", ODM_WAIT)) == -1) {
if (odm_err_msg(odmerrno, &errstr) == -1)
errstr = "Unknown error";
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: odm_lock of /etc/objrepos/config_lock failed: %s",
errstr);
(void)odm_terminate();
@@ -1115,7 +1263,7 @@ bpf_odmcleanup(char *errbuf)
if (errbuf != NULL) {
if (odm_err_msg(odmerrno, &errstr) == -1)
errstr = "Unknown error";
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: odm_unlock failed: %s",
errstr);
}
@@ -1126,7 +1274,7 @@ bpf_odmcleanup(char *errbuf)
if (errbuf != NULL) {
if (odm_err_msg(odmerrno, &errstr) == -1)
errstr = "Unknown error";
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: odm_terminate failed: %s",
errstr);
}
@@ -1160,7 +1308,7 @@ bpf_load(char *errbuf)
major = genmajor(BPF_NAME);
if (major == -1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: genmajor failed: %s", pcap_strerror(errno));
(void)bpf_odmcleanup(NULL);
return (PCAP_ERROR);
@@ -1170,7 +1318,7 @@ bpf_load(char *errbuf)
if (!minors) {
minors = genminor("bpf", major, 0, BPF_MINORS, 1, 1);
if (!minors) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: genminor failed: %s",
pcap_strerror(errno));
(void)bpf_odmcleanup(NULL);
@@ -1183,7 +1331,7 @@ bpf_load(char *errbuf)
rc = stat(BPF_NODE "0", &sbuf);
if (rc == -1 && errno != ENOENT) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: can't stat %s: %s",
BPF_NODE "0", pcap_strerror(errno));
return (PCAP_ERROR);
@@ -1194,7 +1342,7 @@ bpf_load(char *errbuf)
sprintf(buf, "%s%d", BPF_NODE, i);
unlink(buf);
if (mknod(buf, S_IRUSR | S_IFCHR, domakedev(major, i)) == -1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: can't mknod %s: %s",
buf, pcap_strerror(errno));
return (PCAP_ERROR);
@@ -1210,7 +1358,7 @@ bpf_load(char *errbuf)
(cfg_ld.kmid == 0)) {
/* Driver isn't loaded, load it now */
if (sysconfig(SYS_SINGLELOAD, (void *)&cfg_ld, sizeof(cfg_ld)) == -1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: could not load driver: %s",
strerror(errno));
return (PCAP_ERROR);
@@ -1225,7 +1373,7 @@ 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) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"bpf_load: could not configure driver: %s",
strerror(errno));
return (PCAP_ERROR);
@@ -1239,24 +1387,25 @@ bpf_load(char *errbuf)
#endif
/*
- * Turn off rfmon mode if necessary.
+ * Undo any operations done when opening the device when necessary.
*/
static void
pcap_cleanup_bpf(pcap_t *p)
{
+ struct pcap_bpf *pb = p->priv;
#ifdef HAVE_BSD_IEEE80211
int sock;
struct ifmediareq req;
struct ifreq ifr;
#endif
- if (p->md.must_do_on_close != 0) {
+ if (pb->must_do_on_close != 0) {
/*
* There's something we have to do when closing this
* pcap_t.
*/
#ifdef HAVE_BSD_IEEE80211
- if (p->md.must_do_on_close & MUST_CLEAR_RFMON) {
+ if (pb->must_do_on_close & MUST_CLEAR_RFMON) {
/*
* We put the interface into rfmon mode;
* take it out of rfmon mode.
@@ -1273,7 +1422,7 @@ pcap_cleanup_bpf(pcap_t *p)
strerror(errno));
} else {
memset(&req, 0, sizeof(req));
- strncpy(req.ifm_name, p->md.device,
+ strncpy(req.ifm_name, pb->device,
sizeof(req.ifm_name));
if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
fprintf(stderr,
@@ -1288,7 +1437,7 @@ pcap_cleanup_bpf(pcap_t *p)
*/
memset(&ifr, 0, sizeof(ifr));
(void)strncpy(ifr.ifr_name,
- p->md.device,
+ pb->device,
sizeof(ifr.ifr_name));
ifr.ifr_media =
req.ifm_current & ~IFM_IEEE80211_MONITOR;
@@ -1306,16 +1455,34 @@ pcap_cleanup_bpf(pcap_t *p)
}
#endif /* HAVE_BSD_IEEE80211 */
+#if defined(__FreeBSD__) && defined(SIOCIFCREATE2)
+ /*
+ * Attempt to destroy the usbusN interface that we created.
+ */
+ if (pb->must_do_on_close & MUST_DESTROY_USBUS) {
+ if (if_nametoindex(pb->device) > 0) {
+ int s;
+
+ s = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ if (s >= 0) {
+ strlcpy(ifr.ifr_name, pb->device,
+ sizeof(ifr.ifr_name));
+ ioctl(s, SIOCIFDESTROY, &ifr);
+ close(s);
+ }
+ }
+ }
+#endif /* defined(__FreeBSD__) && defined(SIOCIFCREATE2) */
/*
* Take this pcap out of the list of pcaps for which we
* have to take the interface out of some mode.
*/
pcap_remove_from_pcaps_to_close(p);
- p->md.must_do_on_close = 0;
+ pb->must_do_on_close = 0;
}
#ifdef HAVE_ZEROCOPY_BPF
- if (p->md.zerocopy) {
+ if (pb->zerocopy) {
/*
* Delete the mappings. Note that p->buffer gets
* initialized to one of the mmapped regions in
@@ -1323,17 +1490,17 @@ pcap_cleanup_bpf(pcap_t *p)
* null it out so that pcap_cleanup_live_common()
* doesn't try to free it.
*/
- if (p->md.zbuf1 != MAP_FAILED && p->md.zbuf1 != NULL)
- (void) munmap(p->md.zbuf1, p->md.zbufsize);
- if (p->md.zbuf2 != MAP_FAILED && p->md.zbuf2 != NULL)
- (void) munmap(p->md.zbuf2, p->md.zbufsize);
+ if (pb->zbuf1 != MAP_FAILED && pb->zbuf1 != NULL)
+ (void) munmap(pb->zbuf1, pb->zbufsize);
+ if (pb->zbuf2 != MAP_FAILED && pb->zbuf2 != NULL)
+ (void) munmap(pb->zbuf2, pb->zbufsize);
p->buffer = NULL;
p->buffer = NULL;
}
#endif
- if (p->md.device != NULL) {
- free(p->md.device);
- p->md.device = NULL;
+ if (pb->device != NULL) {
+ free(pb->device);
+ pb->device = NULL;
}
pcap_cleanup_live_common(p);
}
@@ -1352,7 +1519,7 @@ check_setif_failure(pcap_t *p, int error)
* No such device exists.
*/
#ifdef __APPLE__
- if (p->opt.rfmon && strncmp(p->opt.source, "wlt", 3) == 0) {
+ if (p->opt.rfmon && strncmp(p->opt.device, "wlt", 3) == 0) {
/*
* Monitor mode was requested, and we're trying
* to open a "wltN" device. Assume that this
@@ -1364,7 +1531,7 @@ check_setif_failure(pcap_t *p, int error)
if (fd != -1) {
strlcpy(ifr.ifr_name, "en",
sizeof(ifr.ifr_name));
- strlcat(ifr.ifr_name, p->opt.source + 3,
+ strlcat(ifr.ifr_name, p->opt.device + 3,
sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
/*
@@ -1373,7 +1540,7 @@ check_setif_failure(pcap_t *p, int error)
* exist.
*/
err = PCAP_ERROR_NO_SUCH_DEVICE;
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFFLAGS on %s failed: %s",
ifr.ifr_name, pcap_strerror(errno));
} else {
@@ -1397,7 +1564,7 @@ check_setif_failure(pcap_t *p, int error)
* just report "no such device".
*/
err = PCAP_ERROR_NO_SUCH_DEVICE;
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"socket() failed: %s",
pcap_strerror(errno));
}
@@ -1407,7 +1574,7 @@ check_setif_failure(pcap_t *p, int error)
/*
* No such device.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF failed: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF failed: %s",
pcap_strerror(errno));
return (PCAP_ERROR_NO_SUCH_DEVICE);
} else if (errno == ENETDOWN) {
@@ -1424,8 +1591,8 @@ check_setif_failure(pcap_t *p, int error)
* Some other error; fill in the error string, and
* return PCAP_ERROR.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
- p->opt.source, pcap_strerror(errno));
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
+ p->opt.device, pcap_strerror(errno));
return (PCAP_ERROR);
}
}
@@ -1448,7 +1615,11 @@ check_setif_failure(pcap_t *p, int error)
static int
pcap_activate_bpf(pcap_t *p)
{
+ struct pcap_bpf *pb = p->priv;
int status = 0;
+#ifdef HAVE_BSD_IEEE80211
+ int retv;
+#endif
int fd;
#ifdef LIFNAMSIZ
char *zonesep;
@@ -1493,7 +1664,7 @@ pcap_activate_bpf(pcap_t *p)
u_int bufmode, zbufmax;
#endif
- fd = bpf_open(p);
+ fd = bpf_open(p->errbuf);
if (fd < 0) {
status = fd;
goto bad;
@@ -1502,14 +1673,14 @@ pcap_activate_bpf(pcap_t *p)
p->fd = fd;
if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCVERSION: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCVERSION: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
}
if (bv.bv_major != BPF_MAJOR_VERSION ||
bv.bv_minor < BPF_MINOR_VERSION) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"kernel bpf filter out of date");
status = PCAP_ERROR;
goto bad;
@@ -1517,30 +1688,57 @@ pcap_activate_bpf(pcap_t *p)
#if defined(LIFNAMSIZ) && defined(ZONENAME_MAX) && defined(lifr_zoneid)
/*
- * Check if the given source network device has a '/' separated
- * zonename prefix string. The zonename prefixed source device
- * can be used by libpcap consumers to capture network traffic
- * in non-global zones from the global zone on Solaris 11 and
- * above. If the zonename prefix is present then we strip the
- * prefix and pass the zone ID as part of lifr_zoneid.
+ * Retrieve the zoneid of the zone we are currently executing in.
*/
- if ((zonesep = strchr(p->opt.source, '/')) != NULL) {
- char zonename[ZONENAME_MAX];
+ if ((ifr.lifr_zoneid = getzoneid()) == -1) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "getzoneid(): %s",
+ pcap_strerror(errno));
+ status = PCAP_ERROR;
+ goto bad;
+ }
+ /*
+ * Check if the given source datalink name has a '/' separated
+ * zonename prefix string. The zonename prefixed source datalink can
+ * be used by pcap consumers in the Solaris global zone to capture
+ * traffic on datalinks in non-global zones. Non-global zones
+ * do not have access to datalinks outside of their own namespace.
+ */
+ if ((zonesep = strchr(p->opt.device, '/')) != NULL) {
+ char path_zname[ZONENAME_MAX];
int znamelen;
char *lnamep;
- znamelen = zonesep - p->opt.source;
- (void) strlcpy(zonename, p->opt.source, znamelen + 1);
+ if (ifr.lifr_zoneid != GLOBAL_ZONEID) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "zonename/linkname only valid in global zone.");
+ status = PCAP_ERROR;
+ goto bad;
+ }
+ znamelen = zonesep - p->opt.device;
+ (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));
+ status = PCAP_ERROR;
+ goto bad;
+ }
lnamep = strdup(zonesep + 1);
- ifr.lifr_zoneid = getzoneidbyname(zonename);
- free(p->opt.source);
- p->opt.source = lnamep;
+ if (lnamep == NULL) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
+ pcap_strerror(errno));
+ status = PCAP_ERROR;
+ goto bad;
+ }
+ free(p->opt.device);
+ p->opt.device = lnamep;
}
#endif
- p->md.device = strdup(p->opt.source);
- if (p->md.device == NULL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
+ pb->device = strdup(p->opt.device);
+ if (pb->device == NULL) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -1583,7 +1781,7 @@ pcap_activate_bpf(pcap_t *p)
/*
* 10.4 (Darwin 8.x). s/en/wlt/
*/
- if (strncmp(p->opt.source, "en", 2) != 0) {
+ if (strncmp(p->opt.device, "en", 2) != 0) {
/*
* Not an enN device; check
* whether the device even exists.
@@ -1591,7 +1789,7 @@ pcap_activate_bpf(pcap_t *p)
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd != -1) {
strlcpy(ifrname,
- p->opt.source, ifnamsiz);
+ p->opt.device, ifnamsiz);
if (ioctl(sockfd, SIOCGIFFLAGS,
(char *)&ifr) < 0) {
/*
@@ -1602,7 +1800,7 @@ pcap_activate_bpf(pcap_t *p)
* exist.
*/
status = PCAP_ERROR_NO_SUCH_DEVICE;
- snprintf(p->errbuf,
+ pcap_snprintf(p->errbuf,
PCAP_ERRBUF_SIZE,
"SIOCGIFFLAGS failed: %s",
pcap_strerror(errno));
@@ -1616,25 +1814,25 @@ pcap_activate_bpf(pcap_t *p)
* report "no such device".
*/
status = PCAP_ERROR_NO_SUCH_DEVICE;
- snprintf(p->errbuf,
+ pcap_snprintf(p->errbuf,
PCAP_ERRBUF_SIZE,
"socket() failed: %s",
pcap_strerror(errno));
}
goto bad;
}
- wltdev = malloc(strlen(p->opt.source) + 2);
+ wltdev = malloc(strlen(p->opt.device) + 2);
if (wltdev == NULL) {
- (void)snprintf(p->errbuf,
+ (void)pcap_snprintf(p->errbuf,
PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
}
strcpy(wltdev, "wlt");
- strcat(wltdev, p->opt.source + 2);
- free(p->opt.source);
- p->opt.source = wltdev;
+ strcat(wltdev, p->opt.device + 2);
+ free(p->opt.device);
+ p->opt.device = wltdev;
}
/*
* Everything else is 10.5 or later; for those,
@@ -1643,6 +1841,85 @@ pcap_activate_bpf(pcap_t *p)
}
}
#endif /* __APPLE__ */
+
+ /*
+ * If this is FreeBSD, and the device name begins with "usbus",
+ * try to create the interface if it's not available.
+ */
+#if defined(__FreeBSD__) && defined(SIOCIFCREATE2)
+ if (strncmp(p->opt.device, usbus_prefix, USBUS_PREFIX_LEN) == 0) {
+ /*
+ * Do we already have an interface with that name?
+ */
+ if (if_nametoindex(p->opt.device) == 0) {
+ /*
+ * No. We need to create it, and, if we
+ * succeed, remember that we should destroy
+ * it when the pcap_t is closed.
+ */
+ int s;
+
+ /*
+ * Open a socket to use for ioctls to
+ * create the interface.
+ */
+ 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));
+ status = PCAP_ERROR;
+ goto bad;
+ }
+
+ /*
+ * If we haven't already done so, arrange to have
+ * "pcap_close_all()" called when we exit.
+ */
+ if (!pcap_do_addexit(p)) {
+ /*
+ * "atexit()" failed; don't create the
+ * interface, just give up.
+ */
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "atexit failed");
+ close(s);
+ status = PCAP_ERROR;
+ goto bad;
+ }
+
+ /*
+ * Create the interface.
+ */
+ strlcpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) {
+ if (errno == EINVAL) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "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));
+ }
+ close(s);
+ status = PCAP_ERROR;
+ goto bad;
+ }
+
+ /*
+ * Make sure we clean this up when we close.
+ */
+ pb->must_do_on_close |= MUST_DESTROY_USBUS;
+
+ /*
+ * Add this to the list of pcaps to close when we exit.
+ */
+ pcap_add_to_pcaps_to_close(p);
+ }
+ }
+#endif /* defined(__FreeBSD__) && defined(SIOCIFCREATE2) */
+
#ifdef HAVE_ZEROCOPY_BPF
/*
* If the BPF extension to set buffer mode is present, try setting
@@ -1654,7 +1931,7 @@ pcap_activate_bpf(pcap_t *p)
/*
* We have zerocopy BPF; use it.
*/
- p->md.zerocopy = 1;
+ pb->zerocopy = 1;
/*
* How to pick a buffer size: first, query the maximum buffer
@@ -1666,8 +1943,9 @@ pcap_activate_bpf(pcap_t *p)
* size.
*/
if (ioctl(fd, BIOCGETZMAX, (caddr_t)&zbufmax) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGETZMAX: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGETZMAX: %s",
pcap_strerror(errno));
+ status = PCAP_ERROR;
goto bad;
}
@@ -1684,34 +1962,37 @@ pcap_activate_bpf(pcap_t *p)
#ifndef roundup
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
#endif
- p->md.zbufsize = roundup(v, getpagesize());
- if (p->md.zbufsize > zbufmax)
- p->md.zbufsize = zbufmax;
- p->md.zbuf1 = mmap(NULL, p->md.zbufsize, PROT_READ | PROT_WRITE,
+ pb->zbufsize = roundup(v, getpagesize());
+ if (pb->zbufsize > zbufmax)
+ pb->zbufsize = zbufmax;
+ pb->zbuf1 = mmap(NULL, pb->zbufsize, PROT_READ | PROT_WRITE,
MAP_ANON, -1, 0);
- p->md.zbuf2 = mmap(NULL, p->md.zbufsize, PROT_READ | PROT_WRITE,
+ pb->zbuf2 = mmap(NULL, pb->zbufsize, PROT_READ | PROT_WRITE,
MAP_ANON, -1, 0);
- if (p->md.zbuf1 == MAP_FAILED || p->md.zbuf2 == MAP_FAILED) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "mmap: %s",
+ if (pb->zbuf1 == MAP_FAILED || pb->zbuf2 == MAP_FAILED) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "mmap: %s",
pcap_strerror(errno));
+ status = PCAP_ERROR;
goto bad;
}
memset(&bz, 0, sizeof(bz)); /* bzero() deprecated, replaced with memset() */
- bz.bz_bufa = p->md.zbuf1;
- bz.bz_bufb = p->md.zbuf2;
- bz.bz_buflen = p->md.zbufsize;
+ bz.bz_bufa = pb->zbuf1;
+ bz.bz_bufb = pb->zbuf2;
+ bz.bz_buflen = pb->zbufsize;
if (ioctl(fd, BIOCSETZBUF, (caddr_t)&bz) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETZBUF: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETZBUF: %s",
pcap_strerror(errno));
+ status = PCAP_ERROR;
goto bad;
}
- (void)strncpy(ifrname, p->opt.source, ifnamsiz);
+ (void)strncpy(ifrname, p->opt.device, ifnamsiz);
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
- p->opt.source, pcap_strerror(errno));
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
+ p->opt.device, pcap_strerror(errno));
+ status = PCAP_ERROR;
goto bad;
}
- v = p->md.zbufsize - sizeof(struct bpf_zbuf_header);
+ v = pb->zbufsize - sizeof(struct bpf_zbuf_header);
} else
#endif
{
@@ -1725,8 +2006,8 @@ pcap_activate_bpf(pcap_t *p)
*/
if (ioctl(fd, BIOCSBLEN,
(caddr_t)&p->opt.buffer_size) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "BIOCSBLEN: %s: %s", p->opt.source,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "BIOCSBLEN: %s: %s", p->opt.device,
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -1735,7 +2016,7 @@ pcap_activate_bpf(pcap_t *p)
/*
* Now bind to the device.
*/
- (void)strncpy(ifrname, p->opt.source, ifnamsiz);
+ (void)strncpy(ifrname, p->opt.device, ifnamsiz);
#ifdef BIOCSETLIF
if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) < 0)
#else
@@ -1768,7 +2049,7 @@ pcap_activate_bpf(pcap_t *p)
*/
(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
- (void)strncpy(ifrname, p->opt.source, ifnamsiz);
+ (void)strncpy(ifrname, p->opt.device, ifnamsiz);
#ifdef BIOCSETLIF
if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) >= 0)
#else
@@ -1783,9 +2064,9 @@ pcap_activate_bpf(pcap_t *p)
}
if (v == 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSBLEN: %s: No buffer size worked",
- p->opt.source);
+ p->opt.device);
status = PCAP_ERROR;
goto bad;
}
@@ -1795,7 +2076,7 @@ pcap_activate_bpf(pcap_t *p)
/* Get the data link layer type. */
if (ioctl(fd, BIOCGDLT, (caddr_t)&v) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGDLT: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGDLT: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -1828,7 +2109,7 @@ pcap_activate_bpf(pcap_t *p)
/*
* We don't know what to map this to yet.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown interface type %u",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown interface type %u",
v);
status = PCAP_ERROR;
goto bad;
@@ -1916,7 +2197,7 @@ pcap_activate_bpf(pcap_t *p)
* the default mode, attempt to
* select the new mode.
*/
- if (new_dlt != v) {
+ if ((u_int)new_dlt != v) {
if (ioctl(p->fd, BIOCSDLT,
&new_dlt) != -1) {
/*
@@ -1963,11 +2244,12 @@ pcap_activate_bpf(pcap_t *p)
/*
* Try to put the interface into monitor mode.
*/
- status = monitor_mode(p, 1);
- if (status != 0) {
+ retv = monitor_mode(p, 1);
+ if (retv != 0) {
/*
* We failed.
*/
+ status = retv;
goto bad;
}
@@ -1987,7 +2269,7 @@ pcap_activate_bpf(pcap_t *p)
* If the new mode we want isn't the default mode,
* attempt to select the new mode.
*/
- if (new_dlt != v) {
+ if ((u_int)new_dlt != v) {
if (ioctl(p->fd, BIOCSDLT, &new_dlt) != -1) {
/*
* We succeeded; make this the
@@ -2024,8 +2306,8 @@ pcap_activate_bpf(pcap_t *p)
if (v == DLT_FDDI)
p->fddipad = PCAP_FDDIPAD;
else
- p->fddipad = 0;
#endif
+ p->fddipad = 0;
p->linktype = v;
#if defined(BIOCGHDRCMPLT) && defined(BIOCSHDRCMPLT)
@@ -2039,7 +2321,7 @@ pcap_activate_bpf(pcap_t *p)
* BSDs - check CVS log for "bpf.c"?
*/
if (ioctl(fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1) {
- (void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSHDRCMPLT: %s", pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -2047,9 +2329,14 @@ pcap_activate_bpf(pcap_t *p)
#endif
/* set timeout */
#ifdef HAVE_ZEROCOPY_BPF
- if (p->md.timeout != 0 && !p->md.zerocopy) {
+ /*
+ * In zero-copy mode, we just use the timeout in select().
+ * XXX - what if we're in non-blocking mode and the *application*
+ * is using select() or poll() or kqueues or....?
+ */
+ if (p->opt.timeout && !pb->zerocopy) {
#else
- if (p->md.timeout) {
+ if (p->opt.timeout) {
#endif
/*
* XXX - is this seconds/nanoseconds in AIX?
@@ -2073,20 +2360,20 @@ pcap_activate_bpf(pcap_t *p)
struct BPF_TIMEVAL bpf_to;
if (IOCPARM_LEN(BIOCSRTIMEOUT) != sizeof(struct timeval)) {
- bpf_to.tv_sec = p->md.timeout / 1000;
- bpf_to.tv_usec = (p->md.timeout * 1000) % 1000000;
+ 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) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSRTIMEOUT: %s", pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
}
} else {
#endif
- to.tv_sec = p->md.timeout / 1000;
- to.tv_usec = (p->md.timeout * 1000) % 1000000;
+ to.tv_sec = p->opt.timeout / 1000;
+ to.tv_usec = (p->opt.timeout * 1000) % 1000000;
if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"BIOCSRTIMEOUT: %s", pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -2096,7 +2383,6 @@ pcap_activate_bpf(pcap_t *p)
#endif
}
-#ifdef _AIX
#ifdef BIOCIMMEDIATE
/*
* Darren Reed notes that
@@ -2108,74 +2394,71 @@ pcap_activate_bpf(pcap_t *p)
* is reducing things to only a few packets (i.e. one every
* second or so).
*
- * so we turn BIOCIMMEDIATE mode on if this is AIX.
+ * so we always turn BIOCIMMEDIATE mode on if this is AIX.
*
- * We don't turn it on for other platforms, as that means we
- * get woken up for every packet, which may not be what we want;
- * in the Winter 1993 USENIX paper on BPF, they say:
+ * For other platforms, we don't turn immediate mode on by default,
+ * as that would mean we get woken up for every packet, which
+ * probably isn't what you want for a packet sniffer.
*
- * Since a process might want to look at every packet on a
- * network and the time between packets can be only a few
- * microseconds, it is not possible to do a read system call
- * per packet and BPF must collect the data from several
- * packets and return it as a unit when the monitoring
- * application does a read.
- *
- * which I infer is the reason for the timeout - it means we
- * wait that amount of time, in the hopes that more packets
- * will arrive and we'll get them all with one read.
- *
- * Setting BIOCIMMEDIATE mode on FreeBSD (and probably other
- * BSDs) causes the timeout to be ignored.
- *
- * On the other hand, some platforms (e.g., Linux) don't support
- * timeouts, they just hand stuff to you as soon as it arrives;
- * if that doesn't cause a problem on those platforms, it may
- * be OK to have BIOCIMMEDIATE mode on BSD as well.
- *
- * (Note, though, that applications may depend on the read
- * completing, even if no packets have arrived, when the timeout
- * expires, e.g. GUI applications that have to check for input
- * while waiting for packets to arrive; a non-zero timeout
- * prevents "select()" from working right on FreeBSD and
- * possibly other BSDs, as the timer doesn't start until a
- * "read()" is done, so the timer isn't in effect if the
- * application is blocked on a "select()", and the "select()"
- * doesn't get woken up for a BPF device until the buffer
- * fills up.)
+ * We set immediate mode if the caller requested it by calling
+ * pcap_set_immediate() before calling pcap_activate().
*/
- v = 1;
- if (ioctl(p->fd, BIOCIMMEDIATE, &v) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCIMMEDIATE: %s",
- pcap_strerror(errno));
+#ifndef _AIX
+ if (p->opt.immediate) {
+#endif /* _AIX */
+ v = 1;
+ if (ioctl(p->fd, BIOCIMMEDIATE, &v) < 0) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "BIOCIMMEDIATE: %s", pcap_strerror(errno));
+ status = PCAP_ERROR;
+ goto bad;
+ }
+#ifndef _AIX
+ }
+#endif /* _AIX */
+#else /* BIOCIMMEDIATE */
+ if (p->opt.immediate) {
+ /*
+ * We don't support immediate mode. Fail.
+ */
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Immediate mode not supported");
status = PCAP_ERROR;
goto bad;
}
-#endif /* BIOCIMMEDIATE */
-#endif /* _AIX */
+#endif /* BIOCIMMEDIATE */
if (p->opt.promisc) {
/* set promiscuous mode, just warn if it fails */
if (ioctl(p->fd, BIOCPROMISC, NULL) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCPROMISC: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCPROMISC: %s",
pcap_strerror(errno));
status = PCAP_WARNING_PROMISC_NOTSUP;
}
}
+#ifdef BIOCSTSTAMP
+ v = BPF_T_BINTIME;
+ if (ioctl(p->fd, BIOCSTSTAMP, &v) < 0) {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSTSTAMP: %s",
+ pcap_strerror(errno));
+ status = PCAP_ERROR;
+ goto bad;
+ }
+#endif /* BIOCSTSTAMP */
+
if (ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGBLEN: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCGBLEN: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
}
p->bufsize = v;
#ifdef HAVE_ZEROCOPY_BPF
- if (!p->md.zerocopy) {
+ if (!pb->zerocopy) {
#endif
- p->buffer = (u_char *)malloc(p->bufsize);
+ p->buffer = malloc(p->bufsize);
if (p->buffer == NULL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -2206,7 +2489,7 @@ 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) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s",
pcap_strerror(errno));
status = PCAP_ERROR;
goto bad;
@@ -2272,13 +2555,140 @@ pcap_activate_bpf(pcap_t *p)
return (status);
bad:
- pcap_cleanup_bpf(p);
+ pcap_cleanup_bpf(p);
return (status);
}
+/*
+ * Not all interfaces can be bound to by BPF, so try to bind to
+ * the specified interface; return 0 if we fail with
+ * PCAP_ERROR_NO_SUCH_DEVICE (which means we got an ENXIO when we tried
+ * to bind, which means this interface isn't in the list of interfaces
+ * attached to BPF) and 1 otherwise.
+ */
+static int
+check_bpf_bindable(const char *name)
+{
+ int fd;
+ char errbuf[PCAP_ERRBUF_SIZE];
+
+ fd = bpf_open_and_bind(name, errbuf);
+ if (fd < 0) {
+ /*
+ * Error - was it PCAP_ERROR_NO_SUCH_DEVICE?
+ */
+ if (fd == PCAP_ERROR_NO_SUCH_DEVICE) {
+ /*
+ * Yes, so we can't bind to this because it's
+ * not something supported by BPF.
+ */
+ return (0);
+ }
+ /*
+ * No, so we don't know whether it's supported or not;
+ * say it is, so that the user can at least try to
+ * open it and report the error (which is probably
+ * "you don't have permission to open BPF devices";
+ * reporting those interfaces means users will ask
+ * "why am I getting a permissions error when I try
+ * to capture" rather than "why am I not seeing any
+ * interfaces", making the underlying problem clearer).
+ */
+ return (1);
+ }
+
+ /*
+ * Success.
+ */
+ close(fd);
+ return (1);
+}
+
+#if defined(__FreeBSD__) && defined(SIOCIFCREATE2)
+static int
+finddevs_usb(pcap_if_t **alldevsp, char *errbuf)
+{
+ DIR *usbdir;
+ struct dirent *usbitem;
+ size_t name_max;
+ char *name;
+
+ /*
+ * We might have USB sniffing support, so try looking for USB
+ * interfaces.
+ *
+ * We want to report a usbusN device for each USB bus, but
+ * usbusN interfaces might, or might not, exist for them -
+ * we create one if there isn't already one.
+ *
+ * So, instead, we look in /dev/usb for all buses and create
+ * a "usbusN" device for each one.
+ */
+ usbdir = opendir("/dev/usb");
+ if (usbdir == NULL) {
+ /*
+ * Just punt.
+ */
+ return (0);
+ }
+
+ /*
+ * Leave enough room for a 32-bit (10-digit) bus number.
+ * Yes, that's overkill, but we won't be using
+ * the buffer very long.
+ */
+ name_max = USBUS_PREFIX_LEN + 10 + 1;
+ name = malloc(name_max);
+ if (name == NULL) {
+ closedir(usbdir);
+ return (0);
+ }
+ while ((usbitem = readdir(usbdir)) != NULL) {
+ char *p;
+ size_t busnumlen;
+ int err;
+
+ if (strcmp(usbitem->d_name, ".") == 0 ||
+ strcmp(usbitem->d_name, "..") == 0) {
+ /*
+ * Ignore these.
+ */
+ continue;
+ }
+ p = strchr(usbitem->d_name, '.');
+ if (p == NULL)
+ continue;
+ busnumlen = p - usbitem->d_name;
+ 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) {
+ free(name);
+ closedir(usbdir);
+ return (err);
+ }
+ }
+ free(name);
+ closedir(usbdir);
+ return (0);
+}
+#endif
+
int
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
{
+ /*
+ * Get the list of regular interfaces first.
+ */
+ if (pcap_findalldevs_interfaces(alldevsp, errbuf, check_bpf_bindable) == -1)
+ return (-1); /* failure */
+
+#if defined(__FreeBSD__) && defined(SIOCIFCREATE2)
+ if (finddevs_usb(alldevsp, errbuf) == -1)
+ return (-1);
+#endif
+
return (0);
}
@@ -2286,22 +2696,23 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
static int
monitor_mode(pcap_t *p, int set)
{
+ struct pcap_bpf *pb = p->priv;
int sock;
struct ifmediareq req;
- int *media_list;
+ IFM_ULIST_TYPE *media_list;
int i;
int can_do;
struct ifreq ifr;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't open socket: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't open socket: %s",
pcap_strerror(errno));
return (PCAP_ERROR);
}
memset(&req, 0, sizeof req);
- strncpy(req.ifm_name, p->opt.source, sizeof req.ifm_name);
+ strncpy(req.ifm_name, p->opt.device, sizeof req.ifm_name);
/*
* Find out how many media types we have.
@@ -2327,7 +2738,7 @@ monitor_mode(pcap_t *p, int set)
return (PCAP_ERROR_RFMON_NOTSUP);
default:
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"SIOCGIFMEDIA 1: %s", pcap_strerror(errno));
close(sock);
return (PCAP_ERROR);
@@ -2345,16 +2756,16 @@ monitor_mode(pcap_t *p, int set)
* Allocate a buffer to hold all the media types, and
* get the media types.
*/
- media_list = malloc(req.ifm_count * sizeof(int));
+ media_list = malloc(req.ifm_count * sizeof(*media_list));
if (media_list == NULL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
close(sock);
return (PCAP_ERROR);
}
req.ifm_ulist = media_list;
if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA: %s",
pcap_strerror(errno));
free(media_list);
close(sock);
@@ -2407,23 +2818,21 @@ monitor_mode(pcap_t *p, int set)
* "atexit()" failed; don't put the interface
* in monitor mode, just give up.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "atexit failed");
close(sock);
return (PCAP_ERROR);
}
memset(&ifr, 0, sizeof(ifr));
- (void)strncpy(ifr.ifr_name, p->opt.source,
+ (void)strncpy(ifr.ifr_name, p->opt.device,
sizeof(ifr.ifr_name));
ifr.ifr_media = req.ifm_current | IFM_IEEE80211_MONITOR;
if (ioctl(sock, SIOCSIFMEDIA, &ifr) == -1) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"SIOCSIFMEDIA: %s", pcap_strerror(errno));
close(sock);
return (PCAP_ERROR);
}
- p->md.must_do_on_close |= MUST_CLEAR_RFMON;
+ pb->must_do_on_close |= MUST_CLEAR_RFMON;
/*
* Add this to the list of pcaps to close when we exit.
@@ -2450,7 +2859,7 @@ static int
find_802_11(struct bpf_dltlist *bdlp)
{
int new_dlt;
- int i;
+ u_int i;
/*
* Scan the list of DLT_ values, looking for 802.11 values,
@@ -2600,6 +3009,8 @@ remove_802_11(pcap_t *p)
static int
pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp)
{
+ struct pcap_bpf *pb = p->priv;
+
/*
* Free any user-mode filter we might happen to have installed.
*/
@@ -2612,7 +3023,7 @@ pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp)
/*
* It worked.
*/
- p->md.use_bpf = 1; /* filtering in the kernel */
+ pb->filtering_in_kernel = 1; /* filtering in the kernel */
/*
* Discard any previously-received packets, as they might
@@ -2640,7 +3051,7 @@ pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp)
* some kernels.
*/
if (errno != EINVAL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETF: %s",
pcap_strerror(errno));
return (-1);
}
@@ -2652,7 +3063,7 @@ pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp)
*/
if (install_bpf_program(p, fp) < 0)
return (-1);
- p->md.use_bpf = 0; /* filtering in userland */
+ pb->filtering_in_kernel = 0; /* filtering in userland */
return (0);
}
@@ -2669,7 +3080,7 @@ 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) snprintf(p->errbuf, sizeof(p->errbuf),
+ (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"Cannot set direction to %s: %s",
(d == PCAP_D_IN) ? "PCAP_D_IN" :
((d == PCAP_D_OUT) ? "PCAP_D_OUT" : "PCAP_D_INOUT"),
@@ -2684,14 +3095,14 @@ pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d)
* We don't support PCAP_D_OUT.
*/
if (d == PCAP_D_OUT) {
- snprintf(p->errbuf, sizeof(p->errbuf),
+ pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"Setting direction to PCAP_D_OUT is not supported on BPF");
return -1;
}
seesent = (d == PCAP_D_INOUT);
if (ioctl(p->fd, BIOCSSEESENT, &seesent) == -1) {
- (void) snprintf(p->errbuf, sizeof(p->errbuf),
+ (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));
@@ -2699,7 +3110,7 @@ pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d)
}
return (0);
#else
- (void) snprintf(p->errbuf, sizeof(p->errbuf),
+ (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"This system doesn't support BIOCSSEESENT, so the direction can't be set");
return (-1);
#endif
@@ -2710,7 +3121,7 @@ pcap_set_datalink_bpf(pcap_t *p, int dlt)
{
#ifdef BIOCSDLT
if (ioctl(p->fd, BIOCSDLT, &dlt) == -1) {
- (void) snprintf(p->errbuf, sizeof(p->errbuf),
+ (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"Cannot set DLT %d: %s", dlt, strerror(errno));
return (-1);
}
diff --git a/freebsd/contrib/libpcap/pcap-common.c b/freebsd/contrib/libpcap/pcap-common.c
index 729c0006..27fcdcda 100644
--- a/freebsd/contrib/libpcap/pcap-common.c
+++ b/freebsd/contrib/libpcap/pcap-common.c
@@ -27,9 +27,9 @@
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -39,10 +39,14 @@
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include "pcap-int.h"
+#include "extract.h"
+#include "pcap/sll.h"
#include "pcap/usb.h"
+#include "pcap/nflog.h"
+#include "pcap/can_socketcan.h"
#include "pcap-common.h"
@@ -352,7 +356,7 @@
#define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */
#define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
-#define LINKTYPE_GPF_F 171 /* GPF-T (ITU-T G.7041/Y.1303) */
+#define LINKTYPE_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
/*
* Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
@@ -387,7 +391,7 @@
/*
* Juniper-private data link type, as per request from
- * Hannes Gredler <hannes@juniper.net>.
+ * Hannes Gredler <hannes@juniper.net>.
* The Link Types are used for prepending meta-information
* like interface index, interface name
* before standard Ethernet, PPP, Frelay & C-HDLC Frames
@@ -404,7 +408,7 @@
/*
* Juniper-private data link type, as per request from
- * Hannes Gredler <hannes@juniper.net>.
+ * Hannes Gredler <hannes@juniper.net>.
* The DLT_ is used for internal communication with a
* voice Adapter Card (PIC)
*/
@@ -427,10 +431,17 @@
#define LINKTYPE_A653_ICM 185
/*
- * USB packets, beginning with a USB setup header; requested by
- * Paolo Abeni <paolo.abeni@email.it>.
+ * This used to be "USB packets, beginning with a USB setup header;
+ * requested by Paolo Abeni <paolo.abeni@email.it>."
+ *
+ * However, that header didn't work all that well - it left out some
+ * useful information - and was abandoned in favor of the DLT_USB_LINUX
+ * header.
+ *
+ * This is now used by FreeBSD for its BPF taps for USB; that has its
+ * own headers. So it is written, so it is done.
*/
-#define LINKTYPE_USB 186
+#define LINKTYPE_USB_FREEBSD 186
/*
* Bluetooth HCI UART transport layer (part H:4); requested by
@@ -479,7 +490,7 @@
/*
* Juniper-private data link type, as per request from
- * Hannes Gredler <hannes@juniper.net>.
+ * Hannes Gredler <hannes@juniper.net>.
* The DLT_ is used for internal communication with a
* integrated service module (ISM).
*/
@@ -520,7 +531,7 @@
/*
* Juniper-private data link type, as per request from
- * Hannes Gredler <hannes@juniper.net>.
+ * Hannes Gredler <hannes@juniper.net>.
* The DLT_ is used for capturing data on a secure tunnel interface.
*/
#define LINKTYPE_JUNIPER_ST 200
@@ -612,11 +623,11 @@
*/
#define LINKTYPE_IEEE802_15_4_NONASK_PHY 215
-/*
+/*
* David Gibson <david@gibson.dropbear.id.au> requested this for
* captures from the Linux kernel /dev/input/eventN devices. This
* is used to communicate keystrokes and mouse movements from the
- * Linux kernel to display systems, such as Xorg.
+ * Linux kernel to display systems, such as Xorg.
*/
#define LINKTYPE_LINUX_EVDEV 216
@@ -737,8 +748,10 @@
/*
* CAN (Controller Area Network) frames, with a pseudo-header as supplied
- * by Linux SocketCAN. See Documentation/networking/can.txt in the Linux
- * source.
+ * by Linux SocketCAN, and with multi-byte numerical fields in that header
+ * in big-endian byte order.
+ *
+ * See Documentation/networking/can.txt in the Linux source.
*
* Requested by Felix Obenhuber <felix@obenhuber.de>.
*/
@@ -778,7 +791,7 @@
/*
* Juniper-private data link type, as per request from
- * Hannes Gredler <hannes@juniper.net>.
+ * Hannes Gredler <hannes@juniper.net>.
*/
#define LINKTYPE_JUNIPER_VS 232
#define LINKTYPE_JUNIPER_SRX_E2E 233
@@ -810,12 +823,12 @@
/*
* Juniper-private data link type, as per request from
- * Hannes Gredler <hannes@juniper.net>.
+ * Hannes Gredler <hannes@juniper.net>.
*/
#define LINKTYPE_JUNIPER_ATM_CEMIC 238
/*
- * NetFilter LOG messages
+ * NetFilter LOG messages
* (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
*
* Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
@@ -899,7 +912,125 @@
*/
#define LINKTYPE_SCTP 248
-#define LINKTYPE_MATCHING_MAX 248 /* highest value in the "matching" range */
+/*
+ * USB packets, beginning with a USBPcap header.
+ *
+ * Requested by Tomasz Mon <desowin@gmail.com>
+ */
+#define LINKTYPE_USBPCAP 249
+
+/*
+ * Schweitzer Engineering Laboratories "RTAC" product serial-line
+ * packets.
+ *
+ * Requested by Chris Bontje <chris_bontje@selinc.com>.
+ */
+#define DLT_RTAC_SERIAL 250
+
+/*
+ * Bluetooth Low Energy air interface link-layer packets.
+ *
+ * Requested by Mike Kershaw <dragorn@kismetwireless.net>.
+ */
+#define LINKTYPE_BLUETOOTH_LE_LL 251
+
+/*
+ * Link-layer header type for upper-protocol layer PDU saves from wireshark.
+ *
+ * the actual contents are determined by two TAGs stored with each
+ * packet:
+ * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
+ * original packet.
+ *
+ * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
+ * that can make sense of the data stored.
+ */
+#define LINKTYPE_WIRESHARK_UPPER_PDU 252
+
+/*
+ * Link-layer header type for the netlink protocol (nlmon devices).
+ */
+#define LINKTYPE_NETLINK 253
+
+/*
+ * Bluetooth Linux Monitor headers for the BlueZ stack.
+ */
+#define LINKTYPE_BLUETOOTH_LINUX_MONITOR 254
+
+/*
+ * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as
+ * captured by Ubertooth.
+ */
+#define LINKTYPE_BLUETOOTH_BREDR_BB 255
+
+/*
+ * Bluetooth Low Energy link layer packets, as captured by Ubertooth.
+ */
+#define LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR 256
+
+/*
+ * PROFIBUS data link layer.
+ */
+#define LINKTYPE_PROFIBUS_DL 257
+
+/*
+ * Apple's DLT_PKTAP headers.
+ *
+ * Sadly, the folks at Apple either had no clue that the DLT_USERn values
+ * are for internal use within an organization and partners only, and
+ * didn't know that the right way to get a link-layer header type is to
+ * ask tcpdump.org for one, or knew and didn't care, so they just
+ * used DLT_USER2, which causes problems for everything except for
+ * their version of tcpdump.
+ *
+ * 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
+ * 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
+ * between OSes!).
+ */
+#define LINKTYPE_PKTAP 258
+
+/*
+ * Ethernet packets preceded by a header giving the last 6 octets
+ * of the preamble specified by 802.3-2012 Clause 65, section
+ * 65.1.3.2 "Transmit".
+ */
+#define LINKTYPE_EPON 259
+
+/*
+ * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format"
+ * in the PICMG HPM.2 specification.
+ */
+#define LINKTYPE_IPMI_HPM_2 260
+
+/*
+ * per Joshua Wright <jwright@hasborg.com>, formats for Zwave captures.
+ */
+#define LINKTYPE_ZWAVE_R1_R2 261
+#define LINKTYPE_ZWAVE_R3 262
+
+/*
+ * per Steve Karg <skarg@users.sourceforge.net>, formats for Wattstopper
+ * Digital Lighting Management room bus serial protocol captures.
+ */
+#define LINKTYPE_WATTSTOPPER_DLM 263
+
+/*
+ * ISO 14443 contactless smart card messages.
+ */
+#define LINKTYPE_ISO_14443 264
+
+/*
+ * Radio data system (RDS) groups. IEC 62106.
+ * Per Jonathan Brucker <jonathan.brucke@gmail.com>.
+ */
+#define LINKTYPE_RDS 265
+
+#define LINKTYPE_MATCHING_MAX 265 /* highest value in the "matching" range */
static struct linktype_map {
int dlt;
@@ -972,13 +1103,20 @@ dlt_to_linktype(int dlt)
int i;
/*
- * Map DLT_PFSYNC, whatever it might be, to LINKTYPE_PFSYNC.
+ * DLTs that, on some platforms, have values in the matching range
+ * but that *don't* have the same value as the corresponding
+ * LINKTYPE because, for some reason, not all OSes have the
+ * same value for that DLT (note that the DLT's value might be
+ * outside the matching range on some of those OSes).
*/
if (dlt == DLT_PFSYNC)
return (LINKTYPE_PFSYNC);
+ if (dlt == DLT_PKTAP)
+ return (LINKTYPE_PKTAP);
/*
- * Map the values in the matching range.
+ * For all other values in the matching range, the DLT
+ * value is the same as the LINKTYPE value.
*/
if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
return (dlt);
@@ -992,9 +1130,9 @@ dlt_to_linktype(int dlt)
}
/*
- * If we don't have a mapping for this DLT_ code, return an
+ * If we don't have a mapping for this DLT, return an
* error; that means that this is a value with no corresponding
- * LINKTYPE_ code, and we need to assign one.
+ * LINKTYPE, and we need to assign one.
*/
return (-1);
}
@@ -1005,16 +1143,19 @@ linktype_to_dlt(int linktype)
int i;
/*
- * Map LINKTYPE_PFSYNC to DLT_PFSYNC, whatever it might be.
- * LINKTYPE_PFSYNC is in the matching range, to make sure
- * it's as safe from reuse as we can arrange, so we do
- * this test first.
+ * LINKTYPEs in the matching range that *don't*
+ * have the same value as the corresponding DLTs
+ * because, for some reason, not all OSes have the
+ * same value for that DLT.
*/
if (linktype == LINKTYPE_PFSYNC)
return (DLT_PFSYNC);
+ if (linktype == LINKTYPE_PKTAP)
+ return (DLT_PKTAP);
/*
- * Map the values in the matching range.
+ * For all other values in the matching range, the LINKTYPE
+ * value is the same as the DLT value.
*/
if (linktype >= LINKTYPE_MATCHING_MIN &&
linktype <= LINKTYPE_MATCHING_MAX)
@@ -1029,30 +1170,70 @@ linktype_to_dlt(int linktype)
}
/*
- * If we don't have an entry for this link type, return
- * the link type value; it may be a DLT_ value from an
- * older version of libpcap.
+ * If we don't have an entry for this LINKTYPE, return
+ * the link type value; it may be a DLT from an older
+ * version of libpcap.
*/
return linktype;
}
+#define EXTRACT_
+
+/*
+ * DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
+ * LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
+ * with the CAN ID being in host byte order.
+ *
+ * When reading a DLT_LINUX_SLL capture file, we need to check for those
+ * packets and convert the CAN ID from the byte order of the host that
+ * wrote the file to this host's byte order.
+ */
+static void
+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;
+ pcap_can_socketcan_hdr *chdr;
+
+ if (caplen < (u_int) sizeof(struct sll_header) ||
+ length < (u_int) sizeof(struct sll_header)) {
+ /* Not enough data to have the protocol field */
+ return;
+ }
+
+ protocol = EXTRACT_16BITS(&shdr->sll_protocol);
+ if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
+ return;
+
+ /*
+ * SocketCAN packet; fix up the packet's header.
+ */
+ chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header));
+ if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) ||
+ length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) {
+ /* Not enough data to have the CAN ID */
+ return;
+ }
+ chdr->can_id = SWAPLONG(chdr->can_id);
+}
+
/*
* The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
* byte order when capturing (it's supplied directly from a
* memory-mapped buffer shared by the kernel).
*
* When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
- * we need to convert it from the capturing host's byte order to
- * the reading host's byte order.
+ * we need to convert it from the byte order of the host that wrote
+ * the file to this host's byte order.
*/
-void
+static void
swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
int header_len_64_bytes)
{
pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
bpf_u_int32 offset = 0;
- usb_isodesc *pisodesc;
- int32_t numdesc, i;
/*
* "offset" is the offset *past* the field we're swapping;
@@ -1061,7 +1242,7 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
*/
/*
- * The URB id is a totally opaque value; do we really need to
+ * The URB id is a totally opaque value; do we really need to
* convert it to the reading host's byte order???
*/
offset += 8; /* skip past id */
@@ -1116,6 +1297,17 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
} else
offset += 8; /* skip USB setup header */
+ /*
+ * With the old header, there are no isochronous descriptors
+ * after the header.
+ *
+ * With the new header, the actual number of descriptors in
+ * the header is not s.iso.numdesc, it's ndesc - only the
+ * first N descriptors, for some value of N, are put into
+ * the header, and ndesc is set to the actual number copied.
+ * In addition, if s.iso.numdesc is negative, no descriptors
+ * are captured, and ndesc is set to 0.
+ */
if (header_len_64_bytes) {
/*
* This is either the "version 1" header, with
@@ -1144,31 +1336,128 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
if (hdr->caplen < offset)
return;
uhdr->ndesc = SWAPLONG(uhdr->ndesc);
- }
- if (uhdr->transfer_type == URB_ISOCHRONOUS) {
- /* swap the values in struct linux_usb_isodesc */
- pisodesc = (usb_isodesc *)(void *)(buf+offset);
- numdesc = uhdr->s.iso.numdesc;
- for (i = 0; i < numdesc; i++) {
- offset += 4; /* skip past status */
- if (hdr->caplen < offset)
- return;
- pisodesc->status = SWAPLONG(pisodesc->status);
-
- offset += 4; /* skip past offset */
- if (hdr->caplen < offset)
- return;
- pisodesc->offset = SWAPLONG(pisodesc->offset);
-
- offset += 4; /* skip past len */
- if (hdr->caplen < offset)
- return;
- pisodesc->len = SWAPLONG(pisodesc->len);
-
- offset += 4; /* skip past padding */
-
- pisodesc++;
+ if (uhdr->transfer_type == URB_ISOCHRONOUS) {
+ /* swap the values in struct linux_usb_isodesc */
+ usb_isodesc *pisodesc;
+ u_int32_t i;
+
+ pisodesc = (usb_isodesc *)(void *)(buf+offset);
+ for (i = 0; i < uhdr->ndesc; i++) {
+ offset += 4; /* skip past status */
+ if (hdr->caplen < offset)
+ return;
+ pisodesc->status = SWAPLONG(pisodesc->status);
+
+ offset += 4; /* skip past offset */
+ if (hdr->caplen < offset)
+ return;
+ pisodesc->offset = SWAPLONG(pisodesc->offset);
+
+ offset += 4; /* skip past len */
+ if (hdr->caplen < offset)
+ return;
+ pisodesc->len = SWAPLONG(pisodesc->len);
+
+ offset += 4; /* skip past padding */
+
+ pisodesc++;
+ }
}
}
}
+
+/*
+ * The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order
+ * data. They begin with a fixed-length header with big-endian fields,
+ * followed by a set of TLVs, where the type and length are in host
+ * byte order but the values are either big-endian or are a raw byte
+ * sequence that's the same regardless of the host's byte order.
+ *
+ * When reading a DLT_NFLOG capture file, we need to convert the type
+ * and length values from the byte order of the host that wrote the
+ * file to the byte order of this host.
+ */
+static void
+swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
+{
+ u_char *p = buf;
+ nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf;
+ nflog_tlv_t *tlv;
+ u_int caplen = hdr->caplen;
+ u_int length = hdr->len;
+ u_int16_t size;
+
+ if (caplen < (u_int) sizeof(nflog_hdr_t) ||
+ length < (u_int) sizeof(nflog_hdr_t)) {
+ /* Not enough data to have any TLVs. */
+ return;
+ }
+
+ if (nfhdr->nflog_version != 0) {
+ /* Unknown NFLOG version */
+ return;
+ }
+
+ length -= sizeof(nflog_hdr_t);
+ caplen -= sizeof(nflog_hdr_t);
+ p += sizeof(nflog_hdr_t);
+
+ while (caplen >= sizeof(nflog_tlv_t)) {
+ tlv = (nflog_tlv_t *) p;
+
+ /* Swap the type and length. */
+ tlv->tlv_type = SWAPSHORT(tlv->tlv_type);
+ tlv->tlv_length = SWAPSHORT(tlv->tlv_length);
+
+ /* Get the length of the TLV. */
+ size = tlv->tlv_length;
+ if (size % 4 != 0)
+ size += 4 - size % 4;
+
+ /* Is the TLV's length less than the minimum? */
+ if (size < sizeof(nflog_tlv_t)) {
+ /* Yes. Give up now. */
+ return;
+ }
+
+ /* Do we have enough data for the full TLV? */
+ if (caplen < size || length < size) {
+ /* No. */
+ return;
+ }
+
+ /* Skip over the TLV. */
+ length -= size;
+ caplen -= size;
+ p += size;
+ }
+}
+
+void
+swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data)
+{
+ /*
+ * Convert pseudo-headers from the byte order of
+ * the host on which the file was saved to our
+ * byte order, as necessary.
+ */
+ switch (linktype) {
+
+ case DLT_LINUX_SLL:
+ swap_linux_sll_header(hdr, data);
+ break;
+
+ case DLT_USB_LINUX:
+ swap_linux_usb_header(hdr, data, 0);
+ break;
+
+ case DLT_USB_LINUX_MMAPPED:
+ swap_linux_usb_header(hdr, data, 1);
+ break;
+
+ case DLT_NFLOG:
+ swap_nflog_header(hdr, data);
+ break;
+ }
+}
diff --git a/freebsd/contrib/libpcap/pcap-common.h b/freebsd/contrib/libpcap/pcap-common.h
index 0c80ba32..6ac5bcd2 100644
--- a/freebsd/contrib/libpcap/pcap-common.h
+++ b/freebsd/contrib/libpcap/pcap-common.h
@@ -21,5 +21,5 @@ extern int dlt_to_linktype(int dlt);
extern int linktype_to_dlt(int linktype);
-extern void swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
- int header_len_64_bytes);
+extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr,
+ u_char *data);
diff --git a/freebsd/contrib/libpcap/pcap-int.h b/freebsd/contrib/libpcap/pcap-int.h
index b3ce82d6..7db7ff5e 100644
--- a/freebsd/contrib/libpcap/pcap-int.h
+++ b/freebsd/contrib/libpcap/pcap-int.h
@@ -29,8 +29,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.94 2008-09-16 00:20:23 guy Exp $ (LBL)
*/
#ifndef pcap_int_h
@@ -42,22 +40,16 @@
extern "C" {
#endif
-#ifdef HAVE_LIBDLPI
-#include <libdlpi.h>
-#endif
-
-#ifdef WIN32
-#include <Packet32.h>
-extern CRITICAL_SECTION g_PcapCompileCriticalSection;
-#endif /* WIN32 */
-
-#ifdef MSDOS
-#include <fcntl.h>
-#include <io.h>
-#endif
-
-#ifdef HAVE_SNF_API
-#include <snf.h>
+#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)
+ #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*/
@@ -93,139 +85,39 @@ extern CRITICAL_SECTION g_PcapCompileCriticalSection;
#endif /* _MSC_VER */
/*
- * Savefile
- */
-typedef enum {
- NOT_SWAPPED,
- SWAPPED,
- MAYBE_SWAPPED
-} swapped_type_t;
-
-/*
- * Used when reading a savefile.
- */
-struct pcap_sf {
- FILE *rfile;
- int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
- int swapped;
- size_t hdrsize;
- swapped_type_t lengths_swapped;
- int version_major;
- int version_minor;
- bpf_u_int32 ifcount; /* number of interfaces seen in this capture */
- u_int tsresol; /* time stamp resolution */
- u_int tsscale; /* scaling factor for resolution -> microseconds */
- u_int64_t tsoffset; /* time stamp offset */
-};
-
-/*
- * Used when doing a live capture.
- */
-struct pcap_md {
- struct pcap_stat stat;
- /*XXX*/
- int use_bpf; /* using kernel filter */
- u_long TotPkts; /* can't oflow for 79 hrs on ether */
- u_long TotAccepted; /* count accepted by filter */
- u_long TotDrops; /* count of dropped packets */
- long TotMissed; /* missed by i/f during this run */
- long OrigMissed; /* missed by i/f before this run */
- char *device; /* device name */
- int timeout; /* timeout for buffering */
- int must_do_on_close; /* stuff we must do when we close */
- struct pcap *next; /* list of open pcaps that need stuff cleared on close */
-#ifdef linux
- int sock_packet; /* using Linux 2.0 compatible interface */
- int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
- int ifindex; /* interface index of device we're bound to */
- int lo_ifindex; /* interface index of the loopback device */
- u_int packets_read; /* count of packets read with recvfrom() */
- bpf_u_int32 oldmode; /* mode to restore when turning monitor mode off */
- char *mondevice; /* mac80211 monitor device we created */
- u_char *mmapbuf; /* memory-mapped region pointer */
- size_t mmapbuflen; /* size of region */
- int vlan_offset; /* offset at which to insert vlan tags; if -1, don't insert */
- u_int tp_version; /* version of tpacket_hdr for mmaped ring */
- u_int tp_hdrlen; /* hdrlen of tpacket_hdr for mmaped ring */
- u_char *oneshot_buffer; /* buffer for copy of packet */
- long proc_dropped; /* packets reported dropped by /proc/net/dev */
-#endif /* linux */
-
-#ifdef HAVE_DAG_API
-#ifdef HAVE_DAG_STREAMS_API
- u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */
- u_char *dag_mem_top; /* DAG card current memory top pointer */
-#else /* HAVE_DAG_STREAMS_API */
- void *dag_mem_base; /* DAG card memory base address */
- u_int dag_mem_bottom; /* DAG card current memory bottom offset */
- u_int dag_mem_top; /* DAG card current memory top offset */
-#endif /* HAVE_DAG_STREAMS_API */
- int dag_fcs_bits; /* Number of checksum bits from link layer */
- int dag_offset_flags; /* Flags to pass to dag_offset(). */
- int dag_stream; /* DAG stream number */
- int dag_timeout; /* timeout specified to pcap_open_live.
- * Same as in linux above, introduce
- * generally? */
-#endif /* HAVE_DAG_API */
-#ifdef HAVE_SNF_API
- snf_handle_t snf_handle; /* opaque device handle */
- snf_ring_t snf_ring; /* opaque device ring handle */
- int snf_timeout;
- int snf_boardnum;
-#endif /*HAVE_SNF_API*/
-
-#ifdef HAVE_ZEROCOPY_BPF
- /*
- * Zero-copy read buffer -- for zero-copy BPF. 'buffer' above will
- * alternative between these two actual mmap'd buffers as required.
- * As there is a header on the front size of the mmap'd buffer, only
- * some of the buffer is exposed to libpcap as a whole via bufsize;
- * zbufsize is the true size. zbuffer tracks the current zbuf
- * assocated with buffer so that it can be used to decide which the
- * next buffer to read will be.
- */
- u_char *zbuf1, *zbuf2, *zbuffer;
- u_int zbufsize;
- u_int zerocopy;
- u_int interrupted;
- struct timespec firstsel;
- /*
- * If there's currently a buffer being actively processed, then it is
- * referenced here; 'buffer' is also pointed at it, but offset by the
- * size of the header.
- */
- struct bpf_zbuf_header *bzh;
-#endif /* HAVE_ZEROCOPY_BPF */
-};
-
-/*
- * Stuff to do when we close.
+ * Maximum snapshot length.
+ *
+ * Somewhat arbitrary, but chosen to be:
+ *
+ * 1) big enough for maximum-size Linux loopback packets (65549)
+ * and some USB packets captured with USBPcap:
+ *
+ * http://desowin.org/usbpcap/
+ *
+ * (> 131072, < 262144)
+ *
+ * and
+ *
+ * 2) small enough not to cause attempts to allocate huge amounts of
+ * memory; some applications might use the snapshot length in a
+ * savefile header to control the size of the buffer they allocate,
+ * so a size of, say, 2^31-1 might not work well.
+ *
+ * We don't enforce this in pcap_set_snaplen(), but we use it internally.
*/
-#define MUST_CLEAR_PROMISC 0x00000001 /* clear promiscuous mode */
-#define MUST_CLEAR_RFMON 0x00000002 /* clear rfmon (monitor) mode */
-#define MUST_DELETE_MONIF 0x00000004 /* delete monitor-mode interface */
+#define MAXIMUM_SNAPLEN 262144
struct pcap_opt {
- int buffer_size;
- char *source;
+ char *device;
+ int timeout; /* timeout for buffering */
+ u_int buffer_size;
int promisc;
- int rfmon;
+ int rfmon; /* monitor mode */
+ int immediate; /* immediate mode - deliver packets as soon as they arrive */
int tstamp_type;
+ int tstamp_precision;
};
-/*
- * Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H
- * Tru64 UNIX, and some versions of NetBSD pad FDDI packets to make everything
- * line up on a nice boundary.
- */
-#ifdef __NetBSD__
-#include <sys/param.h> /* needed to declare __NetBSD_Version__ */
-#endif
-
-#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
-#define PCAP_FDDIPAD 3
-#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 *);
@@ -236,27 +128,70 @@ 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 (*stats_op_t)(pcap_t *, struct pcap_stat *);
-#ifdef WIN32
+#ifdef _WIN32
+typedef struct pcap_stat *(*stats_ex_op_t)(pcap_t *, int *);
typedef int (*setbuff_op_t)(pcap_t *, int);
typedef int (*setmode_op_t)(pcap_t *, int);
typedef int (*setmintocopy_op_t)(pcap_t *, int);
+typedef HANDLE (*getevent_op_t)(pcap_t *);
+typedef int (*oid_get_request_op_t)(pcap_t *, bpf_u_int32, void *, size_t *);
+typedef int (*oid_set_request_op_t)(pcap_t *, bpf_u_int32, const void *, size_t *);
+typedef u_int (*sendqueue_transmit_op_t)(pcap_t *, pcap_send_queue *, int);
+typedef int (*setuserbuffer_op_t)(pcap_t *, int);
+typedef int (*live_dump_op_t)(pcap_t *, char *, int, int);
+typedef int (*live_dump_ended_op_t)(pcap_t *, int);
+typedef PAirpcapHandle (*get_airpcap_handle_op_t)(pcap_t *);
#endif
typedef void (*cleanup_op_t)(pcap_t *);
+/*
+ * We put all the stuff used in the read code path at the beginning,
+ * to try to keep it together in the same cache line or lines.
+ */
struct pcap {
-#ifdef WIN32
+ /*
+ * Method to call to read packets on a live capture.
+ */
+ read_op_t read_op;
+
+ /*
+ * Method to call to read packets from a savefile.
+ */
+ int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
+
+#ifdef _WIN32
ADAPTER *adapter;
- LPPACKET Packet;
- int nonblock;
#else
int fd;
int selectable_fd;
- int send_fd;
-#endif /* WIN32 */
+#endif /* _WIN32 */
+
+ /*
+ * Read buffer.
+ */
+ u_int bufsize;
+ void *buffer;
+ u_char *bp;
+ int cc;
+
+ int break_loop; /* flag set to force break from packet-reading loop */
+
+ void *priv; /* private data for methods */
+
+ int swapped;
+ FILE *rfile; /* null if live capture, non-null if savefile */
+ u_int fddipad;
+ struct pcap *next; /* list of open pcaps that need stuff cleared on close */
+
+ /*
+ * File version number; meaningful only for a savefile, but we
+ * keep it here so that apps that (mistakenly) ask for the
+ * version numbers will get the same zero values that they
+ * always did.
+ */
+ int version_major;
+ int version_minor;
-#ifdef HAVE_LIBDLPI
- dlpi_handle_t dlpi_hd;
-#endif
int snapshot;
int linktype; /* Network linktype */
int linktype_ext; /* Extended information stored in the linktype field of a file */
@@ -265,42 +200,45 @@ struct pcap {
int activated; /* true if the capture is really started */
int oldstyle; /* if we're opening with pcap_open_live() */
- int break_loop; /* flag set to force break from packet-reading loop */
+ struct pcap_opt opt;
-#ifdef PCAP_FDDIPAD
- int fddipad;
-#endif
+ /*
+ * Place holder for pcap_next().
+ */
+ u_char *pkt;
-#ifdef MSDOS
- void (*wait_proc)(void); /* call proc while waiting */
+#ifdef _WIN32
+ struct pcap_stat stat; /* used for pcap_stats_ex() */
#endif
- struct pcap_sf sf;
- struct pcap_md md;
- struct pcap_opt opt;
+ /* We're accepting only packets in this direction/these directions. */
+ pcap_direction_t direction;
/*
- * Read buffer.
+ * Flags to affect BPF code generation.
*/
- int bufsize;
- u_char *buffer;
- u_char *bp;
- int cc;
+ int bpf_codegen_flags;
/*
- * Place holder for pcap_next().
+ * Placeholder for filter code if bpf not in kernel.
*/
- u_char *pkt;
+ struct bpf_program fcode;
- /* We're accepting only packets in this direction/these directions. */
- pcap_direction_t direction;
+ char errbuf[PCAP_ERRBUF_SIZE + 1];
+ int dlt_count;
+ u_int *dlt_list;
+ int tstamp_type_count;
+ u_int *tstamp_type_list;
+ int tstamp_precision_count;
+ u_int *tstamp_precision_list;
+
+ struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
/*
- * Methods.
+ * More methods.
*/
activate_op_t activate_op;
can_set_rfmon_op_t can_set_rfmon_op;
- read_op_t read_op;
inject_op_t inject_op;
setfilter_op_t setfilter_op;
setdirection_op_t setdirection_op;
@@ -314,32 +252,33 @@ struct pcap {
*/
pcap_handler oneshot_callback;
-#ifdef WIN32
+#ifdef _WIN32
/*
* These are, at least currently, specific to the Win32 NPF
* driver.
*/
+ stats_ex_op_t stats_ex_op;
setbuff_op_t setbuff_op;
setmode_op_t setmode_op;
setmintocopy_op_t setmintocopy_op;
+ getevent_op_t getevent_op;
+ oid_get_request_op_t oid_get_request_op;
+ oid_set_request_op_t oid_set_request_op;
+ sendqueue_transmit_op_t sendqueue_transmit_op;
+ setuserbuffer_op_t setuserbuffer_op;
+ live_dump_op_t live_dump_op;
+ live_dump_ended_op_t live_dump_ended_op;
+ get_airpcap_handle_op_t get_airpcap_handle_op;
#endif
cleanup_op_t cleanup_op;
-
- /*
- * Placeholder for filter code if bpf not in kernel.
- */
- struct bpf_program fcode;
-
- char errbuf[PCAP_ERRBUF_SIZE + 1];
- int dlt_count;
- u_int *dlt_list;
- int tstamp_type_count;
- u_int *tstamp_type_list;
-
- struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
};
/*
+ * BPF code generation flags.
+ */
+#define BPF_SPECIAL_VLAN_HANDLING 0x00000001 /* special VLAN handling for Linux */
+
+/*
* This is a timeval as stored in a savefile.
* It has to use the same types everywhere, independent of the actual
* `struct timeval'; `struct timeval' has 32-bit tv_sec values on some
@@ -377,7 +316,7 @@ struct pcap_timeval {
*
* Then supply the changes by forking the branch at
*
- * https://github.com/mcr/libpcap/issues
+ * https://github.com/the-tcpdump-group/libpcap/issues
*
* and issuing a pull request, so that future versions of libpcap and
* programs that use it (such as tcpdump) will be able to read your new
@@ -419,39 +358,26 @@ struct oneshot_userdata {
pcap_t *pd;
};
-int yylex(void);
-
#ifndef min
#define min(a, b) ((a) > (b) ? (b) : (a))
#endif
-/* XXX should these be in pcap.h? */
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
-int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
-
-#ifndef HAVE_STRLCPY
-#define strlcpy(x, y, z) \
- (strncpy((x), (y), (z)), \
- ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
- strlen((y)))
-#endif
#include <stdarg.h>
-#if !defined(HAVE_SNPRINTF)
-#define snprintf pcap_snprintf
-extern int snprintf (char *, size_t, const char *, ...);
-#endif
+#include "portability.h"
-#if !defined(HAVE_VSNPRINTF)
-#define vsnprintf pcap_vsnprintf
-extern int vsnprintf (char *, size_t, const char *, va_list ap);
-#endif
+/*
+ * Does the packet count argument to a module's read routine say
+ * "supply packets until you run out of packets"?
+ */
+#define PACKET_COUNT_IS_UNLIMITED(count) ((count) <= 0)
/*
* Routines that most pcap implementations can use for non-blocking mode.
*/
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
int pcap_getnonblock_fd(pcap_t *, char *);
int pcap_setnonblock_fd(pcap_t *p, int, char *);
#endif
@@ -468,38 +394,68 @@ int pcap_setnonblock_fd(pcap_t *p, int, char *);
* by pcap_create routines.
*/
pcap_t *pcap_create_interface(const char *, char *);
-pcap_t *pcap_create_common(const char *, char *);
+pcap_t *pcap_create_common(char *, size_t);
int pcap_do_addexit(pcap_t *);
void pcap_add_to_pcaps_to_close(pcap_t *);
void pcap_remove_from_pcaps_to_close(pcap_t *);
void pcap_cleanup_live_common(pcap_t *);
-int pcap_not_initialized(pcap_t *);
int pcap_check_activated(pcap_t *);
/*
* Internal interfaces for "pcap_findalldevs()".
*
- * "pcap_findalldevs_interfaces()" finds interfaces using the
- * "standard" mechanisms (SIOCGIFCONF, "getifaddrs()", etc.).
- *
* "pcap_platform_finddevs()" is a platform-dependent routine to
- * add devices not found by the "standard" mechanisms.
+ * 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.
*/
-int pcap_findalldevs_interfaces(pcap_if_t **, char *);
int pcap_platform_finddevs(pcap_if_t **, char *);
-int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *,
- size_t, struct sockaddr *, size_t, struct sockaddr *, size_t,
- struct sockaddr *, size_t, char *);
-int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *);
-struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
-int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
+#if !defined(_WIN32) && !defined(MSDOS)
+int pcap_findalldevs_interfaces(pcap_if_t **, char *,
+ int (*)(const char *));
+#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 *);
+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);
+#endif
+
+/*
+ * Internal interfaces for "pcap_open_offline()".
+ *
+ * "pcap_open_offline_common()" allocates and fills in a pcap_t, for use
+ * by pcap_open_offline routines.
+ *
+ * "sf_cleanup()" closes the file handle associated with a pcap_t, if
+ * appropriate, and frees all data common to all modules for handling
+ * savefile types.
+ */
+pcap_t *pcap_open_offline_common(char *ebuf, size_t size);
+void sf_cleanup(pcap_t *p);
+
+/*
+ * Internal interfaces for both "pcap_create()" and routines that
+ * open savefiles.
+ *
+ * "pcap_oneshot()" is the standard one-shot callback for "pcap_next()"
+ * and "pcap_next_ex()".
+ */
+void pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *);
-#ifdef WIN32
-char *pcap_win32strerror(void);
+#ifdef _WIN32
+void pcap_win32_err_to_str(DWORD, char *);
#endif
int install_bpf_program(pcap_t *, struct bpf_program *);
diff --git a/freebsd/contrib/libpcap/pcap-namedb.h b/freebsd/contrib/libpcap/pcap-namedb.h
index d0b22310..d5908c92 100644
--- a/freebsd/contrib/libpcap/pcap-namedb.h
+++ b/freebsd/contrib/libpcap/pcap-namedb.h
@@ -29,8 +29,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.13 2006-10-04 18:13:32 guy Exp $ (LBL)
*/
/*
diff --git a/freebsd/contrib/libpcap/pcap.c b/freebsd/contrib/libpcap/pcap.c
index e2991fb3..c7e7d02e 100644
--- a/freebsd/contrib/libpcap/pcap.c
+++ b/freebsd/contrib/libpcap/pcap.c
@@ -33,20 +33,13 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.128 2008-12-23 20:13:29 guy Exp $ (LBL)";
-#endif
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -57,7 +50,7 @@ static const char rcsid[] _U_ =
#endif
#include <sys/types.h>
#include <sys/mman.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <stdio.h>
#include <stdlib.h>
@@ -90,6 +83,10 @@ static const char rcsid[] _U_ =
#include "pcap-snf.h"
#endif /* HAVE_SNF_API */
+#ifdef HAVE_TC_API
+#include "pcap-tc.h"
+#endif /* HAVE_TC_API */
+
#ifdef PCAP_SUPPORT_USB
#include "pcap-usb-linux.h"
#endif
@@ -98,25 +95,66 @@ static const char rcsid[] _U_ =
#include "pcap-bt-linux.h"
#endif
-#ifdef PCAP_SUPPORT_CAN
-#include "pcap-can-linux.h"
-#endif
-
-#ifdef PCAP_SUPPORT_CANUSB
-#include "pcap-canusb-linux.h"
+#ifdef PCAP_SUPPORT_BT_MONITOR
+#include "pcap-bt-monitor-linux.h"
#endif
#ifdef PCAP_SUPPORT_NETFILTER
#include "pcap-netfilter-linux.h"
#endif
-int
+#ifdef PCAP_SUPPORT_NETMAP
+pcap_t* pcap_netmap_create(const char *device, char *ebuf, int *is_ours);
+#endif
+
+#ifdef PCAP_SUPPORT_DBUS
+#include "pcap-dbus.h"
+#endif
+
+static int
pcap_not_initialized(pcap_t *pcap)
{
+ /* 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");
/* this means 'not initialized' */
return (PCAP_ERROR_NOT_ACTIVATED);
}
+#ifdef _WIN32
+static void *
+pcap_not_initialized_ptr(pcap_t *pcap)
+{
+ (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
+ "This handle hasn't been activated yet");
+ return (NULL);
+}
+
+static HANDLE
+pcap_getevent_not_initialized(pcap_t *pcap)
+{
+ (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
+ "This handle hasn't been activated yet");
+ return (INVALID_HANDLE_VALUE);
+}
+
+static u_int
+pcap_sendqueue_transmit_not_initialized(pcap_t *pcap, pcap_send_queue* queue, int sync)
+{
+ (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
+ "This handle hasn't been activated yet");
+ return (0);
+}
+
+static PAirpcapHandle
+pcap_get_airpcap_handle_not_initialized(pcap_t *pcap)
+{
+ (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
+ "This handle hasn't been activated yet");
+ return (NULL);
+}
+#endif
+
/*
* Returns 1 if rfmon mode can be set on the pcap_t, 0 if it can't,
* a PCAP_ERROR value on an error.
@@ -159,7 +197,7 @@ 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)snprintf(p->errbuf, sizeof(p->errbuf),
+ (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"malloc: %s", pcap_strerror(errno));
return (PCAP_ERROR);
}
@@ -191,7 +229,7 @@ pcap_free_tstamp_types(int *tstamp_type_list)
* packet data cannot be guaranteed to be available after the callback
* returns, so that a copy must be made.
*/
-static void
+void
pcap_oneshot(u_char *user, const struct pcap_pkthdr *h, const u_char *pkt)
{
struct oneshot_userdata *sp = (struct oneshot_userdata *)user;
@@ -227,7 +265,7 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
/* Saves a pointer to the packet headers */
*pkt_header= &p->pcap_header;
- if (p->sf.rfile != NULL) {
+ if (p->rfile != NULL) {
int status;
/* We are on an offline capture */
@@ -264,47 +302,13 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
return (p->read_op(p, 1, p->oneshot_callback, (u_char *)&s));
}
-#if defined(DAG_ONLY)
-int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
-{
- return (dag_findalldevs(alldevsp, errbuf));
-}
-
-pcap_t *
-pcap_create(const char *source, char *errbuf)
-{
- return (dag_create(source, errbuf));
-}
-#elif defined(SEPTEL_ONLY)
-int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
-{
- return (septel_findalldevs(alldevsp, errbuf));
-}
-
-pcap_t *
-pcap_create(const char *source, char *errbuf)
-{
- return (septel_create(source, errbuf));
-}
-#elif defined(SNF_ONLY)
-int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
-{
- return (snf_findalldevs(alldevsp, errbuf));
-}
-
-pcap_t *
-pcap_create(const char *source, char *errbuf)
-{
- return (snf_create(source, errbuf));
-}
-#else /* regular pcap */
-struct capture_source_type {
+static struct capture_source_type {
int (*findalldevs_op)(pcap_if_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
@@ -314,14 +318,14 @@ struct capture_source_type {
#ifdef HAVE_SNF_API
{ snf_findalldevs, snf_create },
#endif
+#ifdef HAVE_TC_API
+ { TcFindAllDevs, TcCreate },
+#endif
#ifdef PCAP_SUPPORT_BT
{ bt_findalldevs, bt_create },
#endif
-#if PCAP_SUPPORT_CANUSB
- { canusb_findalldevs, canusb_create },
-#endif
-#ifdef PCAP_SUPPORT_CAN
- { can_findalldevs, can_create },
+#ifdef PCAP_SUPPORT_BT_MONITOR
+ { bt_monitor_findalldevs, bt_monitor_create },
#endif
#ifdef PCAP_SUPPORT_USB
{ usb_findalldevs, usb_create },
@@ -329,6 +333,9 @@ struct capture_source_type {
#ifdef PCAP_SUPPORT_NETFILTER
{ netfilter_findalldevs, netfilter_create },
#endif
+#ifdef PCAP_SUPPORT_DBUS
+ { dbus_findalldevs, dbus_create },
+#endif
{ NULL, NULL }
};
@@ -344,26 +351,11 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
size_t i;
/*
- * Get the list of regular interfaces first.
+ * Find all the local network interfaces on which we
+ * can capture.
*/
- if (pcap_findalldevs_interfaces(alldevsp, errbuf) == -1)
- return (-1); /* failure */
-
- /*
- * Add any interfaces that need a platform-specific mechanism
- * to find.
- */
- if (pcap_platform_finddevs(alldevsp, errbuf) == -1) {
- /*
- * We had an error; free the list we've been
- * constructing.
- */
- if (*alldevsp != NULL) {
- pcap_freealldevs(*alldevsp);
- *alldevsp = NULL;
- }
+ if (pcap_platform_finddevs(alldevsp, errbuf) == -1)
return (-1);
- }
/*
* Ask each of the non-local-network-interface capture
@@ -382,25 +374,58 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
return (-1);
}
}
+
return (0);
}
pcap_t *
-pcap_create(const char *source, char *errbuf)
+pcap_create(const char *device, char *errbuf)
{
size_t i;
int is_theirs;
pcap_t *p;
+ char *device_str;
/*
- * A null source name is equivalent to the "any" device -
+ * A null device name is equivalent to the "any" device -
* which might not be supported on this platform, but
* this means that you'll get a "not supported" error
* rather than, say, a crash when we try to dereference
* the null pointer.
*/
- if (source == NULL)
- source = "any";
+ if (device == NULL)
+ device_str = strdup("any");
+ else {
+#ifdef _WIN32
+ /*
+ * If the string appears to be little-endian UCS-2/UTF-16,
+ * convert it to ASCII.
+ *
+ * XXX - to UTF-8 instead? Or report an error if any
+ * character isn't ASCII?
+ */
+ if (device[0] != '\0' && device[1] == '\0') {
+ size_t length;
+
+ 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));
+ return (NULL);
+ }
+
+ pcap_snprintf(device_str, length + 1, "%ws",
+ (const wchar_t *)device);
+ } else
+#endif
+ device_str = strdup(device);
+ }
+ if (device_str == NULL) {
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "malloc: %s", pcap_strerror(errno));
+ return (NULL);
+ }
/*
* Try each of the non-local-network-interface capture
@@ -409,7 +434,8 @@ pcap_create(const char *source, char *errbuf)
*/
for (i = 0; capture_source_types[i].create_op != NULL; i++) {
is_theirs = 0;
- p = capture_source_types[i].create_op(source, errbuf, &is_theirs);
+ p = capture_source_types[i].create_op(device_str, errbuf,
+ &is_theirs);
if (is_theirs) {
/*
* The device name refers to a device of the
@@ -420,6 +446,14 @@ pcap_create(const char *source, char *errbuf)
* should return that to report the failure
* to create.
*/
+ if (p == NULL) {
+ /*
+ * We assume the caller filled in errbuf.
+ */
+ free(device_str);
+ return (NULL);
+ }
+ p->opt.device = device_str;
return (p);
}
}
@@ -427,9 +461,17 @@ pcap_create(const char *source, char *errbuf)
/*
* OK, try it as a regular network interface.
*/
- return (pcap_create_interface(source, errbuf));
+ p = pcap_create_interface(device_str, errbuf);
+ if (p == NULL) {
+ /*
+ * We assume the caller filled in errbuf.
+ */
+ free(device_str);
+ return (NULL);
+ }
+ p->opt.device = device_str;
+ return (p);
}
-#endif
static void
initialize_ops(pcap_t *p)
@@ -447,10 +489,19 @@ initialize_ops(pcap_t *p)
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
+#ifdef _WIN32
+ p->stats_ex_op = (stats_ex_op_t)pcap_not_initialized_ptr;
p->setbuff_op = (setbuff_op_t)pcap_not_initialized;
p->setmode_op = (setmode_op_t)pcap_not_initialized;
p->setmintocopy_op = (setmintocopy_op_t)pcap_not_initialized;
+ p->getevent_op = pcap_getevent_not_initialized;
+ p->oid_get_request_op = (oid_get_request_op_t)pcap_not_initialized;
+ p->oid_set_request_op = (oid_set_request_op_t)pcap_not_initialized;
+ p->sendqueue_transmit_op = pcap_sendqueue_transmit_not_initialized;
+ p->setuserbuffer_op = (setuserbuffer_op_t)pcap_not_initialized;
+ p->live_dump_op = (live_dump_op_t)pcap_not_initialized;
+ p->live_dump_ended_op = (live_dump_ended_op_t)pcap_not_initialized;
+ p->get_airpcap_handle_op = pcap_get_airpcap_handle_not_initialized;
#endif
/*
@@ -461,38 +512,65 @@ initialize_ops(pcap_t *p)
p->cleanup_op = pcap_cleanup_live_common;
/*
- * In most cases, the standard one-short callback can
+ * In most cases, the standard one-shot callback can
* be used for pcap_next()/pcap_next_ex().
*/
p->oneshot_callback = pcap_oneshot;
}
-pcap_t *
-pcap_create_common(const char *source, char *ebuf)
+static pcap_t *
+pcap_alloc_pcap_t(char *ebuf, size_t size)
{
+ char *chunk;
pcap_t *p;
- p = malloc(sizeof(*p));
- if (p == NULL) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
+ /*
+ * Allocate a chunk of memory big enough for a pcap_t
+ * plus a structure following it of size "size". The
+ * structure following it is a private data structure
+ * for the routines that handle this pcap_t.
+ */
+ chunk = malloc(sizeof (pcap_t) + size);
+ if (chunk == NULL) {
+ pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
pcap_strerror(errno));
return (NULL);
}
- memset(p, 0, sizeof(*p));
-#ifndef WIN32
+ memset(chunk, 0, sizeof (pcap_t) + size);
+
+ /*
+ * Get a pointer to the pcap_t at the beginning.
+ */
+ p = (pcap_t *)chunk;
+
+#ifndef _WIN32
p->fd = -1; /* not opened yet */
p->selectable_fd = -1;
- p->send_fd = -1;
#endif
- p->opt.source = strdup(source);
- if (p->opt.source == NULL) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
- pcap_strerror(errno));
- free(p);
- return (NULL);
+ if (size == 0) {
+ /* No private data was requested. */
+ p->priv = NULL;
+ } else {
+ /*
+ * Set the pointer to the private data; that's the structure
+ * of size "size" following the pcap_t.
+ */
+ p->priv = (void *)(chunk + sizeof (pcap_t));
}
+ return (p);
+}
+
+pcap_t *
+pcap_create_common(char *ebuf, size_t size)
+{
+ pcap_t *p;
+
+ p = pcap_alloc_pcap_t(ebuf, size);
+ if (p == NULL)
+ return (NULL);
+
/*
* Default to "can't set rfmon mode"; if it's supported by
* a platform, the create routine that called us can set
@@ -504,11 +582,20 @@ pcap_create_common(const char *source, char *ebuf)
initialize_ops(p);
/* put in some defaults*/
- pcap_set_timeout(p, 0);
- pcap_set_snaplen(p, 65535); /* max packet size */
+ p->snapshot = MAXIMUM_SNAPLEN; /* max packet size */
+ p->opt.timeout = 0; /* no timeout specified */
+ p->opt.buffer_size = 0; /* use the platform's default */
p->opt.promisc = 0;
- p->opt.buffer_size = 0;
+ p->opt.rfmon = 0;
+ p->opt.immediate = 0;
p->opt.tstamp_type = -1; /* default to not setting time stamp type */
+ p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO;
+
+ /*
+ * Start out with no BPF code generation flags set.
+ */
+ p->bpf_codegen_flags = 0;
+
return (p);
}
@@ -516,7 +603,7 @@ int
pcap_check_activated(pcap_t *p)
{
if (p->activated) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't perform "
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't perform "
" operation on activated capture");
return (-1);
}
@@ -528,6 +615,16 @@ 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);
}
@@ -555,7 +652,7 @@ pcap_set_timeout(pcap_t *p, int timeout_ms)
{
if (pcap_check_activated(p))
return (PCAP_ERROR_ACTIVATED);
- p->md.timeout = timeout_ms;
+ p->opt.timeout = timeout_ms;
return (0);
}
@@ -568,42 +665,122 @@ pcap_set_tstamp_type(pcap_t *p, int tstamp_type)
return (PCAP_ERROR_ACTIVATED);
/*
- * If p->tstamp_type_count is 0, we don't support setting
- * the time stamp type at all.
+ * The argument should have been u_int, but that's too late
+ * to change now - it's an API.
*/
- if (p->tstamp_type_count == 0)
- return (PCAP_ERROR_CANTSET_TSTAMP_TYPE);
+ if (tstamp_type < 0)
+ return (PCAP_WARNING_TSTAMP_TYPE_NOTSUP);
/*
- * Check whether we claim to support this type of time stamp.
+ * If p->tstamp_type_count is 0, we only support PCAP_TSTAMP_HOST;
+ * the default time stamp type is PCAP_TSTAMP_HOST.
*/
- for (i = 0; i < p->tstamp_type_count; i++) {
- if (p->tstamp_type_list[i] == tstamp_type) {
- /*
- * Yes.
- */
+ if (p->tstamp_type_count == 0) {
+ if (tstamp_type == PCAP_TSTAMP_HOST) {
p->opt.tstamp_type = tstamp_type;
return (0);
}
+ } else {
+ /*
+ * Check whether we claim to support this type of time stamp.
+ */
+ for (i = 0; i < p->tstamp_type_count; i++) {
+ if (p->tstamp_type_list[i] == (u_int)tstamp_type) {
+ /*
+ * Yes.
+ */
+ p->opt.tstamp_type = tstamp_type;
+ return (0);
+ }
+ }
}
/*
- * No. We support setting the time stamp type, but not to this
- * particular value.
+ * We don't support this type of time stamp.
*/
return (PCAP_WARNING_TSTAMP_TYPE_NOTSUP);
}
int
+pcap_set_immediate_mode(pcap_t *p, int immediate)
+{
+ if (pcap_check_activated(p))
+ return (PCAP_ERROR_ACTIVATED);
+ p->opt.immediate = immediate;
+ return (0);
+}
+
+int
pcap_set_buffer_size(pcap_t *p, int buffer_size)
{
if (pcap_check_activated(p))
return (PCAP_ERROR_ACTIVATED);
+ if (buffer_size <= 0) {
+ /*
+ * Silently ignore invalid values.
+ */
+ return (0);
+ }
p->opt.buffer_size = buffer_size;
return (0);
}
int
+pcap_set_tstamp_precision(pcap_t *p, int tstamp_precision)
+{
+ int i;
+
+ if (pcap_check_activated(p))
+ return (PCAP_ERROR_ACTIVATED);
+
+ /*
+ * The argument should have been u_int, but that's too late
+ * to change now - it's an API.
+ */
+ if (tstamp_precision < 0)
+ return (PCAP_ERROR_TSTAMP_PRECISION_NOTSUP);
+
+ /*
+ * If p->tstamp_precision_count is 0, we only support setting
+ * the time stamp precision to microsecond precision; every
+ * pcap module *MUST* support microsecond precision, even if
+ * it does so by converting the native precision to
+ * microseconds.
+ */
+ if (p->tstamp_precision_count == 0) {
+ if (tstamp_precision == PCAP_TSTAMP_PRECISION_MICRO) {
+ p->opt.tstamp_precision = tstamp_precision;
+ return (0);
+ }
+ } else {
+ /*
+ * Check whether we claim to support this precision of
+ * time stamp.
+ */
+ for (i = 0; i < p->tstamp_precision_count; i++) {
+ if (p->tstamp_precision_list[i] == (u_int)tstamp_precision) {
+ /*
+ * Yes.
+ */
+ p->opt.tstamp_precision = tstamp_precision;
+ return (0);
+ }
+ }
+ }
+
+ /*
+ * We don't support this time stamp precision.
+ */
+ return (PCAP_ERROR_TSTAMP_PRECISION_NOTSUP);
+}
+
+int
+pcap_get_tstamp_precision(pcap_t *p)
+{
+ return (p->opt.tstamp_precision);
+}
+
+int
pcap_activate(pcap_t *p)
{
int status;
@@ -628,7 +805,7 @@ pcap_activate(pcap_t *p)
* handle errors other than PCAP_ERROR, return the
* error message corresponding to the status.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s",
pcap_statustostr(status));
}
@@ -642,12 +819,12 @@ pcap_activate(pcap_t *p)
}
pcap_t *
-pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *errbuf)
+pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *errbuf)
{
pcap_t *p;
int status;
- p = pcap_create(source, errbuf);
+ p = pcap_create(device, errbuf);
if (p == NULL)
return (NULL);
status = pcap_set_snaplen(p, snaplen);
@@ -676,33 +853,37 @@ pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *er
return (p);
fail:
if (status == PCAP_ERROR)
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
p->errbuf);
else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
status == PCAP_ERROR_PERM_DENIED ||
status == PCAP_ERROR_PROMISC_PERM_DENIED)
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", source,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", device,
pcap_statustostr(status), p->errbuf);
else
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
pcap_statustostr(status));
pcap_close(p);
return (NULL);
}
-int
-pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
+pcap_t *
+pcap_open_offline_common(char *ebuf, size_t size)
{
- return (p->read_op(p, cnt, callback, user));
+ pcap_t *p;
+
+ p = pcap_alloc_pcap_t(ebuf, size);
+ if (p == NULL)
+ return (NULL);
+
+ p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO;
+
+ return (p);
}
-/*
- * XXX - is this necessary?
- */
int
-pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
+pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
-
return (p->read_op(p, cnt, callback, user));
}
@@ -712,7 +893,7 @@ pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
register int n;
for (;;) {
- if (p->sf.rfile != NULL) {
+ if (p->rfile != NULL) {
/*
* 0 means EOF, so don't loop if we get 0.
*/
@@ -728,7 +909,7 @@ pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
if (n <= 0)
return (n);
- if (cnt > 0) {
+ if (!PACKET_COUNT_IS_UNLIMITED(cnt)) {
cnt -= n;
if (cnt <= 0)
return (0);
@@ -748,18 +929,24 @@ pcap_breakloop(pcap_t *p)
int
pcap_datalink(pcap_t *p)
{
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
return (p->linktype);
}
int
pcap_datalink_ext(pcap_t *p)
{
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
return (p->linktype_ext);
}
int
pcap_list_datalinks(pcap_t *p, int **dlt_buffer)
{
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
if (p->dlt_count == 0) {
/*
* We couldn't fetch the list of DLTs, which means
@@ -769,18 +956,18 @@ pcap_list_datalinks(pcap_t *p, int **dlt_buffer)
*/
*dlt_buffer = (int*)malloc(sizeof(**dlt_buffer));
if (*dlt_buffer == NULL) {
- (void)snprintf(p->errbuf, sizeof(p->errbuf),
+ (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"malloc: %s", pcap_strerror(errno));
- return (-1);
+ return (PCAP_ERROR);
}
**dlt_buffer = p->linktype;
return (1);
} else {
*dlt_buffer = (int*)calloc(sizeof(**dlt_buffer), p->dlt_count);
if (*dlt_buffer == NULL) {
- (void)snprintf(p->errbuf, sizeof(p->errbuf),
+ (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"malloc: %s", pcap_strerror(errno));
- return (-1);
+ return (PCAP_ERROR);
}
(void)memcpy(*dlt_buffer, p->dlt_list,
sizeof(**dlt_buffer) * p->dlt_count);
@@ -811,6 +998,9 @@ pcap_set_datalink(pcap_t *p, int dlt)
int i;
const char *dlt_name;
+ if (dlt < 0)
+ goto unsupported;
+
if (p->dlt_count == 0 || p->set_datalink_op == NULL) {
/*
* We couldn't fetch the list of DLTs, or we don't
@@ -828,7 +1018,7 @@ pcap_set_datalink(pcap_t *p, int dlt)
return (0);
}
for (i = 0; i < p->dlt_count; i++)
- if (p->dlt_list[i] == dlt)
+ if (p->dlt_list[i] == (u_int)dlt)
break;
if (i >= p->dlt_count)
goto unsupported;
@@ -856,11 +1046,11 @@ pcap_set_datalink(pcap_t *p, int dlt)
unsupported:
dlt_name = pcap_datalink_val_to_name(dlt);
if (dlt_name != NULL) {
- (void) snprintf(p->errbuf, sizeof(p->errbuf),
+ (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"%s is not one of the DLTs supported by this device",
dlt_name);
} else {
- (void) snprintf(p->errbuf, sizeof(p->errbuf),
+ (void) pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"DLT %d is not one of the DLTs supported by this device",
dlt);
}
@@ -958,113 +1148,139 @@ struct dlt_choice {
int dlt;
};
-#define DLT_CHOICE(code, description) { #code, description, code }
+#define DLT_CHOICE(code, description) { #code, description, DLT_ ## code }
#define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
static struct dlt_choice dlt_choices[] = {
- DLT_CHOICE(DLT_NULL, "BSD loopback"),
- DLT_CHOICE(DLT_EN10MB, "Ethernet"),
- DLT_CHOICE(DLT_IEEE802, "Token ring"),
- DLT_CHOICE(DLT_ARCNET, "BSD ARCNET"),
- DLT_CHOICE(DLT_SLIP, "SLIP"),
- DLT_CHOICE(DLT_PPP, "PPP"),
- DLT_CHOICE(DLT_FDDI, "FDDI"),
- DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 LLC-encapsulated ATM"),
- DLT_CHOICE(DLT_RAW, "Raw IP"),
- DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
- DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
- DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
- DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
- DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
- DLT_CHOICE(DLT_SYMANTEC_FIREWALL, "Symantec Firewall"),
- DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
- DLT_CHOICE(DLT_IEEE802_11, "802.11"),
- DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
- DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
- DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
- DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
- DLT_CHOICE(DLT_LTALK, "Localtalk"),
- DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
- DLT_CHOICE(DLT_PFSYNC, "Packet filter state syncing"),
- DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
- DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
- DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
- DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radiotap header"),
- DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
- DLT_CHOICE(DLT_JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
- DLT_CHOICE(DLT_JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
- DLT_CHOICE(DLT_JUNIPER_ES, "Juniper Encryption Services PIC"),
- DLT_CHOICE(DLT_JUNIPER_GGSN, "Juniper GGSN PIC"),
- DLT_CHOICE(DLT_JUNIPER_MFR, "Juniper FRF.16 Frame Relay"),
- DLT_CHOICE(DLT_JUNIPER_ATM2, "Juniper ATM2 PIC"),
- DLT_CHOICE(DLT_JUNIPER_SERVICES, "Juniper Advanced Services PIC"),
- DLT_CHOICE(DLT_JUNIPER_ATM1, "Juniper ATM1 PIC"),
- DLT_CHOICE(DLT_APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
- DLT_CHOICE(DLT_MTP2_WITH_PHDR, "SS7 MTP2 with Pseudo-header"),
- DLT_CHOICE(DLT_MTP2, "SS7 MTP2"),
- DLT_CHOICE(DLT_MTP3, "SS7 MTP3"),
- DLT_CHOICE(DLT_SCCP, "SS7 SCCP"),
- DLT_CHOICE(DLT_DOCSIS, "DOCSIS"),
- DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
- DLT_CHOICE(DLT_IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
- DLT_CHOICE(DLT_JUNIPER_MONITOR, "Juniper Passive Monitor PIC"),
- DLT_CHOICE(DLT_PPP_PPPD, "PPP for pppd, with direction flag"),
- DLT_CHOICE(DLT_JUNIPER_PPPOE, "Juniper PPPoE"),
- DLT_CHOICE(DLT_JUNIPER_PPPOE_ATM, "Juniper PPPoE/ATM"),
- DLT_CHOICE(DLT_GPRS_LLC, "GPRS LLC"),
- DLT_CHOICE(DLT_GPF_T, "GPF-T"),
- DLT_CHOICE(DLT_GPF_F, "GPF-F"),
- DLT_CHOICE(DLT_JUNIPER_PIC_PEER, "Juniper PIC Peer"),
- DLT_CHOICE(DLT_ERF_ETH, "Ethernet with Endace ERF header"),
- DLT_CHOICE(DLT_ERF_POS, "Packet-over-SONET with Endace ERF header"),
- DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
- DLT_CHOICE(DLT_JUNIPER_ETHER, "Juniper Ethernet"),
- DLT_CHOICE(DLT_JUNIPER_PPP, "Juniper PPP"),
- DLT_CHOICE(DLT_JUNIPER_FRELAY, "Juniper Frame Relay"),
- DLT_CHOICE(DLT_JUNIPER_CHDLC, "Juniper C-HDLC"),
- DLT_CHOICE(DLT_MFR, "FRF.16 Frame Relay"),
- DLT_CHOICE(DLT_JUNIPER_VP, "Juniper Voice PIC"),
- DLT_CHOICE(DLT_A429, "Arinc 429"),
- DLT_CHOICE(DLT_A653_ICM, "Arinc 653 Interpartition Communication"),
- DLT_CHOICE(DLT_USB, "USB"),
- DLT_CHOICE(DLT_BLUETOOTH_HCI_H4, "Bluetooth HCI UART transport layer"),
- DLT_CHOICE(DLT_IEEE802_16_MAC_CPS, "IEEE 802.16 MAC Common Part Sublayer"),
- DLT_CHOICE(DLT_USB_LINUX, "USB with Linux header"),
- DLT_CHOICE(DLT_CAN20B, "Controller Area Network (CAN) v. 2.0B"),
- DLT_CHOICE(DLT_IEEE802_15_4_LINUX, "IEEE 802.15.4 with Linux padding"),
- DLT_CHOICE(DLT_PPI, "Per-Packet Information"),
- DLT_CHOICE(DLT_IEEE802_16_MAC_CPS_RADIO, "IEEE 802.16 MAC Common Part Sublayer plus radiotap header"),
- DLT_CHOICE(DLT_JUNIPER_ISM, "Juniper Integrated Service Module"),
- DLT_CHOICE(DLT_IEEE802_15_4, "IEEE 802.15.4 with FCS"),
- DLT_CHOICE(DLT_SITA, "SITA pseudo-header"),
- DLT_CHOICE(DLT_ERF, "Endace ERF header"),
- DLT_CHOICE(DLT_RAIF1, "Ethernet with u10 Networks pseudo-header"),
- DLT_CHOICE(DLT_IPMB, "IPMB"),
- DLT_CHOICE(DLT_JUNIPER_ST, "Juniper Secure Tunnel"),
- DLT_CHOICE(DLT_BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
- DLT_CHOICE(DLT_AX25_KISS, "AX.25 with KISS header"),
- DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
- DLT_CHOICE(DLT_MPLS, "MPLS with label as link-layer header"),
- DLT_CHOICE(DLT_USB_LINUX_MMAPPED, "USB with padded Linux header"),
- DLT_CHOICE(DLT_DECT, "DECT"),
- DLT_CHOICE(DLT_AOS, "AOS Space Data Link protocol"),
- DLT_CHOICE(DLT_WIHART, "Wireless HART"),
- DLT_CHOICE(DLT_FC_2, "Fibre Channel FC-2"),
- DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
- DLT_CHOICE(DLT_IPNET, "Solaris ipnet"),
- DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
- DLT_CHOICE(DLT_IPV4, "Raw IPv4"),
- DLT_CHOICE(DLT_IPV6, "Raw IPv6"),
- DLT_CHOICE(DLT_IEEE802_15_4_NOFCS, "IEEE 802.15.4 without FCS"),
- DLT_CHOICE(DLT_JUNIPER_VS, "Juniper Virtual Server"),
- DLT_CHOICE(DLT_JUNIPER_SRX_E2E, "Juniper SRX E2E"),
- DLT_CHOICE(DLT_JUNIPER_FIBRECHANNEL, "Juniper Fibre Channel"),
- DLT_CHOICE(DLT_DVB_CI, "DVB-CI"),
- DLT_CHOICE(DLT_JUNIPER_ATM_CEMIC, "Juniper ATM CEMIC"),
- DLT_CHOICE(DLT_NFLOG, "Linux netfilter log messages"),
- DLT_CHOICE(DLT_NETANALYZER, "Ethernet with Hilscher netANALYZER pseudo-header"),
- DLT_CHOICE(DLT_NETANALYZER_TRANSPARENT, "Ethernet with Hilscher netANALYZER pseudo-header and with preamble and SFD"),
- DLT_CHOICE(DLT_IPOIB, "RFC 4391 IP-over-Infiniband"),
+ DLT_CHOICE(NULL, "BSD loopback"),
+ DLT_CHOICE(EN10MB, "Ethernet"),
+ DLT_CHOICE(IEEE802, "Token ring"),
+ DLT_CHOICE(ARCNET, "BSD ARCNET"),
+ DLT_CHOICE(SLIP, "SLIP"),
+ DLT_CHOICE(PPP, "PPP"),
+ DLT_CHOICE(FDDI, "FDDI"),
+ DLT_CHOICE(ATM_RFC1483, "RFC 1483 LLC-encapsulated ATM"),
+ DLT_CHOICE(RAW, "Raw IP"),
+ DLT_CHOICE(SLIP_BSDOS, "BSD/OS SLIP"),
+ DLT_CHOICE(PPP_BSDOS, "BSD/OS PPP"),
+ DLT_CHOICE(ATM_CLIP, "Linux Classical IP-over-ATM"),
+ DLT_CHOICE(PPP_SERIAL, "PPP over serial"),
+ DLT_CHOICE(PPP_ETHER, "PPPoE"),
+ DLT_CHOICE(SYMANTEC_FIREWALL, "Symantec Firewall"),
+ DLT_CHOICE(C_HDLC, "Cisco HDLC"),
+ DLT_CHOICE(IEEE802_11, "802.11"),
+ DLT_CHOICE(FRELAY, "Frame Relay"),
+ DLT_CHOICE(LOOP, "OpenBSD loopback"),
+ DLT_CHOICE(ENC, "OpenBSD encapsulated IP"),
+ DLT_CHOICE(LINUX_SLL, "Linux cooked"),
+ DLT_CHOICE(LTALK, "Localtalk"),
+ DLT_CHOICE(PFLOG, "OpenBSD pflog file"),
+ DLT_CHOICE(PFSYNC, "Packet filter state syncing"),
+ DLT_CHOICE(PRISM_HEADER, "802.11 plus Prism header"),
+ DLT_CHOICE(IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
+ DLT_CHOICE(SUNATM, "Sun raw ATM"),
+ DLT_CHOICE(IEEE802_11_RADIO, "802.11 plus radiotap header"),
+ DLT_CHOICE(ARCNET_LINUX, "Linux ARCNET"),
+ DLT_CHOICE(JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
+ DLT_CHOICE(JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
+ DLT_CHOICE(JUNIPER_ES, "Juniper Encryption Services PIC"),
+ DLT_CHOICE(JUNIPER_GGSN, "Juniper GGSN PIC"),
+ DLT_CHOICE(JUNIPER_MFR, "Juniper FRF.16 Frame Relay"),
+ DLT_CHOICE(JUNIPER_ATM2, "Juniper ATM2 PIC"),
+ DLT_CHOICE(JUNIPER_SERVICES, "Juniper Advanced Services PIC"),
+ DLT_CHOICE(JUNIPER_ATM1, "Juniper ATM1 PIC"),
+ DLT_CHOICE(APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
+ DLT_CHOICE(MTP2_WITH_PHDR, "SS7 MTP2 with Pseudo-header"),
+ DLT_CHOICE(MTP2, "SS7 MTP2"),
+ DLT_CHOICE(MTP3, "SS7 MTP3"),
+ DLT_CHOICE(SCCP, "SS7 SCCP"),
+ DLT_CHOICE(DOCSIS, "DOCSIS"),
+ DLT_CHOICE(LINUX_IRDA, "Linux IrDA"),
+ DLT_CHOICE(IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
+ DLT_CHOICE(JUNIPER_MONITOR, "Juniper Passive Monitor PIC"),
+ DLT_CHOICE(BACNET_MS_TP, "BACnet MS/TP"),
+ DLT_CHOICE(PPP_PPPD, "PPP for pppd, with direction flag"),
+ DLT_CHOICE(JUNIPER_PPPOE, "Juniper PPPoE"),
+ DLT_CHOICE(JUNIPER_PPPOE_ATM, "Juniper PPPoE/ATM"),
+ DLT_CHOICE(GPRS_LLC, "GPRS LLC"),
+ DLT_CHOICE(GPF_T, "GPF-T"),
+ DLT_CHOICE(GPF_F, "GPF-F"),
+ DLT_CHOICE(JUNIPER_PIC_PEER, "Juniper PIC Peer"),
+ DLT_CHOICE(ERF_ETH, "Ethernet with Endace ERF header"),
+ DLT_CHOICE(ERF_POS, "Packet-over-SONET with Endace ERF header"),
+ DLT_CHOICE(LINUX_LAPD, "Linux vISDN LAPD"),
+ DLT_CHOICE(JUNIPER_ETHER, "Juniper Ethernet"),
+ DLT_CHOICE(JUNIPER_PPP, "Juniper PPP"),
+ DLT_CHOICE(JUNIPER_FRELAY, "Juniper Frame Relay"),
+ DLT_CHOICE(JUNIPER_CHDLC, "Juniper C-HDLC"),
+ DLT_CHOICE(MFR, "FRF.16 Frame Relay"),
+ DLT_CHOICE(JUNIPER_VP, "Juniper Voice PIC"),
+ DLT_CHOICE(A429, "Arinc 429"),
+ DLT_CHOICE(A653_ICM, "Arinc 653 Interpartition Communication"),
+ DLT_CHOICE(USB_FREEBSD, "USB with FreeBSD header"),
+ DLT_CHOICE(BLUETOOTH_HCI_H4, "Bluetooth HCI UART transport layer"),
+ DLT_CHOICE(IEEE802_16_MAC_CPS, "IEEE 802.16 MAC Common Part Sublayer"),
+ DLT_CHOICE(USB_LINUX, "USB with Linux header"),
+ DLT_CHOICE(CAN20B, "Controller Area Network (CAN) v. 2.0B"),
+ DLT_CHOICE(IEEE802_15_4_LINUX, "IEEE 802.15.4 with Linux padding"),
+ DLT_CHOICE(PPI, "Per-Packet Information"),
+ DLT_CHOICE(IEEE802_16_MAC_CPS_RADIO, "IEEE 802.16 MAC Common Part Sublayer plus radiotap header"),
+ DLT_CHOICE(JUNIPER_ISM, "Juniper Integrated Service Module"),
+ DLT_CHOICE(IEEE802_15_4, "IEEE 802.15.4 with FCS"),
+ DLT_CHOICE(SITA, "SITA pseudo-header"),
+ DLT_CHOICE(ERF, "Endace ERF header"),
+ DLT_CHOICE(RAIF1, "Ethernet with u10 Networks pseudo-header"),
+ DLT_CHOICE(IPMB, "IPMB"),
+ DLT_CHOICE(JUNIPER_ST, "Juniper Secure Tunnel"),
+ DLT_CHOICE(BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
+ DLT_CHOICE(AX25_KISS, "AX.25 with KISS header"),
+ DLT_CHOICE(IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
+ DLT_CHOICE(MPLS, "MPLS with label as link-layer header"),
+ DLT_CHOICE(LINUX_EVDEV, "Linux evdev events"),
+ DLT_CHOICE(USB_LINUX_MMAPPED, "USB with padded Linux header"),
+ DLT_CHOICE(DECT, "DECT"),
+ DLT_CHOICE(AOS, "AOS Space Data Link protocol"),
+ DLT_CHOICE(WIHART, "Wireless HART"),
+ DLT_CHOICE(FC_2, "Fibre Channel FC-2"),
+ DLT_CHOICE(FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
+ DLT_CHOICE(IPNET, "Solaris ipnet"),
+ DLT_CHOICE(CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
+ DLT_CHOICE(IPV4, "Raw IPv4"),
+ DLT_CHOICE(IPV6, "Raw IPv6"),
+ DLT_CHOICE(IEEE802_15_4_NOFCS, "IEEE 802.15.4 without FCS"),
+ DLT_CHOICE(DBUS, "D-Bus"),
+ DLT_CHOICE(JUNIPER_VS, "Juniper Virtual Server"),
+ DLT_CHOICE(JUNIPER_SRX_E2E, "Juniper SRX E2E"),
+ DLT_CHOICE(JUNIPER_FIBRECHANNEL, "Juniper Fibre Channel"),
+ DLT_CHOICE(DVB_CI, "DVB-CI"),
+ DLT_CHOICE(MUX27010, "MUX27010"),
+ DLT_CHOICE(STANAG_5066_D_PDU, "STANAG 5066 D_PDUs"),
+ DLT_CHOICE(JUNIPER_ATM_CEMIC, "Juniper ATM CEMIC"),
+ DLT_CHOICE(NFLOG, "Linux netfilter log messages"),
+ DLT_CHOICE(NETANALYZER, "Ethernet with Hilscher netANALYZER pseudo-header"),
+ DLT_CHOICE(NETANALYZER_TRANSPARENT, "Ethernet with Hilscher netANALYZER pseudo-header and with preamble and SFD"),
+ DLT_CHOICE(IPOIB, "RFC 4391 IP-over-Infiniband"),
+ DLT_CHOICE(MPEG_2_TS, "MPEG-2 transport stream"),
+ DLT_CHOICE(NG40, "ng40 protocol tester Iub/Iur"),
+ DLT_CHOICE(NFC_LLCP, "NFC LLCP PDUs with pseudo-header"),
+ DLT_CHOICE(INFINIBAND, "InfiniBand"),
+ DLT_CHOICE(SCTP, "SCTP"),
+ DLT_CHOICE(USBPCAP, "USB with USBPcap header"),
+ DLT_CHOICE(RTAC_SERIAL, "Schweitzer Engineering Laboratories RTAC packets"),
+ DLT_CHOICE(BLUETOOTH_LE_LL, "Bluetooth Low Energy air interface"),
+ DLT_CHOICE(NETLINK, "Linux netlink"),
+ DLT_CHOICE(BLUETOOTH_LINUX_MONITOR, "Bluetooth Linux Monitor"),
+ DLT_CHOICE(BLUETOOTH_BREDR_BB, "Bluetooth Basic Rate/Enhanced Data Rate baseband packets"),
+ DLT_CHOICE(BLUETOOTH_LE_LL_WITH_PHDR, "Bluetooth Low Energy air interface with pseudo-header"),
+ DLT_CHOICE(PROFIBUS_DL, "PROFIBUS data link layer"),
+ DLT_CHOICE(PKTAP, "Apple DLT_PKTAP"),
+ DLT_CHOICE(EPON, "Ethernet with 802.3 Clause 65 EPON preamble"),
+ DLT_CHOICE(IPMI_HPM_2, "IPMI trace packets"),
+ DLT_CHOICE(ZWAVE_R1_R2, "Z-Wave RF profile R1 and R2 packets"),
+ DLT_CHOICE(ZWAVE_R3, "Z-Wave RF profile R3 packets"),
+ 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_SENTINEL
};
@@ -1074,8 +1290,7 @@ pcap_datalink_name_to_val(const char *name)
int i;
for (i = 0; dlt_choices[i].name != NULL; i++) {
- if (pcap_strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
- name) == 0)
+ if (pcap_strcasecmp(dlt_choices[i].name, name) == 0)
return (dlt_choices[i].dlt);
}
return (-1);
@@ -1088,7 +1303,7 @@ pcap_datalink_val_to_name(int dlt)
for (i = 0; dlt_choices[i].name != NULL; i++) {
if (dlt_choices[i].dlt == dlt)
- return (dlt_choices[i].name + sizeof("DLT_") - 1);
+ return (dlt_choices[i].name);
}
return (NULL);
}
@@ -1159,47 +1374,55 @@ pcap_tstamp_type_val_to_description(int tstamp_type)
int
pcap_snapshot(pcap_t *p)
{
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
return (p->snapshot);
}
int
pcap_is_swapped(pcap_t *p)
{
- return (p->sf.swapped);
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
+ return (p->swapped);
}
int
pcap_major_version(pcap_t *p)
{
- return (p->sf.version_major);
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
+ return (p->version_major);
}
int
pcap_minor_version(pcap_t *p)
{
- return (p->sf.version_minor);
+ if (!p->activated)
+ return (PCAP_ERROR_NOT_ACTIVATED);
+ return (p->version_minor);
}
FILE *
pcap_file(pcap_t *p)
{
- return (p->sf.rfile);
+ return (p->rfile);
}
int
pcap_fileno(pcap_t *p)
{
-#ifndef WIN32
+#ifndef _WIN32
return (p->fd);
#else
if (p->adapter != NULL)
return ((int)(DWORD)p->adapter->hFile);
else
- return (-1);
+ return (PCAP_ERROR);
#endif
}
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
int
pcap_get_selectable_fd(pcap_t *p)
{
@@ -1208,7 +1431,7 @@ pcap_get_selectable_fd(pcap_t *p)
#endif
void
-pcap_perror(pcap_t *p, char *prefix)
+pcap_perror(pcap_t *p, const char *prefix)
{
fprintf(stderr, "%s: %s\n", prefix, p->errbuf);
}
@@ -1239,11 +1462,8 @@ pcap_getnonblock(pcap_t *p, char *errbuf)
/*
* Get the current non-blocking mode setting, under the assumption that
* it's just the standard POSIX non-blocking flag.
- *
- * We don't look at "p->nonblock", in case somebody tweaked the FD
- * directly.
*/
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
int
pcap_getnonblock_fd(pcap_t *p, char *errbuf)
{
@@ -1251,7 +1471,7 @@ pcap_getnonblock_fd(pcap_t *p, char *errbuf)
fdflags = fcntl(p->fd, F_GETFL, 0);
if (fdflags == -1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_GETFL: %s",
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_GETFL: %s",
pcap_strerror(errno));
return (-1);
}
@@ -1279,7 +1499,7 @@ pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf)
return (ret);
}
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
/*
* Set non-blocking mode, under the assumption that it's just the
* standard POSIX non-blocking flag. (This can be called by the
@@ -1293,7 +1513,7 @@ pcap_setnonblock_fd(pcap_t *p, int nonblock, char *errbuf)
fdflags = fcntl(p->fd, F_GETFL, 0);
if (fdflags == -1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_GETFL: %s",
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_GETFL: %s",
pcap_strerror(errno));
return (-1);
}
@@ -1302,7 +1522,7 @@ pcap_setnonblock_fd(pcap_t *p, int nonblock, char *errbuf)
else
fdflags &= ~O_NONBLOCK;
if (fcntl(p->fd, F_SETFL, fdflags) == -1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_SETFL: %s",
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "F_SETFL: %s",
pcap_strerror(errno));
return (-1);
}
@@ -1310,21 +1530,18 @@ pcap_setnonblock_fd(pcap_t *p, int nonblock, char *errbuf)
}
#endif
-#ifdef WIN32
+#ifdef _WIN32
/*
- * Generate a string for the last Win32-specific error (i.e. an error generated when
+ * Generate a string for a Win32-specific error (i.e. an error generated when
* calling a Win32 API).
* For errors occurred during standard C calls, we still use pcap_strerror()
*/
-char *
-pcap_win32strerror(void)
+void
+pcap_win32_err_to_str(DWORD error, char *errbuf)
{
- DWORD error;
- static char errbuf[PCAP_ERRBUF_SIZE+1];
- int errlen;
+ size_t errlen;
char *p;
- error = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, errbuf,
PCAP_ERRBUF_SIZE, NULL);
@@ -1338,8 +1555,7 @@ pcap_win32strerror(void)
errbuf[errlen - 2] = '\0';
}
p = strchr(errbuf, '\0');
- snprintf (p, sizeof(errbuf)-(p-errbuf), " (%lu)", error);
- return (errbuf);
+ pcap_snprintf (p, PCAP_ERRBUF_SIZE+1-(p-errbuf), " (%lu)", error);
}
#endif
@@ -1394,8 +1610,11 @@ pcap_statustostr(int errnum)
case PCAP_ERROR_PROMISC_PERM_DENIED:
return ("You don't have permission to capture in promiscuous mode on that device");
+
+ case PCAP_ERROR_TSTAMP_PRECISION_NOTSUP:
+ return ("That device doesn't support that time stamp precision");
}
- (void)snprintf(ebuf, sizeof ebuf, "Unknown error: %d", errnum);
+ (void)pcap_snprintf(ebuf, sizeof ebuf, "Unknown error: %d", errnum);
return(ebuf);
}
@@ -1406,16 +1625,25 @@ const char *
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 */
+ strlcpy(errbuf, "strerror_s() error", PCAP_ERRBUF_SIZE);
+ return (errbuf);
+#else
return (strerror(errnum));
+#endif /* _WIN32 */
#else
extern int sys_nerr;
extern const char *const sys_errlist[];
- static char ebuf[15+10+1];
+ static char errbuf[PCAP_ERRBUF_SIZE];
if ((unsigned int)errnum < sys_nerr)
return ((char *)sys_errlist[errnum]);
- (void)snprintf(ebuf, sizeof ebuf, "Unknown error: %d", errnum);
- return(ebuf);
+ (void)pcap_snprintf(errbuf, sizeof errbuf, "Unknown error: %d", errnum);
+ return (errbuf);
#endif
}
@@ -1435,7 +1663,7 @@ int
pcap_setdirection(pcap_t *p, pcap_direction_t d)
{
if (p->setdirection_op == NULL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"Setting direction is not implemented on this platform");
return (-1);
} else
@@ -1451,12 +1679,18 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
static int
pcap_stats_dead(pcap_t *p, struct pcap_stat *ps _U_)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"Statistics aren't available from a pcap_open_dead pcap_t");
return (-1);
}
-#ifdef WIN32
+#ifdef _WIN32
+struct pcap_stat *
+pcap_stats_ex(pcap_t *p, int *pcap_stat_size)
+{
+ return (p->stats_ex_op(p, pcap_stat_size));
+}
+
int
pcap_setbuff(pcap_t *p, int dim)
{
@@ -1466,7 +1700,7 @@ pcap_setbuff(pcap_t *p, int dim)
static int
pcap_setbuff_dead(pcap_t *p, int dim)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"The kernel buffer size cannot be set on a pcap_open_dead pcap_t");
return (-1);
}
@@ -1480,7 +1714,7 @@ pcap_setmode(pcap_t *p, int mode)
static int
pcap_setmode_dead(pcap_t *p, int mode)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"impossible to set mode on a pcap_open_dead pcap_t");
return (-1);
}
@@ -1494,10 +1728,178 @@ pcap_setmintocopy(pcap_t *p, int size)
static int
pcap_setmintocopy_dead(pcap_t *p, int size)
{
- snprintf(p->errbuf, PCAP_ERRBUF_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)
+{
+ pcap_send_queue *tqueue;
+
+ /* Allocate the queue */
+ tqueue = (pcap_send_queue *)malloc(sizeof(pcap_send_queue));
+ if (tqueue == NULL){
+ return (NULL);
+ }
+
+ /* Allocate the buffer */
+ tqueue->buffer = (char *)malloc(memsize);
+ if (tqueue->buffer == NULL) {
+ free(tqueue);
+ return (NULL);
+ }
+
+ tqueue->maxlen = memsize;
+ tqueue->len = 0;
+
+ return (tqueue);
+}
+
+void
+pcap_sendqueue_destroy(pcap_send_queue *queue)
+{
+ free(queue->buffer);
+ free(queue);
+}
+
+int
+pcap_sendqueue_queue(pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)
+{
+ if (queue->len + sizeof(struct pcap_pkthdr) + pkt_header->caplen > queue->maxlen){
+ return (-1);
+ }
+
+ /* Copy the pcap_pkthdr header*/
+ memcpy(queue->buffer + queue->len, pkt_header, sizeof(struct pcap_pkthdr));
+ queue->len += sizeof(struct pcap_pkthdr);
+
+ /* copy the packet */
+ memcpy(queue->buffer + queue->len, pkt_data, pkt_header->caplen);
+ queue->len += pkt_header->caplen;
+
+ return (0);
+}
+
+u_int
+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)
+{
+ PAirpcapHandle handle;
+
+ handle = p->get_airpcap_handle_op(p);
+ if (handle == NULL) {
+ (void)pcap_snprintf(p->errbuf, sizeof(p->errbuf),
+ "This isn't an AirPcap device");
+ }
+ return (handle);
+}
+
+static PAirpcapHandle
+pcap_get_airpcap_handle_dead(pcap_t *p)
+{
+ return (NULL);
+}
#endif
/*
@@ -1542,12 +1944,11 @@ pcap_do_addexit(pcap_t *p)
* "pcap_close_all()" called when we exit.
*/
if (!did_atexit) {
- if (atexit(pcap_close_all) == -1) {
+ if (atexit(pcap_close_all) != 0) {
/*
* "atexit()" failed; let our caller know.
*/
- strncpy(p->errbuf, "atexit failed",
- PCAP_ERRBUF_SIZE);
+ strlcpy(p->errbuf, "atexit failed", PCAP_ERRBUF_SIZE);
return (0);
}
did_atexit = 1;
@@ -1558,7 +1959,7 @@ pcap_do_addexit(pcap_t *p)
void
pcap_add_to_pcaps_to_close(pcap_t *p)
{
- p->md.next = pcaps_to_close;
+ p->next = pcaps_to_close;
pcaps_to_close = p;
}
@@ -1568,7 +1969,7 @@ pcap_remove_from_pcaps_to_close(pcap_t *p)
pcap_t *pc, *prevpc;
for (pc = pcaps_to_close, prevpc = NULL; pc != NULL;
- prevpc = pc, pc = pc->md.next) {
+ prevpc = pc, pc = pc->next) {
if (pc == p) {
/*
* Found it. Remove it from the list.
@@ -1577,12 +1978,12 @@ pcap_remove_from_pcaps_to_close(pcap_t *p)
/*
* It was at the head of the list.
*/
- pcaps_to_close = pc->md.next;
+ pcaps_to_close = pc->next;
} else {
/*
* It was in the middle of the list.
*/
- prevpc->md.next = pc->md.next;
+ prevpc->next = pc->next;
}
break;
}
@@ -1606,14 +2007,18 @@ pcap_cleanup_live_common(pcap_t *p)
p->tstamp_type_list = NULL;
p->tstamp_type_count = 0;
}
+ if (p->tstamp_precision_list != NULL) {
+ free(p->tstamp_precision_list);
+ p->tstamp_precision_list = NULL;
+ p->tstamp_precision_count = 0;
+ }
pcap_freecode(&p->fcode);
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
if (p->fd >= 0) {
close(p->fd);
p->fd = -1;
}
p->selectable_fd = -1;
- p->send_fd = -1;
#endif
}
@@ -1624,27 +2029,59 @@ pcap_cleanup_dead(pcap_t *p _U_)
}
pcap_t *
-pcap_open_dead(int linktype, int snaplen)
+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
+#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.
@@ -1672,8 +2109,8 @@ pcap_inject(pcap_t *p, const void *buf, size_t size)
void
pcap_close(pcap_t *p)
{
- if (p->opt.source != NULL)
- free(p->opt.source);
+ if (p->opt.device != NULL)
+ free(p->opt.device);
p->cleanup_op(p);
free(p);
}
@@ -1696,36 +2133,29 @@ pcap_offline_filter(const struct bpf_program *fp, const struct pcap_pkthdr *h,
return (0);
}
-/*
- * We make the version string static, and return a pointer to it, 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).
- */
-#ifdef HAVE_VERSION_H
-#include "version.h"
-#else
-static const char pcap_version_string[] = "libpcap version 1.x.y";
-#endif
+#include "pcap_version.h"
+
+#ifdef _WIN32
-#ifdef WIN32
+static char *full_pcap_version_string;
+
+#ifdef HAVE_VERSION_H
/*
- * XXX - it'd be nice if we could somehow generate the WinPcap and libpcap
- * version numbers when building WinPcap. (It'd be nice to do so for
- * the packet.dll version number as well.)
+ * 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.)
*/
-static const char wpcap_version_string[] = "4.0";
+#include "../../version.h"
+
+static const char wpcap_version_string[] = WINPCAP_VER_STRING;
static const char pcap_version_string_fmt[] =
- "WinPcap version %s, based on %s";
+ WINPCAP_PRODUCT_NAME " version %s, based on %s";
static const char pcap_version_string_packet_dll_fmt[] =
- "WinPcap version %s (packet.dll version %s), based on %s";
-static char *full_pcap_version_string;
+ WINPCAP_PRODUCT_NAME " version %s (packet.dll version %s), based on %s";
const char *
pcap_lib_version(void)
@@ -1750,8 +2180,12 @@ pcap_lib_version(void)
strlen(pcap_version_string);
full_pcap_version_string =
malloc(full_pcap_version_string_len);
- sprintf(full_pcap_version_string,
- pcap_version_string_fmt, wpcap_version_string,
+ 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 {
/*
@@ -1767,16 +2201,57 @@ pcap_lib_version(void)
strlen(packet_version_string) +
strlen(pcap_version_string);
full_pcap_version_string = malloc(full_pcap_version_string_len);
-
- sprintf(full_pcap_version_string,
+ 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,
+ wpcap_version_string,
+ packet_version_string,
pcap_version_string);
}
}
return (full_pcap_version_string);
}
+#else /* HAVE_VERSION_H */
+
+/*
+ * 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)
+{
+ char *packet_version_string;
+ size_t full_pcap_version_string_len;
+
+ 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);
+}
+
+#endif /* HAVE_VERSION_H */
+
#elif defined(MSDOS)
static char *full_pcap_version_string;
@@ -1796,6 +2271,8 @@ pcap_lib_version (void)
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);
}
@@ -1810,3 +2287,51 @@ pcap_lib_version(void)
return (pcap_version_string);
}
#endif
+
+#ifdef YYDEBUG
+/*
+ * Set the internal "debug printout" flag for the filter expression parser.
+ * The code to print that stuff is present only if YYDEBUG is defined, so
+ * the flag, and the routine to set it, are defined only if YYDEBUG 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_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.h b/freebsd/contrib/libpcap/pcap.h
index 490a4bfb..174e32d2 100644
--- a/freebsd/contrib/libpcap/pcap.h
+++ b/freebsd/contrib/libpcap/pcap.h
@@ -29,8 +29,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.59 2006-10-04 18:09:22 guy Exp $ (LBL)
*/
/*
diff --git a/freebsd/contrib/libpcap/pcap/can_socketcan.h b/freebsd/contrib/libpcap/pcap/can_socketcan.h
new file mode 100644
index 00000000..68d2a131
--- /dev/null
+++ b/freebsd/contrib/libpcap/pcap/can_socketcan.h
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * 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 University of
+ * California, Berkeley and its contributors.
+ * 4. 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 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_can_socketcan_h
+#define lib_pcap_can_socketcan_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;
+} pcap_can_socketcan_hdr;
+
+#endif
diff --git a/freebsd/contrib/libpcap/pcap/export-defs.h b/freebsd/contrib/libpcap/pcap/export-defs.h
new file mode 100644
index 00000000..a2350579
--- /dev/null
+++ b/freebsd/contrib/libpcap/pcap/export-defs.h
@@ -0,0 +1,108 @@
+/* -*- 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/namedb.h b/freebsd/contrib/libpcap/pcap/namedb.h
index e3145579..73fb40a4 100644
--- a/freebsd/contrib/libpcap/pcap/namedb.h
+++ b/freebsd/contrib/libpcap/pcap/namedb.h
@@ -29,8 +29,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap/namedb.h,v 1.1 2006-10-04 18:09:22 guy Exp $ (LBL)
*/
#ifndef lib_pcap_namedb_h
@@ -45,7 +43,10 @@ extern "C" {
* XXX this stuff doesn't belong in this interface, but this
* library already must do name to address translation, so
* on systems that don't have support for /etc/ethers, we
- * export these hooks since they'll
+ * export these hooks since they're already being used by
+ * some applications (such as tcpdump) and already being
+ * marked as exported in some OSes offering libpcap (such
+ * as Debian).
*/
struct pcap_etherent {
u_char addr[6];
@@ -54,21 +55,21 @@ struct pcap_etherent {
#ifndef PCAP_ETHERS_FILE
#define PCAP_ETHERS_FILE "/etc/ethers"
#endif
-struct pcap_etherent *pcap_next_etherent(FILE *);
-u_char *pcap_ether_hostton(const char*);
-u_char *pcap_ether_aton(const char *);
+PCAP_API struct pcap_etherent *pcap_next_etherent(FILE *);
+PCAP_API u_char *pcap_ether_hostton(const char*);
+PCAP_API u_char *pcap_ether_aton(const char *);
-bpf_u_int32 **pcap_nametoaddr(const char *);
+PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *);
#ifdef INET6
-struct addrinfo *pcap_nametoaddrinfo(const char *);
+PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *);
#endif
-bpf_u_int32 pcap_nametonetaddr(const char *);
+PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *);
-int pcap_nametoport(const char *, int *, int *);
-int pcap_nametoportrange(const char *, int *, int *, int *);
-int pcap_nametoproto(const char *);
-int pcap_nametoeproto(const char *);
-int pcap_nametollc(const char *);
+PCAP_API int pcap_nametoport(const char *, int *, int *);
+PCAP_API int pcap_nametoportrange(const char *, int *, int *, int *);
+PCAP_API int pcap_nametoproto(const char *);
+PCAP_API int pcap_nametoeproto(const char *);
+PCAP_API int pcap_nametollc(const char *);
/*
* If a protocol is unknown, PROTO_UNDEF is returned.
* Also, pcap_nametoport() returns the protocol along with the port number.
@@ -77,11 +78,6 @@ int pcap_nametollc(const char *);
*/
#define PROTO_UNDEF -1
-/* XXX move these to pcap-int.h? */
-int __pcap_atodn(const char *, bpf_u_int32 *);
-int __pcap_atoin(const char *, bpf_u_int32 *);
-u_short __pcap_nametodnaddr(const char *);
-
#ifdef __cplusplus
}
#endif
diff --git a/freebsd/contrib/libpcap/pcap/nflog.h b/freebsd/contrib/libpcap/pcap/nflog.h
new file mode 100644
index 00000000..a3867cdd
--- /dev/null
+++ b/freebsd/contrib/libpcap/pcap/nflog.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2013, Petar Alilovic,
+ * Faculty of Electrical Engineering and Computing, University of Zagreb
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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_nflog_h
+#define lib_pcap_nflog_h
+
+/*
+ * Structure of an NFLOG header and TLV parts, as described at
+ * http://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html
+ *
+ * The NFLOG header is big-endian.
+ *
+ * The TLV length and type are in host byte order. The value is either
+ * big-endian or is an array of bytes in some externally-specified byte
+ * order (text string, link-layer address, link-layer header, packet
+ * 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 */
+} nflog_hdr_t;
+
+typedef struct nflog_tlv {
+ u_int16_t tlv_length; /* tlv length */
+ u_int16_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 */
+} 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 */
+} nflog_hwaddr_t;
+
+typedef struct nflog_timestamp {
+ u_int64_t sec;
+ u_int64_t usec;
+} nflog_timestamp_t;
+
+/*
+ * TLV types.
+ */
+#define NFULA_PACKET_HDR 1 /* nflog_packet_hdr_t */
+#define NFULA_MARK 2 /* packet mark from skbuff */
+#define NFULA_TIMESTAMP 3 /* nflog_timestamp_t for skbuff's time stamp */
+#define NFULA_IFINDEX_INDEV 4 /* ifindex of device on which packet received (possibly bridge group) */
+#define NFULA_IFINDEX_OUTDEV 5 /* ifindex of device on which packet transmitted (possibly bridge group) */
+#define NFULA_IFINDEX_PHYSINDEV 6 /* ifindex of physical device on which packet received (not bridge group) */
+#define NFULA_IFINDEX_PHYSOUTDEV 7 /* ifindex of physical device on which packet transmitted (not bridge group) */
+#define NFULA_HWADDR 8 /* nflog_hwaddr_t for hardware address */
+#define NFULA_PAYLOAD 9 /* packet payload */
+#define NFULA_PREFIX 10 /* text string - null-terminated, count includes NUL */
+#define NFULA_UID 11 /* UID owning socket on which packet was sent/received */
+#define NFULA_SEQ 12 /* sequence number of packets on this NFLOG socket */
+#define NFULA_SEQ_GLOBAL 13 /* sequence number of pakets on all NFLOG sockets */
+#define NFULA_GID 14 /* GID owning socket on which packet was sent/received */
+#define NFULA_HWTYPE 15 /* ARPHRD_ type of skbuff's device */
+#define NFULA_HWHEADER 16 /* skbuff's MAC-layer header */
+#define NFULA_HWLEN 17 /* length of skbuff's MAC-layer header */
+
+#endif
diff --git a/freebsd/contrib/libpcap/pcap/pcap.h b/freebsd/contrib/libpcap/pcap/pcap.h
index 64c40753..9c277124 100644
--- a/freebsd/contrib/libpcap/pcap/pcap.h
+++ b/freebsd/contrib/libpcap/pcap/pcap.h
@@ -30,14 +30,14 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap/pcap.h,v 1.15 2008-10-06 15:27:32 gianluca Exp $ (LBL)
*/
#ifndef lib_pcap_pcap_h
#define lib_pcap_pcap_h
-#if defined(WIN32)
+#include <pcap/export-defs.h>
+
+#if defined(_WIN32)
#include <pcap-stdinc.h>
#elif defined(MSDOS)
#include <sys/types.h>
@@ -45,7 +45,7 @@
#else /* UN*X */
#include <sys/types.h>
#include <sys/time.h>
-#endif /* WIN32/MSDOS/UN*X */
+#endif /* _WIN32/MSDOS/UN*X */
#include <net/bpf.h>
@@ -113,7 +113,7 @@ typedef struct pcap_addr pcap_addr_t;
*
* Then supply the changes by forking the branch at
*
- * https://github.com/mcr/libpcap/issues
+ * https://github.com/the-tcpdump-group/libpcap/issues
*
* and issuing a pull request, so that future versions of libpcap and
* programs that use it (such as tcpdump) will be able to read your new
@@ -170,9 +170,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 */
-#ifdef WIN32
- u_int bs_capt; /* number of packets that reach the application */
-#endif /* WIN32 */
+#if defined(_WIN32) && defined(HAVE_REMOTE)
+ 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 */
};
#ifdef MSDOS
@@ -220,6 +222,8 @@ struct pcap_if {
};
#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */
+#define PCAP_IF_UP 0x00000002 /* interface is up */
+#define PCAP_IF_RUNNING 0x00000004 /* interface is running */
/*
* Representation of an interface address.
@@ -252,6 +256,7 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
#define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */
#define PCAP_ERROR_CANTSET_TSTAMP_TYPE -10 /* this device doesn't support setting the time stamp type */
#define PCAP_ERROR_PROMISC_PERM_DENIED -11 /* you don't have permission to capture in promiscuous mode */
+#define PCAP_ERROR_TSTAMP_PRECISION_NOTSUP -12 /* the requested time stamp precision is not supported */
/*
* Warning codes for the pcap API.
@@ -268,24 +273,27 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
*/
#define PCAP_NETMASK_UNKNOWN 0xffffffff
-char *pcap_lookupdev(char *);
-int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
-
-pcap_t *pcap_create(const char *, char *);
-int pcap_set_snaplen(pcap_t *, int);
-int pcap_set_promisc(pcap_t *, int);
-int pcap_can_set_rfmon(pcap_t *);
-int pcap_set_rfmon(pcap_t *, int);
-int pcap_set_timeout(pcap_t *, int);
-int pcap_set_tstamp_type(pcap_t *, int);
-int pcap_set_buffer_size(pcap_t *, int);
-int pcap_activate(pcap_t *);
-
-int pcap_list_tstamp_types(pcap_t *, int **);
-void pcap_free_tstamp_types(int *);
-int pcap_tstamp_type_name_to_val(const char *);
-const char *pcap_tstamp_type_val_to_name(int);
-const char *pcap_tstamp_type_val_to_description(int);
+PCAP_API char *pcap_lookupdev(char *);
+PCAP_API int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
+
+PCAP_API pcap_t *pcap_create(const char *, char *);
+PCAP_API int pcap_set_snaplen(pcap_t *, int);
+PCAP_API int pcap_set_promisc(pcap_t *, int);
+PCAP_API int pcap_can_set_rfmon(pcap_t *);
+PCAP_API int pcap_set_rfmon(pcap_t *, int);
+PCAP_API int pcap_set_timeout(pcap_t *, int);
+PCAP_API int pcap_set_tstamp_type(pcap_t *, int);
+PCAP_API int pcap_set_immediate_mode(pcap_t *, int);
+PCAP_API int pcap_set_buffer_size(pcap_t *, int);
+PCAP_API int pcap_set_tstamp_precision(pcap_t *, int);
+PCAP_API int pcap_get_tstamp_precision(pcap_t *);
+PCAP_API int pcap_activate(pcap_t *);
+
+PCAP_API int pcap_list_tstamp_types(pcap_t *, int **);
+PCAP_API void pcap_free_tstamp_types(int *);
+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);
/*
* Time stamp types.
@@ -331,128 +339,195 @@ const char *pcap_tstamp_type_val_to_description(int);
#define PCAP_TSTAMP_ADAPTER 3 /* device-provided, synced with the system clock */
#define PCAP_TSTAMP_ADAPTER_UNSYNCED 4 /* device-provided, not synced with the system clock */
-pcap_t *pcap_open_live(const char *, int, int, int, char *);
-pcap_t *pcap_open_dead(int, int);
-pcap_t *pcap_open_offline(const char *, char *);
-#if defined(WIN32)
-pcap_t *pcap_hopen_offline(intptr_t, char *);
-#if !defined(LIBPCAP_EXPORTS)
-#define pcap_fopen_offline(f,b) \
+/*
+ * Time stamp resolution types.
+ * Not all systems and interfaces will necessarily support all of these
+ * resolutions when doing live captures; all of them can be requested
+ * when reading a savefile.
+ */
+#define PCAP_TSTAMP_PRECISION_MICRO 0 /* use timestamps with microsecond precision, default */
+#define PCAP_TSTAMP_PRECISION_NANO 1 /* use timestamps with nanosecond precision */
+
+PCAP_API pcap_t *pcap_open_live(const char *, int, int, int, char *);
+PCAP_API pcap_t *pcap_open_dead(int, int);
+PCAP_API pcap_t *pcap_open_dead_with_tstamp_precision(int, int, u_int);
+PCAP_API pcap_t *pcap_open_offline_with_tstamp_precision(const char *, u_int, char *);
+PCAP_API pcap_t *pcap_open_offline(const char *, char *);
+#ifdef _WIN32
+ PCAP_API pcap_t *pcap_hopen_offline_with_tstamp_precision(intptr_t, u_int, 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.
+ */
+ #ifndef BUILDING_PCAP
+ #define pcap_fopen_offline_with_tstamp_precision(f,p,b) \
+ pcap_hopen_offline_with_tstamp_precision(_get_osfhandle(_fileno(f)), p, b)
+ #define pcap_fopen_offline(f,b) \
pcap_hopen_offline(_get_osfhandle(_fileno(f)), b)
-#else /*LIBPCAP_EXPORTS*/
-static pcap_t *pcap_fopen_offline(FILE *, char *);
-#endif
-#else /*WIN32*/
-pcap_t *pcap_fopen_offline(FILE *, char *);
-#endif /*WIN32*/
-
-void pcap_close(pcap_t *);
-int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
-int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
-const u_char*
- pcap_next(pcap_t *, struct pcap_pkthdr *);
-int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
-void pcap_breakloop(pcap_t *);
-int pcap_stats(pcap_t *, struct pcap_stat *);
-int pcap_setfilter(pcap_t *, struct bpf_program *);
-int pcap_setdirection(pcap_t *, pcap_direction_t);
-int pcap_getnonblock(pcap_t *, char *);
-int pcap_setnonblock(pcap_t *, int, char *);
-int pcap_inject(pcap_t *, const void *, size_t);
-int pcap_sendpacket(pcap_t *, const u_char *, int);
-const char *pcap_statustostr(int);
-const char *pcap_strerror(int);
-char *pcap_geterr(pcap_t *);
-void pcap_perror(pcap_t *, char *);
-int pcap_compile(pcap_t *, struct bpf_program *, const char *, int,
+ #endif
+#else /*_WIN32*/
+ PCAP_API pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *);
+ PCAP_API pcap_t *pcap_fopen_offline(FILE *, char *);
+#endif /*_WIN32*/
+
+PCAP_API void pcap_close(pcap_t *);
+PCAP_API int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
+PCAP_API int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
+PCAP_API const u_char *pcap_next(pcap_t *, struct pcap_pkthdr *);
+PCAP_API int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
+PCAP_API void pcap_breakloop(pcap_t *);
+PCAP_API int pcap_stats(pcap_t *, struct pcap_stat *);
+PCAP_API int pcap_setfilter(pcap_t *, struct bpf_program *);
+PCAP_API int pcap_setdirection(pcap_t *, pcap_direction_t);
+PCAP_API int pcap_getnonblock(pcap_t *, char *);
+PCAP_API int pcap_setnonblock(pcap_t *, int, char *);
+PCAP_API int pcap_inject(pcap_t *, const void *, size_t);
+PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int);
+PCAP_API const char *pcap_statustostr(int);
+PCAP_API const char *pcap_strerror(int);
+PCAP_API char *pcap_geterr(pcap_t *);
+PCAP_API void pcap_perror(pcap_t *, const char *);
+PCAP_API int pcap_compile(pcap_t *, struct bpf_program *, const char *, int,
bpf_u_int32);
-int pcap_compile_nopcap(int, int, struct bpf_program *,
+PCAP_API int pcap_compile_nopcap(int, int, struct bpf_program *,
const char *, int, bpf_u_int32);
-void pcap_freecode(struct bpf_program *);
-int pcap_offline_filter(const struct bpf_program *,
+PCAP_API void pcap_freecode(struct bpf_program *);
+PCAP_API int pcap_offline_filter(const struct bpf_program *,
const struct pcap_pkthdr *, const u_char *);
-int pcap_datalink(pcap_t *);
-int pcap_datalink_ext(pcap_t *);
-int pcap_list_datalinks(pcap_t *, int **);
-int pcap_set_datalink(pcap_t *, int);
-void pcap_free_datalinks(int *);
-int pcap_datalink_name_to_val(const char *);
-const char *pcap_datalink_val_to_name(int);
-const char *pcap_datalink_val_to_description(int);
-int pcap_snapshot(pcap_t *);
-int pcap_is_swapped(pcap_t *);
-int pcap_major_version(pcap_t *);
-int pcap_minor_version(pcap_t *);
+PCAP_API int pcap_datalink(pcap_t *);
+PCAP_API int pcap_datalink_ext(pcap_t *);
+PCAP_API int pcap_list_datalinks(pcap_t *, int **);
+PCAP_API int pcap_set_datalink(pcap_t *, int);
+PCAP_API void pcap_free_datalinks(int *);
+PCAP_API int pcap_datalink_name_to_val(const char *);
+PCAP_API const char *pcap_datalink_val_to_name(int);
+PCAP_API const char *pcap_datalink_val_to_description(int);
+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 *);
/* XXX */
-FILE *pcap_file(pcap_t *);
-int pcap_fileno(pcap_t *);
+PCAP_API FILE *pcap_file(pcap_t *);
+PCAP_API int pcap_fileno(pcap_t *);
+
+#ifdef _WIN32
+ PCAP_API int pcap_wsockinit(void);
+#endif
-pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
-pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
-FILE *pcap_dump_file(pcap_dumper_t *);
-long pcap_dump_ftell(pcap_dumper_t *);
-int pcap_dump_flush(pcap_dumper_t *);
-void pcap_dump_close(pcap_dumper_t *);
-void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
+PCAP_API pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
+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 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 *);
-int pcap_findalldevs(pcap_if_t **, char *);
-void pcap_freealldevs(pcap_if_t *);
+PCAP_API int pcap_findalldevs(pcap_if_t **, char *);
+PCAP_API void pcap_freealldevs(pcap_if_t *);
-const char *pcap_lib_version(void);
+PCAP_API const char *pcap_lib_version(void);
/*
- * On at least some versions of NetBSD, we don't want to declare
+ * On at least some versions of NetBSD and QNX, we don't want to declare
* bpf_filter() here, as it's also be declared in <net/bpf.h>, with a
* different signature, but, on other BSD-flavored UN*Xes, it's not
* declared in <net/bpf.h>, so we *do* want to declare it here, so it's
* declared when we build pcap-bpf.c.
*/
-#ifndef __NetBSD__
-u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
+#if !defined(__NetBSD__) && !defined(__QNX__)
+ PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
#endif
-int bpf_validate(const struct bpf_insn *f, int len);
-char *bpf_image(struct bpf_insn *, int);
-void bpf_dump(const struct bpf_program *, int);
+PCAP_API int bpf_validate(const struct bpf_insn *f, int len);
+PCAP_API char *bpf_image(const struct bpf_insn *, int);
+PCAP_API void bpf_dump(const struct bpf_program *, int);
-#if defined(WIN32)
+#if defined(_WIN32)
-/*
- * Win32 definitions
- */
+ /*
+ * Win32 definitions
+ */
+
+ /*!
+ \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit().
+ */
+ struct pcap_send_queue
+ {
+ u_int maxlen; /* Maximum size of the 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. */
+ };
+
+ typedef struct pcap_send_queue pcap_send_queue;
+
+ /*!
+ \brief This typedef is a support for the pcap_get_airpcap_handle() function
+ */
+ #if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_)
+ #define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_
+ typedef struct _AirpcapHandle *PAirpcapHandle;
+ #endif
+
+ PCAP_API int pcap_setbuff(pcap_t *p, int dim);
+ PCAP_API int pcap_setmode(pcap_t *p, int mode);
+ PCAP_API int pcap_setmintocopy(pcap_t *p, int size);
+
+ PCAP_API HANDLE pcap_getevent(pcap_t *p);
-int pcap_setbuff(pcap_t *p, int dim);
-int pcap_setmode(pcap_t *p, int mode);
-int pcap_setmintocopy(pcap_t *p, int size);
+ PCAP_API int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t *);
+ PCAP_API int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t *);
-#ifdef WPCAP
-/* Include file with the wpcap-specific extensions */
-#include <Win32-Extensions.h>
-#endif /* WPCAP */
+ PCAP_API pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
-#define MODE_CAPT 0
-#define MODE_STAT 1
-#define MODE_MON 2
+ PCAP_API void pcap_sendqueue_destroy(pcap_send_queue* queue);
+
+ PCAP_API int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);
+
+ PCAP_API u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);
+
+ PCAP_API struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size);
+
+ PCAP_API int pcap_setuserbuffer(pcap_t *p, int size);
+
+ PCAP_API int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks);
+
+ PCAP_API int pcap_live_dump_ended(pcap_t *p, int sync);
+
+ PCAP_API int pcap_start_oem(char* err_str, int flags);
+
+ PCAP_API PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p);
+
+ #define MODE_CAPT 0
+ #define MODE_STAT 1
+ #define MODE_MON 2
#elif defined(MSDOS)
-/*
- * MS-DOS definitions
- */
+ /*
+ * MS-DOS definitions
+ */
-int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *);
-void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait);
-u_long pcap_mac_packets (void);
+ PCAP_API int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *);
+ PCAP_API void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait);
+ PCAP_API u_long pcap_mac_packets (void);
#else /* UN*X */
-/*
- * UN*X definitions
- */
+ /*
+ * UN*X definitions
+ */
+
+ PCAP_API int pcap_get_selectable_fd(pcap_t *);
-int pcap_get_selectable_fd(pcap_t *);
+#endif /* _WIN32/MSDOS/UN*X */
-#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 */
#ifdef __cplusplus
}
diff --git a/freebsd/contrib/libpcap/pcap/sll.h b/freebsd/contrib/libpcap/pcap/sll.h
index 7ad811d7..b46d15f2 100644
--- a/freebsd/contrib/libpcap/pcap/sll.h
+++ b/freebsd/contrib/libpcap/pcap/sll.h
@@ -34,8 +34,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap/sll.h,v 1.3 2008-05-30 01:35:33 guy Exp $ (LBL)
*/
/*
@@ -125,5 +123,7 @@ struct sll_header {
*/
#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
+#define LINUX_SLL_P_CAN 0x000C /* CAN frames, with SocketCAN pseudo-headers */
+#define LINUX_SLL_P_CANFD 0x000D /* CAN FD frames, with SocketCAN pseudo-headers */
#endif
diff --git a/freebsd/contrib/libpcap/pcap/usb.h b/freebsd/contrib/libpcap/pcap/usb.h
index aa351225..26a9046b 100644
--- a/freebsd/contrib/libpcap/pcap/usb.h
+++ b/freebsd/contrib/libpcap/pcap/usb.h
@@ -11,8 +11,8 @@
* 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. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
+ * 3. The name of the author may not 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
@@ -29,14 +29,12 @@
*
* Basic USB data struct
* By Paolo Abeni <paolo.abeni@email.it>
- *
- * @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.9 2008-12-23 20:13:29 guy Exp $
*/
-
-#ifndef _PCAP_USB_STRUCTS_H__
-#define _PCAP_USB_STRUCTS_H__
-/*
+#ifndef lib_pcap_usb_h
+#define lib_pcap_usb_h
+
+/*
* possible transfer mode
*/
#define URB_TRANSFER_IN 0x80
diff --git a/freebsd/contrib/libpcap/pcap_version.h b/freebsd/contrib/libpcap/pcap_version.h
new file mode 100644
index 00000000..619c6d8a
--- /dev/null
+++ b/freebsd/contrib/libpcap/pcap_version.h
@@ -0,0 +1,13 @@
+/*
+ * We make the version string static, and return a pointer to it, 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).
+ */
+static const char pcap_version_string[] = "libpcap version 1.8.1";
diff --git a/freebsd/contrib/libpcap/portability.h b/freebsd/contrib/libpcap/portability.h
new file mode 100644
index 00000000..8a6bf40e
--- /dev/null
+++ b/freebsd/contrib/libpcap/portability.h
@@ -0,0 +1,216 @@
+/*
+ * 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 portability_h
+#define portability_h
+
+/*
+ * Helpers for portability between Windows and UN*X and between different
+ * flavors of UN*X.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef HAVE_STRLCPY
+ /*
+ * Macro that does the same thing as strlcpy().
+ */
+ #ifdef _MSC_VER
+ /*
+ * strncpy_s() is supported at least back to Visual
+ * Studio 2005.
+ */
+ #define strlcpy(x, y, z) \
+ strncpy_s((x), (z), (y), _TRUNCATE)
+
+ #else
+ #define strlcpy(x, y, z) \
+ (strncpy((x), (y), (z)), \
+ ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
+ (void) strlen((y)))
+ #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__)
+ #define strlcat(x, y, z) \
+ strncat_s((x), (z), (y), _TRUNCATE)
+#endif
+
+#ifdef _MSC_VER
+ /*
+ * MSVC.
+ */
+ #if _MSC_VER >= 1900
+ /*
+ * VS 2015 or newer; we have snprintf() function.
+ */
+ #define HAVE_SNPRINTF
+ #endif
+#endif
+
+/*
+ * On Windows, snprintf(), with that name and with C99 behavior - i.e.,
+ * guaranteeing that the formatted string is null-terminated - didn't
+ * appear until Visual Studio 2015. Prior to that, the C runtime had
+ * only _snprintf(), which *doesn't* guarantee that the string is
+ * null-terminated if it is truncated due to the buffer being too
+ * small. We therefore can't just define snprintf to be _snprintf
+ * and define vsnprintf to be _vsnprintf, as we're relying on null-
+ * termination of strings in all cases.
+ *
+ * We also want to allow this to be built with versions of Visual Studio
+ * prior to VS 2015, so we can't rely on snprintf() being present.
+ *
+ * And we want to make sure that, if we support plugins in the future,
+ * a routine with C99 snprintf() behavior will be available to them.
+ * We also don't want it to collide with the C library snprintf() if
+ * there is one.
+ *
+ * So we make pcap_snprintf() and pcap_vsnprintf() available, either by
+ * #defining them to be snprintf or vsnprintf, respectively, or by
+ * defining our own versions and exporting them.
+ */
+#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 */
+ ;
+#endif
+
+#ifdef HAVE_VSNPRINTF
+#define pcap_vsnprintf vsnprintf
+#else
+extern int pcap_vsnprintf(char *, size_t, const char *, va_list ap);
+#endif
+
+#ifdef HAVE_STRTOK_R
+ #define pcap_strtok_r strtok_r
+#else
+ #ifdef _MSC_VER
+ /*
+ * Microsoft gives it a different name.
+ */
+ #define pcap_strtok_r strtok_s
+ #else
+ /*
+ * Define it ourselves.
+ */
+ #define NEED_STRTOK_R
+ extern int 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
+#endif /* _WIN32 */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/freebsd/contrib/libpcap/ppp.h b/freebsd/contrib/libpcap/ppp.h
index 4e1d08de..d6e70c15 100644
--- a/freebsd/contrib/libpcap/ppp.h
+++ b/freebsd/contrib/libpcap/ppp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/libpcap/ppp.h,v 1.12 2005-02-08 19:52:19 guy Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
diff --git a/freebsd/contrib/libpcap/savefile.c b/freebsd/contrib/libpcap/savefile.c
index f62635f1..8f6b17c7 100644
--- a/freebsd/contrib/libpcap/savefile.c
+++ b/freebsd/contrib/libpcap/savefile.c
@@ -30,18 +30,13 @@
* dependent values so we can print the dump file on any architecture.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.183 2008-12-23 20:13:29 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -51,7 +46,7 @@ static const char rcsid[] _U_ =
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <errno.h>
#include <memory.h>
@@ -60,7 +55,6 @@ static const char rcsid[] _U_ =
#include <string.h>
#include "pcap-int.h"
-#include "pcap/usb.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
@@ -69,10 +63,27 @@ static const char rcsid[] _U_ =
#include "sf-pcap.h"
#include "sf-pcap-ng.h"
+#ifdef _WIN32
+/*
+ * These aren't exported on Windows, because they would only work if both
+ * WinPcap and the code using it were to use the Universal CRT; otherwise,
+ * a FILE structure in WinPcap and a FILE structure in the code using it
+ * could be different if they're using different versions of the C runtime.
+ *
+ * Instead, pcap/pcap.h defines them as macros that wrap the hopen versions,
+ * with the wrappers calling _fileno() and _get_osfhandle() themselves,
+ * so that they convert the appropriate CRT version's FILE structure to
+ * a HANDLE (which is OS-defined, not CRT-defined, and is part of the Win32
+ * and Win64 ABIs).
+ */
+static pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *);
+static pcap_t *pcap_fopen_offline(FILE *, char *);
+#endif
+
/*
* Setting O_BINARY on DOS/Windows is a bit tricky
*/
-#if defined(WIN32)
+#if defined(_WIN32)
#define SET_BINMODE(f) _setmode(_fileno(f), _O_BINARY)
#elif defined(MSDOS)
#if defined(__HIGHC__)
@@ -103,7 +114,7 @@ sf_setnonblock(pcap_t *p, int nonblock, char *errbuf)
* as it would have to handle reading partial packets and
* keeping the state of the read.)
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"Savefiles cannot be put into non-blocking mode");
return (-1);
}
@@ -111,16 +122,24 @@ sf_setnonblock(pcap_t *p, int nonblock, char *errbuf)
static int
sf_stats(pcap_t *p, struct pcap_stat *ps)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"Statistics aren't available from savefiles");
return (-1);
}
-#ifdef WIN32
+#ifdef _WIN32
+static struct pcap_stat *
+sf_stats_ex(pcap_t *p, int *size)
+{
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "Statistics aren't available from savefiles");
+ return (NULL);
+}
+
static int
sf_setbuff(pcap_t *p, int dim)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"The kernel buffer size cannot be set while reading from a file");
return (-1);
}
@@ -128,7 +147,7 @@ sf_setbuff(pcap_t *p, int dim)
static int
sf_setmode(pcap_t *p, int mode)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"impossible to set mode while reading from a file");
return (-1);
}
@@ -136,10 +155,74 @@ sf_setmode(pcap_t *p, int mode)
static int
sf_setmintocopy(pcap_t *p, int size)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"The mintocopy parameter cannot be set while reading from a file");
return (-1);
}
+
+static HANDLE
+sf_getevent(pcap_t *pcap)
+{
+ (void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
+ "The read event cannot be retrieved while reading from a file");
+ return (INVALID_HANDLE_VALUE);
+}
+
+static int
+sf_oid_get_request(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 file");
+ return (PCAP_ERROR);
+}
+
+static int
+sf_oid_set_request(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 file");
+ return (PCAP_ERROR);
+}
+
+static u_int
+sf_sendqueue_transmit(pcap_t *p, pcap_send_queue *queue, int sync)
+{
+ strlcpy(p->errbuf, "Sending packets isn't supported on savefiles",
+ PCAP_ERRBUF_SIZE);
+ return (0);
+}
+
+static int
+sf_setuserbuffer(pcap_t *p, int size)
+{
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "The user buffer cannot be set when reading from a file");
+ return (-1);
+}
+
+static int
+sf_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks)
+{
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "Live packet dumping cannot be performed when reading from a file");
+ return (-1);
+}
+
+static int
+sf_live_dump_ended(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
+sf_get_airpcap_handle(pcap_t *pcap)
+{
+ return (NULL);
+}
#endif
static int
@@ -157,31 +240,53 @@ sf_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
static int
sf_setdirection(pcap_t *p, pcap_direction_t d)
{
- snprintf(p->errbuf, sizeof(p->errbuf),
+ pcap_snprintf(p->errbuf, sizeof(p->errbuf),
"Setting direction is not supported on savefiles");
return (-1);
}
-static void
+void
sf_cleanup(pcap_t *p)
{
- if (p->sf.rfile != stdin)
- (void)fclose(p->sf.rfile);
+ if (p->rfile != stdin)
+ (void)fclose(p->rfile);
if (p->buffer != NULL)
free(p->buffer);
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(const char *fname, char *errbuf)
+pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision,
+ char *errbuf)
{
FILE *fp;
pcap_t *p;
+ if (fname == NULL) {
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "A null pointer was supplied as the file name");
+ return (NULL);
+ }
if (fname[0] == '-' && fname[1] == '\0')
{
fp = stdin;
-#if defined(WIN32) || defined(MSDOS)
+#if defined(_WIN32) || defined(MSDOS)
/*
* We're reading from the standard input, so put it in binary
* mode, as savefiles are binary files.
@@ -190,18 +295,18 @@ pcap_open_offline(const char *fname, char *errbuf)
#endif
}
else {
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
fp = fopen(fname, "r");
#else
fp = fopen(fname, "rb");
#endif
if (fp == NULL) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", fname,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", fname,
pcap_strerror(errno));
return (NULL);
}
}
- p = pcap_fopen_offline(fp, errbuf);
+ p = pcap_fopen_offline_with_tstamp_precision(fp, precision, errbuf);
if (p == NULL) {
if (fp != stdin)
fclose(fp);
@@ -209,51 +314,64 @@ pcap_open_offline(const char *fname, char *errbuf)
return (p);
}
-#ifdef WIN32
-pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf)
+pcap_t *
+pcap_open_offline(const char *fname, char *errbuf)
+{
+ return (pcap_open_offline_with_tstamp_precision(fname,
+ PCAP_TSTAMP_PRECISION_MICRO, errbuf));
+}
+
+#ifdef _WIN32
+pcap_t* pcap_hopen_offline_with_tstamp_precision(intptr_t osfd, u_int precision,
+ char *errbuf)
{
int fd;
FILE *file;
fd = _open_osfhandle(osfd, _O_RDONLY);
- if ( fd < 0 )
+ if ( fd < 0 )
{
- snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno));
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno));
return NULL;
}
file = _fdopen(fd, "rb");
- if ( file == NULL )
+ if ( file == NULL )
{
- snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno));
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno));
return NULL;
}
- return pcap_fopen_offline(file, errbuf);
+ return pcap_fopen_offline_with_tstamp_precision(file, precision,
+ errbuf);
+}
+
+pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf)
+{
+ return pcap_hopen_offline_with_tstamp_precision(osfd,
+ PCAP_TSTAMP_PRECISION_MICRO, errbuf);
}
#endif
-static int (*check_headers[])(pcap_t *, bpf_u_int32, FILE *, char *) = {
+static pcap_t *(*check_headers[])(bpf_u_int32, FILE *, u_int, char *, int *) = {
pcap_check_header,
pcap_ng_check_header
};
#define N_FILE_TYPES (sizeof check_headers / sizeof check_headers[0])
-#ifdef WIN32
+#ifdef _WIN32
static
#endif
pcap_t *
-pcap_fopen_offline(FILE *fp, char *errbuf)
+pcap_fopen_offline_with_tstamp_precision(FILE *fp, u_int precision,
+ char *errbuf)
{
register pcap_t *p;
bpf_u_int32 magic;
size_t amt_read;
u_int i;
-
- p = pcap_create_common("(savefile)", errbuf);
- if (p == NULL)
- return (NULL);
+ int err;
/*
* Read the first 4 bytes of the file; the network analyzer dump
@@ -265,53 +383,48 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
amt_read = fread((char *)&magic, 1, sizeof(magic), fp);
if (amt_read != sizeof(magic)) {
if (ferror(fp)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
} else {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"truncated dump file; tried to read %lu file header bytes, only got %lu",
(unsigned long)sizeof(magic),
(unsigned long)amt_read);
}
- goto bad;
+ return (NULL);
}
/*
* Try all file types.
*/
for (i = 0; i < N_FILE_TYPES; i++) {
- switch ((*check_headers[i])(p, magic, fp, errbuf)) {
-
- case -1:
+ p = (*check_headers[i])(magic, fp, precision, errbuf, &err);
+ if (p != NULL) {
+ /* Yup, that's it. */
+ goto found;
+ }
+ if (err) {
/*
* Error trying to read the header.
*/
- goto bad;
-
- case 1:
- /*
- * Yup, that's it.
- */
- goto found;
+ return (NULL);
}
}
/*
* Well, who knows what this mess is....
*/
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "unknown file format");
- goto bad;
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "unknown file format");
+ return (NULL);
found:
- p->sf.rfile = fp;
+ p->rfile = fp;
-#ifdef PCAP_FDDIPAD
/* Padding only needed for live capture fcode */
p->fddipad = 0;
-#endif
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
/*
* You can do "select()" and "poll()" on plain files on most
* platforms, and should be able to do so on pipes.
@@ -330,18 +443,45 @@ found:
p->getnonblock_op = sf_getnonblock;
p->setnonblock_op = sf_setnonblock;
p->stats_op = sf_stats;
-#ifdef WIN32
+#ifdef _WIN32
+ p->stats_ex_op = sf_stats_ex;
p->setbuff_op = sf_setbuff;
p->setmode_op = sf_setmode;
p->setmintocopy_op = sf_setmintocopy;
+ p->getevent_op = sf_getevent;
+ p->oid_get_request_op = sf_oid_get_request;
+ p->oid_set_request_op = sf_oid_set_request;
+ p->sendqueue_transmit_op = sf_sendqueue_transmit;
+ p->setuserbuffer_op = sf_setuserbuffer;
+ p->live_dump_op = sf_live_dump;
+ p->live_dump_ended_op = sf_live_dump_ended;
+ p->get_airpcap_handle_op = sf_get_airpcap_handle;
#endif
- p->cleanup_op = sf_cleanup;
+
+ /*
+ * For offline captures, the standard one-shot callback can
+ * be used for pcap_next()/pcap_next_ex().
+ */
+ p->oneshot_callback = pcap_oneshot;
+
+ /*
+ * Savefiles never require special BPF code generation.
+ */
+ p->bpf_codegen_flags = 0;
+
p->activated = 1;
return (p);
- bad:
- free(p);
- return (NULL);
+}
+
+#ifdef _WIN32
+static
+#endif
+pcap_t *
+pcap_fopen_offline(FILE *fp, char *errbuf)
+{
+ return (pcap_fopen_offline_with_tstamp_precision(fp,
+ PCAP_TSTAMP_PRECISION_MICRO, errbuf));
}
/*
@@ -377,7 +517,7 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
return (n);
}
- status = p->sf.next_packet_op(p, &h, &data);
+ status = p->next_packet_op(p, &h, &data);
if (status) {
if (status == 1)
return (0);
diff --git a/freebsd/contrib/libpcap/scanner.c b/freebsd/contrib/libpcap/scanner.c
index d6f0498d..aaaa209f 100644
--- a/freebsd/contrib/libpcap/scanner.c
+++ b/freebsd/contrib/libpcap/scanner.c
@@ -1,29 +1,18 @@
+#line 2 "scanner.c"
+#line 2 "scanner.l"
+/* Must come first for _LARGE_FILE_API on AIX. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
-#line 3 "<stdout>"
+#line 11 "scanner.c"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
-#define yy_create_buffer pcap_create_buffer
-#define yy_delete_buffer pcap_delete_buffer
-#define yy_flex_debug pcap_flex_debug
-#define yy_init_buffer pcap_init_buffer
-#define yy_flush_buffer pcap_flush_buffer
-#define yy_load_buffer_state pcap_load_buffer_state
-#define yy_switch_to_buffer pcap_switch_to_buffer
-#define yyin pcapin
-#define yyleng pcapleng
-#define yylex pcaplex
-#define yylineno pcaplineno
-#define yyout pcapout
-#define yyrestart pcaprestart
-#define yytext pcaptext
-#define yywrap pcapwrap
-#define yyalloc pcapalloc
-#define yyrealloc pcaprealloc
-#define yyfree pcapfree
-
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
@@ -148,30 +137,47 @@ typedef unsigned int flex_uint32_t;
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
-#define BEGIN (yy_start) = 1 + 2 *
+#define BEGIN yyg->yy_start = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
-#define YY_START (((yy_start) - 1) / 2)
+#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE pcaprestart(pcapin )
+#define YY_NEW_FILE pcap_restart(yyin ,yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 1024
+#define YY_BUF_SIZE 16384
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -188,10 +194,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
typedef size_t yy_size_t;
#endif
-extern yy_size_t pcapleng;
-
-extern FILE *pcapin, *pcapout;
-
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
@@ -202,17 +204,17 @@ extern FILE *pcapin, *pcapout;
#define yyless(n) \
do \
{ \
- /* Undo effects of setting up pcaptext. */ \
+ /* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
+ *yy_cp = yyg->yy_hold_char; \
YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up pcaptext again */ \
+ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-#define unput(c) yyunput( c, (yytext_ptr) )
+#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
@@ -271,80 +273,60 @@ struct yy_buffer_state
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
- * (via pcaprestart()), so that the user can continue scanning by
- * just pointing pcapin at a new input file.
+ * (via pcap_restart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*
* Returns the top of the stack, or NULL.
*/
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
+ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
#define yy_current_buffer YY_CURRENT_BUFFER
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when pcaptext is formed. */
-static char yy_hold_char;
-static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t pcapleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow pcapwrap()'s to do buffer switches
- * instead of setting up a fresh pcapin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
+#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-void pcaprestart (FILE *input_file );
-void pcap_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE pcap_create_buffer (FILE *file,int size );
-void pcap_delete_buffer (YY_BUFFER_STATE b );
-void pcap_flush_buffer (YY_BUFFER_STATE b );
-void pcappush_buffer_state (YY_BUFFER_STATE new_buffer );
-void pcappop_buffer_state (void );
+void pcap_restart (FILE *input_file ,yyscan_t yyscanner );
+void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+YY_BUFFER_STATE pcap__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
+void pcap__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void pcap__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+void pcap_pop_buffer_state (yyscan_t yyscanner );
-static void pcapensure_buffer_stack (void );
-static void pcap_load_buffer_state (void );
-static void pcap_init_buffer (YY_BUFFER_STATE b,FILE *file );
+static void pcap_ensure_buffer_stack (yyscan_t yyscanner );
+static void pcap__load_buffer_state (yyscan_t yyscanner );
+static void pcap__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
-#define YY_FLUSH_BUFFER pcap_flush_buffer(YY_CURRENT_BUFFER )
+#define YY_FLUSH_BUFFER pcap__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
-YY_BUFFER_STATE pcap_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE pcap_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE pcap_scan_bytes (yyconst char *bytes,yy_size_t len );
+YY_BUFFER_STATE pcap__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+YY_BUFFER_STATE pcap__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE pcap__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
-void *pcapalloc (yy_size_t );
-void *pcaprealloc (void *,yy_size_t );
-void pcapfree (void * );
+void *pcap_alloc (yy_size_t ,yyscan_t yyscanner );
+void *pcap_realloc (void *,yy_size_t ,yyscan_t yyscanner );
+void pcap_free (void * ,yyscan_t yyscanner );
-#define yy_new_buffer pcap_create_buffer
+#define yy_new_buffer pcap__create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- pcapensure_buffer_stack (); \
+ pcap_ensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- pcap_create_buffer(pcapin,YY_BUF_SIZE ); \
+ pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
@@ -352,9 +334,9 @@ void pcapfree (void * );
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- pcapensure_buffer_stack (); \
+ pcap_ensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- pcap_create_buffer(pcapin,YY_BUF_SIZE ); \
+ pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
@@ -363,36 +345,32 @@ void pcapfree (void * );
/* Begin user sect3 */
-typedef unsigned char YY_CHAR;
+#define pcap_wrap(yyscanner) 1
+#define YY_SKIP_YYWRAP
-FILE *pcapin = (FILE *) 0, *pcapout = (FILE *) 0;
+typedef unsigned char YY_CHAR;
typedef int yy_state_type;
-extern int pcaplineno;
-
-int pcaplineno = 1;
-
-extern char *pcaptext;
-#define yytext_ptr pcaptext
+#define yytext_ptr yytext_r
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] ) __dead2;
+static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
+static int yy_get_next_buffer (yyscan_t yyscanner );
+static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ) __dead2;
/* Done after the current pattern has been matched and before the
- * corresponding action - sets up pcaptext.
+ * corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- pcapleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
+ yyg->yytext_ptr = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
+ yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 147
-#define YY_END_OF_BUFFER 148
+#define YY_NUM_RULES 157
+#define YY_END_OF_BUFFER 158
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -400,166 +378,169 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[1438] =
+static yyconst flex_int16_t yy_accept[1470] =
{ 0,
- 0, 0, 148, 145, 105, 105, 105, 106, 145, 106,
- 106, 106, 146, 115, 115, 106, 106, 106, 106, 143,
- 143, 145, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 106, 145, 109, 113, 67, 0, 143, 115,
- 0, 143, 143, 143, 0, 117, 111, 108, 110, 107,
- 112, 143, 144, 144, 143, 143, 143, 20, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 7, 143, 34, 35, 143,
-
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 91, 143, 68, 143, 143, 143, 143,
- 143, 143, 60, 143, 143, 143, 143, 85, 143, 143,
- 143, 143, 143, 143, 61, 143, 4, 143, 143, 143,
- 143, 143, 143, 143, 68, 113, 143, 116, 116, 143,
- 115, 143, 0, 117, 115, 117, 117, 117, 143, 143,
- 143, 67, 5, 143, 80, 143, 143, 143, 143, 143,
- 143, 143, 55, 103, 1, 0, 143, 21, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 36, 143,
- 143, 18, 43, 0, 143, 29, 143, 25, 70, 143,
-
- 143, 78, 37, 143, 99, 143, 143, 143, 143, 100,
- 143, 46, 69, 81, 102, 143, 14, 143, 3, 143,
- 143, 143, 143, 143, 93, 143, 143, 26, 143, 101,
- 143, 104, 38, 2, 143, 42, 143, 9, 143, 10,
- 88, 143, 87, 143, 143, 0, 143, 143, 116, 143,
- 143, 143, 143, 115, 0, 143, 0, 118, 117, 117,
- 0, 117, 0, 117, 0, 117, 0, 23, 143, 143,
- 143, 143, 64, 16, 41, 143, 39, 143, 143, 143,
- 30, 143, 97, 143, 143, 45, 11, 143, 12, 13,
- 143, 143, 143, 32, 77, 143, 62, 3, 98, 47,
-
- 143, 143, 143, 74, 143, 143, 143, 143, 48, 143,
- 143, 40, 143, 6, 143, 92, 143, 8, 94, 143,
- 143, 0, 143, 53, 73, 15, 143, 116, 116, 143,
- 116, 116, 116, 143, 115, 143, 0, 117, 143, 0,
- 0, 117, 0, 117, 118, 117, 0, 0, 0, 0,
- 117, 117, 117, 117, 117, 0, 143, 56, 57, 58,
- 59, 143, 22, 143, 143, 143, 143, 31, 143, 143,
- 0, 19, 143, 143, 143, 86, 143, 33, 143, 79,
- 28, 27, 143, 143, 82, 143, 143, 143, 50, 17,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
-
- 143, 143, 0, 143, 143, 116, 143, 143, 143, 143,
- 116, 116, 143, 115, 143, 0, 0, 117, 117, 117,
- 0, 0, 118, 117, 117, 118, 117, 0, 0, 117,
- 117, 117, 117, 117, 0, 0, 0, 0, 117, 117,
- 0, 117, 0, 117, 0, 96, 143, 143, 143, 24,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 70, 143, 143, 143, 143, 143,
- 143, 143, 75, 76, 143, 95, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 116, 116,
- 143, 116, 116, 116, 116, 143, 115, 143, 0, 117,
-
- 117, 0, 117, 0, 0, 117, 0, 117, 118, 117,
- 0, 0, 0, 117, 117, 0, 117, 118, 117, 0,
- 0, 0, 0, 0, 0, 0, 117, 117, 117, 117,
- 117, 0, 143, 143, 143, 143, 52, 63, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 71, 143, 143, 44, 83, 84, 143, 143, 143, 143,
- 54, 141, 137, 143, 139, 138, 142, 143, 0, 143,
- 143, 116, 143, 143, 143, 116, 143, 115, 143, 0,
- 0, 117, 117, 117, 117, 117, 117, 0, 0, 118,
- 117, 117, 117, 0, 0, 117, 117, 117, 117, 117,
-
- 0, 0, 0, 0, 0, 0, 0, 117, 117, 117,
- 117, 117, 0, 0, 0, 0, 0, 117, 117, 0,
- 117, 0, 117, 0, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 120, 119, 143,
- 143, 72, 143, 143, 143, 140, 136, 143, 143, 116,
- 116, 116, 116, 143, 115, 143, 0, 117, 117, 0,
- 117, 117, 0, 117, 0, 0, 117, 0, 117, 118,
- 117, 0, 0, 0, 117, 117, 0, 117, 118, 117,
- 0, 0, 0, 0, 0, 117, 117, 0, 117, 118,
- 117, 0, 117, 117, 0, 0, 0, 0, 0, 0,
-
- 0, 117, 117, 117, 117, 117, 0, 65, 143, 55,
- 125, 132, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 66, 49, 143, 143, 0, 143, 143, 143, 143,
- 143, 115, 143, 0, 0, 117, 117, 117, 117, 117,
- 117, 117, 117, 117, 0, 0, 118, 117, 117, 117,
- 0, 0, 117, 117, 117, 117, 117, 0, 0, 0,
- 0, 0, 0, 0, 117, 117, 117, 117, 117, 0,
- 117, 117, 0, 0, 0, 0, 0, 0, 0, 117,
- 117, 117, 117, 117, 0, 0, 0, 0, 0, 0,
- 117, 117, 0, 117, 0, 117, 0, 89, 143, 143,
-
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 51,
- 114, 114, 116, 116, 143, 115, 143, 0, 117, 117,
- 0, 117, 117, 0, 117, 117, 0, 117, 0, 114,
- 117, 0, 117, 118, 117, 0, 0, 0, 117, 117,
- 0, 117, 118, 117, 0, 0, 0, 0, 0, 117,
- 117, 0, 117, 118, 117, 0, 0, 0, 0, 0,
- 0, 117, 117, 0, 117, 118, 117, 0, 117, 117,
- 117, 0, 0, 0, 0, 0, 0, 0, 117, 117,
- 117, 117, 117, 0, 143, 143, 143, 143, 143, 143,
- 143, 143, 130, 143, 90, 114, 114, 116, 143, 114,
-
- 114, 0, 0, 117, 117, 117, 117, 117, 117, 117,
- 117, 117, 117, 117, 117, 0, 114, 118, 117, 117,
- 117, 0, 0, 117, 117, 117, 117, 117, 0, 0,
- 0, 0, 0, 0, 0, 117, 117, 117, 117, 117,
- 0, 117, 117, 0, 0, 0, 0, 0, 0, 0,
- 117, 117, 117, 117, 117, 0, 117, 117, 117, 0,
- 0, 0, 0, 0, 0, 0, 117, 117, 117, 117,
- 117, 0, 0, 0, 0, 0, 0, 117, 117, 0,
- 117, 0, 117, 0, 143, 143, 143, 134, 143, 143,
- 143, 143, 143, 143, 143, 122, 116, 143, 115, 0,
-
- 117, 117, 0, 117, 117, 0, 117, 117, 0, 117,
- 117, 0, 117, 0, 0, 0, 117, 0, 0, 117,
- 118, 117, 0, 0, 0, 117, 117, 0, 117, 118,
- 117, 0, 0, 0, 0, 0, 117, 117, 0, 117,
- 118, 117, 0, 0, 0, 0, 0, 0, 117, 117,
- 0, 117, 118, 117, 0, 0, 0, 0, 0, 0,
- 117, 117, 0, 117, 118, 117, 0, 117, 117, 117,
- 0, 0, 0, 0, 0, 0, 0, 117, 117, 117,
- 117, 117, 0, 143, 143, 143, 143, 124, 143, 143,
- 143, 128, 143, 114, 0, 0, 117, 117, 117, 117,
-
- 117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
- 117, 0, 0, 0, 118, 0, 0, 117, 0, 0,
- 117, 117, 117, 0, 0, 0, 0, 0, 0, 0,
- 117, 117, 117, 0, 117, 117, 0, 0, 0, 0,
- 0, 0, 0, 117, 117, 117, 0, 117, 117, 117,
- 0, 0, 0, 0, 0, 0, 0, 117, 117, 117,
- 0, 117, 117, 117, 0, 0, 0, 0, 0, 0,
- 0, 117, 117, 117, 0, 0, 0, 0, 0, 0,
- 117, 117, 0, 117, 0, 117, 0, 121, 133, 135,
- 129, 143, 143, 143, 143, 0, 0, 117, 0, 117,
-
- 0, 117, 117, 0, 117, 117, 0, 117, 117, 0,
- 117, 117, 0, 117, 0, 0, 0, 0, 117, 117,
- 0, 117, 0, 0, 117, 117, 117, 0, 0, 0,
- 0, 117, 117, 117, 0, 0, 0, 0, 0, 117,
- 117, 117, 0, 0, 0, 0, 0, 117, 117, 117,
- 0, 0, 0, 0, 0, 117, 117, 117, 117, 117,
- 117, 0, 0, 0, 0, 0, 0, 0, 117, 117,
- 117, 0, 143, 143, 143, 143, 0, 0, 0, 117,
- 117, 117, 117, 117, 117, 0, 0, 0, 0, 117,
- 117, 0, 0, 0, 0, 117, 117, 117, 0, 0,
-
- 0, 0, 0, 117, 117, 117, 117, 0, 0, 0,
- 0, 0, 117, 117, 117, 117, 0, 0, 0, 0,
- 0, 117, 117, 117, 117, 0, 0, 0, 0, 0,
- 117, 0, 0, 0, 0, 0, 117, 117, 117, 143,
- 143, 143, 131, 117, 117, 117, 117, 117, 117, 117,
- 117, 0, 0, 0, 0, 117, 117, 0, 0, 117,
- 0, 0, 0, 117, 0, 0, 0, 117, 0, 0,
- 0, 117, 0, 0, 0, 117, 117, 117, 117, 0,
- 0, 0, 0, 0, 117, 126, 143, 123, 117, 0,
- 0, 117, 117, 0, 117, 117, 117, 0, 117, 117,
-
- 117, 0, 117, 117, 117, 0, 117, 117, 117, 0,
- 0, 0, 0, 117, 127, 117, 117, 0, 0, 0,
- 0, 0, 0, 117, 117, 117, 0, 0, 117, 117,
- 117, 117, 117, 0, 117, 117, 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, 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,
+ 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, 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,
+ 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,
+ 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, 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,
+ 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,
+ 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, 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,
+ 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,
+ 0, 0, 0, 125, 125, 125, 0, 0, 0, 0,
+ 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, 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,
+
+ 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
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -567,13 +548,13 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 5, 1, 1, 6, 1, 7, 1, 8,
- 8, 9, 9, 1, 10, 11, 9, 12, 13, 14,
+ 1, 2, 5, 1, 1, 6, 7, 8, 1, 9,
+ 9, 7, 7, 1, 10, 11, 7, 12, 13, 14,
15, 16, 17, 18, 17, 17, 17, 19, 1, 20,
21, 22, 1, 1, 23, 23, 23, 23, 23, 23,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 25, 24, 24,
- 26, 27, 26, 1, 28, 1, 29, 30, 31, 32,
+ 26, 27, 26, 7, 28, 1, 29, 30, 31, 32,
33, 34, 35, 36, 37, 24, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
@@ -596,7 +577,7 @@ static yyconst flex_int32_t yy_ec[256] =
static yyconst flex_int32_t yy_meta[54] =
{ 0,
- 1, 2, 2, 1, 2, 1, 3, 2, 1, 4,
+ 1, 2, 2, 1, 2, 1, 1, 3, 2, 4,
5, 6, 6, 6, 6, 6, 6, 6, 7, 3,
3, 3, 8, 4, 9, 3, 1, 4, 8, 8,
8, 8, 8, 8, 4, 4, 4, 4, 4, 4,
@@ -604,228 +585,231 @@ static yyconst flex_int32_t yy_meta[54] =
9, 4, 3
} ;
-static yyconst flex_int16_t yy_base[1898] =
+static yyconst flex_int16_t yy_base[1930] =
{ 0,
- 0, 0, 3858, 53, 7396, 7396, 54, 3836, 60, 3849,
- 7396, 82, 7396, 100, 31, 152, 47, 3834, 49, 169,
- 211, 169, 61, 44, 126, 61, 30, 63, 76, 3811,
- 215, 218, 160, 32, 166, 117, 171, 228, 145, 3820,
- 229, 3812, 3782, 276, 7396, 0, 7396, 292, 315, 339,
- 3815, 363, 0, 370, 0, 404, 7396, 7396, 7396, 7396,
- 7396, 274, 292, 0, 3788, 3785, 3799, 0, 3797, 3785,
- 3798, 3781, 3769, 3763, 3764, 3767, 3765, 3764, 3773, 3743,
- 3756, 3739, 324, 3749, 3752, 3736, 3734, 3747, 3719, 3724,
- 3722, 82, 3726, 3721, 3729, 148, 229, 0, 0, 37,
-
- 123, 3717, 3726, 167, 3695, 3693, 3696, 3699, 3689, 3695,
- 3686, 3671, 3677, 0, 3685, 0, 3668, 3674, 3667, 3668,
- 3668, 3653, 160, 3664, 3647, 3658, 3650, 56, 3645, 216,
- 3628, 126, 3627, 3639, 0, 3625, 0, 3624, 3622, 3627,
- 3634, 3610, 3601, 3616, 7396, 7396, 429, 453, 212, 494,
- 518, 542, 3625, 549, 3631, 573, 269, 3621, 3581, 3586,
- 3577, 0, 0, 3582, 0, 3591, 3585, 3574, 3573, 3559,
- 3556, 3557, 3564, 0, 0, 3558, 3548, 0, 3560, 3540,
- 3528, 3542, 3545, 3526, 3528, 3541, 3526, 3525, 0, 3509,
- 3503, 0, 0, 3506, 3496, 0, 3507, 0, 3504, 3492,
-
- 3499, 0, 0, 3474, 0, 3483, 3491, 203, 3473, 0,
- 3469, 3485, 0, 3480, 0, 3483, 0, 3456, 3440, 3434,
- 3437, 3441, 3433, 3429, 0, 3427, 3440, 0, 3414, 0,
- 3413, 0, 0, 0, 3410, 0, 171, 167, 3421, 0,
- 0, 3411, 0, 3408, 3409, 613, 3439, 636, 660, 3423,
- 667, 476, 267, 691, 3414, 715, 3412, 3410, 723, 288,
- 3409, 3407, 483, 764, 787, 3391, 0, 0, 3367, 327,
- 3370, 3375, 0, 0, 0, 3371, 0, 3370, 3371, 3340,
- 0, 3340, 0, 3334, 3334, 0, 590, 3328, 0, 0,
- 3334, 3307, 3308, 0, 0, 3298, 0, 0, 0, 0,
-
- 3313, 3303, 3291, 0, 3284, 3287, 3303, 3276, 3271, 3268,
- 3248, 0, 3246, 0, 3239, 0, 192, 0, 0, 3232,
- 3227, 715, 3218, 0, 0, 0, 812, 836, 312, 877,
- 3245, 3244, 381, 900, 924, 948, 3235, 955, 597, 3234,
- 3231, 978, 752, 1002, 1025, 3230, 0, 3219, 400, 403,
- 1049, 3197, 1073, 339, 3196, 3203, 3168, 0, 0, 0,
- 0, 3162, 0, 3161, 3159, 3142, 3141, 0, 3156, 3140,
- 1092, 0, 3126, 3115, 3133, 0, 3108, 0, 3111, 3102,
- 0, 0, 3101, 3080, 237, 3079, 3097, 268, 3072, 0,
- 3050, 3039, 3053, 3046, 3041, 3050, 3043, 3031, 3032, 3025,
-
- 3022, 3036, 1129, 3051, 1152, 1176, 3039, 1183, 859, 305,
- 1207, 340, 1247, 1270, 1294, 3009, 3008, 1302, 364, 3007,
- 3005, 3003, 3002, 1343, 373, 3001, 2976, 491, 607, 1384,
- 2975, 1408, 404, 2974, 2981, 2971, 866, 0, 347, 2970,
- 1096, 1449, 1472, 2969, 0, 0, 2926, 2942, 2923, 0,
- 2931, 2914, 2920, 2933, 2918, 2919, 2918, 407, 2901, 411,
- 2901, 2909, 2897, 2893, 0, 2883, 2893, 2881, 2886, 2853,
- 2842, 2841, 0, 0, 2844, 0, 2838, 2830, 2843, 2827,
- 2821, 2817, 2811, 2809, 2813, 2818, 2817, 1497, 1521, 405,
- 1562, 2825, 2824, 609, 1586, 1610, 1617, 1641, 2815, 1648,
-
- 1672, 1695, 2814, 2813, 2811, 1718, 1103, 1742, 1765, 2810,
- 0, 1230, 0, 461, 2809, 1237, 1789, 1812, 2794, 0,
- 734, 761, 2801, 462, 781, 812, 1836, 2792, 1860, 428,
- 2791, 2798, 381, 2761, 2766, 2763, 0, 0, 2753, 2755,
- 2741, 2741, 2753, 2735, 2734, 2741, 2719, 2720, 2731, 2730,
- 0, 2721, 2714, 0, 0, 0, 2727, 2723, 2713, 2700,
- 0, 0, 0, 2704, 0, 0, 0, 2693, 1900, 2728,
- 1923, 1947, 2725, 1954, 324, 1978, 2002, 2009, 2033, 2716,
- 2715, 2041, 452, 2700, 2082, 488, 2699, 2698, 2697, 2696,
- 2123, 489, 2694, 874, 894, 2164, 2693, 2188, 493, 2692,
-
- 2684, 1123, 1125, 2683, 2682, 1246, 1312, 2229, 2673, 2253,
- 494, 2672, 2677, 1326, 0, 1333, 0, 527, 2668, 1366,
- 2294, 2317, 2653, 0, 2340, 428, 79, 255, 237, 617,
- 546, 586, 2624, 362, 522, 547, 379, 2623, 2622, 1124,
- 2621, 2619, 1242, 849, 473, 2618, 2617, 2378, 2415, 2451,
- 2487, 546, 2511, 588, 2519, 2543, 2629, 2550, 2574, 2597,
- 2628, 2621, 2644, 2627, 2626, 2624, 2667, 1373, 2691, 2714,
- 2622, 0, 1431, 0, 675, 2606, 1438, 2738, 2761, 2605,
- 0, 1544, 0, 1551, 0, 676, 2604, 1883, 2785, 2808,
- 2603, 0, 637, 1890, 2610, 1381, 1446, 2608, 2607, 1466,
-
- 1497, 2832, 2598, 2856, 638, 2582, 2589, 567, 682, 591,
- 612, 763, 1246, 2051, 1383, 628, 803, 805, 2078, 683,
- 829, 761, 828, 2076, 2080, 2898, 830, 2921, 892, 2944,
- 2109, 2968, 2992, 2580, 2579, 3000, 737, 2577, 3041, 873,
- 2576, 3082, 876, 2575, 2559, 2558, 2557, 3123, 897, 2556,
- 1559, 1689, 3164, 2555, 3188, 901, 2553, 2560, 1899, 2051,
- 2559, 2558, 2052, 2058, 3229, 2528, 3253, 924, 2527, 2534,
- 925, 2146, 2533, 2118, 2119, 2532, 2530, 2120, 2140, 3294,
- 2521, 3318, 926, 2520, 2527, 0, 2211, 0, 2218, 0,
- 732, 2496, 2276, 3359, 3382, 2495, 0, 918, 970, 971,
-
- 972, 1899, 996, 1448, 1017, 1018, 2271, 1042, 1561, 1043,
- 3407, 3430, 3454, 998, 3494, 3518, 3542, 2494, 3549, 3573,
- 3596, 2493, 3620, 3643, 2492, 3667, 3690, 2490, 2489, 2488,
- 3713, 2363, 3737, 3760, 2487, 0, 2401, 0, 1011, 2440,
- 2438, 3784, 3807, 2439, 0, 2458, 0, 2465, 0, 1058,
- 2438, 2472, 3831, 3854, 2424, 0, 0, 2479, 0, 2879,
- 0, 1082, 2423, 2886, 3878, 3901, 2422, 0, 0, 1049,
- 3023, 2429, 2161, 2226, 2378, 2351, 2290, 2291, 3925, 2342,
- 3949, 1072, 2341, 2348, 2293, 2354, 2355, 2122, 1123, 2228,
- 2356, 1066, 2357, 1198, 1121, 1145, 1199, 3991, 4015, 4024,
-
- 1200, 2326, 2325, 4042, 1102, 2324, 4083, 1105, 2320, 4124,
- 1152, 2319, 4165, 1153, 2318, 2303, 2301, 4205, 4229, 1154,
- 2300, 2409, 2410, 4270, 2281, 4294, 1182, 2278, 2285, 2591,
- 2638, 2284, 2268, 2894, 2895, 4335, 2256, 4359, 1241, 2254,
- 2244, 1243, 3030, 2243, 2898, 3038, 2242, 2239, 3051, 3057,
- 4400, 2230, 4424, 1244, 2197, 2204, 0, 1247, 3105, 2203,
- 3058, 3079, 2199, 2198, 3099, 3118, 4465, 2170, 4489, 1271,
- 2169, 2174, 0, 3146, 0, 3211, 0, 1161, 2154, 3218,
- 4530, 4553, 2149, 0, 3263, 3264, 3328, 1201, 2394, 2100,
- 1402, 2395, 2270, 1464, 1488, 1342, 4578, 4602, 4611, 2130,
-
- 4628, 4652, 4675, 2100, 4699, 4722, 2070, 4746, 4769, 2068,
- 4793, 4816, 2065, 2063, 4840, 1384, 2062, 2061, 3281, 4881,
- 2059, 2049, 0, 3345, 0, 1530, 2046, 3477, 4905, 2018,
- 2016, 0, 3484, 0, 3972, 0, 1571, 2015, 3979, 4929,
- 2014, 2011, 0, 0, 4031, 0, 4065, 0, 1594, 1981,
- 4072, 4953, 1980, 1906, 0, 0, 4106, 0, 4113, 0,
- 1595, 1863, 4147, 4977, 1844, 1819, 0, 0, 1385, 4154,
- 1822, 3120, 3140, 1806, 1802, 3159, 3161, 5001, 1771, 5025,
- 1448, 1770, 1756, 1490, 1664, 1665, 1515, 1666, 1736, 4163,
- 1687, 1711, 2396, 5067, 1747, 5084, 5108, 1556, 1725, 5149,
-
- 1561, 1724, 5190, 1586, 1723, 5231, 1616, 1719, 5272, 1617,
- 1704, 1700, 4191, 5313, 1626, 1620, 0, 1619, 3226, 3264,
- 5337, 1617, 1569, 1576, 3289, 3328, 1572, 1536, 3355, 3376,
- 5361, 1521, 1505, 1512, 1618, 4252, 1508, 3407, 3493, 1483,
- 1464, 3590, 3637, 5385, 1451, 1450, 1418, 0, 1619, 4259,
- 1397, 3684, 4175, 1394, 1393, 4176, 4200, 5409, 1352, 1350,
- 1356, 0, 1647, 4317, 1354, 4204, 4267, 1353, 1319, 4311,
- 4330, 5433, 1310, 1309, 1315, 0, 4382, 0, 4389, 0,
- 1751, 1305, 4447, 5457, 0, 1271, 0, 1735, 1758, 1759,
- 1781, 1782, 1969, 4483, 4499, 5481, 1648, 0, 1254, 5522,
-
- 0, 1248, 5546, 0, 1216, 5570, 0, 1212, 5594, 0,
- 1183, 5618, 0, 1109, 4332, 4397, 5642, 1107, 1103, 1076,
- 1064, 1028, 4454, 0, 1821, 1007, 983, 4516, 0, 4618,
- 0, 1845, 964, 960, 0, 4863, 0, 4870, 0, 1869,
- 955, 925, 0, 5048, 0, 5055, 0, 1909, 924, 902,
- 0, 5074, 0, 5131, 0, 1932, 885, 80, 0, 1671,
- 5138, 180, 4462, 4526, 187, 225, 4547, 4627, 5666, 280,
- 0, 301, 2358, 1783, 1806, 1829, 5690, 299, 340, 0,
- 0, 0, 0, 0, 0, 5172, 0, 1962, 431, 496,
- 0, 4669, 4716, 511, 532, 0, 1811, 5179, 559, 4763,
-
- 4810, 563, 605, 0, 0, 1833, 5213, 606, 4878, 5083,
- 628, 630, 0, 0, 1835, 5220, 680, 5228, 5241, 702,
- 704, 0, 0, 1836, 5255, 705, 5269, 5282, 707, 708,
- 0, 0, 5296, 0, 5504, 0, 1963, 728, 0, 3078,
- 2959, 2156, 1916, 0, 7396, 0, 0, 0, 0, 0,
- 0, 5310, 5498, 739, 773, 0, 7396, 5512, 0, 7396,
- 0, 5713, 0, 7396, 0, 5720, 0, 7396, 0, 5727,
- 0, 7396, 0, 5734, 0, 7396, 0, 1894, 5741, 779,
- 5749, 5750, 796, 2017, 0, 1970, 3336, 2057, 0, 5750,
- 0, 1896, 5764, 798, 0, 1897, 5771, 800, 0, 1924,
-
- 5778, 803, 0, 1951, 5790, 844, 0, 1953, 5797, 851,
- 0, 5804, 0, 7396, 2180, 1978, 5811, 853, 0, 0,
- 0, 0, 0, 0, 1980, 5818, 886, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 7396, 5836, 5844, 5848,
- 5851, 5854, 5857, 5860, 5863, 5866, 5869, 5872, 5875, 5878,
- 5881, 5884, 5887, 5890, 5893, 5896, 5900, 5904, 5907, 5910,
- 5913, 5916, 5919, 5922, 5925, 5928, 5932, 5936, 5939, 5942,
- 5946, 5948, 5951, 5954, 5957, 5960, 5963, 5966, 5969, 5972,
- 5976, 5978, 5981, 5985, 5990, 5994, 5997, 6001, 6004, 6007,
- 6010, 6013, 6016, 6019, 6022, 6026, 6030, 6033, 6037, 6041,
-
- 6046, 6050, 6052, 6056, 6059, 6063, 6066, 6069, 6073, 6075,
- 6078, 6081, 6084, 6087, 6090, 6093, 6096, 6099, 6102, 6106,
- 6108, 6111, 6114, 6117, 6121, 6123, 6126, 6129, 6134, 6138,
- 6143, 6147, 6149, 6153, 6156, 6160, 6165, 6169, 6172, 6175,
- 6178, 6181, 6184, 6187, 6190, 6194, 6198, 6201, 6205, 6209,
- 6214, 6218, 6220, 6224, 6227, 6231, 6234, 6239, 6243, 6248,
- 6252, 6254, 6258, 6261, 6265, 6268, 6271, 6274, 6278, 6280,
- 6283, 6288, 6292, 6295, 6298, 6301, 6304, 6307, 6310, 6313,
- 6316, 6320, 6322, 6325, 6328, 6331, 6335, 6337, 6340, 6343,
- 6346, 6349, 6353, 6355, 6358, 6361, 6364, 6369, 6373, 6378,
-
- 6382, 6384, 6388, 6391, 6395, 6400, 6404, 6407, 6410, 6413,
- 6416, 6419, 6422, 6425, 6429, 6433, 6436, 6440, 6444, 6449,
- 6453, 6455, 6459, 6462, 6466, 6469, 6474, 6478, 6483, 6487,
- 6489, 6493, 6496, 6500, 6503, 6506, 6511, 6515, 6520, 6524,
- 6526, 6530, 6533, 6537, 6540, 6543, 6546, 6550, 6552, 6555,
- 6560, 6564, 6567, 6570, 6573, 6576, 6579, 6582, 6585, 6588,
- 6591, 6594, 6597, 6601, 6603, 6606, 6609, 6612, 6615, 6619,
- 6621, 6624, 6627, 6630, 6633, 6636, 6640, 6642, 6645, 6648,
- 6651, 6654, 6657, 6661, 6663, 6666, 6669, 6672, 6675, 6680,
- 6684, 6689, 6693, 6695, 6699, 6702, 6706, 6711, 6715, 6718,
-
- 6721, 6724, 6727, 6730, 6733, 6736, 6739, 6742, 6746, 6750,
- 6753, 6757, 6761, 6766, 6770, 6772, 6776, 6779, 6783, 6786,
- 6791, 6795, 6800, 6804, 6806, 6810, 6813, 6817, 6820, 6823,
- 6828, 6832, 6837, 6841, 6843, 6847, 6850, 6854, 6857, 6860,
- 6865, 6869, 6874, 6878, 6880, 6884, 6887, 6891, 6894, 6897,
- 6900, 6904, 6906, 6909, 6912, 6917, 6921, 6924, 6927, 6930,
- 6933, 6936, 6939, 6942, 6945, 6948, 6951, 6954, 6958, 6962,
- 6965, 6968, 6972, 6975, 6978, 6982, 6984, 6987, 6990, 6994,
- 6996, 6999, 7002, 7005, 7009, 7011, 7014, 7017, 7020, 7024,
- 7026, 7029, 7032, 7035, 7039, 7041, 7044, 7047, 7052, 7056,
-
- 7061, 7065, 7067, 7071, 7074, 7078, 7083, 7087, 7090, 7093,
- 7096, 7099, 7102, 7105, 7108, 7111, 7115, 7117, 7120, 7124,
- 7129, 7133, 7134, 7137, 7142, 7146, 7151, 7155, 7156, 7159,
- 7162, 7167, 7171, 7176, 7180, 7181, 7184, 7187, 7192, 7196,
- 7201, 7205, 7206, 7209, 7212, 7217, 7221, 7226, 7230, 7231,
- 7234, 7237, 7240, 7244, 7246, 7251, 7255, 7258, 7261, 7264,
- 7267, 7270, 7273, 7277, 7282, 7286, 7287, 7290, 7293, 7296,
- 7299, 7302, 7305, 7308, 7311, 7314, 7317, 7322, 7326, 7329,
- 7332, 7335, 7339, 7343, 7347, 7351, 7355, 7358, 7361, 7365,
- 7368, 7371, 7374, 7377, 7380, 7384, 7387
-
+ 0, 0, 3903, 53, 7432, 7432, 57, 3881, 64, 81,
+ 3893, 7432, 7432, 99, 30, 151, 46, 3879, 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
} ;
-static yyconst flex_int16_t yy_def[1898] =
+static yyconst flex_int16_t yy_def[1930] =
{ 0,
- 1437, 1, 1437, 1437, 1437, 1437, 1437, 1437, 1438, 1437,
- 1437, 1437, 1437, 1437, 14, 1437, 1437, 1437, 1437, 14,
- 20, 1439, 20, 20, 20, 20, 20, 20, 21, 21,
+ 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,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 1437, 1437, 1437, 1440, 1437, 21, 21, 20,
- 1441, 50, 21, 21, 21, 1437, 1437, 1437, 1437, 1437,
- 1437, 49, 1439, 1439, 52, 52, 52, 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, 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,
@@ -834,11 +818,11 @@ static yyconst flex_int16_t yy_def[1898] =
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, 1437, 1437, 21, 21, 148, 21,
- 21, 151, 1442, 1437, 54, 1437, 156, 1443, 21, 21,
- 152, 21, 21, 21, 152, 21, 21, 21, 21, 21,
- 21, 152, 21, 21, 21, 21, 21, 21, 21, 152,
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,
+ 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,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
@@ -846,1842 +830,1847 @@ static yyconst flex_int16_t yy_def[1898] =
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, 248, 249, 152, 1444, 254, 1445, 1446, 1437, 259,
- 1447, 1448, 1437, 1437, 1437, 1449, 1450, 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, 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, 328, 21,
- 249, 251, 249, 251, 251, 335, 1451, 1437, 334, 1452,
- 1453, 1437, 1437, 1437, 1437, 1454, 1455, 1456, 1457, 1457,
- 1437, 1458, 1437, 353, 1459, 1450, 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,
+ 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,
+ 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, 405, 406,
- 406, 411, 405, 335, 414, 1460, 1461, 1437, 418, 1462,
- 1437, 1463, 1464, 1437, 424, 1465, 1466, 1467, 1467, 1437,
- 1468, 1437, 432, 1469, 1455, 1437, 1437, 1470, 1471, 1437,
- 1437, 1437, 1437, 1472, 1473, 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, 489,
- 21, 406, 408, 406, 406, 495, 414, 497, 1474, 1437,
+ 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,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 1437, 1437, 1475, 1476, 1477, 1437, 1437, 1437, 1437, 1478,
- 1479, 1437, 1480, 1481, 1437, 1437, 1437, 1437, 1482, 1483,
- 1484, 1484, 1470, 1471, 1485, 1485, 1437, 1486, 1437, 529,
- 1487, 1488, 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, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 572, 572, 576, 497, 578, 1489,
- 1490, 1437, 582, 1491, 1437, 585, 1492, 1437, 1493, 1494,
- 1437, 591, 1495, 1496, 1496, 1437, 1497, 1437, 598, 1498,
-
- 1499, 1500, 1500, 1501, 1502, 1503, 1503, 1437, 1504, 1437,
- 610, 1505, 1506, 1437, 1507, 1437, 1508, 1509, 1437, 1437,
- 1437, 1437, 1510, 1511, 579, 625, 625, 625, 625, 625,
- 625, 625, 625, 625, 625, 625, 625, 625, 625, 625,
- 625, 625, 625, 625, 625, 625, 625, 625, 625, 625,
- 650, 650, 650, 625, 650, 655, 1512, 1437, 1437, 1437,
- 1513, 1437, 1437, 1514, 1515, 1516, 1437, 1437, 1437, 1437,
- 1517, 1518, 1437, 1519, 1520, 1437, 1437, 1437, 1437, 1521,
- 1522, 1437, 1523, 1437, 1524, 1525, 1437, 1437, 1437, 1437,
- 1526, 1527, 1528, 1437, 1529, 1530, 1530, 1531, 1532, 1533,
-
- 1533, 1437, 1534, 1437, 704, 1535, 1536, 1537, 1537, 1537,
- 1537, 1537, 1537, 1537, 1537, 1537, 1537, 1537, 1537, 1537,
- 1537, 1537, 1537, 1537, 1537, 1537, 1537, 726, 1537, 726,
- 730, 730, 732, 1538, 1539, 1437, 736, 1540, 1437, 739,
- 1541, 1437, 742, 1542, 1437, 1543, 1544, 1437, 748, 1545,
- 1546, 1546, 1437, 1547, 1437, 755, 1548, 1549, 1550, 1550,
- 1551, 1552, 1553, 1553, 1437, 1554, 1437, 767, 1555, 1556,
- 1557, 1437, 1558, 1559, 1559, 1560, 1561, 1562, 1562, 1437,
- 1563, 1437, 782, 1564, 1565, 1566, 1437, 1567, 1437, 1568,
- 1569, 1437, 1437, 1437, 1437, 1570, 1571, 1572, 1572, 1572,
-
- 1572, 1572, 1572, 1572, 1572, 1572, 1572, 1572, 1572, 1572,
- 1572, 811, 811, 813, 811, 811, 816, 1573, 1437, 1437,
- 1437, 1574, 1437, 1437, 1575, 1437, 1437, 1576, 1577, 1578,
- 1437, 1437, 1437, 1437, 1579, 1580, 1437, 1581, 1582, 1437,
- 1437, 1437, 1437, 1583, 1584, 1437, 1585, 1437, 1586, 1587,
- 1437, 1437, 1437, 1437, 1588, 1589, 1590, 1437, 1591, 1437,
- 1592, 1593, 1437, 1437, 1437, 1437, 1594, 1595, 1596, 1597,
- 1437, 1598, 1599, 1599, 1600, 1601, 1602, 1602, 1437, 1603,
- 1437, 881, 1604, 1605, 1606, 1606, 1606, 1606, 1606, 1606,
- 1606, 1606, 1606, 1606, 1606, 1606, 1606, 1606, 898, 1606,
-
- 1606, 1607, 1608, 1437, 904, 1609, 1437, 907, 1610, 1437,
- 910, 1611, 1437, 913, 1612, 1437, 1613, 1437, 1437, 919,
- 1614, 1615, 1615, 1437, 1616, 1437, 926, 1617, 1618, 1619,
- 1619, 1620, 1621, 1622, 1622, 1437, 1623, 1437, 938, 1624,
- 1625, 1626, 1437, 1627, 1628, 1628, 1629, 1630, 1631, 1631,
- 1437, 1632, 1437, 953, 1633, 1634, 1635, 1636, 1437, 1637,
- 1638, 1638, 1639, 1640, 1641, 1641, 1437, 1642, 1437, 969,
- 1643, 1644, 1645, 1437, 1646, 1437, 1647, 1648, 1437, 1437,
- 1437, 1437, 1649, 1650, 1651, 1651, 1651, 1651, 1651, 1651,
- 1651, 1651, 1651, 1651, 1651, 1651, 1651, 997, 1651, 1652,
-
- 1437, 1437, 1437, 1653, 1437, 1437, 1654, 1437, 1437, 1655,
- 1437, 1437, 1656, 1657, 1437, 1015, 1658, 1659, 1437, 1437,
- 1660, 1661, 1662, 1437, 1663, 1664, 1437, 1437, 1437, 1665,
- 1666, 1667, 1437, 1668, 1437, 1669, 1670, 1437, 1437, 1437,
- 1671, 1672, 1673, 1674, 1437, 1675, 1437, 1676, 1677, 1437,
- 1437, 1437, 1678, 1679, 1680, 1681, 1437, 1682, 1437, 1683,
- 1684, 1437, 1437, 1437, 1685, 1686, 1687, 1688, 1689, 1437,
- 1690, 1691, 1691, 1692, 1693, 1694, 1694, 1437, 1695, 1437,
- 1080, 1696, 1697, 1698, 1698, 1698, 1698, 1698, 1698, 1698,
- 1698, 1698, 1698, 1698, 1699, 1437, 1437, 1097, 1700, 1437,
-
- 1100, 1701, 1437, 1103, 1702, 1437, 1106, 1703, 1437, 1109,
- 1704, 1437, 1437, 1437, 1705, 1706, 1707, 1708, 1709, 1709,
- 1437, 1710, 1711, 1712, 1713, 1713, 1714, 1715, 1716, 1716,
- 1437, 1717, 1718, 1719, 1720, 1437, 1721, 1722, 1722, 1723,
- 1724, 1725, 1725, 1437, 1726, 1727, 1728, 1729, 1730, 1437,
- 1731, 1732, 1732, 1733, 1734, 1735, 1735, 1437, 1736, 1737,
- 1738, 1739, 1740, 1437, 1741, 1742, 1742, 1743, 1744, 1745,
- 1745, 1437, 1746, 1747, 1748, 1749, 1437, 1750, 1437, 1751,
- 1752, 1437, 1437, 1437, 1753, 1754, 1755, 1756, 1756, 1756,
- 1756, 1756, 1756, 1756, 1756, 1437, 1196, 1757, 1758, 1437,
-
- 1759, 1760, 1437, 1761, 1762, 1437, 1763, 1764, 1437, 1765,
- 1766, 1437, 1767, 1768, 1769, 1769, 1437, 1770, 1771, 1772,
- 1773, 1774, 1437, 1775, 1776, 1437, 1777, 1437, 1778, 1437,
- 1779, 1780, 1437, 1781, 1782, 1437, 1783, 1437, 1784, 1785,
- 1437, 1786, 1787, 1437, 1788, 1437, 1789, 1790, 1437, 1791,
- 1792, 1437, 1793, 1437, 1794, 1795, 1437, 1796, 1797, 1798,
- 1437, 1799, 1800, 1800, 1801, 1802, 1803, 1803, 1437, 1804,
- 1805, 1806, 1807, 1807, 1807, 1807, 1437, 1808, 1809, 1810,
- 1811, 1812, 1813, 1814, 1815, 1437, 1816, 1817, 1437, 1818,
- 1819, 1820, 1820, 1821, 1822, 1823, 1824, 1437, 1825, 1826,
-
- 1826, 1827, 1828, 1829, 1830, 1831, 1437, 1832, 1833, 1833,
- 1834, 1835, 1836, 1837, 1838, 1437, 1839, 1840, 1840, 1841,
- 1842, 1843, 1844, 1845, 1437, 1846, 1847, 1847, 1848, 1849,
- 1850, 1851, 1437, 1852, 1437, 1853, 1854, 1437, 1855, 1856,
- 1856, 1856, 1856, 1857, 1437, 1858, 1859, 1860, 1861, 1862,
- 1863, 1864, 1864, 1865, 1866, 1867, 1437, 1437, 1868, 1437,
- 1869, 1437, 1870, 1437, 1871, 1437, 1872, 1437, 1873, 1437,
- 1874, 1437, 1875, 1437, 1876, 1437, 1851, 1877, 1437, 1852,
- 1878, 1878, 1853, 1854, 1879, 1856, 1856, 1856, 1880, 1437,
- 1881, 1882, 1437, 1868, 1869, 1883, 1437, 1870, 1871, 1884,
-
- 1437, 1872, 1873, 1885, 1437, 1874, 1875, 1886, 1437, 1876,
- 1887, 1437, 1888, 1437, 1856, 1889, 1437, 1881, 1890, 1891,
- 1892, 1893, 1894, 1887, 1895, 1437, 1888, 1896, 1890, 1891,
- 1892, 1893, 1894, 1897, 1896, 1897, 0, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
-
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
-
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
-
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
-
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437
+ 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
} ;
-static yyconst flex_int16_t yy_nxt[7450] =
+static yyconst flex_int16_t yy_nxt[7486] =
{ 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 11,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 12,
13, 14, 15, 15, 15, 15, 15, 15, 16, 17,
- 18, 19, 20, 21, 21, 11, 22, 13, 23, 24,
+ 18, 19, 20, 21, 21, 12, 22, 13, 23, 24,
25, 26, 27, 28, 29, 30, 31, 21, 32, 33,
34, 35, 36, 21, 37, 38, 39, 40, 41, 42,
- 21, 21, 43, 44, 44, 53, 44, 44, 44, 44,
- 44, 44, 44, 44, 111, 44, 57, 58, 44, 60,
- 61, 44, 44, 112, 72, 83, 84, 197, 44, 44,
- 44, 53, 44, 198, 228, 44, 44, 44, 73, 65,
- 44, 66, 67, 79, 85, 74, 68, 80, 426, 86,
-
- 44, 69, 229, 81, 87, 70, 82, 71, 44, 48,
- 49, 50, 50, 50, 50, 50, 50, 50, 51, 710,
- 88, 187, 52, 53, 54, 53, 188, 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, 118, 75, 44, 234, 44, 119, 120,
- 44, 121, 122, 199, 76, 192, 235, 77, 200, 63,
- 56, 78, 63, 135, 63, 136, 322, 63, 44, 62,
- 52, 52, 52, 52, 52, 52, 52, 63, 105, 137,
- 1177, 222, 106, 53, 113, 63, 138, 1179, 193, 123,
-
- 323, 107, 108, 124, 223, 109, 114, 110, 115, 203,
- 116, 125, 204, 117, 205, 320, 126, 321, 127, 53,
- 55, 53, 53, 53, 53, 53, 53, 53, 53, 1437,
- 98, 99, 392, 53, 302, 980, 53, 393, 194, 53,
- 53, 53, 53, 53, 53, 90, 100, 303, 91, 92,
- 101, 93, 231, 94, 102, 95, 103, 96, 128, 140,
- 97, 232, 53, 104, 129, 195, 130, 141, 131, 469,
- 196, 142, 132, 143, 133, 134, 44, 53, 333, 44,
- 712, 44, 470, 53, 44, 150, 150, 150, 150, 150,
- 150, 150, 63, 1437, 44, 63, 711, 63, 1185, 473,
-
- 63, 53, 44, 147, 147, 147, 147, 147, 147, 147,
- 63, 1183, 1437, 474, 147, 53, 494, 1345, 63, 1437,
- 147, 147, 147, 147, 147, 147, 148, 149, 149, 149,
- 149, 149, 149, 176, 53, 652, 53, 150, 1437, 358,
- 359, 360, 361, 150, 150, 150, 150, 150, 150, 49,
- 151, 151, 151, 151, 151, 151, 151, 263, 1278, 362,
- 177, 152, 53, 1437, 53, 265, 178, 152, 152, 152,
- 152, 152, 152, 62, 152, 152, 152, 152, 152, 152,
- 152, 155, 155, 155, 155, 155, 155, 155, 1437, 1437,
- 53, 410, 155, 358, 359, 360, 361, 1437, 155, 155,
-
- 155, 155, 155, 155, 44, 251, 717, 44, 53, 44,
- 437, 720, 44, 437, 1437, 156, 157, 157, 157, 157,
- 157, 157, 44, 1437, 438, 53, 158, 1437, 1437, 53,
- 44, 251, 158, 158, 158, 158, 158, 158, 246, 543,
- 247, 247, 247, 247, 247, 247, 247, 546, 544, 1278,
- 438, 247, 1437, 1437, 1437, 53, 547, 247, 247, 247,
- 247, 247, 247, 248, 249, 249, 249, 249, 249, 249,
- 249, 343, 263, 709, 53, 250, 1437, 251, 1437, 502,
- 1437, 250, 250, 250, 250, 250, 250, 330, 330, 330,
- 330, 330, 330, 330, 349, 350, 350, 350, 350, 350,
-
- 350, 512, 1437, 251, 252, 250, 250, 250, 250, 250,
- 250, 250, 1437, 1437, 426, 513, 250, 1437, 1437, 53,
- 725, 1223, 250, 250, 250, 250, 250, 250, 253, 254,
- 254, 254, 254, 254, 254, 254, 255, 441, 1437, 1437,
- 256, 513, 1019, 1437, 1437, 443, 256, 256, 256, 256,
- 256, 256, 53, 256, 256, 256, 256, 256, 256, 256,
- 259, 260, 260, 260, 260, 260, 260, 261, 53, 1228,
- 574, 262, 718, 1230, 714, 719, 55, 262, 262, 262,
- 262, 262, 262, 263, 264, 264, 264, 264, 264, 264,
- 264, 265, 53, 53, 55, 266, 574, 267, 731, 371,
-
- 55, 266, 266, 266, 266, 266, 266, 372, 413, 413,
- 413, 413, 413, 413, 413, 1028, 1236, 512, 55, 575,
- 373, 55, 715, 267, 327, 327, 327, 327, 327, 327,
- 327, 1437, 53, 408, 53, 327, 374, 55, 1238, 55,
- 1039, 327, 327, 327, 327, 327, 327, 328, 329, 329,
- 329, 329, 329, 329, 713, 55, 799, 1437, 330, 408,
- 804, 786, 1437, 53, 330, 330, 330, 330, 330, 330,
- 248, 331, 331, 331, 331, 331, 331, 331, 332, 332,
- 332, 332, 332, 332, 332, 507, 516, 786, 1437, 332,
- 1244, 55, 55, 660, 663, 332, 332, 332, 332, 332,
-
- 332, 334, 335, 335, 335, 335, 335, 335, 335, 55,
- 55, 808, 1246, 336, 1051, 1252, 798, 1254, 1063, 336,
- 336, 336, 336, 336, 336, 339, 336, 336, 336, 336,
- 336, 336, 336, 343, 344, 344, 344, 344, 344, 344,
- 344, 345, 620, 396, 614, 346, 1185, 347, 397, 1286,
- 622, 346, 346, 346, 346, 346, 346, 398, 615, 399,
- 400, 1437, 401, 428, 429, 429, 429, 429, 429, 429,
- 55, 614, 55, 347, 263, 351, 351, 351, 351, 351,
- 351, 351, 265, 1113, 615, 1437, 352, 1437, 55, 1333,
- 55, 616, 352, 352, 352, 352, 352, 352, 353, 354,
-
- 354, 354, 354, 354, 354, 617, 1335, 800, 1358, 355,
- 1362, 1437, 55, 1366, 55, 355, 355, 355, 355, 355,
- 355, 403, 616, 404, 404, 404, 404, 404, 404, 404,
- 55, 617, 55, 805, 404, 806, 1437, 55, 55, 726,
- 404, 404, 404, 404, 404, 404, 405, 406, 406, 406,
- 406, 406, 406, 406, 1370, 55, 55, 55, 407, 809,
- 408, 1374, 1437, 1390, 407, 407, 407, 407, 407, 407,
- 491, 491, 491, 491, 491, 491, 491, 521, 522, 522,
- 522, 522, 522, 522, 673, 724, 408, 409, 407, 407,
- 407, 407, 407, 407, 407, 53, 1412, 1437, 674, 407,
-
- 1437, 55, 728, 1213, 673, 407, 407, 407, 407, 407,
- 407, 411, 412, 412, 412, 412, 412, 412, 1437, 55,
- 426, 1437, 413, 1437, 674, 1437, 1437, 55, 413, 413,
- 413, 413, 413, 413, 253, 414, 414, 414, 414, 414,
- 414, 414, 1210, 426, 1437, 55, 415, 1437, 1437, 857,
- 1437, 1437, 415, 415, 415, 415, 415, 415, 53, 415,
- 415, 415, 415, 415, 415, 415, 418, 419, 419, 419,
- 419, 419, 419, 1207, 1437, 857, 1437, 420, 426, 55,
- 55, 55, 1204, 420, 420, 420, 420, 420, 420, 424,
- 425, 425, 425, 425, 425, 425, 426, 55, 55, 55,
-
- 427, 426, 885, 886, 887, 55, 427, 427, 427, 427,
- 427, 427, 343, 430, 430, 430, 430, 430, 430, 430,
- 345, 668, 53, 55, 431, 1201, 55, 55, 889, 821,
- 431, 431, 431, 431, 431, 431, 432, 433, 433, 433,
- 433, 433, 433, 426, 55, 55, 426, 434, 53, 891,
- 892, 55, 55, 434, 434, 434, 434, 434, 434, 263,
- 439, 439, 439, 439, 439, 439, 439, 265, 677, 55,
- 55, 440, 894, 973, 1113, 55, 824, 440, 440, 440,
- 440, 440, 440, 441, 442, 442, 442, 442, 442, 442,
- 442, 443, 688, 55, 426, 444, 1437, 445, 994, 973,
-
- 827, 444, 444, 444, 444, 444, 444, 525, 526, 526,
- 526, 526, 526, 526, 594, 595, 595, 595, 595, 595,
- 595, 426, 1437, 445, 454, 1278, 1437, 1213, 455, 1437,
- 55, 456, 55, 682, 457, 682, 458, 459, 460, 461,
- 488, 488, 488, 488, 488, 488, 488, 683, 55, 1437,
- 55, 488, 1437, 990, 55, 1437, 721, 488, 488, 488,
- 488, 488, 488, 489, 490, 490, 490, 490, 490, 490,
- 53, 793, 55, 683, 491, 1437, 1437, 1437, 1437, 795,
- 491, 491, 491, 491, 491, 491, 405, 492, 492, 492,
- 492, 492, 492, 492, 493, 493, 493, 493, 493, 493,
-
- 493, 1210, 1437, 1437, 1437, 493, 1437, 55, 55, 55,
- 55, 493, 493, 493, 493, 493, 493, 410, 495, 495,
- 495, 495, 495, 495, 495, 55, 55, 55, 55, 496,
- 1207, 251, 1437, 996, 1204, 496, 496, 496, 496, 496,
- 496, 602, 603, 603, 603, 603, 603, 603, 606, 607,
- 607, 607, 607, 607, 607, 55, 684, 251, 496, 496,
- 496, 496, 496, 496, 496, 1437, 1201, 1044, 1437, 496,
- 685, 1056, 1278, 55, 723, 496, 496, 496, 496, 496,
- 496, 497, 497, 497, 497, 497, 497, 497, 53, 1185,
- 801, 1437, 498, 1044, 1437, 1437, 685, 1056, 498, 498,
-
- 498, 498, 498, 498, 53, 498, 498, 498, 498, 498,
- 498, 498, 343, 501, 501, 501, 501, 501, 501, 501,
- 502, 1437, 684, 982, 503, 1063, 347, 426, 1213, 864,
- 503, 503, 503, 503, 503, 503, 1437, 693, 694, 694,
- 694, 694, 694, 694, 696, 697, 697, 697, 697, 697,
- 697, 55, 347, 507, 508, 508, 508, 508, 508, 508,
- 508, 509, 1437, 1059, 1057, 510, 1051, 511, 426, 55,
- 1210, 510, 510, 510, 510, 510, 510, 700, 701, 701,
- 701, 701, 701, 701, 751, 752, 752, 752, 752, 752,
- 752, 787, 55, 511, 343, 514, 514, 514, 514, 514,
-
- 514, 514, 502, 852, 1047, 788, 515, 1045, 1437, 1176,
- 55, 55, 515, 515, 515, 515, 515, 515, 516, 517,
- 517, 517, 517, 517, 517, 517, 518, 803, 1039, 55,
- 519, 788, 520, 1089, 1437, 1176, 519, 519, 519, 519,
- 519, 519, 759, 760, 760, 760, 760, 760, 760, 763,
- 764, 764, 764, 764, 764, 764, 787, 55, 520, 441,
- 527, 527, 527, 527, 527, 527, 527, 443, 426, 1207,
- 1437, 528, 1437, 55, 841, 55, 789, 528, 528, 528,
- 528, 528, 528, 529, 530, 530, 530, 530, 530, 530,
- 790, 55, 890, 1035, 531, 1092, 1437, 55, 1437, 55,
-
- 531, 531, 531, 531, 531, 531, 569, 789, 570, 570,
- 570, 570, 570, 570, 570, 55, 790, 55, 1033, 570,
- 1093, 1437, 1028, 426, 55, 570, 570, 570, 570, 570,
- 570, 571, 572, 572, 572, 572, 572, 572, 572, 1204,
- 832, 1188, 55, 573, 1191, 574, 832, 1437, 1003, 573,
- 573, 573, 573, 573, 573, 771, 772, 772, 772, 772,
- 772, 772, 774, 775, 775, 775, 775, 775, 775, 837,
- 55, 574, 571, 573, 573, 573, 573, 573, 573, 573,
- 1437, 841, 1024, 838, 573, 1437, 1019, 426, 55, 1006,
- 573, 573, 573, 573, 573, 573, 410, 576, 576, 576,
-
- 576, 576, 576, 576, 852, 864, 1437, 895, 577, 838,
- 1437, 1437, 1009, 1012, 577, 577, 577, 577, 577, 577,
- 53, 577, 577, 577, 577, 577, 577, 577, 578, 578,
- 578, 578, 578, 578, 578, 1201, 1437, 426, 1115, 579,
- 1437, 1437, 1235, 1243, 1220, 579, 579, 579, 579, 579,
- 579, 53, 579, 579, 579, 579, 579, 579, 579, 582,
- 583, 583, 583, 583, 583, 583, 1437, 1437, 1235, 1243,
- 584, 1251, 1437, 55, 55, 55, 584, 584, 584, 584,
- 584, 584, 343, 430, 430, 430, 430, 430, 430, 430,
- 502, 55, 55, 55, 431, 1332, 55, 1251, 1437, 837,
-
- 431, 431, 431, 431, 431, 431, 585, 586, 586, 586,
- 586, 586, 586, 1437, 55, 1189, 1190, 587, 1096, 1194,
- 55, 1332, 1213, 587, 587, 587, 587, 587, 587, 591,
- 592, 592, 592, 592, 592, 592, 426, 1210, 55, 1437,
- 593, 1207, 1204, 1201, 55, 55, 593, 593, 593, 593,
- 593, 593, 507, 596, 596, 596, 596, 596, 596, 596,
- 509, 980, 55, 55, 597, 1096, 980, 55, 55, 982,
- 597, 597, 597, 597, 597, 597, 598, 599, 599, 599,
- 599, 599, 599, 426, 1192, 55, 55, 600, 1185, 982,
- 55, 55, 55, 600, 600, 600, 600, 600, 600, 516,
-
- 608, 608, 608, 608, 608, 608, 608, 518, 55, 55,
- 55, 609, 793, 1341, 1273, 55, 976, 609, 609, 609,
- 609, 609, 609, 610, 611, 611, 611, 611, 611, 611,
- 426, 1019, 974, 55, 612, 1361, 1342, 1065, 55, 1201,
- 612, 612, 612, 612, 612, 612, 441, 618, 618, 618,
- 618, 618, 618, 618, 443, 1028, 55, 1365, 619, 1369,
- 1373, 1361, 426, 1204, 619, 619, 619, 619, 619, 619,
- 620, 621, 621, 621, 621, 621, 621, 621, 622, 1039,
- 1343, 1012, 623, 1365, 624, 1369, 1373, 1207, 623, 623,
- 623, 623, 623, 623, 778, 779, 779, 779, 779, 779,
-
- 779, 694, 694, 694, 694, 694, 694, 694, 55, 846,
- 624, 648, 648, 648, 648, 648, 648, 648, 1411, 1051,
- 1419, 1420, 648, 847, 1053, 55, 55, 1210, 648, 648,
- 648, 648, 648, 648, 649, 649, 649, 649, 649, 649,
- 649, 888, 1063, 55, 1411, 649, 1419, 1420, 1421, 847,
- 1213, 649, 649, 649, 649, 649, 649, 571, 650, 650,
- 650, 650, 650, 650, 650, 651, 651, 651, 651, 651,
- 651, 651, 1113, 1183, 1421, 1422, 651, 1423, 55, 55,
- 1278, 1185, 651, 651, 651, 651, 651, 651, 410, 653,
- 653, 653, 653, 653, 653, 653, 55, 55, 426, 1009,
-
- 654, 1422, 1428, 1423, 1434, 1274, 654, 654, 654, 654,
- 654, 654, 53, 654, 654, 654, 654, 654, 654, 654,
- 655, 655, 655, 655, 655, 655, 655, 1183, 1428, 1041,
- 1434, 656, 426, 1006, 1030, 1437, 426, 656, 656, 656,
- 656, 656, 656, 53, 656, 656, 656, 656, 656, 656,
- 656, 507, 659, 659, 659, 659, 659, 659, 659, 660,
- 55, 846, 848, 661, 1003, 511, 55, 1021, 848, 661,
- 661, 661, 661, 661, 661, 1437, 849, 426, 55, 1115,
- 426, 1096, 1437, 1012, 55, 55, 1009, 55, 1006, 55,
- 802, 511, 516, 662, 662, 662, 662, 662, 662, 662,
-
- 663, 1437, 849, 55, 664, 55, 520, 55, 1437, 55,
- 664, 664, 664, 664, 664, 664, 810, 807, 1003, 319,
- 815, 815, 815, 815, 815, 815, 815, 55, 858, 858,
- 860, 55, 520, 668, 669, 669, 669, 669, 669, 669,
- 669, 670, 859, 1437, 861, 671, 1088, 672, 1096, 55,
- 860, 671, 671, 671, 671, 671, 671, 772, 772, 772,
- 772, 772, 772, 772, 1437, 55, 989, 982, 859, 1437,
- 861, 974, 795, 672, 507, 675, 675, 675, 675, 675,
- 675, 675, 660, 55, 864, 975, 676, 1065, 1012, 55,
- 1437, 1388, 676, 676, 676, 676, 676, 676, 677, 678,
-
- 678, 678, 678, 678, 678, 678, 679, 55, 688, 860,
- 680, 975, 681, 858, 852, 1053, 680, 680, 680, 680,
- 680, 680, 870, 871, 871, 871, 871, 871, 871, 873,
- 874, 874, 874, 874, 874, 874, 974, 55, 681, 516,
- 686, 686, 686, 686, 686, 686, 686, 663, 1009, 677,
- 1437, 687, 848, 846, 841, 55, 991, 687, 687, 687,
- 687, 687, 687, 688, 689, 689, 689, 689, 689, 689,
- 689, 690, 1041, 992, 1006, 691, 1437, 692, 668, 55,
- 55, 691, 691, 691, 691, 691, 691, 877, 878, 878,
- 878, 878, 878, 878, 837, 832, 1030, 55, 55, 1003,
-
- 976, 976, 55, 692, 620, 702, 702, 702, 702, 702,
- 702, 702, 622, 893, 977, 1437, 703, 1091, 1021, 918,
- 55, 903, 703, 703, 703, 703, 703, 703, 704, 705,
- 705, 705, 705, 705, 705, 985, 1012, 1009, 1006, 706,
- 977, 1437, 1003, 1001, 903, 706, 706, 706, 706, 706,
- 706, 53, 53, 53, 53, 53, 53, 53, 793, 982,
- 795, 620, 53, 55, 55, 55, 55, 55, 53, 53,
- 53, 53, 53, 53, 922, 923, 923, 923, 923, 923,
- 923, 55, 55, 55, 55, 55, 708, 726, 789, 727,
- 727, 727, 727, 727, 727, 727, 986, 987, 988, 993,
-
- 727, 995, 1340, 55, 55, 55, 727, 727, 727, 727,
- 727, 727, 930, 931, 931, 931, 931, 931, 931, 1024,
- 1024, 55, 55, 55, 53, 728, 729, 729, 729, 729,
- 729, 729, 729, 1025, 1437, 1087, 1090, 729, 1195, 787,
- 866, 827, 854, 729, 729, 729, 729, 729, 729, 934,
- 935, 935, 935, 935, 935, 935, 824, 843, 821, 1025,
- 1437, 53, 650, 650, 650, 650, 650, 650, 650, 942,
- 943, 943, 943, 943, 943, 943, 945, 946, 946, 946,
- 946, 946, 946, 949, 950, 950, 950, 950, 950, 950,
- 958, 959, 959, 959, 959, 959, 959, 53, 651, 651,
-
- 651, 651, 651, 651, 651, 834, 918, 903, 827, 651,
- 824, 821, 903, 795, 622, 651, 651, 651, 651, 651,
- 651, 730, 331, 331, 331, 331, 331, 331, 331, 253,
- 732, 732, 732, 732, 732, 732, 732, 688, 866, 827,
- 516, 733, 684, 682, 677, 854, 824, 733, 733, 733,
- 733, 733, 733, 53, 733, 733, 733, 733, 733, 733,
- 733, 736, 737, 737, 737, 737, 737, 737, 507, 673,
- 668, 843, 738, 821, 834, 831, 747, 735, 738, 738,
- 738, 738, 738, 738, 507, 596, 596, 596, 596, 596,
- 596, 596, 660, 827, 824, 821, 597, 819, 735, 620,
-
- 795, 1033, 597, 597, 597, 597, 597, 597, 739, 740,
- 740, 740, 740, 740, 740, 1034, 622, 441, 616, 741,
- 614, 690, 663, 679, 660, 741, 741, 741, 741, 741,
- 741, 516, 608, 608, 608, 608, 608, 608, 608, 663,
- 670, 1034, 747, 609, 735, 663, 660, 735, 1033, 609,
- 609, 609, 609, 609, 609, 742, 743, 743, 743, 743,
- 743, 743, 1437, 53, 53, 53, 744, 722, 53, 53,
- 716, 622, 744, 744, 744, 744, 744, 744, 748, 749,
- 749, 749, 749, 749, 749, 426, 443, 516, 1437, 750,
- 690, 663, 343, 512, 507, 750, 750, 750, 750, 750,
-
- 750, 668, 753, 753, 753, 753, 753, 753, 753, 670,
- 679, 660, 670, 754, 667, 590, 581, 663, 660, 754,
- 754, 754, 754, 754, 754, 755, 756, 756, 756, 756,
- 756, 756, 426, 658, 581, 571, 757, 569, 647, 646,
- 645, 644, 757, 757, 757, 757, 757, 757, 677, 765,
- 765, 765, 765, 765, 765, 765, 679, 643, 642, 641,
- 766, 640, 639, 638, 637, 636, 766, 766, 766, 766,
- 766, 766, 767, 768, 768, 768, 768, 768, 768, 426,
- 635, 634, 633, 769, 632, 631, 630, 629, 628, 769,
- 769, 769, 769, 769, 769, 688, 780, 780, 780, 780,
-
- 780, 780, 780, 690, 627, 626, 625, 781, 441, 622,
- 443, 437, 518, 781, 781, 781, 781, 781, 781, 782,
- 783, 783, 783, 783, 783, 783, 426, 502, 509, 590,
- 784, 581, 502, 581, 575, 575, 784, 784, 784, 784,
- 784, 784, 620, 791, 791, 791, 791, 791, 791, 791,
- 622, 568, 567, 566, 792, 565, 564, 563, 562, 561,
- 792, 792, 792, 792, 792, 792, 793, 794, 794, 794,
- 794, 794, 794, 794, 795, 560, 316, 225, 796, 559,
- 797, 558, 557, 556, 796, 796, 796, 796, 796, 796,
- 961, 962, 962, 962, 962, 962, 962, 965, 966, 966,
-
- 966, 966, 966, 966, 1035, 1035, 797, 55, 1045, 811,
- 811, 811, 811, 811, 811, 811, 555, 554, 1036, 1437,
- 811, 553, 1046, 552, 551, 55, 811, 811, 811, 811,
- 811, 811, 812, 812, 812, 812, 812, 812, 812, 550,
- 549, 548, 545, 812, 1036, 1437, 542, 541, 1046, 812,
- 812, 812, 812, 812, 812, 813, 814, 814, 814, 814,
- 814, 814, 540, 539, 538, 537, 815, 536, 55, 535,
- 534, 533, 815, 815, 815, 815, 815, 815, 253, 816,
- 816, 816, 816, 816, 816, 816, 55, 443, 265, 426,
- 817, 343, 518, 502, 509, 1387, 817, 817, 817, 817,
-
- 817, 817, 53, 817, 817, 817, 817, 817, 817, 817,
- 668, 820, 820, 820, 820, 820, 820, 820, 821, 426,
- 506, 423, 822, 417, 672, 502, 500, 417, 822, 822,
- 822, 822, 822, 822, 871, 871, 871, 871, 871, 871,
- 871, 943, 943, 943, 943, 943, 943, 943, 1045, 409,
- 672, 677, 823, 823, 823, 823, 823, 823, 823, 824,
- 403, 1047, 1437, 825, 487, 681, 486, 1047, 1057, 825,
- 825, 825, 825, 825, 825, 1048, 485, 484, 483, 482,
- 481, 1437, 1058, 480, 479, 478, 477, 55, 1437, 1057,
- 476, 681, 688, 826, 826, 826, 826, 826, 826, 826,
-
- 827, 1048, 475, 1437, 828, 55, 692, 1437, 1058, 1059,
- 828, 828, 828, 828, 828, 828, 959, 959, 959, 959,
- 959, 959, 959, 1060, 1386, 472, 471, 468, 1059, 1437,
- 1177, 467, 692, 832, 833, 833, 833, 833, 833, 833,
- 833, 834, 1437, 466, 1178, 835, 465, 836, 464, 1060,
- 1177, 835, 835, 835, 835, 835, 835, 1069, 1070, 1070,
- 1070, 1070, 1070, 1070, 1437, 114, 463, 462, 1437, 1179,
- 1178, 1179, 453, 836, 668, 839, 839, 839, 839, 839,
- 839, 839, 821, 1180, 452, 1437, 840, 451, 450, 449,
- 1437, 448, 840, 840, 840, 840, 840, 840, 841, 842,
-
- 842, 842, 842, 842, 842, 842, 843, 447, 446, 1180,
- 844, 1437, 845, 263, 443, 265, 844, 844, 844, 844,
- 844, 844, 1072, 1073, 1073, 1073, 1073, 1073, 1073, 1076,
- 1077, 1077, 1077, 1077, 1077, 1077, 1223, 426, 845, 677,
- 850, 850, 850, 850, 850, 850, 850, 824, 345, 423,
- 1224, 851, 417, 417, 410, 410, 402, 851, 851, 851,
- 851, 851, 851, 852, 853, 853, 853, 853, 853, 853,
- 853, 854, 55, 55, 1223, 855, 1224, 856, 395, 394,
- 391, 855, 855, 855, 855, 855, 855, 390, 1437, 389,
- 55, 55, 1119, 1120, 1120, 1120, 1120, 1120, 1120, 1228,
-
- 388, 1084, 1085, 856, 688, 862, 862, 862, 862, 862,
- 862, 862, 827, 1229, 1437, 387, 863, 386, 385, 384,
- 383, 382, 863, 863, 863, 863, 863, 863, 864, 865,
- 865, 865, 865, 865, 865, 865, 866, 55, 1228, 1229,
- 867, 381, 868, 380, 379, 55, 867, 867, 867, 867,
- 867, 867, 1437, 378, 377, 55, 1125, 1126, 1126, 1126,
- 1126, 1126, 1126, 55, 376, 1230, 1086, 375, 868, 793,
- 879, 879, 879, 879, 879, 879, 879, 795, 1437, 1231,
- 370, 880, 1415, 369, 298, 368, 1230, 880, 880, 880,
- 880, 880, 880, 881, 882, 882, 882, 882, 882, 882,
-
- 1437, 367, 366, 365, 883, 1231, 364, 363, 357, 265,
- 883, 883, 883, 883, 883, 883, 55, 1236, 896, 896,
- 896, 896, 896, 896, 896, 345, 1437, 261, 342, 896,
- 258, 1237, 338, 252, 55, 896, 896, 896, 896, 896,
- 896, 897, 897, 897, 897, 897, 897, 897, 246, 137,
- 326, 325, 897, 324, 319, 298, 318, 1237, 897, 897,
- 897, 897, 897, 897, 575, 898, 898, 898, 898, 898,
- 898, 898, 317, 316, 315, 314, 899, 313, 408, 312,
- 311, 310, 899, 899, 899, 899, 899, 899, 1129, 1130,
- 1130, 1130, 1130, 1130, 1130, 1135, 1136, 1136, 1136, 1136,
-
- 1136, 1136, 309, 1236, 408, 899, 899, 899, 899, 899,
- 899, 899, 308, 307, 306, 305, 899, 1437, 304, 301,
- 300, 299, 899, 899, 899, 899, 899, 899, 253, 900,
- 900, 900, 900, 900, 900, 900, 298, 297, 296, 295,
- 901, 294, 293, 1437, 292, 291, 901, 901, 901, 901,
- 901, 901, 53, 901, 901, 901, 901, 901, 901, 901,
- 904, 905, 905, 905, 905, 905, 905, 290, 289, 288,
- 287, 906, 286, 285, 284, 283, 137, 906, 906, 906,
- 906, 906, 906, 668, 753, 753, 753, 753, 753, 753,
- 753, 821, 282, 281, 280, 754, 279, 278, 277, 276,
-
- 1238, 754, 754, 754, 754, 754, 754, 907, 908, 908,
- 908, 908, 908, 908, 1239, 275, 274, 273, 909, 272,
- 271, 270, 269, 268, 909, 909, 909, 909, 909, 909,
- 677, 765, 765, 765, 765, 765, 765, 765, 824, 265,
- 1239, 253, 766, 258, 245, 244, 243, 1238, 766, 766,
- 766, 766, 766, 766, 910, 911, 911, 911, 911, 911,
- 911, 1437, 242, 241, 240, 912, 239, 238, 237, 236,
- 233, 912, 912, 912, 912, 912, 912, 688, 780, 780,
- 780, 780, 780, 780, 780, 827, 230, 1437, 227, 781,
- 226, 225, 224, 221, 1244, 781, 781, 781, 781, 781,
-
- 781, 913, 914, 914, 914, 914, 914, 914, 1245, 220,
- 219, 218, 915, 217, 216, 215, 214, 213, 915, 915,
- 915, 915, 915, 915, 919, 920, 920, 920, 920, 920,
- 920, 426, 212, 211, 1245, 921, 210, 209, 208, 207,
- 206, 921, 921, 921, 921, 921, 921, 832, 924, 924,
- 924, 924, 924, 924, 924, 834, 202, 201, 191, 925,
- 190, 189, 186, 185, 184, 925, 925, 925, 925, 925,
- 925, 926, 927, 927, 927, 927, 927, 927, 426, 183,
- 182, 181, 928, 180, 179, 175, 174, 173, 928, 928,
- 928, 928, 928, 928, 841, 936, 936, 936, 936, 936,
-
- 936, 936, 843, 172, 171, 170, 937, 169, 168, 167,
- 166, 165, 937, 937, 937, 937, 937, 937, 938, 939,
- 939, 939, 939, 939, 939, 426, 164, 163, 162, 940,
- 161, 160, 159, 154, 145, 940, 940, 940, 940, 940,
- 940, 852, 951, 951, 951, 951, 951, 951, 951, 854,
- 144, 139, 89, 952, 59, 47, 45, 1437, 1437, 952,
- 952, 952, 952, 952, 952, 953, 954, 954, 954, 954,
- 954, 954, 426, 1437, 1437, 1437, 955, 1437, 1437, 1437,
- 1437, 1437, 955, 955, 955, 955, 955, 955, 864, 967,
- 967, 967, 967, 967, 967, 967, 866, 1437, 1437, 1437,
-
- 968, 1437, 1437, 1437, 1437, 1437, 968, 968, 968, 968,
- 968, 968, 969, 970, 970, 970, 970, 970, 970, 426,
- 1437, 1437, 1437, 971, 1437, 1437, 1437, 1437, 1437, 971,
- 971, 971, 971, 971, 971, 793, 978, 978, 978, 978,
- 978, 978, 978, 795, 1437, 1437, 1437, 979, 1437, 1437,
- 1437, 1437, 1437, 979, 979, 979, 979, 979, 979, 980,
- 981, 981, 981, 981, 981, 981, 981, 982, 1437, 1437,
- 1437, 983, 1437, 984, 1437, 1437, 1437, 983, 983, 983,
- 983, 983, 983, 1138, 1139, 1139, 1139, 1139, 1139, 1139,
- 1142, 1143, 1143, 1143, 1143, 1143, 1143, 1437, 1437, 984,
-
- 55, 575, 997, 997, 997, 997, 997, 997, 997, 1437,
- 1437, 1437, 1437, 998, 1437, 1437, 1437, 1437, 55, 998,
- 998, 998, 998, 998, 998, 53, 998, 998, 998, 998,
- 998, 998, 998, 55, 253, 999, 999, 999, 999, 999,
- 999, 999, 1149, 1150, 1150, 1150, 1150, 1150, 1150, 1437,
- 1437, 55, 832, 1002, 1002, 1002, 1002, 1002, 1002, 1002,
- 1003, 1437, 1437, 1437, 1004, 1437, 836, 1437, 1437, 1437,
- 1004, 1004, 1004, 1004, 1004, 1004, 1152, 1153, 1153, 1153,
- 1153, 1153, 1153, 1156, 1157, 1157, 1157, 1157, 1157, 1157,
- 1437, 1437, 836, 841, 1005, 1005, 1005, 1005, 1005, 1005,
-
- 1005, 1006, 1437, 1437, 1437, 1007, 1437, 845, 1437, 1437,
- 1437, 1007, 1007, 1007, 1007, 1007, 1007, 1163, 1164, 1164,
- 1164, 1164, 1164, 1164, 1166, 1167, 1167, 1167, 1167, 1167,
- 1167, 1437, 1437, 845, 852, 1008, 1008, 1008, 1008, 1008,
- 1008, 1008, 1009, 1437, 1437, 1437, 1010, 1437, 856, 1437,
- 1437, 1437, 1010, 1010, 1010, 1010, 1010, 1010, 1170, 1171,
- 1171, 1171, 1171, 1171, 1171, 1070, 1070, 1070, 1070, 1070,
- 1070, 1070, 55, 1437, 856, 864, 1011, 1011, 1011, 1011,
- 1011, 1011, 1011, 1012, 1437, 1244, 1246, 1013, 1437, 868,
- 55, 1437, 1437, 1013, 1013, 1013, 1013, 1013, 1013, 1437,
-
- 1247, 1193, 1215, 1216, 1216, 1216, 1216, 1216, 1216, 1437,
- 1246, 1437, 1437, 1437, 1252, 868, 1015, 1016, 1016, 1016,
- 1016, 1016, 1016, 1017, 1437, 1437, 1247, 1018, 1253, 1437,
- 1437, 1437, 1437, 1018, 1018, 1018, 1018, 1018, 1018, 1019,
- 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1021, 1437, 1437,
- 1437, 1022, 1437, 1023, 1253, 1437, 1437, 1022, 1022, 1022,
- 1022, 1022, 1022, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
- 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1252, 1437, 1023,
- 832, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1003, 1437,
- 1437, 1437, 1027, 1437, 1437, 1437, 1437, 1437, 1027, 1027,
-
- 1027, 1027, 1027, 1027, 1028, 1029, 1029, 1029, 1029, 1029,
- 1029, 1029, 1030, 1437, 1437, 1437, 1031, 1437, 1032, 1437,
- 1437, 1254, 1031, 1031, 1031, 1031, 1031, 1031, 1164, 1164,
- 1164, 1164, 1164, 1164, 1164, 1255, 1437, 1437, 1437, 1437,
- 1254, 1437, 1286, 1437, 1032, 841, 1037, 1037, 1037, 1037,
- 1037, 1037, 1037, 1006, 1437, 1437, 1287, 1038, 1437, 1437,
- 1437, 1255, 1437, 1038, 1038, 1038, 1038, 1038, 1038, 1039,
- 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1041, 1437, 1437,
- 1437, 1042, 1287, 1043, 1437, 1437, 1437, 1042, 1042, 1042,
- 1042, 1042, 1042, 1260, 1261, 1261, 1261, 1261, 1261, 1261,
-
- 1263, 1264, 1264, 1264, 1264, 1264, 1264, 1286, 1437, 1043,
- 852, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1009, 1437,
- 1437, 1437, 1050, 1437, 1437, 1437, 1437, 1437, 1050, 1050,
- 1050, 1050, 1050, 1050, 1051, 1052, 1052, 1052, 1052, 1052,
- 1052, 1052, 1053, 1437, 1437, 1437, 1054, 1437, 1055, 1437,
- 1437, 1437, 1054, 1054, 1054, 1054, 1054, 1054, 1267, 1268,
- 1268, 1268, 1268, 1268, 1268, 1292, 1293, 1293, 1293, 1293,
- 1293, 1293, 1333, 1437, 1055, 864, 1061, 1061, 1061, 1061,
- 1061, 1061, 1061, 1012, 1437, 1437, 1334, 1062, 1437, 1437,
- 1437, 1437, 55, 1062, 1062, 1062, 1062, 1062, 1062, 1063,
-
- 1064, 1064, 1064, 1064, 1064, 1064, 1064, 1065, 55, 1437,
- 55, 1066, 1334, 1067, 1437, 1437, 1437, 1066, 1066, 1066,
- 1066, 1066, 1066, 1275, 1437, 1437, 55, 1297, 1298, 1298,
- 1298, 1298, 1298, 1298, 1437, 1437, 1333, 1276, 1437, 1067,
- 980, 1078, 1078, 1078, 1078, 1078, 1078, 1078, 982, 1437,
- 1437, 1437, 1079, 1437, 1437, 1437, 1437, 1335, 1079, 1079,
- 1079, 1079, 1079, 1079, 1080, 1081, 1081, 1081, 1081, 1081,
- 1081, 1336, 1437, 1437, 1437, 1082, 1437, 1437, 1437, 1437,
- 1437, 1082, 1082, 1082, 1082, 1082, 1082, 55, 575, 1094,
- 1094, 1094, 1094, 1094, 1094, 1094, 1437, 1336, 1437, 1437,
-
- 901, 1437, 1437, 1437, 1437, 55, 901, 901, 901, 901,
- 901, 901, 53, 901, 901, 901, 901, 901, 901, 901,
- 55, 253, 999, 999, 999, 999, 999, 999, 999, 1300,
- 1301, 1301, 1301, 1301, 1301, 1301, 1437, 1335, 55, 1097,
- 1098, 1098, 1098, 1098, 1098, 1098, 1437, 1437, 1437, 1437,
- 1099, 1437, 1437, 1437, 1437, 1437, 1099, 1099, 1099, 1099,
- 1099, 1099, 832, 924, 924, 924, 924, 924, 924, 924,
- 1003, 1437, 1437, 1437, 925, 1437, 1437, 1437, 1437, 1358,
- 925, 925, 925, 925, 925, 925, 1100, 1101, 1101, 1101,
- 1101, 1101, 1101, 1359, 1437, 1437, 1437, 1102, 1437, 1437,
-
- 1437, 1437, 1437, 1102, 1102, 1102, 1102, 1102, 1102, 841,
- 936, 936, 936, 936, 936, 936, 936, 1006, 1437, 1359,
- 1437, 937, 1437, 1437, 1437, 1437, 1358, 937, 937, 937,
- 937, 937, 937, 1103, 1104, 1104, 1104, 1104, 1104, 1104,
- 1437, 1437, 1437, 1437, 1105, 1437, 1437, 1437, 1437, 1437,
- 1105, 1105, 1105, 1105, 1105, 1105, 852, 951, 951, 951,
- 951, 951, 951, 951, 1009, 1437, 1437, 1437, 952, 1437,
- 1437, 1437, 1437, 1362, 952, 952, 952, 952, 952, 952,
- 1106, 1107, 1107, 1107, 1107, 1107, 1107, 1363, 1437, 1437,
- 1437, 1108, 1437, 1437, 1437, 1437, 1437, 1108, 1108, 1108,
-
- 1108, 1108, 1108, 864, 967, 967, 967, 967, 967, 967,
- 967, 1012, 1437, 1363, 1437, 968, 1437, 1437, 1437, 1437,
- 1362, 968, 968, 968, 968, 968, 968, 1109, 1110, 1110,
- 1110, 1110, 1110, 1110, 1437, 1437, 1437, 1437, 1111, 1437,
- 1437, 1437, 1437, 1437, 1111, 1111, 1111, 1111, 1111, 1111,
- 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1115, 1437,
- 1437, 1437, 1116, 1437, 1117, 1437, 1437, 1437, 1116, 1116,
- 1116, 1116, 1116, 1116, 1306, 1307, 1307, 1307, 1307, 1307,
- 1307, 1309, 1310, 1310, 1310, 1310, 1310, 1310, 1366, 1437,
- 1117, 1019, 1121, 1121, 1121, 1121, 1121, 1121, 1121, 1021,
-
- 1437, 1437, 1367, 1122, 1437, 1437, 1437, 1437, 1437, 1122,
- 1122, 1122, 1122, 1122, 1122, 1028, 1131, 1131, 1131, 1131,
- 1131, 1131, 1131, 1030, 1437, 1437, 1437, 1132, 1367, 1437,
- 1437, 1437, 1437, 1132, 1132, 1132, 1132, 1132, 1132, 1039,
- 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1041, 1437, 1437,
- 1437, 1145, 1437, 1437, 1437, 1437, 1437, 1145, 1145, 1145,
- 1145, 1145, 1145, 1051, 1158, 1158, 1158, 1158, 1158, 1158,
- 1158, 1053, 1437, 1437, 1437, 1159, 1437, 1437, 1437, 1437,
- 1437, 1159, 1159, 1159, 1159, 1159, 1159, 1063, 1172, 1172,
- 1172, 1172, 1172, 1172, 1172, 1065, 1437, 1437, 1437, 1173,
-
- 1437, 1437, 1437, 1437, 1437, 1173, 1173, 1173, 1173, 1173,
- 1173, 980, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 982,
- 1437, 1437, 1437, 1182, 1437, 1437, 1437, 1437, 1437, 1182,
- 1182, 1182, 1182, 1182, 1182, 1183, 1184, 1184, 1184, 1184,
- 1184, 1184, 1184, 1185, 1437, 1437, 1437, 1186, 1437, 1187,
- 1437, 1437, 1437, 1186, 1186, 1186, 1186, 1186, 1186, 1315,
- 1316, 1316, 1316, 1316, 1316, 1316, 1318, 1319, 1319, 1319,
- 1319, 1319, 1319, 1437, 1437, 1187, 55, 575, 492, 492,
- 492, 492, 492, 492, 492, 1324, 1325, 1325, 1325, 1325,
- 1325, 1325, 1437, 1366, 55, 1196, 1197, 1197, 1197, 1197,
-
- 1197, 1197, 1198, 1437, 1437, 1437, 1199, 1437, 1437, 1437,
- 1437, 1437, 1199, 1199, 1199, 1199, 1199, 1199, 1019, 1200,
- 1200, 1200, 1200, 1200, 1200, 1200, 1201, 1437, 1437, 1437,
- 1202, 1437, 1023, 1437, 1437, 1437, 1202, 1202, 1202, 1202,
- 1202, 1202, 1327, 1328, 1328, 1328, 1328, 1328, 1328, 1261,
- 1261, 1261, 1261, 1261, 1261, 1261, 1437, 1437, 1023, 1028,
- 1203, 1203, 1203, 1203, 1203, 1203, 1203, 1204, 1437, 1437,
- 1437, 1205, 1437, 1032, 1437, 1437, 1437, 1205, 1205, 1205,
- 1205, 1205, 1205, 1352, 1353, 1353, 1353, 1353, 1353, 1353,
- 1298, 1298, 1298, 1298, 1298, 1298, 1298, 1437, 1437, 1032,
-
- 1039, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1207, 1437,
- 1437, 1437, 1208, 1437, 1043, 1437, 1437, 1437, 1208, 1208,
- 1208, 1208, 1208, 1208, 1307, 1307, 1307, 1307, 1307, 1307,
- 1307, 1316, 1316, 1316, 1316, 1316, 1316, 1316, 1370, 1437,
- 1043, 1051, 1209, 1209, 1209, 1209, 1209, 1209, 1209, 1210,
- 1437, 1370, 1371, 1211, 1437, 1055, 1437, 1437, 1437, 1211,
- 1211, 1211, 1211, 1211, 1211, 1437, 1325, 1325, 1325, 1325,
- 1325, 1325, 1325, 1437, 1437, 1437, 1437, 1437, 1371, 1374,
- 1437, 1055, 1063, 1212, 1212, 1212, 1212, 1212, 1212, 1212,
- 1213, 1437, 1374, 1375, 1214, 1437, 1067, 1437, 1437, 1437,
-
- 1214, 1214, 1214, 1214, 1214, 1214, 1437, 1378, 1379, 1379,
- 1379, 1379, 1379, 1379, 1437, 1437, 1437, 1437, 1437, 1375,
- 1390, 1437, 1067, 1113, 1217, 1217, 1217, 1217, 1217, 1217,
- 1217, 1115, 1437, 1437, 1391, 1218, 1437, 1437, 1437, 1437,
- 1437, 1218, 1218, 1218, 1218, 1218, 1218, 1019, 1225, 1225,
- 1225, 1225, 1225, 1225, 1225, 1201, 1437, 1437, 1437, 1226,
- 1391, 1437, 1437, 1437, 1437, 1226, 1226, 1226, 1226, 1226,
- 1226, 1028, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1204,
- 1437, 1437, 1437, 1233, 1437, 1437, 1437, 1437, 1437, 1233,
- 1233, 1233, 1233, 1233, 1233, 1039, 1240, 1240, 1240, 1240,
-
- 1240, 1240, 1240, 1207, 1437, 1437, 1437, 1241, 1437, 1437,
- 1437, 1437, 1437, 1241, 1241, 1241, 1241, 1241, 1241, 1051,
- 1248, 1248, 1248, 1248, 1248, 1248, 1248, 1210, 1437, 1437,
- 1437, 1249, 1437, 1437, 1437, 1437, 1437, 1249, 1249, 1249,
- 1249, 1249, 1249, 1063, 1256, 1256, 1256, 1256, 1256, 1256,
- 1256, 1213, 1437, 1437, 1437, 1257, 1437, 1437, 1437, 1437,
- 1437, 1257, 1257, 1257, 1257, 1257, 1257, 1183, 1269, 1269,
- 1269, 1269, 1269, 1269, 1269, 1185, 1437, 1437, 1437, 1270,
- 1437, 1437, 1437, 1437, 1437, 1270, 1270, 1270, 1270, 1270,
- 1270, 1113, 1277, 1277, 1277, 1277, 1277, 1277, 1277, 1278,
-
- 1437, 1437, 1437, 1279, 1437, 1117, 1437, 1437, 1390, 1279,
- 1279, 1279, 1279, 1279, 1279, 1381, 1382, 1382, 1382, 1382,
- 1382, 1382, 1437, 1392, 1393, 1393, 1393, 1393, 1393, 1393,
- 1437, 1117, 1019, 1121, 1121, 1121, 1121, 1121, 1121, 1121,
- 1201, 1437, 1437, 1437, 1122, 1437, 1437, 1437, 1437, 1437,
- 1122, 1122, 1122, 1122, 1122, 1122, 1028, 1131, 1131, 1131,
- 1131, 1131, 1131, 1131, 1204, 1437, 1437, 1437, 1132, 1437,
- 1437, 1437, 1437, 1437, 1132, 1132, 1132, 1132, 1132, 1132,
- 1039, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1207, 1437,
- 1437, 1437, 1145, 1437, 1437, 1437, 1437, 1437, 1145, 1145,
-
- 1145, 1145, 1145, 1145, 1051, 1158, 1158, 1158, 1158, 1158,
- 1158, 1158, 1210, 1437, 1437, 1437, 1159, 1437, 1437, 1437,
- 1437, 1437, 1159, 1159, 1159, 1159, 1159, 1159, 1063, 1172,
- 1172, 1172, 1172, 1172, 1172, 1172, 1213, 1437, 1437, 1437,
- 1173, 1437, 1437, 1437, 1437, 1437, 1173, 1173, 1173, 1173,
- 1173, 1173, 1113, 1288, 1288, 1288, 1288, 1288, 1288, 1288,
- 1278, 1437, 1437, 1437, 1289, 1437, 1437, 1437, 1437, 1437,
- 1289, 1289, 1289, 1289, 1289, 1289, 1183, 1337, 1337, 1337,
- 1337, 1337, 1337, 1337, 1185, 1437, 1437, 1437, 1338, 1437,
- 1437, 1437, 1437, 1437, 1338, 1338, 1338, 1338, 1338, 1338,
-
- 1113, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1278, 1437,
- 1437, 1437, 1218, 1437, 1437, 1437, 1437, 1437, 1218, 1218,
- 1218, 1218, 1218, 1218, 1396, 1397, 1397, 1397, 1397, 1397,
- 1397, 1400, 1401, 1401, 1401, 1401, 1401, 1401, 1404, 1405,
- 1405, 1405, 1405, 1405, 1405, 1408, 1409, 1409, 1409, 1409,
- 1409, 1409, 1379, 1379, 1379, 1379, 1379, 1379, 1379, 1412,
- 1412, 1416, 1417, 1417, 1417, 1417, 1417, 1417, 1437, 1437,
- 1437, 1437, 1437, 1413, 1437, 1393, 1393, 1393, 1393, 1393,
- 1393, 1393, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1401,
- 1401, 1401, 1401, 1401, 1401, 1401, 1437, 1437, 1437, 1413,
-
- 1437, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1409, 1409,
- 1409, 1409, 1409, 1409, 1409, 1425, 1426, 1426, 1426, 1426,
- 1426, 1426, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1426,
- 1426, 1426, 1426, 1426, 1426, 1426, 46, 1437, 1437, 1437,
- 1437, 46, 46, 46, 64, 1437, 64, 64, 64, 64,
- 64, 64, 64, 146, 1437, 146, 153, 153, 153, 257,
- 257, 257, 266, 266, 266, 337, 337, 337, 340, 340,
- 340, 341, 341, 341, 348, 348, 348, 346, 346, 346,
- 352, 352, 352, 356, 1437, 356, 416, 416, 416, 421,
- 421, 421, 422, 422, 422, 431, 431, 431, 435, 1437,
-
- 435, 436, 436, 436, 350, 350, 1437, 1437, 350, 440,
- 440, 440, 444, 444, 444, 340, 340, 340, 499, 499,
- 499, 503, 503, 503, 504, 504, 504, 505, 505, 505,
- 348, 348, 348, 510, 510, 510, 429, 429, 1437, 1437,
- 429, 515, 515, 515, 519, 519, 519, 523, 1437, 523,
- 524, 524, 524, 528, 528, 528, 532, 1437, 532, 580,
- 580, 580, 431, 431, 431, 588, 588, 588, 589, 589,
- 589, 597, 597, 597, 601, 1437, 601, 604, 1437, 604,
- 605, 605, 605, 609, 609, 609, 613, 1437, 613, 522,
- 522, 1437, 1437, 522, 526, 526, 1437, 1437, 526, 619,
-
- 619, 619, 623, 623, 623, 532, 532, 1437, 532, 504,
- 504, 504, 657, 657, 657, 661, 661, 661, 664, 664,
- 664, 665, 665, 665, 666, 666, 666, 671, 671, 671,
- 595, 595, 1437, 1437, 595, 676, 676, 676, 680, 680,
- 680, 601, 601, 1437, 601, 603, 603, 1437, 1437, 603,
- 604, 604, 1437, 604, 605, 605, 607, 607, 1437, 1437,
- 607, 687, 687, 687, 691, 691, 691, 613, 613, 1437,
- 613, 695, 1437, 695, 698, 1437, 698, 699, 699, 699,
- 703, 703, 703, 707, 1437, 707, 734, 734, 734, 597,
- 597, 597, 609, 609, 609, 745, 745, 745, 746, 746,
-
- 746, 754, 754, 754, 758, 1437, 758, 761, 1437, 761,
- 762, 762, 762, 766, 766, 766, 770, 1437, 770, 773,
- 1437, 773, 776, 1437, 776, 777, 777, 777, 781, 781,
- 781, 785, 1437, 785, 694, 1437, 1437, 694, 695, 695,
- 1437, 695, 697, 697, 1437, 1437, 697, 698, 698, 1437,
- 698, 699, 699, 701, 701, 1437, 1437, 701, 792, 792,
- 792, 796, 796, 796, 707, 707, 1437, 707, 53, 53,
- 53, 1437, 53, 53, 665, 665, 665, 818, 818, 818,
- 822, 822, 822, 825, 825, 825, 828, 828, 828, 829,
- 829, 829, 830, 830, 830, 835, 835, 835, 752, 752,
-
- 1437, 1437, 752, 840, 840, 840, 844, 844, 844, 758,
- 758, 1437, 758, 760, 760, 1437, 1437, 760, 761, 761,
- 1437, 761, 762, 762, 764, 764, 1437, 1437, 764, 851,
- 851, 851, 855, 855, 855, 770, 770, 1437, 770, 772,
- 1437, 1437, 772, 773, 773, 1437, 773, 775, 775, 1437,
- 1437, 775, 776, 776, 1437, 776, 777, 777, 779, 779,
- 1437, 1437, 779, 863, 863, 863, 867, 867, 867, 785,
- 785, 1437, 785, 869, 1437, 869, 872, 1437, 872, 875,
- 1437, 875, 876, 876, 876, 880, 880, 880, 884, 1437,
- 884, 53, 53, 53, 1437, 53, 53, 902, 902, 902,
-
- 754, 754, 754, 766, 766, 766, 781, 781, 781, 916,
- 916, 916, 917, 917, 917, 925, 925, 925, 929, 1437,
- 929, 932, 1437, 932, 933, 933, 933, 937, 937, 937,
- 941, 1437, 941, 944, 1437, 944, 947, 1437, 947, 948,
- 948, 948, 952, 952, 952, 956, 1437, 956, 957, 1437,
- 957, 960, 1437, 960, 963, 1437, 963, 964, 964, 964,
- 968, 968, 968, 972, 1437, 972, 869, 1437, 869, 871,
- 1437, 1437, 871, 872, 872, 1437, 872, 874, 874, 1437,
- 1437, 874, 875, 875, 1437, 875, 876, 876, 878, 878,
- 1437, 1437, 878, 979, 979, 979, 983, 983, 983, 884,
-
- 884, 1437, 884, 53, 53, 53, 1437, 53, 53, 829,
- 829, 829, 1000, 1000, 1000, 1004, 1004, 1004, 1007, 1007,
- 1007, 1010, 1010, 1010, 1013, 1013, 1013, 1014, 1014, 1014,
- 1022, 1022, 1022, 923, 923, 1437, 1437, 923, 1027, 1027,
- 1027, 1031, 1031, 1031, 929, 929, 1437, 929, 931, 931,
- 1437, 1437, 931, 932, 932, 1437, 932, 933, 933, 935,
- 935, 1437, 1437, 935, 1038, 1038, 1038, 1042, 1042, 1042,
- 941, 941, 1437, 941, 943, 1437, 1437, 943, 944, 944,
- 1437, 944, 946, 946, 1437, 1437, 946, 947, 947, 1437,
- 947, 948, 948, 950, 950, 1437, 1437, 950, 1050, 1050,
-
- 1050, 1054, 1054, 1054, 956, 956, 1437, 956, 957, 1437,
- 957, 959, 1437, 1437, 959, 960, 960, 1437, 960, 962,
- 962, 1437, 1437, 962, 963, 963, 1437, 963, 964, 964,
- 966, 966, 1437, 1437, 966, 1062, 1062, 1062, 1066, 1066,
- 1066, 972, 972, 1437, 972, 1068, 1437, 1068, 1071, 1437,
- 1071, 1074, 1437, 1074, 1075, 1075, 1075, 1079, 1079, 1079,
- 1083, 1437, 1083, 53, 53, 53, 1437, 53, 53, 1095,
- 1095, 1095, 925, 925, 925, 937, 937, 937, 952, 952,
- 952, 968, 968, 968, 1112, 1112, 1112, 1118, 1118, 1118,
- 1116, 1116, 1116, 1123, 1123, 1123, 1122, 1122, 1122, 1124,
-
- 1437, 1124, 1127, 1437, 1127, 1128, 1128, 1128, 1133, 1133,
- 1133, 1132, 1132, 1132, 1134, 1437, 1134, 1137, 1437, 1137,
- 1140, 1437, 1140, 1141, 1141, 1141, 1146, 1146, 1146, 1145,
- 1145, 1145, 1147, 1437, 1147, 1148, 1437, 1148, 1151, 1437,
- 1151, 1154, 1437, 1154, 1155, 1155, 1155, 1160, 1160, 1160,
- 1159, 1159, 1159, 1161, 1437, 1161, 1162, 1437, 1162, 1165,
- 1437, 1165, 1168, 1437, 1168, 1169, 1169, 1169, 1174, 1174,
- 1174, 1173, 1173, 1173, 1175, 1437, 1175, 1068, 1437, 1068,
- 1070, 1437, 1437, 1070, 1071, 1071, 1437, 1071, 1073, 1073,
- 1437, 1437, 1073, 1074, 1074, 1437, 1074, 1075, 1075, 1077,
-
- 1077, 1437, 1437, 1077, 1182, 1182, 1182, 1186, 1186, 1186,
- 1083, 1083, 1437, 1083, 53, 53, 53, 1437, 53, 53,
- 1014, 1014, 1014, 1202, 1202, 1202, 1205, 1205, 1205, 1208,
- 1208, 1208, 1211, 1211, 1211, 1214, 1214, 1214, 1219, 1219,
- 1219, 1218, 1218, 1218, 1221, 1437, 1221, 1222, 1222, 1222,
- 1120, 1120, 1437, 1437, 1120, 1226, 1226, 1226, 1227, 1227,
- 1227, 1124, 1124, 1437, 1124, 1126, 1126, 1437, 1437, 1126,
- 1127, 1127, 1437, 1127, 1128, 1128, 1130, 1130, 1437, 1437,
- 1130, 1233, 1233, 1233, 1234, 1234, 1234, 1134, 1134, 1437,
- 1134, 1136, 1437, 1437, 1136, 1137, 1137, 1437, 1137, 1139,
-
- 1139, 1437, 1437, 1139, 1140, 1140, 1437, 1140, 1141, 1141,
- 1143, 1143, 1437, 1437, 1143, 1241, 1241, 1241, 1242, 1242,
- 1242, 1147, 1147, 1437, 1147, 1148, 1437, 1148, 1150, 1437,
- 1437, 1150, 1151, 1151, 1437, 1151, 1153, 1153, 1437, 1437,
- 1153, 1154, 1154, 1437, 1154, 1155, 1155, 1157, 1157, 1437,
- 1437, 1157, 1249, 1249, 1249, 1250, 1250, 1250, 1161, 1161,
- 1437, 1161, 1162, 1437, 1162, 1164, 1437, 1437, 1164, 1165,
- 1165, 1437, 1165, 1167, 1167, 1437, 1437, 1167, 1168, 1168,
- 1437, 1168, 1169, 1169, 1171, 1171, 1437, 1437, 1171, 1257,
- 1257, 1257, 1258, 1258, 1258, 1175, 1175, 1437, 1175, 1259,
-
- 1437, 1259, 1262, 1437, 1262, 1265, 1437, 1265, 1266, 1266,
- 1266, 1271, 1437, 1271, 1270, 1270, 1270, 1272, 1437, 1272,
- 53, 53, 53, 1437, 53, 53, 1280, 1437, 1280, 1279,
- 1279, 1279, 1281, 1437, 1281, 1122, 1122, 1122, 1282, 1437,
- 1282, 1132, 1132, 1132, 1283, 1437, 1283, 1145, 1145, 1145,
- 1284, 1437, 1284, 1159, 1159, 1159, 1285, 1437, 1285, 1173,
- 1173, 1173, 1216, 1216, 1437, 1437, 1216, 1289, 1289, 1289,
- 1290, 1290, 1290, 348, 348, 348, 1221, 1221, 1437, 1221,
- 1291, 1291, 1291, 1294, 1437, 1294, 1295, 1295, 1295, 1296,
- 1296, 1296, 1299, 1437, 1299, 1302, 1437, 1302, 1303, 1303,
-
- 1303, 1304, 1304, 1304, 1305, 1437, 1305, 1308, 1437, 1308,
- 1311, 1437, 1311, 1312, 1312, 1312, 1313, 1313, 1313, 1314,
- 1437, 1314, 1317, 1437, 1317, 1320, 1437, 1320, 1321, 1321,
- 1321, 1322, 1322, 1322, 1323, 1437, 1323, 1326, 1437, 1326,
- 1329, 1437, 1329, 1330, 1330, 1330, 1331, 1331, 1331, 1259,
- 1437, 1259, 1261, 1437, 1437, 1261, 1262, 1262, 1437, 1262,
- 1264, 1264, 1437, 1437, 1264, 1265, 1265, 1437, 1265, 1266,
- 1266, 1268, 1268, 1437, 1437, 1268, 1338, 1338, 1338, 1339,
- 1437, 1339, 1272, 1272, 1437, 1272, 53, 53, 53, 1437,
- 53, 53, 1344, 1344, 1344, 1218, 1218, 1218, 1346, 1437,
-
- 1346, 1347, 1437, 1347, 1348, 1437, 1348, 1349, 1437, 1349,
- 1350, 1437, 1350, 1351, 1437, 1351, 1354, 1437, 1354, 1355,
- 1355, 1355, 1356, 1356, 1356, 1357, 1437, 1357, 1293, 1293,
- 1437, 1437, 1293, 1294, 1294, 1437, 1294, 1295, 1295, 1360,
- 1437, 1360, 1298, 1437, 1437, 1298, 1299, 1299, 1437, 1299,
- 1301, 1301, 1437, 1437, 1301, 1302, 1302, 1437, 1302, 1303,
- 1303, 1364, 1437, 1364, 1305, 1437, 1305, 1307, 1437, 1437,
- 1307, 1308, 1308, 1437, 1308, 1310, 1310, 1437, 1437, 1310,
- 1311, 1311, 1437, 1311, 1312, 1312, 1368, 1437, 1368, 1314,
- 1437, 1314, 1316, 1437, 1437, 1316, 1317, 1317, 1437, 1317,
-
- 1319, 1319, 1437, 1437, 1319, 1320, 1320, 1437, 1320, 1321,
- 1321, 1372, 1437, 1372, 1323, 1437, 1323, 1325, 1437, 1437,
- 1325, 1326, 1326, 1437, 1326, 1328, 1328, 1437, 1437, 1328,
- 1329, 1329, 1437, 1329, 1330, 1330, 1376, 1437, 1376, 1377,
- 1437, 1377, 1380, 1437, 1380, 1383, 1437, 1383, 1384, 1384,
- 1384, 1385, 1437, 1385, 53, 53, 53, 1437, 53, 53,
- 1389, 1437, 1389, 1291, 1437, 1291, 1296, 1437, 1296, 1304,
- 1437, 1304, 1313, 1437, 1313, 1322, 1437, 1322, 1331, 1437,
- 1331, 1353, 1353, 1437, 1437, 1353, 1354, 1354, 1437, 1354,
- 1355, 1355, 1345, 1437, 1345, 1394, 1437, 1394, 1395, 1437,
-
- 1395, 1398, 1437, 1398, 1399, 1437, 1399, 1402, 1437, 1402,
- 1403, 1437, 1403, 1406, 1437, 1406, 1407, 1437, 1407, 1410,
- 1437, 1410, 1379, 1437, 1437, 1379, 1382, 1382, 1437, 1437,
- 1382, 1414, 1437, 1414, 1356, 1437, 1356, 1418, 1437, 1418,
- 1393, 1437, 1437, 1393, 1397, 1437, 1437, 1397, 1401, 1437,
- 1437, 1401, 1405, 1437, 1437, 1405, 1409, 1437, 1437, 1409,
- 1424, 1437, 1424, 1427, 1437, 1427, 1417, 1437, 1437, 1417,
- 1429, 1437, 1429, 1430, 1437, 1430, 1431, 1437, 1431, 1432,
- 1437, 1432, 1433, 1437, 1433, 1426, 1437, 1437, 1426, 1435,
- 1437, 1435, 1436, 1437, 1436, 3, 1437, 1437, 1437, 1437,
-
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437
+ 21, 21, 43, 44, 53, 211, 44, 44, 44, 44,
+ 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,
+
+ 118, 196, 81, 53, 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,
+ 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,
+ 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,
+
+ 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,
+ 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,
+ 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,
+ 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,
+
+ 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,
+ 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,
+ 264, 264, 267, 268, 268, 268, 268, 268, 268, 268,
+ 269, 763, 1469, 1469, 270, 543, 1245, 1469, 606, 453,
+ 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,
+ 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,
+ 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,
+ 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,
+
+ 373, 373, 373, 373, 373, 373, 279, 1255, 1051, 647,
+ 374, 1469, 55, 1260, 55, 752, 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,
+ 435, 436, 434, 434, 434, 434, 434, 434, 434, 53,
+ 1278, 1083, 706, 434, 1469, 55, 55, 55, 705, 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,
+
+ 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,
+ 447, 447, 447, 451, 452, 452, 452, 452, 452, 452,
+ 453, 55, 55, 55, 454, 1318, 919, 921, 923, 55,
+ 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,
+
+ 461, 461, 461, 277, 466, 466, 466, 466, 466, 466,
+ 466, 279, 55, 1390, 1394, 467, 1469, 1026, 55, 55,
+ 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
} ;
-static yyconst flex_int16_t yy_chk[7450] =
+static yyconst flex_int16_t yy_chk[7486] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 4, 7, 15, 4, 7, 4, 7,
- 9, 4, 7, 9, 34, 9, 17, 17, 9, 19,
- 19, 4, 7, 34, 24, 27, 27, 100, 9, 4,
- 7, 15, 12, 100, 128, 12, 9, 12, 24, 23,
- 12, 23, 23, 26, 28, 24, 23, 26, 1258, 28,
-
- 12, 23, 128, 26, 29, 23, 26, 23, 12, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 627,
- 29, 92, 14, 14, 14, 627, 92, 14, 14, 14,
+ 1, 1, 1, 4, 15, 106, 4, 7, 4, 4,
+ 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,
+
+ 34, 94, 26, 659, 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,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 16, 36, 25, 16, 132, 16, 36, 36,
- 16, 36, 36, 101, 25, 96, 132, 25, 101, 22,
- 16, 25, 22, 39, 22, 39, 238, 22, 16, 20,
- 20, 20, 20, 20, 20, 20, 20, 22, 33, 39,
- 1262, 123, 33, 20, 35, 22, 39, 1265, 96, 37,
-
- 238, 33, 33, 37, 123, 33, 35, 33, 35, 104,
- 35, 37, 104, 35, 104, 237, 37, 237, 37, 20,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 32, 32, 317, 21, 208, 1266, 149, 317, 97, 21,
- 21, 21, 21, 21, 21, 31, 32, 208, 31, 31,
- 32, 31, 130, 31, 32, 31, 32, 31, 38, 41,
- 31, 130, 149, 32, 38, 97, 38, 41, 38, 385,
- 97, 41, 38, 41, 38, 38, 44, 253, 253, 44,
- 629, 44, 385, 629, 44, 62, 62, 62, 62, 62,
- 62, 62, 63, 157, 44, 63, 628, 63, 1270, 388,
-
- 63, 628, 44, 48, 48, 48, 48, 48, 48, 48,
- 63, 1272, 260, 388, 48, 410, 410, 1278, 63, 157,
- 48, 48, 48, 48, 48, 48, 49, 49, 49, 49,
- 49, 49, 49, 83, 575, 575, 329, 49, 260, 270,
- 270, 270, 270, 49, 49, 49, 49, 49, 49, 50,
- 50, 50, 50, 50, 50, 50, 50, 439, 1279, 270,
- 83, 50, 329, 354, 412, 439, 83, 50, 50, 50,
- 50, 50, 50, 52, 52, 52, 52, 52, 52, 52,
- 52, 54, 54, 54, 54, 54, 54, 54, 419, 354,
- 412, 333, 54, 533, 533, 533, 533, 425, 54, 54,
-
- 54, 54, 54, 54, 56, 333, 634, 56, 634, 56,
- 349, 637, 56, 350, 419, 56, 56, 56, 56, 56,
- 56, 56, 56, 425, 349, 637, 56, 350, 433, 490,
- 56, 333, 56, 56, 56, 56, 56, 56, 147, 458,
- 147, 147, 147, 147, 147, 147, 147, 460, 458, 1289,
- 349, 147, 530, 350, 433, 490, 460, 147, 147, 147,
- 147, 147, 147, 148, 148, 148, 148, 148, 148, 148,
- 148, 514, 524, 626, 626, 148, 583, 148, 530, 514,
- 524, 148, 148, 148, 148, 148, 148, 252, 252, 252,
- 252, 252, 252, 252, 263, 263, 263, 263, 263, 263,
-
- 263, 428, 583, 148, 150, 150, 150, 150, 150, 150,
- 150, 150, 586, 592, 1290, 428, 150, 599, 611, 645,
- 645, 1294, 150, 150, 150, 150, 150, 150, 151, 151,
- 151, 151, 151, 151, 151, 151, 151, 618, 586, 592,
- 151, 428, 1295, 599, 611, 618, 151, 151, 151, 151,
- 151, 151, 152, 152, 152, 152, 152, 152, 152, 152,
- 154, 154, 154, 154, 154, 154, 154, 154, 635, 1299,
- 652, 154, 635, 1302, 631, 636, 708, 154, 154, 154,
- 154, 154, 154, 156, 156, 156, 156, 156, 156, 156,
- 156, 156, 631, 636, 708, 156, 652, 156, 654, 287,
-
- 710, 156, 156, 156, 156, 156, 156, 287, 339, 339,
- 339, 339, 339, 339, 339, 1303, 1308, 429, 710, 494,
- 287, 711, 632, 156, 246, 246, 246, 246, 246, 246,
- 246, 429, 632, 494, 654, 246, 287, 716, 1311, 711,
- 1312, 246, 246, 246, 246, 246, 246, 248, 248, 248,
- 248, 248, 248, 248, 630, 716, 711, 429, 248, 494,
- 716, 693, 705, 630, 248, 248, 248, 248, 248, 248,
- 249, 249, 249, 249, 249, 249, 249, 249, 251, 251,
- 251, 251, 251, 251, 251, 675, 686, 693, 705, 251,
- 1317, 709, 720, 675, 686, 251, 251, 251, 251, 251,
-
- 251, 254, 254, 254, 254, 254, 254, 254, 254, 709,
- 720, 720, 1320, 254, 1321, 1326, 709, 1329, 1330, 254,
- 254, 254, 254, 254, 254, 256, 256, 256, 256, 256,
- 256, 256, 256, 259, 259, 259, 259, 259, 259, 259,
- 259, 259, 791, 322, 521, 259, 1338, 259, 322, 1354,
- 791, 259, 259, 259, 259, 259, 259, 322, 521, 322,
- 322, 737, 322, 343, 343, 343, 343, 343, 343, 343,
- 722, 522, 712, 259, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 1355, 521, 522, 264, 737, 722, 1380,
- 712, 525, 264, 264, 264, 264, 264, 264, 265, 265,
-
- 265, 265, 265, 265, 265, 525, 1383, 712, 1394, 265,
- 1398, 522, 717, 1402, 718, 265, 265, 265, 265, 265,
- 265, 327, 526, 327, 327, 327, 327, 327, 327, 327,
- 717, 525, 718, 717, 327, 718, 526, 723, 721, 727,
- 327, 327, 327, 327, 327, 327, 328, 328, 328, 328,
- 328, 328, 328, 328, 1406, 723, 721, 727, 328, 721,
- 328, 1410, 526, 1418, 328, 328, 328, 328, 328, 328,
- 409, 409, 409, 409, 409, 409, 409, 437, 437, 437,
- 437, 437, 437, 437, 594, 644, 328, 330, 330, 330,
- 330, 330, 330, 330, 330, 644, 1427, 740, 594, 330,
-
- 743, 729, 729, 1257, 595, 330, 330, 330, 330, 330,
- 330, 334, 334, 334, 334, 334, 334, 334, 595, 729,
- 1250, 749, 334, 740, 594, 756, 743, 798, 334, 334,
- 334, 334, 334, 334, 335, 335, 335, 335, 335, 335,
- 335, 335, 1249, 1242, 595, 798, 335, 749, 768, 771,
- 783, 756, 335, 335, 335, 335, 335, 335, 336, 336,
- 336, 336, 336, 336, 336, 336, 338, 338, 338, 338,
- 338, 338, 338, 1241, 768, 771, 783, 338, 1234, 799,
- 800, 801, 1233, 338, 338, 338, 338, 338, 338, 342,
- 342, 342, 342, 342, 342, 342, 342, 799, 800, 801,
-
- 342, 1227, 799, 800, 801, 803, 342, 342, 342, 342,
- 342, 342, 344, 344, 344, 344, 344, 344, 344, 344,
- 344, 839, 814, 803, 344, 1226, 805, 806, 803, 839,
- 344, 344, 344, 344, 344, 344, 345, 345, 345, 345,
- 345, 345, 345, 345, 805, 806, 1222, 345, 814, 805,
- 806, 808, 810, 345, 345, 345, 345, 345, 345, 351,
- 351, 351, 351, 351, 351, 351, 351, 351, 850, 808,
- 810, 351, 808, 870, 1221, 892, 850, 351, 351, 351,
- 351, 351, 351, 353, 353, 353, 353, 353, 353, 353,
- 353, 353, 862, 892, 1220, 353, 882, 353, 892, 870,
-
- 862, 353, 353, 353, 353, 353, 353, 441, 441, 441,
- 441, 441, 441, 441, 507, 507, 507, 507, 507, 507,
- 507, 1219, 882, 353, 371, 1218, 905, 1214, 371, 908,
- 895, 371, 889, 602, 371, 603, 371, 371, 371, 371,
- 403, 403, 403, 403, 403, 403, 403, 602, 895, 603,
- 889, 403, 905, 889, 896, 908, 640, 403, 403, 403,
- 403, 403, 403, 405, 405, 405, 405, 405, 405, 405,
- 640, 978, 896, 602, 405, 603, 911, 914, 920, 978,
- 405, 405, 405, 405, 405, 405, 406, 406, 406, 406,
- 406, 406, 406, 406, 408, 408, 408, 408, 408, 408,
-
- 408, 1211, 911, 914, 920, 408, 927, 894, 897, 901,
- 988, 408, 408, 408, 408, 408, 408, 411, 411, 411,
- 411, 411, 411, 411, 411, 894, 897, 901, 988, 411,
- 1208, 411, 927, 894, 1205, 411, 411, 411, 411, 411,
- 411, 512, 512, 512, 512, 512, 512, 512, 516, 516,
- 516, 516, 516, 516, 516, 713, 606, 411, 413, 413,
- 413, 413, 413, 413, 413, 939, 1202, 942, 954, 413,
- 606, 958, 1199, 713, 643, 413, 413, 413, 413, 413,
- 413, 414, 414, 414, 414, 414, 414, 414, 643, 1186,
- 713, 939, 414, 942, 954, 970, 606, 958, 414, 414,
-
- 414, 414, 414, 414, 415, 415, 415, 415, 415, 415,
- 415, 415, 418, 418, 418, 418, 418, 418, 418, 418,
- 418, 970, 607, 1182, 418, 1175, 418, 1174, 1173, 1169,
- 418, 418, 418, 418, 418, 418, 607, 614, 614, 614,
- 614, 614, 614, 614, 616, 616, 616, 616, 616, 616,
- 616, 996, 418, 424, 424, 424, 424, 424, 424, 424,
- 424, 424, 607, 1168, 1165, 424, 1161, 424, 1160, 996,
- 1159, 424, 424, 424, 424, 424, 424, 620, 620, 620,
- 620, 620, 620, 620, 668, 668, 668, 668, 668, 668,
- 668, 696, 715, 424, 430, 430, 430, 430, 430, 430,
-
- 430, 430, 430, 1155, 1154, 696, 430, 1151, 1016, 1069,
- 715, 991, 430, 430, 430, 430, 430, 430, 432, 432,
- 432, 432, 432, 432, 432, 432, 432, 715, 1147, 991,
- 432, 696, 432, 991, 1016, 1069, 432, 432, 432, 432,
- 432, 432, 673, 673, 673, 673, 673, 673, 673, 677,
- 677, 677, 677, 677, 677, 677, 697, 804, 432, 442,
- 442, 442, 442, 442, 442, 442, 442, 442, 1146, 1145,
- 697, 442, 1081, 994, 1141, 804, 700, 442, 442, 442,
- 442, 442, 442, 443, 443, 443, 443, 443, 443, 443,
- 700, 994, 804, 1140, 443, 994, 697, 995, 1081, 1084,
-
- 443, 443, 443, 443, 443, 443, 488, 701, 488, 488,
- 488, 488, 488, 488, 488, 995, 700, 1084, 1137, 488,
- 995, 701, 1134, 1133, 1087, 488, 488, 488, 488, 488,
- 488, 489, 489, 489, 489, 489, 489, 489, 489, 1132,
- 1026, 1084, 1087, 489, 1087, 489, 1128, 701, 1026, 489,
- 489, 489, 489, 489, 489, 682, 682, 682, 682, 682,
- 682, 682, 684, 684, 684, 684, 684, 684, 684, 751,
- 809, 489, 491, 491, 491, 491, 491, 491, 491, 491,
- 1098, 1037, 1127, 751, 491, 1101, 1124, 1123, 809, 1037,
- 491, 491, 491, 491, 491, 491, 495, 495, 495, 495,
-
- 495, 495, 495, 495, 1049, 1061, 1098, 809, 495, 751,
- 1104, 1101, 1049, 1061, 495, 495, 495, 495, 495, 495,
- 496, 496, 496, 496, 496, 496, 496, 496, 497, 497,
- 497, 497, 497, 497, 497, 1122, 1104, 1118, 1116, 497,
- 1107, 1110, 1135, 1149, 1115, 497, 497, 497, 497, 497,
- 497, 498, 498, 498, 498, 498, 498, 498, 498, 500,
- 500, 500, 500, 500, 500, 500, 1107, 1110, 1135, 1149,
- 500, 1163, 1197, 1085, 1086, 1088, 500, 500, 500, 500,
- 500, 500, 501, 501, 501, 501, 501, 501, 501, 501,
- 501, 1085, 1086, 1088, 501, 1260, 1091, 1163, 1197, 752,
-
- 501, 501, 501, 501, 501, 501, 502, 502, 502, 502,
- 502, 502, 502, 752, 1091, 1085, 1086, 502, 1112, 1091,
- 1092, 1260, 1111, 502, 502, 502, 502, 502, 502, 506,
- 506, 506, 506, 506, 506, 506, 506, 1108, 1092, 752,
- 506, 1105, 1102, 1099, 1188, 1089, 506, 506, 506, 506,
- 506, 506, 508, 508, 508, 508, 508, 508, 508, 508,
- 508, 1181, 1188, 1089, 508, 1095, 1083, 1189, 1190, 1181,
- 508, 508, 508, 508, 508, 508, 509, 509, 509, 509,
- 509, 509, 509, 509, 1089, 1189, 1190, 509, 1082, 1079,
- 1191, 1192, 1274, 509, 509, 509, 509, 509, 509, 517,
-
- 517, 517, 517, 517, 517, 517, 517, 517, 1191, 1192,
- 1274, 517, 1075, 1274, 1192, 1275, 1074, 517, 517, 517,
- 517, 517, 517, 518, 518, 518, 518, 518, 518, 518,
- 518, 1225, 1071, 1275, 518, 1297, 1275, 1066, 1276, 1225,
- 518, 518, 518, 518, 518, 518, 527, 527, 527, 527,
- 527, 527, 527, 527, 527, 1232, 1276, 1306, 527, 1315,
- 1324, 1297, 1065, 1232, 527, 527, 527, 527, 527, 527,
- 529, 529, 529, 529, 529, 529, 529, 529, 529, 1240,
- 1276, 1062, 529, 1306, 529, 1315, 1324, 1240, 529, 529,
- 529, 529, 529, 529, 688, 688, 688, 688, 688, 688,
-
- 688, 694, 694, 694, 694, 694, 694, 694, 802, 759,
- 529, 569, 569, 569, 569, 569, 569, 569, 1378, 1248,
- 1392, 1396, 569, 759, 1054, 1343, 802, 1248, 569, 569,
- 569, 569, 569, 569, 571, 571, 571, 571, 571, 571,
- 571, 802, 1256, 1343, 1378, 571, 1392, 1396, 1400, 759,
- 1256, 571, 571, 571, 571, 571, 571, 572, 572, 572,
- 572, 572, 572, 572, 572, 574, 574, 574, 574, 574,
- 574, 574, 1288, 1337, 1400, 1404, 574, 1408, 1193, 1386,
- 1288, 1337, 574, 574, 574, 574, 574, 574, 576, 576,
- 576, 576, 576, 576, 576, 576, 1193, 1386, 1053, 1050,
-
- 576, 1404, 1416, 1408, 1425, 1193, 576, 576, 576, 576,
- 576, 576, 577, 577, 577, 577, 577, 577, 577, 577,
- 578, 578, 578, 578, 578, 578, 578, 1384, 1416, 1042,
- 1425, 578, 1041, 1038, 1031, 1384, 1030, 578, 578, 578,
- 578, 578, 578, 579, 579, 579, 579, 579, 579, 579,
- 579, 582, 582, 582, 582, 582, 582, 582, 582, 582,
- 714, 760, 763, 582, 1027, 582, 1388, 1022, 764, 582,
- 582, 582, 582, 582, 582, 760, 763, 1021, 714, 1018,
- 1017, 1014, 764, 1013, 1388, 724, 1010, 719, 1007, 725,
- 714, 582, 585, 585, 585, 585, 585, 585, 585, 585,
-
- 585, 760, 763, 724, 585, 719, 585, 725, 764, 990,
- 585, 585, 585, 585, 585, 585, 724, 719, 1004, 725,
- 731, 731, 731, 731, 731, 731, 731, 990, 774, 775,
- 778, 888, 585, 591, 591, 591, 591, 591, 591, 591,
- 591, 591, 774, 775, 778, 591, 990, 591, 1000, 888,
- 779, 591, 591, 591, 591, 591, 591, 772, 772, 772,
- 772, 772, 772, 772, 779, 1342, 888, 983, 774, 775,
- 778, 873, 979, 591, 596, 596, 596, 596, 596, 596,
- 596, 596, 596, 1342, 972, 873, 596, 971, 968, 1415,
- 779, 1342, 596, 596, 596, 596, 596, 596, 598, 598,
-
- 598, 598, 598, 598, 598, 598, 598, 1415, 964, 963,
- 598, 873, 598, 960, 956, 955, 598, 598, 598, 598,
- 598, 598, 787, 787, 787, 787, 787, 787, 787, 789,
- 789, 789, 789, 789, 789, 789, 874, 890, 598, 608,
- 608, 608, 608, 608, 608, 608, 608, 608, 952, 948,
- 874, 608, 947, 944, 941, 890, 890, 608, 608, 608,
- 608, 608, 608, 610, 610, 610, 610, 610, 610, 610,
- 610, 610, 940, 890, 937, 610, 874, 610, 933, 993,
- 807, 610, 610, 610, 610, 610, 610, 793, 793, 793,
- 793, 793, 793, 793, 932, 929, 928, 993, 807, 925,
-
- 877, 878, 885, 610, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 807, 877, 878, 621, 993, 921, 917,
- 885, 916, 621, 621, 621, 621, 621, 621, 622, 622,
- 622, 622, 622, 622, 622, 885, 915, 912, 909, 622,
- 877, 878, 906, 903, 902, 622, 622, 622, 622, 622,
- 622, 625, 625, 625, 625, 625, 625, 625, 884, 883,
- 880, 876, 625, 886, 887, 891, 893, 1273, 625, 625,
- 625, 625, 625, 625, 832, 832, 832, 832, 832, 832,
- 832, 886, 887, 891, 893, 1273, 625, 648, 875, 648,
- 648, 648, 648, 648, 648, 648, 886, 887, 887, 891,
-
- 648, 893, 1273, 989, 992, 1093, 648, 648, 648, 648,
- 648, 648, 837, 837, 837, 837, 837, 837, 837, 922,
- 923, 989, 992, 1093, 648, 649, 649, 649, 649, 649,
- 649, 649, 649, 922, 923, 989, 992, 649, 1093, 872,
- 867, 863, 855, 649, 649, 649, 649, 649, 649, 841,
- 841, 841, 841, 841, 841, 841, 851, 844, 840, 922,
- 923, 649, 650, 650, 650, 650, 650, 650, 650, 846,
- 846, 846, 846, 846, 846, 846, 848, 848, 848, 848,
- 848, 848, 848, 852, 852, 852, 852, 852, 852, 852,
- 858, 858, 858, 858, 858, 858, 858, 650, 651, 651,
-
- 651, 651, 651, 651, 651, 835, 830, 829, 828, 651,
- 825, 822, 818, 796, 792, 651, 651, 651, 651, 651,
- 651, 653, 653, 653, 653, 653, 653, 653, 653, 655,
- 655, 655, 655, 655, 655, 655, 655, 785, 784, 781,
- 777, 655, 776, 773, 770, 769, 766, 655, 655, 655,
- 655, 655, 655, 656, 656, 656, 656, 656, 656, 656,
- 656, 658, 658, 658, 658, 658, 658, 658, 762, 761,
- 758, 757, 658, 754, 750, 747, 746, 745, 658, 658,
- 658, 658, 658, 658, 659, 659, 659, 659, 659, 659,
- 659, 659, 659, 744, 741, 738, 659, 735, 734, 707,
-
- 706, 930, 659, 659, 659, 659, 659, 659, 660, 660,
- 660, 660, 660, 660, 660, 930, 703, 699, 698, 660,
- 695, 691, 687, 680, 676, 660, 660, 660, 660, 660,
- 660, 662, 662, 662, 662, 662, 662, 662, 662, 662,
- 671, 930, 666, 662, 665, 664, 661, 657, 931, 662,
- 662, 662, 662, 662, 662, 663, 663, 663, 663, 663,
- 663, 663, 931, 647, 646, 642, 663, 641, 639, 638,
- 633, 623, 663, 663, 663, 663, 663, 663, 667, 667,
- 667, 667, 667, 667, 667, 667, 619, 613, 931, 667,
- 612, 609, 605, 604, 601, 667, 667, 667, 667, 667,
-
- 667, 669, 669, 669, 669, 669, 669, 669, 669, 669,
- 600, 597, 593, 669, 590, 589, 588, 587, 584, 669,
- 669, 669, 669, 669, 669, 670, 670, 670, 670, 670,
- 670, 670, 670, 581, 580, 573, 670, 570, 568, 564,
- 560, 559, 670, 670, 670, 670, 670, 670, 678, 678,
- 678, 678, 678, 678, 678, 678, 678, 558, 557, 553,
- 678, 552, 550, 549, 548, 547, 678, 678, 678, 678,
- 678, 678, 679, 679, 679, 679, 679, 679, 679, 679,
- 546, 545, 544, 679, 543, 542, 541, 540, 539, 679,
- 679, 679, 679, 679, 679, 689, 689, 689, 689, 689,
-
- 689, 689, 689, 689, 536, 535, 534, 689, 532, 531,
- 528, 523, 519, 689, 689, 689, 689, 689, 689, 690,
- 690, 690, 690, 690, 690, 690, 690, 515, 510, 505,
- 690, 504, 503, 499, 493, 492, 690, 690, 690, 690,
- 690, 690, 702, 702, 702, 702, 702, 702, 702, 702,
- 702, 487, 486, 485, 702, 484, 483, 482, 481, 480,
- 702, 702, 702, 702, 702, 702, 704, 704, 704, 704,
- 704, 704, 704, 704, 704, 479, 478, 477, 704, 475,
- 704, 472, 471, 470, 704, 704, 704, 704, 704, 704,
- 860, 860, 860, 860, 860, 860, 860, 864, 864, 864,
-
- 864, 864, 864, 864, 934, 935, 704, 726, 945, 726,
- 726, 726, 726, 726, 726, 726, 469, 468, 934, 935,
- 726, 467, 945, 466, 464, 726, 726, 726, 726, 726,
- 726, 726, 728, 728, 728, 728, 728, 728, 728, 463,
- 462, 461, 459, 728, 934, 935, 457, 456, 945, 728,
- 728, 728, 728, 728, 728, 730, 730, 730, 730, 730,
- 730, 730, 455, 454, 453, 452, 730, 451, 1341, 449,
- 448, 447, 730, 730, 730, 730, 730, 730, 732, 732,
- 732, 732, 732, 732, 732, 732, 1341, 444, 440, 436,
- 732, 435, 434, 431, 427, 1341, 732, 732, 732, 732,
-
- 732, 732, 733, 733, 733, 733, 733, 733, 733, 733,
- 736, 736, 736, 736, 736, 736, 736, 736, 736, 426,
- 423, 422, 736, 421, 736, 420, 417, 416, 736, 736,
- 736, 736, 736, 736, 871, 871, 871, 871, 871, 871,
- 871, 943, 943, 943, 943, 943, 943, 943, 946, 407,
- 736, 739, 739, 739, 739, 739, 739, 739, 739, 739,
- 404, 949, 946, 739, 402, 739, 401, 950, 961, 739,
- 739, 739, 739, 739, 739, 949, 400, 399, 398, 397,
- 396, 950, 961, 395, 394, 393, 392, 1340, 946, 962,
- 391, 739, 742, 742, 742, 742, 742, 742, 742, 742,
-
- 742, 949, 389, 962, 742, 1340, 742, 950, 961, 965,
- 742, 742, 742, 742, 742, 742, 959, 959, 959, 959,
- 959, 959, 959, 965, 1340, 387, 386, 384, 966, 962,
- 1072, 383, 742, 748, 748, 748, 748, 748, 748, 748,
- 748, 748, 966, 380, 1072, 748, 379, 748, 377, 965,
- 1073, 748, 748, 748, 748, 748, 748, 974, 974, 974,
- 974, 974, 974, 974, 1073, 375, 374, 373, 966, 1076,
- 1072, 1077, 370, 748, 753, 753, 753, 753, 753, 753,
- 753, 753, 753, 1076, 369, 1077, 753, 367, 366, 365,
- 1073, 364, 753, 753, 753, 753, 753, 753, 755, 755,
-
- 755, 755, 755, 755, 755, 755, 755, 362, 357, 1076,
- 755, 1077, 755, 356, 355, 352, 755, 755, 755, 755,
- 755, 755, 976, 976, 976, 976, 976, 976, 976, 980,
- 980, 980, 980, 980, 980, 980, 1119, 348, 755, 765,
- 765, 765, 765, 765, 765, 765, 765, 765, 346, 341,
- 1119, 765, 340, 337, 332, 331, 323, 765, 765, 765,
- 765, 765, 765, 767, 767, 767, 767, 767, 767, 767,
- 767, 767, 985, 986, 1120, 767, 1119, 767, 321, 320,
- 315, 767, 767, 767, 767, 767, 767, 313, 1120, 311,
- 985, 986, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1125,
-
- 310, 985, 986, 767, 780, 780, 780, 780, 780, 780,
- 780, 780, 780, 1125, 1120, 309, 780, 308, 307, 306,
- 305, 303, 780, 780, 780, 780, 780, 780, 782, 782,
- 782, 782, 782, 782, 782, 782, 782, 987, 1126, 1125,
- 782, 302, 782, 301, 296, 1387, 782, 782, 782, 782,
- 782, 782, 1126, 293, 292, 987, 1024, 1024, 1024, 1024,
- 1024, 1024, 1024, 1387, 291, 1129, 987, 288, 782, 794,
- 794, 794, 794, 794, 794, 794, 794, 794, 1126, 1129,
- 285, 794, 1387, 284, 282, 280, 1130, 794, 794, 794,
- 794, 794, 794, 795, 795, 795, 795, 795, 795, 795,
-
- 1130, 279, 278, 276, 795, 1129, 272, 271, 269, 266,
- 795, 795, 795, 795, 795, 795, 811, 1138, 811, 811,
- 811, 811, 811, 811, 811, 262, 1130, 261, 258, 811,
- 257, 1138, 255, 250, 811, 811, 811, 811, 811, 811,
- 811, 812, 812, 812, 812, 812, 812, 812, 247, 245,
- 244, 242, 812, 239, 235, 231, 229, 1138, 812, 812,
- 812, 812, 812, 812, 813, 813, 813, 813, 813, 813,
- 813, 813, 227, 226, 224, 223, 813, 222, 813, 221,
- 220, 219, 813, 813, 813, 813, 813, 813, 1028, 1028,
- 1028, 1028, 1028, 1028, 1028, 1033, 1033, 1033, 1033, 1033,
-
- 1033, 1033, 218, 1139, 813, 815, 815, 815, 815, 815,
- 815, 815, 216, 214, 212, 211, 815, 1139, 209, 207,
- 206, 204, 815, 815, 815, 815, 815, 815, 816, 816,
- 816, 816, 816, 816, 816, 816, 201, 200, 199, 197,
- 816, 195, 194, 1139, 191, 190, 816, 816, 816, 816,
- 816, 816, 817, 817, 817, 817, 817, 817, 817, 817,
- 819, 819, 819, 819, 819, 819, 819, 188, 187, 186,
- 185, 819, 184, 183, 182, 181, 180, 819, 819, 819,
- 819, 819, 819, 820, 820, 820, 820, 820, 820, 820,
- 820, 820, 179, 177, 176, 820, 173, 172, 171, 170,
-
- 1142, 820, 820, 820, 820, 820, 820, 821, 821, 821,
- 821, 821, 821, 821, 1142, 169, 168, 167, 821, 166,
- 164, 161, 160, 159, 821, 821, 821, 821, 821, 821,
- 823, 823, 823, 823, 823, 823, 823, 823, 823, 158,
- 1142, 155, 823, 153, 144, 143, 142, 1143, 823, 823,
- 823, 823, 823, 823, 824, 824, 824, 824, 824, 824,
- 824, 1143, 141, 140, 139, 824, 138, 136, 134, 133,
- 131, 824, 824, 824, 824, 824, 824, 826, 826, 826,
- 826, 826, 826, 826, 826, 826, 129, 1143, 127, 826,
- 126, 125, 124, 122, 1152, 826, 826, 826, 826, 826,
-
- 826, 827, 827, 827, 827, 827, 827, 827, 1152, 121,
- 120, 119, 827, 118, 117, 115, 113, 112, 827, 827,
- 827, 827, 827, 827, 831, 831, 831, 831, 831, 831,
- 831, 831, 111, 110, 1152, 831, 109, 108, 107, 106,
- 105, 831, 831, 831, 831, 831, 831, 833, 833, 833,
- 833, 833, 833, 833, 833, 833, 103, 102, 95, 833,
- 94, 93, 91, 90, 89, 833, 833, 833, 833, 833,
- 833, 834, 834, 834, 834, 834, 834, 834, 834, 88,
- 87, 86, 834, 85, 84, 82, 81, 80, 834, 834,
- 834, 834, 834, 834, 842, 842, 842, 842, 842, 842,
-
- 842, 842, 842, 79, 78, 77, 842, 76, 75, 74,
- 73, 72, 842, 842, 842, 842, 842, 842, 843, 843,
- 843, 843, 843, 843, 843, 843, 71, 70, 69, 843,
- 67, 66, 65, 51, 43, 843, 843, 843, 843, 843,
- 843, 853, 853, 853, 853, 853, 853, 853, 853, 853,
- 42, 40, 30, 853, 18, 10, 8, 3, 0, 853,
- 853, 853, 853, 853, 853, 854, 854, 854, 854, 854,
- 854, 854, 854, 0, 0, 0, 854, 0, 0, 0,
- 0, 0, 854, 854, 854, 854, 854, 854, 865, 865,
- 865, 865, 865, 865, 865, 865, 865, 0, 0, 0,
-
- 865, 0, 0, 0, 0, 0, 865, 865, 865, 865,
- 865, 865, 866, 866, 866, 866, 866, 866, 866, 866,
- 0, 0, 0, 866, 0, 0, 0, 0, 0, 866,
- 866, 866, 866, 866, 866, 879, 879, 879, 879, 879,
- 879, 879, 879, 879, 0, 0, 0, 879, 0, 0,
- 0, 0, 0, 879, 879, 879, 879, 879, 879, 881,
- 881, 881, 881, 881, 881, 881, 881, 881, 0, 0,
- 0, 881, 0, 881, 0, 0, 0, 881, 881, 881,
- 881, 881, 881, 1035, 1035, 1035, 1035, 1035, 1035, 1035,
- 1039, 1039, 1039, 1039, 1039, 1039, 1039, 0, 0, 881,
-
- 898, 898, 898, 898, 898, 898, 898, 898, 898, 0,
- 0, 0, 0, 898, 0, 0, 0, 0, 898, 898,
- 898, 898, 898, 898, 898, 899, 899, 899, 899, 899,
- 899, 899, 899, 900, 900, 900, 900, 900, 900, 900,
- 900, 900, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 0,
- 0, 900, 904, 904, 904, 904, 904, 904, 904, 904,
- 904, 0, 0, 0, 904, 0, 904, 0, 0, 0,
- 904, 904, 904, 904, 904, 904, 1047, 1047, 1047, 1047,
- 1047, 1047, 1047, 1051, 1051, 1051, 1051, 1051, 1051, 1051,
- 0, 0, 904, 907, 907, 907, 907, 907, 907, 907,
-
- 907, 907, 0, 0, 0, 907, 0, 907, 0, 0,
- 0, 907, 907, 907, 907, 907, 907, 1057, 1057, 1057,
- 1057, 1057, 1057, 1057, 1059, 1059, 1059, 1059, 1059, 1059,
- 1059, 0, 0, 907, 910, 910, 910, 910, 910, 910,
- 910, 910, 910, 0, 0, 0, 910, 0, 910, 0,
- 0, 0, 910, 910, 910, 910, 910, 910, 1063, 1063,
- 1063, 1063, 1063, 1063, 1063, 1070, 1070, 1070, 1070, 1070,
- 1070, 1070, 1090, 0, 910, 913, 913, 913, 913, 913,
- 913, 913, 913, 913, 0, 1153, 1156, 913, 0, 913,
- 1090, 0, 0, 913, 913, 913, 913, 913, 913, 1153,
-
- 1156, 1090, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 0,
- 1157, 0, 0, 0, 1166, 913, 918, 918, 918, 918,
- 918, 918, 918, 918, 1157, 1153, 1156, 918, 1166, 0,
- 0, 0, 0, 918, 918, 918, 918, 918, 918, 919,
- 919, 919, 919, 919, 919, 919, 919, 919, 0, 0,
- 1157, 919, 0, 919, 1166, 0, 0, 919, 919, 919,
- 919, 919, 919, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
- 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1167, 0, 919,
- 924, 924, 924, 924, 924, 924, 924, 924, 924, 0,
- 0, 1167, 924, 0, 0, 0, 0, 0, 924, 924,
-
- 924, 924, 924, 924, 926, 926, 926, 926, 926, 926,
- 926, 926, 926, 0, 0, 0, 926, 1167, 926, 0,
- 0, 1170, 926, 926, 926, 926, 926, 926, 1164, 1164,
- 1164, 1164, 1164, 1164, 1164, 1170, 0, 0, 0, 0,
- 1171, 0, 1215, 0, 926, 936, 936, 936, 936, 936,
- 936, 936, 936, 936, 1171, 0, 1215, 936, 0, 0,
- 0, 1170, 0, 936, 936, 936, 936, 936, 936, 938,
- 938, 938, 938, 938, 938, 938, 938, 938, 0, 0,
- 1171, 938, 1215, 938, 0, 0, 0, 938, 938, 938,
- 938, 938, 938, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
-
- 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1216, 0, 938,
- 951, 951, 951, 951, 951, 951, 951, 951, 951, 0,
- 0, 1216, 951, 0, 0, 0, 0, 0, 951, 951,
- 951, 951, 951, 951, 953, 953, 953, 953, 953, 953,
- 953, 953, 953, 0, 0, 0, 953, 1216, 953, 0,
- 0, 0, 953, 953, 953, 953, 953, 953, 1183, 1183,
- 1183, 1183, 1183, 1183, 1183, 1223, 1223, 1223, 1223, 1223,
- 1223, 1223, 1263, 0, 953, 967, 967, 967, 967, 967,
- 967, 967, 967, 967, 0, 0, 1263, 967, 0, 0,
- 0, 0, 1194, 967, 967, 967, 967, 967, 967, 969,
-
- 969, 969, 969, 969, 969, 969, 969, 969, 1195, 0,
- 1194, 969, 1263, 969, 0, 0, 0, 969, 969, 969,
- 969, 969, 969, 1194, 0, 0, 1195, 1228, 1228, 1228,
- 1228, 1228, 1228, 1228, 0, 0, 1264, 1195, 0, 969,
- 981, 981, 981, 981, 981, 981, 981, 981, 981, 0,
- 1264, 0, 981, 0, 0, 0, 0, 1267, 981, 981,
- 981, 981, 981, 981, 982, 982, 982, 982, 982, 982,
- 982, 1267, 0, 0, 0, 982, 1264, 0, 0, 0,
- 0, 982, 982, 982, 982, 982, 982, 997, 997, 997,
- 997, 997, 997, 997, 997, 997, 0, 1267, 0, 0,
-
- 997, 0, 0, 0, 0, 997, 997, 997, 997, 997,
- 997, 997, 998, 998, 998, 998, 998, 998, 998, 998,
- 999, 999, 999, 999, 999, 999, 999, 999, 999, 1230,
- 1230, 1230, 1230, 1230, 1230, 1230, 0, 1268, 999, 1001,
- 1001, 1001, 1001, 1001, 1001, 1001, 0, 0, 0, 0,
- 1001, 1268, 0, 0, 0, 0, 1001, 1001, 1001, 1001,
- 1001, 1001, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002,
- 1002, 0, 0, 0, 1002, 0, 0, 1268, 0, 1292,
- 1002, 1002, 1002, 1002, 1002, 1002, 1003, 1003, 1003, 1003,
- 1003, 1003, 1003, 1292, 0, 0, 0, 1003, 0, 0,
-
- 0, 0, 0, 1003, 1003, 1003, 1003, 1003, 1003, 1005,
- 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 0, 1292,
- 0, 1005, 0, 0, 0, 0, 1293, 1005, 1005, 1005,
- 1005, 1005, 1005, 1006, 1006, 1006, 1006, 1006, 1006, 1006,
- 1293, 0, 0, 0, 1006, 0, 0, 0, 0, 0,
- 1006, 1006, 1006, 1006, 1006, 1006, 1008, 1008, 1008, 1008,
- 1008, 1008, 1008, 1008, 1008, 0, 1293, 0, 1008, 0,
- 0, 0, 0, 1300, 1008, 1008, 1008, 1008, 1008, 1008,
- 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1300, 0, 0,
- 0, 1009, 0, 0, 0, 0, 0, 1009, 1009, 1009,
-
- 1009, 1009, 1009, 1011, 1011, 1011, 1011, 1011, 1011, 1011,
- 1011, 1011, 0, 1300, 0, 1011, 0, 0, 0, 0,
- 1301, 1011, 1011, 1011, 1011, 1011, 1011, 1012, 1012, 1012,
- 1012, 1012, 1012, 1012, 1301, 0, 0, 0, 1012, 0,
- 0, 0, 0, 0, 1012, 1012, 1012, 1012, 1012, 1012,
- 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 0,
- 1301, 0, 1015, 0, 1015, 0, 0, 0, 1015, 1015,
- 1015, 1015, 1015, 1015, 1236, 1236, 1236, 1236, 1236, 1236,
- 1236, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1309, 0,
- 1015, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020,
-
- 0, 0, 1309, 1020, 0, 0, 0, 0, 0, 1020,
- 1020, 1020, 1020, 1020, 1020, 1029, 1029, 1029, 1029, 1029,
- 1029, 1029, 1029, 1029, 0, 0, 0, 1029, 1309, 0,
- 0, 0, 0, 1029, 1029, 1029, 1029, 1029, 1029, 1040,
- 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 0, 0,
- 0, 1040, 0, 0, 0, 0, 0, 1040, 1040, 1040,
- 1040, 1040, 1040, 1052, 1052, 1052, 1052, 1052, 1052, 1052,
- 1052, 1052, 0, 0, 0, 1052, 0, 0, 0, 0,
- 0, 1052, 1052, 1052, 1052, 1052, 1052, 1064, 1064, 1064,
- 1064, 1064, 1064, 1064, 1064, 1064, 0, 0, 0, 1064,
-
- 0, 0, 0, 0, 0, 1064, 1064, 1064, 1064, 1064,
- 1064, 1078, 1078, 1078, 1078, 1078, 1078, 1078, 1078, 1078,
- 0, 0, 0, 1078, 0, 0, 0, 0, 0, 1078,
- 1078, 1078, 1078, 1078, 1078, 1080, 1080, 1080, 1080, 1080,
- 1080, 1080, 1080, 1080, 0, 0, 0, 1080, 0, 1080,
- 0, 0, 0, 1080, 1080, 1080, 1080, 1080, 1080, 1244,
- 1244, 1244, 1244, 1244, 1244, 1244, 1246, 1246, 1246, 1246,
- 1246, 1246, 1246, 0, 0, 1080, 1094, 1094, 1094, 1094,
- 1094, 1094, 1094, 1094, 1094, 1252, 1252, 1252, 1252, 1252,
- 1252, 1252, 0, 1310, 1094, 1096, 1096, 1096, 1096, 1096,
-
- 1096, 1096, 1096, 0, 0, 0, 1096, 1310, 0, 0,
- 0, 0, 1096, 1096, 1096, 1096, 1096, 1096, 1097, 1097,
- 1097, 1097, 1097, 1097, 1097, 1097, 1097, 0, 0, 0,
- 1097, 0, 1097, 1310, 0, 0, 1097, 1097, 1097, 1097,
- 1097, 1097, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1261,
- 1261, 1261, 1261, 1261, 1261, 1261, 0, 0, 1097, 1100,
- 1100, 1100, 1100, 1100, 1100, 1100, 1100, 1100, 0, 0,
- 0, 1100, 0, 1100, 0, 0, 0, 1100, 1100, 1100,
- 1100, 1100, 1100, 1286, 1286, 1286, 1286, 1286, 1286, 1286,
- 1298, 1298, 1298, 1298, 1298, 1298, 1298, 0, 0, 1100,
-
- 1103, 1103, 1103, 1103, 1103, 1103, 1103, 1103, 1103, 0,
- 0, 0, 1103, 0, 1103, 0, 0, 0, 1103, 1103,
- 1103, 1103, 1103, 1103, 1307, 1307, 1307, 1307, 1307, 1307,
- 1307, 1316, 1316, 1316, 1316, 1316, 1316, 1316, 1318, 0,
- 1103, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106,
- 0, 1319, 1318, 1106, 0, 1106, 0, 0, 0, 1106,
- 1106, 1106, 1106, 1106, 1106, 1319, 1325, 1325, 1325, 1325,
- 1325, 1325, 1325, 0, 0, 0, 0, 0, 1318, 1327,
- 0, 1106, 1109, 1109, 1109, 1109, 1109, 1109, 1109, 1109,
- 1109, 1319, 1328, 1327, 1109, 0, 1109, 0, 0, 0,
-
- 1109, 1109, 1109, 1109, 1109, 1109, 1328, 1333, 1333, 1333,
- 1333, 1333, 1333, 1333, 0, 0, 0, 0, 0, 1327,
- 1352, 0, 1109, 1114, 1114, 1114, 1114, 1114, 1114, 1114,
- 1114, 1114, 1328, 0, 1352, 1114, 0, 0, 0, 0,
- 0, 1114, 1114, 1114, 1114, 1114, 1114, 1121, 1121, 1121,
- 1121, 1121, 1121, 1121, 1121, 1121, 0, 0, 0, 1121,
- 1352, 0, 0, 0, 0, 1121, 1121, 1121, 1121, 1121,
- 1121, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
- 0, 0, 0, 1131, 0, 0, 0, 0, 0, 1131,
- 1131, 1131, 1131, 1131, 1131, 1144, 1144, 1144, 1144, 1144,
-
- 1144, 1144, 1144, 1144, 0, 0, 0, 1144, 0, 0,
- 0, 0, 0, 1144, 1144, 1144, 1144, 1144, 1144, 1158,
- 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 0, 0,
- 0, 1158, 0, 0, 0, 0, 0, 1158, 1158, 1158,
- 1158, 1158, 1158, 1172, 1172, 1172, 1172, 1172, 1172, 1172,
- 1172, 1172, 0, 0, 0, 1172, 0, 0, 0, 0,
- 0, 1172, 1172, 1172, 1172, 1172, 1172, 1184, 1184, 1184,
- 1184, 1184, 1184, 1184, 1184, 1184, 0, 0, 0, 1184,
- 0, 0, 0, 0, 0, 1184, 1184, 1184, 1184, 1184,
- 1184, 1196, 1196, 1196, 1196, 1196, 1196, 1196, 1196, 1196,
-
- 0, 0, 0, 1196, 0, 1196, 0, 0, 1353, 1196,
- 1196, 1196, 1196, 1196, 1196, 1335, 1335, 1335, 1335, 1335,
- 1335, 1335, 1353, 1358, 1358, 1358, 1358, 1358, 1358, 1358,
- 0, 1196, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200,
- 1200, 0, 0, 0, 1200, 0, 0, 0, 1353, 0,
- 1200, 1200, 1200, 1200, 1200, 1200, 1203, 1203, 1203, 1203,
- 1203, 1203, 1203, 1203, 1203, 0, 0, 0, 1203, 0,
- 0, 0, 0, 0, 1203, 1203, 1203, 1203, 1203, 1203,
- 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 0,
- 0, 0, 1206, 0, 0, 0, 0, 0, 1206, 1206,
-
- 1206, 1206, 1206, 1206, 1209, 1209, 1209, 1209, 1209, 1209,
- 1209, 1209, 1209, 0, 0, 0, 1209, 0, 0, 0,
- 0, 0, 1209, 1209, 1209, 1209, 1209, 1209, 1212, 1212,
- 1212, 1212, 1212, 1212, 1212, 1212, 1212, 0, 0, 0,
- 1212, 0, 0, 0, 0, 0, 1212, 1212, 1212, 1212,
- 1212, 1212, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217,
- 1217, 0, 0, 0, 1217, 0, 0, 0, 0, 0,
- 1217, 1217, 1217, 1217, 1217, 1217, 1269, 1269, 1269, 1269,
- 1269, 1269, 1269, 1269, 1269, 0, 0, 0, 1269, 0,
- 0, 0, 0, 0, 1269, 1269, 1269, 1269, 1269, 1269,
-
- 1277, 1277, 1277, 1277, 1277, 1277, 1277, 1277, 1277, 0,
- 0, 0, 1277, 0, 0, 0, 0, 0, 1277, 1277,
- 1277, 1277, 1277, 1277, 1362, 1362, 1362, 1362, 1362, 1362,
- 1362, 1366, 1366, 1366, 1366, 1366, 1366, 1366, 1370, 1370,
- 1370, 1370, 1370, 1370, 1370, 1374, 1374, 1374, 1374, 1374,
- 1374, 1374, 1379, 1379, 1379, 1379, 1379, 1379, 1379, 1381,
- 1382, 1390, 1390, 1390, 1390, 1390, 1390, 1390, 0, 0,
- 0, 0, 0, 1381, 1382, 1393, 1393, 1393, 1393, 1393,
- 1393, 1393, 1397, 1397, 1397, 1397, 1397, 1397, 1397, 1401,
- 1401, 1401, 1401, 1401, 1401, 1401, 0, 0, 0, 1381,
-
- 1382, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1409, 1409,
- 1409, 1409, 1409, 1409, 1409, 1412, 1412, 1412, 1412, 1412,
- 1412, 1412, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1426,
- 1426, 1426, 1426, 1426, 1426, 1426, 1438, 0, 0, 0,
- 0, 1438, 1438, 1438, 1439, 0, 1439, 1439, 1439, 1439,
- 1439, 1439, 1439, 1440, 0, 1440, 1441, 1441, 1441, 1442,
- 1442, 1442, 1443, 1443, 1443, 1444, 1444, 1444, 1445, 1445,
- 1445, 1446, 1446, 1446, 1447, 1447, 1447, 1448, 1448, 1448,
- 1449, 1449, 1449, 1450, 0, 1450, 1451, 1451, 1451, 1452,
- 1452, 1452, 1453, 1453, 1453, 1454, 1454, 1454, 1455, 0,
-
- 1455, 1456, 1456, 1456, 1457, 1457, 0, 0, 1457, 1458,
- 1458, 1458, 1459, 1459, 1459, 1460, 1460, 1460, 1461, 1461,
- 1461, 1462, 1462, 1462, 1463, 1463, 1463, 1464, 1464, 1464,
- 1465, 1465, 1465, 1466, 1466, 1466, 1467, 1467, 0, 0,
- 1467, 1468, 1468, 1468, 1469, 1469, 1469, 1470, 0, 1470,
- 1471, 1471, 1471, 1472, 1472, 1472, 1473, 0, 1473, 1474,
- 1474, 1474, 1475, 1475, 1475, 1476, 1476, 1476, 1477, 1477,
- 1477, 1478, 1478, 1478, 1479, 0, 1479, 1480, 0, 1480,
- 1481, 1481, 1481, 1482, 1482, 1482, 1483, 0, 1483, 1484,
- 1484, 0, 0, 1484, 1485, 1485, 0, 0, 1485, 1486,
-
- 1486, 1486, 1487, 1487, 1487, 1488, 1488, 0, 1488, 1489,
- 1489, 1489, 1490, 1490, 1490, 1491, 1491, 1491, 1492, 1492,
- 1492, 1493, 1493, 1493, 1494, 1494, 1494, 1495, 1495, 1495,
- 1496, 1496, 0, 0, 1496, 1497, 1497, 1497, 1498, 1498,
- 1498, 1499, 1499, 0, 1499, 1500, 1500, 0, 0, 1500,
- 1501, 1501, 0, 1501, 1502, 1502, 1503, 1503, 0, 0,
- 1503, 1504, 1504, 1504, 1505, 1505, 1505, 1506, 1506, 0,
- 1506, 1507, 0, 1507, 1508, 0, 1508, 1509, 1509, 1509,
- 1510, 1510, 1510, 1511, 0, 1511, 1512, 1512, 1512, 1513,
- 1513, 1513, 1514, 1514, 1514, 1515, 1515, 1515, 1516, 1516,
-
- 1516, 1517, 1517, 1517, 1518, 0, 1518, 1519, 0, 1519,
- 1520, 1520, 1520, 1521, 1521, 1521, 1522, 0, 1522, 1523,
- 0, 1523, 1524, 0, 1524, 1525, 1525, 1525, 1526, 1526,
- 1526, 1527, 0, 1527, 1528, 0, 0, 1528, 1529, 1529,
- 0, 1529, 1530, 1530, 0, 0, 1530, 1531, 1531, 0,
- 1531, 1532, 1532, 1533, 1533, 0, 0, 1533, 1534, 1534,
- 1534, 1535, 1535, 1535, 1536, 1536, 0, 1536, 1537, 1537,
- 1537, 0, 1537, 1537, 1538, 1538, 1538, 1539, 1539, 1539,
- 1540, 1540, 1540, 1541, 1541, 1541, 1542, 1542, 1542, 1543,
- 1543, 1543, 1544, 1544, 1544, 1545, 1545, 1545, 1546, 1546,
-
- 0, 0, 1546, 1547, 1547, 1547, 1548, 1548, 1548, 1549,
- 1549, 0, 1549, 1550, 1550, 0, 0, 1550, 1551, 1551,
- 0, 1551, 1552, 1552, 1553, 1553, 0, 0, 1553, 1554,
- 1554, 1554, 1555, 1555, 1555, 1556, 1556, 0, 1556, 1557,
- 0, 0, 1557, 1558, 1558, 0, 1558, 1559, 1559, 0,
- 0, 1559, 1560, 1560, 0, 1560, 1561, 1561, 1562, 1562,
- 0, 0, 1562, 1563, 1563, 1563, 1564, 1564, 1564, 1565,
- 1565, 0, 1565, 1566, 0, 1566, 1567, 0, 1567, 1568,
- 0, 1568, 1569, 1569, 1569, 1570, 1570, 1570, 1571, 0,
- 1571, 1572, 1572, 1572, 0, 1572, 1572, 1573, 1573, 1573,
-
- 1574, 1574, 1574, 1575, 1575, 1575, 1576, 1576, 1576, 1577,
- 1577, 1577, 1578, 1578, 1578, 1579, 1579, 1579, 1580, 0,
- 1580, 1581, 0, 1581, 1582, 1582, 1582, 1583, 1583, 1583,
- 1584, 0, 1584, 1585, 0, 1585, 1586, 0, 1586, 1587,
- 1587, 1587, 1588, 1588, 1588, 1589, 0, 1589, 1590, 0,
- 1590, 1591, 0, 1591, 1592, 0, 1592, 1593, 1593, 1593,
- 1594, 1594, 1594, 1595, 0, 1595, 1596, 0, 1596, 1597,
- 0, 0, 1597, 1598, 1598, 0, 1598, 1599, 1599, 0,
- 0, 1599, 1600, 1600, 0, 1600, 1601, 1601, 1602, 1602,
- 0, 0, 1602, 1603, 1603, 1603, 1604, 1604, 1604, 1605,
-
- 1605, 0, 1605, 1606, 1606, 1606, 0, 1606, 1606, 1607,
+ 14, 16, 83, 25, 16, 1240, 16, 16, 83, 129,
+ 29, 1243, 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, 30, 103, 30, 23, 134, 23, 103, 30, 30,
+ 35, 30, 35, 1246, 35, 30, 1250, 35, 20, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 32,
+ 32, 110, 21, 663, 110, 1251, 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,
+ 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,
+ 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,
+ 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,
+
+ 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,
+ 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,
+
+ 618, 154, 615, 554, 650, 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,
+ 156, 156, 157, 157, 157, 157, 157, 157, 157, 157,
+ 157, 686, 624, 631, 157, 455, 1289, 643, 684, 1290,
+ 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,
+ 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,
+ 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,
+ 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, 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,
+ 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,
+ 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,
+
+ 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, 364, 364, 364, 364, 364, 364, 364,
+ 364, 833, 835, 837, 364, 1386, 833, 835, 837, 838,
+ 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,
+
+ 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,
+ 396, 396, 396, 396, 430, 430, 430, 430, 430, 430,
+ 430, 634, 928, 635, 929, 430, 943, 933, 1020, 946,
+
+ 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,
+ 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,
+ 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,
+ 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,
+ 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, 1612, 1612, 1613, 1613, 1613,
- 1614, 1614, 1614, 1615, 1615, 0, 0, 1615, 1616, 1616,
- 1616, 1617, 1617, 1617, 1618, 1618, 0, 1618, 1619, 1619,
- 0, 0, 1619, 1620, 1620, 0, 1620, 1621, 1621, 1622,
- 1622, 0, 0, 1622, 1623, 1623, 1623, 1624, 1624, 1624,
- 1625, 1625, 0, 1625, 1626, 0, 0, 1626, 1627, 1627,
- 0, 1627, 1628, 1628, 0, 0, 1628, 1629, 1629, 0,
- 1629, 1630, 1630, 1631, 1631, 0, 0, 1631, 1632, 1632,
-
- 1632, 1633, 1633, 1633, 1634, 1634, 0, 1634, 1635, 0,
- 1635, 1636, 0, 0, 1636, 1637, 1637, 0, 1637, 1638,
- 1638, 0, 0, 1638, 1639, 1639, 0, 1639, 1640, 1640,
- 1641, 1641, 0, 0, 1641, 1642, 1642, 1642, 1643, 1643,
- 1643, 1644, 1644, 0, 1644, 1645, 0, 1645, 1646, 0,
- 1646, 1647, 0, 1647, 1648, 1648, 1648, 1649, 1649, 1649,
- 1650, 0, 1650, 1651, 1651, 1651, 0, 1651, 1651, 1652,
- 1652, 1652, 1653, 1653, 1653, 1654, 1654, 1654, 1655, 1655,
- 1655, 1656, 1656, 1656, 1657, 1657, 1657, 1658, 1658, 1658,
- 1659, 1659, 1659, 1660, 1660, 1660, 1661, 1661, 1661, 1662,
-
- 0, 1662, 1663, 0, 1663, 1664, 1664, 1664, 1665, 1665,
- 1665, 1666, 1666, 1666, 1667, 0, 1667, 1668, 0, 1668,
- 1669, 0, 1669, 1670, 1670, 1670, 1671, 1671, 1671, 1672,
- 1672, 1672, 1673, 0, 1673, 1674, 0, 1674, 1675, 0,
- 1675, 1676, 0, 1676, 1677, 1677, 1677, 1678, 1678, 1678,
- 1679, 1679, 1679, 1680, 0, 1680, 1681, 0, 1681, 1682,
- 0, 1682, 1683, 0, 1683, 1684, 1684, 1684, 1685, 1685,
- 1685, 1686, 1686, 1686, 1687, 0, 1687, 1688, 0, 1688,
- 1689, 0, 0, 1689, 1690, 1690, 0, 1690, 1691, 1691,
- 0, 0, 1691, 1692, 1692, 0, 1692, 1693, 1693, 1694,
-
- 1694, 0, 0, 1694, 1695, 1695, 1695, 1696, 1696, 1696,
- 1697, 1697, 0, 1697, 1698, 1698, 1698, 0, 1698, 1698,
- 1699, 1699, 1699, 1700, 1700, 1700, 1701, 1701, 1701, 1702,
- 1702, 1702, 1703, 1703, 1703, 1704, 1704, 1704, 1705, 1705,
- 1705, 1706, 1706, 1706, 1707, 0, 1707, 1708, 1708, 1708,
- 1709, 1709, 0, 0, 1709, 1710, 1710, 1710, 1711, 1711,
- 1711, 1712, 1712, 0, 1712, 1713, 1713, 0, 0, 1713,
- 1714, 1714, 0, 1714, 1715, 1715, 1716, 1716, 0, 0,
- 1716, 1717, 1717, 1717, 1718, 1718, 1718, 1719, 1719, 0,
- 1719, 1720, 0, 0, 1720, 1721, 1721, 0, 1721, 1722,
-
- 1722, 0, 0, 1722, 1723, 1723, 0, 1723, 1724, 1724,
- 1725, 1725, 0, 0, 1725, 1726, 1726, 1726, 1727, 1727,
- 1727, 1728, 1728, 0, 1728, 1729, 0, 1729, 1730, 0,
- 0, 1730, 1731, 1731, 0, 1731, 1732, 1732, 0, 0,
- 1732, 1733, 1733, 0, 1733, 1734, 1734, 1735, 1735, 0,
- 0, 1735, 1736, 1736, 1736, 1737, 1737, 1737, 1738, 1738,
- 0, 1738, 1739, 0, 1739, 1740, 0, 0, 1740, 1741,
- 1741, 0, 1741, 1742, 1742, 0, 0, 1742, 1743, 1743,
- 0, 1743, 1744, 1744, 1745, 1745, 0, 0, 1745, 1746,
- 1746, 1746, 1747, 1747, 1747, 1748, 1748, 0, 1748, 1749,
-
- 0, 1749, 1750, 0, 1750, 1751, 0, 1751, 1752, 1752,
- 1752, 1753, 0, 1753, 1754, 1754, 1754, 1755, 0, 1755,
- 1756, 1756, 1756, 0, 1756, 1756, 1757, 0, 1757, 1758,
- 1758, 1758, 1759, 0, 1759, 1760, 1760, 1760, 1761, 0,
- 1761, 1762, 1762, 1762, 1763, 0, 1763, 1764, 1764, 1764,
- 1765, 0, 1765, 1766, 1766, 1766, 1767, 0, 1767, 1768,
- 1768, 1768, 1769, 1769, 0, 0, 1769, 1770, 1770, 1770,
- 1771, 1771, 1771, 1772, 1772, 1772, 1773, 1773, 0, 1773,
- 1774, 1774, 1774, 1775, 0, 1775, 1776, 1776, 1776, 1777,
- 1777, 1777, 1778, 0, 1778, 1779, 0, 1779, 1780, 1780,
-
- 1780, 1781, 1781, 1781, 1782, 0, 1782, 1783, 0, 1783,
- 1784, 0, 1784, 1785, 1785, 1785, 1786, 1786, 1786, 1787,
- 0, 1787, 1788, 0, 1788, 1789, 0, 1789, 1790, 1790,
- 1790, 1791, 1791, 1791, 1792, 0, 1792, 1793, 0, 1793,
- 1794, 0, 1794, 1795, 1795, 1795, 1796, 1796, 1796, 1797,
- 0, 1797, 1798, 0, 0, 1798, 1799, 1799, 0, 1799,
- 1800, 1800, 0, 0, 1800, 1801, 1801, 0, 1801, 1802,
- 1802, 1803, 1803, 0, 0, 1803, 1804, 1804, 1804, 1805,
- 0, 1805, 1806, 1806, 0, 1806, 1807, 1807, 1807, 0,
- 1807, 1807, 1808, 1808, 1808, 1809, 1809, 1809, 1810, 0,
-
- 1810, 1811, 0, 1811, 1812, 0, 1812, 1813, 0, 1813,
+ 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, 1820,
- 0, 0, 1820, 1821, 1821, 0, 1821, 1822, 1822, 1823,
- 0, 1823, 1824, 0, 0, 1824, 1825, 1825, 0, 1825,
- 1826, 1826, 0, 0, 1826, 1827, 1827, 0, 1827, 1828,
- 1828, 1829, 0, 1829, 1830, 0, 1830, 1831, 0, 0,
- 1831, 1832, 1832, 0, 1832, 1833, 1833, 0, 0, 1833,
- 1834, 1834, 0, 1834, 1835, 1835, 1836, 0, 1836, 1837,
- 0, 1837, 1838, 0, 0, 1838, 1839, 1839, 0, 1839,
-
- 1840, 1840, 0, 0, 1840, 1841, 1841, 0, 1841, 1842,
- 1842, 1843, 0, 1843, 1844, 0, 1844, 1845, 0, 0,
- 1845, 1846, 1846, 0, 1846, 1847, 1847, 0, 0, 1847,
- 1848, 1848, 0, 1848, 1849, 1849, 1850, 0, 1850, 1851,
- 0, 1851, 1852, 0, 1852, 1853, 0, 1853, 1854, 1854,
- 1854, 1855, 0, 1855, 1856, 1856, 1856, 0, 1856, 1856,
- 1857, 0, 1857, 1858, 0, 1858, 1859, 0, 1859, 1860,
- 0, 1860, 1861, 0, 1861, 1862, 0, 1862, 1863, 0,
- 1863, 1864, 1864, 0, 0, 1864, 1865, 1865, 0, 1865,
- 1866, 1866, 1867, 0, 1867, 1868, 0, 1868, 1869, 0,
-
- 1869, 1870, 0, 1870, 1871, 0, 1871, 1872, 0, 1872,
- 1873, 0, 1873, 1874, 0, 1874, 1875, 0, 1875, 1876,
- 0, 1876, 1877, 0, 0, 1877, 1878, 1878, 0, 0,
- 1878, 1879, 0, 1879, 1880, 0, 1880, 1881, 0, 1881,
- 1882, 0, 0, 1882, 1883, 0, 0, 1883, 1884, 0,
- 0, 1884, 1885, 0, 0, 1885, 1886, 0, 0, 1886,
- 1887, 0, 1887, 1888, 0, 1888, 1889, 0, 0, 1889,
- 1890, 0, 1890, 1891, 0, 1891, 1892, 0, 1892, 1893,
- 0, 1893, 1894, 0, 1894, 1895, 0, 0, 1895, 1896,
- 0, 1896, 1897, 0, 1897, 1437, 1437, 1437, 1437, 1437,
-
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437,
- 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1437
+ 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
} ;
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int pcap_flex_debug;
-int pcap_flex_debug = 0;
-
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
@@ -2689,9 +2678,32 @@ int pcap_flex_debug = 0;
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
-char *pcaptext;
-#line 1 "../../freebsd/contrib/libpcap/scanner.l"
-#line 2 "../../freebsd/contrib/libpcap/scanner.l"
+#line 1 "scanner.l"
+
+/*
+ * We want a reentrant scanner.
+ */
+/*
+ * And we need to pass the compiler state to the scanner.
+ */
+/*
+ * We don't use input, so don't generate code for it.
+ */
+#define YY_NO_INPUT 1
+/*
+ * We don't use unput, so don't generate code for it.
+ */
+/*
+ * We don't read from the terminal.
+ */
+/*
+ * We want to stop processing when we get to the end of the input.
+ */
+/*
+ * We want to generate code that can be used by a reentrant parser
+ * generated by Bison or Berkeley YACC.
+ */
+#line 45 "scanner.l"
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -2715,28 +2727,19 @@ char *pcaptext;
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.112 2008-02-06 10:21:30 guy Exp $ (LBL)";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef WIN32
-#include <pcap-stdinc.h>
-#else /* WIN32 */
-#if HAVE_INTTYPES_H
-#include <inttypes.h>
-#elif HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
+#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 <sys/types.h>
-#endif /* WIN32 */
#include <ctype.h>
#include <string.h>
@@ -2744,25 +2747,56 @@ static const char rcsid[] _U_ =
#include "pcap-int.h"
#include "gencode.h"
+
+#include "grammar.h"
+
+/*
+ * Earlier versions of Flex don't declare these, so we declare them
+ * ourselves to squelch warnings.
+ */
+int pcap_get_column(yyscan_t);
+void pcap_set_column(int, yyscan_t);
+
#ifdef INET6
-#ifdef WIN32
-#include <pcap-stdinc.h>
-#ifdef __MINGW32__
-#include "ip6_misc.h"
-#endif
-#else /* WIN32 */
+#ifdef _WIN32
+/*
+ * 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>
+#else /* _WIN32 */
#include <sys/socket.h> /* for "struct sockaddr" in "struct addrinfo" */
#include <netdb.h> /* for "struct addrinfo" */
-#endif /* WIN32 */
+#endif /* _WIN32 */
/* Workaround for AIX 4.3 */
#if !defined(AI_NUMERICHOST)
#define AI_NUMERICHOST 0x04
#endif
+
#endif /*INET6*/
+
#include <pcap/namedb.h>
-#include "tokdefs.h"
+#include "grammar.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
@@ -2771,20 +2805,7 @@ static const char rcsid[] _U_ =
static int stoi(char *);
static inline int xdtoi(int);
-#ifdef FLEX_SCANNER
-#define YY_NO_INPUT
-#define YY_NO_UNPUT
-static YY_BUFFER_STATE in_buffer;
-#else
-static const char *in_buffer;
-
-#undef getc
-#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
-#endif
-
-extern YYSTYPE yylval;
-
-#line 2788 "<stdout>"
+#line 2809 "scanner.c"
#define INITIAL 0
@@ -2796,40 +2817,90 @@ extern YYSTYPE yylval;
#include <unistd.h>
#endif
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
+#define YY_EXTRA_TYPE compiler_state_t *
+
+/* Holds the entire state of the reentrant scanner. */
+struct yyguts_t
+ {
+
+ /* User-defined. Not touched by flex. */
+ YY_EXTRA_TYPE yyextra_r;
+
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
+ FILE *yyin_r, *yyout_r;
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+ char yy_hold_char;
+ yy_size_t yy_n_chars;
+ yy_size_t yyleng_r;
+ char *yy_c_buf_p;
+ int yy_init;
+ int yy_start;
+ int yy_did_buffer_switch_on_eof;
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int *yy_start_stack;
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ int yylineno_r;
+ int yy_flex_debug_r;
+
+ char *yytext_r;
+ int yy_more_flag;
+ int yy_more_len;
+
+ YYSTYPE * yylval_r;
+
+ }; /* end struct yyguts_t */
+
+static int yy_init_globals (yyscan_t yyscanner );
+
+ /* This must go here because YYSTYPE and YYLTYPE are included
+ * from bison output in section 1.*/
+ # define yylval yyg->yylval_r
+
+int pcap_lex_init (yyscan_t* scanner);
-static int yy_init_globals (void );
+int pcap_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int pcaplex_destroy (void );
+int pcap_lex_destroy (yyscan_t yyscanner );
+
+int pcap_get_debug (yyscan_t yyscanner );
+
+void pcap_set_debug (int debug_flag ,yyscan_t yyscanner );
+
+YY_EXTRA_TYPE pcap_get_extra (yyscan_t yyscanner );
-int pcapget_debug (void );
+void pcap_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
-void pcapset_debug (int debug_flag );
+FILE *pcap_get_in (yyscan_t yyscanner );
-YY_EXTRA_TYPE pcapget_extra (void );
+void pcap_set_in (FILE * in_str ,yyscan_t yyscanner );
-void pcapset_extra (YY_EXTRA_TYPE user_defined );
+FILE *pcap_get_out (yyscan_t yyscanner );
-FILE *pcapget_in (void );
+void pcap_set_out (FILE * out_str ,yyscan_t yyscanner );
-void pcapset_in (FILE * in_str );
+yy_size_t pcap_get_leng (yyscan_t yyscanner );
-FILE *pcapget_out (void );
+char *pcap_get_text (yyscan_t yyscanner );
-void pcapset_out (FILE * out_str );
+int pcap_get_lineno (yyscan_t yyscanner );
-yy_size_t pcapget_leng (void );
+void pcap_set_lineno (int line_number ,yyscan_t yyscanner );
-char *pcapget_text (void );
+int pcap_get_column (yyscan_t yyscanner );
-int pcapget_lineno (void );
+void pcap_set_column (int column_no ,yyscan_t yyscanner );
-void pcapset_lineno (int line_number );
+YYSTYPE * pcap_get_lval (yyscan_t yyscanner );
+
+void pcap_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -2837,30 +2908,26 @@ void pcapset_lineno (int line_number );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int pcapwrap (void );
+extern "C" int pcap_wrap (yyscan_t yyscanner );
#else
-extern int pcapwrap (void );
+extern int pcap_wrap (yyscan_t yyscanner );
#endif
#endif
-#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr );
-#endif
-
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
+static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
+static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
-static int yyinput (void );
+static int yyinput (yyscan_t yyscanner );
#else
-static int input (void );
+static int input (yyscan_t yyscanner );
#endif
#endif
@@ -2875,7 +2942,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO do { if (fwrite( pcaptext, pcapleng, 1, pcapout )) {} } while (0)
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -2888,18 +2955,18 @@ static int input (void );
int c = '*'; \
size_t n; \
for ( n = 0; n < max_size && \
- (c = getc( pcapin )) != EOF && c != '\n'; ++n ) \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
- if ( c == EOF && ferror( pcapin ) ) \
+ if ( c == EOF && ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
- while ( (result = fread(buf, 1, max_size, pcapin))==0 && ferror(pcapin)) \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -2907,7 +2974,7 @@ static int input (void );
break; \
} \
errno=0; \
- clearerr(pcapin); \
+ clearerr(yyin); \
} \
}\
\
@@ -2929,7 +2996,7 @@ static int input (void );
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
#endif
/* end tables serialization structures and prototypes */
@@ -2940,12 +3007,14 @@ static int input (void );
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int pcaplex (void);
+extern int pcap_lex \
+ (YYSTYPE * yylval_param ,yyscan_t yyscanner);
-#define YY_DECL int pcaplex (void)
+#define YY_DECL int pcap_lex \
+ (YYSTYPE * yylval_param , yyscan_t yyscanner)
#endif /* !YY_DECL */
-/* Code executed at the beginning of each rule, after pcaptext and pcapleng
+/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
@@ -2967,78 +3036,77 @@ YY_DECL
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
-
-#line 190 "../../freebsd/contrib/libpcap/scanner.l"
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+#line 242 "scanner.l"
-#line 2974 "<stdout>"
+#line 3044 "scanner.c"
- if ( !(yy_init) )
+ yylval = yylval_param;
+
+ if ( !yyg->yy_init )
{
- (yy_init) = 1;
+ yyg->yy_init = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
+ if ( ! yyg->yy_start )
+ yyg->yy_start = 1; /* first start state */
- if ( ! pcapin )
- pcapin = stdin;
+ if ( ! yyin )
+ yyin = stdin;
- if ( ! pcapout )
- pcapout = stdout;
+ if ( ! yyout )
+ yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
- pcapensure_buffer_stack ();
+ pcap_ensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- pcap_create_buffer(pcapin,YY_BUF_SIZE );
+ pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
}
- pcap_load_buffer_state( );
+ pcap__load_buffer_state(yyscanner );
}
while ( 1 ) /* loops until end-of-file is reached */
{
- yy_cp = (yy_c_buf_p);
+ yy_cp = yyg->yy_c_buf_p;
- /* Support of pcaptext. */
- *yy_cp = (yy_hold_char);
+ /* Support of yytext. */
+ *yy_cp = yyg->yy_hold_char;
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
- yy_current_state = (yy_start);
+ yy_current_state = yyg->yy_start;
yy_match:
do
{
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
}
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 >= 1438 )
+ if ( yy_current_state >= 1470 )
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_base[yy_current_state] != 7396 );
+ while ( yy_current_state != 1469 );
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
yy_find_action:
yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
YY_DO_BEFORE_ACTION;
@@ -3048,267 +3116,267 @@ do_action: /* This label is used only to access EOF actions. */
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
+ *yy_cp = yyg->yy_hold_char;
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
case 1:
YY_RULE_SETUP
-#line 191 "../../freebsd/contrib/libpcap/scanner.l"
+#line 243 "scanner.l"
return DST;
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 192 "../../freebsd/contrib/libpcap/scanner.l"
+#line 244 "scanner.l"
return SRC;
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 194 "../../freebsd/contrib/libpcap/scanner.l"
+#line 246 "scanner.l"
return LINK;
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 195 "../../freebsd/contrib/libpcap/scanner.l"
+#line 247 "scanner.l"
return LINK;
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 196 "../../freebsd/contrib/libpcap/scanner.l"
+#line 248 "scanner.l"
return ARP;
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 197 "../../freebsd/contrib/libpcap/scanner.l"
+#line 249 "scanner.l"
return RARP;
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 198 "../../freebsd/contrib/libpcap/scanner.l"
+#line 250 "scanner.l"
return IP;
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 199 "../../freebsd/contrib/libpcap/scanner.l"
+#line 251 "scanner.l"
return SCTP;
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 200 "../../freebsd/contrib/libpcap/scanner.l"
+#line 252 "scanner.l"
return TCP;
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 201 "../../freebsd/contrib/libpcap/scanner.l"
+#line 253 "scanner.l"
return UDP;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 202 "../../freebsd/contrib/libpcap/scanner.l"
+#line 254 "scanner.l"
return ICMP;
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 203 "../../freebsd/contrib/libpcap/scanner.l"
+#line 255 "scanner.l"
return IGMP;
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 204 "../../freebsd/contrib/libpcap/scanner.l"
+#line 256 "scanner.l"
return IGRP;
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 205 "../../freebsd/contrib/libpcap/scanner.l"
+#line 257 "scanner.l"
return PIM;
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 206 "../../freebsd/contrib/libpcap/scanner.l"
+#line 258 "scanner.l"
return VRRP;
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 207 "../../freebsd/contrib/libpcap/scanner.l"
+#line 259 "scanner.l"
return CARP;
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 208 "../../freebsd/contrib/libpcap/scanner.l"
+#line 260 "scanner.l"
return RADIO;
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 210 "../../freebsd/contrib/libpcap/scanner.l"
+#line 262 "scanner.l"
return IPV6;
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 211 "../../freebsd/contrib/libpcap/scanner.l"
+#line 263 "scanner.l"
return ICMPV6;
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 212 "../../freebsd/contrib/libpcap/scanner.l"
+#line 264 "scanner.l"
return AH;
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 213 "../../freebsd/contrib/libpcap/scanner.l"
+#line 265 "scanner.l"
return ESP;
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 215 "../../freebsd/contrib/libpcap/scanner.l"
+#line 267 "scanner.l"
return ATALK;
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 216 "../../freebsd/contrib/libpcap/scanner.l"
+#line 268 "scanner.l"
return AARP;
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 217 "../../freebsd/contrib/libpcap/scanner.l"
+#line 269 "scanner.l"
return DECNET;
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 218 "../../freebsd/contrib/libpcap/scanner.l"
+#line 270 "scanner.l"
return LAT;
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 219 "../../freebsd/contrib/libpcap/scanner.l"
+#line 271 "scanner.l"
return SCA;
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 220 "../../freebsd/contrib/libpcap/scanner.l"
+#line 272 "scanner.l"
return MOPRC;
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 221 "../../freebsd/contrib/libpcap/scanner.l"
+#line 273 "scanner.l"
return MOPDL;
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 223 "../../freebsd/contrib/libpcap/scanner.l"
+#line 275 "scanner.l"
return ISO;
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 224 "../../freebsd/contrib/libpcap/scanner.l"
+#line 276 "scanner.l"
return ESIS;
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 225 "../../freebsd/contrib/libpcap/scanner.l"
+#line 277 "scanner.l"
return ESIS;
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 226 "../../freebsd/contrib/libpcap/scanner.l"
+#line 278 "scanner.l"
return ISIS;
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 227 "../../freebsd/contrib/libpcap/scanner.l"
+#line 279 "scanner.l"
return ISIS;
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 228 "../../freebsd/contrib/libpcap/scanner.l"
+#line 280 "scanner.l"
return L1;
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 229 "../../freebsd/contrib/libpcap/scanner.l"
+#line 281 "scanner.l"
return L2;
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 230 "../../freebsd/contrib/libpcap/scanner.l"
+#line 282 "scanner.l"
return IIH;
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 231 "../../freebsd/contrib/libpcap/scanner.l"
+#line 283 "scanner.l"
return LSP;
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 232 "../../freebsd/contrib/libpcap/scanner.l"
+#line 284 "scanner.l"
return SNP;
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 233 "../../freebsd/contrib/libpcap/scanner.l"
+#line 285 "scanner.l"
return CSNP;
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 234 "../../freebsd/contrib/libpcap/scanner.l"
+#line 286 "scanner.l"
return PSNP;
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 236 "../../freebsd/contrib/libpcap/scanner.l"
+#line 288 "scanner.l"
return CLNP;
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 238 "../../freebsd/contrib/libpcap/scanner.l"
+#line 290 "scanner.l"
return STP;
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 240 "../../freebsd/contrib/libpcap/scanner.l"
+#line 292 "scanner.l"
return IPX;
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 242 "../../freebsd/contrib/libpcap/scanner.l"
+#line 294 "scanner.l"
return NETBEUI;
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 244 "../../freebsd/contrib/libpcap/scanner.l"
+#line 296 "scanner.l"
return HOST;
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 245 "../../freebsd/contrib/libpcap/scanner.l"
+#line 297 "scanner.l"
return NET;
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 246 "../../freebsd/contrib/libpcap/scanner.l"
+#line 298 "scanner.l"
return NETMASK;
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 247 "../../freebsd/contrib/libpcap/scanner.l"
+#line 299 "scanner.l"
return PORT;
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 248 "../../freebsd/contrib/libpcap/scanner.l"
+#line 300 "scanner.l"
return PORTRANGE;
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 249 "../../freebsd/contrib/libpcap/scanner.l"
+#line 301 "scanner.l"
return PROTO;
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 250 "../../freebsd/contrib/libpcap/scanner.l"
+#line 302 "scanner.l"
{
#ifdef NO_PROTOCHAIN
- bpf_error("%s not supported", pcaptext);
+ bpf_error(yyextra, "%s not supported", yytext);
#else
return PROTOCHAIN;
#endif
@@ -3316,531 +3384,585 @@ YY_RULE_SETUP
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 258 "../../freebsd/contrib/libpcap/scanner.l"
+#line 310 "scanner.l"
return GATEWAY;
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 260 "../../freebsd/contrib/libpcap/scanner.l"
+#line 312 "scanner.l"
return TYPE;
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 261 "../../freebsd/contrib/libpcap/scanner.l"
+#line 313 "scanner.l"
return SUBTYPE;
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 262 "../../freebsd/contrib/libpcap/scanner.l"
+#line 314 "scanner.l"
return DIR;
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 263 "../../freebsd/contrib/libpcap/scanner.l"
+#line 315 "scanner.l"
return ADDR1;
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 264 "../../freebsd/contrib/libpcap/scanner.l"
+#line 316 "scanner.l"
return ADDR2;
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 265 "../../freebsd/contrib/libpcap/scanner.l"
+#line 317 "scanner.l"
return ADDR3;
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 266 "../../freebsd/contrib/libpcap/scanner.l"
+#line 318 "scanner.l"
return ADDR4;
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 267 "../../freebsd/contrib/libpcap/scanner.l"
+#line 319 "scanner.l"
return RA;
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 268 "../../freebsd/contrib/libpcap/scanner.l"
+#line 320 "scanner.l"
return TA;
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 270 "../../freebsd/contrib/libpcap/scanner.l"
+#line 322 "scanner.l"
return LESS;
YY_BREAK
case 63:
YY_RULE_SETUP
-#line 271 "../../freebsd/contrib/libpcap/scanner.l"
+#line 323 "scanner.l"
return GREATER;
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 272 "../../freebsd/contrib/libpcap/scanner.l"
+#line 324 "scanner.l"
return CBYTE;
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 273 "../../freebsd/contrib/libpcap/scanner.l"
+#line 325 "scanner.l"
return TK_BROADCAST;
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 274 "../../freebsd/contrib/libpcap/scanner.l"
+#line 326 "scanner.l"
return TK_MULTICAST;
YY_BREAK
case 67:
YY_RULE_SETUP
-#line 276 "../../freebsd/contrib/libpcap/scanner.l"
+#line 328 "scanner.l"
return AND;
YY_BREAK
case 68:
YY_RULE_SETUP
-#line 277 "../../freebsd/contrib/libpcap/scanner.l"
+#line 329 "scanner.l"
return OR;
YY_BREAK
case 69:
YY_RULE_SETUP
-#line 278 "../../freebsd/contrib/libpcap/scanner.l"
+#line 330 "scanner.l"
return '!';
YY_BREAK
case 70:
YY_RULE_SETUP
-#line 280 "../../freebsd/contrib/libpcap/scanner.l"
+#line 332 "scanner.l"
return LEN;
YY_BREAK
case 71:
YY_RULE_SETUP
-#line 281 "../../freebsd/contrib/libpcap/scanner.l"
+#line 333 "scanner.l"
return INBOUND;
YY_BREAK
case 72:
YY_RULE_SETUP
-#line 282 "../../freebsd/contrib/libpcap/scanner.l"
+#line 334 "scanner.l"
return OUTBOUND;
YY_BREAK
case 73:
YY_RULE_SETUP
-#line 284 "../../freebsd/contrib/libpcap/scanner.l"
+#line 336 "scanner.l"
return VLAN;
YY_BREAK
case 74:
YY_RULE_SETUP
-#line 285 "../../freebsd/contrib/libpcap/scanner.l"
+#line 337 "scanner.l"
return MPLS;
YY_BREAK
case 75:
YY_RULE_SETUP
-#line 286 "../../freebsd/contrib/libpcap/scanner.l"
+#line 338 "scanner.l"
return PPPOED;
YY_BREAK
case 76:
YY_RULE_SETUP
-#line 287 "../../freebsd/contrib/libpcap/scanner.l"
+#line 339 "scanner.l"
return PPPOES;
YY_BREAK
case 77:
YY_RULE_SETUP
-#line 289 "../../freebsd/contrib/libpcap/scanner.l"
-return LANE;
+#line 340 "scanner.l"
+return GENEVE;
YY_BREAK
case 78:
YY_RULE_SETUP
-#line 290 "../../freebsd/contrib/libpcap/scanner.l"
-return LLC;
+#line 342 "scanner.l"
+return LANE;
YY_BREAK
case 79:
YY_RULE_SETUP
-#line 291 "../../freebsd/contrib/libpcap/scanner.l"
-return METAC;
+#line 343 "scanner.l"
+return LLC;
YY_BREAK
case 80:
YY_RULE_SETUP
-#line 292 "../../freebsd/contrib/libpcap/scanner.l"
-return BCC;
+#line 344 "scanner.l"
+return METAC;
YY_BREAK
case 81:
YY_RULE_SETUP
-#line 293 "../../freebsd/contrib/libpcap/scanner.l"
-return OAM;
+#line 345 "scanner.l"
+return BCC;
YY_BREAK
case 82:
YY_RULE_SETUP
-#line 294 "../../freebsd/contrib/libpcap/scanner.l"
-return OAMF4;
+#line 346 "scanner.l"
+return OAM;
YY_BREAK
case 83:
YY_RULE_SETUP
-#line 295 "../../freebsd/contrib/libpcap/scanner.l"
-return OAMF4EC;
+#line 347 "scanner.l"
+return OAMF4;
YY_BREAK
case 84:
YY_RULE_SETUP
-#line 296 "../../freebsd/contrib/libpcap/scanner.l"
-return OAMF4SC;
+#line 348 "scanner.l"
+return OAMF4EC;
YY_BREAK
case 85:
YY_RULE_SETUP
-#line 297 "../../freebsd/contrib/libpcap/scanner.l"
-return SC;
+#line 349 "scanner.l"
+return OAMF4SC;
YY_BREAK
case 86:
YY_RULE_SETUP
-#line 298 "../../freebsd/contrib/libpcap/scanner.l"
-return ILMIC;
+#line 350 "scanner.l"
+return SC;
YY_BREAK
case 87:
YY_RULE_SETUP
-#line 299 "../../freebsd/contrib/libpcap/scanner.l"
-return VPI;
+#line 351 "scanner.l"
+return ILMIC;
YY_BREAK
case 88:
YY_RULE_SETUP
-#line 300 "../../freebsd/contrib/libpcap/scanner.l"
-return VCI;
+#line 352 "scanner.l"
+return VPI;
YY_BREAK
case 89:
YY_RULE_SETUP
-#line 301 "../../freebsd/contrib/libpcap/scanner.l"
-return CONNECTMSG;
+#line 353 "scanner.l"
+return VCI;
YY_BREAK
case 90:
YY_RULE_SETUP
-#line 302 "../../freebsd/contrib/libpcap/scanner.l"
-return METACONNECT;
+#line 354 "scanner.l"
+return CONNECTMSG;
YY_BREAK
case 91:
YY_RULE_SETUP
-#line 304 "../../freebsd/contrib/libpcap/scanner.l"
-return PF_IFNAME;
+#line 355 "scanner.l"
+return METACONNECT;
YY_BREAK
case 92:
YY_RULE_SETUP
-#line 305 "../../freebsd/contrib/libpcap/scanner.l"
-return PF_RSET;
+#line 357 "scanner.l"
+return PF_IFNAME;
YY_BREAK
case 93:
YY_RULE_SETUP
-#line 306 "../../freebsd/contrib/libpcap/scanner.l"
-return PF_RNR;
+#line 358 "scanner.l"
+return PF_RSET;
YY_BREAK
case 94:
YY_RULE_SETUP
-#line 307 "../../freebsd/contrib/libpcap/scanner.l"
-return PF_SRNR;
+#line 359 "scanner.l"
+return PF_RNR;
YY_BREAK
case 95:
YY_RULE_SETUP
-#line 308 "../../freebsd/contrib/libpcap/scanner.l"
-return PF_REASON;
+#line 360 "scanner.l"
+return PF_SRNR;
YY_BREAK
case 96:
YY_RULE_SETUP
-#line 309 "../../freebsd/contrib/libpcap/scanner.l"
-return PF_ACTION;
+#line 361 "scanner.l"
+return PF_REASON;
YY_BREAK
case 97:
YY_RULE_SETUP
-#line 311 "../../freebsd/contrib/libpcap/scanner.l"
-return FISU;
+#line 362 "scanner.l"
+return PF_ACTION;
YY_BREAK
case 98:
YY_RULE_SETUP
-#line 312 "../../freebsd/contrib/libpcap/scanner.l"
-return LSSU;
+#line 364 "scanner.l"
+return FISU;
YY_BREAK
case 99:
YY_RULE_SETUP
-#line 313 "../../freebsd/contrib/libpcap/scanner.l"
+#line 365 "scanner.l"
return LSSU;
YY_BREAK
case 100:
YY_RULE_SETUP
-#line 314 "../../freebsd/contrib/libpcap/scanner.l"
-return MSU;
+#line 366 "scanner.l"
+return LSSU;
YY_BREAK
case 101:
YY_RULE_SETUP
-#line 315 "../../freebsd/contrib/libpcap/scanner.l"
-return SIO;
+#line 367 "scanner.l"
+return MSU;
YY_BREAK
case 102:
YY_RULE_SETUP
-#line 316 "../../freebsd/contrib/libpcap/scanner.l"
-return OPC;
+#line 368 "scanner.l"
+return HFISU;
YY_BREAK
case 103:
YY_RULE_SETUP
-#line 317 "../../freebsd/contrib/libpcap/scanner.l"
-return DPC;
+#line 369 "scanner.l"
+return HLSSU;
YY_BREAK
case 104:
YY_RULE_SETUP
-#line 318 "../../freebsd/contrib/libpcap/scanner.l"
-return SLS;
+#line 370 "scanner.l"
+return HMSU;
YY_BREAK
case 105:
-/* rule 105 can match eol */
YY_RULE_SETUP
-#line 320 "../../freebsd/contrib/libpcap/scanner.l"
-;
+#line 371 "scanner.l"
+return SIO;
YY_BREAK
case 106:
YY_RULE_SETUP
-#line 321 "../../freebsd/contrib/libpcap/scanner.l"
-return pcaptext[0];
+#line 372 "scanner.l"
+return OPC;
YY_BREAK
case 107:
YY_RULE_SETUP
-#line 322 "../../freebsd/contrib/libpcap/scanner.l"
-return GEQ;
+#line 373 "scanner.l"
+return DPC;
YY_BREAK
case 108:
YY_RULE_SETUP
-#line 323 "../../freebsd/contrib/libpcap/scanner.l"
-return LEQ;
+#line 374 "scanner.l"
+return SLS;
YY_BREAK
case 109:
YY_RULE_SETUP
-#line 324 "../../freebsd/contrib/libpcap/scanner.l"
-return NEQ;
+#line 375 "scanner.l"
+return HSIO;
YY_BREAK
case 110:
YY_RULE_SETUP
-#line 325 "../../freebsd/contrib/libpcap/scanner.l"
-return '=';
+#line 376 "scanner.l"
+return HOPC;
YY_BREAK
case 111:
YY_RULE_SETUP
-#line 326 "../../freebsd/contrib/libpcap/scanner.l"
-return LSH;
+#line 377 "scanner.l"
+return HDPC;
YY_BREAK
case 112:
YY_RULE_SETUP
-#line 327 "../../freebsd/contrib/libpcap/scanner.l"
-return RSH;
+#line 378 "scanner.l"
+return HSLS;
YY_BREAK
case 113:
+/* rule 113 can match eol */
YY_RULE_SETUP
-#line 328 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.e = pcap_ether_aton(((char *)pcaptext)+1);
- return AID; }
+#line 380 "scanner.l"
+;
YY_BREAK
case 114:
YY_RULE_SETUP
-#line 330 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.e = pcap_ether_aton((char *)pcaptext);
- return EID; }
+#line 381 "scanner.l"
+return yytext[0];
YY_BREAK
case 115:
YY_RULE_SETUP
-#line 332 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = stoi((char *)pcaptext); return NUM; }
+#line 382 "scanner.l"
+return GEQ;
YY_BREAK
case 116:
YY_RULE_SETUP
-#line 333 "../../freebsd/contrib/libpcap/scanner.l"
-{
- yylval.s = sdup((char *)pcaptext); return HID; }
+#line 383 "scanner.l"
+return LEQ;
YY_BREAK
case 117:
YY_RULE_SETUP
-#line 335 "../../freebsd/contrib/libpcap/scanner.l"
-{
-#ifdef INET6
- struct addrinfo hints, *res;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET6;
- hints.ai_flags = AI_NUMERICHOST;
- if (getaddrinfo(pcaptext, NULL, &hints, &res))
- bpf_error("bogus IPv6 address %s", pcaptext);
- else {
- freeaddrinfo(res);
- yylval.s = sdup((char *)pcaptext); return HID6;
- }
-#else
- bpf_error("IPv6 address %s not supported", pcaptext);
-#endif /*INET6*/
- }
+#line 384 "scanner.l"
+return NEQ;
YY_BREAK
case 118:
YY_RULE_SETUP
-#line 351 "../../freebsd/contrib/libpcap/scanner.l"
-{ bpf_error("bogus ethernet address %s", pcaptext); }
+#line 385 "scanner.l"
+return '=';
YY_BREAK
case 119:
YY_RULE_SETUP
-#line 352 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0; return NUM; }
+#line 386 "scanner.l"
+return LSH;
YY_BREAK
case 120:
YY_RULE_SETUP
-#line 353 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 1; return NUM; }
+#line 387 "scanner.l"
+return RSH;
YY_BREAK
case 121:
YY_RULE_SETUP
-#line 354 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0; return NUM; }
+#line 388 "scanner.l"
+{ yylval->e = pcap_ether_aton(((char *)yytext)+1);
+ if (yylval->e == NULL)
+ bpf_error(yyextra, "malloc");
+ return AID; }
YY_BREAK
case 122:
YY_RULE_SETUP
-#line 355 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 3; return NUM; }
+#line 392 "scanner.l"
+{ yylval->e = pcap_ether_aton((char *)yytext);
+ if (yylval->e == NULL)
+ bpf_error(yyextra, "malloc");
+ return EID; }
YY_BREAK
case 123:
YY_RULE_SETUP
-#line 356 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 4; return NUM; }
+#line 396 "scanner.l"
+{ yylval->i = stoi((char *)yytext); return NUM; }
YY_BREAK
case 124:
YY_RULE_SETUP
-#line 357 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 5; return NUM; }
+#line 397 "scanner.l"
+{
+ yylval->s = sdup(yyextra, (char *)yytext); return HID; }
YY_BREAK
case 125:
YY_RULE_SETUP
-#line 358 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 8; return NUM; }
+#line 399 "scanner.l"
+{
+#ifdef INET6
+ struct addrinfo hints, *res;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET6;
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo(yytext, NULL, &hints, &res))
+ bpf_error(yyextra, "bogus IPv6 address %s", yytext);
+ else {
+ freeaddrinfo(res);
+ yylval->s = sdup(yyextra, (char *)yytext); return HID6;
+ }
+#else
+ bpf_error(yyextra, "IPv6 address %s not supported", yytext);
+#endif /*INET6*/
+ }
YY_BREAK
case 126:
YY_RULE_SETUP
-#line 359 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 9; return NUM; }
+#line 415 "scanner.l"
+{ bpf_error(yyextra, "bogus ethernet address %s", yytext); }
YY_BREAK
case 127:
YY_RULE_SETUP
-#line 360 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 10; return NUM; }
+#line 416 "scanner.l"
+{ yylval->i = 0; return NUM; }
YY_BREAK
case 128:
YY_RULE_SETUP
-#line 361 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 11; return NUM; }
+#line 417 "scanner.l"
+{ yylval->i = 1; return NUM; }
YY_BREAK
case 129:
YY_RULE_SETUP
-#line 362 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 12; return NUM; }
+#line 418 "scanner.l"
+{ yylval->i = 0; return NUM; }
YY_BREAK
case 130:
YY_RULE_SETUP
-#line 363 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 13; return NUM; }
+#line 419 "scanner.l"
+{ yylval->i = 3; return NUM; }
YY_BREAK
case 131:
YY_RULE_SETUP
-#line 364 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 14; return NUM; }
+#line 420 "scanner.l"
+{ yylval->i = 4; return NUM; }
YY_BREAK
case 132:
YY_RULE_SETUP
-#line 365 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 15; return NUM; }
+#line 421 "scanner.l"
+{ yylval->i = 5; return NUM; }
YY_BREAK
case 133:
YY_RULE_SETUP
-#line 366 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 16; return NUM; }
+#line 422 "scanner.l"
+{ yylval->i = 8; return NUM; }
YY_BREAK
case 134:
YY_RULE_SETUP
-#line 367 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 17; return NUM; }
+#line 423 "scanner.l"
+{ yylval->i = 9; return NUM; }
YY_BREAK
case 135:
YY_RULE_SETUP
-#line 368 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 18; return NUM; }
+#line 424 "scanner.l"
+{ yylval->i = 10; return NUM; }
YY_BREAK
case 136:
YY_RULE_SETUP
-#line 369 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 13; return NUM; }
+#line 425 "scanner.l"
+{ yylval->i = 11; return NUM; }
YY_BREAK
case 137:
YY_RULE_SETUP
-#line 370 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0x01; return NUM; }
+#line 426 "scanner.l"
+{ yylval->i = 12; return NUM; }
YY_BREAK
case 138:
YY_RULE_SETUP
-#line 371 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0x02; return NUM; }
+#line 427 "scanner.l"
+{ yylval->i = 13; return NUM; }
YY_BREAK
case 139:
YY_RULE_SETUP
-#line 372 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0x04; return NUM; }
+#line 428 "scanner.l"
+{ yylval->i = 14; return NUM; }
YY_BREAK
case 140:
YY_RULE_SETUP
-#line 373 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0x08; return NUM; }
+#line 429 "scanner.l"
+{ yylval->i = 15; return NUM; }
YY_BREAK
case 141:
YY_RULE_SETUP
-#line 374 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0x10; return NUM; }
+#line 430 "scanner.l"
+{ yylval->i = 16; return NUM; }
YY_BREAK
case 142:
YY_RULE_SETUP
-#line 375 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.i = 0x20; return NUM; }
+#line 431 "scanner.l"
+{ yylval->i = 17; return NUM; }
YY_BREAK
case 143:
YY_RULE_SETUP
-#line 376 "../../freebsd/contrib/libpcap/scanner.l"
-{
- yylval.s = sdup((char *)pcaptext); return ID; }
+#line 432 "scanner.l"
+{ yylval->i = 18; return NUM; }
YY_BREAK
case 144:
YY_RULE_SETUP
-#line 378 "../../freebsd/contrib/libpcap/scanner.l"
-{ yylval.s = sdup((char *)pcaptext + 1); return ID; }
+#line 433 "scanner.l"
+{ yylval->i = 13; return NUM; }
YY_BREAK
case 145:
YY_RULE_SETUP
-#line 379 "../../freebsd/contrib/libpcap/scanner.l"
-{
- bpf_error("illegal token: %s", pcaptext); }
+#line 434 "scanner.l"
+{ yylval->i = 0x01; return NUM; }
YY_BREAK
case 146:
YY_RULE_SETUP
-#line 381 "../../freebsd/contrib/libpcap/scanner.l"
-{ bpf_error("illegal char '%c'", *pcaptext); }
+#line 435 "scanner.l"
+{ yylval->i = 0x02; return NUM; }
YY_BREAK
case 147:
YY_RULE_SETUP
-#line 382 "../../freebsd/contrib/libpcap/scanner.l"
+#line 436 "scanner.l"
+{ yylval->i = 0x04; return NUM; }
+ YY_BREAK
+case 148:
+YY_RULE_SETUP
+#line 437 "scanner.l"
+{ yylval->i = 0x08; return NUM; }
+ YY_BREAK
+case 149:
+YY_RULE_SETUP
+#line 438 "scanner.l"
+{ yylval->i = 0x10; return NUM; }
+ YY_BREAK
+case 150:
+YY_RULE_SETUP
+#line 439 "scanner.l"
+{ yylval->i = 0x20; return NUM; }
+ YY_BREAK
+case 151:
+YY_RULE_SETUP
+#line 440 "scanner.l"
+{ yylval->i = 0x40; return NUM; }
+ YY_BREAK
+case 152:
+YY_RULE_SETUP
+#line 441 "scanner.l"
+{ yylval->i = 0x80; return NUM; }
+ YY_BREAK
+case 153:
+YY_RULE_SETUP
+#line 442 "scanner.l"
+{
+ yylval->s = sdup(yyextra, (char *)yytext); return ID; }
+ YY_BREAK
+case 154:
+YY_RULE_SETUP
+#line 444 "scanner.l"
+{ yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }
+ YY_BREAK
+case 155:
+YY_RULE_SETUP
+#line 445 "scanner.l"
+{
+ bpf_error(yyextra, "illegal token: %s", yytext); }
+ YY_BREAK
+case 156:
+YY_RULE_SETUP
+#line 447 "scanner.l"
+{ bpf_error(yyextra, "illegal char '%c'", *yytext); }
+ YY_BREAK
+case 157:
+YY_RULE_SETUP
+#line 448 "scanner.l"
ECHO;
YY_BREAK
-#line 3819 "<stdout>"
+#line 3941 "scanner.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
+ *yy_cp = yyg->yy_hold_char;
YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
- * just pointed pcapin at a new source and called
- * pcaplex(). If so, then we have to assure
+ * just pointed yyin at a new source and called
+ * pcap_lex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = pcapin;
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
@@ -3851,13 +3973,13 @@ case YY_STATE_EOF(INITIAL):
* end-of-buffer state). Contrast this with the test
* in input().
*/
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+ yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state( );
+ yy_current_state = yy_get_previous_state( yyscanner );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
@@ -3868,43 +3990,44 @@ case YY_STATE_EOF(INITIAL):
* will run more slowly).
*/
- yy_next_state = yy_try_NUL_trans( yy_current_state );
+ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
+ yy_cp = ++yyg->yy_c_buf_p;
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
- yy_cp = (yy_c_buf_p);
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
}
}
- else switch ( yy_get_next_buffer( ) )
+ else switch ( yy_get_next_buffer( yyscanner ) )
{
case EOB_ACT_END_OF_FILE:
{
- (yy_did_buffer_switch_on_eof) = 0;
+ yyg->yy_did_buffer_switch_on_eof = 0;
- if ( pcapwrap( ) )
+ if ( pcap_wrap(yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
- * pcaptext, we can now set up
+ * yytext, we can now set up
* yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
@@ -3912,30 +4035,30 @@ case YY_STATE_EOF(INITIAL):
else
{
- if ( ! (yy_did_buffer_switch_on_eof) )
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
+ yyg->yy_c_buf_p =
+ yyg->yytext_ptr + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state( );
+ yy_current_state = yy_get_previous_state( yyscanner );
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ yy_cp = yyg->yy_c_buf_p;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+ yyg->yy_c_buf_p =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
- yy_current_state = yy_get_previous_state( );
+ yy_current_state = yy_get_previous_state( yyscanner );
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ yy_cp = yyg->yy_c_buf_p;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
goto yy_find_action;
}
break;
@@ -3946,7 +4069,7 @@ case YY_STATE_EOF(INITIAL):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
-} /* end of pcaplex */
+} /* end of pcap_lex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -3955,20 +4078,21 @@ case YY_STATE_EOF(INITIAL):
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
-static int yy_get_next_buffer (void)
+static int yy_get_next_buffer (yyscan_t yyscanner)
{
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- char *source = (yytext_ptr);
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ char *source = yyg->yytext_ptr;
int number_to_move, i;
int ret_val;
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
@@ -3988,7 +4112,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -3997,7 +4121,7 @@ static int yy_get_next_buffer (void)
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
else
{
@@ -4011,7 +4135,7 @@ static int yy_get_next_buffer (void)
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
+ (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
@@ -4024,7 +4148,7 @@ static int yy_get_next_buffer (void)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- pcaprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ pcap_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
}
else
/* Can't grow it, we don't own it. */
@@ -4034,7 +4158,7 @@ static int yy_get_next_buffer (void)
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
@@ -4046,17 +4170,17 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
+ yyg->yy_n_chars, num_to_read );
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
- if ( (yy_n_chars) == 0 )
+ if ( yyg->yy_n_chars == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- pcaprestart(pcapin );
+ pcap_restart(yyin ,yyscanner);
}
else
@@ -4070,44 +4194,45 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pcaprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pcap_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+ yyg->yy_n_chars += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+ yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
return ret_val;
}
/* yy_get_previous_state - get the state just before the EOB char was reached */
- static yy_state_type yy_get_previous_state (void)
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
yy_state_type yy_current_state;
char *yy_cp;
-
- yy_current_state = (yy_start);
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ yy_current_state = yyg->yy_start;
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
}
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 >= 1438 )
+ if ( yy_current_state >= 1470 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -4121,96 +4246,60 @@ static int yy_get_next_buffer (void)
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
int yy_is_jam;
- char *yy_cp = (yy_c_buf_p);
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
+ char *yy_cp = yyg->yy_c_buf_p;
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
}
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 >= 1438 )
+ if ( yy_current_state >= 1470 )
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 == 1437);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
+ yy_is_jam = (yy_current_state == 1469);
-#ifndef YY_NO_UNPUT
- static void yyunput (int c, char * yy_bp )
-{
- char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up pcaptext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- yy_size_t number_to_move = (yy_n_chars) + 2;
- char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
+ (void)yyg;
+ return yy_is_jam ? 0 : yy_current_state;
}
-#endif /* ifndef YY_NO_UNPUT */
#ifndef YY_NO_INPUT
#ifdef __cplusplus
- static int yyinput (void)
+ static int yyinput (yyscan_t yyscanner)
#else
- static int input (void)
+ static int input (yyscan_t yyscanner)
#endif
{
int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
/* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
+ *yyg->yy_c_buf_p = '\0';
else
{ /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
+ yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ ++yyg->yy_c_buf_p;
- switch ( yy_get_next_buffer( ) )
+ switch ( yy_get_next_buffer( yyscanner ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
@@ -4224,34 +4313,34 @@ static int yy_get_next_buffer (void)
*/
/* Reset buffer status. */
- pcaprestart(pcapin );
+ pcap_restart(yyin ,yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( pcapwrap( ) )
+ if ( pcap_wrap(yyscanner ) )
return EOF;
- if ( ! (yy_did_buffer_switch_on_eof) )
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
#ifdef __cplusplus
- return yyinput();
+ return yyinput(yyscanner);
#else
- return input();
+ return input(yyscanner);
#endif
}
case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
+ yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
break;
}
}
}
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve pcaptext */
- (yy_hold_char) = *++(yy_c_buf_p);
+ c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
+ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
+ yyg->yy_hold_char = *++yyg->yy_c_buf_p;
return c;
}
@@ -4259,102 +4348,106 @@ static int yy_get_next_buffer (void)
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
- *
+ * @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
- void pcaprestart (FILE * input_file )
+ void pcap_restart (FILE * input_file , yyscan_t yyscanner)
{
-
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
if ( ! YY_CURRENT_BUFFER ){
- pcapensure_buffer_stack ();
+ pcap_ensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- pcap_create_buffer(pcapin,YY_BUF_SIZE );
+ pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
}
- pcap_init_buffer(YY_CURRENT_BUFFER,input_file );
- pcap_load_buffer_state( );
+ pcap__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
+ pcap__load_buffer_state(yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
- *
+ * @param yyscanner The scanner object.
*/
- void pcap_switch_to_buffer (YY_BUFFER_STATE new_buffer )
+ void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
-
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
/* TODO. We should be able to replace this entire function body
* with
- * pcappop_buffer_state();
- * pcappush_buffer_state(new_buffer);
+ * pcap_pop_buffer_state();
+ * pcap_push_buffer_state(new_buffer);
*/
- pcapensure_buffer_stack ();
+ pcap_ensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- pcap_load_buffer_state( );
+ pcap__load_buffer_state(yyscanner );
/* We don't actually know whether we did this switch during
- * EOF (pcapwrap()) processing, but the only time this flag
- * is looked at is after pcapwrap() is called, so it's safe
+ * EOF (pcap_wrap()) processing, but the only time this flag
+ * is looked at is after pcap_wrap() is called, so it's safe
* to go ahead and always set it.
*/
- (yy_did_buffer_switch_on_eof) = 1;
+ yyg->yy_did_buffer_switch_on_eof = 1;
}
-static void pcap_load_buffer_state (void)
+static void pcap__load_buffer_state (yyscan_t yyscanner)
{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- pcapin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ yyg->yy_hold_char = *yyg->yy_c_buf_p;
}
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
+ * @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
- YY_BUFFER_STATE pcap_create_buffer (FILE * file, int size )
+ YY_BUFFER_STATE pcap__create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) pcapalloc(sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) pcap_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in pcap_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in pcap__create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) pcapalloc(b->yy_buf_size + 2 );
+ b->yy_ch_buf = (char *) pcap_alloc(b->yy_buf_size + 2 ,yyscanner );
if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in pcap_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in pcap__create_buffer()" );
b->yy_is_our_buffer = 1;
- pcap_init_buffer(b,file );
+ pcap__init_buffer(b,file ,yyscanner);
return b;
}
/** Destroy the buffer.
- * @param b a buffer created with pcap_create_buffer()
- *
+ * @param b a buffer created with pcap__create_buffer()
+ * @param yyscanner The scanner object.
*/
- void pcap_delete_buffer (YY_BUFFER_STATE b )
+ void pcap__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
-
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
if ( ! b )
return;
@@ -4362,27 +4455,28 @@ static void pcap_load_buffer_state (void)
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- pcapfree((void *) b->yy_ch_buf );
+ pcap_free((void *) b->yy_ch_buf ,yyscanner );
- pcapfree((void *) b );
+ pcap_free((void *) b ,yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
- * such as during a pcaprestart() or at EOF.
+ * such as during a pcap_restart() or at EOF.
*/
- static void pcap_init_buffer (YY_BUFFER_STATE b, FILE * file )
+ static void pcap__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
-
- pcap_flush_buffer(b );
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ pcap__flush_buffer(b ,yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
- /* If b is the current buffer, then pcap_init_buffer was _probably_
- * called from pcaprestart() or through yy_get_next_buffer.
+ /* If b is the current buffer, then pcap__init_buffer was _probably_
+ * called from pcap_restart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
@@ -4390,18 +4484,19 @@ static void pcap_load_buffer_state (void)
b->yy_bs_column = 0;
}
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+ b->yy_is_interactive = 0;
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
+ * @param yyscanner The scanner object.
*/
- void pcap_flush_buffer (YY_BUFFER_STATE b )
+ void pcap__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
- if ( ! b )
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if ( ! b )
return;
b->yy_n_chars = 0;
@@ -4419,114 +4514,117 @@ static void pcap_load_buffer_state (void)
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- pcap_load_buffer_state( );
+ pcap__load_buffer_state(yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
- *
+ * @param yyscanner The scanner object.
*/
-void pcappush_buffer_state (YY_BUFFER_STATE new_buffer )
+void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
- if (new_buffer == NULL)
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if (new_buffer == NULL)
return;
- pcapensure_buffer_stack();
+ pcap_ensure_buffer_stack(yyscanner);
- /* This block is copied from pcap_switch_to_buffer. */
+ /* This block is copied from pcap__switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
/* Only push if top exists. Otherwise, replace top. */
if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
+ yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- /* copied from pcap_switch_to_buffer. */
- pcap_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
+ /* copied from pcap__switch_to_buffer. */
+ pcap__load_buffer_state(yyscanner );
+ yyg->yy_did_buffer_switch_on_eof = 1;
}
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
- *
+ * @param yyscanner The scanner object.
*/
-void pcappop_buffer_state (void)
+void pcap_pop_buffer_state (yyscan_t yyscanner)
{
- if (!YY_CURRENT_BUFFER)
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if (!YY_CURRENT_BUFFER)
return;
- pcap_delete_buffer(YY_CURRENT_BUFFER );
+ pcap__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
+ if (yyg->yy_buffer_stack_top > 0)
+ --yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
- pcap_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
+ pcap__load_buffer_state(yyscanner );
+ yyg->yy_did_buffer_switch_on_eof = 1;
}
}
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-static void pcapensure_buffer_stack (void)
+static void pcap_ensure_buffer_stack (yyscan_t yyscanner)
{
yy_size_t num_to_alloc;
-
- if (!(yy_buffer_stack)) {
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (!yyg->yy_buffer_stack) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)pcapalloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)pcap_alloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in pcapensure_buffer_stack()" );
+ , yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in pcap_ensure_buffer_stack()" );
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+ memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
+ yyg->yy_buffer_stack_max = num_to_alloc;
+ yyg->yy_buffer_stack_top = 0;
return;
}
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
/* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */;
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)pcaprealloc
- ((yy_buffer_stack),
+ num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)pcap_realloc
+ (yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in pcapensure_buffer_stack()" );
+ , yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in pcap_ensure_buffer_stack()" );
/* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
+ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
+ yyg->yy_buffer_stack_max = num_to_alloc;
}
}
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
- *
+ * @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE pcap_scan_buffer (char * base, yy_size_t size )
+YY_BUFFER_STATE pcap__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
@@ -4536,9 +4634,9 @@ YY_BUFFER_STATE pcap_scan_buffer (char * base, yy_size_t size )
/* They forgot to leave room for the EOB's. */
return 0;
- b = (YY_BUFFER_STATE) pcapalloc(sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) pcap_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in pcap_scan_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in pcap__scan_buffer()" );
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
@@ -4550,33 +4648,33 @@ YY_BUFFER_STATE pcap_scan_buffer (char * base, yy_size_t size )
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- pcap_switch_to_buffer(b );
+ pcap__switch_to_buffer(b ,yyscanner );
return b;
}
-/** Setup the input buffer state to scan a string. The next call to pcaplex() will
+/** Setup the input buffer state to scan a string. The next call to pcap_lex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
- *
+ * @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
- * pcap_scan_bytes() instead.
+ * pcap__scan_bytes() instead.
*/
-YY_BUFFER_STATE pcap_scan_string (yyconst char * yystr )
+YY_BUFFER_STATE pcap__scan_string (yyconst char * yystr , yyscan_t yyscanner)
{
- return pcap_scan_bytes(yystr,strlen(yystr) );
+ return pcap__scan_bytes(yystr,strlen(yystr) ,yyscanner);
}
-/** Setup the input buffer state to scan the given bytes. The next call to pcaplex() will
+/** Setup the input buffer state to scan the given bytes. The next call to pcap_lex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
+ * @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE pcap_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
+YY_BUFFER_STATE pcap__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
@@ -4585,18 +4683,18 @@ YY_BUFFER_STATE pcap_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_le
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
- buf = (char *) pcapalloc(n );
+ buf = (char *) pcap_alloc(n ,yyscanner );
if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in pcap_scan_bytes()" );
+ YY_FATAL_ERROR( "out of dynamic memory in pcap__scan_bytes()" );
for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = pcap_scan_buffer(buf,n );
+ b = pcap__scan_buffer(buf,n ,yyscanner);
if ( ! b )
- YY_FATAL_ERROR( "bad buffer in pcap_scan_bytes()" );
+ YY_FATAL_ERROR( "bad buffer in pcap__scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
@@ -4610,7 +4708,7 @@ YY_BUFFER_STATE pcap_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_le
#define YY_EXIT_FAILURE 2
#endif
-static void yy_fatal_error (yyconst char* msg )
+static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
@@ -4622,144 +4720,299 @@ static void yy_fatal_error (yyconst char* msg )
#define yyless(n) \
do \
{ \
- /* Undo effects of setting up pcaptext. */ \
+ /* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
- pcaptext[pcapleng] = (yy_hold_char); \
- (yy_c_buf_p) = pcaptext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- pcapleng = yyless_macro_arg; \
+ yytext[yyleng] = yyg->yy_hold_char; \
+ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
+ yyg->yy_hold_char = *yyg->yy_c_buf_p; \
+ *yyg->yy_c_buf_p = '\0'; \
+ yyleng = yyless_macro_arg; \
} \
while ( 0 )
/* Accessor methods (get/set functions) to struct members. */
+/** Get the user-defined data for this scanner.
+ * @param yyscanner The scanner object.
+ */
+YY_EXTRA_TYPE pcap_get_extra (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyextra;
+}
+
/** Get the current line number.
- *
+ * @param yyscanner The scanner object.
*/
-int pcapget_lineno (void)
+int pcap_get_lineno (yyscan_t yyscanner)
{
-
- return pcaplineno;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+
+ return yylineno;
+}
+
+/** Get the current column number.
+ * @param yyscanner The scanner object.
+ */
+int pcap_get_column (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+
+ return yycolumn;
}
/** Get the input stream.
- *
+ * @param yyscanner The scanner object.
*/
-FILE *pcapget_in (void)
+FILE *pcap_get_in (yyscan_t yyscanner)
{
- return pcapin;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyin;
}
/** Get the output stream.
- *
+ * @param yyscanner The scanner object.
*/
-FILE *pcapget_out (void)
+FILE *pcap_get_out (yyscan_t yyscanner)
{
- return pcapout;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyout;
}
/** Get the length of the current token.
- *
+ * @param yyscanner The scanner object.
*/
-yy_size_t pcapget_leng (void)
+yy_size_t pcap_get_leng (yyscan_t yyscanner)
{
- return pcapleng;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyleng;
}
/** Get the current token.
- *
+ * @param yyscanner The scanner object.
*/
-char *pcapget_text (void)
+char *pcap_get_text (yyscan_t yyscanner)
{
- return pcaptext;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yytext;
+}
+
+/** Set the user-defined data. This data is never touched by the scanner.
+ * @param user_defined The data to be associated with this scanner.
+ * @param yyscanner The scanner object.
+ */
+void pcap_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyextra = user_defined ;
}
/** Set the current line number.
* @param line_number
- *
+ * @param yyscanner The scanner object.
+ */
+void pcap_set_lineno (int line_number , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* lineno is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ YY_FATAL_ERROR( "pcap_set_lineno called with no buffer" );
+
+ yylineno = line_number;
+}
+
+/** Set the current column.
+ * @param line_number
+ * @param yyscanner The scanner object.
*/
-void pcapset_lineno (int line_number )
+void pcap_set_column (int column_no , yyscan_t yyscanner)
{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* column is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ YY_FATAL_ERROR( "pcap_set_column called with no buffer" );
- pcaplineno = line_number;
+ yycolumn = column_no;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param in_str A readable stream.
- *
- * @see pcap_switch_to_buffer
+ * @param yyscanner The scanner object.
+ * @see pcap__switch_to_buffer
*/
-void pcapset_in (FILE * in_str )
+void pcap_set_in (FILE * in_str , yyscan_t yyscanner)
{
- pcapin = in_str ;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyin = in_str ;
}
-void pcapset_out (FILE * out_str )
+void pcap_set_out (FILE * out_str , yyscan_t yyscanner)
{
- pcapout = out_str ;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyout = out_str ;
}
-int pcapget_debug (void)
+int pcap_get_debug (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yy_flex_debug;
+}
+
+void pcap_set_debug (int bdebug , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yy_flex_debug = bdebug ;
+}
+
+/* Accessor methods for yylval and yylloc */
+
+YYSTYPE * pcap_get_lval (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yylval;
+}
+
+void pcap_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yylval = yylval_param;
+}
+
+/* User-visible API */
+
+/* pcap_lex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+
+int pcap_lex_init(yyscan_t* ptr_yy_globals)
+
{
- return pcap_flex_debug;
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) pcap_alloc ( sizeof( struct yyguts_t ), NULL );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ return yy_init_globals ( *ptr_yy_globals );
}
-void pcapset_debug (int bdebug )
+/* pcap_lex_init_extra has the same functionality as pcap_lex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to pcap_alloc in
+ * the yyextra field.
+ */
+
+int pcap_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
{
- pcap_flex_debug = bdebug ;
+ struct yyguts_t dummy_yyguts;
+
+ pcap_set_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) pcap_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ pcap_set_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
}
-static int yy_init_globals (void)
+static int yy_init_globals (yyscan_t yyscanner)
{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from pcaplex_destroy(), so don't allocate here.
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from pcap_lex_destroy(), so don't allocate here.
*/
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
+ yyg->yy_buffer_stack = 0;
+ yyg->yy_buffer_stack_top = 0;
+ yyg->yy_buffer_stack_max = 0;
+ yyg->yy_c_buf_p = (char *) 0;
+ yyg->yy_init = 0;
+ yyg->yy_start = 0;
+
+ yyg->yy_start_stack_ptr = 0;
+ yyg->yy_start_stack_depth = 0;
+ yyg->yy_start_stack = NULL;
/* Defined in main.c */
#ifdef YY_STDINIT
- pcapin = stdin;
- pcapout = stdout;
+ yyin = stdin;
+ yyout = stdout;
#else
- pcapin = (FILE *) 0;
- pcapout = (FILE *) 0;
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
#endif
/* For future reference: Set errno on error, since we are called by
- * pcaplex_init()
+ * pcap_lex_init()
*/
return 0;
}
-/* pcaplex_destroy is for both reentrant and non-reentrant scanners. */
-int pcaplex_destroy (void)
+/* pcap_lex_destroy is for both reentrant and non-reentrant scanners. */
+int pcap_lex_destroy (yyscan_t yyscanner)
{
-
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- pcap_delete_buffer(YY_CURRENT_BUFFER );
+ pcap__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
- pcappop_buffer_state();
+ pcap_pop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
- pcapfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
+ pcap_free(yyg->yy_buffer_stack ,yyscanner);
+ yyg->yy_buffer_stack = NULL;
+
+ /* Destroy the start condition stack. */
+ pcap_free(yyg->yy_start_stack ,yyscanner );
+ yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
- * pcaplex() is called, initialization will occur. */
- yy_init_globals( );
+ * pcap_lex() is called, initialization will occur. */
+ yy_init_globals( yyscanner);
+ /* Destroy the main struct (reentrant only). */
+ pcap_free ( yyscanner , yyscanner );
+ yyscanner = NULL;
return 0;
}
@@ -4768,7 +5021,7 @@ int pcaplex_destroy (void)
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
int i;
for ( i = 0; i < n; ++i )
@@ -4777,7 +5030,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
+static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
int n;
for ( n = 0; s[n]; ++n )
@@ -4787,12 +5040,12 @@ static int yy_flex_strlen (yyconst char * s )
}
#endif
-void *pcapalloc (yy_size_t size )
+void *pcap_alloc (yy_size_t size , yyscan_t yyscanner)
{
return (void *) malloc( size );
}
-void *pcaprealloc (void * ptr, yy_size_t size )
+void *pcap_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
@@ -4804,49 +5057,16 @@ void *pcaprealloc (void * ptr, yy_size_t size )
return (void *) realloc( (char *) ptr, size );
}
-void pcapfree (void * ptr )
+void pcap_free (void * ptr , yyscan_t yyscanner)
{
- free( (char *) ptr ); /* see pcaprealloc() for (char *) cast */
+ free( (char *) ptr ); /* see pcap_realloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
-#line 382 "../../freebsd/contrib/libpcap/scanner.l"
-
+#line 448 "scanner.l"
-void
-lex_init(buf)
- const char *buf;
-{
-#ifdef FLEX_SCANNER
- in_buffer = pcap_scan_string(buf);
-#else
- in_buffer = buf;
-#endif
-}
-/*
- * Do any cleanup necessary after parsing.
- */
-void
-lex_cleanup()
-{
-#ifdef FLEX_SCANNER
- if (in_buffer != NULL)
- pcap_delete_buffer(in_buffer);
- in_buffer = NULL;
-#endif
-}
-
-/*
- * Also define a pcapwrap. Note that if we're using flex, it will
- * define a macro to map this identifier to pcap_wrap.
- */
-int
-pcapwrap()
-{
- return 1;
-}
/* Hex digit to integer. */
static inline int
diff --git a/freebsd/contrib/libpcap/scanner.h b/freebsd/contrib/libpcap/scanner.h
new file mode 100644
index 00000000..1aea2cc7
--- /dev/null
+++ b/freebsd/contrib/libpcap/scanner.h
@@ -0,0 +1,362 @@
+#ifndef pcap_HEADER_H
+#define pcap_HEADER_H 1
+#define pcap_IN_HEADER 1
+
+#line 6 "scanner.h"
+#line 2 "scanner.l"
+/* Must come first for _LARGE_FILE_API on AIX. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+
+#line 15 "scanner.h"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 37
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+#if defined(__FreeBSD__)
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
+#include <sys/cdefs.h>
+#include <stdint.h>
+#else
+#define __dead2
+#endif
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined(__FreeBSD__) || \
+ (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ yy_size_t yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+void pcap_restart (FILE *input_file ,yyscan_t yyscanner );
+void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+YY_BUFFER_STATE pcap__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
+void pcap__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void pcap__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+void pcap_pop_buffer_state (yyscan_t yyscanner );
+
+YY_BUFFER_STATE pcap__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+YY_BUFFER_STATE pcap__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE pcap__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+
+void *pcap_alloc (yy_size_t ,yyscan_t yyscanner );
+void *pcap_realloc (void *,yy_size_t ,yyscan_t yyscanner );
+void pcap_free (void * ,yyscan_t yyscanner );
+
+/* Begin user sect3 */
+
+#define pcap_wrap(yyscanner) 1
+#define YY_SKIP_YYWRAP
+
+#define yytext_ptr yytext_r
+
+#ifdef YY_HEADER_EXPORT_START_CONDITIONS
+#define INITIAL 0
+
+#endif
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#define YY_EXTRA_TYPE compiler_state_t *
+
+int pcap_lex_init (yyscan_t* scanner);
+
+int pcap_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int pcap_lex_destroy (yyscan_t yyscanner );
+
+int pcap_get_debug (yyscan_t yyscanner );
+
+void pcap_set_debug (int debug_flag ,yyscan_t yyscanner );
+
+YY_EXTRA_TYPE pcap_get_extra (yyscan_t yyscanner );
+
+void pcap_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+
+FILE *pcap_get_in (yyscan_t yyscanner );
+
+void pcap_set_in (FILE * in_str ,yyscan_t yyscanner );
+
+FILE *pcap_get_out (yyscan_t yyscanner );
+
+void pcap_set_out (FILE * out_str ,yyscan_t yyscanner );
+
+yy_size_t pcap_get_leng (yyscan_t yyscanner );
+
+char *pcap_get_text (yyscan_t yyscanner );
+
+int pcap_get_lineno (yyscan_t yyscanner );
+
+void pcap_set_lineno (int line_number ,yyscan_t yyscanner );
+
+int pcap_get_column (yyscan_t yyscanner );
+
+void pcap_set_column (int column_no ,yyscan_t yyscanner );
+
+YYSTYPE * pcap_get_lval (yyscan_t yyscanner );
+
+void pcap_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int pcap_wrap (yyscan_t yyscanner );
+#else
+extern int pcap_wrap (yyscan_t yyscanner );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+#endif
+
+#ifndef YY_NO_INPUT
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int pcap_lex \
+ (YYSTYPE * yylval_param ,yyscan_t yyscanner);
+
+#define YY_DECL int pcap_lex \
+ (YYSTYPE * yylval_param , yyscan_t yyscanner)
+#endif /* !YY_DECL */
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+
+#line 448 "scanner.l"
+
+
+#line 361 "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 4879c1f3..d71a9bed 100644
--- a/freebsd/contrib/libpcap/scanner.l
+++ b/freebsd/contrib/libpcap/scanner.l
@@ -1,3 +1,46 @@
+%top {
+/* Must come first for _LARGE_FILE_API on AIX. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+}
+
+/*
+ * We want a reentrant scanner.
+ */
+%option reentrant
+
+/*
+ * And we need to pass the compiler state to the scanner.
+ */
+%option extra-type="compiler_state_t *"
+
+/*
+ * We don't use input, so don't generate code for it.
+ */
+%option noinput
+
+/*
+ * We don't use unput, so don't generate code for it.
+ */
+%option nounput
+
+/*
+ * We don't read from the terminal.
+ */
+%option never-interactive
+
+/*
+ * We want to stop processing when we get to the end of the input.
+ */
+%option noyywrap
+
+/*
+ * We want to generate code that can be used by a reentrant parser
+ * generated by Bison or Berkeley YACC.
+ */
+%option bison-bridge
+
%{
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -22,28 +65,19 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.112 2008-02-06 10:21:30 guy Exp $ (LBL)";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef WIN32
-#include <pcap-stdinc.h>
-#else /* WIN32 */
-#if HAVE_INTTYPES_H
-#include <inttypes.h>
-#elif HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
+#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 <sys/types.h>
-#endif /* WIN32 */
#include <ctype.h>
#include <string.h>
@@ -51,25 +85,56 @@ static const char rcsid[] _U_ =
#include "pcap-int.h"
#include "gencode.h"
+
+#include "grammar.h"
+
+/*
+ * Earlier versions of Flex don't declare these, so we declare them
+ * ourselves to squelch warnings.
+ */
+int pcap_get_column(yyscan_t);
+void pcap_set_column(int, yyscan_t);
+
#ifdef INET6
-#ifdef WIN32
-#include <pcap-stdinc.h>
-#ifdef __MINGW32__
-#include "ip6_misc.h"
-#endif
-#else /* WIN32 */
+#ifdef _WIN32
+/*
+ * 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>
+#else /* _WIN32 */
#include <sys/socket.h> /* for "struct sockaddr" in "struct addrinfo" */
#include <netdb.h> /* for "struct addrinfo" */
-#endif /* WIN32 */
+#endif /* _WIN32 */
/* Workaround for AIX 4.3 */
#if !defined(AI_NUMERICHOST)
#define AI_NUMERICHOST 0x04
#endif
+
#endif /*INET6*/
+
#include <pcap/namedb.h>
-#include "tokdefs.h"
+#include "grammar.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
@@ -78,19 +143,6 @@ static const char rcsid[] _U_ =
static int stoi(char *);
static inline int xdtoi(int);
-#ifdef FLEX_SCANNER
-#define YY_NO_INPUT
-#define YY_NO_UNPUT
-static YY_BUFFER_STATE in_buffer;
-#else
-static const char *in_buffer;
-
-#undef getc
-#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
-#endif
-
-extern YYSTYPE yylval;
-
%}
N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
@@ -249,7 +301,7 @@ portrange return PORTRANGE;
proto return PROTO;
protochain {
#ifdef NO_PROTOCHAIN
- bpf_error("%s not supported", yytext);
+ bpf_error(yyextra, "%s not supported", yytext);
#else
return PROTOCHAIN;
#endif
@@ -285,6 +337,7 @@ vlan return VLAN;
mpls return MPLS;
pppoed return PPPOED;
pppoes return PPPOES;
+geneve return GENEVE;
lane return LANE;
llc return LLC;
@@ -312,26 +365,37 @@ fisu return FISU;
lssu return LSSU;
lsu return LSSU;
msu return MSU;
+hfisu return HFISU;
+hlssu return HLSSU;
+hmsu return HMSU;
sio return SIO;
opc return OPC;
dpc return DPC;
sls return SLS;
+hsio return HSIO;
+hopc return HOPC;
+hdpc return HDPC;
+hsls return HSLS;
[ \r\n\t] ;
-[+\-*/:\[\]!<>()&|=] return yytext[0];
+[+\-*/%:\[\]!<>()&|\^=] return yytext[0];
">=" return GEQ;
"<=" return LEQ;
"!=" return NEQ;
"==" return '=';
"<<" return LSH;
">>" return RSH;
-${B} { yylval.e = pcap_ether_aton(((char *)yytext)+1);
+${B} { yylval->e = pcap_ether_aton(((char *)yytext)+1);
+ if (yylval->e == NULL)
+ bpf_error(yyextra, "malloc");
return AID; }
-{MAC} { yylval.e = pcap_ether_aton((char *)yytext);
+{MAC} { yylval->e = pcap_ether_aton((char *)yytext);
+ if (yylval->e == NULL)
+ bpf_error(yyextra, "malloc");
return EID; }
-{N} { yylval.i = stoi((char *)yytext); return NUM; }
+{N} { yylval->i = stoi((char *)yytext); return NUM; }
({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N}) {
- yylval.s = sdup((char *)yytext); return HID; }
+ yylval->s = sdup(yyextra, (char *)yytext); return HID; }
{V6} {
#ifdef INET6
struct addrinfo hints, *res;
@@ -339,80 +403,49 @@ ${B} { yylval.e = pcap_ether_aton(((char *)yytext)+1);
hints.ai_family = AF_INET6;
hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo(yytext, NULL, &hints, &res))
- bpf_error("bogus IPv6 address %s", yytext);
+ bpf_error(yyextra, "bogus IPv6 address %s", yytext);
else {
freeaddrinfo(res);
- yylval.s = sdup((char *)yytext); return HID6;
+ yylval->s = sdup(yyextra, (char *)yytext); return HID6;
}
#else
- bpf_error("IPv6 address %s not supported", yytext);
+ bpf_error(yyextra, "IPv6 address %s not supported", yytext);
#endif /*INET6*/
}
-{B}:+({B}:+)+ { bpf_error("bogus ethernet address %s", yytext); }
-icmptype { yylval.i = 0; return NUM; }
-icmpcode { yylval.i = 1; return NUM; }
-icmp-echoreply { yylval.i = 0; return NUM; }
-icmp-unreach { yylval.i = 3; return NUM; }
-icmp-sourcequench { yylval.i = 4; return NUM; }
-icmp-redirect { yylval.i = 5; return NUM; }
-icmp-echo { yylval.i = 8; return NUM; }
-icmp-routeradvert { yylval.i = 9; return NUM; }
-icmp-routersolicit { yylval.i = 10; return NUM; }
-icmp-timxceed { yylval.i = 11; return NUM; }
-icmp-paramprob { yylval.i = 12; return NUM; }
-icmp-tstamp { yylval.i = 13; return NUM; }
-icmp-tstampreply { yylval.i = 14; return NUM; }
-icmp-ireq { yylval.i = 15; return NUM; }
-icmp-ireqreply { yylval.i = 16; return NUM; }
-icmp-maskreq { yylval.i = 17; return NUM; }
-icmp-maskreply { yylval.i = 18; return NUM; }
-tcpflags { yylval.i = 13; return NUM; }
-tcp-fin { yylval.i = 0x01; return NUM; }
-tcp-syn { yylval.i = 0x02; return NUM; }
-tcp-rst { yylval.i = 0x04; return NUM; }
-tcp-push { yylval.i = 0x08; return NUM; }
-tcp-ack { yylval.i = 0x10; return NUM; }
-tcp-urg { yylval.i = 0x20; return NUM; }
+{B}:+({B}:+)+ { bpf_error(yyextra, "bogus ethernet address %s", yytext); }
+icmptype { yylval->i = 0; return NUM; }
+icmpcode { yylval->i = 1; return NUM; }
+icmp-echoreply { yylval->i = 0; return NUM; }
+icmp-unreach { yylval->i = 3; return NUM; }
+icmp-sourcequench { yylval->i = 4; return NUM; }
+icmp-redirect { yylval->i = 5; return NUM; }
+icmp-echo { yylval->i = 8; return NUM; }
+icmp-routeradvert { yylval->i = 9; return NUM; }
+icmp-routersolicit { yylval->i = 10; return NUM; }
+icmp-timxceed { yylval->i = 11; return NUM; }
+icmp-paramprob { yylval->i = 12; return NUM; }
+icmp-tstamp { yylval->i = 13; return NUM; }
+icmp-tstampreply { yylval->i = 14; return NUM; }
+icmp-ireq { yylval->i = 15; return NUM; }
+icmp-ireqreply { yylval->i = 16; return NUM; }
+icmp-maskreq { yylval->i = 17; return NUM; }
+icmp-maskreply { yylval->i = 18; return NUM; }
+tcpflags { yylval->i = 13; return NUM; }
+tcp-fin { yylval->i = 0x01; return NUM; }
+tcp-syn { yylval->i = 0x02; return NUM; }
+tcp-rst { yylval->i = 0x04; return NUM; }
+tcp-push { yylval->i = 0x08; return NUM; }
+tcp-ack { yylval->i = 0x10; return NUM; }
+tcp-urg { yylval->i = 0x20; return NUM; }
+tcp-ece { yylval->i = 0x40; return NUM; }
+tcp-cwr { yylval->i = 0x80; return NUM; }
[A-Za-z0-9]([-_.A-Za-z0-9]*[.A-Za-z0-9])? {
- yylval.s = sdup((char *)yytext); return ID; }
-"\\"[^ !()\n\t]+ { yylval.s = sdup((char *)yytext + 1); return ID; }
+ yylval->s = sdup(yyextra, (char *)yytext); return ID; }
+"\\"[^ !()\n\t]+ { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }
[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+ {
- bpf_error("illegal token: %s", yytext); }
-. { bpf_error("illegal char '%c'", *yytext); }
+ bpf_error(yyextra, "illegal token: %s", yytext); }
+. { bpf_error(yyextra, "illegal char '%c'", *yytext); }
%%
-void
-lex_init(buf)
- const char *buf;
-{
-#ifdef FLEX_SCANNER
- in_buffer = yy_scan_string(buf);
-#else
- in_buffer = buf;
-#endif
-}
-
-/*
- * Do any cleanup necessary after parsing.
- */
-void
-lex_cleanup()
-{
-#ifdef FLEX_SCANNER
- if (in_buffer != NULL)
- yy_delete_buffer(in_buffer);
- in_buffer = NULL;
-#endif
-}
-
-/*
- * Also define a yywrap. Note that if we're using flex, it will
- * define a macro to map this identifier to pcap_wrap.
- */
-int
-yywrap()
-{
- return 1;
-}
/* Hex digit to integer. */
static inline int
diff --git a/freebsd/contrib/libpcap/sf-pcap-ng.c b/freebsd/contrib/libpcap/sf-pcap-ng.c
index 0cc595d8..209c1424 100644
--- a/freebsd/contrib/libpcap/sf-pcap-ng.c
+++ b/freebsd/contrib/libpcap/sf-pcap-ng.c
@@ -32,9 +32,9 @@ static const char rcsid[] _U_ =
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -44,7 +44,7 @@ static const char rcsid[] _U_ =
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <errno.h>
#include <memory.h>
@@ -123,6 +123,7 @@ struct section_header_block {
* that means that this code can't read the file.
*/
#define PCAP_NG_VERSION_MAJOR 1
+#define PCAP_NG_VERSION_MINOR 0
/*
* Interface Description Block.
@@ -203,6 +204,32 @@ struct block_cursor {
bpf_u_int32 block_type;
};
+typedef enum {
+ PASS_THROUGH,
+ SCALE_UP_DEC,
+ SCALE_DOWN_DEC,
+ SCALE_UP_BIN,
+ SCALE_DOWN_BIN
+} tstamp_scale_type_t;
+
+/*
+ * Per-interface information.
+ */
+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 */
+};
+
+struct pcap_ng_sf {
+ u_int user_tsresol; /* time stamp resolution requested by the user */
+ 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 */
+};
+
+static void pcap_ng_cleanup(pcap_t *p);
static int pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr,
u_char **data);
@@ -215,13 +242,13 @@ 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)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
} else {
if (amt_read == 0 && !fail_on_eof)
return (0); /* EOF */
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"truncated dump file; tried to read %lu bytes, only got %lu",
(unsigned long)bytes_to_read,
(unsigned long)amt_read);
@@ -236,12 +263,14 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
{
int status;
struct block_header bhdr;
+ u_char *bdata;
+ size_t data_remaining;
status = read_bytes(fp, &bhdr, sizeof(bhdr), 0, errbuf);
if (status <= 0)
return (status); /* error or EOF */
- if (p->sf.swapped) {
+ if (p->swapped) {
bhdr.block_type = SWAPLONG(bhdr.block_type);
bhdr.total_length = SWAPLONG(bhdr.total_length);
}
@@ -254,7 +283,7 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
* memory if we read a malformed file.
*/
if (bhdr.total_length > 16*1024*1024) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"pcap-ng block size %u > maximum %u",
bhdr.total_length, 16*1024*1024);
return (-1);
@@ -266,7 +295,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)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"block in pcap-ng dump file has a length of %u < %lu",
bhdr.total_length,
(unsigned long)(sizeof(struct block_header) + sizeof(struct block_trailer)));
@@ -280,11 +309,14 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
/*
* No - make it big enough.
*/
- p->buffer = realloc(p->buffer, bhdr.total_length);
- if (p->buffer == NULL) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory");
+ void *bigger_buffer;
+
+ bigger_buffer = realloc(p->buffer, bhdr.total_length);
+ if (bigger_buffer == NULL) {
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory");
return (-1);
}
+ p->buffer = bigger_buffer;
}
/*
@@ -292,16 +324,16 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
* of the block.
*/
memcpy(p->buffer, &bhdr, sizeof(bhdr));
- if (read_bytes(fp, p->buffer + sizeof(bhdr),
- bhdr.total_length - sizeof(bhdr), 1, errbuf) == -1)
+ bdata = (u_char *)p->buffer + sizeof(bhdr);
+ data_remaining = bhdr.total_length - sizeof(bhdr);
+ if (read_bytes(fp, bdata, data_remaining, 1, errbuf) == -1)
return (-1);
/*
* Initialize the cursor.
*/
- cursor->data = p->buffer + sizeof(bhdr);
- cursor->data_remaining = bhdr.total_length - sizeof(bhdr) -
- sizeof(struct block_trailer);
+ cursor->data = bdata;
+ cursor->data_remaining = data_remaining - sizeof(struct block_trailer);
cursor->block_type = bhdr.block_type;
return (1);
}
@@ -317,7 +349,7 @@ get_from_block_data(struct block_cursor *cursor, size_t chunk_size,
* the block data.
*/
if (cursor->data_remaining < chunk_size) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"block of type %u in pcap-ng dump file is too short",
cursor->block_type);
return (NULL);
@@ -348,7 +380,7 @@ get_opthdr_from_block_data(pcap_t *p, struct block_cursor *cursor, char *errbuf)
/*
* Byte-swap it if necessary.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
opthdr->option_code = SWAPSHORT(opthdr->option_code);
opthdr->option_length = SWAPSHORT(opthdr->option_length);
}
@@ -380,7 +412,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, char *errbuf)
+ u_int64_t *tsoffset, int *is_binary, char *errbuf)
{
struct option_header *opthdr;
void *optvalue;
@@ -418,7 +450,7 @@ process_idb_options(pcap_t *p, struct block_cursor *cursor, u_int *tsresol,
case OPT_ENDOFOPT:
if (opthdr->option_length != 0) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block has opt_endofopt option with length %u != 0",
opthdr->option_length);
return (-1);
@@ -427,27 +459,29 @@ process_idb_options(pcap_t *p, struct block_cursor *cursor, u_int *tsresol,
case IF_TSRESOL:
if (opthdr->option_length != 1) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block has if_tsresol option with length %u != 1",
opthdr->option_length);
return (-1);
}
if (saw_tsresol) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block has more than one if_tsresol option");
return (-1);
}
saw_tsresol = 1;
- tsresol_opt = *(u_int *)optvalue;
+ memcpy(&tsresol_opt, optvalue, sizeof(tsresol_opt));
if (tsresol_opt & 0x80) {
/*
* Resolution is negative power of 2.
*/
+ *is_binary = 1;
*tsresol = 1 << (tsresol_opt & 0x7F);
} else {
/*
* Resolution is negative power of 10.
*/
+ *is_binary = 0;
*tsresol = 1;
for (i = 0; i < tsresol_opt; i++)
*tsresol *= 10;
@@ -457,11 +491,11 @@ process_idb_options(pcap_t *p, struct block_cursor *cursor, u_int *tsresol,
* Resolution is too high.
*/
if (tsresol_opt & 0x80) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block if_tsresol option resolution 2^-%u is too high",
tsresol_opt & 0x7F);
} else {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block if_tsresol option resolution 10^-%u is too high",
tsresol_opt);
}
@@ -471,19 +505,19 @@ process_idb_options(pcap_t *p, struct block_cursor *cursor, u_int *tsresol,
case IF_TSOFFSET:
if (opthdr->option_length != 8) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block has if_tsoffset option with length %u != 8",
opthdr->option_length);
return (-1);
}
if (saw_tsoffset) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Interface Description Block has more than one if_tsoffset option");
return (-1);
}
saw_tsoffset = 1;
memcpy(tsoffset, optvalue, sizeof(*tsoffset));
- if (p->sf.swapped)
+ if (p->swapped)
*tsoffset = SWAPLL(*tsoffset);
break;
@@ -496,25 +530,204 @@ done:
return (0);
}
+static int
+add_interface(pcap_t *p, struct block_cursor *cursor, char *errbuf)
+{
+ struct pcap_ng_sf *ps;
+ u_int tsresol;
+ u_int64_t tsoffset;
+ int is_binary;
+
+ ps = p->priv;
+
+ /*
+ * Count this interface.
+ */
+ ps->ifcount++;
+
+ /*
+ * Grow the array of per-interface information as necessary.
+ */
+ if (ps->ifcount > ps->ifaces_size) {
+ /*
+ * We need to grow the array.
+ */
+ bpf_u_int32 new_ifaces_size;
+ struct pcap_ng_if *new_ifaces;
+
+ if (ps->ifaces_size == 0) {
+ /*
+ * It's currently empty.
+ *
+ * (The Clang static analyzer doesn't do enough,
+ * err, umm, dataflow *analysis* to realize that
+ * ps->ifaces_size == 0 if ps->ifaces == NULL,
+ * and so complains about a possible zero argument
+ * to realloc(), so we check for the former
+ * condition to shut it up.
+ *
+ * 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
+ * interfaces).)
+ */
+ new_ifaces_size = 1;
+ new_ifaces = malloc(sizeof (struct pcap_ng_if));
+ } else {
+ /*
+ * It's not currently empty; double its size.
+ * (Perhaps overkill once we have a lot of interfaces.)
+ *
+ * Check for overflow if we double it.
+ */
+ if (ps->ifaces_size * 2 < ps->ifaces_size) {
+ /*
+ * The maximum number of interfaces before
+ * ps->ifaces_size overflows is the largest
+ * possible 32-bit power of 2, as we do
+ * size doubling.
+ */
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "more than %u interfaces in the file",
+ 0x80000000U);
+ return (0);
+ }
+
+ /*
+ * ps->ifaces_size * 2 doesn't overflow, so it's
+ * safe to multiply.
+ */
+ new_ifaces_size = ps->ifaces_size * 2;
+
+ /*
+ * Now make sure that's not so big that it overflows
+ * if we multiply by sizeof (struct pcap_ng_if).
+ *
+ * That can happen on 32-bit platforms, with a 32-bit
+ * size_t; it shouldn't happen on 64-bit platforms,
+ * with a 64-bit size_t, as new_ifaces_size is
+ * 32 bits.
+ */
+ if (new_ifaces_size * sizeof (struct pcap_ng_if) < new_ifaces_size) {
+ /*
+ * As this fails only with 32-bit size_t,
+ * the multiplication was 32x32->32, and
+ * the largest 32-bit value that can safely
+ * be multiplied by sizeof (struct pcap_ng_if)
+ * without overflow is the largest 32-bit
+ * (unsigned) value divided by
+ * sizeof (struct pcap_ng_if).
+ */
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "more than %u interfaces in the file",
+ 0xFFFFFFFFU / ((u_int)sizeof (struct pcap_ng_if)));
+ return (0);
+ }
+ new_ifaces = realloc(ps->ifaces, new_ifaces_size * sizeof (struct pcap_ng_if));
+ }
+ if (new_ifaces == NULL) {
+ /*
+ * We ran out of memory.
+ * Give up.
+ */
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "out of memory for per-interface information (%u interfaces)",
+ ps->ifcount);
+ return (0);
+ }
+ ps->ifaces_size = new_ifaces_size;
+ ps->ifaces = new_ifaces;
+ }
+
+ /*
+ * Set the default time stamp resolution and offset.
+ */
+ tsresol = 1000000; /* microsecond resolution */
+ is_binary = 0; /* which is a power of 10 */
+ tsoffset = 0; /* absolute timestamps */
+
+ /*
+ * Now look for various time stamp options, so we know
+ * how to interpret the time stamps for this interface.
+ */
+ if (process_idb_options(p, cursor, &tsresol, &tsoffset, &is_binary,
+ errbuf) == -1)
+ return (0);
+
+ ps->ifaces[ps->ifcount - 1].tsresol = tsresol;
+ ps->ifaces[ps->ifcount - 1].tsoffset = tsoffset;
+
+ /*
+ * Determine whether we're scaling up or down or not
+ * at all for this interface.
+ */
+ if (tsresol == ps->user_tsresol) {
+ /*
+ * The resolution is the resolution the user wants,
+ * so we don't have to do scaling.
+ */
+ ps->ifaces[ps->ifcount - 1].scale_type = PASS_THROUGH;
+ } else if (tsresol > ps->user_tsresol) {
+ /*
+ * The resolution is greater than what the user wants,
+ * so we have to scale the timestamps down.
+ */
+ if (is_binary)
+ ps->ifaces[ps->ifcount - 1].scale_type = SCALE_DOWN_BIN;
+ else {
+ /*
+ * Calculate the scale factor.
+ */
+ ps->ifaces[ps->ifcount - 1].scale_factor = tsresol/ps->user_tsresol;
+ ps->ifaces[ps->ifcount - 1].scale_type = SCALE_DOWN_DEC;
+ }
+ } else {
+ /*
+ * The resolution is less than what the user wants,
+ * so we have to scale the timestamps up.
+ */
+ if (is_binary)
+ ps->ifaces[ps->ifcount - 1].scale_type = SCALE_UP_BIN;
+ else {
+ /*
+ * Calculate the scale factor.
+ */
+ ps->ifaces[ps->ifcount - 1].scale_factor = ps->user_tsresol/tsresol;
+ ps->ifaces[ps->ifcount - 1].scale_type = SCALE_UP_DEC;
+ }
+ }
+ return (1);
+}
+
/*
* Check whether this is a pcap-ng savefile and, if it is, extract the
* relevant information from the header.
*/
-int
-pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
+pcap_t *
+pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf,
+ int *err)
{
size_t amt_read;
bpf_u_int32 total_length;
bpf_u_int32 byte_order_magic;
struct block_header *bhdrp;
struct section_header_block *shbp;
+ pcap_t *p;
+ int swapped = 0;
+ struct pcap_ng_sf *ps;
int status;
struct block_cursor cursor;
struct interface_description_block *idbp;
/*
+ * Assume no read errors.
+ */
+ *err = 0;
+
+ /*
* Check whether the first 4 bytes of the file are the block
- * type for a pcap-ng savefile.
+ * type for a pcap-ng savefile.
*/
if (magic != BT_SHB) {
/*
@@ -526,7 +739,7 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
* this as possibly being a pcap-ng file transferred
* between UN*X and Windows in text file format?
*/
- return (0); /* nope */
+ return (NULL); /* nope */
}
/*
@@ -543,32 +756,34 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
amt_read = fread(&total_length, 1, sizeof(total_length), fp);
if (amt_read < sizeof(total_length)) {
if (ferror(fp)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
- return (-1); /* fail */
+ *err = 1;
+ return (NULL); /* fail */
}
/*
* Possibly a weird short text file, so just say
* "not pcap-ng".
*/
- return (0);
+ return (NULL);
}
amt_read = fread(&byte_order_magic, 1, sizeof(byte_order_magic), fp);
if (amt_read < sizeof(byte_order_magic)) {
if (ferror(fp)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
- return (-1); /* fail */
+ *err = 1;
+ return (NULL); /* fail */
}
/*
* Possibly a weird short text file, so just say
* "not pcap-ng".
*/
- return (0);
+ return (NULL);
}
if (byte_order_magic != BYTE_ORDER_MAGIC) {
byte_order_magic = SWAPLONG(byte_order_magic);
@@ -576,9 +791,9 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
/*
* Not a pcap-ng file.
*/
- return (0);
+ return (NULL);
}
- p->sf.swapped = 1;
+ swapped = 1;
total_length = SWAPLONG(total_length);
}
@@ -586,12 +801,49 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
* Check the sanity of the total length.
*/
if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Section Header Block in pcap-ng dump file has a length of %u < %lu",
total_length,
(unsigned long)(sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)));
- return (-1);
+ *err = 1;
+ return (NULL);
+ }
+
+ /*
+ * OK, this is a good pcap-ng file.
+ * Allocate a pcap_t for it.
+ */
+ p = pcap_open_offline_common(errbuf, sizeof (struct pcap_ng_sf));
+ if (p == NULL) {
+ /* Allocation failed. */
+ *err = 1;
+ return (NULL);
}
+ p->swapped = swapped;
+ ps = p->priv;
+
+ /*
+ * What precision does the user want?
+ */
+ switch (precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ ps->user_tsresol = 1000000;
+ break;
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ ps->user_tsresol = 1000000000;
+ break;
+
+ default:
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "unknown time stamp resolution %u", precision);
+ free(p);
+ *err = 1;
+ return (NULL);
+ }
+
+ p->opt.tstamp_precision = precision;
/*
* Allocate a buffer into which to read blocks. We default to
@@ -610,8 +862,10 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
p->bufsize = total_length;
p->buffer = malloc(p->bufsize);
if (p->buffer == NULL) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory");
- return (-1);
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory");
+ free(p);
+ *err = 1;
+ return (NULL);
}
/*
@@ -619,17 +873,17 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
* of the SHB.
*/
bhdrp = (struct block_header *)p->buffer;
- shbp = (struct section_header_block *)(p->buffer + sizeof(struct block_header));
+ shbp = (struct section_header_block *)((u_char *)p->buffer + sizeof(struct block_header));
bhdrp->block_type = magic;
bhdrp->total_length = total_length;
shbp->byte_order_magic = byte_order_magic;
if (read_bytes(fp,
- p->buffer + (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)),
+ (u_char *)p->buffer + (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)),
total_length - (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)),
1, errbuf) == -1)
goto fail;
- if (p->sf.swapped) {
+ if (p->swapped) {
/*
* Byte-swap the fields we've read.
*/
@@ -640,21 +894,21 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
* XXX - we don't care about the section length.
*/
}
- if (shbp->major_version != PCAP_NG_VERSION_MAJOR) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "unknown pcap-ng savefile major version number %u",
- shbp->major_version);
+ /* currently only SHB version 1.0 is supported */
+ 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",
+ shbp->major_version, shbp->minor_version);
goto fail;
}
- p->sf.version_major = shbp->major_version;
- p->sf.version_minor = shbp->minor_version;
+ p->version_major = shbp->major_version;
+ p->version_minor = shbp->minor_version;
/*
- * Set the default time stamp resolution and offset.
+ * Save the time stamp resolution the user requested.
*/
- p->sf.tsresol = 1000000; /* microsecond resolution */
- p->sf.tsscale = 1; /* multiply by 1 to scale to microseconds */
- p->sf.tsoffset = 0; /* absolute timestamps */
+ p->opt.tstamp_precision = precision;
/*
* Now start looking for an Interface Description Block.
@@ -666,7 +920,7 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
status = read_block(fp, p, &cursor, errbuf);
if (status == 0) {
/* EOF - no IDB in this file */
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"the capture file has no Interface Description Blocks");
goto fail;
}
@@ -687,42 +941,28 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
/*
* Byte-swap it if necessary.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
idbp->linktype = SWAPSHORT(idbp->linktype);
idbp->snaplen = SWAPLONG(idbp->snaplen);
}
/*
- * Count this interface.
+ * Interface capture length sanity check
*/
- p->sf.ifcount++;
+ 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;
+ }
/*
- * Now look for various time stamp options, so
- * we know how to interpret the time stamps.
+ * Try to add this interface.
*/
- if (process_idb_options(p, &cursor, &p->sf.tsresol,
- &p->sf.tsoffset, errbuf) == -1)
+ if (!add_interface(p, &cursor, errbuf))
goto fail;
- /*
- * Compute the scaling factor to convert the
- * sub-second part of the time stamp to
- * microseconds.
- */
- if (p->sf.tsresol > 1000000) {
- /*
- * Higher than microsecond resolution;
- * scale down to microseconds.
- */
- p->sf.tsscale = (p->sf.tsresol / 1000000);
- } else {
- /*
- * Lower than microsecond resolution;
- * scale up to microseconds.
- */
- p->sf.tsscale = (1000000 / p->sf.tsresol);
- }
goto done;
case BT_EPB:
@@ -733,7 +973,7 @@ pcap_ng_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
* not valid, as we don't know what link-layer
* encapsulation the packet has.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"the capture file has a packet block before any Interface Description Blocks");
goto fail;
@@ -751,13 +991,26 @@ done:
p->linktype = linktype_to_dlt(idbp->linktype);
p->linktype_ext = 0;
- p->sf.next_packet_op = pcap_ng_next_packet;
+ p->next_packet_op = pcap_ng_next_packet;
+ p->cleanup_op = pcap_ng_cleanup;
- return (1);
+ return (p);
fail:
+ free(ps->ifaces);
free(p->buffer);
- return (-1);
+ free(p);
+ *err = 1;
+ return (NULL);
+}
+
+static void
+pcap_ng_cleanup(pcap_t *p)
+{
+ struct pcap_ng_sf *ps = p->priv;
+
+ free(ps->ifaces);
+ sf_cleanup(p);
}
/*
@@ -768,6 +1021,7 @@ fail:
static int
pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
{
+ struct pcap_ng_sf *ps = p->priv;
struct block_cursor cursor;
int status;
struct enhanced_packet_block *epbp;
@@ -776,9 +1030,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
bpf_u_int32 interface_id = 0xFFFFFFFF;
struct interface_description_block *idbp;
struct section_header_block *shbp;
- FILE *fp = p->sf.rfile;
- u_int tsresol;
- u_int64_t tsoffset;
+ FILE *fp = p->rfile;
u_int64_t t, sec, frac;
/*
@@ -810,7 +1062,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* Byte-swap it if necessary.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
/* these were written in opposite byte order */
interface_id = SWAPLONG(epbp->interface_id);
hdr->caplen = SWAPLONG(epbp->caplen);
@@ -825,7 +1077,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
epbp->timestamp_low;
}
goto found;
-
+
case BT_SPB:
/*
* Get a pointer to the fixed-length portion of the
@@ -845,7 +1097,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* Byte-swap it if necessary.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
/* these were written in opposite byte order */
hdr->len = SWAPLONG(spbp->len);
} else
@@ -857,7 +1109,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* and the packet length.
*/
hdr->caplen = hdr->len;
- if (hdr->caplen > p->snapshot)
+ if (hdr->caplen > (bpf_u_int32)p->snapshot)
hdr->caplen = p->snapshot;
t = 0; /* no time stamps */
goto found;
@@ -875,7 +1127,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* Byte-swap it if necessary.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
/* these were written in opposite byte order */
interface_id = SWAPSHORT(pbp->interface_id);
hdr->caplen = SWAPLONG(pbp->caplen);
@@ -904,7 +1156,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* Byte-swap it if necessary.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
idbp->linktype = SWAPSHORT(idbp->linktype);
idbp->snaplen = SWAPLONG(idbp->snaplen);
}
@@ -918,50 +1170,23 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* interfaces?
*/
if (p->linktype != idbp->linktype) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"an interface has a type %u different from the type of the first interface",
idbp->linktype);
return (-1);
}
- if (p->snapshot != idbp->snaplen) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ if ((bpf_u_int32)p->snapshot != idbp->snaplen) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"an interface has a snapshot length %u different from the type of the first interface",
idbp->snaplen);
return (-1);
}
/*
- * Count this interface.
+ * Try to add this interface.
*/
- p->sf.ifcount++;
-
- /*
- * Set the default time stamp resolution and offset.
- */
- tsresol = 1000000; /* microsecond resolution */
- tsoffset = 0; /* absolute timestamps */
-
- /*
- * Now look for various time stamp options, to
- * make sure they're the same.
- *
- * XXX - we could, in theory, handle multiple
- * different resolutions and offsets, but we
- * don't do so for now.
- */
- if (process_idb_options(p, &cursor, &tsresol, &tsoffset,
- p->errbuf) == -1)
- return (-1);
- if (tsresol != p->sf.tsresol) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "an interface has a time stamp resolution different from the time stamp resolution of the first interface");
+ if (!add_interface(p, &cursor, p->errbuf))
return (-1);
- }
- if (tsoffset != p->sf.tsoffset) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "an interface has a time stamp offset different from the time stamp offset of the first interface");
- return (-1);
- }
break;
case BT_SHB:
@@ -979,7 +1204,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* the same as that of the previous section.
* We'll check for that later.
*/
- if (p->sf.swapped) {
+ if (p->swapped) {
shbp->byte_order_magic =
SWAPLONG(shbp->byte_order_magic);
shbp->major_version =
@@ -1003,7 +1228,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* Byte order changes.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"the file has sections with different byte orders");
return (-1);
@@ -1011,7 +1236,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* Not a valid SHB.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"the file has a section with a bad byte order magic field");
return (-1);
}
@@ -1021,7 +1246,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* we handle.
*/
if (shbp->major_version != PCAP_NG_VERSION_MAJOR) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"unknown pcap-ng savefile major version number %u",
shbp->major_version);
return (-1);
@@ -1036,7 +1261,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* any IDBs, we'll fail when we see a packet
* block.)
*/
- p->sf.ifcount = 0;
+ ps->ifcount = 0;
break;
default:
@@ -1044,43 +1269,148 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* Not a packet block, IDB, or SHB; ignore it.
*/
break;
- }
+ }
}
found:
/*
* Is the interface ID an interface we know?
*/
- if (interface_id >= p->sf.ifcount) {
+ if (interface_id >= ps->ifcount) {
/*
* Yes. Fail.
*/
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"a packet arrived on interface %u, but there's no Interface Description Block for that interface",
interface_id);
return (-1);
}
/*
- * Convert the time stamp to a struct timeval.
+ * Convert the time stamp to seconds and fractions of a second,
+ * with the fractions being in units of the file-supplied resolution.
*/
- sec = t / p->sf.tsresol + p->sf.tsoffset;
- frac = t % p->sf.tsresol;
- if (p->sf.tsresol > 1000000) {
+ sec = t / ps->ifaces[interface_id].tsresol + ps->ifaces[interface_id].tsoffset;
+ frac = t % ps->ifaces[interface_id].tsresol;
+
+ /*
+ * Convert the fractions from units of the file-supplied resolution
+ * to units of the user-requested resolution.
+ */
+ switch (ps->ifaces[interface_id].scale_type) {
+
+ case PASS_THROUGH:
/*
- * Higher than microsecond resolution; scale down to
- * microseconds.
+ * The interface resolution is what the user wants,
+ * so we're done.
*/
- frac /= p->sf.tsscale;
- } else {
+ break;
+
+ case SCALE_UP_DEC:
+ /*
+ * The interface resolution is less than what the user
+ * wants; scale the fractional part up to the units of
+ * the resolution the user requested by multiplying by
+ * the quotient of the user-requested resolution and the
+ * file-supplied resolution.
+ *
+ * Those resolutions are both powers of 10, and the user-
+ * requested resolution is greater than the file-supplied
+ * resolution, so the quotient in question is an integer.
+ * We've calculated that quotient already, so we just
+ * multiply by it.
+ */
+ frac *= ps->ifaces[interface_id].scale_factor;
+ break;
+
+ case SCALE_UP_BIN:
/*
- * Lower than microsecond resolution; scale up to
- * microseconds.
+ * The interface resolution is less than what the user
+ * wants; scale the fractional part up to the units of
+ * the resolution the user requested by multiplying by
+ * the quotient of the user-requested resolution and the
+ * file-supplied resolution.
+ *
+ * The file-supplied resolution is a power of 2, so the
+ * quotient is not an integer, so, in order to do this
+ * entirely with integer arithmetic, we multiply by the
+ * user-requested resolution and divide by the file-
+ * supplied resolution.
+ *
+ * XXX - Is there something clever we could do here,
+ * given that we know that the file-supplied resolution
+ * is a power of 2? Doing a multiplication followed by
+ * a division runs the risk of overflowing, and involves
+ * two non-simple arithmetic operations.
*/
- frac *= p->sf.tsscale;
+ frac *= ps->user_tsresol;
+ frac /= ps->ifaces[interface_id].tsresol;
+ break;
+
+ case SCALE_DOWN_DEC:
+ /*
+ * The interface resolution is greater than what the user
+ * wants; scale the fractional part up to the units of
+ * the resolution the user requested by multiplying by
+ * the quotient of the user-requested resolution and the
+ * file-supplied resolution.
+ *
+ * Those resolutions are both powers of 10, and the user-
+ * requested resolution is less than the file-supplied
+ * resolution, so the quotient in question isn't an
+ * integer, but its reciprocal is, and we can just divide
+ * by the reciprocal of the quotient. We've calculated
+ * the reciprocal of that quotient already, so we must
+ * divide by it.
+ */
+ frac /= ps->ifaces[interface_id].scale_factor;
+ break;
+
+
+ case SCALE_DOWN_BIN:
+ /*
+ * The interface resolution is greater than what the user
+ * wants; convert the fractional part to units of the
+ * resolution the user requested by multiplying by the
+ * quotient of the user-requested resolution and the
+ * file-supplied resolution. We do that by multiplying
+ * by the user-requested resolution and dividing by the
+ * file-supplied resolution, as the quotient might not
+ * fit in an integer.
+ *
+ * The file-supplied resolution is a power of 2, so the
+ * quotient is not an integer, and neither is its
+ * reciprocal, so, in order to do this entirely with
+ * integer arithmetic, we multiply by the user-requested
+ * resolution and divide by the file-supplied resolution.
+ *
+ * XXX - Is there something clever we could do here,
+ * given that we know that the file-supplied resolution
+ * is a power of 2? Doing a multiplication followed by
+ * a division runs the risk of overflowing, and involves
+ * two non-simple arithmetic operations.
+ */
+ frac *= ps->user_tsresol;
+ frac /= ps->ifaces[interface_id].tsresol;
+ break;
}
- hdr->ts.tv_sec = sec;
- hdr->ts.tv_usec = frac;
+#ifdef _WIN32
+ /*
+ * tv_sec and tv_used in the Windows struct timeval are both
+ * longs.
+ */
+ hdr->ts.tv_sec = (long)sec;
+ hdr->ts.tv_usec = (long)frac;
+#else
+ /*
+ * tv_sec in the UN*X struct timeval is a time_t; tv_usec is
+ * suseconds_t in UN*Xes that work the way the current Single
+ * UNIX Standard specify - but not all older UN*Xes necessarily
+ * support that type, so just cast to int.
+ */
+ hdr->ts.tv_sec = (time_t)sec;
+ hdr->ts.tv_usec = (int)frac;
+#endif
/*
* Get a pointer to the packet data.
@@ -1089,23 +1419,8 @@ found:
if (*data == NULL)
return (-1);
- if (p->sf.swapped) {
- /*
- * Convert pseudo-headers from the byte order of
- * the host on which the file was saved to our
- * byte order, as necessary.
- */
- switch (p->linktype) {
-
- case DLT_USB_LINUX:
- swap_linux_usb_header(hdr, *data, 0);
- break;
-
- case DLT_USB_LINUX_MMAPPED:
- swap_linux_usb_header(hdr, *data, 1);
- break;
- }
- }
+ if (p->swapped)
+ swap_pseudo_headers(p->linktype, hdr, *data);
return (0);
}
diff --git a/freebsd/contrib/libpcap/sf-pcap-ng.h b/freebsd/contrib/libpcap/sf-pcap-ng.h
index cc551824..3c93498f 100644
--- a/freebsd/contrib/libpcap/sf-pcap-ng.h
+++ b/freebsd/contrib/libpcap/sf-pcap-ng.h
@@ -26,6 +26,7 @@
#ifndef sf_pcap_ng_h
#define sf_pcap_ng_h
-extern int pcap_ng_check_header(pcap_t *, bpf_u_int32, FILE *, char *);
+extern pcap_t *pcap_ng_check_header(bpf_u_int32 magic, FILE *fp,
+ u_int precision, char *errbuf, int *err);
#endif
diff --git a/freebsd/contrib/libpcap/sf-pcap.c b/freebsd/contrib/libpcap/sf-pcap.c
index 6fda84f2..d7cb806f 100644
--- a/freebsd/contrib/libpcap/sf-pcap.c
+++ b/freebsd/contrib/libpcap/sf-pcap.c
@@ -39,9 +39,9 @@ static const char rcsid[] _U_ =
#include "config.h"
#endif
-#ifdef WIN32
+#ifdef _WIN32
#include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
@@ -51,7 +51,7 @@ static const char rcsid[] _U_ =
#include <sys/bitypes.h>
#endif
#include <sys/types.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#include <errno.h>
#include <memory.h>
@@ -72,7 +72,7 @@ static const char rcsid[] _U_ =
/*
* Setting O_BINARY on DOS/Windows is a bit tricky
*/
-#if defined(WIN32)
+#if defined(_WIN32)
#define SET_BINMODE(f) _setmode(_fileno(f), _O_BINARY)
#elif defined(MSDOS)
#if defined(__HIGHC__)
@@ -125,25 +125,57 @@ static const char rcsid[] _U_ =
static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
/*
+ * Private data for reading pcap savefiles.
+ */
+typedef enum {
+ NOT_SWAPPED,
+ SWAPPED,
+ MAYBE_SWAPPED
+} swapped_type_t;
+
+typedef enum {
+ PASS_THROUGH,
+ SCALE_UP,
+ SCALE_DOWN
+} tstamp_scale_type_t;
+
+struct pcap_sf {
+ size_t hdrsize;
+ swapped_type_t lengths_swapped;
+ tstamp_scale_type_t scale_type;
+};
+
+/*
* Check whether this is a pcap savefile and, if it is, extract the
* relevant information from the header.
*/
-int
-pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
+pcap_t *
+pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf,
+ int *err)
{
struct pcap_file_header hdr;
size_t amt_read;
+ pcap_t *p;
+ int swapped = 0;
+ struct pcap_sf *ps;
+
+ /*
+ * Assume no read errors.
+ */
+ *err = 0;
/*
* Check whether the first 4 bytes of the file are the magic
* number for a pcap savefile, or for a byte-swapped pcap
* savefile.
*/
- if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC) {
+ if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC &&
+ magic != NSEC_TCPDUMP_MAGIC) {
magic = SWAPLONG(magic);
- if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC)
- return (0); /* nope */
- p->sf.swapped = 1;
+ if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC &&
+ magic != NSEC_TCPDUMP_MAGIC)
+ return (NULL); /* nope */
+ swapped = 1;
}
/*
@@ -155,22 +187,23 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
sizeof(hdr) - sizeof(hdr.magic), fp);
if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) {
if (ferror(fp)) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
} else {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"truncated dump file; tried to read %lu file header bytes, only got %lu",
(unsigned long)sizeof(hdr),
(unsigned long)amt_read);
}
- return (-1);
+ *err = 1;
+ return (NULL);
}
/*
* If it's a byte-swapped capture file, byte-swap the header.
*/
- if (p->sf.swapped) {
+ if (swapped) {
hdr.version_major = SWAPSHORT(hdr.version_major);
hdr.version_minor = SWAPSHORT(hdr.version_minor);
hdr.thiszone = SWAPLONG(hdr.thiszone);
@@ -180,18 +213,106 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
}
if (hdr.version_major < PCAP_VERSION_MAJOR) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
"archaic pcap savefile format");
- return (-1);
+ *err = 1;
+ return (NULL);
+ }
+
+ /*
+ * currently only versions 2.[0-4] are supported with
+ * the exception of 543.0 for DG/UX tcpdump.
+ */
+ if (! ((hdr.version_major == PCAP_VERSION_MAJOR &&
+ hdr.version_minor <= PCAP_VERSION_MINOR) ||
+ (hdr.version_major == 543 &&
+ hdr.version_minor == 0))) {
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "unsupported pcap savefile version %u.%u",
+ hdr.version_major, hdr.version_minor);
+ *err = 1;
+ 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.
+ */
+ p = pcap_open_offline_common(errbuf, sizeof (struct pcap_sf));
+ if (p == NULL) {
+ /* Allocation failed. */
+ *err = 1;
+ return (NULL);
}
- p->sf.version_major = hdr.version_major;
- p->sf.version_minor = hdr.version_minor;
+ p->swapped = swapped;
+ p->version_major = hdr.version_major;
+ p->version_minor = hdr.version_minor;
p->tzoff = hdr.thiszone;
p->snapshot = hdr.snaplen;
p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype));
p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype);
- p->sf.next_packet_op = pcap_next_packet;
+ p->next_packet_op = pcap_next_packet;
+
+ ps = p->priv;
+
+ p->opt.tstamp_precision = precision;
+
+ /*
+ * Will we need to scale the timestamps to match what the
+ * user wants?
+ */
+ switch (precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ if (magic == NSEC_TCPDUMP_MAGIC) {
+ /*
+ * The file has nanoseconds, the user
+ * wants microseconds; scale the
+ * precision down.
+ */
+ ps->scale_type = SCALE_DOWN;
+ } else {
+ /*
+ * The file has microseconds, the
+ * user wants microseconds; nothing to do.
+ */
+ ps->scale_type = PASS_THROUGH;
+ }
+ break;
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ if (magic == NSEC_TCPDUMP_MAGIC) {
+ /*
+ * The file has nanoseconds, the
+ * user wants nanoseconds; nothing to do.
+ */
+ ps->scale_type = PASS_THROUGH;
+ } else {
+ /*
+ * The file has microoseconds, the user
+ * wants nanoseconds; scale the
+ * precision up.
+ */
+ ps->scale_type = SCALE_UP;
+ }
+ break;
+
+ default:
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "unknown time stamp resolution %u", precision);
+ free(p);
+ *err = 1;
+ return (NULL);
+ }
/*
* We interchanged the caplen and len fields at version 2.3,
@@ -207,19 +328,19 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
case 2:
if (hdr.version_minor < 3)
- p->sf.lengths_swapped = SWAPPED;
+ ps->lengths_swapped = SWAPPED;
else if (hdr.version_minor == 3)
- p->sf.lengths_swapped = MAYBE_SWAPPED;
+ ps->lengths_swapped = MAYBE_SWAPPED;
else
- p->sf.lengths_swapped = NOT_SWAPPED;
+ ps->lengths_swapped = NOT_SWAPPED;
break;
case 543:
- p->sf.lengths_swapped = SWAPPED;
+ ps->lengths_swapped = SWAPPED;
break;
default:
- p->sf.lengths_swapped = NOT_SWAPPED;
+ ps->lengths_swapped = NOT_SWAPPED;
break;
}
@@ -241,7 +362,7 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
* data ourselves and read from that buffer in order to
* make that work.
*/
- p->sf.hdrsize = sizeof(struct pcap_sf_patched_pkthdr);
+ ps->hdrsize = sizeof(struct pcap_sf_patched_pkthdr);
if (p->linktype == DLT_EN10MB) {
/*
@@ -267,7 +388,7 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
p->snapshot += 14;
}
} else
- p->sf.hdrsize = sizeof(struct pcap_sf_pkthdr);
+ ps->hdrsize = sizeof(struct pcap_sf_pkthdr);
/*
* Allocate a buffer for the packet data.
@@ -275,17 +396,21 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
p->bufsize = p->snapshot;
if (p->bufsize <= 0) {
/*
- * Bogus snapshot length; use 64KiB as a fallback.
+ * Bogus snapshot length; use the maximum as a fallback.
*/
- p->bufsize = 65536;
+ p->bufsize = MAXIMUM_SNAPLEN;
}
p->buffer = malloc(p->bufsize);
if (p->buffer == NULL) {
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory");
- return (-1);
+ pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "out of memory");
+ free(p);
+ *err = 1;
+ return (NULL);
}
- return (1);
+ p->cleanup_op = sf_cleanup;
+
+ return (p);
}
/*
@@ -296,8 +421,9 @@ pcap_check_header(pcap_t *p, bpf_u_int32 magic, FILE *fp, char *errbuf)
static int
pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
{
+ struct pcap_sf *ps = p->priv;
struct pcap_sf_patched_pkthdr sf_hdr;
- FILE *fp = p->sf.rfile;
+ FILE *fp = p->rfile;
size_t amt_read;
bpf_u_int32 t;
@@ -308,18 +434,18 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* unpatched libpcap we only read as many bytes as the regular
* header has.
*/
- amt_read = fread(&sf_hdr, 1, p->sf.hdrsize, fp);
- if (amt_read != p->sf.hdrsize) {
+ amt_read = fread(&sf_hdr, 1, ps->hdrsize, fp);
+ if (amt_read != ps->hdrsize) {
if (ferror(fp)) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
return (-1);
} else {
if (amt_read != 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"truncated dump file; tried to read %lu header bytes, only got %lu",
- (unsigned long)p->sf.hdrsize,
+ (unsigned long)ps->hdrsize,
(unsigned long)amt_read);
return (-1);
}
@@ -328,7 +454,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
}
}
- if (p->sf.swapped) {
+ if (p->swapped) {
/* these were written in opposite byte order */
hdr->caplen = SWAPLONG(sf_hdr.caplen);
hdr->len = SWAPLONG(sf_hdr.len);
@@ -340,8 +466,34 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
hdr->ts.tv_sec = sf_hdr.ts.tv_sec;
hdr->ts.tv_usec = sf_hdr.ts.tv_usec;
}
+
+ switch (ps->scale_type) {
+
+ case PASS_THROUGH:
+ /*
+ * Just pass the time stamp through.
+ */
+ break;
+
+ case SCALE_UP:
+ /*
+ * File has microseconds, user wants nanoseconds; convert
+ * it.
+ */
+ hdr->ts.tv_usec = hdr->ts.tv_usec * 1000;
+ break;
+
+ case SCALE_DOWN:
+ /*
+ * File has nanoseconds, user wants microseconds; convert
+ * it.
+ */
+ hdr->ts.tv_usec = hdr->ts.tv_usec / 1000;
+ break;
+ }
+
/* Swap the caplen and len fields, if necessary. */
- switch (p->sf.lengths_swapped) {
+ switch (ps->lengths_swapped) {
case NOT_SWAPPED:
break;
@@ -367,63 +519,93 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
/*
* This can happen due to Solaris 2.3 systems tripping
* over the BUFMOD problem and not setting the snapshot
- * correctly in the savefile header. If the caplen isn't
- * grossly wrong, try to salvage.
+ * 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.
*/
- static u_char *tp = NULL;
- static size_t tsize = 0;
-
- if (hdr->caplen > 65535) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "bogus savefile header");
+ 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 (tsize < hdr->caplen) {
- tsize = ((hdr->caplen + 1023) / 1024) * 1024;
- if (tp != NULL)
- free((u_char *)tp);
- tp = (u_char *)malloc(tsize);
- if (tp == NULL) {
- tsize = 0;
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "BUFMOD hack malloc");
- return (-1);
- }
- }
- amt_read = fread((char *)tp, 1, hdr->caplen, fp);
- if (amt_read != hdr->caplen) {
+ /*
+ * 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.
+ */
+ amt_read = fread(p->buffer, 1, p->bufsize, fp);
+ if (amt_read != p->bufsize) {
if (ferror(fp)) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
} else {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ /*
+ * Yes, this uses hdr->caplen; technically,
+ * it's true, because we would try to read
+ * and discard the rest of those bytes, and
+ * that would fail because we got EOF before
+ * the read finished.
+ */
+ 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);
}
return (-1);
}
+
/*
- * We can only keep up to p->bufsize bytes. Since
- * caplen > p->bufsize is exactly how we got here,
- * we know we can only keep the first p->bufsize bytes
- * and must drop the remainder. Adjust caplen accordingly,
- * so we don't get confused later as to how many bytes we
- * have to play with.
+ * Now read and discard what's left.
+ */
+ bytes_to_discard = hdr->caplen - p->bufsize;
+ bytes_read = amt_read;
+ while (bytes_to_discard != 0) {
+ bytes_to_read = bytes_to_discard;
+ if (bytes_to_read > sizeof (discard_buf))
+ bytes_to_read = sizeof (discard_buf);
+ amt_read = fread(discard_buf, 1, bytes_to_read, fp);
+ 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));
+ } else {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "truncated dump file; tried to read %u captured bytes, only got %lu",
+ hdr->caplen, (unsigned long)bytes_read);
+ }
+ return (-1);
+ }
+ bytes_to_discard -= amt_read;
+ }
+
+ /*
+ * Adjust caplen accordingly, so we don't get confused later
+ * as to how many bytes we have to play with.
*/
hdr->caplen = p->bufsize;
- memcpy(p->buffer, (char *)tp, p->bufsize);
} else {
/* read the packet itself */
amt_read = fread(p->buffer, 1, hdr->caplen, fp);
if (amt_read != hdr->caplen) {
if (ferror(fp)) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"error reading dump file: %s",
pcap_strerror(errno));
} else {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ 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);
}
@@ -432,33 +614,18 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
}
*data = p->buffer;
- if (p->sf.swapped) {
- /*
- * Convert pseudo-headers from the byte order of
- * the host on which the file was saved to our
- * byte order, as necessary.
- */
- switch (p->linktype) {
-
- case DLT_USB_LINUX:
- swap_linux_usb_header(hdr, *data, 0);
- break;
-
- case DLT_USB_LINUX_MMAPPED:
- swap_linux_usb_header(hdr, *data, 1);
- break;
- }
- }
+ if (p->swapped)
+ swap_pseudo_headers(p->linktype, hdr, *data);
return (0);
}
static int
-sf_write_header(FILE *fp, int linktype, int thiszone, int snaplen)
+sf_write_header(pcap_t *p, FILE *fp, int linktype, int thiszone, int snaplen)
{
struct pcap_file_header hdr;
- hdr.magic = TCPDUMP_MAGIC;
+ hdr.magic = p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? NSEC_TCPDUMP_MAGIC : TCPDUMP_MAGIC;
hdr.version_major = PCAP_VERSION_MAJOR;
hdr.version_minor = PCAP_VERSION_MINOR;
@@ -496,7 +663,7 @@ static pcap_dumper_t *
pcap_setup_dump(pcap_t *p, int linktype, FILE *f, const char *fname)
{
-#if defined(WIN32) || defined(MSDOS)
+#if defined(_WIN32) || defined(MSDOS)
/*
* If we're writing to the standard output, put it in binary
* mode, as savefiles are binary files.
@@ -509,8 +676,8 @@ pcap_setup_dump(pcap_t *p, int linktype, FILE *f, const char *fname)
else
setbuf(f, NULL);
#endif
- if (sf_write_header(f, linktype, p->tzoff, p->snapshot) == -1) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't write to %s: %s",
+ 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));
if (f != stdout)
(void)fclose(f);
@@ -533,31 +700,36 @@ pcap_dump_open(pcap_t *p, const char *fname)
* link-layer type, so we can't use it.
*/
if (!p->activated) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"%s: not-yet-activated pcap_t passed to pcap_dump_open",
fname);
return (NULL);
}
linktype = dlt_to_linktype(p->linktype);
if (linktype == -1) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"%s: link-layer type %d isn't supported in savefiles",
fname, p->linktype);
return (NULL);
}
linktype |= p->linktype_ext;
+ if (fname == NULL) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "A null pointer was supplied as the file name");
+ return NULL;
+ }
if (fname[0] == '-' && fname[1] == '\0') {
f = stdout;
fname = "standard output";
} else {
-#if !defined(WIN32) && !defined(MSDOS)
+#if !defined(_WIN32) && !defined(MSDOS)
f = fopen(fname, "w");
#else
f = fopen(fname, "wb");
#endif
if (f == NULL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
fname, pcap_strerror(errno));
return (NULL);
}
@@ -570,12 +742,12 @@ pcap_dump_open(pcap_t *p, const char *fname)
*/
pcap_dumper_t *
pcap_dump_fopen(pcap_t *p, FILE *f)
-{
+{
int linktype;
linktype = dlt_to_linktype(p->linktype);
if (linktype == -1) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"stream: link-layer type %d isn't supported in savefiles",
p->linktype);
return (NULL);
@@ -585,6 +757,174 @@ pcap_dump_fopen(pcap_t *p, FILE *f)
return (pcap_setup_dump(p, linktype, f, "stream"));
}
+pcap_dumper_t *
+pcap_dump_open_append(pcap_t *p, const char *fname)
+{
+ FILE *f;
+ int linktype;
+ size_t amt_read;
+ struct pcap_file_header ph;
+
+ linktype = dlt_to_linktype(p->linktype);
+ if (linktype == -1) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: link-layer type %d isn't supported in savefiles",
+ fname, linktype);
+ return (NULL);
+ }
+
+ if (fname == NULL) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "A null pointer was supplied as the file name");
+ return NULL;
+ }
+ 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
+ f = fopen(fname, "rb+");
+#endif
+ if (f == NULL) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
+ fname, pcap_strerror(errno));
+ return (NULL);
+ }
+
+ /*
+ * Try to read a pcap header.
+ */
+ 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));
+ fclose(f);
+ return (NULL);
+ } else if (feof(f) && amt_read > 0) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: truncated pcap file header", fname);
+ fclose(f);
+ return (NULL);
+ }
+ }
+
+#if defined(_WIN32) || defined(MSDOS)
+ /*
+ * We turn off buffering.
+ * XXX - why? And why not on the standard output?
+ */
+ setbuf(f, NULL);
+#endif
+
+ /*
+ * If a header is already present and:
+ *
+ * it's not for a pcap file of the appropriate resolution
+ * and the right byte order for this machine;
+ *
+ * the link-layer header types don't match;
+ *
+ * the snapshot lengths don't match;
+ *
+ * return an error.
+ */
+ if (amt_read > 0) {
+ /*
+ * A header is already present.
+ * Do the checks.
+ */
+ switch (ph.magic) {
+
+ case TCPDUMP_MAGIC:
+ if (p->opt.tstamp_precision != PCAP_TSTAMP_PRECISION_MICRO) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: different time stamp precision, cannot append to file", fname);
+ fclose(f);
+ return (NULL);
+ }
+ break;
+
+ case NSEC_TCPDUMP_MAGIC:
+ if (p->opt.tstamp_precision != PCAP_TSTAMP_PRECISION_NANO) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: different time stamp precision, cannot append to file", fname);
+ fclose(f);
+ return (NULL);
+ }
+ break;
+
+ case SWAPLONG(TCPDUMP_MAGIC):
+ case SWAPLONG(NSEC_TCPDUMP_MAGIC):
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: different byte order, cannot append to file", fname);
+ fclose(f);
+ return (NULL);
+
+ case KUZNETZOV_TCPDUMP_MAGIC:
+ case SWAPLONG(KUZNETZOV_TCPDUMP_MAGIC):
+ case NAVTEL_TCPDUMP_MAGIC:
+ case SWAPLONG(NAVTEL_TCPDUMP_MAGIC):
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: not a pcap file to which we can append", fname);
+ fclose(f);
+ return (NULL);
+
+ default:
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: not a pcap file", fname);
+ fclose(f);
+ return (NULL);
+ }
+
+ /*
+ * Good version?
+ */
+ if (ph.version_major != PCAP_VERSION_MAJOR ||
+ ph.version_minor != PCAP_VERSION_MINOR) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: version is %u.%u, cannot append to file", fname,
+ ph.version_major, ph.version_minor);
+ fclose(f);
+ return (NULL);
+ }
+ if ((bpf_u_int32)linktype != ph.linktype) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: different linktype, cannot append to file", fname);
+ fclose(f);
+ return (NULL);
+ }
+ if ((bpf_u_int32)p->snapshot != ph.snaplen) {
+ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "%s: different snaplen, cannot append to file", fname);
+ fclose(f);
+ return (NULL);
+ }
+ } else {
+ /*
+ * 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));
+ (void)fclose(f);
+ return (NULL);
+ }
+ }
+
+ /*
+ * 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));
+ (void)fclose(f);
+ return (NULL);
+ }
+ return ((pcap_dumper_t *)f);
+}
+
FILE *
pcap_dump_file(pcap_dumper_t *p)
{
diff --git a/freebsd/contrib/libpcap/sf-pcap.h b/freebsd/contrib/libpcap/sf-pcap.h
index 3b3fbe89..e9c7eafa 100644
--- a/freebsd/contrib/libpcap/sf-pcap.h
+++ b/freebsd/contrib/libpcap/sf-pcap.h
@@ -31,6 +31,7 @@
#ifndef sf_pcap_h
#define sf_pcap_h
-extern int pcap_check_header(pcap_t *, bpf_u_int32, FILE *, char *);
+extern pcap_t *pcap_check_header(bpf_u_int32 magic, FILE *fp,
+ u_int precision, char *errbuf, int *err);
#endif
diff --git a/freebsd/contrib/libpcap/sunatmpos.h b/freebsd/contrib/libpcap/sunatmpos.h
index 916017fa..787de857 100644
--- a/freebsd/contrib/libpcap/sunatmpos.h
+++ b/freebsd/contrib/libpcap/sunatmpos.h
@@ -28,8 +28,6 @@
* 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.
- *
- * @(#) $Header: /tcpdump/master/libpcap/sunatmpos.h,v 1.1 2002-07-11 09:06:47 guy Exp $ (LBL)
*/
/* SunATM header for ATM packet */
diff --git a/libbsd.py b/libbsd.py
index 2a9a8baa..be880210 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -3660,19 +3660,25 @@ def contrib_libpcap(mm):
'contrib/libpcap/arcnet.h',
'contrib/libpcap/atmuni31.h',
'contrib/libpcap/ethertype.h',
+ 'contrib/libpcap/extract.h',
'contrib/libpcap/gencode.h',
'contrib/libpcap/ieee80211.h',
'contrib/libpcap/llc.h',
+ 'contrib/libpcap/nametoaddr.h',
'contrib/libpcap/nlpid.h',
'contrib/libpcap/pcap-common.h',
'contrib/libpcap/pcap-int.h',
'contrib/libpcap/pcap-namedb.h',
'contrib/libpcap/pcap.h',
+ 'contrib/libpcap/pcap/can_socketcan.h',
+ 'contrib/libpcap/pcap/export-defs.h',
'contrib/libpcap/pcap/ipnet.h',
'contrib/libpcap/pcap/namedb.h',
+ 'contrib/libpcap/pcap/nflog.h',
'contrib/libpcap/pcap/pcap.h',
'contrib/libpcap/pcap/sll.h',
'contrib/libpcap/pcap/usb.h',
+ 'contrib/libpcap/portability.h',
'contrib/libpcap/ppp.h',
'contrib/libpcap/sf-pcap-ng.h',
'contrib/libpcap/sf-pcap.h',
@@ -3700,6 +3706,7 @@ def contrib_libpcap(mm):
'contrib/libpcap/bpf_image.c',
'contrib/libpcap/etherent.c',
'contrib/libpcap/fad-getad.c',
+ 'contrib/libpcap/fad-helpers.c',
'contrib/libpcap/gencode.c',
'contrib/libpcap/inet.c',
'contrib/libpcap/pcap.c',
diff --git a/libbsd_waf.py b/libbsd_waf.py
index ed7c8995..4b01268a 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -1384,6 +1384,7 @@ def build(bld):
objs07_source = ['freebsd/contrib/libpcap/bpf_image.c',
'freebsd/contrib/libpcap/etherent.c',
'freebsd/contrib/libpcap/fad-getad.c',
+ 'freebsd/contrib/libpcap/fad-helpers.c',
'freebsd/contrib/libpcap/gencode.c',
'freebsd/contrib/libpcap/inet.c',
'freebsd/contrib/libpcap/nametoaddr.c',