update it

This commit is contained in:
Sukchan Lee 2017-04-06 20:44:52 +09:00
parent 4720ecb8b7
commit 677ffa480f
12 changed files with 139 additions and 136 deletions

View File

@ -26,8 +26,13 @@ status_t mutex_create(mutex_id *id, unsigned int flags)
status_t rv;
pool_alloc_node(&mutex_pool, &new_mutex);
d_assert(new_mutex, return CORE_ENOMEM, "mutex_pool(%d) is not enough\n",
MAX_NUM_OF_MUTEX);
d_assert(new_mutex, return CORE_ENOMEM,
"mutex_pool(%d) is not enough"
"(new_mutex=%p, mut:%p, avail:%d,size:%d,head:%d,tail:%d \n",
MAX_NUM_OF_MUTEX,
new_mutex, mutex_pool.mut,
mutex_pool.avail, mutex_pool.size,
mutex_pool.head, mutex_pool.tail);
if (flags & MUTEX_NESTED)
{

View File

@ -1,4 +1,4 @@
#define TRACE_MODULE _hss_ctx
#define TRACE_MODULE _hss_context
#include "core_debug.h"
#include "core_pool.h"
@ -10,25 +10,25 @@
#define OPc "E8ED289DEBA952E4283B54E88E6183CA"
#define AMF "8000"
static hss_ctx_t self;
static hss_context_t self;
pool_declare(user_pool, user_ctx_t, MAX_NUM_OF_UE);
pool_declare(hss_ue_pool, hss_ue_t, MAX_NUM_OF_UE);
static list_t g_user_list;
hss_ctx_t* hss_self()
hss_context_t* hss_self()
{
return &self;
}
status_t hss_ctx_init(void)
status_t hss_context_init(void)
{
char buf[HSS_KEY_LEN];
user_ctx_t *user;
hss_ue_t *user;
pool_init(&user_pool, MAX_NUM_OF_UE);
pool_init(&hss_ue_pool, MAX_NUM_OF_UE);
memset(&self, 0, sizeof(hss_ctx_t));
memset(&self, 0, sizeof(hss_context_t));
memcpy(self.op, CORE_HEX(OP, strlen(OP), buf), HSS_KEY_LEN);
memcpy(self.amf, CORE_HEX(AMF, strlen(AMF), buf), HSS_AMF_LEN);
@ -40,7 +40,7 @@ status_t hss_ctx_init(void)
#define UE3_IMSI "001010123456819"
#define UE3_RAND "20080c3818183b52 2614162c07601d0d"
user = hss_ctx_user_add();
user = hss_ue_add();
d_assert(user, return -1, "UE context add failed");
strcpy((char*)user->imsi, UE1_IMSI);
@ -49,7 +49,7 @@ status_t hss_ctx_init(void)
core_generate_random_bytes(user->rand, RAND_LEN);
user->sqn = 64;
user = hss_ctx_user_add();
user = hss_ue_add();
d_assert(user, return -1, "UE context add failed");
strcpy((char*)user->imsi, UE2_IMSI);
@ -58,7 +58,7 @@ status_t hss_ctx_init(void)
core_generate_random_bytes(user->rand, RAND_LEN);
user->sqn = 64;
user = hss_ctx_user_add();
user = hss_ue_add();
d_assert(user, return -1, "UE context add failed");
strcpy((char*)user->imsi, UE3_IMSI);
@ -71,25 +71,25 @@ status_t hss_ctx_init(void)
return CORE_OK;
}
void hss_ctx_final(void)
void hss_context_final(void)
{
hss_ctx_user_remove_all();
hss_ue_remove_all();
pool_final(&user_pool);
pool_final(&hss_ue_pool);
return;
}
user_ctx_t* hss_ctx_user_add()
hss_ue_t* hss_ue_add()
{
user_ctx_t *user = NULL;
hss_ue_t *user = NULL;
/* Allocate new eNB context */
pool_alloc_node(&user_pool, &user);
pool_alloc_node(&hss_ue_pool, &user);
d_assert(user, return NULL, "HSS-UE context allocation failed");
/* Initialize eNB context */
memset(user, 0, sizeof(user_ctx_t));
memset(user, 0, sizeof(hss_ue_t));
/* Add new eNB context to list */
list_append(&g_user_list, user);
@ -100,26 +100,26 @@ user_ctx_t* hss_ctx_user_add()
return user;
}
status_t hss_ctx_user_remove(user_ctx_t *user)
status_t hss_ue_remove(hss_ue_t *user)
{
d_assert(user, return CORE_ERROR, "Null param");
list_remove(&g_user_list, user);
pool_free_node(&user_pool, user);
pool_free_node(&hss_ue_pool, user);
return CORE_OK;
}
status_t hss_ctx_user_remove_all()
status_t hss_ue_remove_all()
{
user_ctx_t *user = NULL, *next_user = NULL;
hss_ue_t *user = NULL, *next_user = NULL;
user = list_first(&g_user_list);
while (user)
{
next_user = list_next(user);
hss_ctx_user_remove(user);
hss_ue_remove(user);
user = next_user;
}
@ -127,9 +127,9 @@ status_t hss_ctx_user_remove_all()
return CORE_OK;
}
user_ctx_t* hss_ctx_user_find_by_imsi(c_uint8_t *imsi, c_uint8_t imsi_len)
hss_ue_t* hss_ue_find_by_imsi(c_uint8_t *imsi, c_uint8_t imsi_len)
{
user_ctx_t *user = NULL;
hss_ue_t *user = NULL;
user = list_first(&g_user_list);
while (user)
@ -143,12 +143,12 @@ user_ctx_t* hss_ctx_user_find_by_imsi(c_uint8_t *imsi, c_uint8_t imsi_len)
return user;
}
user_ctx_t* hss_ctx_user_first()
hss_ue_t* hss_ue_first()
{
return list_first(&g_user_list);
}
user_ctx_t* hss_ctx_user_next(user_ctx_t *user)
hss_ue_t* hss_ue_next(hss_ue_t *user)
{
return list_next(user);
}

View File

@ -1,5 +1,5 @@
#ifndef __HSS_CTX_H__
#define __HSS_CTX_H__
#ifndef __HSS_CONTEXT_H__
#define __HSS_CONTEXT_H__
#include "core_list.h"
#include "core_errno.h"
@ -12,7 +12,7 @@ extern "C" {
#define HSS_KEY_LEN 16
#define HSS_AMF_LEN 2
typedef struct _user_ctx_t {
typedef struct _hss_ue_t {
lnode_t node; /**< A node of list_t */
c_uint8_t imsi[MAX_IMSI_LEN+1];
@ -24,29 +24,27 @@ typedef struct _user_ctx_t {
c_uint8_t opc[HSS_KEY_LEN];
c_uint8_t op[HSS_KEY_LEN];
c_uint8_t amf[HSS_AMF_LEN];
} user_ctx_t;
} hss_ue_t;
typedef struct _hss_ctx_t {
typedef struct _hss_context_t {
c_uint8_t op[HSS_KEY_LEN];
c_uint8_t amf[HSS_AMF_LEN];
} hss_ctx_t;
} hss_context_t;
CORE_DECLARE(hss_ctx_t*) hss_self(void);
#define self() hss_self()
CORE_DECLARE(status_t) hss_context_init(void);
CORE_DECLARE(void) hss_context_final(void);
CORE_DECLARE(hss_context_t*) hss_self(void);
CORE_DECLARE(status_t) hss_ctx_init(void);
CORE_DECLARE(void) hss_ctx_final(void);
CORE_DECLARE(user_ctx_t*) hss_ctx_user_add(void);
CORE_DECLARE(status_t) hss_ctx_user_remove(user_ctx_t *user);
CORE_DECLARE(status_t) hss_ctx_user_remove_all(void);
CORE_DECLARE(user_ctx_t*) hss_ctx_user_find_by_imsi(
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_all(void);
CORE_DECLARE(hss_ue_t*) hss_ue_find_by_imsi(
c_uint8_t *imsi, c_uint8_t imsi_len);
CORE_DECLARE(user_ctx_t*) hss_ctx_user_first(void);
CORE_DECLARE(user_ctx_t*) hss_ctx_user_next(user_ctx_t *user);
CORE_DECLARE(hss_ue_t*) hss_ue_first(void);
CORE_DECLARE(hss_ue_t*) hss_ue_next(hss_ue_t *user);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __HSS_CTX_H__ */
#endif /* __HSS_CONTEXT_H__ */

View File

@ -35,7 +35,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
struct avp_hdr *hdr;
union avp_value val;
user_ctx_t *user = NULL;
hss_ue_t *ue = NULL;
c_uint8_t sqn[HSS_SQN_LEN];
c_uint8_t autn[AUTN_LEN];
c_uint8_t ik[HSS_KEY_LEN];
@ -56,9 +56,9 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
user = hss_ctx_user_find_by_imsi(
ue = hss_ue_find_by_imsi(
hdr->avp_value->os.data, hdr->avp_value->os.len);
if (!user)
if (!ue)
{
char imsi[MAX_IMSI_LEN];
strncpy(imsi, (char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
@ -70,13 +70,13 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
avp, goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
milenage_opc(user->k, user->op, user->opc);
milenage_generate(user->opc, user->amf, user->k,
core_uint64_to_buffer(user->sqn, HSS_SQN_LEN, sqn), user->rand,
milenage_opc(ue->k, ue->op, ue->opc);
milenage_generate(ue->opc, ue->amf, ue->k,
core_uint64_to_buffer(ue->sqn, HSS_SQN_LEN, sqn), ue->rand,
autn, ik, ck, ak, xres, &xres_len);
hss_kdf_kasme(ck, ik, hdr->avp_value->os.data, sqn, ak, kasme);
user->sqn = (user->sqn + 32) & 0x7ffffffffff;
ue->sqn = (ue->sqn + 32) & 0x7ffffffffff;
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
d_assert(fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) == 0,
@ -93,7 +93,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
d_assert(fd_msg_avp_new(s6a_e_utran_vector, 0, &avpch1) == 0, goto out,);
d_assert(fd_msg_avp_new(s6a_rand, 0, &avpch2) == 0, goto out,);
val.os.data = user->rand;
val.os.data = ue->rand;
val.os.len = HSS_KEY_LEN;
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) == 0,
@ -149,7 +149,7 @@ status_t hss_initialize(void)
ret = s6a_init(MODE_HSS);
if (ret != 0) return CORE_ERROR;
rv = hss_ctx_init();
rv = hss_context_init();
if (rv != CORE_OK) return rv;
memset(&data, 0, sizeof(data));
@ -176,7 +176,7 @@ void hss_terminate(void)
(void) fd_disp_unregister(&hdl_air, NULL);
}
hss_ctx_final();
hss_context_final();
s6a_final();
return;

View File

@ -1,4 +1,4 @@
#define TRACE_MODULE _pgw_ctx
#define TRACE_MODULE _pgw_context
#include "core_debug.h"
#include "core_pool.h"
@ -8,16 +8,16 @@
#include "pgw_context.h"
static pgw_ctx_t self;
static pgw_context_t self;
static int ctx_initialized = 0;
status_t pgw_ctx_init()
status_t pgw_context_init()
{
d_assert(ctx_initialized == 0, return CORE_ERROR,
"MME context already has been initialized");
memset(&self, 0, sizeof(pgw_ctx_t));
memset(&self, 0, sizeof(pgw_context_t));
self.s5c_addr = inet_addr("127.0.0.1");
self.s5c_port = GTPV2_C_UDP_PORT + 3;
@ -36,7 +36,7 @@ status_t pgw_ctx_init()
return CORE_OK;
}
status_t pgw_ctx_final()
status_t pgw_context_final()
{
d_assert(ctx_initialized == 1, return CORE_ERROR,
"HyperCell context already has been finalized");
@ -46,7 +46,7 @@ status_t pgw_ctx_final()
return CORE_OK;
}
pgw_ctx_t* pgw_self()
pgw_context_t* pgw_self()
{
return &self;
}

View File

@ -1,5 +1,5 @@
#ifndef __PGW_CTX_H__
#define __PGW_CTX_H__
#ifndef __PGW_CONTEXT_H__
#define __PGW_CONTEXT_H__
#include "core_list.h"
#include "core_errno.h"
@ -13,7 +13,7 @@
extern "C" {
#endif /* __cplusplus */
typedef struct _pgw_ctx_t {
typedef struct _pgw_context_t {
c_uint32_t s5c_addr; /* PGW S5-C local address */
c_uint32_t s5c_port; /* PGW S5-C local port */
net_sock_t* s5c_sock; /* PGW S5-C local listen socket */
@ -27,15 +27,15 @@ typedef struct _pgw_ctx_t {
msgq_id queue_id; /* Queue for processing PGW control plane */
tm_service_t tm_service; /* Timer Service */
gtp_xact_ctx_t gtp_xact_ctx; /* GTP Transaction Context */
} pgw_ctx_t;
} pgw_context_t;
CORE_DECLARE(status_t) pgw_ctx_init(void);
CORE_DECLARE(status_t) pgw_ctx_final(void);
CORE_DECLARE(status_t) pgw_context_init(void);
CORE_DECLARE(status_t) pgw_context_final(void);
CORE_DECLARE(pgw_ctx_t*) pgw_self(void);
CORE_DECLARE(pgw_context_t*) pgw_self(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PGW_CTX_H__ */
#endif /* __PGW_CONTEXT_H__ */

View File

@ -13,7 +13,7 @@ status_t pgw_initialize()
{
status_t rv;
rv = pgw_ctx_init();
rv = pgw_context_init();
if (rv != CORE_OK) return rv;
rv = thread_create(&pgw_sm_thread, NULL, pgw_sm_main, NULL);
@ -26,7 +26,7 @@ void pgw_terminate(void)
{
thread_delete(pgw_sm_thread);
pgw_ctx_final();
pgw_context_final();
}
void *THREAD_FUNC pgw_sm_main(thread_id id, void *data)

View File

@ -1,4 +1,4 @@
#define TRACE_MODULE _sgw_ctx
#define TRACE_MODULE _sgw_context
#include "core_debug.h"
#include "core_pool.h"
@ -9,7 +9,7 @@
#include "sgw_context.h"
static sgw_ctx_t self;
static sgw_context_t self;
pool_declare(sgw_gtpc_pool, sgw_gtpc_t, MAX_NUM_OF_UE);
static hash_t *gtpc_hash;
@ -17,14 +17,14 @@ static hash_t *gtpc_hash;
((__id) = ((__id) == 0xffffffff ? 1 : ((__id) + 1)))
static c_uint32_t g_gtpc_tunnel_id = 0;
static int ctx_initialized = 0;
static int context_initialized = 0;
status_t sgw_ctx_init()
status_t sgw_context_init()
{
d_assert(ctx_initialized == 0, return CORE_ERROR,
d_assert(context_initialized == 0, return CORE_ERROR,
"MME context already has been initialized");
memset(&self, 0, sizeof(sgw_ctx_t));
memset(&self, 0, sizeof(sgw_context_t));
self.s11_addr = inet_addr("127.0.0.1");
self.s11_port = GTPV2_C_UDP_PORT + 1;
@ -49,14 +49,14 @@ status_t sgw_ctx_init()
gtpc_hash = hash_make();
ctx_initialized = 1;
context_initialized = 1;
return CORE_OK;
}
status_t sgw_ctx_final()
status_t sgw_context_final()
{
d_assert(ctx_initialized == 1, return CORE_ERROR,
d_assert(context_initialized == 1, return CORE_ERROR,
"HyperCell context already has been finalized");
hash_destroy(gtpc_hash);
@ -66,17 +66,17 @@ status_t sgw_ctx_final()
pool_size(&sgw_gtpc_pool));
pool_final(&sgw_gtpc_pool);
ctx_initialized = 0;
context_initialized = 0;
return CORE_OK;
}
sgw_ctx_t* sgw_self()
sgw_context_t* sgw_self()
{
return &self;
}
sgw_gtpc_t *sgw_ctx_gtpc_add()
sgw_gtpc_t *sgw_gtpc_add()
{
sgw_gtpc_t *gtpc = NULL;
@ -91,7 +91,7 @@ sgw_gtpc_t *sgw_ctx_gtpc_add()
return gtpc;
}
status_t sgw_ctx_gtpc_remove(sgw_gtpc_t *gtpc)
status_t sgw_gtpc_remove(sgw_gtpc_t *gtpc)
{
d_assert(gtpc, return CORE_ERROR, "Null param");
hash_set(gtpc_hash, &gtpc->teid, sizeof(gtpc->teid), NULL);
@ -101,42 +101,42 @@ status_t sgw_ctx_gtpc_remove(sgw_gtpc_t *gtpc)
return CORE_OK;
}
status_t sgw_ctx_gtpc_remove_all()
status_t sgw_gtpc_remove_all()
{
hash_index_t *hi = NULL;
sgw_gtpc_t *gtpc = NULL;
for (hi = sgw_ctx_gtpc_first(); hi; hi = sgw_ctx_gtpc_next(hi))
for (hi = sgw_gtpc_first(); hi; hi = sgw_gtpc_next(hi))
{
gtpc = sgw_ctx_gtpc_this(hi);
sgw_ctx_gtpc_remove(gtpc);
gtpc = sgw_gtpc_this(hi);
sgw_gtpc_remove(gtpc);
}
return CORE_OK;
}
sgw_gtpc_t *sgw_ctx_gtpc_find(c_uint32_t teid)
sgw_gtpc_t *sgw_gtpc_find(c_uint32_t teid)
{
return hash_get(gtpc_hash, &teid, sizeof(teid));
}
hash_index_t *sgw_ctx_gtpc_first()
hash_index_t *sgw_gtpc_first()
{
return hash_first(gtpc_hash);
}
hash_index_t *sgw_ctx_gtpc_next(hash_index_t *hi)
hash_index_t *sgw_gtpc_next(hash_index_t *hi)
{
return hash_next(hi);
}
sgw_gtpc_t *sgw_ctx_gtpc_this(hash_index_t *hi)
sgw_gtpc_t *sgw_gtpc_this(hash_index_t *hi)
{
d_assert(hi, return NULL, "Null param");
return hash_this_val(hi);
}
unsigned int sgw_ctx_gtpc_count()
unsigned int sgw_gtpc_count()
{
return hash_count(gtpc_hash);
}

View File

@ -1,5 +1,5 @@
#ifndef __SGW_CTX_H__
#define __SGW_CTX_H__
#ifndef __SGW_CONTEXT_H__
#define __SGW_CONTEXT_H__
#include "core_list.h"
#include "core_errno.h"
@ -16,7 +16,7 @@
extern "C" {
#endif /* __cplusplus */
typedef struct _sgw_ctx_t {
typedef struct _sgw_context_t {
c_uint32_t s11_addr; /* SGW S11 local address */
c_uint32_t s11_port; /* SGW S11 local port */
net_sock_t* s11_sock; /* SGW S11 local listen socket */
@ -35,7 +35,7 @@ typedef struct _sgw_ctx_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 */
} sgw_ctx_t;
} sgw_context_t;
typedef struct _sgw_gtpc_t {
c_uint32_t teid; /* SGW-S11-F-TEID, SGW-S5C-F-TEID */
@ -43,22 +43,22 @@ typedef struct _sgw_gtpc_t {
gtp_f_teid_t pgw; /* MME-S11-F-TEID */
} sgw_gtpc_t;
CORE_DECLARE(status_t) sgw_ctx_init(void);
CORE_DECLARE(status_t) sgw_ctx_final(void);
CORE_DECLARE(status_t) sgw_context_init(void);
CORE_DECLARE(status_t) sgw_context_final(void);
CORE_DECLARE(sgw_ctx_t*) sgw_self(void);
CORE_DECLARE(sgw_context_t*) sgw_self(void);
CORE_DECLARE(sgw_gtpc_t*) sgw_ctx_gtpc_add();
CORE_DECLARE(status_t ) sgw_ctx_gtpc_remove(sgw_gtpc_t *gtpc);
CORE_DECLARE(status_t ) sgw_ctx_gtpc_remove_all();
CORE_DECLARE(sgw_gtpc_t*) sgw_ctx_gtpc_find(c_uint32_t teid);
CORE_DECLARE(hash_index_t*) sgw_ctx_gtpc_first();
CORE_DECLARE(hash_index_t*) sgw_ctx_gtpc_next(hash_index_t *hi);
CORE_DECLARE(sgw_gtpc_t*) sgw_ctx_gtpc_this(hash_index_t *hi);
CORE_DECLARE(unsigned int) sgw_ctx_gtpc_count();
CORE_DECLARE(sgw_gtpc_t*) sgw_gtpc_add();
CORE_DECLARE(status_t ) sgw_gtpc_remove(sgw_gtpc_t *gtpc);
CORE_DECLARE(status_t ) sgw_gtpc_remove_all();
CORE_DECLARE(sgw_gtpc_t*) sgw_gtpc_find(c_uint32_t teid);
CORE_DECLARE(hash_index_t*) sgw_gtpc_first();
CORE_DECLARE(hash_index_t*) sgw_gtpc_next(hash_index_t *hi);
CORE_DECLARE(sgw_gtpc_t*) sgw_gtpc_this(hash_index_t *hi);
CORE_DECLARE(unsigned int) sgw_gtpc_count();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SGW_CTX_H__ */
#endif /* __SGW_CONTEXT_H__ */

View File

@ -26,7 +26,7 @@ void sgw_handle_create_session_request(
return;
}
gtpc = sgw_ctx_gtpc_add();
gtpc = sgw_gtpc_add();
d_assert(gtpc, return, "gtpc_add failed");
memcpy(&gtpc->mme, req->sender_f_teid_for_control_plane.data,

View File

@ -13,7 +13,7 @@ status_t sgw_initialize()
{
status_t rv;
rv = sgw_ctx_init();
rv = sgw_context_init();
if (rv != CORE_OK) return rv;
rv = thread_create(&sgw_sm_thread, NULL, sgw_sm_main, NULL);
@ -26,7 +26,7 @@ void sgw_terminate(void)
{
thread_delete(sgw_sm_thread);
sgw_ctx_final();
sgw_context_final();
}
void *THREAD_FUNC sgw_sm_main(thread_id id, void *data)

View File

@ -296,43 +296,43 @@ static void gtp_message_test2(abts_case *tc, void *data)
hash_index_t *hi = NULL;
int i = 0;
gtpc = sgw_ctx_gtpc_add();
ABTS_INT_EQUAL(tc, 1, sgw_ctx_gtpc_count());
sgw_ctx_gtpc_remove(gtpc);
ABTS_INT_EQUAL(tc, 0, sgw_ctx_gtpc_count());
gtpc = sgw_gtpc_add();
ABTS_INT_EQUAL(tc, 1, sgw_gtpc_count());
sgw_gtpc_remove(gtpc);
ABTS_INT_EQUAL(tc, 0, sgw_gtpc_count());
sgw_ctx_gtpc_add();
sgw_ctx_gtpc_add();
sgw_ctx_gtpc_add();
sgw_ctx_gtpc_add();
sgw_ctx_gtpc_add();
ABTS_INT_EQUAL(tc, 5, sgw_ctx_gtpc_count());
sgw_gtpc_add();
sgw_gtpc_add();
sgw_gtpc_add();
sgw_gtpc_add();
sgw_gtpc_add();
ABTS_INT_EQUAL(tc, 5, sgw_gtpc_count());
sgw_ctx_gtpc_remove_all();
ABTS_INT_EQUAL(tc, 0, sgw_ctx_gtpc_count());
sgw_gtpc_remove_all();
ABTS_INT_EQUAL(tc, 0, sgw_gtpc_count());
for (i = 0; i < 100; i++)
{
gtpc = sgw_ctx_gtpc_add();
gtpc = sgw_gtpc_add();
gtpc->mme.teid = i;
gtpc->pgw.teid = 100-i;
}
ABTS_INT_EQUAL(tc, 100, sgw_ctx_gtpc_count());
ABTS_INT_EQUAL(tc, 100, sgw_gtpc_count());
gtpc = sgw_ctx_gtpc_find(10);
gtpc = sgw_gtpc_find(10);
ABTS_INT_EQUAL(tc, 3, gtpc->mme.teid);
ABTS_INT_EQUAL(tc, 97, gtpc->pgw.teid);
sgw_ctx_gtpc_remove(gtpc);
ABTS_INT_EQUAL(tc, 99, sgw_ctx_gtpc_count());
sgw_gtpc_remove(gtpc);
ABTS_INT_EQUAL(tc, 99, sgw_gtpc_count());
gtpc = sgw_ctx_gtpc_find(50);
gtpc = sgw_gtpc_find(50);
ABTS_INT_EQUAL(tc, 43, gtpc->mme.teid);
ABTS_INT_EQUAL(tc, 57, gtpc->pgw.teid);
sgw_ctx_gtpc_remove(gtpc);
ABTS_INT_EQUAL(tc, 98, sgw_ctx_gtpc_count());
sgw_gtpc_remove(gtpc);
ABTS_INT_EQUAL(tc, 98, sgw_gtpc_count());
sgw_ctx_gtpc_remove_all();
ABTS_INT_EQUAL(tc, 0, sgw_ctx_gtpc_count());
sgw_gtpc_remove_all();
ABTS_INT_EQUAL(tc, 0, sgw_gtpc_count());
}
abts_suite *test_gtp_message(abts_suite *suite)