/* * Copyright (c) 2018, 2017, 2016 Peter Haag * Copyright (c) 2014, Peter Haag * Copyright (c) 2009, Peter Haag * Copyright (c) 2004-2008, 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. * */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_STDINT_H #include #endif #include "nffile.h" #include "nfx.h" #include "nf_common.h" #include "rbtree.h" #include "nftree.h" #include "nfdump.h" #include "nfnet.h" #include "bookkeeper.h" #include "collector.h" #include "exporter.h" #include "netflow_v5_v7.h" #include "netflow_v9.h" #include "nfprof.h" #include "flist.h" #include "util.h" #include "grammar.h" #define DEFAULTCISCOPORT "9995" #define DEFAULTHOSTNAME "127.0.0.1" #undef FPURGE #ifdef HAVE___FPURGE #define FPURGE __fpurge #endif #ifdef HAVE_FPURGE #define FPURGE fpurge #endif /* Externals */ extern int yydebug; #ifdef COMPAT15 extern extension_descriptor_t extension_descriptor[]; #endif /* Global Variables */ FilterEngine_data_t *Engine; int verbose; /* Local Variables */ static const char *nfdump_version = VERSION; send_peer_t peer; extension_map_list_t *extension_map_list; generic_exporter_t **exporter_list; /* Function Prototypes */ static void usage(char *name); static void send_blast(unsigned int delay ); static void send_data(char *rfile, time_t twin_start, time_t twin_end, uint32_t count, unsigned int delay, int confirm, int netflow_version, int distribution); static int FlushBuffer(int confirm); /* Functions */ #include "nffile_inline.c" #include "nfdump_inline.c" static void usage(char *name) { printf("usage %s [options] [\"filter\"]\n" "-h\t\tthis text you see right here\n" "-V\t\tPrint version and exit.\n" "-H \tTarget IP address default: 127.0.0.1\n" "-j \tSend packets to multicast group\n" "-4\t\tForce IPv4 protocol.\n" "-6\t\tForce IPv6 protocol.\n" "-L \tLog to syslog facility \n" "-p \tTarget port default 9995\n" "-d \tDelay in usec between packets. default 10\n" "-c \tPacket count. default send all packets\n" "-b \tSend buffer size.\n" "-r \tread from file. default: stdin\n" "-f \tfilter syntaxfile\n" "-v \tUse netflow version to send flows. Either 5 or 9\n" "-z \tSimulate real time distribution with coefficient\n" "-t