aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-10-06 03:29:36 +0000
committerGuy Harris <guy@alum.mit.edu>1999-10-06 03:29:36 +0000
commit0d43b16fdd69c3ab1e41b0423b6f7861c1738329 (patch)
tree7818e8570b161c5d96370bf6d8a523c7bd5cf207 /wiretap
parent0161298edd84aeb7a1885b21454476838dbdedf1 (diff)
Add "wtap_file_encap()", to return the encapsulation of packets in the
file (which could be WTAP_ENCAP_UNKNOWN, if we couldn't determine it, or WTAP_ENCAP_PER_PACKET, if we could determine the encapsulation of packets in the file, but they didn't all have the same encapsulation). This may be useful in the future, if we allow files to be saved in different capture file formats - we'd have to specify, when creating the capture file, the per-file encapsulation, for those formats that don't support per-packet encapsulations (we wouldn't be able to save a multi-encapsulation capture in those formats). Make the code to read "iptrace" files set the per-file packet encapsulation - set it to the type of the first packet seen, and, if any subsequent packets have a different encapsulation, set it to WTAP_ENCAP_PER_PACKET. svn path=/trunk/; revision=772
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/iptrace.c15
-rw-r--r--wiretap/wtap.c7
-rw-r--r--wiretap/wtap.h5
3 files changed, 24 insertions, 3 deletions
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index ab2b05139d..e87f74c6db 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -1,6 +1,6 @@
/* iptrace.c
*
- * $Id: iptrace.c,v 1.13 1999/10/05 07:06:05 guy Exp $
+ * $Id: iptrace.c,v 1.14 1999/10/06 03:29:36 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -132,5 +132,18 @@ static int iptrace_read(wtap *wth, int *err)
*err = WTAP_ERR_BAD_RECORD;
return -1;
}
+
+ /* If the per-file encapsulation isn't known, set it to this
+ packet's encapsulation.
+
+ If it *is* known, and it isn't this packet's encapsulation,
+ set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
+ have a single encapsulation for all packets in the file. */
+ if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
+ wth->file_encap = wth->phdr.pkt_encap;
+ else {
+ if (wth->file_encap != wth->phdr.pkt_encap)
+ wth->file_encap= WTAP_ENCAP_PER_PACKET;
+ }
return data_offset;
}
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 959878ed35..bc293567af 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1,6 +1,6 @@
/* wtap.c
*
- * $Id: wtap.c,v 1.24 1999/10/05 07:22:53 guy Exp $
+ * $Id: wtap.c,v 1.25 1999/10/06 03:29:35 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -51,6 +51,11 @@ int wtap_snapshot_length(wtap *wth)
return wth->snapshot_length;
}
+int wtap_file_encap(wtap *wth)
+{
+ return wth->file_encap;
+}
+
const char *wtap_file_type_string(wtap *wth)
{
switch (wth->file_type) {
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 22e76a611c..5ca5d8edfb 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.42 1999/10/05 07:06:08 guy Exp $
+ * $Id: wtap.h,v 1.43 1999/10/06 03:29:36 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -31,6 +31,8 @@
* "wtap_dump_fd_open()" to indicate that there is no single encapsulation
* type for all packets in the file; this may cause those routines to
* fail if the capture file format being written can't support that.
+ * It's also returned by "wtap_file_encap()" for capture files that
+ * don't have a single encapsulation type for all packets in the file.
*
* WTAP_ENCAP_UNKNOWN is returned by "wtap_pcap_encap_to_wtap_encap()"
* if it's handed an unknown encapsulation.
@@ -345,6 +347,7 @@ FILE* wtap_file(wtap *wth);
int wtap_fd(wtap *wth);
int wtap_snapshot_length(wtap *wth); /* per file */
int wtap_file_type(wtap *wth);
+int wtap_file_encap(wtap *wth);
const char *wtap_file_type_string(wtap *wth);
const char *wtap_strerror(int err);
void wtap_close(wtap *wth);