Commit 77b60576 authored by Chul Lee's avatar Chul Lee Committed by Randeep

Update the OTMContext management mechanism to improve the reliability of the OTM process.

  1. Apply the list mechanism to manage the OTMContext.
    -> It replaces the global variables of OTMContext.

  2. Add the OCDoHandle member into OTMContext.
    -> In case of OTM process stopped before OTM process complete,
       unnecessary retransmission can be occur
       due to request is performed just before the OTM process stops.
       So we need to cancel this request to prevent retransmission.
       OCDoHandle will be used at this time.

  3. Add the device status of PDM to prevent duplicate OTM.
    -> Added PDM_DEVICE_INIT to prevent deplicate OTM.
       If device status is PDM_DEVICE_INIT, PT will skip OTM process of this device.

Change-Id: I74e200aa88a0c5016c065a518b75614bf4a3a7a8
Signed-off-by: default avatarChul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13857Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarKevin Kane <kkane@microsoft.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent f1efbed0
......@@ -98,6 +98,7 @@ if provisioning_env.get('MULTIPLE_OWNER') == '1':
provisioning_src = [
'src/pmutility.c',
'src/credentialgenerator.c',
'src/otmcontextlist.c',
'src/ownershiptransfermanager.c',
'src/secureresourceprovider.c',
'src/ocprovisioningmanager.c',
......
/* *****************************************************************
*
* Copyright 2016 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *****************************************************************/
#ifndef _OTM_CONTEXT_LIST_H_
#define _OTM_CONTEXT_LIST_H_
#include "pmtypes.h"
#include "ocstack.h"
#include "octypes.h"
#include "securevirtualresourcetypes.h"
#include "ownershiptransfermanager.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct OTMContextItem {
OTMContext_t* otmCtx;
OCDevAddr endpoint;
struct OTMContextItem* next;
}OTMContextItem_t;
/**
* API to remove OTMContext from OTMContext list.
*
* @param[in] addr IP address of peer
* @param[in] port secure port number of peer
*/
void RemoveOTMContext(const char* addr, uint16_t port);
/**
* API to add OTMContext to OTMContext list.
* If same OTMContext exist, will be ignored.
*
* @param[in] ctx new OTMContext
* @param[in] addr IP address of peer
* @param[in] port secure port number of peer
*
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult AddOTMContext(OTMContext_t* ctx, const char* addr, uint16_t port);
/**
* API to read OTMContext from OTMContext list
*
* @param[in] addr IP address of peer
* @param[in] port secure port number of peer
*
* @return OTMContext in case of context found, otherwise NULL.
*/
const OTMContext_t* GetOTMContext(const char* addr, uint16_t port);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //_OTM_CONTEXT_LIST_H_
\ No newline at end of file
......@@ -55,7 +55,6 @@ OCStackResult OTMDoOwnershipTransfer(void* ctx,
*/
typedef OCStackResult (*OTMLoadSecret)(OTMContext_t* otmCtx);
/*
* Callback for create secure channel using secret inputed from OTMLoadSecret callback
*/
......@@ -89,6 +88,7 @@ struct OTMContext{
OCProvisionResult_t* ctxResultArray; /**< Result array having result of all device. */
size_t ctxResultArraySize; /**< No of elements in result array. */
bool ctxHasError; /**< Does OT process have any error. */
OCDoHandle ocDoHandle; /** <A handle for latest request message*/
OTMCallbackData_t otmCallback; /**< OTM callbacks to perform the OT/MOT. **/
int attemptCnt;
};
......
......@@ -28,6 +28,12 @@
extern "C" {
#endif
typedef enum PdmDeviceState {
PDM_DEVICE_ACTIVE = 0,
PDM_DEVICE_STALE = 1,
PDM_DEVICE_INIT = 2,
PDM_DEVICE_UNKNOWN = 99
}PdmDeviceState_t;
/**
* This method is used by provisioning manager to open provisioning database.
......@@ -39,14 +45,24 @@ extern "C" {
OCStackResult PDMInit(const char* dbPath);
/**
* This method is used by provisioning manager to check whether device is stale or not with PDM.
* This method is used by provisioning manager to check device status.
*
* @param[in] uuid information about the target device's uuid.
* @param[out] result true in case device is stale.
* @param[out] result device status.
*
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult PDMIsDeviceStale(const OicUuid_t *uuid, bool *result);
OCStackResult PDMGetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t* result);
/**
* This method is used by provisioning manager to update device status.
*
* @param[in] uuid id of device.
* @param[in] state device state. (ref. PdmDeviceState_t)
*
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult PDMSetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t state);
/**
* This method is used by provisioning manager to check duplication of device's Device ID with
......@@ -129,15 +145,6 @@ OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t**
*/
OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2);
/**
* This method is used by provisioning manager to update device status as stale.
*
* @param[in] uuidOfDevice id of stale device.
*
* @return OC_STACK_OK in case of success and other value otherwise.
*/
OCStackResult PDMSetDeviceStale(const OicUuid_t* uuidOfDevice);
/**
* This method is used by provisioning manager to get stale devices.
*
......
......@@ -501,7 +501,7 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe
* Change the device status as stale status.
* If all request are successed, this device information will be deleted.
*/
res = PDMSetDeviceStale(&pTargetDev->doxm->deviceID);
res = PDMSetDeviceState(&pTargetDev->doxm->deviceID, PDM_DEVICE_STALE);
if (res != OC_STACK_OK)
{
OIC_LOG(WARNING, TAG, "OCRemoveDevice : Failed to set device status as stale");
......
#include "logger.h"
#include "oic_malloc.h"
#include "oic_string.h"
#include "octypes.h"
#include "ownershiptransfermanager.h"
#include "utlist.h"
#include "otmcontextlist.h"
#define TAG "OTM_CTX_LIST"
/**
* List for saving the OTMContext to be used while ownership transfer.
*/
static OTMContextItem_t* g_otmCtxList = NULL;
void RemoveOTMContext(const char* addr, uint16_t port)
{
OTMContext_t* retCtx = NULL;
OIC_LOG(DEBUG, TAG, "IN RemoveOTMContext");
if (NULL != addr && 0 != port)
{
OTMContextItem_t* item = NULL;
OTMContextItem_t* temp = NULL;
LL_FOREACH_SAFE(g_otmCtxList, item, temp)
{
if (strncmp(addr, item->endpoint.addr, sizeof(item->endpoint.addr)) == 0 &&
port == item->endpoint.port)
{
OIC_LOG_V(DEBUG, TAG, "Remove [%s:%d]'s context from OTMContext list", addr, port);
retCtx = item->otmCtx;
item->otmCtx = NULL;
LL_DELETE(g_otmCtxList, item);
OICFree(item);
break;
}
}
}
OIC_LOG(DEBUG, TAG, "OUT RemoveOTMContext");
return retCtx;
}
OCStackResult AddOTMContext(OTMContext_t* ctx, const char* addr, uint16_t port)
{
OTMContextItem_t* item = NULL;
OTMContextItem_t* temp = NULL;
OTMContextItem_t* newItem = NULL;
OIC_LOG(DEBUG, TAG, "IN AddOTMContext");
if (NULL == ctx || NULL == addr || 0 == strlen(addr) || 0 == port)
{
return OC_STACK_INVALID_PARAM;
}
LL_FOREACH_SAFE(g_otmCtxList, item, temp)
{
if (strncmp(addr, item->endpoint.addr, sizeof(item->endpoint.addr)) == 0 &&
port == item->endpoint.port)
{
//if OTM Context already exists, just return OC_STACK_OK.
OIC_LOG(DEBUG, TAG, "Same OTMContext already exists.");
return OC_STACK_OK;
}
}
newItem = (OTMContextItem_t*)OICCalloc(1, sizeof(OTMContextItem_t));
if (NULL == newItem)
{
OIC_LOG(ERROR, TAG, "Failed to allocate memory.");
return OC_STACK_NO_MEMORY;
}
OIC_LOG_V(DEBUG, TAG, "Add [%s:%d]'s context to OTMContext list", addr, port);
newItem->otmCtx = ctx;
OICStrcpy(newItem->endpoint.addr, sizeof(newItem->endpoint.addr), addr);
newItem->endpoint.port = port;
LL_APPEND(g_otmCtxList, newItem);
OIC_LOG(DEBUG, TAG, "OUT AddOTMContext");
return OC_STACK_OK;
}
const OTMContext_t* GetOTMContext(const char* addr, uint16_t port)
{
OIC_LOG(DEBUG, TAG, "IN GetOTMContext");
if (NULL != addr && 0 != port)
{
OTMContextItem_t* item = NULL;
OTMContextItem_t* temp = NULL;
LL_FOREACH_SAFE(g_otmCtxList, item, temp)
{
if (strncmp(addr, item->endpoint.addr, sizeof(item->endpoint.addr)) == 0 &&
port == item->endpoint.port)
{
OIC_LOG_V(DEBUG, TAG, "Found the OTMContext for [%s:%d]", addr, port);
return item->otmCtx;
}
}
}
OIC_LOG(DEBUG, TAG, "OUT GetOTMContext");
return NULL;
}
......@@ -36,9 +36,6 @@
#define TAG "PDM"
#define PDM_STALE_STATE 1
#define PDM_ACTIVE_STATE 0
#define PDM_FIRST_INDEX 0
#define PDM_SECOND_INDEX 1
......@@ -203,7 +200,7 @@ OCStackResult PDMAddDevice(const OicUuid_t *UUID)
res = sqlite3_bind_blob(stmt, PDM_BIND_INDEX_SECOND, UUID, UUID_LENGTH, SQLITE_STATIC);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_THIRD, PDM_ACTIVE_STATE);
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_THIRD, PDM_DEVICE_INIT);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
res = sqlite3_step(stmt);
......@@ -224,42 +221,6 @@ OCStackResult PDMAddDevice(const OicUuid_t *UUID)
return OC_STACK_OK;
}
/**
* Function to check whether device is stale or not
*/
OCStackResult PDMIsDeviceStale(const OicUuid_t *uuid, bool *result)
{
if (NULL == uuid || NULL == result)
{
OIC_LOG(ERROR, TAG, "UUID or result is NULL");
return OC_STACK_INVALID_PARAM;
}
sqlite3_stmt *stmt = 0;
int res = 0;
res = sqlite3_prepare_v2(g_db, PDM_SQLITE_GET_DEVICE_STATUS, strlen(PDM_SQLITE_GET_DEVICE_STATUS) + 1,
&stmt, NULL);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
res = sqlite3_bind_blob(stmt, PDM_BIND_INDEX_FIRST, uuid, UUID_LENGTH, SQLITE_STATIC);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
bool retValue = false;
while(SQLITE_ROW == sqlite3_step(stmt))
{
int tempStaleStateFromDb = sqlite3_column_int(stmt, PDM_FIRST_INDEX);
OIC_LOG_V(DEBUG, TAG, "Stale state is %d", tempStaleStateFromDb);
if (PDM_STALE_STATE == tempStaleStateFromDb)
{
OIC_LOG(INFO, TAG, "Device is stale");
retValue = true;
}
}
*result = retValue;
sqlite3_finalize(stmt);
return OC_STACK_OK;
}
/**
*function to get Id for given UUID
*/
......@@ -336,7 +297,7 @@ static OCStackResult addlink(int id1, int id2)
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_SECOND, id2);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_THIRD, PDM_ACTIVE_STATE);
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_THIRD, PDM_DEVICE_ACTIVE);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
if (sqlite3_step(stmt) != SQLITE_DONE)
......@@ -358,26 +319,27 @@ OCStackResult PDMLinkDevices(const OicUuid_t *UUID1, const OicUuid_t *UUID2)
return OC_STACK_INVALID_PARAM;
}
bool result = false;
if (OC_STACK_OK != PDMIsDeviceStale(UUID1, &result))
PdmDeviceState_t state = PDM_DEVICE_UNKNOWN;
if (OC_STACK_OK != PDMGetDeviceState(UUID1, &state))
{
OIC_LOG(ERROR, TAG, "Internal error occured");
return OC_STACK_ERROR;
}
if (result)
if (PDM_DEVICE_ACTIVE != state)
{
OIC_LOG(ERROR, TAG, "UUID1:Stale device");
OIC_LOG_V(ERROR, TAG, "UUID1: Device state is not active : %d", state);
return OC_STACK_INVALID_PARAM;
}
result = false;
if (OC_STACK_OK != PDMIsDeviceStale(UUID2, &result))
state = PDM_DEVICE_UNKNOWN;
if (OC_STACK_OK != PDMGetDeviceState(UUID2, &state))
{
OIC_LOG(ERROR, TAG, "Internal error occured");
return OC_STACK_ERROR;
}
if (result)
if (PDM_DEVICE_ACTIVE != state)
{
OIC_LOG(ERROR, TAG, "UUID2:Stale device");
OIC_LOG_V(ERROR, TAG, "UUID2: Device state is not active : %d", state);
return OC_STACK_INVALID_PARAM;
}
......@@ -546,8 +508,7 @@ OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* u
return OC_STACK_INVALID_PARAM;
}
ASCENDING_ORDER(id1, id2);
return updateLinkState(id1, id2, PDM_STALE_STATE);
return updateLinkState(id1, id2, PDM_DEVICE_STALE);
}
OCStackResult PDMGetOwnedDevices(OCUuidList_t **uuidList, size_t *numOfDevices)
......@@ -602,7 +563,7 @@ static OCStackResult getUUIDforId(int id, OicUuid_t *uid, bool *result)
memcpy(uid, ptr, sizeof(OicUuid_t));
int temp = sqlite3_column_int(stmt, PDM_SECOND_INDEX);
if(PDM_STALE_STATE == temp)
if(PDM_DEVICE_STALE == temp)
{
if(result)
{
......@@ -635,16 +596,16 @@ OCStackResult PDMGetLinkedDevices(const OicUuid_t *UUID, OCUuidList_t **UUIDLIST
OIC_LOG(ERROR, TAG, "Not null list will cause memory leak");
return OC_STACK_INVALID_PARAM;
}
bool result = false;
OCStackResult ret = PDMIsDeviceStale(UUID, &result);
PdmDeviceState_t state = PDM_DEVICE_UNKNOWN;
OCStackResult ret = PDMGetDeviceState(UUID, &state);
if (OC_STACK_OK != ret)
{
OIC_LOG(ERROR, TAG, "Internal error occured");
return OC_STACK_ERROR;
}
if (result)
if (PDM_DEVICE_ACTIVE != state)
{
OIC_LOG(ERROR, TAG, "Device is stale");
OIC_LOG_V(ERROR, TAG, "Device state is not active : %d", state);
return OC_STACK_INVALID_PARAM;
}
int id = 0;
......@@ -714,7 +675,7 @@ OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t **staleDevList, size_t *num
strlen(PDM_SQLITE_GET_STALE_INFO) + 1, &stmt, NULL);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_FIRST, PDM_STALE_STATE);
res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_FIRST, PDM_DEVICE_STALE);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
size_t counter = 0;
......@@ -801,27 +762,27 @@ OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* u
return OC_STACK_INVALID_PARAM;
}
bool isStale = false;
if (OC_STACK_OK != PDMIsDeviceStale(uuidOfDevice1, &isStale))
PdmDeviceState_t state = PDM_DEVICE_UNKNOWN;
if (OC_STACK_OK != PDMGetDeviceState(uuidOfDevice1, &state))
{
OIC_LOG(ERROR, TAG, "uuidOfDevice1:Internal error occured");
return OC_STACK_ERROR;
}
if (isStale)
if (PDM_DEVICE_ACTIVE != state)
{
OIC_LOG(ERROR, TAG, "uuidOfDevice1:Device is stale");
OIC_LOG_V(ERROR, TAG, "uuidOfDevice1:Device state is not active : %d", state);
return OC_STACK_INVALID_PARAM;
}
isStale = false;
if (OC_STACK_OK != PDMIsDeviceStale(uuidOfDevice2, &isStale))
state = PDM_DEVICE_UNKNOWN;
if (OC_STACK_OK != PDMGetDeviceState(uuidOfDevice2, &state))
{
OIC_LOG(ERROR, TAG, "uuidOfDevice2:Internal error occured");
return OC_STACK_ERROR;
}
if (isStale)
if (PDM_DEVICE_ACTIVE != state)
{
OIC_LOG(ERROR, TAG, "uuidOfDevice2:Device is stale");
OIC_LOG_V(ERROR, TAG, "uuidOfDevice2:Device state is not active : %d", state);
return OC_STACK_INVALID_PARAM;
}
......@@ -850,7 +811,7 @@ OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* u
return OC_STACK_OK;
}
static OCStackResult updateDeviceState(const OicUuid_t *uuid, int state)
static OCStackResult updateDeviceState(const OicUuid_t *uuid, PdmDeviceState_t state)
{
sqlite3_stmt *stmt = 0;
int res = 0 ;
......@@ -907,23 +868,30 @@ static OCStackResult updateLinkForStaleDevice(const OicUuid_t *devUuid)
return OC_STACK_OK;
}
OCStackResult PDMSetDeviceStale(const OicUuid_t* uuidOfDevice)
OCStackResult PDMSetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t state)
{
OCStackResult res = OC_STACK_ERROR;
CHECK_PDM_INIT(TAG);
if (NULL == uuidOfDevice)
if (NULL == uuid)
{
OIC_LOG(ERROR, TAG, "Invalid PARAM");
return OC_STACK_INVALID_PARAM;
}
begin();
OCStackResult res = updateLinkForStaleDevice(uuidOfDevice);
if (OC_STACK_OK != res)
if(PDM_DEVICE_STALE == state)
{
rollback();
OIC_LOG(ERROR, TAG, "unable to update links");
return res;
res = updateLinkForStaleDevice(uuid);
if (OC_STACK_OK != res)
{
rollback();
OIC_LOG(ERROR, TAG, "unable to update links");
return res;
}
}
res = updateDeviceState(uuidOfDevice, PDM_STALE_STATE);
res = updateDeviceState(uuid, state);
if (OC_STACK_OK != res)
{
rollback();
......@@ -933,3 +901,32 @@ OCStackResult PDMSetDeviceStale(const OicUuid_t* uuidOfDevice)
commit();
return OC_STACK_OK;
}
OCStackResult PDMGetDeviceState(const OicUuid_t *uuid, PdmDeviceState_t* result)
{
if (NULL == uuid || NULL == result)
{
OIC_LOG(ERROR, TAG, "UUID or result is NULL");
return OC_STACK_INVALID_PARAM;
}
sqlite3_stmt *stmt = 0;
int res = 0;
res = sqlite3_prepare_v2(g_db, PDM_SQLITE_GET_DEVICE_STATUS, strlen(PDM_SQLITE_GET_DEVICE_STATUS) + 1,
&stmt, NULL);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
res = sqlite3_bind_blob(stmt, PDM_BIND_INDEX_FIRST, uuid, UUID_LENGTH, SQLITE_STATIC);
PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);
*result = PDM_DEVICE_UNKNOWN;
while(SQLITE_ROW == sqlite3_step(stmt))
{
int tempStaleStateFromDb = sqlite3_column_int(stmt, PDM_FIRST_INDEX);
OIC_LOG_V(DEBUG, TAG, "Device state is %d", tempStaleStateFromDb);
*result = (PdmDeviceState_t)tempStaleStateFromDb;
}
sqlite3_finalize(stmt);
return OC_STACK_OK;
}
......@@ -75,10 +75,12 @@ TEST(PDMIsDuplicateDeviceTest, ValidUUID)
{
OicUuid_t uid1 = {{0,}};
memcpy(&uid1.id, ID_1, sizeof(uid1.id));
PDMAddDevice(&uid1);
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid1));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid1, PDM_DEVICE_ACTIVE));
OicUuid_t uid2 = {{0,}};
memcpy(&uid2.id, ID_2, sizeof(uid2.id));
PDMAddDevice(&uid2);
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid2));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid2, PDM_DEVICE_ACTIVE));
OicUuid_t uid3 = {{0,}};
memcpy(&uid3.id, ID_3, sizeof(uid3.id));
bool isDuplicate = true;
......@@ -125,10 +127,14 @@ TEST(PDMLinkDevicesTest, ValidCase)
{
OicUuid_t uid1 = {{0,}};
memcpy(&uid1.id, ID_4, sizeof(uid1.id));
PDMAddDevice(&uid1);
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid1));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid1, PDM_DEVICE_ACTIVE));
OicUuid_t uid2 = {{0,}};
memcpy(&uid2.id, ID_5, sizeof(uid2.id));
PDMAddDevice(&uid2);
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid2));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid2, PDM_DEVICE_ACTIVE));
EXPECT_EQ(OC_STACK_OK, PDMLinkDevices(&uid1, &uid2));
}
......@@ -234,6 +240,8 @@ TEST(PDMSetLinkStale, ValidCase)
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid1));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid1, PDM_DEVICE_ACTIVE));
EXPECT_EQ(OC_STACK_OK, PDMLinkDevices(&uid1, &uid2));
EXPECT_EQ(OC_STACK_OK, PDMSetLinkStale(&uid1, &uid2));
......@@ -267,9 +275,12 @@ TEST(PDMIsLinkExistsTest, DuplicateID)
OicUuid_t uid1 = {{0,}};
memcpy(&uid1.id, ID_7, sizeof(uid1.id));
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid1));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid1, PDM_DEVICE_ACTIVE));
OicUuid_t uid2 = {{0,}};
memcpy(&uid2.id, ID_8, sizeof(uid2.id));
EXPECT_EQ(OC_STACK_OK, PDMAddDevice(&uid2));
EXPECT_EQ(OC_STACK_OK, PDMSetDeviceState(&uid2, PDM_DEVICE_ACTIVE));
bool linkExisits = true;
OCStackResult res = PDMIsLinkExists(&uid1, &uid2, &linkExisits);
......@@ -280,7 +291,7 @@ TEST(PDMIsLinkExistsTest, DuplicateID)