diff options
author | Michael Mann <mmann78@netscape.net> | 2013-08-23 03:17:34 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2013-08-23 03:17:34 +0000 |
commit | 6880359a5f42c208f7ba2fe7af9703214c9cd1e9 (patch) | |
tree | d4cda8619bfcdc6ec930e5b28b7584588bfa4d72 /epan/dissectors/packet-telnet.c | |
parent | 186babc6ba30e635d29f235d95e388dbe434fa26 (diff) |
Batch of filterable expert infos.
svn path=/trunk/; revision=51486
Diffstat (limited to 'epan/dissectors/packet-telnet.c')
-rw-r--r-- | epan/dissectors/packet-telnet.c | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/epan/dissectors/packet-telnet.c b/epan/dissectors/packet-telnet.c index f6d5c7ffaa..d56a9e742c 100644 --- a/epan/dissectors/packet-telnet.c +++ b/epan/dissectors/packet-telnet.c @@ -120,6 +120,19 @@ static gint ett_charset_subopt = -1; static gint ett_rsp_subopt = -1; static gint ett_comport_subopt = -1; +static expert_field ei_telnet_suboption_length = EI_INIT; +static expert_field ei_telnet_invalid_subcommand = EI_INIT; +static expert_field ei_telnet_invalid_linestate = EI_INIT; +static expert_field ei_telnet_invalid_stop = EI_INIT; +static expert_field ei_telnet_enc_cmd_unknown = EI_INIT; +static expert_field ei_telnet_invalid_data_size = EI_INIT; +static expert_field ei_telnet_invalid_modemstate = EI_INIT; +static expert_field ei_telnet_invalid_parity = EI_INIT; +static expert_field ei_telnet_kerberos_blob_too_long = EI_INIT; +static expert_field ei_telnet_invalid_purge = EI_INIT; +static expert_field ei_telnet_invalid_baud_rate = EI_INIT; +static expert_field ei_telnet_invalid_control = EI_INIT; + static dissector_handle_t telnet_handle; static dissector_handle_t tn3270_handle; @@ -258,8 +271,7 @@ dissect_string_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, in break; default: - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Invalid %s subcommand %u", - optname, cmd); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_subcommand, "Invalid %s subcommand %u", optname, cmd); offset++; len--; @@ -293,7 +305,7 @@ dissect_tn3270_regime_subopt(packet_info *pinfo, const char *optname _U_, tvbuff len -= len; return; default: - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Bogus value: %u", cmd); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_subcommand, "Bogus value: %u", cmd); break; } offset++; @@ -489,8 +501,7 @@ dissect_htstops_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i break; default: - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Invalid %s subcommand %u", - optname, cmd); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_subcommand, "Invalid %s subcommand %u", optname, cmd); offset++; len--; if (len > 0) @@ -666,7 +677,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i proto_tree_add_uint_format_value(tree, hf_telnet_comport_subopt_baud_rate, tvb, offset, 5, baud, "%s Baud Rate: %d",source,baud); } } else { - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "%s <Invalid Baud Rate Packet>",source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_baud_rate, "%s <Invalid Baud Rate Packet>", source); } break; @@ -678,7 +689,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i proto_tree_add_uint_format_value(tree, hf_telnet_comport_subopt_data_size, tvb, offset, 2, datasize, "%s Data Size: %s",source,ds); } else { - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "%s <Invalid Data Size Packet>",source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_data_size, "%s <Invalid Data Size Packet>", source); } break; @@ -690,7 +701,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i proto_tree_add_uint_format_value(tree, hf_telnet_comport_subopt_parity, tvb, offset, 2, parity, "%s Parity: %s",source,pr); } else { - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "%s <Invalid Parity Packet>",source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_parity, "%s <Invalid Parity Packet>", source); } break; case TNCOMPORT_SETSTOPSIZE: @@ -701,7 +712,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i proto_tree_add_uint_format_value(tree, hf_telnet_comport_subopt_stop, tvb, offset, 2, stop, "%s Stop: %s",source,st); } else { - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "%s <Invalid Stop Packet>",source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_stop, "%s <Invalid Stop Packet>", source); } break; @@ -713,7 +724,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i proto_tree_add_uint_format_value(tree, hf_telnet_comport_subopt_control, tvb, offset, 2, crt, "%s Stop: %s",source,c); } else { - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "%s <Invalid Control Packet>",source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_control, "%s <Invalid Control Packet>", source); } break; @@ -743,7 +754,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i } else { const char *print_pattern = (cmd == TNCOMPORT_SETLINESTATEMASK) ? "%s <Invalid Linestate Mask>" : "%s <Invalid Linestate Packet>"; - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, print_pattern, source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_linestate, print_pattern, source); } break; @@ -773,7 +784,7 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i } else { const char *print_pattern = (cmd == TNCOMPORT_SETMODEMSTATEMASK) ? "%s <Invalid Modemstate Mask>" : "%s <Invalid Modemstate Packet>"; - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, print_pattern, source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_modemstate, print_pattern, source); } break; @@ -795,12 +806,12 @@ dissect_comport_subopt(packet_info *pinfo, const char *optname, tvbuff_t *tvb, i proto_tree_add_uint_format_value(tree, hf_telnet_comport_subopt_purge, tvb, offset, 2, purge, "%s %s",source,p); } else { - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "%s <Invalid Purge Packet>",source); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_purge, "%s <Invalid Purge Packet>", source); } break; default: - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Invalid %s subcommand %u", optname, cmd); + expert_add_info_format_text(pinfo, item, &ei_telnet_invalid_subcommand, "Invalid %s subcommand %u", optname, cmd); offset++; len--; if (len > 0) @@ -1033,8 +1044,7 @@ dissect_krb5_authentication_data(packet_info *pinfo, tvbuff_t *tvb, int offset, if(krb5_tvb) dissect_kerberos_main(krb5_tvb, pinfo, tree, FALSE, NULL); else - expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_NOTE, "Kerberos blob (too long to dissect - length %u > %u", - len, MAX_KRB5_BLOB_LEN); + expert_add_info_format_text(pinfo, ti, &ei_telnet_kerberos_blob_too_long, "Kerberos blob (too long to dissect - length %u > %u)", len, MAX_KRB5_BLOB_LEN); } } @@ -1175,7 +1185,7 @@ dissect_encryption_subopt(packet_info *pinfo, const char *optname _U_, tvbuff_t break; default: - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Unknown command"); + expert_add_info(pinfo, item, &ei_telnet_enc_cmd_unknown); } } @@ -1574,14 +1584,13 @@ telnet_sub_option(packet_info *pinfo, proto_tree *option_tree, proto_item *optio case NO_LENGTH: /* There isn't supposed to *be* sub-option negotiation for this. */ - expert_add_info_format(pinfo, option_item, PI_PROTOCOL, PI_WARN, "Bogus suboption data"); + expert_add_info_format_text(pinfo, option_item, &ei_telnet_suboption_length, "Bogus suboption data"); return offset; case FIXED_LENGTH: /* Make sure the length is what it's supposed to be. */ if (subneg_len - iac_data != options[opt_byte].optlen) { - expert_add_info_format(pinfo, option_item, PI_PROTOCOL, PI_WARN, "Suboption parameter length is %d, should be %d", - subneg_len, options[opt_byte].optlen); + expert_add_info_format_text(pinfo, option_item, &ei_telnet_suboption_length, "Suboption parameter length is %d, should be %d", subneg_len, options[opt_byte].optlen); return offset; } break; @@ -1589,8 +1598,7 @@ telnet_sub_option(packet_info *pinfo, proto_tree *option_tree, proto_item *optio case VARIABLE_LENGTH: /* Make sure the length is greater than the minimum. */ if (subneg_len - iac_data < options[opt_byte].optlen) { - expert_add_info_format(pinfo, option_item, PI_PROTOCOL, PI_WARN, "Suboption parameter length is %d, should be at least %d", - subneg_len, options[opt_byte].optlen); + expert_add_info_format_text(pinfo, option_item, &ei_telnet_suboption_length, "Suboption parameter length is %d, should be at least %d", subneg_len, options[opt_byte].optlen); return offset; } break; @@ -2016,10 +2024,30 @@ proto_register_telnet(void) &ett_comport_subopt }; + static ei_register_info ei[] = { + { &ei_telnet_invalid_subcommand, { "telnet.invalid_subcommand", PI_PROTOCOL, PI_WARN, "Invalid subcommand", EXPFILL }}, + { &ei_telnet_invalid_baud_rate, { "telnet.invalid_baud_rate", PI_PROTOCOL, PI_WARN, "Invalid Baud Rate", EXPFILL }}, + { &ei_telnet_invalid_data_size, { "telnet.invalid_data_size", PI_PROTOCOL, PI_WARN, "Invalid Data Size", EXPFILL }}, + { &ei_telnet_invalid_parity, { "telnet.invalid_parity", PI_PROTOCOL, PI_WARN, "Invalid Parity Packet", EXPFILL }}, + { &ei_telnet_invalid_stop, { "telnet.invalid_stop", PI_PROTOCOL, PI_WARN, "Invalid Stop Packet", EXPFILL }}, + { &ei_telnet_invalid_control, { "telnet.invalid_control", PI_PROTOCOL, PI_WARN, "Invalid Control Packet", EXPFILL }}, + { &ei_telnet_invalid_linestate, { "telnet.invalid_linestate", PI_PROTOCOL, PI_WARN, "Invalid linestate", EXPFILL }}, + { &ei_telnet_invalid_modemstate, { "telnet.invalid_modemstate", PI_PROTOCOL, PI_WARN, "Invalid Modemstate", EXPFILL }}, + { &ei_telnet_invalid_purge, { "telnet.invalid_purge", PI_PROTOCOL, PI_WARN, "Invalid Purge Packet", EXPFILL }}, + { &ei_telnet_kerberos_blob_too_long, { "telnet.kerberos_blob_too_long", PI_PROTOCOL, PI_NOTE, "Kerberos blob too long to dissect", EXPFILL }}, + { &ei_telnet_enc_cmd_unknown, { "telnet.enc.cmd.unknown", PI_PROTOCOL, PI_WARN, "Unknown encryption command", EXPFILL }}, + { &ei_telnet_suboption_length, { "telnet.suboption_length.invalid", PI_PROTOCOL, PI_WARN, "Bogus suboption data", EXPFILL }}, + }; + + expert_module_t* expert_telnet; + proto_telnet = proto_register_protocol("Telnet", "TELNET", "telnet"); proto_register_field_array(proto_telnet, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_telnet = expert_register_protocol(proto_telnet); + expert_register_field_array(expert_telnet, ei, array_length(ei)); + telnet_handle = register_dissector("telnet", dissect_telnet, proto_telnet); } |