update it
This commit is contained in:
parent
677ffa480f
commit
9ff9bd97a4
|
@ -14,8 +14,6 @@ static hss_context_t self;
|
|||
|
||||
pool_declare(hss_ue_pool, hss_ue_t, MAX_NUM_OF_UE);
|
||||
|
||||
static list_t g_user_list;
|
||||
|
||||
hss_context_t* hss_self()
|
||||
{
|
||||
return &self;
|
||||
|
@ -24,7 +22,7 @@ hss_context_t* hss_self()
|
|||
status_t hss_context_init(void)
|
||||
{
|
||||
char buf[HSS_KEY_LEN];
|
||||
hss_ue_t *user;
|
||||
hss_ue_t *ue;
|
||||
|
||||
pool_init(&hss_ue_pool, MAX_NUM_OF_UE);
|
||||
|
||||
|
@ -40,33 +38,33 @@ status_t hss_context_init(void)
|
|||
#define UE3_IMSI "001010123456819"
|
||||
#define UE3_RAND "20080c3818183b52 2614162c07601d0d"
|
||||
|
||||
user = hss_ue_add();
|
||||
d_assert(user, return -1, "UE context add failed");
|
||||
ue = hss_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)user->imsi, UE1_IMSI);
|
||||
user->imsi_len = strlen(UE1_IMSI);
|
||||
memcpy(user->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
core_generate_random_bytes(user->rand, RAND_LEN);
|
||||
user->sqn = 64;
|
||||
strcpy((char*)ue->imsi, UE1_IMSI);
|
||||
ue->imsi_len = strlen(UE1_IMSI);
|
||||
memcpy(ue->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, RAND_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
user = hss_ue_add();
|
||||
d_assert(user, return -1, "UE context add failed");
|
||||
ue = hss_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)user->imsi, UE2_IMSI);
|
||||
user->imsi_len = strlen(UE2_IMSI);
|
||||
memcpy(user->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
core_generate_random_bytes(user->rand, RAND_LEN);
|
||||
user->sqn = 64;
|
||||
strcpy((char*)ue->imsi, UE2_IMSI);
|
||||
ue->imsi_len = strlen(UE2_IMSI);
|
||||
memcpy(ue->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, RAND_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
user = hss_ue_add();
|
||||
d_assert(user, return -1, "UE context add failed");
|
||||
ue = hss_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)user->imsi, UE3_IMSI);
|
||||
user->imsi_len = strlen(UE3_IMSI);
|
||||
memcpy(user->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
memcpy(user->rand, CORE_HEX(UE3_RAND, strlen(UE3_RAND), buf),
|
||||
strcpy((char*)ue->imsi, UE3_IMSI);
|
||||
ue->imsi_len = strlen(UE3_IMSI);
|
||||
memcpy(ue->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
memcpy(ue->rand, CORE_HEX(UE3_RAND, strlen(UE3_RAND), buf),
|
||||
RAND_LEN);
|
||||
user->sqn = 64;
|
||||
ue->sqn = 64;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
@ -82,46 +80,46 @@ void hss_context_final(void)
|
|||
|
||||
hss_ue_t* hss_ue_add()
|
||||
{
|
||||
hss_ue_t *user = NULL;
|
||||
hss_ue_t *ue = NULL;
|
||||
|
||||
/* Allocate new eNB context */
|
||||
pool_alloc_node(&hss_ue_pool, &user);
|
||||
d_assert(user, return NULL, "HSS-UE context allocation failed");
|
||||
pool_alloc_node(&hss_ue_pool, &ue);
|
||||
d_assert(ue, return NULL, "HSS-UE context allocation failed");
|
||||
|
||||
/* Initialize eNB context */
|
||||
memset(user, 0, sizeof(hss_ue_t));
|
||||
memset(ue, 0, sizeof(hss_ue_t));
|
||||
|
||||
/* Add new eNB context to list */
|
||||
list_append(&g_user_list, user);
|
||||
list_append(&self.ue_list, ue);
|
||||
|
||||
memcpy(user->op, self.op, HSS_KEY_LEN);
|
||||
memcpy(user->amf, self.amf, HSS_AMF_LEN);
|
||||
memcpy(ue->op, self.op, HSS_KEY_LEN);
|
||||
memcpy(ue->amf, self.amf, HSS_AMF_LEN);
|
||||
|
||||
return user;
|
||||
return ue;
|
||||
}
|
||||
|
||||
status_t hss_ue_remove(hss_ue_t *user)
|
||||
status_t hss_ue_remove(hss_ue_t *ue)
|
||||
{
|
||||
d_assert(user, return CORE_ERROR, "Null param");
|
||||
d_assert(ue, return CORE_ERROR, "Null param");
|
||||
|
||||
list_remove(&g_user_list, user);
|
||||
pool_free_node(&hss_ue_pool, user);
|
||||
list_remove(&self.ue_list, ue);
|
||||
pool_free_node(&hss_ue_pool, ue);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t hss_ue_remove_all()
|
||||
{
|
||||
hss_ue_t *user = NULL, *next_user = NULL;
|
||||
hss_ue_t *ue = NULL, *next_ue = NULL;
|
||||
|
||||
user = list_first(&g_user_list);
|
||||
while (user)
|
||||
ue = list_first(&self.ue_list);
|
||||
while (ue)
|
||||
{
|
||||
next_user = list_next(user);
|
||||
next_ue = list_next(ue);
|
||||
|
||||
hss_ue_remove(user);
|
||||
hss_ue_remove(ue);
|
||||
|
||||
user = next_user;
|
||||
ue = next_ue;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
|
@ -129,26 +127,26 @@ status_t hss_ue_remove_all()
|
|||
|
||||
hss_ue_t* hss_ue_find_by_imsi(c_uint8_t *imsi, c_uint8_t imsi_len)
|
||||
{
|
||||
hss_ue_t *user = NULL;
|
||||
hss_ue_t *ue = NULL;
|
||||
|
||||
user = list_first(&g_user_list);
|
||||
while (user)
|
||||
ue = list_first(&self.ue_list);
|
||||
while (ue)
|
||||
{
|
||||
if (memcmp(user->imsi, imsi, imsi_len) == 0)
|
||||
if (memcmp(ue->imsi, imsi, imsi_len) == 0)
|
||||
break;
|
||||
|
||||
user = list_next(user);
|
||||
ue = list_next(ue);
|
||||
}
|
||||
|
||||
return user;
|
||||
return ue;
|
||||
}
|
||||
|
||||
hss_ue_t* hss_ue_first()
|
||||
{
|
||||
return list_first(&g_user_list);
|
||||
return list_first(&self.ue_list);
|
||||
}
|
||||
|
||||
hss_ue_t* hss_ue_next(hss_ue_t *user)
|
||||
hss_ue_t* hss_ue_next(hss_ue_t *ue)
|
||||
{
|
||||
return list_next(user);
|
||||
return list_next(ue);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ typedef struct _hss_ue_t {
|
|||
typedef struct _hss_context_t {
|
||||
c_uint8_t op[HSS_KEY_LEN];
|
||||
c_uint8_t amf[HSS_AMF_LEN];
|
||||
|
||||
list_t ue_list;
|
||||
} hss_context_t;
|
||||
|
||||
CORE_DECLARE(status_t) hss_context_init(void);
|
||||
|
@ -36,12 +38,12 @@ CORE_DECLARE(void) hss_context_final(void);
|
|||
CORE_DECLARE(hss_context_t*) hss_self(void);
|
||||
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_add(void);
|
||||
CORE_DECLARE(status_t) hss_ue_remove(hss_ue_t *user);
|
||||
CORE_DECLARE(status_t) hss_ue_remove(hss_ue_t *ue);
|
||||
CORE_DECLARE(status_t) hss_ue_remove_all(void);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_find_by_imsi(
|
||||
c_uint8_t *imsi, c_uint8_t imsi_len);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_first(void);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_next(hss_ue_t *user);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_next(hss_ue_t *ue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@ pool_declare(mme_ue_pool, mme_ue_t, MAX_NUM_OF_UE);
|
|||
|
||||
static int context_initialized = 0;
|
||||
|
||||
static list_t mme_sgw_list;
|
||||
static list_t mme_enb_list;
|
||||
|
||||
status_t mme_context_init()
|
||||
{
|
||||
d_assert(context_initialized == 0, return CORE_ERROR,
|
||||
|
@ -36,8 +33,8 @@ status_t mme_context_init()
|
|||
pool_init(&mme_enb_pool, MAX_NUM_OF_ENB);
|
||||
pool_init(&mme_ue_pool, MAX_NUM_OF_UE);
|
||||
|
||||
list_init(&mme_sgw_list);
|
||||
list_init(&mme_enb_list);
|
||||
list_init(&self.sgw_list);
|
||||
list_init(&self.enb_list);
|
||||
|
||||
/* Initialize MME context */
|
||||
memset(&self, 0, sizeof(mme_context_t));
|
||||
|
@ -111,7 +108,7 @@ mme_sgw_t* mme_sgw_add()
|
|||
list_init(&sgw->gnode.local_list);
|
||||
list_init(&sgw->gnode.remote_list);
|
||||
|
||||
list_append(&mme_sgw_list, sgw);
|
||||
list_append(&self.sgw_list, sgw);
|
||||
|
||||
return sgw;
|
||||
}
|
||||
|
@ -120,7 +117,7 @@ status_t mme_sgw_remove(mme_sgw_t *sgw)
|
|||
{
|
||||
d_assert(sgw, return CORE_ERROR, "Null param");
|
||||
|
||||
list_remove(&mme_sgw_list, sgw);
|
||||
list_remove(&self.sgw_list, sgw);
|
||||
pool_free_node(&mme_sgw_pool, sgw);
|
||||
|
||||
return CORE_OK;
|
||||
|
@ -161,7 +158,7 @@ mme_sgw_t* mme_sgw_find_by_node(gtp_node_t *gnode)
|
|||
|
||||
mme_sgw_t* mme_sgw_first()
|
||||
{
|
||||
return list_first(&mme_sgw_list);
|
||||
return list_first(&self.sgw_list);
|
||||
}
|
||||
|
||||
mme_sgw_t* mme_sgw_next(mme_sgw_t *sgw)
|
||||
|
@ -180,7 +177,7 @@ mme_enb_t* mme_enb_add()
|
|||
|
||||
list_init(&enb->ue_list);
|
||||
|
||||
list_append(&mme_enb_list, enb);
|
||||
list_append(&self.enb_list, enb);
|
||||
|
||||
return enb;
|
||||
}
|
||||
|
@ -191,7 +188,7 @@ status_t mme_enb_remove(mme_enb_t *enb)
|
|||
|
||||
mme_ue_remove_all(enb);
|
||||
|
||||
list_remove(&mme_enb_list, enb);
|
||||
list_remove(&self.enb_list, enb);
|
||||
pool_free_node(&mme_enb_pool, enb);
|
||||
|
||||
return CORE_OK;
|
||||
|
@ -234,7 +231,7 @@ mme_enb_t* mme_enb_find_by_enb_id(c_uint32_t enb_id)
|
|||
{
|
||||
mme_enb_t *enb = NULL;
|
||||
|
||||
enb = list_first(&mme_enb_list);
|
||||
enb = list_first(&self.enb_list);
|
||||
while (enb)
|
||||
{
|
||||
if (enb_id == enb->enb_id)
|
||||
|
@ -248,7 +245,7 @@ mme_enb_t* mme_enb_find_by_enb_id(c_uint32_t enb_id)
|
|||
|
||||
mme_enb_t* mme_enb_first()
|
||||
{
|
||||
return list_first(&mme_enb_list);
|
||||
return list_first(&self.enb_list);
|
||||
}
|
||||
|
||||
mme_enb_t* mme_enb_next(mme_enb_t *enb)
|
||||
|
|
|
@ -66,6 +66,9 @@ typedef struct _mme_context_t {
|
|||
/* S1SetupResponse */
|
||||
srvd_gummei_t srvd_gummei;
|
||||
c_uint8_t relative_capacity;
|
||||
|
||||
list_t sgw_list;
|
||||
list_t enb_list;
|
||||
} mme_context_t;
|
||||
|
||||
typedef struct _mme_sgw_t {
|
||||
|
|
|
@ -12,10 +12,6 @@
|
|||
static sgw_context_t self;
|
||||
|
||||
pool_declare(sgw_gtpc_pool, sgw_gtpc_t, MAX_NUM_OF_UE);
|
||||
static hash_t *gtpc_hash;
|
||||
#define SGW_NEXT_TUNNEL_ID(__id) \
|
||||
((__id) = ((__id) == 0xffffffff ? 1 : ((__id) + 1)))
|
||||
static c_uint32_t g_gtpc_tunnel_id = 0;
|
||||
|
||||
static int context_initialized = 0;
|
||||
|
||||
|
@ -47,7 +43,7 @@ status_t sgw_context_init()
|
|||
|
||||
pool_init(&sgw_gtpc_pool, MAX_NUM_OF_UE);
|
||||
|
||||
gtpc_hash = hash_make();
|
||||
self.gtpc_hash = hash_make();
|
||||
|
||||
context_initialized = 1;
|
||||
|
||||
|
@ -59,7 +55,8 @@ status_t sgw_context_final()
|
|||
d_assert(context_initialized == 1, return CORE_ERROR,
|
||||
"HyperCell context already has been finalized");
|
||||
|
||||
hash_destroy(gtpc_hash);
|
||||
d_assert(self.gtpc_hash, , "Null param");
|
||||
hash_destroy(self.gtpc_hash);
|
||||
|
||||
d_print("%d not freed in sgw_gtpc_pool[%d] of SGW-Context\n",
|
||||
pool_size(&sgw_gtpc_pool) - pool_avail(&sgw_gtpc_pool),
|
||||
|
@ -80,21 +77,24 @@ sgw_gtpc_t *sgw_gtpc_add()
|
|||
{
|
||||
sgw_gtpc_t *gtpc = NULL;
|
||||
|
||||
d_assert(self.gtpc_hash, return NULL, "Null param");
|
||||
|
||||
pool_alloc_node(&sgw_gtpc_pool, >pc);
|
||||
d_assert(gtpc, return NULL, "Null param");
|
||||
|
||||
memset(gtpc, 0, sizeof(sgw_gtpc_t));
|
||||
|
||||
gtpc->teid = SGW_NEXT_TUNNEL_ID(g_gtpc_tunnel_id);
|
||||
hash_set(gtpc_hash, >pc->teid, sizeof(gtpc->teid), gtpc);
|
||||
gtpc->teid = NEXT_ID(self.gtpc_tunnel_id, 0xffffffff);
|
||||
hash_set(self.gtpc_hash, >pc->teid, sizeof(gtpc->teid), gtpc);
|
||||
|
||||
return gtpc;
|
||||
}
|
||||
|
||||
status_t sgw_gtpc_remove(sgw_gtpc_t *gtpc)
|
||||
{
|
||||
d_assert(self.gtpc_hash, return CORE_ERROR, "Null param");
|
||||
d_assert(gtpc, return CORE_ERROR, "Null param");
|
||||
hash_set(gtpc_hash, >pc->teid, sizeof(gtpc->teid), NULL);
|
||||
hash_set(self.gtpc_hash, >pc->teid, sizeof(gtpc->teid), NULL);
|
||||
|
||||
pool_free_node(&sgw_gtpc_pool, gtpc);
|
||||
|
||||
|
@ -117,12 +117,14 @@ status_t sgw_gtpc_remove_all()
|
|||
|
||||
sgw_gtpc_t *sgw_gtpc_find(c_uint32_t teid)
|
||||
{
|
||||
return hash_get(gtpc_hash, &teid, sizeof(teid));
|
||||
d_assert(self.gtpc_hash, return NULL, "Null param");
|
||||
return hash_get(self.gtpc_hash, &teid, sizeof(teid));
|
||||
}
|
||||
|
||||
hash_index_t *sgw_gtpc_first()
|
||||
{
|
||||
return hash_first(gtpc_hash);
|
||||
d_assert(self.gtpc_hash, return NULL, "Null param");
|
||||
return hash_first(self.gtpc_hash);
|
||||
}
|
||||
|
||||
hash_index_t *sgw_gtpc_next(hash_index_t *hi)
|
||||
|
@ -138,5 +140,6 @@ sgw_gtpc_t *sgw_gtpc_this(hash_index_t *hi)
|
|||
|
||||
unsigned int sgw_gtpc_count()
|
||||
{
|
||||
return hash_count(gtpc_hash);
|
||||
d_assert(self.gtpc_hash, return 0, "Null param");
|
||||
return hash_count(self.gtpc_hash);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ typedef struct _sgw_context_t {
|
|||
msgq_id queue_id; /* Queue for processing SGW control plane */
|
||||
tm_service_t tm_service; /* Timer Service */
|
||||
gtp_xact_ctx_t gtp_xact_ctx; /* GTP Transaction Context */
|
||||
|
||||
c_uint32_t gtpc_tunnel_id; /* GTPv2-C F-TEID generator */
|
||||
|
||||
hash_t *gtpc_hash; /* hash table for sgw_gtpc_t structure */
|
||||
} sgw_context_t;
|
||||
|
||||
typedef struct _sgw_gtpc_t {
|
||||
|
|
Loading…
Reference in New Issue