diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2015-05-22 14:18:19 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-05-22 16:11:45 +0000 |
commit | a34d696377afc2b4eaee5710c385292da613510c (patch) | |
tree | fd9bbef36356d0b8de68410b3192982a391f875a /asn1 | |
parent | 3bc42dbf8e5c63a7a85e6d14d2d2bd3636a6dc81 (diff) |
p1: Fixed do_address for extension attributes
This is not an optimal solution, but fixes the reported problem.
The do_address functionality should probably be rewritten to
only use pinfo for storing data.
Bug: 11210
Ping-Bug: 8515
Change-Id: I2625cc4044ab93b6e943a3c2d2ffd1b26149da29
Reviewed-on: https://code.wireshark.org/review/8585
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/p1/p1.cnf | 5 | ||||
-rw-r--r-- | asn1/p1/packet-p1-template.c | 24 |
2 files changed, 25 insertions, 4 deletions
diff --git a/asn1/p1/p1.cnf b/asn1/p1/p1.cnf index 379430a33b..cc2db23836 100644 --- a/asn1/p1/p1.cnf +++ b/asn1/p1/p1.cnf @@ -576,6 +576,10 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" #.FN_BODY ExtensionAttribute/extension-attribute-value proto_item_append_text(tree, " (%%s)", val_to_str(actx->external.indirect_reference, p1_ExtensionAttributeType_vals, "extension-attribute-type %%d")); + if (!actx->pinfo->private_table) { + actx->pinfo->private_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + } + g_hash_table_insert(actx->pinfo->private_table, (gpointer)P1_ADDRESS_CTX, actx->subtree.tree_ctx); if (dissector_try_uint(p1_extension_attribute_dissector_table, actx->external.indirect_reference, tvb, actx->pinfo, tree)) { offset =tvb_reported_length(tvb); } else { @@ -587,6 +591,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" offset = dissect_unknown_ber(actx->pinfo, tvb, offset, next_tree); expert_add_info(actx->pinfo, item, &ei_p1_unknown_extension_attribute_type); } + g_hash_table_steal(actx->pinfo->private_table, (gpointer)P1_ADDRESS_CTX); #.FN_BODY RefusedOperation/refused-argument/refused-extension diff --git a/asn1/p1/packet-p1-template.c b/asn1/p1/packet-p1-template.c index 49b4fee2dc..75054ea736 100644 --- a/asn1/p1/packet-p1-template.c +++ b/asn1/p1/packet-p1-template.c @@ -86,6 +86,7 @@ static dissector_table_t p1_tokendata_dissector_table; #include "packet-p1-table.c" /* operation and error codes */ +#define P1_ADDRESS_CTX "p1-address-ctx" typedef struct p1_address_ctx { gboolean do_address; const char *content_type_id; @@ -105,9 +106,25 @@ static void set_do_address(asn1_ctx_t* actx, gboolean do_address) ctx->do_address = do_address; } +static p1_address_ctx_t *get_do_address_ctx(asn1_ctx_t* actx) +{ + p1_address_ctx_t* ctx = NULL; + + if (actx->pinfo->private_table) { + /* First check if called from an extension attribute */ + ctx = g_hash_table_lookup(actx->pinfo->private_table, (gpointer)P1_ADDRESS_CTX); + } + + if (!ctx) { + ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + } + + return ctx; +} + static void do_address(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { - p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + p1_address_ctx_t* ctx = get_do_address_ctx(actx); if (ctx && ctx->do_address) { if (addr) { @@ -117,13 +134,12 @@ static void do_address(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) wmem_strbuf_append(ctx->oraddress, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); } } - } static void do_address_str(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; - p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + p1_address_ctx_t* ctx = get_do_address_ctx(actx); do_address(addr, tvb_string, actx); @@ -134,7 +150,7 @@ static void do_address_str(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* a static void do_address_str_tree(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx, proto_tree* tree) { wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; - p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + p1_address_ctx_t* ctx = get_do_address_ctx(actx); do_address(addr, tvb_string, actx); |