diff options
author | Michael Mann <mmann78@netscape.net> | 2013-09-08 00:47:15 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2013-09-08 00:47:15 +0000 |
commit | cc26962f96217d834e1dcf11312f9521bde9841c (patch) | |
tree | 6a06cd62413f22b085499f930edd3cf67d0dacce /epan/dissectors/packet-pw-atm.c | |
parent | 57c28aeffd814a3cb48eebedeb39d1e884d1e5ff (diff) |
Batch of filterable expert info
svn path=/trunk/; revision=51831
Diffstat (limited to 'epan/dissectors/packet-pw-atm.c')
-rw-r--r-- | epan/dissectors/packet-pw-atm.c | 151 |
1 files changed, 93 insertions, 58 deletions
diff --git a/epan/dissectors/packet-pw-atm.c b/epan/dissectors/packet-pw-atm.c index b6f3cc711b..4bc4b2c45d 100644 --- a/epan/dissectors/packet-pw-atm.c +++ b/epan/dissectors/packet-pw-atm.c @@ -98,6 +98,20 @@ static int hf_11_ncells = -1; static int hf_gen_cw_atmbyte = -1; static int hf_cell_payload_len = -1; +static expert_field ei_cell_h_v_not_one = EI_INIT; +static expert_field ei_cell_h_pti_undecoded = EI_INIT; +static expert_field ei_pref_cw_flags = EI_INIT; +static expert_field ei_cell_h_v_not_zero = EI_INIT; +static expert_field ei_pw_payload_size_invalid_note = EI_INIT; +static expert_field ei_pw_payload_size_invalid_error = EI_INIT; +static expert_field ei_cell_h_pti_malformed = EI_INIT; +static expert_field ei_cell_h_rsv = EI_INIT; +static expert_field ei_cell_broken = EI_INIT; +static expert_field ei_cell_h_m = EI_INIT; +static expert_field ei_cw_bits03 = EI_INIT; +static expert_field ei_pw_packet_size_too_small = EI_INIT; +static expert_field ei_pref_cw_len = EI_INIT; + static dissector_handle_t dh_cell; static dissector_handle_t dh_cell_header; static dissector_handle_t dh_control_word; @@ -469,7 +483,7 @@ too_small_packet_or_notpw(tvbuff_t * tvb { proto_item * item; item = proto_tree_add_item(tree, proto_handler, tvb, 0, -1, ENC_NA); - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, item, &ei_pw_packet_size_too_small, "PW packet size (%d) is too small to carry sensible information" ,(int)packet_size); /* represent problems in the Packet List pane */ @@ -631,12 +645,12 @@ dissect_11_or_aal5_pdu(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) } if (pd.props & PWC_PAY_SIZE_BAD) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"PW payload size (%d) must be <> 0 and multiple of %d" - ,(int)payload_size, pw_cell_size(pd.mode, pd.submode)); + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, + "PW payload size (%d) must be <> 0 and multiple of %d", + (int)payload_size, pw_cell_size(pd.mode, pd.submode)); if ((payload_size != 0) && MODE_11(pd.mode)) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_NOTE, + expert_add_info_format_text(pinfo, item, &ei_cell_broken, "PW ATM cell [%.3d] is broken", (int)cells); } } @@ -846,10 +860,10 @@ dissect_aal5_sdu(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) if (pd.props & PWC_PAY_SIZE_BAD) { DISSECTOR_ASSERT(PWATM_SUBMODE_ADMIN_CELL == pd.submode); - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"In ATM admin cell mode," - " PW payload size (%d) must be == %d (exactly 1 admin cell)" - ,(int)payload_size, (int)SIZEOF_N1_PW_CELL); + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, + "In ATM admin cell mode," + " PW payload size (%d) must be == %d (exactly 1 admin cell)", + (int)payload_size, (int)SIZEOF_N1_PW_CELL); } } @@ -1025,13 +1039,18 @@ dissect_n1_cw(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) { if (payload_size != 0) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, item, &ei_cell_broken, "PW ATM cell [%.3d] is broken", (int)cells); + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_note, + "PW payload size (%d) must be <>0 and multiple of %d", + (int)payload_size, (int)SIZEOF_N1_PW_CELL); + } + else + { + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, + "PW payload size (%d) must be <>0 and multiple of %d", + (int)payload_size, (int)SIZEOF_N1_PW_CELL); } - expert_add_info_format(pinfo, item, PI_MALFORMED - , (payload_size == 0) ? PI_ERROR : PI_NOTE - ,"PW payload size (%d) must be <>0 and multiple of %d" - ,(int)payload_size, (int)SIZEOF_N1_PW_CELL); } } @@ -1101,13 +1120,18 @@ dissect_n1_nocw(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) { if (payload_size != 0) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, item, &ei_cell_broken, "Last PW ATM cell [%.3d] is broken", (int)cells); + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_note, + "PW payload size (%d) must be <>0 and multiple of %d", + (int)payload_size, (int)SIZEOF_N1_PW_CELL); + } + else + { + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, + "PW payload size (%d) must be <>0 and multiple of %d", + (int)payload_size, (int)SIZEOF_N1_PW_CELL); } - expert_add_info_format(pinfo, item, PI_MALFORMED - , (payload_size == 0) ? PI_ERROR : PI_NOTE - ,"PW payload size (%d) must be <>0 and multiple of %d" - ,(int)payload_size, (int)SIZEOF_N1_PW_CELL); } } @@ -1164,7 +1188,7 @@ dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) { proto_item *item; item = proto_tree_add_item(tree, proto_control_word, tvb, 0, -1, ENC_NA); - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, "Packet (size: %d) is too small to carry MPLS PW Control Word" ,(int)size); return; @@ -1186,8 +1210,7 @@ dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) if (pd->props & PWC_CW_BAD_BITS03) { /* add item to tree (and show it) only if its value is wrong*/ - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Bits 0..3 of Control Word must be 0"); + expert_add_info(pinfo, item, &ei_cw_bits03); } else { @@ -1200,8 +1223,7 @@ dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) item = proto_tree_add_item(tree2, hf_pref_cw_flags, tvb, 0, 1, ENC_BIG_ENDIAN); if (pd->props & PWC_CW_BAD_FLAGS) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Flags must be 0 for PW ATM N:1 encapsulation"); + expert_add_info(pinfo, item, &ei_pref_cw_flags); } } if (pd->mode == PWATM_MODE_AAL5_SDU) @@ -1245,8 +1267,7 @@ dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) if (pd->props & PWC_CW_BAD_RSV) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Reserved bits in Control Word must be 0"); + expert_add_info(pinfo, item, &ei_cw_bits03); } else { @@ -1274,26 +1295,26 @@ dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) } if (pd->props & PWC_CW_BAD_LEN_MUST_BE_0) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Bad Length: must be 0 for this encapsulation"); + expert_add_info_format_text(pinfo, item, &ei_pref_cw_len, + "Bad Length: must be 0 for this encapsulation"); } if (pd->props & PWC_CW_BAD_PAYLEN_LE_0) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Bad Length: too small, must be >= %d" - ,(int)(PWC_SIZEOF_CW+SIZEOF_N1_PW_CELL)); + expert_add_info_format_text(pinfo, item, &ei_pref_cw_len, + "Bad Length: too small, must be >= %d", + (int)(PWC_SIZEOF_CW+SIZEOF_N1_PW_CELL)); } if (pd->props & PWC_CW_BAD_PAYLEN_GT_PACKET) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Bad Length: must be <= than PSN packet size (%d)" - ,(int)pd->packet_size); + expert_add_info_format_text(pinfo, item, &ei_pref_cw_len, + "Bad Length: must be <= than PSN packet size (%d)", + (int)pd->packet_size); } if (pd->props & PWC_CW_BAD_PADDING_NE_0) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Bad Length: must be == PSN packet size (%d), no padding allowed" - ,(int)pd->packet_size); + expert_add_info_format_text(pinfo, item, &ei_pref_cw_len, + "Bad Length: must be == PSN packet size (%d), no padding allowed", + (int)pd->packet_size); } } @@ -1488,13 +1509,13 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void item2 = proto_tree_add_item(tree2, hf_cell_h_pti, tvb, 3, 1, ENC_BIG_ENDIAN); if (NULL == try_val_to_str(pd->pti, atm_pt_vals)) { - expert_add_info_format(pinfo, item2, PI_UNDECODED, PI_WARN, + expert_add_info_format_text(pinfo, item2, &ei_cell_h_pti_undecoded, "Unknown value of PTI field (%d) in the ATM cell header", pd->pti); } else if ((pd->mode == PWATM_MODE_AAL5_SDU) && !PTI_IS_ADMIN(pd->pti)) { - expert_add_info_format(pinfo, item2, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, item2, &ei_cell_h_pti_malformed, "ATM admin cell is transerred;" " PTI field (%d) should be 4, 5 or 6.", pd->pti); @@ -1507,28 +1528,24 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void item2 = proto_tree_add_item(tree2, hf_cell_h_m , tvb, 0, 1, ENC_BIG_ENDIAN); if ((0 != pd->cwb3.m) && MODE_11(pd->mode)) { - expert_add_info_format(pinfo, item2, PI_MALFORMED, PI_ERROR - ,"1:1 mode:" - " M bit must be 0 to distinguish from AAL5 PDU mode"); + expert_add_info(pinfo, item2, &ei_cell_h_m); } item2 = proto_tree_add_item(tree2, hf_cell_h_v , tvb, 0, 1, ENC_BIG_ENDIAN); if ((0 == pd->cwb3.v) && (PWATM_MODE_11_VPC == pd->mode)) { - expert_add_info_format(pinfo, item2, PI_MALFORMED, PI_ERROR - ,"1:1 VPC mode:" - " V bit must be 1 to indicate that VCI is present"); + expert_add_info(pinfo, item2, &ei_cell_h_v_not_zero); } if ((0 != pd->cwb3.v) && (PWATM_MODE_11_VCC == pd->mode)) { - expert_add_info_format(pinfo, item2, PI_MALFORMED, PI_ERROR - ,"1:1 VCC mode:" + expert_add_info_format_text(pinfo, item2, &ei_cell_h_v_not_one, + "1:1 VCC mode:" " V bit must be 0 to indicate that VCI is absent"); } if ((0 != pd->cwb3.v) && (PWATM_MODE_AAL5_PDU == pd->mode)) { - expert_add_info_format(pinfo, item2, PI_MALFORMED, PI_ERROR - ,"AAL5 PDU mode:" + expert_add_info_format_text(pinfo, item2, &ei_cell_h_v_not_one, + "AAL5 PDU mode:" " V bit must be 0 to indicate that VCI is absent"); } @@ -1539,8 +1556,7 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void ,tvb, 0, 1, ENC_BIG_ENDIAN); if (0 != pd->cwb3.rsv) { - expert_add_info_format(pinfo, item2, PI_MALFORMED, PI_ERROR - ,"Reserved bits in the 3rd byte of CW must be 0"); + expert_add_info(pinfo, item2, &ei_cell_h_rsv); } else { @@ -1552,7 +1568,7 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void item2 = proto_tree_add_item(tree2, hf_cell_h_pti, tvb, 0, 1, ENC_BIG_ENDIAN); if (NULL == try_val_to_str(pd->pti, atm_pt_vals)) { - expert_add_info_format(pinfo, item2, PI_UNDECODED, PI_WARN, + expert_add_info_format_text(pinfo, item2, &ei_cell_h_pti_undecoded, "Unknown value of PTI field (%d) in the atm-specific byte" ,pd->pti); } @@ -1578,9 +1594,9 @@ dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void } else { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Not enough data (size: %d), impossible to decode" - ,(int)dissect_size); + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, + "Not enough data (size: %d), impossible to decode", + (int)dissect_size); } } } @@ -1628,9 +1644,9 @@ dissect_cell(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * data pwc_item_append_text_n_items(item, dissect_size, "byte"); if (!is_enough_data) { - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR - ,"Bad length of cell payload: must be == %d" - ,(int)SIZEOF_ATM_CELL_PAYLOAD); + expert_add_info_format_text(pinfo, item, &ei_pw_payload_size_invalid_error, + "Bad length of cell payload: must be == %d", + (int)SIZEOF_ATM_CELL_PAYLOAD); } { @@ -1858,6 +1874,22 @@ proto_register_pw_atm_ata(void) ,&ett_cell_header ,&ett_cell }; + static ei_register_info ei[] = { + { &ei_pw_packet_size_too_small, { "pw.packet_size_too_small", PI_MALFORMED, PI_ERROR, "PW packet size too small", EXPFILL }}, + { &ei_pw_payload_size_invalid_error, { "pw.payload.size_invalid", PI_MALFORMED, PI_ERROR, "PW payload size invalid", EXPFILL }}, + { &ei_cell_broken, { "atm.cell_broken", PI_MALFORMED, PI_ERROR, "PW ATM cell is broken", EXPFILL }}, + { &ei_pw_payload_size_invalid_note, { "pw.payload.size_invalid", PI_MALFORMED, PI_NOTE, "PW payload size invalid", EXPFILL }}, + { &ei_cw_bits03, { "pw.cw.bits03.not_zero", PI_MALFORMED, PI_ERROR, "Bits 0..3 of Control Word must be 0", EXPFILL }}, + { &ei_pref_cw_flags, { "pw.cw.flags.not_zero", PI_MALFORMED, PI_ERROR, "Flags must be 0 for PW ATM N:1 encapsulation", EXPFILL }}, + { &ei_pref_cw_len, { "pw.cw.length.invalid", PI_MALFORMED, PI_ERROR, "Bad Length: must be 0 for this encapsulation", EXPFILL }}, + { &ei_cell_h_pti_undecoded, { "atm.pti.invalid", PI_UNDECODED, PI_WARN, "Unknown value of PTI field in the ATM cell header", EXPFILL }}, + { &ei_cell_h_pti_malformed, { "atm.pti.invalid", PI_MALFORMED, PI_ERROR, "ATM admin cell is transerred. PTI field should be 4, 5 or 6.", EXPFILL }}, + { &ei_cell_h_m, { "atm.pw_control_byte.m.not_zero", PI_MALFORMED, PI_ERROR, "1:1 mode: M bit must be 0 to distinguish from AAL5 PDU mode", EXPFILL }}, + { &ei_cell_h_v_not_zero, { "atm.pw_control_byte.v.not_one", PI_MALFORMED, PI_ERROR, "1:1 VPC mode: V bit must be 1 to indicate that VCI is present", EXPFILL }}, + { &ei_cell_h_v_not_one, { "atm.pw_control_byte.v.not_zero", PI_MALFORMED, PI_ERROR, "1:1 VCC mode: V bit must be 0 to indicate that VCI is absent", EXPFILL }}, + { &ei_cell_h_rsv, { "atm.pw_control_byte.rsv.not_zero", PI_MALFORMED, PI_ERROR, "Reserved bits in the 3rd byte of CW must be 0", EXPFILL }}, + }; + expert_module_t* expert_cell; proto_n1_cw = proto_register_protocol(pwc_longname_pw_atm_n1_cw @@ -1889,6 +1921,9 @@ proto_register_pw_atm_ata(void) ,"mplspwatmcell"); proto_register_field_array( proto_cell ,hfa_cell ,array_length(hfa_cell)); + expert_cell = expert_register_protocol(proto_cell); + expert_register_field_array(expert_cell, ei, array_length(ei)); + proto_register_field_array( proto_cell_header ,hfa_cell_header,array_length(hfa_cell_header)); proto_register_field_array( proto_control_word ,hfa_cw ,array_length(hfa_cw)); proto_register_field_array( proto_n1_nocw ,hfa_n1_nocw ,array_length(hfa_n1_nocw)); |