Rename rde_common to bej_common

bej_common.h is a more consistant name than rde_common.h.

Also this repo only contains code related to BEJ encoding and decoding.
Therefore this change removes the rde related structs defind in the
bej_common.h. Those structs should be defined somewhere else (libpldm).

Signed-off-by: Kasun Athukorala <kasunath@google.com>
Change-Id: Ic296ece11efc0967366e197a8609c3c88c325610
diff --git a/include/libbej/rde_common.h b/include/libbej/bej_common.h
similarity index 77%
rename from include/libbej/rde_common.h
rename to include/libbej/bej_common.h
index bc5498c..a0ec526 100644
--- a/include/libbej/rde_common.h
+++ b/include/libbej/bej_common.h
@@ -144,50 +144,6 @@
         uint8_t schemaClass;
     } __attribute__((__packed__));
 
-    enum RdeOperationInitType
-    {
-        rdeOpInitOperationHead = 0,
-        rdeOpInitOperationRead = 1,
-        rdeOpInitOperationCreate = 2,
-        rdeOpInitOperationDelete = 3,
-        rdeOpInitOperationUpdate = 4,
-        rdeOpInitOperationReplace = 5,
-        rdeOpInitOperationAction = 6,
-    };
-
-    enum RdeMultiReceiveTransferFlag
-    {
-        rdeMRecFlagStart = 0,
-        rdeMRecFlagMiddle = 1,
-        rdeMRecFlagEnd = 2,
-        rdeMRecFlagStartAndEnd = 3,
-    };
-
-    struct RdeOperationInitReqHeader
-    {
-        uint32_t resourceID;
-        uint16_t operationID;
-        uint8_t operationType;
-
-        // OperationFlags bits
-        uint8_t locatorValid : 1;
-        uint8_t containsRequestPayload : 1;
-        uint8_t containsCustomRequestParameters : 1;
-
-        uint8_t reserved : 5;
-        uint32_t sendDataTransferHandle;
-        uint8_t operationLocatorLength;
-        uint32_t requestPayloadLength;
-    } __attribute__((__packed__));
-
-    struct MultipartReceiveResHeader
-    {
-        uint8_t completionCode;
-        uint8_t transferFlag;
-        uint32_t nextDataTransferHandle;
-        uint32_t dataLengthBytes;
-    } __attribute__((__packed__));
-
     /**
      * @brief Get the unsigned integer value from provided bytes.
      *
@@ -198,7 +154,7 @@
      * undefined.
      * @return unsigend 64bit representation of the value.
      */
-    uint64_t rdeGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes);
+    uint64_t bejGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes);
 
     /**
      * @brief Get the value from nnint type.
@@ -206,7 +162,7 @@
      * @param[in] nnint - nnint should be pointing to a valid nnint.
      * @return unsigend 64bit representation of the value.
      */
-    uint64_t rdeGetNnint(const uint8_t* nnint);
+    uint64_t bejGetNnint(const uint8_t* nnint);
 
     /**
      * @brief Get the size of the complete nnint.
@@ -214,7 +170,7 @@
      * @param[in] nnint - pointer to a valid nnint.
      * @return size of the complete nnint.
      */
-    uint8_t rdeGetNnintSize(const uint8_t* nnint);
+    uint8_t bejGetNnintSize(const uint8_t* nnint);
 
 #ifdef __cplusplus
 }
diff --git a/include/libbej/bej_decoder_core.h b/include/libbej/bej_decoder_core.h
index a0c4686..044d691 100644
--- a/include/libbej/bej_decoder_core.h
+++ b/include/libbej/bej_decoder_core.h
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "rde_common.h"
+#include "bej_common.h"
 
 #include <stdbool.h>
 #include <stddef.h>
diff --git a/include/libbej/bej_decoder_json.hpp b/include/libbej/bej_decoder_json.hpp
index 96192f4..2d59d6a 100644
--- a/include/libbej/bej_decoder_json.hpp
+++ b/include/libbej/bej_decoder_json.hpp
@@ -1,7 +1,7 @@
 #pragma once
 
+#include "bej_common.h"
 #include "bej_decoder_core.h"
-#include "rde_common.h"
 
 #include <span>
 #include <string>
diff --git a/include/libbej/bej_dictionary.h b/include/libbej/bej_dictionary.h
index 13d979e..ad6bee1 100644
--- a/include/libbej/bej_dictionary.h
+++ b/include/libbej/bej_dictionary.h
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "rde_common.h"
+#include "bej_common.h"
 
 #include <stdint.h>
 
diff --git a/include/libbej/meson.build b/include/libbej/meson.build
index de07150..c2c834b 100644
--- a/include/libbej/meson.build
+++ b/include/libbej/meson.build
@@ -2,7 +2,7 @@
   'bej_decoder_core.h',
   'bej_decoder_json.hpp',
   'bej_dictionary.h',
-  'rde_common.h'
+  'bej_common.h'
 )
 
 install_headers(
diff --git a/src/rde_common.c b/src/bej_common.c
similarity index 64%
rename from src/rde_common.c
rename to src/bej_common.c
index 258a543..1d3be07 100644
--- a/src/rde_common.c
+++ b/src/bej_common.c
@@ -1,6 +1,6 @@
-#include "rde_common.h"
+#include "bej_common.h"
 
-uint64_t rdeGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes)
+uint64_t bejGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes)
 {
     uint64_t num = 0;
     for (uint8_t i = 0; i < numOfBytes; ++i)
@@ -10,15 +10,15 @@
     return num;
 }
 
-uint64_t rdeGetNnint(const uint8_t* nnint)
+uint64_t bejGetNnint(const uint8_t* nnint)
 {
     // In nnint, first byte indicate how many bytes are there. Remaining bytes
     // represent the value in little-endian format.
     const uint8_t size = *nnint;
-    return rdeGetUnsignedInteger(nnint + sizeof(uint8_t), size);
+    return bejGetUnsignedInteger(nnint + sizeof(uint8_t), size);
 }
 
-uint8_t rdeGetNnintSize(const uint8_t* nnint)
+uint8_t bejGetNnintSize(const uint8_t* nnint)
 {
     // In nnint, first byte indicate how many bytes are there.
     return *nnint + sizeof(uint8_t);
diff --git a/src/bej_decoder_core.c b/src/bej_decoder_core.c
index 877d8e4..b1688a9 100644
--- a/src/bej_decoder_core.c
+++ b/src/bej_decoder_core.c
@@ -58,7 +58,7 @@
     {
         return 0;
     }
-    uint64_t value = rdeGetUnsignedInteger(bytes, numOfBytes);
+    uint64_t value = bejGetUnsignedInteger(bytes, numOfBytes);
     uint8_t bitsInVal = numOfBytes * 8;
     // Since numOfBytes > 0, bitsInVal is non negative.
     uint64_t mask = (uint64_t)1 << (uint8_t)(bitsInVal - 1);
@@ -112,11 +112,11 @@
     // segment.
     bejGetLocalBejSFLVOffsets(params->state.encodedSubStream, &localOffset);
     struct BejSFLV* sflv = &params->sflv;
-    const uint32_t valueLength = (uint32_t)(rdeGetNnint(
+    const uint32_t valueLength = (uint32_t)(bejGetNnint(
         params->state.encodedSubStream + localOffset.valueLenNnintOffset));
     // Sequence number itself should be 16bits. Using 32bits for
     // [sequence_number + schema_type].
-    uint32_t tupleS = (uint32_t)(rdeGetNnint(params->state.encodedSubStream));
+    uint32_t tupleS = (uint32_t)(bejGetNnint(params->state.encodedSubStream));
     sflv->tupleS.schema = (uint8_t)(tupleS & DICTIONARY_TYPE_MASK);
     sflv->tupleS.sequenceNumber =
         (uint16_t)((tupleS & (~DICTIONARY_TYPE_MASK)) >>
@@ -147,7 +147,7 @@
     // being decoded.
     bejGetLocalBejSFLVOffsets(params->state.encodedSubStream, &localOffset);
     return params->state.encodedStreamOffset + localOffset.valueOffset +
-           rdeGetNnintSize(params->sflv.value);
+           bejGetNnintSize(params->sflv.value);
 }
 
 /**
@@ -344,7 +344,7 @@
     RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackSetStart,
                               propName, params->callbacksDataPtr);
 
-    uint64_t elements = rdeGetNnint(params->sflv.value);
+    uint64_t elements = bejGetNnint(params->sflv.value);
     // If its an empty set, we are done here.
     if (elements == 0)
     {
@@ -403,7 +403,7 @@
     RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackArrayStart,
                               propName, params->callbacksDataPtr);
 
-    uint64_t elements = rdeGetNnint(params->sflv.value);
+    uint64_t elements = bejGetNnint(params->sflv.value);
     // If its an empty array, we are done here.
     if (elements == 0)
     {
@@ -515,7 +515,7 @@
     {
         // Get the string for enum value.
         uint16_t enumValueSequenceN =
-            (uint16_t)(rdeGetNnint(params->sflv.value));
+            (uint16_t)(bejGetNnint(params->sflv.value));
         const struct BejDictionaryProperty* enumValueProp;
         RETURN_IF_IERROR(
             bejDictGetProperty(dictionary, prop->childPointerOffset,
@@ -582,24 +582,24 @@
         // nnint      - fract
         // nnint      - Length of exp
         // bejInteger - exp (includes sign for the exponent)
-        uint8_t wholeByteLen = (uint8_t)rdeGetNnint(params->sflv.value);
+        uint8_t wholeByteLen = (uint8_t)bejGetNnint(params->sflv.value);
         const uint8_t* wholeBejInt =
-            params->sflv.value + rdeGetNnintSize(params->sflv.value);
+            params->sflv.value + bejGetNnintSize(params->sflv.value);
         const uint8_t* fractZeroCountNnint = wholeBejInt + wholeByteLen;
         const uint8_t* fractNnint =
-            fractZeroCountNnint + rdeGetNnintSize(fractZeroCountNnint);
-        const uint8_t* lenExpNnint = fractNnint + rdeGetNnintSize(fractNnint);
-        const uint8_t* expBejInt = lenExpNnint + rdeGetNnintSize(lenExpNnint);
+            fractZeroCountNnint + bejGetNnintSize(fractZeroCountNnint);
+        const uint8_t* lenExpNnint = fractNnint + bejGetNnintSize(fractNnint);
+        const uint8_t* expBejInt = lenExpNnint + bejGetNnintSize(lenExpNnint);
 
         struct BejReal realValue;
         realValue.whole = bejGetIntegerValue(wholeBejInt, wholeByteLen);
-        realValue.zeroCount = rdeGetNnint(fractZeroCountNnint);
-        realValue.fract = rdeGetNnint(fractNnint);
-        realValue.expLen = (uint8_t)rdeGetNnint(lenExpNnint);
+        realValue.zeroCount = bejGetNnint(fractZeroCountNnint);
+        realValue.fract = bejGetNnint(fractNnint);
+        realValue.expLen = (uint8_t)bejGetNnint(lenExpNnint);
         if (realValue.expLen != 0)
         {
             realValue.exp = bejGetIntegerValue(
-                expBejInt, (uint8_t)rdeGetNnint(lenExpNnint));
+                expBejInt, (uint8_t)bejGetNnint(lenExpNnint));
         }
         RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackReal,
                                   propName, &realValue,
diff --git a/src/meson.build b/src/meson.build
index 6651bda..c09268e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,7 +1,7 @@
 libbej_lib = library(
   'libbej',
   'bej_decoder_core.c',
-  'rde_common.c',
+  'bej_common.c',
   'bej_dictionary.c',
   'bej_decoder_json.cpp',
   include_directories : libbej_incs,
diff --git a/test/bej_common_test.cpp b/test/bej_common_test.cpp
new file mode 100644
index 0000000..09682fb
--- /dev/null
+++ b/test/bej_common_test.cpp
@@ -0,0 +1,39 @@
+#include "bej_common.h"
+
+#include <gmock/gmock-matchers.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+namespace libbej
+{
+
+TEST(BejCommonTest, BejGetUnsignedIntegerTest)
+{
+    constexpr uint8_t bytes[] = {0xab, 0xcd, 0xef, 0x12,
+                                 0x13, 0x65, 0x23, 0x89};
+    EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/1), 0xab);
+    EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/2), 0xcdab);
+    EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/5), 0x1312efcdab);
+    EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/8),
+                0x8923651312efcdab);
+}
+
+TEST(BejCommonTest, BejGetNnintTest)
+{
+    constexpr uint8_t nnint1[] = {0x03, 0xcd, 0xef, 0x12};
+    constexpr uint8_t nnint2[] = {0x08, 0xab, 0xcd, 0xef, 0x12,
+                                  0x13, 0x65, 0x23, 0x89};
+    EXPECT_THAT(bejGetNnint(nnint1), 0x12efcd);
+    EXPECT_THAT(bejGetNnint(nnint2), 0x8923651312efcdab);
+}
+
+TEST(BejCommonTest, BejGetNnintSizeTest)
+{
+    constexpr uint8_t nnint1[] = {0x03, 0xcd, 0xef, 0x12};
+    constexpr uint8_t nnint2[] = {0x08, 0xab, 0xcd, 0xef, 0x12,
+                                  0x13, 0x65, 0x23, 0x89};
+    EXPECT_THAT(bejGetNnintSize(nnint1), 4);
+    EXPECT_THAT(bejGetNnintSize(nnint2), 9);
+}
+
+} // namespace libbej
diff --git a/test/bej_dictionary_test.cpp b/test/bej_dictionary_test.cpp
index 0ca9361..0591f7d 100644
--- a/test/bej_dictionary_test.cpp
+++ b/test/bej_dictionary_test.cpp
@@ -8,7 +8,7 @@
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
-namespace rde
+namespace libbej
 {
 
 /**
@@ -104,4 +104,4 @@
                 bejErrorInvalidPropertyOffset);
 }
 
-} // namespace rde
+} // namespace libbej
diff --git a/test/meson.build b/test/meson.build
index 90ccb71..8178dc1 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -17,7 +17,7 @@
 
 gtests = [
   'bej_decoder',
-  'rde_common',
+  'bej_common',
   'bej_dictionary',
 ]
 foreach t : gtests
diff --git a/test/rde_common_test.cpp b/test/rde_common_test.cpp
deleted file mode 100644
index 3217ffd..0000000
--- a/test/rde_common_test.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "rde_common.h"
-
-#include <gmock/gmock-matchers.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-namespace rde
-{
-
-TEST(RdeCommonTest, RdeGetUnsignedIntegerTest)
-{
-    constexpr uint8_t bytes[] = {0xab, 0xcd, 0xef, 0x12,
-                                 0x13, 0x65, 0x23, 0x89};
-    EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/1), 0xab);
-    EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/2), 0xcdab);
-    EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/5), 0x1312efcdab);
-    EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/8),
-                0x8923651312efcdab);
-}
-
-TEST(RdeCommonTest, RdeGetNnintTest)
-{
-    constexpr uint8_t nnint1[] = {0x03, 0xcd, 0xef, 0x12};
-    constexpr uint8_t nnint2[] = {0x08, 0xab, 0xcd, 0xef, 0x12,
-                                  0x13, 0x65, 0x23, 0x89};
-    EXPECT_THAT(rdeGetNnint(nnint1), 0x12efcd);
-    EXPECT_THAT(rdeGetNnint(nnint2), 0x8923651312efcdab);
-}
-
-TEST(RdeCommonTest, RdeGetNnintSizeTest)
-{
-    constexpr uint8_t nnint1[] = {0x03, 0xcd, 0xef, 0x12};
-    constexpr uint8_t nnint2[] = {0x08, 0xab, 0xcd, 0xef, 0x12,
-                                  0x13, 0x65, 0x23, 0x89};
-    EXPECT_THAT(rdeGetNnintSize(nnint1), 4);
-    EXPECT_THAT(rdeGetNnintSize(nnint2), 9);
-}
-
-} // namespace rde