Skip to content

Commit

Permalink
expert_add_info + proto_tree_add_text = proto_tree_add_expert, where …
Browse files Browse the repository at this point in the history
…applicable

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@50337 f5534014-38df-0310-8fa8-9805f1628bb7
  • Loading branch information
mmann committed Jul 3, 2013
1 parent 3f4808c commit 63b8ae1
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 220 deletions.
4 changes: 2 additions & 2 deletions asn1/acse/packet-acse-template.c
Expand Up @@ -216,8 +216,8 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
call_ber_oid_callback(oid, tvb, offset, pinfo, parent_tree);
} else {
proto_item *ti = proto_tree_add_text(parent_tree, tvb, offset, -1, "dissector is not available");
expert_add_info(pinfo, ti, &ei_acse_dissector_not_available);
proto_tree_add_expert(parent_tree, pinfo, &ei_acse_dissector_not_available,
tvb, offset, -1);
}
top_tree = NULL;
return;
Expand Down
11 changes: 4 additions & 7 deletions asn1/cdt/cdt.cnf
Expand Up @@ -67,14 +67,12 @@ CompressedData B "1.3.26.0.4406.0.4.2" "cdt"

#.FN_BODY CompressedContent
tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
proto_item *tf = NULL;
int save_offset = offset;

%(DEFAULT_BODY)s
if (compr_tvb == NULL) {
tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
"[Error: Unable to get compressed content]");
expert_add_info(actx->pinfo, tf, &ei_cdt_unable_compress_content);
proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_compress_content,
tvb, save_offset, -1);
col_append_str (actx->pinfo->cinfo, COL_INFO,
"[Error: Unable to get compressed content]");
return offset;
Expand All @@ -83,9 +81,8 @@ CompressedData B "1.3.26.0.4406.0.4.2" "cdt"
next_tvb = tvb_child_uncompress (tvb, compr_tvb, 0, tvb_length (compr_tvb));

if (next_tvb == NULL) {
tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
"[Error: Unable to uncompress content]");
expert_add_info(actx->pinfo, tf, &ei_cdt_unable_uncompress_content);
proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_uncompress_content,
tvb, save_offset, -1);
col_append_str (actx->pinfo->cinfo, COL_INFO,
"[Error: Unable to uncompress content]");
return offset;
Expand Down
7 changes: 1 addition & 6 deletions asn1/goose/goose.cnf
Expand Up @@ -17,7 +17,6 @@
#.FN_BODY UtcTime

guint32 len;
proto_item *cause;
guint32 seconds;
guint32 fraction;
guint32 nanoseconds;
Expand All @@ -28,11 +27,7 @@

if(len != 8)
{
cause = proto_tree_add_text(tree, tvb, offset, len,
"BER Error: malformed UTCTime encoding, "
"length must be 8 bytes");
proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
expert_add_info(actx->pinfo, cause, &ei_goose_mal_utctime);
proto_tree_add_expert(tree, actx->pinfo, &ei_goose_mal_utctime, tvb, offset, len);
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
Expand Down
10 changes: 3 additions & 7 deletions asn1/gsm_map/packet-gsm_map-template.c
Expand Up @@ -974,7 +974,6 @@ static int dissect_mc_message(tvbuff_t *tvb,
gboolean bug_pc, bug_ind_field;
gint32 bug_tag;
guint32 bug_len;
proto_item *cause;

octet = tvb_get_guint8(tvb,0);
if ( (octet & 0xf) == 3) {
Expand All @@ -986,22 +985,19 @@ static int dissect_mc_message(tvbuff_t *tvb,
if (sequence3 != NULL) {
offset= (sequence3) (implicit_seq3, tvb, offset, actx, tree, hf_index_seq3);
} else {
cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown or not implemented [3] sequence, cannot decode");
expert_add_info(actx->pinfo, cause, &ei_gsm_map_unknown_sequence3);
proto_tree_add_expert(tree, actx->pinfo, &ei_gsm_map_unknown_sequence3, tvb, offset, -1);
}
} else if (octet == 0x30) {
if (sequence != NULL) {
offset= (sequence) (implicit_seq, tvb, 0, actx, tree, hf_index_seq);
} else {
cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown or not implemented sequence");
expert_add_info(actx->pinfo, cause, &ei_gsm_map_unknown_sequence);
proto_tree_add_expert(tree, actx->pinfo, &ei_gsm_map_unknown_sequence, tvb, offset, -1);
}
} else {
if (parameter != NULL) {
offset= (parameter) (implicit_param, tvb, offset, actx, tree, hf_index_param);
} else {
cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown or not implemented parameter");
expert_add_info(actx->pinfo, cause, &ei_gsm_map_unknown_parameter);
proto_tree_add_expert(tree, actx->pinfo, &ei_gsm_map_unknown_parameter, tvb, offset, -1);
}
}
return offset;
Expand Down
14 changes: 4 additions & 10 deletions asn1/mms/mms.cnf
Expand Up @@ -49,7 +49,6 @@ UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE
#.FN_BODY TimeOfDay

guint32 len;
proto_item *cause;
guint32 milliseconds;
guint16 days;
gchar * ptime;
Expand Down Expand Up @@ -89,10 +88,8 @@ UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE
return offset;
}

cause = proto_tree_add_text(tree, tvb, offset, len,
"BER Error: malformed TimeOfDay encoding, "
"length must be 4 or 6 bytes");
expert_add_info(actx->pinfo, cause, &ei_mms_mal_timeofday_encoding);
proto_tree_add_expert_format(tree, actx->pinfo, &ei_mms_mal_timeofday_encoding,
tvb, offset, len, "BER Error: malformed TimeOfDay encoding, length must be 4 or 6 bytes");
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
Expand All @@ -103,7 +100,6 @@ UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE
#.FN_BODY UtcTime

guint32 len;
proto_item *cause;
guint32 seconds;
guint32 fraction;
guint32 nanoseconds;
Expand All @@ -114,10 +110,8 @@ UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE

if(len != 8)
{
cause = proto_tree_add_text(tree, tvb, offset, len,
"BER Error: malformed IEC61850 UTCTime encoding, "
"length must be 8 bytes");
expert_add_info(actx->pinfo, cause, &ei_mms_mal_utctime_encoding);
proto_tree_add_expert_format(tree, actx->pinfo, &ei_mms_mal_utctime_encoding,
tvb, offset, len, "BER Error: malformed IEC61850 UTCTime encoding, length must be 8 bytes");
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
Expand Down
4 changes: 2 additions & 2 deletions asn1/p1/p1.cnf
Expand Up @@ -678,8 +678,8 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token"
proto_item *item = NULL;
proto_tree *next_tree = NULL;

item = proto_tree_add_text(actx->subtree.top_tree ? actx->subtree.top_tree : tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "P1 Unknown Content (unknown built-in content-type)");
expert_add_info(actx->pinfo, item, &ei_p1_unknown_built_in_content_type);
proto_tree_add_expert(actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->pinfo, &ei_p1_unknown_built_in_content_type,
next_tvb, 0, tvb_length_remaining(tvb, offset));
if (item) {
next_tree=proto_item_add_subtree(item, ett_p1_content_unknown);
}
Expand Down
2 changes: 1 addition & 1 deletion asn1/p1/packet-p1-template.c
Expand Up @@ -339,7 +339,7 @@ void proto_register_p1(void) {
static ei_register_info ei[] = {
{ &ei_p1_unknown_extension_attribute_type, { "p1.unknown.extension_attribute_type", PI_UNDECODED, PI_WARN, "Unknown extension-attribute-type", EXPFILL }},
{ &ei_p1_unknown_standard_extension, { "p1.unknown.standard_extension", PI_UNDECODED, PI_WARN, "Unknown standard-extension", EXPFILL }},
{ &ei_p1_unknown_built_in_content_type, { "p1.unknown.built_in_content_type", PI_UNDECODED, PI_WARN, "Unknown built-in content-type", EXPFILL }},
{ &ei_p1_unknown_built_in_content_type, { "p1.unknown.built_in_content_type", PI_UNDECODED, PI_WARN, "P1 Unknown Content (unknown built-in content-type)", EXPFILL }},
{ &ei_p1_unknown_tokendata_type, { "p1.unknown.tokendata_type", PI_UNDECODED, PI_WARN, "Unknown tokendata-type", EXPFILL }},
};

Expand Down
8 changes: 4 additions & 4 deletions asn1/pres/pres.cnf
Expand Up @@ -43,8 +43,8 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree);
} else {
proto_item *ti = proto_tree_add_text(tree, tvb, offset, -1,"dissector is not available");
expert_add_info(actx->pinfo, ti, &ei_pres_dissector_not_available);
proto_tree_add_expert(tree, actx->pinfo, &ei_pres_dissector_not_available,
tvb, offset, -1);
}

#.FN_BODY PDV-list/presentation-data-values/octet-aligned
Expand All @@ -57,8 +57,8 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason
dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &next_tvb);
call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree);
} else {
proto_item *ti = proto_tree_add_text(tree, tvb, offset, -1,"dissector is not available");
expert_add_info(actx->pinfo, ti, &ei_pres_dissector_not_available);
proto_tree_add_expert(tree, actx->pinfo, &ei_pres_dissector_not_available,
tvb, offset, -1);
%(DEFAULT_BODY)s
}

Expand Down
8 changes: 2 additions & 6 deletions asn1/sv/sv.cnf
Expand Up @@ -23,7 +23,6 @@

#.FN_BODY UtcTime
guint32 len;
proto_item *cause;
guint32 seconds;
guint32 fraction;
guint32 nanoseconds;
Expand All @@ -34,11 +33,8 @@

if(len != 8)
{
cause = proto_tree_add_text(tree, tvb, offset, len,
"BER Error: malformed UTCTime encoding, "
"length must be 8 bytes");
proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
expert_add_info(actx->pinfo, cause, &ei_sv_mal_utctime);
proto_tree_add_expert_format(tree, actx->pinfo, &ei_sv_mal_utctime, tvb, offset, len,
"BER Error: malformed UTCTime encoding, length must be 8 bytes");
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
Expand Down
4 changes: 2 additions & 2 deletions epan/dissectors/packet-acse.c
Expand Up @@ -1756,8 +1756,8 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
call_ber_oid_callback(oid, tvb, offset, pinfo, parent_tree);
} else {
proto_item *ti = proto_tree_add_text(parent_tree, tvb, offset, -1, "dissector is not available");
expert_add_info(pinfo, ti, &ei_acse_dissector_not_available);
proto_tree_add_expert(parent_tree, pinfo, &ei_acse_dissector_not_available,
tvb, offset, -1);
}
top_tree = NULL;
return;
Expand Down
12 changes: 6 additions & 6 deletions epan/dissectors/packet-amr.c
Expand Up @@ -395,8 +395,8 @@ dissect_amr_be(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint amr

/* Check if we have enough data available for our frames */
if (tvb_reported_length_remaining(tvb, bitcount/8) < bytes_needed_for_frames) {
item = proto_tree_add_text(tree, tvb, bitcount/8, bytes_needed_for_frames, "Error:");
proto_item_append_text(item, " %d Bytes available, %d would be needed!",
item = proto_tree_add_text(tree, tvb, bitcount/8, bytes_needed_for_frames,
"Error: %d Bytes available, %d would be needed!",
tvb_reported_length_remaining(tvb, bitcount/8),
bytes_needed_for_frames);
expert_add_info(pinfo, item, &ei_amr_not_enough_data_for_frames);
Expand All @@ -409,17 +409,17 @@ dissect_amr_be(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint amr
bitcount += bits_used_for_frames;

if (tvb_reported_length_remaining(tvb, (bitcount+8)/8) > 0) {
item = proto_tree_add_text(tree, tvb, bitcount/8, tvb_reported_length_remaining(tvb, bitcount/8), "Error:");
proto_item_append_text(item, " %d Bytes remaining - should be 0!",tvb_reported_length_remaining(tvb, (bitcount+8)/8));
item = proto_tree_add_text(tree, tvb, bitcount/8, tvb_reported_length_remaining(tvb, bitcount/8),
"Error: %d Bytes remaining - should be 0!",tvb_reported_length_remaining(tvb, (bitcount+8)/8));
expert_add_info(pinfo, item, &ei_amr_superfluous_data);

/* Now check the paddings */
if (bitcount%8 != 0) {
if ( (1 << (8 -(bitcount%8)-1)) & tvb_get_guint8(tvb,bitcount/8) )
proto_tree_add_text(tree, tvb, bitcount/8, 1, "Padding bits correct");
else {
item = proto_tree_add_text(tree, tvb, bitcount/8, 1, "Padding bits error");
expert_add_info(pinfo, item, &ei_amr_padding_bits_not0);
proto_tree_add_expert(tree, pinfo, &ei_amr_padding_bits_not0, tvb,
bitcount/8, 1);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions epan/dissectors/packet-ansi_a.c
Expand Up @@ -927,10 +927,8 @@ ansi_a_so_int_to_str(
#define EXTRANEOUS_DATA_CHECK_EXPERT(edc_len, edc_max_len) \
if ((edc_len) > (edc_max_len)) \
{ \
proto_item *expert_item; \
expert_item = proto_tree_add_text(tree, tvb, \
curr_offset, (edc_len) - (edc_max_len), "Extraneous Data, dissector bug or later version spec(report to wireshark.org)"); \
expert_add_info(pinfo, expert_item, &ei_ansi_a_extraneous_data); \
proto_tree_add_expert(tree, pinfo, &ei_ansi_a_extraneous_data, \
tvb, curr_offset, (edc_len) - (edc_max_len)); \
curr_offset += ((edc_len) - (edc_max_len)); \
}

Expand Down
12 changes: 4 additions & 8 deletions epan/dissectors/packet-beep.c
Expand Up @@ -273,8 +273,6 @@ static int num_len(tvbuff_t *tvb, int offset)
static int
check_term(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree)
{
proto_item *ti;

/* First, check for CRLF, or, if global_beep_strict_term is false,
* one of CR or LF ... If neither of these hold, we add an element
* that complains of a protocol violation, and return -1, else
Expand All @@ -293,21 +291,19 @@ check_term(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree)

if ((tvb_get_guint8(tvb, offset) == 0x0d) && !global_beep_strict_term) {

ti = proto_tree_add_text(tree, tvb, offset, 1, "Terminator: CR");
expert_add_info(pinfo, ti, &ei_beep_cr_terminator);
proto_tree_add_expert(tree, pinfo, &ei_beep_cr_terminator, tvb, offset, 1);
return 1;

}

if ((tvb_get_guint8(tvb, offset) == 0x0a) && !global_beep_strict_term) {

ti = proto_tree_add_text(tree, tvb, offset, 1, "Terminator: LF");
expert_add_info(pinfo, ti, &ei_beep_lf_terminator);
proto_tree_add_expert(tree, pinfo, &ei_beep_lf_terminator, tvb, offset, 1);
return 1;
}

ti = proto_tree_add_text(tree, tvb, offset, 1, "Terminator: %s", tvb_format_text(tvb, offset, 2));
expert_add_info_format_text(pinfo, ti, &ei_beep_invalid_terminator, "Invalid Terminator: %s", tvb_format_text(tvb, offset, 2));
proto_tree_add_expert_format(tree, pinfo, &ei_beep_invalid_terminator, tvb,
offset, 1, "Terminator: %s", tvb_format_text(tvb, offset, 2));
return -1;
}

Expand Down
11 changes: 4 additions & 7 deletions epan/dissectors/packet-cdt.c
Expand Up @@ -244,16 +244,14 @@ static int
dissect_cdt_CompressedContent(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 69 "../../asn1/cdt/cdt.cnf"
tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
proto_item *tf = NULL;
int save_offset = offset;

offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
&compr_tvb);

if (compr_tvb == NULL) {
tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
"[Error: Unable to get compressed content]");
expert_add_info(actx->pinfo, tf, &ei_cdt_unable_compress_content);
proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_compress_content,
tvb, save_offset, -1);
col_append_str (actx->pinfo->cinfo, COL_INFO,
"[Error: Unable to get compressed content]");
return offset;
Expand All @@ -262,9 +260,8 @@ dissect_cdt_CompressedContent(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
next_tvb = tvb_child_uncompress (tvb, compr_tvb, 0, tvb_length (compr_tvb));

if (next_tvb == NULL) {
tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
"[Error: Unable to uncompress content]");
expert_add_info(actx->pinfo, tf, &ei_cdt_unable_uncompress_content);
proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_uncompress_content,
tvb, save_offset, -1);
col_append_str (actx->pinfo->cinfo, COL_INFO,
"[Error: Unable to uncompress content]");
return offset;
Expand Down
12 changes: 2 additions & 10 deletions epan/dissectors/packet-frame.c
Expand Up @@ -48,7 +48,6 @@ int proto_pkt_comment = -1;
int hf_frame_arrival_time = -1;
int hf_frame_shift_offset = -1;
int hf_frame_arrival_time_epoch = -1;
static int hf_frame_time_invalid = -1;
static int hf_frame_time_delta = -1;
static int hf_frame_time_delta_displayed = -1;
static int hf_frame_time_relative = -1;
Expand Down Expand Up @@ -318,12 +317,10 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb,
0, 0, &(pinfo->fd->abs_ts));
if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000) {
item = proto_tree_add_none_format(fh_tree, hf_frame_time_invalid, tvb, 0, 0,
expert_add_info_format_text(pinfo, ti, &ei_arrive_time_out_of_range,
"Arrival Time: Fractional second %09ld is invalid,"
" the valid range is 0-1000000000",
(long) pinfo->fd->abs_ts.nsecs);
PROTO_ITEM_SET_GENERATED(item);
expert_add_info(pinfo, item, &ei_arrive_time_out_of_range);
}
item = proto_tree_add_time(fh_tree, hf_frame_shift_offset, tvb,
0, 0, &(pinfo->fd->shift_offset));
Expand Down Expand Up @@ -602,11 +599,6 @@ proto_register_frame(void)
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"Epoch time when this frame was captured", HFILL }},

{ &hf_frame_time_invalid,
{ "Arrival Timestamp invalid", "frame.time_invalid",
FT_NONE, BASE_NONE, NULL, 0x0,
"The timestamp from the capture is out of the valid range", HFILL }},

{ &hf_frame_time_delta,
{ "Time delta from previous captured frame", "frame.time_delta",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
Expand Down Expand Up @@ -782,7 +774,7 @@ proto_register_frame(void)

static ei_register_info ei[] = {
{ &ei_comments_text, { "frame.comment.expert", PI_COMMENTS_GROUP, PI_COMMENT, "Formatted comment", EXPFILL }},
{ &ei_arrive_time_out_of_range, { "frame.time_invalid.expert", PI_SEQUENCE, PI_NOTE, "Arrival Time: Fractional second out of range (0-1000000000)", EXPFILL }},
{ &ei_arrive_time_out_of_range, { "frame.time_invalid", PI_SEQUENCE, PI_NOTE, "Arrival Time: Fractional second out of range (0-1000000000)", EXPFILL }},
};

module_t *frame_module;
Expand Down
7 changes: 1 addition & 6 deletions epan/dissectors/packet-goose.c
Expand Up @@ -476,7 +476,6 @@ dissect_goose_UtcTime(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _
#line 18 "../../asn1/goose/goose.cnf"

guint32 len;
proto_item *cause;
guint32 seconds;
guint32 fraction;
guint32 nanoseconds;
Expand All @@ -487,11 +486,7 @@ dissect_goose_UtcTime(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _

if(len != 8)
{
cause = proto_tree_add_text(tree, tvb, offset, len,
"BER Error: malformed UTCTime encoding, "
"length must be 8 bytes");
proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
expert_add_info(actx->pinfo, cause, &ei_goose_mal_utctime);
proto_tree_add_expert(tree, actx->pinfo, &ei_goose_mal_utctime, tvb, offset, len);
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
Expand Down

0 comments on commit 63b8ae1

Please sign in to comment.