diff options
-rw-r--r-- | capture_loop.c | 8 | ||||
-rw-r--r-- | ringbuffer.c | 13 | ||||
-rw-r--r-- | ringbuffer.h | 6 | ||||
-rw-r--r-- | tethereal.c | 7 |
4 files changed, 21 insertions, 13 deletions
diff --git a/capture_loop.c b/capture_loop.c index f4a3f908fa..16d32bb350 100644 --- a/capture_loop.c +++ b/capture_loop.c @@ -744,7 +744,8 @@ gboolean capture_loop_init_output(capture_options *capture_opts, int save_file_f /* Set up to write to the capture file. */ if (capture_opts->multi_files_on) { - ld->pdh = ringbuf_init_libpcap_fdopen(ld->linktype, file_snaplen, &err); + ld->pdh = ringbuf_init_libpcap_fdopen(ld->linktype, file_snaplen, + &ld->bytes_written, &err); } else { ld->pdh = libpcap_fdopen(save_file_fd, ld->linktype, file_snaplen, &ld->bytes_written, &err); @@ -1233,7 +1234,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct /* Switch to the next ringbuffer file */ if (ringbuf_switch_file(&ld.pdh, &capture_opts->save_file, - &save_file_fd, &ld.err)) { + &save_file_fd, &ld.bytes_written, &ld.err)) { /* File switch succeeded: reset the conditions */ cnd_reset(cnd_autostop_size); if (cnd_file_duration) { @@ -1303,7 +1304,8 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct } /* Switch to the next ringbuffer file */ - if (ringbuf_switch_file(&ld.pdh, &capture_opts->save_file, &save_file_fd, &ld.err)) { + if (ringbuf_switch_file(&ld.pdh, &capture_opts->save_file, + &save_file_fd, &ld.bytes_written, &ld.err)) { /* file switch succeeded: reset the conditions */ cnd_reset(cnd_file_duration); if(cnd_autostop_size) diff --git a/ringbuffer.c b/ringbuffer.c index 7d1e00af66..f4cf4b0d32 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -88,7 +88,6 @@ typedef struct _ringbuf_data { int fd; /* Current ringbuffer file descriptor */ FILE *pdh; - long bytes_written; /* Bytes written to the current file */ } ringbuf_data; static ringbuf_data rb_data; @@ -231,14 +230,15 @@ const gchar *ringbuf_current_filename(void) * Calls libpcap_fdopen() for the current ringbuffer file */ FILE * -ringbuf_init_libpcap_fdopen(int linktype, int snaplen, int *err) +ringbuf_init_libpcap_fdopen(int linktype, int snaplen, + long *bytes_written, int *err) { rb_data.linktype = linktype; rb_data.snaplen = snaplen; - rb_data.pdh = libpcap_fdopen(rb_data.fd, linktype, snaplen, - &rb_data.bytes_written, err); + rb_data.pdh = libpcap_fdopen(rb_data.fd, linktype, snaplen, bytes_written, + err); return rb_data.pdh; } @@ -246,7 +246,8 @@ ringbuf_init_libpcap_fdopen(int linktype, int snaplen, int *err) * Switches to the next ringbuffer file */ gboolean -ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err) +ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, + long *bytes_written, int *err) { int next_file_num; rb_file *next_rfile = NULL; @@ -274,7 +275,7 @@ ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err) } if (ringbuf_init_libpcap_fdopen(rb_data.linktype, rb_data.snaplen, - err) == NULL) { + bytes_written, err) == NULL) { return FALSE; } diff --git a/ringbuffer.h b/ringbuffer.h index 8989f5c4aa..63af28bce9 100644 --- a/ringbuffer.h +++ b/ringbuffer.h @@ -40,8 +40,10 @@ int ringbuf_init(const char *capture_name, guint num_files); const gchar *ringbuf_current_filename(void); -FILE *ringbuf_init_libpcap_fdopen(int linktype, int snaplen, int *err); -gboolean ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err); +FILE *ringbuf_init_libpcap_fdopen(int linktype, int snaplen, + long *bytes_written, int *err); +gboolean ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, + long *bytes_written, int *err); gboolean ringbuf_libpcap_dump_close(gchar **save_file, int *err); void ringbuf_free(void); void ringbuf_error_cleanup(void); diff --git a/tethereal.c b/tethereal.c index b2fb7a0913..ece0213094 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1716,7 +1716,9 @@ capture(void) its maximum size. */ if (capture_opts.multi_files_on) { /* Switch to the next ringbuffer file */ - if (ringbuf_switch_file(&ld.pdh, &capture_opts.save_file, &save_file_fd, &loop_err)) { + if (ringbuf_switch_file(&ld.pdh, &capture_opts.save_file, + &save_file_fd, &ld.bytes_written, + &loop_err)) { /* File switch succeeded: reset the condition */ cnd_reset(cnd_autostop_size); if (cnd_file_duration) { @@ -1889,7 +1891,8 @@ capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr, */ if (cnd_file_duration != NULL && cnd_eval(cnd_file_duration)) { /* time elapsed for this ring file, switch to the next */ - if (ringbuf_switch_file(&ld->pdh, &ld->save_file, &save_file_fd, &loop_err)) { + if (ringbuf_switch_file(&ld->pdh, &ld->save_file, &save_file_fd, + &ld->bytes_written, &loop_err)) { /* File switch succeeded: reset the condition */ cnd_reset(cnd_file_duration); } else { |