Put Unicode strings into the protocol tree with the appropriate protocol

tree item, not with hf_nt_str.  Get rid of hf_nt_str, as it's no longer
used.

Put ASCII strings into the protocol tree only once.

svn path=/trunk/; revision=6910
This commit is contained in:
Guy Harris 2003-01-11 08:22:39 +00:00
parent 84d0997526
commit 6e57154948
2 changed files with 14 additions and 51 deletions

View File

@ -2,7 +2,7 @@
* Routines for DCERPC over SMB packet disassembly
* Copyright 2001, Tim Potter <tpot@samba.org>
*
* $Id: packet-dcerpc-nt.c,v 1.52 2003/01/11 07:52:34 guy Exp $
* $Id: packet-dcerpc-nt.c,v 1.53 2003/01/11 08:22:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -87,7 +87,6 @@ char *fake_unicode(tvbuff_t *tvb, int offset, int len)
these variables can be found in packet-dcerpc-samr.c
*/
extern int hf_nt_str;
extern int hf_nt_str_len;
extern int hf_nt_str_off;
extern int hf_nt_str_max_len;
@ -97,34 +96,6 @@ extern int hf_nt_string_size;
gint ett_nt_unicode_string = -1;
static gint ett_nt_policy_hnd = -1;
/*
* This handles an array of Unicode characters.
*/
static int
dissect_ndr_ucodechars(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, char *drep _U_,
int hfindex, int length, char **text)
{
dcerpc_info *di;
di=pinfo->private_data;
if(di->conformant_run){
/* just a run to handle conformant arrays, no scalars to dissect */
return offset;
}
if (offset % 2)
offset++;
if (tree) {
*text = fake_unicode(tvb, offset, length);
proto_tree_add_string (tree, hfindex, tvb, offset, length * 2, *text);
} else
*text = NULL;
return offset + length * 2;
}
/* this function will dissect the
[size_is(size/2), length_is(len/2), ptr] unsigned short *string;
part of the unicode string
@ -145,7 +116,6 @@ dissect_ndr_nt_UNICODE_STRING_str(tvbuff_t *tvb, int offset,
char *drep)
{
guint32 len, off, max_len;
int old_offset;
dcerpc_info *di;
char *text;
@ -162,10 +132,16 @@ dissect_ndr_nt_UNICODE_STRING_str(tvbuff_t *tvb, int offset,
offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
hf_nt_str_len, &len);
old_offset=offset;
if (offset % 2)
offset++;
offset = dissect_ndr_ucodechars(
tvb, offset, pinfo, tree, drep, hf_nt_str, len, &text);
if (tree) {
text = fake_unicode(tvb, offset, len);
proto_tree_add_string (tree, di->hf_index, tvb, offset, len * 2, text);
} else
text = NULL;
offset += len * 2;
/* need to test di->levels before doing the proto_item_append_text()
since netlogon has these objects as top level objects in its representation
@ -257,7 +233,6 @@ dissect_ndr_nt_STRING_string (tvbuff_t *tvb, int offset,
{
guint32 len, off, max_len;
const guint8 *text;
int old_offset;
header_field_info *hfi;
dcerpc_info *di;
@ -274,28 +249,21 @@ dissect_ndr_nt_STRING_string (tvbuff_t *tvb, int offset,
offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
hf_nt_str_len, &len);
old_offset=offset;
hfi = proto_registrar_get_nth(di->hf_index);
switch(hfi->type){
case FT_STRING:
offset = dissect_ndr_uint8s(
tvb, offset, pinfo, tree, drep,
hf_nt_str, len, NULL);
text = tvb_get_ptr(tvb, offset - len * 2, len);
proto_tree_add_string_format(tree, di->hf_index,
tvb, old_offset, offset-old_offset,
text, "%s: %s", hfi->name, text);
text = tvb_get_ptr(tvb, offset, len);
break;
case FT_BYTES:
text = NULL;
proto_tree_add_item(tree, di->hf_index, tvb, offset, len, FALSE);
offset += len;
break;
default:
text = NULL;
g_assert_not_reached();
}
proto_tree_add_item(tree, di->hf_index, tvb, offset, len, FALSE);
offset += len;
if(tree && text && (di->levels>-1)){
proto_item_append_text(tree, ": %s", text);

View File

@ -3,7 +3,7 @@
* Copyright 2001, Tim Potter <tpot@samba.org>
* 2002 Added all command dissectors Ronnie Sahlberg
*
* $Id: packet-dcerpc-samr.c,v 1.65 2003/01/11 07:48:22 guy Exp $
* $Id: packet-dcerpc-samr.c,v 1.66 2003/01/11 08:22:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -129,7 +129,6 @@ static int hf_samr_unknown_string = -1;
static int hf_samr_unknown_time = -1;
/* these are used by functions in packet-dcerpc-nt.c */
int hf_nt_str = -1;
int hf_nt_str_len = -1;
int hf_nt_str_off = -1;
int hf_nt_str_max_len = -1;
@ -5202,10 +5201,6 @@ proto_register_dcerpc_samr(void)
{ "Size", "nt.string.size", FT_UINT16, BASE_DEC,
NULL, 0x0, "Size of string in bytes", HFILL }},
{ &hf_nt_str,
{ "String", "nt.str", FT_STRING, BASE_NONE,
NULL, 0x0, "String data", HFILL }},
{ &hf_nt_str_len,
{ "Length", "nt.str.len", FT_UINT32, BASE_DEC,
NULL, 0x0, "Length of string in short integers", HFILL }},