*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
*
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#ifdef HAVE_LIBPCAP
#include <glib.h>
-#include "pcapio.h"
#include "ringbuffer.h"
#include <wsutil/file_util.h>
rb_data.fsuffix, NULL);
if (rfile->name == NULL) {
- *err = ENOMEM;
+ if (err != NULL)
+ *err = ENOMEM;
return -1;
}
}
/*
- * Calls libpcap_fdopen() for the current ringbuffer file
+ * Calls ws_fdopen() for the current ringbuffer file
*/
FILE *
ringbuf_init_libpcap_fdopen(int *err)
{
- rb_data.pdh = libpcap_fdopen(rb_data.fd, err);
+ rb_data.pdh = ws_fdopen(rb_data.fd, "wb");
+ if (rb_data.pdh == NULL) {
+ if (err != NULL) {
+ *err = errno;
+ }
+ }
return rb_data.pdh;
}
/* close current file */
- if (!libpcap_dump_close(rb_data.pdh, err)) {
+ if (fclose(rb_data.pdh) == EOF) {
+ if (err != NULL) {
+ *err = errno;
+ }
ws_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;
}
/*
- * Calls libpcap_dump_close() for the current ringbuffer file
+ * Calls fclose() for the current ringbuffer file
*/
gboolean
ringbuf_libpcap_dump_close(gchar **save_file, int *err)
/* close current file, if it's open */
if (rb_data.pdh != NULL) {
- if (!libpcap_dump_close(rb_data.pdh, err)) {
+ if (fclose(rb_data.pdh) == EOF) {
+ if (err != NULL) {
+ *err = errno;
+ }
ws_close(rb_data.fd);
ret_val = FALSE;
}
-
rb_data.pdh = NULL;
rb_data.fd = -1;
}
/* try to close via wtap */
if (rb_data.pdh != NULL) {
- if (libpcap_dump_close(rb_data.pdh, NULL)) {
+ if (fclose(rb_data.pdh) == 0) {
rb_data.fd = -1;
}
rb_data.pdh = NULL;
}
/* close directly if still open */
- /* XXX - it shouldn't still be open; "libpcap_dump_close()" should leave the
- file closed even if it fails */
if (rb_data.fd != -1) {
ws_close(rb_data.fd);
rb_data.fd = -1;