diff --git a/lib/nas/5gs/types.h b/lib/nas/5gs/types.h index e6f9cf5b7..946ae1f6c 100644 --- a/lib/nas/5gs/types.h +++ b/lib/nas/5gs/types.h @@ -282,12 +282,13 @@ void ogs_nas_5gs_tai_list_build( * O TLV 3 */ typedef struct ogs_nas_5gs_update_type_s { uint8_t length; -ED6(uint8_t spare:2;, - uint8_t pnb_ciot_eps:1;, - uint8_t pnb_ciot_5gs:1;, - uint8_t ng_ran_rcu:1;, - uint8_t sms_requested:1;, - uint8_t amf_pointer_value:2;) +ED7(uint8_t spare:2;, + uint8_t user_plane_ciot_eps_optimization:1;, + uint8_t control_plane_ciot_eps_optimization:1;, + uint8_t user_plane_ciot_5gs_optimization:1;, + uint8_t control_plane_ciot_5gs_optimization:1;, + uint8_t ng_ran_radio_capability_update_needed:1;, + uint8_t sms_over_nas_supported:1;) } __attribute__ ((packed)) ogs_nas_5gs_update_type_t; /* 9.11.3.10 ABBA diff --git a/src/amf/gmm-handler.c b/src/amf/gmm-handler.c index a0b493340..dfd0c0f41 100644 --- a/src/amf/gmm-handler.c +++ b/src/amf/gmm-handler.c @@ -307,11 +307,6 @@ int gmm_handle_registration_update(amf_ue_t *amf_ue, } } - if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered)) { - if (SESSION_SYNC_DONE(amf_ue)) - nas_5gs_send_registration_accept(amf_ue); - } - return OGS_OK; } diff --git a/src/amf/gmm-sm.c b/src/amf/gmm-sm.c index fef0f1e76..b7e213be6 100644 --- a/src/amf/gmm-sm.c +++ b/src/amf/gmm-sm.c @@ -149,6 +149,11 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) break; } + if (SESSION_SYNC_DONE(amf_ue)) + nas_5gs_send_registration_accept(amf_ue); + + OGS_FSM_TRAN(s, &gmm_state_registered); + } else { amf_sbi_send_release_all_sessions(amf_ue); diff --git a/tests/00101/issues-482-test.c b/tests/00101/issues-482-test.c index 41429e3af..c805c885b 100644 --- a/tests/00101/issues-482-test.c +++ b/tests/00101/issues-482-test.c @@ -211,6 +211,7 @@ static void test1_func(abts_case *tc, void *data) /* Send Registration request */ test_ue.registration_request_param.guti = 1; + test_ue.registration_request_param.gmm_capability = 1; gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); diff --git a/tests/00101/issues-508-test.c b/tests/00101/issues-508-test.c index 63524e4c2..3f222adaf 100644 --- a/tests/00101/issues-508-test.c +++ b/tests/00101/issues-508-test.c @@ -211,6 +211,7 @@ static void test1_func(abts_case *tc, void *data) /* Send Registration request */ test_ue.registration_request_param.guti = 1; + test_ue.registration_request_param.gmm_capability = 1; gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); diff --git a/tests/common/context.h b/tests/common/context.h index 5f2c13dbc..3f6979b83 100644 --- a/tests/common/context.h +++ b/tests/common/context.h @@ -60,18 +60,21 @@ typedef struct test_context_s { typedef struct test_sess_s test_sess_t; typedef struct test_registration_request_param_s { - union { - struct { - ED8(uint8_t integrity_protected:1;, - uint8_t guti:1;, - uint8_t requested_nssai:1;, - uint8_t last_visited_registered_tai:1;, - uint8_t ue_usage_setting:1;, - uint8_t uplink_data_status:1;, - uint8_t pdu_session_status:1;, - uint8_t allowed_pdu_session_status:1;) - }; - uint8_t value; + struct { + ED8(uint8_t integrity_protected:1;, + uint8_t ciphered:1;, + uint8_t guti:1;, + uint8_t gmm_capability:1;, + uint8_t requested_nssai:1;, + uint8_t last_visited_registered_tai:1;, + uint8_t ue_usage_setting:1;, + uint8_t update_type:1;) + }; + struct { + ED4(uint8_t uplink_data_status:1;, + uint8_t pdu_session_status:1;, + uint8_t allowed_pdu_session_status:1;, + uint8_t spare2:5;) }; struct { uint16_t pdu_session_status; diff --git a/tests/common/gmm-build.c b/tests/common/gmm-build.c index eb8b4ca74..b4dc1ccdf 100644 --- a/tests/common/gmm-build.c +++ b/tests/common/gmm-build.c @@ -51,6 +51,7 @@ ogs_pkbuf_t *testgmm_build_registration_request( ®istration_request->last_visited_registered_tai; ogs_nas_ue_usage_setting_t *ue_usage_setting = ®istration_request->ue_usage_setting; + ogs_nas_5gs_update_type_t *update_type = ®istration_request->update_type; ogs_nas_message_container_t *nas_message_container = ®istration_request->nas_message_container; @@ -63,8 +64,12 @@ ogs_pkbuf_t *testgmm_build_registration_request( memset(&message, 0, sizeof(message)); if (test_ue->registration_request_param.integrity_protected) { - message.h.security_header_type = - OGS_NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHERED; + if (test_ue->registration_request_param.ciphered) + message.h.security_header_type = + OGS_NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHERED; + else + message.h.security_header_type = + OGS_NAS_SECURITY_HEADER_INTEGRITY_PROTECTED; message.h.extended_protocol_discriminator = OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM; } @@ -119,12 +124,14 @@ ogs_pkbuf_t *testgmm_build_registration_request( registration_request_param.psimask.allowed_pdu_session_status >> 8; } - registration_request->presencemask |= - OGS_NAS_5GS_REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT; - gmm_capability->length = 1; - gmm_capability->lte_positioning_protocol_capability = 0; - gmm_capability->ho_attach = 1; - gmm_capability->s1_mode = 1; + if (test_ue->registration_request_param.gmm_capability) { + registration_request->presencemask |= + OGS_NAS_5GS_REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT; + gmm_capability->length = 1; + gmm_capability->lte_positioning_protocol_capability = 0; + gmm_capability->ho_attach = 1; + gmm_capability->s1_mode = 1; + } registration_request->presencemask |= OGS_NAS_5GS_REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT; @@ -174,6 +181,14 @@ ogs_pkbuf_t *testgmm_build_registration_request( ue_usage_setting->data_centric = 1; } + if (test_ue->registration_request_param.update_type) { + /* Set 5GS update type */ + registration_request->presencemask |= + OGS_NAS_5GS_REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT; + update_type->length = 1; + update_type->sms_over_nas_supported = 1; + } + if (nasbuf) { registration_request->presencemask |= OGS_NAS_5GS_REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT; diff --git a/tests/minimal/minimal-test.c b/tests/minimal/minimal-test.c index 3a513c575..c6fc543c5 100644 --- a/tests/minimal/minimal-test.c +++ b/tests/minimal/minimal-test.c @@ -191,6 +191,7 @@ static void test1_func(abts_case *tc, void *data) bson_destroy(doc); /* Send Registration request */ + test_ue.registration_request_param.gmm_capability = 1; gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); sendbuf = testngap_build_initial_ue_message(&test_ue, gmmbuf, false); diff --git a/tests/registration/auth-test.c b/tests/registration/auth-test.c index 233c5a8f8..9c89cfd0e 100644 --- a/tests/registration/auth-test.c +++ b/tests/registration/auth-test.c @@ -205,6 +205,7 @@ static void test1_func(abts_case *tc, void *data) bson_destroy(doc); /* Send Registration request */ + test_ue.registration_request_param.gmm_capability = 1; gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); sendbuf = testngap_build_initial_ue_message(&test_ue, gmmbuf, false); diff --git a/tests/registration/dereg-test.c b/tests/registration/dereg-test.c index 4def9cb93..cbb20b133 100644 --- a/tests/registration/dereg-test.c +++ b/tests/registration/dereg-test.c @@ -212,6 +212,7 @@ static void test1_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; @@ -570,9 +571,11 @@ static void test2_func(abts_case *tc, void *data) bson_destroy(doc); /* Send Registration request */ + test_ue.registration_request_param.gmm_capability = 0; gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; @@ -761,6 +764,97 @@ static void test2_func(abts_case *tc, void *data) ogs_msleep(100); + /* Send Registration request : Uplink Data Status */ + test_ue.registration_request_param.integrity_protected = 0; + test_ue.registration_request_param.guti = 1; + test_ue.registration_request_param.gmm_capability = 1; + test_ue.registration_request_param.requested_nssai = 1; + test_ue.registration_request_param.last_visited_registered_tai = 1; + test_ue.registration_request_param.ue_usage_setting = 1; + test_ue.registration_request_param.update_type = 1; + nasbuf = testgmm_build_registration_request(&test_ue, NULL); + ABTS_PTR_NOTNULL(tc, nasbuf); + + test_ue.registration_request_param.integrity_protected = 1; + test_ue.registration_request_param.guti = 1; + test_ue.registration_request_param.gmm_capability = 0; + test_ue.registration_request_param.requested_nssai = 0; + test_ue.registration_request_param.last_visited_registered_tai = 0; + test_ue.registration_request_param.ue_usage_setting = 0; + test_ue.registration_request_param.update_type = 0; + gmmbuf = testgmm_build_registration_request(&test_ue, nasbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + + sendbuf = testngap_build_initial_ue_message(&test_ue, gmmbuf, true); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive Registration accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(&test_ue, recvbuf); + ABTS_INT_EQUAL(tc, 0x0000, test_ue.pdu_session_reactivation_result); + + /* Send Initial context setup response */ + sendbuf = testngap_build_initial_context_setup_response(&test_ue, NULL); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send PDU session establishment request */ + test_sess.ul_nas_transport_param.request_type = + OGS_NAS_5GS_REQUEST_TYPE_INITIAL; + test_sess.ul_nas_transport_param.dnn = 1; + test_sess.ul_nas_transport_param.s_nssai = 1; + + gsmbuf = testgsm_build_pdu_session_establishment_request(&test_sess); + ABTS_PTR_NOTNULL(tc, gsmbuf); + gmmbuf = testgmm_build_ul_nas_transport(&test_sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, gsmbuf); + ABTS_PTR_NOTNULL(tc, gmmbuf); + sendbuf = testngap_build_uplink_nas_transport(&test_ue, gmmbuf); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive PDU session establishment accept */ + recvbuf = testgnb_ngap_read(ngap); + ABTS_PTR_NOTNULL(tc, recvbuf); + testngap_recv(&test_ue, recvbuf); + + ogs_msleep(100); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_build_ping(&sendbuf, &test_sess, "10.45.0.1"); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + rv = testgnb_gtpu_send(gtpu, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Send PDU session resource setup response */ + sendbuf = testngap_build_pdu_session_resource_setup_response(&test_sess); + ABTS_PTR_NOTNULL(tc, sendbuf); + rv = testgnb_ngap_send(ngap, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + /* Send GTP-U ICMP Packet */ + rv = test_gtpu_build_ping(&sendbuf, &test_sess, "10.45.0.1"); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + rv = testgnb_gtpu_send(gtpu, sendbuf); + ABTS_INT_EQUAL(tc, OGS_OK, rv); + + /* Receive GTP-U ICMP Packet */ + recvbuf = testgnb_gtpu_read(gtpu); + ABTS_PTR_NOTNULL(tc, recvbuf); + ogs_pkbuf_free(recvbuf); + + ogs_msleep(100); + /********** Remove Subscriber in Database */ doc = BCON_NEW("imsi", BCON_UTF8(test_ue.imsi)); ABTS_PTR_NOTNULL(tc, doc); diff --git a/tests/registration/gmm-status-test.c b/tests/registration/gmm-status-test.c index bf33a543a..5749ea705 100644 --- a/tests/registration/gmm-status-test.c +++ b/tests/registration/gmm-status-test.c @@ -208,6 +208,7 @@ static void test1_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; diff --git a/tests/registration/guti-test.c b/tests/registration/guti-test.c index 1a0385ffa..882689d2e 100644 --- a/tests/registration/guti-test.c +++ b/tests/registration/guti-test.c @@ -209,6 +209,7 @@ static void test1_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; diff --git a/tests/registration/identity-test.c b/tests/registration/identity-test.c index a71d3b5dd..3cc874980 100644 --- a/tests/registration/identity-test.c +++ b/tests/registration/identity-test.c @@ -208,6 +208,7 @@ static void test1_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; diff --git a/tests/registration/idle-test.c b/tests/registration/idle-test.c index a70f170b4..fb40830b9 100644 --- a/tests/registration/idle-test.c +++ b/tests/registration/idle-test.c @@ -208,6 +208,7 @@ static void test1_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; @@ -696,6 +697,7 @@ static void test2_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; @@ -1027,6 +1029,7 @@ static void test3_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; @@ -1449,6 +1452,7 @@ static void test4_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1; diff --git a/tests/registration/ue-context-test.c b/tests/registration/ue-context-test.c index 1146cc6a2..c7c2ce308 100644 --- a/tests/registration/ue-context-test.c +++ b/tests/registration/ue-context-test.c @@ -208,6 +208,7 @@ static void test1_func(abts_case *tc, void *data) gmmbuf = testgmm_build_registration_request(&test_ue, NULL); ABTS_PTR_NOTNULL(tc, gmmbuf); + test_ue.registration_request_param.gmm_capability = 1; test_ue.registration_request_param.requested_nssai = 1; test_ue.registration_request_param.last_visited_registered_tai = 1; test_ue.registration_request_param.ue_usage_setting = 1;