2017-03-04 15:54:15 +00:00
|
|
|
#define TRACE_MODULE _mme_ctx
|
|
|
|
|
2017-02-06 06:30:12 +00:00
|
|
|
#include "core_debug.h"
|
|
|
|
#include "core_pool.h"
|
|
|
|
|
2017-03-24 13:52:55 +00:00
|
|
|
#include "3gpp_conv.h"
|
2017-03-23 14:15:55 +00:00
|
|
|
#include "gtp_path.h"
|
2017-03-26 06:34:34 +00:00
|
|
|
#include "s1ap_message.h"
|
|
|
|
|
2017-04-04 01:49:19 +00:00
|
|
|
#include "mme_ctx.h"
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
#define CELL_PER_ENB 8
|
|
|
|
#define UE_PER_ENB 128
|
2017-03-27 12:28:07 +00:00
|
|
|
#define ERAB_PER_UE 16
|
2017-03-27 13:40:06 +00:00
|
|
|
#define S11_PER_UE 8
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
#define SIZE_OF_SGW_POOL 8
|
2017-03-05 04:03:11 +00:00
|
|
|
#define SIZE_OF_ENB_POOL 128
|
|
|
|
#define SIZE_OF_UE_POOL (SIZE_OF_ENB_POOL * UE_PER_ENB)
|
2017-03-27 12:28:07 +00:00
|
|
|
#define SIZE_OF_ERAB_POOL (SIZE_OF_UE_POOL * ERAB_PER_UE)
|
2017-03-27 13:40:06 +00:00
|
|
|
#define SIZE_OF_S11_POOL (SIZE_OF_UE_POOL * S11_PER_UE)
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-23 14:05:40 +00:00
|
|
|
#define S1AP_SCTP_PORT 36412
|
2017-03-04 14:48:04 +00:00
|
|
|
|
2017-02-06 06:30:12 +00:00
|
|
|
static mme_ctx_t self;
|
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
pool_declare(sgw_pool, sgw_ctx_t, SIZE_OF_SGW_POOL);
|
2017-02-13 04:19:53 +00:00
|
|
|
pool_declare(enb_pool, enb_ctx_t, SIZE_OF_ENB_POOL);
|
|
|
|
pool_declare(ue_pool, ue_ctx_t, SIZE_OF_UE_POOL);
|
2017-03-27 12:28:07 +00:00
|
|
|
pool_declare(erab_pool, erab_ctx_t, SIZE_OF_ERAB_POOL);
|
2017-03-27 13:40:06 +00:00
|
|
|
pool_declare(s11_pool, s11_ctx_t, SIZE_OF_S11_POOL);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-24 09:47:05 +00:00
|
|
|
static int ctx_initialized = 0;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
static list_t sgw_list;
|
2017-03-24 09:47:05 +00:00
|
|
|
static list_t enb_list;
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
status_t mme_ctx_init()
|
2017-02-06 06:30:12 +00:00
|
|
|
{
|
2017-03-24 09:47:05 +00:00
|
|
|
d_assert(ctx_initialized == 0, return CORE_ERROR,
|
|
|
|
"MME context already has been ctx_initialized");
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
pool_init(&sgw_pool, SIZE_OF_SGW_POOL);
|
2017-02-13 04:19:53 +00:00
|
|
|
pool_init(&enb_pool, SIZE_OF_ENB_POOL);
|
|
|
|
pool_init(&ue_pool, SIZE_OF_UE_POOL);
|
2017-03-27 12:28:07 +00:00
|
|
|
pool_init(&erab_pool, SIZE_OF_ERAB_POOL);
|
2017-03-27 13:40:06 +00:00
|
|
|
pool_init(&s11_pool, SIZE_OF_ERAB_POOL);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
list_init(&sgw_list);
|
2017-03-24 09:47:05 +00:00
|
|
|
list_init(&enb_list);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-02-06 06:30:12 +00:00
|
|
|
/* Initialize MME context */
|
|
|
|
memset(&self, 0, sizeof(mme_ctx_t));
|
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
self.s1ap_addr = inet_addr("127.0.0.1");
|
2017-03-24 09:47:05 +00:00
|
|
|
self.s1ap_port = S1AP_SCTP_PORT;
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-27 04:22:42 +00:00
|
|
|
sgw_ctx_t *sgw = mme_ctx_sgw_add();
|
|
|
|
d_assert(sgw, return CORE_ERROR, "Can't add SGW context");
|
|
|
|
|
2017-03-28 07:35:57 +00:00
|
|
|
self.s11_addr = inet_addr("127.0.0.1");
|
|
|
|
self.s11_port = GTPV2_C_UDP_PORT;
|
|
|
|
|
2017-03-27 04:22:42 +00:00
|
|
|
sgw->gnode.addr = inet_addr("127.0.0.1");
|
|
|
|
sgw->gnode.port = GTPV2_C_UDP_PORT+1;
|
|
|
|
|
2017-03-24 13:52:55 +00:00
|
|
|
/* MCC : 001, MNC : 01 */
|
|
|
|
plmn_id_build(&self.plmn_id, 1, 1, 2);
|
2017-02-14 00:09:01 +00:00
|
|
|
self.tracking_area_code = 12345;
|
|
|
|
self.default_paging_drx = S1ap_PagingDRX_v64;
|
2017-02-06 10:12:10 +00:00
|
|
|
self.relative_capacity = 0xff;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-02-06 10:12:10 +00:00
|
|
|
self.srvd_gummei.num_of_plmn_id = 1;
|
2017-03-24 13:52:55 +00:00
|
|
|
/* MCC : 001, MNC : 01 */
|
|
|
|
plmn_id_build(&self.srvd_gummei.plmn_id[0], 1, 1, 2);
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-02-13 05:41:20 +00:00
|
|
|
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;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-03-07 05:47:17 +00:00
|
|
|
self.selected_enc_algorithm = NAS_SECURITY_ALGORITHMS_EEA0;
|
2017-03-07 00:30:12 +00:00
|
|
|
self.selected_int_algorithm = NAS_SECURITY_ALGORITHMS_128_EIA1;
|
|
|
|
|
2017-03-24 09:47:05 +00:00
|
|
|
ctx_initialized = 1;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
status_t mme_ctx_final()
|
2017-02-06 06:30:12 +00:00
|
|
|
{
|
2017-03-24 09:47:05 +00:00
|
|
|
d_assert(ctx_initialized == 1, return CORE_ERROR,
|
2017-02-06 06:30:12 +00:00
|
|
|
"HyperCell context already has been finalized");
|
|
|
|
|
2017-03-27 04:22:42 +00:00
|
|
|
mme_ctx_sgw_remove_all();
|
2017-03-04 16:05:03 +00:00
|
|
|
mme_ctx_enb_remove_all();
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
pool_final(&sgw_pool);
|
2017-02-13 04:19:53 +00:00
|
|
|
pool_final(&enb_pool);
|
|
|
|
pool_final(&ue_pool);
|
2017-03-27 12:28:07 +00:00
|
|
|
pool_final(&erab_pool);
|
2017-03-27 13:40:06 +00:00
|
|
|
pool_final(&s11_pool);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-24 09:47:05 +00:00
|
|
|
ctx_initialized = 0;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mme_ctx_t* mme_self()
|
|
|
|
{
|
|
|
|
return &self;
|
|
|
|
}
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
sgw_ctx_t* mme_ctx_sgw_add()
|
|
|
|
{
|
|
|
|
sgw_ctx_t *sgw = NULL;
|
|
|
|
|
|
|
|
pool_alloc_node(&sgw_pool, &sgw);
|
|
|
|
d_assert(sgw, return NULL, "Null param");
|
|
|
|
|
|
|
|
memset(sgw, 0, sizeof(sgw_ctx_t));
|
|
|
|
|
2017-04-03 06:31:57 +00:00
|
|
|
list_init(&sgw->gnode.local_list);
|
|
|
|
list_init(&sgw->gnode.remote_list);
|
2017-03-30 12:17:05 +00:00
|
|
|
|
2017-03-26 15:48:33 +00:00
|
|
|
list_append(&sgw_list, sgw);
|
|
|
|
|
|
|
|
return sgw;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t mme_ctx_sgw_remove(sgw_ctx_t *sgw)
|
|
|
|
{
|
|
|
|
d_assert(sgw, return CORE_ERROR, "Null param");
|
|
|
|
|
|
|
|
list_remove(&sgw_list, sgw);
|
|
|
|
pool_free_node(&sgw_pool, sgw);
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t mme_ctx_sgw_remove_all()
|
|
|
|
{
|
|
|
|
sgw_ctx_t *sgw = NULL, *next_sgw = NULL;
|
|
|
|
|
|
|
|
sgw = mme_ctx_sgw_first();
|
|
|
|
while (sgw)
|
|
|
|
{
|
|
|
|
next_sgw = mme_ctx_sgw_next(sgw);
|
|
|
|
|
|
|
|
mme_ctx_sgw_remove(sgw);
|
|
|
|
|
|
|
|
sgw = next_sgw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
sgw_ctx_t* mme_ctx_sgw_find_by_node(gtp_node_t *gnode)
|
|
|
|
{
|
|
|
|
sgw_ctx_t *sgw = NULL;
|
|
|
|
|
|
|
|
sgw = mme_ctx_sgw_first();
|
|
|
|
while (sgw)
|
|
|
|
{
|
2017-03-27 04:22:42 +00:00
|
|
|
if (GTP_COMPARE_NODE(&sgw->gnode, gnode))
|
2017-03-26 15:48:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
sgw = mme_ctx_sgw_next(sgw);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sgw;
|
|
|
|
}
|
|
|
|
|
|
|
|
sgw_ctx_t* mme_ctx_sgw_first()
|
|
|
|
{
|
|
|
|
return list_first(&sgw_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
sgw_ctx_t* mme_ctx_sgw_next(sgw_ctx_t *sgw)
|
|
|
|
{
|
|
|
|
return list_next(sgw);
|
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
enb_ctx_t* mme_ctx_enb_add()
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
|
|
|
enb_ctx_t *enb = NULL;
|
|
|
|
|
|
|
|
pool_alloc_node(&enb_pool, &enb);
|
2017-03-05 04:03:11 +00:00
|
|
|
d_assert(enb, return NULL, "Null param");
|
2017-02-13 04:19:53 +00:00
|
|
|
|
|
|
|
memset(enb, 0, sizeof(enb_ctx_t));
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
list_init(&enb->ue_list);
|
|
|
|
|
2017-03-24 09:47:05 +00:00
|
|
|
list_append(&enb_list, enb);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
|
|
|
return enb;
|
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
status_t mme_ctx_enb_remove(enb_ctx_t *enb)
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
|
|
|
d_assert(enb, return CORE_ERROR, "Null param");
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
mme_ctx_ue_remove_all(enb);
|
|
|
|
|
2017-03-24 09:47:05 +00:00
|
|
|
list_remove(&enb_list, enb);
|
2017-02-13 04:19:53 +00:00
|
|
|
pool_free_node(&enb_pool, enb);
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
status_t mme_ctx_enb_remove_all()
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
|
|
|
enb_ctx_t *enb = NULL, *next_enb = NULL;
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
enb = mme_ctx_enb_first();
|
2017-02-13 04:19:53 +00:00
|
|
|
while (enb)
|
|
|
|
{
|
2017-03-05 04:03:11 +00:00
|
|
|
next_enb = mme_ctx_enb_next(enb);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
mme_ctx_enb_remove(enb);
|
2017-02-13 04:19:53 +00:00
|
|
|
|
|
|
|
enb = next_enb;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
enb_ctx_t* mme_ctx_enb_find_by_sock(net_sock_t *sock)
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
|
|
|
enb_ctx_t *enb = NULL;
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
enb = mme_ctx_enb_first();
|
2017-02-13 04:19:53 +00:00
|
|
|
while (enb)
|
|
|
|
{
|
2017-03-05 04:03:11 +00:00
|
|
|
if (sock == enb->s1ap_sock)
|
2017-02-13 04:19:53 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
enb = mme_ctx_enb_next(enb);
|
2017-02-13 04:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return enb;
|
|
|
|
}
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
enb_ctx_t* mme_ctx_enb_find_by_enb_id(c_uint32_t enb_id)
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
|
|
|
enb_ctx_t *enb = NULL;
|
|
|
|
|
2017-03-24 09:47:05 +00:00
|
|
|
enb = list_first(&enb_list);
|
2017-02-13 04:19:53 +00:00
|
|
|
while (enb)
|
|
|
|
{
|
2017-03-05 04:03:11 +00:00
|
|
|
if (enb_id == enb->enb_id)
|
2017-02-13 04:19:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
enb = list_next(enb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return enb;
|
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
enb_ctx_t* mme_ctx_enb_first()
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
2017-03-24 09:47:05 +00:00
|
|
|
return list_first(&enb_list);
|
2017-02-13 04:19:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 16:05:03 +00:00
|
|
|
enb_ctx_t* mme_ctx_enb_next(enb_ctx_t *enb)
|
2017-02-13 04:19:53 +00:00
|
|
|
{
|
|
|
|
return list_next(enb);
|
|
|
|
}
|
2017-03-05 04:03:11 +00:00
|
|
|
|
|
|
|
ue_ctx_t* mme_ctx_ue_add(enb_ctx_t *enb)
|
|
|
|
{
|
|
|
|
ue_ctx_t *ue = NULL;
|
|
|
|
|
|
|
|
d_assert(enb, return NULL, "Null param");
|
|
|
|
|
|
|
|
pool_alloc_node(&ue_pool, &ue);
|
|
|
|
d_assert(ue, return NULL, "Null param");
|
|
|
|
|
|
|
|
memset(ue, 0, sizeof(ue_ctx_t));
|
|
|
|
|
|
|
|
ue->enb = enb;
|
2017-03-27 12:28:07 +00:00
|
|
|
list_init(&ue->erab_list);
|
2017-03-27 13:40:06 +00:00
|
|
|
list_init(&ue->s11_list);
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-05 07:49:57 +00:00
|
|
|
if (self.mme_ue_s1ap_id == 0) self.mme_ue_s1ap_id = 1;
|
|
|
|
ue->mme_ue_s1ap_id = self.mme_ue_s1ap_id;
|
|
|
|
|
2017-03-08 10:10:01 +00:00
|
|
|
self.mme_ue_s1ap_id = self.mme_ue_s1ap_id + 1;
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
list_append(&enb->ue_list, ue);
|
|
|
|
|
|
|
|
return ue;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t mme_ctx_ue_remove(ue_ctx_t *ue)
|
|
|
|
{
|
|
|
|
d_assert(ue, return CORE_ERROR, "Null param");
|
|
|
|
d_assert(ue->enb, return CORE_ERROR, "Null param");
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
mme_ctx_erab_remove_all(ue);
|
2017-03-27 13:40:06 +00:00
|
|
|
mme_ctx_s11_remove_all(ue);
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 10:32:24 +00:00
|
|
|
if (FSM_STATE(&ue->emm_sm))
|
|
|
|
{
|
|
|
|
fsm_final((fsm_t*)&ue->emm_sm, 0);
|
|
|
|
fsm_clear((fsm_t*)&ue->emm_sm);
|
|
|
|
}
|
|
|
|
if (FSM_STATE(&ue->esm_sm))
|
|
|
|
{
|
|
|
|
fsm_final((fsm_t*)&ue->esm_sm, 0);
|
|
|
|
fsm_clear((fsm_t*)&ue->esm_sm);
|
|
|
|
}
|
|
|
|
|
2017-03-05 04:03:11 +00:00
|
|
|
list_remove(&ue->enb->ue_list, ue);
|
|
|
|
pool_free_node(&ue_pool, ue);
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t mme_ctx_ue_remove_all(enb_ctx_t *enb)
|
|
|
|
{
|
|
|
|
ue_ctx_t *ue = NULL, *next_ue = NULL;
|
|
|
|
|
|
|
|
ue = mme_ctx_ue_first(enb);
|
|
|
|
while (ue)
|
|
|
|
{
|
|
|
|
next_ue = mme_ctx_ue_next(ue);
|
|
|
|
|
|
|
|
mme_ctx_ue_remove(ue);
|
|
|
|
|
|
|
|
ue = next_ue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ue_ctx_t* mme_ctx_ue_find_by_enb_ue_s1ap_id(
|
|
|
|
enb_ctx_t *enb, c_uint32_t enb_ue_s1ap_id)
|
|
|
|
{
|
|
|
|
ue_ctx_t *ue = NULL;
|
|
|
|
|
|
|
|
ue = mme_ctx_ue_first(enb);
|
|
|
|
while (ue)
|
|
|
|
{
|
|
|
|
if (enb_ue_s1ap_id == ue->enb_ue_s1ap_id)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ue = mme_ctx_ue_next(ue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ue_ctx_t* mme_ctx_ue_first(enb_ctx_t *enb)
|
|
|
|
{
|
|
|
|
return list_first(&enb->ue_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
ue_ctx_t* mme_ctx_ue_next(ue_ctx_t *ue)
|
|
|
|
{
|
|
|
|
return list_next(ue);
|
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t* mme_ctx_erab_add(ue_ctx_t *ue)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t *erab = NULL;
|
2017-03-05 04:03:11 +00:00
|
|
|
|
|
|
|
d_assert(ue, return NULL, "Null param");
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
pool_alloc_node(&erab_pool, &erab);
|
|
|
|
d_assert(erab, return NULL, "Null param");
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
memset(erab, 0, sizeof(erab_ctx_t));
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab->ue = ue;
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
list_append(&ue->erab_list, erab);
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
return erab;
|
2017-03-05 04:03:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
status_t mme_ctx_erab_remove(erab_ctx_t *erab)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
d_assert(erab, return CORE_ERROR, "Null param");
|
|
|
|
d_assert(erab->ue, return CORE_ERROR, "Null param");
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
list_remove(&erab->ue->erab_list, erab);
|
|
|
|
pool_free_node(&erab_pool, erab);
|
2017-03-05 04:03:11 +00:00
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
status_t mme_ctx_erab_remove_all(ue_ctx_t *ue)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t *erab = NULL, *next_erab = NULL;
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab = mme_ctx_erab_first(ue);
|
|
|
|
while (erab)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
next_erab = mme_ctx_erab_next(erab);
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
mme_ctx_erab_remove(erab);
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab = next_erab;
|
2017-03-05 04:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t* mme_ctx_erab_find_by_erab_id(ue_ctx_t *ue, c_uint32_t erab_id)
|
|
|
|
{
|
|
|
|
erab_ctx_t *erab = NULL;
|
|
|
|
|
|
|
|
erab = mme_ctx_erab_first(ue);
|
|
|
|
while (erab)
|
|
|
|
{
|
|
|
|
if (erab_id == erab->erab_id)
|
|
|
|
break;
|
|
|
|
|
|
|
|
erab = mme_ctx_erab_next(erab);
|
|
|
|
}
|
|
|
|
|
|
|
|
return erab;
|
|
|
|
}
|
|
|
|
|
|
|
|
erab_ctx_t* mme_ctx_erab_find_by_teid(ue_ctx_t *ue, c_uint32_t teid)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t *erab = NULL;
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab = mme_ctx_erab_first(ue);
|
|
|
|
while (erab)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
if (teid == erab->teid)
|
2017-03-05 04:03:11 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab = mme_ctx_erab_next(erab);
|
2017-03-05 04:03:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
return erab;
|
2017-03-05 04:03:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t* mme_ctx_erab_first(ue_ctx_t *ue)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
return list_first(&ue->erab_list);
|
2017-03-05 04:03:11 +00:00
|
|
|
}
|
|
|
|
|
2017-03-27 12:28:07 +00:00
|
|
|
erab_ctx_t* mme_ctx_erab_next(erab_ctx_t *erab)
|
2017-03-05 04:03:11 +00:00
|
|
|
{
|
2017-03-27 12:28:07 +00:00
|
|
|
return list_next(erab);
|
2017-03-05 04:03:11 +00:00
|
|
|
}
|
2017-03-27 13:40:06 +00:00
|
|
|
|
|
|
|
s11_ctx_t* mme_ctx_s11_add(ue_ctx_t *ue)
|
|
|
|
{
|
|
|
|
s11_ctx_t *s11 = NULL;
|
|
|
|
|
|
|
|
d_assert(ue, return NULL, "Null param");
|
|
|
|
|
|
|
|
pool_alloc_node(&s11_pool, &s11);
|
|
|
|
d_assert(s11, return NULL, "Null param");
|
|
|
|
|
|
|
|
memset(s11, 0, sizeof(s11_ctx_t));
|
|
|
|
|
|
|
|
s11->ue = ue;
|
|
|
|
|
|
|
|
list_append(&ue->s11_list, s11);
|
|
|
|
|
|
|
|
return s11;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t mme_ctx_s11_remove(s11_ctx_t *s11)
|
|
|
|
{
|
|
|
|
d_assert(s11, return CORE_ERROR, "Null param");
|
|
|
|
d_assert(s11->ue, return CORE_ERROR, "Null param");
|
|
|
|
|
|
|
|
if (FSM_STATE(&s11->s11_sm))
|
|
|
|
{
|
|
|
|
fsm_final((fsm_t*)&s11->s11_sm, 0);
|
|
|
|
fsm_clear((fsm_t*)&s11->s11_sm);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_remove(&s11->ue->s11_list, s11);
|
|
|
|
pool_free_node(&s11_pool, s11);
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t mme_ctx_s11_remove_all(ue_ctx_t *ue)
|
|
|
|
{
|
|
|
|
s11_ctx_t *s11 = NULL, *next_s11 = NULL;
|
|
|
|
|
|
|
|
s11 = mme_ctx_s11_first(ue);
|
|
|
|
while (s11)
|
|
|
|
{
|
|
|
|
next_s11 = mme_ctx_s11_next(s11);
|
|
|
|
|
|
|
|
mme_ctx_s11_remove(s11);
|
|
|
|
|
|
|
|
s11 = next_s11;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
s11_ctx_t* mme_ctx_s11_find_by_teid(ue_ctx_t *ue, c_uint32_t teid)
|
|
|
|
{
|
|
|
|
s11_ctx_t *s11 = NULL;
|
|
|
|
|
|
|
|
s11 = mme_ctx_s11_first(ue);
|
|
|
|
while (s11)
|
|
|
|
{
|
|
|
|
if (teid == s11->teid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
s11 = mme_ctx_s11_next(s11);
|
|
|
|
}
|
|
|
|
|
|
|
|
return s11;
|
|
|
|
}
|
|
|
|
|
|
|
|
s11_ctx_t* mme_ctx_s11_first(ue_ctx_t *ue)
|
|
|
|
{
|
|
|
|
return list_first(&ue->s11_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
s11_ctx_t* mme_ctx_s11_next(s11_ctx_t *s11)
|
|
|
|
{
|
|
|
|
return list_next(s11);
|
|
|
|
}
|