From 792584c2110578b09bff4f54491d3b8d42ae504c Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Mon, 5 Dec 2005 21:28:34 +0000 Subject: no more usage of Ethereal.lib in dumpcap any longer :-) use capture_opts_trim() output of command line usage and version "enhanced" svn path=/trunk/; revision=16684 --- dumpcap.c | 88 +++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 27 deletions(-) (limited to 'dumpcap.c') diff --git a/dumpcap.c b/dumpcap.c index 2e66093a4d..5e86c9d62a 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -98,29 +98,66 @@ print_usage(gboolean print_ver) { if (print_ver) { output = stdout; - fprintf(output, "This is dumpcap " VERSION "%s" - "\n (C) 1998-2005 Gerald Combs " - "\n\n%s\n\n%s\n", - svnversion, comp_info_str->str, runtime_info_str->str); + fprintf(output, + "Dumpcap " VERSION "%s\n" + "Capture network packets and dump them into a libpcap file.\n" + "See http://www.ethereal.com for more information.\n", + svnversion); } else { output = stderr; } - fprintf(output, "\n%s [ -vh ] [ -Lp ] [ -a ] ...\n", PACKAGE); - fprintf(output, "\t[ -b ] ...\n"); + fprintf(output, "\nUsage: dumpcap [option] ...\n"); + fprintf(output, "\n"); + fprintf(output, "Capture interface:\n"); + fprintf(output, " -i name of interface (def: first none loopback)\n"); + fprintf(output, " -f packet filter in libpcap format\n"); + fprintf(output, " -s packet snapshot length (def: 65535)\n"); + fprintf(output, " -p don't capture in promiscuous mode\n"); #ifdef _WIN32 - fprintf(output, "\t[ -B ]\n"); + fprintf(output, " -B size of kernel buffer (def: 1MB)\n"); #endif - fprintf(output, "\t[ -c ] [ -f ]\n"); - fprintf(output, "\t[ -i ]\n"); - fprintf(output, "\t[ -s ]\n"); - fprintf(output, "\t[ -w ] [ -y ]\n"); + fprintf(output, " -y link layer type (def: first appropriate)\n"); + fprintf(output, "\n"); + fprintf(output, "Stop conditions:\n"); + fprintf(output, " -c stop after n packets (def: infinite)\n"); + fprintf(output, " -a ... duration:NUM - stop after NUM seconds\n"); + fprintf(output, " filesize:NUM - stop this file after NUM KB\n"); + fprintf(output, " files:NUM - stop after NUM files\n"); + /*fprintf(output, "\n");*/ + fprintf(output, "Output (files):\n"); + fprintf(output, " -w name of file to save (def: tempfile)\n"); + fprintf(output, " -b ... duration:NUM - switch to next file after NUM secs\n"); + fprintf(output, " filesize:NUM - switch to next file after NUM KB\n"); + fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n"); + /*fprintf(output, "\n");*/ + fprintf(output, "Miscellaneous:\n"); + fprintf(output, " -v print version information and exit\n"); + fprintf(output, " -h display this help and exit\n"); + fprintf(output, " -L print list of link-layer types of iface and exit\n"); + fprintf(output, "\n"); + fprintf(output, "Example: dumpcap -i eth0 -a duration:60 -w output.pcap\n"); + fprintf(output, "\"Capture network packets from interface eth0 until 60s passed into output.pcap\"\n"); + fprintf(output, "\n"); + fprintf(output, "Use Ctrl-C to stop capturing at any time.\n"); } static void show_version(void) { - printf("dumpcap " VERSION "%s\n\n%s\n\n%s\n", - svnversion, comp_info_str->str, runtime_info_str->str); +#ifdef _WIN32 + create_console(); +#endif + + printf( + "Dumpcap " VERSION "%s\n" + "\n" + "(C) 1998-2005 Gerald Combs \n" + "See http://www.ethereal.com for more information.\n" + "\n" + "%s\n" + "\n" + "%s\n", + svnversion, comp_info_str->str, runtime_info_str->str); } /* @@ -439,20 +476,7 @@ if (capture_opts->iface == NULL) { exit_main(0); } - if (capture_opts->has_snaplen) { - if (capture_opts->snaplen < 1) - capture_opts->snaplen = WTAP_MAX_PACKET_SIZE; - else if (capture_opts->snaplen < MIN_PACKET_SIZE) - capture_opts->snaplen = MIN_PACKET_SIZE; - } - - /* Check the value range of the ringbuffer_num_files parameter */ - if (capture_opts->ring_num_files > RINGBUFFER_MAX_NUM_FILES) - capture_opts->ring_num_files = RINGBUFFER_MAX_NUM_FILES; -#if RINGBUFFER_MIN_NUM_FILES > 0 - else if (capture_opts->num_files < RINGBUFFER_MIN_NUM_FILES) - capture_opts->ring_num_files = RINGBUFFER_MIN_NUM_FILES; -#endif + capture_opts_trim(capture_opts, MIN_PACKET_SIZE); /* Now start the capture. */ @@ -745,6 +769,16 @@ simple_dialog_format_message(const char *msg) return str; } +/****************************************************************************************************************/ +/* link "dummies" */ + + +const char *netsnmp_get_version() { return ""; } + +gboolean dfilter_compile(const gchar *text, dfilter_t **dfp) { return NULL; } + +void dfilter_free(dfilter_t *df) {} + /* * Find out whether a hostname resolves to an ip or ipv6 address -- cgit v1.2.1