aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-isns.c
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-09-30 23:03:21 +0200
committerAnders Broman <a.broman58@gmail.com>2015-10-02 03:24:42 +0000
commit284f2ccf5cf72fb887c547ae9975f8c18c51bc7a (patch)
tree3deaa15dbaba81a2167839275ff8e03a51e419e2 /epan/dissectors/packet-isns.c
parent1c671c5542625eac9e0906fbcbd4f0859f35d40c (diff)
[isns] replace THROW() with an expert info
this removes 37 THROW() calls do some minor reformatting while at it Change-Id: Ib1611d9a9e7cca9c59451b4040bbaa26cd300aa0 Reviewed-on: https://code.wireshark.org/review/10733 Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Reviewed-by: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-isns.c')
-rw-r--r--epan/dissectors/packet-isns.c106
1 files changed, 58 insertions, 48 deletions
diff --git a/epan/dissectors/packet-isns.c b/epan/dissectors/packet-isns.c
index 8846c35642..3c3e8643c5 100644
--- a/epan/dissectors/packet-isns.c
+++ b/epan/dissectors/packet-isns.c
@@ -176,6 +176,7 @@ static int hf_isns_pg_index = -1;
static int hf_isns_pg_next_index = -1;
static expert_field ei_isns_not_first_pdu = EI_INIT;
+static expert_field ei_isns_invalid_attr_len = EI_INIT;
/* Desegment iSNS over TCP messages */
static gboolean isns_desegment = TRUE;
@@ -462,6 +463,15 @@ static const value_string isns_attribute_tags[] = {
};
static value_string_ext isns_attribute_tags_ext = VALUE_STRING_EXT_INIT(isns_attribute_tags);
+#define ISNS_REQUIRE_ATTR_LEN(x) \
+{ \
+ if(len != x) { \
+ expert_add_info_format(pinfo, len_item, &ei_isns_invalid_attr_len, \
+ "Invalid attribute length (should be %d)", x); \
+ break; \
+ } \
+}
+
/* iSNS flags */
#define ISNS_FLAGS_CLIENT 0x8000
#define ISNS_FLAGS_SERVER 0x4000
@@ -865,6 +875,7 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
proto_tree *attr_tree;
proto_item *attr_item;
guint32 tag,len;
+ proto_item *len_item;
attr_tree = proto_tree_add_subtree(tree, tvb, offset, -1,
ett_isns_attribute, &attr_item, "Attribute");
@@ -875,7 +886,7 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
offset +=4;
len = tvb_get_ntohl(tvb, offset);
- proto_tree_add_item(attr_tree, hf_isns_attr_len,
+ len_item = proto_tree_add_item(attr_tree, hf_isns_attr_len,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset +=4;
@@ -895,27 +906,27 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
proto_tree_add_item(attr_tree, hf_isns_entity_identifier, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_ENTITY_PROTOCOL:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_entity_protocol, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_MGMT_IP_ADDRESS:
- if(len != 16) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(16);
proto_tree_add_item(attr_tree, hf_isns_mgmt_ip_addr, tvb, offset, len, ENC_NA);
break;
case ISNS_ATTR_TAG_TIMESTAMP:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_timestamp, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_REGISTRATION_PERIOD:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_registration_period, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_ENTITY_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_entity_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_ENTITY_NEXT_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_entity_next_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_PORTAL_IP_ADDRESS:
@@ -949,26 +960,26 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
proto_tree_add_item(attr_tree, hf_isns_iscsi_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_ISCSI_NODE_TYPE:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
dissect_isns_attr_iscsi_node_type(tvb, offset, attr_tree, len);
break;
case ISNS_ATTR_TAG_ISCSI_ALIAS:
proto_tree_add_item(attr_tree, hf_isns_iscsi_alias, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_ISCSI_SCN_BITMAP:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
dissect_isns_attr_scn_bitmap(tvb, offset, attr_tree);
break;
case ISNS_ATTR_TAG_ISCSI_NODE_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_node_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_WWNN_TOKEN:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_wwnn_token, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_ISCSI_NODE_NEXT_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_node_next_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_ISCSI_AUTH_METHOD:
@@ -981,7 +992,7 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
proto_tree_add_item(attr_tree, hf_isns_pg_portal_ip_addr, tvb, offset, len, ENC_NA);
break;
case ISNS_ATTR_TAG_PG_PORTAL_PORT:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
dissect_isns_attr_port(tvb, offset, attr_tree, hf_isns_pg_portal_port, ISNS_OTHER_PORT, pinfo);
break;
case ISNS_ATTR_TAG_PORTAL_GROUP_TAG:
@@ -990,24 +1001,24 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
proto_tree_add_uint_format_value(tree, hf_isns_portal_group_tag, tvb, offset, 8, 0, "<NULL>");
}
else {
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_portal_group_tag, tvb, offset, len, ENC_BIG_ENDIAN);
}
break;
case ISNS_ATTR_TAG_PORTAL_GROUP_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_pg_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_PORTAL_GROUP_NEXT_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_pg_next_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_FC_PORT_NAME_WWPN:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_fc_port_name_wwpn, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_PORT_ID:
- if(len != 3) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(3);
proto_tree_add_item(attr_tree, hf_isns_port_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
/*
@@ -1024,15 +1035,15 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
proto_tree_add_item(attr_tree, hf_isns_symbolic_port_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_FABRIC_PORT_NAME:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_fabric_port_name, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_HARD_ADDRESS:
- if(len != 3) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(3);
proto_tree_add_item(attr_tree, hf_isns_hard_address, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_PORT_IP_ADDRESS:
- if(len != 16) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(16);
proto_tree_add_item(attr_tree, hf_isns_port_ip_addr, tvb, offset, len, ENC_NA);
break;
/*
@@ -1048,90 +1059,90 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
bit 31 (Lsb) FCP Target
*/
case ISNS_ATTR_TAG_PERMANENT_PORT_NAME:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_permanent_port_name, tvb, offset, len, ENC_BIG_ENDIAN);
break;
/* 8bit type code in byte0 */
case ISNS_ATTR_TAG_FC_NODE_NAME_WWNN:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_fc_node_name_wwnn, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_SYMBOLIC_NODE_NAME:
proto_tree_add_item(attr_tree, hf_isns_symbolic_node_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_NODE_IP_ADDRESS:
- if(len != 16) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(16);
proto_tree_add_item(attr_tree, hf_isns_node_ip_addr, tvb, offset, len, ENC_NA);
break;
case ISNS_ATTR_TAG_NODE_IPA:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_node_ipa, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_PROXY_ISCSI_NAME:
proto_tree_add_item(attr_tree, hf_isns_proxy_iscsi_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_SWITCH_NAME:
- if(len != 8) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(8);
proto_tree_add_item(attr_tree, hf_isns_switch_name, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_PREFERRED_ID:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_preferred_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_ASSIGNED_ID:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_assigned_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_VIRTUAL_FABRIC_ID:
proto_tree_add_item(attr_tree, hf_isns_virtual_fabric_id, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_VENDOR_OUI:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_vendor_oui, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_SET_ID:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_dd_set_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_SET_SYMBOLIC_NAME:
proto_tree_add_item(attr_tree, hf_isns_dd_set_symbolic_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_DD_SET_NEXT_ID:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_dd_set_next_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_ID:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_dd_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_SYMBOLIC_NAME:
proto_tree_add_item(attr_tree, hf_isns_dd_symbolic_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_DD_MEMBER_ISCSI_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_member_iscsi_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_MEMBER_ISCSI_NAME:
proto_tree_add_item(attr_tree, hf_isns_dd_member_iscsi_name, tvb, offset, len, ENC_ASCII|ENC_NA);
break;
case ISNS_ATTR_TAG_DD_MEMBER_FC_PORT_NAME:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_member_fc_port_name, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_MEMBER_PORTAL_INDEX:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_member_portal_index, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case ISNS_ATTR_TAG_DD_MEMBER_PORTAL_IP_ADDRESS:
- if(len != 16) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(16);
proto_tree_add_item(attr_tree, hf_isns_dd_member_portal_ip_addr, tvb, offset, len, ENC_NA);
break;
case ISNS_ATTR_TAG_DD_MEMBER_PORTAL_PORT:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
dissect_isns_attr_port(tvb, offset, attr_tree, hf_isns_dd_member_portal_port, ISNS_OTHER_PORT, pinfo);
break;
case ISNS_ATTR_TAG_DD_ID_NEXT_ID:
- if(len != 4) THROW(ReportedBoundsError);
+ ISNS_REQUIRE_ATTR_LEN(4);
proto_tree_add_item(attr_tree, hf_isns_dd_id_next_id, tvb, offset, len, ENC_BIG_ENDIAN);
break;
default:
@@ -1144,8 +1155,6 @@ AddAttribute(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, guint offset,
-/* Register the protocol with Wireshark */
-
void proto_register_isns(void)
{
/* Setup list of header fields See Section 1.6.1 for details*/
@@ -1683,7 +1692,7 @@ void proto_register_isns(void)
}
};
-/* Setup protocol subtree array */
+ /* Setup protocol subtree array */
static gint *ett[] = {
&ett_isns,
&ett_isns_flags,
@@ -1695,17 +1704,18 @@ void proto_register_isns(void)
static ei_register_info ei[] = {
{ &ei_isns_not_first_pdu,
- { "isns.not_first_pdu",
- PI_PROTOCOL, PI_WARN,
- "This is not the first PDU. The attributes are not decoded", EXPFILL }}
- };
+ { "isns.not_first_pdu", PI_PROTOCOL, PI_WARN,
+ "This is not the first PDU. The attributes are not decoded", EXPFILL }},
+ { &ei_isns_invalid_attr_len,
+ { "isns.invalid_attribute_length", PI_PROTOCOL, PI_WARN,
+ "Invalid attribute length", EXPFILL }}
+ };
module_t *isns_module;
expert_module_t* expert_isns;
-/* Register the protocol name and description */
- proto_isns = proto_register_protocol("iSNS",
- "iSNS", "isns");
+ /* Register the protocol name and description */
+ proto_isns = proto_register_protocol("iSNS", "iSNS", "isns");
proto_register_field_array(proto_isns, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_isns = expert_register_protocol(proto_isns);