From: Oleksii Beketov
Date: Mon, 3 Dec 2018 12:08:56 +0000 (+0200)
Subject: OXM notify CB
X-Git-Tag: submit/tizen_5.0/20181206.000945~1
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1bffe5992f1c60d8dde685fb4b9781e2134ef35c;p=platform%2Fupstream%2Fiotivity.git
OXM notify CB
Added selected OXM notification callback
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/336
(cherry picked from commit 57e8641fcc434d15a4d078bd0d8a4b036c99d140)
Change-Id: I29faaa328082eb4ac41a47c5a1024ff9e04b3392
Signed-off-by: Oleksii Beketov
Signed-off-by: DoHyun Pyun
---
diff --git a/resource/csdk/connectivity/api/casecurityinterface.h b/resource/csdk/connectivity/api/casecurityinterface.h
index ac5a22b26..c891460c4 100644
--- a/resource/csdk/connectivity/api/casecurityinterface.h
+++ b/resource/csdk/connectivity/api/casecurityinterface.h
@@ -373,9 +373,16 @@ typedef void (*SslExportKeysCallback_t)(const unsigned char* masterSecret,
CAResult_t CASetSslExportKeysCallback(SslExportKeysCallback_t exportKeysCb,
CASslEkcbProtocol_t protocol, CASslEkcbRole_t role);
-
+/**
+ * API to set certificate verification callback.
+ */
void CAsetCertificateVerificationCallback(CertificateVerificationCallback_t noCertCallback);
+/**
+ * API to unset certificate verification callback.
+ */
+void CAunsetCertificateVerificationCallback();
+
#endif //__WITH_TLS__ or __WITH_DTLS__
diff --git a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c
index 7a2190819..187d23c78 100644
--- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c
+++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c
@@ -627,6 +627,13 @@ void CAsetCertificateVerificationCallback(CertificateVerificationCallback_t cert
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
}
+void CAunsetCertificateVerificationCallback()
+{
+ OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
+ g_CertificateVerificationCallback = NULL;
+ OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
+}
+
static int GetAdapterIndex(CATransportAdapter_t adapter)
{
switch (adapter)
diff --git a/resource/csdk/security/include/internal/doxmresource.h b/resource/csdk/security/include/internal/doxmresource.h
index d42dd73e9..1000f8618 100644
--- a/resource/csdk/security/include/internal/doxmresource.h
+++ b/resource/csdk/security/include/internal/doxmresource.h
@@ -202,7 +202,6 @@ OCStackResult RemoveSubOwner(const OicUuid_t* subOwner);
*/
OCStackResult SetNumberOfSubOwner(size_t maxSubOwner);
-
#ifdef __cplusplus
}
#endif
diff --git a/resource/csdk/security/include/oxmverifycommon.h b/resource/csdk/security/include/oxmverifycommon.h
index c26852ba2..bab6aa210 100644
--- a/resource/csdk/security/include/oxmverifycommon.h
+++ b/resource/csdk/security/include/oxmverifycommon.h
@@ -60,6 +60,11 @@ typedef OCStackResult (*UserConfirmCallback)(void * ctx);
*/
typedef OCStackResult (*InputStateCallback)(void * ctx);
+/**
+ * Function pointer to notify user selected OXM
+ */
+typedef void (*InformOxmSelectedCallback_t)(OicSecOxm_t oxmSel);
+
/**
* Context for displaying verification PIN
*/
@@ -123,6 +128,16 @@ void* UnsetInputStateCB();
*/
void SetVerifyOption(VerifyOptionBitmask_t verifyOption);
+/**
+ * Set notify selected OXM callback
+ */
+void SetInformOxmSelCB(InformOxmSelectedCallback_t informOxmSelCB);
+
+/**
+ * Set notify selected OXM callback
+ */
+void UnsetInformOxmSelCB();
+
/**
* Call the Callback for Verifying Ownership Transfer process.
*/
diff --git a/resource/csdk/security/provisioning/include/ocprovisioningmanager.h b/resource/csdk/security/provisioning/include/ocprovisioningmanager.h
index 24b55dc9d..483afa236 100644
--- a/resource/csdk/security/provisioning/include/ocprovisioningmanager.h
+++ b/resource/csdk/security/provisioning/include/ocprovisioningmanager.h
@@ -583,10 +583,15 @@ OCStackResult OCSelectOwnershipTransferMethod(const OicSecOxm_t *supportedMethod
OCStackResult OCSetPeerCertCallback(void *ctx, PeerCertCallback peerCertCallback);
/*
- * Callback for selecting OTM.
+ * Set selecting OTM callback.
*/
void SetSelectOTMCB(OTMSelectMethodCallback selectOTMcb);
+/*
+ * Unset selecting OTM callback.
+ */
+void UnsetSelectOTMCB();
+
#endif // __WITH_DTLS__ || __WITH_TLS__
diff --git a/resource/csdk/security/provisioning/sample/sampleserver_mfg.cpp b/resource/csdk/security/provisioning/sample/sampleserver_mfg.cpp
index cb2809ebc..a1923fea3 100644
--- a/resource/csdk/security/provisioning/sample/sampleserver_mfg.cpp
+++ b/resource/csdk/security/provisioning/sample/sampleserver_mfg.cpp
@@ -452,6 +452,11 @@ void confirmNoCertCB(CACertificateVerificationStatus_t status)
return;
}
+void informOxmSelCB(OicSecOxm_t oxmSel)
+{
+ printf(" > OXM selected: 0x%x\n", oxmSel);
+}
+
FILE* server_fopen(const char *path, const char *mode)
{
(void)path;
@@ -495,6 +500,7 @@ int main(int argc, char **argv)
OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink, NULL, NULL};
SetUserConfirmCB(NULL, confirmCB);
+ SetInformOxmSelCB(informOxmSelCB);
CAsetCertificateVerificationCallback(confirmNoCertCB);
OCRegisterPersistentStorageHandler(&ps);
diff --git a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c
index e0e82ef7d..a483e7a73 100644
--- a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c
+++ b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c
@@ -188,6 +188,12 @@ void SetSelectOTMCB(OTMSelectMethodCallback selectOTMcb)
return;
}
+void UnsetSelectOTMCB()
+{
+ g_selectOTMCB = NULL;
+ return;
+}
+
/**
* Internal API to convert OxM value to index of oxm allow table.
*/
diff --git a/resource/csdk/security/src/doxmresource.c b/resource/csdk/security/src/doxmresource.c
index 3128723a6..4fbd45c68 100644
--- a/resource/csdk/security/src/doxmresource.c
+++ b/resource/csdk/security/src/doxmresource.c
@@ -95,6 +95,7 @@ static OicSecDoxm_t *gDoxm = NULL;
static oc_mutex g_mutexDoxm = NULL;
static bool g_isDoxmNull = false;
static OCResourceHandle gDoxmHandle = NULL;
+static InformOxmSelectedCallback_t g_InformOxmSelectedCallback = NULL;
static OicSecOxm_t gOicSecDoxmJustWorks = OIC_JUST_WORKS;
static OicSecDoxm_t gDefaultDoxm =
@@ -1081,6 +1082,20 @@ static bool ValidateOxmsel(const OicSecOxm_t *supportedMethods,
return isValidOxmsel;
}
+void SetInformOxmSelCB(InformOxmSelectedCallback_t informOxmSelCB)
+{
+ OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
+ g_InformOxmSelectedCallback = informOxmSelCB;
+ OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
+}
+
+void UnsetInformOxmSelCB()
+{
+ OIC_LOG_V(DEBUG, TAG, "In %s", __func__);
+ g_InformOxmSelectedCallback = NULL;
+ OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
+}
+
static OCEntityHandlerResult HandleDoxmPostRequest(OCEntityHandlerRequest * ehRequest)
{
OIC_LOG (DEBUG, TAG, "Doxm EntityHandle processing POST request");
@@ -1240,6 +1255,10 @@ static OCEntityHandlerResult HandleDoxmPostRequest(OCEntityHandlerRequest * ehRe
ehRet = OC_EH_NOT_ACCEPTABLE;
goto exit;
}
+ if (g_InformOxmSelectedCallback)
+ {
+ g_InformOxmSelectedCallback(newDoxm->oxmSel);
+ }
#if defined (__WITH_TLS__) || defined(__WITH_DTLS__)
if (memcmp(&(newDoxm->owner), &emptyOwner, sizeof(OicUuid_t)) == 0)