aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dcerpc-ndr.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2012-05-15 20:57:21 +0000
committerBill Meier <wmeier@newsguy.com>2012-05-15 20:57:21 +0000
commitb869cb0bc51176db6ad0574d108481b4d250bef0 (patch)
tree175747de48a842a87136f7b1001a67e21c883d0e /epan/dissectors/packet-dcerpc-ndr.c
parentd5aa739fd0f9ca60faa7134ee3d99fb124b1b8e3 (diff)
Remove unneeded includes (ctype.h, stdio.h);
In one case, define our own size for a string buffer (instead of using a magic constant 'BUFSIZ'); In a few cases: do some whitespace, indentation & reformatting cleanup. svn path=/trunk/; revision=42634
Diffstat (limited to 'epan/dissectors/packet-dcerpc-ndr.c')
-rw-r--r--epan/dissectors/packet-dcerpc-ndr.c301
1 files changed, 150 insertions, 151 deletions
diff --git a/epan/dissectors/packet-dcerpc-ndr.c b/epan/dissectors/packet-dcerpc-ndr.c
index e82d251094..16996e469f 100644
--- a/epan/dissectors/packet-dcerpc-ndr.c
+++ b/epan/dissectors/packet-dcerpc-ndr.c
@@ -27,9 +27,8 @@
#include "config.h"
#endif
-#include <ctype.h>
-
#include <glib.h>
+
#include <epan/packet.h>
#include <epan/emem.h>
#include "packet-dcerpc.h"
@@ -42,60 +41,60 @@
*/
int
-dissect_ndr_uint8 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint8 *pdata)
+dissect_ndr_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint8 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
/* no alignment needed */
- return dissect_dcerpc_uint8 (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_uint8(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
int
-PIDL_dissect_uint8 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
+PIDL_dissect_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
int hfindex, guint32 param _U_)
{
dcerpc_info *di;
- guint8 val;
+ guint8 val;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
/* no alignment needed */
- offset=dissect_dcerpc_uint8 (tvb, offset, pinfo,
- tree, drep, hfindex, &val);
+ offset = dissect_dcerpc_uint8(tvb, offset, pinfo,
+ tree, drep, hfindex, &val);
- if(param&PIDL_SET_COL_INFO){
+ if (param&PIDL_SET_COL_INFO) {
header_field_info *hf_info;
char *valstr;
- hf_info=proto_registrar_get_nth(hfindex);
+ hf_info = proto_registrar_get_nth(hfindex);
- valstr=ep_alloc(64);
+ valstr = ep_alloc(64);
valstr[0]=0;
- switch(hf_info->display){
+ switch (hf_info->display) {
case BASE_DEC:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "%d", val);
}
break;
case BASE_HEX:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(0x%02x)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "0x%02x", val);
@@ -115,66 +114,66 @@ PIDL_dissect_uint8 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
int
-dissect_ndr_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint16 *pdata)
+dissect_ndr_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint16 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 2)) {
offset++;
}
- return dissect_dcerpc_uint16 (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_uint16(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
int
-PIDL_dissect_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
+PIDL_dissect_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
int hfindex, guint32 param _U_)
{
dcerpc_info *di;
- guint16 val;
+ guint16 val;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 2)) {
offset++;
}
- offset=dissect_dcerpc_uint16 (tvb, offset, pinfo,
- tree, drep, hfindex, &val);
+ offset = dissect_dcerpc_uint16(tvb, offset, pinfo,
+ tree, drep, hfindex, &val);
- if(param&PIDL_SET_COL_INFO){
+ if (param&PIDL_SET_COL_INFO) {
header_field_info *hf_info;
char *valstr;
- hf_info=proto_registrar_get_nth(hfindex);
+ hf_info = proto_registrar_get_nth(hfindex);
- valstr=ep_alloc(64);
+ valstr = ep_alloc(64);
valstr[0]=0;
- switch(hf_info->display){
+ switch (hf_info->display) {
case BASE_DEC:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "%d", val);
}
break;
case BASE_HEX:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(0x%04x)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "0x%04x", val);
@@ -193,37 +192,37 @@ PIDL_dissect_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
int
-dissect_ndr_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint32 *pdata)
+dissect_ndr_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint32 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
- return dissect_dcerpc_uint32 (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_uint32(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
/* 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
-dissect_ndr_uint3264 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint3264 *pdata)
+dissect_ndr_uint3264(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint3264 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
+ di = pinfo->private_data;
if (di->call_data->flags & DCERPC_IS_NDR64) {
return dissect_ndr_uint64(tvb, offset, pinfo, tree, drep, hfindex, pdata);
@@ -241,13 +240,13 @@ dissect_ndr_uint3264 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
that are 2 bytes in size in NDR but 4 bytes in NDR64.
*/
int
-dissect_ndr_uint1632 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint1632 *pdata)
+dissect_ndr_uint1632(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint1632 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
+ di = pinfo->private_data;
if (di->call_data->flags & DCERPC_IS_NDR64) {
return dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hfindex, pdata);
@@ -262,45 +261,45 @@ dissect_ndr_uint1632 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
int
-PIDL_dissect_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
+PIDL_dissect_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
int hfindex, guint32 param)
{
dcerpc_info *di;
- guint32 val;
+ guint32 val;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
- offset=dissect_dcerpc_uint32 (tvb, offset, pinfo,
- tree, drep, hfindex, &val);
+ offset = dissect_dcerpc_uint32(tvb, offset, pinfo,
+ tree, drep, hfindex, &val);
- if(param&PIDL_SET_COL_INFO){
+ if (param&PIDL_SET_COL_INFO) {
header_field_info *hf_info;
char *valstr;
- hf_info=proto_registrar_get_nth(hfindex);
+ hf_info = proto_registrar_get_nth(hfindex);
- valstr=ep_alloc(64);
+ valstr = ep_alloc(64);
valstr[0]=0;
- switch(hf_info->display){
+ switch (hf_info->display) {
case BASE_DEC:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "%d", val);
}
break;
case BASE_HEX:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(0x%08x)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "0x%08x", val);
@@ -324,87 +323,87 @@ PIDL_dissect_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
It is really just 2 uint32's
*/
int
-dissect_ndr_duint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
+dissect_ndr_duint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
int hfindex, guint64 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
- return dissect_dcerpc_uint64 (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_uint64(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
/* uint64 : hyper
a 64 bit integer aligned to proper 8 byte boundaries
*/
int
-dissect_ndr_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint64 *pdata)
+dissect_ndr_uint64(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint64 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 8)) {
offset += 8 - (offset % 8);
}
- return dissect_dcerpc_uint64 (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_uint64(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
int
-PIDL_dissect_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
+PIDL_dissect_uint64(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
int hfindex, guint32 param _U_)
{
dcerpc_info *di;
- guint64 val;
+ guint64 val;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 8)) {
offset += 8 - (offset % 8);
}
- offset=dissect_dcerpc_uint64 (tvb, offset, pinfo,
- tree, drep, hfindex, &val);
+ offset = dissect_dcerpc_uint64(tvb, offset, pinfo,
+ tree, drep, hfindex, &val);
- if(param&PIDL_SET_COL_INFO){
+ if (param&PIDL_SET_COL_INFO) {
header_field_info *hf_info;
char *valstr;
- hf_info=proto_registrar_get_nth(hfindex);
+ hf_info = proto_registrar_get_nth(hfindex);
- valstr=ep_alloc(64);
+ valstr = ep_alloc(64);
valstr[0]=0;
- switch(hf_info->display){
+ switch (hf_info->display) {
case BASE_DEC:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(%" G_GINT64_MODIFIER "u)",val_to_str( (guint32) val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "%" G_GINT64_MODIFIER "u", val);
}
break;
case BASE_HEX:
- if(hf_info->strings){
+ if (hf_info->strings) {
g_snprintf(valstr, 64, "%s(0x%" G_GINT64_MODIFIER "x)",val_to_str( (guint32) val, hf_info->strings, "Unknown:%u"), val);
} else {
g_snprintf(valstr, 64, "0x%" G_GINT64_MODIFIER "x", val);
@@ -424,88 +423,88 @@ PIDL_dissect_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
int
dissect_ndr_float(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, gfloat *pdata)
+ proto_tree *tree, guint8 *drep,
+ int hfindex, gfloat *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
return dissect_dcerpc_float(tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ tree, drep, hfindex, pdata);
}
int
dissect_ndr_double(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, gdouble *pdata)
+ proto_tree *tree, guint8 *drep,
+ int hfindex, gdouble *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 8)) {
offset += 8 - (offset % 8);
}
return dissect_dcerpc_double(tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ tree, drep, hfindex, pdata);
}
/* handles unix 32 bit time_t */
int
-dissect_ndr_time_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, guint32 *pdata)
+dissect_ndr_time_t(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, guint32 *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
- return dissect_dcerpc_time_t (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_time_t(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
int
-dissect_ndr_uuid_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, e_uuid_t *pdata)
+dissect_ndr_uuid_t(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, e_uuid_t *pdata)
{
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
/* uuid's are aligned to 4 bytes, due to initial uint32 in struct */
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
- return dissect_dcerpc_uuid_t (tvb, offset, pinfo,
- tree, drep, hfindex, pdata);
+ return dissect_dcerpc_uuid_t(tvb, offset, pinfo,
+ tree, drep, hfindex, pdata);
}
/*
@@ -518,27 +517,27 @@ dissect_ndr_uuid_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
* attributes and the uuid_t?
*/
int
-dissect_ndr_ctx_hnd (tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, guint8 *drep,
- int hfindex, e_ctx_hnd *pdata)
+dissect_ndr_ctx_hnd(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, guint8 *drep,
+ int hfindex, e_ctx_hnd *pdata)
{
static e_ctx_hnd ctx_hnd;
dcerpc_info *di;
- di=pinfo->private_data;
- if(di->conformant_run){
- /* just a run to handle conformant arrays, no scalars to dissect */
- return offset;
+ di = pinfo->private_data;
+ if (di->conformant_run) {
+ /* just a run to handle conformant arrays, no scalars to dissect */
+ return offset;
}
if (!di->no_align && (offset % 2)) {
offset += 4 - (offset % 4);
}
- ctx_hnd.attributes = dcerpc_tvb_get_ntohl (tvb, offset, drep);
- dcerpc_tvb_get_uuid (tvb, offset+4, drep, &ctx_hnd.uuid);
+ ctx_hnd.attributes = dcerpc_tvb_get_ntohl(tvb, offset, drep);
+ dcerpc_tvb_get_uuid(tvb, offset+4, drep, &ctx_hnd.uuid);
if (tree) {
/* Bytes is bytes - don't worry about the data representation */
- proto_tree_add_item (tree, hfindex, tvb, offset, 20, ENC_NA);
+ proto_tree_add_item(tree, hfindex, tvb, offset, 20, ENC_NA);
}
if (pdata) {
*pdata = ctx_hnd;