replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / src / resourcemanager.c
index 198b62a..6d7c8e1 100644 (file)
@@ -25,7 +25,6 @@
 #include "pstatresource.h"
 #include "doxmresource.h"
 #include "credresource.h"
-#include "svcresource.h"
 #include "amaclresource.h"
 #include "oic_malloc.h"
 #include "oic_string.h"
 #include "dpairingresource.h"
 //#endif // DIRECT_PAIRING
 #include "verresource.h"
+#include "psinterface.h"
 
-#define TAG "SRM-RM"
+#define TAG "OIC_SRM_RM"
 
-#ifdef __WITH_X509__
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
 #include "crlresource.h"
-#endif // __WITH_X509__
+#endif // __WITH_DTLS__ || __WITH_TLS__
 
 OCStackResult SendSRMResponse(const OCEntityHandlerRequest *ehRequest,
         OCEntityHandlerResult ehRet, uint8_t *cborPayload, size_t size)
 {
     OIC_LOG(DEBUG, TAG, "SRM sending SRM response");
-    OCEntityHandlerResponse response = {.requestHandle = NULL};
     OCStackResult ret = OC_STACK_ERROR;
 
     if (ehRequest)
     {
+        OCEntityHandlerResponse response = {.requestHandle = 0};
         OCSecurityPayload ocPayload = {.base = {.type = PAYLOAD_TYPE_INVALID}};
 
         response.requestHandle = ehRequest->requestHandle;
@@ -73,13 +73,17 @@ OCStackResult InitSecureResources( )
 {
     OCStackResult ret;
 
+    ret = InitPersistentStorageInterface();
+
     /*
      * doxm resource should be initialized first as it contains the DeviceID
      * which MAY be used during initialization of other resources.
      */
 
-    ret = InitDoxmResource();
-
+    if(OC_STACK_OK == ret)
+    {
+        ret = InitDoxmResource();
+    }
     if(OC_STACK_OK == ret)
     {
         ret = InitPstatResource();
@@ -92,16 +96,12 @@ OCStackResult InitSecureResources( )
     {
         ret = InitCredResource();
     }
-#ifdef __WITH_X509__
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     if(OC_STACK_OK == ret)
     {
         ret = InitCRLResource();
     }
-#endif // __WITH_X509__
-    if(OC_STACK_OK == ret)
-    {
-        ret = InitSVCResource();
-    }
+#endif // __WITH_DTLS__ || __WITH_TLS__
     if(OC_STACK_OK == ret)
     {
         ret = InitAmaclResource();
@@ -134,16 +134,16 @@ OCStackResult DestroySecureResources( )
     DeInitCredResource();
     DeInitDoxmResource();
     DeInitPstatResource();
-#ifdef __WITH_X509__
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     DeInitCRLResource();
-#endif // __WITH_X509__
-    DeInitSVCResource();
+#endif // __WITH_DTLS__ || __WITH_TLS__
     DeInitAmaclResource();
 //#ifdef DIRECT_PAIRING
     DeInitPconfResource();
     DeInitDpairingResource();
 //#endif // DIRECT_PAIRING
     DeInitVerResource();
+    DeinitPersistentStorageInterface();
 
     return OC_STACK_OK;
 }