diff options
-rw-r--r-- | capture_opts.c | 17 | ||||
-rw-r--r-- | capture_opts.h | 5 | ||||
-rw-r--r-- | gtk/main.c | 15 |
3 files changed, 23 insertions, 14 deletions
diff --git a/capture_opts.c b/capture_opts.c index 38da616b64..85b175ee23 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -368,4 +368,21 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, } } + +void capture_opts_trim(capture_options *capture_opts, int snaplen_min) +{ + if (capture_opts->snaplen < 1) + capture_opts->snaplen = WTAP_MAX_PACKET_SIZE; + else if (capture_opts->snaplen < snaplen_min) + capture_opts->snaplen = snaplen_min; + + /* Check the value range of the ring_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->ring_num_files < RINGBUFFER_MIN_NUM_FILES) + capture_opts->ring_num_files = RINGBUFFER_MIN_NUM_FILES; +#endif +} + #endif /* HAVE_LIBPCAP */ diff --git a/capture_opts.h b/capture_opts.h index 2708f80e61..e75535afd1 100644 --- a/capture_opts.h +++ b/capture_opts.h @@ -101,9 +101,14 @@ typedef struct capture_options_tag { extern void capture_opts_init(capture_options *capture_opts, void *cfile); +/* set a command line option value */ extern void capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture); +/* trim values after command line finished */ +extern void +capture_opts_trim(capture_options *capture_opts, int snaplen_min); + /* log content of capture_opts */ extern void capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts); diff --git a/gtk/main.c b/gtk/main.c index 9a764d0937..2e29f8eb08 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2423,20 +2423,7 @@ main(int argc, char *argv[]) exit(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); #endif /* HAVE_LIBPCAP */ /* Notify all registered modules that have had any of their preferences |