X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcodec_utils%2Fcommon%2Fodu_common_codec.c;h=9e7693c368e7f1f27475ba86b19534323ac5699c;hb=2193e4cf01012809495be026097e8d7eacb9f0ac;hp=98f00230d21d22dbfea0e2fa7d4a3db82927b887;hpb=8340c342ebcfc82193c3f66e7f15047c1e37399b;p=o-du%2Fl2.git diff --git a/src/codec_utils/common/odu_common_codec.c b/src/codec_utils/common/odu_common_codec.c index 98f00230d..9e7693c36 100644 --- a/src/codec_utils/common/odu_common_codec.c +++ b/src/codec_utils/common/odu_common_codec.c @@ -1,3 +1,7 @@ +#include "common_def.h" +#include "OCTET_STRING.h" +#include "BIT_STRING.h" +#include "asn_codecs.h" #include "odu_common_codec.h" /******************************************************************* @@ -40,9 +44,9 @@ int PrepFinalEncBuf(const void *buffer, size_t size, void *encodedBuf) * RFAILED - failure * * ****************************************************************/ -S16 buildPlmnId(Plmn plmn, OCTET_STRING_t *octe) +uint8_t buildPlmnId(Plmn plmn, OCTET_STRING_t *octe) { - U8 mncCnt; + uint8_t mncCnt; mncCnt = 2; octe->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0])); if(mncCnt == 2) @@ -55,7 +59,7 @@ S16 buildPlmnId(Plmn plmn, OCTET_STRING_t *octe) octe->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2])); octe->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1])); } - RETVALUE(ROK); + return ROK; } /******************************************************************* @@ -69,21 +73,21 @@ S16 buildPlmnId(Plmn plmn, OCTET_STRING_t *octe) * Functionality: Fills the RicId * * @params[in] BIT_STRING_t *nbid, - * U8 unusedBits - * U8 byteSize - * U8 val + * uint8_t unusedBits + * uint8_t byteSize + * uint8_t val * * @return ROK - success * RFAILED - failure * * ****************************************************************/ -S16 fillBitString(BIT_STRING_t *id, U8 unusedBits, U8 byteSize, U8 val) +uint8_t fillBitString(BIT_STRING_t *id, uint8_t unusedBits, uint8_t byteSize, uint8_t val) { - U8 tmp; + uint8_t tmp; if(id->buf == NULLP) { - RETVALUE(RFAILED); + return RFAILED; } for (tmp = 0 ; tmp < (byteSize-1); tmp++) @@ -92,9 +96,46 @@ S16 fillBitString(BIT_STRING_t *id, U8 unusedBits, U8 byteSize, U8 val) } id->buf[byteSize-1] = val; id->bits_unused = unusedBits; - RETVALUE(ROK); + return ROK; } +/******************************************************************* + * + * @brief Converts bit strings to integer + * + * @details + * + * Function : bitStringToInt + * + * Functionality: + * - Converts ASN bit string format IEs to integer type + * + * @params[in] void + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t bitStringToInt(BIT_STRING_t *bitString, uint16_t *val) +{ + uint16_t idx; + if(bitString->buf == NULL || bitString->size <= 0) + { + DU_LOG("\nDU_APP : Bit string is empty"); + return RFAILED; + } + + for(idx=0; idx< bitString->size-1; idx++) + { + *val |= bitString->buf[idx]; + *val <<= 8; + } + *val |= bitString->buf[idx]; + *val >>= bitString->bits_unused; + + return ROK; +} + + /********************************************************************** End of file