Adding C++ api for configuring SVR db for self-ownership
authoramar <amar.sri@samsung.com>
Wed, 14 Dec 2016 07:54:27 +0000 (13:24 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 5 Jan 2017 03:58:58 +0000 (03:58 +0000)
Change-Id: I0a65b0a1b1a65c8659b0bc253c4d74087612e75d
Signed-off-by: amar <amar.sri@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15589
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jongsung Lee <js126.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit 714a7678ef1cc6d488f85ab13a623e4adb53f971)
Reviewed-on: https://gerrit.iotivity.org/gerrit/16125

resource/include/OCProvisioningManager.hpp
resource/provisioning/examples/provisioningclient.cpp
resource/provisioning/src/OCProvisioningManager.cpp

index 45115ef..0bc1dbf 100644 (file)
@@ -397,6 +397,14 @@ namespace OC
                                 size_t chainSize);
 #endif // __WITH_DTLS__ || __WITH_TLS__
 
+
+            /**
+             * This function configures SVR DB as self-ownership.
+             *
+             *@return OC_STACK_OK in case of successful configue and other value otherwise.
+             */
+            static OCStackResult configSelfOwnership();
+
     };
 
     /**
index c843a8f..1408167 100644 (file)
@@ -103,6 +103,7 @@ void printMenu()
     std::cout << "  19. Provision pre configure PIN for Multiple Ownership Transfer Mode"<<std::endl;
     std::cout << "  20. Add pre configure PIN for Multiple Ownership Transfer Mode"<<std::endl;
 #endif
+    std::cout << "  21. Configure SVRdb as Self-OwnerShip"<<std::endl;
     std::cout << "  99. Exit loop"<<std::endl;
 }
 
@@ -1642,6 +1643,20 @@ int main(void)
                         break;
                     }
 #endif //MULTIPLE_OWNER
+                case 21:
+                    {
+                        OCStackResult result;
+                        result = OCSecure::configSelfOwnership();
+                        if (OC_STACK_OK != result)
+                        {
+                            std::cout<<"configSelfOwnership API error. Please check SVR DB"<<std::endl;
+                        }
+                        else
+                        {
+                            std::cout<<"Success to configures SVR DB as self-ownership"<<std::endl;
+                        }
+                        break;
+                    }
                 case 99:
                 default:
                     out = 1;
index 6b4da7e..fe0e31c 100644 (file)
@@ -586,6 +586,25 @@ namespace OC
         return result;
     }
 
+    OCStackResult OCSecure::configSelfOwnership()
+    {
+        OCStackResult result;
+        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
+
+        if (cLock)
+        {
+            std::lock_guard<std::recursive_mutex> lock(*cLock);
+            result = OCConfigSelfOwnership();
+        }
+        else
+        {
+            oclog() <<"Mutex not found";
+            result = OC_STACK_ERROR;
+        }
+        return result;
+    }
+
+
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     OCStackResult OCSecure::saveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
                                         OicEncodingType_t encodingType, uint16_t *credId)