Integrated WIFI/ETHERNET adapters to single IPAdapter.
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / cainterfacecontroller_singlethread.c
index ab013d1..169ee7e 100644 (file)
@@ -25,8 +25,7 @@
 #include <string.h>
 #include <stdint.h>
 
-#include "cawifiadapter_singlethread.h"
-#include "caethernetadapter_singlethread.h"
+#include "caipadapter_singlethread.h"
 #include "caedradapter_singlethread.h"
 #include "caleadapter_singlethread.h"
 #include "caadapterutils.h"
@@ -48,13 +47,13 @@ static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
 
 static CANetworkChangeCallback g_networkChangeCallback = NULL;
 
-static int CAGetAdapterIndex(CAConnectivityType_t cType)
+static int CAGetAdapterIndex(CATransportType_t cType)
 {
     switch (cType)
     {
-        case CA_ETHERNET:
+        case CA_IPV4:
             return 0;
-        case CA_WIFI:
+        case CA_IPV6:
             return 1;
         case CA_EDR:
             return 2;
@@ -67,7 +66,7 @@ static int CAGetAdapterIndex(CAConnectivityType_t cType)
     return -1;
 }
 
-static void CARegisterCallback(CAConnectivityHandler_t handler, CAConnectivityType_t cType)
+static void CARegisterCallback(CAConnectivityHandler_t handler, CATransportType_t cType)
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
@@ -131,13 +130,9 @@ void CAInitializeAdapters()
     memset(g_adapterHandler, 0, sizeof(CAConnectivityHandler_t) * CA_CONNECTIVITY_TYPE_NUM);
 
     // Initialize adapters and register callback.
-#ifdef ETHERNET_ADAPTER
-    CAInitializeEthernet(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback);
-#endif /* ETHERNET_ADAPTER */
-
-#ifdef WIFI_ADAPTER
-    CAInitializeWIFI(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback);
-#endif /* WIFI_ADAPTER */
+#ifdef IP_ADAPTER
+    CAInitializeIP(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback);
+#endif /* IP_ADAPTER */
 
 #ifdef EDR_ADAPTER
     CAInitializeEDR(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback);
@@ -146,8 +141,8 @@ void CAInitializeAdapters()
 #ifdef LE_ADAPTER
     CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback);
 #endif /* LE_ADAPTER */
-    OIC_LOG(DEBUG, TAG, "OUT");
 
+    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback)
@@ -166,11 +161,11 @@ void CASetNetworkChangeCallback(CANetworkChangeCallback callback)
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
-CAResult_t CAStartAdapter(CAConnectivityType_t cType)
+CAResult_t CAStartAdapter(CATransportType_t transportType)
 {
-    OIC_LOG_V(DEBUG, TAG, "cType[%d]", cType);
+    OIC_LOG_V(DEBUG, TAG, "transportType[%d]", transportType);
 
-    int index = CAGetAdapterIndex(cType);
+    int index = CAGetAdapterIndex(transportType);
 
     if (index == -1)
     {
@@ -186,11 +181,11 @@ CAResult_t CAStartAdapter(CAConnectivityType_t cType)
     return CA_STATUS_OK;
 }
 
-void CAStopAdapter(CAConnectivityType_t cType)
+void CAStopAdapter(CATransportType_t transportType)
 {
-    OIC_LOG_V(DEBUG, TAG, "cType[%d]", cType);
+    OIC_LOG_V(DEBUG, TAG, "transportType[%d]", transportType);
 
-    int index = CAGetAdapterIndex(cType);
+    int index = CAGetAdapterIndex(transportType);
 
     if (index == -1)
     {
@@ -305,7 +300,7 @@ CAResult_t CASendUnicastData(const CARemoteEndpoint_t *endpoint, const void *dat
         return CA_STATUS_INVALID_PARAM;
     }
 
-    CAConnectivityType_t type = endpoint->connectivityType;
+    CATransportType_t type = endpoint->transportType;
 
     int index = CAGetAdapterIndex(type);
 
@@ -350,7 +345,8 @@ CAResult_t CASendMulticastData(const void *data, uint32_t length)
         {
             continue;
         }
-        CAConnectivityType_t connType = *(CAConnectivityType_t *) ptrType;
+
+        CATransportType_t connType = *(CATransportType_t *) ptrType;
 
         int index = CAGetAdapterIndex(connType);
 
@@ -395,7 +391,8 @@ CAResult_t CAStartListeningServerAdapters()
             OIC_LOG(ERROR, TAG, "Invalid conn type");
             continue;
         }
-        CAConnectivityType_t connType = *(CAConnectivityType_t *) ptrType;
+
+        CATransportType_t connType = *(CATransportType_t *) ptrType;
 
         int index = CAGetAdapterIndex(connType);
 
@@ -433,7 +430,8 @@ CAResult_t CAStartDiscoveryServerAdapters()
         {
             continue;
         }
-        CAConnectivityType_t connType = *(CAConnectivityType_t *) ptrType;
+
+        CATransportType_t connType = *(CATransportType_t *) ptrType;
 
         int index = CAGetAdapterIndex(connType);
 
@@ -492,7 +490,7 @@ CAResult_t CAReadData()
             return CA_STATUS_FAILED;
         }
 
-        CAConnectivityType_t connType = *(CAConnectivityType_t *) ptrType;
+        CATransportType_t connType = *(CATransportType_t *) ptrType;
 
         int index = CAGetAdapterIndex(connType);