Set RINGBUFFER_MAX_NUM_FILES to 100000. Use it to generate file names.

Add RINGBUFFER_WARN_NUM_FILES and use it to print a warning. Print
warnings when we change the number of ringbuffer files.

svn path=/trunk/; revision=32998
This commit is contained in:
Gerald Combs 2010-05-27 18:00:46 +00:00
parent 09c06a932d
commit 8598c522b2
3 changed files with 13 additions and 6 deletions

View File

@ -604,10 +604,15 @@ void capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min)
void capture_opts_trim_ring_num_files(capture_options *capture_opts)
{
/* Check the value range of the ring_num_files parameter */
if (capture_opts->ring_num_files > RINGBUFFER_MAX_NUM_FILES)
if (capture_opts->ring_num_files > RINGBUFFER_MAX_NUM_FILES) {
cmdarg_err("Too many ring buffer files (%u). Reducing to %u.\n", capture_opts->ring_num_files, RINGBUFFER_MAX_NUM_FILES);
capture_opts->ring_num_files = RINGBUFFER_MAX_NUM_FILES;
} else if (capture_opts->ring_num_files > RINGBUFFER_WARN_NUM_FILES) {
cmdarg_err("%u is a lot of ring buffer files.\n", capture_opts->ring_num_files);
}
#if RINGBUFFER_MIN_NUM_FILES > 0
else if (capture_opts->ring_num_files < RINGBUFFER_MIN_NUM_FILES)
cmdarg_err("Too few ring buffer files (%u). Increasing to %u.\n", capture_opts->ring_num_files, RINGBUFFER_MIN_NUM_FILES);
capture_opts->ring_num_files = RINGBUFFER_MIN_NUM_FILES;
#endif
}

View File

@ -113,7 +113,7 @@ static int ringbuf_open_file(rb_file *rfile, int *err)
#endif
current_time = time(NULL);
g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % 100000);
g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % RINGBUFFER_MAX_NUM_FILES);
strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", localtime(&current_time));
rfile->name = g_strconcat(rb_data.fprefix, "_", filenum, "_", timestr,
rb_data.fsuffix, NULL);

View File

@ -30,11 +30,13 @@
#include "wiretap/wtap.h"
#define RINGBUFFER_UNLIMITED_FILES 0
/* minimum number of ringbuffer files */
/* Minimum number of ringbuffer files */
#define RINGBUFFER_MIN_NUM_FILES 0
/* maximum number of ringbuffer files */
/* (only to avoid crashes on very large numbers) */
#define RINGBUFFER_MAX_NUM_FILES 10000
/* Maximum number of ringbuffer files */
/* Avoid crashes on very large numbers. Should be a power of 10 */
#define RINGBUFFER_MAX_NUM_FILES 100000
/* Maximum number for FAT filesystems */
#define RINGBUFFER_WARN_NUM_FILES 65535
int ringbuf_init(const char *capture_name, guint num_files);
const gchar *ringbuf_current_filename(void);