diff options
author | root <root@build-vm.(none)> | 2010-06-14 15:51:25 -0700 |
---|---|---|
committer | root <root@build-vm.(none)> | 2010-06-14 15:51:25 -0700 |
commit | c4414d9a8b31bedfb7471cd2365aaf5ea5cf55d5 (patch) | |
tree | 86ee5befd8195f56dcd91f9fd4e06368bf507a11 /src | |
download | conntrack-tools-c4414d9a8b31bedfb7471cd2365aaf5ea5cf55d5.tar.gz conntrack-tools-c4414d9a8b31bedfb7471cd2365aaf5ea5cf55d5.zip |
debian conntrack 0.9.14-2
Diffstat (limited to 'src')
49 files changed, 23394 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..76f0e73 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,33 @@ +include $(top_srcdir)/Make_global.am + +YACC=@YACC@ -d + +CLEANFILES = read_config_yy.c read_config_lex.c + +sbin_PROGRAMS = conntrack conntrackd + +conntrack_SOURCES = conntrack.c +conntrack_LDADD = ../extensions/libct_proto_tcp.la ../extensions/libct_proto_udp.la ../extensions/libct_proto_udplite.la ../extensions/libct_proto_icmp.la ../extensions/libct_proto_icmpv6.la ../extensions/libct_proto_sctp.la ../extensions/libct_proto_dccp.la ../extensions/libct_proto_gre.la ../extensions/libct_proto_unknown.la +conntrack_LDFLAGS = $(all_libraries) @LIBNETFILTER_CONNTRACK_LIBS@ + +conntrackd_SOURCES = alarm.c main.c run.c hash.c queue.c rbtree.c \ + local.c log.c mcast.c udp.c netlink.c vector.c \ + filter.c fds.c event.c process.c origin.c date.c \ + cache.c cache_iterators.c \ + cache_timer.c \ + sync-mode.c sync-alarm.c sync-ftfw.c sync-notrack.c \ + traffic_stats.c stats-mode.c \ + network.c cidr.c \ + build.c parse.c \ + channel.c multichannel.c channel_mcast.c channel_udp.c \ + tcp.c channel_tcp.c \ + external_cache.c external_inject.c \ + internal_cache.c internal_bypass.c \ + read_config_yy.y read_config_lex.l + +# yacc and lex generate dirty code +read_config_yy.o read_config_lex.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations -Wno-implicit-function-declaration -Wno-nested-externs -Wno-undef -Wno-redundant-decls + +conntrackd_LDFLAGS = $(all_libraries) @LIBNETFILTER_CONNTRACK_LIBS@ + +EXTRA_DIST = read_config_yy.h diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..94c36c3 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,647 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Make_global.am read_config_lex.c \ + read_config_yy.c +sbin_PROGRAMS = conntrack$(EXEEXT) conntrackd$(EXEEXT) +subdir = src +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(sbindir)" +PROGRAMS = $(sbin_PROGRAMS) +am_conntrack_OBJECTS = conntrack.$(OBJEXT) +conntrack_OBJECTS = $(am_conntrack_OBJECTS) +conntrack_DEPENDENCIES = ../extensions/libct_proto_tcp.la \ + ../extensions/libct_proto_udp.la \ + ../extensions/libct_proto_udplite.la \ + ../extensions/libct_proto_icmp.la \ + ../extensions/libct_proto_icmpv6.la \ + ../extensions/libct_proto_sctp.la \ + ../extensions/libct_proto_dccp.la \ + ../extensions/libct_proto_gre.la \ + ../extensions/libct_proto_unknown.la +conntrack_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(conntrack_LDFLAGS) $(LDFLAGS) -o $@ +am_conntrackd_OBJECTS = alarm.$(OBJEXT) main.$(OBJEXT) run.$(OBJEXT) \ + hash.$(OBJEXT) queue.$(OBJEXT) rbtree.$(OBJEXT) \ + local.$(OBJEXT) log.$(OBJEXT) mcast.$(OBJEXT) udp.$(OBJEXT) \ + netlink.$(OBJEXT) vector.$(OBJEXT) filter.$(OBJEXT) \ + fds.$(OBJEXT) event.$(OBJEXT) process.$(OBJEXT) \ + origin.$(OBJEXT) date.$(OBJEXT) cache.$(OBJEXT) \ + cache_iterators.$(OBJEXT) cache_timer.$(OBJEXT) \ + sync-mode.$(OBJEXT) sync-alarm.$(OBJEXT) sync-ftfw.$(OBJEXT) \ + sync-notrack.$(OBJEXT) traffic_stats.$(OBJEXT) \ + stats-mode.$(OBJEXT) network.$(OBJEXT) cidr.$(OBJEXT) \ + build.$(OBJEXT) parse.$(OBJEXT) channel.$(OBJEXT) \ + multichannel.$(OBJEXT) channel_mcast.$(OBJEXT) \ + channel_udp.$(OBJEXT) tcp.$(OBJEXT) channel_tcp.$(OBJEXT) \ + external_cache.$(OBJEXT) external_inject.$(OBJEXT) \ + internal_cache.$(OBJEXT) internal_bypass.$(OBJEXT) \ + read_config_yy.$(OBJEXT) read_config_lex.$(OBJEXT) +conntrackd_OBJECTS = $(am_conntrackd_OBJECTS) +conntrackd_LDADD = $(LDADD) +conntrackd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(conntrackd_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) +YLWRAP = $(top_srcdir)/ylwrap +YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) +SOURCES = $(conntrack_SOURCES) $(conntrackd_SOURCES) +DIST_SOURCES = $(conntrack_SOURCES) $(conntrackd_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBNETFILTER_CONNTRACK_CFLAGS = @LIBNETFILTER_CONNTRACK_CFLAGS@ +LIBNETFILTER_CONNTRACK_LIBS = @LIBNETFILTER_CONNTRACK_LIBS@ +LIBNFNETLINK_CFLAGS = @LIBNFNETLINK_CFLAGS@ +LIBNFNETLINK_LIBS = @LIBNFNETLINK_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XLEX = @XLEX@ +XYACC = @XYACC@ +YACC = @YACC@ -d +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -std=gnu99 -W -Wall \ + -Wmissing-prototypes -Wwrite-strings -Wcast-qual -Wfloat-equal -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wstrict-prototypes -Wundef \ + -Wno-unused-parameter + +CLEANFILES = read_config_yy.c read_config_lex.c +conntrack_SOURCES = conntrack.c +conntrack_LDADD = ../extensions/libct_proto_tcp.la ../extensions/libct_proto_udp.la ../extensions/libct_proto_udplite.la ../extensions/libct_proto_icmp.la ../extensions/libct_proto_icmpv6.la ../extensions/libct_proto_sctp.la ../extensions/libct_proto_dccp.la ../extensions/libct_proto_gre.la ../extensions/libct_proto_unknown.la +conntrack_LDFLAGS = $(all_libraries) @LIBNETFILTER_CONNTRACK_LIBS@ +conntrackd_SOURCES = alarm.c main.c run.c hash.c queue.c rbtree.c \ + local.c log.c mcast.c udp.c netlink.c vector.c \ + filter.c fds.c event.c process.c origin.c date.c \ + cache.c cache_iterators.c \ + cache_timer.c \ + sync-mode.c sync-alarm.c sync-ftfw.c sync-notrack.c \ + traffic_stats.c stats-mode.c \ + network.c cidr.c \ + build.c parse.c \ + channel.c multichannel.c channel_mcast.c channel_udp.c \ + tcp.c channel_tcp.c \ + external_cache.c external_inject.c \ + internal_cache.c internal_bypass.c \ + read_config_yy.y read_config_lex.l + +conntrackd_LDFLAGS = $(all_libraries) @LIBNETFILTER_CONNTRACK_LIBS@ +EXTRA_DIST = read_config_yy.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .l .lo .o .obj .y +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Make_global.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-sbinPROGRAMS: $(sbin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" + @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-sbinPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(sbindir)" && rm -f $$files + +clean-sbinPROGRAMS: + @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +conntrack$(EXEEXT): $(conntrack_OBJECTS) $(conntrack_DEPENDENCIES) + @rm -f conntrack$(EXEEXT) + $(conntrack_LINK) $(conntrack_OBJECTS) $(conntrack_LDADD) $(LIBS) +conntrackd$(EXEEXT): $(conntrackd_OBJECTS) $(conntrackd_DEPENDENCIES) + @rm -f conntrackd$(EXEEXT) + $(conntrackd_LINK) $(conntrackd_OBJECTS) $(conntrackd_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alarm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/build.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache_iterators.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache_timer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel_mcast.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel_tcp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel_udp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cidr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conntrack.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/date.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/external_cache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/external_inject.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fds.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/internal_bypass.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/internal_cache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mcast.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multichannel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/origin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rbtree.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_config_lex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_config_yy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stats-mode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sync-alarm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sync-ftfw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sync-mode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sync-notrack.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/traffic_stats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +.l.c: + $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) + +.y.c: + $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(sbindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f read_config_lex.c + -rm -f read_config_yy.c +clean: clean-am + +clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-sbinPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sbinPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-sbinPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sbinPROGRAMS install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-sbinPROGRAMS + + +# yacc and lex generate dirty code +read_config_yy.o read_config_lex.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations -Wno-implicit-function-declaration -Wno-nested-externs -Wno-undef -Wno-redundant-decls + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/alarm.c b/src/alarm.c new file mode 100644 index 0000000..006721a --- /dev/null +++ b/src/alarm.c @@ -0,0 +1,150 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "alarm.h" +#include "date.h" +#include <stdlib.h> +#include <limits.h> + +static struct rb_root alarm_root = RB_ROOT; + +void init_alarm(struct alarm_block *t, + void *data, + void (*fcn)(struct alarm_block *a, void *data)) +{ + /* initialize the head to check whether a node is inserted */ + RB_CLEAR_NODE(&t->node); + timerclear(&t->tv); + t->data = data; + t->function = fcn; +} + +static void __add_alarm(struct alarm_block *alarm) +{ + struct rb_node **new = &(alarm_root.rb_node); + struct rb_node *parent = NULL; + + while (*new) { + struct alarm_block *this; + + this = container_of(*new, struct alarm_block, node); + + parent = *new; + if (timercmp(&alarm->tv, &this->tv, <)) + new = &((*new)->rb_left); + else + new = &((*new)->rb_right); + } + + rb_link_node(&alarm->node, parent, new); + rb_insert_color(&alarm->node, &alarm_root); +} + +void add_alarm(struct alarm_block *alarm, unsigned long sc, unsigned long usc) +{ + struct timeval tv; + + del_alarm(alarm); + alarm->tv.tv_sec = sc; + alarm->tv.tv_usec = usc; + gettimeofday_cached(&tv); + timeradd(&alarm->tv, &tv, &alarm->tv); + __add_alarm(alarm); +} + +void del_alarm(struct alarm_block *alarm) +{ + /* don't remove a non-inserted node */ + if (!RB_EMPTY_NODE(&alarm->node)) { + rb_erase(&alarm->node, &alarm_root); + RB_CLEAR_NODE(&alarm->node); + } +} + +int alarm_pending(struct alarm_block *alarm) +{ + if (RB_EMPTY_NODE(&alarm->node)) + return 0; + + return 1; +} + +static struct timeval * +calculate_next_run(struct timeval *cand, + struct timeval *tv, + struct timeval *next_run) +{ + if (cand->tv_sec != LONG_MAX) { + if (timercmp(cand, tv, >)) + timersub(cand, tv, next_run); + else { + /* loop again inmediately */ + next_run->tv_sec = 0; + next_run->tv_usec = 0; + } + return next_run; + } + return NULL; +} + +struct timeval * +get_next_alarm_run(struct timeval *next_run) +{ + struct rb_node *node; + struct timeval tv; + + gettimeofday_cached(&tv); + + node = rb_first(&alarm_root); + if (node) { + struct alarm_block *this; + this = container_of(node, struct alarm_block, node); + return calculate_next_run(&this->tv, &tv, next_run); + } + return NULL; +} + +struct timeval * +do_alarm_run(struct timeval *next_run) +{ + struct list_head alarm_run_queue; + struct rb_node *node; + struct alarm_block *this, *tmp; + struct timeval tv; + + gettimeofday_cached(&tv); + + INIT_LIST_HEAD(&alarm_run_queue); + for (node = rb_first(&alarm_root); node; node = rb_next(node)) { + this = container_of(node, struct alarm_block, node); + + if (timercmp(&this->tv, &tv, >)) + break; + + list_add(&this->list, &alarm_run_queue); + } + + /* must be safe as entries can vanish from the callback */ + list_for_each_entry_safe(this, tmp, &alarm_run_queue, list) { + rb_erase(&this->node, &alarm_root); + RB_CLEAR_NODE(&this->node); + this->function(this, this->data); + } + + return get_next_alarm_run(next_run); +} diff --git a/src/build.c b/src/build.c new file mode 100644 index 0000000..6d8b12e --- /dev/null +++ b/src/build.c @@ -0,0 +1,209 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <string.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include "network.h" +#include "conntrackd.h" + +static inline void * +put_header(struct nethdr *n, int attr, size_t len) +{ + struct netattr *nta = NETHDR_TAIL(n); + int total_size = NTA_ALIGN(NTA_LENGTH(len)); + int attr_size = NTA_LENGTH(len); + n->len += total_size; + nta->nta_attr = htons(attr); + nta->nta_len = htons(attr_size); + memset((unsigned char *)nta + attr_size, 0, total_size - attr_size); + return NTA_DATA(nta); +} + +static inline void +addattr(struct nethdr *n, int attr, const void *data, size_t len) +{ + void *ptr = put_header(n, attr, len); + memcpy(ptr, data, len); +} + +static inline void +__build_u8(const struct nf_conntrack *ct, int a, struct nethdr *n, int b) +{ + void *ptr = put_header(n, b, sizeof(uint8_t)); + memcpy(ptr, nfct_get_attr(ct, a), sizeof(uint8_t)); +} + +static inline void +__build_u16(const struct nf_conntrack *ct, int a, struct nethdr *n, int b) +{ + uint16_t data = nfct_get_attr_u16(ct, a); + data = htons(data); + addattr(n, b, &data, sizeof(uint16_t)); +} + +static inline void +__build_u32(const struct nf_conntrack *ct, int a, struct nethdr *n, int b) +{ + uint32_t data = nfct_get_attr_u32(ct, a); + data = htonl(data); + addattr(n, b, &data, sizeof(uint32_t)); +} + +static inline void +__build_group(const struct nf_conntrack *ct, int a, struct nethdr *n, + int b, int size) +{ + void *ptr = put_header(n, b, size); + nfct_get_attr_grp(ct, a, ptr); +} + +static inline void +__build_natseqadj(const struct nf_conntrack *ct, struct nethdr *n) +{ + struct nta_attr_natseqadj data = { + .orig_seq_correction_pos = + htonl(nfct_get_attr_u32(ct, ATTR_ORIG_NAT_SEQ_CORRECTION_POS)), + .orig_seq_offset_before = + htonl(nfct_get_attr_u32(ct, ATTR_ORIG_NAT_SEQ_OFFSET_BEFORE)), + .orig_seq_offset_after = + htonl(nfct_get_attr_u32(ct, ATTR_ORIG_NAT_SEQ_OFFSET_AFTER)), + .repl_seq_correction_pos = + htonl(nfct_get_attr_u32(ct, ATTR_REPL_NAT_SEQ_CORRECTION_POS)), + .repl_seq_offset_before = + htonl(nfct_get_attr_u32(ct, ATTR_REPL_NAT_SEQ_OFFSET_BEFORE)), + .repl_seq_offset_after = + htonl(nfct_get_attr_u32(ct, ATTR_REPL_NAT_SEQ_OFFSET_AFTER)) + }; + addattr(n, NTA_NAT_SEQ_ADJ, &data, sizeof(struct nta_attr_natseqadj)); +} + +static enum nf_conntrack_attr nat_type[] = + { ATTR_ORIG_NAT_SEQ_CORRECTION_POS, ATTR_ORIG_NAT_SEQ_OFFSET_BEFORE, + ATTR_ORIG_NAT_SEQ_OFFSET_AFTER, ATTR_REPL_NAT_SEQ_CORRECTION_POS, + ATTR_REPL_NAT_SEQ_OFFSET_BEFORE, ATTR_REPL_NAT_SEQ_OFFSET_AFTER }; + +static void build_l4proto_tcp(const struct nf_conntrack *ct, struct nethdr *n) +{ + if (!nfct_attr_is_set(ct, ATTR_TCP_STATE)) + return; + + __build_u8(ct, ATTR_TCP_STATE, n, NTA_TCP_STATE); +} + +static void build_l4proto_sctp(const struct nf_conntrack *ct, struct nethdr *n) +{ + if (!nfct_attr_is_set(ct, ATTR_SCTP_STATE)) + return; + + __build_u8(ct, ATTR_SCTP_STATE, n, NTA_SCTP_STATE); + __build_u32(ct, ATTR_SCTP_VTAG_ORIG, n, NTA_SCTP_VTAG_ORIG); + __build_u32(ct, ATTR_SCTP_VTAG_REPL, n, NTA_SCTP_VTAG_REPL); +} + +static void build_l4proto_dccp(const struct nf_conntrack *ct, struct nethdr *n) +{ + if (!nfct_attr_is_set(ct, ATTR_DCCP_STATE)) + return; + + __build_u8(ct, ATTR_DCCP_STATE, n, NTA_DCCP_STATE); + __build_u8(ct, ATTR_DCCP_ROLE, n, NTA_DCCP_ROLE); +} + +static void build_l4proto_icmp(const struct nf_conntrack *ct, struct nethdr *n) +{ + __build_u8(ct, ATTR_ICMP_TYPE, n, NTA_ICMP_TYPE); + __build_u8(ct, ATTR_ICMP_CODE, n, NTA_ICMP_CODE); + __build_u16(ct, ATTR_ICMP_ID, n, NTA_ICMP_ID); +} + +#ifndef IPPROTO_DCCP +#define IPPROTO_DCCP 33 +#endif + +static struct build_l4proto { + void (*build)(const struct nf_conntrack *, struct nethdr *n); +} l4proto_fcn[IPPROTO_MAX] = { + [IPPROTO_TCP] = { .build = build_l4proto_tcp }, + [IPPROTO_SCTP] = { .build = build_l4proto_sctp }, + [IPPROTO_DCCP] = { .build = build_l4proto_dccp }, + [IPPROTO_ICMP] = { .build = build_l4proto_icmp }, +}; + +void build_payload(const struct nf_conntrack *ct, struct nethdr *n) +{ + uint8_t l4proto = nfct_get_attr_u8(ct, ATTR_L4PROTO); + + if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV4)) { + __build_group(ct, ATTR_GRP_ORIG_IPV4, n, NTA_IPV4, + sizeof(struct nfct_attr_grp_ipv4)); + } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV6)) { + __build_group(ct, ATTR_GRP_ORIG_IPV6, n, NTA_IPV6, + sizeof(struct nfct_attr_grp_ipv6)); + } + + __build_u8(ct, ATTR_L4PROTO, n, NTA_L4PROTO); + if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_PORT)) { + __build_group(ct, ATTR_GRP_ORIG_PORT, n, NTA_PORT, + sizeof(struct nfct_attr_grp_port)); + } + + __build_u32(ct, ATTR_STATUS, n, NTA_STATUS); + + if (l4proto_fcn[l4proto].build) + l4proto_fcn[l4proto].build(ct, n); + + if (!CONFIG(commit_timeout) && nfct_attr_is_set(ct, ATTR_TIMEOUT)) + __build_u32(ct, ATTR_TIMEOUT, n, NTA_TIMEOUT); + if (nfct_attr_is_set(ct, ATTR_MARK)) + __build_u32(ct, ATTR_MARK, n, NTA_MARK); + + /* setup the master conntrack */ + if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_IPV4)) { + __build_group(ct, ATTR_GRP_MASTER_IPV4, n, NTA_MASTER_IPV4, + sizeof(struct nfct_attr_grp_ipv4)); + __build_u8(ct, ATTR_MASTER_L4PROTO, n, NTA_MASTER_L4PROTO); + if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_PORT)) { + __build_group(ct, ATTR_GRP_MASTER_PORT, + n, NTA_MASTER_PORT, + sizeof(struct nfct_attr_grp_port)); + } + } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_IPV6)) { + __build_group(ct, ATTR_GRP_MASTER_IPV6, n, NTA_MASTER_IPV6, + sizeof(struct nfct_attr_grp_ipv6)); + __build_u8(ct, ATTR_MASTER_L4PROTO, n, NTA_MASTER_L4PROTO); + if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_PORT)) { + __build_group(ct, ATTR_GRP_MASTER_PORT, + n, NTA_MASTER_PORT, + sizeof(struct nfct_attr_grp_port)); + } + } + + /* NAT */ + if (nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT)) + __build_u32(ct, ATTR_REPL_IPV4_DST, n, NTA_SNAT_IPV4); + if (nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT)) + __build_u32(ct, ATTR_REPL_IPV4_SRC, n, NTA_DNAT_IPV4); + if (nfct_getobjopt(ct, NFCT_GOPT_IS_SPAT)) + __build_u16(ct, ATTR_REPL_PORT_DST, n, NTA_SPAT_PORT); + if (nfct_getobjopt(ct, NFCT_GOPT_IS_DPAT)) + __build_u16(ct, ATTR_REPL_PORT_SRC, n, NTA_DPAT_PORT); + + /* NAT sequence adjustment */ + if (nfct_attr_is_set_array(ct, nat_type, 6)) + __build_natseqadj(ct, n); +} diff --git a/src/cache.c b/src/cache.c new file mode 100644 index 0000000..74c5c4b --- /dev/null +++ b/src/cache.c @@ -0,0 +1,434 @@ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "cache.h" +#include "jhash.h" +#include "hash.h" +#include "log.h" +#include "conntrackd.h" + +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +static uint32_t +__hash4(const struct nf_conntrack *ct, const struct hashtable *table) +{ + uint32_t a[4] = { + [0] = nfct_get_attr_u32(ct, ATTR_IPV4_SRC), + [1] = nfct_get_attr_u32(ct, ATTR_IPV4_DST), + [2] = nfct_get_attr_u8(ct, ATTR_L3PROTO) << 16 | + nfct_get_attr_u8(ct, ATTR_L4PROTO), + [3] = nfct_get_attr_u16(ct, ATTR_PORT_SRC) << 16 | + nfct_get_attr_u16(ct, ATTR_PORT_DST), + }; + + /* + * Instead of returning hash % table->hashsize (implying a divide) + * we return the high 32 bits of the (hash * table->hashsize) that will + * give results between [0 and hashsize-1] and same hash distribution, + * but using a multiply, less expensive than a divide. See: + * http://www.mail-archive.com/netdev@vger.kernel.org/msg56623.html + */ + return ((uint64_t)jhash2(a, 4, 0) * table->hashsize) >> 32; +} + +static uint32_t +__hash6(const struct nf_conntrack *ct, const struct hashtable *table) +{ + uint32_t a[10]; + + memcpy(&a[0], nfct_get_attr(ct, ATTR_IPV6_SRC), sizeof(uint32_t)*4); + memcpy(&a[4], nfct_get_attr(ct, ATTR_IPV6_SRC), sizeof(uint32_t)*4); + a[8] = nfct_get_attr_u8(ct, ATTR_ORIG_L3PROTO) << 16 | + nfct_get_attr_u8(ct, ATTR_ORIG_L4PROTO); + a[9] = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC) << 16 | + nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST); + + return ((uint64_t)jhash2(a, 10, 0) * table->hashsize) >> 32; +} + +static uint32_t hash(const void *data, const struct hashtable *table) +{ + int ret = 0; + const struct nf_conntrack *ct = data; + + switch(nfct_get_attr_u8(ct, ATTR_L3PROTO)) { + case AF_INET: + ret = __hash4(ct, table); + break; + case AF_INET6: + ret = __hash6(ct, table); + break; + default: + dlog(LOG_ERR, "unknown layer 3 proto in hash"); + break; + } + + return ret; +} + +static int compare(const void *data1, const void *data2) +{ + const struct cache_object *obj = data1; + const struct nf_conntrack *ct = data2; + + return nfct_cmp(obj->ct, ct, NFCT_CMP_ORIG) && + nfct_get_attr_u32(obj->ct, ATTR_ID) == + nfct_get_attr_u32(ct, ATTR_ID); +} + +struct cache_feature *cache_feature[CACHE_MAX_FEATURE] = { + [TIMER_FEATURE] = &timer_feature, +}; + +struct cache *cache_create(const char *name, + unsigned int features, + struct cache_extra *extra) +{ + size_t size = sizeof(struct cache_object); + int i, j = 0; + struct cache *c; + struct cache_feature *feature_array[CACHE_MAX_FEATURE] = {}; + unsigned int feature_offset[CACHE_MAX_FEATURE] = {}; + unsigned int feature_type[CACHE_MAX_FEATURE] = {}; + + c = malloc(sizeof(struct cache)); + if (!c) + return NULL; + memset(c, 0, sizeof(struct cache)); + + strcpy(c->name, name); + + for (i = 0; i < CACHE_MAX_FEATURE; i++) { + if ((1 << i) & features) { + feature_array[j] = cache_feature[i]; + feature_offset[j] = size; + feature_type[i] = j; + size += cache_feature[i]->size; + j++; + } + } + + memcpy(c->feature_type, feature_type, sizeof(feature_type)); + + c->features = malloc(sizeof(struct cache_feature) * j); + if (!c->features) { + free(c); + return NULL; + } + memcpy(c->features, feature_array, sizeof(struct cache_feature) * j); + c->num_features = j; + + c->extra_offset = size; + c->extra = extra; + if (extra) + size += extra->size; + + c->feature_offset = malloc(sizeof(unsigned int) * j); + if (!c->feature_offset) { + free(c->features); + free(c); + return NULL; + } + memcpy(c->feature_offset, feature_offset, sizeof(unsigned int) * j); + + c->h = hashtable_create(CONFIG(hashsize), + CONFIG(limit), + hash, + compare); + + if (!c->h) { + free(c->features); + free(c->feature_offset); + free(c); + return NULL; + } + c->object_size = size; + + return c; +} + +void cache_destroy(struct cache *c) +{ + cache_flush(c); + hashtable_destroy(c->h); + free(c->features); + free(c->feature_offset); + free(c); +} + +struct cache_object *cache_object_new(struct cache *c, struct nf_conntrack *ct) +{ + struct cache_object *obj; + + obj = calloc(c->object_size, 1); + if (obj == NULL) { + errno = ENOMEM; + c->stats.add_fail_enomem++; + return NULL; + } + obj->cache = c; + + if ((obj->ct = nfct_new()) == NULL) { + free(obj); + errno = ENOMEM; + c->stats.add_fail_enomem++; + return NULL; + } + memcpy(obj->ct, ct, nfct_sizeof(ct)); + obj->status = C_OBJ_NONE; + c->stats.objects++; + + return obj; +} + +void cache_object_free(struct cache_object *obj) +{ + obj->cache->stats.objects--; + nfct_destroy(obj->ct); + free(obj); +} + +int cache_object_put(struct cache_object *obj) +{ + if (--obj->refcnt == 0) { + cache_del(obj->cache, obj); + cache_object_free(obj); + return 1; + } + return 0; +} + +void cache_object_get(struct cache_object *obj) +{ + obj->refcnt++; +} + +void cache_object_set_status(struct cache_object *obj, int status) +{ + if (status == C_OBJ_DEAD) { + obj->cache->stats.del_ok++; + obj->cache->stats.active--; + } + obj->status = status; +} + +static int __add(struct cache *c, struct cache_object *obj, int id) +{ + int ret; + unsigned int i; + char *data = obj->data; + + ret = hashtable_add(c->h, &obj->hashnode, id); + if (ret == -1) + return -1; + + for (i = 0; i < c->num_features; i++) { + c->features[i]->add(obj, data); + data += c->features[i]->size; + } + + if (c->extra && c->extra->add) + c->extra->add(obj, ((char *) obj) + c->extra_offset); + + c->stats.active++; + obj->lifetime = obj->lastupdate = time_cached(); + obj->status = C_OBJ_NEW; + obj->refcnt++; + return 0; +} + +int cache_add(struct cache *c, struct cache_object *obj, int id) +{ + int ret; + + ret = __add(c, obj, id); + if (ret == -1) { + c->stats.add_fail++; + if (errno == ENOSPC) + c->stats.add_fail_enospc++; + return -1; + } + c->stats.add_ok++; + return 0; +} + +void cache_update(struct cache *c, struct cache_object *obj, int id, + struct nf_conntrack *ct) +{ + char *data = obj->data; + unsigned int i; + + nfct_copy(obj->ct, ct, NFCT_CP_META); + + for (i = 0; i < c->num_features; i++) { + c->features[i]->update(obj, data); + data += c->features[i]->size; + } + + if (c->extra && c->extra->update) + c->extra->update(obj, ((char *) obj) + c->extra_offset); + + c->stats.upd_ok++; + obj->lastupdate = time_cached(); + obj->status = C_OBJ_ALIVE; +} + +static void __del(struct cache *c, struct cache_object *obj) +{ + unsigned i; + char *data = obj->data; + + for (i = 0; i < c->num_features; i++) { + c->features[i]->destroy(obj, data); + data += c->features[i]->size; + } + + if (c->extra && c->extra->destroy) + c->extra->destroy(obj, ((char *) obj) + c->extra_offset); + + hashtable_del(c->h, &obj->hashnode); +} + +void cache_del(struct cache *c, struct cache_object *obj) +{ + /* + * Do not increase stats if we are trying to + * kill an entry was previously deleted via + * __cache_del_timer. + */ + if (obj->status != C_OBJ_DEAD) { + c->stats.del_ok++; + c->stats.active--; + } + __del(c, obj); +} + +struct cache_object * +cache_update_force(struct cache *c, struct nf_conntrack *ct) +{ + struct cache_object *obj; + int id; + + obj = cache_find(c, ct, &id); + if (obj) { + if (obj->status != C_OBJ_DEAD) { + cache_update(c, obj, id, ct); + return obj; + } else { + cache_del(c, obj); + cache_object_free(obj); + } + } + obj = cache_object_new(c, ct); + if (obj == NULL) + return NULL; + + if (cache_add(c, obj, id) == -1) { + cache_object_free(obj); + return NULL; + } + + return obj; +} + +struct cache_object * +cache_find(struct cache *c, struct nf_conntrack *ct, int *id) +{ + *id = hashtable_hash(c->h, ct); + return ((struct cache_object *) hashtable_find(c->h, ct, *id)); +} + +struct cache_object *cache_data_get_object(struct cache *c, void *data) +{ + return (struct cache_object *)((char*)data - c->extra_offset); +} + +void *cache_get_extra(struct cache *c, void *data) +{ + return (char*)data + c->extra_offset; +} + +void cache_stats(const struct cache *c, int fd) +{ + char buf[512]; + int size; + + size = sprintf(buf, "cache %s:\n" + "current active connections:\t%12u\n" + "connections created:\t\t%12u\tfailed:\t%12u\n" + "connections updated:\t\t%12u\tfailed:\t%12u\n" + "connections destroyed:\t\t%12u\tfailed:\t%12u\n\n", + c->name, + c->stats.active, + c->stats.add_ok, + c->stats.add_fail, + c->stats.upd_ok, + c->stats.upd_fail, + c->stats.del_ok, + c->stats.del_fail); + send(fd, buf, size, 0); +} + +void cache_stats_extended(const struct cache *c, int fd) +{ + char buf[512]; + int size; + + size = snprintf(buf, sizeof(buf), + "cache:%s\tactive objects:\t\t%12u\n" + "\tactive/total entries:\t\t%12u/%12u\n" + "\tcreation OK/failed:\t\t%12u/%12u\n" + "\t\tno memory available:\t%12u\n" + "\t\tno space left in cache:\t%12u\n" + "\tupdate OK/failed:\t\t%12u/%12u\n" + "\t\tentry not found:\t%12u\n" + "\tdeletion created/failed:\t%12u/%12u\n" + "\t\tentry not found:\t%12u\n\n", + c->name, c->stats.objects, + c->stats.active, hashtable_counter(c->h), + c->stats.add_ok, + c->stats.add_fail, + c->stats.add_fail_enomem, + c->stats.add_fail_enospc, + c->stats.upd_ok, + c->stats.upd_fail, + c->stats.upd_fail_enoent, + c->stats.del_ok, + c->stats.del_fail, + c->stats.del_fail_enoent); + + send(fd, buf, size, 0); +} + +void cache_iterate(struct cache *c, + void *data, + int (*iterate)(void *data1, void *data2)) +{ + hashtable_iterate(c->h, data, iterate); +} + +void cache_iterate_limit(struct cache *c, void *data, + uint32_t from, uint32_t steps, + int (*iterate)(void *data1, void *data2)) +{ + hashtable_iterate_limit(c->h, data, from, steps, iterate); +} diff --git a/src/cache_iterators.c b/src/cache_iterators.c new file mode 100644 index 0000000..c7183fd --- /dev/null +++ b/src/cache_iterators.c @@ -0,0 +1,261 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "cache.h" +#include "hash.h" +#include "log.h" +#include "conntrackd.h" +#include "netlink.h" +#include "event.h" + +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <sched.h> +#include <errno.h> +#include <string.h> +#include <time.h> + +struct __dump_container { + int fd; + int type; +}; + +static int do_dump(void *data1, void *n) +{ + char buf[1024]; + int size; + struct __dump_container *container = data1; + struct cache_object *obj = n; + char *data = obj->data; + unsigned i; + + /* + * XXX: Do not dump the entries that are scheduled to expire. + * These entries talk about already destroyed connections + * that we keep for some time just in case that we have to + * resent some lost messages. We do not show them to the + * user as he may think that the firewall replicas are not + * in sync. The branch below is a hack as it is quite + * specific and it breaks conntrackd modularity. Probably + * there's a nicer way to do this but until I come up with it... + */ + if (CONFIG(flags) & CTD_SYNC_FTFW && obj->status == C_OBJ_DEAD) + return 0; + + /* do not show cached timeout, this may confuse users */ + if (nfct_attr_is_set(obj->ct, ATTR_TIMEOUT)) + nfct_attr_unset(obj->ct, ATTR_TIMEOUT); + + memset(buf, 0, sizeof(buf)); + size = nfct_snprintf(buf, + sizeof(buf), + obj->ct, + NFCT_T_UNKNOWN, + container->type, + 0); + + for (i = 0; i < obj->cache->num_features; i++) { + if (obj->cache->features[i]->dump) { + size += obj->cache->features[i]->dump(obj, + data, + buf+size, + container->type); + data += obj->cache->features[i]->size; + } + } + if (container->type != NFCT_O_XML) { + long tm = time(NULL); + size += sprintf(buf+size, " [active since %lds]", + tm - obj->lifetime); + } + size += sprintf(buf+size, "\n"); + if (send(container->fd, buf, size, 0) == -1) { + if (errno != EPIPE) + return -1; + } + + return 0; +} + +void cache_dump(struct cache *c, int fd, int type) +{ + struct __dump_container tmp = { + .fd = fd, + .type = type + }; + + hashtable_iterate(c->h, (void *) &tmp, do_dump); +} + +struct __commit_container { + struct nfct_handle *h; + struct cache *c; +}; + +static void +__do_commit_step(struct __commit_container *tmp, struct cache_object *obj) +{ + int ret, retry = 1, timeout; + struct nf_conntrack *ct = obj->ct; + + if (CONFIG(commit_timeout)) { + timeout = CONFIG(commit_timeout); + } else { + timeout = time(NULL) - obj->lastupdate; + if (timeout < 0) { + /* XXX: Arbitrarily set the timer to one minute, how + * can this happen? For example, an adjustment due to + * daylight-saving. Probably other situations can + * trigger this. */ + timeout = 60; + } + /* calculate an estimation of the current timeout */ + timeout = nfct_get_attr_u32(ct, ATTR_TIMEOUT) - timeout; + if (timeout < 0) { + timeout = 60; + } + } + +retry: + if (nl_create_conntrack(tmp->h, ct, timeout) == -1) { + if (errno == EEXIST && retry == 1) { + ret = nl_destroy_conntrack(tmp->h, ct); + if (ret == 0 || (ret == -1 && errno == ENOENT)) { + if (retry) { + retry = 0; + goto retry; + } + } + dlog(LOG_ERR, "commit-destroy: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + tmp->c->stats.commit_fail++; + } else { + dlog(LOG_ERR, "commit-create: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + tmp->c->stats.commit_fail++; + } + } else { + tmp->c->stats.commit_ok++; + } +} + +static int do_commit_related(void *data, void *n) +{ + struct cache_object *obj = n; + + if (ct_is_related(obj->ct)) + __do_commit_step(data, obj); + + /* keep iterating even if we have found errors */ + return 0; +} + +static int do_commit_master(void *data, void *n) +{ + struct cache_object *obj = n; + + if (ct_is_related(obj->ct)) + return 0; + + __do_commit_step(data, obj); + return 0; +} + +void cache_commit(struct cache *c, struct nfct_handle *h, int clientfd) +{ + unsigned int commit_ok, commit_fail; + struct __commit_container tmp = { + .h = h, + .c = c, + }; + struct timeval commit_stop, res; + + switch(STATE_SYNC(commit).state) { + case COMMIT_STATE_INACTIVE: + gettimeofday(&STATE_SYNC(commit).stats.start, NULL); + STATE_SYNC(commit).stats.ok = c->stats.commit_ok; + STATE_SYNC(commit).stats.fail = c->stats.commit_fail; + STATE_SYNC(commit).clientfd = clientfd; + case COMMIT_STATE_MASTER: + STATE_SYNC(commit).current = + hashtable_iterate_limit(c->h, &tmp, + STATE_SYNC(commit).current, + CONFIG(general).commit_steps, + do_commit_master); + if (STATE_SYNC(commit).current < CONFIG(hashsize)) { + STATE_SYNC(commit).state = COMMIT_STATE_MASTER; + /* give it another step as soon as possible */ + write_evfd(STATE_SYNC(commit).evfd); + return; + } + STATE_SYNC(commit).current = 0; + STATE_SYNC(commit).state = COMMIT_STATE_RELATED; + case COMMIT_STATE_RELATED: + STATE_SYNC(commit).current = + hashtable_iterate_limit(c->h, &tmp, + STATE_SYNC(commit).current, + CONFIG(general).commit_steps, + do_commit_related); + if (STATE_SYNC(commit).current < CONFIG(hashsize)) { + STATE_SYNC(commit).state = COMMIT_STATE_RELATED; + /* give it another step as soon as possible */ + write_evfd(STATE_SYNC(commit).evfd); + return; + } + /* calculate the time that commit has taken */ + gettimeofday(&commit_stop, NULL); + timersub(&commit_stop, &STATE_SYNC(commit).stats.start, &res); + + /* calculate new entries committed */ + commit_ok = c->stats.commit_ok - STATE_SYNC(commit).stats.ok; + commit_fail = + c->stats.commit_fail - STATE_SYNC(commit).stats.fail; + + /* log results */ + dlog(LOG_NOTICE, "Committed %u new entries", commit_ok); + + if (commit_fail) + dlog(LOG_NOTICE, "%u entries can't be " + "committed", commit_fail); + + dlog(LOG_NOTICE, "commit has taken %lu.%06lu seconds", + res.tv_sec, res.tv_usec); + + /* prepare the state machine for new commits */ + STATE_SYNC(commit).current = 0; + STATE_SYNC(commit).state = COMMIT_STATE_INACTIVE; + + /* Close the client socket now that we're done. */ + close(STATE_SYNC(commit).clientfd); + } +} + +static int do_flush(void *data, void *n) +{ + struct cache *c = data; + struct cache_object *obj = n; + + cache_del(c, obj); + cache_object_free(obj); + return 0; +} + +void cache_flush(struct cache *c) +{ + hashtable_iterate(c->h, c, do_flush); + c->stats.flush++; +} diff --git a/src/cache_timer.c b/src/cache_timer.c new file mode 100644 index 0000000..5881236 --- /dev/null +++ b/src/cache_timer.c @@ -0,0 +1,75 @@ +/* + * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "cache.h" +#include "conntrackd.h" +#include "alarm.h" + +#include <stdio.h> + +static void timeout(struct alarm_block *a, void *data) +{ + struct cache_object *obj = data; + + cache_del(obj->cache, obj); + cache_object_free(obj); +} + +static void timer_add(struct cache_object *obj, void *data) +{ + struct alarm_block *a = data; + + init_alarm(a, obj, timeout); + add_alarm(a, CONFIG(cache_timeout), 0); +} + +static void timer_update(struct cache_object *obj, void *data) +{ + struct alarm_block *a = data; + add_alarm(a, CONFIG(cache_timeout), 0); +} + +static void timer_destroy(struct cache_object *obj, void *data) +{ + struct alarm_block *a = data; + del_alarm(a); +} + +static int timer_dump(struct cache_object *obj, void *data, char *buf, int type) +{ + struct timeval tv, tmp; + struct alarm_block *a = data; + + if (type == NFCT_O_XML) + return 0; + + if (!alarm_pending(a)) + return 0; + + gettimeofday(&tv, NULL); + timersub(&a->tv, &tv, &tmp); + return sprintf(buf, " [expires in %lds]", tmp.tv_sec); +} + +struct cache_feature timer_feature = { + .size = sizeof(struct alarm_block), + .add = timer_add, + .update = timer_update, + .destroy = timer_destroy, + .dump = timer_dump +}; diff --git a/src/channel.c b/src/channel.c new file mode 100644 index 0000000..818bb01 --- /dev/null +++ b/src/channel.c @@ -0,0 +1,312 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <stdlib.h> +#include <unistd.h> +#include <net/if.h> +#include <string.h> +#include <sys/ioctl.h> +#include <netinet/in.h> +#include <errno.h> + +#include "conntrackd.h" +#include "channel.h" +#include "network.h" +#include "queue.h" + +static struct channel_ops *ops[CHANNEL_MAX]; +extern struct channel_ops channel_mcast; +extern struct channel_ops channel_udp; +extern struct channel_ops channel_tcp; + +static struct queue *errorq; + +int channel_init(void) +{ + ops[CHANNEL_MCAST] = &channel_mcast; + ops[CHANNEL_UDP] = &channel_udp; + ops[CHANNEL_TCP] = &channel_tcp; + + errorq = queue_create("errorq", CONFIG(channelc).error_queue_length, 0); + if (errorq == NULL) { + return -1; + } + return 0; +} + +void channel_end(void) +{ + queue_destroy(errorq); +} + +struct channel_buffer { + char *data; + int size; + int len; +}; + +static struct channel_buffer * +channel_buffer_open(int mtu, int headersiz) +{ + struct channel_buffer *b; + + b = calloc(sizeof(struct channel_buffer), 1); + if (b == NULL) + return NULL; + + b->size = mtu - headersiz; + + b->data = malloc(b->size); + if (b->data == NULL) { + free(b); + return NULL; + } + return b; +} + +static void +channel_buffer_close(struct channel_buffer *b) +{ + if (b == NULL) + return; + + free(b->data); + free(b); +} + +struct channel * +channel_open(struct channel_conf *cfg) +{ + struct channel *c; + struct ifreq ifr; + int fd; + + if (cfg->channel_type >= CHANNEL_MAX) + return NULL; + if (!cfg->channel_ifname[0]) + return NULL; + if (cfg->channel_flags >= CHANNEL_F_MAX) + return NULL; + + c = calloc(sizeof(struct channel), 1); + if (c == NULL) + return NULL; + + c->channel_type = cfg->channel_type; + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd == -1) { + free(c); + return NULL; + } + strncpy(ifr.ifr_name, cfg->channel_ifname, sizeof(ifr.ifr_name)); + + if (ioctl(fd, SIOCGIFMTU, &ifr) == -1) { + free(c); + return NULL; + } + close(fd); + c->channel_ifmtu = ifr.ifr_mtu; + + c->channel_ifindex = if_nametoindex(cfg->channel_ifname); + if (c->channel_ifindex == 0) { + free(c); + return NULL; + } + c->ops = ops[cfg->channel_type]; + + if (cfg->channel_flags & CHANNEL_F_BUFFERED) { + c->buffer = channel_buffer_open(c->channel_ifmtu, + c->ops->headersiz); + if (c->buffer == NULL) { + free(c); + return NULL; + } + } + c->channel_flags = cfg->channel_flags; + + c->data = c->ops->open(&cfg->u); + if (c->data == NULL) { + channel_buffer_close(c->buffer); + free(c); + return NULL; + } + return c; +} + +void +channel_close(struct channel *c) +{ + c->ops->close(c->data); + if (c->channel_flags & CHANNEL_F_BUFFERED) + channel_buffer_close(c->buffer); + free(c); +} + +struct channel_error { + char *data; + int len; +}; + +static void channel_enqueue_errors(struct channel *c) +{ + struct queue_object *qobj; + struct channel_error *error; + + qobj = queue_object_new(Q_ELEM_ERR, sizeof(struct channel_error)); + if (qobj == NULL) + return; + + error = (struct channel_error *)qobj->data; + error->len = c->buffer->len; + + error->data = malloc(c->buffer->len); + if (error->data == NULL) { + queue_object_free(qobj); + return; + } + memcpy(error->data, c->buffer->data, c->buffer->len); + if (queue_add(errorq, &qobj->qnode) < 0) { + if (errno == ENOSPC) { + struct queue_node *tail; + struct channel_error *tmp; + + tail = queue_del_head(errorq); + tmp = queue_node_data(tail); + free(tmp->data); + queue_object_free((struct queue_object *)tail); + + queue_add(errorq, &qobj->qnode); + } + } +} + +static int channel_handle_error_step(struct queue_node *n, const void *data2) +{ + struct channel_error *error; + const struct channel *c = data2; + int ret; + + error = queue_node_data(n); + ret = c->ops->send(c->data, error->data, error->len); + if (ret != -1) { + /* Success. Delete it from the error queue. */ + queue_del(n); + free(error->data); + queue_object_free((struct queue_object *)n); + } else { + /* We failed to deliver, give up now, try later. */ + return 1; + } + return 0; +} + +static int channel_handle_errors(struct channel *c) +{ + /* there are pending errors that we have to handle. */ + if (c->channel_flags & CHANNEL_F_ERRORS && queue_len(errorq) > 0) { + queue_iterate(errorq, c, channel_handle_error_step); + return queue_len(errorq) > 0; + } + return 0; +} + +int channel_send(struct channel *c, const struct nethdr *net) +{ + int ret = 0, len = ntohs(net->len), pending_errors; + + pending_errors = channel_handle_errors(c); + + if (!(c->channel_flags & CHANNEL_F_BUFFERED)) { + c->ops->send(c->data, net, len); + return 1; + } +retry: + if (c->buffer->len + len < c->buffer->size) { + memcpy(c->buffer->data + c->buffer->len, net, len); + c->buffer->len += len; + } else { + /* We've got pending packets to deliver, enqueue this + * packet to avoid possible re-ordering. */ + if (pending_errors) { + channel_enqueue_errors(c); + } else { + ret = c->ops->send(c->data, c->buffer->data, + c->buffer->len); + if (ret == -1 && + (c->channel_flags & CHANNEL_F_ERRORS)) { + /* Give it another chance to deliver. */ + channel_enqueue_errors(c); + } + } + ret = 1; + c->buffer->len = 0; + goto retry; + } + return ret; +} + +int channel_send_flush(struct channel *c) +{ + int ret, pending_errors; + + pending_errors = channel_handle_errors(c); + + if (!(c->channel_flags & CHANNEL_F_BUFFERED) || c->buffer->len == 0) + return 0; + + /* We still have pending errors to deliver, avoid any re-ordering. */ + if (pending_errors) { + channel_enqueue_errors(c); + } else { + ret = c->ops->send(c->data, c->buffer->data, c->buffer->len); + if (ret == -1 && (c->channel_flags & CHANNEL_F_ERRORS)) { + /* Give it another chance to deliver it. */ + channel_enqueue_errors(c); + } + } + c->buffer->len = 0; + return 1; +} + +int channel_recv(struct channel *c, char *buf, int size) +{ + return c->ops->recv(c->data, buf, size); +} + +int channel_get_fd(struct channel *c) +{ + return c->ops->get_fd(c->data); +} + +void channel_stats(struct channel *c, int fd) +{ + return c->ops->stats(c, fd); +} + +void channel_stats_extended(struct channel *c, int active, + struct nlif_handle *h, int fd) +{ + return c->ops->stats_extended(c, active, h, fd); +} + +int channel_accept_isset(struct channel *c, fd_set *readfds) +{ + return c->ops->accept_isset(c, readfds); +} + +int channel_isset(struct channel *c, fd_set *readfds) +{ + return c->ops->isset(c, readfds); +} + +int channel_accept(struct channel *c) +{ + return c->ops->accept(c); +} diff --git a/src/channel_mcast.c b/src/channel_mcast.c new file mode 100644 index 0000000..35801d7 --- /dev/null +++ b/src/channel_mcast.c @@ -0,0 +1,139 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <stdlib.h> +#include <libnfnetlink/libnfnetlink.h> + +#include "channel.h" +#include "mcast.h" + +static void +*channel_mcast_open(void *conf) +{ + struct mcast_channel *m; + struct mcast_conf *c = conf; + + m = calloc(sizeof(struct mcast_channel), 1); + if (m == NULL) + return NULL; + + m->client = mcast_client_create(c); + if (m->client == NULL) { + free(m); + return NULL; + } + + m->server = mcast_server_create(c); + if (m->server == NULL) { + mcast_client_destroy(m->client); + free(m); + return NULL; + } + return m; +} + +static int +channel_mcast_send(void *channel, const void *data, int len) +{ + struct mcast_channel *m = channel; + return mcast_send(m->client, data, len); +} + +static int +channel_mcast_recv(void *channel, char *buf, int size) +{ + struct mcast_channel *m = channel; + return mcast_recv(m->server, buf, size); +} + +static void +channel_mcast_close(void *channel) +{ + struct mcast_channel *m = channel; + mcast_client_destroy(m->client); + mcast_server_destroy(m->server); + free(m); +} + +static int +channel_mcast_get_fd(void *channel) +{ + struct mcast_channel *m = channel; + return mcast_get_fd(m->server); +} + +static void +channel_mcast_stats(struct channel *c, int fd) +{ + struct mcast_channel *m = c->data; + char ifname[IFNAMSIZ], buf[512]; + int size; + + if_indextoname(c->channel_ifindex, ifname); + size = mcast_snprintf_stats(buf, sizeof(buf), ifname, + &m->client->stats, &m->server->stats); + send(fd, buf, size, 0); +} + +static void +channel_mcast_stats_extended(struct channel *c, int active, + struct nlif_handle *h, int fd) +{ + struct mcast_channel *m = c->data; + char ifname[IFNAMSIZ], buf[512]; + const char *status; + unsigned int flags; + int size; + + if_indextoname(c->channel_ifindex, ifname); + nlif_get_ifflags(h, c->channel_ifindex, &flags); + /* + * IFF_UP shows administrative status + * IFF_RUNNING shows carrier status + */ + if (flags & IFF_UP) { + if (!(flags & IFF_RUNNING)) + status = "NO-CARRIER"; + else + status = "RUNNING"; + } else { + status = "DOWN"; + } + size = mcast_snprintf_stats2(buf, sizeof(buf), + ifname, status, active, + &m->client->stats, + &m->server->stats); + send(fd, buf, size, 0); +} + +static int +channel_mcast_isset(struct channel *c, fd_set *readfds) +{ + struct mcast_channel *m = c->data; + return mcast_isset(m->server, readfds); +} + +static int +channel_mcast_accept_isset(struct channel *c, fd_set *readfds) +{ + return 0; +} + +struct channel_ops channel_mcast = { + .headersiz = 28, /* IP header (20 bytes) + UDP header 8 (bytes) */ + .open = channel_mcast_open, + .close = channel_mcast_close, + .send = channel_mcast_send, + .recv = channel_mcast_recv, + .get_fd = channel_mcast_get_fd, + .isset = channel_mcast_isset, + .accept_isset = channel_mcast_accept_isset, + .stats = channel_mcast_stats, + .stats_extended = channel_mcast_stats_extended, +}; diff --git a/src/channel_tcp.c b/src/channel_tcp.c new file mode 100644 index 0000000..f132840 --- /dev/null +++ b/src/channel_tcp.c @@ -0,0 +1,150 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * TCP support has been sponsored by 6WIND <www.6wind.com>. + */ + +#include <stdlib.h> +#include <libnfnetlink/libnfnetlink.h> + +#include "channel.h" +#include "tcp.h" + +static void +*channel_tcp_open(void *conf) +{ + struct tcp_channel *m; + struct tcp_conf *c = conf; + + m = calloc(sizeof(struct tcp_channel), 1); + if (m == NULL) + return NULL; + + m->client = tcp_client_create(c); + if (m->client == NULL) { + free(m); + return NULL; + } + + m->server = tcp_server_create(c); + if (m->server == NULL) { + tcp_client_destroy(m->client); + free(m); + return NULL; + } + return m; +} + +static int +channel_tcp_send(void *channel, const void *data, int len) +{ + struct tcp_channel *m = channel; + return tcp_send(m->client, data, len); +} + +static int +channel_tcp_recv(void *channel, char *buf, int size) +{ + struct tcp_channel *m = channel; + return tcp_recv(m->server, buf, size); +} + +static void +channel_tcp_close(void *channel) +{ + struct tcp_channel *m = channel; + tcp_client_destroy(m->client); + tcp_server_destroy(m->server); + free(m); +} + +static int +channel_tcp_get_fd(void *channel) +{ + struct tcp_channel *m = channel; + return tcp_get_fd(m->server); +} + +static void +channel_tcp_stats(struct channel *c, int fd) +{ + struct tcp_channel *m = c->data; + char ifname[IFNAMSIZ], buf[512]; + int size; + + if_indextoname(c->channel_ifindex, ifname); + size = tcp_snprintf_stats(buf, sizeof(buf), ifname, + m->client, m->server); + send(fd, buf, size, 0); +} + +static void +channel_tcp_stats_extended(struct channel *c, int active, + struct nlif_handle *h, int fd) +{ + struct tcp_channel *m = c->data; + char ifname[IFNAMSIZ], buf[512]; + const char *status; + unsigned int flags; + int size; + + if_indextoname(c->channel_ifindex, ifname); + nlif_get_ifflags(h, c->channel_ifindex, &flags); + /* + * IFF_UP shows administrative status + * IFF_RUNNING shows carrier status + */ + if (flags & IFF_UP) { + if (!(flags & IFF_RUNNING)) + status = "NO-CARRIER"; + else + status = "RUNNING"; + } else { + status = "DOWN"; + } + size = tcp_snprintf_stats2(buf, sizeof(buf), + ifname, status, active, + &m->client->stats, + &m->server->stats); + send(fd, buf, size, 0); +} + +static int +channel_tcp_isset(struct channel *c, fd_set *readfds) +{ + struct tcp_channel *m = c->data; + return tcp_isset(m->server, readfds); +} + +static int +channel_tcp_accept_isset(struct channel *c, fd_set *readfds) +{ + struct tcp_channel *m = c->data; + return tcp_accept_isset(m->server, readfds); +} + +static int +channel_tcp_accept(struct channel *c) +{ + struct tcp_channel *m = c->data; + return tcp_accept(m->server); +} + +struct channel_ops channel_tcp = { + .headersiz = 40, /* IP header (20 bytes) + TCP header 20 (bytes) */ + .open = channel_tcp_open, + .close = channel_tcp_close, + .send = channel_tcp_send, + .recv = channel_tcp_recv, + .accept = channel_tcp_accept, + .get_fd = channel_tcp_get_fd, + .isset = channel_tcp_isset, + .accept_isset = channel_tcp_accept_isset, + .stats = channel_tcp_stats, + .stats_extended = channel_tcp_stats_extended, +}; diff --git a/src/channel_udp.c b/src/channel_udp.c new file mode 100644 index 0000000..a46a2b1 --- /dev/null +++ b/src/channel_udp.c @@ -0,0 +1,139 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <stdlib.h> +#include <libnfnetlink/libnfnetlink.h> + +#include "channel.h" +#include "udp.h" + +static void +*channel_udp_open(void *conf) +{ + struct udp_channel *m; + struct udp_conf *c = conf; + + m = calloc(sizeof(struct udp_channel), 1); + if (m == NULL) + return NULL; + + m->client = udp_client_create(c); + if (m->client == NULL) { + free(m); + return NULL; + } + + m->server = udp_server_create(c); + if (m->server == NULL) { + udp_client_destroy(m->client); + free(m); + return NULL; + } + return m; +} + +static int +channel_udp_send(void *channel, const void *data, int len) +{ + struct udp_channel *m = channel; + return udp_send(m->client, data, len); +} + +static int +channel_udp_recv(void *channel, char *buf, int size) +{ + struct udp_channel *m = channel; + return udp_recv(m->server, buf, size); +} + +static void +channel_udp_close(void *channel) +{ + struct udp_channel *m = channel; + udp_client_destroy(m->client); + udp_server_destroy(m->server); + free(m); +} + +static int +channel_udp_get_fd(void *channel) +{ + struct udp_channel *m = channel; + return udp_get_fd(m->server); +} + +static void +channel_udp_stats(struct channel *c, int fd) +{ + struct udp_channel *m = c->data; + char ifname[IFNAMSIZ], buf[512]; + int size; + + if_indextoname(c->channel_ifindex, ifname); + size = udp_snprintf_stats(buf, sizeof(buf), ifname, + &m->client->stats, &m->server->stats); + send(fd, buf, size, 0); +} + +static void +channel_udp_stats_extended(struct channel *c, int active, + struct nlif_handle *h, int fd) +{ + struct udp_channel *m = c->data; + char ifname[IFNAMSIZ], buf[512]; + const char *status; + unsigned int flags; + int size; + + if_indextoname(c->channel_ifindex, ifname); + nlif_get_ifflags(h, c->channel_ifindex, &flags); + /* + * IFF_UP shows administrative status + * IFF_RUNNING shows carrier status + */ + if (flags & IFF_UP) { + if (!(flags & IFF_RUNNING)) + status = "NO-CARRIER"; + else + status = "RUNNING"; + } else { + status = "DOWN"; + } + size = udp_snprintf_stats2(buf, sizeof(buf), + ifname, status, active, + &m->client->stats, + &m->server->stats); + send(fd, buf, size, 0); +} + +static int +channel_udp_isset(struct channel *c, fd_set *readfds) +{ + struct udp_channel *m = c->data; + return udp_isset(m->server, readfds); +} + +static int +channel_udp_accept_isset(struct channel *c, fd_set *readfds) +{ + return 0; +} + +struct channel_ops channel_udp = { + .headersiz = 28, /* IP header (20 bytes) + UDP header 8 (bytes) */ + .open = channel_udp_open, + .close = channel_udp_close, + .send = channel_udp_send, + .recv = channel_udp_recv, + .get_fd = channel_udp_get_fd, + .isset = channel_udp_isset, + .accept_isset = channel_udp_accept_isset, + .stats = channel_udp_stats, + .stats_extended = channel_udp_stats_extended, +}; diff --git a/src/cidr.c b/src/cidr.c new file mode 100644 index 0000000..91025b6 --- /dev/null +++ b/src/cidr.c @@ -0,0 +1,70 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdint.h> +#include <string.h> +#include <netinet/in.h> +#include "cidr.h" + +/* returns the netmask in host byte order */ +uint32_t ipv4_cidr2mask_host(uint8_t cidr) +{ + return 0xFFFFFFFF << (32 - cidr); +} + +/* returns the netmask in network byte order */ +uint32_t ipv4_cidr2mask_net(uint8_t cidr) +{ + return htonl(ipv4_cidr2mask_host(cidr)); +} + +void ipv6_cidr2mask_host(uint8_t cidr, uint32_t *res) +{ + int i, j; + + memset(res, 0, sizeof(uint32_t)*4); + for (i = 0; i < 4 && cidr > 32; i++) { + res[i] = 0xFFFFFFFF; + cidr -= 32; + } + res[i] = 0xFFFFFFFF << (32 - cidr); + for (j = i+1; j < 4; j++) { + res[j] = 0; + } +} + +void ipv6_cidr2mask_net(uint8_t cidr, uint32_t *res) +{ + int i; + + ipv6_cidr2mask_host(cidr, res); + for (i=0; i<4; i++) + res[i] = htonl(res[i]); +} + +/* I need this function because I initially defined an IPv6 address as + * uint32 u[4]. Using char u[16] instead would allow to remove this. */ +void ipv6_addr2addr_host(uint32_t *addr, uint32_t *res) +{ + int i; + + memset(res, 0, sizeof(uint32_t)*4); + for (i = 0; i < 4; i++) { + res[i] = ntohl(addr[i]); + } +} diff --git a/src/conntrack.c b/src/conntrack.c new file mode 100644 index 0000000..eec3868 --- /dev/null +++ b/src/conntrack.c @@ -0,0 +1,1504 @@ +/* + * (C) 2005-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Note: + * Yes, portions of this code has been stolen from iptables ;) + * Special thanks to the the Netfilter Core Team. + * Thanks to Javier de Miguel Rodriguez <jmiguel at talika.eii.us.es> + * for introducing me to advanced firewalling stuff. + * + * --pablo 13/04/2005 + * + * 2005-04-16 Harald Welte <laforge@netfilter.org>: + * Add support for conntrack accounting and conntrack mark + * 2005-06-23 Harald Welte <laforge@netfilter.org>: + * Add support for expect creation + * 2005-09-24 Harald Welte <laforge@netfilter.org>: + * Remove remaints of "-A" + * 2007-04-22 Pablo Neira Ayuso <pablo@netfilter.org>: + * Ported to the new libnetfilter_conntrack API + * 2008-04-13 Pablo Neira Ayuso <pablo@netfilter.org>: + * Way more flexible update and delete operations + */ + +#include "conntrack.h" + +#include <stdio.h> +#include <getopt.h> +#include <stdlib.h> +#include <stdarg.h> +#include <errno.h> +#include <unistd.h> +#include <netinet/in.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <time.h> +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#include <signal.h> +#include <string.h> +#include <netdb.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> + +static const char *optflags[NUMBER_OF_OPT] = { +"src","dst","reply-src","reply-dst","protonum","timeout","status","zero", +"event-mask","tuple-src","tuple-dst","mask-src","mask-dst","nat-range","mark", +"id","family","src-nat","dst-nat","output","secmark","buffersize"}; + +static struct option original_opts[] = { + {"dump", 2, 0, 'L'}, + {"create", 2, 0, 'I'}, + {"delete", 2, 0, 'D'}, + {"update", 2, 0, 'U'}, + {"get", 2, 0, 'G'}, + {"flush", 2, 0, 'F'}, + {"event", 2, 0, 'E'}, + {"counter", 2, 0, 'C'}, + {"stats", 0, 0, 'S'}, + {"version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {"orig-src", 1, 0, 's'}, + {"src", 1, 0, 's'}, + {"orig-dst", 1, 0, 'd'}, + {"dst", 1, 0, 'd'}, + {"reply-src", 1, 0, 'r'}, + {"reply-dst", 1, 0, 'q'}, + {"protonum", 1, 0, 'p'}, + {"timeout", 1, 0, 't'}, + {"status", 1, 0, 'u'}, + {"zero", 0, 0, 'z'}, + {"event-mask", 1, 0, 'e'}, + {"tuple-src", 1, 0, '['}, + {"tuple-dst", 1, 0, ']'}, + {"mask-src", 1, 0, '{'}, + {"mask-dst", 1, 0, '}'}, + {"nat-range", 1, 0, 'a'}, /* deprecated */ + {"mark", 1, 0, 'm'}, + {"secmark", 1, 0, 'c'}, + {"id", 2, 0, 'i'}, /* deprecated */ + {"family", 1, 0, 'f'}, + {"src-nat", 2, 0, 'n'}, + {"dst-nat", 2, 0, 'g'}, + {"output", 1, 0, 'o'}, + {"buffer-size", 1, 0, 'b'}, + {0, 0, 0, 0} +}; + +#define OPTION_OFFSET 256 + +static struct nfct_handle *cth, *ith; +static struct option *opts = original_opts; +static unsigned int global_option_offset = 0; + +/* Table of legal combinations of commands and options. If any of the + * given commands make an option legal, that option is legal (applies to + * CMD_LIST and CMD_ZERO only). + * Key: + * 0 illegal + * 1 compulsory + * 2 optional + * 3 undecided, see flag combination checkings in generic_opt_check() + */ + +static char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] = +/* Well, it's better than "Re: Linux vs FreeBSD" */ +{ + /* s d r q p t u z e [ ] { } a m i f n g o c b*/ +/*CT_LIST*/ {2,2,2,2,2,0,2,2,0,0,0,0,0,0,2,0,2,2,2,2,2,0}, +/*CT_CREATE*/ {3,3,3,3,1,1,2,0,0,0,0,0,0,2,2,0,0,2,2,0,0,0}, +/*CT_UPDATE*/ {2,2,2,2,2,2,2,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0}, +/*CT_DELETE*/ {2,2,2,2,2,2,2,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0}, +/*CT_GET*/ {3,3,3,3,1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,0}, +/*CT_FLUSH*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*CT_EVENT*/ {2,2,2,2,2,0,0,0,2,0,0,0,0,0,2,0,0,2,2,2,2,2}, +/*VERSION*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*HELP*/ {0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*EXP_LIST*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0}, +/*EXP_CREATE*/{1,1,2,2,1,1,2,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0}, +/*EXP_DELETE*/{1,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*EXP_GET*/ {1,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*EXP_FLUSH*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*EXP_EVENT*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*CT_COUNT*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*EXP_COUNT*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +/*X_STATS*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +}; + +#define ADDR_VALID_FLAGS_MAX 2 +static unsigned int addr_valid_flags[ADDR_VALID_FLAGS_MAX] = { + CT_OPT_ORIG_SRC | CT_OPT_ORIG_DST, + CT_OPT_REPL_SRC | CT_OPT_REPL_DST, +}; + +static LIST_HEAD(proto_list); + +static unsigned int options; + +#define CT_COMPARISON (CT_OPT_PROTO | CT_OPT_ORIG | CT_OPT_REPL | CT_OPT_MARK |\ + CT_OPT_SECMARK | CT_OPT_STATUS | CT_OPT_ID) + +void register_proto(struct ctproto_handler *h) +{ + if (strcmp(h->version, VERSION) != 0) { + fprintf(stderr, "plugin `%s': version %s (I'm %s)\n", + h->name, h->version, VERSION); + exit(1); + } + list_add(&h->head, &proto_list); +} + +extern struct ctproto_handler ct_proto_unknown; + +static struct ctproto_handler *findproto(char *name, int *pnum) +{ + struct ctproto_handler *cur; + struct protoent *pent; + int protonum; + + /* is it in the list of supported protocol? */ + list_for_each_entry(cur, &proto_list, head) { + if (strcmp(cur->name, name) == 0) { + *pnum = cur->protonum; + return cur; + } + } + /* using the protocol name for an unsupported protocol? */ + if ((pent = getprotobyname(name))) { + *pnum = pent->p_proto; + return &ct_proto_unknown; + } + /* using a protocol number? */ + protonum = atoi(name); + if (protonum > 0 && protonum <= IPPROTO_MAX) { + /* try lookup by number, perhaps this protocol is supported */ + list_for_each_entry(cur, &proto_list, head) { + if (cur->protonum == protonum) { + *pnum = protonum; + return cur; + } + } + *pnum = protonum; + return &ct_proto_unknown; + } + + return NULL; +} + +static void +extension_help(struct ctproto_handler *h, int protonum) +{ + const char *name; + + if (h == &ct_proto_unknown) { + struct protoent *pent; + + pent = getprotobynumber(protonum); + if (!pent) + name = h->name; + else + name = pent->p_name; + } else { + name = h->name; + } + + fprintf(stdout, "Proto `%s' help:\n", name); + h->help(); +} + +static void __attribute__((noreturn)) +exit_tryhelp(int status) +{ + fprintf(stderr, "Try `%s -h' or '%s --help' for more information.\n", + PROGNAME, PROGNAME); + exit(status); +} + +static void free_options(void) +{ + if (opts != original_opts) { + free(opts); + opts = original_opts; + global_option_offset = 0; + } +} + +void __attribute__((noreturn)) +exit_error(enum exittype status, const char *msg, ...) +{ + va_list args; + + free_options(); + va_start(args, msg); + fprintf(stderr,"%s v%s (conntrack-tools): ", PROGNAME, VERSION); + vfprintf(stderr, msg, args); + fprintf(stderr, "\n"); + va_end(args); + if (status == PARAMETER_PROBLEM) + exit_tryhelp(status); + exit(status); +} + +static int bit2cmd(int command) +{ + int i; + + for (i = 0; i < NUMBER_OF_CMD; i++) + if (command & (1<<i)) + break; + + return i; +} + +int generic_opt_check(int local_options, int num_opts, + char *optset, const char *optflg[], + unsigned int *coupled_flags, int coupled_flags_size, + int *partial) +{ + int i, matching = -1, special_case = 0; + + for (i = 0; i < num_opts; i++) { + if (!(local_options & (1<<i))) { + if (optset[i] == 1) + exit_error(PARAMETER_PROBLEM, + "You need to supply the " + "`--%s' option for this " + "command", optflg[i]); + } else { + if (optset[i] == 0) + exit_error(PARAMETER_PROBLEM, "Illegal " + "option `--%s' with this " + "command", optflg[i]); + } + if (optset[i] == 3) + special_case = 1; + } + + /* no weird flags combinations, leave */ + if (!special_case || coupled_flags == NULL) + return 1; + + *partial = -1; + for (i=0; i<coupled_flags_size; i++) { + /* we look for an exact matching to ensure this is correct */ + if ((local_options & coupled_flags[i]) == coupled_flags[i]) { + matching = i; + break; + } + /* ... otherwise look for the first partial matching */ + if ((local_options & coupled_flags[i]) && *partial < 0) { + *partial = i; + } + } + + /* we found an exact matching, game over */ + if (matching >= 0) + return 1; + + /* report a partial matching to suggest something */ + return 0; +} + +static struct option * +merge_options(struct option *oldopts, const struct option *newopts, + unsigned int *option_offset) +{ + unsigned int num_old, num_new, i; + struct option *merge; + + for (num_old = 0; oldopts[num_old].name; num_old++); + for (num_new = 0; newopts[num_new].name; num_new++); + + global_option_offset += OPTION_OFFSET; + *option_offset = global_option_offset; + + merge = malloc(sizeof(struct option) * (num_new + num_old + 1)); + if (merge == NULL) + return NULL; + + memcpy(merge, oldopts, num_old * sizeof(struct option)); + for (i = 0; i < num_new; i++) { + merge[num_old + i] = newopts[i]; + merge[num_old + i].val += *option_offset; + } + memset(merge + num_old + num_new, 0, sizeof(struct option)); + + return merge; +} + +/* From linux/errno.h */ +#define ENOTSUPP 524 /* Operation is not supported */ + +/* Translates errno numbers into more human-readable form than strerror. */ +static const char * +err2str(int err, enum action command) +{ + unsigned int i; + struct table_struct { + enum action act; + int err; + const char *message; + } table [] = + { { CT_LIST, ENOTSUPP, "function not implemented" }, + { 0xFFFF, EINVAL, "invalid parameters" }, + { CT_CREATE, EEXIST, "Such conntrack exists, try -U to update" }, + { CT_CREATE|CT_GET|CT_DELETE, ENOENT, + "such conntrack doesn't exist" }, + { CT_CREATE|CT_GET, ENOMEM, "not enough memory" }, + { CT_GET, EAFNOSUPPORT, "protocol not supported" }, + { CT_CREATE, ETIME, "conntrack has expired" }, + { EXP_CREATE, ENOENT, "master conntrack not found" }, + { EXP_CREATE, EINVAL, "invalid parameters" }, + { ~0U, EPERM, "sorry, you must be root or get " + "CAP_NET_ADMIN capability to do this"} + }; + + for (i = 0; i < sizeof(table)/sizeof(struct table_struct); i++) { + if ((table[i].act & command) && table[i].err == err) + return table[i].message; + } + + return strerror(err); +} + +#define PARSE_STATUS 0 +#define PARSE_EVENT 1 +#define PARSE_OUTPUT 2 +#define PARSE_MAX 3 + +static struct parse_parameter { + const char *parameter[6]; + size_t size; + unsigned int value[6]; +} parse_array[PARSE_MAX] = { + { {"ASSURED", "SEEN_REPLY", "UNSET", "FIXED_TIMEOUT", "EXPECTED"}, 5, + { IPS_ASSURED, IPS_SEEN_REPLY, 0, IPS_FIXED_TIMEOUT, IPS_EXPECTED} }, + { {"ALL", "NEW", "UPDATES", "DESTROY"}, 4, + {~0U, NF_NETLINK_CONNTRACK_NEW, NF_NETLINK_CONNTRACK_UPDATE, + NF_NETLINK_CONNTRACK_DESTROY} }, + { {"xml", "extended", "timestamp", "id" }, 4, + { _O_XML, _O_EXT, _O_TMS, _O_ID }, + }, +}; + +static int +do_parse_parameter(const char *str, size_t str_length, unsigned int *value, + int parse_type) +{ + size_t i; + int ret = 0; + struct parse_parameter *p = &parse_array[parse_type]; + + if (strncasecmp(str, "SRC_NAT", str_length) == 0) { + fprintf(stderr, "WARNING: ignoring SRC_NAT, " + "use --src-nat instead\n"); + return 1; + } + + if (strncasecmp(str, "DST_NAT", str_length) == 0) { + fprintf(stderr, "WARNING: ignoring DST_NAT, " + "use --dst-nat instead\n"); + return 1; + } + + for (i = 0; i < p->size; i++) + if (strncasecmp(str, p->parameter[i], str_length) == 0) { + *value |= p->value[i]; + ret = 1; + break; + } + + return ret; +} + +static void +parse_parameter(const char *arg, unsigned int *status, int parse_type) +{ + const char *comma; + + while ((comma = strchr(arg, ',')) != NULL) { + if (comma == arg + || !do_parse_parameter(arg, comma-arg, status, parse_type)) + exit_error(PARAMETER_PROBLEM,"Bad parameter `%s'", arg); + arg = comma+1; + } + + if (strlen(arg) == 0 + || !do_parse_parameter(arg, strlen(arg), status, parse_type)) + exit_error(PARAMETER_PROBLEM, "Bad parameter `%s'", arg); +} + +static void +add_command(unsigned int *cmd, const int newcmd) +{ + if (*cmd) + exit_error(PARAMETER_PROBLEM, "Invalid commands combination"); + *cmd |= newcmd; +} + +static unsigned int +check_type(int argc, char *argv[]) +{ + char *table = NULL; + + /* Nasty bug or feature in getopt_long ? + * It seems that it behaves badly with optional arguments. + * Fortunately, I just stole the fix from iptables ;) */ + if (optarg) + return 0; + else if (optind < argc && argv[optind][0] != '-' + && argv[optind][0] != '!') + table = argv[optind++]; + + if (!table) + return 0; + + if (strncmp("expect", table, strlen(table)) == 0) + return 1; + else if (strncmp("conntrack", table, strlen(table)) == 0) + return 0; + else + exit_error(PARAMETER_PROBLEM, "unknown type `%s'", table); + + return 0; +} + +static void set_family(int *family, int new) +{ + if (*family == AF_UNSPEC) + *family = new; + else if (*family != new) + exit_error(PARAMETER_PROBLEM, "mismatched address family"); +} + +struct addr_parse { + struct in_addr addr; + struct in6_addr addr6; + unsigned int family; +}; + +static int +parse_inetaddr(const char *cp, struct addr_parse *parse) +{ + if (inet_aton(cp, &parse->addr)) + return AF_INET; +#ifdef HAVE_INET_PTON_IPV6 + else if (inet_pton(AF_INET6, cp, &parse->addr6) > 0) + return AF_INET6; +#endif + + exit_error(PARAMETER_PROBLEM, "Invalid IP address `%s'", cp); +} + +union ct_address { + uint32_t v4; + uint32_t v6[4]; +}; + +static int +parse_addr(const char *cp, union ct_address *address) +{ + struct addr_parse parse; + int ret; + + if ((ret = parse_inetaddr(cp, &parse)) == AF_INET) + address->v4 = parse.addr.s_addr; + else if (ret == AF_INET6) + memcpy(address->v6, &parse.addr6, sizeof(parse.addr6)); + + return ret; +} + +/* Shamelessly stolen from libipt_DNAT ;). Ranges expected in network order. */ +static void +nat_parse(char *arg, int portok, struct nf_conntrack *obj, int type) +{ + char *colon, *error; + union ct_address parse; + + colon = strchr(arg, ':'); + + if (colon) { + uint16_t port; + + if (!portok) + exit_error(PARAMETER_PROBLEM, + "Need TCP or UDP with port specification"); + + port = (uint16_t)atoi(colon+1); + if (port == 0) + exit_error(PARAMETER_PROBLEM, + "Port `%s' not valid", colon+1); + + error = strchr(colon+1, ':'); + if (error) + exit_error(PARAMETER_PROBLEM, + "Invalid port:port syntax"); + + if (type == CT_OPT_SRC_NAT) + nfct_set_attr_u16(obj, ATTR_SNAT_PORT, port); + else if (type == CT_OPT_DST_NAT) + nfct_set_attr_u16(obj, ATTR_DNAT_PORT, port); + } + + if (parse_addr(arg, &parse) != AF_INET) + return; + + if (type == CT_OPT_SRC_NAT) + nfct_set_attr_u32(obj, ATTR_SNAT_IPV4, parse.v4); + else if (type == CT_OPT_DST_NAT) + nfct_set_attr_u32(obj, ATTR_DNAT_IPV4, parse.v4); +} + +static const char usage_commands[] = + "Commands:\n" + " -L [table] [options]\t\tList conntrack or expectation table\n" + " -G [table] parameters\t\tGet conntrack or expectation\n" + " -D [table] parameters\t\tDelete conntrack or expectation\n" + " -I [table] parameters\t\tCreate a conntrack or expectation\n" + " -U [table] parameters\t\tUpdate a conntrack\n" + " -E [table] [options]\t\tShow events\n" + " -F [table]\t\t\tFlush table\n" + " -C [table]\t\t\tShow counter\n" + " -S\t\t\t\tShow statistics\n"; + +static const char usage_tables[] = + "Tables: conntrack, expect\n"; + +static const char usage_conntrack_parameters[] = + "Conntrack parameters and options:\n" + " -n, --src-nat ip\t\t\tsource NAT ip\n" + " -g, --dst-nat ip\t\t\tdestination NAT ip\n" + " -m, --mark mark\t\t\tSet mark\n" + " -c, --secmark secmark\t\t\tSet selinux secmark\n" + " -e, --event-mask eventmask\t\tEvent mask, eg. NEW,DESTROY\n" + " -z, --zero \t\t\t\tZero counters while listing\n" + " -o, --output type[,...]\t\tOutput format, eg. xml\n"; + +static const char usage_expectation_parameters[] = + "Expectation parameters and options:\n" + " --tuple-src ip\tSource address in expect tuple\n" + " --tuple-dst ip\tDestination address in expect tuple\n" + " --mask-src ip\t\tSource mask address\n" + " --mask-dst ip\t\tDestination mask address\n"; + +static const char usage_parameters[] = + "Common parameters and options:\n" + " -s, --orig-src ip\t\tSource address from original direction\n" + " -d, --orig-dst ip\t\tDestination address from original direction\n" + " -r, --reply-src ip\t\tSource addres from reply direction\n" + " -q, --reply-dst ip\t\tDestination address from reply direction\n" + " -p, --protonum proto\t\tLayer 4 Protocol, eg. 'tcp'\n" + " -f, --family proto\t\tLayer 3 Protocol, eg. 'ipv6'\n" + " -t, --timeout timeout\t\tSet timeout\n" + " -u, --status status\t\tSet status, eg. ASSURED\n" + " -b, --buffer-size\t\tNetlink socket buffer size\n" + ; + + +static void +usage(char *prog) +{ + fprintf(stdout, "Command line interface for the connection " + "tracking system. Version %s\n", VERSION); + fprintf(stdout, "Usage: %s [commands] [options]\n", prog); + + fprintf(stdout, "\n%s", usage_commands); + fprintf(stdout, "\n%s", usage_tables); + fprintf(stdout, "\n%s", usage_conntrack_parameters); + fprintf(stdout, "\n%s", usage_expectation_parameters); + fprintf(stdout, "\n%s\n", usage_parameters); +} + +static unsigned int output_mask; + +static int +filter_nat(const struct nf_conntrack *obj, const struct nf_conntrack *ct) +{ + uint32_t ip; + + if (options & CT_OPT_SRC_NAT) { + if (!nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT)) + return 1; + + if (nfct_attr_is_set(obj, ATTR_SNAT_IPV4)) { + ip = nfct_get_attr_u32(obj, ATTR_SNAT_IPV4); + if (ip != nfct_get_attr_u32(ct, ATTR_REPL_IPV4_DST)) + return 1; + } + } + if (options & CT_OPT_DST_NAT) { + if (!nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT)) + return 1; + + if (nfct_attr_is_set(obj, ATTR_DNAT_IPV4)) { + ip = nfct_get_attr_u32(obj, ATTR_DNAT_IPV4); + if (ip != nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC)) + return 1; + } + } + + return 0; +} + +static int counter; +static int dump_xml_header_done = 1; + +static void __attribute__((noreturn)) +event_sighandler(int s) +{ + if (dump_xml_header_done == 0) { + printf("</conntrack>\n"); + fflush(stdout); + } + + fprintf(stderr, "%s v%s (conntrack-tools): ", PROGNAME, VERSION); + fprintf(stderr, "%d flow events have been shown.\n", counter); + nfct_close(cth); + exit(0); +} + +static int event_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + char buf[1024]; + struct nf_conntrack *obj = data; + unsigned int op_type = NFCT_O_DEFAULT; + unsigned int op_flags = 0; + + if (filter_nat(obj, ct)) + return NFCT_CB_CONTINUE; + + if (options & CT_COMPARISON && + !nfct_cmp(obj, ct, NFCT_CMP_ALL | NFCT_CMP_MASK)) + return NFCT_CB_CONTINUE; + + if (output_mask & _O_XML) { + op_type = NFCT_O_XML; + if (dump_xml_header_done) { + dump_xml_header_done = 0; + printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<conntrack>\n"); + } + } + if (output_mask & _O_EXT) + op_flags = NFCT_OF_SHOW_LAYER3; + if (output_mask & _O_TMS) { + if (!(output_mask & _O_XML)) { + struct timeval tv; + gettimeofday(&tv, NULL); + printf("[%-8ld.%-6ld]\t", tv.tv_sec, tv.tv_usec); + } else + op_flags |= NFCT_OF_TIME; + } + if (output_mask & _O_ID) + op_flags |= NFCT_OF_ID; + + nfct_snprintf(buf, sizeof(buf), ct, type, op_type, op_flags); + + printf("%s\n", buf); + fflush(stdout); + + counter++; + + return NFCT_CB_CONTINUE; +} + +static int dump_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + char buf[1024]; + struct nf_conntrack *obj = data; + unsigned int op_type = NFCT_O_DEFAULT; + unsigned int op_flags = 0; + + if (filter_nat(obj, ct)) + return NFCT_CB_CONTINUE; + + if (options & CT_COMPARISON && + !nfct_cmp(obj, ct, NFCT_CMP_ALL | NFCT_CMP_MASK)) + return NFCT_CB_CONTINUE; + + if (output_mask & _O_XML) { + op_type = NFCT_O_XML; + if (dump_xml_header_done) { + dump_xml_header_done = 0; + printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<conntrack>\n"); + } + } + if (output_mask & _O_EXT) + op_flags = NFCT_OF_SHOW_LAYER3; + if (output_mask & _O_ID) + op_flags |= NFCT_OF_ID; + + nfct_snprintf(buf, sizeof(buf), ct, NFCT_T_UNKNOWN, op_type, op_flags); + printf("%s\n", buf); + + counter++; + + return NFCT_CB_CONTINUE; +} + +static int delete_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + int res; + char buf[1024]; + struct nf_conntrack *obj = data; + unsigned int op_type = NFCT_O_DEFAULT; + unsigned int op_flags = 0; + + if (filter_nat(obj, ct)) + return NFCT_CB_CONTINUE; + + if (options & CT_COMPARISON && + !nfct_cmp(obj, ct, NFCT_CMP_ALL | NFCT_CMP_MASK)) + return NFCT_CB_CONTINUE; + + res = nfct_query(ith, NFCT_Q_DESTROY, ct); + if (res < 0) + exit_error(OTHER_PROBLEM, + "Operation failed: %s", + err2str(errno, CT_DELETE)); + + if (output_mask & _O_XML) + op_type = NFCT_O_XML; + if (output_mask & _O_EXT) + op_flags = NFCT_OF_SHOW_LAYER3; + if (output_mask & _O_ID) + op_flags |= NFCT_OF_ID; + + nfct_snprintf(buf, sizeof(buf), ct, NFCT_T_UNKNOWN, op_type, op_flags); + printf("%s\n", buf); + + counter++; + + return NFCT_CB_CONTINUE; +} + +static int print_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + char buf[1024]; + unsigned int op_type = NFCT_O_DEFAULT; + unsigned int op_flags = 0; + + if (output_mask & _O_XML) + op_type = NFCT_O_XML; + if (output_mask & _O_EXT) + op_flags = NFCT_OF_SHOW_LAYER3; + if (output_mask & _O_ID) + op_flags |= NFCT_OF_ID; + + nfct_snprintf(buf, sizeof(buf), ct, NFCT_T_UNKNOWN, op_type, op_flags); + printf("%s\n", buf); + + return NFCT_CB_CONTINUE; +} + +static int update_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + int res; + struct nf_conntrack *obj = data; + char __tmp[nfct_maxsize()]; + struct nf_conntrack *tmp = (struct nf_conntrack *) (void *)__tmp; + + memset(tmp, 0, sizeof(__tmp)); + + if (filter_nat(obj, ct)) + return NFCT_CB_CONTINUE; + + if (nfct_attr_is_set(obj, ATTR_ID) && nfct_attr_is_set(ct, ATTR_ID) && + nfct_get_attr_u32(obj, ATTR_ID) != nfct_get_attr_u32(ct, ATTR_ID)) + return NFCT_CB_CONTINUE; + + if (options & CT_OPT_TUPLE_ORIG && !nfct_cmp(obj, ct, NFCT_CMP_ORIG)) + return NFCT_CB_CONTINUE; + if (options & CT_OPT_TUPLE_REPL && !nfct_cmp(obj, ct, NFCT_CMP_REPL)) + return NFCT_CB_CONTINUE; + + nfct_copy(tmp, ct, NFCT_CP_ORIG); + nfct_copy(tmp, obj, NFCT_CP_META); + + res = nfct_query(ith, NFCT_Q_UPDATE, tmp); + if (res < 0) + exit_error(OTHER_PROBLEM, + "Operation failed: %s", + err2str(errno, CT_UPDATE)); + + nfct_callback_register(ith, NFCT_T_ALL, print_cb, NULL); + + res = nfct_query(ith, NFCT_Q_GET, tmp); + if (res < 0) { + /* the entry has vanish in middle of the update */ + if (errno == ENOENT) { + nfct_callback_unregister(ith); + return NFCT_CB_CONTINUE; + } + + exit_error(OTHER_PROBLEM, + "Operation failed: %s", + err2str(errno, CT_UPDATE)); + } + + nfct_callback_unregister(ith); + + counter++; + + return NFCT_CB_CONTINUE; +} + +static int dump_exp_cb(enum nf_conntrack_msg_type type, + struct nf_expect *exp, + void *data) +{ + char buf[1024]; + + nfexp_snprintf(buf,sizeof(buf), exp, NFCT_T_UNKNOWN, NFCT_O_DEFAULT, 0); + printf("%s\n", buf); + counter++; + + return NFCT_CB_CONTINUE; +} + +static int count_exp_cb(enum nf_conntrack_msg_type type, + struct nf_expect *exp, + void *data) +{ + counter++; + return NFCT_CB_CONTINUE; +} + +#ifndef CT_STATS_PROC +#define CT_STATS_PROC "/proc/net/stat/nf_conntrack" +#endif + +/* As of 2.6.29, we have 16 entries, this is enough */ +#ifndef CT_STATS_ENTRIES_MAX +#define CT_STATS_ENTRIES_MAX 64 +#endif + +/* maximum string length currently is 13 characters */ +#ifndef CT_STATS_STRING_MAX +#define CT_STATS_STRING_MAX 64 +#endif + +static int display_proc_conntrack_stats(void) +{ + int ret = 0; + FILE *fd; + char buf[4096], *token, *nl; + char output[CT_STATS_ENTRIES_MAX][CT_STATS_STRING_MAX]; + unsigned int value[CT_STATS_ENTRIES_MAX], i, max; + + fd = fopen(CT_STATS_PROC, "r"); + if (fd == NULL) + return -1; + + if (fgets(buf, sizeof(buf), fd) == NULL) { + ret = -1; + goto out_err; + } + + /* trim off trailing \n */ + nl = strchr(buf, '\n'); + if (nl != NULL) { + *nl = '\0'; + nl = strchr(buf, '\n'); + } + token = strtok(buf, " "); + for (i=0; token != NULL && i<CT_STATS_ENTRIES_MAX; i++) { + strncpy(output[i], token, CT_STATS_STRING_MAX); + output[i][CT_STATS_STRING_MAX-1]='\0'; + token = strtok(NULL, " "); + } + max = i; + + if (fgets(buf, sizeof(buf), fd) == NULL) { + ret = -1; + goto out_err; + } + + nl = strchr(buf, '\n'); + while (nl != NULL) { + *nl = '\0'; + nl = strchr(buf, '\n'); + } + token = strtok(buf, " "); + for (i=0; token != NULL && i<CT_STATS_ENTRIES_MAX; i++) { + value[i] = (unsigned int) strtol(token, (char**) NULL, 16); + token = strtok(NULL, " "); + } + + for (i=0; i<max; i++) + printf("%-10s\t\t%-8u\n", output[i], value[i]); + +out_err: + fclose(fd); + return ret; +} + +static struct ctproto_handler *h; + +static const int cmd2type[][2] = { + ['L'] = { CT_LIST, EXP_LIST }, + ['I'] = { CT_CREATE, EXP_CREATE }, + ['D'] = { CT_DELETE, EXP_DELETE }, + ['G'] = { CT_GET, EXP_GET }, + ['F'] = { CT_FLUSH, EXP_FLUSH }, + ['E'] = { CT_EVENT, EXP_EVENT }, + ['V'] = { CT_VERSION, CT_VERSION }, + ['h'] = { CT_HELP, CT_HELP }, + ['C'] = { CT_COUNT, EXP_COUNT }, +}; + +static const int opt2type[] = { + ['s'] = CT_OPT_ORIG_SRC, + ['d'] = CT_OPT_ORIG_DST, + ['r'] = CT_OPT_REPL_SRC, + ['q'] = CT_OPT_REPL_DST, + ['{'] = CT_OPT_MASK_SRC, + ['}'] = CT_OPT_MASK_DST, + ['['] = CT_OPT_EXP_SRC, + [']'] = CT_OPT_EXP_DST, + ['n'] = CT_OPT_SRC_NAT, + ['g'] = CT_OPT_DST_NAT, + ['m'] = CT_OPT_MARK, + ['c'] = CT_OPT_SECMARK, + ['i'] = CT_OPT_ID, +}; + +static const int opt2family_attr[][2] = { + ['s'] = { ATTR_ORIG_IPV4_SRC, ATTR_ORIG_IPV6_SRC }, + ['d'] = { ATTR_ORIG_IPV4_DST, ATTR_ORIG_IPV6_DST }, + ['r'] = { ATTR_REPL_IPV4_SRC, ATTR_REPL_IPV6_SRC }, + ['q'] = { ATTR_REPL_IPV4_DST, ATTR_REPL_IPV6_DST }, + ['{'] = { ATTR_ORIG_IPV4_SRC, ATTR_ORIG_IPV6_SRC }, + ['}'] = { ATTR_ORIG_IPV4_DST, ATTR_ORIG_IPV6_DST }, + ['['] = { ATTR_ORIG_IPV4_SRC, ATTR_ORIG_IPV6_SRC }, + [']'] = { ATTR_ORIG_IPV4_DST, ATTR_ORIG_IPV6_DST }, +}; + +static const int opt2attr[] = { + ['s'] = ATTR_ORIG_L3PROTO, + ['d'] = ATTR_ORIG_L3PROTO, + ['r'] = ATTR_REPL_L3PROTO, + ['q'] = ATTR_REPL_L3PROTO, + ['m'] = ATTR_MARK, + ['c'] = ATTR_SECMARK, + ['i'] = ATTR_ID, +}; + +static char exit_msg[NUMBER_OF_CMD][64] = { + [CT_LIST_BIT] = "%d flow entries have been shown.\n", + [CT_CREATE_BIT] = "%d flow entries have been created.\n", + [CT_UPDATE_BIT] = "%d flow entries have been updated.\n", + [CT_DELETE_BIT] = "%d flow entries have been deleted.\n", + [CT_GET_BIT] = "%d flow entries have been shown.\n", + [CT_EVENT_BIT] = "%d flow events have been shown.\n", + [EXP_LIST_BIT] = "%d expectations have been shown.\n", + [EXP_DELETE_BIT] = "%d expectations have been shown.\n", +}; + +int main(int argc, char *argv[]) +{ + int c, cmd; + unsigned int type = 0, event_mask = 0, l4flags = 0, status = 0; + int res = 0, partial; + size_t socketbuffersize = 0; + int family = AF_UNSPEC; + char __obj[nfct_maxsize()]; + char __exptuple[nfct_maxsize()]; + char __mask[nfct_maxsize()]; + struct nf_conntrack *obj = (struct nf_conntrack *)(void*) __obj; + struct nf_conntrack *exptuple = + (struct nf_conntrack *)(void*) __exptuple; + struct nf_conntrack *mask = (struct nf_conntrack *)(void*) __mask; + char __exp[nfexp_maxsize()]; + struct nf_expect *exp = (struct nf_expect *)(void*) __exp; + int l3protonum, protonum = 0; + union ct_address ad; + unsigned int command = 0; + + memset(__obj, 0, sizeof(__obj)); + memset(__exptuple, 0, sizeof(__exptuple)); + memset(__mask, 0, sizeof(__mask)); + memset(__exp, 0, sizeof(__exp)); + + register_tcp(); + register_udp(); + register_udplite(); + register_sctp(); + register_dccp(); + register_icmp(); + register_icmpv6(); + register_gre(); + register_unknown(); + + /* disable explicit missing arguments error output from getopt_long */ + opterr = 0; + + while ((c = getopt_long(argc, argv, "L::I::U::D::G::E::F::hVs:d:r:q:" + "p:t:u:e:a:z[:]:{:}:m:i:f:o:n::" + "g::c:b:C::S", + opts, NULL)) != -1) { + switch(c) { + /* commands */ + case 'L': + case 'I': + case 'D': + case 'G': + case 'F': + case 'E': + case 'V': + case 'h': + case 'C': + type = check_type(argc, argv); + add_command(&command, cmd2type[c][type]); + break; + case 'U': + type = check_type(argc, argv); + if (type == 0) + add_command(&command, CT_UPDATE); + else + exit_error(PARAMETER_PROBLEM, + "Can't update expectations"); + break; + case 'S': + add_command(&command, X_STATS); + break; + /* options */ + case 's': + case 'd': + case 'r': + case 'q': + options |= opt2type[c]; + + l3protonum = parse_addr(optarg, &ad); + set_family(&family, l3protonum); + if (l3protonum == AF_INET) { + nfct_set_attr_u32(obj, + opt2family_attr[c][0], + ad.v4); + } else if (l3protonum == AF_INET6) { + nfct_set_attr(obj, + opt2family_attr[c][1], + &ad.v6); + } + nfct_set_attr_u8(obj, opt2attr[c], l3protonum); + break; + case '{': + case '}': + case '[': + case ']': + options |= opt2type[c]; + l3protonum = parse_addr(optarg, &ad); + set_family(&family, l3protonum); + if (l3protonum == AF_INET) { + nfct_set_attr_u32(mask, + opt2family_attr[c][0], + ad.v4); + } else if (l3protonum == AF_INET6) { + nfct_set_attr(mask, + opt2family_attr[c][1], + &ad.v6); + } + nfct_set_attr_u8(mask, ATTR_ORIG_L3PROTO, l3protonum); + break; + case 'p': + options |= CT_OPT_PROTO; + h = findproto(optarg, &protonum); + if (!h) + exit_error(PARAMETER_PROBLEM, + "`%s' unsupported protocol", + optarg); + + opts = merge_options(opts, h->opts, &h->option_offset); + if (opts == NULL) + exit_error(OTHER_PROBLEM, "out of memory"); + + nfct_set_attr_u8(obj, ATTR_L4PROTO, protonum); + break; + case 't': + options |= CT_OPT_TIMEOUT; + nfct_set_attr_u32(obj, ATTR_TIMEOUT, atol(optarg)); + nfexp_set_attr_u32(exp, ATTR_EXP_TIMEOUT, atol(optarg)); + break; + case 'u': + options |= CT_OPT_STATUS; + parse_parameter(optarg, &status, PARSE_STATUS); + nfct_set_attr_u32(obj, ATTR_STATUS, status); + break; + case 'e': + options |= CT_OPT_EVENT_MASK; + parse_parameter(optarg, &event_mask, PARSE_EVENT); + break; + case 'o': + options |= CT_OPT_OUTPUT; + parse_parameter(optarg, &output_mask, PARSE_OUTPUT); + break; + case 'z': + options |= CT_OPT_ZERO; + break; + case 'n': + case 'g': { + char *tmp = NULL; + + options |= opt2type[c]; + + if (optarg) + continue; + else if (optind < argc && argv[optind][0] != '-' + && argv[optind][0] != '!') + tmp = argv[optind++]; + + if (tmp == NULL) + continue; + + set_family(&family, AF_INET); + nat_parse(tmp, 1, obj, opt2type[c]); + break; + } + case 'i': + case 'm': + case 'c': + options |= opt2type[c]; + nfct_set_attr_u32(obj, + opt2attr[c], + strtoul(optarg, NULL, 0)); + break; + case 'a': + fprintf(stderr, "WARNING: ignoring -%c, " + "deprecated option.\n", c); + break; + case 'f': + options |= CT_OPT_FAMILY; + if (strncmp(optarg, "ipv4", strlen("ipv4")) == 0) + set_family(&family, AF_INET); + else if (strncmp(optarg, "ipv6", strlen("ipv6")) == 0) + set_family(&family, AF_INET6); + else + exit_error(PARAMETER_PROBLEM, + "`%s' unsupported protocol", + optarg); + break; + case 'b': + socketbuffersize = atol(optarg); + options |= CT_OPT_BUFFERSIZE; + break; + case '?': + if (optopt) + exit_error(PARAMETER_PROBLEM, + "option `%s' requires an " + "argument", argv[optind-1]); + else + exit_error(PARAMETER_PROBLEM, + "unknown option `%s'", + argv[optind-1]); + break; + default: + if (h && h->parse_opts + &&!h->parse_opts(c - h->option_offset, obj, + exptuple, mask, &l4flags)) + exit_error(PARAMETER_PROBLEM, "parse error"); + break; + } + } + + /* default family */ + if (family == AF_UNSPEC) + family = AF_INET; + + cmd = bit2cmd(command); + res = generic_opt_check(options, NUMBER_OF_OPT, + commands_v_options[cmd], optflags, + addr_valid_flags, ADDR_VALID_FLAGS_MAX, + &partial); + if (!res) { + switch(partial) { + case -1: + case 0: + exit_error(PARAMETER_PROBLEM, "you have to specify " + "`--src' and `--dst'"); + break; + case 1: + exit_error(PARAMETER_PROBLEM, "you have to specify " + "`--reply-src' and " + "`--reply-dst'"); + break; + } + } + if (!(command & CT_HELP) && h && h->final_check) + h->final_check(l4flags, cmd, obj); + + switch(command) { + + case CT_LIST: + cth = nfct_open(CONNTRACK, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + if (options & CT_COMPARISON && + options & CT_OPT_ZERO) + exit_error(PARAMETER_PROBLEM, "Can't use -z with " + "filtering parameters"); + + nfct_callback_register(cth, NFCT_T_ALL, dump_cb, obj); + + if (options & CT_OPT_ZERO) + res = nfct_query(cth, NFCT_Q_DUMP_RESET, &family); + else + res = nfct_query(cth, NFCT_Q_DUMP, &family); + + if (dump_xml_header_done == 0) { + printf("</conntrack>\n"); + fflush(stdout); + } + + nfct_close(cth); + break; + + case EXP_LIST: + cth = nfct_open(EXPECT, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + nfexp_callback_register(cth, NFCT_T_ALL, dump_exp_cb, NULL); + res = nfexp_query(cth, NFCT_Q_DUMP, &family); + nfct_close(cth); + break; + + case CT_CREATE: + if ((options & CT_OPT_ORIG) && !(options & CT_OPT_REPL)) + nfct_setobjopt(obj, NFCT_SOPT_SETUP_REPLY); + else if (!(options & CT_OPT_ORIG) && (options & CT_OPT_REPL)) + nfct_setobjopt(obj, NFCT_SOPT_SETUP_ORIGINAL); + + cth = nfct_open(CONNTRACK, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + res = nfct_query(cth, NFCT_Q_CREATE, obj); + if (res != -1) + counter++; + nfct_close(cth); + break; + + case EXP_CREATE: + nfexp_set_attr(exp, ATTR_EXP_MASTER, obj); + nfexp_set_attr(exp, ATTR_EXP_EXPECTED, exptuple); + nfexp_set_attr(exp, ATTR_EXP_MASK, mask); + + cth = nfct_open(EXPECT, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + res = nfexp_query(cth, NFCT_Q_CREATE, exp); + nfct_close(cth); + break; + + case CT_UPDATE: + cth = nfct_open(CONNTRACK, 0); + /* internal handler for delete_cb, otherwise we hit EILSEQ */ + ith = nfct_open(CONNTRACK, 0); + if (!cth || !ith) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + nfct_callback_register(cth, NFCT_T_ALL, update_cb, obj); + + res = nfct_query(cth, NFCT_Q_DUMP, &family); + nfct_close(ith); + nfct_close(cth); + break; + + case CT_DELETE: + cth = nfct_open(CONNTRACK, 0); + ith = nfct_open(CONNTRACK, 0); + if (!cth || !ith) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + nfct_callback_register(cth, NFCT_T_ALL, delete_cb, obj); + + res = nfct_query(cth, NFCT_Q_DUMP, &family); + nfct_close(ith); + nfct_close(cth); + break; + + case EXP_DELETE: + nfexp_set_attr(exp, ATTR_EXP_EXPECTED, obj); + + cth = nfct_open(EXPECT, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + res = nfexp_query(cth, NFCT_Q_DESTROY, exp); + nfct_close(cth); + break; + + case CT_GET: + cth = nfct_open(CONNTRACK, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + nfct_callback_register(cth, NFCT_T_ALL, dump_cb, obj); + res = nfct_query(cth, NFCT_Q_GET, obj); + nfct_close(cth); + break; + + case EXP_GET: + nfexp_set_attr(exp, ATTR_EXP_MASTER, obj); + + cth = nfct_open(EXPECT, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + nfexp_callback_register(cth, NFCT_T_ALL, dump_exp_cb, NULL); + res = nfexp_query(cth, NFCT_Q_GET, exp); + nfct_close(cth); + break; + + case CT_FLUSH: + cth = nfct_open(CONNTRACK, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + res = nfct_query(cth, NFCT_Q_FLUSH, &family); + nfct_close(cth); + fprintf(stderr, "%s v%s (conntrack-tools): ",PROGNAME,VERSION); + fprintf(stderr,"connection tracking table has been emptied.\n"); + break; + + case EXP_FLUSH: + cth = nfct_open(EXPECT, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + res = nfexp_query(cth, NFCT_Q_FLUSH, &family); + nfct_close(cth); + break; + + case CT_EVENT: + if (options & CT_OPT_EVENT_MASK) + cth = nfct_open(CONNTRACK, + event_mask & NFCT_ALL_CT_GROUPS); + else + cth = nfct_open(CONNTRACK, NFCT_ALL_CT_GROUPS); + + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + if (options & CT_OPT_BUFFERSIZE) { + size_t ret; + ret = nfnl_rcvbufsiz(nfct_nfnlh(cth), socketbuffersize); + fprintf(stderr, "NOTICE: Netlink socket buffer size " + "has been set to %zu bytes.\n", ret); + } + signal(SIGINT, event_sighandler); + signal(SIGTERM, event_sighandler); + nfct_callback_register(cth, NFCT_T_ALL, event_cb, obj); + res = nfct_catch(cth); + if (res == -1) { + if (errno == ENOBUFS) { + fprintf(stderr, + "WARNING: We have hit ENOBUFS! We " + "are losing events.\nThis message " + "means that the current netlink " + "socket buffer size is too small.\n" + "Please, check --buffer-size in " + "conntrack(8) manpage.\n"); + } + } + nfct_close(cth); + break; + + case EXP_EVENT: + cth = nfct_open(EXPECT, NF_NETLINK_CONNTRACK_EXP_NEW); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + signal(SIGINT, event_sighandler); + signal(SIGTERM, event_sighandler); + nfexp_callback_register(cth, NFCT_T_ALL, dump_exp_cb, NULL); + res = nfexp_catch(cth); + nfct_close(cth); + break; + case CT_COUNT: { +#define NF_CONNTRACK_COUNT_PROC "/proc/sys/net/netfilter/nf_conntrack_count" + FILE *fd; + int count; + fd = fopen(NF_CONNTRACK_COUNT_PROC, "r"); + if (fd == NULL) { + exit_error(OTHER_PROBLEM, "Can't open %s", + NF_CONNTRACK_COUNT_PROC); + } + if (fscanf(fd, "%d", &count) != 1) { + exit_error(OTHER_PROBLEM, "Can't read %s", + NF_CONNTRACK_COUNT_PROC); + } + fclose(fd); + printf("%d\n", count); + break; + } + case EXP_COUNT: + cth = nfct_open(EXPECT, 0); + if (!cth) + exit_error(OTHER_PROBLEM, "Can't open handler"); + + nfexp_callback_register(cth, NFCT_T_ALL, count_exp_cb, NULL); + res = nfexp_query(cth, NFCT_Q_DUMP, &family); + nfct_close(cth); + printf("%d\n", counter); + break; + case X_STATS: + if (display_proc_conntrack_stats() < 0) + exit_error(OTHER_PROBLEM, "Can't open /proc interface"); + break; + case CT_VERSION: + printf("%s v%s (conntrack-tools)\n", PROGNAME, VERSION); + break; + case CT_HELP: + usage(argv[0]); + if (options & CT_OPT_PROTO) + extension_help(h, protonum); + break; + default: + usage(argv[0]); + break; + } + + if (res < 0) + exit_error(OTHER_PROBLEM, "Operation failed: %s", + err2str(errno, command)); + + free_options(); + + if (command && exit_msg[cmd][0]) { + fprintf(stderr, "%s v%s (conntrack-tools): ",PROGNAME,VERSION); + fprintf(stderr, exit_msg[cmd], counter); + if (counter == 0 && !(command & (CT_LIST | EXP_LIST))) + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/src/date.c b/src/date.c new file mode 100644 index 0000000..f5a5ada --- /dev/null +++ b/src/date.c @@ -0,0 +1,28 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include "date.h" +#include <stdlib.h> +#include <string.h> + +static struct timeval now; + +int do_gettimeofday(void) +{ + return gettimeofday(&now, NULL); +} + +void gettimeofday_cached(struct timeval *tv) +{ + memcpy(tv, &now, sizeof(struct timeval)); +} + +int time_cached(void) +{ + return now.tv_sec; +} diff --git a/src/event.c b/src/event.c new file mode 100644 index 0000000..d1dfe72 --- /dev/null +++ b/src/event.c @@ -0,0 +1,77 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include <unistd.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> + +#include "event.h" + +struct evfd { + int read; + int fds[2]; +}; + +struct evfd *create_evfd(void) +{ + struct evfd *e; + + e = calloc(1, sizeof(struct evfd)); + if (e == NULL) + return NULL; + + if (pipe(e->fds) == -1) { + free(e); + return NULL; + } + fcntl(e->fds[0], F_SETFL, O_NONBLOCK); + + return e; +} + +void destroy_evfd(struct evfd *e) +{ + close(e->fds[0]); + close(e->fds[1]); + free(e); +} + +int get_read_evfd(struct evfd *evfd) +{ + return evfd->fds[0]; +} + +int write_evfd(struct evfd *evfd) +{ + int data = 0, ret = 0; + + if (evfd->read == 0) + ret = write(evfd->fds[1], &data, sizeof(data)); + evfd->read++; + + return ret; +} + +int read_evfd(struct evfd *evfd) +{ + int data, ret = 0; + + if (--evfd->read == 0) + ret = read(evfd->fds[0], &data, sizeof(data)); + return ret; +} diff --git a/src/external_cache.c b/src/external_cache.c new file mode 100644 index 0000000..c70c818 --- /dev/null +++ b/src/external_cache.c @@ -0,0 +1,122 @@ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "conntrackd.h" +#include "sync.h" +#include "log.h" +#include "cache.h" +#include "external.h" + +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <stdlib.h> + +static struct cache *external; + +static int external_cache_init(void) +{ + external = cache_create("external", + STATE_SYNC(sync)->external_cache_flags, + NULL); + if (external == NULL) { + dlog(LOG_ERR, "can't allocate memory for the external cache"); + return -1; + } + return 0; +} + +static void external_cache_close(void) +{ + cache_destroy(external); +} + +static void external_cache_new(struct nf_conntrack *ct) +{ + struct cache_object *obj; + int id; + + obj = cache_find(external, ct, &id); + if (obj == NULL) { +retry: + obj = cache_object_new(external, ct); + if (obj == NULL) + return; + + if (cache_add(external, obj, id) == -1) { + cache_object_free(obj); + return; + } + } else { + cache_del(external, obj); + cache_object_free(obj); + goto retry; + } +} + +static void external_cache_upd(struct nf_conntrack *ct) +{ + cache_update_force(external, ct); +} + +static void external_cache_del(struct nf_conntrack *ct) +{ + struct cache_object *obj; + int id; + + obj = cache_find(external, ct, &id); + if (obj) { + cache_del(external, obj); + cache_object_free(obj); + } +} + +static void external_cache_dump(int fd, int type) +{ + cache_dump(external, fd, type); +} + +static void external_cache_commit(struct nfct_handle *h, int fd) +{ + cache_commit(external, h, fd); +} + +static void external_cache_flush(void) +{ + cache_flush(external); +} + +static void external_cache_stats(int fd) +{ + cache_stats(external, fd); +} + +static void external_cache_stats_ext(int fd) +{ + cache_stats_extended(external, fd); +} + +struct external_handler external_cache = { + .init = external_cache_init, + .close = external_cache_close, + .new = external_cache_new, + .update = external_cache_upd, + .destroy = external_cache_del, + .dump = external_cache_dump, + .commit = external_cache_commit, + .flush = external_cache_flush, + .stats = external_cache_stats, + .stats_ext = external_cache_stats_ext, +}; diff --git a/src/external_inject.c b/src/external_inject.c new file mode 100644 index 0000000..a54bb13 --- /dev/null +++ b/src/external_inject.c @@ -0,0 +1,186 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "conntrackd.h" +#include "sync.h" +#include "log.h" +#include "cache.h" +#include "origin.h" +#include "external.h" +#include "netlink.h" + +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <errno.h> +#include <stdlib.h> + +static struct nfct_handle *inject; + +struct { + uint32_t add_ok; + uint32_t add_fail; + uint32_t upd_ok; + uint32_t upd_fail; + uint32_t del_ok; + uint32_t del_fail; +} external_inject_stat; + +static int external_inject_init(void) +{ + /* handler to directly inject conntracks into kernel-space */ + inject = nfct_open(CONNTRACK, 0); + if (inject == NULL) { + dlog(LOG_ERR, "can't open netlink handler: %s", + strerror(errno)); + dlog(LOG_ERR, "no ctnetlink kernel support?"); + return -1; + } + /* we are directly injecting the entries into the kernel */ + origin_register(inject, CTD_ORIGIN_INJECT); + return 0; +} + +static void external_inject_close(void) +{ + origin_unregister(inject); + nfct_close(inject); +} + +static void external_inject_new(struct nf_conntrack *ct) +{ + int ret, retry = 1; + +retry: + if (nl_create_conntrack(inject, ct, 0) == -1) { + /* if the state entry exists, we delete and try again */ + if (errno == EEXIST && retry == 1) { + ret = nl_destroy_conntrack(inject, ct); + if (ret == 0 || (ret == -1 && errno == ENOENT)) { + if (retry) { + retry = 0; + goto retry; + } + } + external_inject_stat.add_fail++; + dlog(LOG_ERR, "inject-add1: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + return; + } + external_inject_stat.add_fail++; + dlog(LOG_ERR, "inject-add2: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + } else { + external_inject_stat.add_ok++; + } +} + +static void external_inject_upd(struct nf_conntrack *ct) +{ + int ret; + + /* if we successfully update the entry, everything is OK */ + if (nl_update_conntrack(inject, ct, 0) != -1) { + external_inject_stat.upd_ok++; + return; + } + + /* state entries does not exist, we have to create it */ + if (errno == ENOENT) { + if (nl_create_conntrack(inject, ct, 0) == -1) { + external_inject_stat.upd_fail++; + dlog(LOG_ERR, "inject-upd1: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + } else { + external_inject_stat.upd_ok++; + } + return; + } + + /* we failed to update the entry, there are some operations that + * may trigger this error, eg. unset some status bits. Try harder, + * delete the existing entry and create a new one. */ + ret = nl_destroy_conntrack(inject, ct); + if (ret == 0 || (ret == -1 && errno == ENOENT)) { + if (nl_create_conntrack(inject, ct, 0) == -1) { + external_inject_stat.upd_fail++; + dlog(LOG_ERR, "inject-upd2: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + } else { + external_inject_stat.upd_ok++; + } + return; + } + external_inject_stat.upd_fail++; + dlog(LOG_ERR, "inject-upd3: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); +} + +static void external_inject_del(struct nf_conntrack *ct) +{ + if (nl_destroy_conntrack(inject, ct) == -1) { + if (errno != ENOENT) { + external_inject_stat.del_fail++; + dlog(LOG_ERR, "inject-del: %s", strerror(errno)); + dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + } + } else { + external_inject_stat.del_ok++; + } +} + +static void external_inject_dump(int fd, int type) +{ +} + +static void external_inject_commit(struct nfct_handle *h, int fd) +{ +} + +static void external_inject_flush(void) +{ +} + +static void external_inject_stats(int fd) +{ + char buf[512]; + int size; + + size = sprintf(buf, "external inject:\n" + "connections created:\t\t%12u\tfailed:\t%12u\n" + "connections updated:\t\t%12u\tfailed:\t%12u\n" + "connections destroyed:\t\t%12u\tfailed:\t%12u\n\n", + external_inject_stat.add_ok, + external_inject_stat.add_fail, + external_inject_stat.upd_ok, + external_inject_stat.upd_fail, + external_inject_stat.del_ok, + external_inject_stat.del_fail); + + send(fd, buf, size, 0); +} + +struct external_handler external_inject = { + .init = external_inject_init, + .close = external_inject_close, + .new = external_inject_new, + .update = external_inject_upd, + .destroy = external_inject_del, + .dump = external_inject_dump, + .commit = external_inject_commit, + .flush = external_inject_flush, + .stats = external_inject_stats, + .stats_ext = external_inject_stats, +}; diff --git a/src/fds.c b/src/fds.c new file mode 100644 index 0000000..347eee1 --- /dev/null +++ b/src/fds.c @@ -0,0 +1,94 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include <stdlib.h> +#include <string.h> +#include "fds.h" + +struct fds *create_fds(void) +{ + struct fds *fds; + + fds = (struct fds *) calloc(sizeof(struct fds), 1); + if (fds == NULL) + return NULL; + + INIT_LIST_HEAD(&fds->list); + + return fds; +} + +void destroy_fds(struct fds *fds) +{ + struct fds_item *this, *tmp; + + list_for_each_entry_safe(this, tmp, &fds->list, head) { + list_del(&this->head); + FD_CLR(this->fd, &fds->readfds); + free(this); + } + free(fds); +} + +int register_fd(int fd, struct fds *fds) +{ + struct fds_item *item; + + FD_SET(fd, &fds->readfds); + + if (fd > fds->maxfd) + fds->maxfd = fd; + + item = calloc(sizeof(struct fds_item), 1); + if (item == NULL) + return -1; + + item->fd = fd; + list_add(&item->head, &fds->list); + + return 0; +} + +int unregister_fd(int fd, struct fds *fds) +{ + int found = 0, maxfd = -1; + struct fds_item *this, *tmp; + + list_for_each_entry_safe(this, tmp, &fds->list, head) { + if (this->fd == fd) { + list_del(&this->head); + FD_CLR(this->fd, &fds->readfds); + free(this); + found = 1; + /* ... and recalculate maxfd, see below. */ + } + } + /* not found, report an error. */ + if (!found) + return -1; + + /* calculate the new maximum fd. */ + list_for_each_entry(this, &fds->list, head) { + if (maxfd < this->fd) { + maxfd = this->fd; + } + } + fds->maxfd = maxfd; + + return 0; +} + diff --git a/src/filter.c b/src/filter.c new file mode 100644 index 0000000..6a09c77 --- /dev/null +++ b/src/filter.c @@ -0,0 +1,409 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "filter.h" +#include "bitops.h" +#include "jhash.h" +#include "hash.h" +#include "vector.h" +#include "conntrackd.h" +#include "log.h" + +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <limits.h> + +struct ct_filter { + int logic[CT_FILTER_MAX]; + u_int32_t l4protomap[IPPROTO_MAX/32]; + u_int16_t statemap[IPPROTO_MAX]; + struct hashtable *h; + struct hashtable *h6; + struct vector *v; + struct vector *v6; +}; + +/* XXX: These should be configurable, better use a rb-tree */ +#define FILTER_POOL_SIZE 128 +#define FILTER_POOL_LIMIT INT_MAX + +static uint32_t ct_filter_hash(const void *data, const struct hashtable *table) +{ + const uint32_t *f = data; + + return jhash_1word(*f, 0) % table->hashsize; +} + +static uint32_t ct_filter_hash6(const void *data, const struct hashtable *table) +{ + return jhash2(data, 4, 0) % table->hashsize; +} + +static int ct_filter_compare(const void *data1, const void *data2) +{ + const struct ct_filter_ipv4_hnode *f1 = data1; + const uint32_t *f2 = data2; + + return f1->ip == *f2; +} + +static int ct_filter_compare6(const void *data1, const void *data2) +{ + const struct ct_filter_ipv6_hnode *f = data1; + + return memcmp(f->ipv6, data2, sizeof(uint32_t)*4) == 0; +} + +struct ct_filter *ct_filter_create(void) +{ + int i; + struct ct_filter *filter; + + filter = calloc(sizeof(struct ct_filter), 1); + if (!filter) + return NULL; + + filter->h = hashtable_create(FILTER_POOL_SIZE, + FILTER_POOL_LIMIT, + ct_filter_hash, + ct_filter_compare); + if (!filter->h) { + free(filter); + return NULL; + } + + filter->h6 = hashtable_create(FILTER_POOL_SIZE, + FILTER_POOL_LIMIT, + ct_filter_hash6, + ct_filter_compare6); + if (!filter->h6) { + free(filter->h); + free(filter); + return NULL; + } + + filter->v = vector_create(sizeof(struct ct_filter_netmask_ipv4)); + if (!filter->v) { + free(filter->h6); + free(filter->h); + free(filter); + return NULL; + } + + filter->v6 = vector_create(sizeof(struct ct_filter_netmask_ipv6)); + if (!filter->v6) { + free(filter->v); + free(filter->h6); + free(filter->h); + free(filter); + return NULL; + } + + for (i=0; i<CT_FILTER_MAX; i++) + filter->logic[i] = -1; + + return filter; +} + +void ct_filter_destroy(struct ct_filter *filter) +{ + hashtable_destroy(filter->h); + hashtable_destroy(filter->h6); + vector_destroy(filter->v); + vector_destroy(filter->v6); + free(filter); +} + +/* this is ugly, but it simplifies read_config_yy.y */ +static struct ct_filter *__filter_alloc(struct ct_filter *filter) +{ + if (!STATE(us_filter)) { + STATE(us_filter) = ct_filter_create(); + if (!STATE(us_filter)) { + fprintf(stderr, "Can't create ignore pool!\n"); + exit(EXIT_FAILURE); + } + } + + return STATE(us_filter); +} + +void ct_filter_set_logic(struct ct_filter *filter, + enum ct_filter_type type, + enum ct_filter_logic logic) +{ + filter = __filter_alloc(filter); + filter->logic[type] = logic; +} + +int ct_filter_add_ip(struct ct_filter *filter, void *data, uint8_t family) +{ + int id; + filter = __filter_alloc(filter); + + switch(family) { + case AF_INET: + id = hashtable_hash(filter->h, data); + if (!hashtable_find(filter->h, data, id)) { + struct ct_filter_ipv4_hnode *n; + n = malloc(sizeof(struct ct_filter_ipv4_hnode)); + if (n == NULL) + return 0; + memcpy(&n->ip, data, sizeof(uint32_t)); + hashtable_add(filter->h, &n->node, id); + return 0; + } + break; + case AF_INET6: + id = hashtable_hash(filter->h6, data); + if (!hashtable_find(filter->h6, data, id)) { + struct ct_filter_ipv6_hnode *n; + n = malloc(sizeof(struct ct_filter_ipv6_hnode)); + if (n == NULL) + return 0; + memcpy(n->ipv6, data, sizeof(uint32_t)*4); + hashtable_add(filter->h6, &n->node, id); + return 0; + } + break; + } + return 1; +} + +static int cmp_ipv4_addr(const void *a, const void *b) +{ + return memcmp(a, b, sizeof(struct ct_filter_netmask_ipv4)) == 0; +} + +static int cmp_ipv6_addr(const void *a, const void *b) +{ + return memcmp(a, b, sizeof(struct ct_filter_netmask_ipv6)) == 0; +} + +int ct_filter_add_netmask(struct ct_filter *filter, void *data, uint8_t family) +{ + filter = __filter_alloc(filter); + + switch(family) { + case AF_INET: + if (vector_iterate(filter->v, data, cmp_ipv4_addr)) { + errno = EEXIST; + return 0; + } + vector_add(filter->v, data); + break; + case AF_INET6: + if (vector_iterate(filter->v, data, cmp_ipv6_addr)) { + errno = EEXIST; + return 0; + } + vector_add(filter->v6, data); + break; + } + return 1; +} + +void ct_filter_add_proto(struct ct_filter *f, int protonum) +{ + f = __filter_alloc(f); + + set_bit_u32(protonum, f->l4protomap); +} + +void ct_filter_add_state(struct ct_filter *f, int protonum, int val) +{ + f = __filter_alloc(f); + + set_bit_u16(val, &f->statemap[protonum]); +} + +static inline int +__ct_filter_test_ipv4(struct ct_filter *f, struct nf_conntrack *ct) +{ + int id_src, id_dst; + uint32_t src, dst; + + /* we only use the real source and destination address */ + src = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_SRC); + dst = nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC); + + id_src = hashtable_hash(f->h, &src); + id_dst = hashtable_hash(f->h, &dst); + + return hashtable_find(f->h, &src, id_src) || + hashtable_find(f->h, &dst, id_dst); +} + +static inline int +__ct_filter_test_ipv6(struct ct_filter *f, struct nf_conntrack *ct) +{ + int id_src, id_dst; + const uint32_t *src, *dst; + + src = nfct_get_attr(ct, ATTR_ORIG_IPV6_SRC); + dst = nfct_get_attr(ct, ATTR_REPL_IPV6_SRC); + + id_src = hashtable_hash(f->h6, src); + id_dst = hashtable_hash(f->h6, dst); + + return hashtable_find(f->h6, src, id_src) || + hashtable_find(f->h6, dst, id_dst); +} + +static int +__ct_filter_test_mask4(const void *ptr, const void *ct) +{ + const struct ct_filter_netmask_ipv4 *elem = ptr; + const uint32_t src = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_SRC); + const uint32_t dst = nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC); + + return ((elem->ip & elem->mask) == (src & elem->mask) || + (elem->ip & elem->mask) == (dst & elem->mask)); +} + +static int +__ct_filter_test_mask6(const void *ptr, const void *ct) +{ + const struct ct_filter_netmask_ipv6 *elem = ptr; + const uint32_t *src = nfct_get_attr(ct, ATTR_ORIG_IPV6_SRC); + const uint32_t *dst = nfct_get_attr(ct, ATTR_REPL_IPV6_SRC); + + return (((elem->ip[0] & elem->mask[0]) == (src[0] & elem->mask[0]) && + (elem->ip[1] & elem->mask[1]) == (src[1] & elem->mask[1]) && + (elem->ip[2] & elem->mask[2]) == (src[2] & elem->mask[2]) && + (elem->ip[3] & elem->mask[3]) == (src[3] & elem->mask[3])) || + ((elem->ip[0] & elem->mask[0]) == (dst[0] & elem->mask[0]) && + (elem->ip[1] & elem->mask[1]) == (dst[1] & elem->mask[1]) && + (elem->ip[2] & elem->mask[2]) == (dst[2] & elem->mask[2]) && + (elem->ip[3] & elem->mask[3]) == (dst[3] & elem->mask[3]))); +} + +static int __ct_filter_test_state(struct ct_filter *f, struct nf_conntrack *ct) +{ + uint16_t val = 0; + uint8_t protonum = nfct_get_attr_u8(ct, ATTR_L4PROTO); + + switch(protonum) { + case IPPROTO_TCP: + if (!nfct_attr_is_set(ct, ATTR_TCP_STATE)) + return -1; + + val = nfct_get_attr_u8(ct, ATTR_TCP_STATE); + break; + default: + return -1; + } + + return test_bit_u16(val, &f->statemap[protonum]); +} + +static int ct_filter_check(struct ct_filter *f, struct nf_conntrack *ct) +{ + int ret, protonum = nfct_get_attr_u8(ct, ATTR_L4PROTO); + + /* no event filtering at all */ + if (f == NULL) + return 1; + + if (f->logic[CT_FILTER_L4PROTO] != -1) { + ret = test_bit_u32(protonum, f->l4protomap); + if (ret ^ f->logic[CT_FILTER_L4PROTO]) + return 0; + } + + if (f->logic[CT_FILTER_ADDRESS] != -1) { + switch(nfct_get_attr_u8(ct, ATTR_L3PROTO)) { + case AF_INET: + ret = vector_iterate(f->v, ct, __ct_filter_test_mask4); + if (ret ^ f->logic[CT_FILTER_ADDRESS]) + return 0; + ret = __ct_filter_test_ipv4(f, ct); + if (ret ^ f->logic[CT_FILTER_ADDRESS]) + return 0; + break; + case AF_INET6: + ret = vector_iterate(f->v6, ct, __ct_filter_test_mask6); + if (ret ^ f->logic[CT_FILTER_ADDRESS]) + return 0; + ret = __ct_filter_test_ipv6(f, ct); + if (ret ^ f->logic[CT_FILTER_ADDRESS]) + return 0; + break; + default: + break; + } + } + + if (f->logic[CT_FILTER_STATE] != -1) { + ret = __ct_filter_test_state(f, ct); + /* ret is -1 if we don't know what to do */ + if (ret != -1 && ret ^ f->logic[CT_FILTER_STATE]) + return 0; + } + + return 1; +} + +static inline int ct_filter_sanity_check(struct nf_conntrack *ct) +{ + if (!nfct_attr_is_set(ct, ATTR_L3PROTO)) { + dlog(LOG_ERR, "missing layer 3 protocol"); + return 0; + } + + switch(nfct_get_attr_u8(ct, ATTR_L3PROTO)) { + case AF_INET: + if (!nfct_attr_is_set(ct, ATTR_IPV4_SRC) || + !nfct_attr_is_set(ct, ATTR_IPV4_DST) || + !nfct_attr_is_set(ct, ATTR_REPL_IPV4_SRC) || + !nfct_attr_is_set(ct, ATTR_REPL_IPV4_DST)) { + dlog(LOG_ERR, "missing IPv4 address. " + "You forgot to load " + "nf_conntrack_ipv4?"); + return 0; + } + break; + case AF_INET6: + if (!nfct_attr_is_set(ct, ATTR_IPV6_SRC) || + !nfct_attr_is_set(ct, ATTR_IPV6_DST) || + !nfct_attr_is_set(ct, ATTR_REPL_IPV6_SRC) || + !nfct_attr_is_set(ct, ATTR_REPL_IPV6_DST)) { + dlog(LOG_ERR, "missing IPv6 address. " + "You forgot to load " + "nf_conntrack_ipv6?"); + return 0; + } + break; + } + return 1; +} + +/* we do user-space filtering for dump and resyncs */ +int ct_filter_conntrack(struct nf_conntrack *ct, int userspace) +{ + /* missing mandatory attributes in object */ + if (!ct_filter_sanity_check(ct)) + return 1; + + if (userspace && !ct_filter_check(STATE(us_filter), ct)) + return 1; + + return 0; +} diff --git a/src/hash.c b/src/hash.c new file mode 100644 index 0000000..fe6a047 --- /dev/null +++ b/src/hash.c @@ -0,0 +1,143 @@ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: generic hash table implementation + */ + +#include "hash.h" + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> + +struct hashtable * +hashtable_create(int hashsize, int limit, + uint32_t (*hash)(const void *data, + const struct hashtable *table), + int (*compare)(const void *data1, const void *data2)) +{ + int i; + struct hashtable *h; + int size = sizeof(struct hashtable) + + hashsize * sizeof(struct list_head); + + h = (struct hashtable *) calloc(size, 1); + if (h == NULL) { + errno = ENOMEM; + return NULL; + } + + for (i=0; i<hashsize; i++) + INIT_LIST_HEAD(&h->members[i]); + + h->hashsize = hashsize; + h->limit = limit; + h->hash = hash; + h->compare = compare; + + return h; +} + +void hashtable_destroy(struct hashtable *h) +{ + free(h); +} + +int hashtable_hash(const struct hashtable *table, const void *data) +{ + return table->hash(data, table); +} + +struct hashtable_node * +hashtable_find(const struct hashtable *table, const void *data, int id) +{ + struct list_head *e; + struct hashtable_node *n; + + list_for_each(e, &table->members[id]) { + n = list_entry(e, struct hashtable_node, head); + if (table->compare(n, data)) { + return n; + } + } + errno = ENOENT; + return NULL; +} + +int hashtable_add(struct hashtable *table, struct hashtable_node *n, int id) +{ + /* hash table is full */ + if (table->count >= table->limit) { + errno = ENOSPC; + return -1; + } + list_add(&n->head, &table->members[id]); + table->count++; + return 0; +} + +void hashtable_del(struct hashtable *table, struct hashtable_node *n) +{ + list_del(&n->head); + table->count--; +} + +int hashtable_flush(struct hashtable *table) +{ + uint32_t i; + struct list_head *e, *tmp; + struct hashtable_node *n; + + for (i=0; i < table->hashsize; i++) { + list_for_each_safe(e, tmp, &table->members[i]) { + n = list_entry(e, struct hashtable_node, head); + free(n); + } + } + return 0; +} + +int +hashtable_iterate_limit(struct hashtable *table, void *data, + uint32_t from, uint32_t steps, + int (*iterate)(void *data1, void *n)) +{ + uint32_t i; + struct list_head *e, *tmp; + struct hashtable_node *n; + + for (i=from; i < table->hashsize && i < from+steps; i++) { + list_for_each_safe(e, tmp, &table->members[i]) { + n = list_entry(e, struct hashtable_node, head); + if (iterate(data, n) == -1) + return -1; + } + } + return i; +} + +int hashtable_iterate(struct hashtable *table, void *data, + int (*iterate)(void *data1, void *n)) +{ + return hashtable_iterate_limit(table, data, 0, UINT_MAX, iterate); +} + +unsigned int hashtable_counter(const struct hashtable *table) +{ + return table->count; +} diff --git a/src/internal_bypass.c b/src/internal_bypass.c new file mode 100644 index 0000000..4caaf4f --- /dev/null +++ b/src/internal_bypass.c @@ -0,0 +1,165 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This feature has been sponsored by 6WIND <www.6wind.com>. + */ +#include "conntrackd.h" +#include "sync.h" +#include "log.h" +#include "cache.h" +#include "netlink.h" +#include "network.h" +#include "origin.h" + +static int _init(void) +{ + return 0; +} + +static void _close(void) +{ +} + +static int dump_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, void *data) +{ + char buf[1024]; + int size, *fd = data; + + size = nfct_snprintf(buf, 1024, ct, NFCT_T_UNKNOWN, NFCT_O_DEFAULT, 0); + if (size < 1024) { + buf[size] = '\n'; + size++; + } + send(*fd, buf, size, 0); + + return NFCT_CB_CONTINUE; +} + +static void dump(int fd, int type) +{ + struct nfct_handle *h; + u_int32_t family = AF_UNSPEC; + int ret; + + h = nfct_open(CONNTRACK, 0); + if (h == NULL) { + dlog(LOG_ERR, "can't allocate memory for the internal cache"); + return; + } + nfct_callback_register(h, NFCT_T_ALL, dump_cb, &fd); + ret = nfct_query(h, NFCT_Q_DUMP, &family); + if (ret == -1) { + dlog(LOG_ERR, "can't dump kernel table"); + } + nfct_close(h); +} + +static void flush(void) +{ + nl_flush_conntrack_table(STATE(flush)); +} + +struct { + uint32_t new; + uint32_t upd; + uint32_t del; +} internal_bypass_stats; + +static void stats(int fd) +{ + char buf[512]; + int size; + + size = sprintf(buf, "internal bypass:\n" + "connections new:\t\t%12u\n" + "connections updated:\t\t%12u\n" + "connections destroyed:\t\t%12u\n\n", + internal_bypass_stats.new, + internal_bypass_stats.upd, + internal_bypass_stats.del); + + send(fd, buf, size, 0); +} + +/* unused, INTERNAL_F_POPULATE is unset. No cache, nothing to populate. */ +static void populate(struct nf_conntrack *ct) +{ +} + +/* unused, INTERNAL_F_RESYNC is unset. */ +static void purge(void) +{ +} + +/* unused, INTERNAL_F_RESYNC is unset. Nothing to resync, we have no cache. */ +static int resync(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + return NFCT_CB_CONTINUE; +} + +static void +event_new_sync(struct nf_conntrack *ct, int origin) +{ + struct nethdr *net; + + /* this event has been triggered by me, skip */ + if (origin != CTD_ORIGIN_NOT_ME) + return; + + net = BUILD_NETMSG(ct, NET_T_STATE_NEW); + multichannel_send(STATE_SYNC(channel), net); + internal_bypass_stats.new++; +} + +static void +event_update_sync(struct nf_conntrack *ct, int origin) +{ + struct nethdr *net; + + /* this event has been triggered by me, skip */ + if (origin != CTD_ORIGIN_NOT_ME) + return; + + net = BUILD_NETMSG(ct, NET_T_STATE_UPD); + multichannel_send(STATE_SYNC(channel), net); + internal_bypass_stats.upd++; +} + +static int +event_destroy_sync(struct nf_conntrack *ct, int origin) +{ + struct nethdr *net; + + /* this event has been triggered by me, skip */ + if (origin != CTD_ORIGIN_NOT_ME) + return 1; + + net = BUILD_NETMSG(ct, NET_T_STATE_DEL); + multichannel_send(STATE_SYNC(channel), net); + internal_bypass_stats.del++; + + return 1; +} + +struct internal_handler internal_bypass = { + .init = _init, + .close = _close, + .dump = dump, + .flush = flush, + .stats = stats, + .stats_ext = stats, + .populate = populate, + .purge = purge, + .resync = resync, + .new = event_new_sync, + .update = event_update_sync, + .destroy = event_destroy_sync, +}; diff --git a/src/internal_cache.c b/src/internal_cache.c new file mode 100644 index 0000000..daadfd6 --- /dev/null +++ b/src/internal_cache.c @@ -0,0 +1,220 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include "conntrackd.h" +#include "sync.h" +#include "log.h" +#include "cache.h" +#include "netlink.h" +#include "network.h" +#include "origin.h" + +static inline void sync_send(struct cache_object *obj, int query) +{ + STATE_SYNC(sync)->enqueue(obj, query); +} + +static int _init(void) +{ + STATE(mode)->internal->data = + cache_create("internal", + STATE_SYNC(sync)->internal_cache_flags, + STATE_SYNC(sync)->internal_cache_extra); + + if (!STATE(mode)->internal->data) { + dlog(LOG_ERR, "can't allocate memory for the internal cache"); + return -1; + } + return 0; +} + +static void _close(void) +{ + cache_destroy(STATE(mode)->internal->data); +} + +static void dump(int fd, int type) +{ + cache_dump(STATE(mode)->internal->data, fd, NFCT_O_PLAIN); +} + +static void flush(void) +{ + cache_flush(STATE(mode)->internal->data); +} + +static void stats(int fd) +{ + cache_stats(STATE(mode)->internal->data, fd); +} + +static void stats_ext(int fd) +{ + cache_stats_extended(STATE(mode)->internal->data, fd); +} + +static void populate(struct nf_conntrack *ct) +{ + /* This is required by kernels < 2.6.20 */ + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_USE); + + cache_update_force(STATE(mode)->internal->data, ct); +} + +static int purge_step(void *data1, void *data2) +{ + struct cache_object *obj = data2; + + STATE(get_retval) = 0; + nl_get_conntrack(STATE(get), obj->ct); /* modifies STATE(get_reval) */ + if (!STATE(get_retval)) { + if (obj->status != C_OBJ_DEAD) { + cache_object_set_status(obj, C_OBJ_DEAD); + sync_send(obj, NET_T_STATE_DEL); + cache_object_put(obj); + } + } + + return 0; +} + +static void purge(void) +{ + cache_iterate(STATE(mode)->internal->data, NULL, purge_step); +} + +static int resync(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + struct cache_object *obj; + + if (ct_filter_conntrack(ct, 1)) + return NFCT_CB_CONTINUE; + + /* This is required by kernels < 2.6.20 */ + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_USE); + + obj = cache_update_force(STATE(mode)->internal->data, ct); + if (obj == NULL) + return NFCT_CB_CONTINUE; + + switch (obj->status) { + case C_OBJ_NEW: + sync_send(obj, NET_T_STATE_NEW); + break; + case C_OBJ_ALIVE: + sync_send(obj, NET_T_STATE_UPD); + break; + } + return NFCT_CB_CONTINUE; +} + +static void +event_new_sync(struct nf_conntrack *ct, int origin) +{ + struct cache_object *obj; + int id; + + /* this event has been triggered by a direct inject, skip */ + if (origin == CTD_ORIGIN_INJECT) + return; + + /* required by linux kernel <= 2.6.20 */ + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); + + obj = cache_find(STATE(mode)->internal->data, ct, &id); + if (obj == NULL) { +retry: + obj = cache_object_new(STATE(mode)->internal->data, ct); + if (obj == NULL) + return; + if (cache_add(STATE(mode)->internal->data, obj, id) == -1) { + cache_object_free(obj); + return; + } + /* only synchronize events that have been triggered by other + * processes or the kernel, but don't propagate events that + * have been triggered by conntrackd itself, eg. commits. */ + if (origin == CTD_ORIGIN_NOT_ME) + sync_send(obj, NET_T_STATE_NEW); + } else { + cache_del(STATE(mode)->internal->data, obj); + cache_object_free(obj); + goto retry; + } +} + +static void +event_update_sync(struct nf_conntrack *ct, int origin) +{ + struct cache_object *obj; + + /* this event has been triggered by a direct inject, skip */ + if (origin == CTD_ORIGIN_INJECT) + return; + + obj = cache_update_force(STATE(mode)->internal->data, ct); + if (obj == NULL) + return; + + if (origin == CTD_ORIGIN_NOT_ME) + sync_send(obj, NET_T_STATE_UPD); +} + +static int +event_destroy_sync(struct nf_conntrack *ct, int origin) +{ + struct cache_object *obj; + int id; + + /* this event has been triggered by a direct inject, skip */ + if (origin == CTD_ORIGIN_INJECT) + return 0; + + /* we don't synchronize events for objects that are not in the cache */ + obj = cache_find(STATE(mode)->internal->data, ct, &id); + if (obj == NULL) + return 0; + + if (obj->status != C_OBJ_DEAD) { + cache_object_set_status(obj, C_OBJ_DEAD); + if (origin == CTD_ORIGIN_NOT_ME) { + sync_send(obj, NET_T_STATE_DEL); + } + cache_object_put(obj); + } + return 1; +} + +struct internal_handler internal_cache = { + .flags = INTERNAL_F_POPULATE | INTERNAL_F_RESYNC, + .init = _init, + .close = _close, + .dump = dump, + .flush = flush, + .stats = stats, + .stats_ext = stats_ext, + .populate = populate, + .purge = purge, + .resync = resync, + .new = event_new_sync, + .update = event_update_sync, + .destroy = event_destroy_sync, +}; diff --git a/src/local.c b/src/local.c new file mode 100644 index 0000000..feff608 --- /dev/null +++ b/src/local.c @@ -0,0 +1,158 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: UNIX sockets library + */ + +#include "local.h" + +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <arpa/inet.h> +#include <sys/un.h> + +int local_server_create(struct local_server *server, struct local_conf *conf) +{ + int fd; + socklen_t len; + struct sockaddr_un local; + + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + return -1; + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &conf->reuseaddr, + sizeof(conf->reuseaddr)) == -1) { + close(fd); + unlink(conf->path); + return -1; + } + + local.sun_family = AF_UNIX; + strcpy(local.sun_path, conf->path); + len = strlen(local.sun_path) + sizeof(local.sun_family); + unlink(conf->path); + + if (bind(fd, (struct sockaddr *) &local, len) == -1) { + close(fd); + unlink(conf->path); + return -1; + } + + if (listen(fd, conf->backlog) == -1) { + close(fd); + unlink(conf->path); + return -1; + } + + server->fd = fd; + strcpy(server->path, conf->path); + + return 0; +} + +void local_server_destroy(struct local_server *server) +{ + unlink(server->path); + close(server->fd); +} + +int do_local_server_step(struct local_server *server, void *data, + int (*process)(int fd, void *data)) +{ + int rfd; + struct sockaddr_un local; + socklen_t sin_size = sizeof(struct sockaddr_un); + + rfd = accept(server->fd, (struct sockaddr *) &local, &sin_size); + if (rfd == -1) + return -1; + + /* This descriptor will be closed later, we ignore OK and errors */ + if (process(rfd, data) != LOCAL_RET_STOLEN) + close(rfd); + + return 0; +} + +int local_client_create(struct local_conf *conf) +{ + socklen_t len; + struct sockaddr_un local; + int fd; + + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + return -1; + + local.sun_family = AF_UNIX; + strcpy(local.sun_path, conf->path); + len = strlen(local.sun_path) + sizeof(local.sun_family); + + if (connect(fd, (struct sockaddr *) &local, len) == -1) { + close(fd); + return -1; + } + + return fd; +} + +void local_client_destroy(int fd) +{ + close(fd); +} + +int do_local_client_step(int fd, void (*process)(char *buf)) +{ + int numbytes; + char buf[1024]; + + memset(buf, 0, sizeof(buf)); + while ((numbytes = recv(fd, buf, sizeof(buf)-1, 0)) > 0) { + buf[sizeof(buf)-1] = '\0'; + if (process) + process(buf); + memset(buf, 0, sizeof(buf)); + } + + return 0; +} + +void local_step(char *buf) +{ + printf("%s", buf); +} + +int do_local_request(int request, + struct local_conf *conf, + void (*step)(char *buf)) +{ + int fd, ret; + + fd = local_client_create(conf); + if (fd == -1) + return -1; + + ret = send(fd, &request, sizeof(int), 0); + if (ret == -1) + return -1; + + do_local_client_step(fd, step); + + local_client_destroy(fd); + + return 0; +} diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..9fe5119 --- /dev/null +++ b/src/log.c @@ -0,0 +1,159 @@ +/* + * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: Logging support for the conntrack daemon + */ + +#include "log.h" +#include "conntrackd.h" + +#include <time.h> +#include <stdarg.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> + +int init_log(void) +{ + if (CONFIG(logfile)[0]) { + STATE(log) = fopen(CONFIG(logfile), "a+"); + if (STATE(log) == NULL) { + fprintf(stderr, "ERROR: can't open logfile `%s'." + "Reason: %s\n", CONFIG(logfile), + strerror(errno)); + return -1; + } + + setlinebuf(STATE(log)); + } + + if (CONFIG(stats).logfile[0]) { + STATE(stats_log) = fopen(CONFIG(stats).logfile, "a+"); + if (STATE(stats_log) == NULL) { + fprintf(stderr, "ERROR: can't open logfile `%s'." + "Reason: %s\n", CONFIG(stats).logfile, + strerror(errno)); + return -1; + } + + setlinebuf(STATE(stats_log)); + } + + if (CONFIG(syslog_facility) != -1 || + CONFIG(stats).syslog_facility != -1) + openlog(PACKAGE, LOG_PID, CONFIG(syslog_facility)); + + return 0; +} + +void dlog(int priority, const char *format, ...) + { + FILE *fd = STATE(log); + time_t t; + char *buf; + const char *prio; + va_list args; + + if (fd) { + t = time(NULL); + buf = ctime(&t); + buf[strlen(buf)-1]='\0'; + switch (priority) { + case LOG_INFO: + prio = "info"; + break; + case LOG_NOTICE: + prio = "notice"; + break; + case LOG_WARNING: + prio = "warning"; + break; + case LOG_ERR: + prio = "ERROR"; + break; + default: + prio = "?"; + break; + } + va_start(args, format); + fprintf(fd, "[%s] (pid=%d) [%s] ", buf, getpid(), prio); + vfprintf(fd, format, args); + va_end(args); + fprintf(fd, "\n"); + fflush(fd); + } + + if (CONFIG(syslog_facility) != -1) { + va_start(args, format); + vsyslog(priority, format, args); + va_end(args); + } +} + +void dlog_ct(FILE *fd, struct nf_conntrack *ct, unsigned int type) +{ + time_t t; + char buf[1024]; + char *tmp; + unsigned int flags = 0; + + buf[0]='\0'; + + switch(type) { + case NFCT_O_PLAIN: + t = time(NULL); + ctime_r(&t, buf); + tmp = buf + strlen(buf); + buf[strlen(buf)-1]='\t'; + break; + case NFCT_O_XML: + tmp = buf; + flags |= NFCT_OF_TIME; + break; + default: + return; + } + nfct_snprintf(buf+strlen(buf), 1024-strlen(buf), ct, 0, type, flags); + + if (fd) { + snprintf(buf+strlen(buf), 1024-strlen(buf), "\n"); + fputs(buf, fd); + } + + if (fd == STATE(log)) { + /* error reporting */ + if (CONFIG(syslog_facility) != -1) + syslog(LOG_ERR, "%s", tmp); + } else if (fd == STATE(stats_log)) { + /* connection logging */ + if (CONFIG(stats).syslog_facility != -1) + syslog(LOG_INFO, "%s", tmp); + } +} + +void close_log(void) +{ + if (STATE(log) != NULL) + fclose(STATE(log)); + + if (STATE(stats_log) != NULL) + fclose(STATE(stats_log)); + + if (CONFIG(syslog_facility) != -1 || + CONFIG(stats).syslog_facility != -1) + closelog(); +} diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..4ead2ea --- /dev/null +++ b/src/main.c @@ -0,0 +1,363 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "conntrackd.h" +#include "log.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/utsname.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <sched.h> +#include <limits.h> + +struct ct_general_state st; +union ct_state state; + +static const char usage_daemon_commands[] = + "Daemon mode commands:\n" + " -d [options]\t\tRun in daemon mode\n"; + +static const char usage_client_commands[] = + "Client mode commands:\n" + " -c, commit external cache to conntrack table\n" + " -f [|internal|external], flush internal and external cache\n" + " -F, flush kernel conntrack table\n" + " -i, display content of the internal cache\n" + " -e, display the content of the external cache\n" + " -k, kill conntrack daemon\n" + " -s [|network|cache|runtime|link|rsqueue|queue], dump statistics\n" + " -R, resync with kernel conntrack table\n" + " -n, request resync with other node (only FT-FW and NOTRACK modes)\n" + " -x, dump cache in XML format (requires -i or -e)\n" + " -t, reset the kernel timeout (see PurgeTimeout clause)\n" + " -v, display conntrackd version\n" + " -h, display this help information\n"; + +static const char usage_options[] = + "Options:\n" + " -C [configfile], configuration file path\n"; + +static void +show_usage(char *progname) +{ + fprintf(stdout, "Connection tracking userspace daemon v%s\n", VERSION); + fprintf(stdout, "Usage: %s [commands] [options]\n\n", progname); + fprintf(stdout, "%s\n", usage_daemon_commands); + fprintf(stdout, "%s\n", usage_client_commands); + fprintf(stdout, "%s\n", usage_options); +} + +static void +show_version(void) +{ + fprintf(stdout, "Connection tracking userspace daemon v%s. ", VERSION); + fprintf(stdout, "Licensed under GPLv2.\n"); + fprintf(stdout, "(C) 2006-2009 Pablo Neira Ayuso "); + fprintf(stdout, "<pablo@netfilter.org>\n"); +} + +static void +set_operation_mode(int *current, int want, char *argv[]) +{ + if (*current == NOT_SET) { + *current = want; + return; + } + if (*current != want) { + show_usage(argv[0]); + fprintf(stderr, "\nError: Invalid parameters\n"); + exit(EXIT_FAILURE); + } +} + +int main(int argc, char *argv[]) +{ + int ret, i, action = -1; + char config_file[PATH_MAX] = {}; + int type = 0; + struct utsname u; + int version, major, minor; + + /* Check kernel version: it must be >= 2.6.18 */ + if (uname(&u) == -1) { + fprintf(stderr, "Can't retrieve kernel version via uname()\n"); + exit(EXIT_FAILURE); + } + sscanf(u.release, "%d.%d.%d", &version, &major, &minor); + if (version < 2 && major < 6 && minor < 18) { + fprintf(stderr, "Linux kernel version must be >= 2.6.18\n"); + exit(EXIT_FAILURE); + } + + for (i=1; i<argc; i++) { + switch(argv[i][1]) { + case 'd': + set_operation_mode(&type, DAEMON, argv); + break; + case 'c': + set_operation_mode(&type, REQUEST, argv); + action = COMMIT; + break; + case 'i': + set_operation_mode(&type, REQUEST, argv); + action = DUMP_INTERNAL; + break; + case 'e': + set_operation_mode(&type, REQUEST, argv); + action = DUMP_EXTERNAL; + break; + case 'C': + if (++i < argc) { + strncpy(config_file, argv[i], PATH_MAX); + if (strlen(argv[i]) >= PATH_MAX){ + config_file[PATH_MAX-1]='\0'; + fprintf(stderr, "Path to config file " + "to long. Cutting it " + "down to %d characters", + PATH_MAX); + } + break; + } + show_usage(argv[0]); + fprintf(stderr, "Missing config filename\n"); + break; + case 'F': + set_operation_mode(&type, REQUEST, argv); + action = FLUSH_MASTER; + break; + case 'f': + set_operation_mode(&type, REQUEST, argv); + if (i+1 < argc && argv[i+1][0] != '-') { + if (strncmp(argv[i+1], "internal", + strlen(argv[i+1])) == 0) { + action = FLUSH_INT_CACHE; + i++; + } else if (strncmp(argv[i+1], "external", + strlen(argv[i+1])) == 0) { + action = FLUSH_EXT_CACHE; + i++; + } else { + fprintf(stderr, "ERROR: unknown " + "parameter `%s' for " + "option `-f'\n", + argv[i+1]); + exit(EXIT_FAILURE); + } + } else { + /* default to general flushing */ + action = FLUSH_CACHE; + } + break; + case 'R': + set_operation_mode(&type, REQUEST, argv); + action = RESYNC_MASTER; + break; + case 'B': + set_operation_mode(&type, REQUEST, argv); + action = SEND_BULK; + break; + case 't': + set_operation_mode(&type, REQUEST, argv); + action = RESET_TIMERS; + break; + case 'k': + set_operation_mode(&type, REQUEST, argv); + action = KILL; + break; + case 's': + set_operation_mode(&type, REQUEST, argv); + /* we've got a parameter */ + if (i+1 < argc && argv[i+1][0] != '-') { + if (strncmp(argv[i+1], "network", + strlen(argv[i+1])) == 0) { + action = STATS_NETWORK; + i++; + } else if (strncmp(argv[i+1], "cache", + strlen(argv[i+1])) == 0) { + action = STATS_CACHE; + i++; + } else if (strncmp(argv[i+1], "runtime", + strlen(argv[i+1])) == 0) { + action = STATS_RUNTIME; + i++; + } else if (strncmp(argv[i+1], "multicast", + strlen(argv[i+1])) == 0) { + fprintf(stderr, "WARNING: use `link' " + "instead of `multicast' as " + "parameter.\n"); + action = STATS_LINK; + i++; + } else if (strncmp(argv[i+1], "link", + strlen(argv[i+1])) == 0) { + action = STATS_LINK; + i++; + } else if (strncmp(argv[i+1], "rsqueue", + strlen(argv[i+1])) == 0) { + action = STATS_RSQUEUE; + i++; + } else if (strncmp(argv[i+1], "process", + strlen(argv[i+1])) == 0) { + action = STATS_PROCESS; + i++; + } else if (strncmp(argv[i+1], "queue", + strlen(argv[i+1])) == 0) { + action = STATS_QUEUE; + i++; + } else { + fprintf(stderr, "ERROR: unknown " + "parameter `%s' for " + "option `-s'\n", + argv[i+1]); + exit(EXIT_FAILURE); + } + } else { + /* default to general statistics */ + action = STATS; + } + break; + case 'S': + fprintf(stderr, "WARNING: -S option is obsolete. " + "Ignoring.\n"); + break; + case 'n': + set_operation_mode(&type, REQUEST, argv); + action = REQUEST_DUMP; + break; + case 'x': + if (action == DUMP_INTERNAL) + action = DUMP_INT_XML; + else if (action == DUMP_EXTERNAL) + action = DUMP_EXT_XML; + else { + show_usage(argv[0]); + fprintf(stderr, "Error: Invalid parameters\n"); + exit(EXIT_FAILURE); + + } + break; + case 'v': + show_version(); + exit(EXIT_SUCCESS); + case 'h': + show_usage(argv[0]); + exit(EXIT_SUCCESS); + default: + show_usage(argv[0]); + fprintf(stderr, "Unknown option: %s\n", argv[i]); + return 0; + break; + } + } + + if (!config_file[0]) + strcpy(config_file, DEFAULT_CONFIGFILE); + + umask(0177); + + if ((ret = init_config(config_file)) == -1) { + fprintf(stderr, "can't open config file `%s'\n", config_file); + exit(EXIT_FAILURE); + } + + if (type == REQUEST) { + if (do_local_request(action, &conf.local, local_step) == -1) { + fprintf(stderr, "can't connect: is conntrackd " + "running? appropriate permissions?\n"); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); + } + + /* + * Setting up logging + */ + if (init_log() == -1) + exit(EXIT_FAILURE); + + /* + * lock file + */ + ret = open(CONFIG(lockfile), O_CREAT | O_EXCL | O_TRUNC, 0600); + if (ret == -1) { + fprintf(stderr, "lockfile `%s' exists, perhaps conntrackd " + "already running?\n", CONFIG(lockfile)); + exit(EXIT_FAILURE); + } + close(ret); + + /* + * Setting process priority and scheduler + */ + nice(CONFIG(nice)); + + if (CONFIG(sched).type != SCHED_OTHER) { + struct sched_param schedparam = { + .sched_priority = CONFIG(sched).prio, + }; + + ret = sched_setscheduler(0, CONFIG(sched).type, &schedparam); + if (ret == -1) { + perror("sched"); + exit(EXIT_FAILURE); + } + } + + /* + * initialization process + */ + + if (init() == -1) { + close_log(); + fprintf(stderr, "ERROR: conntrackd cannot start, please " + "check the logfile for more info\n"); + unlink(CONFIG(lockfile)); + exit(EXIT_FAILURE); + } + + chdir("/"); + close(STDIN_FILENO); + + /* Daemonize conntrackd */ + if (type == DAEMON) { + pid_t pid; + + if ((pid = fork()) == -1) { + perror("fork has failed: "); + exit(EXIT_FAILURE); + } else if (pid) + exit(EXIT_SUCCESS); + + setsid(); + + close(STDOUT_FILENO); + close(STDERR_FILENO); + + dlog(LOG_NOTICE, "-- starting in daemon mode --"); + } else + dlog(LOG_NOTICE, "-- starting in console mode --"); + + /* + * run main process + */ + run(); + return 0; +} diff --git a/src/mcast.c b/src/mcast.c new file mode 100644 index 0000000..4107d5d --- /dev/null +++ b/src/mcast.c @@ -0,0 +1,358 @@ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: multicast socket library + */ + +#include "mcast.h" + +#include <stdio.h> +#include <stdlib.h> +#include <arpa/inet.h> +#include <unistd.h> +#include <string.h> +#include <sys/ioctl.h> +#include <net/if.h> +#include <errno.h> +#include <limits.h> +#include <libnfnetlink/libnfnetlink.h> + +struct mcast_sock *mcast_server_create(struct mcast_conf *conf) +{ + int yes = 1; + union { + struct ip_mreq ipv4; + struct ipv6_mreq ipv6; + } mreq; + struct mcast_sock *m; + socklen_t socklen = sizeof(int); + + m = (struct mcast_sock *) malloc(sizeof(struct mcast_sock)); + if (!m) + return NULL; + memset(m, 0, sizeof(struct mcast_sock)); + + switch(conf->ipproto) { + case AF_INET: + mreq.ipv4.imr_multiaddr.s_addr = conf->in.inet_addr.s_addr; + mreq.ipv4.imr_interface.s_addr =conf->ifa.interface_addr.s_addr; + + m->addr.ipv4.sin_family = AF_INET; + m->addr.ipv4.sin_port = htons(conf->port); + m->addr.ipv4.sin_addr.s_addr = htonl(INADDR_ANY); + + m->sockaddr_len = sizeof(struct sockaddr_in); + break; + + case AF_INET6: + memcpy(&mreq.ipv6.ipv6mr_multiaddr, &conf->in.inet_addr6, + sizeof(uint32_t) * 4); + mreq.ipv6.ipv6mr_interface = conf->ifa.interface_index6; + + m->addr.ipv6.sin6_family = AF_INET6; + m->addr.ipv6.sin6_port = htons(conf->port); + m->addr.ipv6.sin6_addr = in6addr_any; + + m->sockaddr_len = sizeof(struct sockaddr_in6); + break; + } + + if ((m->fd = socket(conf->ipproto, SOCK_DGRAM, 0)) == -1) { + free(m); + return NULL; + } + + if (setsockopt(m->fd, SOL_SOCKET, SO_REUSEADDR, &yes, + sizeof(int)) == -1) { + close(m->fd); + free(m); + return NULL; + } + +#ifndef SO_RCVBUFFORCE +#define SO_RCVBUFFORCE 33 +#endif + + if (conf->rcvbuf && + setsockopt(m->fd, SOL_SOCKET, SO_RCVBUFFORCE, &conf->rcvbuf, + sizeof(int)) == -1) { + /* not supported in linux kernel < 2.6.14 */ + if (errno != ENOPROTOOPT) { + close(m->fd); + free(m); + return NULL; + } + } + + getsockopt(m->fd, SOL_SOCKET, SO_RCVBUF, &conf->rcvbuf, &socklen); + + if (bind(m->fd, (struct sockaddr *) &m->addr, m->sockaddr_len) == -1) { + close(m->fd); + free(m); + return NULL; + } + + switch(conf->ipproto) { + case AF_INET: + if (setsockopt(m->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, + &mreq.ipv4, sizeof(mreq.ipv4)) < 0) { + close(m->fd); + free(m); + return NULL; + } + break; + case AF_INET6: + if (setsockopt(m->fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, + &mreq.ipv6, sizeof(mreq.ipv6)) < 0) { + close(m->fd); + free(m); + return NULL; + } + break; + } + + return m; +} + +void mcast_server_destroy(struct mcast_sock *m) +{ + close(m->fd); + free(m); +} + +static int +__mcast_client_create_ipv4(struct mcast_sock *m, struct mcast_conf *conf) +{ + int no = 0; + + m->addr.ipv4.sin_family = AF_INET; + m->addr.ipv4.sin_port = htons(conf->port); + m->addr.ipv4.sin_addr = conf->in.inet_addr; + m->sockaddr_len = sizeof(struct sockaddr_in); + + if (setsockopt(m->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &no, + sizeof(int)) < 0) { + close(m->fd); + return -1; + } + + if (setsockopt(m->fd, IPPROTO_IP, IP_MULTICAST_IF, + &conf->ifa.interface_addr, + sizeof(struct in_addr)) == -1) { + close(m->fd); + return -1; + } + + return 0; +} + +static int +__mcast_client_create_ipv6(struct mcast_sock *m, struct mcast_conf *conf) +{ + int no = 0; + + m->addr.ipv6.sin6_family = AF_INET6; + m->addr.ipv6.sin6_port = htons(conf->port); + memcpy(&m->addr.ipv6.sin6_addr, + &conf->in.inet_addr6, + sizeof(struct in6_addr)); + m->sockaddr_len = sizeof(struct sockaddr_in6); + + if (setsockopt(m->fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &no, + sizeof(int)) < 0) { + close(m->fd); + return -1; + } + + if (setsockopt(m->fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, + &conf->ifa.interface_index6, + sizeof(unsigned int)) == -1) { + close(m->fd); + return -1; + } + + return 0; +} + +struct mcast_sock *mcast_client_create(struct mcast_conf *conf) +{ + int ret; + struct mcast_sock *m; + socklen_t socklen = sizeof(int); + + m = (struct mcast_sock *) malloc(sizeof(struct mcast_sock)); + if (!m) + return NULL; + memset(m, 0, sizeof(struct mcast_sock)); + + if ((m->fd = socket(conf->ipproto, SOCK_DGRAM, 0)) == -1) { + free(m); + return NULL; + } + + if (setsockopt(m->fd, SOL_SOCKET, SO_NO_CHECK, &conf->checksum, + sizeof(int)) == -1) { + close(m->fd); + free(m); + return NULL; + } + +#ifndef SO_SNDBUFFORCE +#define SO_SNDBUFFORCE 32 +#endif + + if (conf->sndbuf && + setsockopt(m->fd, SOL_SOCKET, SO_SNDBUFFORCE, &conf->sndbuf, + sizeof(int)) == -1) { + /* not supported in linux kernel < 2.6.14 */ + if (errno != ENOPROTOOPT) { + close(m->fd); + free(m); + return NULL; + } + } + + getsockopt(m->fd, SOL_SOCKET, SO_SNDBUF, &conf->sndbuf, &socklen); + + switch(conf->ipproto) { + case AF_INET: + ret = __mcast_client_create_ipv4(m, conf); + break; + case AF_INET6: + ret = __mcast_client_create_ipv6(m, conf); + break; + default: + ret = 0; + break; + } + + if (ret == -1) { + close(m->fd); + free(m); + m = NULL; + } + + return m; +} + +void mcast_client_destroy(struct mcast_sock *m) +{ + close(m->fd); + free(m); +} + +ssize_t mcast_send(struct mcast_sock *m, const void *data, int size) +{ + ssize_t ret; + + ret = sendto(m->fd, + data, + size, + 0, + (struct sockaddr *) &m->addr, + m->sockaddr_len); + if (ret == -1) { + m->stats.error++; + return ret; + } + + m->stats.bytes += ret; + m->stats.messages++; + + return ret; +} + +ssize_t mcast_recv(struct mcast_sock *m, void *data, int size) +{ + ssize_t ret; + socklen_t sin_size = sizeof(struct sockaddr_in); + + ret = recvfrom(m->fd, + data, + size, + 0, + (struct sockaddr *)&m->addr, + &sin_size); + if (ret == -1) { + if (errno != EAGAIN) + m->stats.error++; + return ret; + } + + m->stats.bytes += ret; + m->stats.messages++; + + return ret; +} + +int mcast_get_fd(struct mcast_sock *m) +{ + return m->fd; +} + +int mcast_isset(struct mcast_sock *m, fd_set *readfds) +{ + return FD_ISSET(m->fd, readfds); +} + +int +mcast_snprintf_stats(char *buf, size_t buflen, char *ifname, + struct mcast_stats *s, struct mcast_stats *r) +{ + size_t size; + + size = snprintf(buf, buflen, "multicast traffic (active device=%s):\n" + "%20llu Bytes sent " + "%20llu Bytes recv\n" + "%20llu Pckts sent " + "%20llu Pckts recv\n" + "%20llu Error send " + "%20llu Error recv\n\n", + ifname, + (unsigned long long)s->bytes, + (unsigned long long)r->bytes, + (unsigned long long)s->messages, + (unsigned long long)r->messages, + (unsigned long long)s->error, + (unsigned long long)r->error); + return size; +} + +int +mcast_snprintf_stats2(char *buf, size_t buflen, const char *ifname, + const char *status, int active, + struct mcast_stats *s, struct mcast_stats *r) +{ + size_t size; + + size = snprintf(buf, buflen, + "multicast traffic device=%s status=%s role=%s:\n" + "%20llu Bytes sent " + "%20llu Bytes recv\n" + "%20llu Pckts sent " + "%20llu Pckts recv\n" + "%20llu Error send " + "%20llu Error recv\n\n", + ifname, status, active ? "ACTIVE" : "BACKUP", + (unsigned long long)s->bytes, + (unsigned long long)r->bytes, + (unsigned long long)s->messages, + (unsigned long long)r->messages, + (unsigned long long)s->error, + (unsigned long long)r->error); + return size; +} diff --git a/src/multichannel.c b/src/multichannel.c new file mode 100644 index 0000000..de69d5c --- /dev/null +++ b/src/multichannel.c @@ -0,0 +1,116 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <stdlib.h> + +#include "channel.h" +#include "network.h" + +struct multichannel * +multichannel_open(struct channel_conf *conf, int len) +{ + struct multichannel *m; + int i, set_default_channel = 0; + + if (len <= 0 || len > MULTICHANNEL_MAX) + return NULL; + + m = calloc(sizeof(struct multichannel), 1); + if (m == NULL) + return NULL; + + m->channel_num = len; + for (i = 0; i < len; i++) { + m->channel[i] = channel_open(&conf[i]); + if (m->channel[i] == NULL) { + int j; + + for (j=0; j<i; j++) { + channel_close(m->channel[j]); + } + free(m); + return NULL; + } + if (conf[i].channel_flags & CHANNEL_F_DEFAULT) { + m->current = m->channel[i]; + set_default_channel = 1; + } + } + if (!set_default_channel) + m->current = m->channel[0]; + + return m; +} + +int multichannel_send(struct multichannel *c, const struct nethdr *net) +{ + return channel_send(c->current, net); +} + +int multichannel_send_flush(struct multichannel *c) +{ + return channel_send_flush(c->current); +} + +int multichannel_recv(struct multichannel *c, char *buf, int size) +{ + return channel_recv(c->current, buf, size); +} + +void multichannel_close(struct multichannel *m) +{ + int i; + + for (i = 0; i < m->channel_num; i++) { + channel_close(m->channel[i]); + } + free(m); +} + +void multichannel_stats(struct multichannel *m, int fd) +{ + channel_stats(m->current, fd); +} + +void +multichannel_stats_extended(struct multichannel *m, + struct nlif_handle *h, int fd) +{ + int i, active; + + for (i = 0; i < m->channel_num; i++) { + if (m->current == m->channel[i]) { + active = 1; + } else { + active = 0; + } + channel_stats_extended(m->channel[i], active, h, fd); + } +} + +int multichannel_get_ifindex(struct multichannel *m, int i) +{ + return m->channel[i]->channel_ifindex; +} + +int multichannel_get_current_ifindex(struct multichannel *m) +{ + return m->current->channel_ifindex; +} + +void multichannel_set_current_channel(struct multichannel *m, int i) +{ + m->current = m->channel[i]; +} + +void multichannel_change_current_channel(struct multichannel *m, int i) +{ + if (m->current != m->channel[i]) + m->current = m->channel[i]; +} diff --git a/src/netlink.c b/src/netlink.c new file mode 100644 index 0000000..a43f782 --- /dev/null +++ b/src/netlink.c @@ -0,0 +1,291 @@ +/* + * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "netlink.h" +#include "conntrackd.h" +#include "filter.h" +#include "log.h" + +#include <string.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/fcntl.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h> + +struct nfct_handle *nl_init_event_handler(void) +{ + struct nfct_handle *h; + + h = nfct_open(CONNTRACK, NFCT_ALL_CT_GROUPS); + if (h == NULL) + return NULL; + + if (STATE(filter)) { + if (CONFIG(filter_from_kernelspace)) { + if (nfct_filter_attach(nfct_fd(h), + STATE(filter)) == -1) { + dlog(LOG_ERR, "cannot set event filtering: %s", + strerror(errno)); + } + dlog(LOG_NOTICE, "using kernel-space event filtering"); + } else + dlog(LOG_NOTICE, "using user-space event filtering"); + + nfct_filter_destroy(STATE(filter)); + } + + fcntl(nfct_fd(h), F_SETFL, O_NONBLOCK); + + /* set up socket buffer size */ + if (CONFIG(netlink_buffer_size)) { + CONFIG(netlink_buffer_size) = + nfnl_rcvbufsiz(nfct_nfnlh(h), CONFIG(netlink_buffer_size)); + } else { + socklen_t socklen = sizeof(unsigned int); + unsigned int read_size; + + /* get current buffer size */ + getsockopt(nfct_fd(h), SOL_SOCKET, + SO_RCVBUF, &read_size, &socklen); + + CONFIG(netlink_buffer_size) = read_size; + } + + dlog(LOG_NOTICE, "netlink event socket buffer size has been set " + "to %u bytes", CONFIG(netlink_buffer_size)); + + /* ensure that maximum grown size is >= than maximum size */ + if (CONFIG(netlink_buffer_size_max_grown) < CONFIG(netlink_buffer_size)) + CONFIG(netlink_buffer_size_max_grown) = + CONFIG(netlink_buffer_size); + + if (CONFIG(netlink).events_reliable) { + int on = 1; + + setsockopt(nfct_fd(h), SOL_NETLINK, + NETLINK_BROADCAST_SEND_ERROR, &on, sizeof(int)); + + setsockopt(nfct_fd(h), SOL_NETLINK, + NETLINK_NO_ENOBUFS, &on, sizeof(int)); + + dlog(LOG_NOTICE, "reliable ctnetlink event delivery " + "is ENABLED."); + } + return h; +} + +struct nlif_handle *nl_init_interface_handler(void) +{ + struct nlif_handle *h; + h = nlif_open(); + if (h == NULL) + return NULL; + + if (nlif_query(h) == -1) { + free(h); + return NULL; + } + fcntl(nlif_fd(h), F_SETFL, O_NONBLOCK); + + return h; +} + +static int warned = 0; + +void nl_resize_socket_buffer(struct nfct_handle *h) +{ + /* sock_setsockopt in net/core/sock.c doubles the size of the buffer */ + unsigned int s = CONFIG(netlink_buffer_size); + + /* already warned that we have reached the maximum buffer size */ + if (warned) + return; + + if (s > CONFIG(netlink_buffer_size_max_grown)) { + dlog(LOG_WARNING, + "maximum netlink socket buffer " + "size has been reached. We are likely to " + "be losing events, this may lead to " + "unsynchronized replicas. Please, consider " + "increasing netlink socket buffer size via " + "SocketBufferSize and " + "SocketBufferSizeMaxGrowth clauses in " + "conntrackd.conf"); + s = CONFIG(netlink_buffer_size_max_grown); + warned = 1; + } + + CONFIG(netlink_buffer_size) = nfnl_rcvbufsiz(nfct_nfnlh(h), s); + + /* notify the sysadmin */ + dlog(LOG_NOTICE, "netlink socket buffer size has been increased " + "to %u bytes", CONFIG(netlink_buffer_size)); +} + +int nl_dump_conntrack_table(struct nfct_handle *h) +{ + return nfct_query(h, NFCT_Q_DUMP, &CONFIG(family)); +} + +int nl_flush_conntrack_table(struct nfct_handle *h) +{ + return nfct_query(h, NFCT_Q_FLUSH, &CONFIG(family)); +} + +int nl_send_resync(struct nfct_handle *h) +{ + int family = CONFIG(family); + return nfct_send(h, NFCT_Q_DUMP, &family); +} + +/* if the handle has no callback, check for existence, otherwise, update */ +int nl_get_conntrack(struct nfct_handle *h, const struct nf_conntrack *ct) +{ + int ret; + char __tmp[nfct_maxsize()]; + struct nf_conntrack *tmp = (struct nf_conntrack *) (void *)__tmp; + + memset(__tmp, 0, sizeof(__tmp)); + + /* use the original tuple to check if it is there */ + nfct_copy(tmp, ct, NFCT_CP_ORIG); + + ret = nfct_query(h, NFCT_Q_GET, tmp); + if (ret == -1) + return errno == ENOENT ? 0 : -1; + + return 1; +} + +int nl_create_conntrack(struct nfct_handle *h, + const struct nf_conntrack *orig, + int timeout) +{ + int ret; + struct nf_conntrack *ct; + + ct = nfct_clone(orig); + if (ct == NULL) + return -1; + + if (timeout > 0) + nfct_set_attr_u32(ct, ATTR_TIMEOUT, timeout); + + /* we hit error if we try to change the expected bit */ + if (nfct_attr_is_set(ct, ATTR_STATUS)) { + uint32_t status = nfct_get_attr_u32(ct, ATTR_STATUS); + status &= ~IPS_EXPECTED; + nfct_set_attr_u32(ct, ATTR_STATUS, status); + } + + nfct_setobjopt(ct, NFCT_SOPT_SETUP_REPLY); + + /* + * TCP flags to overpass window tracking for recovered connections + */ + if (nfct_attr_is_set(ct, ATTR_TCP_STATE)) { + uint8_t flags = IP_CT_TCP_FLAG_BE_LIBERAL | + IP_CT_TCP_FLAG_SACK_PERM; + + /* FIXME: workaround, we should send TCP flags in updates */ + if (nfct_get_attr_u8(ct, ATTR_TCP_STATE) >= + TCP_CONNTRACK_TIME_WAIT) { + flags |= IP_CT_TCP_FLAG_CLOSE_INIT; + } + nfct_set_attr_u8(ct, ATTR_TCP_FLAGS_ORIG, flags); + nfct_set_attr_u8(ct, ATTR_TCP_MASK_ORIG, flags); + nfct_set_attr_u8(ct, ATTR_TCP_FLAGS_REPL, flags); + nfct_set_attr_u8(ct, ATTR_TCP_MASK_REPL, flags); + } + + ret = nfct_query(h, NFCT_Q_CREATE, ct); + nfct_destroy(ct); + + return ret; +} + +int nl_update_conntrack(struct nfct_handle *h, + const struct nf_conntrack *orig, + int timeout) +{ + int ret; + struct nf_conntrack *ct; + + ct = nfct_clone(orig); + if (ct == NULL) + return -1; + + if (timeout > 0) + nfct_set_attr_u32(ct, ATTR_TIMEOUT, timeout); + + /* unset NAT info, otherwise we hit error */ + nfct_attr_unset(ct, ATTR_SNAT_IPV4); + nfct_attr_unset(ct, ATTR_DNAT_IPV4); + nfct_attr_unset(ct, ATTR_SNAT_PORT); + nfct_attr_unset(ct, ATTR_DNAT_PORT); + + if (nfct_attr_is_set(ct, ATTR_STATUS)) { + uint32_t status = nfct_get_attr_u32(ct, ATTR_STATUS); + status &= ~IPS_NAT_MASK; + nfct_set_attr_u32(ct, ATTR_STATUS, status); + } + /* we have to unset the helper to avoid EBUSY in reset timers */ + if (nfct_attr_is_set(ct, ATTR_HELPER_NAME)) + nfct_attr_unset(ct, ATTR_HELPER_NAME); + + /* we hit error if we try to update the master conntrack */ + if (ct_is_related(ct)) { + nfct_attr_unset(ct, ATTR_MASTER_L3PROTO); + nfct_attr_unset(ct, ATTR_MASTER_L4PROTO); + nfct_attr_unset(ct, ATTR_MASTER_IPV4_SRC); + nfct_attr_unset(ct, ATTR_MASTER_IPV4_DST); + nfct_attr_unset(ct, ATTR_MASTER_IPV6_SRC); + nfct_attr_unset(ct, ATTR_MASTER_IPV6_DST); + nfct_attr_unset(ct, ATTR_MASTER_PORT_SRC); + nfct_attr_unset(ct, ATTR_MASTER_PORT_DST); + } + + /* + * TCP flags to overpass window tracking for recovered connections + */ + if (nfct_attr_is_set(ct, ATTR_TCP_STATE)) { + uint8_t flags = IP_CT_TCP_FLAG_BE_LIBERAL | + IP_CT_TCP_FLAG_SACK_PERM; + + /* FIXME: workaround, we should send TCP flags in updates */ + if (nfct_get_attr_u8(ct, ATTR_TCP_STATE) >= + TCP_CONNTRACK_TIME_WAIT) { + flags |= IP_CT_TCP_FLAG_CLOSE_INIT; + } + nfct_set_attr_u8(ct, ATTR_TCP_FLAGS_ORIG, flags); + nfct_set_attr_u8(ct, ATTR_TCP_MASK_ORIG, flags); + nfct_set_attr_u8(ct, ATTR_TCP_FLAGS_REPL, flags); + nfct_set_attr_u8(ct, ATTR_TCP_MASK_REPL, flags); + } + + ret = nfct_query(h, NFCT_Q_UPDATE, ct); + nfct_destroy(ct); + + return ret; +} + +int nl_destroy_conntrack(struct nfct_handle *h, const struct nf_conntrack *ct) +{ + return nfct_query(h, NFCT_Q_DESTROY, ct); +} diff --git a/src/network.c b/src/network.c new file mode 100644 index 0000000..6a66a2b --- /dev/null +++ b/src/network.c @@ -0,0 +1,131 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "conntrackd.h" +#include "network.h" +#include "log.h" + +#include <stdlib.h> +#include <time.h> +#include <string.h> + +#define NETHDR_ALIGNTO 4 + +static unsigned int seq_set, cur_seq; + +int nethdr_align(int value) +{ + return (value + NETHDR_ALIGNTO - 1) & ~(NETHDR_ALIGNTO - 1); +} + +int nethdr_size(int len) +{ + return NETHDR_SIZ + len; +} + +static inline void __nethdr_set(struct nethdr *net, int len) +{ + if (!seq_set) { + seq_set = 1; + cur_seq = time(NULL); + } + net->version = CONNTRACKD_PROTOCOL_VERSION; + net->len = len; + net->seq = cur_seq++; +} + +void nethdr_set(struct nethdr *net, int type) +{ + __nethdr_set(net, NETHDR_SIZ); + net->type = type; +} + +void nethdr_set_ack(struct nethdr *net) +{ + __nethdr_set(net, NETHDR_ACK_SIZ); +} + +void nethdr_set_ctl(struct nethdr *net) +{ + __nethdr_set(net, NETHDR_SIZ); +} + +static int local_seq_set = 0; + +/* this function only tracks, it does not update the last sequence received */ +int nethdr_track_seq(uint32_t seq, uint32_t *exp_seq) +{ + int ret = SEQ_UNKNOWN; + + /* netlink sequence tracking initialization */ + if (!local_seq_set) { + ret = SEQ_UNSET; + goto out; + } + + /* fast path: we received the correct sequence */ + if (seq == STATE_SYNC(last_seq_recv)+1) { + ret = SEQ_IN_SYNC; + goto out; + } + + /* out of sequence: some messages got lost */ + if (after(seq, STATE_SYNC(last_seq_recv)+1)) { + STATE_SYNC(error).msg_rcv_lost += + seq - STATE_SYNC(last_seq_recv) + 1; + ret = SEQ_AFTER; + goto out; + } + + /* out of sequence: replayed/delayed packet? */ + if (before(seq, STATE_SYNC(last_seq_recv)+1)) { + STATE_SYNC(error).msg_rcv_before++; + ret = SEQ_BEFORE; + } + +out: + *exp_seq = STATE_SYNC(last_seq_recv)+1; + + return ret; +} + +void nethdr_track_update_seq(uint32_t seq) +{ + if (!local_seq_set) + local_seq_set = 1; + + STATE_SYNC(last_seq_recv) = seq; +} + +int nethdr_track_is_seq_set() +{ + return local_seq_set; +} + +#include "cache.h" + +static int status2type[] = { + [C_OBJ_NEW] = NET_T_STATE_NEW, + [C_OBJ_ALIVE] = NET_T_STATE_UPD, + [C_OBJ_DEAD] = NET_T_STATE_DEL, +}; + +int object_status_to_network_type(int status) +{ + return status2type[status]; +} diff --git a/src/origin.c b/src/origin.c new file mode 100644 index 0000000..3c65f3d --- /dev/null +++ b/src/origin.c @@ -0,0 +1,70 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "conntrackd.h" +#include "origin.h" + +static LIST_HEAD(origin_list); + +struct origin { + struct list_head head; + unsigned int nl_portid; + int type; +}; + +/* register a Netlink socket as origin of possible events */ +int origin_register(struct nfct_handle *h, int origin_type) +{ + struct origin *nlp; + + nlp = calloc(sizeof(struct origin), 1); + if (nlp == NULL) + return -1; + + nlp->nl_portid = nfnl_portid(nfct_nfnlh(h)); + nlp->type = origin_type; + + list_add(&nlp->head, &origin_list); + return 0; +} + +/* look up for the origin of this Netlink event */ +int origin_find(const struct nlmsghdr *nlh) +{ + struct origin *this; + + list_for_each_entry(this, &origin_list, head) { + if (this->nl_portid == nlh->nlmsg_pid) { + return this->type; + } + } + return CTD_ORIGIN_NOT_ME; +} + +int origin_unregister(struct nfct_handle *h) +{ + struct origin *this, *tmp; + + list_for_each_entry_safe(this, tmp, &origin_list, head) { + if (this->nl_portid == nfnl_portid(nfct_nfnlh(h))) { + list_del(&this->head); + free(this); + return 1; + } + } + return 0; +} diff --git a/src/parse.c b/src/parse.c new file mode 100644 index 0000000..e6eefe4 --- /dev/null +++ b/src/parse.c @@ -0,0 +1,239 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "network.h" + +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> + +#ifndef ssizeof +#define ssizeof(x) (int)sizeof(x) +#endif + +static void parse_u8(struct nf_conntrack *ct, int attr, void *data); +static void parse_u16(struct nf_conntrack *ct, int attr, void *data); +static void parse_u32(struct nf_conntrack *ct, int attr, void *data); +static void parse_group(struct nf_conntrack *ct, int attr, void *data); +static void parse_nat_seq_adj(struct nf_conntrack *ct, int attr, void *data); + +struct parser { + void (*parse)(struct nf_conntrack *ct, int attr, void *data); + int attr; + int size; +}; + +static struct parser h[NTA_MAX] = { + [NTA_IPV4] = { + .parse = parse_group, + .attr = ATTR_GRP_ORIG_IPV4, + .size = NTA_SIZE(sizeof(struct nfct_attr_grp_ipv4)), + }, + [NTA_IPV6] = { + .parse = parse_group, + .attr = ATTR_GRP_ORIG_IPV6, + .size = NTA_SIZE(sizeof(struct nfct_attr_grp_ipv6)), + }, + [NTA_PORT] = { + .parse = parse_group, + .attr = ATTR_GRP_ORIG_PORT, + .size = NTA_SIZE(sizeof(struct nfct_attr_grp_port)), + }, + [NTA_L4PROTO] = { + .parse = parse_u8, + .attr = ATTR_L4PROTO, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_TCP_STATE] = { + .parse = parse_u8, + .attr = ATTR_TCP_STATE, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_STATUS] = { + .parse = parse_u32, + .attr = ATTR_STATUS, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_MARK] = { + .parse = parse_u32, + .attr = ATTR_MARK, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_TIMEOUT] = { + .parse = parse_u32, + .attr = ATTR_TIMEOUT, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_MASTER_IPV4] = { + .parse = parse_group, + .attr = ATTR_GRP_MASTER_IPV4, + .size = NTA_SIZE(sizeof(struct nfct_attr_grp_ipv4)), + }, + [NTA_MASTER_IPV6] = { + .parse = parse_group, + .attr = ATTR_GRP_MASTER_IPV6, + .size = NTA_SIZE(sizeof(struct nfct_attr_grp_ipv6)), + }, + [NTA_MASTER_L4PROTO] = { + .parse = parse_u8, + .attr = ATTR_MASTER_L4PROTO, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_MASTER_PORT] = { + .parse = parse_group, + .attr = ATTR_GRP_MASTER_PORT, + .size = NTA_SIZE(sizeof(struct nfct_attr_grp_port)), + }, + [NTA_SNAT_IPV4] = { + .parse = parse_u32, + .attr = ATTR_SNAT_IPV4, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_DNAT_IPV4] = { + .parse = parse_u32, + .attr = ATTR_DNAT_IPV4, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_SPAT_PORT] = { + .parse = parse_u16, + .attr = ATTR_SNAT_PORT, + .size = NTA_SIZE(sizeof(uint16_t)), + }, + [NTA_DPAT_PORT] = { + .parse = parse_u16, + .attr = ATTR_DNAT_PORT, + .size = NTA_SIZE(sizeof(uint16_t)), + }, + [NTA_NAT_SEQ_ADJ] = { + .parse = parse_nat_seq_adj, + .size = NTA_SIZE(sizeof(struct nta_attr_natseqadj)), + }, + [NTA_SCTP_STATE] = { + .parse = parse_u8, + .attr = ATTR_SCTP_STATE, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_SCTP_VTAG_ORIG] = { + .parse = parse_u32, + .attr = ATTR_SCTP_VTAG_ORIG, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_SCTP_VTAG_REPL] = { + .parse = parse_u32, + .attr = ATTR_SCTP_VTAG_REPL, + .size = NTA_SIZE(sizeof(uint32_t)), + }, + [NTA_DCCP_STATE] = { + .parse = parse_u8, + .attr = ATTR_DCCP_STATE, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_DCCP_ROLE] = { + .parse = parse_u8, + .attr = ATTR_DCCP_ROLE, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_ICMP_TYPE] = { + .parse = parse_u8, + .attr = ATTR_ICMP_TYPE, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_ICMP_CODE] = { + .parse = parse_u8, + .attr = ATTR_ICMP_CODE, + .size = NTA_SIZE(sizeof(uint8_t)), + }, + [NTA_ICMP_ID] = { + .parse = parse_u16, + .attr = ATTR_ICMP_ID, + .size = NTA_SIZE(sizeof(uint16_t)), + }, +}; + +static void +parse_u8(struct nf_conntrack *ct, int attr, void *data) +{ + uint8_t *value = (uint8_t *) data; + nfct_set_attr_u8(ct, h[attr].attr, *value); +} + +static void +parse_u16(struct nf_conntrack *ct, int attr, void *data) +{ + uint16_t *value = (uint16_t *) data; + nfct_set_attr_u16(ct, h[attr].attr, ntohs(*value)); +} + +static void +parse_u32(struct nf_conntrack *ct, int attr, void *data) +{ + uint32_t *value = (uint32_t *) data; + nfct_set_attr_u32(ct, h[attr].attr, ntohl(*value)); +} + +static void +parse_group(struct nf_conntrack *ct, int attr, void *data) +{ + nfct_set_attr_grp(ct, h[attr].attr, data); +} + +static void +parse_nat_seq_adj(struct nf_conntrack *ct, int attr, void *data) +{ + struct nta_attr_natseqadj *this = data; + nfct_set_attr_u32(ct, ATTR_ORIG_NAT_SEQ_CORRECTION_POS, + ntohl(this->orig_seq_correction_pos)); + nfct_set_attr_u32(ct, ATTR_ORIG_NAT_SEQ_OFFSET_BEFORE, + ntohl(this->orig_seq_correction_pos)); + nfct_set_attr_u32(ct, ATTR_ORIG_NAT_SEQ_OFFSET_AFTER, + ntohl(this->orig_seq_correction_pos)); + nfct_set_attr_u32(ct, ATTR_REPL_NAT_SEQ_CORRECTION_POS, + ntohl(this->orig_seq_correction_pos)); + nfct_set_attr_u32(ct, ATTR_REPL_NAT_SEQ_OFFSET_BEFORE, + ntohl(this->orig_seq_correction_pos)); + nfct_set_attr_u32(ct, ATTR_REPL_NAT_SEQ_OFFSET_AFTER, + ntohl(this->orig_seq_correction_pos)); +} + +int parse_payload(struct nf_conntrack *ct, struct nethdr *net, size_t remain) +{ + int len; + struct netattr *attr; + + if (remain < net->len) + return -1; + + len = net->len - NETHDR_SIZ; + attr = NETHDR_DATA(net); + + while (len > ssizeof(struct netattr)) { + ATTR_NETWORK2HOST(attr); + if (attr->nta_len > len) + return -1; + if (attr->nta_attr > NTA_MAX) + return -1; + if (attr->nta_len != h[attr->nta_attr].size) + return -1; + if (h[attr->nta_attr].parse == NULL) { + attr = NTA_NEXT(attr, len); + continue; + } + h[attr->nta_attr].parse(ct, attr->nta_attr, NTA_DATA(attr)); + attr = NTA_NEXT(attr, len); + } + + return 0; +} diff --git a/src/process.c b/src/process.c new file mode 100644 index 0000000..9b9734c --- /dev/null +++ b/src/process.c @@ -0,0 +1,103 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <signal.h> +#include "conntrackd.h" +#include "process.h" + +static LIST_HEAD(process_list); + +int fork_process_new(int type, int flags, void (*cb)(void *data), void *data) +{ + struct child_process *c, *this; + int pid; + + /* block SIGCHLD to avoid the access of the list concurrently */ + sigprocmask(SIG_BLOCK, &STATE(block), NULL); + + /* We only want one process of this type at the same time. This is + * useful if you want to prevent two child processes from accessing + * a shared descriptor at the same time. */ + if (flags & CTD_PROC_F_EXCL) { + list_for_each_entry(this, &process_list, head) { + if (this->type == type) { + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + return -1; + } + } + } + c = calloc(sizeof(struct child_process), 1); + if (c == NULL) { + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + return -1; + } + + c->type = type; + c->cb = cb; + c->data = data; + c->pid = pid = fork(); + + if (c->pid > 0) + list_add(&c->head, &process_list); + + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + + return pid; +} + +int fork_process_delete(int pid) +{ + struct child_process *this, *tmp; + + list_for_each_entry_safe(this, tmp, &process_list, head) { + if (this->pid == pid) { + list_del(&this->head); + if (this->cb) { + this->cb(this->data); + } + free(this); + return 1; + } + } + return 0; +} + +static const char *process_type_to_name[CTD_PROC_MAX] = { + [CTD_PROC_ANY] = "any", + [CTD_PROC_FLUSH] = "flush", + [CTD_PROC_COMMIT] = "commit", +}; + +void fork_process_dump(int fd) +{ + struct child_process *this; + char buf[4096]; + int size = 0; + + sigprocmask(SIG_BLOCK, &STATE(block), NULL); + list_for_each_entry(this, &process_list, head) { + size += snprintf(buf+size, sizeof(buf), + "PID=%u type=%s\n", + this->pid, + this->type < CTD_PROC_MAX ? + process_type_to_name[this->type] : "unknown"); + } + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + + send(fd, buf, size, 0); +} diff --git a/src/queue.c b/src/queue.c new file mode 100644 index 0000000..76425b1 --- /dev/null +++ b/src/queue.c @@ -0,0 +1,187 @@ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "queue.h" +#include "event.h" + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/socket.h> + +static LIST_HEAD(queue_list); /* list of existing queues */ +static uint32_t qobjects_num; /* number of active queue objects */ + +struct queue * +queue_create(const char *name, int max_objects, unsigned int flags) +{ + struct queue *b; + + b = calloc(sizeof(struct queue), 1); + if (b == NULL) + return NULL; + + b->max_elems = max_objects; + INIT_LIST_HEAD(&b->head); + b->flags = flags; + + if (flags & QUEUE_F_EVFD) { + b->evfd = create_evfd(); + if (b->evfd == NULL) { + free(b); + return NULL; + } + } + strncpy(b->name, name, QUEUE_NAMELEN); + b->name[QUEUE_NAMELEN-1]='\0'; + list_add(&b->list, &queue_list); + + return b; +} + +void queue_destroy(struct queue *b) +{ + list_del(&b->list); + if (b->flags & QUEUE_F_EVFD) + destroy_evfd(b->evfd); + free(b); +} + +void queue_stats_show(int fd) +{ + struct queue *this; + int size = 0; + char buf[512]; + + size += snprintf(buf+size, sizeof(buf), + "allocated queue nodes:\t\t%12u\n\n", + qobjects_num); + + list_for_each_entry(this, &queue_list, list) { + size += snprintf(buf+size, sizeof(buf), + "queue %s:\n" + "current elements:\t\t%12u\n" + "maximum elements:\t\t%12u\n" + "not enough space errors:\t%12u\n\n", + this->name, + this->num_elems, + this->max_elems, + this->enospc_err); + } + send(fd, buf, size, 0); +} + +void queue_node_init(struct queue_node *n, int type) +{ + INIT_LIST_HEAD(&n->head); + n->type = type; +} + +void *queue_node_data(struct queue_node *n) +{ + return ((char *)n) + sizeof(struct queue_node); +} + +struct queue_object *queue_object_new(int type, size_t size) +{ + struct queue_object *obj; + + obj = calloc(sizeof(struct queue_object) + size, 1); + if (obj == NULL) + return NULL; + + obj->qnode.size = size; + queue_node_init(&obj->qnode, type); + qobjects_num++; + + return obj; +} + +void queue_object_free(struct queue_object *obj) +{ + free(obj); + qobjects_num--; +} + +int queue_add(struct queue *b, struct queue_node *n) +{ + if (!list_empty(&n->head)) + return 0; + + if (b->num_elems >= b->max_elems) { + b->enospc_err++; + errno = ENOSPC; + return -1; + } + n->owner = b; + list_add_tail(&n->head, &b->head); + b->num_elems++; + if (b->evfd) + write_evfd(b->evfd); + return 1; +} + +int queue_del(struct queue_node *n) +{ + if (list_empty(&n->head)) + return 0; + + list_del_init(&n->head); + n->owner->num_elems--; + if (n->owner->evfd) + read_evfd(n->owner->evfd); + n->owner = NULL; + return 1; +} + +struct queue_node *queue_del_head(struct queue *b) +{ + struct queue_node *n = (struct queue_node *) b->head.next; + queue_del(n); + return n; +} + +int queue_in(struct queue *b, struct queue_node *n) +{ + return b == n->owner; +} + +int queue_get_eventfd(struct queue *b) +{ + return get_read_evfd(b->evfd); +} + +void queue_iterate(struct queue *b, + const void *data, + int (*iterate)(struct queue_node *n, const void *data2)) +{ + struct list_head *i, *tmp; + struct queue_node *n; + + list_for_each_safe(i, tmp, &b->head) { + n = (struct queue_node *) i; + if (iterate(n, data)) + break; + } +} + +unsigned int queue_len(const struct queue *b) +{ + return b->num_elems; +} diff --git a/src/rbtree.c b/src/rbtree.c new file mode 100644 index 0000000..199e2bb --- /dev/null +++ b/src/rbtree.c @@ -0,0 +1,389 @@ +/* + Red Black Trees + (C) 1999 Andrea Arcangeli <andrea@suse.de> + (C) 2002 David Woodhouse <dwmw2@infradead.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + linux/lib/rbtree.c +*/ + +#include "linux_rbtree.h" + +static void __rb_rotate_left(struct rb_node *node, struct rb_root *root) +{ + struct rb_node *right = node->rb_right; + struct rb_node *parent = rb_parent(node); + + if ((node->rb_right = right->rb_left)) + rb_set_parent(right->rb_left, node); + right->rb_left = node; + + rb_set_parent(right, parent); + + if (parent) + { + if (node == parent->rb_left) + parent->rb_left = right; + else + parent->rb_right = right; + } + else + root->rb_node = right; + rb_set_parent(node, right); +} + +static void __rb_rotate_right(struct rb_node *node, struct rb_root *root) +{ + struct rb_node *left = node->rb_left; + struct rb_node *parent = rb_parent(node); + + if ((node->rb_left = left->rb_right)) + rb_set_parent(left->rb_right, node); + left->rb_right = node; + + rb_set_parent(left, parent); + + if (parent) + { + if (node == parent->rb_right) + parent->rb_right = left; + else + parent->rb_left = left; + } + else + root->rb_node = left; + rb_set_parent(node, left); +} + +void rb_insert_color(struct rb_node *node, struct rb_root *root) +{ + struct rb_node *parent, *gparent; + + while ((parent = rb_parent(node)) && rb_is_red(parent)) + { + gparent = rb_parent(parent); + + if (parent == gparent->rb_left) + { + { + register struct rb_node *uncle = gparent->rb_right; + if (uncle && rb_is_red(uncle)) + { + rb_set_black(uncle); + rb_set_black(parent); + rb_set_red(gparent); + node = gparent; + continue; + } + } + + if (parent->rb_right == node) + { + register struct rb_node *tmp; + __rb_rotate_left(parent, root); + tmp = parent; + parent = node; + node = tmp; + } + + rb_set_black(parent); + rb_set_red(gparent); + __rb_rotate_right(gparent, root); + } else { + { + register struct rb_node *uncle = gparent->rb_left; + if (uncle && rb_is_red(uncle)) + { + rb_set_black(uncle); + rb_set_black(parent); + rb_set_red(gparent); + node = gparent; + continue; + } + } + + if (parent->rb_left == node) + { + register struct rb_node *tmp; + __rb_rotate_right(parent, root); + tmp = parent; + parent = node; + node = tmp; + } + + rb_set_black(parent); + rb_set_red(gparent); + __rb_rotate_left(gparent, root); + } + } + + rb_set_black(root->rb_node); +} + +static void __rb_erase_color(struct rb_node *node, struct rb_node *parent, + struct rb_root *root) +{ + struct rb_node *other; + + while ((!node || rb_is_black(node)) && node != root->rb_node) + { + if (parent->rb_left == node) + { + other = parent->rb_right; + if (rb_is_red(other)) + { + rb_set_black(other); + rb_set_red(parent); + __rb_rotate_left(parent, root); + other = parent->rb_right; + } + if ((!other->rb_left || rb_is_black(other->rb_left)) && + (!other->rb_right || rb_is_black(other->rb_right))) + { + rb_set_red(other); + node = parent; + parent = rb_parent(node); + } + else + { + if (!other->rb_right || rb_is_black(other->rb_right)) + { + struct rb_node *o_left; + if ((o_left = other->rb_left)) + rb_set_black(o_left); + rb_set_red(other); + __rb_rotate_right(other, root); + other = parent->rb_right; + } + rb_set_color(other, rb_color(parent)); + rb_set_black(parent); + if (other->rb_right) + rb_set_black(other->rb_right); + __rb_rotate_left(parent, root); + node = root->rb_node; + break; + } + } + else + { + other = parent->rb_left; + if (rb_is_red(other)) + { + rb_set_black(other); + rb_set_red(parent); + __rb_rotate_right(parent, root); + other = parent->rb_left; + } + if ((!other->rb_left || rb_is_black(other->rb_left)) && + (!other->rb_right || rb_is_black(other->rb_right))) + { + rb_set_red(other); + node = parent; + parent = rb_parent(node); + } + else + { + if (!other->rb_left || rb_is_black(other->rb_left)) + { + register struct rb_node *o_right; + if ((o_right = other->rb_right)) + rb_set_black(o_right); + rb_set_red(other); + __rb_rotate_left(other, root); + other = parent->rb_left; + } + rb_set_color(other, rb_color(parent)); + rb_set_black(parent); + if (other->rb_left) + rb_set_black(other->rb_left); + __rb_rotate_right(parent, root); + node = root->rb_node; + break; + } + } + } + if (node) + rb_set_black(node); +} + +void rb_erase(struct rb_node *node, struct rb_root *root) +{ + struct rb_node *child, *parent; + int color; + + if (!node->rb_left) + child = node->rb_right; + else if (!node->rb_right) + child = node->rb_left; + else + { + struct rb_node *old = node, *left; + + node = node->rb_right; + while ((left = node->rb_left) != NULL) + node = left; + child = node->rb_right; + parent = rb_parent(node); + color = rb_color(node); + + if (child) + rb_set_parent(child, parent); + if (parent == old) { + parent->rb_right = child; + parent = node; + } else + parent->rb_left = child; + + node->rb_parent_color = old->rb_parent_color; + node->rb_right = old->rb_right; + node->rb_left = old->rb_left; + + if (rb_parent(old)) + { + if (rb_parent(old)->rb_left == old) + rb_parent(old)->rb_left = node; + else + rb_parent(old)->rb_right = node; + } else + root->rb_node = node; + + rb_set_parent(old->rb_left, node); + if (old->rb_right) + rb_set_parent(old->rb_right, node); + goto color; + } + + parent = rb_parent(node); + color = rb_color(node); + + if (child) + rb_set_parent(child, parent); + if (parent) + { + if (parent->rb_left == node) + parent->rb_left = child; + else + parent->rb_right = child; + } + else + root->rb_node = child; + + color: + if (color == RB_BLACK) + __rb_erase_color(child, parent, root); +} + +/* + * This function returns the first node (in sort order) of the tree. + */ +struct rb_node *rb_first(struct rb_root *root) +{ + struct rb_node *n; + + n = root->rb_node; + if (!n) + return NULL; + while (n->rb_left) + n = n->rb_left; + return n; +} + +struct rb_node *rb_last(struct rb_root *root) +{ + struct rb_node *n; + + n = root->rb_node; + if (!n) + return NULL; + while (n->rb_right) + n = n->rb_right; + return n; +} + +struct rb_node *rb_next(struct rb_node *node) +{ + struct rb_node *parent; + + if (rb_parent(node) == node) + return NULL; + + /* If we have a right-hand child, go down and then left as far + as we can. */ + if (node->rb_right) { + node = node->rb_right; + while (node->rb_left) + node=node->rb_left; + return node; + } + + /* No right-hand children. Everything down and left is + smaller than us, so any 'next' node must be in the general + direction of our parent. Go up the tree; any time the + ancestor is a right-hand child of its parent, keep going + up. First time it's a left-hand child of its parent, said + parent is our 'next' node. */ + while ((parent = rb_parent(node)) && node == parent->rb_right) + node = parent; + + return parent; +} + +struct rb_node *rb_prev(struct rb_node *node) +{ + struct rb_node *parent; + + if (rb_parent(node) == node) + return NULL; + + /* If we have a left-hand child, go down and then right as far + as we can. */ + if (node->rb_left) { + node = node->rb_left; + while (node->rb_right) + node=node->rb_right; + return node; + } + + /* No left-hand children. Go up till we find an ancestor which + is a right-hand child of its parent */ + while ((parent = rb_parent(node)) && node == parent->rb_left) + node = parent; + + return parent; +} + +void rb_replace_node(struct rb_node *victim, struct rb_node *new, + struct rb_root *root) +{ + struct rb_node *parent = rb_parent(victim); + + /* Set the surrounding nodes to point to the replacement */ + if (parent) { + if (victim == parent->rb_left) + parent->rb_left = new; + else + parent->rb_right = new; + } else { + root->rb_node = new; + } + if (victim->rb_left) + rb_set_parent(victim->rb_left, new); + if (victim->rb_right) + rb_set_parent(victim->rb_right, new); + + /* Copy the pointers/colour from the victim to the replacement */ + *new = *victim; +} diff --git a/src/read_config_lex.c b/src/read_config_lex.c new file mode 100644 index 0000000..c463526 --- /dev/null +++ b/src/read_config_lex.c @@ -0,0 +1,5961 @@ + +#line 3 "read_config_lex.c" + +#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 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* 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 (__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 + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* 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 * + +/* 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 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 yyrestart(yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (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 yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#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. + */ + int 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; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), 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)] \ + : NULL) + +/* 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 yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* 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 yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +typedef unsigned char YY_CHAR; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +typedef int yy_state_type; + +extern int yylineno; + +int yylineno = 1; + +extern char *yytext; +#define yytext_ptr yytext + +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[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 102 +#define YY_END_OF_BUFFER 103 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[2830] = + { 0, + 0, 0, 103, 101, 99, 100, 100, 101, 101, 91, + 87, 87, 101, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 101, 99, + 0, 98, 88, 91, 0, 87, 87, 0, 0, 90, + 97, 97, 97, 97, 97, 97, 0, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 0, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 0, 97, 85, 85, 97, 97, 97, 97, 97, + + 0, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 0, 0, 85, 0, + 85, 0, 0, 87, 87, 0, 0, 0, 90, 0, + 90, 97, 97, 97, 0, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 0, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 0, 97, 0, 97, 97, 0, 86, 86, 97, + 0, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + + 11, 97, 97, 10, 97, 97, 45, 86, 86, 0, + 87, 87, 0, 0, 0, 0, 0, 90, 90, 90, + 90, 97, 97, 97, 0, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 0, + 94, 94, 97, 97, 70, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 37, + 97, 95, 95, 97, 0, 97, 77, 95, 97, 0, + 18, 97, 24, 97, 97, 97, 97, 97, 97, 97, + 97, 0, 97, 97, 97, 97, 97, 29, 97, 97, + 79, 1, 97, 0, 94, 0, 0, 87, 87, 0, + + 0, 0, 0, 0, 0, 0, 90, 90, 90, 97, + 97, 92, 92, 97, 97, 97, 54, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 0, 97, 97, + 97, 23, 97, 97, 0, 0, 97, 97, 97, 0, + 97, 97, 97, 97, 97, 97, 97, 0, 97, 97, + 0, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 0, 0, 97, 97, 97, 66, 30, 97, 97, 0, + 97, 92, 92, 0, 87, 87, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 90, 90, 90, + 90, 97, 97, 67, 97, 97, 55, 0, 97, 97, + + 97, 97, 97, 97, 97, 97, 97, 97, 97, 0, + 39, 63, 97, 97, 97, 0, 0, 0, 0, 0, + 0, 68, 97, 97, 0, 56, 97, 97, 97, 97, + 97, 97, 97, 0, 97, 97, 0, 97, 97, 97, + 97, 97, 97, 97, 97, 97, 0, 0, 97, 97, + 97, 97, 26, 0, 97, 0, 89, 89, 87, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 97, 97, 65, 22, 0, 97, 97, 97, 97, 74, + 97, 97, 97, 97, 97, 97, 0, 28, 97, 97, + + 0, 0, 0, 0, 0, 0, 97, 97, 97, 97, + 0, 97, 97, 25, 97, 97, 97, 96, 96, 97, + 97, 0, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 0, 0, 97, 97, 97, 97, 0, 97, + 96, 0, 87, 87, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 97, 97, 0, 97, 97, 42, 97, 97, + 97, 97, 97, 97, 97, 97, 50, 97, 12, 0, + 0, 0, 0, 0, 0, 97, 97, 97, 97, 52, + + 38, 27, 97, 97, 97, 97, 97, 97, 97, 97, + 0, 75, 80, 64, 97, 97, 97, 97, 97, 97, + 97, 48, 47, 97, 97, 97, 21, 0, 97, 89, + 89, 87, 87, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 97, + 0, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 17, 0, 0, 0, 0, 0, 0, 97, 97, + 8, 97, 97, 97, 97, 9, 97, 97, 97, 97, + + 0, 97, 97, 97, 97, 44, 97, 97, 78, 97, + 97, 53, 71, 87, 87, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 97, + 97, 51, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 0, 0, 0, 0, 0, 0, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 93, 93, 97, + 97, 97, 97, 97, 97, 97, 97, 87, 87, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 49, 97, + 97, 0, 0, 0, 0, 0, 0, 97, 97, 72, + 97, 97, 97, 97, 97, 97, 97, 97, 13, 97, + 97, 97, 97, 97, 87, 87, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 97, 97, 14, 97, 97, + 97, 97, 97, 97, 97, 97, 0, 2, 0, 0, + 3, 0, 97, 97, 97, 97, 97, 97, 97, 97, + 69, 97, 97, 97, 97, 97, 97, 87, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 97, 43, 97, 15, 97, 97, + 97, 97, 97, 97, 0, 0, 0, 0, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 87, 87, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 97, + 97, 58, 97, 97, 97, 97, 0, 6, 0, 7, + 19, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 97, 87, 87, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 97, 97, 97, 97, + 97, 97, 97, 0, 0, 97, 97, 97, 97, 97, + 97, 97, 62, 97, 97, 41, 61, 97, 87, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 97, + 97, 97, 97, 97, 84, 97, 0, 0, 20, 97, + 97, 97, 97, 97, 97, 31, 40, 32, 87, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 97, 46, 97, 97, 97, + 97, 0, 0, 57, 97, 97, 35, 97, 97, 97, + + 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + + 90, 90, 90, 90, 97, 97, 97, 97, 97, 0, + 0, 97, 97, 97, 97, 97, 97, 87, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 97, 97, 97, 97, 73, + 0, 0, 97, 97, 97, 97, 97, 97, 87, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 16, + 83, 82, 0, 0, 60, 59, 97, 97, 76, 97, + 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 97, 0, 0, + 97, 81, 97, 87, 87, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 97, 0, 0, 97, + 97, 87, 87, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 97, 0, 0, 97, + 97, 87, 87, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 4, + 5, 97, 33, 97, 87, 87, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 97, 97, 34, 87, 87, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 90, 90, 90, 90, 90, 90, + + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 97, 36, 87, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 87, + 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 97, 87, 87, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 87, + 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 97, 87, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 97, 87, + 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 97, 87, 87, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + + 90, 90, 90, 90, 97, 87, 87, 0, 0, 0, + 0, 0, 0, 90, 90, 90, 90, 90, 90, 90, + 90, 97, 87, 87, 0, 0, 90, 90, 90, 90, + 90, 90, 90, 97, 87, 87, 0, 90, 90, 90, + 97, 87, 87, 90, 97, 87, 87, 97, 87, 87, + 97, 87, 87, 97, 87, 87, 97, 87, 87, 97, + 87, 87, 97, 87, 87, 97, 87, 87, 97, 87, + 87, 97, 87, 87, 97, 87, 87, 97, 87, 87, + 97, 87, 87, 97, 87, 87, 97, 87, 87, 97, + 87, 87, 97, 87, 87, 97, 87, 87, 97, 87, + + 87, 97, 87, 87, 97, 87, 87, 97, 87, 87, + 97, 87, 87, 97, 87, 87, 97, 87, 87, 97, + 87, 87, 97, 87, 87, 97, 87, 87, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 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, 5, 1, 6, 7, 1, 1, 1, 1, 1, + 1, 1, 8, 1, 8, 9, 10, 11, 11, 12, + 13, 14, 13, 15, 13, 13, 13, 16, 1, 1, + 1, 1, 1, 1, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 26, + 1, 1, 1, 1, 42, 1, 43, 44, 45, 46, + + 47, 48, 49, 50, 51, 26, 52, 53, 54, 55, + 56, 57, 26, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 1, 67, 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, 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, + 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 + } ; + +static yyconst flex_int32_t yy_meta[68] = + { 0, + 1, 1, 2, 1, 2, 2, 1, 1, 3, 4, + 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, + 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 1, 5, 5, 5, 5, 5, 5, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 8 + } ; + +static yyconst flex_int16_t yy_base[4541] = + { 0, + 0, 0,10684,10685, 66,10685,10685,10680, 61, 0, + 68, 76,10666, 82, 139, 81, 64, 78, 137, 123, + 98, 147, 53, 100, 152, 155, 182, 193, 189, 127, + 210, 202, 204, 164,10638, 201, 242, 258, 309, 103, + 10677,10685, 269, 0, 275, 288, 299,10663, 103,10668, + 122, 366,10650, 275,10631,10629, 211,10629, 291,10628, + 277, 185, 187, 260, 280, 301, 304, 305, 307,10618, + 279, 333, 306, 175, 334, 332, 354, 337, 359, 350, + 227, 380, 377, 378, 379, 351, 382, 386, 404, 390, + 387, 388, 412, 126, 403, 422, 414, 425, 421, 426, + + 409, 423, 443, 436, 445, 452, 442, 470, 449, 483, + 453, 457, 485, 481, 478, 489, 99, 496,10685, 471, + 547, 521, 546, 559, 573,10655, 325,10654, 107, 528, + 511, 604, 510, 495, 533,10622,10610,10615, 530,10616, + 535, 577,10622, 560, 578, 563, 592, 597, 588, 594, + 595, 593, 612, 613, 617, 619, 621, 624, 653, 625, + 623, 630, 641, 659, 638, 626, 667, 656, 649, 671, + 683, 673, 660, 670, 686, 685, 690, 687,10685, 706, + 677, 693, 703, 691, 705, 695, 697, 714, 713, 731, + 729, 743, 747, 750, 751, 717, 752, 760, 759, 762, + + 761, 767, 769, 763, 783, 775, 771, 768, 805, 834, + 862, 870,10648, 327,10647,10646,10645, 840, 847, 784, + 10650, 876, 849, 851, 872,10602, 883, 850, 886, 888, + 789, 890,10597, 893, 894, 776, 895, 896, 899,10618, + 898,10685, 911, 909, 912, 913, 915, 916, 926, 927, + 917, 929, 930, 931, 965, 954, 918, 951, 932, 921, + 958, 922,10685, 974, 983, 979, 987, 988, 991, 81, + 990, 992, 994, 995, 996, 997, 1004, 998, 1003, 1017, + 1018, 99, 1020, 1013, 1027, 1031, 1019, 1008, 1021, 1040, + 1012, 1022, 1024, 1075, 1076, 1097, 1111, 1122, 1135,10640, + + 786,10639,10638,10637,10636,10635, 793,10640, 1086, 1141, + 1112, 1032,10685, 1105, 1116, 1124, 1097, 1154, 1150, 1152, + 1125, 1153, 1155, 1129, 1178, 1165, 1179,10632, 1158, 1160, + 1181, 1033, 1183, 1184, 1052, 1185, 1186, 1191, 1185,10631, + 1199, 1187, 1192, 1194, 1221, 1215, 1225, 1195, 1210, 1214, + 1228, 1251, 1248, 1241, 1253, 1252, 1255, 1258, 1256, 1259, + 10626,10625, 1260, 1262, 1264, 1263, 1267, 1274, 1268,10606, + 1275, 1266, 1293, 1332, 1342, 1350,10628, 792,10627,10626, + 10625,10624,10623,10622,10621,10620, 1286,10625, 1290, 1293, + 10624, 1356, 1363, 1320, 1321, 1365, 1323,10594, 1366, 1367, + + 1324, 1370, 1368, 1373, 1376, 1377, 1380, 1378, 1382,10607, + 1379, 1381, 1397, 1399, 1391,10584,10584,10574,10581,10581, + 10571, 1395, 1413, 1392,10606, 1394, 1400, 1402, 1405, 1438, + 1410, 1444, 1447, 1441, 1454, 1455, 1437, 1462, 1422, 1460, + 1459, 1465, 1463, 1470, 1469, 1476,10605,10593, 1472, 1468, + 1480, 1484, 1474,10605, 1502, 1497, 1548, 1560, 1567, 1575, + 10605, 797,10604,10603,10602,10601,10600,10599,10598,10597, + 10596,10595,10594, 1300,10599, 1524, 1528,10598, 1532, 1536, + 1581, 1549, 1486, 1487,10590, 1550, 1569, 1552, 1591, 1551, + 1592, 1594, 1616, 1596, 1593, 1597,10570, 1595, 1598, 1599, + + 10546,10558,10543,10543,10555,10540, 1617, 1618, 1605, 1622, + 10572, 1631, 1606, 1627, 1607, 1632, 1623, 1619,10685, 1636, + 1672, 1634, 1654, 1640, 1655, 1661, 1664, 1676, 1675, 1680, + 1684, 1688,10560,10561, 1679, 1686, 1693, 1681,10571, 1690, + 1689, 1750, 1757, 1765,10579, 1006,10578,10577,10576,10575, + 10574,10573,10572,10571,10570,10569,10568,10567,10566,10565, + 10564,10563, 1540,10568, 1704, 1713,10567, 1714, 1722, 1734, + 1742,10566, 1771, 459,10550, 129, 62,10558, 854, 538, + 988, 148, 1161, 248, 808, 1709,10685, 777,10557,10512, + 10513,10523,10509,10510,10520, 1743, 290, 1759, 1778,10685, + + 10550,10549, 1779, 1081, 1785, 1781, 1782, 1515, 1780, 1792, + 1770,10548,10547,10546, 1786, 1788, 1297, 1789, 1787, 130, + 1791,10685,10685, 1793, 1794, 1507,10545,10524, 1808, 1815, + 1849, 1856, 1864,10543, 1403,10542,10541,10540,10539,10538, + 10537,10536,10535,10534,10533,10532,10531,10530,10529,10528, + 10527,10526,10525,10524,10523,10522, 1829,10527, 1836, 1840, + 1871, 1872, 1873, 1874,10526, 1875, 1876, 1883, 1889, 1796, + 10499, 1797, 1819, 1878, 1816, 1795, 1879, 1880, 580, 1881, + 1898,10518,10482,10485,10473,10479,10482,10470, 1882, 1896, + 10511, 1900, 1899, 1897, 1901,10510, 1902, 1904, 1905, 1907, + + 1888, 1903, 345, 1906, 1910,10509, 1913, 1911,10508, 1930, + 1914,10685,10507, 1964, 1972,10506, 1718,10505,10504,10503, + 10502,10501,10500,10499,10498,10497,10496,10495,10494,10493, + 10492,10491,10490,10489,10488,10487,10486,10485,10484,10483, + 10482,10481,10480, 1948,10485, 1955, 1979,10484, 1980, 1981, + 1982,10483, 1983, 1984, 1991, 1992, 1993, 1994,10480, 2000, + 1807,10685, 1966, 1989, 1950, 2007, 2008, 2010, 2012, 805, + 1940, 2013,10431,10423,10430,10419,10411,10418, 2014, 1915, + 2015, 1922, 2016, 2019, 2017, 2020, 2018,10446,10685, 2021, + 2022, 2024, 2023, 2025, 2033, 2026, 2034, 2077, 2085,10442, + + 2042,10438,10434,10430,10426,10422,10418,10414,10410,10406, + 10402,10398,10394,10390,10386,10382,10378,10374,10370,10363, + 10349,10327,10295,10251,10197,10192,10110,10105,10010,10005, + 9890, 2044, 9891, 2068, 2069, 9762, 2092, 2093, 2094, 2095, + 2096, 2097, 2104, 2105, 9757, 2106, 2107, 2108, 2109, 2115, + 2079, 2122, 413, 2123, 2124, 2125, 2127, 2128, 9600, 2126, + 2132, 9568, 9388, 9399, 9213, 9192, 9006, 2130, 2136, 9028, + 2131, 2138, 2139, 2133, 2134, 2135, 2137, 2140, 8804, 2141, + 2148, 2160, 2150, 2149, 2199, 2207, 8799, 2158, 8574, 8569, + 8332, 8327, 8101, 8096, 7870, 7865, 7663, 7658, 7461, 7456, + + 7285, 7280, 7115, 7110, 6969, 6964, 6832, 6827, 6717, 6712, + 6612, 6607, 6527, 6522, 6457, 6410, 6375, 6351, 6334, 6323, + 6315, 6309, 6305, 2161, 6303, 2186, 2189, 6287, 2193, 2214, + 2215, 2216, 6286, 2217, 2218, 2219, 6285, 2226, 2227, 2228, + 2229, 2230, 2231, 2238, 6284, 2244, 2153, 6277, 2235, 2234, + 583, 2156, 2251, 2252, 2253, 2254, 6232,10685, 6241, 6219, + 10685, 6226, 2255, 2233, 2237, 2236, 2256, 2257, 2258, 2259, + 6243, 2261, 2263, 2264, 2265, 2270, 2266, 2310, 2318, 6242, + 2288, 6241, 6240, 6233, 6225, 6217, 6205, 6204, 6203, 6202, + 6195, 6187, 6179, 6167, 6166, 6165, 6164, 6157, 6149, 6129, + + 6128, 6127, 6126, 6119, 6111, 6103, 6091, 6090, 6089, 6088, + 6081, 6073, 6065, 6053, 6052, 6051, 6050, 6043, 6035, 6027, + 2286, 6021, 2325, 2326, 2327, 2328, 2329, 2330, 6020, 2337, + 2338, 2339, 2340, 2341, 2342, 2349, 2350, 2351, 2352, 6019, + 2353, 2354, 2361, 2362, 2368, 6012, 2375, 6005, 2357, 2268, + 2269, 2358, 1065, 2377, 5962, 5946, 5941, 5944, 2260, 2376, + 2359, 2360, 2379, 2383, 1933, 2380, 2381, 2384, 2386, 2387, + 2389, 2390, 2410, 2433, 5974, 2289, 5967, 5959, 5951, 5939, + 5938, 5937, 5936, 5929, 5921, 5913, 5901, 5900, 5899, 5898, + 5891, 5883, 5875, 5863, 5862, 5861, 5860, 5853, 5845, 5825, + + 5824, 5823, 5822, 5815, 5807, 5799, 5787, 5786, 5785, 5784, + 5777, 5769, 5761, 5749, 5748, 5747, 5746, 5739, 5731, 5723, + 2417, 5717, 2440, 2441, 5716, 2442, 2444, 2445, 5715, 2449, + 2452, 2453, 2454, 2456, 2457, 5714, 2461, 2464, 2465, 5707, + 2466, 2468, 2469, 2473, 2476, 2477, 2478, 5699, 2484, 2474, + 2475, 5673, 2491, 2492, 2493, 2040, 5632,10685, 5631,10685, + 5670, 2494, 2392, 2051, 2152, 2495, 2391, 2499, 2496, 2497, + 2498, 2500, 2501, 2502, 2510, 2527, 5663, 2401, 5655, 5647, + 5635, 5634, 5633, 5632, 5625, 5617, 5609, 5597, 5596, 5595, + 5594, 5587, 5579, 5571, 5559, 5558, 5557, 5556, 5549, 5541, + + 5521, 5520, 5519, 5518, 5511, 5503, 5495, 5483, 5482, 5481, + 5480, 5473, 5465, 5457, 5445, 5444, 5443, 5442, 5435, 5427, + 5419, 5407, 5406, 5405, 5404, 5397, 2539, 5395, 2541, 2546, + 5375, 2550, 2551, 2553, 2555, 2560, 2562, 2563, 2564, 5374, + 2565, 2567, 2572, 2574, 2575, 2576, 2577, 2579, 2584, 2586, + 2587, 5373, 2588, 2589, 2591, 2596, 2602, 2592, 2593, 2609, + 2610, 2594, 2611, 5327, 5320, 2595, 2614, 2615, 2616, 2617, + 2618, 2619, 5351, 2620, 2621, 5343, 5331, 2622, 2645, 2673, + 5330, 2654, 5329, 5328, 5321, 5313, 5305, 5293, 5292, 5291, + 5290, 5283, 5275, 5267, 5255, 5254, 5253, 5252, 5245, 5237, + + 5222, 5221, 5220, 5219, 5218, 5210, 5209, 5208, 5207, 5200, + 5192, 5184, 5176, 5175, 5174, 5173, 5164, 5163, 5162, 5161, + 5154, 5146, 5138, 5128, 5127, 5106, 5105, 5104, 54, 70, + 159, 237, 322, 344, 446, 2657, 513, 2662, 2665, 568, + 2680, 2681, 2682, 2683, 696, 2684, 2685, 2692, 704, 2693, + 2694, 2695, 2696, 2697, 2704, 2705, 812, 2706, 2707, 2708, + 926, 2709, 2716, 2717, 2718, 2719, 2720, 2721, 939, 2727, + 2624, 2734, 2735, 2736, 1007, 2504, 1009, 1073, 1197, 2737, + 2738, 2739, 2741, 2740, 2742, 1277, 1333, 2037, 2750, 2781, + 1334, 2751, 1406, 1407, 1479, 1503, 1652, 1700, 1721, 1725, + + 1820, 1841, 1938, 2036, 2061, 2163, 2176, 2188, 2284, 2393, + 2413, 2414, 2418, 2521, 2532, 2623, 2626, 2627, 2635, 2639, + 2648, 2649, 2752, 2753, 2760, 2764, 2765, 2766, 2767, 2769, + 2773, 2782, 2783, 2784, 2786, 2787, 2788, 2789, 2790, 2791, + 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2807, + 2808, 2809, 2810, 2811, 2812, 2814, 2819, 2821, 2822, 2823, + 2824, 2826, 2827, 2831, 2834, 2835, 2836, 2838, 2839, 2843, + 2845, 2846, 2847, 2848, 2850, 2855, 2857, 2858, 2859, 2860, + 2862, 2867, 2868, 2869, 2870, 2876, 2865, 2866, 2883, 2884, + 2885, 2885, 2886, 2888, 2889, 2890, 2896, 2891, 2892, 2897, + + 2930, 2938, 2893, 2901, 2895, 2898, 2900, 2902, 2910, 2911, + 2914, 2915, 2916, 2917, 2919, 2932, 2939, 2940, 2942, 2943, + 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, + 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, + 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, + 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, + 2984, 2985, 2986, 2987, 2994, 2995, 2996, 2997, 2998, 2999, + 3001, 3004, 3006, 3008, 3009, 3011, 3012, 3013, 3016, 3020, + 3021, 3023, 3024, 3025, 3026, 3028, 3031, 3033, 3035, 3036, + 3038, 3040, 3043, 3045, 3046, 3047, 3048, 3050, 3053, 3055, + + 3057, 3058, 3060, 3062, 3066, 3059, 3073, 3074, 3075, 3046, + 3047, 3078, 3079, 3084, 3085, 3081, 3080, 3106, 3134, 3089, + 3121, 3083, 3086, 3087, 3088, 3091, 3092, 3122, 3100, 3112, + 3116, 3117, 3118, 3123, 3124, 3125, 3126, 3135, 3136, 3137, + 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147, + 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, + 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, + 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, + 3178, 3179, 3180, 3187, 3188, 3189, 3190, 3191, 3192, 3194, + 3197, 3199, 3201, 3202, 3204, 3206, 3209, 3211, 3213, 3214, + + 3215, 3216, 3218, 3223, 3225, 3226, 3227, 3228, 3230, 3235, + 3236, 3237, 3238, 3239, 3240, 3247, 3248, 3249, 3250, 3251, + 3252, 3258, 3259, 3260, 3261, 3267, 3257, 3256, 3274, 3275, + 3246, 3247, 3278, 3279, 3280, 3281, 3282, 3283, 3317, 3334, + 3291, 3285, 3286, 3288, 3289, 3292, 3293, 3301, 3302, 3303, + 3304, 3306, 3307, 3308, 3309, 3319, 3322, 3323, 3324, 3325, + 3326, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, + 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, + 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, + 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, + + 3374, 3375, 3376, 3377, 3384, 3385, 3386, 3387, 3388, 3389, + 3391, 3396, 3398, 3399, 3400, 3401, 3402, 3403, 3407, 3410, + 3411, 3412, 3414, 3415, 3419, 3421, 3422, 3423, 3424, 3426, + 3429, 3431, 3433, 3434, 3436, 3438, 3441, 3443, 3444, 3445, + 3446, 3448, 3451, 3453, 3455, 3456, 3458, 3460, 3464, 3457, + 3471, 3472, 3431, 3432, 3475, 3476, 3477, 3478, 3479, 3480, + 3490, 3504, 3481, 3482, 3498, 3505, 3506, 3507, 3508, 3510, + 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, + 3521, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, + 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, + + 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, + 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, + 3562, 3563, 3564, 3571, 3572, 3573, 3574, 3575, 3576, 3581, + 3583, 3584, 3585, 3586, 3588, 3593, 3595, 3596, 3597, 3598, + 3600, 3603, 3605, 3607, 3608, 3610, 3612, 3615, 3617, 3619, + 3620, 3622, 3624, 3626, 3627, 3629, 3631, 3634, 3636, 3638, + 3639, 3641, 3643, 3646, 3648, 3649, 3650, 3656, 3614, 3616, + 3663, 3664, 3666, 3672, 3680, 3674, 3681, 3682, 3689, 3690, + 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, + 3701, 3702, 3703, 3704, 3707, 3708, 3709, 3710, 3711, 3712, + + 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, + 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, + 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741, 3742, + 3743, 3744, 3745, 3752, 3753, 3754, 3755, 3756, 3757, 3764, + 3765, 3766, 3767, 3768, 3769, 3770, 3774, 3777, 3778, 3779, + 3781, 3782, 3786, 3788, 3789, 3790, 3791, 3793, 3796, 3798, + 3800, 3801, 3803, 3805, 3808, 3810, 3811, 3812, 3813, 3815, + 3818, 3820, 3822, 3823, 3825, 3827, 3831, 3781, 3795, 3839, + 3840, 3848, 3856, 3842, 3850, 3857, 3864, 3865, 3866, 3867, + 3868, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, + + 3878, 3880, 3881, 3882, 3883, 3884, 3885, 3886, 3888, 3889, + 3890, 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, + 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3908, 3909, + 3910, 3911, 3912, 3913, 3914, 3915, 3916, 3923, 3924, 3925, + 3926, 3927, 3928, 3935, 3936, 3937, 3938, 3939, 3940, 3945, + 3947, 3948, 3949, 3950, 3952, 3957, 3959, 3960, 3961, 3962, + 3964, 3968, 3969, 3971, 3972, 3973, 3976, 3980, 3981, 3983, + 3984, 3985, 3988, 3991, 3992, 3993, 3999, 3946, 3947, 4006, + 4007, 4015, 4023, 4009, 4017, 4024, 4025, 4032, 4033, 4034, + 4035, 4036, 4037, 4038, 4039, 4040, 4041, 4042, 4043, 4044, + + 4045, 4047, 4055, 4049, 4050, 4052, 4054, 4056, 4057, 4058, + 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, + 4069, 4070, 4071, 4072, 4073, 4074, 4075, 4076, 4077, 4078, + 4079, 4086, 4087, 4088, 4089, 4090, 4091, 4095, 4098, 4099, + 4100, 4102, 4103, 4107, 4110, 4111, 4112, 4113, 4114, 4115, + 4119, 4122, 4123, 4124, 4126, 4127, 4131, 4133, 4134, 4135, + 4136, 4138, 4141, 4143, 4145, 4146, 4148, 4150, 4154,10685, + 10685, 4147, 4161, 4162, 4170, 4178, 4164, 4172, 4179, 4180, + 4187, 4188, 4189, 4190, 4192, 4193, 4194, 4195, 4197, 4198, + 4199, 4200, 4201, 4202, 4203, 4204, 4205, 4206, 4207, 4208, + + 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4217, 4218, + 4219, 4220, 4221, 4222, 4223, 4224, 4225, 4226, 4233, 4234, + 4235, 4236, 4237, 4238, 4244, 4245, 4246, 4247, 4248, 4249, + 4256, 4257, 4258, 4259, 4260, 4261, 4267, 4268, 4269, 4270, + 4271, 4272, 4279, 4280, 4281, 4282, 4283, 4284, 4290, 4291, + 4292, 4293, 4299, 4288, 4289, 4313, 4321, 4307, 4315, 4323, + 4324, 4325, 4332, 4333, 4334, 4335, 4336, 4337, 4338, 4339, + 4340, 4341, 4342, 4343, 4344, 4345, 4346, 4347, 4348, 4349, + 4350, 4351, 4352, 4353, 4354, 4355, 4356, 4357, 4358, 4359, + 4360, 4361, 4362, 4363, 4370, 4371, 4372, 4373, 4374, 4375, + + 4382, 4383, 4384, 4385, 4386, 4387, 4388, 4392, 4395, 4396, + 4397, 4399, 4400, 4404, 4406, 4407, 4408, 4409, 4411, 4414, + 4416, 4418, 4419, 4421, 4423, 4427, 4420, 4441, 4449, 4435, + 4443, 4450, 4451, 4452, 4453, 4460, 4461, 4462, 4463, 4464, + 4465, 4466, 4467, 4468, 4469, 4470, 4471, 4472, 4473, 4474, + 4475, 4476, 4477, 4478, 4479, 4480, 4481, 4482, 4483, 4484, + 4485, 4492, 4493, 4494, 4495, 4496, 4497, 4504, 4505, 4506, + 4507, 4508, 4509, 4514, 4516, 4517, 4518, 4519, 4521, 4526, + 4528, 4529, 4530, 4531, 4533, 4537, 4538, 4540, 4546, 4560, + 4568, 4535, 4536, 4539, 4554, 4562, 4569, 4570, 4571, 4572, + + 4579, 4580, 4581, 4582, 4583, 4584, 4585, 4586, 4587, 4588, + 4589, 4590, 4591, 4592, 4593, 4594, 4595, 4602, 4603, 4604, + 4605, 4606, 4607, 4611, 4614, 4615, 4616, 4618, 4619, 4623, + 4626, 4627, 4628, 4629, 4630, 4631, 4635, 4638, 4639, 4640, + 4642, 4643, 4648, 4662, 4670, 4641, 4656, 4664, 4671, 4672, + 4673, 4674, 4681, 4682, 4683, 4684, 4685, 4686, 4687, 4688, + 4689, 4690, 4691, 4692, 4693, 4694, 4701, 4702, 4703, 4704, + 4705, 4706, 4712, 4713, 4714, 4715, 4716, 4717, 4724, 4725, + 4726, 4727, 4728, 4729, 4735, 4736, 4737, 4738, 4744, 4758, + 4766, 4733, 4734, 4752, 4760, 4767, 4768, 4769, 4770, 4777, + + 4778, 4779, 4780, 4781, 4782, 4783, 4784, 4785, 4792, 4793, + 4794, 4795, 4796, 4797, 4804, 4805, 4806, 4807, 4808, 4809, + 4810, 4814, 4817, 4818, 4819, 4821, 4822, 4827, 4841, 4849, + 4820, 4835, 4843, 4850, 4851, 4852, 4853, 4860, 4861, 4862, + 4863, 4864, 4865, 4872, 4873, 4874, 4875, 4876, 4877, 4884, + 4885, 4886, 4887, 4888, 4889, 4894, 4896, 4897, 4903, 4917, + 4925, 4892, 4893, 4895, 4911, 4919, 4926, 4927, 4928, 4929, + 4936, 4943, 4944, 4945, 4946, 4947, 4948, 4952, 4955, 4956, + 4957, 4959, 4960, 4964, 4966, 4980, 4988, 4966, 4974, 4982, + 4989, 4990, 4991, 4998, 5005, 5006, 5007, 5008, 5009, 5010, + + 5016, 5017, 5018, 5019, 5025, 5039, 5047, 5014, 5015, 5033, + 5041, 5048, 5063, 5055, 5069, 5070, 5071, 5072, 5073, 5074, + 5056, 5080, 5094, 5102, 5051, 5080, 5118, 5123, 5094, 5129, + 5130, 5131, 5132, 5138, 5152, 5160, 5096, 5109, 5177, 5178, + 5184, 5198, 5206, 5223, 5229, 5243, 5251, 5267, 5281, 5289, + 5305, 5319, 5327, 5343, 5357, 5365, 5381, 5395, 5403, 5419, + 5433, 5441, 5457, 5471, 5479, 5495, 5509, 5517, 5533, 5547, + 5555, 5571, 5585, 5593, 5609, 5623, 5631, 5647, 5661, 5669, + 5685, 5699, 5707, 5723, 5737, 5745, 5761, 5775, 5783, 5799, + 5813, 5821, 5837, 5851, 5859, 5875, 5889, 5897, 5913, 5927, + + 5935, 5951, 5965, 5973, 5989, 6003, 6011, 6027, 6041, 6049, + 6065, 6079, 6087, 6103, 6117, 6125, 6141, 6155, 6163, 6179, + 6193, 6201, 6217, 6231, 6239, 6255, 6269, 6276,10685, 6303, + 6311, 6317, 6321, 6327, 6329, 6332, 6335, 6337, 6339, 6342, + 6346, 6348, 6350, 6352, 6354, 6357, 6360, 6363, 6365, 6367, + 6369, 6371, 6373, 6375, 6378, 6381, 6383, 6387, 6389, 6391, + 6393, 6395, 6397, 6399, 6401, 6403, 6405, 6408, 6411, 6413, + 6416, 6419, 6422, 6424, 6426, 6428, 6430, 6432, 6434, 6436, + 6438, 6440, 6442, 6444, 6446, 6449, 6452, 6454, 6457, 6460, + 6462, 6465, 6469, 6471, 6473, 6475, 6477, 6479, 6481, 6483, + + 6485, 6487, 6489, 6491, 6493, 6495, 6497, 6499, 6501, 6503, + 6506, 6509, 6511, 6514, 6517, 6519, 6522, 6525, 6528, 6531, + 6534, 6539, 6541, 6543, 6545, 6547, 6549, 6551, 6553, 6555, + 6557, 6559, 6561, 6563, 6565, 6567, 6569, 6571, 6573, 6575, + 6577, 6579, 6581, 6584, 6587, 6589, 6592, 6595, 6598, 6601, + 6604, 6607, 6609, 6612, 6615, 6619, 6624, 6626, 6628, 6630, + 6632, 6634, 6636, 6638, 6640, 6642, 6644, 6646, 6648, 6650, + 6652, 6654, 6656, 6658, 6660, 6662, 6664, 6666, 6668, 6670, + 6672, 6674, 6676, 6679, 6682, 6684, 6687, 6690, 6692, 6695, + 6698, 6701, 6703, 6706, 6709, 6712, 6715, 6718, 6721, 6724, + + 6729, 6731, 6733, 6735, 6737, 6739, 6741, 6743, 6745, 6747, + 6749, 6751, 6753, 6755, 6757, 6759, 6761, 6763, 6765, 6767, + 6769, 6771, 6773, 6775, 6777, 6779, 6781, 6783, 6785, 6787, + 6790, 6793, 6795, 6798, 6801, 6803, 6806, 6809, 6812, 6815, + 6818, 6821, 6824, 6827, 6829, 6832, 6835, 6839, 6844, 6846, + 6848, 6850, 6852, 6854, 6856, 6858, 6860, 6862, 6864, 6866, + 6868, 6870, 6872, 6874, 6876, 6878, 6880, 6882, 6884, 6886, + 6888, 6890, 6892, 6894, 6896, 6898, 6900, 6902, 6904, 6906, + 6908, 6910, 6912, 6914, 6917, 6920, 6922, 6925, 6928, 6930, + 6933, 6936, 6939, 6942, 6944, 6947, 6950, 6953, 6955, 6958, + + 6961, 6964, 6967, 6970, 6973, 6976, 6981, 6983, 6985, 6987, + 6989, 6991, 6993, 6995, 6997, 6999, 7001, 7003, 7005, 7007, + 7009, 7011, 7013, 7015, 7017, 7019, 7021, 7023, 7025, 7027, + 7029, 7031, 7033, 7035, 7037, 7039, 7041, 7043, 7045, 7047, + 7049, 7051, 7053, 7055, 7058, 7061, 7063, 7066, 7069, 7072, + 7075, 7078, 7081, 7083, 7086, 7089, 7092, 7095, 7098, 7101, + 7104, 7107, 7110, 7112, 7115, 7118, 7122, 7127, 7129, 7131, + 7133, 7135, 7137, 7139, 7141, 7143, 7145, 7147, 7149, 7151, + 7153, 7155, 7157, 7159, 7161, 7163, 7165, 7167, 7169, 7171, + 7173, 7175, 7177, 7179, 7181, 7183, 7185, 7187, 7189, 7191, + + 7193, 7195, 7197, 7199, 7201, 7203, 7205, 7207, 7209, 7211, + 7213, 7216, 7219, 7221, 7224, 7227, 7229, 7232, 7235, 7238, + 7240, 7243, 7246, 7249, 7252, 7255, 7258, 7260, 7263, 7266, + 7269, 7271, 7274, 7277, 7280, 7283, 7286, 7289, 7292, 7297, + 7299, 7301, 7303, 7305, 7307, 7309, 7311, 7313, 7315, 7317, + 7319, 7321, 7323, 7325, 7327, 7329, 7331, 7333, 7335, 7337, + 7339, 7341, 7343, 7345, 7347, 7349, 7351, 7353, 7355, 7357, + 7359, 7361, 7363, 7365, 7367, 7369, 7371, 7373, 7375, 7377, + 7379, 7381, 7383, 7385, 7387, 7390, 7393, 7395, 7398, 7401, + 7403, 7406, 7409, 7412, 7415, 7418, 7421, 7424, 7427, 7429, + + 7432, 7435, 7438, 7441, 7444, 7447, 7450, 7453, 7456, 7458, + 7461, 7464, 7468, 7473, 7475, 7477, 7479, 7481, 7483, 7485, + 7487, 7489, 7491, 7493, 7495, 7497, 7499, 7501, 7503, 7505, + 7507, 7509, 7511, 7513, 7515, 7517, 7519, 7521, 7523, 7525, + 7527, 7529, 7531, 7533, 7535, 7537, 7539, 7541, 7543, 7545, + 7547, 7549, 7551, 7553, 7555, 7557, 7559, 7561, 7563, 7565, + 7567, 7569, 7571, 7573, 7575, 7577, 7580, 7583, 7585, 7588, + 7591, 7593, 7596, 7599, 7602, 7605, 7607, 7610, 7613, 7616, + 7618, 7621, 7624, 7627, 7630, 7633, 7636, 7638, 7641, 7644, + 7647, 7649, 7652, 7655, 7658, 7661, 7664, 7667, 7670, 7675, + + 7677, 7679, 7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, + 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715, + 7717, 7719, 7721, 7723, 7725, 7727, 7729, 7731, 7733, 7735, + 7737, 7739, 7741, 7743, 7745, 7747, 7749, 7751, 7753, 7755, + 7757, 7759, 7761, 7763, 7765, 7767, 7769, 7771, 7773, 7775, + 7777, 7779, 7781, 7784, 7787, 7789, 7792, 7795, 7798, 7801, + 7804, 7807, 7809, 7812, 7815, 7818, 7821, 7824, 7827, 7830, + 7833, 7836, 7838, 7841, 7844, 7847, 7850, 7853, 7856, 7859, + 7862, 7865, 7867, 7870, 7873, 7877, 7882, 7884, 7886, 7888, + 7890, 7892, 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, + + 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928, + 7930, 7932, 7934, 7936, 7938, 7940, 7942, 7944, 7946, 7948, + 7950, 7952, 7954, 7956, 7958, 7960, 7962, 7964, 7966, 7968, + 7970, 7972, 7974, 7976, 7978, 7980, 7982, 7984, 7986, 7988, + 7990, 7992, 7994, 7996, 7998, 8001, 8004, 8006, 8009, 8012, + 8014, 8017, 8020, 8023, 8025, 8028, 8031, 8034, 8037, 8040, + 8043, 8045, 8048, 8051, 8054, 8056, 8059, 8062, 8065, 8068, + 8071, 8074, 8076, 8079, 8082, 8085, 8087, 8090, 8093, 8096, + 8099, 8102, 8105, 8108, 8113, 8115, 8117, 8119, 8121, 8123, + 8125, 8127, 8129, 8131, 8133, 8135, 8137, 8139, 8141, 8143, + + 8145, 8147, 8149, 8151, 8153, 8155, 8157, 8159, 8161, 8163, + 8165, 8167, 8169, 8171, 8173, 8175, 8177, 8179, 8181, 8183, + 8185, 8187, 8189, 8191, 8193, 8195, 8197, 8199, 8201, 8203, + 8205, 8207, 8209, 8211, 8213, 8215, 8217, 8219, 8221, 8223, + 8225, 8227, 8229, 8232, 8235, 8237, 8240, 8243, 8245, 8248, + 8251, 8254, 8257, 8260, 8263, 8266, 8269, 8271, 8274, 8277, + 8280, 8283, 8286, 8289, 8292, 8295, 8298, 8300, 8303, 8306, + 8309, 8312, 8315, 8318, 8321, 8324, 8327, 8329, 8332, 8335, + 8339, 8344, 8346, 8348, 8350, 8352, 8354, 8356, 8358, 8360, + 8362, 8364, 8366, 8368, 8370, 8372, 8374, 8376, 8378, 8380, + + 8382, 8384, 8386, 8388, 8390, 8392, 8394, 8396, 8398, 8400, + 8402, 8404, 8406, 8408, 8410, 8412, 8414, 8416, 8418, 8420, + 8422, 8424, 8426, 8428, 8430, 8432, 8434, 8436, 8438, 8440, + 8442, 8444, 8446, 8448, 8450, 8452, 8454, 8456, 8458, 8460, + 8462, 8465, 8468, 8470, 8473, 8476, 8479, 8482, 8485, 8487, + 8490, 8493, 8496, 8498, 8501, 8504, 8507, 8510, 8513, 8516, + 8518, 8521, 8524, 8527, 8529, 8532, 8535, 8538, 8541, 8544, + 8547, 8549, 8552, 8555, 8558, 8560, 8563, 8566, 8569, 8572, + 8575, 8578, 8581, 8586, 8588, 8590, 8592, 8594, 8596, 8598, + 8600, 8602, 8604, 8606, 8608, 8610, 8612, 8614, 8616, 8618, + + 8620, 8622, 8624, 8626, 8628, 8630, 8632, 8634, 8636, 8638, + 8640, 8642, 8644, 8646, 8648, 8650, 8652, 8654, 8656, 8658, + 8660, 8662, 8664, 8666, 8668, 8670, 8672, 8674, 8676, 8678, + 8680, 8682, 8684, 8686, 8688, 8690, 8692, 8694, 8696, 8698, + 8700, 8703, 8706, 8709, 8712, 8714, 8717, 8720, 8723, 8726, + 8729, 8732, 8735, 8738, 8741, 8743, 8746, 8749, 8752, 8755, + 8758, 8761, 8764, 8767, 8770, 8772, 8775, 8778, 8781, 8784, + 8787, 8790, 8793, 8796, 8799, 8801, 8804, 8807, 8811, 8816, + 8818, 8820, 8822, 8824, 8826, 8828, 8830, 8832, 8834, 8836, + 8838, 8840, 8842, 8844, 8846, 8848, 8850, 8852, 8854, 8856, + + 8858, 8860, 8862, 8864, 8866, 8868, 8870, 8872, 8874, 8876, + 8878, 8880, 8882, 8884, 8886, 8888, 8890, 8892, 8894, 8896, + 8898, 8900, 8902, 8904, 8906, 8908, 8910, 8912, 8914, 8916, + 8918, 8920, 8922, 8924, 8926, 8928, 8931, 8934, 8937, 8940, + 8943, 8946, 8949, 8951, 8954, 8957, 8960, 8963, 8966, 8969, + 8972, 8975, 8977, 8980, 8983, 8986, 8988, 8991, 8994, 8997, + 9000, 9003, 9006, 9008, 9011, 9014, 9017, 9019, 9022, 9025, + 9028, 9031, 9034, 9037, 9040, 9045, 9047, 9049, 9051, 9053, + 9055, 9057, 9059, 9061, 9063, 9065, 9067, 9069, 9071, 9073, + 9075, 9077, 9079, 9081, 9083, 9085, 9087, 9089, 9091, 9093, + + 9095, 9097, 9099, 9101, 9103, 9105, 9107, 9109, 9111, 9113, + 9115, 9117, 9119, 9121, 9123, 9125, 9127, 9129, 9131, 9133, + 9135, 9137, 9139, 9141, 9143, 9145, 9147, 9150, 9153, 9156, + 9159, 9162, 9165, 9168, 9171, 9174, 9177, 9179, 9182, 9185, + 9188, 9191, 9194, 9197, 9200, 9203, 9206, 9208, 9211, 9214, + 9217, 9220, 9223, 9226, 9229, 9232, 9235, 9237, 9240, 9243, + 9247, 9252, 9254, 9256, 9258, 9260, 9262, 9264, 9266, 9268, + 9270, 9272, 9274, 9276, 9278, 9280, 9282, 9284, 9286, 9288, + 9290, 9292, 9294, 9296, 9298, 9300, 9302, 9304, 9306, 9308, + 9310, 9312, 9314, 9316, 9318, 9320, 9322, 9324, 9326, 9328, + + 9330, 9332, 9334, 9336, 9338, 9341, 9344, 9347, 9350, 9352, + 9355, 9358, 9361, 9364, 9367, 9370, 9373, 9375, 9378, 9381, + 9384, 9386, 9389, 9392, 9395, 9398, 9401, 9404, 9406, 9409, + 9412, 9415, 9417, 9420, 9423, 9426, 9429, 9432, 9435, 9438, + 9443, 9445, 9447, 9449, 9451, 9453, 9455, 9457, 9459, 9461, + 9463, 9465, 9467, 9469, 9471, 9473, 9475, 9477, 9479, 9481, + 9483, 9485, 9487, 9489, 9491, 9493, 9495, 9497, 9499, 9501, + 9503, 9505, 9507, 9509, 9511, 9513, 9515, 9517, 9519, 9522, + 9525, 9528, 9531, 9534, 9537, 9539, 9542, 9545, 9548, 9551, + 9554, 9557, 9560, 9563, 9566, 9568, 9571, 9574, 9577, 9580, + + 9583, 9586, 9589, 9592, 9595, 9597, 9600, 9603, 9607, 9612, + 9614, 9616, 9618, 9620, 9622, 9624, 9626, 9628, 9630, 9632, + 9634, 9636, 9638, 9640, 9642, 9644, 9646, 9648, 9650, 9652, + 9654, 9656, 9658, 9660, 9662, 9664, 9666, 9668, 9670, 9672, + 9674, 9676, 9678, 9680, 9682, 9685, 9688, 9691, 9694, 9697, + 9700, 9703, 9705, 9708, 9711, 9714, 9717, 9720, 9723, 9726, + 9729, 9731, 9734, 9737, 9740, 9742, 9745, 9748, 9751, 9754, + 9757, 9760, 9763, 9768, 9770, 9772, 9774, 9776, 9778, 9780, + 9782, 9784, 9786, 9788, 9790, 9792, 9794, 9796, 9798, 9800, + 9802, 9804, 9806, 9808, 9810, 9812, 9814, 9816, 9818, 9820, + + 9822, 9824, 9826, 9829, 9832, 9835, 9838, 9841, 9844, 9847, + 9850, 9853, 9856, 9858, 9861, 9864, 9867, 9870, 9873, 9876, + 9879, 9882, 9885, 9887, 9890, 9893, 9897, 9902, 9904, 9906, + 9908, 9910, 9912, 9914, 9916, 9918, 9920, 9922, 9924, 9926, + 9928, 9930, 9932, 9934, 9936, 9938, 9940, 9942, 9944, 9946, + 9948, 9951, 9954, 9957, 9960, 9962, 9965, 9968, 9971, 9974, + 9977, 9980, 9983, 9985, 9988, 9991, 9994, 9996, 9999,10002, + 10005,10008,10011,10014,10017,10022,10024,10026,10028,10030, + 10032,10034,10036,10038,10040,10042,10044,10046,10048,10050, + 10052,10054,10056,10058,10061,10064,10067,10070,10073,10076, + + 10078,10081,10084,10087,10090,10093,10096,10099,10102,10105, + 10107,10110,10113,10117,10122,10124,10126,10128,10130,10132, + 10134,10136,10138,10140,10142,10144,10146,10148,10150,10152, + 10154,10157,10160,10163,10166,10169,10172,10175,10177,10180, + 10183,10186,10189,10192,10195,10198,10201,10204,10209,10211, + 10213,10215,10217,10219,10221,10223,10225,10227,10230,10233, + 10236,10239,10242,10245,10248,10251,10253,10256,10259,10263, + 10265,10267,10269,10271,10273,10275,10277,10280,10283,10286, + 10289,10292,10295,10298,10301,10304,10307,10309,10311,10313, + 10315,10318,10320,10323,10326,10329,10332,10335,10339,10341, + + 10343,10346,10348,10351,10354,10357,10361,10363,10366,10368, + 10371,10375,10378,10382,10386,10390,10394,10398,10402,10406, + 10410,10414,10418,10422,10426,10430,10434,10438,10442,10446, + 10450,10454,10458,10462,10466,10470,10474,10478,10482,10486 + } ; + +static yyconst flex_int16_t yy_def[4541] = + { 0, + 2829, 1, 2829, 2829, 2829, 2829, 2829, 2830, 2829, 2831, + 2832, 2832, 2829, 2833, 2833, 15, 15, 15, 15, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 15, 15, 15, 2833, 2833, 2829, 2829, + 2830, 2829, 2829, 2831, 2829, 2834, 2834, 2835, 2834, 2836, + 2833, 15, 52, 2833, 52, 52, 2829, 52, 2833, 52, + 2833, 2833, 52, 2833, 2833, 2833, 2833, 2833, 2833, 52, + 2833, 2833, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2829, 2833, 2833, 2829, 2833, 2833, 2833, 2833, 2833, + + 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2837, 2837, 2838, 2837, 2839, 2836, 2829, + 2840, 52, 2833, 2833, 2829, 132, 132, 132, 2833, 132, + 2833, 2833, 132, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2829, 2833, 2829, 2833, 2833, 2829, 2833, 2829, 2833, + 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2829, 2829, + 2841, 2841, 2842, 2841, 2843, 2844, 2845, 2829, 2829, 2846, + 2847, 132, 2833, 2833, 2829, 222, 2833, 2833, 2833, 2833, + 2833, 2833, 222, 2833, 2833, 2833, 2833, 2833, 2833, 2829, + 2833, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2829, 2833, 2829, 2833, 2833, 2829, 2833, 2829, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2829, 2829, 2829, 2829, 2848, 2848, 2849, + + 2848, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 222, + 2833, 2833, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2833, 2833, + 2833, 2833, 2833, 2833, 2829, 2829, 2833, 2833, 2833, 2829, + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2833, 2833, + 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2829, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2829, + 2833, 2829, 2829, 2829, 2858, 2858, 2859, 2858, 2860, 2861, + 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, + 2872, 222, 2833, 2833, 2833, 2833, 2833, 2829, 2833, 2833, + + 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2829, + 2833, 2833, 2833, 2833, 2833, 2829, 2829, 2829, 2829, 2829, + 2829, 2833, 2833, 2833, 2829, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2829, 2833, 2833, 2829, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2829, 2833, 2833, + 2833, 2833, 2833, 2829, 2833, 2829, 2829, 2829, 2873, 2873, + 2874, 2873, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, + 2883, 2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, + 222, 2833, 2833, 2833, 2829, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2833, 2833, 2833, + + 2829, 2829, 2829, 2829, 2829, 2829, 2833, 2833, 2833, 2833, + 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2829, 2833, + 2833, 2829, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, + 2833, 2833, 2829, 2829, 2833, 2833, 2833, 2833, 2829, 2833, + 2829, 2829, 2893, 2893, 2894, 2893, 2895, 2896, 2897, 2898, + 2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, + 2909, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, + 2919, 2920, 2921, 2921, 2829, 2921, 2921, 2921, 2921, 2921, + 2921, 2921, 2921, 2921, 2921, 2921, 2829, 2921, 2921, 2829, + 2829, 2829, 2829, 2829, 2829, 2921, 2921, 2921, 2921, 2829, + + 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, + 2829, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, + 2921, 2829, 2829, 2921, 2921, 2921, 2921, 2829, 2921, 2829, + 2829, 2922, 2922, 2923, 2922, 2924, 2925, 2926, 2927, 2928, + 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, + 2939, 2940, 2927, 2941, 2942, 2943, 2944, 2945, 2946, 2947, + 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2956, 2956, + 2829, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, + 2956, 2956, 2829, 2829, 2829, 2829, 2829, 2829, 2956, 2956, + 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, + + 2829, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, + 2956, 2829, 2956, 2957, 2957, 2958, 2957, 2959, 2960, 2961, + 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, + 2972, 2973, 2974, 2975, 2976, 2962, 2977, 2978, 2979, 2980, + 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, + 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, + 3000, 2829, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, + 3000, 3000, 2829, 2829, 2829, 2829, 2829, 2829, 3000, 3000, + 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 2829, 3000, + 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3001, 3001, 3002, + + 3001, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, + 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3005, + 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3011, 3028, 3029, + 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, + 3040, 3041, 3042, 3043, 3044, 3036, 3045, 3046, 3047, 3048, + 3048, 3048, 3048, 3048, 3048, 3048, 3048, 3048, 3048, 3048, + 3048, 2829, 2829, 2829, 2829, 2829, 2829, 3048, 3048, 3048, + 3048, 3048, 3048, 3048, 3048, 3048, 3048, 3048, 3048, 3048, + 3048, 3048, 3048, 3048, 3049, 3049, 3050, 3049, 3051, 3052, + 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, + + 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, + 3073, 3074, 3075, 3076, 3077, 3059, 3078, 3079, 3080, 3081, + 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, + 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3090, 3099, 3100, + 3101, 3102, 3103, 3104, 3105, 3106, 3106, 3106, 3106, 3106, + 3106, 3106, 3106, 3106, 3106, 3106, 2829, 2829, 2829, 2829, + 2829, 2829, 3106, 3106, 3106, 3106, 3106, 3106, 3106, 3106, + 3106, 3106, 3106, 3106, 3106, 3106, 3106, 3107, 3107, 3108, + 3107, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, + 3118, 3119, 3120, 3112, 3121, 3122, 3123, 3124, 3125, 3126, + + 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3115, 3135, + 3136, 3137, 3138, 3139, 3140, 3141, 3122, 3142, 3143, 3144, + 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, + 3155, 3156, 3149, 3157, 3158, 3159, 3160, 3161, 3162, 3163, + 3155, 3164, 3165, 3166, 3167, 3167, 3167, 3167, 3167, 3167, + 3167, 3167, 3167, 3167, 2829, 2829, 2829, 2829, 3167, 3167, + 3167, 3167, 3167, 3167, 3167, 3167, 3167, 3167, 3167, 3167, + 3167, 3167, 3168, 3168, 3169, 3168, 3170, 3171, 3172, 3173, + 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3173, 3182, + 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, + + 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, + 3203, 3204, 3183, 3205, 3206, 3207, 3208, 3209, 3210, 3211, + 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, + 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, + 3222, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3239, + 3239, 3239, 3239, 3239, 3239, 3239, 2829, 2829, 2829, 2829, + 3239, 3239, 3239, 3239, 3239, 3239, 3239, 3239, 3239, 3239, + 3239, 3239, 3239, 3239, 3240, 3240, 3241, 3240, 3242, 3243, + 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3244, 3252, + 3253, 3254, 3255, 3256, 3257, 3258, 3250, 3259, 3260, 3261, + + 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, + 3272, 3273, 3274, 3275, 3253, 3276, 3277, 3278, 3279, 3280, + 3281, 3282, 3260, 3283, 3284, 3285, 3286, 3287, 3288, 3289, + 3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, + 3291, 3300, 3301, 3302, 3294, 3303, 3304, 3305, 3306, 3307, + 3308, 3309, 3301, 3310, 3311, 3312, 3313, 3313, 3313, 3313, + 3313, 3313, 3313, 2829, 2829, 3313, 3313, 3313, 3313, 3313, + 3313, 3313, 3313, 3313, 3313, 3313, 3313, 3313, 3314, 3314, + 3315, 3314, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, + 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, + + 3324, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, + 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, + 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3335, 3360, 3361, + 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, + 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3372, + 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, + 3391, 3382, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, + 3399, 3399, 3399, 3399, 3399, 3399, 2829, 2829, 3399, 3399, + 3399, 3399, 3399, 3399, 3399, 3399, 3399, 3399, 3400, 3400, + 3401, 3400, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, + + 3410, 3411, 3412, 3413, 3405, 3414, 3415, 3416, 3408, 3417, + 3418, 3419, 3420, 3421, 3422, 3423, 3415, 3424, 3425, 3426, + 3427, 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, + 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3418, 3444, 3445, + 3446, 3447, 3448, 3449, 3450, 3425, 3451, 3452, 3453, 3454, + 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, + 3465, 3458, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3464, + 3473, 3474, 3475, 3467, 3476, 3477, 3478, 3479, 3480, 3481, + 3482, 3474, 3483, 3484, 3485, 3486, 3486, 3486, 3486, 3486, + 3486, 2829, 2829, 3486, 3486, 3486, 3486, 3486, 3486, 3486, + + 3487, 3487, 3488, 3487, 3489, 3490, 3491, 3492, 3493, 3494, + 3495, 3496, 3497, 3498, 3490, 3499, 3500, 3501, 3502, 3503, + 3504, 3505, 3506, 3507, 3508, 3509, 3500, 3510, 3511, 3512, + 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3522, + 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, + 3533, 3534, 3535, 3536, 3537, 3538, 3511, 3539, 3540, 3541, + 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, + 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, + 3562, 3563, 3564, 3565, 3556, 3566, 3567, 3568, 3569, 3570, + 3571, 3572, 3573, 3574, 3575, 3576, 3567, 3577, 3578, 3579, + + 3580, 3581, 3582, 3583, 3584, 3584, 3584, 3584, 3584, 2829, + 2829, 3584, 3584, 3584, 3584, 3584, 3584, 3585, 3585, 3585, + 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3585, 3592, 3593, + 3594, 3595, 3596, 3597, 3598, 3590, 3599, 3600, 3601, 3593, + 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3600, 3609, 3610, + 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, + 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, + 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, + 3641, 3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, + 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3649, 3658, 3659, + + 3660, 3652, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3659, + 3668, 3669, 3670, 3662, 3671, 3672, 3673, 3674, 3675, 3676, + 3677, 3669, 3678, 3679, 3680, 3681, 3681, 3681, 3681, 3681, + 2829, 2829, 3681, 3681, 3681, 3681, 3681, 3681, 3682, 3682, + 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3685, 3689, 3690, + 3688, 3684, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, + 3699, 3700, 3701, 3692, 3702, 3703, 3704, 3705, 3706, 3707, + 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, + 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725, 3726, 3727, + 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, + + 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, + 3748, 3749, 3750, 3751, 3752, 3753, 3745, 3754, 3755, 3756, + 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3755, 3765, + 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, + 3766, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3783, + 3783, 3783, 2829, 2829, 3783, 3783, 3783, 3783, 3783, 3783, + 3784, 3784, 3785, 3786, 3787, 3788, 3789, 3787, 3790, 3791, + 3792, 3793, 3794, 3788, 3795, 3796, 3797, 3790, 3798, 3799, + 3800, 3801, 3802, 3803, 3804, 3796, 3805, 3806, 3807, 3808, + 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817, 3818, + + 3819, 3820, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, + 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, + 3839, 3840, 3841, 3842, 3842, 3843, 3844, 3845, 3846, 3847, + 3848, 3842, 3849, 3850, 3851, 3852, 3853, 3854, 3855, 3847, + 3856, 3857, 3858, 3850, 3859, 3860, 3861, 3862, 3863, 3864, + 3865, 3857, 3866, 3867, 3868, 3860, 3869, 3870, 3871, 3872, + 3873, 3874, 3875, 3867, 3876, 3877, 3878, 3879, 2829, 2829, + 3879, 3879, 3879, 3880, 3880, 3881, 3882, 3883, 3884, 3882, + 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3894, + 3895, 3896, 3887, 3897, 3898, 3899, 3900, 3901, 3902, 3903, + + 3904, 3905, 3906, 3907, 3908, 3909, 3910, 3911, 3912, 3913, + 3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922, 3923, + 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3932, 3933, + 3934, 3935, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3943, + 3940, 3944, 3945, 3943, 3939, 3946, 3947, 3948, 3949, 3950, + 3951, 3952, 3953, 3954, 3955, 3956, 3947, 3957, 3958, 3959, + 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3958, 3968, + 3969, 3970, 3971, 3972, 3973, 3974, 3975, 2829, 2829, 3975, + 3975, 3976, 3976, 3977, 3978, 3979, 3980, 3981, 3982, 3978, + 3983, 3984, 3985, 3978, 3986, 3987, 3988, 3989, 3990, 3991, + + 3992, 3984, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, + 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, + 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, + 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, + 4031, 4032, 4030, 4033, 4034, 4035, 4036, 4037, 4031, 4038, + 4039, 4040, 4033, 4041, 4042, 4043, 4044, 4045, 4046, 4047, + 4039, 4048, 4049, 4050, 4042, 4051, 4052, 4053, 4054, 4055, + 4056, 4057, 4049, 4058, 4059, 4060, 4061, 2829, 2829, 4061, + 4061, 4062, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, + 4066, 4070, 4071, 4069, 4065, 4072, 4073, 4074, 4075, 4076, + + 4077, 4078, 4062, 4079, 4080, 4081, 4082, 4083, 4084, 4085, + 4086, 4087, 4088, 4089, 4090, 4091, 4092, 4093, 4094, 4095, + 4096, 4097, 4098, 4073, 4099, 4100, 4101, 4102, 4103, 4104, + 4105, 4106, 4107, 4108, 4109, 4107, 4110, 4111, 4112, 4113, + 4114, 4115, 4116, 4117, 4118, 4119, 4120, 4121, 4112, 4122, + 4123, 4124, 4125, 4126, 4127, 4128, 4129, 4130, 4131, 4132, + 4123, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4140, 2829, + 2829, 4140, 4140, 4140, 4141, 4141, 4142, 4143, 4144, 4145, + 4146, 4144, 4147, 4148, 4149, 4150, 4151, 4145, 4152, 4153, + 4154, 4155, 4156, 4157, 4158, 4159, 4160, 4161, 4162, 4163, + + 4164, 4165, 4166, 4167, 4168, 4169, 4147, 4170, 4171, 4172, + 4173, 4174, 4175, 4176, 4153, 4177, 4178, 4179, 4180, 4181, + 4182, 4183, 4184, 4185, 4181, 4186, 4187, 4188, 4181, 4189, + 4190, 4191, 4192, 4193, 4194, 4195, 4187, 4196, 4197, 4198, + 4190, 4199, 4200, 4201, 4202, 4203, 4204, 4205, 4197, 4206, + 4207, 4208, 4209, 4209, 4209, 4210, 4210, 4211, 4212, 4213, + 4214, 4212, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, + 4223, 4224, 4225, 4226, 4227, 4228, 4229, 4230, 4231, 4232, + 4233, 4234, 4235, 4236, 4237, 4238, 4217, 4239, 4240, 4241, + 4242, 4243, 4244, 4245, 4246, 4247, 4248, 4249, 4250, 4251, + + 4252, 4249, 4253, 4254, 4252, 4248, 4255, 4256, 4257, 4258, + 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4256, 4266, 4267, + 4268, 4269, 4270, 4271, 4272, 4273, 4273, 4274, 4274, 4275, + 4276, 4277, 4278, 4279, 4280, 4276, 4281, 4282, 4283, 4284, + 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293, 4276, + 4294, 4295, 4296, 4297, 4298, 4299, 4300, 4282, 4301, 4302, + 4303, 4304, 4305, 4306, 4307, 4308, 4306, 4309, 4310, 4311, + 4312, 4313, 4307, 4314, 4315, 4316, 4309, 4317, 4318, 4319, + 4320, 4321, 4322, 4323, 4315, 4324, 4325, 4326, 4327, 4328, + 4328, 4329, 4330, 4331, 4332, 4333, 4334, 4335, 4336, 4337, + + 4329, 4338, 4339, 4340, 4341, 4332, 4342, 4343, 4344, 4331, + 4345, 4346, 4347, 4348, 4349, 4350, 4351, 4352, 4353, 4354, + 4355, 4353, 4356, 4357, 4358, 4359, 4360, 4361, 4362, 4363, + 4364, 4365, 4366, 4367, 4358, 4368, 4369, 4370, 4371, 4372, + 4373, 4374, 4375, 4376, 4376, 4377, 4378, 4379, 4380, 4381, + 4382, 4383, 4377, 4384, 4385, 4379, 4386, 4387, 4388, 4389, + 4390, 4391, 4380, 4392, 4393, 4394, 4395, 4396, 4397, 4398, + 4399, 4400, 4396, 4401, 4402, 4403, 4396, 4404, 4405, 4406, + 4407, 4408, 4409, 4410, 4402, 4411, 4412, 4413, 4414, 4415, + 4415, 4416, 4417, 4418, 4419, 4420, 4421, 4417, 4422, 4423, + + 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4431, 4432, 4433, + 4434, 4435, 4436, 4437, 4438, 4435, 4439, 4440, 4438, 4434, + 4441, 4442, 4443, 4444, 4445, 4446, 4447, 4448, 4449, 4449, + 4425, 4450, 4451, 4452, 4453, 4428, 4454, 4455, 4431, 4450, + 4456, 4457, 4458, 4436, 4434, 4459, 4460, 4461, 4459, 4462, + 4463, 4464, 4465, 4466, 4460, 4467, 4468, 4469, 4448, 4470, + 4470, 4454, 4471, 4472, 4454, 4456, 4473, 4474, 4475, 4476, + 4477, 4463, 4478, 4479, 4466, 4478, 4460, 4480, 4481, 4482, + 4483, 4484, 4485, 4486, 2659, 4487, 4487, 4488, 4489, 4475, + 4488, 4490, 4491, 4492, 4480, 4493, 4483, 4494, 4495, 4486, + + 4493, 4496, 4497, 4498, 2659, 4499, 4499, 4475, 4500, 2829, + 4501, 2829, 2829, 4502, 4494, 4496, 4503, 4504, 4505, 4506, + 2829, 2705, 4507, 4507, 4508, 4508, 2829, 2829, 4509, 4505, + 4503, 4510, 4511, 2705, 4512, 4512, 2829, 2829, 4513, 2829, + 2705, 4514, 4514, 4511, 2705, 4515, 4515, 2745, 4516, 4516, + 2745, 4517, 4517, 2745, 4518, 4518, 2745, 4519, 4519, 2757, + 4520, 4520, 2757, 4521, 4521, 2757, 4522, 4522, 2757, 4523, + 4523, 2769, 4524, 4524, 2769, 4525, 4525, 2769, 4526, 4526, + 2769, 4527, 4527, 2781, 4528, 4528, 2781, 4529, 4529, 2781, + 4530, 4530, 2781, 4531, 4531, 2793, 4532, 4532, 2793, 4533, + + 4533, 2793, 4534, 4534, 2793, 4535, 4535, 2805, 4536, 4536, + 2805, 4537, 4537, 2805, 4538, 4538, 2805, 4539, 4539, 2817, + 4540, 4540, 2817, 2829, 2829, 2817, 2829, 2829, 0, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829 + } ; + +static yyconst flex_int16_t yy_nxt[10753] = + { 0, + 4, 5, 6, 7, 5, 4, 8, 9, 4, 10, + 11, 11, 12, 12, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 23, 30, 31, 32, 33, 23, 23, 23, + 23, 4, 34, 35, 35, 35, 35, 36, 23, 23, + 23, 23, 23, 23, 37, 28, 38, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 39, 40, 2829, 1416, + 40, 43, 43, 43, 43, 43, 45, 2829, 46, 46, + 47, 47, 47, 48, 45, 1437, 47, 47, 47, 47, + 47, 48, 52, 52, 52, 52, 52, 48, 52, 52, + + 53, 52, 52, 52, 40, 351, 52, 40, 59, 54, + 63, 2829, 65, 2829, 64, 2829, 130, 172, 126, 2829, + 52, 673, 50, 60, 52, 52, 55, 56, 52, 52, + 61, 351, 361, 362, 54, 66, 62, 2829, 2829, 67, + 76, 2829, 2829, 172, 2829, 2829, 80, 351, 57, 52, + 52, 52, 52, 52, 48, 52, 52, 52, 52, 52, + 52, 68, 2829, 2829, 2829, 172, 2829, 2829, 81, 74, + 2829, 102, 69, 103, 1445, 672, 82, 707, 77, 70, + 75, 58, 52, 52, 52, 52, 52, 71, 2829, 2829, + 2829, 54, 2829, 2829, 72, 78, 69, 2829, 88, 85, + + 2829, 79, 83, 73, 2829, 2829, 52, 84, 2829, 96, + 86, 677, 89, 2829, 93, 87, 54, 2829, 2829, 2829, + 110, 2829, 94, 113, 88, 2829, 111, 135, 90, 156, + 57, 97, 91, 114, 143, 96, 69, 89, 142, 144, + 93, 2829, 2829, 52, 98, 145, 99, 94, 92, 100, + 104, 2829, 1416, 135, 105, 101, 116, 2829, 88, 95, + 69, 163, 115, 2829, 106, 107, 112, 73, 2829, 108, + 2829, 679, 89, 2829, 109, 2829, 2829, 135, 96, 43, + 43, 43, 43, 43, 88, 122, 122, 123, 123, 123, + 2829, 134, 2829, 2829, 2829, 2829, 45, 89, 124, 124, + + 125, 125, 125, 126, 96, 2829, 2829, 45, 92, 125, + 125, 125, 125, 125, 126, 147, 2829, 134, 146, 2829, + 2829, 139, 2829, 141, 101, 117, 2829, 152, 151, 101, + 118, 154, 690, 2829, 150, 2829, 57, 1437, 119, 120, + 213, 135, 300, 2829, 73, 2829, 2829, 2829, 2829, 2829, + 149, 117, 2829, 152, 151, 101, 118, 2829, 148, 1445, + 2829, 57, 791, 119, 120, 2829, 2829, 2829, 73, 2829, + 2829, 2829, 152, 152, 2829, 121, 132, 132, 132, 132, + 132, 126, 132, 132, 132, 132, 132, 132, 155, 157, + 158, 160, 2829, 2829, 2829, 2829, 169, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 171, 2829, 172, 162, 132, 132, + 132, 132, 132, 132, 164, 159, 2829, 2829, 161, 2829, + 2829, 168, 166, 174, 179, 2829, 167, 2829, 2829, 2829, + 171, 176, 172, 178, 170, 165, 2829, 2829, 2829, 173, + 2829, 2829, 181, 2829, 2829, 2829, 2829, 174, 2829, 175, + 179, 2829, 172, 2829, 177, 180, 2829, 2829, 2829, 178, + 2829, 129, 949, 173, 2829, 193, 181, 2829, 2829, 179, + 174, 185, 2829, 182, 2829, 181, 186, 183, 179, 180, + 2829, 202, 184, 187, 188, 2829, 196, 2829, 181, 2829, + 189, 2829, 2829, 2829, 194, 190, 2829, 195, 2829, 191, + + 2829, 192, 2829, 199, 2829, 205, 174, 200, 2829, 2829, + 2829, 2829, 197, 203, 201, 2829, 204, 179, 2829, 2829, + 130, 670, 130, 2829, 206, 2829, 221, 198, 224, 210, + 174, 122, 122, 123, 123, 123, 2829, 174, 218, 219, + 219, 219, 219, 179, 2829, 2829, 207, 2829, 223, 2829, + 2829, 2829, 224, 2829, 210, 2829, 123, 123, 123, 123, + 123, 225, 179, 135, 229, 172, 225, 45, 208, 211, + 211, 212, 212, 212, 213, 2829, 2829, 130, 2829, 231, + 181, 45, 174, 212, 212, 212, 212, 212, 213, 135, + 225, 172, 2829, 2829, 208, 2829, 2829, 675, 2829, 225, + + 770, 2829, 234, 2829, 181, 236, 174, 2829, 237, 2829, + 2829, 1049, 2829, 209, 222, 222, 222, 222, 222, 213, + 222, 222, 222, 222, 222, 222, 2829, 2829, 2829, 2829, + 232, 242, 2829, 241, 2829, 240, 2829, 235, 2829, 2829, + 2829, 2829, 239, 2829, 2829, 2829, 222, 222, 222, 222, + 222, 222, 238, 2829, 2829, 242, 2829, 241, 2829, 242, + 2829, 242, 243, 2829, 2829, 246, 249, 250, 2829, 252, + 245, 2829, 244, 248, 2829, 2829, 254, 257, 2829, 2829, + 251, 247, 2829, 2829, 253, 2829, 2829, 2829, 258, 2829, + 2829, 2829, 2829, 264, 255, 260, 2829, 256, 2829, 263, + + 2829, 2829, 2829, 265, 2829, 130, 2829, 2829, 2829, 262, + 2829, 270, 2829, 130, 259, 2829, 263, 264, 2829, 2829, + 2829, 2829, 2829, 265, 263, 2829, 265, 265, 2829, 2829, + 261, 267, 2829, 2829, 262, 270, 265, 2829, 266, 263, + 269, 263, 271, 270, 2829, 276, 2829, 265, 277, 263, + 273, 2829, 2829, 2829, 275, 272, 268, 2829, 2829, 2829, + 274, 2829, 2829, 2829, 269, 2829, 2829, 2829, 285, 2829, + 278, 2829, 270, 279, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 280, 2829, 2829, 2829, 284, 2829, 290, 282, 281, + 2829, 2829, 2829, 130, 2829, 2829, 283, 2829, 2829, 308, + + 2829, 377, 130, 288, 2829, 2829, 242, 461, 388, 2829, + 287, 286, 545, 2829, 289, 291, 2829, 2829, 2829, 324, + 2829, 130, 292, 2829, 859, 2829, 2829, 2829, 2829, 2829, + 242, 263, 293, 2829, 242, 2829, 682, 2829, 294, 270, + 319, 2829, 2829, 242, 296, 296, 297, 297, 297, 2829, + 218, 219, 219, 219, 219, 2829, 263, 219, 219, 219, + 219, 219, 294, 270, 2829, 2829, 2829, 242, 680, 2829, + 45, 295, 298, 298, 299, 299, 299, 300, 45, 312, + 299, 299, 299, 299, 299, 300, 310, 310, 310, 310, + 310, 300, 310, 310, 310, 310, 310, 310, 2829, 311, + + 313, 2829, 316, 2829, 312, 2829, 317, 674, 2829, 2829, + 2829, 2829, 325, 2829, 2829, 2829, 2829, 313, 310, 310, + 310, 310, 310, 310, 2829, 313, 2829, 2829, 2829, 315, + 2829, 2829, 2829, 2829, 318, 130, 2829, 2829, 313, 343, + 320, 2829, 2829, 333, 2829, 2829, 2829, 2829, 130, 2829, + 334, 323, 2829, 326, 2829, 330, 2829, 322, 327, 2829, + 2829, 2829, 2829, 329, 2829, 2829, 2829, 335, 336, 2829, + 331, 332, 340, 2829, 337, 2829, 339, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 341, 338, 2829, 2829, 2829, + 347, 345, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 348, + + 342, 344, 2829, 2829, 348, 2829, 2829, 2829, 346, 2829, + 2829, 2829, 2829, 2829, 2829, 350, 347, 2829, 2829, 2829, + 2829, 634, 2829, 2829, 2829, 348, 352, 2829, 2829, 349, + 348, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 676, 2829, + 348, 350, 2829, 355, 357, 2829, 2829, 2829, 2829, 348, + 1492, 354, 353, 2829, 348, 2829, 2829, 351, 2829, 356, + 2829, 2829, 2829, 2829, 2829, 363, 358, 359, 364, 2829, + 2829, 416, 360, 365, 2829, 368, 369, 366, 2829, 2829, + 2829, 370, 371, 2829, 2829, 2829, 2829, 2829, 2829, 367, + 2829, 348, 348, 2829, 417, 130, 2829, 2829, 2829, 2829, + + 351, 391, 418, 313, 313, 374, 2829, 296, 296, 297, + 297, 297, 2829, 1155, 1493, 694, 397, 348, 348, 374, + 2829, 297, 297, 297, 297, 297, 351, 2829, 313, 313, + 45, 2829, 375, 375, 376, 376, 376, 377, 398, 2829, + 2829, 372, 373, 45, 2829, 376, 376, 376, 376, 376, + 377, 392, 392, 392, 392, 392, 377, 392, 392, 392, + 392, 392, 392, 2829, 394, 2829, 393, 2829, 2829, 2829, + 2829, 2829, 404, 2829, 395, 2829, 2829, 403, 2829, 396, + 2829, 406, 2829, 392, 392, 392, 392, 392, 392, 399, + 2829, 2829, 400, 2829, 2829, 2829, 2829, 408, 2829, 2829, + + 2829, 2829, 2829, 409, 419, 407, 2829, 2829, 401, 2829, + 405, 402, 2829, 434, 2829, 678, 2829, 412, 2829, 2829, + 2829, 2829, 411, 413, 2829, 2829, 2829, 420, 426, 2829, + 2829, 2829, 422, 414, 415, 421, 2829, 424, 423, 434, + 2829, 427, 428, 433, 2829, 2829, 429, 2829, 436, 2829, + 2829, 2829, 2829, 2829, 430, 431, 2829, 2829, 2829, 432, + 2829, 434, 437, 2829, 435, 2829, 2829, 2829, 2829, 433, + 2829, 2829, 436, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 437, 2829, 2829, 2829, 434, 440, 437, 2829, 441, 2829, + 2829, 434, 2829, 444, 437, 130, 442, 438, 439, 130, + + 445, 475, 130, 452, 446, 478, 450, 2829, 478, 130, + 434, 434, 2829, 443, 2829, 564, 453, 2829, 2829, 2829, + 449, 2829, 2829, 451, 2829, 2829, 2829, 437, 2829, 2829, + 2829, 455, 434, 2829, 2829, 2829, 2829, 434, 2829, 2829, + 2829, 2829, 457, 457, 458, 458, 458, 704, 2829, 129, + 45, 437, 459, 459, 460, 460, 460, 461, 45, 456, + 460, 460, 460, 460, 460, 461, 481, 481, 481, 481, + 481, 461, 481, 481, 481, 481, 481, 481, 2829, 483, + 2829, 2829, 2829, 2829, 488, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 481, 481, + + 481, 481, 481, 481, 494, 489, 2829, 2829, 482, 2829, + 2829, 2829, 2829, 484, 2829, 2829, 486, 2829, 716, 491, + 2829, 1503, 1503, 493, 487, 2829, 507, 490, 2829, 2829, + 508, 2829, 2829, 2829, 2829, 512, 2829, 2829, 495, 2829, + 492, 496, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 498, + 510, 514, 499, 2829, 513, 509, 500, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 516, 2829, 2829, 519, 2829, 2829, + 2829, 2829, 522, 518, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 524, 515, 2829, 2829, 2829, 517, 2829, 2829, 2829, + 521, 2829, 519, 531, 129, 2829, 522, 537, 518, 2829, + + 538, 2829, 2829, 522, 2829, 520, 523, 519, 532, 526, + 2829, 530, 528, 519, 521, 525, 527, 2829, 1503, 536, + 2829, 522, 2829, 519, 535, 2829, 2829, 529, 2829, 2829, + 2829, 2829, 522, 130, 2829, 2829, 2829, 130, 2829, 567, + 2829, 130, 2829, 567, 540, 130, 2829, 567, 519, 130, + 2829, 572, 2829, 2829, 711, 658, 522, 542, 457, 457, + 458, 458, 458, 541, 2829, 2829, 2829, 2829, 2829, 542, + 458, 458, 458, 458, 458, 45, 698, 543, 543, 544, + 544, 544, 545, 45, 2829, 544, 544, 544, 544, 544, + 545, 573, 573, 573, 573, 573, 545, 573, 573, 573, + + 573, 573, 573, 576, 574, 578, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 577, + 2829, 2829, 2829, 573, 573, 573, 573, 573, 573, 581, + 584, 2829, 2829, 2829, 2829, 2829, 582, 2829, 2829, 585, + 583, 579, 2829, 586, 603, 589, 2829, 2829, 588, 598, + 580, 2829, 602, 607, 611, 2829, 608, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 609, 1510, 604, 2829, + 2829, 2829, 2829, 2829, 596, 597, 2829, 605, 599, 2829, + 611, 606, 2829, 2829, 2829, 2829, 601, 2829, 2829, 2829, + 2829, 2829, 610, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 611, 2829, 2829, 2829, 613, 2829, 2829, 614, 2829, 611, + 616, 617, 612, 130, 615, 1503, 627, 618, 610, 564, + 2829, 2829, 130, 130, 2829, 624, 2829, 2829, 564, 564, + 2829, 130, 625, 800, 629, 611, 1395, 665, 611, 619, + 1514, 2829, 2829, 130, 620, 2829, 2829, 2829, 621, 564, + 2829, 130, 2829, 626, 2829, 611, 2829, 665, 2829, 2829, + 630, 630, 631, 631, 631, 45, 681, 632, 632, 633, + 633, 633, 634, 45, 2829, 633, 633, 633, 633, 633, + 634, 669, 669, 669, 669, 669, 634, 669, 669, 669, + 669, 669, 669, 2829, 2829, 2829, 2829, 2829, 689, 701, + + 2829, 2829, 2829, 2829, 2829, 691, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 669, 669, 669, 669, 669, 669, 695, + 692, 700, 2829, 2829, 701, 630, 630, 631, 631, 631, + 761, 2829, 702, 706, 2829, 1503, 701, 708, 130, 693, + 696, 699, 697, 705, 745, 130, 700, 703, 767, 130, + 709, 748, 763, 710, 713, 658, 1395, 851, 701, 631, + 631, 631, 631, 631, 45, 764, 714, 714, 715, 715, + 715, 716, 45, 766, 715, 715, 715, 715, 715, 716, + 130, 130, 130, 130, 130, 130, 658, 752, 658, 752, + 748, 752, 130, 2829, 2829, 2829, 2829, 2829, 759, 760, + + 760, 760, 760, 760, 716, 760, 760, 760, 760, 760, + 760, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 789, 765, 2829, 2829, 771, 2829, 2829, + 2829, 760, 760, 760, 760, 760, 760, 2829, 768, 769, + 772, 779, 788, 780, 781, 2829, 782, 796, 2829, 785, + 786, 787, 783, 1514, 789, 2829, 784, 130, 790, 792, + 794, 797, 869, 833, 130, 2829, 1167, 860, 793, 871, + 836, 795, 45, 789, 798, 798, 799, 799, 799, 800, + 45, 2829, 799, 799, 799, 799, 799, 800, 130, 130, + 130, 130, 130, 130, 836, 745, 745, 748, 836, 748, + + 130, 130, 130, 130, 2829, 854, 845, 836, 748, 845, + 850, 850, 850, 850, 850, 800, 850, 850, 850, 850, + 850, 850, 2829, 2829, 853, 2829, 852, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 850, 850, 850, 850, 850, 850, 2829, 2829, + 2829, 129, 2829, 130, 856, 2829, 857, 887, 858, 925, + 872, 870, 855, 873, 874, 1500, 2829, 1263, 1268, 868, + 879, 881, 861, 880, 875, 876, 1503, 130, 130, 882, + 884, 877, 878, 928, 928, 45, 883, 885, 885, 886, + 886, 886, 887, 45, 2829, 886, 886, 886, 886, 886, + + 887, 130, 130, 130, 130, 130, 130, 928, 933, 928, + 836, 937, 928, 130, 130, 130, 130, 130, 130, 836, + 937, 928, 933, 937, 945, 946, 946, 946, 946, 946, + 887, 946, 946, 946, 946, 946, 946, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 947, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 946, 946, 946, + 946, 946, 946, 2829, 2829, 2829, 2829, 2829, 2829, 1269, + 130, 2829, 955, 980, 963, 2829, 1022, 965, 1510, 968, + 952, 948, 956, 950, 953, 954, 964, 972, 951, 966, + 967, 1514, 970, 969, 975, 130, 971, 976, 130, 1046, + + 973, 925, 130, 1522, 925, 974, 977, 45, 925, 978, + 978, 979, 979, 979, 980, 45, 1050, 979, 979, 979, + 979, 979, 980, 130, 130, 130, 130, 130, 130, 1029, + 925, 1029, 925, 928, 933, 130, 130, 130, 130, 130, + 130, 925, 1029, 933, 1040, 1029, 933, 130, 2829, 2829, + 2829, 2829, 2829, 1040, 1045, 1045, 1045, 1045, 1045, 980, + 1045, 1045, 1045, 1045, 1045, 1045, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 1060, 2829, 2829, + 2829, 2829, 1062, 2829, 2829, 2829, 1045, 1045, 1045, 1045, + 1045, 1045, 1047, 1048, 1061, 130, 2829, 2829, 1069, 1395, + + 1072, 1122, 1063, 1075, 1177, 1051, 1052, 1053, 1067, 1054, + 1059, 1153, 1161, 1068, 1064, 1070, 1065, 1071, 45, 1066, + 1073, 1073, 1074, 1074, 1074, 1075, 45, 1152, 1074, 1074, + 1074, 1074, 1074, 1075, 130, 130, 130, 130, 130, 130, + 1125, 1022, 1022, 1129, 1022, 1129, 130, 130, 130, 130, + 130, 130, 1125, 1129, 1136, 1022, 1129, 1029, 130, 130, + 130, 130, 130, 130, 1140, 1129, 1029, 1140, 1129, 1136, + 130, 130, 2829, 2829, 2829, 2829, 1140, 1148, 1149, 1149, + 1149, 1149, 1149, 1075, 1149, 1149, 1149, 1149, 1149, 1149, + 2829, 2829, 2829, 1163, 2829, 2829, 2829, 1162, 2829, 2829, + + 1154, 2829, 2829, 1151, 2829, 2829, 2829, 2829, 1514, 2829, + 1149, 1149, 1149, 1149, 1149, 1149, 1281, 1166, 45, 1164, + 1175, 1175, 1176, 1176, 1176, 1177, 130, 1169, 1404, 1526, + 1150, 1156, 1228, 1514, 1168, 1173, 1171, 1271, 1165, 1170, + 1174, 45, 1267, 1176, 1176, 1176, 1176, 1176, 1177, 130, + 130, 130, 1172, 130, 130, 1231, 1231, 1122, 130, 1122, + 1125, 130, 130, 130, 1231, 130, 130, 1125, 1240, 1231, + 130, 1125, 1240, 130, 130, 130, 1125, 130, 130, 1129, + 1136, 1125, 130, 1240, 1136, 130, 130, 130, 1252, 2829, + 2829, 1240, 1136, 1252, 1257, 1257, 1257, 1257, 1257, 1177, + + 1257, 1257, 1257, 1257, 1257, 1257, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 45, 2829, + 1279, 1279, 1280, 1280, 1280, 1281, 1257, 1257, 1257, 1257, + 1257, 1257, 1272, 1259, 1258, 45, 1404, 1280, 1280, 1280, + 1280, 1280, 1281, 1260, 1261, 1270, 1276, 1526, 130, 1266, + 130, 1274, 1262, 1273, 1337, 130, 1340, 1491, 1277, 130, + 130, 1340, 130, 1275, 130, 1340, 1345, 1278, 1340, 130, + 1231, 130, 130, 130, 130, 1349, 130, 1340, 1231, 1349, + 1340, 130, 1345, 130, 130, 130, 130, 1349, 130, 1357, + 1231, 1349, 1240, 130, 1361, 130, 130, 130, 130, 1349, + + 130, 1240, 1361, 1349, 1357, 130, 1361, 2829, 2829, 2829, + 2829, 1369, 1370, 1370, 1370, 1370, 1370, 1281, 1370, 1370, + 1370, 1370, 1370, 1370, 2829, 2829, 2829, 1373, 1374, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 129, 2829, + 1371, 1514, 1522, 1375, 1370, 1370, 1370, 1370, 1370, 1370, + 1526, 1372, 1379, 45, 1534, 1389, 1389, 1390, 1390, 1390, + 1391, 1376, 2829, 1536, 129, 1385, 130, 1387, 1388, 1391, + 1384, 130, 1451, 1487, 130, 1381, 1382, 1337, 1386, 1380, + 1337, 45, 1383, 1390, 1390, 1390, 1390, 1390, 1391, 130, + 130, 130, 130, 130, 130, 1337, 1458, 1337, 1458, 1337, + + 1340, 130, 130, 130, 130, 130, 130, 1345, 1337, 1458, + 1345, 1469, 1458, 130, 130, 130, 130, 130, 130, 1345, + 1469, 1345, 1349, 1357, 1345, 130, 130, 130, 130, 130, + 130, 1469, 1357, 1481, 1469, 1357, 1481, 1486, 1486, 1486, + 1486, 1486, 1391, 1486, 1486, 1486, 1486, 1486, 1486, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 45, 2829, + 1501, 1501, 1502, 1502, 1502, 1503, 1503, 1536, 1540, 1486, + 1486, 1486, 1486, 1486, 1486, 1536, 1488, 1489, 1490, 1540, + 129, 1540, 1545, 1494, 1540, 1495, 1496, 1497, 1545, 45, + 1498, 1502, 1502, 1502, 1502, 1502, 1503, 129, 1545, 1550, + + 1499, 1545, 1550, 129, 1404, 1526, 1550, 1556, 1526, 1550, + 1556, 129, 1526, 1534, 1556, 1564, 130, 130, 130, 130, + 130, 130, 1566, 130, 1569, 1451, 1451, 1573, 130, 1451, + 130, 130, 130, 130, 1573, 130, 130, 1569, 1573, 1580, + 130, 1451, 1573, 130, 130, 130, 1458, 130, 130, 1584, + 1573, 1458, 130, 1584, 130, 130, 130, 130, 1573, 130, + 1580, 1584, 1592, 1458, 130, 1584, 130, 130, 130, 130, + 1469, 130, 1596, 1584, 1469, 1596, 130, 130, 130, 130, + 2829, 2829, 1584, 1592, 1596, 1604, 1605, 1605, 1605, 1605, + 1605, 1503, 1605, 1605, 1605, 1605, 1605, 1605, 2829, 2829, + + 2829, 1610, 1611, 2829, 2829, 2829, 2829, 2829, 129, 2829, + 1503, 2829, 2829, 1503, 1606, 1624, 1503, 1503, 1605, 1605, + 1605, 1605, 1605, 1605, 1614, 1624, 129, 1607, 1608, 1503, + 1503, 1510, 129, 1615, 1503, 1609, 1612, 1613, 45, 1617, + 1618, 1618, 1619, 1619, 1619, 1503, 45, 1624, 1619, 1619, + 1619, 1619, 1619, 1503, 1510, 1635, 1616, 1624, 1510, 1635, + 129, 1510, 1514, 1522, 129, 1510, 1635, 1522, 1647, 1635, + 1522, 1647, 129, 1653, 129, 1656, 1653, 1656, 129, 1656, + 1661, 1656, 1661, 129, 1661, 1666, 1661, 1666, 129, 1666, + 1671, 1522, 1666, 1671, 129, 1522, 1647, 1671, 1679, 1647, + + 1671, 1679, 129, 130, 130, 130, 130, 130, 130, 1685, + 130, 1688, 1688, 130, 1566, 130, 1566, 130, 130, 1569, + 130, 130, 130, 1688, 1569, 130, 1697, 1688, 1569, 130, + 130, 1697, 130, 130, 130, 130, 1569, 130, 1573, 1580, + 130, 1569, 130, 1697, 130, 130, 1580, 130, 1709, 130, + 1697, 1580, 130, 1709, 130, 130, 130, 130, 1580, 130, + 1584, 1592, 130, 1580, 130, 1709, 130, 130, 1592, 130, + 1721, 130, 1709, 1592, 2829, 1721, 1726, 1726, 1726, 1726, + 1726, 1503, 1726, 1726, 1726, 1726, 1726, 1726, 2829, 2829, + 2829, 1731, 1732, 2829, 2829, 2829, 2829, 2829, 1503, 2829, + + 2829, 1624, 129, 1624, 1503, 1727, 1624, 1747, 1726, 1726, + 1726, 1726, 1726, 1726, 45, 1624, 1739, 1739, 1740, 1740, + 1740, 1503, 1728, 1729, 1733, 1734, 1735, 1624, 1736, 2829, + 2829, 1751, 1624, 1624, 1730, 1737, 1503, 1503, 1751, 129, + 1624, 1747, 45, 1738, 1740, 1740, 1740, 1740, 1740, 1503, + 1751, 1759, 1624, 1751, 1635, 1763, 1751, 1635, 1763, 129, + 1751, 1759, 1763, 1771, 1772, 129, 1775, 1775, 129, 1775, + 1780, 1775, 1780, 129, 1780, 1785, 1780, 1785, 129, 1785, + 1790, 1785, 1790, 129, 1635, 1763, 1790, 1796, 1763, 1790, + 1796, 129, 1763, 1771, 1796, 1804, 130, 130, 130, 130, + + 130, 130, 1806, 130, 1806, 1806, 130, 1806, 130, 1812, + 130, 130, 1806, 130, 1688, 130, 1816, 1806, 130, 1688, + 130, 1816, 130, 130, 130, 130, 1806, 130, 1812, 1816, + 1824, 1688, 130, 1816, 130, 130, 130, 130, 1697, 130, + 1828, 1816, 1697, 1828, 130, 130, 130, 130, 130, 130, + 1816, 1824, 1828, 1836, 1697, 1828, 130, 130, 130, 130, + 130, 130, 1709, 1840, 1828, 1709, 1840, 130, 130, 130, + 130, 2829, 2829, 1828, 1836, 1840, 1848, 1849, 1849, 1849, + 1849, 1849, 1503, 1849, 1849, 1849, 1849, 1849, 1849, 2829, + 2829, 1853, 1854, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 1624, 1624, 1851, 1624, 1624, 1860, 1503, 1747, 129, 1849, + 1849, 1849, 1849, 1849, 1849, 1850, 1624, 1624, 1747, 129, + 1852, 1624, 1747, 1747, 1873, 45, 1859, 1861, 1861, 1862, + 1862, 1862, 1503, 1858, 1747, 1855, 1856, 1747, 1873, 129, + 1747, 1751, 45, 1857, 1862, 1862, 1862, 1862, 1862, 1503, + 1759, 129, 1747, 1873, 1759, 1885, 1873, 1759, 1885, 129, + 129, 1891, 1891, 129, 1891, 1896, 1891, 1896, 129, 1896, + 1901, 1896, 1901, 129, 1901, 1906, 1901, 1906, 129, 1906, + 1911, 1759, 1906, 1911, 129, 1759, 1885, 1911, 1919, 1885, + 1911, 1919, 129, 130, 130, 130, 130, 130, 130, 1806, + + 130, 1806, 1806, 1928, 1806, 130, 1928, 130, 130, 130, + 130, 130, 130, 1806, 1806, 1812, 130, 1806, 1928, 130, + 130, 130, 1812, 130, 130, 1939, 1928, 1812, 130, 1939, + 130, 130, 130, 130, 1812, 130, 1816, 1824, 130, 1812, + 130, 1939, 130, 130, 1824, 130, 1951, 130, 1939, 1824, + 130, 1951, 130, 130, 130, 130, 1824, 130, 1828, 1836, + 130, 1824, 130, 1951, 130, 130, 1836, 130, 1963, 130, + 1951, 1836, 2829, 1963, 1968, 1968, 1968, 1968, 1968, 1503, + 1968, 1968, 1968, 1968, 1968, 1968, 2829, 2829, 1969, 1970, + 2829, 2829, 2829, 2829, 2829, 2829, 1624, 1624, 45, 1971, + + 1974, 1974, 1975, 1975, 1975, 1624, 1968, 1968, 1968, 1968, + 1968, 1968, 45, 1747, 1975, 1975, 1975, 1975, 1975, 1624, + 1747, 1979, 1747, 1747, 1972, 1747, 1747, 1979, 129, 1747, + 1979, 1979, 1988, 1747, 1979, 1873, 1992, 1973, 1979, 1873, + 1992, 129, 1979, 1988, 1992, 2000, 1891, 129, 1891, 2004, + 1891, 2004, 129, 2004, 2009, 2004, 2009, 129, 2009, 2014, + 2009, 2014, 129, 2014, 2019, 2014, 2019, 129, 1873, 1992, + 2019, 2025, 1992, 2019, 2025, 129, 1992, 2000, 2025, 2033, + 130, 130, 130, 130, 130, 130, 1806, 1806, 1806, 1928, + 130, 1928, 130, 130, 130, 130, 1928, 130, 2040, 1806, + + 1928, 1928, 130, 2044, 130, 130, 130, 130, 1928, 130, + 1928, 2044, 130, 1928, 130, 2040, 130, 130, 2044, 130, + 2052, 130, 1928, 2044, 130, 1939, 130, 2056, 130, 130, + 2044, 130, 1939, 130, 2056, 130, 130, 2044, 130, 2052, + 130, 2056, 2064, 130, 1939, 130, 2056, 130, 130, 1951, + 130, 2068, 130, 2056, 1951, 130, 2068, 130, 130, 130, + 2078, 2056, 2079, 2064, 2068, 2076, 2077, 2077, 2077, 2077, + 2077, 1624, 2077, 2077, 2077, 2077, 2077, 2077, 2829, 2829, + 45, 2829, 2082, 2082, 2083, 2083, 2083, 1624, 45, 1747, + 2083, 2083, 2083, 2083, 2083, 1624, 1747, 1979, 2077, 2077, + + 2077, 2077, 2077, 2077, 129, 1747, 1747, 1979, 1979, 2089, + 1979, 1979, 2089, 129, 1979, 1979, 1988, 129, 1979, 2089, + 2080, 2081, 1988, 2101, 2089, 1988, 2101, 129, 1891, 1891, + 2004, 129, 2004, 2110, 2004, 2110, 129, 2110, 2115, 2110, + 2115, 129, 2115, 2120, 2115, 2120, 129, 2120, 2125, 1988, + 2120, 2125, 129, 1988, 2101, 2125, 2133, 2101, 2125, 2133, + 129, 130, 130, 130, 130, 130, 130, 1806, 1928, 1928, + 1928, 1928, 2040, 130, 130, 130, 130, 130, 130, 130, + 1928, 1928, 2040, 130, 1928, 2040, 130, 130, 130, 2040, + 130, 130, 2148, 2040, 2040, 130, 2148, 130, 130, 130, + + 130, 2040, 130, 2044, 2052, 130, 2040, 130, 2148, 130, + 130, 2052, 130, 2160, 130, 2148, 2052, 130, 2160, 130, + 130, 130, 130, 2052, 130, 2056, 2064, 130, 2052, 130, + 2160, 130, 130, 2064, 130, 2172, 130, 2160, 2064, 2178, + 2172, 2177, 2177, 2177, 2177, 2177, 1624, 2177, 2177, 2177, + 2177, 2177, 2177, 2179, 2829, 2829, 45, 1979, 2182, 2182, + 2183, 2183, 2183, 1624, 45, 1979, 2183, 2183, 2183, 2183, + 2183, 1624, 1979, 2177, 2177, 2177, 2177, 2177, 2177, 1979, + 2089, 129, 1979, 2089, 2089, 2190, 1979, 2089, 2089, 2194, + 2089, 2089, 2194, 129, 2180, 2089, 2190, 2194, 2202, 1891, + + 2004, 2004, 2181, 2110, 129, 2110, 2207, 2110, 2207, 129, + 2207, 2212, 2207, 2212, 129, 2212, 2217, 2212, 2217, 129, + 2089, 2194, 2217, 2223, 2194, 2217, 2223, 129, 2194, 2202, + 2223, 2231, 130, 130, 130, 130, 130, 130, 1928, 1928, + 2040, 2040, 2235, 2040, 130, 130, 130, 130, 130, 130, + 2040, 2040, 2040, 2235, 130, 2040, 130, 130, 130, 130, + 2235, 130, 2235, 2244, 2040, 2235, 130, 2148, 130, 130, + 130, 130, 2248, 130, 2235, 2148, 2248, 130, 130, 2235, + 130, 130, 130, 2244, 2248, 130, 2256, 2148, 2248, 130, + 130, 2160, 130, 130, 130, 2260, 2248, 130, 2160, 2260, + + 130, 130, 130, 2248, 2270, 2271, 2256, 2260, 2268, 2269, + 2269, 2269, 2269, 2269, 1624, 2269, 2269, 2269, 2269, 2269, + 2269, 2829, 2829, 45, 1979, 2275, 2275, 2276, 2276, 2276, + 1624, 45, 2089, 2276, 2276, 2276, 2276, 2276, 1624, 2089, + 2089, 2269, 2269, 2269, 2269, 2269, 2269, 2089, 2190, 129, + 2089, 2089, 2190, 129, 2089, 2190, 2190, 2287, 2190, 2190, + 2287, 2273, 129, 2829, 2110, 2110, 2274, 2207, 2272, 129, + 2004, 2207, 2296, 2207, 2296, 129, 2296, 2301, 2296, 2301, + 129, 2301, 2306, 2190, 2301, 2306, 129, 2190, 2287, 2306, + 2314, 2287, 2306, 2314, 129, 130, 130, 130, 130, 130, + + 130, 2040, 2040, 2235, 130, 2040, 2040, 130, 130, 130, + 2235, 130, 130, 2235, 2324, 2235, 130, 2235, 2324, 130, + 130, 130, 130, 130, 130, 2235, 2235, 2244, 130, 2235, + 2324, 130, 130, 130, 2244, 130, 130, 2336, 2324, 2244, + 130, 2336, 130, 130, 130, 130, 2244, 130, 2248, 2256, + 130, 2244, 130, 2336, 130, 130, 2256, 130, 2348, 130, + 2336, 2256, 2829, 2348, 2353, 2353, 2353, 2353, 2353, 1624, + 2353, 2353, 2353, 2353, 2353, 2353, 2829, 2829, 45, 2089, + 2356, 2356, 2357, 2357, 2357, 1747, 45, 2089, 2357, 2357, + 2357, 2357, 2357, 1747, 2190, 2190, 2353, 2353, 2353, 2353, + + 2353, 2353, 2361, 2190, 2190, 2190, 2354, 2190, 2361, 129, + 2190, 2355, 2361, 2361, 2370, 2110, 2207, 2207, 2296, 129, + 2296, 2375, 2296, 2375, 129, 2375, 2380, 2375, 2380, 129, + 2190, 2361, 2380, 2386, 2361, 2380, 2386, 129, 2361, 2370, + 2386, 2394, 130, 130, 130, 130, 130, 130, 2235, 2235, + 2235, 2235, 2324, 130, 130, 130, 130, 130, 130, 2235, + 2324, 2324, 2401, 2235, 2324, 130, 130, 130, 130, 130, + 130, 2324, 2405, 2324, 2324, 2405, 130, 130, 130, 130, + 130, 130, 2324, 2401, 2405, 2413, 2324, 2405, 130, 130, + 130, 130, 130, 130, 2336, 2417, 2405, 2336, 2417, 130, + + 130, 130, 130, 2829, 2829, 2405, 2413, 2417, 2425, 2426, + 2426, 2426, 2426, 2426, 1747, 2426, 2426, 2426, 2426, 2426, + 2426, 45, 2190, 2428, 2428, 2429, 2429, 2429, 1747, 45, + 2190, 2429, 2429, 2429, 2429, 2429, 1747, 2427, 2361, 129, + 2190, 2426, 2426, 2426, 2426, 2426, 2426, 2190, 2361, 2361, + 2435, 2361, 2361, 2435, 129, 2207, 2296, 2296, 2375, 129, + 2375, 2444, 2375, 2444, 129, 2444, 2449, 2361, 2444, 2449, + 129, 2361, 2435, 2449, 2457, 2435, 2449, 2457, 129, 130, + 130, 130, 130, 130, 130, 2235, 2324, 2324, 2324, 2324, + 2401, 130, 130, 130, 130, 130, 130, 130, 2324, 2324, + + 2401, 130, 2324, 2401, 130, 130, 130, 2401, 130, 130, + 2472, 2401, 2401, 130, 2472, 130, 130, 130, 130, 2401, + 130, 2405, 2413, 130, 2401, 130, 2472, 130, 130, 2413, + 130, 2484, 130, 2472, 2413, 2829, 2484, 2489, 2489, 2489, + 2489, 2489, 1747, 2489, 2489, 2489, 2489, 2489, 2489, 45, + 2361, 2490, 2490, 2491, 2491, 2491, 1747, 45, 2361, 2491, + 2491, 2491, 2491, 2491, 1747, 2361, 2361, 2435, 129, 2489, + 2489, 2489, 2489, 2489, 2489, 2361, 2435, 2435, 2498, 2296, + 2375, 2375, 2444, 129, 2444, 2503, 2444, 2503, 129, 2361, + 2435, 2503, 2509, 2435, 2503, 2509, 129, 2435, 2498, 2509, + + 2517, 130, 130, 130, 130, 130, 130, 2324, 2324, 2401, + 2401, 2521, 2401, 130, 130, 130, 130, 130, 130, 2401, + 2401, 2401, 2521, 130, 2401, 130, 130, 130, 130, 2521, + 130, 2521, 2530, 2401, 2521, 130, 2472, 130, 130, 130, + 130, 2534, 130, 2521, 2472, 2534, 130, 130, 2521, 130, + 2361, 2435, 2530, 2534, 2435, 2542, 2543, 2543, 2543, 2543, + 2543, 1747, 2543, 2543, 2543, 2543, 2543, 2543, 45, 2435, + 2544, 2544, 2545, 2545, 2545, 1747, 45, 2435, 2545, 2545, + 2545, 2545, 2545, 1747, 2498, 129, 2375, 2444, 2543, 2543, + 2543, 2543, 2543, 2543, 2444, 2503, 129, 2503, 2555, 2435, + + 2503, 2555, 129, 2435, 2498, 2555, 2562, 2498, 2555, 2562, + 129, 130, 130, 130, 130, 130, 130, 2401, 2401, 2521, + 130, 2401, 2401, 130, 130, 130, 2521, 130, 130, 2521, + 2572, 2521, 130, 2521, 2572, 130, 130, 130, 130, 130, + 130, 2521, 2521, 2530, 130, 2521, 2572, 130, 130, 130, + 2530, 130, 130, 2584, 2572, 2530, 2435, 2584, 2589, 2589, + 2589, 2589, 2589, 1747, 2589, 2589, 2589, 2589, 2589, 2589, + 45, 2435, 2590, 2590, 2591, 2591, 2591, 1979, 45, 2498, + 2591, 2591, 2591, 2591, 2591, 1979, 2498, 2595, 2444, 2503, + 2589, 2589, 2589, 2589, 2589, 2589, 2503, 2555, 129, 2498, + + 2555, 2600, 2498, 2555, 2600, 129, 2498, 2595, 2600, 2608, + 130, 130, 130, 130, 130, 130, 2521, 2521, 2521, 2521, + 2572, 130, 130, 130, 130, 130, 130, 2521, 2572, 2572, + 2615, 2521, 2572, 130, 130, 130, 130, 130, 130, 2572, + 2619, 2572, 2572, 2619, 130, 130, 130, 130, 2498, 2498, + 2572, 2615, 2619, 2627, 2628, 2628, 2628, 2628, 2628, 1979, + 2628, 2628, 2628, 2628, 2628, 2628, 45, 2595, 2629, 2629, + 2630, 2630, 2630, 1979, 45, 129, 2630, 2630, 2630, 2630, + 2630, 1979, 2503, 2555, 2555, 2600, 2628, 2628, 2628, 2628, + 2628, 2628, 129, 2498, 2595, 2600, 2639, 2595, 2600, 2639, + + 129, 130, 130, 130, 130, 130, 130, 2521, 2572, 2572, + 2572, 2572, 2615, 130, 130, 130, 130, 130, 130, 130, + 2572, 2572, 2615, 130, 2572, 2615, 130, 130, 130, 2615, + 130, 130, 2654, 2615, 2615, 2595, 2654, 2659, 2659, 2659, + 2659, 2659, 1979, 2659, 2659, 2659, 2659, 2659, 2659, 45, + 2595, 2660, 2660, 2661, 2661, 2661, 1979, 45, 2664, 2661, + 2661, 2661, 2661, 2661, 1979, 2555, 2600, 2595, 2600, 2659, + 2659, 2659, 2659, 2659, 2659, 2639, 129, 2595, 2664, 2639, + 2671, 130, 130, 130, 130, 130, 130, 2572, 2572, 2615, + 2615, 2675, 2615, 130, 130, 130, 130, 130, 130, 2615, + + 2615, 2615, 2675, 130, 2615, 130, 130, 2595, 2664, 2675, + 129, 2675, 2684, 2685, 2685, 2685, 2685, 2685, 1979, 2685, + 2685, 2685, 2685, 2685, 2685, 45, 2600, 2686, 2686, 2687, + 2687, 2687, 1979, 45, 2664, 2687, 2687, 2687, 2687, 2687, + 1979, 2639, 2664, 2639, 2671, 2685, 2685, 2685, 2685, 2685, + 2685, 129, 130, 130, 130, 130, 130, 130, 2615, 2615, + 2675, 130, 2615, 2615, 130, 130, 130, 2675, 130, 130, + 2675, 2700, 2675, 130, 2675, 2700, 2705, 2705, 2705, 2705, + 2705, 2664, 2705, 2705, 2705, 2705, 2705, 2705, 45, 2710, + 2706, 2706, 2707, 2707, 2707, 2089, 45, 2639, 2707, 2707, + + 2707, 2707, 2707, 2089, 2664, 2710, 2671, 2713, 2705, 2705, + 2705, 2705, 2705, 2705, 130, 130, 130, 130, 130, 130, + 2675, 2675, 2675, 2675, 2700, 130, 130, 130, 130, 2664, + 2710, 2675, 2700, 2700, 2721, 2722, 2722, 2722, 2722, 2722, + 2089, 2722, 2722, 2722, 2722, 2722, 2722, 45, 129, 2723, + 2723, 2724, 2724, 2724, 2089, 45, 2710, 2724, 2724, 2724, + 2724, 2724, 2089, 2671, 2713, 130, 2710, 2722, 2722, 2722, + 2722, 2722, 2722, 2727, 2728, 2728, 2728, 2728, 130, 130, + 130, 130, 130, 130, 2675, 2700, 2700, 2700, 2700, 2721, + 2734, 2734, 2734, 2734, 2734, 2710, 2734, 2734, 2734, 2734, + + 2734, 2734, 45, 2713, 2735, 2735, 2736, 2736, 2736, 2089, + 45, 2710, 2736, 2736, 2736, 2736, 2736, 2089, 2713, 1296, + 129, 1437, 2734, 2734, 2734, 2734, 2734, 2734, 2727, 2728, + 2728, 2728, 2728, 2728, 2728, 2728, 2728, 2728, 130, 130, + 130, 130, 1432, 1296, 2700, 2700, 2721, 2721, 2741, 2741, + 2741, 2741, 2741, 1437, 2741, 2741, 2741, 2741, 2741, 2741, + 45, 1432, 2742, 2742, 2743, 2743, 2743, 2089, 45, 129, + 2743, 2743, 2743, 2743, 2743, 2089, 1432, 1427, 1432, 1427, + 2741, 2741, 2741, 2741, 2741, 2741, 130, 130, 129, 1427, + 1422, 1427, 2721, 2721, 2745, 2745, 2745, 2745, 2745, 1422, + + 2745, 2745, 2745, 2745, 2745, 2745, 45, 129, 2746, 2746, + 2747, 2747, 2747, 2190, 45, 1422, 2747, 2747, 2747, 2747, + 2747, 2190, 1422, 129, 1416, 1296, 2745, 2745, 2745, 2745, + 2745, 2745, 130, 1404, 1416, 1296, 1404, 1285, 2721, 2748, + 2748, 2748, 2748, 2748, 2190, 2748, 2748, 2748, 2748, 2748, + 2748, 45, 129, 2749, 2749, 2750, 2750, 2750, 2190, 45, + 1296, 2750, 2750, 2750, 2750, 2750, 2190, 1289, 1285, 129, + 1404, 2748, 2748, 2748, 2748, 2748, 2748, 2751, 2751, 2751, + 2751, 2751, 1285, 2751, 2751, 2751, 2751, 2751, 2751, 45, + 1395, 2752, 2752, 2753, 2753, 2753, 2190, 45, 1404, 2753, + + 2753, 2753, 2753, 2753, 2190, 1285, 1395, 129, 1285, 2751, + 2751, 2751, 2751, 2751, 2751, 2754, 2754, 2754, 2754, 2754, + 1281, 2754, 2754, 2754, 2754, 2754, 2754, 45, 1281, 2755, + 2755, 2756, 2756, 2756, 2190, 45, 129, 2756, 2756, 2756, + 2756, 2756, 2190, 1395, 1395, 129, 2829, 2754, 2754, 2754, + 2754, 2754, 2754, 2757, 2757, 2757, 2757, 2757, 2829, 2757, + 2757, 2757, 2757, 2757, 2757, 45, 2829, 2758, 2758, 2759, + 2759, 2759, 2361, 45, 1378, 2759, 2759, 2759, 2759, 2759, + 2361, 1377, 130, 130, 130, 2757, 2757, 2757, 2757, 2757, + 2757, 2760, 2760, 2760, 2760, 2760, 2361, 2760, 2760, 2760, + + 2760, 2760, 2760, 45, 130, 2761, 2761, 2762, 2762, 2762, + 2361, 45, 1335, 2762, 2762, 2762, 2762, 2762, 2361, 1327, + 1308, 1300, 129, 2760, 2760, 2760, 2760, 2760, 2760, 2763, + 2763, 2763, 2763, 2763, 1327, 2763, 2763, 2763, 2763, 2763, + 2763, 45, 1321, 2764, 2764, 2765, 2765, 2765, 2361, 45, + 1300, 2765, 2765, 2765, 2765, 2765, 2361, 1327, 1321, 1300, + 1185, 2763, 2763, 2763, 2763, 2763, 2763, 2766, 2766, 2766, + 2766, 2766, 129, 2766, 2766, 2766, 2766, 2766, 2766, 45, + 1321, 2767, 2767, 2768, 2768, 2768, 2361, 45, 1316, 2768, + 2768, 2768, 2768, 2768, 2361, 1321, 1316, 129, 1316, 2766, + + 2766, 2766, 2766, 2766, 2766, 2769, 2769, 2769, 2769, 2769, + 1311, 2769, 2769, 2769, 2769, 2769, 2769, 45, 1316, 2770, + 2770, 2771, 2771, 2771, 2435, 45, 1311, 2771, 2771, 2771, + 2771, 2771, 2435, 129, 1311, 1311, 129, 2769, 2769, 2769, + 2769, 2769, 2769, 2772, 2772, 2772, 2772, 2772, 2435, 2772, + 2772, 2772, 2772, 2772, 2772, 45, 1308, 2773, 2773, 2774, + 2774, 2774, 2435, 45, 1300, 2774, 2774, 2774, 2774, 2774, + 2435, 1296, 1289, 129, 1300, 2772, 2772, 2772, 2772, 2772, + 2772, 2775, 2775, 2775, 2775, 2775, 1185, 2775, 2775, 2775, + 2775, 2775, 2775, 45, 1289, 2776, 2776, 2777, 2777, 2777, + + 2435, 45, 1300, 2777, 2777, 2777, 2777, 2777, 2435, 1185, + 1289, 1177, 1296, 2775, 2775, 2775, 2775, 2775, 2775, 2778, + 2778, 2778, 2778, 2778, 1289, 2778, 2778, 2778, 2778, 2778, + 2778, 45, 1285, 2779, 2779, 2780, 2780, 2780, 2435, 45, + 129, 2780, 2780, 2780, 2780, 2780, 2435, 1289, 1177, 1289, + 1177, 2778, 2778, 2778, 2778, 2778, 2778, 2781, 2781, 2781, + 2781, 2781, 1177, 2781, 2781, 2781, 2781, 2781, 2781, 45, + 1285, 2782, 2782, 2783, 2783, 2783, 2498, 45, 129, 2783, + 2783, 2783, 2783, 2783, 2498, 2829, 1265, 1264, 2829, 2781, + 2781, 2781, 2781, 2781, 2781, 2784, 2784, 2784, 2784, 2784, + + 2498, 2784, 2784, 2784, 2784, 2784, 2784, 45, 130, 2785, + 2785, 2786, 2786, 2786, 2498, 45, 130, 2786, 2786, 2786, + 2786, 2786, 2498, 130, 130, 130, 130, 2784, 2784, 2784, + 2784, 2784, 2784, 2787, 2787, 2787, 2787, 2787, 129, 2787, + 2787, 2787, 2787, 2787, 2787, 45, 1222, 2788, 2788, 2789, + 2789, 2789, 2498, 45, 1214, 2789, 2789, 2789, 2789, 2789, + 2498, 1196, 1222, 1214, 1196, 2787, 2787, 2787, 2787, 2787, + 2787, 2790, 2790, 2790, 2790, 2790, 1084, 2790, 2790, 2790, + 2790, 2790, 2790, 45, 129, 2791, 2791, 2792, 2792, 2792, + 2498, 45, 1214, 2792, 2792, 2792, 2792, 2792, 2498, 1209, + + 1084, 1214, 1209, 2790, 2790, 2790, 2790, 2790, 2790, 2793, + 2793, 2793, 2793, 2793, 129, 2793, 2793, 2793, 2793, 2793, + 2793, 45, 1209, 2794, 2794, 2795, 2795, 2795, 2595, 45, + 1204, 2795, 2795, 2795, 2795, 2795, 2595, 1209, 1204, 129, + 1204, 2793, 2793, 2793, 2793, 2793, 2793, 2796, 2796, 2796, + 2796, 2796, 2595, 2796, 2796, 2796, 2796, 2796, 2796, 45, + 1204, 2797, 2797, 2798, 2798, 2798, 2595, 45, 129, 2798, + 2798, 2798, 2798, 2798, 2595, 1201, 129, 1196, 1084, 2796, + 2796, 2796, 2796, 2796, 2796, 2799, 2799, 2799, 2799, 2799, + 1185, 2799, 2799, 2799, 2799, 2799, 2799, 45, 1196, 2800, + + 2800, 2801, 2801, 2801, 2595, 45, 1084, 2801, 2801, 2801, + 2801, 2801, 2595, 1185, 1075, 129, 1084, 2799, 2799, 2799, + 2799, 2799, 2799, 2802, 2802, 2802, 2802, 2802, 1079, 2802, + 2802, 2802, 2802, 2802, 2802, 45, 1075, 2803, 2803, 2804, + 2804, 2804, 2595, 45, 129, 2804, 2804, 2804, 2804, 2804, + 2595, 1185, 1075, 1185, 1075, 2802, 2802, 2802, 2802, 2802, + 2802, 2805, 2805, 2805, 2805, 2805, 129, 2805, 2805, 2805, + 2805, 2805, 2805, 45, 1075, 2806, 2806, 2807, 2807, 2807, + 2664, 45, 1075, 2807, 2807, 2807, 2807, 2807, 2664, 129, + 1160, 1159, 1158, 2805, 2805, 2805, 2805, 2805, 2805, 2808, + + 2808, 2808, 2808, 2808, 2664, 2808, 2808, 2808, 2808, 2808, + 2808, 45, 1157, 2809, 2809, 2810, 2810, 2810, 2664, 45, + 2829, 2810, 2810, 2810, 2810, 2810, 2664, 2829, 130, 130, + 130, 2808, 2808, 2808, 2808, 2808, 2808, 2811, 2811, 2811, + 2811, 2811, 1120, 2811, 2811, 2811, 2811, 2811, 2811, 45, + 1112, 2812, 2812, 2813, 2813, 2813, 2664, 45, 1096, 2813, + 2813, 2813, 2813, 2813, 2664, 1088, 129, 1112, 1106, 2811, + 2811, 2811, 2811, 2811, 2811, 2814, 2814, 2814, 2814, 2814, + 1088, 2814, 2814, 2814, 2814, 2814, 2814, 45, 1112, 2815, + 2815, 2816, 2816, 2816, 2664, 45, 1106, 2816, 2816, 2816, + + 2816, 2816, 2664, 1088, 984, 129, 1106, 2814, 2814, 2814, + 2814, 2814, 2814, 2817, 2817, 2817, 2817, 2817, 1101, 2817, + 2817, 2817, 2817, 2817, 2817, 45, 1106, 2818, 2818, 2819, + 2819, 2819, 2710, 45, 1101, 2819, 2819, 2819, 2819, 2819, + 2710, 129, 1101, 1098, 1101, 2817, 2817, 2817, 2817, 2817, + 2817, 2820, 2820, 2820, 2820, 2820, 2710, 2820, 2820, 2820, + 2820, 2820, 2820, 45, 129, 2821, 2821, 2822, 2822, 2822, + 2710, 45, 1098, 2822, 2822, 2822, 2822, 2822, 2710, 1096, + 1088, 1084, 1079, 2820, 2820, 2820, 2820, 2820, 2820, 2823, + 2823, 2823, 2823, 2823, 129, 2823, 2823, 2823, 2823, 2823, + + 2823, 45, 1088, 2824, 2824, 2825, 2825, 2825, 2710, 45, + 984, 2825, 2825, 2825, 2825, 2825, 2710, 1079, 1088, 984, + 1079, 2823, 2823, 2823, 2823, 2823, 2823, 2826, 2826, 2826, + 2826, 2826, 1084, 2826, 2826, 2826, 2826, 2826, 2826, 45, + 1079, 2827, 2827, 2828, 2828, 2828, 2710, 45, 129, 2828, + 2828, 2828, 2828, 2828, 2710, 1079, 1079, 129, 2829, 2826, + 2826, 2826, 2826, 2826, 2826, 51, 51, 51, 51, 51, + 1058, 51, 51, 51, 51, 51, 51, 45, 1057, 2827, + 2827, 2828, 2828, 2828, 45, 1056, 2828, 2828, 2828, 2828, + 2828, 1055, 2829, 130, 130, 130, 130, 51, 51, 51, + + 51, 51, 51, 41, 41, 41, 41, 41, 41, 41, + 41, 44, 130, 44, 44, 44, 44, 44, 44, 49, + 129, 49, 49, 51, 1016, 51, 51, 51, 51, 127, + 1008, 127, 127, 128, 128, 131, 131, 214, 993, 214, + 214, 215, 215, 216, 216, 220, 220, 220, 301, 1016, + 301, 301, 302, 302, 303, 303, 305, 305, 306, 306, + 307, 307, 307, 309, 309, 378, 1008, 378, 378, 379, + 379, 380, 380, 382, 382, 383, 383, 384, 384, 385, + 385, 387, 387, 387, 389, 389, 390, 390, 390, 462, + 993, 462, 462, 463, 463, 464, 464, 466, 466, 467, + + 467, 468, 468, 469, 469, 471, 471, 472, 472, 473, + 473, 474, 474, 474, 476, 476, 477, 477, 477, 479, + 479, 479, 480, 480, 546, 891, 546, 546, 547, 547, + 548, 548, 550, 550, 552, 552, 553, 553, 554, 554, + 556, 556, 557, 557, 558, 558, 559, 559, 560, 560, + 561, 561, 563, 563, 563, 565, 565, 566, 566, 566, + 568, 568, 568, 569, 569, 570, 570, 570, 571, 571, + 571, 635, 129, 635, 635, 636, 636, 637, 637, 639, + 639, 640, 640, 641, 641, 643, 643, 644, 644, 646, + 646, 647, 647, 648, 648, 649, 649, 650, 650, 651, + + 651, 653, 653, 654, 654, 655, 655, 656, 656, 657, + 657, 657, 659, 659, 660, 660, 660, 661, 661, 661, + 662, 662, 663, 663, 663, 664, 664, 664, 666, 666, + 666, 667, 667, 667, 668, 668, 51, 1008, 51, 51, + 51, 717, 1003, 717, 717, 718, 718, 719, 719, 721, + 721, 722, 722, 723, 723, 724, 724, 635, 635, 727, + 727, 728, 728, 730, 730, 731, 731, 732, 732, 733, + 733, 734, 734, 736, 736, 737, 737, 738, 738, 739, + 739, 740, 740, 741, 741, 742, 742, 744, 744, 744, + 746, 746, 747, 747, 747, 749, 749, 749, 750, 750, + + 750, 751, 751, 751, 753, 753, 753, 754, 754, 754, + 755, 755, 756, 756, 756, 757, 757, 757, 758, 758, + 758, 51, 891, 51, 51, 51, 801, 1008, 801, 801, + 802, 802, 803, 803, 804, 804, 805, 805, 806, 806, + 807, 807, 809, 809, 810, 810, 811, 811, 812, 812, + 813, 813, 815, 815, 816, 816, 817, 817, 818, 818, + 820, 820, 821, 821, 822, 822, 823, 823, 824, 824, + 825, 825, 826, 826, 828, 828, 829, 829, 830, 830, + 831, 831, 832, 832, 832, 834, 834, 835, 835, 835, + 837, 837, 837, 838, 838, 744, 744, 744, 839, 839, + + 839, 840, 840, 840, 841, 841, 842, 842, 842, 843, + 843, 843, 844, 844, 844, 846, 846, 846, 847, 847, + 847, 848, 848, 848, 849, 849, 51, 1003, 51, 51, + 51, 888, 129, 888, 888, 889, 889, 890, 890, 892, + 892, 893, 893, 894, 894, 896, 896, 897, 897, 898, + 898, 899, 899, 900, 900, 901, 901, 903, 903, 905, + 905, 906, 906, 907, 907, 908, 908, 809, 809, 910, + 910, 911, 911, 912, 912, 913, 913, 914, 914, 916, + 916, 917, 917, 918, 918, 919, 919, 920, 920, 921, + 921, 922, 922, 924, 924, 924, 926, 926, 927, 927, + + 927, 929, 929, 929, 930, 930, 931, 931, 931, 932, + 932, 932, 934, 934, 934, 935, 935, 935, 936, 936, + 936, 938, 938, 938, 939, 939, 939, 940, 940, 940, + 941, 941, 942, 942, 942, 943, 943, 943, 944, 944, + 944, 51, 1003, 51, 51, 51, 981, 999, 981, 981, + 982, 982, 983, 983, 985, 985, 986, 986, 888, 888, + 987, 987, 988, 988, 989, 989, 990, 990, 991, 991, + 992, 992, 994, 994, 995, 995, 996, 996, 997, 997, + 998, 998, 1000, 1000, 1001, 1001, 1002, 1002, 896, 896, + 1004, 1004, 1005, 1005, 1006, 1006, 1007, 1007, 1009, 1009, + + 1010, 1010, 1011, 1011, 1012, 1012, 1013, 1013, 1014, 1014, + 1015, 1015, 1017, 1017, 1018, 1018, 1019, 1019, 1020, 1020, + 1021, 1021, 1021, 1023, 1023, 1024, 1024, 1024, 1025, 1025, + 1025, 1026, 1026, 1027, 1027, 1027, 1028, 1028, 1028, 1030, + 1030, 1030, 1031, 1031, 1031, 1032, 1032, 1033, 1033, 1033, + 1034, 1034, 1034, 1035, 1035, 1035, 1036, 1036, 1037, 1037, + 1037, 1038, 1038, 1038, 1039, 1039, 1039, 1041, 1041, 1041, + 1042, 1042, 1042, 1043, 1043, 1043, 1044, 1044, 51, 1003, + 51, 51, 51, 1076, 999, 1076, 1076, 1077, 1077, 1078, + 1078, 1080, 1080, 1081, 1081, 1082, 1082, 1083, 1083, 1085, + + 1085, 1086, 1086, 1087, 1087, 1089, 1089, 1090, 1090, 1091, + 1091, 1092, 1092, 1093, 1093, 1094, 1094, 1095, 1095, 1097, + 1097, 1099, 1099, 1100, 1100, 987, 987, 1102, 1102, 1103, + 1103, 1104, 1104, 1105, 1105, 995, 995, 1107, 1107, 1108, + 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1113, 1113, 1114, + 1114, 1115, 1115, 1116, 1116, 1117, 1117, 1118, 1118, 1119, + 1119, 1121, 1121, 1121, 1123, 1123, 1124, 1124, 1124, 1126, + 1126, 1126, 1127, 1127, 1127, 1128, 1128, 1128, 1130, 1130, + 1130, 1131, 1131, 1131, 1132, 1132, 1133, 1133, 1133, 1134, + 1134, 1134, 1135, 1135, 1135, 1137, 1137, 1137, 1138, 1138, + + 1138, 1139, 1139, 1139, 1141, 1141, 1141, 1142, 1142, 1142, + 1143, 1143, 1143, 1144, 1144, 1145, 1145, 1145, 1146, 1146, + 1146, 1147, 1147, 1147, 51, 129, 51, 51, 51, 1178, + 999, 1178, 1178, 1179, 1179, 1180, 1180, 1181, 1181, 1182, + 1182, 1183, 1183, 1184, 1184, 1186, 1186, 1187, 1187, 1188, + 1188, 1189, 1189, 1190, 1190, 1191, 1191, 1192, 1192, 1193, + 1193, 1194, 1194, 1195, 1195, 1197, 1197, 1198, 1198, 1199, + 1199, 1200, 1200, 981, 981, 1202, 1202, 1203, 1203, 1205, + 1205, 1206, 1206, 1207, 1207, 1208, 1208, 1090, 1090, 1210, + 1210, 1211, 1211, 1212, 1212, 1213, 1213, 1215, 1215, 1216, + + 1216, 1217, 1217, 1218, 1218, 1219, 1219, 1220, 1220, 1221, + 1221, 1223, 1223, 1224, 1224, 1225, 1225, 1226, 1226, 1227, + 1227, 1227, 1229, 1229, 1230, 1230, 1230, 1232, 1232, 1232, + 1233, 1233, 1121, 1121, 1121, 1234, 1234, 1234, 1235, 1235, + 1235, 1236, 1236, 1237, 1237, 1237, 1238, 1238, 1238, 1239, + 1239, 1239, 1241, 1241, 1241, 1242, 1242, 1242, 1243, 1243, + 1243, 1244, 1244, 1245, 1245, 1245, 1246, 1246, 1246, 1247, + 1247, 1247, 1248, 1248, 1249, 1249, 1249, 1250, 1250, 1250, + 1251, 1251, 1251, 1253, 1253, 1253, 1254, 1254, 1254, 1255, + 1255, 1255, 1256, 1256, 51, 129, 51, 51, 51, 1282, + + 993, 1282, 1282, 1283, 1283, 1284, 1284, 1286, 1286, 1287, + 1287, 1288, 1288, 1290, 1290, 1291, 1291, 1292, 1292, 1293, + 1293, 1294, 1294, 1295, 1295, 1297, 1297, 1298, 1298, 1299, + 1299, 1301, 1301, 1302, 1302, 1303, 1303, 1304, 1304, 1305, + 1305, 1306, 1306, 1307, 1307, 1309, 1309, 1310, 1310, 1312, + 1312, 1313, 1313, 1314, 1314, 1315, 1315, 1190, 1190, 1317, + 1317, 1318, 1318, 1319, 1319, 1320, 1320, 1198, 1198, 1322, + 1322, 1323, 1323, 1324, 1324, 1325, 1325, 1326, 1326, 1328, + 1328, 1329, 1329, 1330, 1330, 1331, 1331, 1332, 1332, 1333, + 1333, 1334, 1334, 1336, 1336, 1336, 1338, 1338, 1339, 1339, + + 1339, 1341, 1341, 1341, 1342, 1342, 1343, 1343, 1343, 1344, + 1344, 1344, 1346, 1346, 1346, 1347, 1347, 1347, 1348, 1348, + 1348, 1350, 1350, 1350, 1351, 1351, 1351, 1352, 1352, 1352, + 1353, 1353, 1354, 1354, 1354, 1355, 1355, 1355, 1356, 1356, + 1356, 1358, 1358, 1358, 1359, 1359, 1359, 1360, 1360, 1360, + 1362, 1362, 1362, 1363, 1363, 1363, 1364, 1364, 1364, 1365, + 1365, 1366, 1366, 1366, 1367, 1367, 1367, 1368, 1368, 1368, + 51, 891, 51, 51, 51, 1392, 984, 1392, 1392, 1393, + 1393, 1394, 1394, 1396, 1396, 1397, 1397, 1282, 1282, 1398, + 1398, 1399, 1399, 1400, 1400, 1401, 1401, 1402, 1402, 1403, + + 1403, 1405, 1405, 1406, 1406, 1407, 1407, 1408, 1408, 1409, + 1409, 1410, 1410, 1411, 1411, 1412, 1412, 1413, 1413, 1414, + 1414, 1415, 1415, 1417, 1417, 1418, 1418, 1419, 1419, 1420, + 1420, 1421, 1421, 1423, 1423, 1424, 1424, 1425, 1425, 1426, + 1426, 1186, 1186, 1428, 1428, 1429, 1429, 1430, 1430, 1431, + 1431, 1302, 1302, 1433, 1433, 1434, 1434, 1435, 1435, 1436, + 1436, 1438, 1438, 1439, 1439, 1440, 1440, 1441, 1441, 1442, + 1442, 1443, 1443, 1444, 1444, 1446, 1446, 1447, 1447, 1448, + 1448, 1449, 1449, 1450, 1450, 1450, 1452, 1452, 1453, 1453, + 1453, 1454, 1454, 1454, 1455, 1455, 1456, 1456, 1456, 1457, + + 1457, 1457, 1459, 1459, 1459, 1460, 1460, 1460, 1461, 1461, + 1462, 1462, 1462, 1463, 1463, 1463, 1464, 1464, 1464, 1465, + 1465, 1466, 1466, 1466, 1467, 1467, 1467, 1468, 1468, 1468, + 1470, 1470, 1470, 1471, 1471, 1471, 1472, 1472, 1472, 1473, + 1473, 1474, 1474, 1474, 1475, 1475, 1475, 1476, 1476, 1476, + 1477, 1477, 1478, 1478, 1478, 1479, 1479, 1479, 1480, 1480, + 1480, 1482, 1482, 1482, 1483, 1483, 1483, 1484, 1484, 1484, + 1485, 1485, 51, 993, 51, 51, 51, 1504, 891, 1504, + 1504, 1393, 1393, 1505, 1505, 1506, 1506, 1507, 1507, 1508, + 1508, 1509, 1509, 1511, 1511, 1512, 1512, 1513, 1513, 1515, + + 1515, 1516, 1516, 1517, 1517, 1518, 1518, 1519, 1519, 1520, + 1520, 1521, 1521, 1523, 1523, 1524, 1524, 1525, 1525, 1527, + 1527, 1528, 1528, 1529, 1529, 1530, 1530, 1531, 1531, 1532, + 1532, 1533, 1533, 1535, 1535, 1537, 1537, 1538, 1538, 1539, + 1539, 1290, 1290, 1541, 1541, 1542, 1542, 1543, 1543, 1544, + 1544, 1410, 1410, 1546, 1546, 1547, 1547, 1548, 1548, 1549, + 1549, 1418, 1418, 1551, 1551, 1552, 1552, 1553, 1553, 1554, + 1554, 1555, 1555, 1557, 1557, 1558, 1558, 1559, 1559, 1560, + 1560, 1561, 1561, 1562, 1562, 1563, 1563, 1565, 1565, 1565, + 1567, 1567, 1568, 1568, 1568, 1570, 1570, 1570, 1571, 1571, + + 1571, 1572, 1572, 1572, 1574, 1574, 1574, 1575, 1575, 1575, + 1576, 1576, 1577, 1577, 1577, 1578, 1578, 1578, 1579, 1579, + 1579, 1581, 1581, 1581, 1582, 1582, 1582, 1583, 1583, 1583, + 1585, 1585, 1585, 1586, 1586, 1586, 1587, 1587, 1587, 1588, + 1588, 1589, 1589, 1589, 1590, 1590, 1590, 1591, 1591, 1591, + 1593, 1593, 1593, 1594, 1594, 1594, 1595, 1595, 1595, 1597, + 1597, 1597, 1598, 1598, 1598, 1599, 1599, 1599, 1600, 1600, + 1601, 1601, 1601, 1602, 1602, 1602, 1603, 1603, 1603, 51, + 984, 51, 51, 51, 1620, 129, 1620, 1620, 1507, 1507, + 1621, 1621, 1622, 1622, 1623, 1623, 1625, 1625, 1626, 1626, + + 1627, 1627, 1628, 1628, 1629, 1629, 1630, 1630, 1631, 1631, + 1632, 1632, 1633, 1633, 1634, 1634, 1636, 1636, 1637, 1637, + 1638, 1638, 1639, 1639, 1640, 1640, 1641, 1641, 1642, 1642, + 1643, 1643, 1644, 1644, 1645, 1645, 1646, 1646, 1648, 1648, + 1649, 1649, 1650, 1650, 1651, 1651, 1652, 1652, 1654, 1654, + 1655, 1655, 1398, 1398, 1657, 1657, 1658, 1658, 1659, 1659, + 1660, 1660, 1406, 1406, 1662, 1662, 1663, 1663, 1664, 1664, + 1665, 1665, 1528, 1528, 1667, 1667, 1668, 1668, 1669, 1669, + 1670, 1670, 1672, 1672, 1673, 1673, 1674, 1674, 1675, 1675, + 1676, 1676, 1677, 1677, 1678, 1678, 1680, 1680, 1681, 1681, + + 1682, 1682, 1683, 1683, 1684, 1684, 1684, 1686, 1686, 1687, + 1687, 1687, 1689, 1689, 1689, 1690, 1690, 1565, 1565, 1565, + 1691, 1691, 1691, 1692, 1692, 1692, 1693, 1693, 1694, 1694, + 1694, 1695, 1695, 1695, 1696, 1696, 1696, 1698, 1698, 1698, + 1699, 1699, 1699, 1700, 1700, 1700, 1701, 1701, 1702, 1702, + 1702, 1703, 1703, 1703, 1704, 1704, 1704, 1705, 1705, 1706, + 1706, 1706, 1707, 1707, 1707, 1708, 1708, 1708, 1710, 1710, + 1710, 1711, 1711, 1711, 1712, 1712, 1712, 1713, 1713, 1714, + 1714, 1714, 1715, 1715, 1715, 1716, 1716, 1716, 1717, 1717, + 1718, 1718, 1718, 1719, 1719, 1719, 1720, 1720, 1720, 1722, + + 1722, 1722, 1723, 1723, 1723, 1724, 1724, 1724, 1725, 1725, + 51, 891, 51, 51, 51, 1741, 887, 1741, 1741, 1742, + 1742, 1743, 1743, 1627, 1627, 1744, 1744, 1745, 1745, 1746, + 1746, 1748, 1748, 1749, 1749, 1750, 1750, 1752, 1752, 1753, + 1753, 1754, 1754, 1755, 1755, 1756, 1756, 1757, 1757, 1758, + 1758, 1760, 1760, 1761, 1761, 1762, 1762, 1764, 1764, 1765, + 1765, 1766, 1766, 1767, 1767, 1768, 1768, 1769, 1769, 1770, + 1770, 1392, 1392, 1773, 1773, 1774, 1774, 1776, 1776, 1777, + 1777, 1778, 1778, 1779, 1779, 1516, 1516, 1781, 1781, 1782, + 1782, 1783, 1783, 1784, 1784, 1641, 1641, 1786, 1786, 1787, + + 1787, 1788, 1788, 1789, 1789, 1649, 1649, 1791, 1791, 1792, + 1792, 1761, 1761, 1793, 1793, 1794, 1794, 1795, 1795, 1797, + 1797, 1798, 1798, 1799, 1799, 1800, 1800, 1769, 1769, 1801, + 1801, 1802, 1802, 1803, 1803, 1805, 1805, 1805, 1686, 1686, + 1807, 1807, 1807, 1808, 1808, 1808, 1809, 1809, 1810, 1810, + 1810, 1811, 1811, 1811, 1813, 1813, 1813, 1814, 1814, 1814, + 1815, 1815, 1815, 1817, 1817, 1817, 1818, 1818, 1818, 1819, + 1819, 1819, 1820, 1820, 1821, 1821, 1821, 1822, 1822, 1822, + 1823, 1823, 1823, 1825, 1825, 1825, 1826, 1826, 1826, 1827, + 1827, 1827, 1829, 1829, 1829, 1830, 1830, 1830, 1831, 1831, + + 1831, 1832, 1832, 1833, 1833, 1833, 1834, 1834, 1834, 1835, + 1835, 1835, 1837, 1837, 1837, 1838, 1838, 1838, 1839, 1839, + 1839, 1841, 1841, 1841, 1842, 1842, 1842, 1843, 1843, 1843, + 1844, 1844, 1845, 1845, 1845, 1846, 1846, 1846, 1847, 1847, + 1847, 51, 887, 51, 51, 51, 1742, 129, 1742, 1742, + 1744, 1744, 1863, 1863, 1864, 1864, 1865, 1865, 1866, 1866, + 1867, 1867, 1868, 1868, 1869, 1869, 1870, 1870, 1871, 1871, + 1872, 1872, 1874, 1874, 1875, 1875, 1876, 1876, 1877, 1877, + 1878, 1878, 1879, 1879, 1880, 1880, 1881, 1881, 1882, 1882, + 1883, 1883, 1884, 1884, 1886, 1886, 1887, 1887, 1888, 1888, + + 1889, 1889, 1773, 1773, 1890, 1890, 1892, 1892, 1893, 1893, + 1894, 1894, 1895, 1895, 1629, 1629, 1897, 1897, 1898, 1898, + 1899, 1899, 1900, 1900, 1637, 1637, 1902, 1902, 1903, 1903, + 1904, 1904, 1905, 1905, 1765, 1765, 1907, 1907, 1908, 1908, + 1909, 1909, 1910, 1910, 1912, 1912, 1913, 1913, 1914, 1914, + 1915, 1915, 1883, 1883, 1916, 1916, 1917, 1917, 1918, 1918, + 1920, 1920, 1921, 1921, 1922, 1922, 1923, 1923, 1924, 1924, + 1924, 1809, 1809, 1925, 1925, 1925, 1926, 1926, 1926, 1927, + 1927, 1927, 1929, 1929, 1929, 1930, 1930, 1930, 1931, 1931, + 1932, 1932, 1932, 1933, 1933, 1933, 1934, 1934, 1934, 1935, + + 1935, 1936, 1936, 1936, 1937, 1937, 1937, 1938, 1938, 1938, + 1940, 1940, 1940, 1941, 1941, 1941, 1942, 1942, 1942, 1943, + 1943, 1944, 1944, 1944, 1945, 1945, 1945, 1946, 1946, 1946, + 1947, 1947, 1948, 1948, 1948, 1949, 1949, 1949, 1950, 1950, + 1950, 1952, 1952, 1952, 1953, 1953, 1953, 1954, 1954, 1954, + 1955, 1955, 1956, 1956, 1956, 1957, 1957, 1957, 1958, 1958, + 1958, 1959, 1959, 1960, 1960, 1960, 1961, 1961, 1961, 1962, + 1962, 1962, 1964, 1964, 1964, 1965, 1965, 1965, 1966, 1966, + 1966, 1967, 1967, 51, 984, 51, 51, 51, 1744, 984, + 1744, 1744, 1865, 1865, 1863, 1863, 1976, 1976, 1977, 1977, + + 1978, 1978, 1980, 1980, 1981, 1981, 1982, 1982, 1983, 1983, + 1984, 1984, 1985, 1985, 1986, 1986, 1987, 1987, 1989, 1989, + 1990, 1990, 1991, 1991, 1993, 1993, 1994, 1994, 1995, 1995, + 1996, 1996, 1997, 1997, 1998, 1998, 1999, 1999, 2001, 2001, + 1893, 1893, 2002, 2002, 2003, 2003, 1625, 1625, 2005, 2005, + 2006, 2006, 2007, 2007, 2008, 2008, 1753, 1753, 2010, 2010, + 2011, 2011, 2012, 2012, 2013, 2013, 1879, 1879, 2015, 2015, + 2016, 2016, 2017, 2017, 2018, 2018, 1887, 1887, 2020, 2020, + 2021, 2021, 1990, 1990, 2022, 2022, 2023, 2023, 2024, 2024, + 2026, 2026, 2027, 2027, 2028, 2028, 2029, 2029, 1998, 1998, + + 2030, 2030, 2031, 2031, 2032, 2032, 2034, 2034, 2034, 2035, + 2035, 2035, 2036, 2036, 2036, 1931, 1931, 2037, 2037, 2037, + 2038, 2038, 2038, 2039, 2039, 2039, 2041, 2041, 2041, 2042, + 2042, 2042, 2043, 2043, 2043, 2045, 2045, 2045, 2046, 2046, + 2046, 2047, 2047, 2047, 2048, 2048, 2049, 2049, 2049, 2050, + 2050, 2050, 2051, 2051, 2051, 2053, 2053, 2053, 2054, 2054, + 2054, 2055, 2055, 2055, 2057, 2057, 2057, 2058, 2058, 2058, + 2059, 2059, 2059, 2060, 2060, 2061, 2061, 2061, 2062, 2062, + 2062, 2063, 2063, 2063, 2065, 2065, 2065, 2066, 2066, 2066, + 2067, 2067, 2067, 2069, 2069, 2069, 2070, 2070, 2070, 2071, + + 2071, 2071, 2072, 2072, 2073, 2073, 2073, 2074, 2074, 2074, + 2075, 2075, 2075, 51, 129, 51, 51, 51, 1864, 2829, + 1864, 1864, 1981, 1981, 2084, 2084, 2085, 2085, 1984, 1984, + 1977, 1977, 2086, 2086, 2087, 2087, 2088, 2088, 2090, 2090, + 2091, 2091, 2092, 2092, 2093, 2093, 2094, 2094, 2095, 2095, + 2096, 2096, 2097, 2097, 2098, 2098, 2099, 2099, 2100, 2100, + 2102, 2102, 2103, 2103, 2104, 2104, 2105, 2105, 2106, 2106, + 1742, 1742, 2107, 2107, 2006, 2006, 2108, 2108, 2109, 2109, + 1868, 1868, 2111, 2111, 2112, 2112, 2113, 2113, 2114, 2114, + 1875, 1875, 2116, 2116, 2117, 2117, 2118, 2118, 2119, 2119, + + 1994, 1994, 2121, 2121, 2122, 2122, 2123, 2123, 2124, 2124, + 2126, 2126, 2127, 2127, 2128, 2128, 2129, 2129, 2099, 2099, + 2130, 2130, 2131, 2131, 2132, 2132, 2134, 2134, 2135, 2135, + 2136, 2136, 2137, 2137, 2035, 2035, 2035, 2037, 2037, 2037, + 2138, 2138, 2138, 2139, 2139, 2139, 2140, 2140, 2140, 2141, + 2141, 2141, 2142, 2142, 2143, 2143, 2143, 2144, 2144, 2144, + 2145, 2145, 2145, 2146, 2146, 2146, 2147, 2147, 2147, 2149, + 2149, 2149, 2150, 2150, 2150, 2151, 2151, 2151, 2152, 2152, + 2153, 2153, 2153, 2154, 2154, 2154, 2155, 2155, 2155, 2156, + 2156, 2157, 2157, 2157, 2158, 2158, 2158, 2159, 2159, 2159, + + 2161, 2161, 2161, 2162, 2162, 2162, 2163, 2163, 2163, 2164, + 2164, 2165, 2165, 2165, 2166, 2166, 2166, 2167, 2167, 2167, + 2168, 2168, 2169, 2169, 2169, 2170, 2170, 2170, 2171, 2171, + 2171, 2173, 2173, 2173, 2174, 2174, 2174, 2175, 2175, 2175, + 2176, 2176, 51, 2829, 51, 51, 51, 1863, 962, 1863, + 1863, 2086, 2086, 2184, 2184, 2090, 2090, 2185, 2185, 2186, + 2186, 2093, 2093, 2187, 2187, 2188, 2188, 2189, 2189, 2191, + 2191, 2192, 2192, 2193, 2193, 2195, 2195, 2196, 2196, 2197, + 2197, 2198, 2198, 2199, 2199, 2200, 2200, 2201, 2201, 1742, + 1742, 2203, 2203, 1865, 1865, 2204, 2204, 2112, 2112, 2205, + + 2205, 2206, 2206, 1982, 1982, 2208, 2208, 2209, 2209, 2210, + 2210, 2211, 2211, 2095, 2095, 2213, 2213, 2214, 2214, 2215, + 2215, 2216, 2216, 2103, 2103, 2218, 2218, 2219, 2219, 2192, + 2192, 2220, 2220, 2221, 2221, 2222, 2222, 2224, 2224, 2225, + 2225, 2226, 2226, 2227, 2227, 2200, 2200, 2228, 2228, 2229, + 2229, 2230, 2230, 2140, 2140, 2140, 2138, 2138, 2138, 2232, + 2232, 2232, 2233, 2233, 2233, 2234, 2234, 2234, 2236, 2236, + 2236, 2237, 2237, 2237, 2238, 2238, 2238, 2239, 2239, 2239, + 2240, 2240, 2241, 2241, 2241, 2242, 2242, 2242, 2243, 2243, + 2243, 2245, 2245, 2245, 2246, 2246, 2246, 2247, 2247, 2247, + + 2249, 2249, 2249, 2250, 2250, 2250, 2251, 2251, 2251, 2252, + 2252, 2253, 2253, 2253, 2254, 2254, 2254, 2255, 2255, 2255, + 2257, 2257, 2257, 2258, 2258, 2258, 2259, 2259, 2259, 2261, + 2261, 2261, 2262, 2262, 2262, 2263, 2263, 2263, 2264, 2264, + 2265, 2265, 2265, 2266, 2266, 2266, 2267, 2267, 2267, 51, + 961, 51, 51, 51, 1865, 960, 1865, 1865, 2185, 2185, + 2187, 2187, 2277, 2277, 2278, 2278, 2279, 2279, 2280, 2280, + 2281, 2281, 2282, 2282, 2283, 2283, 2284, 2284, 2285, 2285, + 2286, 2286, 2288, 2288, 2289, 2289, 2290, 2290, 2291, 2291, + 2292, 2292, 2084, 2084, 2293, 2293, 2209, 2209, 2294, 2294, + + 2295, 2295, 2091, 2091, 2297, 2297, 2298, 2298, 2299, 2299, + 2300, 2300, 2196, 2196, 2302, 2302, 2303, 2303, 2304, 2304, + 2305, 2305, 2307, 2307, 2308, 2308, 2309, 2309, 2310, 2310, + 2311, 2311, 2312, 2312, 2313, 2313, 2315, 2315, 2316, 2316, + 2317, 2317, 2318, 2318, 2237, 2237, 2237, 2319, 2319, 2319, + 2320, 2320, 2320, 2240, 2240, 2233, 2233, 2233, 2321, 2321, + 2321, 2322, 2322, 2322, 2323, 2323, 2323, 2325, 2325, 2325, + 2326, 2326, 2326, 2327, 2327, 2327, 2328, 2328, 2329, 2329, + 2329, 2330, 2330, 2330, 2331, 2331, 2331, 2332, 2332, 2333, + 2333, 2333, 2334, 2334, 2334, 2335, 2335, 2335, 2337, 2337, + + 2337, 2338, 2338, 2338, 2339, 2339, 2339, 2340, 2340, 2341, + 2341, 2341, 2342, 2342, 2342, 2343, 2343, 2343, 2344, 2344, + 2345, 2345, 2345, 2346, 2346, 2346, 2347, 2347, 2347, 2349, + 2349, 2349, 2350, 2350, 2350, 2351, 2351, 2351, 2352, 2352, + 51, 959, 51, 51, 51, 1976, 958, 1976, 1976, 2279, + 2279, 2277, 2277, 2358, 2358, 2359, 2359, 2360, 2360, 2362, + 2362, 2363, 2363, 2364, 2364, 2365, 2365, 2366, 2366, 2367, + 2367, 2368, 2368, 2369, 2369, 2084, 2084, 2371, 2371, 2185, + 2185, 2372, 2372, 2298, 2298, 2373, 2373, 2374, 2374, 2282, + 2282, 2376, 2376, 2377, 2377, 2378, 2378, 2379, 2379, 2289, + + 2289, 2381, 2381, 2382, 2382, 2383, 2383, 2384, 2384, 2385, + 2385, 2387, 2387, 2388, 2388, 2389, 2389, 2390, 2390, 2391, + 2391, 2392, 2392, 2393, 2393, 2321, 2321, 2321, 2395, 2395, + 2395, 2325, 2325, 2325, 2396, 2396, 2396, 2397, 2397, 2397, + 2328, 2328, 2398, 2398, 2398, 2399, 2399, 2399, 2400, 2400, + 2400, 2402, 2402, 2402, 2403, 2403, 2403, 2404, 2404, 2404, + 2406, 2406, 2406, 2407, 2407, 2407, 2408, 2408, 2408, 2409, + 2409, 2410, 2410, 2410, 2411, 2411, 2411, 2412, 2412, 2412, + 2414, 2414, 2414, 2415, 2415, 2415, 2416, 2416, 2416, 2418, + 2418, 2418, 2419, 2419, 2419, 2420, 2420, 2420, 2421, 2421, + + 2422, 2422, 2422, 2423, 2423, 2423, 2424, 2424, 2424, 51, + 957, 51, 51, 51, 1981, 2829, 1981, 1981, 2363, 2363, + 2430, 2430, 2431, 2431, 2366, 2366, 2359, 2359, 2432, 2432, + 2433, 2433, 2434, 2434, 2436, 2436, 2437, 2437, 2438, 2438, + 2439, 2439, 2185, 2185, 2440, 2440, 2279, 2279, 2441, 2441, + 2377, 2377, 2442, 2442, 2443, 2443, 2364, 2364, 2445, 2445, + 2446, 2446, 2447, 2447, 2448, 2448, 2450, 2450, 2451, 2451, + 2452, 2452, 2453, 2453, 2454, 2454, 2455, 2455, 2456, 2456, + 2458, 2458, 2459, 2459, 2460, 2460, 2461, 2461, 2396, 2396, + 2396, 2398, 2398, 2398, 2462, 2462, 2462, 2463, 2463, 2463, + + 2464, 2464, 2464, 2465, 2465, 2465, 2466, 2466, 2467, 2467, + 2467, 2468, 2468, 2468, 2469, 2469, 2469, 2470, 2470, 2470, + 2471, 2471, 2471, 2473, 2473, 2473, 2474, 2474, 2474, 2475, + 2475, 2475, 2476, 2476, 2477, 2477, 2477, 2478, 2478, 2478, + 2479, 2479, 2479, 2480, 2480, 2481, 2481, 2481, 2482, 2482, + 2482, 2483, 2483, 2483, 2485, 2485, 2485, 2486, 2486, 2486, + 2487, 2487, 2487, 2488, 2488, 51, 130, 51, 51, 51, + 1977, 130, 1977, 1977, 2432, 2432, 2492, 2492, 2436, 2436, + 2493, 2493, 2494, 2494, 2439, 2439, 2495, 2495, 2496, 2496, + 2497, 2497, 2279, 2279, 2499, 2499, 2430, 2430, 2500, 2500, + + 2446, 2446, 2501, 2501, 2502, 2502, 2437, 2437, 2504, 2504, + 2505, 2505, 2506, 2506, 2507, 2507, 2508, 2508, 2510, 2510, + 2511, 2511, 2512, 2512, 2513, 2513, 2514, 2514, 2515, 2515, + 2516, 2516, 2464, 2464, 2464, 2462, 2462, 2462, 2518, 2518, + 2518, 2519, 2519, 2519, 2520, 2520, 2520, 2522, 2522, 2522, + 2523, 2523, 2523, 2524, 2524, 2524, 2525, 2525, 2525, 2526, + 2526, 2527, 2527, 2527, 2528, 2528, 2528, 2529, 2529, 2529, + 2531, 2531, 2531, 2532, 2532, 2532, 2533, 2533, 2533, 2535, + 2535, 2535, 2536, 2536, 2536, 2537, 2537, 2537, 2538, 2538, + 2539, 2539, 2539, 2540, 2540, 2540, 2541, 2541, 2541, 51, + + 130, 51, 51, 51, 2084, 923, 2084, 2084, 2493, 2493, + 2495, 2495, 2546, 2546, 2547, 2547, 2548, 2548, 2549, 2549, + 2550, 2550, 2430, 2430, 2551, 2551, 2552, 2552, 2505, 2505, + 2553, 2553, 2554, 2554, 2556, 2556, 2557, 2557, 2558, 2558, + 2559, 2559, 2560, 2560, 2561, 2561, 2563, 2563, 2564, 2564, + 2565, 2565, 2566, 2566, 2523, 2523, 2523, 2567, 2567, 2567, + 2568, 2568, 2568, 2526, 2526, 2519, 2519, 2519, 2569, 2569, + 2569, 2570, 2570, 2570, 2571, 2571, 2571, 2573, 2573, 2573, + 2574, 2574, 2574, 2575, 2575, 2575, 2576, 2576, 2577, 2577, + 2577, 2578, 2578, 2578, 2579, 2579, 2579, 2580, 2580, 2581, + + 2581, 2581, 2582, 2582, 2582, 2583, 2583, 2583, 2585, 2585, + 2585, 2586, 2586, 2586, 2587, 2587, 2587, 2588, 2588, 51, + 915, 51, 51, 51, 2086, 902, 2086, 2086, 2548, 2548, + 2546, 2546, 2592, 2592, 2593, 2593, 2594, 2594, 2493, 2493, + 2596, 2596, 2597, 2597, 2558, 2558, 2598, 2598, 2599, 2599, + 2601, 2601, 2602, 2602, 2603, 2603, 2604, 2604, 2605, 2605, + 2606, 2606, 2607, 2607, 2569, 2569, 2569, 2609, 2609, 2609, + 2573, 2573, 2573, 2610, 2610, 2610, 2611, 2611, 2611, 2576, + 2576, 2612, 2612, 2612, 2613, 2613, 2613, 2614, 2614, 2614, + 2616, 2616, 2616, 2617, 2617, 2617, 2618, 2618, 2618, 2620, + + 2620, 2620, 2621, 2621, 2621, 2622, 2622, 2622, 2623, 2623, + 2624, 2624, 2624, 2625, 2625, 2625, 2626, 2626, 2626, 51, + 895, 51, 51, 51, 2090, 129, 2090, 2090, 2601, 2601, + 2631, 2631, 2632, 2632, 2633, 2633, 2548, 2548, 2634, 2634, + 2635, 2635, 2604, 2604, 2593, 2593, 2636, 2636, 2637, 2637, + 2638, 2638, 2640, 2640, 2641, 2641, 2642, 2642, 2643, 2643, + 2610, 2610, 2610, 2612, 2612, 2612, 2644, 2644, 2644, 2645, + 2645, 2645, 2646, 2646, 2646, 2647, 2647, 2647, 2648, 2648, + 2649, 2649, 2649, 2650, 2650, 2650, 2651, 2651, 2651, 2652, + 2652, 2652, 2653, 2653, 2653, 2655, 2655, 2655, 2656, 2656, + + 2656, 2657, 2657, 2657, 2658, 2658, 51, 915, 51, 51, + 51, 2184, 909, 2184, 2184, 2662, 2662, 2663, 2663, 2631, + 2631, 2665, 2665, 2666, 2666, 2667, 2667, 2668, 2668, 2669, + 2669, 2670, 2670, 2672, 2672, 2672, 2673, 2673, 2673, 2674, + 2674, 2674, 2676, 2676, 2676, 2677, 2677, 2677, 2678, 2678, + 2678, 2679, 2679, 2679, 2680, 2680, 2681, 2681, 2681, 2682, + 2682, 2682, 2683, 2683, 2683, 2185, 895, 2185, 2185, 2688, + 2688, 2689, 2689, 2690, 2690, 2691, 2691, 2692, 2692, 2693, + 2693, 2694, 2694, 2695, 2695, 2695, 2696, 2696, 2696, 2697, + 2697, 2697, 2698, 2698, 2698, 2699, 2699, 2699, 2701, 2701, + + 2701, 2702, 2702, 2702, 2703, 2703, 2703, 2704, 2704, 2187, + 915, 2187, 2187, 2708, 2708, 2709, 2709, 2711, 2711, 2712, + 2712, 2714, 2714, 2715, 2715, 2715, 2716, 2716, 2716, 2717, + 2717, 2717, 2718, 2718, 2718, 2719, 2719, 2719, 2720, 2720, + 2720, 2278, 909, 2278, 2278, 2725, 2725, 2726, 2726, 2729, + 2729, 2730, 2730, 2730, 2731, 2731, 2731, 2732, 2732, 2732, + 2733, 2733, 2733, 2277, 895, 2277, 2277, 2737, 2737, 2738, + 2738, 2739, 2739, 2739, 2740, 2740, 2740, 2279, 800, 2279, + 2279, 2744, 2744, 2744, 2358, 129, 2358, 2358, 2363, 909, + 2363, 2363, 2359, 904, 2359, 2359, 2430, 909, 2430, 2430, + + 2432, 904, 2432, 2432, 2436, 129, 2436, 2436, 2492, 904, + 2492, 2492, 2493, 904, 2493, 2493, 2495, 902, 2495, 2495, + 2547, 895, 2547, 2547, 2546, 891, 2546, 2546, 2548, 129, + 2548, 2548, 2592, 895, 2592, 2592, 2601, 800, 2601, 2601, + 2593, 895, 2593, 2593, 2631, 800, 2631, 2631, 2636, 800, + 2636, 2636, 2640, 891, 2640, 2640, 2662, 129, 2662, 2662, + 2666, 2829, 2666, 2666, 2668, 867, 2668, 2668, 2691, 866, + 2691, 2691, 2708, 865, 2708, 2708, 2692, 864, 2692, 2692, + 2711, 863, 2711, 2711, 2726, 862, 2726, 2726, 2737, 130, + 2737, 2737, 130, 130, 130, 129, 827, 819, 808, 827, + + 819, 808, 716, 129, 819, 814, 716, 819, 814, 129, + 814, 814, 129, 129, 808, 716, 808, 716, 129, 716, + 716, 129, 2829, 2829, 2829, 2829, 2829, 778, 777, 776, + 775, 774, 773, 2829, 762, 130, 130, 743, 735, 725, + 720, 129, 735, 729, 720, 735, 729, 720, 129, 729, + 729, 129, 726, 725, 720, 129, 720, 720, 129, 712, + 2829, 2829, 2829, 2829, 2829, 2829, 688, 687, 686, 685, + 684, 683, 2829, 2829, 671, 130, 130, 130, 129, 652, + 645, 638, 652, 645, 638, 129, 645, 642, 645, 129, + 642, 129, 638, 638, 129, 628, 623, 622, 600, 595, + + 594, 593, 592, 591, 590, 587, 575, 130, 130, 562, + 555, 549, 129, 555, 551, 555, 551, 129, 551, 549, + 129, 539, 534, 533, 511, 506, 505, 504, 503, 502, + 501, 497, 485, 130, 130, 129, 470, 465, 470, 465, + 129, 465, 465, 129, 454, 448, 447, 425, 410, 130, + 386, 381, 129, 381, 381, 129, 328, 321, 314, 130, + 129, 304, 304, 129, 233, 230, 228, 227, 226, 217, + 129, 153, 140, 138, 137, 136, 133, 130, 129, 42, + 52, 50, 42, 2829, 3, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829 + } ; + +static yyconst flex_int16_t yy_chk[10753] = + { 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, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 5, 23, 1329, + 5, 9, 9, 9, 9, 9, 11, 577, 11, 11, + 11, 11, 11, 11, 12, 1330, 12, 12, 12, 12, + 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, + + 14, 14, 14, 14, 40, 270, 17, 40, 16, 14, + 17, 49, 18, 21, 17, 24, 129, 117, 49, 23, + 18, 577, 129, 16, 14, 14, 14, 14, 14, 14, + 16, 270, 282, 282, 14, 18, 16, 51, 20, 18, + 21, 94, 30, 117, 576, 620, 24, 270, 14, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 19, 22, 582, 21, 117, 24, 25, 25, 20, + 26, 30, 19, 30, 1331, 576, 25, 620, 22, 19, + 20, 15, 15, 15, 15, 15, 15, 19, 51, 20, + 74, 34, 94, 30, 19, 22, 19, 27, 27, 26, + + 62, 22, 25, 19, 29, 15, 34, 25, 28, 29, + 26, 582, 27, 22, 28, 26, 34, 32, 25, 33, + 32, 26, 28, 33, 27, 31, 32, 57, 27, 74, + 34, 29, 27, 33, 63, 29, 36, 27, 62, 63, + 28, 74, 81, 36, 29, 63, 29, 28, 27, 29, + 31, 62, 1332, 57, 31, 29, 36, 37, 37, 28, + 36, 81, 33, 584, 31, 31, 32, 36, 32, 31, + 33, 584, 37, 38, 31, 64, 31, 57, 38, 43, + 43, 43, 43, 43, 37, 45, 45, 45, 45, 45, + 54, 54, 61, 81, 71, 65, 46, 37, 46, 46, + + 46, 46, 46, 46, 38, 597, 59, 47, 37, 47, + 47, 47, 47, 47, 47, 65, 66, 54, 64, 67, + 68, 59, 69, 61, 38, 39, 64, 73, 69, 39, + 39, 71, 597, 127, 68, 214, 39, 1333, 39, 39, + 127, 54, 214, 61, 39, 71, 65, 76, 72, 75, + 67, 39, 78, 73, 69, 39, 39, 59, 66, 1334, + 703, 39, 703, 39, 39, 80, 86, 66, 39, 77, + 67, 68, 73, 69, 79, 39, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 72, 75, + 76, 78, 83, 84, 85, 82, 86, 87, 76, 72, + + 75, 88, 91, 78, 88, 90, 92, 80, 52, 52, + 52, 52, 52, 52, 82, 77, 80, 86, 79, 89, + 77, 85, 84, 92, 95, 79, 84, 93, 853, 97, + 88, 91, 92, 93, 87, 83, 99, 96, 102, 89, + 98, 100, 101, 83, 84, 85, 82, 92, 87, 90, + 95, 104, 88, 91, 92, 96, 90, 107, 103, 93, + 105, 1335, 853, 89, 109, 104, 101, 106, 111, 95, + 89, 99, 112, 97, 574, 101, 99, 98, 93, 96, + 97, 111, 98, 100, 102, 108, 107, 99, 96, 102, + 103, 98, 100, 115, 105, 103, 114, 106, 110, 103, + + 113, 103, 104, 109, 116, 114, 120, 109, 107, 103, + 134, 105, 108, 112, 110, 109, 113, 118, 106, 111, + 131, 574, 1337, 112, 115, 133, 131, 108, 134, 122, + 120, 122, 122, 122, 122, 122, 108, 120, 130, 130, + 130, 130, 130, 118, 115, 139, 116, 114, 133, 110, + 141, 113, 134, 580, 123, 116, 123, 123, 123, 123, + 123, 134, 118, 121, 139, 121, 135, 124, 121, 124, + 124, 124, 124, 124, 124, 144, 133, 1340, 146, 141, + 121, 125, 121, 125, 125, 125, 125, 125, 125, 121, + 135, 121, 142, 145, 121, 679, 139, 580, 951, 135, + + 679, 141, 144, 149, 121, 146, 121, 147, 147, 150, + 151, 951, 148, 121, 132, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 144, 153, 154, 146, + 142, 152, 155, 151, 156, 150, 157, 145, 161, 158, + 160, 166, 149, 142, 145, 162, 132, 132, 132, 132, + 132, 132, 148, 165, 149, 152, 163, 151, 147, 152, + 150, 151, 153, 148, 169, 156, 159, 159, 159, 161, + 155, 168, 154, 158, 164, 173, 163, 166, 153, 154, + 160, 157, 167, 155, 162, 156, 170, 157, 167, 161, + 158, 160, 166, 173, 164, 169, 162, 165, 171, 172, + + 176, 175, 178, 174, 165, 1345, 184, 163, 182, 171, + 186, 181, 187, 1349, 168, 169, 177, 173, 183, 159, + 185, 180, 168, 177, 172, 164, 173, 174, 189, 188, + 170, 176, 196, 167, 171, 181, 174, 170, 175, 172, + 180, 177, 182, 181, 191, 187, 190, 177, 188, 171, + 184, 176, 175, 178, 186, 183, 177, 184, 192, 182, + 185, 186, 193, 187, 180, 194, 195, 197, 196, 183, + 189, 185, 180, 190, 199, 198, 201, 200, 204, 189, + 188, 191, 202, 196, 203, 195, 207, 202, 193, 192, + 206, 236, 588, 220, 301, 191, 194, 190, 205, 220, + + 378, 301, 307, 199, 231, 462, 208, 378, 307, 192, + 198, 197, 462, 193, 200, 203, 194, 195, 197, 236, + 770, 1357, 205, 585, 770, 199, 198, 201, 200, 204, + 208, 209, 206, 202, 208, 203, 588, 207, 209, 209, + 231, 206, 236, 209, 210, 210, 210, 210, 210, 205, + 218, 218, 218, 218, 218, 231, 209, 219, 219, 219, + 219, 219, 209, 209, 223, 228, 224, 209, 585, 579, + 211, 209, 211, 211, 211, 211, 211, 211, 212, 224, + 212, 212, 212, 212, 212, 212, 222, 222, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 222, 227, 223, + + 225, 229, 228, 230, 224, 232, 229, 579, 234, 235, + 237, 238, 237, 241, 239, 223, 228, 224, 222, 222, + 222, 222, 222, 222, 244, 225, 243, 245, 246, 227, + 247, 248, 251, 257, 230, 1361, 260, 262, 225, 257, + 232, 249, 250, 248, 252, 253, 254, 259, 1369, 227, + 248, 235, 229, 238, 230, 244, 232, 234, 239, 234, + 235, 237, 238, 243, 241, 239, 258, 249, 250, 256, + 246, 247, 254, 261, 251, 244, 253, 243, 245, 246, + 255, 247, 248, 251, 257, 255, 252, 260, 262, 264, + 264, 259, 249, 250, 266, 252, 253, 254, 259, 265, + + 256, 258, 267, 581, 268, 271, 269, 272, 261, 273, + 274, 275, 276, 278, 546, 269, 264, 258, 279, 277, + 256, 546, 1375, 288, 261, 265, 272, 291, 284, 266, + 268, 255, 280, 281, 287, 283, 289, 292, 581, 293, + 264, 269, 285, 276, 278, 266, 286, 312, 332, 265, + 1377, 275, 274, 267, 268, 290, 271, 269, 272, 277, + 273, 274, 275, 276, 278, 283, 279, 280, 284, 279, + 277, 335, 281, 285, 288, 287, 289, 286, 291, 284, + 1053, 290, 293, 280, 281, 287, 283, 289, 292, 286, + 293, 294, 295, 285, 335, 309, 604, 286, 312, 332, + + 295, 309, 335, 294, 295, 296, 290, 296, 296, 296, + 296, 296, 317, 1053, 1378, 604, 317, 294, 295, 297, + 314, 297, 297, 297, 297, 297, 295, 311, 294, 295, + 298, 315, 298, 298, 298, 298, 298, 298, 317, 316, + 321, 294, 295, 299, 324, 299, 299, 299, 299, 299, + 299, 310, 310, 310, 310, 310, 310, 310, 310, 310, + 310, 310, 310, 317, 314, 319, 311, 320, 322, 318, + 323, 314, 322, 329, 315, 330, 583, 321, 311, 316, + 326, 324, 315, 310, 310, 310, 310, 310, 310, 318, + 316, 321, 318, 325, 327, 324, 331, 326, 333, 334, + + 339, 337, 342, 327, 336, 325, 338, 343, 319, 344, + 323, 320, 1379, 348, 341, 583, 319, 330, 320, 322, + 318, 323, 329, 331, 329, 349, 330, 336, 341, 350, + 346, 326, 337, 333, 334, 336, 345, 339, 338, 348, + 347, 342, 343, 347, 325, 327, 344, 331, 350, 333, + 334, 339, 337, 342, 345, 345, 354, 338, 343, 346, + 344, 348, 351, 353, 349, 341, 352, 356, 355, 347, + 357, 359, 350, 358, 360, 363, 349, 364, 366, 365, + 350, 346, 367, 369, 372, 354, 351, 345, 355, 368, + 371, 347, 1386, 358, 351, 387, 356, 352, 353, 389, + + 359, 387, 390, 368, 360, 389, 364, 354, 390, 474, + 372, 373, 617, 357, 353, 474, 369, 352, 356, 355, + 363, 357, 359, 365, 358, 360, 363, 373, 364, 366, + 365, 371, 372, 367, 369, 394, 395, 373, 397, 401, + 368, 371, 374, 374, 374, 374, 374, 617, 1387, 1391, + 375, 373, 375, 375, 375, 375, 375, 375, 376, 373, + 376, 376, 376, 376, 376, 376, 392, 392, 392, 392, + 392, 392, 392, 392, 392, 392, 392, 392, 393, 395, + 396, 399, 400, 403, 401, 402, 394, 395, 404, 397, + 401, 405, 406, 408, 411, 407, 412, 409, 392, 392, + + 392, 392, 392, 392, 407, 402, 415, 424, 393, 426, + 422, 635, 413, 396, 414, 427, 399, 428, 635, 404, + 429, 1393, 1394, 406, 400, 431, 422, 403, 423, 393, + 422, 396, 399, 400, 403, 427, 402, 439, 408, 404, + 405, 409, 405, 406, 408, 411, 407, 412, 409, 413, + 424, 429, 414, 430, 428, 423, 415, 415, 424, 432, + 426, 422, 433, 413, 431, 414, 427, 434, 428, 435, + 436, 429, 437, 433, 441, 440, 431, 438, 443, 423, + 442, 439, 430, 450, 445, 444, 432, 449, 439, 453, + 436, 446, 434, 446, 1395, 451, 437, 451, 433, 452, + + 452, 483, 484, 437, 430, 435, 438, 434, 446, 441, + 432, 445, 443, 433, 436, 440, 442, 455, 1396, 450, + 435, 436, 626, 456, 449, 441, 440, 444, 438, 443, + 608, 442, 456, 476, 450, 445, 444, 477, 449, 476, + 453, 479, 446, 477, 455, 480, 451, 479, 456, 563, + 452, 480, 483, 484, 626, 563, 456, 457, 457, 457, + 457, 457, 457, 456, 482, 486, 490, 488, 455, 458, + 458, 458, 458, 458, 458, 459, 608, 459, 459, 459, + 459, 459, 459, 460, 487, 460, 460, 460, 460, 460, + 460, 481, 481, 481, 481, 481, 481, 481, 481, 481, + + 481, 481, 481, 486, 482, 488, 489, 491, 495, 492, + 498, 494, 496, 499, 500, 482, 486, 490, 488, 487, + 509, 513, 515, 481, 481, 481, 481, 481, 481, 492, + 494, 493, 507, 508, 518, 487, 493, 510, 517, 495, + 493, 489, 514, 496, 514, 500, 512, 516, 499, 509, + 491, 520, 513, 520, 522, 524, 520, 489, 491, 495, + 492, 498, 494, 496, 499, 500, 520, 1397, 515, 523, + 525, 509, 513, 515, 507, 508, 526, 516, 510, 527, + 522, 517, 493, 507, 508, 518, 512, 521, 510, 517, + 529, 528, 521, 514, 535, 530, 538, 512, 516, 531, + + 522, 536, 520, 532, 524, 540, 524, 525, 537, 541, + 527, 528, 523, 565, 526, 1398, 538, 529, 521, 565, + 523, 525, 566, 568, 586, 535, 717, 526, 566, 568, + 527, 569, 536, 717, 540, 541, 1399, 569, 521, 530, + 1400, 529, 528, 570, 531, 535, 530, 538, 532, 570, + 531, 571, 536, 537, 532, 541, 540, 571, 596, 537, + 542, 542, 542, 542, 542, 543, 586, 543, 543, 543, + 543, 543, 543, 544, 598, 544, 544, 544, 544, 544, + 544, 573, 573, 573, 573, 573, 573, 573, 573, 573, + 573, 573, 573, 599, 603, 609, 606, 607, 596, 611, + + 605, 615, 619, 616, 618, 598, 621, 610, 624, 625, + 676, 670, 672, 573, 573, 573, 573, 573, 573, 605, + 599, 610, 761, 629, 611, 630, 630, 630, 630, 630, + 670, 675, 615, 619, 673, 1401, 611, 621, 657, 603, + 606, 609, 607, 618, 657, 659, 610, 616, 676, 660, + 624, 659, 672, 625, 629, 660, 1402, 761, 610, 631, + 631, 631, 631, 631, 632, 673, 632, 632, 632, 632, + 632, 632, 633, 675, 633, 633, 633, 633, 633, 633, + 661, 662, 663, 664, 666, 667, 661, 662, 663, 664, + 666, 667, 668, 674, 677, 678, 680, 689, 668, 669, + + 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, + 669, 690, 694, 681, 693, 692, 695, 697, 702, 698, + 699, 704, 700, 701, 674, 705, 708, 680, 707, 711, + 780, 669, 669, 669, 669, 669, 669, 782, 677, 678, + 681, 689, 700, 690, 692, 710, 693, 710, 1065, 697, + 698, 699, 694, 1403, 701, 771, 695, 744, 702, 704, + 707, 711, 780, 744, 746, 765, 1065, 771, 705, 782, + 746, 708, 714, 700, 714, 714, 714, 714, 714, 714, + 715, 763, 715, 715, 715, 715, 715, 715, 747, 749, + 750, 751, 753, 754, 747, 749, 750, 751, 753, 754, + + 755, 756, 757, 758, 764, 765, 755, 756, 757, 758, + 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, + 760, 760, 766, 767, 764, 768, 763, 769, 772, 779, + 781, 783, 785, 787, 784, 786, 790, 791, 793, 792, + 794, 796, 760, 760, 760, 760, 760, 760, 795, 797, + 801, 1404, 1388, 832, 767, 1156, 768, 801, 769, 832, + 783, 781, 766, 784, 785, 1388, 1164, 1156, 1164, 779, + 792, 794, 772, 793, 786, 787, 1405, 834, 835, 795, + 797, 790, 791, 834, 835, 798, 796, 798, 798, 798, + 798, 798, 798, 799, 851, 799, 799, 799, 799, 799, + + 799, 837, 838, 839, 840, 841, 842, 837, 838, 839, + 840, 841, 842, 843, 844, 846, 847, 848, 849, 843, + 844, 846, 847, 848, 849, 850, 850, 850, 850, 850, + 850, 850, 850, 850, 850, 850, 850, 852, 854, 855, + 856, 860, 857, 858, 851, 868, 871, 861, 874, 875, + 876, 869, 877, 872, 873, 878, 880, 850, 850, 850, + 850, 850, 850, 881, 884, 883, 888, 1165, 947, 1165, + 924, 952, 860, 888, 868, 882, 924, 871, 1406, 874, + 856, 852, 861, 854, 857, 858, 869, 878, 855, 872, + 873, 1407, 876, 875, 882, 926, 877, 883, 927, 947, + + 880, 926, 929, 1408, 927, 881, 884, 885, 929, 885, + 885, 885, 885, 885, 885, 886, 952, 886, 886, 886, + 886, 886, 886, 930, 931, 932, 934, 935, 936, 930, + 931, 932, 934, 935, 936, 938, 939, 940, 941, 942, + 943, 938, 939, 940, 941, 942, 943, 944, 964, 950, + 949, 966, 965, 944, 946, 946, 946, 946, 946, 946, + 946, 946, 946, 946, 946, 946, 953, 954, 955, 956, + 963, 967, 968, 969, 970, 1059, 972, 964, 973, 974, + 975, 977, 966, 1050, 1051, 976, 946, 946, 946, 946, + 946, 946, 949, 950, 965, 1021, 981, 1076, 974, 1409, + + 977, 1021, 967, 981, 1076, 953, 954, 955, 972, 956, + 963, 1051, 1059, 973, 968, 975, 969, 976, 978, 970, + 978, 978, 978, 978, 978, 978, 979, 1050, 979, 979, + 979, 979, 979, 979, 1023, 1024, 1025, 1026, 1027, 1028, + 1023, 1024, 1025, 1026, 1027, 1028, 1030, 1031, 1032, 1033, + 1034, 1035, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, + 1038, 1039, 1041, 1042, 1036, 1037, 1038, 1039, 1041, 1042, + 1043, 1044, 1049, 1052, 1061, 1062, 1043, 1044, 1045, 1045, + 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, + 1047, 1060, 1054, 1061, 1063, 1066, 1067, 1060, 1064, 1068, + + 1052, 1069, 1070, 1049, 1071, 1072, 1167, 1163, 1410, 1178, + 1045, 1045, 1045, 1045, 1045, 1045, 1178, 1064, 1073, 1062, + 1073, 1073, 1073, 1073, 1073, 1073, 1121, 1067, 1411, 1412, + 1047, 1054, 1121, 1413, 1066, 1071, 1069, 1167, 1063, 1068, + 1072, 1074, 1163, 1074, 1074, 1074, 1074, 1074, 1074, 1123, + 1124, 1126, 1070, 1127, 1128, 1123, 1124, 1126, 1130, 1127, + 1128, 1131, 1132, 1133, 1130, 1134, 1135, 1131, 1132, 1133, + 1137, 1134, 1135, 1138, 1139, 1141, 1137, 1142, 1143, 1138, + 1139, 1141, 1144, 1142, 1143, 1145, 1146, 1147, 1144, 1150, + 1151, 1145, 1146, 1147, 1149, 1149, 1149, 1149, 1149, 1149, + + 1149, 1149, 1149, 1149, 1149, 1149, 1153, 1154, 1155, 1162, + 1166, 1169, 1170, 1171, 1168, 1172, 1173, 1174, 1175, 1376, + 1175, 1175, 1175, 1175, 1175, 1175, 1149, 1149, 1149, 1149, + 1149, 1149, 1168, 1151, 1150, 1176, 1414, 1176, 1176, 1176, + 1176, 1176, 1176, 1153, 1154, 1166, 1172, 1415, 1227, 1162, + 1229, 1170, 1155, 1169, 1227, 1230, 1229, 1376, 1173, 1232, + 1233, 1230, 1234, 1171, 1235, 1232, 1233, 1174, 1234, 1236, + 1235, 1237, 1238, 1239, 1241, 1236, 1242, 1237, 1238, 1239, + 1241, 1243, 1242, 1244, 1245, 1246, 1247, 1243, 1248, 1244, + 1245, 1246, 1247, 1249, 1248, 1250, 1251, 1253, 1254, 1249, + + 1255, 1250, 1251, 1253, 1254, 1256, 1255, 1258, 1259, 1262, + 1266, 1256, 1257, 1257, 1257, 1257, 1257, 1257, 1257, 1257, + 1257, 1257, 1257, 1257, 1260, 1261, 1263, 1260, 1261, 1267, + 1268, 1269, 1270, 1271, 1272, 1274, 1275, 1278, 1416, 1371, + 1258, 1417, 1418, 1262, 1257, 1257, 1257, 1257, 1257, 1257, + 1419, 1259, 1266, 1279, 1420, 1279, 1279, 1279, 1279, 1279, + 1279, 1263, 1282, 1421, 1422, 1272, 1336, 1275, 1278, 1282, + 1271, 1338, 1336, 1371, 1339, 1268, 1269, 1338, 1274, 1267, + 1339, 1280, 1270, 1280, 1280, 1280, 1280, 1280, 1280, 1341, + 1342, 1343, 1344, 1346, 1347, 1341, 1342, 1343, 1344, 1346, + + 1347, 1348, 1350, 1351, 1352, 1353, 1354, 1348, 1350, 1351, + 1352, 1353, 1354, 1355, 1356, 1358, 1359, 1360, 1362, 1355, + 1356, 1358, 1359, 1360, 1362, 1363, 1364, 1365, 1366, 1367, + 1368, 1363, 1364, 1365, 1366, 1367, 1368, 1370, 1370, 1370, + 1370, 1370, 1370, 1370, 1370, 1370, 1370, 1370, 1370, 1372, + 1373, 1374, 1380, 1381, 1382, 1384, 1383, 1385, 1389, 1392, + 1389, 1389, 1389, 1389, 1389, 1389, 1392, 1423, 1424, 1370, + 1370, 1370, 1370, 1370, 1370, 1425, 1372, 1373, 1374, 1426, + 1427, 1428, 1429, 1380, 1430, 1381, 1382, 1383, 1431, 1390, + 1384, 1390, 1390, 1390, 1390, 1390, 1390, 1432, 1433, 1434, + + 1385, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, + 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, + 1454, 1455, 1450, 1456, 1452, 1453, 1454, 1455, 1457, 1456, + 1458, 1459, 1460, 1461, 1457, 1462, 1463, 1459, 1460, 1461, + 1464, 1462, 1463, 1465, 1466, 1467, 1464, 1468, 1469, 1465, + 1466, 1467, 1470, 1468, 1471, 1472, 1473, 1474, 1470, 1475, + 1471, 1472, 1473, 1474, 1476, 1475, 1477, 1478, 1479, 1480, + 1476, 1481, 1477, 1478, 1479, 1480, 1482, 1483, 1484, 1485, + 1487, 1488, 1482, 1483, 1484, 1485, 1486, 1486, 1486, 1486, + 1486, 1486, 1486, 1486, 1486, 1486, 1486, 1486, 1489, 1490, + + 1491, 1492, 1493, 1494, 1495, 1496, 1498, 1499, 1503, 1504, + 1505, 1497, 1500, 1506, 1488, 1507, 1504, 1508, 1486, 1486, + 1486, 1486, 1486, 1486, 1497, 1509, 1510, 1489, 1490, 1511, + 1512, 1513, 1514, 1498, 1515, 1491, 1495, 1496, 1501, 1500, + 1501, 1501, 1501, 1501, 1501, 1501, 1502, 1516, 1502, 1502, + 1502, 1502, 1502, 1502, 1517, 1518, 1499, 1519, 1520, 1521, + 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, + 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, + 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, + 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, + + 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1565, + 1571, 1567, 1568, 1572, 1570, 1573, 1571, 1574, 1575, 1572, + 1576, 1577, 1578, 1574, 1575, 1579, 1576, 1577, 1578, 1580, + 1581, 1579, 1582, 1583, 1584, 1585, 1581, 1586, 1582, 1583, + 1587, 1585, 1588, 1586, 1589, 1590, 1587, 1591, 1588, 1592, + 1589, 1590, 1593, 1591, 1594, 1595, 1596, 1597, 1593, 1598, + 1594, 1595, 1599, 1597, 1600, 1598, 1601, 1602, 1599, 1603, + 1600, 1604, 1601, 1602, 1606, 1603, 1605, 1605, 1605, 1605, + 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1607, 1608, + 1609, 1610, 1611, 1612, 1613, 1617, 1616, 1620, 1622, 1614, + + 1615, 1623, 1624, 1625, 1620, 1606, 1626, 1627, 1605, 1605, + 1605, 1605, 1605, 1605, 1618, 1629, 1618, 1618, 1618, 1618, + 1618, 1618, 1607, 1608, 1612, 1613, 1614, 1630, 1615, 1621, + 1628, 1631, 1632, 1633, 1609, 1616, 1621, 1628, 1634, 1635, + 1636, 1637, 1619, 1617, 1619, 1619, 1619, 1619, 1619, 1619, + 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, + 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, + 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, + 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, + 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, + + 1688, 1689, 1684, 1690, 1686, 1687, 1691, 1689, 1692, 1690, + 1693, 1694, 1691, 1695, 1692, 1696, 1693, 1694, 1697, 1695, + 1698, 1696, 1699, 1700, 1701, 1702, 1698, 1703, 1699, 1700, + 1701, 1702, 1704, 1703, 1705, 1706, 1707, 1708, 1704, 1709, + 1705, 1706, 1707, 1708, 1710, 1711, 1712, 1713, 1714, 1715, + 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, + 1720, 1721, 1716, 1717, 1718, 1719, 1720, 1722, 1723, 1724, + 1725, 1728, 1727, 1722, 1723, 1724, 1725, 1726, 1726, 1726, + 1726, 1726, 1726, 1726, 1726, 1726, 1726, 1726, 1726, 1729, + 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1741, + + 1742, 1743, 1728, 1744, 1745, 1738, 1741, 1746, 1747, 1726, + 1726, 1726, 1726, 1726, 1726, 1727, 1748, 1749, 1750, 1751, + 1729, 1752, 1753, 1754, 1755, 1739, 1737, 1739, 1739, 1739, + 1739, 1739, 1739, 1736, 1756, 1733, 1734, 1757, 1758, 1759, + 1760, 1761, 1740, 1735, 1740, 1740, 1740, 1740, 1740, 1740, + 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, + 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, + 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, + 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, + 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1805, + + 1811, 1807, 1808, 1809, 1810, 1812, 1811, 1813, 1814, 1815, + 1816, 1817, 1818, 1813, 1814, 1815, 1819, 1817, 1818, 1820, + 1821, 1822, 1819, 1823, 1824, 1820, 1821, 1822, 1825, 1823, + 1826, 1827, 1828, 1829, 1825, 1830, 1826, 1827, 1831, 1829, + 1832, 1830, 1833, 1834, 1831, 1835, 1832, 1836, 1833, 1834, + 1837, 1835, 1838, 1839, 1840, 1841, 1837, 1842, 1838, 1839, + 1843, 1841, 1844, 1842, 1845, 1846, 1843, 1847, 1844, 1848, + 1845, 1846, 1850, 1847, 1849, 1849, 1849, 1849, 1849, 1849, + 1849, 1849, 1849, 1849, 1849, 1849, 1851, 1852, 1853, 1854, + 1855, 1856, 1857, 1858, 1859, 1860, 1863, 1864, 1861, 1857, + + 1861, 1861, 1861, 1861, 1861, 1861, 1849, 1849, 1849, 1849, + 1849, 1849, 1862, 1865, 1862, 1862, 1862, 1862, 1862, 1862, + 1866, 1867, 1868, 1869, 1858, 1870, 1871, 1872, 1873, 1874, + 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1860, 1882, 1883, + 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, + 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, + 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, + 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, + 1924, 1925, 1926, 1927, 1928, 1929, 1924, 1925, 1926, 1927, + 1930, 1929, 1931, 1932, 1933, 1934, 1930, 1935, 1931, 1932, + + 1933, 1934, 1936, 1935, 1937, 1938, 1939, 1940, 1936, 1941, + 1937, 1938, 1942, 1940, 1943, 1941, 1944, 1945, 1942, 1946, + 1943, 1947, 1944, 1945, 1948, 1946, 1949, 1947, 1950, 1951, + 1948, 1952, 1949, 1953, 1950, 1954, 1955, 1952, 1956, 1953, + 1957, 1954, 1955, 1958, 1956, 1959, 1957, 1960, 1961, 1958, + 1962, 1959, 1963, 1960, 1961, 1964, 1962, 1965, 1966, 1967, + 1969, 1964, 1970, 1965, 1966, 1967, 1968, 1968, 1968, 1968, + 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1971, 1972, + 1974, 1973, 1974, 1974, 1974, 1974, 1974, 1974, 1975, 1976, + 1975, 1975, 1975, 1975, 1975, 1975, 1977, 1978, 1968, 1968, + + 1968, 1968, 1968, 1968, 1979, 1980, 1981, 1982, 1983, 1984, + 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1971, 1973, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, + 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, + 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, + 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, + 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2034, 2035, 2036, + 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, + 2041, 2042, 2043, 2047, 2045, 2046, 2048, 2049, 2050, 2047, + 2051, 2052, 2048, 2049, 2050, 2053, 2051, 2054, 2055, 2056, + + 2057, 2053, 2058, 2054, 2055, 2059, 2057, 2060, 2058, 2061, + 2062, 2059, 2063, 2060, 2064, 2061, 2062, 2065, 2063, 2066, + 2067, 2068, 2069, 2065, 2070, 2066, 2067, 2071, 2069, 2072, + 2070, 2073, 2074, 2071, 2075, 2072, 2076, 2073, 2074, 2078, + 2075, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, + 2077, 2077, 2077, 2079, 2080, 2081, 2082, 2084, 2082, 2082, + 2082, 2082, 2082, 2082, 2083, 2085, 2083, 2083, 2083, 2083, + 2083, 2083, 2086, 2077, 2077, 2077, 2077, 2077, 2077, 2087, + 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, + 2098, 2099, 2100, 2101, 2080, 2102, 2103, 2104, 2105, 2106, + + 2107, 2108, 2081, 2109, 2110, 2111, 2112, 2113, 2114, 2115, + 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, + 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, + 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2138, 2139, + 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, + 2144, 2145, 2146, 2147, 2150, 2149, 2151, 2152, 2153, 2154, + 2150, 2155, 2151, 2152, 2153, 2154, 2156, 2155, 2157, 2158, + 2159, 2160, 2156, 2161, 2157, 2158, 2159, 2162, 2163, 2161, + 2164, 2165, 2166, 2162, 2163, 2167, 2164, 2165, 2166, 2168, + 2169, 2167, 2170, 2171, 2172, 2168, 2169, 2173, 2170, 2171, + + 2174, 2175, 2176, 2173, 2178, 2179, 2174, 2175, 2176, 2177, + 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, + 2177, 2180, 2181, 2182, 2184, 2182, 2182, 2182, 2182, 2182, + 2182, 2183, 2185, 2183, 2183, 2183, 2183, 2183, 2183, 2186, + 2187, 2177, 2177, 2177, 2177, 2177, 2177, 2188, 2189, 2190, + 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, + 2201, 2181, 2202, 2203, 2204, 2205, 2181, 2206, 2180, 2207, + 2203, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, + 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, + 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, + + 2237, 2232, 2233, 2234, 2238, 2236, 2237, 2239, 2240, 2241, + 2238, 2242, 2243, 2239, 2240, 2241, 2244, 2242, 2243, 2245, + 2246, 2247, 2248, 2249, 2250, 2245, 2246, 2247, 2251, 2249, + 2250, 2252, 2253, 2254, 2251, 2255, 2256, 2252, 2253, 2254, + 2257, 2255, 2258, 2259, 2260, 2261, 2257, 2262, 2258, 2259, + 2263, 2261, 2264, 2262, 2265, 2266, 2263, 2267, 2264, 2268, + 2265, 2266, 2272, 2267, 2269, 2269, 2269, 2269, 2269, 2269, + 2269, 2269, 2269, 2269, 2269, 2269, 2273, 2274, 2275, 2277, + 2275, 2275, 2275, 2275, 2275, 2275, 2276, 2278, 2276, 2276, + 2276, 2276, 2276, 2276, 2279, 2280, 2269, 2269, 2269, 2269, + + 2269, 2269, 2281, 2282, 2283, 2284, 2272, 2285, 2286, 2287, + 2288, 2274, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, + 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, + 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, + 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2319, 2320, + 2321, 2322, 2323, 2325, 2326, 2327, 2328, 2329, 2330, 2325, + 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, + 2336, 2331, 2332, 2333, 2334, 2335, 2337, 2338, 2339, 2340, + 2341, 2342, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, + 2345, 2346, 2347, 2348, 2343, 2344, 2345, 2346, 2347, 2349, + + 2350, 2351, 2352, 2354, 2355, 2349, 2350, 2351, 2352, 2353, + 2353, 2353, 2353, 2353, 2353, 2353, 2353, 2353, 2353, 2353, + 2353, 2356, 2358, 2356, 2356, 2356, 2356, 2356, 2356, 2357, + 2359, 2357, 2357, 2357, 2357, 2357, 2357, 2354, 2360, 2361, + 2362, 2353, 2353, 2353, 2353, 2353, 2353, 2363, 2364, 2365, + 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, + 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, + 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, + 2396, 2397, 2398, 2399, 2400, 2395, 2396, 2397, 2398, 2399, + 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2402, 2403, + + 2404, 2408, 2406, 2407, 2409, 2410, 2411, 2408, 2412, 2413, + 2409, 2410, 2411, 2414, 2412, 2415, 2416, 2417, 2418, 2414, + 2419, 2415, 2416, 2420, 2418, 2421, 2419, 2422, 2423, 2420, + 2424, 2421, 2425, 2422, 2423, 2427, 2424, 2426, 2426, 2426, + 2426, 2426, 2426, 2426, 2426, 2426, 2426, 2426, 2426, 2428, + 2430, 2428, 2428, 2428, 2428, 2428, 2428, 2429, 2431, 2429, + 2429, 2429, 2429, 2429, 2429, 2432, 2433, 2434, 2435, 2426, + 2426, 2426, 2426, 2426, 2426, 2436, 2437, 2438, 2439, 2440, + 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, + 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, + + 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2462, 2463, 2464, + 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2468, + 2469, 2470, 2471, 2474, 2473, 2475, 2476, 2477, 2478, 2474, + 2479, 2475, 2476, 2477, 2478, 2480, 2479, 2481, 2482, 2483, + 2484, 2480, 2485, 2481, 2482, 2483, 2486, 2487, 2485, 2488, + 2492, 2493, 2486, 2487, 2494, 2488, 2489, 2489, 2489, 2489, + 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2490, 2495, + 2490, 2490, 2490, 2490, 2490, 2490, 2491, 2496, 2491, 2491, + 2491, 2491, 2491, 2491, 2497, 2498, 2499, 2500, 2489, 2489, + 2489, 2489, 2489, 2489, 2501, 2502, 2503, 2504, 2505, 2506, + + 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, + 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2518, 2519, 2520, + 2524, 2522, 2523, 2525, 2526, 2527, 2524, 2528, 2529, 2525, + 2526, 2527, 2530, 2528, 2529, 2531, 2532, 2533, 2534, 2535, + 2536, 2531, 2532, 2533, 2537, 2535, 2536, 2538, 2539, 2540, + 2537, 2541, 2542, 2538, 2539, 2540, 2546, 2541, 2543, 2543, + 2543, 2543, 2543, 2543, 2543, 2543, 2543, 2543, 2543, 2543, + 2544, 2547, 2544, 2544, 2544, 2544, 2544, 2544, 2545, 2548, + 2545, 2545, 2545, 2545, 2545, 2545, 2549, 2550, 2551, 2552, + 2543, 2543, 2543, 2543, 2543, 2543, 2553, 2554, 2555, 2556, + + 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, + 2567, 2568, 2569, 2570, 2571, 2572, 2567, 2568, 2569, 2570, + 2571, 2573, 2574, 2575, 2576, 2577, 2578, 2573, 2574, 2575, + 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2579, + 2580, 2581, 2582, 2583, 2585, 2586, 2587, 2588, 2592, 2593, + 2585, 2586, 2587, 2588, 2589, 2589, 2589, 2589, 2589, 2589, + 2589, 2589, 2589, 2589, 2589, 2589, 2590, 2594, 2590, 2590, + 2590, 2590, 2590, 2590, 2591, 2595, 2591, 2591, 2591, 2591, + 2591, 2591, 2596, 2597, 2598, 2599, 2589, 2589, 2589, 2589, + 2589, 2589, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, + + 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2609, 2610, 2611, + 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, + 2616, 2617, 2618, 2622, 2620, 2621, 2623, 2624, 2625, 2622, + 2626, 2627, 2623, 2624, 2625, 2631, 2626, 2628, 2628, 2628, + 2628, 2628, 2628, 2628, 2628, 2628, 2628, 2628, 2628, 2629, + 2632, 2629, 2629, 2629, 2629, 2629, 2629, 2630, 2633, 2630, + 2630, 2630, 2630, 2630, 2630, 2634, 2635, 2636, 2637, 2628, + 2628, 2628, 2628, 2628, 2628, 2638, 2639, 2640, 2641, 2642, + 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2644, 2645, 2646, + 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2650, + + 2651, 2652, 2653, 2656, 2655, 2657, 2658, 2662, 2663, 2656, + 2664, 2657, 2658, 2659, 2659, 2659, 2659, 2659, 2659, 2659, + 2659, 2659, 2659, 2659, 2659, 2660, 2665, 2660, 2660, 2660, + 2660, 2660, 2660, 2661, 2666, 2661, 2661, 2661, 2661, 2661, + 2661, 2667, 2668, 2669, 2670, 2659, 2659, 2659, 2659, 2659, + 2659, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2672, 2673, + 2674, 2678, 2676, 2677, 2679, 2680, 2681, 2678, 2682, 2683, + 2679, 2680, 2681, 2684, 2682, 2683, 2685, 2685, 2685, 2685, + 2685, 2688, 2685, 2685, 2685, 2685, 2685, 2685, 2686, 2689, + 2686, 2686, 2686, 2686, 2686, 2686, 2687, 2690, 2687, 2687, + + 2687, 2687, 2687, 2687, 2691, 2692, 2693, 2694, 2685, 2685, + 2685, 2685, 2685, 2685, 2695, 2696, 2697, 2698, 2699, 2700, + 2695, 2696, 2697, 2698, 2699, 2701, 2702, 2703, 2704, 2708, + 2709, 2701, 2702, 2703, 2704, 2705, 2705, 2705, 2705, 2705, + 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2706, 2710, 2706, + 2706, 2706, 2706, 2706, 2706, 2707, 2711, 2707, 2707, 2707, + 2707, 2707, 2707, 2712, 2714, 2721, 2725, 2705, 2705, 2705, + 2705, 2705, 2705, 2713, 2713, 2713, 2713, 2713, 2715, 2716, + 2717, 2718, 2719, 2720, 2715, 2716, 2717, 2718, 2719, 2720, + 2722, 2722, 2722, 2722, 2722, 2726, 2722, 2722, 2722, 2722, + + 2722, 2722, 2723, 2729, 2723, 2723, 2723, 2723, 2723, 2723, + 2724, 2737, 2724, 2724, 2724, 2724, 2724, 2724, 2738, 1328, + 1327, 1326, 2722, 2722, 2722, 2722, 2722, 2722, 2727, 2727, + 2727, 2727, 2727, 2728, 2728, 2728, 2728, 2728, 2730, 2731, + 2732, 2733, 1325, 1324, 2730, 2731, 2732, 2733, 2734, 2734, + 2734, 2734, 2734, 1323, 2734, 2734, 2734, 2734, 2734, 2734, + 2735, 1322, 2735, 2735, 2735, 2735, 2735, 2735, 2736, 1321, + 2736, 2736, 2736, 2736, 2736, 2736, 1320, 1319, 1318, 1317, + 2734, 2734, 2734, 2734, 2734, 2734, 2739, 2740, 1316, 1315, + 1314, 1313, 2739, 2740, 2741, 2741, 2741, 2741, 2741, 1312, + + 2741, 2741, 2741, 2741, 2741, 2741, 2742, 1311, 2742, 2742, + 2742, 2742, 2742, 2742, 2743, 1310, 2743, 2743, 2743, 2743, + 2743, 2743, 1309, 1308, 1307, 1306, 2741, 2741, 2741, 2741, + 2741, 2741, 2744, 1305, 1304, 1303, 1302, 1301, 2744, 2745, + 2745, 2745, 2745, 2745, 2745, 2745, 2745, 2745, 2745, 2745, + 2745, 2746, 1300, 2746, 2746, 2746, 2746, 2746, 2746, 2747, + 1299, 2747, 2747, 2747, 2747, 2747, 2747, 1298, 1297, 1296, + 1295, 2745, 2745, 2745, 2745, 2745, 2745, 2748, 2748, 2748, + 2748, 2748, 1294, 2748, 2748, 2748, 2748, 2748, 2748, 2749, + 1293, 2749, 2749, 2749, 2749, 2749, 2749, 2750, 1292, 2750, + + 2750, 2750, 2750, 2750, 2750, 1291, 1290, 1289, 1288, 2748, + 2748, 2748, 2748, 2748, 2748, 2751, 2751, 2751, 2751, 2751, + 1287, 2751, 2751, 2751, 2751, 2751, 2751, 2752, 1286, 2752, + 2752, 2752, 2752, 2752, 2752, 2753, 1285, 2753, 2753, 2753, + 2753, 2753, 2753, 1284, 1283, 1281, 1277, 2751, 2751, 2751, + 2751, 2751, 2751, 2754, 2754, 2754, 2754, 2754, 1276, 2754, + 2754, 2754, 2754, 2754, 2754, 2755, 1273, 2755, 2755, 2755, + 2755, 2755, 2755, 2756, 1265, 2756, 2756, 2756, 2756, 2756, + 2756, 1264, 1252, 1240, 1231, 2754, 2754, 2754, 2754, 2754, + 2754, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2757, + + 2757, 2757, 2757, 2758, 1228, 2758, 2758, 2758, 2758, 2758, + 2758, 2759, 1226, 2759, 2759, 2759, 2759, 2759, 2759, 1225, + 1224, 1223, 1222, 2757, 2757, 2757, 2757, 2757, 2757, 2760, + 2760, 2760, 2760, 2760, 1221, 2760, 2760, 2760, 2760, 2760, + 2760, 2761, 1220, 2761, 2761, 2761, 2761, 2761, 2761, 2762, + 1219, 2762, 2762, 2762, 2762, 2762, 2762, 1218, 1217, 1216, + 1215, 2760, 2760, 2760, 2760, 2760, 2760, 2763, 2763, 2763, + 2763, 2763, 1214, 2763, 2763, 2763, 2763, 2763, 2763, 2764, + 1213, 2764, 2764, 2764, 2764, 2764, 2764, 2765, 1212, 2765, + 2765, 2765, 2765, 2765, 2765, 1211, 1210, 1209, 1208, 2763, + + 2763, 2763, 2763, 2763, 2763, 2766, 2766, 2766, 2766, 2766, + 1207, 2766, 2766, 2766, 2766, 2766, 2766, 2767, 1206, 2767, + 2767, 2767, 2767, 2767, 2767, 2768, 1205, 2768, 2768, 2768, + 2768, 2768, 2768, 1204, 1203, 1202, 1201, 2766, 2766, 2766, + 2766, 2766, 2766, 2769, 2769, 2769, 2769, 2769, 2769, 2769, + 2769, 2769, 2769, 2769, 2769, 2770, 1200, 2770, 2770, 2770, + 2770, 2770, 2770, 2771, 1199, 2771, 2771, 2771, 2771, 2771, + 2771, 1198, 1197, 1196, 1195, 2769, 2769, 2769, 2769, 2769, + 2769, 2772, 2772, 2772, 2772, 2772, 1194, 2772, 2772, 2772, + 2772, 2772, 2772, 2773, 1193, 2773, 2773, 2773, 2773, 2773, + + 2773, 2774, 1192, 2774, 2774, 2774, 2774, 2774, 2774, 1191, + 1190, 1189, 1188, 2772, 2772, 2772, 2772, 2772, 2772, 2775, + 2775, 2775, 2775, 2775, 1187, 2775, 2775, 2775, 2775, 2775, + 2775, 2776, 1186, 2776, 2776, 2776, 2776, 2776, 2776, 2777, + 1185, 2777, 2777, 2777, 2777, 2777, 2777, 1184, 1183, 1182, + 1181, 2775, 2775, 2775, 2775, 2775, 2775, 2778, 2778, 2778, + 2778, 2778, 1180, 2778, 2778, 2778, 2778, 2778, 2778, 2779, + 1179, 2779, 2779, 2779, 2779, 2779, 2779, 2780, 1177, 2780, + 2780, 2780, 2780, 2780, 2780, 1161, 1159, 1157, 1152, 2778, + 2778, 2778, 2778, 2778, 2778, 2781, 2781, 2781, 2781, 2781, + + 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2782, 1148, 2782, + 2782, 2782, 2782, 2782, 2782, 2783, 1140, 2783, 2783, 2783, + 2783, 2783, 2783, 1136, 1129, 1125, 1122, 2781, 2781, 2781, + 2781, 2781, 2781, 2784, 2784, 2784, 2784, 2784, 1120, 2784, + 2784, 2784, 2784, 2784, 2784, 2785, 1119, 2785, 2785, 2785, + 2785, 2785, 2785, 2786, 1118, 2786, 2786, 2786, 2786, 2786, + 2786, 1117, 1116, 1115, 1114, 2784, 2784, 2784, 2784, 2784, + 2784, 2787, 2787, 2787, 2787, 2787, 1113, 2787, 2787, 2787, + 2787, 2787, 2787, 2788, 1112, 2788, 2788, 2788, 2788, 2788, + 2788, 2789, 1111, 2789, 2789, 2789, 2789, 2789, 2789, 1110, + + 1109, 1108, 1107, 2787, 2787, 2787, 2787, 2787, 2787, 2790, + 2790, 2790, 2790, 2790, 1106, 2790, 2790, 2790, 2790, 2790, + 2790, 2791, 1105, 2791, 2791, 2791, 2791, 2791, 2791, 2792, + 1104, 2792, 2792, 2792, 2792, 2792, 2792, 1103, 1102, 1101, + 1100, 2790, 2790, 2790, 2790, 2790, 2790, 2793, 2793, 2793, + 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2794, + 1099, 2794, 2794, 2794, 2794, 2794, 2794, 2795, 1098, 2795, + 2795, 2795, 2795, 2795, 2795, 1097, 1096, 1095, 1094, 2793, + 2793, 2793, 2793, 2793, 2793, 2796, 2796, 2796, 2796, 2796, + 1093, 2796, 2796, 2796, 2796, 2796, 2796, 2797, 1092, 2797, + + 2797, 2797, 2797, 2797, 2797, 2798, 1091, 2798, 2798, 2798, + 2798, 2798, 2798, 1090, 1089, 1088, 1087, 2796, 2796, 2796, + 2796, 2796, 2796, 2799, 2799, 2799, 2799, 2799, 1086, 2799, + 2799, 2799, 2799, 2799, 2799, 2800, 1085, 2800, 2800, 2800, + 2800, 2800, 2800, 2801, 1084, 2801, 2801, 2801, 2801, 2801, + 2801, 1083, 1082, 1081, 1080, 2799, 2799, 2799, 2799, 2799, + 2799, 2802, 2802, 2802, 2802, 2802, 1079, 2802, 2802, 2802, + 2802, 2802, 2802, 2803, 1078, 2803, 2803, 2803, 2803, 2803, + 2803, 2804, 1077, 2804, 2804, 2804, 2804, 2804, 2804, 1075, + 1058, 1057, 1056, 2802, 2802, 2802, 2802, 2802, 2802, 2805, + + 2805, 2805, 2805, 2805, 2805, 2805, 2805, 2805, 2805, 2805, + 2805, 2806, 1055, 2806, 2806, 2806, 2806, 2806, 2806, 2807, + 1048, 2807, 2807, 2807, 2807, 2807, 2807, 1046, 1040, 1029, + 1022, 2805, 2805, 2805, 2805, 2805, 2805, 2808, 2808, 2808, + 2808, 2808, 1020, 2808, 2808, 2808, 2808, 2808, 2808, 2809, + 1019, 2809, 2809, 2809, 2809, 2809, 2809, 2810, 1018, 2810, + 2810, 2810, 2810, 2810, 2810, 1017, 1016, 1015, 1014, 2808, + 2808, 2808, 2808, 2808, 2808, 2811, 2811, 2811, 2811, 2811, + 1013, 2811, 2811, 2811, 2811, 2811, 2811, 2812, 1012, 2812, + 2812, 2812, 2812, 2812, 2812, 2813, 1011, 2813, 2813, 2813, + + 2813, 2813, 2813, 1010, 1009, 1008, 1007, 2811, 2811, 2811, + 2811, 2811, 2811, 2814, 2814, 2814, 2814, 2814, 1006, 2814, + 2814, 2814, 2814, 2814, 2814, 2815, 1005, 2815, 2815, 2815, + 2815, 2815, 2815, 2816, 1004, 2816, 2816, 2816, 2816, 2816, + 2816, 1003, 1002, 1001, 1000, 2814, 2814, 2814, 2814, 2814, + 2814, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, + 2817, 2817, 2817, 2818, 999, 2818, 2818, 2818, 2818, 2818, + 2818, 2819, 998, 2819, 2819, 2819, 2819, 2819, 2819, 997, + 996, 995, 994, 2817, 2817, 2817, 2817, 2817, 2817, 2820, + 2820, 2820, 2820, 2820, 993, 2820, 2820, 2820, 2820, 2820, + + 2820, 2821, 992, 2821, 2821, 2821, 2821, 2821, 2821, 2822, + 991, 2822, 2822, 2822, 2822, 2822, 2822, 990, 989, 988, + 987, 2820, 2820, 2820, 2820, 2820, 2820, 2823, 2823, 2823, + 2823, 2823, 986, 2823, 2823, 2823, 2823, 2823, 2823, 2824, + 985, 2824, 2824, 2824, 2824, 2824, 2824, 2825, 984, 2825, + 2825, 2825, 2825, 2825, 2825, 983, 982, 980, 971, 2823, + 2823, 2823, 2823, 2823, 2823, 2826, 2826, 2826, 2826, 2826, + 962, 2826, 2826, 2826, 2826, 2826, 2826, 2827, 960, 2827, + 2827, 2827, 2827, 2827, 2828, 959, 2828, 2828, 2828, 2828, + 2828, 957, 948, 945, 937, 933, 928, 2826, 2826, 2826, + + 2826, 2826, 2826, 2830, 2830, 2830, 2830, 2830, 2830, 2830, + 2830, 2831, 925, 2831, 2831, 2831, 2831, 2831, 2831, 2832, + 923, 2832, 2832, 2833, 922, 2833, 2833, 2833, 2833, 2834, + 921, 2834, 2834, 2835, 2835, 2836, 2836, 2837, 920, 2837, + 2837, 2838, 2838, 2839, 2839, 2840, 2840, 2840, 2841, 919, + 2841, 2841, 2842, 2842, 2843, 2843, 2844, 2844, 2845, 2845, + 2846, 2846, 2846, 2847, 2847, 2848, 918, 2848, 2848, 2849, + 2849, 2850, 2850, 2851, 2851, 2852, 2852, 2853, 2853, 2854, + 2854, 2855, 2855, 2855, 2856, 2856, 2857, 2857, 2857, 2858, + 917, 2858, 2858, 2859, 2859, 2860, 2860, 2861, 2861, 2862, + + 2862, 2863, 2863, 2864, 2864, 2865, 2865, 2866, 2866, 2867, + 2867, 2868, 2868, 2868, 2869, 2869, 2870, 2870, 2870, 2871, + 2871, 2871, 2872, 2872, 2873, 916, 2873, 2873, 2874, 2874, + 2875, 2875, 2876, 2876, 2877, 2877, 2878, 2878, 2879, 2879, + 2880, 2880, 2881, 2881, 2882, 2882, 2883, 2883, 2884, 2884, + 2885, 2885, 2886, 2886, 2886, 2887, 2887, 2888, 2888, 2888, + 2889, 2889, 2889, 2890, 2890, 2891, 2891, 2891, 2892, 2892, + 2892, 2893, 915, 2893, 2893, 2894, 2894, 2895, 2895, 2896, + 2896, 2897, 2897, 2898, 2898, 2899, 2899, 2900, 2900, 2901, + 2901, 2902, 2902, 2903, 2903, 2904, 2904, 2905, 2905, 2906, + + 2906, 2907, 2907, 2908, 2908, 2909, 2909, 2910, 2910, 2911, + 2911, 2911, 2912, 2912, 2913, 2913, 2913, 2914, 2914, 2914, + 2915, 2915, 2916, 2916, 2916, 2917, 2917, 2917, 2918, 2918, + 2918, 2919, 2919, 2919, 2920, 2920, 2921, 914, 2921, 2921, + 2921, 2922, 913, 2922, 2922, 2923, 2923, 2924, 2924, 2925, + 2925, 2926, 2926, 2927, 2927, 2928, 2928, 2929, 2929, 2930, + 2930, 2931, 2931, 2932, 2932, 2933, 2933, 2934, 2934, 2935, + 2935, 2936, 2936, 2937, 2937, 2938, 2938, 2939, 2939, 2940, + 2940, 2941, 2941, 2942, 2942, 2943, 2943, 2944, 2944, 2944, + 2945, 2945, 2946, 2946, 2946, 2947, 2947, 2947, 2948, 2948, + + 2948, 2949, 2949, 2949, 2950, 2950, 2950, 2951, 2951, 2951, + 2952, 2952, 2953, 2953, 2953, 2954, 2954, 2954, 2955, 2955, + 2955, 2956, 912, 2956, 2956, 2956, 2957, 911, 2957, 2957, + 2958, 2958, 2959, 2959, 2960, 2960, 2961, 2961, 2962, 2962, + 2963, 2963, 2964, 2964, 2965, 2965, 2966, 2966, 2967, 2967, + 2968, 2968, 2969, 2969, 2970, 2970, 2971, 2971, 2972, 2972, + 2973, 2973, 2974, 2974, 2975, 2975, 2976, 2976, 2977, 2977, + 2978, 2978, 2979, 2979, 2980, 2980, 2981, 2981, 2982, 2982, + 2983, 2983, 2984, 2984, 2984, 2985, 2985, 2986, 2986, 2986, + 2987, 2987, 2987, 2988, 2988, 2989, 2989, 2989, 2990, 2990, + + 2990, 2991, 2991, 2991, 2992, 2992, 2993, 2993, 2993, 2994, + 2994, 2994, 2995, 2995, 2995, 2996, 2996, 2996, 2997, 2997, + 2997, 2998, 2998, 2998, 2999, 2999, 3000, 910, 3000, 3000, + 3000, 3001, 909, 3001, 3001, 3002, 3002, 3003, 3003, 3004, + 3004, 3005, 3005, 3006, 3006, 3007, 3007, 3008, 3008, 3009, + 3009, 3010, 3010, 3011, 3011, 3012, 3012, 3013, 3013, 3014, + 3014, 3015, 3015, 3016, 3016, 3017, 3017, 3018, 3018, 3019, + 3019, 3020, 3020, 3021, 3021, 3022, 3022, 3023, 3023, 3024, + 3024, 3025, 3025, 3026, 3026, 3027, 3027, 3028, 3028, 3029, + 3029, 3030, 3030, 3031, 3031, 3031, 3032, 3032, 3033, 3033, + + 3033, 3034, 3034, 3034, 3035, 3035, 3036, 3036, 3036, 3037, + 3037, 3037, 3038, 3038, 3038, 3039, 3039, 3039, 3040, 3040, + 3040, 3041, 3041, 3041, 3042, 3042, 3042, 3043, 3043, 3043, + 3044, 3044, 3045, 3045, 3045, 3046, 3046, 3046, 3047, 3047, + 3047, 3048, 908, 3048, 3048, 3048, 3049, 907, 3049, 3049, + 3050, 3050, 3051, 3051, 3052, 3052, 3053, 3053, 3054, 3054, + 3055, 3055, 3056, 3056, 3057, 3057, 3058, 3058, 3059, 3059, + 3060, 3060, 3061, 3061, 3062, 3062, 3063, 3063, 3064, 3064, + 3065, 3065, 3066, 3066, 3067, 3067, 3068, 3068, 3069, 3069, + 3070, 3070, 3071, 3071, 3072, 3072, 3073, 3073, 3074, 3074, + + 3075, 3075, 3076, 3076, 3077, 3077, 3078, 3078, 3079, 3079, + 3080, 3080, 3081, 3081, 3082, 3082, 3083, 3083, 3084, 3084, + 3085, 3085, 3085, 3086, 3086, 3087, 3087, 3087, 3088, 3088, + 3088, 3089, 3089, 3090, 3090, 3090, 3091, 3091, 3091, 3092, + 3092, 3092, 3093, 3093, 3093, 3094, 3094, 3095, 3095, 3095, + 3096, 3096, 3096, 3097, 3097, 3097, 3098, 3098, 3099, 3099, + 3099, 3100, 3100, 3100, 3101, 3101, 3101, 3102, 3102, 3102, + 3103, 3103, 3103, 3104, 3104, 3104, 3105, 3105, 3106, 906, + 3106, 3106, 3106, 3107, 905, 3107, 3107, 3108, 3108, 3109, + 3109, 3110, 3110, 3111, 3111, 3112, 3112, 3113, 3113, 3114, + + 3114, 3115, 3115, 3116, 3116, 3117, 3117, 3118, 3118, 3119, + 3119, 3120, 3120, 3121, 3121, 3122, 3122, 3123, 3123, 3124, + 3124, 3125, 3125, 3126, 3126, 3127, 3127, 3128, 3128, 3129, + 3129, 3130, 3130, 3131, 3131, 3132, 3132, 3133, 3133, 3134, + 3134, 3135, 3135, 3136, 3136, 3137, 3137, 3138, 3138, 3139, + 3139, 3140, 3140, 3141, 3141, 3142, 3142, 3143, 3143, 3144, + 3144, 3145, 3145, 3145, 3146, 3146, 3147, 3147, 3147, 3148, + 3148, 3148, 3149, 3149, 3149, 3150, 3150, 3150, 3151, 3151, + 3151, 3152, 3152, 3152, 3153, 3153, 3154, 3154, 3154, 3155, + 3155, 3155, 3156, 3156, 3156, 3157, 3157, 3157, 3158, 3158, + + 3158, 3159, 3159, 3159, 3160, 3160, 3160, 3161, 3161, 3161, + 3162, 3162, 3162, 3163, 3163, 3164, 3164, 3164, 3165, 3165, + 3165, 3166, 3166, 3166, 3167, 904, 3167, 3167, 3167, 3168, + 903, 3168, 3168, 3169, 3169, 3170, 3170, 3171, 3171, 3172, + 3172, 3173, 3173, 3174, 3174, 3175, 3175, 3176, 3176, 3177, + 3177, 3178, 3178, 3179, 3179, 3180, 3180, 3181, 3181, 3182, + 3182, 3183, 3183, 3184, 3184, 3185, 3185, 3186, 3186, 3187, + 3187, 3188, 3188, 3189, 3189, 3190, 3190, 3191, 3191, 3192, + 3192, 3193, 3193, 3194, 3194, 3195, 3195, 3196, 3196, 3197, + 3197, 3198, 3198, 3199, 3199, 3200, 3200, 3201, 3201, 3202, + + 3202, 3203, 3203, 3204, 3204, 3205, 3205, 3206, 3206, 3207, + 3207, 3208, 3208, 3209, 3209, 3210, 3210, 3211, 3211, 3212, + 3212, 3212, 3213, 3213, 3214, 3214, 3214, 3215, 3215, 3215, + 3216, 3216, 3217, 3217, 3217, 3218, 3218, 3218, 3219, 3219, + 3219, 3220, 3220, 3221, 3221, 3221, 3222, 3222, 3222, 3223, + 3223, 3223, 3224, 3224, 3224, 3225, 3225, 3225, 3226, 3226, + 3226, 3227, 3227, 3228, 3228, 3228, 3229, 3229, 3229, 3230, + 3230, 3230, 3231, 3231, 3232, 3232, 3232, 3233, 3233, 3233, + 3234, 3234, 3234, 3235, 3235, 3235, 3236, 3236, 3236, 3237, + 3237, 3237, 3238, 3238, 3239, 902, 3239, 3239, 3239, 3240, + + 901, 3240, 3240, 3241, 3241, 3242, 3242, 3243, 3243, 3244, + 3244, 3245, 3245, 3246, 3246, 3247, 3247, 3248, 3248, 3249, + 3249, 3250, 3250, 3251, 3251, 3252, 3252, 3253, 3253, 3254, + 3254, 3255, 3255, 3256, 3256, 3257, 3257, 3258, 3258, 3259, + 3259, 3260, 3260, 3261, 3261, 3262, 3262, 3263, 3263, 3264, + 3264, 3265, 3265, 3266, 3266, 3267, 3267, 3268, 3268, 3269, + 3269, 3270, 3270, 3271, 3271, 3272, 3272, 3273, 3273, 3274, + 3274, 3275, 3275, 3276, 3276, 3277, 3277, 3278, 3278, 3279, + 3279, 3280, 3280, 3281, 3281, 3282, 3282, 3283, 3283, 3284, + 3284, 3285, 3285, 3286, 3286, 3286, 3287, 3287, 3288, 3288, + + 3288, 3289, 3289, 3289, 3290, 3290, 3291, 3291, 3291, 3292, + 3292, 3292, 3293, 3293, 3293, 3294, 3294, 3294, 3295, 3295, + 3295, 3296, 3296, 3296, 3297, 3297, 3297, 3298, 3298, 3298, + 3299, 3299, 3300, 3300, 3300, 3301, 3301, 3301, 3302, 3302, + 3302, 3303, 3303, 3303, 3304, 3304, 3304, 3305, 3305, 3305, + 3306, 3306, 3306, 3307, 3307, 3307, 3308, 3308, 3308, 3309, + 3309, 3310, 3310, 3310, 3311, 3311, 3311, 3312, 3312, 3312, + 3313, 900, 3313, 3313, 3313, 3314, 899, 3314, 3314, 3315, + 3315, 3316, 3316, 3317, 3317, 3318, 3318, 3319, 3319, 3320, + 3320, 3321, 3321, 3322, 3322, 3323, 3323, 3324, 3324, 3325, + + 3325, 3326, 3326, 3327, 3327, 3328, 3328, 3329, 3329, 3330, + 3330, 3331, 3331, 3332, 3332, 3333, 3333, 3334, 3334, 3335, + 3335, 3336, 3336, 3337, 3337, 3338, 3338, 3339, 3339, 3340, + 3340, 3341, 3341, 3342, 3342, 3343, 3343, 3344, 3344, 3345, + 3345, 3346, 3346, 3347, 3347, 3348, 3348, 3349, 3349, 3350, + 3350, 3351, 3351, 3352, 3352, 3353, 3353, 3354, 3354, 3355, + 3355, 3356, 3356, 3357, 3357, 3358, 3358, 3359, 3359, 3360, + 3360, 3361, 3361, 3362, 3362, 3363, 3363, 3364, 3364, 3365, + 3365, 3366, 3366, 3367, 3367, 3367, 3368, 3368, 3369, 3369, + 3369, 3370, 3370, 3370, 3371, 3371, 3372, 3372, 3372, 3373, + + 3373, 3373, 3374, 3374, 3374, 3375, 3375, 3375, 3376, 3376, + 3377, 3377, 3377, 3378, 3378, 3378, 3379, 3379, 3379, 3380, + 3380, 3381, 3381, 3381, 3382, 3382, 3382, 3383, 3383, 3383, + 3384, 3384, 3384, 3385, 3385, 3385, 3386, 3386, 3386, 3387, + 3387, 3388, 3388, 3388, 3389, 3389, 3389, 3390, 3390, 3390, + 3391, 3391, 3392, 3392, 3392, 3393, 3393, 3393, 3394, 3394, + 3394, 3395, 3395, 3395, 3396, 3396, 3396, 3397, 3397, 3397, + 3398, 3398, 3399, 898, 3399, 3399, 3399, 3400, 897, 3400, + 3400, 3401, 3401, 3402, 3402, 3403, 3403, 3404, 3404, 3405, + 3405, 3406, 3406, 3407, 3407, 3408, 3408, 3409, 3409, 3410, + + 3410, 3411, 3411, 3412, 3412, 3413, 3413, 3414, 3414, 3415, + 3415, 3416, 3416, 3417, 3417, 3418, 3418, 3419, 3419, 3420, + 3420, 3421, 3421, 3422, 3422, 3423, 3423, 3424, 3424, 3425, + 3425, 3426, 3426, 3427, 3427, 3428, 3428, 3429, 3429, 3430, + 3430, 3431, 3431, 3432, 3432, 3433, 3433, 3434, 3434, 3435, + 3435, 3436, 3436, 3437, 3437, 3438, 3438, 3439, 3439, 3440, + 3440, 3441, 3441, 3442, 3442, 3443, 3443, 3444, 3444, 3445, + 3445, 3446, 3446, 3447, 3447, 3448, 3448, 3449, 3449, 3450, + 3450, 3451, 3451, 3452, 3452, 3453, 3453, 3454, 3454, 3454, + 3455, 3455, 3456, 3456, 3456, 3457, 3457, 3457, 3458, 3458, + + 3458, 3459, 3459, 3459, 3460, 3460, 3460, 3461, 3461, 3461, + 3462, 3462, 3463, 3463, 3463, 3464, 3464, 3464, 3465, 3465, + 3465, 3466, 3466, 3466, 3467, 3467, 3467, 3468, 3468, 3468, + 3469, 3469, 3469, 3470, 3470, 3470, 3471, 3471, 3471, 3472, + 3472, 3473, 3473, 3473, 3474, 3474, 3474, 3475, 3475, 3475, + 3476, 3476, 3476, 3477, 3477, 3477, 3478, 3478, 3478, 3479, + 3479, 3479, 3480, 3480, 3480, 3481, 3481, 3481, 3482, 3482, + 3483, 3483, 3483, 3484, 3484, 3484, 3485, 3485, 3485, 3486, + 896, 3486, 3486, 3486, 3487, 895, 3487, 3487, 3488, 3488, + 3489, 3489, 3490, 3490, 3491, 3491, 3492, 3492, 3493, 3493, + + 3494, 3494, 3495, 3495, 3496, 3496, 3497, 3497, 3498, 3498, + 3499, 3499, 3500, 3500, 3501, 3501, 3502, 3502, 3503, 3503, + 3504, 3504, 3505, 3505, 3506, 3506, 3507, 3507, 3508, 3508, + 3509, 3509, 3510, 3510, 3511, 3511, 3512, 3512, 3513, 3513, + 3514, 3514, 3515, 3515, 3516, 3516, 3517, 3517, 3518, 3518, + 3519, 3519, 3520, 3520, 3521, 3521, 3522, 3522, 3523, 3523, + 3524, 3524, 3525, 3525, 3526, 3526, 3527, 3527, 3528, 3528, + 3529, 3529, 3530, 3530, 3531, 3531, 3532, 3532, 3533, 3533, + 3534, 3534, 3535, 3535, 3536, 3536, 3537, 3537, 3538, 3538, + 3539, 3539, 3540, 3540, 3541, 3541, 3542, 3542, 3543, 3543, + + 3544, 3544, 3545, 3545, 3546, 3546, 3546, 3547, 3547, 3548, + 3548, 3548, 3549, 3549, 3549, 3550, 3550, 3551, 3551, 3551, + 3552, 3552, 3552, 3553, 3553, 3553, 3554, 3554, 3555, 3555, + 3555, 3556, 3556, 3556, 3557, 3557, 3557, 3558, 3558, 3558, + 3559, 3559, 3559, 3560, 3560, 3560, 3561, 3561, 3562, 3562, + 3562, 3563, 3563, 3563, 3564, 3564, 3564, 3565, 3565, 3566, + 3566, 3566, 3567, 3567, 3567, 3568, 3568, 3568, 3569, 3569, + 3569, 3570, 3570, 3570, 3571, 3571, 3571, 3572, 3572, 3573, + 3573, 3573, 3574, 3574, 3574, 3575, 3575, 3575, 3576, 3576, + 3577, 3577, 3577, 3578, 3578, 3578, 3579, 3579, 3579, 3580, + + 3580, 3580, 3581, 3581, 3581, 3582, 3582, 3582, 3583, 3583, + 3584, 894, 3584, 3584, 3584, 3585, 893, 3585, 3585, 3586, + 3586, 3587, 3587, 3588, 3588, 3589, 3589, 3590, 3590, 3591, + 3591, 3592, 3592, 3593, 3593, 3594, 3594, 3595, 3595, 3596, + 3596, 3597, 3597, 3598, 3598, 3599, 3599, 3600, 3600, 3601, + 3601, 3602, 3602, 3603, 3603, 3604, 3604, 3605, 3605, 3606, + 3606, 3607, 3607, 3608, 3608, 3609, 3609, 3610, 3610, 3611, + 3611, 3612, 3612, 3613, 3613, 3614, 3614, 3615, 3615, 3616, + 3616, 3617, 3617, 3618, 3618, 3619, 3619, 3620, 3620, 3621, + 3621, 3622, 3622, 3623, 3623, 3624, 3624, 3625, 3625, 3626, + + 3626, 3627, 3627, 3628, 3628, 3629, 3629, 3630, 3630, 3631, + 3631, 3632, 3632, 3633, 3633, 3634, 3634, 3635, 3635, 3636, + 3636, 3637, 3637, 3638, 3638, 3639, 3639, 3640, 3640, 3641, + 3641, 3642, 3642, 3643, 3643, 3644, 3644, 3644, 3645, 3645, + 3646, 3646, 3646, 3647, 3647, 3647, 3648, 3648, 3649, 3649, + 3649, 3650, 3650, 3650, 3651, 3651, 3651, 3652, 3652, 3652, + 3653, 3653, 3653, 3654, 3654, 3654, 3655, 3655, 3655, 3656, + 3656, 3656, 3657, 3657, 3658, 3658, 3658, 3659, 3659, 3659, + 3660, 3660, 3660, 3661, 3661, 3661, 3662, 3662, 3662, 3663, + 3663, 3663, 3664, 3664, 3664, 3665, 3665, 3665, 3666, 3666, + + 3666, 3667, 3667, 3668, 3668, 3668, 3669, 3669, 3669, 3670, + 3670, 3670, 3671, 3671, 3671, 3672, 3672, 3672, 3673, 3673, + 3673, 3674, 3674, 3674, 3675, 3675, 3675, 3676, 3676, 3676, + 3677, 3677, 3678, 3678, 3678, 3679, 3679, 3679, 3680, 3680, + 3680, 3681, 892, 3681, 3681, 3681, 3682, 891, 3682, 3682, + 3683, 3683, 3684, 3684, 3685, 3685, 3686, 3686, 3687, 3687, + 3688, 3688, 3689, 3689, 3690, 3690, 3691, 3691, 3692, 3692, + 3693, 3693, 3694, 3694, 3695, 3695, 3696, 3696, 3697, 3697, + 3698, 3698, 3699, 3699, 3700, 3700, 3701, 3701, 3702, 3702, + 3703, 3703, 3704, 3704, 3705, 3705, 3706, 3706, 3707, 3707, + + 3708, 3708, 3709, 3709, 3710, 3710, 3711, 3711, 3712, 3712, + 3713, 3713, 3714, 3714, 3715, 3715, 3716, 3716, 3717, 3717, + 3718, 3718, 3719, 3719, 3720, 3720, 3721, 3721, 3722, 3722, + 3723, 3723, 3724, 3724, 3725, 3725, 3726, 3726, 3727, 3727, + 3728, 3728, 3729, 3729, 3730, 3730, 3731, 3731, 3732, 3732, + 3733, 3733, 3734, 3734, 3735, 3735, 3736, 3736, 3737, 3737, + 3738, 3738, 3739, 3739, 3740, 3740, 3741, 3741, 3742, 3742, + 3742, 3743, 3743, 3744, 3744, 3744, 3745, 3745, 3745, 3746, + 3746, 3746, 3747, 3747, 3747, 3748, 3748, 3748, 3749, 3749, + 3750, 3750, 3750, 3751, 3751, 3751, 3752, 3752, 3752, 3753, + + 3753, 3754, 3754, 3754, 3755, 3755, 3755, 3756, 3756, 3756, + 3757, 3757, 3757, 3758, 3758, 3758, 3759, 3759, 3759, 3760, + 3760, 3761, 3761, 3761, 3762, 3762, 3762, 3763, 3763, 3763, + 3764, 3764, 3765, 3765, 3765, 3766, 3766, 3766, 3767, 3767, + 3767, 3768, 3768, 3768, 3769, 3769, 3769, 3770, 3770, 3770, + 3771, 3771, 3772, 3772, 3772, 3773, 3773, 3773, 3774, 3774, + 3774, 3775, 3775, 3776, 3776, 3776, 3777, 3777, 3777, 3778, + 3778, 3778, 3779, 3779, 3779, 3780, 3780, 3780, 3781, 3781, + 3781, 3782, 3782, 3783, 890, 3783, 3783, 3783, 3784, 889, + 3784, 3784, 3785, 3785, 3786, 3786, 3787, 3787, 3788, 3788, + + 3789, 3789, 3790, 3790, 3791, 3791, 3792, 3792, 3793, 3793, + 3794, 3794, 3795, 3795, 3796, 3796, 3797, 3797, 3798, 3798, + 3799, 3799, 3800, 3800, 3801, 3801, 3802, 3802, 3803, 3803, + 3804, 3804, 3805, 3805, 3806, 3806, 3807, 3807, 3808, 3808, + 3809, 3809, 3810, 3810, 3811, 3811, 3812, 3812, 3813, 3813, + 3814, 3814, 3815, 3815, 3816, 3816, 3817, 3817, 3818, 3818, + 3819, 3819, 3820, 3820, 3821, 3821, 3822, 3822, 3823, 3823, + 3824, 3824, 3825, 3825, 3826, 3826, 3827, 3827, 3828, 3828, + 3829, 3829, 3830, 3830, 3831, 3831, 3832, 3832, 3833, 3833, + 3834, 3834, 3835, 3835, 3836, 3836, 3837, 3837, 3838, 3838, + + 3839, 3839, 3840, 3840, 3841, 3841, 3842, 3842, 3842, 3843, + 3843, 3843, 3844, 3844, 3844, 3845, 3845, 3846, 3846, 3846, + 3847, 3847, 3847, 3848, 3848, 3848, 3849, 3849, 3849, 3850, + 3850, 3850, 3851, 3851, 3851, 3852, 3852, 3852, 3853, 3853, + 3853, 3854, 3854, 3854, 3855, 3855, 3856, 3856, 3856, 3857, + 3857, 3857, 3858, 3858, 3858, 3859, 3859, 3859, 3860, 3860, + 3860, 3861, 3861, 3861, 3862, 3862, 3862, 3863, 3863, 3863, + 3864, 3864, 3864, 3865, 3865, 3866, 3866, 3866, 3867, 3867, + 3867, 3868, 3868, 3868, 3869, 3869, 3869, 3870, 3870, 3870, + 3871, 3871, 3871, 3872, 3872, 3872, 3873, 3873, 3873, 3874, + + 3874, 3874, 3875, 3875, 3876, 3876, 3876, 3877, 3877, 3877, + 3878, 3878, 3878, 3879, 887, 3879, 3879, 3879, 3880, 879, + 3880, 3880, 3881, 3881, 3882, 3882, 3883, 3883, 3884, 3884, + 3885, 3885, 3886, 3886, 3887, 3887, 3888, 3888, 3889, 3889, + 3890, 3890, 3891, 3891, 3892, 3892, 3893, 3893, 3894, 3894, + 3895, 3895, 3896, 3896, 3897, 3897, 3898, 3898, 3899, 3899, + 3900, 3900, 3901, 3901, 3902, 3902, 3903, 3903, 3904, 3904, + 3905, 3905, 3906, 3906, 3907, 3907, 3908, 3908, 3909, 3909, + 3910, 3910, 3911, 3911, 3912, 3912, 3913, 3913, 3914, 3914, + 3915, 3915, 3916, 3916, 3917, 3917, 3918, 3918, 3919, 3919, + + 3920, 3920, 3921, 3921, 3922, 3922, 3923, 3923, 3924, 3924, + 3925, 3925, 3926, 3926, 3927, 3927, 3928, 3928, 3929, 3929, + 3930, 3930, 3931, 3931, 3932, 3932, 3933, 3933, 3934, 3934, + 3935, 3935, 3936, 3936, 3937, 3937, 3937, 3938, 3938, 3938, + 3939, 3939, 3939, 3940, 3940, 3940, 3941, 3941, 3941, 3942, + 3942, 3942, 3943, 3943, 3944, 3944, 3944, 3945, 3945, 3945, + 3946, 3946, 3946, 3947, 3947, 3947, 3948, 3948, 3948, 3949, + 3949, 3949, 3950, 3950, 3950, 3951, 3951, 3951, 3952, 3952, + 3953, 3953, 3953, 3954, 3954, 3954, 3955, 3955, 3955, 3956, + 3956, 3957, 3957, 3957, 3958, 3958, 3958, 3959, 3959, 3959, + + 3960, 3960, 3960, 3961, 3961, 3961, 3962, 3962, 3962, 3963, + 3963, 3964, 3964, 3964, 3965, 3965, 3965, 3966, 3966, 3966, + 3967, 3967, 3968, 3968, 3968, 3969, 3969, 3969, 3970, 3970, + 3970, 3971, 3971, 3971, 3972, 3972, 3972, 3973, 3973, 3973, + 3974, 3974, 3975, 870, 3975, 3975, 3975, 3976, 867, 3976, + 3976, 3977, 3977, 3978, 3978, 3979, 3979, 3980, 3980, 3981, + 3981, 3982, 3982, 3983, 3983, 3984, 3984, 3985, 3985, 3986, + 3986, 3987, 3987, 3988, 3988, 3989, 3989, 3990, 3990, 3991, + 3991, 3992, 3992, 3993, 3993, 3994, 3994, 3995, 3995, 3996, + 3996, 3997, 3997, 3998, 3998, 3999, 3999, 4000, 4000, 4001, + + 4001, 4002, 4002, 4003, 4003, 4004, 4004, 4005, 4005, 4006, + 4006, 4007, 4007, 4008, 4008, 4009, 4009, 4010, 4010, 4011, + 4011, 4012, 4012, 4013, 4013, 4014, 4014, 4015, 4015, 4016, + 4016, 4017, 4017, 4018, 4018, 4019, 4019, 4020, 4020, 4021, + 4021, 4022, 4022, 4023, 4023, 4024, 4024, 4025, 4025, 4026, + 4026, 4027, 4027, 4028, 4028, 4028, 4029, 4029, 4029, 4030, + 4030, 4030, 4031, 4031, 4031, 4032, 4032, 4032, 4033, 4033, + 4033, 4034, 4034, 4034, 4035, 4035, 4035, 4036, 4036, 4036, + 4037, 4037, 4038, 4038, 4038, 4039, 4039, 4039, 4040, 4040, + 4040, 4041, 4041, 4041, 4042, 4042, 4042, 4043, 4043, 4043, + + 4044, 4044, 4044, 4045, 4045, 4045, 4046, 4046, 4046, 4047, + 4047, 4048, 4048, 4048, 4049, 4049, 4049, 4050, 4050, 4050, + 4051, 4051, 4051, 4052, 4052, 4052, 4053, 4053, 4053, 4054, + 4054, 4054, 4055, 4055, 4055, 4056, 4056, 4056, 4057, 4057, + 4058, 4058, 4058, 4059, 4059, 4059, 4060, 4060, 4060, 4061, + 866, 4061, 4061, 4061, 4062, 865, 4062, 4062, 4063, 4063, + 4064, 4064, 4065, 4065, 4066, 4066, 4067, 4067, 4068, 4068, + 4069, 4069, 4070, 4070, 4071, 4071, 4072, 4072, 4073, 4073, + 4074, 4074, 4075, 4075, 4076, 4076, 4077, 4077, 4078, 4078, + 4079, 4079, 4080, 4080, 4081, 4081, 4082, 4082, 4083, 4083, + + 4084, 4084, 4085, 4085, 4086, 4086, 4087, 4087, 4088, 4088, + 4089, 4089, 4090, 4090, 4091, 4091, 4092, 4092, 4093, 4093, + 4094, 4094, 4095, 4095, 4096, 4096, 4097, 4097, 4098, 4098, + 4099, 4099, 4100, 4100, 4101, 4101, 4102, 4102, 4103, 4103, + 4104, 4104, 4105, 4105, 4106, 4106, 4106, 4107, 4107, 4107, + 4108, 4108, 4108, 4109, 4109, 4110, 4110, 4110, 4111, 4111, + 4111, 4112, 4112, 4112, 4113, 4113, 4113, 4114, 4114, 4114, + 4115, 4115, 4115, 4116, 4116, 4116, 4117, 4117, 4118, 4118, + 4118, 4119, 4119, 4119, 4120, 4120, 4120, 4121, 4121, 4122, + 4122, 4122, 4123, 4123, 4123, 4124, 4124, 4124, 4125, 4125, + + 4125, 4126, 4126, 4126, 4127, 4127, 4127, 4128, 4128, 4129, + 4129, 4129, 4130, 4130, 4130, 4131, 4131, 4131, 4132, 4132, + 4133, 4133, 4133, 4134, 4134, 4134, 4135, 4135, 4135, 4136, + 4136, 4136, 4137, 4137, 4137, 4138, 4138, 4138, 4139, 4139, + 4140, 864, 4140, 4140, 4140, 4141, 863, 4141, 4141, 4142, + 4142, 4143, 4143, 4144, 4144, 4145, 4145, 4146, 4146, 4147, + 4147, 4148, 4148, 4149, 4149, 4150, 4150, 4151, 4151, 4152, + 4152, 4153, 4153, 4154, 4154, 4155, 4155, 4156, 4156, 4157, + 4157, 4158, 4158, 4159, 4159, 4160, 4160, 4161, 4161, 4162, + 4162, 4163, 4163, 4164, 4164, 4165, 4165, 4166, 4166, 4167, + + 4167, 4168, 4168, 4169, 4169, 4170, 4170, 4171, 4171, 4172, + 4172, 4173, 4173, 4174, 4174, 4175, 4175, 4176, 4176, 4177, + 4177, 4178, 4178, 4179, 4179, 4180, 4180, 4180, 4181, 4181, + 4181, 4182, 4182, 4182, 4183, 4183, 4183, 4184, 4184, 4184, + 4185, 4185, 4186, 4186, 4186, 4187, 4187, 4187, 4188, 4188, + 4188, 4189, 4189, 4189, 4190, 4190, 4190, 4191, 4191, 4191, + 4192, 4192, 4192, 4193, 4193, 4193, 4194, 4194, 4194, 4195, + 4195, 4196, 4196, 4196, 4197, 4197, 4197, 4198, 4198, 4198, + 4199, 4199, 4199, 4200, 4200, 4200, 4201, 4201, 4201, 4202, + 4202, 4202, 4203, 4203, 4203, 4204, 4204, 4204, 4205, 4205, + + 4206, 4206, 4206, 4207, 4207, 4207, 4208, 4208, 4208, 4209, + 862, 4209, 4209, 4209, 4210, 859, 4210, 4210, 4211, 4211, + 4212, 4212, 4213, 4213, 4214, 4214, 4215, 4215, 4216, 4216, + 4217, 4217, 4218, 4218, 4219, 4219, 4220, 4220, 4221, 4221, + 4222, 4222, 4223, 4223, 4224, 4224, 4225, 4225, 4226, 4226, + 4227, 4227, 4228, 4228, 4229, 4229, 4230, 4230, 4231, 4231, + 4232, 4232, 4233, 4233, 4234, 4234, 4235, 4235, 4236, 4236, + 4237, 4237, 4238, 4238, 4239, 4239, 4240, 4240, 4241, 4241, + 4242, 4242, 4243, 4243, 4244, 4244, 4245, 4245, 4246, 4246, + 4246, 4247, 4247, 4247, 4248, 4248, 4248, 4249, 4249, 4249, + + 4250, 4250, 4250, 4251, 4251, 4251, 4252, 4252, 4253, 4253, + 4253, 4254, 4254, 4254, 4255, 4255, 4255, 4256, 4256, 4256, + 4257, 4257, 4257, 4258, 4258, 4258, 4259, 4259, 4259, 4260, + 4260, 4260, 4261, 4261, 4262, 4262, 4262, 4263, 4263, 4263, + 4264, 4264, 4264, 4265, 4265, 4266, 4266, 4266, 4267, 4267, + 4267, 4268, 4268, 4268, 4269, 4269, 4269, 4270, 4270, 4270, + 4271, 4271, 4271, 4272, 4272, 4273, 845, 4273, 4273, 4273, + 4274, 836, 4274, 4274, 4275, 4275, 4276, 4276, 4277, 4277, + 4278, 4278, 4279, 4279, 4280, 4280, 4281, 4281, 4282, 4282, + 4283, 4283, 4284, 4284, 4285, 4285, 4286, 4286, 4287, 4287, + + 4288, 4288, 4289, 4289, 4290, 4290, 4291, 4291, 4292, 4292, + 4293, 4293, 4294, 4294, 4295, 4295, 4296, 4296, 4297, 4297, + 4298, 4298, 4299, 4299, 4300, 4300, 4301, 4301, 4302, 4302, + 4303, 4303, 4304, 4304, 4304, 4305, 4305, 4305, 4306, 4306, + 4306, 4307, 4307, 4307, 4308, 4308, 4308, 4309, 4309, 4309, + 4310, 4310, 4310, 4311, 4311, 4311, 4312, 4312, 4312, 4313, + 4313, 4314, 4314, 4314, 4315, 4315, 4315, 4316, 4316, 4316, + 4317, 4317, 4317, 4318, 4318, 4318, 4319, 4319, 4319, 4320, + 4320, 4320, 4321, 4321, 4321, 4322, 4322, 4322, 4323, 4323, + 4324, 4324, 4324, 4325, 4325, 4325, 4326, 4326, 4326, 4327, + + 833, 4327, 4327, 4327, 4328, 831, 4328, 4328, 4329, 4329, + 4330, 4330, 4331, 4331, 4332, 4332, 4333, 4333, 4334, 4334, + 4335, 4335, 4336, 4336, 4337, 4337, 4338, 4338, 4339, 4339, + 4340, 4340, 4341, 4341, 4342, 4342, 4343, 4343, 4344, 4344, + 4345, 4345, 4346, 4346, 4347, 4347, 4348, 4348, 4349, 4349, + 4350, 4350, 4351, 4351, 4352, 4352, 4352, 4353, 4353, 4353, + 4354, 4354, 4354, 4355, 4355, 4356, 4356, 4356, 4357, 4357, + 4357, 4358, 4358, 4358, 4359, 4359, 4359, 4360, 4360, 4360, + 4361, 4361, 4361, 4362, 4362, 4362, 4363, 4363, 4364, 4364, + 4364, 4365, 4365, 4365, 4366, 4366, 4366, 4367, 4367, 4368, + + 4368, 4368, 4369, 4369, 4369, 4370, 4370, 4370, 4371, 4371, + 4371, 4372, 4372, 4372, 4373, 4373, 4373, 4374, 4374, 4375, + 830, 4375, 4375, 4375, 4376, 829, 4376, 4376, 4377, 4377, + 4378, 4378, 4379, 4379, 4380, 4380, 4381, 4381, 4382, 4382, + 4383, 4383, 4384, 4384, 4385, 4385, 4386, 4386, 4387, 4387, + 4388, 4388, 4389, 4389, 4390, 4390, 4391, 4391, 4392, 4392, + 4393, 4393, 4394, 4394, 4395, 4395, 4395, 4396, 4396, 4396, + 4397, 4397, 4397, 4398, 4398, 4398, 4399, 4399, 4399, 4400, + 4400, 4401, 4401, 4401, 4402, 4402, 4402, 4403, 4403, 4403, + 4404, 4404, 4404, 4405, 4405, 4405, 4406, 4406, 4406, 4407, + + 4407, 4407, 4408, 4408, 4408, 4409, 4409, 4409, 4410, 4410, + 4411, 4411, 4411, 4412, 4412, 4412, 4413, 4413, 4413, 4414, + 828, 4414, 4414, 4414, 4415, 827, 4415, 4415, 4416, 4416, + 4417, 4417, 4418, 4418, 4419, 4419, 4420, 4420, 4421, 4421, + 4422, 4422, 4423, 4423, 4424, 4424, 4425, 4425, 4426, 4426, + 4427, 4427, 4428, 4428, 4429, 4429, 4430, 4430, 4431, 4431, + 4432, 4432, 4432, 4433, 4433, 4433, 4434, 4434, 4434, 4435, + 4435, 4435, 4436, 4436, 4436, 4437, 4437, 4437, 4438, 4438, + 4439, 4439, 4439, 4440, 4440, 4440, 4441, 4441, 4441, 4442, + 4442, 4442, 4443, 4443, 4443, 4444, 4444, 4444, 4445, 4445, + + 4445, 4446, 4446, 4446, 4447, 4447, 4448, 826, 4448, 4448, + 4448, 4449, 825, 4449, 4449, 4450, 4450, 4451, 4451, 4452, + 4452, 4453, 4453, 4454, 4454, 4455, 4455, 4456, 4456, 4457, + 4457, 4458, 4458, 4459, 4459, 4459, 4460, 4460, 4460, 4461, + 4461, 4461, 4462, 4462, 4462, 4463, 4463, 4463, 4464, 4464, + 4464, 4465, 4465, 4465, 4466, 4466, 4467, 4467, 4467, 4468, + 4468, 4468, 4469, 4469, 4469, 4470, 824, 4470, 4470, 4471, + 4471, 4472, 4472, 4473, 4473, 4474, 4474, 4475, 4475, 4476, + 4476, 4477, 4477, 4478, 4478, 4478, 4479, 4479, 4479, 4480, + 4480, 4480, 4481, 4481, 4481, 4482, 4482, 4482, 4483, 4483, + + 4483, 4484, 4484, 4484, 4485, 4485, 4485, 4486, 4486, 4487, + 823, 4487, 4487, 4488, 4488, 4489, 4489, 4490, 4490, 4491, + 4491, 4492, 4492, 4493, 4493, 4493, 4494, 4494, 4494, 4495, + 4495, 4495, 4496, 4496, 4496, 4497, 4497, 4497, 4498, 4498, + 4498, 4499, 822, 4499, 4499, 4500, 4500, 4501, 4501, 4502, + 4502, 4503, 4503, 4503, 4504, 4504, 4504, 4505, 4505, 4505, + 4506, 4506, 4506, 4507, 821, 4507, 4507, 4508, 4508, 4509, + 4509, 4510, 4510, 4510, 4511, 4511, 4511, 4512, 820, 4512, + 4512, 4513, 4513, 4513, 4514, 819, 4514, 4514, 4515, 818, + 4515, 4515, 4516, 817, 4516, 4516, 4517, 816, 4517, 4517, + + 4518, 815, 4518, 4518, 4519, 814, 4519, 4519, 4520, 813, + 4520, 4520, 4521, 812, 4521, 4521, 4522, 811, 4522, 4522, + 4523, 810, 4523, 4523, 4524, 809, 4524, 4524, 4525, 808, + 4525, 4525, 4526, 807, 4526, 4526, 4527, 806, 4527, 4527, + 4528, 805, 4528, 4528, 4529, 804, 4529, 4529, 4530, 803, + 4530, 4530, 4531, 802, 4531, 4531, 4532, 800, 4532, 4532, + 4533, 788, 4533, 4533, 4534, 778, 4534, 4534, 4535, 777, + 4535, 4535, 4536, 776, 4536, 4536, 4537, 775, 4537, 4537, + 4538, 774, 4538, 4538, 4539, 773, 4539, 4539, 4540, 759, + 4540, 4540, 752, 748, 745, 743, 742, 741, 740, 739, + + 738, 737, 736, 735, 734, 733, 732, 731, 730, 729, + 728, 727, 726, 725, 724, 723, 722, 721, 720, 719, + 718, 716, 713, 709, 706, 696, 691, 688, 687, 686, + 685, 684, 683, 682, 671, 665, 658, 656, 655, 654, + 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, + 643, 642, 641, 640, 639, 638, 637, 636, 634, 628, + 627, 614, 613, 612, 602, 601, 595, 594, 593, 592, + 591, 590, 589, 578, 575, 572, 567, 564, 562, 561, + 560, 559, 558, 557, 556, 555, 554, 553, 552, 551, + 550, 549, 548, 547, 545, 539, 534, 533, 511, 506, + + 505, 504, 503, 502, 501, 497, 485, 478, 475, 473, + 472, 471, 470, 469, 468, 467, 466, 465, 464, 463, + 461, 454, 448, 447, 425, 421, 420, 419, 418, 417, + 416, 410, 398, 391, 388, 386, 385, 384, 383, 382, + 381, 380, 379, 377, 370, 362, 361, 340, 328, 308, + 306, 305, 304, 303, 302, 300, 240, 233, 226, 221, + 217, 216, 215, 213, 143, 140, 138, 137, 136, 128, + 126, 70, 60, 58, 56, 55, 53, 50, 48, 41, + 35, 13, 8, 3, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, 2829, + 2829, 2829 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[103] = + { 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, }; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "read_config_lex.l" +#line 2 "read_config_lex.l" +/* + * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: configuration file syntax + */ + +#include <string.h> + +#include "read_config_yy.h" +#define YY_NO_INPUT 1 +#line 4182 "read_config_lex.c" + +#define INITIAL 0 + +#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 + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (void ); + +int yyget_debug (void ); + +void yyset_debug (int debug_flag ); + +YY_EXTRA_TYPE yyget_extra (void ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in (void ); + +void yyset_in (FILE * in_str ); + +FILE *yyget_out (void ); + +void yyset_out (FILE * out_str ); + +int yyget_leng (void ); + +char *yyget_text (void ); + +int yyget_lineno (void ); + +void yyset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (void ); +#else +extern int yywrap (void ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#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, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + 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, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* 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 yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 57 "read_config_lex.l" + +#line 4369 "read_config_lex.c" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (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_match: + do + { + register 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; + } + 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 >= 2830 ) + 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] != 10685 ); + +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; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + yylineno++; +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* 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); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 58 "read_config_lex.l" +{ return T_UNIX; } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 59 "read_config_lex.l" +{ return T_IPV4_ADDR; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 60 "read_config_lex.l" +{ return T_IPV6_ADDR; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 61 "read_config_lex.l" +{ return T_IPV4_DEST_ADDR; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 62 "read_config_lex.l" +{ return T_IPV6_DEST_ADDR; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 63 "read_config_lex.l" +{ return T_IPV4_IFACE; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 64 "read_config_lex.l" +{ return T_IPV6_IFACE; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 65 "read_config_lex.l" +{ return T_IFACE; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 66 "read_config_lex.l" +{ return T_MULTICAST; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 67 "read_config_lex.l" +{ return T_UDP; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 68 "read_config_lex.l" +{ return T_TCP; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 69 "read_config_lex.l" +{ return T_HASHSIZE; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 70 "read_config_lex.l" +{ return T_REFRESH; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 71 "read_config_lex.l" +{ return T_EXPIRE; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 72 "read_config_lex.l" +{ return T_TIMEOUT; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 73 "read_config_lex.l" +{ return T_DELAY; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 74 "read_config_lex.l" +{ return T_HASHLIMIT; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 75 "read_config_lex.l" +{ return T_PATH; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 76 "read_config_lex.l" +{ return T_IGNORE_PROTOCOL; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 77 "read_config_lex.l" +{ return T_IGNORE_TRAFFIC; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 78 "read_config_lex.l" +{ return T_STRIP_NAT; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 79 "read_config_lex.l" +{ return T_BACKLOG; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 80 "read_config_lex.l" +{ return T_GROUP; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 81 "read_config_lex.l" +{ return T_PORT; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 82 "read_config_lex.l" +{ return T_LOG; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 83 "read_config_lex.l" +{ return T_SYSLOG; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 84 "read_config_lex.l" +{ return T_LOCK; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 85 "read_config_lex.l" +{ return T_GENERAL; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 86 "read_config_lex.l" +{ return T_SYNC; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 87 "read_config_lex.l" +{ return T_STATS; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 88 "read_config_lex.l" +{ return T_RELAX_TRANSITIONS; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 89 "read_config_lex.l" +{ return T_BUFFER_SIZE; /* alias */ } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 90 "read_config_lex.l" +{ return T_BUFFER_SIZE_MAX_GROWN; /* alias */ } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 91 "read_config_lex.l" +{ return T_BUFFER_SIZE_MAX_GROWN; /* alias */ } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 92 "read_config_lex.l" +{ return T_BUFFER_SIZE; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 93 "read_config_lex.l" +{ return T_BUFFER_SIZE_MAX_GROWN; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 94 "read_config_lex.l" +{ return T_SYNC_MODE; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 95 "read_config_lex.l" +{ return T_LISTEN_TO; } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 96 "read_config_lex.l" +{ return T_FAMILY; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 97 "read_config_lex.l" +{ return T_RESEND_BUFFER_SIZE; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 98 "read_config_lex.l" +{ return T_RESEND_QUEUE_SIZE; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 99 "read_config_lex.l" +{ return T_CHECKSUM; } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 100 "read_config_lex.l" +{ return T_WINDOWSIZE; } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 101 "read_config_lex.l" +{ return T_REPLICATE; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 102 "read_config_lex.l" +{ return T_FOR; } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 103 "read_config_lex.l" +{ return T_WRITE_THROUGH; } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 104 "read_config_lex.l" +{ return T_SYN_SENT; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 105 "read_config_lex.l" +{ return T_SYN_RECV; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 106 "read_config_lex.l" +{ return T_ESTABLISHED; } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 107 "read_config_lex.l" +{ return T_FIN_WAIT; } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 108 "read_config_lex.l" +{ return T_CLOSE_WAIT; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 109 "read_config_lex.l" +{ return T_LAST_ACK; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 110 "read_config_lex.l" +{ return T_TIME_WAIT; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 111 "read_config_lex.l" +{ return T_CLOSE; /* alias of CLOSED */ } + YY_BREAK +case 55: +YY_RULE_SETUP +#line 112 "read_config_lex.l" +{ return T_CLOSE; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 113 "read_config_lex.l" +{ return T_LISTEN; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 114 "read_config_lex.l" +{ return T_STAT_BUFFER_SIZE; } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 115 "read_config_lex.l" +{ return T_DESTROY_TIMEOUT; } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 116 "read_config_lex.l" +{ return T_SNDBUFF; /* deprecated */ } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 117 "read_config_lex.l" +{ return T_RCVBUFF; /* deprecated */ } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 118 "read_config_lex.l" +{ return T_SNDBUFF; } + YY_BREAK +case 62: +YY_RULE_SETUP +#line 119 "read_config_lex.l" +{ return T_RCVBUFF; } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 120 "read_config_lex.l" +{ return T_FILTER; } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 121 "read_config_lex.l" +{ return T_PROTOCOL; } + YY_BREAK +case 65: +YY_RULE_SETUP +#line 122 "read_config_lex.l" +{ return T_ADDRESS; } + YY_BREAK +case 66: +YY_RULE_SETUP +#line 123 "read_config_lex.l" +{ return T_STATE; } + YY_BREAK +case 67: +YY_RULE_SETUP +#line 124 "read_config_lex.l" +{ return T_ACCEPT; } + YY_BREAK +case 68: +YY_RULE_SETUP +#line 125 "read_config_lex.l" +{ return T_IGNORE; } + YY_BREAK +case 69: +YY_RULE_SETUP +#line 126 "read_config_lex.l" +{ return T_PURGE; } + YY_BREAK +case 70: +YY_RULE_SETUP +#line 127 "read_config_lex.l" +{ return T_FROM; } + YY_BREAK +case 71: +YY_RULE_SETUP +#line 128 "read_config_lex.l" +{ return T_USERSPACE; } + YY_BREAK +case 72: +YY_RULE_SETUP +#line 129 "read_config_lex.l" +{ return T_KERNELSPACE; } + YY_BREAK +case 73: +YY_RULE_SETUP +#line 130 "read_config_lex.l" +{ return T_EVENT_ITER_LIMIT; } + YY_BREAK +case 74: +YY_RULE_SETUP +#line 131 "read_config_lex.l" +{ return T_DEFAULT; } + YY_BREAK +case 75: +YY_RULE_SETUP +#line 132 "read_config_lex.l" +{ return T_POLL_SECS; } + YY_BREAK +case 76: +YY_RULE_SETUP +#line 133 "read_config_lex.l" +{ return T_NETLINK_OVERRUN_RESYNC; } + YY_BREAK +case 77: +YY_RULE_SETUP +#line 134 "read_config_lex.l" +{ return T_NICE; } + YY_BREAK +case 78: +YY_RULE_SETUP +#line 135 "read_config_lex.l" +{ return T_SCHEDULER; } + YY_BREAK +case 79: +YY_RULE_SETUP +#line 136 "read_config_lex.l" +{ return T_TYPE; } + YY_BREAK +case 80: +YY_RULE_SETUP +#line 137 "read_config_lex.l" +{ return T_PRIO; } + YY_BREAK +case 81: +YY_RULE_SETUP +#line 138 "read_config_lex.l" +{ return T_NETLINK_EVENTS_RELIABLE; } + YY_BREAK +case 82: +YY_RULE_SETUP +#line 139 "read_config_lex.l" +{ return T_DISABLE_INTERNAL_CACHE; } + YY_BREAK +case 83: +YY_RULE_SETUP +#line 140 "read_config_lex.l" +{ return T_DISABLE_EXTERNAL_CACHE; } + YY_BREAK +case 84: +YY_RULE_SETUP +#line 141 "read_config_lex.l" +{ return T_ERROR_QUEUE_LENGTH; } + YY_BREAK +case 85: +YY_RULE_SETUP +#line 143 "read_config_lex.l" +{ return T_ON; } + YY_BREAK +case 86: +YY_RULE_SETUP +#line 144 "read_config_lex.l" +{ return T_OFF; } + YY_BREAK +case 87: +YY_RULE_SETUP +#line 145 "read_config_lex.l" +{ yylval.val = atoi(yytext); return T_NUMBER; } + YY_BREAK +case 88: +YY_RULE_SETUP +#line 146 "read_config_lex.l" +{ yylval.val = atoi(yytext); return T_SIGNED_NUMBER; } + YY_BREAK +case 89: +YY_RULE_SETUP +#line 147 "read_config_lex.l" +{ yylval.string = strdup(yytext); return T_IP; } + YY_BREAK +case 90: +YY_RULE_SETUP +#line 148 "read_config_lex.l" +{ yylval.string = strdup(yytext); return T_IP; } + YY_BREAK +case 91: +YY_RULE_SETUP +#line 149 "read_config_lex.l" +{ yylval.string = strdup(yytext); return T_PATH_VAL; } + YY_BREAK +case 92: +YY_RULE_SETUP +#line 150 "read_config_lex.l" +{ return T_ALARM; } + YY_BREAK +case 93: +YY_RULE_SETUP +#line 151 "read_config_lex.l" +{ fprintf(stderr, "\nWARNING: Now `persistent' mode " + "is called `alarm'. Please, update " + "your conntrackd.conf file.\n"); + return T_ALARM; } + YY_BREAK +case 94: +YY_RULE_SETUP +#line 155 "read_config_lex.l" +{ return T_FTFW; } + YY_BREAK +case 95: +YY_RULE_SETUP +#line 156 "read_config_lex.l" +{ fprintf(stderr, "\nWARNING: Now `nack' mode " + "is called `ftfw'. Please, update " + "your conntrackd.conf file.\n"); + return T_FTFW; } + YY_BREAK +case 96: +YY_RULE_SETUP +#line 160 "read_config_lex.l" +{ return T_NOTRACK; } + YY_BREAK +case 97: +YY_RULE_SETUP +#line 161 "read_config_lex.l" +{ yylval.string = strdup(yytext); return T_STRING; } + YY_BREAK +case 98: +*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 163 "read_config_lex.l" +; + YY_BREAK +case 99: +YY_RULE_SETUP +#line 164 "read_config_lex.l" +; + YY_BREAK +case 100: +/* rule 100 can match eol */ +YY_RULE_SETUP +#line 165 "read_config_lex.l" +; + YY_BREAK +case YY_STATE_EOF(INITIAL): +#line 167 "read_config_lex.l" +{ yyterminate(); } + YY_BREAK +case 101: +YY_RULE_SETUP +#line 169 "read_config_lex.l" +{ return yytext[0]; } + YY_BREAK +case 102: +YY_RULE_SETUP +#line 171 "read_config_lex.l" +ECHO; + YY_BREAK +#line 4986 "read_config_lex.c" + + 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; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (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 yyin at a new source and called + * yylex(). 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 = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * 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)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have 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; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (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; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (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)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(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 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* 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; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (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; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((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 *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + 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; + + (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) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register 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; + } + 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 >= 2830 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (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 >= 2830 ) + 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 == 2829); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(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)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart(yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + if ( c == '\n' ) + + yylineno++; +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + 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); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(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. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_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 *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 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. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** 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. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_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); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(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**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((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**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_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; + } +} + +/** 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 + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() 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. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_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 = yy_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param line_number + * + */ +void yyset_lineno (int line_number ) +{ + + yylineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str ) +{ + yyin = in_str ; +} + +void yyset_out (FILE * out_str ) +{ + yyout = out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int bdebug ) +{ + yy_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + /* We do not touch yylineno unless the option is enabled. */ + yylineno = 1; + + (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; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 171 "read_config_lex.l" + + + +int +yywrap() +{ + return 1; +} + diff --git a/src/read_config_lex.l b/src/read_config_lex.l new file mode 100644 index 0000000..b2d4bdb --- /dev/null +++ b/src/read_config_lex.l @@ -0,0 +1,177 @@ +%{ +/* + * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: configuration file syntax + */ + +#include <string.h> + +#include "read_config_yy.h" +%} + +%option yylineno +%option noinput +%option nounput + +ws [ \t]+ +comment #.*$ +nl [\n\r] + +is_on [o|O][n|N] +is_off [o|O][f|F][f|F] +integer [0-9]+ +signed_integer [\-\+][0-9]+ +path \/[^\"\n ]* +ip4_cidr \/[0-2]*[0-9]+ +ip4_end [0-9]*[0-9]+ +ip4_part [0-2]*{ip4_end} +ip4 {ip4_part}\.{ip4_part}\.{ip4_part}\.{ip4_part}{ip4_cidr}? +hex_255 [0-9a-fA-F]{1,4} +ip6_cidr \/[0-1]*[0-9]*[0-9]+ +ip6_part {hex_255}":"? +ip6_form1 {ip6_part}{0,16}"::"{ip6_part}{0,16} +ip6_form2 ({hex_255}":"){16}{hex_255} +ip6 {ip6_form1}{ip6_cidr}?|{ip6_form2}{ip6_cidr}? +string [a-zA-Z][a-zA-Z0-9\.]* +persistent [P|p][E|e][R|r][S|s][I|i][S|s][T|t][E|e][N|n][T|T] +nack [N|n][A|a][C|c][K|k] +alarm [A|a][L|l][A|a][R|r][M|m] +ftfw [F|f][T|t][F|f][W|w] +notrack [N|n][O|o][T|t][R|r][A|a][C|c][K|k] + +%% +"UNIX" { return T_UNIX; } +"IPv4_address" { return T_IPV4_ADDR; } +"IPv6_address" { return T_IPV6_ADDR; } +"IPv4_Destination_Address" { return T_IPV4_DEST_ADDR; } +"IPv6_Destination_Address" { return T_IPV6_DEST_ADDR; } +"IPv4_interface" { return T_IPV4_IFACE; } +"IPv6_interface" { return T_IPV6_IFACE; } +"Interface" { return T_IFACE; } +"Multicast" { return T_MULTICAST; } +"UDP" { return T_UDP; } +"TCP" { return T_TCP; } +"HashSize" { return T_HASHSIZE; } +"RefreshTime" { return T_REFRESH; } +"CacheTimeout" { return T_EXPIRE; } +"CommitTimeout" { return T_TIMEOUT; } +"DelayDestroyMessages" { return T_DELAY; } +"HashLimit" { return T_HASHLIMIT; } +"Path" { return T_PATH; } +"IgnoreProtocol" { return T_IGNORE_PROTOCOL; } +"IgnoreTrafficFor" { return T_IGNORE_TRAFFIC; } +"StripNAT" { return T_STRIP_NAT; } +"Backlog" { return T_BACKLOG; } +"Group" { return T_GROUP; } +"Port" { return T_PORT; } +"LogFile" { return T_LOG; } +"Syslog" { return T_SYSLOG; } +"LockFile" { return T_LOCK; } +"General" { return T_GENERAL; } +"Sync" { return T_SYNC; } +"Stats" { return T_STATS; } +"RelaxTransitions" { return T_RELAX_TRANSITIONS; } +"SocketBufferSize" { return T_BUFFER_SIZE; /* alias */ } +"SocketBufferSizeMaxGrown" { return T_BUFFER_SIZE_MAX_GROWN; /* alias */ } +"SocketBufferSizeMaxGrowth" { return T_BUFFER_SIZE_MAX_GROWN; /* alias */ } +"NetlinkBufferSize" { return T_BUFFER_SIZE; } +"NetlinkBufferSizeMaxGrowth" { return T_BUFFER_SIZE_MAX_GROWN; } +"Mode" { return T_SYNC_MODE; } +"ListenTo" { return T_LISTEN_TO; } +"Family" { return T_FAMILY; } +"ResendBufferSize" { return T_RESEND_BUFFER_SIZE; } +"ResendQueueSize" { return T_RESEND_QUEUE_SIZE; } +"Checksum" { return T_CHECKSUM; } +"ACKWindowSize" { return T_WINDOWSIZE; } +"Replicate" { return T_REPLICATE; } +"for" { return T_FOR; } +"CacheWriteThrough" { return T_WRITE_THROUGH; } +"SYN_SENT" { return T_SYN_SENT; } +"SYN_RECV" { return T_SYN_RECV; } +"ESTABLISHED" { return T_ESTABLISHED; } +"FIN_WAIT" { return T_FIN_WAIT; } +"CLOSE_WAIT" { return T_CLOSE_WAIT; } +"LAST_ACK" { return T_LAST_ACK; } +"TIME_WAIT" { return T_TIME_WAIT; } +"CLOSE" { return T_CLOSE; /* alias of CLOSED */ } +"CLOSED" { return T_CLOSE; } +"LISTEN" { return T_LISTEN; } +"LogFileBufferSize" { return T_STAT_BUFFER_SIZE; } +"DestroyTimeout" { return T_DESTROY_TIMEOUT; } +"McastSndSocketBuffer" { return T_SNDBUFF; /* deprecated */ } +"McastRcvSocketBuffer" { return T_RCVBUFF; /* deprecated */ } +"SndSocketBuffer" { return T_SNDBUFF; } +"RcvSocketBuffer" { return T_RCVBUFF; } +"Filter" { return T_FILTER; } +"Protocol" { return T_PROTOCOL; } +"Address" { return T_ADDRESS; } +"State" { return T_STATE; } +"Accept" { return T_ACCEPT; } +"Ignore" { return T_IGNORE; } +"PurgeTimeout" { return T_PURGE; } +"From" { return T_FROM; } +"Userspace" { return T_USERSPACE; } +"Kernelspace" { return T_KERNELSPACE; } +"EventIterationLimit" { return T_EVENT_ITER_LIMIT; } +"Default" { return T_DEFAULT; } +"PollSecs" { return T_POLL_SECS; } +"NetlinkOverrunResync" { return T_NETLINK_OVERRUN_RESYNC; } +"Nice" { return T_NICE; } +"Scheduler" { return T_SCHEDULER; } +"Type" { return T_TYPE; } +"Priority" { return T_PRIO; } +"NetlinkEventsReliable" { return T_NETLINK_EVENTS_RELIABLE; } +"DisableInternalCache" { return T_DISABLE_INTERNAL_CACHE; } +"DisableExternalCache" { return T_DISABLE_EXTERNAL_CACHE; } +"ErrorQueueLength" { return T_ERROR_QUEUE_LENGTH; } + +{is_on} { return T_ON; } +{is_off} { return T_OFF; } +{integer} { yylval.val = atoi(yytext); return T_NUMBER; } +{signed_integer} { yylval.val = atoi(yytext); return T_SIGNED_NUMBER; } +{ip4} { yylval.string = strdup(yytext); return T_IP; } +{ip6} { yylval.string = strdup(yytext); return T_IP; } +{path} { yylval.string = strdup(yytext); return T_PATH_VAL; } +{alarm} { return T_ALARM; } +{persistent} { fprintf(stderr, "\nWARNING: Now `persistent' mode " + "is called `alarm'. Please, update " + "your conntrackd.conf file.\n"); + return T_ALARM; } +{ftfw} { return T_FTFW; } +{nack} { fprintf(stderr, "\nWARNING: Now `nack' mode " + "is called `ftfw'. Please, update " + "your conntrackd.conf file.\n"); + return T_FTFW; } +{notrack} { return T_NOTRACK; } +{string} { yylval.string = strdup(yytext); return T_STRING; } + +{comment} ; +{ws} ; +{nl} ; + +<<EOF>> { yyterminate(); } + +. { return yytext[0]; } + +%% + +int +yywrap() +{ + return 1; +} diff --git a/src/read_config_yy.c b/src/read_config_yy.c new file mode 100644 index 0000000..bd3a785 --- /dev/null +++ b/src/read_config_yy.c @@ -0,0 +1,4051 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 1 "read_config_yy.y" + +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: configuration file abstract grammar + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <netdb.h> +#include <errno.h> +#include <stdarg.h> +#include "conntrackd.h" +#include "bitops.h" +#include "cidr.h" +#include <syslog.h> +#include <sched.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h> + +extern char *yytext; +extern int yylineno; + +struct ct_conf conf; + +enum { + CTD_CFG_ERROR = 0, + CTD_CFG_WARN, +}; + +static void print_err(int err, const char *msg, ...); + +static void __kernel_filter_start(void); +static void __kernel_filter_add_state(int value); +static void __max_dedicated_links_reached(void); + + +/* Line 189 of yacc.c */ +#line 126 "read_config_yy.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_IPV4_ADDR = 258, + T_IPV4_IFACE = 259, + T_PORT = 260, + T_HASHSIZE = 261, + T_HASHLIMIT = 262, + T_MULTICAST = 263, + T_PATH = 264, + T_UNIX = 265, + T_REFRESH = 266, + T_IPV6_ADDR = 267, + T_IPV6_IFACE = 268, + T_IGNORE_UDP = 269, + T_IGNORE_ICMP = 270, + T_IGNORE_TRAFFIC = 271, + T_BACKLOG = 272, + T_GROUP = 273, + T_LOG = 274, + T_UDP = 275, + T_ICMP = 276, + T_IGMP = 277, + T_VRRP = 278, + T_TCP = 279, + T_IGNORE_PROTOCOL = 280, + T_LOCK = 281, + T_STRIP_NAT = 282, + T_BUFFER_SIZE_MAX_GROWN = 283, + T_EXPIRE = 284, + T_TIMEOUT = 285, + T_GENERAL = 286, + T_SYNC = 287, + T_STATS = 288, + T_RELAX_TRANSITIONS = 289, + T_BUFFER_SIZE = 290, + T_DELAY = 291, + T_SYNC_MODE = 292, + T_LISTEN_TO = 293, + T_FAMILY = 294, + T_RESEND_BUFFER_SIZE = 295, + T_ALARM = 296, + T_FTFW = 297, + T_CHECKSUM = 298, + T_WINDOWSIZE = 299, + T_ON = 300, + T_OFF = 301, + T_REPLICATE = 302, + T_FOR = 303, + T_IFACE = 304, + T_PURGE = 305, + T_RESEND_QUEUE_SIZE = 306, + T_ESTABLISHED = 307, + T_SYN_SENT = 308, + T_SYN_RECV = 309, + T_FIN_WAIT = 310, + T_CLOSE_WAIT = 311, + T_LAST_ACK = 312, + T_TIME_WAIT = 313, + T_CLOSE = 314, + T_LISTEN = 315, + T_SYSLOG = 316, + T_WRITE_THROUGH = 317, + T_STAT_BUFFER_SIZE = 318, + T_DESTROY_TIMEOUT = 319, + T_RCVBUFF = 320, + T_SNDBUFF = 321, + T_NOTRACK = 322, + T_POLL_SECS = 323, + T_FILTER = 324, + T_ADDRESS = 325, + T_PROTOCOL = 326, + T_STATE = 327, + T_ACCEPT = 328, + T_IGNORE = 329, + T_FROM = 330, + T_USERSPACE = 331, + T_KERNELSPACE = 332, + T_EVENT_ITER_LIMIT = 333, + T_DEFAULT = 334, + T_NETLINK_OVERRUN_RESYNC = 335, + T_NICE = 336, + T_IPV4_DEST_ADDR = 337, + T_IPV6_DEST_ADDR = 338, + T_SCHEDULER = 339, + T_TYPE = 340, + T_PRIO = 341, + T_NETLINK_EVENTS_RELIABLE = 342, + T_DISABLE_INTERNAL_CACHE = 343, + T_DISABLE_EXTERNAL_CACHE = 344, + T_ERROR_QUEUE_LENGTH = 345, + T_IP = 346, + T_PATH_VAL = 347, + T_NUMBER = 348, + T_SIGNED_NUMBER = 349, + T_STRING = 350 + }; +#endif +/* Tokens. */ +#define T_IPV4_ADDR 258 +#define T_IPV4_IFACE 259 +#define T_PORT 260 +#define T_HASHSIZE 261 +#define T_HASHLIMIT 262 +#define T_MULTICAST 263 +#define T_PATH 264 +#define T_UNIX 265 +#define T_REFRESH 266 +#define T_IPV6_ADDR 267 +#define T_IPV6_IFACE 268 +#define T_IGNORE_UDP 269 +#define T_IGNORE_ICMP 270 +#define T_IGNORE_TRAFFIC 271 +#define T_BACKLOG 272 +#define T_GROUP 273 +#define T_LOG 274 +#define T_UDP 275 +#define T_ICMP 276 +#define T_IGMP 277 +#define T_VRRP 278 +#define T_TCP 279 +#define T_IGNORE_PROTOCOL 280 +#define T_LOCK 281 +#define T_STRIP_NAT 282 +#define T_BUFFER_SIZE_MAX_GROWN 283 +#define T_EXPIRE 284 +#define T_TIMEOUT 285 +#define T_GENERAL 286 +#define T_SYNC 287 +#define T_STATS 288 +#define T_RELAX_TRANSITIONS 289 +#define T_BUFFER_SIZE 290 +#define T_DELAY 291 +#define T_SYNC_MODE 292 +#define T_LISTEN_TO 293 +#define T_FAMILY 294 +#define T_RESEND_BUFFER_SIZE 295 +#define T_ALARM 296 +#define T_FTFW 297 +#define T_CHECKSUM 298 +#define T_WINDOWSIZE 299 +#define T_ON 300 +#define T_OFF 301 +#define T_REPLICATE 302 +#define T_FOR 303 +#define T_IFACE 304 +#define T_PURGE 305 +#define T_RESEND_QUEUE_SIZE 306 +#define T_ESTABLISHED 307 +#define T_SYN_SENT 308 +#define T_SYN_RECV 309 +#define T_FIN_WAIT 310 +#define T_CLOSE_WAIT 311 +#define T_LAST_ACK 312 +#define T_TIME_WAIT 313 +#define T_CLOSE 314 +#define T_LISTEN 315 +#define T_SYSLOG 316 +#define T_WRITE_THROUGH 317 +#define T_STAT_BUFFER_SIZE 318 +#define T_DESTROY_TIMEOUT 319 +#define T_RCVBUFF 320 +#define T_SNDBUFF 321 +#define T_NOTRACK 322 +#define T_POLL_SECS 323 +#define T_FILTER 324 +#define T_ADDRESS 325 +#define T_PROTOCOL 326 +#define T_STATE 327 +#define T_ACCEPT 328 +#define T_IGNORE 329 +#define T_FROM 330 +#define T_USERSPACE 331 +#define T_KERNELSPACE 332 +#define T_EVENT_ITER_LIMIT 333 +#define T_DEFAULT 334 +#define T_NETLINK_OVERRUN_RESYNC 335 +#define T_NICE 336 +#define T_IPV4_DEST_ADDR 337 +#define T_IPV6_DEST_ADDR 338 +#define T_SCHEDULER 339 +#define T_TYPE 340 +#define T_PRIO 341 +#define T_NETLINK_EVENTS_RELIABLE 342 +#define T_DISABLE_INTERNAL_CACHE 343 +#define T_DISABLE_EXTERNAL_CACHE 344 +#define T_ERROR_QUEUE_LENGTH 345 +#define T_IP 346 +#define T_PATH_VAL 347 +#define T_NUMBER 348 +#define T_SIGNED_NUMBER 349 +#define T_STRING 350 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 214 of yacc.c */ +#line 53 "read_config_yy.y" + + int val; + char *string; + + + +/* Line 214 of yacc.c */ +#line 359 "read_config_yy.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 264 of yacc.c */ +#line 371 "read_config_yy.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 21 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 332 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 98 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 94 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 234 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 367 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 350 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 96, 2, 97, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 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, 88, 89, 90, 91, 92, 93, 94, + 95 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 6, 8, 11, 13, 15, 17, + 19, 21, 23, 26, 29, 32, 35, 38, 41, 44, + 46, 49, 52, 55, 58, 61, 64, 69, 70, 73, + 76, 79, 84, 90, 91, 94, 97, 100, 103, 106, + 109, 112, 115, 118, 121, 124, 127, 132, 138, 139, + 142, 145, 148, 151, 154, 157, 160, 163, 166, 169, + 172, 177, 183, 184, 187, 190, 193, 196, 199, 202, + 205, 208, 211, 214, 217, 220, 223, 226, 231, 232, + 235, 238, 241, 246, 247, 250, 252, 254, 259, 260, + 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, + 283, 285, 287, 289, 291, 293, 295, 297, 303, 309, + 315, 316, 319, 321, 323, 325, 327, 329, 331, 332, + 335, 337, 339, 341, 343, 345, 347, 348, 351, 353, + 355, 357, 359, 362, 365, 368, 371, 374, 377, 380, + 383, 385, 387, 390, 395, 396, 399, 401, 403, 404, + 407, 409, 411, 413, 415, 417, 419, 421, 423, 425, + 428, 431, 436, 437, 440, 442, 444, 446, 448, 450, + 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, + 472, 474, 476, 479, 482, 485, 488, 491, 494, 497, + 500, 505, 506, 509, 512, 515, 518, 521, 524, 529, + 536, 543, 544, 547, 553, 559, 560, 563, 565, 567, + 573, 579, 580, 583, 586, 589, 595, 601, 602, 605, + 609, 614, 615, 618, 620, 622, 624, 626, 628, 631, + 634, 637, 640, 643, 646 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 99, 0, -1, -1, 100, -1, 101, -1, 100, 101, + -1, 130, -1, 113, -1, 107, -1, 161, -1, 133, + -1, 184, -1, 19, 45, -1, 19, 46, -1, 19, + 92, -1, 61, 45, -1, 61, 46, -1, 61, 95, + -1, 26, 92, -1, 27, -1, 11, 93, -1, 29, + 93, -1, 30, 93, -1, 50, 93, -1, 43, 45, + -1, 43, 46, -1, 16, 96, 114, 97, -1, -1, + 114, 115, -1, 3, 91, -1, 12, 91, -1, 8, + 96, 117, 97, -1, 8, 79, 96, 117, 97, -1, + -1, 117, 118, -1, 3, 91, -1, 12, 91, -1, + 4, 91, -1, 13, 91, -1, 49, 95, -1, 17, + 93, -1, 18, 93, -1, 66, 93, -1, 65, 93, + -1, 43, 45, -1, 43, 46, -1, 20, 96, 120, + 97, -1, 20, 79, 96, 120, 97, -1, -1, 120, + 121, -1, 3, 91, -1, 12, 91, -1, 82, 91, + -1, 83, 91, -1, 49, 95, -1, 5, 93, -1, + 66, 93, -1, 65, 93, -1, 43, 45, -1, 43, + 46, -1, 24, 96, 123, 97, -1, 24, 79, 96, + 123, 97, -1, -1, 123, 124, -1, 3, 91, -1, + 12, 91, -1, 82, 91, -1, 83, 91, -1, 49, + 95, -1, 5, 93, -1, 66, 93, -1, 65, 93, + -1, 43, 45, -1, 43, 46, -1, 90, 93, -1, + 6, 93, -1, 7, 93, -1, 10, 96, 128, 97, + -1, -1, 128, 129, -1, 9, 92, -1, 17, 93, + -1, 25, 96, 131, 97, -1, -1, 131, 132, -1, + 93, -1, 95, -1, 32, 96, 134, 97, -1, -1, + 134, 135, -1, 108, -1, 109, -1, 110, -1, 111, + -1, 112, -1, 116, -1, 119, -1, 122, -1, 151, + -1, 152, -1, 136, -1, 137, -1, 138, -1, 153, + -1, 154, -1, 160, -1, 150, -1, 37, 41, 96, + 139, 97, -1, 37, 42, 96, 141, 97, -1, 37, + 67, 96, 143, 97, -1, -1, 139, 140, -1, 108, + -1, 109, -1, 110, -1, 111, -1, 151, -1, 152, + -1, -1, 141, 142, -1, 148, -1, 147, -1, 110, + -1, 111, -1, 149, -1, 146, -1, -1, 143, 144, + -1, 110, -1, 111, -1, 145, -1, 146, -1, 88, + 45, -1, 88, 46, -1, 89, 45, -1, 89, 46, + -1, 40, 93, -1, 51, 93, -1, 44, 93, -1, + 64, 93, -1, 34, -1, 36, -1, 38, 91, -1, + 47, 155, 48, 156, -1, -1, 155, 157, -1, 95, + -1, 159, -1, -1, 158, 159, -1, 53, -1, 54, + -1, 52, -1, 55, -1, 56, -1, 57, -1, 58, + -1, 59, -1, 60, -1, 62, 45, -1, 62, 46, + -1, 31, 96, 162, 97, -1, -1, 162, 163, -1, + 125, -1, 126, -1, 102, -1, 103, -1, 105, -1, + 104, -1, 106, -1, 127, -1, 164, -1, 165, -1, + 172, -1, 173, -1, 174, -1, 175, -1, 166, -1, + 167, -1, 168, -1, 169, -1, 35, 93, -1, 28, + 93, -1, 80, 45, -1, 80, 46, -1, 80, 93, + -1, 87, 45, -1, 87, 46, -1, 81, 94, -1, + 84, 96, 170, 97, -1, -1, 170, 171, -1, 85, + 95, -1, 86, 93, -1, 39, 95, -1, 78, 93, + -1, 68, 93, -1, 69, 96, 176, 97, -1, 69, + 75, 76, 96, 176, 97, -1, 69, 75, 77, 96, + 176, 97, -1, -1, 176, 177, -1, 71, 73, 96, + 178, 97, -1, 71, 74, 96, 178, 97, -1, -1, + 178, 179, -1, 95, -1, 24, -1, 70, 73, 96, + 180, 97, -1, 70, 74, 96, 180, 97, -1, -1, + 180, 181, -1, 3, 91, -1, 12, 91, -1, 72, + 73, 96, 182, 97, -1, 72, 74, 96, 182, 97, + -1, -1, 182, 183, -1, 158, 48, 24, -1, 33, + 96, 185, 97, -1, -1, 185, 186, -1, 187, -1, + 188, -1, 189, -1, 190, -1, 191, -1, 19, 45, + -1, 19, 46, -1, 19, 92, -1, 61, 45, -1, + 61, 46, -1, 61, 95, -1, 63, 93, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 84, 84, 85, 88, 89, 92, 93, 94, 95, + 96, 97, 100, 105, 109, 114, 119, 124, 156, 161, + 166, 171, 176, 181, 186, 197, 208, 218, 219, 221, + 243, 269, 283, 299, 300, 302, 321, 361, 380, 385, + 405, 412, 418, 424, 430, 436, 442, 456, 472, 473, + 475, 486, 503, 514, 531, 546, 552, 558, 564, 570, + 576, 592, 610, 611, 613, 624, 641, 652, 669, 684, + 690, 696, 702, 708, 714, 720, 725, 730, 732, 733, + 736, 741, 746, 756, 757, 760, 768, 781, 791, 792, + 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, + 804, 805, 806, 807, 808, 809, 810, 813, 818, 823, + 828, 829, 831, 832, 833, 834, 835, 836, 839, 840, + 842, 843, 844, 845, 846, 847, 850, 851, 853, 854, + 855, 856, 859, 864, 869, 874, 879, 885, 890, 895, + 900, 906, 912, 917, 927, 928, 930, 937, 939, 940, + 942, 950, 958, 966, 974, 982, 990, 998, 1006, 1015, + 1021, 1027, 1029, 1030, 1033, 1034, 1035, 1036, 1037, 1038, + 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, + 1049, 1050, 1053, 1058, 1063, 1068, 1073, 1078, 1083, 1088, + 1093, 1095, 1096, 1099, 1111, 1120, 1128, 1133, 1143, 1148, + 1153, 1158, 1159, 1161, 1170, 1183, 1184, 1186, 1205, 1224, + 1233, 1255, 1256, 1258, 1317, 1377, 1386, 1400, 1401, 1403, + 1405, 1415, 1416, 1419, 1420, 1421, 1422, 1423, 1426, 1431, + 1435, 1440, 1445, 1450, 1482 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_IPV4_ADDR", "T_IPV4_IFACE", "T_PORT", + "T_HASHSIZE", "T_HASHLIMIT", "T_MULTICAST", "T_PATH", "T_UNIX", + "T_REFRESH", "T_IPV6_ADDR", "T_IPV6_IFACE", "T_IGNORE_UDP", + "T_IGNORE_ICMP", "T_IGNORE_TRAFFIC", "T_BACKLOG", "T_GROUP", "T_LOG", + "T_UDP", "T_ICMP", "T_IGMP", "T_VRRP", "T_TCP", "T_IGNORE_PROTOCOL", + "T_LOCK", "T_STRIP_NAT", "T_BUFFER_SIZE_MAX_GROWN", "T_EXPIRE", + "T_TIMEOUT", "T_GENERAL", "T_SYNC", "T_STATS", "T_RELAX_TRANSITIONS", + "T_BUFFER_SIZE", "T_DELAY", "T_SYNC_MODE", "T_LISTEN_TO", "T_FAMILY", + "T_RESEND_BUFFER_SIZE", "T_ALARM", "T_FTFW", "T_CHECKSUM", + "T_WINDOWSIZE", "T_ON", "T_OFF", "T_REPLICATE", "T_FOR", "T_IFACE", + "T_PURGE", "T_RESEND_QUEUE_SIZE", "T_ESTABLISHED", "T_SYN_SENT", + "T_SYN_RECV", "T_FIN_WAIT", "T_CLOSE_WAIT", "T_LAST_ACK", "T_TIME_WAIT", + "T_CLOSE", "T_LISTEN", "T_SYSLOG", "T_WRITE_THROUGH", + "T_STAT_BUFFER_SIZE", "T_DESTROY_TIMEOUT", "T_RCVBUFF", "T_SNDBUFF", + "T_NOTRACK", "T_POLL_SECS", "T_FILTER", "T_ADDRESS", "T_PROTOCOL", + "T_STATE", "T_ACCEPT", "T_IGNORE", "T_FROM", "T_USERSPACE", + "T_KERNELSPACE", "T_EVENT_ITER_LIMIT", "T_DEFAULT", + "T_NETLINK_OVERRUN_RESYNC", "T_NICE", "T_IPV4_DEST_ADDR", + "T_IPV6_DEST_ADDR", "T_SCHEDULER", "T_TYPE", "T_PRIO", + "T_NETLINK_EVENTS_RELIABLE", "T_DISABLE_INTERNAL_CACHE", + "T_DISABLE_EXTERNAL_CACHE", "T_ERROR_QUEUE_LENGTH", "T_IP", "T_PATH_VAL", + "T_NUMBER", "T_SIGNED_NUMBER", "T_STRING", "'{'", "'}'", "$accept", + "configfile", "lines", "line", "logfile_bool", "logfile_path", + "syslog_bool", "syslog_facility", "lock", "strip_nat", "refreshtime", + "expiretime", "timeout", "purge", "checksum", "ignore_traffic", + "ignore_traffic_options", "ignore_traffic_option", "multicast_line", + "multicast_options", "multicast_option", "udp_line", "udp_options", + "udp_option", "tcp_line", "tcp_options", "tcp_option", "hashsize", + "hashlimit", "unix_line", "unix_options", "unix_option", + "ignore_protocol", "ignore_proto_list", "ignore_proto", "sync", + "sync_list", "sync_line", "sync_mode_alarm", "sync_mode_ftfw", + "sync_mode_notrack", "sync_mode_alarm_list", "sync_mode_alarm_line", + "sync_mode_ftfw_list", "sync_mode_ftfw_line", "sync_mode_notrack_list", + "sync_mode_notrack_line", "disable_internal_cache", + "disable_external_cache", "resend_buffer_size", "resend_queue_size", + "window_size", "destroy_timeout", "relax_transitions", + "delay_destroy_msgs", "listen_to", "state_replication", "states", + "state_proto", "state", "tcp_states", "tcp_state", "cache_writethrough", + "general", "general_list", "general_line", "netlink_buffer_size", + "netlink_buffer_size_max_grown", "netlink_overrun_resync", + "netlink_events_reliable", "nice", "scheduler", "scheduler_options", + "scheduler_line", "family", "event_iterations_limit", "poll_secs", + "filter", "filter_list", "filter_item", "filter_protocol_list", + "filter_protocol_item", "filter_address_list", "filter_address_item", + "filter_state_list", "filter_state_item", "stats", "stats_list", + "stat_line", "stat_logfile_bool", "stat_logfile_path", + "stat_syslog_bool", "stat_syslog_facility", "buffer_size", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 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, 123, 125 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 98, 99, 99, 100, 100, 101, 101, 101, 101, + 101, 101, 102, 102, 103, 104, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 112, 113, 114, 114, 115, + 115, 116, 116, 117, 117, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 119, 119, 120, 120, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 122, 122, 123, 123, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 125, 126, 127, 128, 128, + 129, 129, 130, 131, 131, 132, 132, 133, 134, 134, + 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, + 135, 135, 135, 135, 135, 135, 135, 136, 137, 138, + 139, 139, 140, 140, 140, 140, 140, 140, 141, 141, + 142, 142, 142, 142, 142, 142, 143, 143, 144, 144, + 144, 144, 145, 145, 146, 146, 147, 148, 149, 150, + 151, 152, 153, 154, 155, 155, 156, 157, 158, 158, + 159, 159, 159, 159, 159, 159, 159, 159, 159, 160, + 160, 161, 162, 162, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 164, 165, 166, 166, 166, 167, 167, 168, + 169, 170, 170, 171, 171, 172, 173, 174, 175, 175, + 175, 176, 176, 177, 177, 178, 178, 179, 179, 177, + 177, 180, 180, 181, 181, 177, 177, 182, 182, 183, + 184, 185, 185, 186, 186, 186, 186, 186, 187, 187, + 188, 189, 189, 190, 191 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 1, 2, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, + 2, 2, 2, 2, 2, 2, 4, 0, 2, 2, + 2, 4, 5, 0, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 4, 5, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 4, 5, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 4, 0, 2, + 2, 2, 4, 0, 2, 1, 1, 4, 0, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, + 0, 2, 1, 1, 1, 1, 1, 1, 0, 2, + 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 2, 4, 0, 2, 1, 1, 0, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 4, 0, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, + 4, 0, 2, 2, 2, 2, 2, 2, 4, 6, + 6, 0, 2, 5, 5, 0, 2, 1, 1, 5, + 5, 0, 2, 2, 2, 5, 5, 0, 2, 3, + 4, 0, 2, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 0, 19, 0, 0, 0, 0, 3, 4, + 8, 7, 6, 10, 9, 11, 27, 83, 162, 88, + 221, 1, 5, 0, 0, 0, 0, 0, 0, 0, + 26, 28, 85, 86, 82, 84, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 161, 166, 167, 169, 168, 170, 164, 165, + 171, 163, 172, 173, 178, 179, 180, 181, 174, 175, + 176, 177, 0, 0, 0, 0, 0, 0, 140, 141, + 0, 0, 0, 144, 0, 0, 0, 87, 90, 91, + 92, 93, 94, 95, 96, 97, 89, 100, 101, 102, + 106, 98, 99, 103, 104, 105, 0, 0, 0, 220, + 222, 223, 224, 225, 226, 227, 29, 30, 75, 76, + 78, 12, 13, 14, 18, 183, 182, 195, 15, 16, + 17, 197, 0, 201, 196, 184, 185, 186, 189, 191, + 187, 188, 0, 33, 20, 0, 48, 0, 62, 21, + 22, 0, 0, 0, 142, 24, 25, 0, 23, 159, + 160, 139, 228, 229, 230, 231, 232, 233, 234, 0, + 0, 0, 0, 0, 33, 0, 48, 0, 62, 0, + 110, 118, 126, 0, 152, 150, 151, 153, 154, 155, + 156, 157, 158, 145, 147, 0, 0, 77, 79, 201, + 201, 0, 0, 0, 198, 202, 0, 0, 190, 192, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 31, 34, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 46, 49, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 60, 63, 0, 0, + 0, 146, 143, 80, 81, 0, 0, 0, 0, 0, + 0, 0, 0, 193, 194, 32, 35, 37, 36, 38, + 40, 41, 44, 45, 39, 43, 42, 47, 50, 55, + 51, 58, 59, 54, 57, 56, 52, 53, 61, 64, + 69, 65, 72, 73, 68, 71, 70, 66, 67, 74, + 107, 112, 113, 114, 115, 111, 116, 117, 0, 0, + 0, 0, 108, 122, 123, 119, 125, 121, 120, 124, + 0, 109, 128, 129, 127, 130, 131, 199, 200, 211, + 211, 205, 205, 217, 217, 136, 138, 137, 134, 135, + 132, 133, 0, 0, 0, 0, 148, 148, 0, 0, + 209, 212, 210, 208, 207, 203, 206, 204, 215, 0, + 218, 216, 213, 214, 0, 149, 219 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 7, 8, 9, 53, 54, 55, 56, 57, 10, + 88, 89, 90, 91, 92, 11, 23, 31, 93, 175, + 222, 94, 177, 234, 95, 179, 247, 58, 59, 60, + 169, 198, 12, 24, 35, 13, 26, 96, 97, 98, + 99, 248, 305, 249, 315, 250, 324, 325, 316, 317, + 318, 319, 100, 101, 102, 103, 104, 157, 252, 193, + 359, 194, 105, 14, 25, 61, 62, 63, 64, 65, + 66, 67, 173, 209, 68, 69, 70, 71, 172, 205, + 344, 356, 342, 351, 346, 360, 15, 27, 110, 111, + 112, 113, 114, 115 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -94 +static const yytype_int16 yypact[] = +{ + 193, -93, -90, -94, -84, -77, -70, 52, 193, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, 15, 115, 119, 155, 24, -24, -13, + -94, -94, -94, -94, -94, -94, 2, 20, 28, 60, + 38, 23, 42, 49, -7, 62, -52, 97, 53, 59, + 105, 26, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -47, 101, -38, -23, 111, 114, -94, -94, + 13, 76, 30, -94, 118, 65, 135, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, 104, 5, 137, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, 88, -94, -94, -94, -94, -94, -94, -94, + -94, -94, 171, -94, -94, 172, -94, 173, -94, -94, + -94, 174, 175, 176, -94, -94, -94, 179, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -4, + 177, 178, -36, 84, -94, -3, -94, 54, -94, -1, + -94, -94, -94, 180, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, 184, 185, -94, -94, -94, + -94, 100, 149, 170, -94, -94, 182, 186, -94, -94, + 4, 189, 190, 191, 192, 194, 195, 200, 196, 197, + 199, -94, -94, 74, 198, 203, 204, 202, 206, 207, + 209, 208, 212, -94, -94, 25, 213, 214, 215, 205, + 210, 216, 218, 221, 222, 223, -94, -94, 98, 132, + -5, -94, -94, -94, -94, 71, 89, 188, 224, 225, + 226, 227, 228, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, 232, 233, + 234, 217, -94, -94, -94, -94, -94, -94, -94, -94, + 219, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, 17, 21, 7, 36, 169, 211, 237, 238, + -94, -94, -94, -94, -94, -94, -94, -94, -94, 201, + -94, -94, -94, -94, 261, -94, -94 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -94, -94, -94, 278, -94, -94, -94, -94, -94, -94, + 45, 46, -35, -8, -94, -94, -94, -94, -94, 123, + -94, -94, 122, -94, -94, 136, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, 67, -94, + -94, -94, -94, 70, 82, -94, -94, -94, -94, -94, + -94, -49, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -22, -94, + -17, -94, -11, -94, -2, -94, -94, -94, -94, -94, + -94, -94, -94, -94 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint16 yytable[] = +{ + 211, 212, 236, 16, 237, 195, 17, 211, 212, 213, + 214, 238, 18, 196, 215, 216, 213, 214, 28, 19, + 348, 215, 216, 132, 348, 77, 20, 29, 236, 349, + 237, 353, 142, 349, 201, 202, 203, 238, 128, 129, + 217, 145, 239, 106, 133, 84, 218, 217, 240, 143, + 165, 166, 21, 218, 151, 152, 147, 224, 146, 225, + 353, 204, 219, 220, 241, 242, 226, 116, 239, 219, + 220, 140, 141, 148, 240, 155, 156, 224, 117, 225, + 153, 243, 244, 320, 311, 107, 226, 108, 130, 245, + 241, 242, 321, 197, 221, 118, 246, 227, 135, 136, + 167, 265, 354, 228, 355, 121, 122, 243, 244, 73, + 159, 160, 30, 119, 350, 245, 125, 227, 352, 229, + 230, 109, 288, 228, 120, 36, 37, 76, 77, 38, + 124, 354, 78, 357, 79, 126, 231, 232, 39, 229, + 230, 201, 202, 203, 127, 40, 137, 41, 84, 162, + 163, 233, 123, 138, 42, 131, 231, 232, 43, 201, + 202, 203, 77, 72, 170, 171, 73, 154, 327, 206, + 207, 277, 308, 257, 258, 74, 309, 255, 256, 75, + 44, 208, 84, 310, 76, 77, 328, 45, 46, 78, + 134, 79, 80, 81, 144, 300, 164, 47, 82, 48, + 49, 139, 83, 50, 149, 84, 51, 150, 32, 1, + 33, 158, 34, 303, 313, 322, 52, 85, 2, 86, + 3, 311, 259, 260, 4, 5, 6, 183, 161, 312, + 168, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 304, 314, 323, 261, 262, 272, 273, 281, 282, 364, + 292, 293, 87, 184, 185, 186, 187, 188, 189, 190, + 191, 192, 338, 339, 340, 341, 358, 174, 176, 178, + 180, 181, 182, 199, 200, 251, 253, 263, 254, 264, + 266, 267, 268, 269, 329, 366, 22, 270, 271, 278, + 275, 274, 276, 301, 302, 280, 279, 210, 223, 286, + 284, 283, 285, 287, 289, 294, 291, 290, 361, 295, + 365, 296, 297, 298, 235, 345, 299, 326, 306, 343, + 330, 331, 332, 333, 334, 335, 336, 337, 362, 363, + 307, 0, 347 +}; + +static const yytype_int16 yycheck[] = +{ + 3, 4, 3, 96, 5, 9, 96, 3, 4, 12, + 13, 12, 96, 17, 17, 18, 12, 13, 3, 96, + 3, 17, 18, 75, 3, 30, 96, 12, 3, 12, + 5, 24, 79, 12, 70, 71, 72, 12, 45, 46, + 43, 79, 43, 19, 96, 50, 49, 43, 49, 96, + 45, 46, 0, 49, 41, 42, 79, 3, 96, 5, + 24, 97, 65, 66, 65, 66, 12, 91, 43, 65, + 66, 45, 46, 96, 49, 45, 46, 3, 91, 5, + 67, 82, 83, 88, 89, 61, 12, 63, 95, 90, + 65, 66, 97, 97, 97, 93, 97, 43, 45, 46, + 95, 97, 95, 49, 97, 45, 46, 82, 83, 11, + 45, 46, 97, 93, 97, 90, 93, 43, 97, 65, + 66, 97, 97, 49, 96, 6, 7, 29, 30, 10, + 92, 95, 34, 97, 36, 93, 82, 83, 19, 65, + 66, 70, 71, 72, 95, 26, 93, 28, 50, 45, + 46, 97, 92, 94, 35, 93, 82, 83, 39, 70, + 71, 72, 30, 8, 76, 77, 11, 91, 97, 85, + 86, 97, 40, 73, 74, 20, 44, 199, 200, 24, + 61, 97, 50, 51, 29, 30, 97, 68, 69, 34, + 93, 36, 37, 38, 93, 97, 92, 78, 43, 80, + 81, 96, 47, 84, 93, 50, 87, 93, 93, 16, + 95, 93, 97, 248, 249, 250, 97, 62, 25, 64, + 27, 89, 73, 74, 31, 32, 33, 48, 93, 97, + 93, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 248, 249, 250, 73, 74, 45, 46, 45, 46, 48, + 45, 46, 97, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 45, 46, 45, 46, 97, 96, 96, 96, + 96, 96, 96, 96, 96, 95, 92, 95, 93, 93, + 91, 91, 91, 91, 96, 24, 8, 93, 93, 91, + 93, 95, 93, 248, 248, 91, 93, 174, 176, 91, + 93, 95, 93, 91, 91, 95, 91, 93, 97, 93, + 359, 93, 91, 91, 178, 332, 93, 250, 248, 330, + 96, 96, 96, 96, 96, 93, 93, 93, 91, 91, + 248, -1, 334 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 16, 25, 27, 31, 32, 33, 99, 100, 101, + 107, 113, 130, 133, 161, 184, 96, 96, 96, 96, + 96, 0, 101, 114, 131, 162, 134, 185, 3, 12, + 97, 115, 93, 95, 97, 132, 6, 7, 10, 19, + 26, 28, 35, 39, 61, 68, 69, 78, 80, 81, + 84, 87, 97, 102, 103, 104, 105, 106, 125, 126, + 127, 163, 164, 165, 166, 167, 168, 169, 172, 173, + 174, 175, 8, 11, 20, 24, 29, 30, 34, 36, + 37, 38, 43, 47, 50, 62, 64, 97, 108, 109, + 110, 111, 112, 116, 119, 122, 135, 136, 137, 138, + 150, 151, 152, 153, 154, 160, 19, 61, 63, 97, + 186, 187, 188, 189, 190, 191, 91, 91, 93, 93, + 96, 45, 46, 92, 92, 93, 93, 95, 45, 46, + 95, 93, 75, 96, 93, 45, 46, 93, 94, 96, + 45, 46, 79, 96, 93, 79, 96, 79, 96, 93, + 93, 41, 42, 67, 91, 45, 46, 155, 93, 45, + 46, 93, 45, 46, 92, 45, 46, 95, 93, 128, + 76, 77, 176, 170, 96, 117, 96, 120, 96, 123, + 96, 96, 96, 48, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 157, 159, 9, 17, 97, 129, 96, + 96, 70, 71, 72, 97, 177, 85, 86, 97, 171, + 117, 3, 4, 12, 13, 17, 18, 43, 49, 65, + 66, 97, 118, 120, 3, 5, 12, 43, 49, 65, + 66, 82, 83, 97, 121, 123, 3, 5, 12, 43, + 49, 65, 66, 82, 83, 90, 97, 124, 139, 141, + 143, 95, 156, 92, 93, 176, 176, 73, 74, 73, + 74, 73, 74, 95, 93, 97, 91, 91, 91, 91, + 93, 93, 45, 46, 95, 93, 93, 97, 91, 93, + 91, 45, 46, 95, 93, 93, 91, 91, 97, 91, + 93, 91, 45, 46, 95, 93, 93, 91, 91, 93, + 97, 108, 109, 110, 111, 140, 151, 152, 40, 44, + 51, 89, 97, 110, 111, 142, 146, 147, 148, 149, + 88, 97, 110, 111, 144, 145, 146, 97, 97, 96, + 96, 96, 96, 96, 96, 93, 93, 93, 45, 46, + 45, 46, 180, 180, 178, 178, 182, 182, 3, 12, + 97, 181, 97, 24, 95, 97, 179, 97, 97, 158, + 183, 97, 91, 91, 48, 159, 24 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 12: + +/* Line 1455 of yacc.c */ +#line 101 "read_config_yy.y" + { + strncpy(conf.logfile, DEFAULT_LOGFILE, FILENAME_MAXLEN); +} + break; + + case 13: + +/* Line 1455 of yacc.c */ +#line 106 "read_config_yy.y" + { +} + break; + + case 14: + +/* Line 1455 of yacc.c */ +#line 110 "read_config_yy.y" + { + strncpy(conf.logfile, (yyvsp[(2) - (2)].string), FILENAME_MAXLEN); +} + break; + + case 15: + +/* Line 1455 of yacc.c */ +#line 115 "read_config_yy.y" + { + conf.syslog_facility = DEFAULT_SYSLOG_FACILITY; +} + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 120 "read_config_yy.y" + { + conf.syslog_facility = -1; +} + break; + + case 17: + +/* Line 1455 of yacc.c */ +#line 125 "read_config_yy.y" + { + if (!strcmp((yyvsp[(2) - (2)].string), "daemon")) + conf.syslog_facility = LOG_DAEMON; + else if (!strcmp((yyvsp[(2) - (2)].string), "local0")) + conf.syslog_facility = LOG_LOCAL0; + else if (!strcmp((yyvsp[(2) - (2)].string), "local1")) + conf.syslog_facility = LOG_LOCAL1; + else if (!strcmp((yyvsp[(2) - (2)].string), "local2")) + conf.syslog_facility = LOG_LOCAL2; + else if (!strcmp((yyvsp[(2) - (2)].string), "local3")) + conf.syslog_facility = LOG_LOCAL3; + else if (!strcmp((yyvsp[(2) - (2)].string), "local4")) + conf.syslog_facility = LOG_LOCAL4; + else if (!strcmp((yyvsp[(2) - (2)].string), "local5")) + conf.syslog_facility = LOG_LOCAL5; + else if (!strcmp((yyvsp[(2) - (2)].string), "local6")) + conf.syslog_facility = LOG_LOCAL6; + else if (!strcmp((yyvsp[(2) - (2)].string), "local7")) + conf.syslog_facility = LOG_LOCAL7; + else { + print_err(CTD_CFG_WARN, "'%s' is not a known syslog facility, " + "ignoring", (yyvsp[(2) - (2)].string)); + break; + } + + if (conf.stats.syslog_facility != -1 && + conf.syslog_facility != conf.stats.syslog_facility) + print_err(CTD_CFG_WARN, "conflicting Syslog facility " + "values, defaulting to General"); +} + break; + + case 18: + +/* Line 1455 of yacc.c */ +#line 157 "read_config_yy.y" + { + strncpy(conf.lockfile, (yyvsp[(2) - (2)].string), FILENAME_MAXLEN); +} + break; + + case 19: + +/* Line 1455 of yacc.c */ +#line 162 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`StripNAT' clause is obsolete, ignoring"); +} + break; + + case 20: + +/* Line 1455 of yacc.c */ +#line 167 "read_config_yy.y" + { + conf.refresh = (yyvsp[(2) - (2)].val); +} + break; + + case 21: + +/* Line 1455 of yacc.c */ +#line 172 "read_config_yy.y" + { + conf.cache_timeout = (yyvsp[(2) - (2)].val); +} + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 177 "read_config_yy.y" + { + conf.commit_timeout = (yyvsp[(2) - (2)].val); +} + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 182 "read_config_yy.y" + { + conf.purge_timeout = (yyvsp[(2) - (2)].val); +} + break; + + case 24: + +/* Line 1455 of yacc.c */ +#line 187 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "the use of `Checksum' outside the " + "`Multicast' clause is ambiguous"); + /* + * XXX: The use of Checksum outside of the Multicast clause is broken + * if we have more than one dedicated links. + */ + conf.channel[0].u.mcast.checksum = 0; +} + break; + + case 25: + +/* Line 1455 of yacc.c */ +#line 198 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "the use of `Checksum' outside the " + "`Multicast' clause is ambiguous"); + /* + * XXX: The use of Checksum outside of the Multicast clause is broken + * if we have more than one dedicated links. + */ + conf.channel[0].u.mcast.checksum = 1; +} + break; + + case 26: + +/* Line 1455 of yacc.c */ +#line 209 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_ADDRESS, + CT_FILTER_NEGATIVE); + + print_err(CTD_CFG_WARN, "the clause `IgnoreTrafficFor' is obsolete. " + "Use `Filter' instead"); +} + break; + + case 29: + +/* Line 1455 of yacc.c */ +#line 222 "read_config_yy.y" + { + union inet_address ip; + + memset(&ip, 0, sizeof(union inet_address)); + + if (!inet_aton((yyvsp[(2) - (2)].string), &ip.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4, " + "ignoring", (yyvsp[(2) - (2)].string)); + break; + } + + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated " + "in the ignore pool", (yyvsp[(2) - (2)].string)); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } +} + break; + + case 30: + +/* Line 1455 of yacc.c */ +#line 244 "read_config_yy.y" + { + union inet_address ip; + + memset(&ip, 0, sizeof(union inet_address)); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), &ip.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6, ignoring", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); +#endif + + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET6)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated " + "in the ignore pool", (yyvsp[(2) - (2)].string)); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } + +} + break; + + case 31: + +/* Line 1455 of yacc.c */ +#line 270 "read_config_yy.y" + { + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_MCAST) { + print_err(CTD_CFG_ERROR, "cannot use `Multicast' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_type = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_BUFFERED; + conf.channel_num++; +} + break; + + case 32: + +/* Line 1455 of yacc.c */ +#line 284 "read_config_yy.y" + { + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_MCAST) { + print_err(CTD_CFG_ERROR, "cannot use `Multicast' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_type = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_DEFAULT | + CHANNEL_F_BUFFERED; + conf.channel_default = conf.channel_num; + conf.channel_num++; +} + break; + + case 35: + +/* Line 1455 of yacc.c */ +#line 303 "read_config_yy.y" + { + __max_dedicated_links_reached(); + + if (!inet_aton((yyvsp[(2) - (2)].string), &conf.channel[conf.channel_num].u.mcast.in)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", (yyvsp[(2) - (2)].string)); + break; + } + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET6) { + print_err(CTD_CFG_WARN, "your multicast address is IPv4 but " + "is binded to an IPv6 interface? " + "Surely, this is not what you want"); + break; + } + + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET; +} + break; + + case 36: + +/* Line 1455 of yacc.c */ +#line 322 "read_config_yy.y" + { + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), + &conf.channel[conf.channel_num].u.mcast.in) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET) { + print_err(CTD_CFG_WARN, "your multicast address is IPv6 but " + "is binded to an IPv4 interface? " + "Surely this is not what you want"); + break; + } + + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET6; + + if (conf.channel[conf.channel_num].channel_ifname[0] && + !conf.channel[conf.channel_num].u.mcast.ifa.interface_index6) { + unsigned int idx; + + idx = if_nametoindex((yyvsp[(2) - (2)].string)); + if (!idx) { + print_err(CTD_CFG_WARN, + "%s is an invalid interface", (yyvsp[(2) - (2)].string)); + break; + } + + conf.channel[conf.channel_num].u.mcast.ifa.interface_index6 = idx; + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET6; + } +} + break; + + case 37: + +/* Line 1455 of yacc.c */ +#line 362 "read_config_yy.y" + { + __max_dedicated_links_reached(); + + if (!inet_aton((yyvsp[(2) - (2)].string), &conf.channel[conf.channel_num].u.mcast.ifa)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", (yyvsp[(2) - (2)].string)); + break; + } + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET6) { + print_err(CTD_CFG_WARN, "your multicast interface is IPv4 but " + "is binded to an IPv6 interface? " + "Surely, this is not what you want"); + break; + } + + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET; +} + break; + + case 38: + +/* Line 1455 of yacc.c */ +#line 381 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`IPv6_interface' not required, ignoring"); +} + break; + + case 39: + +/* Line 1455 of yacc.c */ +#line 386 "read_config_yy.y" + { + unsigned int idx; + + __max_dedicated_links_reached(); + + strncpy(conf.channel[conf.channel_num].channel_ifname, (yyvsp[(2) - (2)].string), IFNAMSIZ); + + idx = if_nametoindex((yyvsp[(2) - (2)].string)); + if (!idx) { + print_err(CTD_CFG_WARN, "%s is an invalid interface", (yyvsp[(2) - (2)].string)); + break; + } + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET6) { + conf.channel[conf.channel_num].u.mcast.ifa.interface_index6 = idx; + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET6; + } +} + break; + + case 40: + +/* Line 1455 of yacc.c */ +#line 406 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`Backlog' option inside Multicast clause is " + "obsolete. Please, remove it from " + "conntrackd.conf"); +} + break; + + case 41: + +/* Line 1455 of yacc.c */ +#line 413 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.port = (yyvsp[(2) - (2)].val); +} + break; + + case 42: + +/* Line 1455 of yacc.c */ +#line 419 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.sndbuf = (yyvsp[(2) - (2)].val); +} + break; + + case 43: + +/* Line 1455 of yacc.c */ +#line 425 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.rcvbuf = (yyvsp[(2) - (2)].val); +} + break; + + case 44: + +/* Line 1455 of yacc.c */ +#line 431 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.checksum = 0; +} + break; + + case 45: + +/* Line 1455 of yacc.c */ +#line 437 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.checksum = 1; +} + break; + + case 46: + +/* Line 1455 of yacc.c */ +#line 443 "read_config_yy.y" + { + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_UDP) { + print_err(CTD_CFG_ERROR, "cannot use `UDP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_type = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_BUFFERED; + conf.channel_num++; +} + break; + + case 47: + +/* Line 1455 of yacc.c */ +#line 457 "read_config_yy.y" + { + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_UDP) { + print_err(CTD_CFG_ERROR, "cannot use `UDP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_type = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_DEFAULT | + CHANNEL_F_BUFFERED; + conf.channel_default = conf.channel_num; + conf.channel_num++; +} + break; + + case 50: + +/* Line 1455 of yacc.c */ +#line 476 "read_config_yy.y" + { + __max_dedicated_links_reached(); + + if (!inet_aton((yyvsp[(2) - (2)].string), &conf.channel[conf.channel_num].u.udp.server.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", (yyvsp[(2) - (2)].string)); + break; + } + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET; +} + break; + + case 51: + +/* Line 1455 of yacc.c */ +#line 487 "read_config_yy.y" + { + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), + &conf.channel[conf.channel_num].u.udp.server.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET6; +} + break; + + case 52: + +/* Line 1455 of yacc.c */ +#line 504 "read_config_yy.y" + { + __max_dedicated_links_reached(); + + if (!inet_aton((yyvsp[(2) - (2)].string), &conf.channel[conf.channel_num].u.udp.client)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", (yyvsp[(2) - (2)].string)); + break; + } + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET; +} + break; + + case 53: + +/* Line 1455 of yacc.c */ +#line 515 "read_config_yy.y" + { + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), + &conf.channel[conf.channel_num].u.udp.client) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET6; +} + break; + + case 54: + +/* Line 1455 of yacc.c */ +#line 532 "read_config_yy.y" + { + int idx; + + __max_dedicated_links_reached(); + strncpy(conf.channel[conf.channel_num].channel_ifname, (yyvsp[(2) - (2)].string), IFNAMSIZ); + + idx = if_nametoindex((yyvsp[(2) - (2)].string)); + if (!idx) { + print_err(CTD_CFG_WARN, "%s is an invalid interface", (yyvsp[(2) - (2)].string)); + break; + } + conf.channel[conf.channel_num].u.udp.server.ipv6.scope_id = idx; +} + break; + + case 55: + +/* Line 1455 of yacc.c */ +#line 547 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.port = (yyvsp[(2) - (2)].val); +} + break; + + case 56: + +/* Line 1455 of yacc.c */ +#line 553 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.sndbuf = (yyvsp[(2) - (2)].val); +} + break; + + case 57: + +/* Line 1455 of yacc.c */ +#line 559 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.rcvbuf = (yyvsp[(2) - (2)].val); +} + break; + + case 58: + +/* Line 1455 of yacc.c */ +#line 565 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.checksum = 0; +} + break; + + case 59: + +/* Line 1455 of yacc.c */ +#line 571 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.checksum = 1; +} + break; + + case 60: + +/* Line 1455 of yacc.c */ +#line 577 "read_config_yy.y" + { + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_TCP) { + print_err(CTD_CFG_ERROR, "cannot use `TCP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_type = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_BUFFERED | + CHANNEL_F_STREAM | + CHANNEL_F_ERRORS; + conf.channel_num++; +} + break; + + case 61: + +/* Line 1455 of yacc.c */ +#line 593 "read_config_yy.y" + { + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_TCP) { + print_err(CTD_CFG_ERROR, "cannot use `TCP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_type = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_DEFAULT | + CHANNEL_F_BUFFERED | + CHANNEL_F_STREAM | + CHANNEL_F_ERRORS; + conf.channel_default = conf.channel_num; + conf.channel_num++; +} + break; + + case 64: + +/* Line 1455 of yacc.c */ +#line 614 "read_config_yy.y" + { + __max_dedicated_links_reached(); + + if (!inet_aton((yyvsp[(2) - (2)].string), &conf.channel[conf.channel_num].u.tcp.server.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", (yyvsp[(2) - (2)].string)); + break; + } + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET; +} + break; + + case 65: + +/* Line 1455 of yacc.c */ +#line 625 "read_config_yy.y" + { + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), + &conf.channel[conf.channel_num].u.tcp.server.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET6; +} + break; + + case 66: + +/* Line 1455 of yacc.c */ +#line 642 "read_config_yy.y" + { + __max_dedicated_links_reached(); + + if (!inet_aton((yyvsp[(2) - (2)].string), &conf.channel[conf.channel_num].u.tcp.client)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", (yyvsp[(2) - (2)].string)); + break; + } + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET; +} + break; + + case 67: + +/* Line 1455 of yacc.c */ +#line 653 "read_config_yy.y" + { + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), + &conf.channel[conf.channel_num].u.tcp.client) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET6; +} + break; + + case 68: + +/* Line 1455 of yacc.c */ +#line 670 "read_config_yy.y" + { + int idx; + + __max_dedicated_links_reached(); + strncpy(conf.channel[conf.channel_num].channel_ifname, (yyvsp[(2) - (2)].string), IFNAMSIZ); + + idx = if_nametoindex((yyvsp[(2) - (2)].string)); + if (!idx) { + print_err(CTD_CFG_WARN, "%s is an invalid interface", (yyvsp[(2) - (2)].string)); + break; + } + conf.channel[conf.channel_num].u.tcp.server.ipv6.scope_id = idx; +} + break; + + case 69: + +/* Line 1455 of yacc.c */ +#line 685 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.port = (yyvsp[(2) - (2)].val); +} + break; + + case 70: + +/* Line 1455 of yacc.c */ +#line 691 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.sndbuf = (yyvsp[(2) - (2)].val); +} + break; + + case 71: + +/* Line 1455 of yacc.c */ +#line 697 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.rcvbuf = (yyvsp[(2) - (2)].val); +} + break; + + case 72: + +/* Line 1455 of yacc.c */ +#line 703 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.checksum = 0; +} + break; + + case 73: + +/* Line 1455 of yacc.c */ +#line 709 "read_config_yy.y" + { + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.checksum = 1; +} + break; + + case 74: + +/* Line 1455 of yacc.c */ +#line 715 "read_config_yy.y" + { + __max_dedicated_links_reached(); + CONFIG(channelc).error_queue_length = (yyvsp[(2) - (2)].val); +} + break; + + case 75: + +/* Line 1455 of yacc.c */ +#line 721 "read_config_yy.y" + { + conf.hashsize = (yyvsp[(2) - (2)].val); +} + break; + + case 76: + +/* Line 1455 of yacc.c */ +#line 726 "read_config_yy.y" + { + conf.limit = (yyvsp[(2) - (2)].val); +} + break; + + case 80: + +/* Line 1455 of yacc.c */ +#line 737 "read_config_yy.y" + { + strcpy(conf.local.path, (yyvsp[(2) - (2)].string)); +} + break; + + case 81: + +/* Line 1455 of yacc.c */ +#line 742 "read_config_yy.y" + { + conf.local.backlog = (yyvsp[(2) - (2)].val); +} + break; + + case 82: + +/* Line 1455 of yacc.c */ +#line 747 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_L4PROTO, + CT_FILTER_NEGATIVE); + + print_err(CTD_CFG_WARN, "the clause `IgnoreProtocol' is " + "obsolete. Use `Filter' instead"); +} + break; + + case 85: + +/* Line 1455 of yacc.c */ +#line 761 "read_config_yy.y" + { + if ((yyvsp[(1) - (1)].val) < IPPROTO_MAX) + ct_filter_add_proto(STATE(us_filter), (yyvsp[(1) - (1)].val)); + else + print_err(CTD_CFG_WARN, "protocol number `%d' is freak", (yyvsp[(1) - (1)].val)); +} + break; + + case 86: + +/* Line 1455 of yacc.c */ +#line 769 "read_config_yy.y" + { + struct protoent *pent; + + pent = getprotobyname((yyvsp[(1) - (1)].string)); + if (pent == NULL) { + print_err(CTD_CFG_WARN, "getprotobyname() cannot find " + "protocol `%s' in /etc/protocols", (yyvsp[(1) - (1)].string)); + break; + } + ct_filter_add_proto(STATE(us_filter), pent->p_proto); +} + break; + + case 87: + +/* Line 1455 of yacc.c */ +#line 782 "read_config_yy.y" + { + if (conf.flags & CTD_STATS_MODE) { + print_err(CTD_CFG_ERROR, "cannot use both `Stats' and `Sync' " + "clauses in conntrackd.conf"); + exit(EXIT_FAILURE); + } + conf.flags |= CTD_SYNC_MODE; +} + break; + + case 107: + +/* Line 1455 of yacc.c */ +#line 814 "read_config_yy.y" + { + conf.flags |= CTD_SYNC_ALARM; +} + break; + + case 108: + +/* Line 1455 of yacc.c */ +#line 819 "read_config_yy.y" + { + conf.flags |= CTD_SYNC_FTFW; +} + break; + + case 109: + +/* Line 1455 of yacc.c */ +#line 824 "read_config_yy.y" + { + conf.flags |= CTD_SYNC_NOTRACK; +} + break; + + case 132: + +/* Line 1455 of yacc.c */ +#line 860 "read_config_yy.y" + { + conf.sync.internal_cache_disable = 1; +} + break; + + case 133: + +/* Line 1455 of yacc.c */ +#line 865 "read_config_yy.y" + { + conf.sync.internal_cache_disable = 0; +} + break; + + case 134: + +/* Line 1455 of yacc.c */ +#line 870 "read_config_yy.y" + { + conf.sync.external_cache_disable = 1; +} + break; + + case 135: + +/* Line 1455 of yacc.c */ +#line 875 "read_config_yy.y" + { + conf.sync.external_cache_disable = 0; +} + break; + + case 136: + +/* Line 1455 of yacc.c */ +#line 880 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`ResendBufferSize' is deprecated. " + "Use `ResendQueueSize' instead"); +} + break; + + case 137: + +/* Line 1455 of yacc.c */ +#line 886 "read_config_yy.y" + { + conf.resend_queue_size = (yyvsp[(2) - (2)].val); +} + break; + + case 138: + +/* Line 1455 of yacc.c */ +#line 891 "read_config_yy.y" + { + conf.window_size = (yyvsp[(2) - (2)].val); +} + break; + + case 139: + +/* Line 1455 of yacc.c */ +#line 896 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`DestroyTimeout' is deprecated. Remove it"); +} + break; + + case 140: + +/* Line 1455 of yacc.c */ +#line 901 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`RelaxTransitions' clause is obsolete. " + "Please, remove it from conntrackd.conf"); +} + break; + + case 141: + +/* Line 1455 of yacc.c */ +#line 907 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`DelayDestroyMessages' clause is obsolete. " + "Please, remove it from conntrackd.conf"); +} + break; + + case 142: + +/* Line 1455 of yacc.c */ +#line 913 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "the clause `ListenTo' is obsolete, ignoring"); +} + break; + + case 143: + +/* Line 1455 of yacc.c */ +#line 918 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_STATE, + CT_FILTER_POSITIVE); + + print_err(CTD_CFG_WARN, "the clause `Replicate' is obsolete. " + "Use `Filter' instead"); +} + break; + + case 146: + +/* Line 1455 of yacc.c */ +#line 931 "read_config_yy.y" + { + if (strncmp((yyvsp[(1) - (1)].string), "TCP", strlen("TCP")) != 0) { + print_err(CTD_CFG_WARN, "unsupported protocol `%s' in line %d", + (yyvsp[(1) - (1)].string), yylineno); + } +} + break; + + case 150: + +/* Line 1455 of yacc.c */ +#line 943 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_SYN_SENT); + + __kernel_filter_add_state(TCP_CONNTRACK_SYN_SENT); +} + break; + + case 151: + +/* Line 1455 of yacc.c */ +#line 951 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_SYN_RECV); + + __kernel_filter_add_state(TCP_CONNTRACK_SYN_RECV); +} + break; + + case 152: + +/* Line 1455 of yacc.c */ +#line 959 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_ESTABLISHED); + + __kernel_filter_add_state(TCP_CONNTRACK_ESTABLISHED); +} + break; + + case 153: + +/* Line 1455 of yacc.c */ +#line 967 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_FIN_WAIT); + + __kernel_filter_add_state(TCP_CONNTRACK_FIN_WAIT); +} + break; + + case 154: + +/* Line 1455 of yacc.c */ +#line 975 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_CLOSE_WAIT); + + __kernel_filter_add_state(TCP_CONNTRACK_CLOSE_WAIT); +} + break; + + case 155: + +/* Line 1455 of yacc.c */ +#line 983 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_LAST_ACK); + + __kernel_filter_add_state(TCP_CONNTRACK_LAST_ACK); +} + break; + + case 156: + +/* Line 1455 of yacc.c */ +#line 991 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_TIME_WAIT); + + __kernel_filter_add_state(TCP_CONNTRACK_TIME_WAIT); +} + break; + + case 157: + +/* Line 1455 of yacc.c */ +#line 999 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_CLOSE); + + __kernel_filter_add_state(TCP_CONNTRACK_CLOSE); +} + break; + + case 158: + +/* Line 1455 of yacc.c */ +#line 1007 "read_config_yy.y" + { + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_LISTEN); + + __kernel_filter_add_state(TCP_CONNTRACK_LISTEN); +} + break; + + case 159: + +/* Line 1455 of yacc.c */ +#line 1016 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`CacheWriteThrough' clause is obsolete, " + "ignoring"); +} + break; + + case 160: + +/* Line 1455 of yacc.c */ +#line 1022 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`CacheWriteThrough' clause is obsolete, " + "ignoring"); +} + break; + + case 182: + +/* Line 1455 of yacc.c */ +#line 1054 "read_config_yy.y" + { + conf.netlink_buffer_size = (yyvsp[(2) - (2)].val); +} + break; + + case 183: + +/* Line 1455 of yacc.c */ +#line 1059 "read_config_yy.y" + { + conf.netlink_buffer_size_max_grown = (yyvsp[(2) - (2)].val); +} + break; + + case 184: + +/* Line 1455 of yacc.c */ +#line 1064 "read_config_yy.y" + { + conf.nl_overrun_resync = 30; +} + break; + + case 185: + +/* Line 1455 of yacc.c */ +#line 1069 "read_config_yy.y" + { + conf.nl_overrun_resync = -1; +} + break; + + case 186: + +/* Line 1455 of yacc.c */ +#line 1074 "read_config_yy.y" + { + conf.nl_overrun_resync = (yyvsp[(2) - (2)].val); +} + break; + + case 187: + +/* Line 1455 of yacc.c */ +#line 1079 "read_config_yy.y" + { + conf.netlink.events_reliable = 1; +} + break; + + case 188: + +/* Line 1455 of yacc.c */ +#line 1084 "read_config_yy.y" + { + conf.netlink.events_reliable = 0; +} + break; + + case 189: + +/* Line 1455 of yacc.c */ +#line 1089 "read_config_yy.y" + { + conf.nice = (yyvsp[(2) - (2)].val); +} + break; + + case 193: + +/* Line 1455 of yacc.c */ +#line 1100 "read_config_yy.y" + { + if (strcasecmp((yyvsp[(2) - (2)].string), "rr") == 0) { + conf.sched.type = SCHED_RR; + } else if (strcasecmp((yyvsp[(2) - (2)].string), "fifo") == 0) { + conf.sched.type = SCHED_FIFO; + } else { + print_err(CTD_CFG_ERROR, "unknown scheduler `%s'", (yyvsp[(2) - (2)].string)); + exit(EXIT_FAILURE); + } +} + break; + + case 194: + +/* Line 1455 of yacc.c */ +#line 1112 "read_config_yy.y" + { + conf.sched.prio = (yyvsp[(2) - (2)].val); + if (conf.sched.prio < 0 || conf.sched.prio > 99) { + print_err(CTD_CFG_ERROR, "`Priority' must be [0, 99]\n", (yyvsp[(2) - (2)].val)); + exit(EXIT_FAILURE); + } +} + break; + + case 195: + +/* Line 1455 of yacc.c */ +#line 1121 "read_config_yy.y" + { + if (strncmp((yyvsp[(2) - (2)].string), "IPv6", strlen("IPv6")) == 0) + conf.family = AF_INET6; + else + conf.family = AF_INET; +} + break; + + case 196: + +/* Line 1455 of yacc.c */ +#line 1129 "read_config_yy.y" + { + CONFIG(event_iterations_limit) = (yyvsp[(2) - (2)].val); +} + break; + + case 197: + +/* Line 1455 of yacc.c */ +#line 1134 "read_config_yy.y" + { + conf.flags |= CTD_POLL; + conf.poll_kernel_secs = (yyvsp[(2) - (2)].val); + if (conf.poll_kernel_secs == 0) { + print_err(CTD_CFG_ERROR, "`PollSecs' clause must be > 0"); + exit(EXIT_FAILURE); + } +} + break; + + case 198: + +/* Line 1455 of yacc.c */ +#line 1144 "read_config_yy.y" + { + CONFIG(filter_from_kernelspace) = 0; +} + break; + + case 199: + +/* Line 1455 of yacc.c */ +#line 1149 "read_config_yy.y" + { + CONFIG(filter_from_kernelspace) = 0; +} + break; + + case 200: + +/* Line 1455 of yacc.c */ +#line 1154 "read_config_yy.y" + { + CONFIG(filter_from_kernelspace) = 1; +} + break; + + case 203: + +/* Line 1455 of yacc.c */ +#line 1162 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_L4PROTO, + CT_FILTER_POSITIVE); + + __kernel_filter_start(); +} + break; + + case 204: + +/* Line 1455 of yacc.c */ +#line 1171 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_L4PROTO, + CT_FILTER_NEGATIVE); + + __kernel_filter_start(); + + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_L4PROTO, + NFCT_FILTER_LOGIC_NEGATIVE); +} + break; + + case 207: + +/* Line 1455 of yacc.c */ +#line 1187 "read_config_yy.y" + { + struct protoent *pent; + + pent = getprotobyname((yyvsp[(1) - (1)].string)); + if (pent == NULL) { + print_err(CTD_CFG_WARN, "getprotobyname() cannot find " + "protocol `%s' in /etc/protocols", (yyvsp[(1) - (1)].string)); + break; + } + ct_filter_add_proto(STATE(us_filter), pent->p_proto); + + __kernel_filter_start(); + + nfct_filter_add_attr_u32(STATE(filter), + NFCT_FILTER_L4PROTO, + pent->p_proto); +} + break; + + case 208: + +/* Line 1455 of yacc.c */ +#line 1206 "read_config_yy.y" + { + struct protoent *pent; + + pent = getprotobyname("tcp"); + if (pent == NULL) { + print_err(CTD_CFG_WARN, "getprotobyname() cannot find " + "protocol `tcp' in /etc/protocols"); + break; + } + ct_filter_add_proto(STATE(us_filter), pent->p_proto); + + __kernel_filter_start(); + + nfct_filter_add_attr_u32(STATE(filter), + NFCT_FILTER_L4PROTO, + pent->p_proto); +} + break; + + case 209: + +/* Line 1455 of yacc.c */ +#line 1225 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_ADDRESS, + CT_FILTER_POSITIVE); + + __kernel_filter_start(); +} + break; + + case 210: + +/* Line 1455 of yacc.c */ +#line 1234 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_ADDRESS, + CT_FILTER_NEGATIVE); + + __kernel_filter_start(); + + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_SRC_IPV4, + NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_DST_IPV4, + NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_SRC_IPV6, + NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_DST_IPV6, + NFCT_FILTER_LOGIC_NEGATIVE); +} + break; + + case 213: + +/* Line 1455 of yacc.c */ +#line 1259 "read_config_yy.y" + { + union inet_address ip; + char *slash; + unsigned int cidr = 32; + + memset(&ip, 0, sizeof(union inet_address)); + + slash = strchr((yyvsp[(2) - (2)].string), '/'); + if (slash) { + *slash = '\0'; + cidr = atoi(slash+1); + if (cidr > 32) { + print_err(CTD_CFG_WARN, "%s/%d is not a valid network, " + "ignoring", (yyvsp[(2) - (2)].string), cidr); + break; + } + } + + if (!inet_aton((yyvsp[(2) - (2)].string), &ip.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4, ignoring", (yyvsp[(2) - (2)].string)); + break; + } + + if (slash && cidr < 32) { + /* network byte order */ + struct ct_filter_netmask_ipv4 tmp = { + .ip = ip.ipv4, + .mask = ipv4_cidr2mask_net(cidr) + }; + + if (!ct_filter_add_netmask(STATE(us_filter), &tmp, AF_INET)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "netmask %s is " + "repeated in the " + "ignore pool", (yyvsp[(2) - (2)].string)); + } + } else { + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated in " + "the ignore pool", (yyvsp[(2) - (2)].string)); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } + } + __kernel_filter_start(); + + /* host byte order */ + struct nfct_filter_ipv4 filter_ipv4 = { + .addr = ntohl(ip.ipv4), + .mask = ipv4_cidr2mask_host(cidr), + }; + + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_SRC_IPV4, &filter_ipv4); + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_DST_IPV4, &filter_ipv4); +} + break; + + case 214: + +/* Line 1455 of yacc.c */ +#line 1318 "read_config_yy.y" + { + union inet_address ip; + char *slash; + int cidr = 128; + struct nfct_filter_ipv6 filter_ipv6; + + memset(&ip, 0, sizeof(union inet_address)); + + slash = strchr((yyvsp[(2) - (2)].string), '/'); + if (slash) { + *slash = '\0'; + cidr = atoi(slash+1); + if (cidr > 128) { + print_err(CTD_CFG_WARN, "%s/%d is not a valid network, " + "ignoring", (yyvsp[(2) - (2)].string), cidr); + break; + } + } + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, (yyvsp[(2) - (2)].string), &ip.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6, ignoring", (yyvsp[(2) - (2)].string)); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + if (slash && cidr < 128) { + struct ct_filter_netmask_ipv6 tmp; + + memcpy(tmp.ip, ip.ipv6, sizeof(uint32_t)*4); + ipv6_cidr2mask_net(cidr, tmp.mask); + if (!ct_filter_add_netmask(STATE(us_filter), &tmp, AF_INET6)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "netmask %s is " + "repeated in the " + "ignore pool", (yyvsp[(2) - (2)].string)); + } + } else { + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET6)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated in " + "the ignore pool", (yyvsp[(2) - (2)].string)); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } + } + __kernel_filter_start(); + + /* host byte order */ + ipv6_addr2addr_host(ip.ipv6, filter_ipv6.addr); + ipv6_cidr2mask_host(cidr, filter_ipv6.mask); + + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_SRC_IPV6, &filter_ipv6); + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_DST_IPV6, &filter_ipv6); +} + break; + + case 215: + +/* Line 1455 of yacc.c */ +#line 1378 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_STATE, + CT_FILTER_POSITIVE); + + __kernel_filter_start(); +} + break; + + case 216: + +/* Line 1455 of yacc.c */ +#line 1387 "read_config_yy.y" + { + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_STATE, + CT_FILTER_NEGATIVE); + + + __kernel_filter_start(); + + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_L4PROTO_STATE, + NFCT_FILTER_LOGIC_NEGATIVE); +} + break; + + case 220: + +/* Line 1455 of yacc.c */ +#line 1406 "read_config_yy.y" + { + if (conf.flags & CTD_SYNC_MODE) { + print_err(CTD_CFG_ERROR, "cannot use both `Stats' and `Sync' " + "clauses in conntrackd.conf"); + exit(EXIT_FAILURE); + } + conf.flags |= CTD_STATS_MODE; +} + break; + + case 228: + +/* Line 1455 of yacc.c */ +#line 1427 "read_config_yy.y" + { + strncpy(conf.stats.logfile, DEFAULT_STATS_LOGFILE, FILENAME_MAXLEN); +} + break; + + case 229: + +/* Line 1455 of yacc.c */ +#line 1432 "read_config_yy.y" + { +} + break; + + case 230: + +/* Line 1455 of yacc.c */ +#line 1436 "read_config_yy.y" + { + strncpy(conf.stats.logfile, (yyvsp[(2) - (2)].string), FILENAME_MAXLEN); +} + break; + + case 231: + +/* Line 1455 of yacc.c */ +#line 1441 "read_config_yy.y" + { + conf.stats.syslog_facility = DEFAULT_SYSLOG_FACILITY; +} + break; + + case 232: + +/* Line 1455 of yacc.c */ +#line 1446 "read_config_yy.y" + { + conf.stats.syslog_facility = -1; +} + break; + + case 233: + +/* Line 1455 of yacc.c */ +#line 1451 "read_config_yy.y" + { + if (!strcmp((yyvsp[(2) - (2)].string), "daemon")) + conf.stats.syslog_facility = LOG_DAEMON; + else if (!strcmp((yyvsp[(2) - (2)].string), "local0")) + conf.stats.syslog_facility = LOG_LOCAL0; + else if (!strcmp((yyvsp[(2) - (2)].string), "local1")) + conf.stats.syslog_facility = LOG_LOCAL1; + else if (!strcmp((yyvsp[(2) - (2)].string), "local2")) + conf.stats.syslog_facility = LOG_LOCAL2; + else if (!strcmp((yyvsp[(2) - (2)].string), "local3")) + conf.stats.syslog_facility = LOG_LOCAL3; + else if (!strcmp((yyvsp[(2) - (2)].string), "local4")) + conf.stats.syslog_facility = LOG_LOCAL4; + else if (!strcmp((yyvsp[(2) - (2)].string), "local5")) + conf.stats.syslog_facility = LOG_LOCAL5; + else if (!strcmp((yyvsp[(2) - (2)].string), "local6")) + conf.stats.syslog_facility = LOG_LOCAL6; + else if (!strcmp((yyvsp[(2) - (2)].string), "local7")) + conf.stats.syslog_facility = LOG_LOCAL7; + else { + print_err(CTD_CFG_WARN, "'%s' is not a known syslog facility, " + "ignoring.", (yyvsp[(2) - (2)].string)); + break; + } + + if (conf.syslog_facility != -1 && + conf.stats.syslog_facility != conf.syslog_facility) + print_err(CTD_CFG_WARN, "conflicting Syslog facility " + "values, defaulting to General"); +} + break; + + case 234: + +/* Line 1455 of yacc.c */ +#line 1483 "read_config_yy.y" + { + print_err(CTD_CFG_WARN, "`LogFileBufferSize' is deprecated"); +} + break; + + + +/* Line 1455 of yacc.c */ +#line 3712 "read_config_yy.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + +/* Line 1675 of yacc.c */ +#line 1487 "read_config_yy.y" + + +int __attribute__((noreturn)) +yyerror(char *msg) +{ + print_err(CTD_CFG_ERROR, "parsing config file in " + "line (%d), symbol '%s': %s", + yylineno, yytext, msg); + exit(EXIT_FAILURE); +} + +static void print_err(int type, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + switch(type) { + case CTD_CFG_ERROR: + fprintf(stderr, "ERROR: "); + break; + case CTD_CFG_WARN: + fprintf(stderr, "WARNING: "); + break; + default: + fprintf(stderr, "?: "); + } + vfprintf(stderr, msg, args); + va_end(args); + fprintf(stderr,"\n"); +} + +static void __kernel_filter_start(void) +{ + if (!STATE(filter)) { + STATE(filter) = nfct_filter_create(); + if (!STATE(filter)) { + print_err(CTD_CFG_ERROR, "cannot create ignore pool!"); + exit(EXIT_FAILURE); + } + } +} + +static void __kernel_filter_add_state(int value) +{ + __kernel_filter_start(); + + struct nfct_filter_proto filter_proto = { + .proto = IPPROTO_TCP, + .state = value + }; + nfct_filter_add_attr(STATE(filter), + NFCT_FILTER_L4PROTO_STATE, + &filter_proto); +} + +static void __max_dedicated_links_reached(void) +{ + if (conf.channel_num >= MULTICHANNEL_MAX) { + print_err(CTD_CFG_ERROR, "too many dedicated links in " + "the configuration file " + "(Maximum: %d)", MULTICHANNEL_MAX); + exit(EXIT_FAILURE); + } +} + +int +init_config(char *filename) +{ + FILE *fp; + + fp = fopen(filename, "r"); + if (!fp) + return -1; + + /* Zero may be a valid facility */ + CONFIG(syslog_facility) = -1; + CONFIG(stats).syslog_facility = -1; + + yyrestart(fp); + yyparse(); + fclose(fp); + + /* default to IPv4 */ + if (CONFIG(family) == 0) + CONFIG(family) = AF_INET; + + /* set to default is not specified */ + if (strcmp(CONFIG(lockfile), "") == 0) + strncpy(CONFIG(lockfile), DEFAULT_LOCKFILE, FILENAME_MAXLEN); + + /* default to 180 seconds of expiration time: cache entries */ + if (CONFIG(cache_timeout) == 0) + CONFIG(cache_timeout) = 180; + + /* default to 60 seconds: purge kernel entries */ + if (CONFIG(purge_timeout) == 0) + CONFIG(purge_timeout) = 60; + + /* default to 60 seconds of refresh time */ + if (CONFIG(refresh) == 0) + CONFIG(refresh) = 60; + + if (CONFIG(resend_queue_size) == 0) + CONFIG(resend_queue_size) = 131072; + + /* default to a window size of 300 packets */ + if (CONFIG(window_size) == 0) + CONFIG(window_size) = 300; + + if (CONFIG(event_iterations_limit) == 0) + CONFIG(event_iterations_limit) = 100; + + /* default number of bucket of the hashtable that are committed in + one run loop. XXX: no option available to tune this value yet. */ + if (CONFIG(general).commit_steps == 0) + CONFIG(general).commit_steps = 64; + + /* if overrun, automatically resync with kernel after 30 seconds */ + if (CONFIG(nl_overrun_resync) == 0) + CONFIG(nl_overrun_resync) = 30; + + /* default to 128 elements in the channel error queue */ + if (CONFIG(channelc).error_queue_length == 0) + CONFIG(channelc).error_queue_length = 128; + + return 0; +} + diff --git a/src/read_config_yy.h b/src/read_config_yy.h new file mode 100644 index 0000000..c1c2a98 --- /dev/null +++ b/src/read_config_yy.h @@ -0,0 +1,257 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_IPV4_ADDR = 258, + T_IPV4_IFACE = 259, + T_PORT = 260, + T_HASHSIZE = 261, + T_HASHLIMIT = 262, + T_MULTICAST = 263, + T_PATH = 264, + T_UNIX = 265, + T_REFRESH = 266, + T_IPV6_ADDR = 267, + T_IPV6_IFACE = 268, + T_IGNORE_UDP = 269, + T_IGNORE_ICMP = 270, + T_IGNORE_TRAFFIC = 271, + T_BACKLOG = 272, + T_GROUP = 273, + T_LOG = 274, + T_UDP = 275, + T_ICMP = 276, + T_IGMP = 277, + T_VRRP = 278, + T_TCP = 279, + T_IGNORE_PROTOCOL = 280, + T_LOCK = 281, + T_STRIP_NAT = 282, + T_BUFFER_SIZE_MAX_GROWN = 283, + T_EXPIRE = 284, + T_TIMEOUT = 285, + T_GENERAL = 286, + T_SYNC = 287, + T_STATS = 288, + T_RELAX_TRANSITIONS = 289, + T_BUFFER_SIZE = 290, + T_DELAY = 291, + T_SYNC_MODE = 292, + T_LISTEN_TO = 293, + T_FAMILY = 294, + T_RESEND_BUFFER_SIZE = 295, + T_ALARM = 296, + T_FTFW = 297, + T_CHECKSUM = 298, + T_WINDOWSIZE = 299, + T_ON = 300, + T_OFF = 301, + T_REPLICATE = 302, + T_FOR = 303, + T_IFACE = 304, + T_PURGE = 305, + T_RESEND_QUEUE_SIZE = 306, + T_ESTABLISHED = 307, + T_SYN_SENT = 308, + T_SYN_RECV = 309, + T_FIN_WAIT = 310, + T_CLOSE_WAIT = 311, + T_LAST_ACK = 312, + T_TIME_WAIT = 313, + T_CLOSE = 314, + T_LISTEN = 315, + T_SYSLOG = 316, + T_WRITE_THROUGH = 317, + T_STAT_BUFFER_SIZE = 318, + T_DESTROY_TIMEOUT = 319, + T_RCVBUFF = 320, + T_SNDBUFF = 321, + T_NOTRACK = 322, + T_POLL_SECS = 323, + T_FILTER = 324, + T_ADDRESS = 325, + T_PROTOCOL = 326, + T_STATE = 327, + T_ACCEPT = 328, + T_IGNORE = 329, + T_FROM = 330, + T_USERSPACE = 331, + T_KERNELSPACE = 332, + T_EVENT_ITER_LIMIT = 333, + T_DEFAULT = 334, + T_NETLINK_OVERRUN_RESYNC = 335, + T_NICE = 336, + T_IPV4_DEST_ADDR = 337, + T_IPV6_DEST_ADDR = 338, + T_SCHEDULER = 339, + T_TYPE = 340, + T_PRIO = 341, + T_NETLINK_EVENTS_RELIABLE = 342, + T_DISABLE_INTERNAL_CACHE = 343, + T_DISABLE_EXTERNAL_CACHE = 344, + T_ERROR_QUEUE_LENGTH = 345, + T_IP = 346, + T_PATH_VAL = 347, + T_NUMBER = 348, + T_SIGNED_NUMBER = 349, + T_STRING = 350 + }; +#endif +/* Tokens. */ +#define T_IPV4_ADDR 258 +#define T_IPV4_IFACE 259 +#define T_PORT 260 +#define T_HASHSIZE 261 +#define T_HASHLIMIT 262 +#define T_MULTICAST 263 +#define T_PATH 264 +#define T_UNIX 265 +#define T_REFRESH 266 +#define T_IPV6_ADDR 267 +#define T_IPV6_IFACE 268 +#define T_IGNORE_UDP 269 +#define T_IGNORE_ICMP 270 +#define T_IGNORE_TRAFFIC 271 +#define T_BACKLOG 272 +#define T_GROUP 273 +#define T_LOG 274 +#define T_UDP 275 +#define T_ICMP 276 +#define T_IGMP 277 +#define T_VRRP 278 +#define T_TCP 279 +#define T_IGNORE_PROTOCOL 280 +#define T_LOCK 281 +#define T_STRIP_NAT 282 +#define T_BUFFER_SIZE_MAX_GROWN 283 +#define T_EXPIRE 284 +#define T_TIMEOUT 285 +#define T_GENERAL 286 +#define T_SYNC 287 +#define T_STATS 288 +#define T_RELAX_TRANSITIONS 289 +#define T_BUFFER_SIZE 290 +#define T_DELAY 291 +#define T_SYNC_MODE 292 +#define T_LISTEN_TO 293 +#define T_FAMILY 294 +#define T_RESEND_BUFFER_SIZE 295 +#define T_ALARM 296 +#define T_FTFW 297 +#define T_CHECKSUM 298 +#define T_WINDOWSIZE 299 +#define T_ON 300 +#define T_OFF 301 +#define T_REPLICATE 302 +#define T_FOR 303 +#define T_IFACE 304 +#define T_PURGE 305 +#define T_RESEND_QUEUE_SIZE 306 +#define T_ESTABLISHED 307 +#define T_SYN_SENT 308 +#define T_SYN_RECV 309 +#define T_FIN_WAIT 310 +#define T_CLOSE_WAIT 311 +#define T_LAST_ACK 312 +#define T_TIME_WAIT 313 +#define T_CLOSE 314 +#define T_LISTEN 315 +#define T_SYSLOG 316 +#define T_WRITE_THROUGH 317 +#define T_STAT_BUFFER_SIZE 318 +#define T_DESTROY_TIMEOUT 319 +#define T_RCVBUFF 320 +#define T_SNDBUFF 321 +#define T_NOTRACK 322 +#define T_POLL_SECS 323 +#define T_FILTER 324 +#define T_ADDRESS 325 +#define T_PROTOCOL 326 +#define T_STATE 327 +#define T_ACCEPT 328 +#define T_IGNORE 329 +#define T_FROM 330 +#define T_USERSPACE 331 +#define T_KERNELSPACE 332 +#define T_EVENT_ITER_LIMIT 333 +#define T_DEFAULT 334 +#define T_NETLINK_OVERRUN_RESYNC 335 +#define T_NICE 336 +#define T_IPV4_DEST_ADDR 337 +#define T_IPV6_DEST_ADDR 338 +#define T_SCHEDULER 339 +#define T_TYPE 340 +#define T_PRIO 341 +#define T_NETLINK_EVENTS_RELIABLE 342 +#define T_DISABLE_INTERNAL_CACHE 343 +#define T_DISABLE_EXTERNAL_CACHE 344 +#define T_ERROR_QUEUE_LENGTH 345 +#define T_IP 346 +#define T_PATH_VAL 347 +#define T_NUMBER 348 +#define T_SIGNED_NUMBER 349 +#define T_STRING 350 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 1676 of yacc.c */ +#line 53 "read_config_yy.y" + + int val; + char *string; + + + +/* Line 1676 of yacc.c */ +#line 249 "read_config_yy.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +extern YYSTYPE yylval; + + diff --git a/src/read_config_yy.y b/src/read_config_yy.y new file mode 100644 index 0000000..6dfca98 --- /dev/null +++ b/src/read_config_yy.y @@ -0,0 +1,1613 @@ +%{ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: configuration file abstract grammar + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <netdb.h> +#include <errno.h> +#include <stdarg.h> +#include "conntrackd.h" +#include "bitops.h" +#include "cidr.h" +#include <syslog.h> +#include <sched.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h> + +extern char *yytext; +extern int yylineno; + +struct ct_conf conf; + +enum { + CTD_CFG_ERROR = 0, + CTD_CFG_WARN, +}; + +static void print_err(int err, const char *msg, ...); + +static void __kernel_filter_start(void); +static void __kernel_filter_add_state(int value); +static void __max_dedicated_links_reached(void); +%} + +%union { + int val; + char *string; +} + +%token T_IPV4_ADDR T_IPV4_IFACE T_PORT T_HASHSIZE T_HASHLIMIT T_MULTICAST +%token T_PATH T_UNIX T_REFRESH T_IPV6_ADDR T_IPV6_IFACE +%token T_IGNORE_UDP T_IGNORE_ICMP T_IGNORE_TRAFFIC T_BACKLOG T_GROUP +%token T_LOG T_UDP T_ICMP T_IGMP T_VRRP T_TCP T_IGNORE_PROTOCOL +%token T_LOCK T_STRIP_NAT T_BUFFER_SIZE_MAX_GROWN T_EXPIRE T_TIMEOUT +%token T_GENERAL T_SYNC T_STATS T_RELAX_TRANSITIONS T_BUFFER_SIZE T_DELAY +%token T_SYNC_MODE T_LISTEN_TO T_FAMILY T_RESEND_BUFFER_SIZE +%token T_ALARM T_FTFW T_CHECKSUM T_WINDOWSIZE T_ON T_OFF +%token T_REPLICATE T_FOR T_IFACE T_PURGE T_RESEND_QUEUE_SIZE +%token T_ESTABLISHED T_SYN_SENT T_SYN_RECV T_FIN_WAIT +%token T_CLOSE_WAIT T_LAST_ACK T_TIME_WAIT T_CLOSE T_LISTEN +%token T_SYSLOG T_WRITE_THROUGH T_STAT_BUFFER_SIZE T_DESTROY_TIMEOUT +%token T_RCVBUFF T_SNDBUFF T_NOTRACK T_POLL_SECS +%token T_FILTER T_ADDRESS T_PROTOCOL T_STATE T_ACCEPT T_IGNORE +%token T_FROM T_USERSPACE T_KERNELSPACE T_EVENT_ITER_LIMIT T_DEFAULT +%token T_NETLINK_OVERRUN_RESYNC T_NICE T_IPV4_DEST_ADDR T_IPV6_DEST_ADDR +%token T_SCHEDULER T_TYPE T_PRIO T_NETLINK_EVENTS_RELIABLE +%token T_DISABLE_INTERNAL_CACHE T_DISABLE_EXTERNAL_CACHE T_ERROR_QUEUE_LENGTH + +%token <string> T_IP T_PATH_VAL +%token <val> T_NUMBER +%token <val> T_SIGNED_NUMBER +%token <string> T_STRING + +%% + +configfile : + | lines + ; + +lines : line + | lines line + ; + +line : ignore_protocol + | ignore_traffic + | strip_nat + | general + | sync + | stats + ; + +logfile_bool : T_LOG T_ON +{ + strncpy(conf.logfile, DEFAULT_LOGFILE, FILENAME_MAXLEN); +}; + +logfile_bool : T_LOG T_OFF +{ +}; + +logfile_path : T_LOG T_PATH_VAL +{ + strncpy(conf.logfile, $2, FILENAME_MAXLEN); +}; + +syslog_bool : T_SYSLOG T_ON +{ + conf.syslog_facility = DEFAULT_SYSLOG_FACILITY; +}; + +syslog_bool : T_SYSLOG T_OFF +{ + conf.syslog_facility = -1; +} + +syslog_facility : T_SYSLOG T_STRING +{ + if (!strcmp($2, "daemon")) + conf.syslog_facility = LOG_DAEMON; + else if (!strcmp($2, "local0")) + conf.syslog_facility = LOG_LOCAL0; + else if (!strcmp($2, "local1")) + conf.syslog_facility = LOG_LOCAL1; + else if (!strcmp($2, "local2")) + conf.syslog_facility = LOG_LOCAL2; + else if (!strcmp($2, "local3")) + conf.syslog_facility = LOG_LOCAL3; + else if (!strcmp($2, "local4")) + conf.syslog_facility = LOG_LOCAL4; + else if (!strcmp($2, "local5")) + conf.syslog_facility = LOG_LOCAL5; + else if (!strcmp($2, "local6")) + conf.syslog_facility = LOG_LOCAL6; + else if (!strcmp($2, "local7")) + conf.syslog_facility = LOG_LOCAL7; + else { + print_err(CTD_CFG_WARN, "'%s' is not a known syslog facility, " + "ignoring", $2); + break; + } + + if (conf.stats.syslog_facility != -1 && + conf.syslog_facility != conf.stats.syslog_facility) + print_err(CTD_CFG_WARN, "conflicting Syslog facility " + "values, defaulting to General"); +}; + +lock : T_LOCK T_PATH_VAL +{ + strncpy(conf.lockfile, $2, FILENAME_MAXLEN); +}; + +strip_nat: T_STRIP_NAT +{ + print_err(CTD_CFG_WARN, "`StripNAT' clause is obsolete, ignoring"); +}; + +refreshtime : T_REFRESH T_NUMBER +{ + conf.refresh = $2; +}; + +expiretime: T_EXPIRE T_NUMBER +{ + conf.cache_timeout = $2; +}; + +timeout: T_TIMEOUT T_NUMBER +{ + conf.commit_timeout = $2; +}; + +purge: T_PURGE T_NUMBER +{ + conf.purge_timeout = $2; +}; + +checksum: T_CHECKSUM T_ON +{ + print_err(CTD_CFG_WARN, "the use of `Checksum' outside the " + "`Multicast' clause is ambiguous"); + /* + * XXX: The use of Checksum outside of the Multicast clause is broken + * if we have more than one dedicated links. + */ + conf.channel[0].u.mcast.checksum = 0; +}; + +checksum: T_CHECKSUM T_OFF +{ + print_err(CTD_CFG_WARN, "the use of `Checksum' outside the " + "`Multicast' clause is ambiguous"); + /* + * XXX: The use of Checksum outside of the Multicast clause is broken + * if we have more than one dedicated links. + */ + conf.channel[0].u.mcast.checksum = 1; +}; + +ignore_traffic : T_IGNORE_TRAFFIC '{' ignore_traffic_options '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_ADDRESS, + CT_FILTER_NEGATIVE); + + print_err(CTD_CFG_WARN, "the clause `IgnoreTrafficFor' is obsolete. " + "Use `Filter' instead"); +}; + +ignore_traffic_options : + | ignore_traffic_options ignore_traffic_option; + +ignore_traffic_option : T_IPV4_ADDR T_IP +{ + union inet_address ip; + + memset(&ip, 0, sizeof(union inet_address)); + + if (!inet_aton($2, &ip.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4, " + "ignoring", $2); + break; + } + + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated " + "in the ignore pool", $2); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } +}; + +ignore_traffic_option : T_IPV6_ADDR T_IP +{ + union inet_address ip; + + memset(&ip, 0, sizeof(union inet_address)); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, &ip.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6, ignoring", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); +#endif + + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET6)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated " + "in the ignore pool", $2); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } + +}; + +multicast_line : T_MULTICAST '{' multicast_options '}' +{ + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_MCAST) { + print_err(CTD_CFG_ERROR, "cannot use `Multicast' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_type = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_BUFFERED; + conf.channel_num++; +}; + +multicast_line : T_MULTICAST T_DEFAULT '{' multicast_options '}' +{ + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_MCAST) { + print_err(CTD_CFG_ERROR, "cannot use `Multicast' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_type = CHANNEL_MCAST; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_DEFAULT | + CHANNEL_F_BUFFERED; + conf.channel_default = conf.channel_num; + conf.channel_num++; +}; + +multicast_options : + | multicast_options multicast_option; + +multicast_option : T_IPV4_ADDR T_IP +{ + __max_dedicated_links_reached(); + + if (!inet_aton($2, &conf.channel[conf.channel_num].u.mcast.in)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", $2); + break; + } + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET6) { + print_err(CTD_CFG_WARN, "your multicast address is IPv4 but " + "is binded to an IPv6 interface? " + "Surely, this is not what you want"); + break; + } + + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET; +}; + +multicast_option : T_IPV6_ADDR T_IP +{ + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, + &conf.channel[conf.channel_num].u.mcast.in) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET) { + print_err(CTD_CFG_WARN, "your multicast address is IPv6 but " + "is binded to an IPv4 interface? " + "Surely this is not what you want"); + break; + } + + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET6; + + if (conf.channel[conf.channel_num].channel_ifname[0] && + !conf.channel[conf.channel_num].u.mcast.ifa.interface_index6) { + unsigned int idx; + + idx = if_nametoindex($2); + if (!idx) { + print_err(CTD_CFG_WARN, + "%s is an invalid interface", $2); + break; + } + + conf.channel[conf.channel_num].u.mcast.ifa.interface_index6 = idx; + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET6; + } +}; + +multicast_option : T_IPV4_IFACE T_IP +{ + __max_dedicated_links_reached(); + + if (!inet_aton($2, &conf.channel[conf.channel_num].u.mcast.ifa)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", $2); + break; + } + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET6) { + print_err(CTD_CFG_WARN, "your multicast interface is IPv4 but " + "is binded to an IPv6 interface? " + "Surely, this is not what you want"); + break; + } + + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET; +}; + +multicast_option : T_IPV6_IFACE T_IP +{ + print_err(CTD_CFG_WARN, "`IPv6_interface' not required, ignoring"); +} + +multicast_option : T_IFACE T_STRING +{ + unsigned int idx; + + __max_dedicated_links_reached(); + + strncpy(conf.channel[conf.channel_num].channel_ifname, $2, IFNAMSIZ); + + idx = if_nametoindex($2); + if (!idx) { + print_err(CTD_CFG_WARN, "%s is an invalid interface", $2); + break; + } + + if (conf.channel[conf.channel_num].u.mcast.ipproto == AF_INET6) { + conf.channel[conf.channel_num].u.mcast.ifa.interface_index6 = idx; + conf.channel[conf.channel_num].u.mcast.ipproto = AF_INET6; + } +}; + +multicast_option : T_BACKLOG T_NUMBER +{ + print_err(CTD_CFG_WARN, "`Backlog' option inside Multicast clause is " + "obsolete. Please, remove it from " + "conntrackd.conf"); +}; + +multicast_option : T_GROUP T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.port = $2; +}; + +multicast_option: T_SNDBUFF T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.sndbuf = $2; +}; + +multicast_option: T_RCVBUFF T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.rcvbuf = $2; +}; + +multicast_option: T_CHECKSUM T_ON +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.checksum = 0; +}; + +multicast_option: T_CHECKSUM T_OFF +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.mcast.checksum = 1; +}; + +udp_line : T_UDP '{' udp_options '}' +{ + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_UDP) { + print_err(CTD_CFG_ERROR, "cannot use `UDP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_type = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_BUFFERED; + conf.channel_num++; +}; + +udp_line : T_UDP T_DEFAULT '{' udp_options '}' +{ + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_UDP) { + print_err(CTD_CFG_ERROR, "cannot use `UDP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_type = CHANNEL_UDP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_DEFAULT | + CHANNEL_F_BUFFERED; + conf.channel_default = conf.channel_num; + conf.channel_num++; +}; + +udp_options : + | udp_options udp_option; + +udp_option : T_IPV4_ADDR T_IP +{ + __max_dedicated_links_reached(); + + if (!inet_aton($2, &conf.channel[conf.channel_num].u.udp.server.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", $2); + break; + } + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET; +}; + +udp_option : T_IPV6_ADDR T_IP +{ + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, + &conf.channel[conf.channel_num].u.udp.server.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET6; +}; + +udp_option : T_IPV4_DEST_ADDR T_IP +{ + __max_dedicated_links_reached(); + + if (!inet_aton($2, &conf.channel[conf.channel_num].u.udp.client)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", $2); + break; + } + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET; +}; + +udp_option : T_IPV6_DEST_ADDR T_IP +{ + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, + &conf.channel[conf.channel_num].u.udp.client) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.udp.ipproto = AF_INET6; +}; + +udp_option : T_IFACE T_STRING +{ + int idx; + + __max_dedicated_links_reached(); + strncpy(conf.channel[conf.channel_num].channel_ifname, $2, IFNAMSIZ); + + idx = if_nametoindex($2); + if (!idx) { + print_err(CTD_CFG_WARN, "%s is an invalid interface", $2); + break; + } + conf.channel[conf.channel_num].u.udp.server.ipv6.scope_id = idx; +}; + +udp_option : T_PORT T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.port = $2; +}; + +udp_option: T_SNDBUFF T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.sndbuf = $2; +}; + +udp_option: T_RCVBUFF T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.rcvbuf = $2; +}; + +udp_option: T_CHECKSUM T_ON +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.checksum = 0; +}; + +udp_option: T_CHECKSUM T_OFF +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.udp.checksum = 1; +}; + +tcp_line : T_TCP '{' tcp_options '}' +{ + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_TCP) { + print_err(CTD_CFG_ERROR, "cannot use `TCP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_type = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_BUFFERED | + CHANNEL_F_STREAM | + CHANNEL_F_ERRORS; + conf.channel_num++; +}; + +tcp_line : T_TCP T_DEFAULT '{' tcp_options '}' +{ + if (conf.channel_type_global != CHANNEL_NONE && + conf.channel_type_global != CHANNEL_TCP) { + print_err(CTD_CFG_ERROR, "cannot use `TCP' with other " + "dedicated link protocols!"); + exit(EXIT_FAILURE); + } + conf.channel_type_global = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_type = CHANNEL_TCP; + conf.channel[conf.channel_num].channel_flags = CHANNEL_F_DEFAULT | + CHANNEL_F_BUFFERED | + CHANNEL_F_STREAM | + CHANNEL_F_ERRORS; + conf.channel_default = conf.channel_num; + conf.channel_num++; +}; + +tcp_options : + | tcp_options tcp_option; + +tcp_option : T_IPV4_ADDR T_IP +{ + __max_dedicated_links_reached(); + + if (!inet_aton($2, &conf.channel[conf.channel_num].u.tcp.server.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", $2); + break; + } + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET; +}; + +tcp_option : T_IPV6_ADDR T_IP +{ + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, + &conf.channel[conf.channel_num].u.tcp.server.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET6; +}; + +tcp_option : T_IPV4_DEST_ADDR T_IP +{ + __max_dedicated_links_reached(); + + if (!inet_aton($2, &conf.channel[conf.channel_num].u.tcp.client)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4 address", $2); + break; + } + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET; +}; + +tcp_option : T_IPV6_DEST_ADDR T_IP +{ + __max_dedicated_links_reached(); + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, + &conf.channel[conf.channel_num].u.tcp.client) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6 address", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + conf.channel[conf.channel_num].u.tcp.ipproto = AF_INET6; +}; + +tcp_option : T_IFACE T_STRING +{ + int idx; + + __max_dedicated_links_reached(); + strncpy(conf.channel[conf.channel_num].channel_ifname, $2, IFNAMSIZ); + + idx = if_nametoindex($2); + if (!idx) { + print_err(CTD_CFG_WARN, "%s is an invalid interface", $2); + break; + } + conf.channel[conf.channel_num].u.tcp.server.ipv6.scope_id = idx; +}; + +tcp_option : T_PORT T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.port = $2; +}; + +tcp_option: T_SNDBUFF T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.sndbuf = $2; +}; + +tcp_option: T_RCVBUFF T_NUMBER +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.rcvbuf = $2; +}; + +tcp_option: T_CHECKSUM T_ON +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.checksum = 0; +}; + +tcp_option: T_CHECKSUM T_OFF +{ + __max_dedicated_links_reached(); + conf.channel[conf.channel_num].u.tcp.checksum = 1; +}; + +tcp_option: T_ERROR_QUEUE_LENGTH T_NUMBER +{ + __max_dedicated_links_reached(); + CONFIG(channelc).error_queue_length = $2; +}; + +hashsize : T_HASHSIZE T_NUMBER +{ + conf.hashsize = $2; +}; + +hashlimit: T_HASHLIMIT T_NUMBER +{ + conf.limit = $2; +}; + +unix_line: T_UNIX '{' unix_options '}'; + +unix_options: + | unix_options unix_option + ; + +unix_option : T_PATH T_PATH_VAL +{ + strcpy(conf.local.path, $2); +}; + +unix_option : T_BACKLOG T_NUMBER +{ + conf.local.backlog = $2; +}; + +ignore_protocol: T_IGNORE_PROTOCOL '{' ignore_proto_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_L4PROTO, + CT_FILTER_NEGATIVE); + + print_err(CTD_CFG_WARN, "the clause `IgnoreProtocol' is " + "obsolete. Use `Filter' instead"); +}; + +ignore_proto_list: + | ignore_proto_list ignore_proto + ; + +ignore_proto: T_NUMBER +{ + if ($1 < IPPROTO_MAX) + ct_filter_add_proto(STATE(us_filter), $1); + else + print_err(CTD_CFG_WARN, "protocol number `%d' is freak", $1); +}; + +ignore_proto: T_STRING +{ + struct protoent *pent; + + pent = getprotobyname($1); + if (pent == NULL) { + print_err(CTD_CFG_WARN, "getprotobyname() cannot find " + "protocol `%s' in /etc/protocols", $1); + break; + } + ct_filter_add_proto(STATE(us_filter), pent->p_proto); +}; + +sync: T_SYNC '{' sync_list '}' +{ + if (conf.flags & CTD_STATS_MODE) { + print_err(CTD_CFG_ERROR, "cannot use both `Stats' and `Sync' " + "clauses in conntrackd.conf"); + exit(EXIT_FAILURE); + } + conf.flags |= CTD_SYNC_MODE; +}; + +sync_list: + | sync_list sync_line; + +sync_line: refreshtime + | expiretime + | timeout + | purge + | checksum + | multicast_line + | udp_line + | tcp_line + | relax_transitions + | delay_destroy_msgs + | sync_mode_alarm + | sync_mode_ftfw + | sync_mode_notrack + | listen_to + | state_replication + | cache_writethrough + | destroy_timeout + ; + +sync_mode_alarm: T_SYNC_MODE T_ALARM '{' sync_mode_alarm_list '}' +{ + conf.flags |= CTD_SYNC_ALARM; +}; + +sync_mode_ftfw: T_SYNC_MODE T_FTFW '{' sync_mode_ftfw_list '}' +{ + conf.flags |= CTD_SYNC_FTFW; +}; + +sync_mode_notrack: T_SYNC_MODE T_NOTRACK '{' sync_mode_notrack_list '}' +{ + conf.flags |= CTD_SYNC_NOTRACK; +}; + +sync_mode_alarm_list: + | sync_mode_alarm_list sync_mode_alarm_line; + +sync_mode_alarm_line: refreshtime + | expiretime + | timeout + | purge + | relax_transitions + | delay_destroy_msgs + ; + +sync_mode_ftfw_list: + | sync_mode_ftfw_list sync_mode_ftfw_line; + +sync_mode_ftfw_line: resend_queue_size + | resend_buffer_size + | timeout + | purge + | window_size + | disable_external_cache + ; + +sync_mode_notrack_list: + | sync_mode_notrack_list sync_mode_notrack_line; + +sync_mode_notrack_line: timeout + | purge + | disable_internal_cache + | disable_external_cache + ; + +disable_internal_cache: T_DISABLE_INTERNAL_CACHE T_ON +{ + conf.sync.internal_cache_disable = 1; +}; + +disable_internal_cache: T_DISABLE_INTERNAL_CACHE T_OFF +{ + conf.sync.internal_cache_disable = 0; +}; + +disable_external_cache: T_DISABLE_EXTERNAL_CACHE T_ON +{ + conf.sync.external_cache_disable = 1; +}; + +disable_external_cache: T_DISABLE_EXTERNAL_CACHE T_OFF +{ + conf.sync.external_cache_disable = 0; +}; + +resend_buffer_size: T_RESEND_BUFFER_SIZE T_NUMBER +{ + print_err(CTD_CFG_WARN, "`ResendBufferSize' is deprecated. " + "Use `ResendQueueSize' instead"); +}; + +resend_queue_size: T_RESEND_QUEUE_SIZE T_NUMBER +{ + conf.resend_queue_size = $2; +}; + +window_size: T_WINDOWSIZE T_NUMBER +{ + conf.window_size = $2; +}; + +destroy_timeout: T_DESTROY_TIMEOUT T_NUMBER +{ + print_err(CTD_CFG_WARN, "`DestroyTimeout' is deprecated. Remove it"); +}; + +relax_transitions: T_RELAX_TRANSITIONS +{ + print_err(CTD_CFG_WARN, "`RelaxTransitions' clause is obsolete. " + "Please, remove it from conntrackd.conf"); +}; + +delay_destroy_msgs: T_DELAY +{ + print_err(CTD_CFG_WARN, "`DelayDestroyMessages' clause is obsolete. " + "Please, remove it from conntrackd.conf"); +}; + +listen_to: T_LISTEN_TO T_IP +{ + print_err(CTD_CFG_WARN, "the clause `ListenTo' is obsolete, ignoring"); +}; + +state_replication: T_REPLICATE states T_FOR state_proto +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_STATE, + CT_FILTER_POSITIVE); + + print_err(CTD_CFG_WARN, "the clause `Replicate' is obsolete. " + "Use `Filter' instead"); +}; + +states: + | states state; + +state_proto: T_STRING +{ + if (strncmp($1, "TCP", strlen("TCP")) != 0) { + print_err(CTD_CFG_WARN, "unsupported protocol `%s' in line %d", + $1, yylineno); + } +}; +state: tcp_state; + +tcp_states: + | tcp_states tcp_state; + +tcp_state: T_SYN_SENT +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_SYN_SENT); + + __kernel_filter_add_state(TCP_CONNTRACK_SYN_SENT); +}; +tcp_state: T_SYN_RECV +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_SYN_RECV); + + __kernel_filter_add_state(TCP_CONNTRACK_SYN_RECV); +}; +tcp_state: T_ESTABLISHED +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_ESTABLISHED); + + __kernel_filter_add_state(TCP_CONNTRACK_ESTABLISHED); +}; +tcp_state: T_FIN_WAIT +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_FIN_WAIT); + + __kernel_filter_add_state(TCP_CONNTRACK_FIN_WAIT); +}; +tcp_state: T_CLOSE_WAIT +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_CLOSE_WAIT); + + __kernel_filter_add_state(TCP_CONNTRACK_CLOSE_WAIT); +}; +tcp_state: T_LAST_ACK +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_LAST_ACK); + + __kernel_filter_add_state(TCP_CONNTRACK_LAST_ACK); +}; +tcp_state: T_TIME_WAIT +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_TIME_WAIT); + + __kernel_filter_add_state(TCP_CONNTRACK_TIME_WAIT); +}; +tcp_state: T_CLOSE +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_CLOSE); + + __kernel_filter_add_state(TCP_CONNTRACK_CLOSE); +}; +tcp_state: T_LISTEN +{ + ct_filter_add_state(STATE(us_filter), + IPPROTO_TCP, + TCP_CONNTRACK_LISTEN); + + __kernel_filter_add_state(TCP_CONNTRACK_LISTEN); +}; + +cache_writethrough: T_WRITE_THROUGH T_ON +{ + print_err(CTD_CFG_WARN, "`CacheWriteThrough' clause is obsolete, " + "ignoring"); +}; + +cache_writethrough: T_WRITE_THROUGH T_OFF +{ + print_err(CTD_CFG_WARN, "`CacheWriteThrough' clause is obsolete, " + "ignoring"); +}; + +general: T_GENERAL '{' general_list '}'; + +general_list: + | general_list general_line + ; + +general_line: hashsize + | hashlimit + | logfile_bool + | logfile_path + | syslog_facility + | syslog_bool + | lock + | unix_line + | netlink_buffer_size + | netlink_buffer_size_max_grown + | family + | event_iterations_limit + | poll_secs + | filter + | netlink_overrun_resync + | netlink_events_reliable + | nice + | scheduler + ; + +netlink_buffer_size: T_BUFFER_SIZE T_NUMBER +{ + conf.netlink_buffer_size = $2; +}; + +netlink_buffer_size_max_grown : T_BUFFER_SIZE_MAX_GROWN T_NUMBER +{ + conf.netlink_buffer_size_max_grown = $2; +}; + +netlink_overrun_resync : T_NETLINK_OVERRUN_RESYNC T_ON +{ + conf.nl_overrun_resync = 30; +}; + +netlink_overrun_resync : T_NETLINK_OVERRUN_RESYNC T_OFF +{ + conf.nl_overrun_resync = -1; +}; + +netlink_overrun_resync : T_NETLINK_OVERRUN_RESYNC T_NUMBER +{ + conf.nl_overrun_resync = $2; +}; + +netlink_events_reliable : T_NETLINK_EVENTS_RELIABLE T_ON +{ + conf.netlink.events_reliable = 1; +}; + +netlink_events_reliable : T_NETLINK_EVENTS_RELIABLE T_OFF +{ + conf.netlink.events_reliable = 0; +}; + +nice : T_NICE T_SIGNED_NUMBER +{ + conf.nice = $2; +}; + +scheduler : T_SCHEDULER '{' scheduler_options '}'; + +scheduler_options : + | scheduler_options scheduler_line + ; + +scheduler_line : T_TYPE T_STRING +{ + if (strcasecmp($2, "rr") == 0) { + conf.sched.type = SCHED_RR; + } else if (strcasecmp($2, "fifo") == 0) { + conf.sched.type = SCHED_FIFO; + } else { + print_err(CTD_CFG_ERROR, "unknown scheduler `%s'", $2); + exit(EXIT_FAILURE); + } +}; + +scheduler_line : T_PRIO T_NUMBER +{ + conf.sched.prio = $2; + if (conf.sched.prio < 0 || conf.sched.prio > 99) { + print_err(CTD_CFG_ERROR, "`Priority' must be [0, 99]\n", $2); + exit(EXIT_FAILURE); + } +}; + +family : T_FAMILY T_STRING +{ + if (strncmp($2, "IPv6", strlen("IPv6")) == 0) + conf.family = AF_INET6; + else + conf.family = AF_INET; +}; + +event_iterations_limit : T_EVENT_ITER_LIMIT T_NUMBER +{ + CONFIG(event_iterations_limit) = $2; +}; + +poll_secs: T_POLL_SECS T_NUMBER +{ + conf.flags |= CTD_POLL; + conf.poll_kernel_secs = $2; + if (conf.poll_kernel_secs == 0) { + print_err(CTD_CFG_ERROR, "`PollSecs' clause must be > 0"); + exit(EXIT_FAILURE); + } +}; + +filter : T_FILTER '{' filter_list '}' +{ + CONFIG(filter_from_kernelspace) = 0; +}; + +filter : T_FILTER T_FROM T_USERSPACE '{' filter_list '}' +{ + CONFIG(filter_from_kernelspace) = 0; +}; + +filter : T_FILTER T_FROM T_KERNELSPACE '{' filter_list '}' +{ + CONFIG(filter_from_kernelspace) = 1; +}; + +filter_list : + | filter_list filter_item; + +filter_item : T_PROTOCOL T_ACCEPT '{' filter_protocol_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_L4PROTO, + CT_FILTER_POSITIVE); + + __kernel_filter_start(); +}; + +filter_item : T_PROTOCOL T_IGNORE '{' filter_protocol_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_L4PROTO, + CT_FILTER_NEGATIVE); + + __kernel_filter_start(); + + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_L4PROTO, + NFCT_FILTER_LOGIC_NEGATIVE); +}; + +filter_protocol_list : + | filter_protocol_list filter_protocol_item; + +filter_protocol_item : T_STRING +{ + struct protoent *pent; + + pent = getprotobyname($1); + if (pent == NULL) { + print_err(CTD_CFG_WARN, "getprotobyname() cannot find " + "protocol `%s' in /etc/protocols", $1); + break; + } + ct_filter_add_proto(STATE(us_filter), pent->p_proto); + + __kernel_filter_start(); + + nfct_filter_add_attr_u32(STATE(filter), + NFCT_FILTER_L4PROTO, + pent->p_proto); +}; + +filter_protocol_item : T_TCP +{ + struct protoent *pent; + + pent = getprotobyname("tcp"); + if (pent == NULL) { + print_err(CTD_CFG_WARN, "getprotobyname() cannot find " + "protocol `tcp' in /etc/protocols"); + break; + } + ct_filter_add_proto(STATE(us_filter), pent->p_proto); + + __kernel_filter_start(); + + nfct_filter_add_attr_u32(STATE(filter), + NFCT_FILTER_L4PROTO, + pent->p_proto); +}; + +filter_item : T_ADDRESS T_ACCEPT '{' filter_address_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_ADDRESS, + CT_FILTER_POSITIVE); + + __kernel_filter_start(); +}; + +filter_item : T_ADDRESS T_IGNORE '{' filter_address_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_ADDRESS, + CT_FILTER_NEGATIVE); + + __kernel_filter_start(); + + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_SRC_IPV4, + NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_DST_IPV4, + NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_SRC_IPV6, + NFCT_FILTER_LOGIC_NEGATIVE); + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_DST_IPV6, + NFCT_FILTER_LOGIC_NEGATIVE); +}; + +filter_address_list : + | filter_address_list filter_address_item; + +filter_address_item : T_IPV4_ADDR T_IP +{ + union inet_address ip; + char *slash; + unsigned int cidr = 32; + + memset(&ip, 0, sizeof(union inet_address)); + + slash = strchr($2, '/'); + if (slash) { + *slash = '\0'; + cidr = atoi(slash+1); + if (cidr > 32) { + print_err(CTD_CFG_WARN, "%s/%d is not a valid network, " + "ignoring", $2, cidr); + break; + } + } + + if (!inet_aton($2, &ip.ipv4)) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv4, ignoring", $2); + break; + } + + if (slash && cidr < 32) { + /* network byte order */ + struct ct_filter_netmask_ipv4 tmp = { + .ip = ip.ipv4, + .mask = ipv4_cidr2mask_net(cidr) + }; + + if (!ct_filter_add_netmask(STATE(us_filter), &tmp, AF_INET)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "netmask %s is " + "repeated in the " + "ignore pool", $2); + } + } else { + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated in " + "the ignore pool", $2); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } + } + __kernel_filter_start(); + + /* host byte order */ + struct nfct_filter_ipv4 filter_ipv4 = { + .addr = ntohl(ip.ipv4), + .mask = ipv4_cidr2mask_host(cidr), + }; + + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_SRC_IPV4, &filter_ipv4); + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_DST_IPV4, &filter_ipv4); +}; + +filter_address_item : T_IPV6_ADDR T_IP +{ + union inet_address ip; + char *slash; + int cidr = 128; + struct nfct_filter_ipv6 filter_ipv6; + + memset(&ip, 0, sizeof(union inet_address)); + + slash = strchr($2, '/'); + if (slash) { + *slash = '\0'; + cidr = atoi(slash+1); + if (cidr > 128) { + print_err(CTD_CFG_WARN, "%s/%d is not a valid network, " + "ignoring", $2, cidr); + break; + } + } + +#ifdef HAVE_INET_PTON_IPV6 + if (inet_pton(AF_INET6, $2, &ip.ipv6) <= 0) { + print_err(CTD_CFG_WARN, "%s is not a valid IPv6, ignoring", $2); + break; + } +#else + print_err(CTD_CFG_WARN, "cannot find inet_pton(), IPv6 unsupported!"); + break; +#endif + if (slash && cidr < 128) { + struct ct_filter_netmask_ipv6 tmp; + + memcpy(tmp.ip, ip.ipv6, sizeof(uint32_t)*4); + ipv6_cidr2mask_net(cidr, tmp.mask); + if (!ct_filter_add_netmask(STATE(us_filter), &tmp, AF_INET6)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "netmask %s is " + "repeated in the " + "ignore pool", $2); + } + } else { + if (!ct_filter_add_ip(STATE(us_filter), &ip, AF_INET6)) { + if (errno == EEXIST) + print_err(CTD_CFG_WARN, "IP %s is repeated in " + "the ignore pool", $2); + if (errno == ENOSPC) + print_err(CTD_CFG_WARN, "too many IP in the " + "ignore pool!"); + } + } + __kernel_filter_start(); + + /* host byte order */ + ipv6_addr2addr_host(ip.ipv6, filter_ipv6.addr); + ipv6_cidr2mask_host(cidr, filter_ipv6.mask); + + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_SRC_IPV6, &filter_ipv6); + nfct_filter_add_attr(STATE(filter), NFCT_FILTER_DST_IPV6, &filter_ipv6); +}; + +filter_item : T_STATE T_ACCEPT '{' filter_state_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_STATE, + CT_FILTER_POSITIVE); + + __kernel_filter_start(); +}; + +filter_item : T_STATE T_IGNORE '{' filter_state_list '}' +{ + ct_filter_set_logic(STATE(us_filter), + CT_FILTER_STATE, + CT_FILTER_NEGATIVE); + + + __kernel_filter_start(); + + nfct_filter_set_logic(STATE(filter), + NFCT_FILTER_L4PROTO_STATE, + NFCT_FILTER_LOGIC_NEGATIVE); +}; + +filter_state_list : + | filter_state_list filter_state_item; + +filter_state_item : tcp_states T_FOR T_TCP; + +stats: T_STATS '{' stats_list '}' +{ + if (conf.flags & CTD_SYNC_MODE) { + print_err(CTD_CFG_ERROR, "cannot use both `Stats' and `Sync' " + "clauses in conntrackd.conf"); + exit(EXIT_FAILURE); + } + conf.flags |= CTD_STATS_MODE; +}; + +stats_list: + | stats_list stat_line + ; + +stat_line: stat_logfile_bool + | stat_logfile_path + | stat_syslog_bool + | stat_syslog_facility + | buffer_size + ; + +stat_logfile_bool : T_LOG T_ON +{ + strncpy(conf.stats.logfile, DEFAULT_STATS_LOGFILE, FILENAME_MAXLEN); +}; + +stat_logfile_bool : T_LOG T_OFF +{ +}; + +stat_logfile_path : T_LOG T_PATH_VAL +{ + strncpy(conf.stats.logfile, $2, FILENAME_MAXLEN); +}; + +stat_syslog_bool : T_SYSLOG T_ON +{ + conf.stats.syslog_facility = DEFAULT_SYSLOG_FACILITY; +}; + +stat_syslog_bool : T_SYSLOG T_OFF +{ + conf.stats.syslog_facility = -1; +} + +stat_syslog_facility : T_SYSLOG T_STRING +{ + if (!strcmp($2, "daemon")) + conf.stats.syslog_facility = LOG_DAEMON; + else if (!strcmp($2, "local0")) + conf.stats.syslog_facility = LOG_LOCAL0; + else if (!strcmp($2, "local1")) + conf.stats.syslog_facility = LOG_LOCAL1; + else if (!strcmp($2, "local2")) + conf.stats.syslog_facility = LOG_LOCAL2; + else if (!strcmp($2, "local3")) + conf.stats.syslog_facility = LOG_LOCAL3; + else if (!strcmp($2, "local4")) + conf.stats.syslog_facility = LOG_LOCAL4; + else if (!strcmp($2, "local5")) + conf.stats.syslog_facility = LOG_LOCAL5; + else if (!strcmp($2, "local6")) + conf.stats.syslog_facility = LOG_LOCAL6; + else if (!strcmp($2, "local7")) + conf.stats.syslog_facility = LOG_LOCAL7; + else { + print_err(CTD_CFG_WARN, "'%s' is not a known syslog facility, " + "ignoring.", $2); + break; + } + + if (conf.syslog_facility != -1 && + conf.stats.syslog_facility != conf.syslog_facility) + print_err(CTD_CFG_WARN, "conflicting Syslog facility " + "values, defaulting to General"); +}; + +buffer_size: T_STAT_BUFFER_SIZE T_NUMBER +{ + print_err(CTD_CFG_WARN, "`LogFileBufferSize' is deprecated"); +}; + +%% + +int __attribute__((noreturn)) +yyerror(char *msg) +{ + print_err(CTD_CFG_ERROR, "parsing config file in " + "line (%d), symbol '%s': %s", + yylineno, yytext, msg); + exit(EXIT_FAILURE); +} + +static void print_err(int type, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + switch(type) { + case CTD_CFG_ERROR: + fprintf(stderr, "ERROR: "); + break; + case CTD_CFG_WARN: + fprintf(stderr, "WARNING: "); + break; + default: + fprintf(stderr, "?: "); + } + vfprintf(stderr, msg, args); + va_end(args); + fprintf(stderr,"\n"); +} + +static void __kernel_filter_start(void) +{ + if (!STATE(filter)) { + STATE(filter) = nfct_filter_create(); + if (!STATE(filter)) { + print_err(CTD_CFG_ERROR, "cannot create ignore pool!"); + exit(EXIT_FAILURE); + } + } +} + +static void __kernel_filter_add_state(int value) +{ + __kernel_filter_start(); + + struct nfct_filter_proto filter_proto = { + .proto = IPPROTO_TCP, + .state = value + }; + nfct_filter_add_attr(STATE(filter), + NFCT_FILTER_L4PROTO_STATE, + &filter_proto); +} + +static void __max_dedicated_links_reached(void) +{ + if (conf.channel_num >= MULTICHANNEL_MAX) { + print_err(CTD_CFG_ERROR, "too many dedicated links in " + "the configuration file " + "(Maximum: %d)", MULTICHANNEL_MAX); + exit(EXIT_FAILURE); + } +} + +int +init_config(char *filename) +{ + FILE *fp; + + fp = fopen(filename, "r"); + if (!fp) + return -1; + + /* Zero may be a valid facility */ + CONFIG(syslog_facility) = -1; + CONFIG(stats).syslog_facility = -1; + + yyrestart(fp); + yyparse(); + fclose(fp); + + /* default to IPv4 */ + if (CONFIG(family) == 0) + CONFIG(family) = AF_INET; + + /* set to default is not specified */ + if (strcmp(CONFIG(lockfile), "") == 0) + strncpy(CONFIG(lockfile), DEFAULT_LOCKFILE, FILENAME_MAXLEN); + + /* default to 180 seconds of expiration time: cache entries */ + if (CONFIG(cache_timeout) == 0) + CONFIG(cache_timeout) = 180; + + /* default to 60 seconds: purge kernel entries */ + if (CONFIG(purge_timeout) == 0) + CONFIG(purge_timeout) = 60; + + /* default to 60 seconds of refresh time */ + if (CONFIG(refresh) == 0) + CONFIG(refresh) = 60; + + if (CONFIG(resend_queue_size) == 0) + CONFIG(resend_queue_size) = 131072; + + /* default to a window size of 300 packets */ + if (CONFIG(window_size) == 0) + CONFIG(window_size) = 300; + + if (CONFIG(event_iterations_limit) == 0) + CONFIG(event_iterations_limit) = 100; + + /* default number of bucket of the hashtable that are committed in + one run loop. XXX: no option available to tune this value yet. */ + if (CONFIG(general).commit_steps == 0) + CONFIG(general).commit_steps = 64; + + /* if overrun, automatically resync with kernel after 30 seconds */ + if (CONFIG(nl_overrun_resync) == 0) + CONFIG(nl_overrun_resync) = 30; + + /* default to 128 elements in the channel error queue */ + if (CONFIG(channelc).error_queue_length == 0) + CONFIG(channelc).error_queue_length = 128; + + return 0; +} diff --git a/src/run.c b/src/run.c new file mode 100644 index 0000000..803bbcc --- /dev/null +++ b/src/run.c @@ -0,0 +1,572 @@ +/* + * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Description: run and init functions + */ + +#include "conntrackd.h" +#include "netlink.h" +#include "filter.h" +#include "log.h" +#include "alarm.h" +#include "fds.h" +#include "traffic_stats.h" +#include "process.h" +#include "origin.h" +#include "date.h" +#include "internal.h" + +#include <errno.h> +#include <signal.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/wait.h> +#include <string.h> +#include <time.h> +#include <fcntl.h> + +void killer(int foo) +{ + /* no signals while handling signals */ + sigprocmask(SIG_BLOCK, &STATE(block), NULL); + + if (!(CONFIG(flags) & CTD_POLL)) + nfct_close(STATE(event)); + + nfct_close(STATE(resync)); + nfct_close(STATE(get)); + origin_unregister(STATE(flush)); + nfct_close(STATE(flush)); + + if (STATE(us_filter)) + ct_filter_destroy(STATE(us_filter)); + local_server_destroy(&STATE(local)); + STATE(mode)->kill(); + + if (STATE(mode)->internal->flags & INTERNAL_F_POPULATE) { + nfct_close(STATE(dump)); + } + destroy_fds(STATE(fds)); + + unlink(CONFIG(lockfile)); + dlog(LOG_NOTICE, "---- shutdown received ----"); + close_log(); + + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + + exit(0); +} + +static void child(int foo) +{ + int status, ret; + + while ((ret = waitpid(0, &status, WNOHANG)) != 0) { + if (ret == -1) { + if (errno == EINTR) + continue; + if (errno == ECHILD) + break; + STATE(stats).wait_failed++; + break; + } + /* delete process from list and run the callback */ + fork_process_delete(ret); + + if (!WIFSIGNALED(status)) + continue; + + switch(WTERMSIG(status)) { + case SIGSEGV: + dlog(LOG_ERR, "child process (pid=%u) has aborted, " + "received signal SIGSEGV (crashed)", ret); + STATE(stats).child_process_failed++; + STATE(stats).child_process_error_segfault++; + break; + case SIGINT: + case SIGTERM: + case SIGKILL: + dlog(LOG_ERR, "child process (pid=%u) has aborted, " + "received termination signal (%u)", + ret, WTERMSIG(status)); + STATE(stats).child_process_failed++; + STATE(stats).child_process_error_term++; + break; + default: + dlog(LOG_NOTICE, "child process (pid=%u) " + "received signal (%u)", + ret, WTERMSIG(status)); + STATE(stats).child_process_failed++; + break; + } + } +} + +static void uptime(char *buf, size_t bufsiz) +{ + time_t tmp; + int updays, upminutes, uphours; + size_t size = 0; + + time(&tmp); + tmp = tmp - STATE(stats).daemon_start_time; + updays = (int) tmp / (60*60*24); + if (updays) { + size = snprintf(buf, bufsiz, "%d day%s ", + updays, (updays != 1) ? "s" : ""); + } + upminutes = (int) tmp / 60; + uphours = (upminutes / 60) % 24; + upminutes %= 60; + if(uphours) { + snprintf(buf + size, bufsiz, "%d h %d min", uphours, upminutes); + } else { + snprintf(buf + size, bufsiz, "%d min", upminutes); + } +} + +static void dump_stats_runtime(int fd) +{ + char buf[1024], uptime_string[512]; + int size; + + uptime(uptime_string, sizeof(uptime_string)); + size = snprintf(buf, sizeof(buf), + "daemon uptime: %s\n\n" + "netlink stats:\n" + "\tevents received:\t%20llu\n" + "\tevents filtered:\t%20llu\n" + "\tevents unknown type:\t\t%12u\n" + "\tcatch event failed:\t\t%12u\n" + "\tdump unknown type:\t\t%12u\n" + "\tnetlink overrun:\t\t%12u\n" + "\tflush kernel table:\t\t%12u\n" + "\tresync with kernel table:\t%12u\n" + "\tcurrent buffer size (in bytes):\t%12u\n\n" + "runtime stats:\n" + "\tchild process failed:\t\t%12u\n" + "\t\tchild process segfault:\t%12u\n" + "\t\tchild process termsig:\t%12u\n" + "\tselect failed:\t\t\t%12u\n" + "\twait failed:\t\t\t%12u\n" + "\tlocal read failed:\t\t%12u\n" + "\tlocal unknown request:\t\t%12u\n\n", + uptime_string, + (unsigned long long)STATE(stats).nl_events_received, + (unsigned long long)STATE(stats).nl_events_filtered, + STATE(stats).nl_events_unknown_type, + STATE(stats).nl_catch_event_failed, + STATE(stats).nl_dump_unknown_type, + STATE(stats).nl_overrun, + STATE(stats).nl_kernel_table_flush, + STATE(stats).nl_kernel_table_resync, + CONFIG(netlink_buffer_size), + STATE(stats).child_process_failed, + STATE(stats).child_process_error_segfault, + STATE(stats).child_process_error_term, + STATE(stats).select_failed, + STATE(stats).wait_failed, + STATE(stats).local_read_failed, + STATE(stats).local_unknown_request); + + send(fd, buf, size, 0); +} + +static int local_handler(int fd, void *data) +{ + int ret = LOCAL_RET_OK; + int type; + + ret = read(fd, &type, sizeof(type)); + if (ret == -1) { + STATE(stats).local_read_failed++; + return LOCAL_RET_OK; + } + if (ret == 0) + return LOCAL_RET_OK; + + switch(type) { + case FLUSH_MASTER: + STATE(stats).nl_kernel_table_flush++; + dlog(LOG_NOTICE, "flushing kernel conntrack table"); + + /* fork a child process that performs the flush operation, + * meanwhile the parent process handles events. */ + if (fork_process_new(CTD_PROC_FLUSH, CTD_PROC_F_EXCL, + NULL, NULL) == 0) { + nl_flush_conntrack_table(STATE(flush)); + exit(EXIT_SUCCESS); + } + break; + case RESYNC_MASTER: + if (STATE(mode)->internal->flags & INTERNAL_F_POPULATE) { + STATE(stats).nl_kernel_table_resync++; + dlog(LOG_NOTICE, "resync with master table"); + nl_dump_conntrack_table(STATE(dump)); + } else { + dlog(LOG_NOTICE, "resync is unsupported in this mode"); + } + break; + case STATS_RUNTIME: + dump_stats_runtime(fd); + break; + case STATS_PROCESS: + fork_process_dump(fd); + break; + } + + ret = STATE(mode)->local(fd, type, data); + if (ret == LOCAL_RET_ERROR) { + STATE(stats).local_unknown_request++; + return LOCAL_RET_ERROR; + } + return ret; +} + +static void do_overrun_resync_alarm(struct alarm_block *a, void *data) +{ + nl_send_resync(STATE(resync)); + STATE(stats).nl_kernel_table_resync++; +} + +static void do_polling_alarm(struct alarm_block *a, void *data) +{ + if (STATE(mode)->internal->purge) + STATE(mode)->internal->purge(); + + nl_send_resync(STATE(resync)); + add_alarm(&STATE(polling_alarm), CONFIG(poll_kernel_secs), 0); +} + +static int event_handler(const struct nlmsghdr *nlh, + enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + int origin_type; + + STATE(stats).nl_events_received++; + + /* skip user-space filtering if already do it in the kernel */ + if (ct_filter_conntrack(ct, !CONFIG(filter_from_kernelspace))) { + STATE(stats).nl_events_filtered++; + goto out; + } + + origin_type = origin_find(nlh); + + switch(type) { + case NFCT_T_NEW: + STATE(mode)->internal->new(ct, origin_type); + break; + case NFCT_T_UPDATE: + STATE(mode)->internal->update(ct, origin_type); + break; + case NFCT_T_DESTROY: + if (STATE(mode)->internal->destroy(ct, origin_type)) + update_traffic_stats(ct); + break; + default: + STATE(stats).nl_events_unknown_type++; + break; + } + +out: + if (STATE(event_iterations_limit)-- <= 0) { + STATE(event_iterations_limit) = CONFIG(event_iterations_limit); + return NFCT_CB_STOP; + } else + return NFCT_CB_CONTINUE; +} + +static int dump_handler(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + if (ct_filter_conntrack(ct, 1)) + return NFCT_CB_CONTINUE; + + switch(type) { + case NFCT_T_UPDATE: + STATE(mode)->internal->populate(ct); + break; + default: + STATE(stats).nl_dump_unknown_type++; + break; + } + return NFCT_CB_CONTINUE; +} + +static int get_handler(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + if (ct_filter_conntrack(ct, 1)) + return NFCT_CB_CONTINUE; + + STATE(get_retval) = 1; + return NFCT_CB_CONTINUE; +} + +int +init(void) +{ + if (CONFIG(flags) & CTD_STATS_MODE) + STATE(mode) = &stats_mode; + else if (CONFIG(flags) & CTD_SYNC_MODE) + STATE(mode) = &sync_mode; + else { + fprintf(stderr, "WARNING: No running mode specified. " + "Defaulting to statistics mode.\n"); + CONFIG(flags) |= CTD_STATS_MODE; + STATE(mode) = &stats_mode; + } + + STATE(fds) = create_fds(); + if (STATE(fds) == NULL) { + dlog(LOG_ERR, "can't create file descriptor pool"); + return -1; + } + + /* Initialization */ + if (STATE(mode)->init() == -1) { + dlog(LOG_ERR, "initialization failed"); + return -1; + } + + /* local UNIX socket */ + if (local_server_create(&STATE(local), &CONFIG(local)) == -1) { + dlog(LOG_ERR, "can't open unix socket!"); + return -1; + } + register_fd(STATE(local).fd, STATE(fds)); + + if (!(CONFIG(flags) & CTD_POLL)) { + STATE(event) = nl_init_event_handler(); + if (STATE(event) == NULL) { + dlog(LOG_ERR, "can't open netlink handler: %s", + strerror(errno)); + dlog(LOG_ERR, "no ctnetlink kernel support?"); + return -1; + } + nfct_callback_register2(STATE(event), NFCT_T_ALL, + event_handler, NULL); + register_fd(nfct_fd(STATE(event)), STATE(fds)); + } + + /* resynchronize (like 'dump' socket) but it also purges old entries */ + STATE(resync) = nfct_open(CONNTRACK, 0); + if (STATE(resync)== NULL) { + dlog(LOG_ERR, "can't open netlink handler: %s", + strerror(errno)); + dlog(LOG_ERR, "no ctnetlink kernel support?"); + return -1; + } + nfct_callback_register(STATE(resync), + NFCT_T_ALL, + STATE(mode)->internal->resync, + NULL); + register_fd(nfct_fd(STATE(resync)), STATE(fds)); + fcntl(nfct_fd(STATE(resync)), F_SETFL, O_NONBLOCK); + + if (STATE(mode)->internal->flags & INTERNAL_F_POPULATE) { + STATE(dump) = nfct_open(CONNTRACK, 0); + if (STATE(dump) == NULL) { + dlog(LOG_ERR, "can't open netlink handler: %s", + strerror(errno)); + dlog(LOG_ERR, "no ctnetlink kernel support?"); + return -1; + } + nfct_callback_register(STATE(dump), NFCT_T_ALL, + dump_handler, NULL); + + if (nl_dump_conntrack_table(STATE(dump)) == -1) { + dlog(LOG_ERR, "can't get kernel conntrack table"); + return -1; + } + } + + STATE(get) = nfct_open(CONNTRACK, 0); + if (STATE(get) == NULL) { + dlog(LOG_ERR, "can't open netlink handler: %s", + strerror(errno)); + dlog(LOG_ERR, "no ctnetlink kernel support?"); + return -1; + } + nfct_callback_register(STATE(get), NFCT_T_ALL, get_handler, NULL); + + STATE(flush) = nfct_open(CONNTRACK, 0); + if (STATE(flush) == NULL) { + dlog(LOG_ERR, "cannot open flusher handler"); + return -1; + } + /* register this handler as the origin of a flush operation */ + origin_register(STATE(flush), CTD_ORIGIN_FLUSH); + + if (CONFIG(flags) & CTD_POLL) { + init_alarm(&STATE(polling_alarm), NULL, do_polling_alarm); + add_alarm(&STATE(polling_alarm), CONFIG(poll_kernel_secs), 0); + dlog(LOG_NOTICE, "running in polling mode"); + } else { + init_alarm(&STATE(resync_alarm), NULL, do_overrun_resync_alarm); + } + + /* Signals handling */ + sigemptyset(&STATE(block)); + sigaddset(&STATE(block), SIGTERM); + sigaddset(&STATE(block), SIGINT); + sigaddset(&STATE(block), SIGCHLD); + + if (signal(SIGINT, killer) == SIG_ERR) + return -1; + + if (signal(SIGTERM, killer) == SIG_ERR) + return -1; + + /* ignore connection reset by peer */ + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) + return -1; + + if (signal(SIGCHLD, child) == SIG_ERR) + return -1; + + time(&STATE(stats).daemon_start_time); + + dlog(LOG_NOTICE, "initialization completed"); + + return 0; +} + +static void __run(struct timeval *next_alarm) +{ + int ret; + fd_set readfds = STATE(fds)->readfds; + + ret = select(STATE(fds)->maxfd + 1, &readfds, NULL, NULL, next_alarm); + if (ret == -1) { + /* interrupted syscall, retry */ + if (errno == EINTR) + return; + + STATE(stats).select_failed++; + return; + } + + /* signals are racy */ + sigprocmask(SIG_BLOCK, &STATE(block), NULL); + + /* order received via UNIX socket */ + if (FD_ISSET(STATE(local).fd, &readfds)) + do_local_server_step(&STATE(local), NULL, local_handler); + + if (!(CONFIG(flags) & CTD_POLL)) { + /* conntrack event has happened */ + if (FD_ISSET(nfct_fd(STATE(event)), &readfds)) { + ret = nfct_catch(STATE(event)); + /* reset event iteration limit counter */ + STATE(event_iterations_limit) = + CONFIG(event_iterations_limit); + if (ret == -1) { + switch(errno) { + case ENOBUFS: + /* We have hit ENOBUFS, it's likely that we are + * losing events. Two possible situations may + * trigger this error: + * + * 1) The netlink receiver buffer is too small: + * increasing the netlink buffer size should + * be enough. However, some event messages + * got lost. We have to resync ourselves + * with the kernel table conntrack table to + * resolve the inconsistency. + * + * 2) The receiver is too slow to process the + * netlink messages so that the queue gets + * full quickly. This generally happens + * if the system is under heavy workload + * (busy CPU). In this case, increasing the + * size of the netlink receiver buffer + * would not help anymore since we would + * be delaying the overrun. Moreover, we + * should avoid resynchronizations. We + * should do our best here and keep + * replicating as much states as possible. + * If workload lowers at some point, + * we resync ourselves. + */ + nl_resize_socket_buffer(STATE(event)); + if (CONFIG(nl_overrun_resync) > 0 && + STATE(mode)->internal->flags & + INTERNAL_F_RESYNC) { + add_alarm(&STATE(resync_alarm), + CONFIG(nl_overrun_resync),0); + } + STATE(stats).nl_catch_event_failed++; + STATE(stats).nl_overrun++; + break; + case ENOENT: + /* + * We received a message from another + * netfilter subsystem that we are not + * interested in. Just ignore it. + */ + break; + case EAGAIN: + break; + default: + STATE(stats).nl_catch_event_failed++; + break; + } + } + } + if (FD_ISSET(nfct_fd(STATE(resync)), &readfds)) { + nfct_catch(STATE(resync)); + if (STATE(mode)->internal->purge) + STATE(mode)->internal->purge(); + } + } else { + /* using polling mode */ + if (FD_ISSET(nfct_fd(STATE(resync)), &readfds)) { + nfct_catch(STATE(resync)); + } + } + + if (STATE(mode)->run) + STATE(mode)->run(&readfds); + + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); +} + +void __attribute__((noreturn)) +run(void) +{ + struct timeval next_alarm; + struct timeval *next = NULL; + + while(1) { + do_gettimeofday(); + + sigprocmask(SIG_BLOCK, &STATE(block), NULL); + if (next != NULL && !timerisset(next)) + next = do_alarm_run(&next_alarm); + else + next = get_next_alarm_run(&next_alarm); + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + + __run(next); + } +} diff --git a/src/stats-mode.c b/src/stats-mode.c new file mode 100644 index 0000000..0403ce2 --- /dev/null +++ b/src/stats-mode.c @@ -0,0 +1,206 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "netlink.h" +#include "traffic_stats.h" +#include "cache.h" +#include "log.h" +#include "conntrackd.h" +#include "internal.h" + +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <libnetfilter_conntrack/libnetfilter_conntrack.h> + +static int init_stats(void) +{ + state.stats = malloc(sizeof(struct ct_stats_state)); + if (!state.stats) { + dlog(LOG_ERR, "can't allocate memory for stats"); + return -1; + } + memset(state.stats, 0, sizeof(struct ct_stats_state)); + + STATE_STATS(cache) = cache_create("stats", NO_FEATURES, NULL); + if (!STATE_STATS(cache)) { + dlog(LOG_ERR, "can't allocate memory for the " + "external cache"); + free(state.stats); + return -1; + } + + return 0; +} + +static void kill_stats(void) +{ + cache_destroy(STATE_STATS(cache)); +} + +/* handler for requests coming via UNIX socket */ +static int local_handler_stats(int fd, int type, void *data) +{ + int ret = LOCAL_RET_OK; + + switch(type) { + case DUMP_INTERNAL: + cache_dump(STATE_STATS(cache), fd, NFCT_O_PLAIN); + break; + case DUMP_INT_XML: + cache_dump(STATE_STATS(cache), fd, NFCT_O_XML); + break; + case FLUSH_CACHE: + case FLUSH_INT_CACHE: + dlog(LOG_NOTICE, "flushing caches"); + cache_flush(STATE_STATS(cache)); + break; + case KILL: + killer(0); + break; + case STATS: + cache_stats(STATE_STATS(cache), fd); + dump_traffic_stats(fd); + break; + case STATS_CACHE: + cache_stats_extended(STATE_STATS(cache), fd); + break; + default: + ret = 0; + break; + } + + return ret; +} + +static void populate_stats(struct nf_conntrack *ct) +{ + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_TIMEOUT); + nfct_attr_unset(ct, ATTR_USE); + + cache_update_force(STATE_STATS(cache), ct); +} + +static int resync_stats(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, + void *data) +{ + if (ct_filter_conntrack(ct, 1)) + return NFCT_CB_CONTINUE; + + /* This is required by kernels < 2.6.20 */ + nfct_attr_unset(ct, ATTR_TIMEOUT); + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_ORIG_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_BYTES); + nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); + nfct_attr_unset(ct, ATTR_USE); + + cache_update_force(STATE_STATS(cache), ct); + + return NFCT_CB_CONTINUE; +} + +static int purge_step(void *data1, void *data2) +{ + struct cache_object *obj = data2; + + STATE(get_retval) = 0; + nl_get_conntrack(STATE(get), obj->ct); /* modifies STATE(get_retval) */ + if (!STATE(get_retval)) { + cache_del(STATE_STATS(cache), obj); + dlog_ct(STATE(stats_log), obj->ct, NFCT_O_PLAIN); + cache_object_free(obj); + } + + return 0; +} + +static void purge_stats(void) +{ + cache_iterate(STATE_STATS(cache), NULL, purge_step); +} + +static void +event_new_stats(struct nf_conntrack *ct, int origin) +{ + int id; + struct cache_object *obj; + + nfct_attr_unset(ct, ATTR_TIMEOUT); + + obj = cache_find(STATE_STATS(cache), ct, &id); + if (obj == NULL) { + obj = cache_object_new(STATE_STATS(cache), ct); + if (obj == NULL) + return; + + if (cache_add(STATE_STATS(cache), obj, id) == -1) { + cache_object_free(obj); + return; + } + } + return; +} + +static void +event_update_stats(struct nf_conntrack *ct, int origin) +{ + nfct_attr_unset(ct, ATTR_TIMEOUT); + cache_update_force(STATE_STATS(cache), ct); +} + +static int +event_destroy_stats(struct nf_conntrack *ct, int origin) +{ + int id; + struct cache_object *obj; + + nfct_attr_unset(ct, ATTR_TIMEOUT); + + obj = cache_find(STATE_STATS(cache), ct, &id); + if (obj) { + cache_del(STATE_STATS(cache), obj); + dlog_ct(STATE(stats_log), ct, NFCT_O_PLAIN); + cache_object_free(obj); + return 1; + } + return 0; +} + +static struct internal_handler internal_cache_stats = { + .flags = INTERNAL_F_POPULATE | INTERNAL_F_RESYNC, + .populate = populate_stats, + .resync = resync_stats, + .purge = purge_stats, + .new = event_new_stats, + .update = event_update_stats, + .destroy = event_destroy_stats +}; + +struct ct_mode stats_mode = { + .init = init_stats, + .run = NULL, + .local = local_handler_stats, + .kill = kill_stats, + .internal = &internal_cache_stats, +}; diff --git a/src/sync-alarm.c b/src/sync-alarm.c new file mode 100644 index 0000000..0fc7943 --- /dev/null +++ b/src/sync-alarm.c @@ -0,0 +1,161 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "conntrackd.h" +#include "sync.h" +#include "network.h" +#include "alarm.h" +#include "cache.h" +#include "queue.h" + +#include <stdlib.h> +#include <string.h> + +struct cache_alarm { + struct queue_node qnode; + struct alarm_block alarm; +}; + +static void alarm_enqueue(struct cache_object *obj, int query); + +static void refresher(struct alarm_block *a, void *data) +{ + struct cache_object *obj = data; + + add_alarm(a, + random() % CONFIG(refresh) + 1, + ((random() % 5 + 1) * 200000) - 1); + + alarm_enqueue(obj, NET_T_STATE_UPD); +} + +static void cache_alarm_add(struct cache_object *obj, void *data) +{ + struct cache_alarm *ca = data; + + queue_node_init(&ca->qnode, Q_ELEM_OBJ); + init_alarm(&ca->alarm, obj, refresher); + add_alarm(&ca->alarm, + random() % CONFIG(refresh) + 1, + ((random() % 5 + 1) * 200000) - 1); +} + +static void cache_alarm_update(struct cache_object *obj, void *data) +{ + struct cache_alarm *ca = data; + add_alarm(&ca->alarm, + random() % CONFIG(refresh) + 1, + ((random() % 5 + 1) * 200000) - 1); +} + +static void cache_alarm_destroy(struct cache_object *obj, void *data) +{ + struct cache_alarm *ca = data; + queue_del(&ca->qnode); + del_alarm(&ca->alarm); +} + +static struct cache_extra cache_alarm_extra = { + .size = sizeof(struct cache_alarm), + .add = cache_alarm_add, + .update = cache_alarm_update, + .destroy = cache_alarm_destroy +}; + +static int alarm_recv(const struct nethdr *net) +{ + unsigned int exp_seq; + + /* + * Ignore error messages: Although this message type is not ever + * generated in alarm mode, we don't want to crash the daemon + * if someone nuts mixes ftfw and alarm. + */ + if (net->flags) + return 1; + + /* + * Multicast sequence tracking: we keep track of multicast messages + * although we don't do any explicit message recovery. So, why do + * we do sequence tracking? Just to let know the sysadmin. + * + * Let t be 1 < t < RefreshTime. To ensure consistency, conntrackd + * retransmit every t seconds a message with the state of a certain + * entry even if such entry did not change. This mechanism also + * provides passive resynchronization, in other words, there is + * no facility to request a full synchronization from new nodes that + * just joined the cluster, instead they just get resynchronized in + * RefreshTime seconds at worst case. + */ + nethdr_track_seq(net->seq, &exp_seq); + + return 0; +} + +static void alarm_enqueue(struct cache_object *obj, int query) +{ + struct cache_alarm *ca = + cache_get_extra(STATE(mode)->internal->data, obj); + if (queue_add(STATE_SYNC(tx_queue), &ca->qnode)) + cache_object_get(obj); +} + +static int tx_queue_xmit(struct queue_node *n, const void *data) +{ + struct nethdr *net; + + queue_del(n); + + switch(n->type) { + case Q_ELEM_CTL: + net = queue_node_data(n); + nethdr_set_ctl(net); + HDR_HOST2NETWORK(net); + multichannel_send(STATE_SYNC(channel), net); + queue_object_free((struct queue_object *)n); + break; + case Q_ELEM_OBJ: { + struct cache_alarm *ca; + struct cache_object *obj; + int type; + + ca = (struct cache_alarm *)n; + obj = cache_data_get_object(STATE(mode)->internal->data, ca); + type = object_status_to_network_type(obj->status); + net = BUILD_NETMSG(obj->ct, type); + multichannel_send(STATE_SYNC(channel), net); + cache_object_put(obj); + break; + } + } + return 0; +} + +static void alarm_xmit(void) +{ + queue_iterate(STATE_SYNC(tx_queue), NULL, tx_queue_xmit); +} + +struct sync_mode sync_alarm = { + .internal_cache_flags = NO_FEATURES, + .external_cache_flags = TIMER, + .internal_cache_extra = &cache_alarm_extra, + .recv = alarm_recv, + .enqueue = alarm_enqueue, + .xmit = alarm_xmit, +}; diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c new file mode 100644 index 0000000..86edeab --- /dev/null +++ b/src/sync-ftfw.c @@ -0,0 +1,572 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "conntrackd.h" +#include "sync.h" +#include "queue.h" +#include "network.h" +#include "alarm.h" +#include "log.h" +#include "cache.h" +#include "fds.h" + +#include <string.h> +#include <errno.h> + +#if 0 +#define dp printf +#else +#define dp(...) +#endif + +struct queue *rs_queue; +static uint32_t exp_seq; +static uint32_t window; +static uint32_t ack_from; +static int ack_from_set = 0; +static struct alarm_block alive_alarm; + +enum { + HELLO_INIT, + HELLO_SAY, + HELLO_DONE, +}; +static int hello_state = HELLO_INIT; +static int say_hello_back; + +/* XXX: alive message expiration configurable */ +#define ALIVE_INT 1 + +struct cache_ftfw { + struct queue_node qnode; + uint32_t seq; +}; + +static void cache_ftfw_add(struct cache_object *obj, void *data) +{ + struct cache_ftfw *cn = data; + /* These nodes are not inserted in the list */ + queue_node_init(&cn->qnode, Q_ELEM_OBJ); +} + +static void cache_ftfw_del(struct cache_object *obj, void *data) +{ + struct cache_ftfw *cn = data; + queue_del(&cn->qnode); +} + +static struct cache_extra cache_ftfw_extra = { + .size = sizeof(struct cache_ftfw), + .add = cache_ftfw_add, + .destroy = cache_ftfw_del +}; + +static void nethdr_set_hello(struct nethdr *net) +{ + switch(hello_state) { + case HELLO_INIT: + hello_state = HELLO_SAY; + /* fall through */ + case HELLO_SAY: + net->flags |= NET_F_HELLO; + break; + } + if (say_hello_back) { + net->flags |= NET_F_HELLO_BACK; + say_hello_back = 0; + } +} + +static void tx_queue_add_ctlmsg(uint32_t flags, uint32_t from, uint32_t to) +{ + struct queue_object *qobj; + struct nethdr_ack *ack; + + qobj = queue_object_new(Q_ELEM_CTL, sizeof(struct nethdr_ack)); + if (qobj == NULL) + return; + + ack = (struct nethdr_ack *)qobj->data; + ack->type = NET_T_CTL; + ack->flags = flags; + ack->from = from; + ack->to = to; + + queue_add(STATE_SYNC(tx_queue), &qobj->qnode); +} + +static void tx_queue_add_ctlmsg2(uint32_t flags) +{ + struct queue_object *qobj; + struct nethdr *ctl; + + qobj = queue_object_new(Q_ELEM_CTL, sizeof(struct nethdr_ack)); + if (qobj == NULL) + return; + + ctl = (struct nethdr *)qobj->data; + ctl->type = NET_T_CTL; + ctl->flags = flags; + + queue_add(STATE_SYNC(tx_queue), &qobj->qnode); +} + +/* this function is called from the alarm framework */ +static void do_alive_alarm(struct alarm_block *a, void *data) +{ + if (ack_from_set && nethdr_track_is_seq_set()) { + /* exp_seq contains the last update received */ + tx_queue_add_ctlmsg(NET_F_ACK, + ack_from, + STATE_SYNC(last_seq_recv)); + ack_from_set = 0; + } else + tx_queue_add_ctlmsg2(NET_F_ALIVE); + + add_alarm(&alive_alarm, ALIVE_INT, 0); +} + +static int ftfw_init(void) +{ + rs_queue = queue_create("rsqueue", CONFIG(resend_queue_size), 0); + if (rs_queue == NULL) { + dlog(LOG_ERR, "cannot create rs queue"); + return -1; + } + + init_alarm(&alive_alarm, NULL, do_alive_alarm); + add_alarm(&alive_alarm, ALIVE_INT, 0); + + /* set ack window size */ + window = CONFIG(window_size); + + return 0; +} + +static void ftfw_kill(void) +{ + queue_destroy(rs_queue); +} + +static int do_cache_to_tx(void *data1, void *data2) +{ + struct cache_object *obj = data2; + struct cache_ftfw *cn = + cache_get_extra(STATE(mode)->internal->data, obj); + + if (queue_in(rs_queue, &cn->qnode)) { + queue_del(&cn->qnode); + queue_add(STATE_SYNC(tx_queue), &cn->qnode); + } else { + if (queue_add(STATE_SYNC(tx_queue), &cn->qnode)) + cache_object_get(obj); + } + return 0; +} + +static int rs_queue_dump(struct queue_node *n, const void *data2) +{ + const int *fd = data2; + char buf[512]; + int size; + + switch(n->type) { + case Q_ELEM_CTL: { + struct nethdr *net = queue_node_data(n); + size = sprintf(buf, "control -> seq:%u flags:%u\n", + net->seq, net->flags); + break; + } + case Q_ELEM_OBJ: { + struct cache_ftfw *cn = (struct cache_ftfw *) n; + size = sprintf(buf, "object -> seq:%u\n", cn->seq); + break; + } + default: + return 0; + } + send(*fd, buf, size, 0); + return 0; +} + +static void ftfw_local_queue(int fd) +{ + char buf[512]; + int size; + + size = sprintf(buf, "resent queue (len=%u)\n", queue_len(rs_queue)); + send(fd, buf, size, 0); + queue_iterate(rs_queue, &fd, rs_queue_dump); +} + +static int ftfw_local(int fd, int type, void *data) +{ + int ret = LOCAL_RET_OK; + + switch(type) { + case REQUEST_DUMP: + dlog(LOG_NOTICE, "request resync"); + tx_queue_add_ctlmsg(NET_F_RESYNC, 0, 0); + break; + case SEND_BULK: + dlog(LOG_NOTICE, "sending bulk update"); + cache_iterate(STATE(mode)->internal->data, + NULL, do_cache_to_tx); + break; + case STATS_RSQUEUE: + ftfw_local_queue(fd); + break; + } + + return ret; +} + +static int rs_queue_to_tx(struct queue_node *n, const void *data) +{ + const struct nethdr_ack *nack = data; + + switch(n->type) { + case Q_ELEM_CTL: { + struct nethdr_ack *net = queue_node_data(n); + + if (before(net->seq, nack->from)) + return 0; /* continue */ + else if (after(net->seq, nack->to)) + return 1; /* break */ + + dp("rs_queue_to_tx sq: %u fl:%u len:%u\n", + net->seq, net->flags, net->len); + + queue_del(n); + queue_add(STATE_SYNC(tx_queue), n); + break; + } + case Q_ELEM_OBJ: { + struct cache_ftfw *cn; + + cn = (struct cache_ftfw *) n; + if (before(cn->seq, nack->from)) + return 0; + else if (after(cn->seq, nack->to)) + return 1; + + dp("resending nack'ed (oldseq=%u)\n", cn->seq); + + queue_del(n); + queue_add(STATE_SYNC(tx_queue), n); + break; + } + } + return 0; +} + +static int rs_queue_empty(struct queue_node *n, const void *data) +{ + const struct nethdr_ack *h = data; + + switch(n->type) { + case Q_ELEM_CTL: { + struct nethdr_ack *net = queue_node_data(n); + + if (h == NULL) { + queue_del(n); + queue_object_free((struct queue_object *)n); + return 0; + } + if (before(net->seq, h->from)) + return 0; /* continue */ + else if (after(net->seq, h->to)) + return 1; /* break */ + + dp("remove from queue (seq=%u)\n", net->seq); + queue_del(n); + queue_object_free((struct queue_object *)n); + break; + } + case Q_ELEM_OBJ: { + struct cache_ftfw *cn; + struct cache_object *obj; + + cn = (struct cache_ftfw *) n; + if (h == NULL) { + queue_del(n); + obj = cache_data_get_object(STATE(mode)->internal->data, cn); + cache_object_put(obj); + return 0; + } + if (before(cn->seq, h->from)) + return 0; + else if (after(cn->seq, h->to)) + return 1; + + dp("queue: deleting from queue (seq=%u)\n", cn->seq); + queue_del(n); + obj = cache_data_get_object(STATE(mode)->internal->data, cn); + cache_object_put(obj); + break; + } + } + return 0; +} + +static int digest_msg(const struct nethdr *net) +{ + if (IS_DATA(net)) + return MSG_DATA; + + else if (IS_ACK(net)) { + const struct nethdr_ack *h = (const struct nethdr_ack *) net; + + if (before(h->to, h->from)) + return MSG_BAD; + + queue_iterate(rs_queue, h, rs_queue_empty); + return MSG_CTL; + + } else if (IS_NACK(net)) { + const struct nethdr_ack *nack = (const struct nethdr_ack *) net; + + if (before(nack->to, nack->from)) + return MSG_BAD; + + queue_iterate(rs_queue, nack, rs_queue_to_tx); + return MSG_CTL; + + } else if (IS_RESYNC(net)) { + dp("RESYNC ALL\n"); + cache_iterate(STATE(mode)->internal->data, NULL, do_cache_to_tx); + return MSG_CTL; + + } else if (IS_ALIVE(net)) + return MSG_CTL; + + return MSG_BAD; +} + +static int digest_hello(const struct nethdr *net) +{ + int ret = 0; + + if (IS_HELLO(net)) { + say_hello_back = 1; + ret = 1; + } + if (IS_HELLO_BACK(net)) { + /* this is a hello back for a requested hello */ + if (hello_state == HELLO_SAY) + hello_state = HELLO_DONE; + } + + return ret; +} + +static int ftfw_recv(const struct nethdr *net) +{ + int ret = MSG_DATA; + + if (digest_hello(net)) { + /* we have received a hello while we had data to acknowledge. + * reset the window, the other doesn't know anthing about it. */ + if (ack_from_set && before(net->seq, ack_from)) { + window = CONFIG(window_size) - 1; + ack_from = net->seq; + } + + /* XXX: flush the resend queues since the other does not + * know anything about that data, we are unreliable until + * the helloing finishes */ + queue_iterate(rs_queue, NULL, rs_queue_empty); + + goto bypass; + } + + switch (nethdr_track_seq(net->seq, &exp_seq)) { + case SEQ_AFTER: + ret = digest_msg(net); + if (ret == MSG_BAD) { + ret = MSG_BAD; + goto out; + } + + if (ack_from_set) { + tx_queue_add_ctlmsg(NET_F_ACK, ack_from, exp_seq-1); + ack_from_set = 0; + } + + tx_queue_add_ctlmsg(NET_F_NACK, exp_seq, net->seq-1); + + /* count this message as part of the new window */ + window = CONFIG(window_size) - 1; + ack_from = net->seq; + ack_from_set = 1; + break; + + case SEQ_BEFORE: + /* we don't accept delayed packets */ + ret = MSG_DROP; + break; + + case SEQ_UNSET: + case SEQ_IN_SYNC: +bypass: + ret = digest_msg(net); + if (ret == MSG_BAD) { + ret = MSG_BAD; + goto out; + } + + if (!ack_from_set) { + ack_from_set = 1; + ack_from = net->seq; + } + + if (--window <= 0) { + /* received a window, send an acknowledgement */ + tx_queue_add_ctlmsg(NET_F_ACK, ack_from, net->seq); + window = CONFIG(window_size); + ack_from_set = 0; + } + } + +out: + if ((ret == MSG_DATA || ret == MSG_CTL)) + nethdr_track_update_seq(net->seq); + + return ret; +} + +static void rs_queue_purge_full(void) +{ + struct queue_node *n; + + n = queue_del_head(rs_queue); + switch(n->type) { + case Q_ELEM_CTL: { + struct queue_object *qobj = (struct queue_object *)n; + queue_object_free(qobj); + break; + } + case Q_ELEM_OBJ: { + struct cache_ftfw *cn; + struct cache_object *obj; + + cn = (struct cache_ftfw *)n; + obj = cache_data_get_object(STATE(mode)->internal->data, cn); + cache_object_put(obj); + break; + } + } +} + +static int tx_queue_xmit(struct queue_node *n, const void *data) +{ + queue_del(n); + + switch(n->type) { + case Q_ELEM_CTL: { + struct nethdr *net = queue_node_data(n); + + nethdr_set_hello(net); + + if (IS_ACK(net) || IS_NACK(net) || IS_RESYNC(net)) { + nethdr_set_ack(net); + } else { + nethdr_set_ctl(net); + } + HDR_HOST2NETWORK(net); + + dp("tx_queue sq: %u fl:%u len:%u\n", + ntohl(net->seq), net->flags, ntohs(net->len)); + + multichannel_send(STATE_SYNC(channel), net); + HDR_NETWORK2HOST(net); + + if (IS_ACK(net) || IS_NACK(net) || IS_RESYNC(net)) { + if (queue_add(rs_queue, n) < 0) { + if (errno == ENOSPC) { + rs_queue_purge_full(); + queue_add(rs_queue, n); + } + } + } else + queue_object_free((struct queue_object *)n); + break; + } + case Q_ELEM_OBJ: { + struct cache_ftfw *cn; + struct cache_object *obj; + int type; + struct nethdr *net; + + cn = (struct cache_ftfw *)n; + obj = cache_data_get_object(STATE(mode)->internal->data, cn); + type = object_status_to_network_type(obj->status); + net = BUILD_NETMSG(obj->ct, type); + nethdr_set_hello(net); + + dp("tx_list sq: %u fl:%u len:%u\n", + ntohl(net->seq), net->flags, ntohs(net->len)); + + multichannel_send(STATE_SYNC(channel), net); + cn->seq = ntohl(net->seq); + if (queue_add(rs_queue, &cn->qnode) < 0) { + if (errno == ENOSPC) { + rs_queue_purge_full(); + queue_add(rs_queue, &cn->qnode); + } + } + /* we release the object once we get the acknowlegment */ + break; + } + } + + return 0; +} + +static void ftfw_xmit(void) +{ + queue_iterate(STATE_SYNC(tx_queue), NULL, tx_queue_xmit); + add_alarm(&alive_alarm, ALIVE_INT, 0); + dp("tx_queue_len:%u rs_queue_len:%u\n", + queue_len(tx_queue), queue_len(rs_queue)); +} + +static void ftfw_enqueue(struct cache_object *obj, int type) +{ + struct cache_ftfw *cn = + cache_get_extra(STATE(mode)->internal->data, obj); + if (queue_in(rs_queue, &cn->qnode)) { + queue_del(&cn->qnode); + queue_add(STATE_SYNC(tx_queue), &cn->qnode); + } else { + if (queue_add(STATE_SYNC(tx_queue), &cn->qnode)) + cache_object_get(obj); + } +} + +struct sync_mode sync_ftfw = { + .internal_cache_flags = NO_FEATURES, + .external_cache_flags = NO_FEATURES, + .internal_cache_extra = &cache_ftfw_extra, + .init = ftfw_init, + .kill = ftfw_kill, + .local = ftfw_local, + .recv = ftfw_recv, + .enqueue = ftfw_enqueue, + .xmit = ftfw_xmit, +}; diff --git a/src/sync-mode.c b/src/sync-mode.c new file mode 100644 index 0000000..ecc2f0d --- /dev/null +++ b/src/sync-mode.c @@ -0,0 +1,569 @@ +/* + * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "sync.h" +#include "netlink.h" +#include "traffic_stats.h" +#include "log.h" +#include "cache.h" +#include "conntrackd.h" +#include "network.h" +#include "fds.h" +#include "event.h" +#include "queue.h" +#include "process.h" +#include "origin.h" +#include "internal.h" +#include "external.h" + +#include <errno.h> +#include <unistd.h> +#include <time.h> +#include <string.h> +#include <stdlib.h> +#include <limits.h> +#include <net/if.h> +#include <fcntl.h> + +static void +do_channel_handler_step(int i, struct nethdr *net, size_t remain) +{ + char __ct[nfct_maxsize()]; + struct nf_conntrack *ct = (struct nf_conntrack *)(void*) __ct; + + if (net->version != CONNTRACKD_PROTOCOL_VERSION) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_version++; + return; + } + + switch (STATE_SYNC(sync)->recv(net)) { + case MSG_DATA: + multichannel_change_current_channel(STATE_SYNC(channel), i); + break; + case MSG_CTL: + multichannel_change_current_channel(STATE_SYNC(channel), i); + return; + case MSG_BAD: + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_header++; + return; + case MSG_DROP: + return; + default: + break; + } + + if (net->type > NET_T_STATE_MAX) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_type++; + return; + } + memset(ct, 0, sizeof(__ct)); + + if (parse_payload(ct, net, remain) == -1) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_payload++; + return; + } + + switch(net->type) { + case NET_T_STATE_NEW: + STATE_SYNC(external)->new(ct); + break; + case NET_T_STATE_UPD: + STATE_SYNC(external)->update(ct); + break; + case NET_T_STATE_DEL: + STATE_SYNC(external)->destroy(ct); + break; + default: + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_type++; + break; + } +} + +static char __net[65536]; /* XXX: maximum MTU for IPv4 */ +static char *cur = __net; + +static int channel_stream(struct channel *m, const char *ptr, ssize_t remain) +{ + if (m->channel_flags & CHANNEL_F_STREAM) { + /* truncated data. */ + memcpy(__net, ptr, remain); + cur = __net + remain; + return 1; + } + return 0; +} + +/* handler for messages received */ +static int channel_handler_routine(struct channel *m, int i) +{ + ssize_t numbytes; + ssize_t remain, pending = cur - __net; + char *ptr = __net; + + numbytes = channel_recv(m, cur, sizeof(__net) - pending); + if (numbytes <= 0) + return -1; + + remain = numbytes; + if (pending) { + remain += pending; + cur = __net; + } + + while (remain > 0) { + struct nethdr *net = (struct nethdr *) ptr; + int len; + + if (remain < NETHDR_SIZ) { + if (!channel_stream(m, ptr, remain)) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_truncated++; + } + break; + } + + len = ntohs(net->len); + if (len <= 0) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_size++; + break; + } + + if (len > remain) { + if (!channel_stream(m, ptr, remain)) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_size++; + } + break; + } + + if (IS_ACK(net) || IS_NACK(net) || IS_RESYNC(net)) { + if (remain < NETHDR_ACK_SIZ) { + if (!channel_stream(m, ptr, remain)) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_truncated++; + } + break; + } + + if (len < NETHDR_ACK_SIZ) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_size++; + break; + } + } else { + if (len < NETHDR_SIZ) { + STATE_SYNC(error).msg_rcv_malformed++; + STATE_SYNC(error).msg_rcv_bad_size++; + break; + } + } + + HDR_NETWORK2HOST(net); + + do_channel_handler_step(i, net, remain); + ptr += net->len; + remain -= net->len; + } + return 0; +} + +/* handler for messages received */ +static void channel_handler(struct channel *m, int i) +{ + int k; + + for (k=0; k<CONFIG(event_iterations_limit); k++) { + if (channel_handler_routine(m, i) == -1) { + break; + } + } +} + +/* select a new interface candidate in a round robin basis */ +static void interface_candidate(void) +{ + int i, idx; + unsigned int flags; + char buf[IFNAMSIZ]; + + for (i=0; i<STATE_SYNC(channel)->channel_num; i++) { + idx = multichannel_get_ifindex(STATE_SYNC(channel), i); + if (idx == multichannel_get_current_ifindex(STATE_SYNC(channel))) + continue; + nlif_get_ifflags(STATE_SYNC(interface), idx, &flags); + if (flags & (IFF_RUNNING | IFF_UP)) { + multichannel_set_current_channel(STATE_SYNC(channel), i); + dlog(LOG_NOTICE, "device `%s' becomes " + "dedicated link", + if_indextoname(idx, buf)); + return; + } + } + dlog(LOG_ERR, "no dedicated links available!"); +} + +static void interface_handler(void) +{ + int idx = multichannel_get_current_ifindex(STATE_SYNC(channel)); + unsigned int flags; + + nlif_catch(STATE_SYNC(interface)); + nlif_get_ifflags(STATE_SYNC(interface), idx, &flags); + if (!(flags & IFF_RUNNING) || !(flags & IFF_UP)) + interface_candidate(); +} + +static void do_reset_cache_alarm(struct alarm_block *a, void *data) +{ + STATE(stats).nl_kernel_table_flush++; + dlog(LOG_NOTICE, "flushing kernel conntrack table (scheduled)"); + + /* fork a child process that performs the flush operation, + * meanwhile the parent process handles events. */ + if (fork_process_new(CTD_PROC_FLUSH, CTD_PROC_F_EXCL, + NULL, NULL) == 0) { + nl_flush_conntrack_table(STATE(flush)); + exit(EXIT_SUCCESS); + } + /* this is not required if events don't get lost */ + STATE(mode)->internal->flush(); +} + +static int init_sync(void) +{ + int i; + + state.sync = malloc(sizeof(struct ct_sync_state)); + if (!state.sync) { + dlog(LOG_ERR, "can't allocate memory for sync"); + return -1; + } + memset(state.sync, 0, sizeof(struct ct_sync_state)); + + if (CONFIG(flags) & CTD_SYNC_FTFW) + STATE_SYNC(sync) = &sync_ftfw; + else if (CONFIG(flags) & CTD_SYNC_ALARM) + STATE_SYNC(sync) = &sync_alarm; + else if (CONFIG(flags) & CTD_SYNC_NOTRACK) + STATE_SYNC(sync) = &sync_notrack; + else { + fprintf(stderr, "WARNING: No synchronization mode specified. " + "Defaulting to FT-FW mode.\n"); + CONFIG(flags) |= CTD_SYNC_FTFW; + STATE_SYNC(sync) = &sync_ftfw; + } + + if (STATE_SYNC(sync)->init) + STATE_SYNC(sync)->init(); + + if (CONFIG(sync).internal_cache_disable == 0) { + STATE(mode)->internal = &internal_cache; + } else { + STATE(mode)->internal = &internal_bypass; + dlog(LOG_NOTICE, "disabling internal cache"); + + } + if (STATE(mode)->internal->init() == -1) + return -1; + + if (CONFIG(sync).external_cache_disable == 0) { + STATE_SYNC(external) = &external_cache; + } else { + STATE_SYNC(external) = &external_inject; + dlog(LOG_NOTICE, "disabling external cache"); + } + if (STATE_SYNC(external)->init() == -1) + return -1; + + if (channel_init() == -1) + return -1; + + /* channel to send events on the wire */ + STATE_SYNC(channel) = + multichannel_open(CONFIG(channel), CONFIG(channel_num)); + if (STATE_SYNC(channel) == NULL) { + dlog(LOG_ERR, "can't open channel socket"); + return -1; + } + for (i=0; i<STATE_SYNC(channel)->channel_num; i++) { + int fd = channel_get_fd(STATE_SYNC(channel)->channel[i]); + fcntl(fd, F_SETFL, O_NONBLOCK); + if (register_fd(fd, STATE(fds)) == -1) + return -1; + } + + STATE_SYNC(interface) = nl_init_interface_handler(); + if (!STATE_SYNC(interface)) { + dlog(LOG_ERR, "can't open interface watcher"); + return -1; + } + if (register_fd(nlif_fd(STATE_SYNC(interface)), STATE(fds)) == -1) + return -1; + + STATE_SYNC(tx_queue) = queue_create("txqueue", INT_MAX, QUEUE_F_EVFD); + if (STATE_SYNC(tx_queue) == NULL) { + dlog(LOG_ERR, "cannot create tx queue"); + return -1; + } + if (register_fd(queue_get_eventfd(STATE_SYNC(tx_queue)), + STATE(fds)) == -1) + return -1; + + STATE_SYNC(commit).h = nfct_open(CONNTRACK, 0); + if (STATE_SYNC(commit).h == NULL) { + dlog(LOG_ERR, "can't create handler to commit"); + return -1; + } + origin_register(STATE_SYNC(commit).h, CTD_ORIGIN_COMMIT); + + STATE_SYNC(commit).evfd = create_evfd(); + if (STATE_SYNC(commit).evfd == NULL) { + dlog(LOG_ERR, "can't create eventfd to commit"); + return -1; + } + if (register_fd(get_read_evfd(STATE_SYNC(commit).evfd), + STATE(fds)) == -1) { + return -1; + } + + init_alarm(&STATE_SYNC(reset_cache_alarm), NULL, do_reset_cache_alarm); + + /* initialization of message sequence generation */ + STATE_SYNC(last_seq_sent) = time(NULL); + + return 0; +} + +static void channel_check(struct channel *c, int i, fd_set *readfds) +{ + /* In case that this channel is connection-oriented. */ + if (channel_accept_isset(c, readfds)) + channel_accept(c); + + /* For data handling. */ + if (channel_isset(c, readfds)) + channel_handler(c, i); +} + +static void run_sync(fd_set *readfds) +{ + int i; + + for (i=0; i<STATE_SYNC(channel)->channel_num; i++) + channel_check(STATE_SYNC(channel)->channel[i], i, readfds); + + if (FD_ISSET(queue_get_eventfd(STATE_SYNC(tx_queue)), readfds)) + STATE_SYNC(sync)->xmit(); + + if (FD_ISSET(nlif_fd(STATE_SYNC(interface)), readfds)) + interface_handler(); + + if (FD_ISSET(get_read_evfd(STATE_SYNC(commit).evfd), readfds)) { + read_evfd(STATE_SYNC(commit).evfd); + STATE_SYNC(external)->commit(STATE_SYNC(commit).h, 0); + } + + /* flush pending messages */ + multichannel_send_flush(STATE_SYNC(channel)); +} + +static void kill_sync(void) +{ + STATE(mode)->internal->close(); + STATE_SYNC(external)->close(); + + multichannel_close(STATE_SYNC(channel)); + + nlif_close(STATE_SYNC(interface)); + + queue_destroy(STATE_SYNC(tx_queue)); + + channel_end(); + + origin_unregister(STATE_SYNC(commit).h); + nfct_close(STATE_SYNC(commit).h); + destroy_evfd(STATE_SYNC(commit).evfd); + + if (STATE_SYNC(sync)->kill) + STATE_SYNC(sync)->kill(); +} + +static void dump_stats_sync(int fd) +{ + char buf[512]; + int size; + + size = sprintf(buf, "message sequence tracking:\n" + "%20llu Msgs mfrm " + "%20llu Msgs lost\n\n", + (unsigned long long)STATE_SYNC(error).msg_rcv_malformed, + (unsigned long long)STATE_SYNC(error).msg_rcv_lost); + + send(fd, buf, size, 0); +} + +static void dump_stats_sync_extended(int fd) +{ + char buf[512]; + int size; + + size = snprintf(buf, sizeof(buf), + "network statistics:\n" + "\trecv:\n" + "\t\tMalformed messages:\t%20llu\n" + "\t\tWrong protocol version:\t%20u\n" + "\t\tMalformed header:\t%20u\n" + "\t\tMalformed payload:\t%20u\n" + "\t\tBad message type:\t%20u\n" + "\t\tTruncated message:\t%20u\n" + "\t\tBad message size:\t%20u\n" + "\tsend:\n" + "\t\tMalformed messages:\t%20u\n\n" + "sequence tracking statistics:\n" + "\trecv:\n" + "\t\tPackets lost:\t\t%20llu\n" + "\t\tPackets before:\t\t%20llu\n\n", + (unsigned long long)STATE_SYNC(error).msg_rcv_malformed, + STATE_SYNC(error).msg_rcv_bad_version, + STATE_SYNC(error).msg_rcv_bad_header, + STATE_SYNC(error).msg_rcv_bad_payload, + STATE_SYNC(error).msg_rcv_bad_type, + STATE_SYNC(error).msg_rcv_truncated, + STATE_SYNC(error).msg_rcv_bad_size, + STATE_SYNC(error).msg_snd_malformed, + (unsigned long long)STATE_SYNC(error).msg_rcv_lost, + (unsigned long long)STATE_SYNC(error).msg_rcv_before); + + send(fd, buf, size, 0); +} + +/* handler for requests coming via UNIX socket */ +static int local_handler_sync(int fd, int type, void *data) +{ + int ret = LOCAL_RET_OK; + + switch(type) { + case DUMP_INTERNAL: + ret = fork_process_new(CTD_PROC_ANY, 0, NULL, NULL); + if (ret == 0) { + STATE(mode)->internal->dump(fd, NFCT_O_PLAIN); + exit(EXIT_SUCCESS); + } + break; + case DUMP_EXTERNAL: + ret = fork_process_new(CTD_PROC_ANY, 0, NULL, NULL); + if (ret == 0) { + STATE_SYNC(external)->dump(fd, NFCT_O_PLAIN); + exit(EXIT_SUCCESS); + } + break; + case DUMP_INT_XML: + ret = fork_process_new(CTD_PROC_ANY, 0, NULL, NULL); + if (ret == 0) { + STATE(mode)->internal->dump(fd, NFCT_O_XML); + exit(EXIT_SUCCESS); + } + break; + case DUMP_EXT_XML: + ret = fork_process_new(CTD_PROC_ANY, 0, NULL, NULL); + if (ret == 0) { + STATE_SYNC(external)->dump(fd, NFCT_O_XML); + exit(EXIT_SUCCESS); + } + break; + case COMMIT: + /* delete the reset alarm if any before committing */ + del_alarm(&STATE_SYNC(reset_cache_alarm)); + + dlog(LOG_NOTICE, "committing external cache"); + STATE_SYNC(external)->commit(STATE_SYNC(commit).h, fd); + /* Keep the client socket open, we want synchronous commits. */ + ret = LOCAL_RET_STOLEN; + break; + case RESET_TIMERS: + if (!alarm_pending(&STATE_SYNC(reset_cache_alarm))) { + dlog(LOG_NOTICE, "flushing conntrack table in %d secs", + CONFIG(purge_timeout)); + add_alarm(&STATE_SYNC(reset_cache_alarm), + CONFIG(purge_timeout), 0); + } + break; + case FLUSH_CACHE: + /* inmediate flush, remove pending flush scheduled if any */ + del_alarm(&STATE_SYNC(reset_cache_alarm)); + dlog(LOG_NOTICE, "flushing caches"); + STATE(mode)->internal->flush(); + STATE_SYNC(external)->flush(); + break; + case FLUSH_INT_CACHE: + /* inmediate flush, remove pending flush scheduled if any */ + del_alarm(&STATE_SYNC(reset_cache_alarm)); + dlog(LOG_NOTICE, "flushing internal cache"); + STATE(mode)->internal->flush(); + break; + case FLUSH_EXT_CACHE: + dlog(LOG_NOTICE, "flushing external cache"); + STATE_SYNC(external)->flush(); + break; + case KILL: + killer(0); + break; + case STATS: + STATE(mode)->internal->stats(fd); + STATE_SYNC(external)->stats(fd); + dump_traffic_stats(fd); + multichannel_stats(STATE_SYNC(channel), fd); + dump_stats_sync(fd); + break; + case STATS_NETWORK: + dump_stats_sync_extended(fd); + multichannel_stats(STATE_SYNC(channel), fd); + break; + case STATS_CACHE: + STATE(mode)->internal->stats_ext(fd); + STATE_SYNC(external)->stats_ext(fd); + break; + case STATS_LINK: + multichannel_stats_extended(STATE_SYNC(channel), + STATE_SYNC(interface), fd); + break; + case STATS_QUEUE: + queue_stats_show(fd); + break; + default: + if (STATE_SYNC(sync)->local) + ret = STATE_SYNC(sync)->local(fd, type, data); + break; + } + + return ret; +} + +struct ct_mode sync_mode = { + .init = init_sync, + .run = run_sync, + .local = local_handler_sync, + .kill = kill_sync, + /* the internal handler is set in run-time. */ +}; diff --git a/src/sync-notrack.c b/src/sync-notrack.c new file mode 100644 index 0000000..c4ad941 --- /dev/null +++ b/src/sync-notrack.c @@ -0,0 +1,264 @@ +/* + * (C) 2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "conntrackd.h" +#include "sync.h" +#include "queue.h" +#include "network.h" +#include "log.h" +#include "cache.h" +#include "fds.h" + +#include <string.h> + +static struct alarm_block alive_alarm; + +/* XXX: alive message expiration configurable */ +#define ALIVE_INT 1 + +struct cache_notrack { + struct queue_node qnode; +}; + +static void cache_notrack_add(struct cache_object *obj, void *data) +{ + struct cache_notrack *cn = data; + queue_node_init(&cn->qnode, Q_ELEM_OBJ); +} + +static void cache_notrack_del(struct cache_object *obj, void *data) +{ + struct cache_notrack *cn = data; + queue_del(&cn->qnode); +} + +static struct cache_extra cache_notrack_extra = { + .size = sizeof(struct cache_notrack), + .add = cache_notrack_add, + .destroy = cache_notrack_del +}; + +static void tx_queue_add_ctlmsg(uint32_t flags, uint32_t from, uint32_t to) +{ + struct queue_object *qobj; + struct nethdr_ack *ack; + + qobj = queue_object_new(Q_ELEM_CTL, sizeof(struct nethdr_ack)); + if (qobj == NULL) + return; + + ack = (struct nethdr_ack *)qobj->data; + ack->type = NET_T_CTL; + ack->flags = flags; + ack->from = from; + ack->to = to; + + queue_add(STATE_SYNC(tx_queue), &qobj->qnode); +} + +static int do_cache_to_tx(void *data1, void *data2) +{ + struct cache_object *obj = data2; + struct cache_notrack *cn = + cache_get_extra(STATE(mode)->internal->data, obj); + if (queue_add(STATE_SYNC(tx_queue), &cn->qnode)) + cache_object_get(obj); + return 0; +} + +static int kernel_resync_cb(enum nf_conntrack_msg_type type, + struct nf_conntrack *ct, void *data) +{ + struct nethdr *net; + + net = BUILD_NETMSG(ct, NET_T_STATE_NEW); + multichannel_send(STATE_SYNC(channel), net); + + return NFCT_CB_CONTINUE; +} + +/* Only used if the internal cache is disabled. */ +static void kernel_resync(void) +{ + struct nfct_handle *h; + u_int32_t family = AF_UNSPEC; + int ret; + + h = nfct_open(CONNTRACK, 0); + if (h == NULL) { + dlog(LOG_ERR, "can't allocate memory for the internal cache"); + return; + } + nfct_callback_register(h, NFCT_T_ALL, kernel_resync_cb, NULL); + ret = nfct_query(h, NFCT_Q_DUMP, &family); + if (ret == -1) { + dlog(LOG_ERR, "can't dump kernel table"); + } + nfct_close(h); +} + +static int notrack_local(int fd, int type, void *data) +{ + int ret = LOCAL_RET_OK; + + switch(type) { + case REQUEST_DUMP: + dlog(LOG_NOTICE, "request resync"); + tx_queue_add_ctlmsg(NET_F_RESYNC, 0, 0); + break; + case SEND_BULK: + dlog(LOG_NOTICE, "sending bulk update"); + if (CONFIG(sync).internal_cache_disable) { + kernel_resync(); + } else { + cache_iterate(STATE(mode)->internal->data, + NULL, do_cache_to_tx); + } + break; + default: + ret = 0; + break; + } + + return ret; +} + +static int digest_msg(const struct nethdr *net) +{ + if (IS_DATA(net)) + return MSG_DATA; + + if (IS_RESYNC(net)) { + if (CONFIG(sync).internal_cache_disable) { + kernel_resync(); + } else { + cache_iterate(STATE(mode)->internal->data, + NULL, do_cache_to_tx); + } + return MSG_CTL; + } + + if (IS_ALIVE(net)) + return MSG_CTL; + + return MSG_BAD; +} + +static int notrack_recv(const struct nethdr *net) +{ + int ret; + unsigned int exp_seq; + + nethdr_track_seq(net->seq, &exp_seq); + + ret = digest_msg(net); + + if (ret != MSG_BAD) + nethdr_track_update_seq(net->seq); + + return ret; +} + +static int tx_queue_xmit(struct queue_node *n, const void *data2) +{ + switch (n->type) { + case Q_ELEM_CTL: { + struct nethdr *net = queue_node_data(n); + if (IS_RESYNC(net)) + nethdr_set_ack(net); + else + nethdr_set_ctl(net); + HDR_HOST2NETWORK(net); + multichannel_send(STATE_SYNC(channel), net); + queue_del(n); + queue_object_free((struct queue_object *)n); + break; + } + case Q_ELEM_OBJ: { + struct cache_ftfw *cn; + struct cache_object *obj; + int type; + struct nethdr *net; + + cn = (struct cache_ftfw *)n; + obj = cache_data_get_object(STATE(mode)->internal->data, cn); + type = object_status_to_network_type(obj->status);; + net = BUILD_NETMSG(obj->ct, type); + + multichannel_send(STATE_SYNC(channel), net); + queue_del(n); + cache_object_put(obj); + break; + } + } + return 0; +} + +static void notrack_xmit(void) +{ + queue_iterate(STATE_SYNC(tx_queue), NULL, tx_queue_xmit); + add_alarm(&alive_alarm, ALIVE_INT, 0); +} + +static void notrack_enqueue(struct cache_object *obj, int query) +{ + struct cache_notrack *cn = + cache_get_extra(STATE(mode)->internal->data, obj); + if (queue_add(STATE_SYNC(tx_queue), &cn->qnode)) + cache_object_get(obj); +} + +static void tx_queue_add_ctlmsg2(uint32_t flags) +{ + struct queue_object *qobj; + struct nethdr *ctl; + + qobj = queue_object_new(Q_ELEM_CTL, sizeof(struct nethdr_ack)); + if (qobj == NULL) + return; + + ctl = (struct nethdr *)qobj->data; + ctl->type = NET_T_CTL; + ctl->flags = flags; + + queue_add(STATE_SYNC(tx_queue), &qobj->qnode); +} + +static void do_alive_alarm(struct alarm_block *a, void *data) +{ + tx_queue_add_ctlmsg2(NET_F_ALIVE); + add_alarm(&alive_alarm, ALIVE_INT, 0); +} + +static int notrack_init(void) +{ + init_alarm(&alive_alarm, NULL, do_alive_alarm); + add_alarm(&alive_alarm, ALIVE_INT, 0); + return 0; +} + +struct sync_mode sync_notrack = { + .internal_cache_flags = NO_FEATURES, + .external_cache_flags = NO_FEATURES, + .internal_cache_extra = &cache_notrack_extra, + .init = notrack_init, + .local = notrack_local, + .recv = notrack_recv, + .enqueue = notrack_enqueue, + .xmit = notrack_xmit, +}; diff --git a/src/tcp.c b/src/tcp.c new file mode 100644 index 0000000..c551c54 --- /dev/null +++ b/src/tcp.c @@ -0,0 +1,457 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * TCP support has been sponsored by 6WIND <www.6wind.com>. + */ + +#include "tcp.h" + +#include <stdio.h> +#include <stdlib.h> +#include <arpa/inet.h> +#include <unistd.h> +#include <string.h> +#include <sys/ioctl.h> +#include <net/if.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> + +#include "conntrackd.h" +#include "fds.h" + +struct tcp_sock *tcp_server_create(struct tcp_conf *c) +{ + int yes = 1, ret; + struct tcp_sock *m; + socklen_t socklen = sizeof(int); + + m = calloc(sizeof(struct tcp_sock), 1); + if (m == NULL) + return NULL; + + m->conf = c; + + switch(c->ipproto) { + case AF_INET: + m->addr.ipv4.sin_family = AF_INET; + m->addr.ipv4.sin_port = htons(c->port); + m->addr.ipv4.sin_addr = c->server.ipv4.inet_addr; + m->sockaddr_len = sizeof(struct sockaddr_in); + break; + + case AF_INET6: + m->addr.ipv6.sin6_family = AF_INET6; + m->addr.ipv6.sin6_port = htons(c->port); + m->addr.ipv6.sin6_addr = c->server.ipv6.inet_addr6; + m->addr.ipv6.sin6_scope_id = c->server.ipv6.scope_id; + m->sockaddr_len = sizeof(struct sockaddr_in6); + break; + } + + m->fd = socket(c->ipproto, SOCK_STREAM, 0); + if (m->fd == -1) { + free(m); + return NULL; + } + + if (setsockopt(m->fd, SOL_SOCKET, SO_REUSEADDR, &yes, + sizeof(int)) == -1) { + close(m->fd); + free(m); + return NULL; + } + + if (setsockopt(m->fd, SOL_SOCKET, SO_KEEPALIVE, &yes, + sizeof(int)) == -1) { + close(m->fd); + free(m); + return NULL; + } + +#ifndef SO_RCVBUFFORCE +#define SO_RCVBUFFORCE 33 +#endif + + if (c->rcvbuf && + setsockopt(m->fd, SOL_SOCKET, SO_RCVBUFFORCE, &c->rcvbuf, + sizeof(int)) == -1) { + /* not supported in linux kernel < 2.6.14 */ + if (errno != ENOPROTOOPT) { + close(m->fd); + free(m); + return NULL; + } + } + + getsockopt(m->fd, SOL_SOCKET, SO_RCVBUF, &c->rcvbuf, &socklen); + + if (bind(m->fd, (struct sockaddr *) &m->addr, m->sockaddr_len) == -1) { + close(m->fd); + free(m); + return NULL; + } + + if (listen(m->fd, 1) == -1) { + close(m->fd); + free(m); + return NULL; + } + + if (fcntl(m->fd, F_SETFL, O_NONBLOCK) == -1) { + close(m->fd); + free(m); + return NULL; + } + + /* now we accept new connections ... */ + ret = accept(m->fd, NULL, NULL); + if (ret == -1) { + if (errno != EAGAIN) { + /* unexpected error, give up. */ + close(m->fd); + free(m); + m = NULL; + } else { + /* still in progress ... we'll do it in tcp_recv() */ + m->state = TCP_SERVER_ACCEPTING; + } + } else { + /* very unlikely at this stage. */ + if (fcntl(ret, F_SETFL, O_NONBLOCK) == -1) { + /* unexpected error, give up. */ + close(m->fd); + free(m); + return NULL; + } + m->client_fd = ret; + m->state = TCP_SERVER_CONNECTED; + register_fd(m->client_fd, STATE(fds)); + } + + return m; +} + +void tcp_server_destroy(struct tcp_sock *m) +{ + close(m->fd); + free(m); +} + +static int +tcp_client_init(struct tcp_sock *m, struct tcp_conf *c) +{ + int ret = 0; + socklen_t socklen = sizeof(int); + + m->fd = socket(c->ipproto, SOCK_STREAM, 0); + if (m->fd == -1) + return -1; + + if (setsockopt(m->fd, SOL_SOCKET, SO_NO_CHECK, &c->checksum, + sizeof(int)) == -1) { + close(m->fd); + return -1; + } + +#ifndef SO_SNDBUFFORCE +#define SO_SNDBUFFORCE 32 +#endif + + if (c->sndbuf && + setsockopt(m->fd, SOL_SOCKET, SO_SNDBUFFORCE, &c->sndbuf, + sizeof(int)) == -1) { + /* not supported in linux kernel < 2.6.14 */ + if (errno != ENOPROTOOPT) { + close(m->fd); + return -1; + } + } + + getsockopt(m->fd, SOL_SOCKET, SO_SNDBUF, &c->sndbuf, &socklen); + + switch(c->ipproto) { + case AF_INET: + m->addr.ipv4.sin_family = AF_INET; + m->addr.ipv4.sin_port = htons(c->port); + m->addr.ipv4.sin_addr = c->client.inet_addr; + m->sockaddr_len = sizeof(struct sockaddr_in); + break; + case AF_INET6: + m->addr.ipv6.sin6_family = AF_INET6; + m->addr.ipv6.sin6_port = htons(c->port); + memcpy(&m->addr.ipv6.sin6_addr, &c->client.inet_addr6, + sizeof(struct in6_addr)); + m->sockaddr_len = sizeof(struct sockaddr_in6); + break; + default: + ret = -1; + break; + } + + if (ret == -1) { + close(m->fd); + return -1; + } + + if (fcntl(m->fd, F_SETFL, O_NONBLOCK) == -1) { + close(m->fd); + return -1; + } + + ret = connect(m->fd, (struct sockaddr *)&m->addr, m->sockaddr_len); + if (ret == -1) { + if (errno == EINPROGRESS) { + /* connection in progress ... */ + m->state = TCP_CLIENT_DISCONNECTED; + } else if (errno == ECONNREFUSED) { + /* connection refused. */ + m->state = TCP_CLIENT_DISCONNECTED; + } else { + /* unexpected error, give up. */ + close(m->fd); + return -1; + } + } else { + /* very unlikely at this stage. */ + m->state = TCP_CLIENT_CONNECTED; + } + return 0; +} + +/* We use this to rate-limit the amount of connect() calls per second. */ +static struct alarm_block tcp_connect_alarm; +static void tcp_connect_alarm_cb(struct alarm_block *a, void *data) {} + +struct tcp_sock *tcp_client_create(struct tcp_conf *c) +{ + struct tcp_sock *m; + + m = calloc(sizeof(struct tcp_sock), 1); + if (m == NULL) + return NULL; + + m->conf = c; + + if (tcp_client_init(m, c) == -1) { + free(m); + return NULL; + } + + init_alarm(&tcp_connect_alarm, NULL, tcp_connect_alarm_cb); + + return m; +} + +void tcp_client_destroy(struct tcp_sock *m) +{ + close(m->fd); + free(m); +} + +int tcp_accept(struct tcp_sock *m) +{ + int ret; + + /* we got an attempt to connect but we already have a client? */ + if (m->state != TCP_SERVER_ACCEPTING) { + /* clear the session and restart ... */ + unregister_fd(m->client_fd, STATE(fds)); + close(m->client_fd); + m->client_fd = -1; + m->state = TCP_SERVER_ACCEPTING; + } + + /* the other peer wants to connect ... */ + ret = accept(m->fd, NULL, NULL); + if (ret == -1) { + if (errno != EAGAIN) { + /* unexpected error. Give us another try. */ + m->state = TCP_SERVER_ACCEPTING; + } else { + /* waiting for new connections. */ + m->state = TCP_SERVER_ACCEPTING; + } + } else { + /* the peer finally got connected. */ + if (fcntl(ret, F_SETFL, O_NONBLOCK) == -1) { + /* close the connection and give us another chance. */ + close(ret); + return -1; + } + + m->client_fd = ret; + m->state = TCP_SERVER_CONNECTED; + register_fd(m->client_fd, STATE(fds)); + } + return m->client_fd; +} + +#define TCP_CONNECT_TIMEOUT 1 + +ssize_t tcp_send(struct tcp_sock *m, const void *data, int size) +{ + ssize_t ret = 0; + + switch(m->state) { + case TCP_CLIENT_DISCONNECTED: + /* We rate-limit the amount of connect() calls. */ + if (alarm_pending(&tcp_connect_alarm)) { + ret = -1; + break; + } + add_alarm(&tcp_connect_alarm, TCP_CONNECT_TIMEOUT, 0); + ret = connect(m->fd, (struct sockaddr *)&m->addr, + m->sockaddr_len); + if (ret == -1) { + if (errno == EINPROGRESS || errno == EALREADY) { + /* connection in progress or already trying. */ + m->state = TCP_CLIENT_DISCONNECTED; + } else if (errno == ECONNREFUSED) { + /* connection refused. */ + m->state = TCP_CLIENT_DISCONNECTED; + m->stats.error++; + } else { + /* unexpected error, give up. */ + m->state = TCP_CLIENT_DISCONNECTED; + m->stats.error++; + } + break; + } else { + /* we got connected :) */ + m->state = TCP_CLIENT_CONNECTED; + } + case TCP_CLIENT_CONNECTED: + ret = sendto(m->fd, data, size, 0, + (struct sockaddr *) &m->addr, m->sockaddr_len); + if (ret == -1) { + if (errno == EPIPE || errno == ECONNRESET) { + close(m->fd); + tcp_client_init(m, m->conf); + m->state = TCP_CLIENT_DISCONNECTED; + m->stats.error++; + } else { + m->stats.error++; + return -1; + } + } + } + + if (ret >= 0) { + m->stats.bytes += ret; + m->stats.messages++; + } + return ret; +} + +ssize_t tcp_recv(struct tcp_sock *m, void *data, int size) +{ + ssize_t ret = 0; + socklen_t sin_size = sizeof(struct sockaddr_in); + + /* we are not connected, skip. */ + if (m->state != TCP_SERVER_CONNECTED) + return 0; + + ret = recvfrom(m->client_fd, data, size, 0, + (struct sockaddr *)&m->addr, &sin_size); + if (ret == -1) { + /* the other peer has disconnected... */ + if (errno == ENOTCONN) { + unregister_fd(m->client_fd, STATE(fds)); + close(m->client_fd); + m->client_fd = -1; + m->state = TCP_SERVER_ACCEPTING; + tcp_accept(m); + } else if (errno != EAGAIN) { + m->stats.error++; + } + } else if (ret == 0) { + /* the other peer has closed the connection... */ + unregister_fd(m->client_fd, STATE(fds)); + close(m->client_fd); + m->client_fd = -1; + m->state = TCP_SERVER_ACCEPTING; + tcp_accept(m); + } + + if (ret >= 0) { + m->stats.bytes += ret; + m->stats.messages++; + } + return ret; +} + +int tcp_get_fd(struct tcp_sock *m) +{ + return m->fd; +} + +int tcp_isset(struct tcp_sock *m, fd_set *readfds) +{ + return m->client_fd >= 0 ? FD_ISSET(m->client_fd, readfds) : 0; +} + +int tcp_accept_isset(struct tcp_sock *m, fd_set *readfds) +{ + return FD_ISSET(m->fd, readfds); +} + +int +tcp_snprintf_stats(char *buf, size_t buflen, char *ifname, + struct tcp_sock *client, struct tcp_sock *server) +{ + size_t size; + struct tcp_stats *s = &client->stats, *r = &server->stats; + + size = snprintf(buf, buflen, "TCP traffic (active device=%s) " + "server=%s client=%s:\n" + "%20llu Bytes sent " + "%20llu Bytes recv\n" + "%20llu Pckts sent " + "%20llu Pckts recv\n" + "%20llu Error send " + "%20llu Error recv\n\n", + ifname, + server->state == TCP_SERVER_CONNECTED ? + "connected" : "disconnected", + client->state == TCP_CLIENT_CONNECTED ? + "connected" : "disconnected", + (unsigned long long)s->bytes, + (unsigned long long)r->bytes, + (unsigned long long)s->messages, + (unsigned long long)r->messages, + (unsigned long long)s->error, + (unsigned long long)r->error); + return size; +} + +int +tcp_snprintf_stats2(char *buf, size_t buflen, const char *ifname, + const char *status, int active, + struct tcp_stats *s, struct tcp_stats *r) +{ + size_t size; + + size = snprintf(buf, buflen, + "TCP traffic device=%s status=%s role=%s:\n" + "%20llu Bytes sent " + "%20llu Bytes recv\n" + "%20llu Pckts sent " + "%20llu Pckts recv\n" + "%20llu Error send " + "%20llu Error recv\n\n", + ifname, status, active ? "ACTIVE" : "BACKUP", + (unsigned long long)s->bytes, + (unsigned long long)r->bytes, + (unsigned long long)s->messages, + (unsigned long long)r->messages, + (unsigned long long)s->error, + (unsigned long long)r->error); + return size; +} diff --git a/src/traffic_stats.c b/src/traffic_stats.c new file mode 100644 index 0000000..6535527 --- /dev/null +++ b/src/traffic_stats.c @@ -0,0 +1,47 @@ +/* + * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "traffic_stats.h" +#include "conntrackd.h" + +void update_traffic_stats(struct nf_conntrack *ct) +{ + STATE(stats).bytes_orig += + nfct_get_attr_u32(ct, ATTR_ORIG_COUNTER_BYTES); + STATE(stats).bytes_repl += + nfct_get_attr_u32(ct, ATTR_REPL_COUNTER_BYTES); + STATE(stats).packets_orig += + nfct_get_attr_u32(ct, ATTR_ORIG_COUNTER_PACKETS); + STATE(stats).packets_repl += + nfct_get_attr_u32(ct, ATTR_REPL_COUNTER_PACKETS); +} + +void dump_traffic_stats(int fd) +{ + char buf[512]; + int size; + uint64_t bytes = STATE(stats).bytes_orig + STATE(stats).bytes_repl; + uint64_t packets = STATE(stats).packets_orig + + STATE(stats).packets_repl; + + size = sprintf(buf, "traffic processed:\n"); + size += sprintf(buf+size, "%20llu Bytes ", (unsigned long long)bytes); + size += sprintf(buf+size, "%20llu Pckts\n\n", (unsigned long long)packets); + + send(fd, buf, size, 0); +} diff --git a/src/udp.c b/src/udp.c new file mode 100644 index 0000000..ecaa46e --- /dev/null +++ b/src/udp.c @@ -0,0 +1,268 @@ +/* + * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "udp.h" + +#include <stdio.h> +#include <stdlib.h> +#include <arpa/inet.h> +#include <unistd.h> +#include <string.h> +#include <sys/ioctl.h> +#include <net/if.h> +#include <errno.h> +#include <limits.h> + +struct udp_sock *udp_server_create(struct udp_conf *conf) +{ + int yes = 1; + struct udp_sock *m; + socklen_t socklen = sizeof(int); + + m = calloc(sizeof(struct udp_sock), 1); + if (m == NULL) + return NULL; + + switch(conf->ipproto) { + case AF_INET: + m->addr.ipv4.sin_family = AF_INET; + m->addr.ipv4.sin_port = htons(conf->port); + m->addr.ipv4.sin_addr = conf->server.ipv4.inet_addr; + m->sockaddr_len = sizeof(struct sockaddr_in); + break; + + case AF_INET6: + m->addr.ipv6.sin6_family = AF_INET6; + m->addr.ipv6.sin6_port = htons(conf->port); + m->addr.ipv6.sin6_addr = conf->server.ipv6.inet_addr6; + m->addr.ipv6.sin6_scope_id = conf->server.ipv6.scope_id; + m->sockaddr_len = sizeof(struct sockaddr_in6); + break; + } + + m->fd = socket(conf->ipproto, SOCK_DGRAM, 0); + if (m->fd == -1) { + free(m); + return NULL; + } + + if (setsockopt(m->fd, SOL_SOCKET, SO_REUSEADDR, &yes, + sizeof(int)) == -1) { + close(m->fd); + free(m); + return NULL; + } + +#ifndef SO_RCVBUFFORCE +#define SO_RCVBUFFORCE 33 +#endif + + if (conf->rcvbuf && + setsockopt(m->fd, SOL_SOCKET, SO_RCVBUFFORCE, &conf->rcvbuf, + sizeof(int)) == -1) { + /* not supported in linux kernel < 2.6.14 */ + if (errno != ENOPROTOOPT) { + close(m->fd); + free(m); + return NULL; + } + } + + getsockopt(m->fd, SOL_SOCKET, SO_RCVBUF, &conf->rcvbuf, &socklen); + + if (bind(m->fd, (struct sockaddr *) &m->addr, m->sockaddr_len) == -1) { + close(m->fd); + free(m); + return NULL; + } + + return m; +} + +void udp_server_destroy(struct udp_sock *m) +{ + close(m->fd); + free(m); +} + +struct udp_sock *udp_client_create(struct udp_conf *conf) +{ + int ret = 0; + struct udp_sock *m; + socklen_t socklen = sizeof(int); + + m = calloc(sizeof(struct udp_sock), 1); + if (m == NULL) + return NULL; + + m->fd = socket(conf->ipproto, SOCK_DGRAM, 0); + if (m->fd == -1) { + free(m); + return NULL; + } + + if (setsockopt(m->fd, SOL_SOCKET, SO_NO_CHECK, &conf->checksum, + sizeof(int)) == -1) { + close(m->fd); + free(m); + return NULL; + } + +#ifndef SO_SNDBUFFORCE +#define SO_SNDBUFFORCE 32 +#endif + + if (conf->sndbuf && + setsockopt(m->fd, SOL_SOCKET, SO_SNDBUFFORCE, &conf->sndbuf, + sizeof(int)) == -1) { + /* not supported in linux kernel < 2.6.14 */ + if (errno != ENOPROTOOPT) { + close(m->fd); + free(m); + return NULL; + } + } + + getsockopt(m->fd, SOL_SOCKET, SO_SNDBUF, &conf->sndbuf, &socklen); + + switch(conf->ipproto) { + case AF_INET: + m->addr.ipv4.sin_family = AF_INET; + m->addr.ipv4.sin_port = htons(conf->port); + m->addr.ipv4.sin_addr = conf->client.inet_addr; + m->sockaddr_len = sizeof(struct sockaddr_in); + break; + case AF_INET6: + m->addr.ipv6.sin6_family = AF_INET6; + m->addr.ipv6.sin6_port = htons(conf->port); + memcpy(&m->addr.ipv6.sin6_addr, &conf->client.inet_addr6, + sizeof(struct in6_addr)); + m->sockaddr_len = sizeof(struct sockaddr_in6); + break; + default: + ret = -1; + break; + } + + if (ret == -1) { + close(m->fd); + free(m); + m = NULL; + } + + return m; +} + +void udp_client_destroy(struct udp_sock *m) +{ + close(m->fd); + free(m); +} + +ssize_t udp_send(struct udp_sock *m, const void *data, int size) +{ + ssize_t ret; + + ret = sendto(m->fd, + data, + size, + 0, + (struct sockaddr *) &m->addr, + m->sockaddr_len); + if (ret == -1) { + m->stats.error++; + return ret; + } + + m->stats.bytes += ret; + m->stats.messages++; + + return ret; +} + +ssize_t udp_recv(struct udp_sock *m, void *data, int size) +{ + ssize_t ret; + socklen_t sin_size = sizeof(struct sockaddr_in); + + ret = recvfrom(m->fd, + data, + size, + 0, + (struct sockaddr *)&m->addr, + &sin_size); + if (ret == -1) { + if (errno != EAGAIN) + m->stats.error++; + return ret; + } + + m->stats.bytes += ret; + m->stats.messages++; + + return ret; +} + +int udp_get_fd(struct udp_sock *m) +{ + return m->fd; +} + +int udp_isset(struct udp_sock *m, fd_set *readfds) +{ + return FD_ISSET(m->fd, readfds); +} + +int +udp_snprintf_stats(char *buf, size_t buflen, char *ifname, + struct udp_stats *s, struct udp_stats *r) +{ + size_t size; + + size = snprintf(buf, buflen, "UDP traffic (active device=%s):\n" + "%20llu Bytes sent " + "%20llu Bytes recv\n" + "%20llu Pckts sent " + "%20llu Pckts recv\n" + "%20llu Error send " + "%20llu Error recv\n\n", + ifname, + (unsigned long long)s->bytes, + (unsigned long long)r->bytes, + (unsigned long long)s->messages, + (unsigned long long)r->messages, + (unsigned long long)s->error, + (unsigned long long)r->error); + return size; +} + +int +udp_snprintf_stats2(char *buf, size_t buflen, const char *ifname, + const char *status, int active, + struct udp_stats *s, struct udp_stats *r) +{ + size_t size; + + size = snprintf(buf, buflen, + "UDP traffic device=%s status=%s role=%s:\n" + "%20llu Bytes sent " + "%20llu Bytes recv\n" + "%20llu Pckts sent " + "%20llu Pckts recv\n" + "%20llu Error send " + "%20llu Error recv\n\n", + ifname, status, active ? "ACTIVE" : "BACKUP", + (unsigned long long)s->bytes, + (unsigned long long)r->bytes, + (unsigned long long)s->messages, + (unsigned long long)r->messages, + (unsigned long long)s->error, + (unsigned long long)r->error); + return size; +} diff --git a/src/vector.c b/src/vector.c new file mode 100644 index 0000000..c81e7ce --- /dev/null +++ b/src/vector.c @@ -0,0 +1,88 @@ +/* + * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "vector.h" + +#include <stdlib.h> +#include <string.h> + +struct vector { + char *data; + unsigned int cur_elems; + unsigned int max_elems; + size_t size; +}; + +#define DEFAULT_VECTOR_MEMBERS 8 +#define DEFAULT_VECTOR_GROWTH 8 + +struct vector *vector_create(size_t size) +{ + struct vector *v; + + v = calloc(sizeof(struct vector), 1); + if (v == NULL) + return NULL; + + v->size = size; + v->cur_elems = 0; + v->max_elems = DEFAULT_VECTOR_MEMBERS; + + v->data = calloc(size * DEFAULT_VECTOR_MEMBERS, 1); + if (v->data == NULL) { + free(v); + return NULL; + } + + return v; +} + +void vector_destroy(struct vector *v) +{ + free(v->data); + free(v); +} + +int vector_add(struct vector *v, void *data) +{ + if (v->cur_elems >= v->max_elems) { + v->max_elems += DEFAULT_VECTOR_GROWTH; + v->data = realloc(v->data, v->max_elems * v->size); + if (v->data == NULL) { + v->max_elems -= DEFAULT_VECTOR_GROWTH; + return -1; + } + } + memcpy(v->data + (v->size * v->cur_elems), data, v->size); + v->cur_elems++; + return 0; +} + +int vector_iterate(struct vector *v, + const void *data, + int (*fcn)(const void *a, const void *b)) +{ + unsigned int i; + + for (i=0; i<v->cur_elems; i++) { + char *ptr = v->data + (v->size * i); + if (fcn(ptr, data)) + return 1; + } + return 0; +} |