[CONPRO-1471]Adding logic for caching MTU in tizen LE Server
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / tizen / caleutil.c
old mode 100644 (file)
new mode 100755 (executable)
index a4c4561..0c12e25
@@ -112,7 +112,7 @@ void CARemoveLEDataFromList(LEDataList **dataList)
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
-    VERIFY_NON_NULL(dataList, TAG, "Data list is null");
+    VERIFY_NON_NULL_VOID(dataList, TAG, "Data list is null");
 
     if (*dataList)
     {
@@ -322,6 +322,7 @@ CAResult_t CAAddLEClientInfoToList(LEClientInfoList **clientList,
     }
 
     node->remoteAddress= clientAddress;
+    node->mtuSize = 0;
     node->next = NULL;
 
     if (*clientList == NULL)   // Empty list
@@ -339,6 +340,45 @@ CAResult_t CAAddLEClientInfoToList(LEClientInfoList **clientList,
     return CA_STATUS_OK;
 }
 
+uint16_t CAClientInfoGetMTUSize(LEClientInfoList *clientList,
+                                        const char *clientAddress)
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    LEClientInfoList *temp = clientList;
+    while (temp)
+    {
+        if (!strcasecmp(temp->remoteAddress, clientAddress))
+        {
+            return temp->mtuSize;
+        }
+        temp = temp->next;
+    }
+
+    OIC_LOG(DEBUG, TAG, "OUT");
+    return 0;
+}
+
+CAResult_t CAClientInfoUpdateMTUSize(LEClientInfoList *clientList,
+                                        const char *clientAddress,uint16_t mtu_size)
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    LEClientInfoList *temp = clientList;
+    while (temp)
+    {
+        if (!strcasecmp(temp->remoteAddress, clientAddress))
+        {
+            temp->mtuSize = mtu_size;
+            return CA_STATUS_OK;
+        }
+        temp = temp->next;
+    }
+
+    OIC_LOG(DEBUG, TAG, "OUT");
+    return CA_STATUS_FAILED;
+}
+
 CAResult_t CAIsLEClientInfoInList(LEClientInfoList *clientList,
                                         const char *clientAddress)
 {