Ethereal-dev: [Ethereal-dev] packet-smb.c

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

From: "Pia Sahlberg" <piabar@xxxxxxxxxxx>
Date: Fri, 10 Aug 2001 01:13:43 +0000
Hi list
 
Attached is a small patch for packet-smb.c.
 
best regards
  ronnie sahlberg
 


Get your FREE download of MSN Explorer at http://explorer.msn.com
diff -u -r -x *.[^ch]|nmake|am ethereal-orig/packet-smb.c ethereal/packet-smb.c
--- ethereal-orig/packet-smb.c	Tue Aug  7 08:45:14 2001
+++ ethereal/packet-smb.c	Fri Aug 10 08:16:47 2001
@@ -53,7 +53,6 @@
#include "packet-smb-pipe.h"

static int proto_smb = -1;
-
static int hf_smb_cmd = -1;

static gint ett_smb = -1;
@@ -73,7 +72,7 @@
static gint ett_smb_action = -1;
static gint ett_smb_writemode = -1;
static gint ett_smb_lock_type = -1;
-
+static gint ett_smb_header = -1;


/*
@@ -191,6 +190,10 @@

static void (*dissect[256])(const u_char *, int, frame_data *, proto_tree *, proto_tree *, struct smb_info si, int, int, int);

+
+/* NOTEr: this value_string is accessed directly by index and not val_to_str().
+ * That means that ALL entries 0x00-0xFF MUST exists and be in order.
+ */
static const value_string smb_cmd_vals[] = {
  { 0x00, "SMBcreatedirectory" },
  { 0x01, "SMBdeletedirectory" },
@@ -451,265 +454,6 @@
  { 0x00, NULL },
};

-char *SMB_names[256] = {
-  "SMBcreatedirectory",
-  "SMBdeletedirectory",
-  "SMBopen",
-  "SMBcreate",
-  "SMBclose",
-  "SMBflush",
-  "SMBunlink",
-  "SMBmv",
-  "SMBgetatr",
-  "SMBsetatr",
-  "SMBread",
-  "SMBwrite",
-  "SMBlock",
-  "SMBunlock",
-  "SMBctemp",
-  "SMBmknew",
-  "SMBchkpth",
-  "SMBexit",
-  "SMBlseek",
-  "SMBlockread",
-  "SMBwriteunlock",
-  "unknown-0x15",
-  "unknown-0x16",
-  "unknown-0x17",
-  "unknown-0x18",
-  "unknown-0x19",
-  "SMBreadBraw",
-  "SMBreadBmpx",
-  "SMBreadBs",
-  "SMBwriteBraw",
-  "SMBwriteBmpx",
-  "SMBwriteBs",
-  "SMBwriteC",
-  "unknown-0x21",
-  "SMBsetattrE",
-  "SMBgetattrE",
-  "SMBlockingX",
-  "SMBtrans",
-  "SMBtranss",
-  "SMBioctl",
-  "SMBioctls",
-  "SMBcopy",
-  "SMBmove",
-  "SMBecho",
-  "SMBwriteclose",
-  "SMBopenX",
-  "SMBreadX",
-  "SMBwriteX",
-  "unknown-0x30",
-  "SMBcloseandtreedisc",
-  "SMBtrans2",
-  "SMBtrans2secondary",
-  "SMBfindclose2",
-  "SMBfindnotifyclose",
-  "unknown-0x36",
-  "unknown-0x37",
-  "unknown-0x38",
-  "unknown-0x39",
-  "unknown-0x3A",
-  "unknown-0x3B",
-  "unknown-0x3C",
-  "unknown-0x3D",
-  "unknown-0x3E",
-  "unknown-0x3F",
-  "unknown-0x40",
-  "unknown-0x41",
-  "unknown-0x42",
-  "unknown-0x43",
-  "unknown-0x44",
-  "unknown-0x45",
-  "unknown-0x46",
-  "unknown-0x47",
-  "unknown-0x48",
-  "unknown-0x49",
-  "unknown-0x4A",
-  "unknown-0x4B",
-  "unknown-0x4C",
-  "unknown-0x4D",
-  "unknown-0x4E",
-  "unknown-0x4F",
-  "unknown-0x50",
-  "unknown-0x51",
-  "unknown-0x52",
-  "unknown-0x53",
-  "unknown-0x54",
-  "unknown-0x55",
-  "unknown-0x56",
-  "unknown-0x57",
-  "unknown-0x58",
-  "unknown-0x59",
-  "unknown-0x5A",
-  "unknown-0x5B",
-  "unknown-0x5C",
-  "unknown-0x5D",
-  "unknown-0x5E",
-  "unknown-0x5F",
-  "unknown-0x60",
-  "unknown-0x61",
-  "unknown-0x62",
-  "unknown-0x63",
-  "unknown-0x64",
-  "unknown-0x65",
-  "unknown-0x66",
-  "unknown-0x67",
-  "unknown-0x68",
-  "unknown-0x69",
-  "unknown-0x6A",
-  "unknown-0x6B",
-  "unknown-0x6C",
-  "unknown-0x6D",
-  "unknown-0x6E",
-  "unknown-0x6F",
-  "SMBtcon",
-  "SMBtdis",
-  "SMBnegprot",
-  "SMBsesssetupX",
-  "SMBlogoffX",
-  "SMBtconX",
-  "unknown-0x76",
-  "unknown-0x77",
-  "unknown-0x78",
-  "unknown-0x79",
-  "unknown-0x7A",
-  "unknown-0x7B",
-  "unknown-0x7C",
-  "unknown-0x7D",
-  "unknown-0x7E",
-  "unknown-0x7F",
-  "SMBdskattr",
-  "SMBsearch",
-  "SMBffirst",
-  "SMBfunique",
-  "SMBfclose",
-  "unknown-0x85",
-  "unknown-0x86",
-  "unknown-0x87",
-  "unknown-0x88",
-  "unknown-0x89",
-  "unknown-0x8A",
-  "unknown-0x8B",
-  "unknown-0x8C",
-  "unknown-0x8D",
-  "unknown-0x8E",
-  "unknown-0x8F",
-  "unknown-0x90",
-  "unknown-0x91",
-  "unknown-0x92",
-  "unknown-0x93",
-  "unknown-0x94",
-  "unknown-0x95",
-  "unknown-0x96",
-  "unknown-0x97",
-  "unknown-0x98",
-  "unknown-0x99",
-  "unknown-0x9A",
-  "unknown-0x9B",
-  "unknown-0x9C",
-  "unknown-0x9D",
-  "unknown-0x9E",
-  "unknown-0x9F",
-  "SMBnttransact",
-  "SMBnttransactsecondary",
-  "SMBntcreateX",
-  "unknown-0xA3",
-  "SMBntcancel",
-  "unknown-0xA5",
-  "unknown-0xA6",
-  "unknown-0xA7",
-  "unknown-0xA8",
-  "unknown-0xA9",
-  "unknown-0xAA",
-  "unknown-0xAB",
-  "unknown-0xAC",
-  "unknown-0xAD",
-  "unknown-0xAE",
-  "unknown-0xAF",
-  "unknown-0xB0",
-  "unknown-0xB1",
-  "unknown-0xB2",
-  "unknown-0xB3",
-  "unknown-0xB4",
-  "unknown-0xB5",
-  "unknown-0xB6",
-  "unknown-0xB7",
-  "unknown-0xB8",
-  "unknown-0xB9",
-  "unknown-0xBA",
-  "unknown-0xBB",
-  "unknown-0xBC",
-  "unknown-0xBD",
-  "unknown-0xBE",
-  "unknown-0xBF",
-  "SMBsplopen",
-  "SMBsplwr",
-  "SMBsplclose",
-  "SMBsplretq",
-  "unknown-0xC4",
-  "unknown-0xC5",
-  "unknown-0xC6",
-  "unknown-0xC7",
-  "unknown-0xC8",
-  "unknown-0xC9",
-  "unknown-0xCA",
-  "unknown-0xCB",
-  "unknown-0xCC",
-  "unknown-0xCD",
-  "unknown-0xCE",
-  "unknown-0xCF",
-  "SMBsends",
-  "SMBsendb",
-  "SMBfwdname",
-  "SMBcancelf",
-  "SMBgetmac",
-  "SMBsendstrt",
-  "SMBsendend",
-  "SMBsendtxt",
-  "SMBreadbulk",
-  "SMBwritebulk",
-  "SMBwritebulkdata",
-  "unknown-0xDB",
-  "unknown-0xDC",
-  "unknown-0xDD",
-  "unknown-0xDE",
-  "unknown-0xDF",
-  "unknown-0xE0",
-  "unknown-0xE1",
-  "unknown-0xE2",
-  "unknown-0xE3",
-  "unknown-0xE4",
-  "unknown-0xE5",
-  "unknown-0xE6",
-  "unknown-0xE7",
-  "unknown-0xE8",
-  "unknown-0xE9",
-  "unknown-0xEA",
-  "unknown-0xEB",
-  "unknown-0xEC",
-  "unknown-0xED",
-  "unknown-0xEE",
-  "unknown-0xEF",
-  "unknown-0xF0",
-  "unknown-0xF1",
-  "unknown-0xF2",
-  "unknown-0xF3",
-  "unknown-0xF4",
-  "unknown-0xF5",
-  "unknown-0xF6",
-  "unknown-0xF7",
-  "unknown-0xF8",
-  "unknown-0xF9",
-  "unknown-0xFA",
-  "unknown-0xFB",
-  "unknown-0xFC",
-  "unknown-0xFD",
-  "SMBinvalid",
-  "unknown-0xFF"
-};
-
void
dissect_unknown_smb(const u_char *pd, int offset, frame_data *fd, proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data, int SMB_offset, int errcode)
{
@@ -10704,7 +10448,7 @@
char *decode_smb_name(unsigned char cmd)
{

-  return(SMB_names[cmd]);
+  return(smb_cmd_vals[cmd].strptr);

}

@@ -10891,7 +10635,7 @@

	if (tree) {

-	  proto_tree_add_uint(smb_tree, hf_smb_cmd, NullTVB, offset, 1, cmd);
+ proto_tree_add_uint_format(smb_tree, hf_smb_cmd, NullTVB, offset, 1, cmd, "SMB Command: %s (0x%02x)", decode_smb_name(cmd), cmd);

	}

@@ -11163,8 +10907,8 @@
{
	static hf_register_info hf[] = {
	  { &hf_smb_cmd,
-	    { "SMB Command", "smb.cmd",
-	      FT_UINT8, BASE_HEX, VALS(smb_cmd_vals), 0x0, "", HFILL }}
+	    { "SMB Command", "smb.cmd", FT_UINT8, BASE_HEX,
+	    NULL, 0x0, "SMB Command", HFILL }}
	};
	static gint *ett[] = {
		&ett_smb,