forked from acouzens/open5gs
Fix the AMF bug and add TLV log [#521]
This commit is contained in:
parent
bcffdd823e
commit
9f24b7f295
|
@ -115,7 +115,11 @@ static ogs_tlv_t *tlv_add_leaf(
|
|||
{
|
||||
ogs_tlv_octet_t *v = (ogs_tlv_octet_t *)msg;
|
||||
|
||||
ogs_assert(v->len > 0);
|
||||
if (v->len == 0) {
|
||||
ogs_fatal("No TLV length - [%s] T:%d I:%d (vsz=%d)",
|
||||
desc->name, desc->type, desc->instance, desc->vsize);
|
||||
ogs_assert_if_reached();
|
||||
}
|
||||
|
||||
if (parent_tlv)
|
||||
tlv = ogs_tlv_embed(parent_tlv,
|
||||
|
@ -185,7 +189,8 @@ static uint32_t tlv_add_compound(ogs_tlv_t **root, ogs_tlv_t *parent_tlv,
|
|||
tlv = ogs_tlv_embed(parent_tlv,
|
||||
desc->type, 0, desc->instance, NULL);
|
||||
else
|
||||
tlv = ogs_tlv_add(tlv, desc->type, 0, desc->instance, NULL);
|
||||
tlv = ogs_tlv_add(tlv,
|
||||
desc->type, 0, desc->instance, NULL);
|
||||
|
||||
r = tlv_add_compound(&emb_tlv, tlv, desc,
|
||||
p + offset2 + sizeof(ogs_tlv_presence_t),
|
||||
|
@ -224,7 +229,8 @@ static uint32_t tlv_add_compound(ogs_tlv_t **root, ogs_tlv_t *parent_tlv,
|
|||
tlv = ogs_tlv_embed(parent_tlv,
|
||||
desc->type, 0, desc->instance, NULL);
|
||||
else
|
||||
tlv = ogs_tlv_add(tlv, desc->type, 0, desc->instance, NULL);
|
||||
tlv = ogs_tlv_add(tlv,
|
||||
desc->type, 0, desc->instance, NULL);
|
||||
|
||||
r = tlv_add_compound(&emb_tlv, tlv, desc,
|
||||
p + offset + sizeof(ogs_tlv_presence_t),
|
||||
|
|
|
@ -452,7 +452,7 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
|
|||
amf_ue->supi, sbi_message.res_status);
|
||||
}
|
||||
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(sess);
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(sess, state);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
|
|
|
@ -302,7 +302,8 @@ int gmm_handle_registration_update(amf_ue_t *amf_ue,
|
|||
ogs_list_for_each(&amf_ue->sess_list, sess) {
|
||||
if ((psimask & (1 << sess->psi)) == 0) {
|
||||
if (SESSION_CONTEXT_IN_SMF(sess))
|
||||
amf_sbi_send_release_session(sess);
|
||||
amf_sbi_send_release_session(
|
||||
sess, AMF_RELEASE_SM_CONTEXT_REGISTRATION_ACCEPT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,7 +490,8 @@ int gmm_handle_service_update(amf_ue_t *amf_ue,
|
|||
ogs_list_for_each(&amf_ue->sess_list, sess) {
|
||||
if ((psimask & (1 << sess->psi)) == 0) {
|
||||
if (SESSION_CONTEXT_IN_SMF(sess))
|
||||
amf_sbi_send_release_session(sess);
|
||||
amf_sbi_send_release_session(
|
||||
sess, AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +528,8 @@ int gmm_handle_deregistration_request(amf_ue_t *amf_ue,
|
|||
if (deregistration_request->de_registration_type.switch_off)
|
||||
ogs_debug(" Switch-Off");
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
amf_sbi_send_release_all_sessions(
|
||||
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
|
||||
if (ogs_list_count(&amf_ue->sess_list) == 0)
|
||||
nas_5gs_send_de_registration_accept(amf_ue);
|
||||
|
|
|
@ -86,14 +86,13 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
|
|||
|
||||
static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
|
||||
{
|
||||
int rv;
|
||||
int rv, xact_count = 0;
|
||||
|
||||
amf_ue_t *amf_ue = NULL;
|
||||
amf_sess_t *sess = NULL;
|
||||
ran_ue_t *ran_ue = NULL;
|
||||
ogs_nas_5gs_message_t *nas_message = NULL;
|
||||
ogs_nas_security_header_type_t h;
|
||||
int xact_count = 0;
|
||||
|
||||
ogs_assert(e);
|
||||
|
||||
|
@ -146,9 +145,7 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
|
|||
amf_ue, &nas_message->gmm.registration_request);
|
||||
if (rv != OGS_OK) {
|
||||
ogs_error("gmm_handle_registration_update() failed");
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
OGS_FSM_TRAN(s, &gmm_state_authentication);
|
||||
OGS_FSM_TRAN(s, gmm_state_exception);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -159,7 +156,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
|
|||
|
||||
} else {
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
amf_sbi_send_release_all_sessions(
|
||||
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
if (amf_sess_xact_count(amf_ue) == xact_count) {
|
||||
amf_ue_sbi_discover_and_send(
|
||||
OpenAPI_nf_type_AUSF, amf_ue, NULL,
|
||||
|
@ -220,7 +218,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e)
|
|||
break;
|
||||
}
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
amf_sbi_send_release_all_sessions(
|
||||
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
if (amf_sess_xact_count(amf_ue) == xact_count) {
|
||||
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, amf_ue, NULL,
|
||||
amf_nausf_auth_build_authenticate);
|
||||
|
@ -771,7 +770,7 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e)
|
|||
|
||||
void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e)
|
||||
{
|
||||
int rv;
|
||||
int rv, xact_count = 0;
|
||||
amf_ue_t *amf_ue = NULL;
|
||||
amf_sess_t *sess = NULL;
|
||||
ogs_nas_5gs_message_t *nas_message = NULL;
|
||||
|
@ -924,7 +923,12 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e)
|
|||
break;
|
||||
}
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
amf_sbi_send_release_all_sessions(
|
||||
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
if (amf_sess_xact_count(amf_ue) == xact_count) {
|
||||
amf_ue_sbi_discover_and_send(OpenAPI_nf_type_AUSF, amf_ue, NULL,
|
||||
amf_nausf_auth_build_authenticate);
|
||||
}
|
||||
OGS_FSM_TRAN(s, &gmm_state_authentication);
|
||||
break;
|
||||
|
||||
|
@ -973,7 +977,8 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
|
|||
case OGS_FSM_ENTRY_SIG:
|
||||
CLEAR_AMF_UE_ALL_TIMERS(amf_ue);
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
amf_sbi_send_release_all_sessions(
|
||||
amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
|
||||
if (ogs_list_count(&amf_ue->sess_list) == 0)
|
||||
ngap_send_amf_ue_context_release_command(amf_ue,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "nas-path.h"
|
||||
#include "ngap-path.h"
|
||||
#include "sbi-path.h"
|
||||
|
||||
int amf_namf_comm_handle_n1_n2_message_transfer(
|
||||
ogs_sbi_session_t *session, ogs_sbi_message_t *recvmsg)
|
||||
|
@ -276,7 +277,8 @@ int amf_namf_callback_handle_sm_context_status(
|
|||
sess->resource_status == OpenAPI_resource_status_RELEASED) {
|
||||
|
||||
ogs_debug("[%s:%d] SM context remove", amf_ue->supi, sess->psi);
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(sess);
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(
|
||||
sess, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
|
|
@ -798,9 +798,10 @@ void ngap_handle_initial_context_setup_failure(
|
|||
amf_gnb_t *gnb, ogs_ngap_message_t *message)
|
||||
{
|
||||
char buf[OGS_ADDRSTRLEN];
|
||||
int i;
|
||||
int i, old_xact_count = 0, new_xact_count = 0;
|
||||
|
||||
ran_ue_t *ran_ue = NULL;
|
||||
amf_ue_t *amf_ue = NULL;
|
||||
uint64_t amf_ue_ngap_id;
|
||||
|
||||
NGAP_UnsuccessfulOutcome_t *unsuccessfulOutcome = NULL;
|
||||
|
@ -892,9 +893,21 @@ void ngap_handle_initial_context_setup_failure(
|
|||
* may in principle be adopted. The RAN should ensure
|
||||
* that no hanging resources remain at the RAN.
|
||||
*/
|
||||
ngap_send_session_sync_or_context_release_command(ran_ue,
|
||||
NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release,
|
||||
NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0);
|
||||
amf_ue = ran_ue->amf_ue;
|
||||
if (amf_ue) {
|
||||
old_xact_count = amf_sess_xact_count(amf_ue);
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue,
|
||||
AMF_RELEASE_SM_CONTEXT_NG_CONTEXT_REMOVE);
|
||||
|
||||
new_xact_count = amf_sess_xact_count(amf_ue);
|
||||
}
|
||||
|
||||
if (old_xact_count == new_xact_count) {
|
||||
ngap_send_ran_ue_context_release_command(ran_ue,
|
||||
NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release,
|
||||
NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -357,28 +357,6 @@ void ngap_send_amf_ue_context_release_command(
|
|||
}
|
||||
}
|
||||
|
||||
void ngap_send_session_sync_or_context_release_command(
|
||||
ran_ue_t *ran_ue, NGAP_Cause_PR group, long cause,
|
||||
uint8_t action, uint32_t delay)
|
||||
{
|
||||
amf_ue_t *amf_ue = NULL;
|
||||
|
||||
ogs_assert(ran_ue);
|
||||
|
||||
amf_ue = ran_ue->amf_ue;
|
||||
if (!amf_ue) {
|
||||
ngap_send_ran_ue_context_release_command(ran_ue,
|
||||
group, cause, action, delay);
|
||||
} else {
|
||||
int xact_count = amf_sess_xact_count(amf_ue);
|
||||
|
||||
amf_sbi_send_release_all_sessions(amf_ue);
|
||||
if (amf_sess_xact_count(amf_ue) == xact_count)
|
||||
ngap_send_ran_ue_context_release_command(ran_ue,
|
||||
group, cause, action, delay);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void ngap_send_paging(amf_ue_t *amf_ue, NGAP_CNDomain_t cn_domain)
|
||||
{
|
||||
|
|
|
@ -61,10 +61,6 @@ void ngap_send_amf_ue_context_release_command(
|
|||
amf_ue_t *amf_ue, NGAP_Cause_PR group, long cause,
|
||||
uint8_t action, uint32_t delay);
|
||||
|
||||
void ngap_send_session_sync_or_context_release_command(
|
||||
ran_ue_t *ran_ue, NGAP_Cause_PR group, long cause,
|
||||
uint8_t action, uint32_t delay);
|
||||
|
||||
#if 0
|
||||
void ngap_send_paging(amf_ue_t *amf_ue, NGAP_CNDomain_t cn_domain);
|
||||
#endif
|
||||
|
|
|
@ -333,7 +333,8 @@ int amf_nsmf_pdu_session_handle_update_sm_context(
|
|||
sess->resource_status == OpenAPI_resource_status_RELEASED) {
|
||||
|
||||
ogs_debug("[%s:%d] SM context remove", amf_ue->supi, sess->psi);
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(sess);
|
||||
amf_nsmf_pdu_session_handle_release_sm_context(
|
||||
sess, AMF_RELEASE_SM_CONTEXT_NO_STATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -413,7 +414,7 @@ int amf_nsmf_pdu_session_handle_update_sm_context(
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess)
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess, int state)
|
||||
{
|
||||
amf_ue_t *amf_ue = NULL;
|
||||
|
||||
|
@ -421,8 +422,10 @@ int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess)
|
|||
amf_ue = sess->amf_ue;
|
||||
ogs_assert(amf_ue);
|
||||
|
||||
amf_sess_remove(sess);
|
||||
|
||||
/* Check last session */
|
||||
if (ogs_list_count(&amf_ue->sess_list) == 1) {
|
||||
if (ogs_list_count(&amf_ue->sess_list) == 0) {
|
||||
|
||||
if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_authentication)) {
|
||||
|
||||
|
@ -433,19 +436,6 @@ int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess)
|
|||
|
||||
nas_5gs_send_de_registration_accept(amf_ue);
|
||||
|
||||
} else if (OGS_FSM_CHECK(&amf_ue->sm,
|
||||
gmm_state_initial_context_setup)) {
|
||||
|
||||
/*
|
||||
* 1. Initial context setup failure
|
||||
* 2. Release All SM contexts
|
||||
* 3. UE Context release command
|
||||
* 4. UE Context release complete
|
||||
*/
|
||||
ngap_send_amf_ue_context_release_command(amf_ue,
|
||||
NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release,
|
||||
NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0);
|
||||
|
||||
} else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_exception)) {
|
||||
|
||||
/*
|
||||
|
@ -458,22 +448,54 @@ int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess)
|
|||
NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release,
|
||||
NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
|
||||
|
||||
} else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered)) {
|
||||
|
||||
ogs_debug("Release SM Context in registered STATE");
|
||||
|
||||
} else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_security_mode)) {
|
||||
|
||||
ogs_error("Release SM Context in security-mode STATE");
|
||||
|
||||
} else {
|
||||
if (state == AMF_RELEASE_SM_CONTEXT_NG_CONTEXT_REMOVE) {
|
||||
/*
|
||||
* 1. Initial context setup failure
|
||||
* 2. Release All SM contexts
|
||||
* 3. UE Context release command
|
||||
* 4. UE Context release complete
|
||||
*/
|
||||
ngap_send_amf_ue_context_release_command(amf_ue,
|
||||
NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release,
|
||||
NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0);
|
||||
|
||||
ogs_error("Release SM Context : INVALID STATE");
|
||||
} else if (state == AMF_RELEASE_SM_CONTEXT_REGISTRATION_ACCEPT) {
|
||||
/*
|
||||
* 1. Registration request
|
||||
* 2. Release All SM contexts
|
||||
* 3. Registration accept
|
||||
*/
|
||||
nas_5gs_send_registration_accept(amf_ue);
|
||||
|
||||
} else if (state == AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) {
|
||||
/*
|
||||
* 1. Service request
|
||||
* 2. Release All SM contexts
|
||||
* 3. Service accept
|
||||
*/
|
||||
nas_5gs_send_service_accept(amf_ue);
|
||||
|
||||
} else {
|
||||
ogs_fatal("Unknown state[%d]", state);
|
||||
if (OGS_FSM_CHECK(&amf_ue->sm,
|
||||
gmm_state_initial_context_setup)) {
|
||||
ogs_fatal("Release SM Context in initial-context-setup");
|
||||
} else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered)) {
|
||||
|
||||
ogs_fatal("Release SM Context in registered");
|
||||
|
||||
} else if (OGS_FSM_CHECK(
|
||||
&amf_ue->sm, gmm_state_security_mode)) {
|
||||
ogs_fatal("Release SM Context in security-mode");
|
||||
} else {
|
||||
ogs_fatal("Release SM Context : INVALID STATE");
|
||||
|
||||
}
|
||||
ogs_assert_if_reached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
amf_sess_remove(sess);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ int amf_nsmf_pdu_session_handle_create_sm_context(
|
|||
amf_sess_t *sess, ogs_sbi_message_t *message);
|
||||
int amf_nsmf_pdu_session_handle_update_sm_context(
|
||||
amf_sess_t *sess, int state, ogs_sbi_message_t *recvmsg);
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess);
|
||||
int amf_nsmf_pdu_session_handle_release_sm_context(amf_sess_t *sess, int state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -215,19 +215,19 @@ void amf_sbi_send_deactivate_all_sessions(
|
|||
}
|
||||
}
|
||||
|
||||
void amf_sbi_send_release_session(amf_sess_t *sess)
|
||||
void amf_sbi_send_release_session(amf_sess_t *sess, int state)
|
||||
{
|
||||
ogs_assert(sess);
|
||||
|
||||
amf_sess_sbi_discover_and_send(
|
||||
OpenAPI_nf_type_SMF, sess, AMF_UPDATE_SM_CONTEXT_NO_STATE, NULL,
|
||||
OpenAPI_nf_type_SMF, sess, state, NULL,
|
||||
amf_nsmf_pdu_session_build_release_sm_context);
|
||||
|
||||
/* Prevent to invoke SMF for this session */
|
||||
CLEAR_SM_CONTEXT_REF(sess);
|
||||
}
|
||||
|
||||
void amf_sbi_send_release_all_sessions(amf_ue_t *amf_ue)
|
||||
void amf_sbi_send_release_all_sessions(amf_ue_t *amf_ue, int state)
|
||||
{
|
||||
amf_sess_t *sess = NULL;
|
||||
|
||||
|
@ -235,6 +235,6 @@ void amf_sbi_send_release_all_sessions(amf_ue_t *amf_ue)
|
|||
|
||||
ogs_list_for_each(&amf_ue->sess_list, sess) {
|
||||
if (SESSION_CONTEXT_IN_SMF(sess))
|
||||
amf_sbi_send_release_session(sess);
|
||||
amf_sbi_send_release_session(sess, state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,12 @@ void amf_sbi_send_deactivate_session(
|
|||
void amf_sbi_send_deactivate_all_sessions(
|
||||
amf_ue_t *amf_ue, int group, int cause);
|
||||
|
||||
void amf_sbi_send_release_session(amf_sess_t *sess);
|
||||
void amf_sbi_send_release_all_sessions(amf_ue_t *amf_ue);
|
||||
#define AMF_RELEASE_SM_CONTEXT_NO_STATE 0
|
||||
#define AMF_RELEASE_SM_CONTEXT_NG_CONTEXT_REMOVE 1
|
||||
#define AMF_RELEASE_SM_CONTEXT_REGISTRATION_ACCEPT 2
|
||||
#define AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT 3
|
||||
void amf_sbi_send_release_session(amf_sess_t *sess, int state);
|
||||
void amf_sbi_send_release_all_sessions(amf_ue_t *amf_ue, int state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1759,6 +1759,430 @@ static void test4_func(abts_case *tc, void *data)
|
|||
test_ue_remove(&test_ue);
|
||||
}
|
||||
|
||||
static void test5_func(abts_case *tc, void *data)
|
||||
{
|
||||
int rv;
|
||||
ogs_socknode_t *ngap;
|
||||
ogs_socknode_t *gtpu;
|
||||
ogs_pkbuf_t *gmmbuf;
|
||||
ogs_pkbuf_t *gsmbuf;
|
||||
ogs_pkbuf_t *nasbuf;
|
||||
ogs_pkbuf_t *sendbuf;
|
||||
ogs_pkbuf_t *recvbuf;
|
||||
ogs_ngap_message_t message;
|
||||
int i;
|
||||
int msgindex = 0;
|
||||
|
||||
ogs_nas_5gs_mobile_identity_suci_t mobile_identity_suci;
|
||||
test_ue_t test_ue;
|
||||
test_sess_t test_sess;
|
||||
|
||||
uint8_t tmp[OGS_MAX_SDU_LEN];
|
||||
|
||||
const char *_k_string = "70d49a71dd1a2b806a25abe0ef749f1e";
|
||||
uint8_t k[OGS_KEY_LEN];
|
||||
const char *_opc_string = "6f1bf53d624b3a43af6592854e2444c7";
|
||||
uint8_t opc[OGS_KEY_LEN];
|
||||
|
||||
mongoc_collection_t *collection = NULL;
|
||||
bson_t *doc = NULL;
|
||||
int64_t count = 0;
|
||||
bson_error_t error;
|
||||
const char *json =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, "
|
||||
"\"imsi\" : \"901700000021309\","
|
||||
"\"ambr\" : { "
|
||||
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
|
||||
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
|
||||
"},"
|
||||
"\"pdn\" : ["
|
||||
"{"
|
||||
"\"apn\" : \"internet\", "
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c7\" }, "
|
||||
"\"ambr\" : {"
|
||||
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
|
||||
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
|
||||
"},"
|
||||
"\"qos\" : { "
|
||||
"\"qci\" : 9, "
|
||||
"\"arp\" : { "
|
||||
"\"priority_level\" : 8,"
|
||||
"\"pre_emption_vulnerability\" : 1, "
|
||||
"\"pre_emption_capability\" : 1"
|
||||
"} "
|
||||
"}, "
|
||||
"\"type\" : 2"
|
||||
"}"
|
||||
"],"
|
||||
"\"security\" : { "
|
||||
"\"k\" : \"70d49a71dd1a2b806a25abe0ef749f1e\", "
|
||||
"\"opc\" : \"6f1bf53d624b3a43af6592854e2444c7\", "
|
||||
"\"amf\" : \"8000\", "
|
||||
"\"sqn\" : { \"$numberLong\" : \"25235952177090\" } "
|
||||
"}, "
|
||||
"\"subscribed_rau_tau_timer\" : 12,"
|
||||
"\"network_access_mode\" : 2, "
|
||||
"\"subscriber_status\" : 0, "
|
||||
"\"access_restriction_data\" : 32, "
|
||||
"\"__v\" : 0 "
|
||||
"}";
|
||||
|
||||
/* Setup Test UE & Session Context */
|
||||
memset(&test_ue, 0, sizeof(test_ue));
|
||||
memset(&test_sess, 0, sizeof(test_sess));
|
||||
test_sess.test_ue = &test_ue;
|
||||
test_ue.sess = &test_sess;
|
||||
|
||||
test_ue.nas.registration.type = OGS_NAS_KSI_NO_KEY_IS_AVAILABLE;
|
||||
test_ue.nas.registration.follow_on_request = 1;
|
||||
test_ue.nas.registration.value = OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL;
|
||||
|
||||
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;
|
||||
ogs_nas_from_plmn_id(&mobile_identity_suci.nas_plmn_id,
|
||||
&test_self()->tai.plmn_id);
|
||||
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] = 0;
|
||||
mobile_identity_suci.scheme_output[1] = 0;
|
||||
mobile_identity_suci.scheme_output[2] = 0x20;
|
||||
mobile_identity_suci.scheme_output[3] = 0x31;
|
||||
mobile_identity_suci.scheme_output[4] = 0x90;
|
||||
|
||||
test_ue_set_mobile_identity_suci(&test_ue, &mobile_identity_suci, 13);
|
||||
|
||||
memset(&test_ue.mobile_identity_imeisv, 0,
|
||||
sizeof(ogs_nas_mobile_identity_imeisv_t));
|
||||
test_ue.mobile_identity_imeisv.type = OGS_NAS_5GS_MOBILE_IDENTITY_IMEISV;
|
||||
test_ue.mobile_identity_imeisv.odd_even = OGS_NAS_MOBILE_IDENTITY_EVEN;
|
||||
test_ue.mobile_identity_imeisv.digit1 = 8;
|
||||
test_ue.mobile_identity_imeisv.digit2 = 6;
|
||||
test_ue.mobile_identity_imeisv.digit3 = 6;
|
||||
test_ue.mobile_identity_imeisv.digit4 = 5;
|
||||
test_ue.mobile_identity_imeisv.digit5 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit6 = 7;
|
||||
test_ue.mobile_identity_imeisv.digit7 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit8 = 4;
|
||||
test_ue.mobile_identity_imeisv.digit9 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit10 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit11 = 4;
|
||||
test_ue.mobile_identity_imeisv.digit12 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit13 = 5;
|
||||
test_ue.mobile_identity_imeisv.digit14 = 3;
|
||||
test_ue.mobile_identity_imeisv.digit15 = 0;
|
||||
test_ue.mobile_identity_imeisv.digit16 = 1;
|
||||
test_ue.mobile_identity_imeisv.digit17 = 0xf;
|
||||
|
||||
test_ue.nas.access_type = OGS_ACCESS_TYPE_3GPP;
|
||||
test_ue.abba_len = 2;
|
||||
|
||||
OGS_HEX(_k_string, strlen(_k_string), test_ue.k);
|
||||
OGS_HEX(_opc_string, strlen(_opc_string), test_ue.opc);
|
||||
|
||||
test_sess.psi = 5;
|
||||
test_sess.pti = 1;
|
||||
test_sess.pdu_session_type = OGS_PDU_SESSION_TYPE_IPV4V6;
|
||||
test_sess.dnn = (char *)"internet";
|
||||
|
||||
memset(&test_sess.gnb_n3_ip, 0, sizeof(test_sess.gnb_n3_ip));
|
||||
test_sess.gnb_n3_ip.ipv4 = true;
|
||||
test_sess.gnb_n3_ip.addr = inet_addr("127.0.0.5");
|
||||
test_sess.gnb_n3_teid = 3;
|
||||
|
||||
/* gNB connects to AMF */
|
||||
ngap = testgnb_ngap_client("127.0.0.2");
|
||||
ABTS_PTR_NOTNULL(tc, ngap);
|
||||
|
||||
/* gNB connects to UPF */
|
||||
gtpu = testgnb_gtpu_server("127.0.0.5");
|
||||
ABTS_PTR_NOTNULL(tc, gtpu);
|
||||
|
||||
/* Send NG-Setup Reqeust */
|
||||
sendbuf = testngap_build_ng_setup_request(0x4000, 23);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive NG-Setup Response */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/********** Insert Subscriber in Database */
|
||||
collection = mongoc_client_get_collection(
|
||||
ogs_mongoc()->client, ogs_mongoc()->name, "subscribers");
|
||||
ABTS_PTR_NOTNULL(tc, collection);
|
||||
doc = BCON_NEW("imsi", BCON_UTF8(test_ue.imsi));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
|
||||
count = mongoc_collection_count (
|
||||
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
|
||||
if (count) {
|
||||
ABTS_TRUE(tc, mongoc_collection_remove(collection,
|
||||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
}
|
||||
bson_destroy(doc);
|
||||
|
||||
doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_TRUE(tc, mongoc_collection_insert(collection,
|
||||
MONGOC_INSERT_NONE, doc, NULL, &error));
|
||||
bson_destroy(doc);
|
||||
|
||||
doc = BCON_NEW("imsi", BCON_UTF8(test_ue.imsi));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
do {
|
||||
count = mongoc_collection_count (
|
||||
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
|
||||
} while (count == 0);
|
||||
bson_destroy(doc);
|
||||
|
||||
/* Send Registration request */
|
||||
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;
|
||||
nasbuf = testgmm_build_registration_request(&test_ue, NULL);
|
||||
ABTS_PTR_NOTNULL(tc, nasbuf);
|
||||
|
||||
sendbuf = testngap_build_initial_ue_message(&test_ue, gmmbuf, false);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive Authentication request */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send Authentication response */
|
||||
gmmbuf = testgmm_build_authentication_response(&test_ue);
|
||||
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 Security mode command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send Security mode complete */
|
||||
gmmbuf = testgmm_build_security_mode_complete(&test_ue, nasbuf);
|
||||
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 Initial context setup request */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send UE radio capability info indication */
|
||||
sendbuf = testngap_build_ue_radio_capability_info_indication(&test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* 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 Registration complete */
|
||||
gmmbuf = testgmm_build_registration_complete(&test_ue);
|
||||
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 Configuration update command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Send UE context release request */
|
||||
sendbuf = testngap_build_ue_context_release_request(&test_ue,
|
||||
NGAP_Cause_PR_radioNetwork, NGAP_CauseRadioNetwork_user_inactivity,
|
||||
true);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive UE context release command */
|
||||
recvbuf = testgnb_ngap_read(ngap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
testngap_recv(&test_ue, recvbuf);
|
||||
|
||||
/* Send UE context release complete */
|
||||
sendbuf = testngap_build_ue_context_release_complete(&test_ue);
|
||||
ABTS_PTR_NOTNULL(tc, sendbuf);
|
||||
rv = testgnb_ngap_send(ngap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/*
|
||||
* Send Service request Using InitialUEMessage
|
||||
* - PDU Session Status
|
||||
*/
|
||||
test_ue.service_request_param.integrity_protected = 0;
|
||||
test_ue.service_request_param.pdu_session_status = 1;
|
||||
nasbuf = testgmm_build_service_request(&test_ue, NULL);
|
||||
ABTS_PTR_NOTNULL(tc, nasbuf);
|
||||
|
||||
test_ue.service_request_param.integrity_protected = 1;
|
||||
test_ue.service_request_param.pdu_session_status = 0;
|
||||
gmmbuf = testgmm_build_service_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 Service 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_status);
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/********** Remove Subscriber in Database */
|
||||
doc = BCON_NEW("imsi", BCON_UTF8(test_ue.imsi));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_TRUE(tc, mongoc_collection_remove(collection,
|
||||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
bson_destroy(doc);
|
||||
|
||||
mongoc_collection_destroy(collection);
|
||||
|
||||
/* gNB disonncect from UPF */
|
||||
testgnb_gtpu_close(gtpu);
|
||||
|
||||
/* gNB disonncect from AMF */
|
||||
testgnb_ngap_close(ngap);
|
||||
|
||||
/* Clear Test UE Context */
|
||||
test_ue_remove(&test_ue);
|
||||
}
|
||||
|
||||
abts_suite *test_idle(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
@ -1767,6 +2191,7 @@ abts_suite *test_idle(abts_suite *suite)
|
|||
abts_run_test(suite, test2_func, NULL);
|
||||
abts_run_test(suite, test3_func, NULL);
|
||||
abts_run_test(suite, test4_func, NULL);
|
||||
abts_run_test(suite, test5_func, NULL);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue