aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/iptrace.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-10-06 03:29:36 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-10-06 03:29:36 +0000
commit08200661505d52dccd147d882f304a019eb7ab33 (patch)
tree7818e8570b161c5d96370bf6d8a523c7bd5cf207 /wiretap/iptrace.c
parent6d8bebf4351b7e6b302c0327d0f6a18101df4da0 (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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@772 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wiretap/iptrace.c')
-rw-r--r--wiretap/iptrace.c15
1 files changed, 14 insertions, 1 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;
}