aboutsummaryrefslogtreecommitdiffstats
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-04-29 17:54:46 +0000
committerGuy Harris <guy@alum.mit.edu>2006-04-29 17:54:46 +0000
commit25e8c37489cf6503e7ce8c436f19f54bf7a5027a (patch)
treedcbe91c747f03f35df391a14e4fdf728623dbffe /ringbuffer.c
parentf3d1963924c0b88d7a47c983f3bc3d98273a9e7b (diff)
Have the ring buffer routines take a pointer to a "bytes written" count
as an argument, rather than keeping the count to themselves, so the count kept by the capturing program can be updated correctly - including getting reset when files are switched. Fixes bug 895. svn path=/trunk/; revision=18032
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c13
1 files changed, 7 insertions, 6 deletions
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;
}