X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=Cu%2FCuUp%2FPdcp%2FPdcpUp%2FSrc%2FpdcpuUpc.c;fp=Cu%2FCuUp%2FPdcp%2FPdcpUp%2FSrc%2FpdcpuUpc.c;h=6def3a94e7910d0620f20ff015401ef8a64d2576;hb=e93798699eccb72af04938fc9b0d7a836e284488;hp=36ba83b35071e40d969dd5f721cf1b83a790dcbf;hpb=94f13ab3e8da393eb27ccc561d31b447b1367c56;p=scp%2Focu%2F5gnr.git diff --git a/Cu/CuUp/Pdcp/PdcpUp/Src/pdcpuUpc.c b/Cu/CuUp/Pdcp/PdcpUp/Src/pdcpuUpc.c index 36ba83b..6def3a9 100644 --- a/Cu/CuUp/Pdcp/PdcpUp/Src/pdcpuUpc.c +++ b/Cu/CuUp/Pdcp/PdcpUp/Src/pdcpuUpc.c @@ -1,9 +1,21 @@ /****************************************************************************** -############################################################################### -# 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" @@ -23,15 +35,15 @@ CuupUeIdxTable_t gPdcpuUeIdxTable; /******************************************************************************* -* To +* To * INPUT: -* : +* : * OUTPUT: * 0:success * -1:fail -*******************************************************************************/ +*******************************************************************************/ INT32 pdcpuInit(ULONG userModuleId) -{ +{ /* get pdcpu moduleId */ gPdcpuModuleId = userModuleId; @@ -47,7 +59,7 @@ INT32 pdcpuInit(ULONG userModuleId) { gPdcpuUeInfo[i] = NULL; } - + return VOS_OK; } @@ -60,13 +72,13 @@ INT32 pdcpuFreeSecInfo(UINT16 ueIdx) 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 @@ -76,14 +88,14 @@ INT32 pdcpuFreeSecInfo(UINT16 ueIdx) * 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) { @@ -93,65 +105,65 @@ INT32 pdcpuDealSecurityInd(PdcpuSecInfo_t *pSec, PdcpuSecEnableInfo_t *pEnableIn 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; } @@ -170,22 +182,22 @@ INT32 pdcpuRetFailResult(UpcCfgType_e cfgType, upcTempSessInfo_t *pCfgInfo, Pdcp } 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; @@ -194,10 +206,10 @@ INT32 pdcpuSessionAddProc(UINT64 ueE1apId, VOID *pCfgInfo, PdcpuCfgResult_t *pRe 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"); @@ -206,12 +218,12 @@ INT32 pdcpuSessionAddProc(UINT64 ueE1apId, VOID *pCfgInfo, PdcpuCfgResult_t *pRe /* 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) @@ -227,34 +239,34 @@ INT32 pdcpuSessionAddProc(UINT64 ueE1apId, VOID *pCfgInfo, PdcpuCfgResult_t *pRe } 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; - + } } @@ -271,7 +283,7 @@ INT32 pdcpuSessionAddProc(UINT64 ueE1apId, VOID *pCfgInfo, PdcpuCfgResult_t *pRe } /******************************************************************************* - * To manage pdcp-u entity + * To manage pdcp-u entity * INPUT: * ueE1apId : UE E1AP ID * pPduSessionCfg : PDU Session Resource to setup item @@ -281,7 +293,7 @@ INT32 pdcpuSessionAddProc(UINT64 ueE1apId, VOID *pCfgInfo, PdcpuCfgResult_t *pRe * result: PDCP config result *******************************************************************************/ INT32 pdcpuConfig(UINT64 ueE1apId, VOID *pCfgInfo, UpcCfgType_e cfgType, PdcpuCfgResult_t *pResult) -{ +{ switch(cfgType) { case PDU_SESSION_ADD: @@ -291,7 +303,7 @@ INT32 pdcpuConfig(UINT64 ueE1apId, VOID *pCfgInfo, UpcCfgType_e cfgType, PdcpuCf VOS_MemZero(pResult, sizeof(PdcpuCfgResult_t)); pResult->cfgType = cfgType; return pdcpuSessionAddProc(ueE1apId, pCfgInfo, pResult); - } + } default: { pdcpuLog(LOG_ERR,"[PDCPU] cfgType error\n"); @@ -311,12 +323,12 @@ INT32 pdcpuConfig(UINT64 ueE1apId, VOID *pCfgInfo, UpcCfgType_e cfgType, PdcpuCf *******************************************************************************/ 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)); @@ -327,7 +339,7 @@ PdcpuSecInfo_t *pdcpuAllocUeSecInfo(UINT16 ueIdx) } //check secInfo if(NULL == pPdcpUeInfo->secInfo) - { + { pSecInfo = VOS_Malloc(sizeof(PdcpuSecInfo_t), gPdcpuModuleId); pdcpuNullCheckRp(pSecInfo); VOS_MemZero(pSecInfo, sizeof(PdcpuSecInfo_t)); @@ -338,14 +350,14 @@ PdcpuSecInfo_t *pdcpuAllocUeSecInfo(UINT16 ueIdx) } 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 @@ -356,21 +368,21 @@ PdcpuSecInfo_t *pdcpuAllocUeSecInfo(UINT16 ueIdx) 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 */ @@ -381,7 +393,7 @@ INT32 pdcpuSetSecParam(UINT64 ueE1apId, SecuInfo_t *secInfo) pdcpuFreeSecInfo(ueIdx); return VOS_ERROR; } - + pDrbSecInfo->intActiveFlag = ACTIVE_INT_STATE; /* 0-inactive, 1-active */ if(intAlgorithm == NIA0 || intAlgorithm == NIA1 || intAlgorithm == NIA2) { @@ -399,8 +411,8 @@ INT32 pdcpuSetSecParam(UINT64 ueE1apId, SecuInfo_t *secInfo) 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 */ @@ -414,12 +426,12 @@ INT32 pdcpuSetSecParam(UINT64 ueE1apId, SecuInfo_t *secInfo) 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; @@ -428,7 +440,6 @@ INT32 pdcpuSetSecParam(UINT64 ueE1apId, SecuInfo_t *secInfo) pDrbSecInfo->ueE1apId = ueE1apId; pDrbSecInfo->ueIdx = ueIdx; pDrbSecInfo->nhInd = FALSE; - + return VOS_OK; } -