forked from osmocom/wireshark
h1: remove if (tree) checks, indent according to the modelines
Change-Id: I878aa23b5d718653b9039aeb94a0ece88c9c03cf Reviewed-on: https://code.wireshark.org/review/10079 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
This commit is contained in:
parent
c78d7c8aa8
commit
41cb3bdc54
|
@ -96,13 +96,13 @@ static gboolean dissect_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
{
|
||||
tvbuff_t *next_tvb;
|
||||
|
||||
proto_tree *h1_tree = NULL;
|
||||
proto_tree *h1_tree;
|
||||
|
||||
proto_item *ti;
|
||||
proto_tree *opcode_tree = NULL;
|
||||
proto_tree *org_tree = NULL;
|
||||
proto_tree *response_tree = NULL;
|
||||
proto_tree *empty_tree = NULL;
|
||||
proto_tree *opcode_tree;
|
||||
proto_tree *org_tree;
|
||||
proto_tree *response_tree;
|
||||
proto_tree *empty_tree;
|
||||
|
||||
unsigned int position = 3;
|
||||
unsigned int offset=0;
|
||||
|
@ -121,106 +121,97 @@ static gboolean dissect_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
|
||||
col_set_str (pinfo->cinfo, COL_PROTOCOL, "H1");
|
||||
col_set_str(pinfo->cinfo, COL_INFO, "S5: ");
|
||||
if (tree)
|
||||
{
|
||||
ti = proto_tree_add_item (tree, proto_h1, tvb, offset, 16, ENC_NA);
|
||||
h1_tree = proto_item_add_subtree (ti, ett_h1);
|
||||
proto_tree_add_uint (h1_tree, hf_h1_header, tvb, offset, 2,
|
||||
tvb_get_ntohs(tvb,offset));
|
||||
proto_tree_add_uint (h1_tree, hf_h1_len, tvb, offset + 2, 1,
|
||||
tvb_get_guint8(tvb,offset+2));
|
||||
}
|
||||
|
||||
ti = proto_tree_add_item (tree, proto_h1, tvb, offset, 16, ENC_NA);
|
||||
h1_tree = proto_item_add_subtree (ti, ett_h1);
|
||||
proto_tree_add_uint (h1_tree, hf_h1_header, tvb, offset, 2,
|
||||
tvb_get_ntohs(tvb,offset));
|
||||
proto_tree_add_uint (h1_tree, hf_h1_len, tvb, offset + 2, 1,
|
||||
tvb_get_guint8(tvb,offset+2));
|
||||
|
||||
while (position < tvb_get_guint8(tvb,offset+2))
|
||||
{
|
||||
switch (tvb_get_guint8(tvb,offset + position))
|
||||
{
|
||||
case OPCODE_BLOCK:
|
||||
if (h1_tree)
|
||||
{
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_opfield, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset+position+1),
|
||||
tvb_get_guint8(tvb,offset+position));
|
||||
opcode_tree = proto_item_add_subtree (ti, ett_opcode);
|
||||
proto_tree_add_uint (opcode_tree, hf_h1_oplen, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position + 1));
|
||||
proto_tree_add_uint (opcode_tree, hf_h1_opcode, tvb,
|
||||
offset + position + 2, 1,
|
||||
tvb_get_guint8(tvb,offset + position + 2));
|
||||
}
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_opfield, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset+position+1),
|
||||
tvb_get_guint8(tvb,offset+position));
|
||||
opcode_tree = proto_item_add_subtree (ti, ett_opcode);
|
||||
proto_tree_add_uint (opcode_tree, hf_h1_oplen, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position + 1));
|
||||
proto_tree_add_uint (opcode_tree, hf_h1_opcode, tvb,
|
||||
offset + position + 2, 1,
|
||||
tvb_get_guint8(tvb,offset + position + 2));
|
||||
|
||||
col_append_str (pinfo->cinfo, COL_INFO,
|
||||
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
||||
opcode_vals,"Unknown Opcode (0x%2.2x)"));
|
||||
col_append_str (pinfo->cinfo, COL_INFO,
|
||||
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
||||
opcode_vals,"Unknown Opcode (0x%2.2x)"));
|
||||
break;
|
||||
|
||||
case REQUEST_BLOCK:
|
||||
if (h1_tree)
|
||||
{
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_requestblock, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset + position + 1),
|
||||
tvb_get_guint8(tvb,offset + position));
|
||||
org_tree = proto_item_add_subtree (ti, ett_org);
|
||||
proto_tree_add_uint (org_tree, hf_h1_requestlen, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position+1));
|
||||
proto_tree_add_uint (org_tree, hf_h1_org, tvb,
|
||||
offset + position + 2, 1,
|
||||
tvb_get_guint8(tvb,offset + position+2));
|
||||
proto_tree_add_uint (org_tree, hf_h1_dbnr, tvb,
|
||||
offset + position + 3, 1,
|
||||
tvb_get_guint8(tvb,offset + position+3));
|
||||
proto_tree_add_uint (org_tree, hf_h1_dwnr, tvb,
|
||||
offset + position + 4, 2,
|
||||
tvb_get_ntohs(tvb,offset+position+4));
|
||||
proto_tree_add_int (org_tree, hf_h1_dlen, tvb,
|
||||
offset + position + 6, 2,
|
||||
tvb_get_ntohs(tvb,offset+position+6));
|
||||
}
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " %s %d",
|
||||
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
||||
org_vals,"Unknown Type (0x%2.2x)"),
|
||||
tvb_get_guint8(tvb,offset + position + 3));
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " DW %d",
|
||||
tvb_get_ntohs(tvb,offset+position+4));
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " Count %d",
|
||||
tvb_get_ntohs(tvb,offset+position+6));
|
||||
break;
|
||||
case RESPONSE_BLOCK:
|
||||
if (h1_tree)
|
||||
{
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_response, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset + position + 1),
|
||||
tvb_get_guint8(tvb,offset + position));
|
||||
response_tree = proto_item_add_subtree (ti, ett_response);
|
||||
proto_tree_add_uint (response_tree, hf_h1_response_len, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position+1));
|
||||
proto_tree_add_uint (response_tree, hf_h1_response_value, tvb,
|
||||
offset + position + 2, 1,
|
||||
tvb_get_guint8(tvb,offset + position+2));
|
||||
}
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " %s",
|
||||
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
||||
returncode_vals,"Unknown Returncode (0x%2.2x"));
|
||||
break;
|
||||
case EMPTY_BLOCK:
|
||||
if (h1_tree)
|
||||
{
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_empty, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset + position + 1),
|
||||
tvb_get_guint8(tvb,offset + position));
|
||||
empty_tree = proto_item_add_subtree (ti, ett_empty);
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_requestblock, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset + position + 1),
|
||||
tvb_get_guint8(tvb,offset + position));
|
||||
org_tree = proto_item_add_subtree (ti, ett_org);
|
||||
proto_tree_add_uint (org_tree, hf_h1_requestlen, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position+1));
|
||||
proto_tree_add_uint (org_tree, hf_h1_org, tvb,
|
||||
offset + position + 2, 1,
|
||||
tvb_get_guint8(tvb,offset + position+2));
|
||||
proto_tree_add_uint (org_tree, hf_h1_dbnr, tvb,
|
||||
offset + position + 3, 1,
|
||||
tvb_get_guint8(tvb,offset + position+3));
|
||||
proto_tree_add_uint (org_tree, hf_h1_dwnr, tvb,
|
||||
offset + position + 4, 2,
|
||||
tvb_get_ntohs(tvb,offset+position+4));
|
||||
proto_tree_add_int (org_tree, hf_h1_dlen, tvb,
|
||||
offset + position + 6, 2,
|
||||
tvb_get_ntohs(tvb,offset+position+6));
|
||||
|
||||
proto_tree_add_uint (empty_tree, hf_h1_empty_len, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position+1));
|
||||
}
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " %s %d",
|
||||
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
||||
org_vals,"Unknown Type (0x%2.2x)"),
|
||||
tvb_get_guint8(tvb,offset + position + 3));
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " DW %d",
|
||||
tvb_get_ntohs(tvb,offset+position+4));
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " Count %d",
|
||||
tvb_get_ntohs(tvb,offset+position+6));
|
||||
break;
|
||||
|
||||
case RESPONSE_BLOCK:
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_response, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset + position + 1),
|
||||
tvb_get_guint8(tvb,offset + position));
|
||||
response_tree = proto_item_add_subtree (ti, ett_response);
|
||||
proto_tree_add_uint (response_tree, hf_h1_response_len, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position+1));
|
||||
proto_tree_add_uint (response_tree, hf_h1_response_value, tvb,
|
||||
offset + position + 2, 1,
|
||||
tvb_get_guint8(tvb,offset + position+2));
|
||||
|
||||
col_append_fstr (pinfo->cinfo, COL_INFO, " %s",
|
||||
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
||||
returncode_vals,"Unknown Returncode (0x%2.2x"));
|
||||
break;
|
||||
|
||||
case EMPTY_BLOCK:
|
||||
ti = proto_tree_add_uint (h1_tree, hf_h1_empty, tvb,
|
||||
offset + position,
|
||||
tvb_get_guint8(tvb,offset + position + 1),
|
||||
tvb_get_guint8(tvb,offset + position));
|
||||
empty_tree = proto_item_add_subtree (ti, ett_empty);
|
||||
proto_tree_add_uint (empty_tree, hf_h1_empty_len, tvb,
|
||||
offset + position + 1, 1,
|
||||
tvb_get_guint8(tvb,offset + position+1));
|
||||
break;
|
||||
|
||||
default:
|
||||
/* This is not a valid telegram. So cancel dissection
|
||||
and try the next dissector */
|
||||
|
|
Loading…
Reference in New Issue