Ethereal-dev: [Ethereal-dev] nettl (HP-UX) Fixes

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Mark C. Brown" <mbrown@xxxxxxxxxx>
Date: Sat, 03 May 2003 23:00:32 -0400
Greetings,

Following fixes for nettl (HP-UX):

1) Fixed 11.X timestamp issue
     there is no difference in 10.X/11.X timestamps, so no
     need to shift 11.X timestamps
2) Fixed NS_LS_DRIVER trace record handling
     now works rather than throwing "...network type that
     Ethereal doesn't support" error
3) Fixed handling of traces with sliced packets (nettl -m xx)
     now uses correct packet and capture lengths
4) Additional ethernet card support
     now handles btlan[1,3-6],gelan,igelan,intl100 driver
     trace records

Comments welcome...

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.h
===================================================================
RCS file: /cvsroot/ethereal/wiretap/nettl.h,v
retrieving revision 1.8
diff -u -r1.8 nettl.h
--- wiretap/nettl.h	28 Aug 2002 20:30:45 -0000	1.8
+++ wiretap/nettl.h	4 May 2003 02:35:17 -0000
@@ -69,8 +69,15 @@
 #define NETTL_SUBSYS_EM			0x7C
 
 /* Ethernet cards */
+#define NETTL_SUBSYS_LAN100		0xA4
 #define NETTL_SUBSYS_BASE100		0xAD
 #define NETTL_SUBSYS_GSC100BT		0xB2
+#define NETTL_SUBSYS_PCI100BT		0xB3
+#define NETTL_SUBSYS_SPP100BT		0xB4
+#define NETTL_SUBSYS_GELAN		0xB9
+#define NETTL_SUBSYS_BTLAN		0xD2
+#define NETTL_SUBSYS_INTL100		0xE9
+#define NETTL_SUBSYS_IGELAN		0xFC
 
 
 int nettl_open(wtap *wth, int *err);
Index: wiretap/nettl.c
===================================================================
RCS file: /cvsroot/ethereal/wiretap/nettl.c,v
retrieving revision 1.31
diff -u -r1.31 nettl.c
--- wiretap/nettl.c	28 Aug 2002 20:30:45 -0000	1.31
+++ wiretap/nettl.c	4 May 2003 02:35:17 -0000
@@ -44,8 +44,8 @@
     guint8	xxa[8];
     guint8	from_dce;
     guint8	xxb[55];
+    guint8	caplen[2];
     guint8	length[2];
-    guint8	length2[2];    /* don't know which one is captured length / real length */
     guint8	xxc[4];
     guint8	sec[4];
     guint8	usec[4];
@@ -56,8 +56,8 @@
 /* This also works for BASE100 and GSC100BT */
 struct nettlrec_ns_ls_ip_hdr {
     guint8	xxa[28];
+    guint8	caplen[4];
     guint8	length[4];
-    guint8	length2[4];    /* don't know which one is captured length / real length */
     guint8	sec[4];
     guint8	usec[4];
     guint8	xxb[16];
@@ -105,20 +105,20 @@
 
 The header for 100baseT seems to be
 	0-3	unknown
-	4-5	length1   these are probably total/captured len. unknown which.
-	6-7	length2
+	4-5	captured length
+	6-7	actual length
 	8-11	unknown
 	12-15	secs
-	16-19	100 x nsec
+	16-19	usecs
 	20-23	unknown
 */
 struct nettlrec_ns_ls_drv_eth_hdr {
     guint8	xxa[4];
-    guint8	length[2];
-    guint8	length2[2];
+    guint8      caplen[2];
+    guint8      length[2];
     guint8	xxb[4];
     guint8	sec[4];
-    guint8	cnsec[4];  /* unit of 100 nsec */
+    guint8	usec[4];
     guint8	xxc[4];
 };
 
@@ -267,13 +267,19 @@
     offset += 4;
 
     switch (encap[3]) {
+	case NETTL_SUBSYS_LAN100 :
 	case NETTL_SUBSYS_BASE100 :
 	case NETTL_SUBSYS_GSC100BT :
+	case NETTL_SUBSYS_PCI100BT :
+	case NETTL_SUBSYS_SPP100BT :
+	case NETTL_SUBSYS_GELAN :
+	case NETTL_SUBSYS_BTLAN :
+	case NETTL_SUBSYS_INTL100 :
+	case NETTL_SUBSYS_IGELAN :
 	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 0xb9:	/* XXX unknown encapsulation name */
 	case NETTL_SUBSYS_NS_LS_ICMP :
 	    if( (encap[3] == NETTL_SUBSYS_NS_LS_IP)
 	    ||  (encap[3] == NETTL_SUBSYS_NS_LS_LOOPBACK)
@@ -320,16 +326,12 @@
 	    length = pntohl(&ip_hdr.length);
 	    if (length <= 0) return 0;
 	    phdr->len = length;
+	    length = pntohl(&ip_hdr.caplen);
 	    phdr->caplen = length;
 
 
 	    phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
-	    /* this filed is in units of 0.1 us for HPUX 11 */
-	    if (wth->capture.nettl->is_hpux_11) {
-		    phdr->ts.tv_usec = pntohl(&ip_hdr.usec)/10;
-	    } else {
-		    phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
-	    }
+	    phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
 	    break;
 	case NETTL_SUBSYS_NS_LS_DRIVER :
 	    bytes_read = file_read(&ip_hdr, 1, sizeof ip_hdr, fh);
@@ -362,7 +364,7 @@
 		offset += 4;
 	    }
 
-	    /* XXX we dont know how to identify this as ehternet frames, so
+	    /* XXX we dont know how to identify this as ethernet frames, so
 	       we assumes everything is. We will crash and burn for anything else */
 	    /* for encapsulated 100baseT we do this */
 	    phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
@@ -379,19 +381,14 @@
 	    }
 	    offset += sizeof drv_eth_hdr;
 
-	    length = pntohl(&ip_hdr.length);
+	    length = pntohs(&drv_eth_hdr.length); 
 	    if (length <= 0) return 0;
 	    phdr->len = length;
+	    length = pntohs(&drv_eth_hdr.caplen);
 	    phdr->caplen = length;
 
-
 	    phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
-	    /* this filed is in units of 0.1 us for HPUX 11 */
-	    if (wth->capture.nettl->is_hpux_11) {
-		    phdr->ts.tv_usec = pntohl(&ip_hdr.usec)/10;
-	    } else {
-		    phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
-	    }
+	    phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
 	    break;
 	case NETTL_SUBSYS_SX25L2 :
 	    phdr->pkt_encap = WTAP_ENCAP_LAPB;