diff --git a/lib/core/ogs-errno.h b/lib/core/ogs-errno.h index a18631bb4..78cbd3c05 100644 --- a/lib/core/ogs-errno.h +++ b/lib/core/ogs-errno.h @@ -74,11 +74,12 @@ typedef int ogs_err_t; #endif -#define OGS_OK 0 -#define OGS_ERROR -1 -#define OGS_RETRY -2 -#define OGS_TIMEUP -3 -#define OGS_DONE -4 +#define OGS_OK 0 +#define OGS_ERROR -1 +#define OGS_RETRY -2 +#define OGS_TIMEUP -3 +#define OGS_DONE -4 +#define OGS_NOTFOUND -5 char *ogs_strerror(ogs_err_t err, char *buf, size_t size); diff --git a/lib/core/ogs-pkbuf.c b/lib/core/ogs-pkbuf.c index b8d4b716c..85eb90ae6 100644 --- a/lib/core/ogs-pkbuf.c +++ b/lib/core/ogs-pkbuf.c @@ -318,6 +318,7 @@ ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line) newbuf = ogs_pkbuf_alloc_debug(NULL, size, file_line); if (!newbuf) { ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size); + ogs_pkbuf_free(pkbuf); return NULL; } @@ -344,6 +345,7 @@ ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line) ogs_pool_alloc(&pool->pkbuf, &newbuf); if (!newbuf) { ogs_error("ogs_pkbuf_copy() failed"); + ogs_pkbuf_free(pkbuf); ogs_thread_mutex_unlock(&pool->mutex); return NULL; } diff --git a/src/amf/amf-sm.c b/src/amf/amf-sm.c index 6a68da658..95a4c4c4d 100644 --- a/src/amf/amf-sm.c +++ b/src/amf/amf-sm.c @@ -45,7 +45,7 @@ void amf_state_final(ogs_fsm_t *s, amf_event_t *e) void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) { - int rv; + int r, rv; char buf[OGS_ADDRSTRLEN]; const char *api_version = NULL; @@ -621,9 +621,10 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) } ogs_error("[%s] Cannot receive SBI message", amf_ue->suci); - ogs_expect(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi(amf_ue, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); + r = nas_5gs_send_gmm_reject_from_sbi(amf_ue, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case OGS_SBI_OBJ_SESS_TYPE: @@ -638,16 +639,17 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) ogs_error("[%d:%d] Cannot receive SBI message", sess->psi, sess->pti); if (sess->payload_container_type) { - ogs_expect(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_transport, - NGAP_CauseTransport_transport_resource_unavailable) - ); + NGAP_CauseTransport_transport_resource_unavailable); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -755,10 +757,11 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) ogs_fsm_dispatch(&gnb->sm, e); } else { ogs_error("Cannot decode NGAP message"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, NULL, NULL, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + NGAP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } ogs_ngap_free(&ngap_message); @@ -776,7 +779,9 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) pkbuf = e->pkbuf; ogs_assert(pkbuf); - ogs_expect(OGS_OK == ngap_send_to_ran_ue(ran_ue, pkbuf)); + r = ngap_send_to_ran_ue(ran_ue, pkbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_timer_delete(e->timer); break; case AMF_TIMER_NG_HOLDING: @@ -811,11 +816,13 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) if (!amf_ue) { amf_ue = amf_ue_add(ran_ue); if (amf_ue == NULL) { - ogs_expect(OGS_OK == - ngap_send_ran_ue_context_release_command(ran_ue, + r = ngap_send_ran_ue_context_release_command( + ran_ue, NGAP_Cause_PR_misc, NGAP_CauseMisc_control_processing_overload, - NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_pkbuf_free(pkbuf); return; } @@ -871,10 +878,11 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) /* De-associate NG with NAS/EMM */ ran_ue_deassociate(amf_ue->ran_ue); - ogs_expect(OGS_OK == - ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, + r = ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release, - NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } amf_ue_associate_ran_ue(amf_ue, ran_ue); diff --git a/src/amf/gmm-handler.c b/src/amf/gmm-handler.c index 163a6c73e..1a2472bae 100644 --- a/src/amf/gmm-handler.c +++ b/src/amf/gmm-handler.c @@ -548,7 +548,7 @@ ogs_nas_5gmm_cause_t gmm_handle_service_update(amf_ue_t *amf_ue, { amf_sess_t *sess = NULL; uint16_t psimask = 0; - int xact_count = 0; + int xact_count = 0, r; ogs_nas_uplink_data_status_t *uplink_data_status = NULL; ogs_nas_pdu_session_status_t *pdu_session_status = NULL; @@ -634,9 +634,11 @@ ogs_nas_5gmm_cause_t gmm_handle_service_update(amf_ue_t *amf_ue, } } - if (amf_sess_xact_count(amf_ue) == xact_count) - ogs_assert(OGS_OK == - nas_5gs_send_service_accept(amf_ue)); + if (amf_sess_xact_count(amf_ue) == xact_count) { + r = nas_5gs_send_service_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } return OGS_5GMM_CAUSE_REQUEST_ACCEPTED; } @@ -644,6 +646,7 @@ ogs_nas_5gmm_cause_t gmm_handle_service_update(amf_ue_t *amf_ue, int gmm_handle_deregistration_request(amf_ue_t *amf_ue, ogs_nas_5gs_deregistration_request_from_ue_t *deregistration_request) { + int r; ogs_nas_de_registration_type_t *de_registration_type = NULL; ogs_assert(amf_ue); @@ -690,9 +693,11 @@ int gmm_handle_deregistration_request(amf_ue_t *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) - ogs_assert(OGS_OK == - nas_5gs_send_de_registration_accept(amf_ue)); + if (ogs_list_count(&amf_ue->sess_list) == 0) { + r = nas_5gs_send_de_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } return OGS_OK; } @@ -885,6 +890,7 @@ ogs_nas_5gmm_cause_t gmm_handle_security_mode_complete(amf_ue_t *amf_ue, int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, ogs_nas_5gs_ul_nas_transport_t *ul_nas_transport) { + int r; ogs_slice_data_t *selected_slice = NULL; amf_sess_t *sess = NULL; amf_nsmf_pdusession_sm_context_param_t param; @@ -906,34 +912,38 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!payload_container_type->value) { ogs_error("[%s] No Payload container type", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); + r = nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!payload_container->length) { ogs_error("[%s] No Payload container length", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); + r = nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!payload_container->buffer) { ogs_error("[%s] No Payload container buffer", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); + r = nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if ((ul_nas_transport->presencemask & OGS_NAS_5GS_UL_NAS_TRANSPORT_PDU_SESSION_ID_PRESENT) == 0) { ogs_error("[%s] No PDU session ID", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); + r = nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -941,9 +951,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (*pdu_session_id == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("[%s] PDU session identity is unassigned", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); + r = nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -964,9 +975,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!sess) { ogs_error("[%s] No Session Context [%d]", amf_ue->supi, gsm_header->message_type); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status(amf_ue, - OGS_5GMM_CAUSE_INSUFFICIENT_USER_PLANE_RESOURCES_FOR_THE_PDU_SESSION)); + r = nas_5gs_send_gmm_status(amf_ue, + OGS_5GMM_CAUSE_INSUFFICIENT_USER_PLANE_RESOURCES_FOR_THE_PDU_SESSION); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } } @@ -1072,8 +1084,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!selected_slice || !sess->dnn) { ogs_warn("[%s] DNN Not Supported OR " "Not Subscribed in the Slice", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status(amf_ue, OGS_5GMM_CAUSE_DNN_NOT_SUPPORTED_OR_NOT_SUBSCRIBED_IN_THE_SLICE)); + r = nas_5gs_send_gmm_status(amf_ue, + OGS_5GMM_CAUSE_DNN_NOT_SUPPORTED_OR_NOT_SUBSCRIBED_IN_THE_SLICE); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -1137,9 +1151,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("[%s:%d] Session Context is not in SMF [%d]", amf_ue->supi, sess->psi, gsm_header->message_type); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_DNN_NOT_SUPPORTED_OR_NOT_SUBSCRIBED_IN_THE_SLICE, 0)); + r = nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_DNN_NOT_SUPPORTED_OR_NOT_SUBSCRIBED_IN_THE_SLICE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -1192,9 +1207,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, memset(¶m, 0, sizeof(param)); param.acknowledgement_requested = 1; param.guti = 1; - ogs_assert(OGS_OK == - nas_5gs_send_configuration_update_command( - amf_ue, ¶m)); + r = nas_5gs_send_configuration_update_command( + amf_ue, ¶m); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_PAGING_INFO(amf_ue); } @@ -1212,9 +1228,10 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, default: ogs_error("[%s] Unknown Payload container type [%d]", amf_ue->supi, payload_container_type->value); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status(amf_ue, - OGS_5GMM_CAUSE_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED)); + r = nas_5gs_send_gmm_status(amf_ue, + OGS_5GMM_CAUSE_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } diff --git a/src/amf/gmm-sm.c b/src/amf/gmm-sm.c index cf5796b6f..19f30a3b9 100644 --- a/src/amf/gmm-sm.c +++ b/src/amf/gmm-sm.c @@ -58,7 +58,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e) ogs_sbi_message_t *sbi_message = NULL; - int state = 0; + int r, state = 0; ogs_assert(e); @@ -96,8 +96,9 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e) OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3570.retry_count++; - ogs_assert(OGS_OK == - nas_5gs_send_identity_request(amf_ue)); + r = nas_5gs_send_identity_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -110,9 +111,10 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e) OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3522.retry_count++; - ogs_assert(OGS_OK == - nas_5gs_send_de_registration_request(amf_ue, - OpenAPI_deregistration_reason_NULL)); + r = nas_5gs_send_de_registration_request(amf_ue, + OpenAPI_deregistration_reason_NULL); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -287,9 +289,11 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e) break; CASE(OGS_SBI_HTTP_METHOD_DELETE) - if (state != AMF_NETWORK_INITIATED_DE_REGISTERED) - ogs_assert(OGS_OK == - nas_5gs_send_de_registration_accept(amf_ue)); + if (state != AMF_NETWORK_INITIATED_DE_REGISTERED) { + r = nas_5gs_send_de_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } PCF_AM_POLICY_CLEAR(amf_ue); break; @@ -320,7 +324,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e) void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e) { - int i; + int i, r; amf_ue_t *amf_ue = NULL; amf_sess_t *sess = NULL; @@ -389,7 +393,9 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e) } else { amf_ue->t3513.retry_count++; /* If t3513 is timeout, the saved pkbuf is used. */ - ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + r = ngap_send_paging(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -408,8 +414,9 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e) * If t3555 is timeout, the saved pkbuf is used. * In this case, ack should be set to 1 for timer expiration */ - ogs_assert(OGS_OK == - nas_5gs_send_configuration_update_command(amf_ue, NULL)); + r = nas_5gs_send_configuration_update_command(amf_ue, NULL); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -422,8 +429,9 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e) OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3570.retry_count++; - ogs_assert(OGS_OK == - nas_5gs_send_identity_request(amf_ue)); + r = nas_5gs_send_identity_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -507,7 +515,7 @@ 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, xact_count = 0; + int r, rv, xact_count = 0; ogs_nas_5gmm_cause_t gmm_cause; amf_ue_t *amf_ue = NULL; @@ -548,16 +556,18 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("gmm_handle_registration_request() failed [%d]", gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } if (!AMF_UE_HAVE_SUCI(amf_ue)) { CLEAR_AMF_UE_TIMER(amf_ue->t3570); - ogs_assert(OGS_OK == - nas_5gs_send_identity_request(amf_ue)); + r = nas_5gs_send_identity_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; } @@ -568,8 +578,9 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_registration_update() " "failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -595,8 +606,9 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) } CLEAR_AMF_UE_TIMER(amf_ue->t3550); - ogs_assert(OGS_OK == - nas_5gs_send_registration_accept(amf_ue)); + r = nas_5gs_send_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } if (amf_ue->next.m_tmsi) @@ -628,28 +640,29 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_service_request() failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_service_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_service_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } if (!AMF_UE_HAVE_SUCI(amf_ue)) { ogs_info("Service request : Unknown UE"); - ogs_assert(OGS_OK == - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } if (!h.integrity_protected || !SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_error("No Security Context"); - ogs_assert(OGS_OK == - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -659,8 +672,9 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_service_update() failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_service_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_service_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); } @@ -719,10 +733,11 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) /* De-associate NG with NAS/EMM */ ran_ue_deassociate(amf_ue->ran_ue); - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, + r = ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, NGAP_Cause_PR_misc, NGAP_CauseMisc_om_intervention, - NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &gmm_state_de_registered); break; @@ -789,7 +804,7 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) { - int rv; + int r, rv; ogs_nas_5gmm_cause_t gmm_cause; amf_ue_t *amf_ue = NULL; @@ -835,8 +850,9 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) amf_ue, &nas_message->gmm.authentication_response); if (rv != OGS_OK) { - ogs_assert(OGS_OK == - nas_5gs_send_authentication_reject(amf_ue)); + r = nas_5gs_send_authentication_reject(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } break; @@ -893,8 +909,9 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) break; } - ogs_assert(OGS_OK == - nas_5gs_send_authentication_reject(amf_ue)); + r = nas_5gs_send_authentication_reject(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; @@ -906,8 +923,9 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_registration_request() failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -944,17 +962,15 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) amf_timer_cfg(AMF_TIMER_T3560)->max_count) { ogs_warn("[%s] Retransmission failed. Stop retransmission", amf_ue->suci); - ogs_assert(OGS_OK == - nas_5gs_send_authentication_reject(amf_ue)); + r = nas_5gs_send_authentication_reject(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { - rv = nas_5gs_send_authentication_request(amf_ue); - if (rv == OGS_OK) { - amf_ue->t3560.retry_count++; - } else { - ogs_error("nas_5gs_send_authentication_request() failed"); - OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); - } + amf_ue->t3560.retry_count++; + r = nas_5gs_send_authentication_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -982,9 +998,10 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) ogs_error("[%s] HTTP response error [%d]", amf_ue->suci, sbi_message->res_status); } - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, sbi_message->res_status)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, sbi_message->res_status); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -996,8 +1013,9 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) if (rv != OGS_OK) { ogs_error("[%s] Cannot handle SBI message", amf_ue->suci); - ogs_assert(OGS_OK == - nas_5gs_send_authentication_reject(amf_ue)); + r = nas_5gs_send_authentication_reject(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } break; @@ -1007,8 +1025,9 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) if (rv != OGS_OK) { ogs_error("[%s] Cannot handle SBI message", amf_ue->suci); - ogs_assert(OGS_OK == - nas_5gs_send_authentication_reject(amf_ue)); + r = nas_5gs_send_authentication_reject(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_security_mode); @@ -1042,7 +1061,7 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) { - int rv; + int r; ogs_nas_5gmm_cause_t gmm_cause; amf_ue_t *amf_ue = NULL; ogs_nas_5gs_message_t *nas_message = NULL; @@ -1059,8 +1078,9 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) switch (e->h.id) { case OGS_FSM_ENTRY_SIG: CLEAR_AMF_UE_TIMER(amf_ue->t3560); - ogs_assert(OGS_OK == - nas_5gs_send_security_mode_command(amf_ue)); + r = nas_5gs_send_security_mode_command(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case OGS_FSM_EXIT_SIG: break; @@ -1109,8 +1129,9 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) ogs_error("[%s] gmm_handle_security_mode_complete() " "failed [%d] in type [%d]", amf_ue->suci, gmm_cause, amf_ue->nas.message_type); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_gmm_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -1151,8 +1172,9 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_registration_request() failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -1167,10 +1189,10 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) case OGS_NAS_5GS_SERVICE_REQUEST: ogs_info("[%s] Service request", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &gmm_state_exception); break; @@ -1199,18 +1221,16 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) if (amf_ue->t3560.retry_count >= amf_timer_cfg(AMF_TIMER_T3560)->max_count) { ogs_warn("[%s] Retransmission failed. Stop", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject(amf_ue, - OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); + r = nas_5gs_send_gmm_reject(amf_ue, + OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { - rv = nas_5gs_send_security_mode_command(amf_ue); - if (rv == OGS_OK) { - amf_ue->t3560.retry_count++; - } else { - ogs_error("nas_5gs_send_security_mode_command() failed"); - OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); - } + amf_ue->t3560.retry_count++; + r = nas_5gs_send_security_mode_command(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -1227,7 +1247,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, state, xact_count = 0; + int rv, r, state, xact_count = 0; ogs_nas_5gmm_cause_t gmm_cause; amf_ue_t *amf_ue = NULL; @@ -1274,9 +1294,10 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) sbi_message->res_status != OGS_SBI_HTTP_STATUS_OK) { ogs_error("[%s] HTTP response error [%d]", amf_ue->supi, sbi_message->res_status); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject( - amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); + r = nas_5gs_send_gmm_reject( + amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -1316,9 +1337,10 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) (sbi_message->res_status != OGS_SBI_HTTP_STATUS_CREATED)) { ogs_error("[%s] HTTP response error [%d]", amf_ue->supi, sbi_message->res_status); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject( - amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); + r = nas_5gs_send_gmm_reject( + amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -1328,9 +1350,10 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) if (rv != OGS_OK) { ogs_error("[%s] amf_nudm_sdm_handle_provisioned(%s) failed", amf_ue->supi, sbi_message->h.resource.component[1]); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject( - amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); + r = nas_5gs_send_gmm_reject( + amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -1360,8 +1383,9 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) ogs_assert(amf_ue->nas.message_type == OGS_NAS_5GS_REGISTRATION_REQUEST); CLEAR_AMF_UE_TIMER(amf_ue->t3550); - ogs_assert(OGS_OK == - nas_5gs_send_registration_accept(amf_ue)); + r = nas_5gs_send_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* In nsmf-handler.c * @@ -1465,8 +1489,9 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) */ memset(¶m, 0, sizeof(param)); param.nitz = 1; - ogs_assert(OGS_OK == - nas_5gs_send_configuration_update_command(amf_ue, ¶m)); + r = nas_5gs_send_configuration_update_command(amf_ue, ¶m); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &gmm_state_registered); break; @@ -1479,8 +1504,9 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_registration_request() failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -1499,10 +1525,10 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) case OGS_NAS_5GS_SERVICE_REQUEST: ogs_info("[%s] Service request", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &gmm_state_exception); break; @@ -1534,13 +1560,10 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) amf_ue->suci); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { - rv = nas_5gs_send_registration_accept(amf_ue); - if (rv == OGS_OK) { - amf_ue->t3550.retry_count++; - } else { - ogs_error("nas_5gs_send_registration_accept() failed"); - OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); - } + amf_ue->t3550.retry_count++; + r = nas_5gs_send_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -1557,7 +1580,7 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) { - int xact_count = 0; + int xact_count = 0, r; ogs_nas_5gmm_cause_t gmm_cause; amf_ue_t *amf_ue = NULL; @@ -1588,11 +1611,13 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) amf_sbi_send_release_all_sessions( amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); - if (ogs_list_count(&amf_ue->sess_list) == 0) - ogs_assert(OGS_OK == - ngap_send_amf_ue_context_release_command(amf_ue, + if (ogs_list_count(&amf_ue->sess_list) == 0) { + r = ngap_send_amf_ue_context_release_command(amf_ue, NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release, - NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } break; case OGS_FSM_EXIT_SIG: break; @@ -1617,16 +1642,18 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("gmm_handle_registration_request() failed [%d]", gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } if (!AMF_UE_HAVE_SUCI(amf_ue)) { CLEAR_AMF_UE_TIMER(amf_ue->t3570); - ogs_assert(OGS_OK == - nas_5gs_send_identity_request(amf_ue)); + r = nas_5gs_send_identity_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &gmm_state_de_registered); break; @@ -1639,8 +1666,9 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) if (gmm_cause != OGS_5GMM_CAUSE_REQUEST_ACCEPTED) { ogs_error("[%s] gmm_handle_registration_update() " "failed [%d]", amf_ue->suci, gmm_cause); - ogs_assert(OGS_OK == - nas_5gs_send_registration_reject(amf_ue, gmm_cause)); + r = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -1664,8 +1692,9 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) } CLEAR_AMF_UE_TIMER(amf_ue->t3550); - ogs_assert(OGS_OK == - nas_5gs_send_registration_accept(amf_ue)); + r = nas_5gs_send_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } if (amf_ue->next.m_tmsi) diff --git a/src/amf/namf-handler.c b/src/amf/namf-handler.c index 3bfe368f9..0c2325f4b 100644 --- a/src/amf/namf-handler.c +++ b/src/amf/namf-handler.c @@ -27,7 +27,7 @@ int amf_namf_comm_handle_n1_n2_message_transfer( ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { - int status; + int status, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -206,7 +206,9 @@ int amf_namf_comm_handle_n1_n2_message_transfer( * sm-context-ref is created in [1-CLIENT]. * So, the PDU session establishment accpet can be transmitted. */ - ogs_expect(OGS_OK == ngap_send_to_ran_ue(ran_ue, ngapbuf)); + r = ngap_send_to_ran_ue(ran_ue, ngapbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { sess->pdu_session_establishment_accept = ngapbuf; } @@ -285,12 +287,15 @@ int amf_namf_comm_handle_n1_n2_message_transfer( AMF_SESS_STORE_N2_TRANSFER( sess, pdu_session_resource_setup_request, n2buf); - ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + r = ngap_send_paging(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (CM_CONNECTED(amf_ue)) { - ogs_assert(OGS_OK == - nas_send_pdu_session_setup_request(sess, NULL, n2buf)); + r = nas_send_pdu_session_setup_request(sess, NULL, n2buf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { @@ -349,12 +354,15 @@ int amf_namf_comm_handle_n1_n2_message_transfer( OGS_NAS_5GS_PDU_SESSION_MODIFICATION_COMMAND, n1buf, n2buf); - ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + r = ngap_send_paging(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (CM_CONNECTED(amf_ue)) { - ogs_expect(OGS_OK == - nas_send_pdu_session_modification_command(sess, n1buf, n2buf)); + r = nas_send_pdu_session_modification_command(sess, n1buf, n2buf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_fatal("[%s] Invalid AMF-UE state", amf_ue->supi); @@ -386,8 +394,9 @@ int amf_namf_comm_handle_n1_n2_message_transfer( } } else if (CM_CONNECTED(amf_ue)) { - ogs_expect(OGS_OK == - nas_send_pdu_session_release_command(sess, NULL, n2buf)); + r = nas_send_pdu_session_release_command(sess, NULL, n2buf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_fatal("[%s] Invalid AMF-UE state", amf_ue->supi); ogs_assert_if_reached(); @@ -512,11 +521,13 @@ cleanup: static int do_network_initiated_de_register( amf_ue_t *amf_ue, OpenAPI_deregistration_reason_e dereg_reason) { + int r; if ((CM_CONNECTED(amf_ue)) && (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered))) { - ogs_assert(OGS_OK == - nas_5gs_send_de_registration_request(amf_ue, dereg_reason)); + r = nas_5gs_send_de_registration_request(amf_ue, dereg_reason); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); amf_sbi_send_release_all_sessions( amf_ue, AMF_NETWORK_INITIATED_DE_REGISTERED); @@ -809,6 +820,7 @@ int amf_namf_callback_handle_sdm_data_change_notify( ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { int status = OGS_SBI_HTTP_STATUS_NO_CONTENT; + int r; amf_ue_t *amf_ue = NULL; @@ -905,8 +917,9 @@ int amf_namf_callback_handle_sdm_data_change_notify( ngapbuf = ngap_build_ue_context_modification_request(amf_ue); ogs_assert(ngapbuf); - if (nas_5gs_send_to_gnb(amf_ue, ngapbuf) != OGS_OK) - ogs_error("nas_5gs_send_to_gnb() failed"); + r = nas_5gs_send_to_gnb(amf_ue, ngapbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } cleanup: diff --git a/src/amf/nas-path.c b/src/amf/nas-path.c index 3c492feeb..b667a17d3 100644 --- a/src/amf/nas-path.c +++ b/src/amf/nas-path.c @@ -24,16 +24,20 @@ int nas_5gs_send_to_gnb(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf) { + int rv; ogs_assert(pkbuf); amf_ue = amf_ue_cycle(amf_ue); if (!amf_ue) { - ogs_warn("UE(amf-ue) context has already been removed"); + ogs_error("UE(amf-ue) context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } - return ngap_send_to_ran_ue(amf_ue->ran_ue, pkbuf); + rv = ngap_send_to_ran_ue(amf_ue->ran_ue, pkbuf); + ogs_expect(rv == OGS_OK); + + return rv; } int nas_5gs_send_to_downlink_nas_transport(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf) @@ -46,21 +50,24 @@ int nas_5gs_send_to_downlink_nas_transport(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf) amf_ue = amf_ue_cycle(amf_ue); if (!amf_ue) { - ogs_warn("UE(amf-ue) context has already been removed"); + ogs_error("UE(amf-ue) context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ran_ue = ran_ue_cycle(amf_ue->ran_ue); if (!ran_ue) { - ogs_warn("NG context has already been removed"); + ogs_error("NG context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ngapbuf = ngap_build_downlink_nas_transport( ran_ue, pkbuf, false, false); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_downlink_nas_transport() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -80,26 +87,37 @@ int nas_5gs_send_registration_accept(amf_ue_t *amf_ue) ogs_assert(amf_ue); ran_ue = ran_ue_cycle(amf_ue->ran_ue); - ogs_expect_or_return_val(ran_ue, OGS_ERROR); + if (!ran_ue) { + ogs_error("NG context has already been removed"); + return OGS_NOTFOUND; + } ogs_debug("[%s] Registration accept", amf_ue->supi); if (amf_ue->next.m_tmsi) { if (amf_ue->t3550.pkbuf) { gmmbuf = amf_ue->t3550.pkbuf; - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_registration_accept(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_registration_accept() failed"); + return OGS_ERROR; + } } amf_ue->t3550.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3550.pkbuf, OGS_ERROR); + if (!amf_ue->t3550.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3550.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3550.timer, amf_timer_cfg(AMF_TIMER_T3550)->duration); } else { gmmbuf = gmm_build_registration_accept(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_registration_accept() failed"); + return OGS_ERROR; + } } /* @@ -125,31 +143,41 @@ int nas_5gs_send_registration_accept(amf_ue_t *amf_ue) if (ran_ue->initial_context_setup_request_sent == false && (ran_ue->ue_context_requested == true || transfer_needed == true)) { ngapbuf = ngap_ue_build_initial_context_setup_request(amf_ue, gmmbuf); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_ue_build_initial_context_setup_request() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); ran_ue->initial_context_setup_request_sent = true; } else { if (transfer_needed == true) { ngapbuf = ngap_ue_build_pdu_session_resource_setup_request( amf_ue, gmmbuf); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_ue_build_pdu_session_resource_setup_request()" + " failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); } else { ngapbuf = ngap_build_downlink_nas_transport( ran_ue, gmmbuf, true, true); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_downlink_nas_transport() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); } } - return OGS_OK; + return rv; } int nas_5gs_send_registration_reject( @@ -165,7 +193,10 @@ int nas_5gs_send_registration_reject( ogs_warn("[%s] Registration reject [%d]", amf_ue->suci, gmm_cause); gmmbuf = gmm_build_registration_reject(gmm_cause); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_registration_reject() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); @@ -184,12 +215,18 @@ int nas_5gs_send_service_accept(amf_ue_t *amf_ue) ogs_assert(amf_ue); ran_ue = ran_ue_cycle(amf_ue->ran_ue); - ogs_expect_or_return_val(ran_ue, OGS_ERROR); + if (!ran_ue) { + ogs_error("NG context has already been removed"); + return OGS_NOTFOUND; + } ogs_debug("[%s] Service accept", amf_ue->supi); gmmbuf = gmm_build_service_accept(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_registration_reject() failed"); + return OGS_ERROR; + } /* * Previously, AMF would sends PDUSessionResourceSetupRequest @@ -214,27 +251,34 @@ int nas_5gs_send_service_accept(amf_ue_t *amf_ue) if (ran_ue->initial_context_setup_request_sent == false && (ran_ue->ue_context_requested == true || transfer_needed == true)) { ngapbuf = ngap_ue_build_initial_context_setup_request(amf_ue, gmmbuf); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_ue_build_initial_context_setup_request() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); ran_ue->initial_context_setup_request_sent = true; } else { if (transfer_needed == true) { ngapbuf = ngap_ue_build_pdu_session_resource_setup_request( amf_ue, gmmbuf); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_ue_build_pdu_session_resource_setup_request()" + " failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); } else { rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); } } - return OGS_OK; + return rv; } int nas_5gs_send_service_reject( @@ -248,7 +292,10 @@ int nas_5gs_send_service_reject( ogs_debug("[%s] Service reject", amf_ue->supi); gmmbuf = gmm_build_service_reject(amf_ue, gmm_cause); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_registration_reject() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); @@ -265,7 +312,10 @@ int nas_5gs_send_de_registration_accept(amf_ue_t *amf_ue) ogs_assert(amf_ue); ran_ue = ran_ue_cycle(amf_ue->ran_ue); - ogs_expect_or_return_val(ran_ue, OGS_ERROR); + if (!ran_ue) { + ogs_error("NG context has already been removed"); + return OGS_NOTFOUND; + } ogs_debug("[%s] De-registration accept", amf_ue->supi); @@ -273,10 +323,16 @@ int nas_5gs_send_de_registration_accept(amf_ue_t *amf_ue) int rv; gmmbuf = gmm_build_de_registration_accept(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_registration_reject() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + if (rv != OGS_OK) { + ogs_error("nas_5gs_send_to_downlink_nas_transport() failed"); + return rv; + } } rv = ngap_send_ran_ue_context_release_command(ran_ue, @@ -297,25 +353,33 @@ int nas_5gs_send_de_registration_request(amf_ue_t *amf_ue, ogs_assert(amf_ue); ran_ue = ran_ue_cycle(amf_ue->ran_ue); - ogs_expect_or_return_val(ran_ue, OGS_ERROR); + if (!ran_ue) { + ogs_error("NG context has already been removed"); + return OGS_NOTFOUND; + } ogs_debug("[%s] De-registration request", amf_ue->supi); if (amf_ue->t3522.pkbuf) { gmmbuf = amf_ue->t3522.pkbuf; - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_de_registration_request(amf_ue, dereg_reason); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_de_registration_request() failed"); + return OGS_ERROR; + } } amf_ue->t3522.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3522.pkbuf, OGS_ERROR); + if (!amf_ue->t3522.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3522.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3522.timer, amf_timer_cfg(AMF_TIMER_T3522)->duration); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); return rv; } @@ -331,14 +395,19 @@ int nas_5gs_send_identity_request(amf_ue_t *amf_ue) if (amf_ue->t3570.pkbuf) { gmmbuf = amf_ue->t3570.pkbuf; - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_identity_request(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_identity_request() failed"); + return OGS_ERROR; + } } amf_ue->t3570.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3570.pkbuf, OGS_ERROR); + if (!amf_ue->t3570.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3570.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3570.timer, amf_timer_cfg(AMF_TIMER_T3570)->duration); @@ -359,14 +428,19 @@ int nas_5gs_send_authentication_request(amf_ue_t *amf_ue) if (amf_ue->t3560.pkbuf) { gmmbuf = amf_ue->t3560.pkbuf; - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_authentication_request(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_authentication_request() failed"); + return OGS_ERROR; + } } amf_ue->t3560.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3560.pkbuf, OGS_ERROR); + if (!amf_ue->t3560.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3560.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3560.timer, amf_timer_cfg(AMF_TIMER_T3560)->duration); @@ -388,7 +462,10 @@ int nas_5gs_send_authentication_reject(amf_ue_t *amf_ue) ogs_warn("[%s] Authentication reject", amf_ue->suci); gmmbuf = gmm_build_authentication_reject(); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_authentication_reject() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); @@ -407,14 +484,19 @@ int nas_5gs_send_security_mode_command(amf_ue_t *amf_ue) if (amf_ue->t3560.pkbuf) { gmmbuf = amf_ue->t3560.pkbuf; - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_security_mode_command(amf_ue); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_security_mode_command() failed"); + return OGS_ERROR; + } } amf_ue->t3560.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3560.pkbuf, OGS_ERROR); + if (!amf_ue->t3560.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3560.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3560.timer, amf_timer_cfg(AMF_TIMER_T3560)->duration); @@ -436,21 +518,32 @@ int nas_5gs_send_configuration_update_command( if (amf_ue->t3555.pkbuf) { gmmbuf = amf_ue->t3555.pkbuf; - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); amf_ue->t3555.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3555.pkbuf, OGS_ERROR); + if (!amf_ue->t3555.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3555.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3555.timer, amf_timer_cfg(AMF_TIMER_T3555)->duration); } else { - ogs_expect_or_return_val(param, OGS_ERROR); + if (!param) { + ogs_error("No param"); + return OGS_ERROR; + } gmmbuf = gmm_build_configuration_update_command(amf_ue, param); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_configuration_update_command() failed"); + return OGS_ERROR; + } if (param->acknowledgement_requested) { amf_ue->t3555.pkbuf = ogs_pkbuf_copy(gmmbuf); - ogs_expect_or_return_val(amf_ue->t3555.pkbuf, OGS_ERROR); + if (!amf_ue->t3555.pkbuf) { + ogs_error("ogs_pkbuf_copy(amf_ue->t3555.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(amf_ue->t3555.timer, amf_timer_cfg(AMF_TIMER_T3555)->duration); } @@ -476,17 +569,17 @@ int nas_send_pdu_session_setup_request(amf_sess_t *sess, ogs_assert(sess); amf_ue = amf_ue_cycle(sess->amf_ue); if (!amf_ue) { - ogs_warn("UE(amf-ue) context has already been removed"); + ogs_error("UE(amf-ue) context has already been removed"); if (n1smbuf) ogs_pkbuf_free(n1smbuf); ogs_pkbuf_free(n2smbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ran_ue = ran_ue_cycle(amf_ue->ran_ue); if (!ran_ue) { ogs_warn("NG context has already been removed"); if (n1smbuf) ogs_pkbuf_free(n1smbuf); ogs_pkbuf_free(n2smbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } if (n1smbuf) { @@ -508,10 +601,7 @@ int nas_send_pdu_session_setup_request(amf_sess_t *sess, } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - if (rv != OGS_OK) { - ogs_error("nas_5gs_send_to_gnb() failed"); - return OGS_ERROR; - } + ogs_expect(rv == OGS_OK); ran_ue->initial_context_setup_request_sent = true; } else { @@ -523,10 +613,7 @@ int nas_send_pdu_session_setup_request(amf_sess_t *sess, } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - if (rv != OGS_OK) { - ogs_error("nas_5gs_send_to_gnb() failed"); - return OGS_ERROR; - } + ogs_expect(rv == OGS_OK); } return rv; @@ -546,17 +633,17 @@ int nas_send_pdu_session_modification_command(amf_sess_t *sess, ogs_assert(sess); amf_ue = amf_ue_cycle(sess->amf_ue); if (!amf_ue) { - ogs_warn("UE(amf-ue) context has already been removed"); + ogs_error("UE(amf-ue) context has already been removed"); if (n1smbuf) ogs_pkbuf_free(n1smbuf); ogs_pkbuf_free(n2smbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ran_ue = ran_ue_cycle(amf_ue->ran_ue); if (!ran_ue) { ogs_warn("NG context has already been removed"); if (n1smbuf) ogs_pkbuf_free(n1smbuf); ogs_pkbuf_free(n2smbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } if (n1smbuf) { @@ -607,17 +694,17 @@ int nas_send_pdu_session_release_command(amf_sess_t *sess, ogs_assert(sess); amf_ue = amf_ue_cycle(sess->amf_ue); if (!amf_ue) { - ogs_warn("UE(amf-ue) context has already been removed"); + ogs_error("UE(amf-ue) context has already been removed"); if (n1smbuf) ogs_pkbuf_free(n1smbuf); ogs_pkbuf_free(n2smbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ran_ue = ran_ue_cycle(amf_ue->ran_ue); if (!ran_ue) { ogs_warn("NG context has already been removed"); if (n1smbuf) ogs_pkbuf_free(n1smbuf); ogs_pkbuf_free(n2smbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } if (n1smbuf) { @@ -689,7 +776,10 @@ int nas_5gs_send_gmm_status(amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t cause) ogs_debug("[%s] 5GMM status", amf_ue->supi); gmmbuf = gmm_build_status(amf_ue, cause); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_status() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); @@ -776,9 +866,12 @@ int nas_5gs_send_dl_nas_transport(amf_sess_t *sess, gmmbuf = gmm_build_dl_nas_transport(sess, payload_container_type, payload_container, cause, backoff_time); - ogs_expect_or_return_val(gmmbuf, OGS_ERROR); + if (!gmmbuf) { + ogs_error("gmm_build_dl_nas_transport() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + ogs_expect(rv == OGS_OK); return rv; } @@ -823,10 +916,13 @@ int nas_5gs_send_back_gsm_message( ogs_assert(sess->payload_container); pbuf = ogs_pkbuf_copy(sess->payload_container); - ogs_expect_or_return_val(pbuf, OGS_ERROR); + if (!pbuf) { + ogs_error("ogs_pkbuf_copy(pbuf) failed"); + return OGS_ERROR; + } - rv = nas_5gs_send_dl_nas_transport(sess, sess->payload_container_type, pbuf, - cause, backoff_time); + rv = nas_5gs_send_dl_nas_transport( + sess, sess->payload_container_type, pbuf, cause, backoff_time); ogs_expect(rv == OGS_OK); return rv; diff --git a/src/amf/nausf-handler.c b/src/amf/nausf-handler.c index 012a225b7..ef94768cd 100644 --- a/src/amf/nausf-handler.c +++ b/src/amf/nausf-handler.c @@ -23,6 +23,7 @@ int amf_nausf_auth_handle_authenticate( amf_ue_t *amf_ue, ogs_sbi_message_t *message) { + int r; OpenAPI_ue_authentication_ctx_t *UeAuthenticationCtx = NULL; OpenAPI_av5g_aka_t *AV5G_AKA = NULL; OpenAPI_links_value_schema_t *LinksValueSchemeValue = NULL; @@ -111,8 +112,9 @@ int amf_nausf_auth_handle_authenticate( amf_ue->nas.ue.ksi = amf_ue->nas.amf.ksi; - ogs_assert(OGS_OK == - nas_5gs_send_authentication_request(amf_ue)); + r = nas_5gs_send_authentication_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_OK; } diff --git a/src/amf/ngap-handler.c b/src/amf/ngap-handler.c index 69247ae3a..21deaf843 100644 --- a/src/amf/ngap-handler.c +++ b/src/amf/ngap-handler.c @@ -100,7 +100,7 @@ static bool maximum_number_of_gnbs_is_reached(void) void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i, j, k; + int i, j, k, r; NGAP_InitiatingMessage_t *initiatingMessage = NULL; NGAP_NGSetupRequest_t *NGSetupRequest = NULL; @@ -148,8 +148,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) ogs_error("No GlobalRANNodeID"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -158,8 +159,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) ogs_error("No globalGNB_ID"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -167,8 +169,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) ogs_error("No SupportedTAList"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -191,8 +194,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) ogs_error("No SupportedTAItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -216,8 +220,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) ogs_error("No BroadcastPLMNItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -248,8 +253,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) ogs_error("No SliceSupportItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -285,8 +291,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) group = NGAP_Cause_PR_misc; cause = NGAP_CauseMisc_control_processing_overload; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -296,8 +303,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_message_not_compatible_with_receiver_state; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -307,8 +315,9 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) group = NGAP_Cause_PR_misc; cause = NGAP_CauseMisc_unknown_PLMN_or_SNPN; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -319,21 +328,23 @@ void ngap_handle_ng_setup_request(amf_gnb_t *gnb, ogs_ngap_message_t *message) group = NGAP_Cause_PR_radioNetwork; cause = NGAP_CauseRadioNetwork_slice_not_supported; - ogs_assert(OGS_OK == - ngap_send_ng_setup_failure(gnb, group, cause)); + r = ngap_send_ng_setup_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } amf_gnb_set_gnb_id(gnb, gnb_id); gnb->state.ng_setup_success = true; - ogs_assert(OGS_OK == - ngap_send_ng_setup_response(gnb)); + r = ngap_send_ng_setup_response(gnb); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) { - int i; + int i, r; char buf[OGS_ADDRSTRLEN]; ran_ue_t *ran_ue = NULL; @@ -389,9 +400,10 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -399,10 +411,11 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) if (!ran_ue) { ran_ue = ran_ue_add(gnb, *RAN_UE_NGAP_ID); if (ran_ue == NULL) { - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, + r = ngap_send_error_indication(gnb, NULL, NULL, NGAP_Cause_PR_misc, - NGAP_CauseMisc_control_processing_overload)); + NGAP_CauseMisc_control_processing_overload); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -456,10 +469,12 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) /* De-associate NG with NAS/EMM */ ran_ue_deassociate(amf_ue->ran_ue); - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, + r = ngap_send_ran_ue_context_release_command( + amf_ue->ran_ue, NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release, - NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } amf_ue_associate_ran_ue(amf_ue, ran_ue); @@ -480,9 +495,10 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -490,17 +506,19 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); + r = ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!NAS_PDU) { ogs_error("No NAS_PDU"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -523,14 +541,15 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) } } - ngap_send_to_nas(ran_ue, NGAP_ProcedureCode_id_InitialUEMessage, NAS_PDU); + ogs_expect(OGS_OK == ngap_send_to_nas( + ran_ue, NGAP_ProcedureCode_id_InitialUEMessage, NAS_PDU)); } void ngap_handle_uplink_nas_transport( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -582,18 +601,20 @@ void ngap_handle_uplink_nas_transport( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -601,11 +622,12 @@ void ngap_handle_uplink_nas_transport( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -613,19 +635,21 @@ void ngap_handle_uplink_nas_transport( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -633,18 +657,20 @@ void ngap_handle_uplink_nas_transport( NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); + r = ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!NAS_PDU) { ogs_error("No NAS_PDU"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -665,14 +691,15 @@ void ngap_handle_uplink_nas_transport( memcpy(&amf_ue->nr_tai, &ran_ue->saved.nr_tai, sizeof(ogs_5gs_tai_t)); memcpy(&amf_ue->nr_cgi, &ran_ue->saved.nr_cgi, sizeof(ogs_nr_cgi_t)); - ngap_send_to_nas(ran_ue, NGAP_ProcedureCode_id_UplinkNASTransport, NAS_PDU); + ogs_expect(OGS_OK == ngap_send_to_nas( + ran_ue, NGAP_ProcedureCode_id_UplinkNASTransport, NAS_PDU)); } void ngap_handle_ue_radio_capability_info_indication( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; ran_ue_t *ran_ue = NULL; uint64_t amf_ue_ngap_id; @@ -721,18 +748,20 @@ void ngap_handle_ue_radio_capability_info_indication( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -740,11 +769,12 @@ void ngap_handle_ue_radio_capability_info_indication( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -753,10 +783,11 @@ void ngap_handle_ue_radio_capability_info_indication( if (!UERadioCapability) { ogs_error("No UERadioCapability"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -769,7 +800,7 @@ void ngap_handle_initial_context_setup_response( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -822,18 +853,20 @@ void ngap_handle_initial_context_setup_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -841,11 +874,12 @@ void ngap_handle_initial_context_setup_response( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -856,11 +890,12 @@ void ngap_handle_initial_context_setup_response( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -870,27 +905,30 @@ void ngap_handle_initial_context_setup_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceSetupItemCxtRes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->pDUSessionResourceSetupResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupResponseTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -898,20 +936,22 @@ void ngap_handle_initial_context_setup_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -963,9 +1003,10 @@ void ngap_handle_initial_context_setup_response( switch (sess->gsm_message.type) { case OGS_NAS_5GS_PDU_SESSION_MODIFICATION_COMMAND: - ogs_expect(OGS_OK == - nas_send_pdu_session_modification_command(sess, - sess->gsm_message.n1buf, sess->gsm_message.n2buf)); + r = nas_send_pdu_session_modification_command(sess, + sess->gsm_message.n1buf, sess->gsm_message.n2buf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* n1buf is de-allocated * in gmm_build_dl_nas_transport() */ @@ -1012,8 +1053,9 @@ void ngap_handle_initial_context_setup_response( memset(¶m, 0, sizeof(param)); param.acknowledgement_requested = 1; param.guti = 1; - ogs_assert(OGS_OK == - nas_5gs_send_configuration_update_command(amf_ue, ¶m)); + r = nas_5gs_send_configuration_update_command(amf_ue, ¶m); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_PAGING_INFO(amf_ue); } @@ -1023,7 +1065,7 @@ void ngap_handle_initial_context_setup_failure( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i, old_xact_count = 0, new_xact_count = 0; + int i, r, old_xact_count = 0, new_xact_count = 0; ran_ue_t *ran_ue = NULL; amf_ue_t *amf_ue = NULL; @@ -1071,18 +1113,20 @@ void ngap_handle_initial_context_setup_failure( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1090,11 +1134,12 @@ void ngap_handle_initial_context_setup_failure( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1103,10 +1148,11 @@ void ngap_handle_initial_context_setup_failure( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } ogs_debug(" Cause[Group:%d Cause:%d]", @@ -1143,10 +1189,11 @@ void ngap_handle_initial_context_setup_failure( } if (old_xact_count == new_xact_count) { - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(ran_ue, + r = 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)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -1307,7 +1354,7 @@ void ngap_handle_ue_context_modification_failure( void ngap_handle_ue_context_release_request( amf_gnb_t *gnb, ogs_ngap_message_t *message) { - int i; + int i, r; char buf[OGS_ADDRSTRLEN]; uint64_t amf_ue_ngap_id; @@ -1362,18 +1409,20 @@ void ngap_handle_ue_context_release_request( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1381,11 +1430,12 @@ void ngap_handle_ue_context_release_request( if (!ran_ue) { ogs_warn("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1394,10 +1444,11 @@ void ngap_handle_ue_context_release_request( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1422,10 +1473,11 @@ void ngap_handle_ue_context_release_request( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(ran_ue, + r = ngap_send_ran_ue_context_release_command(ran_ue, Cause->present, (int)Cause->choice.radioNetwork, - NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { int xact_count = amf_sess_xact_count(amf_ue); @@ -1443,20 +1495,22 @@ void ngap_handle_ue_context_release_request( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceSetupItemSURes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1469,19 +1523,21 @@ void ngap_handle_ue_context_release_request( } } } - - if (amf_sess_xact_count(amf_ue) == xact_count) - ogs_assert(OGS_OK == - ngap_send_amf_ue_context_release_command(amf_ue, + + if (amf_sess_xact_count(amf_ue) == xact_count) { + r = ngap_send_amf_ue_context_release_command(amf_ue, Cause->present, (int)Cause->choice.radioNetwork, - NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0)); + NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } } } void ngap_handle_ue_context_release_complete( amf_gnb_t *gnb, ogs_ngap_message_t *message) { - int i; + int i, r; char buf[OGS_ADDRSTRLEN]; uint64_t amf_ue_ngap_id; @@ -1525,18 +1581,20 @@ void ngap_handle_ue_context_release_complete( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1544,11 +1602,12 @@ void ngap_handle_ue_context_release_complete( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1557,6 +1616,7 @@ void ngap_handle_ue_context_release_complete( void ngap_handle_ue_context_release_action(ran_ue_t *ran_ue) { + int r; amf_ue_t *amf_ue = NULL; ogs_assert(ran_ue); @@ -1619,13 +1679,19 @@ void ngap_handle_ue_context_release_action(ran_ue_t *ran_ue) case NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK: ogs_debug(" Action: NG normal release"); ran_ue_remove(ran_ue); - ogs_expect_or_return(amf_ue); + if (!amf_ue) { + ogs_error("No UE(amf-ue) Context"); + return; + } amf_ue_deassociate(amf_ue); break; case NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE: ogs_debug(" Action: UE context remove"); ran_ue_remove(ran_ue); - ogs_expect_or_return(amf_ue); + if (!amf_ue) { + ogs_error("No UE(amf-ue) context"); + return; + } amf_ue_remove(amf_ue); break; case NGAP_UE_CTX_REL_NG_HANDOVER_COMPLETE: @@ -1634,7 +1700,10 @@ void ngap_handle_ue_context_release_action(ran_ue_t *ran_ue) source_ue_deassociate_target_ue(ran_ue); ran_ue_remove(ran_ue); - ogs_expect_or_return(amf_ue); + if (!amf_ue) { + ogs_error("No UE(amf-ue) context"); + return; + } break; case NGAP_UE_CTX_REL_NG_HANDOVER_CANCEL: ogs_warn(" Action: NG handover cancel"); @@ -1642,11 +1711,18 @@ void ngap_handle_ue_context_release_action(ran_ue_t *ran_ue) source_ue_deassociate_target_ue(ran_ue); ran_ue_remove(ran_ue); - ogs_expect_or_return(amf_ue); - ogs_expect_or_return(amf_ue->ran_ue); + if (!amf_ue) { + ogs_error("No UE(amf-ue) context"); + return; + } + if (!amf_ue->ran_ue) { + ogs_error("No NG context"); + return; + } - ogs_assert(OGS_OK == - ngap_send_handover_cancel_ack(amf_ue->ran_ue)); + r = ngap_send_handover_cancel_ack(amf_ue->ran_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case NGAP_UE_CTX_REL_NG_HANDOVER_FAILURE: ogs_warn(" Action: NG handover failure"); @@ -1654,7 +1730,10 @@ void ngap_handle_ue_context_release_action(ran_ue_t *ran_ue) source_ue_deassociate_target_ue(ran_ue); ran_ue_remove(ran_ue); - ogs_expect_or_return(amf_ue); + if (!amf_ue) { + ogs_error("No UE(amf-ue) context"); + return; + } break; default: ogs_error("Invalid Action[%d]", ran_ue->ue_ctx_rel_action); @@ -1666,7 +1745,7 @@ void ngap_handle_pdu_session_resource_setup_response( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -1727,18 +1806,20 @@ void ngap_handle_pdu_session_resource_setup_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1746,11 +1827,12 @@ void ngap_handle_pdu_session_resource_setup_response( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1761,11 +1843,12 @@ void ngap_handle_pdu_session_resource_setup_response( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1777,33 +1860,36 @@ void ngap_handle_pdu_session_resource_setup_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceSetupItemSURes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->pDUSessionResourceSetupResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupResponseTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1811,20 +1897,22 @@ void ngap_handle_pdu_session_resource_setup_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1856,11 +1944,12 @@ void ngap_handle_pdu_session_resource_setup_response( if (!PDUSessionFailedItem) { ogs_error("No PDUSessionResourceFailedToSetupItemSURes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1869,22 +1958,24 @@ void ngap_handle_pdu_session_resource_setup_response( pDUSessionResourceSetupUnsuccessfulTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupUnsuccessfulTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionFailedItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1893,21 +1984,23 @@ void ngap_handle_pdu_session_resource_setup_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionFailedItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2( + r = ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionFailedItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1969,9 +2062,10 @@ void ngap_handle_pdu_session_resource_setup_response( } } else { ogs_error("No PDUSessionResourceList"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -1979,7 +2073,7 @@ void ngap_handle_pdu_session_resource_modify_response( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -2032,18 +2126,20 @@ void ngap_handle_pdu_session_resource_modify_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2051,11 +2147,12 @@ void ngap_handle_pdu_session_resource_modify_response( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2066,19 +2163,21 @@ void ngap_handle_pdu_session_resource_modify_response( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!PDUSessionList) { ogs_error("No PDUSessionResourceModifyListModRes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2089,27 +2188,30 @@ void ngap_handle_pdu_session_resource_modify_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceModifyItemModRes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->pDUSessionResourceModifyResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceModifyResponseTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2117,20 +2219,22 @@ void ngap_handle_pdu_session_resource_modify_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2154,7 +2258,7 @@ void ngap_handle_pdu_session_resource_release_response( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -2208,18 +2312,20 @@ void ngap_handle_pdu_session_resource_release_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2227,11 +2333,12 @@ void ngap_handle_pdu_session_resource_release_response( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2242,19 +2349,21 @@ void ngap_handle_pdu_session_resource_release_response( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!PDUSessionList) { ogs_error("No PDUSessionResourceReleasedListRelRes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2265,27 +2374,30 @@ void ngap_handle_pdu_session_resource_release_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceReleasedItemRelRes"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->pDUSessionResourceReleaseResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceReleaseResponseTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2293,20 +2405,22 @@ void ngap_handle_pdu_session_resource_release_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2330,7 +2444,7 @@ void ngap_handle_uplink_ran_configuration_transfer( amf_gnb_t *gnb, ogs_ngap_message_t *message, ogs_pkbuf_t *pkbuf) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; NGAP_InitiatingMessage_t *initiatingMessage = NULL; NGAP_UplinkRANConfigurationTransfer_t @@ -2385,18 +2499,20 @@ void ngap_handle_uplink_ran_configuration_transfer( NGAP_GlobalRANNodeID_PR_globalGNB_ID) { ogs_error("Not implemented targetGlobalRANNodeID->present[%d]", targetGlobalRANNodeID->present); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } targetGlobalGNB_ID = targetGlobalRANNodeID->choice.globalGNB_ID; if (!targetGlobalGNB_ID) { ogs_error("No targetGlobalGNB_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2410,18 +2526,20 @@ void ngap_handle_uplink_ran_configuration_transfer( NGAP_GlobalRANNodeID_PR_globalGNB_ID) { ogs_error("Not implemented sourceGlobalRANNodeID->present[%d]", sourceGlobalRANNodeID->present); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } sourceGlobalGNB_ID = sourceGlobalRANNodeID->choice.globalGNB_ID; if (!sourceGlobalGNB_ID) { ogs_error("No sourceGlobalGNB_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2437,15 +2555,17 @@ void ngap_handle_uplink_ran_configuration_transfer( if (!target_gnb) { ogs_error("Uplink RAN configuration transfer : " "cannot find target gNB-id[0x%x]", target_gnb_id); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } - ogs_assert(OGS_OK == - ngap_send_downlink_ran_configuration_transfer( - target_gnb, SONConfigurationTransfer)); + r = ngap_send_downlink_ran_configuration_transfer( + target_gnb, SONConfigurationTransfer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -2453,7 +2573,7 @@ void ngap_handle_path_switch_request( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -2525,26 +2645,29 @@ void ngap_handle_path_switch_request( if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2552,11 +2675,12 @@ void ngap_handle_path_switch_request( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2564,11 +2688,12 @@ void ngap_handle_path_switch_request( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2585,9 +2710,10 @@ void ngap_handle_path_switch_request( if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2595,33 +2721,37 @@ void ngap_handle_path_switch_request( NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!UESecurityCapabilities) { ogs_error("No UESecurityCapabilities"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!PDUSessionResourceToBeSwitchedDLList) { ogs_error("No PDUSessionResourceToBeSwitchedDLList"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_error("No Security Context"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2688,27 +2818,30 @@ void ngap_handle_path_switch_request( if (!PDUSessionItem) { ogs_error("No NGAP_PDUSessionResourceToBeSwitchedDLItem"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->pathSwitchRequestTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupResponseTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2716,20 +2849,22 @@ void ngap_handle_path_switch_request( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2753,7 +2888,7 @@ void ngap_handle_handover_required( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *source_ue = NULL, *target_ue = NULL; @@ -2829,18 +2964,20 @@ void ngap_handle_handover_required( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2848,11 +2985,12 @@ void ngap_handle_handover_required( if (!source_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2863,51 +3001,57 @@ void ngap_handle_handover_required( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &source_ue->ran_ue_ngap_id, &source_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!HandoverType) { ogs_error("No HandoverType"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!TargetID) { ogs_error("No TargetID"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (TargetID->present != NGAP_TargetID_PR_targetRANNodeID) { ogs_error("Not implemented TargetID[%d]", TargetID->present); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } targetRANNodeID = TargetID->choice.targetRANNodeID; if (!targetRANNodeID) { ogs_error("No targetRANNodeID"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2915,18 +3059,20 @@ void ngap_handle_handover_required( if (globalRANNodeID->present != NGAP_GlobalRANNodeID_PR_globalGNB_ID) { ogs_error("Not implemented globalRANNodeID[%d]", globalRANNodeID->present); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } globalGNB_ID = globalRANNodeID->choice.globalGNB_ID; if (!globalGNB_ID) { ogs_error("No globalGNB_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2935,42 +3081,47 @@ void ngap_handle_handover_required( if (!target_gnb) { ogs_error("Handover required : cannot find target gNB-id[0x%x]", target_gnb_id); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!PDUSessionList) { ogs_error("No PDUSessionList"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SourceToTarget_TransparentContainer) { ogs_error("No SourceToTarget_TransparentContainer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_error("No Security Context"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } /* Target UE */ target_ue = ran_ue_add(target_gnb, INVALID_UE_NGAP_ID); if (target_ue == NULL) { - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_misc, - NGAP_CauseMisc_control_processing_overload)); + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_misc, + NGAP_CauseMisc_control_processing_overload); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3007,27 +3158,30 @@ void ngap_handle_handover_required( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceItemHORqd"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->handoverRequiredTransfer; if (!transfer) { ogs_error("No handoverRequiredTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3035,20 +3189,22 @@ void ngap_handle_handover_required( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3075,7 +3231,7 @@ void ngap_handle_handover_request_ack( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *source_ue = NULL, *target_ue = NULL; @@ -3133,26 +3289,29 @@ void ngap_handle_handover_request_ack( if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3160,19 +3319,21 @@ void ngap_handle_handover_request_ack( if (!target_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3182,22 +3343,24 @@ void ngap_handle_handover_request_ack( if (!source_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &target_ue->ran_ue_ngap_id, &target_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } amf_ue = target_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &target_ue->ran_ue_ngap_id, &target_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3208,17 +3371,19 @@ void ngap_handle_handover_request_ack( if (!PDUSessionList) { ogs_error("No PDUSessionList"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!TargetToSource_TransparentContainer) { ogs_error("No TargetToSource_TransparentContainer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3233,27 +3398,30 @@ void ngap_handle_handover_request_ack( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceAdmittedItem"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } transfer = &PDUSessionItem->handoverRequestAcknowledgeTransfer; if (!transfer) { ogs_error("No handoverRequestAcknowledgeTransfer"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3261,20 +3429,22 @@ void ngap_handle_handover_request_ack( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3300,7 +3470,7 @@ void ngap_handle_handover_failure( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; ran_ue_t *source_ue = NULL, *target_ue = NULL; uint64_t amf_ue_ngap_id; @@ -3343,18 +3513,20 @@ void ngap_handle_handover_failure( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3362,11 +3534,12 @@ void ngap_handle_handover_failure( if (!target_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, NULL, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3374,11 +3547,12 @@ void ngap_handle_handover_failure( if (!source_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &target_ue->ran_ue_ngap_id, &target_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3389,29 +3563,32 @@ void ngap_handle_handover_failure( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &target_ue->ran_ue_ngap_id, &target_ue->amf_ue_ngap_id, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } ogs_debug(" Cause[Group:%d Cause:%d]", Cause->present, (int)Cause->choice.radioNetwork); - ogs_assert(OGS_OK == - ngap_send_handover_preparation_failure(source_ue, Cause)); + r = ngap_send_handover_preparation_failure(source_ue, Cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(target_ue, + r = ngap_send_ran_ue_context_release_command(target_ue, NGAP_Cause_PR_radioNetwork, NGAP_CauseRadioNetwork_ho_failure_in_target_5GC_ngran_node_or_target_system, - NGAP_UE_CTX_REL_NG_HANDOVER_FAILURE, 0)); + NGAP_UE_CTX_REL_NG_HANDOVER_FAILURE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void ngap_handle_handover_cancel( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; amf_sess_t *sess = NULL; @@ -3460,18 +3637,20 @@ void ngap_handle_handover_cancel( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3479,11 +3658,12 @@ void ngap_handle_handover_cancel( if (!source_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3491,22 +3671,24 @@ void ngap_handle_handover_cancel( if (!target_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &source_ue->ran_ue_ngap_id, &source_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } amf_ue = source_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &source_ue->ran_ue_ngap_id, &source_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3517,10 +3699,11 @@ void ngap_handle_handover_cancel( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &source_ue->ran_ue_ngap_id, &source_ue->amf_ue_ngap_id, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } ogs_debug(" Cause[Group:%d Cause:%d]", @@ -3544,7 +3727,7 @@ void ngap_handle_uplink_ran_status_transfer( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; ran_ue_t *source_ue = NULL, *target_ue = NULL; @@ -3594,18 +3777,20 @@ void ngap_handle_uplink_ran_status_transfer( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3613,11 +3798,12 @@ void ngap_handle_uplink_ran_status_transfer( if (!source_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3625,22 +3811,24 @@ void ngap_handle_uplink_ran_status_transfer( if (!target_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &source_ue->ran_ue_ngap_id, &source_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } amf_ue = source_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &source_ue->ran_ue_ngap_id, &source_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3649,16 +3837,17 @@ void ngap_handle_uplink_ran_status_transfer( ogs_debug(" Target : RAN_UE_NGAP_ID[%d] AMF_UE_NGAP_ID[%lld] ", target_ue->ran_ue_ngap_id, (long long)target_ue->amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_downlink_ran_status_transfer( - target_ue, RANStatusTransfer_TransparentContainer)); + r = ngap_send_downlink_ran_status_transfer( + target_ue, RANStatusTransfer_TransparentContainer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void ngap_handle_handover_notification( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; amf_ue_t *amf_ue = NULL; amf_sess_t *sess = NULL; @@ -3708,18 +3897,20 @@ void ngap_handle_handover_notification( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3727,11 +3918,12 @@ void ngap_handle_handover_notification( if (!target_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, (uint32_t *)RAN_UE_NGAP_ID, &amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3739,22 +3931,24 @@ void ngap_handle_handover_notification( if (!source_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &target_ue->ran_ue_ngap_id, &target_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_inconsistent_remote_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } amf_ue = target_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ogs_assert(OGS_OK == - ngap_send_error_indication( + r = ngap_send_error_indication( gnb, &target_ue->ran_ue_ngap_id, &target_ue->amf_ue_ngap_id, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3762,9 +3956,10 @@ void ngap_handle_handover_notification( if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3772,9 +3967,10 @@ void ngap_handle_handover_notification( NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); + r = ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3802,12 +3998,13 @@ void ngap_handle_handover_notification( memcpy(&amf_ue->nr_tai, &target_ue->saved.nr_tai, sizeof(ogs_5gs_tai_t)); memcpy(&amf_ue->nr_cgi, &target_ue->saved.nr_cgi, sizeof(ogs_nr_cgi_t)); - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(source_ue, + r = ngap_send_ran_ue_context_release_command(source_ue, NGAP_Cause_PR_radioNetwork, NGAP_CauseRadioNetwork_successful_handover, NGAP_UE_CTX_REL_NG_HANDOVER_COMPLETE, - ogs_app()->time.handover.duration)); + ogs_app()->time.handover.duration); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_list_for_each(&amf_ue->sess_list, sess) { memset(¶m, 0, sizeof(param)); @@ -3825,7 +4022,7 @@ void ngap_handle_ran_configuration_update( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i, j, k; + int i, j, k, r; NGAP_InitiatingMessage_t *initiatingMessage = NULL; NGAP_RANConfigurationUpdate_t *RANConfigurationUpdate = NULL; @@ -3875,8 +4072,9 @@ void ngap_handle_ran_configuration_update( ogs_error("No globalGNB_ID"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure(gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3901,9 +4099,10 @@ void ngap_handle_ran_configuration_update( ogs_error("No SupportedTAItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure( - gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure( + gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3927,9 +4126,10 @@ void ngap_handle_ran_configuration_update( ogs_error("No BroadcastPLMNItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure( - gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure( + gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3960,9 +4160,10 @@ void ngap_handle_ran_configuration_update( ogs_error("No SliceSupportItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure( - gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure( + gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -4001,8 +4202,9 @@ void ngap_handle_ran_configuration_update( cause = NGAP_CauseProtocol_message_not_compatible_with_receiver_state; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure(gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -4013,8 +4215,9 @@ void ngap_handle_ran_configuration_update( group = NGAP_Cause_PR_misc; cause = NGAP_CauseMisc_unknown_PLMN_or_SNPN; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure(gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -4025,8 +4228,9 @@ void ngap_handle_ran_configuration_update( group = NGAP_Cause_PR_radioNetwork; cause = NGAP_CauseRadioNetwork_slice_not_supported; - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_failure(gnb, group, cause)); + r = ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } } @@ -4034,15 +4238,14 @@ void ngap_handle_ran_configuration_update( if (PagingDRX) ogs_debug(" PagingDRX[%ld]", *PagingDRX); - ogs_assert(OGS_OK == - ngap_send_ran_configuration_update_ack(gnb)); + ogs_expect(OGS_OK == ngap_send_ran_configuration_update_ack(gnb)); } void ngap_handle_ng_reset( amf_gnb_t *gnb, ogs_ngap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i, old_xact_count = 0, new_xact_count = 0; + int i, r, old_xact_count = 0, new_xact_count = 0; NGAP_InitiatingMessage_t *initiatingMessage = NULL; NGAP_NGReset_t *NGReset = NULL; @@ -4084,9 +4287,10 @@ void ngap_handle_ng_reset( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -4095,9 +4299,10 @@ void ngap_handle_ng_reset( if (!ResetType) { ogs_error("No ResetType"); - ogs_assert(OGS_OK == - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -4137,9 +4342,11 @@ void ngap_handle_ng_reset( * for new UE-associated logical NG-connections over the NG interface, * the AMF shall respond with the NG RESET ACKNOWLEDGE message. */ - if (ogs_list_count(&gnb->ran_ue_list) == 0) - ogs_assert(OGS_OK == - ngap_send_ng_reset_ack(gnb, NULL)); + if (ogs_list_count(&gnb->ran_ue_list) == 0) { + r = ngap_send_ng_reset_ack(gnb, NULL); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } break; @@ -4153,7 +4360,10 @@ void ngap_handle_ng_reset( ogs_pkbuf_free(gnb->ng_reset_ack); gnb->ng_reset_ack = ogs_ngap_build_ng_reset_ack(partOfNG_Interface); - ogs_expect_or_return(gnb->ng_reset_ack); + if (!gnb->ng_reset_ack) { + ogs_error("ogs_ngap_build_ng_reset_ack() failed"); + return; + } for (i = 0; i < partOfNG_Interface->list.count; i++) { NGAP_UE_associatedLogicalNG_connectionItem_t *item = NULL; @@ -4246,8 +4456,9 @@ void ngap_handle_ng_reset( * where PartOfNG_interface was requested * REMOVED */ ogs_assert(gnb->ng_reset_ack); - ogs_expect(OGS_OK == - ngap_send_to_gnb(gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING)); + r = ngap_send_to_gnb(gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* Clear NG-Reset Ack Buffer */ gnb->ng_reset_ack = NULL; diff --git a/src/amf/ngap-path.c b/src/amf/ngap-path.c index 44fee8ec0..5f8c3898a 100644 --- a/src/amf/ngap-path.c +++ b/src/amf/ngap-path.c @@ -54,16 +54,16 @@ int ngap_send_to_gnb(amf_gnb_t *gnb, ogs_pkbuf_t *pkbuf, uint16_t stream_no) gnb = amf_gnb_cycle(gnb); if (!gnb) { - ogs_warn("gNB has already been removed"); + ogs_error("gNB has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ogs_assert(gnb->sctp.sock); if (gnb->sctp.sock->fd == INVALID_SOCKET) { - ogs_fatal("gNB SCTP socket has already been destroyed"); + ogs_error("gNB SCTP socket has already been destroyed"); ogs_log_hexdump(OGS_LOG_FATAL, pkbuf->data, pkbuf->len); - ogs_assert_if_reached(); + ogs_pkbuf_free(pkbuf); return OGS_ERROR; } @@ -83,16 +83,20 @@ int ngap_send_to_gnb(amf_gnb_t *gnb, ogs_pkbuf_t *pkbuf, uint16_t stream_no) int ngap_send_to_ran_ue(ran_ue_t *ran_ue, ogs_pkbuf_t *pkbuf) { + int rv; ogs_assert(pkbuf); ran_ue = ran_ue_cycle(ran_ue); if (!ran_ue) { - ogs_warn("NG context has already been removed"); + ogs_error("NG context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } - return ngap_send_to_gnb(ran_ue->gnb, pkbuf, ran_ue->gnb_ostream_id); + rv = ngap_send_to_gnb(ran_ue->gnb, pkbuf, ran_ue->gnb_ostream_id); + ogs_expect(rv == OGS_OK); + + return rv; } int ngap_delayed_send_to_ran_ue( @@ -117,10 +121,10 @@ int ngap_delayed_send_to_ran_ue( return OGS_OK; } else { - amf_gnb_t *gnb = NULL; - gnb = ran_ue->gnb; - ogs_assert(gnb); - return ngap_send_to_ran_ue(ran_ue, pkbuf); + int rv = ngap_send_to_ran_ue(ran_ue, pkbuf); + ogs_expect(rv == OGS_OK); + + return rv; } } @@ -149,6 +153,8 @@ int ngap_send_to_5gsm(amf_ue_t *amf_ue, ogs_pkbuf_t *esmbuf) int ngap_send_to_nas(ran_ue_t *ran_ue, NGAP_ProcedureCode_t procedureCode, NGAP_NAS_PDU_t *nasPdu) { + int rv; + ogs_nas_5gs_security_header_t *sh = NULL; ogs_nas_security_header_type_t security_header_type; @@ -211,7 +217,6 @@ int ngap_send_to_nas(ran_ue_t *ran_ue, ogs_assert(h); if (h->extended_protocol_discriminator == OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM) { - int rv; e = amf_event_new(AMF_EVENT_5GMM_MESSAGE); if (!e) { ogs_error("ngap_send_to_nas() failed"); @@ -237,7 +242,10 @@ int ngap_send_to_nas(ran_ue_t *ran_ue, ogs_pkbuf_free(nasbuf); return OGS_ERROR; } - return ngap_send_to_5gsm(amf_ue, nasbuf); + rv = ngap_send_to_5gsm(amf_ue, nasbuf); + ogs_expect(rv == OGS_OK); + + return rv; } else { ogs_error("Unknown NAS Protocol discriminator 0x%02x", h->extended_protocol_discriminator); @@ -253,7 +261,10 @@ int ngap_send_ng_setup_response(amf_gnb_t *gnb) ogs_debug("NG-Setup response"); ngap_buffer = ngap_build_ng_setup_response(); - ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); + if (!ngap_buffer) { + ogs_error("ngap_build_ng_setup_response() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -270,7 +281,10 @@ int ngap_send_ng_setup_failure( ogs_debug("NG-Setup failure"); ngap_buffer = ngap_build_ng_setup_failure( group, cause, NGAP_TimeToWait_v10s); - ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); + if (!ngap_buffer) { + ogs_error("ngap_build_ng_setup_failure() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -285,7 +299,10 @@ int ngap_send_ran_configuration_update_ack(amf_gnb_t *gnb) ogs_debug("RANConfigurationUpdateAcknowledge"); ngap_buffer = ngap_build_ran_configuration_update_ack(); - ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); + if (!ngap_buffer) { + ogs_error("ngap_build_ran_configuration_update_ack() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -302,7 +319,10 @@ int ngap_send_ran_configuration_update_failure( ogs_debug("RANConfigurationUpdateFailure"); ngap_buffer = ngap_build_ran_configuration_update_failure( group, cause, NGAP_TimeToWait_v10s); - ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); + if (!ngap_buffer) { + ogs_error("ngap_build_ran_configuration_update_failure() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -330,7 +350,10 @@ int ngap_send_ran_ue_context_release_command( group, (int)cause, action, (int)duration); ngapbuf = ngap_build_ue_context_release_command(ran_ue, group, cause); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_ue_context_release_command() failed"); + return OGS_ERROR; + } rv = ngap_delayed_send_to_ran_ue(ran_ue, ngapbuf, duration); ogs_expect(rv == OGS_OK); @@ -345,21 +368,15 @@ int ngap_send_amf_ue_context_release_command( amf_ue_t *amf_ue, NGAP_Cause_PR group, long cause, uint8_t action, ogs_time_t duration) { + int rv; ogs_assert(amf_ue); - ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue); - if (ran_ue) { - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(ran_ue, - group, cause, action, duration)); - ogs_debug(" SUPI[%s]", amf_ue->supi); - } else { - ogs_error("[%s] No NG Context - " - "Group[%d] Cause[%d] Action[%d] Duration[%d]", - amf_ue->supi, group, (int)cause, action, (int)duration); - } + rv = ngap_send_ran_ue_context_release_command( + amf_ue->ran_ue, group, cause, action, duration); + ogs_expect(rv == OGS_OK); + ogs_debug(" SUPI[%s]", amf_ue->supi); - return OGS_OK; + return rv; } int ngap_send_paging(amf_ue_t *amf_ue) @@ -383,14 +400,23 @@ int ngap_send_paging(amf_ue_t *amf_ue) ngapbuf = amf_ue->t3513.pkbuf; } else { ngapbuf = ngap_build_paging(amf_ue); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_paging() failed"); + return OGS_ERROR; + } } amf_ue->t3513.pkbuf = ogs_pkbuf_copy(ngapbuf); - ogs_expect_or_return_val(amf_ue->t3513.pkbuf, OGS_ERROR); + if (!amf_ue->t3513.pkbuf) { + ogs_error("ogs_pkbuf_copy() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); - ogs_expect_or_return_val(rv == OGS_OK, rv); + if (rv != OGS_OK) { + ogs_error("ngap_send_to_gnb() failed"); + return rv; + } } } } @@ -413,7 +439,10 @@ int ngap_send_downlink_ran_configuration_transfer( ogs_assert(transfer); ngapbuf = ngap_build_downlink_ran_configuration_transfer(transfer); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_downlink_ran_configuration_transfer() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(target_gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -433,7 +462,10 @@ int ngap_send_path_switch_ack(amf_sess_t *sess) ogs_assert(amf_ue); ngapbuf = ngap_build_path_switch_ack(amf_ue); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_path_switch_ack() failed"); + return OGS_ERROR; + } rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -456,7 +488,10 @@ int ngap_send_handover_request(amf_ue_t *amf_ue) ogs_assert(target_ue); ngapbuf = ngap_build_handover_request(target_ue); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_handover_request() failed"); + return OGS_ERROR; + } rv = ngap_send_to_ran_ue(target_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -474,7 +509,10 @@ int ngap_send_handover_preparation_failure( ogs_assert(cause); ngapbuf = ngap_build_handover_preparation_failure(source_ue, cause); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_handover_preparation_failure() failed"); + return OGS_ERROR; + } rv = ngap_send_to_ran_ue(source_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -494,7 +532,10 @@ int ngap_send_handover_command(amf_ue_t *amf_ue) ogs_assert(source_ue); ngapbuf = ngap_build_handover_command(source_ue); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_handover_command() failed"); + return OGS_ERROR; + } rv = ngap_send_to_ran_ue(source_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -510,7 +551,10 @@ int ngap_send_handover_cancel_ack(ran_ue_t *source_ue) ogs_assert(source_ue); ngapbuf = ngap_build_handover_cancel_ack(source_ue); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_handover_cancel_ack() failed"); + return OGS_ERROR; + } rv = ngap_send_to_ran_ue(source_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -529,7 +573,10 @@ int ngap_send_downlink_ran_status_transfer( ogs_assert(transfer); ngapbuf = ngap_build_uplink_ran_status_transfer(target_ue, transfer); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ngap_build_uplink_ran_status_transfer() failed"); + return OGS_ERROR; + } rv = ngap_send_to_ran_ue(target_ue, ngapbuf); ogs_expect(rv == OGS_OK); @@ -550,7 +597,10 @@ int ngap_send_error_indication( ngapbuf = ogs_ngap_build_error_indication( ran_ue_ngap_id, amf_ue_ngap_id, group, cause); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ogs_ngap_build_error_indication() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -562,17 +612,18 @@ int ngap_send_error_indication2( amf_ue_t *amf_ue, NGAP_Cause_PR group, long cause) { int rv; - amf_gnb_t *gnb; ran_ue_t *ran_ue; ogs_assert(amf_ue); ran_ue = ran_ue_cycle(amf_ue->ran_ue); - ogs_expect_or_return_val(ran_ue, OGS_ERROR); - gnb = ran_ue->gnb; - ogs_expect_or_return_val(gnb, OGS_ERROR); + if (!ran_ue) { + ogs_error("NG context has already been removed"); + return OGS_NOTFOUND; + } rv = ngap_send_error_indication( - gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, group, cause); + ran_ue->gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, + group, cause); ogs_expect(rv == OGS_OK); return rv; @@ -588,7 +639,10 @@ int ngap_send_ng_reset_ack( ogs_assert(gnb); ngapbuf = ogs_ngap_build_ng_reset_ack(partOfNG_Interface); - ogs_expect_or_return_val(ngapbuf, OGS_ERROR); + if (!ngapbuf) { + ogs_error("ogs_ngap_build_ng_reset_ack() failed"); + return OGS_ERROR; + } rv = ngap_send_to_gnb(gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); diff --git a/src/amf/ngap-path.h b/src/amf/ngap-path.h index 1ad54ef9e..c3a7e1bb8 100644 --- a/src/amf/ngap-path.h +++ b/src/amf/ngap-path.h @@ -35,8 +35,6 @@ void ngap_close(void); ogs_sock_t *ngap_server(ogs_socknode_t *node); void ngap_recv_upcall(short when, ogs_socket_t fd, void *data); -int ngap_send(ogs_sock_t *sock, - ogs_pkbuf_t *pkbuf, ogs_sockaddr_t *addr, uint16_t stream_no); int ngap_send_to_gnb( amf_gnb_t *gnb, ogs_pkbuf_t *pkb, uint16_t stream_no); diff --git a/src/amf/ngap-sm.c b/src/amf/ngap-sm.c index 729e948b6..cf36e6c54 100644 --- a/src/amf/ngap-sm.c +++ b/src/amf/ngap-sm.c @@ -39,6 +39,8 @@ void ngap_state_final(ogs_fsm_t *s, amf_event_t *e) void ngap_state_operational(ogs_fsm_t *s, amf_event_t *e) { + int r; + amf_gnb_t *gnb = NULL; ogs_pkbuf_t *pkbuf = NULL; @@ -192,7 +194,10 @@ void ngap_state_operational(ogs_fsm_t *s, amf_event_t *e) ogs_assert(e->ran_ue); ogs_assert(e->pkbuf); - ogs_expect(OGS_OK == ngap_send_to_ran_ue(e->ran_ue, e->pkbuf)); + r = ngap_send_to_ran_ue(e->ran_ue, e->pkbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + ogs_timer_delete(e->timer); break; default: diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index 561d5fc0d..f42e80dc0 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -25,6 +25,8 @@ void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { + int r; + ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_object_t *sbi_object = NULL; ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL; @@ -68,9 +70,10 @@ void amf_nnrf_handle_nf_discover( ogs_assert(amf_ue); ogs_error("[%s] (NF discover) No [%s]", amf_ue->suci, ogs_sbi_service_type_to_name(service_type)); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi(amf_ue, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); + r = nas_5gs_send_gmm_reject_from_sbi(amf_ue, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case OGS_SBI_OBJ_SESS_TYPE: sess = (amf_sess_t *)sbi_object; @@ -82,15 +85,17 @@ void amf_nnrf_handle_nf_discover( ogs_error("[%d:%d] (NF discover) No [%s]", sess->psi, sess->pti, ogs_sbi_service_type_to_name(service_type)); if (sess->payload_container_type) { - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_assert(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_transport, - NGAP_CauseTransport_transport_resource_unavailable)); + NGAP_CauseTransport_transport_resource_unavailable); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: diff --git a/src/amf/nnssf-handler.c b/src/amf/nnssf-handler.c index 19050bdd7..74c929058 100644 --- a/src/amf/nnssf-handler.c +++ b/src/amf/nnssf-handler.c @@ -25,6 +25,7 @@ int amf_nnssf_nsselection_handle_get( amf_sess_t *sess, ogs_sbi_message_t *recvmsg) { bool rc; + int r; OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL; ogs_sbi_client_t *client = NULL, *scp_client = NULL; ogs_sockaddr_t *addr = NULL; @@ -44,34 +45,38 @@ int amf_nnssf_nsselection_handle_get( if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_OK) { ogs_error("[%s] HTTP response error [%d]", amf_ue->supi, recvmsg->res_status); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_status(amf_ue, recvmsg->res_status)); + r = nas_5gs_send_gmm_status(amf_ue, recvmsg->res_status); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } AuthorizedNetworkSliceInfo = recvmsg->AuthorizedNetworkSliceInfo; if (!AuthorizedNetworkSliceInfo) { ogs_error("No AuthorizedNetworkSliceInfo"); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } NsiInformation = AuthorizedNetworkSliceInfo->nsi_information; if (!NsiInformation) { ogs_error("No NsiInformation"); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!NsiInformation->nrf_id) { ogs_error("No nrfId"); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -97,9 +102,10 @@ int amf_nnssf_nsselection_handle_get( if (rc == false || scheme == OpenAPI_uri_scheme_NULL) { ogs_error("[%s:%d] Invalid URI [%s]", amf_ue->supi, sess->psi, NsiInformation->nrf_id); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR;; } diff --git a/src/amf/npcf-handler.c b/src/amf/npcf-handler.c index f3f30df1c..2ba4a58a2 100644 --- a/src/amf/npcf-handler.c +++ b/src/amf/npcf-handler.c @@ -25,7 +25,7 @@ int amf_npcf_am_policy_control_handle_create( amf_ue_t *amf_ue, ogs_sbi_message_t *recvmsg) { - int rv; + int r, rv; uint64_t supported_features; @@ -38,33 +38,37 @@ int amf_npcf_am_policy_control_handle_create( if (recvmsg->res_status != OGS_SBI_HTTP_STATUS_CREATED) { ogs_error("[%s] HTTP response error [%d]", amf_ue->supi, recvmsg->res_status); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi(amf_ue, recvmsg->res_status)); + r = nas_5gs_send_gmm_reject_from_sbi(amf_ue, recvmsg->res_status); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!recvmsg->http.location) { ogs_error("[%s] No http.location", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } PolicyAssociation = recvmsg->PolicyAssociation; if (!PolicyAssociation) { ogs_error("No PolicyAssociation"); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!PolicyAssociation->supp_feat) { ogs_error("No suppFeat"); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -75,9 +79,10 @@ int amf_npcf_am_policy_control_handle_create( if (rv != OGS_OK) { ogs_error("[%s] Cannot parse http.location [%s]", amf_ue->supi, recvmsg->http.location); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -86,9 +91,10 @@ int amf_npcf_am_policy_control_handle_create( amf_ue->supi, recvmsg->http.location); ogs_sbi_header_free(&header); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } diff --git a/src/amf/nsmf-handler.c b/src/amf/nsmf-handler.c index de691cbec..a20f2c717 100644 --- a/src/amf/nsmf-handler.c +++ b/src/amf/nsmf-handler.c @@ -27,7 +27,7 @@ int amf_nsmf_pdusession_handle_create_sm_context( amf_sess_t *sess, ogs_sbi_message_t *recvmsg) { - int rv; + int rv, r; ogs_assert(sess); ogs_assert(recvmsg); @@ -38,10 +38,11 @@ int amf_nsmf_pdusession_handle_create_sm_context( if (!recvmsg->http.location) { ogs_error("[%d:%d] No http.location", sess->psi, sess->pti); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -53,10 +54,11 @@ int amf_nsmf_pdusession_handle_create_sm_context( if (rv != OGS_OK) { ogs_error("[%d:%d] Cannot parse http.location [%s]", sess->psi, sess->pti, recvmsg->http.location); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -66,10 +68,11 @@ int amf_nsmf_pdusession_handle_create_sm_context( sess->psi, sess->pti, recvmsg->http.location); ogs_sbi_header_free(&header); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -86,7 +89,7 @@ int amf_nsmf_pdusession_handle_create_sm_context( amf_ue_t *amf_ue = sess->amf_ue; ogs_assert(amf_ue); - rv = nas_5gs_send_to_gnb(amf_ue, + r = nas_5gs_send_to_gnb(amf_ue, sess->pdu_session_establishment_accept); sess->pdu_session_establishment_accept = NULL; @@ -96,10 +99,11 @@ int amf_nsmf_pdusession_handle_create_sm_context( sess->psi, sess->pti); ogs_sbi_header_free(&header); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -120,19 +124,21 @@ int amf_nsmf_pdusession_handle_create_sm_context( SmContextCreateError = recvmsg->SmContextCreateError; if (!SmContextCreateError) { ogs_error("[%d:%d] No SmContextCreateError", sess->psi, sess->pti); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!SmContextCreateError->error) { ogs_error("[%d:%d] No Error", sess->psi, sess->pti); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -150,19 +156,21 @@ int amf_nsmf_pdusession_handle_create_sm_context( sess->psi, sess->pti); n1smbuf = ogs_pkbuf_copy(n1smbuf); ogs_assert(n1smbuf); - ogs_assert(OGS_OK == - nas_5gs_send_gsm_reject(sess, - OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, n1smbuf)); + r = nas_5gs_send_gsm_reject(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, n1smbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } } ogs_error("[%d:%d] 5GMM was not forwarded", sess->psi, sess->pti); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -173,6 +181,8 @@ int amf_nsmf_pdusession_handle_create_sm_context( int amf_nsmf_pdusession_handle_update_sm_context( amf_sess_t *sess, int state, ogs_sbi_message_t *recvmsg) { + int r; + amf_ue_t *amf_ue = NULL; ran_ue_t *ran_ue = NULL; @@ -239,8 +249,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( amf_ue, 0, NULL)); } else { CLEAR_AMF_UE_TIMER(amf_ue->t3550); - ogs_assert(OGS_OK == - nas_5gs_send_registration_accept(amf_ue)); + r = nas_5gs_send_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_N2_TRANSFER( amf_ue, pdu_session_resource_setup_request); @@ -255,8 +266,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) && AMF_SESSION_SYNC_DONE(amf_ue, AMF_UPDATE_SM_CONTEXT_SERVICE_REQUEST)) { - ogs_assert(OGS_OK == - nas_5gs_send_service_accept(amf_ue)); + r = nas_5gs_send_service_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_N2_TRANSFER( amf_ue, pdu_session_resource_setup_request); @@ -267,8 +279,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (AMF_SESSION_SYNC_DONE(amf_ue, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQUIRED)) { - ogs_assert(OGS_OK == - ngap_send_handover_request(amf_ue)); + r = ngap_send_handover_request(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, handover_request); } @@ -282,10 +295,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n1smbuf) { ogs_error("[%s:%d] No N1 SM Content [%s]", amf_ue->supi, sess->psi, n1SmMsg->content_id); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -293,10 +307,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n2smbuf) { ogs_error("[%s:%d] No N2 SM Content", amf_ue->supi, sess->psi); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -311,9 +326,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( n2smbuf = ogs_pkbuf_copy(n2smbuf); ogs_assert(n2smbuf); - ogs_assert(OGS_OK == - nas_send_pdu_session_modification_command( - sess, n1smbuf, n2smbuf)); + r = nas_send_pdu_session_modification_command( + sess, n1smbuf, n2smbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; @@ -321,10 +337,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n1smbuf) { ogs_error("[%s:%d] No N1 SM Content [%s]", amf_ue->supi, sess->psi, n1SmMsg->content_id); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -332,10 +349,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n2smbuf) { ogs_error("[%s:%d] No N2 SM Content", amf_ue->supi, sess->psi); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -350,19 +368,21 @@ int amf_nsmf_pdusession_handle_update_sm_context( n2smbuf = ogs_pkbuf_copy(n2smbuf); ogs_assert(n2smbuf); - ogs_assert(OGS_OK == - nas_send_pdu_session_release_command( - sess, n1smbuf, n2smbuf)); + r = nas_send_pdu_session_release_command( + sess, n1smbuf, n2smbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case OpenAPI_n2_sm_info_type_PATH_SWITCH_REQ_ACK: if (!n2smbuf) { ogs_error("[%s:%d] No N2 SM Content", amf_ue->supi, sess->psi); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -372,8 +392,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( ogs_pkbuf_copy(n2smbuf)); if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { - ogs_assert(OGS_OK == - ngap_send_path_switch_ack(sess)); + r = ngap_send_path_switch_ack(sess); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, path_switch_request_ack); } @@ -383,10 +404,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n2smbuf) { ogs_error("[%s:%d] No N2 SM Content", amf_ue->supi, sess->psi); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -395,8 +417,9 @@ int amf_nsmf_pdusession_handle_update_sm_context( sess, handover_command, ogs_pkbuf_copy(n2smbuf)); if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { - ogs_assert(OGS_OK == - ngap_send_handover_command(amf_ue)); + r = ngap_send_handover_command(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, handover_command); } @@ -405,10 +428,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( default: ogs_error("Not implemented [%d]", SmContextUpdatedData->n2_sm_info_type); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, + r = ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error)); + NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else { @@ -478,11 +502,12 @@ int amf_nsmf_pdusession_handle_update_sm_context( ogs_warn("PDUSessionResourceSetupResponse(Unsuccessful)"); ogs_assert(amf_ue->deactivation.group); - ogs_assert(OGS_OK == - ngap_send_amf_ue_context_release_command(amf_ue, + r = ngap_send_amf_ue_context_release_command(amf_ue, amf_ue->deactivation.group, amf_ue->deactivation.cause, - NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0)); + NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (state == AMF_UPDATE_SM_CONTEXT_MODIFIED) { /* @@ -515,11 +540,12 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { ogs_assert(amf_ue->deactivation.group); - ogs_assert(OGS_OK == - ngap_send_amf_ue_context_release_command(amf_ue, + r = ngap_send_amf_ue_context_release_command(amf_ue, amf_ue->deactivation.group, amf_ue->deactivation.cause, - NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0)); + NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (state == AMF_UPDATE_SM_CONTEXT_REGISTRATION_REQUEST) { @@ -597,11 +623,12 @@ int amf_nsmf_pdusession_handle_update_sm_context( target_ue = source_ue->target_ue; ogs_assert(target_ue); - ogs_assert(OGS_OK == - ngap_send_ran_ue_context_release_command(target_ue, + r = ngap_send_ran_ue_context_release_command(target_ue, NGAP_Cause_PR_radioNetwork, NGAP_CauseRadioNetwork_handover_cancelled, - NGAP_UE_CTX_REL_NG_HANDOVER_CANCEL, 0)); + NGAP_UE_CTX_REL_NG_HANDOVER_CANCEL, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (state == AMF_UPDATE_SM_CONTEXT_HANDOVER_NOTIFY) { @@ -636,9 +663,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( ogs_debug(" SUPI[%s]", amf_ue->supi); ran_ue_remove(ran_ue); - if (ogs_list_count(&gnb->ran_ue_list) == 0) - ogs_assert(OGS_OK == - ngap_send_ng_reset_ack(gnb, NULL)); + if (ogs_list_count(&gnb->ran_ue_list) == 0) { + r = ngap_send_ng_reset_ack(gnb, NULL); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } } else { ogs_warn("[%s] RAN-NG Context has already been removed", @@ -673,9 +702,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( * where PartOfNG_interface was requested * REMOVED */ ogs_assert(gnb->ng_reset_ack); - ogs_expect(OGS_OK == - ngap_send_to_gnb(gnb, - gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING)); + r = ngap_send_to_gnb( + gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* Clear NG-Reset Ack Buffer */ gnb->ng_reset_ack = NULL; @@ -722,18 +752,20 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!SmContextUpdateError) { ogs_error("[%d:%d] No SmContextUpdateError [%d]", sess->psi, sess->pti, recvmsg->res_status); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } if (!SmContextUpdateError->error) { ogs_error("[%d:%d] No Error [%d]", sess->psi, sess->pti, recvmsg->res_status); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -752,9 +784,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( n1smbuf = ogs_pkbuf_copy(n1smbuf); ogs_assert(n1smbuf); - ogs_assert(OGS_OK == - nas_5gs_send_gsm_reject(sess, - OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, n1smbuf)); + r = nas_5gs_send_gsm_reject(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, n1smbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -764,9 +797,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( n2SmInfo = SmContextUpdateError->n2_sm_info; if (!n2SmInfo || !n2SmInfo->content_id) { ogs_error("[%d:%d] No N2 SM Message", sess->psi, sess->pti); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -776,9 +810,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n2smbuf) { ogs_error("[%d:%d] No N2 SM Content [%s]", sess->psi, sess->pti, n2SmInfo->content_id); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -786,9 +821,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( ogs_error("[%d:%d] Error Indication", sess->psi, sess->pti); - ogs_expect(OGS_OK == - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); + r = ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -798,6 +834,7 @@ int amf_nsmf_pdusession_handle_update_sm_context( int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) { + int r; amf_ue_t *amf_ue = NULL; ogs_assert(sess); @@ -825,8 +862,9 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) amf_ue, 0, NULL)); } else { CLEAR_AMF_UE_TIMER(amf_ue->t3550); - ogs_assert(OGS_OK == - nas_5gs_send_registration_accept(amf_ue)); + r = nas_5gs_send_registration_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -836,10 +874,14 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) * 2. Release All SM contexts * 3. Service accept */ - if (AMF_SESSION_SYNC_DONE(amf_ue, AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) && - AMF_SESSION_SYNC_DONE(amf_ue, AMF_UPDATE_SM_CONTEXT_SERVICE_REQUEST)) - ogs_assert(OGS_OK == - nas_5gs_send_service_accept(amf_ue)); + if (AMF_SESSION_SYNC_DONE(amf_ue, + AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) && + AMF_SESSION_SYNC_DONE(amf_ue, + AMF_UPDATE_SM_CONTEXT_SERVICE_REQUEST)) { + r = nas_5gs_send_service_accept(amf_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } } else { @@ -852,10 +894,11 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) * 3. UE Context release command * 4. UE Context release complete */ - ogs_assert(OGS_OK == - ngap_send_amf_ue_context_release_command(amf_ue, + r = 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)); + NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (state == AMF_RELEASE_SM_CONTEXT_REGISTRATION_ACCEPT) { @@ -917,10 +960,11 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) * 3. UE Context release command * 4. UE Context release complete */ - ogs_assert(OGS_OK == - ngap_send_amf_ue_context_release_command(amf_ue, + r = ngap_send_amf_ue_context_release_command(amf_ue, NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release, - NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_initial_context_setup)) { diff --git a/src/amf/nudm-handler.c b/src/amf/nudm-handler.c index a9586ae01..a165a14ea 100644 --- a/src/amf/nudm-handler.c +++ b/src/amf/nudm-handler.c @@ -25,7 +25,7 @@ int amf_nudm_sdm_handle_provisioned( amf_ue_t *amf_ue, int state, ogs_sbi_message_t *recvmsg) { - int i; + int i, r; ogs_assert(amf_ue); ogs_assert(recvmsg); @@ -259,9 +259,10 @@ int amf_nudm_sdm_handle_provisioned( if (!recvmsg->http.location) { ogs_error("[%s] No http.location", amf_ue->supi); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -272,9 +273,10 @@ int amf_nudm_sdm_handle_provisioned( if (rv != OGS_OK) { ogs_error("[%s] Cannot parse http.location [%s]", amf_ue->supi, recvmsg->http.location); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -283,9 +285,10 @@ int amf_nudm_sdm_handle_provisioned( amf_ue->supi, recvmsg->http.location); ogs_sbi_header_free(&header); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c index 1d351c819..45ee4c4d9 100644 --- a/src/amf/sbi-path.c +++ b/src/amf/sbi-path.c @@ -92,6 +92,7 @@ bool amf_ue_sbi_discover_and_send( ogs_sbi_request_t *(*build)(amf_ue_t *amf_ue, void *data), amf_ue_t *amf_ue, int state, void *data) { + int r; ogs_sbi_xact_t *xact = NULL; ogs_assert(service_type); @@ -103,9 +104,10 @@ bool amf_ue_sbi_discover_and_send( (ogs_sbi_build_f)build, amf_ue, data); if (!xact) { ogs_error("amf_ue_sbi_discover_and_send() failed"); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return false; } @@ -114,9 +116,10 @@ bool amf_ue_sbi_discover_and_send( if (ogs_sbi_discover_and_send(xact) != true) { ogs_error("amf_ue_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); - ogs_assert(OGS_OK == - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); + r = nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return false; } @@ -129,6 +132,7 @@ bool amf_sess_sbi_discover_and_send( ogs_sbi_request_t *(*build)(amf_sess_t *sess, void *data), amf_sess_t *sess, int state, void *data) { + int r; ogs_sbi_xact_t *xact = NULL; ogs_assert(service_type); @@ -140,8 +144,10 @@ bool amf_sess_sbi_discover_and_send( (ogs_sbi_build_f)build, sess, data); if (!xact) { ogs_error("amf_sess_sbi_discover_and_send() failed"); - ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME)); + r = nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return false; } @@ -150,8 +156,10 @@ bool amf_sess_sbi_discover_and_send( if (ogs_sbi_discover_and_send(xact) != true) { ogs_error("amf_sess_sbi_discover_and_send() failed"); ogs_sbi_xact_remove(xact); - ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME)); + r = nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return false; } @@ -160,7 +168,7 @@ bool amf_sess_sbi_discover_and_send( static int client_discover_cb( int status, ogs_sbi_response_t *response, void *data) { - int rv; + int r, rv; ogs_sbi_message_t message; ogs_sbi_xact_t *xact = NULL; @@ -216,24 +224,30 @@ static int client_discover_cb( rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { ogs_error("cannot parse HTTP response"); - ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME)); + r = nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); goto cleanup; } if (message.res_status != OGS_SBI_HTTP_STATUS_OK) { ogs_error("NF-Discover failed [%d]", message.res_status); - ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME)); + r = nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); goto cleanup; } if (!message.SearchResult) { ogs_error("No SearchResult"); - ogs_assert(OGS_OK == nas_5gs_send_back_gsm_message(sess, - OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME)); + r = nas_5gs_send_back_gsm_message(sess, + OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); goto cleanup; } @@ -247,10 +261,11 @@ static int client_discover_cb( ogs_error("[%s:%d] (NF discover) No [%s]", amf_ue->supi, sess->psi, ogs_sbi_service_type_to_name(service_type)); - ogs_assert(OGS_OK == - nas_5gs_send_back_gsm_message(sess, + r = nas_5gs_send_back_gsm_message(sess, OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, - AMF_NAS_BACKOFF_TIME)); + AMF_NAS_BACKOFF_TIME); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); goto cleanup; } @@ -294,11 +309,18 @@ bool amf_sess_sbi_discover_by_nsi( xact = ogs_sbi_xact_add( &sess->sbi, service_type, discovery_option, NULL, NULL, NULL); - ogs_expect_or_return_val(xact, false); + if (!xact) { + ogs_error("ogs_sbi_xact_add() failed"); + return false; + } xact->request = amf_nnrf_disc_build_discover( sess->nssf.nrf.id, xact->service_type, xact->discovery_option); - ogs_expect_or_return_val(xact->request, false); + if (!xact->request) { + ogs_error("amf_nnrf_disc_build_discover() failed"); + ogs_sbi_xact_remove(xact); + return false; + } return ogs_sbi_client_send_request( client, client_discover_cb, xact->request, xact); @@ -460,7 +482,10 @@ bool amf_sbi_send_n1_n2_failure_notify( ogs_assert(client); request = amf_nsmf_callback_build_n1_n2_failure_notify(sess, cause); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("amf_nsmf_callback_build_n1_n2_failure_notify() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL); diff --git a/src/mme/emm-handler.c b/src/mme/emm-handler.c index e25b6d2a0..e52a41ee4 100644 --- a/src/mme/emm-handler.c +++ b/src/mme/emm-handler.c @@ -35,6 +35,7 @@ int emm_handle_attach_request(mme_ue_t *mme_ue, ogs_nas_eps_attach_request_t *attach_request, ogs_pkbuf_t *pkbuf) { + int r; int served_tai_index = 0; ogs_nas_eps_mobile_identity_guti_t *eps_mobile_identity_guti = NULL; @@ -129,10 +130,11 @@ int emm_handle_attach_request(mme_ue_t *mme_ue, /* Send Attach Reject */ ogs_warn("Cannot find Served TAI[PLMN_ID:%06x,TAC:%d]", ogs_plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); @@ -172,10 +174,11 @@ int emm_handle_attach_request(mme_ue_t *mme_ue, "but Integrity[0x%x] cannot be bypassed with EIA0", mme_selected_enc_algorithm(mme_ue), mme_selected_int_algorithm(mme_ue)); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -222,7 +225,7 @@ int emm_handle_attach_request(mme_ue_t *mme_ue, int emm_handle_attach_complete( mme_ue_t *mme_ue, ogs_nas_eps_attach_complete_t *attach_complete) { - int rv; + int r, rv; ogs_pkbuf_t *emmbuf = NULL; ogs_nas_eps_message_t message; @@ -315,15 +318,19 @@ int emm_handle_attach_complete( network_daylight_saving_time->length = 1; emmbuf = nas_eps_security_encode(mme_ue, &message); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("nas_eps_security_encode() failed"); + return OGS_ERROR; + } - rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + r = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_debug("EMM information"); ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd); - return rv; + return r; } int emm_handle_identity_response( @@ -487,6 +494,7 @@ int emm_handle_service_request( int emm_handle_tau_request(mme_ue_t *mme_ue, ogs_nas_eps_tracking_area_update_request_t *tau_request, ogs_pkbuf_t *pkbuf) { + int r; int served_tai_index = 0; ogs_nas_eps_mobile_identity_guti_t *eps_mobile_identity_guti = NULL; @@ -560,9 +568,10 @@ int emm_handle_tau_request(mme_ue_t *mme_ue, /* Send TAU reject */ ogs_warn("Cannot find Served TAI[PLMN_ID:%06x,TAC:%d]", ogs_plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac); - ogs_assert(OGS_OK == - nas_eps_send_tau_reject( - mme_ue, OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED)); + r = nas_eps_send_tau_reject( + mme_ue, OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); @@ -625,6 +634,7 @@ int emm_handle_tau_request(mme_ue_t *mme_ue, int emm_handle_extended_service_request(mme_ue_t *mme_ue, ogs_nas_eps_extended_service_request_t *extended_service_request) { + int r; int served_tai_index = 0; ogs_nas_service_type_t *service_type = @@ -678,9 +688,10 @@ int emm_handle_extended_service_request(mme_ue_t *mme_ue, /* Send TAU reject */ ogs_warn("Cannot find Served TAI[PLMN_ID:%06x,TAC:%d]", ogs_plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac); - ogs_assert(OGS_OK == - nas_eps_send_tau_reject( - mme_ue, OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED)); + r = nas_eps_send_tau_reject( + mme_ue, OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); diff --git a/src/mme/emm-sm.c b/src/mme/emm-sm.c index 4a5f70a10..b0d6dd189 100644 --- a/src/mme/emm-sm.c +++ b/src/mme/emm-sm.c @@ -56,7 +56,7 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e); void emm_state_de_registered(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r; mme_ue_t *mme_ue = NULL; ogs_assert(e); @@ -85,14 +85,10 @@ void emm_state_de_registered(ogs_fsm_t *s, mme_event_t *e) "Stop retransmission"); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { - ogs_assert(mme_ue->t3470.pkbuf); - rv = nas_eps_send_identity_request(mme_ue); - if (rv == OGS_OK) { - mme_ue->t3470.retry_count++; - } else { - ogs_error("nas_eps_send_identity_request() failed"); - OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - } + mme_ue->t3470.retry_count++; + r = nas_eps_send_identity_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -109,7 +105,7 @@ void emm_state_de_registered(ogs_fsm_t *s, mme_event_t *e) void emm_state_registered(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r; mme_ue_t *mme_ue = NULL; ogs_assert(e); @@ -146,7 +142,9 @@ void emm_state_registered(ogs_fsm_t *s, mme_event_t *e) * We don't have to set CNDomain. * So, we just set CNDomain to 0 */ - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, 0)); + r = s1ap_send_paging(mme_ue, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -157,14 +155,10 @@ void emm_state_registered(ogs_fsm_t *s, mme_event_t *e) "Stop retransmission"); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { - ogs_assert(mme_ue->t3470.pkbuf); - rv = nas_eps_send_identity_request(mme_ue); - if (rv == OGS_OK) { - mme_ue->t3470.retry_count++; - } else { - ogs_error("nas_eps_send_identity_request() failed"); - OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - } + mme_ue->t3470.retry_count++; + r = nas_eps_send_identity_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -175,14 +169,10 @@ void emm_state_registered(ogs_fsm_t *s, mme_event_t *e) "Stop retransmission"); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { - ogs_assert(mme_ue->t3422.pkbuf); - rv = nas_eps_send_detach_request(mme_ue); - if (rv == OGS_OK) { - mme_ue->t3422.retry_count++; - } else { - ogs_error("nas_eps_send_detach_request() failed"); - OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - } + mme_ue->t3422.retry_count++; + r = nas_eps_send_detach_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -199,7 +189,7 @@ void emm_state_registered(ogs_fsm_t *s, mme_event_t *e) static void common_register_state(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; enb_ue_t *enb_ue = NULL; @@ -234,42 +224,47 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (!MME_UE_HAVE_IMSI(mme_ue)) { ogs_info("Service request : Unknown UE"); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_warn("No Security Context : IMSI[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { ogs_warn("No Session Context : IMSI[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!ACTIVE_EPS_BEARERS_IS_AVAIABLE(mme_ue)) { ogs_warn("No active EPS bearers : IMSI[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } - ogs_assert(OGS_OK == - s1ap_send_initial_context_setup_request(mme_ue)); + r = s1ap_send_initial_context_setup_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_registered); break; } @@ -314,8 +309,9 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (!MME_UE_HAVE_IMSI(mme_ue)) { CLEAR_MME_UE_TIMER(mme_ue->t3470); - ogs_assert(OGS_OK == - nas_eps_send_identity_request(mme_ue)); + r = nas_eps_send_identity_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; } @@ -328,10 +324,11 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) &mme_ue->pdn_connectivity_request); if (rv != OGS_OK) { ogs_error("nas_eps_send_emm_to_esm() failed"); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -360,27 +357,30 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (!MME_UE_HAVE_IMSI(mme_ue)) { ogs_info("TAU request : Unknown UE"); - ogs_assert(OGS_OK == - nas_eps_send_tau_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_tau_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { ogs_warn("No PDN Connection : UE[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_tau_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_tau_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, emm_state_exception); break; } if (!ACTIVE_EPS_BEARERS_IS_AVAIABLE(mme_ue)) { ogs_warn("No active EPS bearers : IMSI[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_tau_reject(mme_ue, - OGS_NAS_EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED)); + r = nas_eps_send_tau_reject(mme_ue, + OGS_NAS_EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -459,20 +459,23 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (e->s1ap_code == S1AP_ProcedureCode_id_initialUEMessage) { ogs_debug(" Iniital UE Message"); if (mme_ue->nas_eps.update.active_flag) { - ogs_assert(OGS_OK == - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_InitialContextSetup)); + r = nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_InitialContextSetup); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_assert(OGS_OK == - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_downlinkNASTransport)); + r = nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_downlinkNASTransport); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (e->s1ap_code == S1AP_ProcedureCode_id_uplinkNASTransport) { ogs_debug(" Uplink NAS Transport"); - ogs_assert(OGS_OK == - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_downlinkNASTransport)); + r = nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_downlinkNASTransport); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_fatal("Invalid Procedure Code[%d]", (int)e->s1ap_code); } @@ -501,27 +504,30 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (!MME_UE_HAVE_IMSI(mme_ue)) { ogs_warn("Extended Service request : Unknown UE"); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { ogs_warn("No PDN Connection : UE[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, emm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_warn("No Security Context : IMSI[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -531,10 +537,10 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (!MME_P_TMSI_IS_AVAILABLE(mme_ue)) { ogs_warn("No P-TMSI : UE[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); mme_send_release_access_bearer_or_ue_context_release( enb_ue); break; @@ -558,16 +564,17 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) } else { ogs_warn(" Unknown CSFB Service Type[%d]", mme_ue->nas_eps.service.value); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } - ogs_assert(OGS_OK == - s1ap_send_initial_context_setup_request(mme_ue)); + r = s1ap_send_initial_context_setup_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (e->s1ap_code == S1AP_ProcedureCode_id_uplinkNASTransport) { @@ -575,10 +582,10 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (!MME_P_TMSI_IS_AVAILABLE(mme_ue)) { ogs_warn("No P-TMSI : UE[%s]", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; } @@ -600,16 +607,17 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) } else { ogs_warn(" Unknown CSFB Service Type[%d]", mme_ue->nas_eps.service.value); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) - ); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } - ogs_assert(OGS_OK == - s1ap_send_ue_context_modification_request(mme_ue)); + r = s1ap_send_ue_context_modification_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_error("Invalid Procedure Code[%d]", (int)e->s1ap_code); } @@ -646,10 +654,11 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) CLEAR_MME_UE_TIMER(mme_ue->t3422); - rv = s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_detach, S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); - ogs_expect(rv == OGS_OK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_de_registered); break; @@ -669,11 +678,12 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) MME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id; ENB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id; - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb_ue->enb, + r = s1ap_send_error_indication(enb_ue->enb, &MME_UE_S1AP_ID, &ENB_UE_S1AP_ID, S1AP_Cause_PR_transport, - S1AP_CauseTransport_transport_resource_unavailable)); + S1AP_CauseTransport_transport_resource_unavailable); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -700,7 +710,7 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) void emm_state_authentication(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; ogs_nas_eps_message_t *message = NULL; @@ -745,8 +755,9 @@ void emm_state_authentication(ogs_fsm_t *s, mme_event_t *e) authentication_response_parameter->length); ogs_log_hexdump(OGS_LOG_WARN, mme_ue->xres, OGS_MAX_RES_LEN); - ogs_assert(OGS_OK == - nas_eps_send_authentication_reject(mme_ue)); + r = nas_eps_send_authentication_reject(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { OGS_FSM_TRAN(&mme_ue->sm, &emm_state_security_mode); @@ -789,8 +800,9 @@ void emm_state_authentication(ogs_fsm_t *s, mme_event_t *e) break; } - ogs_assert(OGS_OK == - nas_eps_send_authentication_reject(mme_ue)); + r = nas_eps_send_authentication_reject(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); break; @@ -841,16 +853,14 @@ void emm_state_authentication(ogs_fsm_t *s, mme_event_t *e) "Stop retransmission", mme_ue->imsi_bcd); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - ogs_expect(OGS_OK == - nas_eps_send_authentication_reject(mme_ue)); + r = nas_eps_send_authentication_reject(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - rv = nas_eps_send_authentication_request(mme_ue); - if (rv == OGS_OK) { - mme_ue->t3460.retry_count++; - } else { - ogs_error("nas_eps_send_authentication_request() failed"); - OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - } + mme_ue->t3460.retry_count++; + r = nas_eps_send_authentication_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -867,7 +877,7 @@ void emm_state_authentication(ogs_fsm_t *s, mme_event_t *e) void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; ogs_nas_eps_message_t *message = NULL; ogs_nas_security_header_type_t h; @@ -883,8 +893,9 @@ void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: CLEAR_MME_UE_TIMER(mme_ue->t3460); - ogs_assert(OGS_OK == - nas_eps_send_security_mode_command(mme_ue)); + r = nas_eps_send_security_mode_command(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case OGS_FSM_EXIT_SIG: break; @@ -895,9 +906,10 @@ void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) if (message->emm.h.security_header_type == OGS_NAS_SECURITY_HEADER_FOR_SERVICE_REQUEST_MESSAGE) { ogs_debug("Service request"); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -979,9 +991,10 @@ void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) break; case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST: ogs_debug("Tracking area update request"); - ogs_assert(OGS_OK == - nas_eps_send_tau_reject(mme_ue, - OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); + r = nas_eps_send_tau_reject(mme_ue, + OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; case OGS_NAS_EPS_EMM_STATUS: @@ -1017,18 +1030,16 @@ void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) "Stop retransmission", mme_ue->imsi_bcd); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - ogs_expect(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - rv = nas_eps_send_security_mode_command(mme_ue); - if (rv == OGS_OK) { - mme_ue->t3460.retry_count++; - } else { - ogs_error("nas_eps_send_security_mode_command() failed"); - OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - } + mme_ue->t3460.retry_count++; + r = nas_eps_send_security_mode_command(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -1045,7 +1056,7 @@ void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; ogs_nas_eps_message_t *message = NULL; ogs_nas_security_header_type_t h; @@ -1070,9 +1081,10 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) if (message->emm.h.security_header_type == OGS_NAS_SECURITY_HEADER_FOR_SERVICE_REQUEST_MESSAGE) { ogs_debug("Service request"); - ogs_assert(OGS_OK == - nas_eps_send_service_reject(mme_ue, - OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); + r = nas_eps_send_service_reject(mme_ue, + OGS_NAS_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -1225,7 +1237,10 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) mme_ue->t3450.retry_count++; emmbuf = mme_ue->t3450.pkbuf; - ogs_expect_or_return(emmbuf); + if (!emmbuf) { + ogs_error("No emmbuf"); + return; + } mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf); ogs_assert(mme_ue->t3450.pkbuf); @@ -1233,12 +1248,9 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) ogs_timer_start(mme_ue->t3450.timer, mme_timer_cfg(MME_TIMER_T3450)->duration); - rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - if (rv != OGS_OK) { - ogs_error("nas_eps_send_to_downlink_nas_transport() " - "failed"); - OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); - } + r = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -1255,7 +1267,7 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) void emm_state_exception(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; enb_ue_t *enb_ue = NULL; @@ -1298,8 +1310,9 @@ void emm_state_exception(ogs_fsm_t *s, mme_event_t *e) if (!MME_UE_HAVE_IMSI(mme_ue)) { CLEAR_MME_UE_TIMER(mme_ue->t3470); - ogs_assert(OGS_OK == - nas_eps_send_identity_request(mme_ue)); + r = nas_eps_send_identity_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_de_registered); break; @@ -1314,10 +1327,11 @@ void emm_state_exception(ogs_fsm_t *s, mme_event_t *e) &mme_ue->pdn_connectivity_request); if (rv != OGS_OK) { ogs_error("nas_eps_send_emm_to_esm() failed"); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &emm_state_exception); break; } diff --git a/src/mme/esm-handler.c b/src/mme/esm-handler.c index 7f8cd46c2..242fcbca0 100644 --- a/src/mme/esm-handler.c +++ b/src/mme/esm-handler.c @@ -31,6 +31,7 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, ogs_nas_eps_pdn_connectivity_request_t *req, int create_action) { + int r; mme_ue_t *mme_ue = NULL; mme_sess_t *sess = NULL; uint8_t security_protected_required = 0; @@ -65,9 +66,11 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, mme_ue, req->access_point_name.apn); if (!sess->session) { /* Invalid APN */ - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject( - sess, OGS_NAS_ESM_CAUSE_MISSING_OR_UNKNOWN_APN, create_action)); + r = nas_eps_send_pdn_connectivity_reject( + sess, OGS_NAS_ESM_CAUSE_MISSING_OR_UNKNOWN_APN, + create_action); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_warn("Invalid APN[%s]", req->access_point_name.apn); return OGS_ERROR; } @@ -80,9 +83,11 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, if (derived_pdn_type == 0) { ogs_error("Cannot derived PDN Type [UE:%d,HSS:%d]", sess->request_type.type, sess->session->session_type); - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject( - sess, OGS_NAS_ESM_CAUSE_UNKNOWN_PDN_TYPE, create_action)); + r = nas_eps_send_pdn_connectivity_reject( + sess, OGS_NAS_ESM_CAUSE_UNKNOWN_PDN_TYPE, + create_action); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } } else { @@ -102,7 +107,9 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, if (security_protected_required) { CLEAR_BEARER_TIMER(bearer->t3489); - ogs_assert(OGS_OK == nas_eps_send_esm_information_request(bearer)); + r = nas_eps_send_esm_information_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_OK; } @@ -137,9 +144,10 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, mme_gtp_send_create_session_request(sess, create_action)); } else { ogs_error("No APN"); - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject( - sess, OGS_NAS_ESM_CAUSE_MISSING_OR_UNKNOWN_APN, create_action)); + r = nas_eps_send_pdn_connectivity_reject( + sess, OGS_NAS_ESM_CAUSE_MISSING_OR_UNKNOWN_APN, create_action); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -149,6 +157,7 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, int esm_handle_information_response(mme_sess_t *sess, ogs_nas_eps_esm_information_response_t *rsp) { + int r; mme_ue_t *mme_ue = NULL; ogs_assert(sess); @@ -183,10 +192,11 @@ int esm_handle_information_response(mme_sess_t *sess, if (derived_pdn_type == 0) { ogs_error("Cannot derived PDN Type [UE:%d,HSS:%d]", sess->request_type.type, sess->session->session_type); - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject( + r = nas_eps_send_pdn_connectivity_reject( sess, OGS_NAS_ESM_CAUSE_UNKNOWN_PDN_TYPE, - OGS_GTP_CREATE_IN_ATTACH_REQUEST)); + OGS_GTP_CREATE_IN_ATTACH_REQUEST); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } } else { @@ -203,8 +213,9 @@ int esm_handle_information_response(mme_sess_t *sess, ogs_assert(OGS_OK == sgsap_send_location_update_request(mme_ue)); } else { - ogs_assert(OGS_OK == - nas_eps_send_attach_accept(mme_ue)); + r = nas_eps_send_attach_accept(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else { ogs_assert(OGS_OK == @@ -217,10 +228,11 @@ int esm_handle_information_response(mme_sess_t *sess, else ogs_error("No APN"); - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject( + r = nas_eps_send_pdn_connectivity_reject( sess, OGS_NAS_ESM_CAUSE_MISSING_OR_UNKNOWN_APN, - OGS_GTP_CREATE_IN_ATTACH_REQUEST)); + OGS_GTP_CREATE_IN_ATTACH_REQUEST); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_ERROR; } @@ -230,6 +242,7 @@ int esm_handle_information_response(mme_sess_t *sess, int esm_handle_bearer_resource_allocation_request( mme_bearer_t *bearer, ogs_nas_eps_message_t *message) { + int r; mme_ue_t *mme_ue = NULL; mme_sess_t *sess = NULL; @@ -239,9 +252,10 @@ int esm_handle_bearer_resource_allocation_request( mme_ue = sess->mme_ue; ogs_assert(mme_ue); - ogs_assert(OGS_OK == - nas_eps_send_bearer_resource_allocation_reject( - mme_ue, sess->pti, OGS_NAS_ESM_CAUSE_NETWORK_FAILURE)); + r = nas_eps_send_bearer_resource_allocation_reject( + mme_ue, sess->pti, OGS_NAS_ESM_CAUSE_NETWORK_FAILURE); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_OK; } diff --git a/src/mme/esm-sm.c b/src/mme/esm-sm.c index 4cb31ac89..72dbf9a90 100644 --- a/src/mme/esm-sm.c +++ b/src/mme/esm-sm.c @@ -68,7 +68,7 @@ void esm_state_final(ogs_fsm_t *s, mme_event_t *e) void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; mme_sess_t *sess = NULL; mme_bearer_t *bearer = NULL; @@ -122,8 +122,9 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) mme_gtp_send_delete_session_request(mme_ue->sgw_ue, sess, OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST)); } else { - ogs_assert(OGS_OK == - nas_eps_send_deactivate_bearer_context_request(bearer)); + r = nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } OGS_FSM_TRAN(s, esm_state_pdn_will_disconnect); break; @@ -137,30 +138,34 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) h.type = e->nas_type; if (h.integrity_protected == 0) { ogs_error("[%s] No Integrity Protected", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_assert(mme_ue->enb_ue); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(mme_ue->enb_ue, + r = s1ap_send_ue_context_release_command(mme_ue->enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &esm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_warn("[%s] No Security Context", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_assert(mme_ue->enb_ue); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(mme_ue->enb_ue, + r = s1ap_send_ue_context_release_command(mme_ue->enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); OGS_FSM_TRAN(s, &esm_state_exception); break; } @@ -230,18 +235,16 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) "Stop retransmission", mme_ue->imsi_bcd); OGS_FSM_TRAN(&bearer->sm, &esm_state_exception); - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject(sess, + r = nas_eps_send_pdn_connectivity_reject(sess, OGS_NAS_ESM_CAUSE_ESM_INFORMATION_NOT_RECEIVED, - e->create_action)); + e->create_action); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - rv = nas_eps_send_esm_information_request(bearer); - if (rv == OGS_OK) { - bearer->t3489.retry_count++; - } else { - ogs_error("nas_eps_send_esm_information_request() failed"); - OGS_FSM_TRAN(&bearer->sm, &esm_state_exception); - } + bearer->t3489.retry_count++; + r = nas_eps_send_esm_information_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; default: @@ -258,7 +261,7 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) void esm_state_active(ogs_fsm_t *s, mme_event_t *e) { - int rv; + int r, rv; mme_ue_t *mme_ue = NULL; mme_sess_t *sess = NULL; mme_bearer_t *bearer = NULL; @@ -309,8 +312,9 @@ void esm_state_active(ogs_fsm_t *s, mme_event_t *e) mme_gtp_send_delete_session_request(mme_ue->sgw_ue, sess, OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST)); } else { - ogs_assert(OGS_OK == - nas_eps_send_deactivate_bearer_context_request(bearer)); + r = nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } OGS_FSM_TRAN(s, esm_state_pdn_will_disconnect); break; diff --git a/src/mme/mme-context.c b/src/mme/mme-context.c index 090d5bcda..35d07721a 100644 --- a/src/mme/mme-context.c +++ b/src/mme/mme-context.c @@ -3223,6 +3223,7 @@ mme_bearer_t *mme_bearer_find_by_ue_ebi(mme_ue_t *mme_ue, uint8_t ebi) mme_bearer_t *mme_bearer_find_or_add_by_message( mme_ue_t *mme_ue, ogs_nas_eps_message_t *message, int create_action) { + int r; uint8_t pti = OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED; uint8_t ebi = OGS_NAS_EPS_BEARER_IDENTITY_UNASSIGNED; @@ -3242,10 +3243,11 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( bearer = mme_bearer_find_by_ue_ebi(mme_ue, ebi); if (!bearer) { ogs_error("No Bearer : EBI[%d]", ebi); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return NULL; } @@ -3254,10 +3256,11 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( if (pti == OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED) { ogs_error("Both PTI[%d] and EBI[%d] are 0", pti, ebi); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return NULL; } @@ -3272,10 +3275,11 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( if (!bearer) { ogs_error("No Bearer : Linked-EBI[%d]", linked_eps_bearer_identity->eps_bearer_identity); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return NULL; } } else if (message->esm.h.message_type == @@ -3291,10 +3295,11 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( if (!bearer) { ogs_error("No Bearer : Linked-EBI[%d]", linked_eps_bearer_identity->eps_bearer_identity); - ogs_assert(OGS_OK == - nas_eps_send_bearer_resource_allocation_reject( + r = nas_eps_send_bearer_resource_allocation_reject( mme_ue, pti, - OGS_NAS_ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY)); + OGS_NAS_ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return NULL; } @@ -3311,10 +3316,11 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( if (!bearer) { ogs_error("No Bearer : Linked-EBI[%d]", linked_eps_bearer_identity->eps_bearer_identity); - ogs_assert(OGS_OK == - nas_eps_send_bearer_resource_modification_reject( + r = nas_eps_send_bearer_resource_modification_reject( mme_ue, pti, - OGS_NAS_ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY)); + OGS_NAS_ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return NULL; } } @@ -3335,11 +3341,12 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( sess = mme_sess_find_by_apn(mme_ue, pdn_connectivity_request->access_point_name.apn); if (sess && create_action != OGS_GTP_CREATE_IN_ATTACH_REQUEST) { - ogs_assert(OGS_OK == - nas_eps_send_pdn_connectivity_reject( + r = nas_eps_send_pdn_connectivity_reject( sess, OGS_NAS_ESM_CAUSE_MULTIPLE_PDN_CONNECTIONS_FOR_A_GIVEN_APN_NOT_ALLOWED, - create_action)); + create_action); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_warn("APN duplicated [%s]", pdn_connectivity_request->access_point_name.apn); return NULL; @@ -3359,10 +3366,11 @@ mme_bearer_t *mme_bearer_find_or_add_by_message( if (!sess) { ogs_error("No Session : ESM message type[%d], PTI[%d]", message->esm.h.message_type, pti); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return NULL; } } diff --git a/src/mme/mme-gtp-path.c b/src/mme/mme-gtp-path.c index 1d601d9e9..883b6d548 100644 --- a/src/mme/mme-gtp-path.c +++ b/src/mme/mme-gtp-path.c @@ -76,6 +76,7 @@ static void _gtpv2_c_recv_cb(short when, ogs_socket_t fd, void *data) static void timeout(ogs_gtp_xact_t *xact, void *data) { + int r; mme_ue_t *mme_ue = NULL; enb_ue_t *enb_ue = NULL; mme_sess_t *sess = NULL; @@ -131,10 +132,11 @@ static void timeout(ogs_gtp_xact_t *xact, void *data) enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (enb_ue) { - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_warn("No S1 Context"); } diff --git a/src/mme/mme-path.c b/src/mme/mme-path.c index ea305769f..eb765ad60 100644 --- a/src/mme/mme-path.c +++ b/src/mme/mme-path.c @@ -26,6 +26,7 @@ void mme_send_delete_session_or_detach(mme_ue_t *mme_ue) { + int r; ogs_assert(mme_ue); switch (mme_ue->detach_type) { @@ -35,7 +36,9 @@ void mme_send_delete_session_or_detach(mme_ue_t *mme_ue) mme_gtp_send_delete_all_sessions( mme_ue, OGS_GTP_DELETE_SEND_DETACH_ACCEPT); } else { - ogs_assert(OGS_OK == nas_eps_send_detach_accept(mme_ue)); + r = nas_eps_send_detach_accept(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; @@ -94,6 +97,7 @@ void mme_send_delete_session_or_detach(mme_ue_t *mme_ue) void mme_send_delete_session_or_mme_ue_context_release(mme_ue_t *mme_ue) { + int r; ogs_assert(mme_ue); if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) { @@ -102,10 +106,11 @@ void mme_send_delete_session_or_mme_ue_context_release(mme_ue_t *mme_ue) } else { enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (enb_ue) { - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_warn("[%s] No S1 Context", mme_ue->imsi_bcd); } @@ -114,6 +119,7 @@ void mme_send_delete_session_or_mme_ue_context_release(mme_ue_t *mme_ue) void mme_send_release_access_bearer_or_ue_context_release(enb_ue_t *enb_ue) { + int r; mme_ue_t *mme_ue = NULL; ogs_assert(enb_ue); @@ -125,15 +131,17 @@ void mme_send_release_access_bearer_or_ue_context_release(enb_ue_t *enb_ue) mme_ue, OGS_GTP_RELEASE_SEND_UE_CONTEXT_RELEASE_COMMAND)); } else { ogs_debug("No UE Context"); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } void mme_send_after_paging(mme_ue_t *mme_ue, bool failed) { + int r; mme_bearer_t *bearer = NULL; ogs_assert(mme_ue); @@ -168,8 +176,9 @@ void mme_send_after_paging(mme_ue_t *mme_ue, bool failed) mme_gtp_send_create_bearer_response( bearer, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE)); } else { - ogs_assert(OGS_OK == - nas_eps_send_activate_dedicated_bearer_context_request(bearer)); + r = nas_eps_send_activate_dedicated_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; case MME_PAGING_TYPE_UPDATE_BEARER: @@ -190,12 +199,13 @@ void mme_send_after_paging(mme_ue_t *mme_ue, bool failed) goto cleanup; } - ogs_assert(OGS_OK == - nas_eps_send_modify_bearer_context_request(bearer, + r = nas_eps_send_modify_bearer_context_request(bearer, (xact->update_flags & OGS_GTP_MODIFY_QOS_UPDATE) ? 1 : 0, (xact->update_flags & - OGS_GTP_MODIFY_TFT_UPDATE) ? 1 : 0)); + OGS_GTP_MODIFY_TFT_UPDATE) ? 1 : 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; case MME_PAGING_TYPE_DELETE_BEARER: @@ -210,8 +220,9 @@ void mme_send_after_paging(mme_ue_t *mme_ue, bool failed) mme_gtp_send_delete_bearer_response( bearer, OGS_GTP2_CAUSE_UNABLE_TO_PAGE_UE)); } else { - ogs_assert(OGS_OK == - nas_eps_send_deactivate_bearer_context_request(bearer)); + r = nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; case MME_PAGING_TYPE_CS_CALL_SERVICE: @@ -239,7 +250,9 @@ void mme_send_after_paging(mme_ue_t *mme_ue, bool failed) /* Nothing */ ogs_warn("MME-initiated Detach cannot be invoked"); } else { - ogs_assert(OGS_OK == nas_eps_send_detach_request(mme_ue)); + r = nas_eps_send_detach_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) { ogs_assert(OGS_OK == sgsap_send_detach_indication(mme_ue)); } else { diff --git a/src/mme/mme-s11-handler.c b/src/mme/mme-s11-handler.c index 50e784012..7763d94c8 100644 --- a/src/mme/mme-s11-handler.c +++ b/src/mme/mme-s11-handler.c @@ -81,7 +81,7 @@ void mme_s11_handle_create_session_response( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_create_session_response_t *rsp) { - int rv, i; + int i, r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; uint8_t session_cause = OGS_GTP2_CAUSE_UNDEFINED_VALUE; uint8_t bearer_cause = OGS_GTP2_CAUSE_UNDEFINED_VALUE; @@ -151,8 +151,11 @@ void mme_s11_handle_create_session_response( if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) { ogs_error("[%s] Attach reject [Cause:%d]", mme_ue->imsi_bcd, session_cause); - ogs_assert(OGS_OK == nas_eps_send_attach_reject(mme_ue, - OGS_NAS_EMM_CAUSE_NETWORK_FAILURE, OGS_NAS_ESM_CAUSE_NETWORK_FAILURE)); + r = nas_eps_send_attach_reject(mme_ue, + OGS_NAS_EMM_CAUSE_NETWORK_FAILURE, + OGS_NAS_ESM_CAUSE_NETWORK_FAILURE); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -216,9 +219,11 @@ void mme_s11_handle_create_session_response( if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) { ogs_error("[%s] Attach reject [Cause:%d]", mme_ue->imsi_bcd, session_cause); - ogs_assert(OGS_OK == nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_NETWORK_FAILURE, - OGS_NAS_ESM_CAUSE_NETWORK_FAILURE)); + OGS_NAS_ESM_CAUSE_NETWORK_FAILURE); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -246,9 +251,11 @@ void mme_s11_handle_create_session_response( mme_ue->imsi_bcd, bearer_cause); if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) { ogs_error("[%s] Attach reject", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_NETWORK_FAILURE, - OGS_NAS_ESM_CAUSE_NETWORK_FAILURE)); + OGS_NAS_ESM_CAUSE_NETWORK_FAILURE); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -264,8 +271,11 @@ void mme_s11_handle_create_session_response( ogs_error("[%s] GTP Cause [VALUE:%d]", mme_ue->imsi_bcd, session_cause); if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) { ogs_error("[%s] Attach reject", mme_ue->imsi_bcd); - ogs_assert(OGS_OK == nas_eps_send_attach_reject(mme_ue, - OGS_NAS_EMM_CAUSE_NETWORK_FAILURE, OGS_NAS_ESM_CAUSE_NETWORK_FAILURE)); + r = nas_eps_send_attach_reject(mme_ue, + OGS_NAS_EMM_CAUSE_NETWORK_FAILURE, + OGS_NAS_ESM_CAUSE_NETWORK_FAILURE); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -395,15 +405,17 @@ void mme_s11_handle_create_session_response( } else { ogs_assert(OGS_PDU_SESSION_TYPE_IS_VALID( session->paa.session_type)); - ogs_assert(OGS_OK == - nas_eps_send_attach_accept(mme_ue)); + r = nas_eps_send_attach_accept(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (create_action == OGS_GTP_CREATE_IN_UPLINK_NAS_TRANSPORT) { ogs_assert(OGS_PDU_SESSION_TYPE_IS_VALID(session->paa.session_type)); - ogs_assert(OGS_OK == - nas_eps_send_activate_default_bearer_context_request( - bearer, create_action)); + r = nas_eps_send_activate_default_bearer_context_request( + bearer, create_action); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) { GTP_COUNTER_CHECK(mme_ue, GTP_COUNTER_CREATE_SESSION_BY_PATH_SWITCH, @@ -411,7 +423,9 @@ void mme_s11_handle_create_session_response( mme_timer_cfg(MME_TIMER_S11_HOLDING)->duration); sgw_ue_associate_mme_ue(target_ue, mme_ue); - ogs_assert(OGS_OK == s1ap_send_path_switch_ack(mme_ue, true)); + r = s1ap_send_path_switch_ack(mme_ue, true); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ); } else { @@ -424,7 +438,7 @@ void mme_s11_handle_modify_bearer_response( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_modify_bearer_response_t *rsp) { - int rv; + int r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; uint8_t session_cause = OGS_GTP2_CAUSE_UNDEFINED_VALUE; int modify_action = 0; @@ -511,10 +525,14 @@ void mme_s11_handle_modify_bearer_response( switch (modify_action) { case OGS_GTP_MODIFY_IN_PATH_SWITCH_REQUEST: - ogs_assert(OGS_OK == s1ap_send_path_switch_ack(mme_ue, false)); + r = s1ap_send_path_switch_ack(mme_ue, false); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; case OGS_GTP_MODIFY_IN_E_RAB_MODIFICATION: - ogs_assert(OGS_OK == s1ap_send_e_rab_modification_confirm(mme_ue)); + r = s1ap_send_e_rab_modification_confirm(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; default: break; @@ -525,7 +543,7 @@ void mme_s11_handle_delete_session_response( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_delete_session_response_t *rsp) { - int rv; + int r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; int action = 0; sgw_ue_t *source_ue = NULL, *target_ue = NULL; @@ -601,7 +619,9 @@ void mme_s11_handle_delete_session_response( } else if (action == OGS_GTP_DELETE_SEND_DETACH_ACCEPT) { if (mme_sess_count(mme_ue) == 1) /* Last Session */ { - ogs_assert(OGS_OK == nas_eps_send_detach_accept(mme_ue)); + r = nas_eps_send_detach_accept(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else if (action == @@ -609,8 +629,9 @@ void mme_s11_handle_delete_session_response( mme_bearer_t *bearer = mme_default_bearer_in_sess(sess); ogs_expect_or_return(bearer); - ogs_assert(OGS_OK == - nas_eps_send_deactivate_bearer_context_request(bearer)); + r = nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* * mme_sess_remove() should not be called here. @@ -631,10 +652,11 @@ void mme_s11_handle_delete_session_response( } } else { ogs_assert(mme_ue->enb_ue); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(mme_ue->enb_ue, + r = s1ap_send_ue_context_release_command(mme_ue->enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -645,10 +667,11 @@ void mme_s11_handle_delete_session_response( enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (enb_ue) { - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0)); + S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else ogs_error("ENB-S1 Context has already been removed"); } @@ -659,10 +682,11 @@ void mme_s11_handle_delete_session_response( &mme_ue->pdn_connectivity_request); if (rv != OGS_OK) { ogs_error("nas_eps_send_emm_to_esm() failed"); - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -701,6 +725,7 @@ void mme_s11_handle_create_bearer_request( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue, ogs_gtp2_create_bearer_request_t *req) { + int r; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; mme_bearer_t *bearer = NULL, *default_bearer = NULL; mme_sess_t *sess = NULL; @@ -863,10 +888,13 @@ void mme_s11_handle_create_bearer_request( if (ECM_IDLE(mme_ue)) { MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_CREATE_BEARER, bearer); - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_assert(OGS_OK == - nas_eps_send_activate_dedicated_bearer_context_request(bearer)); + r = nas_eps_send_activate_dedicated_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else { /* @@ -880,6 +908,7 @@ void mme_s11_handle_update_bearer_request( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue, ogs_gtp2_update_bearer_request_t *req) { + int r; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; mme_bearer_t *bearer = NULL; mme_sess_t *sess = NULL; @@ -988,12 +1017,15 @@ void mme_s11_handle_update_bearer_request( if (ECM_IDLE(mme_ue)) { MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_UPDATE_BEARER, bearer); - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_assert(OGS_OK == - nas_eps_send_modify_bearer_context_request(bearer, + r = nas_eps_send_modify_bearer_context_request(bearer, req->bearer_contexts.bearer_level_qos.presence, - req->bearer_contexts.tft.presence)); + req->bearer_contexts.tft.presence); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } else { ogs_error("[IGNORE] Update Bearer Request : " @@ -1001,10 +1033,11 @@ void mme_s11_handle_update_bearer_request( if (xact->xid & OGS_GTP_CMD_XACT_ID) { /* MME received Bearer Resource Modification Request */ - ogs_assert(OGS_OK == - nas_eps_send_bearer_resource_modification_reject( + r = nas_eps_send_bearer_resource_modification_reject( mme_ue, sess->pti, - OGS_NAS_ESM_CAUSE_SERVICE_OPTION_NOT_SUPPORTED)); + OGS_NAS_ESM_CAUSE_SERVICE_OPTION_NOT_SUPPORTED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } ogs_assert(OGS_OK == @@ -1017,6 +1050,7 @@ void mme_s11_handle_delete_bearer_request( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue, ogs_gtp2_delete_bearer_request_t *req) { + int r; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; mme_bearer_t *bearer = NULL; @@ -1121,10 +1155,13 @@ void mme_s11_handle_delete_bearer_request( if (ECM_IDLE(mme_ue)) { MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_DELETE_BEARER, bearer); - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_assert(OGS_OK == - nas_eps_send_deactivate_bearer_context_request(bearer)); + r = nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } @@ -1132,7 +1169,7 @@ void mme_s11_handle_release_access_bearers_response( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_release_access_bearers_response_t *rsp) { - int rv; + int r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; int action = 0; enb_ue_t *enb_ue = NULL; @@ -1197,10 +1234,11 @@ void mme_s11_handle_release_access_bearers_response( if (action == OGS_GTP_RELEASE_SEND_UE_CONTEXT_RELEASE_COMMAND) { enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (enb_ue) { - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0)); + S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_error("ENB-S1 Context has already been removed"); } @@ -1232,9 +1270,11 @@ void mme_s11_handle_release_access_bearers_response( enb_ue_remove(enb_ue); - if (ogs_list_count(&enb->enb_ue_list) == 0) - ogs_assert(OGS_OK == - s1ap_send_s1_reset_ack(enb, NULL)); + if (ogs_list_count(&enb->enb_ue_list) == 0) { + r = s1ap_send_s1_reset_ack(enb, NULL); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } } else { ogs_error("ENB-S1 Context has already been removed"); } @@ -1265,7 +1305,9 @@ void mme_s11_handle_release_access_bearers_response( * where PartOfS1_interface was requested * REMOVED */ ogs_assert(enb->s1_reset_ack); - s1ap_send_to_enb(enb, enb->s1_reset_ack, S1AP_NON_UE_SIGNALLING); + r = s1ap_send_to_enb(enb, enb->s1_reset_ack, S1AP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* Clear S1-Reset Ack Buffer */ enb->s1_reset_ack = NULL; @@ -1284,6 +1326,7 @@ void mme_s11_handle_downlink_data_notification( ogs_gtp2_downlink_data_notification_t *noti) { uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; + int r; mme_bearer_t *bearer = NULL; sgw_ue_t *sgw_ue = NULL; @@ -1370,7 +1413,9 @@ void mme_s11_handle_downlink_data_notification( if (ECM_IDLE(mme_ue)) { MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION, bearer); - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (ECM_CONNECTED(mme_ue)) { if (cause_value == OGS_GTP2_CAUSE_ERROR_INDICATION_RECEIVED) { @@ -1406,10 +1451,11 @@ void mme_s11_handle_downlink_data_notification( enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue); ogs_assert(enb_ue); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_S1_PAGING, 0)); + S1AP_UE_CTX_REL_S1_PAGING, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_assert(OGS_OK == mme_gtp_send_downlink_data_notification_ack( @@ -1422,14 +1468,13 @@ void mme_s11_handle_create_indirect_data_forwarding_tunnel_response( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_create_indirect_data_forwarding_tunnel_response_t *rsp) { - int rv; + int i, r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; uint8_t session_cause = OGS_GTP2_CAUSE_UNDEFINED_VALUE; sgw_ue_t *sgw_ue = NULL; mme_bearer_t *bearer = NULL; mme_ue_t *mme_ue = NULL; enb_ue_t *source_ue = NULL; - int i; ogs_gtp2_f_teid_t *teid = NULL; @@ -1540,14 +1585,16 @@ void mme_s11_handle_create_indirect_data_forwarding_tunnel_response( source_ue = enb_ue_cycle(mme_ue->enb_ue); ogs_assert(source_ue); - ogs_assert(OGS_OK == s1ap_send_handover_command(source_ue)); + r = s1ap_send_handover_command(source_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void mme_s11_handle_delete_indirect_data_forwarding_tunnel_response( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_delete_indirect_data_forwarding_tunnel_response_t *rsp) { - int rv; + int r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; uint8_t session_cause = OGS_GTP2_CAUSE_UNDEFINED_VALUE; int action = 0; @@ -1637,8 +1684,9 @@ void mme_s11_handle_delete_indirect_data_forwarding_tunnel_response( if (action == OGS_GTP_DELETE_INDIRECT_HANDOVER_COMPLETE) { /* Nothing to do */ } else if (action == OGS_GTP_DELETE_INDIRECT_HANDOVER_CANCEL) { - ogs_assert(OGS_OK == - s1ap_send_handover_cancel_ack(mme_ue->enb_ue)); + r = s1ap_send_handover_cancel_ack(mme_ue->enb_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_fatal("Invalid action = %d", action); ogs_assert_if_reached(); @@ -1649,7 +1697,7 @@ void mme_s11_handle_bearer_resource_failure_indication( ogs_gtp_xact_t *xact, mme_ue_t *mme_ue_from_teid, ogs_gtp2_bearer_resource_failure_indication_t *ind) { - int rv; + int r, rv; uint8_t cause_value = OGS_GTP2_CAUSE_UNDEFINED_VALUE; mme_bearer_t *bearer = NULL; @@ -1700,9 +1748,10 @@ void mme_s11_handle_bearer_resource_failure_indication( ogs_debug(" MME_S11_TEID[%d] SGW_S11_TEID[%d]", mme_ue->mme_s11_teid, sgw_ue->sgw_s11_teid); - ogs_assert(OGS_OK == - nas_eps_send_bearer_resource_modification_reject( - mme_ue, sess->pti, esm_cause_from_gtp(cause_value))); + r = nas_eps_send_bearer_resource_modification_reject( + mme_ue, sess->pti, esm_cause_from_gtp(cause_value)); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); if (!sgw_ue || cause_value == OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND) { diff --git a/src/mme/mme-s6a-handler.c b/src/mme/mme-s6a-handler.c index 8147d04a4..155bf58cd 100644 --- a/src/mme/mme-s6a-handler.c +++ b/src/mme/mme-s6a-handler.c @@ -39,6 +39,7 @@ static uint8_t mme_ue_session_from_slice_data(mme_ue_t *mme_ue, uint8_t mme_s6a_handle_aia( mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message) { + int r; ogs_diam_s6a_aia_message_t *aia_message = NULL; ogs_diam_e_utran_vector_t *e_utran_vector = NULL; @@ -66,7 +67,9 @@ uint8_t mme_s6a_handle_aia( if (mme_ue->nas_eps.ksi == OGS_NAS_KSI_NO_KEY_IS_AVAILABLE) mme_ue->nas_eps.ksi = 0; - ogs_assert(OGS_OK == nas_eps_send_authentication_request(mme_ue)); + r = nas_eps_send_authentication_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED; } @@ -77,7 +80,7 @@ uint8_t mme_s6a_handle_ula( ogs_diam_s6a_ula_message_t *ula_message = NULL; ogs_subscription_data_t *subscription_data = NULL; ogs_slice_data_t *slice_data = NULL; - int rv, num_of_session; + int r, rv, num_of_session; ogs_assert(mme_ue); ogs_assert(s6a_message); @@ -115,9 +118,10 @@ uint8_t mme_s6a_handle_ula( return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED; } } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_TAU_REQUEST) { - ogs_assert(OGS_OK == - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_InitialContextSetup)); + r = nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_InitialContextSetup); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { ogs_error("Invalid Type[%d]", mme_ue->nas_eps.type); return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED; @@ -199,6 +203,7 @@ uint8_t mme_s6a_handle_idr( void mme_s6a_handle_clr(mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message) { + int r; ogs_diam_s6a_clr_message_t *clr_message = NULL; ogs_assert(mme_ue); ogs_assert(s6a_message); @@ -260,9 +265,13 @@ void mme_s6a_handle_clr(mme_ue_t *mme_ue, ogs_diam_s6a_message_t *s6a_message) */ if (ECM_IDLE(mme_ue)) { MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_DETACH_TO_UE, NULL); - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else { - ogs_assert(OGS_OK == nas_eps_send_detach_request(mme_ue)); + r = nas_eps_send_detach_request(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) { ogs_assert(OGS_OK == sgsap_send_detach_indication(mme_ue)); } else { diff --git a/src/mme/mme-sm.c b/src/mme/mme-sm.c index caa19ab47..ee4dcfc20 100644 --- a/src/mme/mme-sm.c +++ b/src/mme/mme-sm.c @@ -62,7 +62,7 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) ogs_s1ap_message_t s1ap_message; ogs_pkbuf_t *pkbuf = NULL; - int rc; + int rc, r; ogs_nas_eps_message_t nas_message; enb_ue_t *enb_ue = NULL; @@ -196,10 +196,11 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) ogs_fsm_dispatch(&enb->sm, e); } else { ogs_warn("Cannot decode S1AP message"); - ogs_assert(OGS_OK == - s1ap_send_error_indication( + r = s1ap_send_error_indication( enb, NULL, NULL, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } ogs_s1ap_free(&s1ap_message); @@ -217,7 +218,9 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) pkbuf = e->pkbuf; ogs_assert(pkbuf); - ogs_expect(OGS_OK == s1ap_send_to_enb_ue(enb_ue, pkbuf)); + r = s1ap_send_to_enb_ue(enb_ue, pkbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_timer_delete(e->timer); break; case MME_TIMER_S1_HOLDING: @@ -251,11 +254,12 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) if (!mme_ue) { mme_ue = mme_ue_add(enb_ue); if (mme_ue == NULL) { - ogs_expect(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_misc, S1AP_CauseMisc_control_processing_overload, - S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_pkbuf_free(pkbuf); return; } @@ -296,10 +300,11 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) /* De-associate S1 with NAS/EMM */ enb_ue_deassociate(mme_ue->enb_ue); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(mme_ue->enb_ue, + r = s1ap_send_ue_context_release_command(mme_ue->enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } enb_ue_associate_mme_ue(enb_ue, mme_ue); } @@ -409,14 +414,16 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) ogs_error("S1 context has already been removed"); break; } - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, emm_cause, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + r = nas_eps_send_attach_reject(mme_ue, emm_cause, + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; case OGS_DIAM_S6A_CMD_CODE_UPDATE_LOCATION: @@ -429,14 +436,16 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) ogs_error("S1 context has already been removed"); break; } - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, emm_cause, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + r = nas_eps_send_attach_reject(mme_ue, emm_cause, + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(enb_ue, + r = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } mme_ue->location_updated_but_not_canceled_yet = true; diff --git a/src/mme/nas-path.c b/src/mme/nas-path.c index 5989f2822..b26fbea85 100644 --- a/src/mme/nas-path.c +++ b/src/mme/nas-path.c @@ -28,16 +28,21 @@ int nas_eps_send_to_enb(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf) { + int rv; + ogs_assert(pkbuf); mme_ue = mme_ue_cycle(mme_ue); if (!mme_ue) { - ogs_warn("UE(mme-ue) context has already been removed"); + ogs_error("UE(mme-ue) context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } - return s1ap_send_to_enb_ue(mme_ue->enb_ue, pkbuf); + rv = s1ap_send_to_enb_ue(mme_ue->enb_ue, pkbuf); + ogs_expect(rv == OGS_OK); + + return rv; } int nas_eps_send_emm_to_esm(mme_ue_t *mme_ue, @@ -75,20 +80,23 @@ int nas_eps_send_to_downlink_nas_transport(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf) mme_ue = mme_ue_cycle(mme_ue); if (!mme_ue) { - ogs_warn("UE(mme-ue) context has already been removed"); + ogs_error("UE(mme-ue) context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (!enb_ue) { - ogs_warn("S1 context has already been removed"); + ogs_error("S1 context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } s1apbuf = s1ap_build_downlink_nas_transport(enb_ue, pkbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_downlink_nas_transport() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -116,19 +124,31 @@ int nas_eps_send_attach_accept(mme_ue_t *mme_ue) esmbuf = esm_build_activate_default_bearer_context_request( sess, OGS_GTP_CREATE_IN_ATTACH_REQUEST); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_activate_default_bearer_context_request() failed"); + return OGS_ERROR; + } emmbuf = emm_build_attach_accept(mme_ue, esmbuf); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_attach_accept() failed"); + return OGS_ERROR; + } CLEAR_MME_UE_TIMER(mme_ue->t3450); mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf); - ogs_expect_or_return_val(mme_ue->t3450.pkbuf, OGS_ERROR); + if (!mme_ue->t3450.pkbuf) { + ogs_error("ogs_pkbuf_copy(mme_ue->t3450.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(mme_ue->t3450.timer, mme_timer_cfg(MME_TIMER_T3450)->duration); s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, emmbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_initial_context_setup_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -143,7 +163,11 @@ int nas_eps_send_attach_reject(mme_ue_t *mme_ue, mme_sess_t *sess = NULL; ogs_pkbuf_t *esmbuf = NULL, *emmbuf = NULL; - ogs_expect_or_return_val(mme_ue, OGS_ERROR); + mme_ue = mme_ue_cycle(mme_ue); + if (!mme_ue) { + ogs_error("UE(mme-ue) context has already been removed"); + return OGS_NOTFOUND; + } ogs_debug("[%s] Attach reject", mme_ue->imsi_bcd); ogs_debug(" Cause[%d]", emm_cause); @@ -152,13 +176,19 @@ int nas_eps_send_attach_reject(mme_ue_t *mme_ue, if (sess) { esmbuf = esm_build_pdn_connectivity_reject( sess, esm_cause, OGS_GTP_CREATE_IN_ATTACH_REQUEST); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_pdn_connectivity_reject() failed"); + return OGS_ERROR; + } } emmbuf = emm_build_attach_reject(emm_cause, esmbuf); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_attach_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -174,19 +204,24 @@ int nas_eps_send_identity_request(mme_ue_t *mme_ue) if (mme_ue->t3470.pkbuf) { emmbuf = mme_ue->t3470.pkbuf; - ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_identity_request(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_identity_request() failed"); + return OGS_ERROR; + } } mme_ue->t3470.pkbuf = ogs_pkbuf_copy(emmbuf); - ogs_expect_or_return_val(mme_ue->t3470.pkbuf, OGS_ERROR); + if (!mme_ue->t3470.pkbuf) { + ogs_error("ogs_pkbuf_copy(mme_ue->t3470.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(mme_ue->t3470.timer, mme_timer_cfg(MME_TIMER_T3470)->duration); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -202,19 +237,24 @@ int nas_eps_send_authentication_request(mme_ue_t *mme_ue) if (mme_ue->t3460.pkbuf) { emmbuf = mme_ue->t3460.pkbuf; - ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_authentication_request(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_authentication_request() failed"); + return OGS_ERROR; + } } mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf); - ogs_expect_or_return_val(mme_ue->t3460.pkbuf, OGS_ERROR); + if (!mme_ue->t3460.pkbuf) { + ogs_error("ogs_pkbuf_copy(mme_ue->t3460.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(mme_ue->t3460.timer, mme_timer_cfg(MME_TIMER_T3460)->duration); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -230,19 +270,24 @@ int nas_eps_send_security_mode_command(mme_ue_t *mme_ue) if (mme_ue->t3460.pkbuf) { emmbuf = mme_ue->t3460.pkbuf; - ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_security_mode_command(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_security_mode_command() failed"); + return OGS_ERROR; + } } mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf); - ogs_expect_or_return_val(mme_ue->t3460.pkbuf, OGS_ERROR); + if (!mme_ue->t3460.pkbuf) { + ogs_error("ogs_pkbuf_copy(mme_ue->t3460.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(mme_ue->t3460.timer, mme_timer_cfg(MME_TIMER_T3460)->duration); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -257,10 +302,13 @@ int nas_eps_send_authentication_reject(mme_ue_t *mme_ue) ogs_debug("[%s] Authentication reject", mme_ue->imsi_bcd); emmbuf = emm_build_authentication_reject(); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_authentication_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -274,19 +322,24 @@ int nas_eps_send_detach_request(mme_ue_t *mme_ue) if (mme_ue->t3422.pkbuf) { emmbuf = mme_ue->t3422.pkbuf; - ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_detach_request(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_detach_request() failed"); + return OGS_ERROR; + } } mme_ue->t3422.pkbuf = ogs_pkbuf_copy(emmbuf); - ogs_expect_or_return_val(mme_ue->t3422.pkbuf, OGS_ERROR); + if (!mme_ue->t3422.pkbuf) { + ogs_error("ogs_pkbuf_copy(mme_ue->t3422.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(mme_ue->t3422.timer, mme_timer_cfg(MME_TIMER_T3422)->duration); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -300,17 +353,26 @@ int nas_eps_send_detach_accept(mme_ue_t *mme_ue) ogs_assert(mme_ue); enb_ue = enb_ue_cycle(mme_ue->enb_ue); - ogs_expect_or_return_val(enb_ue, OGS_ERROR); + if (!enb_ue) { + ogs_error("S1 context has already been removed"); + return OGS_NOTFOUND; + } ogs_debug("[%s] Detach accept", mme_ue->imsi_bcd); /* reply with detach accept */ if (mme_ue->nas_eps.detach.switch_off == 0) { emmbuf = emm_build_detach_accept(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_detach_accept() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + if (rv != OGS_OK) { + ogs_error("nas_eps_send_to_downlink_nas_transport() failed"); + return rv; + } } rv = s1ap_send_ue_context_release_command(enb_ue, @@ -333,28 +395,29 @@ int nas_eps_send_pdn_connectivity_reject( ogs_assert(mme_ue); if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) { - enb_ue_t *enb_ue = NULL; - /* During the UE-attach process, we'll send Attach-Reject * with pyggybacking PDN-connectivity-Reject */ rv = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_ESM_FAILURE, esm_cause); - ogs_expect(rv == OGS_OK); - - enb_ue = enb_ue_cycle(mme_ue->enb_ue); - if (enb_ue) { - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(mme_ue->enb_ue, - S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); + if (rv != OGS_OK) { + ogs_error("nas_eps_send_attach_reject() failed"); + return rv; } + + rv = s1ap_send_ue_context_release_command(mme_ue->enb_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0); + ogs_expect(rv == OGS_OK); } else { esmbuf = esm_build_pdn_connectivity_reject( sess, esm_cause, create_action); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_pdn_connectivity_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); } return rv; @@ -372,19 +435,24 @@ int nas_eps_send_esm_information_request(mme_bearer_t *bearer) if (bearer->t3489.pkbuf) { esmbuf = bearer->t3489.pkbuf; - ogs_expect_or_return_val(esmbuf, OGS_ERROR); } else { esmbuf = esm_build_information_request(bearer); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_information_request() failed"); + return OGS_ERROR; + } } bearer->t3489.pkbuf = ogs_pkbuf_copy(esmbuf); - ogs_expect_or_return_val(bearer->t3489.pkbuf, OGS_ERROR); + if (!bearer->t3489.pkbuf) { + ogs_error("ogs_pkbuf_copy(bearer->t3489) failed"); + return OGS_ERROR; + } ogs_timer_start(bearer->t3489.timer, mme_timer_cfg(MME_TIMER_T3489)->duration); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -406,10 +474,16 @@ int nas_eps_send_activate_default_bearer_context_request( esmbuf = esm_build_activate_default_bearer_context_request( sess, create_action); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_activate_default_bearer_context_request() failed"); + return OGS_ERROR; + } s1apbuf = s1ap_build_e_rab_setup_request(bearer, esmbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_e_rab_setup_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -430,10 +504,17 @@ int nas_eps_send_activate_dedicated_bearer_context_request( ogs_assert(mme_ue); esmbuf = esm_build_activate_dedicated_bearer_context_request(bearer); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error( + "esm_build_activate_dedicated_bearer_context_request() failed"); + return OGS_ERROR; + } s1apbuf = s1ap_build_e_rab_setup_request(bearer, esmbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_e_rab_setup_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -443,12 +524,15 @@ int nas_eps_send_activate_dedicated_bearer_context_request( void nas_eps_send_activate_all_dedicated_bearers(mme_bearer_t *default_bearer) { + int r; ogs_assert(default_bearer); mme_bearer_t *dedicated_bearer = mme_bearer_next(default_bearer); while (dedicated_bearer) { - nas_eps_send_activate_dedicated_bearer_context_request( + r = nas_eps_send_activate_dedicated_bearer_context_request( dedicated_bearer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); dedicated_bearer = mme_bearer_next(dedicated_bearer); } } @@ -467,17 +551,23 @@ int nas_eps_send_modify_bearer_context_request( esmbuf = esm_build_modify_bearer_context_request( bearer, qos_presence, tft_presence); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_modify_bearer_context_request() failed"); + return OGS_ERROR; + } if (qos_presence == 1) { s1apbuf = s1ap_build_e_rab_modify_request(bearer, esmbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_e_rab_modify_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); } else { rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); } return rv; @@ -496,11 +586,17 @@ int nas_eps_send_deactivate_bearer_context_request(mme_bearer_t *bearer) esmbuf = esm_build_deactivate_bearer_context_request( bearer, OGS_NAS_ESM_CAUSE_REGULAR_DEACTIVATION); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_deactivate_bearer_context_request() failed"); + return OGS_ERROR; + } s1apbuf = s1ap_build_e_rab_release_command(bearer, esmbuf, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_e_rab_release_command() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -519,10 +615,13 @@ int nas_eps_send_bearer_resource_allocation_reject( esmbuf = esm_build_bearer_resource_allocation_reject( mme_ue, pti, esm_cause); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_bearer_resource_allocation_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -538,10 +637,13 @@ int nas_eps_send_bearer_resource_modification_reject( esmbuf = esm_build_bearer_resource_modification_reject( mme_ue, pti, esm_cause); - ogs_expect_or_return_val(esmbuf, OGS_ERROR); + if (!esmbuf) { + ogs_error("esm_build_bearer_resource_modification_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -557,12 +659,18 @@ int nas_eps_send_tau_accept( ogs_debug("[%s] Tracking area update accept", mme_ue->imsi_bcd); emmbuf = emm_build_tau_accept(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_tau_accept() failed"); + return OGS_ERROR; + } if (mme_ue->next.m_tmsi) { CLEAR_MME_UE_TIMER(mme_ue->t3450); mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf); - ogs_expect_or_return_val(mme_ue->t3450.pkbuf, OGS_ERROR); + if (!mme_ue->t3450.pkbuf) { + ogs_error("ogs_pkbuf_copy(mme_ue->t3450.pkbuf) failed"); + return OGS_ERROR; + } ogs_timer_start(mme_ue->t3450.timer, mme_timer_cfg(MME_TIMER_T3450)->duration); } @@ -570,13 +678,16 @@ int nas_eps_send_tau_accept( if (procedureCode == S1AP_ProcedureCode_id_InitialContextSetup) { ogs_pkbuf_t *s1apbuf = NULL; s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, emmbuf); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_initial_context_setup_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); } else if (procedureCode == S1AP_ProcedureCode_id_downlinkNASTransport) { rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); } else ogs_assert_if_reached(); @@ -594,10 +705,13 @@ int nas_eps_send_tau_reject(mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause) /* Build TAU reject */ emmbuf = emm_build_tau_reject(emm_cause, mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_tau_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -614,10 +728,13 @@ int nas_eps_send_service_reject(mme_ue_t *mme_ue, /* Build Service Reject */ emmbuf = emm_build_service_reject(emm_cause, mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_service_reject() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -632,10 +749,13 @@ int nas_eps_send_cs_service_notification(mme_ue_t *mme_ue) ogs_debug("[%s] CS Service Notification", mme_ue->imsi_bcd); emmbuf = emm_build_cs_service_notification(mme_ue); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_cs_service_notification() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } @@ -653,10 +773,13 @@ int nas_eps_send_downlink_nas_transport( ogs_debug("[%s] Downlink NAS transport", mme_ue->imsi_bcd); emmbuf = emm_build_downlink_nas_transport(mme_ue, buffer, length); - ogs_expect_or_return_val(emmbuf, OGS_ERROR); + if (!emmbuf) { + ogs_error("emm_build_downlink_nas_transport() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return_val(rv == OGS_OK, rv); + ogs_expect(rv == OGS_OK); return rv; } diff --git a/src/mme/s1ap-handler.c b/src/mme/s1ap-handler.c index bbe57c4ad..6b524dced 100644 --- a/src/mme/s1ap-handler.c +++ b/src/mme/s1ap-handler.c @@ -68,7 +68,7 @@ static bool maximum_number_of_enbs_is_reached(void) void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i, j; + int i, j, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_S1SetupRequest_t *S1SetupRequest = NULL; @@ -163,7 +163,9 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) group = S1AP_Cause_PR_misc; cause = S1AP_CauseMisc_unspecified; - ogs_assert(OGS_OK == s1ap_send_s1_setup_failure(enb, group, cause)); + r = s1ap_send_s1_setup_failure(enb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -173,7 +175,9 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) group = S1AP_Cause_PR_misc; cause = S1AP_CauseMisc_unspecified; - ogs_assert(OGS_OK == s1ap_send_s1_setup_failure(enb, group, cause)); + r = s1ap_send_s1_setup_failure(enb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -183,17 +187,21 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) group = S1AP_Cause_PR_misc; cause = S1AP_CauseMisc_unknown_PLMN; - ogs_assert(OGS_OK == s1ap_send_s1_setup_failure(enb, group, cause)); + r = s1ap_send_s1_setup_failure(enb, group, cause); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } enb->state.s1_setup_success = true; - ogs_assert(OGS_OK == s1ap_send_s1_setup_response(enb)); + r = s1ap_send_s1_setup_response(enb); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) { - int i; + int i, r; char buf[OGS_ADDRSTRLEN]; S1AP_InitiatingMessage_t *initiatingMessage = NULL; @@ -251,19 +259,21 @@ void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } enb_ue = enb_ue_find_by_enb_ue_s1ap_id(enb, *ENB_UE_S1AP_ID); if (!enb_ue) { enb_ue = enb_ue_add(enb, *ENB_UE_S1AP_ID); if (enb_ue == NULL) { - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, NULL, + r = s1ap_send_error_indication(enb, NULL, NULL, S1AP_Cause_PR_misc, - S1AP_CauseMisc_control_processing_overload)); + S1AP_CauseMisc_control_processing_overload); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -313,10 +323,11 @@ void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) /* De-associate S1 with NAS/EMM */ enb_ue_deassociate(mme_ue->enb_ue); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(mme_ue->enb_ue, + r = s1ap_send_ue_context_release_command(mme_ue->enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, - S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0)); + S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } enb_ue_associate_mme_ue(enb_ue, mme_ue); } @@ -325,25 +336,28 @@ void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!NAS_PDU) { ogs_error("No NAS_PDU"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!TAI) { ogs_error("No TAI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -371,15 +385,17 @@ void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id, enb_ue->saved.tai.tac, enb_ue->saved.e_cgi.cell_id); - s1ap_send_to_nas(enb_ue, + r = s1ap_send_to_nas(enb_ue, S1AP_ProcedureCode_id_initialUEMessage, NAS_PDU); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void s1ap_handle_uplink_nas_transport( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_UplinkNASTransport_t *UplinkNASTransport = NULL; @@ -436,9 +452,10 @@ void s1ap_handle_uplink_nas_transport( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -446,18 +463,20 @@ void s1ap_handle_uplink_nas_transport( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -466,25 +485,28 @@ void s1ap_handle_uplink_nas_transport( if (!NAS_PDU) { ogs_error("No NAS_PDU"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!TAI) { ogs_error("No TAI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -524,15 +546,17 @@ void s1ap_handle_uplink_nas_transport( ogs_assert_if_reached(); } - s1ap_send_to_nas(enb_ue, + r = s1ap_send_to_nas(enb_ue, S1AP_ProcedureCode_id_uplinkNASTransport, NAS_PDU); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void s1ap_handle_ue_capability_info_indication( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_UECapabilityInfoIndication_t *UECapabilityInfoIndication = NULL; @@ -578,9 +602,10 @@ void s1ap_handle_ue_capability_info_indication( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -588,18 +613,20 @@ void s1ap_handle_ue_capability_info_indication( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -616,9 +643,8 @@ void s1ap_handle_ue_capability_info_indication( void s1ap_handle_initial_context_setup_response( mme_enb_t *enb, ogs_s1ap_message_t *message) { - int rv; + int i, r, rv; char buf[OGS_ADDRSTRLEN]; - int i; S1AP_SuccessfulOutcome_t *successfulOutcome = NULL; S1AP_InitialContextSetupResponse_t *InitialContextSetupResponse = NULL; @@ -666,9 +692,10 @@ void s1ap_handle_initial_context_setup_response( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -676,18 +703,20 @@ void s1ap_handle_initial_context_setup_response( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -695,7 +724,10 @@ void s1ap_handle_initial_context_setup_response( enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id); mme_ue = enb_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (E_RABSetupListCtxtSURes) { int uli_presence = 0; @@ -712,28 +744,31 @@ void s1ap_handle_initial_context_setup_response( E_RABSetupListCtxtSURes->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABSetupItemCtxtSUResIEs_t"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } e_rab = &item->value.choice.E_RABSetupItemCtxtSURes; if (!e_rab) { ogs_error("No E_RABSetupItemCtxtSURes"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID); if (!bearer) { ogs_error("No Bearer [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -745,10 +780,11 @@ void s1ap_handle_initial_context_setup_response( if (rv != OGS_OK) { ogs_error("No transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -780,7 +816,7 @@ void s1ap_handle_initial_context_setup_failure( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_UnsuccessfulOutcome_t *unsuccessfulOutcome = NULL; S1AP_InitialContextSetupFailure_t *InitialContextSetupFailure = NULL; @@ -827,9 +863,10 @@ void s1ap_handle_initial_context_setup_failure( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -837,18 +874,20 @@ void s1ap_handle_initial_context_setup_failure( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -857,9 +896,10 @@ void s1ap_handle_initial_context_setup_failure( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -894,7 +934,7 @@ void s1ap_handle_ue_context_modification_response( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_SuccessfulOutcome_t *successfulOutcome = NULL; S1AP_UEContextModificationResponse_t *UEContextModificationResponse = NULL; @@ -938,9 +978,10 @@ void s1ap_handle_ue_context_modification_response( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -948,18 +989,20 @@ void s1ap_handle_ue_context_modification_response( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -967,7 +1010,10 @@ void s1ap_handle_ue_context_modification_response( enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id); mme_ue = enb_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } CLEAR_SERVICE_INDICATOR(mme_ue); } @@ -976,7 +1022,7 @@ void s1ap_handle_ue_context_modification_failure( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_UnsuccessfulOutcome_t *unsuccessfulOutcome = NULL; S1AP_UEContextModificationFailure_t *UEContextModificationFailure = NULL; @@ -1023,9 +1069,10 @@ void s1ap_handle_ue_context_modification_failure( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1033,18 +1080,20 @@ void s1ap_handle_ue_context_modification_failure( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1053,9 +1102,10 @@ void s1ap_handle_ue_context_modification_failure( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1063,7 +1113,10 @@ void s1ap_handle_ue_context_modification_failure( Cause->present, (int)Cause->choice.radioNetwork); mme_ue = enb_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } CLEAR_SERVICE_INDICATOR(mme_ue); } @@ -1071,9 +1124,8 @@ void s1ap_handle_ue_context_modification_failure( void s1ap_handle_e_rab_setup_response( mme_enb_t *enb, ogs_s1ap_message_t *message) { - int rv; + int i, r, rv; char buf[OGS_ADDRSTRLEN]; - int i; S1AP_SuccessfulOutcome_t *successfulOutcome = NULL; S1AP_E_RABSetupResponse_t *E_RABSetupResponse = NULL; @@ -1130,9 +1182,10 @@ void s1ap_handle_e_rab_setup_response( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1140,18 +1193,20 @@ void s1ap_handle_e_rab_setup_response( if (!enb_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1159,7 +1214,10 @@ void s1ap_handle_e_rab_setup_response( enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id); mme_ue = enb_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (E_RABSetupListBearerSURes) { for (i = 0; i < E_RABSetupListBearerSURes->list.count; i++) { @@ -1172,30 +1230,33 @@ void s1ap_handle_e_rab_setup_response( E_RABSetupListBearerSURes->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABSetupItemBearerSUResIEs_t"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_semantic_error)); + S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } e_rab = &item->value.choice.E_RABSetupItemBearerSURes; if (!e_rab) { ogs_error("No E_RABSetupItemBearerSURes"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_semantic_error)); + S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID); if (!bearer) { ogs_error("No Bearer [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1207,10 +1268,11 @@ void s1ap_handle_e_rab_setup_response( if (rv != OGS_OK) { ogs_error("No transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1244,10 +1306,11 @@ void s1ap_handle_e_rab_setup_response( if (!item) { ogs_error("No S1AP_E_RABItem_t"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_semantic_error)); + S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1279,7 +1342,7 @@ void s1ap_handle_ue_context_release_request( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_UEContextReleaseRequest_t *UEContextReleaseRequest = NULL; @@ -1325,20 +1388,22 @@ void s1ap_handle_ue_context_release_request( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID); if (!enb_ue) { ogs_warn("No ENB UE Context : MME_UE_S1AP_ID[%d]", (int)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1347,9 +1412,10 @@ void s1ap_handle_ue_context_release_request( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1377,7 +1443,7 @@ void s1ap_handle_ue_context_release_complete( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_SuccessfulOutcome_t *successfulOutcome = NULL; S1AP_UEContextReleaseComplete_t *UEContextReleaseComplete = NULL; @@ -1419,20 +1485,22 @@ void s1ap_handle_ue_context_release_complete( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID); if (!enb_ue) { ogs_warn("No ENB UE Context : MME_UE_S1AP_ID[%d]", (int)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1441,6 +1509,7 @@ void s1ap_handle_ue_context_release_complete( void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) { + int r; mme_ue_t *mme_ue = NULL; ogs_assert(enb_ue); @@ -1477,13 +1546,19 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) case S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK: ogs_debug(" Action: S1 normal release"); enb_ue_remove(enb_ue); - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } enb_ue_unlink(mme_ue); break; case S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE: ogs_debug(" Action: UE context remove"); enb_ue_remove(enb_ue); - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (mme_ue->location_updated_but_not_canceled_yet == true) { mme_s6a_send_pur(mme_ue); @@ -1498,7 +1573,10 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) enb_ue_source_deassociate_target(enb_ue); enb_ue_remove(enb_ue); - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (mme_ue_have_indirect_tunnel(mme_ue) == true) { ogs_assert(OGS_OK == mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( @@ -1516,7 +1594,10 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) enb_ue_source_deassociate_target(enb_ue); enb_ue_remove(enb_ue); - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (mme_ue_have_indirect_tunnel(mme_ue) == true) { ogs_assert(OGS_OK == mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( @@ -1527,9 +1608,13 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) ogs_warn(" Packet could be dropped during S1-Handover"); mme_ue_clear_indirect_tunnel(mme_ue); - ogs_expect_or_return(mme_ue->enb_ue); - ogs_assert(OGS_OK == - s1ap_send_handover_cancel_ack(mme_ue->enb_ue)); + if (!mme_ue->enb_ue) { + ogs_error("No S1 context"); + return; + } + r = s1ap_send_handover_cancel_ack(mme_ue->enb_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } break; case S1AP_UE_CTX_REL_S1_HANDOVER_FAILURE: @@ -1538,7 +1623,10 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) enb_ue_source_deassociate_target(enb_ue); enb_ue_remove(enb_ue); - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (mme_ue_have_indirect_tunnel(mme_ue) == true) { ogs_error("Check your eNodeB"); ogs_error(" We found INDIRECT TUNNEL in HandoverFailure"); @@ -1548,10 +1636,15 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) case S1AP_UE_CTX_REL_S1_PAGING: ogs_debug(" Action: S1 paging"); enb_ue_remove(enb_ue); - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } enb_ue_unlink(mme_ue); - ogs_assert(OGS_OK == s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); break; default: ogs_error("Invalid Action[%d]", enb_ue->ue_ctx_rel_action); @@ -1563,7 +1656,7 @@ void s1ap_handle_e_rab_modification_indication( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int rv, i; + int i, r, rv; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_E_RABModificationIndication_t *E_RABModificationIndication = NULL; @@ -1611,28 +1704,31 @@ void s1ap_handle_e_rab_modification_indication( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID); if (!enb_ue) { ogs_warn("No ENB UE Context : MME_UE_S1AP_ID[%d]", (int)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1641,14 +1737,18 @@ void s1ap_handle_e_rab_modification_indication( if (!E_RABToBeModifiedListBearerModInd) { ogs_error("No E_RABToBeModifiedListBearerModInd"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } mme_ue = enb_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } ogs_list_init(&mme_ue->bearer_to_modify_list); @@ -1662,28 +1762,31 @@ void s1ap_handle_e_rab_modification_indication( E_RABToBeModifiedListBearerModInd->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABToBeModifiedItemBearerModIndIEs_t"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } e_rab = &item->value.choice.E_RABToBeModifiedItemBearerModInd; if (!e_rab) { ogs_error("No E_RABToBeModifiedItemBearerModInd"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID); if (!bearer) { ogs_error("No Bearer [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1695,10 +1798,11 @@ void s1ap_handle_e_rab_modification_indication( if (rv != OGS_OK) { ogs_error("No transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1714,9 +1818,8 @@ void s1ap_handle_e_rab_modification_indication( void s1ap_handle_path_switch_request( mme_enb_t *enb, ogs_s1ap_message_t *message) { - int rv; + int i, r, rv; char buf[OGS_ADDRSTRLEN]; - int i; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_PathSwitchRequest_t *PathSwitchRequest = NULL; @@ -1786,16 +1889,18 @@ void s1ap_handle_path_switch_request( if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID); @@ -1808,10 +1913,14 @@ void s1ap_handle_path_switch_request( *ENB_UE_S1AP_ID, *MME_UE_S1AP_ID, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); - ogs_expect_or_return(s1apbuf); + if (!s1apbuf) { + ogs_error("s1ap_build_path_switch_failure() failed"); + return; + } - ogs_expect(OGS_OK == - s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING)); + r = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1820,9 +1929,10 @@ void s1ap_handle_path_switch_request( if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1833,9 +1943,10 @@ void s1ap_handle_path_switch_request( if (!TAI) { ogs_error("No TAI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1846,23 +1957,32 @@ void s1ap_handle_path_switch_request( if (!E_RABToBeSwitchedDLList) { ogs_error("No E_RABToBeSwitchedDLList"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } mme_ue = enb_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_error("No Security Context"); s1apbuf = s1ap_build_path_switch_failure( *ENB_UE_S1AP_ID, *MME_UE_S1AP_ID, S1AP_Cause_PR_nas, S1AP_CauseNas_authentication_failure); - ogs_expect_or_return(s1apbuf); + if (!s1apbuf) { + ogs_error("s1ap_build_path_switch_failure() failed"); + return; + } - s1ap_send_to_enb_ue(enb_ue, s1apbuf); + r = s1ap_send_to_enb_ue(enb_ue, s1apbuf); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1940,28 +2060,31 @@ void s1ap_handle_path_switch_request( E_RABToBeSwitchedDLList->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABToBeSwitchedDLItemIEs_t"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } e_rab = &item->value.choice.E_RABToBeSwitchedDLItem; if (!e_rab) { ogs_error("No E_RABToBeSwitchedDLItem"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID); if (!bearer) { ogs_error("No Bearer [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -1973,10 +2096,11 @@ void s1ap_handle_path_switch_request( if (rv != OGS_OK) { ogs_error("No transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2011,7 +2135,7 @@ void s1ap_handle_enb_configuration_transfer( mme_enb_t *enb, ogs_s1ap_message_t *message, ogs_pkbuf_t *pkbuf) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_ENBConfigurationTransfer_t *ENBConfigurationTransfer = NULL; @@ -2084,23 +2208,25 @@ void s1ap_handle_enb_configuration_transfer( if (target_enb == NULL) { ogs_error("eNB configuration transfer : " "cannot find target eNB-id[0x%x]", target_enb_id); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, NULL, + r = s1ap_send_error_indication(enb, NULL, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_targetID)); + S1AP_CauseRadioNetwork_unknown_targetID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } - ogs_assert(OGS_OK == - s1ap_send_mme_configuration_transfer( - target_enb, SONConfigurationTransfer)); + r = s1ap_send_mme_configuration_transfer( + target_enb, SONConfigurationTransfer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_HandoverRequired_t *HandoverRequired = NULL; @@ -2161,9 +2287,10 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2171,18 +2298,20 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!source_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2191,33 +2320,37 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!HandoverType) { ogs_error("No HandoverType"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!TargetID) { ogs_error("No TargetID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!Source_ToTarget_TransparentContainer) { ogs_error("No Source_ToTarget_TransparentContainer"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2229,9 +2362,10 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) break; default: ogs_error("Not implemented(%d)", TargetID->present); - ogs_assert(OGS_OK == - s1ap_send_handover_preparation_failure(source_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_handover_preparation_failure(source_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2239,21 +2373,26 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) if (target_enb == NULL) { ogs_error("Handover required : cannot find target eNB-id[0x%x]", target_enb_id); - ogs_assert(OGS_OK == - s1ap_send_handover_preparation_failure(source_ue, + r = s1ap_send_handover_preparation_failure(source_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_targetID)); + S1AP_CauseRadioNetwork_unknown_targetID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } mme_ue = source_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_error("No Security Context"); - ogs_assert(OGS_OK == - s1ap_send_handover_preparation_failure(source_ue, - S1AP_Cause_PR_nas, S1AP_CauseNas_authentication_failure)); + r = s1ap_send_handover_preparation_failure(source_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_authentication_failure); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2262,18 +2401,18 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) mme_ue->nhcc++; ogs_kdf_nh_enb(mme_ue->kasme, mme_ue->nh, mme_ue->nh); - ogs_assert(OGS_OK == - s1ap_send_handover_request( + r = s1ap_send_handover_request( source_ue, target_enb, HandoverType, Cause, - Source_ToTarget_TransparentContainer)); + Source_ToTarget_TransparentContainer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void s1ap_handle_handover_request_ack( mme_enb_t *enb, ogs_s1ap_message_t *message) { - int rv; + int i, r, rv; char buf[OGS_ADDRSTRLEN]; - int i; S1AP_SuccessfulOutcome_t *successfulOutcome = NULL; S1AP_HandoverRequestAcknowledge_t *HandoverRequestAcknowledge = NULL; @@ -2326,9 +2465,10 @@ void s1ap_handle_handover_request_ack( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2336,48 +2476,56 @@ void s1ap_handle_handover_request_ack( if (!target_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!E_RABAdmittedList) { ogs_error("No E_RABAdmittedList"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!Target_ToSource_TransparentContainer) { ogs_error("No Target_ToSource_TransparentContainer"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } source_ue = target_ue->source_ue; if (!source_ue) { ogs_error("No Source UE"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } mme_ue = source_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } ogs_debug(" Source : ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]", source_ue->enb_ue_s1ap_id, source_ue->mme_ue_s1ap_id); @@ -2395,28 +2543,31 @@ void s1ap_handle_handover_request_ack( item = (S1AP_E_RABAdmittedItemIEs_t *)E_RABAdmittedList->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABAdmittedItemIEs_t"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } e_rab = &item->value.choice.E_RABAdmittedItem; if (!e_rab) { ogs_error("No E_RABAdmittedItem"); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID); if (!bearer) { ogs_error("No Bearer [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2428,10 +2579,11 @@ void s1ap_handle_handover_request_ack( if (rv != OGS_OK) { ogs_error("No transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2446,10 +2598,11 @@ void s1ap_handle_handover_request_ack( if (rv != OGS_OK) { ogs_error("No dL_transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } } @@ -2465,10 +2618,11 @@ void s1ap_handle_handover_request_ack( if (rv != OGS_OK) { ogs_error("No uL_transportLayerAddress [%d]", (int)e_rab->e_RAB_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication2(mme_ue, + r = s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_protocol, - S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message)); + S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } } @@ -2482,15 +2636,16 @@ void s1ap_handle_handover_request_ack( mme_gtp_send_create_indirect_data_forwarding_tunnel_request(mme_ue)\ ); } else { - ogs_assert(OGS_OK == - s1ap_send_handover_command(source_ue)); + r = s1ap_send_handover_command(source_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } void s1ap_handle_handover_failure(mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_UnsuccessfulOutcome_t *unsuccessfulOutcome = NULL; S1AP_HandoverFailure_t *HandoverFailure = NULL; @@ -2531,9 +2686,10 @@ void s1ap_handle_handover_failure(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2541,27 +2697,30 @@ void s1ap_handle_handover_failure(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!target_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } source_ue = target_ue->source_ue; if (!source_ue) { ogs_error("No Source UE"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2570,21 +2729,23 @@ void s1ap_handle_handover_failure(mme_enb_t *enb, ogs_s1ap_message_t *message) ogs_debug(" Target : ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]", target_ue->enb_ue_s1ap_id, target_ue->mme_ue_s1ap_id); - ogs_assert(OGS_OK == - s1ap_send_handover_preparation_failure( - source_ue, Cause->present, Cause->choice.radioNetwork)); + r = s1ap_send_handover_preparation_failure( + source_ue, Cause->present, Cause->choice.radioNetwork); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command( + r = s1ap_send_ue_context_release_command( target_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system, - S1AP_UE_CTX_REL_S1_HANDOVER_FAILURE, 0)); + S1AP_UE_CTX_REL_S1_HANDOVER_FAILURE, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void s1ap_handle_handover_cancel(mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_HandoverCancel_t *HandoverCancel = NULL; @@ -2629,9 +2790,10 @@ void s1ap_handle_handover_cancel(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2639,35 +2801,39 @@ void s1ap_handle_handover_cancel(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!source_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } target_ue = source_ue->target_ue; if (!target_ue) { ogs_error("No Target UE"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2676,11 +2842,12 @@ void s1ap_handle_handover_cancel(mme_enb_t *enb, ogs_s1ap_message_t *message) ogs_debug(" Target : ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]", target_ue->enb_ue_s1ap_id, target_ue->mme_ue_s1ap_id); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command( + r = s1ap_send_ue_context_release_command( target_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_handover_cancelled, - S1AP_UE_CTX_REL_S1_HANDOVER_CANCEL, 0)); + S1AP_UE_CTX_REL_S1_HANDOVER_CANCEL, 0); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_debug("Handover Cancel : UE[eNB-UE-S1AP-ID(%d)] --> eNB[%s:%d]", source_ue->enb_ue_s1ap_id, @@ -2691,7 +2858,7 @@ void s1ap_handle_enb_status_transfer( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_ENBStatusTransfer_t *ENBStatusTransfer = NULL; @@ -2736,9 +2903,10 @@ void s1ap_handle_enb_status_transfer( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2746,35 +2914,39 @@ void s1ap_handle_enb_status_transfer( if (!source_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_StatusTransfer_TransparentContainer) { ogs_error("No ENB_StatusTransfer_TransparentContainer"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } target_ue = source_ue->target_ue; if (!target_ue) { ogs_error("No Target UE"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2783,16 +2955,17 @@ void s1ap_handle_enb_status_transfer( ogs_debug(" Target : ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]", target_ue->enb_ue_s1ap_id, target_ue->mme_ue_s1ap_id); - ogs_assert(OGS_OK == - s1ap_send_mme_status_transfer(target_ue, - ENB_StatusTransfer_TransparentContainer)); + r = s1ap_send_mme_status_transfer(target_ue, + ENB_StatusTransfer_TransparentContainer); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void s1ap_handle_handover_notification( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_HandoverNotify_t *HandoverNotify = NULL; @@ -2847,9 +3020,10 @@ void s1ap_handle_handover_notification( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2857,26 +3031,29 @@ void s1ap_handle_handover_notification( if (!target_ue) { ogs_error("No eNB UE Context : MME_UE_S1AP_ID[%lld]", (long long)*MME_UE_S1AP_ID); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id)); + S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2887,9 +3064,10 @@ void s1ap_handle_handover_notification( if (!TAI) { ogs_error("No TAI"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -2901,14 +3079,18 @@ void s1ap_handle_handover_notification( source_ue = target_ue->source_ue; if (!source_ue) { ogs_error("No Source UE"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } mme_ue = source_ue->mme_ue; - ogs_expect_or_return(mme_ue); + if (!mme_ue) { + ogs_error("No UE(mme-ue) context"); + return; + } ogs_debug(" Source : ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]", source_ue->enb_ue_s1ap_id, source_ue->mme_ue_s1ap_id); @@ -2949,12 +3131,13 @@ void s1ap_handle_handover_notification( memcpy(&mme_ue->e_cgi, &target_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); mme_ue->ue_location_timestamp = ogs_time_now(); - ogs_assert(OGS_OK == - s1ap_send_ue_context_release_command(source_ue, + r = s1ap_send_ue_context_release_command(source_ue, S1AP_Cause_PR_radioNetwork, S1AP_CauseRadioNetwork_successful_handover, S1AP_UE_CTX_REL_S1_HANDOVER_COMPLETE, - ogs_app()->time.handover.duration)); + ogs_app()->time.handover.duration); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); ogs_list_init(&mme_ue->bearer_to_modify_list); @@ -2979,7 +3162,7 @@ void s1ap_handle_s1_reset( mme_enb_t *enb, ogs_s1ap_message_t *message) { char buf[OGS_ADDRSTRLEN]; - int i; + int i, r; S1AP_InitiatingMessage_t *initiatingMessage = NULL; S1AP_Reset_t *Reset = NULL; @@ -3021,9 +3204,10 @@ void s1ap_handle_s1_reset( if (!Cause) { ogs_error("No Cause"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3032,9 +3216,10 @@ void s1ap_handle_s1_reset( if (!ResetType) { ogs_error("No ResetType"); - ogs_assert(OGS_OK == - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); + r = s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; } @@ -3058,9 +3243,11 @@ void s1ap_handle_s1_reset( * for new UE-associated logical S1-connections over the S1 interface, * the MME shall respond with the RESET ACKNOWLEDGE message. */ - if (ogs_list_count(&enb->enb_ue_list) == 0) - ogs_assert(OGS_OK == - s1ap_send_s1_reset_ack(enb, NULL)); + if (ogs_list_count(&enb->enb_ue_list) == 0) { + r = s1ap_send_s1_reset_ack(enb, NULL); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); + } break; @@ -3074,7 +3261,10 @@ void s1ap_handle_s1_reset( ogs_pkbuf_free(enb->s1_reset_ack); enb->s1_reset_ack = ogs_s1ap_build_s1_reset_ack(partOfS1_Interface); - ogs_expect_or_return(enb->s1_reset_ack); + if (!enb->s1_reset_ack) { + ogs_error("ogs_s1ap_build_s1_reset_ack() failed"); + return; + } for (i = 0; i < partOfS1_Interface->list.count; i++) { S1AP_UE_associatedLogicalS1_ConnectionItemRes_t *ie2 = NULL; @@ -3153,7 +3343,9 @@ void s1ap_handle_s1_reset( * where PartOfS1_interface was requested * REMOVED */ ogs_assert(enb->s1_reset_ack); - s1ap_send_to_enb(enb, enb->s1_reset_ack, S1AP_NON_UE_SIGNALLING); + r = s1ap_send_to_enb(enb, enb->s1_reset_ack, S1AP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); /* Clear S1-Reset Ack Buffer */ enb->s1_reset_ack = NULL; diff --git a/src/mme/s1ap-path.c b/src/mme/s1ap-path.c index 4e3a18d39..5ed5b54da 100644 --- a/src/mme/s1ap-path.c +++ b/src/mme/s1ap-path.c @@ -55,16 +55,16 @@ int s1ap_send_to_enb(mme_enb_t *enb, ogs_pkbuf_t *pkbuf, uint16_t stream_no) enb = mme_enb_cycle(enb); if (!enb) { - ogs_warn("eNB has already been removed"); + ogs_error("eNB has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } ogs_assert(enb->sctp.sock); if (enb->sctp.sock->fd == INVALID_SOCKET) { ogs_fatal("eNB SCTP socket has already been destroyed"); ogs_log_hexdump(OGS_LOG_FATAL, pkbuf->data, pkbuf->len); - ogs_assert_if_reached(); + ogs_pkbuf_free(pkbuf); return OGS_ERROR; } @@ -84,16 +84,20 @@ int s1ap_send_to_enb(mme_enb_t *enb, ogs_pkbuf_t *pkbuf, uint16_t stream_no) int s1ap_send_to_enb_ue(enb_ue_t *enb_ue, ogs_pkbuf_t *pkbuf) { + int rv; ogs_assert(pkbuf); enb_ue = enb_ue_cycle(enb_ue); if (!enb_ue) { - ogs_warn("S1 context has already been removed"); + ogs_error("S1 context has already been removed"); ogs_pkbuf_free(pkbuf); - return OGS_ERROR; + return OGS_NOTFOUND; } - return s1ap_send_to_enb(enb_ue->enb, pkbuf, enb_ue->enb_ostream_id); + rv = s1ap_send_to_enb(enb_ue->enb, pkbuf, enb_ue->enb_ostream_id); + ogs_expect(rv == OGS_OK); + + return rv; } int s1ap_delayed_send_to_enb_ue( @@ -118,10 +122,10 @@ int s1ap_delayed_send_to_enb_ue( return OGS_OK; } else { - mme_enb_t *enb = NULL; - enb = enb_ue->enb; - ogs_assert(enb); - return s1ap_send_to_enb_ue(enb_ue, pkbuf); + int rv = s1ap_send_to_enb_ue(enb_ue, pkbuf); + ogs_expect(rv == OGS_OK); + + return rv; } } @@ -154,6 +158,7 @@ int s1ap_send_to_esm( int s1ap_send_to_nas(enb_ue_t *enb_ue, S1AP_ProcedureCode_t procedureCode, S1AP_NAS_PDU_t *nasPdu) { + int rv; ogs_nas_eps_security_header_t *sh = NULL; ogs_nas_security_header_type_t security_header_type; @@ -244,9 +249,11 @@ int s1ap_send_to_nas(enb_ue_t *enb_ue, ogs_pkbuf_free(nasbuf); return OGS_ERROR; } - return s1ap_send_to_esm( + rv = s1ap_send_to_esm( mme_ue, nasbuf, security_header_type.type, OGS_GTP_CREATE_IN_UPLINK_NAS_TRANSPORT); + ogs_expect(rv == OGS_OK); + return rv; } else { ogs_error("Unknown/Unimplemented NAS Protocol discriminator 0x%02x", h->protocol_discriminator); @@ -262,7 +269,10 @@ int s1ap_send_s1_setup_response(mme_enb_t *enb) ogs_debug("S1-Setup response"); s1ap_buffer = s1ap_build_setup_rsp(); - ogs_expect_or_return_val(s1ap_buffer, OGS_ERROR); + if (!s1ap_buffer) { + ogs_error("s1ap_build_setup_rsp() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb(enb, s1ap_buffer, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -278,7 +288,10 @@ int s1ap_send_s1_setup_failure( ogs_debug("S1-Setup failure"); s1ap_buffer = s1ap_build_setup_failure(group, cause, S1AP_TimeToWait_v10s); - ogs_expect_or_return_val(s1ap_buffer, OGS_ERROR); + if (!s1ap_buffer) { + ogs_error("s1ap_build_setup_failure() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb(enb, s1ap_buffer, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -295,7 +308,10 @@ int s1ap_send_initial_context_setup_request(mme_ue_t *mme_ue) ogs_debug("InitialContextSetupRequest"); s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, NULL); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_initial_context_setup_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -312,7 +328,10 @@ int s1ap_send_ue_context_modification_request(mme_ue_t *mme_ue) ogs_debug("UEContextModificationRequest"); s1apbuf = s1ap_build_ue_context_modification_request(mme_ue); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_ue_context_modification_request() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -340,7 +359,10 @@ int s1ap_send_ue_context_release_command( group, (int)cause, action, (int)duration); s1apbuf = s1ap_build_ue_context_release_command(enb_ue, group, cause); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_ue_context_release_command() failed"); + return OGS_ERROR; + } rv = s1ap_delayed_send_to_enb_ue(enb_ue, s1apbuf, duration); ogs_expect(rv == OGS_OK); @@ -369,14 +391,23 @@ int s1ap_send_paging(mme_ue_t *mme_ue, S1AP_CNDomain_t cn_domain) s1apbuf = mme_ue->t3413.pkbuf; } else { s1apbuf = s1ap_build_paging(mme_ue, cn_domain); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_paging() failed"); + return OGS_ERROR; + } } mme_ue->t3413.pkbuf = ogs_pkbuf_copy(s1apbuf); - ogs_expect_or_return_val(mme_ue->t3413.pkbuf, OGS_ERROR); + if (!mme_ue->t3413.pkbuf) { + ogs_error("ogs_pkbuf_copy() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); - ogs_expect_or_return_val(rv == OGS_OK, rv); + if (rv != OGS_OK) { + ogs_error("s1ap_send_to_enb() failed"); + return rv; + } } } } @@ -400,7 +431,10 @@ int s1ap_send_mme_configuration_transfer( ogs_debug("MMEConfigurationTransfer"); s1apbuf = s1ap_build_mme_configuration_transfer(SONConfigurationTransfer); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_mme_configuration_transfer() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb(target_enb, s1apbuf, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -417,7 +451,10 @@ int s1ap_send_e_rab_modification_confirm(mme_ue_t *mme_ue) ogs_debug("E-RABModificationConfirm"); s1apbuf = s1ap_build_e_rab_modification_confirm(mme_ue); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_e_rab_modification_confirm() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -436,7 +473,10 @@ int s1ap_send_path_switch_ack( ogs_debug("PathSwitchAcknowledge"); s1apbuf = s1ap_build_path_switch_ack( mme_ue, e_rab_to_switched_in_uplink_list); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_path_switch_ack() failed"); + return OGS_ERROR; + } rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -453,7 +493,10 @@ int s1ap_send_handover_command(enb_ue_t *source_ue) ogs_debug("HandoverCommand"); s1apbuf = s1ap_build_handover_command(source_ue); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_handover_command() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb_ue(source_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -472,7 +515,10 @@ int s1ap_send_handover_preparation_failure( ogs_debug("HandoverPreparationFailure"); s1apbuf = s1ap_build_handover_preparation_failure(source_ue, group, cause); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_handover_preparation_failure() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb_ue(source_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -489,7 +535,10 @@ int s1ap_send_handover_cancel_ack(enb_ue_t *source_ue) ogs_debug("HandoverCancelAcknowledge"); s1apbuf = s1ap_build_handover_cancel_ack(source_ue); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_handover_cancel_ack() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb_ue(source_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -516,11 +565,12 @@ int s1ap_send_handover_request( target_ue = enb_ue_add(target_enb, INVALID_UE_S1AP_ID); if (target_ue == NULL) { - ogs_assert(OGS_OK == - s1ap_send_error_indication(target_enb, NULL, NULL, + rv = s1ap_send_error_indication(target_enb, NULL, NULL, S1AP_Cause_PR_misc, - S1AP_CauseMisc_control_processing_overload)); - return OGS_ERROR; + S1AP_CauseMisc_control_processing_overload); + ogs_expect(rv == OGS_OK); + + return rv; } ogs_info(" Source : ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]", @@ -533,7 +583,10 @@ int s1ap_send_handover_request( s1apbuf = s1ap_build_handover_request( target_ue, handovertype, cause, source_totarget_transparentContainer); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_handover_request() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb_ue(target_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -554,7 +607,10 @@ int s1ap_send_mme_status_transfer( ogs_info("MMEStatusTransfer"); s1apbuf = s1ap_build_mme_status_transfer(target_ue, enb_statustransfer_transparentContainer); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("s1ap_build_mme_status_transfer() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb_ue(target_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -576,7 +632,10 @@ int s1ap_send_error_indication( ogs_info("ErrorIndication"); s1apbuf = ogs_s1ap_build_error_indication( mme_ue_s1ap_id, enb_ue_s1ap_id, group, cause); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("ogs_s1ap_build_error_indication() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); @@ -596,9 +655,15 @@ int s1ap_send_error_indication2( ogs_assert(mme_ue); enb_ue = enb_ue_cycle(mme_ue->enb_ue); - ogs_expect_or_return_val(enb_ue, OGS_ERROR); - enb = enb_ue->enb; - ogs_expect_or_return_val(enb, OGS_ERROR); + if (!enb_ue) { + ogs_error("S1 context has already been removed"); + return OGS_NOTFOUND; + } + enb = mme_enb_cycle(enb_ue->enb); + if (!enb) { + ogs_error("eNB has already been removed"); + return OGS_NOTFOUND; + } mme_ue_s1ap_id = enb_ue->mme_ue_s1ap_id, enb_ue_s1ap_id = enb_ue->enb_ue_s1ap_id, @@ -621,7 +686,10 @@ int s1ap_send_s1_reset_ack( ogs_info("S1-Reset Acknowledge"); s1apbuf = ogs_s1ap_build_s1_reset_ack(partOfS1_Interface); - ogs_expect_or_return_val(s1apbuf, OGS_ERROR); + if (!s1apbuf) { + ogs_error("ogs_s1ap_build_s1_reset_ack() failed"); + return OGS_ERROR; + } rv = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); diff --git a/src/mme/sbc-handler.c b/src/mme/sbc-handler.c index b408565c4..466aa7efb 100644 --- a/src/mme/sbc-handler.c +++ b/src/mme/sbc-handler.c @@ -26,7 +26,7 @@ void sbc_handle_write_replace_warning_request(sbc_pws_data_t *sbc_pws) { ogs_pkbuf_t *s1apbuf = NULL; mme_enb_t *enb = NULL; - int i, j, flag; + int i, j, flag, r; /* Find enB with matched TAI */ ogs_list_for_each(&mme_self()->enb_list, enb) { @@ -48,11 +48,15 @@ void sbc_handle_write_replace_warning_request(sbc_pws_data_t *sbc_pws) if (flag) { /* Build S1AP Write Replace Warning Request message */ s1apbuf = s1ap_build_write_replace_warning_request(sbc_pws); - ogs_expect_or_return(s1apbuf); + if (!s1apbuf) { + ogs_error("s1ap_build_kill_request() failed"); + return; + } /* Send to enb */ - ogs_expect(s1ap_send_to_enb( - enb, s1apbuf, S1AP_NON_UE_SIGNALLING) == OGS_OK); + r = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } } @@ -61,7 +65,7 @@ void sbc_handle_stop_warning_request(sbc_pws_data_t *sbc_pws) { ogs_pkbuf_t *s1apbuf = NULL; mme_enb_t *enb = NULL; - int i, j, flag; + int i, j, flag, r; /* Find enB with matched TAI */ ogs_list_for_each(&mme_self()->enb_list, enb) { @@ -83,11 +87,15 @@ void sbc_handle_stop_warning_request(sbc_pws_data_t *sbc_pws) if (flag) { /* Build S1AP Kill request message */ s1apbuf = s1ap_build_kill_request(sbc_pws); - ogs_expect_or_return(s1apbuf); + if (!s1apbuf) { + ogs_error("s1ap_build_kill_request() failed"); + return; + } /* Send to enb */ - ogs_expect(s1ap_send_to_enb( - enb, s1apbuf, S1AP_NON_UE_SIGNALLING) == OGS_OK); + r = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } } } diff --git a/src/mme/sgsap-handler.c b/src/mme/sgsap-handler.c index 7a2010ae4..07c5f0378 100644 --- a/src/mme/sgsap-handler.c +++ b/src/mme/sgsap-handler.c @@ -30,6 +30,7 @@ void sgsap_handle_location_update_accept(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) { + int r; ogs_tlv_t *root = NULL, *iter = NULL; mme_ue_t *mme_ue = NULL; @@ -116,21 +117,24 @@ void sgsap_handle_location_update_accept(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) ogs_debug(" P-TMSI[0x%08x]", mme_ue->p_tmsi); } - ogs_assert(OGS_OK == - nas_eps_send_attach_accept(mme_ue)); + r = nas_eps_send_attach_accept(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); return; error: - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, + r = nas_eps_send_attach_reject(mme_ue, OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); mme_send_delete_session_or_mme_ue_context_release(mme_ue); } void sgsap_handle_location_update_reject(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) { + int r; ogs_tlv_t *root = NULL, *iter = NULL; mme_ue_t *mme_ue = NULL; @@ -203,9 +207,10 @@ void sgsap_handle_location_update_reject(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) ogs_plmn_id_hexdump(&lai->nas_plmn_id), lai->lac); } - ogs_assert(OGS_OK == - nas_eps_send_attach_reject(mme_ue, - emm_cause, OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); + r = nas_eps_send_attach_reject(mme_ue, + emm_cause, OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -277,6 +282,7 @@ void sgsap_handle_detach_ack(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) void sgsap_handle_paging_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) { + int r; ogs_tlv_t *root = NULL, *iter = NULL; mme_ue_t *mme_ue = NULL; @@ -354,22 +360,25 @@ void sgsap_handle_paging_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) /* UE will respond Extended Service Request in PS CNDomain*/ MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_CS_CALL_SERVICE, NULL); - ogs_assert(OGS_OK == - s1ap_send_paging(mme_ue, S1AP_CNDomain_cs)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_cs); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (SMS_SERVICE_INDICATOR(mme_ue)) { /* UE will respond Service Request in PS CNDomain*/ MME_STORE_PAGING_INFO(mme_ue, MME_PAGING_TYPE_SMS_SERVICE, NULL); - ogs_assert(OGS_OK == - s1ap_send_paging(mme_ue, S1AP_CNDomain_ps)); + r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else goto paging_reject; } else { if (CS_CALL_SERVICE_INDICATOR(mme_ue)) { - ogs_assert(OGS_OK == - nas_eps_send_cs_service_notification(mme_ue)); + r = nas_eps_send_cs_service_notification(mme_ue); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } else if (SMS_SERVICE_INDICATOR(mme_ue)) { ogs_assert(OGS_OK == sgsap_send_service_request( @@ -395,6 +404,7 @@ paging_reject: void sgsap_handle_downlink_unitdata(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) { + int r; ogs_tlv_t *root = NULL, *iter = NULL; mme_ue_t *mme_ue = NULL; @@ -455,9 +465,10 @@ void sgsap_handle_downlink_unitdata(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) nas_message_container_buffer, nas_message_container_length); - ogs_assert(OGS_OK == - nas_eps_send_downlink_nas_transport(mme_ue, - nas_message_container_buffer, nas_message_container_length)); + r = nas_eps_send_downlink_nas_transport(mme_ue, + nas_message_container_buffer, nas_message_container_length); + ogs_expect(r == OGS_OK); + ogs_assert(r != OGS_ERROR); } void sgsap_handle_reset_indication(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) diff --git a/src/mme/sgsap-path.c b/src/mme/sgsap-path.c index ed08aca16..25d56f740 100644 --- a/src/mme/sgsap-path.c +++ b/src/mme/sgsap-path.c @@ -120,7 +120,10 @@ int sgsap_send_location_update_request(mme_ue_t *mme_ue) ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd); pkbuf = sgsap_build_location_update_request(mme_ue); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_location_update_request() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -137,7 +140,10 @@ int sgsap_send_tmsi_reallocation_complete(mme_ue_t *mme_ue) ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd); pkbuf = sgsap_build_tmsi_reallocation_complete(mme_ue); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_tmsi_reallocation_complete() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -151,7 +157,10 @@ int sgsap_send_detach_indication(mme_ue_t *mme_ue) ogs_assert(mme_ue); pkbuf = sgsap_build_detach_indication(mme_ue); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_detach_indication() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -168,7 +177,10 @@ int sgsap_send_mo_csfb_indication(mme_ue_t *mme_ue) ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd); pkbuf = sgsap_build_mo_csfb_indication(mme_ue); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_mo_csfb_indication() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -187,7 +199,10 @@ int sgsap_send_paging_reject(mme_ue_t *mme_ue, uint8_t sgs_cause) pkbuf = sgsap_build_paging_reject( &mme_ue->nas_mobile_identity_imsi, SGSAP_IE_IMSI_LEN, sgs_cause); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_paging_reject() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -206,7 +221,10 @@ int sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode) ogs_debug(" EMM_MODE[%d]", emm_mode); pkbuf = sgsap_build_service_request(mme_ue, emm_mode); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_service_request() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -222,7 +240,10 @@ int sgsap_send_reset_ack(mme_vlr_t *vlr) ogs_debug("[SGSAP] RESET-ACK"); pkbuf = sgsap_build_reset_ack(vlr); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_reset_ack() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr_with_sid(vlr, pkbuf, 0); ogs_expect(rv == OGS_OK); @@ -243,7 +264,10 @@ int sgsap_send_uplink_unitdata(mme_ue_t *mme_ue, nas_message_container->buffer, nas_message_container->length); pkbuf = sgsap_build_uplink_unidata(mme_ue, nas_message_container); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_uplink_unidata() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); @@ -261,7 +285,10 @@ int sgsap_send_ue_unreachable(mme_ue_t *mme_ue, uint8_t sgs_cause) ogs_debug(" CAUSE[%d]", sgs_cause); pkbuf = sgsap_build_ue_unreachable(mme_ue, sgs_cause); - ogs_expect_or_return_val(pkbuf, OGS_ERROR); + if (!pkbuf) { + ogs_error("sgsap_build_ue_unreachable() failed"); + return OGS_ERROR; + } rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); diff --git a/src/nrf/sbi-path.c b/src/nrf/sbi-path.c index 1fe3e26ea..0e9dbcf28 100644 --- a/src/nrf/sbi-path.c +++ b/src/nrf/sbi-path.c @@ -84,11 +84,17 @@ bool nrf_nnrf_nfm_send_nf_status_notify( ogs_assert(subscription_data); client = subscription_data->client; - ogs_expect_or_return_val(client, false); + if (!client) { + ogs_error("No Client"); + return false; + } request = nrf_nnrf_nfm_build_nf_status_notify( subscription_data, event, nf_instance); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("nrf_nnrf_nfm_build_nf_status_notify() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL); @@ -103,6 +109,7 @@ bool nrf_nnrf_nfm_send_nf_status_notify_all( OpenAPI_notification_event_type_e event, ogs_sbi_nf_instance_t *nf_instance) { + bool rc; ogs_sbi_subscription_data_t *subscription_data = NULL; ogs_assert(nf_instance); @@ -135,10 +142,12 @@ bool nrf_nnrf_nfm_send_nf_status_notify_all( continue; } - ogs_expect_or_return_val(true == - nrf_nnrf_nfm_send_nf_status_notify( - subscription_data, event, nf_instance), - false); + rc = nrf_nnrf_nfm_send_nf_status_notify( + subscription_data, event, nf_instance); + if (rc == false) { + ogs_error("nrf_nnrf_nfm_send_nf_status_notify() failed"); + return rc; + } } return true; diff --git a/src/pcf/sbi-path.c b/src/pcf/sbi-path.c index c1e3cddb8..d167e4542 100644 --- a/src/pcf/sbi-path.c +++ b/src/pcf/sbi-path.c @@ -139,7 +139,10 @@ static bool pcf_sbi_discover_and_send( xact = ogs_sbi_xact_add( sbi_object, service_type, discovery_option, build, context, data); - ogs_expect_or_return_val(xact, false); + if (!xact) { + ogs_error("ogs_sbi_xact_add() failed"); + return false; + } xact->assoc_stream = stream; @@ -182,7 +185,10 @@ bool pcf_sess_sbi_discover_only( ogs_assert(service_type); xact = ogs_sbi_xact_add(&sess->sbi, service_type, NULL, NULL, NULL, NULL); - ogs_expect_or_return_val(xact, false); + if (!xact) { + ogs_error("ogs_sbi_xact_add() failed"); + return false; + } xact->assoc_stream = stream; @@ -265,7 +271,10 @@ bool pcf_sbi_send_am_policy_control_notify(pcf_ue_t *pcf_ue) ogs_assert(client); request = pcf_namf_callback_build_am_policy_control(pcf_ue, NULL); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("pcf_namf_callback_build_am_policy_control() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL); @@ -289,7 +298,10 @@ bool pcf_sbi_send_smpolicycontrol_update_notify( request = pcf_nsmf_callback_build_smpolicycontrol_update( sess, SmPolicyDecision); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("pcf_nsmf_callback_build_smpolicycontrol_update() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL); @@ -314,7 +326,10 @@ bool pcf_sbi_send_smpolicycontrol_delete_notify( request = pcf_nsmf_callback_build_smpolicycontrol_update( sess, SmPolicyDecision); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("pcf_nsmf_callback_build_smpolicycontrol_update() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_delete_notify_cb, request, app_session); @@ -336,7 +351,10 @@ bool pcf_sbi_send_smpolicycontrol_terminate_notify(pcf_sess_t *sess) ogs_assert(client); request = pcf_nsmf_callback_build_smpolicycontrol_terminate(sess, NULL); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("pcf_nsmf_callback_build_smpolicycontrol_terminate() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL); @@ -358,7 +376,11 @@ bool pcf_sbi_send_policyauthorization_terminate_notify(pcf_app_t *app) ogs_assert(client); request = pcf_naf_callback_build_policyauthorization_terminate(app, NULL); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("pcf_naf_callback_build_policyauthorization_terminate() " + "failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL); diff --git a/src/smf/sbi-path.c b/src/smf/sbi-path.c index ea7aa2b42..0b048f318 100644 --- a/src/smf/sbi-path.c +++ b/src/smf/sbi-path.c @@ -392,7 +392,10 @@ bool smf_sbi_send_sm_context_status_notify(smf_sess_t *sess) ogs_assert(client); request = smf_namf_callback_build_sm_context_status(sess, NULL); - ogs_expect_or_return_val(request, false); + if (!request) { + ogs_error("smf_namf_callback_build_sm_context_status() failed"); + return false; + } rc = ogs_sbi_send_request_to_client( client, client_notify_cb, request, NULL);