2017-03-07 07:19:18 +00:00
|
|
|
#define TRACE_MODULE _s1ap_send
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-05 06:16:32 +00:00
|
|
|
#include "core_debug.h"
|
2017-08-02 06:11:08 +00:00
|
|
|
#include "core_param.h"
|
2017-03-03 09:25:04 +00:00
|
|
|
|
2017-07-13 01:31:07 +00:00
|
|
|
#include "types.h"
|
2017-02-15 11:16:50 +00:00
|
|
|
#include "s1ap_message.h"
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_initiating_message(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-05 06:16:32 +00:00
|
|
|
static inline int s1ap_encode_successfull_outcome(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-05 06:16:32 +00:00
|
|
|
static inline int s1ap_encode_unsuccessfull_outcome(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-06 05:53:18 +00:00
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_s1setup_request(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_s1setup_response(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_s1setup_failure(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-06 05:53:18 +00:00
|
|
|
static inline int s1ap_encode_downlink_nas_transport(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-04 15:04:05 +00:00
|
|
|
static inline int s1ap_encode_initial_context_setup_request(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
|
|
|
static inline int s1ap_encode_e_rab_setup_request(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-07 14:41:05 +00:00
|
|
|
static inline int s1ap_encode_e_rab_release_command(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-09 14:15:08 +00:00
|
|
|
static inline int s1ap_encode_ue_context_release_command(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-08-04 21:34:52 +00:00
|
|
|
static inline int s1ap_encode_paging(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-11 10:20:40 +00:00
|
|
|
static inline int s1ap_encode_path_switch_ack(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-11 10:20:40 +00:00
|
|
|
static inline int s1ap_encode_path_switch_failure(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-12 04:54:55 +00:00
|
|
|
static inline int s1ap_encode_handover_request(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-12 04:54:55 +00:00
|
|
|
static inline int s1ap_encode_handover_command(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-15 03:06:26 +00:00
|
|
|
static inline int s1ap_encode_handover_cancel_ack(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-09-12 04:54:55 +00:00
|
|
|
static inline int s1ap_encode_handover_preparation_failure(
|
2017-09-12 05:16:22 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
|
|
|
static inline int s1ap_encode_mme_status_transfer(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf);
|
2017-02-06 05:53:18 +00:00
|
|
|
|
2017-02-10 13:16:22 +00:00
|
|
|
static void s1ap_encode_xer_print_message(
|
|
|
|
asn_enc_rval_t (*func)(asn_app_consume_bytes_f *cb,
|
2017-03-06 00:07:59 +00:00
|
|
|
void *app_key, s1ap_message_t *message_p),
|
|
|
|
asn_app_consume_bytes_f *cb, s1ap_message_t *message_p);
|
2017-02-10 13:16:22 +00:00
|
|
|
|
2017-03-06 00:07:59 +00:00
|
|
|
int s1ap_encode_pdu(pkbuf_t **pkb, s1ap_message_t *message_p)
|
2017-02-05 06:16:32 +00:00
|
|
|
{
|
2017-02-06 05:53:18 +00:00
|
|
|
int encoded = -1;
|
2017-02-05 06:36:02 +00:00
|
|
|
|
2017-02-05 06:16:32 +00:00
|
|
|
d_assert (message_p, return -1, "Null param");
|
|
|
|
|
2017-03-24 12:19:24 +00:00
|
|
|
*pkb = pkbuf_alloc(0, MAX_SDU_LEN);
|
2017-02-06 05:53:18 +00:00
|
|
|
d_assert(*pkb, return -1, "Null Param");
|
|
|
|
|
2017-02-05 06:16:32 +00:00
|
|
|
switch (message_p->direction)
|
|
|
|
{
|
|
|
|
case S1AP_PDU_PR_initiatingMessage:
|
2017-02-07 01:33:28 +00:00
|
|
|
encoded = s1ap_encode_initiating_message(message_p, *pkb);
|
2017-02-05 06:36:02 +00:00
|
|
|
break;
|
2017-02-05 06:16:32 +00:00
|
|
|
|
|
|
|
case S1AP_PDU_PR_successfulOutcome:
|
2017-02-06 05:53:18 +00:00
|
|
|
encoded = s1ap_encode_successfull_outcome(message_p, *pkb);
|
2017-02-05 06:36:02 +00:00
|
|
|
break;
|
2017-02-05 06:16:32 +00:00
|
|
|
|
|
|
|
case S1AP_PDU_PR_unsuccessfulOutcome:
|
2017-02-06 05:53:18 +00:00
|
|
|
encoded = s1ap_encode_unsuccessfull_outcome(message_p, *pkb);
|
2017-02-05 06:36:02 +00:00
|
|
|
break;
|
2017-02-05 06:16:32 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
d_warn("Unknown message outcome (%d) or not implemented",
|
|
|
|
(int)message_p->direction);
|
2017-02-06 05:53:18 +00:00
|
|
|
pkbuf_free(*pkb);
|
|
|
|
return -1;
|
2017-02-05 06:16:32 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
if (encoded < 0)
|
2017-02-05 06:36:02 +00:00
|
|
|
{
|
2017-02-06 05:53:18 +00:00
|
|
|
pkbuf_free(*pkb);
|
|
|
|
return -1;
|
2017-02-05 06:36:02 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 09:11:09 +00:00
|
|
|
(*pkb)->len = (encoded >> 3);
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
return encoded;
|
2017-02-05 06:16:32 +00:00
|
|
|
}
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_initiating_message(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-10 13:16:22 +00:00
|
|
|
int ret = -1;
|
2017-02-06 05:53:18 +00:00
|
|
|
switch (message_p->procedureCode)
|
|
|
|
{
|
2017-02-06 11:54:31 +00:00
|
|
|
case S1ap_ProcedureCode_id_S1Setup:
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_s1setuprequest,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_s1setup_request(message_p, pkbuf);
|
|
|
|
break;
|
2017-02-06 11:54:31 +00:00
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
case S1ap_ProcedureCode_id_downlinkNASTransport:
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_downlinknastransport,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_downlink_nas_transport(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
case S1ap_ProcedureCode_id_InitialContextSetup:
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_initialcontextsetuprequest,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_initial_context_setup_request(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-04 15:04:05 +00:00
|
|
|
case S1ap_ProcedureCode_id_E_RABSetup:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_e_rabsetuprequest,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_e_rab_setup_request(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-07 14:41:05 +00:00
|
|
|
case S1ap_ProcedureCode_id_E_RABRelease:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_e_rabreleasecommand,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_e_rab_release_command(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
case S1ap_ProcedureCode_id_UEContextRelease:
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_uecontextreleasecommand,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_ue_context_release_command(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-08-04 21:34:52 +00:00
|
|
|
case S1ap_ProcedureCode_id_Paging:
|
2017-09-12 04:54:55 +00:00
|
|
|
s1ap_encode_xer_print_message(s1ap_xer_print_s1ap_paging,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
2017-08-04 21:34:52 +00:00
|
|
|
ret = s1ap_encode_paging(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
case S1ap_ProcedureCode_id_HandoverResourceAllocation:
|
|
|
|
s1ap_encode_xer_print_message(s1ap_xer_print_s1ap_handoverrequest,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_handover_request(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
|
|
|
case S1ap_ProcedureCode_id_MMEStatusTransfer:
|
|
|
|
s1ap_encode_xer_print_message(s1ap_xer_print_s1ap_mmestatustransfer,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_mme_status_transfer(message_p, pkbuf);
|
|
|
|
break;
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
default:
|
|
|
|
d_warn("Unknown procedure ID (%d) for initiating message_p\n",
|
|
|
|
(int)message_p->procedureCode);
|
|
|
|
break;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 13:16:22 +00:00
|
|
|
return ret;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
static inline int s1ap_encode_successfull_outcome(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-10 13:16:22 +00:00
|
|
|
int ret = -1;
|
2017-02-06 05:53:18 +00:00
|
|
|
switch (message_p->procedureCode)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-06 05:53:18 +00:00
|
|
|
case S1ap_ProcedureCode_id_S1Setup:
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_s1setupresponse,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_s1setup_response(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-11 10:20:40 +00:00
|
|
|
case S1ap_ProcedureCode_id_PathSwitchRequest:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_pathswitchrequestacknowledge,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_path_switch_ack(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
case S1ap_ProcedureCode_id_HandoverPreparation:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_handovercommand,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_handover_command(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-15 03:06:26 +00:00
|
|
|
case S1ap_ProcedureCode_id_HandoverCancel:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_handovercancelacknowledge,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_handover_cancel_ack(message_p, pkbuf);
|
|
|
|
break;
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
default:
|
|
|
|
d_warn("Unknown procedure ID (%d) for successfull "
|
|
|
|
"outcome message\n", (int)message_p->procedureCode);
|
|
|
|
break;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 13:16:22 +00:00
|
|
|
return ret;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
static inline int s1ap_encode_unsuccessfull_outcome(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-10 13:16:22 +00:00
|
|
|
int ret = -1;
|
2017-02-06 05:53:18 +00:00
|
|
|
switch (message_p->procedureCode)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-06 05:53:18 +00:00
|
|
|
case S1ap_ProcedureCode_id_S1Setup:
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_s1setupfailure,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_s1setup_failure(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-11 10:20:40 +00:00
|
|
|
case S1ap_ProcedureCode_id_PathSwitchRequest:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_pathswitchrequestfailure,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_path_switch_failure(message_p, pkbuf);
|
|
|
|
break;
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
case S1ap_ProcedureCode_id_HandoverPreparation:
|
|
|
|
s1ap_encode_xer_print_message(
|
|
|
|
s1ap_xer_print_s1ap_handoverpreparationfailure,
|
|
|
|
s1ap_xer__print2sp, message_p);
|
|
|
|
ret = s1ap_encode_handover_preparation_failure(message_p, pkbuf);
|
2017-09-12 05:16:22 +00:00
|
|
|
break;
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
default:
|
|
|
|
d_warn("Unknown procedure ID (%d) for unsuccessfull "
|
|
|
|
"outcome message\n", (int)message_p->procedureCode);
|
|
|
|
break;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 13:16:22 +00:00
|
|
|
return ret;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_s1setup_request(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-06 11:54:31 +00:00
|
|
|
{
|
2017-02-07 01:33:28 +00:00
|
|
|
asn_enc_rval_t enc_ret = {0};
|
2017-02-06 11:54:31 +00:00
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_S1SetupRequest_t s1SetupRequest;
|
2017-02-07 02:35:22 +00:00
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_S1SetupRequest;
|
2017-02-06 11:54:31 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&s1SetupRequest, 0, sizeof(s1SetupRequest));
|
2017-02-06 11:54:31 +00:00
|
|
|
if (s1ap_encode_s1ap_s1setuprequesties(
|
2017-03-05 02:46:42 +00:00
|
|
|
&s1SetupRequest, &message_p->s1ap_S1SetupRequestIEs) < 0)
|
2017-02-06 11:54:31 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-06 11:54:31 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
2017-02-07 02:35:22 +00:00
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
2017-02-07 01:33:28 +00:00
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
2017-02-07 02:35:22 +00:00
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, &s1SetupRequest);
|
2017-02-07 01:33:28 +00:00
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
2017-03-24 12:19:24 +00:00
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
2017-02-07 01:33:28 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &s1SetupRequest);
|
2017-02-07 01:33:28 +00:00
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-07 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
2017-02-06 11:54:31 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 01:33:28 +00:00
|
|
|
static inline int s1ap_encode_s1setup_response(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
asn_enc_rval_t enc_ret = {0};
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_S1SetupResponse_t s1SetupResponse;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_S1SetupResponse;
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&s1SetupResponse, 0, sizeof (S1ap_S1SetupResponse_t));
|
2017-02-04 15:49:53 +00:00
|
|
|
if (s1ap_encode_s1ap_s1setupresponseies(
|
2017-03-05 02:46:42 +00:00
|
|
|
&s1SetupResponse, &message_p->s1ap_S1SetupResponseIEs) < 0)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-04 16:11:21 +00:00
|
|
|
return -1;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
|
|
|
pdu.choice.successfulOutcome.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.successfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.successfulOutcome.value,
|
|
|
|
td, &s1SetupResponse);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
2017-03-24 12:19:24 +00:00
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &s1SetupResponse);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
if (enc_ret.encoded < 0)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
return enc_ret.encoded;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
static inline int s1ap_encode_s1setup_failure(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
asn_enc_rval_t enc_ret = {0};
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_S1SetupFailure_t s1SetupFailure;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_S1SetupFailure;
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&s1SetupFailure, 0, sizeof (S1ap_S1SetupFailure_t));
|
|
|
|
if (s1ap_encode_s1ap_s1setupfailureies(
|
2017-03-05 02:46:42 +00:00
|
|
|
&s1SetupFailure, &message_p->s1ap_S1SetupFailureIEs) < 0)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-04 16:11:21 +00:00
|
|
|
return -1;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_unsuccessfulOutcome;
|
|
|
|
pdu.choice.unsuccessfulOutcome.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.unsuccessfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.unsuccessfulOutcome.value,
|
|
|
|
td, &s1SetupFailure);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
2017-03-24 12:19:24 +00:00
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &s1SetupFailure);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
if (enc_ret.encoded < 0)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
return enc_ret.encoded;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
static inline int s1ap_encode_downlink_nas_transport(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
S1AP_PDU_t pdu;
|
2017-02-07 02:35:22 +00:00
|
|
|
S1ap_DownlinkNASTransport_t downlinkNasTransport;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_DownlinkNASTransport;
|
2017-02-07 01:33:28 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&downlinkNasTransport, 0, sizeof(S1ap_DownlinkNASTransport_t));
|
|
|
|
if (s1ap_encode_s1ap_downlinknastransport_ies(&downlinkNasTransport,
|
2017-03-05 02:46:42 +00:00
|
|
|
&message_p->s1ap_DownlinkNASTransport_IEs) < 0)
|
2017-02-07 02:35:22 +00:00
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
2017-02-07 02:35:22 +00:00
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_ignore;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value,
|
|
|
|
td, &downlinkNasTransport);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
2017-03-24 12:19:24 +00:00
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &downlinkNasTransport);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
2017-09-04 15:04:05 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int s1ap_encode_initial_context_setup_request(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_InitialContextSetupRequest_t initialContextSetupRequest;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_InitialContextSetupRequest;
|
|
|
|
|
|
|
|
memset(&initialContextSetupRequest, 0,
|
|
|
|
sizeof(S1ap_InitialContextSetupRequest_t));
|
|
|
|
if (s1ap_encode_s1ap_initialcontextsetuprequesties(
|
|
|
|
&initialContextSetupRequest,
|
|
|
|
&message_p->s1ap_InitialContextSetupRequestIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value,
|
|
|
|
td, &initialContextSetupRequest);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &initialContextSetupRequest);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int s1ap_encode_e_rab_setup_request(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_E_RABSetupRequest_t req;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_E_RABSetupRequest;
|
|
|
|
|
|
|
|
memset(&req, 0, sizeof(S1ap_E_RABSetupRequest_t));
|
|
|
|
if (s1ap_encode_s1ap_e_rabsetuprequesties(
|
|
|
|
&req, &message_p->s1ap_E_RABSetupRequestIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, &req);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &req);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
2017-09-07 14:41:05 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int s1ap_encode_e_rab_release_command(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_E_RABReleaseCommand_t req;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_E_RABReleaseCommand;
|
|
|
|
|
|
|
|
memset(&req, 0, sizeof(S1ap_E_RABReleaseCommand_t));
|
|
|
|
if (s1ap_encode_s1ap_e_rabreleasecommandies(
|
|
|
|
&req, &message_p->s1ap_E_RABReleaseCommandIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, &req);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &req);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
2017-02-06 05:53:18 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
return enc_ret.encoded;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
static inline int s1ap_encode_ue_context_release_command(
|
2017-03-06 00:07:59 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-02-04 15:49:53 +00:00
|
|
|
{
|
2017-02-07 02:35:22 +00:00
|
|
|
asn_enc_rval_t enc_ret = {0};
|
2017-02-04 15:49:53 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_UEContextReleaseCommand_t ueContextReleaseCommand;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_UEContextReleaseCommand;
|
2017-02-06 05:53:18 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&ueContextReleaseCommand, 0,
|
|
|
|
sizeof(S1ap_UEContextReleaseCommand_t));
|
|
|
|
if (s1ap_encode_s1ap_uecontextreleasecommand_ies(
|
|
|
|
&ueContextReleaseCommand,
|
2017-03-05 02:46:42 +00:00
|
|
|
&message_p->s1ap_UEContextReleaseCommand_IEs) < 0)
|
2017-02-07 02:35:22 +00:00
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
2017-02-07 01:33:28 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value,
|
|
|
|
td, &ueContextReleaseCommand);
|
2017-02-06 05:53:18 +00:00
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
2017-03-24 12:19:24 +00:00
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
2017-02-07 01:33:28 +00:00
|
|
|
|
2017-02-07 02:35:22 +00:00
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &ueContextReleaseCommand);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
2017-02-07 01:33:28 +00:00
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 05:53:18 +00:00
|
|
|
return enc_ret.encoded;
|
2017-02-04 15:49:53 +00:00
|
|
|
}
|
2017-02-10 13:16:22 +00:00
|
|
|
|
2017-08-04 21:34:52 +00:00
|
|
|
static inline int s1ap_encode_paging(s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_Paging_t paging;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_Paging;
|
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
memset(&paging, 0, sizeof(S1ap_Paging_t));
|
|
|
|
if (s1ap_encode_s1ap_pagingies(&paging, &message_p->s1ap_PagingIEs) < 0)
|
2017-08-04 21:34:52 +00:00
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_ignore;
|
2017-09-12 04:54:55 +00:00
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, &paging);
|
2017-08-04 21:34:52 +00:00
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &paging);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
2017-09-11 10:20:40 +00:00
|
|
|
static inline int s1ap_encode_path_switch_ack(
|
2017-09-12 04:54:55 +00:00
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
2017-09-11 10:20:40 +00:00
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_PathSwitchRequestAcknowledge_t ack;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_PathSwitchRequestAcknowledge;
|
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
memset(&ack, 0, sizeof(S1ap_PathSwitchRequestAcknowledge_t));
|
2017-09-11 10:20:40 +00:00
|
|
|
if (s1ap_encode_s1ap_pathswitchrequestacknowledgeies(
|
|
|
|
&ack, &message_p->s1ap_PathSwitchRequestAcknowledgeIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
|
|
|
pdu.choice.successfulOutcome.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.successfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, &ack);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &ack);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int s1ap_encode_path_switch_failure(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_PathSwitchRequestFailure_t failure;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_PathSwitchRequestFailure;
|
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
memset(&failure, 0, sizeof(S1ap_PathSwitchRequestFailure_t));
|
2017-09-11 10:20:40 +00:00
|
|
|
if (s1ap_encode_s1ap_pathswitchrequestfailureies(
|
|
|
|
&failure, &message_p->s1ap_PathSwitchRequestFailureIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_unsuccessfulOutcome;
|
|
|
|
pdu.choice.unsuccessfulOutcome.procedureCode = message_p->procedureCode;
|
2017-09-12 04:54:55 +00:00
|
|
|
pdu.choice.unsuccessfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.unsuccessfulOutcome.value, td, &failure);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &failure);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int s1ap_encode_handover_request(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_HandoverRequest_t request;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_HandoverRequest;
|
|
|
|
|
|
|
|
memset(&request, 0, sizeof(S1ap_HandoverRequest_t));
|
|
|
|
if (s1ap_encode_s1ap_handoverrequesties(
|
|
|
|
&request, &message_p->s1ap_HandoverRequestIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, &request);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &request);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
2017-09-12 05:16:22 +00:00
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
static inline int s1ap_encode_handover_command(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_HandoverCommand_t command;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_HandoverCommand;
|
|
|
|
|
|
|
|
memset(&command, 0, sizeof(S1ap_HandoverCommand_t));
|
|
|
|
if (s1ap_encode_s1ap_handovercommandies(
|
|
|
|
&command, &message_p->s1ap_HandoverCommandIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
|
|
|
pdu.choice.successfulOutcome.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.successfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, &command);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &command);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
2017-09-15 03:06:26 +00:00
|
|
|
|
2017-09-12 04:54:55 +00:00
|
|
|
static inline int s1ap_encode_handover_preparation_failure(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_HandoverPreparationFailure_t failure;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_HandoverPreparationFailure;
|
|
|
|
|
|
|
|
memset(&failure, 0, sizeof(S1ap_HandoverPreparationFailure_t));
|
|
|
|
if (s1ap_encode_s1ap_handoverpreparationfailureies(
|
|
|
|
&failure, &message_p->s1ap_HandoverPreparationFailureIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_unsuccessfulOutcome;
|
|
|
|
pdu.choice.unsuccessfulOutcome.procedureCode = message_p->procedureCode;
|
2017-09-11 10:20:40 +00:00
|
|
|
pdu.choice.unsuccessfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.unsuccessfulOutcome.value, td, &failure);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &failure);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
2017-09-15 03:06:26 +00:00
|
|
|
static inline int s1ap_encode_handover_cancel_ack(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_HandoverCancelAcknowledge_t ack;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_HandoverCommand;
|
|
|
|
|
|
|
|
memset(&ack, 0, sizeof(S1ap_HandoverCommand_t));
|
|
|
|
if (s1ap_encode_s1ap_handovercancelacknowledgeies(
|
|
|
|
&ack, &message_p->s1ap_HandoverCancelAcknowledgeIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
|
|
|
pdu.choice.successfulOutcome.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.successfulOutcome.criticality = S1ap_Criticality_reject;
|
|
|
|
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, &ack);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &ack);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
2017-09-12 05:16:22 +00:00
|
|
|
static inline int s1ap_encode_mme_status_transfer(
|
|
|
|
s1ap_message_t *message_p, pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
asn_enc_rval_t enc_ret = {0};
|
|
|
|
|
|
|
|
S1AP_PDU_t pdu;
|
|
|
|
S1ap_MMEStatusTransfer_t status;
|
|
|
|
asn_TYPE_descriptor_t *td = &asn_DEF_S1ap_MMEStatusTransfer;
|
|
|
|
|
|
|
|
memset(&status, 0, sizeof(S1ap_MMEStatusTransfer_t));
|
|
|
|
if (s1ap_encode_s1ap_mmestatustransferies(
|
|
|
|
&status, &message_p->s1ap_MMEStatusTransferIEs) < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
|
|
|
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
|
|
|
pdu.choice.initiatingMessage.procedureCode = message_p->procedureCode;
|
|
|
|
pdu.choice.initiatingMessage.criticality = S1ap_Criticality_ignore;
|
|
|
|
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, &status);
|
|
|
|
|
|
|
|
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
|
|
|
&pdu, pkbuf->payload, MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, &status);
|
|
|
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_PDU, &pdu);
|
|
|
|
|
|
|
|
if (enc_ret.encoded < 0)
|
|
|
|
{
|
|
|
|
d_error("Encoding of %s failed", td->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enc_ret.encoded;
|
|
|
|
}
|
|
|
|
|
2017-02-10 13:16:22 +00:00
|
|
|
static void s1ap_encode_xer_print_message(
|
|
|
|
asn_enc_rval_t (*func)(asn_app_consume_bytes_f *cb,
|
2017-03-06 00:07:59 +00:00
|
|
|
void *app_key, s1ap_message_t *message_p),
|
|
|
|
asn_app_consume_bytes_f *cb, s1ap_message_t *message_p)
|
2017-02-10 13:16:22 +00:00
|
|
|
{
|
2017-07-31 13:35:25 +00:00
|
|
|
if (g_trace_mask && TRACE_MODULE >= 5)
|
2017-02-10 13:16:22 +00:00
|
|
|
{
|
2017-02-10 13:27:35 +00:00
|
|
|
char *message_string = core_calloc(HUGE_STRING_LEN, sizeof(c_uint8_t));
|
2017-02-10 13:16:22 +00:00
|
|
|
s1ap_string_total_size = 0;
|
|
|
|
|
2017-02-10 13:27:35 +00:00
|
|
|
func(cb, message_string, message_p);
|
2017-02-10 13:16:22 +00:00
|
|
|
|
2017-02-10 13:27:35 +00:00
|
|
|
printf("%s\n", message_string);
|
2017-02-10 13:32:26 +00:00
|
|
|
|
|
|
|
core_free(message_string);
|
2017-02-10 13:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|