forked from osmocom/wireshark
add capture_opts_trim(), as this sequence is used three times now (will replace the other appearances later) ...
svn path=/trunk/; revision=16683
This commit is contained in:
parent
7e5f31b6a0
commit
e1ee12bc71
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
15
gtk/main.c
15
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
|
||||
|
|
Loading…
Reference in New Issue