diff options
-rw-r--r-- | epan/dissectors/packet-radius.c | 24 | ||||
-rw-r--r-- | epan/proto.h | 3 |
2 files changed, 14 insertions, 13 deletions
diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index 97ae20e8d7..0643a0f923 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -1357,6 +1357,7 @@ vsa_buffer_table_destroy(void *table) } } +static void register_radius_fields(const char *); void dissect_attribute_value_pairs(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, guint length) @@ -1371,8 +1372,8 @@ dissect_attribute_value_pairs(proto_tree *tree, packet_info *pinfo, tvbuff_t *tv GHashTable *vsa_buffer_table = NULL; - /* Forces load of header fields, if not already done so */ - DISSECTOR_ASSERT(proto_registrar_get_byname("radius.code")); + if (hf_radius_code == -1) + register_radius_fields(""); /* * In case we throw an exception, clean up whatever stuff we've @@ -1763,8 +1764,6 @@ is_radius(tvbuff_t *tvb) return TRUE; } -static void register_radius_fields(const char *); - /* * returns true if the response authenticator is valid * input: tvb of the reponse, corresponding request authenticator @@ -1846,16 +1845,15 @@ dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ val_to_str_ext_const(rh.rh_code, &radius_pkt_type_codes_ext, "Unknown Packet"), rh.rh_code, rh.rh_ident, rh.rh_pktlength); - if (tree) { - /* Forces load of header fields, if not already done so */ - DISSECTOR_ASSERT(proto_registrar_get_byname("radius.code")); + /* Load header fields if not already done */ + if (hf_radius_code == -1) + register_radius_fields(""); - ti = proto_tree_add_item(tree, proto_radius, tvb, 0, rh.rh_pktlength, ENC_NA); - radius_tree = proto_item_add_subtree(ti, ett_radius); - proto_tree_add_uint(radius_tree, hf_radius_code, tvb, 0, 1, rh.rh_code); - proto_tree_add_uint_format(radius_tree, hf_radius_id, tvb, 1, 1, rh.rh_ident, - "Packet identifier: 0x%01x (%d)", rh.rh_ident, rh.rh_ident); - } + ti = proto_tree_add_item(tree, proto_radius, tvb, 0, rh.rh_pktlength, ENC_NA); + radius_tree = proto_item_add_subtree(ti, ett_radius); + proto_tree_add_uint(radius_tree, hf_radius_code, tvb, 0, 1, rh.rh_code); + proto_tree_add_uint_format(radius_tree, hf_radius_id, tvb, 1, 1, rh.rh_ident, + "Packet identifier: 0x%01x (%d)", rh.rh_ident, rh.rh_ident); /* * Make sure the length is sane. diff --git a/epan/proto.h b/epan/proto.h index 54c72a10e8..7d6ce083c2 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -2080,6 +2080,9 @@ proto_deregister_protocol(const char *short_name); typedef void (*prefix_initializer_t)(const char* match); /** Register a new prefix for delayed initialization of field arrays + Note that the initializer function MAY NOT be called before the dissector + is first called. That is, dissectors using this function must be prepared + to call the initializer before beginning dissection. @param prefix the prefix for the new protocol @param initializer function that will initialize the field array for the given prefix */ WS_DLL_PUBLIC void |