OXM notify CB 16/194516/1
authorOleksii Beketov <ol.beketov@samsung.com>
Mon, 3 Dec 2018 12:08:56 +0000 (14:08 +0200)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 5 Dec 2018 07:43:30 +0000 (16:43 +0900)
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 <ol.beketov@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resource/csdk/connectivity/api/casecurityinterface.h
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c
resource/csdk/security/include/internal/doxmresource.h
resource/csdk/security/include/oxmverifycommon.h
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/sample/sampleserver_mfg.cpp
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/src/doxmresource.c

index ac5a22b..c891460 100644 (file)
@@ -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__
 
 
index 7a21908..187d23c 100644 (file)
@@ -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)
index d42dd73..1000f86 100644 (file)
@@ -202,7 +202,6 @@ OCStackResult RemoveSubOwner(const OicUuid_t* subOwner);
  */
 OCStackResult SetNumberOfSubOwner(size_t maxSubOwner);
 
-
 #ifdef __cplusplus
 }
 #endif
index c26852b..bab6aa2 100644 (file)
@@ -61,6 +61,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
  */
 typedef struct DisplayNumContext
@@ -124,6 +129,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.
  */
 OCStackResult VerifyOwnershipTransfer(uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN],
index 24b55dc..483afa2 100644 (file)
@@ -583,10 +583,15 @@ OCStackResult OCSelectOwnershipTransferMethod(const OicSecOxm_t *supportedMethod
 OCStackResult OCSetPeerCertCallback(void *ctx, PeerCertCallback peerCertCallback);\r
 \r
 /*\r
- * Callback for selecting OTM.\r
+ * Set selecting OTM callback.\r
  */\r
 void SetSelectOTMCB(OTMSelectMethodCallback selectOTMcb);\r
 \r
+/*\r
+ * Unset selecting OTM callback.\r
+ */\r
+void UnsetSelectOTMCB();\r
+\r
 #endif // __WITH_DTLS__ || __WITH_TLS__\r
 \r
 \r
index cb2809e..a1923fe 100644 (file)
@@ -452,6 +452,11 @@ void confirmNoCertCB(CACertificateVerificationStatus_t status)
     return;
 }
 
+void informOxmSelCB(OicSecOxm_t oxmSel)\r
+{\r
+    printf("   > OXM selected: 0x%x\n", oxmSel);\r
+}\r
+\r
 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);
index e0e82ef..a483e7a 100644 (file)
@@ -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.
  */
index 3128723..4fbd45c 100644 (file)
@@ -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)