forked from osmocom/wireshark
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=23031daniel/osmux
parent
53e74d7931
commit
a2778dcb27
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue