/******************************************************************************
-###############################################################################
-# Copyright (c) [2017-2020] [ICT/CAS] #
-# Licensed under the ORAN Software License v1.0 (License) #
-###############################################################################
-******************************************************************************/
+*
+* Copyright (c) 2020 ICT/CAS.
+*
+* Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* https://www.o-ran.org/software
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*******************************************************************************/
+
#include "vos_types.h"
#include "vos_string.h"
#include "vos_lib.h"
/*******************************************************************************
-* To
+* To
* INPUT:
-* :
+* :
* OUTPUT:
* 0:success
* -1:fail
-*******************************************************************************/
+*******************************************************************************/
INT32 pdcpuInit(ULONG userModuleId)
-{
+{
/* get pdcpu moduleId */
gPdcpuModuleId = userModuleId;
{
gPdcpuUeInfo[i] = NULL;
}
-
+
return VOS_OK;
}
VOS_Free(pDrbSecInfo);
gPdcpuUeInfo[ueIdx]->secInfo = NULL;
}
-
+
return VOS_OK;
}
/*******************************************************************************
* To deal with security indication
-* Security Result indicates whether the security policy indicated as "preferred"
+* Security Result indicates whether the security policy indicated as "preferred"
* in the Security Indication IE is performed or not.
* INPUT:
* ueE1apId : UE E1AP ID
* OUTPUT:
* 0:success
* -1:fail
-*******************************************************************************/
+*******************************************************************************/
INT32 pdcpuDealSecurityInd(PdcpuSecInfo_t *pSec, PdcpuSecEnableInfo_t *pEnableInfo, SecuInd_t *pSecInd, PdcpuCfgResult_t *pResult)
{
/* get security enable information global variable */
pdcpuNullCheck(pSec);
pdcpuNullCheck(pEnableInfo);
pdcpuNullCheck(pSecInd);
-
+
/* for integrity protection */
if(ACTIVE_INT_STATE == pSec->intActiveFlag)
{
pEnableInfo->integrityEnableFlag = TRUE;
pEnableInfo->maxIPDataRate = pSecInd->maxIPdataRate;
pResult->secResPresent = FALSE;
-
+
}else if(IP_PREFERRED == pSecInd->IPIndication)
- {
+ {
pEnableInfo->integrityEnableFlag = TRUE;
pEnableInfo->maxIPDataRate = pSecInd->maxIPdataRate;
pResult->secResPresent = TRUE;
pResult->secuResult.integrityProtectionResult= IP_RESULT_PERFORMED;
-
+
}else
{
pEnableInfo->integrityEnableFlag = FALSE;
pResult->secResPresent = FALSE;
-
+
}
-
+
}else
- {
+ {
/* integrity protection is inactive for the UE */
- pEnableInfo->integrityEnableFlag = FALSE;
+ pEnableInfo->integrityEnableFlag = FALSE;
if(IP_PREFERRED == pSecInd->IPIndication)
- {
+ {
pResult->secResPresent = TRUE;
- pResult->secuResult.integrityProtectionResult= IP_RESULT_NOT_PERFORMED;
+ pResult->secuResult.integrityProtectionResult= IP_RESULT_NOT_PERFORMED;
}
}
-
+
/* for ciphering */
if(ACTIVE_ENC_STATE == pSec->encActiveFlag)
{
/* ciphering is active for the UE, apply the indication */
if(CP_REQUIRED == pSecInd->CPIndication)
{
- pEnableInfo->cipherEnableFlag = TRUE;
+ pEnableInfo->cipherEnableFlag = TRUE;
pResult->secResPresent = FALSE;
-
+
}else if(CP_PREFERRED == pSecInd->CPIndication)
{
pEnableInfo->cipherEnableFlag = TRUE;
pResult->secResPresent = TRUE;
pResult->secuResult.confidentialityProtectionResult = CP_RESULT_PERFORMED;
-
+
}else
{
pEnableInfo->cipherEnableFlag = FALSE;
pResult->secResPresent = FALSE;
-
+
}
-
+
}else
- {
+ {
/* ciphering is inactive for the UE */
- pEnableInfo->cipherEnableFlag = FALSE;
+ pEnableInfo->cipherEnableFlag = FALSE;
if(CP_PREFERRED == pSecInd->CPIndication)
- {
+ {
pResult->secResPresent = TRUE;
- pResult->secuResult.confidentialityProtectionResult= CP_RESULT_NOT_PERFORMED;
+ pResult->secuResult.confidentialityProtectionResult= CP_RESULT_NOT_PERFORMED;
}
}
-
+
return VOS_OK;
}
}
pResult->drbSetupFailNum = pCfgInfo->drbSetupNum;
pResult->pduSessionCause = RNL_UNSPECIFIED;
-
+
}
-
+
return VOS_ERROR;
}
/*******************************************************************************
-* To deal with PDU session to setup config
+* To deal with PDU session to setup config
* INPUT:
* ueE1apId : UE E1AP ID
* pPduSessionCfg : PDU session to setup config
* pResult : PDU session to setup result
* OUTPUT:
* none
-*******************************************************************************/
+*******************************************************************************/
INT32 pdcpuSessionAddProc(UINT64 ueE1apId, VOID *pCfgInfo, PdcpuCfgResult_t *pResult)
{
upcTempSessInfo_t *pSetupInfo = (upcTempSessInfo_t *)pCfgInfo;
PdcpuSecEnableInfo_t *pEnableInfo = NULL;
UINT16 pduSessionId = pSetupInfo->pduSessId;
- pResult->pduSessionId = pduSessionId;
+ pResult->pduSessionId = pduSessionId;
/* get ueIdx */
- UINT16 ueIdx;
+ UINT16 ueIdx;
if(VOS_ERROR == cuupAddUeE1apid(ueE1apId, &ueIdx, &gPdcpuUeIdxTable))
{
pdcpuLog(LOG_ERR,"[PDCPU] add ueE1apId failed\n");
/* check ue and security context block */
if((NULL == gPdcpuUeInfo[ueIdx]) || (NULL == gPdcpuUeInfo[ueIdx]->secInfo))
- {
+ {
pdcpuLog(LOG_ERR,"[PDCPU] ue and security context block not exist\n");
return pdcpuRetFailResult(PDU_SESSION_ADD,pCfgInfo,pResult);
}
pSec = gPdcpuUeInfo[ueIdx]->secInfo;
-
+
/* alloc pdu session information */
pEnableInfo = gPdcpuUeInfo[ueIdx]->secEnableInfo[pduSessionId];
if(NULL == pEnableInfo)
}
pEnableInfo->pduSessionId = pduSessionId;
- /* deal with security indication */
+ /* deal with security indication */
if(VOS_ERROR == pdcpuDealSecurityInd(pSec, pEnableInfo, &pSetupInfo->secuIndi, pResult))
{
pdcpuLog(LOG_ERR,"[PDCPU] deal security indication failed\n");
return pdcpuRetFailResult(PDU_SESSION_ADD,pCfgInfo,pResult);
}
-
+
/* create pdcp entity */
- UINT8 i = 0;
+ UINT8 i = 0;
for(i = 0; i < pSetupInfo->drbSetupNum; i++)
{
pDrbTemp = &pSetupInfo->pTempDrbSetupList[i];
-
+
if((NULL == pDrbTemp) || (FALSE == pDrbTemp->drbSetupAllowed))
{
continue;
}
-
+
if(VOS_OK == pdcpuCreateEntity(ueE1apId, ueIdx, pduSessionId, pDrbTemp))
{
pResult->drbSetupSuccessArray[pResult->drbSetupSuccessNum] = pDrbTemp->drbId;
pResult->drbSetupSuccessNum += 1;
}else
- {
+ {
pResult->drbSetupFailedArray[pResult->drbSetupFailNum].drbId = pDrbTemp->drbId;
pResult->drbSetupFailedArray[pResult->drbSetupFailNum].cause = RNL_PDCP_CONFIG_NOT_SUPPORT;
pResult->drbSetupFailNum += 1;
-
+
}
}
}
/*******************************************************************************
- * To manage pdcp-u entity
+ * To manage pdcp-u entity
* INPUT:
* ueE1apId : UE E1AP ID
* pPduSessionCfg : PDU Session Resource to setup item
* result: PDCP config result
*******************************************************************************/
INT32 pdcpuConfig(UINT64 ueE1apId, VOID *pCfgInfo, UpcCfgType_e cfgType, PdcpuCfgResult_t *pResult)
-{
+{
switch(cfgType)
{
case PDU_SESSION_ADD:
VOS_MemZero(pResult, sizeof(PdcpuCfgResult_t));
pResult->cfgType = cfgType;
return pdcpuSessionAddProc(ueE1apId, pCfgInfo, pResult);
- }
+ }
default:
{
pdcpuLog(LOG_ERR,"[PDCPU] cfgType error\n");
*******************************************************************************/
PdcpuSecInfo_t *pdcpuAllocUeSecInfo(UINT16 ueIdx)
{
- PdcpuSecInfo_t *pSecInfo = NULL;
+ PdcpuSecInfo_t *pSecInfo = NULL;
PdcpuUeInfo_t *pPdcpUeInfo = NULL;
//check ue
if(NULL == gPdcpuUeInfo[ueIdx])
- {
+ {
pPdcpUeInfo = VOS_Malloc(sizeof(PdcpuUeInfo_t), gPdcpuModuleId);
pdcpuNullCheckRp(pPdcpUeInfo);
VOS_MemZero(pPdcpUeInfo, sizeof(PdcpuUeInfo_t));
}
//check secInfo
if(NULL == pPdcpUeInfo->secInfo)
- {
+ {
pSecInfo = VOS_Malloc(sizeof(PdcpuSecInfo_t), gPdcpuModuleId);
pdcpuNullCheckRp(pSecInfo);
VOS_MemZero(pSecInfo, sizeof(PdcpuSecInfo_t));
}
VOS_MemZero(pSecInfo, sizeof(PdcpuSecInfo_t));
-
+
return pSecInfo;
}
/*******************************************************************************
- * To set ue security parameters. When receiving security information,
- * pdcp-u shall save AS keys, AS algorithm and active integrity and ciphering.
+ * To set ue security parameters. When receiving security information,
+ * pdcp-u shall save AS keys, AS algorithm and active integrity and ciphering.
* INPUT:
* ueE1apId: UE E1AP ID
* secInfo: security information
INT32 pdcpuSetSecParam(UINT64 ueE1apId, SecuInfo_t *secInfo)
{
pdcpuNullCheck(secInfo);
-
- UINT16 ueIdx;
+
+ UINT16 ueIdx;
if(VOS_ERROR == cuupAddUeE1apid(ueE1apId, &ueIdx, &gPdcpuUeIdxTable))
{
pdcpuLog(LOG_ERR,"[PDCPU] add ueE1apId failed\n");
return VOS_ERROR;
}
-
+
/* find ue security struct */
PdcpuSecInfo_t *pDrbSecInfo = pdcpuAllocUeSecInfo(ueIdx);
pdcpuNullCheck(pDrbSecInfo);
-
+
/* activate integrity */
if(secInfo->secuAlgorithm.bitMask & SECURITY_ALGORITHM_INTERGRITY_PROTECTION_ALGORITHM)
- {
+ {
UINT8 intAlgorithm = secInfo->secuAlgorithm.integrityProtectionAlgorithm;
UINT8 *pIntKey = secInfo->upSecukey.integrityProtectionKey.buffer;
UINT8 intKeyLen = secInfo->upSecukey.integrityProtectionKey.size; /* 128 bits */
pdcpuFreeSecInfo(ueIdx);
return VOS_ERROR;
}
-
+
pDrbSecInfo->intActiveFlag = ACTIVE_INT_STATE; /* 0-inactive, 1-active */
if(intAlgorithm == NIA0 || intAlgorithm == NIA1 || intAlgorithm == NIA2)
{
pDrbSecInfo->intActiveFlag = INACTIVE_INT_STATE;
pdcpuLog(LOG_INFO,"[PDCPU] integrity is not config\n");
}
-
- /* activate encryption */
+
+ /* activate encryption */
UINT8 encAlgorithm = secInfo->secuAlgorithm.cipheringAlgorithm;
UINT8 *pEncKey = secInfo->upSecukey.encryptionKey.buffer;
UINT8 encKeyLen = secInfo->upSecukey.encryptionKey.size; /* 128 bits */
pDrbSecInfo->encActiveFlag = ACTIVE_ENC_STATE; /* 0-inactive, 1-active */
if(encAlgorithm == NEA0 || encAlgorithm == NEA1 || encAlgorithm == NEA2)
- {
- pDrbSecInfo->encAlgorithm = encAlgorithm;
+ {
+ pDrbSecInfo->encAlgorithm = encAlgorithm;
VOS_MemCpy(pDrbSecInfo->kUpEnc, pEncKey, AS_KEY_LEN); /* 128 bits */
}else
{
- pDrbSecInfo->encActiveFlag = INACTIVE_ENC_STATE;
+ pDrbSecInfo->encActiveFlag = INACTIVE_ENC_STATE;
pdcpuLog(LOG_ERR,"[PDCPU] encryption algorithm:%d, is not supported!\n", encAlgorithm);
pdcpuFreeSecInfo(ueIdx);
return VOS_ERROR;
pDrbSecInfo->ueE1apId = ueE1apId;
pDrbSecInfo->ueIdx = ueIdx;
pDrbSecInfo->nhInd = FALSE;
-
+
return VOS_OK;
}
-