projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
security
/
src
/
pconfresource.c
diff --git
a/resource/csdk/security/src/pconfresource.c
b/resource/csdk/security/src/pconfresource.c
index
84bbf48
..
da0b9c0
100644
(file)
--- a/
resource/csdk/security/src/pconfresource.c
+++ b/
resource/csdk/security/src/pconfresource.c
@@
-18,15
+18,21
@@
*
* *****************************************************************/
*
* *****************************************************************/
+#include "iotivity_config.h"
#include <stdlib.h>
#include <string.h>
#include "ocstack.h"
#include "logger.h"
#include "oic_malloc.h"
#include "oic_string.h"
#include <stdlib.h>
#include <string.h>
#include "ocstack.h"
#include "logger.h"
#include "oic_malloc.h"
#include "oic_string.h"
+#if defined (__TIZENRT__)
+#include <apps/netutils/cJSON.h>
+#else
#include "cJSON.h"
#include "cJSON.h"
+#endif
#include "base64.h"
#include "ocpayload.h"
#include "base64.h"
#include "ocpayload.h"
+#include "ocpayloadcbor.h"
#include "payload_logging.h"
#include "resourcemanager.h"
#include "pconfresource.h"
#include "payload_logging.h"
#include "resourcemanager.h"
#include "pconfresource.h"
@@
-36,14
+42,13
@@
#include "doxmresource.h"
#include "srmutility.h"
#include "ocserverrequest.h"
#include "doxmresource.h"
#include "srmutility.h"
#include "ocserverrequest.h"
-#include <stdlib.h>
#include "psinterface.h"
#include "security_internals.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "psinterface.h"
#include "security_internals.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#define TAG "
SRM-
PCONF"
+#define TAG "
OIC_SRM_
PCONF"
static const uint16_t CBOR_SIZE = 1024;
static const uint64_t CBOR_MAX_SIZE = 4400;
static const uint16_t CBOR_SIZE = 1024;
static const uint64_t CBOR_MAX_SIZE = 4400;
@@
-425,7
+430,7
@@
OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
cborEncoderResult = cbor_encoder_close_container(&encoder, &pconfMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close pconfMap");
cborEncoderResult = cbor_encoder_close_container(&encoder, &pconfMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close pconfMap");
- *size =
encoder.ptr - outPayload
;
+ *size =
cbor_encoder_get_buffer_size(&encoder, outPayload)
;
*payload = outPayload;
ret = OC_STACK_OK;
exit:
*payload = outPayload;
ret = OC_STACK_OK;
exit:
@@
-434,7
+439,7
@@
exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
- cborLen +=
encoder.ptr - encoder.end
;
+ cborLen +=
cbor_encoder_get_buffer_size(&encoder, encoder.end)
;
cborEncoderResult = CborNoError;
ret = PconfToCBORPayload(pconf, payload, &cborLen);
*size = cborLen;
cborEncoderResult = CborNoError;
ret = PconfToCBORPayload(pconf, payload, &cborLen);
*size = cborLen;
@@
-817,6
+822,7
@@
static OCEntityHandlerResult HandlePconfGetRequest (const OCEntityHandlerRequest
{
uint8_t* payload = NULL;
size_t size = 0;
{
uint8_t* payload = NULL;
size_t size = 0;
+ const OicSecDoxm_t *m_doxm = NULL;
OCEntityHandlerResult ehRet = OC_EH_OK;
OicSecPconf_t pconf;
OCEntityHandlerResult ehRet = OC_EH_OK;
OicSecPconf_t pconf;
@@
-824,7
+830,13
@@
static OCEntityHandlerResult HandlePconfGetRequest (const OCEntityHandlerRequest
OIC_LOG (DEBUG, TAG, "Pconf EntityHandle processing GET request");
OIC_LOG (DEBUG, TAG, "Pconf EntityHandle processing GET request");
- if (true == GetDoxmResourceData()->dpc)
+ m_doxm = GetDoxmResourceData();
+ if (NULL == m_doxm)
+ {
+ OIC_LOG (DEBUG, TAG, "Doxm resource Data is NULL");
+ }
+
+ if ((m_doxm) && (true == m_doxm->dpc))
{
//Making response elements for Get request
if( (true == gPconf->edp) &&
{
//Making response elements for Get request
if( (true == gPconf->edp) &&
@@
-891,7
+903,7
@@
static OCEntityHandlerResult HandlePconfPostRequest (const OCEntityHandlerReques
OCStackResult res=OC_STACK_OK;
OicSecPconf_t* newPconf = NULL;
OCStackResult res=OC_STACK_OK;
OicSecPconf_t* newPconf = NULL;
- if (true == GetDoxmResourceData()->dpc)
+ if (
NULL != GetDoxmResourceData() &&
true == GetDoxmResourceData()->dpc)
{
// Convert CBOR PCONF data into binary. This will also validate the PCONF data received.
uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
{
// Convert CBOR PCONF data into binary. This will also validate the PCONF data received.
uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;