summaryrefslogtreecommitdiff
path: root/tethereal.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-06-07 21:11:24 +0000
committerGuy Harris <guy@alum.mit.edu>2002-06-07 21:11:24 +0000
commitc2b438ddfa12d8cec7b4da8026012d2808baad5a (patch)
treebe2e1bf7af783c71c773706bc786dec9d18b26a6 /tethereal.c
parentec511777923e32cdb0b1877ece838a376f511076 (diff)
downloadwireshark-c2b438ddfa12d8cec7b4da8026012d2808baad5a.tar.gz
Add a Wiretap routine to process packets captured via libpcap, possibly
extracting a pseudo-header, for the use of SunATM captures. Add support for SunATM capture. svn path=/trunk/; revision=5652
Diffstat (limited to 'tethereal.c')
-rw-r--r--tethereal.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/tethereal.c b/tethereal.c
index 26dadfc627..11dab8a92c 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.139 2002/06/04 07:03:47 guy Exp $
+ * $Id: tethereal.c,v 1.140 2002/06/07 21:11:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -103,6 +103,10 @@
#include "ringbuffer.h"
#include <epan/epan_dissect.h>
+#ifdef HAVE_LIBPCAP
+#include <wiretap/wtap-capture.h>
+#endif
+
#ifdef WIN32
#include "capture-wpcap.h"
#endif
@@ -1090,26 +1094,31 @@ capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr,
const u_char *pd)
{
struct wtap_pkthdr whdr;
+ union wtap_pseudo_header pseudo_header;
loop_data *ld = (loop_data *) user;
cb_args_t args;
-
- whdr.ts.tv_sec = phdr->ts.tv_sec;
- whdr.ts.tv_usec = phdr->ts.tv_usec;
- whdr.caplen = phdr->caplen;
- whdr.len = phdr->len;
- whdr.pkt_encap = ld->linktype;
+ int err;
+
+ /* Convert from libpcap to Wiretap format.
+ If that fails, ignore the packet.
+ XXX - print a message. */
+ pd = wtap_process_pcap_packet(ld->linktype, phdr, pd, &pseudo_header,
+ &whdr, &err);
+ if (pd == NULL) {
+ return;
+ }
args.cf = &cfile;
args.pdh = ld->pdh;
if (ld->pdh) {
- wtap_dispatch_cb_write((u_char *)&args, &whdr, 0, NULL, pd);
+ wtap_dispatch_cb_write((u_char *)&args, &whdr, 0, &pseudo_header, pd);
/* Report packet capture count if not quiet */
if (!quiet) {
fprintf(stderr, "\r%u ", cfile.count);
fflush(stdout);
}
} else {
- wtap_dispatch_cb_print((u_char *)&args, &whdr, 0, NULL, pd);
+ wtap_dispatch_cb_print((u_char *)&args, &whdr, 0, &pseudo_header, pd);
}
}