Add InitialUEMessage And InitialContextSetupRequest Message
This commit is contained in:
@@ -195,6 +195,12 @@ typedef struct fiveg_s_tmsi_s {
|
||||
uint32_t m_tmsi;
|
||||
} fiveg_s_tmsi_t;
|
||||
|
||||
typedef struct ngap_tai_plmn_identity_s {
|
||||
uint16_t mcc;
|
||||
uint16_t mnc;
|
||||
uint8_t mnc_digit_length;
|
||||
} ngap_plmn_identity_t;
|
||||
|
||||
typedef struct ngap_ue_paging_identity_s {
|
||||
fiveg_s_tmsi_t s_tmsi;
|
||||
} ngap_ue_paging_identity_t;
|
||||
@@ -218,6 +224,10 @@ typedef struct ngap_nas_pdu_s {
|
||||
uint32_t length;
|
||||
} ngap_nas_pdu_t, ngap_ue_radio_cap_t;
|
||||
|
||||
typedef struct ngap_mobility_restriction_s{
|
||||
ngap_plmn_identity_t serving_plmn;
|
||||
}ngap_mobility_restriction_t;
|
||||
|
||||
typedef enum pdu_session_type_e {
|
||||
PDUSessionType_ipv4 = 0,
|
||||
PDUSessionType_ipv6 = 1,
|
||||
@@ -550,13 +560,16 @@ typedef struct ngap_initial_context_setup_req_s {
|
||||
uint8_t nb_of_pdusessions;
|
||||
/* list of pdusession to be setup by RRC layers */
|
||||
pdusession_t pdusession_param[NGAP_MAX_PDUSESSION];
|
||||
|
||||
/* Mobility Restriction List */
|
||||
uint8_t mobility_restriction_flag;
|
||||
ngap_mobility_restriction_t mobility_restriction;
|
||||
|
||||
/* Nas Pdu */
|
||||
uint8_t nas_pdu_flag;
|
||||
ngap_nas_pdu_t nas_pdu;
|
||||
} ngap_initial_context_setup_req_t;
|
||||
|
||||
typedef struct ngap_tai_plmn_identity_s {
|
||||
uint16_t mcc;
|
||||
uint16_t mnc;
|
||||
uint8_t mnc_digit_length;
|
||||
} ngap_plmn_identity_t;
|
||||
|
||||
typedef struct ngap_paging_ind_s {
|
||||
/* UE identity index value.
|
||||
|
||||
@@ -343,8 +343,7 @@ void RCconfig_nr_flexran()
|
||||
if (!GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr) {
|
||||
// Calculate a default gNB ID
|
||||
if (EPC_MODE_ENABLED)
|
||||
//gnb_id = i + (ngap_generate_gNB_id () & 0xFFFF8);
|
||||
gnb_id = i + (ngap_generate_gNB_id () & 0xFFFF8);
|
||||
gnb_id = i + (ngap_generate_gNB_id () & 0xFFFFFF8);
|
||||
else
|
||||
gnb_id = i;
|
||||
} else {
|
||||
@@ -571,9 +570,8 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
|
||||
// Calculate a default gNB ID
|
||||
if (EPC_MODE_ENABLED) {
|
||||
uint32_t hash;
|
||||
//hash = ngap_generate_gNB_id ();
|
||||
hash = ngap_generate_gNB_id ();
|
||||
gnb_id = i + (hash & 0xFFFF8);
|
||||
hash = ngap_generate_gNB_id ();
|
||||
gnb_id = i + (hash & 0xFFFFFF8);
|
||||
} else {
|
||||
gnb_id = i;
|
||||
}
|
||||
@@ -789,9 +787,8 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) {
|
||||
if (EPC_MODE_ENABLED) {
|
||||
uint32_t hash;
|
||||
|
||||
//hash = ngap_generate_gNB_id ();
|
||||
hash = ngap_generate_gNB_id ();
|
||||
gnb_id = k + (hash & 0xFFFF8);
|
||||
hash = ngap_generate_gNB_id ();
|
||||
gnb_id = k + (hash & 0xFFFFFF8);
|
||||
} else {
|
||||
gnb_id = k;
|
||||
}
|
||||
@@ -1039,9 +1036,8 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) {
|
||||
// Calculate a default eNB ID
|
||||
if (EPC_MODE_ENABLED) {
|
||||
uint32_t hash;
|
||||
//hash = ngap_generate_gNB_id ();
|
||||
hash = ngap_generate_gNB_id ();
|
||||
gnb_id = k + (hash & 0xFFFF8);
|
||||
hash = ngap_generate_gNB_id ();
|
||||
gnb_id = k + (hash & 0xFFFFFF8);
|
||||
} else {
|
||||
gnb_id = k;
|
||||
}
|
||||
|
||||
@@ -126,11 +126,14 @@ struct served_guami_s {
|
||||
};
|
||||
|
||||
/* NSSAI element */
|
||||
typedef struct ngap_gNB_NSSAI_s{
|
||||
struct slice_support_s{
|
||||
uint8_t sST;
|
||||
uint8_t sD_flag;
|
||||
uint8_t sD[3];
|
||||
}ngap_gNB_NSSAI_t, slice_support_s;
|
||||
|
||||
/* Next slice element */
|
||||
STAILQ_ENTRY(slice_support_s) next;
|
||||
};
|
||||
|
||||
|
||||
/* plmn support element */
|
||||
@@ -206,6 +209,12 @@ typedef struct ngap_gNB_amf_data_s {
|
||||
struct ngap_gNB_instance_s *ngap_gNB_instance;
|
||||
} ngap_gNB_amf_data_t;
|
||||
|
||||
typedef struct ngap_gNB_NSSAI_s{
|
||||
uint8_t sST;
|
||||
uint8_t sD_flag;
|
||||
uint8_t sD[3];
|
||||
}ngap_gNB_NSSAI_t;
|
||||
|
||||
typedef struct ngap_gNB_instance_s {
|
||||
/* Next ngap gNB association.
|
||||
* Only used for virtual mode.
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
#include "assertions.h"
|
||||
#include "conversions.h"
|
||||
#include "msc.h"
|
||||
#include "NGAP_PDUSessionResourceSetupRequestTransfer.h"
|
||||
#include "NGAP_PDUSessionResourceSetupItemCxtReq.h"
|
||||
#include "NGAP_QosFlowSetupRequestItem.h"
|
||||
#include "NGAP_AllowedNSSAI-Item.h"
|
||||
|
||||
static
|
||||
int ngap_gNB_handle_ng_setup_response(uint32_t assoc_id,
|
||||
@@ -297,7 +301,6 @@ static
|
||||
int ngap_gNB_handle_ng_setup_response(uint32_t assoc_id,
|
||||
uint32_t stream,
|
||||
NGAP_NGAP_PDU_t *pdu) {
|
||||
#if 0
|
||||
NGAP_NGSetupResponse_t *container;
|
||||
NGAP_NGSetupResponseIEs_t *ie;
|
||||
ngap_gNB_amf_data_t *amf_desc_p;
|
||||
@@ -447,7 +450,7 @@ int ngap_gNB_handle_ng_setup_response(uint32_t assoc_id,
|
||||
amf_desc_p->state = NGAP_GNB_STATE_CONNECTED;
|
||||
amf_desc_p->ngap_gNB_instance->ngap_amf_associated_nb ++;
|
||||
ngap_handle_ng_setup_message(amf_desc_p, 0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -794,7 +797,7 @@ static
|
||||
int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
|
||||
uint32_t stream,
|
||||
NGAP_NGAP_PDU_t *pdu) {
|
||||
#if 0
|
||||
|
||||
int i;
|
||||
ngap_gNB_amf_data_t *amf_desc_p = NULL;
|
||||
ngap_gNB_ue_context_t *ue_desc_p = NULL;
|
||||
@@ -802,7 +805,7 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
|
||||
NGAP_InitialContextSetupRequest_t *container;
|
||||
NGAP_InitialContextSetupRequestIEs_t *ie;
|
||||
NGAP_RAN_UE_NGAP_ID_t ran_ue_ngap_id;
|
||||
NGAP_AMF_UE_NGAP_ID_t amf_ue_ngap_id;
|
||||
uint64_t amf_ue_ngap_id;
|
||||
DevAssert(pdu != NULL);
|
||||
container = &pdu->choice.initiatingMessage.value.choice.InitialContextSetupRequest;
|
||||
|
||||
@@ -817,7 +820,7 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
|
||||
NGAP_ProtocolIE_ID_id_AMF_UE_NGAP_ID, true);
|
||||
|
||||
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
|
||||
amf_ue_ngap_id = ie->value.choice.AMF_UE_NGAP_ID;
|
||||
asn_INTEGER2ulong(&(ie->value.choice.AMF_UE_NGAP_ID), &amf_ue_ngap_id);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -849,6 +852,7 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
|
||||
|
||||
ue_desc_p->rx_stream = stream;
|
||||
ue_desc_p->amf_ue_ngap_id = amf_ue_ngap_id;
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_NGAP, NGAP_INITIAL_CONTEXT_SETUP_REQ);
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_initial_id = ue_desc_p->ue_initial_id;
|
||||
ue_desc_p->ue_initial_id = 0;
|
||||
@@ -873,10 +877,6 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
|
||||
NGAP_ProtocolIE_ID_id_GUAMI, true);
|
||||
|
||||
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
|
||||
ie->value.choice.GUAMI.pLMNIdentity
|
||||
ie->value.choice.GUAMI.aMFRegionID
|
||||
ie->value.choice.GUAMI.aMFSetID
|
||||
ie->value.choice.GUAMI.aMFPointer
|
||||
TBCD_TO_MCC_MNC(&ie->value.choice.GUAMI.pLMNIdentity, NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).guami.mcc,
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).guami.mnc, NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).guami.mnc_len);
|
||||
|
||||
@@ -1065,17 +1065,50 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* id-MobilityRestrictionList */
|
||||
NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container,
|
||||
NGAP_ProtocolIE_ID_id_SecurityKey, true);
|
||||
|
||||
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
|
||||
memcpy(&NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_key,
|
||||
ie->value.choice.SecurityKey.buf, ie->value.choice.SecurityKey.size);
|
||||
itti_send_msg_to_task(TASK_RRC_GNB, ue_desc_p->gNB_instance->instance, message_p);
|
||||
|
||||
} else {/* ie != NULL */
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* id-NAS-PDU */
|
||||
NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container,
|
||||
NGAP_ProtocolIE_ID_id_MobilityRestrictionList, false);
|
||||
|
||||
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
|
||||
NGAP_MobilityRestrictionList_t *mobility_rest_list_p = NULL;
|
||||
mobility_rest_list_p = &ie->value.choice.MobilityRestrictionList;
|
||||
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).mobility_restriction_flag = 1;
|
||||
TBCD_TO_MCC_MNC(&mobility_rest_list_p->servingPLMN,
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).mobility_restriction.serving_plmn.mcc,
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).mobility_restriction.serving_plmn.mnc,
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).mobility_restriction.serving_plmn.mnc_digit_length);
|
||||
}
|
||||
|
||||
|
||||
NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container,
|
||||
NGAP_ProtocolIE_ID_id_NAS_PDU, false);
|
||||
|
||||
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
|
||||
if(ie->value.choice.NAS_PDU.size > 0) {
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nas_pdu_flag = 1;
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nas_pdu.length = ie->value.choice.NAS_PDU.size;
|
||||
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nas_pdu.buffer = malloc(sizeof(uint8_t) * ie->value.choice.NAS_PDU.size);
|
||||
memcpy(NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nas_pdu.buffer,
|
||||
ie->value.choice.NAS_PDU.buf, ie->value.choice.NAS_PDU.size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
itti_send_msg_to_task(TASK_RRC_GNB, ue_desc_p->gNB_instance->instance, message_p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ int ngap_gNB_handle_nas_first_req(
|
||||
instance_t instance, ngap_nas_first_req_t *ngap_nas_first_req_p)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
#if 0
|
||||
ngap_gNB_instance_t *instance_p = NULL;
|
||||
struct ngap_gNB_amf_data_s *amf_desc_p = NULL;
|
||||
struct ngap_gNB_ue_context_s *ue_desc_p = NULL;
|
||||
@@ -315,7 +314,7 @@ int ngap_gNB_handle_nas_first_req(
|
||||
/* Send encoded message over sctp */
|
||||
ngap_gNB_itti_send_sctp_data_req(instance_p->instance, amf_desc_p->assoc_id,
|
||||
buffer, length, ue_desc_p->tx_stream);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -656,7 +655,7 @@ int ngap_gNB_initial_ctxt_resp(
|
||||
if ((ue_context_p = ngap_gNB_get_ue_context(ngap_gNB_instance_p,
|
||||
initial_ctxt_resp_p->gNB_ue_ngap_id)) == NULL) {
|
||||
/* The context for this gNB ue ngap id doesn't exist in the map of gNB UEs */
|
||||
NGAP_WARN("Failed to find ue context associated with gNB ue ngap id: 0x%06x\n",
|
||||
NGAP_WARN("Failed to find ue context associated with gNB ue ngap id: 0x%08x\n",
|
||||
initial_ctxt_resp_p->gNB_ue_ngap_id);
|
||||
return -1;
|
||||
}
|
||||
@@ -688,10 +687,10 @@ int ngap_gNB_initial_ctxt_resp(
|
||||
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
|
||||
/* mandatory */
|
||||
ie = (NGAP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(NGAP_InitialContextSetupResponseIEs_t));
|
||||
ie->id = NGAP_ProtocolIE_ID_id_gNB_UE_NGAP_ID;
|
||||
ie->id = NGAP_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
|
||||
ie->criticality = NGAP_Criticality_ignore;
|
||||
ie->value.present = NGAP_InitialContextSetupResponseIEs__value_PR_GNB_UE_NGAP_ID;
|
||||
ie->value.choice.GNB_UE_NGAP_ID = initial_ctxt_resp_p->gNB_ue_ngap_id;
|
||||
ie->value.present = NGAP_InitialContextSetupResponseIEs__value_PR_RAN_UE_NGAP_ID;
|
||||
ie->value.choice.RAN_UE_NGAP_ID = initial_ctxt_resp_p->gNB_ue_ngap_id;
|
||||
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
|
||||
/* mandatory */
|
||||
ie = (NGAP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(NGAP_InitialContextSetupResponseIEs_t));
|
||||
|
||||
@@ -339,7 +339,7 @@ ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_t *instance_p
|
||||
struct ngap_gNB_amf_data_s *amf_highest_capacity_p = NULL;
|
||||
uint8_t current_capacity = 0;
|
||||
|
||||
#if 0
|
||||
|
||||
RB_FOREACH(amf_data_p, ngap_amf_map, &instance_p->ngap_amf_head) {
|
||||
struct served_guami_s *guami_p = NULL;
|
||||
|
||||
@@ -366,9 +366,9 @@ ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_t *instance_p
|
||||
|
||||
/* Looking for AMF guami matching the one provided by NAS */
|
||||
STAILQ_FOREACH(guami_p, &amf_data_p->served_guami, next) {
|
||||
struct served_group_id_s *group_id_p = NULL;
|
||||
struct amf_code_s *amf_code_p = NULL;
|
||||
struct plmn_identity_s *served_plmn_p = NULL;
|
||||
struct served_region_id_s *region_id_p = NULL;
|
||||
struct amf_set_id_s *amf_set_id_p = NULL;
|
||||
struct plmn_identity_s *served_plmn_p = NULL;
|
||||
|
||||
STAILQ_FOREACH(served_plmn_p, &guami_p->served_plmns, next) {
|
||||
if ((served_plmn_p->mcc == guami.mcc) &&
|
||||
@@ -376,13 +376,13 @@ ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_t *instance_p
|
||||
break;
|
||||
}
|
||||
}
|
||||
STAILQ_FOREACH(amf_code_p, &guami_p->amf_codes, next) {
|
||||
if (amf_code_p->amf_code == guami.amf_code) {
|
||||
STAILQ_FOREACH(amf_set_id_p, &guami_p->amf_set_ids, next) {
|
||||
if (amf_set_id_p->amf_set_id == guami.amf_set_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
STAILQ_FOREACH(group_id_p, &guami_p->served_group_ids, next) {
|
||||
if (group_id_p->amf_group_id == guami.amf_group_id) {
|
||||
STAILQ_FOREACH(region_id_p, &guami_p->served_region_ids, next) {
|
||||
if (region_id_p->amf_region_id == guami.amf_region_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -391,8 +391,8 @@ ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_t *instance_p
|
||||
* the AMF is knwown and the association is ready.
|
||||
* Return the reference to the AMF to use it for this UE.
|
||||
*/
|
||||
if ((group_id_p != NULL) &&
|
||||
(amf_code_p != NULL) &&
|
||||
if ((region_id_p != NULL) &&
|
||||
(amf_set_id_p != NULL) &&
|
||||
(served_plmn_p != NULL)) {
|
||||
return amf_data_p;
|
||||
}
|
||||
@@ -404,6 +404,6 @@ ngap_gNB_nnsf_select_amf_by_guami_no_cause(ngap_gNB_instance_t *instance_p
|
||||
* In case the list of known AMF is empty, simply return NULL, that way the RRC
|
||||
* layer should know about it and reject RRC connectivity.
|
||||
*/
|
||||
#endif
|
||||
|
||||
return amf_highest_capacity_p;
|
||||
}
|
||||
|
||||
@@ -47,15 +47,15 @@ typedef struct ngap_gNB_ue_context_s {
|
||||
RB_ENTRY(ngap_gNB_ue_context_s) entries;
|
||||
|
||||
/* Uniquely identifies the UE between AMF and gNB within the gNB.
|
||||
* This id is encoded on 24bits.
|
||||
* This id is encoded on 32bits.
|
||||
*/
|
||||
unsigned gNB_ue_ngap_id:24;
|
||||
uint32_t gNB_ue_ngap_id;
|
||||
|
||||
/* UE id for initial connection to NGAP */
|
||||
uint16_t ue_initial_id;
|
||||
|
||||
/* Uniquely identifies the UE within AMF. Encoded on 32 bits. */
|
||||
uint32_t amf_ue_ngap_id;
|
||||
uint64_t amf_ue_ngap_id:40;
|
||||
|
||||
/* Stream used for this particular UE */
|
||||
int32_t tx_stream;
|
||||
|
||||
@@ -506,11 +506,12 @@ do { \
|
||||
|
||||
#define MACRO_GNB_ID_TO_BIT_STRING(mACRO, bITsTRING) \
|
||||
do { \
|
||||
(bITsTRING)->buf = calloc(3, sizeof(uint8_t)); \
|
||||
(bITsTRING)->buf[0] = ((mACRO) >> 12); \
|
||||
(bITsTRING)->buf[1] = (mACRO) >> 4; \
|
||||
(bITsTRING)->buf[2] = ((mACRO) & 0x0f) << 4; \
|
||||
(bITsTRING)->size = 3; \
|
||||
(bITsTRING)->buf = calloc(4, sizeof(uint8_t)); \
|
||||
(bITsTRING)->buf[0] = ((mACRO) >> 20); \
|
||||
(bITsTRING)->buf[1] = (mACRO) >> 12; \
|
||||
(bITsTRING)->buf[3] = (mACRO) >> 4; \
|
||||
(bITsTRING)->buf[4] = ((mACRO) & 0x0f) << 4; \
|
||||
(bITsTRING)->size = 4; \
|
||||
(bITsTRING)->bits_unused = 4; \
|
||||
} while(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user