summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSake Blok <sake@euronet.nl>2007-09-29 07:55:25 +0000
committerSake Blok <sake@euronet.nl>2007-09-29 07:55:25 +0000
commita2778dcb2784bb63d5d1ed824d8810b81bbd0c7f (patch)
tree0f92fd07ba4a6d9f8df915fafbacd2069251df7f
parent53e74d793104886de6ebf57ce9d9a2f9d1c9073e (diff)
downloadwireshark-a2778dcb2784bb63d5d1ed824d8810b81bbd0c7f.tar.gz
When reading NetScreen snoop output, only use WTAP_ENCAP_PER_PACKET
if there are packets with different encapsulationtype in the file. Otherwise use the encapsulationtype of the packets in the file. This makes it possible to save the imported data as libpcap file (or any other format that does not support per-packet encapsulation). svn path=/trunk/; revision=23031
-rw-r--r--wiretap/netscreen.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index 325905e027..4122935709 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -202,7 +202,7 @@ int netscreen_open(wtap *wth, int *err, gchar **err_info _U_)
return -1;
wth->data_offset = 0;
- wth->file_encap = WTAP_ENCAP_PER_PACKET;
+ wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->file_type = WTAP_FILE_NETSCREEN;
wth->snapshot_length = 0; /* not known */
wth->subtype_read = netscreen_read;
@@ -244,6 +244,13 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
return FALSE;
}
+ /*
+ * Determine the encapsulation type, based on the
+ * first 4 characters of the interface name
+ *
+ * XXX convert this to a 'case' structure when adding more
+ * (non-ethernet) interfacetypes
+ */
if (strncmp(cap_int, "adsl", 4) == 0)
wth->phdr.pkt_encap = WTAP_ENCAP_PPP;
else if (strncmp(cap_int, "seri", 4) == 0)
@@ -251,6 +258,21 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
else
wth->phdr.pkt_encap = WTAP_ENCAP_ETHERNET;
+ /*
+ * 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;
+ }
+
wth->data_offset = offset;
wth->phdr.caplen = caplen;
*data_offset = offset;