X-Git-Url: http://git.samba.org/samba.git/?p=obnox%2Fwireshark%2Fwip.git;a=blobdiff_plain;f=ringbuffer.c;h=00fb35fbcd5316d130c7186565e24eca0e2c759b;hp=0c1e7f4b759a1def7cf8d621bf084a10cd33f8ed;hb=b57d071069e0b51f2472da84392518a7674df962;hpb=0180a288fa38bef477488aecd025aade16614bbf diff --git a/ringbuffer.c b/ringbuffer.c index 0c1e7f4b75..00fb35fbcd 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -3,8 +3,8 @@ * * $Id$ * - * Ethereal - Network traffic analyzer - * By Gerald Combs + * Wireshark - Network traffic analyzer + * By Gerald Combs * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or @@ -61,7 +61,11 @@ #include #include -#include +#include + +#include + +#include "pcapio.h" #include "ringbuffer.h" #include "file_util.h" @@ -79,12 +83,11 @@ typedef struct _ringbuf_data { gchar *fprefix; /* Filename prefix */ gchar *fsuffix; /* Filename suffix */ gboolean unlimited; /* TRUE if unlimited number of files */ - int filetype; int linktype; int snaplen; int fd; /* Current ringbuffer file descriptor */ - wtap_dumper *pdh; + FILE *pdh; } ringbuf_data; static ringbuf_data rb_data; @@ -224,18 +227,18 @@ const gchar *ringbuf_current_filename(void) } /* - * Calls wtap_dump_fdopen() for the current ringbuffer file + * Calls libpcap_fdopen() for the current ringbuffer file */ -wtap_dumper* -ringbuf_init_wtap_dump_fdopen(int filetype, int linktype, int snaplen, int *err) +FILE * +ringbuf_init_libpcap_fdopen(int linktype, int snaplen, + long *bytes_written, int *err) { - rb_data.filetype = filetype; rb_data.linktype = linktype; rb_data.snaplen = snaplen; - rb_data.pdh = wtap_dump_fdopen(rb_data.fd, filetype, linktype, snaplen, FALSE /* compressed */, err); - + rb_data.pdh = libpcap_fdopen(rb_data.fd, linktype, snaplen, bytes_written, + err); return rb_data.pdh; } @@ -243,14 +246,15 @@ ringbuf_init_wtap_dump_fdopen(int filetype, int linktype, int snaplen, int *err) * Switches to the next ringbuffer file */ gboolean -ringbuf_switch_file(wtap_dumper **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; /* close current file */ - if (!wtap_dump_close(rb_data.pdh, err)) { + if (!libpcap_dump_close(rb_data.pdh, err)) { eth_close(rb_data.fd); /* XXX - the above should have closed this already */ rb_data.pdh = NULL; /* it's still closed, we just got an error while closing */ rb_data.fd = -1; @@ -270,8 +274,8 @@ ringbuf_switch_file(wtap_dumper **pdh, gchar **save_file, int *save_file_fd, int return FALSE; } - if (ringbuf_init_wtap_dump_fdopen(rb_data.filetype, rb_data.linktype, - rb_data.snaplen, err) == NULL) { + if (ringbuf_init_libpcap_fdopen(rb_data.linktype, rb_data.snaplen, + bytes_written, err) == NULL) { return FALSE; } @@ -284,16 +288,16 @@ ringbuf_switch_file(wtap_dumper **pdh, gchar **save_file, int *save_file_fd, int } /* - * Calls wtap_dump_close() for the current ringbuffer file + * Calls libpcap_dump_close() for the current ringbuffer file */ gboolean -ringbuf_wtap_dump_close(gchar **save_file, int *err) +ringbuf_libpcap_dump_close(gchar **save_file, int *err) { gboolean ret_val = TRUE; /* close current file, if it's open */ if (rb_data.pdh != NULL) { - if (!wtap_dump_close(rb_data.pdh, err)) { + if (!libpcap_dump_close(rb_data.pdh, err)) { eth_close(rb_data.fd); ret_val = FALSE; } @@ -345,14 +349,14 @@ ringbuf_error_cleanup(void) /* try to close via wtap */ if (rb_data.pdh != NULL) { - if (wtap_dump_close(rb_data.pdh, NULL)) { + if (libpcap_dump_close(rb_data.pdh, NULL)) { rb_data.fd = -1; } rb_data.pdh = NULL; } /* close directly if still open */ - /* XXX - it shouldn't still be open; "wtap_dump_close()" should leave the + /* XXX - it shouldn't still be open; "libpcap_dump_close()" should leave the file closed even if it fails */ if (rb_data.fd != -1) { eth_close(rb_data.fd);