E2AP changes Part2
[o-du/l2.git] / src / codec_utils / common / odu_common_codec.c
1 #include "odu_common_codec.h"
2
3 /*******************************************************************
4  *
5  * @brief Builds PLMN ID 
6  *
7  * @details
8  *
9  *    Function : plmnBuildId
10  *
11  *    Functionality: Building the PLMN ID
12  *
13  * @params[in] PLMNID plmn
14  *             OCTET_STRING_t *octe
15  * @return ROK     - success
16  *         RFAILED - failure
17  *
18  * ****************************************************************/
19 S16 buildPlmnId(Plmn plmn, OCTET_STRING_t *octe)
20 {
21    U8 mncCnt;
22    mncCnt = 2;
23    octe->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
24    if(mncCnt == 2)
25    {
26       octe->buf[1]  = ((0xf0) | (plmn.mcc[2]));
27       octe->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
28    }
29    else
30    {
31       octe->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
32       octe->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
33    }
34    RETVALUE(ROK);
35 }
36
37 /*******************************************************************
38  *
39  * @brief Fills the RicId
40  *
41  * @details
42  *
43  *    Function : FillRicId
44  *
45  *    Functionality: Fills the RicId
46  *
47  * @params[in] BIT_STRING_t *nbid,
48  *             U8 unusedBits
49  *             U8 byteSize
50  *             U8 val
51  *
52  * @return ROK     - success
53  *         RFAILED - failure
54  *
55  * ****************************************************************/
56
57 S16 fillBitString(BIT_STRING_t *id, U8 unusedBits, U8 byteSize, U8 val)
58 {
59    U8 tmp;
60    if(id->buf == NULLP)
61    {
62       RETVALUE(RFAILED);
63    }
64
65    for (tmp = 0 ; tmp < (byteSize-1); tmp++)
66    {
67       id->buf[tmp] = tmp;
68    }
69    id->buf[byteSize-1]   = val;
70    id->bits_unused = unusedBits;
71    RETVALUE(ROK);
72 }
73
74
75 /**********************************************************************
76   End of file
77  **********************************************************************/