Add the re-write of the NetWare Core Protocol dissector. It's mostly
[obnox/wireshark/wip.git] / packet-smb-pipe.c
index 842982fa894be13b19151ca4906b6ff356021832..bc1ea076b55e2cef63ca7d32784b765e863e3e91 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for smb packet dissection
  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
  *
- * $Id: packet-smb-pipe.c,v 1.6 2000/05/14 03:17:26 guy Exp $
+ * $Id: packet-smb-pipe.c,v 1.9 2000/05/31 05:07:41 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -57,7 +57,13 @@ static gint ett_lanman_shares = -1;
 static gint ett_lanman_share = -1;
 static gint ett_lanman_flags = -1;
 
-
+/*
+ * See
+ *
+ *     ftp://ftp.microsoft.com/developr/drg/CIFS/cifsrap2.txt
+ *
+ * among other documents.
+ */
 
 /* 
  * The following data structure describes the LANMAN requests we understand
@@ -538,7 +544,13 @@ int dissect_transact_next(const u_char *pd, char *Name, int dirn, proto_tree *tr
 
 }
 
-
+static const value_string share_type_vals[] = {
+        {0, "Directory tree"},
+        {1, "Printer queue"},
+        {2, "Communications device"},
+        {3, "IPC"},
+        {0, NULL}
+};
 
 guint32 
 dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
@@ -558,6 +570,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
   proto_tree          *lanman_tree = NULL, *flags_tree = NULL;
   proto_item          *ti;
   struct lanman_desc  *lanman;
+  guint32             string_offset;
 
   if (check_col(fd, COL_PROTOCOL))
     col_add_fstr(fd, COL_PROTOCOL, "LANMAN");
@@ -580,7 +593,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, ParameterCount, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, ParameterCount, FALSE);
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
 
        proto_tree_add_text(lanman_tree, NullTVB, loc_offset, 2, "Function Code: NetShareEnum");
@@ -653,7 +666,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, ParameterCount, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, ParameterCount, FALSE);
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
       
        proto_tree_add_text(lanman_tree, NullTVB, loc_offset, 2, "Function Code: NetServerEnum2");
@@ -749,7 +762,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, ParameterCount, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, ParameterCount, FALSE);
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
 
        if (lanman) {
@@ -838,7 +851,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
       
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + DataOffset, END_OF_FRAME, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + DataOffset, END_OF_FRAME, FALSE);
 
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
 
@@ -865,7 +878,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, END_OF_FRAME, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, END_OF_FRAME, FALSE);
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
       
        proto_tree_add_text(lanman_tree, NullTVB, loc_offset, 0, "Function Code: NetShareEnum");
@@ -953,13 +966,20 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
        if (tree) {
 
-         proto_tree_add_text(share, NullTVB, loc_offset, 2, "Share Type: %u", Flags);
+         proto_tree_add_text(share, NullTVB, loc_offset, 2, "Share Type: %s",
+               val_to_str(Flags, share_type_vals, "Unknown (%u)"));
 
        }
 
        loc_offset += 2;
 
-       Comment = pd + SMB_offset + DataOffset + (GWORD(pd, loc_offset) & 0xFFFF) - Convert;
+       /* XXX - should check whether all of the string is within the
+          frame. */
+       string_offset = SMB_offset + DataOffset + (GWORD(pd, loc_offset) & 0xFFFF) - Convert;
+       if (IS_DATA_IN_FRAME(string_offset))
+         Comment = pd + string_offset;
+       else
+         Comment = "<String goes past end of frame>";
 
        if (tree) {
 
@@ -983,7 +1003,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, END_OF_FRAME, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, END_OF_FRAME, FALSE);
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
       
        proto_tree_add_text(lanman_tree, NullTVB, loc_offset, 2, "Function Code: NetServerEnum2");
@@ -1108,7 +1128,13 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
          loc_offset += 4;
 
-         Comment = pd + SMB_offset + DataOffset + (GWORD(pd, loc_offset) & 0xFFFF) - Convert;
+         /* XXX - should check whether all of the string is within the
+            frame. */
+         string_offset = SMB_offset + DataOffset + (GWORD(pd, loc_offset) & 0xFFFF) - Convert;
+         if (IS_DATA_IN_FRAME(string_offset))
+           Comment = pd + string_offset;
+         else
+           Comment = "<String goes past end of frame>";
 
          if (tree) {
 
@@ -1140,7 +1166,7 @@ dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
 
       if (tree) {
 
-       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, END_OF_FRAME, NULL);
+       ti = proto_tree_add_item(parent, proto_smb_lanman, NullTVB, SMB_offset + ParameterOffset, END_OF_FRAME, FALSE);
        lanman_tree = proto_item_add_subtree(ti, ett_lanman);
        if (lanman) {
          proto_tree_add_text(lanman_tree, NullTVB, 0, 0, "%s Response", lanman -> lanman_name);