diff options
Diffstat (limited to 'asn1/h248/packet-h248-template.c')
-rw-r--r-- | asn1/h248/packet-h248-template.c | 117 |
1 files changed, 109 insertions, 8 deletions
diff --git a/asn1/h248/packet-h248-template.c b/asn1/h248/packet-h248-template.c index 251689a1c2..4adf7b48ed 100644 --- a/asn1/h248/packet-h248-template.c +++ b/asn1/h248/packet-h248-template.c @@ -41,6 +41,8 @@ static int hf_h248_pkg_name = -1; static int hf_248_pkg_param = -1; static int hf_h248_event_name = -1; static int hf_h248_signal_name = -1; +static int hf_h248_signal_code = -1; +static int hf_h248_event_code = -1; static int hf_h248_pkg_bcp_BNCChar_PDU = -1; @@ -591,6 +593,76 @@ static const h248_pkg_sig_t no_signal = { 0, &hf_h248_no_sig, &ett_h248_no_sig, static const h248_pkg_param_t no_param = { 0, &hf_h248_param, h248_param_item, NULL }; static const h248_pkg_evt_t no_event = { 0, &hf_h248_no_evt, &ett_h248_no_evt, NULL, NULL }; +static GPtrArray* packages = NULL; + +extern void h248_param_PkgdName(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u _U_, void* dissector_hdl) { + tvbuff_t *new_tvb = NULL; + proto_tree *package_tree=NULL; + guint16 name_major, name_minor; + int old_offset; + const h248_package_t* pkg = NULL; + guint i; + gint8 class; + gboolean pc, ind; + gint32 tag; + guint32 len; + int offset = 0; + + old_offset=offset; + offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &class, &pc, &tag); + offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, &ind); + + if( (class!=BER_CLASS_UNI) + ||(tag!=BER_UNI_TAG_OCTETSTRING) ){ + proto_tree_add_text(tree, tvb, offset-2, 2, "H.248 BER Error: OctetString expected but Class:%d PC:%d Tag:%d was unexpected", class, pc, tag); + return; + } + + new_tvb = tvb_new_subset(tvb,offset,len,len); + + if (new_tvb) { + /* this field is always 4 bytes so just read it into two integers */ + name_major=tvb_get_ntohs(new_tvb, 0); + name_minor=tvb_get_ntohs(new_tvb, 2); + + /* do the prettification */ + proto_item_append_text(ber_last_created_item, " %s (%04x)", val_to_str(name_major, package_name_vals, "Unknown Package"), name_major); + + if(tree){ + proto_item* pi; + const gchar* strval; + + package_tree = proto_item_add_subtree(ber_last_created_item, ett_packagename); + proto_tree_add_uint(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major); + + for(i=0; i < packages->len; i++) { + pkg = g_ptr_array_index(packages,i); + + if (name_major == pkg->id) { + break; + } else { + pkg = NULL; + } + } + + if (! pkg ) pkg = &no_package; + + + pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor); + + if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + strval = ep_strdup_printf("%s (%d)",strval,name_minor); + } else { + strval = ep_strdup_printf("Unknown (%d)",name_minor); + } + + proto_item_set_text(pi,"Parameter: %s", strval); + } + + } +} + + static int dissect_h248_trx_id(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32* trx_id_p) { guint64 trx_id = 0; gint8 class; @@ -678,8 +750,6 @@ static int dissect_h248_ctx_id(gboolean implicit_tag, packet_info *pinfo, proto_ return offset; } -static GPtrArray* packages = NULL; - void h248_register_package(const h248_package_t* pkg) { if (! packages) packages = g_ptr_array_new(); @@ -748,7 +818,6 @@ static int dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offse return offset; } - static int dissect_h248_EventName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) { tvbuff_t *new_tvb; proto_tree *package_tree=NULL; @@ -772,7 +841,7 @@ static int dissect_h248_EventName(gboolean implicit_tag, tvbuff_t *tvb, int offs if(tree){ package_tree = proto_item_add_subtree(ber_last_created_item, ett_packagename); } - proto_tree_add_uint(package_tree, hf_h248_event_name, tvb, offset-4, 4, packageandid); + proto_tree_add_uint(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major); for(i=0; i < packages->len; i++) { @@ -803,6 +872,19 @@ static int dissect_h248_EventName(gboolean implicit_tag, tvbuff_t *tvb, int offs curr_info.evt = evt; + { + proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_event_code, tvb, offset-2, 2, name_minor); + const gchar* strval; + + if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + strval = ep_strdup_printf("%s (%d)",strval,name_minor); + } else { + strval = ep_strdup_printf("Unknown (%d)",name_minor); + } + + proto_item_set_text(pi,"Event ID: %s", strval); + } + } else { curr_info.pkg = &no_package; curr_info.evt = &no_event; @@ -836,7 +918,7 @@ static int dissect_h248_SignalName(gboolean implicit_tag , tvbuff_t *tvb, int of if(tree){ package_tree = proto_item_add_subtree(ber_last_created_item, ett_packagename); } - proto_tree_add_uint(package_tree, hf_h248_signal_name, tvb, offset-4, 4, packageandid); + proto_tree_add_uint(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major); for(i=0; i < packages->len; i++) { pkg = g_ptr_array_index(packages,i); @@ -866,6 +948,19 @@ static int dissect_h248_SignalName(gboolean implicit_tag , tvbuff_t *tvb, int of curr_info.sig = &no_signal; } + { + proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_signal_code, tvb, offset-2, 2, name_minor); + const gchar* strval; + + if (pkg->signal_names && ( strval = match_strval(name_minor, pkg->signal_names) )) { + strval = ep_strdup_printf("%s (%d)",strval,name_minor); + } else { + strval = ep_strdup_printf("Unknown (%d)",name_minor); + } + + proto_item_set_text(pi,"Signal ID: %s", strval); + } + } else { curr_info.pkg = &no_package; curr_info.sig = &no_signal; @@ -1845,6 +1940,12 @@ void proto_register_h248(void) { { &hf_248_pkg_param, { "Parameter ID", "h248.package_paramid", FT_UINT16, BASE_HEX, NULL, 0, "Parameter ID", HFILL }}, + { &hf_h248_signal_code, { + "Signal ID", "h248.package_signalid", FT_UINT16, BASE_HEX, + NULL, 0, "Parameter ID", HFILL }}, + { &hf_h248_event_code, { + "Event ID", "h248.package_eventid", FT_UINT16, BASE_HEX, + NULL, 0, "Parameter ID", HFILL }}, { &hf_h248_event_name, { "Package and Event name", "h248.event_name", FT_UINT32, BASE_HEX, VALS(event_name_vals), 0, "Package", HFILL }}, @@ -1920,9 +2021,9 @@ void proto_register_h248(void) { &ett_ctx_cmds, &ett_ctx_terms, &ett_ctx_term, - &ett_h248_no_pkg, - &ett_h248_no_sig, - &ett_h248_no_evt, + &ett_h248_no_pkg, + &ett_h248_no_sig, + &ett_h248_no_evt, #include "packet-h248-ettarr.c" }; |