Greetings,
Fixed FDDI to use correct bit swapped encap. Tweaked
file open code to guess at file encap so merge works
better.
Hope I made the cutoff for the new release...
Thanks!
Mark
--
"If a train station is where a train stops, | Mark C. Brown
then what's a workstation?" -- D. Huber | mbrown@xxxxxxxxxx
Index: wiretap/nettl.c
===================================================================
--- wiretap/nettl.c (revision 12350)
+++ wiretap/nettl.c (working copy)
@@ -164,6 +164,7 @@
int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
{
char magic[12], os_vers[2];
+ guint8 dummy[4];
int bytes_read;
/* Read in the string that should be at the start of a HP file */
@@ -208,6 +209,45 @@
wth->subtype_close = nettl_close;
wth->snapshot_length = 0; /* not available in header, only in frame */
+ /* read the first header to take a guess at the file encap */
+ bytes_read = file_read(dummy, 1, 4, wth->fh);
+ if (bytes_read != 4) {
+ if (*err != 0)
+ return -1;
+ if (bytes_read != 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ return -1;
+ }
+ return 0;
+ }
+
+ switch (dummy[3]) {
+ case NETTL_SUBSYS_HPPB_FDDI :
+ case NETTL_SUBSYS_EISA_FDDI :
+ case NETTL_SUBSYS_PCI_FDDI :
+ case NETTL_SUBSYS_HSC_FDDI :
+ wth->file_encap = WTAP_ENCAP_FDDI_BITSWAPPED;
+ break;
+ case NETTL_SUBSYS_TOKEN :
+ case NETTL_SUBSYS_PCI_TR :
+ wth->file_encap = WTAP_ENCAP_TOKEN_RING;
+ break;
+ case NETTL_SUBSYS_NS_LS_IP :
+ case NETTL_SUBSYS_NS_LS_LOOPBACK :
+ case NETTL_SUBSYS_NS_LS_TCP :
+ case NETTL_SUBSYS_NS_LS_UDP :
+ case NETTL_SUBSYS_NS_LS_IPV6 :
+ wth->file_encap = WTAP_ENCAP_RAW_IP;
+ break;
+ default:
+ /* if assumption is bad, the read will catch it */
+ wth->file_encap = WTAP_ENCAP_ETHERNET;
+ }
+
+ if (file_seek(wth->fh, 0x80, SEEK_SET, err) == -1)
+ return -1;
+ wth->data_offset = 0x80;
+
return 1;
}
@@ -357,7 +397,7 @@
|| (encap == NETTL_SUBSYS_EISA_FDDI)
|| (encap == NETTL_SUBSYS_PCI_FDDI)
|| (encap == NETTL_SUBSYS_HSC_FDDI) ) {
- phdr->pkt_encap = WTAP_ENCAP_FDDI;
+ phdr->pkt_encap = WTAP_ENCAP_FDDI_BITSWAPPED;
} else if( (encap == NETTL_SUBSYS_PCI_TR)
|| (encap == NETTL_SUBSYS_TOKEN) ) {
phdr->pkt_encap = WTAP_ENCAP_TOKEN_RING;
@@ -663,7 +703,7 @@
switch (encap) {
case WTAP_ENCAP_ETHERNET:
- case WTAP_ENCAP_FDDI:
+ case WTAP_ENCAP_FDDI_BITSWAPPED:
case WTAP_ENCAP_TOKEN_RING:
case WTAP_ENCAP_RAW_IP:
case WTAP_ENCAP_RAW_ICMP:
@@ -740,7 +780,7 @@
rec_hdr.subsys = g_htons(NETTL_SUBSYS_BTLAN);
break;
- case WTAP_ENCAP_FDDI:
+ case WTAP_ENCAP_FDDI_BITSWAPPED:
rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_FDDI);
/* account for pad bytes */
rec_hdr.hdr.caplen = g_htonl(phdr->caplen + 3);
@@ -775,7 +815,7 @@
}
wdh->bytes_dumped += sizeof(rec_hdr);
- if (phdr->pkt_encap == WTAP_ENCAP_FDDI) {
+ if (phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) {
/* add those weird 3 bytes of padding */
nwritten = fwrite(&dummy, 1, 3, wdh->fh);
if (nwritten != 3) {