Clarify code for pull request (#223)

This commit is contained in:
Sukchan Lee 2019-07-14 11:00:11 +09:00
parent 79a952d910
commit 99d91da6eb
7 changed files with 101 additions and 45 deletions

View File

@ -71,18 +71,15 @@ int emm_handle_attach_request(
* ATTACH_REQUEST
* Clear EBI generator
* Clear Paging Timer and Message
* Update KeNB
*
* TAU_REQUEST
* Clear Paging Timer and Message
*
* SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*
* EXTENDED_SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*/
CLEAR_EPS_BEARER_ID(mme_ue);
CLEAR_PAGING_INFO(mme_ue);
@ -376,18 +373,15 @@ int emm_handle_service_request(
* ATTACH_REQUEST
* Clear EBI generator
* Clear Paging Timer and Message
* Update KeNB
*
* TAU_REQUEST
* Clear Paging Timer and Message
*
* SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*
* EXTENDED_SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*/
CLEAR_PAGING_INFO(mme_ue);
if (SECURITY_CONTEXT_IS_VALID(mme_ue)) {
@ -436,18 +430,15 @@ int emm_handle_tau_request(
* ATTACH_REQUEST
* Clear EBI generator
* Clear Paging Timer and Message
* Update KeNB
*
* TAU_REQUEST
* Clear Paging Timer and Message
*
* SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*
* EXTENDED_SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*/
CLEAR_PAGING_INFO(mme_ue);
CLEAR_SERVICE_INDICATOR(mme_ue);
@ -569,25 +560,24 @@ int emm_handle_extended_service_request(
* ATTACH_REQUEST
* Clear EBI generator
* Clear Paging Timer and Message
* Update KeNB
*
* TAU_REQUEST
* Clear Paging Timer and Message
*
* SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*
* EXTENDED_SERVICE_REQUEST
* Clear Paging Timer and Message
* Update KeNB
*/
CLEAR_PAGING_INFO(mme_ue);
#if KeNB_Should_Not_Refreshed
if (SECURITY_CONTEXT_IS_VALID(mme_ue)) {
mme_kdf_enb(mme_ue->kasme, mme_ue->ul_count.i32, mme_ue->kenb);
mme_kdf_nh(mme_ue->kasme, mme_ue->kenb, mme_ue->nh);
mme_ue->nhcc = 1;
}
#endif
ogs_debug(" OLD TAI[PLMN_ID:%06x,TAC:%d]",
plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac);

View File

@ -426,7 +426,6 @@ static void common_register_state(ogs_fsm_t *s, mme_event_t *e)
ogs_assert_if_reached();
}
CLEAR_SERVICE_INDICATOR(mme_ue);
break;
default:
ogs_fatal("Invalid NAS-EPS[%d]", mme_ue->nas_eps.type);

View File

@ -2011,6 +2011,9 @@ void mme_ue_remove(mme_ue_t *mme_ue)
/* Clear Paging info : stop t3413, last_paing_msg */
CLEAR_PAGING_INFO(mme_ue);
/* Clear Service Indicator */
CLEAR_SERVICE_INDICATOR(mme_ue);
/* Free UeRadioCapability */
S1AP_CLEAR_DATA(&mme_ue->ueRadioCapability);

View File

@ -17,8 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MME_CONTEXT
#define MME_CONTEXT
#ifndef MME_CONTEXT_H
#define MME_CONTEXT_H
#include "ogs-crypt.h"
#include "base/types.h"
@ -423,6 +423,13 @@ struct mme_ue_s {
} while(0);
#define SGSAP_CS_CALL_SERVICE_INDICATOR 1
#define SGSAP_SMS_SERVICE_INDICATOR 2
#define CS_CALL_SERVICE_INDICATOR(__mME) \
(MME_P_TMSI_IS_AVAILABLE(__mME) && \
((__mME)->service_indicator) == SGSAP_CS_CALL_SERVICE_INDICATOR)
#define SMS_SERVICE_INDICATOR(__mME) \
(MME_P_TMSI_IS_AVAILABLE(__mME) && \
((__mME)->service_indicator) == SGSAP_SMS_SERVICE_INDICATOR)
uint8_t service_indicator;
/* UE Radio Capability */
@ -744,4 +751,4 @@ uint8_t mme_selected_enc_algorithm(mme_ue_t *mme_ue);
}
#endif
#endif /* MME_CONTEXT */
#endif /* MME_CONTEXT_H */

View File

@ -572,6 +572,8 @@ int s1ap_build_ue_context_modification_request(
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
S1AP_UESecurityCapabilities_t *UESecurityCapabilities = NULL;
S1AP_SecurityKey_t *SecurityKey = NULL;
S1AP_CSFallbackIndicator_t *CSFallbackIndicator = NULL;
S1AP_LAI_t *LAI = NULL;
@ -624,35 +626,81 @@ int s1ap_build_ue_context_modification_request(
ogs_debug(" ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
ie = ogs_calloc(1, sizeof(S1AP_UEContextModificationRequestIEs_t));
ASN_SEQUENCE_ADD(&UEContextModificationRequest->protocolIEs, ie);
if (mme_ue->nas_eps.type == MME_EPS_TYPE_EXTENDED_SERVICE_REQUEST &&
MME_P_TMSI_IS_AVAILABLE(mme_ue)) {
ie = ogs_calloc(1, sizeof(S1AP_UEContextModificationRequestIEs_t));
ASN_SEQUENCE_ADD(&UEContextModificationRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_CSFallbackIndicator;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_UEContextModificationRequestIEs__value_PR_CSFallbackIndicator;
ie->id = S1AP_ProtocolIE_ID_id_CSFallbackIndicator;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_UEContextModificationRequestIEs__value_PR_CSFallbackIndicator;
CSFallbackIndicator = &ie->value.choice.CSFallbackIndicator;
ogs_assert(CSFallbackIndicator);
CSFallbackIndicator = &ie->value.choice.CSFallbackIndicator;
ogs_assert(CSFallbackIndicator);
*CSFallbackIndicator = S1AP_CSFallbackIndicator_cs_fallback_required;
*CSFallbackIndicator = S1AP_CSFallbackIndicator_cs_fallback_required;
ie = ogs_calloc(1, sizeof(S1AP_UEContextModificationRequestIEs_t));
ASN_SEQUENCE_ADD(&UEContextModificationRequest->protocolIEs, ie);
ie = ogs_calloc(1, sizeof(S1AP_UEContextModificationRequestIEs_t));
ASN_SEQUENCE_ADD(&UEContextModificationRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_RegisteredLAI;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present =
S1AP_UEContextModificationRequestIEs__value_PR_LAI;
ie->id = S1AP_ProtocolIE_ID_id_RegisteredLAI;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present =
S1AP_UEContextModificationRequestIEs__value_PR_LAI;
LAI = &ie->value.choice.LAI;
ogs_assert(LAI);
LAI = &ie->value.choice.LAI;
ogs_assert(LAI);
s1ap_buffer_to_OCTET_STRING(&mme_ue->tai.plmn_id, sizeof(plmn_id_t),
&LAI->pLMNidentity);
ogs_assert(mme_ue->vlr);
ogs_assert(mme_ue->p_tmsi);
s1ap_uint16_to_OCTET_STRING(mme_ue->vlr->lai.lac, &LAI->lAC);
s1ap_buffer_to_OCTET_STRING(&mme_ue->tai.plmn_id, sizeof(plmn_id_t),
&LAI->pLMNidentity);
ogs_assert(mme_ue->vlr);
ogs_assert(mme_ue->p_tmsi);
s1ap_uint16_to_OCTET_STRING(mme_ue->vlr->lai.lac, &LAI->lAC);
} else {
ie = ogs_calloc(1, sizeof(S1AP_UEContextModificationRequestIEs_t));
ASN_SEQUENCE_ADD(&UEContextModificationRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_UESecurityCapabilities;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_UEContextModificationRequestIEs__value_PR_UESecurityCapabilities;
UESecurityCapabilities = &ie->value.choice.UESecurityCapabilities;
UESecurityCapabilities->encryptionAlgorithms.size = 2;
UESecurityCapabilities->encryptionAlgorithms.buf =
ogs_calloc(UESecurityCapabilities->encryptionAlgorithms.size,
sizeof(uint8_t));
UESecurityCapabilities->encryptionAlgorithms.bits_unused = 0;
UESecurityCapabilities->encryptionAlgorithms.buf[0] =
(mme_ue->ue_network_capability.eea << 1);
UESecurityCapabilities->integrityProtectionAlgorithms.size = 2;
UESecurityCapabilities->integrityProtectionAlgorithms.buf =
ogs_calloc(UESecurityCapabilities->
integrityProtectionAlgorithms.size, sizeof(uint8_t));
UESecurityCapabilities->integrityProtectionAlgorithms.bits_unused = 0;
UESecurityCapabilities->integrityProtectionAlgorithms.buf[0] =
(mme_ue->ue_network_capability.eia << 1);
ie = ogs_calloc(1, sizeof(S1AP_UEContextModificationRequestIEs_t));
ASN_SEQUENCE_ADD(&UEContextModificationRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_SecurityKey;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_UEContextModificationRequestIEs__value_PR_SecurityKey;
SecurityKey = &ie->value.choice.SecurityKey;
SecurityKey->size = OGS_SHA256_DIGEST_SIZE;
SecurityKey->buf =
ogs_calloc(SecurityKey->size, sizeof(uint8_t));
SecurityKey->bits_unused = 0;
memcpy(SecurityKey->buf, mme_ue->kenb, SecurityKey->size);
}
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);

View File

@ -517,7 +517,7 @@ void s1ap_handle_initial_context_setup_response(
}
}
if (mme_ue->service_indicator == SGSAP_SMS_SERVICE_INDICATOR) {
if (SMS_SERVICE_INDICATOR(mme_ue)) {
sgsap_send_service_request(mme_ue, SGSAP_EMM_CONNECTED_MODE);
}
@ -577,7 +577,7 @@ void s1ap_handle_initial_context_setup_failure(
if (enb_ue == NULL) {
ogs_warn("Initial context setup failure : "
"cannot find eNB-UE-S1AP-ID[%d]", (int)*ENB_UE_S1AP_ID);
return;
goto cleanup;
}
mme_ue = enb_ue->mme_ue;
@ -606,6 +606,9 @@ void s1ap_handle_initial_context_setup_failure(
rv = mme_send_delete_session_or_ue_context_release(mme_ue, enb_ue);
ogs_assert(rv == OGS_OK);
}
cleanup:
CLEAR_SERVICE_INDICATOR(mme_ue);
}
void s1ap_handle_ue_context_modification_response(
@ -658,6 +661,7 @@ void s1ap_handle_ue_context_modification_response(
ogs_debug(" ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
CLEAR_SERVICE_INDICATOR(mme_ue);
}
void s1ap_handle_ue_context_modification_failure(
@ -674,6 +678,7 @@ void s1ap_handle_ue_context_modification_failure(
S1AP_Cause_t *Cause = NULL;
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
ogs_assert(enb);
ogs_assert(enb->sock);
@ -711,13 +716,18 @@ void s1ap_handle_ue_context_modification_failure(
if (enb_ue == NULL) {
ogs_warn("Initial context setup failure : "
"cannot find eNB-UE-S1AP-ID[%d]", (int)*ENB_UE_S1AP_ID);
return;
goto cleanup;
}
ogs_debug(" ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
ogs_debug(" Cause[Group:%d Cause:%d]",
Cause->present, (int)Cause->choice.radioNetwork);
cleanup:
mme_ue = enb_ue->mme_ue;
ogs_assert(mme_ue);
CLEAR_SERVICE_INDICATOR(mme_ue);
}

View File

@ -21,6 +21,7 @@
#include "sgsap-build.h"
#include "sgsap-path.h"
#include "mme-sm.h"
#include "mme-context.h"
#include "mme-path.h"
#include "nas-conv.h"
@ -319,13 +320,11 @@ void sgsap_handle_paging_request(mme_vlr_t *vlr, ogs_pkbuf_t *pkbuf)
}
if (ECM_IDLE(mme_ue)) {
if (mme_ue->service_indicator ==
SGSAP_CS_CALL_SERVICE_INDICATOR) {
if (CS_CALL_SERVICE_INDICATOR(mme_ue)) {
/* UE will respond Extended Service Request in PS CNDomain*/
s1ap_send_paging(mme_ue, S1AP_CNDomain_cs);
} else if (mme_ue->service_indicator ==
SGSAP_SMS_SERVICE_INDICATOR) {
} else if (SMS_SERVICE_INDICATOR(mme_ue)) {
/* UE will respond Service Request in PS CNDomain*/
s1ap_send_paging(mme_ue, S1AP_CNDomain_ps);
} else