warning set 4
[o-du/l2.git] / src / codec_utils / common / odu_common_codec.c
1 #include "odu_common_codec.h"
2
3 /*******************************************************************
4  *
5  * @brief Writes the encoded chunks into a buffer
6  *
7  * @details
8  *
9  *    Function : PrepFinalEncBuf
10  *
11  *    Functionality:Fills the encoded buffer
12  *
13  * @params[in] void *buffer,initial encoded data
14  * @params[in] size_t size,size of buffer
15  * @params[in] void *encodedBuf,final buffer
16  * @return ROK     - success
17  *         RFAILED - failure
18  *
19  * ****************************************************************/
20 int PrepFinalEncBuf(const void *buffer, size_t size, void *encodedBuf)
21 {
22    memcpy(encodedBuf + encBufSize, buffer, size);
23    encBufSize += size;
24    return 0;
25 } /* PrepFinalEncBuf */
26
27 /*******************************************************************
28  *
29  * @brief Builds PLMN ID 
30  *
31  * @details
32  *
33  *    Function : plmnBuildId
34  *
35  *    Functionality: Building the PLMN ID
36  *
37  * @params[in] PLMNID plmn
38  *             OCTET_STRING_t *octe
39  * @return ROK     - success
40  *         RFAILED - failure
41  *
42  * ****************************************************************/
43 S16 buildPlmnId(Plmn plmn, OCTET_STRING_t *octe)
44 {
45    U8 mncCnt;
46    mncCnt = 2;
47    octe->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
48    if(mncCnt == 2)
49    {
50       octe->buf[1]  = ((0xf0) | (plmn.mcc[2]));
51       octe->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
52    }
53    else
54    {
55       octe->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
56       octe->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
57    }
58    RETVALUE(ROK);
59 }
60
61 /*******************************************************************
62  *
63  * @brief Fills the RicId
64  *
65  * @details
66  *
67  *    Function : FillRicId
68  *
69  *    Functionality: Fills the RicId
70  *
71  * @params[in] BIT_STRING_t *nbid,
72  *             U8 unusedBits
73  *             U8 byteSize
74  *             U8 val
75  *
76  * @return ROK     - success
77  *         RFAILED - failure
78  *
79  * ****************************************************************/
80
81 S16 fillBitString(BIT_STRING_t *id, U8 unusedBits, U8 byteSize, U8 val)
82 {
83    U8 tmp;
84    if(id->buf == NULLP)
85    {
86       RETVALUE(RFAILED);
87    }
88
89    for (tmp = 0 ; tmp < (byteSize-1); tmp++)
90    {
91       id->buf[tmp] = tmp;
92    }
93    id->buf[byteSize-1]   = val;
94    id->bits_unused = unusedBits;
95    RETVALUE(ROK);
96 }
97
98
99 /**********************************************************************
100   End of file
101  **********************************************************************/