diff options
author | Michael Mann <mmann78@netscape.net> | 2013-08-25 21:01:11 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2013-08-25 21:01:11 +0000 |
commit | e5e4d357e398b9f1a9714dd03f7790215fd82fe4 (patch) | |
tree | 4fee9b5fc2bae8ec58932889adfd0bfff1c748b6 /epan/dissectors/packet-rtcdc.c | |
parent | d8e8f48636c5f139210eefe259fa71a02f49c71f (diff) |
Batch of filterable expert infos.
svn path=/trunk/; revision=51518
Diffstat (limited to 'epan/dissectors/packet-rtcdc.c')
-rw-r--r-- | epan/dissectors/packet-rtcdc.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/epan/dissectors/packet-rtcdc.c b/epan/dissectors/packet-rtcdc.c index 5d614ad5c6..7f33569d94 100644 --- a/epan/dissectors/packet-rtcdc.c +++ b/epan/dissectors/packet-rtcdc.c @@ -68,6 +68,12 @@ static int hf_new_protocol = -1; static gint ett_rtcdc = -1; static gint ett_flags = -1; +static expert_field ei_rtcdc_new_reliability_non_zero = EI_INIT; +static expert_field ei_rtcdc_message_type_unknown = EI_INIT; +static expert_field ei_rtcdc_inconsistent_label_and_parameter_length = EI_INIT; +static expert_field ei_rtcdc_message_too_long = EI_INIT; +static expert_field ei_rtcdc_new_channel_type = EI_INIT; + #define DATA_CHANNEL_OPEN_REQUEST 0x00 #define DATA_CHANNEL_OPEN_RESPONSE 0x01 #define DATA_CHANNEL_ACK 0x02 @@ -138,7 +144,7 @@ static void dissect_open_response_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtcdc_tree, proto_item *rtcdc_item) { if (tvb_length(tvb) > DATA_CHANNEL_RESPONSE_LENGTH) { - expert_add_info_format(pinfo, rtcdc_item, PI_MALFORMED, PI_ERROR, "Message too long"); + expert_add_info(pinfo, rtcdc_item, &ei_rtcdc_message_too_long); } if (rtcdc_tree) { proto_tree_add_item(rtcdc_tree, hf_error, tvb, ERROR_OFFSET, ERROR_LENGTH, ENC_BIG_ENDIAN); @@ -154,7 +160,7 @@ static void dissect_open_ack_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtcdc_tree _U_, proto_item *rtcdc_item) { if (tvb_length(tvb) > DATA_CHANNEL_ACK_LENGTH) { - expert_add_info_format(pinfo, rtcdc_item, PI_MALFORMED, PI_ERROR, "Message too long"); + expert_add_info(pinfo, rtcdc_item, &ei_rtcdc_message_too_long); } return; } @@ -209,20 +215,20 @@ dissect_new_open_request_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * proto_tree_add_item(rtcdc_tree, hf_new_channel_type, tvb, NEW_CHANNEL_TYPE_OFFSET, NEW_CHANNEL_TYPE_LENGTH, ENC_BIG_ENDIAN); channel_type = tvb_get_guint8(tvb, NEW_CHANNEL_TYPE_OFFSET); if ((channel_type & 0x7f) > 0x02) { - expert_add_info_format(pinfo, rtcdc_item, PI_MALFORMED, PI_ERROR, "Unknown channel type"); + expert_add_info(pinfo, rtcdc_item, &ei_rtcdc_new_channel_type); } proto_tree_add_item(rtcdc_tree, hf_new_priority, tvb, NEW_PRIORITY_OFFSET, NEW_PRIORITY_LENGTH, ENC_BIG_ENDIAN); proto_tree_add_item(rtcdc_tree, hf_new_reliability, tvb, NEW_RELIABILITY_OFFSET, NEW_RELIABILITY_LENGTH, ENC_BIG_ENDIAN); reliability = tvb_get_ntohl(tvb, NEW_RELIABILITY_OFFSET); if ((reliability > 0) && ((channel_type & 0x80) == 0)) { - expert_add_info_format(pinfo, rtcdc_item, PI_MALFORMED, PI_ERROR, "Reliability parameter non zero for reliable channel"); + expert_add_info(pinfo, rtcdc_item, &ei_rtcdc_new_reliability_non_zero); } proto_tree_add_item(rtcdc_tree, hf_new_label_length, tvb, NEW_LABEL_LENGTH_OFFSET, NEW_LABEL_LENGTH_LENGTH, ENC_BIG_ENDIAN); proto_tree_add_item(rtcdc_tree, hf_new_protocol_length, tvb, NEW_PROTOCOL_LENGTH_OFFSET, NEW_PROTOCOL_LENGTH_LENGTH, ENC_BIG_ENDIAN); label_length = tvb_get_ntohs(tvb, NEW_LABEL_LENGTH_OFFSET); protocol_length = tvb_get_ntohs(tvb, NEW_PROTOCOL_LENGTH_OFFSET); if (NEW_OPEN_REQUEST_HEADER_LENGTH + (guint)label_length + (guint)protocol_length != tvb_length(tvb)) { - expert_add_info_format(pinfo, rtcdc_item, PI_MALFORMED, PI_ERROR, "Inconsistent label and parameter length"); + expert_add_info(pinfo, rtcdc_item, &ei_rtcdc_inconsistent_label_and_parameter_length); } proto_tree_add_item(rtcdc_tree, hf_new_label, tvb, NEW_LABEL_OFFSET, label_length, ENC_BIG_ENDIAN); proto_tree_add_item(rtcdc_tree, hf_new_protocol, tvb, NEW_LABEL_OFFSET + label_length, protocol_length, ENC_BIG_ENDIAN); @@ -233,7 +239,7 @@ dissect_new_open_request_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * static int dissect_rtcdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - proto_item *rtcdc_item; + proto_item *rtcdc_item, *msg_item; proto_tree *rtcdc_tree; guint8 message_type; @@ -241,15 +247,11 @@ dissect_rtcdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTCDC"); col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(message_type, message_type_values, "reserved")); - if (tree) { - rtcdc_item = proto_tree_add_item(tree, proto_rtcdc, tvb, 0, -1, ENC_NA); - rtcdc_tree = proto_item_add_subtree(rtcdc_item, ett_rtcdc); - proto_tree_add_item(rtcdc_tree, hf_message_type, tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, ENC_BIG_ENDIAN); - } else { - rtcdc_item = NULL; - rtcdc_tree = NULL; - } - switch (message_type) { + rtcdc_item = proto_tree_add_item(tree, proto_rtcdc, tvb, 0, -1, ENC_NA); + rtcdc_tree = proto_item_add_subtree(rtcdc_item, ett_rtcdc); + msg_item = proto_tree_add_item(rtcdc_tree, hf_message_type, tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, ENC_BIG_ENDIAN); + + switch (message_type) { case DATA_CHANNEL_OPEN_REQUEST: dissect_open_request_message(tvb, pinfo, rtcdc_tree, rtcdc_item); break; @@ -263,7 +265,7 @@ dissect_rtcdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U dissect_new_open_request_message(tvb, pinfo, rtcdc_tree, rtcdc_item); break; default: - expert_add_info_format(pinfo, rtcdc_item, PI_MALFORMED, PI_ERROR, "Unknown message type"); + expert_add_info(pinfo, msg_item, &ei_rtcdc_message_type_unknown); break; } return tvb_length(tvb); @@ -273,6 +275,7 @@ void proto_register_rtcdc(void) { module_t *rtcdc_module; + expert_module_t* expert_rtcdc; static hf_register_info hf[] = { { &hf_message_type, { "Message type", "rtcdc.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, NULL, HFILL } }, { &hf_channel_type, { "Channel type", "rtcdc.channel_type", FT_UINT8, BASE_DEC, VALS(channel_type_values), 0x0, NULL, HFILL } }, @@ -297,9 +300,19 @@ proto_register_rtcdc(void) &ett_flags }; + static ei_register_info ei[] = { + { &ei_rtcdc_message_too_long, { "rtcdc.message_too_long", PI_MALFORMED, PI_ERROR, "Message too long", EXPFILL }}, + { &ei_rtcdc_new_channel_type, { "rtcdc.channel_type.unknown", PI_PROTOCOL, PI_WARN, "Unknown channel type", EXPFILL }}, + { &ei_rtcdc_new_reliability_non_zero, { "rtcdc.reliability_parameter.non_zero", PI_PROTOCOL, PI_WARN, "Reliability parameter non zero for reliable channel", EXPFILL }}, + { &ei_rtcdc_inconsistent_label_and_parameter_length, { "rtcdc.inconsistent_label_and_parameter_length", PI_MALFORMED, PI_ERROR, "Inconsistent label and parameter length", EXPFILL }}, + { &ei_rtcdc_message_type_unknown, { "rtcdc.message_type.unknown", PI_PROTOCOL, PI_WARN, "Unknown message type", EXPFILL }}, + }; + proto_rtcdc = proto_register_protocol("WebRTC Datachannel Protocol", "RTCDC", "rtcdc"); proto_register_field_array(proto_rtcdc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_rtcdc = expert_register_protocol(proto_rtcdc); + expert_register_field_array(expert_rtcdc, ei, array_length(ei)); rtcdc_module = prefs_register_protocol(proto_rtcdc, proto_reg_handoff_rtcdc); prefs_register_uint_preference(rtcdc_module, "sctp.ppi", "RTCDC SCTP PPID", "RTCDC SCTP PPID if other than the default", 10, &rtcdc_ppid); } |