aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c52
1 files changed, 11 insertions, 41 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 1da8f4ed23..f8e02cd8e8 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1,6 +1,6 @@
/* wtap.c
*
- * $Id: wtap.c,v 1.2 1998/11/12 06:01:26 gram Exp $
+ * $Id: wtap.c,v 1.3 1998/11/15 05:29:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -23,19 +23,9 @@
#include "wtap.h"
-static
-void pcap_callback_wrapper(u_char *user, const struct pcap_pkthdr *phdr,
- const u_char *buf);
-
-wtap_handler wtap_callback = NULL;
-
FILE* wtap_file(wtap *wth)
{
- if (wth->file_type == WTAP_FILE_PCAP) {
- return pcap_file(wth->capture.pcap);
- }
- else
- return wth->fh;
+ return wth->fh;
}
int wtap_file_type(wtap *wth)
@@ -51,44 +41,24 @@ int wtap_encapsulation(wtap *wth)
int wtap_snapshot_length(wtap *wth)
{
- if (wth->file_type == WTAP_FILE_PCAP)
- return pcap_snapshot(wth->capture.pcap);
- else
- /* this is obviously *very* temporary :-) */
- return 5000;
+ return wth->snapshot_length;
}
void wtap_close(wtap *wth)
{
- if (wth->file_type == WTAP_FILE_PCAP)
- pcap_close(wth->capture.pcap);
- else
- fclose(wth->fh);
+ /* XXX - free up memory? */
+ fclose(wth->fh);
}
void wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user)
{
int i = 0;
+ int data_offset;
- if (wth->file_type == WTAP_FILE_PCAP) {
- wtap_callback = callback;
- pcap_loop(wth->capture.pcap, count, pcap_callback_wrapper, user);
- }
- else {
- /*while (ngsniffer_read(wth)) {*/
- while (wth->subtype_read(wth)) {
- i++;
- /*g_message("Parsing packet %d", i);*/
- callback(user, &wth->phdr, buffer_start_ptr(&wth->frame_buffer));
- }
+ while ((data_offset = wth->subtype_read(wth)) > 0) {
+ i++;
+ /*g_message("Parsing packet %d", i);*/
+ callback(user, &wth->phdr, data_offset,
+ buffer_start_ptr(&wth->frame_buffer));
}
}
-
-static
-void pcap_callback_wrapper(u_char *user, const struct pcap_pkthdr *phdr,
- const u_char *buf)
-{
-/* struct wtap_pkthdr whdr;
- memcpy(&whdr, phdr, sizeof(struct wtap_pkthdr));*/
- wtap_callback(user, (struct wtap_pkthdr*) phdr, buf);
-}