Imported Upstream version 1.6.3
Erik Wenzel
13 years ago
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 | ||
0 | 9 | 2010-09-09 v1.6.2 |
1 | 10 | - released |
2 | 11 | - fixes some sflow bugs in sfcapd |
3 | 3 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, |
4 | 4 | 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
5 | 5 | |
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. | |
8 | 10 | |
9 | 11 | Basic Installation |
10 | 12 | ================== |
12 | 14 | Briefly, the shell commands `./configure; make; make install' should |
13 | 15 | configure, build, and install this package. The following |
14 | 16 | 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. | |
16 | 22 | |
17 | 23 | The `configure' shell script attempts to guess correct values for |
18 | 24 | various system-dependent variables used during compilation. It uses |
41 | 47 | you want to change it or regenerate `configure' using a newer version |
42 | 48 | of `autoconf'. |
43 | 49 | |
44 | The simplest way to compile this package is: | |
50 | The simplest way to compile this package is: | |
45 | 51 | |
46 | 52 | 1. `cd' to the directory containing the package's source code and type |
47 | 53 | `./configure' to configure the package for your system. |
52 | 58 | 2. Type `make' to compile the package. |
53 | 59 | |
54 | 60 | 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. | |
56 | 62 | |
57 | 63 | 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 | |
61 | 77 | source code directory by typing `make clean'. To also remove the |
62 | 78 | files that `configure' created (so you can compile the package for |
63 | 79 | a different kind of computer), type `make distclean'. There is |
66 | 82 | all sorts of other programs in order to regenerate files that came |
67 | 83 | with the distribution. |
68 | 84 | |
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. | |
71 | 94 | |
72 | 95 | Compilers and Options |
73 | 96 | ===================== |
92 | 115 | own directory. To do this, you can use GNU `make'. `cd' to the |
93 | 116 | directory where you want the object files and executables to go and run |
94 | 117 | 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. | |
96 | 120 | |
97 | 121 | With a non-GNU `make', it is safer to compile the package for one |
98 | 122 | architecture at a time in the source code directory. After you have |
119 | 143 | By default, `make install' installs the package's commands under |
120 | 144 | `/usr/local/bin', include files under `/usr/local/include', etc. You |
121 | 145 | 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. | |
123 | 148 | |
124 | 149 | You can specify separate installation prefixes for |
125 | 150 | architecture-specific files and architecture-independent files. If you |
130 | 155 | In addition, if you use an unusual directory layout you can give |
131 | 156 | options like `--bindir=DIR' to specify different values for particular |
132 | 157 | 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 | ================= | |
134 | 193 | |
135 | 194 | If the package supports it, you can cause programs to be installed |
136 | 195 | with an extra prefix or suffix on their names by giving `configure' the |
137 | 196 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. |
138 | ||
139 | Optional Features | |
140 | ================= | |
141 | 197 | |
142 | 198 | Some packages pay attention to `--enable-FEATURE' options to |
143 | 199 | `configure', where FEATURE indicates an optional part of the package. |
150 | 206 | find the X include and library files automatically, but if it doesn't, |
151 | 207 | you can use the `configure' options `--x-includes=DIR' and |
152 | 208 | `--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'. | |
153 | 216 | |
154 | 217 | Particular systems |
155 | 218 | ================== |
287 | 350 | `configure' can determine that directory automatically. |
288 | 351 | |
289 | 352 | `--prefix=DIR' |
290 | Use DIR as the installation prefix. *Note Installation Names:: | |
353 | Use DIR as the installation prefix. *note Installation Names:: | |
291 | 354 | for more details, including other options available for fine-tuning |
292 | 355 | the installation locations. |
293 | 356 |
0 | # Makefile.in generated by automake 1.11 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.11.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | 3 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
259 | 259 | # (which will cause the Makefiles to be regenerated when you run `make'); |
260 | 260 | # (2) otherwise, pass the desired values on the `make' command line. |
261 | 261 | $(RECURSIVE_TARGETS): |
262 | @failcom='exit 1'; \ | |
262 | @fail= failcom='exit 1'; \ | |
263 | 263 | for f in x $$MAKEFLAGS; do \ |
264 | 264 | case $$f in \ |
265 | 265 | *=* | --[!k]*);; \ |
284 | 284 | fi; test -z "$$fail" |
285 | 285 | |
286 | 286 | $(RECURSIVE_CLEAN_TARGETS): |
287 | @failcom='exit 1'; \ | |
287 | @fail= failcom='exit 1'; \ | |
288 | 288 | for f in x $$MAKEFLAGS; do \ |
289 | 289 | case $$f in \ |
290 | 290 | *=* | --[!k]*);; \ |
448 | 448 | fi; \ |
449 | 449 | done |
450 | 450 | -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 \ | |
452 | 453 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ |
453 | 454 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ |
454 | 455 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ |
492 | 493 | distcheck: dist |
493 | 494 | case '$(DIST_ARCHIVES)' in \ |
494 | 495 | *.tar.gz*) \ |
495 | GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ | |
496 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ | |
496 | 497 | *.tar.bz2*) \ |
497 | bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ | |
498 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ | |
498 | 499 | *.tar.lzma*) \ |
499 | unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ | |
500 | lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ | |
500 | 501 | *.tar.xz*) \ |
501 | 502 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ |
502 | 503 | *.tar.Z*) \ |
503 | 504 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ |
504 | 505 | *.shar.gz*) \ |
505 | GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ | |
506 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ | |
506 | 507 | *.zip*) \ |
507 | 508 | unzip $(distdir).zip ;;\ |
508 | 509 | esac |
0 | # generated automatically by aclocal 1.11 -*- Autoconf -*- | |
0 | # generated automatically by aclocal 1.11.1 -*- Autoconf -*- | |
1 | 1 | |
2 | 2 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
3 | 3 | # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
12 | 12 | |
13 | 13 | m4_ifndef([AC_AUTOCONF_VERSION], |
14 | 14 | [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. | |
17 | 17 | You have another version of autoconf. It may work, but is not guaranteed to. |
18 | 18 | If you have problems, you may need to regenerate the build system entirely. |
19 | 19 | To do so, use the procedure documented by the package, typically `autoreconf'.])]) |
33 | 33 | [am__api_version='1.11' |
34 | 34 | dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to |
35 | 35 | dnl require some minimum version. Point them to the right macro. |
36 | m4_if([$1], [1.11], [], | |
36 | m4_if([$1], [1.11.1], [], | |
37 | 37 | [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl |
38 | 38 | ]) |
39 | 39 | |
49 | 49 | # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. |
50 | 50 | # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. |
51 | 51 | AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], |
52 | [AM_AUTOMAKE_VERSION([1.11])dnl | |
52 | [AM_AUTOMAKE_VERSION([1.11.1])dnl | |
53 | 53 | m4_ifndef([AC_AUTOCONF_VERSION], |
54 | 54 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl |
55 | 55 | _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 ) |
0 | 0 | |
1 | bin_PROGRAMS = nfcapd nfdump nfreplay nfexpire | |
1 | bin_PROGRAMS = nfcapd nfdump nfreplay nfexpire nfanon | |
2 | 2 | EXTRA_PROGRAMS = nftest nfgen nfreader |
3 | 3 | |
4 | 4 | check_PROGRAMMS = test.sh |
10 | 10 | |
11 | 11 | if NFPROFILE |
12 | 12 | bin_PROGRAMS += nfprofile |
13 | endif | |
14 | ||
15 | if NFTRACK | |
16 | bin_PROGRAMS += nftrack | |
13 | 17 | endif |
14 | 18 | |
15 | 19 | if FT2NFDUMP |
25 | 29 | #Add extra debug info for gdb |
26 | 30 | AM_CFLAGS = -ggdb |
27 | 31 | |
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 | |
30 | 33 | util = util.c util.h |
31 | 34 | filelzo = minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c nffile.h nfx.c nfx.h |
32 | 35 | nflist = flist.c flist.h fts_compat.c fts_compat.h |
33 | 36 | filter = grammar.y scanner.l nftree.c nftree.h ipconv.c ipconv.h rbtree.h |
34 | 37 | nfprof = nfprof.c nfprof.h |
35 | 38 | nfnet = nfnet.c nfnet.h |
39 | anon = panonymizer.c panonymizer.h rijndael.c rijndael.h | |
36 | 40 | collector = collector.c collector.h |
37 | 41 | nfv9 = netflow_v9.c netflow_v9.h |
38 | 42 | nfv5v7 = netflow_v5_v7.c netflow_v5_v7.h |
52 | 56 | nfprofile_SOURCES = nfprofile.c profile.c profile.h \ |
53 | 57 | $(common) $(util) $(filelzo) $(nflist) $(filter) $(nfstatfile) |
54 | 58 | 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 | |
55 | 64 | |
56 | 65 | nfcapd_SOURCES = nfcapd.c \ |
57 | 66 | $(common) $(util) $(filelzo) $(nflist) $(nfstatfile) $(launch) \ |
74 | 83 | endif |
75 | 84 | |
76 | 85 | nfreader_SOURCES = nfreader.c \ |
77 | $(util) $(filelzo) $(nflist) | |
86 | $(util) $(filelzo) $(nflist) | |
87 | ||
88 | nfanon_SOURCES = nfanon.c \ | |
89 | $(util) $(filelzo) $(nflist) $(anon) | |
78 | 90 | |
79 | 91 | nfgen_SOURCES = nfgen.c $(util) $(filelzo) $(nflist) |
80 | 92 |
0 | # Makefile.in generated by automake 1.11 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.11.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | 3 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
32 | 32 | PRE_UNINSTALL = : |
33 | 33 | POST_UNINSTALL = : |
34 | 34 | 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) | |
37 | 37 | EXTRA_PROGRAMS = nftest$(EXEEXT) nfgen$(EXEEXT) nfreader$(EXEEXT) |
38 | 38 | TESTS = nftest$(EXEEXT) test.sh |
39 | 39 | @SFLOW_TRUE@am__append_1 = sfcapd |
40 | 40 | @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 | |
43 | 43 | @READPCAP_TRUE@am__append_5 = pcap_reader.c pcap_reader.h |
44 | @READPCAP_TRUE@am__append_6 = pcap_reader.c pcap_reader.h | |
44 | 45 | subdir = bin |
45 | 46 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in grammar.c \ |
46 | 47 | grammar.h scanner.c |
54 | 55 | CONFIG_CLEAN_VPATH_FILES = |
55 | 56 | @SFLOW_TRUE@am__EXEEXT_1 = sfcapd$(EXEEXT) |
56 | 57 | @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) | |
58 | 60 | am__installdirs = "$(DESTDIR)$(bindir)" |
59 | 61 | PROGRAMS = $(bin_PROGRAMS) |
60 | 62 | 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) | |
66 | 66 | am__objects_2 = ft2nfdump-minilzo.$(OBJEXT) ft2nfdump-nffile.$(OBJEXT) \ |
67 | 67 | ft2nfdump-nfx.$(OBJEXT) |
68 | 68 | am__objects_3 = ft2nfdump-util.$(OBJEXT) |
73 | 73 | ft2nfdump_DEPENDENCIES = |
74 | 74 | ft2nfdump_LINK = $(CCLD) $(ft2nfdump_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ |
75 | 75 | $(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 \ | |
78 | 86 | util.c util.h minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c \ |
79 | 87 | nffile.h nfx.c nfx.h flist.c flist.h fts_compat.c fts_compat.h \ |
80 | 88 | nfstatfile.c nfstatfile.h launch.c launch.h nfnet.c nfnet.h \ |
81 | 89 | collector.c collector.h netflow_v9.c netflow_v9.h \ |
82 | 90 | netflow_v5_v7.c netflow_v5_v7.h bookkeeper.c bookkeeper.h \ |
83 | 91 | 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) \ | |
88 | 95 | 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) | |
104 | 111 | nfcapd_OBJECTS = $(am_nfcapd_OBJECTS) |
105 | 112 | nfcapd_DEPENDENCIES = |
106 | 113 | nfcapd_LINK = $(CCLD) $(nfcapd_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ |
107 | 114 | $(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) \ | |
115 | 118 | ipconv.$(OBJEXT) |
116 | am__objects_23 = nfprof.$(OBJEXT) | |
119 | am__objects_24 = nfprof.$(OBJEXT) | |
117 | 120 | 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) | |
121 | 124 | nfdump_OBJECTS = $(am_nfdump_OBJECTS) |
122 | 125 | nfdump_LDADD = $(LDADD) |
123 | 126 | 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) | |
129 | 132 | nfexpire_OBJECTS = $(am_nfexpire_OBJECTS) |
130 | 133 | 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) | |
133 | 136 | nfgen_OBJECTS = $(am_nfgen_OBJECTS) |
134 | 137 | nfgen_LDADD = $(LDADD) |
135 | 138 | nfgen_DEPENDENCIES = |
136 | 139 | 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) | |
139 | 142 | nfprofile_OBJECTS = $(am_nfprofile_OBJECTS) |
140 | 143 | 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) | |
143 | 146 | nfreader_OBJECTS = $(am_nfreader_OBJECTS) |
144 | 147 | nfreader_LDADD = $(LDADD) |
145 | 148 | 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) | |
154 | 157 | nfreplay_OBJECTS = $(am_nfreplay_OBJECTS) |
155 | 158 | nfreplay_LDADD = $(LDADD) |
156 | 159 | 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) | |
159 | 162 | nftest_OBJECTS = $(am_nftest_OBJECTS) |
160 | 163 | 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 $@ | |
161 | 179 | 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) \ | |
173 | 189 | 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) | |
182 | 198 | 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) \ | |
185 | 199 | $(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) | |
187 | 203 | sfcapd_OBJECTS = $(am_sfcapd_OBJECTS) |
188 | 204 | sfcapd_DEPENDENCIES = |
189 | 205 | sfcapd_LINK = $(CCLD) $(sfcapd_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ |
199 | 215 | LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) |
200 | 216 | YLWRAP = $(top_srcdir)/ylwrap |
201 | 217 | 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) \ | |
207 | 223 | $(am__nfcapd_SOURCES_DIST) $(nfdump_SOURCES) \ |
208 | 224 | $(nfexpire_SOURCES) $(nfgen_SOURCES) $(nfprofile_SOURCES) \ |
209 | 225 | $(nfreader_SOURCES) $(nfreplay_SOURCES) $(nftest_SOURCES) \ |
210 | $(am__sfcapd_SOURCES_DIST) | |
226 | $(nftrack_SOURCES) $(am__sfcapd_SOURCES_DIST) | |
211 | 227 | ETAGS = etags |
212 | 228 | CTAGS = ctags |
213 | 229 | am__tty_colors = \ |
317 | 333 | |
318 | 334 | #Add extra debug info for gdb |
319 | 335 | 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 | |
323 | 337 | util = util.c util.h |
324 | 338 | filelzo = minilzo.c minilzo.h lzoconf.h lzodefs.h nffile.c nffile.h nfx.c nfx.h |
325 | 339 | nflist = flist.c flist.h fts_compat.c fts_compat.h |
326 | 340 | filter = grammar.y scanner.l nftree.c nftree.h ipconv.c ipconv.h rbtree.h |
327 | 341 | nfprof = nfprof.c nfprof.h |
328 | 342 | nfnet = nfnet.c nfnet.h |
343 | anon = panonymizer.c panonymizer.h rijndael.c rijndael.h | |
329 | 344 | collector = collector.c collector.h |
330 | 345 | nfv9 = netflow_v9.c netflow_v9.h |
331 | 346 | nfv5v7 = netflow_v5_v7.c netflow_v5_v7.h |
345 | 360 | $(common) $(util) $(filelzo) $(nflist) $(filter) $(nfstatfile) |
346 | 361 | |
347 | 362 | 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 | |
348 | 368 | nfcapd_SOURCES = nfcapd.c $(common) $(util) $(filelzo) $(nflist) \ |
349 | 369 | $(nfstatfile) $(launch) $(nfnet) $(collector) $(nfv9) \ |
350 | $(nfv5v7) $(bookkeeper) $(expire) $(am__append_4) | |
370 | $(nfv5v7) $(bookkeeper) $(expire) $(am__append_5) | |
351 | 371 | @READPCAP_TRUE@nfcapd_CFLAGS = -DPCAP |
352 | 372 | @READPCAP_TRUE@nfcapd_LDADD = -lpcap |
353 | 373 | sfcapd_SOURCES = sfcapd.c sflow.c sflow.h sflow_proto.h $(common) \ |
354 | 374 | $(util) $(filelzo) $(nflist) $(nfstatfile) $(launch) $(nfnet) \ |
355 | $(collector) $(bookkeeper) $(expire) $(am__append_5) | |
375 | $(collector) $(bookkeeper) $(expire) $(am__append_6) | |
356 | 376 | @READPCAP_TRUE@sfcapd_CFLAGS = -DPCAP |
357 | 377 | @READPCAP_TRUE@sfcapd_LDADD = -lpcap |
358 | 378 | nfreader_SOURCES = nfreader.c \ |
359 | $(util) $(filelzo) $(nflist) | |
379 | $(util) $(filelzo) $(nflist) | |
380 | ||
381 | nfanon_SOURCES = nfanon.c \ | |
382 | $(util) $(filelzo) $(nflist) $(anon) | |
360 | 383 | |
361 | 384 | nfgen_SOURCES = nfgen.c $(util) $(filelzo) $(nflist) |
362 | 385 | nfexpire_SOURCES = nfexpire.c \ |
445 | 468 | ft2nfdump$(EXEEXT): $(ft2nfdump_OBJECTS) $(ft2nfdump_DEPENDENCIES) |
446 | 469 | @rm -f ft2nfdump$(EXEEXT) |
447 | 470 | $(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) | |
448 | 474 | nfcapd$(EXEEXT): $(nfcapd_OBJECTS) $(nfcapd_DEPENDENCIES) |
449 | 475 | @rm -f nfcapd$(EXEEXT) |
450 | 476 | $(nfcapd_LINK) $(nfcapd_OBJECTS) $(nfcapd_LDADD) $(LIBS) |
474 | 500 | nftest$(EXEEXT): $(nftest_OBJECTS) $(nftest_DEPENDENCIES) |
475 | 501 | @rm -f nftest$(EXEEXT) |
476 | 502 | $(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) | |
477 | 506 | sfcapd$(EXEEXT): $(sfcapd_OBJECTS) $(sfcapd_DEPENDENCIES) |
478 | 507 | @rm -f sfcapd$(EXEEXT) |
479 | 508 | $(sfcapd_LINK) $(sfcapd_OBJECTS) $(sfcapd_LDADD) $(LIBS) |
493 | 522 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-nf_common.Po@am__quote@ |
494 | 523 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-nffile.Po@am__quote@ |
495 | 524 | @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@ | |
498 | 525 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ft2nfdump-util.Po@am__quote@ |
499 | 526 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fts_compat.Po@am__quote@ |
500 | 527 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grammar.Po@am__quote@ |
503 | 530 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netflow_v5_v7.Po@am__quote@ |
504 | 531 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netflow_v9.Po@am__quote@ |
505 | 532 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nf_common.Po@am__quote@ |
533 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfanon.Po@am__quote@ | |
506 | 534 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-bookkeeper.Po@am__quote@ |
507 | 535 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-collector.Po@am__quote@ |
508 | 536 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-expire.Po@am__quote@ |
518 | 546 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-nfnet.Po@am__quote@ |
519 | 547 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-nfstatfile.Po@am__quote@ |
520 | 548 | @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@ | |
522 | 549 | @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@ | |
524 | 550 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfcapd-util.Po@am__quote@ |
525 | 551 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfdump.Po@am__quote@ |
526 | 552 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfexpire.Po@am__quote@ |
536 | 562 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfstat.Po@am__quote@ |
537 | 563 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfstatfile.Po@am__quote@ |
538 | 564 | @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@ | |
539 | 579 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nftree.Po@am__quote@ |
540 | 580 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfx.Po@am__quote@ |
541 | 581 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panonymizer.Po@am__quote@ |
554 | 594 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-nfnet.Po@am__quote@ |
555 | 595 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-nfstatfile.Po@am__quote@ |
556 | 596 | @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@ | |
558 | 597 | @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@ | |
560 | 598 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-sfcapd.Po@am__quote@ |
561 | 599 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-sflow.Po@am__quote@ |
562 | 600 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfcapd-util.Po@am__quote@ |
604 | 642 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
605 | 643 | @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` |
606 | 644 | |
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 | ||
635 | 645 | ft2nfdump-minilzo.o: minilzo.c |
636 | 646 | @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 |
637 | 647 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ft2nfdump-minilzo.Tpo $(DEPDIR)/ft2nfdump-minilzo.Po |
716 | 726 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
717 | 727 | @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` |
718 | 728 | |
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 | ||
747 | 729 | nfcapd-util.o: util.c |
748 | 730 | @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 |
749 | 731 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nfcapd-util.Tpo $(DEPDIR)/nfcapd-util.Po |
954 | 936 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
955 | 937 | @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` |
956 | 938 | |
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 | ||
957 | 1135 | sfcapd-sfcapd.o: sfcapd.c |
958 | 1136 | @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 |
959 | 1137 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sfcapd-sfcapd.Tpo $(DEPDIR)/sfcapd-sfcapd.Po |
995 | 1173 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nf_common.c' object='sfcapd-nf_common.obj' libtool=no @AMDEPBACKSLASH@ |
996 | 1174 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
997 | 1175 | @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` | |
1026 | 1176 | |
1027 | 1177 | sfcapd-util.o: util.c |
1028 | 1178 | @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 |
296 | 296 | } |
297 | 297 | |
298 | 298 | // 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; | |
300 | 300 | // at least space for the map size is required |
301 | 301 | if ( bsize >= (BUFFSIZE - map->size ) ) { |
302 | 302 | syslog(LOG_WARNING,"AddExtensionMap: Outputbuffer full. Flush buffer but have to skip records."); |
303 | 303 | return 0; |
304 | 304 | } |
305 | 305 | |
306 | if ( !CheckBufferSpace(&(fs->nffile), map->size) ) { | |
306 | if ( !CheckBufferSpace(fs->nffile, map->size) ) { | |
307 | 307 | // fishy! - should never happen. maybe disk full? |
308 | 308 | syslog(LOG_ERR,"AddExtensionMap: output buffer size error. Abort record processing"); |
309 | 309 | return 0; |
310 | 310 | } |
311 | 311 | |
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++; | |
317 | 317 | |
318 | 318 | return 1; |
319 | 319 | |
325 | 325 | for ( i=0; i<fs->extension_map_list.next_free; i++ ) { |
326 | 326 | extension_map_t *map = fs->extension_map_list.maps[i]; |
327 | 327 | |
328 | if ( !CheckBufferSpace(&(fs->nffile), map->size) ) { | |
328 | if ( !CheckBufferSpace(fs->nffile, map->size) ) { | |
329 | 329 | // fishy! - should never happen. maybe disk full? |
330 | 330 | syslog(LOG_ERR,"FlushExtensionMaps: output buffer size error. Abort record processing"); |
331 | 331 | return; |
332 | 332 | } |
333 | 333 | |
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; | |
339 | 339 | } |
340 | 340 | |
341 | 341 | } // End of FlushExtensionMaps |
89 | 89 | // all about data storage |
90 | 90 | char *datadir; // where to store data for this source |
91 | 91 | 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 | |
93 | 93 | |
94 | 94 | // statistical data per source |
95 | 95 | stat_record_t stat_record; |
222 | 222 | |
223 | 223 | #define NUM_PTR 16 |
224 | 224 | |
225 | static char *first_file, *last_file, current_file[255]; | |
225 | static char *first_file, *last_file; | |
226 | static char *current_file = NULL; | |
226 | 227 | static uint32_t twin_first, twin_last; |
227 | 228 | static stringlist_t source_dirs, file_list; |
228 | 229 | |
993 | 994 | // stdin ( current = 0 ) is not closed |
994 | 995 | if ( current > 0 ) { |
995 | 996 | close(current); |
996 | current_file[0] = '\0'; | |
997 | current_file = NULL; | |
997 | 998 | } |
998 | 999 | |
999 | 1000 | // no or no more files available |
1000 | 1001 | if ( file_list.num_strings == cnt ) { |
1001 | 1002 | if ( stat_record ) |
1002 | 1003 | *stat_record = NULL; |
1004 | current_file = NULL; | |
1003 | 1005 | return EMPTY_LIST; |
1004 | 1006 | } |
1005 | 1007 | |
1011 | 1013 | |
1012 | 1014 | while ( cnt < file_list.num_strings ) { |
1013 | 1015 | fd = OpenFile(file_list.list[cnt], &stat_ptr, &error); // Open the file |
1016 | current_file = file_list.list[cnt]; | |
1014 | 1017 | cnt++; |
1015 | 1018 | |
1016 | 1019 | // stdin |
1018 | 1021 | if ( stat_record ) |
1019 | 1022 | *stat_record = NULL; |
1020 | 1023 | CurrentIdent = "none"; |
1024 | current_file = NULL; | |
1021 | 1025 | return fd; |
1022 | 1026 | } |
1023 | 1027 | |
1035 | 1039 | if ( stat_record ) |
1036 | 1040 | *stat_record = NULL; |
1037 | 1041 | |
1042 | current_file = NULL; | |
1038 | 1043 | return EMPTY_LIST; |
1039 | 1044 | |
1040 | 1045 | } // End of GetNextFile |
193 | 193 | struct ftver ftv; |
194 | 194 | char *rec; |
195 | 195 | // nfdump variables |
196 | nffile_t nffile; | |
196 | nffile_t *nffile; | |
197 | 197 | master_record_t record; |
198 | file_header_t *file_header; | |
199 | ||
198 | char *s; | |
200 | 199 | 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 | ||
246 | 209 | ftio_get_ver(ftio, &ftv); |
247 | 210 | fts3rec_compute_offsets(&fo, &ftv); |
248 | 211 | |
317 | 280 | i++; |
318 | 281 | } |
319 | 282 | |
320 | ||
321 | PackRecord(&record, &nffile); | |
283 | PackRecord(&record, nffile); | |
322 | 284 | |
323 | 285 | if ( extended ) { |
324 | 286 | char *string; |
325 | format_file_block_record(&record, &string, 0, 0); | |
287 | format_file_block_record(&record, &string, 0); | |
326 | 288 | fprintf(stderr, "%s\n", string); |
327 | 289 | } |
328 | 290 | |
333 | 295 | } /* while */ |
334 | 296 | |
335 | 297 | // 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 ) { | |
338 | 300 | fprintf(stderr, "Failed to write output buffer: '%s'" , strerror(errno)); |
339 | 301 | } |
340 | 302 | } |
341 | 303 | |
342 | 304 | free((void *)extension_info->map); |
343 | 305 | free((void *)extension_info); |
344 | free((void *)nffile.block_header); | |
345 | free((void *)file_header); | |
306 | DisposeFile(nffile); | |
346 | 307 | |
347 | 308 | return 0; |
348 | 309 |
564 | 564 | RB_INIT(root); |
565 | 565 | |
566 | 566 | RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) { |
567 | if ( node->value > 65535 ) { | |
568 | yyerror("Port outside of range 0..65535"); | |
569 | YYABORT; | |
570 | } | |
567 | 571 | if ((n = malloc(sizeof(struct ULongListNode))) == NULL) { |
568 | 572 | yyerror("malloc() error"); |
569 | 573 | YYABORT; |
669 | 673 | |
670 | 674 | | dqual AS comp NUMBER { |
671 | 675 | $$.direction = $1.direction; |
672 | if ( $4 > 0x7FFFFFFF || $4 < 0 ) { | |
676 | if ( $4 > 0xfFFFFFFF || $4 < 0 ) { | |
673 | 677 | yyerror("AS number of range"); |
674 | 678 | YYABORT; |
675 | 679 | } |
729 | 733 | RB_INIT(root); |
730 | 734 | |
731 | 735 | RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) { |
732 | ||
736 | if ( node->value > 0xFFFFFFFFLL ) { | |
737 | yyerror("AS number of range"); | |
738 | YYABORT; | |
739 | } | |
733 | 740 | if ((n = malloc(sizeof(struct ULongListNode))) == NULL) { |
734 | 741 | yyerror("malloc() error"); |
735 | 742 | YYABORT; |
1025 | 1032 | } |
1026 | 1033 | |
1027 | 1034 | | 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"); | |
1030 | 1037 | YYABORT; |
1031 | 1038 | } |
1032 | 1039 | |
1562 | 1569 | ullist: NUMBER { |
1563 | 1570 | struct ULongListNode *node; |
1564 | 1571 | |
1565 | if ( $1 > 65535 ) { | |
1566 | yyerror("Value outside of range 0..65535"); | |
1567 | YYABORT; | |
1568 | } | |
1569 | 1572 | ULongtree_t *root = malloc(sizeof(ULongtree_t)); |
1570 | 1573 | |
1571 | 1574 | if ( root == NULL) { |
1586 | 1589 | | ullist NUMBER { |
1587 | 1590 | struct ULongListNode *node; |
1588 | 1591 | |
1589 | if ( $2 > 65535 ) { | |
1590 | yyerror("Value outside of range 0..65535"); | |
1591 | YYABORT; | |
1592 | } | |
1593 | 1592 | if ((node = malloc(sizeof(struct ULongListNode))) == NULL) { |
1594 | 1593 | yyerror("malloc() error"); |
1595 | 1594 | 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 | */ |
69 | 69 | extern int verbose; |
70 | 70 | extern extension_descriptor_t extension_descriptor[]; |
71 | 71 | extern uint32_t default_sampling; |
72 | extern uint32_t overwrite_sampling; | |
72 | 73 | |
73 | 74 | /* module limited globals */ |
74 | 75 | static extension_info_t v5_extension_info; // common for all v5 records |
93 | 94 | // exporter identifier |
94 | 95 | uint32_t version; |
95 | 96 | uint16_t engine_tag; |
97 | ip_addr_t ip; | |
98 | uint32_t sa_family; | |
99 | ||
96 | 100 | uint16_t align; |
97 | 101 | uint16_t sampling_mode; |
98 | 102 | uint16_t sampling_interval; |
187 | 191 | |
188 | 192 | // search the appropriate exporter engine |
189 | 193 | 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]) | |
191 | 196 | return *e; |
192 | 197 | e = &((*e)->next); |
193 | 198 | } |
200 | 205 | } |
201 | 206 | memset((void *)(*e), 0, sizeof(exporter_v5_t)); |
202 | 207 | (*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; | |
203 | 211 | (*e)->align = 0; |
204 | 212 | (*e)->sampling_mode = (0xC000 & ntohs(header->sampling_interval)) >> 14; |
205 | 213 | (*e)->sampling_interval = 0x3fff & ntohs(header->sampling_interval); |
245 | 253 | (*e)->extension_map->map_id, ipstr, (*e)->sampling_mode ,(*e)->sampling_interval); |
246 | 254 | syslog(LOG_INFO, "Process_v5: New exporter: engine id %u, type %u, IP: %s, Sampling Mode: %i, Sampling Interval: %i\n", |
247 | 255 | ( 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 | } | |
248 | 261 | |
249 | 262 | return (*e); |
250 | 263 | |
286 | 299 | // this many data to process |
287 | 300 | size_left = in_buff_cnt; |
288 | 301 | |
289 | common_record = fs->nffile.writeto; | |
302 | common_record = fs->nffile->writeto; | |
290 | 303 | done = 0; |
291 | 304 | while ( !done ) { |
292 | 305 | v5_block_t *v5_block; |
297 | 310 | count = ntohs(v5_header->count); |
298 | 311 | if ( count > NETFLOW_V5_MAX_RECORDS ) { |
299 | 312 | 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; | |
301 | 314 | return; |
302 | 315 | } |
303 | 316 | |
304 | 317 | // input buffer size check for all expected records |
305 | 318 | if ( size_left < ( NETFLOW_V5_HEADER_LENGTH + count * flow_record_length) ) { |
306 | 319 | 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; | |
308 | 321 | return; |
309 | 322 | } |
310 | 323 | |
311 | 324 | // 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) ) { | |
313 | 326 | // fishy! - should never happen. maybe disk full? |
314 | 327 | syslog(LOG_ERR,"Process_v5: output buffer size error. Abort v5/v7 record processing"); |
315 | 328 | return; |
316 | 329 | } |
317 | 330 | |
318 | 331 | // map output record to memory buffer |
319 | common_record = (common_record_t *)fs->nffile.writeto; | |
332 | common_record = (common_record_t *)fs->nffile->writeto; | |
320 | 333 | v5_block = (v5_block_t *)common_record->data; |
321 | 334 | |
322 | 335 | // sequence check |
440 | 453 | if ( First > Last ) |
441 | 454 | /* First in msec, in case of msec overflow, between start and end */ |
442 | 455 | 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 | } | |
443 | 465 | else |
444 | 466 | start_time = (uint64_t)First + boot_time; |
445 | 467 | |
446 | 468 | /* end time in msecs */ |
447 | 469 | end_time = (uint64_t)Last + boot_time; |
448 | 470 | |
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 | } | |
449 | 476 | |
450 | 477 | common_record->first = start_time/1000; |
451 | 478 | common_record->msec_first = start_time - common_record->first*1000; |
499 | 526 | if ( verbose ) { |
500 | 527 | master_record_t master_record; |
501 | 528 | 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); | |
503 | 530 | printf("%s\n", string); |
504 | 531 | } |
505 | 532 | |
507 | 534 | v5_record = (netflow_v5_record_t *)((pointer_addr_t)v5_record + flow_record_length); |
508 | 535 | |
509 | 536 | 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 ); | |
511 | 538 | abort(); |
512 | 539 | } |
513 | 540 | // advance to next output record |
515 | 542 | v5_block = (v5_block_t *)common_record->data; |
516 | 543 | |
517 | 544 | // 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); | |
519 | 546 | if ( bsize >= BUFFSIZE ) { |
547 | syslog(LOG_ERR,"### Software error ###: %s line %d", __FILE__, __LINE__); | |
520 | 548 | 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); | |
522 | 550 | // 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) ); | |
526 | 554 | return; |
527 | 555 | } |
528 | 556 | |
529 | 557 | } // End of foreach v5 record |
530 | 558 | |
531 | 559 | // 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; | |
535 | 563 | |
536 | 564 | // still to go for this many input bytes |
537 | 565 | size_left -= NETFLOW_V5_HEADER_LENGTH + count * flow_record_length; |
625 | 625 | if ( map_table[i] == 0 ) |
626 | 626 | continue; |
627 | 627 | |
628 | extension_map->size += sizeof(uint16_t); | |
629 | extension_map->extension_size += extension_descriptor[i].size; | |
630 | 628 | switch(i) { |
631 | 629 | case EX_IO_SNMP_2: |
632 | 630 | case EX_IO_SNMP_4: |
633 | 631 | // 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) { | |
635 | 633 | FillElement( table, NF9_INPUT_SNMP, &offset); |
636 | 634 | FillElement( table, NF9_OUTPUT_SNMP, &offset); |
637 | 635 | map_index = EX_IO_SNMP_2; |
702 | 700 | break; |
703 | 701 | case EX_OUT_BYTES_4: |
704 | 702 | case EX_OUT_BYTES_8: |
705 | if ( input_template[NF9_OUT_PKTS].length <= 4 ) { | |
703 | if ( input_template[NF9_OUT_BYTES].length <= 4 ) { | |
706 | 704 | FillElement( table, NF9_OUT_BYTES, &offset); |
707 | 705 | map_index = EX_OUT_BYTES_4; |
708 | 706 | } else { |
770 | 768 | // unused fill element for 32bit alignment |
771 | 769 | break; |
772 | 770 | } |
771 | extension_map->size += sizeof(uint16_t); | |
772 | extension_map->extension_size += extension_descriptor[map_index].size; | |
773 | 773 | |
774 | 774 | // found extension in map_index must be the same as in map - otherwise map is dirty |
775 | 775 | if ( extension_map->ex_id[next_extension] != map_index ) { |
894 | 894 | // do we store this extension? enabled != 0 |
895 | 895 | // more than 1 v9 tag may map to an extension - so count this extension once only |
896 | 896 | if ( ext_id && extension_descriptor[ext_id].enabled ) { |
897 | dbg_printf("Type: %u, Length %u => Extension: %u\n", field_type, field_length, ext_id); | |
897 | 898 | if ( map_table[ext_id] == 0 ) { |
898 | 899 | map_table[ext_id] = 1; |
899 | 900 | num_extensions++; |
900 | 901 | } |
901 | dbg_printf("Type: %u, Length %u => Extension: %u\n", field_type, field_length, ext_id); | |
902 | 902 | } else { |
903 | 903 | dbg_printf("Type: %u, Length %u\n", field_type, field_length); |
904 | 904 | } |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | // 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) ) { | |
1110 | 1110 | // this should really never occur, because the buffer gets flushed ealier |
1111 | 1111 | syslog(LOG_ERR,"Process_v9: output buffer size error. Abort v9 record processing"); |
1112 | 1112 | dbg_printf("Process_v9: output buffer size error. Abort v9 record processing"); |
1115 | 1115 | processed_records++; |
1116 | 1116 | |
1117 | 1117 | // map file record to output buffer |
1118 | data_record = (common_record_t *)fs->nffile.writeto; | |
1118 | data_record = (common_record_t *)fs->nffile->writeto; | |
1119 | 1119 | // map output buffer as a byte array |
1120 | 1120 | out = (uint8_t *)data_record; |
1121 | 1121 | |
1362 | 1362 | if ( verbose ) { |
1363 | 1363 | master_record_t master_record; |
1364 | 1364 | 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); | |
1366 | 1366 | printf("%s\n", string); |
1367 | 1367 | } |
1368 | 1368 | |
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); | |
1372 | 1372 | |
1373 | 1373 | // advance input |
1374 | 1374 | size_left -= table->input_record_size; |
1375 | 1375 | in += table->input_record_size; |
1376 | 1376 | |
1377 | 1377 | // buffer size sanity check |
1378 | if ( fs->nffile.block_header->size > BUFFSIZE ) { | |
1378 | if ( fs->nffile->block_header->size > BUFFSIZE ) { | |
1379 | 1379 | // should never happen |
1380 | 1380 | syslog(LOG_ERR,"### Software error ###: %s line %d", __FILE__, __LINE__); |
1381 | 1381 | 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); | |
1383 | 1383 | |
1384 | 1384 | // 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) ); | |
1388 | 1388 | return; |
1389 | 1389 | } |
1390 | 1390 | |
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | #ifdef DEVEL |
1544 | if ( (ptrdiff_t)fs->nffile.writeto & 0x3 ) { | |
1544 | if ( (ptrdiff_t)fs->nffile->writeto & 0x3 ) { | |
1545 | 1545 | fprintf(stderr, "PANIC: alignment error!! \n"); |
1546 | 1546 | exit(255); |
1547 | 1547 | } |
2228 | 2228 | |
2229 | 2229 | #ifdef DEVEL |
2230 | 2230 | // char *string; |
2231 | // format_file_block_record(master_record, 1, &string, 0, 0); | |
2231 | // format_file_block_record(master_record, 1, &string, 0); | |
2232 | 2232 | // dbg_printf("%s\n", string); |
2233 | 2233 | #endif |
2234 | 2234 |
52 | 52 | #endif |
53 | 53 | |
54 | 54 | #include "nffile.h" |
55 | #include "panonymizer.h" | |
56 | 55 | #include "nf_common.h" |
57 | 56 | #include "util.h" |
58 | 57 | |
72 | 71 | static int max_format_index = 0; |
73 | 72 | static int format_index = 0; |
74 | 73 | |
75 | static int do_anonymize = 0; | |
76 | 74 | static int do_tag = 0; |
77 | 75 | static int long_v6 = 0; |
78 | 76 | static int no_scale = 0; |
533 | 531 | |
534 | 532 | } // End of Get_fwd_status_name |
535 | 533 | |
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) { | |
537 | 535 | data_block_header_t *h = (data_block_header_t *)header; |
538 | 536 | |
539 | 537 | snprintf(data_string,STRINGSIZE-1 ,"" |
548 | 546 | |
549 | 547 | } // End of format_file_block_header |
550 | 548 | |
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) { | |
553 | 550 | char *_s, as[IP_STRING_LEN], ds[IP_STRING_LEN], datestr1[64], datestr2[64], flags_str[16]; |
554 | 551 | char s_snet[IP_STRING_LEN], s_dnet[IP_STRING_LEN]; |
555 | 552 | int i, id; |
565 | 562 | uint64_t snet[2]; |
566 | 563 | uint64_t dnet[2]; |
567 | 564 | |
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 | } | |
577 | 565 | // remember IPs for network |
578 | 566 | snet[0] = r->v6.srcaddr[0]; |
579 | 567 | snet[1] = r->v6.srcaddr[1]; |
621 | 609 | |
622 | 610 | } else { // IPv4 |
623 | 611 | uint32_t snet, dnet; |
624 | if ( anon ) { | |
625 | r->v4.srcaddr = anonymize(r->v4.srcaddr); | |
626 | r->v4.dstaddr = anonymize(r->v4.dstaddr); | |
627 | } | |
628 | 612 | snet = r->v4.srcaddr; |
629 | 613 | dnet = r->v4.dstaddr; |
630 | 614 | r->v4.srcaddr = htonl(r->v4.srcaddr); |
728 | 712 | break; |
729 | 713 | case EX_NEXT_HOP_v4: |
730 | 714 | as[0] = 0; |
731 | if ( anon ) { | |
732 | r->ip_nexthop.v4 = anonymize(r->ip_nexthop.v4); | |
733 | } | |
734 | 715 | r->ip_nexthop.v4 = htonl(r->ip_nexthop.v4); |
735 | 716 | inet_ntop(AF_INET, &r->ip_nexthop.v4, as, sizeof(as)); |
736 | 717 | as[IP_STRING_LEN-1] = 0; |
745 | 726 | break; |
746 | 727 | case EX_NEXT_HOP_v6: |
747 | 728 | 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 | } | |
753 | 729 | r->ip_nexthop.v6[0] = htonll(r->ip_nexthop.v6[0]); |
754 | 730 | r->ip_nexthop.v6[1] = htonll(r->ip_nexthop.v6[1]); |
755 | 731 | inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as)); |
768 | 744 | break; |
769 | 745 | case EX_NEXT_HOP_BGP_v4: |
770 | 746 | as[0] = 0; |
771 | if ( anon ) { | |
772 | r->bgp_nexthop.v4 = anonymize(r->bgp_nexthop.v4); | |
773 | } | |
774 | 747 | r->bgp_nexthop.v4 = htonl(r->bgp_nexthop.v4); |
775 | 748 | inet_ntop(AF_INET, &r->bgp_nexthop.v4, as, sizeof(as)); |
776 | 749 | as[IP_STRING_LEN-1] = 0; |
785 | 758 | break; |
786 | 759 | case EX_NEXT_HOP_BGP_v6: |
787 | 760 | 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 | } | |
793 | 761 | r->bgp_nexthop.v6[0] = htonll(r->bgp_nexthop.v6[0]); |
794 | 762 | r->bgp_nexthop.v6[1] = htonll(r->bgp_nexthop.v6[1]); |
795 | 763 | inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as)); |
893 | 861 | } break; |
894 | 862 | case EX_ROUTER_IP_v4: |
895 | 863 | as[0] = 0; |
896 | if ( anon ) { | |
897 | r->ip_router.v4 = anonymize(r->ip_router.v4); | |
898 | } | |
899 | 864 | r->ip_router.v4 = htonl(r->ip_router.v4); |
900 | 865 | inet_ntop(AF_INET, &r->ip_router.v4, as, sizeof(as)); |
901 | 866 | as[IP_STRING_LEN-1] = 0; |
910 | 875 | break; |
911 | 876 | case EX_ROUTER_IP_v6: |
912 | 877 | 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 | } | |
918 | 878 | r->ip_router.v6[0] = htonll(r->ip_router.v6[0]); |
919 | 879 | r->ip_router.v6[1] = htonll(r->ip_router.v6[1]); |
920 | 880 | inet_ntop(AF_INET6, &r->ip_router.v6, as, sizeof(as)); |
954 | 914 | |
955 | 915 | } // End of format_file_block_record |
956 | 916 | |
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) { | |
959 | 918 | uint32_t sa[4], da[4]; |
960 | 919 | int af; |
961 | 920 | master_record_t *r = (master_record_t *)record; |
962 | 921 | |
963 | 922 | 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 | } | |
973 | 923 | af = PF_INET6; |
974 | 924 | } else { // IPv4 |
975 | if ( anon ) { | |
976 | r->v4.srcaddr = anonymize(r->v4.srcaddr); | |
977 | r->v4.dstaddr = anonymize(r->v4.dstaddr); | |
978 | } | |
979 | 925 | af = PF_INET; |
980 | 926 | } |
981 | 927 | |
1002 | 948 | |
1003 | 949 | } // End of flow_record_pipe |
1004 | 950 | |
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) { | |
1007 | 952 | char *_s, as[IP_STRING_LEN], ds[IP_STRING_LEN]; |
1008 | 953 | char proto_str[MAX_PROTO_STR], datestr1[64], datestr2[64], flags_str[16]; |
1009 | 954 | char s_snet[IP_STRING_LEN], s_dnet[IP_STRING_LEN]; |
1018 | 963 | uint64_t snet[2]; |
1019 | 964 | uint64_t dnet[2]; |
1020 | 965 | |
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 | } | |
1030 | 966 | // remember IPs for network |
1031 | 967 | snet[0] = r->v6.srcaddr[0]; |
1032 | 968 | snet[1] = r->v6.srcaddr[1]; |
1067 | 1003 | |
1068 | 1004 | } else { // IPv4 |
1069 | 1005 | uint32_t snet, dnet; |
1070 | if ( anon ) { | |
1071 | r->v4.srcaddr = anonymize(r->v4.srcaddr); | |
1072 | r->v4.dstaddr = anonymize(r->v4.dstaddr); | |
1073 | } | |
1074 | 1006 | snet = r->v4.srcaddr; |
1075 | 1007 | dnet = r->v4.dstaddr; |
1076 | 1008 | r->v4.srcaddr = htonl(r->v4.srcaddr); |
1155 | 1087 | if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6 |
1156 | 1088 | // EX_NEXT_HOP_v6: |
1157 | 1089 | 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 | } | |
1163 | 1090 | r->ip_nexthop.v6[0] = htonll(r->ip_nexthop.v6[0]); |
1164 | 1091 | r->ip_nexthop.v6[1] = htonll(r->ip_nexthop.v6[1]); |
1165 | 1092 | inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as)); |
1173 | 1100 | } else { |
1174 | 1101 | // EX_NEXT_HOP_v4: |
1175 | 1102 | as[0] = 0; |
1176 | if ( anon ) { | |
1177 | r->ip_nexthop.v4 = anonymize(r->ip_nexthop.v4); | |
1178 | } | |
1179 | 1103 | r->ip_nexthop.v4 = htonl(r->ip_nexthop.v4); |
1180 | 1104 | inet_ntop(AF_INET, &r->ip_nexthop.v4, as, sizeof(as)); |
1181 | 1105 | as[IP_STRING_LEN-1] = 0; |
1189 | 1113 | if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6 |
1190 | 1114 | // EX_NEXT_HOP_BGP_v6: |
1191 | 1115 | 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 | } | |
1197 | 1116 | r->bgp_nexthop.v6[0] = htonll(r->bgp_nexthop.v6[0]); |
1198 | 1117 | r->bgp_nexthop.v6[1] = htonll(r->bgp_nexthop.v6[1]); |
1199 | 1118 | inet_ntop(AF_INET6, r->ip_nexthop.v6, as, sizeof(as)); |
1207 | 1126 | } else { |
1208 | 1127 | // EX_NEXT_HOP_BGP_v4: |
1209 | 1128 | as[0] = 0; |
1210 | if ( anon ) { | |
1211 | r->bgp_nexthop.v4 = anonymize(r->bgp_nexthop.v4); | |
1212 | } | |
1213 | 1129 | r->bgp_nexthop.v4 = htonl(r->bgp_nexthop.v4); |
1214 | 1130 | inet_ntop(AF_INET, &r->bgp_nexthop.v4, as, sizeof(as)); |
1215 | 1131 | as[IP_STRING_LEN-1] = 0; |
1291 | 1207 | if ( (r->flags & FLAG_IPV6_EXP ) != 0 ) { // IPv6 |
1292 | 1208 | // EX_NEXT_HOP_v6: |
1293 | 1209 | 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 | } | |
1299 | 1210 | r->ip_router.v6[0] = htonll(r->ip_router.v6[0]); |
1300 | 1211 | r->ip_router.v6[1] = htonll(r->ip_router.v6[1]); |
1301 | 1212 | inet_ntop(AF_INET6, r->ip_router.v6, as, sizeof(as)); |
1309 | 1220 | } else { |
1310 | 1221 | // EX_NEXT_HOP_v4: |
1311 | 1222 | as[0] = 0; |
1312 | if ( anon ) { | |
1313 | r->ip_router.v4 = anonymize(r->ip_router.v4); | |
1314 | } | |
1315 | 1223 | r->ip_router.v4 = htonl(r->ip_router.v4); |
1316 | 1224 | inet_ntop(AF_INET, &r->ip_router.v4, as, sizeof(as)); |
1317 | 1225 | as[IP_STRING_LEN-1] = 0; |
1335 | 1243 | |
1336 | 1244 | } // End of flow_record_to_csv |
1337 | 1245 | |
1338 | void format_special(void *record, char ** s, int anon, int tag) { | |
1246 | void format_special(void *record, char ** s, int tag) { | |
1339 | 1247 | master_record_t *r = (master_record_t *)record; |
1340 | 1248 | int i, index; |
1341 | 1249 | |
1342 | do_anonymize = anon; | |
1343 | 1250 | do_tag = tag; |
1344 | 1251 | tag_string[0] = do_tag ? TAG_CHAR : '\0'; |
1345 | 1252 | tag_string[1] = '\0'; |
1631 | 1538 | if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6 |
1632 | 1539 | uint64_t ip[2]; |
1633 | 1540 | |
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]); | |
1643 | 1543 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1644 | 1544 | if ( ! long_v6 ) { |
1645 | 1545 | condense_v6(tmp_str); |
1646 | 1546 | } |
1647 | 1547 | } else { // IPv4 |
1648 | 1548 | uint32_t ip; |
1649 | ip = do_anonymize ? anonymize(r->v4.srcaddr) : r->v4.srcaddr; | |
1650 | ip = htonl(ip); | |
1549 | ip = htonl(r->v4.srcaddr); | |
1651 | 1550 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1652 | 1551 | } |
1653 | 1552 | tmp_str[IP_STRING_LEN-1] = 0; |
1668 | 1567 | if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6 |
1669 | 1568 | uint64_t ip[2]; |
1670 | 1569 | |
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]); | |
1680 | 1572 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1681 | 1573 | if ( ! long_v6 ) { |
1682 | 1574 | condense_v6(tmp_str); |
1684 | 1576 | portchar = '.'; |
1685 | 1577 | } else { // IPv4 |
1686 | 1578 | uint32_t ip; |
1687 | ip = do_anonymize ? anonymize(r->v4.srcaddr) : r->v4.srcaddr; | |
1688 | ip = htonl(ip); | |
1579 | ip = htonl(r->v4.srcaddr); | |
1689 | 1580 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1690 | 1581 | portchar = ':'; |
1691 | 1582 | } |
1707 | 1598 | if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6 |
1708 | 1599 | uint64_t ip[2]; |
1709 | 1600 | |
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]); | |
1719 | 1603 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1720 | 1604 | if ( ! long_v6 ) { |
1721 | 1605 | condense_v6(tmp_str); |
1722 | 1606 | } |
1723 | 1607 | } else { // IPv4 |
1724 | 1608 | uint32_t ip; |
1725 | ip = do_anonymize ? anonymize(r->v4.dstaddr) : r->v4.dstaddr; | |
1726 | ip = htonl(ip); | |
1609 | ip = htonl(r->v4.dstaddr); | |
1727 | 1610 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1728 | 1611 | } |
1729 | 1612 | tmp_str[IP_STRING_LEN-1] = 0; |
1745 | 1628 | if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6 |
1746 | 1629 | uint64_t ip[2]; |
1747 | 1630 | |
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]); | |
1757 | 1633 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1758 | 1634 | if ( ! long_v6 ) { |
1759 | 1635 | condense_v6(tmp_str); |
1760 | 1636 | } |
1761 | 1637 | } else { // IPv4 |
1762 | 1638 | 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); | |
1765 | 1640 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1766 | 1641 | } |
1767 | 1642 | tmp_str[IP_STRING_LEN-1] = 0; |
1782 | 1657 | if ( (r->flags & FLAG_IPV6_NH ) != 0 ) { // IPv6 |
1783 | 1658 | uint64_t ip[2]; |
1784 | 1659 | |
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]); | |
1794 | 1662 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1795 | 1663 | if ( ! long_v6 ) { |
1796 | 1664 | condense_v6(tmp_str); |
1797 | 1665 | } |
1798 | 1666 | } else { // IPv4 |
1799 | 1667 | 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); | |
1802 | 1669 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1803 | 1670 | } |
1804 | 1671 | tmp_str[IP_STRING_LEN-1] = 0; |
1819 | 1686 | if ( (r->flags & FLAG_IPV6_EXP ) != 0 ) { // IPv6 |
1820 | 1687 | uint64_t ip[2]; |
1821 | 1688 | |
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]); | |
1831 | 1691 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1832 | 1692 | if ( ! long_v6 ) { |
1833 | 1693 | condense_v6(tmp_str); |
1834 | 1694 | } |
1835 | 1695 | } else { // IPv4 |
1836 | 1696 | 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); | |
1839 | 1698 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1840 | 1699 | } |
1841 | 1700 | tmp_str[IP_STRING_LEN-1] = 0; |
1858 | 1717 | if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6 |
1859 | 1718 | uint64_t ip[2]; |
1860 | 1719 | |
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]); | |
1870 | 1722 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1871 | 1723 | if ( ! long_v6 ) { |
1872 | 1724 | condense_v6(tmp_str); |
1874 | 1726 | portchar = '.'; |
1875 | 1727 | } else { // IPv4 |
1876 | 1728 | uint32_t ip; |
1877 | ip = do_anonymize ? anonymize(r->v4.dstaddr) : r->v4.dstaddr; | |
1878 | ip = htonl(ip); | |
1729 | ip = htonl(r->v4.dstaddr); | |
1879 | 1730 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1880 | 1731 | portchar = ':'; |
1881 | 1732 | } |
1900 | 1751 | if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6 |
1901 | 1752 | uint64_t ip[2]; |
1902 | 1753 | |
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]); | |
1912 | 1756 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1913 | 1757 | if ( ! long_v6 ) { |
1914 | 1758 | condense_v6(tmp_str); |
1915 | 1759 | } |
1916 | 1760 | } else { // IPv4 |
1917 | 1761 | uint32_t ip; |
1918 | ip = do_anonymize ? anonymize(r->v4.srcaddr) : r->v4.srcaddr; | |
1919 | ip = htonl(ip); | |
1762 | ip = htonl(r->v4.srcaddr); | |
1920 | 1763 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1921 | 1764 | } |
1922 | 1765 | tmp_str[IP_STRING_LEN-1] = 0; |
1939 | 1782 | if ( (r->flags & FLAG_IPV6_ADDR ) != 0 ) { // IPv6 |
1940 | 1783 | uint64_t ip[2]; |
1941 | 1784 | |
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]); | |
1951 | 1787 | inet_ntop(AF_INET6, ip, tmp_str, sizeof(tmp_str)); |
1952 | 1788 | if ( ! long_v6 ) { |
1953 | 1789 | condense_v6(tmp_str); |
1954 | 1790 | } |
1955 | 1791 | } else { // IPv4 |
1956 | 1792 | uint32_t ip; |
1957 | ip = do_anonymize ? anonymize(r->v4.dstaddr) : r->v4.dstaddr; | |
1958 | ip = htonl(ip); | |
1793 | ip = htonl(r->v4.dstaddr); | |
1959 | 1794 | inet_ntop(AF_INET, &ip, tmp_str, sizeof(tmp_str)); |
1960 | 1795 | } |
1961 | 1796 | tmp_str[IP_STRING_LEN-1] = 0; |
39 | 39 | #define _NF_COMMON_H 1 |
40 | 40 | |
41 | 41 | |
42 | typedef void (*printer_t)(void *, char **, int, int); | |
42 | typedef void (*printer_t)(void *, char **, int); | |
43 | 43 | |
44 | 44 | #if ( SIZEOF_VOID_P == 8 ) |
45 | 45 | typedef uint64_t pointer_addr_t; |
91 | 91 | |
92 | 92 | int Proto_num(char *protostr); |
93 | 93 | |
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); | |
95 | 95 | |
96 | 96 | char *format_csv_header(void); |
97 | 97 | |
99 | 99 | |
100 | 100 | void set_record_header(void); |
101 | 101 | |
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); | |
103 | 103 | |
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); | |
105 | 105 | |
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); | |
107 | 107 | |
108 | 108 | int ParseOutputFormat(char *format, int plain_numbers); |
109 | 109 | |
110 | void format_special(void *record, char ** s, int anon, int tag); | |
110 | void format_special(void *record, char ** s, int tag); | |
111 | 111 | |
112 | 112 | |
113 | 113 | 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 | } |
387 | 387 | fs = FlowSource; |
388 | 388 | while ( fs ) { |
389 | 389 | |
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 | ||
399 | 390 | // 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 ) { | |
402 | 393 | syslog(LOG_ERR, "%s", string); |
403 | 394 | return; |
404 | 395 | } |
500 | 491 | |
501 | 492 | if ( verbose ) { |
502 | 493 | // 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); | |
504 | 495 | printf("%s\n", string); |
505 | 496 | } |
506 | 497 | |
507 | if ( fs->nffile.block_header->NumRecords ) { | |
498 | if ( fs->nffile->block_header->NumRecords ) { | |
508 | 499 | // flush current buffer to disc |
509 | if ( WriteBlock(&(fs->nffile)) <= 0 ) | |
500 | if ( WriteBlock(fs->nffile) <= 0 ) | |
510 | 501 | syslog(LOG_ERR, "Ident: %s, failed to write output buffer to disk: '%s'" , fs->Ident, strerror(errno)); |
511 | 502 | else |
512 | 503 | // update successful written blocks |
513 | fs->nffile.file_blocks++; | |
504 | fs->nffile->file_header->NumBlocks++; | |
514 | 505 | } // else - no new records in current block |
515 | 506 | |
516 | 507 | |
525 | 516 | fs->stat_record.msec_last = fs->last_seen - fs->stat_record.last_seen*1000; |
526 | 517 | |
527 | 518 | // 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 ); | |
529 | 520 | if ( string != NULL ) { |
530 | 521 | // closing the file failed. maybe disk full ?? |
531 | 522 | syslog(LOG_ERR, "Ident: %s, %s", fs->Ident, string); |
532 | 523 | } |
533 | ||
524 | ||
534 | 525 | if ( subdir && !SetupSubDir(fs->datadir, subdir, error, 255) ) { |
535 | 526 | // in this case the flows get lost! - the rename will fail |
536 | 527 | // but this should not happen anyway, unless i/o problems, inode problems etc. |
563 | 554 | fs->Ident, (unsigned long long)fs->stat_record.numflows, (unsigned long long)fs->stat_record.numpackets, |
564 | 555 | (unsigned long long)fs->stat_record.numbytes, fs->stat_record.sequence_failure, fs->bad_packets); |
565 | 556 | |
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 | ||
571 | 557 | // reset stat record |
572 | 558 | memset((void *)&fs->stat_record, 0, sizeof(stat_record_t)); |
573 | 559 | fs->bad_packets = 0; |
574 | 560 | fs->first_seen = 0xffffffffffffLL; |
575 | 561 | 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 | } | |
577 | 571 | |
578 | 572 | // Dump all extension maps to the buffer |
579 | 573 | 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 | } | |
591 | 574 | |
592 | 575 | // next flow source |
593 | 576 | fs = fs->next; |
710 | 693 | export_packets++; |
711 | 694 | |
712 | 695 | // flush current buffer to disc |
713 | if ( fs->nffile.block_header->size > BUFFSIZE ) { | |
696 | if ( fs->nffile->block_header->size > BUFFSIZE ) { | |
714 | 697 | // fishy! - we already wrote into someone elses memory! - I'm sorry |
715 | 698 | // 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) ); | |
719 | 702 | syslog(LOG_ERR, "### Software bug ### Ident: %s, output buffer overflow: expect memory inconsitency", fs->Ident); |
720 | 703 | } |
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 | */ | |
733 | 704 | } |
734 | 705 | |
735 | 706 | if ( verbose && blast_failures ) { |
739 | 710 | |
740 | 711 | fs = FlowSource; |
741 | 712 | while ( fs ) { |
742 | free((void *)fs->nffile.block_header); | |
713 | DisposeFile(fs->nffile); | |
743 | 714 | fs = fs->next; |
744 | 715 | } |
745 | 716 | |
1144 | 1115 | exit(255); |
1145 | 1116 | } |
1146 | 1117 | |
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 | ||
1154 | 1118 | fs = fs->next; |
1155 | 1119 | } |
1156 | 1120 |
74 | 74 | #include "version.h" |
75 | 75 | #include "util.h" |
76 | 76 | #include "flist.h" |
77 | #include "panonymizer.h" | |
78 | 77 | |
79 | 78 | /* hash parameters */ |
80 | 79 | #define NumPrealloc 128000 |
226 | 225 | /* Function Prototypes */ |
227 | 226 | static void usage(char *name); |
228 | 227 | |
229 | static int ParseCryptoPAnKey ( char *s, char *key ); | |
230 | ||
231 | 228 | static void PrintSummary(stat_record_t *stat_record, int plain_numbers, int csv_output); |
232 | 229 | |
233 | 230 | |
234 | 231 | static stat_record_t process_data(char *wfile, int element_stat, int flow_stat, int sort_flows, |
235 | 232 | 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); | |
237 | 234 | |
238 | 235 | /* Functions */ |
239 | 236 | |
263 | 260 | "-j <file>\tCompress/Uncompress file.\n" |
264 | 261 | "-z\t\tCompress flows in output file. Used in combination with -w.\n" |
265 | 262 | "-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" | |
267 | 263 | "\t\tkey: 32 character string or 64 digit hex string starting with 0x.\n" |
268 | 264 | "-L <expr>\tSet limit on bytes for line and packed output format.\n" |
269 | 265 | "-I \t\tPrint netflow summary statistics info from file, specified by -r.\n" |
291 | 287 | "\t\tyyyy/MM/dd.hh:mm:ss[-yyyy/MM/dd.hh:mm:ss]\n", name); |
292 | 288 | } /* usage */ |
293 | 289 | |
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 | |
322 | 290 | |
323 | 291 | static void PrintSummary(stat_record_t *stat_record, int plain_numbers, int csv_output) { |
324 | 292 | static double duration; |
359 | 327 | |
360 | 328 | stat_record_t process_data(char *wfile, int element_stat, int flow_stat, int sort_flows, |
361 | 329 | 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) { | |
363 | 331 | data_block_header_t in_block_header; |
364 | 332 | common_record_t *flow_record, *in_buff; |
365 | 333 | master_record_t *master_record; |
366 | nffile_t nffile; | |
334 | nffile_t *nffile; | |
367 | 335 | stat_record_t stat_record; |
368 | int rfd, done, write_file, is_stdout; | |
336 | int rfd, done, write_file; | |
369 | 337 | char *string; |
370 | 338 | |
371 | 339 | #ifdef COMPAT15 |
399 | 367 | // do not write flows to file, when doing any stats |
400 | 368 | // -w may apply for flow_stats later |
401 | 369 | write_file = !(sort_flows || flow_stat || element_stat) && wfile; |
402 | // is the file stdout? | |
403 | is_stdout = wfile && ( strcmp(wfile, "-") == 0 ); | |
370 | nffile = NULL; | |
404 | 371 | |
405 | 372 | // allocate network buffer |
406 | 373 | in_buff = (common_record_t *) malloc(BUFFSIZE); |
418 | 385 | return stat_record; |
419 | 386 | } |
420 | 387 | |
421 | memset((void *)&nffile, 0, sizeof(nffile)); | |
422 | 388 | // 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 | } | |
428 | 399 | } |
429 | 400 | |
430 | 401 | // setup Filter Engine to point to master_record, as any record read from file |
490 | 461 | map->extension_size += extension_descriptor[EX_IO_SNMP_2].size; |
491 | 462 | map->extension_size += extension_descriptor[EX_AS_2].size; |
492 | 463 | |
493 | if ( Insert_Extension_Map(&extension_map_list,map) && nffile.wfd ) { | |
464 | if ( Insert_Extension_Map(&extension_map_list,map) && write_file ) { | |
494 | 465 | // flush new map |
495 | AppendToBuffer(&nffile, (void *)map, map->size); | |
466 | AppendToBuffer(nffile, (void *)map, map->size); | |
496 | 467 | } // else map already known and flushed |
497 | 468 | |
498 | 469 | v1_map_done = 1; |
581 | 552 | } else { |
582 | 553 | |
583 | 554 | |
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); | |
604 | 557 | } else if ( print_record ) { |
605 | 558 | |
606 | 559 | // if we need to print out this record |
607 | print_record(master_record, &string, anon, tag); | |
560 | print_record(master_record, &string, tag); | |
608 | 561 | if ( string ) { |
609 | 562 | if ( limitflows ) { |
610 | 563 | if ( (stat_record.numflows <= limitflows) ) |
622 | 575 | } else if ( flow_record->type == ExtensionMapType ) { |
623 | 576 | extension_map_t *map = (extension_map_t *)flow_record; |
624 | 577 | |
625 | if ( Insert_Extension_Map(&extension_map_list, map) && nffile.wfd ) { | |
578 | if ( Insert_Extension_Map(&extension_map_list, map) && write_file ) { | |
626 | 579 | // flush new map |
627 | AppendToBuffer(&nffile, (void *)map, map->size); | |
580 | AppendToBuffer(nffile, (void *)map, map->size); | |
628 | 581 | } // else map already known and flushed |
629 | 582 | } else { |
630 | 583 | fprintf(stderr, "Skip unknown record type %i\n", flow_record->type); |
646 | 599 | close(rfd); |
647 | 600 | |
648 | 601 | // flush output file |
649 | if ( nffile.wfd ) { | |
602 | if ( write_file ) { | |
650 | 603 | // 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 ) { | |
653 | 606 | fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno)); |
654 | 607 | } else { |
655 | nffile.file_blocks++; | |
608 | nffile->file_header->NumBlocks++; | |
656 | 609 | } |
657 | 610 | } |
658 | 611 | |
659 | 612 | /* Stat info */ |
660 | 613 | if ( write_file ) { |
661 | 614 | /* 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 ); | |
663 | 616 | if ( string != NULL ) |
664 | 617 | fprintf(stderr, "%s\n", string); |
618 | nffile = DisposeFile(nffile); | |
665 | 619 | } // else stdout |
666 | 620 | } |
667 | 621 | |
683 | 637 | char *order_by, *query_file, *UnCompress_file, *nameserver, *aggr_fmt; |
684 | 638 | int c, ffd, ret, element_stat, fdump; |
685 | 639 | 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; | |
687 | 641 | int plain_numbers, GuessDir, pipe_output, csv_output; |
688 | 642 | time_t t_start, t_end; |
689 | 643 | uint16_t Aggregate_Bits; |
690 | 644 | uint32_t limitflows; |
691 | 645 | uint64_t AggregateMasks[AGGR_SIZE]; |
692 | 646 | char Ident[IdentLen]; |
693 | char CryptoPAnKey[32]; | |
694 | 647 | |
695 | 648 | rfile = Rfile = Mdirs = wfile = ffile = filter = tstring = stat_type = NULL; |
696 | 649 | byte_limit_string = packet_limit_string = NULL; |
708 | 661 | total_bytes = 0; |
709 | 662 | total_flows = 0; |
710 | 663 | skipped_blocks = 0; |
711 | do_anonymize = 0; | |
712 | 664 | do_tag = 0; |
713 | 665 | quiet = 0; |
714 | 666 | user_format = 0; |
798 | 750 | packet_limit_string = optarg; |
799 | 751 | break; |
800 | 752 | 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); | |
806 | 755 | break; |
807 | 756 | case 'L': |
808 | 757 | byte_limit_string = optarg; |
1118 | 1067 | } |
1119 | 1068 | } |
1120 | 1069 | |
1121 | if (do_anonymize) | |
1122 | PAnonymizer_Init((uint8_t *)CryptoPAnKey); | |
1123 | ||
1124 | 1070 | nfprof_start(&profile_data); |
1125 | 1071 | sum_stat = process_data(wfile, element_stat, aggregate || flow_stat, date_sorted, |
1126 | 1072 | print_header, print_record, t_start, t_end, |
1127 | limitflows, do_anonymize, do_tag, compress); | |
1073 | limitflows, do_tag, compress); | |
1128 | 1074 | nfprof_end(&profile_data, total_flows); |
1129 | 1075 | |
1130 | 1076 | if ( total_bytes == 0 ) |
1133 | 1079 | |
1134 | 1080 | if (aggregate || date_sorted) { |
1135 | 1081 | if ( wfile ) { |
1136 | ExportFlowTable(wfile, compress, aggregate, bidir, date_sorted, do_anonymize); | |
1082 | ExportFlowTable(wfile, compress, aggregate, bidir, date_sorted); | |
1137 | 1083 | } else { |
1138 | PrintFlowTable(print_record, limitflows, date_sorted, do_anonymize, do_tag, GuessDir); | |
1084 | PrintFlowTable(print_record, limitflows, date_sorted, do_tag, GuessDir); | |
1139 | 1085 | } |
1140 | 1086 | } |
1141 | 1087 | |
1142 | 1088 | 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); | |
1144 | 1090 | #ifdef DEVEL |
1145 | 1091 | printf("Loopcnt: %u\n", loopcnt); |
1146 | 1092 | #endif |
1147 | 1093 | } |
1148 | 1094 | |
1149 | 1095 | 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); | |
1151 | 1097 | } |
1152 | 1098 | |
1153 | 1099 | if ( !quiet ) { |
1154 | 1100 | if ( csv_output ) { |
1155 | 1101 | PrintSummary(&sum_stat, plain_numbers, csv_output); |
1156 | 1102 | } else if ( !wfile ) { |
1157 | if (do_anonymize) | |
1158 | printf("IP addresses anonymized\n"); | |
1103 | if (IsAnonymized()) | |
1104 | printf("IP addresses anonymised\n"); | |
1159 | 1105 | PrintSummary(&sum_stat, plain_numbers, csv_output); |
1160 | 1106 | printf("Time window: %s\n", TimeString(t_first_flow, t_last_flow)); |
1161 | 1107 | printf("Total flows processed: %u, Blocks skipped: %u, Bytes read: %llu\n", |
137 | 137 | num_extensions++; |
138 | 138 | } |
139 | 139 | #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); | |
142 | 142 | #endif |
143 | 143 | |
144 | 144 | // count missing extensions |
153 | 153 | opt_extensions++; |
154 | 154 | |
155 | 155 | // 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 | |
156 | 161 | if ( opt_extensions ) { |
157 | new_map_size = sizeof(extension_map_t) + ( num_extensions + opt_extensions ) * sizeof(uint16_t); | |
158 | 162 | // align 32bits |
159 | 163 | if (( new_map_size & 0x3 ) != 0 ) { |
160 | 164 | new_map_size += 4 - ( new_map_size & 0x3 ); |
231 | 235 | |
232 | 236 | } // End of CreateExportExtensionMaps |
233 | 237 | |
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) { | |
235 | 239 | hash_FlowTable *FlowTable; |
236 | 240 | FlowTableRecord_t *r; |
237 | 241 | SortElement_t *SortList; |
238 | 242 | stat_record_t stat_record; |
239 | nffile_t nffile; | |
243 | nffile_t *nffile; | |
240 | 244 | uint32_t i; |
241 | 245 | uint32_t maxindex, c; |
242 | 246 | char *string; |
243 | 247 | |
244 | // Init new stat record | |
248 | // Init | |
245 | 249 | memset((void *)&stat_record, 0, sizeof(stat_record_t)); |
246 | 250 | stat_record.first_seen = 0x7fffffff; |
247 | 251 | stat_record.msec_first = 999; |
248 | 252 | |
249 | 253 | // 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); | |
251 | 257 | return; |
252 | ||
253 | CreateExportExtensionMaps(aggregate, bidir, &nffile); | |
258 | } | |
259 | ||
260 | CreateExportExtensionMaps(aggregate, bidir, nffile); | |
254 | 261 | |
255 | 262 | FlowTable = GetFlowTable(); |
256 | 263 | c = 0; |
288 | 295 | heapSort(SortList, c, 0); |
289 | 296 | |
290 | 297 | for ( i = 0; i < c; i++ ) { |
291 | master_record_t flow_record; | |
298 | master_record_t *flow_record; | |
292 | 299 | common_record_t *raw_record; |
293 | 300 | int map_id; |
294 | 301 | |
296 | 303 | raw_record = &(r->flowrecord); |
297 | 304 | map_id = r->map_ref->map_id; |
298 | 305 | |
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]; | |
305 | 313 | |
306 | 314 | // apply IP mask from aggregation, to provide a pretty output |
307 | 315 | 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]; | |
312 | 320 | } |
313 | 321 | |
314 | 322 | if ( FlowTable->apply_netbits ) |
315 | ApplyNetMaskBits(&flow_record, FlowTable->apply_netbits); | |
323 | ApplyNetMaskBits(flow_record, FlowTable->apply_netbits); | |
316 | 324 | |
317 | 325 | // 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); | |
323 | 331 | printf("%s\n", string); |
324 | 332 | #endif |
325 | 333 | // Update statistics |
326 | UpdateStat(&stat_record, &flow_record); | |
334 | UpdateStat(&stat_record, flow_record); | |
327 | 335 | } |
328 | 336 | |
329 | 337 | } else { |
331 | 339 | for ( i=0; i<FlowTable->IndexMask; i++ ) { |
332 | 340 | r = FlowTable->bucket[i]; |
333 | 341 | while ( r ) { |
334 | master_record_t flow_record; | |
342 | master_record_t *flow_record; | |
335 | 343 | common_record_t *raw_record; |
336 | 344 | int map_id; |
337 | 345 | |
338 | 346 | raw_record = &(r->flowrecord); |
339 | 347 | map_id = r->map_ref->map_id; |
340 | 348 | |
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]; | |
347 | 356 | |
348 | 357 | // apply IP mask from aggregation, to provide a pretty output |
349 | 358 | 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]; | |
354 | 363 | } |
355 | 364 | |
356 | 365 | |
357 | 366 | // 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); | |
363 | 372 | printf("%s\n", string); |
364 | 373 | #endif |
365 | 374 | // Update statistics |
366 | UpdateStat(&stat_record, &flow_record); | |
375 | UpdateStat(&stat_record, flow_record); | |
367 | 376 | |
368 | 377 | r = r->next; |
369 | 378 | } |
371 | 380 | |
372 | 381 | } |
373 | 382 | |
374 | if ( nffile.block_header->NumRecords ) { | |
375 | if ( WriteBlock(&nffile) <= 0 ) { | |
383 | if ( nffile->block_header->NumRecords ) { | |
384 | if ( WriteBlock(nffile) <= 0 ) { | |
376 | 385 | fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno)); |
377 | 386 | } |
378 | 387 | } |
379 | 388 | |
380 | CloseUpdateFile(nffile.wfd, &stat_record, nffile.file_blocks, GetIdent(), nffile.compress, &string ); | |
389 | CloseUpdateFile(nffile, &stat_record, GetIdent(), &string ); | |
381 | 390 | if ( string != NULL ) |
382 | 391 | fprintf(stderr, "%s\n", string); |
392 | nffile = DisposeFile(nffile); | |
383 | 393 | |
384 | 394 | } // End of PrintFlowTable |
385 | 395 |
37 | 37 | #ifndef _NFEXPORT_H |
38 | 38 | #define _NFEXPORT_H 1 |
39 | 39 | |
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); | |
41 | 41 | |
42 | 42 | #endif //_NFEXPORT_H |
43 | 43 |
87 | 87 | |
88 | 88 | static void ZeroStat(void); |
89 | 89 | |
90 | static int WriteSTDOUTFileheader(void); | |
91 | ||
92 | 90 | /* function definitions */ |
93 | 91 | |
94 | 92 | static void ZeroStat() { |
140 | 138 | s2->msec_last > s1->msec_last ) |
141 | 139 | s1->msec_last = s2->msec_last; |
142 | 140 | |
143 | } // End of AddStatRecords | |
141 | } // End of SumStatRecords | |
144 | 142 | |
145 | 143 | |
146 | 144 | char *GetIdent(void) { |
148 | 146 | return CurrentIdent; |
149 | 147 | |
150 | 148 | } // 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 | |
151 | 157 | |
152 | 158 | static int LZO_initialize(void) { |
153 | 159 | |
155 | 161 | // this usually indicates a compiler bug - try recompiling |
156 | 162 | // without optimizations, and enable `-DLZO_DEBUG' for diagnostics |
157 | 163 | snprintf(error_string, ERR_SIZE,"Compression lzo_init() failed.\n"); |
158 | error_string[ERR_SIZE-1] = 0; | |
159 | 164 | return 0; |
160 | 165 | } |
161 | 166 | lzo_buff = malloc(BUFFSIZE+ sizeof(data_block_header_t)); |
373 | 378 | printf("Sequence failures: %u\n", s->sequence_failure); |
374 | 379 | } // End of PrintStat |
375 | 380 | |
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; | |
378 | 388 | |
379 | 389 | // Init vars |
380 | nffile->block_header = NULL; | |
381 | 390 | nffile->writeto = NULL; |
382 | nffile->file_blocks = 0; | |
383 | nffile->compress = compress; | |
384 | 391 | nffile->wfd = 0; |
385 | 392 | |
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 | |
410 | 394 | nffile->block_header->size = 0; |
411 | 395 | nffile->block_header->NumRecords = 0; |
412 | 396 | nffile->block_header->id = DATA_BLOCK_TYPE_2; |
413 | 397 | nffile->block_header->pad = 0; |
414 | 398 | nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t)); |
415 | 399 | |
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; | |
421 | 442 | 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; | |
423 | 510 | |
424 | 511 | *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); | |
471 | 528 | file_header.ident[IdentLen - 1] = 0; |
472 | 529 | |
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 ) { | |
484 | 533 | snprintf(error_string, ERR_SIZE,"close failed: '%s'" , strerror(errno)); |
485 | 534 | error_string[ERR_SIZE-1] = 0; |
486 | 535 | *err = error_string; |
606 | 655 | lzo_uint in_len; |
607 | 656 | lzo_uint out_len; |
608 | 657 | |
609 | if ( !nffile->compress ) { | |
658 | if ( !TestFlag(nffile->file_header->flags, FLAG_COMPRESSED) ) { | |
610 | 659 | return write(nffile->wfd, (void *)nffile->block_header, sizeof(data_block_header_t) + nffile->block_header->size); |
611 | 660 | } |
612 | 661 | |
688 | 737 | } // End of ExpandRecord_v1 |
689 | 738 | |
690 | 739 | void UnCompressFile(char * filename) { |
691 | int i, rfd; | |
740 | int i, rfd, flags, compressed, anonymized; | |
692 | 741 | ssize_t ret; |
693 | nffile_t nffile; | |
742 | nffile_t *nffile; | |
694 | 743 | stat_record_t *stat_ptr; |
695 | 744 | char *string; |
696 | 745 | char outfile[MAXPATHLEN]; |
706 | 755 | snprintf(outfile, MAXPATHLEN, "%s-tmp", filename); |
707 | 756 | outfile[MAXPATHLEN-1] = '\0'; |
708 | 757 | |
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); | |
713 | 772 | close(rfd); |
714 | 773 | return; |
715 | 774 | } |
716 | 775 | |
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)); | |
731 | 777 | |
732 | 778 | 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); | |
734 | 780 | if ( ret < 0 ) { |
735 | 781 | fprintf(stderr, "Error while reading data block. Abort.\n"); |
736 | 782 | close(rfd); |
737 | close(nffile.wfd); | |
783 | close(nffile->wfd); | |
738 | 784 | unlink(outfile); |
739 | 785 | return; |
740 | 786 | } |
741 | if ( WriteBlock(&nffile) <= 0 ) { | |
787 | if ( WriteBlock(nffile) <= 0 ) { | |
742 | 788 | fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno)); |
743 | 789 | close(rfd); |
744 | close(nffile.wfd); | |
790 | close(nffile->wfd); | |
745 | 791 | unlink(outfile); |
746 | 792 | return; |
747 | 793 | } |
748 | 794 | } |
749 | 795 | |
750 | 796 | close(rfd); |
751 | CloseUpdateFile(nffile.wfd, stat_ptr, FileHeader.NumBlocks, GetIdent(), nffile.compress, &string ); | |
797 | CloseUpdateFile(nffile, stat_ptr, GetIdent(), &string ); | |
752 | 798 | if ( string != NULL ) { |
753 | 799 | fprintf(stderr, "%s\n", string); |
754 | close(nffile.wfd); | |
800 | close(nffile->wfd); | |
755 | 801 | unlink(outfile); |
756 | return; | |
757 | 802 | } else { |
758 | close(nffile.wfd); | |
803 | close(nffile->wfd); | |
759 | 804 | unlink(filename); |
760 | 805 | rename(outfile, filename); |
761 | 806 | } |
807 | DisposeFile(nffile); | |
762 | 808 | |
763 | 809 | } // End of UnCompressFile |
764 | 810 | |
812 | 858 | close(fd); |
813 | 859 | |
814 | 860 | } // 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 | |
839 | 861 | |
840 | 862 | #ifdef COMPAT15 |
841 | 863 | /* |
71 | 71 | #define LAYOUT_VERSION_1 1 |
72 | 72 | |
73 | 73 | uint32_t flags; |
74 | #define NUM_FLAGS 2 | |
74 | #define NUM_FLAGS 3 | |
75 | 75 | #define FLAG_COMPRESSED 0x1 |
76 | #define FLAG_EXTENDED_STATS 0x2 | |
76 | #define FLAG_ANONYMIZED 0x2 | |
77 | #define FLAG_EXTENDED_STATS 0x4 | |
77 | 78 | /* |
78 | 79 | 0x1 File is compressed with LZO1X-1 compression |
79 | 80 | */ |
82 | 83 | } file_header_t; |
83 | 84 | |
84 | 85 | /* 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 | |
86 | 87 | * inplicit stat record follows, which contains the statistics |
87 | 88 | * information about all netflow records in this file. |
88 | 89 | */ |
117 | 118 | } stat_record_t; |
118 | 119 | |
119 | 120 | /* 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 | |
123 | 122 | */ |
124 | 123 | |
125 | 124 | typedef struct stat_header_s { |
156 | 155 | * Generic fle handle for writing files |
157 | 156 | */ |
158 | 157 | typedef struct nffile_s { |
158 | file_header_t *file_header; // file header | |
159 | 159 | data_block_header_t *block_header; // output buffer |
160 | 160 | 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 | |
163 | 162 | int wfd; // file id |
164 | 163 | } nffile_t; |
165 | 164 | |
1353 | 1352 | |
1354 | 1353 | int OpenFile(char *filename, stat_record_t **stat_record, char **err); |
1355 | 1354 | |
1356 | int OpenNewFile(char *filename, char **err, int compressed); | |
1355 | nffile_t *OpenNewFile(char *filename, nffile_t *nffile, int compressed, int anonymized, char **err); | |
1357 | 1356 | |
1358 | 1357 | int ChangeIdent(char *filename, char *Ident, char **err); |
1359 | 1358 | |
1361 | 1360 | |
1362 | 1361 | void QueryFile(char *filename); |
1363 | 1362 | |
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 ); | |
1365 | 1368 | |
1366 | 1369 | int ReadBlock(int rfd, data_block_header_t *block_header, void *read_buff, char **err); |
1367 | 1370 | |
1371 | 1374 | |
1372 | 1375 | char *GetIdent(void); |
1373 | 1376 | |
1374 | int InitExportFile(char *filename, int compress, nffile_t *nffile ); | |
1377 | int IsCompressed(void); | |
1378 | ||
1379 | int IsAnonymized(void); | |
1375 | 1380 | |
1376 | 1381 | void ExpandRecord_v1(common_record_t *input_record,master_record_t *output_record ); |
1377 | 1382 |
70 | 70 | nffile->block_header->size = 0; |
71 | 71 | nffile->block_header->NumRecords = 0; |
72 | 72 | nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t) ); |
73 | nffile->file_blocks++; | |
73 | nffile->file_header->NumBlocks++; | |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
359 | 359 | nffile->block_header->size = 0; |
360 | 360 | nffile->block_header->NumRecords = 0; |
361 | 361 | nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t) ); |
362 | nffile->file_blocks++; | |
362 | nffile->file_header->NumBlocks++; | |
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
578 | 578 | |
579 | 579 | } // End of PackRecord |
580 | 580 | |
581 | ||
582 | 581 | static inline void AppendToBuffer(nffile_t *nffile, void *record, size_t required) { |
583 | 582 | |
584 | 583 | // flush current buffer to disc |
597 | 596 | nffile->block_header->size = 0; |
598 | 597 | nffile->block_header->NumRecords = 0; |
599 | 598 | nffile->writeto = (void *)((pointer_addr_t)nffile->block_header + sizeof(data_block_header_t) ); |
600 | nffile->file_blocks++; | |
599 | nffile->file_header->NumBlocks++; | |
601 | 600 | } |
602 | 601 | |
603 | 602 | } |
613 | 612 | nffile->writeto = (void *)((pointer_addr_t)nffile->writeto + required); |
614 | 613 | |
615 | 614 | } // End of AppendToBuffer |
616 |
172 | 172 | |
173 | 173 | int main( int argc, char **argv ) { |
174 | 174 | int i, c; |
175 | file_header_t *file_header; | |
176 | 175 | master_record_t record; |
177 | nffile_t nffile; | |
178 | size_t len; | |
179 | void *records; | |
176 | nffile_t *nffile; | |
177 | char *string; | |
180 | 178 | |
181 | 179 | 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 | ||
189 | 180 | while ((c = getopt(argc, argv, "h")) != EOF) { |
190 | 181 | switch(c) { |
191 | 182 | case 'h': |
235 | 226 | } |
236 | 227 | memset((void *)&record, 0, sizeof(record)); |
237 | 228 | |
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); | |
241 | 232 | exit(255); |
242 | 233 | } |
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); | |
268 | 236 | |
269 | 237 | record.map_ref = extension_info.map; |
270 | 238 | record.type = CommonRecordType; |
314 | 282 | |
315 | 283 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
316 | 284 | UpdateRecord(&record); |
317 | PackRecord(&record, &nffile); | |
285 | PackRecord(&record, nffile); | |
318 | 286 | |
319 | 287 | SetIPaddress(&record, PF_INET, "172.16.2.66", "192.168.170.101"); |
320 | 288 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
321 | 289 | UpdateRecord(&record); |
322 | PackRecord(&record, &nffile); | |
290 | PackRecord(&record, nffile); | |
323 | 291 | |
324 | 292 | record.dPkts = 101; |
325 | 293 | record.dOctets = 102; |
326 | 294 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
327 | 295 | UpdateRecord(&record); |
328 | PackRecord(&record, &nffile); | |
296 | PackRecord(&record, nffile); | |
329 | 297 | |
330 | 298 | SetIPaddress(&record, PF_INET, "172.16.3.66", "192.168.170.102"); |
331 | 299 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
332 | 300 | UpdateRecord(&record); |
333 | PackRecord(&record, &nffile); | |
301 | PackRecord(&record, nffile); | |
334 | 302 | |
335 | 303 | SetIPaddress(&record, PF_INET, "172.16.4.66", "192.168.170.103"); |
336 | 304 | record.srcport = 2024; |
341 | 309 | record.dOctets = 1002; |
342 | 310 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
343 | 311 | UpdateRecord(&record); |
344 | PackRecord(&record, &nffile); | |
312 | PackRecord(&record, nffile); | |
345 | 313 | |
346 | 314 | SetIPaddress(&record, PF_INET, "172.16.5.66", "192.168.170.104"); |
347 | 315 | record.srcport = 3024; |
352 | 320 | record.dOctets = 10002; |
353 | 321 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
354 | 322 | UpdateRecord(&record); |
355 | PackRecord(&record, &nffile); | |
323 | PackRecord(&record, nffile); | |
356 | 324 | |
357 | 325 | SetIPaddress(&record, PF_INET, "172.16.6.66", "192.168.170.105"); |
358 | 326 | record.srcport = 4024; |
363 | 331 | record.dOctets = 100002; |
364 | 332 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
365 | 333 | UpdateRecord(&record); |
366 | PackRecord(&record, &nffile); | |
334 | PackRecord(&record, nffile); | |
367 | 335 | |
368 | 336 | SetIPaddress(&record, PF_INET, "172.16.7.66", "192.168.170.106"); |
369 | 337 | record.srcport = 5024; |
373 | 341 | record.dOctets = 1000002; |
374 | 342 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
375 | 343 | UpdateRecord(&record); |
376 | PackRecord(&record, &nffile); | |
344 | PackRecord(&record, nffile); | |
377 | 345 | |
378 | 346 | SetIPaddress(&record, PF_INET, "172.16.8.66", "192.168.170.107"); |
379 | 347 | record.tcp_flags = 1; |
382 | 350 | record.dOctets = 1001; |
383 | 351 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
384 | 352 | UpdateRecord(&record); |
385 | PackRecord(&record, &nffile); | |
353 | PackRecord(&record, nffile); | |
386 | 354 | |
387 | 355 | SetIPaddress(&record, PF_INET, "172.16.9.66", "192.168.170.108"); |
388 | 356 | record.srcport = 6024; |
392 | 360 | record.dOctets = 10000001; |
393 | 361 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
394 | 362 | UpdateRecord(&record); |
395 | PackRecord(&record, &nffile); | |
363 | PackRecord(&record, nffile); | |
396 | 364 | |
397 | 365 | SetIPaddress(&record, PF_INET, "172.16.10.66", "192.168.170.109"); |
398 | 366 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
399 | 367 | UpdateRecord(&record); |
400 | PackRecord(&record, &nffile); | |
368 | PackRecord(&record, nffile); | |
401 | 369 | |
402 | 370 | SetIPaddress(&record, PF_INET, "172.16.11.66", "192.168.170.110"); |
403 | 371 | record.srcport = 7024; |
407 | 375 | record.dOctets = 100000001; |
408 | 376 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
409 | 377 | UpdateRecord(&record); |
410 | PackRecord(&record, &nffile); | |
378 | PackRecord(&record, nffile); | |
411 | 379 | |
412 | 380 | SetIPaddress(&record, PF_INET, "172.16.12.66", "192.168.170.111"); |
413 | 381 | record.srcport = 8024; |
416 | 384 | record.dOctets = 1000000001; |
417 | 385 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
418 | 386 | UpdateRecord(&record); |
419 | PackRecord(&record, &nffile); | |
387 | PackRecord(&record, nffile); | |
420 | 388 | |
421 | 389 | SetIPaddress(&record, PF_INET, "172.16.13.66", "192.168.170.112"); |
422 | 390 | record.srcport = 0; |
428 | 396 | record.dOctets = 50000; |
429 | 397 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
430 | 398 | UpdateRecord(&record); |
431 | PackRecord(&record, &nffile); | |
399 | PackRecord(&record, nffile); | |
432 | 400 | |
433 | 401 | SetIPaddress(&record, PF_INET, "172.160.160.166", "172.160.160.180"); |
434 | 402 | record.srcport = 10024; |
438 | 406 | record.dOctets = 500000; |
439 | 407 | fprintf(stderr, "IPv4 32bit packets 32bit bytes\n"); |
440 | 408 | UpdateRecord(&record); |
441 | PackRecord(&record, &nffile); | |
409 | PackRecord(&record, nffile); | |
442 | 410 | |
443 | 411 | SetIPaddress(&record, PF_INET6, "fe80::2110:abcd:1234:0", "fe80::2110:abcd:1235:4321"); |
444 | 412 | // SetNextIPaddress(&record, PF_INET6, "2003:234:aabb::211:24ff:fe80:d01e"); |
450 | 418 | record.dOctets = 15100; |
451 | 419 | fprintf(stderr, "IPv6 32bit packets 32bit bytes\n"); |
452 | 420 | UpdateRecord(&record); |
453 | PackRecord(&record, &nffile); | |
421 | PackRecord(&record, nffile); | |
454 | 422 | |
455 | 423 | SetIPaddress(&record, PF_INET6, "2001:234:aabb::211:24ff:fe80:d01e", "2001:620::8:203:baff:fe52:38e5"); |
456 | 424 | record.srcport = 10240; |
459 | 427 | record.dOctets = 15000000; |
460 | 428 | fprintf(stderr, "IPv6 32bit packets 32bit bytes\n"); |
461 | 429 | UpdateRecord(&record); |
462 | PackRecord(&record, &nffile); | |
430 | PackRecord(&record, nffile); | |
463 | 431 | |
464 | 432 | record.dPkts = 10100000; |
465 | 433 | record.dOctets = 0x100000000LL; |
466 | 434 | fprintf(stderr, "IPv6 32bit packets 64bit bytes\n"); |
467 | 435 | UpdateRecord(&record); |
468 | PackRecord(&record, &nffile); | |
436 | PackRecord(&record, nffile); | |
469 | 437 | |
470 | 438 | record.dPkts = 0x100000000LL; |
471 | 439 | record.dOctets = 15000000; |
472 | 440 | fprintf(stderr, "IPv6 64bit packets 32bit bytes\n"); |
473 | 441 | UpdateRecord(&record); |
474 | PackRecord(&record, &nffile); | |
442 | PackRecord(&record, nffile); | |
475 | 443 | |
476 | 444 | record.dOctets = 0x200000000LL; |
477 | 445 | fprintf(stderr, "IPv6 64bit packets 64bit bytes\n"); |
478 | 446 | UpdateRecord(&record); |
479 | PackRecord(&record, &nffile); | |
447 | PackRecord(&record, nffile); | |
480 | 448 | |
481 | 449 | SetIPaddress(&record, PF_INET, "172.16.14.18", "192.168.170.113"); |
482 | 450 | // SetNextIPaddress(&record, PF_INET, "172.72.1.2"); |
487 | 455 | record.dOctets = 0x100000000LL; |
488 | 456 | fprintf(stderr, "IPv4 32bit packets 64bit bytes\n"); |
489 | 457 | UpdateRecord(&record); |
490 | PackRecord(&record, &nffile); | |
458 | PackRecord(&record, nffile); | |
491 | 459 | |
492 | 460 | SetIPaddress(&record, PF_INET, "172.16.15.18", "192.168.170.114"); |
493 | 461 | record.dPkts = 0x100000000LL; |
494 | 462 | record.dOctets = 15000000; |
495 | 463 | fprintf(stderr, "IPv4 64bit packets 32bit bytes\n"); |
496 | 464 | UpdateRecord(&record); |
497 | PackRecord(&record, &nffile); | |
465 | PackRecord(&record, nffile); | |
498 | 466 | |
499 | 467 | SetIPaddress(&record, PF_INET, "172.16.16.18", "192.168.170.115"); |
500 | 468 | record.dOctets = 0x200000000LL; |
501 | 469 | fprintf(stderr, "IPv4 64bit packets 64bit bytes\n"); |
502 | 470 | UpdateRecord(&record); |
503 | PackRecord(&record, &nffile); | |
471 | PackRecord(&record, nffile); | |
504 | 472 | |
505 | 473 | extension_info.map->ex_id[0] = EX_IO_SNMP_4; |
506 | 474 | |
512 | 480 | i++; |
513 | 481 | } |
514 | 482 | |
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); | |
523 | 491 | |
524 | 492 | extension_info.map->ex_id[0] = EX_IO_SNMP_2; |
525 | 493 | extension_info.map->ex_id[1] = EX_AS_4; |
532 | 500 | i++; |
533 | 501 | } |
534 | 502 | |
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); | |
543 | 511 | |
544 | 512 | extension_info.map->ex_id[0] = EX_IO_SNMP_4; |
545 | 513 | |
551 | 519 | i++; |
552 | 520 | } |
553 | 521 | |
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 ) { | |
565 | 533 | fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno)); |
566 | 534 | } |
567 | 535 | } |
72 | 72 | |
73 | 73 | extension_map_list_t extension_map_list; |
74 | 74 | |
75 | /* exported fuctions */ | |
76 | void LogError(char *format, ...); | |
77 | ||
78 | 75 | /* Function Prototypes */ |
79 | 76 | static void usage(char *name); |
80 | 77 | |
184 | 181 | if ( Insert_Extension_Map(&extension_map_list, map) ) { |
185 | 182 | int j; |
186 | 183 | for ( j=0; j < num_channels; j++ ) { |
187 | if ( channels[j].nffile.wfd > 0 ) { | |
184 | if ( channels[j].nffile != NULL) { | |
188 | 185 | // flush new map |
189 | AppendToBuffer(&channels[j].nffile, (void *)map, map->size); | |
186 | AppendToBuffer(channels[j].nffile, (void *)map, map->size); | |
190 | 187 | } |
191 | 188 | } |
192 | 189 | } // else map already known and flushed |
239 | 236 | |
240 | 237 | // do we need to write data to new file - shadow profiles do not have files. |
241 | 238 | // check if we need to flush the output buffer |
242 | if ( channels[j].nffile.wfd > 0 ) { | |
239 | if ( channels[j].nffile != NULL ) { | |
243 | 240 | // 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); | |
245 | 242 | } |
246 | 243 | |
247 | 244 | } // End of for all channels |
252 | 249 | if ( Insert_Extension_Map(&extension_map_list, map) ) { |
253 | 250 | int j; |
254 | 251 | for ( j=0; j < num_channels; j++ ) { |
255 | if ( channels[j].nffile.wfd > 0 ) { | |
252 | if ( channels[j].nffile != NULL ) { | |
256 | 253 | // flush new map |
257 | AppendToBuffer(&channels[j].nffile, (void *)map, map->size); | |
254 | AppendToBuffer(channels[j].nffile, (void *)map, map->size); | |
258 | 255 | } |
259 | 256 | } |
260 | 257 | } // else map already known and flushed |
271 | 268 | |
272 | 269 | // do we need to write data to new file - shadow profiles do not have files. |
273 | 270 | for ( j=0; j < num_channels; j++ ) { |
274 | if ( channels[j].nffile.wfd > 0 ) { | |
271 | if ( channels[j].nffile != NULL ) { | |
275 | 272 | // 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 ) { | |
278 | 275 | LogError("Failed to write output buffer to disk: '%s'" , strerror(errno)); |
279 | 276 | } 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++; | |
283 | 278 | } |
284 | 279 | } |
285 | 280 | } |
Binary diff not shown
73 | 73 | #include "flist.h" |
74 | 74 | #include "util.h" |
75 | 75 | #include "grammar.h" |
76 | #include "panonymizer.h" | |
77 | 76 | |
78 | 77 | #define DEFAULTCISCOPORT "9995" |
79 | 78 | #define DEFAULTHOSTNAME "127.0.0.1" |
103 | 102 | /* Function Prototypes */ |
104 | 103 | static void usage(char *name); |
105 | 104 | |
106 | static int ParseCryptoPAnKey ( char *s, char *key ); | |
107 | ||
108 | 105 | static void send_blast(unsigned int delay ); |
109 | 106 | |
110 | 107 | 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); | |
112 | 109 | |
113 | 110 | static int FlushBuffer(int confirm); |
114 | 111 | |
152 | 149 | return sendto(peer.sockfd, peer.send_buffer, len, 0, (struct sockaddr *)&(peer.addr), peer.addrlen); |
153 | 150 | } // End of FlushBuffer |
154 | 151 | |
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 | |
183 | 152 | |
184 | 153 | static void send_blast(unsigned int delay ) { |
185 | 154 | common_flow_header_t *header; |
231 | 200 | } // End of send_blast |
232 | 201 | |
233 | 202 | 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) { | |
235 | 204 | data_block_header_t in_block_header; |
236 | 205 | master_record_t master_record; |
237 | 206 | common_record_t *flow_record, *in_buff; |
369 | 338 | continue; |
370 | 339 | } |
371 | 340 | // 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 | } | |
388 | 341 | |
389 | 342 | if ( netflow_version == 5 ) |
390 | 343 | again = Add_v5_output_record(&master_record, &peer); |
459 | 412 | int main( int argc, char **argv ) { |
460 | 413 | struct stat stat_buff; |
461 | 414 | 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; | |
464 | 416 | unsigned int delay, count, sockbuff_size; |
465 | 417 | time_t t_start, t_end; |
466 | 418 | |
477 | 429 | count = 0xFFFFFFFF; |
478 | 430 | sockbuff_size = 0; |
479 | 431 | netflow_version = 5; |
480 | do_anonymize = 0; | |
481 | 432 | blast = 0; |
482 | 433 | verbose = 0; |
483 | 434 | confirm = 0; |
512 | 463 | } |
513 | 464 | break; |
514 | 465 | 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); | |
520 | 468 | break; |
521 | 469 | case 'L': |
522 | 470 | if ( !InitLog(argv[0], optarg) ) |
637 | 585 | exit(255); |
638 | 586 | } |
639 | 587 | |
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); | |
644 | 589 | |
645 | 590 | return 0; |
646 | 591 | } |
61 | 61 | #include "netflow_v5_v7.h" |
62 | 62 | #include "nf_common.h" |
63 | 63 | #include "util.h" |
64 | #include "panonymizer.h" | |
65 | 64 | #include "nflowcache.h" |
66 | 65 | #include "nfstat.h" |
67 | 66 | |
331 | 330 | |
332 | 331 | static void Expand_StatTable_Blocks(int hash_num); |
333 | 332 | |
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); | |
339 | 338 | |
340 | 339 | static void Create_topN_FlowStat(SortElement_t **topN_lists, int order, int topN, uint32_t *count ); |
341 | 340 | |
863 | 862 | |
864 | 863 | } // End of AddStat |
865 | 864 | |
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) { | |
867 | 866 | char proto[16], valstr[40], datestr[64], flows_str[32], byte_str[32], packets_str[32], pps_str[32], bps_str[32]; |
868 | 867 | char tag_string[2]; |
869 | 868 | double duration, flows_percent, packets_percent, bytes_percent; |
882 | 881 | case IS_IPADDR: |
883 | 882 | tag_string[0] = tag ? TAG_CHAR : '\0'; |
884 | 883 | 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 | } | |
891 | 884 | StatData->stat_key[0] = htonll(StatData->stat_key[0]); |
892 | 885 | StatData->stat_key[1] = htonll(StatData->stat_key[1]); |
893 | 886 | inet_ntop(AF_INET6, StatData->stat_key, valstr, sizeof(valstr)); |
895 | 888 | condense_v6(valstr); |
896 | 889 | |
897 | 890 | } 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]); | |
903 | 893 | inet_ntop(AF_INET, &ipv4, valstr, sizeof(valstr)); |
904 | 894 | } |
905 | 895 | break; |
975 | 965 | |
976 | 966 | } // End of PrintStatLine |
977 | 967 | |
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) { | |
979 | 969 | double duration; |
980 | 970 | uint32_t pps, bps, bpp; |
981 | 971 | uint32_t sa[4]; |
985 | 975 | af = AF_UNSPEC; |
986 | 976 | if ( type == IS_IPADDR ) { |
987 | 977 | 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 | } | |
994 | 978 | StatData->stat_key[0] = htonll(StatData->stat_key[0]); |
995 | 979 | StatData->stat_key[1] = htonll(StatData->stat_key[1]); |
996 | 980 | af = PF_INET6; |
997 | 981 | |
998 | 982 | } else { // IPv4 |
999 | uint32_t ipv4 = StatData->stat_key[1]; | |
1000 | if ( anon ) { | |
1001 | StatData->stat_key[1] = anonymize(ipv4); | |
1002 | } | |
1003 | 983 | af = PF_INET; |
1004 | 984 | } |
1005 | 985 | // Make sure Endian does not screw us up |
1042 | 1022 | |
1043 | 1023 | } // End of PrintPipeStatLine |
1044 | 1024 | |
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) { | |
1046 | 1026 | char proto[16], valstr[40], datestr1[64], datestr2[64]; |
1047 | 1027 | char tag_string[2]; |
1048 | 1028 | double duration, flows_percent, packets_percent, bytes_percent; |
1061 | 1041 | case IS_IPADDR: |
1062 | 1042 | tag_string[0] = tag ? TAG_CHAR : '\0'; |
1063 | 1043 | 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 | } | |
1070 | 1044 | StatData->stat_key[0] = htonll(StatData->stat_key[0]); |
1071 | 1045 | StatData->stat_key[1] = htonll(StatData->stat_key[1]); |
1072 | 1046 | inet_ntop(AF_INET6, StatData->stat_key, valstr, sizeof(valstr)); |
1073 | 1047 | |
1074 | 1048 | } 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]); | |
1080 | 1051 | inet_ntop(AF_INET, &ipv4, valstr, sizeof(valstr)); |
1081 | 1052 | } |
1082 | 1053 | break; |
1159 | 1130 | |
1160 | 1131 | } // End of PrintCvsStatLine |
1161 | 1132 | |
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) { | |
1163 | 1134 | hash_FlowTable *FlowTable; |
1164 | 1135 | FlowTableRecord_t *r; |
1165 | 1136 | SortElement_t *SortList; |
1218 | 1189 | if ( limitflows && limitflows < maxindex ) |
1219 | 1190 | maxindex = limitflows; |
1220 | 1191 | for ( i = 0; i < maxindex; i++ ) { |
1221 | master_record_t flow_record; | |
1192 | master_record_t *flow_record; | |
1222 | 1193 | common_record_t *raw_record; |
1223 | 1194 | int map_id; |
1224 | 1195 | |
1226 | 1197 | raw_record = &(r->flowrecord); |
1227 | 1198 | map_id = r->map_ref->map_id; |
1228 | 1199 | |
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]; | |
1235 | 1207 | |
1236 | 1208 | // apply IP mask from aggregation, to provide a pretty output |
1237 | 1209 | 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]; | |
1242 | 1214 | } |
1243 | 1215 | |
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); | |
1247 | 1219 | printf("%s\n", string); |
1248 | 1220 | } |
1249 | 1221 | |
1297 | 1269 | |
1298 | 1270 | if ( GuessDir && ( flow_record->srcport < 1024 && flow_record->dstport > 1024 ) ) |
1299 | 1271 | SwapFlow(flow_record); |
1300 | print_record((void *)flow_record, &string, anon, tag); | |
1272 | print_record((void *)flow_record, &string, tag); | |
1301 | 1273 | printf("%s\n", string); |
1302 | 1274 | |
1303 | 1275 | c++; |
1308 | 1280 | |
1309 | 1281 | } // End of PrintFlowTable |
1310 | 1282 | |
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) { | |
1312 | 1284 | hash_FlowTable *FlowTable; |
1313 | 1285 | SortElement_t *topN_flow_list[NumOrders]; |
1314 | 1286 | uint32_t numflows; |
1367 | 1339 | if ( FlowTable->apply_netbits ) |
1368 | 1340 | ApplyNetMaskBits(&flow_record, FlowTable->apply_netbits); |
1369 | 1341 | |
1370 | print_record((void *)&flow_record, &string, anon, tag); | |
1342 | print_record((void *)&flow_record, &string, tag); | |
1371 | 1343 | printf("%s\n", string); |
1372 | 1344 | } |
1373 | 1345 | printf("\n"); |
1381 | 1353 | |
1382 | 1354 | } // End of PrintFlowStat |
1383 | 1355 | |
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) { | |
1385 | 1357 | SortElement_t *topN_element_list; |
1386 | 1358 | uint32_t numflows, maxindex; |
1387 | 1359 | int32_t i, j, hash_num, order_index, order_bit; |
1426 | 1398 | // Again - ugly output formating - needs to be cleand up |
1427 | 1399 | if ( pipe_output ) |
1428 | 1400 | PrintPipeStatLine((StatRecord_t *)topN_element_list[i].record, type, |
1429 | anon, StatRequest[hash_num].order_proto, tag); | |
1401 | StatRequest[hash_num].order_proto, tag); | |
1430 | 1402 | else if ( cvs_output ) |
1431 | 1403 | 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); | |
1433 | 1405 | else |
1434 | 1406 | 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); | |
1436 | 1408 | } |
1437 | 1409 | free((void *)topN_element_list); |
1438 | 1410 | printf("\n"); |
101 | 101 | |
102 | 102 | void AddStat(common_record_t *raw_record, master_record_t *flow_record ); |
103 | 103 | |
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); | |
105 | 105 | |
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); | |
107 | 107 | |
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); | |
109 | 109 | |
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); | |
111 | 111 | |
112 | 112 | #endif //_NFSTAT_H |
Binary diff not shown
146 | 146 | } |
147 | 147 | |
148 | 148 | void CheckCompression(char *filename) { |
149 | nffile_t nffile; | |
150 | int i, rfd; | |
149 | nffile_t *nffile; | |
150 | int i, rfd, compress, bsize; | |
151 | 151 | ssize_t ret; |
152 | 152 | stat_record_t *stat_ptr; |
153 | 153 | char *string; |
154 | 154 | char outfile[MAXPATHLEN]; |
155 | void *buff_ptr; | |
155 | void *buff_ptr, *in_buff; | |
156 | data_block_header_t *in_block_header, *p; | |
156 | 157 | |
157 | 158 | struct timeval tstart[2]; |
158 | 159 | struct timeval tend[2]; |
169 | 170 | snprintf(outfile, MAXPATHLEN, "%s-tmp", filename); |
170 | 171 | outfile[MAXPATHLEN-1] = '\0'; |
171 | 172 | |
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) ); | |
176 | 176 | return; |
177 | 177 | } |
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); | |
181 | 182 | if ( ret < 0 ) { |
182 | 183 | fprintf(stderr, "Error while reading data block. Abort.\n"); |
183 | 184 | close(rfd); |
186 | 187 | } |
187 | 188 | close(rfd); |
188 | 189 | |
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 ) { | |
192 | 194 | fprintf(stderr, "%s\n", string); |
193 | 195 | return; |
194 | 196 | } |
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); | |
197 | 203 | for ( i=0; i<100; i++ ) { |
198 | if ( (ret = WriteBlock(&nffile)) <= 0 ) { | |
204 | if ( (ret = WriteBlock(nffile)) <= 0 ) { | |
199 | 205 | fprintf(stderr, "Failed to write output buffer to disk: '%s'" , strerror(errno)); |
200 | 206 | close(rfd); |
201 | close(nffile.wfd); | |
207 | CloseUpdateFile(nffile, stat_ptr, "none", &string ); | |
202 | 208 | unlink(outfile); |
203 | 209 | return; |
204 | 210 | } |
205 | 211 | } |
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); | |
209 | 218 | unlink(outfile); |
210 | 219 | |
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); | |
222 | 231 | 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); | |
224 | 233 | |
225 | 234 | if ( wall[0] < wall[1] ) |
226 | 235 | printf("You should run nfcapd without compression\n"); |
231 | 240 | |
232 | 241 | int main(int argc, char **argv) { |
233 | 242 | master_record_t flow_record; |
243 | common_record_t c_record; | |
234 | 244 | uint64_t *blocks, l; |
235 | 245 | uint32_t size, in[2]; |
236 | 246 | time_t now; |
237 | 247 | int ret, i; |
238 | 248 | value64_t v; |
249 | void *p; | |
239 | 250 | |
240 | 251 | if ( sizeof(struct in_addr) != sizeof(uint32_t) ) { |
241 | 252 | #ifdef HAVE_SIZE_T_Z_FORMAT |
246 | 257 | exit(255); |
247 | 258 | } |
248 | 259 | |
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 | } | |
249 | 268 | i = 3; |
250 | 269 | printf("ALIGN BYTES: %lu\n", (long unsigned)ALIGN_BYTES); |
251 | 270 | printf("aligned: %i -> %lu\n", i, (long unsigned)(((u_int)(i) + ALIGN_BYTES) &~ ALIGN_BYTES)); |
103 | 103 | |
104 | 104 | uint32_t Max_num_extensions; |
105 | 105 | |
106 | void FixExtensionMap(extension_map_t *map); | |
107 | ||
106 | 108 | void InitExtensionMaps(extension_map_list_t *extension_map_list ) { |
109 | int i; | |
107 | 110 | memset((void *)extension_map_list->slot, 0, MAX_EXTENSION_MAPS * sizeof(extension_info_t *)); |
108 | 111 | memset((void *)extension_map_list->page, 0, MAX_EXTENSION_MAPS * sizeof(extension_info_t *)); |
109 | 112 | |
110 | 113 | extension_map_list->next_free = 0; |
111 | 114 | 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++; | |
112 | 120 | |
113 | 121 | } // End of InitExtensionMaps |
114 | 122 | |
223 | 231 | } |
224 | 232 | } |
225 | 233 | } |
234 | ||
235 | FixExtensionMap(map); | |
226 | 236 | |
227 | 237 | // add new entry to slot |
228 | 238 | extension_map_list->slot[map_id] = (extension_info_t *)calloc(1,sizeof(extension_info_t)); |
493 | 503 | i++; |
494 | 504 | } |
495 | 505 | |
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 | } | |
496 | 511 | if ( (i != max_elements ) && ((max_elements-i) != 1) ) { |
497 | 512 | // off by 1 is the opt alignment |
498 | 513 | printf("Verify map id %i: ERROR: Expected %i elements in map, but found %i!\n", map->map_id, max_elements, i); |
502 | 517 | return failed; |
503 | 518 | |
504 | 519 | } // 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 | |
505 | 560 | |
506 | 561 | |
507 | 562 | void DumpExMaps(char *filename) { |
81 | 81 | #include <sys/types.h> |
82 | 82 | #include <stdlib.h> |
83 | 83 | #include <string.h> |
84 | #include <ctype.h> | |
84 | 85 | |
85 | 86 | #ifdef HAVE_STDINT_H |
86 | 87 | #include <stdint.h> |
100 | 101 | //initialize the 128-bit secret pad. The pad is encrypted before being used for padding. |
101 | 102 | Rijndael_blockEncrypt(key + 16, 128, m_pad); |
102 | 103 | } |
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 | |
103 | 142 | |
104 | 143 | //Anonymization funtion |
105 | 144 | uint32_t anonymize(const uint32_t orig_addr) { |
85 | 85 | // The second 128 bits of the key are used as the secret pad for padding |
86 | 86 | void PAnonymizer_Init(uint8_t * key); |
87 | 87 | |
88 | int ParseCryptoPAnKey ( char *s, char *key ); | |
89 | ||
88 | 90 | uint32_t anonymize( const uint32_t orig_addr); |
89 | 91 | |
90 | 92 | void anonymize_v6(const uint64_t orig_addr[2], uint64_t *anon_addr); |
122 | 122 | char path[MAXPATHLEN]; |
123 | 123 | int ffd, ret; |
124 | 124 | size_t filter_size; |
125 | nffile_t nffile; | |
125 | nffile_t *nffile; | |
126 | 126 | |
127 | 127 | ofile = wfile = NULL; |
128 | nffile = NULL; | |
128 | 129 | |
129 | 130 | /* |
130 | 131 | * Compile the complete filter: |
256 | 257 | exit(255); |
257 | 258 | } |
258 | 259 | |
259 | memset((void *)&nffile, 0, sizeof(nffile)); | |
260 | ||
261 | 260 | // check for subdir hierarchy |
262 | 261 | subdir = NULL; |
263 | 262 | if ( (profile_param->profiletype & 4) == 0 ) { // no shadow profile |
263 | char *string; | |
264 | 264 | int is_alert = (profile_param->profiletype & 8) == 8; |
265 | 265 | if ( !is_alert && subdir_index && strlen(filename) == 19 && (strncmp(filename, "nfcapd.", 7) == 0) ) { |
266 | 266 | char *p = &filename[7]; // points to ISO timstamp in filename |
303 | 303 | |
304 | 304 | ofile = strdup(path); |
305 | 305 | |
306 | if ( !InitExportFile(path, compress, &nffile) ) | |
306 | nffile = OpenNewFile(path, NULL, compress, 0, &string); | |
307 | if ( !nffile ) { | |
308 | LogError("%s", string); | |
307 | 309 | return; |
310 | } | |
308 | 311 | |
309 | 312 | } |
310 | 313 | |
357 | 360 | |
358 | 361 | for ( num = 0; num < num_channels; num++ ) { |
359 | 362 | 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); | |
362 | 365 | |
363 | 366 | if ( s != NULL ) { |
364 | 367 | LogError("%s\n", s); |
55 | 55 | char *wfile; // final filename |
56 | 56 | char *rrdfile; // rrd filename for update |
57 | 57 | char *dirstat_path; // pathname for dirstat file |
58 | nffile_t nffile; | |
58 | nffile_t *nffile; | |
59 | 59 | stat_record_t stat_record; |
60 | 60 | int type; |
61 | 61 | dirstat_t *dirstat; |
358 | 358 | // Init each netflow source output data buffer |
359 | 359 | fs = FlowSource; |
360 | 360 | 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; | |
369 | 361 | |
370 | 362 | // 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 ) { | |
373 | 365 | syslog(LOG_ERR, "%s", string); |
374 | 366 | return; |
375 | 367 | } |
470 | 462 | |
471 | 463 | if ( verbose ) { |
472 | 464 | // 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); | |
474 | 466 | printf("%s\n", string); |
475 | 467 | } |
476 | 468 | |
477 | if ( fs->nffile.block_header->NumRecords ) { | |
469 | if ( fs->nffile->block_header->NumRecords ) { | |
478 | 470 | // flush current buffer to disc |
479 | if ( WriteBlock(&(fs->nffile)) <= 0 ) | |
471 | if ( WriteBlock(fs->nffile) <= 0 ) | |
480 | 472 | syslog(LOG_ERR, "Ident: %s, failed to write output buffer to disk: '%s'" , fs->Ident, strerror(errno)); |
481 | 473 | else |
482 | 474 | // update successful written blocks |
483 | fs->nffile.file_blocks++; | |
475 | fs->nffile->file_header->NumBlocks++; | |
484 | 476 | } // else - no new records in current block |
485 | 477 | |
486 | 478 | |
495 | 487 | fs->stat_record.msec_last = fs->last_seen - fs->stat_record.last_seen*1000; |
496 | 488 | |
497 | 489 | // 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 ); | |
499 | 491 | if ( string != NULL ) { |
500 | 492 | // closing the file failed. maybe disk full ?? |
501 | 493 | syslog(LOG_ERR, "Ident: %s, %s", fs->Ident, string); |
533 | 525 | fs->Ident, (unsigned long long)fs->stat_record.numflows, (unsigned long long)fs->stat_record.numpackets, |
534 | 526 | (unsigned long long)fs->stat_record.numbytes, fs->stat_record.sequence_failure, fs->bad_packets); |
535 | 527 | |
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 | ||
541 | 528 | // reset stat record |
542 | 529 | memset((void *)&fs->stat_record, 0, sizeof(stat_record_t)); |
543 | 530 | fs->bad_packets = 0; |
544 | 531 | fs->first_seen = 0xffffffffffffLL; |
545 | 532 | fs->last_seen = 0; |
546 | fs->nffile.file_blocks = 0; | |
547 | 533 | |
548 | 534 | // Dump all extension maps to the buffer |
549 | 535 | FlushExtensionMaps(fs); |
550 | 536 | |
551 | 537 | 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; | |
559 | 543 | } |
560 | 544 | } |
545 | ||
546 | // Dump all extension maps to the buffer | |
547 | FlushExtensionMaps(fs); | |
548 | ||
561 | 549 | |
562 | 550 | // next flow source |
563 | 551 | fs = fs->next; |
648 | 636 | export_packets++; |
649 | 637 | |
650 | 638 | // flush current buffer to disc |
651 | if ( fs->nffile.block_header->size > BUFFSIZE ) { | |
639 | if ( fs->nffile->block_header->size > BUFFSIZE ) { | |
652 | 640 | // fishy! - we already wrote into someone elses memory! - I'm sorry |
653 | 641 | // 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) ); | |
657 | 645 | syslog(LOG_ERR, "### Software bug ### Ident: %s, output buffer overflow: expect memory inconsitency", fs->Ident); |
658 | 646 | } |
659 | 647 | } |
665 | 653 | |
666 | 654 | fs = FlowSource; |
667 | 655 | while ( fs ) { |
668 | free((void *)fs->nffile.block_header); | |
656 | fs->nffile = DisposeFile(fs->nffile); | |
669 | 657 | fs = fs->next; |
670 | 658 | } |
671 | 659 | |
1050 | 1038 | exit(255); |
1051 | 1039 | } |
1052 | 1040 | |
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 | ||
1060 | 1041 | fs = fs->next; |
1061 | 1042 | } |
1062 | 1043 |
1072 | 1072 | // output buffer size check |
1073 | 1073 | // IPv6 needs 2 x 16 bytes, IPv4 2 x 4 bytes |
1074 | 1074 | 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 )) { | |
1076 | 1076 | // fishy! - should never happen. maybe disk full? |
1077 | 1077 | syslog(LOG_ERR,"SFLOW: output buffer size error. Abort sflow record processing"); |
1078 | 1078 | return; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | common_record = (common_record_t *)fs->nffile.writeto; | |
1081 | common_record = (common_record_t *)fs->nffile->writeto; | |
1082 | 1082 | |
1083 | 1083 | common_record->size = sflow_output_record_size[ip_flags] + ipsize; |
1084 | 1084 | common_record->type = CommonRecordType; |
1288 | 1288 | master_record_t master_record; |
1289 | 1289 | char *string; |
1290 | 1290 | 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); | |
1292 | 1292 | printf("%s\n", string); |
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | // 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); | |
1298 | 1298 | #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) ) { | |
1300 | 1300 | 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), | |
1302 | 1302 | (sflow_output_record_size[ip_flags] + ipsize)); |
1303 | 1303 | exit(255); |
1304 | 1304 | } |
1305 | 1305 | #endif |
1306 | fs->nffile.writeto = next_data; | |
1306 | fs->nffile->writeto = next_data; | |
1307 | 1307 | |
1308 | 1308 | } |
1309 | 1309 |
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 | /*_________________---------------------------__________________ |
26 | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | 27 | * POSSIBILITY OF SUCH DAMAGE. |
28 | 28 | * |
29 | * $Author: haag $ | |
29 | * $Author: peter $ | |
30 | 30 | * |
31 | * $Id: version.h 69 2010-09-09 07:17:43Z haag $ | |
31 | * $Id: version.h 19 2011-01-09 11:28:32Z peter $ | |
32 | 32 | * |
33 | * $LastChangedRevision: 69 $ | |
33 | * $LastChangedRevision: 19 $ | |
34 | 34 | * |
35 | 35 | * |
36 | 36 | */ |
37 | ||
37 | ||
38 | 38 | #ifndef _VERSION_H |
39 | 39 | #define _VERSION_H 1 |
40 | ||
40 | ||
41 | 41 | const char *nfdump_version = VERSION; |
42 | 42 | |
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) $"; | |
44 | 44 | |
45 | 45 | #endif //_VERSION_H |
0 | 0 | #! /bin/sh |
1 | 1 | # Wrapper for compilers which do not understand `-c -o'. |
2 | 2 | |
3 | scriptversion=2009-04-28.21; # UTC | |
3 | scriptversion=2009-10-06.20; # UTC | |
4 | 4 | |
5 | 5 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software |
6 | 6 | # Foundation, Inc. |
123 | 123 | ret=$? |
124 | 124 | |
125 | 125 | if test -f "$cofile"; then |
126 | mv "$cofile" "$ofile" | |
126 | test "$cofile" = "$ofile" || mv "$cofile" "$ofile" | |
127 | 127 | elif test -f "${cofile}bj"; then |
128 | mv "${cofile}bj" "$ofile" | |
128 | test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" | |
129 | 129 | fi |
130 | 130 | |
131 | 131 | rmdir "$lockdir" |
0 | 0 | #! /bin/sh |
1 | # From configure.in Revision: 100 . | |
1 | # From configure.in Revision: 69 . | |
2 | 2 | # 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. | |
4 | 4 | # |
5 | 5 | # Report bugs to <phaag@users.sourceforge.net>. |
6 | 6 | # |
7 | 7 | # |
8 | 8 | # 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. | |
11 | 11 | # |
12 | 12 | # |
13 | 13 | # This configure script is free software; the Free Software Foundation |
319 | 319 | test -d "$as_dir" && break |
320 | 320 | done |
321 | 321 | 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" | |
323 | 323 | |
324 | 324 | |
325 | 325 | } # as_fn_mkdir_p |
359 | 359 | fi # as_fn_arith |
360 | 360 | |
361 | 361 | |
362 | # as_fn_error ERROR [LINENO LOG_FD] | |
363 | # --------------------------------- | |
362 | # as_fn_error STATUS ERROR [LINENO LOG_FD] | |
363 | # ---------------------------------------- | |
364 | 364 | # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are |
365 | 365 | # 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. | |
367 | 367 | as_fn_error () |
368 | 368 | { |
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 | |
373 | 373 | fi |
374 | $as_echo "$as_me: error: $1" >&2 | |
374 | $as_echo "$as_me: error: $2" >&2 | |
375 | 375 | as_fn_exit $as_status |
376 | 376 | } # as_fn_error |
377 | 377 | |
533 | 533 | exec 6>&1 |
534 | 534 | |
535 | 535 | # 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, | |
537 | 537 | # so uname gets run too. |
538 | 538 | ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` |
539 | 539 | |
552 | 552 | # Identity of this package. |
553 | 553 | PACKAGE_NAME='nfdump' |
554 | 554 | 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' | |
557 | 557 | PACKAGE_BUGREPORT='phaag@users.sourceforge.net' |
558 | 558 | PACKAGE_URL='' |
559 | 559 | |
607 | 607 | READPCAP_TRUE |
608 | 608 | SFLOW_FALSE |
609 | 609 | SFLOW_TRUE |
610 | NFTRACK_FALSE | |
611 | NFTRACK_TRUE | |
610 | 612 | EGREP |
611 | 613 | GREP |
612 | 614 | CPP |
707 | 709 | with_rrdpath |
708 | 710 | enable_ftconv |
709 | 711 | enable_nfprofile |
712 | enable_nftrack | |
710 | 713 | enable_sflow |
711 | 714 | enable_readpcap |
712 | 715 | ' |
783 | 786 | fi |
784 | 787 | |
785 | 788 | 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 ;; | |
788 | 792 | esac |
789 | 793 | |
790 | 794 | # Accept the important Cygnus configure options, so we can diagnose typos. |
829 | 833 | ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` |
830 | 834 | # Reject names that are not valid shell variable names. |
831 | 835 | 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" | |
833 | 837 | ac_useropt_orig=$ac_useropt |
834 | 838 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
835 | 839 | case $ac_user_opts in |
855 | 859 | ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` |
856 | 860 | # Reject names that are not valid shell variable names. |
857 | 861 | 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" | |
859 | 863 | ac_useropt_orig=$ac_useropt |
860 | 864 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
861 | 865 | case $ac_user_opts in |
1059 | 1063 | ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` |
1060 | 1064 | # Reject names that are not valid shell variable names. |
1061 | 1065 | 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" | |
1063 | 1067 | ac_useropt_orig=$ac_useropt |
1064 | 1068 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
1065 | 1069 | case $ac_user_opts in |
1075 | 1079 | ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` |
1076 | 1080 | # Reject names that are not valid shell variable names. |
1077 | 1081 | 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" | |
1079 | 1083 | ac_useropt_orig=$ac_useropt |
1080 | 1084 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
1081 | 1085 | case $ac_user_opts in |
1105 | 1109 | | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) |
1106 | 1110 | x_libraries=$ac_optarg ;; |
1107 | 1111 | |
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" | |
1110 | 1114 | ;; |
1111 | 1115 | |
1112 | 1116 | *=*) |
1114 | 1118 | # Reject names that are not valid shell variable names. |
1115 | 1119 | case $ac_envvar in #( |
1116 | 1120 | '' | [0-9]* | *[!_$as_cr_alnum]* ) |
1117 | as_fn_error "invalid variable name: \`$ac_envvar'" ;; | |
1121 | as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; | |
1118 | 1122 | esac |
1119 | 1123 | eval $ac_envvar=\$ac_optarg |
1120 | 1124 | export $ac_envvar ;; |
1132 | 1136 | |
1133 | 1137 | if test -n "$ac_prev"; then |
1134 | 1138 | 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" | |
1136 | 1140 | fi |
1137 | 1141 | |
1138 | 1142 | if test -n "$ac_unrecognized_opts"; then |
1139 | 1143 | case $enable_option_checking in |
1140 | 1144 | no) ;; |
1141 | fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; | |
1145 | fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; | |
1142 | 1146 | *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; |
1143 | 1147 | esac |
1144 | 1148 | fi |
1161 | 1165 | [\\/$]* | ?:[\\/]* ) continue;; |
1162 | 1166 | NONE | '' ) case $ac_var in *prefix ) continue;; esac;; |
1163 | 1167 | 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" | |
1165 | 1169 | done |
1166 | 1170 | |
1167 | 1171 | # There might be people who depend on the old broken behavior: `$host' |
1175 | 1179 | if test "x$host_alias" != x; then |
1176 | 1180 | if test "x$build_alias" = x; then |
1177 | 1181 | 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 | |
1180 | 1184 | elif test "x$build_alias" != "x$host_alias"; then |
1181 | 1185 | cross_compiling=yes |
1182 | 1186 | fi |
1191 | 1195 | ac_pwd=`pwd` && test -n "$ac_pwd" && |
1192 | 1196 | ac_ls_di=`ls -di .` && |
1193 | 1197 | 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" | |
1195 | 1199 | 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" | |
1197 | 1201 | |
1198 | 1202 | |
1199 | 1203 | # Find the source files, if location was not specified. |
1232 | 1236 | fi |
1233 | 1237 | if test ! -r "$srcdir/$ac_unique_file"; then |
1234 | 1238 | 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" | |
1236 | 1240 | fi |
1237 | 1241 | ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" |
1238 | 1242 | 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" | |
1240 | 1244 | pwd)` |
1241 | 1245 | # When building in place, set srcdir=. |
1242 | 1246 | if test "$ac_abs_confdir" = "$ac_pwd"; then |
1262 | 1266 | # Omit some internal or obsolete options to make the list less imposing. |
1263 | 1267 | # This message is too long to be a string in the A/UX 3.1 sh. |
1264 | 1268 | 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. | |
1266 | 1270 | |
1267 | 1271 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1268 | 1272 | |
1276 | 1280 | --help=short display options specific to this package |
1277 | 1281 | --help=recursive display the short help of all the included packages |
1278 | 1282 | -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 | |
1280 | 1284 | --cache-file=FILE cache test results in FILE [disabled] |
1281 | 1285 | -C, --config-cache alias for \`--cache-file=config.cache' |
1282 | 1286 | -n, --no-create do not create output files |
1328 | 1332 | |
1329 | 1333 | if test -n "$ac_init_help"; then |
1330 | 1334 | 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:";; | |
1332 | 1336 | esac |
1333 | 1337 | cat <<\_ACEOF |
1334 | 1338 | |
1342 | 1346 | --enable-compat15 compile nfdump, to read nfdump data files created with nfdump 1.5.x; default is NO |
1343 | 1347 | --enable-ftconv Build the flow-tools to nfdump converter; default is NO |
1344 | 1348 | --enable-nfprofile Build nfprofile used by NfSen; default is NO |
1349 | --enable-nftrack Build nftrack used by PortTracker; default is NO | |
1345 | 1350 | --enable-sflow Build sflow collector sfcpad; default is NO |
1346 | 1351 | --enable-readpcap Build nfcapd collector to read from pcap file instead of network data; default is NO |
1347 | 1352 | |
1432 | 1437 | test -n "$ac_init_help" && exit $ac_status |
1433 | 1438 | if $ac_init_version; then |
1434 | 1439 | 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. | |
1439 | 1444 | This configure script is free software; the Free Software Foundation |
1440 | 1445 | gives unlimited permission to copy, distribute and modify it. |
1441 | 1446 | _ACEOF |
1551 | 1556 | mv -f conftest.er1 conftest.err |
1552 | 1557 | fi |
1553 | 1558 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
1554 | test $ac_status = 0; } >/dev/null && { | |
1559 | test $ac_status = 0; } > conftest.i && { | |
1555 | 1560 | test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || |
1556 | 1561 | test ! -s conftest.err |
1557 | 1562 | }; then : |
1575 | 1580 | ac_fn_c_check_header_mongrel () |
1576 | 1581 | { |
1577 | 1582 | 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 : | |
1579 | 1584 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1580 | 1585 | $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 : | |
1582 | 1587 | $as_echo_n "(cached) " >&6 |
1583 | 1588 | fi |
1584 | 1589 | eval ac_res=\$$3 |
1614 | 1619 | else |
1615 | 1620 | ac_header_preproc=no |
1616 | 1621 | fi |
1617 | rm -f conftest.err conftest.$ac_ext | |
1622 | rm -f conftest.err conftest.i conftest.$ac_ext | |
1618 | 1623 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 |
1619 | 1624 | $as_echo "$ac_header_preproc" >&6; } |
1620 | 1625 | |
1637 | 1642 | $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} |
1638 | 1643 | { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 |
1639 | 1644 | $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} |
1640 | ( cat <<\_ASBOX | |
1641 | ## ------------------------------------------ ## | |
1645 | ( $as_echo "## ------------------------------------------ ## | |
1642 | 1646 | ## Report this to phaag@users.sourceforge.net ## |
1643 | ## ------------------------------------------ ## | |
1644 | _ASBOX | |
1647 | ## ------------------------------------------ ##" | |
1645 | 1648 | ) | sed "s/^/$as_me: WARNING: /" >&2 |
1646 | 1649 | ;; |
1647 | 1650 | esac |
1648 | 1651 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1649 | 1652 | $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 : | |
1651 | 1654 | $as_echo_n "(cached) " >&6 |
1652 | 1655 | else |
1653 | 1656 | eval "$3=\$ac_header_compiler" |
1711 | 1714 | as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack |
1712 | 1715 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1713 | 1716 | $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 : | |
1715 | 1718 | $as_echo_n "(cached) " >&6 |
1716 | 1719 | else |
1717 | 1720 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
1742 | 1745 | as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack |
1743 | 1746 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 |
1744 | 1747 | $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 : | |
1746 | 1749 | $as_echo_n "(cached) " >&6 |
1747 | 1750 | else |
1748 | 1751 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
1798 | 1801 | as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack |
1799 | 1802 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1800 | 1803 | $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 : | |
1802 | 1805 | $as_echo_n "(cached) " >&6 |
1803 | 1806 | else |
1804 | 1807 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
2044 | 2047 | as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack |
2045 | 2048 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
2046 | 2049 | $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 : | |
2048 | 2051 | $as_echo_n "(cached) " >&6 |
2049 | 2052 | else |
2050 | 2053 | eval "$3=no" |
2092 | 2095 | This file contains any messages produced by compilers while |
2093 | 2096 | running configure, to aid debugging if configure makes a mistake. |
2094 | 2097 | |
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 | |
2097 | 2100 | |
2098 | 2101 | $ $0 $@ |
2099 | 2102 | |
2203 | 2206 | { |
2204 | 2207 | echo |
2205 | 2208 | |
2206 | cat <<\_ASBOX | |
2207 | ## ---------------- ## | |
2209 | $as_echo "## ---------------- ## | |
2208 | 2210 | ## Cache variables. ## |
2209 | ## ---------------- ## | |
2210 | _ASBOX | |
2211 | ## ---------------- ##" | |
2211 | 2212 | echo |
2212 | 2213 | # The following way of writing the cache mishandles newlines in values, |
2213 | 2214 | ( |
2241 | 2242 | ) |
2242 | 2243 | echo |
2243 | 2244 | |
2244 | cat <<\_ASBOX | |
2245 | ## ----------------- ## | |
2245 | $as_echo "## ----------------- ## | |
2246 | 2246 | ## Output variables. ## |
2247 | ## ----------------- ## | |
2248 | _ASBOX | |
2247 | ## ----------------- ##" | |
2249 | 2248 | echo |
2250 | 2249 | for ac_var in $ac_subst_vars |
2251 | 2250 | do |
2258 | 2257 | echo |
2259 | 2258 | |
2260 | 2259 | if test -n "$ac_subst_files"; then |
2261 | cat <<\_ASBOX | |
2262 | ## ------------------- ## | |
2260 | $as_echo "## ------------------- ## | |
2263 | 2261 | ## File substitutions. ## |
2264 | ## ------------------- ## | |
2265 | _ASBOX | |
2262 | ## ------------------- ##" | |
2266 | 2263 | echo |
2267 | 2264 | for ac_var in $ac_subst_files |
2268 | 2265 | do |
2276 | 2273 | fi |
2277 | 2274 | |
2278 | 2275 | if test -s confdefs.h; then |
2279 | cat <<\_ASBOX | |
2280 | ## ----------- ## | |
2276 | $as_echo "## ----------- ## | |
2281 | 2277 | ## confdefs.h. ## |
2282 | ## ----------- ## | |
2283 | _ASBOX | |
2278 | ## ----------- ##" | |
2284 | 2279 | echo |
2285 | 2280 | cat confdefs.h |
2286 | 2281 | echo |
2335 | 2330 | ac_site_file1=NONE |
2336 | 2331 | ac_site_file2=NONE |
2337 | 2332 | 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 | |
2339 | 2339 | elif test "x$prefix" != xNONE; then |
2340 | 2340 | ac_site_file1=$prefix/share/config.site |
2341 | 2341 | ac_site_file2=$prefix/etc/config.site |
2350 | 2350 | { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 |
2351 | 2351 | $as_echo "$as_me: loading site script $ac_site_file" >&6;} |
2352 | 2352 | 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; } | |
2354 | 2358 | fi |
2355 | 2359 | done |
2356 | 2360 | |
2429 | 2433 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
2430 | 2434 | { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 |
2431 | 2435 | $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 | |
2433 | 2437 | fi |
2434 | 2438 | ## -------------------- ## |
2435 | 2439 | ## Main body of script. ## |
2449 | 2453 | |
2450 | 2454 | ac_aux_dir= |
2451 | 2455 | 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 | |
2459 | 2469 | done |
2460 | 2470 | 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 | |
2462 | 2472 | fi |
2463 | 2473 | |
2464 | 2474 | # These three variables are undocumented and unsupported, |
2574 | 2584 | ' |
2575 | 2585 | case `pwd` in |
2576 | 2586 | *[\\\"\#\$\&\'\`$am_lf]*) |
2577 | as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; | |
2587 | as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; | |
2578 | 2588 | esac |
2579 | 2589 | case $srcdir in |
2580 | 2590 | *[\\\"\#\$\&\'\`$am_lf\ \ ]*) |
2581 | as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; | |
2591 | as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; | |
2582 | 2592 | esac |
2583 | 2593 | |
2584 | 2594 | # Do `set' in a subshell so we don't clobber the current shell's |
2600 | 2610 | # if, for instance, CONFIG_SHELL is bash and it inherits a |
2601 | 2611 | # broken ls alias from the environment. This has actually |
2602 | 2612 | # 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 | |
2604 | 2614 | alias in your environment" "$LINENO" 5 |
2605 | 2615 | fi |
2606 | 2616 | |
2610 | 2620 | # Ok. |
2611 | 2621 | : |
2612 | 2622 | 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! | |
2614 | 2624 | Check your system clock" "$LINENO" 5 |
2615 | 2625 | fi |
2616 | 2626 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 |
2848 | 2858 | $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } |
2849 | 2859 | set x ${MAKE-make} |
2850 | 2860 | 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 : | |
2852 | 2862 | $as_echo_n "(cached) " >&6 |
2853 | 2863 | else |
2854 | 2864 | cat >conftest.make <<\_ACEOF |
2856 | 2866 | all: |
2857 | 2867 | @echo '@@@%%%=$(MAKE)=@@@%%%' |
2858 | 2868 | _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. | |
2860 | 2870 | case `${MAKE-make} -f conftest.make 2>/dev/null` in |
2861 | 2871 | *@@@%%%=?*=@@@%%%*) |
2862 | 2872 | eval ac_cv_prog_make_${ac_make}_set=yes;; |
2890 | 2900 | am__isrc=' -I$(srcdir)' |
2891 | 2901 | # test to see if srcdir already configured |
2892 | 2902 | 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 | |
2894 | 2904 | fi |
2895 | 2905 | fi |
2896 | 2906 | |
2906 | 2916 | |
2907 | 2917 | # Define the identity of the package. |
2908 | 2918 | PACKAGE='nfdump' |
2909 | VERSION='1.6.1p1' | |
2919 | VERSION='1.6.3' | |
2910 | 2920 | |
2911 | 2921 | |
2912 | 2922 | cat >>confdefs.h <<_ACEOF |
3248 | 3258 | |
3249 | 3259 | test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
3250 | 3260 | $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; } | |
3253 | 3263 | |
3254 | 3264 | # Provide some information about the compiler. |
3255 | 3265 | $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 |
3363 | 3373 | |
3364 | 3374 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
3365 | 3375 | $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; } | |
3369 | 3378 | else |
3370 | 3379 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 |
3371 | 3380 | $as_echo "yes" >&6; } |
3407 | 3416 | else |
3408 | 3417 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
3409 | 3418 | $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; } | |
3412 | 3421 | fi |
3413 | 3422 | rm -f conftest conftest$ac_cv_exeext |
3414 | 3423 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 |
3465 | 3474 | else |
3466 | 3475 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
3467 | 3476 | $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. | |
3469 | 3478 | 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; } | |
3471 | 3480 | fi |
3472 | 3481 | fi |
3473 | 3482 | fi |
3518 | 3527 | |
3519 | 3528 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
3520 | 3529 | $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; } | |
3523 | 3532 | fi |
3524 | 3533 | rm -f conftest.$ac_cv_objext conftest.$ac_ext |
3525 | 3534 | fi |
3937 | 3946 | fi |
3938 | 3947 | set dummy $CC; ac_cc=`$as_echo "$2" | |
3939 | 3948 | 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 : | |
3941 | 3950 | $as_echo_n "(cached) " >&6 |
3942 | 3951 | else |
3943 | 3952 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
4251 | 4260 | elif test -f lexyy.c; then |
4252 | 4261 | ac_cv_prog_lex_root=lexyy |
4253 | 4262 | 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 | |
4255 | 4264 | fi |
4256 | 4265 | fi |
4257 | 4266 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 |
4325 | 4334 | fi |
4326 | 4335 | which $LEX > /dev/null 2>&1 |
4327 | 4336 | 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 | |
4329 | 4338 | fi |
4330 | 4339 | |
4331 | 4340 | |
4411 | 4420 | LIBS="-lz $LIBS" |
4412 | 4421 | |
4413 | 4422 | 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 | |
4415 | 4424 | |
4416 | 4425 | fi |
4417 | 4426 | |
4418 | 4427 | if test -d "$WHERE_FTPATH"; then |
4419 | 4428 | 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 | |
4421 | 4430 | fi |
4422 | 4431 | 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 | |
4424 | 4433 | fi |
4425 | 4434 | FT_INCLUDES="-I$WHERE_FTPATH/include -I$WHERE_FTPATH/lib" |
4426 | 4435 | FT_LDFLAGS="-L$WHERE_FTPATH/lib" |
4427 | 4436 | 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 | |
4429 | 4438 | fi |
4430 | 4439 | if true; then |
4431 | 4440 | FT2NFDUMP_TRUE= |
4492 | 4501 | # Broken: fails on valid input. |
4493 | 4502 | continue |
4494 | 4503 | fi |
4495 | rm -f conftest.err conftest.$ac_ext | |
4504 | rm -f conftest.err conftest.i conftest.$ac_ext | |
4496 | 4505 | |
4497 | 4506 | # OK, works on sane cases. Now check whether nonexistent headers |
4498 | 4507 | # can be detected and how. |
4508 | 4517 | ac_preproc_ok=: |
4509 | 4518 | break |
4510 | 4519 | fi |
4511 | rm -f conftest.err conftest.$ac_ext | |
4520 | rm -f conftest.err conftest.i conftest.$ac_ext | |
4512 | 4521 | |
4513 | 4522 | done |
4514 | 4523 | # 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 | |
4516 | 4525 | if $ac_preproc_ok; then : |
4517 | 4526 | break |
4518 | 4527 | fi |
4551 | 4560 | # Broken: fails on valid input. |
4552 | 4561 | continue |
4553 | 4562 | fi |
4554 | rm -f conftest.err conftest.$ac_ext | |
4563 | rm -f conftest.err conftest.i conftest.$ac_ext | |
4555 | 4564 | |
4556 | 4565 | # OK, works on sane cases. Now check whether nonexistent headers |
4557 | 4566 | # can be detected and how. |
4567 | 4576 | ac_preproc_ok=: |
4568 | 4577 | break |
4569 | 4578 | fi |
4570 | rm -f conftest.err conftest.$ac_ext | |
4579 | rm -f conftest.err conftest.i conftest.$ac_ext | |
4571 | 4580 | |
4572 | 4581 | done |
4573 | 4582 | # 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 | |
4575 | 4584 | if $ac_preproc_ok; then : |
4576 | 4585 | |
4577 | 4586 | else |
4578 | 4587 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
4579 | 4588 | $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; } | |
4582 | 4591 | fi |
4583 | 4592 | |
4584 | 4593 | ac_ext=c |
4639 | 4648 | done |
4640 | 4649 | IFS=$as_save_IFS |
4641 | 4650 | 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 | |
4643 | 4652 | fi |
4644 | 4653 | else |
4645 | 4654 | ac_cv_path_GREP=$GREP |
4705 | 4714 | done |
4706 | 4715 | IFS=$as_save_IFS |
4707 | 4716 | 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 | |
4709 | 4718 | fi |
4710 | 4719 | else |
4711 | 4720 | ac_cv_path_EGREP=$EGREP |
4837 | 4846 | as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` |
4838 | 4847 | ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default |
4839 | 4848 | " |
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 : | |
4842 | 4850 | cat >>confdefs.h <<_ACEOF |
4843 | 4851 | #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 |
4844 | 4852 | _ACEOF |
4897 | 4905 | |
4898 | 4906 | |
4899 | 4907 | 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 | |
4901 | 4909 | fi |
4902 | 4910 | |
4903 | 4911 | for ac_header in rrd.h |
4922 | 4930 | fi |
4923 | 4931 | |
4924 | 4932 | 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 | |
4926 | 4934 | fi |
4927 | 4935 | if test "$cross_compiling" = yes; then : |
4928 | 4936 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
4929 | 4937 | $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; } | |
4932 | 4940 | else |
4933 | 4941 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
4934 | 4942 | /* end confdefs.h. */ |
4950 | 4958 | if ac_fn_c_try_run "$LINENO"; then : |
4951 | 4959 | |
4952 | 4960 | 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 | |
4954 | 4962 | fi |
4955 | 4963 | rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ |
4956 | 4964 | conftest.$ac_objext conftest.beam conftest.$ac_ext |
4966 | 4974 | else |
4967 | 4975 | NFPROFILE_TRUE='#' |
4968 | 4976 | 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= | |
4969 | 5101 | fi |
4970 | 5102 | |
4971 | 5103 | |
5184 | 5316 | do : |
5185 | 5317 | as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` |
5186 | 5318 | 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 : | |
5189 | 5320 | cat >>confdefs.h <<_ACEOF |
5190 | 5321 | #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 |
5191 | 5322 | _ACEOF |
5201 | 5332 | as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` |
5202 | 5333 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 |
5203 | 5334 | $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 : | |
5205 | 5336 | $as_echo_n "(cached) " >&6 |
5206 | 5337 | else |
5207 | 5338 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
5228 | 5359 | eval ac_res=\$$as_ac_Header |
5229 | 5360 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 |
5230 | 5361 | $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 : | |
5233 | 5363 | cat >>confdefs.h <<_ACEOF |
5234 | 5364 | #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 |
5235 | 5365 | _ACEOF |
5483 | 5613 | do : |
5484 | 5614 | as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` |
5485 | 5615 | 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 : | |
5488 | 5617 | cat >>confdefs.h <<_ACEOF |
5489 | 5618 | #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 |
5490 | 5619 | _ACEOF |
5510 | 5639 | # include <netdb.h> |
5511 | 5640 | #endif |
5512 | 5641 | " |
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 : | |
5515 | 5643 | cat >>confdefs.h <<_ACEOF |
5516 | 5644 | #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 |
5517 | 5645 | _ACEOF |
5544 | 5672 | if test "$ac_cv_type_void_p" = yes; then |
5545 | 5673 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
5546 | 5674 | $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; } | |
5550 | 5677 | else |
5551 | 5678 | ac_cv_sizeof_void_p=0 |
5552 | 5679 | fi |
5906 | 6033 | |
5907 | 6034 | ;; #( |
5908 | 6035 | *) |
5909 | as_fn_error "unknown endianness | |
6036 | as_fn_error $? "unknown endianness | |
5910 | 6037 | presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; |
5911 | 6038 | esac |
5912 | 6039 | |
6137 | 6264 | do : |
6138 | 6265 | as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` |
6139 | 6266 | 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 : | |
6142 | 6268 | cat >>confdefs.h <<_ACEOF |
6143 | 6269 | #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 |
6144 | 6270 | _ACEOF |
6445 | 6571 | as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` |
6446 | 6572 | ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default |
6447 | 6573 | " |
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 : | |
6450 | 6575 | cat >>confdefs.h <<_ACEOF |
6451 | 6576 | #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 |
6452 | 6577 | _ACEOF |
6466 | 6591 | do : |
6467 | 6592 | as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` |
6468 | 6593 | 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 : | |
6471 | 6595 | cat >>confdefs.h <<_ACEOF |
6472 | 6596 | #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 |
6473 | 6597 | _ACEOF |
6519 | 6643 | static time_t time_t_min; |
6520 | 6644 | |
6521 | 6645 | /* 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", | |
6524 | 6648 | "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" |
6525 | 6649 | }; |
6526 | 6650 | #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) |
6537 | 6661 | instead of "TZ=America/Vancouver" in order to detect the bug even |
6538 | 6662 | on systems that don't support the Olson extension, or don't have the |
6539 | 6663 | 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"); | |
6541 | 6665 | |
6542 | 6666 | tm.tm_year = 98; |
6543 | 6667 | tm.tm_mon = 3; |
6550 | 6674 | } |
6551 | 6675 | |
6552 | 6676 | static int |
6553 | mktime_test1 (now) | |
6554 | time_t now; | |
6677 | mktime_test1 (time_t now) | |
6555 | 6678 | { |
6556 | 6679 | struct tm *lt; |
6557 | 6680 | return ! (lt = localtime (&now)) || mktime (lt) == now; |
6558 | 6681 | } |
6559 | 6682 | |
6560 | 6683 | static int |
6561 | mktime_test (now) | |
6562 | time_t now; | |
6684 | mktime_test (time_t now) | |
6563 | 6685 | { |
6564 | 6686 | return (mktime_test1 (now) |
6565 | 6687 | && mktime_test1 ((time_t) (time_t_max - now)) |
6583 | 6705 | } |
6584 | 6706 | |
6585 | 6707 | static int |
6586 | bigtime_test (j) | |
6587 | int j; | |
6708 | bigtime_test (int j) | |
6588 | 6709 | { |
6589 | 6710 | struct tm tm; |
6590 | 6711 | time_t now; |
6628 | 6749 | instead of "TZ=America/Vancouver" in order to detect the bug even |
6629 | 6750 | on systems that don't support the Olson extension, or don't have the |
6630 | 6751 | 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"); | |
6632 | 6753 | |
6633 | 6754 | t = mktime (&tm); |
6634 | 6755 | |
6663 | 6784 | for (i = 0; i < N_STRINGS; i++) |
6664 | 6785 | { |
6665 | 6786 | if (tz_strings[i]) |
6666 | putenv (tz_strings[i]); | |
6787 | putenv ((char*) tz_strings[i]); | |
6667 | 6788 | |
6668 | 6789 | for (t = 0; t <= time_t_max - delta; t += delta) |
6669 | 6790 | if (! mktime_test (t)) |
6939 | 7060 | do : |
6940 | 7061 | as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` |
6941 | 7062 | 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 : | |
6944 | 7064 | cat >>confdefs.h <<_ACEOF |
6945 | 7065 | #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 |
6946 | 7066 | _ACEOF |
7263 | 7383 | if test "$ac_cv_type_short" = yes; then |
7264 | 7384 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7265 | 7385 | $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; } | |
7269 | 7388 | else |
7270 | 7389 | ac_cv_sizeof_short=0 |
7271 | 7390 | fi |
7297 | 7416 | if test "$ac_cv_type_int" = yes; then |
7298 | 7417 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7299 | 7418 | $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; } | |
7303 | 7421 | else |
7304 | 7422 | ac_cv_sizeof_int=0 |
7305 | 7423 | fi |
7331 | 7449 | if test "$ac_cv_type_long" = yes; then |
7332 | 7450 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7333 | 7451 | $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; } | |
7337 | 7454 | else |
7338 | 7455 | ac_cv_sizeof_long=0 |
7339 | 7456 | fi |
7365 | 7482 | if test "$ac_cv_type_long_long" = yes; then |
7366 | 7483 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7367 | 7484 | $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; } | |
7371 | 7487 | else |
7372 | 7488 | ac_cv_sizeof_long_long=0 |
7373 | 7489 | fi |
7399 | 7515 | if test "$ac_cv_type___int64" = yes; then |
7400 | 7516 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7401 | 7517 | $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; } | |
7405 | 7520 | else |
7406 | 7521 | ac_cv_sizeof___int64=0 |
7407 | 7522 | fi |
7433 | 7548 | if test "$ac_cv_type_void_p" = yes; then |
7434 | 7549 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7435 | 7550 | $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; } | |
7439 | 7553 | else |
7440 | 7554 | ac_cv_sizeof_void_p=0 |
7441 | 7555 | fi |
7467 | 7581 | if test "$ac_cv_type_size_t" = yes; then |
7468 | 7582 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7469 | 7583 | $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; } | |
7473 | 7586 | else |
7474 | 7587 | ac_cv_sizeof_size_t=0 |
7475 | 7588 | fi |
7501 | 7614 | if test "$ac_cv_type_ptrdiff_t" = yes; then |
7502 | 7615 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
7503 | 7616 | $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; } | |
7507 | 7619 | else |
7508 | 7620 | ac_cv_sizeof_ptrdiff_t=0 |
7509 | 7621 | fi |
7604 | 7716 | do : |
7605 | 7717 | as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` |
7606 | 7718 | 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 : | |
7609 | 7720 | cat >>confdefs.h <<_ACEOF |
7610 | 7721 | #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 |
7611 | 7722 | _ACEOF |
7789 | 7900 | |
7790 | 7901 | ac_libobjs= |
7791 | 7902 | ac_ltlibobjs= |
7903 | U= | |
7792 | 7904 | for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue |
7793 | 7905 | # 1. Remove the extension, and $U if already installed. |
7794 | 7906 | ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' |
7812 | 7924 | fi |
7813 | 7925 | |
7814 | 7926 | 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. | |
7816 | 7928 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7817 | 7929 | fi |
7818 | 7930 | 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. | |
7820 | 7932 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7821 | 7933 | fi |
7822 | 7934 | 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. | |
7824 | 7936 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7825 | 7937 | fi |
7826 | 7938 | 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. | |
7828 | 7940 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7829 | 7941 | fi |
7830 | 7942 | 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. | |
7832 | 7944 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7833 | 7945 | fi |
7834 | 7946 | 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. | |
7836 | 7948 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7837 | 7949 | 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 | |
7838 | 7958 | 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. | |
7840 | 7960 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7841 | 7961 | fi |
7842 | 7962 | 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. | |
7844 | 7964 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
7845 | 7965 | fi |
7846 | 7966 | |
7991 | 8111 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH |
7992 | 8112 | |
7993 | 8113 | |
7994 | # as_fn_error ERROR [LINENO LOG_FD] | |
7995 | # --------------------------------- | |
8114 | # as_fn_error STATUS ERROR [LINENO LOG_FD] | |
8115 | # ---------------------------------------- | |
7996 | 8116 | # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are |
7997 | 8117 | # 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. | |
7999 | 8119 | as_fn_error () |
8000 | 8120 | { |
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 | |
8005 | 8125 | fi |
8006 | $as_echo "$as_me: error: $1" >&2 | |
8126 | $as_echo "$as_me: error: $2" >&2 | |
8007 | 8127 | as_fn_exit $as_status |
8008 | 8128 | } # as_fn_error |
8009 | 8129 | |
8199 | 8319 | test -d "$as_dir" && break |
8200 | 8320 | done |
8201 | 8321 | 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" | |
8203 | 8323 | |
8204 | 8324 | |
8205 | 8325 | } # as_fn_mkdir_p |
8252 | 8372 | # report actual input values of CONFIG_FILES etc. instead of their |
8253 | 8373 | # values after options handling. |
8254 | 8374 | 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 | |
8257 | 8377 | |
8258 | 8378 | CONFIG_FILES = $CONFIG_FILES |
8259 | 8379 | CONFIG_HEADERS = $CONFIG_HEADERS |
8318 | 8438 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
8319 | 8439 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
8320 | 8440 | 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, | |
8323 | 8443 | with options \\"\$ac_cs_config\\" |
8324 | 8444 | |
8325 | Copyright (C) 2009 Free Software Foundation, Inc. | |
8445 | Copyright (C) 2010 Free Software Foundation, Inc. | |
8326 | 8446 | This config.status script is free software; the Free Software Foundation |
8327 | 8447 | gives unlimited permission to copy, distribute and modify it." |
8328 | 8448 | |
8340 | 8460 | while test $# != 0 |
8341 | 8461 | do |
8342 | 8462 | case $1 in |
8343 | --*=*) | |
8463 | --*=?*) | |
8344 | 8464 | ac_option=`expr "X$1" : 'X\([^=]*\)='` |
8345 | 8465 | ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` |
8466 | ac_shift=: | |
8467 | ;; | |
8468 | --*=) | |
8469 | ac_option=`expr "X$1" : 'X\([^=]*\)='` | |
8470 | ac_optarg= | |
8346 | 8471 | ac_shift=: |
8347 | 8472 | ;; |
8348 | 8473 | *) |
8366 | 8491 | $ac_shift |
8367 | 8492 | case $ac_optarg in |
8368 | 8493 | *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; |
8494 | '') as_fn_error $? "missing file argument" ;; | |
8369 | 8495 | esac |
8370 | 8496 | as_fn_append CONFIG_FILES " '$ac_optarg'" |
8371 | 8497 | ac_need_defaults=false;; |
8378 | 8504 | ac_need_defaults=false;; |
8379 | 8505 | --he | --h) |
8380 | 8506 | # Conflict between --help and --header |
8381 | as_fn_error "ambiguous option: \`$1' | |
8507 | as_fn_error $? "ambiguous option: \`$1' | |
8382 | 8508 | Try \`$0 --help' for more information.";; |
8383 | 8509 | --help | --hel | -h ) |
8384 | 8510 | $as_echo "$ac_cs_usage"; exit ;; |
8387 | 8513 | ac_cs_silent=: ;; |
8388 | 8514 | |
8389 | 8515 | # This is an error. |
8390 | -*) as_fn_error "unrecognized option: \`$1' | |
8516 | -*) as_fn_error $? "unrecognized option: \`$1' | |
8391 | 8517 | Try \`$0 --help' for more information." ;; |
8392 | 8518 | |
8393 | 8519 | *) as_fn_append ac_config_targets " $1" |
8447 | 8573 | "bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;; |
8448 | 8574 | "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; |
8449 | 8575 | |
8450 | *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; | |
8576 | *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; | |
8451 | 8577 | esac |
8452 | 8578 | done |
8453 | 8579 | |
8485 | 8611 | { |
8486 | 8612 | tmp=./conf$$-$RANDOM |
8487 | 8613 | (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 | |
8489 | 8615 | |
8490 | 8616 | # Set up the scripts for CONFIG_FILES section. |
8491 | 8617 | # No need to generate them if there are no CONFIG_FILES. |
8502 | 8628 | fi |
8503 | 8629 | ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` |
8504 | 8630 | if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then |
8505 | ac_cs_awk_cr='\r' | |
8631 | ac_cs_awk_cr='\\r' | |
8506 | 8632 | else |
8507 | 8633 | ac_cs_awk_cr=$ac_cr |
8508 | 8634 | fi |
8516 | 8642 | echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && |
8517 | 8643 | echo "_ACEOF" |
8518 | 8644 | } >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 '^'` | |
8521 | 8647 | ac_delim='%!_!# ' |
8522 | 8648 | for ac_last_try in false false false false false :; do |
8523 | 8649 | . ./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 | |
8525 | 8651 | |
8526 | 8652 | ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` |
8527 | 8653 | if test $ac_delim_n = $ac_delim_num; then |
8528 | 8654 | break |
8529 | 8655 | 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 | |
8531 | 8657 | else |
8532 | 8658 | ac_delim="$ac_delim!$ac_delim _$ac_delim!! " |
8533 | 8659 | fi |
8616 | 8742 | else |
8617 | 8743 | cat |
8618 | 8744 | 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 | |
8624 | 8750 | # trailing colons and then remove the whole line if VPATH becomes empty |
8625 | 8751 | # (actually we leave an empty line to preserve line numbers). |
8626 | 8752 | 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/^:*// | |
8632 | 8762 | s/:*$// |
8763 | x | |
8764 | s/\(=[ ]*\).*/\1/ | |
8765 | G | |
8766 | s/\n// | |
8633 | 8767 | s/^[^=]*=[ ]*$// |
8634 | 8768 | }' |
8635 | 8769 | fi |
8657 | 8791 | if test -z "$ac_t"; then |
8658 | 8792 | break |
8659 | 8793 | 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 | |
8661 | 8795 | else |
8662 | 8796 | ac_delim="$ac_delim!$ac_delim _$ac_delim!! " |
8663 | 8797 | fi |
8742 | 8876 | _ACAWK |
8743 | 8877 | _ACEOF |
8744 | 8878 | 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 | |
8746 | 8880 | fi # test -n "$CONFIG_HEADERS" |
8747 | 8881 | |
8748 | 8882 | |
8755 | 8889 | esac |
8756 | 8890 | case $ac_mode$ac_tag in |
8757 | 8891 | :[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;; | |
8759 | 8893 | :[FH]-) ac_tag=-:-;; |
8760 | 8894 | :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; |
8761 | 8895 | esac |
8783 | 8917 | [\\/$]*) false;; |
8784 | 8918 | *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; |
8785 | 8919 | 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;; | |
8787 | 8921 | esac |
8788 | 8922 | case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac |
8789 | 8923 | as_fn_append ac_file_inputs " '$ac_f'" |
8810 | 8944 | |
8811 | 8945 | case $ac_tag in |
8812 | 8946 | *:-:* | *:-) 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 ;; | |
8814 | 8948 | esac |
8815 | 8949 | ;; |
8816 | 8950 | esac |
8947 | 9081 | $ac_datarootdir_hack |
8948 | 9082 | " |
8949 | 9083 | 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 | |
8951 | 9085 | |
8952 | 9086 | test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && |
8953 | 9087 | { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && |
8954 | 9088 | { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && |
8955 | 9089 | { $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 | |
8957 | 9091 | $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;} | |
8959 | 9093 | |
8960 | 9094 | rm -f "$tmp/stdin" |
8961 | 9095 | case $ac_file in |
8962 | 9096 | -) cat "$tmp/out" && rm -f "$tmp/out";; |
8963 | 9097 | *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; |
8964 | 9098 | esac \ |
8965 | || as_fn_error "could not create $ac_file" "$LINENO" 5 | |
9099 | || as_fn_error $? "could not create $ac_file" "$LINENO" 5 | |
8966 | 9100 | ;; |
8967 | 9101 | :H) |
8968 | 9102 | # |
8973 | 9107 | $as_echo "/* $configure_input */" \ |
8974 | 9108 | && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" |
8975 | 9109 | } >"$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 | |
8977 | 9111 | if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then |
8978 | 9112 | { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 |
8979 | 9113 | $as_echo "$as_me: $ac_file is unchanged" >&6;} |
8980 | 9114 | else |
8981 | 9115 | rm -f "$ac_file" |
8982 | 9116 | 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 | |
8984 | 9118 | fi |
8985 | 9119 | else |
8986 | 9120 | $as_echo "/* $configure_input */" \ |
8987 | 9121 | && 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 | |
8989 | 9123 | fi |
8990 | 9124 | # Compute "$ac_file"'s index in $config_headers. |
8991 | 9125 | _am_arg="$ac_file" |
9135 | 9269 | ac_clean_files=$ac_clean_files_save |
9136 | 9270 | |
9137 | 9271 | 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 | |
9139 | 9273 | |
9140 | 9274 | |
9141 | 9275 | # configure is writing to config.log, and then calls config.status. |
9156 | 9290 | exec 5>>config.log |
9157 | 9291 | # Use ||, not &&, to avoid exiting from the if with $? = 1, which |
9158 | 9292 | # 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 | |
9160 | 9294 | fi |
9161 | 9295 | if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then |
9162 | 9296 | { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 |
2 | 2 | |
3 | 3 | AC_PREREQ(2.59) |
4 | 4 | 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) | |
6 | 6 | #AC_CONFIG_SRCDIR([grammar.y]) |
7 | 7 | AC_CONFIG_HEADER([config.h]) |
8 | 8 | AM_INIT_AUTOMAKE() |
147 | 147 | ] |
148 | 148 | , |
149 | 149 | 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) | |
150 | 183 | ) |
151 | 184 | |
152 | 185 | 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
0 | # Makefile.in generated by automake 1.11 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.11.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | 3 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
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 |
362 | 362 | .RE |
363 | 363 | .PD |
364 | 364 | .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 | |
379 | 365 | .B -q |
380 | 366 | Suppress the header line and the statistics at the bottom. |
381 | 367 | .TP 3 |