diff options
author | Anders Broman <anders.broman@ericsson.com> | 2005-06-07 05:49:06 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2005-06-07 05:49:06 +0000 |
commit | 86a56ba7cccfa5fec459904a57fcd7807cd8ef49 (patch) | |
tree | 35b9d1e26d85804314854f73fa1ad0ba15d32179 /epan | |
parent | 75ab9e7ad2438f5f7022a742807cbb48fd81bc21 (diff) |
From Tim Endean:
- I have had to make some changes to packet-ber to allow for PRIVATE and APPLICATION tags.
- Both ANSI and ITU variants supported without configuration.
- Asn.1 dissectors can now register using an OID value as well as an SSN, the oid it tried first.
svn path=/trunk/; revision=14572
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-ber.c | 20 | ||||
-rw-r--r-- | epan/dissectors/packet-ber.h | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-gsm_map.c | 98 | ||||
-rw-r--r-- | epan/dissectors/packet-tcap.c | 4807 | ||||
-rw-r--r-- | epan/dissectors/packet-tcap.h | 38 |
5 files changed, 2486 insertions, 2480 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index d783cbb0ab..445f9a60a5 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -136,6 +136,14 @@ dissect_ber_oid_NULL_callback(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_t return; } + +void +register_ber_oid_dissector_handle(char *oid, dissector_handle_t dissector, int proto, char *name) +{ + dissector_add_string("ber.oid", oid, dissector); + g_hash_table_insert(oid_table, oid, name); +} + void register_ber_oid_dissector(char *oid, dissector_t dissector, int proto, char *name) { @@ -145,6 +153,7 @@ register_ber_oid_dissector(char *oid, dissector_t dissector, int proto, char *na dissector_add_string("ber.oid", oid, dissector_handle); g_hash_table_insert(oid_table, oid, name); } + /* Register the oid name to get translation in proto dissection */ void register_ber_oid_name(char *oid, char *name) @@ -167,8 +176,7 @@ get_ber_oid_name(char *oid) * when it is called it is a BAD thing not a good thing. * It can not handle IMPLICIT tags nor indefinite length. */ -static int -dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree) +int dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree) { int start_offset; guint8 class; @@ -467,6 +475,8 @@ printf("OCTET STRING dissect_ber_octet_string(%s) entered\n",name); end_offset=offset+len; /* sanity check: we only handle Constructed Universal Sequences */ + if ((class!=BER_CLASS_APP)&&(class!=BER_CLASS_PRI)) + if( (class!=BER_CLASS_UNI) ||((tag<BER_UNI_TAG_NumericString)&&(tag!=BER_UNI_TAG_OCTETSTRING)&&(tag!=BER_UNI_TAG_UTF8String)) ){ tvb_ensure_bytes_exist(tvb, offset-2, 2); @@ -578,7 +588,7 @@ name="unnamed"; if(tvb_length_remaining(tvb,offset)>3){ printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n",name,implicit_tag,offset,tvb_length_remaining(tvb,offset),tvb_get_guint8(tvb,offset),tvb_get_guint8(tvb,offset+1),tvb_get_guint8(tvb,offset+2)); }else{ -printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d len:%d\n",name,implicit_tag,len); +printf("INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n",name,implicit_tag); } } #endif @@ -734,6 +744,7 @@ printf("SEQUENCE dissect_ber_sequence(%s) entered\n",name); } /* sanity check: we only handle Constructed Universal Sequences */ + if ((class!=BER_CLASS_APP)&&(class!=BER_CLASS_PRI)) if ((!pc) ||(!implicit_tag&&((class!=BER_CLASS_UNI) ||(tag!=BER_UNI_TAG_SEQUENCE)))) { @@ -795,7 +806,7 @@ ber_sequence_try_again: * { BER_CLASS_CON, 7, BER_FLAGS_OPTIONAL|BER_FLAGS_NOTCHKTAG, dissect_scope }, * and there should not be a NOTCHKTAG here */ - if( (seq->class==BER_CLASS_CON) && (!(seq->flags&BER_FLAGS_NOOWNTAG)) ){ + if( ((seq->class==BER_CLASS_CON)||(seq->class==BER_CLASS_APP)||(seq->class==BER_CLASS_PRI)) && (!(seq->flags&BER_FLAGS_NOOWNTAG)) ){ if( (seq->class!=BER_CLASS_ANY) && (seq->tag!=-1) &&( (seq->class!=class) @@ -1313,6 +1324,7 @@ printf("SQ OF dissect_ber_sq_of(%s) entered\n",name); } /* sanity check: we only handle Constructed Universal Sequences */ + if ((class!=BER_CLASS_APP)&&(class!=BER_CLASS_PRI)) if (!pc ||(!implicit_tag&&((class!=BER_CLASS_UNI) ||(tag!=type)))) { diff --git a/epan/dissectors/packet-ber.h b/epan/dissectors/packet-ber.h index 70938f01b7..4e60881ce1 100644 --- a/epan/dissectors/packet-ber.h +++ b/epan/dissectors/packet-ber.h @@ -80,7 +80,7 @@ typedef int (*ber_callback)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, */ extern int get_ber_identifier(tvbuff_t *tvb, int offset, gint8 *class, gboolean *pc, gint32 *tag); extern int dissect_ber_identifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint8 *class, gboolean *pc, gint32 *tag); - +extern int dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree); /* this function dissects the identifier octer of the BER TLV. * We only handle (TAGs and) LENGTHs that fit inside 32 bit integers. */ @@ -164,6 +164,7 @@ extern proto_item *ber_last_created_item; extern proto_item *get_ber_last_created_item(void); int call_ber_oid_callback(char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree); +void register_ber_oid_dissector_handle(char *oid, dissector_handle_t dissector, int proto, char *name); void register_ber_oid_dissector(char *oid, dissector_t dissector, int proto, char *name); void register_ber_oid_name(char *oid, char *name); void dissect_ber_oid_NULL_callback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index 01822d4f10..3f0fe66f03 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -51,7 +51,7 @@ #include "packet-q931.h" #include "packet-gsm_map.h" -#define PNAME "GSM_MobileAPplication" +#define PNAME "GSM Mobile Application" #define PSNAME "GSM_MAP" #define PFNAME "gsm_map" @@ -10788,7 +10788,7 @@ static int dissect_invokeData(packet_info *pinfo, proto_tree *tree, tvbuff_t *tv offset=dissect_gsm_map_Ss_ForBS(FALSE, tvb, offset, pinfo, tree, -1); break; case 14: /*interrogateSS*/ - offset=dissect_gsm_map_InterrogateSS_Res(FALSE, tvb, offset, pinfo, tree, -1); + offset=dissect_gsm_map_Ss_ForBS(FALSE, tvb, offset, pinfo, tree, -1); break; case 17: /*registerPassword*/ offset=dissect_gsm_map_Ss_Code(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_ss_Code); @@ -10886,7 +10886,7 @@ static int dissect_invokeData(packet_info *pinfo, proto_tree *tree, tvbuff_t *tv offset=dissect_gsm_map_RestoreDataArg(FALSE, tvb, offset, pinfo, tree, -1); break; case 58: /*sendIMSI*/ - offset=dissect_gsm_map_Msisdn(FALSE, tvb, offset, pinfo, tree, -1); + offset=dissect_gsm_map_Msisdn(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_msisdn); break; case 59: /*processUnstructuredSS-Request*/ offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1); @@ -11368,7 +11368,7 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } top_tree = parent_tree; - + dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle); /* create display subtree for the protocol */ if(parent_tree){ item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE); @@ -11590,6 +11590,50 @@ void proto_reg_handoff_gsm_map(void) { if (!map_prefs_initialized) { map_prefs_initialized = TRUE; map_handle = create_dissector_handle(dissect_gsm_map, proto_gsm_map); + register_ber_oid_dissector_handle("0.4.0.0.1.0.1.3", map_handle, proto_gsm_map, "itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version3(3)"); + register_ber_oid_dissector_handle("0.4.0.0.1.0.1.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.2.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.2.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.2.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.3.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.3.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.3.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.5.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.5.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.5.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.10.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reset(10) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.10.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reset(10) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.11.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.11.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.11.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.26.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) imsiRetrieval(26) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.13.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) equipmentMngt(13) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.13.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) equipmentMngt(13) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.14.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.14.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.14.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.15.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) interVlrInfoRetrieval(15) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.16.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.16.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.16.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.17.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) tracing(17) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.17.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) tracing(17) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.18.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkFunctionalSs(18) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.18.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkFunctionalSs(18) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.19.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkUnstructuredSs(19) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.20.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.20.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.20.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.21.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMO-Relay(21) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.21.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) --shortMsgRelay--21 version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.23.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgAlert(23) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.23.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgAlert(23) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.24.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mwdMngt(24) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.24.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mwdMngt(24) version1(1)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.25.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMT-Relay(25) version3(3)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.25.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMT-Relay(25) version2(2)" ); + register_ber_oid_dissector_handle("0.4.0.0.1.0.25.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) msPurging(27) version2(2)" ); + } else { range_foreach(ssn_range, range_delete_callback); @@ -14731,50 +14775,8 @@ void proto_register_gsm_map(void) { BASE_DEC); gsm_map_tap = register_tap("gsm_map"); - register_ber_oid_name("0.4.0.0.1.0.1.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.1.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.2.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.2.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.2.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.3.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.3.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.3.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.5.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.5.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.5.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.10.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reset(10) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.10.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reset(10) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.11.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.11.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.11.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.26.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) imsiRetrieval(26) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.13.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) equipmentMngt(13) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.13.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) equipmentMngt(13) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.14.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.14.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.14.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.15.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) interVlrInfoRetrieval(15) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.16.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.16.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.16.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.17.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) tracing(17) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.17.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) tracing(17) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.18.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkFunctionalSs(18) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.18.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkFunctionalSs(18) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.19.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkUnstructuredSs(19) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.20.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.20.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.20.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.21.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMO-Relay(21) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.21.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) --shortMsgRelay--21 version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.23.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgAlert(23) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.23.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgAlert(23) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.24.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mwdMngt(24) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.24.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mwdMngt(24) version1(1)" ); - register_ber_oid_name("0.4.0.0.1.0.25.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMT-Relay(25) version3(3)" ); - register_ber_oid_name("0.4.0.0.1.0.25.2","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMT-Relay(25) version2(2)" ); - register_ber_oid_name("0.4.0.0.1.0.25.1","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) msPurging(27) version2(2)" ); - + //register_ber_oid_name("0.4.0.0.1.0.1.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version3(3)" ); + /* /* Register our configuration options, particularly our ssn:s */ /* Set default SSNs */ range_convert_str(&global_ssn_range, "6-9", MAX_SSN); diff --git a/epan/dissectors/packet-tcap.c b/epan/dissectors/packet-tcap.c index cddce3126f..36f4c41f63 100644 --- a/epan/dissectors/packet-tcap.c +++ b/epan/dissectors/packet-tcap.c @@ -1,26 +1,20 @@ -/* packet-tcap.c - * Routines for TCAP dissection - * - * Copyright 2000, Samuel Qu <samuel.qu [AT] utstar.com>, - * - * Michael Lum <mlum [AT] telostech.com>, - * Modified for ANSI TCAP support and many changes for - * EOC matching. (2003) - * - * (append your name here for newer version) +/* Do not modify this file. */ +/* It is created automatically by the ASN.1 to Ethereal dissector compiler */ +/* .\packet-tcap.c */ +/* ../../tools/asn2eth.py -X -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */ + +/* Input file: packet-tcap-template.c */ + +/* packet-tcap-template.c + * Routines for TCAP + * Copyright 2004 - 2005, Tim Endean <endeant@hotmail.com> + * Built from the gsm-map dissector Copyright 2004 - 2005, Anders Broman <anders.broman@ericsson.com> * * $Id$ - * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED" - * is a dissector file; if you just copied this from README.developer, - * don't bother with the "Copied from" - you don't even need to put - * in a "Copied from" if you copied an existing dissector, especially - * if the bulk of the code in the new dissector is your code) - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -33,2764 +27,2135 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * References: ETSI 300 374 */ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include <glib.h> +#include <epan/packet.h> +#include <epan/prefs.h> +#include <epan/conversation.h> + #include <stdio.h> -#include <stdlib.h> #include <string.h> -#include <gmodule.h> +#include <epan/asn1.h> +#include "packet-ber.h" +#include "packet-tcap.h" -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif +#define PNAME "Transaction Capabilities Application Part" +#define PSNAME "TCAP" +#define PFNAME "tcap" -#ifdef HAVE_NETINET_IN_H -# include <netinet/in.h> -#endif +/* Initialize the protocol and registered fields */ +int proto_tcap = -1; +static int hf_tcap_tag = -1; +static int hf_tcap_length = -1; +static int hf_tcap_data = -1; + +/*--- Included file: packet-tcap-hf.c ---*/ + +static int hf_tcap_dialogueRequest = -1; /* AARQ_apdu */ +static int hf_tcap_dialogueResponse = -1; /* AARE_apdu */ +static int hf_tcap_dialogueAbort = -1; /* ABRT_apdu */ +static int hf_tcap_oid = -1; /* OBJECT_IDENTIFIER */ +static int hf_tcap_dialog = -1; /* Dialog1 */ +static int hf_tcap_useroid = -1; /* UserInfoOID */ +static int hf_tcap_externuserinfo = -1; /* ExternUserInfo */ +static int hf_tcap_protocol_versionrq = -1; /* T_protocol_versionrq */ +static int hf_tcap_application_context_name = -1; /* Applicationcontext */ +static int hf_tcap_user_information = -1; /* User_information */ +static int hf_tcap_protocol_versionre = -1; /* T_protocol_versionre */ +static int hf_tcap_result = -1; /* Associate_result */ +static int hf_tcap_result_source_diagnostic = -1; /* Associate_source_diagnostic */ +static int hf_tcap_reasonrq = -1; /* Release_request_reason */ +static int hf_tcap_reasonre = -1; /* Release_response_reason */ +static int hf_tcap_abort_source = -1; /* ABRT_source */ +static int hf_tcap_dialogue_service_user = -1; /* T_dialogue_service_user */ +static int hf_tcap_dialogue_service_provider = -1; /* T_dialogue_service_provider */ +static int hf_tcap_unidialoguePDU = -1; /* AUDT_apdu */ +static int hf_tcap_protocol_version3 = -1; /* T_protocol_version3 */ +static int hf_tcap_unidirectional = -1; /* Unidirectional */ +static int hf_tcap_begin = -1; /* Begin */ +static int hf_tcap_end = -1; /* End */ +static int hf_tcap_continue = -1; /* Continue */ +static int hf_tcap_abort = -1; /* Abort */ +static int hf_tcap_ansiunidirectional = -1; /* UniTransactionPDU */ +static int hf_tcap_ansiqueryWithPerm = -1; /* TransactionPDU */ +static int hf_tcap_ansiqueryWithoutPerm = -1; /* TransactionPDU */ +static int hf_tcap_ansiresponse = -1; /* TransactionPDU */ +static int hf_tcap_ansiconversationWithPerm = -1; /* TransactionPDU */ +static int hf_tcap_ansiconversationWithoutPerm = -1; /* TransactionPDU */ +static int hf_tcap_ansiabort = -1; /* AbortPDU */ +static int hf_tcap_dialoguePortion = -1; /* DialoguePortion */ +static int hf_tcap_components = -1; /* ComponentPortion */ +static int hf_tcap_otid = -1; /* OrigTransactionID */ +static int hf_tcap_dtid = -1; /* DestTransactionID */ +static int hf_tcap_reason = -1; /* Reason */ +static int hf_tcap_p_abortCause = -1; /* P_AbortCause */ +static int hf_tcap_u_abortCause = -1; /* DialoguePortion */ +static int hf_tcap_ComponentPortion_item = -1; /* Component */ +static int hf_tcap_invoke = -1; /* Invoke */ +static int hf_tcap_returnResultLast = -1; /* ReturnResult */ +static int hf_tcap_returnError = -1; /* ReturnError */ +static int hf_tcap_reject = -1; /* Reject */ +static int hf_tcap_returnResultNotLast = -1; /* ReturnResult */ +static int hf_tcap_invokeID = -1; /* InvokeIdType */ +static int hf_tcap_linkedID = -1; /* InvokeIdType */ +static int hf_tcap_operationCode = -1; /* OperationCode */ +static int hf_tcap_parameter = -1; /* Parameter */ +static int hf_tcap_resultretres = -1; /* T_resultretres */ +static int hf_tcap_errorCode = -1; /* ErrorCode */ +static int hf_tcap_invokeIDRej = -1; /* T_invokeIDRej */ +static int hf_tcap_derivable = -1; /* InvokeIdType */ +static int hf_tcap_not_derivable = -1; /* NULL */ +static int hf_tcap_problem = -1; /* T_problem */ +static int hf_tcap_generalProblem = -1; /* GeneralProblem */ +static int hf_tcap_invokeProblem = -1; /* InvokeProblem */ +static int hf_tcap_returnResultProblem = -1; /* ReturnResultProblem */ +static int hf_tcap_returnErrorProblem = -1; /* ReturnErrorProblem */ +static int hf_tcap_localValue = -1; /* INTEGER */ +static int hf_tcap_globalValue = -1; /* OBJECT_IDENTIFIER */ +static int hf_tcap_identifier = -1; /* TransactionID */ +static int hf_tcap_dialoguePortionansi = -1; /* DialoguePortionANSI */ +static int hf_tcap_componentPortion = -1; /* ComponentSequence */ +static int hf_tcap_causeInformation = -1; /* T_causeInformation */ +static int hf_tcap_abortCause = -1; /* P_Abort_cause */ +static int hf_tcap_userInformation = -1; /* UserInformation */ +static int hf_tcap_version = -1; /* ProtocolVersion */ +static int hf_tcap_applicationContext = -1; /* T_applicationContext */ +static int hf_tcap_integerApplicationId = -1; /* IntegerApplicationContext */ +static int hf_tcap_objectApplicationId = -1; /* ObjectIDApplicationContext */ +static int hf_tcap_securityContext = -1; /* T_securityContext */ +static int hf_tcap_integerSecurityId = -1; /* INTEGER */ +static int hf_tcap_objectSecurityId = -1; /* OBJECT_IDENTIFIER */ +static int hf_tcap_confidentiality = -1; /* Confidentiality */ +static int hf_tcap_confidentialityId = -1; /* T_confidentialityId */ +static int hf_tcap_integerConfidentialityId = -1; /* INTEGER */ +static int hf_tcap_objectConfidentialityId = -1; /* OBJECT_IDENTIFIER */ +static int hf_tcap_ComponentSequence_item = -1; /* ComponentPDU */ +static int hf_tcap_invokeLastansi = -1; /* InvokePDU */ +static int hf_tcap_returnResultLastansi = -1; /* ReturnResultPDU */ +static int hf_tcap_returnErroransi = -1; /* ReturnErrorPDU */ +static int hf_tcap_rejectansi = -1; /* RejectPDU */ +static int hf_tcap_invokeNotLastansi = -1; /* InvokePDU */ +static int hf_tcap_returnResultNotLastansi = -1; /* ReturnResultPDU */ +static int hf_tcap_componentIDs = -1; /* OCTET_STRING_SIZE_0_2 */ +static int hf_tcap_parameterinv = -1; /* ANSIparamch */ +static int hf_tcap_ansiparams = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams1 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams2 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams3 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams4 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams5 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams6 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams7 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams8 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams9 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams10 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams11 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams12 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams13 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams14 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams15 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams16 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams17 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams18 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams19 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams20 = -1; /* ANSIParameters */ +static int hf_tcap_ansiparams21 = -1; /* ANSIParameters */ +static int hf_tcap_componentID = -1; /* ComponentID */ +static int hf_tcap_parameterrr = -1; /* ANSIparamch */ +static int hf_tcap_parameterre = -1; /* ANSIparamch */ +static int hf_tcap_rejectProblem = -1; /* ProblemPDU */ +static int hf_tcap_parameterrj = -1; /* ANSIparamch */ +static int hf_tcap_national = -1; /* INTEGER_M32768_32767 */ +static int hf_tcap_private = -1; /* INTEGER */ +static int hf_tcap_nationaler = -1; /* INTEGER_M32768_32767 */ +static int hf_tcap_privateer = -1; /* INTEGER */ +/* named bits */ +static int hf_tcap_T_protocol_versionrq_version1 = -1; +static int hf_tcap_T_protocol_versionre_version1 = -1; +static int hf_tcap_T_protocol_version3_version1 = -1; + +/*--- End of included file: packet-tcap-hf.c ---*/ + +static guint tcap_itu_ssn = 106; + +static guint global_tcap_itu_ssn = 1; -#include <glib.h> +/* Initialize the subtree pointers */ +static gint ett_tcap = -1; +static gint ett_param = -1; -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif -#include <epan/packet.h> -#include <epan/prefs.h> -#include <epan/asn1.h> -#include "packet-tcap.h" -#include "packet-ber.h" +/*--- Included file: packet-tcap-ett.c ---*/ + +static gint ett_tcap_DialoguePDU = -1; +static gint ett_tcap_ExternalPDU = -1; +static gint ett_tcap_UserInformation = -1; +static gint ett_tcap_AARQ_apdu = -1; +static gint ett_tcap_T_protocol_versionrq = -1; +static gint ett_tcap_AARE_apdu = -1; +static gint ett_tcap_T_protocol_versionre = -1; +static gint ett_tcap_RLRQ_apdu = -1; +static gint ett_tcap_RLRE_apdu = -1; +static gint ett_tcap_ABRT_apdu = -1; +static gint ett_tcap_Associate_source_diagnostic = -1; +static gint ett_tcap_UniDialoguePDU = -1; +static gint ett_tcap_AUDT_apdu = -1; +static gint ett_tcap_T_protocol_version3 = -1; +static gint ett_tcap_MessageType = -1; +static gint ett_tcap_Unidirectional = -1; +static gint ett_tcap_Begin = -1; +static gint ett_tcap_End = -1; +static gint ett_tcap_Continue = -1; +static gint ett_tcap_Abort = -1; +static gint ett_tcap_Reason = -1; +static gint ett_tcap_ComponentPortion = -1; +static gint ett_tcap_Component = -1; +static gint ett_tcap_Invoke = -1; +static gint ett_tcap_ReturnResult = -1; +static gint ett_tcap_T_resultretres = -1; +static gint ett_tcap_ReturnError = -1; +static gint ett_tcap_Reject = -1; +static gint ett_tcap_T_invokeIDRej = -1; +static gint ett_tcap_T_problem = -1; +static gint ett_tcap_OPERATION = -1; +static gint ett_tcap_ERROR = -1; +static gint ett_tcap_UniTransactionPDU = -1; +static gint ett_tcap_TransactionPDU = -1; +static gint ett_tcap_AbortPDU = -1; +static gint ett_tcap_T_causeInformation = -1; +static gint ett_tcap_DialoguePortionANSI = -1; +static gint ett_tcap_T_applicationContext = -1; +static gint ett_tcap_T_securityContext = -1; +static gint ett_tcap_Confidentiality = -1; +static gint ett_tcap_T_confidentialityId = -1; +static gint ett_tcap_ComponentSequence = -1; +static gint ett_tcap_ComponentPDU = -1; +static gint ett_tcap_InvokePDU = -1; +static gint ett_tcap_ANSIparamch = -1; +static gint ett_tcap_ReturnResultPDU = -1; +static gint ett_tcap_ReturnErrorPDU = -1; +static gint ett_tcap_RejectPDU = -1; +static gint ett_tcap_OperationCode = -1; +static gint ett_tcap_ErrorCode = -1; + +/*--- End of included file: packet-tcap-ett.c ---*/ -gint tcap_standard = ITU_TCAP_STANDARD; #define MAX_SSN 254 static range_t *global_ssn_range; static range_t *ssn_range; -static dissector_handle_t tcap_handle; - -/* saved pinfo */ static packet_info *g_pinfo = NULL; static proto_tree *g_tcap_tree = NULL; static gboolean g_tcap_ends_def_len = FALSE; -/* Initialize the protocol and registered fields */ -static int proto_tcap = -1; -static int hf_tcap_message_type = -1; -static int hf_ansi_tcap_message_type = -1; -static int hf_tcap_tag = -1; -static int hf_tcap_length = -1; -static int hf_tcap_bytes = -1; -static int hf_tcap_app_con_name = -1; -static int hf_tcap_id = -1; -static int hf_tcap_tid = -1; -static int hf_tcap_ssn = -1; /* faked */ -static int hf_tcap_dlg_type = -1; -static int hf_tcap_int = -1; -static int hf_tcap_oid = -1; - -/* Initialize the subtree pointers */ -static gint ett_tcap = -1; -/* Samuel */ -static gint ett_otid = -1; -static gint ett_dtid = -1; -static gint ett_dlg_portion = -1; -static gint ett_dlg_req = -1; -static gint ett_dlg_rsp = -1; -static gint ett_dlg_abort = -1; -static gint ett_comps_portion = -1; -static gint ett_reason = -1; -static gint ett_component = -1; -static gint ett_problem = -1; -static gint ett_error = -1; -static gint ett_params = -1; -static gint ett_param = -1; -static gint ett_para_portion = -1; +dissector_handle_t tcap_handle; +static dissector_table_t ber_oid_dissector_table=NULL; +static char * cur_oid; +static char * tcapext_oid; +static proto_tree *tcap_top_tree=NULL; static dissector_handle_t data_handle; static dissector_table_t tcap_itu_ssn_dissector_table; /* map use ssn in sccp */ static dissector_table_t tcap_ansi_ssn_dissector_table; /* map use ssn in sccp */ -static gboolean lock_info_col = TRUE; - -/* TCAP transaction message type definition - Samuel */ -#define ST_MSG_TYP_UNI 0x61 /*0b01100001*/ -#define ST_MSG_TYP_BGN 0x62 /*0b01100010*/ -#define ST_MSG_TYP_CNT 0x65 /*0b01100101*/ -#define ST_MSG_TYP_END 0x64 /*0b01100100*/ -#define ST_MSG_TYP_PABT 0x67 /*0b01100111*/ -static const value_string msg_type_strings[] = { - { ST_MSG_TYP_UNI, "TC-UNI" }, - { ST_MSG_TYP_BGN, "TC-BEGIN" }, - { ST_MSG_TYP_CNT, "TC-CONTINUE" }, - { ST_MSG_TYP_END, "TC-END" }, - { ST_MSG_TYP_PABT, "TC-PABORT" }, - { 0, NULL }, -}; - -/* ANSI TCAP transaction message type definition */ -#define ANSI_ST_MSG_TYP_UNI 0xe1 -#define ANSI_ST_MSG_TYP_QWP 0xe2 -#define ANSI_ST_MSG_TYP_QWOP 0xe3 -#define ANSI_ST_MSG_TYP_RSP 0xe4 -#define ANSI_ST_MSG_TYP_CWP 0xe5 -#define ANSI_ST_MSG_TYP_CWOP 0xe6 -#define ANSI_ST_MSG_TYP_ABT 0xf6 -static const value_string ansi_msg_type_strings[] = { - { ANSI_ST_MSG_TYP_UNI, "TC-UNI" }, - { ANSI_ST_MSG_TYP_QWP, "TC-QUERY W PERM" }, - { ANSI_ST_MSG_TYP_QWOP, "TC-QUERY WO PERM" }, - { ANSI_ST_MSG_TYP_RSP, "TC-RESPONSE" }, - { ANSI_ST_MSG_TYP_CWP, "TC-CONV W PERM" }, - { ANSI_ST_MSG_TYP_CWOP, "TC-CONV WO PERM" }, - { ANSI_ST_MSG_TYP_ABT, "TC-ABORT" }, - { 0, NULL }, -}; - -#define ST_ANSI_CMP_TAG 0xe8 -#define ST_ANSI_TID_TAG 0xc7 - -/* TCAP TID tag value - Samuel */ -#define ST_TID_SOURCE 0 -#define ST_TID_DEST 1 -#define ST_ITU_ORG_TID_TAG 0x48 /*0b01001000*/ -#define ST_ITU_DST_TID_TAG 0x49 /*0b01001001*/ -#define ST_ITU_PABT_TAG 0x4a /*0b01001010*/ -#define ST_ITU_DLG_TAG 0x6b -#define ST_ITU_CMP_TAG 0x6c - -static const value_string tid_strings[] = { - { ST_ITU_ORG_TID_TAG, "Source Transaction ID" }, - { ST_ITU_DST_TID_TAG, "Destination Transaction ID" }, - { 0, NULL }, -}; - -/* TCAP dialog type */ -#define TC_DLG_REQ 0x60 -#define TC_DLG_RSP 0x61 -#define TC_DLG_ABRT 0x64 - -static const value_string dlg_type_strings[] = { - { TC_DLG_REQ , "Dialogue Request" }, - { TC_DLG_RSP , "Dialogue Response" }, - { TC_DLG_ABRT, "Dialogue Abort" }, - { 0, NULL }, -}; -const value_string tcap_component_type_str[] = { - { TCAP_COMP_INVOKE, "Invoke" }, - { TCAP_COMP_RRL, "Return Result(L)" }, - { TCAP_COMP_RE, "Return Error" }, - { TCAP_COMP_REJECT, "Reject" }, - { TCAP_COMP_RRN, "Return Result(NL)" }, - { 0, NULL } }; +static int dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset); +static int dissect_tcap_UserInformation(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_); -#define TC_DS_OK 1 -#define TC_DS_FAIL 0 -int -tcap_find_eoc(ASN1_SCK *asn1) -{ - guint saved_offset; - gint prev_offset; - guint tag; - guint len; - gboolean def_len; +/*--- Included file: packet-tcap-fn.c ---*/ - saved_offset = asn1->offset; +/*--- Fields for imported types ---*/ - while (!asn1_eoc(asn1, -1)) - { - prev_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - asn1_length_decode(asn1, &def_len, &len); - if (def_len) - { - asn1->offset += len; - } - else - { - asn1->offset += tcap_find_eoc(asn1); - asn1_eoc_decode(asn1, -1); - } - if (prev_offset >= asn1->offset) - THROW(ReportedBoundsError); - } +static const asn_namedbit T_protocol_versionrq_bits[] = { + { 0, &hf_tcap_T_protocol_versionrq_version1, -1, -1, NULL, NULL }, + { 0, NULL, 0, 0, NULL, NULL } +}; - len = asn1->offset - saved_offset; - asn1->offset = saved_offset; +static int +dissect_tcap_T_protocol_versionrq(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset, + T_protocol_versionrq_bits, hf_index, ett_tcap_T_protocol_versionrq, + NULL); - return(len); + return offset; } - -gboolean -tcap_check_tag(ASN1_SCK *asn1, guint tag) -{ - guint saved_offset, real_tag; - - if (tvb_length_remaining(asn1->tvb, asn1->offset) <= 0) - { - return (FALSE); - } - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &real_tag); - asn1->offset = saved_offset; - return (tag == real_tag); +static int dissect_protocol_versionrq_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_protocol_versionrq(TRUE, tvb, offset, pinfo, tree, hf_tcap_protocol_versionrq); } static int -dissect_tcap_len(ASN1_SCK *asn1, proto_tree *tree, gboolean *def_len, guint *len) -{ - guint saved_offset; - int ret; - - saved_offset = asn1->offset; - *len = 0; - *def_len = FALSE; - ret = asn1_length_decode(asn1, def_len, len); +dissect_tcap_Applicationcontext(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + static char buffer[128]; + cur_oid = buffer; + pinfo->private_data = buffer; + offset = dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset, + hf_index, cur_oid); - if (*def_len) - { - proto_tree_add_uint(tree, hf_tcap_length, asn1->tvb, saved_offset, asn1->offset - saved_offset, *len); - } - else - { - proto_tree_add_text(tree, asn1->tvb, - saved_offset, asn1->offset - saved_offset, "Length: Indefinite"); - } - return TC_DS_OK; + return offset; } - -static int -dissect_tcap_eoc(ASN1_SCK *asn1, proto_tree *tree) -{ - guint saved_offset, ret; - - saved_offset = asn1->offset; - - if (tvb_length_remaining(asn1->tvb, saved_offset) <= 0) - { - return TC_DS_FAIL; - } - - if (!asn1_eoc(asn1, -1)) - { - return TC_DS_FAIL; - } - - ret = asn1_eoc_decode(asn1, -1); - - proto_tree_add_text(tree, asn1->tvb, - saved_offset, asn1->offset - saved_offset, "End of Contents"); - - return TC_DS_OK; +static int dissect_application_context_name(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Applicationcontext(FALSE, tvb, offset, pinfo, tree, hf_tcap_application_context_name); } -static int -dissect_tcap_tag(ASN1_SCK *asn1, proto_tree *tree, guint *tag, gchar * str) -{ - guint saved_offset, real_tag; - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &real_tag); - if ((*tag != (guint) -1) && (real_tag != *tag)) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } - proto_tree_add_uint_format(tree, hf_tcap_tag, asn1->tvb, saved_offset, asn1->offset - saved_offset, - real_tag, str); - return TC_DS_OK; -} static int -dissect_tcap_octet(ASN1_SCK *asn1, proto_tree *tree, gchar * str) -{ - guint saved_offset; - guchar my_oct; - - saved_offset = asn1->offset; - asn1_octet_decode(asn1, &my_oct); - proto_tree_add_uint_format(tree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, - my_oct, "%s %d", str, my_oct); - return TC_DS_OK; +dissect_tcap_User_information(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *parameter_tvb; +tvbuff_t *next_tvb; +guint8 class; + gboolean pc; + guint32 tag; + guint32 len; + guint32 ind_field; + + +offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); +offset = get_ber_length(tree, tvb, offset, &len, &ind_field); +next_tvb = tvb_new_subset(tvb, offset, len, len); +dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_index, + ¶meter_tvb); + +dissect_tcap_UserInformation(TRUE, parameter_tvb, 0, pinfo, tree, -1); + + +return offset+len; + + return offset; } - -static int -dissect_tcap_integer(ASN1_SCK *asn1, proto_tree *tree, guint len, gchar * str) -{ - guint saved_offset; - gint32 invokeId; - - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, len, &invokeId); - proto_tree_add_int_format(tree, hf_tcap_int, asn1->tvb, saved_offset, asn1->offset - saved_offset, - invokeId, "%s %d", str, invokeId); - return TC_DS_OK; +static int dissect_user_information_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_User_information(TRUE, tvb, offset, pinfo, tree, hf_tcap_user_information); } -/* dissect tid */ -static int -dissect_tcap_tid(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti, int type) -{ - guint saved_offset, org_offset = 0; - guint len; - guint tag; - int ret; - proto_item *tid_item; - proto_tree *subtree; - guchar *poctets; - guint32 val; - gboolean def_len; - - org_offset = asn1->offset; - if ( ST_TID_SOURCE == type) - { - tid_item = proto_tree_add_text(tcap_tree, asn1->tvb, asn1->offset, -1, "Source Transaction ID"); - subtree = proto_item_add_subtree(tid_item, ett_otid); - } - else - { - tid_item = proto_tree_add_text(tcap_tree, asn1->tvb, asn1->offset, -1, "Destination Transaction ID"); - subtree = proto_item_add_subtree(tid_item, ett_dtid); - } - - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - proto_tree_add_uint(subtree, hf_tcap_tid, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag); - - /* error handling */ - switch(type) - { - case ST_TID_SOURCE: - if (ST_ITU_ORG_TID_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } - break; - case ST_TID_DEST: - if (ST_ITU_DST_TID_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } - break; - default: - break; - } - - - dissect_tcap_len(asn1, subtree, &def_len, &len); - - /* - * XXX - this is, I think, an OCTET STRING (SIZE(1..4)); should it - * just be put into the protocol tree as an FT_BYTES value and - * displayed in the Info column with "bytes_to_str()"? - * - * If so, should we have separate hf_tcap_source_tid and - * hf_tcap_destination_tid? - * - * Does that apply to other transaction IDs? - */ - if (len > 4) - { - return TC_DS_FAIL; - } - - saved_offset = asn1->offset; - ret = asn1_string_value_decode(asn1, len, &poctets); - val = 0; - memcpy(&val, poctets, len); - - ti = proto_tree_add_uint(subtree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, val); - g_free(poctets); - - proto_item_set_len(tid_item, asn1->offset - org_offset); - - if (type == ST_TID_DEST) - { - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "dtid(%x) ", val); - } - else - { - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "stid(%x) ", val); - } - - return TC_DS_OK; -} +static const ber_sequence_t AARQ_apdu_sequence[] = { + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_protocol_versionrq_impl }, + { BER_CLASS_CON, 1, 0, dissect_application_context_name }, + { BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_user_information_impl }, + { 0, 0, 0, NULL } +}; -/* Samuel */ -/* dissect operation portion */ static int -dissect_tcap_invokeId(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - guint tag; - gboolean def_len; - -#define INVOKE_ID_TAG 0x2 - if (tcap_check_tag(asn1, INVOKE_ID_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Invoke ID Tag"); - dissect_tcap_len(asn1, tree, &def_len, &len); - dissect_tcap_integer(asn1, tree, len, "Invoke ID:"); - } +dissect_tcap_AARQ_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + AARQ_apdu_sequence, hf_index, ett_tcap_AARQ_apdu); - return TC_DS_OK; + return offset; } - -static int -dissect_tcap_lnkId(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - guint tag; - gboolean def_len; - - if (tcap_check_tag(asn1, TCAP_LINKED_ID_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Linked ID Tag"); - dissect_tcap_len(asn1, tree, &def_len, &len); - dissect_tcap_integer(asn1, tree, len, "Linked ID:"); - } - - return TC_DS_OK; +static int dissect_dialogueRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_AARQ_apdu(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialogueRequest); } -static void -dissect_tcap_opr_code(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - guint tag; - gboolean got_it = FALSE; - gboolean def_len; - -#define TCAP_LOC_OPR_CODE_TAG 0x02 - if (tcap_check_tag(asn1, TCAP_LOC_OPR_CODE_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Local Operation Code Tag"); - got_it = TRUE; - } -#define TCAP_GLB_OPR_CODE_TAG 0x06 - else if (tcap_check_tag(asn1, TCAP_GLB_OPR_CODE_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Global Operation Code Tag"); - got_it = TRUE; - } - - if (got_it) - { - dissect_tcap_len(asn1, tree, &def_len, &len); - - proto_tree_add_text(tree, asn1->tvb, asn1->offset, len, "Operation Code"); - - asn1->offset += len; - } -} +static const asn_namedbit T_protocol_versionre_bits[] = { + { 0, &hf_tcap_T_protocol_versionre_version1, -1, -1, NULL, NULL }, + { 0, NULL, 0, 0, NULL, NULL } +}; static int -dissect_tcap_param(ASN1_SCK *asn1, proto_tree *tree, guint exp_len) -{ - gint orig_offset, saved_offset, len_offset; - guint tag, len; - gboolean def_len; - proto_item *item; - proto_tree *subtree; - - orig_offset = asn1->offset; - -#define TC_INVALID_TAG 0 - while ((tvb_length_remaining(asn1->tvb, asn1->offset) > 0) && - (!tcap_check_tag(asn1, 0))) - { - if ((exp_len != 0) && - ((asn1->offset - orig_offset) >= exp_len)) - { - break; - } - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - len_offset = asn1->offset; - asn1_length_decode(asn1, &def_len, &len); - - if (TCAP_CONSTRUCTOR(tag)) - { - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Sequence"); - - subtree = proto_item_add_subtree(item, ett_params); - - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, len_offset - saved_offset, tag, "Sequence Tag"); - - if (def_len) - { - proto_tree_add_uint(subtree, hf_tcap_length, asn1->tvb, - len_offset, asn1->offset - len_offset, len); - } - else - { - proto_tree_add_text(subtree, asn1->tvb, - len_offset, asn1->offset - len_offset, "Length: Indefinite"); - - len = tcap_find_eoc(asn1); - } - - proto_item_set_len(item, - (asn1->offset - saved_offset) + len + - (def_len ? 0 : TCAP_EOC_LEN)); - - dissect_tcap_param(asn1, subtree, len); - - if (!def_len) - { - dissect_tcap_eoc(asn1, subtree); - } - continue; - } +dissect_tcap_T_protocol_versionre(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset, + T_protocol_versionre_bits, hf_index, ett_tcap_T_protocol_versionre, + NULL); - if (!def_len) - { - proto_tree_add_uint_format(tree, hf_tcap_tag, asn1->tvb, - saved_offset, len_offset - saved_offset, tag, "Parameter Tag"); - - proto_tree_add_text(tree, asn1->tvb, - len_offset, asn1->offset - len_offset, "Length: Indefinite"); - - len = tcap_find_eoc(asn1); - - dissect_tcap_param(asn1, tree, len); - - dissect_tcap_eoc(asn1, tree); - continue; - } - - item = - proto_tree_add_text(tree, asn1->tvb, - saved_offset, (asn1->offset - saved_offset) + len, "Parameter"); - - subtree = proto_item_add_subtree(item, ett_param); + return offset; +} +static int dissect_protocol_versionre_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_protocol_versionre(TRUE, tvb, offset, pinfo, tree, hf_tcap_protocol_versionre); +} - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, len_offset - saved_offset, tag, "Parameter Tag"); - proto_tree_add_uint(subtree, hf_tcap_length, asn1->tvb, - len_offset, asn1->offset - len_offset, len); +static const value_string tcap_Associate_result_vals[] = { + { 0, "accepted" }, + { 1, "reject-permanent" }, + { 0, NULL } +}; - proto_tree_add_text(subtree, asn1->tvb, - asn1->offset, len, "Parameter Data"); - asn1->offset += len; - if (saved_offset >= asn1->offset) - THROW(ReportedBoundsError); - } +static int +dissect_tcap_Associate_result(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - return TC_DS_OK; + return offset; +} +static int dissect_result(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Associate_result(FALSE, tvb, offset, pinfo, tree, hf_tcap_result); } -static proto_tree * -dissect_tcap_component(ASN1_SCK *asn1, proto_tree *tree, guint *len_p) -{ - guint saved_offset; - guint tag; - proto_item *item; - proto_tree *subtree; - gboolean def_len; - - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Component ID"); - - subtree = proto_item_add_subtree(item, ett_component); - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "Component ID Identifier"); +static const value_string tcap_T_dialogue_service_user_vals[] = { + { 0, "null" }, + { 1, "no-reason-given" }, + { 2, "application-context-name-not-supported" }, + { 0, NULL } +}; - dissect_tcap_len(asn1, subtree, &def_len, len_p); - proto_item_set_len(item, (asn1->offset - saved_offset) + *len_p); +static int +dissect_tcap_T_dialogue_service_user(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - return(subtree); + return offset; +} +static int dissect_dialogue_service_user(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_dialogue_service_user(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialogue_service_user); } -static void -dissect_tcap_problem(ASN1_SCK *asn1, proto_tree *tree) -{ - guint orig_offset, saved_offset, len_offset; - guint len; - guint tag; - proto_tree *subtree; - proto_item *item = NULL; - gchar *str = NULL; - gchar *type_str = NULL; - gint32 spec; - gboolean def_len; +static const value_string tcap_T_dialogue_service_provider_vals[] = { + { 0, "null" }, + { 1, "no-reason-given" }, + { 2, "no-common-dialogue-portion" }, + { 0, NULL } +}; - orig_offset = asn1->offset; - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - len_offset = asn1->offset; - asn1_length_decode(asn1, &def_len, &len); +static int +dissect_tcap_T_dialogue_service_provider(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Problem Code"); + return offset; +} +static int dissect_dialogue_service_provider(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_dialogue_service_provider(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialogue_service_provider); +} - subtree = proto_item_add_subtree(item, ett_problem); - if (!def_len) - { - len = tcap_find_eoc(asn1); - } +static const value_string tcap_Associate_source_diagnostic_vals[] = { + { 1, "dialogue-service-user" }, + { 2, "dialogue-service-provider" }, + { 0, NULL } +}; - proto_item_set_len(item, (asn1->offset - saved_offset) + len + - (def_len ? 0 : TCAP_EOC_LEN)); +static const ber_choice_t Associate_source_diagnostic_choice[] = { + { 1, BER_CLASS_CON, 1, 0, dissect_dialogue_service_user }, + { 2, BER_CLASS_CON, 2, 0, dissect_dialogue_service_provider }, + { 0, 0, 0, 0, NULL } +}; - if (len != 1) - { - proto_tree_add_text(subtree, asn1->tvb, - asn1->offset, len, "Unknown encoding of Problem Code"); +static int +dissect_tcap_Associate_source_diagnostic(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + Associate_source_diagnostic_choice, hf_index, ett_tcap_Associate_source_diagnostic); - asn1->offset += len; + return offset; +} +static int dissect_result_source_diagnostic(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Associate_source_diagnostic(FALSE, tvb, offset, pinfo, tree, hf_tcap_result_source_diagnostic); +} - if (!def_len) - { - asn1_eoc_decode(asn1, -1); - } +static const ber_sequence_t AARE_apdu_sequence[] = { + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_protocol_versionre_impl }, + { BER_CLASS_CON, 1, 0, dissect_application_context_name }, + { BER_CLASS_CON, 2, 0, dissect_result }, + { BER_CLASS_CON, 3, BER_FLAGS_NOTCHKTAG, dissect_result_source_diagnostic }, + { BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_user_information_impl }, + { 0, 0, 0, NULL } +}; - return; - } +static int +dissect_tcap_AARE_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + AARE_apdu_sequence, hf_index, ett_tcap_AARE_apdu); - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, 1, &spec); + return offset; +} +static int dissect_dialogueResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_AARE_apdu(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialogueResponse); +} - switch (tag) - { - case 0x80: - type_str = "General Problem"; - switch (spec) - { - case 0: str = "Unrecognized Component"; break; - case 1: str = "Mistyped Component"; break; - case 2: str = "Badly Structured Component"; break; - default: - str = "Undefined"; - break; - } - break; - case 0x81: - type_str = "Invoke"; - switch (spec) - { - case 0: str = "Duplicate Invoke ID"; break; - case 1: str = "Unrecognized Operation"; break; - case 2: str = "Mistyped Parameter"; break; - case 3: str = "Resource Limitation"; break; - case 4: str = "Initiating Release"; break; - case 5: str = "Unrecognized Linked ID"; break; - case 6: str = "Linked Response Unexpected"; break; - case 7: str = "Unexpected Linked Operation"; break; - default: - str = "Undefined"; - break; - } - break; +static const value_string tcap_ABRT_source_vals[] = { + { 0, "dialogue-service-user" }, + { 1, "dialogue-service-provider" }, + { 0, NULL } +}; - case 0x82: - type_str = "Return Result"; - switch (spec) - { - case 0: str = "Unrecognized Invoke ID"; break; - case 1: str = "Return Result Unexpected"; break; - case 2: str = "Mistyped Parameter"; break; - default: - str = "Undefined"; - break; - } - break; - case 0x83: - type_str = "Return Error"; - switch (spec) - { - case 0: str = "Unrecognized Invoke ID"; break; - case 1: str = "Return Error Unexpected"; break; - case 2: str = "Unrecognized Error"; break; - case 3: str = "Unexpected Error"; break; - case 4: str = "Mistyped Parameter"; break; - default: - str = "Undefined"; - break; - } - break; +static int +dissect_tcap_ABRT_source(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - default: - type_str = "Undefined"; - break; - } + return offset; +} +static int dissect_abort_source_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ABRT_source(TRUE, tvb, offset, pinfo, tree, hf_tcap_abort_source); +} - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - orig_offset, len_offset - orig_offset, tag, type_str); +static const ber_sequence_t ABRT_apdu_sequence[] = { + { BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_abort_source_impl }, + { BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_user_information_impl }, + { 0, 0, 0, NULL } +}; - if (def_len) - { - proto_tree_add_uint(subtree, hf_tcap_length, asn1->tvb, - len_offset, saved_offset - len_offset, len); - } - else - { - proto_tree_add_text(subtree, asn1->tvb, - len_offset, saved_offset - len_offset, "Length: Indefinite"); - } +static int +dissect_tcap_ABRT_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ABRT_apdu_sequence, hf_index, ett_tcap_ABRT_apdu); - proto_tree_add_text(subtree, asn1->tvb, saved_offset, 1, - "Problem Specifier %s", str); + return offset; +} +static int dissect_dialogueAbort(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ABRT_apdu(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialogueAbort); } -static void -dissect_ansi_opr_code(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - guint tag; - gboolean got_it = FALSE; - gboolean def_len; - -#define TCAP_NAT_OPR_CODE_TAG 0xd0 - if (tcap_check_tag(asn1, TCAP_NAT_OPR_CODE_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "National TCAP Operation Code Identifier"); - got_it = TRUE; - } -#define TCAP_PRIV_OPR_CODE_TAG 0xd1 - else if (tcap_check_tag(asn1, TCAP_PRIV_OPR_CODE_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Private TCAP Operation Code Identifier"); - got_it = TRUE; - } +static const value_string tcap_DialoguePDU_vals[] = { + { 0, "dialogueRequest" }, + { 1, "dialogueResponse" }, + { 4, "dialogueAbort" }, + { 0, NULL } +}; - if (got_it) - { - dissect_tcap_len(asn1, tree, &def_len, &len); +static const ber_choice_t DialoguePDU_choice[] = { + { 0, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_dialogueRequest }, + { 1, BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_dialogueResponse }, + { 4, BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_dialogueAbort }, + { 0, 0, 0, 0, NULL } +}; - proto_tree_add_text(tree, asn1->tvb, asn1->offset, len, "Operation Code"); +static int +dissect_tcap_DialoguePDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + DialoguePDU_choice, hf_index, ett_tcap_DialoguePDU); - asn1->offset += len; - } + return offset; } -static void -dissect_ansi_problem(ASN1_SCK *asn1, proto_tree *tree) -{ - guint saved_offset = 0; - guint len; - guint tag; - proto_tree *subtree; - proto_item *item = NULL; - gchar *str = NULL; - gchar *type_str = NULL; - gint32 type, spec; - gboolean def_len; +static int +dissect_tcap_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, + hf_index, NULL); -#define TCAP_PROB_CODE_TAG 0xd5 - if (tcap_check_tag(asn1, TCAP_PROB_CODE_TAG)) - { - str = "Problem Code Identifier"; - } - else - { - /* XXX */ - return; - } - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); + return offset; +} +static int dissect_oid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OBJECT_IDENTIFIER(FALSE, tvb, offset, pinfo, tree, hf_tcap_oid); +} +static int dissect_globalValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OBJECT_IDENTIFIER(FALSE, tvb, offset, pinfo, tree, hf_tcap_globalValue); +} +static int dissect_objectSecurityId_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_tcap_objectSecurityId); +} +static int dissect_objectConfidentialityId_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_tcap_objectConfidentialityId); +} - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Problem Code"); - subtree = proto_item_add_subtree(item, ett_problem); +static int +dissect_tcap_Dialog1(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *parameter_tvb; +tvbuff_t *next_tvb; +guint8 class; + gboolean pc; + guint32 tag; + guint32 len; + guint32 ind_field; + - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, str); +offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); +offset = get_ber_length(tree, tvb, offset, &len, &ind_field); +next_tvb = tvb_new_subset(tvb, offset, len, len); + offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, 0, hf_index, + ¶meter_tvb); + + /*offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, offset, hf_index, + * ¶meter_tvb); + */ + if (!parameter_tvb) + return offset; + dissect_tcap_DialoguePDU(TRUE, parameter_tvb, 0, pinfo, tree, -1); + + + return offset; +} +static int dissect_dialog_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Dialog1(TRUE, tvb, offset, pinfo, tree, hf_tcap_dialog); +} - dissect_tcap_len(asn1, subtree, &def_len, &len); - proto_item_set_len(item, (asn1->offset - saved_offset) + len); +static const ber_sequence_t ExternalPDU_sequence[] = { + { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_oid }, + { BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_dialog_impl }, + { 0, 0, 0, NULL } +}; - if (len != 2) - { - proto_tree_add_text(subtree, asn1->tvb, - asn1->offset, len, "Unknown encoding of Problem Code"); +static int +dissect_tcap_ExternalPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ExternalPDU_sequence, hf_index, ett_tcap_ExternalPDU); - asn1->offset += len; - return; - } + return offset; +} - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, 1, &type); - asn1_int32_value_decode(asn1, 1, &spec); - switch (type) - { - case 0: type_str = "Not used"; break; +static int +dissect_tcap_UserInfoOID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + static char buffer[128]; + tcapext_oid = buffer; + pinfo->private_data = buffer; + offset = dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset, + hf_index, tcapext_oid); - case 1: - type_str = "General"; - switch (spec) - { - case 1: str = "Unrecognized Component Type"; break; - case 2: str = "Incorrect Component Portion"; break; - case 3: str = "Badly Structured Component Portion"; break; - default: - str = "Undefined"; - break; - } - break; - case 2: - type_str = "Invoke"; - switch (spec) - { - case 1: str = "Duplicate Invoke ID"; break; - case 2: str = "Unrecognized Operation Code"; break; - case 3: str = "Incorrect Parameter"; break; - case 4: str = "Unrecognized Correlation ID"; break; - default: - str = "Undefined"; - break; - } - break; + return offset; +} +static int dissect_useroid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_UserInfoOID(FALSE, tvb, offset, pinfo, tree, hf_tcap_useroid); +} - case 3: - type_str = "Return Result"; - switch (spec) - { - case 1: str = "Unrecognized Correlation ID"; break; - case 2: str = "Unexpected Return Result"; break; - case 3: str = "Incorrect Parameter"; break; - default: - str = "Undefined"; - break; - } - break; - case 4: - type_str = "Return Error"; - switch (spec) +static int +dissect_tcap_ExternUserInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *next_tvb; +guint8 class; + gboolean pc; + guint32 tag; + guint32 len, start_offset; + guint32 ind_field; +/* + * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it. + */ +ber_oid_dissector_table = find_dissector_table("ber.oid"); +start_offset = offset; +offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); +offset = get_ber_length(tree, tvb, offset, &len, &ind_field); +/* Use the recived length, XXX What if it was indefenet? */ +next_tvb = tvb_new_subset(tvb, start_offset, len +(offset - start_offset), len+(offset - start_offset)); +if (ber_oid_dissector_table && tcapext_oid){ +if(!dissector_try_string(ber_oid_dissector_table, tcapext_oid, next_tvb, pinfo, tree)) { - case 1: str = "Unrecognized Correlation ID"; break; - case 2: str = "Unexpected Return Error"; break; - case 3: str = "Unrecognized Error"; break; - case 4: str = "Unexpected Error"; break; - case 5: str = "Incorrect Parameter"; break; - default: - str = "Undefined"; - break; } - break; - - case 5: - type_str = "Transaction Portion"; - switch (spec) - { - case 1: str = "Unrecognized Package Type"; break; - case 2: str = "Incorrect Transaction Portion"; break; - case 3: str = "Badly Structured Transaction Portion"; break; - case 4: str = "Unrecognized Transaction ID"; break; - case 5: str = "Permission to Release"; break; - case 6: str = "Resource Unavailable"; break; - default: - str = "Undefined"; - break; } - break; +offset+=len; - default: - type_str = "Undefined"; - break; - } - - if (spec == 255) { str = "Reserved"; } - else if (spec == 0) { str = "Not used"; } - proto_tree_add_text(subtree, asn1->tvb, - saved_offset, 1, "Problem Type %s", type_str); - proto_tree_add_text(subtree, asn1->tvb, - saved_offset + 1, 1, "Problem Specifier %s", str); + return offset; } - - -static void -dissect_ansi_error(ASN1_SCK *asn1, proto_tree *tree) -{ - guint saved_offset = 0; - guint len; - guint tag; - proto_tree *subtree; - proto_item *item = NULL; - gchar *str = NULL; - gboolean def_len; - - -#define TCAP_NAT_ERR_CODE_TAG 0xd3 - if (tcap_check_tag(asn1, TCAP_NAT_ERR_CODE_TAG)) - { - str = "National TCAP Error Code Identifier"; - } -#define TCAP_PRIV_ERR_CODE_TAG 0xd4 - else if (tcap_check_tag(asn1, TCAP_PRIV_ERR_CODE_TAG)) - { - str = "Private TCAP Error Code Identifier"; - } - else - { - /* XXX */ - return; - } - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - - item = - proto_tree_add_text(tree, asn1->tvb, - saved_offset, -1, "TCAP Error Code"); - - subtree = proto_item_add_subtree(item, ett_error); - - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, str); - - dissect_tcap_len(asn1, subtree, &def_len, &len); - proto_item_set_len(item, (asn1->offset - saved_offset) + len); - - proto_tree_add_text(subtree, asn1->tvb, asn1->offset, len, "Error Code"); - - asn1->offset += len; +static int dissect_externuserinfo_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ExternUserInfo(TRUE, tvb, offset, pinfo, tree, hf_tcap_externuserinfo); } +static const ber_sequence_t UserInformation_sequence[] = { + { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_useroid }, + { BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_externuserinfo_impl }, + { 0, 0, 0, NULL } +}; -static void -dissect_ansi_param(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - guint tag; - gboolean got_it = FALSE; - gboolean def_len; - -#define TCAP_PARAM_SET_TAG 0xf2 - if (tcap_check_tag(asn1, TCAP_PARAM_SET_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Parameter Set Identifier"); - got_it = TRUE; - } -#define TCAP_PARAM_SEQ_TAG 0x30 - else if (tcap_check_tag(asn1, TCAP_PARAM_SEQ_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Parameter Sequence Identifier"); - got_it = TRUE; - } - - if (got_it) - { - dissect_tcap_len(asn1, tree, &def_len, &len); - - proto_tree_add_text(tree, asn1->tvb, asn1->offset, len, "Parameter Data"); +static int +dissect_tcap_UserInformation(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + UserInformation_sequence, hf_index, ett_tcap_UserInformation); - asn1->offset += len; - } + return offset; } - -static void -dissect_ansi_tcap_reject(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - proto_tree *subtree; - -#define COMPONENT_ID_TAG 0xcf - if (tcap_check_tag(asn1, COMPONENT_ID_TAG)) - { - subtree = dissect_tcap_component(asn1, tree, &len); - - switch (len) - { - case 1: - dissect_tcap_octet(asn1, subtree, "Correlation ID:"); - break; - } - } - - dissect_ansi_problem(asn1, tree); - - dissect_ansi_param(asn1, tree); +static int dissect_userInformation(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_UserInformation(FALSE, tvb, offset, pinfo, tree, hf_tcap_userInformation); } -static void -dissect_ansi_tcap_re(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - proto_tree *subtree; -#define COMPONENT_ID_TAG 0xcf - if (tcap_check_tag(asn1, COMPONENT_ID_TAG)) - { - subtree = dissect_tcap_component(asn1, tree, &len); +static const value_string tcap_Release_request_reason_vals[] = { + { 0, "normal" }, + { 1, "urgent" }, + { 30, "user-defined" }, + { 0, NULL } +}; - switch (len) - { - case 1: - dissect_tcap_octet(asn1, tree, "Correlation ID:"); - break; - } - } - dissect_ansi_error(asn1, tree); +static int +dissect_tcap_Release_request_reason(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - dissect_ansi_param(asn1, tree); + return offset; } - -static void -dissect_ansi_tcap_rr(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - proto_tree *subtree; - -#define COMPONENT_ID_TAG 0xcf - if (tcap_check_tag(asn1, COMPONENT_ID_TAG)) - { - subtree = dissect_tcap_component(asn1, tree, &len); - - switch (len) - { - case 1: - dissect_tcap_octet(asn1, tree, "Correlation ID:"); - break; - } - } - - dissect_ansi_param(asn1, tree); +static int dissect_reasonrq_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Release_request_reason(TRUE, tvb, offset, pinfo, tree, hf_tcap_reasonrq); } -static void -dissect_ansi_tcap_invoke(ASN1_SCK *asn1, proto_tree *tree) -{ - guint len; - proto_tree *subtree; - -#define COMPONENT_ID_TAG 0xcf - if (tcap_check_tag(asn1, COMPONENT_ID_TAG)) - { - subtree = dissect_tcap_component(asn1, tree, &len); - - switch (len) - { - case 1: - dissect_tcap_octet(asn1, tree, "Invoke ID:"); - break; - - case 2: - dissect_tcap_octet(asn1, tree, "Invoke ID:"); - dissect_tcap_octet(asn1, tree, "Correlation ID:"); - break; - } - } +static const ber_sequence_t RLRQ_apdu_sequence[] = { + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_reasonrq_impl }, + { BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_user_information_impl }, + { 0, 0, 0, NULL } +}; - dissect_ansi_opr_code(asn1, tree); +static int +dissect_tcap_RLRQ_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + RLRQ_apdu_sequence, hf_index, ett_tcap_RLRQ_apdu); - dissect_ansi_param(asn1, tree); + return offset; } -static void -dissect_tcap_invoke(ASN1_SCK *asn1, proto_tree *tree) -{ - proto_tree *subtree; - guint orig_offset, saved_offset; - guint len; - guint tag; - int ret; - proto_item *item; - gboolean def_len; - - orig_offset = asn1->offset; - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Component"); - - subtree = proto_item_add_subtree(item, ett_component); - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, "Invoke Type Tag"); - - dissect_tcap_len(asn1, subtree, &def_len, &len); - - saved_offset = asn1->offset; - - dissect_tcap_invokeId(asn1, subtree); - - dissect_tcap_lnkId(asn1, subtree); - - dissect_tcap_opr_code(asn1, subtree); - - if (def_len) - { - len -= asn1->offset - saved_offset; - } - else - { - len = tcap_find_eoc(asn1); - } +static const value_string tcap_Release_response_reason_vals[] = { + { 0, "normal" }, + { 1, "not-finished" }, + { 30, "user-defined" }, + { 0, NULL } +}; - dissect_tcap_param(asn1, subtree, len); - if (!def_len) - { - dissect_tcap_eoc(asn1, subtree); - } +static int +dissect_tcap_Release_response_reason(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - proto_item_set_len(item, asn1->offset - orig_offset); + return offset; +} +static int dissect_reasonre_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Release_response_reason(TRUE, tvb, offset, pinfo, tree, hf_tcap_reasonre); } -static void -dissect_tcap_rr(ASN1_SCK *asn1, proto_tree *tree, gchar *str) -{ - guint tag, len, comp_len; - guint orig_offset, saved_offset, len_offset; - proto_item *seq_item, *item; - proto_tree *seq_subtree, *subtree; - gboolean def_len; - gboolean comp_def_len; - - tag = -1; - orig_offset = asn1->offset; - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Component"); - - subtree = proto_item_add_subtree(item, ett_component); - - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, str); - - dissect_tcap_len(asn1, subtree, &comp_def_len, &comp_len); - - saved_offset = asn1->offset; - - dissect_tcap_invokeId(asn1, subtree); - - if (tvb_length_remaining(asn1->tvb, asn1->offset) <= 0) - { - proto_item_set_len(item, asn1->offset - orig_offset); - - return; - } - - saved_offset = asn1->offset; - - tag = -1; - asn1_id_decode1(asn1, &tag); - - if (TCAP_CONSTRUCTOR(tag)) - { - len_offset = asn1->offset; - asn1_length_decode(asn1, &def_len, &len); - - seq_item = - proto_tree_add_text(subtree, asn1->tvb, saved_offset, -1, "Sequence"); - - seq_subtree = proto_item_add_subtree(seq_item, ett_params); +static const ber_sequence_t RLRE_apdu_sequence[] = { + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_reasonre_impl }, + { BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_user_information_impl }, + { 0, 0, 0, NULL } +}; - proto_tree_add_uint_format(seq_subtree, hf_tcap_tag, asn1->tvb, - saved_offset, len_offset - saved_offset, tag, "Sequence Tag"); +static int +dissect_tcap_RLRE_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + RLRE_apdu_sequence, hf_index, ett_tcap_RLRE_apdu); - if (def_len) - { - proto_tree_add_uint(seq_subtree, hf_tcap_length, asn1->tvb, - len_offset, asn1->offset - len_offset, len); - } - else - { - proto_tree_add_text(seq_subtree, asn1->tvb, - len_offset, asn1->offset - len_offset, "Length: Indefinite"); + return offset; +} - len = tcap_find_eoc(asn1); - } +static const asn_namedbit T_protocol_version3_bits[] = { + { 0, &hf_tcap_T_protocol_version3_version1, -1, -1, NULL, NULL }, + { 0, NULL, 0, 0, NULL, NULL } +}; - proto_item_set_len(seq_item, - (asn1->offset - saved_offset) + len + - (def_len ? 0 : TCAP_EOC_LEN)); +static int +dissect_tcap_T_protocol_version3(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset, + T_protocol_version3_bits, hf_index, ett_tcap_T_protocol_version3, + NULL); - saved_offset = asn1->offset; + return offset; +} +static int dissect_protocol_version3_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_protocol_version3(TRUE, tvb, offset, pinfo, tree, hf_tcap_protocol_version3); +} - dissect_tcap_opr_code(asn1, seq_subtree); +static const ber_sequence_t AUDT_apdu_sequence[] = { + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_protocol_version3_impl }, + { BER_CLASS_CON, 1, 0, dissect_application_context_name }, + { BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_user_information_impl }, + { 0, 0, 0, NULL } +}; - len -= asn1->offset - saved_offset; +static int +dissect_tcap_AUDT_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + AUDT_apdu_sequence, hf_index, ett_tcap_AUDT_apdu); - dissect_tcap_param(asn1, seq_subtree, len); + return offset; +} +static int dissect_unidialoguePDU(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_AUDT_apdu(FALSE, tvb, offset, pinfo, tree, hf_tcap_unidialoguePDU); +} - if (!def_len) - { - dissect_tcap_eoc(asn1, seq_subtree); - } - } - if (!comp_def_len) - { - dissect_tcap_eoc(asn1, subtree); - } +static const value_string tcap_UniDialoguePDU_vals[] = { + { 0, "unidialoguePDU" }, + { 0, NULL } +}; - proto_item_set_len(item, asn1->offset - orig_offset); -} +static const ber_choice_t UniDialoguePDU_choice[] = { + { 0, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_unidialoguePDU }, + { 0, 0, 0, 0, NULL } +}; static int -dissect_tcap_re(ASN1_SCK *asn1, proto_tree *tree) -{ - guint tag, len, comp_len; - guint orig_offset, saved_offset; - proto_item *item; - proto_tree *subtree; - gboolean comp_def_len, def_len; +dissect_tcap_UniDialoguePDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + UniDialoguePDU_choice, hf_index, ett_tcap_UniDialoguePDU); - tag = -1; - orig_offset = asn1->offset; - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); + return offset; +} - item = - proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Component"); - subtree = proto_item_add_subtree(item, ett_component); +static int +dissect_tcap_DialogueOC(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *parameter_tvb; +tvbuff_t *next_tvb; +guint8 class; + gboolean pc; + guint32 tag; + guint32 len; + guint32 ind_field; + - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, - tag, "Return Error Type Tag"); +offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); +offset = get_ber_length(tree, tvb, offset, &len, &ind_field); +next_tvb = tvb_new_subset(tvb, offset, len, len); + offset = dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_index, + ¶meter_tvb); + + + if (!parameter_tvb) + return offset; + dissect_tcap_ExternalPDU(TRUE, parameter_tvb, 2, pinfo, tree, -1); - dissect_tcap_len(asn1, subtree, &comp_def_len, &comp_len); +return offset+2; - if (!comp_def_len) - { - comp_len = tcap_find_eoc(asn1); - } - saved_offset = asn1->offset; + return offset; +} - dissect_tcap_invokeId(asn1, subtree); -#define TC_LOCAL_ERR_CODE_TAG 0x2 -#define TC_GBL_ERR_CODE_TAG 0x6 - if (tcap_check_tag(asn1, TC_LOCAL_ERR_CODE_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, subtree, &tag, "Local Error Code Tag"); - } - else if (tcap_check_tag(asn1, TC_GBL_ERR_CODE_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, subtree, &tag, "Global Error Code Tag"); - } - else - { - proto_tree_add_text(subtree, asn1->tvb, asn1->offset, comp_len, - "Unknown Error Code"); +static int +dissect_tcap_DialoguePortion(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_tcap_DialogueOC(implicit_tag, tvb, offset, pinfo, tree, hf_index); - asn1->offset += comp_len; + return offset; +} +static int dissect_dialoguePortion(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_DialoguePortion(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialoguePortion); +} +static int dissect_u_abortCause(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_DialoguePortion(FALSE, tvb, offset, pinfo, tree, hf_tcap_u_abortCause); +} - if (!comp_def_len) - { - dissect_tcap_eoc(asn1, subtree); - } - proto_item_set_len(item, asn1->offset - orig_offset); - return(TC_DS_OK); - } +static int +dissect_tcap_InvokeIdType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - dissect_tcap_len(asn1, subtree, &def_len, &len); - dissect_tcap_integer(asn1, subtree, len, "Error Code:"); + return offset; +} +static int dissect_invokeID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_InvokeIdType(FALSE, tvb, offset, pinfo, tree, hf_tcap_invokeID); +} +static int dissect_linkedID_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_InvokeIdType(TRUE, tvb, offset, pinfo, tree, hf_tcap_linkedID); +} +static int dissect_derivable(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_InvokeIdType(FALSE, tvb, offset, pinfo, tree, hf_tcap_derivable); +} - dissect_tcap_param(asn1, subtree, comp_len - (asn1->offset - saved_offset)); - if (!comp_def_len) - { - dissect_tcap_eoc(asn1, subtree); - } - proto_item_set_len(item, asn1->offset - orig_offset); +static int +dissect_tcap_INTEGER_M32768_32767(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - return(TC_DS_OK); + return offset; +} +static int dissect_national_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER_M32768_32767(TRUE, tvb, offset, pinfo, tree, hf_tcap_national); +} +static int dissect_nationaler_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER_M32768_32767(TRUE, tvb, offset, pinfo, tree, hf_tcap_nationaler); } -static void -dissect_tcap_reject(ASN1_SCK *asn1, proto_tree *tree) -{ - guint tag, comp_len; - guint saved_offset; - proto_item *item; - proto_tree *subtree; - gboolean def_len; - - tag = -1; - - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - item = proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Component"); - subtree = proto_item_add_subtree(item, ett_component); +static int +dissect_tcap_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, - tag, "Reject Type Tag"); + return offset; +} +static int dissect_localValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_tcap_localValue); +} +static int dissect_integerSecurityId_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER(TRUE, tvb, offset, pinfo, tree, hf_tcap_integerSecurityId); +} +static int dissect_integerConfidentialityId_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER(TRUE, tvb, offset, pinfo, tree, hf_tcap_integerConfidentialityId); +} +static int dissect_private_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER(TRUE, tvb, offset, pinfo, tree, hf_tcap_private); +} +static int dissect_privateer_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_INTEGER(TRUE, tvb, offset, pinfo, tree, hf_tcap_privateer); +} - dissect_tcap_len(asn1, subtree, &def_len, &comp_len); - dissect_tcap_invokeId(asn1, subtree); +static const value_string tcap_OperationCode_vals[] = { + { 16, "national" }, + { 17, "private" }, + { 0, NULL } +}; - dissect_tcap_problem(asn1, subtree); +static const ber_choice_t OperationCode_choice[] = { + { 16, BER_CLASS_PRI, 16, BER_FLAGS_IMPLTAG, dissect_national_impl }, + { 17, BER_CLASS_PRI, 17, BER_FLAGS_IMPLTAG, dissect_private_impl }, + { 0, 0, 0, 0, NULL } +}; - if (!def_len) - { - dissect_tcap_eoc(asn1, subtree); - } +static int +dissect_tcap_OperationCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + OperationCode_choice, hf_index, ett_tcap_OperationCode); - proto_item_set_len(item, asn1->offset - saved_offset); + return offset; +} +static int dissect_operationCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OperationCode(FALSE, tvb, offset, pinfo, tree, hf_tcap_operationCode); } -static void -dissect_ansi_tcap_next_tvb(ASN1_SCK *asn1, guint len, proto_tree *tree) -{ - tvbuff_t *next_tvb; - guint saved_offset; - int ret; - gboolean flag = TRUE; - guint tag; - proto_item *item, *tag_item; - proto_tree *subtree, *tag_subtree; - gboolean def_len; +static int +dissect_tcap_Parameter(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *next_tvb; +guint8 class; + gboolean pc; + guint32 tag; + guint32 len; + guint32 ind_field; + + + offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); +offset = get_ber_length(tree, tvb, offset, &len, &ind_field); + offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, 0, hf_index, + &next_tvb); + +/*dissect_tcap_param(tvb, tree, len); + */ + return offset; - if (lock_info_col) col_set_fence(g_pinfo->cinfo, COL_INFO); + return offset; +} +static int dissect_parameter(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Parameter(FALSE, tvb, offset, pinfo, tree, hf_tcap_parameter); +} - next_tvb = tvb_new_subset(asn1->tvb, asn1->offset, len, len); +static const ber_sequence_t Invoke_sequence[] = { + { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeID }, + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_linkedID_impl }, + { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_operationCode }, + { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_parameter }, + { 0, 0, 0, NULL } +}; - /* process components data */ - if (!dissector_try_port(tcap_ansi_ssn_dissector_table, g_pinfo->match_port, next_tvb, g_pinfo, g_tcap_tree)) - { - /* dissect cmp */ +static int +dissect_tcap_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Invoke_sequence, hf_index, ett_tcap_Invoke); - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); + return offset; +} +static int dissect_invoke_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Invoke(TRUE, tvb, offset, pinfo, tree, hf_tcap_invoke); +} - /* - * verify tag type is known - */ - switch (tag) - { - case ANSI_TC_INVOKE_L : - case ANSI_TC_RRL : - case ANSI_TC_RE : - case ANSI_TC_REJECT : - case ANSI_TC_INVOKE_N : - case ANSI_TC_RRN : - flag = TRUE; - break; - - default: - flag = FALSE; - break; - } +static const ber_sequence_t T_resultretres_sequence[] = { + { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_operationCode }, + { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_parameter }, + { 0, 0, 0, NULL } +}; - if (flag != FALSE) - { - item = proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Components"); - subtree = proto_item_add_subtree(item, ett_component); - - switch (tag) - { - case ANSI_TC_INVOKE_L : - tag_item = proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Invoke(Last)"); - dissect_tcap_len(asn1, subtree, &def_len, &len); - tag_subtree = proto_item_add_subtree(tag_item, ett_component); - - dissect_ansi_tcap_invoke(asn1, tag_subtree); - break; - case ANSI_TC_RRL : - tag_item = proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Return Result(Last)"); - dissect_tcap_len(asn1, subtree, &def_len, &len); - tag_subtree = proto_item_add_subtree(tag_item, ett_component); - - dissect_ansi_tcap_rr(asn1, tag_subtree); - break; - case ANSI_TC_RE : - tag_item = proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Return Error"); - dissect_tcap_len(asn1, subtree, &def_len, &len); - tag_subtree = proto_item_add_subtree(tag_item, ett_component); - - dissect_ansi_tcap_re(asn1, tag_subtree); - break; - case ANSI_TC_REJECT : - tag_item = proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Reject"); - dissect_tcap_len(asn1, subtree, &def_len, &len); - tag_subtree = proto_item_add_subtree(tag_item, ett_component); - - dissect_ansi_tcap_reject(asn1, tag_subtree); - break; - case ANSI_TC_INVOKE_N : - tag_item = proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Invoke(Not Last)"); - dissect_tcap_len(asn1, subtree, &def_len, &len); - tag_subtree = proto_item_add_subtree(tag_item, ett_component); - - dissect_ansi_tcap_invoke(asn1, tag_subtree); - break; - case ANSI_TC_RRN : - tag_item = proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Return Result(Not Last)"); - dissect_tcap_len(asn1, subtree, &def_len, &len); - tag_subtree = proto_item_add_subtree(tag_item, ett_component); - - dissect_ansi_tcap_rr(asn1, tag_subtree); - break; - } - - proto_item_set_len(item, asn1->offset - saved_offset); - } - } +static int +dissect_tcap_T_resultretres(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + T_resultretres_sequence, hf_index, ett_tcap_T_resultretres); - if (!flag) - { - /* No sub-dissection occured, treat it as raw data */ - call_dissector(data_handle, next_tvb, g_pinfo, g_tcap_tree); - } + return offset; } +static int dissect_resultretres(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_resultretres(FALSE, tvb, offset, pinfo, tree, hf_tcap_resultretres); +} + +static const ber_sequence_t ReturnResult_sequence[] = { + { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeID }, + { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_resultretres }, + { 0, 0, 0, NULL } +}; static int -dissect_tcap_components(ASN1_SCK *asn1, proto_tree *tcap_tree) -{ - proto_tree *subtree; - proto_item *comps_item; - gint saved_offset, comps_start; - guint len, comp_len; - gint keep_len; - gboolean comps_def_len, def_len; - guint tag; - int ret; - tvbuff_t *next_tvb; +dissect_tcap_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ReturnResult_sequence, hf_index, ett_tcap_ReturnResult); - if (tvb_length_remaining(asn1->tvb, asn1->offset) <= 0) - { - return TC_DS_FAIL; - } + return offset; +} +static int dissect_returnResultLast_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnResult(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnResultLast); +} +static int dissect_returnResultNotLast_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnResult(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnResultNotLast); +} - comps_start = asn1->offset; - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - if (ST_ITU_CMP_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } +static const value_string tcap_ErrorCode_vals[] = { + { 19, "nationaler" }, + { 20, "privateer" }, + { 0, NULL } +}; - comps_item = - proto_tree_add_text(tcap_tree, asn1->tvb, - saved_offset, -1, "Components Portion"); +static const ber_choice_t ErrorCode_choice[] = { + { 19, BER_CLASS_PRI, 19, BER_FLAGS_IMPLTAG, dissect_nationaler_impl }, + { 20, BER_CLASS_PRI, 20, BER_FLAGS_IMPLTAG, dissect_privateer_impl }, + { 0, 0, 0, 0, NULL } +}; - subtree = proto_item_add_subtree(comps_item, ett_comps_portion); +static int +dissect_tcap_ErrorCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + ErrorCode_choice, hf_index, ett_tcap_ErrorCode); - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, - asn1->offset - saved_offset, tag, "Component Portion Tag"); + return offset; +} +static int dissect_errorCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ErrorCode(FALSE, tvb, offset, pinfo, tree, hf_tcap_errorCode); +} - dissect_tcap_len(asn1, subtree, &comps_def_len, &len); +static const ber_sequence_t ReturnError_sequence[] = { + { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeID }, + { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_errorCode }, + { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_parameter }, + { 0, 0, 0, NULL } +}; - if (comps_def_len) - { - proto_item_set_len(comps_item, (asn1->offset - comps_start) + len); - } +static int +dissect_tcap_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ReturnError_sequence, hf_index, ett_tcap_ReturnError); - if (lock_info_col) col_set_fence(g_pinfo->cinfo, COL_INFO); + return offset; +} +static int dissect_returnError_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnError(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnError); +} - /* call next dissector for EACH component */ - keep_len = - (comps_def_len ? 0 : TCAP_EOC_LEN) + - (g_tcap_ends_def_len ? 0 : TCAP_EOC_LEN); +static int +dissect_tcap_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + { proto_item *ti_tmp; + ti_tmp = proto_tree_add_item(tree, hf_index, tvb, offset>>8, 0, FALSE); + proto_item_append_text(ti_tmp, ": NULL"); + } - while (tvb_length_remaining(asn1->tvb, asn1->offset) > keep_len) - { - /* peek at tag and length */ - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); + return offset; +} +static int dissect_not_derivable(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_NULL(FALSE, tvb, offset, pinfo, tree, hf_tcap_not_derivable); +} - comp_len = 0; - def_len = FALSE; - ret = asn1_length_decode(asn1, &def_len, &comp_len); - if (def_len) - { - comp_len += (asn1->offset - saved_offset); - } - else - { - comp_len = (asn1->offset - saved_offset) + tcap_find_eoc(asn1) + TCAP_EOC_LEN; - } +static const value_string tcap_T_invokeIDRej_vals[] = { + { 0, "derivable" }, + { 1, "not-derivable" }, + { 0, NULL } +}; - next_tvb = tvb_new_subset(asn1->tvb, saved_offset, comp_len, comp_len); - asn1->offset = saved_offset; +static const ber_choice_t T_invokeIDRej_choice[] = { + { 0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_derivable }, + { 1, BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_not_derivable }, + { 0, 0, 0, 0, NULL } +}; - /* process component data */ - if (dissector_try_port(tcap_itu_ssn_dissector_table, g_pinfo->match_port, next_tvb, g_pinfo, g_tcap_tree)) - { - proto_tree_add_text(subtree, asn1->tvb, asn1->offset, comp_len, "Component"); +static int +dissect_tcap_T_invokeIDRej(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + T_invokeIDRej_choice, hf_index, ett_tcap_T_invokeIDRej); - asn1->offset += comp_len; - } - else - { - switch (tag) - { - case TCAP_COMP_INVOKE : - dissect_tcap_invoke(asn1, subtree); - break; - case TCAP_COMP_RRL : - dissect_tcap_rr(asn1, subtree, "Return Result(Last) Type Tag"); - break; - case TCAP_COMP_RE : - dissect_tcap_re(asn1, subtree); - break; - case TCAP_COMP_REJECT : - dissect_tcap_reject(asn1, subtree); - break; - case TCAP_COMP_RRN : - /* same definition as RRL */ - dissect_tcap_rr(asn1, subtree, "Return Result(Not Last) Type Tag"); - break; - default: - /* treat it as raw data */ - call_dissector(data_handle, next_tvb, g_pinfo, g_tcap_tree); - break; - } - } - if (saved_offset >= asn1->offset) - THROW(ReportedBoundsError); - } + return offset; +} +static int dissect_invokeIDRej(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_invokeIDRej(FALSE, tvb, offset, pinfo, tree, hf_tcap_invokeIDRej); +} - if (!comps_def_len) - { - dissect_tcap_eoc(asn1, subtree); - proto_item_set_len(comps_item, asn1->offset - comps_start); - } +static const value_string tcap_GeneralProblem_vals[] = { + { 0, "unrecognizedComponent" }, + { 1, "mistypedComponent" }, + { 2, "badlyStructuredComponent" }, + { 0, NULL } +}; - return TC_DS_OK; -} -/* dissect dialog portion */ static int -dissect_tcap_dlg_protocol_version(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti) -{ - guint saved_offset = 0; - guint len; - guint tag; - int ret; - gboolean def_len; - -#define TC_DLG_PROTO_VER_TAG 0x80 - if (tcap_check_tag(asn1, TC_DLG_PROTO_VER_TAG)) - { - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - proto_tree_add_uint_format(tcap_tree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "Protocol Version Tag: 0x%x", tag); - - dissect_tcap_len(asn1, tcap_tree, &def_len, &len); - saved_offset = asn1->offset; - ti = - proto_tree_add_item(tcap_tree, hf_tcap_bytes, asn1->tvb, - saved_offset, len, FALSE); - asn1->offset += len; - } +dissect_tcap_GeneralProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - return TC_DS_OK; + return offset; +} +static int dissect_generalProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_GeneralProblem(TRUE, tvb, offset, pinfo, tree, hf_tcap_generalProblem); } -static int -dissect_tcap_dlg_application_context_name(ASN1_SCK *asn1, proto_tree *tcap_tree,packet_info *pinfo) -{ - guint saved_offset = 0; - guint name_len, len, len2; - guint tag; - subid_t *oid; - char oid_str[BER_MAX_OID_STR_LEN]; - int ret; - gboolean def_len; - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - proto_tree_add_uint_format(tcap_tree, hf_tcap_tag, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag, - "Application Context Name Tag: 0x%x", tag); +static const value_string tcap_InvokeProblem_vals[] = { + { 0, "duplicateInvokeID" }, + { 1, "unrecognizedOperation" }, + { 2, "mistypedParameter" }, + { 3, "resourceLimitation" }, + { 4, "initiatingRelease" }, + { 5, "unrecognizedLinkedID" }, + { 6, "linkedResponseUnexpected" }, + { 7, "unexpectedLinkedOperation" }, + { 0, NULL } +}; - dissect_tcap_len(asn1, tcap_tree, &def_len, &name_len); - saved_offset = asn1->offset; - ret = asn1_oid_decode (asn1, &oid, &len, &len2); - /* - * TODO Probbably more can be removed here but I'm uncertain about the lengths - proto_tree_add_bytes(tcap_tree, hf_tcap_app_con_name, asn1->tvb, saved_offset, len2, tvb_get_ptr(asn1->tvb, saved_offset, len2)); - */ - asn1->offset = dissect_ber_object_identifier(FALSE, pinfo, tcap_tree, asn1->tvb, saved_offset, hf_tcap_oid, oid_str); - if (ret == ASN1_ERR_NOERROR) g_free(oid); - - if (!def_len) - { - /* for Application Context Name Tag */ - dissect_tcap_eoc(asn1, tcap_tree); - } - pinfo->private_data = g_strdup(oid_str); +static int +dissect_tcap_InvokeProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - return TC_DS_OK; + return offset; +} +static int dissect_invokeProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_InvokeProblem(TRUE, tvb, offset, pinfo, tree, hf_tcap_invokeProblem); } -static int -dissect_tcap_dlg_result(ASN1_SCK *asn1, proto_tree *tree) -{ - guint tag, rtag_len, itag_len; - guint saved_offset = 0; - gint32 value; - gchar *str; - gboolean def_len; - gboolean rtag_def_len; - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Result Tag"); +static const value_string tcap_ReturnResultProblem_vals[] = { + { 0, "unrecognizedInvokeID" }, + { 1, "returnResultUnexpected" }, + { 2, "mistypedParameter" }, + { 0, NULL } +}; - dissect_tcap_len(asn1, tree, &rtag_def_len, &rtag_len); - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Integer Tag"); +static int +dissect_tcap_ReturnResultProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - dissect_tcap_len(asn1, tree, &def_len, &itag_len); + return offset; +} +static int dissect_returnResultProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnResultProblem(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnResultProblem); +} - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, itag_len, &value); - switch (value) - { - case 0x00: str = "Accepted"; break; - case 0x01: str = "Reject-permanent"; break; - default: str = "Unknown value"; break; - } +static const value_string tcap_ReturnErrorProblem_vals[] = { + { 0, "unrecognizedInvokeID" }, + { 1, "returnErrorUnexpected" }, + { 2, "unrecognizedError" }, + { 3, "unexpectedError" }, + { 4, "mistypedParameter" }, + { 0, NULL } +}; - proto_tree_add_int_format(tree, hf_tcap_int, asn1->tvb, saved_offset, asn1->offset - saved_offset, - value, "%s %d", str, value); - if (!rtag_def_len) - { - /* for Result Tag */ - dissect_tcap_eoc(asn1, tree); - } +static int +dissect_tcap_ReturnErrorProblem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - return TC_DS_OK; + return offset; +} +static int dissect_returnErrorProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnErrorProblem(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnErrorProblem); } -static int -dissect_tcap_dlg_result_src_diag(ASN1_SCK *asn1, proto_tree *tree) -{ - guint saved_offset = 0; - guint len, tag; - gint32 value; - gboolean user; - gchar *str; - gboolean def_len; - gboolean serv_def_len; - gboolean diag_def_len; - - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Result Source Diagnostic Tag"); - - dissect_tcap_len(asn1, tree, &diag_def_len, &len); - -#define TC_DIAG_SERV_USER_TAG 0xa1 -#define TC_DIAG_SERV_PROV_TAG 0xa2 - if (tcap_check_tag(asn1, TC_DIAG_SERV_USER_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Dialogue Service User Tag"); - user = TRUE; - } - else if (tcap_check_tag(asn1, TC_DIAG_SERV_PROV_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Dialogue Service Provider Tag"); - user = FALSE; - } - else - { - proto_tree_add_text(tree, asn1->tvb, asn1->offset, len, - "Unknown Result Source Diagnostic"); - asn1->offset += len; - return(TC_DS_OK); - } +static const value_string tcap_T_problem_vals[] = { + { 0, "generalProblem" }, + { 1, "invokeProblem" }, + { 2, "returnResultProblem" }, + { 3, "returnErrorProblem" }, + { 0, NULL } +}; - dissect_tcap_len(asn1, tree, &serv_def_len, &len); +static const ber_choice_t T_problem_choice[] = { + { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_generalProblem_impl }, + { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_invokeProblem_impl }, + { 2, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_returnResultProblem_impl }, + { 3, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_returnErrorProblem_impl }, + { 0, 0, 0, 0, NULL } +}; - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "Integer Tag"); +static int +dissect_tcap_T_problem(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + T_problem_choice, hf_index, ett_tcap_T_problem); - dissect_tcap_len(asn1, tree, &def_len, &len); + return offset; +} +static int dissect_problem(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_problem(FALSE, tvb, offset, pinfo, tree, hf_tcap_problem); +} - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, len, &value); +static const ber_sequence_t Reject_sequence[] = { + { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeIDRej }, + { BER_CLASS_CON, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_problem }, + { 0, 0, 0, NULL } +}; - if (user) - { - switch (value) - { - case 0x00: str = "Null"; break; - case 0x01: str = "No reason given"; break; - case 0x02: str = "Application Context Name not supplied"; break; - default: str = "Unknown value"; break; - } - } - else - { - switch (value) - { - case 0x00: str = "Null"; break; - case 0x01: str = "No reason given"; break; - case 0x02: str = "No common dialogue portion"; break; - default: str = "Unknown value"; break; - } - } +static int +dissect_tcap_Reject(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Reject_sequence, hf_index, ett_tcap_Reject); - proto_tree_add_int_format(tree, hf_tcap_int, asn1->tvb, saved_offset, asn1->offset - saved_offset, - value, "%s %d", str, value); + return offset; +} +static int dissect_reject_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Reject(TRUE, tvb, offset, pinfo, tree, hf_tcap_reject); +} - if (!serv_def_len) - { - /* for Dialogue Service User/Provider Tag */ - dissect_tcap_eoc(asn1, tree); - } - if (!diag_def_len) - { - /* for Result Source Diagnostic Tag */ - dissect_tcap_eoc(asn1, tree); - } +static const value_string tcap_Component_vals[] = { + { 1, "invoke" }, + { 2, "returnResultLast" }, + { 3, "returnError" }, + { 4, "reject" }, + { 7, "returnResultNotLast" }, + { 0, NULL } +}; - return TC_DS_OK; -} +static const ber_choice_t Component_choice[] = { + { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_invoke_impl }, + { 2, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_returnResultLast_impl }, + { 3, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_returnError_impl }, + { 4, BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_reject_impl }, + { 7, BER_CLASS_CON, 7, BER_FLAGS_IMPLTAG, dissect_returnResultNotLast_impl }, + { 0, 0, 0, 0, NULL } +}; static int -dissect_tcap_dlg_user_info(ASN1_SCK *asn1, proto_tree *tree, packet_info *pinfo) -{ - guint tag, len; - guint saved_offset = 0; - gboolean def_len; - gboolean user_info_def_len; - int ret; - proto_item *para_item; - proto_tree *sub_tree; - char oid_str[BER_MAX_OID_STR_LEN]; - tvbuff_t *next_tvb; - -#define TC_USR_INFO_TAG 0xbe - if (tcap_check_tag(asn1, TC_USR_INFO_TAG)) - { - tag = -1; - dissect_tcap_tag(asn1, tree, &tag, "User Info Tag"); - dissect_tcap_len(asn1, tree, &user_info_def_len, &len); - -#define TC_EXT_TAG 0x28 - if (tcap_check_tag(asn1, TC_EXT_TAG)) +dissect_tcap_Component(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *next_tvb; +guint8 class; + gboolean pc; + guint32 tag; + guint32 len; + guint32 ind_field; +/* + * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it. + */ +ber_oid_dissector_table = find_dissector_table("ber.oid"); +tcap_itu_ssn_dissector_table = find_dissector_table("tcap.itu_ssn"); + +next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_length_remaining(tvb, offset)); +offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); +offset = get_ber_length(tree, tvb, offset, &len, &ind_field); +if (ber_oid_dissector_table && cur_oid){ +if(!dissector_try_string(ber_oid_dissector_table, cur_oid, next_tvb, pinfo, tcap_top_tree)) { - saved_offset = asn1->offset; - asn1_id_decode1(asn1, &tag); - proto_tree_add_uint_format(tree, hf_tcap_length, asn1->tvb, saved_offset, asn1->offset - saved_offset, - tag, "External Tag: 0x%x", tag); - - dissect_tcap_len(asn1, tree, &def_len, &len); + if (!dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb,pinfo, tcap_top_tree)) + dissect_ber_choice(pinfo, tree, next_tvb, 0, + Component_choice, hf_index, ett_tcap_Component); } - para_item = proto_tree_add_text(tree, asn1->tvb, asn1->offset, len, "Parameter Data"); - sub_tree = proto_item_add_subtree(para_item, ett_para_portion); - asn1->offset = dissect_ber_object_identifier(FALSE, pinfo, sub_tree, asn1->tvb, asn1->offset, hf_tcap_oid, oid_str); - - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - - proto_tree_add_uint_format(sub_tree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "Single-ASN.1-type Tag"); - dissect_tcap_len(asn1, sub_tree, &def_len, &len); - - next_tvb = tvb_new_subset(asn1->tvb, asn1->offset, len, len); - - call_ber_oid_callback(oid_str, next_tvb,0, pinfo, sub_tree); - +} +else + if (!dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree)) + dissect_ber_choice(pinfo, tree, next_tvb, 0, + Component_choice, hf_index, ett_tcap_Component); - asn1->offset += len; +offset+=len; - if (!user_info_def_len) - { - /* for User Information Tag */ - dissect_tcap_eoc(asn1, tree); - } - } - return TC_DS_OK; + return offset; +} +static int dissect_ComponentPortion_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Component(FALSE, tvb, offset, pinfo, tree, hf_tcap_ComponentPortion_item); } -static int -dissect_tcap_dlg_req(ASN1_SCK *asn1, proto_tree *tcap_tree,packet_info *pinfo) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *req_item; - guint req_start = asn1->offset; - gboolean def_len; - - /* dissect dialog portion */ - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - req_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Dialogue Request"); - subtree = proto_item_add_subtree(req_item, ett_dlg_req); - proto_tree_add_uint(subtree, hf_tcap_dlg_type, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag); - - dissect_tcap_len(asn1, subtree, &def_len, &len); +static const ber_sequence_t ComponentPortion_sequence_of[1] = { + { BER_CLASS_CON, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ComponentPortion_item }, +}; - dissect_tcap_dlg_protocol_version(asn1, subtree, NULL); +static int +dissect_tcap_ComponentPortion(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset, + ComponentPortion_sequence_of, hf_index, ett_tcap_ComponentPortion); - dissect_tcap_dlg_application_context_name(asn1, subtree, pinfo); + return offset; +} +static int dissect_components(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ComponentPortion(FALSE, tvb, offset, pinfo, tree, hf_tcap_components); +} - dissect_tcap_dlg_user_info(asn1, subtree, pinfo); +static const ber_sequence_t Unidirectional_sequence[] = { + { BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortion }, + { BER_CLASS_APP, 12, BER_FLAGS_NOOWNTAG, dissect_components }, + { 0, 0, 0, NULL } +}; - /* decode end of sequence */ +static int +dissect_tcap_Unidirectional(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Unidirectional_sequence, hf_index, ett_tcap_Unidirectional); - if (!def_len) - { - /* for Dialogue Request Tag */ - dissect_tcap_eoc(asn1, subtree); - } + return offset; +} +static int dissect_unidirectional_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Unidirectional(TRUE, tvb, offset, pinfo, tree, hf_tcap_unidirectional); +} - proto_item_set_len(req_item, asn1->offset - req_start); - return TC_DS_OK; +static int +dissect_tcap_OrigTransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *parameter_tvb; +guint8 len, i; +offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + ¶meter_tvb); +len = tvb_length_remaining(parameter_tvb, 0); +if ((len)&&(check_col(pinfo->cinfo, COL_INFO))) + { + + col_append_fstr(pinfo->cinfo, COL_INFO, "dtid("); + for(i=0;i<len;i++) + col_append_fstr(pinfo->cinfo, COL_INFO, "%02x",tvb_get_guint8(parameter_tvb,i)); + col_append_fstr(pinfo->cinfo, COL_INFO, ") "); + } + + + return offset; } +static int dissect_otid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OrigTransactionID(FALSE, tvb, offset, pinfo, tree, hf_tcap_otid); +} + +static const ber_sequence_t Begin_sequence[] = { + { BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_otid }, + { BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortion }, + { BER_CLASS_APP, 12, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_components }, + { 0, 0, 0, NULL } +}; static int -dissect_tcap_dlg_rsp(ASN1_SCK *asn1, proto_tree *tcap_tree, packet_info *pinfo) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *req_item; - guint req_start = asn1->offset; - gboolean def_len; - - /* dissect dialog portion */ - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - req_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Dialogue Response"); - subtree = proto_item_add_subtree(req_item, ett_dlg_rsp); - proto_tree_add_uint(subtree, hf_tcap_dlg_type, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag); +dissect_tcap_Begin(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Begin_sequence, hf_index, ett_tcap_Begin); - dissect_tcap_len(asn1, subtree, &def_len, &len); + return offset; +} +static int dissect_begin_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Begin(TRUE, tvb, offset, pinfo, tree, hf_tcap_begin); +} - dissect_tcap_dlg_protocol_version(asn1, subtree, NULL); - dissect_tcap_dlg_application_context_name(asn1, subtree, pinfo); +static int +dissect_tcap_DestTransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *parameter_tvb; +guint8 len , i; +offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + ¶meter_tvb); +len = tvb_length_remaining(parameter_tvb, 0); +if ((len)&&(check_col(pinfo->cinfo, COL_INFO))) + { + col_append_fstr(pinfo->cinfo, COL_INFO, "dtid("); + for(i=0;i<len;i++) + col_append_fstr(pinfo->cinfo, COL_INFO, "%02x",tvb_get_guint8(parameter_tvb,i)); + col_append_fstr(pinfo->cinfo, COL_INFO, ") "); + } + + + + return offset; +} +static int dissect_dtid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_DestTransactionID(FALSE, tvb, offset, pinfo, tree, hf_tcap_dtid); +} - /* result */ - dissect_tcap_dlg_result(asn1, subtree); +static const ber_sequence_t End_sequence[] = { + { BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_dtid }, + { BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortion }, + { BER_CLASS_APP, 12, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_components }, + { 0, 0, 0, NULL } +}; - /* result source diag */ - dissect_tcap_dlg_result_src_diag(asn1, subtree); +static int +dissect_tcap_End(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + End_sequence, hf_index, ett_tcap_End); - dissect_tcap_dlg_user_info(asn1, subtree, pinfo); + return offset; +} +static int dissect_end_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_End(TRUE, tvb, offset, pinfo, tree, hf_tcap_end); +} - if (!def_len) - { - /* for Dialogue Response Tag */ - dissect_tcap_eoc(asn1, subtree); - } +static const ber_sequence_t Continue_sequence[] = { + { BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_otid }, + { BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_dtid }, + { BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortion }, + { BER_CLASS_APP, 12, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_components }, + { 0, 0, 0, NULL } +}; - proto_item_set_len(req_item, asn1->offset - req_start); +static int +dissect_tcap_Continue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Continue_sequence, hf_index, ett_tcap_Continue); - return TC_DS_OK; + return offset; +} +static int dissect_continue_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Continue(TRUE, tvb, offset, pinfo, tree, hf_tcap_continue); } -static int -dissect_tcap_dlg_abrt(ASN1_SCK *asn1, proto_tree *tree, packet_info *pinfo) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *req_item; - gint32 value; - gchar *str; - gboolean def_len, abort_def_len; - - /* dissect dialog pabort portion */ - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - req_item = proto_tree_add_text(tree, asn1->tvb, saved_offset, -1, "Dialogue Abort"); - subtree = proto_item_add_subtree(req_item, ett_dlg_abort ); - proto_tree_add_uint(subtree, hf_tcap_dlg_type, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag); - - dissect_tcap_len(asn1, subtree, &abort_def_len, &len); - tag = -1; - dissect_tcap_tag(asn1, subtree, &tag, "Abort Source Tag"); - dissect_tcap_len(asn1, subtree, &def_len, &len); +static const value_string tcap_P_AbortCause_vals[] = { + { 0, "unrecognizedMessageType" }, + { 1, "unrecognizedTransactionID" }, + { 2, "badlyFormattedTransactionPortion" }, + { 3, "incorrectTransactionPortion" }, + { 4, "resourceLimitation" }, + { 0, NULL } +}; - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, len, &value); - switch (value) - { - case 0x00: str = "Dialogue Service User"; break; - case 0x01: str = "Dialogue Service Provider"; break; - default: str = "Unknown value"; break; - } +static int +dissect_tcap_P_AbortCause(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - proto_tree_add_int_format(subtree, hf_tcap_int, asn1->tvb, saved_offset, asn1->offset - saved_offset, - value, "Abort Source: %s %d", str, value); + return offset; +} +static int dissect_p_abortCause(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_P_AbortCause(FALSE, tvb, offset, pinfo, tree, hf_tcap_p_abortCause); +} - dissect_tcap_dlg_user_info(asn1, subtree, pinfo); - if (!abort_def_len) - { - /* for Dialogue Abort Tag */ - dissect_tcap_eoc(asn1, subtree); - } +static const value_string tcap_Reason_vals[] = { + { 10, "p-abortCause" }, + { 11, "u-abortCause" }, + { 0, NULL } +}; - return TC_DS_OK; -} +static const ber_choice_t Reason_choice[] = { + { 10, BER_CLASS_APP, 10, BER_FLAGS_NOOWNTAG, dissect_p_abortCause }, + { 11, BER_CLASS_APP, 11, BER_FLAGS_NOOWNTAG, dissect_u_abortCause }, + { 0, 0, 0, 0, NULL } +}; static int -dissect_tcap_dialog_portion(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti _U_,packet_info *pinfo) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *dlg_item; - guint dlg_start = asn1->offset; - gboolean def_len, ext_tag_def_len, portion_def_len; +dissect_tcap_Reason(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + Reason_choice, hf_index, ett_tcap_Reason); - if (tvb_length_remaining(asn1->tvb, asn1->offset) <= 0) - { - return TC_DS_FAIL; - } + return offset; +} +static int dissect_reason(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Reason(FALSE, tvb, offset, pinfo, tree, hf_tcap_reason); +} - /* dissect dialog portion */ - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); +static const ber_sequence_t Abort_sequence[] = { + { BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_dtid }, + { BER_CLASS_APP, -1/*choice*/, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_reason }, + { 0, 0, 0, NULL } +}; - /* error handling */ - if (ST_ITU_DLG_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } +static int +dissect_tcap_Abort(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Abort_sequence, hf_index, ett_tcap_Abort); - dlg_item = - proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Dialogue Portion"); + return offset; +} +static int dissect_abort_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Abort(TRUE, tvb, offset, pinfo, tree, hf_tcap_abort); +} - subtree = proto_item_add_subtree(dlg_item, ett_dlg_portion); - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, "Dialogue Portion Tag"); +static int +dissect_tcap_TransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + NULL); - dissect_tcap_len(asn1, subtree, &portion_def_len, &len); + return offset; +} +static int dissect_identifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_TransactionID(FALSE, tvb, offset, pinfo, tree, hf_tcap_identifier); +} - if (portion_def_len) - { - tvb_ensure_bytes_exist(asn1->tvb, saved_offset, len); - proto_item_set_len(dlg_item, len); - } - ext_tag_def_len = FALSE; - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); -#define TC_EXT_TAG 0x28 - if (TC_EXT_TAG != tag) - { - asn1->offset = saved_offset; - } - else - { - proto_tree_add_uint_format(subtree, hf_tcap_length, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "External Tag: 0x%x", tag); +static int +dissect_tcap_ProtocolVersion(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + NULL); - dissect_tcap_len(asn1, subtree, &ext_tag_def_len, &len); - } + return offset; +} +static int dissect_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ProtocolVersion(FALSE, tvb, offset, pinfo, tree, hf_tcap_version); +} - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); -#define TC_OID_TAG 0x06 - if (TC_OID_TAG != tag) - { - asn1->offset = saved_offset; - } - else - { - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "Object Identifier Tag"); - - asn1->offset = dissect_ber_object_identifier(FALSE, pinfo, subtree, asn1->tvb, saved_offset, hf_tcap_oid, NULL); - /* - dissect_tcap_len(asn1, subtree, &def_len, &len); - saved_offset = asn1->offset; - ti = - proto_tree_add_bytes(subtree, hf_tcap_bytes, asn1->tvb, saved_offset, len, - (guchar*)(tvb_get_ptr(asn1->tvb, saved_offset, len))); - asn1->offset += len; - */ - } +static int +dissect_tcap_IntegerApplicationContext(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); + return offset; +} +static int dissect_integerApplicationId(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_IntegerApplicationContext(FALSE, tvb, offset, pinfo, tree, hf_tcap_integerApplicationId); +} - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "Single-ASN.1-type Tag"); - dissect_tcap_len(asn1, subtree, &def_len, &len); +static int +dissect_tcap_ObjectIDApplicationContext(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, + hf_index, NULL); - proto_item_set_len(dlg_item, asn1->offset - dlg_start); + return offset; +} +static int dissect_objectApplicationId(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ObjectIDApplicationContext(FALSE, tvb, offset, pinfo, tree, hf_tcap_objectApplicationId); +} - /* dialogue PDU */ - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - asn1->offset = saved_offset; - switch(tag) - { - case TC_DLG_REQ: - dissect_tcap_dlg_req(asn1, subtree, pinfo); - break; - case TC_DLG_RSP: - dissect_tcap_dlg_rsp(asn1, subtree, pinfo); - break; - case TC_DLG_ABRT: - dissect_tcap_dlg_abrt(asn1, subtree, pinfo); - break; - default: - break; - } +static const value_string tcap_T_applicationContext_vals[] = { + { 27, "integerApplicationId" }, + { 28, "objectApplicationId" }, + { 0, NULL } +}; - /* decode end of sequence */ +static const ber_choice_t T_applicationContext_choice[] = { + { 27, BER_CLASS_PRI, 27, BER_FLAGS_NOOWNTAG, dissect_integerApplicationId }, + { 28, BER_CLASS_PRI, 28, BER_FLAGS_NOOWNTAG, dissect_objectApplicationId }, + { 0, 0, 0, 0, NULL } +}; - if (!def_len) - { - dissect_tcap_eoc(asn1, subtree); - } +static int +dissect_tcap_T_applicationContext(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + T_applicationContext_choice, hf_index, ett_tcap_T_applicationContext); - if (!ext_tag_def_len) - { - dissect_tcap_eoc(asn1, subtree); - } + return offset; +} +static int dissect_applicationContext(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_applicationContext(FALSE, tvb, offset, pinfo, tree, hf_tcap_applicationContext); +} - if (!portion_def_len) - { - dissect_tcap_eoc(asn1, subtree); - } - proto_item_set_len(dlg_item, asn1->offset - dlg_start); +static const value_string tcap_T_securityContext_vals[] = { + { 0, "integerSecurityId" }, + { 1, "objectSecurityId" }, + { 0, NULL } +}; - return TC_DS_OK; -} +static const ber_choice_t T_securityContext_choice[] = { + { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_integerSecurityId_impl }, + { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_objectSecurityId_impl }, + { 0, 0, 0, 0, NULL } +}; -/* dissect reason */ static int -dissect_tcap_abort_reason(ASN1_SCK *asn1, proto_tree *tcap_tree) -{ - guint saved_offset = 0; - guint tag, len; - proto_tree *subtree; - proto_item *item; - gint32 value; - gchar *str = NULL; - gboolean def_len; - -#define TC_PABRT_REASON_TAG 0x4a - tag = TC_PABRT_REASON_TAG; - if (tcap_check_tag(asn1, tag)) - { - saved_offset = asn1->offset; - item = - proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "PAbort Cause"); - - subtree = proto_item_add_subtree(item, ett_reason); +dissect_tcap_T_securityContext(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + T_securityContext_choice, hf_index, ett_tcap_T_securityContext); - tag = -1; - dissect_tcap_tag(asn1, subtree, &tag, "PAbort Cause Tag"); - dissect_tcap_len(asn1, subtree, &def_len, &len); + return offset; +} +static int dissect_securityContext(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_securityContext(FALSE, tvb, offset, pinfo, tree, hf_tcap_securityContext); +} - proto_item_set_len(item, (asn1->offset - saved_offset) + len); - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, len, &value); +static const value_string tcap_T_confidentialityId_vals[] = { + { 0, "integerConfidentialityId" }, + { 1, "objectConfidentialityId" }, + { 0, NULL } +}; - switch (value) - { - case 0x00: str = "Unrecognized Message Type"; break; - case 0x01: str = "Unrecognized Transaction ID"; break; - case 0x02: str = "Badly Formatted Transaction Portion"; break; - case 0x03: str = "Incorrect Transaction Portion"; break; - case 0x04: str = "Resource Limitation"; break; - default: - str = "Undefined"; - break; - } +static const ber_choice_t T_confidentialityId_choice[] = { + { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_integerConfidentialityId_impl }, + { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_objectConfidentialityId_impl }, + { 0, 0, 0, 0, NULL } +}; - proto_tree_add_text(subtree, asn1->tvb, - saved_offset, asn1->offset - saved_offset, "Cause Value %s (%d)", - str, value); - } +static int +dissect_tcap_T_confidentialityId(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + T_confidentialityId_choice, hf_index, ett_tcap_T_confidentialityId); - return TC_DS_OK; + return offset; } - -/* dissect each type of message */ - -static void -dissect_tcap_unidirectional(ASN1_SCK *asn1, proto_tree *tcap_tree, packet_info *pinfo) -{ - - dissect_tcap_dialog_portion(asn1, tcap_tree, NULL, pinfo); - - dissect_tcap_components(asn1, tcap_tree); +static int dissect_confidentialityId(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_confidentialityId(FALSE, tvb, offset, pinfo, tree, hf_tcap_confidentialityId); } -static void -dissect_tcap_begin(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti, packet_info *pinfo) -{ - - dissect_tcap_tid(asn1, tcap_tree, ti, ST_TID_SOURCE); +static const ber_sequence_t Confidentiality_sequence[] = { + { BER_CLASS_CON, -1/*choice*/, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_confidentialityId }, + { 0, 0, 0, NULL } +}; - dissect_tcap_dialog_portion(asn1, tcap_tree, NULL,pinfo); +static int +dissect_tcap_Confidentiality(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + Confidentiality_sequence, hf_index, ett_tcap_Confidentiality); - dissect_tcap_components(asn1, tcap_tree); + return offset; } - -static void -dissect_tcap_continue(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti, packet_info *pinfo) -{ - - dissect_tcap_tid(asn1, tcap_tree, ti, ST_TID_SOURCE); - - dissect_tcap_tid(asn1, tcap_tree, ti, ST_TID_DEST); - - dissect_tcap_dialog_portion(asn1, tcap_tree, NULL, pinfo); - - dissect_tcap_components(asn1, tcap_tree); - +static int dissect_confidentiality_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_Confidentiality(TRUE, tvb, offset, pinfo, tree, hf_tcap_confidentiality); } -static void -dissect_tcap_end(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti,packet_info *pinfo) -{ - - dissect_tcap_tid(asn1, tcap_tree, ti, ST_TID_DEST); +static const ber_sequence_t DialoguePortionANSI_sequence[] = { + { BER_CLASS_PRI, 26, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_version }, + { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_applicationContext }, + { BER_CLASS_UNI, 8, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_userInformation }, + { BER_CLASS_CON, -1/*choice*/, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_securityContext }, + { BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_confidentiality_impl }, + { 0, 0, 0, NULL } +}; - dissect_tcap_dialog_portion(asn1, tcap_tree, NULL, pinfo); +static int +dissect_tcap_DialoguePortionANSI(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + DialoguePortionANSI_sequence, hf_index, ett_tcap_DialoguePortionANSI); - dissect_tcap_components(asn1, tcap_tree); + return offset; } - -static void -dissect_tcap_abort(ASN1_SCK *asn1, proto_tree *tree, proto_item *ti, packet_info *pinfo) -{ - - dissect_tcap_tid(asn1, tree, ti, ST_TID_DEST); - - dissect_tcap_abort_reason(asn1, tree); - - dissect_tcap_dialog_portion(asn1, tree, NULL, pinfo); +static int dissect_dialoguePortionansi(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_DialoguePortionANSI(FALSE, tvb, offset, pinfo, tree, hf_tcap_dialoguePortionansi); } -/* Samuel */ -static void -dissect_tcap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tcap_tree) -{ - ASN1_SCK asn1; - guint msg_type_tag; - proto_item *ti; - guint offset = 0; - guint saved_offset = 0; - guint len; - gchar *str = NULL; - - asn1_open(&asn1, tvb, offset); - - asn1_id_decode1(&asn1, &msg_type_tag); - - str = match_strval(msg_type_tag, msg_type_strings); - - if (str == NULL) - { - proto_tree_add_text(tcap_tree, asn1.tvb, offset, -1, "Unknown message type, ignoring"); - return; - } - - if (check_col(pinfo->cinfo, COL_INFO)) - { - col_set_str(pinfo->cinfo, COL_INFO, str); - col_append_str(pinfo->cinfo, COL_INFO, " "); - } - - proto_tree_add_uint_hidden(tcap_tree, hf_tcap_ssn, asn1.tvb, offset, - 0, pinfo->match_port); /* len -1 is unacceptable */ - ti = proto_tree_add_uint(tcap_tree, hf_tcap_message_type, asn1.tvb, offset, asn1.offset - saved_offset, - msg_type_tag); - - dissect_tcap_len(&asn1, tcap_tree, &g_tcap_ends_def_len, &len); +static int +dissect_tcap_OCTET_STRING_SIZE_0_2(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + NULL); - switch(msg_type_tag) - { - case ST_MSG_TYP_UNI: - dissect_tcap_unidirectional(&asn1, tcap_tree, pinfo); - break; - case ST_MSG_TYP_BGN: - dissect_tcap_begin(&asn1, tcap_tree, ti, pinfo); - break; - case ST_MSG_TYP_CNT: - dissect_tcap_continue(&asn1, tcap_tree, ti, pinfo); - break; - case ST_MSG_TYP_END: - dissect_tcap_end(&asn1, tcap_tree, ti, pinfo); - break; - case ST_MSG_TYP_PABT: - dissect_tcap_abort(&asn1, tcap_tree, ti, pinfo); - break; - default: - proto_tree_add_text(tcap_tree, asn1.tvb, offset, -1, - "Message type not handled, ignoring"); - break; - } + return offset; +} +static int dissect_componentIDs_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_OCTET_STRING_SIZE_0_2(TRUE, tvb, offset, pinfo, tree, hf_tcap_componentIDs); +} - if (!g_tcap_ends_def_len) - { - dissect_tcap_eoc(&asn1, tcap_tree); - } - asn1_close(&asn1, &saved_offset); -} static int -dissect_ansi_tcap_components(ASN1_SCK *asn1, proto_tree *tcap_tree) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *cmp_item; - guint cmp_start = asn1->offset; - gboolean def_len; - - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); +dissect_tcap_ANSIParameters(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +/* we are doing the ParamSet here so need to look at the tags*/ + guint32 len; +len = tvb_length_remaining(tvb, offset); +if (len > 2) /* arghhh I dont know whether this is constructed or not! */ + offset = dissect_tcap_param(pinfo,tree,tvb,offset); +else +offset = dissect_ber_octet_string(TRUE, pinfo, tree, tvb, 0, hf_index, + NULL); - if (ST_ANSI_CMP_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } - cmp_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Components Portion"); - subtree = proto_item_add_subtree(cmp_item, ett_comps_portion); + return offset; +} +static int dissect_ansiparams(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams); +} +static int dissect_ansiparams1(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams1); +} +static int dissect_ansiparams2(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams2); +} +static int dissect_ansiparams3(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams3); +} +static int dissect_ansiparams4(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams4); +} +static int dissect_ansiparams5(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams5); +} +static int dissect_ansiparams6(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams6); +} +static int dissect_ansiparams7(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams7); +} +static int dissect_ansiparams8(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams8); +} +static int dissect_ansiparams9(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams9); +} +static int dissect_ansiparams10(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams10); +} +static int dissect_ansiparams11(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams11); +} +static int dissect_ansiparams12(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams12); +} +static int dissect_ansiparams13(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams13); +} +static int dissect_ansiparams14(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams14); +} +static int dissect_ansiparams15(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams15); +} +static int dissect_ansiparams16(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams16); +} +static int dissect_ansiparams17(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams17); +} +static int dissect_ansiparams18(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams18); +} +static int dissect_ansiparams19(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams19); +} +static int dissect_ansiparams20(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams20); +} +static int dissect_ansiparams21(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIParameters(FALSE, tvb, offset, pinfo, tree, hf_tcap_ansiparams21); +} - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag, - "Component Sequence Identifier"); +static const ber_sequence_t ANSIparamch_sequence[] = { + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams1 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams2 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams3 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams4 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams5 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams6 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams7 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams8 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams9 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams10 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams11 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams12 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams13 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams14 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams15 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams16 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams17 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams18 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams19 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams20 }, + { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ansiparams21 }, + { 0, 0, 0, NULL } +}; - dissect_tcap_len(asn1, tcap_tree, &def_len, &len); +static int +dissect_tcap_ANSIparamch(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ANSIparamch_sequence, hf_index, ett_tcap_ANSIparamch); - /* call next dissector */ + return offset; +} +static int dissect_parameterinv(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIparamch(FALSE, tvb, offset, pinfo, tree, hf_tcap_parameterinv); +} +static int dissect_parameterrr(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIparamch(FALSE, tvb, offset, pinfo, tree, hf_tcap_parameterrr); +} +static int dissect_parameterre(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIparamch(FALSE, tvb, offset, pinfo, tree, hf_tcap_parameterre); +} +static int dissect_parameterrj(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ANSIparamch(FALSE, tvb, offset, pinfo, tree, hf_tcap_parameterrj); +} - dissect_ansi_tcap_next_tvb(asn1, len, subtree); +static const ber_sequence_t InvokePDU_sequence[] = { + { BER_CLASS_PRI, 15, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_componentIDs_impl }, + { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_operationCode }, + { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_parameterinv }, + { 0, 0, 0, NULL } +}; - proto_item_set_len(cmp_item, asn1->offset - cmp_start); +static int +dissect_tcap_InvokePDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + InvokePDU_sequence, hf_index, ett_tcap_InvokePDU); - return TC_DS_OK; + return offset; +} +static int dissect_invokeLastansi_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_InvokePDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_invokeLastansi); +} +static int dissect_invokeNotLastansi_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_InvokePDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_invokeNotLastansi); } -static int -dissect_ansi_tcap_unidirectional(ASN1_SCK *asn1, proto_tree *tcap_tree) -{ - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *trans_item; - guint trans_start = asn1->offset; - gboolean def_len; - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); +static int +dissect_tcap_ComponentID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, + NULL); - if (ST_ANSI_TID_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } + return offset; +} +static int dissect_componentID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ComponentID(FALSE, tvb, offset, pinfo, tree, hf_tcap_componentID); +} - trans_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Transaction Portion"); +static const ber_sequence_t ReturnResultPDU_sequence[] = { + { BER_CLASS_PRI, 15, BER_FLAGS_NOOWNTAG, dissect_componentID }, + { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_parameterrr }, + { 0, 0, 0, NULL } +}; - dissect_tcap_len(asn1, tcap_tree, &def_len, &len); +static int +dissect_tcap_ReturnResultPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ReturnResultPDU_sequence, hf_index, ett_tcap_ReturnResultPDU); - if (len != 0) - { - return TC_DS_FAIL; - } + return offset; +} +static int dissect_returnResultLastansi_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnResultPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnResultLastansi); +} +static int dissect_returnResultNotLastansi_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnResultPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnResultNotLastansi); +} - proto_item_set_len(trans_item, asn1->offset - trans_start); +static const ber_sequence_t ReturnErrorPDU_sequence[] = { + { BER_CLASS_PRI, 15, BER_FLAGS_NOOWNTAG, dissect_componentID }, + { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_errorCode }, + { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_parameterre }, + { 0, 0, 0, NULL } +}; - dissect_ansi_tcap_components(asn1, tcap_tree); +static int +dissect_tcap_ReturnErrorPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + ReturnErrorPDU_sequence, hf_index, ett_tcap_ReturnErrorPDU); - return TC_DS_OK; + return offset; +} +static int dissect_returnErroransi_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ReturnErrorPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_returnErroransi); } -static int -dissect_ansi_tcap_qwp_qwop(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *trans_item; - guint trans_start = asn1->offset; - guchar *poctets; - guint32 val; - gboolean def_len; - - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); - if (ST_ANSI_TID_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } +static const value_string tcap_ProblemPDU_vals[] = { + { 257, "general-unrecognisedComponentType" }, + { 258, "general-incorrectComponentPortion" }, + { 259, "general-badlyStructuredCompPortion" }, + { 0, NULL } +}; - trans_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Transaction Portion"); - subtree = proto_item_add_subtree(trans_item, ett_dlg_portion); - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag, - "Originating Transaction ID Identifier"); +static int +dissect_tcap_ProblemPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - dissect_tcap_len(asn1, tcap_tree, &def_len, &len); + return offset; +} +static int dissect_rejectProblem_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ProblemPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_rejectProblem); +} - if (len != 4) - { - return TC_DS_FAIL; - } +static const ber_sequence_t RejectPDU_sequence[] = { + { BER_CLASS_PRI, 15, BER_FLAGS_NOOWNTAG, dissect_componentID }, + { BER_CLASS_PRI, 21, BER_FLAGS_IMPLTAG, dissect_rejectProblem_impl }, + { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_parameterrj }, + { 0, 0, 0, NULL } +}; - saved_offset = asn1->offset; - ret = asn1_string_value_decode(asn1, len, &poctets); - val = 0; - memcpy(&val, poctets, len); - ti = proto_tree_add_uint(subtree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, val); - g_free(poctets); +static int +dissect_tcap_RejectPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + RejectPDU_sequence, hf_index, ett_tcap_RejectPDU); - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "otid(%x) ", val); + return offset; +} +static int dissect_rejectansi_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_RejectPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_rejectansi); +} - proto_item_set_len(trans_item, asn1->offset - trans_start); - dissect_ansi_tcap_components(asn1, tcap_tree); +static const value_string tcap_ComponentPDU_vals[] = { + { 9, "invokeLastansi" }, + { 10, "returnResultLastansi" }, + { 11, "returnErroransi" }, + { 12, "rejectansi" }, + { 13, "invokeNotLastansi" }, + { 14, "returnResultNotLastansi" }, + { 0, NULL } +}; - return TC_DS_OK; -} +static const ber_choice_t ComponentPDU_choice[] = { + { 9, BER_CLASS_PRI, 9, BER_FLAGS_IMPLTAG, dissect_invokeLastansi_impl }, + { 10, BER_CLASS_PRI, 10, BER_FLAGS_IMPLTAG, dissect_returnResultLastansi_impl }, + { 11, BER_CLASS_PRI, 11, BER_FLAGS_IMPLTAG, dissect_returnErroransi_impl }, + { 12, BER_CLASS_PRI, 12, BER_FLAGS_IMPLTAG, dissect_rejectansi_impl }, + { 13, BER_CLASS_PRI, 13, BER_FLAGS_IMPLTAG, dissect_invokeNotLastansi_impl }, + { 14, BER_CLASS_PRI, 14, BER_FLAGS_IMPLTAG, dissect_returnResultNotLastansi_impl }, + { 0, 0, 0, 0, NULL } +}; static int -dissect_ansi_tcap_abort(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *trans_item; - guint trans_start = asn1->offset; - guchar *poctets; - guint32 val; - gint32 value; - gboolean def_len; - gchar *str; +dissect_tcap_ComponentPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { +tvbuff_t *next_tvb; - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); +next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_length_remaining(tvb, offset)); - if (ST_ANSI_TID_TAG != tag) +if (!dissector_try_port(tcap_ansi_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tree)) { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } - - trans_item = - proto_tree_add_text(tcap_tree, asn1->tvb, - saved_offset, -1, "Transaction Portion"); - - subtree = proto_item_add_subtree(trans_item, ett_dlg_portion); + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + ComponentPDU_choice, hf_index, ett_tcap_ComponentPDU); + } + + - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, - saved_offset, asn1->offset - saved_offset, tag, - "Responding Transaction ID Identifier"); + return offset; +} +static int dissect_ComponentSequence_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ComponentPDU(FALSE, tvb, offset, pinfo, tree, hf_tcap_ComponentSequence_item); +} - dissect_tcap_len(asn1, subtree, &def_len, &len); +static const ber_sequence_t ComponentSequence_sequence_of[1] = { + { BER_CLASS_PRI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ComponentSequence_item }, +}; - if (len != 4) - { - return TC_DS_FAIL; - } +static int +dissect_tcap_ComponentSequence(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset, + ComponentSequence_sequence_of, hf_index, ett_tcap_ComponentSequence); - saved_offset = asn1->offset; - ret = asn1_string_value_decode(asn1, len, &poctets); + return offset; +} +static int dissect_componentPortion(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_ComponentSequence(FALSE, tvb, offset, pinfo, tree, hf_tcap_componentPortion); +} - val = 0; - memcpy(&val, poctets, len); - ti = proto_tree_add_uint(subtree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, val); - g_free(poctets); +static const ber_sequence_t UniTransactionPDU_sequence[] = { + { BER_CLASS_PRI, 7, BER_FLAGS_NOOWNTAG, dissect_identifier }, + { BER_CLASS_PRI, 25, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortionansi }, + { BER_CLASS_PRI, 8, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_componentPortion }, + { 0, 0, 0, NULL } +}; - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "rtid(%x) ", val); +static int +dissect_tcap_UniTransactionPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + UniTransactionPDU_sequence, hf_index, ett_tcap_UniTransactionPDU); - proto_item_set_len(trans_item, asn1->offset - trans_start); + return offset; +} +static int dissect_ansiunidirectional_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_UniTransactionPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiunidirectional); +} - if (tvb_length_remaining(asn1->tvb, asn1->offset) <= 0) - { - proto_tree_add_text(tcap_tree, asn1->tvb, asn1->offset, -1, - "!!! Missing Component Portion !!!"); +static const ber_sequence_t TransactionPDU_sequence[] = { + { BER_CLASS_PRI, 7, BER_FLAGS_NOOWNTAG, dissect_identifier }, + { BER_CLASS_PRI, 25, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortionansi }, + { BER_CLASS_PRI, 8, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_componentPortion }, + { 0, 0, 0, NULL } +}; - return TC_DS_FAIL; - } +static int +dissect_tcap_TransactionPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + TransactionPDU_sequence, hf_index, ett_tcap_TransactionPDU); - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); + return offset; +} +static int dissect_ansiqueryWithPerm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_TransactionPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiqueryWithPerm); +} +static int dissect_ansiqueryWithoutPerm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_TransactionPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiqueryWithoutPerm); +} +static int dissect_ansiresponse_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_TransactionPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiresponse); +} +static int dissect_ansiconversationWithPerm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_TransactionPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiconversationWithPerm); +} +static int dissect_ansiconversationWithoutPerm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_TransactionPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiconversationWithoutPerm); +} -#define ANSI_TC_PABRT_CAUSE_TAG 0xd7 - if (tag == ANSI_TC_PABRT_CAUSE_TAG) - { - trans_item = - proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "P-Abort Portion"); - subtree = proto_item_add_subtree(trans_item, ett_dlg_abort); +static const value_string tcap_P_Abort_cause_vals[] = { + { 1, "unrecognizedPackageType" }, + { 2, "incorrestTransactionPortion" }, + { 3, "badlyStructuredTransactionPortion" }, + { 4, "unassignedRespondingTransactionID" }, + { 5, "permissionToReleaseProblem" }, + { 6, "resourceUnavilable" }, + { 7, "unrecognizedDialoguePortionID" }, + { 8, "badlyStructuredDialoguePortion" }, + { 9, "missingDialoguePortion" }, + { 10, "inconsistentDialoguePortion" }, + { 0, NULL } +}; - dissect_tcap_len(asn1, subtree, &def_len, &len); - proto_item_set_len(trans_item, (asn1->offset - saved_offset) + len); +static int +dissect_tcap_P_Abort_cause(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); - saved_offset = asn1->offset; - asn1_int32_value_decode(asn1, len, &value); + return offset; +} +static int dissect_abortCause(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_P_Abort_cause(FALSE, tvb, offset, pinfo, tree, hf_tcap_abortCause); +} - switch (value) - { - case 1: str = "Unrecognized Package Type"; break; - case 2: str = "Incorrect Transaction Portion"; break; - case 3: str = "Badly Structured Transaction Portion"; break; - case 4: str = "Unrecognized Transaction ID"; break; - case 5: str = "Permission to Release"; break; - case 6: str = "Resource Unavailable"; break; - default: - str = "Undefined"; - break; - } - proto_tree_add_text(subtree, asn1->tvb, - saved_offset, asn1->offset - saved_offset, "P-Abort Cause Value %s (%d)", - str, value); - } -#define ANSI_TC_UABRT_INFO_TAG 0xd8 - else if (tag == ANSI_TC_UABRT_INFO_TAG) - { - trans_item = - proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "U-Abort Portion"); +static const value_string tcap_T_causeInformation_vals[] = { + { 0, "abortCause" }, + { 1, "userInformation" }, + { 0, NULL } +}; - subtree = proto_item_add_subtree(trans_item, ett_dlg_abort); +static const ber_choice_t T_causeInformation_choice[] = { + { 0, BER_CLASS_PRI, 23, BER_FLAGS_NOOWNTAG, dissect_abortCause }, + { 1, BER_CLASS_UNI, 8, BER_FLAGS_NOOWNTAG, dissect_userInformation }, + { 0, 0, 0, 0, NULL } +}; - dissect_tcap_len(asn1, subtree, &def_len, &len); - if (len > 0) - { - dissect_tcap_integer(asn1, subtree, len, "User Abort Information:"); - } - } +static int +dissect_tcap_T_causeInformation(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + T_causeInformation_choice, hf_index, ett_tcap_T_causeInformation); - return TC_DS_OK; + return offset; +} +static int dissect_causeInformation(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_T_causeInformation(FALSE, tvb, offset, pinfo, tree, hf_tcap_causeInformation); } -static int -dissect_ansi_tcap_rsp(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *trans_item; - guint trans_start = asn1->offset; - guchar *poctets; - guint32 val; - gboolean def_len; - - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); +static const ber_sequence_t AbortPDU_sequence[] = { + { BER_CLASS_PRI, 7, BER_FLAGS_NOOWNTAG, dissect_identifier }, + { BER_CLASS_PRI, 25, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_dialoguePortionansi }, + { -1/*choice*/ , -1/*choice*/, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_causeInformation }, + { 0, 0, 0, NULL } +}; - if (ST_ANSI_TID_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } +static int +dissect_tcap_AbortPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset, + AbortPDU_sequence, hf_index, ett_tcap_AbortPDU); - trans_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Transaction Portion"); - subtree = proto_item_add_subtree(trans_item, ett_dlg_portion); + return offset; +} +static int dissect_ansiabort_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) { + return dissect_tcap_AbortPDU(TRUE, tvb, offset, pinfo, tree, hf_tcap_ansiabort); +} - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag, - "Responding Transaction ID Identifier"); - dissect_tcap_len(asn1, tcap_tree, &def_len, &len); +static const value_string tcap_MessageType_vals[] = { + { 0, "unidirectional" }, + { 1, "begin" }, + { 2, "end" }, + { 3, "continue" }, + { 4, "abort" }, + { 5, "ansiunidirectional" }, + { 6, "ansiqueryWithPerm" }, + { 7, "ansiqueryWithoutPerm" }, + { 8, "ansiresponse" }, + { 9, "ansiconversationWithPerm" }, + { 10, "ansiconversationWithoutPerm" }, + { 11, "ansiabort" }, + { 0, NULL } +}; - if (len != 4) - { - return TC_DS_FAIL; - } +static const ber_choice_t MessageType_choice[] = { + { 0, BER_CLASS_APP, 1, BER_FLAGS_IMPLTAG, dissect_unidirectional_impl }, + { 1, BER_CLASS_APP, 2, BER_FLAGS_IMPLTAG, dissect_begin_impl }, + { 2, BER_CLASS_APP, 4, BER_FLAGS_IMPLTAG, dissect_end_impl }, + { 3, BER_CLASS_APP, 5, BER_FLAGS_IMPLTAG, dissect_continue_impl }, + { 4, BER_CLASS_APP, 7, BER_FLAGS_IMPLTAG, dissect_abort_impl }, + { 5, BER_CLASS_PRI, 1, BER_FLAGS_IMPLTAG, dissect_ansiunidirectional_impl }, + { 6, BER_CLASS_PRI, 2, BER_FLAGS_IMPLTAG, dissect_ansiqueryWithPerm_impl }, + { 7, BER_CLASS_PRI, 3, BER_FLAGS_IMPLTAG, dissect_ansiqueryWithoutPerm_impl }, + { 8, BER_CLASS_PRI, 4, BER_FLAGS_IMPLTAG, dissect_ansiresponse_impl }, + { 9, BER_CLASS_PRI, 5, BER_FLAGS_IMPLTAG, dissect_ansiconversationWithPerm_impl }, + { 10, BER_CLASS_PRI, 6, BER_FLAGS_IMPLTAG, dissect_ansiconversationWithoutPerm_impl }, + { 11, BER_CLASS_PRI, 22, BER_FLAGS_IMPLTAG, dissect_ansiabort_impl }, + { 0, 0, 0, 0, NULL } +}; - saved_offset = asn1->offset; - ret = asn1_string_value_decode(asn1, len, &poctets); - val = 0; - memcpy(&val, poctets, len); - ti = proto_tree_add_uint(subtree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, val); - g_free(poctets); +static int +dissect_tcap_MessageType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + MessageType_choice, hf_index, ett_tcap_MessageType); - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "rtid(%x) ", val); + return offset; +} - proto_item_set_len(trans_item, asn1->offset - trans_start); - dissect_ansi_tcap_components(asn1, tcap_tree); +static const value_string tcap_OPERATION_vals[] = { + { 0, "localValue" }, + { 1, "globalValue" }, + { 0, NULL } +}; - return TC_DS_OK; -} +static const ber_choice_t OPERATION_choice[] = { + { 0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_localValue }, + { 1, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_globalValue }, + { 0, 0, 0, 0, NULL } +}; static int -dissect_ansi_tcap_cwp_cwop(ASN1_SCK *asn1, proto_tree *tcap_tree, proto_item *ti) -{ - proto_tree *subtree; - guint saved_offset = 0; - guint len; - guint tag; - int ret; - proto_item *trans_item; - guint trans_start = asn1->offset; - guchar *poctets; - guint32 val; - gboolean def_len; +dissect_tcap_OPERATION(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + OPERATION_choice, hf_index, ett_tcap_OPERATION); - saved_offset = asn1->offset; - ret = asn1_id_decode1(asn1, &tag); + return offset; +} - if (ST_ANSI_TID_TAG != tag) - { - asn1->offset = saved_offset; - return TC_DS_FAIL; - } - trans_item = proto_tree_add_text(tcap_tree, asn1->tvb, saved_offset, -1, "Transaction Portion"); - subtree = proto_item_add_subtree(trans_item, ett_dlg_portion); +static const value_string tcap_ERROR_vals[] = { + { 0, "localValue" }, + { 1, "globalValue" }, + { 0, NULL } +}; - proto_tree_add_uint_format(subtree, hf_tcap_tag, asn1->tvb, saved_offset, asn1->offset - saved_offset, tag, - "Transaction ID Identifier"); +static const ber_choice_t ERROR_choice[] = { + { 0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_localValue }, + { 1, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_globalValue }, + { 0, 0, 0, 0, NULL } +}; - dissect_tcap_len(asn1, tcap_tree, &def_len, &len); +static int +dissect_tcap_ERROR(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) { + offset = dissect_ber_choice(pinfo, tree, tvb, offset, + ERROR_choice, hf_index, ett_tcap_ERROR); - if (len != 8) - { - return TC_DS_FAIL; - } + return offset; +} - saved_offset = asn1->offset; - ret = asn1_string_value_decode(asn1, 4, &poctets); - val = 0; - memcpy(&val, poctets, 4); - ti = proto_tree_add_uint(subtree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, val); - g_free(poctets); - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "otid(%x) ", val); +/*--- End of included file: packet-tcap-fn.c ---*/ - saved_offset = asn1->offset; - ret = asn1_string_value_decode(asn1, 4, &poctets); - val = 0; - memcpy(&val, poctets, 4); - ti = proto_tree_add_uint(subtree, hf_tcap_id, asn1->tvb, saved_offset, asn1->offset - saved_offset, val); - g_free(poctets); - if (check_col(g_pinfo->cinfo, COL_INFO)) - col_append_fstr(g_pinfo->cinfo, COL_INFO, "rtid(%x) ", val); - proto_item_set_len(trans_item, asn1->offset - trans_start); - dissect_ansi_tcap_components(asn1, tcap_tree); +const value_string tcap_component_type_str[] = { + { TCAP_COMP_INVOKE, "Invoke" }, + { TCAP_COMP_RRL, "Return Result(L)" }, + { TCAP_COMP_RE, "Return Error" }, + { TCAP_COMP_REJECT, "Reject" }, + { TCAP_COMP_RRN, "Return Result(NL)" }, + { 0, NULL } }; - return TC_DS_OK; -} static void -dissect_ansi_tcap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tcap_tree) +dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - ASN1_SCK asn1; - guint msg_type_tag; - proto_item *ti; - guint offset = 0; - guint saved_offset = 0; - guint len; - gchar *str = NULL; - gboolean def_len; - - asn1_open(&asn1, tvb, offset); - - asn1_id_decode1(&asn1, &msg_type_tag); - - str = match_strval(msg_type_tag, ansi_msg_type_strings); - - if (str == NULL) - { - proto_tree_add_text(tcap_tree, asn1.tvb, offset, -1, "Unknown message type, ignoring"); - return; - } + proto_item *item=NULL; + proto_tree *tree=NULL; - if (check_col(pinfo->cinfo, COL_INFO)) + tcap_top_tree = parent_tree; + if (check_col(pinfo->cinfo, COL_PROTOCOL)) { - col_set_str(pinfo->cinfo, COL_INFO, str); - col_append_str(pinfo->cinfo, COL_INFO, " "); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCAP"); } - proto_tree_add_uint_hidden(tcap_tree, hf_tcap_ssn, asn1.tvb, offset, - 0, pinfo->match_port); /* len -1 is unacceptable */ - - ti = proto_tree_add_uint(tcap_tree, hf_ansi_tcap_message_type, asn1.tvb, offset, asn1.offset - saved_offset, - msg_type_tag); - - dissect_tcap_len(&asn1, tcap_tree, &def_len, &len); - - switch(msg_type_tag) - { - case ANSI_ST_MSG_TYP_UNI: - dissect_ansi_tcap_unidirectional(&asn1, tcap_tree); - break; - case ANSI_ST_MSG_TYP_QWP: - dissect_ansi_tcap_qwp_qwop(&asn1, tcap_tree, ti); - break; - case ANSI_ST_MSG_TYP_QWOP: - dissect_ansi_tcap_qwp_qwop(&asn1, tcap_tree, ti); - break; - case ANSI_ST_MSG_TYP_RSP: - dissect_ansi_tcap_rsp(&asn1, tcap_tree, ti); - break; - case ANSI_ST_MSG_TYP_CWP: - dissect_ansi_tcap_cwp_cwop(&asn1, tcap_tree, ti); - break; - case ANSI_ST_MSG_TYP_CWOP: - dissect_ansi_tcap_cwp_cwop(&asn1, tcap_tree, ti); - break; - case ANSI_ST_MSG_TYP_ABT: - dissect_ansi_tcap_abort(&asn1, tcap_tree, ti); - break; - default: - proto_tree_add_text(tcap_tree, asn1.tvb, offset, -1, - "Message type not handled, ignoring"); - break; + /* create display subtree for the protocol */ + if(parent_tree){ + item = proto_tree_add_item(parent_tree, proto_tcap, tvb, 0, -1, FALSE); + tree = proto_item_add_subtree(item, ett_tcap); } - - asn1_close(&asn1, &saved_offset); -} - -/* Code to actually dissect the packets */ -static void -dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -{ - proto_item *ti; - proto_tree *tcap_tree; - void *save_private_data = pinfo->private_data; - - g_pinfo = pinfo; + cur_oid = NULL; + tcapext_oid = NULL; pinfo->private_data = NULL; + dissect_tcap_MessageType(FALSE, tvb, 0, pinfo, tree, -1); - if (check_col(pinfo->cinfo, COL_PROTOCOL)) - col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCAP"); - /* Dissect the packet (even if !tree so can call sub-dissectors and update - * the INFO column) */ - ti = proto_tree_add_item(tree, proto_tcap, tvb, 0, -1, FALSE); - tcap_tree = proto_item_add_subtree(ti, ett_tcap); - g_tcap_tree = tree; - - if (tcap_standard == ITU_TCAP_STANDARD) - { - dissect_tcap_message(tvb, pinfo, tcap_tree); - } - else - { - dissect_ansi_tcap_message(tvb, pinfo, tcap_tree); - } - if ( pinfo->private_data != NULL) - g_free(pinfo->private_data); - pinfo->private_data = save_private_data; } + /* Register the protocol with Ethereal */ void proto_reg_handoff_tcap(void); @@ -2804,11 +2169,6 @@ proto_register_tcap(void) /* Setup list of header fields See Section 1.6.1 for details*/ static hf_register_info hf[] = { - /*{ &hf_tcap_FIELDABBREV, - { "FIELDNAME", "PROTOABBREV.FIELDABBREV", - FIELDTYPE, FIELDBASE, FIELDCONVERT, BITMASK, - "FIELDDESCR" } - },*/ { &hf_tcap_tag, { "Tag", "tcap.msgtype", FT_UINT8, BASE_HEX, NULL, 0, @@ -2819,88 +2179,575 @@ proto_register_tcap(void) FT_UINT8, BASE_HEX, NULL, 0, "", HFILL } }, - { &hf_tcap_id, - { "Value", "tcap.id", - FT_UINT8, BASE_HEX, NULL, 0, - "", HFILL } - }, - { &hf_tcap_message_type, - { "Message Type", "tcap.msgtype", - FT_UINT8, BASE_HEX, VALS(msg_type_strings), 0, - "", HFILL } - }, - { &hf_ansi_tcap_message_type, - { "Message Type", "tcap.msgtype", - FT_UINT8, BASE_HEX, VALS(ansi_msg_type_strings), 0, - "", HFILL } - }, - { &hf_tcap_tid, - { "Transaction Id", "tcap.tid", - FT_UINT32, BASE_DEC, VALS(tid_strings), 0, - "", HFILL } - }, - { &hf_tcap_ssn, - { "Called or Calling SubSystem Number", "tcap.ssn", - FT_UINT8, BASE_DEC, 0x0, 0x0, - "", HFILL } - }, - { &hf_tcap_dlg_type, - { "Dialogue Type", "tcap.dlgtype", - FT_UINT8, BASE_HEX, VALS(dlg_type_strings), 0, - "", HFILL } - }, - { &hf_tcap_app_con_name, - { "Application Context Name", "tcap.dlg.appconname", - FT_BYTES, BASE_HEX, 0, 0, - "", HFILL } - }, - { &hf_tcap_bytes, - { "Binary Data", "tcap.data", - FT_BYTES, BASE_HEX, 0, 0, - "", HFILL } - }, - { &hf_tcap_int, - { "Integer Data", "tcap.data", - FT_INT32, BASE_DEC, 0, 0, - "", HFILL } - }, - { &hf_tcap_oid, - { "OID", "tcap.oid", - FT_STRING, BASE_NONE, 0, 0, + { &hf_tcap_data, + { "Data", "tcap.data", + FT_BYTES, BASE_HEX, NULL, 0, "", HFILL } }, + +/*--- Included file: packet-tcap-hfarr.c ---*/ + + { &hf_tcap_dialogueRequest, + { "dialogueRequest", "tcap.dialogueRequest", + FT_NONE, BASE_NONE, NULL, 0, + "DialoguePDU/dialogueRequest", HFILL }}, + { &hf_tcap_dialogueResponse, + { "dialogueResponse", "tcap.dialogueResponse", + FT_NONE, BASE_NONE, NULL, 0, + "DialoguePDU/dialogueResponse", HFILL }}, + { &hf_tcap_dialogueAbort, + { "dialogueAbort", "tcap.dialogueAbort", + FT_NONE, BASE_NONE, NULL, 0, + "DialoguePDU/dialogueAbort", HFILL }}, + { &hf_tcap_oid, + { "oid", "tcap.oid", + FT_STRING, BASE_NONE, NULL, 0, + "ExternalPDU/oid", HFILL }}, + { &hf_tcap_dialog, + { "dialog", "tcap.dialog", + FT_BYTES, BASE_HEX, NULL, 0, + "ExternalPDU/dialog", HFILL }}, + { &hf_tcap_useroid, + { "useroid", "tcap.useroid", + FT_STRING, BASE_NONE, NULL, 0, + "UserInformation/useroid", HFILL }}, + { &hf_tcap_externuserinfo, + { "externuserinfo", "tcap.externuserinfo", + FT_BYTES, BASE_HEX, NULL, 0, + "UserInformation/externuserinfo", HFILL }}, + { &hf_tcap_protocol_versionrq, + { "protocol-versionrq", "tcap.protocol_versionrq", + FT_BYTES, BASE_HEX, NULL, 0, + "AARQ-apdu/protocol-versionrq", HFILL }}, + { &hf_tcap_application_context_name, + { "application-context-name", "tcap.application_context_name", + FT_STRING, BASE_NONE, NULL, 0, + "", HFILL }}, + { &hf_tcap_user_information, + { "user-information", "tcap.user_information", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_protocol_versionre, + { "protocol-versionre", "tcap.protocol_versionre", + FT_BYTES, BASE_HEX, NULL, 0, + "AARE-apdu/protocol-versionre", HFILL }}, + { &hf_tcap_result, + { "result", "tcap.result", + FT_INT32, BASE_DEC, VALS(tcap_Associate_result_vals), 0, + "AARE-apdu/result", HFILL }}, + { &hf_tcap_result_source_diagnostic, + { "result-source-diagnostic", "tcap.result_source_diagnostic", + FT_UINT32, BASE_DEC, VALS(tcap_Associate_source_diagnostic_vals), 0, + "AARE-apdu/result-source-diagnostic", HFILL }}, + { &hf_tcap_reasonrq, + { "reasonrq", "tcap.reasonrq", + FT_INT32, BASE_DEC, VALS(tcap_Release_request_reason_vals), 0, + "RLRQ-apdu/reasonrq", HFILL }}, + { &hf_tcap_reasonre, + { "reasonre", "tcap.reasonre", + FT_INT32, BASE_DEC, VALS(tcap_Release_response_reason_vals), 0, + "RLRE-apdu/reasonre", HFILL }}, + { &hf_tcap_abort_source, + { "abort-source", "tcap.abort_source", + FT_INT32, BASE_DEC, VALS(tcap_ABRT_source_vals), 0, + "ABRT-apdu/abort-source", HFILL }}, + { &hf_tcap_dialogue_service_user, + { "dialogue-service-user", "tcap.dialogue_service_user", + FT_INT32, BASE_DEC, VALS(tcap_T_dialogue_service_user_vals), 0, + "Associate-source-diagnostic/dialogue-service-user", HFILL }}, + { &hf_tcap_dialogue_service_provider, + { "dialogue-service-provider", "tcap.dialogue_service_provider", + FT_INT32, BASE_DEC, VALS(tcap_T_dialogue_service_provider_vals), 0, + "Associate-source-diagnostic/dialogue-service-provider", HFILL }}, + { &hf_tcap_unidialoguePDU, + { "unidialoguePDU", "tcap.unidialoguePDU", + FT_NONE, BASE_NONE, NULL, 0, + "UniDialoguePDU/unidialoguePDU", HFILL }}, + { &hf_tcap_protocol_version3, + { "protocol-version3", "tcap.protocol_version3", + FT_BYTES, BASE_HEX, NULL, 0, + "AUDT-apdu/protocol-version3", HFILL }}, + { &hf_tcap_unidirectional, + { "unidirectional", "tcap.unidirectional", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/unidirectional", HFILL }}, + { &hf_tcap_begin, + { "begin", "tcap.begin", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/begin", HFILL }}, + { &hf_tcap_end, + { "end", "tcap.end", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/end", HFILL }}, + { &hf_tcap_continue, + { "continue", "tcap.continue", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/continue", HFILL }}, + { &hf_tcap_abort, + { "abort", "tcap.abort", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/abort", HFILL }}, + { &hf_tcap_ansiunidirectional, + { "ansiunidirectional", "tcap.ansiunidirectional", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiunidirectional", HFILL }}, + { &hf_tcap_ansiqueryWithPerm, + { "ansiqueryWithPerm", "tcap.ansiqueryWithPerm", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiqueryWithPerm", HFILL }}, + { &hf_tcap_ansiqueryWithoutPerm, + { "ansiqueryWithoutPerm", "tcap.ansiqueryWithoutPerm", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiqueryWithoutPerm", HFILL }}, + { &hf_tcap_ansiresponse, + { "ansiresponse", "tcap.ansiresponse", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiresponse", HFILL }}, + { &hf_tcap_ansiconversationWithPerm, + { "ansiconversationWithPerm", "tcap.ansiconversationWithPerm", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiconversationWithPerm", HFILL }}, + { &hf_tcap_ansiconversationWithoutPerm, + { "ansiconversationWithoutPerm", "tcap.ansiconversationWithoutPerm", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiconversationWithoutPerm", HFILL }}, + { &hf_tcap_ansiabort, + { "ansiabort", "tcap.ansiabort", + FT_NONE, BASE_NONE, NULL, 0, + "MessageType/ansiabort", HFILL }}, + { &hf_tcap_dialoguePortion, + { "dialoguePortion", "tcap.dialoguePortion", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_components, + { "components", "tcap.components", + FT_NONE, BASE_NONE, NULL, 0, + "", HFILL }}, + { &hf_tcap_otid, + { "otid", "tcap.otid", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_dtid, + { "dtid", "tcap.dtid", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_reason, + { "reason", "tcap.reason", + FT_UINT32, BASE_DEC, VALS(tcap_Reason_vals), 0, + "Abort/reason", HFILL }}, + { &hf_tcap_p_abortCause, + { "p-abortCause", "tcap.p_abortCause", + FT_INT32, BASE_DEC, VALS(tcap_P_AbortCause_vals), 0, + "Reason/p-abortCause", HFILL }}, + { &hf_tcap_u_abortCause, + { "u-abortCause", "tcap.u_abortCause", + FT_BYTES, BASE_HEX, NULL, 0, + "Reason/u-abortCause", HFILL }}, + { &hf_tcap_ComponentPortion_item, + { "Item", "tcap.ComponentPortion_item", + FT_UINT32, BASE_DEC, VALS(tcap_Component_vals), 0, + "ComponentPortion/_item", HFILL }}, + { &hf_tcap_invoke, + { "invoke", "tcap.invoke", + FT_NONE, BASE_NONE, NULL, 0, + "Component/invoke", HFILL }}, + { &hf_tcap_returnResultLast, + { "returnResultLast", "tcap.returnResultLast", + FT_NONE, BASE_NONE, NULL, 0, + "Component/returnResultLast", HFILL }}, + { &hf_tcap_returnError, + { "returnError", "tcap.returnError", + FT_NONE, BASE_NONE, NULL, 0, + "Component/returnError", HFILL }}, + { &hf_tcap_reject, + { "reject", "tcap.reject", + FT_NONE, BASE_NONE, NULL, 0, + "Component/reject", HFILL }}, + { &hf_tcap_returnResultNotLast, + { "returnResultNotLast", "tcap.returnResultNotLast", + FT_NONE, BASE_NONE, NULL, 0, + "Component/returnResultNotLast", HFILL }}, + { &hf_tcap_invokeID, + { "invokeID", "tcap.invokeID", + FT_UINT32, BASE_DEC, NULL, 0, + "", HFILL }}, + { &hf_tcap_linkedID, + { "linkedID", "tcap.linkedID", + FT_UINT32, BASE_DEC, NULL, 0, + "Invoke/linkedID", HFILL }}, + { &hf_tcap_operationCode, + { "operationCode", "tcap.operationCode", + FT_UINT32, BASE_DEC, VALS(tcap_OperationCode_vals), 0, + "", HFILL }}, + { &hf_tcap_parameter, + { "parameter", "tcap.parameter", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_resultretres, + { "resultretres", "tcap.resultretres", + FT_NONE, BASE_NONE, NULL, 0, + "ReturnResult/resultretres", HFILL }}, + { &hf_tcap_errorCode, + { "errorCode", "tcap.errorCode", + FT_UINT32, BASE_DEC, VALS(tcap_ErrorCode_vals), 0, + "", HFILL }}, + { &hf_tcap_invokeIDRej, + { "invokeIDRej", "tcap.invokeIDRej", + FT_UINT32, BASE_DEC, VALS(tcap_T_invokeIDRej_vals), 0, + "Reject/invokeIDRej", HFILL }}, + { &hf_tcap_derivable, + { "derivable", "tcap.derivable", + FT_UINT32, BASE_DEC, NULL, 0, + "Reject/invokeIDRej/derivable", HFILL }}, + { &hf_tcap_not_derivable, + { "not-derivable", "tcap.not_derivable", + FT_NONE, BASE_NONE, NULL, 0, + "Reject/invokeIDRej/not-derivable", HFILL }}, + { &hf_tcap_problem, + { "problem", "tcap.problem", + FT_UINT32, BASE_DEC, VALS(tcap_T_problem_vals), 0, + "Reject/problem", HFILL }}, + { &hf_tcap_generalProblem, + { "generalProblem", "tcap.generalProblem", + FT_INT32, BASE_DEC, VALS(tcap_GeneralProblem_vals), 0, + "Reject/problem/generalProblem", HFILL }}, + { &hf_tcap_invokeProblem, + { "invokeProblem", "tcap.invokeProblem", + FT_INT32, BASE_DEC, VALS(tcap_InvokeProblem_vals), 0, + "Reject/problem/invokeProblem", HFILL }}, + { &hf_tcap_returnResultProblem, + { "returnResultProblem", "tcap.returnResultProblem", + FT_INT32, BASE_DEC, VALS(tcap_ReturnResultProblem_vals), 0, + "Reject/problem/returnResultProblem", HFILL }}, + { &hf_tcap_returnErrorProblem, + { "returnErrorProblem", "tcap.returnErrorProblem", + FT_INT32, BASE_DEC, VALS(tcap_ReturnErrorProblem_vals), 0, + "Reject/problem/returnErrorProblem", HFILL }}, + { &hf_tcap_localValue, + { "localValue", "tcap.localValue", + FT_INT32, BASE_DEC, NULL, 0, + "", HFILL }}, + { &hf_tcap_globalValue, + { "globalValue", "tcap.globalValue", + FT_STRING, BASE_NONE, NULL, 0, + "", HFILL }}, + { &hf_tcap_identifier, + { "identifier", "tcap.identifier", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_dialoguePortionansi, + { "dialoguePortionansi", "tcap.dialoguePortionansi", + FT_NONE, BASE_NONE, NULL, 0, + "", HFILL }}, + { &hf_tcap_componentPortion, + { "componentPortion", "tcap.componentPortion", + FT_NONE, BASE_NONE, NULL, 0, + "", HFILL }}, + { &hf_tcap_causeInformation, + { "causeInformation", "tcap.causeInformation", + FT_UINT32, BASE_DEC, VALS(tcap_T_causeInformation_vals), 0, + "AbortPDU/causeInformation", HFILL }}, + { &hf_tcap_abortCause, + { "abortCause", "tcap.abortCause", + FT_INT32, BASE_DEC, VALS(tcap_P_Abort_cause_vals), 0, + "AbortPDU/causeInformation/abortCause", HFILL }}, + { &hf_tcap_userInformation, + { "userInformation", "tcap.userInformation", + FT_NONE, BASE_NONE, NULL, 0, + "", HFILL }}, + { &hf_tcap_version, + { "version", "tcap.version", + FT_BYTES, BASE_HEX, NULL, 0, + "DialoguePortionANSI/version", HFILL }}, + { &hf_tcap_applicationContext, + { "applicationContext", "tcap.applicationContext", + FT_UINT32, BASE_DEC, VALS(tcap_T_applicationContext_vals), 0, + "DialoguePortionANSI/applicationContext", HFILL }}, + { &hf_tcap_integerApplicationId, + { "integerApplicationId", "tcap.integerApplicationId", + FT_INT32, BASE_DEC, NULL, 0, + "DialoguePortionANSI/applicationContext/integerApplicationId", HFILL }}, + { &hf_tcap_objectApplicationId, + { "objectApplicationId", "tcap.objectApplicationId", + FT_STRING, BASE_NONE, NULL, 0, + "DialoguePortionANSI/applicationContext/objectApplicationId", HFILL }}, + { &hf_tcap_securityContext, + { "securityContext", "tcap.securityContext", + FT_UINT32, BASE_DEC, VALS(tcap_T_securityContext_vals), 0, + "DialoguePortionANSI/securityContext", HFILL }}, + { &hf_tcap_integerSecurityId, + { "integerSecurityId", "tcap.integerSecurityId", + FT_INT32, BASE_DEC, NULL, 0, + "DialoguePortionANSI/securityContext/integerSecurityId", HFILL }}, + { &hf_tcap_objectSecurityId, + { "objectSecurityId", "tcap.objectSecurityId", + FT_STRING, BASE_NONE, NULL, 0, + "DialoguePortionANSI/securityContext/objectSecurityId", HFILL }}, + { &hf_tcap_confidentiality, + { "confidentiality", "tcap.confidentiality", + FT_NONE, BASE_NONE, NULL, 0, + "DialoguePortionANSI/confidentiality", HFILL }}, + { &hf_tcap_confidentialityId, + { "confidentialityId", "tcap.confidentialityId", + FT_UINT32, BASE_DEC, VALS(tcap_T_confidentialityId_vals), 0, + "Confidentiality/confidentialityId", HFILL }}, + { &hf_tcap_integerConfidentialityId, + { "integerConfidentialityId", "tcap.integerConfidentialityId", + FT_INT32, BASE_DEC, NULL, 0, + "Confidentiality/confidentialityId/integerConfidentialityId", HFILL }}, + { &hf_tcap_objectConfidentialityId, + { "objectConfidentialityId", "tcap.objectConfidentialityId", + FT_STRING, BASE_NONE, NULL, 0, + "Confidentiality/confidentialityId/objectConfidentialityId", HFILL }}, + { &hf_tcap_ComponentSequence_item, + { "Item", "tcap.ComponentSequence_item", + FT_UINT32, BASE_DEC, VALS(tcap_ComponentPDU_vals), 0, + "ComponentSequence/_item", HFILL }}, + { &hf_tcap_invokeLastansi, + { "invokeLastansi", "tcap.invokeLastansi", + FT_NONE, BASE_NONE, NULL, 0, + "ComponentPDU/invokeLastansi", HFILL }}, + { &hf_tcap_returnResultLastansi, + { "returnResultLastansi", "tcap.returnResultLastansi", + FT_NONE, BASE_NONE, NULL, 0, + "ComponentPDU/returnResultLastansi", HFILL }}, + { &hf_tcap_returnErroransi, + { "returnErroransi", "tcap.returnErroransi", + FT_NONE, BASE_NONE, NULL, 0, + "ComponentPDU/returnErroransi", HFILL }}, + { &hf_tcap_rejectansi, + { "rejectansi", "tcap.rejectansi", + FT_NONE, BASE_NONE, NULL, 0, + "ComponentPDU/rejectansi", HFILL }}, + { &hf_tcap_invokeNotLastansi, + { "invokeNotLastansi", "tcap.invokeNotLastansi", + FT_NONE, BASE_NONE, NULL, 0, + "ComponentPDU/invokeNotLastansi", HFILL }}, + { &hf_tcap_returnResultNotLastansi, + { "returnResultNotLastansi", "tcap.returnResultNotLastansi", + FT_NONE, BASE_NONE, NULL, 0, + "ComponentPDU/returnResultNotLastansi", HFILL }}, + { &hf_tcap_componentIDs, + { "componentIDs", "tcap.componentIDs", + FT_BYTES, BASE_HEX, NULL, 0, + "InvokePDU/componentIDs", HFILL }}, + { &hf_tcap_parameterinv, + { "parameterinv", "tcap.parameterinv", + FT_NONE, BASE_NONE, NULL, 0, + "InvokePDU/parameterinv", HFILL }}, + { &hf_tcap_ansiparams, + { "ansiparams", "tcap.ansiparams", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams", HFILL }}, + { &hf_tcap_ansiparams1, + { "ansiparams1", "tcap.ansiparams1", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams1", HFILL }}, + { &hf_tcap_ansiparams2, + { "ansiparams2", "tcap.ansiparams2", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams2", HFILL }}, + { &hf_tcap_ansiparams3, + { "ansiparams3", "tcap.ansiparams3", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams3", HFILL }}, + { &hf_tcap_ansiparams4, + { "ansiparams4", "tcap.ansiparams4", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams4", HFILL }}, + { &hf_tcap_ansiparams5, + { "ansiparams5", "tcap.ansiparams5", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams5", HFILL }}, + { &hf_tcap_ansiparams6, + { "ansiparams6", "tcap.ansiparams6", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams6", HFILL }}, + { &hf_tcap_ansiparams7, + { "ansiparams7", "tcap.ansiparams7", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams7", HFILL }}, + { &hf_tcap_ansiparams8, + { "ansiparams8", "tcap.ansiparams8", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams8", HFILL }}, + { &hf_tcap_ansiparams9, + { "ansiparams9", "tcap.ansiparams9", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams9", HFILL }}, + { &hf_tcap_ansiparams10, + { "ansiparams10", "tcap.ansiparams10", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams10", HFILL }}, + { &hf_tcap_ansiparams11, + { "ansiparams11", "tcap.ansiparams11", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams11", HFILL }}, + { &hf_tcap_ansiparams12, + { "ansiparams12", "tcap.ansiparams12", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams12", HFILL }}, + { &hf_tcap_ansiparams13, + { "ansiparams13", "tcap.ansiparams13", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams13", HFILL }}, + { &hf_tcap_ansiparams14, + { "ansiparams14", "tcap.ansiparams14", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams14", HFILL }}, + { &hf_tcap_ansiparams15, + { "ansiparams15", "tcap.ansiparams15", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams15", HFILL }}, + { &hf_tcap_ansiparams16, + { "ansiparams16", "tcap.ansiparams16", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams16", HFILL }}, + { &hf_tcap_ansiparams17, + { "ansiparams17", "tcap.ansiparams17", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams17", HFILL }}, + { &hf_tcap_ansiparams18, + { "ansiparams18", "tcap.ansiparams18", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams18", HFILL }}, + { &hf_tcap_ansiparams19, + { "ansiparams19", "tcap.ansiparams19", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams19", HFILL }}, + { &hf_tcap_ansiparams20, + { "ansiparams20", "tcap.ansiparams20", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams20", HFILL }}, + { &hf_tcap_ansiparams21, + { "ansiparams21", "tcap.ansiparams21", + FT_NONE, BASE_NONE, NULL, 0, + "ANSIparamch/ansiparams21", HFILL }}, + { &hf_tcap_componentID, + { "componentID", "tcap.componentID", + FT_BYTES, BASE_HEX, NULL, 0, + "", HFILL }}, + { &hf_tcap_parameterrr, + { "parameterrr", "tcap.parameterrr", + FT_NONE, BASE_NONE, NULL, 0, + "ReturnResultPDU/parameterrr", HFILL }}, + { &hf_tcap_parameterre, + { "parameterre", "tcap.parameterre", + FT_NONE, BASE_NONE, NULL, 0, + "ReturnErrorPDU/parameterre", HFILL }}, + { &hf_tcap_rejectProblem, + { "rejectProblem", "tcap.rejectProblem", + FT_INT32, BASE_DEC, VALS(tcap_ProblemPDU_vals), 0, + "RejectPDU/rejectProblem", HFILL }}, + { &hf_tcap_parameterrj, + { "parameterrj", "tcap.parameterrj", + FT_NONE, BASE_NONE, NULL, 0, + "RejectPDU/parameterrj", HFILL }}, + { &hf_tcap_national, + { "national", "tcap.national", + FT_UINT32, BASE_DEC, NULL, 0, + "OperationCode/national", HFILL }}, + { &hf_tcap_private, + { "private", "tcap.private", + FT_INT32, BASE_DEC, NULL, 0, + "OperationCode/private", HFILL }}, + { &hf_tcap_nationaler, + { "nationaler", "tcap.nationaler", + FT_UINT32, BASE_DEC, NULL, 0, + "ErrorCode/nationaler", HFILL }}, + { &hf_tcap_privateer, + { "privateer", "tcap.privateer", + FT_INT32, BASE_DEC, NULL, 0, + "ErrorCode/privateer", HFILL }}, + { &hf_tcap_T_protocol_versionrq_version1, + { "version1", "tcap.version1", + FT_BOOLEAN, 8, NULL, 0x80, + "", HFILL }}, + { &hf_tcap_T_protocol_versionre_version1, + { "version1", "tcap.version1", + FT_BOOLEAN, 8, NULL, 0x80, + "", HFILL }}, + { &hf_tcap_T_protocol_version3_version1, + { "version1", "tcap.version1", + FT_BOOLEAN, 8, NULL, 0x80, + "", HFILL }}, + +/*--- End of included file: packet-tcap-hfarr.c ---*/ + }; /* Setup protocol subtree array */ static gint *ett[] = { &ett_tcap, - &ett_otid, - &ett_dtid, - &ett_dlg_portion, - &ett_comps_portion, - &ett_reason, - &ett_dlg_req, - &ett_dlg_rsp, - &ett_dlg_abort, - &ett_component, - &ett_error, - &ett_problem, - &ett_params, &ett_param, - &ett_para_portion, + +/*--- Included file: packet-tcap-ettarr.c ---*/ + + &ett_tcap_DialoguePDU, + &ett_tcap_ExternalPDU, + &ett_tcap_UserInformation, + &ett_tcap_AARQ_apdu, + &ett_tcap_T_protocol_versionrq, + &ett_tcap_AARE_apdu, + &ett_tcap_T_protocol_versionre, + &ett_tcap_RLRQ_apdu, + &ett_tcap_RLRE_apdu, + &ett_tcap_ABRT_apdu, + &ett_tcap_Associate_source_diagnostic, + &ett_tcap_UniDialoguePDU, + &ett_tcap_AUDT_apdu, + &ett_tcap_T_protocol_version3, + &ett_tcap_MessageType, + &ett_tcap_Unidirectional, + &ett_tcap_Begin, + &ett_tcap_End, + &ett_tcap_Continue, + &ett_tcap_Abort, + &ett_tcap_Reason, + &ett_tcap_ComponentPortion, + &ett_tcap_Component, + &ett_tcap_Invoke, + &ett_tcap_ReturnResult, + &ett_tcap_T_resultretres, + &ett_tcap_ReturnError, + &ett_tcap_Reject, + &ett_tcap_T_invokeIDRej, + &ett_tcap_T_problem, + &ett_tcap_OPERATION, + &ett_tcap_ERROR, + &ett_tcap_UniTransactionPDU, + &ett_tcap_TransactionPDU, + &ett_tcap_AbortPDU, + &ett_tcap_T_causeInformation, + &ett_tcap_DialoguePortionANSI, + &ett_tcap_T_applicationContext, + &ett_tcap_T_securityContext, + &ett_tcap_Confidentiality, + &ett_tcap_T_confidentialityId, + &ett_tcap_ComponentSequence, + &ett_tcap_ComponentPDU, + &ett_tcap_InvokePDU, + &ett_tcap_ANSIparamch, + &ett_tcap_ReturnResultPDU, + &ett_tcap_ReturnErrorPDU, + &ett_tcap_RejectPDU, + &ett_tcap_OperationCode, + &ett_tcap_ErrorCode, + +/*--- End of included file: packet-tcap-ettarr.c ---*/ + }; - static enum_val_t tcap_options[] = { + /*static enum_val_t tcap_options[] = { { "itu", "ITU", ITU_TCAP_STANDARD }, { "ansi", "ANSI", ANSI_TCAP_STANDARD }, { NULL, NULL, 0 } - }; + };*/ module_t *tcap_module; /* Register the protocol name and description */ - proto_tcap = proto_register_protocol("Transaction Capabilities Application Part", - "TCAP", "tcap"); + proto_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_tcap, hf, array_length(hf)); @@ -2908,16 +2755,16 @@ proto_register_tcap(void) tcap_module = prefs_register_protocol(proto_tcap, proto_reg_handoff_tcap); - prefs_register_enum_preference(tcap_module, "standard", "TCAP standard", - "The SS7 standard used in TCAP packets", - &tcap_standard, tcap_options, FALSE); + /*prefs_register_enum_preference(tcap_module, "standard", "ITU TCAP standard", + "The SS7 standard used in ITU TCAP packets", + &tcap_standard, tcap_options, FALSE);*/ - prefs_register_bool_preference(tcap_module, "lock_info_col", "Lock Info column", +/* prefs_register_bool_preference(tcap_module, "lock_info_col", "Lock Info column", "Always show TCAP in Info column", &lock_info_col); - +*/ /* Set default SSNs */ - range_convert_str(&global_ssn_range, "5-12", MAX_SSN); + range_convert_str(&global_ssn_range, "1-255", MAX_SSN); ssn_range = range_empty(); prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs", @@ -2927,9 +2774,13 @@ proto_register_tcap(void) /* we will fake a ssn subfield which has the same value obtained from sccp */ tcap_itu_ssn_dissector_table = register_dissector_table("tcap.itu_ssn", "ITU TCAP SSN", FT_UINT8, BASE_DEC); tcap_ansi_ssn_dissector_table = register_dissector_table("tcap.ansi_ssn", "ANSI TCAP SSN", FT_UINT8, BASE_DEC); + + } + + /* If this dissector uses sub-dissector registration add a registration routine. This format is required because a script is used to find these routines and create the code that calls these routines. @@ -2959,8 +2810,7 @@ proto_reg_handoff_tcap(void) if (!prefs_initialized) { tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap); - data_handle = find_dissector("data"); - + prefs_initialized = TRUE; } else { @@ -2976,3 +2826,134 @@ proto_reg_handoff_tcap(void) "itu-t(0) recommendation(0) q(17) 773 as(1) dialogue-as(1) version1(1)"); } + + + + +/* some functions from packet_tcap which are needed by some other dissectors */ + +#define TC_DS_OK 1 +#define TC_DS_FAIL 0 + + +int +tcap_find_eoc(ASN1_SCK *asn1) +{ + guint saved_offset; + gint prev_offset; + guint tag; + guint len; + gboolean def_len; + + saved_offset = asn1->offset; + + while (!asn1_eoc(asn1, -1)) + { + prev_offset = asn1->offset; + asn1_id_decode1(asn1, &tag); + asn1_length_decode(asn1, &def_len, &len); + + if (def_len) + { + asn1->offset += len; + } + else + { + asn1->offset += tcap_find_eoc(asn1); + asn1_eoc_decode(asn1, -1); + } + if (prev_offset >= asn1->offset) + THROW(ReportedBoundsError); + } + + len = asn1->offset - saved_offset; + asn1->offset = saved_offset; + + return(len); +} + +gboolean +tcap_check_tag(ASN1_SCK *asn1, guint tag) +{ + guint saved_offset, real_tag; + + if (tvb_length_remaining(asn1->tvb, asn1->offset) <= 0) + { + return (FALSE); + } + + saved_offset = asn1->offset; + asn1_id_decode1(asn1, &real_tag); + asn1->offset = saved_offset; + return (tag == real_tag); +} + + +static int +dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) +{ + gint orig_offset, tag_offset, saved_offset, len_offset; + tvbuff_t *next_tvb; + proto_tree *subtree; + proto_item *pi; + gint32 tlen; + guint8 class; + gboolean pc; + guint32 tag; + guint32 len; + guint32 ind_field; + guint32 soffset = offset; + +orig_offset = offset; +tlen = tvb_length_remaining(tvb, offset); + while (tlen > (offset-orig_offset)) + { + saved_offset = offset; + + offset = get_ber_identifier(tvb, offset, &class, &pc, &tag); + tag_offset = offset; + offset = get_ber_length(tree, tvb, offset, &len, &ind_field); + len_offset = offset; + + + + if (pc) + { + pi = + proto_tree_add_text(tree, tvb, saved_offset, -1, "CONSTRUCTOR"); + subtree = proto_item_add_subtree(pi, ett_param); + proto_tree_add_uint_format(subtree, hf_tcap_tag, tvb, + saved_offset, tag_offset-saved_offset, tag, "CONSTRUCTOR Tag"); + proto_tree_add_uint(subtree, hf_tcap_tag, tvb, + saved_offset, tag_offset-saved_offset, class); + + proto_tree_add_uint(subtree, hf_tcap_length, tvb, + tag_offset, len_offset-tag_offset, len); + /* need to handle indefinite length */ + next_tvb = tvb_new_subset(tvb, offset, len, len); + dissect_tcap_param(pinfo, subtree,next_tvb,0); + offset += len; + } + else + { + + + pi = + proto_tree_add_text(tree, tvb, + saved_offset, len + (len_offset - saved_offset), "Parameter"); + + subtree = proto_item_add_subtree(pi, ett_param); + + proto_tree_add_uint(subtree, hf_tcap_tag, tvb, + saved_offset, 1, tag); + + proto_tree_add_uint(subtree, hf_tcap_length, tvb, + saved_offset+1, 1, len); + next_tvb = tvb_new_subset(tvb, offset, len, len); + dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_tcap_data, + NULL); + offset += len; + } + } +return offset; +}
\ No newline at end of file diff --git a/epan/dissectors/packet-tcap.h b/epan/dissectors/packet-tcap.h index c644b0a54e..327a094ee9 100644 --- a/epan/dissectors/packet-tcap.h +++ b/epan/dissectors/packet-tcap.h @@ -1,11 +1,15 @@ +/* Do not modify this file. */ +/* It is created automatically by the ASN.1 to Ethereal dissector compiler */ +/* .\packet-tcap.h */ +/* ../../tools/asn2eth.py -X -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */ + +/* Input file: packet-tcap-template.h */ + /* packet-tcap.h * * $Id$ * - * Copyright 2003, Michael Lum <mlum [AT] telostech.com>, - * In association with Telos Technology Inc. - * - * Taken from packet-mtp3.h + * Copyright 2004, Tim Endean <endeant@hotmail.com> * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -26,15 +30,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -typedef enum { - ITU_TCAP_STANDARD = 1, - ANSI_TCAP_STANDARD = 2 -} Tcap_Standard_Type; - -extern gint tcap_standard; - -extern const value_string tcap_component_type_str[]; +#ifndef PACKET_tcap_H +#define PACKET_tcap_H /* TCAP component type */ #define TCAP_COMP_INVOKE 0xa1 #define TCAP_COMP_RRL 0xa2 @@ -42,7 +40,7 @@ extern const value_string tcap_component_type_str[]; #define TCAP_COMP_REJECT 0xa4 #define TCAP_COMP_RRN 0xa7 -/* ANSI TCAP component type */ + #define ANSI_TC_INVOKE_L 0xe9 #define ANSI_TC_RRL 0xea #define ANSI_TC_RE 0xeb @@ -56,9 +54,21 @@ extern const value_string tcap_component_type_str[]; #define TCAP_INVOKE_ID_TAG 0x02 #define TCAP_LINKED_ID_TAG 0x80 -#define TCAP_EOC_LEN 2 /* 0x00 0x00 */ +#define TCAP_EOC_LEN 2 #define TCAP_CONSTRUCTOR(TCtag) (TCtag & 0x20) + + +extern gint tcap_standard; + +extern const value_string tcap_component_type_str[]; + + extern int tcap_find_eoc(ASN1_SCK *asn1); + extern gboolean tcap_check_tag(ASN1_SCK *asn1, guint tag); + + + +#endif /* PACKET_INAP_H */ |