Use the new ANSI TCAP dissector.

svn path=/trunk/; revision=22854
This commit is contained in:
Anders Broman 2007-09-12 16:45:53 +00:00
parent 626c9f3d61
commit c4daf58278
13 changed files with 2996 additions and 1468 deletions

View File

@ -8,7 +8,7 @@ all: generate_dissector
generate_dissector: $(DISSECTOR_FILES)
$(DISSECTOR_FILES): ../../tools/asn2wrs.py ansi_map.asn packet-$(PROTOCOL_NAME)-template.c packet-$(PROTOCOL_NAME)-template.h ansi_map.cnf
python ../../tools/asn2wrs.py -b -X -e -p $(PROTOCOL_NAME) -c ansi_map.cnf -s packet-$(PROTOCOL_NAME)-template ansi_map.asn
python ../../tools/asn2wrs.py -b -X -T -e -p $(PROTOCOL_NAME) -c ansi_map.cnf -s packet-$(PROTOCOL_NAME)-template ansi_map.asn
clean:
rm -f parsetab.py parsetab.pyc $(DISSECTOR_FILES)

View File

@ -15,7 +15,7 @@ generate_dissector: $(DISSECTOR_FILES)
$(DISSECTOR_FILES): ../../tools/asn2wrs.py ansi_map.asn packet-ansi_map-template.c packet-ansi_map-template.h ansi_map.cnf
!IFDEF PYTHON
$(PYTHON) "../../tools/asn2wrs.py" -b -X -e -p $(PROTOCOL_NAME) -c ansi_map.cnf -s packet-ansi_map-template ansi_map.asn
$(PYTHON) "../../tools/asn2wrs.py" -b -X -T -e -p $(PROTOCOL_NAME) -c ansi_map.cnf -s packet-ansi_map-template ansi_map.asn
!ELSE
@echo Error: You need Python to use asn2wrs.py
@exit 1

View File

@ -10,70 +10,6 @@ IMPORTS
IMSI
FROM MAP-Protocol;
-- TCAP part
ComponentPDU ::=
CHOICE {
invokeLast [ PRIVATE 9 ] IMPLICIT InvokePDU ,
returnResultLast [ PRIVATE 10 ] IMPLICIT ReturnResultPDU,
returnError [ PRIVATE 11 ] IMPLICIT ReturnErrorPDU ,
reject [ PRIVATE 12 ] IMPLICIT RejectPDU ,
invokeNotLast [ PRIVATE 13 ] IMPLICIT InvokePDU ,
returnResultNotLast [ PRIVATE 14 ] IMPLICIT ReturnResultPDU
}
InvokePDU ::= SEQUENCE {
componentIDs [ PRIVATE 15 ] IMPLICIT OCTET STRING (SIZE(0..2)) OPTIONAL ,
operationCode OperationCode OPTIONAL,
invokeParameters [ PRIVATE 18 ] IMPLICIT InvokeParameters
}
InvokeParameters ::= ANY
ReturnParameters ::= ANY
-- ErrorParameters ::= ANY
RejectParameters ::= ANY
ReturnResultPDU ::= SEQUENCE {
componentID ComponentID,
returnResult [ PRIVATE 18 ] IMPLICIT ReturnParameters
}
ComponentID ::= [ PRIVATE 15 ] IMPLICIT OCTET STRING ( SIZE(1) )
ReturnErrorPDU ::= SEQUENCE {
componentID ComponentID ,
errorCode ErrorCode ,
parameterre RejectParameters
}
RejectPDU ::= SEQUENCE {
componentID ComponentID ,
rejectProblem [PRIVATE 21 ] IMPLICIT ProblemPDU,
parameterrj RejectParameters
}
ProblemPDU ::= INTEGER {
general-unrecognisedComponentType (257) ,
general-incorrectComponentPortion ( 258 ) ,
general-badlyStructuredCompPortion ( 259 )
}
OperationCode ::= CHOICE
{
national [PRIVATE 16] IMPLICIT INTEGER (-32768..32767),
private [PRIVATE 17] IMPLICIT PrivateOperationCode
}
PrivateOperationCode ::= INTEGER
ErrorCode ::= CHOICE
{
nationaler [PRIVATE 19] IMPLICIT INTEGER (-32768..32767),
privateer [PRIVATE 20] IMPLICIT INTEGER
}
-- END TCAP
--6.4.2.1
AuthenticationDirective ::= [PRIVATE 18] SET {
electronicSerialNumber [9] IMPLICIT ElectronicSerialNumber,

View File

@ -13,78 +13,7 @@
#.FIELD_RENAME
#.FN_BODY InvokeParameters
ServiceIndicator = 0;
OperationCode = OperationCode&0x00ff;
ansi_map_is_invoke = TRUE;
if (check_col(actx->pinfo->cinfo, COL_INFO)){
col_set_str(actx->pinfo->cinfo, COL_INFO, val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
}
/* No Data */
if(tvb_length_remaining(tvb, offset)<=0){
update_saved_invokedata(actx->pinfo, tree, tvb);
return offset;
}
offset = dissect_invokeData(tree, tvb, offset, actx);
update_saved_invokedata(actx->pinfo, tree, tvb);
#.FN_BODY ReturnParameters
struct amsi_map_invokedata_t *ansi_map_saved_invokedata;
struct tcap_private_t *p_private_tcap;
proto_item *item;
address* src = &(actx->pinfo->src);
address* dst = &(actx->pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf;
buf=ep_alloc(1024);
src_str = address_to_str(src);
dst_str = address_to_str(dst);
/* Data from the TCAP dissector */
if (actx->pinfo->private_data != NULL){
p_private_tcap=actx->pinfo->private_data;
/* The hash string needs to contain src and dest to distiguish differnt flows */
src_str = address_to_str(src);
dst_str = address_to_str(dst);
buf = p_private_tcap->TransactionID_str;
/* Reverse order to invoke */
strcat(buf,dst_str);
strcat(buf,src_str);
strcat(buf,"\0");
ansi_map_saved_invokedata = g_hash_table_lookup(TransactionId_table, p_private_tcap->TransactionID_str);
if(ansi_map_saved_invokedata){
OperationCode = ansi_map_saved_invokedata->opcode;
ServiceIndicator = ansi_map_saved_invokedata->ServiceIndicator;
}else{
OperationCode = OperationCode & 0x00ff;
}
}else{
OperationCode = OperationCode & 0x00ff;
}
if (check_col(actx->pinfo->cinfo, COL_INFO)){
col_clear(actx->pinfo->cinfo, COL_INFO);
col_add_fstr(actx->pinfo->cinfo, COL_INFO,"%s Response", val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
}
/* No Data */
if(tvb_length_remaining(tvb, offset)<=0){
return offset;
}
item = proto_tree_add_text(tree, tvb, 0, -1, "OperationCode %s",val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown %u"));
PROTO_ITEM_SET_GENERATED(item);
ansi_map_is_invoke = FALSE;
offset = dissect_returnData(tree, tvb, offset, actx);
#.FN_BODY ErrorParameters
#.FN_BODY RejectParameters
# N.S0005-0 v 1.0 TCAP Formats and Procedures 5-16 Application Services
# 6.3.2 Component Portion
@ -92,10 +21,6 @@
# Specifier associated with each Operation Family member. For TIA/EIA-41 the
# Operation Family is coded as decimal 9. Bit H of the Operation Family is always
# coded as 0.
#.FN_BODY PrivateOperationCode VAL_PTR = &OperationCode
%(DEFAULT_BODY)s
proto_tree_add_item(tree, hf_ansi_map_op_code_fam, tvb, offset-2,1,FALSE);
proto_tree_add_item(tree, hf_ansi_map_op_code, tvb, offset-1,1,FALSE);
#.FN_BODY MINType VAL_PTR = &parameter_tvb
tvbuff_t *parameter_tvb = NULL;

View File

@ -104,6 +104,7 @@
#include "packet-ansi_a.h"
#include "packet-gsm_map.h"
#include "packet-tcap.h"
#include "packet-ansi_tcap.h"
#define PNAME "ANSI Mobile Application Part"
#define PSNAME "ANSI MAP"
@ -370,7 +371,7 @@ static guint32 OperationCode;
static guint8 ServiceIndicator;
struct amsi_map_invokedata_t {
struct ansi_map_invokedata_t {
guint32 opcode;
guint8 ServiceIndicator;
};
@ -384,7 +385,7 @@ static GHashTable *TransactionId_table=NULL;
static void
TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){
struct amsi_map_invokedata_t *ansi_map_saved_invokedata = value;
struct ansi_map_invokedata_t *ansi_map_saved_invokedata = value;
gchar *TransactionId_str = key;
if ( TransactionId_str ){
@ -417,9 +418,9 @@ ansi_map_init_protocol(void)
/* Store Invoke information needed for the corresponding reply */
static void
update_saved_invokedata(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb){
struct amsi_map_invokedata_t *ansi_map_saved_invokedata;
struct tcap_private_t *p_private_tcap;
update_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
struct ansi_map_invokedata_t *ansi_map_saved_invokedata;
struct ansi_tcap_private_t *p_private_tcap;
address* src = &(pinfo->src);
address* dst = &(pinfo->dst);
guint8 *src_str;
@ -434,12 +435,12 @@ update_saved_invokedata(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb){
/* Data from the TCAP dissector */
if (pinfo->private_data != NULL){
p_private_tcap=pinfo->private_data;
ansi_map_saved_invokedata = g_malloc(sizeof(ansi_map_saved_invokedata));
ansi_map_saved_invokedata->opcode = OperationCode;
ansi_map_saved_invokedata->ServiceIndicator = ServiceIndicator;
if ((!pinfo->fd->flags.visited)&&(p_private_tcap->TransactionID_str)){
/* Only do this once XXX I hope its the right thing to do */
buf = p_private_tcap->TransactionID_str;
ansi_map_saved_invokedata = g_malloc(sizeof(ansi_map_saved_invokedata));
ansi_map_saved_invokedata->opcode = p_private_tcap->d.OperationCode_private;
ansi_map_saved_invokedata->ServiceIndicator = ServiceIndicator;
strcpy(buf,p_private_tcap->TransactionID_str);
/* The hash string needs to contain src and dest to distiguish differnt flows */
strcat(buf,src_str);
strcat(buf,dst_str);
@ -447,7 +448,9 @@ update_saved_invokedata(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb){
g_hash_table_insert(TransactionId_table,
g_strdup(buf),
ansi_map_saved_invokedata);
proto_tree_add_text(tree, tvb, 0, 1, "HAsh string %s",buf);
/*
g_warning("Invoke Hash string %s",buf);
*/
}
}
@ -757,7 +760,10 @@ dissect_ansi_map_digits_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
case 2:/* Telephony Numbering (ITU-T Rec. E.164,E.163). */
case 6:/* Land Mobile Numbering (ITU-T Rec. E.212) */
case 7:/* Private Numbering Plan */
octet = tvb_get_guint8(tvb,offset);
proto_tree_add_item(subtree, hf_ansi_map_nr_digits, tvb, offset, 1, FALSE);
if(octet == 0)
return;
offset++;
switch ((octet&0xf)){
case 1:
@ -3617,7 +3623,7 @@ dissect_ansi_map_win_trigger_list(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
int offset = 0;
int end_offset = 0;
int j = 0;
int j;
proto_tree *subtree;
guint8 octet;
@ -3652,6 +3658,7 @@ dissect_ansi_map_win_trigger_list(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
}
}
static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx) {
@ -4043,6 +4050,10 @@ static int dissect_returnData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_
case 25: /*Handoff To Third*/
offset = dissect_ansi_map_HandoffToThirdRes(TRUE, tvb, offset, actx, tree, hf_ansi_map_handoffToThirdRes);
break;
case 26: /*Flash Request*/
/* No data */
proto_tree_add_text(tree, tvb, offset, -1, "No Data");
break;
case 27: /*Authentication Directive*/
offset = dissect_ansi_map_AuthenticationDirectiveRes(TRUE, tvb, offset, actx, tree, hf_ansi_map_authenticationDirectiveRes);
break;
@ -4228,12 +4239,54 @@ static int dissect_returnData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_
}
static int
find_saved_invokedata(asn1_ctx_t *actx){
struct ansi_map_invokedata_t *ansi_map_saved_invokedata;
struct ansi_tcap_private_t *p_private_tcap;
address* src = &(actx->pinfo->src);
address* dst = &(actx->pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf;
buf=ep_alloc(1024);
src_str = address_to_str(src);
dst_str = address_to_str(dst);
/* Data from the TCAP dissector */
if (actx->pinfo->private_data != NULL){
p_private_tcap=actx->pinfo->private_data;
/* The hash string needs to contain src and dest to distiguish differnt flows */
src_str = address_to_str(src);
dst_str = address_to_str(dst);
strcpy(buf, p_private_tcap->TransactionID_str);
/* Reverse order to invoke */
strcat(buf,dst_str);
strcat(buf,src_str);
strcat(buf,"\0");
/*
g_warning("Find Hash string %s",buf);
*/
ansi_map_saved_invokedata = g_hash_table_lookup(TransactionId_table, p_private_tcap->TransactionID_str);
if(ansi_map_saved_invokedata){
OperationCode = ansi_map_saved_invokedata->opcode & 0xff;
ServiceIndicator = ansi_map_saved_invokedata->ServiceIndicator;
}else{
OperationCode = OperationCode & 0x00ff;
}
}else{
OperationCode = OperationCode & 0x00ff;
}
return OperationCode;
}
static void
dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ansi_map_item;
proto_tree *ansi_map_tree = NULL;
int offset = 0;
struct ansi_tcap_private_t *p_private_tcap;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
@ -4248,6 +4301,12 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ANSI MAP");
}
/* Data from the TCAP dissector */
if (pinfo->private_data == NULL){
proto_tree_add_text(tree, tvb, 0, -1, "Dissector ERROR this dissector relays on private data");
return;
}
/*
* create the ansi_map protocol tree
*/
@ -4256,8 +4315,54 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
ansi_map_is_invoke = FALSE;
is683_ota = FALSE;
is801_pld = FALSE;
dissect_ansi_map_ComponentPDU(FALSE, tvb, offset, &asn1_ctx, ansi_map_tree, -1);
ServiceIndicator = 0;
p_private_tcap=pinfo->private_data;
switch(p_private_tcap->d.pdu){
/*
1 : invoke,
2 : returnResult,
3 : returnError,
4 : reject
*/
case 1:
OperationCode = p_private_tcap->d.OperationCode_private & 0x00ff;
ansi_map_is_invoke = TRUE;
if (check_col(pinfo->cinfo, COL_INFO)){
col_clear(pinfo->cinfo, COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO,"%s Invoke", val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
}
proto_item_append_text(p_private_tcap->d.OperationCode_item," %s",val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
offset = dissect_invokeData(ansi_map_tree, tvb, 0, &asn1_ctx);
update_saved_invokedata(pinfo, ansi_map_tree, tvb);
break;
case 2:
OperationCode = find_saved_invokedata(&asn1_ctx);
if (check_col(pinfo->cinfo, COL_INFO)){
col_clear(pinfo->cinfo, COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO,"%s ReturnResult", val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
}
proto_item_append_text(p_private_tcap->d.OperationCode_item," %s",val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
offset = dissect_returnData(ansi_map_tree, tvb, 0, &asn1_ctx);
break;
case 3:
if (check_col(pinfo->cinfo, COL_INFO)){
col_clear(pinfo->cinfo, COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO,"%s ReturnError", val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
}
break;
case 4:
if (check_col(pinfo->cinfo, COL_INFO)){
col_clear(pinfo->cinfo, COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO,"%s Reject", val_to_str(OperationCode, ansi_map_opr_code_strings, "Unknown ANSI-MAP PDU (%u)"));
}
break;
default:
/* Must be Invoke ReturnResult ReturnError or Reject */
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
}
static void range_delete_callback(guint32 ssn)

View File

@ -24,9 +24,9 @@ tvbuff_t *parameter_tvb;
if(!parameter_tvb)
return offset;
find_tcap_subdisector(parameter_tvb, actx, tcap_top_tree);
find_tcap_subdisector(parameter_tvb, actx, tree);
#.FN_FTR Invoke
#.FN_HDR Invoke
ansi_tcap_private.d.pdu = 1;
#--- RETURN RESULT ---
@ -43,9 +43,9 @@ tvbuff_t *parameter_tvb;
if(!parameter_tvb)
return offset;
find_tcap_subdisector(parameter_tvb, actx, tcap_top_tree);
find_tcap_subdisector(parameter_tvb, actx, tree);
#.FN_FTR ReturnResult
#.FN_HDR ReturnResult
ansi_tcap_private.d.pdu = 2;
@ -62,9 +62,9 @@ tvbuff_t *parameter_tvb;
if(!parameter_tvb)
return offset;
find_tcap_subdisector(parameter_tvb, actx, tcap_top_tree);
find_tcap_subdisector(parameter_tvb, actx, tree);
#.FN_FTR ReturnError
#.FN_HDR ReturnError
ansi_tcap_private.d.pdu = 3;
#--- ObjectIDApplicationContext --

View File

@ -105,7 +105,7 @@ struct ansi_tcap_private_t ansi_tcap_private;
static void ansi_tcap_ctx_init(struct ansi_tcap_private_t *a_tcap_ctx) {
memset(a_tcap_ctx, '\0', sizeof(*a_tcap_ctx));
a_tcap_ctx->signature = ANSI_TCAP_CTX_SIGNATURE;
ansi_tcap_private.oid_is_present = FALSE;
a_tcap_ctx->oid_is_present = FALSE;
}
static void dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree);
@ -125,6 +125,124 @@ dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
}
*/
/* Transaction tracking */
/* Transaction table */
struct ansi_tcap_invokedata_t {
gint OperationCode;
/*
0 : national,
1 : private
*/
gint32 OperationCode_private;
gint32 OperationCode_national;
};
static GHashTable *TransactionId_table=NULL;
static void
TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata = value;
gchar *TransactionId_str = key;
if ( TransactionId_str ){
g_free(TransactionId_str);
}
if (ansi_tcap_saved_invokedata){
g_free(ansi_tcap_saved_invokedata);
}
}
void
ansi_tcap_init_transaction_table(void){
/* Destroy any existing memory chunks / hashes. */
if (TransactionId_table){
g_hash_table_foreach(TransactionId_table, TransactionId_table_cleanup, NULL);
g_hash_table_destroy(TransactionId_table);
TransactionId_table = NULL;
}
TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal);
}
static void
ansi_tcap_init_protocol(void)
{
ansi_tcap_init_transaction_table();
}
/* Store Invoke information needed for the corresponding reply */
static void
save_invoke_data(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata;
address* src = &(pinfo->src);
address* dst = &(pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf;
buf=ep_alloc(1024);
src_str = address_to_str(src);
dst_str = address_to_str(dst);
if ((!pinfo->fd->flags.visited)&&(ansi_tcap_private.TransactionID_str)){
/* Only do this once XXX I hope its the right thing to do */
ansi_tcap_saved_invokedata = g_malloc(sizeof(ansi_tcap_saved_invokedata));
ansi_tcap_saved_invokedata->OperationCode = ansi_tcap_private.d.OperationCode;
ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national;
ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private;
strcpy(buf, ansi_tcap_private.TransactionID_str);
/* The hash string needs to contain src and dest to distiguish differnt flows */
strcat(buf,src_str);
strcat(buf,dst_str);
strcat(buf,"\0");
g_hash_table_insert(TransactionId_table,
g_strdup(buf),
ansi_tcap_saved_invokedata);
/*
g_warning("Tcap Invoke Hash string %s",buf);
*/
}
}
static gboolean
find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata;
address* src = &(pinfo->src);
address* dst = &(pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf;
buf=ep_alloc(1024);
src_str = address_to_str(src);
dst_str = address_to_str(dst);
/* The hash string needs to contain src and dest to distiguish differnt flows */
src_str = address_to_str(src);
dst_str = address_to_str(dst);
strcpy(buf, ansi_tcap_private.TransactionID_str);
/* Reverse order to invoke */
strcat(buf,dst_str);
strcat(buf,src_str);
strcat(buf,"\0");
ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table, buf);
if(ansi_tcap_saved_invokedata){
ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode;
ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national;
ansi_tcap_private.d.OperationCode_private = ansi_tcap_saved_invokedata->OperationCode_private;
return TRUE;
}
return FALSE;
}
/* As currently ANSI MAP is the only possible sub dissector this function
* must be improved to handle general cases.
*
@ -143,6 +261,7 @@ dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
*/
static gboolean
find_tcap_subdisector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
proto_item *item;
/* If "DialoguePortion objectApplicationId ObjectIDApplicationContext
* points to the subdissector this code can be used.
@ -152,18 +271,36 @@ find_tcap_subdisector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
return TRUE;
}
*/
if(ansi_tcap_private.d.pdu == 1){
/* Save Invoke data for this transaction */
save_invoke_data(actx->pinfo, tree, tvb);
}else{
/* Get saved data for this transaction */
if(find_saved_invokedata(actx->pinfo, tree, tvb)){
if(ansi_tcap_private.d.OperationCode == 0){
/* national */
item = proto_tree_add_int(tree, hf_ansi_tcap_national, tvb, 0, 0, ansi_tcap_private.d.OperationCode_national);
}else{
item = proto_tree_add_int(tree, hf_ansi_tcap_private, tvb, 0, 0, ansi_tcap_private.d.OperationCode_private);
}
PROTO_ITEM_SET_GENERATED(item);
ansi_tcap_private.d.OperationCode_item = item;
}
}
if(ansi_tcap_private.d.OperationCode == 0){
/* national */
proto_tree_add_text(tree, tvb, 0, -1,
item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP NATIONAL code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_national);
PROTO_ITEM_SET_GENERATED(item);
return FALSE;
}else if(ansi_tcap_private.d.OperationCode == 1){
/* private */
if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){
proto_tree_add_text(tree, tvb, 0, -1,
item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP PRIVATE code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_private);
PROTO_ITEM_SET_GENERATED(item);
return FALSE;
}
}
@ -176,10 +313,9 @@ find_tcap_subdisector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
* Operation Family is coded as decimal 9. Bit H of the Operation Family is always
* coded as 0.
*/
call_dissector(ansi_map_handle, tvb, actx->pinfo, tcap_top_tree);
call_dissector(ansi_map_handle, tvb, actx->pinfo, tree);
return FALSE;
return TRUE;
}
#include "packet-ansi_tcap-fn.c"
@ -195,8 +331,10 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_item *stat_item=NULL;
proto_tree *stat_tree=NULL;
gint offset = 0;
#if 0
struct tcaphash_context_t * p_tcap_context;
dissector_handle_t subdissector_handle;
#endif
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
@ -224,6 +362,8 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
gp_tcap_context=NULL;
dissect_ansi_tcap_PackageType(FALSE, tvb, 0, &asn1_ctx, tree, -1);
#if 0 /* Skipp this part for now it will be rewritten */
if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) {
if (gtcap_DisplaySRT && tree) {
stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat");
@ -250,6 +390,7 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
(p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context);
}
}
#endif
}
@ -330,6 +471,7 @@ proto_register_ansi_tcap(void)
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&ansi_tcap_init_protocol);
}

View File

@ -183,7 +183,7 @@ dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
*
*/
get_ber_identifier(tvb, 0, &class, &pc, &tag);
#if 0
if(class == BER_CLASS_PRI){
switch(tag){
case 1:
@ -200,7 +200,7 @@ dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
return;
}
}
#endif
/* ITU TCAP */
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* ./packet-ansi_map.h */
/* ../../tools/asn2wrs.py -b -X -e -p ansi_map -c ansi_map.cnf -s packet-ansi_map-template ansi_map.asn */
/* ../../tools/asn2wrs.py -b -X -T -e -p ansi_map -c ansi_map.cnf -s packet-ansi_map-template ansi_map.asn */
/* Input file: packet-ansi_map-template.h */

View File

@ -1,6 +1,6 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* .\packet-ansi_tcap.c */
/* ./packet-ansi_tcap.c */
/* ../../tools/asn2wrs.py -b -X -T -e -p ansi_tcap -c ansi_tcap.cnf -s packet-ansi_tcap-template TCAP-Remote-Operations-Information-Objects.asn TCAPPackage.asn */
/* Input file: packet-ansi_tcap-template.c */
@ -196,7 +196,7 @@ struct ansi_tcap_private_t ansi_tcap_private;
static void ansi_tcap_ctx_init(struct ansi_tcap_private_t *a_tcap_ctx) {
memset(a_tcap_ctx, '\0', sizeof(*a_tcap_ctx));
a_tcap_ctx->signature = ANSI_TCAP_CTX_SIGNATURE;
ansi_tcap_private.oid_is_present = FALSE;
a_tcap_ctx->oid_is_present = FALSE;
}
static void dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree);
@ -216,6 +216,124 @@ dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
}
*/
/* Transaction tracking */
/* Transaction table */
struct ansi_tcap_invokedata_t {
gint OperationCode;
/*
0 : national,
1 : private
*/
gint32 OperationCode_private;
gint32 OperationCode_national;
};
static GHashTable *TransactionId_table=NULL;
static void
TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata = value;
gchar *TransactionId_str = key;
if ( TransactionId_str ){
g_free(TransactionId_str);
}
if (ansi_tcap_saved_invokedata){
g_free(ansi_tcap_saved_invokedata);
}
}
void
ansi_tcap_init_transaction_table(void){
/* Destroy any existing memory chunks / hashes. */
if (TransactionId_table){
g_hash_table_foreach(TransactionId_table, TransactionId_table_cleanup, NULL);
g_hash_table_destroy(TransactionId_table);
TransactionId_table = NULL;
}
TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal);
}
static void
ansi_tcap_init_protocol(void)
{
ansi_tcap_init_transaction_table();
}
/* Store Invoke information needed for the corresponding reply */
static void
save_invoke_data(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata;
address* src = &(pinfo->src);
address* dst = &(pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf;
buf=ep_alloc(1024);
src_str = address_to_str(src);
dst_str = address_to_str(dst);
if ((!pinfo->fd->flags.visited)&&(ansi_tcap_private.TransactionID_str)){
/* Only do this once XXX I hope its the right thing to do */
ansi_tcap_saved_invokedata = g_malloc(sizeof(ansi_tcap_saved_invokedata));
ansi_tcap_saved_invokedata->OperationCode = ansi_tcap_private.d.OperationCode;
ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national;
ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private;
strcpy(buf, ansi_tcap_private.TransactionID_str);
/* The hash string needs to contain src and dest to distiguish differnt flows */
strcat(buf,src_str);
strcat(buf,dst_str);
strcat(buf,"\0");
g_hash_table_insert(TransactionId_table,
g_strdup(buf),
ansi_tcap_saved_invokedata);
/*
g_warning("Tcap Invoke Hash string %s",buf);
*/
}
}
static gboolean
find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata;
address* src = &(pinfo->src);
address* dst = &(pinfo->dst);
guint8 *src_str;
guint8 *dst_str;
char *buf;
buf=ep_alloc(1024);
src_str = address_to_str(src);
dst_str = address_to_str(dst);
/* The hash string needs to contain src and dest to distiguish differnt flows */
src_str = address_to_str(src);
dst_str = address_to_str(dst);
strcpy(buf, ansi_tcap_private.TransactionID_str);
/* Reverse order to invoke */
strcat(buf,dst_str);
strcat(buf,src_str);
strcat(buf,"\0");
ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table, buf);
if(ansi_tcap_saved_invokedata){
ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode;
ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national;
ansi_tcap_private.d.OperationCode_private = ansi_tcap_saved_invokedata->OperationCode_private;
return TRUE;
}
return FALSE;
}
/* As currently ANSI MAP is the only possible sub dissector this function
* must be improved to handle general cases.
*
@ -234,6 +352,7 @@ dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
*/
static gboolean
find_tcap_subdisector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
proto_item *item;
/* If "DialoguePortion objectApplicationId ObjectIDApplicationContext
* points to the subdissector this code can be used.
@ -243,18 +362,36 @@ find_tcap_subdisector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
return TRUE;
}
*/
if(ansi_tcap_private.d.pdu == 1){
/* Save Invoke data for this transaction */
save_invoke_data(actx->pinfo, tree, tvb);
}else{
/* Get saved data for this transaction */
if(find_saved_invokedata(actx->pinfo, tree, tvb)){
if(ansi_tcap_private.d.OperationCode == 0){
/* national */
item = proto_tree_add_int(tree, hf_ansi_tcap_national, tvb, 0, 0, ansi_tcap_private.d.OperationCode_national);
}else{
item = proto_tree_add_int(tree, hf_ansi_tcap_private, tvb, 0, 0, ansi_tcap_private.d.OperationCode_private);
}
PROTO_ITEM_SET_GENERATED(item);
ansi_tcap_private.d.OperationCode_item = item;
}
}
if(ansi_tcap_private.d.OperationCode == 0){
/* national */
proto_tree_add_text(tree, tvb, 0, -1,
item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP NATIONAL code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_national);
PROTO_ITEM_SET_GENERATED(item);
return FALSE;
}else if(ansi_tcap_private.d.OperationCode == 1){
/* private */
if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){
proto_tree_add_text(tree, tvb, 0, -1,
item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP PRIVATE code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_private);
PROTO_ITEM_SET_GENERATED(item);
return FALSE;
}
}
@ -267,10 +404,9 @@ find_tcap_subdisector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
* Operation Family is coded as decimal 9. Bit H of the Operation Family is always
* coded as 0.
*/
call_dissector(ansi_map_handle, tvb, actx->pinfo, tcap_top_tree);
call_dissector(ansi_map_handle, tvb, actx->pinfo, tree);
return FALSE;
return TRUE;
}
@ -640,7 +776,7 @@ tvbuff_t *parameter_tvb;
if(!parameter_tvb)
return offset;
find_tcap_subdisector(parameter_tvb, actx, tcap_top_tree);
find_tcap_subdisector(parameter_tvb, actx, tree);
@ -657,14 +793,14 @@ static const ber_sequence_t Invoke_sequence[] = {
static int
dissect_ansi_tcap_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
Invoke_sequence, hf_index, ett_ansi_tcap_Invoke);
#line 30 "ansi_tcap.cnf"
ansi_tcap_private.d.pdu = 1;
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
Invoke_sequence, hf_index, ett_ansi_tcap_Invoke);
return offset;
}
@ -691,7 +827,7 @@ tvbuff_t *parameter_tvb;
if(!parameter_tvb)
return offset;
find_tcap_subdisector(parameter_tvb, actx, tcap_top_tree);
find_tcap_subdisector(parameter_tvb, actx, tree);
@ -707,15 +843,15 @@ static const ber_sequence_t ReturnResult_sequence[] = {
static int
dissect_ansi_tcap_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ReturnResult_sequence, hf_index, ett_ansi_tcap_ReturnResult);
#line 49 "ansi_tcap.cnf"
ansi_tcap_private.d.pdu = 2;
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ReturnResult_sequence, hf_index, ett_ansi_tcap_ReturnResult);
return offset;
}
@ -741,7 +877,7 @@ tvbuff_t *parameter_tvb;
if(!parameter_tvb)
return offset;
find_tcap_subdisector(parameter_tvb, actx, tcap_top_tree);
find_tcap_subdisector(parameter_tvb, actx, tree);
@ -758,13 +894,13 @@ static const ber_sequence_t ReturnError_sequence[] = {
static int
dissect_ansi_tcap_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ReturnError_sequence, hf_index, ett_ansi_tcap_ReturnError);
#line 68 "ansi_tcap.cnf"
ansi_tcap_private.d.pdu = 3;
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ReturnError_sequence, hf_index, ett_ansi_tcap_ReturnError);
return offset;
}
@ -1184,7 +1320,7 @@ dissect_ansi_tcap_PackageType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
/*--- End of included file: packet-ansi_tcap-fn.c ---*/
#line 186 "packet-ansi_tcap-template.c"
#line 322 "packet-ansi_tcap-template.c"
@ -1197,8 +1333,10 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
proto_item *stat_item=NULL;
proto_tree *stat_tree=NULL;
gint offset = 0;
#if 0
struct tcaphash_context_t * p_tcap_context;
dissector_handle_t subdissector_handle;
#endif
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
@ -1226,6 +1364,8 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
gp_tcap_context=NULL;
dissect_ansi_tcap_PackageType(FALSE, tvb, 0, &asn1_ctx, tree, -1);
#if 0 /* Skipp this part for now it will be rewritten */
if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) {
if (gtcap_DisplaySRT && tree) {
stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat");
@ -1252,6 +1392,7 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
(p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context);
}
}
#endif
}
@ -1512,7 +1653,7 @@ proto_register_ansi_tcap(void)
"ansi_tcap.T_paramSet", HFILL }},
/*--- End of included file: packet-ansi_tcap-hfarr.c ---*/
#line 305 "packet-ansi_tcap-template.c"
#line 446 "packet-ansi_tcap-template.c"
};
/* Setup protocol subtree array */
@ -1549,7 +1690,7 @@ proto_register_ansi_tcap(void)
&ett_ansi_tcap_T_paramSet,
/*--- End of included file: packet-ansi_tcap-ettarr.c ---*/
#line 315 "packet-ansi_tcap-template.c"
#line 456 "packet-ansi_tcap-template.c"
};
/*static enum_val_t tcap_options[] = {
@ -1568,6 +1709,7 @@ proto_register_ansi_tcap(void)
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&ansi_tcap_init_protocol);
}

View File

@ -1,6 +1,6 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* .\packet-ansi_tcap.h */
/* ./packet-ansi_tcap.h */
/* ../../tools/asn2wrs.py -b -X -T -e -p ansi_tcap -c ansi_tcap.cnf -s packet-ansi_tcap-template TCAP-Remote-Operations-Information-Objects.asn TCAPPackage.asn */
/* Input file: packet-ansi_tcap-template.h */

View File

@ -2518,7 +2518,7 @@ dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
*
*/
get_ber_identifier(tvb, 0, &class, &pc, &tag);
#if 0
if(class == BER_CLASS_PRI){
switch(tag){
case 1:
@ -2535,7 +2535,7 @@ dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
return;
}
}
#endif
/* ITU TCAP */
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);