#include <unistd.h>
#include "caadapterutils.h"
-#include "umutex.h"
+#include "camutex.h"
#include "logger.h"
#include "oic_malloc.h"
#include "oic_string.h"
* @var g_stopNetworkMonitorMutex
* @brief Mutex for synchronizing access to g_stopNetworkMonitor flag.
*/
-static u_mutex g_stopNetworkMonitorMutex = NULL;
+static ca_mutex g_stopNetworkMonitorMutex = NULL;
/**
* @struct CAIPNwMonitorContext
typedef struct
{
u_arraylist_t *netInterfaceList;
- u_thread_pool_t threadPool;
+ ca_thread_pool_t threadPool;
CANetworkStatus_t nwConnectivityStatus;
CAIPConnectionStateChangeCallback networkChangeCb;
} CAIPNetworkMonitorContext;
* @var g_networkMonitorContextMutex
* @brief Mutex for synchronizing access to cached interface and IP address information.
*/
-static u_mutex g_networkMonitorContextMutex = NULL;
+static ca_mutex g_networkMonitorContextMutex = NULL;
/**
* @var g_jvm
{
VERIFY_NON_NULL_RET(info, IP_MONITOR_TAG, "info is null", false);
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
uint32_t list_length = u_arraylist_length(g_networkMonitorContext->netInterfaceList);
for (uint32_t list_index = 0; list_index < list_length; list_index++)
{
if (strncmp(netInfo->ipAddress, info->ipAddress, strlen(info->ipAddress)) == 0)
{
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
else
if (!newNetInfo)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "newNetInfo malloc failed");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
memcpy(newNetInfo, info, sizeof(*newNetInfo));
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "u_arraylist_add failed!");
OICFree(newNetInfo);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
/*Callback will be unset only at the time of termination. By that time, all the threads will be
stopped gracefully. This callback is properly protected*/
{
if (!g_networkMonitorContextMutex)
{
- g_networkMonitorContextMutex = u_mutex_new();
+ g_networkMonitorContextMutex = ca_mutex_new();
if (!g_networkMonitorContextMutex)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContextMutex Malloc failed");
if (!g_stopNetworkMonitorMutex)
{
- g_stopNetworkMonitorMutex = u_mutex_new();
+ g_stopNetworkMonitorMutex = ca_mutex_new();
if (!g_stopNetworkMonitorMutex)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_stopNetworkMonitorMutex Malloc failed");
- u_mutex_free(g_networkMonitorContextMutex);
+ ca_mutex_free(g_networkMonitorContextMutex);
return CA_MEMORY_ALLOC_FAILED;
}
}
static void CADestroyNetworkMonitorMutexes()
{
- u_mutex_free(g_networkMonitorContextMutex);
+ ca_mutex_free(g_networkMonitorContextMutex);
g_networkMonitorContextMutex = NULL;
- u_mutex_free(g_stopNetworkMonitorMutex);
+ ca_mutex_free(g_stopNetworkMonitorMutex);
g_stopNetworkMonitorMutex = NULL;
}
-CAResult_t CAIPInitializeNetworkMonitor(const u_thread_pool_t threadPool)
+CAResult_t CAIPInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
return CA_STATUS_FAILED;
}
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
g_networkMonitorContext = (CAIPNetworkMonitorContext *) OICCalloc(
1, sizeof(*g_networkMonitorContext));
if (!g_networkMonitorContext)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContext Malloc failed");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
CADestroyNetworkMonitorMutexes();
return CA_MEMORY_ALLOC_FAILED;
}
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "u_arraylist_create failed");
OICFree(g_networkMonitorContext);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
CADestroyNetworkMonitorMutexes();
return CA_MEMORY_ALLOC_FAILED;
}
g_networkMonitorContext->nwConnectivityStatus = CA_INTERFACE_DOWN;
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
g_networkMonitorContext->threadPool = NULL;
CAClearNetInterfaceInfoList(g_networkMonitorContext->netInterfaceList);
OICFree(g_networkMonitorContext);
g_networkMonitorContext = NULL;
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
- u_mutex_lock(g_stopNetworkMonitorMutex);
+ ca_mutex_lock(g_stopNetworkMonitorMutex);
g_stopNetworkMonitor = true;
- u_mutex_unlock(g_stopNetworkMonitorMutex);
+ ca_mutex_unlock(g_stopNetworkMonitorMutex);
CADestroyNetworkMonitorMutexes();
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
- u_mutex_lock(g_stopNetworkMonitorMutex);
+ ca_mutex_lock(g_stopNetworkMonitorMutex);
g_stopNetworkMonitor = false;
- u_mutex_unlock(g_stopNetworkMonitorMutex);
+ ca_mutex_unlock(g_stopNetworkMonitorMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContext is null");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_STATUS_FAILED;
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
- u_mutex_lock(g_stopNetworkMonitorMutex);
+ ca_mutex_lock(g_stopNetworkMonitorMutex);
if (!g_stopNetworkMonitor)
{
g_stopNetworkMonitor = true;
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStopNetworkMonitor, already stopped!");
}
- u_mutex_unlock(g_stopNetworkMonitorMutex);
+ ca_mutex_unlock(g_stopNetworkMonitorMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
"g_networkMonitorContextMutex is null");
// Get the interface and ipaddress information from cache
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->netInterfaceList
|| !(u_arraylist_length(g_networkMonitorContext->netInterfaceList)))
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "Network not enabled");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_ADAPTER_NOT_ENABLED;
}
if (!newNetinfo)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "Malloc failed!");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_MEMORY_ALLOC_FAILED;
}
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "u_arraylist_add failed!");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_STATUS_FAILED;
}
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
"g_networkMonitorContextMutex is null");
// Get the interface and ipaddress information from cache
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->netInterfaceList
|| (0 == u_arraylist_length(g_networkMonitorContext->netInterfaceList)))
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "Network not enabled");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_ADAPTER_NOT_ENABLED;
}
break;
}
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
return false;
}
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (0 == u_arraylist_length(g_networkMonitorContext->netInterfaceList))
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "IP is not connected");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return true;
OIC_LOG(ERROR, IP_MONITOR_TAG, "CAIPSetConnectionStateChangeCallback failed");
return;
}
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
g_networkMonitorContext->networkChangeCb = callback;
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
}
void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus)
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
- u_mutex_lock(g_stopNetworkMonitorMutex);
+ ca_mutex_lock(g_stopNetworkMonitorMutex);
if (g_stopNetworkMonitor)
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "Stop Network Monitor Thread is called");
- u_mutex_unlock(g_stopNetworkMonitorMutex);
+ ca_mutex_unlock(g_stopNetworkMonitorMutex);
return;
}
- u_mutex_unlock(g_stopNetworkMonitorMutex);
+ ca_mutex_unlock(g_stopNetworkMonitorMutex);
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->networkChangeCb)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkChangeCb is NULL");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return;
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
u_arraylist_t *netInterfaceList = u_arraylist_create();
OIC_LOG(ERROR, IP_MONITOR_TAG, "could not update interface information");
}
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->netInterfaceList)
{
OIC_LOG(ERROR, IP_MONITOR_TAG,
"u_arraylist_create failed. Network Monitor thread stopped");
CAClearNetInterfaceInfoList(netInterfaceList);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return;
}
}
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
listLength = u_arraylist_length(netInterfaceList);
for (uint32_t listIndex = 0; listIndex < listLength; listIndex++)
#include <wifi.h>
#include "caadapterutils.h"
-#include "umutex.h"
+#include "camutex.h"
#include "logger.h"
#include "oic_malloc.h"
#include "oic_string.h"
* @var g_networkMonitorContextMutex
* @brief Mutex for synchronizing access to cached interface and IP address information.
*/
-static u_mutex g_networkMonitorContextMutex = NULL;
+static ca_mutex g_networkMonitorContextMutex = NULL;
/**
* @struct CAIPNwMonitorContext
static void CARemoveInterfaceInfo()
{
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->netInterfaceList)
{
OIC_LOG(ERROR, IP_MONITOR_TAG,
"netInterfaceList is empty");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return;
}
u_arraylist_free(&g_networkMonitorContext->netInterfaceList);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
}
static bool CACheckIsInterfaceInfoChanged(const CANetInfo_t *info)
{
VERIFY_NON_NULL_RET(info, IP_MONITOR_TAG, "info is null", false);
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
uint32_t list_index = 0;
uint32_t list_length = u_arraylist_length(g_networkMonitorContext->netInterfaceList);
for (list_index = 0; list_index < list_length; list_index++)
{
if (strncmp(netInfo->ipAddress, info->ipAddress, strlen(info->ipAddress)) == 0)
{
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
else
if (!newNetInfo)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "newNetInfo malloc failed");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
memcpy(newNetInfo, info, sizeof(*newNetInfo));
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "u_arraylist_add failed!");
OICFree(newNetInfo);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
/*Callback will be unset only at the time of termination. By that time, all the threads will be
stopped gracefully. This callback is properly protected*/
{
if (!g_networkMonitorContextMutex)
{
- g_networkMonitorContextMutex = u_mutex_new();
+ g_networkMonitorContextMutex = ca_mutex_new();
if (!g_networkMonitorContextMutex)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContextMutex Malloc failed");
static void CADestroyNetworkMonitorMutexes()
{
- u_mutex_free(g_networkMonitorContextMutex);
+ ca_mutex_free(g_networkMonitorContextMutex);
g_networkMonitorContextMutex = NULL;
}
OIC_LOG(ERROR, IP_MONITOR_TAG, "CAInitializeNetworkMonitorMutexes failed");
return CA_STATUS_FAILED;
}
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
// Initialize Wifi service
wifi_error_e retValue = wifi_initialize();
if (!g_networkMonitorContext)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContext Malloc failed");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
CADestroyNetworkMonitorMutexes();
return CA_MEMORY_ALLOC_FAILED;
}
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "u_arraylist_create failed");
OICFree(g_networkMonitorContext);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
CADestroyNetworkMonitorMutexes();
return CA_MEMORY_ALLOC_FAILED;
}
CAIPGetInterfaceInformation(&g_networkMonitorContext->netInterfaceList);
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
// Deinitialize Wifi service
wifi_error_e ret = wifi_deinitialize();
OICFree(g_networkMonitorContext);
g_networkMonitorContext = NULL;
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
CADestroyNetworkMonitorMutexes();
"g_networkMonitorContextMutex is null");
// Get the interface and ipaddress information from cache
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->netInterfaceList
|| !(u_arraylist_length(g_networkMonitorContext->netInterfaceList)))
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "Network not enabled");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_ADAPTER_NOT_ENABLED;
}
if (!newNetinfo)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "Malloc failed!");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_MEMORY_ALLOC_FAILED;
}
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, IP_MONITOR_TAG, "u_arraylist_add failed!");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_STATUS_FAILED;
}
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
"g_networkMonitorContextMutex is null");
// Get the interface and ipaddress information from cache
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
if (!g_networkMonitorContext->netInterfaceList
|| !(u_arraylist_length(g_networkMonitorContext->netInterfaceList)))
{
OIC_LOG(DEBUG, IP_MONITOR_TAG, "Network not enabled");
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_ADAPTER_NOT_ENABLED;
}
break;
}
}
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
return CA_STATUS_OK;
OIC_LOG(ERROR, IP_MONITOR_TAG, "CAIPSetConnectionStateChangeCallback failed");
return;
}
- u_mutex_lock(g_networkMonitorContextMutex);
+ ca_mutex_lock(g_networkMonitorContextMutex);
g_networkMonitorContext->networkChangeCb = callback;
- u_mutex_unlock(g_networkMonitorContextMutex);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
}