From 1326fc85dc03b05978b9a9d17a713ca1348fea65 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Thu, 15 Jul 2021 21:20:56 +0900 Subject: [PATCH] [MME] fix the bug when GTPv2 conflict (#1095) --- src/mme/mme-context.h | 4 +- src/mme/mme-gtp-path.c | 8 +- src/mme/mme-path.c | 2 +- src/mme/mme-s11-handler.c | 12 +- tests/attach/idle-test.c | 88 +++---- tests/volte/rx-test.c | 500 ++++++++++++++++++++++++++++++++++---- 6 files changed, 514 insertions(+), 100 deletions(-) diff --git a/src/mme/mme-context.h b/src/mme/mme-context.h index 23420660d9..2f6d7c35fe 100644 --- a/src/mme/mme-context.h +++ b/src/mme/mme-context.h @@ -638,7 +638,9 @@ typedef struct mme_bearer_s { /* Related Context */ mme_ue_t *mme_ue; mme_sess_t *sess; - ogs_gtp_xact_t *xact; + struct { + ogs_gtp_xact_t *xact; + } create, update, delete, notify, current; } mme_bearer_t; void mme_context_init(void); diff --git a/src/mme/mme-gtp-path.c b/src/mme/mme-gtp-path.c index 0de49ca5e4..6a6f17041d 100644 --- a/src/mme/mme-gtp-path.c +++ b/src/mme/mme-gtp-path.c @@ -337,7 +337,7 @@ int mme_gtp_send_create_bearer_response( ogs_assert(bearer); mme_ue = bearer->mme_ue; ogs_assert(mme_ue); - xact = ogs_gtp_xact_cycle(bearer->xact); + xact = ogs_gtp_xact_cycle(bearer->create.xact); ogs_assert(xact); memset(&h, 0, sizeof(ogs_gtp_header_t)); @@ -370,7 +370,7 @@ int mme_gtp_send_update_bearer_response( ogs_assert(bearer); mme_ue = bearer->mme_ue; ogs_assert(mme_ue); - xact = ogs_gtp_xact_cycle(bearer->xact); + xact = ogs_gtp_xact_cycle(bearer->update.xact); ogs_assert(xact); memset(&h, 0, sizeof(ogs_gtp_header_t)); @@ -403,7 +403,7 @@ int mme_gtp_send_delete_bearer_response( ogs_assert(bearer); mme_ue = bearer->mme_ue; ogs_assert(mme_ue); - xact = ogs_gtp_xact_cycle(bearer->xact); + xact = ogs_gtp_xact_cycle(bearer->delete.xact); ogs_assert(xact); memset(&h, 0, sizeof(ogs_gtp_header_t)); @@ -488,7 +488,7 @@ int mme_gtp_send_downlink_data_notification_ack( ogs_pkbuf_t *s11buf = NULL; ogs_assert(bearer); - xact = ogs_gtp_xact_cycle(bearer->xact); + xact = ogs_gtp_xact_cycle(bearer->notify.xact); ogs_assert(xact); mme_ue = bearer->mme_ue; ogs_assert(mme_ue); diff --git a/src/mme/mme-path.c b/src/mme/mme-path.c index 111bae3b6c..951f6836b0 100644 --- a/src/mme/mme-path.c +++ b/src/mme/mme-path.c @@ -87,7 +87,7 @@ void mme_send_after_paging(mme_ue_t *mme_ue, uint8_t cause_value) ogs_gtp_xact_t *xact = NULL; uint8_t type; - xact = ogs_gtp_xact_cycle(bearer->xact); + xact = ogs_gtp_xact_cycle(bearer->current.xact); if (xact) { /* * It may conflict with GTP transaction already used. diff --git a/src/mme/mme-s11-handler.c b/src/mme/mme-s11-handler.c index 6e6846a6d1..6b63058c3b 100644 --- a/src/mme/mme-s11-handler.c +++ b/src/mme/mme-s11-handler.c @@ -524,7 +524,8 @@ void mme_s11_handle_create_bearer_request( * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->xact = xact; + bearer->current.xact = xact; + bearer->create.xact = xact; /* Before Activate DEDICATED bearer, check DEFAULT bearer status */ default_bearer = mme_default_bearer_in_sess(sess); @@ -607,7 +608,8 @@ void mme_s11_handle_update_bearer_request( * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->xact = xact; + bearer->current.xact = xact; + bearer->update.xact = xact; if (req->bearer_contexts.bearer_level_qos.presence == 1) { /* Bearer QoS */ @@ -742,7 +744,8 @@ void mme_s11_handle_delete_bearer_request( * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->xact = xact; + bearer->current.xact = xact; + bearer->delete.xact = xact; if (ECM_IDLE(mme_ue)) { ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); @@ -945,7 +948,8 @@ void mme_s11_handle_downlink_data_notification( * If GTP-xact Holding timer is expired, * OLD bearer->xact memory will be automatically removed. */ - bearer->xact = xact; + bearer->current.xact = xact; + bearer->notify.xact = xact; if (noti->cause.presence) { ogs_gtp_cause_t *cause = noti->cause.data; diff --git a/tests/attach/idle-test.c b/tests/attach/idle-test.c index c0bf85fbbb..88c6c73308 100644 --- a/tests/attach/idle-test.c +++ b/tests/attach/idle-test.c @@ -158,7 +158,7 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -171,7 +171,7 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -196,19 +196,19 @@ static void test1_func(abts_case *tc, void *data) ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Request */ + /* Send UEContextReleaseRequest */ sendbuf = test_s1ap_build_ue_context_release_request(test_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_user_inactivity); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -223,7 +223,7 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); @@ -234,7 +234,7 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -262,14 +262,14 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive OLD UE Context Release Command */ + /* Receive OLD UEContextReleaseCommand */ enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send OLD UE Context Release Complete */ + /* Send OLD UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -282,7 +282,7 @@ static void test1_func(abts_case *tc, void *data) ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -311,14 +311,14 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive OLD UE Context Release Command */ + /* Receive OLD UEContextReleaseCommand */ enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send OLD UE Context Release Complete */ + /* Send OLD UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -331,12 +331,12 @@ static void test1_func(abts_case *tc, void *data) ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -495,7 +495,7 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -508,7 +508,7 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -558,14 +558,14 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive OLD UE Context Release Command */ + /* Receive OLD UEContextReleaseCommand */ enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send OLD UE Context Release Complete */ + /* Send OLD UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -578,12 +578,12 @@ static void test2_func(abts_case *tc, void *data) ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -598,7 +598,7 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); @@ -609,25 +609,25 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send UE Context Release Request */ + /* Send UEContextReleaseRequest */ sendbuf = test_s1ap_build_ue_context_release_request(test_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_user_inactivity); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -786,7 +786,7 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -799,7 +799,7 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -824,19 +824,19 @@ static void test3_func(abts_case *tc, void *data) ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Request */ + /* Send UEContextReleaseRequest */ sendbuf = test_s1ap_build_ue_context_release_request(test_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_user_inactivity); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -860,12 +860,12 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -889,12 +889,12 @@ static void test3_func(abts_case *tc, void *data) rv = test_gtpu_send_error_indication(gtpu, bearer); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -914,30 +914,30 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send UE Context Release Request */ + /* Send UEContextReleaseRequest */ sendbuf = test_s1ap_build_ue_context_release_request(test_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_user_inactivity); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -961,12 +961,12 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -981,19 +981,19 @@ static void test3_func(abts_case *tc, void *data) ABTS_PTR_NOTNULL(tc, recvbuf); ogs_pkbuf_free(recvbuf); - /* Send UE Context Release Request */ + /* Send UEContextReleaseRequest */ sendbuf = test_s1ap_build_ue_context_release_request(test_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_user_inactivity); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); diff --git a/tests/volte/rx-test.c b/tests/volte/rx-test.c index a8c69f40af..b5a097b6e5 100644 --- a/tests/volte/rx-test.c +++ b/tests/volte/rx-test.c @@ -166,7 +166,7 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -179,7 +179,7 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -500,14 +500,14 @@ static void test1_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive OLD UE Context Release Command */ + /* Receive OLD UEContextReleaseCommand */ enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send OLD UE Context Release Complete */ + /* Send OLD UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -515,12 +515,12 @@ static void test1_func(abts_case *tc, void *data) test_ue->enb_ue_s1ap_id = enb_ue_s1ap_id; - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -683,7 +683,7 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -696,7 +696,7 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -865,12 +865,12 @@ static void test2_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1036,7 +1036,7 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -1049,7 +1049,7 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1230,14 +1230,14 @@ static void test3_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive OLD UE Context Release Command */ + /* Receive OLD UEContextReleaseCommand */ enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send OLD UE Context Release Complete */ + /* Send OLD UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1245,12 +1245,12 @@ static void test3_func(abts_case *tc, void *data) test_ue->enb_ue_s1ap_id = enb_ue_s1ap_id; - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1416,7 +1416,7 @@ static void test4_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -1429,7 +1429,7 @@ static void test4_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1665,12 +1665,12 @@ static void test4_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1734,7 +1734,7 @@ static void test4_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -1747,7 +1747,7 @@ static void test4_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1778,12 +1778,12 @@ static void test4_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -1949,7 +1949,7 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -1976,7 +1976,7 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2055,12 +2055,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2084,12 +2084,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2139,12 +2139,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2168,12 +2168,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2211,12 +2211,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2239,12 +2239,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request */ + /* Receive InitialContextSetupRequest */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2285,12 +2285,12 @@ static void test5_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2457,7 +2457,7 @@ static void test6_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive Initial Context Setup Request + + /* Receive InitialContextSetupRequest + * Attach Accept + * Activate Default Bearer Context Request */ recvbuf = testenb_s1ap_read(s1ap); @@ -2470,7 +2470,7 @@ static void test6_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Send Initial Context Setup Response */ + /* Send InitialContextSetupResponse */ sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2697,14 +2697,14 @@ static void test6_func(abts_case *tc, void *data) rv = testenb_s1ap_send(s1ap, sendbuf); ABTS_INT_EQUAL(tc, OGS_OK, rv); - /* Receive OLD UE Context Release Command */ + /* Receive OLD UEContextReleaseCommand */ enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send OLD UE Context Release Complete */ + /* Send OLD UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2712,12 +2712,419 @@ static void test6_func(abts_case *tc, void *data) test_ue->enb_ue_s1ap_id = enb_ue_s1ap_id; - /* Receive UE Context Release Command */ + /* Receive UEContextReleaseCommand */ recvbuf = testenb_s1ap_read(s1ap); ABTS_PTR_NOTNULL(tc, recvbuf); tests1ap_recv(test_ue, recvbuf); - /* Send UE Context Release Complete */ + /* Send UEContextReleaseComplete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + ogs_msleep(300); + + /********** Remove Subscriber in Database */ + ABTS_INT_EQUAL(tc, OGS_OK, test_db_remove_ue(test_ue)); + + /* eNB disonncect from MME */ + testenb_s1ap_close(s1ap); + + /* eNB disonncect from SGW */ + test_gtpu_close(gtpu); + + test_ue_remove(test_ue); +} + +static void test7_func(abts_case *tc, void *data) +{ + int rv; + ogs_socknode_t *s1ap; + ogs_socknode_t *gtpu; + ogs_pkbuf_t *emmbuf; + ogs_pkbuf_t *esmbuf; + ogs_pkbuf_t *sendbuf; + ogs_pkbuf_t *recvbuf; + ogs_s1ap_message_t message; + + uint8_t *rx_sid1 = NULL; + uint8_t *rx_sid2 = NULL; + + ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci; + test_ue_t *test_ue = NULL; + test_sess_t *sess = NULL; + test_bearer_t *bearer = NULL; + + uint32_t enb_ue_s1ap_id; + uint64_t mme_ue_s1ap_id; + + bson_t *doc = NULL; + + /* Setup Test UE & Session Context */ + memset(&mobile_identity_suci, 0, sizeof(mobile_identity_suci)); + + mobile_identity_suci.h.supi_format = OGS_NAS_5GS_SUPI_FORMAT_IMSI; + mobile_identity_suci.h.type = OGS_NAS_5GS_MOBILE_IDENTITY_SUCI; + mobile_identity_suci.routing_indicator1 = 0; + mobile_identity_suci.routing_indicator2 = 0xf; + mobile_identity_suci.routing_indicator3 = 0xf; + mobile_identity_suci.routing_indicator4 = 0xf; + mobile_identity_suci.protection_scheme_id = OGS_NAS_5GS_NULL_SCHEME; + mobile_identity_suci.home_network_pki_value = 0; + mobile_identity_suci.scheme_output[0] = 0x10; + mobile_identity_suci.scheme_output[1] = 0x32; + mobile_identity_suci.scheme_output[2] = 0x54; + mobile_identity_suci.scheme_output[3] = 0x86; + mobile_identity_suci.scheme_output[4] = 0x91; + + test_ue = test_ue_add_by_suci(&mobile_identity_suci, 13); + ogs_assert(test_ue); + + test_ue->e_cgi.cell_id = 0x1079baf; + test_ue->nas.ksi = 0; + test_ue->nas.value = OGS_NAS_ATTACH_TYPE_COMBINED_EPS_IMSI_ATTACH; + + test_ue->k_string = "465b5ce8b199b49faa5f0a2ee238a6bc"; + test_ue->opc_string = "e8ed289deba952e4283b54e88e6183ca"; + + sess = test_sess_add_by_apn(test_ue, "internet", OGS_GTP_RAT_TYPE_EUTRAN); + ogs_assert(sess); + + /* eNB connects to MME */ + s1ap = tests1ap_client(AF_INET); + ABTS_PTR_NOTNULL(tc, s1ap); + + /* eNB connects to SGW */ + gtpu = test_gtpu_server(1, AF_INET); + ABTS_PTR_NOTNULL(tc, gtpu); + + /* Send S1-Setup Reqeust */ + sendbuf = test_s1ap_build_s1_setup_request( + S1AP_ENB_ID_PR_macroENB_ID, 0x54f64); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive S1-Setup Response */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(NULL, recvbuf); + + /********** Insert Subscriber in Database */ + doc = test_db_new_ims(test_ue); + ABTS_PTR_NOTNULL(tc, doc); + ABTS_INT_EQUAL(tc, OGS_OK, test_db_insert_ue(test_ue, doc)); + + /* Send Attach Request */ + memset(&sess->pdn_connectivity_param, + 0, sizeof(sess->pdn_connectivity_param)); + sess->pdn_connectivity_param.eit = 1; + sess->pdn_connectivity_param.request_type = + OGS_NAS_EPS_REQUEST_TYPE_INITIAL; + esmbuf = testesm_build_pdn_connectivity_request(sess); + ABTS_PTR_NOTNULL(tc, esmbuf); + + memset(&test_ue->attach_request_param, + 0, sizeof(test_ue->attach_request_param)); + test_ue->attach_request_param.integrity_protected = 1; + test_ue->attach_request_param.drx_parameter = 1; + test_ue->attach_request_param.ms_network_capability = 1; + test_ue->attach_request_param.tmsi_status = 1; + test_ue->attach_request_param.mobile_station_classmark_2 = 1; + test_ue->attach_request_param.ue_usage_setting = 1; + emmbuf = testemm_build_attach_request(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, emmbuf); + + memset(&test_ue->initial_ue_param, 0, sizeof(test_ue->initial_ue_param)); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, false); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Authentication Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Authentication response */ + emmbuf = testemm_build_authentication_response(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Security mode Command */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Security mode complete */ + test_ue->mobile_identity_imeisv_presence = true; + emmbuf = testemm_build_security_mode_complete(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive ESM Information Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send ESM Information Response */ + sess->esm_information_param.pco = 1; + esmbuf = testesm_build_esm_information_response(sess); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive InitialContextSetupRequest + + * Attach Accept + + * Activate Default Bearer Context Request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send UE Capability Info Indication */ + sendbuf = tests1ap_build_ue_radio_capability_info_indication(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send InitialContextSetupResponse */ + sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Attach Complete + Activate default EPS bearer cotext accept */ + test_ue->nr_cgi.cell_id = 0x1234502; + bearer = test_bearer_find_by_ue_ebi(test_ue, 5); + ogs_assert(bearer); + esmbuf = testesm_build_activate_default_eps_bearer_context_accept( + bearer, false); + ABTS_PTR_NOTNULL(tc, esmbuf); + emmbuf = testemm_build_attach_complete(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, emmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive EMM information */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send PDN Connectivity Request */ + sess = test_sess_add_by_apn(test_ue, "ims", OGS_GTP_RAT_TYPE_EUTRAN); + ogs_assert(sess); + sess->pti = 5; + + sess->pdn_connectivity_param.integrity_protected = 1; + sess->pdn_connectivity_param.apn = 1; + sess->pdn_connectivity_param.pco = 1; + sess->pdn_connectivity_param.request_type = + OGS_NAS_EPS_REQUEST_TYPE_INITIAL; + esmbuf = testesm_build_pdn_connectivity_request(sess); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive E-RABSetupRequest + + * Activate default EPS bearer context request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + S1AP_ProcedureCode_id_E_RABSetup, + test_ue->s1ap_procedure_code); + + /* Send E-RABSetupResponse */ + bearer = test_bearer_find_by_ue_ebi(test_ue, 6); + ogs_assert(bearer); + sendbuf = test_s1ap_build_e_rab_setup_response(bearer); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Activate default EPS bearer context accept */ + esmbuf = testesm_build_activate_default_eps_bearer_context_accept( + bearer, true); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send AA-Request */ + test_rx_send_aar_audio(&rx_sid1, sess, + OGS_DIAM_RX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI, 1, 1); + + /* Receive E-RABSetupRequest + + * Activate dedicated EPS bearer context request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + S1AP_ProcedureCode_id_E_RABSetup, + test_ue->s1ap_procedure_code); + + /* Send E-RABSetupResponse */ + bearer = test_bearer_find_by_ue_ebi(test_ue, 7); + ogs_assert(bearer); + sendbuf = test_s1ap_build_e_rab_setup_response(bearer); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Activate dedicated EPS bearer context accept */ + esmbuf = testesm_build_activate_dedicated_eps_bearer_context_accept(bearer); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* DELAY is needed in dedicated EPS bearer */ + ogs_msleep(100); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = test_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send Session-Termination-Request */ + test_rx_send_str(rx_sid1); + + /* Receive E-RABReleaseCommand + + * Dectivate EPS bearer context request */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + ABTS_INT_EQUAL(tc, + S1AP_ProcedureCode_id_E_RABRelease, + test_ue->s1ap_procedure_code); + + /* Send Error Indication */ + rv = test_gtpu_send_error_indication(gtpu, bearer); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive UEContextReleaseCommand */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send E-RABReleaseResponse */ + bearer = test_bearer_find_by_ue_ebi(test_ue, 7); + ogs_assert(bearer); + sendbuf = test_s1ap_build_e_rab_release_response(bearer); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Deactivate EPS bearer context accept */ + esmbuf = testesm_build_deactivate_eps_bearer_context_accept(bearer); + ABTS_PTR_NOTNULL(tc, esmbuf); + sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Test Bearer Remove */ + test_bearer_remove(bearer); + + /* Send UEContextReleaseComplete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive S1-Paging */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send Service Request */ + emmbuf = testemm_build_service_request(test_ue); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Data, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive InitialContextSetupRequest */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send InitialContextSetupResponse */ + sendbuf = test_s1ap_build_initial_context_setup_response(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send Detach Request */ + emmbuf = testemm_build_detach_request(test_ue, 1); + ABTS_PTR_NOTNULL(tc, emmbuf); + sendbuf = test_s1ap_build_initial_ue_message( + test_ue, emmbuf, S1AP_RRC_Establishment_Cause_mo_Signalling, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive OLD UEContextReleaseCommand */ + enb_ue_s1ap_id = test_ue->enb_ue_s1ap_id; + + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send OLD UEContextReleaseComplete */ + sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testenb_s1ap_send(s1ap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + test_ue->enb_ue_s1ap_id = enb_ue_s1ap_id; + + /* Receive UEContextReleaseCommand */ + recvbuf = testenb_s1ap_read(s1ap); + ABTS_PTR_NOTNULL(tc, recvbuf); + tests1ap_recv(test_ue, recvbuf); + + /* Send UEContextReleaseComplete */ sendbuf = test_s1ap_build_ue_context_release_complete(test_ue); ABTS_PTR_NOTNULL(tc, sendbuf); rv = testenb_s1ap_send(s1ap, sendbuf); @@ -2747,6 +3154,7 @@ abts_suite *test_rx(abts_suite *suite) abts_run_test(suite, test4_func, NULL); abts_run_test(suite, test5_func, NULL); abts_run_test(suite, test6_func, NULL); + abts_run_test(suite, test7_func, NULL); return suite; }