2001-11-27 09:27:29 +00:00
|
|
|
/* packet-dcerpc-ndr.c
|
|
|
|
* Routines for DCERPC NDR dissection
|
|
|
|
* Copyright 2001, Todd Sabin <tas@webspan.net>
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-11-27 09:27:29 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2001-11-27 09:27:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2001-11-27 09:27:29 +00:00
|
|
|
#include "packet-dcerpc.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The NDR routines are for use by dcerpc subdissetors. They're
|
|
|
|
* primarily for making sure things are aligned properly according
|
|
|
|
* to the rules of NDR.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint8 *pdata)
|
2001-11-27 09:27:29 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 09:27:29 +00:00
|
|
|
/* no alignment needed */
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_uint8(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, pdata);
|
2001-11-27 09:27:29 +00:00
|
|
|
}
|
|
|
|
|
2007-02-25 01:34:41 +00:00
|
|
|
int
|
2013-10-21 18:25:41 +00:00
|
|
|
PIDL_dissect_uint8_val(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param, guint8 *pval)
|
2007-02-25 01:34:41 +00:00
|
|
|
{
|
2012-05-15 20:57:21 +00:00
|
|
|
guint8 val;
|
2007-02-25 01:34:41 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* no alignment needed */
|
2012-05-15 20:57:21 +00:00
|
|
|
offset = dissect_dcerpc_uint8(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, &val);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (param&PIDL_SET_COL_INFO) {
|
2007-02-25 11:48:06 +00:00
|
|
|
header_field_info *hf_info;
|
|
|
|
char *valstr;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
hf_info = proto_registrar_get_nth(hfindex);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2013-09-13 10:13:19 +00:00
|
|
|
valstr = (char *)wmem_alloc(wmem_packet_scope(), 64);
|
2007-02-25 11:48:06 +00:00
|
|
|
valstr[0]=0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
switch (hf_info->display) {
|
2007-02-25 11:48:06 +00:00
|
|
|
case BASE_DEC:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(valstr, 64, "%d", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BASE_HEX:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(0x%02x)",val_to_str(val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(valstr, 64, "0x%02x", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
REPORT_DISSECTOR_BUG("Invalid hf->display value");
|
|
|
|
}
|
|
|
|
|
2013-10-01 13:02:12 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, valstr);
|
2007-02-25 11:48:06 +00:00
|
|
|
}
|
2013-10-21 18:25:41 +00:00
|
|
|
if (pval) {
|
|
|
|
*pval = val;
|
|
|
|
}
|
2007-02-25 11:48:06 +00:00
|
|
|
|
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
2013-10-21 18:25:41 +00:00
|
|
|
int
|
|
|
|
PIDL_dissect_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param)
|
|
|
|
{
|
2013-11-06 14:31:29 +00:00
|
|
|
return PIDL_dissect_uint8_val(tvb, offset, pinfo, tree, di, drep, hfindex, param, NULL);
|
2013-10-21 18:25:41 +00:00
|
|
|
}
|
|
|
|
|
2007-02-25 01:34:41 +00:00
|
|
|
|
2001-11-27 09:27:29 +00:00
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint16 *pdata)
|
2001-11-27 09:27:29 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 2)) {
|
2001-11-27 09:27:29 +00:00
|
|
|
offset++;
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_uint16(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, pdata);
|
2001-11-27 09:27:29 +00:00
|
|
|
}
|
|
|
|
|
2007-02-25 01:34:41 +00:00
|
|
|
int
|
2013-10-21 18:25:41 +00:00
|
|
|
PIDL_dissect_uint16_val(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param, guint16 *pval)
|
2007-02-25 01:34:41 +00:00
|
|
|
{
|
2012-05-15 20:57:21 +00:00
|
|
|
guint16 val;
|
2007-02-25 01:34:41 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 2)) {
|
2007-02-25 01:34:41 +00:00
|
|
|
offset++;
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
offset = dissect_dcerpc_uint16(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, &val);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (param&PIDL_SET_COL_INFO) {
|
2007-02-25 11:48:06 +00:00
|
|
|
header_field_info *hf_info;
|
|
|
|
char *valstr;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
hf_info = proto_registrar_get_nth(hfindex);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2013-09-13 10:13:19 +00:00
|
|
|
valstr = (char *)wmem_alloc(wmem_packet_scope(), 64);
|
2007-02-25 11:48:06 +00:00
|
|
|
valstr[0]=0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
switch (hf_info->display) {
|
2007-02-25 11:48:06 +00:00
|
|
|
case BASE_DEC:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(valstr, 64, "%d", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BASE_HEX:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(0x%04x)",val_to_str(val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(valstr, 64, "0x%04x", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
REPORT_DISSECTOR_BUG("Invalid hf->display value");
|
|
|
|
}
|
|
|
|
|
2013-10-01 13:02:12 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, valstr);
|
2007-02-25 11:48:06 +00:00
|
|
|
}
|
|
|
|
|
2013-10-21 18:25:41 +00:00
|
|
|
if (pval) {
|
|
|
|
*pval = val;
|
|
|
|
}
|
2007-02-25 11:48:06 +00:00
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
2013-10-21 18:25:41 +00:00
|
|
|
int
|
|
|
|
PIDL_dissect_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2016-04-15 17:20:20 +00:00
|
|
|
int hfindex, guint32 param)
|
2013-10-21 18:25:41 +00:00
|
|
|
{
|
2013-11-06 14:31:29 +00:00
|
|
|
return PIDL_dissect_uint16_val(tvb, offset, pinfo, tree, di, drep, hfindex, param, NULL);
|
2013-10-21 18:25:41 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 09:27:29 +00:00
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint32 *pdata)
|
2001-11-27 09:27:29 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2013-11-06 14:31:29 +00:00
|
|
|
if ((di != NULL) && (di->conformant_run)) {
|
2012-05-15 20:57:21 +00:00
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-06 14:31:29 +00:00
|
|
|
if ((di != NULL) && (!di->no_align) && (offset % 4)) {
|
2001-11-27 09:27:29 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_uint32(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, pdata);
|
2001-11-27 09:27:29 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 00:03:48 +00:00
|
|
|
/* This is used to dissect the new datatypes, such as pointers and conformance
|
|
|
|
data, which is 4 bytes in size in NDR but 8 bytes in NDR64.
|
|
|
|
*/
|
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uint3264(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint3264 *pdata)
|
2009-10-03 00:03:48 +00:00
|
|
|
{
|
|
|
|
if (di->call_data->flags & DCERPC_IS_NDR64) {
|
2013-11-06 14:31:29 +00:00
|
|
|
return dissect_ndr_uint64(tvb, offset, pinfo, tree, di, drep, hfindex, pdata);
|
2009-10-03 00:03:48 +00:00
|
|
|
} else {
|
2012-04-28 18:23:19 +00:00
|
|
|
guint32 val = 0;
|
2013-11-06 14:31:29 +00:00
|
|
|
offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hfindex, &val);
|
2009-10-03 08:26:32 +00:00
|
|
|
if (pdata) {
|
|
|
|
*pdata = val;
|
|
|
|
}
|
|
|
|
return offset;
|
2009-10-03 00:03:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-03 04:49:04 +00:00
|
|
|
/* This is used to dissect the new datatypes, such as enums
|
|
|
|
that are 2 bytes in size in NDR but 4 bytes in NDR64.
|
|
|
|
*/
|
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uint1632(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint1632 *pdata)
|
2009-10-03 04:49:04 +00:00
|
|
|
{
|
|
|
|
if (di->call_data->flags & DCERPC_IS_NDR64) {
|
2013-11-06 14:31:29 +00:00
|
|
|
return dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hfindex, pdata);
|
2009-10-03 04:49:04 +00:00
|
|
|
} else {
|
2012-04-28 18:23:19 +00:00
|
|
|
guint16 val = 0;
|
2013-11-06 14:31:29 +00:00
|
|
|
offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, di, drep, hfindex, &val);
|
2009-10-03 08:26:32 +00:00
|
|
|
if (pdata) {
|
|
|
|
*pdata = val;
|
|
|
|
}
|
|
|
|
return offset;
|
2009-10-03 04:49:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-25 01:34:41 +00:00
|
|
|
int
|
2013-10-21 18:25:41 +00:00
|
|
|
PIDL_dissect_uint32_val(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param, guint32 *rval)
|
2007-02-25 01:34:41 +00:00
|
|
|
{
|
2012-05-15 20:57:21 +00:00
|
|
|
guint32 val;
|
2007-02-25 01:34:41 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 4)) {
|
2007-02-25 01:34:41 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
offset = dissect_dcerpc_uint32(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, &val);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (param&PIDL_SET_COL_INFO) {
|
2007-02-25 11:48:06 +00:00
|
|
|
header_field_info *hf_info;
|
|
|
|
char *valstr;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
hf_info = proto_registrar_get_nth(hfindex);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2013-09-13 10:13:19 +00:00
|
|
|
valstr = (char *)wmem_alloc(wmem_packet_scope(), 64);
|
2007-02-25 11:48:06 +00:00
|
|
|
valstr[0]=0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
switch (hf_info->display) {
|
2007-02-25 11:48:06 +00:00
|
|
|
case BASE_DEC:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(valstr, 64, "%d", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BASE_HEX:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(0x%08x)",val_to_str(val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(valstr, 64, "0x%08x", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
REPORT_DISSECTOR_BUG("Invalid hf->display value");
|
|
|
|
}
|
|
|
|
|
2013-10-01 13:02:12 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, valstr);
|
2007-02-25 11:48:06 +00:00
|
|
|
}
|
2013-10-21 18:25:41 +00:00
|
|
|
if (rval != NULL) {
|
|
|
|
*rval = val;
|
|
|
|
}
|
2007-02-25 11:48:06 +00:00
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
2013-10-21 18:25:41 +00:00
|
|
|
int
|
|
|
|
PIDL_dissect_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param)
|
|
|
|
{
|
2013-11-06 14:31:29 +00:00
|
|
|
return PIDL_dissect_uint32_val(tvb, offset, pinfo, tree, di, drep, hfindex, param, NULL);
|
2013-10-21 18:25:41 +00:00
|
|
|
}
|
|
|
|
|
2005-01-28 09:29:49 +00:00
|
|
|
/* Double uint32
|
|
|
|
This function dissects the 64bit datatype that is common for
|
|
|
|
ms interfaces and which is 32bit aligned.
|
|
|
|
It is really just 2 uint32's
|
|
|
|
*/
|
2002-01-29 09:13:28 +00:00
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_duint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2005-01-29 20:39:14 +00:00
|
|
|
int hfindex, guint64 *pdata)
|
2002-01-29 09:13:28 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 4)) {
|
2002-01-29 09:13:28 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_uint64(tvb, offset, pinfo,
|
2014-09-19 02:40:49 +00:00
|
|
|
tree, di, drep, hfindex, pdata);
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
2005-01-28 09:37:47 +00:00
|
|
|
/* uint64 : hyper
|
|
|
|
a 64 bit integer aligned to proper 8 byte boundaries
|
|
|
|
*/
|
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uint64(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint64 *pdata)
|
2005-01-28 09:37:47 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2005-01-28 09:37:47 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 8)) {
|
2012-09-01 11:22:29 +00:00
|
|
|
gint padding = 8 - (offset % 8);
|
2015-05-31 15:45:36 +00:00
|
|
|
proto_tree_add_item(tree, hf_dcerpc_ndr_padding, tvb, offset, padding, ENC_NA);
|
2013-10-21 15:46:13 +00:00
|
|
|
offset += padding;
|
2005-01-28 09:37:47 +00:00
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_uint64(tvb, offset, pinfo,
|
2014-09-19 02:40:49 +00:00
|
|
|
tree, di, drep, hfindex, pdata);
|
2005-01-28 09:37:47 +00:00
|
|
|
}
|
2002-09-03 08:39:16 +00:00
|
|
|
|
2007-02-25 01:34:41 +00:00
|
|
|
int
|
2013-10-21 18:25:41 +00:00
|
|
|
PIDL_dissect_uint64_val(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param, guint64 *pval)
|
2007-02-25 01:34:41 +00:00
|
|
|
{
|
2012-05-15 20:57:21 +00:00
|
|
|
guint64 val;
|
2007-02-25 01:34:41 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 8)) {
|
2007-02-25 01:34:41 +00:00
|
|
|
offset += 8 - (offset % 8);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
offset = dissect_dcerpc_uint64(tvb, offset, pinfo,
|
2014-09-19 02:40:49 +00:00
|
|
|
tree, di, drep, hfindex, &val);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (param&PIDL_SET_COL_INFO) {
|
2007-02-25 11:48:06 +00:00
|
|
|
header_field_info *hf_info;
|
|
|
|
char *valstr;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
hf_info = proto_registrar_get_nth(hfindex);
|
2007-02-25 11:48:06 +00:00
|
|
|
|
2013-09-13 10:13:19 +00:00
|
|
|
valstr = (char *)wmem_alloc(wmem_packet_scope(), 64);
|
2007-02-25 11:48:06 +00:00
|
|
|
valstr[0]=0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
switch (hf_info->display) {
|
2007-02-25 11:48:06 +00:00
|
|
|
case BASE_DEC:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(%" G_GINT64_MODIFIER "u)",val_to_str( (guint32) val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
2007-05-29 18:52:42 +00:00
|
|
|
g_snprintf(valstr, 64, "%" G_GINT64_MODIFIER "u", val);
|
2007-02-25 11:48:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BASE_HEX:
|
2012-05-15 20:57:21 +00:00
|
|
|
if (hf_info->strings) {
|
2013-03-02 22:54:39 +00:00
|
|
|
g_snprintf(valstr, 64, "%s(0x%" G_GINT64_MODIFIER "x)",val_to_str( (guint32) val, (const value_string *)hf_info->strings, "Unknown:%u"), val);
|
2007-02-25 11:48:06 +00:00
|
|
|
} else {
|
2007-05-29 18:52:42 +00:00
|
|
|
g_snprintf(valstr, 64, "0x%" G_GINT64_MODIFIER "x", val);
|
2007-02-25 11:48:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
REPORT_DISSECTOR_BUG("Invalid hf->display value");
|
|
|
|
}
|
|
|
|
|
2013-10-01 13:02:12 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, valstr);
|
2007-02-25 11:48:06 +00:00
|
|
|
}
|
|
|
|
|
2013-10-21 18:25:41 +00:00
|
|
|
if (pval) {
|
|
|
|
*pval = val;
|
|
|
|
}
|
2007-02-25 11:48:06 +00:00
|
|
|
return offset;
|
2007-02-25 01:34:41 +00:00
|
|
|
}
|
|
|
|
|
2013-10-21 18:25:41 +00:00
|
|
|
int
|
|
|
|
PIDL_dissect_uint64(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2013-10-21 18:25:41 +00:00
|
|
|
int hfindex, guint32 param)
|
|
|
|
{
|
2013-11-06 14:31:29 +00:00
|
|
|
return PIDL_dissect_uint64_val(tvb, offset, pinfo, tree, di, drep, hfindex, param, NULL);
|
2013-10-21 18:25:41 +00:00
|
|
|
}
|
|
|
|
|
2002-09-03 08:39:16 +00:00
|
|
|
int
|
|
|
|
dissect_ndr_float(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, gfloat *pdata)
|
2002-09-03 08:39:16 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2002-09-03 08:39:16 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-09-03 08:39:16 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 4)) {
|
2002-09-03 08:39:16 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2009-10-03 08:26:32 +00:00
|
|
|
return dissect_dcerpc_float(tvb, offset, pinfo,
|
2012-05-15 20:57:21 +00:00
|
|
|
tree, drep, hfindex, pdata);
|
2002-09-03 08:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
dissect_ndr_double(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, gdouble *pdata)
|
2002-09-03 08:39:16 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
2002-09-03 08:39:16 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-09-03 08:39:16 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 8)) {
|
2002-09-03 08:39:16 +00:00
|
|
|
offset += 8 - (offset % 8);
|
|
|
|
}
|
2009-10-03 08:26:32 +00:00
|
|
|
return dissect_dcerpc_double(tvb, offset, pinfo,
|
2012-05-15 20:57:21 +00:00
|
|
|
tree, drep, hfindex, pdata);
|
2002-09-03 08:39:16 +00:00
|
|
|
}
|
|
|
|
|
2002-09-26 06:13:08 +00:00
|
|
|
/* handles unix 32 bit time_t */
|
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_time_t(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, guint32 *pdata)
|
2002-09-26 06:13:08 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
*pdata = 0;
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-09-26 06:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 4)) {
|
2002-09-26 06:13:08 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_time_t(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, pdata);
|
2002-09-26 06:13:08 +00:00
|
|
|
}
|
2002-09-03 08:39:16 +00:00
|
|
|
|
2001-11-27 09:27:29 +00:00
|
|
|
int
|
2012-05-15 20:57:21 +00:00
|
|
|
dissect_ndr_uuid_t(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2015-03-03 10:47:53 +00:00
|
|
|
int hfindex, e_guid_t *pdata)
|
2001-11-27 09:27:29 +00:00
|
|
|
{
|
2013-06-28 23:54:53 +00:00
|
|
|
/* Some callers expect us to initialize pdata, even in error conditions, so
|
|
|
|
* do it right away in case we forget later */
|
|
|
|
if (pdata)
|
|
|
|
memset(pdata, 0, sizeof(*pdata));
|
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
2001-11-27 09:27:29 +00:00
|
|
|
|
|
|
|
/* uuid's are aligned to 4 bytes, due to initial uint32 in struct */
|
2010-01-20 06:02:42 +00:00
|
|
|
if (!di->no_align && (offset % 4)) {
|
2001-11-27 09:27:29 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
return dissect_dcerpc_uuid_t(tvb, offset, pinfo,
|
|
|
|
tree, drep, hfindex, pdata);
|
2001-11-27 09:27:29 +00:00
|
|
|
}
|
|
|
|
|
2003-11-21 02:48:11 +00:00
|
|
|
/*
|
|
|
|
* XXX - at least according to the DCE RPC 1.1 "nbase.idl", an
|
|
|
|
* "ndr_context_handle" is an unsigned32 "context_handle_attributes"
|
|
|
|
* and a uuid_t "context_handle_uuid". The attributes do not appear to
|
|
|
|
* be used, and always appear to be set to 0, in the DCE RPC 1.1 code.
|
|
|
|
*
|
|
|
|
* Should we display an "ndr_context_handle" with a tree holding the
|
|
|
|
* attributes and the uuid_t?
|
|
|
|
*/
|
2001-12-06 23:30:36 +00:00
|
|
|
int
|
2013-11-06 15:46:36 +00:00
|
|
|
dissect_ndr_ctx_hnd(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
|
2013-11-06 14:31:29 +00:00
|
|
|
proto_tree *tree, dcerpc_info *di, guint8 *drep,
|
2012-05-15 20:57:21 +00:00
|
|
|
int hfindex, e_ctx_hnd *pdata)
|
2001-12-06 23:30:36 +00:00
|
|
|
{
|
2002-05-27 09:50:58 +00:00
|
|
|
static e_ctx_hnd ctx_hnd;
|
2002-01-29 09:13:28 +00:00
|
|
|
|
2012-05-15 20:57:21 +00:00
|
|
|
if (di->conformant_run) {
|
|
|
|
/* just a run to handle conformant arrays, no scalars to dissect */
|
|
|
|
return offset;
|
2002-01-29 09:13:28 +00:00
|
|
|
}
|
2001-12-06 23:30:36 +00:00
|
|
|
|
2015-03-17 07:43:15 +00:00
|
|
|
if (!di->no_align && (offset % 4)) {
|
2001-12-06 23:30:36 +00:00
|
|
|
offset += 4 - (offset % 4);
|
|
|
|
}
|
2012-05-15 20:57:21 +00:00
|
|
|
ctx_hnd.attributes = dcerpc_tvb_get_ntohl(tvb, offset, drep);
|
|
|
|
dcerpc_tvb_get_uuid(tvb, offset+4, drep, &ctx_hnd.uuid);
|
2001-12-06 23:30:36 +00:00
|
|
|
if (tree) {
|
2003-11-21 02:48:11 +00:00
|
|
|
/* Bytes is bytes - don't worry about the data representation */
|
2012-05-15 20:57:21 +00:00
|
|
|
proto_tree_add_item(tree, hfindex, tvb, offset, 20, ENC_NA);
|
2001-12-06 23:30:36 +00:00
|
|
|
}
|
|
|
|
if (pdata) {
|
|
|
|
*pdata = ctx_hnd;
|
|
|
|
}
|
|
|
|
return offset + 20;
|
|
|
|
}
|
2014-09-28 23:25:09 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2014-09-28 23:25:09 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|