S1 Setup Request done
This commit is contained in:
parent
47a9d20c0a
commit
7fc2fa1823
|
@ -50,10 +50,10 @@ status_t context_init()
|
|||
self.srvd_gummei.plmn_id[0].mcc = 1; /* 001 */
|
||||
self.srvd_gummei.plmn_id[0].mnc = 1; /* 01 */
|
||||
|
||||
self.srvd_gummei.num_of_grp_id = 1;
|
||||
self.srvd_gummei.grp_id[0] = 2;
|
||||
self.srvd_gummei.num_of_code = 1;
|
||||
self.srvd_gummei.code[0] = 1;
|
||||
self.srvd_gummei.num_of_mme_gid = 1;
|
||||
self.srvd_gummei.mme_gid[0] = 2;
|
||||
self.srvd_gummei.num_of_mme_code = 1;
|
||||
self.srvd_gummei.mme_code[0] = 1;
|
||||
|
||||
g_mme_ctx_initialized = 1;
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ typedef struct _served_gummei {
|
|||
c_uint32_t num_of_plmn_id;
|
||||
plmn_id_t plmn_id[MAX_PLMN_ID];
|
||||
|
||||
c_uint32_t num_of_grp_id;
|
||||
c_uint16_t grp_id[GRP_PER_MME];
|
||||
c_uint32_t num_of_code;
|
||||
c_uint8_t code[CODE_PER_MME];
|
||||
c_uint32_t num_of_mme_gid;
|
||||
c_uint16_t mme_gid[GRP_PER_MME];
|
||||
c_uint32_t num_of_mme_code;
|
||||
c_uint8_t mme_code[CODE_PER_MME];
|
||||
} srvd_gummei_t;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
/**
|
||||
* @file enb_s1_state.c
|
||||
*/
|
||||
|
||||
/* Server */
|
||||
#include "sm.h"
|
||||
#include "context.h"
|
||||
#include "event.h"
|
||||
|
||||
/* Core libaray */
|
||||
#define TRACE_MODULE _enb_s1_sm
|
||||
#include "core_debug.h"
|
||||
|
||||
#include "s1ap_message.h"
|
||||
#include "s1ap_conv.h"
|
||||
#include "s1ap_path.h"
|
||||
|
||||
status_t enb_s1_handle_s1setuprequest(enb_ctx_t *enb, s1ap_message *message);
|
||||
|
||||
void enb_s1_state_initial(enb_s1_sm_t *s, event_t *e)
|
||||
{
|
||||
d_assert(s, return, "Null param");
|
||||
|
||||
sm_trace(1, e);
|
||||
|
||||
FSM_TRAN(s, &enb_s1_state_operational);
|
||||
}
|
||||
|
||||
void enb_s1_state_final(enb_s1_sm_t *s, event_t *e)
|
||||
{
|
||||
d_assert(s, return, "Null param");
|
||||
|
||||
sm_trace(1, e);
|
||||
}
|
||||
|
||||
void enb_s1_state_operational(enb_s1_sm_t *s, event_t *e)
|
||||
{
|
||||
d_assert(s, return, "Null param");
|
||||
d_assert(e, return, "Null param");
|
||||
|
||||
enb_ctx_t *enb = s->ctx;
|
||||
d_assert(enb, return, "Null param");
|
||||
|
||||
sm_trace(1, e);
|
||||
|
||||
switch (event_get(e))
|
||||
{
|
||||
case FSM_ENTRY_SIG:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case FSM_EXIT_SIG:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case EVT_S1_ENB_INF:
|
||||
{
|
||||
s1ap_message message;
|
||||
status_t rv;
|
||||
pkbuf_t *recvbuf = event_get_msg(e);
|
||||
|
||||
rv = s1ap_decode_pdu(&message, recvbuf);
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("Can't parse S1AP_PDU in EVT_S1_ENB_INF");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(message.direction)
|
||||
{
|
||||
case S1AP_PDU_PR_initiatingMessage :
|
||||
{
|
||||
switch(message.procedureCode)
|
||||
{
|
||||
case S1ap_ProcedureCode_id_S1Setup :
|
||||
{
|
||||
enb_s1_handle_s1setuprequest(enb, &message);
|
||||
d_info("s1setuprequest is received");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_warn("Not implemented(choice:%d, proc:%d",
|
||||
message.direction, message.procedureCode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S1AP_PDU_PR_successfulOutcome :
|
||||
{
|
||||
switch(message.procedureCode)
|
||||
{
|
||||
default:
|
||||
{
|
||||
d_warn("Not implemented(choice:%d, proc:%d",
|
||||
message.direction, message.procedureCode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S1AP_PDU_PR_unsuccessfulOutcome :
|
||||
default:
|
||||
{
|
||||
d_warn("Not implemented(choice:%d, proc:%d",
|
||||
message.direction, message.procedureCode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s1ap_free_pdu(&message);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
d_error("Unknown event %s", event_get_name(e));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void enb_s1_state_exception(enb_s1_sm_t *s, event_t *e)
|
||||
{
|
||||
d_assert(s, return, "Null param");
|
||||
d_assert(e, return, "Null param");
|
||||
|
||||
sm_trace(1, e);
|
||||
|
||||
switch (event_get(e))
|
||||
{
|
||||
case FSM_ENTRY_SIG:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case FSM_EXIT_SIG:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_error("Unknown event %s", event_get_name(e));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status_t enb_s1_handle_s1setuprequest(enb_ctx_t *enb, s1ap_message *message)
|
||||
{
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
S1ap_S1SetupRequestIEs_t *ies = NULL;
|
||||
status_t rv;
|
||||
pkbuf_t *sendbuf = NULL;
|
||||
|
||||
d_assert(enb, return CORE_ERROR, "Null param");
|
||||
d_assert(enb->s1_sock, return CORE_ERROR, "Null param");
|
||||
d_assert(message, return CORE_ERROR, "Null param");
|
||||
|
||||
ies = &message->msg.s1ap_S1SetupRequestIEs;
|
||||
d_assert(ies, return CORE_ERROR, "Null param");
|
||||
|
||||
rv = s1ap_conv_uint32_from_enb_id(&enb->id, &ies->global_ENB_ID.eNB_ID);
|
||||
d_assert(rv == CORE_OK, return rv, "Null param");
|
||||
|
||||
d_info("eNB-id[%x] sends S1-Setup-Request from [%s]", enb->id,
|
||||
INET_NTOP(&enb->s1_sock->remote.sin_addr.s_addr, buf));
|
||||
|
||||
rv = s1ap_build_setup_rsp(&sendbuf);
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("Can't build S1 Setup Response");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
rv = s1ap_send_to_enb(enb, sendbuf);
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("Can't send S1 Setup Response");
|
||||
}
|
||||
|
||||
pkbuf_free(sendbuf);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#define TRACE_MODULE _s1conv
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "s1ap_conv.h"
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_uint8_to_octet_string(
|
||||
|
@ -83,3 +84,31 @@ CORE_DECLARE(void) s1ap_conv_home_enb_id_to_bit_string(
|
|||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_conv_uint32_from_enb_id(
|
||||
c_uint32_t *uint32, S1ap_ENB_ID_t *eNB_ID)
|
||||
{
|
||||
d_assert(uint32, return CORE_ERROR, "Null param");
|
||||
d_assert(eNB_ID, return CORE_ERROR, "Null param");
|
||||
|
||||
if (eNB_ID->present == S1ap_ENB_ID_PR_homeENB_ID)
|
||||
{
|
||||
c_uint8_t *buf = eNB_ID->choice.homeENB_ID.buf;
|
||||
d_assert(buf, return CORE_ERROR, "Null param");
|
||||
*uint32 = (buf[0] << 20) + (buf[1] << 12) + (buf[2] << 4) +
|
||||
((buf[3] & 0xf0) >> 4);
|
||||
|
||||
}
|
||||
else if (eNB_ID->present == S1ap_ENB_ID_PR_macroENB_ID)
|
||||
{
|
||||
c_uint8_t *buf = eNB_ID->choice.macroENB_ID.buf;
|
||||
d_assert(buf, return CORE_ERROR, "Null param");
|
||||
*uint32 = (buf[0] << 12) + (buf[1] << 4) + ((buf[2] & 0xf0) >> 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ CORE_DECLARE(void) s1ap_conv_macro_enb_id_to_bit_string(
|
|||
c_uint32_t enb_id, BIT_STRING_t *bit_string);
|
||||
CORE_DECLARE(void) s1ap_conv_home_enb_id_to_bit_string(
|
||||
c_uint32_t enb_id, BIT_STRING_t *bit_string);
|
||||
CORE_DECLARE(status_t) s1ap_conv_uint32_from_enb_id(
|
||||
c_uint32_t *uint32, S1ap_ENB_ID_t *eNB_ID);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -41,23 +41,23 @@ status_t s1ap_build_setup_rsp(pkbuf_t **pkbuf)
|
|||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedPLMNs, plmnIdentity);
|
||||
}
|
||||
|
||||
for (j = 0; j < srvd_gummei->num_of_grp_id; j++)
|
||||
for (j = 0; j < srvd_gummei->num_of_mme_gid; j++)
|
||||
{
|
||||
mmeGroupId = (S1ap_MME_Group_ID_t *)
|
||||
core_calloc(srvd_gummei->num_of_grp_id,
|
||||
core_calloc(srvd_gummei->num_of_mme_gid,
|
||||
sizeof(S1ap_MME_Group_ID_t));
|
||||
s1ap_conv_uint16_to_octet_string(
|
||||
srvd_gummei->grp_id[j], mmeGroupId);
|
||||
srvd_gummei->mme_gid[j], mmeGroupId);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedGroupIDs, mmeGroupId);
|
||||
}
|
||||
|
||||
for (j = 0; j < srvd_gummei->num_of_code; j++)
|
||||
for (j = 0; j < srvd_gummei->num_of_mme_code; j++)
|
||||
{
|
||||
mmeCode = (S1ap_MME_Code_t *)
|
||||
core_calloc(srvd_gummei->num_of_grp_id,
|
||||
core_calloc(srvd_gummei->num_of_mme_code,
|
||||
sizeof(S1ap_MME_Code_t));
|
||||
s1ap_conv_uint8_to_octet_string(
|
||||
srvd_gummei->code[j], mmeCode);
|
||||
srvd_gummei->mme_code[j], mmeCode);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedMMECs, mmeCode);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue