X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcodec_utils%2Fcommon%2Fodu_common_codec.c;h=5ea3c8da6e0e8552e7d024818785b2a922a5d040;hb=073b67b21b11eefdaa84a30029f374435c3e0fd0;hp=5f52c253a35b8ca88b213e92347c8352de289610;hpb=bb8df345963bb5ef2e035ead7731c1171e4cbbe0;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 5f52c253a..5ea3c8da6 100644 --- a/src/codec_utils/common/odu_common_codec.c +++ b/src/codec_utils/common/odu_common_codec.c @@ -1,38 +1,32 @@ +#include "common_def.h" +#include "OCTET_STRING.h" +#include "BIT_STRING.h" +#include "asn_codecs.h" #include "odu_common_codec.h" /******************************************************************* * - * @brief Builds PLMN ID + * @brief Writes the encoded chunks into a buffer * * @details * - * Function : plmnBuildId + * Function : PrepFinalEncBuf * - * Functionality: Building the PLMN ID + * Functionality:Fills the encoded buffer * - * @params[in] PLMNID plmn - * OCTET_STRING_t *octe + * @params[in] void *buffer,initial encoded data + * @params[in] size_t size,size of buffer + * @params[in] void *encodedBuf,final buffer * @return ROK - success * RFAILED - failure * * ****************************************************************/ -S16 buildPlmnId(Plmn plmn, OCTET_STRING_t *octe) +int PrepFinalEncBuf(const void *buffer, size_t size, void *encodedBuf) { - U8 mncCnt; - mncCnt = 2; - octe->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0])); - if(mncCnt == 2) - { - octe->buf[1] = ((0xf0) | (plmn.mcc[2])); - octe->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0])); - } - else - { - octe->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2])); - octe->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1])); - } - RETVALUE(ROK); -} + memcpy(encodedBuf + encBufSize, buffer, size); + encBufSize += size; + return 0; +} /* PrepFinalEncBuf */ /******************************************************************* * @@ -45,21 +39,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++) @@ -68,9 +62,53 @@ 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, void *value) +{ + uint16_t idx; + uint32_t *val = NULLP; + + if(bitString->buf == NULL || bitString->size <= 0) + { + DU_LOG("\nDU_APP : Bit string is empty"); + return RFAILED; + } + + if(value) + val = (uint32_t *)value; + else + 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