diff -Nur flow-tools-0.56-orig/Makefile.am flow-tools-0.56/Makefile.am --- flow-tools-0.56-orig/Makefile.am Mon Jul 16 13:02:07 2001 +++ flow-tools-0.56/Makefile.am Sat Feb 9 13:20:31 2002 @@ -1,4 +1,4 @@ -SUBDIRS = lib src docs configs +SUBDIRS = lib src docs configs contrib EXTRA_DIST = bin/flow-mirror bin/flow-rsync bin/flow-search utils/* \ SECURITY contrib/* configs/* diff -Nur flow-tools-0.56-orig/Makefile.in flow-tools-0.56/Makefile.in --- flow-tools-0.56-orig/Makefile.in Sat Dec 29 06:27:24 2001 +++ flow-tools-0.56/Makefile.in Sat Feb 9 13:20:42 2002 @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -66,7 +66,7 @@ YACC = @YACC@ YLIB = @YLIB@ -SUBDIRS = lib src docs configs +SUBDIRS = lib src docs configs contrib EXTRA_DIST = bin/flow-mirror bin/flow-rsync bin/flow-search utils/* SECURITY contrib/* configs/* @@ -81,14 +81,14 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -164,7 +164,7 @@ dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ - test "$$subdir" != "." || dot_seen=yes; \ + test "$$subdir" = "." && dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && rev=". $$rev"; \ target=`echo $@ | sed s/-recursive//`; \ @@ -255,6 +255,11 @@ -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile $(mkinstalldirs) $(distdir)/bin $(distdir)/configs $(distdir)/contrib \ $(distdir)/utils @for file in $(DISTFILES); do \ diff -Nur flow-tools-0.56-orig/aclocal.m4 flow-tools-0.56/aclocal.m4 --- flow-tools-0.56-orig/aclocal.m4 Sat Dec 29 06:05:33 2001 +++ flow-tools-0.56/aclocal.m4 Sat Feb 9 13:20:42 2002 @@ -1,6 +1,6 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4-p5 +dnl aclocal.m4 generated automatically by aclocal 1.4 -dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -19,7 +19,7 @@ dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) -AC_DEFUN([AM_INIT_AUTOMAKE], +AC_DEFUN(AM_INIT_AUTOMAKE, [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) @@ -47,7 +47,7 @@ # Check to make sure that the build environment is sane. # -AC_DEFUN([AM_SANITY_CHECK], +AC_DEFUN(AM_SANITY_CHECK, [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 @@ -88,7 +88,7 @@ dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. -AC_DEFUN([AM_MISSING_PROG], +AC_DEFUN(AM_MISSING_PROG, [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -104,7 +104,7 @@ # Like AC_CONFIG_HEADER, but automatically create stamp file. -AC_DEFUN([AM_CONFIG_HEADER], +AC_DEFUN(AM_CONFIG_HEADER, [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. @@ -128,7 +128,7 @@ dnl AM_PROG_LEX dnl Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT -AC_DEFUN([AM_PROG_LEX], +AC_DEFUN(AM_PROG_LEX, [missing_dir=ifelse([$1],,`cd $ac_aux_dir && pwd`,$1) AC_CHECK_PROGS(LEX, flex lex, "$missing_dir/missing flex") AC_PROG_LEX diff -Nur flow-tools-0.56-orig/configs/Makefile flow-tools-0.56/configs/Makefile --- flow-tools-0.56-orig/configs/Makefile Sat Dec 29 06:05:48 2001 +++ flow-tools-0.56/configs/Makefile Thu Jan 1 08:00:00 1970 @@ -1,217 +0,0 @@ -# Generated automatically from Makefile.in by configure. -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = /bin/sh - -srcdir = . -top_srcdir = .. -prefix = /usr/local/netflow -exec_prefix = ${prefix} - -bindir = ${exec_prefix}/bin -sbindir = ${exec_prefix}/sbin -libexecdir = ${exec_prefix}/libexec -datadir = ${prefix}/share -sysconfdir = ${prefix}/etc -sharedstatedir = ${prefix}/com -localstatedir = /var/ft -libdir = ${exec_prefix}/lib -infodir = ${prefix}/info -mandir = ${prefix}/man -includedir = ${prefix}/include -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/flow-tools -pkglibdir = $(libdir)/flow-tools -pkgincludedir = $(includedir)/flow-tools - -top_builddir = .. - -ACLOCAL = aclocal -AUTOCONF = autoconf -AUTOMAKE = automake -AUTOHEADER = autoheader - -INSTALL = /usr/bin/install -c -INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_SCRIPT = ${INSTALL_PROGRAM} -transform = s,x,x, - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -CC = gcc -LEX = flex -MAKEINFO = makeinfo -PACKAGE = flow-tools -RANLIB = ranlib -VERSION = 0.56 -YACC = byacc -d -YLIB = -ly - -ftsymdir = $(localstatedir)/sym -ftsym_DATA = asn ip-prot tcp-port - -ftcfgdir = $(localstatedir)/cfg -ftcfg_DATA = map filter-acl -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../config.h -CONFIG_CLEAN_FILES = -DATA = $(ftcfg_DATA) $(ftsym_DATA) - -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = tar -GZIP_ENV = --best -all: all-redirect -.SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps configs/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -install-ftcfgDATA: $(ftcfg_DATA) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(ftcfgdir) - @list='$(ftcfg_DATA)'; for p in $$list; do \ - if test -f $(srcdir)/$$p; then \ - echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(ftcfgdir)/$$p"; \ - $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(ftcfgdir)/$$p; \ - else if test -f $$p; then \ - echo " $(INSTALL_DATA) $$p $(DESTDIR)$(ftcfgdir)/$$p"; \ - $(INSTALL_DATA) $$p $(DESTDIR)$(ftcfgdir)/$$p; \ - fi; fi; \ - done - -uninstall-ftcfgDATA: - @$(NORMAL_UNINSTALL) - list='$(ftcfg_DATA)'; for p in $$list; do \ - rm -f $(DESTDIR)$(ftcfgdir)/$$p; \ - done - -install-ftsymDATA: $(ftsym_DATA) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(ftsymdir) - @list='$(ftsym_DATA)'; for p in $$list; do \ - if test -f $(srcdir)/$$p; then \ - echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(ftsymdir)/$$p"; \ - $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(ftsymdir)/$$p; \ - else if test -f $$p; then \ - echo " $(INSTALL_DATA) $$p $(DESTDIR)$(ftsymdir)/$$p"; \ - $(INSTALL_DATA) $$p $(DESTDIR)$(ftsymdir)/$$p; \ - fi; fi; \ - done - -uninstall-ftsymDATA: - @$(NORMAL_UNINSTALL) - list='$(ftsym_DATA)'; for p in $$list; do \ - rm -f $(DESTDIR)$(ftsymdir)/$$p; \ - done -tags: TAGS -TAGS: - - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = configs - -distdir: $(DISTFILES) - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: install-ftcfgDATA install-ftsymDATA -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: uninstall-ftcfgDATA uninstall-ftsymDATA -uninstall: uninstall-am -all-am: Makefile $(DATA) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - $(mkinstalldirs) $(DESTDIR)$(ftcfgdir) $(DESTDIR)$(ftsymdir) - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-generic clean-am - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-generic distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: uninstall-ftcfgDATA install-ftcfgDATA uninstall-ftsymDATA \ -install-ftsymDATA tags distdir info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff -Nur flow-tools-0.56-orig/configs/Makefile.in flow-tools-0.56/configs/Makefile.in --- flow-tools-0.56-orig/configs/Makefile.in Sat Dec 29 06:05:48 2001 +++ flow-tools-0.56/configs/Makefile.in Sat Feb 9 13:20:42 2002 @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -81,14 +81,14 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps configs/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu configs/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -139,6 +139,11 @@ subdir = configs distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu configs/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ diff -Nur flow-tools-0.56-orig/configure flow-tools-0.56/configure --- flow-tools-0.56-orig/configure Sat Dec 29 06:05:33 2001 +++ flow-tools-0.56/configure Sat Feb 9 13:20:42 2002 @@ -2971,7 +2971,7 @@ ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "lib/Makefile src/Makefile Makefile docs/Makefile lib/ftpaths.h configs/Makefile config.h:config.h.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "lib/Makefile src/Makefile Makefile docs/Makefile lib/ftpaths.h configs/Makefile contrib/Makefile contrib/inter.net/Makefile contrib/inter.net/libpatricia/Makefile config.h:config.h.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff -Nur flow-tools-0.56-orig/configure.in flow-tools-0.56/configure.in --- flow-tools-0.56-orig/configure.in Sat Dec 29 06:02:24 2001 +++ flow-tools-0.56/configure.in Sat Feb 9 13:07:57 2002 @@ -58,7 +58,7 @@ AC_CHECK_FUNCS(strtoull timelocal) AC_REPLACE_FUNCS(strsep strerror) -AC_OUTPUT(lib/Makefile src/Makefile Makefile docs/Makefile lib/ftpaths.h configs/Makefile) +AC_OUTPUT(lib/Makefile src/Makefile Makefile docs/Makefile lib/ftpaths.h configs/Makefile contrib/Makefile contrib/inter.net/Makefile contrib/inter.net/libpatricia/Makefile) echo echo "Please subscribe to the flow-tools mailing list by sending a message to" diff -Nur flow-tools-0.56-orig/contrib/Makefile.am flow-tools-0.56/contrib/Makefile.am --- flow-tools-0.56-orig/contrib/Makefile.am Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/Makefile.am Wed Feb 6 20:41:53 2002 @@ -0,0 +1,3 @@ + +SUBDIRS = inter.net + diff -Nur flow-tools-0.56-orig/contrib/Makefile.in flow-tools-0.56/contrib/Makefile.in --- flow-tools-0.56-orig/contrib/Makefile.in Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/Makefile.in Sat Feb 9 13:20:42 2002 @@ -0,0 +1,280 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +LEX = @LEX@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +YLIB = @YLIB@ + +SUBDIRS = inter.net +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu contrib/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = contrib + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu contrib/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: +uninstall: uninstall-recursive +all-am: Makefile +all-redirect: all-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: installdirs-recursive +installdirs-am: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-tags distclean-generic clean-am + +distclean: distclean-recursive + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + +.PHONY: install-data-recursive uninstall-data-recursive \ +install-exec-recursive uninstall-exec-recursive installdirs-recursive \ +uninstalldirs-recursive all-recursive check-recursive \ +installcheck-recursive info-recursive dvi-recursive \ +mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nur flow-tools-0.56-orig/contrib/inter.net/Makefile.am flow-tools-0.56/contrib/inter.net/Makefile.am --- flow-tools-0.56-orig/contrib/inter.net/Makefile.am Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/Makefile.am Sat Feb 9 13:19:58 2002 @@ -0,0 +1,28 @@ + +SUBDIRS = libpatricia + +noinst_HEADERS = + +INCLUDES = -I../../src -I../../lib -L../../lib -I./libpatricia -L./libpatricia + +bin_PROGRAMS = flow-split flow-as-if flow-cidr flow-iptime flow-syn + +flow_cidr_SOURCES = flow-cidr.c +flow_cidr_LDFLAGS = -L../../lib -L./libpatricia +flow_cidr_LDADD = -lft -lpatricia + +flow_split_SOURCES = flow-split.c +flow_split_LDFLAGS = -L../../lib -L./libpatricia +flow_split_LDADD = -lft -lpatricia + +flow_as_if_SOURCES = flow-as-if.c +flow_as_if_LDFLAGS = -L../../lib -L./libpatricia +flow_as_if_LDADD = -lft -lpatricia + +flow_iptime_SOURCES = flow-iptime.c +flow_iptime_LDFLAGS = -L../../lib +flow_iptime_LDADD = -lft + +flow_syn_SOURCES = flow-syn.c +flow_syn_LDFLAGS = -L../../lib +flow_syn_LDADD = -lft diff -Nur flow-tools-0.56-orig/contrib/inter.net/Makefile.in flow-tools-0.56/contrib/inter.net/Makefile.in --- flow-tools-0.56-orig/contrib/inter.net/Makefile.in Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/Makefile.in Sat Feb 9 13:20:42 2002 @@ -0,0 +1,439 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +LEX = @LEX@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +YLIB = @YLIB@ + +SUBDIRS = libpatricia + +noinst_HEADERS = + +INCLUDES = -I../../src -I../../lib -L../../lib -I./libpatricia -L./libpatricia + +bin_PROGRAMS = flow-split flow-as-if flow-cidr flow-iptime flow-syn + +flow_cidr_SOURCES = flow-cidr.c +flow_cidr_LDFLAGS = -L../../lib -L./libpatricia +flow_cidr_LDADD = -lft -lpatricia + +flow_split_SOURCES = flow-split.c +flow_split_LDFLAGS = -L../../lib -L./libpatricia +flow_split_LDADD = -lft -lpatricia + +flow_as_if_SOURCES = flow-as-if.c +flow_as_if_LDFLAGS = -L../../lib -L./libpatricia +flow_as_if_LDADD = -lft -lpatricia + +flow_iptime_SOURCES = flow-iptime.c +flow_iptime_LDFLAGS = -L../../lib +flow_iptime_LDADD = -lft + +flow_syn_SOURCES = flow-syn.c +flow_syn_LDFLAGS = -L../../lib +flow_syn_LDADD = -lft +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +flow_split_OBJECTS = flow-split.o +flow_split_DEPENDENCIES = +flow_as_if_OBJECTS = flow-as-if.o +flow_as_if_DEPENDENCIES = +flow_cidr_OBJECTS = flow-cidr.o +flow_cidr_DEPENDENCIES = +flow_iptime_OBJECTS = flow-iptime.o +flow_iptime_DEPENDENCIES = +flow_syn_OBJECTS = flow-syn.o +flow_syn_DEPENDENCIES = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/flow-as-if.P .deps/flow-cidr.P .deps/flow-iptime.P \ +.deps/flow-split.P .deps/flow-syn.P +SOURCES = $(flow_split_SOURCES) $(flow_as_if_SOURCES) $(flow_cidr_SOURCES) $(flow_iptime_SOURCES) $(flow_syn_SOURCES) +OBJECTS = $(flow_split_OBJECTS) $(flow_as_if_OBJECTS) $(flow_cidr_OBJECTS) $(flow_iptime_OBJECTS) $(flow_syn_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu contrib/inter.net/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +flow-split: $(flow_split_OBJECTS) $(flow_split_DEPENDENCIES) + @rm -f flow-split + $(LINK) $(flow_split_LDFLAGS) $(flow_split_OBJECTS) $(flow_split_LDADD) $(LIBS) + +flow-as-if: $(flow_as_if_OBJECTS) $(flow_as_if_DEPENDENCIES) + @rm -f flow-as-if + $(LINK) $(flow_as_if_LDFLAGS) $(flow_as_if_OBJECTS) $(flow_as_if_LDADD) $(LIBS) + +flow-cidr: $(flow_cidr_OBJECTS) $(flow_cidr_DEPENDENCIES) + @rm -f flow-cidr + $(LINK) $(flow_cidr_LDFLAGS) $(flow_cidr_OBJECTS) $(flow_cidr_LDADD) $(LIBS) + +flow-iptime: $(flow_iptime_OBJECTS) $(flow_iptime_DEPENDENCIES) + @rm -f flow-iptime + $(LINK) $(flow_iptime_LDFLAGS) $(flow_iptime_OBJECTS) $(flow_iptime_LDADD) $(LIBS) + +flow-syn: $(flow_syn_OBJECTS) $(flow_syn_DEPENDENCIES) + @rm -f flow-syn + $(LINK) $(flow_syn_LDFLAGS) $(flow_syn_OBJECTS) $(flow_syn_LDADD) $(LIBS) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = contrib/inter.net + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu contrib/inter.net/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +install-exec-am: install-binPROGRAMS +install-exec: install-exec-recursive + +install-data-am: +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: uninstall-binPROGRAMS +uninstall: uninstall-recursive +all-am: Makefile $(PROGRAMS) $(HEADERS) +all-redirect: all-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(bindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-depend distclean-generic clean-am + +distclean: distclean-recursive + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile install-data-recursive \ +uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs-am installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nur flow-tools-0.56-orig/contrib/inter.net/README flow-tools-0.56/contrib/inter.net/README --- flow-tools-0.56-orig/contrib/inter.net/README Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/README Wed Feb 6 20:41:39 2002 @@ -0,0 +1,77 @@ +flow-split +flow-split-rev +flow-as-if +flow-cidr + +---------------------------------------------- + +Miguel A.L. Paraz +Mandaluyong City, Metro Manila, Philippines +March 6, 2001 + +William Emmanuel S. Yu +Pasay City, Metro Manila, Philippines +April 5, 2001 + +NOTE: the scripts folder contains some miscellaneous scripts +that are potentially useful for monitoring traffic and +manipulating data files. + +---------------------------------------------- +flow-split + +While the rest of the flow-tools follow a "pipeline" philosophy, I found it +necessary to to be able to split flow data into many files matching certain +criteria. My immediate need was to split it according to destination IP +network, so that I could analyze the new files separately. + +flow-split description-file < flow-file + +or + +flow-cat flow-file ... | flow-split description-file + +Where description-file is currently a plain text file with: + +file1 prefix1 prefix2 prefix3 ... +file2 prefix1 prefix2 prefix3 ... +... + +For example: + +lan1 192.168.0.0/24 192.168.2.0/24 +lan2 192.168.1.0/24 192.168.3.0/24 + + +Right now everything there must be separated by a single space, no multiple +spaces nor tabs. (I appreciate it if someone could clean that up.) + +This was built and tested on Red Hat Linux 7. It depends on the C code Dave +Plonka's Net::Patricia perl module, available at CPAN, which packages up a +Patricia radix trie function that is used by flow-split to easily identify +flows. + +---------------------------------------------- +flow-as-if + +This tool generates a report based on the interfaces defined and will +order them according to ASN and source interfaces. The tool will +also group the results into clients based on a description file which +has the same format as the definition file above. + +Usage: + +flow-cat flow-file ... | flow-as-if -f description-file -i int1,.. [-e] [-c] + +---------------------------------------------- +flow-cidr + +This tools is to function as a part of flow-filter if need. flow-cidr +accepts various options for it to function. This is another filter tool. + +Usage: + +flow-cidr -f description-file -D name-in-description-file +flow-cidr -i ip-address-block/prefix-lenght + +This code is intend to be part of flow-filter. diff -Nur flow-tools-0.56-orig/contrib/inter.net/flow-as-if.c flow-tools-0.56/contrib/inter.net/flow-as-if.c --- flow-tools-0.56-orig/contrib/inter.net/flow-as-if.c Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/flow-as-if.c Wed Feb 6 20:41:39 2002 @@ -0,0 +1,576 @@ +/* + * Copyright (c) 2001 Mark Fullmer and The Ohio State University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: flow-as-if.c,v 1.8 2001/02/10 04:40:12 wyy Exp $ + */ + +/* subnets summary, with ASN and source interface. must specify + interfaces on the command line */ + +/* generic defines */ +#define IF_MAX 16 +#define ARRAY_NODE_TOPSIZE 64 + +/* generic includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* network related includes */ +#include + +/* flow-tools related includes */ +#include +#include +#include "ftlib.h" +#include "support.h" +#include "fmt.h" + +/* patricia tree related includes */ +#include "patricia.h" + +struct array_node { /* array node of the tree */ + u_int16 src_as; + u_int32 dOctets; + u_int32 exaddr; + /* Whatever other data */ +}; + +struct leaf_node { /* leaf node of the tree */ + + /* Actual data */ + struct array_node a_node[ARRAY_NODE_TOPSIZE]; + + /* How many we have in here. If in excess, follow the linked list */ + int n_arrays; + struct leaf_node *next; +}; + +struct output_record { /* record for storing output */ + u_int32 dOctets; + u_int32 dstaddr; + u_int8 dstmask; + u_int16 src_as; + u_int32 exaddr; + u_int16 input; +}; + +/* function declarations */ +extern prefix_t * New_Prefix (int family, void *dest, int bitlen); +int sort_compare_output_record (const void *pa, const void *pb); +int process(struct ftio *ftio); +void usage(); + +/* define debugging version of malloc */ +#ifdef DEBUG +int mem; + +void *MALLOC (size_t size) { + mem += size; + return malloc (size); +} + +#else +#define MALLOC(x) malloc(x) +#endif + +/* globally defined variables */ +int n_total_nodes; /* total number of nodes */ +static struct output_record *p_o_r; /* pointer for array-ll */ +patricia_tree_t *inside_tree[IF_MAX]; /* one tree per interface */ +int n_if_table=0; /* number of interfaces */ +int if_table[IF_MAX]; /* table of interfaces */ +int match_client=0; +int match_exact=0; +prefix_t pref_tmp; /* multipurpose addr holder */ + +patricia_tree_t *client_pt; /* variables for desc tree */ +patricia_node_t *client_pn; + +/* the main function */ +int main(int argc, char *argv[]) +{ + int i, ret; + extern char *optarg; + struct ftio ftio; + + patricia_node_t *node; + struct output_record *o_r; + int *p_i; + + prefix_t *pref; + FILE *desc_file; + + char *inputfile; /* manipulating args */ + char *int_string; + char *s; + char buf[512]; + + int n_entries=0; + +#ifdef DEBUG + int debug_counter; +#endif + + if (argc <= 1) { + usage(); + return(0); + } + + while ((i = getopt(argc, argv, "i:f:vhec")) != -1) + switch (i) { + case 'v': + printf("Version 0.01 Copyright 2001 William Emmanuel S. Yu\n"); + return(0); + break; + case 'i': + int_string = optarg; + break; + case 'f': + inputfile = optarg; + break; + case 'e': + match_exact = 1; + break; + case 'c': + match_client = 1; + break; + case 'h': + default: + usage(); + return(0); + break; + } + + /* check the number of interfaces */ + p_i = if_table; + + while (int_string != NULL) { + s = strchr(int_string, ','); + if (s != NULL) { + *s++=0; + } + + *(p_i++)=atoi(int_string); + n_if_table++; + + int_string = s; + }; + + if (n_if_table > IF_MAX) { + fputs("too many SNMP interface IDs on command line\n", stderr); + return 1; + } + + if (n_if_table <= 0) { + fputs("need at least one SNMP interface ID on command line\n", stderr); + return 1; + } + + /** + generate patricia tree for our descriptions based on + the description file + + filename prefix1 prefix2 prefix3 + + */ + if ((desc_file = fopen(inputfile, "r")) == NULL) { + fprintf (stderr, "could not open description filename: %s\n", argv[1]); + return 1; + } + + client_pt = New_Patricia(32); + + while (fgets (buf, 160, desc_file) != NULL) { + char *s, *s2; + + s = strchr(buf, '\n'); + *s = 0; + + s = strchr(buf, ' '); + if (s == NULL) + break; + + *s++ = 0; + + while (s != NULL) { + char *client_string; + + s2 = strchr(s,' '); + if (s2 != NULL) { + *s2++=0; + } + + if ((pref = ascii2prefix(AF_INET, s)) == NULL) { + fprintf (stderr, "invalid prefix: %s\n", s); + return 1; + } + + if ((client_pn = patricia_lookup(client_pt, pref)) == NULL) { + fprintf (stderr, "could not create node for prefix: %s\n", s); + } + + /* All we really want to store */ + client_string = MALLOC(sizeof(buf)+1); + strcpy(client_string,buf); + client_pn->data = client_string; + s = s2; + } + } + fclose(desc_file); + /* end generating patricia tree */ + + /* start reading flow file and do analysis */ + /* read from stdin */ + if (ftio_init(&ftio, 0, FT_IO_FLAG_READ) < 0) { + fprintf(stderr, "ftio_init(): failed\n"); + exit (1); + } + + /* Create */ + n_total_nodes = 0; + ret = process(&ftio); + + /* Calculate how many entries we need - worst case estimate */ + + o_r = p_o_r = MALLOC (n_total_nodes * ARRAY_NODE_TOPSIZE * sizeof(*o_r)); + + for (i = 0; i < IF_MAX; i++) { + if (inside_tree[i] == NULL) + continue; + + /* Dump the trees to the output record */ + PATRICIA_WALK(inside_tree[i]->head, node) { + struct leaf_node *pn = (struct leaf_node *)(node->data); + + while (pn != NULL) { + int j; + + for (j = 0; j < pn->n_arrays; j++) { + + u_int32 o = pn->a_node[j].dOctets; + + if (o > 0) { + p_o_r->dOctets = o; + p_o_r->exaddr = pn->a_node[j].exaddr; + p_o_r->src_as = pn->a_node[j].src_as; + p_o_r->dstaddr = node->prefix->add.sin.s_addr; + p_o_r->dstmask = node->prefix->bitlen; + p_o_r->input = if_table[i]; + + p_o_r++; + n_entries++; + } + } + pn = pn->next; + } + } + PATRICIA_WALK_END; + } + +#ifdef DEBUG + debug_counter=0; + printf("end walk: %d entries.\n",n_entries); +#endif + + /* Sort */ + qsort(o_r, n_entries, sizeof(*o_r), sort_compare_output_record); + + /* Output */ + p_o_r = o_r; + while (n_entries--) { + char fmt_buf1[64]; + char fmt_buf2[64]; + +#ifdef DEBUG + debug_counter++; +#endif + + /* converting IP to string */ + fmt_ipv4(fmt_buf1, p_o_r->dstaddr, FMT_PAD_RIGHT); + fmt_ipv4(fmt_buf2, p_o_r->exaddr, FMT_PAD_RIGHT); + + /* this "if" should be unnecessary but they are not eliminated above */ + if (p_o_r->dOctets > 0) { + printf ("%12d %5d %5d %s/%2d ", p_o_r->dOctets, p_o_r->input, + p_o_r->src_as, fmt_buf1, p_o_r->dstmask); + + /* generate readable form */ + pref_tmp.add.sin.s_addr = ntohl(p_o_r->dstaddr); + + if ((pref_tmp.bitlen = p_o_r->dstmask) == 0) { + pref_tmp.bitlen = 32; + } + + if ((client_pn = patricia_search_best(client_pt, &pref_tmp)) != NULL) { + printf ("%15.15s",(char *)client_pn->data); + } else { + printf (" unknown"); + } + + printf (" %s\n",fmt_buf2); + } + p_o_r++; + + } + + /* done! */ + +#ifdef DEBUG + fprintf (stderr, "mem: %d\n", mem); +#endif + + return 0; + +} /* main */ + + + + +/** + process() - function for reading the flow file and propagating + the patricia tree + */ +int process(struct ftio *ftio) +{ + struct fts3rec_v5 *rec; + prefix_t pref_out; + patricia_node_t *pn; + int if_e, *p; + +#ifdef LIMIT + int n = 0; +#endif + + if (ftio_check_generic(ftio) < 0) + return -1; + + pref_out.family = AF_INET; + pref_out.ref_count = 0; + + while ((rec = ftio_read(ftio)) + +#ifdef LIMIT + && (n++ < LIMIT) +#endif + ) { + + /* Find the interface entry */ + if_e = 0; + p = if_table; + + while ((if_e < n_if_table) && (*p++ != rec->input)) { + if_e++; + } + if (if_e == n_if_table) { + /* Ignore this unspecified interface */ + continue; + } + + pref_out.add.sin.s_addr = rec->dstaddr; + + if ((match_exact!=1) && (match_client!=1)) { + pref_out.bitlen = rec->dst_mask; + + /* Don't process 0 or 32 masks */ + if (pref_out.bitlen == 0) { + pref_out.bitlen = 32; + } + } + + if (match_client==1) { + + /* FIXME - must be able to change this to srcaddr later */ + pref_tmp.add.sin.s_addr = ntohl(rec->dstaddr); + pref_tmp.bitlen = 32; + + if ((client_pn = patricia_search_best(client_pt, &pref_tmp)) != NULL) { + pref_out.bitlen = client_pn->prefix->bitlen; + } else { + pref_out.bitlen = 32; + } + + } + + if (match_exact==1) { + pref_out.bitlen = 32; + } + + /* Mask the pref_in by its netmask */ + pref_out.add.sin.s_addr &= + (0xffffffff ^ ((1 << (32 - pref_out.bitlen)) - 1)); + + /* Does this interface have a tree yet? */ + if (inside_tree[if_e] == NULL) { + if ((inside_tree[if_e] = New_Patricia(32)) == NULL) { + fputs ("inside tree New failed\n", stderr); + } + pn = NULL; + } + + if (pn != NULL) { + /* Search for the best network */ + pn = patricia_search_best(inside_tree[if_e], &pref_out); + } + + if (pn == NULL) { + + /* Add a node */ + if ((pn = patricia_lookup(inside_tree[if_e], &pref_out)) == NULL) { + fputs ("inside patricia_lookup failed", stderr); + exit(1); + } + + /* Create the leaf node data */ + if ((pn->data = MALLOC(sizeof(struct leaf_node))) == NULL) { + fputs ("MALLOC pn->data failed", stderr); + exit (1); + } + + /* Just one element, points to nothing */ + ((struct leaf_node *)pn->data)->n_arrays = 1; + ((struct leaf_node *)pn->data)->next = NULL; + + /* Content */ + ((struct leaf_node *)pn->data)->a_node[0].src_as = rec->src_as; + ((struct leaf_node *)pn->data)->a_node[0].dOctets = rec->dOctets; + ((struct leaf_node *)pn->data)->a_node[0].exaddr = rec->exaddr; + + /* Need this for tracking: sort buffer and tree walk */ + n_total_nodes++; + + } + else { + /* We have the starting leaf node, look if we have the ASN already */ + struct array_node *anp; + struct leaf_node *lnpb, *lnp = (struct leaf_node *)pn->data; + int found = 0; + + while ((lnp != NULL) && !found) { + int i = 0; + + anp = lnp->a_node; + i = lnp->n_arrays; + + while ((i--) && !found) { + if (anp->src_as == rec->src_as) { + found = 1; + } + else { + anp++; + } + } + + if (!found) { + lnpb = lnp; + lnp = lnp->next; + } + } + + if (!found) { + /* Not found, see if the array is full already */ + if (lnpb->n_arrays == ARRAY_NODE_TOPSIZE) { + + /* Full, create a new leaf node */ + if ((lnp = MALLOC(sizeof(*lnp))) == NULL) { + fputs ("MALLOC lnp failed\n", stderr); + exit (1); + } + + /* Fill in the data */ + lnp->n_arrays = 1; + lnp->next = NULL; + lnp->a_node[0].src_as = rec->src_as; + lnp->a_node[0].dOctets = rec->dOctets; + lnp->a_node[0].exaddr = rec->exaddr; + + /* Backlink */ + lnpb->next = lnp; + n_total_nodes++; + } + else { + /* Not full, just add to the last node */ + int i = lnpb->n_arrays; +#ifdef DEBUG + if (i >= ARRAY_NODE_TOPSIZE) { + fputs ("GOTCHA 2", stderr); + } +#endif + + lnpb->a_node[i].src_as = rec->src_as; + lnpb->a_node[i].dOctets = rec->dOctets; + lnpb->a_node[i].exaddr = rec->exaddr; + lnpb->n_arrays++; + + } + } + else { + /* Found, just update */ + anp->dOctets += rec->dOctets; + } + } + + } /* while */ + + return 0; + +} /* process() */ + +/** + sort_compare_output_record() - function to be feed to qsort + function for sorting records by octet size. + */ +int sort_compare_output_record (const void *pa, const void *pb) { + if (((struct output_record *)pb)->dOctets < + ((struct output_record *)pa)->dOctets) { + return -1; + } + else if (((struct output_record *)pb)->dOctets > + ((struct output_record *)pa)->dOctets) { + return 1; + } + else return 0; +} /* sort_compare_output_record() */ + +/** + usage() - displayed usage message + */ +void usage() +{ + fprintf(stderr, "flow-as-if:\n\n"); + fprintf(stderr, " -f filename input definition file\n"); + fprintf(stderr, " -i interfaces interface list\n"); + fprintf(stderr, " -e exactly match IPs\n"); + fprintf(stderr, " -c exactly match client\n"); + fprintf(stderr, " -v show version number\n"); + fprintf(stderr, " -h help\n"); + fprintf(stderr, "\n"); +} /* usage() */ diff -Nur flow-tools-0.56-orig/contrib/inter.net/flow-cidr.c flow-tools-0.56/contrib/inter.net/flow-cidr.c --- flow-tools-0.56-orig/contrib/inter.net/flow-cidr.c Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/flow-cidr.c Wed Feb 6 20:41:39 2002 @@ -0,0 +1,286 @@ +/* + + flow-cidr is a redone version of flow-split that work similarly to + flow-filter however, it accepts a definition file with a format + defined below + + file on command line will contain: + + file1 net1 net2 net3... + file2 net1 net2 net3... + + */ + +/* generic includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* network related includes */ +#include +#include +/* flow-tools related includes */ +#include +#include "ftlib.h" +#include "support.h" +#include "fmt.h" + +/* patricia tree related includes */ +#include "patricia.h" + +/* function declarations */ +void usage(); + +int main(int argc, char *argv[]) +{ + extern char *optarg; + struct ftio ftio; + + char *inputfile; + char *clientname; + char *ipblock;/*JRLEE Added for -i option*/ + FILE *desc_file; + int out_fd,i; + int dstflag=0; + struct ftio others_file; + struct fts3rec_v5 *rec; + char buf[512]; + patricia_tree_t *pt; + patricia_node_t *pn; + prefix_t *pref; + struct ftver ftv; + struct ftset ftset; + int opt;/* added by jrlee ... maybe I should use a smaller data type :) */ + int clientname_exist=0; + if (argc <= 1) { + usage(); + return(0); + } + + while ((i = getopt(argc, argv, "f:D:d:i:I:vh")) != -1) + switch (i) { + case 'v': + printf("Version 0.05 Copyright 2001 William Emmanuel S. Yu\n"); + return(0); + break; + case 'f': + inputfile = optarg; + break; + case 'D': + opt = 2; + dstflag = 1; + clientname = optarg; + break; + case 'd': + opt = 2; + dstflag = 0; + clientname = optarg; + break; + case 'h': + default: + usage(); + return(0); + break; + case 'i': + opt=1; + dstflag = 0; + ipblock = optarg; + break; + case 'I': + opt=1; + dstflag = 1; + ipblock = optarg; + break; + } + + if (((desc_file = fopen(inputfile, "r")) == NULL)&& (opt!=1)) { + fprintf (stderr, "could not open description filename: %s\n", argv[1]); + return 1; + } + + /* generate the output stream for the match packets. */ + ftset_init(&ftset, 0); + memset(&ftv, 0, sizeof(ftv)); + ftv.s_version = FT_IO_SVERSION; + ftv.d_version = 5; + ftv.agg_method = 1; + ftv.agg_version = 2; + + out_fd = 1; + + if (ftio_init(&others_file, out_fd, FT_IO_FLAG_WRITE) < 0) + { + fprintf (stderr, "cannot initialize for writing: others.dump\n"); + return 1; + } + + if (ftio_set_ver(&others_file, &ftv) < 0) { + fprintf (stderr, "cannot set version: others.dump\n"); + return 1; + } + + ftio_set_byte_order(&others_file, ftset.byte_order); + ftio_set_streaming(&others_file, 1); + + if (ftio_write_header(&others_file) < 0) { + fprintf (stderr, "cannot write header: others.dump\n"); + return 1; + } + /* end of segment to initialize others file */ + if (opt!=1){ + /** + this segment parses the configuration file + the format of the configuration file is as follows: + + filename prefix1 prefix2 prefix3 + */ + pt = New_Patricia(32); + + while (fgets (buf, 160, desc_file) != NULL) { + char *s, *s2; + char *client_string; + + /* Format: filename prefix1 prefix2 prefix3... */ + + s = strchr(buf, '\n'); + *s = 0; + + s = strchr(buf, ' '); + if (s == NULL) + break; + + /* Null terminate the filename and move to the first prefix */ + *s++ = 0; + + while (s != NULL) { + s2 = strchr(s,' '); + if (s2 != NULL) { + *s2++=0; + } + +#ifdef DEBUG + printf("s = %s.\n",s); + printf("s2 = %s.\n",s2); +#endif + + if ((pref = ascii2prefix(AF_INET, s)) == NULL) { + fprintf (stderr, "invalid prefix: %s\n", s); + return 1; + } + + if ((pn = patricia_lookup(pt, pref)) == NULL) { + fprintf (stderr, "could not create node for prefix: %s\n", s); + } + + /* All we really want to store */ + client_string = malloc(sizeof(buf)+1); + strcpy(client_string,buf); + pn->data = client_string; + s = s2; + if(opt!=1){ + if (strcmp(client_string,clientname)==0){ + clientname_exist = 1; + } + } + } + + } + + fclose (desc_file); + /* end generating patricia tree */ + } + if (opt!=1){ + if (clientname_exist ==0){ + fprintf(stderr,"Client name doesn't exist!!!\n"); + exit(1); + } + } + + /* At this point we have the tree */ + /* read flowfile from stdin */ + if (ftio_init(&ftio, 0, FT_IO_FLAG_READ) < 0) { + fprintf(stderr, "ftio_init(): failed\n"); + exit (1); + } + + while ((rec = ftio_read(&ftio))) { + prefix_t *pref_out,pref_tmp; + char* temp_string; + + /* Compute the following for a valid address, jrlee */ + if(opt==1){ + u_int netmask; + + if (dstflag == 1) + pref_tmp.add.sin.s_addr = rec->dstaddr; + else pref_tmp.add.sin.s_addr = rec->srcaddr; + + pref_tmp.bitlen = 32; + + pref_out=ascii2prefix(AF_INET,ipblock); + pref_out->add.sin.s_addr = ntohl(pref_out->add.sin.s_addr); + netmask = (0xffffffff ^ ((1 << (32 - pref_out->bitlen)) - 1)); + pref_tmp.add.sin.s_addr &= netmask; + pref_tmp.bitlen=32; + + if (pref_out->add.sin.s_addr==pref_tmp.add.sin.s_addr){ + if(ftio_write(&others_file, rec) < 0) { + fprintf(stderr,"Error writing flow file.\n"); + exit(-1); + } + } + } + + + /* FIXME - must be able to change this to srcaddr later */ + if(opt!=1){ + if (dstflag == 1) + pref_tmp.add.sin.s_addr = rec->dstaddr; + else pref_tmp.add.sin.s_addr = rec->srcaddr; + + pref_tmp.bitlen = 32; + + if ((pn = patricia_search_best(pt, &pref_tmp)) != NULL) { + temp_string = (char *)((struct ftio *)pn->data); + if ( strcmp(temp_string,clientname) == 0 ) + if(ftio_write(&others_file, rec) < 0) { + fprintf(stderr,"Error writing flow file.\n"); + exit(-1); + } + } + + } + + + } + ftio_close(&others_file); + + return 0; + +} /* main */ + + +/* + usage() - displayed usage message + */ + + +void usage() +{ + fprintf(stderr, "flow-cidr:\n\n"); + fprintf(stderr, " -f filename definition filename\n"); + fprintf(stderr, " -D client destination client\n"); + fprintf(stderr, " -I ipblock destination client\n"); + fprintf(stderr, " -d client source client\n"); + fprintf(stderr, " -i ipblock source ip \n "); + fprintf(stderr, " -v show version number\n"); + fprintf(stderr, " -h help\n"); + fprintf(stderr, "\n"); +} /* usage() */ diff -Nur flow-tools-0.56-orig/contrib/inter.net/flow-iptime.c flow-tools-0.56/contrib/inter.net/flow-iptime.c --- flow-tools-0.56-orig/contrib/inter.net/flow-iptime.c Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/flow-iptime.c Wed Feb 6 20:41:39 2002 @@ -0,0 +1,441 @@ +/* + * Copyright (c) 2001 Mark Fullmer and The Ohio State University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: flow-filter.c,v 1.17 2001/06/18 00:41:43 maf Exp $ + */ + +/* + * flow-iptime source-ip destination-ip start-time stop-time + * flow-ipfime -f spec + * + * where spec: source-ip destination-ip start-time stop-time + * ... + * + * IP can be decimal or dotted quad + * ip = 0 means any + * + * Miguel A.L. Paraz + * + * TODO: + * Support netmasks/wildcards? + * + * Command line for: if input is guaranteed to be sequential, skip over + * searches whose time is older than the flow. Stop when flow is older + than oldest entry. Need to sort spec file for this. + */ + +/* Maximum entries in spec file + TODO: allocate dynamically, or specify max on command line (?) +*/ +#define MAX_SPEC 256 +#define MAX_SPEC_LINE 64 + +#if HAVE_CONFIG_H + #include +#endif + +#include +#include +#include +#include +#include +#include +#if HAVE_STRINGS_H + #include +#endif +#if HAVE_STRING_H + #include +#endif +#include +#include +#include "ftlib.h" +#include "support.h" +#include "acl2.h" +#include "aclyacc.h" + +/* might not portable. for inet_ntoa. */ +#include +#include +#include + +int debug; + +/* lookup structure */ +struct iptime_lookup { + u_int32 srcaddr; + u_int32 dstaddr; + int start; + int stop; +}; + +/* malloc() a lookup structure and fill it up */ +struct iptime_lookup *make_lookup +(const char *text_src, const char *text_dst, + const char *text_start, + const char *text_stop) { + + struct in_addr ia; + struct iptime_lookup *ret; + char *endptr; + + if ((ret = malloc(sizeof(struct iptime_lookup))) == NULL) { + /* Out of memory! */ + return NULL; + } + + /* Try dotted quad on src. + This isn't pretty since it passes through endian conversion */ + + if (inet_aton(text_src, &ia) == 0) { + /* Try decimal */ + ret->srcaddr = strtol(text_src, &endptr, 10); + + if (*endptr != 0) { + free(ret); + return NULL; + } + } + else { + ret->srcaddr = ntohl(ia.s_addr); + } + + /* Try dotted quad on dst. */ + + if (inet_aton(text_dst, &ia) == 0) { + /* Try decimal */ + ret->dstaddr = strtol(text_dst, &endptr, 10); + + if (*endptr != 0) { + free(ret); + return NULL; + } + } + else { + ret->dstaddr = ntohl(ia.s_addr); + } + + ret->start = strtol(text_start, &endptr, 10); + if (*endptr != 0) { + free(ret); + return NULL; + } + + ret->stop = strtol(text_stop, &endptr, 10); + if (*endptr != 0) { + free(ret); + return NULL; + } + + return ret; +} + +void usage(); + +int main(int argc, char **argv) +{ + extern char *optarg; + struct ftio ftio_in, ftio_out; + struct ftset ftset; + struct ftver ftv; + struct ftprof ftp; + struct fts3rec_v5 *rec_v5; + struct fts3rec_gen *rec_gen; + int i; + void *rec; + + u_int64 total_flows; + int as_present; + + char *spec_fname = ""; + extern int optind; + struct iptime_lookup **itlp, **itlp_p, *itl_sp; + int n_itl; + + + /* init fterr */ + fterr_setid(argv[0]); + + /* profile */ + ftprof_start (&ftp); + + bzero(&ftv, sizeof ftv); + + /* defaults + no compression */ + ftset_init(&ftset, 0); + + /* init */ + total_flows = 0; + + while ((i = getopt(argc, argv, "f:")) != -1) + switch (i) { + + case 'f': /* acl file name */ + spec_fname = optarg; + break; + + case 'd': /* debug */ + debug = atoi(optarg); + break; + + + } /* switch */ + + + i = optind; + if (i < argc) { + + /* use the command line. check that there are 4 parameters */ + + if (argc - i != 4) { + usage(); + exit(1); + } + + /* get ip, start, stop; store into the static pointer */ + if ((itl_sp = make_lookup(argv[i], argv[i + 1], argv[i + 2], argv[i + 3])) + == NULL) { + + usage(); + exit(1); + } + + /* Exactly one entry, point to it */ + n_itl = 1; + itlp = &itl_sp; + } + else { + FILE *fp; + char spec_line[MAX_SPEC_LINE]; + + + /* load the spec file, point working pointer */ + if ((itlp = itlp_p = + malloc(MAX_SPEC * sizeof(struct iptime_lookup *))) == NULL) { + + fputs ("Out of memory for spec list\n", stderr); + exit (1); + } + + /* Open file */ + if ((fp = fopen (argv[i - 1], "r")) == NULL) { + fprintf (stderr, "Cannot open spec file: %s\n", argv[i]); + exit (1); + } + + /* Parse. Ignore blank lines. + * TODO: More flexible parser. + */ + while ((fgets (spec_line, MAX_SPEC_LINE, fp)) != NULL) { + char *p, *p2, *p3, *p4; + char spec_line_work[MAX_SPEC_LINE]; + + if (spec_line[0] == '\n') { + continue; + } + + /* We need a working copy since we'll add zeroes and we might + * need the original. + */ + + strcpy (spec_line_work, spec_line); + + /* load four parameters, separated by EXACTLY ONE SPACE each, and + NO SPACE at the end. FIXME. */ + + if ((p = strchr(spec_line_work, ' ')) == NULL) { + fprintf (stderr, "Cannot parse line: %s\n", spec_line); + } + + *p++ = 0; + + /* At this point, p points to the start of the IP number. */ + if ((p2 = strchr(p, ' ')) == NULL) { + fprintf (stderr, "Cannot parse line: %s\n", spec_line); + } + + *p2++ = 0; + + /* At this point, p2 points to the start of the first time. */ + if ((p3 = strchr(p2, ' ')) == NULL) { + fprintf (stderr, "Cannot parse line: %s\n", spec_line); + } + *p3++ = 0; + + /* At this point, p3 points to the start of the second time. + * Replace the newline with an end-of-string zero. + */ + if ((p4 = strchr (p3, '\n')) != NULL) { + *p4 = 0; + } + + /* Parse. */ + if (((*itlp_p++) = make_lookup(spec_line_work, p, p2, p3)) == NULL) { + fprintf (stderr, "Cannot understand line: %s\n", spec_line); + exit (1); + } + + /* Check if we have hit our maximum line count. */ + if (++n_itl == MAX_SPEC) { + fprintf (stderr, "Reached maximum line count of %d\n", MAX_SPEC); + exit (1); + } + } + + + fclose(fp); + + } + + /* if have spec filename, use it. for testing, just use command line */ + + /* input from stdin */ + if (ftio_init(&ftio_in, 0, FT_IO_FLAG_READ) < 0) + fterr_errx(1, "ftio_init(): failed"); + + if (ftio_check_generic(&ftio_in) < 0) + fterr_errx(1, "flow-filter does not yet support PDU format"); + + ftio_get_ver(&ftio_in, &ftv); + ftv.s_version = FT_IO_SVERSION; + + if ((ftv.d_version == 5) || (ftv.d_version == 6) || (ftv.d_version == 7)) + as_present = 1; + + /* output to stdout */ + if (ftio_init(&ftio_out, 1, FT_IO_FLAG_WRITE | + ((ftset.z_level) ? FT_IO_FLAG_ZINIT : 0) ) < 0) + fterr_errx(1, "ftio_init(): failed"); + + ftio_set_comment(&ftio_out, ftset.comments); + ftio_set_byte_order(&ftio_out, ftset.byte_order); + ftio_set_z_level(&ftio_out, ftset.z_level); + ftio_set_streaming(&ftio_out, 1); + ftio_set_debug(&ftio_out, debug); + + if (ftio_set_ver(&ftio_out, &ftv) < 0) + fterr_errx(1, "ftio_set_ver(): failed"); + + /* + * normalize masks + */ + /* XXX TODO */ + + /* header first */ + if (ftio_write_header(&ftio_out) < 0) + fterr_errx(1, "ftio_write_header(): failed"); + + + /* grab 1 flow */ + while ((rec = ftio_read(&ftio_in))) { + struct fttime ftt; + int is_output; + + rec_v5 = rec; + rec_gen = rec; + + + ++ total_flows; + + ftt = ftltime(rec_gen->sysUpTime, rec_gen->unix_secs, rec_gen->unix_nsecs, + rec_gen->First); + + /* Check against itlp */ + + /* Time before IP. Or should it be the other way around? + This is not as efficient as can be. */ + + /* recycle i */ + i = n_itl; + itlp_p = itlp; + is_output = 0; + + while ((is_output == 0) && (i--)) { + + if ((ftt.secs > (*itlp_p)->start) && (ftt.secs < (*itlp_p)->stop)) { + if ((*itlp_p)->srcaddr == 0) { + if ((*itlp_p)->dstaddr == 0) { + /* both 0, don't check IP's */ + is_output = 1; + } + else if ((*itlp_p)->dstaddr == rec_gen->dstaddr) { + is_output = 1; + } + } + else if ((*itlp_p)->dstaddr == 0) { + /* case of srcaddr also == 0 covered above */ + if ((*itlp_p)->srcaddr == rec_gen->srcaddr) { + is_output = 1; + } + } + else { + /* both > 0 */ + if (((*itlp_p)->srcaddr == rec_gen->srcaddr) && + ((*itlp_p)->dstaddr == rec_gen->dstaddr)) { + is_output = 1; + } + } + } + else { + /* Didn't match the time. */ + } + + itlp_p++; + } /* while () */ + + + /* + * made it by the filters, write it + */ + + if (is_output) { + if (ftio_write(&ftio_out, rec) < 0) + fterr_errx(1, "ftio_write(): failed"); + } + + } /* while more flows to read */ + + if (ftio_close(&ftio_in) < 0) + fterr_errx(1, "ftio_close(): failed"); + + if (ftio_close(&ftio_out) < 0) + fterr_errx(1, "ftio_close(): failed"); + + if (debug > 0) { + ftprof_end (&ftp, total_flows); + ftprof_print(&ftp, argv[0], stderr); + } + + + return 0; + +} /* main */ + +void usage() { + + fprintf(stderr, "flow-iptime [-f spec-file | ip1 ip2 start stop]"); + fprintf(stderr, "\n\n"); + +} /* usage */ + diff -Nur flow-tools-0.56-orig/contrib/inter.net/flow-split.c flow-tools-0.56/contrib/inter.net/flow-split.c --- flow-tools-0.56-orig/contrib/inter.net/flow-split.c Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/flow-split.c Wed Feb 6 20:41:39 2002 @@ -0,0 +1,272 @@ +/** + redone version of flow-split. dues to problems with the original + i rewrote it. + + file on command line will contain: + + file1 net1 net2 net3... + file2 net1 net2 net3... + + */ + +/* generic defines */ +#define FTIO_OUT_MAX 512 + +/* generic includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* network related includes */ +#include + +/* flow-tools related includes */ +#include +#include "ftlib.h" +#include "support.h" +#include "fmt.h" + +/* patricia tree related includes */ +#include "patricia.h" + +/* function declarations */ +void usage(); + +int main(int argc, char *argv[]) +{ + extern char *optarg; + struct ftio ftio; + + char *inputfile; + FILE *desc_file; + int others_fd; + struct ftio others_file; + struct ftio ftio_out[FTIO_OUT_MAX]; + struct fts3rec_v5 *rec; + char buf[512]; + int ftio_out_count, i; + patricia_tree_t *pt; + patricia_node_t *pn; + prefix_t *pref; + struct ftver ftv; + struct ftset ftset; + int reverse = 0; + + if (argc <= 1) { + usage(); + return(0); + } + + while ((i = getopt(argc, argv, "f:vh")) != -1) + switch (i) { + case 'v': + printf("Version 0.02 Copyright 2001 William Emmanuel S. Yu\n"); + return(0); + break; + case 'f': + inputfile = optarg; + break; + case 'r': + reverse = 1; + break; + case 'h': + default: + usage(); + return(0); + break; + } + + if ((desc_file = fopen(inputfile, "r")) == NULL) { + fprintf (stderr, "could not open description filename: %s\n", argv[1]); + return 1; + } + + /* generate the others.dump file for the unaccounted packets. */ + others_fd = open("others.dump", O_WRONLY | O_TRUNC | O_CREAT, 0644); + + if (others_fd < 0) { + fprintf (stderr, "cannot open for writing: others.dump\n"); + return 1; + } + + ftset_init(&ftset, 0); + memset(&ftv, 0, sizeof(ftv)); + ftv.s_version = FT_IO_SVERSION; + ftv.d_version = 5; + ftv.agg_method = 1; + ftv.agg_version = 2; + + if (ftio_init(&others_file, others_fd, FT_IO_FLAG_WRITE) < 0) + { + fprintf (stderr, "cannot initialize for writing: others.dump\n"); + return 1; + } + + if (ftio_set_ver(&others_file, &ftv) < 0) { + fprintf (stderr, "cannot set version: others.dump\n"); + return 1; + } + + ftio_set_byte_order(&others_file, ftset.byte_order); + ftio_set_streaming(&others_file, 1); + + if (ftio_write_header(&others_file) < 0) { + fprintf (stderr, "cannot write header: others.dump\n"); + return 1; + } + /* end of segment to initialize others file */ + + /** + this segment parses the configuration file + the format of the configuration file is as follows: + + filename prefix1 prefix2 prefix3 + */ + pt = New_Patricia(32); + ftio_out_count = 0; + + while (fgets (buf, 160, desc_file) != NULL) { + char *s, *s2; + int fd; + + /* Format: filename prefix1 prefix2 prefix3... */ + + s = strchr(buf, '\n'); + *s = 0; + + s = strchr(buf, ' '); + if (s == NULL) + break; + + /* Null terminate the filename and move to the first prefix */ + *s++ = 0; + + fd = open(buf, O_WRONLY | O_TRUNC | O_CREAT, 0644); + + if (fd < 0) { + fprintf (stderr, "cannot open for writing: %s\n", buf); + return 1; + } + + ftset_init(&ftset, 0); + memset(&ftv, 0, sizeof(ftv)); + ftv.s_version = FT_IO_SVERSION; + ftv.d_version = 5; + ftv.agg_method = 1; + ftv.agg_version = 2; + + if (ftio_init(ftio_out + ftio_out_count, fd, FT_IO_FLAG_WRITE) < 0) { + fprintf (stderr, "cannot initialize for writing: %s\n", buf); + return 1; + } + + if (ftio_set_ver(ftio_out + ftio_out_count, &ftv) < 0) { + fprintf (stderr, "cannot set version: %s\n", buf); + return 1; + } + + ftio_set_byte_order(ftio_out + ftio_out_count, ftset.byte_order); + ftio_set_streaming(ftio_out + ftio_out_count, 1); + + if (ftio_write_header(ftio_out + ftio_out_count) < 0) { + fprintf (stderr, "cannot write header: %s\n", buf); + return 1; + } + + + while (s != NULL) { + s2 = strchr(s,' '); + if (s2 != NULL) { + *s2++=0; + } + +#ifdef DEBUG + printf("s = %s.\n",s); + printf("s2 = %s.\n",s2); +#endif + + if ((pref = ascii2prefix(AF_INET, s)) == NULL) { + fprintf (stderr, "invalid prefix: %s\n", s); + return 1; + } + + if ((pn = patricia_lookup(pt, pref)) == NULL) { + fprintf (stderr, "could not create node for prefix: %s\n", s); + } + + /* All we really want to store */ + pn->data = ftio_out + ftio_out_count; + s = s2; + } + + if (++ftio_out_count == FTIO_OUT_MAX) { + fputs ("too many files, ignoring the rest.\n", stderr); + break; + } + } + fclose (desc_file); + + + /* At this point we have the tree */ + + /* read flowfile from stdin */ + if (ftio_init(&ftio, 0, FT_IO_FLAG_READ) < 0) { + fprintf(stderr, "ftio_init(): failed\n"); + exit (1); + } + + while ((rec = ftio_read(&ftio))) { + prefix_t pref_tmp; + + if (reverse) + pref_tmp.add.sin.s_addr = ntohl(rec->srcaddr); + else + pref_tmp.add.sin.s_addr = ntohl(rec->dstaddr); + + pref_tmp.bitlen = 32; + + if ((pn = patricia_search_best(pt, &pref_tmp)) != NULL) { + if(ftio_write((struct ftio *)pn->data, rec) < 0) { + fprintf(stderr,"Error writing flow file.\n"); + exit(-1); + } + } + else { + /* writing all other packets to the others file */ + if(ftio_write(&others_file, rec) < 0) { + fprintf(stderr,"Error writing flow file.\n"); + exit(-1); + } + } + } + + + /* We are done, close down. */ + for (i = 0; i < ftio_out_count; i++) { + ftio_close(ftio_out + i); + } + ftio_close(&others_file); + + return 0; + +} /* main */ + + +/** + usage() - displayed usage message + */ +void usage() +{ + fprintf(stderr, "flow-split:\n\n"); + fprintf(stderr, " -f filename input filename\n"); + fprintf(stderr, " -v show version number\n"); + fprintf(stderr, " -h help\n"); + fprintf(stderr, "\n"); +} /* usage() */ diff -Nur flow-tools-0.56-orig/contrib/inter.net/flow-syn.c flow-tools-0.56/contrib/inter.net/flow-syn.c --- flow-tools-0.56-orig/contrib/inter.net/flow-syn.c Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/flow-syn.c Wed Feb 6 20:41:39 2002 @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2001 Mark Fullmer and The Ohio State University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: flow-filter.c,v 1.17 2001/06/18 00:41:43 maf Exp $ + */ + +/* + * flow-syn [-t] + * no parameters: output in raw format for piping to other tools + * -t: output in text mode + * + * Miguel A.L. Paraz + + */ + +#if HAVE_CONFIG_H + #include +#endif + +#include +#include +#include +#include +#include +#include +#if HAVE_STRINGS_H + #include +#endif +#if HAVE_STRING_H + #include +#endif +#include +#include + +#include "ftlib.h" +#include "fmt.h" + +int debug; + +/* lookup structure */ +struct iptime_lookup { + u_int32 srcaddr; + u_int32 dstaddr; + int start; + int stop; +}; + +void usage(); + +int main(int argc, char **argv) +{ + extern char *optarg; + struct ftio ftio_in, ftio_out; + struct ftset ftset; + struct ftver ftv; + struct ftprof ftp; + struct fts3rec_v5 *rec_v5; + int i, is_text; + void *rec; + + u_int64 total_flows; + + extern int optind; + + + /* init fterr */ + fterr_setid(argv[0]); + + /* profile */ + ftprof_start (&ftp); + + bzero(&ftv, sizeof ftv); + + /* defaults + no compression */ + ftset_init(&ftset, 0); + + /* init */ + total_flows = 0; + + while ((i = getopt(argc, argv, "tf:")) != -1) + switch (i) { + + case 't': /* text */ + is_text = 1; + break; + + case 'd': /* debug */ + debug = atoi(optarg); + break; + + + } /* switch */ + + /* input from stdin */ + if (ftio_init(&ftio_in, 0, FT_IO_FLAG_READ) < 0) + fterr_errx(1, "ftio_init(): failed"); + + if (ftio_check_generic(&ftio_in) < 0) + fterr_errx(1, "flow-filter does not yet support PDU format"); + + ftio_get_ver(&ftio_in, &ftv); + ftv.s_version = FT_IO_SVERSION; + + /* output to stdout */ + if (ftio_init(&ftio_out, 1, FT_IO_FLAG_WRITE | + ((ftset.z_level) ? FT_IO_FLAG_ZINIT : 0) ) < 0) + fterr_errx(1, "ftio_init(): failed"); + + ftio_set_comment(&ftio_out, ftset.comments); + ftio_set_byte_order(&ftio_out, ftset.byte_order); + ftio_set_z_level(&ftio_out, ftset.z_level); + ftio_set_streaming(&ftio_out, 1); + ftio_set_debug(&ftio_out, debug); + + if (ftio_set_ver(&ftio_out, &ftv) < 0) + fterr_errx(1, "ftio_set_ver(): failed"); + + /* header first */ + if (!is_text) { + if (ftio_write_header(&ftio_out) < 0) + fterr_errx(1, "ftio_write_header(): failed"); + } + + + /* grab 1 flow */ + while ((rec = ftio_read(&ftio_in))) { + rec_v5 = rec; + + ++ total_flows; + + /* Output if and only if the flag is SYN alone */ + if ((rec_v5->prot == IPPROTO_TCP) && (rec_v5->tcp_flags == 2)) { + if (is_text) { + struct fttime ftt; + char fmt_buf1[64], fmt_buf2[64]; + + fmt_ipv4(fmt_buf1, rec_v5->srcaddr, FMT_PAD_RIGHT); + fmt_ipv4(fmt_buf2, rec_v5->dstaddr, FMT_PAD_RIGHT); + + ftt = ftltime(rec_v5->sysUpTime, rec_v5->unix_secs, + rec_v5->unix_nsecs, rec_v5->First); + + /* Time, source IP, dest IP, source port, dest port */ + printf ("%10d %-15s %-15s %5d %5d\n", ftt.secs, fmt_buf1, fmt_buf2, + (int)rec_v5->srcport, (int)rec_v5->dstport); + + + } + else { + if (ftio_write(&ftio_out, rec) < 0) + fterr_errx(1, "ftio_write(): failed"); + } + } + + } /* while more flows to read */ + + if (ftio_close(&ftio_in) < 0) + fterr_errx(1, "ftio_close(): failed"); + + if (ftio_close(&ftio_out) < 0) + fterr_errx(1, "ftio_close(): failed"); + + if (debug > 0) { + ftprof_end (&ftp, total_flows); + ftprof_print(&ftp, argv[0], stderr); + } + + + return 0; + +} /* main */ + +void usage() { + + fprintf(stderr, "flow-syn"); + fprintf(stderr, "\n\n"); + exit(1); + +} /* usage */ + diff -Nur flow-tools-0.56-orig/contrib/inter.net/libpatricia/COPYRIGHT flow-tools-0.56/contrib/inter.net/libpatricia/COPYRIGHT --- flow-tools-0.56-orig/contrib/inter.net/libpatricia/COPYRIGHT Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/libpatricia/COPYRIGHT Wed Feb 6 20:41:39 2002 @@ -0,0 +1,34 @@ +Copyright (c) 1997, 1998, 1999 + + +The Regents of the University of Michigan ("The Regents") and Merit Network, +Inc. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. +2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. +3. All advertising materials mentioning features or use of + this software must display the following acknowledgement: +This product includes software developed by the University of Michigan, Merit +Network, Inc., and their contributors. +4. Neither the name of the University, Merit Network, nor the + names of their contributors may be used to endorse or + promote products derived from this software without + specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + diff -Nur flow-tools-0.56-orig/contrib/inter.net/libpatricia/Makefile.am flow-tools-0.56/contrib/inter.net/libpatricia/Makefile.am --- flow-tools-0.56-orig/contrib/inter.net/libpatricia/Makefile.am Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/libpatricia/Makefile.am Wed Feb 6 20:41:39 2002 @@ -0,0 +1,8 @@ +## Process this file with automake to produce Makefile.in + +noinst_HEADERS = + +noinst_LIBRARIES = libpatricia.a + +libpatricia_a_SOURCES = patricia.c + diff -Nur flow-tools-0.56-orig/contrib/inter.net/libpatricia/Makefile.in flow-tools-0.56/contrib/inter.net/libpatricia/Makefile.in --- flow-tools-0.56-orig/contrib/inter.net/libpatricia/Makefile.in Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/libpatricia/Makefile.in Sat Feb 9 13:20:42 2002 @@ -0,0 +1,301 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +LEX = @LEX@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +YLIB = @YLIB@ + +noinst_HEADERS = + +noinst_LIBRARIES = libpatricia.a + +libpatricia_a_SOURCES = patricia.c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../../config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libpatricia_a_LIBADD = +libpatricia_a_OBJECTS = patricia.o +AR = ar +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/patricia.P +SOURCES = $(libpatricia_a_SOURCES) +OBJECTS = $(libpatricia_a_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu contrib/inter.net/libpatricia/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLIBRARIES: + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +distclean-noinstLIBRARIES: + +maintainer-clean-noinstLIBRARIES: + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +libpatricia.a: $(libpatricia_a_OBJECTS) $(libpatricia_a_DEPENDENCIES) + -rm -f libpatricia.a + $(AR) cru libpatricia.a $(libpatricia_a_OBJECTS) $(libpatricia_a_LIBADD) + $(RANLIB) libpatricia.a + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = contrib/inter.net/libpatricia + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu contrib/inter.net/libpatricia/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLIBRARIES distclean-compile \ + distclean-tags distclean-depend distclean-generic \ + clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ +clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nur flow-tools-0.56-orig/contrib/inter.net/libpatricia/patricia.c flow-tools-0.56/contrib/inter.net/libpatricia/patricia.c --- flow-tools-0.56-orig/contrib/inter.net/libpatricia/patricia.c Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/libpatricia/patricia.c Wed Feb 6 20:41:39 2002 @@ -0,0 +1,1008 @@ +/* + * $Id: patricia.c,v 1.4 2000/09/29 19:28:07 dplonka Exp $ + * Dave Plonka + * + * This product includes software developed by the University of Michigan, + * Merit Network, Inc., and their contributors. + * + * This file had been called "radix.c" in the MRT sources. + * + * I renamed it to "patricia.c" since it's not an implementation of a general + * radix trie. Also I pulled in various requirements from "prefix.c" and + * "demo.c" so that it could be used as a standalone API. + */ + +#include /* assert */ +#include /* isdigit */ +#include /* errno */ +#include /* sin */ +#include /* NULL */ +#include /* sprintf, fprintf, stderr */ +#include /* free, atol, calloc */ +#include /* memcpy, strchr, strlen */ +#include /* for inet_addr */ + +#include "patricia.h" + +#define Delete free + +/* { from prefix.c */ + +/* prefix_tochar + * convert prefix information to bytes + */ +u_char * +prefix_tochar (prefix_t * prefix) +{ + if (prefix == NULL) + return (NULL); + + return ((u_char *) & prefix->add.sin); +} + +int +comp_with_mask (void *addr, void *dest, u_int mask) +{ + + if ( /* mask/8 == 0 || */ memcmp (addr, dest, mask / 8) == 0) { + int n = mask / 8; + int m = ((-1) << (8 - (mask % 8))); + + if (mask % 8 == 0 || (((u_char *)addr)[n] & m) == (((u_char *)dest)[n] & m)) + return (1); + } + return (0); +} + +/* inet_pton substitute implementation + * Uses inet_addr to convert an IP address in dotted decimal notation into + * unsigned long and copies the result to dst. + * Only supports AF_INET. Follows standard error return conventions of + * inet_pton. + */ +int +inet_pton (int af, const char *src, void *dst) +{ + u_long result; + + if (af == AF_INET) { + result = inet_addr(src); + if (result == -1) + return 0; + else { + memcpy (dst, &result, 4); + return 1; + } + } +#ifdef NT +#ifdef HAVE_IPV6 + else if (af == AF_INET6) { + struct in6_addr Address; + return (inet6_addr(src, &Address)); + } +#endif /* HAVE_IPV6 */ +#endif /* NT */ +#ifndef NT + else { + + errno = EAFNOSUPPORT; + return -1; + } +#endif /* NT */ +} + +/* this allows imcomplete prefix */ +int +my_inet_pton (int af, const char *src, void *dst) +{ + if (af == AF_INET) { + int i, c, val; + u_char xp[4] = {0, 0, 0, 0}; + + for (i = 0; ; i++) { + c = *src++; + if (!isdigit (c)) + return (-1); + val = 0; + do { + val = val * 10 + c - '0'; + if (val > 255) + return (0); + c = *src++; + } while (c && isdigit (c)); + xp[i] = val; + if (c == '\0') + break; + if (c != '.') + return (0); + if (i >= 3) + return (0); + } + memcpy (dst, xp, 4); + return (1); +#ifdef HAVE_IPV6 + } else if (af == AF_INET6) { + return (inet_pton (af, src, dst)); +#endif /* HAVE_IPV6 */ + } else { +#ifndef NT + errno = EAFNOSUPPORT; +#endif /* NT */ + return -1; + } +} + +/* + * convert prefix information to ascii string with length + * thread safe and (almost) re-entrant implementation + */ +char * +prefix_toa2x (prefix_t *prefix, char *buff, int with_len) +{ + if (prefix == NULL) + return ("(Null)"); + assert (prefix->ref_count >= 0); + if (buff == NULL) { + + struct buffer { + char buffs[16][48+5]; + u_int i; + } *buffp; + +# if 0 + THREAD_SPECIFIC_DATA (struct buffer, buffp, 1); +# else + { /* for scope only */ + static struct buffer local_buff; + buffp = &local_buff; + } +# endif + if (buffp == NULL) { + /* XXX should we report an error? */ + return (NULL); + } + + buff = buffp->buffs[buffp->i++%16]; + } + if (prefix->family == AF_INET) { + u_char *a; + assert (prefix->bitlen <= 32); + a = prefix_touchar (prefix); + if (with_len) { + sprintf (buff, "%d.%d.%d.%d/%d", a[0], a[1], a[2], a[3], + prefix->bitlen); + } + else { + sprintf (buff, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); + } + return (buff); + } +#ifdef HAVE_IPV6 + else if (prefix->family == AF_INET6) { + char *r; + r = (char *) inet_ntop (AF_INET6, &prefix->add.sin6, buff, 48 /* a guess value */ ); + if (r && with_len) { + assert (prefix->bitlen <= 128); + sprintf (buff + strlen (buff), "/%d", prefix->bitlen); + } + return (buff); + } +#endif /* HAVE_IPV6 */ + else + return (NULL); +} + +/* prefix_toa2 + * convert prefix information to ascii string + */ +char * +prefix_toa2 (prefix_t *prefix, char *buff) +{ + return (prefix_toa2x (prefix, buff, 0)); +} + +/* prefix_toa + */ +char * +prefix_toa (prefix_t * prefix) +{ + return (prefix_toa2 (prefix, (char *) NULL)); +} + +prefix_t * +New_Prefix2 (int family, void *dest, int bitlen, prefix_t *prefix) +{ + int dynamic_allocated = 0; + int default_bitlen = 32; + +#ifdef HAVE_IPV6 + if (family == AF_INET6) { + default_bitlen = 128; + if (prefix == NULL) { + prefix = calloc(1, sizeof (prefix6_t)); + dynamic_allocated++; + } + memcpy (&prefix->add.sin6, dest, 16); + } + else +#endif /* HAVE_IPV6 */ + if (family == AF_INET) { + if (prefix == NULL) { +#ifndef NT + prefix = calloc(1, sizeof (prefix4_t)); +#else + //for some reason, compiler is getting + //prefix4_t size incorrect on NT + prefix = calloc(1, sizeof (prefix_t)); +#endif /* NT */ + + dynamic_allocated++; + } + memcpy (&prefix->add.sin, dest, 4); + } + else { + return (NULL); + } + + prefix->bitlen = (bitlen >= 0)? bitlen: default_bitlen; + prefix->family = family; + prefix->ref_count = 0; + if (dynamic_allocated) { + prefix->ref_count++; + } +/* fprintf(stderr, "[C %s, %d]\n", prefix_toa (prefix), prefix->ref_count); */ + return (prefix); +} + +prefix_t * +New_Prefix (int family, void *dest, int bitlen) +{ + return (New_Prefix2 (family, dest, bitlen, NULL)); +} + +/* ascii2prefix + */ +prefix_t * +ascii2prefix (int family, char *string) +{ + u_long bitlen, maxbitlen = 0; + char *cp; + struct in_addr sin; +#ifdef HAVE_IPV6 + struct in6_addr sin6; +#endif /* HAVE_IPV6 */ + int result; + char save[MAXLINE]; + + if (string == NULL) + return (NULL); + + /* easy way to handle both families */ + if (family == 0) { + family = AF_INET; +#ifdef HAVE_IPV6 + if (strchr (string, ':')) family = AF_INET6; +#endif /* HAVE_IPV6 */ + } + + if (family == AF_INET) { + maxbitlen = 32; + } +#ifdef HAVE_IPV6 + else if (family == AF_INET6) { + maxbitlen = 128; + } +#endif /* HAVE_IPV6 */ + + if ((cp = strchr (string, '/')) != NULL) { + bitlen = atol (cp + 1); + /* *cp = '\0'; */ + /* copy the string to save. Avoid destroying the string */ + assert (cp - string < MAXLINE); + memcpy (save, string, cp - string); + save[cp - string] = '\0'; + string = save; + if (bitlen < 0 || bitlen > maxbitlen) + bitlen = maxbitlen; + } + else { + bitlen = maxbitlen; + } + + if (family == AF_INET) { + if ((result = my_inet_pton (AF_INET, string, &sin)) <= 0) + return (NULL); + return (New_Prefix (AF_INET, &sin, bitlen)); + } + +#ifdef HAVE_IPV6 + else if (family == AF_INET6) { +// Get rid of this with next IPv6 upgrade +#if defined(NT) && !defined(HAVE_INET_NTOP) + inet6_addr(string, &sin6); + return (New_Prefix (AF_INET6, &sin6, bitlen)); +#else + if ((result = inet_pton (AF_INET6, string, &sin6)) <= 0) + return (NULL); +#endif /* NT */ + return (New_Prefix (AF_INET6, &sin6, bitlen)); + } +#endif /* HAVE_IPV6 */ + else + return (NULL); +} + +prefix_t * +Ref_Prefix (prefix_t * prefix) +{ + if (prefix == NULL) + return (NULL); + if (prefix->ref_count == 0) { + /* make a copy in case of a static prefix */ + return (New_Prefix2 (prefix->family, &prefix->add, prefix->bitlen, NULL)); + } + prefix->ref_count++; +/* fprintf(stderr, "[A %s, %d]\n", prefix_toa (prefix), prefix->ref_count); */ + return (prefix); +} + +void +Deref_Prefix (prefix_t * prefix) +{ + if (prefix == NULL) + return; + /* for secure programming, raise an assert. no static prefix can call this */ + assert (prefix->ref_count > 0); + + prefix->ref_count--; + assert (prefix->ref_count >= 0); + if (prefix->ref_count <= 0) { + Delete (prefix); + return; + } +} + +/* } */ + +/* #define PATRICIA_DEBUG 1 */ + +static int num_active_patricia = 0; + +/* these routines support continuous mask only */ + +patricia_tree_t * +New_Patricia (int maxbits) +{ + patricia_tree_t *patricia = calloc(1, sizeof *patricia); + + patricia->maxbits = maxbits; + patricia->head = NULL; + patricia->num_active_node = 0; + assert (maxbits <= PATRICIA_MAXBITS); /* XXX */ + num_active_patricia++; + return (patricia); +} + + +/* + * if func is supplied, it will be called as func(node->data) + * before deleting the node + */ + +void +Clear_Patricia (patricia_tree_t *patricia, void_fn_t func) +{ + assert (patricia); + if (patricia->head) { + + patricia_node_t *Xstack[PATRICIA_MAXBITS+1]; + patricia_node_t **Xsp = Xstack; + patricia_node_t *Xrn = patricia->head; + + while (Xrn) { + patricia_node_t *l = Xrn->l; + patricia_node_t *r = Xrn->r; + + if (Xrn->prefix) { + Deref_Prefix (Xrn->prefix); + if (Xrn->data && func) + func (Xrn->data); + } + else { + assert (Xrn->data == NULL); + } + Delete (Xrn); + patricia->num_active_node--; + + if (l) { + if (r) { + *Xsp++ = r; + } + Xrn = l; + } else if (r) { + Xrn = r; + } else if (Xsp != Xstack) { + Xrn = *(--Xsp); + } else { + Xrn = (patricia_node_t *) 0; + } + } + } + assert (patricia->num_active_node == 0); + /* Delete (patricia); */ +} + + +void +Destroy_Patricia (patricia_tree_t *patricia, void_fn_t func) +{ + Clear_Patricia (patricia, func); + Delete (patricia); + num_active_patricia--; +} + + +/* + * if func is supplied, it will be called as func(node->prefix, node->data) + */ + +void +patricia_process (patricia_tree_t *patricia, void_fn_t func) +{ + patricia_node_t *node; + assert (func); + + PATRICIA_WALK (patricia->head, node) { + func (node->prefix, node->data); + } PATRICIA_WALK_END; +} + + +patricia_node_t * +patricia_search_exact (patricia_tree_t *patricia, prefix_t *prefix) +{ + patricia_node_t *node; + u_char *addr; + u_int bitlen; + + assert (patricia); + assert (prefix); + assert (prefix->bitlen <= patricia->maxbits); + + if (patricia->head == NULL) + return (NULL); + + node = patricia->head; + addr = prefix_touchar (prefix); + bitlen = prefix->bitlen; + + while (node->bit < bitlen) { + + if (BIT_TEST (addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_search_exact: take right %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_search_exact: take right at %d\n", + node->bit); +#endif /* PATRICIA_DEBUG */ + node = node->r; + } + else { +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_search_exact: take left %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_search_exact: take left at %d\n", + node->bit); +#endif /* PATRICIA_DEBUG */ + node = node->l; + } + + if (node == NULL) + return (NULL); + } + +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_search_exact: stop at %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_search_exact: stop at %d\n", node->bit); +#endif /* PATRICIA_DEBUG */ + if (node->bit > bitlen || node->prefix == NULL) + return (NULL); + assert (node->bit == bitlen); + assert (node->bit == node->prefix->bitlen); + if (comp_with_mask (prefix_tochar (node->prefix), prefix_tochar (prefix), + bitlen)) { +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_search_exact: found %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + return (node); + } + return (NULL); +} + + +/* if inclusive != 0, "best" may be the given prefix itself */ +patricia_node_t * +patricia_search_best2 (patricia_tree_t *patricia, prefix_t *prefix, int inclusive) +{ + patricia_node_t *node; + patricia_node_t *stack[PATRICIA_MAXBITS + 1]; + u_char *addr; + u_int bitlen; + int cnt = 0; + + assert (patricia); + assert (prefix); + assert (prefix->bitlen <= patricia->maxbits); + + if (patricia->head == NULL) + return (NULL); + + node = patricia->head; + addr = prefix_touchar (prefix); + bitlen = prefix->bitlen; + + while (node->bit < bitlen) { + + if (node->prefix) { +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_search_best: push %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + stack[cnt++] = node; + } + + if (BIT_TEST (addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_search_best: take right %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_search_best: take right at %d\n", + node->bit); +#endif /* PATRICIA_DEBUG */ + node = node->r; + } + else { +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_search_best: take left %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_search_best: take left at %d\n", + node->bit); +#endif /* PATRICIA_DEBUG */ + node = node->l; + } + + if (node == NULL) + break; + } + + if (inclusive && node && node->prefix) + stack[cnt++] = node; + +#ifdef PATRICIA_DEBUG + if (node == NULL) + fprintf (stderr, "patricia_search_best: stop at null\n"); + else if (node->prefix) + fprintf (stderr, "patricia_search_best: stop at %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_search_best: stop at %d\n", node->bit); +#endif /* PATRICIA_DEBUG */ + + if (cnt <= 0) + return (NULL); + + while (--cnt >= 0) { + node = stack[cnt]; +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_search_best: pop %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + if (comp_with_mask (prefix_tochar (node->prefix), + prefix_tochar (prefix), + node->prefix->bitlen)) { +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_search_best: found %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + return (node); + } + } + return (NULL); +} + + +patricia_node_t * +patricia_search_best (patricia_tree_t *patricia, prefix_t *prefix) +{ + return (patricia_search_best2 (patricia, prefix, 1)); +} + + +patricia_node_t * +patricia_lookup (patricia_tree_t *patricia, prefix_t *prefix) +{ + patricia_node_t *node, *new_node, *parent, *glue; + u_char *addr, *test_addr; + u_int bitlen, check_bit, differ_bit; + int i, j, r; + + assert (patricia); + assert (prefix); + assert (prefix->bitlen <= patricia->maxbits); + + if (patricia->head == NULL) { + node = calloc(1, sizeof *node); + node->bit = prefix->bitlen; + node->prefix = Ref_Prefix (prefix); + node->parent = NULL; + node->l = node->r = NULL; + node->data = NULL; + patricia->head = node; +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: new_node #0 %s/%d (head)\n", + prefix_toa (prefix), prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + patricia->num_active_node++; + return (node); + } + + addr = prefix_touchar (prefix); + bitlen = prefix->bitlen; + node = patricia->head; + + while (node->bit < bitlen || node->prefix == NULL) { + + if (node->bit < patricia->maxbits && + BIT_TEST (addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { + if (node->r == NULL) + break; +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_lookup: take right %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_lookup: take right at %d\n", node->bit); +#endif /* PATRICIA_DEBUG */ + node = node->r; + } + else { + if (node->l == NULL) + break; +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_lookup: take left %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_lookup: take left at %d\n", node->bit); +#endif /* PATRICIA_DEBUG */ + node = node->l; + } + + assert (node); + } + + assert (node->prefix); +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: stop at %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + + test_addr = prefix_touchar (node->prefix); + /* find the first bit different */ + check_bit = (node->bit < bitlen)? node->bit: bitlen; + differ_bit = 0; + for (i = 0; i*8 < check_bit; i++) { + if ((r = (addr[i] ^ test_addr[i])) == 0) { + differ_bit = (i + 1) * 8; + continue; + } + /* I know the better way, but for now */ + for (j = 0; j < 8; j++) { + if (BIT_TEST (r, (0x80 >> j))) + break; + } + /* must be found */ + assert (j < 8); + differ_bit = i * 8 + j; + break; + } + if (differ_bit > check_bit) + differ_bit = check_bit; +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: differ_bit %d\n", differ_bit); +#endif /* PATRICIA_DEBUG */ + + parent = node->parent; + while (parent && parent->bit >= differ_bit) { + node = parent; + parent = node->parent; +#ifdef PATRICIA_DEBUG + if (node->prefix) + fprintf (stderr, "patricia_lookup: up to %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); + else + fprintf (stderr, "patricia_lookup: up to %d\n", node->bit); +#endif /* PATRICIA_DEBUG */ + } + + if (differ_bit == bitlen && node->bit == bitlen) { + if (node->prefix) { +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: found %s/%d\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + return (node); + } + node->prefix = Ref_Prefix (prefix); +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: new node #1 %s/%d (glue mod)\n", + prefix_toa (prefix), prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + assert (node->data == NULL); + return (node); + } + + new_node = calloc(1, sizeof *new_node); + new_node->bit = prefix->bitlen; + new_node->prefix = Ref_Prefix (prefix); + new_node->parent = NULL; + new_node->l = new_node->r = NULL; + new_node->data = NULL; + patricia->num_active_node++; + + if (node->bit == differ_bit) { + new_node->parent = node; + if (node->bit < patricia->maxbits && + BIT_TEST (addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { + assert (node->r == NULL); + node->r = new_node; + } + else { + assert (node->l == NULL); + node->l = new_node; + } +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: new_node #2 %s/%d (child)\n", + prefix_toa (prefix), prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + return (new_node); + } + + if (bitlen == differ_bit) { + if (bitlen < patricia->maxbits && + BIT_TEST (test_addr[bitlen >> 3], 0x80 >> (bitlen & 0x07))) { + new_node->r = node; + } + else { + new_node->l = node; + } + new_node->parent = node->parent; + if (node->parent == NULL) { + assert (patricia->head == node); + patricia->head = new_node; + } + else if (node->parent->r == node) { + node->parent->r = new_node; + } + else { + node->parent->l = new_node; + } + node->parent = new_node; +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: new_node #3 %s/%d (parent)\n", + prefix_toa (prefix), prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + } + else { + glue = calloc(1, sizeof *glue); + glue->bit = differ_bit; + glue->prefix = NULL; + glue->parent = node->parent; + glue->data = NULL; + patricia->num_active_node++; + if (differ_bit < patricia->maxbits && + BIT_TEST (addr[differ_bit >> 3], 0x80 >> (differ_bit & 0x07))) { + glue->r = new_node; + glue->l = node; + } + else { + glue->r = node; + glue->l = new_node; + } + new_node->parent = glue; + + if (node->parent == NULL) { + assert (patricia->head == node); + patricia->head = glue; + } + else if (node->parent->r == node) { + node->parent->r = glue; + } + else { + node->parent->l = glue; + } + node->parent = glue; +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_lookup: new_node #4 %s/%d (glue+node)\n", + prefix_toa (prefix), prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + } + return (new_node); +} + + +void +patricia_remove (patricia_tree_t *patricia, patricia_node_t *node) +{ + patricia_node_t *parent, *child; + + assert (patricia); + assert (node); + + if (node->r && node->l) { +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_remove: #0 %s/%d (r & l)\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + + /* this might be a placeholder node -- have to check and make sure + * there is a prefix aossciated with it ! */ + if (node->prefix != NULL) + Deref_Prefix (node->prefix); + node->prefix = NULL; + /* Also I needed to clear data pointer -- masaki */ + node->data = NULL; + return; + } + + if (node->r == NULL && node->l == NULL) { +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_remove: #1 %s/%d (!r & !l)\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + parent = node->parent; + Deref_Prefix (node->prefix); + Delete (node); + patricia->num_active_node--; + + if (parent == NULL) { + assert (patricia->head == node); + patricia->head = NULL; + return; + } + + if (parent->r == node) { + parent->r = NULL; + child = parent->l; + } + else { + assert (parent->l == node); + parent->l = NULL; + child = parent->r; + } + + if (parent->prefix) + return; + + /* we need to remove parent too */ + + if (parent->parent == NULL) { + assert (patricia->head == parent); + patricia->head = child; + } + else if (parent->parent->r == parent) { + parent->parent->r = child; + } + else { + assert (parent->parent->l == parent); + parent->parent->l = child; + } + child->parent = parent->parent; + Delete (parent); + patricia->num_active_node--; + return; + } + +#ifdef PATRICIA_DEBUG + fprintf (stderr, "patricia_remove: #2 %s/%d (r ^ l)\n", + prefix_toa (node->prefix), node->prefix->bitlen); +#endif /* PATRICIA_DEBUG */ + if (node->r) { + child = node->r; + } + else { + assert (node->l); + child = node->l; + } + parent = node->parent; + child->parent = parent; + + Deref_Prefix (node->prefix); + Delete (node); + patricia->num_active_node--; + + if (parent == NULL) { + assert (patricia->head == node); + patricia->head = child; + return; + } + + if (parent->r == node) { + parent->r = child; + } + else { + assert (parent->l == node); + parent->l = child; + } +} + +/* { from demo.c */ + +patricia_node_t * +make_and_lookup (patricia_tree_t *tree, char *string) +{ + prefix_t *prefix; + patricia_node_t *node; + + prefix = ascii2prefix (AF_INET, string); + printf ("make_and_lookup: %s/%d\n", prefix_toa (prefix), prefix->bitlen); + node = patricia_lookup (tree, prefix); + Deref_Prefix (prefix); + return (node); +} + +patricia_node_t * +try_search_exact (patricia_tree_t *tree, char *string) +{ + prefix_t *prefix; + patricia_node_t *node; + + prefix = ascii2prefix (AF_INET, string); + printf ("try_search_exact: %s/%d\n", prefix_toa (prefix), prefix->bitlen); + if ((node = patricia_search_exact (tree, prefix)) == NULL) { + printf ("try_search_exact: not found\n"); + } + else { + printf ("try_search_exact: %s/%d found\n", + prefix_toa (node->prefix), node->prefix->bitlen); + } + Deref_Prefix (prefix); + return (node); +} + +void +lookup_then_remove (patricia_tree_t *tree, char *string) +{ + patricia_node_t *node; + + if ((node = try_search_exact (tree, string))) + patricia_remove (tree, node); +} + +patricia_node_t * +try_search_best (patricia_tree_t *tree, char *string) +{ + prefix_t *prefix; + patricia_node_t *node; + + prefix = ascii2prefix (AF_INET, string); + printf ("try_search_best: %s/%d\n", prefix_toa (prefix), prefix->bitlen); + if ((node = patricia_search_best (tree, prefix)) == NULL) + printf ("try_search_best: not found\n"); + else + printf ("try_search_best: %s/%d found\n", + prefix_toa (node->prefix), node->prefix->bitlen); + Deref_Prefix (prefix); + return (node); +} diff -Nur flow-tools-0.56-orig/contrib/inter.net/libpatricia/patricia.h flow-tools-0.56/contrib/inter.net/libpatricia/patricia.h --- flow-tools-0.56-orig/contrib/inter.net/libpatricia/patricia.h Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/libpatricia/patricia.h Wed Feb 6 20:41:39 2002 @@ -0,0 +1,139 @@ +/* + * $Id: patricia.h,v 1.4 2000/09/29 19:28:07 dplonka Exp $ + * Dave Plonka + * + * This product includes software developed by the University of Michigan, + * Merit Network, Inc., and their contributors. + * + * This file had been called "radix.h" in the MRT sources. + * + * I renamed it to "patricia.h" since it's not an implementation of a general + * radix trie. Also, pulled in various requirements from "mrt.h" and added + * some other things it could be used as a standalone API. + */ + +#ifndef _PATRICIA_H +#define _PATRICIA_H + +/* typedef unsigned int u_int; */ +typedef void (*void_fn_t)(); +/* { from defs.h */ +#define prefix_touchar(prefix) ((u_char *)&(prefix)->add.sin) +#define MAXLINE 1024 +#define BIT_TEST(f, b) ((f) & (b)) +/* } */ + +#define addroute make_and_lookup + +#include /* for struct in_addr */ + +#include /* for AF_INET */ + +/* { from mrt.h */ + +typedef struct _prefix4_t { + u_short family; /* AF_INET | AF_INET6 */ + u_short bitlen; /* same as mask? */ + int ref_count; /* reference count */ + struct in_addr sin; +} prefix4_t; + +typedef struct _prefix_t { + u_short family; /* AF_INET | AF_INET6 */ + u_short bitlen; /* same as mask? */ + int ref_count; /* reference count */ + union { + struct in_addr sin; +#ifdef HAVE_IPV6 + struct in6_addr sin6; +#endif /* IPV6 */ + } add; +} prefix_t; + +/* } */ + +typedef struct _patricia_node_t { + u_int bit; /* flag if this node used */ + prefix_t *prefix; /* who we are in patricia tree */ + struct _patricia_node_t *l, *r; /* left and right children */ + struct _patricia_node_t *parent;/* may be used */ + void *data; /* pointer to data */ + void *user1; /* pointer to usr data (ex. route flap info) */ +} patricia_node_t; + +typedef struct _patricia_tree_t { + patricia_node_t *head; + u_int maxbits; /* for IP, 32 bit addresses */ + int num_active_node; /* for debug purpose */ +} patricia_tree_t; + + +patricia_node_t *patricia_search_exact (patricia_tree_t *patricia, prefix_t *prefix); +patricia_node_t *patricia_search_best (patricia_tree_t *patricia, prefix_t *prefix); +patricia_node_t * patricia_search_best2 (patricia_tree_t *patricia, prefix_t *prefix, + int inclusive); +patricia_node_t *patricia_lookup (patricia_tree_t *patricia, prefix_t *prefix); +void patricia_remove (patricia_tree_t *patricia, patricia_node_t *node); +patricia_tree_t *New_Patricia (int maxbits); +void Clear_Patricia (patricia_tree_t *patricia, void_fn_t func); +void Destroy_Patricia (patricia_tree_t *patricia, void_fn_t func); +void patricia_process (patricia_tree_t *patricia, void_fn_t func); + +/* { from demo.c */ + +prefix_t * +ascii2prefix (int family, char *string); + +patricia_node_t * +make_and_lookup (patricia_tree_t *tree, char *string); + +/* } */ + +#define PATRICIA_MAXBITS 128 +#define PATRICIA_NBIT(x) (0x80 >> ((x) & 0x7f)) +#define PATRICIA_NBYTE(x) ((x) >> 3) + +#define PATRICIA_DATA_GET(node, type) (type *)((node)->data) +#define PATRICIA_DATA_SET(node, value) ((node)->data = (void *)(value)) + +#define PATRICIA_WALK(Xhead, Xnode) \ + do { \ + patricia_node_t *Xstack[PATRICIA_MAXBITS+1]; \ + patricia_node_t **Xsp = Xstack; \ + patricia_node_t *Xrn = (Xhead); \ + while ((Xnode = Xrn)) { \ + if (Xnode->prefix) + +#define PATRICIA_WALK_ALL(Xhead, Xnode) \ +do { \ + patricia_node_t *Xstack[PATRICIA_MAXBITS+1]; \ + patricia_node_t **Xsp = Xstack; \ + patricia_node_t *Xrn = (Xhead); \ + while ((Xnode = Xrn)) { \ + if (1) + +#define PATRICIA_WALK_BREAK { \ + if (Xsp != Xstack) { \ + Xrn = *(--Xsp); \ + } else { \ + Xrn = (patricia_node_t *) 0; \ + } \ + continue; } + +#define PATRICIA_WALK_END \ + if (Xrn->l) { \ + if (Xrn->r) { \ + *Xsp++ = Xrn->r; \ + } \ + Xrn = Xrn->l; \ + } else if (Xrn->r) { \ + Xrn = Xrn->r; \ + } else if (Xsp != Xstack) { \ + Xrn = *(--Xsp); \ + } else { \ + Xrn = (patricia_node_t *) 0; \ + } \ + } \ + } while (0) + +#endif /* _PATRICIA_H */ diff -Nur flow-tools-0.56-orig/contrib/inter.net/scripts/condense.pl flow-tools-0.56/contrib/inter.net/scripts/condense.pl --- flow-tools-0.56-orig/contrib/inter.net/scripts/condense.pl Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/scripts/condense.pl Wed Feb 6 20:41:39 2002 @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# +# condense according to time modulo 15 minutes and account, eliminating +# the router + +use strict; + +# Client hash +my %client; + +# Load up the hash +while (defined (my $line = )) { + # Break up into an array, delimited by one or more spaces. + my @a = split (/\s+/, $line); + + # Round up the minute to every 15 minutes, e.g. 104602 -> 104500 + # Note we only have to round up the middle. + # . - string concatenation + my $t = substr ($a[2], 0, 2) . + sprintf ("%02d", int((substr ($a[2], 2, 2) / 15) * 15)) . + "00"; + + # Store into the hash. + $client{$a[3]}{$t} += $a[4]; +} + +# Loop through the content. +# outer: client inner: time + +my @l; +foreach my $c (keys (%client)) { + foreach my $t (keys (%{$client{$c}})) { + push (@l, [$t, $c, $client{$c}{$t}]); # [] creates an array reference + } +} + +# Sort according to time first, then client next. +# Inside the sort function, $a and $b are special variables denoting the +# values to compare. Since @l is an array of references, $a and $b are refs. +@l = sort { + my $v = $a->[0] <=> $b->[0]; # Numeric comparison + if ($v) { # If already > or <, then return + return $v; + } + else { + return $a->[1] cmp $b->[1]; # String comparison + } +} @l; + +# Output +foreach my $e (@l) { + printf "%06d %s %s\n", $e->[0], $e->[1], $e->[2]; +} diff -Nur flow-tools-0.56-orig/contrib/inter.net/scripts/conf2acl.pl flow-tools-0.56/contrib/inter.net/scripts/conf2acl.pl --- flow-tools-0.56-orig/contrib/inter.net/scripts/conf2acl.pl Thu Jan 1 08:00:00 1970 +++ flow-tools-0.56/contrib/inter.net/scripts/conf2acl.pl Wed Feb 6 20:41:39 2002 @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# generated by william.s.yu@ieee.org +# +# quick perl hack for converting client.conf files +# to cisco ACL files for Inter.net Philippines +# + +use strict; + +my ($oldline,$line); +my @splitline; +my @names; +my $determinant; +my $element; +my $i; +my $mask2; +my $m; +my @w; + +#$determinant="1"; +while (($line = ) ne undef) { + chomp($line); #removes new line character + @splitline = split(/\s+/, $line); #splits the elements into an array. (duh?) + #check if first digit is numeric. + if (substr($splitline[0],0,1)=~ /\d/) + { + $splitline[0]="x".$splitline[0];#if numeric, add 'x' + } + for ($i=1; $i