/* * Copyright (c) 2014, Peter Haag * Copyright (c) 2009, Peter Haag * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the author nor the names of its contributors may be * used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. * * $Author: peter $ * * $Id: nftrack.c 224 2014-02-16 12:59:29Z peter $ * * $LastChangedRevision: 224 $ * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #ifdef HAVE_STDINT_H #include #endif #include "nf_common.h" #include "nffile.h" #include "flist.h" #include "rbtree.h" #include "nftree.h" #include "nfdump.h" #include "nfx.h" #include "util.h" #include "grammar.h" #include "nftrack_stat.h" #include "nftrack_rrd.h" // We have 288 slot ( 1 day ) for stat record #define AVG_STAT 1 /* Externals */ extern int yydebug; /* Global Variables */ FilterEngine_data_t *Engine; int byte_mode, packet_mode; uint32_t byte_limit, packet_limit; // needed for linking purpose only extension_map_list_t *extension_map_list; /* Local Variables */ static const char *nfdump_version = VERSION; /* Function Prototypes */ static void usage(char *name); static int CheckRunningOnce(char *pidfile); static data_row *process(char *filter); /* Functions */ #include "nffile_inline.c" static void usage(char *name) { printf("usage %s [options] [\"filter\"]\n" "-h\t\tthis text you see right here\n" "-l\t\tLast update of Ports DB\n" "-V\t\tPrint version and exit.\n" "-I\t\tInitialize Ports DB files.\n" "-d \tPorts DB directory.\n" "-r \tread from file. default: stdin\n" "-p\t\tOnline output mode.\n" "-s\t\tCreate port statistics for timeslot -t\n" "-t