replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / adapter_util / caadapterutils.c
index 7ccba06..be74098 100644 (file)
  *
  ******************************************************************/
 
+#include "iotivity_config.h"
 #include "caadapterutils.h"
 
 #include <string.h>
-
-#include "oic_malloc.h"
+#include <ctype.h>
 #include "oic_string.h"
-
-#define CA_ADAPTER_UTILS_TAG "CA_ADAPTER_UTILS"
-
-CALocalConnectivity_t *CAAdapterCreateLocalEndpoint(CAConnectivityType_t type,
-        const char *address)
+#include "oic_malloc.h"
+#include <errno.h>
+
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if defined(HAVE_WINSOCK2_H) && defined(HAVE_WS2TCPIP_H)
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef __ANDROID__
+#include <jni.h>
+#endif
+
+#define CA_ADAPTER_UTILS_TAG "OIC_CA_ADAP_UTILS"
+
+#ifdef __ANDROID__
+/**
+ * @var g_jvm
+ * @brief pointer to store JavaVM
+ */
+static JavaVM *g_jvm = NULL;
+
+/**
+ * @var gContext
+ * @brief pointer to store context for android callback interface
+ */
+static jobject g_Context = NULL;
+static jobject g_Activity = NULL;
+#endif
+
+#ifdef WITH_ARDUINO
+CAResult_t CAParseIPv4AddressInternal(const char *ipAddrStr, uint8_t *ipAddr,
+                                   size_t ipAddrLen, uint16_t *port)
 {
-    CALocalConnectivity_t *info = (CALocalConnectivity_t *)
-                                  OICMalloc(sizeof(CALocalConnectivity_t));
-    if (NULL == info)
+    if (!ipAddr || !isdigit(ipAddrStr[0]) || !port)
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
-        return NULL;
+        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "invalid param");
+        return CA_STATUS_INVALID_PARAM;
     }
-    memset(info, 0, sizeof(CALocalConnectivity_t));
 
-    info->type = type;
-    if (address && strlen(address))
+    size_t index = 0;
+    uint8_t dotCount = 0;
+
+    ipAddr[index] = 0;
+    *port = 0;
+    while (*ipAddrStr)
     {
-        if (CA_EDR == type)
+        if (isdigit(*ipAddrStr))
         {
-            strncpy(info->addressInfo.BT.btMacAddress, address, CA_MACADDR_SIZE - 1);
-            info->addressInfo.BT.btMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+            if(index >= ipAddrLen)
+            {
+                OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "invalid param");
+                return CA_STATUS_INVALID_PARAM;
+            }
+            ipAddr[index] *= 10;
+            ipAddr[index] += *ipAddrStr - '0';
         }
-        else if (CA_LE == type)
+        else if (*ipAddrStr == '.')
         {
-            strncpy(info->addressInfo.LE.leMacAddress, address, CA_MACADDR_SIZE - 1);
-            info->addressInfo.LE.leMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+            index++;
+            dotCount++;
+            ipAddr[index] = 0;
         }
-        else if (CA_WIFI == type || CA_ETHERNET == type)
+        else
         {
-            strncpy(info->addressInfo.IP.ipAddress, address, CA_IPADDR_SIZE - 1);
-            info->addressInfo.IP.ipAddress[CA_IPADDR_SIZE - 1] = '\0';
+            break;
         }
+        ipAddrStr++;
     }
 
-    return info;
-}
-
-CALocalConnectivity_t *CAAdapterCopyLocalEndpoint(CALocalConnectivity_t *connectivity)
-{
-    VERIFY_NON_NULL_RET(connectivity, CA_ADAPTER_UTILS_TAG, "connectivity is NULL", NULL);
-
-    CALocalConnectivity_t *info = (CALocalConnectivity_t *)
-                                  OICMalloc(sizeof(CALocalConnectivity_t));
-    if (NULL == info)
+    if (*ipAddrStr == ':')
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
-        return NULL;
+        ipAddrStr++;
+        while (*ipAddrStr)
+        {
+            if (isdigit(*ipAddrStr))
+            {
+                *port *= 10;
+                *port += *ipAddrStr - '0';
+            }
+            else
+            {
+                break;
+            }
+            ipAddrStr++;
+        }
     }
-    memset(info, 0, sizeof(CALocalConnectivity_t));
 
-    info->type = connectivity->type;
-    if (CA_EDR == info->type && strlen(connectivity->addressInfo.BT.btMacAddress))
-    {
-        strncpy(info->addressInfo.BT.btMacAddress, connectivity->addressInfo.BT.btMacAddress,
-                CA_MACADDR_SIZE - 1);
-        info->addressInfo.BT.btMacAddress[CA_MACADDR_SIZE - 1] = '\0';
-    }
-    else if (CA_LE == info->type && strlen(connectivity->addressInfo.LE.leMacAddress))
+    if (dotCount == 3)
     {
-        strncpy(info->addressInfo.LE.leMacAddress, connectivity->addressInfo.LE.leMacAddress,
-                CA_MACADDR_SIZE - 1);
-        info->addressInfo.LE.leMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+        return CA_STATUS_OK;
     }
-    else if ((CA_WIFI == info->type || CA_ETHERNET == info->type)
-             && strlen(connectivity->addressInfo.IP.ipAddress))
-    {
-        strncpy(info->addressInfo.IP.ipAddress, connectivity->addressInfo.IP.ipAddress,
-                CA_IPADDR_SIZE - 1);
-        info->addressInfo.IP.ipAddress[CA_IPADDR_SIZE - 1] = '\0';
-        info->addressInfo.IP.port = connectivity->addressInfo.IP.port;
-    }
-
-    info->isSecured = connectivity->isSecured;
-    return info;
+    return CA_STATUS_FAILED;
 }
 
-void CAAdapterFreeLocalEndpoint(CALocalConnectivity_t *localEndpoint)
+#else // not with_arduino
+/*
+ * These two conversion functions return void because errors can't happen
+ * (because of NI_NUMERIC), and there's nothing to do if they do happen.
+ */
+void CAConvertAddrToName(const struct sockaddr_storage *sockAddr, socklen_t sockAddrLen,
+                         char *host, uint16_t *port)
 {
-    if (localEndpoint)
+    VERIFY_NON_NULL_VOID(sockAddr, CA_ADAPTER_UTILS_TAG, "sockAddr is null");
+    VERIFY_NON_NULL_VOID(host, CA_ADAPTER_UTILS_TAG, "host is null");
+    VERIFY_NON_NULL_VOID(port, CA_ADAPTER_UTILS_TAG, "port is null");
+
+    int r = getnameinfo((struct sockaddr *)sockAddr,
+                        sockAddrLen,
+                        host, MAX_ADDR_STR_SIZE_CA,
+                        NULL, 0,
+                        NI_NUMERICHOST|NI_NUMERICSERV);
+    if (r)
     {
-        OICFree(localEndpoint);
+#if defined(EAI_SYSTEM)
+        if (EAI_SYSTEM == r)
+        {
+            OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getnameinfo failed: errno %s", strerror(errno));
+        }
+        else
+        {
+            OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getnameinfo failed: %s", gai_strerror(r));
+        }
+#elif defined(_WIN32)
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getnameinfo failed: errno %i", WSAGetLastError());
+#else
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getnameinfo failed: %s", gai_strerror(r));
+#endif
+        return;
     }
+    *port = ntohs(((struct sockaddr_in *)sockAddr)->sin_port); // IPv4 and IPv6
 }
 
-CARemoteEndpoint_t *CAAdapterCreateRemoteEndpoint(CAConnectivityType_t type,
-        const char *address,
-        const char *resourceUri)
+void CAConvertNameToAddr(const char *host, uint16_t port, struct sockaddr_storage *sockaddr)
 {
-    CARemoteEndpoint_t *info = (CARemoteEndpoint_t *)
-                               OICMalloc(sizeof(CARemoteEndpoint_t));
-    if (NULL == info)
-    {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
-        return NULL;
-    }
-    memset(info, 0, sizeof(CARemoteEndpoint_t));
+    VERIFY_NON_NULL_VOID(host, CA_ADAPTER_UTILS_TAG, "host is null");
+    VERIFY_NON_NULL_VOID(sockaddr, CA_ADAPTER_UTILS_TAG, "sockaddr is null");
 
-    info->connectivityType = type;
-    if (address && strlen(address))
+    struct addrinfo *addrs = NULL;
+    struct addrinfo hints = { .ai_family = AF_UNSPEC,
+                              .ai_socktype = SOCK_DGRAM,
+                              .ai_flags = AI_NUMERICHOST };
+
+    int r = getaddrinfo(host, NULL, &hints, &addrs);
+    if (r)
     {
-        if (CA_EDR == type)
+        if (NULL != addrs)
         {
-            strncpy(info->addressInfo.BT.btMacAddress, address, CA_MACADDR_SIZE - 1);
-            info->addressInfo.BT.btMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+            freeaddrinfo(addrs);
         }
-        else if (CA_LE == info->connectivityType)
+#if defined(EAI_SYSTEM)
+        if (EAI_SYSTEM == r)
         {
-            strncpy(info->addressInfo.LE.leMacAddress, address, CA_MACADDR_SIZE - 1);
-            info->addressInfo.LE.leMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+            OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getaddrinfo failed: errno %s", strerror(errno));
         }
-        else if (CA_WIFI == type || CA_ETHERNET == type)
+        else
         {
-            strncpy(info->addressInfo.IP.ipAddress, address, CA_IPADDR_SIZE - 1);
-            info->addressInfo.IP.ipAddress[CA_IPADDR_SIZE - 1] = '\0';
+            OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getaddrinfo failed: %s", gai_strerror(r));
         }
+#elif defined(_WIN32)
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getaddrinfo failed: errno %i", WSAGetLastError());
+#else
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG,
+                            "getaddrinfo failed: %s", gai_strerror(r));
+#endif
+        return;
     }
-
-    if (resourceUri && strlen(resourceUri))
+    // assumption: in this case, getaddrinfo will only return one addrinfo
+    // or first is the one we want.
+    if (addrs[0].ai_family == AF_INET6)
     {
-        info->resourceUri = OICStrdup(resourceUri);
+        memcpy(sockaddr, addrs[0].ai_addr, sizeof (struct sockaddr_in6));
+        ((struct sockaddr_in6 *)sockaddr)->sin6_port = htons(port);
     }
-
-    return info;
+    else
+    {
+        memcpy(sockaddr, addrs[0].ai_addr, sizeof (struct sockaddr_in));
+        ((struct sockaddr_in *)sockaddr)->sin_port = htons(port);
+    }
+    freeaddrinfo(addrs);
 }
+#endif // WITH_ARDUINO
 
-CARemoteEndpoint_t *CAAdapterCopyRemoteEndpoint(const CARemoteEndpoint_t *remoteEndpoint)
+#ifdef __ANDROID__
+void CANativeJNISetContext(JNIEnv *env, jobject context)
 {
-    VERIFY_NON_NULL_RET(remoteEndpoint, CA_ADAPTER_UTILS_TAG, "Remote endpoint is NULL", NULL);
+    OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeJNISetContext");
 
-    CARemoteEndpoint_t *info = (CARemoteEndpoint_t *)
-                               OICMalloc(sizeof(CARemoteEndpoint_t));
-    if (NULL == info)
+    if (!context)
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Memory allocation failed !");
-        return NULL;
+        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "context is null");
+        return;
     }
-    memset(info, 0, sizeof(CARemoteEndpoint_t));
 
-    info->connectivityType = remoteEndpoint->connectivityType;
-    if (CA_EDR == info->connectivityType && strlen(remoteEndpoint->addressInfo.BT.btMacAddress))
+    if (!g_Context)
     {
-        strncpy(info->addressInfo.BT.btMacAddress, remoteEndpoint->addressInfo.BT.btMacAddress,
-                CA_MACADDR_SIZE - 1);
-        info->addressInfo.BT.btMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+        g_Context = (*env)->NewGlobalRef(env, context);
     }
-    else if (CA_LE == info->connectivityType && strlen(remoteEndpoint->addressInfo.LE.leMacAddress))
+    else
     {
-        strncpy(info->addressInfo.LE.leMacAddress, remoteEndpoint->addressInfo.LE.leMacAddress,
-                CA_MACADDR_SIZE - 1);
-        info->addressInfo.LE.leMacAddress[CA_MACADDR_SIZE - 1] = '\0';
+        OIC_LOG(INFO, CA_ADAPTER_UTILS_TAG, "context is already set");
     }
-    else if ((CA_WIFI == info->connectivityType || CA_ETHERNET == info->connectivityType)
-             && strlen(remoteEndpoint->addressInfo.IP.ipAddress))
+}
+
+void CANativeJNISetJavaVM(JavaVM *jvm)
+{
+    OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeJNISetJavaVM");
+    g_jvm = jvm;
+}
+
+jobject CANativeJNIGetContext()
+{
+    return g_Context;
+}
+
+JavaVM *CANativeJNIGetJavaVM()
+{
+    return g_jvm;
+}
+
+void CANativeSetActivity(JNIEnv *env, jobject activity)
+{
+    OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeSetActivity");
+
+    if (!activity)
     {
-        strncpy(info->addressInfo.IP.ipAddress, remoteEndpoint->addressInfo.IP.ipAddress,
-                CA_IPADDR_SIZE - 1);
-        info->addressInfo.IP.ipAddress[CA_IPADDR_SIZE - 1] = '\0';
-        info->addressInfo.IP.port = remoteEndpoint->addressInfo.IP.port;
+        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "activity is null");
+        return;
     }
 
-    if (remoteEndpoint->resourceUri && strlen(remoteEndpoint->resourceUri))
+    if (!g_Activity)
+    {
+        g_Activity = (*env)->NewGlobalRef(env, activity);
+    }
+    else
     {
-        info->resourceUri = OICStrdup(remoteEndpoint->resourceUri);
+        OIC_LOG(INFO, CA_ADAPTER_UTILS_TAG, "activity is already set");
     }
+}
 
-    info->isSecured = remoteEndpoint->isSecured;
-    return info;
+jobject *CANativeGetActivity()
+{
+    return g_Activity;
 }
 
-void CAAdapterFreeRemoteEndpoint(CARemoteEndpoint_t *remoteEndpoint)
+jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className,
+                           const char* methodName,
+                           const char* methodFormat)
 {
-    if (remoteEndpoint)
+    VERIFY_NON_NULL_RET(env, CA_ADAPTER_UTILS_TAG, "env", NULL);
+    VERIFY_NON_NULL_RET(className, CA_ADAPTER_UTILS_TAG, "className", NULL);
+    VERIFY_NON_NULL_RET(methodName, CA_ADAPTER_UTILS_TAG, "methodName", NULL);
+    VERIFY_NON_NULL_RET(methodFormat, CA_ADAPTER_UTILS_TAG, "methodFormat", NULL);
+
+    jclass jni_cid = (*env)->FindClass(env, className);
+    if (!jni_cid)
     {
-        if (remoteEndpoint->resourceUri)
-        {
-            OICFree(remoteEndpoint->resourceUri);
-        }
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, "jni_cid [%s] is null", className);
+        CACheckJNIException(env);
+        return NULL;
+    }
 
-        OICFree(remoteEndpoint);
+    jmethodID jni_midID = (*env)->GetMethodID(env, jni_cid, methodName, methodFormat);
+    if (!jni_midID)
+    {
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, "jni_midID [%s] is null", methodName);
+        CACheckJNIException(env);
+        (*env)->DeleteLocalRef(env, jni_cid);
+        return NULL;
     }
+
+    (*env)->DeleteLocalRef(env, jni_cid);
+    return jni_midID;
 }
 
-bool CAAdapterIsSameSubnet(const char *ipAddress1, const char *ipAddress2,
-                           const char *netMask)
+bool CACheckJNIException(JNIEnv *env)
 {
-    VERIFY_NON_NULL_RET(ipAddress1, CA_ADAPTER_UTILS_TAG, "First address", false);
-    VERIFY_NON_NULL_RET(ipAddress2, CA_ADAPTER_UTILS_TAG, "Second address", false);
-    VERIFY_NON_NULL_RET(netMask, CA_ADAPTER_UTILS_TAG, "netMask", false);
-
-    int32_t ipList1[8] = {0};
-    int32_t ipList2[8] = {0};
-    int32_t maskList[8] = {0};
-
-    /* Local Loopback Address */
-    if (0 == strncmp(ipAddress1, "127.", 4)
-        || 0 == strncmp(ipAddress2, "127.", 4))
+    if ((*env)->ExceptionCheck(env))
     {
+        (*env)->ExceptionDescribe(env);
+        (*env)->ExceptionClear(env);
         return true;
     }
+    return false;
+}
 
-    char *ipAdrs1 = OICStrdup(ipAddress1);
-    if (!ipAdrs1)
+void CADeleteGlobalReferences(JNIEnv *env)
+{
+    if (g_Context)
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Failed to get dup string!");
-        return false;
+        (*env)->DeleteGlobalRef(env, g_Context);
+        g_Context = NULL;
     }
 
-    int16_t index = 0;
-    int16_t lastDotIndex = 0;
-    int16_t ip1TokenCount = 0;
-    while ('\0' != ipAdrs1[index])
+    if (g_Activity)
     {
-        if ('.' == ipAdrs1[index])
-        {
-            ipAdrs1[index] = '\0';
-            ipList1[ip1TokenCount++] = atoi(ipAdrs1 + lastDotIndex);
-            lastDotIndex = index + 1;
-        }
-        index++;
+        (*env)->DeleteGlobalRef(env, g_Activity);
+        g_Activity = NULL;
     }
-    // Add last touple
-    ipList1[ip1TokenCount] = atoi(ipAdrs1 + lastDotIndex);
+}
+#endif
 
-    char *ipAdrs2 = OICStrdup(ipAddress2);
-    if (!ipAdrs2)
+#ifndef WITH_ARDUINO
+void CALogAdapterStateInfo(CATransportAdapter_t adapter, CANetworkStatus_t state)
+{
+    OIC_LOG(DEBUG, CA_ADAPTER_UTILS_TAG, "CALogAdapterStateInfo");
+    OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+    CALogAdapterTypeInfo(adapter);
+    if (CA_INTERFACE_UP == state)
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Failed to get dup string!");
-        OICFree(ipAdrs1);
-        return false;
+        OIC_LOG(INFO, ANALYZER_TAG, "adapter status is changed to CA_INTERFACE_UP");
     }
-
-    index = 0;
-    lastDotIndex = 0;
-    int16_t ip2TokenCount = 0;
-    while ('\0' != ipAdrs2[index])
+    else
     {
-        if ('.' == ipAdrs2[index])
-        {
-            ipAdrs2[index] = '\0';
-            ipList2[ip2TokenCount++] = atoi(ipAdrs2 + lastDotIndex);
-            lastDotIndex = index + 1;
-        }
-        index++;
+        OIC_LOG(INFO, ANALYZER_TAG, "adapter status is changed to CA_INTERFACE_DOWN");
     }
-    // Add last touple
-    ipList2[ip2TokenCount] = atoi(ipAdrs2 + lastDotIndex);
+    OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+}
+
+void CALogSendStateInfo(CATransportAdapter_t adapter,
+                        const char *addr, uint16_t port, ssize_t sentLen,
+                        bool isSuccess, const char* message)
+{
+    OIC_LOG(DEBUG, CA_ADAPTER_UTILS_TAG, "CALogSendStateInfo");
+    OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
 
-    char *nMask = OICStrdup(netMask);
-    if (!nMask)
+    if (true == isSuccess)
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Failed to get dup string!");
-        OICFree(ipAdrs1);
-        OICFree(ipAdrs2);
-        return false;
+        OIC_LOG_V(INFO, ANALYZER_TAG, "Send Success, sent length = [%d]", sentLen);
     }
-
-    index = 0;
-    lastDotIndex = 0;
-    int16_t maskTokenCount = 0;
-    while ('\0' != nMask[index])
+    else
     {
-        if ('.' == nMask[index])
-        {
-            nMask[index] = '\0';
-            maskList[maskTokenCount++] = atoi(nMask + lastDotIndex);
-            lastDotIndex = index + 1;
-        }
-        index++;
+        OIC_LOG_V(INFO, ANALYZER_TAG, "Send Failure, error message  = [%s]",
+                  message != NULL ? message : "no message");
     }
-    // Add last touple
-    maskList[maskTokenCount] = atoi(nMask + lastDotIndex);
 
-    OICFree(ipAdrs1);
-    OICFree(ipAdrs2);
-    OICFree(nMask);
+    CALogAdapterTypeInfo(adapter);
+    OIC_LOG_V(INFO, ANALYZER_TAG, "Address = [%s]:[%d]", addr, port);
+    OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
 
-    if (ip1TokenCount < 3 || ip2TokenCount < 3 || maskTokenCount < 3)
+    // samsung log
+    if (true == isSuccess)
+    {
+        OIC_LOG_V(INFO, CA_ADAPTER_UTILS_TAG, "| Analyzer(Retail) | %02x", 1);
+    }
+    else
     {
-        OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "Address or mask is invalid!");
-        return false;
+        OIC_LOG_V(INFO, CA_ADAPTER_UTILS_TAG, "| Analyzer(Retail) | %02x", 0);
     }
+}
 
-    if (((ipList1[0]& maskList[0]) == (ipList2[0]& maskList[0]))
-        && ((ipList1[1]& maskList[1]) == (ipList2[1]& maskList[1]))
-        && ((ipList1[2]& maskList[2]) == (ipList2[2]& maskList[2]))
-        && ((ipList1[3]& maskList[3]) == (ipList2[3]& maskList[3])))
+void CALogAdapterTypeInfo(CATransportAdapter_t adapter)
+{
+    switch(adapter)
     {
-        return true;
+        case CA_ADAPTER_IP:
+            OIC_LOG(INFO, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_IP]");
+            break;
+        case CA_ADAPTER_TCP:
+            OIC_LOG(INFO, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_TCP]");
+            break;
+        case CA_ADAPTER_GATT_BTLE:
+            OIC_LOG(INFO, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_GATT_BTLE]");
+            break;
+        case CA_ADAPTER_RFCOMM_BTEDR:
+            OIC_LOG(INFO, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_RFCOMM_BTEDR]");
+            break;
+        default:
+            OIC_LOG_V(INFO, ANALYZER_TAG, "Transport Type = [%d]", adapter);
+            break;
     }
-    return false;
 }
+#endif