Commit ce3b886f authored by Sakthivel Velumani's avatar Sakthivel Velumani

Included missing IEs in bearer cxt setup message

parent 1208ae0d
......@@ -112,6 +112,8 @@ typedef struct DRB_nGRAN_to_setup_s {
long sDAP_Header_DL;
long pDCP_SN_Size_UL;
long pDCP_SN_Size_DL;
long discardTimer;
long reorderingTimer;
long rLC_Mode;
int numCellGroups;
cell_group_t cellGroupList[E1AP_MAX_NUM_CELL_GROUPS];
......@@ -134,7 +136,9 @@ typedef struct pdu_session_to_setup_s {
typedef struct e1ap_bearer_setup_req_s {
uint64_t gNB_cu_cp_ue_id;
uint64_t cipheringAlgorithm;
uint64_t integrityProtectionAlgorithm;
char encryptionKey[128];
char integrityProtectionKey[128];
long ueDlAggMaxBitRate;
PLMN_ID_t servingPLMNid;
long activityNotificationLevel;
......
......@@ -538,6 +538,12 @@ int e1apCUCP_send_BEARER_CONTEXT_SETUP_REQUEST(instance_t instance,
ieC2->value.choice.SecurityInformation.securityAlgorithm.cipheringAlgorithm = bearerCxt->cipheringAlgorithm;
OCTET_STRING_fromBuf(&ieC2->value.choice.SecurityInformation.uPSecuritykey.encryptionKey,
bearerCxt->encryptionKey, strlen(bearerCxt->encryptionKey));
ieC2->value.choice.SecurityInformation.securityAlgorithm.integrityProtectionAlgorithm = (E1AP_IntegrityProtectionAlgorithm_t *) calloc(1, sizeof(E1AP_IntegrityProtectionAlgorithm_t));
*ieC2->value.choice.SecurityInformation.securityAlgorithm.integrityProtectionAlgorithm = bearerCxt->integrityProtectionAlgorithm;
ieC2->value.choice.SecurityInformation.uPSecuritykey.integrityProtectionKey = (E1AP_IntegrityProtectionKey_t *) calloc(1, sizeof(E1AP_IntegrityProtectionKey_t));
OCTET_STRING_fromBuf(ieC2->value.choice.SecurityInformation.uPSecuritykey.integrityProtectionKey,
bearerCxt->integrityProtectionKey, strlen(bearerCxt->integrityProtectionKey));
/* mandatory */
/* c3. UE DL Aggregate Maximum Bit Rate */
asn1cSequenceAdd(out->protocolIEs.list, E1AP_BearerContextSetupRequestIEs_t, ieC3);
......@@ -598,6 +604,10 @@ int e1apCUCP_send_BEARER_CONTEXT_SETUP_REQUEST(instance_t instance,
ieC6_1_1->pDCP_Configuration.pDCP_SN_Size_UL = j->pDCP_SN_Size_UL;
ieC6_1_1->pDCP_Configuration.pDCP_SN_Size_DL = j->pDCP_SN_Size_DL;
asn1cCallocOne(ieC6_1_1->pDCP_Configuration.discardTimer, j->discardTimer);
E1AP_T_ReorderingTimer_t *roTimer = calloc(1, sizeof(E1AP_T_ReorderingTimer_t));
ieC6_1_1->pDCP_Configuration.t_ReorderingTimer = roTimer;
roTimer->t_Reordering = j->reorderingTimer;
ieC6_1_1->pDCP_Configuration.rLC_Mode = j->rLC_Mode;
for (cell_group_t *k=j->cellGroupList; k < j->cellGroupList+j->numCellGroups; k++) {
......@@ -810,6 +820,14 @@ int e1apCUUP_handle_BEARER_CONTEXT_SETUP_REQUEST(instance_t instance,
memcpy(bearerCxt->encryptionKey,
ie->value.choice.SecurityInformation.uPSecuritykey.encryptionKey.buf,
ie->value.choice.SecurityInformation.uPSecuritykey.encryptionKey.size);
if (ie->value.choice.SecurityInformation.securityAlgorithm.integrityProtectionAlgorithm) {
bearerCxt->integrityProtectionAlgorithm = *ie->value.choice.SecurityInformation.securityAlgorithm.integrityProtectionAlgorithm;
}
if (ie->value.choice.SecurityInformation.uPSecuritykey.integrityProtectionKey) {
memcpy(bearerCxt->integrityProtectionKey,
ie->value.choice.SecurityInformation.uPSecuritykey.integrityProtectionKey->buf,
ie->value.choice.SecurityInformation.uPSecuritykey.integrityProtectionKey->size);
}
break;
case E1AP_ProtocolIE_ID_id_UEDLAggregateMaximumBitRate:
......
......@@ -61,6 +61,7 @@
#include <E1AP_GTPTunnel.h>
#include <E1AP_Non-Dynamic5QIDescriptor.h>
#include <E1AP_Dynamic5QIDescriptor.h>
#include <E1AP_T-ReorderingTimer.h>
#endif
......
......@@ -3868,11 +3868,80 @@ int rrc_gNB_process_e1_setup_req(e1ap_setup_req_t *req, instance_t instance) {
return 0;
}
void fill_DRB_configList(NR_DRB_ToAddModList_t *DRB_configList, pdu_session_to_setup_t *pdu) {
for (int i=0; i < pdu->numDRB2Setup; i++) {
DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + i;
asn1cSequenceAdd(DRB_configList->list, NR_DRB_ToAddMod_t, ie);
ie->drb_Identity = drb->id;
ie->cnAssociation = CALLOC(1, sizeof(*ie->cnAssociation));
ie->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config;
// sdap_Config
NR_SDAP_Config_t *sdap_config = ie->cnAssociation->choice.sdap_config;
sdap_config = CALLOC(1, sizeof(*sdap_config));
memset(sdap_config, 0, sizeof(*sdap_config));
sdap_config->pdu_Session = pdu->sessionId;
sdap_config->sdap_HeaderDL = drb->sDAP_Header_DL;
sdap_config->sdap_HeaderUL = drb->sDAP_Header_UL;
sdap_config->defaultDRB = drb->defaultDRB;
sdap_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
memset(sdap_config->mappedQoS_FlowsToAdd, 0, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
for (int j=0; j < numQosFlow2Setup; j++) {
NR_QFI_t *qfi = calloc(1, sizeof(NR_QFI_t));
*qfi = drb->qosFlows[j].fiveQI;
ASN_SEQUENCE_ADD(&sdap_config->mappedQoS_FlowsToAdd->list, qfi);
}
sdap_config->mappedQoS_FlowsToRelease = NULL;
// pdcp_Config
ie->reestablishPDCP = NULL;
ie->recoverPDCP = NULL;
NR_PDCP_Config_t *pdcp_config = ie->pdcp_Config;
pdcp_config = calloc(1, sizeof(*pdcp_config));
memset(pdcp_config, 0, sizeof(*pdcp_config));
pdcp_config->drb = calloc(1,sizeof(*pdcp_config->drb));
pdcp_config->drb->discardTimer = calloc(1, sizeof(*pdcp_config->drb->discardTimer));
*pdcp_config->drb->discardTimer = drb->discardTimer;
pdcp_config->drb->pdcp_SN_SizeUL = calloc(1, sizeof(*pdcp_config->drb->pdcp_SN_SizeUL));
*pdcp_config->drb->pdcp_SN_SizeUL = drb->pDCP_SN_Size_UL;
pdcp_config->drb->pdcp_SN_SizeDL = calloc(1, sizeof(*pdcp_config->drb->pdcp_SN_SizeDL));
*pdcp_config->drb->pdcp_SN_SizeDL = drb->pDCP_SN_Size_DL;
pdcp_config->drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
pdcp_config->drb->headerCompression.choice.notUsed = 0;
pdcp_config->drb->integrityProtection = NULL;
pdcp_config->drb->statusReportRequired = NULL;
pdcp_config->drb->outOfOrderDelivery = NULL;
pdcp_config->moreThanOneRLC = NULL;
pdcp_config->t_Reordering = calloc(1, sizeof(*drb->pdcp_config->t_Reordering));
*pdcp_config->t_Reordering = drb->reorderingTimer;
pdcp_config->ext1 = NULL;
if (drb->integrityProtectionIndication == 0 || // Required
drb->integrityProtectionIndication == 1) { // Preferred
pdcp_config->drb->integrityProtection = calloc(1, sizeof(*pdcp_config->drb->integrityProtection));
*pdcp_config->drb->integrityProtection = NR_PDCP_Config__drb__integrityProtection_enabled;
}
if (drb->confidentialityProtectionIndication == 0 || // Required
drb->confidentialityProtectionIndication == 1) { // Preferred
pdcp_config->ext1 = calloc(1, sizeof(*pdcp_config->ext1));
pdcp_config->ext1->cipheringDisabled = calloc(1, sizeof(*pdcp_config->ext1->cipheringDisabled));
*pdcp_config->ext1->cipheringDisabled = NR_PDCP_Config__ext1__cipheringDisabled_true;
}
}
}
int rrc_gNB_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *req, instance_t instance) {
gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0};
gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0};
NR_DRB_ToAddModList_t *DRB_configList;
for (int i=0; i < req->numPDUSessions; i++) {
pdu_session_to_setup_t *pdu = req->pduSession[i];
create_tunnel_req.pdusession_id[i] = pdu->sessionId;
......@@ -3881,6 +3950,7 @@ int rrc_gNB_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *req, in
pdu->tlAddress,
sizeof(uint8_t)*20);
create_tunnel_req.outgoing_teid = pdu->teID;
fill_DRB_configList(DRB_configList, pdu);
}
create_tunnel_req.num_tunnels = req->numPDUSessions;
create_tunnel_req.rnti = (req->gNB_cu_cp_ue_id & 0xFFFF);
......@@ -3890,6 +3960,17 @@ int rrc_gNB_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *req, in
&create_tunnel_req,
&create_tunnel_resp);
uint8_t *kRRCenc = NULL;
uint8_t *kRRCint = NULL;
nr_derive_key_rrc_enc(cipheringAlgorithm,
encryptionKey,
&kRRCenc);
nr_derive_key_rrc_int(integrityProtectionAlgorithm,
integrityProtectionKey,
&kRRCint);
return 0;
}
......
......@@ -997,7 +997,9 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(
bearer_req->gNB_cu_cp_ue_id = gNB_ue_ngap_id;
bearer_req->cipheringAlgorithm = ue_context_p->ue_context.ciphering_algorithm;
memcpy(bearer_req->encryptionKey, ue_context_p->ue_context.kgnb, 128);
memcpy(bearer_req->encryptionKey, ue_context_p->ue_context.kgnb, strlen(ue_context_p->ue_context.kgnb));
bearer_req->integrityProtectionAlgorithm = ue_context_pP->ue_context.integrity_algorithm;
memcpy(bearer_req->integrityProtectionKey, ue_context_pP->ue_context.kgnb, strlen(ue_context_p->ue_context.kgnb));
bearer_req->ueDlAggMaxBitRate = msg->ueAggMaxBitRateDownlink;
bearer_req->numPDUSessions = msg->nb_pdusessions_tosetup;
......@@ -1006,8 +1008,12 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(
pdu->sessionId = msg->pdusession_setup_params[i].pdusession_id;
pdu->sessionType = msg->pdusession_setup_params[i].upf_addr.pdu_session_type;
pdu->sst = msg->allowed_nssai[i].sST;
pdu->integrityProtectionIndication = 2; //E1AP_IntegrityProtectionIndication_not_needed; // Preferred. TODO: Remove hardcoding
pdu->confidentialityProtectionIndication = 2; //E1AP_ConfidentialityProtectionIndication_not_needed; // Preferred. TODO: Remove hardcoding
if (rrc->security.do_drb_integrity) {
pdu->integrityProtectionIndication = E1AP_IntegrityProtectionIndication_required;
}
if (rrc->security.do_drb_ciphering) {
pdu->confidentialityProtectionIndication = E1AP_ConfidentialityProtectionIndication_required;
}
pdu->teId = msg->pdusession_setup_params[i].gtp_teid;
memcpy(&pdu->tlAddress,
msg->pdusession_setup_params[i].upf_addr.buffer,
......@@ -1024,6 +1030,9 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(
drb->pDCP_SN_Size_UL = E1AP_PDCP_SN_Size_s_18;
drb->pDCP_SN_Size_DL = E1AP_PDCP_SN_Size_s_18;
drb->discardTimer = E1AP_DiscardTimer_infinity;
drb->reorderingTimer = E1AP_T_Reordering_ms0;
drb->rLC_Mode = E1AP_RLC_Mode_rlc_am;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment