replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / tcp_adapter / arduino / catcpserver_eth.cpp
index 3cc0e7d..6e6404e 100644 (file)
@@ -29,9 +29,9 @@
 
 #include "catcpadapterutils_eth.h"
 #include "catcpinterface.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 #include "caadapterutils.h"
-#include "camutex.h"
+#include "octhread.h"
 #include "oic_malloc.h"
 #include "oic_string.h"
 
@@ -159,6 +159,11 @@ void CATCPSetPacketReceiveCallback(CATCPPacketReceivedCallback callback)
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
+void CATCPSetConnectionChangedCallback(CATCPConnectionHandleCallback connHandler)
+{
+    return;
+}
+
 void CATCPSetErrorHandler(CATCPErrorHandleCallback errorHandleCallback)
 {
     return;
@@ -207,7 +212,7 @@ void CATCPReadDataInternal()
 
             if (!isHeaderChecked && totalReceivedLen)
             {
-                coap_transport_type transport;
+                coap_transport_t transport;
                 size_t headerLen;
                 CAGetTCPHeaderDetails(recvBuffer, &transport, &headerLen);
                 if (totalReceivedLen >= headerLen)
@@ -232,7 +237,9 @@ void CATCPReadDataInternal()
             if (totalLen == totalReceivedLen)
             {
                 CASecureEndpoint_t ep =
-                    {.endpoint = {.adapter = CA_ADAPTER_TCP, .port = tcpClientPort}};
+                    {.endpoint = {.adapter = CA_ADAPTER_TCP,
+                                  .flags = CA_DEFAULT_FLAGS,
+                                  .port = tcpClientPort}};
 
                 IPAddress clientIP = tcpClientIP;
                 int ret = snprintf(ep.endpoint.addr, sizeof(ep.endpoint.addr), "%d.%d.%d.%d",
@@ -277,8 +284,8 @@ CAResult_t CAGetTCPInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
     return CA_NOT_SUPPORTED;
 }
 
-static void sendData(const CAEndpoint_t *endpoint,
-                     const void *data, size_t dlen)
+static ssize_t sendData(const CAEndpoint_t *endpoint,
+                        const void *data, size_t dlen)
 {
     uint16_t port = endpoint->port;
     uint8_t ipAddr[4] = { 0 };
@@ -287,14 +294,14 @@ static void sendData(const CAEndpoint_t *endpoint,
                                    &parsedPort) != CA_STATUS_OK)
     {
         OIC_LOG(ERROR, TAG, "parse fail");
-        return;
+        return -1;
     }
 
     if (dlen > 65535) // Max value for uint16_t
     {
         // This will never happen as max buffer size we are dealing with is COAP_MAX_PDU_SIZE
         OIC_LOG(ERROR, TAG, "Size exceeded");
-        return;
+        return -1;
     }
 
     uint32_t ret = send(g_unicastSocket, (const uint8_t *)data, (uint16_t)dlen);
@@ -304,19 +311,17 @@ static void sendData(const CAEndpoint_t *endpoint,
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
+    return ret;
 }
 
-void CATCPSendData(CAEndpoint_t *endpoint, const void *data, uint32_t datalen,
-                   bool isMulticast)
+ssize_t CATCPSendData(CAEndpoint_t *endpoint, const void *data, size_t datalen)
 {
     VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint is NULL");
     VERIFY_NON_NULL_VOID(data, TAG, "data is NULL");
 
-    if (!isMulticast)
+    if (caglobals.tcp.ipv4tcpenabled && (endpoint->adapter & CA_ADAPTER_TCP))
     {
-        if (caglobals.tcp.ipv4tcpenabled && (endpoint->adapter & CA_ADAPTER_TCP))
-        {
-            sendData(endpoint, data, datalen);
-        }
+        return sendData(endpoint, data, datalen);
     }
-}
\ No newline at end of file
+    return -1;
+}