diff options
author | Luke Mewburn <luke@mewburn.net> | 2014-12-23 18:32:34 +1100 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-01-19 03:08:54 +0000 |
commit | 119416ef2765f290b4cdaaf930438f9b603abd9c (patch) | |
tree | 749282cffd696aa07e4e957cd239b79b82cc9278 /asn1 | |
parent | c4297e63915acaf9f3f6304fe255326ea553767f (diff) |
TCAP: support dialogue confirmation
TCAP permits the changing of the originating address on the first
backwards continue (i.e. the establishment of the dialogue).
See ITU-T Q.771 (06/97) clause 3.1.2.2.2.2 Confirmation of the dialogue.
In practice, a BEGIN replied to with an END can also exhibit this behaviour.
For example, a BEGIN from GT A TID TA -> GT B,
and the reply CONTINUE from GT B2 TID TB -> GT A TID TA.
To support this, only support a single address hash in
tcaphash_begin_info_key_t and tcaphash_end_info_key_t.
The match of the first CONTINUE should find the appropriate
tcaphash_begin and create the appropriate tcaphash_end entries.
Also fix compile warning with DEBUG_TCAPSRT.
Bug: 10841
Change-Id: Ibe75e3940e757727357b20be10f9c195c5888fdd
Reviewed-on: https://code.wireshark.org/review/6446
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/tcap/packet-tcap-template.c | 110 | ||||
-rw-r--r-- | asn1/tcap/packet-tcap-template.h | 6 |
2 files changed, 57 insertions, 59 deletions
diff --git a/asn1/tcap/packet-tcap-template.c b/asn1/tcap/packet-tcap-template.c index 336536128f..b1a7dd7f80 100644 --- a/asn1/tcap/packet-tcap-template.c +++ b/asn1/tcap/packet-tcap-template.c @@ -169,7 +169,7 @@ dissector_handle_t get_itu_tcap_subdissector(guint32 ssn) { static guint debug_level = 99; static void -dbg(guint level, char* fmt, ...) +dbg(guint level, const char* fmt, ...) { va_list ap; @@ -205,15 +205,7 @@ tcaphash_begin_equal(gconstpointer k1, gconstpointer k2) const struct tcaphash_begin_info_key_t *key2 = (const struct tcaphash_begin_info_key_t *) k2; if (key1->hashKey == key2->hashKey) { - - if ( ( (key1->opc_hash == key2->opc_hash) && - (key1->dpc_hash == key2->dpc_hash) && - (key1->tid == key2->tid) ) - || - ( (key1->opc_hash == key2->dpc_hash) && - (key1->dpc_hash == key2->opc_hash) && - (key1->tid == key2->tid) ) - ) + if ( (key1->pc_hash == key2->pc_hash) && (key1->tid == key2->tid) ) return TRUE; } return FALSE; @@ -272,13 +264,7 @@ tcaphash_end_equal(gconstpointer k1, gconstpointer k2) const struct tcaphash_end_info_key_t *key2 = (const struct tcaphash_end_info_key_t *) k2; if (key1->hashKey == key2->hashKey) { - if ( ( (key1->opc_hash == key2->opc_hash) && - (key1->dpc_hash == key2->dpc_hash) && - (key1->tid == key2->tid) ) - || - ( (key1->opc_hash == key2->dpc_hash) && - (key1->dpc_hash == key2->opc_hash) && - (key1->tid == key2->tid) ) ) + if ( (key1->pc_hash == key2->pc_hash) && (key1->tid == key2->tid) ) return TRUE; } return FALSE; @@ -688,8 +674,7 @@ new_tcaphash_begin(struct tcaphash_begin_info_key_t *p_tcaphash_begin_key, #endif p_new_tcaphash_begin_key->hashKey = p_tcaphash_begin_key->hashKey; p_new_tcaphash_begin_key->tid = p_tcaphash_begin_key->tid; - p_new_tcaphash_begin_key->opc_hash = p_tcaphash_begin_key->opc_hash; - p_new_tcaphash_begin_key->dpc_hash = p_tcaphash_begin_key->dpc_hash; + p_new_tcaphash_begin_key->pc_hash = p_tcaphash_begin_key->pc_hash; #ifdef MEM_TCAPSRT p_new_tcaphash_begincall = (struct tcaphash_begincall_t *)g_malloc0(sizeof(struct tcaphash_begincall_t)); @@ -780,8 +765,7 @@ new_tcaphash_end(struct tcaphash_end_info_key_t *p_tcaphash_end_key, #endif p_new_tcaphash_end_key->hashKey = p_tcaphash_end_key->hashKey; p_new_tcaphash_end_key->tid = p_tcaphash_end_key->tid; - p_new_tcaphash_end_key->opc_hash = p_tcaphash_end_key->opc_hash; - p_new_tcaphash_end_key->dpc_hash = p_tcaphash_end_key->dpc_hash; + p_new_tcaphash_end_key->pc_hash = p_tcaphash_end_key->pc_hash; #ifdef MEM_TCAPSRT p_new_tcaphash_endcall = (struct tcaphash_endcall_t *)g_malloc0(sizeof(struct tcaphash_endcall_t)); @@ -985,17 +969,19 @@ tcaphash_begin_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *stat_item=NULL; proto_tree *stat_tree=NULL; +#ifdef DEBUG_TCAPSRT + dbg(51,"src %s srcTid %lx dst %s ", address_to_str(wmem_packet_scope(), &pinfo->src), p_tcapsrt_info->src_tid, address_to_str(wmem_packet_scope(), &pinfo->dst)); +#endif + /* prepare the key data */ tcaphash_begin_key.tid = p_tcapsrt_info->src_tid; if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC) { /* We have MTP3 PCs (so we can safely do this cast) */ - tcaphash_begin_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); - tcaphash_begin_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); + tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ - tcaphash_begin_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); - tcaphash_begin_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); + /* Don't have MTP3 PCs (have SCCP GT ?) */ + tcaphash_begin_key.pc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); } tcaphash_begin_key.hashKey=tcaphash_begin_calchash(&tcaphash_begin_key); @@ -1003,7 +989,7 @@ tcaphash_begin_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, #ifdef DEBUG_TCAPSRT dbg(10,"\n Hbegin #%u ", pinfo->fd->num); dbg(11,"key %lx ",tcaphash_begin_key.hashKey); - dbg(51,"PC %s %s ",address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst)); + dbg(51,"addr %s ", address_to_str(wmem_packet_scope(), &pinfo->src)); dbg(51,"Tid %lx \n",tcaphash_begin_key.tid); #endif @@ -1174,6 +1160,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *stat_tree=NULL; #ifdef DEBUG_TCAPSRT + dbg(51,"src %s srcTid %lx dst %s dstTid %lx ", address_to_str(wmem_packet_scope(), &pinfo->src), p_tcapsrt_info->src_tid, address_to_str(wmem_packet_scope(), &pinfo->dst), p_tcapsrt_info->dst_tid); dbg(10,"\n Hcont #%u ", pinfo->fd->num); #endif @@ -1186,7 +1173,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tcaphash_cont_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); tcaphash_cont_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ + /* Don't have MTP3 PCs (have SCCP GT ?) */ tcaphash_cont_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); tcaphash_cont_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); } @@ -1194,7 +1181,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, #ifdef DEBUG_TCAPSRT dbg(11,"Ckey %lx ", tcaphash_cont_key.hashKey); - dbg(51,"PC %s %s ",address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst)); + dbg(51,"addr %s %s ", address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst)); dbg(51,"Tid %lx %lx \n",tcaphash_cont_key.src_tid, tcaphash_cont_key.dst_tid); #endif p_tcaphash_contcall = find_tcaphash_cont(&tcaphash_cont_key, pinfo); @@ -1207,30 +1194,45 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, #ifdef DEBUG_TCAPSRT dbg(12,"CnotFound "); #endif - /* Find the TCAP transaction according to the TC_BEGIN */ + /* Find the TCAP transaction according to the TC_BEGIN (from dtid,dst) */ tcaphash_begin_key.tid = p_tcapsrt_info->dst_tid; if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC) { /* We have MTP3 PCs (so we can safely do this cast) */ - tcaphash_begin_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); - tcaphash_begin_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); + tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ - tcaphash_begin_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); - tcaphash_begin_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); + /* Don't have MTP3 PCs (have SCCP GT ?) */ + tcaphash_begin_key.pc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); } tcaphash_begin_key.hashKey=tcaphash_begin_calchash(&tcaphash_begin_key); #ifdef DEBUG_TCAPSRT dbg(11,"Bkey %lx ", tcaphash_begin_key.hashKey); - dbg(51,"PC %s %s ",address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst)); + dbg(51,"addr %s ", address_to_str(wmem_packet_scope(), &pinfo->dst)); dbg(51,"Tid %lx \n",tcaphash_begin_key.tid); #endif p_tcaphash_begincall = find_tcaphash_begin(&tcaphash_begin_key, pinfo, FALSE); if(!p_tcaphash_begincall){ - /* Do we have a continue from the same source? */ +/* can this actually happen? */ +#ifdef DEBUG_TCAPSRT + dbg(12,"BNotFound trying stid,src"); +#endif + /* Do we have a continue from the same source? (stid,src) */ tcaphash_begin_key.tid = p_tcapsrt_info->src_tid; + if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC) + { + /* We have MTP3 PCs (so we can safely do this cast) */ + tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); + } else { + /* Don't have MTP3 PCs (have SCCP GT ?) */ + tcaphash_begin_key.pc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); + } tcaphash_begin_key.hashKey=tcaphash_begin_calchash(&tcaphash_begin_key); +#ifdef DEBUG_TCAPSRT + dbg(11,"Bkey %lx ", tcaphash_begin_key.hashKey); + dbg(51,"addr %s ", address_to_str(wmem_packet_scope(), &pinfo->src)); + dbg(51,"Tid %lx \n",tcaphash_begin_key.tid); +#endif p_tcaphash_begincall = find_tcaphash_begin(&tcaphash_begin_key, pinfo,FALSE); } if(p_tcaphash_begincall && @@ -1248,21 +1250,22 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, create_tcaphash_cont(&tcaphash_cont_key, p_tcaphash_begincall->context); + /* Create END for (stid,src) */ tcaphash_end_key.tid = p_tcapsrt_info->src_tid; if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC) { /* We have MTP3 PCs (so we can safely do this cast) */ - tcaphash_end_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); - tcaphash_end_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); + tcaphash_end_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ - tcaphash_end_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); - tcaphash_end_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); + /* Don't have MTP3 PCs (have SCCP GT ?) */ + tcaphash_end_key.pc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); } tcaphash_end_key.hashKey=tcaphash_end_calchash(&tcaphash_end_key); #ifdef DEBUG_TCAPSRT dbg(10,"New Ekey %lx ",tcaphash_end_key.hashKey); + dbg(51,"addr %s ", address_to_str(wmem_packet_scope(), &pinfo->src)); + dbg(51,"Tid %lx ",tcaphash_end_key.tid); dbg(11,"Frame reqlink #%u ", pinfo->fd->num); #endif create_tcaphash_end(&tcaphash_end_key, @@ -1315,6 +1318,7 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *stat_tree=NULL; #ifdef DEBUG_TCAPSRT + dbg(51,"src %s dst %s dstTid %lx ", address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst), p_tcapsrt_info->dst_tid); dbg(10,"\n Hend #%u ", pinfo->fd->num); #endif /* look only for matching request, if matching conversation is available. */ @@ -1322,18 +1326,16 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC) { /* We have MTP3 PCs (so we can safely do this cast) */ - tcaphash_end_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); - tcaphash_end_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); + tcaphash_end_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ - tcaphash_end_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); - tcaphash_end_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); + /* Don't have MTP3 PCs (have SCCP GT ?) */ + tcaphash_end_key.pc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); } tcaphash_end_key.hashKey=tcaphash_end_calchash(&tcaphash_end_key); #ifdef DEBUG_TCAPSRT dbg(11,"Ekey %lx ",tcaphash_end_key.hashKey); - dbg(11,"PC %s %s ",address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst)); + dbg(11,"addr %s ", address_to_str(wmem_packet_scope(), &pinfo->dst)); dbg(51,"Tid %lx ",tcaphash_end_key.tid); #endif p_tcaphash_endcall = find_tcaphash_end(&tcaphash_end_key, pinfo,TRUE); @@ -1346,18 +1348,16 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC) { /* We have MTP3 PCs (so we can safely do this cast) */ - tcaphash_begin_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); - tcaphash_begin_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); + tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ - tcaphash_begin_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); - tcaphash_begin_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); + /* Don't have MTP3 PCs (have SCCP GT ?) */ + tcaphash_begin_key.pc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); } tcaphash_begin_key.hashKey=tcaphash_begin_calchash(&tcaphash_begin_key); #ifdef DEBUG_TCAPSRT dbg(11,"Bkey %lx ", tcaphash_begin_key.hashKey); - dbg(51,"PC %s %s ",address_to_str(wmem_packet_scope(), &pinfo->src), address_to_str(wmem_packet_scope(), &pinfo->dst)); + dbg(51,"addr %s ", address_to_str(wmem_packet_scope(), &pinfo->dst)); dbg(51,"Tid %lx ",tcaphash_begin_key.tid); #endif p_tcaphash_begincall = find_tcaphash_begin(&tcaphash_begin_key, pinfo,FALSE); @@ -1447,7 +1447,7 @@ tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tcaphash_ansi_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data); tcaphash_ansi_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data); } else { - /* Don't have MTP3 PCs (maybe we're over SUA?) */ + /* Don't have MTP3 PCs (have SCCP GT ?) */ tcaphash_ansi_key.opc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->src)); tcaphash_ansi_key.dpc_hash = g_str_hash(address_to_str(wmem_packet_scope(), &pinfo->dst)); } diff --git a/asn1/tcap/packet-tcap-template.h b/asn1/tcap/packet-tcap-template.h index 2175b741a9..b79365bd79 100644 --- a/asn1/tcap/packet-tcap-template.h +++ b/asn1/tcap/packet-tcap-template.h @@ -137,8 +137,7 @@ struct tcaphash_context_key_t { struct tcaphash_begin_info_key_t { guint32 hashKey; guint32 tid; - guint32 opc_hash; - guint32 dpc_hash; + guint32 pc_hash; }; struct tcaphash_cont_info_key_t { @@ -152,8 +151,7 @@ struct tcaphash_cont_info_key_t { struct tcaphash_end_info_key_t { guint32 hashKey; guint32 tid; - guint32 opc_hash; - guint32 dpc_hash; + guint32 pc_hash; }; struct tcaphash_ansi_info_key_t { |