Example #1
0
ProvisioningInfo *PrepareProvisioingStatusCB(OCClientResponse *clientResponse,
                                             ProvStatus provStatus) {

    ProvisioningInfo *provInfo = (ProvisioningInfo *) OICCalloc(1, sizeof(ProvisioningInfo));

    if (provInfo == NULL) {
        OIC_LOG_V(ERROR, ES_PROV_TAG, "Failed to allocate memory");
        return NULL;
    }

    OCDevAddr *devAddr = (OCDevAddr *) OICCalloc(1, sizeof(OCDevAddr));

    if (devAddr == NULL) {
        OIC_LOG_V(ERROR, ES_PROV_TAG, "Failed to allocate memory");
        OICFree(provInfo);
        return NULL;
    }

    OICStrcpy(devAddr->addr, sizeof(devAddr->addr), clientResponse->addr->addr);

    devAddr->port = clientResponse->addr->port;

    provInfo->provDeviceInfo.addr = devAddr;

    provInfo->provStatus = provStatus;

    return provInfo;
}
CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
{
    u_arraylist_t *list = CAGetSelectedNetworkList();
    if (!list)
    {
        OIC_LOG(DEBUG, TAG, "No selected network");
        return CA_SEND_FAILED;
    }

    CATransportFlags_t requestedAdapter = endpoint->adapter ? endpoint->adapter : CA_ALL_ADAPTERS;
    size_t selectedLength = u_arraylist_length(list);
    for (size_t i = 0; i < selectedLength; i++)
    {
        void* ptrType = u_arraylist_get(list, i);

        if(ptrType == NULL)
        {
            continue;
        }

        CATransportAdapter_t connType = *(CATransportAdapter_t *)ptrType;
        if ((connType & requestedAdapter) == 0)
        {
            continue;
        }

        int index = CAGetAdapterIndex(connType);
        if (0 > index)
        {
            OIC_LOG(DEBUG, TAG, "unknown connectivity type!");
            continue;
        }

        uint32_t sentDataLen = 0;

        if (g_adapterHandler[index].sendDataToAll != NULL)
        {
            void *payload = (void *) OICMalloc(length);
            if (!payload)
            {
                OIC_LOG(ERROR, TAG, "Out of memory!");
                return CA_MEMORY_ALLOC_FAILED;
            }
            memcpy(payload, data, length);
            sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length);
            OICFree(payload);
        }

        if (sentDataLen != length)
        {
            OIC_LOG(ERROR, TAG, "sendDataToAll failed! Error will be reported from adapter");
#ifdef SINGLE_THREAD
            //in case of single thread, no error handler. Report error immediately
            return CA_SEND_FAILED;
#endif
        }
    }

    return CA_STATUS_OK;
}
Example #3
0
void OCFreeLinksResource(OCLinksPayload *payload)
{
    if (!payload)
    {
        return;
    }
    OICFree(payload->href);
    OCFreeOCStringLL(payload->rt);
    OCFreeOCStringLL(payload->itf);
    OICFree(payload->rel);
    OICFree(payload->title);
    OICFree(payload->uri);
    OCFreeOCStringLL(payload->mt);
    OCFreeLinksResource(payload->next);
    OICFree(payload);
}
Example #4
0
void OCFreeLinksResource(OCLinksPayload *links)
{
    if (!links)
    {
        return;
    }
    OICFree(links->href);
    OICFree(links->rel);
    OCFreeOCStringLL(links->rt);
    OCFreeOCStringLL(links->itf);
    OICFree(links->title);
    OICFree(links->anchor);
    OCFreeOCStringLL(links->type);
    OCFreeLinksResource(links->next);
    OICFree(links);
}
Example #5
0
CAResult_t u_linklist_free(u_linklist_t **linklist)
{
    VERIFY_NON_NULL(linklist, TAG, "linklist is null");
    if (!(*linklist))
    {
        OIC_LOG(DEBUG, TAG, "List is already Empty");
        return CA_STATUS_OK;
    }

    u_linklist_data_t *free_node=NULL;
    while((*linklist)->size)
    {
        free_node = (*linklist)->list;
        (*linklist)->list = (*linklist)->list->next;

        if(free_node != NULL)
        {
            OICFree(free_node);
            free_node=NULL;
        }

        (*linklist)->size -= 1;
    }
    *linklist=NULL;

    return CA_STATUS_OK;
}
void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env)
{
    OIC_LOG(DEBUG, TAG, "CANativeRemoveAllDeviceObjsList");

    if (!g_deviceObjectList)
    {
        OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
        return;
    }

    jint length = u_arraylist_length(g_deviceStateList);
    for (jint index = 0; index < length; index++)
    {
        jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
        if (!jarrayObj)
        {
            OIC_LOG(ERROR, TAG, "jarrayObj is null");
            return;
        }
        (*env)->DeleteGlobalRef(env, jarrayObj);
    }

    OICFree(g_deviceObjectList);
    g_deviceObjectList = NULL;
    return;
}
void DeleteSVCList(OicSecSvc_t* svc)
{
    if (svc)
    {
        OicSecSvc_t *svcTmp1 = NULL, *svcTmp2 = NULL;
        LL_FOREACH_SAFE(svc, svcTmp1, svcTmp2)
        {
            LL_DELETE(svc, svcTmp1);

            // Clean Owners
            OICFree(svcTmp1->owners);

            // Clean SVC node itself
            OICFree(svcTmp1);
        }
    }
CAResult_t CABleGattDiscoverCharacteristics(bt_gatt_attribute_h service,
        const char *remoteAddress)
{
    OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");

    VERIFY_NON_NULL_RET(service, TZ_BLE_CLIENT_TAG, "service is NULL", CA_STATUS_FAILED);

    VERIFY_NON_NULL_RET(remoteAddress, TZ_BLE_CLIENT_TAG, "remoteAddress is NULL", CA_STATUS_FAILED);

    char *addr = OICStrdup(remoteAddress);
    VERIFY_NON_NULL_RET(addr, TZ_BLE_CLIENT_TAG, "Malloc failed", CA_STATUS_FAILED);

    int32_t ret = bt_gatt_discover_characteristics(service, CABleGattCharacteristicsDiscoveredCb,
                  (void *)addr); // addr will be freed in callback.
    if (BT_ERROR_NONE != ret)
    {
        OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
                  "bt_gatt_discover_characteristics failed with error [%d]", ret);
        OICFree(addr);
        return CA_STATUS_FAILED;
    }

    OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
    return CA_STATUS_OK;
}
Example #9
0
void OCPayloadDestroy(OCPayload* payload)
{
    if(!payload)
    {
        return;
    }

    switch(payload->type)
    {
        case PAYLOAD_TYPE_REPRESENTATION:
            OCRepPayloadDestroy((OCRepPayload*)payload);
            break;
        case PAYLOAD_TYPE_DISCOVERY:
            OCDiscoveryPayloadDestroy((OCDiscoveryPayload*)payload);
            break;
        case PAYLOAD_TYPE_DEVICE:
            OCDevicePayloadDestroy((OCDevicePayload*)payload);
            break;
        case PAYLOAD_TYPE_PLATFORM:
            OCPlatformPayloadDestroy((OCPlatformPayload*)payload);
            break;
        case PAYLOAD_TYPE_PRESENCE:
            OCPresencePayloadDestroy((OCPresencePayload*)payload);
            break;
        case PAYLOAD_TYPE_SECURITY:
            OCSecurityPayloadDestroy((OCSecurityPayload*)payload);
            break;
        default:
            OC_LOG_V(ERROR, TAG, "Unsupported payload type in destroy: %d", payload->type);
            OICFree(payload);
            break;
    }
}
static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uint32_t size)
{
    OIC_LOG(DEBUG, TAG, "IN");
    CAEndpoint_t* ep = CACloneEndpoint(endpoint);
    if (NULL == ep)
    {
        OIC_LOG(ERROR, TAG, "clone failed");
        return;
    }

    CAResponseInfo_t* resInfo = (CAResponseInfo_t*) OICCalloc(1, sizeof(CAResponseInfo_t));

    if (NULL == resInfo)
    {
        OIC_LOG(ERROR, TAG, "calloc failed");
        CAFreeEndpoint(ep);
        return;
    }

    resInfo->result = CA_RETRANSMIT_TIMEOUT;
    resInfo->info.type = CAGetMessageTypeFromPduBinaryData(pdu, size);
    resInfo->info.messageId = CAGetMessageIdFromPduBinaryData(pdu, size);

    if (g_responseHandler)
    {
        g_responseHandler(ep, resInfo);
    }

    CAFreeEndpoint(ep);
    OICFree(resInfo);

    OIC_LOG(DEBUG, TAG, "OUT");
}
Example #11
0
CAResult_t CABleGattDiscoverServices(const char *remoteAddress)
{
    OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");

    VERIFY_NON_NULL_RET(remoteAddress, TZ_BLE_CLIENT_TAG,
                        "remote address is NULL", CA_STATUS_FAILED);

    char *addr = OICStrdup(remoteAddress);
    VERIFY_NON_NULL_RET(addr, TZ_BLE_CLIENT_TAG, "Malloc failed", CA_STATUS_FAILED);

    int32_t ret = bt_gatt_foreach_primary_services(remoteAddress, CABleGattPrimaryServiceCb,
                  (void *)addr); // addr memory will be free in callback.
    if (BT_ERROR_NONE != ret)
    {
        OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
                  "bt_gatt_foreach_primary_services Failed with ret value [%d] ", ret);
        OICFree(addr);
        return CA_STATUS_FAILED;
    }
    else
    {
        OIC_LOG_V(DEBUG, TZ_BLE_CLIENT_TAG,
                  "bt_gatt_foreach_primary_services success for address [%s]", remoteAddress);
    }

    OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
    return CA_STATUS_OK;
}
Example #12
0
void CAEDRNativeRemoveDevice(const char *remoteAddress)
{
    OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceforStateList");

    if(!g_deviceStateList)
    {
        OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceStateList is null");
        return;
    }
    if (!remoteAddress) {
        OIC_LOG(ERROR, TAG, "[EDR][Native] remoteAddress is null");
        return;
    }

    jint index;
    for (index = 0; index < u_arraylist_length(g_deviceStateList); index++)
    {
        state_t* state = (state_t*) u_arraylist_get(g_deviceStateList, index);
        if(!state)
        {
            OIC_LOG(DEBUG, TAG, "[EDR][Native] state_t object is null");
            continue;
        }

        if(!strcmp(state->address, remoteAddress))
        {
            OIC_LOG_V(DEBUG, TAG, "[EDR][Native] remove state : %s", remoteAddress);
            OICFree(state);

            CAEDRReorderingDeviceList(index);
            break;
        }
    }
    return;
}
Example #13
0
u_queue_message_t *u_queue_get_element(u_queue_t *queue)
{
    u_queue_element *element = NULL;
    u_queue_message_t *message = NULL;

    if (NULL == queue)
    {
        OIC_LOG(DEBUG, TAG, "QueueAddElement FAIL, Invalid Queue");
        return NULL;
    }

    element = queue->element;

    if (NULL == element)
    {
        return NULL;
    }

    queue->element = element->next;;
    queue->count--;

    message = element->message;
    OICFree(element);
    return message;
}
Example #14
0
static OCStackResult OCParseSecurityPayload(OCPayload** outPayload, CborValue* rootValue)
{
    OCStackResult ret = OC_STACK_MALFORMED_RESPONSE;
    CborError err;
    char *securityData = NULL;

    VERIFY_PARAM_NON_NULL(TAG, outPayload, "Invalid parameter");
    VERIFY_PARAM_NON_NULL(TAG, outPayload, "Invalid cbor");

    CborValue strVal;

    err = cbor_value_enter_container(rootValue, &strVal);
    VERIFY_CBOR_SUCCESS(TAG, err, "Failed entering container");
    if (cbor_value_is_text_string(&strVal))
    {
        size_t len = 0;
        err = cbor_value_dup_text_string(&strVal, &securityData, &len, NULL);
        VERIFY_CBOR_SUCCESS(TAG, err, "Failed reading security data");
        *outPayload = (OCPayload *)OCSecurityPayloadCreate(securityData);
        VERIFY_PARAM_NON_NULL(TAG, *outPayload, "Invalid cbor");
        ret = OC_STACK_OK;
    }

exit:
    OICFree(securityData);
    return ret;

}
Example #15
0
void CAIPTerminateServer()
{
    OIC_LOG(DEBUG, IP_SERVER_TAG, "IN");
    ca_mutex_lock(g_mutexAdapterServerContext);
    if (!g_adapterIPServerContext)
    {
        OIC_LOG(ERROR, IP_SERVER_TAG, "g_adapterIPServerContext NULL");
        ca_mutex_unlock(g_mutexAdapterServerContext);
        return;
    }

    OICFree(g_adapterIPServerContext);
    g_adapterIPServerContext = NULL;

    ca_mutex_unlock(g_mutexAdapterServerContext);

    ca_mutex_lock(g_mutexServerInfoList);

    CAClearServerInfoList(g_serverInfoList);
    g_serverInfoList = NULL;

    ca_mutex_unlock(g_mutexServerInfoList);
    // Destroy mutex
    CAIPServerDestroyMutex();

    OIC_LOG(DEBUG, IP_SERVER_TAG, "OUT");

}
Example #16
0
/**
 * Initialize DOXM resource by loading data from persistent storage.
 *
 * @retval  OC_STACK_OK for Success, otherwise some error value
 */
OCStackResult InitDoxmResource()
{
    OCStackResult ret = OC_STACK_ERROR;

    //Read DOXM resource from PS
    char* jsonSVRDatabase = GetSVRDatabase();
    if(jsonSVRDatabase)
    {
        //Convert JSON DOXM into binary format
        gDoxm = JSONToDoxmBin(jsonSVRDatabase);
    }
    /*
     * If SVR database in persistent storage got corrupted or
     * is not available for some reason, a default doxm is created
     * which allows user to initiate doxm provisioning again.
     */
    if(!jsonSVRDatabase || !gDoxm)
    {
        gDoxm = GetDoxmDefault();
    }
    CheckDeviceID();
    //Instantiate 'oic.sec.doxm'
    ret = CreateDoxmResource();
    OICFree(jsonSVRDatabase);
    return ret;
}
Example #17
0
CAResult_t CAInitLEGattServer()
{
    OIC_LOG(DEBUG, TAG, "IN");

    int ret =  bt_gatt_server_initialize();
    if (0 != ret)
    {
        OIC_LOG_V(ERROR, TAG, "bt_gatt_server_initialize failed with ret[%s]",
                  CALEGetErrorMsg(ret));
        return CA_STATUS_FAILED;
    }

    bt_gatt_server_h server;

    ret = bt_gatt_server_create(&server);
    if (0 != ret)
    {
        OIC_LOG_V(ERROR, TAG, "bt_gatt_server_create failed with ret[%s]",
                  CALEGetErrorMsg(ret));
        return CA_STATUS_FAILED;
    }

    if (NULL != g_gattServer)
    {
        OICFree(g_gattServer);
        g_gattServer = NULL;
    }
    g_gattServer = server;

    OIC_LOG(DEBUG, TAG, "OUT");
    return CA_STATUS_OK;
}
bool ca_mutex_free(ca_mutex mutex)
{
    bool bRet=false;

    ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
    if (mutexInfo)
    {
        int ret = pthread_mutex_destroy(&mutexInfo->mutex);
        if (0 == ret)
        {
            OICFree(mutexInfo);
            bRet=true;
        }
        else
        {
            OIC_LOG_V(ERROR, TAG, "%s Failed to free mutex !", __func__);
        }
    }
    else
    {
        OIC_LOG_V(ERROR, TAG, "%s Invalid mutex !", __func__);
    }

    return bRet;
}
Example #19
0
/**
 * Initialize pstat resource by loading data from persistent storage.
 *
 * @retval  OC_STACK_OK for Success, otherwise some error value
 */
OCStackResult InitPstatResource()
{
    OCStackResult ret = OC_STACK_ERROR;

    // Read Pstat resource from PS
    char* jsonSVRDatabase = GetSVRDatabase();
    if (jsonSVRDatabase)
    {
        // Convert JSON Pstat into binary format
        gPstat = JSONToPstatBin(jsonSVRDatabase, true);
    }
    /*
     * If SVR database in persistent storage got corrupted or
     * is not available for some reason, a default pstat is created
     * which allows user to initiate pstat provisioning again.
     */
    if(!jsonSVRDatabase || !gPstat)
    {
        gPstat = GetPstatDefault();
    }
    // Instantiate 'oic.sec.pstat'
    ret = CreatePstatResource();

    OICFree(jsonSVRDatabase);
    return ret;
}
Example #20
0
void CAIPErrorHandler (const CAEndpoint_t *endpoint, const void *data,
                       uint32_t dataLength, CAResult_t result)
{
    OIC_LOG(DEBUG, TAG, "IN");

    VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint is NULL");

    VERIFY_NON_NULL_VOID(data, TAG, "data is NULL");

    void *buf = (void*)OICMalloc(sizeof(char) * dataLength);
    if (!buf)
    {
        OIC_LOG(ERROR, TAG, "Memory Allocation failed!");
        return;
    }
    memcpy(buf, data, dataLength);
    if (g_errorCallback)
    {
        g_errorCallback(endpoint, buf, dataLength, result);
    }
    else
    {
        OICFree(buf);
    }

    OIC_LOG(DEBUG, TAG, "OUT");
}
Example #21
0
static CborError OCTagsCborToPayload(CborValue *tagsMap, OCTagsPayload **tagsPayload)
{
    CborError cborFindResult = CborErrorOutOfMemory;
    OCTagsPayload *tags = (OCTagsPayload *)OICCalloc(1, sizeof(OCTagsPayload));
    VERIFY_PARAM_NON_NULL(TAG, tags, "Failed allocating tags");

    cborFindResult = FindStringInMap(tagsMap, OC_RSRVD_DEVICE_NAME, &tags->n.deviceName);
    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed finding deviceName");

    {
        char *deviceId = NULL;
        cborFindResult = FindStringInMap(tagsMap, OC_RSRVD_DEVICE_ID, &deviceId);
        if (deviceId)
        {
            memcpy(tags->di.id, deviceId, strlen(deviceId));
            OICFree(deviceId);
        }
        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed finding deviceId");
    }

    cborFindResult = FindIntInMap(tagsMap, OC_RSRVD_DEVICE_TTL, &tags->ttl);
    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed finding ttl");

    *tagsPayload = tags;
    return cborFindResult;

exit:
    OCFreeTagsResource(tags);
    return cborFindResult;
}
Example #22
0
// passthrough function to convert the pthreads call to a u_thread_func call
void* ca_thread_pool_pthreads_delegate(void* data)
{
    ca_thread_pool_callback_info_t* info = (ca_thread_pool_callback_info_t*)data;
    info->func(info->data);
    OICFree(info);
    return NULL;
}
Example #23
0
void CAIPTerminateNetworkMonitor()
{
    OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");

    ca_mutex_lock(g_networkMonitorContextMutex);
    g_networkMonitorContext->threadPool = NULL;

    CAClearNetInterfaceInfoList(g_networkMonitorContext->netInterfaceList);

    g_networkMonitorContext->netInterfaceList = NULL;
    g_networkMonitorContext->nwConnectivityStatus = CA_INTERFACE_DOWN;
    g_networkMonitorContext->networkChangeCb = NULL;
    g_networkMonitorContext->threadPool = NULL;

    OICFree(g_networkMonitorContext);
    g_networkMonitorContext = NULL;

    ca_mutex_unlock(g_networkMonitorContextMutex);

    ca_mutex_lock(g_stopNetworkMonitorMutex);
    g_stopNetworkMonitor = true;
    ca_mutex_unlock(g_stopNetworkMonitorMutex);

    CADestroyNetworkMonitorMutexes();

    OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
}
Example #24
0
/**
 * Add a server response to the server response list
 *
 * @param response initialized server response that is created by this function
 * @param requestHandle - handle of the response
 *
 * @return
 *     OCStackResult
 */
static OCStackResult AddServerResponse (OCServerResponse ** response, OCRequestHandle requestHandle)
{
    if (!response)
    {
        return OC_STACK_INVALID_PARAM;
    }

    OCServerResponse * serverResponse = NULL;

    serverResponse = (OCServerResponse *) OICCalloc(1, sizeof(OCServerResponse));
    VERIFY_NON_NULL(serverResponse);

    serverResponse->payload = NULL;

    serverResponse->requestHandle = requestHandle;

    *response = serverResponse;
    OIC_LOG(INFO, TAG, "Server Response Added!!");
    LL_APPEND (serverResponseList, serverResponse);
    return OC_STACK_OK;

exit:
    if (serverResponse)
    {
        OICFree(serverResponse);
        serverResponse = NULL;
    }
    *response = NULL;
    return OC_STACK_NO_MEMORY;
}
static void CARemoveNetworkMonitorList(int ifiindex)
{
    VERIFY_NON_NULL_VOID(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");

    ca_mutex_lock(g_networkMonitorContextMutex);

    uint32_t list_length = u_arraylist_length(g_netInterfaceList);
    for (uint32_t list_index = 0; list_index < list_length; list_index++)
    {
        CAInterface_t *removedifitem = (CAInterface_t *) u_arraylist_get(
                g_netInterfaceList, list_index);
        if (removedifitem && removedifitem->index == ifiindex)
        {
            if (u_arraylist_remove(g_netInterfaceList, list_index))
            {
                OICFree(removedifitem);
                ca_mutex_unlock(g_networkMonitorContextMutex);
                return;
            }
            continue;
        }
    }
    ca_mutex_unlock(g_networkMonitorContextMutex);
    return;
}
Example #26
0
CAResult_t CAIPInitializeQueueHandles()
{
    // Check if the message queue is already initialized
    if (g_sendQueueHandle)
    {
        OIC_LOG(DEBUG, TAG, "send queue handle is already initialized!");
        return CA_STATUS_OK;
    }

    // Create send message queue
    g_sendQueueHandle = OICMalloc(sizeof(CAQueueingThread_t));
    if (!g_sendQueueHandle)
    {
        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
        return CA_MEMORY_ALLOC_FAILED;
    }

    if (CA_STATUS_OK != CAQueueingThreadInitialize(g_sendQueueHandle,
                                (const ca_thread_pool_t)caglobals.ip.threadpool,
                                CAIPSendDataThread, CADataDestroyer))
    {
        OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread");
        OICFree(g_sendQueueHandle);
        g_sendQueueHandle = NULL;
        return CA_STATUS_FAILED;
    }

    return CA_STATUS_OK;
}
Example #27
0
static void CARemovePeerFromPeerInfoList(const char * addr, uint16_t port)
{
    if (NULL == addr || 0 >= port)
    {
        OIC_LOG(ERROR, NET_DTLS_TAG, "CADTLSGetPeerPSKId invalid parameters");
        return;
    }

    uint32_t list_length = u_arraylist_length(g_caDtlsContext->peerInfoList);
    for (uint32_t list_index = 0; list_index < list_length; list_index++)
    {
        CAEndpoint_t *peerInfo = (CAEndpoint_t *)u_arraylist_get(
                                g_caDtlsContext->peerInfoList,list_index);
        if (NULL == peerInfo)
        {
            continue;
        }
        if((0 == strncmp(addr, peerInfo->addr, MAX_ADDR_STR_SIZE_CA)) &&
                (port == peerInfo->port))
        {
            OICFree(u_arraylist_remove(g_caDtlsContext->peerInfoList, list_index));
            return;
        }
    }
}
Example #28
0
OCStackResult UpdateAmsMgrContext(PEContext_t *context, const CAEndpoint_t *endpoint,
                        const CARequestInfo_t *requestInfo)
{
    OCStackResult ret = OC_STACK_ERROR;

    //The AmsMgr context endpoint and requestInfo will be free from ,
    //AmsMgrAclReqCallback function
    if(context->amsMgrContext->endpoint)
    {
        OICFree(context->amsMgrContext->endpoint);
        context->amsMgrContext->endpoint = NULL;
    }
    context->amsMgrContext->endpoint = (CAEndpoint_t *)OICCalloc(1, sizeof(CAEndpoint_t ));
    VERIFY_NON_NULL(TAG, context->amsMgrContext->endpoint, ERROR);
    *context->amsMgrContext->endpoint = *endpoint;

    if(context->amsMgrContext->requestInfo)
    {
        FreeCARequestInfo(context->amsMgrContext->requestInfo);
        context->amsMgrContext->requestInfo = NULL;
    }
    context->amsMgrContext->requestInfo = CACloneRequestInfo(requestInfo);
    VERIFY_NON_NULL(TAG, context->amsMgrContext->requestInfo, ERROR);
    ret = OC_STACK_OK;
exit:
    return ret;
}
Example #29
0
OCRDDiscoveryPayload *OCRDDiscoveryPayloadCreate(const char *deviceName, const char *id, int biasFactor)
{
    OCRDDiscoveryPayload *discoveryPayload = (OCRDDiscoveryPayload *)OICCalloc(1, sizeof(OCRDDiscoveryPayload));

    if (!discoveryPayload)
    {
        return NULL;
    }

    if (deviceName)
    {
        discoveryPayload->n.deviceName = OICStrdup(deviceName);
        if (!discoveryPayload->n.deviceName)
        {
            OICFree(discoveryPayload);
            return NULL;
        }
    }
    if (id)
    {
        OICStrcpy((char*)discoveryPayload->di.id, MAX_IDENTITY_SIZE, id);
    }

    discoveryPayload->sel = biasFactor;

    return discoveryPayload;
}
Example #30
0
bool ClearMemory() {

    OIC_LOG(DEBUG, ES_PROV_TAG, "thread_pool_add_task of FindProvisioningResource failed");
    OICFree(netProvInfo);
    return true;

}