Not all strings in MS interfaces are unicode.

Rename cb_str_postprocess which handles unicode strings to cb_wstr_postprocess.

Add cb_str_postprocess which handles ASCII strings

svn path=/trunk/; revision=7572
This commit is contained in:
Ronnie Sahlberg 2003-04-27 00:49:14 +00:00
parent 6df423d0be
commit bca3332efd
7 changed files with 82 additions and 20 deletions

View File

@ -3,7 +3,7 @@
* Copyright 2001,2003 Tim Potter <tpot@samba.org>
* 2002 Added LSA command dissectors Ronnie Sahlberg
*
* $Id: packet-dcerpc-lsa.c,v 1.73 2003/04/03 05:43:58 tpot Exp $
* $Id: packet-dcerpc-lsa.c,v 1.74 2003/04/27 00:49:13 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -598,7 +598,7 @@ lsa_dissect_lsaopenpolicy2_rqst(tvbuff_t *tvb, int offset,
{
offset = dissect_ndr_pointer_cb(tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE, "Server",
hf_lsa_server, cb_str_postprocess,
hf_lsa_server, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | CB_STR_SAVE | 1));
offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
@ -2719,7 +2719,7 @@ lsa_dissect_lsaopensecret_rqst(tvbuff_t *tvb, int offset,
/* [in, ref] LSA_UNICODE_STRING *name */
offset = dissect_ndr_counted_string_cb(
tvb, offset, pinfo, tree, drep, hf_lsa_name,
cb_str_postprocess,
cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | 1));
/* [in] ACCESS_MASK access */

View File

@ -3,7 +3,7 @@
* Copyright 2001,2003 Tim Potter <tpot@samba.org>
* 2002 structure and command dissectors by Ronnie Sahlberg
*
* $Id: packet-dcerpc-netlogon.c,v 1.76 2003/02/14 06:17:20 tpot Exp $
* $Id: packet-dcerpc-netlogon.c,v 1.77 2003/04/27 00:49:13 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1403,7 +1403,7 @@ netlogon_dissect_netserverreqchallenge_rqst(tvbuff_t *tvb, int offset,
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_REF,
"Computer Name", hf_netlogon_computer_name,
cb_str_postprocess,
cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | 1));
offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
@ -3807,7 +3807,7 @@ netlogon_dissect_netserverauthenticate2_rqst(tvbuff_t *tvb, int offset,
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_REF,
"User Name", hf_netlogon_acct_name,
cb_str_postprocess, GINT_TO_POINTER(CB_STR_COL_INFO | 1));
cb_wstr_postprocess, GINT_TO_POINTER(CB_STR_COL_INFO | 1));
offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
pinfo, tree, drep);

View File

@ -2,7 +2,7 @@
* Routines for DCERPC over SMB packet disassembly
* Copyright 2001-2003, Tim Potter <tpot@samba.org>
*
* $Id: packet-dcerpc-nt.c,v 1.70 2003/04/27 00:34:27 guy Exp $
* $Id: packet-dcerpc-nt.c,v 1.71 2003/04/27 00:49:13 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -114,7 +114,7 @@ dissect_ndr_counted_string_helper(tvbuff_t *tvb, int offset,
*/
return dissect_ndr_counted_string_cb(
tvb, offset, pinfo, subtree, drep, hf_index,
cb_str_postprocess, GINT_TO_POINTER(2 + levels));
cb_wstr_postprocess, GINT_TO_POINTER(2 + levels));
}
/* Dissect a counted string in-line. */
@ -663,7 +663,7 @@ dissect_ndr_uint16s(tvbuff_t *tvb, gint offset, packet_info *pinfo,
* Helper routines for dissecting NDR strings
*/
void cb_str_postprocess(packet_info *pinfo, proto_tree *tree _U_,
void cb_wstr_postprocess(packet_info *pinfo, proto_tree *tree _U_,
proto_item *item, tvbuff_t *tvb,
int start_offset, int end_offset,
void *callback_args)
@ -723,6 +723,64 @@ void cb_str_postprocess(packet_info *pinfo, proto_tree *tree _U_,
g_free(s);
}
void cb_str_postprocess(packet_info *pinfo, proto_tree *tree _U_,
proto_item *item, tvbuff_t *tvb,
int start_offset, int end_offset,
void *callback_args)
{
gint options = GPOINTER_TO_INT(callback_args);
gint levels = CB_STR_ITEM_LEVELS(options);
char *s;
/* Align start_offset on 4-byte boundary. */
if (start_offset % 4)
start_offset += 4 - (start_offset % 4);
/* Get string value */
if ((end_offset - start_offset) <= 12)
return; /* XXX: Use unistr2 dissector instead? */
s = tvb_get_ptr(tvb, start_offset + 12, (end_offset - start_offset - 12) );
/* Append string to COL_INFO */
if (options & CB_STR_COL_INFO) {
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
}
/* Append string to upper-level proto_items */
if (levels > 0 && item && s && s[0]) {
proto_item_append_text(item, ": %s", s);
item = item->parent;
levels--;
if (levels > 0) {
proto_item_append_text(item, ": %s", s);
item = item->parent;
levels--;
while (levels > 0) {
proto_item_append_text(item, " %s", s);
item = item->parent;
levels--;
}
}
}
/* Save string to dcv->private_data */
if (options & CB_STR_SAVE) {
dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data;
dcv->private_data = g_strdup(s);
}
g_free(s);
}
/* Dissect a pointer to a NDR string and append the string value to the
proto_item. */
@ -734,7 +792,7 @@ int dissect_ndr_str_pointer_item(tvbuff_t *tvb, gint offset,
return dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, type, text, hf_index,
cb_str_postprocess, GINT_TO_POINTER(levels + 1));
cb_wstr_postprocess, GINT_TO_POINTER(levels + 1));
}
/*

View File

@ -2,7 +2,7 @@
* Routines for DCERPC over SMB packet disassembly
* Copyright 2001-2003 Tim Potter <tpot@samba.org>
*
* $Id: packet-dcerpc-nt.h,v 1.41 2003/02/08 09:41:44 guy Exp $
* $Id: packet-dcerpc-nt.h,v 1.42 2003/04/27 00:49:13 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -185,6 +185,10 @@ int dissect_ndr_str_pointer_item(tvbuff_t *tvb, gint offset,
#define CB_STR_COL_INFO 0x10000 /* Append string to COL_INFO */
#define CB_STR_SAVE 0x20000 /* Save string to dcv->private_data */
void cb_wstr_postprocess(packet_info *pinfo, proto_tree *tree _U_,
proto_item *item, tvbuff_t *tvb,
int start_offset, int end_offset,
void *callback_args);
void cb_str_postprocess(packet_info *pinfo, proto_tree *tree _U_,
proto_item *item, tvbuff_t *tvb,
int start_offset, int end_offset,

View File

@ -3,7 +3,7 @@
* Copyright 2001,2003 Tim Potter <tpot@samba.org>
* 2002 Added all command dissectors Ronnie Sahlberg
*
* $Id: packet-dcerpc-samr.c,v 1.83 2003/04/03 05:43:58 tpot Exp $
* $Id: packet-dcerpc-samr.c,v 1.84 2003/04/27 00:49:13 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1135,7 +1135,7 @@ samr_dissect_connect2_rqst(tvbuff_t *tvb, int offset,
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE,
"Server", hf_samr_server, cb_str_postprocess,
"Server", hf_samr_server, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | CB_STR_SAVE | 1));
offset = dissect_nt_access_mask(
@ -1153,7 +1153,7 @@ samr_dissect_connect4_rqst(tvbuff_t *tvb, int offset,
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE,
"Server", hf_samr_server, cb_str_postprocess,
"Server", hf_samr_server, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | 1));
offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,

View File

@ -2,7 +2,7 @@
* Routines for SMB \PIPE\spoolss packet disassembly
* Copyright 2001-2003, Tim Potter <tpot@samba.org>
*
* $Id: packet-dcerpc-spoolss.c,v 1.95 2003/04/15 08:11:33 guy Exp $
* $Id: packet-dcerpc-spoolss.c,v 1.96 2003/04/27 00:49:14 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -2465,7 +2465,7 @@ static int SpoolssOpenPrinterEx_q(tvbuff_t *tvb, int offset,
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE,
"Printer name", hf_printername, cb_str_postprocess,
"Printer name", hf_printername, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | CB_STR_SAVE | 1));
offset = dissect_ndr_pointer(

View File

@ -9,7 +9,7 @@
* 2002, some share information levels implemented based on samba
* sources.
*
* $Id: packet-dcerpc-srvsvc.c,v 1.54 2003/04/26 00:44:20 sharpe Exp $
* $Id: packet-dcerpc-srvsvc.c,v 1.55 2003/04/27 00:49:14 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -2948,13 +2948,13 @@ srvsvc_dissect_netrsharegetinfo_rqst(tvbuff_t *tvb, int offset,
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE,
"Server", hf_srvsvc_server, cb_str_postprocess,
"Server", hf_srvsvc_server, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | 1));
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_REF,
"Share", hf_srvsvc_share, cb_str_postprocess,
"Share", hf_srvsvc_share, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | 1));
offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
@ -5295,7 +5295,7 @@ srvsvc_dissect_netrservergetinfo_rqst(tvbuff_t *tvb, int offset,
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep,
dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE,
"Server", hf_srvsvc_server, cb_str_postprocess,
"Server", hf_srvsvc_server, cb_wstr_postprocess,
GINT_TO_POINTER(CB_STR_COL_INFO | 1));
offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,