class OCSecure
{
+ private:
+ /**
+ * Common callback wrapper, which will be called from OC-APIs.
+ */
+ static void callbackWrapper(void* ctx, size_t nOfRes,
+ OCProvisionResult_t *arr, bool hasError);
+
+ /**
+ * Callback function to display Verification Number.
+ *
+ * @param[in] ctx User context returned in callback
+ * @param[in] verifNum Array of MUTUAL_VERIF_NUM_LEN size bytes
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+ static OCStackResult displayNumCallbackWrapper(void* ctx,
+ uint8_t verifNum[MUTUAL_VERIF_NUM_LEN]);
+
+ /**
+ * Callback function to get 'Num' verification result.
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+ static OCStackResult confirmUserCallbackWrapper(void* ctx);
+
+ /**
+ * Notifier wrapper for trustCertChain change.
+ *
+ * @param[in] ctx User context returned in callback
+ * @param[in] credId trustCertChain changed for this ID
+ * @param[in] trustCertChain trustcertchain binary blob
+ * @param[in] chainSize size of trustCertChain
+ */
+ static void certCallbackWrapper(void* ctx, uint16_t credId, uint8_t *trustCertChain,
+ size_t chainSize);
+
public:
/**
* The API is responsible for initialization of the provisioning manager. It will load
/**
* API for registering a pin input callback. Only one input pin callback is allowed
- * to be registered at a time by setInputPinCallback and registerInputPinCallback.
- * Use unsetInputPinCallback to unregister a callback set by setInputPinCallback.
+ * to be registered at a time by setInputPinCallback and registerInputPinCallback.
+ * Use unsetInputPinCallback to unregister a callback set by setInputPinCallback.
*
-
* @deprecated Use registerInputPinCallback instead.
*
* @param inputPin inputPin callback function.
static OCStackResult unsetInputPinCallback();
/**
-
* API to register for a callback to input a pin. Only one input pin callback is allowed
- * to be registered at a time by setInputPinCallback and registerInputPinCallback. Use
+ * to be registered at a time by setInputPinCallback and registerInputPinCallback. Use
* deregisterInputPinCallback to unregister a callback set by registerInputPinCallback.
*
* @param inputPinCB Callback which is to be registered.
*/
static OCStackResult deregisterDisplayPinCallback(DisplayPinCallbackHandle displayPinCallbackHandle);
-
-
-
-
-
-
-
-
-
/**
* API to get status of all the devices in current subnet. The status include endpoint
* information and doxm information which can be extracted during owned and unowned
*/
static OCStackResult setVerifyOptionMask(VerifyOptionBitmask_t optionMask);
- /**
- * Callback function to display Verification Number.
- *
- * @param[in] ctx User context returned in callback
- * @param[in] verifNum Array of MUTUAL_VERIF_NUM_LEN size bytes
- *
- * @return OC_STACK_OK in case of success and other value otherwise.
- */
- static OCStackResult displayNumCallbackWrapper(void* ctx,
- uint8_t verifNum[MUTUAL_VERIF_NUM_LEN]);
-
- /**
- * Callback function to get 'Num' verification result.
- *
- * @return OC_STACK_OK in case of success and other value otherwise.
- */
- static OCStackResult confirmUserCallbackWrapper(void* ctx);
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
/**
static OCStackResult saveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
OicEncodingType_t encodingType, uint16_t *credId);
-
/**
* API to read Trust certificate chain from SVR.
* Caller must free when done using the returned trust certificate
static OCStackResult removeTrustCertChangeNotifier();
/**
- * Notifier wrapper for trustCertChain change.
- *
- * @param[in] ctx User context returned in callback
- * @param[in] credId trustCertChain changed for this ID
- * @param[in] trustCertChain trustcertchain binary blob
- * @param[in] chainSize size of trustCertChain
- */
- static void certCallbackWrapper(void* ctx, uint16_t credId, uint8_t *trustCertChain,
- size_t chainSize);
-
- /**
* Wrapper to save the seed value to generate device UUID
*
* @param[in] seed buffer of seed value
*@return OC_STACK_OK in case of successful configue and other value otherwise.
*/
static OCStackResult configSelfOwnership();
-
};
/**
*/
OCStackResult getOTMethod(OicSecOxm_t* oxm);
- /**
- * Common callback wrapper, which will be called from OC-APIs.
- */
- static void callbackWrapper(void* ctx, size_t nOfRes,
- OCProvisionResult_t *arr, bool hasError);
-
#ifdef MULTIPLE_OWNER
/**
* API to update 'doxm.oxmsel' to resource server.
#endif // MULTIPLE_OWNER
private:
+ /**
+ * Common callback wrapper, which will be called from OC-APIs.
+ */
+ static void callbackWrapper(void* ctx, size_t nOfRes,
+ OCProvisionResult_t *arr, bool hasError);
+
void validateSecureResource();
};
*/
bool g_displayPinCallbackRegistered = false;
+ static void callbackWrapperImpl(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
+ {
+ PMResultList_t *results = nullptr;
+ ProvisionContext* context = static_cast<ProvisionContext*>(ctx);
+
+ try
+ {
+ results = new PMResultList_t;
+ }
+ catch (std::bad_alloc& e)
+ {
+ oclog() <<"Bad alloc exception";
+ return;
+ }
+
+ for (size_t i = 0; i < nOfRes; i++)
+ {
+ results->push_back(arr[i]);
+ }
+
+ std::thread exec(context->callback, results, hasError);
+ exec.detach();
+
+ delete context;
+ }
OCStackResult OCSecure::provisionInit(const std::string& dbPath)
{
OCStackResult result;
return result;
}
-
+
static void inputPinCallbackWrapper(OicUuid_t deviceId, char* pinBuffer, size_t pinBufferSize, void* context)
{
(static_cast<InputPinContext*>(context))->callback(deviceId, pinBuffer, pinBufferSize);
if(OC_STACK_OK == result)
{
result = OCRemoveDeviceWithUuid(static_cast<void*>(context), waitTimeForOwnedDeviceDiscovery,
- &targetDev, &OCSecureResource::callbackWrapper);
+ &targetDev, &OCSecure::callbackWrapper);
}
else
{
}
#endif // __WITH_DTLS__ || __WITH_TLS__
- void OCSecureResource::callbackWrapper(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
+ void OCSecure::callbackWrapper(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
{
- PMResultList_t *results = nullptr;
- ProvisionContext* context = static_cast<ProvisionContext*>(ctx);
-
- try
- {
- results = new PMResultList_t;
- }
- catch (std::bad_alloc& e)
- {
- oclog() <<"Bad alloc exception";
- return;
- }
-
- for (size_t i = 0; i < nOfRes; i++)
- {
- results->push_back(arr[i]);
- }
-
- std::thread exec(context->callback, results, hasError);
- exec.detach();
+ callbackWrapperImpl(ctx, nOfRes, arr, hasError);
+ }
- delete context;
+ void OCSecureResource::callbackWrapper(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
+ {
+ callbackWrapperImpl(ctx, nOfRes, arr, hasError);
}
OCSecureResource::OCSecureResource(): m_csdkLock(std::weak_ptr<std::recursive_mutex>()),