diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-03-01 02:48:10 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-03-01 02:48:10 +0000 |
commit | d8a08e186c8eec199c6b94466fc0210ca4f15045 (patch) | |
tree | 6009602e8f6b5b3bebf67bfea15142b33d711b2d /packet-snmp.c | |
parent | 84b6b76cf3910dd07d44907f1cb7bb04b09f94c1 (diff) |
Add a routine to "asn1.c" to translate ASN1_ERR_ values to strings. Use
that in the SNMP dissector.
Check the return values of ASN.1 routines in the LDAP dissector, and
have all the subroutines in that disesctor that can return error
indications return ASN1_ERR_ values.
Have the routines that can supply a pointer to a newly-created
protocol-tree item use the right type for items ("proto_item *", not
"proto_tree *", even though they are, at least currently, typedefs for
the same type), and use "proto_item" for the type of the item a pointer
to which is passed to those routines.
Before calling those routines, set the item pointer to null, in case the
routine fails.
Don't check the return value of "parse_filter_strings()" against -1 -
that routine can't return -1.
svn path=/trunk/; revision=4833
Diffstat (limited to 'packet-snmp.c')
-rw-r--r-- | packet-snmp.c | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/packet-snmp.c b/packet-snmp.c index f37db104e0..cab3b4c8d2 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -8,7 +8,7 @@ * * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u. * - * $Id: packet-snmp.c,v 1.80 2002/02/19 09:35:45 guy Exp $ + * $Id: packet-snmp.c,v 1.81 2002/03/01 02:48:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -531,34 +531,9 @@ static void dissect_snmp_parse_error(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *field_name, int ret) { - const gchar *errstr; + char *errstr; - switch (ret) { - - case ASN1_ERR_EOC_MISMATCH: - errstr = "EOC mismatch"; - break; - - case ASN1_ERR_WRONG_TYPE: - errstr = "Wrong type for that item"; - break; - - case ASN1_ERR_LENGTH_NOT_DEFINITE: - errstr = "Length was indefinite"; - break; - - case ASN1_ERR_LENGTH_MISMATCH: - errstr = "Length mismatch"; - break; - - case ASN1_ERR_WRONG_LENGTH_FOR_TYPE: - errstr = "Wrong length for that item's type"; - break; - - default: - errstr = "Unknown error"; - break; - } + errstr = asn1_err_to_str(ret); if (check_col(pinfo->cinfo, COL_INFO)) { col_add_fstr(pinfo->cinfo, COL_INFO, @@ -567,7 +542,8 @@ dissect_snmp_parse_error(tvbuff_t *tvb, int offset, packet_info *pinfo, if (tree != NULL) { proto_tree_add_text(tree, tvb, offset, 0, "ERROR: Couldn't parse %s: %s", field_name, errstr); - call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree); + call_dissector(data_handle, + tvb_new_subset(tvb, offset, -1, -1), pinfo, tree); } } |