modified tcp connection callback parameter type
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Mon, 13 Jun 2016 00:30:08 +0000 (09:30 +0900)
committerJon A. Cruz <jon@joncruz.org>
Wed, 15 Jun 2016 07:25:39 +0000 (07:25 +0000)
I modified the parameter of the tcp connection callback
to pass the connectivity and flag information

Change-Id: Id99b92726b39ffac2b73a1e6d9041521e624af3d
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8609
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/csdk/connectivity/inc/catcpinterface.h
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index a9463ab..722a1c0 100644 (file)
@@ -65,12 +65,11 @@ typedef void (*CATCPErrorHandleCallback)(const CAEndpoint_t *endpoint, const voi
 /**
   * Callback to notify connection information in the TCP adapter.
   *
-  * @param[in]  addr    connected device address.
-  * @param[in]  port    connected port info.
-  * @param[in]  isConnected    Whether keepalive message needs to be sent.
+  * @param[in]  endpoint        network endpoint description.
+  * @param[in]  isConnected     Whether keepalive message needs to be sent.
   * @see  Callback must be registered using CATCPSetKeepAliveCallback().
  */
-typedef void (*CATCPConnectionHandleCallback)(const char *addr, uint16_t port, bool isConnected);
+typedef void (*CATCPConnectionHandleCallback)(const CAEndpoint_t *endpoint, bool isConnected);
 
 /**
  * set error callback to notify error in TCP adapter.
index 1b5e0f5..d81f600 100644 (file)
@@ -175,22 +175,18 @@ void CATCPErrorHandler(const CAEndpoint_t *endpoint, const void *data,
     }
 }
 
-static void CATCPConnectionHandler(const char *addr, uint16_t port, bool isConnected)
+static void CATCPConnectionHandler(const CAEndpoint_t *endpoint, bool isConnected)
 {
-    CAEndpoint_t endpoint = { .adapter =  CA_ADAPTER_TCP,
-                              .port = port };
-    OICStrcpy(endpoint.addr, sizeof(endpoint.addr), addr);
-
     // Pass the changed connection status to RI Layer for keepalive.
     if (g_connKeepAliveCallback)
     {
-        g_connKeepAliveCallback(&endpoint, isConnected);
+        g_connKeepAliveCallback(endpoint, isConnected);
     }
 
     // Pass the changed connection status to CAUtil.
     if (g_connectionChangeCallback)
     {
-        g_connectionChangeCallback(&endpoint, isConnected);
+        g_connectionChangeCallback(endpoint, isConnected);
     }
 }
 
index 3ee7165..89cda0f 100644 (file)
@@ -890,6 +890,7 @@ CATCPSessionInfo_t *CAConnectTCPSession(const CAEndpoint_t *endpoint)
         return NULL;
     }
     memcpy(svritem->sep.endpoint.addr, endpoint->addr, sizeof(svritem->sep.endpoint.addr));
+    svritem->sep.endpoint.adapter = endpoint->adapter;
     svritem->sep.endpoint.port = endpoint->port;
     svritem->sep.endpoint.flags = endpoint->flags;
     svritem->sep.endpoint.interface = endpoint->interface;
@@ -925,7 +926,7 @@ CATCPSessionInfo_t *CAConnectTCPSession(const CAEndpoint_t *endpoint)
     // pass the connection information to CA Common Layer.
     if (g_connectionCallback)
     {
-        g_connectionCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, true);
+        g_connectionCallback(&(svritem->sep.endpoint), true);
     }
 
     return svritem;
@@ -948,7 +949,7 @@ CAResult_t CADisconnectTCPSession(CATCPSessionInfo_t *svritem, size_t index)
     // pass the connection information to CA Common Layer.
     if (g_connectionCallback)
     {
-        g_connectionCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, false);
+        g_connectionCallback(&(svritem->sep.endpoint), false);
     }
 
     OICFree(svritem);