Refactor handling of NGAP UE Context in ngap_gNB_handle_nas_first_req
this commit is refactoring the function ngap_gNB_handle_nas_first_req to (1) fill first a local instance of ngap_gNB_ue_context_t and then (2) pass it to ngap_store_ue_context which will allocate memory for the instance to store in ngap
This commit is contained in:
@@ -165,16 +165,13 @@ int ngap_gNB_handle_nas_first_req(instance_t instance, ngap_nas_first_req_t *UEf
|
|||||||
head->value.present = NGAP_InitiatingMessage__value_PR_InitialUEMessage;
|
head->value.present = NGAP_InitiatingMessage__value_PR_InitialUEMessage;
|
||||||
NGAP_InitialUEMessage_t *out = &head->value.choice.InitialUEMessage;
|
NGAP_InitialUEMessage_t *out = &head->value.choice.InitialUEMessage;
|
||||||
|
|
||||||
/* Store the UE context in NGAP with:
|
/* Create and store NGAP UE context */
|
||||||
* selected AMF, selected PLMN identity, gNB ID
|
ngap_gNB_ue_context_t ue_desc_p = {
|
||||||
* the unique gNB UE NGAP ID, used for the duration of the connectivity */
|
.amf_ref = amf,
|
||||||
struct ngap_gNB_ue_context_s *ue_desc_p = calloc_or_fail(1, sizeof(*ue_desc_p));
|
.gNB_ue_ngap_id = UEfirstReq->gNB_ue_ngap_id,
|
||||||
DevAssert(ue_desc_p != NULL);
|
.gNB_instance = instance_p,
|
||||||
ue_desc_p->amf_ref = amf;
|
.selected_plmn_identity = UEfirstReq->plmn,
|
||||||
ue_desc_p->gNB_ue_ngap_id = UEfirstReq->gNB_ue_ngap_id;
|
};
|
||||||
ue_desc_p->gNB_instance = instance_p;
|
|
||||||
ue_desc_p->selected_plmn_identity = UEfirstReq->plmn;
|
|
||||||
ngap_store_ue_context(ue_desc_p);
|
|
||||||
|
|
||||||
// RAN UE NGAP ID (M)
|
// RAN UE NGAP ID (M)
|
||||||
{
|
{
|
||||||
@@ -182,7 +179,7 @@ int ngap_gNB_handle_nas_first_req(instance_t instance, ngap_nas_first_req_t *UEf
|
|||||||
ie->id = NGAP_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
|
ie->id = NGAP_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
|
||||||
ie->criticality = NGAP_Criticality_reject;
|
ie->criticality = NGAP_Criticality_reject;
|
||||||
ie->value.present = NGAP_InitialUEMessage_IEs__value_PR_RAN_UE_NGAP_ID;
|
ie->value.present = NGAP_InitialUEMessage_IEs__value_PR_RAN_UE_NGAP_ID;
|
||||||
ie->value.choice.RAN_UE_NGAP_ID = ue_desc_p->gNB_ue_ngap_id;
|
ie->value.choice.RAN_UE_NGAP_ID = ue_desc_p.gNB_ue_ngap_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NAS-PDU (M): transferred transparently */
|
/* NAS-PDU (M): transferred transparently */
|
||||||
@@ -208,7 +205,7 @@ int ngap_gNB_handle_nas_first_req(instance_t instance, ngap_nas_first_req_t *UEf
|
|||||||
0, // Cell ID
|
0, // Cell ID
|
||||||
&userinfo_nr_p->nR_CGI.nRCellIdentity);
|
&userinfo_nr_p->nR_CGI.nRCellIdentity);
|
||||||
|
|
||||||
plmn_id_t *plmn = &ue_desc_p->selected_plmn_identity;
|
plmn_id_t *plmn = &ue_desc_p.selected_plmn_identity;
|
||||||
MCC_MNC_TO_TBCD(plmn->mcc, plmn->mnc, plmn->mnc_digit_length, &userinfo_nr_p->nR_CGI.pLMNIdentity);
|
MCC_MNC_TO_TBCD(plmn->mcc, plmn->mnc, plmn->mnc_digit_length, &userinfo_nr_p->nR_CGI.pLMNIdentity);
|
||||||
|
|
||||||
/* In case of network sharing,
|
/* In case of network sharing,
|
||||||
@@ -255,7 +252,7 @@ int ngap_gNB_handle_nas_first_req(instance_t instance, ngap_nas_first_req_t *UEf
|
|||||||
DevMessage("Failed to encode initial UE message\n");
|
DevMessage("Failed to encode initial UE message\n");
|
||||||
|
|
||||||
/* Update the current NGAP UE state */
|
/* Update the current NGAP UE state */
|
||||||
ue_desc_p->ue_state = NGAP_UE_WAITING_CSR;
|
ue_desc_p.ue_state = NGAP_UE_WAITING_CSR;
|
||||||
/* Assign a stream for this UE :
|
/* Assign a stream for this UE :
|
||||||
* From 3GPP 38.412 7)Transport layers:
|
* From 3GPP 38.412 7)Transport layers:
|
||||||
* Within the SCTP association established between one AMF and gNB pair:
|
* Within the SCTP association established between one AMF and gNB pair:
|
||||||
@@ -272,9 +269,13 @@ int ngap_gNB_handle_nas_first_req(instance_t instance, ngap_nas_first_req_t *UEf
|
|||||||
if ((amf->nextstream == 0) && (amf->out_streams > 1)) {
|
if ((amf->nextstream == 0) && (amf->out_streams > 1)) {
|
||||||
amf->nextstream += 1;
|
amf->nextstream += 1;
|
||||||
}
|
}
|
||||||
ue_desc_p->tx_stream = amf->nextstream;
|
ue_desc_p.tx_stream = amf->nextstream;
|
||||||
|
|
||||||
|
/* Create and store UE context */
|
||||||
|
ngap_store_ue_context(&ue_desc_p);
|
||||||
|
|
||||||
/* Send encoded message over sctp */
|
/* Send encoded message over sctp */
|
||||||
ngap_gNB_itti_send_sctp_data_req(instance_p->instance, amf->assoc_id, buffer, length, ue_desc_p->tx_stream);
|
ngap_gNB_itti_send_sctp_data_req(instance_p->instance, amf->assoc_id, buffer, length, ue_desc_p.tx_stream);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,11 @@ static int ngap_gNB_compare_gNB_ue_ngap_id(struct ngap_gNB_ue_context_s *p1, str
|
|||||||
RB_GENERATE(ngap_ue_map, ngap_gNB_ue_context_s, entries,
|
RB_GENERATE(ngap_ue_map, ngap_gNB_ue_context_s, entries,
|
||||||
ngap_gNB_compare_gNB_ue_ngap_id);
|
ngap_gNB_compare_gNB_ue_ngap_id);
|
||||||
|
|
||||||
void ngap_store_ue_context(struct ngap_gNB_ue_context_s *ue_desc_p)
|
void ngap_store_ue_context(const ngap_gNB_ue_context_t *ue)
|
||||||
{
|
{
|
||||||
|
LOG_I(NGAP, "Create UE context (ID %d) for AMF '%s' (assoc_id %d)\n", ue->gNB_ue_ngap_id, ue->amf_ref->amf_name, ue->amf_ref->assoc_id);
|
||||||
|
ngap_gNB_ue_context_t *ue_desc_p = calloc_or_fail(1, sizeof(*ue_desc_p));
|
||||||
|
*ue_desc_p = *ue;
|
||||||
if (RB_INSERT(ngap_ue_map, &ngap_ue_head, ue_desc_p))
|
if (RB_INSERT(ngap_ue_map, &ngap_ue_head, ue_desc_p))
|
||||||
LOG_E(NGAP, "Bug in UE uniq number allocation %u, we try to add a existing UE\n", ue_desc_p->gNB_ue_ngap_id);
|
LOG_E(NGAP, "Bug in UE uniq number allocation %u, we try to add a existing UE\n", ue_desc_p->gNB_ue_ngap_id);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ typedef struct ngap_gNB_ue_context_s {
|
|||||||
ngap_gNB_instance_t *gNB_instance;
|
ngap_gNB_instance_t *gNB_instance;
|
||||||
} ngap_gNB_ue_context_t;
|
} ngap_gNB_ue_context_t;
|
||||||
|
|
||||||
void ngap_store_ue_context(ngap_gNB_ue_context_t *ue_desc_p);
|
void ngap_store_ue_context(const ngap_gNB_ue_context_t *ue_desc_p);
|
||||||
|
|
||||||
ngap_gNB_ue_context_t *ngap_get_ue_context(uint32_t gNB_ue_ngap_id);
|
ngap_gNB_ue_context_t *ngap_get_ue_context(uint32_t gNB_ue_ngap_id);
|
||||||
ngap_gNB_ue_context_t *ngap_detach_ue_context(uint32_t gNB_ue_ngap_id);
|
ngap_gNB_ue_context_t *ngap_detach_ue_context(uint32_t gNB_ue_ngap_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user