add capture_opts_trim(), as this sequence is used three times now (will replace the...
authorUlf Lamping <ulf.lamping@web.de>
Mon, 5 Dec 2005 21:26:01 +0000 (21:26 -0000)
committerUlf Lamping <ulf.lamping@web.de>
Mon, 5 Dec 2005 21:26:01 +0000 (21:26 -0000)
svn path=/trunk/; revision=16683

capture_opts.c
capture_opts.h
gtk/main.c

index 38da616b642c79d3e1ee810673d41f2eeb049891..85b175ee23cb0c01b3c059ac8e1ec96d1ce19fa0 100644 (file)
@@ -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 */
index 2708f80e6144dbcfc1c0aa12dfd96ec2f98fd695..e75535afd1944f2704c52cced5dd00c3744e4e17 100644 (file)
@@ -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);
index 9a764d093748ae8585738942ac16159dfd42772f..2e29f8eb080d7f1a4d0d084580ba55659692562d 100644 (file)
@@ -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