fix the bug for memory leak
This commit is contained in:
parent
c7521ad124
commit
199c9f8327
|
@ -1,4 +1,4 @@
|
|||
#define TRACE_MODULE _s1dec
|
||||
#define TRACE_MODULE _s1ap_recv
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define TRACE_MODULE _s1enc
|
||||
#define TRACE_MODULE _s1ap_send
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define TRACE_MODULE _s6a_fd
|
||||
#define TRACE_MODULE _s6a
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
|
22
main.c
22
main.c
|
@ -117,21 +117,19 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
#if 0
|
||||
extern int _mme_sm;
|
||||
extern int _enb_s1_sm;
|
||||
extern int _s1dec;
|
||||
extern int _s1enc;
|
||||
extern int _s6a_fd;
|
||||
#endif
|
||||
extern int _ue_emm_sm;
|
||||
|
||||
#if 0
|
||||
d_trace_level(&_mme_sm, 100);
|
||||
extern int _enb_s1_sm;
|
||||
d_trace_level(&_enb_s1_sm, 100);
|
||||
d_trace_level(&_s1dec, 100);
|
||||
d_trace_level(&_s1enc, 100);
|
||||
d_trace_level(&_s6a_fd, 100);
|
||||
#endif
|
||||
extern int _ue_emm_sm;
|
||||
d_trace_level(&_ue_emm_sm, 100);
|
||||
|
||||
extern int _s1ap_recv;
|
||||
d_trace_level(&_ue_emm_sm, 100);
|
||||
extern int _s1ap_send;
|
||||
d_trace_level(&_s1ap_recv, 100);
|
||||
extern int _s6a;
|
||||
d_trace_level(&_s1ap_send, 100);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cellwire_initialize(config_path, log_path) != CORE_OK)
|
||||
|
|
|
@ -24,6 +24,7 @@ hss_ctx_t* hss_self()
|
|||
status_t hss_ctx_init(void)
|
||||
{
|
||||
char buf[MAX_KEY_LEN];
|
||||
ue_ctx_t *ue;
|
||||
|
||||
pool_init(&ue_pool, SIZE_OF_UE_POOL);
|
||||
|
||||
|
@ -31,12 +32,48 @@ status_t hss_ctx_init(void)
|
|||
|
||||
memcpy(self.op, core_ascii_to_hex(OP, strlen(OP), buf), MAX_KEY_LEN);
|
||||
memcpy(self.amf, core_ascii_to_hex(AMF, strlen(AMF), buf), MAX_AMF_LEN);
|
||||
|
||||
|
||||
#define K "465B5CE8B199B49FAA5F0A2EE238A6BC"
|
||||
#define UE1_IMSI "001010123456800"
|
||||
#define UE2_IMSI "001010123456796"
|
||||
|
||||
#define UE3_IMSI "001010123456819"
|
||||
#define UE3_RAND "20080c3818183b52 2614162c07601d0d"
|
||||
|
||||
ue = hss_ctx_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi, UE1_IMSI);
|
||||
ue->imsi_len = strlen(UE1_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, MAX_KEY_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
ue = hss_ctx_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi, UE2_IMSI);
|
||||
ue->imsi_len = strlen(UE2_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, MAX_KEY_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
ue = hss_ctx_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi, UE3_IMSI);
|
||||
ue->imsi_len = strlen(UE3_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
memcpy(ue->rand, core_ascii_to_hex(UE3_RAND, strlen(UE3_RAND), buf), MAX_KEY_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void hss_ctx_final(void)
|
||||
{
|
||||
hss_ctx_ue_remove_all();
|
||||
|
||||
pool_final(&ue_pool);
|
||||
|
||||
return;
|
||||
|
|
|
@ -152,46 +152,6 @@ status_t hss_initialize(void)
|
|||
rv = hss_ctx_init();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
/* FIXME : this is a sample UE for testing */
|
||||
{
|
||||
ue_ctx_t *ue;
|
||||
char buf[MAX_KEY_LEN];
|
||||
|
||||
#define K "465B5CE8B199B49FAA5F0A2EE238A6BC"
|
||||
#define UE1_IMSI "001010123456800"
|
||||
#define UE2_IMSI "001010123456796"
|
||||
|
||||
#define UE3_IMSI "001010123456819"
|
||||
#define UE3_RAND "20080c3818183b52 2614162c07601d0d"
|
||||
|
||||
ue = hss_ctx_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi, UE1_IMSI);
|
||||
ue->imsi_len = strlen(UE1_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, MAX_KEY_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
ue = hss_ctx_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi, UE2_IMSI);
|
||||
ue->imsi_len = strlen(UE2_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, MAX_KEY_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
ue = hss_ctx_ue_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi, UE3_IMSI);
|
||||
ue->imsi_len = strlen(UE3_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
memcpy(ue->rand, core_ascii_to_hex(UE3_RAND, strlen(UE3_RAND), buf), MAX_KEY_LEN);
|
||||
ue->sqn = 64;
|
||||
}
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = s6a_appli;
|
||||
data.command = s6a_cmd_air;
|
||||
|
@ -216,11 +176,6 @@ void hss_terminate(void)
|
|||
(void) fd_disp_unregister(&hdl_air, NULL);
|
||||
}
|
||||
|
||||
/* FIXME : this is a sample UE for testing */
|
||||
{
|
||||
hss_ctx_ue_remove_all();
|
||||
}
|
||||
|
||||
hss_ctx_final();
|
||||
s6a_final();
|
||||
|
||||
|
|
|
@ -188,10 +188,10 @@ status_t s1ap_send(net_sock_t *s, pkbuf_t *pkbuf)
|
|||
|
||||
status_t s1ap_send_to_enb(enb_ctx_t *enb, pkbuf_t *pkbuf)
|
||||
{
|
||||
status_t rv;
|
||||
d_assert(enb, return CORE_ERROR, "Null param");
|
||||
d_assert(pkbuf, return CORE_ERROR, "Null param");
|
||||
d_assert(enb->s1ap_sock, return CORE_ERROR, "No S1 path with ENB");
|
||||
status_t rv = CORE_ERROR;
|
||||
d_assert(enb,,);
|
||||
d_assert(pkbuf,,);
|
||||
d_assert(enb->s1ap_sock,,);
|
||||
|
||||
rv = s1ap_send(enb->s1ap_sock, pkbuf);
|
||||
pkbuf_free(pkbuf);
|
||||
|
|
|
@ -82,7 +82,8 @@ void ue_emm_state_operational(ue_emm_sm_t *s, event_t *e)
|
|||
}
|
||||
case NAS_AUTHENTICATION_REQUEST:
|
||||
{
|
||||
ue_emm_send_to_ue(ue, recvbuf);
|
||||
pkbuf_t *pkbuf = pkbuf_copy(recvbuf);
|
||||
ue_emm_send_to_ue(ue, pkbuf);
|
||||
|
||||
d_assert(ue->imsi, return,);
|
||||
d_info("[NAS] Authentication request : UE[%s] <-- EMM",
|
||||
|
@ -288,11 +289,12 @@ static void ue_emm_send_to_ue(ue_ctx_t *ue, pkbuf_t *pkbuf)
|
|||
|
||||
encoded = s1ap_encode_pdu(&sendbuf, &message);
|
||||
s1ap_free_pdu(&message);
|
||||
d_assert(encoded >= 0, , "encode failed");
|
||||
|
||||
d_assert(s1ap_send_to_enb(ue->enb, sendbuf) == CORE_OK, , "send error");
|
||||
d_assert(sendbuf && encoded >= 0,,);
|
||||
d_assert(s1ap_send_to_enb(ue->enb, sendbuf) == CORE_OK,,);
|
||||
pkbuf_free(pkbuf);
|
||||
|
||||
d_assert(ue->enb, return,);
|
||||
d_assert(ue->enb,,);
|
||||
d_info("[S1AP] downlinkNASTransport : "
|
||||
"UE[eNB-UE-S1AP-ID(%d)] <-- eNB[%s:%d]",
|
||||
ue->enb_ue_s1ap_id,
|
||||
|
|
|
@ -131,12 +131,6 @@ static void s1ap_message_test5(abts_case *tc, void *data)
|
|||
abts_suite *test_s1ap_message(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
{
|
||||
extern int _s1enc;
|
||||
extern int _s1dec;
|
||||
d_trace_level(&_s1enc, 0);
|
||||
d_trace_level(&_s1dec, 0);
|
||||
}
|
||||
|
||||
abts_run_test(suite, s1ap_message_test1, NULL);
|
||||
abts_run_test(suite, s1ap_message_test2, NULL);
|
||||
|
|
Loading…
Reference in New Issue