]> The Tcpdump Group git mirrors - tcpdump/commitdiff
The control field of an LLC frame is 1 byte for a U frame and 2 bytes
authorguy <guy>
Tue, 5 Dec 2000 06:42:47 +0000 (06:42 +0000)
committerguy <guy>
Tue, 5 Dec 2000 06:42:47 +0000 (06:42 +0000)
for an S or I frame; have the LLC dissector pass the control field value
as an argument to the NetBEUI dissector, rather than having the NetBEUI
dissector extract the control field value itself, and have it pass a
pointer to the beginning of the LLC *payload* rather than to the control
field.

Keep the NetBEUI dissector from running past the end of the buffer.

Add support for the NetBEUI SESSION ALIVE frame.

interface.h
print-llc.c
print-smb.c

index e6e1d36311f3203fca078094110e12effb880f3b..c8462f443c1360ac66c28dbe3087a32d74d09f39 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.145 2000-11-17 19:08:14 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.146 2000-12-05 06:42:49 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -271,7 +271,7 @@ extern int esp_print(register const u_char *, register const u_char *, int *);
 extern void isakmp_print(const u_char *, u_int, const u_char *);
 extern int ipcomp_print(register const u_char *, register const u_char *, int *);
 extern void rx_print(register const u_char *, int, int, int, u_char *);
-extern void netbeui_print(const u_char *, const u_char *);
+extern void netbeui_print(u_short, const u_char *, const u_char *);
 extern void ipx_netbios_print(const u_char *, const u_char *);
 extern void nbt_tcp_print(const u_char *, int);
 extern void nbt_udp137_print(const u_char *data, int);
index 4f0dbed53a27114299bb0cba138df325b8612aca..2763c0fca4eafa0175b1901fa6d873677f3c19fd 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.29 2000-06-10 20:57:56 assar Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.30 2000-12-05 06:42:48 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -68,6 +68,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
 {
        struct llc llc;
        register u_short et;
+       u_short control;
        register int ret;
 
        if (caplen < 3) {
@@ -102,7 +103,32 @@ llc_print(const u_char *p, u_int length, u_int caplen,
                 * smb parser can handle many smb-in-netbeui packets, which
                 * is very useful, so we call that
                 */
-               netbeui_print(p + 2, p + min(caplen, length));
+
+               /*
+                * Skip the DSAP and LSAP.
+                */
+               p += 2;
+               length -= 2;
+               caplen -= 2;
+
+               /*
+                * OK, what type of LLC frame is this?  The length
+                * of the control field depends on that - S or I
+                * frames have a two-byte control field, and U frames
+                * have a one-byte control field.
+                */
+               if ((llc.llcu & LLC_U_FMT) == LLC_U_FMT) {
+                       control = llc.llcu;
+                       p += 1;
+                       length -= 1;
+                       caplen -= 1;
+               } else {
+                       control = llc.llcis;
+                       p += 2;
+                       length -= 2;
+                       caplen -= 2;
+               }
+               netbeui_print(control, p, p + min(caplen, length));
                return (1);
        }
        if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
index 414bea38f8587577cefdc9ef8cb2755ee1c3fb08..85e2b43751bbe1c3750e460239a674d84f3ddb52 100644 (file)
@@ -11,7 +11,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.6 2000-12-04 00:35:44 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.7 2000-12-05 06:42:47 guy Exp $";
 #endif
 
 #include <stdio.h>
@@ -935,15 +935,22 @@ void nbt_udp138_print(const uchar *data, int length)
 /*
    print netbeui frames 
 */
-void netbeui_print(const uchar *data, const uchar *maxbuf)
+void netbeui_print(u_short control, const uchar *data, const uchar *maxbuf)
 {
-  int len = SVAL(data,1);
-  int command = CVAL(data,5);
-  const uchar *data2 = data + 1 + len;
+  int len = SVAL(data,0);
+  int command = CVAL(data,4);
+  const uchar *data2 = data + len;
+  int is_truncated = 0;
+
+  if (data2 >= maxbuf) {
+    data2 = maxbuf;
+    is_truncated = 1;
+  }
 
   startbuf = data;
 
-  data = fdata(data,"\n>>> NetBeui Packet\nType=[B] Length=[d] Signature=[w] Command=[B]\n#",maxbuf);
+  printf("\n>>> NetBeui Packet\nType=0x%X ", control);
+  data = fdata(data,"Length=[d] Signature=[w] Command=[B]\n#",maxbuf);
   if (data == NULL)
     goto out;
 
@@ -980,6 +987,10 @@ void netbeui_print(const uchar *data, const uchar *maxbuf)
     data = fdata(data,"SessionEnd:\n[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
     break;
 
+  case 0x1f:
+    data = fdata(data,"SessionAlive\n",data2);
+    break;
+
   default:
     data = fdata(data,"Unknown Netbios Command ",data2);
     break;
@@ -987,11 +998,18 @@ void netbeui_print(const uchar *data, const uchar *maxbuf)
   if (data == NULL)
     goto out;
 
+  if (is_truncated) {
+    /* data2 was past the end of the buffer */
+    goto out;
+  }
+
   if (memcmp(data2,"\377SMB",4)==0) {
     print_smb(data2,maxbuf);
   } else {
     int i;
     for (i=0;i<128;i++) {
+      if (&data2[i] >= maxbuf)
+        break;
       if (memcmp(&data2[i],"\377SMB",4)==0) {
        printf("found SMB packet at %d\n", i);
        print_smb(&data2[i],maxbuf);