From fa1cd47182885a598d230082d92ac1ce55f07925 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 17 Jul 2010 15:25:36 +0200 Subject: [PATCH] TC-BEGIN.ind correctly parse the dialogue portion --- src/csl_dha.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/csl_dha.c b/src/csl_dha.c index 2090f5f..27f90ef 100644 --- a/src/csl_dha.c +++ b/src/csl_dha.c @@ -61,7 +61,7 @@ int tcap_csl_tc_uni_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, memcpy(&audt->application_context_name, app_ctx, sizeof(audt->application_context_name)); audt->protocol_version = &dial_version1; - fprintf(stdout, "\nDialogue portion:\n"); + fprintf(stdout, "\nTC-UNI.req Dialogue portion:\n"); xer_fprint(stdout, &asn_DEF_UniDialoguePDU, &dial); memset(&ext, 0, sizeof(ext)); @@ -114,7 +114,7 @@ int tcap_csl_tc_begin_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx /* Set protocol_version = 1 */ aarq->protocol_version = &dial_version1; /* Build AARQ apdu */ - fprintf(stdout, "\nDialogue portion:\n"); + fprintf(stdout, "\nTC-BEGIN.req Dialogue portion:\n"); xer_fprint(stdout, &asn_DEF_DialoguePDU, &dial); memset(&ext, 0, sizeof(ext)); @@ -174,28 +174,55 @@ int tcap_csl_tr_begin_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, { struct tcap_dialogue *td = dialg_by_trans(tt); struct Begin *bgmsg = &tcmsg->choice.begin; + struct DialoguePDU *dial_pdu = NULL; OBJECT_IDENTIFIER_t *app_ctx = NULL; - void *user_info; + struct user_information *user_info = NULL; int rc = 0; if (bgmsg->dialoguePortion) { + struct ExternalPDU *ext_pdu = NULL; + asn_dec_rval_t adr; + struct AARQ_apdu *aarq; /* extract dialogue portion */ - if (0/* Check for correctness */) { + adr = ber_decode(NULL, &asn_DEF_ExternalPDU, &ext_pdu, + bgmsg->dialoguePortion->buf, + bgmsg->dialoguePortion->size); + if (adr.code != RC_OK) { + fprintf(stderr, "TC-BEGIN.ind Error parsing Dialogue portion 1\n"); + return -EINVAL; + } + adr = ber_decode(NULL, &asn_DEF_DialoguePDU, &dial_pdu, + ext_pdu->dialog.buf, ext_pdu->dialog.size); + /* Release the External part */ + asn_DEF_ExternalPDU.free_struct(&asn_DEF_ExternalPDU, ext_pdu, 0); + /* Check for correctness */ + if (adr.code != RC_OK ){ //|| + //(dial_pdu && dial_pdu->present != DialoguePDU_PR_dialogueRequest)) { + fprintf(stderr, "TC-BEGIN.ind Error parsing Dialogue portion\n"); /* Build ABORT apdu */ /* Discard components */ /* TR-U-ABPRT.req to TSL */ rc = tcap_tco_tr_u_abort_req(tt, tcmsg); /* Dalogue terminated to CHA */ tcap_cha_dialg_term(td); + + return rc; } - if (0/* Check version 1 */) { + + fprintf(stdout, "\nTC-BEGIN.ind Dialogue portion:\n"); + xer_fprint(stdout, &asn_DEF_UniDialoguePDU, dial_pdu); + + aarq = &dial_pdu->choice.dialogueRequest; + if (aarq->protocol_version && 0/* Check version 1 */) { /* Build AARE apdu */ /* Discard components */ /* TR-P-ABPRT.req to TSL */ /* Dalogue terminated to CHA */ tcap_cha_dialg_term(td); } - /* FIXME: Set application context mode */ + /* Set application context mode */ + app_ctx = &aarq->application_context_name; + user_info = aarq->user_information; } /* Assign Dialogue ID */ td->dialogue_id = tcap_dialg_id_alloc(); @@ -207,6 +234,10 @@ int tcap_csl_tr_begin_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, } tt->state = TCAP_TS_INIT_RECV; + if (dial_pdu) { + /* Release resources of the ber_decode */ + asn_DEF_DialoguePDU.free_struct(&asn_DEF_DialoguePDU, dial_pdu, 0); + } return rc; }