X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fprovisioning%2Fsrc%2Focprovisioningmanager.c;h=a46843fffc555580ae92926e2e9e2e3b63d644d4;hb=5f158d54ec795682e8cf4f504df69c5e34ecc03e;hp=1a3f56c1aa3038d0f3f97a2896d0ad8683f6231a;hpb=487f60fa7ccf510ddd05e2fcfe7ed1888db6566a;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/provisioning/src/ocprovisioningmanager.c b/resource/csdk/security/provisioning/src/ocprovisioningmanager.c index 1a3f56c..a46843f 100644 --- a/resource/csdk/security/provisioning/src/ocprovisioningmanager.c +++ b/resource/csdk/security/provisioning/src/ocprovisioningmanager.c @@ -18,6 +18,7 @@ * * *****************************************************************/ #include +#include #include #include #include "ocprovisioningmanager.h" @@ -701,6 +702,16 @@ error: return res; } +#if !defined(MAX_WAIT_TIME) +#define MAX_WAIT_TIME 15 +#endif + +static int g_reset; +static void localResultCallback(void* ctx) +{ + OC_UNUSED(ctx); + g_reset = 0; +} /* * Function to device revocation * This function will remove credential of target device from all devices in subnet. @@ -726,7 +737,7 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD if (!pTargetUuid || 0 == waitTimeForOwnedDeviceDiscovery) { - OIC_LOG(INFO, TAG, "OCRemoveDeviceWithUuid : Invalied parameters"); + OIC_LOG(INFO, TAG, "OCRemoveDeviceWithUuid : Invalid parameters"); return OC_STACK_INVALID_PARAM; } if (!resultCallback) @@ -770,41 +781,41 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD } PDMDestoryOicUuidLinkList(linkedDevices); - //If there is no linked devices, device revocation step can be skipped. - if(0 != numOfLinkedDevices) + //2. Find owned device from the network + res = PMDeviceDiscovery(waitTimeForOwnedDeviceDiscovery, true, &pOwnedDevList); + if (OC_STACK_OK != res) { - OIC_LOG_V(INFO, TAG, "[%s] linked with other devices.", strUuid); - //2. Find owned device from the network - res = PMDeviceDiscovery(waitTimeForOwnedDeviceDiscovery, true, &pOwnedDevList); - if (OC_STACK_OK != res) - { - OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to PMDeviceDiscovery"); - goto error; - } + OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to PMDeviceDiscovery"); + goto error; + } - OCProvisionDev_t* tempDev = NULL; - LL_FOREACH(pOwnedDevList, tempDev) + OCProvisionDev_t* tempDev = NULL; + LL_FOREACH(pOwnedDevList, tempDev) + { + if(memcmp(&tempDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id)) == 0) { - if(memcmp(&tempDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id)) == 0) - { - break; - } + break; } + } - if(NULL == tempDev) - { - OIC_LOG_V(WARNING, TAG, "Can not find [%s] on the network.", strUuid); - OIC_LOG_V(WARNING, TAG, "[%s]'s information will be deleted from local and other devices.", strUuid); - } - else - { - OICFree(pTargetDev->doxm); - OICFree(pTargetDev); - pTargetDev = tempDev; - discoverdFlag = true; - OIC_LOG_V(INFO, TAG, "[%s] is dectected on the network.", strUuid); - } + if(NULL == tempDev) + { + OIC_LOG_V(WARNING, TAG, "Can not find [%s] on the network.", strUuid); + OIC_LOG_V(WARNING, TAG, "[%s]'s information will be deleted from local and other devices.", strUuid); + } + else + { + OICFree(pTargetDev->doxm); + OICFree(pTargetDev); + pTargetDev = tempDev; + discoverdFlag = true; + OIC_LOG_V(INFO, TAG, "[%s] is detected on the network.", strUuid); + } + //If there is no linked devices, device revocation step can be skipped. + if(0 != numOfLinkedDevices) + { + OIC_LOG_V(INFO, TAG, "[%s] linked with other devices.", strUuid); OIC_LOG_V(INFO, TAG, "Trying [%s] revocation.", strUuid); // Send DELETE requests to linked devices @@ -829,26 +840,28 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD OIC_LOG(INFO, TAG, "Device discovery and SRPRemoveDevice will be skipped."); } - res = RemoveDeviceInfoFromLocal(pTargetDev); - if(OC_STACK_OK != res) + int maxWait = MAX_WAIT_TIME; + g_reset = 1; + + SRPResetDevice(pTargetDev, localResultCallback); + while(g_reset && maxWait) { - OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Filed to remove the device information from local."); - goto error; + sleep(1); + maxWait--; } if(OC_STACK_CONTINUE == resReq) { - /** - * If there is no linked device, PM does not send any request. - * So we should directly invoke the result callback to inform the result of OCRemoveDevice. - */ - if(resultCallback) - { - resultCallback(ctx, 0, NULL, false); - } + resultCallback(ctx, 0, NULL, false); res = OC_STACK_OK; } + res = RemoveDeviceInfoFromLocal(pTargetDev); + if(OC_STACK_OK != res) + { + OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to remove the device information from local."); + goto error; + } error: OICFree(strUuid); PMDeleteDeviceList(pOwnedDevList);