Fix encoding of DialoguePortion of TC-CONTINUE and TC-END

This commit is contained in:
Harald Welte 2010-07-18 01:09:24 +02:00
parent 1e2f04410b
commit 6a06c081cd
4 changed files with 62 additions and 17 deletions

View File

@ -146,9 +146,13 @@ int tcap_csl_tc_begin_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx
xer_fprint(stdout, &asn_DEF_DialoguePDU, &dial);
memset(&ext, 0, sizeof(ext));
ANY_fromType(&ext.dialog, &asn_DEF_DialoguePDU, &dial);
rc = ANY_fromType(&ext.dialog, &asn_DEF_DialoguePDU, &dial);
if (rc < 0)
fprintf(stderr, "Error encoding DialoguePDU portion\n");
memset(&any, 0, sizeof(any));
ANY_fromType(&any, &asn_DEF_ExternalPDU, &ext);
rc = ANY_fromType(&any, &asn_DEF_ExternalPDU, &ext);
if (rc < 0)
fprintf(stderr, "Error encoding ExternalPDU portion\n");
tcm.choice.begin.dialoguePortion = (OCTET_STRING_t *) &any;
}
/* Request components to CHA */
@ -300,7 +304,10 @@ static int gen_ext_AARE(struct DialoguePDU *dial, ANY_t *any, ExternalPDU_t *ext
AARE_apdu_t *aare;
int rc;
memset(&dial, 0, sizeof(dial));
memset(any, 0, sizeof(*any));
memset(ext, 0, sizeof(*ext));
memset(dial, 0, sizeof(*dial));
dial->present = DialoguePDU_PR_dialogueResponse;
aare = &dial->choice.dialogueResponse;
/* Set protocol version 1 */
@ -309,14 +316,21 @@ static int gen_ext_AARE(struct DialoguePDU *dial, ANY_t *any, ExternalPDU_t *ext
memcpy(&aare->application_context_name, app_ctx, sizeof(aare->application_context_name));
asn_long2INTEGER(&aare->result, Associate_result_accepted);
aare->user_information = user_info;
aare->result_source_diagnostic.present = Associate_source_diagnostic_PR_dialogue_service_user;
asn_long2INTEGER(&aare->result_source_diagnostic.choice.dialogue_service_user,
dialogue_service_user_no_reason_given);
/* Link Dialogue into External PDU */
rc = ANY_fromType(&ext->dialog, &asn_DEF_DialoguePDU, &dial);
if (rc < 0)
rc = ANY_fromType(&ext->dialog, &asn_DEF_DialoguePDU, dial);
if (rc < 0) {
fprintf(stderr, "Error generating ExternalPDU from DialoguePDU\n");
return rc;
}
/* Link External PDU into Dialogue Portion */
rc = ANY_fromType(any, &asn_DEF_ExternalPDU, &ext);
if (rc < 0)
rc = ANY_fromType(any, &asn_DEF_ExternalPDU, ext);
if (rc < 0) {
fprintf(stderr, "Error generating ANY_t from ExternalPDU\n");
return rc;
}
return 0;
}
@ -329,6 +343,7 @@ int tcap_csl_tc_cont_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx,
ExternalPDU_t ext;
DialoguePDU_t dial;
ANY_t any;
uint32_t trans_id;
int rc = 0;
memset(&tcm, 0, sizeof(tcm));
@ -336,7 +351,7 @@ int tcap_csl_tc_cont_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx,
switch (td->trans.state) {
case TCAP_TS_INIT_RECV:
if (app_ctx && user_info) {
if (app_ctx) {
gen_ext_AARE(&dial, &any, &ext, app_ctx, user_info);
fprintf(stdout, "\nTC-CONTINUE.req Dialogue portion:\n");
xer_fprint(stdout, &asn_DEF_DialoguePDU, &dial);
@ -355,6 +370,17 @@ int tcap_csl_tc_cont_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx,
/* Assemble TSL user data */
tcm.choice.Continue.components = assemble_components(&cp, td);
/* Assign local transaction ID */
trans_id = htonl(td->trans.tid_local);
OCTET_STRING_fromBuf(&tcm.choice.Continue.otid,
(const char *) &trans_id, sizeof(trans_id));
/* Assign remote transaction ID */
trans_id = htonl(td->trans.tid_remote);
OCTET_STRING_fromBuf(&tcm.choice.Continue.dtid,
(const char *) &trans_id, sizeof(trans_id));
/* TR-CONTINUE to TSL */
rc = tcap_tco_tr_continue_req(&td->trans, &tcm);

View File

@ -17,12 +17,14 @@ static struct {
uint32_t dialg_id;
} test_state;
static int send_continue()
static int send_continue(uint32_t dialg_id, void *app_ctx, void *user_info)
{
struct tcap_dialg_ind tcdi;
memset(&tcdi, 0, sizeof(tcdi));
tcdi.dialg_id = test_state.dialg_id;
tcdi.dialg_id = dialg_id;
tcdi.app_ctx_name = app_ctx;
tcdi.user_info = user_info;
return tcap_user_req_dialg(TCAP_PR_TC_CONTINUE, &tcdi);
}
@ -103,7 +105,7 @@ int tcap_user_ind_comp(enum tcap_primitive prim, struct tcap_component_ind *tcci
/* actually process the invoke */
send_invoke(test_state.dialg_id, 0, NULL, 0);
if (tcci->last_component)
send_continue();
send_continue(test_state.dialg_id, &gprs_loc_upd_ctx_v3_oid, NULL);
break;
default:
break;

View File

@ -200,6 +200,7 @@ int tcap_user_req_dialg(enum tcap_primitive prim, struct tcap_dialg_ind *tcdi)
rc = tcap_csl_tc_begin_req(td, tcdi->app_ctx_name, tcdi->user_info);
break;
case TCAP_PR_TC_CONTINUE:
fprintf(stdout, "TC-CONTINUE.req\n");
rc = tcap_csl_tc_cont_req(td, tcdi->app_ctx_name, tcdi->user_info);
break;
case TCAP_PR_TC_END:

View File

@ -2,6 +2,7 @@
#include <stdint.h>
#include <errno.h>
#include <netinet/in.h>
#include <osmocore/msgb.h>
#include <osmocom/tcap/TCMessage.h>
@ -25,12 +26,12 @@ int tcap_tsm_begin_rcvd(struct tcap_transaction *tt, struct TCMessage *tcmsg, st
if (tt->state != TCAP_TS_IDLE)
return -EINVAL;
/* FIXME: Store remote address and remote TID */
memcpy(&tt->tid_remote, msg_beg->otid.buf, sizeof(uint32_t));
/* Store remote address and remote TID */
tt->tid_remote = ntohl(*(uint32_t *) msg_beg->otid.buf);
/* FIXME: DHA */
/* FIXME: TR-BEGIN.ind to CSL */
/* TR-BEGIN.ind to CSL */
rc = tcap_csl_tr_begin_ind(tt, tcmsg, msg);
tcap_trans_set_state(tt, TCAP_TS_INIT_RECV);
@ -51,13 +52,15 @@ int tcap_tsm_begin_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg)
msg = tcap_msgb_alloc();
fprintf(stdout, "TC-BEGIN.req:\n");
xer_fprint(stdout, &asn_DEF_TCMessage, tcmsg);
/* FIXME: Store Local Address */
/* FIXME: Assemble TR-portion of BEGIN message */
/* Assemble TR-portion of BEGIN message */
ar = der_encode_to_buffer(&asn_DEF_TCMessage, tcmsg, msg->data, msgb_tailroom(msg));
if (ar.encoded < 0) {
fprintf(stdout, "some error during encode\n");
msgb_free(msg);
return -EIO;
}
msgb_put(msg, ar.encoded);
@ -76,6 +79,7 @@ int tcap_tsm_continue_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg
struct tcap_dialogue *td = dialg_by_trans(tt);
enum tcap_transaction_state new_state;
struct msgb *msg;
asn_enc_rval_t ar;
int rc;
switch (tt->state) {
@ -92,7 +96,19 @@ int tcap_tsm_continue_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg
msg = tcap_msgb_alloc();
/* FIXME: Assemble TR-portion of CONTINUE message */
fprintf(stdout, "TC-CONTINUE.req:\n");
xer_fprint(stdout, &asn_DEF_TCMessage, tcmsg);
/* Assemble TR-portion of CONTINUE message */
ar = der_encode_to_buffer(&asn_DEF_TCMessage, tcmsg, msg->data, msgb_tailroom(msg));
if (ar.encoded < 0) {
fprintf(stdout, "some error during encode\n");
msgb_free(msg);
return -EIO;
}
msgb_put(msg, ar.encoded);
/* Send N-UNITDATA.req to SCCP / SUA */
rc = tcap_scXp_n_unitdata_req(td->transp_ent, msg);
@ -172,7 +188,7 @@ int tcap_tsm_continue_rcvd(struct tcap_transaction *tt, struct TCMessage *tcmsg,
case TCAP_TS_INIT_SENT:
/* FIXME: Store remote address */
/* Store remote TID */
memcpy(&tt->tid_remote, msg_cnt->otid.buf, sizeof(uint32_t));
tt->tid_remote = ntohl(*(uint32_t *) msg_cnt->otid.buf);
/* fall-through */
case TCAP_TS_ACTIVE:
/* TR-CONTINUE.ind to CSL */