1 #include "common_def.h"
2 #include "OCTET_STRING.h"
3 #include "BIT_STRING.h"
4 #include "asn_codecs.h"
5 #include "odu_common_codec.h"
7 /*******************************************************************
9 * @brief Writes the encoded chunks into a buffer
13 * Function : PrepFinalEncBuf
15 * Functionality:Fills the encoded buffer
17 * @params[in] void *buffer,initial encoded data
18 * @params[in] size_t size,size of buffer
19 * @params[in] void *encodedBuf,final buffer
20 * @return ROK - success
23 * ****************************************************************/
24 int PrepFinalEncBuf(const void *buffer, size_t size, void *encodedBuf)
26 memcpy(encodedBuf + encBufSize, buffer, size);
29 } /* PrepFinalEncBuf */
31 /*******************************************************************
33 * @brief Fills the RicId
37 * Function : FillRicId
39 * Functionality: Fills the RicId
41 * @params[in] BIT_STRING_t *nbid,
46 * @return ROK - success
49 * ****************************************************************/
51 uint8_t fillBitString(BIT_STRING_t *id, uint8_t unusedBits, uint8_t byteSize, uint8_t val)
59 for (tmp = 0 ; tmp < (byteSize-1); tmp++)
63 id->buf[byteSize-1] = val;
64 id->bits_unused = unusedBits;
68 /*******************************************************************
70 * @brief Converts bit strings to integer
74 * Function : bitStringToInt
77 * - Converts ASN bit string format IEs to integer type
80 * @return ROK - success
83 * ****************************************************************/
84 uint8_t bitStringToInt(BIT_STRING_t *bitString, void *value)
87 uint32_t *val = NULLP;
89 if(bitString->buf == NULL || bitString->size <= 0)
91 DU_LOG("\nDU_APP : Bit string is empty");
96 val = (uint32_t *)value;
100 for(idx=0; idx< bitString->size-1; idx++)
102 *val |= bitString->buf[idx];
105 *val |= bitString->buf[idx];
106 *val >>= bitString->bits_unused;
111 /*******************************************************************
113 * @brief Function to decode teId value from the octect String
117 * Function : teIdStringToInt
119 * Functionality: Function to decode teId value from the octect string
120 * It can used as generic function to convert
121 * octect string to uint32_t value
123 * @params[in] buf, value
126 * ****************************************************************/
127 void teIdStringToInt(uint8_t *buf, uint32_t *val)
129 uint32_t temp1 = 0, temp2 = 0, temp3 = 0;
140 *val = temp1|temp2|temp3|buf[3];
143 /*******************************************************************
145 * @brief Function to encode teId value to the octect String
149 * Function : fillTeIdString
151 * Functionality: Function to encode teId value to the octect String
152 * It can used as generic function to encode
153 * uint32_t value to octect string
155 * @params[in] bufSize, value, buf
158 * ****************************************************************/
160 void fillTeIdString(uint8_t bufSize, uint32_t val, uint8_t *buf)
164 for(bitPos = 0; bitPos < TEID_BIT_SIZE; bitPos += 8, bufSize--)
166 /*extracting bitBits from the bitPos*/
167 buf[bufSize] = (((1 << 8) - 1) & (val >> (bitPos)));
171 /**********************************************************************
173 **********************************************************************/