X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Fmac_utils.c;h=00af8075f2684bb26e1c54a3e695f7c8595bf2ff;hb=refs%2Fchanges%2F91%2F5391%2F11;hp=86072278fb48d3b0c8118cd2d1250b51bbcec36f;hpb=6b44407d464a5a4e060999255233a7cfe78bb0fa;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_utils.c b/src/5gnrmac/mac_utils.c index 86072278f..00af8075f 100644 --- a/src/5gnrmac/mac_utils.c +++ b/src/5gnrmac/mac_utils.c @@ -24,3 +24,40 @@ uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES] = { 0, 10, 14, 20, 28, 38, 53, 74, 102, 142, 198, 276, 384, 535, 745, 1038, 1446, 2014, 2806, 3909, \ 5446, 7587, 10570, 14726, 20516, 28581, 39818, 55474, 77284, 107669, 150000, \ 150001 }; + +/******************************************************************* + * + * @brief Allocates a crnti for new UE + * + * @details + * + * Function : getNewCrnti + * + * Functionality: Allocates a crnti for new UE + * + * @params[in] CRNTI bit map + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t getNewCrnti(uint8_t *crntiMap) +{ + uint8_t bitIdx = 0; /* bit position */ + uint8_t mask = 1; /* bit mask */ + uint16_t newCrnti; /* new crnti */ + + while(bitIdx < 8) + { + /* Find the first unset bit in crntiMap and allocate + * this as new crnti */ + if((*crntiMap & (mask << bitIdx)) == 0) + { + newCrnti = ODU_START_CRNTI + bitIdx; + SET_ONE_BIT(bitIdx, *crntiMap); + return newCrnti; + } + else + bitIdx++; + } + return -1; +}