use more dynamically-allocated structures as opposed to stack-allocated
This commit is contained in:
parent
ed59503766
commit
7b907ec4d4
|
@ -73,71 +73,74 @@ static int extract_appctx_uinfo(OBJECT_IDENTIFIER_t **app_ctx_name, struct user_
|
|||
/* TC-UNI.req from TCU */
|
||||
int tcap_csl_tc_uni_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info)
|
||||
{
|
||||
struct TCMessage tcm;
|
||||
ExternalPDU_t ext;
|
||||
UniDialoguePDU_t dial;
|
||||
ANY_t any;
|
||||
struct TCMessage *tcm;
|
||||
ExternalPDU_t *ext;
|
||||
UniDialoguePDU_t *dial;
|
||||
ANY_t *any;
|
||||
int rc;
|
||||
|
||||
tcm = talloc_zero(td, struct TCMessage);
|
||||
tcm->present = TCMessage_PR_unidirectional;
|
||||
|
||||
if (app_ctx) {
|
||||
AUDT_apdu_t *audt;
|
||||
/* build AUDT apdu */
|
||||
memset(&dial, 0, sizeof(dial));
|
||||
dial.present = UniDialoguePDU_PR_unidialoguePDU;
|
||||
audt = &dial.choice.unidialoguePDU;
|
||||
dial = talloc_zero(td, UniDialoguePDU_t);
|
||||
dial->present = UniDialoguePDU_PR_unidialoguePDU;
|
||||
audt = &dial->choice.unidialoguePDU;
|
||||
if (user_info)
|
||||
audt->user_information = user_info;
|
||||
memcpy(&audt->application_context_name, app_ctx, sizeof(audt->application_context_name));
|
||||
audt->protocol_version = &dial_version1;
|
||||
|
||||
fprintf(stdout, "\nTC-UNI.req Dialogue portion:\n");
|
||||
xer_fprint(stdout, &asn_DEF_UniDialoguePDU, &dial);
|
||||
xer_fprint(stdout, &asn_DEF_UniDialoguePDU, dial);
|
||||
|
||||
memset(&ext, 0, sizeof(ext));
|
||||
ANY_fromType((ANY_t *) &ext.dialog, &asn_DEF_UniDialoguePDU, &dial);
|
||||
memset(&any, 0, sizeof(any));
|
||||
ANY_fromType(&any, &asn_DEF_ExternalPDU, &ext);
|
||||
tcm.choice.unidirectional.dialoguePortion = (OCTET_STRING_t *) &any;
|
||||
ext = talloc_zero(dial, ExternalPDU_t);
|
||||
ANY_fromType((ANY_t *) &ext->dialog, &asn_DEF_UniDialoguePDU, dial);
|
||||
any = ANY_new_fromType(&asn_DEF_ExternalPDU, ext);
|
||||
tcm->choice.unidirectional.dialoguePortion = (OCTET_STRING_t *) any;
|
||||
}
|
||||
/* Request components to CHA */
|
||||
/* Process components */
|
||||
/* Assemble TSL user data */
|
||||
memcpy(&tcm.choice.unidirectional.components, td->pend_comp, sizeof(*td->pend_comp));
|
||||
memcpy(&tcm->choice.unidirectional.components, td->pend_comp, sizeof(*td->pend_comp));
|
||||
talloc_free(td->pend_comp);
|
||||
td->pend_comp = talloc_zero(td, struct ComponentPortion);
|
||||
|
||||
/* TR-UNI-REQ to TSL */
|
||||
rc = tcap_tco_tr_uni_req(&td->trans, &tcm);
|
||||
rc = tcap_tco_tr_uni_req(&td->trans, tcm);
|
||||
/* Dialogue terminated to CHA */
|
||||
tcap_cha_dialg_term(td);
|
||||
/* Free Dialogue ID */
|
||||
tcap_dialg_free(td);
|
||||
|
||||
asn_DEF_TCMessage.free_struct(&asn_DEF_TCMessage, tcm, 0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* TC-BEGIN.req from TCU */
|
||||
int tcap_csl_tc_begin_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info)
|
||||
{
|
||||
struct TCMessage tcm;
|
||||
struct ComponentPortion cp;
|
||||
ExternalPDU_t ext;
|
||||
DialoguePDU_t dial;
|
||||
struct TCMessage *tcm;
|
||||
ExternalPDU_t *ext;
|
||||
DialoguePDU_t *dial;
|
||||
struct tcap_invocation *ti;
|
||||
uint32_t trans_id;
|
||||
int rc;
|
||||
|
||||
memset(&tcm, 0, sizeof(tcm));
|
||||
tcm.present = TCMessage_PR_begin;
|
||||
tcm = talloc_zero(td, struct TCMessage);
|
||||
tcm->present = TCMessage_PR_begin;
|
||||
|
||||
if (app_ctx) {
|
||||
AARQ_apdu_t *aarq;
|
||||
ANY_t *any;
|
||||
|
||||
memset(&dial, 0, sizeof(dial));
|
||||
dial.present = DialoguePDU_PR_dialogueRequest;
|
||||
dial = talloc_zero(tcm, DialoguePDU_t);
|
||||
dial->present = DialoguePDU_PR_dialogueRequest;
|
||||
|
||||
aarq = &dial.choice.dialogueRequest;
|
||||
aarq = &dial->choice.dialogueRequest;
|
||||
if (user_info)
|
||||
aarq->user_information = user_info;
|
||||
/* Set Application context mode */
|
||||
|
@ -147,32 +150,32 @@ int tcap_csl_tc_begin_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx
|
|||
aarq->protocol_version = &dial_version1;
|
||||
/* Build AARQ apdu */
|
||||
fprintf(stdout, "\nTC-BEGIN.req Dialogue portion:\n");
|
||||
xer_fprint(stdout, &asn_DEF_DialoguePDU, &dial);
|
||||
xer_fprint(stdout, &asn_DEF_DialoguePDU, dial);
|
||||
|
||||
memset(&ext, 0, sizeof(ext));
|
||||
rc = ANY_fromType((ANY_t *) &ext.dialog, &asn_DEF_DialoguePDU, &dial);
|
||||
ext = talloc_zero(dial, ExternalPDU_t);
|
||||
rc = ANY_fromType((ANY_t *) &ext->dialog, &asn_DEF_DialoguePDU, dial);
|
||||
if (rc < 0)
|
||||
fprintf(stderr, "Error encoding DialoguePDU portion\n");
|
||||
any = ANY_new_fromType(&asn_DEF_ExternalPDU, &ext);
|
||||
tcm.choice.begin.dialoguePortion = (OCTET_STRING_t *) any;
|
||||
any = ANY_new_fromType(&asn_DEF_ExternalPDU, ext);
|
||||
tcm->choice.begin.dialoguePortion = (OCTET_STRING_t *) any;
|
||||
}
|
||||
/* Request components to CHA */
|
||||
/* Process components */
|
||||
/* Assemble TSL user data */
|
||||
tcm.choice.begin.components = td->pend_comp;
|
||||
tcm->choice.begin.components = td->pend_comp;
|
||||
td->pend_comp = talloc_zero(td, struct ComponentPortion);
|
||||
|
||||
/* Assign local transaction ID */
|
||||
trans_id = ntohl(td->trans.tid_local);
|
||||
OCTET_STRING_fromBuf(&tcm.choice.begin.otid,
|
||||
OCTET_STRING_fromBuf(&tcm->choice.begin.otid,
|
||||
(const char *) &trans_id, sizeof(trans_id));
|
||||
|
||||
/* TR-BEGIN-REQ to TSL */
|
||||
rc = tcap_tco_tr_begin_req(&td->trans, &tcm);
|
||||
rc = tcap_tco_tr_begin_req(&td->trans, tcm);
|
||||
|
||||
tcap_trans_set_state(&td->trans, TCAP_TS_INIT_SENT);
|
||||
|
||||
asn_DEF_TCMessage.free_struct(&asn_DEF_TCMessage, &tcm, 1);
|
||||
asn_DEF_TCMessage.free_struct(&asn_DEF_TCMessage, tcm, 0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue