open5gs/test/s1ap_enb_build.c

57 lines
1.5 KiB
C
Raw Normal View History

2017-02-13 07:03:12 +00:00
#define TRACE_MODULE _s1enbmsg
#include "core_debug.h"
#include "core_pkbuf.h"
#include "context.h"
2017-02-20 10:46:58 +00:00
#include "s1ap_build.h"
2017-02-13 07:03:12 +00:00
#include "s1ap_conv.h"
2017-02-13 10:14:04 +00:00
status_t s1ap_build_setup_req(pkbuf_t **pkbuf, c_uint32_t enb_id)
2017-02-13 07:03:12 +00:00
{
int erval = -1;
s1ap_message message;
S1ap_S1SetupRequestIEs_t *ies;
S1ap_PLMNidentity_t *plmnIdentity;
S1ap_SupportedTAs_Item_t *supportedTA;
memset(&message, 0, sizeof(s1ap_message));
2017-03-05 02:46:42 +00:00
ies = &message.s1ap_S1SetupRequestIEs;
2017-02-13 07:03:12 +00:00
2017-03-05 02:29:15 +00:00
s1ap_uint32_to_ENB_ID(S1ap_ENB_ID_PR_macroENB_ID, enb_id,
&ies->global_ENB_ID.eNB_ID);
s1ap_plmn_id_to_TBCD_STRING(
2017-02-13 07:03:12 +00:00
&mme_self()->plmn_id, &ies->global_ENB_ID.pLMNidentity);
supportedTA = (S1ap_SupportedTAs_Item_t *)
core_calloc(1, sizeof(S1ap_SupportedTAs_Item_t));
2017-03-05 02:29:15 +00:00
s1ap_uint16_to_OCTET_STRING(
2017-02-14 00:09:01 +00:00
mme_self()->tracking_area_code, &supportedTA->tAC);
2017-02-13 07:03:12 +00:00
plmnIdentity = (S1ap_PLMNidentity_t *)
core_calloc(1, sizeof(S1ap_PLMNidentity_t));
2017-03-05 02:29:15 +00:00
s1ap_plmn_id_to_TBCD_STRING(
2017-02-13 07:03:12 +00:00
&mme_self()->plmn_id, plmnIdentity);
ASN_SEQUENCE_ADD(&supportedTA->broadcastPLMNs, plmnIdentity);
ASN_SEQUENCE_ADD(&ies->supportedTAs, supportedTA);
2017-02-14 00:09:01 +00:00
ies->defaultPagingDRX = mme_self()->default_paging_drx;
2017-02-13 07:03:12 +00:00
message.direction = S1AP_PDU_PR_initiatingMessage;
message.procedureCode = S1ap_ProcedureCode_id_S1Setup;
erval = s1ap_encode_pdu(pkbuf, &message);
s1ap_free_pdu(&message);
if (erval < 0)
{
d_error("s1ap_encode_error : (%d)", erval);
return CORE_ERROR;
}
return CORE_OK;
}