Codebase list nfdump / ffa738b
Imported Upstream version 1.6.3 Erik Wenzel 13 years ago
81 changed file(s) with 7772 addition(s) and 1489 deletion(s). Raw diff Collapse all Expand all
(No changes)
(No changes)
0 2011-02-05
1 - Fix SysUptime 32bit overflow in v5 header
2 - Add fix for strange first/last swap reported by some users.
3
4 2011-01-09 v1.6.3
5 - Fix extension size bug
6 - Move IP anonymisation to separate binary nfanon
7 - Fix initialise bug of -o fmt: and not available fields
8
09 2010-09-09 v1.6.2
110 - released
211 - fixes some sflow bugs in sfcapd
33 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
44 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
55
6 This file is free documentation; the Free Software Foundation gives
7 unlimited permission to copy, distribute and modify it.
6 Copying and distribution of this file, with or without modification,
7 are permitted in any medium without royalty provided the copyright
8 notice and this notice are preserved. This file is offered as-is,
9 without warranty of any kind.
810
911 Basic Installation
1012 ==================
1214 Briefly, the shell commands `./configure; make; make install' should
1315 configure, build, and install this package. The following
1416 more-detailed instructions are generic; see the `README' file for
15 instructions specific to this package.
17 instructions specific to this package. Some packages provide this
18 `INSTALL' file but do not implement all of the features documented
19 below. The lack of an optional feature in a given package is not
20 necessarily a bug. More recommendations for GNU packages can be found
21 in *note Makefile Conventions: (standards)Makefile Conventions.
1622
1723 The `configure' shell script attempts to guess correct values for
1824 various system-dependent variables used during compilation. It uses
4147 you want to change it or regenerate `configure' using a newer version
4248 of `autoconf'.
4349
44 The simplest way to compile this package is:
50 The simplest way to compile this package is:
4551
4652 1. `cd' to the directory containing the package's source code and type
4753 `./configure' to configure the package for your system.
5258 2. Type `make' to compile the package.
5359
5460 3. Optionally, type `make check' to run any self-tests that come with
55 the package.
61 the package, generally using the just-built uninstalled binaries.
5662
5763 4. Type `make install' to install the programs and any data files and
58 documentation.
59
60 5. You can remove the program binaries and object files from the
64 documentation. When installing into a prefix owned by root, it is
65 recommended that the package be configured and built as a regular
66 user, and only the `make install' phase executed with root
67 privileges.
68
69 5. Optionally, type `make installcheck' to repeat any self-tests, but
70 this time using the binaries in their final installed location.
71 This target does not install anything. Running this target as a
72 regular user, particularly if the prior `make install' required
73 root privileges, verifies that the installation completed
74 correctly.
75
76 6. You can remove the program binaries and object files from the
6177 source code directory by typing `make clean'. To also remove the
6278 files that `configure' created (so you can compile the package for
6379 a different kind of computer), type `make distclean'. There is
6682 all sorts of other programs in order to regenerate files that came
6783 with the distribution.
6884
69 6. Often, you can also type `make uninstall' to remove the installed
70 files again.
85 7. Often, you can also type `make uninstall' to remove the installed
86 files again. In practice, not all packages have tested that
87 uninstallation works correctly, even though it is required by the
88 GNU Coding Standards.
89
90 8. Some packages, particularly those that use Automake, provide `make
91 distcheck', which can by used by developers to test that all other
92 targets like `make install' and `make uninstall' work correctly.
93 This target is generally not run by end users.
7194
7295 Compilers and Options
7396 =====================
92115 own directory. To do this, you can use GNU `make'. `cd' to the
93116 directory where you want the object files and executables to go and run
94117 the `configure' script. `configure' automatically checks for the
95 source code in the directory that `configure' is in and in `..'.
118 source code in the directory that `configure' is in and in `..'. This
119 is known as a "VPATH" build.
96120
97121 With a non-GNU `make', it is safer to compile the package for one
98122 architecture at a time in the source code directory. After you have
119143 By default, `make install' installs the package's commands under
120144 `/usr/local/bin', include files under `/usr/local/include', etc. You
121145 can specify an installation prefix other than `/usr/local' by giving
122 `configure' the option `--prefix=PREFIX'.
146 `configure' the option `--prefix=PREFIX', where PREFIX must be an
147 absolute file name.
123148
124149 You can specify separate installation prefixes for
125150 architecture-specific files and architecture-independent files. If you
130155 In addition, if you use an unusual directory layout you can give
131156 options like `--bindir=DIR' to specify different values for particular
132157 kinds of files. Run `configure --help' for a list of the directories
133 you can set and what kinds of files go in them.
158 you can set and what kinds of files go in them. In general, the
159 default for these options is expressed in terms of `${prefix}', so that
160 specifying just `--prefix' will affect all of the other directory
161 specifications that were not explicitly provided.
162
163 The most portable way to affect installation locations is to pass the
164 correct locations to `configure'; however, many packages provide one or
165 both of the following shortcuts of passing variable assignments to the
166 `make install' command line to change installation locations without
167 having to reconfigure or recompile.
168
169 The first method involves providing an override variable for each
170 affected directory. For example, `make install
171 prefix=/alternate/directory' will choose an alternate location for all
172 directory configuration variables that were expressed in terms of
173 `${prefix}'. Any directories that were specified during `configure',
174 but not in terms of `${prefix}', must each be overridden at install
175 time for the entire installation to be relocated. The approach of
176 makefile variable overrides for each directory variable is required by
177 the GNU Coding Standards, and ideally causes no recompilation.
178 However, some platforms have known limitations with the semantics of
179 shared libraries that end up requiring recompilation when using this
180 method, particularly noticeable in packages that use GNU Libtool.
181
182 The second method involves providing the `DESTDIR' variable. For
183 example, `make install DESTDIR=/alternate/directory' will prepend
184 `/alternate/directory' before all installation names. The approach of
185 `DESTDIR' overrides is not required by the GNU Coding Standards, and
186 does not work on platforms that have drive letters. On the other hand,
187 it does better at avoiding recompilation issues, and works well even
188 when some directory options were not specified in terms of `${prefix}'
189 at `configure' time.
190
191 Optional Features
192 =================
134193
135194 If the package supports it, you can cause programs to be installed
136195 with an extra prefix or suffix on their names by giving `configure' the
137196 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
138
139 Optional Features
140 =================
141197
142198 Some packages pay attention to `--enable-FEATURE' options to
143199 `configure', where FEATURE indicates an optional part of the package.
150206 find the X include and library files automatically, but if it doesn't,
151207 you can use the `configure' options `--x-includes=DIR' and
152208 `--x-libraries=DIR' to specify their locations.
209
210 Some packages offer the ability to configure how verbose the
211 execution of `make' will be. For these packages, running `./configure
212 --enable-silent-rules' sets the default to minimal output, which can be
213 overridden with `make V=1'; while running `./configure
214 --disable-silent-rules' sets the default to verbose, which can be
215 overridden with `make V=0'.
153216
154217 Particular systems
155218 ==================
287350 `configure' can determine that directory automatically.
288351
289352 `--prefix=DIR'
290 Use DIR as the installation prefix. *Note Installation Names::
353 Use DIR as the installation prefix. *note Installation Names::
291354 for more details, including other options available for fine-tuning
292355 the installation locations.
293356
(No changes)
0 # Makefile.in generated by automake 1.11 from Makefile.am.
0 # Makefile.in generated by automake 1.11.1 from Makefile.am.
11 # @configure_input@
22
33 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
259259 # (which will cause the Makefiles to be regenerated when you run `make');
260260 # (2) otherwise, pass the desired values on the `make' command line.
261261 $(RECURSIVE_TARGETS):
262 @failcom='exit 1'; \
262 @fail= failcom='exit 1'; \
263263 for f in x $$MAKEFLAGS; do \
264264 case $$f in \
265265 *=* | --[!k]*);; \
284284 fi; test -z "$$fail"
285285
286286 $(RECURSIVE_CLEAN_TARGETS):
287 @failcom='exit 1'; \
287 @fail= failcom='exit 1'; \
288288 for f in x $$MAKEFLAGS; do \
289289 case $$f in \
290290 *=* | --[!k]*);; \
448448 fi; \
449449 done
450450 -test -n "$(am__skip_mode_fix)" \
451 || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
451 || find "$(distdir)" -type d ! -perm -755 \
452 -exec chmod u+rwx,go+rx {} \; -o \
452453 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
453454 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
454455 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
492493 distcheck: dist
493494 case '$(DIST_ARCHIVES)' in \
494495 *.tar.gz*) \
495 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
496 GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
496497 *.tar.bz2*) \
497 bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
498 bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
498499 *.tar.lzma*) \
499 unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
500 lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
500501 *.tar.xz*) \
501502 xz -dc $(distdir).tar.xz | $(am__untar) ;;\
502503 *.tar.Z*) \
503504 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
504505 *.shar.gz*) \
505 GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
506 GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
506507 *.zip*) \
507508 unzip $(distdir).zip ;;\
508509 esac
(No changes)
0 # generated automatically by aclocal 1.11 -*- Autoconf -*-
0 # generated automatically by aclocal 1.11.1 -*- Autoconf -*-
11
22 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
33 # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
1212
1313 m4_ifndef([AC_AUTOCONF_VERSION],
1414 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
15 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
16 [m4_warning([this file was generated for autoconf 2.65.
15 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
16 [m4_warning([this file was generated for autoconf 2.67.
1717 You have another version of autoconf. It may work, but is not guaranteed to.
1818 If you have problems, you may need to regenerate the build system entirely.
1919 To do so, use the procedure documented by the package, typically `autoreconf'.])])
3333 [am__api_version='1.11'
3434 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3535 dnl require some minimum version. Point them to the right macro.
36 m4_if([$1], [1.11], [],
36 m4_if([$1], [1.11.1], [],
3737 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
3838 ])
3939
4949 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5050 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5151 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
52 [AM_AUTOMAKE_VERSION([1.11])dnl
52 [AM_AUTOMAKE_VERSION([1.11.1])dnl
5353 m4_ifndef([AC_AUTOCONF_VERSION],
5454 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5555 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
0 Add extensions:
1 ===============
2
3 1. Add appropriate definitions for new extension in nffile.h
4 2. Update extension_descriptor array in nfx.c to reflect the new extension.
5 Increase user index ( 3rd value )
00
1 bin_PROGRAMS = nfcapd nfdump nfreplay nfexpire
1 bin_PROGRAMS = nfcapd nfdump nfreplay nfexpire nfanon
22 EXTRA_PROGRAMS = nftest nfgen nfreader
33
44 check_PROGRAMMS = test.sh
1010
1111 if NFPROFILE
1212 bin_PROGRAMS += nfprofile
13 endif
14
15 if NFTRACK
16 bin_PROGRAMS += nftrack
1317 endif
1418
1519 if FT2NFDUMP
2529 #Add extra debug info for gdb
2630 AM_CFLAGS = -ggdb
2731
28 common = nf_common.c nf_common.h panonymizer.c panonymizer.h rijndael.c \
29 version.h rijndael.h
32 common = nf_common.c nf_common.h version.h
3033 util = util.c util.h
3134 filelzo = minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c nffile.h nfx.c nfx.h
3235 nflist = flist.c flist.h fts_compat.c fts_compat.h
3336 filter = grammar.y scanner.l nftree.c nftree.h ipconv.c ipconv.h rbtree.h
3437 nfprof = nfprof.c nfprof.h
3538 nfnet = nfnet.c nfnet.h
39 anon = panonymizer.c panonymizer.h rijndael.c rijndael.h
3640 collector = collector.c collector.h
3741 nfv9 = netflow_v9.c netflow_v9.h
3842 nfv5v7 = netflow_v5_v7.c netflow_v5_v7.h
5256 nfprofile_SOURCES = nfprofile.c profile.c profile.h \
5357 $(common) $(util) $(filelzo) $(nflist) $(filter) $(nfstatfile)
5458 nfprofile_LDADD = -lrrd
59
60 nftrack_SOURCES = ../extra/nftrack/nftrack.c ../extra/nftrack/nftrack_rrd.c ../extra/nftrack/nftrack_stat.c \
61 $(common) $(util) $(filelzo) $(nflist) $(filter)
62 nftrack_CFLAGS = -I ../extra/nftrack
63 nftrack_LDADD = -lrrd
5564
5665 nfcapd_SOURCES = nfcapd.c \
5766 $(common) $(util) $(filelzo) $(nflist) $(nfstatfile) $(launch) \
7483 endif
7584
7685 nfreader_SOURCES = nfreader.c \
77 $(util) $(filelzo) $(nflist)
86 $(util) $(filelzo) $(nflist)
87
88 nfanon_SOURCES = nfanon.c \
89 $(util) $(filelzo) $(nflist) $(anon)
7890
7991 nfgen_SOURCES = nfgen.c $(util) $(filelzo) $(nflist)
8092
0 # Makefile.in generated by automake 1.11 from Makefile.am.
0 # Makefile.in generated by automake 1.11.1 from Makefile.am.
11 # @configure_input@
22
33 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3232 PRE_UNINSTALL = :
3333 POST_UNINSTALL = :
3434 bin_PROGRAMS = nfcapd$(EXEEXT) nfdump$(EXEEXT) nfreplay$(EXEEXT) \
35 nfexpire$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \
36 $(am__EXEEXT_3)
35 nfexpire$(EXEEXT) nfanon$(EXEEXT) $(am__EXEEXT_1) \
36 $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4)
3737 EXTRA_PROGRAMS = nftest$(EXEEXT) nfgen$(EXEEXT) nfreader$(EXEEXT)
3838 TESTS = nftest$(EXEEXT) test.sh
3939 @SFLOW_TRUE@am__append_1 = sfcapd
4040 @NFPROFILE_TRUE@am__append_2 = nfprofile
41 @FT2NFDUMP_TRUE@am__append_3 = ft2nfdump
42 @READPCAP_TRUE@am__append_4 = pcap_reader.c pcap_reader.h
41 @NFTRACK_TRUE@am__append_3 = nftrack
42 @FT2NFDUMP_TRUE@am__append_4 = ft2nfdump
4343 @READPCAP_TRUE@am__append_5 = pcap_reader.c pcap_reader.h
44 @READPCAP_TRUE@am__append_6 = pcap_reader.c pcap_reader.h
4445 subdir = bin
4546 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in grammar.c \
4647 grammar.h scanner.c
5455 CONFIG_CLEAN_VPATH_FILES =
5556 @SFLOW_TRUE@am__EXEEXT_1 = sfcapd$(EXEEXT)
5657 @NFPROFILE_TRUE@am__EXEEXT_2 = nfprofile$(EXEEXT)
57 @FT2NFDUMP_TRUE@am__EXEEXT_3 = ft2nfdump$(EXEEXT)
58 @NFTRACK_TRUE@am__EXEEXT_3 = nftrack$(EXEEXT)
59 @FT2NFDUMP_TRUE@am__EXEEXT_4 = ft2nfdump$(EXEEXT)
5860 am__installdirs = "$(DESTDIR)$(bindir)"
5961 PROGRAMS = $(bin_PROGRAMS)
6062 am__ft2nfdump_SOURCES_DIST = ft2nfdump.c nf_common.c nf_common.h \
61 panonymizer.c panonymizer.h rijndael.c version.h rijndael.h \
62 minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c nffile.h \
63 nfx.c nfx.h util.c util.h
64 am__objects_1 = ft2nfdump-nf_common.$(OBJEXT) \
65 ft2nfdump-panonymizer.$(OBJEXT) ft2nfdump-rijndael.$(OBJEXT)
63 version.h minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c \
64 nffile.h nfx.c nfx.h util.c util.h
65 am__objects_1 = ft2nfdump-nf_common.$(OBJEXT)
6666 am__objects_2 = ft2nfdump-minilzo.$(OBJEXT) ft2nfdump-nffile.$(OBJEXT) \
6767 ft2nfdump-nfx.$(OBJEXT)
6868 am__objects_3 = ft2nfdump-util.$(OBJEXT)
7373 ft2nfdump_DEPENDENCIES =
7474 ft2nfdump_LINK = $(CCLD) $(ft2nfdump_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
7575 $(LDFLAGS) -o $@
76 am__nfcapd_SOURCES_DIST = nfcapd.c nf_common.c nf_common.h \
77 panonymizer.c panonymizer.h rijndael.c version.h rijndael.h \
76 am__objects_4 = util.$(OBJEXT)
77 am__objects_5 = minilzo.$(OBJEXT) nffile.$(OBJEXT) nfx.$(OBJEXT)
78 am__objects_6 = flist.$(OBJEXT) fts_compat.$(OBJEXT)
79 am__objects_7 = panonymizer.$(OBJEXT) rijndael.$(OBJEXT)
80 am_nfanon_OBJECTS = nfanon.$(OBJEXT) $(am__objects_4) $(am__objects_5) \
81 $(am__objects_6) $(am__objects_7)
82 nfanon_OBJECTS = $(am_nfanon_OBJECTS)
83 nfanon_LDADD = $(LDADD)
84 nfanon_DEPENDENCIES =
85 am__nfcapd_SOURCES_DIST = nfcapd.c nf_common.c nf_common.h version.h \
7886 util.c util.h minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c \
7987 nffile.h nfx.c nfx.h flist.c flist.h fts_compat.c fts_compat.h \
8088 nfstatfile.c nfstatfile.h launch.c launch.h nfnet.c nfnet.h \
8189 collector.c collector.h netflow_v9.c netflow_v9.h \
8290 netflow_v5_v7.c netflow_v5_v7.h bookkeeper.c bookkeeper.h \
8391 expire.c expire.h pcap_reader.c pcap_reader.h
84 am__objects_4 = nfcapd-nf_common.$(OBJEXT) \
85 nfcapd-panonymizer.$(OBJEXT) nfcapd-rijndael.$(OBJEXT)
86 am__objects_5 = nfcapd-util.$(OBJEXT)
87 am__objects_6 = nfcapd-minilzo.$(OBJEXT) nfcapd-nffile.$(OBJEXT) \
92 am__objects_8 = nfcapd-nf_common.$(OBJEXT)
93 am__objects_9 = nfcapd-util.$(OBJEXT)
94 am__objects_10 = nfcapd-minilzo.$(OBJEXT) nfcapd-nffile.$(OBJEXT) \
8895 nfcapd-nfx.$(OBJEXT)
89 am__objects_7 = nfcapd-flist.$(OBJEXT) nfcapd-fts_compat.$(OBJEXT)
90 am__objects_8 = nfcapd-nfstatfile.$(OBJEXT)
91 am__objects_9 = nfcapd-launch.$(OBJEXT)
92 am__objects_10 = nfcapd-nfnet.$(OBJEXT)
93 am__objects_11 = nfcapd-collector.$(OBJEXT)
94 am__objects_12 = nfcapd-netflow_v9.$(OBJEXT)
95 am__objects_13 = nfcapd-netflow_v5_v7.$(OBJEXT)
96 am__objects_14 = nfcapd-bookkeeper.$(OBJEXT)
97 am__objects_15 = nfcapd-expire.$(OBJEXT)
98 @READPCAP_TRUE@am__objects_16 = nfcapd-pcap_reader.$(OBJEXT)
99 am_nfcapd_OBJECTS = nfcapd-nfcapd.$(OBJEXT) $(am__objects_4) \
100 $(am__objects_5) $(am__objects_6) $(am__objects_7) \
101 $(am__objects_8) $(am__objects_9) $(am__objects_10) \
102 $(am__objects_11) $(am__objects_12) $(am__objects_13) \
103 $(am__objects_14) $(am__objects_15) $(am__objects_16)
96 am__objects_11 = nfcapd-flist.$(OBJEXT) nfcapd-fts_compat.$(OBJEXT)
97 am__objects_12 = nfcapd-nfstatfile.$(OBJEXT)
98 am__objects_13 = nfcapd-launch.$(OBJEXT)
99 am__objects_14 = nfcapd-nfnet.$(OBJEXT)
100 am__objects_15 = nfcapd-collector.$(OBJEXT)
101 am__objects_16 = nfcapd-netflow_v9.$(OBJEXT)
102 am__objects_17 = nfcapd-netflow_v5_v7.$(OBJEXT)
103 am__objects_18 = nfcapd-bookkeeper.$(OBJEXT)
104 am__objects_19 = nfcapd-expire.$(OBJEXT)
105 @READPCAP_TRUE@am__objects_20 = nfcapd-pcap_reader.$(OBJEXT)
106 am_nfcapd_OBJECTS = nfcapd-nfcapd.$(OBJEXT) $(am__objects_8) \
107 $(am__objects_9) $(am__objects_10) $(am__objects_11) \
108 $(am__objects_12) $(am__objects_13) $(am__objects_14) \
109 $(am__objects_15) $(am__objects_16) $(am__objects_17) \
110 $(am__objects_18) $(am__objects_19) $(am__objects_20)
104111 nfcapd_OBJECTS = $(am_nfcapd_OBJECTS)
105112 nfcapd_DEPENDENCIES =
106113 nfcapd_LINK = $(CCLD) $(nfcapd_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
107114 $(LDFLAGS) -o $@
108 am__objects_17 = nf_common.$(OBJEXT) panonymizer.$(OBJEXT) \
109 rijndael.$(OBJEXT)
110 am__objects_18 = nflowcache.$(OBJEXT)
111 am__objects_19 = util.$(OBJEXT)
112 am__objects_20 = minilzo.$(OBJEXT) nffile.$(OBJEXT) nfx.$(OBJEXT)
113 am__objects_21 = flist.$(OBJEXT) fts_compat.$(OBJEXT)
114 am__objects_22 = grammar.$(OBJEXT) scanner.$(OBJEXT) nftree.$(OBJEXT) \
115 am__objects_21 = nf_common.$(OBJEXT)
116 am__objects_22 = nflowcache.$(OBJEXT)
117 am__objects_23 = grammar.$(OBJEXT) scanner.$(OBJEXT) nftree.$(OBJEXT) \
115118 ipconv.$(OBJEXT)
116 am__objects_23 = nfprof.$(OBJEXT)
119 am__objects_24 = nfprof.$(OBJEXT)
117120 am_nfdump_OBJECTS = nfdump.$(OBJEXT) nfstat.$(OBJEXT) \
118 nfexport.$(OBJEXT) $(am__objects_17) $(am__objects_18) \
119 $(am__objects_19) $(am__objects_20) $(am__objects_21) \
120 $(am__objects_22) $(am__objects_23)
121 nfexport.$(OBJEXT) $(am__objects_21) $(am__objects_22) \
122 $(am__objects_4) $(am__objects_5) $(am__objects_6) \
123 $(am__objects_23) $(am__objects_24)
121124 nfdump_OBJECTS = $(am_nfdump_OBJECTS)
122125 nfdump_LDADD = $(LDADD)
123126 nfdump_DEPENDENCIES =
124 am__objects_24 = bookkeeper.$(OBJEXT)
125 am__objects_25 = expire.$(OBJEXT)
126 am__objects_26 = nfstatfile.$(OBJEXT)
127 am_nfexpire_OBJECTS = nfexpire.$(OBJEXT) $(am__objects_24) \
128 $(am__objects_25) $(am__objects_19) $(am__objects_26)
127 am__objects_25 = bookkeeper.$(OBJEXT)
128 am__objects_26 = expire.$(OBJEXT)
129 am__objects_27 = nfstatfile.$(OBJEXT)
130 am_nfexpire_OBJECTS = nfexpire.$(OBJEXT) $(am__objects_25) \
131 $(am__objects_26) $(am__objects_4) $(am__objects_27)
129132 nfexpire_OBJECTS = $(am_nfexpire_OBJECTS)
130133 nfexpire_DEPENDENCIES =
131 am_nfgen_OBJECTS = nfgen.$(OBJEXT) $(am__objects_19) $(am__objects_20) \
132 $(am__objects_21)
134 am_nfgen_OBJECTS = nfgen.$(OBJEXT) $(am__objects_4) $(am__objects_5) \
135 $(am__objects_6)
133136 nfgen_OBJECTS = $(am_nfgen_OBJECTS)
134137 nfgen_LDADD = $(LDADD)
135138 nfgen_DEPENDENCIES =
136139 am_nfprofile_OBJECTS = nfprofile.$(OBJEXT) profile.$(OBJEXT) \
137 $(am__objects_17) $(am__objects_19) $(am__objects_20) \
138 $(am__objects_21) $(am__objects_22) $(am__objects_26)
140 $(am__objects_21) $(am__objects_4) $(am__objects_5) \
141 $(am__objects_6) $(am__objects_23) $(am__objects_27)
139142 nfprofile_OBJECTS = $(am_nfprofile_OBJECTS)
140143 nfprofile_DEPENDENCIES =
141 am_nfreader_OBJECTS = nfreader.$(OBJEXT) $(am__objects_19) \
142 $(am__objects_20) $(am__objects_21)
144 am_nfreader_OBJECTS = nfreader.$(OBJEXT) $(am__objects_4) \
145 $(am__objects_5) $(am__objects_6)
143146 nfreader_OBJECTS = $(am_nfreader_OBJECTS)
144147 nfreader_LDADD = $(LDADD)
145148 nfreader_DEPENDENCIES =
146 am__objects_27 = nfnet.$(OBJEXT)
147 am__objects_28 = collector.$(OBJEXT)
148 am__objects_29 = netflow_v9.$(OBJEXT)
149 am__objects_30 = netflow_v5_v7.$(OBJEXT)
150 am_nfreplay_OBJECTS = nfreplay.$(OBJEXT) $(am__objects_17) \
151 $(am__objects_19) $(am__objects_20) $(am__objects_21) \
152 $(am__objects_22) $(am__objects_23) $(am__objects_27) \
153 $(am__objects_28) $(am__objects_29) $(am__objects_30)
149 am__objects_28 = nfnet.$(OBJEXT)
150 am__objects_29 = collector.$(OBJEXT)
151 am__objects_30 = netflow_v9.$(OBJEXT)
152 am__objects_31 = netflow_v5_v7.$(OBJEXT)
153 am_nfreplay_OBJECTS = nfreplay.$(OBJEXT) $(am__objects_21) \
154 $(am__objects_4) $(am__objects_5) $(am__objects_6) \
155 $(am__objects_23) $(am__objects_24) $(am__objects_28) \
156 $(am__objects_29) $(am__objects_30) $(am__objects_31)
154157 nfreplay_OBJECTS = $(am_nfreplay_OBJECTS)
155158 nfreplay_LDADD = $(LDADD)
156159 nfreplay_DEPENDENCIES =
157 am_nftest_OBJECTS = nftest.$(OBJEXT) $(am__objects_17) \
158 $(am__objects_22) $(am__objects_20)
160 am_nftest_OBJECTS = nftest.$(OBJEXT) $(am__objects_21) \
161 $(am__objects_23) $(am__objects_5)
159162 nftest_OBJECTS = $(am_nftest_OBJECTS)
160163 nftest_LDADD = $(LDADD)
164 am__objects_32 = nftrack-nf_common.$(OBJEXT)
165 am__objects_33 = nftrack-util.$(OBJEXT)
166 am__objects_34 = nftrack-minilzo.$(OBJEXT) nftrack-nffile.$(OBJEXT) \
167 nftrack-nfx.$(OBJEXT)
168 am__objects_35 = nftrack-flist.$(OBJEXT) nftrack-fts_compat.$(OBJEXT)
169 am__objects_36 = nftrack-grammar.$(OBJEXT) nftrack-scanner.$(OBJEXT) \
170 nftrack-nftree.$(OBJEXT) nftrack-ipconv.$(OBJEXT)
171 am_nftrack_OBJECTS = nftrack-nftrack.$(OBJEXT) \
172 nftrack-nftrack_rrd.$(OBJEXT) nftrack-nftrack_stat.$(OBJEXT) \
173 $(am__objects_32) $(am__objects_33) $(am__objects_34) \
174 $(am__objects_35) $(am__objects_36)
175 nftrack_OBJECTS = $(am_nftrack_OBJECTS)
176 nftrack_DEPENDENCIES =
177 nftrack_LINK = $(CCLD) $(nftrack_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
178 $(LDFLAGS) -o $@
161179 am__sfcapd_SOURCES_DIST = sfcapd.c sflow.c sflow.h sflow_proto.h \
162 nf_common.c nf_common.h panonymizer.c panonymizer.h rijndael.c \
163 version.h rijndael.h util.c util.h minilzo.c minilzo.h \
164 lzoconf.h lzodefs.h nffile.c nffile.h nfx.c nfx.h flist.c \
165 flist.h fts_compat.c fts_compat.h nfstatfile.c nfstatfile.h \
166 launch.c launch.h nfnet.c nfnet.h collector.c collector.h \
167 bookkeeper.c bookkeeper.h expire.c expire.h pcap_reader.c \
168 pcap_reader.h
169 am__objects_31 = sfcapd-nf_common.$(OBJEXT) \
170 sfcapd-panonymizer.$(OBJEXT) sfcapd-rijndael.$(OBJEXT)
171 am__objects_32 = sfcapd-util.$(OBJEXT)
172 am__objects_33 = sfcapd-minilzo.$(OBJEXT) sfcapd-nffile.$(OBJEXT) \
180 nf_common.c nf_common.h version.h util.c util.h minilzo.c \
181 minilzo.h lzoconf.h lzodefs.h nffile.c nffile.h nfx.c nfx.h \
182 flist.c flist.h fts_compat.c fts_compat.h nfstatfile.c \
183 nfstatfile.h launch.c launch.h nfnet.c nfnet.h collector.c \
184 collector.h bookkeeper.c bookkeeper.h expire.c expire.h \
185 pcap_reader.c pcap_reader.h
186 am__objects_37 = sfcapd-nf_common.$(OBJEXT)
187 am__objects_38 = sfcapd-util.$(OBJEXT)
188 am__objects_39 = sfcapd-minilzo.$(OBJEXT) sfcapd-nffile.$(OBJEXT) \
173189 sfcapd-nfx.$(OBJEXT)
174 am__objects_34 = sfcapd-flist.$(OBJEXT) sfcapd-fts_compat.$(OBJEXT)
175 am__objects_35 = sfcapd-nfstatfile.$(OBJEXT)
176 am__objects_36 = sfcapd-launch.$(OBJEXT)
177 am__objects_37 = sfcapd-nfnet.$(OBJEXT)
178 am__objects_38 = sfcapd-collector.$(OBJEXT)
179 am__objects_39 = sfcapd-bookkeeper.$(OBJEXT)
180 am__objects_40 = sfcapd-expire.$(OBJEXT)
181 @READPCAP_TRUE@am__objects_41 = sfcapd-pcap_reader.$(OBJEXT)
190 am__objects_40 = sfcapd-flist.$(OBJEXT) sfcapd-fts_compat.$(OBJEXT)
191 am__objects_41 = sfcapd-nfstatfile.$(OBJEXT)
192 am__objects_42 = sfcapd-launch.$(OBJEXT)
193 am__objects_43 = sfcapd-nfnet.$(OBJEXT)
194 am__objects_44 = sfcapd-collector.$(OBJEXT)
195 am__objects_45 = sfcapd-bookkeeper.$(OBJEXT)
196 am__objects_46 = sfcapd-expire.$(OBJEXT)
197 @READPCAP_TRUE@am__objects_47 = sfcapd-pcap_reader.$(OBJEXT)
182198 am_sfcapd_OBJECTS = sfcapd-sfcapd.$(OBJEXT) sfcapd-sflow.$(OBJEXT) \
183 $(am__objects_31) $(am__objects_32) $(am__objects_33) \
184 $(am__objects_34) $(am__objects_35) $(am__objects_36) \
185199 $(am__objects_37) $(am__objects_38) $(am__objects_39) \
186 $(am__objects_40) $(am__objects_41)
200 $(am__objects_40) $(am__objects_41) $(am__objects_42) \
201 $(am__objects_43) $(am__objects_44) $(am__objects_45) \
202 $(am__objects_46) $(am__objects_47)
187203 sfcapd_OBJECTS = $(am_sfcapd_OBJECTS)
188204 sfcapd_DEPENDENCIES =
189205 sfcapd_LINK = $(CCLD) $(sfcapd_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
199215 LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
200216 YLWRAP = $(top_srcdir)/ylwrap
201217 YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
202 SOURCES = $(ft2nfdump_SOURCES) $(nfcapd_SOURCES) $(nfdump_SOURCES) \
203 $(nfexpire_SOURCES) $(nfgen_SOURCES) $(nfprofile_SOURCES) \
204 $(nfreader_SOURCES) $(nfreplay_SOURCES) $(nftest_SOURCES) \
205 $(sfcapd_SOURCES)
206 DIST_SOURCES = $(am__ft2nfdump_SOURCES_DIST) \
218 SOURCES = $(ft2nfdump_SOURCES) $(nfanon_SOURCES) $(nfcapd_SOURCES) \
219 $(nfdump_SOURCES) $(nfexpire_SOURCES) $(nfgen_SOURCES) \
220 $(nfprofile_SOURCES) $(nfreader_SOURCES) $(nfreplay_SOURCES) \
221 $(nftest_SOURCES) $(nftrack_SOURCES) $(sfcapd_SOURCES)
222 DIST_SOURCES = $(am__ft2nfdump_SOURCES_DIST) $(nfanon_SOURCES) \
207223 $(am__nfcapd_SOURCES_DIST) $(nfdump_SOURCES) \
208224 $(nfexpire_SOURCES) $(nfgen_SOURCES) $(nfprofile_SOURCES) \
209225 $(nfreader_SOURCES) $(nfreplay_SOURCES) $(nftest_SOURCES) \
210 $(am__sfcapd_SOURCES_DIST)
226 $(nftrack_SOURCES) $(am__sfcapd_SOURCES_DIST)
211227 ETAGS = etags
212228 CTAGS = ctags
213229 am__tty_colors = \
317333
318334 #Add extra debug info for gdb
319335 AM_CFLAGS = -ggdb
320 common = nf_common.c nf_common.h panonymizer.c panonymizer.h rijndael.c \
321 version.h rijndael.h
322
336 common = nf_common.c nf_common.h version.h
323337 util = util.c util.h
324338 filelzo = minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c nffile.h nfx.c nfx.h
325339 nflist = flist.c flist.h fts_compat.c fts_compat.h
326340 filter = grammar.y scanner.l nftree.c nftree.h ipconv.c ipconv.h rbtree.h
327341 nfprof = nfprof.c nfprof.h
328342 nfnet = nfnet.c nfnet.h
343 anon = panonymizer.c panonymizer.h rijndael.c rijndael.h
329344 collector = collector.c collector.h
330345 nfv9 = netflow_v9.c netflow_v9.h
331346 nfv5v7 = netflow_v5_v7.c netflow_v5_v7.h
345360 $(common) $(util) $(filelzo) $(nflist) $(filter) $(nfstatfile)
346361
347362 nfprofile_LDADD = -lrrd
363 nftrack_SOURCES = ../extra/nftrack/nftrack.c ../extra/nftrack/nftrack_rrd.c ../extra/nftrack/nftrack_stat.c \
364 $(common) $(util) $(filelzo) $(nflist) $(filter)
365
366 nftrack_CFLAGS = -I ../extra/nftrack
367 nftrack_LDADD = -lrrd
348368 nfcapd_SOURCES = nfcapd.c $(common) $(util) $(filelzo) $(nflist) \
349369 $(nfstatfile) $(launch) $(nfnet) $(collector) $(nfv9) \
350 $(nfv5v7) $(bookkeeper) $(expire) $(am__append_4)
370 $(nfv5v7) $(bookkeeper) $(expire) $(am__append_5)
351371 @READPCAP_TRUE@nfcapd_CFLAGS = -DPCAP
352372 @READPCAP_TRUE@nfcapd_LDADD = -lpcap
353373 sfcapd_SOURCES = sfcapd.c sflow.c sflow.h sflow_proto.h $(common) \
354374 $(util) $(filelzo) $(nflist) $(nfstatfile) $(launch) $(nfnet) \
355 $(collector) $(bookkeeper) $(expire) $(am__append_5)
375 $(collector) $(bookkeeper) $(expire) $(am__append_6)
356376 @READPCAP_TRUE@sfcapd_CFLAGS = -DPCAP
357377 @READPCAP_TRUE@sfcapd_LDADD = -lpcap
358378 nfreader_SOURCES = nfreader.c \
359 $(util) $(filelzo) $(nflist)
379 $(util) $(filelzo) $(nflist)
380
381 nfanon_SOURCES = nfanon.c \
382 $(util) $(filelzo) $(nflist) $(anon)
360383
361384 nfgen_SOURCES = nfgen.c $(util) $(filelzo) $(nflist)
362385 nfexpire_SOURCES = nfexpire.c \
445468 ft2nfdump$(EXEEXT): $(ft2nfdump_OBJECTS) $(ft2nfdump_DEPENDENCIES)
446469 @rm -f ft2nfdump$(EXEEXT)
447470 $(ft2nfdump_LINK) $(ft2nfdump_OBJECTS) $(ft2nfdump_LDADD) $(LIBS)
471 nfanon$(EXEEXT): $(nfanon_OBJECTS) $(nfanon_DEPENDENCIES)
472 @rm -f nfanon$(EXEEXT)
473 $(LINK) $(nfanon_OBJECTS) $(nfanon_LDADD) $(LIBS)
448474 nfcapd$(EXEEXT): $(nfcapd_OBJECTS) $(nfcapd_DEPENDENCIES)
449475 @rm -f nfcapd$(EXEEXT)
450476 $(nfcapd_LINK) $(nfcapd_OBJECTS) $(nfcapd_LDADD) $(LIBS)
474500 nftest$(EXEEXT): $(nftest_OBJECTS) $(nftest_DEPENDENCIES)
475501 @rm -f nftest$(EXEEXT)
476502 $(LINK) $(nftest_OBJECTS) $(nftest_LDADD) $(LIBS)
503 nftrack$(EXEEXT): $(nftrack_OBJECTS) $(nftrack_DEPENDENCIES)
504 @rm -f nftrack$(EXEEXT)
505 $(nftrack_LINK) $(nftrack_OBJECTS) $(nftrack_LDADD) $(LIBS)
477506 sfcapd$(EXEEXT): $(sfcapd_OBJECTS) $(sfcapd_DEPENDENCIES)
478507 @rm -f sfcapd$(EXEEXT)
479508 $(sfcapd_LINK) $(sfcapd_OBJECTS) $(sfcapd_LDADD) $(LIBS)
493522 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-nf_common.Po@am__quote@
494523 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-nffile.Po@am__quote@
495524 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-nfx.Po@am__quote@
496 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-panonymizer.Po@am__quote@
497 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-rijndael.Po@am__quote@
498525 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-util.Po@am__quote@
499526 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fts_compat.Po@am__quote@
500527 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grammar.Po@am__quote@
503530 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netflow_v5_v7.Po@am__quote@
504531 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netflow_v9.Po@am__quote@
505532 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nf_common.Po@am__quote@
533 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfanon.Po@am__quote@
506534 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-bookkeeper.Po@am__quote@
507535 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-collector.Po@am__quote@
508536 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-expire.Po@am__quote@
518546 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-nfnet.Po@am__quote@
519547 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-nfstatfile.Po@am__quote@
520548 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-nfx.Po@am__quote@
521 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-panonymizer.Po@am__quote@
522549 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-pcap_reader.Po@am__quote@
523 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-rijndael.Po@am__quote@
524550 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-util.Po@am__quote@
525551 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfdump.Po@am__quote@
526552 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfexpire.Po@am__quote@
536562 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfstat.Po@am__quote@
537563 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfstatfile.Po@am__quote@
538564 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftest.Po@am__quote@
565 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-flist.Po@am__quote@
566 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-fts_compat.Po@am__quote@
567 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-grammar.Po@am__quote@
568 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-ipconv.Po@am__quote@
569 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-minilzo.Po@am__quote@
570 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nf_common.Po@am__quote@
571 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nffile.Po@am__quote@
572 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nftrack.Po@am__quote@
573 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nftrack_rrd.Po@am__quote@
574 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nftrack_stat.Po@am__quote@
575 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nftree.Po@am__quote@
576 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-nfx.Po@am__quote@
577 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-scanner.Po@am__quote@
578 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftrack-util.Po@am__quote@
539579 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftree.Po@am__quote@
540580 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfx.Po@am__quote@
541581 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panonymizer.Po@am__quote@
554594 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-nfnet.Po@am__quote@
555595 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-nfstatfile.Po@am__quote@
556596 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-nfx.Po@am__quote@
557 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-panonymizer.Po@am__quote@
558597 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-pcap_reader.Po@am__quote@
559 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-rijndael.Po@am__quote@
560598 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-sfcapd.Po@am__quote@
561599 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-sflow.Po@am__quote@
562600 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-util.Po@am__quote@
604642 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
605643 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -c -o ft2nfdump-nf_common.obj `if test -f 'nf_common.c'; then $(CYGPATH_W) 'nf_common.c'; else $(CYGPATH_W) '$(srcdir)/nf_common.c'; fi`
606644
607 ft2nfdump-panonymizer.o: panonymizer.c
608 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -MT ft2nfdump-panonymizer.o -MD -MP -MF $(DEPDIR)/ft2nfdump-panonymizer.Tpo -c -o ft2nfdump-panonymizer.o `test -f 'panonymizer.c' || echo '$(srcdir)/'`panonymizer.c
609 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ft2nfdump-panonymizer.Tpo $(DEPDIR)/ft2nfdump-panonymizer.Po
610 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panonymizer.c' object='ft2nfdump-panonymizer.o' libtool=no @AMDEPBACKSLASH@
611 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
612 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -c -o ft2nfdump-panonymizer.o `test -f 'panonymizer.c' || echo '$(srcdir)/'`panonymizer.c
613
614 ft2nfdump-panonymizer.obj: panonymizer.c
615 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -MT ft2nfdump-panonymizer.obj -MD -MP -MF $(DEPDIR)/ft2nfdump-panonymizer.Tpo -c -o ft2nfdump-panonymizer.obj `if test -f 'panonymizer.c'; then $(CYGPATH_W) 'panonymizer.c'; else $(CYGPATH_W) '$(srcdir)/panonymizer.c'; fi`
616 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ft2nfdump-panonymizer.Tpo $(DEPDIR)/ft2nfdump-panonymizer.Po
617 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panonymizer.c' object='ft2nfdump-panonymizer.obj' libtool=no @AMDEPBACKSLASH@
618 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
619 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -c -o ft2nfdump-panonymizer.obj `if test -f 'panonymizer.c'; then $(CYGPATH_W) 'panonymizer.c'; else $(CYGPATH_W) '$(srcdir)/panonymizer.c'; fi`
620
621 ft2nfdump-rijndael.o: rijndael.c
622 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -MT ft2nfdump-rijndael.o -MD -MP -MF $(DEPDIR)/ft2nfdump-rijndael.Tpo -c -o ft2nfdump-rijndael.o `test -f 'rijndael.c' || echo '$(srcdir)/'`rijndael.c
623 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ft2nfdump-rijndael.Tpo $(DEPDIR)/ft2nfdump-rijndael.Po
624 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rijndael.c' object='ft2nfdump-rijndael.o' libtool=no @AMDEPBACKSLASH@
625 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
626 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -c -o ft2nfdump-rijndael.o `test -f 'rijndael.c' || echo '$(srcdir)/'`rijndael.c
627
628 ft2nfdump-rijndael.obj: rijndael.c
629 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -MT ft2nfdump-rijndael.obj -MD -MP -MF $(DEPDIR)/ft2nfdump-rijndael.Tpo -c -o ft2nfdump-rijndael.obj `if test -f 'rijndael.c'; then $(CYGPATH_W) 'rijndael.c'; else $(CYGPATH_W) '$(srcdir)/rijndael.c'; fi`
630 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ft2nfdump-rijndael.Tpo $(DEPDIR)/ft2nfdump-rijndael.Po
631 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rijndael.c' object='ft2nfdump-rijndael.obj' libtool=no @AMDEPBACKSLASH@
632 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
633 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -c -o ft2nfdump-rijndael.obj `if test -f 'rijndael.c'; then $(CYGPATH_W) 'rijndael.c'; else $(CYGPATH_W) '$(srcdir)/rijndael.c'; fi`
634
635645 ft2nfdump-minilzo.o: minilzo.c
636646 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ft2nfdump_CFLAGS) $(CFLAGS) -MT ft2nfdump-minilzo.o -MD -MP -MF $(DEPDIR)/ft2nfdump-minilzo.Tpo -c -o ft2nfdump-minilzo.o `test -f 'minilzo.c' || echo '$(srcdir)/'`minilzo.c
637647 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ft2nfdump-minilzo.Tpo $(DEPDIR)/ft2nfdump-minilzo.Po
716726 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
717727 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -c -o nfcapd-nf_common.obj `if test -f 'nf_common.c'; then $(CYGPATH_W) 'nf_common.c'; else $(CYGPATH_W) '$(srcdir)/nf_common.c'; fi`
718728
719 nfcapd-panonymizer.o: panonymizer.c
720 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -MT nfcapd-panonymizer.o -MD -MP -MF $(DEPDIR)/nfcapd-panonymizer.Tpo -c -o nfcapd-panonymizer.o `test -f 'panonymizer.c' || echo '$(srcdir)/'`panonymizer.c
721 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nfcapd-panonymizer.Tpo $(DEPDIR)/nfcapd-panonymizer.Po
722 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panonymizer.c' object='nfcapd-panonymizer.o' libtool=no @AMDEPBACKSLASH@
723 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
724 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -c -o nfcapd-panonymizer.o `test -f 'panonymizer.c' || echo '$(srcdir)/'`panonymizer.c
725
726 nfcapd-panonymizer.obj: panonymizer.c
727 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -MT nfcapd-panonymizer.obj -MD -MP -MF $(DEPDIR)/nfcapd-panonymizer.Tpo -c -o nfcapd-panonymizer.obj `if test -f 'panonymizer.c'; then $(CYGPATH_W) 'panonymizer.c'; else $(CYGPATH_W) '$(srcdir)/panonymizer.c'; fi`
728 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nfcapd-panonymizer.Tpo $(DEPDIR)/nfcapd-panonymizer.Po
729 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panonymizer.c' object='nfcapd-panonymizer.obj' libtool=no @AMDEPBACKSLASH@
730 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
731 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -c -o nfcapd-panonymizer.obj `if test -f 'panonymizer.c'; then $(CYGPATH_W) 'panonymizer.c'; else $(CYGPATH_W) '$(srcdir)/panonymizer.c'; fi`
732
733 nfcapd-rijndael.o: rijndael.c
734 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -MT nfcapd-rijndael.o -MD -MP -MF $(DEPDIR)/nfcapd-rijndael.Tpo -c -o nfcapd-rijndael.o `test -f 'rijndael.c' || echo '$(srcdir)/'`rijndael.c
735 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nfcapd-rijndael.Tpo $(DEPDIR)/nfcapd-rijndael.Po
736 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rijndael.c' object='nfcapd-rijndael.o' libtool=no @AMDEPBACKSLASH@
737 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
738 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -c -o nfcapd-rijndael.o `test -f 'rijndael.c' || echo '$(srcdir)/'`rijndael.c
739
740 nfcapd-rijndael.obj: rijndael.c
741 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -MT nfcapd-rijndael.obj -MD -MP -MF $(DEPDIR)/nfcapd-rijndael.Tpo -c -o nfcapd-rijndael.obj `if test -f 'rijndael.c'; then $(CYGPATH_W) 'rijndael.c'; else $(CYGPATH_W) '$(srcdir)/rijndael.c'; fi`
742 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nfcapd-rijndael.Tpo $(DEPDIR)/nfcapd-rijndael.Po
743 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rijndael.c' object='nfcapd-rijndael.obj' libtool=no @AMDEPBACKSLASH@
744 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
745 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -c -o nfcapd-rijndael.obj `if test -f 'rijndael.c'; then $(CYGPATH_W) 'rijndael.c'; else $(CYGPATH_W) '$(srcdir)/rijndael.c'; fi`
746
747729 nfcapd-util.o: util.c
748730 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -MT nfcapd-util.o -MD -MP -MF $(DEPDIR)/nfcapd-util.Tpo -c -o nfcapd-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
749731 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nfcapd-util.Tpo $(DEPDIR)/nfcapd-util.Po
954936 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
955937 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nfcapd_CFLAGS) $(CFLAGS) -c -o nfcapd-pcap_reader.obj `if test -f 'pcap_reader.c'; then $(CYGPATH_W) 'pcap_reader.c'; else $(CYGPATH_W) '$(srcdir)/pcap_reader.c'; fi`
956938
939 nftrack-nftrack.o: ../extra/nftrack/nftrack.c
940 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftrack.o -MD -MP -MF $(DEPDIR)/nftrack-nftrack.Tpo -c -o nftrack-nftrack.o `test -f '../extra/nftrack/nftrack.c' || echo '$(srcdir)/'`../extra/nftrack/nftrack.c
941 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftrack.Tpo $(DEPDIR)/nftrack-nftrack.Po
942 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../extra/nftrack/nftrack.c' object='nftrack-nftrack.o' libtool=no @AMDEPBACKSLASH@
943 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
944 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftrack.o `test -f '../extra/nftrack/nftrack.c' || echo '$(srcdir)/'`../extra/nftrack/nftrack.c
945
946 nftrack-nftrack.obj: ../extra/nftrack/nftrack.c
947 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftrack.obj -MD -MP -MF $(DEPDIR)/nftrack-nftrack.Tpo -c -o nftrack-nftrack.obj `if test -f '../extra/nftrack/nftrack.c'; then $(CYGPATH_W) '../extra/nftrack/nftrack.c'; else $(CYGPATH_W) '$(srcdir)/../extra/nftrack/nftrack.c'; fi`
948 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftrack.Tpo $(DEPDIR)/nftrack-nftrack.Po
949 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../extra/nftrack/nftrack.c' object='nftrack-nftrack.obj' libtool=no @AMDEPBACKSLASH@
950 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
951 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftrack.obj `if test -f '../extra/nftrack/nftrack.c'; then $(CYGPATH_W) '../extra/nftrack/nftrack.c'; else $(CYGPATH_W) '$(srcdir)/../extra/nftrack/nftrack.c'; fi`
952
953 nftrack-nftrack_rrd.o: ../extra/nftrack/nftrack_rrd.c
954 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftrack_rrd.o -MD -MP -MF $(DEPDIR)/nftrack-nftrack_rrd.Tpo -c -o nftrack-nftrack_rrd.o `test -f '../extra/nftrack/nftrack_rrd.c' || echo '$(srcdir)/'`../extra/nftrack/nftrack_rrd.c
955 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftrack_rrd.Tpo $(DEPDIR)/nftrack-nftrack_rrd.Po
956 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../extra/nftrack/nftrack_rrd.c' object='nftrack-nftrack_rrd.o' libtool=no @AMDEPBACKSLASH@
957 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
958 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftrack_rrd.o `test -f '../extra/nftrack/nftrack_rrd.c' || echo '$(srcdir)/'`../extra/nftrack/nftrack_rrd.c
959
960 nftrack-nftrack_rrd.obj: ../extra/nftrack/nftrack_rrd.c
961 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftrack_rrd.obj -MD -MP -MF $(DEPDIR)/nftrack-nftrack_rrd.Tpo -c -o nftrack-nftrack_rrd.obj `if test -f '../extra/nftrack/nftrack_rrd.c'; then $(CYGPATH_W) '../extra/nftrack/nftrack_rrd.c'; else $(CYGPATH_W) '$(srcdir)/../extra/nftrack/nftrack_rrd.c'; fi`
962 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftrack_rrd.Tpo $(DEPDIR)/nftrack-nftrack_rrd.Po
963 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../extra/nftrack/nftrack_rrd.c' object='nftrack-nftrack_rrd.obj' libtool=no @AMDEPBACKSLASH@
964 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
965 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftrack_rrd.obj `if test -f '../extra/nftrack/nftrack_rrd.c'; then $(CYGPATH_W) '../extra/nftrack/nftrack_rrd.c'; else $(CYGPATH_W) '$(srcdir)/../extra/nftrack/nftrack_rrd.c'; fi`
966
967 nftrack-nftrack_stat.o: ../extra/nftrack/nftrack_stat.c
968 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftrack_stat.o -MD -MP -MF $(DEPDIR)/nftrack-nftrack_stat.Tpo -c -o nftrack-nftrack_stat.o `test -f '../extra/nftrack/nftrack_stat.c' || echo '$(srcdir)/'`../extra/nftrack/nftrack_stat.c
969 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftrack_stat.Tpo $(DEPDIR)/nftrack-nftrack_stat.Po
970 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../extra/nftrack/nftrack_stat.c' object='nftrack-nftrack_stat.o' libtool=no @AMDEPBACKSLASH@
971 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
972 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftrack_stat.o `test -f '../extra/nftrack/nftrack_stat.c' || echo '$(srcdir)/'`../extra/nftrack/nftrack_stat.c
973
974 nftrack-nftrack_stat.obj: ../extra/nftrack/nftrack_stat.c
975 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftrack_stat.obj -MD -MP -MF $(DEPDIR)/nftrack-nftrack_stat.Tpo -c -o nftrack-nftrack_stat.obj `if test -f '../extra/nftrack/nftrack_stat.c'; then $(CYGPATH_W) '../extra/nftrack/nftrack_stat.c'; else $(CYGPATH_W) '$(srcdir)/../extra/nftrack/nftrack_stat.c'; fi`
976 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftrack_stat.Tpo $(DEPDIR)/nftrack-nftrack_stat.Po
977 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../extra/nftrack/nftrack_stat.c' object='nftrack-nftrack_stat.obj' libtool=no @AMDEPBACKSLASH@
978 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
979 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftrack_stat.obj `if test -f '../extra/nftrack/nftrack_stat.c'; then $(CYGPATH_W) '../extra/nftrack/nftrack_stat.c'; else $(CYGPATH_W) '$(srcdir)/../extra/nftrack/nftrack_stat.c'; fi`
980
981 nftrack-nf_common.o: nf_common.c
982 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nf_common.o -MD -MP -MF $(DEPDIR)/nftrack-nf_common.Tpo -c -o nftrack-nf_common.o `test -f 'nf_common.c' || echo '$(srcdir)/'`nf_common.c
983 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nf_common.Tpo $(DEPDIR)/nftrack-nf_common.Po
984 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nf_common.c' object='nftrack-nf_common.o' libtool=no @AMDEPBACKSLASH@
985 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
986 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nf_common.o `test -f 'nf_common.c' || echo '$(srcdir)/'`nf_common.c
987
988 nftrack-nf_common.obj: nf_common.c
989 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nf_common.obj -MD -MP -MF $(DEPDIR)/nftrack-nf_common.Tpo -c -o nftrack-nf_common.obj `if test -f 'nf_common.c'; then $(CYGPATH_W) 'nf_common.c'; else $(CYGPATH_W) '$(srcdir)/nf_common.c'; fi`
990 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nf_common.Tpo $(DEPDIR)/nftrack-nf_common.Po
991 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nf_common.c' object='nftrack-nf_common.obj' libtool=no @AMDEPBACKSLASH@
992 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
993 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nf_common.obj `if test -f 'nf_common.c'; then $(CYGPATH_W) 'nf_common.c'; else $(CYGPATH_W) '$(srcdir)/nf_common.c'; fi`
994
995 nftrack-util.o: util.c
996 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-util.o -MD -MP -MF $(DEPDIR)/nftrack-util.Tpo -c -o nftrack-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
997 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-util.Tpo $(DEPDIR)/nftrack-util.Po
998 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='nftrack-util.o' libtool=no @AMDEPBACKSLASH@
999 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1000 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
1001
1002 nftrack-util.obj: util.c
1003 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-util.obj -MD -MP -MF $(DEPDIR)/nftrack-util.Tpo -c -o nftrack-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi`
1004 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-util.Tpo $(DEPDIR)/nftrack-util.Po
1005 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='nftrack-util.obj' libtool=no @AMDEPBACKSLASH@
1006 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1007 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi`
1008
1009 nftrack-minilzo.o: minilzo.c
1010 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-minilzo.o -MD -MP -MF $(DEPDIR)/nftrack-minilzo.Tpo -c -o nftrack-minilzo.o `test -f 'minilzo.c' || echo '$(srcdir)/'`minilzo.c
1011 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-minilzo.Tpo $(DEPDIR)/nftrack-minilzo.Po
1012 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minilzo.c' object='nftrack-minilzo.o' libtool=no @AMDEPBACKSLASH@
1013 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1014 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-minilzo.o `test -f 'minilzo.c' || echo '$(srcdir)/'`minilzo.c
1015
1016 nftrack-minilzo.obj: minilzo.c
1017 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-minilzo.obj -MD -MP -MF $(DEPDIR)/nftrack-minilzo.Tpo -c -o nftrack-minilzo.obj `if test -f 'minilzo.c'; then $(CYGPATH_W) 'minilzo.c'; else $(CYGPATH_W) '$(srcdir)/minilzo.c'; fi`
1018 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-minilzo.Tpo $(DEPDIR)/nftrack-minilzo.Po
1019 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minilzo.c' object='nftrack-minilzo.obj' libtool=no @AMDEPBACKSLASH@
1020 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1021 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-minilzo.obj `if test -f 'minilzo.c'; then $(CYGPATH_W) 'minilzo.c'; else $(CYGPATH_W) '$(srcdir)/minilzo.c'; fi`
1022
1023 nftrack-nffile.o: nffile.c
1024 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nffile.o -MD -MP -MF $(DEPDIR)/nftrack-nffile.Tpo -c -o nftrack-nffile.o `test -f 'nffile.c' || echo '$(srcdir)/'`nffile.c
1025 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nffile.Tpo $(DEPDIR)/nftrack-nffile.Po
1026 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nffile.c' object='nftrack-nffile.o' libtool=no @AMDEPBACKSLASH@
1027 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1028 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nffile.o `test -f 'nffile.c' || echo '$(srcdir)/'`nffile.c
1029
1030 nftrack-nffile.obj: nffile.c
1031 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nffile.obj -MD -MP -MF $(DEPDIR)/nftrack-nffile.Tpo -c -o nftrack-nffile.obj `if test -f 'nffile.c'; then $(CYGPATH_W) 'nffile.c'; else $(CYGPATH_W) '$(srcdir)/nffile.c'; fi`
1032 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nffile.Tpo $(DEPDIR)/nftrack-nffile.Po
1033 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nffile.c' object='nftrack-nffile.obj' libtool=no @AMDEPBACKSLASH@
1034 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1035 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nffile.obj `if test -f 'nffile.c'; then $(CYGPATH_W) 'nffile.c'; else $(CYGPATH_W) '$(srcdir)/nffile.c'; fi`
1036
1037 nftrack-nfx.o: nfx.c
1038 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nfx.o -MD -MP -MF $(DEPDIR)/nftrack-nfx.Tpo -c -o nftrack-nfx.o `test -f 'nfx.c' || echo '$(srcdir)/'`nfx.c
1039 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nfx.Tpo $(DEPDIR)/nftrack-nfx.Po
1040 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nfx.c' object='nftrack-nfx.o' libtool=no @AMDEPBACKSLASH@
1041 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1042 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nfx.o `test -f 'nfx.c' || echo '$(srcdir)/'`nfx.c
1043
1044 nftrack-nfx.obj: nfx.c
1045 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nfx.obj -MD -MP -MF $(DEPDIR)/nftrack-nfx.Tpo -c -o nftrack-nfx.obj `if test -f 'nfx.c'; then $(CYGPATH_W) 'nfx.c'; else $(CYGPATH_W) '$(srcdir)/nfx.c'; fi`
1046 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nfx.Tpo $(DEPDIR)/nftrack-nfx.Po
1047 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nfx.c' object='nftrack-nfx.obj' libtool=no @AMDEPBACKSLASH@
1048 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1049 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nfx.obj `if test -f 'nfx.c'; then $(CYGPATH_W) 'nfx.c'; else $(CYGPATH_W) '$(srcdir)/nfx.c'; fi`
1050
1051 nftrack-flist.o: flist.c
1052 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-flist.o -MD -MP -MF $(DEPDIR)/nftrack-flist.Tpo -c -o nftrack-flist.o `test -f 'flist.c' || echo '$(srcdir)/'`flist.c
1053 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-flist.Tpo $(DEPDIR)/nftrack-flist.Po
1054 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='flist.c' object='nftrack-flist.o' libtool=no @AMDEPBACKSLASH@
1055 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1056 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-flist.o `test -f 'flist.c' || echo '$(srcdir)/'`flist.c
1057
1058 nftrack-flist.obj: flist.c
1059 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-flist.obj -MD -MP -MF $(DEPDIR)/nftrack-flist.Tpo -c -o nftrack-flist.obj `if test -f 'flist.c'; then $(CYGPATH_W) 'flist.c'; else $(CYGPATH_W) '$(srcdir)/flist.c'; fi`
1060 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-flist.Tpo $(DEPDIR)/nftrack-flist.Po
1061 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='flist.c' object='nftrack-flist.obj' libtool=no @AMDEPBACKSLASH@
1062 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1063 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-flist.obj `if test -f 'flist.c'; then $(CYGPATH_W) 'flist.c'; else $(CYGPATH_W) '$(srcdir)/flist.c'; fi`
1064
1065 nftrack-fts_compat.o: fts_compat.c
1066 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-fts_compat.o -MD -MP -MF $(DEPDIR)/nftrack-fts_compat.Tpo -c -o nftrack-fts_compat.o `test -f 'fts_compat.c' || echo '$(srcdir)/'`fts_compat.c
1067 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-fts_compat.Tpo $(DEPDIR)/nftrack-fts_compat.Po
1068 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fts_compat.c' object='nftrack-fts_compat.o' libtool=no @AMDEPBACKSLASH@
1069 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1070 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-fts_compat.o `test -f 'fts_compat.c' || echo '$(srcdir)/'`fts_compat.c
1071
1072 nftrack-fts_compat.obj: fts_compat.c
1073 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-fts_compat.obj -MD -MP -MF $(DEPDIR)/nftrack-fts_compat.Tpo -c -o nftrack-fts_compat.obj `if test -f 'fts_compat.c'; then $(CYGPATH_W) 'fts_compat.c'; else $(CYGPATH_W) '$(srcdir)/fts_compat.c'; fi`
1074 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-fts_compat.Tpo $(DEPDIR)/nftrack-fts_compat.Po
1075 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fts_compat.c' object='nftrack-fts_compat.obj' libtool=no @AMDEPBACKSLASH@
1076 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1077 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-fts_compat.obj `if test -f 'fts_compat.c'; then $(CYGPATH_W) 'fts_compat.c'; else $(CYGPATH_W) '$(srcdir)/fts_compat.c'; fi`
1078
1079 nftrack-grammar.o: grammar.c
1080 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-grammar.o -MD -MP -MF $(DEPDIR)/nftrack-grammar.Tpo -c -o nftrack-grammar.o `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c
1081 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-grammar.Tpo $(DEPDIR)/nftrack-grammar.Po
1082 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='grammar.c' object='nftrack-grammar.o' libtool=no @AMDEPBACKSLASH@
1083 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1084 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-grammar.o `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c
1085
1086 nftrack-grammar.obj: grammar.c
1087 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-grammar.obj -MD -MP -MF $(DEPDIR)/nftrack-grammar.Tpo -c -o nftrack-grammar.obj `if test -f 'grammar.c'; then $(CYGPATH_W) 'grammar.c'; else $(CYGPATH_W) '$(srcdir)/grammar.c'; fi`
1088 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-grammar.Tpo $(DEPDIR)/nftrack-grammar.Po
1089 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='grammar.c' object='nftrack-grammar.obj' libtool=no @AMDEPBACKSLASH@
1090 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1091 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-grammar.obj `if test -f 'grammar.c'; then $(CYGPATH_W) 'grammar.c'; else $(CYGPATH_W) '$(srcdir)/grammar.c'; fi`
1092
1093 nftrack-scanner.o: scanner.c
1094 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-scanner.o -MD -MP -MF $(DEPDIR)/nftrack-scanner.Tpo -c -o nftrack-scanner.o `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c
1095 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-scanner.Tpo $(DEPDIR)/nftrack-scanner.Po
1096 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanner.c' object='nftrack-scanner.o' libtool=no @AMDEPBACKSLASH@
1097 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1098 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-scanner.o `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c
1099
1100 nftrack-scanner.obj: scanner.c
1101 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-scanner.obj -MD -MP -MF $(DEPDIR)/nftrack-scanner.Tpo -c -o nftrack-scanner.obj `if test -f 'scanner.c'; then $(CYGPATH_W) 'scanner.c'; else $(CYGPATH_W) '$(srcdir)/scanner.c'; fi`
1102 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-scanner.Tpo $(DEPDIR)/nftrack-scanner.Po
1103 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanner.c' object='nftrack-scanner.obj' libtool=no @AMDEPBACKSLASH@
1104 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1105 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-scanner.obj `if test -f 'scanner.c'; then $(CYGPATH_W) 'scanner.c'; else $(CYGPATH_W) '$(srcdir)/scanner.c'; fi`
1106
1107 nftrack-nftree.o: nftree.c
1108 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftree.o -MD -MP -MF $(DEPDIR)/nftrack-nftree.Tpo -c -o nftrack-nftree.o `test -f 'nftree.c' || echo '$(srcdir)/'`nftree.c
1109 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftree.Tpo $(DEPDIR)/nftrack-nftree.Po
1110 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nftree.c' object='nftrack-nftree.o' libtool=no @AMDEPBACKSLASH@
1111 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1112 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftree.o `test -f 'nftree.c' || echo '$(srcdir)/'`nftree.c
1113
1114 nftrack-nftree.obj: nftree.c
1115 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-nftree.obj -MD -MP -MF $(DEPDIR)/nftrack-nftree.Tpo -c -o nftrack-nftree.obj `if test -f 'nftree.c'; then $(CYGPATH_W) 'nftree.c'; else $(CYGPATH_W) '$(srcdir)/nftree.c'; fi`
1116 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-nftree.Tpo $(DEPDIR)/nftrack-nftree.Po
1117 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nftree.c' object='nftrack-nftree.obj' libtool=no @AMDEPBACKSLASH@
1118 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1119 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-nftree.obj `if test -f 'nftree.c'; then $(CYGPATH_W) 'nftree.c'; else $(CYGPATH_W) '$(srcdir)/nftree.c'; fi`
1120
1121 nftrack-ipconv.o: ipconv.c
1122 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-ipconv.o -MD -MP -MF $(DEPDIR)/nftrack-ipconv.Tpo -c -o nftrack-ipconv.o `test -f 'ipconv.c' || echo '$(srcdir)/'`ipconv.c
1123 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-ipconv.Tpo $(DEPDIR)/nftrack-ipconv.Po
1124 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ipconv.c' object='nftrack-ipconv.o' libtool=no @AMDEPBACKSLASH@
1125 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1126 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-ipconv.o `test -f 'ipconv.c' || echo '$(srcdir)/'`ipconv.c
1127
1128 nftrack-ipconv.obj: ipconv.c
1129 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -MT nftrack-ipconv.obj -MD -MP -MF $(DEPDIR)/nftrack-ipconv.Tpo -c -o nftrack-ipconv.obj `if test -f 'ipconv.c'; then $(CYGPATH_W) 'ipconv.c'; else $(CYGPATH_W) '$(srcdir)/ipconv.c'; fi`
1130 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nftrack-ipconv.Tpo $(DEPDIR)/nftrack-ipconv.Po
1131 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ipconv.c' object='nftrack-ipconv.obj' libtool=no @AMDEPBACKSLASH@
1132 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1133 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nftrack_CFLAGS) $(CFLAGS) -c -o nftrack-ipconv.obj `if test -f 'ipconv.c'; then $(CYGPATH_W) 'ipconv.c'; else $(CYGPATH_W) '$(srcdir)/ipconv.c'; fi`
1134
9571135 sfcapd-sfcapd.o: sfcapd.c
9581136 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -MT sfcapd-sfcapd.o -MD -MP -MF $(DEPDIR)/sfcapd-sfcapd.Tpo -c -o sfcapd-sfcapd.o `test -f 'sfcapd.c' || echo '$(srcdir)/'`sfcapd.c
9591137 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sfcapd-sfcapd.Tpo $(DEPDIR)/sfcapd-sfcapd.Po
9951173 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nf_common.c' object='sfcapd-nf_common.obj' libtool=no @AMDEPBACKSLASH@
9961174 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
9971175 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -c -o sfcapd-nf_common.obj `if test -f 'nf_common.c'; then $(CYGPATH_W) 'nf_common.c'; else $(CYGPATH_W) '$(srcdir)/nf_common.c'; fi`
998
999 sfcapd-panonymizer.o: panonymizer.c
1000 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -MT sfcapd-panonymizer.o -MD -MP -MF $(DEPDIR)/sfcapd-panonymizer.Tpo -c -o sfcapd-panonymizer.o `test -f 'panonymizer.c' || echo '$(srcdir)/'`panonymizer.c
1001 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sfcapd-panonymizer.Tpo $(DEPDIR)/sfcapd-panonymizer.Po
1002 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panonymizer.c' object='sfcapd-panonymizer.o' libtool=no @AMDEPBACKSLASH@
1003 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1004 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -c -o sfcapd-panonymizer.o `test -f 'panonymizer.c' || echo '$(srcdir)/'`panonymizer.c
1005
1006 sfcapd-panonymizer.obj: panonymizer.c
1007 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -MT sfcapd-panonymizer.obj -MD -MP -MF $(DEPDIR)/sfcapd-panonymizer.Tpo -c -o sfcapd-panonymizer.obj `if test -f 'panonymizer.c'; then $(CYGPATH_W) 'panonymizer.c'; else $(CYGPATH_W) '$(srcdir)/panonymizer.c'; fi`
1008 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sfcapd-panonymizer.Tpo $(DEPDIR)/sfcapd-panonymizer.Po
1009 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='panonymizer.c' object='sfcapd-panonymizer.obj' libtool=no @AMDEPBACKSLASH@
1010 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1011 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -c -o sfcapd-panonymizer.obj `if test -f 'panonymizer.c'; then $(CYGPATH_W) 'panonymizer.c'; else $(CYGPATH_W) '$(srcdir)/panonymizer.c'; fi`
1012
1013 sfcapd-rijndael.o: rijndael.c
1014 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -MT sfcapd-rijndael.o -MD -MP -MF $(DEPDIR)/sfcapd-rijndael.Tpo -c -o sfcapd-rijndael.o `test -f 'rijndael.c' || echo '$(srcdir)/'`rijndael.c
1015 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sfcapd-rijndael.Tpo $(DEPDIR)/sfcapd-rijndael.Po
1016 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rijndael.c' object='sfcapd-rijndael.o' libtool=no @AMDEPBACKSLASH@
1017 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1018 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -c -o sfcapd-rijndael.o `test -f 'rijndael.c' || echo '$(srcdir)/'`rijndael.c
1019
1020 sfcapd-rijndael.obj: rijndael.c
1021 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -MT sfcapd-rijndael.obj -MD -MP -MF $(DEPDIR)/sfcapd-rijndael.Tpo -c -o sfcapd-rijndael.obj `if test -f 'rijndael.c'; then $(CYGPATH_W) 'rijndael.c'; else $(CYGPATH_W) '$(srcdir)/rijndael.c'; fi`
1022 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sfcapd-rijndael.Tpo $(DEPDIR)/sfcapd-rijndael.Po
1023 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rijndael.c' object='sfcapd-rijndael.obj' libtool=no @AMDEPBACKSLASH@
1024 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1025 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -c -o sfcapd-rijndael.obj `if test -f 'rijndael.c'; then $(CYGPATH_W) 'rijndael.c'; else $(CYGPATH_W) '$(srcdir)/rijndael.c'; fi`
10261176
10271177 sfcapd-util.o: util.c
10281178 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sfcapd_CFLAGS) $(CFLAGS) -MT sfcapd-util.o -MD -MP -MF $(DEPDIR)/sfcapd-util.Tpo -c -o sfcapd-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
296296 }
297297
298298 // sanity check for buffer size
299 bsize = (pointer_addr_t)fs->nffile.writeto - (pointer_addr_t)fs->nffile.block_header;
299 bsize = (pointer_addr_t)fs->nffile->writeto - (pointer_addr_t)fs->nffile->block_header;
300300 // at least space for the map size is required
301301 if ( bsize >= (BUFFSIZE - map->size ) ) {
302302 syslog(LOG_WARNING,"AddExtensionMap: Outputbuffer full. Flush buffer but have to skip records.");
303303 return 0;
304304 }
305305
306 if ( !CheckBufferSpace(&(fs->nffile), map->size) ) {
306 if ( !CheckBufferSpace(fs->nffile, map->size) ) {
307307 // fishy! - should never happen. maybe disk full?
308308 syslog(LOG_ERR,"AddExtensionMap: output buffer size error. Abort record processing");
309309 return 0;
310310 }
311311
312 memcpy(fs->nffile.writeto, (void *)map, map->size);
313 fs->nffile.writeto += map->size;
314
315 fs->nffile.block_header->size += map->size;
316 fs->nffile.block_header->NumRecords++;
312 memcpy(fs->nffile->writeto, (void *)map, map->size);
313 fs->nffile->writeto += map->size;
314
315 fs->nffile->block_header->size += map->size;
316 fs->nffile->block_header->NumRecords++;
317317
318318 return 1;
319319
325325 for ( i=0; i<fs->extension_map_list.next_free; i++ ) {
326326 extension_map_t *map = fs->extension_map_list.maps[i];
327327
328 if ( !CheckBufferSpace(&(fs->nffile), map->size) ) {
328 if ( !CheckBufferSpace(fs->nffile, map->size) ) {
329329 // fishy! - should never happen. maybe disk full?
330330 syslog(LOG_ERR,"FlushExtensionMaps: output buffer size error. Abort record processing");
331331 return;
332332 }
333333
334 memcpy(fs->nffile.writeto, (void *)map, map->size);
335
336 fs->nffile.writeto += map->size;
337 fs->nffile.block_header->NumRecords++;
338 fs->nffile.block_header->size += map->size;
334 memcpy(fs->nffile->writeto, (void *)map, map->size);
335
336 fs->nffile->writeto += map->size;
337 fs->nffile->block_header->NumRecords++;
338 fs->nffile->block_header->size += map->size;
339339 }
340340
341341 } // End of FlushExtensionMaps
8989 // all about data storage
9090 char *datadir; // where to store data for this source
9191 char *current; // current file name - typically nfcad.current.pid
92 nffile_t nffile; // the writing file handle
92 nffile_t *nffile; // the writing file handle
9393
9494 // statistical data per source
9595 stat_record_t stat_record;
222222
223223 #define NUM_PTR 16
224224
225 static char *first_file, *last_file, current_file[255];
225 static char *first_file, *last_file;
226 static char *current_file = NULL;
226227 static uint32_t twin_first, twin_last;
227228 static stringlist_t source_dirs, file_list;
228229
993994 // stdin ( current = 0 ) is not closed
994995 if ( current > 0 ) {
995996 close(current);
996 current_file[0] = '\0';
997 current_file = NULL;
997998 }
998999
9991000 // no or no more files available
10001001 if ( file_list.num_strings == cnt ) {
10011002 if ( stat_record )
10021003 *stat_record = NULL;
1004 current_file = NULL;
10031005 return EMPTY_LIST;
10041006 }
10051007
10111013
10121014 while ( cnt < file_list.num_strings ) {
10131015 fd = OpenFile(file_list.list[cnt], &stat_ptr, &error); // Open the file
1016 current_file = file_list.list[cnt];
10141017 cnt++;
10151018
10161019 // stdin
10181021 if ( stat_record )
10191022 *stat_record = NULL;
10201023 CurrentIdent = "none";
1024 current_file = NULL;
10211025 return fd;
10221026 }
10231027
10351039 if ( stat_record )
10361040 *stat_record = NULL;
10371041
1042 current_file = NULL;
10381043 return EMPTY_LIST;
10391044
10401045 } // End of GetNextFile
193193 struct ftver ftv;
194194 char *rec;
195195 // nfdump variables
196 nffile_t nffile;
196 nffile_t *nffile;
197197 master_record_t record;
198 file_header_t *file_header;
199
198 char *s;
200199 uint32_t cnt;
201 size_t len;
202
203 // Init file record
204 nffile.block_header = NULL;
205 nffile.writeto = NULL;
206 nffile.file_blocks = 0;
207 nffile.compress = 0;
208 nffile.wfd = 0;
209
210
211 nffile.block_header = (data_block_header_t *)malloc(sizeof(data_block_header_t) + BUFFSIZE);
212 if ( !nffile.block_header ) {
213 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror (errno));
214 exit(255);
215 }
216 nffile.block_header->NumRecords = 0;
217 nffile.block_header->pad = 0;
218 nffile.block_header->size = 0;
219 nffile.block_header->id = DATA_BLOCK_TYPE_2;
220 nffile.wfd = STDOUT_FILENO;
221 nffile.writeto = (void *)((pointer_addr_t)nffile.block_header + sizeof(data_block_header_t));
222
223 // initialize file header and dummy stat record
224 len = sizeof(file_header_t) + sizeof(stat_record_t);
225 file_header = (file_header_t *)malloc(len);
226 if ( !file_header ) {
227 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror (errno));
228 exit(255);
229 }
230
231 // prepare file header
232 memset((void *)file_header, 0, len);
233 file_header->magic = MAGIC;
234 file_header->version = LAYOUT_VERSION_1;
235 strncpy(file_header->ident, "none", IDENT_SIZE);
236
237 // write file header
238 write(STDOUT_FILENO, (void *)file_header, len) ;
239
240 // put extension map into buffer
241 memcpy(nffile.writeto, (void *)extension_info->map, extension_info->map->size);
242 nffile.writeto += extension_info->map->size;
243 nffile.block_header->NumRecords = 1;
244 nffile.block_header->size = extension_info->map->size;
245
200
201 nffile = OpenNewFile( "-", NULL, 0, 0, &s);
202 if ( !nffile ) {
203 fprintf(stderr, "%s\n", s);
204 return 1;
205 }
206
207 AppendToBuffer(nffile, (void *)extension_info->map, extension_info->map->size);
208
246209 ftio_get_ver(ftio, &ftv);
247210 fts3rec_compute_offsets(&fo, &ftv);
248211
317280 i++;
318281 }
319282
320
321 PackRecord(&record, &nffile);
283 PackRecord(&record, nffile);
322284
323285 if ( extended ) {
324286 char *string;
325 format_file_block_record(&record, &string, 0, 0);
287 format_file_block_record(&record, &string, 0);
326288 fprintf(stderr, "%s\n", string);
327289 }
328290
333295 } /* while */
334296
335297 // write the last records in buffer
336 if ( nffile.block_header->NumRecords ) {
337 if ( WriteBlock(&nffile) <= 0 ) {
298 if ( nffile->block_header->NumRecords ) {
299 if ( WriteBlock(nffile) <= 0 ) {
338300 fprintf(stderr, "Failed to write output buffer: '%s'" , strerror(errno));
339301 }
340302 }
341303
342304 free((void *)extension_info->map);
343305 free((void *)extension_info);
344 free((void *)nffile.block_header);
345 free((void *)file_header);
306 DisposeFile(nffile);
346307
347308 return 0;
348309
(No changes)
(No changes)
564564 RB_INIT(root);
565565
566566 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
567 if ( node->value > 65535 ) {
568 yyerror("Port outside of range 0..65535");
569 YYABORT;
570 }
567571 if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
568572 yyerror("malloc() error");
569573 YYABORT;
669673
670674 | dqual AS comp NUMBER {
671675 $$.direction = $1.direction;
672 if ( $4 > 0x7FFFFFFF || $4 < 0 ) {
676 if ( $4 > 0xfFFFFFFF || $4 < 0 ) {
673677 yyerror("AS number of range");
674678 YYABORT;
675679 }
729733 RB_INIT(root);
730734
731735 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
732
736 if ( node->value > 0xFFFFFFFFLL ) {
737 yyerror("AS number of range");
738 YYABORT;
739 }
733740 if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
734741 yyerror("malloc() error");
735742 YYABORT;
10251032 }
10261033
10271034 | dqual IF NUMBER {
1028 if ( $3 > 65535 ) {
1029 yyerror("Input interface number must be 0..65535");
1035 if ( $3 > 0xffffffffLL ) {
1036 yyerror("Input interface number must 0..2^32");
10301037 YYABORT;
10311038 }
10321039
15621569 ullist: NUMBER {
15631570 struct ULongListNode *node;
15641571
1565 if ( $1 > 65535 ) {
1566 yyerror("Value outside of range 0..65535");
1567 YYABORT;
1568 }
15691572 ULongtree_t *root = malloc(sizeof(ULongtree_t));
15701573
15711574 if ( root == NULL) {
15861589 | ullist NUMBER {
15871590 struct ULongListNode *node;
15881591
1589 if ( $2 > 65535 ) {
1590 yyerror("Value outside of range 0..65535");
1591 YYABORT;
1592 }
15931592 if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
15941593 yyerror("malloc() error");
15951594 YYABORT;
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: grammar.y 100 2008-08-15 11:36:21Z peter $
33 *
34 * $LastChangedRevision: 100 $
35 *
36 *
37 *
38 */
39
40 %{
41
42 #include "config.h"
43
44 #include <stdio.h>
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #include <netinet/in.h>
48 #include <string.h>
49 #include <stdlib.h>
50 #include <ctype.h>
51
52 #ifdef HAVE_STDINT_H
53 #include <stdint.h>
54 #endif
55
56 #include "nf_common.h"
57 #include "rbtree.h"
58 #include "nfdump.h"
59 #include "nffile.h"
60 #include "nftree.h"
61 #include "ipconv.h"
62 #include "util.h"
63
64 /*
65 * function prototypes
66 */
67 static void yyerror(char *msg);
68
69 static uint32_t ChainHosts(uint64_t *hostlist, int num_records, int type);
70
71 static uint64_t VerifyMac(char *s);
72
73 enum { DIR_UNSPEC = 1, SOURCE, DESTINATION, SOURCE_AND_DESTINATION, SOURCE_OR_DESTINATION, DIR_IN, DIR_OUT, IN_SRC, IN_DST, OUT_SRC, OUT_DST };
74
75 /* var defs */
76 extern int lineno;
77 extern char *yytext;
78 extern uint64_t *IPstack;
79 extern uint32_t StartNode;
80 extern uint16_t Extended;
81 extern int (*FilterEngine)(uint32_t *);
82 extern char *FilterFilename;
83
84 static uint32_t num_ip;
85
86 #define MPLSMAX 0x00ffffff
87 %}
88
89 %union {
90 uint64_t value;
91 char *s;
92 FilterParam_t param;
93 void *list;
94 }
95
96 %token ANY IP IF MAC MPLS TOS DIR FLAGS PROTO MASK HOSTNAME NET PORT FWDSTAT IN OUT SRC DST EQ LT GT
97 %token NUMBER STRING IDENT ALPHA_FLAGS PROTOSTR PORTNUM ICMP_TYPE ICMP_CODE ENGINE_TYPE ENGINE_ID AS PACKETS BYTES FLOWS
98 %token PPS BPS BPP DURATION
99 %token IPV4 IPV6 NEXTHOP BGPNEXTHOP ROUTER VLAN
100 %token NOT END
101 %type <value> expr NUMBER PORTNUM ICMP_TYPE ICMP_CODE
102 %type <s> STRING IDENT ALPHA_FLAGS PROTOSTR
103 %type <param> dqual term comp
104 %type <list> iplist ullist
105
106 %left '+' OR
107 %left '*' AND
108 %left NEGATE
109
110 %%
111 prog: /* empty */
112 | expr {
113 StartNode = $1;
114 }
115 ;
116
117 term: ANY { /* this is an unconditionally true expression, as a filter applies in any case */
118 $$.self = NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL );
119 }
120
121 | IDENT STRING {
122 if ( !ScreenIdentString($2) ) {
123 yyerror("Illegal ident string");
124 YYABORT;
125 }
126
127 uint32_t index = AddIdent($2);
128 $$.self = NewBlock(0, 0, index, CMP_IDENT, FUNC_NONE, NULL );
129 }
130
131 | IPV4 {
132 $$.self = NewBlock(OffsetRecordFlags, (1LL << ShiftRecordFlags) & MaskRecordFlags,
133 (0LL << ShiftRecordFlags) & MaskRecordFlags, CMP_EQ, FUNC_NONE, NULL);
134 }
135
136 | IPV6 {
137 $$.self = NewBlock(OffsetRecordFlags, (1LL << ShiftRecordFlags) & MaskRecordFlags,
138 (1LL << ShiftRecordFlags) & MaskRecordFlags, CMP_EQ, FUNC_NONE, NULL);
139 }
140
141 | PROTO NUMBER {
142 int64_t proto;
143 proto = $2;
144
145 if ( proto > 255 ) {
146 yyerror("Protocol number > 255");
147 YYABORT;
148 }
149 if ( proto < 0 ) {
150 yyerror("Unknown protocol");
151 YYABORT;
152 }
153 $$.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL);
154
155 }
156
157 | PROTO STRING {
158 int64_t proto;
159 proto = Proto_num($2);
160
161 if ( proto > 255 ) {
162 yyerror("Protocol number > 255");
163 YYABORT;
164 }
165 if ( proto < 0 ) {
166 yyerror("Unknown protocol");
167 YYABORT;
168 }
169 $$.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL);
170 }
171
172 | dqual PACKETS comp NUMBER {
173
174 switch ( $$.direction ) {
175 case DIR_UNSPEC:
176 case DIR_IN:
177 $$.self = NewBlock(OffsetPackets, MaskPackets, $4, $3.comp, FUNC_NONE, NULL);
178 break;
179 case DIR_OUT:
180 $$.self = NewBlock(OffsetOutPackets, MaskPackets, $4, $3.comp, FUNC_NONE, NULL);
181 break;
182 case SOURCE:
183 case DESTINATION:
184 case SOURCE_OR_DESTINATION:
185 case SOURCE_AND_DESTINATION:
186 case IN_SRC:
187 case IN_DST:
188 case OUT_SRC:
189 case OUT_DST:
190 yyerror("This token is not expected here!");
191 YYABORT;
192 break;
193 default:
194 /* should never happen */
195 yyerror("Internal parser error");
196 YYABORT;
197 } // End of switch
198
199 }
200
201 | dqual BYTES comp NUMBER {
202
203 switch ( $$.direction ) {
204 case DIR_UNSPEC:
205 case DIR_IN:
206 $$.self = NewBlock(OffsetBytes, MaskBytes, $4, $3.comp, FUNC_NONE, NULL);
207 break;
208 case DIR_OUT:
209 $$.self = NewBlock(OffsetOutBytes, MaskBytes, $4, $3.comp, FUNC_NONE, NULL);
210 break;
211 case SOURCE:
212 case DESTINATION:
213 case SOURCE_OR_DESTINATION:
214 case SOURCE_AND_DESTINATION:
215 case IN_SRC:
216 case IN_DST:
217 case OUT_SRC:
218 case OUT_DST:
219 yyerror("This token is not expected here!");
220 YYABORT;
221 break;
222 default:
223 /* should never happen */
224 yyerror("Internal parser error");
225 YYABORT;
226 } // End of switch
227
228 }
229
230 | FLOWS comp NUMBER {
231 $$.self = NewBlock(OffsetAggrFlows, MaskFlows, $3, $2.comp, FUNC_NONE, NULL);
232 }
233
234 | PPS comp NUMBER {
235 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_PPS, NULL);
236 }
237
238 | BPS comp NUMBER {
239 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_BPS, NULL);
240 }
241
242 | BPP comp NUMBER {
243 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_BPP, NULL);
244 }
245
246 | DURATION comp NUMBER {
247 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_DURATION, NULL);
248 }
249
250 | dqual TOS comp NUMBER {
251 if ( $4 > 255 ) {
252 yyerror("TOS must be 0..255");
253 YYABORT;
254 }
255
256 switch ( $$.direction ) {
257 case DIR_UNSPEC:
258 case SOURCE:
259 $$.self = NewBlock(OffsetTos, MaskTos, ($4 << ShiftTos) & MaskTos, $3.comp, FUNC_NONE, NULL);
260 break;
261 case DESTINATION:
262 $$.self = NewBlock(OffsetDstTos, MaskDstTos, ($4 << ShiftDstTos) & MaskDstTos, $3.comp, FUNC_NONE, NULL);
263 break;
264 case SOURCE_OR_DESTINATION:
265 $$.self = Connect_OR(
266 NewBlock(OffsetTos, MaskTos, ($4 << ShiftTos) & MaskTos, $3.comp, FUNC_NONE, NULL),
267 NewBlock(OffsetDstTos, MaskDstTos, ($4 << ShiftDstTos) & MaskDstTos, $3.comp, FUNC_NONE, NULL)
268 );
269 break;
270 case SOURCE_AND_DESTINATION:
271 $$.self = Connect_AND(
272 NewBlock(OffsetTos, MaskTos, ($4 << ShiftTos) & MaskTos, $3.comp, FUNC_NONE, NULL),
273 NewBlock(OffsetDstTos, MaskDstTos, ($4 << ShiftDstTos) & MaskDstTos, $3.comp, FUNC_NONE, NULL)
274 );
275 break;
276 case DIR_IN:
277 case DIR_OUT:
278 case IN_SRC:
279 case IN_DST:
280 case OUT_SRC:
281 case OUT_DST:
282 yyerror("This token is not expected here!");
283 YYABORT;
284 break;
285 default:
286 /* should never happen */
287 yyerror("Internal parser error");
288 YYABORT;
289 }
290 }
291
292 | FLAGS comp NUMBER {
293 if ( $3 > 63 ) {
294 yyerror("Flags must be 0..63");
295 YYABORT;
296 }
297 $$.self = NewBlock(OffsetFlags, MaskFlags, ($3 << ShiftFlags) & MaskFlags, $2.comp, FUNC_NONE, NULL);
298 }
299
300 | FLAGS STRING {
301 uint64_t fl = 0;
302 int cnt = 0;
303 size_t len = strlen($2);
304
305 if ( len > 7 ) {
306 yyerror("Too many flags");
307 YYABORT;
308 }
309
310 if ( strchr($2, 'F') ) { fl |= 1; cnt++; }
311 if ( strchr($2, 'S') ) { fl |= 2; cnt++; }
312 if ( strchr($2, 'R') ) { fl |= 4; cnt++; }
313 if ( strchr($2, 'P') ) { fl |= 8; cnt++; }
314 if ( strchr($2, 'A') ) { fl |= 16; cnt++; }
315 if ( strchr($2, 'U') ) { fl |= 32; cnt++; }
316 if ( strchr($2, 'X') ) { fl = 63; cnt++; }
317
318 if ( cnt != len ) {
319 yyerror("Too many flags");
320 YYABORT;
321 }
322
323 $$.self = NewBlock(OffsetFlags, (fl << ShiftFlags) & MaskFlags,
324 (fl << ShiftFlags) & MaskFlags, CMP_FLAGS, FUNC_NONE, NULL);
325 }
326
327 | dqual IP STRING {
328 int af, bytes, ret;
329
330 ret = parse_ip(&af, $3, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
331
332 if ( ret == 0 ) {
333 yyerror("Error parsing IP address.");
334 YYABORT;
335 }
336
337 // ret == -1 will never happen here, as ALLOW_LOOKUP is set
338 if ( ret == -2 ) {
339 // could not resolv host => 'not any'
340 $$.self = Invert(NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL ));
341 } else {
342 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
343 yyerror("incomplete IP address");
344 YYABORT;
345 }
346
347 switch ( $$.direction ) {
348 case SOURCE:
349 case DESTINATION:
350 $$.self = ChainHosts(IPstack, num_ip, $$.direction);
351 break;
352 case DIR_UNSPEC:
353 case SOURCE_OR_DESTINATION: {
354 uint32_t src = ChainHosts(IPstack, num_ip, SOURCE);
355 uint32_t dst = ChainHosts(IPstack, num_ip, DESTINATION);
356 $$.self = Connect_OR(src, dst);
357 } break;
358 case SOURCE_AND_DESTINATION: {
359 uint32_t src = ChainHosts(IPstack, num_ip, SOURCE);
360 uint32_t dst = ChainHosts(IPstack, num_ip, DESTINATION);
361 $$.self = Connect_AND(src, dst);
362 } break;
363 case DIR_IN:
364 case DIR_OUT:
365 case IN_SRC:
366 case IN_DST:
367 case OUT_SRC:
368 case OUT_DST:
369 yyerror("This token is not expected here!");
370 YYABORT;
371 break;
372 default:
373 /* should never happen */
374 yyerror("Internal parser error");
375 YYABORT;
376
377 } // End of switch
378
379 }
380 }
381
382 | dqual IP IN '[' iplist ']' {
383
384 $$.direction = $1.direction;
385
386 switch ( $$.direction ) {
387 case SOURCE:
388 $$.self = NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 );
389 break;
390 case DESTINATION:
391 $$.self = NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 );
392 break;
393 case DIR_UNSPEC:
394 case SOURCE_OR_DESTINATION:
395 $$.self = Connect_OR(
396 NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 ),
397 NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 )
398 );
399 break;
400 case SOURCE_AND_DESTINATION:
401 $$.self = Connect_AND(
402 NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 ),
403 NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 )
404 );
405 break;
406 case DIR_IN:
407 case DIR_OUT:
408 case IN_SRC:
409 case IN_DST:
410 case OUT_SRC:
411 case OUT_DST:
412 yyerror("This token is not expected here!");
413 YYABORT;
414 break;
415 default:
416 /* should never happen */
417 yyerror("Internal parser error");
418 YYABORT;
419 }
420 }
421
422 | NEXTHOP IP STRING {
423 int af, bytes, ret;
424
425 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
426
427 if ( ret == 0 ) {
428 yyerror("Error parsing IP address.");
429 YYABORT;
430 }
431
432 if ( ret == -1 ) {
433 yyerror("IP address required - hostname not allowed here.");
434 YYABORT;
435 }
436 // ret == -2 will never happen here, as STRICT_IP is set
437
438 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
439 yyerror("incomplete IP address");
440 YYABORT;
441 }
442
443 $$.self = Connect_AND(
444 NewBlock(OffsetNexthopv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
445 NewBlock(OffsetNexthopv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
446 );
447 }
448
449 | BGPNEXTHOP IP STRING {
450 int af, bytes, ret;
451
452 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
453
454 if ( ret == 0 ) {
455 yyerror("Error parsing IP address.");
456 YYABORT;
457 }
458
459 if ( ret == -1 ) {
460 yyerror("IP address required - hostname not allowed here.");
461 YYABORT;
462 }
463 // ret == -2 will never happen here, as STRICT_IP is set
464
465 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
466 yyerror("incomplete IP address");
467 YYABORT;
468 }
469
470 $$.self = Connect_AND(
471 NewBlock(OffsetBGPNexthopv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
472 NewBlock(OffsetBGPNexthopv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
473 );
474 }
475
476 | ROUTER IP STRING {
477 int af, bytes, ret;
478
479 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
480
481 if ( ret == 0 ) {
482 yyerror("Error parsing IP address.");
483 YYABORT;
484 }
485
486 if ( ret == -1 ) {
487 yyerror("IP address required - hostname not allowed here.");
488 YYABORT;
489 }
490 // ret == -2 will never happen here, as STRICT_IP is set
491
492 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
493 yyerror("incomplete IP address");
494 YYABORT;
495 }
496
497 $$.self = Connect_AND(
498 NewBlock(OffsetRouterv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
499 NewBlock(OffsetRouterv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
500 );
501 }
502
503 | dqual PORT comp NUMBER {
504 $$.direction = $1.direction;
505 if ( $4 > 65535 ) {
506 yyerror("Port outside of range 0..65535");
507 YYABORT;
508 }
509
510 switch ( $$.direction ) {
511 case SOURCE:
512 $$.self = NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE, NULL );
513 break;
514 case DESTINATION:
515 $$.self = NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE, NULL );
516 break;
517 case DIR_UNSPEC:
518 case SOURCE_OR_DESTINATION:
519 $$.self = Connect_OR(
520 NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE, NULL ),
521 NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE, NULL )
522 );
523 break;
524 case SOURCE_AND_DESTINATION:
525 $$.self = Connect_AND(
526 NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE, NULL ),
527 NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE, NULL )
528 );
529 break;
530 case DIR_IN:
531 case DIR_OUT:
532 case IN_SRC:
533 case IN_DST:
534 case OUT_SRC:
535 case OUT_DST:
536 yyerror("This token is not expected here!");
537 YYABORT;
538 break;
539 default:
540 /* should never happen */
541 yyerror("Internal parser error");
542 YYABORT;
543 } // End switch
544
545 }
546
547 | dqual PORT IN '[' ullist ']' {
548 struct ULongListNode *node;
549 ULongtree_t *root = NULL;
550
551 $$.direction = $1.direction;
552 if ( $$.direction == DIR_UNSPEC || $$.direction == SOURCE_OR_DESTINATION || $$.direction == SOURCE_AND_DESTINATION ) {
553 // src and/or dst port
554 // we need a second rbtree due to different shifts for src and dst ports
555 root = malloc(sizeof(ULongtree_t));
556
557 struct ULongListNode *n;
558 if ( root == NULL) {
559 yyerror("malloc() error");
560 YYABORT;
561 }
562 RB_INIT(root);
563
564 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
565 if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
566 yyerror("malloc() error");
567 YYABORT;
568 }
569 n->value = (node->value << ShiftDstPort) & MaskDstPort;
570 node->value = (node->value << ShiftSrcPort) & MaskSrcPort;
571 RB_INSERT(ULongtree, root, n);
572 }
573 }
574
575 switch ( $$.direction ) {
576 case SOURCE:
577 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
578 node->value = (node->value << ShiftSrcPort) & MaskSrcPort;
579 }
580 $$.self = NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
581 break;
582 case DESTINATION:
583 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
584 node->value = (node->value << ShiftDstPort) & MaskDstPort;
585 }
586 $$.self = NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
587 break;
588 case DIR_UNSPEC:
589 case SOURCE_OR_DESTINATION:
590 $$.self = Connect_OR(
591 NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
592 NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
593 );
594 break;
595 case SOURCE_AND_DESTINATION:
596 $$.self = Connect_AND(
597 NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
598 NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
599 );
600 break;
601 case DIR_IN:
602 case DIR_OUT:
603 case IN_SRC:
604 case IN_DST:
605 case OUT_SRC:
606 case OUT_DST:
607 yyerror("This token is not expected here!");
608 YYABORT;
609 break;
610 default:
611 /* should never happen */
612 yyerror("Internal parser error");
613 YYABORT;
614 } // End of switch
615
616 }
617
618 | ICMP_TYPE NUMBER {
619 if ( $2 > 255 ) {
620 yyerror("ICMP tpye of range 0..15");
621 YYABORT;
622 }
623 $$.self = Connect_AND(
624 // imply proto ICMP with a proto ICMP block
625 Connect_OR (
626 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMP << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL),
627 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMPV6 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL)
628 ),
629 NewBlock(OffsetPort, MaskICMPtype, ($2 << ShiftICMPtype) & MaskICMPtype, CMP_EQ, FUNC_NONE, NULL )
630 );
631
632 }
633
634 | ICMP_CODE NUMBER {
635 if ( $2 > 255 ) {
636 yyerror("ICMP code of range 0..15");
637 YYABORT;
638 }
639 $$.self = Connect_AND(
640 // imply proto ICMP with a proto ICMP block
641 Connect_OR (
642 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMP << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL),
643 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMPV6 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL)
644 ),
645 NewBlock(OffsetPort, MaskICMPcode, ($2 << ShiftICMPcode) & MaskICMPcode, CMP_EQ, FUNC_NONE, NULL )
646 );
647
648 }
649
650 | ENGINE_TYPE comp NUMBER {
651 if ( $3 > 255 ) {
652 yyerror("Engine type of range 0..255");
653 YYABORT;
654 }
655 $$.self = NewBlock(OffsetRouterID, MaskEngineType, ($3 << ShiftEngineType) & MaskEngineType, $2.comp, FUNC_NONE, NULL);
656
657 }
658
659 | ENGINE_ID comp NUMBER {
660 if ( $3 > 255 ) {
661 yyerror("Engine ID of range 0..255");
662 YYABORT;
663 }
664 $$.self = NewBlock(OffsetRouterID, MaskEngineID, ($3 << ShiftEngineID) & MaskEngineID, $2.comp, FUNC_NONE, NULL);
665
666 }
667
668 | dqual AS comp NUMBER {
669 $$.direction = $1.direction;
670 if ( $4 > 0x7FFFFFFF || $4 < 0 ) {
671 yyerror("AS number of range");
672 YYABORT;
673 }
674
675 switch ( $$.direction ) {
676 case SOURCE:
677 $$.self = NewBlock(OffsetAS, MaskSrcAS, ($4 << ShiftSrcAS) & MaskSrcAS, $3.comp, FUNC_NONE, NULL );
678 break;
679 case DESTINATION:
680 $$.self = NewBlock(OffsetAS, MaskDstAS, ($4 << ShiftDstAS) & MaskDstAS, $3.comp, FUNC_NONE, NULL);
681 break;
682 case DIR_UNSPEC:
683 case SOURCE_OR_DESTINATION:
684 $$.self = Connect_OR(
685 NewBlock(OffsetAS, MaskSrcAS, ($4 << ShiftSrcAS) & MaskSrcAS, $3.comp, FUNC_NONE, NULL ),
686 NewBlock(OffsetAS, MaskDstAS, ($4 << ShiftDstAS) & MaskDstAS, $3.comp, FUNC_NONE, NULL)
687 );
688 break;
689 case SOURCE_AND_DESTINATION:
690 $$.self = Connect_AND(
691 NewBlock(OffsetAS, MaskSrcAS, ($4 << ShiftSrcAS) & MaskSrcAS, $3.comp, FUNC_NONE, NULL ),
692 NewBlock(OffsetAS, MaskDstAS, ($4 << ShiftDstAS) & MaskDstAS, $3.comp, FUNC_NONE, NULL)
693 );
694 break;
695 case DIR_IN:
696 case DIR_OUT:
697 case IN_SRC:
698 case IN_DST:
699 case OUT_SRC:
700 case OUT_DST:
701 yyerror("This token is not expected here!");
702 YYABORT;
703 break;
704 default:
705 /* should never happen */
706 yyerror("Internal parser error");
707 YYABORT;
708 } // End of switch
709
710 }
711
712 | dqual AS IN '[' ullist ']' {
713 struct ULongListNode *node;
714 ULongtree_t *root = NULL;
715
716 $$.direction = $1.direction;
717 if ( $$.direction == DIR_UNSPEC || $$.direction == SOURCE_OR_DESTINATION || $$.direction == SOURCE_AND_DESTINATION ) {
718 // src and/or dst AS
719 // we need a second rbtree due to different shifts for src and dst AS
720 root = malloc(sizeof(ULongtree_t));
721
722 struct ULongListNode *n;
723 if ( root == NULL) {
724 yyerror("malloc() error");
725 YYABORT;
726 }
727 RB_INIT(root);
728
729 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
730
731 if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
732 yyerror("malloc() error");
733 YYABORT;
734 }
735 n->value = (node->value << ShiftDstAS) & MaskDstAS;
736 node->value = (node->value << ShiftSrcAS) & MaskSrcAS;
737 RB_INSERT(ULongtree, root, n);
738 }
739 }
740
741 switch ( $$.direction ) {
742 case SOURCE:
743 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
744 node->value = (node->value << ShiftSrcAS) & MaskSrcAS;
745 }
746 $$.self = NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
747 break;
748 case DESTINATION:
749 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
750 node->value = (node->value << ShiftDstAS) & MaskDstAS;
751 }
752 $$.self = NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
753 break;
754 case DIR_UNSPEC:
755 case SOURCE_OR_DESTINATION:
756 $$.self = Connect_OR(
757 NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
758 NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
759 );
760 break;
761 case SOURCE_AND_DESTINATION:
762 $$.self = Connect_AND(
763 NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
764 NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
765 );
766 break;
767 case DIR_IN:
768 case DIR_OUT:
769 case IN_SRC:
770 case IN_DST:
771 case OUT_SRC:
772 case OUT_DST:
773 yyerror("This token is not expected here!");
774 YYABORT;
775 break;
776 default:
777 /* should never happen */
778 yyerror("Internal parser error");
779 YYABORT;
780 }
781
782 }
783
784 | dqual MASK NUMBER {
785 $$.direction = $1.direction;
786 if ( $3 > 255 ) {
787 yyerror("Mask outside of range 0..255");
788 YYABORT;
789 }
790
791 switch ( $$.direction ) {
792 case SOURCE:
793 $$.self = NewBlock(OffsetMask, MaskSrcMask, ($3 << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL );
794 break;
795 case DESTINATION:
796 $$.self = NewBlock(OffsetMask, MaskDstMask, ($3 << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL );
797 break;
798 case DIR_UNSPEC:
799 case SOURCE_OR_DESTINATION:
800 $$.self = Connect_OR(
801 NewBlock(OffsetMask, MaskSrcMask, ($3 << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL ),
802 NewBlock(OffsetMask, MaskDstMask, ($3 << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL )
803 );
804 break;
805 case SOURCE_AND_DESTINATION:
806 $$.self = Connect_AND(
807 NewBlock(OffsetMask, MaskSrcMask, ($3 << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL ),
808 NewBlock(OffsetMask, MaskDstMask, ($3 << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL )
809 );
810 break;
811 case DIR_IN:
812 case DIR_OUT:
813 case IN_SRC:
814 case IN_DST:
815 case OUT_SRC:
816 case OUT_DST:
817 yyerror("This token is not expected here!");
818 YYABORT;
819 break;
820 default:
821 /* should never happen */
822 yyerror("Internal parser error");
823 YYABORT;
824 } // End switch
825
826 }
827
828 | dqual NET STRING STRING {
829 int af, bytes, ret;
830 uint64_t mask[2];
831 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
832
833 if ( ret == 0 ) {
834 yyerror("Invalid IP address");
835 YYABORT;
836 }
837
838 if ( ret == -1 ) {
839 yyerror("IP address required - hostname not allowed here.");
840 YYABORT;
841 }
842 // ret == -2 will never happen here, as STRICT_IP is set
843
844 if ( af != PF_INET ) {
845 yyerror("IP netmask syntax valid only for IPv4");
846 YYABORT;
847 }
848 if ( bytes != 4 ) {
849 yyerror("Need complete IP address");
850 YYABORT;
851 }
852
853 ret = parse_ip(&af, $4, mask, &bytes, STRICT_IP, &num_ip);
854 if ( ret == 0 ) {
855 yyerror("Invalid IP address");
856 YYABORT;
857 }
858 if ( ret == -1 ) {
859 yyerror("IP address required - hostname not allowed here.");
860 YYABORT;
861 }
862 // ret == -2 will never happen here, as STRICT_IP is set
863
864 if ( af != PF_INET || bytes != 4 ) {
865 yyerror("Invalid netmask for IPv4 address");
866 YYABORT;
867 }
868
869 IPstack[0] &= mask[0];
870 IPstack[1] &= mask[1];
871
872 $$.direction = $1.direction;
873
874 switch ( $$.direction ) {
875 case SOURCE:
876 $$.self = Connect_AND(
877 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
878 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
879 );
880 break;
881 case DESTINATION:
882 $$.self = Connect_AND(
883 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
884 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
885 );
886 break;
887 case DIR_UNSPEC:
888 case SOURCE_OR_DESTINATION:
889 $$.self = Connect_OR(
890 Connect_AND(
891 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
892 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
893 ),
894 Connect_AND(
895 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
896 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
897 )
898 );
899 break;
900 case SOURCE_AND_DESTINATION:
901 $$.self = Connect_AND(
902 Connect_AND(
903 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
904 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
905 ),
906 Connect_AND(
907 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
908 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
909 )
910 );
911 break;
912 case DIR_IN:
913 case DIR_OUT:
914 case IN_SRC:
915 case IN_DST:
916 case OUT_SRC:
917 case OUT_DST:
918 yyerror("This token is not expected here!");
919 YYABORT;
920 break;
921 default:
922 /* should never happen */
923 yyerror("Internal parser error");
924 YYABORT;
925 } // End of switch
926
927 }
928
929 | dqual NET STRING '/' NUMBER {
930 int af, bytes, ret;
931 uint64_t mask[2];
932
933 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
934 if ( ret == 0 ) {
935 yyerror("Invalid IP address");
936 YYABORT;
937 }
938 if ( ret == -1 ) {
939 yyerror("IP address required - hostname not allowed here.");
940 YYABORT;
941 }
942 // ret == -2 will never happen here, as STRICT_IP is set
943
944
945 if ( $5 > (bytes*8) ) {
946 yyerror("Too many netbits for this IP addresss");
947 YYABORT;
948 }
949
950 if ( af == PF_INET ) {
951 mask[0] = 0xffffffffffffffffLL;
952 mask[1] = 0xffffffffffffffffLL << ( 32 - $5 );
953 } else { // PF_INET6
954 if ( $5 > 64 ) {
955 mask[0] = 0xffffffffffffffffLL;
956 mask[1] = 0xffffffffffffffffLL << ( 128 - $5 );
957 } else {
958 mask[0] = 0xffffffffffffffffLL << ( 64 - $5 );
959 mask[1] = 0;
960 }
961 }
962 // IP aadresses are stored in network representation
963 mask[0] = mask[0];
964 mask[1] = mask[1];
965
966 IPstack[0] &= mask[0];
967 IPstack[1] &= mask[1];
968
969 $$.direction = $1.direction;
970 switch ( $$.direction ) {
971 case SOURCE:
972 $$.self = Connect_AND(
973 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
974 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
975 );
976 break;
977 case DESTINATION:
978 $$.self = Connect_AND(
979 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
980 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
981 );
982 break;
983 case DIR_UNSPEC:
984 case SOURCE_OR_DESTINATION:
985 $$.self = Connect_OR(
986 Connect_AND(
987 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
988 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
989 ),
990 Connect_AND(
991 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
992 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
993 )
994 );
995 break;
996 case SOURCE_AND_DESTINATION:
997 $$.self = Connect_AND(
998 Connect_AND(
999 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
1000 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
1001 ),
1002 Connect_AND(
1003 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
1004 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
1005 )
1006 );
1007 break;
1008 case DIR_IN:
1009 case DIR_OUT:
1010 case IN_SRC:
1011 case IN_DST:
1012 case OUT_SRC:
1013 case OUT_DST:
1014 yyerror("This token is not expected here!");
1015 YYABORT;
1016 break;
1017 default:
1018 /* should never happen */
1019 yyerror("Internal parser error");
1020 YYABORT;
1021 } // End of switch
1022
1023 }
1024
1025 | dqual IF NUMBER {
1026 if ( $3 > 65535 ) {
1027 yyerror("Input interface number must be 0..65535");
1028 YYABORT;
1029 }
1030
1031 switch ( $$.direction ) {
1032 case DIR_UNSPEC:
1033 $$.self = Connect_OR(
1034 NewBlock(OffsetInOut, MaskInput, ($3 << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE, NULL),
1035 NewBlock(OffsetInOut, MaskOutput, ($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL)
1036 );
1037 break;
1038 case DIR_IN:
1039 $$.self = NewBlock(OffsetInOut, MaskInput, ($3 << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE, NULL);
1040 break;
1041 case DIR_OUT:
1042 $$.self = NewBlock(OffsetInOut, MaskOutput, ($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL);
1043 break;
1044 case SOURCE:
1045 case DESTINATION:
1046 case SOURCE_OR_DESTINATION:
1047 case SOURCE_AND_DESTINATION:
1048 case IN_SRC:
1049 case IN_DST:
1050 case OUT_SRC:
1051 case OUT_DST:
1052 yyerror("This token is not expected here!");
1053 YYABORT;
1054 break;
1055 default:
1056 /* should never happen */
1057 yyerror("Internal parser error");
1058 YYABORT;
1059 } // End of switch
1060
1061 }
1062
1063 | dqual VLAN NUMBER {
1064 $$.direction = $1.direction;
1065 if ( $3 > 65535 || $3 < 0 ) {
1066 yyerror("VLAN number of range 0..65535");
1067 YYABORT;
1068 }
1069
1070 switch ( $$.direction ) {
1071 case SOURCE:
1072 $$.self = NewBlock(OffsetVlan, MaskSrcVlan, ($3 << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL );
1073 break;
1074 case DESTINATION:
1075 $$.self = NewBlock(OffsetVlan, MaskDstVlan, ($3 << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL);
1076 break;
1077 case DIR_UNSPEC:
1078 case SOURCE_OR_DESTINATION:
1079 $$.self = Connect_OR(
1080 NewBlock(OffsetVlan, MaskSrcVlan, ($3 << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL ),
1081 NewBlock(OffsetVlan, MaskDstVlan, ($3 << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL)
1082 );
1083 break;
1084 case SOURCE_AND_DESTINATION:
1085 $$.self = Connect_AND(
1086 NewBlock(OffsetVlan, MaskSrcVlan, ($3 << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL ),
1087 NewBlock(OffsetVlan, MaskDstVlan, ($3 << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL)
1088 );
1089 break;
1090 case DIR_IN:
1091 case DIR_OUT:
1092 case IN_SRC:
1093 case IN_DST:
1094 case OUT_SRC:
1095 case OUT_DST:
1096 yyerror("This token is not expected here!");
1097 YYABORT;
1098 break;
1099 default:
1100 /* should never happen */
1101 yyerror("Internal parser error");
1102 YYABORT;
1103 } // End of switch
1104
1105 }
1106
1107 | dqual MAC STRING {
1108 uint64_t mac = VerifyMac($3);
1109 if ( mac == 0 ) {
1110 yyerror("Invalid MAC address format");
1111 YYABORT;
1112 }
1113 switch ( $$.direction ) {
1114 case DIR_UNSPEC: {
1115 uint32_t in, out;
1116 in = Connect_OR(
1117 NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1118 NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1119 );
1120 out = Connect_OR(
1121 NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1122 NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1123 );
1124 $$.self = Connect_OR(in, out);
1125 } break;
1126 case DIR_IN:
1127 $$.self = Connect_OR(
1128 NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1129 NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1130 );
1131 break;
1132 case DIR_OUT:
1133 $$.self = Connect_OR(
1134 NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1135 NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1136 );
1137 break;
1138 case SOURCE:
1139 $$.self = Connect_OR(
1140 NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1141 NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1142 );
1143 break;
1144 case DESTINATION:
1145 $$.self = Connect_OR(
1146 NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1147 NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1148 );
1149 break;
1150 case IN_SRC:
1151 $$.self = NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1152 break;
1153 case IN_DST:
1154 $$.self = NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1155 break;
1156 case OUT_SRC:
1157 $$.self = NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1158 break;
1159 case OUT_DST:
1160 $$.self = NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1161 break;
1162 case SOURCE_OR_DESTINATION:
1163 case SOURCE_AND_DESTINATION:
1164 yyerror("This token is not expected here!");
1165 YYABORT;
1166 break;
1167 default:
1168 /* should never happen */
1169 yyerror("Internal parser error");
1170 YYABORT;
1171 } // End of switch
1172 }
1173
1174 | MPLS STRING comp NUMBER {
1175 if ( $4 > MPLSMAX ) {
1176 yyerror("MPLS value out of range");
1177 YYABORT;
1178 }
1179
1180 // search for label1 - label10
1181 if ( strncasecmp($2, "label", 5) == 0 ) {
1182 uint64_t mask;
1183 uint32_t offset, shift;
1184 char *s = &$2[5];
1185 if ( s == '\0' ) {
1186 yyerror("Missing label number");
1187 YYABORT;
1188 }
1189 int i = (int)strtol(s, (char **)NULL, 10);
1190
1191 switch (i) {
1192 case 1:
1193 offset = OffsetMPLS12;
1194 mask = MaskMPLSlabelOdd;
1195 shift = ShiftMPLSlabelOdd;
1196 break;
1197 case 2:
1198 offset = OffsetMPLS12;
1199 mask = MaskMPLSlabelEven;
1200 shift = ShiftMPLSlabelEven;
1201 break;
1202 case 3:
1203 offset = OffsetMPLS34;
1204 mask = MaskMPLSlabelOdd;
1205 shift = ShiftMPLSlabelOdd;
1206 break;
1207 case 4:
1208 offset = OffsetMPLS34;
1209 mask = MaskMPLSlabelEven;
1210 shift = ShiftMPLSlabelEven;
1211 break;
1212 case 5:
1213 offset = OffsetMPLS56;
1214 mask = MaskMPLSlabelOdd;
1215 shift = ShiftMPLSlabelOdd;
1216 break;
1217 case 6:
1218 offset = OffsetMPLS56;
1219 mask = MaskMPLSlabelEven;
1220 shift = ShiftMPLSlabelEven;
1221 break;
1222 case 7:
1223 offset = OffsetMPLS78;
1224 mask = MaskMPLSlabelOdd;
1225 shift = ShiftMPLSlabelOdd;
1226 break;
1227 case 8:
1228 offset = OffsetMPLS78;
1229 mask = MaskMPLSlabelEven;
1230 shift = ShiftMPLSlabelEven;
1231 break;
1232 case 9:
1233 offset = OffsetMPLS910;
1234 mask = MaskMPLSlabelOdd;
1235 shift = ShiftMPLSlabelOdd;
1236 break;
1237 case 10:
1238 offset = OffsetMPLS910;
1239 mask = MaskMPLSlabelEven;
1240 shift = ShiftMPLSlabelEven;
1241 break;
1242 default:
1243 yyerror("MPLS label out of range 1..10");
1244 YYABORT;
1245 }
1246 $$.self = NewBlock(offset, mask, ($4 << shift) & mask, $3.comp, FUNC_NONE, NULL );
1247
1248 } else if ( strcasecmp($2, "eos") == 0 ) {
1249 // match End of Stack label
1250 $$.self = NewBlock(0, AnyMask, $4 << 4, $3.comp, FUNC_MPLS_EOS, NULL );
1251
1252 } else if ( strncasecmp($2, "exp", 3) == 0 ) {
1253 uint64_t mask;
1254 uint32_t offset, shift;
1255 char *s = &$2[3];
1256 if ( s == '\0' ) {
1257 yyerror("Missing label number");
1258 YYABORT;
1259 }
1260 int i = (int)strtol(s, (char **)NULL, 10);
1261
1262 if ( $4 < 0 || $4 > 7 ) {
1263 yyerror("MPLS exp value out of range");
1264 YYABORT;
1265 }
1266
1267 switch (i) {
1268 case 1:
1269 offset = OffsetMPLS12;
1270 mask = MaskMPLSexpOdd;
1271 shift = ShiftMPLSexpOdd;
1272 break;
1273 case 2:
1274 offset = OffsetMPLS12;
1275 mask = MaskMPLSexpEven;
1276 shift = ShiftMPLSexpEven;
1277 break;
1278 case 3:
1279 offset = OffsetMPLS34;
1280 mask = MaskMPLSexpOdd;
1281 shift = ShiftMPLSexpOdd;
1282 break;
1283 case 4:
1284 offset = OffsetMPLS34;
1285 mask = MaskMPLSexpEven;
1286 shift = ShiftMPLSexpEven;
1287 break;
1288 case 5:
1289 offset = OffsetMPLS56;
1290 mask = MaskMPLSexpOdd;
1291 shift = ShiftMPLSexpOdd;
1292 break;
1293 case 6:
1294 offset = OffsetMPLS56;
1295 mask = MaskMPLSexpEven;
1296 shift = ShiftMPLSexpEven;
1297 break;
1298 case 7:
1299 offset = OffsetMPLS78;
1300 mask = MaskMPLSexpOdd;
1301 shift = ShiftMPLSexpOdd;
1302 break;
1303 case 8:
1304 offset = OffsetMPLS78;
1305 mask = MaskMPLSexpEven;
1306 shift = ShiftMPLSexpEven;
1307 break;
1308 case 9:
1309 offset = OffsetMPLS910;
1310 mask = MaskMPLSexpOdd;
1311 shift = ShiftMPLSexpOdd;
1312 break;
1313 case 10:
1314 offset = OffsetMPLS910;
1315 mask = MaskMPLSexpEven;
1316 shift = ShiftMPLSexpEven;
1317 break;
1318 default:
1319 yyerror("MPLS label out of range 1..10");
1320 YYABORT;
1321 }
1322 $$.self = NewBlock(offset, mask, $4 << shift, $3.comp, FUNC_NONE, NULL );
1323
1324 } else {
1325 yyerror("Unknown MPLS option");
1326 YYABORT;
1327 }
1328 }
1329 | MPLS ANY NUMBER {
1330 uint32_t *opt = malloc(sizeof(uint32_t));
1331 if ( $3 > MPLSMAX ) {
1332 yyerror("MPLS value out of range");
1333 YYABORT;
1334 }
1335 if ( opt == NULL) {
1336 yyerror("malloc() error");
1337 YYABORT;
1338 }
1339 *opt = $3 << 4;
1340 $$.self = NewBlock(0, AnyMask, $3 << 4, CMP_EQ, FUNC_MPLS_ANY, opt );
1341
1342 }
1343 | FWDSTAT NUMBER {
1344 if ( $2 > 255 ) {
1345 yyerror("Forwarding status of range 0..255");
1346 YYABORT;
1347 }
1348 $$.self = NewBlock(OffsetStatus, MaskStatus, ($2 << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);
1349 }
1350
1351 | FWDSTAT STRING {
1352 uint64_t id = Get_fwd_status_id($2);
1353 if (id == 256 ) {
1354 yyerror("Unknown forwarding status");
1355 YYABORT;
1356 }
1357
1358 $$.self = NewBlock(OffsetStatus, MaskStatus, (id << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);
1359
1360 }
1361
1362 | DIR NUMBER {
1363 if ( $2 > 2 ) {
1364 yyerror("Flow direction status of range 0, 1");
1365 YYABORT;
1366 }
1367 $$.self = NewBlock(OffsetDir, MaskDir, ($2 << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);
1368
1369 }
1370
1371 | DIR STRING {
1372 uint64_t dir = 0xFF;
1373 if ( strcasecmp($2, "ingress") == 0 )
1374 dir = 0;
1375 else if ( strcasecmp($2, "egress") == 0 )
1376 dir = 1;
1377 else {
1378 yyerror("Flow direction status of range ingress, egress");
1379 YYABORT;
1380 }
1381
1382 $$.self = NewBlock(OffsetDir, MaskDir, (dir << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);
1383
1384 }
1385
1386 /* iplist definition */
1387 iplist: STRING {
1388 int i, af, bytes, ret;
1389 struct IPListNode *node;
1390
1391 IPlist_t *root = malloc(sizeof(IPlist_t));
1392
1393 if ( root == NULL) {
1394 yyerror("malloc() error");
1395 YYABORT;
1396 }
1397 RB_INIT(root);
1398
1399 ret = parse_ip(&af, $1, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
1400
1401 if ( ret == 0 ) {
1402 yyerror("Invalid IP address");
1403 YYABORT;
1404 }
1405 // ret == -1 will never happen here, as ALLOW_LOOKUP is set
1406
1407 if ( ret != -2 ) {
1408 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1409 yyerror("incomplete IP address");
1410 YYABORT;
1411 }
1412
1413 for ( i=0; i<num_ip; i++ ) {
1414 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1415 yyerror("malloc() error");
1416 YYABORT;
1417 }
1418 node->ip[0] = IPstack[2*i];
1419 node->ip[1] = IPstack[2*i+1];
1420 node->mask[0] = 0xffffffffffffffffLL;
1421 node->mask[1] = 0xffffffffffffffffLL;
1422 RB_INSERT(IPtree, root, node);
1423 }
1424
1425 }
1426 $$ = (void *)root;
1427
1428 }
1429
1430 iplist: STRING '/' NUMBER {
1431 int af, bytes, ret;
1432 struct IPListNode *node;
1433
1434 IPlist_t *root = malloc(sizeof(IPlist_t));
1435
1436 if ( root == NULL) {
1437 yyerror("malloc() error");
1438 YYABORT;
1439 }
1440 RB_INIT(root);
1441
1442 ret = parse_ip(&af, $1, IPstack, &bytes, STRICT_IP, &num_ip);
1443
1444 if ( ret == 0 ) {
1445 yyerror("Invalid IP address");
1446 YYABORT;
1447 }
1448 // ret == -1 will never happen here, as ALLOW_LOOKUP is set
1449
1450 if ( ret != -2 ) {
1451 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1452 yyerror("incomplete IP address");
1453 YYABORT;
1454 }
1455
1456 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1457 yyerror("malloc() error");
1458 YYABORT;
1459 }
1460
1461 if ( af == PF_INET ) {
1462 node->mask[0] = 0xffffffffffffffffLL;
1463 node->mask[1] = 0xffffffffffffffffLL << ( 32 - $3 );
1464 } else { // PF_INET6
1465 if ( $3 > 64 ) {
1466 node->mask[0] = 0xffffffffffffffffLL;
1467 node->mask[1] = 0xffffffffffffffffLL << ( 128 - $3 );
1468 } else {
1469 node->mask[0] = 0xffffffffffffffffLL << ( 64 - $3 );
1470 node->mask[1] = 0;
1471 }
1472 }
1473
1474 node->ip[0] = IPstack[0] & node->mask[0];
1475 node->ip[1] = IPstack[1] & node->mask[1];
1476
1477 RB_INSERT(IPtree, root, node);
1478
1479 }
1480 $$ = (void *)root;
1481
1482 }
1483
1484 | iplist STRING {
1485 int i, af, bytes, ret;
1486 struct IPListNode *node;
1487
1488 ret = parse_ip(&af, $2, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
1489
1490 if ( ret == 0 ) {
1491 yyerror("Invalid IP address");
1492 YYABORT;
1493 }
1494 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1495 yyerror("incomplete IP address");
1496 YYABORT;
1497 }
1498
1499 // ret == - 2 means lookup failure
1500 if ( ret != -2 ) {
1501 for ( i=0; i<num_ip; i++ ) {
1502 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1503 yyerror("malloc() error");
1504 YYABORT;
1505 }
1506 node->ip[0] = IPstack[2*i];
1507 node->ip[1] = IPstack[2*i+1];
1508 node->mask[0] = 0xffffffffffffffffLL;
1509 node->mask[1] = 0xffffffffffffffffLL;
1510
1511 RB_INSERT(IPtree, (IPlist_t *)$$, node);
1512 }
1513 }
1514 }
1515
1516 | iplist STRING '/' NUMBER {
1517 int af, bytes, ret;
1518 struct IPListNode *node;
1519
1520 ret = parse_ip(&af, $2, IPstack, &bytes, STRICT_IP, &num_ip);
1521
1522 if ( ret == 0 ) {
1523 yyerror("Invalid IP address");
1524 YYABORT;
1525 }
1526 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1527 yyerror("incomplete IP address");
1528 YYABORT;
1529 }
1530
1531 // ret == - 2 means lookup failure
1532 if ( ret != -2 ) {
1533 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1534 yyerror("malloc() error");
1535 YYABORT;
1536 }
1537 if ( af == PF_INET ) {
1538 node->mask[0] = 0xffffffffffffffffLL;
1539 node->mask[1] = 0xffffffffffffffffLL << ( 32 - $4 );
1540 } else { // PF_INET6
1541 if ( $4 > 64 ) {
1542 node->mask[0] = 0xffffffffffffffffLL;
1543 node->mask[1] = 0xffffffffffffffffLL << ( 128 - $4 );
1544 } else {
1545 node->mask[0] = 0xffffffffffffffffLL << ( 64 - $4 );
1546 node->mask[1] = 0;
1547 }
1548 }
1549
1550 node->ip[0] = IPstack[0] & node->mask[0];
1551 node->ip[1] = IPstack[1] & node->mask[1];
1552
1553 RB_INSERT(IPtree, (IPlist_t *)$$, node);
1554 }
1555 }
1556
1557 ;
1558
1559 /* ULlist definition */
1560 ullist: NUMBER {
1561 struct ULongListNode *node;
1562
1563 if ( $1 > 65535 ) {
1564 yyerror("Value outside of range 0..65535");
1565 YYABORT;
1566 }
1567 ULongtree_t *root = malloc(sizeof(ULongtree_t));
1568
1569 if ( root == NULL) {
1570 yyerror("malloc() error");
1571 YYABORT;
1572 }
1573 RB_INIT(root);
1574
1575 if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
1576 yyerror("malloc() error");
1577 YYABORT;
1578 }
1579 node->value = $1;
1580
1581 RB_INSERT(ULongtree, root, node);
1582 $$ = (void *)root;
1583 }
1584 | ullist NUMBER {
1585 struct ULongListNode *node;
1586
1587 if ( $2 > 65535 ) {
1588 yyerror("Value outside of range 0..65535");
1589 YYABORT;
1590 }
1591 if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
1592 yyerror("malloc() error");
1593 YYABORT;
1594 }
1595 node->value = $2;
1596 RB_INSERT(ULongtree, (ULongtree_t *)$$, node);
1597 }
1598 ;
1599
1600 /* scaling qualifiers */
1601
1602 /* comparator qualifiers */
1603 comp: { $$.comp = CMP_EQ; }
1604 | EQ { $$.comp = CMP_EQ; }
1605 | LT { $$.comp = CMP_LT; }
1606 | GT { $$.comp = CMP_GT; }
1607 ;
1608
1609 /* 'direction' qualifiers */
1610 dqual: { $$.direction = DIR_UNSPEC; }
1611 | SRC { $$.direction = SOURCE; }
1612 | DST { $$.direction = DESTINATION; }
1613 | SRC OR DST { $$.direction = SOURCE_OR_DESTINATION; }
1614 | DST OR SRC { $$.direction = SOURCE_OR_DESTINATION; }
1615 | SRC AND DST { $$.direction = SOURCE_AND_DESTINATION; }
1616 | DST AND SRC { $$.direction = SOURCE_AND_DESTINATION; }
1617 | IN { $$.direction = DIR_IN; }
1618 | OUT { $$.direction = DIR_OUT; }
1619 | IN SRC { $$.direction = IN_SRC; }
1620 | IN DST { $$.direction = IN_DST; }
1621 | OUT SRC { $$.direction = OUT_SRC; }
1622 | OUT DST { $$.direction = OUT_DST; }
1623 ;
1624
1625 expr: term { $$ = $1.self; }
1626 | expr OR expr { $$ = Connect_OR($1, $3); }
1627 | expr AND expr { $$ = Connect_AND($1, $3); }
1628 | NOT expr %prec NEGATE { $$ = Invert($2); }
1629 | '(' expr ')' { $$ = $2; }
1630 ;
1631
1632 %%
1633
1634 static void yyerror(char *msg) {
1635 if ( FilterFilename )
1636 fprintf(stderr,"File '%s' line %d: %s at '%s'\n", FilterFilename, lineno, msg, yytext);
1637 else
1638 fprintf(stderr,"Line %d: %s at '%s'\n", lineno, msg, yytext);
1639 } /* End of yyerror */
1640
1641 static uint32_t ChainHosts(uint64_t *hostlist, int num_records, int type) {
1642 uint32_t offset_a, offset_b, i, j, block;
1643
1644 if ( type == SOURCE ) {
1645 offset_a = OffsetSrcIPv6a;
1646 offset_b = OffsetSrcIPv6b;
1647 } else {
1648 offset_a = OffsetDstIPv6a;
1649 offset_b = OffsetDstIPv6b;
1650 }
1651
1652 i = 0;
1653 block = Connect_AND(
1654 NewBlock(offset_b, MaskIPv6, hostlist[i+1] , CMP_EQ, FUNC_NONE, NULL ),
1655 NewBlock(offset_a, MaskIPv6, hostlist[i] , CMP_EQ, FUNC_NONE, NULL )
1656 );
1657 i += 2;
1658 for ( j=1; j<num_records; j++ ) {
1659 uint32_t b = Connect_AND(
1660 NewBlock(offset_b, MaskIPv6, hostlist[i+1] , CMP_EQ, FUNC_NONE, NULL ),
1661 NewBlock(offset_a, MaskIPv6, hostlist[i] , CMP_EQ, FUNC_NONE, NULL )
1662 );
1663 block = Connect_OR(block, b);
1664 i += 2;
1665 }
1666
1667 return block;
1668
1669 } // End of ChainHosts
1670
1671 uint64_t VerifyMac(char *s) {
1672 uint64_t mac;
1673 size_t slen = strlen(s);
1674 long l;
1675 char *p, *q, *r;
1676 int i;
1677
1678 if ( slen > 17 )
1679 return 0;
1680
1681 for (i=0; i<slen; i++ ) {
1682 if ( !isxdigit(s[i]) && s[i] != ':' )
1683 return 0;
1684 }
1685
1686 p = strdup(s);
1687 if ( !p ) {
1688 yyerror("malloc() error");
1689 return 0;
1690 }
1691
1692 mac = 0;
1693 i = 0; // number of MAC octets must be 6
1694 r = p;
1695 q = strchr(r, ':');
1696 while ( r && i < 6 ) {
1697 if ( q )
1698 *q = '\0';
1699 l = strtol(r, NULL, 16);
1700 if ( l > 255 ) {
1701 free(p);
1702 return 0;
1703 }
1704
1705 mac = ( mac << 8 ) | (l & 0xFF );
1706 i++;
1707
1708 if ( q ) {
1709 r = ++q;
1710 q = strchr(r, ':');
1711 } else
1712 r = NULL;
1713 }
1714
1715 if ( i != 6 )
1716 return 0;
1717
1718 return mac;
1719
1720 } // End of VerifyMac
1721
1722 /*
1723
1724 mpls 1 == 3
1725 mpls label1 == 3
1726 mpls any == 4
1727
1728
1729
1730
1731 */
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004-2008, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: grammar.y 100 2008-08-15 11:36:21Z peter $
33 *
34 * $LastChangedRevision: 100 $
35 *
36 *
37 *
38 */
39
40 %{
41
42 #include "config.h"
43
44 #include <stdio.h>
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #include <netinet/in.h>
48 #include <string.h>
49 #include <stdlib.h>
50 #include <ctype.h>
51
52 #ifdef HAVE_STDINT_H
53 #include <stdint.h>
54 #endif
55
56 #include "nf_common.h"
57 #include "rbtree.h"
58 #include "nfdump.h"
59 #include "nffile.h"
60 #include "nftree.h"
61 #include "ipconv.h"
62 #include "util.h"
63
64 /*
65 * function prototypes
66 */
67 static void yyerror(char *msg);
68
69 static uint32_t ChainHosts(uint64_t *hostlist, int num_records, int type);
70
71 static uint64_t VerifyMac(char *s);
72
73 enum { DIR_UNSPEC = 1, SOURCE, DESTINATION, SOURCE_AND_DESTINATION, SOURCE_OR_DESTINATION, DIR_IN, DIR_OUT, IN_SRC, IN_DST, OUT_SRC, OUT_DST };
74
75 /* var defs */
76 extern int lineno;
77 extern char *yytext;
78 extern uint64_t *IPstack;
79 extern uint32_t StartNode;
80 extern uint16_t Extended;
81 extern int (*FilterEngine)(uint32_t *);
82 extern char *FilterFilename;
83
84 static uint32_t num_ip;
85
86 char yyerror_buff[256];
87
88 #define MPLSMAX 0x00ffffff
89 %}
90
91 %union {
92 uint64_t value;
93 char *s;
94 FilterParam_t param;
95 void *list;
96 }
97
98 %token ANY IP IF MAC MPLS TOS DIR FLAGS PROTO MASK HOSTNAME NET PORT FWDSTAT IN OUT SRC DST EQ LT GT
99 %token NUMBER STRING IDENT ALPHA_FLAGS PROTOSTR PORTNUM ICMP_TYPE ICMP_CODE ENGINE_TYPE ENGINE_ID AS PACKETS BYTES FLOWS
100 %token PPS BPS BPP DURATION
101 %token IPV4 IPV6 NEXTHOP BGPNEXTHOP ROUTER VLAN
102 %token NOT END
103 %type <value> expr NUMBER PORTNUM ICMP_TYPE ICMP_CODE
104 %type <s> STRING IDENT ALPHA_FLAGS PROTOSTR
105 %type <param> dqual term comp
106 %type <list> iplist ullist
107
108 %left '+' OR
109 %left '*' AND
110 %left NEGATE
111
112 %%
113 prog: /* empty */
114 | expr {
115 StartNode = $1;
116 }
117 ;
118
119 term: ANY { /* this is an unconditionally true expression, as a filter applies in any case */
120 $$.self = NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL );
121 }
122
123 | IDENT STRING {
124 if ( !ScreenIdentString($2) ) {
125 yyerror("Illegal ident string");
126 YYABORT;
127 }
128
129 uint32_t index = AddIdent($2);
130 $$.self = NewBlock(0, 0, index, CMP_IDENT, FUNC_NONE, NULL );
131 }
132
133 | IPV4 {
134 $$.self = NewBlock(OffsetRecordFlags, (1LL << ShiftRecordFlags) & MaskRecordFlags,
135 (0LL << ShiftRecordFlags) & MaskRecordFlags, CMP_EQ, FUNC_NONE, NULL);
136 }
137
138 | IPV6 {
139 $$.self = NewBlock(OffsetRecordFlags, (1LL << ShiftRecordFlags) & MaskRecordFlags,
140 (1LL << ShiftRecordFlags) & MaskRecordFlags, CMP_EQ, FUNC_NONE, NULL);
141 }
142
143 | PROTO NUMBER {
144 int64_t proto;
145 proto = $2;
146
147 if ( proto > 255 ) {
148 yyerror("Protocol number > 255");
149 YYABORT;
150 }
151 if ( proto < 0 ) {
152 yyerror("Unknown protocol");
153 YYABORT;
154 }
155 $$.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL);
156
157 }
158
159 | PROTO STRING {
160 int64_t proto;
161 proto = Proto_num($2);
162
163 if ( proto > 255 ) {
164 yyerror("Protocol number > 255");
165 YYABORT;
166 }
167 if ( proto < 0 ) {
168 yyerror("Unknown protocol");
169 YYABORT;
170 }
171 $$.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL);
172 }
173
174 | dqual PACKETS comp NUMBER {
175
176 switch ( $$.direction ) {
177 case DIR_UNSPEC:
178 case DIR_IN:
179 $$.self = NewBlock(OffsetPackets, MaskPackets, $4, $3.comp, FUNC_NONE, NULL);
180 break;
181 case DIR_OUT:
182 $$.self = NewBlock(OffsetOutPackets, MaskPackets, $4, $3.comp, FUNC_NONE, NULL);
183 break;
184 case SOURCE:
185 case DESTINATION:
186 case SOURCE_OR_DESTINATION:
187 case SOURCE_AND_DESTINATION:
188 case IN_SRC:
189 case IN_DST:
190 case OUT_SRC:
191 case OUT_DST:
192 yyerror("This token is not expected here!");
193 YYABORT;
194 break;
195 default:
196 /* should never happen */
197 yyerror("Internal parser error");
198 YYABORT;
199 } // End of switch
200
201 }
202
203 | dqual BYTES comp NUMBER {
204
205 switch ( $$.direction ) {
206 case DIR_UNSPEC:
207 case DIR_IN:
208 $$.self = NewBlock(OffsetBytes, MaskBytes, $4, $3.comp, FUNC_NONE, NULL);
209 break;
210 case DIR_OUT:
211 $$.self = NewBlock(OffsetOutBytes, MaskBytes, $4, $3.comp, FUNC_NONE, NULL);
212 break;
213 case SOURCE:
214 case DESTINATION:
215 case SOURCE_OR_DESTINATION:
216 case SOURCE_AND_DESTINATION:
217 case IN_SRC:
218 case IN_DST:
219 case OUT_SRC:
220 case OUT_DST:
221 yyerror("This token is not expected here!");
222 YYABORT;
223 break;
224 default:
225 /* should never happen */
226 yyerror("Internal parser error");
227 YYABORT;
228 } // End of switch
229
230 }
231
232 | FLOWS comp NUMBER {
233 $$.self = NewBlock(OffsetAggrFlows, MaskFlows, $3, $2.comp, FUNC_NONE, NULL);
234 }
235
236 | PPS comp NUMBER {
237 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_PPS, NULL);
238 }
239
240 | BPS comp NUMBER {
241 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_BPS, NULL);
242 }
243
244 | BPP comp NUMBER {
245 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_BPP, NULL);
246 }
247
248 | DURATION comp NUMBER {
249 $$.self = NewBlock(0, AnyMask, $3, $2.comp, FUNC_DURATION, NULL);
250 }
251
252 | dqual TOS comp NUMBER {
253 if ( $4 > 255 ) {
254 yyerror("TOS must be 0..255");
255 YYABORT;
256 }
257
258 switch ( $$.direction ) {
259 case DIR_UNSPEC:
260 case SOURCE:
261 $$.self = NewBlock(OffsetTos, MaskTos, ($4 << ShiftTos) & MaskTos, $3.comp, FUNC_NONE, NULL);
262 break;
263 case DESTINATION:
264 $$.self = NewBlock(OffsetDstTos, MaskDstTos, ($4 << ShiftDstTos) & MaskDstTos, $3.comp, FUNC_NONE, NULL);
265 break;
266 case SOURCE_OR_DESTINATION:
267 $$.self = Connect_OR(
268 NewBlock(OffsetTos, MaskTos, ($4 << ShiftTos) & MaskTos, $3.comp, FUNC_NONE, NULL),
269 NewBlock(OffsetDstTos, MaskDstTos, ($4 << ShiftDstTos) & MaskDstTos, $3.comp, FUNC_NONE, NULL)
270 );
271 break;
272 case SOURCE_AND_DESTINATION:
273 $$.self = Connect_AND(
274 NewBlock(OffsetTos, MaskTos, ($4 << ShiftTos) & MaskTos, $3.comp, FUNC_NONE, NULL),
275 NewBlock(OffsetDstTos, MaskDstTos, ($4 << ShiftDstTos) & MaskDstTos, $3.comp, FUNC_NONE, NULL)
276 );
277 break;
278 case DIR_IN:
279 case DIR_OUT:
280 case IN_SRC:
281 case IN_DST:
282 case OUT_SRC:
283 case OUT_DST:
284 yyerror("This token is not expected here!");
285 YYABORT;
286 break;
287 default:
288 /* should never happen */
289 yyerror("Internal parser error");
290 YYABORT;
291 }
292 }
293
294 | FLAGS comp NUMBER {
295 if ( $3 > 63 ) {
296 yyerror("Flags must be 0..63");
297 YYABORT;
298 }
299 $$.self = NewBlock(OffsetFlags, MaskFlags, ($3 << ShiftFlags) & MaskFlags, $2.comp, FUNC_NONE, NULL);
300 }
301
302 | FLAGS STRING {
303 uint64_t fl = 0;
304 int cnt = 0;
305 size_t len = strlen($2);
306
307 if ( len > 7 ) {
308 yyerror("Too many flags");
309 YYABORT;
310 }
311
312 if ( strchr($2, 'F') ) { fl |= 1; cnt++; }
313 if ( strchr($2, 'S') ) { fl |= 2; cnt++; }
314 if ( strchr($2, 'R') ) { fl |= 4; cnt++; }
315 if ( strchr($2, 'P') ) { fl |= 8; cnt++; }
316 if ( strchr($2, 'A') ) { fl |= 16; cnt++; }
317 if ( strchr($2, 'U') ) { fl |= 32; cnt++; }
318 if ( strchr($2, 'X') ) { fl = 63; cnt++; }
319
320 if ( cnt != len ) {
321 yyerror("Too many flags");
322 YYABORT;
323 }
324
325 $$.self = NewBlock(OffsetFlags, (fl << ShiftFlags) & MaskFlags,
326 (fl << ShiftFlags) & MaskFlags, CMP_FLAGS, FUNC_NONE, NULL);
327 }
328
329 | dqual IP STRING {
330 int af, bytes, ret;
331
332 ret = parse_ip(&af, $3, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
333
334 if ( ret == 0 ) {
335 yyerror("Error parsing IP address.");
336 YYABORT;
337 }
338
339 // ret == -1 will never happen here, as ALLOW_LOOKUP is set
340 if ( ret == -2 ) {
341 // could not resolv host => 'not any'
342 $$.self = Invert(NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL ));
343 } else {
344 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
345 yyerror("incomplete IP address");
346 YYABORT;
347 }
348
349 switch ( $$.direction ) {
350 case SOURCE:
351 case DESTINATION:
352 $$.self = ChainHosts(IPstack, num_ip, $$.direction);
353 break;
354 case DIR_UNSPEC:
355 case SOURCE_OR_DESTINATION: {
356 uint32_t src = ChainHosts(IPstack, num_ip, SOURCE);
357 uint32_t dst = ChainHosts(IPstack, num_ip, DESTINATION);
358 $$.self = Connect_OR(src, dst);
359 } break;
360 case SOURCE_AND_DESTINATION: {
361 uint32_t src = ChainHosts(IPstack, num_ip, SOURCE);
362 uint32_t dst = ChainHosts(IPstack, num_ip, DESTINATION);
363 $$.self = Connect_AND(src, dst);
364 } break;
365 case DIR_IN:
366 case DIR_OUT:
367 case IN_SRC:
368 case IN_DST:
369 case OUT_SRC:
370 case OUT_DST:
371 yyerror("This token is not expected here!");
372 YYABORT;
373 break;
374 default:
375 /* should never happen */
376 yyerror("Internal parser error");
377 YYABORT;
378
379 } // End of switch
380
381 }
382 }
383
384 | dqual IP IN '[' iplist ']' {
385
386 $$.direction = $1.direction;
387
388 switch ( $$.direction ) {
389 case SOURCE:
390 $$.self = NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 );
391 break;
392 case DESTINATION:
393 $$.self = NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 );
394 break;
395 case DIR_UNSPEC:
396 case SOURCE_OR_DESTINATION:
397 $$.self = Connect_OR(
398 NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 ),
399 NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 )
400 );
401 break;
402 case SOURCE_AND_DESTINATION:
403 $$.self = Connect_AND(
404 NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 ),
405 NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)$5 )
406 );
407 break;
408 case DIR_IN:
409 case DIR_OUT:
410 case IN_SRC:
411 case IN_DST:
412 case OUT_SRC:
413 case OUT_DST:
414 yyerror("This token is not expected here!");
415 YYABORT;
416 break;
417 default:
418 /* should never happen */
419 yyerror("Internal parser error");
420 YYABORT;
421 }
422 }
423
424 | NEXTHOP IP STRING {
425 int af, bytes, ret;
426
427 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
428
429 if ( ret == 0 ) {
430 yyerror("Error parsing IP address.");
431 YYABORT;
432 }
433
434 if ( ret == -1 ) {
435 yyerror("IP address required - hostname not allowed here.");
436 YYABORT;
437 }
438 // ret == -2 will never happen here, as STRICT_IP is set
439
440 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
441 yyerror("incomplete IP address");
442 YYABORT;
443 }
444
445 $$.self = Connect_AND(
446 NewBlock(OffsetNexthopv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
447 NewBlock(OffsetNexthopv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
448 );
449 }
450
451 | BGPNEXTHOP IP STRING {
452 int af, bytes, ret;
453
454 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
455
456 if ( ret == 0 ) {
457 yyerror("Error parsing IP address.");
458 YYABORT;
459 }
460
461 if ( ret == -1 ) {
462 yyerror("IP address required - hostname not allowed here.");
463 YYABORT;
464 }
465 // ret == -2 will never happen here, as STRICT_IP is set
466
467 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
468 yyerror("incomplete IP address");
469 YYABORT;
470 }
471
472 $$.self = Connect_AND(
473 NewBlock(OffsetBGPNexthopv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
474 NewBlock(OffsetBGPNexthopv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
475 );
476 }
477
478 | ROUTER IP STRING {
479 int af, bytes, ret;
480
481 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
482
483 if ( ret == 0 ) {
484 yyerror("Error parsing IP address.");
485 YYABORT;
486 }
487
488 if ( ret == -1 ) {
489 yyerror("IP address required - hostname not allowed here.");
490 YYABORT;
491 }
492 // ret == -2 will never happen here, as STRICT_IP is set
493
494 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
495 yyerror("incomplete IP address");
496 YYABORT;
497 }
498
499 $$.self = Connect_AND(
500 NewBlock(OffsetRouterv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
501 NewBlock(OffsetRouterv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
502 );
503 }
504
505 | dqual PORT comp NUMBER {
506 $$.direction = $1.direction;
507 if ( $4 > 65535 ) {
508 yyerror("Port outside of range 0..65535");
509 YYABORT;
510 }
511
512 switch ( $$.direction ) {
513 case SOURCE:
514 $$.self = NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE, NULL );
515 break;
516 case DESTINATION:
517 $$.self = NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE, NULL );
518 break;
519 case DIR_UNSPEC:
520 case SOURCE_OR_DESTINATION:
521 $$.self = Connect_OR(
522 NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE, NULL ),
523 NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE, NULL )
524 );
525 break;
526 case SOURCE_AND_DESTINATION:
527 $$.self = Connect_AND(
528 NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE, NULL ),
529 NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE, NULL )
530 );
531 break;
532 case DIR_IN:
533 case DIR_OUT:
534 case IN_SRC:
535 case IN_DST:
536 case OUT_SRC:
537 case OUT_DST:
538 yyerror("This token is not expected here!");
539 YYABORT;
540 break;
541 default:
542 /* should never happen */
543 yyerror("Internal parser error");
544 YYABORT;
545 } // End switch
546
547 }
548
549 | dqual PORT IN '[' ullist ']' {
550 struct ULongListNode *node;
551 ULongtree_t *root = NULL;
552
553 $$.direction = $1.direction;
554 if ( $$.direction == DIR_UNSPEC || $$.direction == SOURCE_OR_DESTINATION || $$.direction == SOURCE_AND_DESTINATION ) {
555 // src and/or dst port
556 // we need a second rbtree due to different shifts for src and dst ports
557 root = malloc(sizeof(ULongtree_t));
558
559 struct ULongListNode *n;
560 if ( root == NULL) {
561 yyerror("malloc() error");
562 YYABORT;
563 }
564 RB_INIT(root);
565
566 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
567 if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
568 yyerror("malloc() error");
569 YYABORT;
570 }
571 n->value = (node->value << ShiftDstPort) & MaskDstPort;
572 node->value = (node->value << ShiftSrcPort) & MaskSrcPort;
573 RB_INSERT(ULongtree, root, n);
574 }
575 }
576
577 switch ( $$.direction ) {
578 case SOURCE:
579 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
580 node->value = (node->value << ShiftSrcPort) & MaskSrcPort;
581 }
582 $$.self = NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
583 break;
584 case DESTINATION:
585 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
586 node->value = (node->value << ShiftDstPort) & MaskDstPort;
587 }
588 $$.self = NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
589 break;
590 case DIR_UNSPEC:
591 case SOURCE_OR_DESTINATION:
592 $$.self = Connect_OR(
593 NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
594 NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
595 );
596 break;
597 case SOURCE_AND_DESTINATION:
598 $$.self = Connect_AND(
599 NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
600 NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
601 );
602 break;
603 case DIR_IN:
604 case DIR_OUT:
605 case IN_SRC:
606 case IN_DST:
607 case OUT_SRC:
608 case OUT_DST:
609 yyerror("This token is not expected here!");
610 YYABORT;
611 break;
612 default:
613 /* should never happen */
614 yyerror("Internal parser error");
615 YYABORT;
616 } // End of switch
617
618 }
619
620 | ICMP_TYPE NUMBER {
621 if ( $2 > 255 ) {
622 yyerror("ICMP tpye of range 0..15");
623 YYABORT;
624 }
625 $$.self = Connect_AND(
626 // imply proto ICMP with a proto ICMP block
627 Connect_OR (
628 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMP << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL),
629 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMPV6 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL)
630 ),
631 NewBlock(OffsetPort, MaskICMPtype, ($2 << ShiftICMPtype) & MaskICMPtype, CMP_EQ, FUNC_NONE, NULL )
632 );
633
634 }
635
636 | ICMP_CODE NUMBER {
637 if ( $2 > 255 ) {
638 yyerror("ICMP code of range 0..15");
639 YYABORT;
640 }
641 $$.self = Connect_AND(
642 // imply proto ICMP with a proto ICMP block
643 Connect_OR (
644 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMP << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL),
645 NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMPV6 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL)
646 ),
647 NewBlock(OffsetPort, MaskICMPcode, ($2 << ShiftICMPcode) & MaskICMPcode, CMP_EQ, FUNC_NONE, NULL )
648 );
649
650 }
651
652 | ENGINE_TYPE comp NUMBER {
653 if ( $3 > 255 ) {
654 yyerror("Engine type of range 0..255");
655 YYABORT;
656 }
657 $$.self = NewBlock(OffsetRouterID, MaskEngineType, ($3 << ShiftEngineType) & MaskEngineType, $2.comp, FUNC_NONE, NULL);
658
659 }
660
661 | ENGINE_ID comp NUMBER {
662 if ( $3 > 255 ) {
663 yyerror("Engine ID of range 0..255");
664 YYABORT;
665 }
666 $$.self = NewBlock(OffsetRouterID, MaskEngineID, ($3 << ShiftEngineID) & MaskEngineID, $2.comp, FUNC_NONE, NULL);
667
668 }
669
670 | dqual AS comp NUMBER {
671 $$.direction = $1.direction;
672 if ( $4 > 0x7FFFFFFF || $4 < 0 ) {
673 yyerror("AS number of range");
674 YYABORT;
675 }
676
677 switch ( $$.direction ) {
678 case SOURCE:
679 $$.self = NewBlock(OffsetAS, MaskSrcAS, ($4 << ShiftSrcAS) & MaskSrcAS, $3.comp, FUNC_NONE, NULL );
680 break;
681 case DESTINATION:
682 $$.self = NewBlock(OffsetAS, MaskDstAS, ($4 << ShiftDstAS) & MaskDstAS, $3.comp, FUNC_NONE, NULL);
683 break;
684 case DIR_UNSPEC:
685 case SOURCE_OR_DESTINATION:
686 $$.self = Connect_OR(
687 NewBlock(OffsetAS, MaskSrcAS, ($4 << ShiftSrcAS) & MaskSrcAS, $3.comp, FUNC_NONE, NULL ),
688 NewBlock(OffsetAS, MaskDstAS, ($4 << ShiftDstAS) & MaskDstAS, $3.comp, FUNC_NONE, NULL)
689 );
690 break;
691 case SOURCE_AND_DESTINATION:
692 $$.self = Connect_AND(
693 NewBlock(OffsetAS, MaskSrcAS, ($4 << ShiftSrcAS) & MaskSrcAS, $3.comp, FUNC_NONE, NULL ),
694 NewBlock(OffsetAS, MaskDstAS, ($4 << ShiftDstAS) & MaskDstAS, $3.comp, FUNC_NONE, NULL)
695 );
696 break;
697 case DIR_IN:
698 case DIR_OUT:
699 case IN_SRC:
700 case IN_DST:
701 case OUT_SRC:
702 case OUT_DST:
703 yyerror("This token is not expected here!");
704 YYABORT;
705 break;
706 default:
707 /* should never happen */
708 yyerror("Internal parser error");
709 YYABORT;
710 } // End of switch
711
712 }
713
714 | dqual AS IN '[' ullist ']' {
715 struct ULongListNode *node;
716 ULongtree_t *root = NULL;
717
718 $$.direction = $1.direction;
719 if ( $$.direction == DIR_UNSPEC || $$.direction == SOURCE_OR_DESTINATION || $$.direction == SOURCE_AND_DESTINATION ) {
720 // src and/or dst AS
721 // we need a second rbtree due to different shifts for src and dst AS
722 root = malloc(sizeof(ULongtree_t));
723
724 struct ULongListNode *n;
725 if ( root == NULL) {
726 yyerror("malloc() error");
727 YYABORT;
728 }
729 RB_INIT(root);
730
731 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
732
733 if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
734 yyerror("malloc() error");
735 YYABORT;
736 }
737 n->value = (node->value << ShiftDstAS) & MaskDstAS;
738 node->value = (node->value << ShiftSrcAS) & MaskSrcAS;
739 RB_INSERT(ULongtree, root, n);
740 }
741 }
742
743 switch ( $$.direction ) {
744 case SOURCE:
745 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
746 node->value = (node->value << ShiftSrcAS) & MaskSrcAS;
747 }
748 $$.self = NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
749 break;
750 case DESTINATION:
751 RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
752 node->value = (node->value << ShiftDstAS) & MaskDstAS;
753 }
754 $$.self = NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 );
755 break;
756 case DIR_UNSPEC:
757 case SOURCE_OR_DESTINATION:
758 $$.self = Connect_OR(
759 NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
760 NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
761 );
762 break;
763 case SOURCE_AND_DESTINATION:
764 $$.self = Connect_AND(
765 NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)$5 ),
766 NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
767 );
768 break;
769 case DIR_IN:
770 case DIR_OUT:
771 case IN_SRC:
772 case IN_DST:
773 case OUT_SRC:
774 case OUT_DST:
775 yyerror("This token is not expected here!");
776 YYABORT;
777 break;
778 default:
779 /* should never happen */
780 yyerror("Internal parser error");
781 YYABORT;
782 }
783
784 }
785
786 | dqual MASK NUMBER {
787 $$.direction = $1.direction;
788 if ( $3 > 255 ) {
789 yyerror("Mask outside of range 0..255");
790 YYABORT;
791 }
792
793 switch ( $$.direction ) {
794 case SOURCE:
795 $$.self = NewBlock(OffsetMask, MaskSrcMask, ($3 << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL );
796 break;
797 case DESTINATION:
798 $$.self = NewBlock(OffsetMask, MaskDstMask, ($3 << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL );
799 break;
800 case DIR_UNSPEC:
801 case SOURCE_OR_DESTINATION:
802 $$.self = Connect_OR(
803 NewBlock(OffsetMask, MaskSrcMask, ($3 << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL ),
804 NewBlock(OffsetMask, MaskDstMask, ($3 << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL )
805 );
806 break;
807 case SOURCE_AND_DESTINATION:
808 $$.self = Connect_AND(
809 NewBlock(OffsetMask, MaskSrcMask, ($3 << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL ),
810 NewBlock(OffsetMask, MaskDstMask, ($3 << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL )
811 );
812 break;
813 case DIR_IN:
814 case DIR_OUT:
815 case IN_SRC:
816 case IN_DST:
817 case OUT_SRC:
818 case OUT_DST:
819 yyerror("This token is not expected here!");
820 YYABORT;
821 break;
822 default:
823 /* should never happen */
824 yyerror("Internal parser error");
825 YYABORT;
826 } // End switch
827
828 }
829
830 | dqual NET STRING STRING {
831 int af, bytes, ret;
832 uint64_t mask[2];
833 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
834
835 if ( ret == 0 ) {
836 yyerror("Invalid IP address");
837 YYABORT;
838 }
839
840 if ( ret == -1 ) {
841 yyerror("IP address required - hostname not allowed here.");
842 YYABORT;
843 }
844 // ret == -2 will never happen here, as STRICT_IP is set
845
846 if ( af != PF_INET ) {
847 yyerror("IP netmask syntax valid only for IPv4");
848 YYABORT;
849 }
850 if ( bytes != 4 ) {
851 yyerror("Need complete IP address");
852 YYABORT;
853 }
854
855 ret = parse_ip(&af, $4, mask, &bytes, STRICT_IP, &num_ip);
856 if ( ret == 0 ) {
857 yyerror("Invalid IP address");
858 YYABORT;
859 }
860 if ( ret == -1 ) {
861 yyerror("IP address required - hostname not allowed here.");
862 YYABORT;
863 }
864 // ret == -2 will never happen here, as STRICT_IP is set
865
866 if ( af != PF_INET || bytes != 4 ) {
867 yyerror("Invalid netmask for IPv4 address");
868 YYABORT;
869 }
870
871 IPstack[0] &= mask[0];
872 IPstack[1] &= mask[1];
873
874 $$.direction = $1.direction;
875
876 switch ( $$.direction ) {
877 case SOURCE:
878 $$.self = Connect_AND(
879 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
880 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
881 );
882 break;
883 case DESTINATION:
884 $$.self = Connect_AND(
885 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
886 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
887 );
888 break;
889 case DIR_UNSPEC:
890 case SOURCE_OR_DESTINATION:
891 $$.self = Connect_OR(
892 Connect_AND(
893 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
894 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
895 ),
896 Connect_AND(
897 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
898 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
899 )
900 );
901 break;
902 case SOURCE_AND_DESTINATION:
903 $$.self = Connect_AND(
904 Connect_AND(
905 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
906 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
907 ),
908 Connect_AND(
909 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
910 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
911 )
912 );
913 break;
914 case DIR_IN:
915 case DIR_OUT:
916 case IN_SRC:
917 case IN_DST:
918 case OUT_SRC:
919 case OUT_DST:
920 yyerror("This token is not expected here!");
921 YYABORT;
922 break;
923 default:
924 /* should never happen */
925 yyerror("Internal parser error");
926 YYABORT;
927 } // End of switch
928
929 }
930
931 | dqual NET STRING '/' NUMBER {
932 int af, bytes, ret;
933 uint64_t mask[2];
934
935 ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
936 if ( ret == 0 ) {
937 yyerror("Invalid IP address");
938 YYABORT;
939 }
940 if ( ret == -1 ) {
941 yyerror("IP address required - hostname not allowed here.");
942 YYABORT;
943 }
944 // ret == -2 will never happen here, as STRICT_IP is set
945
946
947 if ( $5 > (bytes*8) ) {
948 yyerror("Too many netbits for this IP addresss");
949 YYABORT;
950 }
951
952 if ( af == PF_INET ) {
953 mask[0] = 0xffffffffffffffffLL;
954 mask[1] = 0xffffffffffffffffLL << ( 32 - $5 );
955 } else { // PF_INET6
956 if ( $5 > 64 ) {
957 mask[0] = 0xffffffffffffffffLL;
958 mask[1] = 0xffffffffffffffffLL << ( 128 - $5 );
959 } else {
960 mask[0] = 0xffffffffffffffffLL << ( 64 - $5 );
961 mask[1] = 0;
962 }
963 }
964 // IP aadresses are stored in network representation
965 mask[0] = mask[0];
966 mask[1] = mask[1];
967
968 IPstack[0] &= mask[0];
969 IPstack[1] &= mask[1];
970
971 $$.direction = $1.direction;
972 switch ( $$.direction ) {
973 case SOURCE:
974 $$.self = Connect_AND(
975 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
976 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
977 );
978 break;
979 case DESTINATION:
980 $$.self = Connect_AND(
981 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
982 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
983 );
984 break;
985 case DIR_UNSPEC:
986 case SOURCE_OR_DESTINATION:
987 $$.self = Connect_OR(
988 Connect_AND(
989 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
990 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
991 ),
992 Connect_AND(
993 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
994 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
995 )
996 );
997 break;
998 case SOURCE_AND_DESTINATION:
999 $$.self = Connect_AND(
1000 Connect_AND(
1001 NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
1002 NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
1003 ),
1004 Connect_AND(
1005 NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
1006 NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
1007 )
1008 );
1009 break;
1010 case DIR_IN:
1011 case DIR_OUT:
1012 case IN_SRC:
1013 case IN_DST:
1014 case OUT_SRC:
1015 case OUT_DST:
1016 yyerror("This token is not expected here!");
1017 YYABORT;
1018 break;
1019 default:
1020 /* should never happen */
1021 yyerror("Internal parser error");
1022 YYABORT;
1023 } // End of switch
1024
1025 }
1026
1027 | dqual IF NUMBER {
1028 if ( $3 > 0x00000000ffffffffLL ) {
1029 yyerror("Input interface number must 0..2^32");
1030 YYABORT;
1031 }
1032
1033 switch ( $$.direction ) {
1034 case DIR_UNSPEC:
1035 $$.self = Connect_OR(
1036 NewBlock(OffsetInOut, MaskInput, ($3 << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE, NULL),
1037 NewBlock(OffsetInOut, MaskOutput, ($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL)
1038 );
1039 break;
1040 case DIR_IN:
1041 $$.self = NewBlock(OffsetInOut, MaskInput, ($3 << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE, NULL);
1042 break;
1043 case DIR_OUT:
1044 $$.self = NewBlock(OffsetInOut, MaskOutput, ($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL);
1045 break;
1046 case SOURCE:
1047 case DESTINATION:
1048 case SOURCE_OR_DESTINATION:
1049 case SOURCE_AND_DESTINATION:
1050 case IN_SRC:
1051 case IN_DST:
1052 case OUT_SRC:
1053 case OUT_DST:
1054 yyerror("This token is not expected here!");
1055 YYABORT;
1056 break;
1057 default:
1058 /* should never happen */
1059 yyerror("Internal parser error");
1060 YYABORT;
1061 } // End of switch
1062
1063 }
1064
1065 | dqual VLAN NUMBER {
1066 $$.direction = $1.direction;
1067 if ( $3 > 65535 || $3 < 0 ) {
1068 yyerror("VLAN number of range 0..65535");
1069 YYABORT;
1070 }
1071
1072 switch ( $$.direction ) {
1073 case SOURCE:
1074 $$.self = NewBlock(OffsetVlan, MaskSrcVlan, ($3 << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL );
1075 break;
1076 case DESTINATION:
1077 $$.self = NewBlock(OffsetVlan, MaskDstVlan, ($3 << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL);
1078 break;
1079 case DIR_UNSPEC:
1080 case SOURCE_OR_DESTINATION:
1081 $$.self = Connect_OR(
1082 NewBlock(OffsetVlan, MaskSrcVlan, ($3 << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL ),
1083 NewBlock(OffsetVlan, MaskDstVlan, ($3 << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL)
1084 );
1085 break;
1086 case SOURCE_AND_DESTINATION:
1087 $$.self = Connect_AND(
1088 NewBlock(OffsetVlan, MaskSrcVlan, ($3 << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL ),
1089 NewBlock(OffsetVlan, MaskDstVlan, ($3 << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL)
1090 );
1091 break;
1092 case DIR_IN:
1093 case DIR_OUT:
1094 case IN_SRC:
1095 case IN_DST:
1096 case OUT_SRC:
1097 case OUT_DST:
1098 yyerror("This token is not expected here!");
1099 YYABORT;
1100 break;
1101 default:
1102 /* should never happen */
1103 yyerror("Internal parser error");
1104 YYABORT;
1105 } // End of switch
1106
1107 }
1108
1109 | dqual MAC STRING {
1110 uint64_t mac = VerifyMac($3);
1111 if ( mac == 0 ) {
1112 yyerror("Invalid MAC address format");
1113 YYABORT;
1114 }
1115 switch ( $$.direction ) {
1116 case DIR_UNSPEC: {
1117 uint32_t in, out;
1118 in = Connect_OR(
1119 NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1120 NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1121 );
1122 out = Connect_OR(
1123 NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1124 NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1125 );
1126 $$.self = Connect_OR(in, out);
1127 } break;
1128 case DIR_IN:
1129 $$.self = Connect_OR(
1130 NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1131 NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1132 );
1133 break;
1134 case DIR_OUT:
1135 $$.self = Connect_OR(
1136 NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1137 NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1138 );
1139 break;
1140 case SOURCE:
1141 $$.self = Connect_OR(
1142 NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1143 NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1144 );
1145 break;
1146 case DESTINATION:
1147 $$.self = Connect_OR(
1148 NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
1149 NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
1150 );
1151 break;
1152 case IN_SRC:
1153 $$.self = NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1154 break;
1155 case IN_DST:
1156 $$.self = NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1157 break;
1158 case OUT_SRC:
1159 $$.self = NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1160 break;
1161 case OUT_DST:
1162 $$.self = NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
1163 break;
1164 case SOURCE_OR_DESTINATION:
1165 case SOURCE_AND_DESTINATION:
1166 yyerror("This token is not expected here!");
1167 YYABORT;
1168 break;
1169 default:
1170 /* should never happen */
1171 yyerror("Internal parser error");
1172 YYABORT;
1173 } // End of switch
1174 }
1175
1176 | MPLS STRING comp NUMBER {
1177 if ( $4 > MPLSMAX ) {
1178 yyerror("MPLS value out of range");
1179 YYABORT;
1180 }
1181
1182 // search for label1 - label10
1183 if ( strncasecmp($2, "label", 5) == 0 ) {
1184 uint64_t mask;
1185 uint32_t offset, shift;
1186 char *s = &$2[5];
1187 if ( s == '\0' ) {
1188 yyerror("Missing label number");
1189 YYABORT;
1190 }
1191 int i = (int)strtol(s, (char **)NULL, 10);
1192
1193 switch (i) {
1194 case 1:
1195 offset = OffsetMPLS12;
1196 mask = MaskMPLSlabelOdd;
1197 shift = ShiftMPLSlabelOdd;
1198 break;
1199 case 2:
1200 offset = OffsetMPLS12;
1201 mask = MaskMPLSlabelEven;
1202 shift = ShiftMPLSlabelEven;
1203 break;
1204 case 3:
1205 offset = OffsetMPLS34;
1206 mask = MaskMPLSlabelOdd;
1207 shift = ShiftMPLSlabelOdd;
1208 break;
1209 case 4:
1210 offset = OffsetMPLS34;
1211 mask = MaskMPLSlabelEven;
1212 shift = ShiftMPLSlabelEven;
1213 break;
1214 case 5:
1215 offset = OffsetMPLS56;
1216 mask = MaskMPLSlabelOdd;
1217 shift = ShiftMPLSlabelOdd;
1218 break;
1219 case 6:
1220 offset = OffsetMPLS56;
1221 mask = MaskMPLSlabelEven;
1222 shift = ShiftMPLSlabelEven;
1223 break;
1224 case 7:
1225 offset = OffsetMPLS78;
1226 mask = MaskMPLSlabelOdd;
1227 shift = ShiftMPLSlabelOdd;
1228 break;
1229 case 8:
1230 offset = OffsetMPLS78;
1231 mask = MaskMPLSlabelEven;
1232 shift = ShiftMPLSlabelEven;
1233 break;
1234 case 9:
1235 offset = OffsetMPLS910;
1236 mask = MaskMPLSlabelOdd;
1237 shift = ShiftMPLSlabelOdd;
1238 break;
1239 case 10:
1240 offset = OffsetMPLS910;
1241 mask = MaskMPLSlabelEven;
1242 shift = ShiftMPLSlabelEven;
1243 break;
1244 default:
1245 yyerror("MPLS label out of range 1..10");
1246 YYABORT;
1247 }
1248 $$.self = NewBlock(offset, mask, ($4 << shift) & mask, $3.comp, FUNC_NONE, NULL );
1249
1250 } else if ( strcasecmp($2, "eos") == 0 ) {
1251 // match End of Stack label
1252 $$.self = NewBlock(0, AnyMask, $4 << 4, $3.comp, FUNC_MPLS_EOS, NULL );
1253
1254 } else if ( strncasecmp($2, "exp", 3) == 0 ) {
1255 uint64_t mask;
1256 uint32_t offset, shift;
1257 char *s = &$2[3];
1258 if ( s == '\0' ) {
1259 yyerror("Missing label number");
1260 YYABORT;
1261 }
1262 int i = (int)strtol(s, (char **)NULL, 10);
1263
1264 if ( $4 < 0 || $4 > 7 ) {
1265 yyerror("MPLS exp value out of range");
1266 YYABORT;
1267 }
1268
1269 switch (i) {
1270 case 1:
1271 offset = OffsetMPLS12;
1272 mask = MaskMPLSexpOdd;
1273 shift = ShiftMPLSexpOdd;
1274 break;
1275 case 2:
1276 offset = OffsetMPLS12;
1277 mask = MaskMPLSexpEven;
1278 shift = ShiftMPLSexpEven;
1279 break;
1280 case 3:
1281 offset = OffsetMPLS34;
1282 mask = MaskMPLSexpOdd;
1283 shift = ShiftMPLSexpOdd;
1284 break;
1285 case 4:
1286 offset = OffsetMPLS34;
1287 mask = MaskMPLSexpEven;
1288 shift = ShiftMPLSexpEven;
1289 break;
1290 case 5:
1291 offset = OffsetMPLS56;
1292 mask = MaskMPLSexpOdd;
1293 shift = ShiftMPLSexpOdd;
1294 break;
1295 case 6:
1296 offset = OffsetMPLS56;
1297 mask = MaskMPLSexpEven;
1298 shift = ShiftMPLSexpEven;
1299 break;
1300 case 7:
1301 offset = OffsetMPLS78;
1302 mask = MaskMPLSexpOdd;
1303 shift = ShiftMPLSexpOdd;
1304 break;
1305 case 8:
1306 offset = OffsetMPLS78;
1307 mask = MaskMPLSexpEven;
1308 shift = ShiftMPLSexpEven;
1309 break;
1310 case 9:
1311 offset = OffsetMPLS910;
1312 mask = MaskMPLSexpOdd;
1313 shift = ShiftMPLSexpOdd;
1314 break;
1315 case 10:
1316 offset = OffsetMPLS910;
1317 mask = MaskMPLSexpEven;
1318 shift = ShiftMPLSexpEven;
1319 break;
1320 default:
1321 yyerror("MPLS label out of range 1..10");
1322 YYABORT;
1323 }
1324 $$.self = NewBlock(offset, mask, $4 << shift, $3.comp, FUNC_NONE, NULL );
1325
1326 } else {
1327 yyerror("Unknown MPLS option");
1328 YYABORT;
1329 }
1330 }
1331 | MPLS ANY NUMBER {
1332 uint32_t *opt = malloc(sizeof(uint32_t));
1333 if ( $3 > MPLSMAX ) {
1334 yyerror("MPLS value out of range");
1335 YYABORT;
1336 }
1337 if ( opt == NULL) {
1338 yyerror("malloc() error");
1339 YYABORT;
1340 }
1341 *opt = $3 << 4;
1342 $$.self = NewBlock(0, AnyMask, $3 << 4, CMP_EQ, FUNC_MPLS_ANY, opt );
1343
1344 }
1345 | FWDSTAT NUMBER {
1346 if ( $2 > 255 ) {
1347 yyerror("Forwarding status of range 0..255");
1348 YYABORT;
1349 }
1350 $$.self = NewBlock(OffsetStatus, MaskStatus, ($2 << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);
1351 }
1352
1353 | FWDSTAT STRING {
1354 uint64_t id = Get_fwd_status_id($2);
1355 if (id == 256 ) {
1356 yyerror("Unknown forwarding status");
1357 YYABORT;
1358 }
1359
1360 $$.self = NewBlock(OffsetStatus, MaskStatus, (id << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);
1361
1362 }
1363
1364 | DIR NUMBER {
1365 if ( $2 > 2 ) {
1366 yyerror("Flow direction status of range 0, 1");
1367 YYABORT;
1368 }
1369 $$.self = NewBlock(OffsetDir, MaskDir, ($2 << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);
1370
1371 }
1372
1373 | DIR STRING {
1374 uint64_t dir = 0xFF;
1375 if ( strcasecmp($2, "ingress") == 0 )
1376 dir = 0;
1377 else if ( strcasecmp($2, "egress") == 0 )
1378 dir = 1;
1379 else {
1380 yyerror("Flow direction status of range ingress, egress");
1381 YYABORT;
1382 }
1383
1384 $$.self = NewBlock(OffsetDir, MaskDir, (dir << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);
1385
1386 }
1387
1388 /* iplist definition */
1389 iplist: STRING {
1390 int i, af, bytes, ret;
1391 struct IPListNode *node;
1392
1393 IPlist_t *root = malloc(sizeof(IPlist_t));
1394
1395 if ( root == NULL) {
1396 yyerror("malloc() error");
1397 YYABORT;
1398 }
1399 RB_INIT(root);
1400
1401 ret = parse_ip(&af, $1, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
1402
1403 if ( ret == 0 ) {
1404 yyerror("Invalid IP address");
1405 YYABORT;
1406 }
1407 // ret == -1 will never happen here, as ALLOW_LOOKUP is set
1408
1409 if ( ret != -2 ) {
1410 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1411 yyerror("incomplete IP address");
1412 YYABORT;
1413 }
1414
1415 for ( i=0; i<num_ip; i++ ) {
1416 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1417 yyerror("malloc() error");
1418 YYABORT;
1419 }
1420 node->ip[0] = IPstack[2*i];
1421 node->ip[1] = IPstack[2*i+1];
1422 node->mask[0] = 0xffffffffffffffffLL;
1423 node->mask[1] = 0xffffffffffffffffLL;
1424 RB_INSERT(IPtree, root, node);
1425 }
1426
1427 }
1428 $$ = (void *)root;
1429
1430 }
1431
1432 iplist: STRING '/' NUMBER {
1433 int af, bytes, ret;
1434 struct IPListNode *node;
1435
1436 IPlist_t *root = malloc(sizeof(IPlist_t));
1437
1438 if ( root == NULL) {
1439 yyerror("malloc() error");
1440 YYABORT;
1441 }
1442 RB_INIT(root);
1443
1444 ret = parse_ip(&af, $1, IPstack, &bytes, STRICT_IP, &num_ip);
1445
1446 if ( ret == 0 ) {
1447 yyerror("Invalid IP address");
1448 YYABORT;
1449 }
1450 // ret == -1 will never happen here, as ALLOW_LOOKUP is set
1451
1452 if ( ret != -2 ) {
1453 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1454 yyerror("incomplete IP address");
1455 YYABORT;
1456 }
1457
1458 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1459 yyerror("malloc() error");
1460 YYABORT;
1461 }
1462
1463 if ( af == PF_INET ) {
1464 node->mask[0] = 0xffffffffffffffffLL;
1465 node->mask[1] = 0xffffffffffffffffLL << ( 32 - $3 );
1466 } else { // PF_INET6
1467 if ( $3 > 64 ) {
1468 node->mask[0] = 0xffffffffffffffffLL;
1469 node->mask[1] = 0xffffffffffffffffLL << ( 128 - $3 );
1470 } else {
1471 node->mask[0] = 0xffffffffffffffffLL << ( 64 - $3 );
1472 node->mask[1] = 0;
1473 }
1474 }
1475
1476 node->ip[0] = IPstack[0] & node->mask[0];
1477 node->ip[1] = IPstack[1] & node->mask[1];
1478
1479 RB_INSERT(IPtree, root, node);
1480
1481 }
1482 $$ = (void *)root;
1483
1484 }
1485
1486 | iplist STRING {
1487 int i, af, bytes, ret;
1488 struct IPListNode *node;
1489
1490 ret = parse_ip(&af, $2, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
1491
1492 if ( ret == 0 ) {
1493 yyerror("Invalid IP address");
1494 YYABORT;
1495 }
1496 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1497 yyerror("incomplete IP address");
1498 YYABORT;
1499 }
1500
1501 // ret == - 2 means lookup failure
1502 if ( ret != -2 ) {
1503 for ( i=0; i<num_ip; i++ ) {
1504 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1505 yyerror("malloc() error");
1506 YYABORT;
1507 }
1508 node->ip[0] = IPstack[2*i];
1509 node->ip[1] = IPstack[2*i+1];
1510 node->mask[0] = 0xffffffffffffffffLL;
1511 node->mask[1] = 0xffffffffffffffffLL;
1512
1513 RB_INSERT(IPtree, (IPlist_t *)$$, node);
1514 }
1515 }
1516 }
1517
1518 | iplist STRING '/' NUMBER {
1519 int af, bytes, ret;
1520 struct IPListNode *node;
1521
1522 ret = parse_ip(&af, $2, IPstack, &bytes, STRICT_IP, &num_ip);
1523
1524 if ( ret == 0 ) {
1525 yyerror("Invalid IP address");
1526 YYABORT;
1527 }
1528 if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
1529 yyerror("incomplete IP address");
1530 YYABORT;
1531 }
1532
1533 // ret == - 2 means lookup failure
1534 if ( ret != -2 ) {
1535 if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
1536 yyerror("malloc() error");
1537 YYABORT;
1538 }
1539 if ( af == PF_INET ) {
1540 node->mask[0] = 0xffffffffffffffffLL;
1541 node->mask[1] = 0xffffffffffffffffLL << ( 32 - $4 );
1542 } else { // PF_INET6
1543 if ( $4 > 64 ) {
1544 node->mask[0] = 0xffffffffffffffffLL;
1545 node->mask[1] = 0xffffffffffffffffLL << ( 128 - $4 );
1546 } else {
1547 node->mask[0] = 0xffffffffffffffffLL << ( 64 - $4 );
1548 node->mask[1] = 0;
1549 }
1550 }
1551
1552 node->ip[0] = IPstack[0] & node->mask[0];
1553 node->ip[1] = IPstack[1] & node->mask[1];
1554
1555 RB_INSERT(IPtree, (IPlist_t *)$$, node);
1556 }
1557 }
1558
1559 ;
1560
1561 /* ULlist definition */
1562 ullist: NUMBER {
1563 struct ULongListNode *node;
1564
1565 if ( $1 > 65535 ) {
1566 yyerror("Value outside of range 0..65535");
1567 YYABORT;
1568 }
1569 ULongtree_t *root = malloc(sizeof(ULongtree_t));
1570
1571 if ( root == NULL) {
1572 yyerror("malloc() error");
1573 YYABORT;
1574 }
1575 RB_INIT(root);
1576
1577 if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
1578 yyerror("malloc() error");
1579 YYABORT;
1580 }
1581 node->value = $1;
1582
1583 RB_INSERT(ULongtree, root, node);
1584 $$ = (void *)root;
1585 }
1586 | ullist NUMBER {
1587 struct ULongListNode *node;
1588
1589 if ( $2 > 65535 ) {
1590 yyerror("Value outside of range 0..65535");
1591 YYABORT;
1592 }
1593 if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
1594 yyerror("malloc() error");
1595 YYABORT;
1596 }
1597 node->value = $2;
1598 RB_INSERT(ULongtree, (ULongtree_t *)$$, node);
1599 }
1600 ;
1601
1602 /* scaling qualifiers */
1603
1604 /* comparator qualifiers */
1605 comp: { $$.comp = CMP_EQ; }
1606 | EQ { $$.comp = CMP_EQ; }
1607 | LT { $$.comp = CMP_LT; }
1608 | GT { $$.comp = CMP_GT; }
1609 ;
1610
1611 /* 'direction' qualifiers */
1612 dqual: { $$.direction = DIR_UNSPEC; }
1613 | SRC { $$.direction = SOURCE; }
1614 | DST { $$.direction = DESTINATION; }
1615 | SRC OR DST { $$.direction = SOURCE_OR_DESTINATION; }
1616 | DST OR SRC { $$.direction = SOURCE_OR_DESTINATION; }
1617 | SRC AND DST { $$.direction = SOURCE_AND_DESTINATION; }
1618 | DST AND SRC { $$.direction = SOURCE_AND_DESTINATION; }
1619 | IN { $$.direction = DIR_IN; }
1620 | OUT { $$.direction = DIR_OUT; }
1621 | IN SRC { $$.direction = IN_SRC; }
1622 | IN DST { $$.direction = IN_DST; }
1623 | OUT SRC { $$.direction = OUT_SRC; }
1624 | OUT DST { $$.direction = OUT_DST; }
1625 ;
1626
1627 expr: term { $$ = $1.self; }
1628 | expr OR expr { $$ = Connect_OR($1, $3); }
1629 | expr AND expr { $$ = Connect_AND($1, $3); }
1630 | NOT expr %prec NEGATE { $$ = Invert($2); }
1631 | '(' expr ')' { $$ = $2; }
1632 ;
1633
1634 %%
1635
1636 static void yyerror(char *msg) {
1637
1638 if ( FilterFilename )
1639 snprintf(yyerror_buff, 255 ,"File '%s' line %d: %s at '%s'", FilterFilename, lineno, msg, yytext);
1640 else
1641 snprintf(yyerror_buff, 255, "Line %d: %s at '%s'", lineno, msg, yytext);
1642
1643 yyerror_buff[255] = '\0';
1644 fprintf(stderr, "%s\n", yyerror_buff);
1645
1646 } /* End of yyerror */
1647
1648 static uint32_t ChainHosts(uint64_t *hostlist, int num_records, int type) {
1649 uint32_t offset_a, offset_b, i, j, block;
1650
1651 if ( type == SOURCE ) {
1652 offset_a = OffsetSrcIPv6a;
1653 offset_b = OffsetSrcIPv6b;
1654 } else {
1655 offset_a = OffsetDstIPv6a;
1656 offset_b = OffsetDstIPv6b;
1657 }
1658
1659 i = 0;
1660 block = Connect_AND(
1661 NewBlock(offset_b, MaskIPv6, hostlist[i+1] , CMP_EQ, FUNC_NONE, NULL ),
1662 NewBlock(offset_a, MaskIPv6, hostlist[i] , CMP_EQ, FUNC_NONE, NULL )
1663 );
1664 i += 2;
1665 for ( j=1; j<num_records; j++ ) {
1666 uint32_t b = Connect_AND(
1667 NewBlock(offset_b, MaskIPv6, hostlist[i+1] , CMP_EQ, FUNC_NONE, NULL ),
1668 NewBlock(offset_a, MaskIPv6, hostlist[i] , CMP_EQ, FUNC_NONE, NULL )
1669 );
1670 block = Connect_OR(block, b);
1671 i += 2;
1672 }
1673
1674 return block;
1675
1676 } // End of ChainHosts
1677
1678 uint64_t VerifyMac(char *s) {
1679 uint64_t mac;
1680 size_t slen = strlen(s);
1681 long l;
1682 char *p, *q, *r;
1683 int i;
1684
1685 if ( slen > 17 )
1686 return 0;
1687
1688 for (i=0; i<slen; i++ ) {
1689 if ( !isxdigit(s[i]) && s[i] != ':' )
1690 return 0;
1691 }
1692
1693 p = strdup(s);
1694 if ( !p ) {
1695 yyerror("malloc() error");
1696 return 0;
1697 }
1698
1699 mac = 0;
1700 i = 0; // number of MAC octets must be 6
1701 r = p;
1702 q = strchr(r, ':');
1703 while ( r && i < 6 ) {
1704 if ( q )
1705 *q = '\0';
1706 l = strtol(r, NULL, 16);
1707 if ( l > 255 ) {
1708 free(p);
1709 return 0;
1710 }
1711
1712 mac = ( mac << 8 ) | (l & 0xFF );
1713 i++;
1714
1715 if ( q ) {
1716 r = ++q;
1717 q = strchr(r, ':');
1718 } else
1719 r = NULL;
1720 }
1721
1722 if ( i != 6 )
1723 return 0;
1724
1725 return mac;
1726
1727 } // End of VerifyMac
1728
1729 /*
1730
1731 mpls 1 == 3
1732 mpls label1 == 3
1733 mpls any == 4
1734
1735
1736
1737
1738 */
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)
6969 extern int verbose;
7070 extern extension_descriptor_t extension_descriptor[];
7171 extern uint32_t default_sampling;
72 extern uint32_t overwrite_sampling;
7273
7374 /* module limited globals */
7475 static extension_info_t v5_extension_info; // common for all v5 records
9394 // exporter identifier
9495 uint32_t version;
9596 uint16_t engine_tag;
97 ip_addr_t ip;
98 uint32_t sa_family;
99
96100 uint16_t align;
97101 uint16_t sampling_mode;
98102 uint16_t sampling_interval;
187191
188192 // search the appropriate exporter engine
189193 while ( *e ) {
190 if ( (*e)->version == 5 && (*e)->engine_tag == engine_tag )
194 if ( (*e)->version == 5 && (*e)->engine_tag == engine_tag &&
195 (*e)->ip.v6[0] == fs->ip.v6[0] && (*e)->ip.v6[1] == fs->ip.v6[1])
191196 return *e;
192197 e = &((*e)->next);
193198 }
200205 }
201206 memset((void *)(*e), 0, sizeof(exporter_v5_t));
202207 (*e)->engine_tag = engine_tag;
208 (*e)->ip.v6[0] = fs->ip.v6[0];
209 (*e)->ip.v6[1] = fs->ip.v6[1];
210 (*e)->sa_family = fs->sa_family;
203211 (*e)->align = 0;
204212 (*e)->sampling_mode = (0xC000 & ntohs(header->sampling_interval)) >> 14;
205213 (*e)->sampling_interval = 0x3fff & ntohs(header->sampling_interval);
245253 (*e)->extension_map->map_id, ipstr, (*e)->sampling_mode ,(*e)->sampling_interval);
246254 syslog(LOG_INFO, "Process_v5: New exporter: engine id %u, type %u, IP: %s, Sampling Mode: %i, Sampling Interval: %i\n",
247255 ( engine_tag & 0xFF ), ( (engine_tag >> 8) & 0xFF ), ipstr, (*e)->sampling_mode ,(*e)->sampling_interval );
256
257 if ( overwrite_sampling > 0 ) {
258 (*e)->sampling_interval = overwrite_sampling;
259 syslog(LOG_INFO, "Process_v5: Hard overwrite sampling rate: %llu\n", (*e)->sampling_interval);
260 }
248261
249262 return (*e);
250263
286299 // this many data to process
287300 size_left = in_buff_cnt;
288301
289 common_record = fs->nffile.writeto;
302 common_record = fs->nffile->writeto;
290303 done = 0;
291304 while ( !done ) {
292305 v5_block_t *v5_block;
297310 count = ntohs(v5_header->count);
298311 if ( count > NETFLOW_V5_MAX_RECORDS ) {
299312 syslog(LOG_ERR,"Process_v5: Unexpected record count in header: %i. Abort v5/v7 record processing", count);
300 fs->nffile.writeto = (void *)common_record;
313 fs->nffile->writeto = (void *)common_record;
301314 return;
302315 }
303316
304317 // input buffer size check for all expected records
305318 if ( size_left < ( NETFLOW_V5_HEADER_LENGTH + count * flow_record_length) ) {
306319 syslog(LOG_ERR,"Process_v5: Not enough data to process v5 record. Abort v5/v7 record processing");
307 fs->nffile.writeto = (void *)common_record;
320 fs->nffile->writeto = (void *)common_record;
308321 return;
309322 }
310323
311324 // output buffer size check for all expected records
312 if ( !CheckBufferSpace(&(fs->nffile), count * v5_output_record_size) ) {
325 if ( !CheckBufferSpace(fs->nffile, count * v5_output_record_size) ) {
313326 // fishy! - should never happen. maybe disk full?
314327 syslog(LOG_ERR,"Process_v5: output buffer size error. Abort v5/v7 record processing");
315328 return;
316329 }
317330
318331 // map output record to memory buffer
319 common_record = (common_record_t *)fs->nffile.writeto;
332 common_record = (common_record_t *)fs->nffile->writeto;
320333 v5_block = (v5_block_t *)common_record->data;
321334
322335 // sequence check
440453 if ( First > Last )
441454 /* First in msec, in case of msec overflow, between start and end */
442455 start_time = boot_time - 0x100000000LL + (uint64_t)First;
456 if ( start_time < boot_time ) {
457 uint32_t _t;
458 syslog(LOG_ERR,"Process_v5: Unexpected time swap: First 0x%xll smaller than boot time: 0x%xll", start_time, boot_time);
459 // assume bug, some users reported - swap time stamps
460 _t= First;
461 First = Last;
462 Last = _t;
463 start_time = (uint64_t)First + boot_time;
464 }
443465 else
444466 start_time = (uint64_t)First + boot_time;
445467
446468 /* end time in msecs */
447469 end_time = (uint64_t)Last + boot_time;
448470
471 // if overflow happened after flow ended but before got exported
472 if ( Last > v5_header->SysUptime ) {
473 start_time -= 0x100000000LL;
474 end_time -= 0x100000000LL;
475 }
449476
450477 common_record->first = start_time/1000;
451478 common_record->msec_first = start_time - common_record->first*1000;
499526 if ( verbose ) {
500527 master_record_t master_record;
501528 ExpandRecord_v2((common_record_t *)common_record, &v5_extension_info, &master_record);
502 format_file_block_record(&master_record, &string, 0, 0);
529 format_file_block_record(&master_record, &string, 0);
503530 printf("%s\n", string);
504531 }
505532
507534 v5_record = (netflow_v5_record_t *)((pointer_addr_t)v5_record + flow_record_length);
508535
509536 if ( ((pointer_addr_t)data_ptr - (pointer_addr_t)common_record) != v5_output_record_size ) {
510 printf("Panic size check: ptr diff: %u, record size: %u\n", ((pointer_addr_t)data_ptr - (pointer_addr_t)common_record), v5_output_record_size );
537 printf("Panic size check: ptr diff: %llu, record size: %u\n", ((pointer_addr_t)data_ptr - (pointer_addr_t)common_record), v5_output_record_size );
511538 abort();
512539 }
513540 // advance to next output record
515542 v5_block = (v5_block_t *)common_record->data;
516543
517544 // buffer size sanity check - should never happen, but check it anyway
518 bsize = (pointer_addr_t)common_record - (pointer_addr_t)fs->nffile.block_header;
545 bsize = (pointer_addr_t)common_record - (pointer_addr_t)fs->nffile->block_header - sizeof(data_block_header_t);
519546 if ( bsize >= BUFFSIZE ) {
547 syslog(LOG_ERR,"### Software error ###: %s line %d", __FILE__, __LINE__);
520548 syslog(LOG_ERR,"Process_v5: Output buffer overflow! Flush buffer and skip records.");
521 syslog(LOG_ERR,"Buffer size: size: %u, bsize: %u > %u", fs->nffile.block_header->size, bsize, BUFFSIZE);
549 syslog(LOG_ERR,"Buffer size: size: %u, bsize: %u > %u", fs->nffile->block_header->size, bsize, BUFFSIZE);
522550 // reset buffer
523 fs->nffile.block_header->size = 0;
524 fs->nffile.block_header->NumRecords = 0;
525 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
551 fs->nffile->block_header->size = 0;
552 fs->nffile->block_header->NumRecords = 0;
553 fs->nffile->writeto = (void *)((pointer_addr_t)fs->nffile->block_header + sizeof(data_block_header_t) );
526554 return;
527555 }
528556
529557 } // End of foreach v5 record
530558
531559 // update file record size ( -> output buffer size )
532 fs->nffile.block_header->NumRecords += count;
533 fs->nffile.block_header->size += count * v5_output_record_size;
534 fs->nffile.writeto = (void *)common_record;
560 fs->nffile->block_header->NumRecords += count;
561 fs->nffile->block_header->size += count * v5_output_record_size;
562 fs->nffile->writeto = (void *)common_record;
535563
536564 // still to go for this many input bytes
537565 size_left -= NETFLOW_V5_HEADER_LENGTH + count * flow_record_length;
625625 if ( map_table[i] == 0 )
626626 continue;
627627
628 extension_map->size += sizeof(uint16_t);
629 extension_map->extension_size += extension_descriptor[i].size;
630628 switch(i) {
631629 case EX_IO_SNMP_2:
632630 case EX_IO_SNMP_4:
633631 // 2 byte length
634 if ( input_template[NF9_IN_BYTES].length <= 2 || input_template[NF9_OUTPUT_SNMP].length <= 2) {
632 if ( input_template[NF9_INPUT_SNMP].length <= 2 || input_template[NF9_OUTPUT_SNMP].length <= 2) {
635633 FillElement( table, NF9_INPUT_SNMP, &offset);
636634 FillElement( table, NF9_OUTPUT_SNMP, &offset);
637635 map_index = EX_IO_SNMP_2;
702700 break;
703701 case EX_OUT_BYTES_4:
704702 case EX_OUT_BYTES_8:
705 if ( input_template[NF9_OUT_PKTS].length <= 4 ) {
703 if ( input_template[NF9_OUT_BYTES].length <= 4 ) {
706704 FillElement( table, NF9_OUT_BYTES, &offset);
707705 map_index = EX_OUT_BYTES_4;
708706 } else {
770768 // unused fill element for 32bit alignment
771769 break;
772770 }
771 extension_map->size += sizeof(uint16_t);
772 extension_map->extension_size += extension_descriptor[map_index].size;
773773
774774 // found extension in map_index must be the same as in map - otherwise map is dirty
775775 if ( extension_map->ex_id[next_extension] != map_index ) {
894894 // do we store this extension? enabled != 0
895895 // more than 1 v9 tag may map to an extension - so count this extension once only
896896 if ( ext_id && extension_descriptor[ext_id].enabled ) {
897 dbg_printf("Type: %u, Length %u => Extension: %u\n", field_type, field_length, ext_id);
897898 if ( map_table[ext_id] == 0 ) {
898899 map_table[ext_id] = 1;
899900 num_extensions++;
900901 }
901 dbg_printf("Type: %u, Length %u => Extension: %u\n", field_type, field_length, ext_id);
902902 } else {
903903 dbg_printf("Type: %u, Length %u\n", field_type, field_length);
904904 }
11061106 }
11071107
11081108 // check for enough space in output buffer
1109 if ( !CheckBufferSpace(&(fs->nffile), table->output_record_size) ) {
1109 if ( !CheckBufferSpace(fs->nffile, table->output_record_size) ) {
11101110 // this should really never occur, because the buffer gets flushed ealier
11111111 syslog(LOG_ERR,"Process_v9: output buffer size error. Abort v9 record processing");
11121112 dbg_printf("Process_v9: output buffer size error. Abort v9 record processing");
11151115 processed_records++;
11161116
11171117 // map file record to output buffer
1118 data_record = (common_record_t *)fs->nffile.writeto;
1118 data_record = (common_record_t *)fs->nffile->writeto;
11191119 // map output buffer as a byte array
11201120 out = (uint8_t *)data_record;
11211121
13621362 if ( verbose ) {
13631363 master_record_t master_record;
13641364 ExpandRecord_v2((common_record_t *)data_record, &(table->extension_info), &master_record);
1365 format_file_block_record(&master_record, &string, 0, 0);
1365 format_file_block_record(&master_record, &string, 0);
13661366 printf("%s\n", string);
13671367 }
13681368
1369 fs->nffile.block_header->size += data_record->size;
1370 fs->nffile.block_header->NumRecords++;
1371 fs->nffile.writeto = (common_record_t *)((pointer_addr_t)data_record + data_record->size);
1369 fs->nffile->block_header->size += data_record->size;
1370 fs->nffile->block_header->NumRecords++;
1371 fs->nffile->writeto = (common_record_t *)((pointer_addr_t)data_record + data_record->size);
13721372
13731373 // advance input
13741374 size_left -= table->input_record_size;
13751375 in += table->input_record_size;
13761376
13771377 // buffer size sanity check
1378 if ( fs->nffile.block_header->size > BUFFSIZE ) {
1378 if ( fs->nffile->block_header->size > BUFFSIZE ) {
13791379 // should never happen
13801380 syslog(LOG_ERR,"### Software error ###: %s line %d", __FILE__, __LINE__);
13811381 syslog(LOG_ERR,"Process v9: Output buffer overflow! Flush buffer and skip records.");
1382 syslog(LOG_ERR,"Buffer size: %u > %u", fs->nffile.block_header->size, BUFFSIZE);
1382 syslog(LOG_ERR,"Buffer size: %u > %u", fs->nffile->block_header->size, BUFFSIZE);
13831383
13841384 // reset buffer
1385 fs->nffile.block_header->size = 0;
1386 fs->nffile.block_header->NumRecords = 0;
1387 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
1385 fs->nffile->block_header->size = 0;
1386 fs->nffile->block_header->NumRecords = 0;
1387 fs->nffile->writeto = (void *)((pointer_addr_t)fs->nffile->block_header + sizeof(data_block_header_t) );
13881388 return;
13891389 }
13901390
15411541 }
15421542
15431543 #ifdef DEVEL
1544 if ( (ptrdiff_t)fs->nffile.writeto & 0x3 ) {
1544 if ( (ptrdiff_t)fs->nffile->writeto & 0x3 ) {
15451545 fprintf(stderr, "PANIC: alignment error!! \n");
15461546 exit(255);
15471547 }
22282228
22292229 #ifdef DEVEL
22302230 // char *string;
2231 // format_file_block_record(master_record, 1, &string, 0, 0);
2231 // format_file_block_record(master_record, 1, &string, 0);
22322232 // dbg_printf("%s\n", string);
22332233 #endif
22342234
5252 #endif
5353
5454 #include "nffile.h"
55 #include "panonymizer.h"
5655 #include "nf_common.h"
5756 #include "util.h"
5857
7271 static int max_format_index = 0;
7372 static int format_index = 0;
7473
75 static int do_anonymize = 0;
7674 static int do_tag = 0;
7775 static int long_v6 = 0;
7876 static int no_scale = 0;
533531
534532 } // End of Get_fwd_status_name
535533
536 void format_file_block_header(void *header, char ** s, int anon, int tag) {
534 void format_file_block_header(void *header, char ** s, int tag) {
537535 data_block_header_t *h = (data_block_header_t *)header;
538536
539537 snprintf(data_string,STRINGSIZE-1 ,""
548546
549547 } // End of format_file_block_header
550548
551 void format_file_block_record(void *record, char ** s, int anon, int tag) {
552 uint64_t anon_ip[2];
549 void format_file_block_record(void *record, char ** s, int tag) {
553550 char *_s, as[IP_STRING_LEN], ds[IP_STRING_LEN], datestr1[64], datestr2[64], flags_str[16];
554551 char s_snet[IP_STRING_LEN], s_dnet[IP_STRING_LEN];
555552 int i, id;
565562 uint64_t snet[2];
566563 uint64_t dnet[2];
567564
568 if ( anon ) {
569 anonymize_v6(r->v6.srcaddr, anon_ip);
570 r->v6.srcaddr[0] = anon_ip[0];
571 r->v6.srcaddr[1] = anon_ip[1];
572
573 anonymize_v6(r->v6.dstaddr, anon_ip);
574 r->v6.dstaddr[0] = anon_ip[0];
575 r->v6.dstaddr[1] = anon_ip[1];
576 }
577565 // remember IPs for network
578566 snet[0] = r->v6.srcaddr[0];
579567 snet[1] = r->v6.srcaddr[1];
621609
622610 } else { // IPv4
623611 uint32_t snet, dnet;
624 if ( anon ) {
625 r->v4.srcaddr = anonymize(r->v4.srcaddr);
626 r->v4.dstaddr = anonymize(r->v4.dstaddr);
627 }
628612 snet = r->v4.srcaddr;
629613 dnet = r->v4.dstaddr;
630614 r->v4.srcaddr = htonl(r->v4.srcaddr);
728712 break;
729713 case EX_NEXT_HOP_v4:
730714 as[0] = 0;
731 if ( anon ) {
732 r->ip_nexthop.v4 = anonymize(r->ip_nexthop.v4);
733 }
734715 r->ip_nexthop.v4 = htonl(r->ip_nexthop.v4);
735716 inet_ntop(AF_INET, &r->ip_nexthop.v4, as, sizeof(as));
736717 as[IP_STRING_LEN-1] = 0;
745726 break;
746727 case EX_NEXT_HOP_v6:
747728 as[0] = 0;
748 if ( anon ) {
749 anonymize_v6(r->ip_nexthop.v6, anon_ip);
750 r->ip_nexthop.v6[0] = anon_ip[0];
751 r->ip_nexthop.v6[1] = anon_ip[1];
752 }
753729 r->ip_nexthop.v6[0] = htonll(r->ip_nexthop.v6[0]);
754730 r->ip_nexthop.v6[1] = htonll(r->ip_nexthop.v6[1]);
755731 inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as));
768744 break;
769745 case EX_NEXT_HOP_BGP_v4:
770746 as[0] = 0;
771 if ( anon ) {
772 r->bgp_nexthop.v4 = anonymize(r->bgp_nexthop.v4);
773 }
774747 r->bgp_nexthop.v4 = htonl(r->bgp_nexthop.v4);
775748 inet_ntop(AF_INET, &r->bgp_nexthop.v4, as, sizeof(as));
776749 as[IP_STRING_LEN-1] = 0;
785758 break;
786759 case EX_NEXT_HOP_BGP_v6:
787760 as[0] = 0;
788 if ( anon ) {
789 anonymize_v6(r->bgp_nexthop.v6, anon_ip);
790 r->bgp_nexthop.v6[0] = anon_ip[0];
791 r->bgp_nexthop.v6[1] = anon_ip[1];
792 }
793761 r->bgp_nexthop.v6[0] = htonll(r->bgp_nexthop.v6[0]);
794762 r->bgp_nexthop.v6[1] = htonll(r->bgp_nexthop.v6[1]);
795763 inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as));
893861 } break;
894862 case EX_ROUTER_IP_v4:
895863 as[0] = 0;
896 if ( anon ) {
897 r->ip_router.v4 = anonymize(r->ip_router.v4);
898 }
899864 r->ip_router.v4 = htonl(r->ip_router.v4);
900865 inet_ntop(AF_INET, &r->ip_router.v4, as, sizeof(as));
901866 as[IP_STRING_LEN-1] = 0;
910875 break;
911876 case EX_ROUTER_IP_v6:
912877 as[0] = 0;
913 if ( anon ) {
914 anonymize_v6(r->ip_router.v6, anon_ip);
915 r->ip_router.v6[0] = anon_ip[0];
916 r->ip_router.v6[1] = anon_ip[1];
917 }
918878 r->ip_router.v6[0] = htonll(r->ip_router.v6[0]);
919879 r->ip_router.v6[1] = htonll(r->ip_router.v6[1]);
920880 inet_ntop(AF_INET6, &r->ip_router.v6, as, sizeof(as));
954914
955915 } // End of format_file_block_record
956916
957 void flow_record_to_pipe(void *record, char ** s, int anon, int tag) {
958 uint64_t anon_ip[2];
917 void flow_record_to_pipe(void *record, char ** s, int tag) {
959918 uint32_t sa[4], da[4];
960919 int af;
961920 master_record_t *r = (master_record_t *)record;
962921
963922 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
964 if ( anon ) {
965 anonymize_v6(r->v6.srcaddr, anon_ip);
966 r->v6.srcaddr[0] = anon_ip[0];
967 r->v6.srcaddr[1] = anon_ip[1];
968
969 anonymize_v6(r->v6.dstaddr, anon_ip);
970 r->v6.dstaddr[0] = anon_ip[0];
971 r->v6.dstaddr[1] = anon_ip[1];
972 }
973923 af = PF_INET6;
974924 } else { // IPv4
975 if ( anon ) {
976 r->v4.srcaddr = anonymize(r->v4.srcaddr);
977 r->v4.dstaddr = anonymize(r->v4.dstaddr);
978 }
979925 af = PF_INET;
980926 }
981927
1002948
1003949 } // End of flow_record_pipe
1004950
1005 void flow_record_to_csv(void *record, char ** s, int anon, int tag) {
1006 uint64_t anon_ip[2];
951 void flow_record_to_csv(void *record, char ** s, int tag) {
1007952 char *_s, as[IP_STRING_LEN], ds[IP_STRING_LEN];
1008953 char proto_str[MAX_PROTO_STR], datestr1[64], datestr2[64], flags_str[16];
1009954 char s_snet[IP_STRING_LEN], s_dnet[IP_STRING_LEN];
1018963 uint64_t snet[2];
1019964 uint64_t dnet[2];
1020965
1021 if ( anon ) {
1022 anonymize_v6(r->v6.srcaddr, anon_ip);
1023 r->v6.srcaddr[0] = anon_ip[0];
1024 r->v6.srcaddr[1] = anon_ip[1];
1025
1026 anonymize_v6(r->v6.dstaddr, anon_ip);
1027 r->v6.dstaddr[0] = anon_ip[0];
1028 r->v6.dstaddr[1] = anon_ip[1];
1029 }
1030966 // remember IPs for network
1031967 snet[0] = r->v6.srcaddr[0];
1032968 snet[1] = r->v6.srcaddr[1];
10671003
10681004 } else { // IPv4
10691005 uint32_t snet, dnet;
1070 if ( anon ) {
1071 r->v4.srcaddr = anonymize(r->v4.srcaddr);
1072 r->v4.dstaddr = anonymize(r->v4.dstaddr);
1073 }
10741006 snet = r->v4.srcaddr;
10751007 dnet = r->v4.dstaddr;
10761008 r->v4.srcaddr = htonl(r->v4.srcaddr);
11551087 if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6
11561088 // EX_NEXT_HOP_v6:
11571089 as[0] = 0;
1158 if ( anon ) {
1159 anonymize_v6(r->ip_nexthop.v6, anon_ip);
1160 r->ip_nexthop.v6[0] = anon_ip[0];
1161 r->ip_nexthop.v6[1] = anon_ip[1];
1162 }
11631090 r->ip_nexthop.v6[0] = htonll(r->ip_nexthop.v6[0]);
11641091 r->ip_nexthop.v6[1] = htonll(r->ip_nexthop.v6[1]);
11651092 inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as));
11731100 } else {
11741101 // EX_NEXT_HOP_v4:
11751102 as[0] = 0;
1176 if ( anon ) {
1177 r->ip_nexthop.v4 = anonymize(r->ip_nexthop.v4);
1178 }
11791103 r->ip_nexthop.v4 = htonl(r->ip_nexthop.v4);
11801104 inet_ntop(AF_INET, &r->ip_nexthop.v4, as, sizeof(as));
11811105 as[IP_STRING_LEN-1] = 0;
11891113 if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6
11901114 // EX_NEXT_HOP_BGP_v6:
11911115 as[0] = 0;
1192 if ( anon ) {
1193 anonymize_v6(r->bgp_nexthop.v6, anon_ip);
1194 r->bgp_nexthop.v6[0] = anon_ip[0];
1195 r->bgp_nexthop.v6[1] = anon_ip[1];
1196 }
11971116 r->bgp_nexthop.v6[0] = htonll(r->bgp_nexthop.v6[0]);
11981117 r->bgp_nexthop.v6[1] = htonll(r->bgp_nexthop.v6[1]);
11991118 inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as));
12071126 } else {
12081127 // EX_NEXT_HOP_BGP_v4:
12091128 as[0] = 0;
1210 if ( anon ) {
1211 r->bgp_nexthop.v4 = anonymize(r->bgp_nexthop.v4);
1212 }
12131129 r->bgp_nexthop.v4 = htonl(r->bgp_nexthop.v4);
12141130 inet_ntop(AF_INET, &r->bgp_nexthop.v4, as, sizeof(as));
12151131 as[IP_STRING_LEN-1] = 0;
12911207 if ( (r->flags & FLAG_IPV6_EXP ) != 0 ) { // IPv6
12921208 // EX_NEXT_HOP_v6:
12931209 as[0] = 0;
1294 if ( anon ) {
1295 anonymize_v6(r->ip_router.v6, anon_ip);
1296 r->ip_router.v6[0] = anon_ip[0];
1297 r->ip_router.v6[1] = anon_ip[1];
1298 }
12991210 r->ip_router.v6[0] = htonll(r->ip_router.v6[0]);
13001211 r->ip_router.v6[1] = htonll(r->ip_router.v6[1]);
13011212 inet_ntop(AF_INET6, r->ip_router.v6, as, sizeof(as));
13091220 } else {
13101221 // EX_NEXT_HOP_v4:
13111222 as[0] = 0;
1312 if ( anon ) {
1313 r->ip_router.v4 = anonymize(r->ip_router.v4);
1314 }
13151223 r->ip_router.v4 = htonl(r->ip_router.v4);
13161224 inet_ntop(AF_INET, &r->ip_router.v4, as, sizeof(as));
13171225 as[IP_STRING_LEN-1] = 0;
13351243
13361244 } // End of flow_record_to_csv
13371245
1338 void format_special(void *record, char ** s, int anon, int tag) {
1246 void format_special(void *record, char ** s, int tag) {
13391247 master_record_t *r = (master_record_t *)record;
13401248 int i, index;
13411249
1342 do_anonymize = anon;
13431250 do_tag = tag;
13441251 tag_string[0] = do_tag ? TAG_CHAR : '\0';
13451252 tag_string[1] = '\0';
16311538 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
16321539 uint64_t ip[2];
16331540
1634 if ( do_anonymize ) {
1635 anonymize_v6(r->v6.srcaddr, ip);
1636 } else {
1637 ip[0] = r->v6.srcaddr[0];
1638 ip[1] = r->v6.srcaddr[1];
1639 }
1640
1641 ip[0] = htonll(ip[0]);
1642 ip[1] = htonll(ip[1]);
1541 ip[0] = htonll(r->v6.srcaddr[0]);
1542 ip[1] = htonll(r->v6.srcaddr[1]);
16431543 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
16441544 if ( ! long_v6 ) {
16451545 condense_v6(tmp_str);
16461546 }
16471547 } else { // IPv4
16481548 uint32_t ip;
1649 ip = do_anonymize ? anonymize(r->v4.srcaddr) : r->v4.srcaddr;
1650 ip = htonl(ip);
1549 ip = htonl(r->v4.srcaddr);
16511550 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
16521551 }
16531552 tmp_str[IP_STRING_LEN-1] = 0;
16681567 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
16691568 uint64_t ip[2];
16701569
1671 if ( do_anonymize ) {
1672 anonymize_v6(r->v6.srcaddr, ip);
1673 } else {
1674 ip[0] = r->v6.srcaddr[0];
1675 ip[1] = r->v6.srcaddr[1];
1676 }
1677
1678 ip[0] = htonll(ip[0]);
1679 ip[1] = htonll(ip[1]);
1570 ip[0] = htonll(r->v6.srcaddr[0]);
1571 ip[1] = htonll(r->v6.srcaddr[1]);
16801572 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
16811573 if ( ! long_v6 ) {
16821574 condense_v6(tmp_str);
16841576 portchar = '.';
16851577 } else { // IPv4
16861578 uint32_t ip;
1687 ip = do_anonymize ? anonymize(r->v4.srcaddr) : r->v4.srcaddr;
1688 ip = htonl(ip);
1579 ip = htonl(r->v4.srcaddr);
16891580 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
16901581 portchar = ':';
16911582 }
17071598 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
17081599 uint64_t ip[2];
17091600
1710 if ( do_anonymize ) {
1711 anonymize_v6(r->v6.dstaddr, ip);
1712 } else {
1713 ip[0] = r->v6.dstaddr[0];
1714 ip[1] = r->v6.dstaddr[1];
1715 }
1716
1717 ip[0] = htonll(ip[0]);
1718 ip[1] = htonll(ip[1]);
1601 ip[0] = htonll(r->v6.dstaddr[0]);
1602 ip[1] = htonll(r->v6.dstaddr[1]);
17191603 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
17201604 if ( ! long_v6 ) {
17211605 condense_v6(tmp_str);
17221606 }
17231607 } else { // IPv4
17241608 uint32_t ip;
1725 ip = do_anonymize ? anonymize(r->v4.dstaddr) : r->v4.dstaddr;
1726 ip = htonl(ip);
1609 ip = htonl(r->v4.dstaddr);
17271610 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
17281611 }
17291612 tmp_str[IP_STRING_LEN-1] = 0;
17451628 if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6
17461629 uint64_t ip[2];
17471630
1748 if ( do_anonymize ) {
1749 anonymize_v6(r->ip_nexthop.v6, ip);
1750 } else {
1751 ip[0] = r->ip_nexthop.v6[0];
1752 ip[1] = r->ip_nexthop.v6[1];
1753 }
1754
1755 ip[0] = htonll(ip[0]);
1756 ip[1] = htonll(ip[1]);
1631 ip[0] = htonll(r->ip_nexthop.v6[0]);
1632 ip[1] = htonll(r->ip_nexthop.v6[1]);
17571633 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
17581634 if ( ! long_v6 ) {
17591635 condense_v6(tmp_str);
17601636 }
17611637 } else { // IPv4
17621638 uint32_t ip;
1763 ip = do_anonymize ? anonymize(r->ip_nexthop.v4) : r->ip_nexthop.v4;
1764 ip = htonl(ip);
1639 ip = htonl(r->ip_nexthop.v4);
17651640 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
17661641 }
17671642 tmp_str[IP_STRING_LEN-1] = 0;
17821657 if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6
17831658 uint64_t ip[2];
17841659
1785 if ( do_anonymize ) {
1786 anonymize_v6(r->bgp_nexthop.v6, ip);
1787 } else {
1788 ip[0] = r->bgp_nexthop.v6[0];
1789 ip[1] = r->bgp_nexthop.v6[1];
1790 }
1791
1792 ip[0] = htonll(ip[0]);
1793 ip[1] = htonll(ip[1]);
1660 ip[0] = htonll(r->bgp_nexthop.v6[0]);
1661 ip[1] = htonll(r->bgp_nexthop.v6[1]);
17941662 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
17951663 if ( ! long_v6 ) {
17961664 condense_v6(tmp_str);
17971665 }
17981666 } else { // IPv4
17991667 uint32_t ip;
1800 ip = do_anonymize ? anonymize(r->bgp_nexthop.v4) : r->bgp_nexthop.v4;
1801 ip = htonl(ip);
1668 ip = htonl(r->bgp_nexthop.v4);
18021669 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
18031670 }
18041671 tmp_str[IP_STRING_LEN-1] = 0;
18191686 if ( (r->flags & FLAG_IPV6_EXP ) != 0 ) { // IPv6
18201687 uint64_t ip[2];
18211688
1822 if ( do_anonymize ) {
1823 anonymize_v6(r->ip_router.v6, ip);
1824 } else {
1825 ip[0] = r->ip_router.v6[0];
1826 ip[1] = r->ip_router.v6[1];
1827 }
1828
1829 ip[0] = htonll(ip[0]);
1830 ip[1] = htonll(ip[1]);
1689 ip[0] = htonll(r->ip_router.v6[0]);
1690 ip[1] = htonll(r->ip_router.v6[1]);
18311691 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
18321692 if ( ! long_v6 ) {
18331693 condense_v6(tmp_str);
18341694 }
18351695 } else { // IPv4
18361696 uint32_t ip;
1837 ip = do_anonymize ? anonymize(r->ip_router.v4) : r->ip_router.v4;
1838 ip = htonl(ip);
1697 ip = htonl(r->ip_router.v4);
18391698 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
18401699 }
18411700 tmp_str[IP_STRING_LEN-1] = 0;
18581717 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
18591718 uint64_t ip[2];
18601719
1861 if ( do_anonymize ) {
1862 anonymize_v6(r->v6.dstaddr, ip);
1863 } else {
1864 ip[0] = r->v6.dstaddr[0];
1865 ip[1] = r->v6.dstaddr[1];
1866 }
1867
1868 ip[0] = htonll(ip[0]);
1869 ip[1] = htonll(ip[1]);
1720 ip[0] = htonll(r->v6.dstaddr[0]);
1721 ip[1] = htonll(r->v6.dstaddr[1]);
18701722 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
18711723 if ( ! long_v6 ) {
18721724 condense_v6(tmp_str);
18741726 portchar = '.';
18751727 } else { // IPv4
18761728 uint32_t ip;
1877 ip = do_anonymize ? anonymize(r->v4.dstaddr) : r->v4.dstaddr;
1878 ip = htonl(ip);
1729 ip = htonl(r->v4.dstaddr);
18791730 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
18801731 portchar = ':';
18811732 }
19001751 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
19011752 uint64_t ip[2];
19021753
1903 if ( do_anonymize ) {
1904 anonymize_v6(r->v6.srcaddr, ip);
1905 } else {
1906 ip[0] = r->v6.srcaddr[0];
1907 ip[1] = r->v6.srcaddr[1];
1908 }
1909
1910 ip[0] = htonll(ip[0]);
1911 ip[1] = htonll(ip[1]);
1754 ip[0] = htonll(r->v6.srcaddr[0]);
1755 ip[1] = htonll(r->v6.srcaddr[1]);
19121756 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
19131757 if ( ! long_v6 ) {
19141758 condense_v6(tmp_str);
19151759 }
19161760 } else { // IPv4
19171761 uint32_t ip;
1918 ip = do_anonymize ? anonymize(r->v4.srcaddr) : r->v4.srcaddr;
1919 ip = htonl(ip);
1762 ip = htonl(r->v4.srcaddr);
19201763 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
19211764 }
19221765 tmp_str[IP_STRING_LEN-1] = 0;
19391782 if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6
19401783 uint64_t ip[2];
19411784
1942 if ( do_anonymize ) {
1943 anonymize_v6(r->v6.dstaddr, ip);
1944 } else {
1945 ip[0] = r->v6.dstaddr[0];
1946 ip[1] = r->v6.dstaddr[1];
1947 }
1948
1949 ip[0] = htonll(ip[0]);
1950 ip[1] = htonll(ip[1]);
1785 ip[0] = htonll(r->v6.dstaddr[0]);
1786 ip[1] = htonll(r->v6.dstaddr[1]);
19511787 inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str));
19521788 if ( ! long_v6 ) {
19531789 condense_v6(tmp_str);
19541790 }
19551791 } else { // IPv4
19561792 uint32_t ip;
1957 ip = do_anonymize ? anonymize(r->v4.dstaddr) : r->v4.dstaddr;
1958 ip = htonl(ip);
1793 ip = htonl(r->v4.dstaddr);
19591794 inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str));
19601795 }
19611796 tmp_str[IP_STRING_LEN-1] = 0;
3939 #define _NF_COMMON_H 1
4040
4141
42 typedef void (*printer_t)(void *, char **, int, int);
42 typedef void (*printer_t)(void *, char **, int);
4343
4444 #if ( SIZEOF_VOID_P == 8 )
4545 typedef uint64_t pointer_addr_t;
9191
9292 int Proto_num(char *protostr);
9393
94 void format_file_block_header(void *header, char **s, int anon, int tag);
94 void format_file_block_header(void *header, char **s, int tag);
9595
9696 char *format_csv_header(void);
9797
9999
100100 void set_record_header(void);
101101
102 void format_file_block_record(void *record, char **s, int anon, int tag);
102 void format_file_block_record(void *record, char **s, int tag);
103103
104 void flow_record_to_pipe(void *record, char ** s, int anon, int tag);
104 void flow_record_to_pipe(void *record, char ** s, int tag);
105105
106 void flow_record_to_csv(void *record, char ** s, int anon, int tag);
106 void flow_record_to_csv(void *record, char ** s, int tag);
107107
108108 int ParseOutputFormat(char *format, int plain_numbers);
109109
110 void format_special(void *record, char ** s, int anon, int tag);
110 void format_special(void *record, char ** s, int tag);
111111
112112
113113 uint32_t Get_fwd_status_id(char *status);
0 /*
1 * Copyright (c) 2009, Peter Haag
2 * Copyright (c) 2004-2008, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of SWITCH nor the names of its contributors may be
14 * used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Author: haag $
30 *
31 * $Id:$
32 *
33 * $LastChangedRevision: 48 $
34 *
35 *
36 */
37
38 #include "config.h"
39
40 #include <stdio.h>
41 #include <unistd.h>
42 #include <stdlib.h>
43 #include <stdarg.h>
44 #include <errno.h>
45 #include <time.h>
46 #include <string.h>
47 #include <ctype.h>
48 #include <sys/types.h>
49 #include <sys/socket.h>
50 #include <sys/param.h>
51 #include <netinet/in.h>
52 #include <arpa/inet.h>
53 #include <sys/stat.h>
54 #include <fcntl.h>
55
56 #ifdef HAVE_STDINT_H
57 #include <stdint.h>
58 #endif
59
60 #include "nffile.h"
61 #include "nfx.h"
62 #include "util.h"
63 #include "flist.h"
64 #include "panonymizer.h"
65
66 #define BUFFSIZE 1048576
67 #define MAX_BUFFER_SIZE 104857600
68
69 #if ( SIZEOF_VOID_P == 8 )
70 typedef uint64_t pointer_addr_t;
71 #else
72 typedef uint32_t pointer_addr_t;
73 #endif
74
75 // module limited globals
76 extension_map_list_t extension_map_list;
77
78 /* Function Prototypes */
79 static void usage(char *name);
80
81 static inline void AnonRecord(master_record_t *master_record);
82
83 static void process_data(void *wfile);
84
85 /* Functions */
86
87 #include "nffile_inline.c"
88
89 static void usage(char *name) {
90 printf("usage %s [options] \n"
91 "-h\t\tthis text you see right here\n"
92 "-K <key>\tAnonymize IP addressses using CryptoPAn with key <key>.\n"
93 "-r\t\tread input from file\n"
94 "-M <expr>\tRead input from multiple directories.\n"
95 "-R <expr>\tRead input from sequence of files.\n"
96 "-w <file>\tName of output file. Defaults to input file.\n"
97 , name);
98 } /* usage */
99
100 static inline void AnonRecord(master_record_t *master_record) {
101 extension_map_t *extension_map = master_record->map_ref;
102 int i;
103
104 // Required extension 1 - IP addresses
105 if ( (master_record->flags & FLAG_IPV6_ADDR) != 0 ) { // IPv6
106 // IPv6
107 uint64_t anon_ip[2];
108 anonymize_v6(master_record->v6.srcaddr, anon_ip);
109 master_record->v6.srcaddr[0] = anon_ip[0];
110 master_record->v6.srcaddr[1] = anon_ip[1];
111
112 anonymize_v6(master_record->v6.dstaddr, anon_ip);
113 master_record->v6.dstaddr[0] = anon_ip[0];
114 master_record->v6.dstaddr[1] = anon_ip[1];
115
116 } else {
117 // IPv4
118 master_record->v4.srcaddr = anonymize(master_record->v4.srcaddr);
119 master_record->v4.dstaddr = anonymize(master_record->v4.dstaddr);
120 }
121
122 // Process optional extensions
123 i=0;
124 while ( extension_map->ex_id[i] ) {
125 switch (extension_map->ex_id[i++]) {
126 case EX_AS_2: // srcas/dstas 2 byte
127 master_record->srcas = 0;
128 master_record->dstas = 0;
129 break;
130 case EX_AS_4: // srcas/dstas 4 byte
131 master_record->srcas = 0;
132 master_record->dstas = 0;
133 break;
134 case EX_NEXT_HOP_v4:
135 master_record->ip_nexthop.v4 = anonymize(master_record->ip_nexthop.v4);
136 break;
137 case EX_NEXT_HOP_v6: {
138 uint64_t anon_ip[2];
139 anonymize_v6(master_record->ip_nexthop.v6, anon_ip);
140 master_record->ip_nexthop.v6[0] = anon_ip[0];
141 master_record->ip_nexthop.v6[1] = anon_ip[1];
142 } break;
143 case EX_NEXT_HOP_BGP_v4:
144 master_record->bgp_nexthop.v4 = anonymize(master_record->bgp_nexthop.v4);
145 break;
146 case EX_NEXT_HOP_BGP_v6: {
147 uint64_t anon_ip[2];
148 anonymize_v6(master_record->bgp_nexthop.v6, anon_ip);
149 master_record->bgp_nexthop.v6[0] = anon_ip[0];
150 master_record->bgp_nexthop.v6[1] = anon_ip[1];
151 } break;
152 case EX_ROUTER_IP_v4:
153 master_record->ip_router.v4 = anonymize(master_record->ip_router.v4);
154 break;
155 case EX_ROUTER_IP_v6: {
156 uint64_t anon_ip[2];
157 anonymize_v6(master_record->ip_router.v6, anon_ip);
158 master_record->ip_router.v6[0] = anon_ip[0];
159 master_record->ip_router.v6[1] = anon_ip[1];
160 } break;
161 }
162 }
163
164 } // End of AnonRecord
165
166
167 static void process_data(void *wfile) {
168 data_block_header_t block_header;
169 master_record_t master_record;
170 common_record_t *flow_record, *in_buff;
171 stat_record_t *stat_record, sum_statrecord;
172 nffile_t *nffile;
173 uint32_t buffer_size;
174 int i, rfd, done, ret, cnt, verbose;
175 char *string, outfile[MAXPATHLEN], *cfile;
176 #ifdef COMPAT15
177 int v1_map_done = 0;
178 #endif
179
180
181 setbuf(stderr, NULL);
182 cnt = 1;
183 verbose = 1;
184
185 // Get the first file handle
186 rfd = GetNextFile(0, 0, 0, &stat_record);
187 if ( rfd < 0 ) {
188 if ( rfd == FILE_ERROR )
189 perror("Can't open input file for reading");
190 return;
191 }
192
193 // allocate buffer suitable for netflow version
194 buffer_size = BUFFSIZE;
195 in_buff = (common_record_t *) malloc(buffer_size);
196
197 if ( !in_buff ) {
198 perror("Memory allocation error");
199 close(rfd);
200 return;
201 }
202 cfile = GetCurrentFilename();
203 if ( !cfile ) {
204 if ( rfd == 0 ) { // stdin
205 outfile[0] = '-';
206 outfile[1] = '\0';
207 verbose = 0;
208 } else {
209 fprintf(stderr, "(NULL) input file name error in %s line %d\n", __FILE__, __LINE__);
210 return;
211 }
212 } else {
213 // prepare output file
214 snprintf(outfile,MAXPATHLEN-1, "%s-tmp", cfile);
215 outfile[MAXPATHLEN-1] = '\0';
216 if ( verbose )
217 fprintf(stderr, " %i Processing %s\r", cnt++, cfile);
218 }
219
220 if ( wfile ) {
221 memset((void *)&sum_statrecord, 0, sizeof(sum_statrecord));
222 SumStatRecords(&sum_statrecord, stat_record);
223 nffile = OpenNewFile(wfile, NULL, IsCompressed(), 1, &string);
224 } else
225 nffile = OpenNewFile(outfile, NULL, IsCompressed(), 1, &string);
226
227 if ( !nffile ) {
228 fprintf(stderr, "%s\n", string);
229 if ( rfd )
230 close(rfd);
231 free(in_buff);
232 return;
233 }
234
235 done = 0;
236 while ( !done ) {
237 // get next data block from file
238 ret = ReadBlock(rfd, &block_header, (void *)in_buff, &string);
239
240 switch (ret) {
241 case NF_CORRUPT:
242 case NF_ERROR:
243 if ( ret == NF_CORRUPT )
244 fprintf(stderr, "Skip corrupt data file '%s': '%s'\n",GetCurrentFilename(), string);
245 else
246 fprintf(stderr, "Read error in file '%s': %s\n",GetCurrentFilename(), strerror(errno) );
247 // fall through - get next file in chain
248 case NF_EOF: {
249 char *string;
250 if ( nffile->block_header->NumRecords ) {
251 if ( WriteBlock(nffile) <= 0 ) {
252 fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno));
253 }
254 }
255 if ( wfile == NULL ) {
256 CloseUpdateFile(nffile, stat_record, GetIdent(), &string );
257 if ( rename(outfile, cfile) < 0 ) {
258 fprintf(stderr, "\nrename() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
259 fprintf(stderr, "Abort processing.\n");
260 return;
261 }
262 }
263
264 rfd = GetNextFile(rfd, 0, 0, &stat_record);
265 if ( rfd < 0 ) {
266 if ( rfd == NF_ERROR )
267 fprintf(stderr, "Read error in file '%s': %s\n",GetCurrentFilename(), strerror(errno) );
268
269 // rfd == EMPTY_LIST
270 done = 1;
271 continue;
272 }
273
274 cfile = GetCurrentFilename();
275 if ( !cfile ) {
276 fprintf(stderr, "(NULL) input file name error in %s line %d\n", __FILE__, __LINE__);
277 return;
278 }
279 fprintf(stderr, " %i Processing %s\r", cnt++, cfile);
280
281 if ( wfile == NULL ) {
282 snprintf(outfile,MAXPATHLEN-1, "%s-tmp", cfile);
283 outfile[MAXPATHLEN-1] = '\0';
284
285 nffile = OpenNewFile(outfile, nffile, IsCompressed(), 1, &string);
286 if ( !nffile ) {
287 fprintf(stderr, "%s\n", string);
288 if ( rfd )
289 close(rfd);
290 free(in_buff);
291 return;
292 }
293 } else {
294 SumStatRecords(&sum_statrecord, stat_record);
295 }
296
297 // continue with next file
298 continue;
299
300 } break; // not really needed
301 }
302
303 #ifdef COMPAT15
304 if ( block_header.id == DATA_BLOCK_TYPE_1 ) {
305 common_record_v1_t *v1_record = (common_record_v1_t *)in_buff;
306 // create an extension map for v1 blocks
307 if ( v1_map_done == 0 ) {
308 extension_map_t *map = malloc(sizeof(extension_map_t) + 2 * sizeof(uint16_t) );
309 if ( ! map ) {
310 perror("Memory allocation error");
311 exit(255);
312 }
313 map->type = ExtensionMapType;
314 map->size = sizeof(extension_map_t) + 2 * sizeof(uint16_t);
315 map->map_id = 0;
316 map->ex_id[0] = EX_IO_SNMP_2;
317 map->ex_id[1] = EX_AS_2;
318 map->ex_id[2] = 0;
319
320 Insert_Extension_Map(&extension_map_list, map);
321 AppendToBuffer(&nffile, (void *)map, map->size);
322
323 v1_map_done = 1;
324 }
325
326 // convert the records to v2
327 for ( i=0; i < block_header.NumRecords; i++ ) {
328 common_record_t *v2_record = (common_record_t *)v1_record;
329 Convert_v1_to_v2((void *)v1_record);
330 // now we have a v2 record -> use size of v2_record->size
331 v1_record = (common_record_v1_t *)((pointer_addr_t)v1_record + v2_record->size);
332 }
333 block_header.id = DATA_BLOCK_TYPE_2;
334 }
335 #endif
336
337 if ( block_header.id != DATA_BLOCK_TYPE_2 ) {
338 fprintf(stderr, "Can't process block type %u. Skip block.\n", block_header.id);
339 continue;
340 }
341
342 flow_record = in_buff;
343 for ( i=0; i < block_header.NumRecords; i++ ) {
344 char string[1024];
345
346 if ( flow_record->type == CommonRecordType ) {
347 uint32_t map_id = flow_record->ext_map;
348 if ( extension_map_list.slot[map_id] == NULL ) {
349 snprintf(string, 1024, "Corrupt data file! No such extension map id: %u. Skip record", flow_record->ext_map );
350 string[1023] = '\0';
351 } else {
352 ExpandRecord_v2( flow_record, extension_map_list.slot[flow_record->ext_map], &master_record);
353
354 // update number of flows matching a given map
355 extension_map_list.slot[map_id]->ref_count++;
356
357 AnonRecord(&master_record);
358 PackRecord(&master_record, nffile);
359 }
360
361 } else if ( flow_record->type == ExtensionMapType ) {
362 extension_map_t *map = (extension_map_t *)flow_record;
363
364 if ( Insert_Extension_Map(&extension_map_list, map) ) {
365 // flush new map
366 } // else map already known and flushed
367 AppendToBuffer(nffile, (void *)map, map->size);
368
369 } else {
370 fprintf(stderr, "Skip unknown record type %i\n", flow_record->type);
371 }
372
373 // Advance pointer by number of bytes for netflow record
374 flow_record = (common_record_t *)((pointer_addr_t)flow_record + flow_record->size);
375
376 } // for all records
377
378 } // while
379
380 if ( rfd > 0 )
381 close(rfd);
382
383 DisposeFile(nffile);
384
385 free((void *)in_buff);
386 fprintf(stderr, "\n");
387 fprintf(stderr, "Processed %i files.\n", --cnt);
388 PackExtensionMapList(&extension_map_list);
389
390 } // End of process_data
391
392
393 int main( int argc, char **argv ) {
394 char *rfile, *Rfile, *wfile, *Mdirs;
395 int c;
396 char CryptoPAnKey[32];
397
398 rfile = Rfile = Mdirs = wfile = NULL;
399 while ((c = getopt(argc, argv, "K:L:r:M:R:w:")) != EOF) {
400 switch (c) {
401 case 'h':
402 usage(argv[0]);
403 exit(0);
404 break;
405 break;
406 case 'K':
407 if ( !ParseCryptoPAnKey(optarg, CryptoPAnKey) ) {
408 fprintf(stderr, "Invalid key '%s' for CryptoPAn!\n", optarg);
409 exit(255);
410 }
411 PAnonymizer_Init((uint8_t *)CryptoPAnKey);
412 break;
413 case 'L':
414 if ( !InitLog("argv[0]", optarg) )
415 exit(255);
416 break;
417 case 'r':
418 rfile = optarg;
419 if ( strcmp(rfile, "-") == 0 )
420 rfile = NULL;
421 break;
422 case 'M':
423 Mdirs = optarg;
424 break;
425 case 'R':
426 Rfile = optarg;
427 break;
428 case 'w':
429 wfile = optarg;
430 break;
431 default:
432 usage(argv[0]);
433 exit(0);
434 }
435 }
436
437 if ( rfile && Rfile ) {
438 fprintf(stderr, "-r and -R are mutually exclusive. Please specify either -r or -R\n");
439 exit(255);
440 }
441 if ( Mdirs && !(rfile || Rfile) ) {
442 fprintf(stderr, "-M needs either -r or -R to specify the file or file list. Add '-R .' for all files in the directories.\n");
443 exit(255);
444 }
445
446 InitExtensionMaps(&extension_map_list);
447
448 SetupInputFileSequence(Mdirs, rfile, Rfile);
449
450 process_data(wfile);
451
452
453 return 0;
454 }
387387 fs = FlowSource;
388388 while ( fs ) {
389389
390 // Init block header
391 fs->nffile.block_header->NumRecords = 0;
392 fs->nffile.block_header->size = 0;
393 fs->nffile.block_header->id = DATA_BLOCK_TYPE_2;
394 fs->nffile.block_header->pad = 0;
395 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
396 fs->nffile.file_blocks = 0;
397 fs->nffile.compress = compress;
398
399390 // prepare file
400 fs->nffile.wfd = OpenNewFile(fs->current, &string, compress);
401 if ( string != NULL ) {
391 fs->nffile = OpenNewFile(fs->current, NULL, compress, 0, &string);
392 if ( !fs->nffile ) {
402393 syslog(LOG_ERR, "%s", string);
403394 return;
404395 }
500491
501492 if ( verbose ) {
502493 // Dump to stdout
503 format_file_block_header(fs->nffile.block_header, &string, 0, 0);
494 format_file_block_header(fs->nffile->block_header, &string, 0);
504495 printf("%s\n", string);
505496 }
506497
507 if ( fs->nffile.block_header->NumRecords ) {
498 if ( fs->nffile->block_header->NumRecords ) {
508499 // flush current buffer to disc
509 if ( WriteBlock(&(fs->nffile)) <= 0 )
500 if ( WriteBlock(fs->nffile) <= 0 )
510501 syslog(LOG_ERR, "Ident: %s, failed to write output buffer to disk: '%s'" , fs->Ident, strerror(errno));
511502 else
512503 // update successful written blocks
513 fs->nffile.file_blocks++;
504 fs->nffile->file_header->NumBlocks++;
514505 } // else - no new records in current block
515506
516507
525516 fs->stat_record.msec_last = fs->last_seen - fs->stat_record.last_seen*1000;
526517
527518 // Write Stat record and close file
528 CloseUpdateFile(fs->nffile.wfd, &fs->stat_record, fs->nffile.file_blocks, fs->Ident, compress, &string );
519 CloseUpdateFile(fs->nffile, &fs->stat_record, fs->Ident, &string );
529520 if ( string != NULL ) {
530521 // closing the file failed. maybe disk full ??
531522 syslog(LOG_ERR, "Ident: %s, %s", fs->Ident, string);
532523 }
533
524
534525 if ( subdir && !SetupSubDir(fs->datadir, subdir, error, 255) ) {
535526 // in this case the flows get lost! - the rename will fail
536527 // but this should not happen anyway, unless i/o problems, inode problems etc.
563554 fs->Ident, (unsigned long long)fs->stat_record.numflows, (unsigned long long)fs->stat_record.numpackets,
564555 (unsigned long long)fs->stat_record.numbytes, fs->stat_record.sequence_failure, fs->bad_packets);
565556
566 // Initialize block header and write pointer for next block
567 fs->nffile.block_header->NumRecords = 0;
568 fs->nffile.block_header->size = 0;
569 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
570
571557 // reset stat record
572558 memset((void *)&fs->stat_record, 0, sizeof(stat_record_t));
573559 fs->bad_packets = 0;
574560 fs->first_seen = 0xffffffffffffLL;
575561 fs->last_seen = 0;
576 fs->nffile.file_blocks = 0;
562
563 if ( !done ) {
564 fs->nffile = OpenNewFile(fs->current, fs->nffile, compress, 0, &string);
565 if ( !fs->nffile ) {
566 syslog(LOG_ERR, "Fatal: ident: %s, %s", fs->Ident, string);
567 syslog(LOG_ERR, "Suicide due to fatal error!");
568 break;
569 }
570 }
577571
578572 // Dump all extension maps to the buffer
579573 FlushExtensionMaps(fs);
580
581 if ( !done ) {
582 fs->nffile.wfd = OpenNewFile(fs->current, &string, compress);
583 if ( string != NULL ) {
584 syslog(LOG_ERR, "Ident: %s, %s", fs->Ident, string);
585 syslog(LOG_ERR, "New flows will get lost!\n");
586
587 // do not crash or terminate
588 fs->nffile.wfd = 0;
589 }
590 }
591574
592575 // next flow source
593576 fs = fs->next;
710693 export_packets++;
711694
712695 // flush current buffer to disc
713 if ( fs->nffile.block_header->size > BUFFSIZE ) {
696 if ( fs->nffile->block_header->size > BUFFSIZE ) {
714697 // fishy! - we already wrote into someone elses memory! - I'm sorry
715698 // reset output buffer - data may be lost, as we don not know, where it happen
716 fs->nffile.block_header->size = 0;
717 fs->nffile.block_header->NumRecords = 0;
718 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
699 fs->nffile->block_header->size = 0;
700 fs->nffile->block_header->NumRecords = 0;
701 fs->nffile->writeto = (void *)((pointer_addr_t)fs->nffile->block_header + sizeof(data_block_header_t) );
719702 syslog(LOG_ERR, "### Software bug ### Ident: %s, output buffer overflow: expect memory inconsitency", fs->Ident);
720703 }
721 /*
722 if ( fs->nffile.block_header->size > OUTPUT_FLUSH_LIMIT ) {
723 if ( WriteBlock(fs->nffile) <= 0 ) {
724 syslog(LOG_ERR, "Failed to write output buffer to disk: '%s'" , strerror(errno));
725 } else {
726 fs->nffile.block_header->size = 0;
727 fs->nffile.block_header->NumRecords = 0;
728 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
729 fs->nffile.file_blocks++;
730 }
731 }
732 */
733704 }
734705
735706 if ( verbose && blast_failures ) {
739710
740711 fs = FlowSource;
741712 while ( fs ) {
742 free((void *)fs->nffile.block_header);
713 DisposeFile(fs->nffile);
743714 fs = fs->next;
744715 }
745716
11441115 exit(255);
11451116 }
11461117
1147 // setup output memory buffer
1148 fs->nffile.block_header = (data_block_header_t *)malloc(BUFFSIZE + sizeof(data_block_header_t));
1149 if ( !fs->nffile.block_header ) {
1150 syslog(LOG_ERR, "malloc() allocation error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
1151 exit(255);
1152 }
1153
11541118 fs = fs->next;
11551119 }
11561120
7474 #include "version.h"
7575 #include "util.h"
7676 #include "flist.h"
77 #include "panonymizer.h"
7877
7978 /* hash parameters */
8079 #define NumPrealloc 128000
226225 /* Function Prototypes */
227226 static void usage(char *name);
228227
229 static int ParseCryptoPAnKey ( char *s, char *key );
230
231228 static void PrintSummary(stat_record_t *stat_record, int plain_numbers, int csv_output);
232229
233230
234231 static stat_record_t process_data(char *wfile, int element_stat, int flow_stat, int sort_flows,
235232 printer_t print_header, printer_t print_record, time_t twin_start, time_t twin_end,
236 uint64_t limitflows, int anon, int tag, int compress);
233 uint64_t limitflows, int tag, int compress);
237234
238235 /* Functions */
239236
263260 "-j <file>\tCompress/Uncompress file.\n"
264261 "-z\t\tCompress flows in output file. Used in combination with -w.\n"
265262 "-l <expr>\tSet limit on packets for line and packed output format.\n"
266 "-K <key>\tAnonymize IP addressses using CryptoPAn with key <key>.\n"
267263 "\t\tkey: 32 character string or 64 digit hex string starting with 0x.\n"
268264 "-L <expr>\tSet limit on bytes for line and packed output format.\n"
269265 "-I \t\tPrint netflow summary statistics info from file, specified by -r.\n"
291287 "\t\tyyyy/MM/dd.hh:mm:ss[-yyyy/MM/dd.hh:mm:ss]\n", name);
292288 } /* usage */
293289
294 static int ParseCryptoPAnKey ( char *s, char *key ) {
295 int i, j;
296 char numstr[3];
297
298 if ( strlen(s) == 32 ) {
299 // Key is a string
300 strncpy(key, s, 32);
301 return 1;
302 }
303
304 s[1] = tolower(s[1]);
305 numstr[2] = 0;
306 if ( strlen(s) == 66 && s[0] == '0' && s[1] == 'x' ) {
307 j = 2;
308 for ( i=0; i<32; i++ ) {
309 if ( !isxdigit((int)s[j]) || !isxdigit((int)s[j+1]) )
310 return 0;
311 numstr[0] = s[j++];
312 numstr[1] = s[j++];
313 key[i] = strtol(numstr, NULL, 16);
314 }
315 return 1;
316 }
317
318 // It's an invalid key
319 return 0;
320
321 } // End of ParseCryptoPAnKey
322290
323291 static void PrintSummary(stat_record_t *stat_record, int plain_numbers, int csv_output) {
324292 static double duration;
359327
360328 stat_record_t process_data(char *wfile, int element_stat, int flow_stat, int sort_flows,
361329 printer_t print_header, printer_t print_record, time_t twin_start, time_t twin_end,
362 uint64_t limitflows, int anon, int tag, int compress) {
330 uint64_t limitflows, int tag, int compress) {
363331 data_block_header_t in_block_header;
364332 common_record_t *flow_record, *in_buff;
365333 master_record_t *master_record;
366 nffile_t nffile;
334 nffile_t *nffile;
367335 stat_record_t stat_record;
368 int rfd, done, write_file, is_stdout;
336 int rfd, done, write_file;
369337 char *string;
370338
371339 #ifdef COMPAT15
399367 // do not write flows to file, when doing any stats
400368 // -w may apply for flow_stats later
401369 write_file = !(sort_flows || flow_stat || element_stat) && wfile;
402 // is the file stdout?
403 is_stdout = wfile && ( strcmp(wfile, "-") == 0 );
370 nffile = NULL;
404371
405372 // allocate network buffer
406373 in_buff = (common_record_t *) malloc(BUFFSIZE);
418385 return stat_record;
419386 }
420387
421 memset((void *)&nffile, 0, sizeof(nffile));
422388 // prepare file is requested
423 if ( write_file && !InitExportFile(wfile, compress, &nffile) ) {
424 if ( rfd )
425 close(rfd);
426 free(in_buff);
427 return stat_record;
389 if ( write_file ) {
390 char *string;
391 nffile = OpenNewFile(wfile, NULL, compress, IsAnonymized(), &string);
392 if ( !nffile ) {
393 fprintf(stderr, "%s\n", string);
394 if ( rfd )
395 close(rfd);
396 free(in_buff);
397 return stat_record;
398 }
428399 }
429400
430401 // setup Filter Engine to point to master_record, as any record read from file
490461 map->extension_size += extension_descriptor[EX_IO_SNMP_2].size;
491462 map->extension_size += extension_descriptor[EX_AS_2].size;
492463
493 if ( Insert_Extension_Map(&extension_map_list,map) && nffile.wfd ) {
464 if ( Insert_Extension_Map(&extension_map_list,map) && write_file ) {
494465 // flush new map
495 AppendToBuffer(&nffile, (void *)map, map->size);
466 AppendToBuffer(nffile, (void *)map, map->size);
496467 } // else map already known and flushed
497468
498469 v1_map_done = 1;
581552 } else {
582553
583554
584 if ( nffile.wfd != 0 ) {
585 if ( anon ) {
586 pointer_addr_t size = COMMON_RECORD_DATA_SIZE;
587 if ( (flow_record->flags & FLAG_IPV6_ADDR ) == 0 ) {
588 uint32_t *ip = (uint32_t *)((pointer_addr_t)nffile.writeto + size);
589 ip[0] = anonymize(ip[0]);
590 ip[1] = anonymize(ip[1]);
591 } else {
592 ipv6_block_t *ip = (ipv6_block_t *)((pointer_addr_t)nffile.writeto + size);
593 uint64_t anon_ip[2];
594 anonymize_v6(ip->srcaddr, anon_ip);
595 ip->srcaddr[0] = anon_ip[0];
596 ip->srcaddr[1] = anon_ip[1];
597
598 anonymize_v6(ip->dstaddr, anon_ip);
599 ip->dstaddr[0] = anon_ip[0];
600 ip->dstaddr[1] = anon_ip[1];
601 }
602 }
603 AppendToBuffer(&nffile, (void *)flow_record, flow_record->size);
555 if ( write_file ) {
556 AppendToBuffer(nffile, (void *)flow_record, flow_record->size);
604557 } else if ( print_record ) {
605558
606559 // if we need to print out this record
607 print_record(master_record, &string, anon, tag);
560 print_record(master_record, &string, tag);
608561 if ( string ) {
609562 if ( limitflows ) {
610563 if ( (stat_record.numflows <= limitflows) )
622575 } else if ( flow_record->type == ExtensionMapType ) {
623576 extension_map_t *map = (extension_map_t *)flow_record;
624577
625 if ( Insert_Extension_Map(&extension_map_list, map) && nffile.wfd ) {
578 if ( Insert_Extension_Map(&extension_map_list, map) && write_file ) {
626579 // flush new map
627 AppendToBuffer(&nffile, (void *)map, map->size);
580 AppendToBuffer(nffile, (void *)map, map->size);
628581 } // else map already known and flushed
629582 } else {
630583 fprintf(stderr, "Skip unknown record type %i\n", flow_record->type);
646599 close(rfd);
647600
648601 // flush output file
649 if ( nffile.wfd ) {
602 if ( write_file ) {
650603 // flush current buffer to disc
651 if ( nffile.block_header->NumRecords ) {
652 if ( WriteBlock(&nffile) <= 0 ) {
604 if ( nffile->block_header->NumRecords ) {
605 if ( WriteBlock(nffile) <= 0 ) {
653606 fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno));
654607 } else {
655 nffile.file_blocks++;
608 nffile->file_header->NumBlocks++;
656609 }
657610 }
658611
659612 /* Stat info */
660613 if ( write_file ) {
661614 /* Write stat info and close file */
662 CloseUpdateFile(nffile.wfd, &stat_record, nffile.file_blocks, GetIdent(), nffile.compress, &string );
615 CloseUpdateFile(nffile, &stat_record, GetIdent(), &string );
663616 if ( string != NULL )
664617 fprintf(stderr, "%s\n", string);
618 nffile = DisposeFile(nffile);
665619 } // else stdout
666620 }
667621
683637 char *order_by, *query_file, *UnCompress_file, *nameserver, *aggr_fmt;
684638 int c, ffd, ret, element_stat, fdump;
685639 int i, user_format, quiet, flow_stat, topN, aggregate, aggregate_mask, bidir;
686 int print_stat, syntax_only, date_sorted, do_anonymize, do_tag, compress;
640 int print_stat, syntax_only, date_sorted, do_tag, compress;
687641 int plain_numbers, GuessDir, pipe_output, csv_output;
688642 time_t t_start, t_end;
689643 uint16_t Aggregate_Bits;
690644 uint32_t limitflows;
691645 uint64_t AggregateMasks[AGGR_SIZE];
692646 char Ident[IdentLen];
693 char CryptoPAnKey[32];
694647
695648 rfile = Rfile = Mdirs = wfile = ffile = filter = tstring = stat_type = NULL;
696649 byte_limit_string = packet_limit_string = NULL;
708661 total_bytes = 0;
709662 total_flows = 0;
710663 skipped_blocks = 0;
711 do_anonymize = 0;
712664 do_tag = 0;
713665 quiet = 0;
714666 user_format = 0;
798750 packet_limit_string = optarg;
799751 break;
800752 case 'K':
801 if ( !ParseCryptoPAnKey(optarg, CryptoPAnKey) ) {
802 fprintf(stderr, "Invalid key '%s' for CryptoPAn!\n", optarg);
803 exit(255);
804 }
805 do_anonymize = 1;
753 fprintf(stderr, "*** Anonymisation moved! Use nfanon to anonymise flows!\n");
754 exit(255);
806755 break;
807756 case 'L':
808757 byte_limit_string = optarg;
11181067 }
11191068 }
11201069
1121 if (do_anonymize)
1122 PAnonymizer_Init((uint8_t *)CryptoPAnKey);
1123
11241070 nfprof_start(&profile_data);
11251071 sum_stat = process_data(wfile, element_stat, aggregate || flow_stat, date_sorted,
11261072 print_header, print_record, t_start, t_end,
1127 limitflows, do_anonymize, do_tag, compress);
1073 limitflows, do_tag, compress);
11281074 nfprof_end(&profile_data, total_flows);
11291075
11301076 if ( total_bytes == 0 )
11331079
11341080 if (aggregate || date_sorted) {
11351081 if ( wfile ) {
1136 ExportFlowTable(wfile, compress, aggregate, bidir, date_sorted, do_anonymize);
1082 ExportFlowTable(wfile, compress, aggregate, bidir, date_sorted);
11371083 } else {
1138 PrintFlowTable(print_record, limitflows, date_sorted, do_anonymize, do_tag, GuessDir);
1084 PrintFlowTable(print_record, limitflows, date_sorted, do_tag, GuessDir);
11391085 }
11401086 }
11411087
11421088 if (flow_stat) {
1143 PrintFlowStat(record_header, print_record, topN, do_anonymize, do_tag, quiet, csv_output);
1089 PrintFlowStat(record_header, print_record, topN, do_tag, quiet, csv_output);
11441090 #ifdef DEVEL
11451091 printf("Loopcnt: %u\n", loopcnt);
11461092 #endif
11471093 }
11481094
11491095 if (element_stat) {
1150 PrintElementStat(&sum_stat, record_header, print_record, topN, do_anonymize, do_tag, quiet, pipe_output, csv_output);
1096 PrintElementStat(&sum_stat, record_header, print_record, topN, do_tag, quiet, pipe_output, csv_output);
11511097 }
11521098
11531099 if ( !quiet ) {
11541100 if ( csv_output ) {
11551101 PrintSummary(&sum_stat, plain_numbers, csv_output);
11561102 } else if ( !wfile ) {
1157 if (do_anonymize)
1158 printf("IP addresses anonymized\n");
1103 if (IsAnonymized())
1104 printf("IP addresses anonymised\n");
11591105 PrintSummary(&sum_stat, plain_numbers, csv_output);
11601106 printf("Time window: %s\n", TimeString(t_first_flow, t_last_flow));
11611107 printf("Total flows processed: %u, Blocks skipped: %u, Bytes read: %llu\n",
137137 num_extensions++;
138138 }
139139 #ifdef DEVEL
140 printf("map: has_aggr_flows: %i, has_out_bytes: %i, has_out_packets: %i\n",
141 has_aggr_flows, has_out_bytes, has_out_packets);
140 printf("map: num_extensions: %i, has_aggr_flows: %i, has_out_bytes: %i, has_out_packets: %i\n",
141 num_extensions, has_aggr_flows, has_out_bytes, has_out_packets);
142142 #endif
143143
144144 // count missing extensions
153153 opt_extensions++;
154154
155155 // calculate new map size
156 new_map_size = sizeof(extension_map_t) + ( num_extensions + opt_extensions ) * sizeof(uint16_t);
157 #ifdef DEVEL
158 printf("opt_extensions: %i, new_map_size: %i\n", opt_extensions,new_map_size );
159 PrintExtensionMap(SourceMap);
160 #endif
156161 if ( opt_extensions ) {
157 new_map_size = sizeof(extension_map_t) + ( num_extensions + opt_extensions ) * sizeof(uint16_t);
158162 // align 32bits
159163 if (( new_map_size & 0x3 ) != 0 ) {
160164 new_map_size += 4 - ( new_map_size & 0x3 );
231235
232236 } // End of CreateExportExtensionMaps
233237
234 void ExportFlowTable(char *filename, int compress, int aggregate, int bidir, int date_sorted, int anon) {
238 void ExportFlowTable(char *filename, int compress, int aggregate, int bidir, int date_sorted) {
235239 hash_FlowTable *FlowTable;
236240 FlowTableRecord_t *r;
237241 SortElement_t *SortList;
238242 stat_record_t stat_record;
239 nffile_t nffile;
243 nffile_t *nffile;
240244 uint32_t i;
241245 uint32_t maxindex, c;
242246 char *string;
243247
244 // Init new stat record
248 // Init
245249 memset((void *)&stat_record, 0, sizeof(stat_record_t));
246250 stat_record.first_seen = 0x7fffffff;
247251 stat_record.msec_first = 999;
248252
249253 // Init nfile handle - open file
250 if ( !InitExportFile(filename, compress, &nffile) )
254 nffile = OpenNewFile(filename, NULL, compress, IsAnonymized(), &string);
255 if ( !nffile ) {
256 fprintf(stderr, "%s\n", string);
251257 return;
252
253 CreateExportExtensionMaps(aggregate, bidir, &nffile);
258 }
259
260 CreateExportExtensionMaps(aggregate, bidir, nffile);
254261
255262 FlowTable = GetFlowTable();
256263 c = 0;
288295 heapSort(SortList, c, 0);
289296
290297 for ( i = 0; i < c; i++ ) {
291 master_record_t flow_record;
298 master_record_t *flow_record;
292299 common_record_t *raw_record;
293300 int map_id;
294301
296303 raw_record = &(r->flowrecord);
297304 map_id = r->map_ref->map_id;
298305
299 ExpandRecord_v2( raw_record, extension_map_list.slot[map_id], &flow_record);
300 flow_record.dPkts = r->counter[INPACKETS];
301 flow_record.dOctets = r->counter[INBYTES];
302 flow_record.out_pkts = r->counter[OUTPACKETS];
303 flow_record.out_bytes = r->counter[OUTBYTES];
304 flow_record.aggr_flows = r->counter[FLOWS];
306 flow_record = &(extension_map_list.slot[map_id]->master_record);
307 ExpandRecord_v2( raw_record, extension_map_list.slot[map_id], flow_record);
308 flow_record->dPkts = r->counter[INPACKETS];
309 flow_record->dOctets = r->counter[INBYTES];
310 flow_record->out_pkts = r->counter[OUTPACKETS];
311 flow_record->out_bytes = r->counter[OUTBYTES];
312 flow_record->aggr_flows = r->counter[FLOWS];
305313
306314 // apply IP mask from aggregation, to provide a pretty output
307315 if ( FlowTable->has_masks ) {
308 flow_record.v6.srcaddr[0] &= FlowTable->IPmask[0];
309 flow_record.v6.srcaddr[1] &= FlowTable->IPmask[1];
310 flow_record.v6.dstaddr[0] &= FlowTable->IPmask[2];
311 flow_record.v6.dstaddr[1] &= FlowTable->IPmask[3];
316 flow_record->v6.srcaddr[0] &= FlowTable->IPmask[0];
317 flow_record->v6.srcaddr[1] &= FlowTable->IPmask[1];
318 flow_record->v6.dstaddr[0] &= FlowTable->IPmask[2];
319 flow_record->v6.dstaddr[1] &= FlowTable->IPmask[3];
312320 }
313321
314322 if ( FlowTable->apply_netbits )
315 ApplyNetMaskBits(&flow_record, FlowTable->apply_netbits);
323 ApplyNetMaskBits(flow_record, FlowTable->apply_netbits);
316324
317325 // switch to output extension map
318 flow_record.map_ref = export_maps[map_id];
319 flow_record.ext_map = map_id;
320 PackRecord(&flow_record, &nffile);
321 #ifdef DEVEL
322 format_file_block_record((void *)&flow_record, &string, anon, 0);
326 flow_record->map_ref = export_maps[map_id];
327 flow_record->ext_map = map_id;
328 PackRecord(flow_record, nffile);
329 #ifdef DEVEL
330 format_file_block_record((void *)flow_record, &string, 0);
323331 printf("%s\n", string);
324332 #endif
325333 // Update statistics
326 UpdateStat(&stat_record, &flow_record);
334 UpdateStat(&stat_record, flow_record);
327335 }
328336
329337 } else {
331339 for ( i=0; i<FlowTable->IndexMask; i++ ) {
332340 r = FlowTable->bucket[i];
333341 while ( r ) {
334 master_record_t flow_record;
342 master_record_t *flow_record;
335343 common_record_t *raw_record;
336344 int map_id;
337345
338346 raw_record = &(r->flowrecord);
339347 map_id = r->map_ref->map_id;
340348
341 ExpandRecord_v2( raw_record, extension_map_list.slot[map_id], &flow_record);
342 flow_record.dPkts = r->counter[INPACKETS];
343 flow_record.dOctets = r->counter[INBYTES];
344 flow_record.out_pkts = r->counter[OUTPACKETS];
345 flow_record.out_bytes = r->counter[OUTBYTES];
346 flow_record.aggr_flows = r->counter[FLOWS];
349 flow_record = &(extension_map_list.slot[map_id]->master_record);
350 ExpandRecord_v2( raw_record, extension_map_list.slot[map_id], flow_record);
351 flow_record->dPkts = r->counter[INPACKETS];
352 flow_record->dOctets = r->counter[INBYTES];
353 flow_record->out_pkts = r->counter[OUTPACKETS];
354 flow_record->out_bytes = r->counter[OUTBYTES];
355 flow_record->aggr_flows = r->counter[FLOWS];
347356
348357 // apply IP mask from aggregation, to provide a pretty output
349358 if ( FlowTable->has_masks ) {
350 flow_record.v6.srcaddr[0] &= FlowTable->IPmask[0];
351 flow_record.v6.srcaddr[1] &= FlowTable->IPmask[1];
352 flow_record.v6.dstaddr[0] &= FlowTable->IPmask[2];
353 flow_record.v6.dstaddr[1] &= FlowTable->IPmask[3];
359 flow_record->v6.srcaddr[0] &= FlowTable->IPmask[0];
360 flow_record->v6.srcaddr[1] &= FlowTable->IPmask[1];
361 flow_record->v6.dstaddr[0] &= FlowTable->IPmask[2];
362 flow_record->v6.dstaddr[1] &= FlowTable->IPmask[3];
354363 }
355364
356365
357366 // switch to output extension map
358 flow_record.map_ref = export_maps[map_id];
359 flow_record.ext_map = map_id;
360 PackRecord(&flow_record, &nffile);
361 #ifdef DEVEL
362 format_file_block_record((void *)&flow_record, &string, anon, 0);
367 flow_record->map_ref = export_maps[map_id];
368 flow_record->ext_map = map_id;
369 PackRecord(flow_record, nffile);
370 #ifdef DEVEL
371 format_file_block_record((void *)flow_record, &string, 0);
363372 printf("%s\n", string);
364373 #endif
365374 // Update statistics
366 UpdateStat(&stat_record, &flow_record);
375 UpdateStat(&stat_record, flow_record);
367376
368377 r = r->next;
369378 }
371380
372381 }
373382
374 if ( nffile.block_header->NumRecords ) {
375 if ( WriteBlock(&nffile) <= 0 ) {
383 if ( nffile->block_header->NumRecords ) {
384 if ( WriteBlock(nffile) <= 0 ) {
376385 fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno));
377386 }
378387 }
379388
380 CloseUpdateFile(nffile.wfd, &stat_record, nffile.file_blocks, GetIdent(), nffile.compress, &string );
389 CloseUpdateFile(nffile, &stat_record, GetIdent(), &string );
381390 if ( string != NULL )
382391 fprintf(stderr, "%s\n", string);
392 nffile = DisposeFile(nffile);
383393
384394 } // End of PrintFlowTable
385395
3737 #ifndef _NFEXPORT_H
3838 #define _NFEXPORT_H 1
3939
40 void ExportFlowTable(char *filename, int compress, int aggregate, int bidir, int date_sorted, int anon);
40 void ExportFlowTable(char *filename, int compress, int aggregate, int bidir, int date_sorted);
4141
4242 #endif //_NFEXPORT_H
4343
8787
8888 static void ZeroStat(void);
8989
90 static int WriteSTDOUTFileheader(void);
91
9290 /* function definitions */
9391
9492 static void ZeroStat() {
140138 s2->msec_last > s1->msec_last )
141139 s1->msec_last = s2->msec_last;
142140
143 } // End of AddStatRecords
141 } // End of SumStatRecords
144142
145143
146144 char *GetIdent(void) {
148146 return CurrentIdent;
149147
150148 } // End of GetIdent
149
150 int IsCompressed(void) {
151 return file_compressed;
152 } // End of IsCompressed
153
154 int IsAnonymized(void) {
155 return (FileHeader.flags & FLAG_ANONYMIZED);
156 } // End of IsCompressed
151157
152158 static int LZO_initialize(void) {
153159
155161 // this usually indicates a compiler bug - try recompiling
156162 // without optimizations, and enable `-DLZO_DEBUG' for diagnostics
157163 snprintf(error_string, ERR_SIZE,"Compression lzo_init() failed.\n");
158 error_string[ERR_SIZE-1] = 0;
159164 return 0;
160165 }
161166 lzo_buff = malloc(BUFFSIZE+ sizeof(data_block_header_t));
373378 printf("Sequence failures: %u\n", s->sequence_failure);
374379 } // End of PrintStat
375380
376 int InitExportFile(char *filename, int compress, nffile_t *nffile ) {
377 char *string;
381 static void InitFile(nffile_t *nffile) {
382
383 // Init header
384 nffile->file_header->magic = MAGIC;
385 nffile->file_header->version = LAYOUT_VERSION_1;
386 nffile->file_header->flags = 0;
387 nffile->file_header->NumBlocks = 0;
378388
379389 // Init vars
380 nffile->block_header = NULL;
381390 nffile->writeto = NULL;
382 nffile->file_blocks = 0;
383 nffile->compress = compress;
384391 nffile->wfd = 0;
385392
386 if ( !filename )
387 return 0;
388
389 if ( strcmp(filename, "-") == 0 ) { // output to stdout
390 if ( !WriteSTDOUTFileheader() ) {
391 return 0;
392 }
393 nffile->wfd = STDOUT_FILENO;
394
395 } else {
396 nffile->wfd = OpenNewFile(filename, &string, nffile->compress);
397 if ( nffile->wfd < 0 ) {
398 if ( string != NULL )
399 fprintf(stderr, "%s\n", string);
400 return 0;
401 }
402 }
403
404 // init all nffile vars
405 nffile->block_header = malloc(BUFFSIZE + sizeof(data_block_header_t));
406 if ( !nffile->block_header ) {
407 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
408 return 0;
409 }
393 // Init block header
410394 nffile->block_header->size = 0;
411395 nffile->block_header->NumRecords = 0;
412396 nffile->block_header->id = DATA_BLOCK_TYPE_2;
413397 nffile->block_header->pad = 0;
414398 nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t));
415399
416 return 1;
417 } // End of InitExportFile
418
419 int OpenNewFile(char *filename, char **err, int compressed) {
420 file_header_t *file_header;
400 } // End of InitFile
401
402 nffile_t *NewFile(void) {
403 nffile_t *nffile;
404
405 // Create struct
406 nffile = calloc(1, sizeof(nffile_t));
407 if ( !nffile ) {
408 snprintf(error_string, ERR_SIZE, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
409 error_string[ERR_SIZE-1] = 0;
410 return NULL;
411 }
412
413 // Init file header
414 nffile->file_header = calloc(1, sizeof(file_header_t));
415 if ( !nffile->file_header ) {
416 snprintf(error_string, ERR_SIZE, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
417 error_string[ERR_SIZE-1] = 0;
418 return NULL;
419 }
420
421 // init output data buffer
422 nffile->block_header = malloc(BUFFSIZE + sizeof(data_block_header_t));
423 if ( !nffile->block_header ) {
424 snprintf(error_string, ERR_SIZE, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
425 error_string[ERR_SIZE-1] = 0;
426 return NULL;
427 }
428
429 return nffile;
430
431 } // End of NewFile
432
433 nffile_t *DisposeFile(nffile_t *nffile) {
434 free(nffile->file_header);
435 free(nffile->block_header);
436 free(nffile);
437 return NULL;
438 } // End of
439
440 nffile_t *OpenNewFile(char *filename, nffile_t *nffile, int compressed, int anonymized, char **err) {
441 stat_record_t stat_record;
421442 size_t len;
422 int nffd;
443 int flags;
444
445 // Allocate new struct if not given
446 if ( nffile == NULL ) {
447 nffile = NewFile();
448 if ( nffile == NULL ) {
449 *err = error_string;
450 return NULL;
451 }
452 }
453
454 InitFile(nffile);
455
456 flags = compressed ? FLAG_COMPRESSED : 0;
457 if ( anonymized )
458 SetFlag(flags, FLAG_ANONYMIZED);
459
460 nffile->file_header->flags = flags;
461
462 if ( strcmp(filename, "-") == 0 ) { // output to stdout
463 nffile->wfd = STDOUT_FILENO;
464 } else {
465 nffile->wfd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
466 if ( nffile->wfd < 0 ) {
467 snprintf(error_string, ERR_SIZE, "Failed to open file %s: '%s'" , filename, strerror(errno));
468 error_string[ERR_SIZE-1] = 0;
469 *err = error_string;
470 return NULL;
471 }
472 }
473
474 memset((void *)&stat_record, 0, sizeof(stat_record));
475
476 if ( TestFlag(flags, FLAG_COMPRESSED) ) {
477 if ( !lzo_initialized && !LZO_initialize() ) {
478 snprintf(error_string, ERR_SIZE, "Failed to initialize compression");
479 *err = error_string;
480 close(nffile->wfd);
481 return NULL;
482 }
483 }
484
485 len = sizeof(file_header_t);
486 if ( write(nffile->wfd, (void *)nffile->file_header, len) < len ) {
487 snprintf(error_string, ERR_SIZE, "Failed to write file header: '%s'" , strerror(errno));
488 error_string[ERR_SIZE-1] = 0;
489 *err = error_string;
490 close(nffile->wfd);
491 return NULL;
492 }
493
494 // write empty stat record - ist updated when file gets closed
495 len = sizeof(stat_record_t);
496 if ( write(nffile->wfd, (void *)&stat_record, len) < len ) {
497 snprintf(error_string, ERR_SIZE, "Failed to write file header: '%s'" , strerror(errno));
498 error_string[ERR_SIZE-1] = 0;
499 *err = error_string;
500 close(nffile->wfd);
501 return NULL;
502 }
503
504 return nffile;
505
506 } /* End of OpenNewFile */
507
508 void CloseUpdateFile(nffile_t *nffile, stat_record_t *stat_record, char *ident, char **err ) {
509 file_header_t file_header;
423510
424511 *err = NULL;
425 nffd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
426 if ( nffd < 0 ) {
427 snprintf(error_string, ERR_SIZE, "Failed to open file %s: '%s'" , filename, strerror(errno));
428 error_string[ERR_SIZE-1] = 0;
429 *err = error_string;
430 return -1;
431 }
432
433 len = sizeof(file_header_t) + sizeof(stat_record_t);
434 file_header = (file_header_t *)malloc(len);
435 memset((void *)file_header, 0, len);
436
437 /* magic set, version = 0 => file open for writing */
438 file_header->magic = MAGIC;
439
440 if ( compressed ) {
441 if ( !lzo_initialized && !LZO_initialize() ) {
442 *err = error_string;
443 close(nffd);
444 return -1;
445 }
446 file_header->flags |= FLAG_COMPRESSED;
447 }
448
449 if ( write(nffd, (void *)file_header, len) < len ) {
450 snprintf(error_string, ERR_SIZE, "Failed to write file header: '%s'" , strerror(errno));
451 error_string[ERR_SIZE-1] = 0;
452 *err = error_string;
453 close(nffd);
454 return -1;
455 }
456
457 return nffd;
458
459 } /* End of OpenNewFile */
460
461 void CloseUpdateFile(int fd, stat_record_t *stat_record, uint32_t record_count, char *ident, int compressed, char **err ) {
462 file_header_t file_header;
463
464 *err = NULL;
465
466 file_header.magic = MAGIC;
467 file_header.version = LAYOUT_VERSION_1;
468 file_header.flags = compressed ? FLAG_COMPRESSED : 0;
469 file_header.NumBlocks = record_count;
470 strncpy(file_header.ident, ident ? ident : "unknown" , IdentLen);
512 if ( lseek(nffile->wfd, 0, SEEK_SET) < 0 ) {
513 // lseek on stdout works if output redirected:
514 // e.g. -w - > outfile
515 // but fails on pipe e.g. -w - | ./nfdump ....
516 if ( nffile->wfd == STDOUT_FILENO ) {
517 return;
518 } else {
519 snprintf(error_string, ERR_SIZE,"lseek failed: '%s'\n" , strerror(errno));
520 error_string[ERR_SIZE-1] = 0;
521 *err = error_string;
522 close(nffile->wfd);
523 return;
524 }
525 }
526
527 strncpy(nffile->file_header->ident, ident ? ident : "unknown" , IdentLen);
471528 file_header.ident[IdentLen - 1] = 0;
472529
473 if ( lseek(fd, 0, SEEK_SET) < 0 ) {
474 snprintf(error_string, ERR_SIZE,"lseek failed: '%s'\n" , strerror(errno));
475 error_string[ERR_SIZE-1] = 0;
476 *err = error_string;
477 close(fd);
478 return;
479 }
480
481 write(fd, (void *)&file_header, sizeof(file_header_t));
482 write(fd, (void *)stat_record, sizeof(stat_record_t));
483 if ( close(fd) < 0 ) {
530 write(nffile->wfd, (void *)nffile->file_header, sizeof(file_header_t));
531 write(nffile->wfd, (void *)stat_record, sizeof(stat_record_t));
532 if ( close(nffile->wfd) < 0 ) {
484533 snprintf(error_string, ERR_SIZE,"close failed: '%s'" , strerror(errno));
485534 error_string[ERR_SIZE-1] = 0;
486535 *err = error_string;
606655 lzo_uint in_len;
607656 lzo_uint out_len;
608657
609 if ( !nffile->compress ) {
658 if ( !TestFlag(nffile->file_header->flags, FLAG_COMPRESSED) ) {
610659 return write(nffile->wfd, (void *)nffile->block_header, sizeof(data_block_header_t) + nffile->block_header->size);
611660 }
612661
688737 } // End of ExpandRecord_v1
689738
690739 void UnCompressFile(char * filename) {
691 int i, rfd;
740 int i, rfd, flags, compressed, anonymized;
692741 ssize_t ret;
693 nffile_t nffile;
742 nffile_t *nffile;
694743 stat_record_t *stat_ptr;
695744 char *string;
696745 char outfile[MAXPATHLEN];
706755 snprintf(outfile, MAXPATHLEN, "%s-tmp", filename);
707756 outfile[MAXPATHLEN-1] = '\0';
708757
709 // allocate output buffer
710 nffile.block_header = (data_block_header_t *)malloc(BUFFSIZE+ sizeof(data_block_header_t));
711 if ( !nffile.block_header ) {
712 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror (errno));
758 flags = FileHeader.flags;
759 if ( file_compressed ) {
760 printf("Uncompress file .. \n");
761 compressed = 0;
762 } else {
763 printf("Compress file .. \n");
764 compressed = 1;
765 }
766 anonymized = IsAnonymized();
767
768 // allocate output file
769 nffile = OpenNewFile(outfile, NULL, compressed, anonymized, &string);
770 if ( !nffile ) {
771 fprintf(stderr, "%s\n", string);
713772 close(rfd);
714773 return;
715774 }
716775
717 buff_ptr = (void *)((pointer_addr_t)nffile.block_header + sizeof(data_block_header_t));
718
719 nffile.compress = file_compressed ? 0 : 1;
720
721 nffile.wfd = OpenNewFile(outfile, &string, nffile.compress);
722 if ( nffile.wfd < 0 ) {
723 fprintf(stderr, "%s", string);
724 return;
725 }
726
727 if ( nffile.compress )
728 printf("Compress file .. \n");
729 else
730 printf("Uncompress file .. \n");
776 buff_ptr = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t));
731777
732778 for ( i=0; i < FileHeader.NumBlocks; i++ ) {
733 ret = ReadBlock(rfd, nffile.block_header, buff_ptr, &string);
779 ret = ReadBlock(rfd, nffile->block_header, buff_ptr, &string);
734780 if ( ret < 0 ) {
735781 fprintf(stderr, "Error while reading data block. Abort.\n");
736782 close(rfd);
737 close(nffile.wfd);
783 close(nffile->wfd);
738784 unlink(outfile);
739785 return;
740786 }
741 if ( WriteBlock(&nffile) <= 0 ) {
787 if ( WriteBlock(nffile) <= 0 ) {
742788 fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno));
743789 close(rfd);
744 close(nffile.wfd);
790 close(nffile->wfd);
745791 unlink(outfile);
746792 return;
747793 }
748794 }
749795
750796 close(rfd);
751 CloseUpdateFile(nffile.wfd, stat_ptr, FileHeader.NumBlocks, GetIdent(), nffile.compress, &string );
797 CloseUpdateFile(nffile, stat_ptr, GetIdent(), &string );
752798 if ( string != NULL ) {
753799 fprintf(stderr, "%s\n", string);
754 close(nffile.wfd);
800 close(nffile->wfd);
755801 unlink(outfile);
756 return;
757802 } else {
758 close(nffile.wfd);
803 close(nffile->wfd);
759804 unlink(filename);
760805 rename(outfile, filename);
761806 }
807 DisposeFile(nffile);
762808
763809 } // End of UnCompressFile
764810
812858 close(fd);
813859
814860 } // End of QueryFile
815
816 static int WriteSTDOUTFileheader(void) {
817 file_header_t *file_header;
818 size_t len;
819
820 len = sizeof(file_header_t) + sizeof(stat_record_t);
821 file_header = (file_header_t *)calloc(1,len);
822 if ( !file_header ) {
823 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
824 return 0;
825 }
826
827 // we do not compress data on stdout
828 file_header->magic = MAGIC;
829 file_header->version = LAYOUT_VERSION_1;
830 strncpy(file_header->ident, "none", sizeof(file_header->ident));
831 if ( write(STDOUT_FILENO, (void *)file_header, len) < 0 ) {
832 fprintf(stderr, "write() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
833 return 0;
834 } else {
835 return 1;
836 }
837
838 } // End of WriteSTDOUTFileheader
839861
840862 #ifdef COMPAT15
841863 /*
7171 #define LAYOUT_VERSION_1 1
7272
7373 uint32_t flags;
74 #define NUM_FLAGS 2
74 #define NUM_FLAGS 3
7575 #define FLAG_COMPRESSED 0x1
76 #define FLAG_EXTENDED_STATS 0x2
76 #define FLAG_ANONYMIZED 0x2
77 #define FLAG_EXTENDED_STATS 0x4
7778 /*
7879 0x1 File is compressed with LZO1X-1 compression
7980 */
8283 } file_header_t;
8384
8485 /* FLAG_EXTENDED_STATS bit = 0
85 * Compatible with nfdump 1.5.x file format: After the file header an
86 * Compatible with nfdump x.x.x file format: After the file header an
8687 * inplicit stat record follows, which contains the statistics
8788 * information about all netflow records in this file.
8889 */
117118 } stat_record_t;
118119
119120 /* FLAG_EXTENDED_STATS bit = 1
120 * nfdump 1.6.x file format: Extended stat record.
121 * The extended stat record is identified by a header describing it's type and length
122 * various extension may add specific stats.
121 * not yet implemented
123122 */
124123
125124 typedef struct stat_header_s {
156155 * Generic fle handle for writing files
157156 */
158157 typedef struct nffile_s {
158 file_header_t *file_header; // file header
159159 data_block_header_t *block_header; // output buffer
160160 void *writeto; // pointer into buffer for next availabe memory
161 uint32_t file_blocks; // number of blocks in file
162 int compress; // data compressed flag
161 int _compress; // data compressed flag
163162 int wfd; // file id
164163 } nffile_t;
165164
13531352
13541353 int OpenFile(char *filename, stat_record_t **stat_record, char **err);
13551354
1356 int OpenNewFile(char *filename, char **err, int compressed);
1355 nffile_t *OpenNewFile(char *filename, nffile_t *nffile, int compressed, int anonymized, char **err);
13571356
13581357 int ChangeIdent(char *filename, char *Ident, char **err);
13591358
13611360
13621361 void QueryFile(char *filename);
13631362
1364 void CloseUpdateFile(int fd, stat_record_t *stat_record, uint32_t record_count, char *ident, int compressed, char **err );
1363 nffile_t *NewFile(void);
1364
1365 nffile_t *DisposeFile(nffile_t *nffile);
1366
1367 void CloseUpdateFile(nffile_t *nffile, stat_record_t *stat_record, char *ident, char **err );
13651368
13661369 int ReadBlock(int rfd, data_block_header_t *block_header, void *read_buff, char **err);
13671370
13711374
13721375 char *GetIdent(void);
13731376
1374 int InitExportFile(char *filename, int compress, nffile_t *nffile );
1377 int IsCompressed(void);
1378
1379 int IsAnonymized(void);
13751380
13761381 void ExpandRecord_v1(common_record_t *input_record,master_record_t *output_record );
13771382
7070 nffile->block_header->size = 0;
7171 nffile->block_header->NumRecords = 0;
7272 nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t) );
73 nffile->file_blocks++;
73 nffile->file_header->NumBlocks++;
7474 }
7575 }
7676
359359 nffile->block_header->size = 0;
360360 nffile->block_header->NumRecords = 0;
361361 nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t) );
362 nffile->file_blocks++;
362 nffile->file_header->NumBlocks++;
363363 }
364364 }
365365
578578
579579 } // End of PackRecord
580580
581
582581 static inline void AppendToBuffer(nffile_t *nffile, void *record, size_t required) {
583582
584583 // flush current buffer to disc
597596 nffile->block_header->size = 0;
598597 nffile->block_header->NumRecords = 0;
599598 nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t) );
600 nffile->file_blocks++;
599 nffile->file_header->NumBlocks++;
601600 }
602601
603602 }
613612 nffile->writeto = (void *)((pointer_addr_t)nffile->writeto + required);
614613
615614 } // End of AppendToBuffer
616
172172
173173 int main( int argc, char **argv ) {
174174 int i, c;
175 file_header_t *file_header;
176175 master_record_t record;
177 nffile_t nffile;
178 size_t len;
179 void *records;
176 nffile_t *nffile;
177 char *string;
180178
181179 when = ISO2UNIX(strdup("200407111030"));
182 // Init vars
183 nffile.block_header = NULL;
184 nffile.writeto = NULL;
185 nffile.file_blocks = 0;
186 nffile.compress = 0;
187 nffile.wfd = 0;
188
189180 while ((c = getopt(argc, argv, "h")) != EOF) {
190181 switch(c) {
191182 case 'h':
235226 }
236227 memset((void *)&record, 0, sizeof(record));
237228
238 nffile.block_header = (data_block_header_t *)malloc(sizeof(data_block_header_t) + BUFFSIZE);
239 if ( !nffile.block_header ) {
240 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror (errno));
229 nffile = OpenNewFile("-", NULL, 0, 0, &string);
230 if ( !nffile ) {
231 fprintf(stderr, "%s\n", string);
241232 exit(255);
242233 }
243 nffile.block_header->NumRecords = 0;
244 nffile.block_header->pad = 0;
245 nffile.block_header->size = 0;
246 nffile.block_header->id = DATA_BLOCK_TYPE_2;
247 nffile.wfd = STDOUT_FILENO;
248 nffile.writeto = records = (void *)((pointer_addr_t)nffile.block_header + sizeof(data_block_header_t));
249
250 // initialize file header and dummy stat record
251 len = sizeof(file_header_t) + sizeof(stat_record_t);
252 file_header = (file_header_t *)malloc(len);
253 if ( !file_header ) {
254 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror (errno));
255 exit(255);
256 }
257 memset((void *)file_header, 0, len);
258
259 file_header->magic = MAGIC;
260 file_header->version = LAYOUT_VERSION_1;
261 strncpy(file_header->ident, "none", IDENT_SIZE);
262 write(STDOUT_FILENO, (void *)file_header, len) ;
263
264 memcpy(nffile.writeto, (void *)extension_info.map, extension_info.map->size);
265 nffile.writeto += extension_info.map->size;
266 nffile.block_header->NumRecords = 1;
267 nffile.block_header->size = extension_info.map->size;
234
235 AppendToBuffer(nffile, (void *)extension_info.map, extension_info.map->size);
268236
269237 record.map_ref = extension_info.map;
270238 record.type = CommonRecordType;
314282
315283 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
316284 UpdateRecord(&record);
317 PackRecord(&record, &nffile);
285 PackRecord(&record, nffile);
318286
319287 SetIPaddress(&record, PF_INET, "172.16.2.66", "192.168.170.101");
320288 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
321289 UpdateRecord(&record);
322 PackRecord(&record, &nffile);
290 PackRecord(&record, nffile);
323291
324292 record.dPkts = 101;
325293 record.dOctets = 102;
326294 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
327295 UpdateRecord(&record);
328 PackRecord(&record, &nffile);
296 PackRecord(&record, nffile);
329297
330298 SetIPaddress(&record, PF_INET, "172.16.3.66", "192.168.170.102");
331299 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
332300 UpdateRecord(&record);
333 PackRecord(&record, &nffile);
301 PackRecord(&record, nffile);
334302
335303 SetIPaddress(&record, PF_INET, "172.16.4.66", "192.168.170.103");
336304 record.srcport = 2024;
341309 record.dOctets = 1002;
342310 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
343311 UpdateRecord(&record);
344 PackRecord(&record, &nffile);
312 PackRecord(&record, nffile);
345313
346314 SetIPaddress(&record, PF_INET, "172.16.5.66", "192.168.170.104");
347315 record.srcport = 3024;
352320 record.dOctets = 10002;
353321 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
354322 UpdateRecord(&record);
355 PackRecord(&record, &nffile);
323 PackRecord(&record, nffile);
356324
357325 SetIPaddress(&record, PF_INET, "172.16.6.66", "192.168.170.105");
358326 record.srcport = 4024;
363331 record.dOctets = 100002;
364332 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
365333 UpdateRecord(&record);
366 PackRecord(&record, &nffile);
334 PackRecord(&record, nffile);
367335
368336 SetIPaddress(&record, PF_INET, "172.16.7.66", "192.168.170.106");
369337 record.srcport = 5024;
373341 record.dOctets = 1000002;
374342 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
375343 UpdateRecord(&record);
376 PackRecord(&record, &nffile);
344 PackRecord(&record, nffile);
377345
378346 SetIPaddress(&record, PF_INET, "172.16.8.66", "192.168.170.107");
379347 record.tcp_flags = 1;
382350 record.dOctets = 1001;
383351 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
384352 UpdateRecord(&record);
385 PackRecord(&record, &nffile);
353 PackRecord(&record, nffile);
386354
387355 SetIPaddress(&record, PF_INET, "172.16.9.66", "192.168.170.108");
388356 record.srcport = 6024;
392360 record.dOctets = 10000001;
393361 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
394362 UpdateRecord(&record);
395 PackRecord(&record, &nffile);
363 PackRecord(&record, nffile);
396364
397365 SetIPaddress(&record, PF_INET, "172.16.10.66", "192.168.170.109");
398366 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
399367 UpdateRecord(&record);
400 PackRecord(&record, &nffile);
368 PackRecord(&record, nffile);
401369
402370 SetIPaddress(&record, PF_INET, "172.16.11.66", "192.168.170.110");
403371 record.srcport = 7024;
407375 record.dOctets = 100000001;
408376 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
409377 UpdateRecord(&record);
410 PackRecord(&record, &nffile);
378 PackRecord(&record, nffile);
411379
412380 SetIPaddress(&record, PF_INET, "172.16.12.66", "192.168.170.111");
413381 record.srcport = 8024;
416384 record.dOctets = 1000000001;
417385 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
418386 UpdateRecord(&record);
419 PackRecord(&record, &nffile);
387 PackRecord(&record, nffile);
420388
421389 SetIPaddress(&record, PF_INET, "172.16.13.66", "192.168.170.112");
422390 record.srcport = 0;
428396 record.dOctets = 50000;
429397 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
430398 UpdateRecord(&record);
431 PackRecord(&record, &nffile);
399 PackRecord(&record, nffile);
432400
433401 SetIPaddress(&record, PF_INET, "172.160.160.166", "172.160.160.180");
434402 record.srcport = 10024;
438406 record.dOctets = 500000;
439407 fprintf(stderr, "IPv4 32bit packets 32bit bytes\n");
440408 UpdateRecord(&record);
441 PackRecord(&record, &nffile);
409 PackRecord(&record, nffile);
442410
443411 SetIPaddress(&record, PF_INET6, "fe80::2110:abcd:1234:0", "fe80::2110:abcd:1235:4321");
444412 // SetNextIPaddress(&record, PF_INET6, "2003:234:aabb::211:24ff:fe80:d01e");
450418 record.dOctets = 15100;
451419 fprintf(stderr, "IPv6 32bit packets 32bit bytes\n");
452420 UpdateRecord(&record);
453 PackRecord(&record, &nffile);
421 PackRecord(&record, nffile);
454422
455423 SetIPaddress(&record, PF_INET6, "2001:234:aabb::211:24ff:fe80:d01e", "2001:620::8:203:baff:fe52:38e5");
456424 record.srcport = 10240;
459427 record.dOctets = 15000000;
460428 fprintf(stderr, "IPv6 32bit packets 32bit bytes\n");
461429 UpdateRecord(&record);
462 PackRecord(&record, &nffile);
430 PackRecord(&record, nffile);
463431
464432 record.dPkts = 10100000;
465433 record.dOctets = 0x100000000LL;
466434 fprintf(stderr, "IPv6 32bit packets 64bit bytes\n");
467435 UpdateRecord(&record);
468 PackRecord(&record, &nffile);
436 PackRecord(&record, nffile);
469437
470438 record.dPkts = 0x100000000LL;
471439 record.dOctets = 15000000;
472440 fprintf(stderr, "IPv6 64bit packets 32bit bytes\n");
473441 UpdateRecord(&record);
474 PackRecord(&record, &nffile);
442 PackRecord(&record, nffile);
475443
476444 record.dOctets = 0x200000000LL;
477445 fprintf(stderr, "IPv6 64bit packets 64bit bytes\n");
478446 UpdateRecord(&record);
479 PackRecord(&record, &nffile);
447 PackRecord(&record, nffile);
480448
481449 SetIPaddress(&record, PF_INET, "172.16.14.18", "192.168.170.113");
482450 // SetNextIPaddress(&record, PF_INET, "172.72.1.2");
487455 record.dOctets = 0x100000000LL;
488456 fprintf(stderr, "IPv4 32bit packets 64bit bytes\n");
489457 UpdateRecord(&record);
490 PackRecord(&record, &nffile);
458 PackRecord(&record, nffile);
491459
492460 SetIPaddress(&record, PF_INET, "172.16.15.18", "192.168.170.114");
493461 record.dPkts = 0x100000000LL;
494462 record.dOctets = 15000000;
495463 fprintf(stderr, "IPv4 64bit packets 32bit bytes\n");
496464 UpdateRecord(&record);
497 PackRecord(&record, &nffile);
465 PackRecord(&record, nffile);
498466
499467 SetIPaddress(&record, PF_INET, "172.16.16.18", "192.168.170.115");
500468 record.dOctets = 0x200000000LL;
501469 fprintf(stderr, "IPv4 64bit packets 64bit bytes\n");
502470 UpdateRecord(&record);
503 PackRecord(&record, &nffile);
471 PackRecord(&record, nffile);
504472
505473 extension_info.map->ex_id[0] = EX_IO_SNMP_4;
506474
512480 i++;
513481 }
514482
515 memcpy(nffile.writeto, (void *)extension_info.map, extension_info.map->size);
516 nffile.writeto += extension_info.map->size;
517 nffile.block_header->NumRecords++;
518 nffile.block_header->size += extension_info.map->size;
519
520 UpdateRecord(&record);
521 fprintf(stderr, "4 bytes interfaces, 2 bytes AS numbers %d %d\n", record.fwd_status, nffile.block_header->NumRecords);
522 PackRecord(&record, &nffile);
483 memcpy(nffile->writeto, (void *)extension_info.map, extension_info.map->size);
484 nffile->writeto += extension_info.map->size;
485 nffile->block_header->NumRecords++;
486 nffile->block_header->size += extension_info.map->size;
487
488 UpdateRecord(&record);
489 fprintf(stderr, "4 bytes interfaces, 2 bytes AS numbers %d %d\n", record.fwd_status, nffile->block_header->NumRecords);
490 PackRecord(&record, nffile);
523491
524492 extension_info.map->ex_id[0] = EX_IO_SNMP_2;
525493 extension_info.map->ex_id[1] = EX_AS_4;
532500 i++;
533501 }
534502
535 memcpy(nffile.writeto, (void *)extension_info.map, extension_info.map->size);
536 nffile.writeto += extension_info.map->size;
537 nffile.block_header->NumRecords++;
538 nffile.block_header->size += extension_info.map->size;
539
540 UpdateRecord(&record);
541 fprintf(stderr, "2 bytes interfaces, 4 bytes AS numbers %d %d\n", record.fwd_status, nffile.block_header->NumRecords);
542 PackRecord(&record, &nffile);
503 memcpy(nffile->writeto, (void *)extension_info.map, extension_info.map->size);
504 nffile->writeto += extension_info.map->size;
505 nffile->block_header->NumRecords++;
506 nffile->block_header->size += extension_info.map->size;
507
508 UpdateRecord(&record);
509 fprintf(stderr, "2 bytes interfaces, 4 bytes AS numbers %d %d\n", record.fwd_status, nffile->block_header->NumRecords);
510 PackRecord(&record, nffile);
543511
544512 extension_info.map->ex_id[0] = EX_IO_SNMP_4;
545513
551519 i++;
552520 }
553521
554 memcpy(nffile.writeto, (void *)extension_info.map, extension_info.map->size);
555 nffile.writeto += extension_info.map->size;
556 nffile.block_header->NumRecords++;
557 nffile.block_header->size += extension_info.map->size;
558
559 UpdateRecord(&record);
560 fprintf(stderr, "4 bytes interfaces, 4 bytes AS numbers %d %d\n", record.fwd_status, nffile.block_header->NumRecords);
561 PackRecord(&record, &nffile);
562
563 if ( nffile.block_header->NumRecords ) {
564 if ( WriteBlock(&nffile) <= 0 ) {
522 memcpy(nffile->writeto, (void *)extension_info.map, extension_info.map->size);
523 nffile->writeto += extension_info.map->size;
524 nffile->block_header->NumRecords++;
525 nffile->block_header->size += extension_info.map->size;
526
527 UpdateRecord(&record);
528 fprintf(stderr, "4 bytes interfaces, 4 bytes AS numbers %d %d\n", record.fwd_status, nffile->block_header->NumRecords);
529 PackRecord(&record, nffile);
530
531 if ( nffile->block_header->NumRecords ) {
532 if ( WriteBlock(nffile) <= 0 ) {
565533 fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno));
566534 }
567535 }
7272
7373 extension_map_list_t extension_map_list;
7474
75 /* exported fuctions */
76 void LogError(char *format, ...);
77
7875 /* Function Prototypes */
7976 static void usage(char *name);
8077
184181 if ( Insert_Extension_Map(&extension_map_list, map) ) {
185182 int j;
186183 for ( j=0; j < num_channels; j++ ) {
187 if ( channels[j].nffile.wfd > 0 ) {
184 if ( channels[j].nffile != NULL) {
188185 // flush new map
189 AppendToBuffer(&channels[j].nffile, (void *)map, map->size);
186 AppendToBuffer(channels[j].nffile, (void *)map, map->size);
190187 }
191188 }
192189 } // else map already known and flushed
239236
240237 // do we need to write data to new file - shadow profiles do not have files.
241238 // check if we need to flush the output buffer
242 if ( channels[j].nffile.wfd > 0 ) {
239 if ( channels[j].nffile != NULL ) {
243240 // write record to output buffer
244 AppendToBuffer(&channels[j].nffile, (void *)flow_record, flow_record->size);
241 AppendToBuffer(channels[j].nffile, (void *)flow_record, flow_record->size);
245242 }
246243
247244 } // End of for all channels
252249 if ( Insert_Extension_Map(&extension_map_list, map) ) {
253250 int j;
254251 for ( j=0; j < num_channels; j++ ) {
255 if ( channels[j].nffile.wfd > 0 ) {
252 if ( channels[j].nffile != NULL ) {
256253 // flush new map
257 AppendToBuffer(&channels[j].nffile, (void *)map, map->size);
254 AppendToBuffer(channels[j].nffile, (void *)map, map->size);
258255 }
259256 }
260257 } // else map already known and flushed
271268
272269 // do we need to write data to new file - shadow profiles do not have files.
273270 for ( j=0; j < num_channels; j++ ) {
274 if ( channels[j].nffile.wfd > 0 ) {
271 if ( channels[j].nffile != NULL ) {
275272 // flush output buffer
276 if ( channels[j].nffile.block_header->NumRecords ) {
277 if ( WriteBlock(&(channels[j].nffile)) <= 0 ) {
273 if ( channels[j].nffile->block_header->NumRecords ) {
274 if ( WriteBlock(channels[j].nffile) <= 0 ) {
278275 LogError("Failed to write output buffer to disk: '%s'" , strerror(errno));
279276 } else {
280 free((void *)channels[j].nffile.block_header);
281 channels[j].nffile.writeto = NULL;
282 channels[j].nffile.file_blocks++;
277 channels[j].nffile->file_header->NumBlocks++;
283278 }
284279 }
285280 }
Binary diff not shown
7373 #include "flist.h"
7474 #include "util.h"
7575 #include "grammar.h"
76 #include "panonymizer.h"
7776
7877 #define DEFAULTCISCOPORT "9995"
7978 #define DEFAULTHOSTNAME "127.0.0.1"
103102 /* Function Prototypes */
104103 static void usage(char *name);
105104
106 static int ParseCryptoPAnKey ( char *s, char *key );
107
108105 static void send_blast(unsigned int delay );
109106
110107 static void send_data(char *rfile, time_t twin_start, time_t twin_end, uint32_t count,
111 unsigned int delay, int confirm, int anon, int netflow_version);
108 unsigned int delay, int confirm, int netflow_version);
112109
113110 static int FlushBuffer(int confirm);
114111
152149 return sendto(peer.sockfd, peer.send_buffer, len, 0, (struct sockaddr *)&(peer.addr), peer.addrlen);
153150 } // End of FlushBuffer
154151
155 static int ParseCryptoPAnKey ( char *s, char *key ) {
156 int i, j;
157 char numstr[3];
158
159 if ( strlen(s) == 32 ) {
160 // Key is a string
161 strncpy(key, s, 32);
162 return 1;
163 }
164
165 s[1] = tolower(s[1]);
166 numstr[2] = 0;
167 if ( strlen(s) == 66 && s[0] == '0' && s[1] == 'x' ) {
168 j = 2;
169 for ( i=0; i<32; i++ ) {
170 if ( !isxdigit((int)s[j]) || !isxdigit((int)s[j+1]) )
171 return 0;
172 numstr[0] = s[j++];
173 numstr[1] = s[j++];
174 key[i] = strtol(numstr, NULL, 16);
175 }
176 return 1;
177 }
178
179 // It's an invalid key
180 return 0;
181
182 } // End of ParseCryptoPAnKey
183152
184153 static void send_blast(unsigned int delay ) {
185154 common_flow_header_t *header;
231200 } // End of send_blast
232201
233202 static void send_data(char *rfile, time_t twin_start,
234 time_t twin_end, uint32_t count, unsigned int delay, int confirm, int anon, int netflow_version) {
203 time_t twin_end, uint32_t count, unsigned int delay, int confirm, int netflow_version) {
235204 data_block_header_t in_block_header;
236205 master_record_t master_record;
237206 common_record_t *flow_record, *in_buff;
369338 continue;
370339 }
371340 // Records passed filter -> continue record processing
372
373 if ( anon ) {
374 if ( (flow_record->flags & FLAG_IPV6_ADDR ) == 0 ) {
375 master_record.v4.srcaddr = anonymize(master_record.v4.srcaddr);
376 master_record.v4.dstaddr = anonymize(master_record.v4.dstaddr);
377 } else {
378 uint64_t anon_ip[2];
379 anonymize_v6(master_record.v6.srcaddr, anon_ip);
380 master_record.v6.srcaddr[0] = anon_ip[0];
381 master_record.v6.srcaddr[1] = anon_ip[1];
382
383 anonymize_v6(master_record.v6.dstaddr, anon_ip);
384 master_record.v6.dstaddr[0] = anon_ip[0];
385 master_record.v6.dstaddr[1] = anon_ip[1];
386 }
387 }
388341
389342 if ( netflow_version == 5 )
390343 again = Add_v5_output_record(&master_record, &peer);
459412 int main( int argc, char **argv ) {
460413 struct stat stat_buff;
461414 char *rfile, *ffile, *filter, *tstring;
462 char CryptoPAnKey[32];
463 int c, do_anonymize, confirm, ffd, ret, blast, netflow_version;
415 int c, confirm, ffd, ret, blast, netflow_version;
464416 unsigned int delay, count, sockbuff_size;
465417 time_t t_start, t_end;
466418
477429 count = 0xFFFFFFFF;
478430 sockbuff_size = 0;
479431 netflow_version = 5;
480 do_anonymize = 0;
481432 blast = 0;
482433 verbose = 0;
483434 confirm = 0;
512463 }
513464 break;
514465 case 'K':
515 if ( !ParseCryptoPAnKey(optarg, CryptoPAnKey) ) {
516 fprintf(stderr, "Invalid key '%s' for CryptoPAn!\n", optarg);
517 exit(255);
518 }
519 do_anonymize = 1;
466 fprintf(stderr, "*** Anonymization moved! Use nfanon to anonymize flows first!\n");
467 exit(255);
520468 break;
521469 case 'L':
522470 if ( !InitLog(argv[0], optarg) )
637585 exit(255);
638586 }
639587
640 if (do_anonymize)
641 PAnonymizer_Init((uint8_t *)CryptoPAnKey);
642
643 send_data(rfile, t_start, t_end, count, delay, confirm, do_anonymize, netflow_version);
588 send_data(rfile, t_start, t_end, count, delay, confirm, netflow_version);
644589
645590 return 0;
646591 }
6161 #include "netflow_v5_v7.h"
6262 #include "nf_common.h"
6363 #include "util.h"
64 #include "panonymizer.h"
6564 #include "nflowcache.h"
6665 #include "nfstat.h"
6766
331330
332331 static void Expand_StatTable_Blocks(int hash_num);
333332
334 static void PrintStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int anon, int order_proto, int tag);
335
336 static void PrintPipeStatLine(StatRecord_t *StatData, int type, int anon, int order_proto, int tag);
337
338 static void PrintCvsStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int anon, int order_proto, int tag);
333 static void PrintStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int order_proto, int tag);
334
335 static void PrintPipeStatLine(StatRecord_t *StatData, int type, int order_proto, int tag);
336
337 static void PrintCvsStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int order_proto, int tag);
339338
340339 static void Create_topN_FlowStat(SortElement_t **topN_lists, int order, int topN, uint32_t *count );
341340
863862
864863 } // End of AddStat
865864
866 static void PrintStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int anon, int order_proto, int tag) {
865 static void PrintStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int order_proto, int tag) {
867866 char proto[16], valstr[40], datestr[64], flows_str[32], byte_str[32], packets_str[32], pps_str[32], bps_str[32];
868867 char tag_string[2];
869868 double duration, flows_percent, packets_percent, bytes_percent;
882881 case IS_IPADDR:
883882 tag_string[0] = tag ? TAG_CHAR : '\0';
884883 if ( (StatData->record_flags & 0x1) != 0 ) { // IPv6
885 if ( anon ) {
886 uint64_t anon_ip[2];
887 anonymize_v6(StatData->stat_key, anon_ip);
888 StatData->stat_key[0] = anon_ip[0];
889 StatData->stat_key[1] = anon_ip[1];
890 }
891884 StatData->stat_key[0] = htonll(StatData->stat_key[0]);
892885 StatData->stat_key[1] = htonll(StatData->stat_key[1]);
893886 inet_ntop(AF_INET6, StatData->stat_key, valstr, sizeof(valstr));
895888 condense_v6(valstr);
896889
897890 } else { // IPv4
898 uint32_t ipv4 = StatData->stat_key[1];
899 if ( anon ) {
900 ipv4 = anonymize(ipv4);
901 }
902 ipv4 = htonl(ipv4);
891 uint32_t ipv4;
892 ipv4 = htonl(StatData->stat_key[1]);
903893 inet_ntop(AF_INET, &ipv4, valstr, sizeof(valstr));
904894 }
905895 break;
975965
976966 } // End of PrintStatLine
977967
978 static void PrintPipeStatLine(StatRecord_t *StatData, int type, int anon, int order_proto, int tag) {
968 static void PrintPipeStatLine(StatRecord_t *StatData, int type, int order_proto, int tag) {
979969 double duration;
980970 uint32_t pps, bps, bpp;
981971 uint32_t sa[4];
985975 af = AF_UNSPEC;
986976 if ( type == IS_IPADDR ) {
987977 if ( (StatData->record_flags & 0x1) != 0 ) { // IPv6
988 if ( anon ) {
989 uint64_t anon_ip[2];
990 anonymize_v6(StatData->stat_key, anon_ip);
991 StatData->stat_key[0] = anon_ip[0];
992 StatData->stat_key[1] = anon_ip[1];
993 }
994978 StatData->stat_key[0] = htonll(StatData->stat_key[0]);
995979 StatData->stat_key[1] = htonll(StatData->stat_key[1]);
996980 af = PF_INET6;
997981
998982 } else { // IPv4
999 uint32_t ipv4 = StatData->stat_key[1];
1000 if ( anon ) {
1001 StatData->stat_key[1] = anonymize(ipv4);
1002 }
1003983 af = PF_INET;
1004984 }
1005985 // Make sure Endian does not screw us up
10421022
10431023 } // End of PrintPipeStatLine
10441024
1045 static void PrintCvsStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int anon, int order_proto, int tag) {
1025 static void PrintCvsStatLine(stat_record_t *stat, StatRecord_t *StatData, int type, int order_proto, int tag) {
10461026 char proto[16], valstr[40], datestr1[64], datestr2[64];
10471027 char tag_string[2];
10481028 double duration, flows_percent, packets_percent, bytes_percent;
10611041 case IS_IPADDR:
10621042 tag_string[0] = tag ? TAG_CHAR : '\0';
10631043 if ( (StatData->record_flags & 0x1) != 0 ) { // IPv6
1064 if ( anon ) {
1065 uint64_t anon_ip[2];
1066 anonymize_v6(StatData->stat_key, anon_ip);
1067 StatData->stat_key[0] = anon_ip[0];
1068 StatData->stat_key[1] = anon_ip[1];
1069 }
10701044 StatData->stat_key[0] = htonll(StatData->stat_key[0]);
10711045 StatData->stat_key[1] = htonll(StatData->stat_key[1]);
10721046 inet_ntop(AF_INET6, StatData->stat_key, valstr, sizeof(valstr));
10731047
10741048 } else { // IPv4
1075 uint32_t ipv4 = StatData->stat_key[1];
1076 if ( anon ) {
1077 ipv4 = anonymize(ipv4);
1078 }
1079 ipv4 = htonl(ipv4);
1049 uint32_t ipv4;
1050 ipv4 = htonl(StatData->stat_key[1]);
10801051 inet_ntop(AF_INET, &ipv4, valstr, sizeof(valstr));
10811052 }
10821053 break;
11591130
11601131 } // End of PrintCvsStatLine
11611132
1162 void PrintFlowTable(printer_t print_record, uint32_t limitflows, int date_sorted, int anon, int tag, int GuessDir) {
1133 void PrintFlowTable(printer_t print_record, uint32_t limitflows, int date_sorted, int tag, int GuessDir) {
11631134 hash_FlowTable *FlowTable;
11641135 FlowTableRecord_t *r;
11651136 SortElement_t *SortList;
12181189 if ( limitflows && limitflows < maxindex )
12191190 maxindex = limitflows;
12201191 for ( i = 0; i < maxindex; i++ ) {
1221 master_record_t flow_record;
1192 master_record_t *flow_record;
12221193 common_record_t *raw_record;
12231194 int map_id;
12241195
12261197 raw_record = &(r->flowrecord);
12271198 map_id = r->map_ref->map_id;
12281199
1229 ExpandRecord_v2( raw_record, extension_map_list.slot[map_id], &flow_record);
1230 flow_record.dPkts = r->counter[INPACKETS];
1231 flow_record.dOctets = r->counter[INBYTES];
1232 flow_record.out_pkts = r->counter[OUTPACKETS];
1233 flow_record.out_bytes = r->counter[OUTBYTES];
1234 flow_record.aggr_flows = r->counter[FLOWS];
1200 flow_record = &(extension_map_list.slot[map_id]->master_record);
1201 ExpandRecord_v2( raw_record, extension_map_list.slot[map_id], flow_record);
1202 flow_record->dPkts = r->counter[INPACKETS];
1203 flow_record->dOctets = r->counter[INBYTES];
1204 flow_record->out_pkts = r->counter[OUTPACKETS];
1205 flow_record->out_bytes = r->counter[OUTBYTES];
1206 flow_record->aggr_flows = r->counter[FLOWS];
12351207
12361208 // apply IP mask from aggregation, to provide a pretty output
12371209 if ( FlowTable->has_masks ) {
1238 flow_record.v6.srcaddr[0] &= FlowTable->IPmask[0];
1239 flow_record.v6.srcaddr[1] &= FlowTable->IPmask[1];
1240 flow_record.v6.dstaddr[0] &= FlowTable->IPmask[2];
1241 flow_record.v6.dstaddr[1] &= FlowTable->IPmask[3];
1210 flow_record->v6.srcaddr[0] &= FlowTable->IPmask[0];
1211 flow_record->v6.srcaddr[1] &= FlowTable->IPmask[1];
1212 flow_record->v6.dstaddr[0] &= FlowTable->IPmask[2];
1213 flow_record->v6.dstaddr[1] &= FlowTable->IPmask[3];
12421214 }
12431215
1244 if ( GuessDir && ( flow_record.srcport < 1024 && flow_record.dstport > 1024 ) )
1245 SwapFlow(&flow_record);
1246 print_record((void *)&flow_record, &string, anon, tag);
1216 if ( GuessDir && ( flow_record->srcport < 1024 && flow_record->dstport > 1024 ) )
1217 SwapFlow(flow_record);
1218 print_record((void *)flow_record, &string, tag);
12471219 printf("%s\n", string);
12481220 }
12491221
12971269
12981270 if ( GuessDir && ( flow_record->srcport < 1024 && flow_record->dstport > 1024 ) )
12991271 SwapFlow(flow_record);
1300 print_record((void *)flow_record, &string, anon, tag);
1272 print_record((void *)flow_record, &string, tag);
13011273 printf("%s\n", string);
13021274
13031275 c++;
13081280
13091281 } // End of PrintFlowTable
13101282
1311 void PrintFlowStat(char *record_header, printer_t print_record, int topN, int anon, int tag, int quiet, int cvs_output) {
1283 void PrintFlowStat(char *record_header, printer_t print_record, int topN, int tag, int quiet, int cvs_output) {
13121284 hash_FlowTable *FlowTable;
13131285 SortElement_t *topN_flow_list[NumOrders];
13141286 uint32_t numflows;
13671339 if ( FlowTable->apply_netbits )
13681340 ApplyNetMaskBits(&flow_record, FlowTable->apply_netbits);
13691341
1370 print_record((void *)&flow_record, &string, anon, tag);
1342 print_record((void *)&flow_record, &string, tag);
13711343 printf("%s\n", string);
13721344 }
13731345 printf("\n");
13811353
13821354 } // End of PrintFlowStat
13831355
1384 void PrintElementStat(stat_record_t *sum_stat, char *record_header, printer_t print_record, int topN, int anon, int tag, int quiet, int pipe_output, int cvs_output) {
1356 void PrintElementStat(stat_record_t *sum_stat, char *record_header, printer_t print_record, int topN, int tag, int quiet, int pipe_output, int cvs_output) {
13851357 SortElement_t *topN_element_list;
13861358 uint32_t numflows, maxindex;
13871359 int32_t i, j, hash_num, order_index, order_bit;
14261398 // Again - ugly output formating - needs to be cleand up
14271399 if ( pipe_output )
14281400 PrintPipeStatLine((StatRecord_t *)topN_element_list[i].record, type,
1429 anon, StatRequest[hash_num].order_proto, tag);
1401 StatRequest[hash_num].order_proto, tag);
14301402 else if ( cvs_output )
14311403 PrintCvsStatLine(sum_stat, (StatRecord_t *)topN_element_list[i].record, type,
1432 anon, StatRequest[hash_num].order_proto, tag);
1404 StatRequest[hash_num].order_proto, tag);
14331405 else
14341406 PrintStatLine(sum_stat, (StatRecord_t *)topN_element_list[i].record,
1435 type, anon, StatRequest[hash_num].order_proto, tag);
1407 type, StatRequest[hash_num].order_proto, tag);
14361408 }
14371409 free((void *)topN_element_list);
14381410 printf("\n");
101101
102102 void AddStat(common_record_t *raw_record, master_record_t *flow_record );
103103
104 void PrintFlowTable(printer_t print_record, uint32_t limitflows, int date_sorted, int anon, int tag, int GuessDir);
104 void PrintFlowTable(printer_t print_record, uint32_t limitflows, int date_sorted, int tag, int GuessDir);
105105
106 void PrintFlowStat(char *record_header, printer_t print_record, int topN, int anon, int tag, int quiet, int cvs_output);
106 void PrintFlowStat(char *record_header, printer_t print_record, int topN, int tag, int quiet, int cvs_output);
107107
108 void PrintElementStat(stat_record_t *sum_stat, char *record_header, printer_t print_record, int topN, int anon, int tag, int quiet, int pipe_output, int cvs_output);
108 void PrintElementStat(stat_record_t *sum_stat, char *record_header, printer_t print_record, int topN, int tag, int quiet, int pipe_output, int cvs_output);
109109
110 void PrintSortedFlows(printer_t print_record, uint32_t limitflows, int anon, int tag);
110 void PrintSortedFlows(printer_t print_record, uint32_t limitflows, int tag);
111111
112112 #endif //_NFSTAT_H
Binary diff not shown
146146 }
147147
148148 void CheckCompression(char *filename) {
149 nffile_t nffile;
150 int i, rfd;
149 nffile_t *nffile;
150 int i, rfd, compress, bsize;
151151 ssize_t ret;
152152 stat_record_t *stat_ptr;
153153 char *string;
154154 char outfile[MAXPATHLEN];
155 void *buff_ptr;
155 void *buff_ptr, *in_buff;
156 data_block_header_t *in_block_header, *p;
156157
157158 struct timeval tstart[2];
158159 struct timeval tend[2];
169170 snprintf(outfile, MAXPATHLEN, "%s-tmp", filename);
170171 outfile[MAXPATHLEN-1] = '\0';
171172
172 nffile.block_header = malloc(BUFFSIZE + sizeof(data_block_header_t));
173 if ( !nffile.block_header ) {
174 fprintf(stderr, "Buffer allocation error: %s", strerror(errno));
175 close(rfd);
173 in_buff = malloc(BUFFSIZE + sizeof(data_block_header_t));
174 if ( !in_buff ) {
175 fprintf(stderr, "malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
176176 return;
177177 }
178 buff_ptr = (void *)((pointer_addr_t)nffile.block_header + sizeof(data_block_header_t));
179
180 ret = ReadBlock(rfd, nffile.block_header, buff_ptr, &string);
178 in_block_header = (data_block_header_t *)in_buff;
179 buff_ptr = (void *)((pointer_addr_t)in_buff + sizeof(data_block_header_t));
180
181 ret = ReadBlock(rfd, in_block_header, buff_ptr, &string);
181182 if ( ret < 0 ) {
182183 fprintf(stderr, "Error while reading data block. Abort.\n");
183184 close(rfd);
186187 }
187188 close(rfd);
188189
189 for ( nffile.compress=0; nffile.compress<=1; nffile.compress++ ) {
190 nffile.wfd = OpenNewFile(outfile, &string, nffile.compress);
191 if ( nffile.wfd < 0 ) {
190 bsize = in_block_header->size;
191 for ( compress=0; compress<=1; compress++ ) {
192 nffile = OpenNewFile(outfile, NULL, compress, 0, &string);
193 if ( !nffile ) {
192194 fprintf(stderr, "%s\n", string);
193195 return;
194196 }
195
196 gettimeofday(&(tstart[nffile.compress]), (struct timezone*)NULL);
197
198 // tmp replace buffer with data from input file
199 p = nffile->block_header;
200 nffile->block_header = in_block_header;
201
202 gettimeofday(&(tstart[compress]), (struct timezone*)NULL);
197203 for ( i=0; i<100; i++ ) {
198 if ( (ret = WriteBlock(&nffile)) <= 0 ) {
204 if ( (ret = WriteBlock(nffile)) <= 0 ) {
199205 fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno));
200206 close(rfd);
201 close(nffile.wfd);
207 CloseUpdateFile(nffile, stat_ptr, "none", &string );
202208 unlink(outfile);
203209 return;
204210 }
205211 }
206 gettimeofday(&(tend[nffile.compress]), (struct timezone*)NULL);
207
208 CloseUpdateFile(nffile.wfd, stat_ptr, 0, "none", nffile.compress, &string );
212 gettimeofday(&(tend[compress]), (struct timezone*)NULL);
213
214 // reset buffer
215 nffile->block_header = p;
216 CloseUpdateFile(nffile, stat_ptr, "none", &string );
217 nffile = DisposeFile(nffile);
209218 unlink(outfile);
210219
211 if (tend[nffile.compress].tv_usec < tstart[nffile.compress].tv_usec)
212 tend[nffile.compress].tv_usec += 1000000, --tend[nffile.compress].tv_sec;
213
214 usec = tend[nffile.compress].tv_usec - tstart[nffile.compress].tv_usec;
215 sec = tend[nffile.compress].tv_sec - tstart[nffile.compress].tv_sec;
216
217 wall[nffile.compress] = (double)sec + ((double)usec)/1000000;
218 }
219
220 printf("100 write cycles, with size %u bytes\n", nffile.block_header->size);
221 printf("Uncompressed write time: %-.6fs size: %u\n", wall[0], nffile.block_header->size);
220 if (tend[compress].tv_usec < tstart[compress].tv_usec)
221 tend[compress].tv_usec += 1000000, --tend[compress].tv_sec;
222
223 usec = tend[compress].tv_usec - tstart[compress].tv_usec;
224 sec = tend[compress].tv_sec - tstart[compress].tv_sec;
225
226 wall[compress] = (double)sec + ((double)usec)/1000000;
227 }
228
229 printf("100 write cycles, with size %u bytes\n", bsize);
230 printf("Uncompressed write time: %-.6fs size: %u\n", wall[0], bsize);
222231 printf("Compressed write time : %-.6fs size: %d\n", wall[1], (int32_t)ret);
223 printf("Ratio : 1:%-.3f\n", (double)ret/(double)nffile.block_header->size);
232 printf("Ratio : 1:%-.3f\n", (double)ret/(double)bsize);
224233
225234 if ( wall[0] < wall[1] )
226235 printf("You should run nfcapd without compression\n");
231240
232241 int main(int argc, char **argv) {
233242 master_record_t flow_record;
243 common_record_t c_record;
234244 uint64_t *blocks, l;
235245 uint32_t size, in[2];
236246 time_t now;
237247 int ret, i;
238248 value64_t v;
249 void *p;
239250
240251 if ( sizeof(struct in_addr) != sizeof(uint32_t) ) {
241252 #ifdef HAVE_SIZE_T_Z_FORMAT
246257 exit(255);
247258 }
248259
260 p = (void *)c_record.data;
261 if (( (pointer_addr_t)p - (pointer_addr_t)&c_record ) != COMMON_RECORD_DATA_SIZE ) {
262 printf("*** common record size missmatch: expected %i, found: %i\n",
263 COMMON_RECORD_DATA_SIZE, (pointer_addr_t)p - (pointer_addr_t)&c_record );
264 exit(255);
265 } else {
266 printf("Common record size is %i\n", COMMON_RECORD_DATA_SIZE);
267 }
249268 i = 3;
250269 printf("ALIGN BYTES: %lu\n", (long unsigned)ALIGN_BYTES);
251270 printf("aligned: %i -> %lu\n", i, (long unsigned)(((u_int)(i) + ALIGN_BYTES) &~ ALIGN_BYTES));
103103
104104 uint32_t Max_num_extensions;
105105
106 void FixExtensionMap(extension_map_t *map);
107
106108 void InitExtensionMaps(extension_map_list_t *extension_map_list ) {
109 int i;
107110 memset((void *)extension_map_list->slot, 0, MAX_EXTENSION_MAPS * sizeof(extension_info_t *));
108111 memset((void *)extension_map_list->page, 0, MAX_EXTENSION_MAPS * sizeof(extension_info_t *));
109112
110113 extension_map_list->next_free = 0;
111114 extension_map_list->max_used = -1;
115
116 Max_num_extensions = 0;
117 i = 1;
118 while ( extension_descriptor[i++].id )
119 Max_num_extensions++;
112120
113121 } // End of InitExtensionMaps
114122
223231 }
224232 }
225233 }
234
235 FixExtensionMap(map);
226236
227237 // add new entry to slot
228238 extension_map_list->slot[map_id] = (extension_info_t *)calloc(1,sizeof(extension_info_t));
493503 i++;
494504 }
495505
506 if ( (extension_size != map->extension_size ) ) {
507 printf("Verify map id %i: ERROR extension size: Expected %i, Map reports: %i!\n", map->map_id,
508 extension_size, map->extension_size);
509 failed = 1;
510 }
496511 if ( (i != max_elements ) && ((max_elements-i) != 1) ) {
497512 // off by 1 is the opt alignment
498513 printf("Verify map id %i: ERROR: Expected %i elements in map, but found %i!\n", map->map_id, max_elements, i);
502517 return failed;
503518
504519 } // End of VerifyExtensionMap
520
521 void FixExtensionMap(extension_map_t *map) {
522 int i, extension_size, max_elements;
523
524 if (( map->size & 0x3 ) != 0 ) {
525 printf("PANIC! - Verify map id %i: WARNING: map size %i not aligned!\n", map->map_id, map->size);
526 exit(255);
527 }
528
529 if ( ((int)map->size - (int)sizeof(extension_map_t)) <= 0 ) {
530 printf("PANIC! - Verify map id %i: ERROR: map size %i too small!\n", map->map_id, map->size);
531 exit(255);
532 }
533
534 max_elements = (map->size - sizeof(extension_map_t)) / sizeof(uint16_t);
535 extension_size = 0;
536 i=0;
537 while (map->ex_id[i] && i <= max_elements) {
538 int id = map->ex_id[i];
539 if ( id > Max_num_extensions ) {
540 printf("PANIC! - Verify map id %i: ERROR: element id %i out of range [%i]!\n", map->map_id, id, Max_num_extensions);
541 }
542 extension_size += extension_descriptor[id].size;
543 i++;
544 }
545
546 // silently fix extension size bug of nfdump <= 1.6.2 ..
547 if ( (extension_size != map->extension_size ) ) {
548 #ifdef DEVEL
549 printf("FixExtension map extension size from %i to %i\n", map->extension_size, extension_size);
550 #endif
551 map->extension_size = extension_size;
552 }
553
554 if ( (i != max_elements ) && ((max_elements-i) != 1) ) {
555 // off by 1 is the opt alignment
556 printf("Verify map id %i: ERROR: Expected %i elements in map, but found %i!\n", map->map_id, max_elements, i);
557 }
558
559 } // End of FixExtensionMap
505560
506561
507562 void DumpExMaps(char *filename) {
8181 #include <sys/types.h>
8282 #include <stdlib.h>
8383 #include <string.h>
84 #include <ctype.h>
8485
8586 #ifdef HAVE_STDINT_H
8687 #include <stdint.h>
100101 //initialize the 128-bit secret pad. The pad is encrypted before being used for padding.
101102 Rijndael_blockEncrypt(key + 16, 128, m_pad);
102103 }
104
105 int ParseCryptoPAnKey ( char *s, char *key ) {
106 int i, j;
107 char numstr[3];
108 uint32_t len = strlen(s);
109
110 if ( len < 32 || len > 66 ) {
111 fprintf(stderr, "*** CryptoPAnKey error: size: %u\n", len);
112 fprintf(stderr, "*** Need either a plain 32 char string, or a 32 byte hex key starting with 0x..\n");
113 return 0;
114 }
115
116 if ( strlen(s) == 32 ) {
117 // Key is a string
118 strncpy(key, s, 32);
119 return 1;
120 }
121
122 s[1] = tolower(s[1]);
123 numstr[2] = 0;
124 if ( strlen(s) == 66 && s[0] == '0' && s[1] == 'x' ) {
125 j = 2;
126 for ( i=0; i<32; i++ ) {
127 if ( !isxdigit((int)s[j]) || !isxdigit((int)s[j+1]) )
128 return 0;
129 numstr[0] = s[j++];
130 numstr[1] = s[j++];
131 key[i] = strtol(numstr, NULL, 16);
132 }
133 return 1;
134 }
135
136 // It's an invalid key
137 fprintf(stderr, "*** CryptoPAnKey error: size: %u\n", len);
138 fprintf(stderr, "*** Need either a plain 32 char string, or a 32 byte hex key starting with 0x..\n");
139 return 0;
140
141 } // End of ParseCryptoPAnKey
103142
104143 //Anonymization funtion
105144 uint32_t anonymize(const uint32_t orig_addr) {
8585 // The second 128 bits of the key are used as the secret pad for padding
8686 void PAnonymizer_Init(uint8_t * key);
8787
88 int ParseCryptoPAnKey ( char *s, char *key );
89
8890 uint32_t anonymize( const uint32_t orig_addr);
8991
9092 void anonymize_v6(const uint64_t orig_addr[2], uint64_t *anon_addr);
122122 char path[MAXPATHLEN];
123123 int ffd, ret;
124124 size_t filter_size;
125 nffile_t nffile;
125 nffile_t *nffile;
126126
127127 ofile = wfile = NULL;
128 nffile = NULL;
128129
129130 /*
130131 * Compile the complete filter:
256257 exit(255);
257258 }
258259
259 memset((void *)&nffile, 0, sizeof(nffile));
260
261260 // check for subdir hierarchy
262261 subdir = NULL;
263262 if ( (profile_param->profiletype & 4) == 0 ) { // no shadow profile
263 char *string;
264264 int is_alert = (profile_param->profiletype & 8) == 8;
265265 if ( !is_alert && subdir_index && strlen(filename) == 19 && (strncmp(filename, "nfcapd.", 7) == 0) ) {
266266 char *p = &filename[7]; // points to ISO timstamp in filename
303303
304304 ofile = strdup(path);
305305
306 if ( !InitExportFile(path, compress, &nffile) )
306 nffile = OpenNewFile(path, NULL, compress, 0, &string);
307 if ( !nffile ) {
308 LogError("%s", string);
307309 return;
310 }
308311
309312 }
310313
357360
358361 for ( num = 0; num < num_channels; num++ ) {
359362 if ( profile_channels[num].ofile ) {
360 CloseUpdateFile(profile_channels[num].nffile.wfd, &(profile_channels[num].stat_record),
361 profile_channels[num].nffile.file_blocks, GetIdent(), compress, &s );
363 CloseUpdateFile(profile_channels[num].nffile, &(profile_channels[num].stat_record), GetIdent(), &s );
364 profile_channels[num].nffile = DisposeFile(profile_channels[num].nffile);
362365
363366 if ( s != NULL ) {
364367 LogError("%s\n", s);
5555 char *wfile; // final filename
5656 char *rrdfile; // rrd filename for update
5757 char *dirstat_path; // pathname for dirstat file
58 nffile_t nffile;
58 nffile_t *nffile;
5959 stat_record_t stat_record;
6060 int type;
6161 dirstat_t *dirstat;
(No changes)
(No changes)
358358 // Init each netflow source output data buffer
359359 fs = FlowSource;
360360 while ( fs ) {
361 // Init block header
362 fs->nffile.block_header->NumRecords = 0;
363 fs->nffile.block_header->size = 0;
364 fs->nffile.block_header->id = DATA_BLOCK_TYPE_2;
365 fs->nffile.block_header->pad = 0;
366 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
367 fs->nffile.compress = compress;
368 fs->nffile.file_blocks = 0;
369361
370362 // prepare file
371 fs->nffile.wfd = OpenNewFile(fs->current, &string, fs->nffile.compress);
372 if ( string != NULL ) {
363 fs->nffile = OpenNewFile(fs->current, NULL, compress, 0, &string);
364 if ( !fs->nffile ) {
373365 syslog(LOG_ERR, "%s", string);
374366 return;
375367 }
470462
471463 if ( verbose ) {
472464 // Dump to stdout
473 format_file_block_header(fs->nffile.block_header, &string, 0, 0);
465 format_file_block_header(fs->nffile->block_header, &string, 0);
474466 printf("%s\n", string);
475467 }
476468
477 if ( fs->nffile.block_header->NumRecords ) {
469 if ( fs->nffile->block_header->NumRecords ) {
478470 // flush current buffer to disc
479 if ( WriteBlock(&(fs->nffile)) <= 0 )
471 if ( WriteBlock(fs->nffile) <= 0 )
480472 syslog(LOG_ERR, "Ident: %s, failed to write output buffer to disk: '%s'" , fs->Ident, strerror(errno));
481473 else
482474 // update successful written blocks
483 fs->nffile.file_blocks++;
475 fs->nffile->file_header->NumBlocks++;
484476 } // else - no new records in current block
485477
486478
495487 fs->stat_record.msec_last = fs->last_seen - fs->stat_record.last_seen*1000;
496488
497489 // Write Stat record and close file
498 CloseUpdateFile(fs->nffile.wfd, &fs->stat_record, fs->nffile.file_blocks, fs->Ident, fs->nffile.compress, &string );
490 CloseUpdateFile(fs->nffile, &fs->stat_record, fs->Ident, &string );
499491 if ( string != NULL ) {
500492 // closing the file failed. maybe disk full ??
501493 syslog(LOG_ERR, "Ident: %s, %s", fs->Ident, string);
533525 fs->Ident, (unsigned long long)fs->stat_record.numflows, (unsigned long long)fs->stat_record.numpackets,
534526 (unsigned long long)fs->stat_record.numbytes, fs->stat_record.sequence_failure, fs->bad_packets);
535527
536 // Initialize block header and write pointer for next block
537 fs->nffile.block_header->NumRecords = 0;
538 fs->nffile.block_header->size = 0;
539 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
540
541528 // reset stat record
542529 memset((void *)&fs->stat_record, 0, sizeof(stat_record_t));
543530 fs->bad_packets = 0;
544531 fs->first_seen = 0xffffffffffffLL;
545532 fs->last_seen = 0;
546 fs->nffile.file_blocks = 0;
547533
548534 // Dump all extension maps to the buffer
549535 FlushExtensionMaps(fs);
550536
551537 if ( !done ) {
552 fs->nffile.wfd = OpenNewFile(fs->current, &string, fs->nffile.compress);
553 if ( string != NULL ) {
554 syslog(LOG_ERR, "Ident: %s, %s", fs->Ident, string);
555 syslog(LOG_ERR, "New flows will get lost!\n");
556
557 // do not crash or terminate
558 fs->nffile.wfd = 0;
538 fs->nffile = OpenNewFile(fs->current, fs->nffile, compress, 0, &string );
539 if ( fs->nffile ) {
540 syslog(LOG_ERR, "Fatal: ident: %s, %s", fs->Ident, string);
541 syslog(LOG_ERR, "Suicide due to fatal error!");
542 break;
559543 }
560544 }
545
546 // Dump all extension maps to the buffer
547 FlushExtensionMaps(fs);
548
561549
562550 // next flow source
563551 fs = fs->next;
648636 export_packets++;
649637
650638 // flush current buffer to disc
651 if ( fs->nffile.block_header->size > BUFFSIZE ) {
639 if ( fs->nffile->block_header->size > BUFFSIZE ) {
652640 // fishy! - we already wrote into someone elses memory! - I'm sorry
653641 // reset output buffer - data may be lost, as we don not know, where it happen
654 fs->nffile.block_header->size = 0;
655 fs->nffile.block_header->NumRecords = 0;
656 fs->nffile.writeto = (void *)((pointer_addr_t)fs->nffile.block_header + sizeof(data_block_header_t) );
642 fs->nffile->block_header->size = 0;
643 fs->nffile->block_header->NumRecords = 0;
644 fs->nffile->writeto = (void *)((pointer_addr_t)fs->nffile->block_header + sizeof(data_block_header_t) );
657645 syslog(LOG_ERR, "### Software bug ### Ident: %s, output buffer overflow: expect memory inconsitency", fs->Ident);
658646 }
659647 }
665653
666654 fs = FlowSource;
667655 while ( fs ) {
668 free((void *)fs->nffile.block_header);
656 fs->nffile = DisposeFile(fs->nffile);
669657 fs = fs->next;
670658 }
671659
10501038 exit(255);
10511039 }
10521040
1053 // setup output memory buffer
1054 fs->nffile.block_header = (data_block_header_t *)malloc(BUFFSIZE + sizeof(data_block_header_t));
1055 if ( !fs->nffile.block_header ) {
1056 syslog(LOG_ERR, "malloc() buffer allocation error: %s", strerror(errno));
1057 exit(255);
1058 }
1059
10601041 fs = fs->next;
10611042 }
10621043
10721072 // output buffer size check
10731073 // IPv6 needs 2 x 16 bytes, IPv4 2 x 4 bytes
10741074 ipsize = sample->gotIPV6 ? 32 : 8;
1075 if ( !CheckBufferSpace(&(fs->nffile), sflow_output_record_size[ip_flags] + ipsize )) {
1075 if ( !CheckBufferSpace(fs->nffile, sflow_output_record_size[ip_flags] + ipsize )) {
10761076 // fishy! - should never happen. maybe disk full?
10771077 syslog(LOG_ERR,"SFLOW: output buffer size error. Abort sflow record processing");
10781078 return;
10791079 }
10801080
1081 common_record = (common_record_t *)fs->nffile.writeto;
1081 common_record = (common_record_t *)fs->nffile->writeto;
10821082
10831083 common_record->size = sflow_output_record_size[ip_flags] + ipsize;
10841084 common_record->type = CommonRecordType;
12881288 master_record_t master_record;
12891289 char *string;
12901290 ExpandRecord_v2((common_record_t *)common_record, &exporter->sflow_extension_info[ip_flags], &master_record);
1291 format_file_block_record(&master_record, &string, 0, 0);
1291 format_file_block_record(&master_record, &string, 0);
12921292 printf("%s\n", string);
12931293 }
12941294
12951295 // update file record size ( -> output buffer size )
1296 fs->nffile.block_header->NumRecords++;
1297 fs->nffile.block_header->size += (sflow_output_record_size[ip_flags] + ipsize);
1296 fs->nffile->block_header->NumRecords++;
1297 fs->nffile->block_header->size += (sflow_output_record_size[ip_flags] + ipsize);
12981298 #ifdef DEVEL
1299 if ( (next_data - fs->nffile.writeto) != (sflow_output_record_size[ip_flags] + ipsize) ) {
1299 if ( (next_data - fs->nffile->writeto) != (sflow_output_record_size[ip_flags] + ipsize) ) {
13001300 printf("PANIC: Size error. Buffer diff: %llu, Size: %u\n",
1301 (unsigned long long)(next_data - fs->nffile.writeto),
1301 (unsigned long long)(next_data - fs->nffile->writeto),
13021302 (sflow_output_record_size[ip_flags] + ipsize));
13031303 exit(255);
13041304 }
13051305 #endif
1306 fs->nffile.writeto = next_data;
1306 fs->nffile->writeto = next_data;
13071307
13081308 }
13091309
0 --- sflow.c.orig 2009-11-18 07:18:25.000000000 +0100
1 +++ sflow.c 2009-11-17 19:27:42.000000000 +0100
2 @@ -1067,7 +1067,6 @@
3 extension_map = sflow_extension_info[ip_flags].map;
4 }
5
6 - common_record = (common_record_t *)fs->nffile.writeto;
7
8 // output buffer size check
9 // IPv6 needs 2 x 128 bytes, IPv4 2 x 4 bytes
10 @@ -1078,6 +1077,8 @@
11 return;
12 }
13
14 + common_record = (common_record_t *)fs->nffile.writeto;
15 +
16 common_record->size = sflow_output_record_size[ip_flags] + ipsize;
17 common_record->type = CommonRecordType;
18 common_record->flags = 0;
19 @@ -1283,7 +1284,7 @@
20 fs->nffile.block_header->size += (sflow_output_record_size[ip_flags] + ipsize);
21 #ifdef DEVEL
22 if ( (next_data - fs->nffile.writeto) != (sflow_output_record_size[ip_flags] + ipsize) ) {
23 - printf("PANIC: Size error. Buffer diff: %ull, Size: %u\n",
24 + printf("PANIC: Size error. Buffer diff: %llu, Size: %u\n",
25 (unsigned long long)(next_data - fs->nffile.writeto),
26 (sflow_output_record_size[ip_flags] + ipsize));
27 exit(255);
28 @@ -2328,7 +2329,8 @@
29 default: receiveError(sample, "unknown INMCOUNTERSVERSION", YES); break;
30 }
31 /* line-by-line output... */
32 - writeCountersLine(sample);
33 + if ( verbose )
34 + writeCountersLine(sample);
35 }
36
37 /*_________________---------------------------__________________
38 @@ -2385,7 +2387,9 @@
39 }
40 lengthCheck(sample, "counters_sample", sampleStart, sampleLength);
41 /* line-by-line output... */
42 - writeCountersLine(sample);
43 + if ( verbose )
44 + writeCountersLine(sample);
45 +
46 }
47
48 /*_________________---------------------------__________________
2626 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2727 * POSSIBILITY OF SUCH DAMAGE.
2828 *
29 * $Author: haag $
29 * $Author: peter $
3030 *
31 * $Id: version.h 69 2010-09-09 07:17:43Z haag $
31 * $Id: version.h 19 2011-01-09 11:28:32Z peter $
3232 *
33 * $LastChangedRevision: 69 $
33 * $LastChangedRevision: 19 $
3434 *
3535 *
3636 */
37
37
3838 #ifndef _VERSION_H
3939 #define _VERSION_H 1
40
40
4141 const char *nfdump_version = VERSION;
4242
43 const char *nfdump_date = "$LastChangedDate: 2010-03-05 07:50:35 +0100 (Fri, 05 Mar 2010) $";
43 const char *nfdump_date = "$LastChangedDate: 2011-01-09 12:28:32 +0100 (Sun, 09 Jan 2011) $";
4444
4545 #endif //_VERSION_H
00 #! /bin/sh
11 # Wrapper for compilers which do not understand `-c -o'.
22
3 scriptversion=2009-04-28.21; # UTC
3 scriptversion=2009-10-06.20; # UTC
44
55 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
66 # Foundation, Inc.
123123 ret=$?
124124
125125 if test -f "$cofile"; then
126 mv "$cofile" "$ofile"
126 test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
127127 elif test -f "${cofile}bj"; then
128 mv "${cofile}bj" "$ofile"
128 test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
129129 fi
130130
131131 rmdir "$lockdir"
00 #! /bin/sh
1 # From configure.in Revision: 100 .
1 # From configure.in Revision: 69 .
22 # Guess values for system-dependent variables and create Makefiles.
3 # Generated by GNU Autoconf 2.65 for nfdump 1.6.1p1.
3 # Generated by GNU Autoconf 2.67 for nfdump 1.6.3.
44 #
55 # Report bugs to <phaag@users.sourceforge.net>.
66 #
77 #
88 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
9 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
10 # Inc.
9 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
10 # Foundation, Inc.
1111 #
1212 #
1313 # This configure script is free software; the Free Software Foundation
319319 test -d "$as_dir" && break
320320 done
321321 test -z "$as_dirs" || eval "mkdir $as_dirs"
322 } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
322 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
323323
324324
325325 } # as_fn_mkdir_p
359359 fi # as_fn_arith
360360
361361
362 # as_fn_error ERROR [LINENO LOG_FD]
363 # ---------------------------------
362 # as_fn_error STATUS ERROR [LINENO LOG_FD]
363 # ----------------------------------------
364364 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
365365 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
366 # script with status $?, using 1 if that was 0.
366 # script with STATUS, using 1 if that was 0.
367367 as_fn_error ()
368368 {
369 as_status=$?; test $as_status -eq 0 && as_status=1
370 if test "$3"; then
371 as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
372 $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
369 as_status=$1; test $as_status -eq 0 && as_status=1
370 if test "$4"; then
371 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
372 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
373373 fi
374 $as_echo "$as_me: error: $1" >&2
374 $as_echo "$as_me: error: $2" >&2
375375 as_fn_exit $as_status
376376 } # as_fn_error
377377
533533 exec 6>&1
534534
535535 # Name of the host.
536 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
536 # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
537537 # so uname gets run too.
538538 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
539539
552552 # Identity of this package.
553553 PACKAGE_NAME='nfdump'
554554 PACKAGE_TARNAME='nfdump'
555 PACKAGE_VERSION='1.6.1p1'
556 PACKAGE_STRING='nfdump 1.6.1p1'
555 PACKAGE_VERSION='1.6.3'
556 PACKAGE_STRING='nfdump 1.6.3'
557557 PACKAGE_BUGREPORT='phaag@users.sourceforge.net'
558558 PACKAGE_URL=''
559559
607607 READPCAP_TRUE
608608 SFLOW_FALSE
609609 SFLOW_TRUE
610 NFTRACK_FALSE
611 NFTRACK_TRUE
610612 EGREP
611613 GREP
612614 CPP
707709 with_rrdpath
708710 enable_ftconv
709711 enable_nfprofile
712 enable_nftrack
710713 enable_sflow
711714 enable_readpcap
712715 '
783786 fi
784787
785788 case $ac_option in
786 *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
787 *) ac_optarg=yes ;;
789 *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
790 *=) ac_optarg= ;;
791 *) ac_optarg=yes ;;
788792 esac
789793
790794 # Accept the important Cygnus configure options, so we can diagnose typos.
829833 ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
830834 # Reject names that are not valid shell variable names.
831835 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
832 as_fn_error "invalid feature name: $ac_useropt"
836 as_fn_error $? "invalid feature name: $ac_useropt"
833837 ac_useropt_orig=$ac_useropt
834838 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
835839 case $ac_user_opts in
855859 ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
856860 # Reject names that are not valid shell variable names.
857861 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
858 as_fn_error "invalid feature name: $ac_useropt"
862 as_fn_error $? "invalid feature name: $ac_useropt"
859863 ac_useropt_orig=$ac_useropt
860864 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
861865 case $ac_user_opts in
10591063 ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
10601064 # Reject names that are not valid shell variable names.
10611065 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1062 as_fn_error "invalid package name: $ac_useropt"
1066 as_fn_error $? "invalid package name: $ac_useropt"
10631067 ac_useropt_orig=$ac_useropt
10641068 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
10651069 case $ac_user_opts in
10751079 ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
10761080 # Reject names that are not valid shell variable names.
10771081 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1078 as_fn_error "invalid package name: $ac_useropt"
1082 as_fn_error $? "invalid package name: $ac_useropt"
10791083 ac_useropt_orig=$ac_useropt
10801084 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
10811085 case $ac_user_opts in
11051109 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
11061110 x_libraries=$ac_optarg ;;
11071111
1108 -*) as_fn_error "unrecognized option: \`$ac_option'
1109 Try \`$0 --help' for more information."
1112 -*) as_fn_error $? "unrecognized option: \`$ac_option'
1113 Try \`$0 --help' for more information"
11101114 ;;
11111115
11121116 *=*)
11141118 # Reject names that are not valid shell variable names.
11151119 case $ac_envvar in #(
11161120 '' | [0-9]* | *[!_$as_cr_alnum]* )
1117 as_fn_error "invalid variable name: \`$ac_envvar'" ;;
1121 as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
11181122 esac
11191123 eval $ac_envvar=\$ac_optarg
11201124 export $ac_envvar ;;
11321136
11331137 if test -n "$ac_prev"; then
11341138 ac_option=--`echo $ac_prev | sed 's/_/-/g'`
1135 as_fn_error "missing argument to $ac_option"
1139 as_fn_error $? "missing argument to $ac_option"
11361140 fi
11371141
11381142 if test -n "$ac_unrecognized_opts"; then
11391143 case $enable_option_checking in
11401144 no) ;;
1141 fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
1145 fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
11421146 *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
11431147 esac
11441148 fi
11611165 [\\/$]* | ?:[\\/]* ) continue;;
11621166 NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
11631167 esac
1164 as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
1168 as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
11651169 done
11661170
11671171 # There might be people who depend on the old broken behavior: `$host'
11751179 if test "x$host_alias" != x; then
11761180 if test "x$build_alias" = x; then
11771181 cross_compiling=maybe
1178 $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
1179 If a cross compiler is detected then cross compile mode will be used." >&2
1182 $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
1183 If a cross compiler is detected then cross compile mode will be used" >&2
11801184 elif test "x$build_alias" != "x$host_alias"; then
11811185 cross_compiling=yes
11821186 fi
11911195 ac_pwd=`pwd` && test -n "$ac_pwd" &&
11921196 ac_ls_di=`ls -di .` &&
11931197 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
1194 as_fn_error "working directory cannot be determined"
1198 as_fn_error $? "working directory cannot be determined"
11951199 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
1196 as_fn_error "pwd does not report name of working directory"
1200 as_fn_error $? "pwd does not report name of working directory"
11971201
11981202
11991203 # Find the source files, if location was not specified.
12321236 fi
12331237 if test ! -r "$srcdir/$ac_unique_file"; then
12341238 test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
1235 as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
1239 as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
12361240 fi
12371241 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
12381242 ac_abs_confdir=`(
1239 cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
1243 cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
12401244 pwd)`
12411245 # When building in place, set srcdir=.
12421246 if test "$ac_abs_confdir" = "$ac_pwd"; then
12621266 # Omit some internal or obsolete options to make the list less imposing.
12631267 # This message is too long to be a string in the A/UX 3.1 sh.
12641268 cat <<_ACEOF
1265 \`configure' configures nfdump 1.6.1p1 to adapt to many kinds of systems.
1269 \`configure' configures nfdump 1.6.3 to adapt to many kinds of systems.
12661270
12671271 Usage: $0 [OPTION]... [VAR=VALUE]...
12681272
12761280 --help=short display options specific to this package
12771281 --help=recursive display the short help of all the included packages
12781282 -V, --version display version information and exit
1279 -q, --quiet, --silent do not print \`checking...' messages
1283 -q, --quiet, --silent do not print \`checking ...' messages
12801284 --cache-file=FILE cache test results in FILE [disabled]
12811285 -C, --config-cache alias for \`--cache-file=config.cache'
12821286 -n, --no-create do not create output files
13281332
13291333 if test -n "$ac_init_help"; then
13301334 case $ac_init_help in
1331 short | recursive ) echo "Configuration of nfdump 1.6.1p1:";;
1335 short | recursive ) echo "Configuration of nfdump 1.6.3:";;
13321336 esac
13331337 cat <<\_ACEOF
13341338
13421346 --enable-compat15 compile nfdump, to read nfdump data files created with nfdump 1.5.x; default is NO
13431347 --enable-ftconv Build the flow-tools to nfdump converter; default is NO
13441348 --enable-nfprofile Build nfprofile used by NfSen; default is NO
1349 --enable-nftrack Build nftrack used by PortTracker; default is NO
13451350 --enable-sflow Build sflow collector sfcpad; default is NO
13461351 --enable-readpcap Build nfcapd collector to read from pcap file instead of network data; default is NO
13471352
14321437 test -n "$ac_init_help" && exit $ac_status
14331438 if $ac_init_version; then
14341439 cat <<\_ACEOF
1435 nfdump configure 1.6.1p1
1436 generated by GNU Autoconf 2.65
1437
1438 Copyright (C) 2009 Free Software Foundation, Inc.
1440 nfdump configure 1.6.3
1441 generated by GNU Autoconf 2.67
1442
1443 Copyright (C) 2010 Free Software Foundation, Inc.
14391444 This configure script is free software; the Free Software Foundation
14401445 gives unlimited permission to copy, distribute and modify it.
14411446 _ACEOF
15511556 mv -f conftest.er1 conftest.err
15521557 fi
15531558 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1554 test $ac_status = 0; } >/dev/null && {
1559 test $ac_status = 0; } > conftest.i && {
15551560 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
15561561 test ! -s conftest.err
15571562 }; then :
15751580 ac_fn_c_check_header_mongrel ()
15761581 {
15771582 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1578 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1583 if eval "test \"\${$3+set}\"" = set; then :
15791584 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
15801585 $as_echo_n "checking for $2... " >&6; }
1581 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1586 if eval "test \"\${$3+set}\"" = set; then :
15821587 $as_echo_n "(cached) " >&6
15831588 fi
15841589 eval ac_res=\$$3
16141619 else
16151620 ac_header_preproc=no
16161621 fi
1617 rm -f conftest.err conftest.$ac_ext
1622 rm -f conftest.err conftest.i conftest.$ac_ext
16181623 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
16191624 $as_echo "$ac_header_preproc" >&6; }
16201625
16371642 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
16381643 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
16391644 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
1640 ( cat <<\_ASBOX
1641 ## ------------------------------------------ ##
1645 ( $as_echo "## ------------------------------------------ ##
16421646 ## Report this to phaag@users.sourceforge.net ##
1643 ## ------------------------------------------ ##
1644 _ASBOX
1647 ## ------------------------------------------ ##"
16451648 ) | sed "s/^/$as_me: WARNING: /" >&2
16461649 ;;
16471650 esac
16481651 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
16491652 $as_echo_n "checking for $2... " >&6; }
1650 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1653 if eval "test \"\${$3+set}\"" = set; then :
16511654 $as_echo_n "(cached) " >&6
16521655 else
16531656 eval "$3=\$ac_header_compiler"
17111714 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
17121715 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
17131716 $as_echo_n "checking for $2... " >&6; }
1714 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1717 if eval "test \"\${$3+set}\"" = set; then :
17151718 $as_echo_n "(cached) " >&6
17161719 else
17171720 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17421745 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
17431746 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
17441747 $as_echo_n "checking for $2.$3... " >&6; }
1745 if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
1748 if eval "test \"\${$4+set}\"" = set; then :
17461749 $as_echo_n "(cached) " >&6
17471750 else
17481751 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17981801 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
17991802 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
18001803 $as_echo_n "checking for $2... " >&6; }
1801 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1804 if eval "test \"\${$3+set}\"" = set; then :
18021805 $as_echo_n "(cached) " >&6
18031806 else
18041807 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20442047 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
20452048 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
20462049 $as_echo_n "checking for $2... " >&6; }
2047 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
2050 if eval "test \"\${$3+set}\"" = set; then :
20482051 $as_echo_n "(cached) " >&6
20492052 else
20502053 eval "$3=no"
20922095 This file contains any messages produced by compilers while
20932096 running configure, to aid debugging if configure makes a mistake.
20942097
2095 It was created by nfdump $as_me 1.6.1p1, which was
2096 generated by GNU Autoconf 2.65. Invocation command line was
2098 It was created by nfdump $as_me 1.6.3, which was
2099 generated by GNU Autoconf 2.67. Invocation command line was
20972100
20982101 $ $0 $@
20992102
22032206 {
22042207 echo
22052208
2206 cat <<\_ASBOX
2207 ## ---------------- ##
2209 $as_echo "## ---------------- ##
22082210 ## Cache variables. ##
2209 ## ---------------- ##
2210 _ASBOX
2211 ## ---------------- ##"
22112212 echo
22122213 # The following way of writing the cache mishandles newlines in values,
22132214 (
22412242 )
22422243 echo
22432244
2244 cat <<\_ASBOX
2245 ## ----------------- ##
2245 $as_echo "## ----------------- ##
22462246 ## Output variables. ##
2247 ## ----------------- ##
2248 _ASBOX
2247 ## ----------------- ##"
22492248 echo
22502249 for ac_var in $ac_subst_vars
22512250 do
22582257 echo
22592258
22602259 if test -n "$ac_subst_files"; then
2261 cat <<\_ASBOX
2262 ## ------------------- ##
2260 $as_echo "## ------------------- ##
22632261 ## File substitutions. ##
2264 ## ------------------- ##
2265 _ASBOX
2262 ## ------------------- ##"
22662263 echo
22672264 for ac_var in $ac_subst_files
22682265 do
22762273 fi
22772274
22782275 if test -s confdefs.h; then
2279 cat <<\_ASBOX
2280 ## ----------- ##
2276 $as_echo "## ----------- ##
22812277 ## confdefs.h. ##
2282 ## ----------- ##
2283 _ASBOX
2278 ## ----------- ##"
22842279 echo
22852280 cat confdefs.h
22862281 echo
23352330 ac_site_file1=NONE
23362331 ac_site_file2=NONE
23372332 if test -n "$CONFIG_SITE"; then
2338 ac_site_file1=$CONFIG_SITE
2333 # We do not want a PATH search for config.site.
2334 case $CONFIG_SITE in #((
2335 -*) ac_site_file1=./$CONFIG_SITE;;
2336 */*) ac_site_file1=$CONFIG_SITE;;
2337 *) ac_site_file1=./$CONFIG_SITE;;
2338 esac
23392339 elif test "x$prefix" != xNONE; then
23402340 ac_site_file1=$prefix/share/config.site
23412341 ac_site_file2=$prefix/etc/config.site
23502350 { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
23512351 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
23522352 sed 's/^/| /' "$ac_site_file" >&5
2353 . "$ac_site_file"
2353 . "$ac_site_file" \
2354 || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2355 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2356 as_fn_error $? "failed to load site script $ac_site_file
2357 See \`config.log' for more details" "$LINENO" 5; }
23542358 fi
23552359 done
23562360
24292433 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
24302434 { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
24312435 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
2432 as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
2436 as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
24332437 fi
24342438 ## -------------------- ##
24352439 ## Main body of script. ##
24492453
24502454 ac_aux_dir=
24512455 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
2452 for ac_t in install-sh install.sh shtool; do
2453 if test -f "$ac_dir/$ac_t"; then
2454 ac_aux_dir=$ac_dir
2455 ac_install_sh="$ac_aux_dir/$ac_t -c"
2456 break 2
2457 fi
2458 done
2456 if test -f "$ac_dir/install-sh"; then
2457 ac_aux_dir=$ac_dir
2458 ac_install_sh="$ac_aux_dir/install-sh -c"
2459 break
2460 elif test -f "$ac_dir/install.sh"; then
2461 ac_aux_dir=$ac_dir
2462 ac_install_sh="$ac_aux_dir/install.sh -c"
2463 break
2464 elif test -f "$ac_dir/shtool"; then
2465 ac_aux_dir=$ac_dir
2466 ac_install_sh="$ac_aux_dir/shtool install -c"
2467 break
2468 fi
24592469 done
24602470 if test -z "$ac_aux_dir"; then
2461 as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
2471 as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
24622472 fi
24632473
24642474 # These three variables are undocumented and unsupported,
25742584 '
25752585 case `pwd` in
25762586 *[\\\"\#\$\&\'\`$am_lf]*)
2577 as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
2587 as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
25782588 esac
25792589 case $srcdir in
25802590 *[\\\"\#\$\&\'\`$am_lf\ \ ]*)
2581 as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
2591 as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
25822592 esac
25832593
25842594 # Do `set' in a subshell so we don't clobber the current shell's
26002610 # if, for instance, CONFIG_SHELL is bash and it inherits a
26012611 # broken ls alias from the environment. This has actually
26022612 # happened. Such a system could not be considered "sane".
2603 as_fn_error "ls -t appears to fail. Make sure there is not a broken
2613 as_fn_error $? "ls -t appears to fail. Make sure there is not a broken
26042614 alias in your environment" "$LINENO" 5
26052615 fi
26062616
26102620 # Ok.
26112621 :
26122622 else
2613 as_fn_error "newly created file is older than distributed files!
2623 as_fn_error $? "newly created file is older than distributed files!
26142624 Check your system clock" "$LINENO" 5
26152625 fi
26162626 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
28482858 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
28492859 set x ${MAKE-make}
28502860 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
2851 if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
2861 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
28522862 $as_echo_n "(cached) " >&6
28532863 else
28542864 cat >conftest.make <<\_ACEOF
28562866 all:
28572867 @echo '@@@%%%=$(MAKE)=@@@%%%'
28582868 _ACEOF
2859 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
2869 # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
28602870 case `${MAKE-make} -f conftest.make 2>/dev/null` in
28612871 *@@@%%%=?*=@@@%%%*)
28622872 eval ac_cv_prog_make_${ac_make}_set=yes;;
28902900 am__isrc=' -I$(srcdir)'
28912901 # test to see if srcdir already configured
28922902 if test -f $srcdir/config.status; then
2893 as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
2903 as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
28942904 fi
28952905 fi
28962906
29062916
29072917 # Define the identity of the package.
29082918 PACKAGE='nfdump'
2909 VERSION='1.6.1p1'
2919 VERSION='1.6.3'
29102920
29112921
29122922 cat >>confdefs.h <<_ACEOF
32483258
32493259 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
32503260 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3251 as_fn_error "no acceptable C compiler found in \$PATH
3252 See \`config.log' for more details." "$LINENO" 5; }
3261 as_fn_error $? "no acceptable C compiler found in \$PATH
3262 See \`config.log' for more details" "$LINENO" 5; }
32533263
32543264 # Provide some information about the compiler.
32553265 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
33633373
33643374 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
33653375 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3366 { as_fn_set_status 77
3367 as_fn_error "C compiler cannot create executables
3368 See \`config.log' for more details." "$LINENO" 5; }; }
3376 as_fn_error 77 "C compiler cannot create executables
3377 See \`config.log' for more details" "$LINENO" 5; }
33693378 else
33703379 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
33713380 $as_echo "yes" >&6; }
34073416 else
34083417 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
34093418 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3410 as_fn_error "cannot compute suffix of executables: cannot compile and link
3411 See \`config.log' for more details." "$LINENO" 5; }
3419 as_fn_error $? "cannot compute suffix of executables: cannot compile and link
3420 See \`config.log' for more details" "$LINENO" 5; }
34123421 fi
34133422 rm -f conftest conftest$ac_cv_exeext
34143423 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
34653474 else
34663475 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
34673476 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3468 as_fn_error "cannot run C compiled programs.
3477 as_fn_error $? "cannot run C compiled programs.
34693478 If you meant to cross compile, use \`--host'.
3470 See \`config.log' for more details." "$LINENO" 5; }
3479 See \`config.log' for more details" "$LINENO" 5; }
34713480 fi
34723481 fi
34733482 fi
35183527
35193528 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
35203529 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3521 as_fn_error "cannot compute suffix of object files: cannot compile
3522 See \`config.log' for more details." "$LINENO" 5; }
3530 as_fn_error $? "cannot compute suffix of object files: cannot compile
3531 See \`config.log' for more details" "$LINENO" 5; }
35233532 fi
35243533 rm -f conftest.$ac_cv_objext conftest.$ac_ext
35253534 fi
39373946 fi
39383947 set dummy $CC; ac_cc=`$as_echo "$2" |
39393948 sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
3940 if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then :
3949 if eval "test \"\${ac_cv_prog_cc_${ac_cc}_c_o+set}\"" = set; then :
39413950 $as_echo_n "(cached) " >&6
39423951 else
39433952 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
42514260 elif test -f lexyy.c; then
42524261 ac_cv_prog_lex_root=lexyy
42534262 else
4254 as_fn_error "cannot find output from $LEX; giving up" "$LINENO" 5
4263 as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5
42554264 fi
42564265 fi
42574266 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5
43254334 fi
43264335 which $LEX > /dev/null 2>&1
43274336 if test $? = 1; then
4328 as_fn_error "No lex or flex found on system" "$LINENO" 5
4337 as_fn_error $? "No lex or flex found on system" "$LINENO" 5
43294338 fi
43304339
43314340
44114420 LIBS="-lz $LIBS"
44124421
44134422 else
4414 as_fn_error "Link with \"-lz\" failed! (Need zlib >= 1.0.2)" "$LINENO" 5
4423 as_fn_error $? "Link with \"-lz\" failed! (Need zlib >= 1.0.2)" "$LINENO" 5
44154424
44164425 fi
44174426
44184427 if test -d "$WHERE_FTPATH"; then
44194428 if test ! -f "$WHERE_FTPATH/include/ftlib.h"; then
4420 as_fn_error "ftlib.h file not found in flow-tools directory '$WHERE_FTPATH'. Use --with-ftpath=PATH" "$LINENO" 5
4429 as_fn_error $? "ftlib.h file not found in flow-tools directory '$WHERE_FTPATH'. Use --with-ftpath=PATH" "$LINENO" 5
44214430 fi
44224431 if test ! -f "$WHERE_FTPATH/lib/libft.a"; then
4423 as_fn_error "libft.a not found in flow-tools directory '$WHERE_FTPATH'. Build flow tools first" "$LINENO" 5
4432 as_fn_error $? "libft.a not found in flow-tools directory '$WHERE_FTPATH'. Build flow tools first" "$LINENO" 5
44244433 fi
44254434 FT_INCLUDES="-I$WHERE_FTPATH/include -I$WHERE_FTPATH/lib"
44264435 FT_LDFLAGS="-L$WHERE_FTPATH/lib"
44274436 else
4428 as_fn_error "flow-tools directory '$WHERE_FTPATH' does not exists. Use --with-ftpath=PATH" "$LINENO" 5
4437 as_fn_error $? "flow-tools directory '$WHERE_FTPATH' does not exists. Use --with-ftpath=PATH" "$LINENO" 5
44294438 fi
44304439 if true; then
44314440 FT2NFDUMP_TRUE=
44924501 # Broken: fails on valid input.
44934502 continue
44944503 fi
4495 rm -f conftest.err conftest.$ac_ext
4504 rm -f conftest.err conftest.i conftest.$ac_ext
44964505
44974506 # OK, works on sane cases. Now check whether nonexistent headers
44984507 # can be detected and how.
45084517 ac_preproc_ok=:
45094518 break
45104519 fi
4511 rm -f conftest.err conftest.$ac_ext
4520 rm -f conftest.err conftest.i conftest.$ac_ext
45124521
45134522 done
45144523 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
4515 rm -f conftest.err conftest.$ac_ext
4524 rm -f conftest.i conftest.err conftest.$ac_ext
45164525 if $ac_preproc_ok; then :
45174526 break
45184527 fi
45514560 # Broken: fails on valid input.
45524561 continue
45534562 fi
4554 rm -f conftest.err conftest.$ac_ext
4563 rm -f conftest.err conftest.i conftest.$ac_ext
45554564
45564565 # OK, works on sane cases. Now check whether nonexistent headers
45574566 # can be detected and how.
45674576 ac_preproc_ok=:
45684577 break
45694578 fi
4570 rm -f conftest.err conftest.$ac_ext
4579 rm -f conftest.err conftest.i conftest.$ac_ext
45714580
45724581 done
45734582 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
4574 rm -f conftest.err conftest.$ac_ext
4583 rm -f conftest.i conftest.err conftest.$ac_ext
45754584 if $ac_preproc_ok; then :
45764585
45774586 else
45784587 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
45794588 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
4580 as_fn_error "C preprocessor \"$CPP\" fails sanity check
4581 See \`config.log' for more details." "$LINENO" 5; }
4589 as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
4590 See \`config.log' for more details" "$LINENO" 5; }
45824591 fi
45834592
45844593 ac_ext=c
46394648 done
46404649 IFS=$as_save_IFS
46414650 if test -z "$ac_cv_path_GREP"; then
4642 as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
4651 as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
46434652 fi
46444653 else
46454654 ac_cv_path_GREP=$GREP
47054714 done
47064715 IFS=$as_save_IFS
47074716 if test -z "$ac_cv_path_EGREP"; then
4708 as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
4717 as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
47094718 fi
47104719 else
47114720 ac_cv_path_EGREP=$EGREP
48374846 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
48384847 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
48394848 "
4840 eval as_val=\$$as_ac_Header
4841 if test "x$as_val" = x""yes; then :
4849 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
48424850 cat >>confdefs.h <<_ACEOF
48434851 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
48444852 _ACEOF
48974905
48984906
48994907 else
4900 as_fn_error "Can not link librrd. Please specify --with-rrdpath=.. configure failed! " "$LINENO" 5
4908 as_fn_error $? "Can not link librrd. Please specify --with-rrdpath=.. configure failed! " "$LINENO" 5
49014909 fi
49024910
49034911 for ac_header in rrd.h
49224930 fi
49234931
49244932 else
4925 as_fn_error "Required rrd.h header file not found!" "$LINENO" 5
4933 as_fn_error $? "Required rrd.h header file not found!" "$LINENO" 5
49264934 fi
49274935 if test "$cross_compiling" = yes; then :
49284936 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
49294937 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
4930 as_fn_error "cannot run test program while cross compiling
4931 See \`config.log' for more details." "$LINENO" 5; }
4938 as_fn_error $? "cannot run test program while cross compiling
4939 See \`config.log' for more details" "$LINENO" 5; }
49324940 else
49334941 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
49344942 /* end confdefs.h. */
49504958 if ac_fn_c_try_run "$LINENO"; then :
49514959
49524960 else
4953 as_fn_error "Can not load rrd library. Not in loader search path! " "$LINENO" 5
4961 as_fn_error $? "Can not load rrd library. Not in loader search path! " "$LINENO" 5
49544962 fi
49554963 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
49564964 conftest.$ac_objext conftest.beam conftest.$ac_ext
49664974 else
49674975 NFPROFILE_TRUE='#'
49684976 NFPROFILE_FALSE=
4977 fi
4978
4979
4980 fi
4981
4982
4983 # Check whether --enable-nftrack was given.
4984 if test "${enable_nftrack+set}" = set; then :
4985 enableval=$enable_nftrack;
4986 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rrd_update in -lrrd" >&5
4987 $as_echo_n "checking for rrd_update in -lrrd... " >&6; }
4988 if test "${ac_cv_lib_rrd_rrd_update+set}" = set; then :
4989 $as_echo_n "(cached) " >&6
4990 else
4991 ac_check_lib_save_LIBS=$LIBS
4992 LIBS="-lrrd $LIBS"
4993 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4994 /* end confdefs.h. */
4995
4996 /* Override any GCC internal prototype to avoid an error.
4997 Use char because int might match the return type of a GCC
4998 builtin and then its argument prototype would still apply. */
4999 #ifdef __cplusplus
5000 extern "C"
5001 #endif
5002 char rrd_update ();
5003 int
5004 main ()
5005 {
5006 return rrd_update ();
5007 ;
5008 return 0;
5009 }
5010 _ACEOF
5011 if ac_fn_c_try_link "$LINENO"; then :
5012 ac_cv_lib_rrd_rrd_update=yes
5013 else
5014 ac_cv_lib_rrd_rrd_update=no
5015 fi
5016 rm -f core conftest.err conftest.$ac_objext \
5017 conftest$ac_exeext conftest.$ac_ext
5018 LIBS=$ac_check_lib_save_LIBS
5019 fi
5020 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rrd_rrd_update" >&5
5021 $as_echo "$ac_cv_lib_rrd_rrd_update" >&6; }
5022 if test "x$ac_cv_lib_rrd_rrd_update" = x""yes; then :
5023
5024 cat >>config.h <<_ACEOF
5025 #define HAVE_LIBRRD 1
5026 _ACEOF
5027 RRD_LIBS="-lrrd"
5028
5029
5030
5031 else
5032 as_fn_error $? "Can not link librrd. Please specify --with-rrdpath=.. configure failed! " "$LINENO" 5
5033 fi
5034
5035 for ac_header in rrd.h
5036 do :
5037 ac_fn_c_check_header_mongrel "$LINENO" "rrd.h" "ac_cv_header_rrd_h" "$ac_includes_default"
5038 if test "x$ac_cv_header_rrd_h" = x""yes; then :
5039 cat >>confdefs.h <<_ACEOF
5040 #define HAVE_RRD_H 1
5041 _ACEOF
5042
5043 fi
5044
5045 done
5046
5047 if test "$ac_cv_header_rrd_h" = yes; then
5048 if true; then
5049 NFTRACK_TRUE=
5050 NFTRACK_FALSE='#'
5051 else
5052 NFTRACK_TRUE='#'
5053 NFTRACK_FALSE=
5054 fi
5055
5056 else
5057 as_fn_error $? "Required rrd.h header file not found!" "$LINENO" 5
5058 fi
5059 if test "$cross_compiling" = yes; then :
5060 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
5061 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
5062 as_fn_error $? "cannot run test program while cross compiling
5063 See \`config.log' for more details" "$LINENO" 5; }
5064 else
5065 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5066 /* end confdefs.h. */
5067
5068 #include <stdio.h>
5069 #include <rrd.h>
5070
5071 int
5072 main ()
5073 {
5074
5075 rrd_value_t d;
5076
5077 ;
5078 return 0;
5079 }
5080
5081 _ACEOF
5082 if ac_fn_c_try_run "$LINENO"; then :
5083
5084 else
5085 as_fn_error $? "Can not load rrd library. Not in loader search path! " "$LINENO" 5
5086 fi
5087 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
5088 conftest.$ac_objext conftest.beam conftest.$ac_ext
5089 fi
5090
5091
5092
5093
5094 else
5095 if false; then
5096 NFTRACK_TRUE=
5097 NFTRACK_FALSE='#'
5098 else
5099 NFTRACK_TRUE='#'
5100 NFTRACK_FALSE=
49695101 fi
49705102
49715103
51845316 do :
51855317 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
51865318 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
5187 eval as_val=\$$as_ac_var
5188 if test "x$as_val" = x""yes; then :
5319 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
51895320 cat >>confdefs.h <<_ACEOF
51905321 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
51915322 _ACEOF
52015332 as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
52025333 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
52035334 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
5204 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
5335 if eval "test \"\${$as_ac_Header+set}\"" = set; then :
52055336 $as_echo_n "(cached) " >&6
52065337 else
52075338 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
52285359 eval ac_res=\$$as_ac_Header
52295360 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
52305361 $as_echo "$ac_res" >&6; }
5231 eval as_val=\$$as_ac_Header
5232 if test "x$as_val" = x""yes; then :
5362 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
52335363 cat >>confdefs.h <<_ACEOF
52345364 #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
52355365 _ACEOF
54835613 do :
54845614 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
54855615 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
5486 eval as_val=\$$as_ac_Header
5487 if test "x$as_val" = x""yes; then :
5616 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
54885617 cat >>confdefs.h <<_ACEOF
54895618 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
54905619 _ACEOF
55105639 # include <netdb.h>
55115640 #endif
55125641 "
5513 eval as_val=\$$as_ac_Header
5514 if test "x$as_val" = x""yes; then :
5642 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
55155643 cat >>confdefs.h <<_ACEOF
55165644 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
55175645 _ACEOF
55445672 if test "$ac_cv_type_void_p" = yes; then
55455673 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
55465674 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
5547 { as_fn_set_status 77
5548 as_fn_error "cannot compute sizeof (void *)
5549 See \`config.log' for more details." "$LINENO" 5; }; }
5675 as_fn_error 77 "cannot compute sizeof (void *)
5676 See \`config.log' for more details" "$LINENO" 5; }
55505677 else
55515678 ac_cv_sizeof_void_p=0
55525679 fi
59066033
59076034 ;; #(
59086035 *)
5909 as_fn_error "unknown endianness
6036 as_fn_error $? "unknown endianness
59106037 presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
59116038 esac
59126039
61376264 do :
61386265 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
61396266 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
6140 eval as_val=\$$as_ac_var
6141 if test "x$as_val" = x""yes; then :
6267 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
61426268 cat >>confdefs.h <<_ACEOF
61436269 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
61446270 _ACEOF
64456571 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
64466572 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
64476573 "
6448 eval as_val=\$$as_ac_Header
6449 if test "x$as_val" = x""yes; then :
6574 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
64506575 cat >>confdefs.h <<_ACEOF
64516576 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
64526577 _ACEOF
64666591 do :
64676592 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
64686593 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
6469 eval as_val=\$$as_ac_var
6470 if test "x$as_val" = x""yes; then :
6594 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
64716595 cat >>confdefs.h <<_ACEOF
64726596 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
64736597 _ACEOF
65196643 static time_t time_t_min;
65206644
65216645 /* Values we'll use to set the TZ environment variable. */
6522 static char *tz_strings[] = {
6523 (char *) 0, "TZ=GMT0", "TZ=JST-9",
6646 static const char *tz_strings[] = {
6647 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
65246648 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
65256649 };
65266650 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
65376661 instead of "TZ=America/Vancouver" in order to detect the bug even
65386662 on systems that don't support the Olson extension, or don't have the
65396663 full zoneinfo tables installed. */
6540 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
6664 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
65416665
65426666 tm.tm_year = 98;
65436667 tm.tm_mon = 3;
65506674 }
65516675
65526676 static int
6553 mktime_test1 (now)
6554 time_t now;
6677 mktime_test1 (time_t now)
65556678 {
65566679 struct tm *lt;
65576680 return ! (lt = localtime (&now)) || mktime (lt) == now;
65586681 }
65596682
65606683 static int
6561 mktime_test (now)
6562 time_t now;
6684 mktime_test (time_t now)
65636685 {
65646686 return (mktime_test1 (now)
65656687 && mktime_test1 ((time_t) (time_t_max - now))
65836705 }
65846706
65856707 static int
6586 bigtime_test (j)
6587 int j;
6708 bigtime_test (int j)
65886709 {
65896710 struct tm tm;
65906711 time_t now;
66286749 instead of "TZ=America/Vancouver" in order to detect the bug even
66296750 on systems that don't support the Olson extension, or don't have the
66306751 full zoneinfo tables installed. */
6631 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
6752 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
66326753
66336754 t = mktime (&tm);
66346755
66636784 for (i = 0; i < N_STRINGS; i++)
66646785 {
66656786 if (tz_strings[i])
6666 putenv (tz_strings[i]);
6787 putenv ((char*) tz_strings[i]);
66676788
66686789 for (t = 0; t <= time_t_max - delta; t += delta)
66696790 if (! mktime_test (t))
69397060 do :
69407061 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
69417062 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
6942 eval as_val=\$$as_ac_var
6943 if test "x$as_val" = x""yes; then :
7063 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
69447064 cat >>confdefs.h <<_ACEOF
69457065 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
69467066 _ACEOF
72637383 if test "$ac_cv_type_short" = yes; then
72647384 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
72657385 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7266 { as_fn_set_status 77
7267 as_fn_error "cannot compute sizeof (short)
7268 See \`config.log' for more details." "$LINENO" 5; }; }
7386 as_fn_error 77 "cannot compute sizeof (short)
7387 See \`config.log' for more details" "$LINENO" 5; }
72697388 else
72707389 ac_cv_sizeof_short=0
72717390 fi
72977416 if test "$ac_cv_type_int" = yes; then
72987417 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
72997418 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7300 { as_fn_set_status 77
7301 as_fn_error "cannot compute sizeof (int)
7302 See \`config.log' for more details." "$LINENO" 5; }; }
7419 as_fn_error 77 "cannot compute sizeof (int)
7420 See \`config.log' for more details" "$LINENO" 5; }
73037421 else
73047422 ac_cv_sizeof_int=0
73057423 fi
73317449 if test "$ac_cv_type_long" = yes; then
73327450 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
73337451 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7334 { as_fn_set_status 77
7335 as_fn_error "cannot compute sizeof (long)
7336 See \`config.log' for more details." "$LINENO" 5; }; }
7452 as_fn_error 77 "cannot compute sizeof (long)
7453 See \`config.log' for more details" "$LINENO" 5; }
73377454 else
73387455 ac_cv_sizeof_long=0
73397456 fi
73657482 if test "$ac_cv_type_long_long" = yes; then
73667483 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
73677484 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7368 { as_fn_set_status 77
7369 as_fn_error "cannot compute sizeof (long long)
7370 See \`config.log' for more details." "$LINENO" 5; }; }
7485 as_fn_error 77 "cannot compute sizeof (long long)
7486 See \`config.log' for more details" "$LINENO" 5; }
73717487 else
73727488 ac_cv_sizeof_long_long=0
73737489 fi
73997515 if test "$ac_cv_type___int64" = yes; then
74007516 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
74017517 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7402 { as_fn_set_status 77
7403 as_fn_error "cannot compute sizeof (__int64)
7404 See \`config.log' for more details." "$LINENO" 5; }; }
7518 as_fn_error 77 "cannot compute sizeof (__int64)
7519 See \`config.log' for more details" "$LINENO" 5; }
74057520 else
74067521 ac_cv_sizeof___int64=0
74077522 fi
74337548 if test "$ac_cv_type_void_p" = yes; then
74347549 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
74357550 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7436 { as_fn_set_status 77
7437 as_fn_error "cannot compute sizeof (void *)
7438 See \`config.log' for more details." "$LINENO" 5; }; }
7551 as_fn_error 77 "cannot compute sizeof (void *)
7552 See \`config.log' for more details" "$LINENO" 5; }
74397553 else
74407554 ac_cv_sizeof_void_p=0
74417555 fi
74677581 if test "$ac_cv_type_size_t" = yes; then
74687582 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
74697583 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7470 { as_fn_set_status 77
7471 as_fn_error "cannot compute sizeof (size_t)
7472 See \`config.log' for more details." "$LINENO" 5; }; }
7584 as_fn_error 77 "cannot compute sizeof (size_t)
7585 See \`config.log' for more details" "$LINENO" 5; }
74737586 else
74747587 ac_cv_sizeof_size_t=0
74757588 fi
75017614 if test "$ac_cv_type_ptrdiff_t" = yes; then
75027615 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
75037616 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7504 { as_fn_set_status 77
7505 as_fn_error "cannot compute sizeof (ptrdiff_t)
7506 See \`config.log' for more details." "$LINENO" 5; }; }
7617 as_fn_error 77 "cannot compute sizeof (ptrdiff_t)
7618 See \`config.log' for more details" "$LINENO" 5; }
75077619 else
75087620 ac_cv_sizeof_ptrdiff_t=0
75097621 fi
76047716 do :
76057717 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
76067718 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
7607 eval as_val=\$$as_ac_var
7608 if test "x$as_val" = x""yes; then :
7719 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
76097720 cat >>confdefs.h <<_ACEOF
76107721 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
76117722 _ACEOF
77897900
77907901 ac_libobjs=
77917902 ac_ltlibobjs=
7903 U=
77927904 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
77937905 # 1. Remove the extension, and $U if already installed.
77947906 ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
78127924 fi
78137925
78147926 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
7815 as_fn_error "conditional \"AMDEP\" was never defined.
7927 as_fn_error $? "conditional \"AMDEP\" was never defined.
78167928 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78177929 fi
78187930 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
7819 as_fn_error "conditional \"am__fastdepCC\" was never defined.
7931 as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
78207932 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78217933 fi
78227934 if test -z "${FT2NFDUMP_TRUE}" && test -z "${FT2NFDUMP_FALSE}"; then
7823 as_fn_error "conditional \"FT2NFDUMP\" was never defined.
7935 as_fn_error $? "conditional \"FT2NFDUMP\" was never defined.
78247936 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78257937 fi
78267938 if test -z "${FT2NFDUMP_TRUE}" && test -z "${FT2NFDUMP_FALSE}"; then
7827 as_fn_error "conditional \"FT2NFDUMP\" was never defined.
7939 as_fn_error $? "conditional \"FT2NFDUMP\" was never defined.
78287940 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78297941 fi
78307942 if test -z "${NFPROFILE_TRUE}" && test -z "${NFPROFILE_FALSE}"; then
7831 as_fn_error "conditional \"NFPROFILE\" was never defined.
7943 as_fn_error $? "conditional \"NFPROFILE\" was never defined.
78327944 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78337945 fi
78347946 if test -z "${NFPROFILE_TRUE}" && test -z "${NFPROFILE_FALSE}"; then
7835 as_fn_error "conditional \"NFPROFILE\" was never defined.
7947 as_fn_error $? "conditional \"NFPROFILE\" was never defined.
78367948 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78377949 fi
7950 if test -z "${NFTRACK_TRUE}" && test -z "${NFTRACK_FALSE}"; then
7951 as_fn_error $? "conditional \"NFTRACK\" was never defined.
7952 Usually this means the macro was only invoked conditionally." "$LINENO" 5
7953 fi
7954 if test -z "${NFTRACK_TRUE}" && test -z "${NFTRACK_FALSE}"; then
7955 as_fn_error $? "conditional \"NFTRACK\" was never defined.
7956 Usually this means the macro was only invoked conditionally." "$LINENO" 5
7957 fi
78387958 if test -z "${SFLOW_TRUE}" && test -z "${SFLOW_FALSE}"; then
7839 as_fn_error "conditional \"SFLOW\" was never defined.
7959 as_fn_error $? "conditional \"SFLOW\" was never defined.
78407960 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78417961 fi
78427962 if test -z "${READPCAP_TRUE}" && test -z "${READPCAP_FALSE}"; then
7843 as_fn_error "conditional \"READPCAP\" was never defined.
7963 as_fn_error $? "conditional \"READPCAP\" was never defined.
78447964 Usually this means the macro was only invoked conditionally." "$LINENO" 5
78457965 fi
78467966
79918111 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
79928112
79938113
7994 # as_fn_error ERROR [LINENO LOG_FD]
7995 # ---------------------------------
8114 # as_fn_error STATUS ERROR [LINENO LOG_FD]
8115 # ----------------------------------------
79968116 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
79978117 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
7998 # script with status $?, using 1 if that was 0.
8118 # script with STATUS, using 1 if that was 0.
79998119 as_fn_error ()
80008120 {
8001 as_status=$?; test $as_status -eq 0 && as_status=1
8002 if test "$3"; then
8003 as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
8004 $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
8121 as_status=$1; test $as_status -eq 0 && as_status=1
8122 if test "$4"; then
8123 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
8124 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
80058125 fi
8006 $as_echo "$as_me: error: $1" >&2
8126 $as_echo "$as_me: error: $2" >&2
80078127 as_fn_exit $as_status
80088128 } # as_fn_error
80098129
81998319 test -d "$as_dir" && break
82008320 done
82018321 test -z "$as_dirs" || eval "mkdir $as_dirs"
8202 } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
8322 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
82038323
82048324
82058325 } # as_fn_mkdir_p
82528372 # report actual input values of CONFIG_FILES etc. instead of their
82538373 # values after options handling.
82548374 ac_log="
8255 This file was extended by nfdump $as_me 1.6.1p1, which was
8256 generated by GNU Autoconf 2.65. Invocation command line was
8375 This file was extended by nfdump $as_me 1.6.3, which was
8376 generated by GNU Autoconf 2.67. Invocation command line was
82578377
82588378 CONFIG_FILES = $CONFIG_FILES
82598379 CONFIG_HEADERS = $CONFIG_HEADERS
83188438 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
83198439 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
83208440 ac_cs_version="\\
8321 nfdump config.status 1.6.1p1
8322 configured by $0, generated by GNU Autoconf 2.65,
8441 nfdump config.status 1.6.3
8442 configured by $0, generated by GNU Autoconf 2.67,
83238443 with options \\"\$ac_cs_config\\"
83248444
8325 Copyright (C) 2009 Free Software Foundation, Inc.
8445 Copyright (C) 2010 Free Software Foundation, Inc.
83268446 This config.status script is free software; the Free Software Foundation
83278447 gives unlimited permission to copy, distribute and modify it."
83288448
83408460 while test $# != 0
83418461 do
83428462 case $1 in
8343 --*=*)
8463 --*=?*)
83448464 ac_option=`expr "X$1" : 'X\([^=]*\)='`
83458465 ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
8466 ac_shift=:
8467 ;;
8468 --*=)
8469 ac_option=`expr "X$1" : 'X\([^=]*\)='`
8470 ac_optarg=
83468471 ac_shift=:
83478472 ;;
83488473 *)
83668491 $ac_shift
83678492 case $ac_optarg in
83688493 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
8494 '') as_fn_error $? "missing file argument" ;;
83698495 esac
83708496 as_fn_append CONFIG_FILES " '$ac_optarg'"
83718497 ac_need_defaults=false;;
83788504 ac_need_defaults=false;;
83798505 --he | --h)
83808506 # Conflict between --help and --header
8381 as_fn_error "ambiguous option: \`$1'
8507 as_fn_error $? "ambiguous option: \`$1'
83828508 Try \`$0 --help' for more information.";;
83838509 --help | --hel | -h )
83848510 $as_echo "$ac_cs_usage"; exit ;;
83878513 ac_cs_silent=: ;;
83888514
83898515 # This is an error.
8390 -*) as_fn_error "unrecognized option: \`$1'
8516 -*) as_fn_error $? "unrecognized option: \`$1'
83918517 Try \`$0 --help' for more information." ;;
83928518
83938519 *) as_fn_append ac_config_targets " $1"
84478573 "bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;;
84488574 "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
84498575
8450 *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
8576 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
84518577 esac
84528578 done
84538579
84858611 {
84868612 tmp=./conf$$-$RANDOM
84878613 (umask 077 && mkdir "$tmp")
8488 } || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
8614 } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
84898615
84908616 # Set up the scripts for CONFIG_FILES section.
84918617 # No need to generate them if there are no CONFIG_FILES.
85028628 fi
85038629 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
85048630 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
8505 ac_cs_awk_cr='\r'
8631 ac_cs_awk_cr='\\r'
85068632 else
85078633 ac_cs_awk_cr=$ac_cr
85088634 fi
85168642 echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
85178643 echo "_ACEOF"
85188644 } >conf$$subs.sh ||
8519 as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
8520 ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
8645 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
8646 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
85218647 ac_delim='%!_!# '
85228648 for ac_last_try in false false false false false :; do
85238649 . ./conf$$subs.sh ||
8524 as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
8650 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
85258651
85268652 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
85278653 if test $ac_delim_n = $ac_delim_num; then
85288654 break
85298655 elif $ac_last_try; then
8530 as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
8656 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
85318657 else
85328658 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
85338659 fi
86168742 else
86178743 cat
86188744 fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
8619 || as_fn_error "could not setup config files machinery" "$LINENO" 5
8620 _ACEOF
8621
8622 # VPATH may cause trouble with some makes, so we remove $(srcdir),
8623 # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
8745 || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
8746 _ACEOF
8747
8748 # VPATH may cause trouble with some makes, so we remove sole $(srcdir),
8749 # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
86248750 # trailing colons and then remove the whole line if VPATH becomes empty
86258751 # (actually we leave an empty line to preserve line numbers).
86268752 if test "x$srcdir" = x.; then
8627 ac_vpsub='/^[ ]*VPATH[ ]*=/{
8628 s/:*\$(srcdir):*/:/
8629 s/:*\${srcdir}:*/:/
8630 s/:*@srcdir@:*/:/
8631 s/^\([^=]*=[ ]*\):*/\1/
8753 ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
8754 h
8755 s///
8756 s/^/:/
8757 s/[ ]*$/:/
8758 s/:\$(srcdir):/:/g
8759 s/:\${srcdir}:/:/g
8760 s/:@srcdir@:/:/g
8761 s/^:*//
86328762 s/:*$//
8763 x
8764 s/\(=[ ]*\).*/\1/
8765 G
8766 s/\n//
86338767 s/^[^=]*=[ ]*$//
86348768 }'
86358769 fi
86578791 if test -z "$ac_t"; then
86588792 break
86598793 elif $ac_last_try; then
8660 as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
8794 as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
86618795 else
86628796 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
86638797 fi
87428876 _ACAWK
87438877 _ACEOF
87448878 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
8745 as_fn_error "could not setup config headers machinery" "$LINENO" 5
8879 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
87468880 fi # test -n "$CONFIG_HEADERS"
87478881
87488882
87558889 esac
87568890 case $ac_mode$ac_tag in
87578891 :[FHL]*:*);;
8758 :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
8892 :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
87598893 :[FH]-) ac_tag=-:-;;
87608894 :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
87618895 esac
87838917 [\\/$]*) false;;
87848918 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
87858919 esac ||
8786 as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
8920 as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
87878921 esac
87888922 case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
87898923 as_fn_append ac_file_inputs " '$ac_f'"
88108944
88118945 case $ac_tag in
88128946 *:-:* | *:-) cat >"$tmp/stdin" \
8813 || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
8947 || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
88148948 esac
88158949 ;;
88168950 esac
89479081 $ac_datarootdir_hack
89489082 "
89499083 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
8950 || as_fn_error "could not create $ac_file" "$LINENO" 5
9084 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
89519085
89529086 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
89539087 { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
89549088 { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
89559089 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
8956 which seems to be undefined. Please make sure it is defined." >&5
9090 which seems to be undefined. Please make sure it is defined" >&5
89579091 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
8958 which seems to be undefined. Please make sure it is defined." >&2;}
9092 which seems to be undefined. Please make sure it is defined" >&2;}
89599093
89609094 rm -f "$tmp/stdin"
89619095 case $ac_file in
89629096 -) cat "$tmp/out" && rm -f "$tmp/out";;
89639097 *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
89649098 esac \
8965 || as_fn_error "could not create $ac_file" "$LINENO" 5
9099 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
89669100 ;;
89679101 :H)
89689102 #
89739107 $as_echo "/* $configure_input */" \
89749108 && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
89759109 } >"$tmp/config.h" \
8976 || as_fn_error "could not create $ac_file" "$LINENO" 5
9110 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
89779111 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
89789112 { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
89799113 $as_echo "$as_me: $ac_file is unchanged" >&6;}
89809114 else
89819115 rm -f "$ac_file"
89829116 mv "$tmp/config.h" "$ac_file" \
8983 || as_fn_error "could not create $ac_file" "$LINENO" 5
9117 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
89849118 fi
89859119 else
89869120 $as_echo "/* $configure_input */" \
89879121 && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
8988 || as_fn_error "could not create -" "$LINENO" 5
9122 || as_fn_error $? "could not create -" "$LINENO" 5
89899123 fi
89909124 # Compute "$ac_file"'s index in $config_headers.
89919125 _am_arg="$ac_file"
91359269 ac_clean_files=$ac_clean_files_save
91369270
91379271 test $ac_write_fail = 0 ||
9138 as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
9272 as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
91399273
91409274
91419275 # configure is writing to config.log, and then calls config.status.
91569290 exec 5>>config.log
91579291 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
91589292 # would make configure fail if this is the last instruction.
9159 $ac_cs_success || as_fn_exit $?
9293 $ac_cs_success || as_fn_exit 1
91609294 fi
91619295 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
91629296 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
22
33 AC_PREREQ(2.59)
44 AC_REVISION($Revision: 69 $)dnl
5 AC_INIT(nfdump, 1.6.2, phaag@users.sourceforge.net)
5 AC_INIT(nfdump, 1.6.3, phaag@users.sourceforge.net)
66 #AC_CONFIG_SRCDIR([grammar.y])
77 AC_CONFIG_HEADER([config.h])
88 AM_INIT_AUTOMAKE()
147147 ]
148148 ,
149149 AM_CONDITIONAL(NFPROFILE, false)
150 )
151
152 AC_ARG_ENABLE(nftrack,
153 [ --enable-nftrack Build nftrack used by PortTracker; default is NO],
154 [
155 AC_CHECK_LIB(rrd, rrd_update,[
156 cat >>config.h <<_ACEOF
157 #define HAVE_LIBRRD 1
158 _ACEOF
159 RRD_LIBS="-lrrd"
160 AC_SUBST(RRD_LIBS)
161 ]
162 , AC_MSG_ERROR(Can not link librrd. Please specify --with-rrdpath=.. configure failed! ))
163 AC_CHECK_HEADERS([rrd.h])
164 if test "$ac_cv_header_rrd_h" = yes; then
165 AM_CONDITIONAL(NFTRACK, true)
166 else
167 AC_MSG_ERROR(Required rrd.h header file not found!)
168 fi
169 AC_RUN_IFELSE(
170 [ AC_LANG_PROGRAM(
171 [[
172 #include <stdio.h>
173 #include <rrd.h>
174 ]],
175 [[
176 rrd_value_t d;
177 ]])
178 ],, AC_MSG_ERROR(Can not load rrd library. Not in loader search path! ))
179
180 ]
181 ,
182 AM_CONDITIONAL(NFTRACK, false)
150183 )
151184
152185 AC_ARG_ENABLE(sflow,
0 #!/usr/bin/perl
1 #
2 # Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
13 # * Neither the name of SWITCH nor the names of its contributors may be
14 # used to endorse or promote products derived from this software without
15 # specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29 # $Author: haag $
30 #
31 # $Id: PortTracker.pm 67 2010-09-09 05:56:05Z haag $
32 #
33 # $LastChangedRevision: 67 $
34
35 # Demo plugin for NfSen
36 #
37 # This plugin demonstrates the use of plugins
38
39 package PortTracker;
40
41 use strict;
42 use NfSen;
43 use NfConf;
44
45 #
46 # The plugin may send any messages to syslog
47 # Do not initialize syslog, as this is done by
48 # the main process nfsen-run
49 use Sys::Syslog;
50
51 our $VERSION = 130;
52
53 our %cmd_lookup = (
54 'get-portgraph' => \&GetPortGraph,
55 'get-topN' => \&GetTopN,
56 );
57
58 my ( $nftrack, $PROFILEDATADIR );
59
60 my $PORTSDBDIR = "/data/ports-db";
61
62 my $EODATA = ".\n";
63
64 # colours used in graphs
65 # if more than 12 graphs are drawn ( does this really make sense ? )
66 # the same colours are used again
67 my @colour = (
68 '#ff0000', '#ff8000', '#ffff00', '#80ff00', '#00ff00',
69 '#00ff80', '#00ffff', '#0080ff', '#0000ff', '#8000ff',
70 '#ff00ff', '#ff0080'
71 );
72
73
74 sub GetTopN {
75 my $socket = shift;
76 my $opts = shift;
77
78 my $interval;
79 if ( !exists $$opts{'interval'} ) {
80 $interval = 1;
81 } else {
82 $interval = $$opts{'interval'};
83 }
84 print $socket ".Get topN ports\n";
85
86 my $statfile = $interval == 24 ? 'portstat24.txt' : 'portstat.txt';
87 print $socket ".topN ports $PORTSDBDIR/$statfile\n";
88 if ( !open STAT, "$PORTSDBDIR/$statfile" ) {
89 print $socket $EODATA;
90 print $socket "ERR Open statfile '$PORTSDBDIR/$statfile': $!\n";
91 return;
92 }
93
94 print $socket ".topN read ports\n";
95 while ( <STAT> ) {
96 chomp;
97 print $socket "_topN=$_\n";
98 }
99 print $socket $EODATA;
100 print $socket "OK Command completed\n",
101
102 } # End of GetPortGraph
103
104 sub GetPortGraph {
105 my $socket = shift;
106 my $opts = shift;
107
108 # get all arguments:
109 # Example:
110 # proto typw logscale light tstart tend topN track_list
111 # tcp flows 0 0 1116495000 1116581400 '22 445 135 1433' '80 143'
112 if ( !exists $$opts{'arg'} ) {
113 print $socket $EODATA;
114 print $socket "ERR Missing Arguments.\n";
115 }
116 my $ARGS = $$opts{'arg'};
117 my $proto = shift @$ARGS; # 'tcp' or 'udp'
118 my $type = shift @$ARGS; # 'flows', 'packets' or 'bytes'
119 my $logscale = shift @$ARGS; # 0 or 1
120 my $stacked = shift @$ARGS; # 0 or 1
121 my $light = shift @$ARGS; # 0 or 1
122 my $tstart = shift @$ARGS; # start time - UNIX format
123 my $tend = shift @$ARGS; # end time - UNIX format
124 my $topN = shift @$ARGS; # TopN port list: string: ' ' separated port list
125 my $track_list = shift @$ARGS; # Static track port list: string: ' ' separated port list
126 my $skip_list = shift @$ARGS; # Static skip port list: string: ' ' separated port list
127
128 if ( !defined $proto || !defined $type || !defined $logscale || !defined $stacked ||
129 !defined $light || !defined $tstart || !defined $tend || !defined $topN ||
130 !defined $track_list || !defined $skip_list ) {
131 print $socket $EODATA;
132 print $socket "ERR Argument Error.\n";
133 return;
134 }
135 my @skipPorts = split '-', $skip_list;
136
137 my @topN = split '-', $topN;
138 my @track_list = split '-', $track_list;
139
140 # remove the common ports in both lists from the dynamic topN list
141 my %_tmp;
142 @_tmp{@track_list} = @track_list;
143 delete @_tmp{@topN};
144 @track_list = sort keys %_tmp;
145
146 # %_tmp = ();
147 # @_tmp{@topN} = @topN;
148 # delete @_tmp{@skipPorts};
149 # @topN = keys %_tmp;
150
151 %_tmp = ();
152 my @_tmp;
153 @_tmp{@skipPorts} = @skipPorts;
154 foreach my $port ( @topN ) {
155 push @_tmp, $port unless exists $_tmp{$port};
156 }
157 @topN = @_tmp;
158
159 my $datestr = scalar localtime($tstart) . " - " . scalar localtime($tend);
160 my $title = uc($proto) . " " . ucfirst($type);
161
162 my @DEFS = ();
163
164 # Compile rrd args
165 my @rrdargs = ();
166 push @rrdargs, "-"; # output graphics to stdout
167
168 foreach my $port ( @topN, @track_list ) {
169 # assemble filename
170 my $fileident = $port >> 10;
171 my $rrdfile = "$PORTSDBDIR/${proto}-${type}-$fileident.rrd";
172 # which ident in this rrd file
173 my $ident = $port & 1023; # 0x0000001111111111 mask
174 push @rrdargs, "DEF:Port${port}=$rrdfile:p${ident}:AVERAGE";
175 }
176
177 push @rrdargs, "--start", "$tstart";
178 push @rrdargs, "--end", "$tend";
179 push @rrdargs, "--title", "$datestr - $title" unless $light;
180 push @rrdargs, "--vertical-label", "$title" unless $light;
181
182 # lin or log graph?
183 push @rrdargs, "--logarithmic" if $logscale;
184
185 if ( $light ) {
186 push @rrdargs, "-w";
187 push @rrdargs, "288";
188 push @rrdargs, "-h";
189 push @rrdargs, "150";
190 push @rrdargs, "--no-legend"; # no legend in small pictures
191 } else {
192 push @rrdargs, "-w";
193 push @rrdargs, "576";
194 push @rrdargs, "-h";
195 push @rrdargs, "300";
196 }
197
198
199 my $i=0;
200 my $area_set = 0;
201 my $n = scalar @topN;
202 push @rrdargs, "COMMENT:Top $n Ports\\n";
203 if ( $stacked && scalar @topN ) {
204 my $port = shift @topN;
205 push @rrdargs, "AREA:Port${port}$colour[$i]:Port ${port}";
206 $i++;
207 $area_set = 1;
208 foreach my $port ( @topN ) {
209 push @rrdargs, "STACK:Port${port}$colour[$i]:Port ${port}";
210 $i++;
211 }
212
213 } else {
214 foreach my $port ( @topN ) {
215 push @rrdargs, "LINE1:Port${port}$colour[$i]:Port ${port}";
216 $i++;
217 }
218 }
219
220 if ( scalar @track_list) {
221 push @rrdargs, "COMMENT:\\n";
222 push @rrdargs, "COMMENT:\\n";
223 push @rrdargs, "COMMENT:Tracked Ports\\n";
224 }
225 if ( $stacked && scalar @track_list) {
226 if ( !$area_set ) {
227 my $port = shift @track_list;
228 push @rrdargs, "AREA:Port${port}$colour[$i]:Port ${port}";
229 $i++;
230 }
231 foreach my $port ( @track_list ) {
232 push @rrdargs, "STACK:Port${port}$colour[$i]:Port ${port}";
233 $i++;
234 }
235
236 } else {
237 foreach my $port ( @track_list ) {
238 push @rrdargs, "LINE2:Port${port}$colour[$i]:Port ${port}";
239 $i++;
240 }
241 }
242 if ( scalar @skipPorts) {
243 push @rrdargs, "COMMENT:\\n";
244 push @rrdargs, "COMMENT:\\n";
245 my $portlist = join ',', @skipPorts;
246 push @rrdargs, "COMMENT:Skipped Ports $portlist\\n";
247 }
248 my ($averages,$xsize,$ysize) = RRDs::graph( @rrdargs );
249
250 if (my $ERROR = RRDs::error) {
251 print "ERROR: $ERROR\n";
252 }
253
254 } # End of GenPortGraph
255
256
257 sub nftrack_execute {
258 my $command = shift;
259
260 syslog('debug', $command);
261
262 my $ret = system($command);
263 if ( $ret == - 1 ) {
264 syslog('err', "Failed to execute nftrack: $!\n");
265 } elsif ($ret & 127) {
266 syslog('err', "nftrack died with signal %d, %s coredump\n", ($ret & 127), ($ret & 128) ? 'with' : 'without');
267 } else {
268 syslog('debug', "nftrack exited with value %d\n", $ret >> 8);
269 }
270
271 } # End of nftrack_execute
272
273 #
274 # Periodic function
275 # input: hash reference including the items:
276 # 'profile' profile name
277 # 'profilegroup' profile group
278 # 'timeslot' time of slot to process: Format yyyymmddHHMM e.g. 200503031200
279 sub run {
280 my $argref = shift;
281
282 my $profile = $$argref{'profile'};
283 my $profilegroup = $$argref{'profilegroup'};
284 my $timeslot = $$argref{'timeslot'};
285
286 syslog('debug', "PortTracker run: Profile: $profile, Time: $timeslot");
287
288 my %profileinfo = NfProfile::ReadProfile($profile);
289 my $netflow_sources = "$PROFILEDATADIR/$profile/$profileinfo{'sourcelist'}";
290
291 #
292 # process all sources of this profile at once
293 my $command = "$nftrack -M $netflow_sources -r nfcapd.$timeslot -d $PORTSDBDIR -A -t $timeslot -s -p -w $PORTSDBDIR/portstat.txt";
294 nftrack_execute($command);
295
296 $command = "$nftrack -d $PORTSDBDIR -S -p -w $PORTSDBDIR/portstat24.txt";
297 nftrack_execute($command);
298
299 #
300 # Process the output and notify the duty team
301
302 syslog('debug', "PortTracker run: Done.");
303
304 } # End of run
305
306 sub Init {
307 syslog("info", "PortTracker: Init");
308
309 # Init some vars
310 $nftrack = "$NfConf::PREFIX/nftrack";
311 $PROFILEDATADIR = "$NfConf::PROFILEDATADIR";
312
313 return 1;
314 }
315
316 sub Cleanup {
317 syslog("info", "PortTracker Cleanup");
318 # not used here
319 }
320
321 1;
0 #!/usr/bin/perl
1 #
2 # Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
13 # * Neither the name of SWITCH nor the names of its contributors may be
14 # used to endorse or promote products derived from this software without
15 # specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29 # $Author: haag $
30 #
31 # $Id: PortTracker.pm 67 2010-09-09 05:56:05Z haag $
32 #
33 # $LastChangedRevision: 67 $
34
35 # Demo plugin for NfSen
36 #
37 # This plugin demonstrates the use of plugins
38
39 package PortTracker;
40
41 use strict;
42 use NfSen;
43 use NfConf;
44
45 #
46 # The plugin may send any messages to syslog
47 # Do not initialize syslog, as this is done by
48 # the main process nfsen-run
49 use Sys::Syslog;
50
51 our $VERSION = 130;
52
53 our %cmd_lookup = (
54 'get-portgraph' => \&GetPortGraph,
55 'get-topN' => \&GetTopN,
56 );
57
58 my ( $nftrack, $PROFILEDATADIR );
59
60 my $PORTSDBDIR = "/data/ports-db";
61
62 my $EODATA = ".\n";
63
64 # colours used in graphs
65 # if more than 12 graphs are drawn ( does this really make sense ? )
66 # the same colours are used again
67 my @colour = (
68 '#ff0000', '#ff8000', '#ffff00', '#80ff00', '#00ff00',
69 '#00ff80', '#00ffff', '#0080ff', '#0000ff', '#8000ff',
70 '#ff00ff', '#ff0080'
71 );
72
73
74 sub GetTopN {
75 my $socket = shift;
76 my $opts = shift;
77
78 my $interval;
79 if ( !exists $$opts{'interval'} ) {
80 $interval = 1;
81 } else {
82 $interval = $$opts{'interval'};
83 }
84 print $socket ".Get topN ports\n";
85
86 my $statfile = $interval == 24 ? 'portstat24.txt' : 'portstat.txt';
87 print $socket ".topN ports $PORTSDBDIR/$statfile\n";
88 if ( !open STAT, "$PORTSDBDIR/$statfile" ) {
89 print $socket $EODATA;
90 print $socket "ERR Open statfile '$PORTSDBDIR/$statfile': $!\n";
91 return;
92 }
93
94 print $socket ".topN read ports\n";
95 while ( <STAT> ) {
96 chomp;
97 print $socket "_topN=$_\n";
98 }
99 print $socket $EODATA;
100 print $socket "OK Command completed\n",
101
102 } # End of GetPortGraph
103
104 sub GetPortGraph {
105 my $socket = shift;
106 my $opts = shift;
107
108 # get all arguments:
109 # Example:
110 # proto typw logscale light tstart tend topN track_list
111 # tcp flows 0 0 1116495000 1116581400 '22 445 135 1433' '80 143'
112 if ( !exists $$opts{'arg'} ) {
113 print $socket $EODATA;
114 print $socket "ERR Missing Arguments.\n";
115 }
116 my $ARGS = $$opts{'arg'};
117 my $proto = shift @$ARGS; # 'tcp' or 'udp'
118 my $type = shift @$ARGS; # 'flows', 'packets' or 'bytes'
119 my $logscale = shift @$ARGS; # 0 or 1
120 my $stacked = shift @$ARGS; # 0 or 1
121 my $light = shift @$ARGS; # 0 or 1
122 my $tstart = shift @$ARGS; # start time - UNIX format
123 my $tend = shift @$ARGS; # end time - UNIX format
124 my $topN = shift @$ARGS; # TopN port list: string: ' ' separated port list
125 my $track_list = shift @$ARGS; # Static track port list: string: ' ' separated port list
126 my $skip_list = shift @$ARGS; # Static skip port list: string: ' ' separated port list
127
128 if ( !defined $proto || !defined $type || !defined $logscale || !defined $stacked ||
129 !defined $light || !defined $tstart || !defined $tend || !defined $topN ||
130 !defined $track_list || !defined $skip_list ) {
131 print $socket $EODATA;
132 print $socket "ERR Argument Error.\n";
133 return;
134 }
135 my @skipPorts = split '-', $skip_list;
136
137 my @topN = split '-', $topN;
138 my @track_list = split '-', $track_list;
139
140 # remove the common ports in both lists from the dynamic topN list
141 my %_tmp;
142 @_tmp{@track_list} = @track_list;
143 delete @_tmp{@topN};
144 @track_list = sort keys %_tmp;
145
146 # %_tmp = ();
147 # @_tmp{@topN} = @topN;
148 # delete @_tmp{@skipPorts};
149 # @topN = keys %_tmp;
150
151 %_tmp = ();
152 my @_tmp;
153 @_tmp{@skipPorts} = @skipPorts;
154 foreach my $port ( @topN ) {
155 push @_tmp, $port unless exists $_tmp{$port};
156 }
157 @topN = @_tmp;
158
159 my $datestr = scalar localtime($tstart) . " - " . scalar localtime($tend);
160 my $title = uc($proto) . " " . ucfirst($type);
161
162 my @DEFS = ();
163
164 # Compile rrd args
165 my @rrdargs = ();
166 push @rrdargs, "-"; # output graphics to stdout
167
168 foreach my $port ( @topN, @track_list ) {
169 # assemble filename
170 my $fileident = $port >> 10;
171 my $rrdfile = "$PORTSDBDIR/${proto}-${type}-$fileident.rrd";
172 # which ident in this rrd file
173 my $ident = $port & 1023; # 0x0000001111111111 mask
174 push @rrdargs, "DEF:Port${port}=$rrdfile:p${ident}:AVERAGE";
175 }
176
177 push @rrdargs, "--start", "$tstart";
178 push @rrdargs, "--end", "$tend";
179 push @rrdargs, "--title", "$datestr - $title" unless $light;
180 push @rrdargs, "--vertical-label", "$title" unless $light;
181
182 # lin or log graph?
183 push @rrdargs, "--logarithmic" if $logscale;
184
185 if ( $light ) {
186 push @rrdargs, "-w";
187 push @rrdargs, "288";
188 push @rrdargs, "-h";
189 push @rrdargs, "150";
190 push @rrdargs, "--no-legend"; # no legend in small pictures
191 } else {
192 push @rrdargs, "-w";
193 push @rrdargs, "576";
194 push @rrdargs, "-h";
195 push @rrdargs, "300";
196 }
197
198
199 my $i=0;
200 my $area_set = 0;
201 my $n = scalar @topN;
202 push @rrdargs, "COMMENT:Top $n Ports\\n";
203 if ( $stacked && scalar @topN ) {
204 my $port = shift @topN;
205 push @rrdargs, "AREA:Port${port}$colour[$i]:Port ${port}";
206 $i++;
207 $area_set = 1;
208 foreach my $port ( @topN ) {
209 push @rrdargs, "STACK:Port${port}$colour[$i]:Port ${port}";
210 $i++;
211 }
212
213 } else {
214 foreach my $port ( @topN ) {
215 push @rrdargs, "LINE1:Port${port}$colour[$i]:Port ${port}";
216 $i++;
217 }
218 }
219
220 if ( scalar @track_list) {
221 push @rrdargs, "COMMENT:\\n";
222 push @rrdargs, "COMMENT:\\n";
223 push @rrdargs, "COMMENT:Tracked Ports\\n";
224 }
225 if ( $stacked && scalar @track_list) {
226 if ( !$area_set ) {
227 my $port = shift @track_list;
228 push @rrdargs, "AREA:Port${port}$colour[$i]:Port ${port}";
229 $i++;
230 }
231 foreach my $port ( @track_list ) {
232 push @rrdargs, "STACK:Port${port}$colour[$i]:Port ${port}";
233 $i++;
234 }
235
236 } else {
237 foreach my $port ( @track_list ) {
238 push @rrdargs, "LINE2:Port${port}$colour[$i]:Port ${port}";
239 $i++;
240 }
241 }
242 if ( scalar @skipPorts) {
243 push @rrdargs, "COMMENT:\\n";
244 push @rrdargs, "COMMENT:\\n";
245 my $portlist = join ',', @skipPorts;
246 push @rrdargs, "COMMENT:Skipped Ports $portlist\\n";
247 }
248 my ($averages,$xsize,$ysize) = RRDs::graph( @rrdargs );
249
250 if (my $ERROR = RRDs::error) {
251 print "ERROR: $ERROR\n";
252 }
253
254 } # End of GenPortGraph
255
256
257 sub nftrack_execute {
258 my $command = shift;
259
260 syslog('debug', $command);
261
262 my $ret = system($command);
263 if ( $ret == - 1 ) {
264 syslog('err', "Failed to execute nftrack: $!\n");
265 } elsif ($ret & 127) {
266 syslog('err', "nftrack died with signal %d, %s coredump\n", ($ret & 127), ($ret & 128) ? 'with' : 'without');
267 } else {
268 syslog('debug', "nftrack exited with value %d\n", $ret >> 8);
269 }
270
271 } # End of nftrack_execute
272
273 #
274 # Periodic function
275 # input: hash reference including the items:
276 # 'profile' profile name
277 # 'profilegroup' profile group
278 # 'timeslot' time of slot to process: Format yyyymmddHHMM e.g. 200503031200
279 sub run {
280 my $argref = shift;
281
282 my $profile = $$argref{'profile'};
283 my $profilegroup = $$argref{'profilegroup'};
284 my $timeslot = $$argref{'timeslot'};
285
286 syslog('debug', "PortTracker run: Profile: $profile, Time: $timeslot");
287
288 my %profileinfo = NfProfile::ReadProfile($profile);
289 my $netflow_sources = "$PROFILEDATADIR/$profile/$profileinfo{'sourcelist'}";
290
291 #
292 # process all sources of this profile at once
293 my $command = "$nftrack -L $NfConf::syslog_facility -M $netflow_sources -r nfcapd.$timeslot -d $PORTSDBDIR -A -t $timeslot -s -p -w $PORTSDBDIR/portstat.txt";
294 nftrack_execute($command);
295
296 $command = "$nftrack -d $PORTSDBDIR -S -p -w $PORTSDBDIR/portstat24.txt";
297 nftrack_execute($command);
298
299 #
300 # Process the output and notify the duty team
301
302 syslog('debug', "PortTracker run: Done.");
303
304 } # End of run
305
306 sub Init {
307 syslog("info", "PortTracker: Init");
308
309 # Init some vars
310 $nftrack = "$NfConf::PREFIX/nftrack";
311 $PROFILEDATADIR = "$NfConf::PROFILEDATADIR";
312
313 return 1;
314 }
315
316 sub Cleanup {
317 syslog("info", "PortTracker Cleanup");
318 # not used here
319 }
320
321 1;
0 /*
1 * nfreplay : Reads netflow data from files saved by nfcapd
2 * and sends them to another host.
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: haag $
32 *
33 * $Id: nftrack.c 8 2009-05-07 08:13:13Z haag $
34 *
35 * $LastChangedRevision: 8 $
36 *
37 */
38
39 #include <stdio.h>
40 #include <unistd.h>
41 #include <stdlib.h>
42 #include <stdarg.h>
43 #include <errno.h>
44 #include <time.h>
45 #include <string.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <fcntl.h>
49 #include <netinet/in.h>
50 #include <arpa/inet.h>
51 #include <syslog.h>
52
53 #include "config.h"
54
55 #ifdef HAVE_STDINT_H
56 #include <stdint.h>
57 #endif
58
59
60 #include "version.h"
61 #include "nf_common.h"
62 #include "nffile.h"
63 #include "flist.h"
64 #include "rbtree.h"
65 #include "nftree.h"
66 #include "nfdump.h"
67 #include "nfx.h"
68 #include "util.h"
69 #include "grammar.h"
70
71 #include "nftrack_stat.h"
72 #include "nftrack_rrd.h"
73
74 // We have 288 slot ( 1 day ) for stat record
75 #define AVG_STAT 1
76
77 /* Externals */
78 extern int yydebug;
79
80 /* Global Variables */
81 FilterEngine_data_t *Engine;
82 int byte_mode, packet_mode;
83 uint32_t byte_limit, packet_limit; // needed for linking purpose only
84
85 extension_map_list_t extension_map_list;
86
87 /* Function Prototypes */
88 static void usage(char *name);
89
90 static data_row *process(char *filter);
91
92 /* Functions */
93
94 #include "nffile_inline.c"
95
96 static void usage(char *name) {
97 printf("usage %s [options] [\"filter\"]\n"
98 "-h\t\tthis text you see right here\n"
99 "-l\t\tLast update of Ports DB\n"
100 "-V\t\tPrint version and exit.\n"
101 "-I\t\tInitialize Ports DB files.\n"
102 "-d <db_dir>\tPorts DB directory.\n"
103 "-r <input>\tread from file. default: stdin\n"
104 "-p\t\tOnline output mode.\n"
105 "-s\t\tCreate port statistics for timeslot -t\n"
106 "-t <time>\tTimeslot for statistics\n"
107 "-S\t\tCreate port statistics for last day\n"
108 "-w <file>\twrite output to file\n"
109 "-f <filter>\tfilter syntaxfile\n"
110 , name);
111 } /* usage */
112
113 static data_row *process(char *filter) {
114 data_block_header_t block_header;
115 master_record_t master_record;
116 common_record_t *flow_record, *in_buff;
117 int i, rfd, done, ret;
118 uint32_t buffer_size;
119 data_row * port_table;
120 char *string;
121 uint64_t total_bytes;
122
123 rfd = GetNextFile(0, 0, 0, NULL);
124 if ( rfd < 0 ) {
125 if ( errno )
126 perror("Can't open file for reading");
127 return NULL;
128 }
129
130 // prepare read and send buffer
131 buffer_size = BUFFSIZE;
132 in_buff = (common_record_t *) malloc(buffer_size);
133 if ( !in_buff ) {
134 perror("Memory allocation error");
135 close(rfd);
136 return NULL;
137 }
138
139 port_table = (data_row *)calloc(65536, sizeof(data_row));
140 if ( !port_table) {
141 perror("Memory allocation error");
142 close(rfd);
143 return NULL;
144 }
145
146 memset((void *)port_table, 0, 65536 * sizeof(data_row));
147
148 // setup Filter Engine to point to master_record, as any record read from file
149 // is expanded into this record
150 Engine->nfrecord = (uint64_t *)&master_record;
151
152 done = 0;
153 while ( !done ) {
154
155 // get next data block from file
156 ret = ReadBlock(rfd, &block_header, (void *)in_buff, &string);
157
158 switch (ret) {
159 case NF_CORRUPT:
160 case NF_ERROR:
161 if ( ret == NF_CORRUPT )
162 fprintf(stderr, "Skip corrupt data file '%s': '%s'\n",GetCurrentFilename(), string);
163 else
164 fprintf(stderr, "Read error in file '%s': %s\n",GetCurrentFilename(), strerror(errno) );
165 // fall through - get next file in chain
166 case NF_EOF:
167 rfd = GetNextFile(rfd, 0, 0, NULL);
168 if ( rfd < 0 ) {
169 if ( rfd == NF_ERROR )
170 fprintf(stderr, "Read error in file '%s': %s\n",GetCurrentFilename(), strerror(errno) );
171
172 // rfd == EMPTY_LIST
173 done = 1;
174 } // else continue with next file
175 continue;
176
177 break; // not really needed
178 default:
179 // successfully read block
180 total_bytes += ret;
181 }
182
183 if ( block_header.id != DATA_BLOCK_TYPE_2 ) {
184 fprintf(stderr, "Can't process block type %u\n", block_header.id);
185 continue;
186 }
187
188 flow_record = in_buff;
189
190 for ( i=0; i < block_header.NumRecords; i++ ) {
191 char string[1024];
192 int ret;
193
194 if ( flow_record->type == CommonRecordType ) {
195 if ( extension_map_list.slot[flow_record->ext_map] == NULL ) {
196 snprintf(string, 1024, "Corrupt data file! No such extension map id: %u. Skip record", flow_record->ext_map );
197 string[1023] = '\0';
198 } else {
199 ExpandRecord_v2( flow_record, extension_map_list.slot[flow_record->ext_map], &master_record);
200
201 ret = (*Engine->FilterEngine)(Engine);
202
203 if ( ret == 0 ) { // record failed to pass the filter
204 // increment pointer by number of bytes for netflow record
205 flow_record = (common_record_t *)((pointer_addr_t)flow_record + flow_record->size);
206 // go to next record
207 continue;
208 }
209
210
211 // Add to stat record
212 if ( master_record.prot == 6 ) {
213 port_table[master_record.dstport].proto[tcp].type[flows]++;
214 port_table[master_record.dstport].proto[tcp].type[packets] += master_record.dPkts;
215 port_table[master_record.dstport].proto[tcp].type[bytes] += master_record.dOctets;
216 } else if ( master_record.prot == 17 ) {
217 port_table[master_record.dstport].proto[udp].type[flows]++;
218 port_table[master_record.dstport].proto[udp].type[packets] += master_record.dPkts;
219 port_table[master_record.dstport].proto[udp].type[bytes] += master_record.dOctets;
220 }
221 }
222
223 } else if ( flow_record->type == ExtensionMapType ) {
224 extension_map_t *map = (extension_map_t *)flow_record;
225
226 if ( Insert_Extension_Map(&extension_map_list, map) ) {
227 // flush new map
228 } // else map already known and flushed
229
230 } else {
231 fprintf(stderr, "Skip unknown record type %i\n", flow_record->type);
232 }
233
234 // Advance pointer by number of bytes for netflow record
235 flow_record = (common_record_t *)((pointer_addr_t)flow_record + flow_record->size);
236 }
237 } // while
238
239 return port_table;
240
241 } // End of process
242
243
244 int main( int argc, char **argv ) {
245 struct stat stat_buff;
246 char c, *wfile, *rfile, *Rfile, *Mdirs, *ffile, *filter, *timeslot, *DBdir;
247 char datestr[64];
248 int ffd, ret, DBinit, AddDB, GenStat, AvStat, output_mode;
249 unsigned int lastupdate, topN;
250 data_row *port_table;
251 time_t when;
252 struct tm * t1;
253
254 wfile = rfile = Rfile = Mdirs = ffile = filter = DBdir = timeslot = NULL;
255 DBinit = AddDB = GenStat = AvStat = 0;
256 lastupdate = output_mode = 0;
257 topN = 10;
258 while ((c = getopt(argc, argv, "d:hln:pr:st:w:AIM:L:R:SV")) != EOF) {
259 switch (c) {
260 case 'h':
261 usage(argv[0]);
262 exit(0);
263 break;
264 case 'I':
265 DBinit = 1;
266 break;
267 case 'M':
268 Mdirs = strdup(optarg);
269 break;
270 case 'R':
271 Rfile = strdup(optarg);
272 break;
273 case 'd':
274 DBdir = strdup(optarg);
275 ret = stat(DBdir, &stat_buff);
276 if ( !(stat_buff.st_mode & S_IFDIR) ) {
277 fprintf(stderr, "No such directory: %s\n", DBdir);
278 exit(255);
279 }
280 break;
281 case 'l':
282 lastupdate = 1;
283 break;
284 case 'n':
285 topN = atoi(optarg);
286 if ( topN < 0 ) {
287 fprintf(stderr, "TopnN number %i out of range\n", topN);
288 exit(255);
289 }
290 break;
291 case 'p':
292 output_mode = 1;
293 break;
294 case 'r':
295 rfile = strdup(optarg);
296 break;
297 case 'w':
298 wfile = strdup(optarg);
299 break;
300 case 's':
301 GenStat = 1;
302 break;
303 case 't':
304 timeslot = optarg;
305 if ( !ISO2UNIX(timeslot) ) {
306 exit(255);
307 }
308 break;
309 case 'A':
310 AddDB = 1;
311 break;
312 case 'L':
313 if ( !InitLog("nftrack", optarg) )
314 exit(255);
315 break;
316 case 'S':
317 AvStat = 1;
318 break;
319 default:
320 usage(argv[0]);
321 exit(0);
322 }
323 }
324
325 if (argc - optind > 1) {
326 usage(argv[0]);
327 exit(255);
328 } else {
329 /* user specified a pcap filter */
330 filter = argv[optind];
331 }
332
333 if ( !filter && ffile ) {
334 if ( stat(ffile, &stat_buff) ) {
335 perror("Can't stat file");
336 exit(255);
337 }
338 filter = (char *)malloc(stat_buff.st_size);
339 if ( !filter ) {
340 perror("Memory error");
341 exit(255);
342 }
343 ffd = open(ffile, O_RDONLY);
344 if ( ffd < 0 ) {
345 perror("Can't open file");
346 exit(255);
347 }
348 ret = read(ffd, (void *)filter, stat_buff.st_size);
349 if ( ret < 0 ) {
350 perror("Error reading file");
351 close(ffd);
352 exit(255);
353 }
354 close(ffd);
355 }
356
357 if ( !DBdir ) {
358 fprintf(stderr, "DB directory required\n");
359 exit(255);
360 }
361
362 InitStat(DBdir);
363
364 if ( !filter )
365 filter = "any";
366
367 Engine = CompileFilter(filter);
368 if ( !Engine )
369 exit(254);
370
371 if ( DBinit ) {
372 when = time(NULL);
373 when -= ((when % 300) + 300);
374 InitStatFile();
375 if ( !CreateRRDBs(DBdir, when) ) {
376 fprintf(stderr, "Init DBs failed\n");
377 exit(255);
378 }
379 fprintf(stderr, "Port DBs initialized.\n");
380 exit(0);
381 }
382
383 if ( lastupdate ) {
384 when = RRD_LastUpdate(DBdir);
385 if ( !when )
386 exit(255);
387 t1 = localtime(&when);
388 strftime(datestr, 63, "%b %d %Y %T", t1);
389 printf("Last Update: %i, %s\n", (int)when, datestr);
390 exit(0);
391 }
392
393 port_table = NULL;
394 if ( Mdirs || Rfile || rfile ) {
395 SetupInputFileSequence(Mdirs, rfile, Rfile);
396 port_table = process(filter);
397 // Lister(port_table);
398 if ( !port_table ) {
399 exit(255);
400 }
401 if ( AddDB ) {
402 if ( !timeslot ) {
403 fprintf(stderr, "Timeslot required!\n");
404 exit(255);
405 }
406 UpdateStat(port_table, ISO2UNIX(timeslot));
407 RRD_StoreDataRow(DBdir, timeslot, port_table);
408 }
409 }
410
411 if ( AvStat ) {
412 port_table = GetStat();
413 if ( !port_table ) {
414 fprintf(stderr, "Unable to get port table!\n");
415 exit(255);
416 }
417 // DoStat
418 Generate_TopN(port_table, topN, AVG_STAT, 0, output_mode, wfile);
419
420 }
421
422
423 if ( GenStat ) {
424 when = ISO2UNIX(timeslot);
425 if ( !port_table ) {
426 if ( !timeslot ) {
427 fprintf(stderr, "Timeslot required!\n");
428 exit(255);
429 }
430 port_table = RRD_GetDataRow(DBdir, when);
431 }
432 if ( !port_table ) {
433 fprintf(stderr, "Unable to get port table!\n");
434 exit(255);
435 }
436 // DoStat
437 Generate_TopN(port_table, topN, 0, when, output_mode, wfile);
438 }
439
440 CloseStat();
441
442 return 0;
443 }
0 #include <stdio.h>
1 #include <stdlib.h>
2 #include <limits.h>
3 #include <time.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <string.h>
9 #include <errno.h>
10
11 #include "config.h"
12
13 #ifdef HAVE_STDINT_H
14 #include <stdint.h>
15 #endif
16
17 #include "rrd.h"
18 #include "nftrack_stat.h"
19 #include "nftrack_rrd.h"
20
21 #define BUFF_CHECK(num,buffsize) if ( (num) >= (buffsize) ) { \
22 fprintf(stderr, "No enough space to create RRD arg\n"); \
23 exit(0); \
24 }
25
26 // temporary RRD file
27 #define TMPRRD "ports.rrd"
28
29 #define MAXBUFF 15 * 1024;
30
31 /* global const */
32 static const char *proto[] = { "tcp", "udp" };
33 static const char *type[] = { "flows", "packets", "bytes" };
34
35 /* Local prototypes */
36
37 static void CreateRRDB (char *filename, time_t when);
38
39 /* Functions */
40
41 static void CreateRRDB (char *filename, time_t when) {
42 char *buff, *s, *rrd_arg[1100];
43 long i, num, buffsize, argc;
44
45 optind = 0; opterr = 0;
46 argc = 0;
47 /*
48 Create bufferspace for create args:
49 1024 DS records: each ~ 23 bytes in average +
50 3 RRA records + filename + start time => 512 bytes should be more than enough
51 */
52 buffsize = 23 * 1024 + 512;
53 buff = (char *)malloc(buffsize);
54 if ( !buff ) {
55 perror("Memory error!");
56 exit(0);
57 }
58
59 s = buff;
60
61 unlink(filename);
62
63 rrd_arg[argc++] = "create";
64
65 // add DB name
66 rrd_arg[argc++] = filename;
67
68 // Add start time
69 num = snprintf(s, buffsize, "--start=%lld", (long long)when);
70 num++; // include '\0'
71 BUFF_CHECK(num,buffsize);
72 rrd_arg[argc++] = s;
73
74 buffsize -= num;
75 s += num;
76
77 /* Add the DS strings */
78 for ( i=0; i<1024; i++) {
79 num = snprintf(s, buffsize, "DS:p%ld:GAUGE:600:0:U", i);
80 num++; // include '\0'
81 // printf("I: %ld ", i);
82 BUFF_CHECK(num,buffsize);
83 rrd_arg[argc++] = s;
84
85 buffsize -= num;
86 s += num;
87 }
88
89 /*
90 RRD DB layout:
91 1 x 5min = 5 min samples 7 * 288 ( per day ) = 2016 => 7 days
92 24 x 5min = 2 hour samples 60 * 12 ( per day ) = 720 => 60 days
93 288 x 5min = 1 day samples 180 * 1 ( per day ) = 180 => 180 days
94 */
95
96 num = snprintf(s, buffsize, "RRA:AVERAGE:0.5:1:2016");
97 num++; // include '\0'
98 BUFF_CHECK(num,buffsize);
99 rrd_arg[argc++] = s;
100
101 buffsize -= num;
102 s += num;
103
104 num = snprintf(s, buffsize, "RRA:AVERAGE:0.5:24:720");
105 num++; // include '\0'
106 BUFF_CHECK(num,buffsize);
107 rrd_arg[argc++] = s;
108
109 buffsize -= num;
110 s += num;
111
112 num = snprintf(s, buffsize, "RRA:AVERAGE:0.5:288:180");
113 num++; // include '\0'
114 BUFF_CHECK(num,buffsize);
115 rrd_arg[argc] = s;
116
117 /*
118 for ( i=0; i<=argc; i++ ) {
119 printf("I:%ld %s\n", i, rrd_arg[i]);
120 }
121 */
122
123 rrd_clear_error();
124 if ( ( i=rrd_create(argc, rrd_arg))) {
125 fprintf(stderr, "Create DB Error: %ld %s\n", i, rrd_get_error());
126 }
127
128 } // End of CreateRRDB
129
130 int CreateRRDBs (char *path, time_t when) {
131 const char progress[] = { '|', '/', '-', '|', '\\', '-' };
132 char rrd_filename[1024];
133 int fd, i, p, t, len, total;
134 struct stat statbuf;
135 void *buff;
136
137 // Check if path exists
138 if ( (stat(path, &statbuf) < 0 ) || !(statbuf.st_mode & S_IFDIR) ) {
139 fprintf(stderr, "No such directory: '%s'\n", path);
140 return 0;
141 }
142
143 // make stdout unbuffered for progress pointer
144 setvbuf(stdout, (char *)NULL, _IONBF, 0);
145
146 printf("Create DBs ... ");
147
148 /*
149 * we create an RRD DB file and will copy this file
150 * that many time as required - so every RRD file looks the
151 * same. They only distinguish by their name
152 */
153 len = snprintf(rrd_filename, 1024, "%s/%s", path, TMPRRD);
154 if ( len >= 1024 ) {
155 fprintf(stderr, "Failed to concat RRD filename: string overflow");
156 return 0;
157 }
158
159 CreateRRDB(rrd_filename, when);
160 if ( (i = stat(rrd_filename, &statbuf) < 0 )) {
161 fprintf(stderr, "Can't create RRD file '%s': %s\n", rrd_filename, strerror(errno));
162 return 0;
163 }
164 buff = malloc(statbuf.st_size);
165 if ( !buff ) {
166 perror("Buffer allocation failed");
167 unlink(rrd_filename);
168 return 0;
169 }
170 fd = open(rrd_filename, O_RDONLY, 0);
171 if ( fd < 0 ) {
172 perror("Failed to open RRD file");
173 unlink(rrd_filename);
174 return 0;
175 }
176 if ( read(fd, buff, statbuf.st_size) != statbuf.st_size ) {
177 perror("Failed to read data from RRD file");
178 close(fd);
179 unlink(rrd_filename);
180 return 0;
181 }
182 close(fd);
183 unlink(rrd_filename);
184 printf("\n");
185
186 // we are now ready to multiplicate the DB files
187 total = 384; // 2 * 3 * 64 files total
188 for (p=tcp; p<=udp; p++) { // for TCP and UDP
189 for (t=flows; t<=bytes; t++) { // for flows, packets and bytes
190 for (i=0; i<64; i++) { // Create 64 times an RRD DB - each for 1024 ports
191 printf("Creating %s:%s %c Left: %d files \r", proto[p], type[t], progress[i % 6], total );
192 len = snprintf(rrd_filename, 1024, "%s/%s-%s-%d.rrd", path, proto[p], type[t], i);
193 if ( len >= 1024 ) {
194 fprintf(stderr, "Failed to concat RRD filename: string overflow");
195 free(buff);
196 return 0;
197 }
198 fd = open(rrd_filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
199 if ( fd < 0 ) {
200 fprintf(stderr, "Failed to create RRD file '%s': %s\n", rrd_filename, strerror(errno));
201 free(buff);
202 return 0;
203 }
204 if ( write(fd, buff, statbuf.st_size) != statbuf.st_size ) {
205 fprintf(stderr, "Failed to write RRD file '%s': %s\n", rrd_filename, strerror(errno));
206 free(buff);
207 return 0;
208 }
209 close(fd);
210 total--;
211 }
212 }
213 }
214
215 printf("\n");
216 return 1;
217
218 } // End of CreateRRDBs
219
220 int RRD_StoreDataRow(char *path, char *iso_time, data_row *row) {
221 char rrd_filename[1024], *buff, *s;
222 char *rrd_arg[10];
223 time_t when, frag;
224 int i, j, len, p, t, buffsize, argc;
225 uint32_t pnum;
226 struct stat statbuf;
227
228 buffsize = MAXBUFF;
229 buff = (char *)malloc(buffsize);
230 if ( !buff ) {
231 perror("Memory error!");
232 return 0;
233 }
234
235 when = ISO2UNIX(iso_time);
236 if ( !when )
237 return 0;
238
239 // make sure, we are at a 5min boundary
240 frag = when % 300;
241 if ( frag ) {
242 fprintf(stderr, "Round to next timeslot: offset %lld\n", (long long)frag);
243 when -= frag;
244 }
245
246 for ( p=tcp; p<=udp; p++ ) {
247 // for every protocol TCP - UDP
248 for ( t=flows; t<=bytes; t++ ) {
249 // for every type flows - packets - bytes
250 for (j=0; j<64; j++) {
251 // for all 64 RRD files in proto - type
252 len = snprintf(rrd_filename, 1024, "%s/%s-%s-%d.rrd", path, proto[p], type[t], j);
253 if ( len >= 1024 ) {
254 fprintf(stderr, "Failed to concat RRD filename: string overflow");
255 return 0;
256 }
257
258 // Check if RRD file exists
259 if ( (stat(rrd_filename, &statbuf) < 0 ) || !(statbuf.st_mode & S_IFREG) ) {
260 fprintf(stderr, "No such RRD file: '%s'\n", rrd_filename);
261 return 0;
262 }
263
264 buffsize = MAXBUFF;
265 s = buff;
266
267 /* add time to RRD arg string */
268 len = snprintf(s, buffsize, "%lld:", (long long)when);
269 buffsize -= len;
270 s += len;
271
272 /* add port data to RRD arg string */
273 for ( i=0; i<1024; i++) {
274 pnum = ( j << 10 ) + i;
275 /*
276 if ( row[pnum].proto[p].type[t] ) {
277 fprintf(stderr, "%d %d %d\n", pnum, p, t);
278 }
279 */
280 len = snprintf(s, buffsize, "%llu:", (long long unsigned)row[pnum].proto[p].type[t]);
281 if ( len >= buffsize ) {
282 fprintf(stderr, "No enough space to create RRD arg\n");
283 return 0;
284 }
285 buffsize -= len;
286 s += len;
287 }
288 s--;
289 *s = '\0';
290
291 // Create arg vector
292 argc = 0;
293 rrd_arg[argc++] = "update";
294 rrd_arg[argc++] = rrd_filename;
295 rrd_arg[argc++] = buff;
296 rrd_arg[argc] = NULL;
297
298 optind = 0; opterr = 0;
299 rrd_clear_error();
300 if ( ( i=rrd_update(argc, rrd_arg))) {
301 fprintf(stderr, "RRD: %s Insert Error: %d %s\n", rrd_filename, i, rrd_get_error());
302 }
303 } // for all 64 rrd files
304 } // for every type flows - packets - bytes
305 } // for every protocol TCP - UDP
306
307 return 1;
308 } // End of RRD_StoreDataRow
309
310 data_row *RRD_GetDataRow(char *path, time_t when) {
311 time_t last, frag;
312 struct tm * t1, *t2;
313 struct stat statbuf;
314 char datestr1[64] , datestr2[64], rrd_filename[1024];
315 char *rrd_arg[10];
316 char **ds_namv;
317 int ret, i, j, p, t, len, argc;
318 unsigned long step, ds_cnt, pnum;
319 data_row *row;
320 rrd_value_t *data;
321 uint64_t dummy;
322
323 data = NULL;
324 frag = when % 300;
325 if ( frag ) {
326 fprintf(stderr, "Round to next timeslot: offset %lld\n", (long long)frag);
327 when -= frag;
328 }
329
330 last = RRD_LastUpdate(path);
331 if ( when > last ) {
332 t1 = localtime(&when);
333 strftime(datestr1, 63, "%b %d %Y %T", t1);
334
335 t2 = localtime(&last);
336 strftime(datestr2, 63, "%b %d %Y %T", t2);
337
338 fprintf(stderr, "Error get data: Requested time slot '%s' later then last available time slot '%s'\n",
339 datestr1, datestr2);
340
341 return NULL;
342 }
343
344 row = (data_row *)calloc(65536, sizeof(data_row));
345 if ( !row ) {
346 perror("Memory allocation error");
347 return NULL;
348 }
349
350 len = snprintf(datestr1, 64, "--start=%lld", (long long)when);
351 if ( len >= 64 ) {
352 fprintf(stderr, "String overflow --start\n");
353 free(row);
354 return NULL;
355 }
356 len = snprintf(datestr2, 64, "--end=%lld", (long long)when);
357 if ( len >= 64 ) {
358 fprintf(stderr, "String overflow --end\n");
359 free(row);
360 return NULL;
361 }
362
363 for ( p=tcp; p<=udp; p++ ) {
364 // for every protocol TCP - UDP
365 for ( t=flows; t<=bytes; t++ ) {
366 // for every type flows - packets - bytes
367 for (j=0; j<64; j++) {
368 // for all 64 RRD files in proto - type
369 len = snprintf(rrd_filename, 1024, "%s/%s-%s-%d.rrd", path, proto[p], type[t], j);
370 if ( len >= 1024 ) {
371 fprintf(stderr, "Failed to concat RRD filename: string overflow");
372 free(row);
373 return NULL;
374 }
375
376 // Check if RRD file exists
377 if ( (stat(rrd_filename, &statbuf) < 0 ) || !(statbuf.st_mode & S_IFREG) ) {
378 fprintf(stderr, "No such RRD file: '%s'\n", rrd_filename);
379 free(row);
380 return NULL;
381 }
382
383
384 // Create arg vector
385 argc = 0;
386 rrd_arg[argc++] = "fetch";
387 rrd_arg[argc++] = rrd_filename;
388 rrd_arg[argc++] = "AVERAGE";
389 rrd_arg[argc++] = datestr1;
390 rrd_arg[argc++] = datestr2;
391 rrd_arg[argc] = NULL;
392
393 optind = 0; opterr = 0;
394 rrd_clear_error();
395 if ( ( ret=rrd_fetch(argc, rrd_arg, &when, &when, &step, &ds_cnt, &ds_namv, &data))) {
396 fprintf(stderr, "RRD: %s Fetch Error: %d %s\n", rrd_filename, ret, rrd_get_error());
397 }
398 if ( ds_cnt != 1024 ) {
399 fprintf(stderr, "RRD: %s Fetch Error: Short read: Expected 1024 records got %lu\n",
400 rrd_filename, ds_cnt);
401 free(row);
402 return NULL;
403 }
404
405 for ( i=0; i<1024; i++) {
406 pnum = ( j << 10 ) + i;
407 dummy = data[0];
408 row[pnum].proto[p].type[t] = dummy;
409 }
410
411 free(ds_namv);
412 free(data);
413
414 } // for all 64 rrd files
415 } // for every type flows - packets - bytes
416 } // for every protocol TCP - UDP
417
418 return row;
419
420 } // End of RRD_GetDataRow
421
422 time_t RRD_LastUpdate(char *path) {
423 struct stat statbuf;
424 char rrd_filename[1024];
425 char *rrd_arg[10];
426 time_t when;
427 int len, argc;
428
429 // Get timestamp from the first file
430 len = snprintf(rrd_filename, 1024, "%s/%s-%s-%d.rrd", path, "tcp", "flows", 0);
431 if ( len >= 1024 ) {
432 fprintf(stderr, "Failed to concat RRD filename: string overflow");
433 return 0;
434 }
435
436 // Check if RRD file exists
437 if ( (stat(rrd_filename, &statbuf) < 0 ) || !(statbuf.st_mode & S_IFREG) ) {
438 fprintf(stderr, "RRD files not found in '%s'\n", path);
439 return 0;
440 }
441
442 argc = 0;
443 rrd_arg[argc++] = "last";
444 rrd_arg[argc++] = rrd_filename;
445 rrd_arg[argc] = NULL;
446
447 when = rrd_last(argc, rrd_arg);
448
449 return when;
450
451 } // End of RRD_LastUpdate
452
453 /*
454 int main () {
455 char *buff, *s, *rrd_arg[10];
456 long i, num, buffsize, argc;
457 time_t now;
458
459 CreateRRDBs("/data/rrd-db");
460 exit(0);
461
462 buffsize = 15 * 1024;
463 buff = (char *)malloc(buffsize);
464 if ( !buff ) {
465 perror("Memory error!");
466 exit(0);
467 }
468
469 s = buff;
470 now = time(NULL);
471 now -= now % 300;
472
473 num = snprintf(s, buffsize, "%ld:", now);
474 // num = snprintf(s, buffsize, "N:");
475 buffsize -= num;
476 s += num;
477
478 for ( i=0; i<1024; i++) {
479 num = snprintf(s, buffsize, "%ld:", i);
480 if ( num >= buffsize ) {
481 fprintf(stderr, "No enough space to create RRD arg\n");
482 exit(0);
483 }
484 buffsize -= num;
485 s += num;
486 }
487 s--;
488 *s = '\0';
489 printf("String: %s\n", buff);
490
491 argc = 0;
492 rrd_arg[argc++] = "update";
493 rrd_arg[argc++] = "ports.rrd";
494 rrd_arg[argc++] = buff;
495 rrd_arg[argc] = NULL;
496
497 rrd_clear_error();
498 if ( ( i=rrd_update(argc, rrd_arg))) {
499 fprintf(stderr, "Insert Error: %ld %s\n", i, rrd_get_error());
500 }
501
502 return 0;
503 }
504
505 */
0
1 int CreateRRDBs (char *path, time_t when);
2
3 int RRD_StoreDataRow(char *path, char *iso_time, data_row *row);
4
5 data_row *RRD_GetDataRow(char *path, time_t when);
6
7 time_t RRD_LastUpdate(char *path);
8
9 time_t RRD_First(char *path);
10
11 time_t ISO2UNIX(char *tstring);
0 #include <stdio.h>
1 #include <stdlib.h>
2 #include <errno.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <sys/param.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <string.h>
9 #include <time.h>
10
11 #include "config.h"
12
13 #ifdef HAVE_STDINT_H
14 #include <stdint.h>
15 #endif
16
17 #include "util.h"
18
19 #include "nftrack_stat.h"
20 #include "nftrack_rrd.h"
21
22 #define STATFILE "ports.stat"
23
24 #define NUMPORTS 65536
25
26 // 288 slots per day
27 #define MAX_SLOTS 288
28
29 typedef struct stat_header_s {
30 uint16_t version;
31 int av_num;
32 time_t last;
33 } stat_header_t;
34
35 typedef struct topN_vector_s {
36 uint16_t port;
37 uint64_t count;
38 } topN_vector_t;
39
40 static stat_header_t stat_header;
41 static data_row *stat_record;
42 static char statfile[MAXPATHLEN];
43 static char dbpath[MAXPATHLEN];
44 static int dirty;
45
46 /* prototypes */
47 static void ReadStat(void);
48 static void heapSort(topN_vector_t *vector, int array_size, int topN);
49 static void siftDown(topN_vector_t *vector, int root, int bottom);
50
51 int InitStat(char *path) {
52 int len;
53 stat_header.version = 0;
54 stat_record = NULL;
55
56 len = snprintf(statfile, MAXPATHLEN, "%s/%s", path, STATFILE);
57 if ( len >= MAXPATHLEN ) {
58 LogError("String overflow: statfile name\n");
59 statfile[0] = 0;
60 return 0;
61 }
62 len = snprintf(dbpath, MAXPATHLEN, "%s", path);
63 dirty = 0;
64
65 return 1;
66
67 } // End of InitStat
68
69 int InitStatFile(void) {
70 ssize_t num;
71 int fd;
72
73 if ( statfile[0] == 0 )
74 return 0;
75
76 stat_record = (data_row *)calloc(NUMPORTS, sizeof(data_row));
77 if ( !stat_record ) {
78 LogError("calloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
79 return 0;
80 }
81
82 fd = open(statfile, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
83 if ( fd < 0 ) {
84 LogError("open() error for %s in %s line %d: %s\n", statfile, __FILE__, __LINE__, strerror(errno) );
85 free(stat_record);
86 stat_record = NULL;
87 return 0;
88 }
89
90 stat_header.version = 1;
91 stat_header.av_num = 0;
92 stat_header.last = 0;
93
94 num = write(fd, &stat_header, sizeof(stat_header));
95 num = write(fd, stat_record, NUMPORTS * sizeof(data_row));
96 if ( num < 0 ) {
97 LogError("write() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
98 stat_header.version = 0;
99 free(stat_record);
100 stat_record = NULL;
101 close(fd);
102 return 0;
103 }
104
105 close(fd);
106
107 return 1;
108
109 } // End of InitStatFile
110
111 data_row *GetStat(void) {
112
113 if ( !stat_record )
114 ReadStat();
115
116 return stat_record;
117
118 } // End of GetStat
119
120 int CloseStat(void) {
121 int fd;
122 ssize_t num;
123
124 if ( statfile[0] == 0 || !dirty )
125 return 1;
126
127 fd = open(statfile, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
128 if ( fd < 0 ) {
129 LogError("open() error for %s in %s line %d: %s\n", statfile, __FILE__, __LINE__, strerror(errno) );
130 return 0;
131 }
132
133 num = write(fd, (void *)&stat_header, sizeof(stat_header));
134 if ( num < 0 ) {
135 LogError("write() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
136 close(fd);
137 return 0;
138 }
139
140 num = write(fd, stat_record, NUMPORTS * sizeof(data_row));
141 if ( num < 0 ) {
142 LogError("write() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
143 return 0;
144 }
145
146 free(stat_record);
147 stat_record = NULL;
148 stat_header.version = 0;
149 close(fd);
150
151 return 1;
152
153 } // End of CloseStat
154
155 static void ReadStat(void) {
156 int fd;
157 ssize_t num;
158
159 if ( statfile[0] == 0 )
160 return;
161
162 stat_record = (data_row *)calloc(NUMPORTS, sizeof(data_row));
163 if ( !stat_record ) {
164 LogError("calloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
165 return;
166 }
167
168 fd = open(statfile, O_RDONLY );
169 if ( fd < 0 ) {
170 // allow to delete the stat file to restart stat from scratch
171 if ( errno == ENOENT ) {
172 LogError("Missing stat file - re-initialise\n");
173 if ( InitStatFile() ) {
174 fd = open(statfile, O_RDONLY );
175 if ( fd < 0 ) {
176 LogError("open() error for %s in %s line %d: %s\n", statfile, __FILE__, __LINE__, strerror(errno) );
177 free(stat_record);
178 stat_record = NULL;
179 return;
180 }
181 }
182 } else {
183 LogError("open() error for %s in %s line %d: %s\n", statfile, __FILE__, __LINE__, strerror(errno) );
184 free(stat_record);
185 stat_record = NULL;
186 return;
187 }
188 }
189
190 num = read(fd, (void *)&stat_header, sizeof(stat_header));
191 if ( num < 0 ) {
192 LogError("read() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
193 free(stat_record);
194 stat_record = NULL;
195 close(fd);
196 return;
197 }
198
199 if ( stat_header.version != 1 ) {
200 LogError("Version error stat file. Found version: %d expected: 1\n", stat_header.version);
201 free(stat_record);
202 stat_record = NULL;
203 stat_header.version = 0;
204 close(fd);
205 return;
206 }
207
208 num = read(fd, stat_record, NUMPORTS * sizeof(data_row));
209 if ( num < 0 ) {
210 LogError("read() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) );
211 free(stat_record);
212 stat_record = NULL;
213 stat_header.version = 0;
214 close(fd);
215 }
216
217 } // End of ReadStat
218
219 void ClearStat(void) {
220 memset((void *)stat_record, 0, NUMPORTS * sizeof(data_row));
221 stat_header.av_num = 0;
222 stat_header.last = 0;
223 } // End of ClearStat
224
225 int UpdateStat(data_row *row, time_t when) {
226 int pnum, p, t;
227 time_t last_rrd, first_stat;
228
229 if ( !stat_record ) {
230 ReadStat();
231 if ( !stat_record )
232 return 0;
233 }
234
235 if ( stat_header.av_num > MAX_SLOTS ) {
236 LogError("Too many slots aggregated: %i. Expected max. %i", stat_header.av_num, MAX_SLOTS);
237 LogError("Stat: Num : %i", stat_header.av_num);
238 LogError("Stat: last: %s", ctime(&stat_header.last));
239 // should not happend - anyway consider stat record to be corrupt - > clear
240 ClearStat();
241 }
242
243 last_rrd = RRD_LastUpdate(dbpath);
244 if ( stat_header.last && (last_rrd != stat_header.last) ) {
245 LogError("RRD and stat record out of sync. %i != %i", last_rrd, stat_header.last);
246 LogError("Stat: Num : %i", stat_header.av_num);
247 LogError("Stat: last: %s", ctime(&stat_header.last));
248 LogError("RRD : last: %s", ctime(&last_rrd));
249 // should not happend - anyway consider stat record to be corrupt - > clear
250 ClearStat();
251 }
252
253 if ( stat_header.last && ((when - (300*MAX_SLOTS)) > stat_header.last) ) {
254 LogError("Last stat update too far in the past -> clear stat record");
255 LogError("Stat: Num : %i", stat_header.av_num);
256 LogError("Stat: last: %s", ctime(&stat_header.last));
257 // last update too far in the past -> clear stat record
258 ClearStat();
259 }
260 if ( stat_header.last && (when - stat_header.last) > 1800 ) {
261 LogError("Last stat update too far in the past -> clear stat record");
262 LogError("Stat: Num : %i", stat_header.av_num);
263 LogError("Stat: last: %s", ctime(&stat_header.last));
264 // last update too far in the past -> clear stat record
265 ClearStat();
266 }
267
268 if ( stat_header.av_num ) {
269 first_stat = stat_header.last - (stat_header.av_num-1)*300;
270 } else {
271 first_stat = 0;
272 }
273
274 if ( stat_header.av_num == MAX_SLOTS ) {
275 time_t tslot;
276 data_row *oldrow;
277 for ( tslot = first_stat; tslot < when - ((MAX_SLOTS-1)*300); tslot += 300 ) {
278 oldrow = RRD_GetDataRow(dbpath, tslot);
279 if ( !oldrow ) {
280 LogError("Failed to fetch RRD datarow");
281 break;
282 }
283 LogInfo("Remove stat line %s\n", ctime(&tslot));
284 for(pnum=0; pnum<NUMPORTS; pnum++ ) {
285 for (p=0; p<2; p++) {
286 for (t=0; t<3; t++) {
287 stat_record[pnum].proto[p].type[t] -= oldrow[pnum].proto[p].type[t];
288 }
289 }
290 }
291 stat_header.av_num--;
292 }
293
294 }
295
296 // Add new slot
297 for(pnum=0; pnum<NUMPORTS; pnum++ ) {
298 for (p=0; p<2; p++) {
299 for (t=0; t<3; t++) {
300 stat_record[pnum].proto[p].type[t] += row[pnum].proto[p].type[t];
301 }
302 }
303 }
304 stat_header.av_num++;
305 stat_header.last = when;
306 dirty = 1;
307
308 LogInfo("UpdateStat: Num : %i\n", stat_header.av_num);
309 LogInfo("UpdateStat: last: %s\n", ctime(&stat_header.last));
310
311 return 1;
312
313 } // End of UpdateStat
314
315 void Generate_TopN(data_row *row, int n, int scale, time_t when, int output_mode, char *wfile) {
316 int i, p, t, pnum;
317 FILE *wfd;
318 topN_vector_t *topN_vector;
319 static const char *proto[] = { "TCP", "UDP" };
320 static const char *type[] = { "Flows", "Packets", "Bytes" };
321
322 if ( wfile ) {
323 wfd = strcmp(wfile, "-") == 0 ? stdout :
324 fopen(wfile, "w");
325 if ( wfd == NULL ) {
326 perror("Can't open output file for writing");
327 return;
328 }
329 } else
330 wfd = stdout;
331
332 topN_vector = (topN_vector_t *)malloc((NUMPORTS+1) * sizeof(struct topN_vector_s));
333 if ( !topN_vector ) {
334 perror("Memory error");
335 exit(255);
336 }
337
338 // Add new slot
339 if ( when == 0 )
340 when = stat_header.last;
341 if ( output_mode != 0 )
342 fprintf(wfd, "%i\n", (int)when);
343 for (p=0; p<2; p++) {
344 for (t=0; t<3; t++) {
345 for(pnum=0; pnum<NUMPORTS; pnum++ ) {
346 topN_vector[pnum].port = pnum;
347 topN_vector[pnum].count = row[pnum].proto[p].type[t];
348 if ( scale && stat_header.av_num ) {
349 topN_vector[pnum].count /= stat_header.av_num;
350 }
351 }
352 heapSort(topN_vector, NUMPORTS, n);
353 if ( output_mode == 0 ) {
354 fprintf(wfd, "Top %i %s Proto %s\n", n, type[t], proto[p]);
355 for (i = NUMPORTS-1; i > ( NUMPORTS-n-1 ); i--)
356 fprintf(wfd, "%u %llu\n", topN_vector[i].port, (long long unsigned)topN_vector[i].count);
357 fprintf(wfd, "\n");
358 } else {
359 fprintf(wfd, "%i %i %i\n", n, t, p);
360 for (i = NUMPORTS-1; i > ( NUMPORTS-n-1 ); i--)
361 fprintf(wfd, "%u ", topN_vector[i].port);
362 fprintf(wfd, "\n");
363 for (i = NUMPORTS-1; i > ( NUMPORTS-n-1 ); i--)
364 fprintf(wfd, "%llu ", (long long unsigned)topN_vector[i].count);
365 fprintf(wfd, "\n");
366 }
367 }
368 }
369
370 if ( wfile )
371 fclose(wfd);
372
373 } // End of TopN
374
375 static void heapSort(topN_vector_t *vector, int array_size, int topN) {
376 topN_vector_t temp;
377 int32_t i, top_count;
378
379 for (i = (array_size / 2)-1; i >= 0; i--)
380 siftDown(vector, i, array_size);
381
382 top_count = 1;
383
384 for (i = array_size-1; i >= 1; i--) {
385 temp = vector[0];
386 vector[0] = vector[i];
387 vector[i] = temp;
388 siftDown(vector, 0, i-1);
389 if ( top_count == topN )
390 return;
391 top_count++;
392 }
393
394 } // End of heapSort
395
396
397 static void siftDown(topN_vector_t *vector, int root, int bottom) {
398 uint32_t done, maxChild;
399 topN_vector_t temp;
400
401 done = 0;
402 while ((root*2 <= bottom) && (!done)) {
403 if (root*2 == bottom)
404 maxChild = root * 2;
405 else if (vector[root * 2].count > vector[root * 2 + 1].count)
406 maxChild = root * 2;
407 else
408 maxChild = root * 2 + 1;
409
410 if (vector[root].count < vector[maxChild].count ) {
411 temp = vector[root];
412 vector[root] = vector[maxChild];
413 vector[maxChild] = temp;
414 root = maxChild;
415 } else
416 done = 1;
417 }
418 } // End of siftDown
419
420 int Lister(data_row *row) {
421 int pnum, p, t;
422
423 if ( !row ) {
424 LogError("Lister: Empty row!\n");
425 return 0;
426 }
427 for(pnum=0; pnum<NUMPORTS; pnum++ ) {
428 for (p=0; p<2; p++) {
429 for (t=0; t<3; t++) {
430 if ( row[pnum].proto[p].type[t] ) {
431 LogError("%d %d %d: %llu\n", pnum, p, t, (long long unsigned)row[pnum].proto[p].type[t]);
432 }
433 }
434 }
435 }
436 return 1;
437 } // List
438
439
0
1
2 typedef struct data_element_s {
3 uint64_t type[3]; // 0 - flows 1 - packets 2- bytes
4 } data_element;
5
6 typedef struct data_row_s {
7 data_element proto[2]; // 0 - tcp 1 - udp
8 } data_row;
9
10 // to be used as index
11 enum { tcp = 0, udp };
12 enum { flows = 0, packets, bytes };
13
14 int InitStat(char *path);
15
16 int CloseStat(void);
17
18 int InitStatFile(void);
19
20 data_row *GetStat(void);
21
22 void ClearStat(void);
23
24 int UpdateStat(data_row *row, time_t when);
25
26 void Generate_TopN(data_row *row, int n, int scale, time_t when, int output_mode, char *wfile);
27
28 int Lister(data_row *row);
Binary diff not shown
Binary diff not shown
(No changes)
0 # Makefile.in generated by automake 1.11 from Makefile.am.
0 # Makefile.in generated by automake 1.11.1 from Makefile.am.
11 # @configure_input@
22
33 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
(No changes)
0 .TH nfexpire 1 2009\-09\-09 "" ""
1 .SH NAME
2 nfanon \- netflow anonymisation
3 .SH SYNOPSIS
4 .HP 5
5 .B nfanon [options]
6 .SH DESCRIPTION
7 .B nfanon
8 is used to anonymise all IP addresses ( src, dst, next hop, router IP etc. )
9 in the netflow records using the CryptoPAn (Cryptography\-based Prefix\-preserving
10 Anonymization) module. The key \fI-K\fR is used to initialize the Rijndael cipher.
11 The key is either a 32 character string, or a 64 hex digit string starting with 0x.
12 .P
13 .RS 3
14 See http://www.cc.gatech.edu/computing/Telecomm/cryptopan/ for
15 more information about CryptoPAn.
16 .RE
17 .PD
18 .P
19 nfanon has several modes of
20 operation.
21 .P
22 \fBo\fR nfanon reads a sequence of input files, specified by -r, -R and -M
23 and anonymises the flows in the given files. The input file arguments
24 have the same syntax and meaning as nfdump(1).
25 .P
26 \fBo\fR nfanon reads a sequence of input files, specified by -r, -R and -M.
27 All anonymised flows are written to a single file specified by -w.
28 .P
29 \fBo\fR nfanon works as filter and reads flows from stding and writes the anonymised
30 flows to stdout.
31
32 .SH OPTIONS
33 .TP 3
34 .B -r \fIinputfile
35 Read input data from \fIinputfile\fR. Default is read from stdin.
36 .TP 3
37 .B -R \fIexpr
38 Read input from a sequence of files in the same directory. \fIexpr\fR
39 may be one of:
40 .PD 0
41 .RS 4
42 /any/\fIdir\fR Read recursively all files in directory \fIdir\fR.
43 .P
44 /dir/\fIfile\fR Read all files beginning with \fIfile\fR.
45 .P
46 /dir/\fIfile1:file2\fR Read all files from \fIfile1\fR to \fIfile2\fR.
47
48 .P
49 Note: files are read in alphabetical sequence.
50 .RE
51 .PD
52 .TP 3
53 .B -M \fIexpr
54 Read input from multiple directories. \fIexpr\fR looks like:
55 \fI/any/path/to/dir1:dir2:dir3\fR etc. and will be expanded to the
56 directories: \fI/any/path/to/dir1\fR, \fI/any/path/to/dir2\fR and
57 \fI/any/path/to/dir3\fR Any number of colon separated directories may
58 be given. The files to read are specified by \-r or \-R and are expected
59 to exist in all the given directories. The options \-r and \-R must
60 not contain any directory part when used in conjunction with \-M.
61 .TP 3
62 .B -w \fIoutputfile
63 If specified writes anonymised netflow records to \fIoutputfile\fR.
64 .TP 3
65 .B -K \fIkey
66 The key is used to initialize the Rijndael cipher. \fIkey\fR is either
67 a 32 character string, or a 64 hex digit string starting with 0x.
68 .P
69 .SH "RETURN VALUE"
70 Returns
71 .PD 0
72 .RS 4
73 0 No error. \fn
74 .P
75 255 Initialization failed.
76 .P
77 250 Internal error.
78 .RE
79 .PD
80 .SH NOTES
81 None.
82 .P
83 .SH "SEE ALSO"
84 nfdump(1)
85 .SH BUGS
86
(No changes)
362362 .RE
363363 .PD
364364 .TP 3
365 .B -K \fIkey
366 Anonymize all IP addresses using the CryptoPAn (Cryptography\-based
367 Prefix\-preserving Anonymization) module. The key is used to
368 initialize the Rijndael cipher. \fIkey\fR is either a 32 character
369 string, or a 64 hex digit string starting with 0x. Anonymizing takes
370 place \fIafter\fR applying the flow filter, but before printing the flow
371 or writing the flow to a file.
372 .P
373 .RS 3
374 See http://www.cc.gatech.edu/computing/Telecomm/cryptopan/ for
375 more information about CryptoPAn.
376 .RE
377 .PD
378 .TP 3
379365 .B -q
380366 Suppress the header line and the statistics at the bottom.
381367 .TP 3
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)