* significant rewrite to tvbuffify the dissector, Ronnie Sahlberg and
* Guy Harris 2001
*
- * $Id: packet-smb-pipe.c,v 1.48 2001/11/19 12:34:51 guy Exp $
+ * $Id: packet-smb-pipe.c,v 1.49 2001/11/20 06:24:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
proto_tree *pipe_tree = NULL;
int offset;
int function;
- guint16 fid = 0;
+ int fid = -1;
int len;
if (!proto_is_protocol_enabled(proto_smb_pipe))
smb_info->request ? "Request" : "Response");
}
+ if (smb_info->sip != NULL)
+ tri = smb_info->sip->extra_info;
+ else
+ tri = NULL;
+
/*
* Set up a subtree for the pipe data, if there is any.
*/
- if (s_tvb != NULL || tvb_length(sp_tvb) != 0) {
+ if (s_tvb != NULL || tvb_length(sp_tvb) != 0 ||
+ (tri != NULL && tri->function != -1)) {
if (tree) {
pipe_item = proto_tree_add_item(tree, proto_smb_pipe,
sp_tvb, 0, tvb_length(sp_tvb), FALSE);
val_to_str(function, functions, "Unknown function (0x%04x)"),
smb_info->request ? "Request" : "Response");
}
+ if (tri != NULL)
+ tri->function = function;
/*
* The second of them depends on the function.
* It's a priority.
*/
proto_tree_add_item(pipe_tree, hf_pipe_priority, s_tvb,
- 2, 2, TRUE);
+ offset, 2, TRUE);
break;
case PEEK_NM_PIPE:
* It's a FID.
*/
fid = tvb_get_letohs(s_tvb, 2);
- add_fid(s_tvb, pinfo, pipe_tree, 2, fid);
+ add_fid(s_tvb, pinfo, pipe_tree, offset, 2, fid);
+ if (tri != NULL)
+ tri->fid = fid;
+ break;
+
+ default:
+ /*
+ * It's something unknown.
+ * XXX - put it into the tree?
+ */
break;
}
offset += 2;
* In the latter case, we could get that information from
* the matching request, if we saw it. (XXX - do that.)
*/
- function = -1;
- fid = 0;
+ if (tri != NULL && tri->function != -1) {
+ function = tri->function;
+ proto_tree_add_uint(pipe_tree, hf_pipe_function, sp_tvb,
+ 0, 0, function);
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_add_fstr(pinfo->fd, COL_INFO, "%s %s",
+ val_to_str(function, functions, "Unknown function (0x%04x)"),
+ smb_info->request ? "Request" : "Response");
+ }
+ fid = tri->fid;
+ if (fid != -1)
+ add_fid(sp_tvb, pinfo, pipe_tree, 0, 0, fid);
+ } else {
+ function = -1;
+ fid = -1;
+ }
}
/*
* that requires us to fetch a possibly-Unicode string.
*/
- if (smb_info->sip != NULL)
- tri = smb_info->sip->extra_info;
- else
- tri = NULL;
if(smb_info->request){
if(strncmp(pipe,"LANMAN",6) == 0){
tri->trans_subcmd=PIPE_LANMAN;
switch (function) {
- case -1:
case CALL_NM_PIPE:
case TRANSACT_NM_PIPE:
switch(tri->trans_subcmd){
+
case PIPE_LANMAN:
return dissect_pipe_lanman(pd_tvb, p_tvb, d_tvb, pinfo,
tree);
break;
+
case PIPE_MSRPC:
- return dissect_pipe_msrpc(d_tvb, pinfo, tree, fid);
+ /*
+ * Only dissect this if we know the FID.
+ */
+ if (fid != -1) {
+ return dissect_pipe_msrpc(d_tvb, pinfo, tree,
+ fid);
+ }
+ break;
+ }
+ break;
+
+ case -1:
+ /*
+ * We don't know the function; we dissect only LANMAN
+ * pipe messages, not RPC pipe messages, in that case.
+ */
+ switch(tri->trans_subcmd){
+ case PIPE_LANMAN:
+ return dissect_pipe_lanman(pd_tvb, p_tvb, d_tvb, pinfo,
+ tree);
break;
}
break;
* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-smb.c,v 1.160 2001/11/19 11:41:51 guy Exp $
+ * $Id: packet-smb.c,v 1.161 2001/11/20 06:24:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
void
add_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
- guint16 fid)
+ int len, guint16 fid)
{
- proto_tree_add_uint(tree, hf_smb_fid, tvb, offset, 2, fid);
+ proto_tree_add_uint(tree, hf_smb_fid, tvb, offset, len, fid);
if (check_col(pinfo->fd, COL_INFO))
col_append_fstr(pinfo->fd, COL_INFO, ", FID: 0x%04x", fid);
}
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
/* File Attributes */
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
BYTE_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
BYTE_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
/* File Attributes */
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
/* create action */
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
/* create action */
*/
tri = g_mem_chunk_alloc(smb_transact_info_chunk);
tri->subcmd = -1;
+ tri->trans_subcmd = -1;
+ tri->function = -1;
+ tri->fid = -1;
tri->lanman_cmd = 0;
tri->param_descrip = NULL;
tri->data_descrip = NULL;
case 0x00: /*TRANS2_OPEN2*/
/* fid */
fid = tvb_get_letohs(tvb, offset);
- add_fid(tvb, pinfo, tree, offset, fid);
+ add_fid(tvb, pinfo, tree, offset, 2, fid);
offset += 2;
/* File Attributes */
* Defines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: smb.h,v 1.23 2001/11/19 10:06:42 guy Exp $
+ * $Id: smb.h,v 1.24 2001/11/20 06:24:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
typedef struct {
int subcmd;
int trans_subcmd;
+ int function;
+ int fid;
guint16 lanman_cmd;
guchar *param_descrip; /* Keep these descriptors around */
guchar *data_descrip;
* Add a FID to the protocol tree and the Info column.
*/
extern void add_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- int offset, guint16 fid);
+ int offset, int len, guint16 fid);
#endif