* @param ehRequest pointer to entity handler request data structure.
* @param ehRet result code from entity handler.
* @param cborPayload response payload.
+ * @param size is the cborpayload size
*
* @return ::OC_STACK_OK for Success, otherwise some error value.
*/
-OCStackResult SendSRMCBORResponse(const OCEntityHandlerRequest *ehRequest,
+OCStackResult SendSRMResponse(const OCEntityHandlerRequest *ehRequest,
OCEntityHandlerResult ehRet, uint8_t *cborPayload, size_t size);
#ifdef __cplusplus
*/
static OTMCallbackData_t g_OTMDatas[OIC_OXM_COUNT];
-/**
- * Number of supported provisioning methods
- * current version supports only one.
- */
-static size_t gNumOfProvisioningMethodsPT = 1;
-
/**
* Variables for pointing the OTMContext to be used in the DTLS handshake result callback.
*/
}
OicSecPstat_t* pstat = NULL;
OCStackResult result = CBORPayloadToPstat(
- ((OCSecurityPayload*)clientResponse->payload)->securityData1,
+ ((OCSecurityPayload*)clientResponse->payload)->securityData,
((OCSecurityPayload*)clientResponse->payload)->payloadSize,
&pstat);
- if(NULL == pstat && result != OC_STACK_OK)
+ if(NULL == pstat || result != OC_STACK_OK)
{
OIC_LOG(ERROR, TAG, "Error while converting cbor to pstat.");
SetResult(otmCtx, OC_STACK_ERROR);
//Generate owner credential for new device
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- OicSecCred_t* ownerCredential = GetCredResourceData(&(deviceInfo->doxm->deviceID));
+ const OicSecCred_t* ownerCredential = GetCredResourceData(&(deviceInfo->doxm->deviceID));
if(!ownerCredential)
{
OIC_LOG(ERROR, TAG, "Can not find OwnerPSK.");
#endif
//Send owner credential to new device : PUT /oic/sec/cred [ owner credential ]
- if (OC_STACK_OK != CredToCBORPayload(&newCredential, &secPayload->securityData1, &secPayload->payloadSize))
+ if (OC_STACK_OK != CredToCBORPayload(&newCredential, &secPayload->securityData, &secPayload->payloadSize))
{
OICFree(secPayload);
OIC_LOG(ERROR, TAG, "Error while converting bin to cbor.");
return OC_STACK_ERROR;
}
- OIC_LOG_V(DEBUG, TAG, "Payload : %s", secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Cred Payload:");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
OCCallbackData cbData;
cbData.cb = &OwnerCredentialHandler;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
OCStackResult res = g_OTMDatas[selectedOxm].createSelectOxmPayloadCB(otmCtx,
- &secPayload->securityData1, &secPayload->payloadSize);
- if (OC_STACK_OK != res && NULL == secPayload->securityData1)
+ &secPayload->securityData, &secPayload->payloadSize);
+ if (OC_STACK_OK != res && NULL == secPayload->securityData)
{
OCPayloadDestroy((OCPayload *)secPayload);
OIC_LOG(ERROR, TAG, "Error while converting bin to cbor");
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
OCStackResult res = g_OTMDatas[deviceInfo->doxm->oxmSel].createOwnerTransferPayloadCB(
- otmCtx, &secPayload->securityData1, &secPayload->payloadSize);
- if (NULL == secPayload->securityData1)
+ otmCtx, &secPayload->securityData, &secPayload->payloadSize);
+ if (OC_STACK_OK != res && NULL == secPayload->securityData)
{
OCPayloadDestroy((OCPayload *)secPayload);
OIC_LOG(ERROR, TAG, "Error while converting doxm bin to cbor.");
return OC_STACK_INVALID_PARAM;
}
- OIC_LOG_V(DEBUG, TAG, "Payload : %s", secPayload->securityData1);
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
OCCallbackData cbData;
cbData.cb = &OwnerUuidUpdateHandler;
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
OCStackResult res = DoxmToCBORPayload(otmCtx->selectedDeviceInfo->doxm,
- &secPayload->securityData1, &secPayload->payloadSize);
- if (OC_STACK_OK != res && NULL == secPayload->securityData1)
+ &secPayload->securityData, &secPayload->payloadSize);
+ if (OC_STACK_OK != res && NULL == secPayload->securityData)
{
OCPayloadDestroy((OCPayload *)secPayload);
OIC_LOG(ERROR, TAG, "Error while converting doxm bin to json");
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- OCStackResult res = PstatToCBORPayload(deviceInfo->pstat, &secPayload->securityData1,
+ OCStackResult res = PstatToCBORPayload(deviceInfo->pstat, &secPayload->securityData,
&secPayload->payloadSize);
if (OC_STACK_OK != res)
{
return res;
}
-/**
- * Callback handler of SRPFinalizeProvisioning.
- *
- * @param[in] ctx ctx value passed to callback from calling function.
- * @param[in] UNUSED handle to an invocation
- * @param[in] clientResponse Response from queries to remote servers.
- * @return OC_STACK_DELETE_TRANSACTION to delete the transaction
- * and OC_STACK_KEEP_TRANSACTION to keep it.
- */
-static OCStackApplicationResult FinalizeProvisioningCB(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
-{
- OIC_LOG_V(INFO, TAG, "IN FinalizeProvisioningCB.");
-
- VERIFY_NON_NULL(TAG, clientResponse, ERROR);
- VERIFY_NON_NULL(TAG, ctx, ERROR);
-
- OTMContext_t* otmCtx = (OTMContext_t*)ctx;
- (void)UNUSED;
- if(OC_STACK_OK == clientResponse->result)
- {
- OCStackResult res = PDMAddDevice(&otmCtx->selectedDeviceInfo->doxm->deviceID);
-
- if (OC_STACK_OK == res)
- {
- OIC_LOG_V(INFO, TAG, "Add device's UUID in PDM_DB");
- SetResult(otmCtx, OC_STACK_OK);
- return OC_STACK_DELETE_TRANSACTION;
- }
- else
- {
- OIC_LOG(ERROR, TAG, "Ownership transfer is complete but adding information to DB is failed.");
- }
- }
-exit:
- return OC_STACK_DELETE_TRANSACTION;
-}
-
-/**
- * Callback handler of default ACL provisioning.
- *
- * @param[in] ctx ctx value passed to callback from calling function.
- * @param[in] UNUSED handle to an invocation
- * @param[in] clientResponse Response from queries to remote servers.
- * @return OC_STACK_DELETE_TRANSACTION to delete the transaction
- * and OC_STACK_KEEP_TRANSACTION to keep it.
- */
-static OCStackApplicationResult ProvisionDefaultACLCB(void *ctx, OCDoHandle UNUSED,
- OCClientResponse *clientResponse)
-{
- OIC_LOG_V(INFO, TAG, "IN ProvisionDefaultACLCB.");
-
- VERIFY_NON_NULL(TAG, clientResponse, ERROR);
- VERIFY_NON_NULL(TAG, ctx, ERROR);
-
- OTMContext_t* otmCtx = (OTMContext_t*) ctx;
- (void)UNUSED;
-
- if (OC_STACK_RESOURCE_CREATED == clientResponse->result)
- {
- OIC_LOG_V(INFO, TAG, "Staring commit hash task.");
- // TODO hash currently have fixed value 0.
- uint16_t aclHash = 0;
- otmCtx->selectedDeviceInfo->pstat->commitHash = aclHash;
- otmCtx->selectedDeviceInfo->pstat->tm = NORMAL;
- OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
- if(!secPayload)
- {
- OIC_LOG(ERROR, TAG, "Failed to memory allocation");
- return OC_STACK_NO_MEMORY;
- }
- secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- OCStackResult res = PstatToCBORPayload(otmCtx->selectedDeviceInfo->pstat,
- &secPayload->securityData1, &secPayload->payloadSize);
- if (OC_STACK_OK != res || NULL == secPayload->securityData1)
- {
- OICFree(secPayload);
- SetResult(otmCtx, OC_STACK_INVALID_JSON);
- return OC_STACK_DELETE_TRANSACTION;
- }
-
- char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
- if(!PMGenerateQuery(true,
- otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort,
- otmCtx->selectedDeviceInfo->connType,
- query, sizeof(query), OIC_RSRC_PSTAT_URI))
- {
- OIC_LOG(ERROR, TAG, "ProvisionDefaultACLCB : Failed to generate query");
- return OC_STACK_ERROR;
- }
- OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
- OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
- cbData.cb = &FinalizeProvisioningCB;
- cbData.context = (void*)otmCtx;
- cbData.cd = NULL;
- OCStackResult ret = OCDoResource(NULL, OC_REST_PUT, query, 0, (OCPayload*)secPayload,
- otmCtx->selectedDeviceInfo->connType, OC_HIGH_QOS, &cbData, NULL, 0);
- OIC_LOG_V(INFO, TAG, "OCDoResource returned: %d",ret);
- if (ret != OC_STACK_OK)
- {
- OIC_LOG(ERROR, TAG, "OCStack resource error");
- SetResult(otmCtx, ret);
- }
- }
- else
- {
- OIC_LOG_V(INFO, TAG, "Error occured in provisionDefaultACLCB :: %d\n",
- clientResponse->result);
- SetResult(otmCtx, clientResponse->result);
- }
-exit:
- return OC_STACK_DELETE_TRANSACTION;
-}
-
OCStackResult PutProvisioningStatus(OTMContext_t* otmCtx)
{
OIC_LOG(INFO, TAG, "IN PutProvisioningStatus");
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
if (OC_STACK_OK != PstatToCBORPayload(otmCtx->selectedDeviceInfo->pstat,
- &secPayload->securityData1, &secPayload->payloadSize))
+ &secPayload->securityData, &secPayload->payloadSize))
{
OCPayloadDestroy((OCPayload *)secPayload);
return OC_STACK_INVALID_JSON;
}
- OIC_LOG_V(INFO, TAG, "Created payload for chage to Provisiong state : %s",secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Created payload for chage to Provisiong state");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
if(!PMGenerateQuery(true,
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
if (OC_STACK_OK != PstatToCBORPayload(otmCtx->selectedDeviceInfo->pstat,
- &secPayload->securityData1, &secPayload->payloadSize))
+ &secPayload->securityData, &secPayload->payloadSize))
{
OCPayloadDestroy((OCPayload *)secPayload);
return OC_STACK_INVALID_JSON;
}
- OIC_LOG_V(INFO, TAG, "Created payload for chage to Provisiong state: %s",secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Created payload for chage to Provisiong state");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
if(!PMGenerateQuery(true,
}
OicSecVer_t *ptrVer = NULL;
- uint8_t *payload = ((OCSecurityPayload*)clientResponse->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload*)clientResponse->payload)->securityData;
size_t size = ((OCSecurityPayload*)clientResponse->payload)->payloadSize;
+
OCStackResult res = CBORPayloadToVer(payload, size, &ptrVer);
if ((NULL == ptrVer) && (OC_STACK_OK != res))
{
}
OicSecDoxm_t *ptrDoxm = NULL;
- uint8_t *payload = ((OCSecurityPayload*)clientResponse->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload*)clientResponse->payload)->securityData;
size_t size = ((OCSecurityPayload*)clientResponse->payload)->payloadSize;
+
OCStackResult res = CBORPayloadToDoxm(payload, size, &ptrDoxm);
- if ((NULL == ptrDoxm) && (OC_STACK_OK != res))
+ if ((NULL == ptrDoxm) || (OC_STACK_OK != res))
{
OIC_LOG(INFO, TAG, "Ignoring malformed CBOR");
return OC_STACK_KEEP_TRANSACTION;
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- OCStackResult res = CredToCBORPayload(cred, &secPayload->securityData1, &secPayload->payloadSize);
- if((OC_STACK_OK != res) && (NULL == secPayload->securityData1))
+ OCStackResult res = CredToCBORPayload(cred, &secPayload->securityData, &secPayload->payloadSize);
+ if((OC_STACK_OK != res) && (NULL == secPayload->securityData))
{
OCPayloadDestroy((OCPayload *)secPayload);
OIC_LOG(ERROR, TAG, "Failed to CredToCBORPayload");
return OC_STACK_NO_MEMORY;
}
- OIC_LOG_V(INFO, TAG, "Credential for provisioning : %s",secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Created payload for Cred:");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
if(!PMGenerateQuery(true,
deviceInfo->endpoint.addr,
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- OCStackResult res = CrlToCBORPayload(crl, &secPayload->securityData1, &secPayload->payloadSize);
- if((OC_STACK_OK != res) && (NULL == secPayload->securityData1))
+ OCStackResult res = CrlToCBORPayload(crl, &secPayload->securityData, &secPayload->payloadSize);
+ if((OC_STACK_OK != res) && (NULL == secPayload->securityData))
{
OICFree(secPayload);
OIC_LOG(ERROR, TAG, "Failed to BinToCrlJSON");
return OC_STACK_NO_MEMORY;
}
- OIC_LOG_V(INFO, TAG, "CRL : %s", secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Created payload for CRL:");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
if(!PMGenerateQuery(true,
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- OCStackResult res = CredToCBORPayload(cred, &secPayload->securityData1,
+ OCStackResult res = CredToCBORPayload(cred, &secPayload->securityData,
&secPayload->payloadSize);
- if ((OC_STACK_OK != res) || (NULL == secPayload->securityData1))
+ if ((OC_STACK_OK != res) || (NULL == secPayload->securityData))
{
OICFree(secPayload);
OIC_LOG(ERROR, TAG, "Failed to CredToCBORPayload");
return OC_STACK_NO_MEMORY;
}
- OIC_LOG_V(INFO, TAG, "Credential for provisioning : %s",secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Created payload for Cred:");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
if(!PMGenerateQuery(true,
deviceInfo->endpoint.addr,
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- if(OC_STACK_OK != AclToCBORPayload(acl, &secPayload->securityData1, &secPayload->payloadSize))
+ if(OC_STACK_OK != AclToCBORPayload(acl, &secPayload->securityData, &secPayload->payloadSize))
{
OCPayloadDestroy((OCPayload *)secPayload);
OIC_LOG(ERROR, TAG, "Failed to AclToCBORPayload");
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- if (OC_STACK_OK != PconfToCBORPayload(pconf, &(secPayload->securityData1),
+ if (OC_STACK_OK != PconfToCBORPayload(pconf, &(secPayload->securityData),
&(secPayload->payloadSize)))
{
OCPayloadDestroy((OCPayload*)secPayload);
OIC_LOG(ERROR, TAG, "Failed to PconfToCborPayload");
return OC_STACK_NO_MEMORY;
}
- OIC_LOG_V(INFO, TAG, "PCONF : %s", secPayload->securityData1);
+ OIC_LOG(DEBUG, TAG, "Created payload for pconf set");
+ OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
+
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
if(!PMGenerateQuery(true,
sptest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
sptest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
sptest_env.PrependUnique(LIBS = [ 'ocpmapi',
+ 'oc',
'ocsrm',
'octbstack',
'oc_logger',
// note: This function is used in unit test hence not declared static,
OicSecAcl_t* CBORPayloadToAcl(const uint8_t *cborPayload, const size_t size)
{
- if (NULL == cborPayload)
+ if (NULL == cborPayload || 0 == size)
{
return NULL;
}
ehRet = (payload ? OC_EH_OK : OC_EH_ERROR);
// Send response payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, payload, size);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed for HandleACLGetRequest");
+ }
+ OICFree(payload);
OIC_LOG_V(DEBUG, TAG, "%s RetVal %d", __func__, ehRet);
return ehRet;
OCEntityHandlerResult ehRet = OC_EH_ERROR;
// Convert CBOR into ACL data and update to SVR buffers. This will also validate the ACL data received.
- uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
if (payload)
{
}
// Send payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleACLPostRequest");
+ }
OIC_LOG_V(DEBUG, TAG, "%s RetVal %d", __func__, ehRet);
return ehRet;
exit:
// Send payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleACLDeleteRequest");
+ }
return ehRet;
}
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
}
}
OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
OicSecAmacl_t **secAmacl)
{
- if (NULL == cborPayload || NULL == secAmacl || NULL != *secAmacl)
+ if (NULL == cborPayload || NULL == secAmacl || NULL != *secAmacl || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
CborValue amaclCbor = { .parser = NULL };
CborParser parser = { .end = NULL };
CborError cborFindResult = CborNoError;
- int cborLen = size;
- if (0 == size)
- {
- cborLen = CBOR_SIZE;
- }
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &amaclCbor);
+ cbor_parser_init(cborPayload, size, 0, &parser, &amaclCbor);
OicSecAmacl_t *headAmacl = (OicSecAmacl_t *)OICCalloc(1, sizeof(OicSecAmacl_t));
CborValue amaclMap = { .parser = NULL };
OCEntityHandlerResult ehRet = (res == OC_STACK_OK) ? OC_EH_OK : OC_EH_ERROR;
// Send response payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, cborPayload, size);
-
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, cborPayload, size))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleAmaclGetRequest");
+ }
OICFree(cborPayload);
OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
OCEntityHandlerResult ehRet = OC_EH_ERROR;
// Convert CBOR Amacl data into binary. This will also validate the Amacl data received.
- uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
if (payload)
{
}
// Send payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleAmaclPostRequest");
+ }
OIC_LOG_V(DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
}
}
OicSecDoxm_t *doxm = NULL;
OIC_LOG_V(INFO, TAG, "Doxm DeviceId Discovery response = %s\n",
- ((OCSecurityPayload*)clientResponse->payload)->securityData1);
- uint8_t *payload = ((OCSecurityPayload*)clientResponse->payload)->securityData1;
+ ((OCSecurityPayload*)clientResponse->payload)->securityData);
+ uint8_t *payload = ((OCSecurityPayload*)clientResponse->payload)->securityData;
size_t size = ((OCSecurityPayload*)clientResponse->payload)->payloadSize;
//As doxm is NULL amsmgr can't test if response from trusted AMS service
{
size_t size = ((OCSecurityPayload*)clientResponse->payload)->payloadSize;
OCStackResult ret =
- InstallNewACL(((OCSecurityPayload*)clientResponse->payload)->securityData1, size);
+ InstallNewACL(((OCSecurityPayload*)clientResponse->payload)->securityData, size);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
OIC_LOG_V(INFO, TAG, "%s : Calling checkPermission", __func__);
OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
OicSecCred_t **secCred)
{
- if (NULL == cborPayload || NULL == secCred || NULL != *secCred)
+ if (NULL == cborPayload || NULL == secCred || NULL != *secCred || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
//Get binary representation of cbor
OicSecCred_t *cred = NULL;
- uint8_t *payload = (((OCSecurityPayload*)ehRequest->payload)->securityData1);
+ uint8_t *payload = (((OCSecurityPayload*)ehRequest->payload)->securityData);
size_t size = (((OCSecurityPayload*)ehRequest->payload)->payloadSize);
OCStackResult res = CBORPayloadToCred(payload, size, &cred);
if (res == OC_STACK_OK)
//Get binary representation of CBOR
OicSecCred_t *cred = NULL;
- uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload*)ehRequest->payload)->payloadSize;
OCStackResult res = CBORPayloadToCred(payload, size, &cred);
if ((OC_STACK_OK == res) && cred)
}
//Send payload to request originator
- ret = (SendSRMCBORResponse(ehRequest, ret, NULL, 0) == OC_STACK_OK) ?
+ ret = (SendSRMResponse(ehRequest, ret, NULL, 0) == OC_STACK_OK) ?
ret : OC_EH_ERROR;
return ret;
cbor_encoder_init(&encoder, outPayload, cborLen, 0);
cborEncoderResult = cbor_encoder_create_map(&encoder, &crlMap, CRL_MAP_SIZE);
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create CRL Map");
//CRLId -- Mandatory
cborEncoderResult = cbor_encode_text_string(&crlMap, OIC_CBOR_CRL_ID,
strlen(OIC_CBOR_CRL_ID));
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add CRL ID");
cborEncoderResult = cbor_encode_int(&crlMap, crl->CrlId);
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add CRL Id value");
//ThisUpdate -- Mandatory
cborEncoderResult = cbor_encode_text_string(&crlMap, OIC_CBOR_CRL_THIS_UPDATE,
strlen(OIC_CBOR_CRL_THIS_UPDATE));
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add Crl update");
cborEncoderResult = cbor_encode_byte_string(&crlMap, crl->ThisUpdate.data,
crl->ThisUpdate.len);
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add Crl Update value");
//CRLData -- Mandatory
cborEncoderResult = cbor_encode_text_string(&crlMap, OIC_CBOR_CRL_DATA,
strlen(OIC_CBOR_CRL_DATA));
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add Crl data name");
cborEncoderResult = cbor_encode_byte_string(&crlMap, crl->CrlData.data,
crl->CrlData.len);
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add Crl data value");
cborEncoderResult = cbor_encoder_close_container(&encoder, &crlMap);
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add close Crl map");
*size = encoder.ptr - outPayload;
*payload = outPayload;
OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
OicSecCrl_t **secCrl)
{
- if (NULL == cborPayload || NULL == secCrl || NULL != *secCrl)
+ if (NULL == cborPayload || NULL == secCrl || NULL != *secCrl || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
CborValue crlCbor = {.parser = NULL};
CborParser parser = {.end = NULL};
CborError cborFindResult = CborNoError;
- int cborLen = (size == 0) ? CBOR_SIZE : size;
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &crlCbor);
+
+ cbor_parser_init(cborPayload, size, 0, &parser, &crlCbor);
CborValue crlMap = { .parser = NULL};
OicSecCrl_t *crl = NULL;
size_t outLen = 0;
cborFindResult = cbor_value_enter_container(&crlCbor, &crlMap);
- VERIFY_CBOR_SUCCESS(TAG, cborFindResult, ERROR);
+ VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter Crl map");
crl = (OicSecCrl_t *)OICCalloc(1, sizeof(OicSecCrl_t));
VERIFY_NON_NULL(TAG, crl, ERROR);
{
OCEntityHandlerResult ehRet = OC_EH_ERROR;
OicSecCrl_t *crl = NULL;
- uint8_t *payload = ((OCSecurityPayload *)ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *)ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
if (payload)
}
DeleteCrlBinData(crl);
- OICFree(payload);
}
exit:
// Send payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleCRLPostRequest");
+ }
OIC_LOG_V(INFO, TAG, "%s RetVal %d", __func__, ehRet);
return ehRet;
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
}
}
}\r
secPayload->base.type = PAYLOAD_TYPE_SECURITY;\r
\r
- OCStackResult ret = DpairingToCBORPayload(&dpair, &(secPayload->securityData1),\r
+ OCStackResult ret = DpairingToCBORPayload(&dpair, &(secPayload->securityData),\r
&(secPayload->payloadSize));\r
\r
if(OC_STACK_OK != ret)\r
OIC_LOG(ERROR, TAG, "Failed to DpairingToCBORPayload");\r
return OC_STACK_NO_MEMORY;\r
}\r
- OIC_LOG_V(INFO, TAG, "DPARING : %s", secPayload->securityData1);\r
+ OIC_LOG(INFO, TAG, "DPARING CBOR data:");\r
+ OIC_LOG_BUFFER(INFO, TAG, secPayload->securityData, secPayload->payloadSize);\r
\r
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};\r
if(!DPGenerateQuery(true,\r
}\r
secPayload->base.type = PAYLOAD_TYPE_SECURITY;\r
\r
- OCStackResult ret = DpairingToCBORPayload(&dpair, &(secPayload->securityData1),\r
+ OCStackResult ret = DpairingToCBORPayload(&dpair, &(secPayload->securityData),\r
&(secPayload->payloadSize));\r
\r
if(OC_STACK_OK != ret)\r
OIC_LOG(ERROR, TAG, "Failed to DpairingToCBORPayload");\r
return OC_STACK_NO_MEMORY;\r
}\r
- OIC_LOG_V(INFO, TAG, "DPARING : %s", secPayload->securityData1);\r
+ OIC_LOG(INFO, TAG, "DPARING CBOR data:");\r
+ OIC_LOG_BUFFER(INFO, TAG, secPayload->securityData, secPayload->payloadSize);\r
\r
char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};\r
if(!DPGenerateQuery(false,\r
OicSecPconf_t *pconf = NULL;\r
\r
OCStackResult res = CBORPayloadToPconf(\r
- ((OCSecurityPayload*)clientResponse->payload)->securityData1,\r
+ ((OCSecurityPayload*)clientResponse->payload)->securityData,\r
CBOR_SIZE,&pconf);\r
if (OC_STACK_OK != res )\r
{\r
OCStackResult CBORPayloadToDoxm(const uint8_t *cborPayload, size_t size,
OicSecDoxm_t **secDoxm)
{
- if (NULL == cborPayload || NULL == secDoxm || NULL != *secDoxm)
+ if (NULL == cborPayload || NULL == secDoxm || NULL != *secDoxm || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
CborParser parser;
CborError cborFindResult = CborNoError;
- int cborLen = (size == 0) ? CBOR_SIZE : size;
char* strUuid = NULL;
size_t len = 0;
CborValue doxmCbor;
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &doxmCbor);
+
+ cbor_parser_init(cborPayload, size, 0, &parser, &doxmCbor);
CborValue doxmMap;
OicSecDoxm_t *doxm = (OicSecDoxm_t *)OICCalloc(1, sizeof(*doxm));
VERIFY_NON_NULL(TAG, doxm, ERROR);
}
// Send response payload to request originator
- if (OC_STACK_OK != SendSRMCBORResponse(ehRequest, ehRet, payload, size))
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
{
- OIC_LOG(ERROR, TAG, "SendSRMCBORResponse failed in HandleDoxmGetRequest");
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleDoxmGetRequest");
}
OICFree(payload);
if (ehRequest->payload)
{
- uint8_t *payload = ((OCSecurityPayload *)ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *)ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *)ehRequest->payload)->payloadSize;
OCStackResult res = CBORPayloadToDoxm(payload, size, &newDoxm);
}
//Send payload to request originator
- if (OC_STACK_OK != SendSRMCBORResponse(ehRequest, ehRet, NULL, 0))
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
{
- OIC_LOG(ERROR, TAG, "SendSRMCBORResponse failed in HandleDoxmPostRequest");
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleDoxmPostRequest");
}
DeleteDoxmBinData(newDoxm);
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
break;
}
}
CborValue dpairCbor = { .parser = NULL };
CborParser parser = { .end = NULL };
CborError cborFindResult = CborNoError;
- int cborLen = size;
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &dpairCbor);
+ cbor_parser_init(cborPayload, size, 0, &parser, &dpairCbor);
CborValue dpairMap = { .parser = NULL };
OicSecDpairing_t *dpair = NULL;
cborFindResult = cbor_value_enter_container(&dpairCbor, &dpairMap);
const OicSecPconf_t *pconf = GetPconfResourceData();
if (true == pconf->edp)
{
- uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload*)ehRequest->payload)->payloadSize;
if (payload)
{
exit:
#endif // __WITH_DTLS__
- if (OC_EH_ERROR == ehRet && gDpair)
+ // Send payload to request originator
+ if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
{
- RemoveCredential(&gDpair->pdeviceID);
- gDpair = NULL;
+ ehRet = OC_EH_ERROR;
+ OIC_LOG (ERROR, TAG, "SendSRMResponse failed in HandleDpairingPostRequest");
}
- // Send payload to request originator
- if(OC_STACK_OK != SendSRMCBORResponse(ehRequest, ehRet, NULL, 0))
+ if (OC_EH_ERROR == ehRet && gDpair)
{
- OIC_LOG (ERROR, TAG, "SendSRMCBORResponse failed in HandleDpairingPostRequest");
+ RemoveCredential(&gDpair->pdeviceID);
+ gDpair = NULL;
}
DeleteDpairingBinData(newDpair);
const OicSecPconf_t *pconf = GetPconfResourceData();
if (true == pconf->edp)
{
- uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload*)ehRequest->payload)->payloadSize;
if (payload)
{
exit:
//Send payload to request originator
- if(OC_STACK_OK != SendSRMCBORResponse(ehRequest, ehRet, NULL, 0))
+ if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
{
- OIC_LOG (ERROR, TAG, "SendSRMCBORResponse failed in HandleDpairingPutRequest");
+ ehRet = OC_EH_ERROR;
+ OIC_LOG (ERROR, TAG, "SendSRMResponse failed in HandleDpairingPutRequest");
}
DeleteDpairingBinData(newDpair);
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
}
}
CborValue pconfCbor = { .parser = NULL };
CborParser parser = { .end = NULL };
CborError cborFindResult = CborNoError;
- int cborLen = size;
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &pconfCbor);
+ cbor_parser_init(cborPayload, size, 0, &parser, &pconfCbor);
CborValue pconfMap = { .parser = NULL } ;
OicSecPconf_t *pconf = NULL;
cborFindResult = cbor_value_enter_container(&pconfCbor, &pconfMap);
}
// Send response payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, payload, size);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandlePconfGetRequest");
+ }
OIC_LOG_V(DEBUG, TAG, "%s RetVal %d", __func__, ehRet);
+ OICFree(payload);
return ehRet;
}
if (true == GetDoxmResourceData()->dpc)
{
// Convert CBOR PCONF data into binary. This will also validate the PCONF data received.
- uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
if(payload){
{
// Check if valid Post request
if ((true == newPconf->edp) && (0 < newPconf->prmLen) &&
- DP_PIN_LENGTH == sizeof((const char*)newPconf->pin.val))
+ DP_PIN_LENGTH == sizeof(newPconf->pin.val))
{
OicSecPrm_t *oldPrm = gPconf->prm;
OicSecPdAcl_t *oldPdacl = gPconf->pdacls;
}
// Send payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandlePconfPostRequest");
+ }
OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
}
}
OCStackResult CBORPayloadToPstat(const uint8_t *cborPayload, const size_t size,
OicSecPstat_t **secPstat)
{
- if (NULL == cborPayload || NULL == secPstat || NULL != *secPstat)
+ if (NULL == cborPayload || NULL == secPstat || NULL != *secPstat || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
CborParser parser;
CborError cborFindResult = CborNoError;
char *strUuid = NULL;
- int cborLen = size;
size_t len = 0;
- if (0 == size)
- {
- cborLen = CBOR_SIZE;
- }
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &pstatCbor);
+
+ cbor_parser_init(cborPayload, size, 0, &parser, &pstatCbor);
CborValue pstatMap = { .parser = NULL };
OicSecPstat_t *pstat = NULL;
OCEntityHandlerResult ehRet = (res == OC_STACK_OK) ? OC_EH_OK : OC_EH_ERROR;
// Send response payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, payload, size);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandlePstatGetRequest");
+ }
OICFree(payload);
return ehRet;
}
OIC_LOG(INFO, TAG, "HandlePstatPutRequest processing PUT request");
OicSecPstat_t *pstat = NULL;
- if (ehRequest->resource)
+ if (ehRequest->payload)
{
- uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
VERIFY_NON_NULL(TAG, payload, ERROR);
OCStackResult ret = CBORPayloadToPstat(payload, size, &pstat);
- OICFree(payload);
VERIFY_NON_NULL(TAG, pstat, ERROR);
if (OC_STACK_OK == ret)
{
}
//Send payload to request originator
- if(OC_STACK_OK != SendSRMCBORResponse(ehRequest, ehRet, NULL, 0))
+ if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
{
+ ehRet = OC_EH_ERROR;
OIC_LOG (ERROR, TAG, "SendSRMResponse failed in HandlePstatPostRequest");
}
DeletePstatBinData(pstat);
break;
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
break;
}
}
#endif // __WITH_X509__
OCStackResult SendSRMResponse(const OCEntityHandlerRequest *ehRequest,
- OCEntityHandlerResult ehRet, const char *rspPayload)
-{
- OIC_LOG (DEBUG, TAG, "SRM sending SRM response");
- OCEntityHandlerResponse response = {.requestHandle = NULL};
- if (ehRequest)
- {
- OCSecurityPayload ocPayload = {.base = {.type = PAYLOAD_TYPE_INVALID}};
-
- response.requestHandle = ehRequest->requestHandle;
- response.resourceHandle = ehRequest->resource;
- response.ehResult = ehRet;
- response.payload = (OCPayload*)(&ocPayload);
- response.payload->type = PAYLOAD_TYPE_SECURITY;
- ((OCSecurityPayload*)response.payload)->securityData = (char *)rspPayload;
- response.persistentBufferFlag = 0;
-
- return OCDoResponse(&response);
- }
- return OC_STACK_ERROR;
-}
-
-OCStackResult SendSRMCBORResponse(const OCEntityHandlerRequest *ehRequest,
OCEntityHandlerResult ehRet, uint8_t *cborPayload, size_t size)
{
OIC_LOG(DEBUG, TAG, "SRM sending SRM response");
response.ehResult = ehRet;
response.payload = (OCPayload *)(&ocPayload);
response.payload->type = PAYLOAD_TYPE_SECURITY;
- ((OCSecurityPayload *)response.payload)->securityData1 = cborPayload;
+ ((OCSecurityPayload *)response.payload)->securityData = cborPayload;
((OCSecurityPayload *)response.payload)->payloadSize = size;
response.persistentBufferFlag = 0;
OCStackResult CBORPayloadToSVC(const uint8_t *cborPayload, size_t size,
OicSecSvc_t **secSvc)
{
- if (NULL == cborPayload || NULL == secSvc || NULL != *secSvc)
+ if (NULL == cborPayload || NULL == secSvc || NULL != *secSvc || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
CborValue svcCbor = { .parser = NULL };
CborParser parser = { .end = NULL };
CborError cborFindResult = CborNoError;
- int cborLen = size;
- if (0 == size)
- {
- cborLen = CBOR_SIZE;
- }
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &svcCbor);
+ cbor_parser_init(cborPayload, size, 0, &parser, &svcCbor);
OicSecSvc_t *headSvc = NULL;
CborValue svcArray = { .parser = NULL };
OCEntityHandlerResult ehRet = (res == OC_STACK_OK) ? OC_EH_OK : OC_EH_ERROR;
// Send response payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, cborSvc, size);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, cborSvc, size))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleSVCGetRequest");
+ }
OICFree(cborSvc);
-
OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
static OCEntityHandlerResult HandleSVCPostRequest(const OCEntityHandlerRequest * ehRequest)
{
OCEntityHandlerResult ehRet = OC_EH_ERROR;
- uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData1;
+ uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
if (payload)
{
}
// Send payload to request originator
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
+ {
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleSVCPostRequest");
+ }
OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
}
}
OCStackResult CBORPayloadToVer(const uint8_t *cborPayload, size_t size,
OicSecVer_t **secVer)
{
- if (NULL == cborPayload || NULL == secVer || NULL != *secVer)
+ if (NULL == cborPayload || NULL == secVer || NULL != *secVer || 0 == size)
{
return OC_STACK_INVALID_PARAM;
}
CborParser parser = { .end = NULL};
CborError cborFindResult = CborNoError;
- int cborLen = (size == 0) ? CBOR_SIZE : size;
size_t len = 0;
CborValue verCbor = { .parser = NULL };
- cbor_parser_init(cborPayload, cborLen, 0, &parser, &verCbor);
+ cbor_parser_init(cborPayload, size, 0, &parser, &verCbor);
CborValue verMap = { .parser = NULL };
OicSecVer_t *ver = (OicSecVer_t *)OICCalloc(1, sizeof(OicSecVer_t));
VERIFY_NON_NULL(TAG, ver, ERROR);
}
// Send response payload to request originator
- if (OC_STACK_OK != SendSRMCBORResponse(ehRequest, ehRet, payload, size))
+ if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
{
- OIC_LOG(ERROR, TAG, "SendSRMCBORResponse failed in HandleVerGetRequest");
+ ehRet = OC_EH_ERROR;
+ OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleVerGetRequest");
}
OICFree(payload);
default:
ehRet = OC_EH_ERROR;
- SendSRMCBORResponse(ehRequest, ehRet, NULL, 0);
+ SendSRMResponse(ehRequest, ehRet, NULL, 0);
break;
}
}
do
{
bytesRead = fread(buffer, 1, DB_FILE_SIZE_BLOCK, fp);
- if (size + bytesRead > MAX_RANGE)
+ if (bytesRead >=(MAX_RANGE - size))
{
fclose(fp);
return 0;
return;
}
+ jsonStr = (char *)OICMalloc(size + 1);
+ VERIFY_NON_NULL(TAG, jsonStr, FATAL);
+
fp = fopen(jsonFileName, "r");
if (fp)
{
- jsonStr = (char *)OICMalloc(size + 1);
- VERIFY_NON_NULL(TAG, jsonStr, FATAL);
size_t bytesRead = fread(jsonStr, 1, size, fp);
jsonStr[bytesRead] = '\0';
OicSecCred_t * JSONToCredBin(const char * jsonStr)
{
+ if (NULL == jsonStr)
+ {
+ OIC_LOG(ERROR, TAG,"JSONToCredBin jsonStr in NULL");
+ return NULL;
+ }
- VERIFY_NON_NULL(TAG, jsonStr, ERROR);
OicSecCred_t *headCred = (OicSecCred_t*)OICCalloc(1, sizeof(OicSecCred_t));
-
OCStackResult ret = OC_STACK_ERROR;
cJSON *jsonRoot = NULL;
+ VERIFY_NON_NULL(TAG, headCred, ERROR);
jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
ASSERT_TRUE(ReadCBORFile(ACL1_FILE_NAME, OIC_JSON_ACL_NAME, &payload, &size));
ASSERT_TRUE(NULL != payload);
- OCSecurityPayload *securityPayload = OCSecurityPayloadCBORCreate(payload, size);
+ OCSecurityPayload *securityPayload = OCSecurityPayloadCreate(payload, size);
ASSERT_TRUE(NULL != securityPayload);
static OCPersistentStorage ps = OCPersistentStorage();
ehReq.method = OC_REST_POST;
ehReq.payload = (OCPayload *) securityPayload;
- OCEntityHandlerResult ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_RESOURCE_CREATED, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
OicSecAcl_t *acl = CBORPayloadToAcl(payload, size);
ASSERT_TRUE(NULL != acl);
ASSERT_TRUE(NULL != payload);
// Security Payload
- OCSecurityPayload *securityPayload = OCSecurityPayloadCBORCreate(payload, size);
+ OCSecurityPayload *securityPayload = OCSecurityPayloadCreate(payload, size);
ASSERT_TRUE(NULL != securityPayload);
static OCPersistentStorage ps = OCPersistentStorage();
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
ehReq.payload = (OCPayload *) securityPayload;
ehReq.method = OC_REST_POST;
- OCEntityHandlerResult ehRet = OC_EH_ERROR;
- ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_RESOURCE_CREATED, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
// Verify if SRM contains ACE for the subject
OicSecAcl_t* savePtr = NULL;
ehReq.query = (char *)OICMalloc(strlen(query)+1);
ASSERT_TRUE(NULL != ehReq.query);
OICStrcpy(ehReq.query, strlen(query)+1, query);
- ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- // This returns error as WILDARD is used as a subject query.
- EXPECT_EQ(OC_EH_RESOURCE_DELETED, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
// Verify if SRM has deleted ACE for the subject
savePtr = NULL;
ASSERT_TRUE(NULL != payload);
// Security Payload
- OCSecurityPayload *securityPayload = OCSecurityPayloadCBORCreate(payload, size);
+ OCSecurityPayload *securityPayload = OCSecurityPayloadCreate(payload, size);
ASSERT_TRUE(NULL!= securityPayload);
static OCPersistentStorage ps = OCPersistentStorage();
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
ehReq.method = OC_REST_POST;
ehReq.payload = (OCPayload *)securityPayload;
- OCEntityHandlerResult ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_RESOURCE_CREATED, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
// Verify if SRM contains ACE for the subject with two resources
OicSecAcl_t* savePtr = NULL;
ASSERT_TRUE(NULL != ehReq.query);
OICStrcpy(ehReq.query, strlen(query)+1, query);
- ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_RESOURCE_DELETED, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
// Verify if SRM contains ACL for the subject but only with one resource
savePtr = NULL;
ASSERT_TRUE(NULL != payload);
// Security Payload
- OCSecurityPayload *securityPayload = OCSecurityPayloadCBORCreate(payload, size);
+ OCSecurityPayload *securityPayload = OCSecurityPayloadCreate(payload, size);
ASSERT_TRUE(NULL != securityPayload);
static OCPersistentStorage ps = OCPersistentStorage();
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
ehReq.method = OC_REST_POST;
ehReq.payload = (OCPayload *)securityPayload;
- OCEntityHandlerResult ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_RESOURCE_CREATED, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
//Create Entity Handler GET request wit query
ehReq.method = OC_REST_GET;
ASSERT_TRUE(NULL != ehReq.query);
OICStrcpy(ehReq.query, strlen(query)+1, query);
- ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_OK, ehRet);
+ ACLEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
// Perform cleanup
OCPayloadDestroy((OCPayload *)securityPayload);
// Create Entity Handler POST request payload
ehReq.method = OC_REST_POST;
- ehReq.payload = (OCPayload *)OCSecurityPayloadCBORCreate(payload, size);
+ ehReq.payload = (OCPayload *)OCSecurityPayloadCreate(payload, size);
if (!ehReq.payload)
{
OICFree(payload);
OCEntityHandlerRequest req = OCEntityHandlerRequest();
req.method = OC_REST_POST;
- req.payload = (OCPayload *) OCSecurityPayloadCBORCreate(cbor, size);
+ req.payload = (OCPayload *) OCSecurityPayloadCreate(cbor, size);
EXPECT_EQ(OC_EH_ERROR, PstatEntityHandler(OCEntityHandlerFlag::OC_REQUEST_FLAG, &req));
OICFree(cbor);
OCPayloadDestroy(req.payload);
// Discovery Payload
OCDiscoveryPayload* OCDiscoveryPayloadCreate();
-// TODO: Remove OCSecurityPayloadCBORCreate once all cbor changes land.
-OCSecurityPayload* OCSecurityPayloadCreate(const char* securityData);
-OCSecurityPayload* OCSecurityPayloadCBORCreate(const uint8_t* securityData, size_t size);
+OCSecurityPayload* OCSecurityPayloadCreate(const uint8_t* securityData, size_t size);
void OCSecurityPayloadDestroy(OCSecurityPayload* payload);
void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
typedef struct
{
OCPayload base;
- char* securityData;
- uint8_t *securityData1;
+ uint8_t* securityData;
size_t payloadSize;
} OCSecurityPayload;
{
case OCREP_PROP_INT:
dest->arr.iArray = (int64_t*)OICMalloc(dimTotal * sizeof(int64_t));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.iArray, "Failed allocating memory");
memcpy(dest->arr.iArray, source->arr.iArray, dimTotal * sizeof(int64_t));
break;
case OCREP_PROP_DOUBLE:
dest->arr.dArray = (double*)OICMalloc(dimTotal * sizeof(double));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.dArray, "Failed allocating memory");
memcpy(dest->arr.dArray, source->arr.dArray, dimTotal * sizeof(double));
break;
case OCREP_PROP_BOOL:
dest->arr.bArray = (bool*)OICMalloc(dimTotal * sizeof(bool));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.bArray, "Failed allocating memory");
memcpy(dest->arr.bArray, source->arr.bArray, dimTotal * sizeof(bool));
break;
case OCREP_PROP_STRING:
dest->arr.strArray = (char**)OICMalloc(dimTotal * sizeof(char*));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.strArray, "Failed allocating memory");
for(size_t i = 0; i < dimTotal; ++i)
{
dest->arr.strArray[i] = OICStrdup(source->arr.strArray[i]);
break;
case OCREP_PROP_OBJECT:
dest->arr.objArray = (OCRepPayload**)OICMalloc(dimTotal * sizeof(OCRepPayload*));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.objArray, "Failed allocating memory");
for(size_t i = 0; i < dimTotal; ++i)
{
dest->arr.objArray[i] = OCRepPayloadClone(source->arr.objArray[i]);
break;
case OCREP_PROP_ARRAY:
dest->arr.objArray = (OCRepPayload**)OICMalloc(dimTotal * sizeof(OCRepPayload*));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.objArray, "Failed allocating memory");
for(size_t i = 0; i < dimTotal; ++i)
{
dest->arr.objArray[i] = OCRepPayloadClone(source->arr.objArray[i]);
OIC_LOG(ERROR, TAG, "CopyPropertyValueArray invalid type");
break;
}
+exit:
+ return;
}
static void OCCopyPropertyValue (OCRepPayloadValue *dest, OCRepPayloadValue *source)
return payload;
}
-//TODO : Remove this once all cbor changes land.
-OCSecurityPayload* OCSecurityPayloadCreate(const char* securityData)
+OCSecurityPayload* OCSecurityPayloadCreate(const uint8_t* securityData, size_t size)
{
OCSecurityPayload* payload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
}
payload->base.type = PAYLOAD_TYPE_SECURITY;
- payload->securityData = OICStrdup(securityData);
-
- return payload;
-}
-
-// TODO : To convert this to OCSecurityPayloadCreate once all cbor changes land.
-OCSecurityPayload* OCSecurityPayloadCBORCreate(const uint8_t* securityData, size_t size)
-{
- OCSecurityPayload* payload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
-
- if (!payload)
- {
- return NULL;
- }
-
- payload->base.type = PAYLOAD_TYPE_SECURITY;
- payload->securityData1 = (uint8_t *)OICCalloc(1, size);
- if (!payload->securityData1)
+ payload->securityData = (uint8_t *)OICCalloc(1, size);
+ if (!payload->securityData)
{
OICFree(payload);
return NULL;
}
- memcpy(payload->securityData1, (uint8_t *)securityData, size);
+ memcpy(payload->securityData, (uint8_t *)securityData, size);
payload->payloadSize = size;
return payload;
{
return;
}
- // Remove this once all cbor changes land.
+
OICFree(payload->securityData);
- // OICFree(payload->securityData1);
OICFree(payload);
}
if (!*stringLL)
{
*stringLL = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
- VERIFY_PARAM_NON_NULL(TAG, dup, "Failed allocating memory");
+ VERIFY_PARAM_NON_NULL(TAG, *stringLL, "Failed allocating memory");
(*stringLL)->value = dup;
return true;
}
static int64_t OCConvertSecurityPayload(OCSecurityPayload* payload, uint8_t* outPayload,
size_t* size)
{
- memcpy(outPayload, payload->securityData1, payload->payloadSize);
+ memcpy(outPayload, payload->securityData, payload->payloadSize);
*size = payload->payloadSize;
return CborNoError;
sizeof(OC_RSRVD_RESOURCE_TYPE) - 1);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding rep resource type tag");
char *joinedTypes = OCStringLLJoin(payload->types);
- printf(" JOINED TYPES : %s %zd \n", joinedTypes, strlen(joinedTypes));
VERIFY_PARAM_NON_NULL(TAG, joinedTypes, "Failed creating joined string");
+ printf(" JOINED TYPES : %s %zd \n", joinedTypes, strlen(joinedTypes));
err |= cbor_encode_text_string(&repMap, joinedTypes, strlen(joinedTypes));
OICFree(joinedTypes);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding rep resource type value");
{
if (size > 0)
{
- *outPayload = (OCPayload *)OCSecurityPayloadCBORCreate(payload, size);
+ *outPayload = (OCPayload *)OCSecurityPayloadCreate(payload, size);
}
else
{
// BaseURI - Not a mandatory field
err = cbor_value_map_find_value(&rootMap, OC_RSRVD_BASE_URI, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find uri tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_dup_text_string(&curVal, &(out->baseURI), &len, NULL);
{
if (!OCResourcePayloadAddStringLL(&resource->interfaces, OC_RSRVD_INTERFACE_LL))
{
- err = CborErrorOutOfMemory;
+ OIC_LOG(ERROR, TAG, "Failed to add string to StringLL");
+ goto exit;
}
}
// Secure Flag
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_SECURE, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find secure tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_get_boolean(&curVal, &(resource->secure));
// Port
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_HOSTING_PORT, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find port tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_get_int(&curVal, (int *)&resource->port);
CborValue curVal;
// Resource Type
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
if (cbor_value_is_valid(&curVal))
{
err = OCParseStringLL(rootValue, OC_RSRVD_RESOURCE_TYPE, &out->types);
// Device ID
size_t len = 0;
err = cbor_value_map_find_value(rootValue, OC_RSRVD_DEVICE_ID, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find device id tag");
if (cbor_value_is_valid(&curVal))
{
if (cbor_value_is_byte_string(&curVal))
}
// Device Name
err = cbor_value_map_find_value(rootValue, OC_RSRVD_DEVICE_NAME, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find device name tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_dup_text_string(&curVal, &out->deviceName, &len, NULL);
}
// Device Spec Version
err = cbor_value_map_find_value(rootValue, OC_RSRVD_SPEC_VERSION, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find spec ver tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_dup_text_string(&curVal, &out->specVersion, &len, NULL);
}
// Data Model Version
err = cbor_value_map_find_value(rootValue, OC_RSRVD_DATA_MODEL_VERSION, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find data model ver tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_dup_text_string(&curVal, &out->dataModelVersion, &len, NULL);
// Platform ID
err = cbor_value_map_find_value(rootValue, OC_RSRVD_PLATFORM_ID, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find platform id tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.platformID), &len, NULL);
}
// MFG Name
err = cbor_value_map_find_value(rootValue, OC_RSRVD_MFG_NAME, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find mfg name tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.manufacturerName), &len, NULL);
}
// MFG URL
err = cbor_value_map_find_value(rootValue, OC_RSRVD_MFG_URL, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find mfg url tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.manufacturerUrl), &len, NULL);
}
// Model Num
err = cbor_value_map_find_value(rootValue, OC_RSRVD_MODEL_NUM, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find model num tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.modelNumber), &len, NULL);
}
// Date of Mfg
err = cbor_value_map_find_value(rootValue, OC_RSRVD_MFG_DATE, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find mfg date tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.dateOfManufacture), &len, NULL);
}
// Platform Version
err = cbor_value_map_find_value(rootValue, OC_RSRVD_PLATFORM_VERSION, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find platform ver tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.platformVersion), &len, NULL);
}
// OS Version
err = cbor_value_map_find_value(rootValue, OC_RSRVD_OS_VERSION, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find os ver tag");
if (cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.operatingSystemVersion), &len, NULL);
}
// Hardware Version
err = cbor_value_map_find_value(rootValue, OC_RSRVD_HARDWARE_VERSION, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find hw ver tag");
if(cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.hardwareVersion), &len, NULL);
}
// Firmware Version
err = cbor_value_map_find_value(rootValue, OC_RSRVD_FIRMWARE_VERSION, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find fw ver tag");
if(cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.firmwareVersion), &len, NULL);
}
// Support URL
err = cbor_value_map_find_value(rootValue, OC_RSRVD_SUPPORT_URL, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find support url tag");
if(cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.supportUrl), &len, NULL);
}
// System Time
err = cbor_value_map_find_value(rootValue, OC_RSRVD_SYSTEM_TIME, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find sys time tag");
if(cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &(info.systemTime), &len, NULL);
// Resource type
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
if(cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &rt, &len, NULL);
// Interface Types
err = cbor_value_map_find_value(rootValue, OC_RSRVD_INTERFACE, &repVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find interface tag");
if(cbor_value_is_valid(&repVal))
{
err = OCParseStringLL(rootValue, OC_RSRVD_INTERFACE, &interfaces);
if (cbor_value_is_array(root))
{
err = cbor_value_enter_container(root, &rootMap);
+ VERIFY_CBOR_SUCCESS(TAG, err, "Failed entering repMap");
}
while (cbor_value_is_valid(&rootMap))
{
if (cbor_value_is_map(&rootMap))
{
err = cbor_value_map_find_value(&rootMap, OC_RSRVD_HREF, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find href tag");
if (cbor_value_is_valid(&curVal))
{
size_t len = 0;
// Resource type name
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find res type tag");
if (cbor_value_is_valid(&curVal))
{
size_t len = 0;
threadingsample = examples_env.Program('threadingsample', 'threadingsample.cpp')
clientjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/examples/',
- env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.json')
+ env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.dat')
serverjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/examples/',
- env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.json')
+ env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.dat')
Alias("examples", [simpleserver, simpleclient,
simpleserverHQ, simpleclientHQ,
fridgeserver, fridgeclient,
using namespace OC;
+static const char* SVR_DB_FILE_NAME = "./oic_svr_db_client.dat";
typedef std::map<OCResourceIdentifier, std::shared_ptr<OCResource>> DiscoveredResourceMap;
DiscoveredResourceMap discoveredResources;
static FILE* client_open(const char* /*path*/, const char *mode)
{
- return fopen("./oic_svr_db_client.json", mode);
+ return fopen(SVR_DB_FILE_NAME, mode);
}
int main(int argc, char* argv[]) {
using namespace std;
namespace PH = std::placeholders;
+static const char* SVR_DB_FILE_NAME = "./oic_svr_db_server.dat";
int gObservation = 0;
void * ChangeLightRepresentation (void *param);
void * handleSlowResponse (void *param, std::shared_ptr<OCResourceRequest> pRequest);
static FILE* client_open(const char* /*path*/, const char *mode)
{
- return fopen("./oic_svr_db_server.json", mode);
+ return fopen(SVR_DB_FILE_NAME, mode);
}
int main(int argc, char* argv[])
{
using namespace OC;
+ static const char* SVR_DB_FILE_NAME = "./oic_svr_db_server.dat";
const OCResourceHandle HANDLE_ZERO = 0;
const std::string gResourceTypeName = "core.res";
const std::string gResourceInterface = DEFAULT_INTERFACE;
//OCPersistent Storage Handlers
static FILE* client_open(const char * /*path*/, const char *mode)
{
- std::cout << "<===Opening SVR DB file = './oic_svr_db_client.json' with mode = '" << mode
+ std::cout << "<===Opening SVR DB file = './oic_svr_db_client.dat' with mode = '" << mode
<< "' " << std::endl;
- return fopen("./oic_svr_db_client.json", mode);
+ return fopen(SVR_DB_FILE_NAME, mode);
}
OCPersistentStorage gps {client_open, fread, fwrite, fclose, unlink };
unittests_env.Alias("install",
unittests_env.Install(svr_db_build_dir,
os.path.join(svr_db_src_dir,
- 'oic_svr_db_client.json')))
+ 'oic_svr_db_client.dat')))
cp out/tizen/*/%{build_mode}/resource/examples/simpleserver %{ex_install_dir}
cp out/tizen/*/%{build_mode}/resource/examples/simpleserverHQ %{ex_install_dir}
cp out/tizen/*/%{build_mode}/resource/examples/threadingsample %{ex_install_dir}
-cp out/tizen/*/%{build_mode}/resource/examples/oic_svr_db_server.json %{ex_install_dir}
-cp out/tizen/*/%{build_mode}/resource/examples/oic_svr_db_client.json %{ex_install_dir}
+cp out/tizen/*/%{build_mode}/resource/examples/oic_svr_db_server.dat %{ex_install_dir}
+cp out/tizen/*/%{build_mode}/resource/examples/oic_svr_db_client.dat %{ex_install_dir}
cp out/tizen/*/%{build_mode}/libcoap.a %{buildroot}%{_libdir}
%if 0%{?SECURED} == 1
mkdir -p %{ex_install_dir}/provisioning