From 873cf398c733cf5e780619eab1117604de30931f Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sun, 16 May 2021 12:22:10 +0900 Subject: [PATCH] [ALL] Add protection of message encoding (#991) All process will be forcely exited if it failed to encode the S1AP/NGAP/GTP/PFCP message. It is to make sure there was no problem with the encoding of open5gs. --- lib/core/ogs-log.h | 9 + lib/core/ogs-tlv-msg.c | 34 +- src/amf/amf-sm.c | 26 +- src/amf/gmm-handler.c | 100 +++-- src/amf/gmm-sm.c | 120 ++++-- src/amf/namf-handler.c | 3 +- src/amf/nas-path.c | 189 ++++++--- src/amf/nas-path.h | 48 +-- src/amf/nausf-handler.c | 3 +- src/amf/ngap-handler.c | 873 +++++++++++++++++++++++--------------- src/amf/ngap-path.c | 153 ++++--- src/amf/ngap-path.h | 38 +- src/amf/nnrf-handler.c | 15 +- src/amf/nnssf-handler.c | 23 +- src/amf/npcf-handler.c | 28 +- src/amf/nsmf-handler.c | 151 ++++--- src/amf/sbi-path.c | 40 +- src/mme/emm-handler.c | 22 +- src/mme/emm-sm.c | 239 +++++++---- src/mme/esm-handler.c | 38 +- src/mme/esm-sm.c | 71 ++-- src/mme/mme-context.c | 38 +- src/mme/mme-gtp-path.c | 98 +++-- src/mme/mme-gtp-path.h | 24 +- src/mme/mme-path.c | 55 ++- src/mme/mme-s11-handler.c | 88 ++-- src/mme/mme-s6a-handler.c | 3 +- src/mme/mme-sm.c | 30 +- src/mme/nas-path.c | 176 +++++--- src/mme/nas-path.h | 42 +- src/mme/s1ap-handler.c | 604 +++++++++++++++----------- src/mme/s1ap-path.c | 114 +++-- src/mme/s1ap-path.h | 32 +- src/mme/sgsap-handler.c | 27 +- src/mme/sgsap-path.c | 50 ++- src/mme/sgsap-path.h | 16 +- src/sgwc/gtp-path.c | 8 +- src/sgwc/gtp-path.h | 2 +- src/sgwc/pfcp-path.c | 42 +- src/sgwc/pfcp-path.h | 10 +- src/sgwc/s11-handler.c | 41 +- src/sgwc/s5c-handler.c | 24 +- src/sgwc/sxa-handler.c | 32 +- src/sgwu/gtp-path.c | 8 +- src/sgwu/pfcp-path.c | 34 +- src/sgwu/pfcp-path.h | 8 +- src/sgwu/sxa-handler.c | 10 +- src/smf/binding.c | 21 +- src/smf/gsm-sm.c | 5 +- src/smf/gtp-path.c | 18 +- src/smf/gtp-path.h | 4 +- src/smf/gx-handler.c | 6 +- src/smf/n4-build.c | 38 -- src/smf/n4-handler.c | 36 +- src/smf/ngap-handler.c | 25 +- src/smf/ngap-path.c | 2 +- src/smf/npcf-handler.c | 3 +- src/smf/nsmf-handler.c | 25 +- src/smf/pfcp-path.c | 66 +-- src/smf/pfcp-path.h | 16 +- src/smf/s5c-handler.c | 18 +- src/upf/gtp-path.c | 11 +- src/upf/n4-handler.c | 10 +- src/upf/pfcp-path.c | 34 +- src/upf/pfcp-path.h | 8 +- 65 files changed, 2506 insertions(+), 1679 deletions(-) diff --git a/lib/core/ogs-log.h b/lib/core/ogs-log.h index 40133341b..c38455bc2 100644 --- a/lib/core/ogs-log.h +++ b/lib/core/ogs-log.h @@ -134,6 +134,15 @@ void ogs_log_hexdump_func(ogs_log_level_e level, int domain_id, } \ } while (0) +#define ogs_expect_or_return_val(expr, val) \ + do { \ + if (ogs_likely(expr)) ; \ + else { \ + ogs_error("%s: Expectation `%s' failed.", OGS_FUNC, #expr); \ + return (val); \ + } \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/lib/core/ogs-tlv-msg.c b/lib/core/ogs-tlv-msg.c index fe1883d68..2993a6d07 100644 --- a/lib/core/ogs-tlv-msg.c +++ b/lib/core/ogs-tlv-msg.c @@ -49,7 +49,7 @@ static ogs_tlv_t *tlv_add_leaf( desc->type, 1, desc->instance, &v->u8); else tlv = ogs_tlv_add(tlv, desc->type, 1, desc->instance, &v->u8); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } case OGS_TLV_UINT16: @@ -63,7 +63,7 @@ static ogs_tlv_t *tlv_add_leaf( desc->type, 2, desc->instance, &v->u16); else tlv = ogs_tlv_add(tlv, desc->type, 2, desc->instance, &v->u16); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } case OGS_TLV_UINT24: @@ -79,7 +79,7 @@ static ogs_tlv_t *tlv_add_leaf( desc->type, 3, desc->instance, &v->u24); else tlv = ogs_tlv_add(tlv, desc->type, 3, desc->instance, &v->u24); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } case OGS_TLV_UINT32: @@ -95,7 +95,7 @@ static ogs_tlv_t *tlv_add_leaf( else tlv = ogs_tlv_add(tlv, desc->type, 4, desc->instance, &v->u32); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } case OGS_TLV_FIXED_STR: @@ -108,7 +108,7 @@ static ogs_tlv_t *tlv_add_leaf( else tlv = ogs_tlv_add(tlv, desc->type, desc->length, desc->instance, v->data); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } case OGS_TLV_VAR_STR: @@ -116,9 +116,9 @@ static ogs_tlv_t *tlv_add_leaf( ogs_tlv_octet_t *v = (ogs_tlv_octet_t *)msg; if (v->len == 0) { - ogs_fatal("No TLV length - [%s] T:%d I:%d (vsz=%d)", + ogs_error("No TLV length - [%s] T:%d I:%d (vsz=%d)", desc->name, desc->type, desc->instance, desc->vsize); - ogs_assert_if_reached(); + ogs_expect_or_return_val(0, NULL); } if (parent_tlv) @@ -127,7 +127,7 @@ static ogs_tlv_t *tlv_add_leaf( else tlv = ogs_tlv_add(tlv, desc->type, v->len, desc->instance, v->data); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } case OGS_TLV_NULL: @@ -138,11 +138,11 @@ static ogs_tlv_t *tlv_add_leaf( else tlv = ogs_tlv_add(tlv, desc->type, 0, desc->instance, NULL); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, NULL); break; } default: - ogs_assert_if_reached(); + ogs_expect_or_return_val(0, NULL); break; } @@ -195,7 +195,7 @@ static uint32_t tlv_add_compound(ogs_tlv_t **root, ogs_tlv_t *parent_tlv, r = tlv_add_compound(&emb_tlv, tlv, desc, p + offset2 + sizeof(ogs_tlv_presence_t), depth + 1); - ogs_assert(r > 0 && emb_tlv); + ogs_expect_or_return_val(r > 0 && emb_tlv, 0); count += 1 + r; } else { ogs_trace("BUILD %sL#%d [%s] T:%d L:%d I:%d " @@ -205,7 +205,7 @@ static uint32_t tlv_add_compound(ogs_tlv_t **root, ogs_tlv_t *parent_tlv, p + offset2); tlv = tlv_add_leaf(parent_tlv, tlv, desc, p + offset2); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, 0); count++; } @@ -235,7 +235,7 @@ static uint32_t tlv_add_compound(ogs_tlv_t **root, ogs_tlv_t *parent_tlv, r = tlv_add_compound(&emb_tlv, tlv, desc, p + offset + sizeof(ogs_tlv_presence_t), depth + 1); - ogs_assert(r > 0 && emb_tlv); + ogs_expect_or_return_val(r > 0 && emb_tlv, 0); count += 1 + r; } else { ogs_trace("BUILD %sL#%d [%s] T:%d L:%d I:%d " @@ -245,7 +245,7 @@ static uint32_t tlv_add_compound(ogs_tlv_t **root, ogs_tlv_t *parent_tlv, p + offset); tlv = tlv_add_leaf(parent_tlv, tlv, desc, p + offset); - ogs_assert(tlv); + ogs_expect_or_return_val(tlv, 0); count++; } @@ -272,20 +272,20 @@ ogs_pkbuf_t *ogs_tlv_build_msg(ogs_tlv_desc_t *desc, void *msg, int mode) if (desc->child_descs[0]) { r = tlv_add_compound(&root, NULL, desc, msg, 0); - ogs_assert(r > 0 && root); + ogs_expect_or_return_val(r > 0 && root, NULL); length = ogs_tlv_calc_length(root, mode); } else { length = 0; } pkbuf = ogs_pkbuf_alloc(NULL, OGS_TLV_MAX_HEADROOM+length); - ogs_assert(pkbuf); + ogs_expect_or_return_val(pkbuf, NULL); ogs_pkbuf_reserve(pkbuf, OGS_TLV_MAX_HEADROOM); ogs_pkbuf_put(pkbuf, length); if (desc->child_descs[0]) { rendlen = ogs_tlv_render(root, pkbuf->data, length, mode); - ogs_assert(rendlen == length); + ogs_expect_or_return_val(rendlen == length, NULL); ogs_tlv_free_all(root); } diff --git a/src/amf/amf-sm.c b/src/amf/amf-sm.c index 1ca7249ad..d9a29d603 100644 --- a/src/amf/amf-sm.c +++ b/src/amf/amf-sm.c @@ -546,8 +546,9 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) amf_ue = (amf_ue_t *)sbi_object; ogs_assert(amf_ue); ogs_error("[%s] Cannot receive SBI message", amf_ue->suci); - nas_5gs_send_gmm_reject_from_sbi(amf_ue, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi(amf_ue, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); break; case OGS_SBI_OBJ_SESS_TYPE: @@ -556,12 +557,15 @@ 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) { - nas_5gs_send_back_5gsm_message_from_sbi(sess, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi(sess, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); } else { - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_transport, - NGAP_CauseTransport_transport_resource_unavailable); + NGAP_CauseTransport_transport_resource_unavailable) + ); } break; @@ -665,9 +669,10 @@ 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"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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_ngap_free(&ngap_message); @@ -772,9 +777,10 @@ 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); - ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, + ogs_assert(OGS_OK == + 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)); } amf_ue_associate_ran_ue(amf_ue, ran_ue); } diff --git a/src/amf/gmm-handler.c b/src/amf/gmm-handler.c index f2f06d61e..9214e1f8c 100644 --- a/src/amf/gmm-handler.c +++ b/src/amf/gmm-handler.c @@ -110,8 +110,9 @@ int gmm_handle_registration_request(amf_ue_t *amf_ue, ~OGS_REGISTRATION_CLEARTEXT_PRESENT) { ogs_error("Non cleartext IEs is included [0x%llx]", (long long)registration_request->presencemask); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } @@ -119,15 +120,17 @@ int gmm_handle_registration_request(amf_ue_t *amf_ue, (registration_request->presencemask & OGS_NAS_5GS_REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT)) { ogs_error("NAS container present without Integrity-protected"); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } if (!mobile_identity->length || !mobile_identity->buffer) { ogs_error("No Mobile Identity"); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } @@ -142,8 +145,10 @@ int gmm_handle_registration_request(amf_ue_t *amf_ue, OGS_NAS_5GS_NULL_SCHEME) { ogs_error("Not implemented ProtectionSchemeID(%d) in SUCI", mobile_identity_suci->protection_scheme_id); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED) + ); return OGS_ERROR; } amf_ue_set_suci(amf_ue, mobile_identity); @@ -232,8 +237,9 @@ int gmm_handle_registration_request(amf_ue_t *amf_ue, /* Send Registration Reject */ ogs_warn("Cannot find Served TAI[PLMN_ID:%06x,TAC:%d]", ogs_plmn_id_hexdump(&amf_ue->nr_tai.plmn_id), amf_ue->nr_tai.tac.v); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_TRACKING_AREA_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_TRACKING_AREA_NOT_ALLOWED)); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); @@ -253,8 +259,9 @@ int gmm_handle_registration_request(amf_ue_t *amf_ue, ue_security_capability->nr_ea, ue_security_capability->nr_ia, amf_selected_enc_algorithm(amf_ue), amf_selected_int_algorithm(amf_ue)); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH)); return OGS_ERROR; } @@ -446,8 +453,9 @@ int gmm_handle_service_request(amf_ue_t *amf_ue, if (service_request->presencemask & ~OGS_SERVICE_CLEARTEXT_PRESENT) { ogs_error("Non cleartext IEs is included [0x%llx]", (long long)service_request->presencemask); - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } @@ -455,8 +463,9 @@ int gmm_handle_service_request(amf_ue_t *amf_ue, (service_request->presencemask & OGS_NAS_5GS_SERVICE_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT)) { ogs_error("NAS container present without Integrity-protected"); - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } @@ -514,8 +523,9 @@ int gmm_handle_service_request(amf_ue_t *amf_ue, /* Send Registration Reject */ ogs_warn("Cannot find Served TAI[PLMN_ID:%06x,TAC:%d]", ogs_plmn_id_hexdump(&amf_ue->nr_tai.plmn_id), amf_ue->nr_tai.tac.v); - nas_5gs_send_registration_reject(amf_ue, - OGS_5GMM_CAUSE_TRACKING_AREA_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_5gs_send_registration_reject(amf_ue, + OGS_5GMM_CAUSE_TRACKING_AREA_NOT_ALLOWED)); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); @@ -619,7 +629,8 @@ int gmm_handle_service_update(amf_ue_t *amf_ue, } if (amf_sess_xact_count(amf_ue) == xact_count) - nas_5gs_send_service_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_service_accept(amf_ue)); return OGS_OK; } @@ -660,7 +671,8 @@ 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) - nas_5gs_send_de_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_de_registration_accept(amf_ue)); return OGS_OK; } @@ -866,30 +878,34 @@ 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); - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); return OGS_ERROR; } if (!payload_container->length) { ogs_error("[%s] No Payload container length", amf_ue->supi); - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); return OGS_ERROR; } if (!payload_container->buffer) { ogs_error("[%s] No Payload container buffer", amf_ue->supi); - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); 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); - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); return OGS_ERROR; } @@ -897,8 +913,9 @@ 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); - nas_5gs_send_gmm_status( - amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status( + amf_ue, OGS_5GMM_CAUSE_INVALID_MANDATORY_INFORMATION)); return OGS_ERROR; } @@ -924,8 +941,9 @@ 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); - nas_5gs_send_gmm_status(amf_ue, - OGS_5GMM_CAUSE_INSUFFICIENT_USER_PLANE_RESOURCES_FOR_THE_PDU_SESSION); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status(amf_ue, + OGS_5GMM_CAUSE_INSUFFICIENT_USER_PLANE_RESOURCES_FOR_THE_PDU_SESSION)); return OGS_ERROR; } } @@ -964,8 +982,9 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!selected_slice) { ogs_error("[%s] No S-NSSAI", amf_ue->supi); - nas_5gs_send_gmm_status(amf_ue, - OGS_5GMM_CAUSE_INSUFFICIENT_RESOURCES_FOR_SPECIFIC_SLICE); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status(amf_ue, + OGS_5GMM_CAUSE_INSUFFICIENT_RESOURCES_FOR_SPECIFIC_SLICE)); return OGS_ERROR; } @@ -988,7 +1007,8 @@ int gmm_handle_ul_nas_transport(amf_ue_t *amf_ue, if (!sess->dnn) { ogs_error("[%s] No DNN", amf_ue->supi); - nas_5gs_send_gmm_status(amf_ue, OGS_5GMM_CAUSE_DNN_NOT_SUPPORTED_OR_NOT_SUBSCRIBED_IN_THE_SLICE); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status(amf_ue, OGS_5GMM_CAUSE_DNN_NOT_SUPPORTED_OR_NOT_SUBSCRIBED_IN_THE_SLICE)); return OGS_ERROR; } @@ -1032,8 +1052,9 @@ 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); - nas_5gs_send_back_5gsm_message(sess, - OGS_5GSM_CAUSE_PDU_SESSION_DOES_NOT_EXIST); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message(sess, + OGS_5GSM_CAUSE_PDU_SESSION_DOES_NOT_EXIST)); return OGS_ERROR; } @@ -1061,8 +1082,9 @@ 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); - nas_5gs_send_gmm_status(amf_ue, - OGS_5GMM_CAUSE_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status(amf_ue, + OGS_5GMM_CAUSE_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED)); return OGS_ERROR; } diff --git a/src/amf/gmm-sm.c b/src/amf/gmm-sm.c index 2afea4d96..d052cd051 100644 --- a/src/amf/gmm-sm.c +++ b/src/amf/gmm-sm.c @@ -139,7 +139,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (!AMF_UE_HAVE_SUCI(amf_ue)) { CLEAR_AMF_UE_TIMER(amf_ue->t3570); - nas_5gs_send_identity_request(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_identity_request(amf_ue)); break; } @@ -192,7 +193,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) } CLEAR_AMF_UE_TIMER(amf_ue->t3550); - nas_5gs_send_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_registration_accept(amf_ue)); } if (amf_ue->next.m_tmsi) @@ -227,16 +229,20 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) if (!AMF_UE_HAVE_SUCI(amf_ue)) { ogs_info("Service request : Unknown UE"); - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); OGS_FSM_TRAN(s, gmm_state_exception); break; } if (!h.integrity_protected || !SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_error("No Security Context"); - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -376,7 +382,8 @@ static void common_register_state(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 */ - nas_5gs_send_configuration_update_command(amf_ue, NULL); + ogs_assert(OGS_OK == + nas_5gs_send_configuration_update_command(amf_ue, NULL)); } break; @@ -389,7 +396,8 @@ static void common_register_state(ogs_fsm_t *s, amf_event_t *e) OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3570.retry_count++; - nas_5gs_send_identity_request(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_identity_request(amf_ue)); } break; @@ -451,7 +459,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) amf_ue, &nas_message->gmm.authentication_response); if (rv != OGS_OK) { - nas_5gs_send_authentication_reject(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_reject(amf_ue)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } break; @@ -503,7 +512,8 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e) break; } - nas_5gs_send_authentication_reject(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_reject(amf_ue)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; @@ -547,11 +557,13 @@ 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); - nas_5gs_send_authentication_reject(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_reject(amf_ue)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3560.retry_count++; - nas_5gs_send_authentication_request(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_request(amf_ue)); } break; default: @@ -581,8 +593,9 @@ 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); } - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, sbi_message->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, sbi_message->res_status)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -594,7 +607,8 @@ 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); - nas_5gs_send_authentication_reject(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_reject(amf_ue)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } break; @@ -604,7 +618,8 @@ 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); - nas_5gs_send_authentication_reject(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_reject(amf_ue)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_security_mode); @@ -654,7 +669,8 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: CLEAR_AMF_UE_TIMER(amf_ue->t3560); - nas_5gs_send_security_mode_command(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_security_mode_command(amf_ue)); break; case OGS_FSM_EXIT_SIG: break; @@ -676,16 +692,18 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) ogs_error("[%s] Security-mode : No Integrity Protected", amf_ue->supi); - nas_5gs_send_gmm_reject(amf_ue, - OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject(amf_ue, + OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); OGS_FSM_TRAN(s, &gmm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_warn("[%s] No Security Context", amf_ue->supi); - nas_5gs_send_gmm_reject(amf_ue, - OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject(amf_ue, + OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); OGS_FSM_TRAN(s, &gmm_state_exception); break; } @@ -694,8 +712,9 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e) amf_ue, &nas_message->gmm.security_mode_complete); if (rv != OGS_OK) { ogs_error("[%s] Cannot handle NAS message", amf_ue->suci); - nas_5gs_send_gmm_reject(amf_ue, - OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject(amf_ue, + OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); OGS_FSM_TRAN(s, gmm_state_exception); break; } @@ -744,8 +763,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); - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); OGS_FSM_TRAN(s, &gmm_state_exception); break; @@ -774,12 +795,14 @@ 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); - nas_5gs_send_gmm_reject(amf_ue, - OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject(amf_ue, + OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3560.retry_count++; - nas_5gs_send_security_mode_command(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_security_mode_command(amf_ue)); } break; default: @@ -842,8 +865,9 @@ 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); - nas_5gs_send_gmm_reject( - amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject( + amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -878,8 +902,9 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) if (sbi_message->res_status != OGS_SBI_HTTP_STATUS_OK) { ogs_error("[%s] HTTP response error [%d]", amf_ue->supi, sbi_message->res_status); - nas_5gs_send_gmm_reject( - amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject( + amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -888,8 +913,9 @@ 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]); - nas_5gs_send_gmm_reject( - amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject( + amf_ue, OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED)); OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); break; } @@ -917,7 +943,8 @@ 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); - nas_5gs_send_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_registration_accept(amf_ue)); if (!amf_ue->next.m_tmsi) OGS_FSM_TRAN(s, &gmm_state_registered); @@ -982,7 +1009,8 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) */ memset(¶m, 0, sizeof(param)); param.nitz = 1; - nas_5gs_send_configuration_update_command(amf_ue, ¶m); + ogs_assert(OGS_OK == + nas_5gs_send_configuration_update_command(amf_ue, ¶m)); OGS_FSM_TRAN(s, &gmm_state_registered); break; @@ -1008,8 +1036,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); - nas_5gs_send_service_reject(amf_ue, - OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_5gs_send_service_reject(amf_ue, + OGS_5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); OGS_FSM_TRAN(s, &gmm_state_exception); break; @@ -1042,7 +1072,8 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e) OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_exception); } else { amf_ue->t3550.retry_count++; - nas_5gs_send_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_registration_accept(amf_ue)); } break; default: @@ -1089,9 +1120,10 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); if (ogs_list_count(&amf_ue->sess_list) == 0) - ngap_send_amf_ue_context_release_command(amf_ue, + ogs_assert(OGS_OK == + 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)); break; case OGS_FSM_EXIT_SIG: break; @@ -1121,7 +1153,8 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) if (!AMF_UE_HAVE_SUCI(amf_ue)) { CLEAR_AMF_UE_TIMER(amf_ue->t3570); - nas_5gs_send_identity_request(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_identity_request(amf_ue)); OGS_FSM_TRAN(s, &gmm_state_de_registered); break; @@ -1176,7 +1209,8 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e) } CLEAR_AMF_UE_TIMER(amf_ue->t3550); - nas_5gs_send_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_registration_accept(amf_ue)); } if (amf_ue->next.m_tmsi) diff --git a/src/amf/namf-handler.c b/src/amf/namf-handler.c index afacdd9cf..4971c8849 100644 --- a/src/amf/namf-handler.c +++ b/src/amf/namf-handler.c @@ -287,7 +287,8 @@ int amf_namf_comm_handle_n1_n2_message_transfer( ngap_send_paging(amf_ue); } else if (CM_CONNECTED(amf_ue)) { - ngap_send_pdu_resource_setup_request(sess, n2buf); + ogs_assert(OGS_OK == + ngap_send_pdu_resource_setup_request(sess, n2buf)); } else { diff --git a/src/amf/nas-path.c b/src/amf/nas-path.c index 015cd690b..f7daa4b51 100644 --- a/src/amf/nas-path.c +++ b/src/amf/nas-path.c @@ -46,24 +46,20 @@ int nas_5gs_send_to_downlink_nas_transport(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf) ogs_warn("NG context has already been removed"); ogs_pkbuf_free(pkbuf); + return OGS_ERROR; } else { ngapbuf = ngap_build_downlink_nas_transport( ran_ue, pkbuf, false, false); - if (!ngapbuf) { - ogs_error("ngap_build_downlink_nas_transport() failed"); - return OGS_ERROR; - } + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - if (rv != OGS_OK) { - return OGS_ERROR; - } - } + ogs_expect(rv == OGS_OK); - return OGS_OK; + return rv; + } } -void nas_5gs_send_registration_accept(amf_ue_t *amf_ue) +int nas_5gs_send_registration_accept(amf_ue_t *amf_ue) { int rv; bool transfer_needed = false; @@ -82,10 +78,10 @@ void nas_5gs_send_registration_accept(amf_ue_t *amf_ue) if (amf_ue->next.m_tmsi) { if (amf_ue->t3550.pkbuf) { gmmbuf = amf_ue->t3550.pkbuf; - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_registration_accept(amf_ue); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } amf_ue->t3550.pkbuf = ogs_pkbuf_copy(gmmbuf); @@ -94,7 +90,7 @@ void nas_5gs_send_registration_accept(amf_ue_t *amf_ue) amf_timer_cfg(AMF_TIMER_T3550)->duration); } else { gmmbuf = gmm_build_registration_accept(amf_ue); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } /* @@ -120,32 +116,34 @@ void 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } else { ngapbuf = ngap_build_downlink_nas_transport( ran_ue, gmmbuf, true, true); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } } + + return OGS_OK; } -void nas_5gs_send_registration_reject( +int nas_5gs_send_registration_reject( amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t gmm_cause) { int rv; @@ -156,13 +154,15 @@ void 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(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_service_accept(amf_ue_t *amf_ue) +int nas_5gs_send_service_accept(amf_ue_t *amf_ue) { int rv; bool transfer_needed = false; @@ -178,7 +178,7 @@ void nas_5gs_send_service_accept(amf_ue_t *amf_ue) ogs_debug("[%s] Service accept", amf_ue->supi); gmmbuf = gmm_build_service_accept(amf_ue); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); /* * Previously, AMF would sends PDUSessionResourceSetupRequest @@ -203,28 +203,30 @@ void 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } else { rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } } + + return OGS_OK; } -void nas_5gs_send_service_reject( +int nas_5gs_send_service_reject( amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t gmm_cause) { int rv; @@ -235,14 +237,18 @@ void 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(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_de_registration_accept(amf_ue_t *amf_ue) +int nas_5gs_send_de_registration_accept(amf_ue_t *amf_ue) { + int rv; + ran_ue_t *ran_ue = NULL; ogs_pkbuf_t *gmmbuf = NULL; @@ -256,18 +262,21 @@ void 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(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } - ngap_send_ran_ue_context_release_command(ran_ue, + rv = ngap_send_ran_ue_context_release_command(ran_ue, NGAP_Cause_PR_nas, NGAP_CauseNas_deregister, NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK, 0); + ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_identity_request(amf_ue_t *amf_ue) +int nas_5gs_send_identity_request(amf_ue_t *amf_ue) { int rv; ogs_pkbuf_t *gmmbuf = NULL; @@ -278,10 +287,10 @@ void nas_5gs_send_identity_request(amf_ue_t *amf_ue) if (amf_ue->t3570.pkbuf) { gmmbuf = amf_ue->t3570.pkbuf; - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_identity_request(amf_ue); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } amf_ue->t3570.pkbuf = ogs_pkbuf_copy(gmmbuf); @@ -291,9 +300,11 @@ void nas_5gs_send_identity_request(amf_ue_t *amf_ue) rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_authentication_request(amf_ue_t *amf_ue) +int nas_5gs_send_authentication_request(amf_ue_t *amf_ue) { int rv; ogs_pkbuf_t *gmmbuf = NULL; @@ -304,10 +315,10 @@ void nas_5gs_send_authentication_request(amf_ue_t *amf_ue) if (amf_ue->t3560.pkbuf) { gmmbuf = amf_ue->t3560.pkbuf; - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_authentication_request(amf_ue); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } amf_ue->t3560.pkbuf = ogs_pkbuf_copy(gmmbuf); @@ -317,9 +328,11 @@ void nas_5gs_send_authentication_request(amf_ue_t *amf_ue) rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_authentication_reject(amf_ue_t *amf_ue) +int nas_5gs_send_authentication_reject(amf_ue_t *amf_ue) { int rv; ogs_pkbuf_t *gmmbuf = NULL; @@ -329,13 +342,15 @@ void 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(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_security_mode_command(amf_ue_t *amf_ue) +int nas_5gs_send_security_mode_command(amf_ue_t *amf_ue) { int rv; ogs_pkbuf_t *gmmbuf = NULL; @@ -346,10 +361,10 @@ void 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(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } else { gmmbuf = gmm_build_security_mode_command(amf_ue); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); } amf_ue->t3560.pkbuf = ogs_pkbuf_copy(gmmbuf); @@ -359,9 +374,11 @@ void nas_5gs_send_security_mode_command(amf_ue_t *amf_ue) rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_configuration_update_command( +int nas_5gs_send_configuration_update_command( amf_ue_t *amf_ue, gmm_configuration_update_command_param_t *param) { int rv; @@ -373,7 +390,7 @@ void nas_5gs_send_configuration_update_command( if (amf_ue->t3555.pkbuf) { gmmbuf = amf_ue->t3555.pkbuf; - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); amf_ue->t3555.pkbuf = ogs_pkbuf_copy(gmmbuf); ogs_assert(amf_ue->t3555.pkbuf); @@ -381,9 +398,9 @@ void nas_5gs_send_configuration_update_command( amf_timer_cfg(AMF_TIMER_T3555)->duration); } else { - ogs_expect_or_return(param); + ogs_expect_or_return_val(param, OGS_ERROR); gmmbuf = gmm_build_configuration_update_command(amf_ue, param); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); if (param->acknowledgement_requested) { amf_ue->t3555.pkbuf = ogs_pkbuf_copy(gmmbuf); @@ -395,9 +412,11 @@ void nas_5gs_send_configuration_update_command( rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_send_pdu_session_release_command(amf_sess_t *sess, +int nas_send_pdu_session_release_command(amf_sess_t *sess, ogs_pkbuf_t *n1smbuf, ogs_pkbuf_t *n2smbuf) { int rv; @@ -415,17 +434,19 @@ void nas_send_pdu_session_release_command(amf_sess_t *sess, gmmbuf = gmm_build_dl_nas_transport(sess, OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, n1smbuf, 0, 0); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); ngapbuf = ngap_build_pdu_session_resource_release_command( sess, gmmbuf, n2smbuf); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_gmm_status(amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t cause) +int nas_5gs_send_gmm_status(amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t cause) { int rv; ogs_pkbuf_t *gmmbuf = NULL; @@ -435,27 +456,35 @@ void 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(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_gmm_reject( +int nas_5gs_send_gmm_reject( amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t gmm_cause) { + int rv; ogs_assert(amf_ue); switch(amf_ue->nas.message_type) { case OGS_NAS_5GS_REGISTRATION_REQUEST: - nas_5gs_send_registration_reject(amf_ue, gmm_cause); + rv = nas_5gs_send_registration_reject(amf_ue, gmm_cause); + ogs_expect(rv == OGS_OK); break; case OGS_NAS_5GS_SERVICE_REQUEST: - nas_5gs_send_service_reject(amf_ue, gmm_cause); + rv = nas_5gs_send_service_reject(amf_ue, gmm_cause); + ogs_expect(rv == OGS_OK); break; default: ogs_error("Unknown message type [%d]", amf_ue->nas.message_type); + rv = OGS_ERROR; } + + return rv; } static ogs_nas_5gmm_cause_t gmm_cause_from_sbi(int status) @@ -483,13 +512,18 @@ static ogs_nas_5gmm_cause_t gmm_cause_from_sbi(int status) return gmm_cause; } -void nas_5gs_send_gmm_reject_from_sbi(amf_ue_t *amf_ue, int status) +int nas_5gs_send_gmm_reject_from_sbi(amf_ue_t *amf_ue, int status) { + int rv; + ogs_assert(amf_ue); - nas_5gs_send_gmm_reject(amf_ue, gmm_cause_from_sbi(status)); + rv = nas_5gs_send_gmm_reject(amf_ue, gmm_cause_from_sbi(status)); + ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_gsm_reject(amf_sess_t *sess, +int nas_5gs_send_gsm_reject(amf_sess_t *sess, uint8_t payload_container_type, ogs_pkbuf_t *payload_container, ogs_nas_5gmm_cause_t cause, uint8_t backoff_time) { @@ -509,26 +543,34 @@ void nas_5gs_send_gsm_reject(amf_sess_t *sess, gmmbuf = gmm_build_dl_nas_transport(sess, payload_container_type, payload_container, cause, backoff_time); - ogs_expect_or_return(gmmbuf); + ogs_expect_or_return_val(gmmbuf, OGS_ERROR); rv = nas_5gs_send_to_downlink_nas_transport(amf_ue, gmmbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); + + return rv; } -void nas_5gs_send_gsm_reject_from_sbi(amf_sess_t *sess, +int nas_5gs_send_gsm_reject_from_sbi(amf_sess_t *sess, uint8_t payload_container_type, ogs_pkbuf_t *payload_container, int status) { + int rv; + ogs_assert(sess); ogs_assert(payload_container_type); ogs_assert(payload_container); - nas_5gs_send_gsm_reject(sess, payload_container_type, payload_container, + rv = nas_5gs_send_gsm_reject(sess, payload_container_type, payload_container, gmm_cause_from_sbi(status), AMF_NAS_BACKOFF_TIME); + ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_back_5gsm_message( +int nas_5gs_send_back_5gsm_message( amf_sess_t *sess, ogs_nas_5gmm_cause_t cause) { + int rv; ogs_pkbuf_t *pbuf = NULL; ogs_assert(sess); @@ -538,12 +580,21 @@ void nas_5gs_send_back_5gsm_message( pbuf = ogs_pkbuf_copy(sess->payload_container); ogs_assert(pbuf); - nas_5gs_send_gsm_reject(sess, sess->payload_container_type, pbuf, + rv = nas_5gs_send_gsm_reject(sess, sess->payload_container_type, pbuf, cause, AMF_NAS_BACKOFF_TIME); + ogs_expect(rv == OGS_OK); + + return rv; } -void nas_5gs_send_back_5gsm_message_from_sbi(amf_sess_t *sess, int status) +int nas_5gs_send_back_5gsm_message_from_sbi(amf_sess_t *sess, int status) { + int rv; + ogs_assert(sess); - nas_5gs_send_back_5gsm_message(sess, gmm_cause_from_sbi(status)); -} + + rv = nas_5gs_send_back_5gsm_message(sess, gmm_cause_from_sbi(status)); + ogs_expect(rv == OGS_OK); + + return rv; +} \ No newline at end of file diff --git a/src/amf/nas-path.h b/src/amf/nas-path.h index 4063641fe..6f0cdf6fb 100644 --- a/src/amf/nas-path.h +++ b/src/amf/nas-path.h @@ -32,57 +32,47 @@ int nas_5gs_send_to_gnb(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf); int nas_5gs_send_to_downlink_nas_transport( amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf); -void nas_5gs_send_registration_accept(amf_ue_t *amf_ue); -void nas_5gs_send_registration_reject( +int nas_5gs_send_registration_accept(amf_ue_t *amf_ue); +int nas_5gs_send_registration_reject( amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t gmm_cause); -void nas_5gs_send_service_accept(amf_ue_t *amf_ue); -void nas_5gs_send_service_reject( +int nas_5gs_send_service_accept(amf_ue_t *amf_ue); +int nas_5gs_send_service_reject( amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t gmm_cause); -void nas_5gs_send_de_registration_accept(amf_ue_t *amf_ue); +int nas_5gs_send_de_registration_accept(amf_ue_t *amf_ue); -void nas_5gs_send_identity_request(amf_ue_t *amf_ue); +int nas_5gs_send_identity_request(amf_ue_t *amf_ue); -void nas_5gs_send_authentication_request(amf_ue_t *amf_ue); -void nas_5gs_send_authentication_reject(amf_ue_t *amf_ue); +int nas_5gs_send_authentication_request(amf_ue_t *amf_ue); +int nas_5gs_send_authentication_reject(amf_ue_t *amf_ue); -void nas_5gs_send_security_mode_command(amf_ue_t *amf_ue); +int nas_5gs_send_security_mode_command(amf_ue_t *amf_ue); -void nas_5gs_send_configuration_update_command( +int nas_5gs_send_configuration_update_command( amf_ue_t *amf_ue, gmm_configuration_update_command_param_t *param); -void nas_send_pdu_session_release_command(amf_sess_t *sess, +int nas_send_pdu_session_release_command(amf_sess_t *sess, ogs_pkbuf_t *n1smbuf, ogs_pkbuf_t *n2smbuf); -void nas_5gs_send_gmm_status(amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t cause); +int nas_5gs_send_gmm_status(amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t cause); -void nas_5gs_send_gmm_reject( +int nas_5gs_send_gmm_reject( amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t gmm_cause); -void nas_5gs_send_gmm_reject_from_sbi(amf_ue_t *amf_ue, int status); +int nas_5gs_send_gmm_reject_from_sbi(amf_ue_t *amf_ue, int status); -void nas_5gs_send_gsm_reject(amf_sess_t *sess, +int nas_5gs_send_gsm_reject(amf_sess_t *sess, uint8_t payload_container_type, ogs_pkbuf_t *payload_container, ogs_nas_5gmm_cause_t cause, uint8_t backoff_time); -void nas_5gs_send_gsm_reject_from_sbi(amf_sess_t *sess, +int nas_5gs_send_gsm_reject_from_sbi(amf_sess_t *sess, uint8_t payload_container_type, ogs_pkbuf_t *payload_container, int status); -void nas_5gs_send_back_5gsm_message( +int nas_5gs_send_back_5gsm_message( amf_sess_t *sess, ogs_nas_5gmm_cause_t gmm_cause); -void nas_5gs_send_back_5gsm_message_from_sbi(amf_sess_t *sess, int status); - -#if 0 -void nas_5gs_send_tau_accept( - amf_ue_t *amf_ue, S1AP_ProcedureCode_t procedureCode); -void nas_5gs_send_tau_reject(amf_ue_t *amf_ue, ogs_nas_5gsm_cause_t gmm_cause); - -void nas_5gs_send_cs_service_notification(amf_ue_t *amf_ue); -void nas_5gs_send_downlink_nas_transport( - amf_ue_t *amf_ue, uint8_t *buffer, uint8_t length); -#endif +int nas_5gs_send_back_5gsm_message_from_sbi(amf_sess_t *sess, int status); #ifdef __cplusplus } #endif -#endif /* AMF_NAS_5GS_PATH_H */ +#endif /* AMF_NAS_5GS_PATH_H */ \ No newline at end of file diff --git a/src/amf/nausf-handler.c b/src/amf/nausf-handler.c index b24cb34d2..98adc1d23 100644 --- a/src/amf/nausf-handler.c +++ b/src/amf/nausf-handler.c @@ -110,7 +110,8 @@ int amf_nausf_auth_handle_authenticate( amf_ue->nas.ue.ksi = amf_ue->nas.amf.ksi; - nas_5gs_send_authentication_request(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_authentication_request(amf_ue)); return OGS_OK; } diff --git a/src/amf/ngap-handler.c b/src/amf/ngap-handler.c index 6825983c3..a11f3ddaf 100644 --- a/src/amf/ngap-handler.c +++ b/src/amf/ngap-handler.c @@ -148,7 +148,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -157,7 +158,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -165,7 +167,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -188,7 +191,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -212,7 +216,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -243,7 +248,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -279,7 +285,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -289,7 +296,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -299,7 +307,8 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } @@ -310,14 +319,16 @@ 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; - ngap_send_ng_setup_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ng_setup_failure(gnb, group, cause)); return; } amf_gnb_set_gnb_id(gnb, gnb_id); gnb->state.ng_setup_success = true; - ngap_send_ng_setup_response(gnb); + ogs_assert(OGS_OK == + ngap_send_ng_setup_response(gnb)); } void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) @@ -378,8 +389,9 @@ 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"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -438,9 +450,10 @@ 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); - ngap_send_ran_ue_context_release_command(amf_ue->ran_ue, + ogs_assert(OGS_OK == + 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)); } amf_ue_associate_ran_ue(amf_ue, ran_ue); } @@ -449,8 +462,9 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -458,15 +472,17 @@ 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); - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); return; } if (!NAS_PDU) { ogs_error("No NAS_PDU"); - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -548,16 +564,18 @@ void ngap_handle_uplink_nas_transport( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -565,10 +583,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -576,17 +595,19 @@ void ngap_handle_uplink_nas_transport( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -594,16 +615,18 @@ void ngap_handle_uplink_nas_transport( NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &ran_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); return; } if (!NAS_PDU) { ogs_error("No NAS_PDU"); - 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); + ogs_assert(OGS_OK == + 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)); return; } @@ -680,16 +703,18 @@ void ngap_handle_ue_radio_capability_info_indication( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -697,10 +722,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -709,9 +735,10 @@ void ngap_handle_ue_radio_capability_info_indication( if (!UERadioCapability) { ogs_error("No UERadioCapability"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -779,16 +806,18 @@ void ngap_handle_initial_context_setup_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -796,10 +825,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -810,10 +840,11 @@ void ngap_handle_initial_context_setup_response( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -823,24 +854,27 @@ void ngap_handle_initial_context_setup_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceSetupItemCxtRes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->pDUSessionResourceSetupResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupResponseTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -848,18 +882,20 @@ void ngap_handle_initial_context_setup_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -892,7 +928,8 @@ void ngap_handle_initial_context_setup_response( memset(¶m, 0, sizeof(param)); param.acknowledgement_requested = 1; param.guti = 1; - nas_5gs_send_configuration_update_command(amf_ue, ¶m); + ogs_assert(OGS_OK == + nas_5gs_send_configuration_update_command(amf_ue, ¶m)); } AMF_UE_CLEAR_PAGING_INFO(amf_ue); @@ -950,16 +987,18 @@ void ngap_handle_initial_context_setup_failure( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -967,10 +1006,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -979,9 +1019,10 @@ void ngap_handle_initial_context_setup_failure( if (!Cause) { ogs_error("No Cause"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } ogs_debug(" Cause[Group:%d Cause:%d]", @@ -1012,9 +1053,10 @@ void ngap_handle_initial_context_setup_failure( } if (old_xact_count == new_xact_count) { - ngap_send_ran_ue_context_release_command(ran_ue, - NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release, - NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); + ogs_assert(OGS_OK == + 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)); } } @@ -1076,16 +1118,18 @@ void ngap_handle_ue_context_release_request( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1093,10 +1137,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -1105,9 +1150,10 @@ void ngap_handle_ue_context_release_request( if (!Cause) { ogs_error("No Cause"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -1132,9 +1178,10 @@ void ngap_handle_ue_context_release_request( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_ran_ue_context_release_command(ran_ue, + ogs_assert(OGS_OK == + 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)); } else { int xact_count = amf_sess_xact_count(amf_ue); @@ -1152,18 +1199,20 @@ void ngap_handle_ue_context_release_request( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceSetupItemSURes"); - ngap_send_error_indication2( + ogs_assert(OGS_OK == + ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2( + ogs_assert(OGS_OK == + ngap_send_error_indication2( amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return; } @@ -1178,9 +1227,10 @@ void ngap_handle_ue_context_release_request( } if (amf_sess_xact_count(amf_ue) == xact_count) - ngap_send_amf_ue_context_release_command(amf_ue, + ogs_assert(OGS_OK == + 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)); } } @@ -1231,16 +1281,18 @@ void ngap_handle_ue_context_release_complete( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1248,10 +1300,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -1311,7 +1364,8 @@ void ngap_handle_ue_context_release_action(ran_ue_t *ran_ue) ogs_expect_or_return(amf_ue); ogs_expect_or_return(amf_ue->ran_ue); - ngap_send_handover_cancel_ack(amf_ue->ran_ue); + ogs_assert(OGS_OK == + ngap_send_handover_cancel_ack(amf_ue->ran_ue)); break; case NGAP_UE_CTX_REL_NG_HANDOVER_FAILURE: ogs_warn(" Action: NG handover failure"); @@ -1384,16 +1438,18 @@ void ngap_handle_pdu_session_resource_setup_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1401,10 +1457,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -1415,17 +1472,19 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } if (!PDUSessionList) { ogs_error("No PDUSessionResourceSetupListSURes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1436,24 +1495,27 @@ void ngap_handle_pdu_session_resource_setup_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceSetupItemSURes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->pDUSessionResourceSetupResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupResponseTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1461,18 +1523,20 @@ void ngap_handle_pdu_session_resource_setup_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -1547,16 +1611,18 @@ void ngap_handle_pdu_session_resource_modify_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1564,10 +1630,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -1578,17 +1645,19 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } if (!PDUSessionList) { ogs_error("No PDUSessionResourceModifyListModRes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1599,24 +1668,27 @@ void ngap_handle_pdu_session_resource_modify_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceModifyItemModRes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->pDUSessionResourceModifyResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceModifyResponseTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1624,18 +1696,20 @@ void ngap_handle_pdu_session_resource_modify_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -1711,16 +1785,18 @@ void ngap_handle_pdu_session_resource_release_response( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1728,10 +1804,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -1742,17 +1819,19 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } if (!PDUSessionList) { ogs_error("No PDUSessionResourceReleasedListRelRes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1763,24 +1842,27 @@ void ngap_handle_pdu_session_resource_release_response( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceReleasedItemRelRes"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->pDUSessionResourceReleaseResponseTransfer; if (!transfer) { ogs_error("No PDUSessionResourceReleaseResponseTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1788,18 +1870,20 @@ void ngap_handle_pdu_session_resource_release_response( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -1876,16 +1960,18 @@ void ngap_handle_uplink_ran_configuration_transfer( NGAP_GlobalRANNodeID_PR_globalGNB_ID) { ogs_error("Not implemented targetGlobalRANNodeID->present[%d]", targetGlobalRANNodeID->present); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } targetGlobalGNB_ID = targetGlobalRANNodeID->choice.globalGNB_ID; if (!targetGlobalGNB_ID) { ogs_error("No targetGlobalGNB_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1899,16 +1985,18 @@ void ngap_handle_uplink_ran_configuration_transfer( NGAP_GlobalRANNodeID_PR_globalGNB_ID) { ogs_error("Not implemented sourceGlobalRANNodeID->present[%d]", sourceGlobalRANNodeID->present); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } sourceGlobalGNB_ID = sourceGlobalRANNodeID->choice.globalGNB_ID; if (!sourceGlobalGNB_ID) { ogs_error("No sourceGlobalGNB_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -1924,13 +2012,15 @@ 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); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } - ngap_send_downlink_ran_configuration_transfer( - target_gnb, SONConfigurationTransfer); + ogs_assert(OGS_OK == + ngap_send_downlink_ran_configuration_transfer( + target_gnb, SONConfigurationTransfer)); } } @@ -2010,23 +2100,26 @@ void ngap_handle_path_switch_request( if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2034,10 +2127,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2045,10 +2139,11 @@ void ngap_handle_path_switch_request( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2065,8 +2160,9 @@ void ngap_handle_path_switch_request( if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2074,8 +2170,9 @@ void ngap_handle_path_switch_request( NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); return; } @@ -2100,8 +2197,9 @@ void ngap_handle_path_switch_request( if (!UESecurityCapabilities) { ogs_error("No UESecurityCapabilities"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2140,8 +2238,9 @@ void ngap_handle_path_switch_request( if (!SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_error("No Security Context"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure)); return; } @@ -2151,8 +2250,9 @@ void ngap_handle_path_switch_request( if (!PDUSessionResourceToBeSwitchedDLList) { ogs_error("No PDUSessionResourceToBeSwitchedDLList"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2163,24 +2263,27 @@ void ngap_handle_path_switch_request( if (!PDUSessionItem) { ogs_error("No NGAP_PDUSessionResourceToBeSwitchedDLItem"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->pathSwitchRequestTransfer; if (!transfer) { ogs_error("No PDUSessionResourceSetupResponseTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2188,18 +2291,20 @@ void ngap_handle_path_switch_request( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -2297,16 +2402,18 @@ void ngap_handle_handover_required( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2314,10 +2421,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2328,45 +2436,51 @@ void ngap_handle_handover_required( if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } if (!HandoverType) { ogs_error("No HandoverType"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!Cause) { ogs_error("No Cause"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!TargetID) { ogs_error("No TargetID"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (TargetID->present != NGAP_TargetID_PR_targetRANNodeID) { ogs_error("Not implemented TargetID[%d]", TargetID->present); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } targetRANNodeID = TargetID->choice.targetRANNodeID; if (!targetRANNodeID) { ogs_error("No targetRANNodeID"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2374,16 +2488,18 @@ void ngap_handle_handover_required( if (globalRANNodeID->present != NGAP_GlobalRANNodeID_PR_globalGNB_ID) { ogs_error("Not implemented globalRANNodeID[%d]", globalRANNodeID->present); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } globalGNB_ID = globalRANNodeID->choice.globalGNB_ID; if (!globalGNB_ID) { ogs_error("No globalGNB_ID"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2392,29 +2508,33 @@ void ngap_handle_handover_required( if (!target_gnb) { ogs_error("Handover required : cannot find target gNB-id[0x%x]", target_gnb_id); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!PDUSessionList) { ogs_error("No PDUSessionList"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!SourceToTarget_TransparentContainer) { ogs_error("No SourceToTarget_TransparentContainer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!SECURITY_CONTEXT_IS_VALID(amf_ue)) { ogs_error("No Security Context"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_nas, NGAP_CauseNas_authentication_failure)); return; } @@ -2455,24 +2575,27 @@ void ngap_handle_handover_required( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceItemHORqd"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->handoverRequiredTransfer; if (!transfer) { ogs_error("No handoverRequiredTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2480,18 +2603,20 @@ void ngap_handle_handover_required( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -2574,23 +2699,26 @@ void ngap_handle_handover_request_ack( if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2598,17 +2726,19 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } if (!RAN_UE_NGAP_ID) { ogs_error("No RAN_UE_NGAP_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2618,20 +2748,22 @@ void ngap_handle_handover_request_ack( if (!source_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } amf_ue = target_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2642,15 +2774,17 @@ void ngap_handle_handover_request_ack( if (!PDUSessionList) { ogs_error("No PDUSessionList"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (!TargetToSource_TransparentContainer) { ogs_error("No TargetToSource_TransparentContainer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2665,24 +2799,27 @@ void ngap_handle_handover_request_ack( if (!PDUSessionItem) { ogs_error("No PDUSessionResourceAdmittedItem"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } transfer = &PDUSessionItem->handoverRequestAcknowledgeTransfer; if (!transfer) { ogs_error("No handoverRequestAcknowledgeTransfer"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (PDUSessionItem->pDUSessionID == OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED) { ogs_error("PDU Session Identity is unassigned"); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2690,18 +2827,20 @@ void ngap_handle_handover_request_ack( if (!sess) { ogs_error("Cannot find PDU Session ID [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } if (!SESSION_CONTEXT_IN_SMF(sess)) { ogs_error("Session Context is not in SMF [%d]", (int)PDUSessionItem->pDUSessionID); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_PDU_session_ID); + NGAP_CauseRadioNetwork_unknown_PDU_session_ID)); return; } @@ -2768,16 +2907,18 @@ void ngap_handle_handover_failure( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2785,10 +2926,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2796,10 +2938,11 @@ void ngap_handle_handover_failure( if (!source_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2810,19 +2953,22 @@ void ngap_handle_handover_failure( if (!Cause) { ogs_error("No Cause"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } ogs_debug(" Cause[Group:%d Cause:%d]", Cause->present, (int)Cause->choice.radioNetwork); - ngap_send_handover_preparation_failure(source_ue, Cause); + ogs_assert(OGS_OK == + ngap_send_handover_preparation_failure(source_ue, Cause)); - ngap_send_ran_ue_context_release_command(target_ue, + ogs_assert(OGS_OK == + 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)); } void ngap_handle_handover_cancel( @@ -2878,16 +3024,18 @@ void ngap_handle_handover_cancel( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -2895,10 +3043,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2906,20 +3055,22 @@ void ngap_handle_handover_cancel( if (!target_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } amf_ue = source_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -2930,9 +3081,10 @@ void ngap_handle_handover_cancel( if (!Cause) { ogs_error("No Cause"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } ogs_debug(" Cause[Group:%d Cause:%d]", @@ -3004,16 +3156,18 @@ void ngap_handle_uplink_ran_status_transfer( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -3021,10 +3175,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -3032,20 +3187,22 @@ void ngap_handle_uplink_ran_status_transfer( if (!target_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } amf_ue = source_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -3054,8 +3211,9 @@ 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); - ngap_send_downlink_ran_status_transfer( - target_ue, RANStatusTransfer_TransparentContainer); + ogs_assert(OGS_OK == + ngap_send_downlink_ran_status_transfer( + target_ue, RANStatusTransfer_TransparentContainer)); } void ngap_handle_handover_notification( @@ -3112,16 +3270,18 @@ void ngap_handle_handover_notification( if (!AMF_UE_NGAP_ID) { ogs_error("No AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } if (asn_INTEGER2ulong(AMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, (uint32_t *)RAN_UE_NGAP_ID, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -3129,10 +3289,11 @@ 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); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -3140,20 +3301,22 @@ void ngap_handle_handover_notification( if (!source_ue) { ogs_error("Cannot find Source-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } amf_ue = target_ue->amf_ue; if (!amf_ue) { ogs_error("Cannot find AMF-UE Context [%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -3161,8 +3324,9 @@ void ngap_handle_handover_notification( if (!UserLocationInformation) { ogs_error("No UserLocationInformation"); - ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -3170,8 +3334,9 @@ void ngap_handle_handover_notification( NGAP_UserLocationInformation_PR_userLocationInformationNR) { ogs_error("Not implemented UserLocationInformation[%d]", UserLocationInformation->present); - ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, &target_ue->ran_ue_ngap_id, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_unspecified)); return; } @@ -3199,11 +3364,12 @@ 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)); - ngap_send_ran_ue_context_release_command(source_ue, + ogs_assert(OGS_OK == + 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_list_for_each(&amf_ue->sess_list, sess) { memset(¶m, 0, sizeof(param)); @@ -3269,7 +3435,8 @@ void ngap_handle_ran_configuration_update( ogs_error("No globalGNB_ID"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure(gnb, group, cause)); return; } @@ -3294,7 +3461,9 @@ void ngap_handle_ran_configuration_update( ogs_error("No SupportedTAItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure( + gnb, group, cause)); return; } @@ -3318,8 +3487,9 @@ void ngap_handle_ran_configuration_update( ogs_error("No BroadcastPLMNItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ngap_send_ran_configuration_update_failure( - gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure( + gnb, group, cause)); return; } @@ -3350,8 +3520,9 @@ void ngap_handle_ran_configuration_update( ogs_error("No SliceSupportItem"); group = NGAP_Cause_PR_protocol; cause = NGAP_CauseProtocol_semantic_error; - ngap_send_ran_configuration_update_failure( - gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure( + gnb, group, cause)); return; } @@ -3390,7 +3561,8 @@ void ngap_handle_ran_configuration_update( cause = NGAP_CauseProtocol_message_not_compatible_with_receiver_state; - ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure(gnb, group, cause)); return; } @@ -3401,7 +3573,8 @@ void ngap_handle_ran_configuration_update( group = NGAP_Cause_PR_misc; cause = NGAP_CauseMisc_unknown_PLMN; - ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure(gnb, group, cause)); return; } @@ -3412,7 +3585,8 @@ void ngap_handle_ran_configuration_update( group = NGAP_Cause_PR_misc; cause = NGAP_CauseMisc_unknown_PLMN; - ngap_send_ran_configuration_update_failure(gnb, group, cause); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_failure(gnb, group, cause)); return; } } @@ -3420,7 +3594,8 @@ void ngap_handle_ran_configuration_update( if (PagingDRX) ogs_debug(" PagingDRX[%ld]", *PagingDRX); - ngap_send_ran_configuration_update_ack(gnb); + ogs_assert(OGS_OK == + ngap_send_ran_configuration_update_ack(gnb)); } void ngap_handle_ng_reset( @@ -3469,8 +3644,9 @@ void ngap_handle_ng_reset( if (!Cause) { ogs_error("No Cause"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -3479,8 +3655,9 @@ void ngap_handle_ng_reset( if (!ResetType) { ogs_error("No ResetType"); - ngap_send_error_indication(gnb, NULL, NULL, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication(gnb, NULL, NULL, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return; } @@ -3521,7 +3698,8 @@ void ngap_handle_ng_reset( * the AMF shall respond with the NG RESET ACKNOWLEDGE message. */ if (ogs_list_count(&gnb->ran_ue_list) == 0) - ngap_send_ng_reset_ack(gnb, NULL); + ogs_assert(OGS_OK == + ngap_send_ng_reset_ack(gnb, NULL)); break; @@ -3541,10 +3719,11 @@ void ngap_handle_ng_reset( partOfNG_Interface->list.array[i]; if (!item) { ogs_error("No ResetType"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + ngap_send_error_indication( gnb, NULL, NULL, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return; } @@ -3552,10 +3731,11 @@ void ngap_handle_ng_reset( if (asn_INTEGER2ulong(item->aMF_UE_NGAP_ID, (unsigned long *)&amf_ue_ngap_id) != 0) { ogs_error("Invalid AMF_UE_NGAP_ID"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + ngap_send_error_indication( gnb, NULL, NULL, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return; } @@ -3564,10 +3744,11 @@ void ngap_handle_ng_reset( if (!ran_ue) { ogs_error("No RAN UE Context : AMF_UE_NGAP_ID[%lld]", (long long)amf_ue_ngap_id); - ngap_send_error_indication( + ogs_assert(OGS_OK == + 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)); return; } @@ -3579,18 +3760,20 @@ void ngap_handle_ng_reset( if (!ran_ue) { ogs_error("No RAN UE Context : RAN_UE_NGAP_ID[%d]", (int)*item->rAN_UE_NGAP_ID); - ngap_send_error_indication( + ogs_assert(OGS_OK == + ngap_send_error_indication( gnb, NULL, NULL, NGAP_Cause_PR_radioNetwork, - NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID); + NGAP_CauseRadioNetwork_unknown_local_UE_NGAP_ID)); return; } } else { ogs_error("No UE NGAP ID"); - ngap_send_error_indication( + ogs_assert(OGS_OK == + ngap_send_error_indication( gnb, NULL, NULL, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return; } diff --git a/src/amf/ngap-path.c b/src/amf/ngap-path.c index b08fd3879..dc3bb4a66 100644 --- a/src/amf/ngap-path.c +++ b/src/amf/ngap-path.c @@ -236,75 +236,71 @@ int ngap_send_to_nas(ran_ue_t *ran_ue, } } -void ngap_send_ng_setup_response(amf_gnb_t *gnb) +int ngap_send_ng_setup_response(amf_gnb_t *gnb) { + int rv; ogs_pkbuf_t *ngap_buffer; ogs_debug("NG-Setup response"); ngap_buffer = ngap_build_ng_setup_response(); - ogs_expect_or_return(ngap_buffer); + ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); - ogs_expect(OGS_OK == - ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING)); + rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); + ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_ng_setup_failure( +int ngap_send_ng_setup_failure( amf_gnb_t *gnb, NGAP_Cause_PR group, long cause) { + int rv; ogs_pkbuf_t *ngap_buffer; ogs_debug("NG-Setup failure"); ngap_buffer = ngap_build_ng_setup_failure( group, cause, NGAP_TimeToWait_v10s); - ogs_expect_or_return(ngap_buffer); + ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); - ogs_expect(OGS_OK == - ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING)); + rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); + ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_ran_configuration_update_ack(amf_gnb_t *gnb) +int ngap_send_ran_configuration_update_ack(amf_gnb_t *gnb) { + int rv; ogs_pkbuf_t *ngap_buffer; ogs_debug("RANConfigurationUpdateAcknowledge"); ngap_buffer = ngap_build_ran_configuration_update_ack(); - ogs_expect_or_return(ngap_buffer); + ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); - ogs_expect(OGS_OK == - ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING)); + rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); + ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_ran_configuration_update_failure( +int ngap_send_ran_configuration_update_failure( amf_gnb_t *gnb, NGAP_Cause_PR group, long cause) { + int rv; ogs_pkbuf_t *ngap_buffer; ogs_debug("RANConfigurationUpdateFailure"); ngap_buffer = ngap_build_ran_configuration_update_failure( group, cause, NGAP_TimeToWait_v10s); - ogs_expect_or_return(ngap_buffer); + ogs_expect_or_return_val(ngap_buffer, OGS_ERROR); - ogs_expect(OGS_OK == - ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING)); -} - -#if 0 -void ngap_send_ue_context_modification_request(amf_ue_t *amf_ue) -{ - int rv; - ogs_pkbuf_t *ngapbuf = NULL; - - ogs_assert(amf_ue); - - ngapbuf = ngap_build_ue_context_modification_request(amf_ue); - ogs_expect_or_return(ngapbuf); - - rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); + rv = ngap_send_to_gnb(gnb, ngap_buffer, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); -} -#endif -void ngap_send_ran_ue_context_release_command( + return rv; +} + +int ngap_send_ran_ue_context_release_command( ran_ue_t *ran_ue, NGAP_Cause_PR group, long cause, uint8_t action, ogs_time_t duration) { @@ -324,16 +320,18 @@ void 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_delayed_send_to_ran_ue(ran_ue, ngapbuf, duration); ogs_expect(rv == OGS_OK); ogs_timer_start(ran_ue->t_ng_holding, amf_timer_cfg(AMF_TIMER_NG_HOLDING)->duration); + + return rv; } -void ngap_send_amf_ue_context_release_command( +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) { @@ -341,14 +339,17 @@ void ngap_send_amf_ue_context_release_command( ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue); if (ran_ue) { - ngap_send_ran_ue_context_release_command(ran_ue, - group, cause, action, duration); + 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); } + + return OGS_OK; } void ngap_send_paging(amf_ue_t *amf_ue) @@ -387,7 +388,7 @@ void ngap_send_paging(amf_ue_t *amf_ue) amf_timer_cfg(AMF_TIMER_T3513)->duration); } -void ngap_send_pdu_resource_setup_request( +int ngap_send_pdu_resource_setup_request( amf_sess_t *sess, ogs_pkbuf_t *n2smbuf) { int rv; @@ -406,23 +407,25 @@ void ngap_send_pdu_resource_setup_request( ran_ue->initial_context_setup_request_sent == false) { ngapbuf = ngap_sess_build_initial_context_setup_request( sess, NULL, n2smbuf); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); ran_ue->initial_context_setup_request_sent = true; } else { ngapbuf = ngap_sess_build_pdu_session_resource_setup_request( sess, NULL, n2smbuf); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } + + return OGS_OK; } -void ngap_send_downlink_ran_configuration_transfer( +int ngap_send_downlink_ran_configuration_transfer( amf_gnb_t *target_gnb, NGAP_SONConfigurationTransfer_t *transfer) { int rv; @@ -432,13 +435,15 @@ void ngap_send_downlink_ran_configuration_transfer( ogs_assert(transfer); ngapbuf = ngap_build_downlink_ran_configuration_transfer(transfer); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_gnb(target_gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_path_switch_ack(amf_sess_t *sess) +int ngap_send_path_switch_ack(amf_sess_t *sess) { int rv; @@ -450,13 +455,15 @@ void 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_handover_request(amf_ue_t *amf_ue) +int ngap_send_handover_request(amf_ue_t *amf_ue) { int rv; @@ -471,13 +478,15 @@ void ngap_send_handover_request(amf_ue_t *amf_ue) ogs_assert(target_ue); ngapbuf = ngap_build_handover_request(target_ue); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_ran_ue(target_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_handover_preparation_failure( +int ngap_send_handover_preparation_failure( ran_ue_t *source_ue, NGAP_Cause_t *cause) { int rv; @@ -487,13 +496,15 @@ void ngap_send_handover_preparation_failure( ogs_assert(cause); ngapbuf = ngap_build_handover_preparation_failure(source_ue, cause); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_ran_ue(source_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_handover_command(amf_ue_t *amf_ue) +int ngap_send_handover_command(amf_ue_t *amf_ue) { int rv; @@ -505,13 +516,15 @@ void ngap_send_handover_command(amf_ue_t *amf_ue) ogs_assert(source_ue); ngapbuf = ngap_build_handover_command(source_ue); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_ran_ue(source_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_handover_cancel_ack(ran_ue_t *source_ue) +int ngap_send_handover_cancel_ack(ran_ue_t *source_ue) { int rv; ogs_pkbuf_t *ngapbuf = NULL; @@ -519,13 +532,15 @@ void 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(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_ran_ue(source_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_downlink_ran_status_transfer( +int ngap_send_downlink_ran_status_transfer( ran_ue_t *target_ue, NGAP_RANStatusTransfer_TransparentContainer_t *transfer) { @@ -536,13 +551,15 @@ void ngap_send_downlink_ran_status_transfer( ogs_assert(transfer); ngapbuf = ngap_build_uplink_ran_status_transfer(target_ue, transfer); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_ran_ue(target_ue, ngapbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_error_indication( +int ngap_send_error_indication( amf_gnb_t *gnb, uint32_t *ran_ue_ngap_id, uint64_t *amf_ue_ngap_id, @@ -555,29 +572,35 @@ void ngap_send_error_indication( ngapbuf = ogs_ngap_build_error_indication( ran_ue_ngap_id, amf_ue_ngap_id, group, cause); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_gnb(gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_error_indication2( +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(ran_ue); + ogs_expect_or_return_val(ran_ue, OGS_ERROR); gnb = ran_ue->gnb; - ogs_expect_or_return(gnb); + ogs_expect_or_return_val(gnb, OGS_ERROR); - ngap_send_error_indication( + rv = ngap_send_error_indication( gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id, group, cause); + ogs_expect(rv == OGS_OK); + + return rv; } -void ngap_send_ng_reset_ack( +int ngap_send_ng_reset_ack( amf_gnb_t *gnb, NGAP_UE_associatedLogicalNG_connectionList_t *partOfNG_Interface) { @@ -587,8 +610,10 @@ void ngap_send_ng_reset_ack( ogs_assert(gnb); ngapbuf = ogs_ngap_build_ng_reset_ack(partOfNG_Interface); - ogs_expect_or_return(ngapbuf); + ogs_expect_or_return_val(ngapbuf, OGS_ERROR); rv = ngap_send_to_gnb(gnb, ngapbuf, NGAP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); + + return rv; } diff --git a/src/amf/ngap-path.h b/src/amf/ngap-path.h index 00ec6276a..ba9d532e9 100644 --- a/src/amf/ngap-path.h +++ b/src/amf/ngap-path.h @@ -47,49 +47,47 @@ int ngap_send_to_nas(ran_ue_t *ran_ue, NGAP_ProcedureCode_t procedureCode, NGAP_NAS_PDU_t *nasPdu); int ngap_send_to_5gsm(amf_ue_t *amf_ue, ogs_pkbuf_t *esmbuf); -void ngap_send_ng_setup_response(amf_gnb_t *gnb); -void ngap_send_ng_setup_failure( +int ngap_send_ng_setup_response(amf_gnb_t *gnb); +int ngap_send_ng_setup_failure( amf_gnb_t *gnb, NGAP_Cause_PR group, long cause); -void ngap_send_ran_configuration_update_ack(amf_gnb_t *gnb); -void ngap_send_ran_configuration_update_failure( +int ngap_send_ran_configuration_update_ack(amf_gnb_t *gnb); +int ngap_send_ran_configuration_update_failure( amf_gnb_t *gnb, NGAP_Cause_PR group, long cause); -void ngap_send_ue_context_modification_request(amf_ue_t *amf_ue); - -void ngap_send_ran_ue_context_release_command( +int ngap_send_ran_ue_context_release_command( ran_ue_t *ran_ue, NGAP_Cause_PR group, long cause, uint8_t action, ogs_time_t delay); -void ngap_send_amf_ue_context_release_command( +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 delay); void ngap_send_paging(amf_ue_t *amf_ue); -void ngap_send_pdu_resource_setup_request( +int ngap_send_pdu_resource_setup_request( amf_sess_t *sess, ogs_pkbuf_t *n2smbuf); -void ngap_send_downlink_ran_configuration_transfer( +int ngap_send_downlink_ran_configuration_transfer( amf_gnb_t *target_gnb, NGAP_SONConfigurationTransfer_t *transfer); -void ngap_send_path_switch_ack(amf_sess_t *sess); +int ngap_send_path_switch_ack(amf_sess_t *sess); -void ngap_send_handover_request(amf_ue_t *amf_ue); -void ngap_send_handover_preparation_failure( +int ngap_send_handover_request(amf_ue_t *amf_ue); +int ngap_send_handover_preparation_failure( ran_ue_t *source_ue, NGAP_Cause_t *cause); -void ngap_send_handover_command(amf_ue_t *amf_ue); -void ngap_send_handover_cancel_ack(ran_ue_t *source_ue); +int ngap_send_handover_command(amf_ue_t *amf_ue); +int ngap_send_handover_cancel_ack(ran_ue_t *source_ue); -void ngap_send_downlink_ran_status_transfer( +int ngap_send_downlink_ran_status_transfer( ran_ue_t *target_ue, NGAP_RANStatusTransfer_TransparentContainer_t *transfer); -void ngap_send_error_indication( +int ngap_send_error_indication( amf_gnb_t *gnb, uint32_t *ran_ue_ngap_id, uint64_t *amf_ue_ngap_id, NGAP_Cause_PR group, long cause); -void ngap_send_error_indication2( +int ngap_send_error_indication2( amf_ue_t *amf_ue, NGAP_Cause_PR group, long cause); -void ngap_send_ng_reset_ack( +int ngap_send_ng_reset_ack( amf_gnb_t *gnb, NGAP_UE_associatedLogicalNG_connectionList_t *partOfNG_Interface); @@ -97,4 +95,4 @@ void ngap_send_ng_reset_ack( } #endif -#endif /* NGAP_PATH_H */ +#endif /* NGAP_PATH_H */ \ No newline at end of file diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index 3ffb7ed44..b7f73f8ee 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -276,8 +276,9 @@ void amf_nnrf_handle_nf_discover( ogs_assert(amf_ue); ogs_error("[%s] (NF discover) No [%s]", amf_ue->suci, OpenAPI_nf_type_ToString(xact->target_nf_type)); - nas_5gs_send_gmm_reject_from_sbi(amf_ue, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi(amf_ue, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); break; case OGS_SBI_OBJ_SESS_TYPE: sess = (amf_sess_t *)sbi_object; @@ -285,12 +286,14 @@ void amf_nnrf_handle_nf_discover( ogs_error("[%d:%d] (NF discover) No [%s]", sess->psi, sess->pti, OpenAPI_nf_type_ToString(xact->target_nf_type)); if (sess->payload_container_type) { - nas_5gs_send_back_5gsm_message_from_sbi(sess, - OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi(sess, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); } else { - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_transport, - NGAP_CauseTransport_transport_resource_unavailable); + NGAP_CauseTransport_transport_resource_unavailable)); } break; default: diff --git a/src/amf/nnssf-handler.c b/src/amf/nnssf-handler.c index a40e63d0d..6e4228133 100644 --- a/src/amf/nnssf-handler.c +++ b/src/amf/nnssf-handler.c @@ -42,30 +42,34 @@ 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); - nas_5gs_send_gmm_status(amf_ue, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_status(amf_ue, recvmsg->res_status)); return OGS_ERROR; } AuthorizedNetworkSliceInfo = recvmsg->AuthorizedNetworkSliceInfo; if (!AuthorizedNetworkSliceInfo) { ogs_error("No AuthorizedNetworkSliceInfo"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } NsiInformation = AuthorizedNetworkSliceInfo->nsi_information; if (!NsiInformation) { ogs_error("No NsiInformation"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } if (!NsiInformation->nrf_id) { ogs_error("No nrfId"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } @@ -77,8 +81,9 @@ int amf_nnssf_nsselection_handle_get( if (!addr) { ogs_error("[%s:%d] Invalid URI [%s]", amf_ue->supi, sess->psi, NsiInformation->nrf_id); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR;; } diff --git a/src/amf/npcf-handler.c b/src/amf/npcf-handler.c index bfe6b4d3b..ef64c2238 100644 --- a/src/amf/npcf-handler.c +++ b/src/amf/npcf-handler.c @@ -38,29 +38,33 @@ 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); - nas_5gs_send_gmm_reject_from_sbi(amf_ue, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi(amf_ue, recvmsg->res_status)); return OGS_ERROR; } if (!recvmsg->http.location) { ogs_error("[%s] No http.location", amf_ue->supi); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } PolicyAssociation = recvmsg->PolicyAssociation; if (!PolicyAssociation) { ogs_error("No PolicyAssociation"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } if (!PolicyAssociation->supp_feat) { ogs_error("No suppFeat"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } @@ -71,8 +75,9 @@ 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); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } @@ -81,8 +86,9 @@ int amf_npcf_am_policy_control_handle_create( amf_ue->supi, recvmsg->http.location); ogs_sbi_header_free(&header); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } diff --git a/src/amf/nsmf-handler.c b/src/amf/nsmf-handler.c index b3eee9132..827210013 100644 --- a/src/amf/nsmf-handler.c +++ b/src/amf/nsmf-handler.c @@ -38,8 +38,9 @@ int amf_nsmf_pdusession_handle_create_sm_context( if (!recvmsg->http.location) { ogs_error("[%d:%d] No http.location", sess->psi, sess->pti); - nas_5gs_send_back_5gsm_message_from_sbi(sess, - OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi(sess, + OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } @@ -50,8 +51,9 @@ 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); - nas_5gs_send_back_5gsm_message_from_sbi(sess, - OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi(sess, + OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } @@ -60,8 +62,9 @@ int amf_nsmf_pdusession_handle_create_sm_context( sess->psi, sess->pti, recvmsg->http.location); ogs_sbi_header_free(&header); - nas_5gs_send_back_5gsm_message_from_sbi(sess, - OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi(sess, + OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } @@ -87,8 +90,9 @@ int amf_nsmf_pdusession_handle_create_sm_context( sess->psi, sess->pti); ogs_sbi_header_free(&header); - nas_5gs_send_back_5gsm_message_from_sbi(sess, - OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi(sess, + OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR)); return OGS_ERROR; } } @@ -107,12 +111,16 @@ int amf_nsmf_pdusession_handle_create_sm_context( SmContextCreateError = recvmsg->SmContextCreateError; if (!SmContextCreateError) { ogs_error("[%d:%d] No SmContextCreateError", sess->psi, sess->pti); - nas_5gs_send_back_5gsm_message_from_sbi(sess, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, recvmsg->res_status)); return OGS_ERROR; } if (!SmContextCreateError->error) { ogs_error("[%d:%d] No Error", sess->psi, sess->pti); - nas_5gs_send_back_5gsm_message_from_sbi(sess, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, recvmsg->res_status)); return OGS_ERROR; } @@ -127,14 +135,17 @@ int amf_nsmf_pdusession_handle_create_sm_context( */ n1smbuf = ogs_pkbuf_copy(n1smbuf); ogs_assert(n1smbuf); - nas_5gs_send_gsm_reject_from_sbi(sess, - OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, - n1smbuf, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_gsm_reject_from_sbi(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, + n1smbuf, recvmsg->res_status)); return OGS_ERROR; } } - nas_5gs_send_back_5gsm_message_from_sbi(sess, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, recvmsg->res_status)); return OGS_ERROR; } @@ -199,7 +210,8 @@ int amf_nsmf_pdusession_handle_update_sm_context( AMF_UPDATE_SM_CONTEXT_REGISTRATION_REQUEST)) { CLEAR_AMF_UE_TIMER(amf_ue->t3550); - nas_5gs_send_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_registration_accept(amf_ue)); AMF_UE_CLEAR_N2_TRANSFER( amf_ue, pdu_session_resource_setup_request); @@ -213,7 +225,8 @@ int amf_nsmf_pdusession_handle_update_sm_context( AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) && SESSION_SYNC_DONE(amf_ue, AMF_UPDATE_SM_CONTEXT_SERVICE_REQUEST)) { - nas_5gs_send_service_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_service_accept(amf_ue)); AMF_UE_CLEAR_N2_TRANSFER( amf_ue, pdu_session_resource_setup_request); @@ -224,7 +237,8 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (SESSION_SYNC_DONE(amf_ue, AMF_UPDATE_SM_CONTEXT_HANDOVER_REQUIRED)) { - ngap_send_handover_request(amf_ue); + ogs_assert(OGS_OK == + ngap_send_handover_request(amf_ue)); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, handover_request); } @@ -238,16 +252,18 @@ 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); - nas_5gs_send_back_5gsm_message(sess, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message(sess, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } if (!n2smbuf) { ogs_error("[%s:%d] No N2 SM Content", amf_ue->supi, sess->psi); - nas_5gs_send_back_5gsm_message(sess, - OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message(sess, + OGS_5GMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE)); return OGS_ERROR; } @@ -261,16 +277,19 @@ int amf_nsmf_pdusession_handle_update_sm_context( n2smbuf = ogs_pkbuf_copy(n2smbuf); ogs_assert(n2smbuf); - nas_send_pdu_session_release_command(sess, n1smbuf, n2smbuf); + ogs_assert(OGS_OK == + nas_send_pdu_session_release_command( + sess, n1smbuf, n2smbuf)); 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); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } @@ -279,7 +298,8 @@ int amf_nsmf_pdusession_handle_update_sm_context( ogs_pkbuf_copy(n2smbuf)); if (SESSION_SYNC_DONE(amf_ue, state)) { - ngap_send_path_switch_ack(sess); + ogs_assert(OGS_OK == + ngap_send_path_switch_ack(sess)); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, path_switch_request_ack); } @@ -289,9 +309,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!n2smbuf) { ogs_error("[%s:%d] No N2 SM Content", amf_ue->supi, sess->psi); - ngap_send_error_indication2(amf_ue, + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, - NGAP_CauseProtocol_semantic_error); + NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } @@ -299,7 +320,8 @@ int amf_nsmf_pdusession_handle_update_sm_context( sess, handover_command, ogs_pkbuf_copy(n2smbuf)); if (SESSION_SYNC_DONE(amf_ue, state)) { - ngap_send_handover_command(amf_ue); + ogs_assert(OGS_OK == + ngap_send_handover_command(amf_ue)); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, handover_command); } @@ -308,8 +330,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( default: ogs_error("Not implemented [%d]", SmContextUpdatedData->n2_sm_info_type); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, + NGAP_CauseProtocol_semantic_error)); } } else { @@ -350,9 +374,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (SESSION_SYNC_DONE(amf_ue, state)) { ogs_assert(amf_ue->deactivation.group); - 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); + ogs_assert(OGS_OK == + 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)); } } else if (state == AMF_UPDATE_SM_CONTEXT_REGISTRATION_REQUEST) { @@ -429,10 +455,11 @@ int amf_nsmf_pdusession_handle_update_sm_context( target_ue = source_ue->target_ue; ogs_assert(target_ue); - ngap_send_ran_ue_context_release_command(target_ue, + ogs_assert(OGS_OK == + 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)); } } else if (state == AMF_UPDATE_SM_CONTEXT_HANDOVER_NOTIFY) { @@ -468,7 +495,8 @@ int amf_nsmf_pdusession_handle_update_sm_context( ran_ue_remove(ran_ue); if (ogs_list_count(&gnb->ran_ue_list) == 0) - ngap_send_ng_reset_ack(gnb, NULL); + ogs_assert(OGS_OK == + ngap_send_ng_reset_ack(gnb, NULL)); } else { ogs_warn("[%s] RAN-NG Context has already been removed", @@ -552,15 +580,17 @@ int amf_nsmf_pdusession_handle_update_sm_context( if (!SmContextUpdateError) { ogs_error("[%d:%d] No SmContextUpdateError [%d]", sess->psi, sess->pti, recvmsg->res_status); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } if (!SmContextUpdateError->error) { ogs_error("[%d:%d] No Error [%d]", sess->psi, sess->pti, recvmsg->res_status); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } @@ -575,9 +605,10 @@ int amf_nsmf_pdusession_handle_update_sm_context( */ n1smbuf = ogs_pkbuf_copy(n1smbuf); ogs_assert(n1smbuf); - nas_5gs_send_gsm_reject_from_sbi(sess, - OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, - n1smbuf, recvmsg->res_status); + ogs_assert(OGS_OK == + nas_5gs_send_gsm_reject_from_sbi(sess, + OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, + n1smbuf, recvmsg->res_status)); return OGS_ERROR; } } @@ -586,8 +617,9 @@ 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); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } @@ -596,16 +628,18 @@ 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); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } #endif ogs_error("[%d:%d] HTTP response error [%d]", sess->psi, sess->pti, recvmsg->res_status); - ngap_send_error_indication2(amf_ue, - NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + ngap_send_error_indication2(amf_ue, + NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); return OGS_ERROR; } @@ -635,7 +669,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) amf_ue, AMF_UPDATE_SM_CONTEXT_REGISTRATION_REQUEST)) CLEAR_AMF_UE_TIMER(amf_ue->t3550); - nas_5gs_send_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_registration_accept(amf_ue)); } else if (state == AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) { /* @@ -645,7 +680,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) */ if (SESSION_SYNC_DONE(amf_ue, AMF_RELEASE_SM_CONTEXT_SERVICE_ACCEPT) && SESSION_SYNC_DONE(amf_ue, AMF_UPDATE_SM_CONTEXT_SERVICE_REQUEST)) - nas_5gs_send_service_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_service_accept(amf_ue)); } else { @@ -658,9 +694,10 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) * 3. UE Context release command * 4. UE Context release complete */ - ngap_send_amf_ue_context_release_command(amf_ue, + ogs_assert(OGS_OK == + 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)); } else if (state == AMF_RELEASE_SM_CONTEXT_REGISTRATION_ACCEPT) { @@ -694,7 +731,8 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) * 7. UEContextReleaseComplete */ - nas_5gs_send_de_registration_accept(amf_ue); + ogs_assert(OGS_OK == + nas_5gs_send_de_registration_accept(amf_ue)); } else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered)) { /* @@ -715,9 +753,10 @@ int amf_nsmf_pdusession_handle_release_sm_context(amf_sess_t *sess, int state) * 3. UE Context release command * 4. UE Context release complete */ - ngap_send_amf_ue_context_release_command(amf_ue, + ogs_assert(OGS_OK == + 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)); } else if (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_initial_context_setup)) { diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c index 61c331695..65af898d7 100644 --- a/src/amf/sbi-path.c +++ b/src/amf/sbi-path.c @@ -151,16 +151,18 @@ void amf_ue_sbi_discover_and_send( amf_timer_sbi_client_wait_expire); if (!xact) { ogs_error("amf_ue_sbi_discover_and_send() failed"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); return; } if (ogs_sbi_discover_and_send(xact, (ogs_fsm_handler_t)amf_nf_state_registered, client_cb) != true) { ogs_error("amf_ue_sbi_discover_and_send() failed"); - nas_5gs_send_gmm_reject_from_sbi( - amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_gmm_reject_from_sbi( + amf_ue, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); return; } } @@ -180,8 +182,9 @@ void amf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, amf_timer_sbi_client_wait_expire); if (!xact) { ogs_error("amf_sess_sbi_discover_and_send() failed"); - nas_5gs_send_back_5gsm_message_from_sbi( - sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); return; } @@ -190,8 +193,9 @@ void amf_sess_sbi_discover_and_send(OpenAPI_nf_type_e target_nf_type, if (ogs_sbi_discover_and_send(xact, (ogs_fsm_handler_t)amf_nf_state_registered, client_cb) != true) { ogs_error("amf_sess_sbi_discover_and_send() failed"); - nas_5gs_send_back_5gsm_message_from_sbi( - sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); return; } } @@ -209,24 +213,27 @@ static int client_discover_cb(ogs_sbi_response_t *response, void *data) rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { ogs_error("cannot parse HTTP response"); - nas_5gs_send_back_5gsm_message_from_sbi( - sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); goto cleanup; } if (message.res_status != OGS_SBI_HTTP_STATUS_OK) { ogs_error("NF-Discover failed [%d]", message.res_status); - nas_5gs_send_back_5gsm_message_from_sbi( - sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); goto cleanup; } if (!message.SearchResult) { ogs_error("No SearchResult"); - nas_5gs_send_back_5gsm_message_from_sbi( - sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); goto cleanup; } @@ -237,8 +244,9 @@ static int client_discover_cb(ogs_sbi_response_t *response, void *data) if (!OGS_SBI_NF_INSTANCE(&sess->sbi, OpenAPI_nf_type_SMF)) { ogs_error("Cannot discover [%s]", OpenAPI_nf_type_ToString(OpenAPI_nf_type_SMF)); - nas_5gs_send_back_5gsm_message_from_sbi( - sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT); + ogs_assert(OGS_OK == + nas_5gs_send_back_5gsm_message_from_sbi( + sess, OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT)); goto cleanup; } diff --git a/src/mme/emm-handler.c b/src/mme/emm-handler.c index b5a7fd175..e9bb3d01e 100644 --- a/src/mme/emm-handler.c +++ b/src/mme/emm-handler.c @@ -110,9 +110,10 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); @@ -152,9 +153,10 @@ 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)); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); return OGS_ERROR; } @@ -501,7 +503,9 @@ 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); - nas_eps_send_tau_reject(mme_ue, EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_eps_send_tau_reject( + mme_ue, EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED)); return OGS_ERROR; } ogs_debug(" SERVED_TAI_INDEX[%d]", served_tai_index); @@ -617,7 +621,9 @@ 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); - nas_eps_send_tau_reject(mme_ue, EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED); + ogs_assert(OGS_OK == + nas_eps_send_tau_reject( + mme_ue, EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED)); 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 274695be5..5dadc2904 100644 --- a/src/mme/emm-sm.c +++ b/src/mme/emm-sm.c @@ -131,37 +131,42 @@ 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"); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } - s1ap_send_initial_context_setup_request(mme_ue); + ogs_assert(OGS_OK == + s1ap_send_initial_context_setup_request(mme_ue)); OGS_FSM_TRAN(s, &emm_state_registered); break; } @@ -206,7 +211,8 @@ 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); - nas_eps_send_identity_request(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_identity_request(mme_ue)); break; } @@ -219,9 +225,10 @@ 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"); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -250,24 +257,27 @@ 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"); - nas_eps_send_tau_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_tau_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_tau_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_tau_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_tau_reject(mme_ue, - EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED); + ogs_assert(OGS_OK == + nas_eps_send_tau_reject(mme_ue, + EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -346,17 +356,20 @@ 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) { - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_InitialContextSetup); + ogs_assert(OGS_OK == + nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_InitialContextSetup)); } else { - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_downlinkNASTransport); + ogs_assert(OGS_OK == + nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_downlinkNASTransport)); } } else if (e->s1ap_code == S1AP_ProcedureCode_id_uplinkNASTransport) { ogs_debug(" Uplink NAS Transport"); - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_downlinkNASTransport); + ogs_assert(OGS_OK == + nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_downlinkNASTransport)); } else { ogs_fatal("Invalid Procedure Code[%d]", (int)e->s1ap_code); } @@ -385,24 +398,27 @@ 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"); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); 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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -412,8 +428,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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); mme_send_release_access_bearer_or_ue_context_release( enb_ue); break; @@ -425,22 +443,28 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) OGS_NAS_SERVICE_TYPE_CS_FALLBACK_EMERGENCY_CALL_FROM_UE) { ogs_debug(" MO-CSFB-INDICATION[%d]", mme_ue->nas_eps.service.value); - sgsap_send_mo_csfb_indication(mme_ue); + ogs_assert(OGS_OK == + sgsap_send_mo_csfb_indication(mme_ue)); } else if (mme_ue->nas_eps.service.value == OGS_NAS_SERVICE_TYPE_CS_FALLBACK_TO_UE) { ogs_debug(" SERVICE_REQUEST[%d]", mme_ue->nas_eps.service.value); - sgsap_send_service_request(mme_ue, SGSAP_EMM_IDLE_MODE); + ogs_assert(OGS_OK == + sgsap_send_service_request(mme_ue, SGSAP_EMM_IDLE_MODE) + ); } else { ogs_warn(" Unknown CSFB Service Type[%d]", mme_ue->nas_eps.service.value); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); OGS_FSM_TRAN(s, &emm_state_exception); break; } - s1ap_send_initial_context_setup_request(mme_ue); + ogs_assert(OGS_OK == + s1ap_send_initial_context_setup_request(mme_ue)); } else if (e->s1ap_code == S1AP_ProcedureCode_id_uplinkNASTransport) { @@ -448,8 +472,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); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); break; } @@ -459,23 +485,28 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) OGS_NAS_SERVICE_TYPE_CS_FALLBACK_EMERGENCY_CALL_FROM_UE) { ogs_debug(" MO-CSFB-INDICATION[%d]", mme_ue->nas_eps.service.value); - sgsap_send_mo_csfb_indication(mme_ue); + ogs_assert(OGS_OK == + sgsap_send_mo_csfb_indication(mme_ue)); } else if (mme_ue->nas_eps.service.value == OGS_NAS_SERVICE_TYPE_CS_FALLBACK_TO_UE) { ogs_debug(" SERVICE_REQUEST[%d]", mme_ue->nas_eps.service.value); - sgsap_send_service_request( - mme_ue, SGSAP_EMM_CONNECTED_MODE); + ogs_assert(OGS_OK == + sgsap_send_service_request( + mme_ue, SGSAP_EMM_CONNECTED_MODE)); } else { ogs_warn(" Unknown CSFB Service Type[%d]", mme_ue->nas_eps.service.value); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK) + ); OGS_FSM_TRAN(s, &emm_state_exception); break; } - s1ap_send_ue_context_modification_request(mme_ue); + ogs_assert(OGS_OK == + s1ap_send_ue_context_modification_request(mme_ue)); } else { ogs_error("Invalid Procedure Code[%d]", (int)e->s1ap_code); } @@ -499,7 +530,8 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) } if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) { - sgsap_send_detach_indication(mme_ue); + ogs_assert(OGS_OK == + sgsap_send_detach_indication(mme_ue)); } else { mme_send_delete_session_or_detach(mme_ue); } @@ -511,8 +543,9 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) ogs_debug("Uplink NAS Transport"); ogs_debug(" IMSI[%s]", mme_ue->imsi_bcd); if (MME_SGSAP_IS_CONNECTED(mme_ue)) { - sgsap_send_uplink_unitdata(mme_ue, &message->emm. - uplink_nas_transport.nas_message_container); + ogs_assert(OGS_OK == + sgsap_send_uplink_unitdata(mme_ue, &message->emm. + uplink_nas_transport.nas_message_container)); } else { S1AP_MME_UE_S1AP_ID_t MME_UE_S1AP_ID; S1AP_ENB_UE_S1AP_ID_t ENB_UE_S1AP_ID; @@ -521,10 +554,11 @@ 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; - s1ap_send_error_indication(enb_ue->enb, + ogs_assert(OGS_OK == + 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)); } break; @@ -557,8 +591,9 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) if (CS_CALL_SERVICE_INDICATOR(mme_ue) || SMS_SERVICE_INDICATOR(mme_ue)) { - sgsap_send_ue_unreachable(mme_ue, - SGSAP_SGS_CAUSE_UE_UNREACHABLE); + ogs_assert(OGS_OK == + sgsap_send_ue_unreachable(mme_ue, + SGSAP_SGS_CAUSE_UE_UNREACHABLE)); } @@ -583,7 +618,8 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e) OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { mme_ue->t3470.retry_count++; - nas_eps_send_identity_request(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_identity_request(mme_ue)); } break; @@ -645,7 +681,8 @@ 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); - nas_eps_send_authentication_reject(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_authentication_reject(mme_ue)); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); } else { OGS_FSM_TRAN(&mme_ue->sm, &emm_state_security_mode); @@ -688,7 +725,8 @@ void emm_state_authentication(ogs_fsm_t *s, mme_event_t *e) break; } - nas_eps_send_authentication_reject(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_authentication_reject(mme_ue)); OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception); break; @@ -739,10 +777,12 @@ 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); - nas_eps_send_authentication_reject(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_authentication_reject(mme_ue)); } else { mme_ue->t3460.retry_count++; - nas_eps_send_authentication_request(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_authentication_request(mme_ue)); } break; default: @@ -775,7 +815,8 @@ 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); - nas_eps_send_security_mode_command(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_security_mode_command(mme_ue)); break; case OGS_FSM_EXIT_SIG: break; @@ -786,8 +827,9 @@ 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"); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -804,18 +846,20 @@ void emm_state_security_mode(ogs_fsm_t *s, mme_event_t *e) if (h.integrity_protected == 0) { ogs_error("[%s] No Integrity Protected", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_warn("[%s] No Security Context", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -863,8 +907,9 @@ 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"); - nas_eps_send_tau_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_tau_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; case OGS_NAS_EPS_EMM_STATUS: @@ -900,12 +945,14 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); } else { mme_ue->t3460.retry_count++; - nas_eps_send_security_mode_command(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_security_mode_command(mme_ue)); } break; default: @@ -947,8 +994,9 @@ 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"); - nas_eps_send_service_reject(mme_ue, - EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); + ogs_assert(OGS_OK == + nas_eps_send_service_reject(mme_ue, + EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -963,18 +1011,20 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) if (h.integrity_protected == 0) { ogs_error("[%s] No Integrity Protected", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_warn("[%s] No Security Context", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -993,7 +1043,8 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) mme_ue_confirm_guti(mme_ue); if (MME_P_TMSI_IS_AVAILABLE(mme_ue)) - sgsap_send_tmsi_reallocation_complete(mme_ue); + ogs_assert(OGS_OK == + sgsap_send_tmsi_reallocation_complete(mme_ue)); OGS_FSM_TRAN(s, &emm_state_registered); break; @@ -1007,18 +1058,20 @@ void emm_state_initial_context_setup(ogs_fsm_t *s, mme_event_t *e) if (h.integrity_protected == 0) { ogs_error("[%s] No Integrity Protected", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) { ogs_warn("[%s] No Security Context", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } @@ -1155,7 +1208,8 @@ 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); - nas_eps_send_identity_request(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_identity_request(mme_ue)); OGS_FSM_TRAN(s, &emm_state_de_registered); break; @@ -1170,9 +1224,10 @@ 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"); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); OGS_FSM_TRAN(s, &emm_state_exception); break; } diff --git a/src/mme/esm-handler.c b/src/mme/esm-handler.c index 0949dcfd8..d45db5281 100644 --- a/src/mme/esm-handler.c +++ b/src/mme/esm-handler.c @@ -65,8 +65,9 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, mme_ue, req->access_point_name.apn); if (!sess->session) { /* Invalid APN */ - nas_eps_send_pdn_connectivity_reject( - sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN); + ogs_assert(OGS_OK == + nas_eps_send_pdn_connectivity_reject( + sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN)); ogs_warn("Invalid APN"); return OGS_ERROR; } @@ -83,7 +84,8 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, if (security_protected_required) { CLEAR_BEARER_TIMER(bearer->t3489); - nas_eps_send_esm_information_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_esm_information_request(bearer)); return OGS_OK; } @@ -114,11 +116,13 @@ int esm_handle_pdn_connectivity_request(mme_bearer_t *bearer, } } - mme_gtp_send_create_session_request(sess); + ogs_assert(OGS_OK == + mme_gtp_send_create_session_request(sess)); } else { ogs_error("No APN"); - nas_eps_send_pdn_connectivity_reject( - sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN); + ogs_assert(OGS_OK == + nas_eps_send_pdn_connectivity_reject( + sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN)); return OGS_ERROR; } @@ -160,17 +164,21 @@ int esm_handle_information_response(mme_sess_t *sess, mme_ue->csmap = csmap; if (csmap) { - sgsap_send_location_update_request(mme_ue); + ogs_assert(OGS_OK == + sgsap_send_location_update_request(mme_ue)); } else { - nas_eps_send_attach_accept(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_attach_accept(mme_ue)); } } else { - mme_gtp_send_create_session_request(sess); + ogs_assert(OGS_OK == + mme_gtp_send_create_session_request(sess)); } } else { ogs_error("No APN"); - nas_eps_send_pdn_connectivity_reject( - sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN); + ogs_assert(OGS_OK == + nas_eps_send_pdn_connectivity_reject( + sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN)); return OGS_ERROR; } @@ -189,8 +197,9 @@ int esm_handle_bearer_resource_allocation_request( mme_ue = sess->mme_ue; ogs_assert(mme_ue); - nas_eps_send_bearer_resource_allocation_reject( - mme_ue, sess->pti, ESM_CAUSE_NETWORK_FAILURE); + ogs_assert(OGS_OK == + nas_eps_send_bearer_resource_allocation_reject( + mme_ue, sess->pti, ESM_CAUSE_NETWORK_FAILURE)); return OGS_OK; } @@ -204,7 +213,8 @@ int esm_handle_bearer_resource_modification_request( mme_ue = bearer->mme_ue; ogs_assert(mme_ue); - mme_gtp_send_bearer_resource_command(bearer, message); + ogs_assert(OGS_OK == + mme_gtp_send_bearer_resource_command(bearer, message)); return OGS_OK; } diff --git a/src/mme/esm-sm.c b/src/mme/esm-sm.c index d5344ae37..2547dce1d 100644 --- a/src/mme/esm-sm.c +++ b/src/mme/esm-sm.c @@ -117,10 +117,12 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) ogs_debug(" IMSI[%s] PTI[%d] EBI[%d]", mme_ue->imsi_bcd, sess->pti, bearer->ebi); if (MME_HAVE_SGW_S1U_PATH(sess)) { - mme_gtp_send_delete_session_request(sess, - OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST); + ogs_assert(OGS_OK == + mme_gtp_send_delete_session_request(sess, + OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST)); } else { - nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_deactivate_bearer_context_request(bearer)); } OGS_FSM_TRAN(s, esm_state_pdn_will_disconnect); break; @@ -134,26 +136,30 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); ogs_assert(mme_ue->enb_ue); - s1ap_send_ue_context_release_command(mme_ue->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); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); ogs_assert(mme_ue->enb_ue); - s1ap_send_ue_context_release_command(mme_ue->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); + S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0)); OGS_FSM_TRAN(s, &esm_state_exception); break; } @@ -172,7 +178,8 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) /* Check if Initial Context Setup Response or * E-RAB Setup Response is received */ if (MME_HAVE_ENB_S1U_PATH(bearer)) { - mme_gtp_send_modify_bearer_request(bearer, 0); + ogs_assert(OGS_OK == + mme_gtp_send_modify_bearer_request(bearer, 0)); } nas_eps_send_activate_all_dedicated_bearers(bearer); @@ -185,8 +192,9 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) /* Check if Initial Context Setup Response or * E-RAB Setup Response is received */ if (MME_HAVE_ENB_S1U_PATH(bearer)) { - mme_gtp_send_create_bearer_response( - bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + mme_gtp_send_create_bearer_response( + bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED)); } OGS_FSM_TRAN(s, esm_state_active); @@ -198,9 +206,10 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) activate_dedicated_eps_bearer_context_reject = &message->esm.activate_dedicated_eps_bearer_context_reject; ogs_assert(activate_dedicated_eps_bearer_context_reject); - mme_gtp_send_create_bearer_response(bearer, + ogs_assert(OGS_OK == + mme_gtp_send_create_bearer_response(bearer, gtp_cause_from_esm( - activate_dedicated_eps_bearer_context_reject->esm_cause)); + activate_dedicated_eps_bearer_context_reject->esm_cause))); OGS_FSM_TRAN(s, esm_state_bearer_deactivated); break; default: @@ -218,11 +227,13 @@ void esm_state_inactive(ogs_fsm_t *s, mme_event_t *e) mme_ue->imsi_bcd); OGS_FSM_TRAN(&bearer->sm, &esm_state_exception); - nas_eps_send_pdn_connectivity_reject(sess, - ESM_CAUSE_ESM_INFORMATION_NOT_RECEIVED); + ogs_assert(OGS_OK == + nas_eps_send_pdn_connectivity_reject(sess, + ESM_CAUSE_ESM_INFORMATION_NOT_RECEIVED)); } else { bearer->t3489.retry_count++; - nas_eps_send_esm_information_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_esm_information_request(bearer)); } break; default: @@ -285,10 +296,12 @@ void esm_state_active(ogs_fsm_t *s, mme_event_t *e) ogs_debug(" IMSI[%s] PTI[%d] EBI[%d]", mme_ue->imsi_bcd, sess->pti, bearer->ebi); if (MME_HAVE_SGW_S1U_PATH(sess)) { - mme_gtp_send_delete_session_request(sess, - OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST); + ogs_assert(OGS_OK == + mme_gtp_send_delete_session_request(sess, + OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST)); } else { - nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_deactivate_bearer_context_request(bearer)); } OGS_FSM_TRAN(s, esm_state_pdn_will_disconnect); break; @@ -297,16 +310,18 @@ void esm_state_active(ogs_fsm_t *s, mme_event_t *e) ogs_debug(" IMSI[%s] PTI[%d] EBI[%d]", mme_ue->imsi_bcd, sess->pti, bearer->ebi); - mme_gtp_send_update_bearer_response( - bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + mme_gtp_send_update_bearer_response( + bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED)); break; case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT: ogs_debug("Deactivate EPS bearer " "context accept"); ogs_debug(" IMSI[%s] PTI[%d] EBI[%d]", mme_ue->imsi_bcd, sess->pti, bearer->ebi); - mme_gtp_send_delete_bearer_response( - bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + mme_gtp_send_delete_bearer_response( + bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED)); OGS_FSM_TRAN(s, esm_state_bearer_deactivated); break; case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST: diff --git a/src/mme/mme-context.c b/src/mme/mme-context.c index faed178fa..79767cbf9 100644 --- a/src/mme/mme-context.c +++ b/src/mme/mme-context.c @@ -2857,9 +2857,10 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); return NULL; } @@ -2868,9 +2869,10 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); return NULL; } @@ -2885,9 +2887,10 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); return NULL; } } else if (message->esm.h.message_type == @@ -2903,8 +2906,9 @@ 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); - nas_eps_send_bearer_resource_allocation_reject( - mme_ue, pti, ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + ogs_assert(OGS_OK == + nas_eps_send_bearer_resource_allocation_reject( + mme_ue, pti, ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY)); return NULL; } @@ -2921,8 +2925,9 @@ 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); - nas_eps_send_bearer_resource_modification_reject( - mme_ue, pti, ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY); + ogs_assert(OGS_OK == + nas_eps_send_bearer_resource_modification_reject( + mme_ue, pti, ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY)); return NULL; } } @@ -2956,9 +2961,10 @@ 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); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); return NULL; } } diff --git a/src/mme/mme-gtp-path.c b/src/mme/mme-gtp-path.c index c71ad0350..b1cf34ba6 100644 --- a/src/mme/mme-gtp-path.c +++ b/src/mme/mme-gtp-path.c @@ -131,9 +131,10 @@ static void timeout(ogs_gtp_xact_t *xact, void *data) enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (enb_ue) { - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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)); } else { ogs_warn("No S1 Context"); } @@ -198,7 +199,7 @@ void mme_gtp_close(void) ogs_socknode_remove_all(&ogs_gtp_self()->gtpc_list6); } -void mme_gtp_send_create_session_request(mme_sess_t *sess) +int mme_gtp_send_create_session_request(mme_sess_t *sess) { int rv; ogs_gtp_header_t h; @@ -214,16 +215,18 @@ void mme_gtp_send_create_session_request(mme_sess_t *sess) h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_create_session_request(h.type, sess); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, pkbuf, timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_modify_bearer_request(mme_bearer_t *bearer, int uli_presence) +int mme_gtp_send_modify_bearer_request(mme_bearer_t *bearer, int uli_presence) { int rv; @@ -242,16 +245,18 @@ void mme_gtp_send_modify_bearer_request(mme_bearer_t *bearer, int uli_presence) h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_modify_bearer_request(h.type, bearer, uli_presence); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, pkbuf, timeout, bearer); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_delete_session_request(mme_sess_t *sess, int action) +int mme_gtp_send_delete_session_request(mme_sess_t *sess, int action) { int rv; ogs_pkbuf_t *s11buf = NULL; @@ -269,14 +274,16 @@ void mme_gtp_send_delete_session_request(mme_sess_t *sess, int action) h.teid = mme_ue->sgw_s11_teid; s11buf = mme_s11_build_delete_session_request(h.type, sess); - ogs_expect_or_return(s11buf); + ogs_expect_or_return_val(s11buf, OGS_ERROR); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, s11buf, timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->delete_action = action; rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } void mme_gtp_send_delete_all_sessions(mme_ue_t *mme_ue, int action) @@ -316,7 +323,7 @@ void mme_gtp_send_delete_all_sessions(mme_ue_t *mme_ue, int action) } } -void mme_gtp_send_create_bearer_response( +int mme_gtp_send_create_bearer_response( mme_bearer_t *bearer, uint8_t cause_value) { int rv; @@ -338,16 +345,18 @@ void mme_gtp_send_create_bearer_response( h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_create_bearer_response(h.type, bearer, cause_value); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_update_bearer_response( +int mme_gtp_send_update_bearer_response( mme_bearer_t *bearer, uint8_t cause_value) { int rv; @@ -369,16 +378,18 @@ void mme_gtp_send_update_bearer_response( h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_update_bearer_response(h.type, bearer, cause_value); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_delete_bearer_response( +int mme_gtp_send_delete_bearer_response( mme_bearer_t *bearer, uint8_t cause_value) { int rv; @@ -400,16 +411,18 @@ void mme_gtp_send_delete_bearer_response( h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_delete_bearer_response(h.type, bearer, cause_value); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_release_access_bearers_request(mme_ue_t *mme_ue, int action) +int mme_gtp_send_release_access_bearers_request(mme_ue_t *mme_ue, int action) { int rv; ogs_gtp_header_t h; @@ -424,14 +437,16 @@ void mme_gtp_send_release_access_bearers_request(mme_ue_t *mme_ue, int action) h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_release_access_bearers_request(h.type); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, pkbuf, timeout, mme_ue); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->release_action = action; rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } void mme_gtp_send_release_all_ue_in_enb(mme_enb_t *enb, int action) @@ -443,8 +458,8 @@ void mme_gtp_send_release_all_ue_in_enb(mme_enb_t *enb, int action) mme_ue = enb_ue->mme_ue; if (mme_ue) { - - mme_gtp_send_release_access_bearers_request(mme_ue, action); + ogs_assert(OGS_OK == + mme_gtp_send_release_access_bearers_request(mme_ue, action)); } else { ogs_warn("mme_gtp_send_release_all_ue_in_enb()"); @@ -462,7 +477,7 @@ void mme_gtp_send_release_all_ue_in_enb(mme_enb_t *enb, int action) } } -void mme_gtp_send_downlink_data_notification_ack( +int mme_gtp_send_downlink_data_notification_ack( mme_bearer_t *bearer, uint8_t cause_value) { int rv; @@ -484,17 +499,18 @@ void mme_gtp_send_downlink_data_notification_ack( h.teid = mme_ue->sgw_s11_teid; s11buf = mme_s11_build_downlink_data_notification_ack(h.type, cause_value); - ogs_expect_or_return(s11buf); + ogs_expect_or_return_val(s11buf, OGS_ERROR); rv = ogs_gtp_xact_update_tx(xact, &h, s11buf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + return rv; } -void mme_gtp_send_create_indirect_data_forwarding_tunnel_request( +int mme_gtp_send_create_indirect_data_forwarding_tunnel_request( mme_ue_t *mme_ue) { int rv; @@ -510,16 +526,18 @@ void mme_gtp_send_create_indirect_data_forwarding_tunnel_request( pkbuf = mme_s11_build_create_indirect_data_forwarding_tunnel_request( h.type, mme_ue); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, pkbuf, timeout, mme_ue); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( +int mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( mme_ue_t *mme_ue, int action) { int rv; @@ -535,18 +553,20 @@ void mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( h.teid = mme_ue->sgw_s11_teid; pkbuf = ogs_pkbuf_alloc(NULL, OGS_TLV_MAX_HEADROOM); - ogs_assert(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); ogs_pkbuf_reserve(pkbuf, OGS_TLV_MAX_HEADROOM); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, pkbuf, timeout, mme_ue); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->delete_indirect_action = action; rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void mme_gtp_send_bearer_resource_command( +int mme_gtp_send_bearer_resource_command( mme_bearer_t *bearer, ogs_nas_eps_message_t *nas_message) { int rv; @@ -565,12 +585,14 @@ void mme_gtp_send_bearer_resource_command( h.teid = mme_ue->sgw_s11_teid; pkbuf = mme_s11_build_bearer_resource_command(h.type, bearer, nas_message); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); xact = ogs_gtp_xact_local_create(mme_ue->gnode, &h, pkbuf, timeout, bearer); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->xid |= OGS_GTP_CMD_XACT_ID; rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); -} + + return rv; +} \ No newline at end of file diff --git a/src/mme/mme-gtp-path.h b/src/mme/mme-gtp-path.h index c91bdd2aa..de208441d 100644 --- a/src/mme/mme-gtp-path.h +++ b/src/mme/mme-gtp-path.h @@ -29,32 +29,32 @@ extern "C" { int mme_gtp_open(void); void mme_gtp_close(void); -void mme_gtp_send_create_session_request(mme_sess_t *sess); -void mme_gtp_send_modify_bearer_request(mme_bearer_t *bearer, int uli_presence); -void mme_gtp_send_delete_session_request(mme_sess_t *sess, int action); +int mme_gtp_send_create_session_request(mme_sess_t *sess); +int mme_gtp_send_modify_bearer_request(mme_bearer_t *bearer, int uli_presence); +int mme_gtp_send_delete_session_request(mme_sess_t *sess, int action); void mme_gtp_send_delete_all_sessions(mme_ue_t *mme_ue, int action); -void mme_gtp_send_create_bearer_response( +int mme_gtp_send_create_bearer_response( mme_bearer_t *bearer, uint8_t cause_value); -void mme_gtp_send_update_bearer_response( +int mme_gtp_send_update_bearer_response( mme_bearer_t *bearer, uint8_t cause_value); -void mme_gtp_send_delete_bearer_response( +int mme_gtp_send_delete_bearer_response( mme_bearer_t *bearer, uint8_t cause_value); -void mme_gtp_send_release_access_bearers_request(mme_ue_t *mme_ue, int action); +int mme_gtp_send_release_access_bearers_request(mme_ue_t *mme_ue, int action); void mme_gtp_send_release_all_ue_in_enb(mme_enb_t *enb, int action); -void mme_gtp_send_downlink_data_notification_ack( +int mme_gtp_send_downlink_data_notification_ack( mme_bearer_t *bearer, uint8_t cause_value); -void mme_gtp_send_create_indirect_data_forwarding_tunnel_request( +int mme_gtp_send_create_indirect_data_forwarding_tunnel_request( mme_ue_t *mme_ue); -void mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( +int mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( mme_ue_t *mme_ue, int action); -void mme_gtp_send_bearer_resource_command( +int mme_gtp_send_bearer_resource_command( mme_bearer_t *bearer, ogs_nas_eps_message_t *nas_message); #ifdef __cplusplus } #endif -#endif /* MME_S11_PATH_H */ +#endif /* MME_S11_PATH_H */ \ No newline at end of file diff --git a/src/mme/mme-path.c b/src/mme/mme-path.c index 35f979a8e..9b45a3521 100644 --- a/src/mme/mme-path.c +++ b/src/mme/mme-path.c @@ -30,7 +30,8 @@ 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 { - nas_eps_send_detach_accept(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_detach_accept(mme_ue)); } } @@ -44,9 +45,10 @@ 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) { - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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)); } else { ogs_warn("[%s] No S1 Context", mme_ue->imsi_bcd); } @@ -61,13 +63,15 @@ void mme_send_release_access_bearer_or_ue_context_release(enb_ue_t *enb_ue) mme_ue = enb_ue->mme_ue; if (mme_ue) { ogs_debug("[%s] Release access bearer request", mme_ue->imsi_bcd); - mme_gtp_send_release_access_bearers_request( - mme_ue, OGS_GTP_RELEASE_SEND_UE_CONTEXT_RELEASE_COMMAND); + ogs_assert(OGS_OK == + mme_gtp_send_release_access_bearers_request( + mme_ue, OGS_GTP_RELEASE_SEND_UE_CONTEXT_RELEASE_COMMAND)); } else { ogs_debug("[%s] No UE Context", mme_ue->imsi_bcd); - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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)); } } @@ -94,36 +98,43 @@ void mme_send_after_paging(mme_ue_t *mme_ue, uint8_t cause_value) switch (type) { case OGS_GTP_DOWNLINK_DATA_NOTIFICATION_TYPE: - mme_gtp_send_downlink_data_notification_ack( - bearer, cause_value); + ogs_assert(OGS_OK == + mme_gtp_send_downlink_data_notification_ack( + bearer, cause_value)); break; case OGS_GTP_CREATE_BEARER_REQUEST_TYPE: if (cause_value == OGS_GTP_CAUSE_REQUEST_ACCEPTED) { + ogs_assert(OGS_OK == nas_eps_send_activate_dedicated_bearer_context_request( - bearer); + bearer)); } else { - mme_gtp_send_create_bearer_response( - bearer, cause_value); + ogs_assert(OGS_OK == + mme_gtp_send_create_bearer_response( + bearer, cause_value)); } break; case OGS_GTP_UPDATE_BEARER_REQUEST_TYPE: if (cause_value == OGS_GTP_CAUSE_REQUEST_ACCEPTED) { - 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_assert(OGS_OK == + 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)); } else { - mme_gtp_send_update_bearer_response( - bearer, cause_value); + ogs_assert(OGS_OK == + mme_gtp_send_update_bearer_response( + bearer, cause_value)); } break; case OGS_GTP_DELETE_BEARER_REQUEST_TYPE: if (cause_value == OGS_GTP_CAUSE_REQUEST_ACCEPTED) { - nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_deactivate_bearer_context_request(bearer)); } else { - mme_gtp_send_delete_bearer_response( - bearer, cause_value); + ogs_assert(OGS_OK == + mme_gtp_send_delete_bearer_response( + bearer, cause_value)); } break; default: diff --git a/src/mme/mme-s11-handler.c b/src/mme/mme-s11-handler.c index 4a7622a93..91b2d60af 100644 --- a/src/mme/mme-s11-handler.c +++ b/src/mme/mme-s11-handler.c @@ -168,8 +168,9 @@ void mme_s11_handle_create_session_response( if (cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED) { if (sess && SESSION_CONTEXT_IN_ATTACH(sess)) { ogs_error("[%s] Attach reject", mme_ue->imsi_bcd); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_NETWORK_FAILURE, ESM_CAUSE_NETWORK_FAILURE); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_NETWORK_FAILURE, ESM_CAUSE_NETWORK_FAILURE)); } mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -236,16 +237,19 @@ void mme_s11_handle_create_session_response( if (csmap) { ogs_assert(OGS_PDU_SESSION_TYPE_IS_VALID( session->paa.session_type)); - sgsap_send_location_update_request(mme_ue); + ogs_assert(OGS_OK == + sgsap_send_location_update_request(mme_ue)); } else { ogs_assert(OGS_PDU_SESSION_TYPE_IS_VALID( session->paa.session_type)); - nas_eps_send_attach_accept(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_attach_accept(mme_ue)); } } else { ogs_assert(OGS_PDU_SESSION_TYPE_IS_VALID(session->paa.session_type)); - nas_eps_send_activate_default_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_activate_default_bearer_context_request(bearer)); } } @@ -293,11 +297,13 @@ void mme_s11_handle_modify_bearer_response( mme_ue->mme_s11_teid, mme_ue->sgw_s11_teid); GTP_COUNTER_CHECK(mme_ue, GTP_COUNTER_MODIFY_BEARER_BY_PATH_SWITCH, - s1ap_send_path_switch_ack(mme_ue); + ogs_assert(OGS_OK == + s1ap_send_path_switch_ack(mme_ue)); ); GTP_COUNTER_CHECK(mme_ue, GTP_COUNTER_MODIFY_BEARER_BY_E_RAB_MODIFICATION, - s1ap_send_e_rab_modification_confirm(mme_ue); + ogs_assert(OGS_OK == + s1ap_send_e_rab_modification_confirm(mme_ue)); ); } @@ -344,7 +350,8 @@ 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 */ { - nas_eps_send_detach_accept(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_detach_accept(mme_ue)); } } else if (action == @@ -352,7 +359,8 @@ void mme_s11_handle_delete_session_response( mme_bearer_t *bearer = mme_default_bearer_in_sess(sess); ogs_expect_or_return(bearer); - nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_deactivate_bearer_context_request(bearer)); /* * mme_sess_remove() should not be called here. @@ -368,9 +376,10 @@ void mme_s11_handle_delete_session_response( enb_ue = enb_ue_cycle(mme_ue->enb_ue); if (enb_ue) { - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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)); } else ogs_warn("ENB-S1 Context has already been removed"); } @@ -381,9 +390,10 @@ 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"); - nas_eps_send_attach_reject(mme_ue, - EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); } } @@ -524,7 +534,8 @@ void mme_s11_handle_create_bearer_request( if (ECM_IDLE(mme_ue)) { s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); } else { - nas_eps_send_activate_dedicated_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_activate_dedicated_bearer_context_request(bearer)); } } else { /* @@ -629,9 +640,10 @@ void mme_s11_handle_update_bearer_request( if (ECM_IDLE(mme_ue)) { s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); } else { - nas_eps_send_modify_bearer_context_request(bearer, + ogs_assert(OGS_OK == + 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)); } } else { ogs_warn("[IGNORE] Update Bearer Request : " @@ -639,12 +651,14 @@ void mme_s11_handle_update_bearer_request( if (xact->xid & OGS_GTP_CMD_XACT_ID) { /* MME received Bearer Resource Modification Request */ - nas_eps_send_bearer_resource_modification_reject( - mme_ue, sess->pti, ESM_CAUSE_SERVICE_OPTION_NOT_SUPPORTED); + ogs_assert(OGS_OK == + nas_eps_send_bearer_resource_modification_reject( + mme_ue, sess->pti, ESM_CAUSE_SERVICE_OPTION_NOT_SUPPORTED)); } - mme_gtp_send_update_bearer_response( - bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + mme_gtp_send_update_bearer_response( + bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED)); } } @@ -710,7 +724,8 @@ void mme_s11_handle_delete_bearer_request( if (ECM_IDLE(mme_ue)) { s1ap_send_paging(mme_ue, S1AP_CNDomain_ps); } else { - nas_eps_send_deactivate_bearer_context_request(bearer); + ogs_assert(OGS_OK == + nas_eps_send_deactivate_bearer_context_request(bearer)); } } @@ -763,9 +778,10 @@ 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) { - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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)); } else { ogs_warn("ENB-S1 Context has already been removed"); } @@ -805,7 +821,8 @@ void mme_s11_handle_release_access_bearers_response( enb_ue_remove(enb_ue); if (ogs_list_count(&enb->enb_ue_list) == 0) - s1ap_send_s1_reset_ack(enb, NULL); + ogs_assert(OGS_OK == + s1ap_send_s1_reset_ack(enb, NULL)); } else { ogs_warn("ENB-S1 Context has already been removed"); } @@ -964,12 +981,14 @@ void mme_s11_handle_downlink_data_notification( enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue); ogs_assert(enb_ue); - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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)); } else { - mme_gtp_send_downlink_data_notification_ack( - bearer, OGS_GTP_CAUSE_UE_ALREADY_RE_ATTACHED); + ogs_assert(OGS_OK == + mme_gtp_send_downlink_data_notification_ack( + bearer, OGS_GTP_CAUSE_UE_ALREADY_RE_ATTACHED)); } } } @@ -1048,7 +1067,8 @@ void mme_s11_handle_create_indirect_data_forwarding_tunnel_response( source_ue = enb_ue_cycle(mme_ue->enb_ue); ogs_assert(source_ue); - s1ap_send_handover_command(source_ue); + ogs_assert(OGS_OK == + s1ap_send_handover_command(source_ue)); } void mme_s11_handle_delete_indirect_data_forwarding_tunnel_response( @@ -1097,7 +1117,8 @@ 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) { - s1ap_send_handover_cancel_ack(mme_ue->enb_ue); + ogs_assert(OGS_OK == + s1ap_send_handover_cancel_ack(mme_ue->enb_ue)); } else { ogs_fatal("Invalid action = %d", action); ogs_assert_if_reached(); @@ -1139,8 +1160,9 @@ void mme_s11_handle_bearer_resource_failure_indication( ogs_debug(" MME_S11_TEID[%d] SGW_S11_TEID[%d]", mme_ue->mme_s11_teid, mme_ue->sgw_s11_teid); - nas_eps_send_bearer_resource_modification_reject( - mme_ue, sess->pti, esm_cause_from_gtp(cause_value)); + ogs_assert(OGS_OK == + nas_eps_send_bearer_resource_modification_reject( + mme_ue, sess->pti, esm_cause_from_gtp(cause_value))); if (cause_value == OGS_GTP_CAUSE_CONTEXT_NOT_FOUND) { ogs_warn("No Bearer"); diff --git a/src/mme/mme-s6a-handler.c b/src/mme/mme-s6a-handler.c index 311ad9f04..2e65df67e 100644 --- a/src/mme/mme-s6a-handler.c +++ b/src/mme/mme-s6a-handler.c @@ -44,7 +44,8 @@ void mme_s6a_handle_aia(mme_ue_t *mme_ue, if (mme_ue->nas_eps.ksi == OGS_NAS_KSI_NO_KEY_IS_AVAILABLE) mme_ue->nas_eps.ksi = 0; - nas_eps_send_authentication_request(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_authentication_request(mme_ue)); } void mme_s6a_handle_ula(mme_ue_t *mme_ue, diff --git a/src/mme/mme-sm.c b/src/mme/mme-sm.c index 609e5454f..4dc873325 100644 --- a/src/mme/mme-sm.c +++ b/src/mme/mme-sm.c @@ -239,9 +239,10 @@ 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"); - s1ap_send_error_indication( + ogs_assert(OGS_OK == + 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_s1ap_free(&s1ap_message); @@ -330,9 +331,10 @@ 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); - s1ap_send_ue_context_release_command(mme_ue->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_S1_CONTEXT_REMOVE, 0); + S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0)); } mme_ue_associate_enb_ue(mme_ue, enb_ue); } @@ -446,15 +448,17 @@ void mme_state_operational(ogs_fsm_t *s, mme_event_t *e) ogs_info("[%s] Attach reject [EMM_CAUSE:%d]", mme_ue->imsi_bcd, emm_cause); - nas_eps_send_attach_reject(mme_ue, - emm_cause, ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + emm_cause, ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); enb_ue = enb_ue_cycle(mme_ue->enb_ue); ogs_assert(enb_ue); - s1ap_send_ue_context_release_command(enb_ue, + ogs_assert(OGS_OK == + 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_subscription_data_free( &s6a_message->ula_message.subscription_data); @@ -474,13 +478,15 @@ void mme_state_operational(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"); - nas_eps_send_attach_reject(mme_ue, + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); } } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_TAU_REQUEST) { - nas_eps_send_tau_accept(mme_ue, - S1AP_ProcedureCode_id_InitialContextSetup); + ogs_assert(OGS_OK == + nas_eps_send_tau_accept(mme_ue, + S1AP_ProcedureCode_id_InitialContextSetup)); } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_SERVICE_REQUEST) { ogs_error("[%s] Service request", mme_ue->imsi_bcd); } else if (mme_ue->nas_eps.type == diff --git a/src/mme/nas-path.c b/src/mme/nas-path.c index 5c3ba57d9..a43bd82bd 100644 --- a/src/mme/nas-path.c +++ b/src/mme/nas-path.c @@ -57,9 +57,7 @@ int nas_eps_send_emm_to_esm(mme_ue_t *mme_ue, esm_message_container->buffer, esm_message_container->length); rv = s1ap_send_to_esm(mme_ue, esmbuf, 0); - if (rv != OGS_OK) { - ogs_error("s1ap_send_to_esm() failed"); - } + ogs_expect(rv == OGS_OK); return rv; } @@ -77,23 +75,19 @@ int nas_eps_send_to_downlink_nas_transport(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf) ogs_warn("S1 context has already been removed"); ogs_pkbuf_free(pkbuf); + return OGS_ERROR; } else { s1apbuf = s1ap_build_downlink_nas_transport(enb_ue, pkbuf); - if (!s1apbuf) { - ogs_error("s1ap_build_downlink_nas_transport() failed"); - return OGS_ERROR; - } + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); - if (rv != OGS_OK) { - return OGS_ERROR; - } - } + ogs_expect(rv == OGS_OK); - return OGS_OK; + return rv; + } } -void nas_eps_send_attach_accept(mme_ue_t *mme_ue) +int nas_eps_send_attach_accept(mme_ue_t *mme_ue) { int rv; mme_sess_t *sess = NULL; @@ -112,10 +106,10 @@ void nas_eps_send_attach_accept(mme_ue_t *mme_ue) ogs_debug("[%s] Attach accept", mme_ue->imsi_bcd); esmbuf = esm_build_activate_default_bearer_context_request(sess); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); emmbuf = emm_build_attach_accept(mme_ue, esmbuf); - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); CLEAR_MME_UE_TIMER(mme_ue->t3450); mme_ue->t3450.pkbuf = ogs_pkbuf_copy(emmbuf); @@ -124,13 +118,15 @@ void nas_eps_send_attach_accept(mme_ue_t *mme_ue) mme_timer_cfg(MME_TIMER_T3450)->duration); s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, emmbuf); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_attach_reject(mme_ue_t *mme_ue, +int nas_eps_send_attach_reject(mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause, ogs_nas_esm_cause_t esm_cause) { int rv; @@ -145,16 +141,18 @@ void nas_eps_send_attach_reject(mme_ue_t *mme_ue, sess = mme_sess_first(mme_ue); if (sess) { esmbuf = esm_build_pdn_connectivity_reject(sess, esm_cause); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); } emmbuf = emm_build_attach_reject(emm_cause, esmbuf); - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_identity_request(mme_ue_t *mme_ue) +int nas_eps_send_identity_request(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *emmbuf = NULL; @@ -165,10 +163,10 @@ void nas_eps_send_identity_request(mme_ue_t *mme_ue) if (mme_ue->t3470.pkbuf) { emmbuf = mme_ue->t3470.pkbuf; - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_identity_request(mme_ue); - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); } mme_ue->t3470.pkbuf = ogs_pkbuf_copy(emmbuf); @@ -178,9 +176,11 @@ void nas_eps_send_identity_request(mme_ue_t *mme_ue) rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_authentication_request(mme_ue_t *mme_ue) +int nas_eps_send_authentication_request(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *emmbuf = NULL; @@ -191,10 +191,10 @@ void nas_eps_send_authentication_request(mme_ue_t *mme_ue) if (mme_ue->t3460.pkbuf) { emmbuf = mme_ue->t3460.pkbuf; - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_authentication_request(mme_ue); - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); } mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf); @@ -204,9 +204,11 @@ void nas_eps_send_authentication_request(mme_ue_t *mme_ue) rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_security_mode_command(mme_ue_t *mme_ue) +int nas_eps_send_security_mode_command(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *emmbuf = NULL; @@ -217,10 +219,10 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); } else { emmbuf = emm_build_security_mode_command(mme_ue); - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); } mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf); @@ -230,9 +232,11 @@ void nas_eps_send_security_mode_command(mme_ue_t *mme_ue) rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_authentication_reject(mme_ue_t *mme_ue) +int nas_eps_send_authentication_reject(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *emmbuf = NULL; @@ -242,14 +246,18 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_detach_accept(mme_ue_t *mme_ue) +int nas_eps_send_detach_accept(mme_ue_t *mme_ue) { + int rv; + enb_ue_t *enb_ue = NULL; ogs_pkbuf_t *emmbuf = NULL; @@ -261,21 +269,22 @@ void nas_eps_send_detach_accept(mme_ue_t *mme_ue) /* reply with detach accept */ if (mme_ue->nas_eps.detach.switch_off == 0) { - int rv; emmbuf = emm_build_detach_accept(mme_ue); - ogs_expect_or_return(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); } - s1ap_send_ue_context_release_command(enb_ue, + rv = s1ap_send_ue_context_release_command(enb_ue, S1AP_Cause_PR_nas, S1AP_CauseNas_detach, S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0); + ogs_expect(rv == OGS_OK); + + return rv; } - -void nas_eps_send_pdn_connectivity_reject( +int nas_eps_send_pdn_connectivity_reject( mme_sess_t *sess, ogs_nas_esm_cause_t esm_cause) { int rv; @@ -289,18 +298,21 @@ void nas_eps_send_pdn_connectivity_reject( if (SESSION_CONTEXT_IN_ATTACH(sess)) { /* During the UE-attach process, we'll send Attach-Reject * with pyggybacking PDN-connectivity-Reject */ - nas_eps_send_attach_reject(mme_ue, + rv = nas_eps_send_attach_reject(mme_ue, EMM_CAUSE_EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED, esm_cause); + ogs_expect(rv == OGS_OK); } else { esmbuf = esm_build_pdn_connectivity_reject(sess, esm_cause); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); ogs_expect(rv == OGS_OK); } + + return rv; } -void nas_eps_send_esm_information_request(mme_bearer_t *bearer) +int nas_eps_send_esm_information_request(mme_bearer_t *bearer) { int rv; mme_ue_t *mme_ue = NULL; @@ -312,10 +324,10 @@ void nas_eps_send_esm_information_request(mme_bearer_t *bearer) if (bearer->t3489.pkbuf) { esmbuf = bearer->t3489.pkbuf; - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); } else { esmbuf = esm_build_information_request(bearer); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); } bearer->t3489.pkbuf = ogs_pkbuf_copy(esmbuf); @@ -325,9 +337,11 @@ void nas_eps_send_esm_information_request(mme_bearer_t *bearer) rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_activate_default_bearer_context_request(mme_bearer_t *bearer) +int nas_eps_send_activate_default_bearer_context_request(mme_bearer_t *bearer) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -342,16 +356,18 @@ void nas_eps_send_activate_default_bearer_context_request(mme_bearer_t *bearer) ogs_assert(mme_ue); esmbuf = esm_build_activate_default_bearer_context_request(sess); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); s1apbuf = s1ap_build_e_rab_setup_request(bearer, esmbuf); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_activate_dedicated_bearer_context_request( +int nas_eps_send_activate_dedicated_bearer_context_request( mme_bearer_t *bearer) { int rv; @@ -364,13 +380,15 @@ void 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(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); s1apbuf = s1ap_build_e_rab_setup_request(bearer, esmbuf); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } void nas_eps_send_activate_all_dedicated_bearers(mme_bearer_t *default_bearer) @@ -385,7 +403,7 @@ void nas_eps_send_activate_all_dedicated_bearers(mme_bearer_t *default_bearer) } } -void nas_eps_send_modify_bearer_context_request( +int nas_eps_send_modify_bearer_context_request( mme_bearer_t *bearer, int qos_presence, int tft_presence) { int rv; @@ -399,11 +417,11 @@ void nas_eps_send_modify_bearer_context_request( esmbuf = esm_build_modify_bearer_context_request( bearer, qos_presence, tft_presence); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); if (qos_presence == 1) { s1apbuf = s1ap_build_e_rab_modify_request(bearer, esmbuf); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -411,9 +429,11 @@ void nas_eps_send_modify_bearer_context_request( rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); ogs_expect(rv == OGS_OK); } + + return rv; } -void nas_eps_send_deactivate_bearer_context_request(mme_bearer_t *bearer) +int nas_eps_send_deactivate_bearer_context_request(mme_bearer_t *bearer) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -426,17 +446,19 @@ void nas_eps_send_deactivate_bearer_context_request(mme_bearer_t *bearer) esmbuf = esm_build_deactivate_bearer_context_request( bearer, ESM_CAUSE_REGULAR_DEACTIVATION); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); s1apbuf = s1ap_build_e_rab_release_command(bearer, esmbuf, S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_bearer_resource_allocation_reject( +int nas_eps_send_bearer_resource_allocation_reject( mme_ue_t *mme_ue, uint8_t pti, ogs_nas_esm_cause_t esm_cause) { int rv; @@ -447,13 +469,15 @@ void nas_eps_send_bearer_resource_allocation_reject( esmbuf = esm_build_bearer_resource_allocation_reject( mme_ue, pti, esm_cause); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_bearer_resource_modification_reject( +int nas_eps_send_bearer_resource_modification_reject( mme_ue_t *mme_ue, uint8_t pti, ogs_nas_esm_cause_t esm_cause) { int rv; @@ -464,13 +488,15 @@ void nas_eps_send_bearer_resource_modification_reject( esmbuf = esm_build_bearer_resource_modification_reject( mme_ue, pti, esm_cause); - ogs_expect_or_return(esmbuf); + ogs_expect_or_return_val(esmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, esmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_tau_accept( +int nas_eps_send_tau_accept( mme_ue_t *mme_ue, S1AP_ProcedureCode_t procedureCode) { int rv; @@ -481,7 +507,7 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); if (mme_ue->next.m_tmsi) { CLEAR_MME_UE_TIMER(mme_ue->t3450); @@ -494,7 +520,7 @@ void 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(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); @@ -503,9 +529,11 @@ void nas_eps_send_tau_accept( ogs_expect(rv == OGS_OK); } else ogs_assert_if_reached(); + + return rv; } -void nas_eps_send_tau_reject(mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause) +int nas_eps_send_tau_reject(mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause) { int rv; ogs_pkbuf_t *emmbuf = NULL; @@ -516,13 +544,15 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_service_reject(mme_ue_t *mme_ue, +int nas_eps_send_service_reject(mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause) { int rv; @@ -534,13 +564,15 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_cs_service_notification(mme_ue_t *mme_ue) +int nas_eps_send_cs_service_notification(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *emmbuf = NULL; @@ -550,13 +582,15 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void nas_eps_send_downlink_nas_transport( +int nas_eps_send_downlink_nas_transport( mme_ue_t *mme_ue, uint8_t *buffer, uint8_t length) { int rv; @@ -569,8 +603,10 @@ void 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(emmbuf); + ogs_expect_or_return_val(emmbuf, OGS_ERROR); rv = nas_eps_send_to_downlink_nas_transport(mme_ue, emmbuf); ogs_expect(rv == OGS_OK); + + return rv; } diff --git a/src/mme/nas-path.h b/src/mme/nas-path.h index 80d7cb3c3..ca53b689a 100644 --- a/src/mme/nas-path.h +++ b/src/mme/nas-path.h @@ -32,47 +32,47 @@ int nas_eps_send_emm_to_esm( int nas_eps_send_to_downlink_nas_transport( mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf); -void nas_eps_send_attach_accept(mme_ue_t *mme_ue); -void nas_eps_send_attach_reject(mme_ue_t *mme_ue, +int nas_eps_send_attach_accept(mme_ue_t *mme_ue); +int nas_eps_send_attach_reject(mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause, ogs_nas_esm_cause_t esm_cause); -void nas_eps_send_identity_request(mme_ue_t *mme_ue); +int nas_eps_send_identity_request(mme_ue_t *mme_ue); -void nas_eps_send_authentication_request(mme_ue_t *mme_ue); -void nas_eps_send_authentication_reject(mme_ue_t *mme_ue); +int nas_eps_send_authentication_request(mme_ue_t *mme_ue); +int nas_eps_send_authentication_reject(mme_ue_t *mme_ue); -void nas_eps_send_security_mode_command(mme_ue_t *mme_ue); +int nas_eps_send_security_mode_command(mme_ue_t *mme_ue); -void nas_eps_send_detach_accept(mme_ue_t *mme_ue); +int nas_eps_send_detach_accept(mme_ue_t *mme_ue); -void nas_eps_send_pdn_connectivity_reject( +int nas_eps_send_pdn_connectivity_reject( mme_sess_t *sess, ogs_nas_esm_cause_t esm_cause); -void nas_eps_send_esm_information_request(mme_bearer_t *bearer); -void nas_eps_send_activate_default_bearer_context_request(mme_bearer_t *bearer); -void nas_eps_send_activate_dedicated_bearer_context_request( +int nas_eps_send_esm_information_request(mme_bearer_t *bearer); +int nas_eps_send_activate_default_bearer_context_request(mme_bearer_t *bearer); +int nas_eps_send_activate_dedicated_bearer_context_request( mme_bearer_t *bearer); void nas_eps_send_activate_all_dedicated_bearers(mme_bearer_t *default_bearer); -void nas_eps_send_modify_bearer_context_request( +int nas_eps_send_modify_bearer_context_request( mme_bearer_t *bearer, int qos_presence, int tft_presence); -void nas_eps_send_deactivate_bearer_context_request(mme_bearer_t *bearer); -void nas_eps_send_bearer_resource_allocation_reject( +int nas_eps_send_deactivate_bearer_context_request(mme_bearer_t *bearer); +int nas_eps_send_bearer_resource_allocation_reject( mme_ue_t *mme_ue, uint8_t pti, ogs_nas_esm_cause_t esm_cause); -void nas_eps_send_bearer_resource_modification_reject( +int nas_eps_send_bearer_resource_modification_reject( mme_ue_t *mme_ue, uint8_t pti, ogs_nas_esm_cause_t esm_cause); -void nas_eps_send_tau_accept( +int nas_eps_send_tau_accept( mme_ue_t *mme_ue, S1AP_ProcedureCode_t procedureCode); -void nas_eps_send_tau_reject(mme_ue_t *mme_ue, ogs_nas_esm_cause_t emm_cause); +int nas_eps_send_tau_reject(mme_ue_t *mme_ue, ogs_nas_esm_cause_t emm_cause); -void nas_eps_send_service_reject( +int nas_eps_send_service_reject( mme_ue_t *mme_ue, ogs_nas_emm_cause_t emm_cause); -void nas_eps_send_cs_service_notification(mme_ue_t *mme_ue); -void nas_eps_send_downlink_nas_transport( +int nas_eps_send_cs_service_notification(mme_ue_t *mme_ue); +int nas_eps_send_downlink_nas_transport( mme_ue_t *mme_ue, uint8_t *buffer, uint8_t length); #ifdef __cplusplus } #endif -#endif /* NAS_EPS_PATH_H */ +#endif /* NAS_EPS_PATH_H */ \ No newline at end of file diff --git a/src/mme/s1ap-handler.c b/src/mme/s1ap-handler.c index 4ee3a37b7..7e6d57199 100644 --- a/src/mme/s1ap-handler.c +++ b/src/mme/s1ap-handler.c @@ -162,7 +162,7 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) group = S1AP_Cause_PR_misc; cause = S1AP_CauseMisc_unspecified; - s1ap_send_s1_setup_failure(enb, group, cause); + ogs_assert(OGS_OK == s1ap_send_s1_setup_failure(enb, group, cause)); return; } @@ -172,7 +172,7 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) group = S1AP_Cause_PR_misc; cause = S1AP_CauseMisc_unspecified; - s1ap_send_s1_setup_failure(enb, group, cause); + ogs_assert(OGS_OK == s1ap_send_s1_setup_failure(enb, group, cause)); return; } @@ -182,12 +182,12 @@ 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; - s1ap_send_s1_setup_failure(enb, group, cause); + ogs_assert(OGS_OK == s1ap_send_s1_setup_failure(enb, group, cause)); return; } enb->state.s1_setup_success = true; - s1ap_send_s1_setup_response(enb); + ogs_assert(OGS_OK == s1ap_send_s1_setup_response(enb)); } void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) @@ -250,8 +250,9 @@ 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"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } enb_ue = enb_ue_find_by_enb_ue_s1ap_id(enb, *ENB_UE_S1AP_ID); @@ -305,9 +306,10 @@ 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); - s1ap_send_ue_context_release_command(mme_ue->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_S1_CONTEXT_REMOVE, 0); + S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0)); } mme_ue_associate_enb_ue(mme_ue, enb_ue); } @@ -316,22 +318,25 @@ void s1ap_handle_initial_ue_message(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!NAS_PDU) { ogs_error("No NAS_PDU"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } if (!TAI) { ogs_error("No TAI"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -424,8 +429,9 @@ void s1ap_handle_uplink_nas_transport( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -433,16 +439,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -451,22 +459,25 @@ void s1ap_handle_uplink_nas_transport( if (!NAS_PDU) { ogs_error("No NAS_PDU"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!TAI) { ogs_error("No TAI"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -559,8 +570,9 @@ void s1ap_handle_ue_capability_info_indication( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -568,16 +580,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -644,8 +658,9 @@ void s1ap_handle_initial_context_setup_response( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -653,16 +668,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -683,25 +700,28 @@ void s1ap_handle_initial_context_setup_response( E_RABSetupListCtxtSURes->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABSetupItemCtxtSUResIEs_t"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } e_rab = &item->value.choice.E_RABSetupItemCtxtSURes; if (!e_rab) { ogs_error("No E_RABSetupItemCtxtSURes"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication2(mme_ue, + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); return; } @@ -722,7 +742,8 @@ void s1ap_handle_initial_context_setup_response( ogs_debug(" ### ULI PRESENT ###"); uli_presence = 1; } - mme_gtp_send_modify_bearer_request(bearer, uli_presence); + ogs_assert(OGS_OK == + mme_gtp_send_modify_bearer_request(bearer, uli_presence)); } } } @@ -731,7 +752,8 @@ void s1ap_handle_initial_context_setup_response( mme_send_after_paging(mme_ue, OGS_GTP_CAUSE_REQUEST_ACCEPTED); if (SMS_SERVICE_INDICATOR(mme_ue)) { - sgsap_send_service_request(mme_ue, SGSAP_EMM_CONNECTED_MODE); + ogs_assert(OGS_OK == + sgsap_send_service_request(mme_ue, SGSAP_EMM_CONNECTED_MODE)); } CLEAR_SERVICE_INDICATOR(mme_ue); @@ -788,8 +810,9 @@ void s1ap_handle_initial_context_setup_failure( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -797,16 +820,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -815,8 +840,9 @@ void s1ap_handle_initial_context_setup_failure( if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -889,8 +915,9 @@ void s1ap_handle_ue_context_modification_response( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -898,16 +925,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -971,8 +1000,9 @@ void s1ap_handle_ue_context_modification_failure( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -980,16 +1010,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -998,8 +1030,9 @@ void s1ap_handle_ue_context_modification_failure( if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1064,8 +1097,9 @@ void s1ap_handle_e_rab_setup_response( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -1073,16 +1107,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1091,8 +1127,9 @@ void s1ap_handle_e_rab_setup_response( if (!E_RABSetupListBearerSURes) { ogs_error("No E_RABSetupListBearerSURes"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1109,25 +1146,28 @@ void s1ap_handle_e_rab_setup_response( E_RABSetupListBearerSURes->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABSetupItemBearerSUResIEs_t"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } e_rab = &item->value.choice.E_RABSetupItemBearerSURes; if (!e_rab) { ogs_error("No E_RABSetupItemBearerSURes"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication2(mme_ue, + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); return; } @@ -1146,10 +1186,12 @@ void s1ap_handle_e_rab_setup_response( ogs_debug(" Linked-EBI[%d]", linked_bearer->ebi); if (bearer->ebi == linked_bearer->ebi) { - mme_gtp_send_modify_bearer_request(bearer, 0); + ogs_assert(OGS_OK == + mme_gtp_send_modify_bearer_request(bearer, 0)); } else { - mme_gtp_send_create_bearer_response( - bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + mme_gtp_send_create_bearer_response( + bearer, OGS_GTP_CAUSE_REQUEST_ACCEPTED)); } } } @@ -1205,18 +1247,20 @@ void s1ap_handle_ue_context_release_request( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication(enb, + ogs_assert(OGS_OK == + 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)); return; } @@ -1225,8 +1269,9 @@ void s1ap_handle_ue_context_release_request( if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1296,18 +1341,20 @@ void s1ap_handle_ue_context_release_complete( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication(enb, + ogs_assert(OGS_OK == + 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)); return; } @@ -1358,8 +1405,9 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) ogs_expect_or_return(mme_ue); if (mme_ue_have_indirect_tunnel(mme_ue) == true) { - mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( - mme_ue, OGS_GTP_DELETE_INDIRECT_HANDOVER_COMPLETE); + ogs_assert(OGS_OK == + mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( + mme_ue, OGS_GTP_DELETE_INDIRECT_HANDOVER_COMPLETE)); } else { ogs_warn("Check your eNodeB"); ogs_warn(" No INDIRECT TUNNEL"); @@ -1375,8 +1423,9 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) ogs_expect_or_return(mme_ue); if (mme_ue_have_indirect_tunnel(mme_ue) == true) { - mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( - mme_ue, OGS_GTP_DELETE_INDIRECT_HANDOVER_CANCEL); + ogs_assert(OGS_OK == + mme_gtp_send_delete_indirect_data_forwarding_tunnel_request( + mme_ue, OGS_GTP_DELETE_INDIRECT_HANDOVER_CANCEL)); } else { ogs_warn("Check your eNodeB"); ogs_warn(" No INDIRECT TUNNEL"); @@ -1384,7 +1433,8 @@ void s1ap_handle_ue_context_release_action(enb_ue_t *enb_ue) mme_ue_clear_indirect_tunnel(mme_ue); ogs_expect_or_return(mme_ue->enb_ue); - s1ap_send_handover_cancel_ack(mme_ue->enb_ue); + ogs_assert(OGS_OK == + s1ap_send_handover_cancel_ack(mme_ue->enb_ue)); } break; case S1AP_UE_CTX_REL_S1_HANDOVER_FAILURE: @@ -1466,25 +1516,28 @@ void s1ap_handle_e_rab_modification_indication( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication(enb, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1493,8 +1546,9 @@ void s1ap_handle_e_rab_modification_indication( if (!E_RABToBeModifiedListBearerModInd) { ogs_error("No E_RABToBeModifiedListBearerModInd"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1511,25 +1565,28 @@ void s1ap_handle_e_rab_modification_indication( E_RABToBeModifiedListBearerModInd->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABToBeModifiedItemBearerModIndIEs_t"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } e_rab = &item->value.choice.E_RABToBeModifiedItemBearerModInd; if (!e_rab) { ogs_error("No E_RABToBeModifiedItemBearerModInd"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication2(mme_ue, + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); return; } @@ -1543,7 +1600,8 @@ void s1ap_handle_e_rab_modification_indication( GTP_COUNTER_INCREMENT( mme_ue, GTP_COUNTER_MODIFY_BEARER_BY_E_RAB_MODIFICATION); - mme_gtp_send_modify_bearer_request(bearer, 0); + ogs_assert(OGS_OK == + mme_gtp_send_modify_bearer_request(bearer, 0)); } } @@ -1620,14 +1678,16 @@ void s1ap_handle_path_switch_request( if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID); @@ -1652,8 +1712,9 @@ void s1ap_handle_path_switch_request( if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1664,8 +1725,9 @@ void s1ap_handle_path_switch_request( if (!TAI) { ogs_error("No TAI"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1676,8 +1738,9 @@ void s1ap_handle_path_switch_request( if (!E_RABToBeSwitchedDLList) { ogs_error("No E_RABToBeSwitchedDLList"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1766,25 +1829,28 @@ void s1ap_handle_path_switch_request( E_RABToBeSwitchedDLList->list.array[i]; if (!item) { ogs_error("No S1AP_E_RABToBeSwitchedDLItemIEs_t"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } e_rab = &item->value.choice.E_RABToBeSwitchedDLItem; if (!e_rab) { ogs_error("No E_RABToBeSwitchedDLItem"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication2(mme_ue, + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); return; } @@ -1798,7 +1864,8 @@ void s1ap_handle_path_switch_request( GTP_COUNTER_INCREMENT( mme_ue, GTP_COUNTER_MODIFY_BEARER_BY_PATH_SWITCH); - mme_gtp_send_modify_bearer_request(bearer, 1); + ogs_assert(OGS_OK == + mme_gtp_send_modify_bearer_request(bearer, 1)); } } @@ -1879,14 +1946,16 @@ 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); - s1ap_send_error_indication(enb, NULL, NULL, + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, NULL, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_targetID); + S1AP_CauseRadioNetwork_unknown_targetID)); return; } - s1ap_send_mme_configuration_transfer( - target_enb, SONConfigurationTransfer); + ogs_assert(OGS_OK == + s1ap_send_mme_configuration_transfer( + target_enb, SONConfigurationTransfer)); } } @@ -1954,8 +2023,9 @@ 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"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -1963,16 +2033,18 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -1981,29 +2053,33 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) if (!HandoverType) { ogs_error("No HandoverType"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!TargetID) { ogs_error("No TargetID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!Source_ToTarget_TransparentContainer) { ogs_error("No Source_ToTarget_TransparentContainer"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2015,8 +2091,9 @@ void s1ap_handle_handover_required(mme_enb_t *enb, ogs_s1ap_message_t *message) break; default: ogs_error("Not implemented(%d)", TargetID->present); - s1ap_send_handover_preparation_failure(source_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_handover_preparation_failure(source_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2024,9 +2101,10 @@ 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); - s1ap_send_handover_preparation_failure(source_ue, + ogs_assert(OGS_OK == + s1ap_send_handover_preparation_failure(source_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_targetID); + S1AP_CauseRadioNetwork_unknown_targetID)); return; } @@ -2039,14 +2117,16 @@ 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); } else { - s1ap_send_handover_preparation_failure(source_ue, - S1AP_Cause_PR_nas, S1AP_CauseNas_authentication_failure); + ogs_assert(OGS_OK == + s1ap_send_handover_preparation_failure(source_ue, + S1AP_Cause_PR_nas, S1AP_CauseNas_authentication_failure)); return; } - s1ap_send_handover_request( + ogs_assert(OGS_OK == + s1ap_send_handover_request( source_ue, target_enb, HandoverType, Cause, - Source_ToTarget_TransparentContainer); + Source_ToTarget_TransparentContainer)); } void s1ap_handle_handover_request_ack( @@ -2107,8 +2187,9 @@ void s1ap_handle_handover_request_ack( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2116,38 +2197,43 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!E_RABAdmittedList) { ogs_error("No E_RABAdmittedList"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!Target_ToSource_TransparentContainer) { ogs_error("No Target_ToSource_TransparentContainer"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } source_ue = target_ue->source_ue; if (!source_ue) { ogs_error("No Source UE"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2170,25 +2256,28 @@ 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"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } e_rab = &item->value.choice.E_RABAdmittedItem; if (!e_rab) { ogs_error("No E_RABAdmittedItem"); - s1ap_send_error_indication2(mme_ue, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_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); - s1ap_send_error_indication2(mme_ue, + ogs_assert(OGS_OK == + s1ap_send_error_indication2(mme_ue, S1AP_Cause_PR_radioNetwork, - S1AP_CauseRadioNetwork_unknown_E_RAB_ID); + S1AP_CauseRadioNetwork_unknown_E_RAB_ID)); return; } @@ -2226,9 +2315,12 @@ void s1ap_handle_handover_request_ack( Target_ToSource_TransparentContainer); if (mme_ue_have_indirect_tunnel(mme_ue) == true) { - mme_gtp_send_create_indirect_data_forwarding_tunnel_request(mme_ue); + ogs_assert(OGS_OK == + mme_gtp_send_create_indirect_data_forwarding_tunnel_request(mme_ue)\ + ); } else { - s1ap_send_handover_command(source_ue); + ogs_assert(OGS_OK == + s1ap_send_handover_command(source_ue)); } } @@ -2276,8 +2368,9 @@ 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"); - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2285,24 +2378,27 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } source_ue = target_ue->source_ue; if (!source_ue) { ogs_error("No Source UE"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2311,13 +2407,15 @@ 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); - s1ap_send_handover_preparation_failure( - source_ue, Cause->present, Cause->choice.radioNetwork); + ogs_assert(OGS_OK == + s1ap_send_handover_preparation_failure( + source_ue, Cause->present, Cause->choice.radioNetwork)); - s1ap_send_ue_context_release_command( + ogs_assert(OGS_OK == + 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)); } void s1ap_handle_handover_cancel(mme_enb_t *enb, ogs_s1ap_message_t *message) @@ -2368,8 +2466,9 @@ 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"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2377,31 +2476,35 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } target_ue = source_ue->target_ue; if (!target_ue) { ogs_error("No Target UE"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2410,10 +2513,11 @@ 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); - s1ap_send_ue_context_release_command( + ogs_assert(OGS_OK == + 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_debug("Handover Cancel : UE[eNB-UE-S1AP-ID(%d)] --> eNB[%s:%d]", source_ue->enb_ue_s1ap_id, @@ -2469,8 +2573,9 @@ void s1ap_handle_enb_status_transfer( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2478,31 +2583,35 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!ENB_StatusTransfer_TransparentContainer) { ogs_error("No ENB_StatusTransfer_TransparentContainer"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } target_ue = source_ue->target_ue; if (!target_ue) { ogs_error("No Target UE"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2511,8 +2620,9 @@ 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); - s1ap_send_mme_status_transfer(target_ue, - ENB_StatusTransfer_TransparentContainer); + ogs_assert(OGS_OK == + s1ap_send_mme_status_transfer(target_ue, + ENB_StatusTransfer_TransparentContainer)); } void s1ap_handle_handover_notification( @@ -2574,8 +2684,9 @@ void s1ap_handle_handover_notification( if (!MME_UE_S1AP_ID) { ogs_error("No MME_UE_S1AP_ID"); - s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, ENB_UE_S1AP_ID, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2583,23 +2694,26 @@ 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); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL, + ogs_assert(OGS_OK == + 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)); return; } if (!ENB_UE_S1AP_ID) { ogs_error("No ENB_UE_S1AP_ID"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } if (!EUTRAN_CGI) { ogs_error("No EUTRAN_CGI"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2610,8 +2724,9 @@ void s1ap_handle_handover_notification( if (!TAI) { ogs_error("No TAI"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2623,8 +2738,9 @@ void s1ap_handle_handover_notification( source_ue = target_ue->source_ue; if (!source_ue) { ogs_error("No Source UE"); - s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + 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)); return; } @@ -2669,11 +2785,12 @@ void s1ap_handle_handover_notification( memcpy(&mme_ue->tai, &target_ue->saved.tai, sizeof(ogs_eps_tai_t)); memcpy(&mme_ue->e_cgi, &target_ue->saved.e_cgi, sizeof(ogs_e_cgi_t)); - s1ap_send_ue_context_release_command(source_ue, + ogs_assert(OGS_OK == + 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_list_for_each(&mme_ue->sess_list, sess) { ogs_list_for_each(&sess->bearer_list, bearer) { @@ -2681,7 +2798,8 @@ void s1ap_handle_handover_notification( memcpy(&bearer->enb_s1u_ip, &bearer->target_s1u_ip, sizeof(ogs_ip_t)); - mme_gtp_send_modify_bearer_request(bearer, 1); + ogs_assert(OGS_OK == + mme_gtp_send_modify_bearer_request(bearer, 1)); } } } @@ -2732,8 +2850,9 @@ void s1ap_handle_s1_reset( if (!Cause) { ogs_error("No Cause"); - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2742,8 +2861,9 @@ void s1ap_handle_s1_reset( if (!ResetType) { ogs_error("No ResetType"); - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2768,7 +2888,8 @@ void s1ap_handle_s1_reset( * the MME shall respond with the RESET ACKNOWLEDGE message. */ if (ogs_list_count(&enb->enb_ue_list) == 0) - s1ap_send_s1_reset_ack(enb, NULL); + ogs_assert(OGS_OK == + s1ap_send_s1_reset_ack(enb, NULL)); break; @@ -2788,16 +2909,18 @@ void s1ap_handle_s1_reset( partOfS1_Interface->list.array[i]; if (!ie2) { ogs_error("No S1AP_UE_associatedLogicalS1_ConnectionItemRes_t"); - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } item = &ie2->value.choice.UE_associatedLogicalS1_ConnectionItem; if (!item) { ogs_error("No UE_associatedLogicalS1_ConnectionItem"); - s1ap_send_error_indication(enb, NULL, NULL, - S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error); + ogs_assert(OGS_OK == + s1ap_send_error_indication(enb, NULL, NULL, + S1AP_Cause_PR_protocol, S1AP_CauseProtocol_semantic_error)); return; } @@ -2824,8 +2947,9 @@ void s1ap_handle_s1_reset( mme_ue = enb_ue->mme_ue; if (mme_ue) { - mme_gtp_send_release_access_bearers_request( - mme_ue, OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_PARTIAL); + ogs_assert(OGS_OK == + mme_gtp_send_release_access_bearers_request(mme_ue, + OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_PARTIAL)); } else { enb_ue_remove(enb_ue); } diff --git a/src/mme/s1ap-path.c b/src/mme/s1ap-path.c index de6b08563..e80cfc7af 100644 --- a/src/mme/s1ap-path.c +++ b/src/mme/s1ap-path.c @@ -240,32 +240,38 @@ int s1ap_send_to_nas(enb_ue_t *enb_ue, } } -void s1ap_send_s1_setup_response(mme_enb_t *enb) +int s1ap_send_s1_setup_response(mme_enb_t *enb) { + int rv; ogs_pkbuf_t *s1ap_buffer; ogs_debug("[MME] S1-Setup response"); s1ap_buffer = s1ap_build_setup_rsp(); - ogs_expect_or_return(s1ap_buffer); + ogs_expect_or_return_val(s1ap_buffer, OGS_ERROR); - ogs_expect(OGS_OK == - s1ap_send_to_enb(enb, s1ap_buffer, S1AP_NON_UE_SIGNALLING)); + rv = s1ap_send_to_enb(enb, s1ap_buffer, S1AP_NON_UE_SIGNALLING); + ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_s1_setup_failure( +int s1ap_send_s1_setup_failure( mme_enb_t *enb, S1AP_Cause_PR group, long cause) { + int rv; ogs_pkbuf_t *s1ap_buffer; ogs_debug("[MME] S1-Setup failure"); s1ap_buffer = s1ap_build_setup_failure(group, cause, S1AP_TimeToWait_v10s); - ogs_expect_or_return(s1ap_buffer); + ogs_expect_or_return_val(s1ap_buffer, OGS_ERROR); - ogs_expect(OGS_OK == - s1ap_send_to_enb(enb, s1ap_buffer, S1AP_NON_UE_SIGNALLING)); + rv = s1ap_send_to_enb(enb, s1ap_buffer, S1AP_NON_UE_SIGNALLING); + ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_initial_context_setup_request(mme_ue_t *mme_ue) +int s1ap_send_initial_context_setup_request(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -273,13 +279,15 @@ void s1ap_send_initial_context_setup_request(mme_ue_t *mme_ue) ogs_assert(mme_ue); s1apbuf = s1ap_build_initial_context_setup_request(mme_ue, NULL); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_ue_context_modification_request(mme_ue_t *mme_ue) +int s1ap_send_ue_context_modification_request(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -287,13 +295,15 @@ void s1ap_send_ue_context_modification_request(mme_ue_t *mme_ue) ogs_assert(mme_ue); s1apbuf = s1ap_build_ue_context_modification_request(mme_ue); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_ue_context_release_command( +int s1ap_send_ue_context_release_command( enb_ue_t *enb_ue, S1AP_Cause_PR group, long cause, uint8_t action, ogs_time_t duration) { @@ -313,13 +323,15 @@ void 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(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_delayed_send_to_enb_ue(enb_ue, s1apbuf, duration); ogs_expect(rv == OGS_OK); ogs_timer_start(enb_ue->t_s1_holding, mme_timer_cfg(MME_TIMER_S1_HOLDING)->duration); + + return rv; } void s1ap_send_paging(mme_ue_t *mme_ue, S1AP_CNDomain_t cn_domain) @@ -357,7 +369,7 @@ void s1ap_send_paging(mme_ue_t *mme_ue, S1AP_CNDomain_t cn_domain) mme_timer_cfg(MME_TIMER_T3413)->duration); } -void s1ap_send_mme_configuration_transfer( +int s1ap_send_mme_configuration_transfer( mme_enb_t *target_enb, S1AP_SONConfigurationTransfer_t *SONConfigurationTransfer) { @@ -368,13 +380,15 @@ void s1ap_send_mme_configuration_transfer( ogs_assert(SONConfigurationTransfer); s1apbuf = s1ap_build_mme_configuration_transfer(SONConfigurationTransfer); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb(target_enb, s1apbuf, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_e_rab_modification_confirm(mme_ue_t *mme_ue) +int s1ap_send_e_rab_modification_confirm(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -382,13 +396,15 @@ void s1ap_send_e_rab_modification_confirm(mme_ue_t *mme_ue) ogs_assert(mme_ue); s1apbuf = s1ap_build_e_rab_modification_confirm(mme_ue); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_path_switch_ack(mme_ue_t *mme_ue) +int s1ap_send_path_switch_ack(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -396,13 +412,15 @@ void s1ap_send_path_switch_ack(mme_ue_t *mme_ue) ogs_assert(mme_ue); s1apbuf = s1ap_build_path_switch_ack(mme_ue); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = nas_eps_send_to_enb(mme_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_handover_command(enb_ue_t *source_ue) +int s1ap_send_handover_command(enb_ue_t *source_ue) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -410,13 +428,15 @@ void s1ap_send_handover_command(enb_ue_t *source_ue) ogs_assert(source_ue); s1apbuf = s1ap_build_handover_command(source_ue); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb_ue(source_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_handover_preparation_failure( +int s1ap_send_handover_preparation_failure( enb_ue_t *source_ue, S1AP_Cause_PR group, long cause) { int rv; @@ -426,13 +446,15 @@ void s1ap_send_handover_preparation_failure( ogs_assert(group); s1apbuf = s1ap_build_handover_preparation_failure(source_ue, group, cause); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb_ue(source_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_handover_cancel_ack(enb_ue_t *source_ue) +int s1ap_send_handover_cancel_ack(enb_ue_t *source_ue) { int rv; ogs_pkbuf_t *s1apbuf = NULL; @@ -440,14 +462,16 @@ void s1ap_send_handover_cancel_ack(enb_ue_t *source_ue) ogs_assert(source_ue); s1apbuf = s1ap_build_handover_cancel_ack(source_ue); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb_ue(source_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_handover_request( +int s1ap_send_handover_request( enb_ue_t *source_ue, mme_enb_t *target_enb, S1AP_HandoverType_t *handovertype, S1AP_Cause_t *cause, S1AP_Source_ToTarget_TransparentContainer_t @@ -477,13 +501,15 @@ void s1ap_send_handover_request( s1apbuf = s1ap_build_handover_request( target_ue, handovertype, cause, source_totarget_transparentContainer); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb_ue(target_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_mme_status_transfer( +int s1ap_send_mme_status_transfer( enb_ue_t *target_ue, S1AP_ENB_StatusTransfer_TransparentContainer_t *enb_statustransfer_transparentContainer) @@ -495,13 +521,15 @@ void s1ap_send_mme_status_transfer( s1apbuf = s1ap_build_mme_status_transfer(target_ue, enb_statustransfer_transparentContainer); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb_ue(target_ue, s1apbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_error_indication( +int s1ap_send_error_indication( mme_enb_t *enb, S1AP_MME_UE_S1AP_ID_t *mme_ue_s1ap_id, S1AP_ENB_UE_S1AP_ID_t *enb_ue_s1ap_id, @@ -514,15 +542,18 @@ void s1ap_send_error_indication( s1apbuf = ogs_s1ap_build_error_indication( mme_ue_s1ap_id, enb_ue_s1ap_id, group, cause); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_error_indication2( +int s1ap_send_error_indication2( mme_ue_t *mme_ue, S1AP_Cause_PR group, long cause) { + int rv; mme_enb_t *enb; enb_ue_t *enb_ue; @@ -531,18 +562,21 @@ void s1ap_send_error_indication2( ogs_assert(mme_ue); enb_ue = enb_ue_cycle(mme_ue->enb_ue); - ogs_expect_or_return(enb_ue); + ogs_expect_or_return_val(enb_ue, OGS_ERROR); enb = enb_ue->enb; - ogs_expect_or_return(enb); + ogs_expect_or_return_val(enb, OGS_ERROR); mme_ue_s1ap_id = enb_ue->mme_ue_s1ap_id, enb_ue_s1ap_id = enb_ue->enb_ue_s1ap_id, - s1ap_send_error_indication( + rv = s1ap_send_error_indication( enb, &mme_ue_s1ap_id, &enb_ue_s1ap_id, group, cause); + ogs_expect(rv == OGS_OK); + + return rv; } -void s1ap_send_s1_reset_ack( +int s1ap_send_s1_reset_ack( mme_enb_t *enb, S1AP_UE_associatedLogicalS1_ConnectionListRes_t *partOfS1_Interface) { @@ -552,8 +586,10 @@ void s1ap_send_s1_reset_ack( ogs_assert(enb); s1apbuf = ogs_s1ap_build_s1_reset_ack(partOfS1_Interface); - ogs_expect_or_return(s1apbuf); + ogs_expect_or_return_val(s1apbuf, OGS_ERROR); rv = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING); ogs_expect(rv == OGS_OK); -} + + return rv; +} \ No newline at end of file diff --git a/src/mme/s1ap-path.h b/src/mme/s1ap-path.h index 7bc886d18..bf3e19566 100644 --- a/src/mme/s1ap-path.h +++ b/src/mme/s1ap-path.h @@ -46,50 +46,50 @@ int s1ap_send_to_nas(enb_ue_t *enb_ue, S1AP_ProcedureCode_t procedureCode, S1AP_NAS_PDU_t *nasPdu); int s1ap_send_to_esm(mme_ue_t *mme_ue, ogs_pkbuf_t *esmbuf, uint8_t nas_type); -void s1ap_send_s1_setup_response(mme_enb_t *enb); -void s1ap_send_s1_setup_failure( +int s1ap_send_s1_setup_response(mme_enb_t *enb); +int s1ap_send_s1_setup_failure( mme_enb_t *enb, S1AP_Cause_PR group, long cause); -void s1ap_send_initial_context_setup_request(mme_ue_t *mme_ue); -void s1ap_send_ue_context_modification_request(mme_ue_t *mme_ue); -void s1ap_send_ue_context_release_command( +int s1ap_send_initial_context_setup_request(mme_ue_t *mme_ue); +int s1ap_send_ue_context_modification_request(mme_ue_t *mme_ue); +int s1ap_send_ue_context_release_command( enb_ue_t *enb_ue, S1AP_Cause_PR group, long cause, uint8_t action, ogs_time_t duration); void s1ap_send_paging(mme_ue_t *mme_ue, S1AP_CNDomain_t cn_domain); -void s1ap_send_mme_configuration_transfer( +int s1ap_send_mme_configuration_transfer( mme_enb_t *target_enb, S1AP_SONConfigurationTransfer_t *SONConfigurationTransfer); -void s1ap_send_e_rab_modification_confirm(mme_ue_t *mme_ue); +int s1ap_send_e_rab_modification_confirm(mme_ue_t *mme_ue); -void s1ap_send_path_switch_ack(mme_ue_t *mme_ue); +int s1ap_send_path_switch_ack(mme_ue_t *mme_ue); -void s1ap_send_handover_command(enb_ue_t *source_ue); -void s1ap_send_handover_preparation_failure( +int s1ap_send_handover_command(enb_ue_t *source_ue); +int s1ap_send_handover_preparation_failure( enb_ue_t *source_ue, S1AP_Cause_PR group, long cause); -void s1ap_send_handover_request( +int s1ap_send_handover_request( enb_ue_t *source_ue, mme_enb_t *target_enb, S1AP_HandoverType_t *handovertype, S1AP_Cause_t *cause, S1AP_Source_ToTarget_TransparentContainer_t *source_totarget_transparentContainer); -void s1ap_send_handover_cancel_ack(enb_ue_t *source_ue); +int s1ap_send_handover_cancel_ack(enb_ue_t *source_ue); -void s1ap_send_mme_status_transfer( +int s1ap_send_mme_status_transfer( enb_ue_t *target_ue, S1AP_ENB_StatusTransfer_TransparentContainer_t *enb_statustransfer_transparentContainer); -void s1ap_send_error_indication( +int s1ap_send_error_indication( mme_enb_t *enb, S1AP_MME_UE_S1AP_ID_t *mme_ue_s1ap_id, S1AP_ENB_UE_S1AP_ID_t *enb_ue_s1ap_id, S1AP_Cause_PR group, long cause); -void s1ap_send_error_indication2( +int s1ap_send_error_indication2( mme_ue_t *mme_ue, S1AP_Cause_PR group, long cause); -void s1ap_send_s1_reset_ack( +int s1ap_send_s1_reset_ack( mme_enb_t *enb, S1AP_UE_associatedLogicalS1_ConnectionListRes_t *partOfS1_Interface); diff --git a/src/mme/sgsap-handler.c b/src/mme/sgsap-handler.c index 7887b9fa5..d0e96107a 100644 --- a/src/mme/sgsap-handler.c +++ b/src/mme/sgsap-handler.c @@ -105,14 +105,16 @@ void sgsap_handle_location_update_accept(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) ogs_debug(" P-TMSI[0x%08x]", mme_ue->p_tmsi); } - nas_eps_send_attach_accept(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_attach_accept(mme_ue)); return; error: - nas_eps_send_attach_reject(mme_ue, + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, EMM_CAUSE_EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED, - ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); mme_send_delete_session_or_mme_ue_context_release(mme_ue); } @@ -181,8 +183,9 @@ void sgsap_handle_location_update_reject(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) ogs_plmn_id_hexdump(&lai->nas_plmn_id), lai->lac); } - nas_eps_send_attach_reject(mme_ue, - emm_cause, ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED); + ogs_assert(OGS_OK == + nas_eps_send_attach_reject(mme_ue, + emm_cause, ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED)); mme_send_delete_session_or_mme_ue_context_release(mme_ue); return; @@ -337,9 +340,12 @@ void sgsap_handle_paging_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) } else { if (CS_CALL_SERVICE_INDICATOR(mme_ue)) { - nas_eps_send_cs_service_notification(mme_ue); + ogs_assert(OGS_OK == + nas_eps_send_cs_service_notification(mme_ue)); } else if (SMS_SERVICE_INDICATOR(mme_ue)) { - sgsap_send_service_request(mme_ue, SGSAP_EMM_CONNECTED_MODE); + ogs_assert(OGS_OK == + sgsap_send_service_request( + mme_ue, SGSAP_EMM_CONNECTED_MODE)); } else goto paging_reject; } @@ -421,8 +427,9 @@ void sgsap_handle_downlink_unitdata(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) nas_message_container_buffer, nas_message_container_length); - nas_eps_send_downlink_nas_transport(mme_ue, - 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)); } void sgsap_handle_reset_indication(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) @@ -432,7 +439,7 @@ void sgsap_handle_reset_indication(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) ogs_assert(vlr); ogs_assert(pkbuf); - sgsap_send_reset_ack(vlr); + ogs_assert(OGS_OK == sgsap_send_reset_ack(vlr)); } void sgsap_handle_release_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf) diff --git a/src/mme/sgsap-path.c b/src/mme/sgsap-path.c index d42c405b0..c61a718e3 100644 --- a/src/mme/sgsap-path.c +++ b/src/mme/sgsap-path.c @@ -114,7 +114,7 @@ int sgsap_send_to_vlr(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf) return sgsap_send_to_vlr_with_sid(vlr, pkbuf, mme_ue->vlr_ostream_id); } -void sgsap_send_location_update_request(mme_ue_t *mme_ue) +int sgsap_send_location_update_request(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *pkbuf = NULL; @@ -124,12 +124,14 @@ void 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(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_tmsi_reallocation_complete(mme_ue_t *mme_ue) +int sgsap_send_tmsi_reallocation_complete(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *pkbuf = NULL; @@ -139,24 +141,28 @@ void 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(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_detach_indication(mme_ue_t *mme_ue) +int sgsap_send_detach_indication(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *pkbuf = NULL; ogs_assert(mme_ue); pkbuf = sgsap_build_detach_indication(mme_ue); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_mo_csfb_indication(mme_ue_t *mme_ue) +int sgsap_send_mo_csfb_indication(mme_ue_t *mme_ue) { int rv; ogs_pkbuf_t *pkbuf = NULL; @@ -166,12 +172,14 @@ void 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(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode) +int sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode) { int rv; ogs_pkbuf_t *pkbuf = NULL; @@ -183,12 +191,14 @@ void 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(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_reset_ack(mme_vlr_t *vlr) +int sgsap_send_reset_ack(mme_vlr_t *vlr) { int rv; ogs_pkbuf_t *pkbuf = NULL; @@ -197,12 +207,14 @@ void sgsap_send_reset_ack(mme_vlr_t *vlr) ogs_debug("[SGSAP] RESET-ACK"); pkbuf = sgsap_build_reset_ack(vlr); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr_with_sid(vlr, pkbuf, 0); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_uplink_unitdata(mme_ue_t *mme_ue, +int sgsap_send_uplink_unitdata(mme_ue_t *mme_ue, ogs_nas_eps_message_container_t *nas_message_container) { int rv; @@ -216,12 +228,14 @@ void 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(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); + + return rv; } -void sgsap_send_ue_unreachable(mme_ue_t *mme_ue, uint8_t sgs_cause) +int sgsap_send_ue_unreachable(mme_ue_t *mme_ue, uint8_t sgs_cause) { int rv; ogs_pkbuf_t *pkbuf = NULL; @@ -232,7 +246,9 @@ void 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(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = sgsap_send_to_vlr(mme_ue, pkbuf); ogs_expect(rv == OGS_OK); -} + + return rv; +} \ No newline at end of file diff --git a/src/mme/sgsap-path.h b/src/mme/sgsap-path.h index 325c7c559..1ecfb71a6 100644 --- a/src/mme/sgsap-path.h +++ b/src/mme/sgsap-path.h @@ -41,15 +41,15 @@ int sgsap_send_to_vlr_with_sid( mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf, uint16_t stream_no); int sgsap_send_to_vlr(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf); -void sgsap_send_location_update_request(mme_ue_t *mme_ue); -void sgsap_send_tmsi_reallocation_complete(mme_ue_t *mme_ue); -void sgsap_send_detach_indication(mme_ue_t *mme_ue); -void sgsap_send_mo_csfb_indication(mme_ue_t *mme_ue); -void sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode); -void sgsap_send_reset_ack(mme_vlr_t *vlr); -void sgsap_send_uplink_unitdata(mme_ue_t *mme_ue, +int sgsap_send_location_update_request(mme_ue_t *mme_ue); +int sgsap_send_tmsi_reallocation_complete(mme_ue_t *mme_ue); +int sgsap_send_detach_indication(mme_ue_t *mme_ue); +int sgsap_send_mo_csfb_indication(mme_ue_t *mme_ue); +int sgsap_send_service_request(mme_ue_t *mme_ue, uint8_t emm_mode); +int sgsap_send_reset_ack(mme_vlr_t *vlr); +int sgsap_send_uplink_unitdata(mme_ue_t *mme_ue, ogs_nas_eps_message_container_t *nas_message_container); -void sgsap_send_ue_unreachable(mme_ue_t *mme_ue, uint8_t sgs_cause); +int sgsap_send_ue_unreachable(mme_ue_t *mme_ue, uint8_t sgs_cause); #ifdef __cplusplus } diff --git a/src/sgwc/gtp-path.c b/src/sgwc/gtp-path.c index d9c0a7174..f3b830d54 100644 --- a/src/sgwc/gtp-path.c +++ b/src/sgwc/gtp-path.c @@ -159,7 +159,7 @@ static void bearer_timeout(ogs_gtp_xact_t *xact, void *data) } } -void sgwc_gtp_send_downlink_data_notification( +int sgwc_gtp_send_downlink_data_notification( uint8_t cause_value, sgwc_bearer_t *bearer) { int rv; @@ -189,12 +189,14 @@ void sgwc_gtp_send_downlink_data_notification( h.teid = sgwc_ue->mme_s11_teid; pkbuf = sgwc_s11_build_downlink_data_notification(cause_value, bearer); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); gtp_xact = ogs_gtp_xact_local_create( sgwc_ue->gnode, &h, pkbuf, bearer_timeout, bearer); - ogs_expect_or_return(gtp_xact); + ogs_expect_or_return_val(gtp_xact, OGS_ERROR); rv = ogs_gtp_xact_commit(gtp_xact); ogs_expect(rv == OGS_OK); + + return rv; } diff --git a/src/sgwc/gtp-path.h b/src/sgwc/gtp-path.h index a6b35323c..81b4633e0 100644 --- a/src/sgwc/gtp-path.h +++ b/src/sgwc/gtp-path.h @@ -29,7 +29,7 @@ extern "C" { int sgwc_gtp_open(void); void sgwc_gtp_close(void); -void sgwc_gtp_send_downlink_data_notification( +int sgwc_gtp_send_downlink_data_notification( uint8_t cause_value, sgwc_bearer_t *bearer); #ifdef __cplusplus diff --git a/src/sgwc/pfcp-path.c b/src/sgwc/pfcp-path.c index 692de1574..2c38f03f1 100644 --- a/src/sgwc/pfcp-path.c +++ b/src/sgwc/pfcp-path.c @@ -202,7 +202,7 @@ static void bearer_timeout(ogs_pfcp_xact_t *xact, void *data) } } -void sgwc_pfcp_send_session_establishment_request( +int sgwc_pfcp_send_session_establishment_request( sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf) { int rv; @@ -217,11 +217,11 @@ void sgwc_pfcp_send_session_establishment_request( h.seid = sess->sgwu_sxa_seid; sxabuf = sgwc_sxa_build_session_establishment_request(h.type, sess); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, sxabuf, sess_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_xact = gtp_xact; if (gtpbuf) { xact->gtpbuf = ogs_pkbuf_copy(gtpbuf); @@ -230,9 +230,11 @@ void sgwc_pfcp_send_session_establishment_request( rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void sgwc_pfcp_send_sess_modification_request( +int sgwc_pfcp_send_sess_modification_request( sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf, uint64_t flags) { @@ -248,11 +250,11 @@ void sgwc_pfcp_send_sess_modification_request( h.seid = sess->sgwu_sxa_seid; sxabuf = sgwc_sxa_build_sess_modification_request(h.type, sess, flags); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, sxabuf, sess_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_xact = gtp_xact; xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION; if (gtpbuf) { @@ -262,9 +264,11 @@ void sgwc_pfcp_send_sess_modification_request( rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void sgwc_pfcp_send_bearer_modification_request( +int sgwc_pfcp_send_bearer_modification_request( sgwc_bearer_t *bearer, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf, uint64_t flags) { @@ -283,11 +287,11 @@ void sgwc_pfcp_send_bearer_modification_request( h.seid = sess->sgwu_sxa_seid; sxabuf = sgwc_sxa_build_bearer_modification_request(h.type, bearer, flags); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, sxabuf, bearer_timeout, bearer); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_xact = gtp_xact; xact->modify_flags = flags; if (gtpbuf) { @@ -297,9 +301,11 @@ void sgwc_pfcp_send_bearer_modification_request( rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void sgwc_pfcp_send_session_deletion_request( +int sgwc_pfcp_send_session_deletion_request( sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf) { int rv; @@ -314,11 +320,11 @@ void sgwc_pfcp_send_session_deletion_request( h.seid = sess->sgwu_sxa_seid; sxabuf = sgwc_sxa_build_session_deletion_request(h.type, sess); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, sxabuf, sess_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_xact = gtp_xact; if (gtpbuf) { xact->gtpbuf = ogs_pkbuf_copy(gtpbuf); @@ -327,9 +333,11 @@ void sgwc_pfcp_send_session_deletion_request( rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void sgwc_pfcp_send_session_report_response( +int sgwc_pfcp_send_session_report_response( ogs_pfcp_xact_t *xact, sgwc_sess_t *sess, uint8_t cause) { int rv; @@ -343,11 +351,13 @@ void sgwc_pfcp_send_session_report_response( h.seid = sess->sgwu_sxa_seid; sxabuf = ogs_pfcp_build_session_report_response(h.type, cause); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, sxabuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); -} + + return rv; +} \ No newline at end of file diff --git a/src/sgwc/pfcp-path.h b/src/sgwc/pfcp-path.h index 9293fbbdc..1ee3d32e8 100644 --- a/src/sgwc/pfcp-path.h +++ b/src/sgwc/pfcp-path.h @@ -29,18 +29,18 @@ extern "C" { int sgwc_pfcp_open(void); void sgwc_pfcp_close(void); -void sgwc_pfcp_send_session_establishment_request( +int sgwc_pfcp_send_session_establishment_request( sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf); -void sgwc_pfcp_send_sess_modification_request( +int sgwc_pfcp_send_sess_modification_request( sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf, uint64_t flags); -void sgwc_pfcp_send_bearer_modification_request( +int sgwc_pfcp_send_bearer_modification_request( sgwc_bearer_t *bearer, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf, uint64_t flags); -void sgwc_pfcp_send_session_deletion_request( +int sgwc_pfcp_send_session_deletion_request( sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf); -void sgwc_pfcp_send_session_report_response( +int sgwc_pfcp_send_session_report_response( ogs_pfcp_xact_t *xact, sgwc_sess_t *sess, uint8_t cause); #ifdef __cplusplus diff --git a/src/sgwc/s11-handler.c b/src/sgwc/s11-handler.c index b16966b52..81526b0d5 100644 --- a/src/sgwc/s11-handler.c +++ b/src/sgwc/s11-handler.c @@ -43,7 +43,8 @@ static void sess_timeout(ogs_gtp_xact_t *xact, void *data) sgwc_ue->imsi_bcd); break; } - sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL)); break; default: ogs_error("GTP Timeout : IMSI[%s] Message-Type[%d]", @@ -262,7 +263,8 @@ void sgwc_s11_handle_create_session_request( ogs_debug(" MME_S11_TEID[%d] SGW_S11_TEID[%d]", sgwc_ue->mme_s11_teid, sgwc_ue->sgw_s11_teid); - sgwc_pfcp_send_session_establishment_request(sess, s11_xact, gtpbuf); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_establishment_request(sess, s11_xact, gtpbuf)); } void sgwc_s11_handle_modify_bearer_request( @@ -403,8 +405,9 @@ void sgwc_s11_handle_modify_bearer_request( ogs_debug(" ENB_S1U_TEID[%d] SGW_S1U_TEID[%d]", dl_tunnel->remote_teid, dl_tunnel->local_teid); - sgwc_pfcp_send_bearer_modification_request( - bearer, s11_xact, gtpbuf, flags); + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( + bearer, s11_xact, gtpbuf, flags)); } void sgwc_s11_handle_delete_session_request( @@ -577,9 +580,10 @@ void sgwc_s11_handle_create_bearer_response( } if (cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED) { - sgwc_pfcp_send_bearer_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( bearer, NULL, NULL, - OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE); + OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE)); ogs_gtp_send_error_message(s5c_xact, sess ? sess->pgw_s5c_teid : 0, OGS_GTP_CREATE_BEARER_RESPONSE_TYPE, cause_value); return; @@ -636,9 +640,10 @@ void sgwc_s11_handle_create_bearer_response( ogs_plmn_id_hexdump(&sgwc_ue->e_cgi.plmn_id), sgwc_ue->e_cgi.cell_id); - sgwc_pfcp_send_bearer_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( bearer, s5c_xact, gtpbuf, - OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_CREATE); + OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_CREATE)); } void sgwc_s11_handle_update_bearer_response( @@ -824,8 +829,9 @@ void sgwc_s11_handle_delete_bearer_response( ogs_debug(" SGW_S5C_TEID[0x%x] PGW_S5C_TEID[0x%x]", sess->sgw_s5c_teid, sess->pgw_s5c_teid); - sgwc_pfcp_send_bearer_modification_request( - bearer, s5c_xact, gtpbuf, OGS_PFCP_MODIFY_REMOVE); + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( + bearer, s5c_xact, gtpbuf, OGS_PFCP_MODIFY_REMOVE)); } void sgwc_s11_handle_release_access_bearers_request( @@ -867,9 +873,10 @@ void sgwc_s11_handle_release_access_bearers_request( ogs_list_for_each(&sgwc_ue->sess_list, sess) { sess->state.release_access_bearers = false; - sgwc_pfcp_send_sess_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_sess_modification_request( sess, s11_xact, gtpbuf, - OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE); + OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE)); } } @@ -1042,9 +1049,10 @@ void sgwc_s11_handle_create_indirect_data_forwarding_tunnel_request( ogs_list_for_each(&sgwc_ue->sess_list, sess) { sess->state.create_indirect_tunnel = false; - sgwc_pfcp_send_sess_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_sess_modification_request( sess, s11_xact, gtpbuf, - OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_CREATE); + OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_CREATE)); } } @@ -1084,9 +1092,10 @@ void sgwc_s11_handle_delete_indirect_data_forwarding_tunnel_request( ogs_list_for_each(&sgwc_ue->sess_list, sess) { sess->state.delete_indirect_tunnel = false; - sgwc_pfcp_send_sess_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_sess_modification_request( sess, s11_xact, gtpbuf, - OGS_PFCP_MODIFY_INDIRECT| OGS_PFCP_MODIFY_REMOVE); + OGS_PFCP_MODIFY_INDIRECT| OGS_PFCP_MODIFY_REMOVE)); } } diff --git a/src/sgwc/s5c-handler.c b/src/sgwc/s5c-handler.c index acae98bac..c21c02996 100644 --- a/src/sgwc/s5c-handler.c +++ b/src/sgwc/s5c-handler.c @@ -48,8 +48,9 @@ static void bearer_timeout(ogs_gtp_xact_t *xact, void *data) ogs_warn("[%s] Bearer has already been removed", sgwc_ue->imsi_bcd); break; } - sgwc_pfcp_send_bearer_modification_request( - bearer, NULL, NULL, OGS_PFCP_MODIFY_REMOVE); + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( + bearer, NULL, NULL, OGS_PFCP_MODIFY_REMOVE)); break; default: ogs_error("GTP Timeout : IMSI[%s] Message-Type[%d]", @@ -179,7 +180,8 @@ void sgwc_s5c_handle_create_session_response( } if (cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED) { - sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL)); ogs_gtp_send_error_message( s11_xact, sgwc_ue ? sgwc_ue->mme_s11_teid : 0, OGS_GTP_CREATE_SESSION_RESPONSE_TYPE, cause_value); @@ -225,9 +227,10 @@ void sgwc_s5c_handle_create_session_response( ogs_debug(" SGW_S5U_TEID[%d] PGW_S5U_TEID[%d]", ul_tunnel->local_teid, ul_tunnel->remote_teid); - sgwc_pfcp_send_bearer_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( bearer, s11_xact, gtpbuf, - OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_ACTIVATE); + OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_ACTIVATE)); } void sgwc_s5c_handle_delete_session_response( @@ -276,7 +279,8 @@ void sgwc_s5c_handle_delete_session_response( } if (cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED) { - sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL)); ogs_gtp_send_error_message( s11_xact, sgwc_ue ? sgwc_ue->mme_s11_teid : 0, OGS_GTP_DELETE_SESSION_RESPONSE_TYPE, cause_value); @@ -289,7 +293,8 @@ void sgwc_s5c_handle_delete_session_response( ogs_debug(" SGW_S5C_TEID[0x%x] PGW_S5C_TEID[0x%x]", sess->sgw_s5c_teid, sess->pgw_s5c_teid); - sgwc_pfcp_send_session_deletion_request(sess, s11_xact, gtpbuf); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_deletion_request(sess, s11_xact, gtpbuf)); } void sgwc_s5c_handle_create_bearer_request( @@ -381,9 +386,10 @@ void sgwc_s5c_handle_create_bearer_request( &far->outer_header_creation, &far->outer_header_creation_len); far->outer_header_creation.teid = ul_tunnel->remote_teid; - sgwc_pfcp_send_bearer_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( bearer, s5c_xact, gtpbuf, - OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_CREATE); + OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_CREATE)); } void sgwc_s5c_handle_update_bearer_request( diff --git a/src/sgwc/sxa-handler.c b/src/sgwc/sxa-handler.c index 7b6826411..6c75c1ad6 100644 --- a/src/sgwc/sxa-handler.c +++ b/src/sgwc/sxa-handler.c @@ -81,7 +81,8 @@ static void sess_timeout(ogs_gtp_xact_t *xact, void *data) sgwc_ue->imsi_bcd); break; } - sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL)); break; default: ogs_error("GTP Timeout : IMSI[%s] Message-Type[%d]", @@ -112,9 +113,10 @@ static void bearer_timeout(ogs_gtp_xact_t *xact, void *data) ogs_warn("[%s] Bearer has already been removed", sgwc_ue->imsi_bcd); break; } - sgwc_pfcp_send_bearer_modification_request( + ogs_assert(OGS_OK == + sgwc_pfcp_send_bearer_modification_request( bearer, NULL, NULL, - OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE); + OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE)); break; default: ogs_error("GTP Timeout : IMSI[%s] Message-Type[%d]", @@ -962,8 +964,9 @@ void sgwc_sxa_handle_session_modification_response( bearer = pfcp_xact->assoc_xact; ogs_assert(bearer); - sgwc_gtp_send_downlink_data_notification( - OGS_GTP_CAUSE_ERROR_INDICATION_RECEIVED, bearer); + ogs_assert(OGS_OK == + sgwc_gtp_send_downlink_data_notification( + OGS_GTP_CAUSE_ERROR_INDICATION_RECEIVED, bearer)); } else { ogs_gtp_release_access_bearers_response_t *gtp_rsp = NULL; @@ -1123,8 +1126,9 @@ void sgwc_sxa_handle_session_report_request( return; } - sgwc_pfcp_send_session_report_response( - pfcp_xact, sess, OGS_PFCP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + sgwc_pfcp_send_session_report_response( + pfcp_xact, sess, OGS_PFCP_CAUSE_REQUEST_ACCEPTED)); report_type.value = pfcp_req->report_type.u8; @@ -1145,8 +1149,9 @@ void sgwc_sxa_handle_session_report_request( ogs_list_for_each(&bearer->tunnel_list, tunnel) { ogs_assert(tunnel->pdr); if (tunnel->pdr->id == pdr_id) { - sgwc_gtp_send_downlink_data_notification( - OGS_GTP_CAUSE_INVALID_VALUE, bearer); + ogs_assert(OGS_OK == + sgwc_gtp_send_downlink_data_notification( + OGS_GTP_CAUSE_INVALID_VALUE, bearer)); return; } } @@ -1164,13 +1169,14 @@ void sgwc_sxa_handle_session_report_request( sess->state.release_access_bearers = false; - sgwc_pfcp_send_sess_modification_request(sess, - /* We only use the `assoc_xact` parameter temporarily here - * to pass the `bearer` context. */ + ogs_assert(OGS_OK == + sgwc_pfcp_send_sess_modification_request(sess, + /* We only use the `assoc_xact` parameter temporarily here + * to pass the `bearer` context. */ (ogs_gtp_xact_t *)bearer, NULL, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE| - OGS_PFCP_MODIFY_ERROR_INDICATION); + OGS_PFCP_MODIFY_ERROR_INDICATION)); } } else { diff --git a/src/sgwu/gtp-path.c b/src/sgwu/gtp-path.c index c220389bc..e32990090 100644 --- a/src/sgwu/gtp-path.c +++ b/src/sgwu/gtp-path.c @@ -140,7 +140,8 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data) sess = SGWU_SESS(far->sess); ogs_assert(sess); - sgwu_pfcp_send_session_report_request(sess, &report); + ogs_assert(OGS_OK == + sgwu_pfcp_send_session_report_request(sess, &report)); } } else { @@ -216,7 +217,8 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data) report.downlink_data.pdr_id = pdr->id; report.downlink_data.qfi = qfi; /* for 5GC */ - sgwu_pfcp_send_session_report_request(sess, &report); + ogs_assert(OGS_OK == + sgwu_pfcp_send_session_report_request(sess, &report)); } } else { ogs_error("[DROP] Invalid GTPU Type [%d]", gtp_h->type); @@ -271,4 +273,4 @@ int sgwu_gtp_open(void) void sgwu_gtp_close(void) { ogs_socknode_remove_all(&ogs_gtp_self()->gtpu_list); -} +} \ No newline at end of file diff --git a/src/sgwu/pfcp-path.c b/src/sgwu/pfcp-path.c index 0f58b64b9..775f95ed4 100644 --- a/src/sgwu/pfcp-path.c +++ b/src/sgwu/pfcp-path.c @@ -162,7 +162,7 @@ void sgwu_pfcp_close(void) ogs_socknode_remove_all(&ogs_pfcp_self()->pfcp_list6); } -void sgwu_pfcp_send_session_establishment_response( +int sgwu_pfcp_send_session_establishment_response( ogs_pfcp_xact_t *xact, sgwu_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr) { @@ -178,16 +178,18 @@ void sgwu_pfcp_send_session_establishment_response( sxabuf = sgwu_sxa_build_session_establishment_response( h.type, sess, created_pdr, num_of_created_pdr); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, sxabuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void sgwu_pfcp_send_session_modification_response( +int sgwu_pfcp_send_session_modification_response( ogs_pfcp_xact_t *xact, sgwu_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr) { @@ -204,16 +206,18 @@ void sgwu_pfcp_send_session_modification_response( sxabuf = sgwu_sxa_build_session_modification_response( h.type, sess, created_pdr, num_of_created_pdr); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, sxabuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void sgwu_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, +int sgwu_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, sgwu_sess_t *sess) { int rv; @@ -227,13 +231,15 @@ void sgwu_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, h.seid = sess->sgwc_sxa_seid; sxabuf = sgwu_sxa_build_session_deletion_response(h.type, sess); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, sxabuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } static void sess_timeout(ogs_pfcp_xact_t *xact, void *data) @@ -253,7 +259,7 @@ static void sess_timeout(ogs_pfcp_xact_t *xact, void *data) } } -void sgwu_pfcp_send_session_report_request( +int sgwu_pfcp_send_session_report_request( sgwu_sess_t *sess, ogs_pfcp_user_plane_report_t *report) { int rv; @@ -269,12 +275,14 @@ void sgwu_pfcp_send_session_report_request( h.seid = sess->sgwc_sxa_seid; sxabuf = ogs_pfcp_build_session_report_request(h.type, report); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, sxabuf, sess_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); -} + + return rv; +} \ No newline at end of file diff --git a/src/sgwu/pfcp-path.h b/src/sgwu/pfcp-path.h index 9a47cd93e..c015ff424 100644 --- a/src/sgwu/pfcp-path.h +++ b/src/sgwu/pfcp-path.h @@ -29,16 +29,16 @@ extern "C" { int sgwu_pfcp_open(void); void sgwu_pfcp_close(void); -void sgwu_pfcp_send_session_establishment_response( +int sgwu_pfcp_send_session_establishment_response( ogs_pfcp_xact_t *xact, sgwu_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr); -void sgwu_pfcp_send_session_modification_response( +int sgwu_pfcp_send_session_modification_response( ogs_pfcp_xact_t *xact, sgwu_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr); -void sgwu_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, +int sgwu_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, sgwu_sess_t *sess); -void sgwu_pfcp_send_session_report_request( +int sgwu_pfcp_send_session_report_request( sgwu_sess_t *sess, ogs_pfcp_user_plane_report_t *report); #ifdef __cplusplus diff --git a/src/sgwu/sxa-handler.c b/src/sgwu/sxa-handler.c index 3ccb352cd..0efb2cafa 100644 --- a/src/sgwu/sxa-handler.c +++ b/src/sgwu/sxa-handler.c @@ -152,8 +152,9 @@ void sgwu_sxa_handle_session_establishment_request( } } - sgwu_pfcp_send_session_establishment_response( - xact, sess, created_pdr, num_of_created_pdr); + ogs_assert(OGS_OK == + sgwu_pfcp_send_session_establishment_response( + xact, sess, created_pdr, num_of_created_pdr)); return; cleanup: @@ -357,8 +358,9 @@ void sgwu_sxa_handle_session_modification_request( } } - sgwu_pfcp_send_session_modification_response( - xact, sess, created_pdr, num_of_created_pdr); + ogs_assert(OGS_OK == + sgwu_pfcp_send_session_modification_response( + xact, sess, created_pdr, num_of_created_pdr)); return; cleanup: diff --git a/src/smf/binding.c b/src/smf/binding.c index 8f3125104..774e6c66b 100644 --- a/src/smf/binding.c +++ b/src/smf/binding.c @@ -45,8 +45,9 @@ static void bearer_timeout(ogs_gtp_xact_t *xact, void *data) ogs_warn("[%s] Bearer has already been removed", smf_ue->imsi_bcd); break; } - smf_epc_pfcp_send_bearer_modification_request( - bearer, OGS_PFCP_MODIFY_REMOVE); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request( + bearer, OGS_PFCP_MODIFY_REMOVE)); break; case OGS_GTP_UPDATE_BEARER_REQUEST_TYPE: ogs_error("[%s] No Update Bearer Response", smf_ue->imsi_bcd); @@ -57,8 +58,10 @@ static void bearer_timeout(ogs_gtp_xact_t *xact, void *data) ogs_warn("[%s] Bearer has already been removed", smf_ue->imsi_bcd); break; } - smf_epc_pfcp_send_bearer_modification_request( - bearer, OGS_PFCP_MODIFY_REMOVE); + + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request( + bearer, OGS_PFCP_MODIFY_REMOVE)); break; default: ogs_error("GTP Timeout : IMSI[%s] Message-Type[%d]", @@ -314,8 +317,9 @@ void smf_bearer_binding(smf_sess_t *sess) qer->gbr.downlink = bearer->qos.gbr.downlink; } - smf_epc_pfcp_send_bearer_modification_request( - bearer, OGS_PFCP_MODIFY_CREATE); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request( + bearer, OGS_PFCP_MODIFY_CREATE)); } else { ogs_gtp_tft_t tft; @@ -595,8 +599,9 @@ void smf_qos_flow_binding(smf_sess_t *sess, ogs_sbi_stream_t *stream) qer->gbr.downlink = qos_flow->qos.gbr.downlink; } - smf_5gc_pfcp_send_qos_flow_modification_request( - qos_flow, NULL, OGS_PFCP_MODIFY_CREATE); + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_qos_flow_modification_request( + qos_flow, NULL, OGS_PFCP_MODIFY_CREATE)); } else { ogs_fatal("Update Qos Flow Not Implemented"); diff --git a/src/smf/gsm-sm.c b/src/smf/gsm-sm.c index bcbd5904b..abb78fb2c 100644 --- a/src/smf/gsm-sm.c +++ b/src/smf/gsm-sm.c @@ -231,8 +231,9 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e) break; case OGS_NAS_5GS_PDU_SESSION_RELEASE_REQUEST: - smf_5gc_pfcp_send_session_deletion_request( - sess, stream, OGS_PFCP_DELETE_TRIGGER_UE_REQUESTED); + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_deletion_request( + sess, stream, OGS_PFCP_DELETE_TRIGGER_UE_REQUESTED)); break; case OGS_NAS_5GS_PDU_SESSION_RELEASE_COMPLETE: diff --git a/src/smf/gtp-path.c b/src/smf/gtp-path.c index dc2240b37..a69c7a6f8 100644 --- a/src/smf/gtp-path.c +++ b/src/smf/gtp-path.c @@ -273,7 +273,7 @@ void smf_gtp_close(void) ogs_socknode_remove_all(&ogs_gtp_self()->gtpu_list); } -void smf_gtp_send_create_session_response( +int smf_gtp_send_create_session_response( smf_sess_t *sess, ogs_gtp_xact_t *xact) { int rv; @@ -288,16 +288,18 @@ void smf_gtp_send_create_session_response( h.teid = sess->sgw_s5c_teid; pkbuf = smf_s5c_build_create_session_response(h.type, sess); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_gtp_send_delete_session_response( +int smf_gtp_send_delete_session_response( smf_sess_t *sess, ogs_gtp_xact_t *xact) { int rv; @@ -312,13 +314,15 @@ void smf_gtp_send_delete_session_response( h.teid = sess->sgw_s5c_teid; pkbuf = smf_s5c_build_delete_session_response(h.type, sess); - ogs_expect_or_return(pkbuf); + ogs_expect_or_return_val(pkbuf, OGS_ERROR); rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_gtp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } static bool check_if_router_solicit(ogs_pkbuf_t *pkbuf) @@ -442,4 +446,4 @@ static void send_router_advertisement(smf_sess_t *sess, uint8_t *ip6_dst) } ogs_pkbuf_free(pkbuf); -} +} \ No newline at end of file diff --git a/src/smf/gtp-path.h b/src/smf/gtp-path.h index be7141123..f1740b545 100644 --- a/src/smf/gtp-path.h +++ b/src/smf/gtp-path.h @@ -29,9 +29,9 @@ extern "C" { int smf_gtp_open(void); void smf_gtp_close(void); -void smf_gtp_send_create_session_response( +int smf_gtp_send_create_session_response( smf_sess_t *sess, ogs_gtp_xact_t *xact); -void smf_gtp_send_delete_session_response( +int smf_gtp_send_delete_session_response( smf_sess_t *sess, ogs_gtp_xact_t *xact); #ifdef __cplusplus diff --git a/src/smf/gx-handler.c b/src/smf/gx-handler.c index 8a0bd5cb2..d040079b8 100644 --- a/src/smf/gx-handler.c +++ b/src/smf/gx-handler.c @@ -248,7 +248,8 @@ void smf_gx_handle_cca_initial_request( ogs_pfcp_pdr_associate_qer(ul_pdr, qer); } - smf_epc_pfcp_send_session_establishment_request(sess, gtp_xact); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_session_establishment_request(sess, gtp_xact)); } void smf_gx_handle_cca_termination_request( @@ -263,7 +264,8 @@ void smf_gx_handle_cca_termination_request( ogs_debug(" SGW_S5C_TEID[0x%x] SMF_N4_TEID[0x%x]", sess->sgw_s5c_teid, sess->smf_n4_teid); - smf_epc_pfcp_send_session_deletion_request(sess, gtp_xact); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_session_deletion_request(sess, gtp_xact)); } void smf_gx_handle_re_auth_request( diff --git a/src/smf/n4-build.c b/src/smf/n4-build.c index 3c4af0072..0aa7b28b2 100644 --- a/src/smf/n4-build.c +++ b/src/smf/n4-build.c @@ -208,44 +208,6 @@ ogs_pkbuf_t *smf_n4_build_session_modification_request( } -#if 0 - i = 0; - ogs_list_for_each(&sess->bearer_list, qos_flow) { - if (modify_flags & OGS_PFCP_MODIFY_ACTIVATE) { - - /* Update FAR - Only DL */ - if (qos_flow->dl_far) { - if (qos_flow->dl_far->apply_action & - OGS_PFCP_APPLY_ACTION_FORW) { - - if (modify_flags & OGS_PFCP_MODIFY_END_MARKER) { - qos_flow->dl_far-> - smreq_flags.send_end_marker_packets = 1; - } - - ogs_fatal("FAR = %d", qos_flow->dl_far->id); - - ogs_pfcp_build_update_far_activate( - &req->update_far[i], i, qos_flow->dl_far); - - /* Clear all FAR flags */ - qos_flow->dl_far->smreq_flags.value = 0; - - i++; - } - } - - } else if (modify_flags & OGS_PFCP_MODIFY_DEACTIVATE) { - if (qos_flow->dl_far) { - ogs_pfcp_build_update_far_deactivate( - &req->update_far[i], i, qos_flow->dl_far); - ogs_error("FAR = %d", qos_flow->dl_far->id); - i++; - } - } - } -#endif - pfcp_message.h.type = type; pkbuf = ogs_pfcp_build_msg(&pfcp_message); diff --git a/src/smf/n4-handler.c b/src/smf/n4-handler.c index d382d3f6d..607a64945 100644 --- a/src/smf/n4-handler.c +++ b/src/smf/n4-handler.c @@ -339,10 +339,11 @@ void smf_5gc_n4_handle_session_modification_response( } else if (flags & OGS_PFCP_MODIFY_N2_HANDOVER) { if (smf_sess_have_indirect_data_forwarding(sess) == true) { - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_REMOVE, - ogs_app()->time.handover.duration); + ogs_app()->time.handover.duration)); } smf_sbi_send_sm_context_updated_data_ho_state( @@ -392,10 +393,11 @@ void smf_5gc_n4_handle_session_modification_response( if (flags & OGS_PFCP_MODIFY_CREATE) { smf_sess_create_indirect_data_forwarding(sess); - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_CREATE, - 0); + 0)); } else if (flags & OGS_PFCP_MODIFY_HANDOVER_CANCEL) { smf_sbi_send_sm_context_updated_data_ho_state( sess, stream, OpenAPI_ho_state_CANCELLED); @@ -621,7 +623,8 @@ void smf_epc_n4_handle_session_establishment_response( ogs_assert(up_f_seid); sess->upf_n4_seid = be64toh(up_f_seid->seid); - smf_gtp_send_create_session_response(sess, gtp_xact); + ogs_assert(OGS_OK == + smf_gtp_send_create_session_response(sess, gtp_xact)); smf_bearer_binding(sess); } @@ -758,7 +761,8 @@ void smf_epc_n4_handle_session_deletion_response( ogs_assert(sess); - smf_gtp_send_delete_session_response(sess, gtp_xact); + ogs_assert(OGS_OK == + smf_gtp_send_delete_session_response(sess, gtp_xact)); SMF_SESS_CLEAR(sess); } @@ -862,8 +866,9 @@ void smf_n4_handle_session_report_request( cause_value, 0); } - smf_pfcp_send_session_report_response( - pfcp_xact, sess, OGS_PFCP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + smf_pfcp_send_session_report_response( + pfcp_xact, sess, OGS_PFCP_CAUSE_REQUEST_ACCEPTED)); if (sess->paging.ue_requested_pdu_session_establishment_done == true) { smf_n1_n2_message_transfer_param_t param; @@ -885,23 +890,26 @@ void smf_n4_handle_session_report_request( smf_sess_t *error_indication_session = NULL; ogs_assert(smf_ue); - smf_pfcp_send_session_report_response( - pfcp_xact, sess, OGS_PFCP_CAUSE_REQUEST_ACCEPTED); + ogs_assert(OGS_OK == + smf_pfcp_send_session_report_response( + pfcp_xact, sess, OGS_PFCP_CAUSE_REQUEST_ACCEPTED)); error_indication_session = smf_sess_find_by_error_indication_report( smf_ue, &pfcp_req->error_indication_report); if (!error_indication_session) return; - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( error_indication_session, NULL, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE| OGS_PFCP_MODIFY_ERROR_INDICATION, - 0); + 0)); } else { ogs_error("Not supported Report Type[%d]", report_type.value); - smf_pfcp_send_session_report_response( - pfcp_xact, sess, OGS_PFCP_CAUSE_SYSTEM_FAILURE); + ogs_assert(OGS_OK == + smf_pfcp_send_session_report_response( + pfcp_xact, sess, OGS_PFCP_CAUSE_SYSTEM_FAILURE)); } } diff --git a/src/smf/ngap-handler.c b/src/smf/ngap-handler.c index a993820a7..e0e706f96 100644 --- a/src/smf/ngap-handler.c +++ b/src/smf/ngap-handler.c @@ -138,9 +138,10 @@ int ngap_handle_pdu_session_resource_setup_response_transfer( } if (far_update) { - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE, - 0); + 0)); } else { /* ACTIVATED Is NOT Included in RESPONSE */ smf_sbi_send_http_status_no_content(stream); @@ -223,8 +224,9 @@ int ngap_handle_pdu_session_resource_modify_response_transfer( &dl_far->outer_header_creation_len); dl_far->outer_header_creation.teid = sess->gnb_n3_teid; - smf_5gc_pfcp_send_qos_flow_modification_request( - qos_flow, stream, OGS_PFCP_MODIFY_ACTIVATE); + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_qos_flow_modification_request( + qos_flow, stream, OGS_PFCP_MODIFY_ACTIVATE)); rv = OGS_OK; @@ -341,11 +343,12 @@ int ngap_handle_path_switch_request_transfer( } if (far_update) { - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE| OGS_PFCP_MODIFY_XN_HANDOVER|OGS_PFCP_MODIFY_END_MARKER, - 0); + 0)); } else { /* ACTIVATED Is NOT Included in RESPONSE */ smf_sbi_send_http_status_no_content(stream); @@ -534,7 +537,8 @@ int ngap_handle_handover_request_ack( ogs_error("We found redundant INDIRECT Tunnel"); ogs_error("It will be automatically removed"); - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_INDIRECT| /* @@ -550,15 +554,16 @@ int ngap_handle_handover_request_ack( * ... */ OGS_PFCP_MODIFY_REMOVE|OGS_PFCP_MODIFY_CREATE, - 0); + 0)); } else { smf_sess_create_indirect_data_forwarding(sess); - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_CREATE, - 0); + 0)); } } else { ogs_pkbuf_t *n2smbuf = ngap_build_handover_command_transfer(sess); diff --git a/src/smf/ngap-path.c b/src/smf/ngap-path.c index 3d818f6dd..7a6c6ee46 100644 --- a/src/smf/ngap-path.c +++ b/src/smf/ngap-path.c @@ -40,4 +40,4 @@ void ngap_send_to_n2sm(smf_sess_t *sess, ogs_pkbuf_free(e->pkbuf); smf_event_free(e); } -} +} \ No newline at end of file diff --git a/src/smf/npcf-handler.c b/src/smf/npcf-handler.c index 9acf57fc7..39aab7886 100644 --- a/src/smf/npcf-handler.c +++ b/src/smf/npcf-handler.c @@ -487,7 +487,8 @@ bool smf_npcf_smpolicycontrol_handle_create( cp2up_pdr->precedence = OGS_PFCP_CP2UP_PDR_PRECEDENCE; up2cp_pdr->precedence = OGS_PFCP_UP2CP_PDR_PRECEDENCE; - smf_5gc_pfcp_send_session_establishment_request(sess, stream); + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_establishment_request(sess, stream)); return true; diff --git a/src/smf/nsmf-handler.c b/src/smf/nsmf-handler.c index bc7387bb9..b74e6704d 100644 --- a/src/smf/nsmf-handler.c +++ b/src/smf/nsmf-handler.c @@ -347,10 +347,11 @@ bool smf_nsmf_handle_update_sm_context( /********************************************************* * Handle DEACTIVATED ********************************************************/ - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE, - 0); + 0)); } else if (SmContextUpdateData->up_cnx_state == OpenAPI_up_cnx_state_ACTIVATING) { @@ -481,11 +482,12 @@ bool smf_nsmf_handle_update_sm_context( } if (far_update) { - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE| OGS_PFCP_MODIFY_N2_HANDOVER|OGS_PFCP_MODIFY_END_MARKER, - 0); + 0)); } else { char *strerror = ogs_msprintf( "[%s:%d] No FAR Update", smf_ue->supi, sess->psi); @@ -513,11 +515,12 @@ bool smf_nsmf_handle_update_sm_context( } if (smf_sess_have_indirect_data_forwarding(sess) == true) { - smf_5gc_pfcp_send_session_modification_request( + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_modification_request( sess, stream, OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_REMOVE| OGS_PFCP_MODIFY_HANDOVER_CANCEL, - 0); + 0)); } else { smf_sbi_send_sm_context_updated_data_ho_state( sess, stream, OpenAPI_ho_state_CANCELLED); @@ -536,8 +539,9 @@ bool smf_nsmf_handle_update_sm_context( return false; } } else if (SmContextUpdateData->release) { - smf_5gc_pfcp_send_session_deletion_request(sess, stream, - OGS_PFCP_DELETE_TRIGGER_AMF_UPDATE_SM_CONTEXT); + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_deletion_request(sess, stream, + OGS_PFCP_DELETE_TRIGGER_AMF_UPDATE_SM_CONTEXT)); } else { ogs_error("[%s:%d] No UpdateData", smf_ue->supi, sess->psi); smf_sbi_send_sm_context_update_error(stream, @@ -585,8 +589,9 @@ bool smf_nsmf_handle_release_sm_context( } } - smf_5gc_pfcp_send_session_deletion_request(sess, stream, - OGS_PFCP_DELETE_TRIGGER_AMF_RELEASE_SM_CONTEXT); + ogs_assert(OGS_OK == + smf_5gc_pfcp_send_session_deletion_request(sess, stream, + OGS_PFCP_DELETE_TRIGGER_AMF_RELEASE_SM_CONTEXT)); return true; } diff --git a/src/smf/pfcp-path.c b/src/smf/pfcp-path.c index b4b42d75f..f4bd006a7 100644 --- a/src/smf/pfcp-path.c +++ b/src/smf/pfcp-path.c @@ -290,7 +290,7 @@ static void bearer_epc_timeout(ogs_pfcp_xact_t *xact, void *data) } } -void smf_5gc_pfcp_send_session_establishment_request( +int smf_5gc_pfcp_send_session_establishment_request( smf_sess_t *sess, ogs_sbi_stream_t *stream) { int rv; @@ -306,18 +306,20 @@ void smf_5gc_pfcp_send_session_establishment_request( h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_session_establishment_request(h.type, sess); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, sess_5gc_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_stream = stream; rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_5gc_pfcp_send_session_modification_request( +int smf_5gc_pfcp_send_session_modification_request( smf_sess_t *sess, ogs_sbi_stream_t *stream, uint64_t flags, ogs_time_t duration) { @@ -335,23 +337,27 @@ void smf_5gc_pfcp_send_session_modification_request( h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_session_modification_request(h.type, sess, flags); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, sess_5gc_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_stream = stream; xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION; if (duration) { ogs_pfcp_xact_delayed_commit(xact, duration); + + return OGS_OK; } else { rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } } -void smf_5gc_pfcp_send_qos_flow_modification_request(smf_bearer_t *qos_flow, +int smf_5gc_pfcp_send_qos_flow_modification_request(smf_bearer_t *qos_flow, ogs_sbi_stream_t *stream, uint64_t flags) { int rv; @@ -369,20 +375,22 @@ void smf_5gc_pfcp_send_qos_flow_modification_request(smf_bearer_t *qos_flow, h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_qos_flow_modification_request(h.type, qos_flow, flags); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, qos_flow_5gc_timeout, qos_flow); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_stream = stream; xact->modify_flags = flags; rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_5gc_pfcp_send_session_deletion_request( +int smf_5gc_pfcp_send_session_deletion_request( smf_sess_t *sess, ogs_sbi_stream_t *stream, int trigger) { int rv; @@ -399,19 +407,21 @@ void smf_5gc_pfcp_send_session_deletion_request( h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_session_deletion_request(h.type, sess); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, sess_5gc_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->assoc_stream = stream; xact->delete_trigger = trigger; rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_epc_pfcp_send_session_establishment_request( +int smf_epc_pfcp_send_session_establishment_request( smf_sess_t *sess, void *gtp_xact) { int rv; @@ -426,20 +436,22 @@ void smf_epc_pfcp_send_session_establishment_request( h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_session_establishment_request(h.type, sess); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, sess_epc_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->epc = true; /* EPC PFCP transaction */ xact->assoc_xact = gtp_xact; rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_epc_pfcp_send_bearer_modification_request( +int smf_epc_pfcp_send_bearer_modification_request( smf_bearer_t *bearer, uint64_t flags) { int rv; @@ -457,20 +469,22 @@ void smf_epc_pfcp_send_bearer_modification_request( h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_qos_flow_modification_request(h.type, bearer, flags); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, bearer_epc_timeout, bearer); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->epc = true; /* EPC PFCP transaction */ xact->modify_flags = flags; rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_epc_pfcp_send_session_deletion_request( +int smf_epc_pfcp_send_session_deletion_request( smf_sess_t *sess, void *gtp_xact) { int rv; @@ -485,20 +499,22 @@ void smf_epc_pfcp_send_session_deletion_request( h.seid = sess->upf_n4_seid; n4buf = smf_n4_build_session_deletion_request(h.type, sess); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, sess_epc_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); xact->epc = true; /* EPC PFCP transaction */ xact->assoc_xact = gtp_xact; rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void smf_pfcp_send_session_report_response( +int smf_pfcp_send_session_report_response( ogs_pfcp_xact_t *xact, smf_sess_t *sess, uint8_t cause) { int rv; @@ -512,11 +528,13 @@ void smf_pfcp_send_session_report_response( h.seid = sess->upf_n4_seid; sxabuf = ogs_pfcp_build_session_report_response(h.type, cause); - ogs_expect_or_return(sxabuf); + ogs_expect_or_return_val(sxabuf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, sxabuf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } diff --git a/src/smf/pfcp-path.h b/src/smf/pfcp-path.h index 346f01098..538982ecc 100644 --- a/src/smf/pfcp-path.h +++ b/src/smf/pfcp-path.h @@ -29,24 +29,24 @@ extern "C" { int smf_pfcp_open(void); void smf_pfcp_close(void); -void smf_5gc_pfcp_send_session_establishment_request( +int smf_5gc_pfcp_send_session_establishment_request( smf_sess_t *sess, ogs_sbi_stream_t *stream); -void smf_5gc_pfcp_send_session_modification_request( +int smf_5gc_pfcp_send_session_modification_request( smf_sess_t *sess, ogs_sbi_stream_t *stream, uint64_t flags, ogs_time_t duration); -void smf_5gc_pfcp_send_qos_flow_modification_request(smf_bearer_t *qos_flow, +int smf_5gc_pfcp_send_qos_flow_modification_request(smf_bearer_t *qos_flow, ogs_sbi_stream_t *stream, uint64_t flags); -void smf_5gc_pfcp_send_session_deletion_request( +int smf_5gc_pfcp_send_session_deletion_request( smf_sess_t *sess, ogs_sbi_stream_t *stream, int trigger); -void smf_epc_pfcp_send_session_establishment_request( +int smf_epc_pfcp_send_session_establishment_request( smf_sess_t *sess, void *gtp_xact); -void smf_epc_pfcp_send_bearer_modification_request( +int smf_epc_pfcp_send_bearer_modification_request( smf_bearer_t *bearer, uint64_t flags); -void smf_epc_pfcp_send_session_deletion_request( +int smf_epc_pfcp_send_session_deletion_request( smf_sess_t *sess, void *gtp_xact); -void smf_pfcp_send_session_report_response( +int smf_pfcp_send_session_report_response( ogs_pfcp_xact_t *xact, smf_sess_t *sess, uint8_t cause); #ifdef __cplusplus diff --git a/src/smf/s5c-handler.c b/src/smf/s5c-handler.c index 1f6fced26..9e3524149 100644 --- a/src/smf/s5c-handler.c +++ b/src/smf/s5c-handler.c @@ -344,8 +344,9 @@ void smf_s5c_handle_create_bearer_response( } if (cause_value != OGS_GTP_CAUSE_REQUEST_ACCEPTED) { - smf_epc_pfcp_send_bearer_modification_request( - bearer, OGS_PFCP_MODIFY_REMOVE); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request( + bearer, OGS_PFCP_MODIFY_REMOVE)); return; } @@ -380,8 +381,9 @@ void smf_s5c_handle_create_bearer_response( &dl_far->outer_header_creation, &dl_far->outer_header_creation_len); dl_far->outer_header_creation.teid = bearer->sgw_s5u_teid; - smf_epc_pfcp_send_bearer_modification_request( - bearer, OGS_PFCP_MODIFY_ACTIVATE); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request( + bearer, OGS_PFCP_MODIFY_ACTIVATE)); } void smf_s5c_handle_update_bearer_response( @@ -506,7 +508,8 @@ void smf_s5c_handle_update_bearer_response( } if (pfcp_flags) - smf_epc_pfcp_send_bearer_modification_request(bearer, pfcp_flags); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request(bearer, pfcp_flags)); } void smf_s5c_handle_delete_bearer_response( @@ -577,8 +580,9 @@ void smf_s5c_handle_delete_bearer_response( ogs_debug("Delete Bearer Response : SGW[0x%x] --> SMF[0x%x]", sess->sgw_s5c_teid, sess->smf_n4_teid); - smf_epc_pfcp_send_bearer_modification_request( - bearer, OGS_PFCP_MODIFY_REMOVE); + ogs_assert(OGS_OK == + smf_epc_pfcp_send_bearer_modification_request( + bearer, OGS_PFCP_MODIFY_REMOVE)); } static int reconfigure_packet_filter(smf_pf_t *pf, ogs_gtp_tft_t *tft, int i) diff --git a/src/upf/gtp-path.c b/src/upf/gtp-path.c index f26eb5cae..b717f6df1 100644 --- a/src/upf/gtp-path.c +++ b/src/upf/gtp-path.c @@ -119,7 +119,8 @@ static void _gtpv1_tun_recv_cb(short when, ogs_socket_t fd, void *data) if (pdr->qer && pdr->qer->qfi) report.downlink_data.qfi = pdr->qer->qfi; /* for 5GC */ - upf_pfcp_send_session_report_request(sess, &report); + ogs_assert(OGS_OK == + upf_pfcp_send_session_report_request(sess, &report)); } cleanup: @@ -243,7 +244,8 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data) sess = UPF_SESS(far->sess); ogs_assert(sess); - upf_pfcp_send_session_report_request(sess, &report); + ogs_assert(OGS_OK == + upf_pfcp_send_session_report_request(sess, &report)); } } else { @@ -353,7 +355,8 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data) if (pdr->qer && pdr->qer->qfi) report.downlink_data.qfi = pdr->qer->qfi; /* for 5GC */ - upf_pfcp_send_session_report_request(sess, &report); + ogs_assert(OGS_OK == + upf_pfcp_send_session_report_request(sess, &report)); } } else if (far->dst_if == OGS_PFCP_INTERFACE_CP_FUNCTION) { @@ -530,4 +533,4 @@ static void upf_gtp_handle_multicast(ogs_pkbuf_t *recvbuf) } } } -} +} \ No newline at end of file diff --git a/src/upf/n4-handler.c b/src/upf/n4-handler.c index e5b81d733..96ea498d7 100644 --- a/src/upf/n4-handler.c +++ b/src/upf/n4-handler.c @@ -157,8 +157,9 @@ void upf_n4_handle_session_establishment_request( } } - upf_pfcp_send_session_establishment_response( - xact, sess, created_pdr, num_of_created_pdr); + ogs_assert(OGS_OK == + upf_pfcp_send_session_establishment_response( + xact, sess, created_pdr, num_of_created_pdr)); return; cleanup: @@ -370,8 +371,9 @@ void upf_n4_handle_session_modification_request( } } - upf_pfcp_send_session_modification_response( - xact, sess, created_pdr, num_of_created_pdr); + ogs_assert(OGS_OK == + upf_pfcp_send_session_modification_response( + xact, sess, created_pdr, num_of_created_pdr)); return; cleanup: diff --git a/src/upf/pfcp-path.c b/src/upf/pfcp-path.c index 2f9e82237..08e22e5fc 100644 --- a/src/upf/pfcp-path.c +++ b/src/upf/pfcp-path.c @@ -165,7 +165,7 @@ void upf_pfcp_close(void) ogs_socknode_remove_all(&ogs_pfcp_self()->pfcp_list6); } -void upf_pfcp_send_session_establishment_response( +int upf_pfcp_send_session_establishment_response( ogs_pfcp_xact_t *xact, upf_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr) { @@ -181,16 +181,18 @@ void upf_pfcp_send_session_establishment_response( n4buf = upf_n4_build_session_establishment_response( h.type, sess, created_pdr, num_of_created_pdr); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, n4buf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void upf_pfcp_send_session_modification_response( +int upf_pfcp_send_session_modification_response( ogs_pfcp_xact_t *xact, upf_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr) { @@ -207,16 +209,18 @@ void upf_pfcp_send_session_modification_response( n4buf = upf_n4_build_session_modification_response( h.type, sess, created_pdr, num_of_created_pdr); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, n4buf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } -void upf_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, +int upf_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, upf_sess_t *sess) { int rv; @@ -230,13 +234,15 @@ void upf_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, h.seid = sess->smf_n4_seid; n4buf = upf_n4_build_session_deletion_response(h.type, sess); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); rv = ogs_pfcp_xact_update_tx(xact, &h, n4buf); - ogs_expect_or_return(rv == OGS_OK); + ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); + + return rv; } static void sess_timeout(ogs_pfcp_xact_t *xact, void *data) @@ -256,7 +262,7 @@ static void sess_timeout(ogs_pfcp_xact_t *xact, void *data) } } -void upf_pfcp_send_session_report_request( +int upf_pfcp_send_session_report_request( upf_sess_t *sess, ogs_pfcp_user_plane_report_t *report) { int rv; @@ -272,12 +278,14 @@ void upf_pfcp_send_session_report_request( h.seid = sess->smf_n4_seid; n4buf = ogs_pfcp_build_session_report_request(h.type, report); - ogs_expect_or_return(n4buf); + ogs_expect_or_return_val(n4buf, OGS_ERROR); xact = ogs_pfcp_xact_local_create( sess->pfcp_node, &h, n4buf, sess_timeout, sess); - ogs_expect_or_return(xact); + ogs_expect_or_return_val(xact, OGS_ERROR); rv = ogs_pfcp_xact_commit(xact); ogs_expect(rv == OGS_OK); -} + + return rv; +} \ No newline at end of file diff --git a/src/upf/pfcp-path.h b/src/upf/pfcp-path.h index 4b06467be..a55e103b3 100644 --- a/src/upf/pfcp-path.h +++ b/src/upf/pfcp-path.h @@ -29,16 +29,16 @@ extern "C" { int upf_pfcp_open(void); void upf_pfcp_close(void); -void upf_pfcp_send_session_establishment_response( +int upf_pfcp_send_session_establishment_response( ogs_pfcp_xact_t *xact, upf_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr); -void upf_pfcp_send_session_modification_response( +int upf_pfcp_send_session_modification_response( ogs_pfcp_xact_t *xact, upf_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr); -void upf_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, +int upf_pfcp_send_session_deletion_response(ogs_pfcp_xact_t *xact, upf_sess_t *sess); -void upf_pfcp_send_session_report_request( +int upf_pfcp_send_session_report_request( upf_sess_t *sess, ogs_pfcp_user_plane_report_t *report); #ifdef __cplusplus