aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netscreen.c
diff options
context:
space:
mode:
authorsake <sake@f5534014-38df-0310-8fa8-9805f1628bb7>2007-09-29 07:55:25 +0000
committersake <sake@f5534014-38df-0310-8fa8-9805f1628bb7>2007-09-29 07:55:25 +0000
commit20c15d9efbaeb9bcbc755d719e16ede9117b4624 (patch)
tree0f92fd07ba4a6d9f8df915fafbacd2069251df7f /wiretap/netscreen.c
parent1731c9857fb42722ebec2e351338c78776eb964c (diff)
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). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23031 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wiretap/netscreen.c')
-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;