in order to guarantee OTM success.
1. Change the response check condition about POST request.
2. Prevent restore of doxm,pstat in case of owned status and retransmission.
Change-Id: I69d2b3e497517373add683e7765b3521422e329b
Signed-off-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9465
Reviewed-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
Tested-by: Randeep Singh <randeep.s@samsung.com>
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
(void)UNUSED;
- if(clientResponse->result == OC_STACK_OK)
+ if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
{
OIC_LOG(INFO, TAG, "OwnerTransferModeHandler : response result = OC_STACK_OK");
//Send request : GET /oic/sec/pstat
OCStackResult res = OC_STACK_OK;
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
- if(OC_STACK_OK == clientResponse->result)
+ if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
{
if(otmCtx && otmCtx->selectedDeviceInfo)
{
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
(void) UNUSED;
- if (OC_STACK_OK == clientResponse->result)
+ if (OC_STACK_RESOURCE_CHANGED == clientResponse->result)
{
OCStackResult res = OC_STACK_ERROR;
OicSecOxm_t selOxm = otmCtx->selectedDeviceInfo->doxm->oxmSel;
OCStackResult res = OC_STACK_OK;
OTMContext_t* otmCtx = (OTMContext_t*)ctx;
- if(OC_STACK_OK == clientResponse->result)
+ if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
{
if(otmCtx && otmCtx->selectedDeviceInfo)
{
(void)UNUSED;
OCStackResult res = OC_STACK_OK;
- if(OC_STACK_OK == clientResponse->result)
+ if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
{
if(otmCtx && otmCtx->selectedDeviceInfo)
{
OTMContext_t* otmCtx = (OTMContext_t*) ctx;
(void)UNUSED;
- if (OC_STACK_OK == clientResponse->result)
+ if (OC_STACK_RESOURCE_CHANGED == clientResponse->result)
{
OIC_LOG(INFO, TAG, "Device state is in Ready for Normal Operation.");
OCStackResult res = PDMAddDevice(&otmCtx->selectedDeviceInfo->doxm->deviceID);
}
}
+ OIC_LOG(DEBUG, TAG, "Send payload for doxm GET request");
+ OIC_LOG_BUFFER(DEBUG, TAG, payload, size);
+
// Send response payload to request originator
if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
{
OIC_LOG(ERROR, TAG, "Failed to generate random PIN");
ehRet = OC_EH_ERROR;
}
- previousMsgId = ehRequest->messageID;
}
#endif //__WITH_DTLS__
}
exit:
if(OC_EH_OK != ehRet)
{
- OIC_LOG(WARNING, TAG, "The operation failed during handle DOXM request,"\
- "DOXM will be reverted.");
/*
* If some error is occured while ownership transfer,
* ownership transfer related resource should be revert back to initial status.
- */
- RestoreDoxmToInitState();
- RestorePstatToInitState();
+ */
+ if(gDoxm)
+ {
+ if(!gDoxm->owned && previousMsgId != ehRequest->messageID)
+ {
+ OIC_LOG(WARNING, TAG, "The operation failed during handle DOXM request,"\
+ "DOXM will be reverted.");
+ RestoreDoxmToInitState();
+ RestorePstatToInitState();
+ }
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "Invalid DOXM resource.");
+ }
+ }
+ else
+ {
+ previousMsgId = ehRequest->messageID;
}
//Send payload to request originator
OCEntityHandlerResult ehRet = OC_EH_ERROR;
OIC_LOG(INFO, TAG, "HandlePstatPostRequest processing POST request");
OicSecPstat_t *pstat = NULL;
+ static uint16_t prevMsgId = 0;
if (ehRequest->payload)
{
}
}
exit:
- if(OC_EH_OK != ehRet)
- {
- /*
- * If some error is occured while ownership transfer,
- * ownership transfer related resource should be revert back to initial status.
- */
- RestoreDoxmToInitState();
- RestorePstatToInitState();
- }
+ if(OC_EH_OK != ehRet)
+ {
+ /*
+ * If some error is occured while ownership transfer,
+ * ownership transfer related resource should be revert back to initial status.
+ */
+ const OicSecDoxm_t* doxm = GetDoxmResourceData();
+ if(doxm)
+ {
+ if(!doxm->owned && prevMsgId != ehRequest->messageID)
+ {
+ RestoreDoxmToInitState();
+ RestorePstatToInitState();
+ }
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "Invalid DOXM resource.");
+ }
+ }
+ else
+ {
+ prevMsgId = ehRequest->messageID;
+ }
+
//Send payload to request originator
if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))