Added API to reset SVR DB
authorJongmin Choi <jminl.choi@samsung.com>
Fri, 25 Nov 2016 09:44:55 +0000 (18:44 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 9 Dec 2016 07:18:28 +0000 (07:18 +0000)
OCResetSVRDB() added to reset the SVR DB of the device

Patch #1: Initial upload
Patch #2: Fix based on Chul's comments

Change-Id: I2b55eaad5dd4c81f45373ca1dbde113c01d0a93d
Signed-off-by: Jongmin Choi <jminl.choi@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14791
Reviewed-by: Jongsung Lee <js126.lee@samsung.com>
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: dongik Lee <dongik.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit 2de9ab10e67d24111202aa8e255b5bfb2634cee2)
Reviewed-on: https://gerrit.iotivity.org/gerrit/15307

resource/csdk/octbstack_product_secured.def
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/ocprovisioningmanager.c

index 65d655f..3a4b672 100644 (file)
@@ -32,6 +32,7 @@ OCProvisionPairwiseDevices
 OCRemoveDevice
 OCRemoveDeviceWithUuid
 OCResetDevice
+OCResetSVRDB
 OCSetOwnerTransferCallbackData
 OCUnlinkDevices
 OCSetOxmAllowStatus
index 973dfb9..e995272 100644 (file)
@@ -363,6 +363,13 @@ OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc
                             OCProvisionResultCB resultCallback);\r
 \r
 /**\r
+ * This function resets SVR DB to its factory setting.\r
+ *\r
+ *@return OC_STACK_OK in case of successful reset and other value otherwise.\r
+ */\r
+OCStackResult OCResetSVRDB(void);\r
+\r
+/**\r
  * API to get status of all the devices in current subnet. The status include endpoint information\r
  * and doxm information which can be extracted duing owned and unowned discovery. Along with this\r
  * information. The API will provide information about devices' status\r
index 90c18b9..2f70504 100644 (file)
@@ -62,6 +62,7 @@ extern "C"
 #define _50_REMOVE_SELEC_DEV_       50
 #define _51_REMOVE_DEV_WITH_UUID_   51
 #define _52_RESET_SELEC_DEV_        52
+#define _53_RESET_SVR_DB_           53
 #define _60_GET_CRED_               60
 #define _61_GET_ACL_                61
 #ifdef MULTIPLE_OWNER
@@ -1503,6 +1504,18 @@ static int resetDevice(void)
     return 0;
 }
 
+static int resetSVRDB(void)
+{
+    printf("   Resetting SVR DB..\n");
+    OCStackResult rst = OCResetSVRDB();
+    if (OC_STACK_OK != rst)
+    {
+        OIC_LOG_V(ERROR, TAG, "OCResetSVRDB API error: %d", rst);
+        return -1;
+    }
+    return 0;
+}
+
 static OicSecAcl_t* createAcl(const int dev_num)
 {
     if(0>=dev_num || g_own_cnt<dev_num)
@@ -2113,7 +2126,8 @@ static void printMenu(void)
     printf("** [E] REMOVE THE SELECTED DEVICE\n");
     printf("** 50. Remove the Selected Device\n");
     printf("** 51. Remove Device with UUID (UUID input is required)\n");
-    printf("** 52. Reset the Selected Device\n\n");
+    printf("** 52. Reset the Selected Device\n");
+    printf("** 53. Reset SVR DB\n\n");
 
     printf("** [F] GET SECURITY RESOURCE FOR DEBUGGING ONLY\n");
     printf("** 60. Get the Credential resources of the Selected Device\n");
@@ -2293,6 +2307,12 @@ int main()
                 OIC_LOG(ERROR, TAG, "_52_RESET_SELEC_DEV_: error");
             }
             break;
+        case _53_RESET_SVR_DB_:
+            if(resetSVRDB())
+            {
+                OIC_LOG(ERROR, TAG, "_53_RESET_SVR_DB_: error");
+            }
+            break;
         case _60_GET_CRED_:
             if(getCred())
             {
index 1dfc8c2..eb72fb2 100644 (file)
@@ -35,6 +35,7 @@
 #include "utlist.h"
 #include "aclresource.h" //Note: SRM internal header
 #include "pconfresource.h"
+#include "psinterface.h"
 
 #define TAG "OIC_OCPMAPI"
 
@@ -816,6 +817,16 @@ OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc
 }
 
 /**
+ * This function resets SVR DB to its factory setting.
+ *
+ * @return OC_STACK_OK in case of successful reset and other value otherwise.
+ */
+OCStackResult OCResetSVRDB(void)
+{
+    return ResetSecureResourceInPS();
+}
+
+/**
  * Internal Function to update result in link result array.
  */
 static void UpdateLinkResults(Linkdata_t *link, int device, OCStackResult stackresult)