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 Builds PLMN ID
37 * Function : plmnBuildId
39 * Functionality: Building the PLMN ID
41 * @params[in] PLMNID plmn
42 * OCTET_STRING_t *octe
43 * @return ROK - success
46 * ****************************************************************/
47 uint8_t buildPlmnId(Plmn plmn, uint8_t *buf)
51 buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
54 buf[1] = ((0xf0) | (plmn.mcc[2]));
55 buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
59 buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
60 buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
65 /*******************************************************************
67 * @brief Fills the RicId
71 * Function : FillRicId
73 * Functionality: Fills the RicId
75 * @params[in] BIT_STRING_t *nbid,
80 * @return ROK - success
83 * ****************************************************************/
85 uint8_t fillBitString(BIT_STRING_t *id, uint8_t unusedBits, uint8_t byteSize, uint8_t val)
93 for (tmp = 0 ; tmp < (byteSize-1); tmp++)
97 id->buf[byteSize-1] = val;
98 id->bits_unused = unusedBits;
102 /*******************************************************************
104 * @brief Converts bit strings to integer
108 * Function : bitStringToInt
111 * - Converts ASN bit string format IEs to integer type
114 * @return ROK - success
117 * ****************************************************************/
118 uint8_t bitStringToInt(BIT_STRING_t *bitString, uint16_t *val)
121 if(bitString->buf == NULL || bitString->size <= 0)
123 DU_LOG("\nDU_APP : Bit string is empty");
127 for(idx=0; idx< bitString->size-1; idx++)
129 *val |= bitString->buf[idx];
132 *val |= bitString->buf[idx];
133 *val >>= bitString->bits_unused;
140 /**********************************************************************
142 **********************************************************************/