[IOT-2306] Remove Direct Pairing 49/21449/18
authorv.riznyk <v.riznyk@samsung.com>
Fri, 14 Jul 2017 08:51:47 +0000 (11:51 +0300)
committerVadym Riznyk <v.riznyk@samsung.com>
Thu, 21 Sep 2017 07:53:12 +0000 (07:53 +0000)
Remove direct pairing and pconfresource

Change-Id: Ia71db37f0c2ecbf2d7a62a8363c0949ada7e0f9e
Signed-off-by: v.riznyk <v.riznyk@samsung.com>
53 files changed:
resource/IPCA/unittests/mockInProcClientWrapper.cpp
resource/csdk/include/octypes.h
resource/csdk/security/SConscript
resource/csdk/security/include/experimental/securevirtualresourcetypes.h
resource/csdk/security/include/internal/directpairing.h [deleted file]
resource/csdk/security/include/internal/dpairingresource.h [deleted file]
resource/csdk/security/include/internal/pconfresource.h [deleted file]
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/provisioning/include/internal/secureresourceprovider.h
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/include/pmtypes.h
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/provisioning/unittest/ocprovisioningmanager.cpp
resource/csdk/security/provisioning/unittest/secureresourceprovider.cpp
resource/csdk/security/src/directpairing.c [deleted file]
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/dpairingresource.c [deleted file]
resource/csdk/security/src/pconfresource.c [deleted file]
resource/csdk/security/src/policyengine.c
resource/csdk/security/src/psinterface.c
resource/csdk/security/src/resourcemanager.c
resource/csdk/security/src/secureresourcemanager.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/unittest/SConscript
resource/csdk/security/unittest/directpairingtest.cpp [deleted file]
resource/csdk/stack/include/ocstack.h
resource/csdk/stack/octbstack_product.def
resource/csdk/stack/octbstack_product_secured.def
resource/csdk/stack/samples/linux/secure/SConscript
resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp [deleted file]
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/test/stacktests.cpp
resource/examples/SConscript
resource/examples/directpairingclient.cpp [deleted file]
resource/include/IClientWrapper.h
resource/include/InProcClientWrapper.h
resource/include/OCApi.h
resource/include/OCDirectPairing.h [deleted file]
resource/include/OCPlatform.h
resource/include/OCPlatform_impl.h
resource/include/OCProvisioningManager.hpp
resource/include/OutOfProcClientWrapper.h
resource/provisioning/examples/provisioningclient.cpp
resource/provisioning/src/OCProvisioningManager.cpp
resource/provisioning/unittests/OCProvisioningTest.cpp
resource/src/InProcClientWrapper.cpp
resource/src/OCDirectPairing.cpp [deleted file]
resource/src/OCPlatform.cpp
resource/src/OCPlatform_impl.cpp
resource/src/SConscript
resource/unittests/OCPlatformTest.cpp

index 2846e9e..dc97431 100644 (file)
@@ -289,35 +289,6 @@ namespace OC
         return OC_STACK_OK;\r
     }\r
 \r
-\r
-    OCStackResult InProcClientWrapper::FindDirectPairingDevices(\r
-                                                unsigned short waittime,\r
-                                                GetDirectPairedCallback& callback)\r
-    {\r
-        OC_UNUSED(waittime);\r
-        OC_UNUSED(callback);\r
-        return OC_STACK_OK;\r
-    }\r
-\r
-    OCStackResult InProcClientWrapper::GetDirectPairedDevices(GetDirectPairedCallback& callback)\r
-    {\r
-        OC_UNUSED(callback);\r
-        return OC_STACK_OK;\r
-    }\r
-\r
-    OCStackResult InProcClientWrapper::DoDirectPairing(\r
-                                                std::shared_ptr<OCDirectPairing> peer,\r
-                                                const OCPrm_t& pmSel,\r
-                                                const std::string& pinNumber,\r
-                                                DirectPairingCallback& callback)\r
-    {\r
-        OC_UNUSED(peer);\r
-        OC_UNUSED(pmSel);\r
-        OC_UNUSED(pinNumber);\r
-        OC_UNUSED(callback);\r
-        return OC_STACK_OK;\r
-    }\r
-\r
 #ifdef WITH_CLOUD\r
     OCStackResult InProcClientWrapper::SubscribeDevicePresence(\r
                                                 OCDoHandle* handle,\r
index 44cc1c8..d58c8dd 100644 (file)
@@ -1879,17 +1879,6 @@ typedef OCEntityHandlerResult (*OCEntityHandler)
 typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri, void* callbackParam);
 
-//#ifdef DIRECT_PAIRING
-/**
- * Callback function definition of direct-pairing
- *
- * @param[OUT] ctx - user context returned in the callback.
- * @param[OUT] peer - pairing device info.
- * @param[OUT] result - It's returned with 'OC_STACK_XXX'. It will return 'OC_STACK_OK'
- *                                   if D2D pairing is success without error
- */
-typedef void (*OCDirectPairingCB)(void *ctx, OCDPDev_t *peer, OCStackResult result);
-//#endif // DIRECT_PAIRING
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
 /**
  * Callback function definition for Change in TrustCertChain
index 28a9870..2daa1ae 100644 (file)
@@ -107,15 +107,12 @@ libocsrm_src = [
     OCSRM_SRC + 'pstatresource.c',
     OCSRM_SRC + 'doxmresource.c',
     OCSRM_SRC + 'credresource.c',
-    OCSRM_SRC + 'pconfresource.c',
-    OCSRM_SRC + 'dpairingresource.c',
     OCSRM_SRC + 'policyengine.c',
     OCSRM_SRC + 'psinterface.c',
     OCSRM_SRC + 'srmresourcestrings.c',
     OCSRM_SRC + 'srmutility.c',
     OCSRM_SRC + 'iotvticalendar.c',
     OCSRM_SRC + 'base64.c',
-    OCSRM_SRC + 'directpairing.c',
     OCSRM_SRC + 'deviceonboardingstate.c'
 ]
 
index 47f6305..c7c0a06 100644 (file)
@@ -639,10 +639,6 @@ typedef struct OicPin OicDpPin_t;
 
 typedef struct OicSecPdAcl OicSecPdAcl_t;
 
-typedef struct OicSecPconf OicSecPconf_t;
-
-typedef struct OicSecDpairing OicSecDpairing_t;
-
 #define DP_PIN_LENGTH 8 // temporary length
 
 /**
@@ -681,34 +677,6 @@ struct OicSecPdAcl
     OicSecPdAcl_t    *next;
 };
 
-/**
- * @brief   /oic/sec/pconf (Pairing Configuration) data type
- */
-struct OicSecPconf
-{
-    // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
-    bool                  edp;                // 0:W:S:M:Boolean
-    OicSecPrm_t      *prm;              // 1:R:M:N:UINT16
-    size_t                prmLen;          // the number of elts in Prm
-    OicDpPin_t          pin;               // 2:R:S:Y:String
-    OicSecPdAcl_t    *pdacls;         // 3:R:M:Y:oic.sec.pdacltype
-    OicUuid_t           *pddevs;        // 4:R:M:Y:oic.uuid
-    size_t                 pddevLen;     // the number of elts in pddev
-    OicUuid_t           deviceID;       // 5:R:S:Y:oic.uuid
-    OicUuid_t           rownerID;          // 6:R:S:Y:oic.uuid
-};
-
-/**
- * @brief   /oic/sec/dpairing (Device Pairing) data type
- */
-struct OicSecDpairing
-{
-    // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
-    OicSecPrm_t      spm;               // 0:R/W:S:Y:UINT16
-    OicUuid_t           pdeviceID;     // 1:R:S:Y:oic.uuid
-    OicUuid_t           rownerID;          // 2:R:S:Y:oic.uuid
-};
-
 #define SPEC_MAX_VER_LEN (sizeof("core.x.x.x") + 1) // Spec Version length.
 /**
  * @def GET_ACL_VER(specVer)
diff --git a/resource/csdk/security/include/internal/directpairing.h b/resource/csdk/security/include/internal/directpairing.h
deleted file mode 100644 (file)
index a11d2df..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* *****************************************************************\r
- *\r
- * Copyright 2016 Samsung Electronics All Rights Reserved.\r
- *\r
- *\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * *****************************************************************/\r
-\r
-#ifndef _DIRECT_PAIRING_H_\r
-#define _DIRECT_PAIRING_H_\r
-\r
-#include <stdbool.h>\r
-#include "ocstack.h"\r
-#include "pmtypes.h"\r
-#include "experimental/securevirtualresourcetypes.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-/**\r
- * Discover direct-pairing devices in the same IP subnet.\r
- *\r
- * @param[in] waittime  Timeout in seconds.\r
- *\r
- * @return OC_STACK_OK on success otherwise error.\r
- */\r
-OCStackResult DPDeviceDiscovery(unsigned short waittime);\r
-\r
-/**\r
- * Start direct-pairing processes.\r
- *\r
- * @param[in] ctx  user context passed back with resultCallback.\r
- * @param[in] peer  target device to establish direct-pairing.\r
- * @param[in] pmSel  selected pairing method.\r
- * @param[in] pinNumber  secret value for dtls connection.\r
- * @param[in] resultCallback  result event callback.\r
- *\r
- * @return OC_STACK_OK on success otherwise error.\r
- */\r
-OCStackResult DPDirectPairing(void *ctx, OCDirectPairingDev_t* peer, OicSecPrm_t pmSel,\r
-                                char *pinNumber, OCDirectPairingResultCB resultCallback);\r
-\r
-/**\r
- * This function returns discovered devices list in direct-pairing discovery\r
- * Caller must NOT free returned constant pointer\r
- *\r
- * @return OCDirectPairingDev_t pointer on success otherwise NULL.\r
- */\r
-const OCDirectPairingDev_t* DPGetDiscoveredDevices();\r
-\r
-/**\r
- * This function returns paired devices list until now\r
- * Caller must NOT free returned constant pointer\r
- *\r
- * @return OCDirectPairingDev_t pointer on success otherwise NULL.\r
- */\r
-const OCDirectPairingDev_t* DPGetPairedDevices();\r
-\r
-/**\r
- * This function delete both discovered devices and paired devices list\r
- *\r
- */\r
-void DPDeleteLists();\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif //_DIRECT_PAIRING_H_\r
-\r
diff --git a/resource/csdk/security/include/internal/dpairingresource.h b/resource/csdk/security/include/internal/dpairingresource.h
deleted file mode 100644 (file)
index ee158b4..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/* *****************************************************************\r
- *\r
- * Copyright 2016 Samsung Electronics All Rights Reserved.\r
- *\r
- *\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * *****************************************************************/\r
-\r
-#ifndef IOTVT_SRM_DPAIRING_H\r
-#define IOTVT_SRM_DPAIRING_H\r
-\r
-#include "octypes.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/**\r
- * Initialize DPAIRING resource by loading data from persistent storage.\r
- *\r
- * @retval  OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult InitDpairingResource();\r
-\r
-/**\r
- * Perform cleanup for DPAIRING resources.\r
- *\r
- * @retval  OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult DeInitDpairingResource();\r
-\r
-/**\r
- * This method converts CBOR DPAIRING into binary DPAIRING.\r
- * The CBOR DPAIRING can be from persistent database or\r
- * or received as POST request.\r
- *\r
- * @param cborPayload pconf data in cbor format.\r
- * @param size size of the cbor payload\r
- * @param secDpair binary Dpairing resource\r
- * @return OC_STACK_OK for Success, otherwise some error value.\r
- *\r
- * @note Caller needs to invoke OICFree after done\r
- *       using the return pointer\r
- */\r
-OCStackResult CBORPayloadToDpair(const uint8_t *cborPayload, size_t size,\r
-        OicSecDpairing_t **secDpair);\r
-\r
-/**\r
- * This method converts DPAIRING data into CBOR format.\r
- *\r
- * @param dpair  Pointer to OicSecDpairing_t.\r
- * @param payload CBOR format converted from binary dpairing\r
- * @param size Size of the coverted payload\r
- * @return OC_STACK_OK for Success, otherwise some error value.\r
- *\r
- * @note Caller needs to invoke OICFree after done\r
- *       using the return pointer\r
- */\r
-OCStackResult DpairingToCBORPayload(const OicSecDpairing_t *dpair, uint8_t **payload, size_t *size);\r
-\r
-/** This function deallocates the memory for OicSecPconf_t .\r
- *\r
- * @param[in] dpair  Pointer to OicSecDpairing_t.\r
- */\r
-void DeleteDpairingBinData(OicSecDpairing_t* dpair);\r
-\r
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)\r
-/**\r
- * Function to save PairingPSK.\r
- *\r
- * @param[in] endpoint   current endpoint.\r
- * @param[in] peerDevID   peer device indentitiy.\r
- * @param[in] isPairingServer   indicate if it generates PairingPSK for server or client.\r
- *\r
- * @return  OC_STACK_OK on success\r
- */\r
-OCStackResult SavePairingPSK(OCDevAddr *endpoint,\r
-            OicUuid_t *peerDevID, OicUuid_t *owner, bool isPairingServer);\r
-#endif // __WITH_DTLS__ or __WITH_TLS__\r
-\r
-/**\r
- * Gets the OicUuid_t value for the rownerid of the Dpairing resource.\r
- *\r
- * @param rowneruuid a pointer to be assigned to the rowneruuid property\r
- * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.\r
- */\r
-OCStackResult GetDpairingRownerId(OicUuid_t *rowneruuid);\r
-\r
-/**\r
- * Internal function to update resource owner\r
- *\r
- * @param newROwner new owner\r
- *\r
- * @retval ::OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult SetDpairingRownerId(const OicUuid_t* newROwner);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif //IOTVT_SRM_DPAIRING_H\r
-\r
-\r
-\r
-\r
diff --git a/resource/csdk/security/include/internal/pconfresource.h b/resource/csdk/security/include/internal/pconfresource.h
deleted file mode 100644 (file)
index 8a3ffc7..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* *****************************************************************\r
- *\r
- * Copyright 2016 Samsung Electronics All Rights Reserved.\r
- *\r
- *\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * *****************************************************************/\r
-\r
-#ifndef IOTVT_SRM_PCONF_H\r
-#define IOTVT_SRM_PCONF_H\r
-\r
-#include "octypes.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/**\r
- * Initialize PCONF resource by loading data from persistent storage.\r
- *\r
- * @retval  OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult InitPconfResource();\r
-\r
-/**\r
- * Perform cleanup for PCONF resources.\r
- *\r
- * @retval  OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult DeInitPconfResource();\r
-\r
-/**\r
- * This method is used by SRM to retrieve PCONF resource data.\r
- *\r
- * @retval  reference to @ref OicSecPconf_t, binary format of Pconf resource data\r
- */\r
-const OicSecPconf_t* GetPconfResourceData();\r
-\r
-/**\r
- * This method converts CBOR PCONF into binary PCONF.\r
- * The JSON PCONF can be from persistent database or\r
- * or received as PUT request.\r
- *\r
- * @param cborPayload  pconf data in cbor format.\r
- * @param size cbor payload size\r
- * @param secPconf converted pconf\r
- * @return OC_STACK_OK for success.\r
- *\r
- * @note Caller needs to invoke OCFree after done\r
- *       using the return pointer\r
- */\r
-OCStackResult CBORPayloadToPconf(const uint8_t *cborPayload, size_t size, OicSecPconf_t **secPconf);\r
-\r
-/**\r
- * This method converts PCONF data into CBOR format.\r
- * Caller needs to invoke 'free' when finished done using\r
- * return string\r
- *\r
- * @param pconf  Pointer to OicSecPconf_t.\r
- * @param payload pconf converted in cbor format\r
- * @param size size of the converted payload\r
- * @return OC_STACK_OK for success.\r
- *\r
- * @note Caller needs to invoke OCFree after done\r
- *       using the return pointer\r
- */\r
-OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,size_t *size);\r
-\r
-/**\r
- * This method might be used to add a paired device id after direct-pairing process complete.\r
- *\r
- * @param pdeviceId ID of the paired device.\r
- *\r
- * @retval  OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult AddPairedDevice(OicUuid_t *pdeviceId);\r
-\r
-/**\r
- * This method might be used by PolicyEngine to retrieve PDACL for a Subject.\r
- *\r
- * @param subjectId ID of the subject for which PDACL is required.\r
- * @param savePtr is used internally by @ref GetACLResourceData to maintain index between\r
- *                successive calls for same subjectId.\r
- *\r
- * @retval  reference to @ref OicSecPdAcl_t if PDACL is found, else NULL\r
- */\r
-const OicSecPdAcl_t* GetPdAclData(const OicUuid_t* subjectId, OicSecPdAcl_t **savePtr);\r
-\r
-/**\r
- * This method return whether device is paired or not.\r
- *\r
- * @param pdeviceId Target device ID to find in paired list.\r
- * @retval  ture if device is already paired, else false\r
- */\r
-bool IsPairedDevice(const OicUuid_t* pdeviceId);\r
-\r
-/** This function deallocates the memory for OicSecPconf_t .\r
- *\r
- * @param[in] pconf  Pointer to OicSecPconf_t.\r
- */\r
-void DeletePconfBinData(OicSecPconf_t* pconf);\r
-\r
-/**\r
- * This function frees OicSecPdAcl_t object's fields and object itself.\r
- */\r
-void FreePdAclList(OicSecPdAcl_t* pdacls);\r
-\r
-/**\r
- * Internal function to update resource owner\r
- *\r
- * @param newROwner new owner\r
- *\r
- * @retval ::OC_STACK_OK for Success, otherwise some error value\r
- */\r
-OCStackResult SetPconfRownerId(const OicUuid_t* newROwner);\r
-\r
-/**\r
- * Gets the OicUuid_t value for the rownerid of the pconf resource.\r
- *\r
- * @param rowneruuid a pointer to be assigned to the rowneruuid property\r
- * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.\r
- */\r
-OCStackResult GetPconfRownerId(OicUuid_t *rowneruuid);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif //IOTVT_SRM_PCONF_H\r
-\r
-\r
-\r
index d260fa4..ad30aa6 100644 (file)
@@ -91,16 +91,6 @@ extern const char * OIC_RSRC_TYPE_SEC_SVC;
 extern const char * OIC_RSRC_SVC_URI;
 extern const char * OIC_JSON_SVC_NAME;
 
-//PCONF
-extern const char * OIC_RSRC_TYPE_SEC_PCONF;
-extern const char * OIC_RSRC_PCONF_URI;
-extern const char * OIC_JSON_PCONF_NAME;
-
-//DPAIRING
-extern const char * OIC_RSRC_TYPE_SEC_DPAIRING;
-extern const char * OIC_RSRC_DPAIRING_URI;
-extern const char * OIC_JSON_DPAIRING_NAME;
-
 //version
 extern const char * OIC_RSRC_TYPE_SEC_VER;
 extern const char * OIC_RSRC_VER_URI;
index ce20483..49728b9 100644 (file)
@@ -202,30 +202,6 @@ OCStackResult SRPRegisterTrustCertChainNotifier(void *ctx, TrustCertChainChangeC
 void SRPRemoveTrustCertChainNotifier(void);
 
 #endif // __WITH_DTLS__ || __WITH_TLS__
-/**
- * API to send Direct-Pairing Configuration to a device.
- *
- * @param[in] ctx Application context to be returned in result callback.
- * @param[in] selectedDeviceInfo Selected target device.
- * @param[in] pconf PCONF pointer.
- * @param[in] resultCallback callback provided by API user, callback will be called when
- *            provisioning request recieves a response from resource server.
- * @return OC_STACK_OK in case of success and other value otherwise.
- */
-OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
-                                        OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
-
-/**
- * API to send Direct-Pairing Configuration to a device.
- *
- * @param[in] selectedDeviceInfo Selected target device.
- * @param[in] pconf PCONF pointer.
- * @param[in] resultCallback callback provided by API user, callback will be called when
- *            provisioning request recieves a response from resource server.
- * @return OC_STACK_OK in case of success and other value otherwise.
- */
-OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
-                                        OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
 
 /**
  * API to provision credential to devices.
index 23b2cb1..1853072 100644 (file)
@@ -336,19 +336,6 @@ OCStackResult OC_CALL OCGetRolesResource(void *ctx, const OCProvisionDev_t *sele
 OCStackResult OC_CALL OCDeleteRoleCertificateByCredId(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
                                               OCProvisionResultCB resultCallback, uint32_t credId);
 
-/**
- * this function sends Direct-Pairing Configuration to a device.
- *
- * @param[in] ctx Application context returned in the result callback.
- * @param[in] selectedDeviceInfo Selected target device.
- * @param[in] pconf PCONF pointer.
- * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
-              request recieves a response from resource server.
- * @return  OC_STACK_OK in case of success and other value otherwise.
- */
-OCStackResult OC_CALL OCProvisionDirectPairing(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecPconf_t *pconf,
-                             OCProvisionResultCB resultCallback);
-
 /**
  * API to provision credential to devices.
  *
@@ -605,13 +592,6 @@ void OC_CALL OCDeleteUuidList(OCUuidList_t* pList);
  */
 void OC_CALL OCDeleteACLList(OicSecAcl_t* pAcl);
 
-/**
- * This function deletes PDACL data.
- *
- * @param pPdAcl Pointer to OicSecPdAcl_t structure.
- */
-void OC_CALL OCDeletePdAclList(OicSecPdAcl_t* pPdAcl);
-
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
 /**
  * this function sends CRL information to resource.
index f027ae4..ca152de 100644 (file)
@@ -78,22 +78,6 @@ typedef struct OCProvisionDev
     struct OCProvisionDev  *next;    /**< Next pointer. **/
 }OCProvisionDev_t;
 
-/**
- * Device Information of discoverd direct pairing device(s).
- */
-typedef struct OCDirectPairingDev
-{
-    OCDevAddr               endpoint;
-    OCConnectivityType   connType;
-    uint16_t                     securePort;
-    bool              edp;
-    OicSecPrm_t  *prm;
-    size_t            prmLen;
-    OicUuid_t       deviceID;
-    OicUuid_t       rowner;
-    struct OCDirectPairingDev *next;
-} OCDirectPairingDev_t;
-
 /**
  * Result information for each target device.
  */
@@ -189,17 +173,6 @@ typedef void (*OCGetCSRResultCB)(void* ctx, size_t nOfRes, OCPMGetCsrResult_t *a
  */
 typedef void (*OCGetRolesResultCB)(void* ctx, size_t nOfRes, OCPMGetRolesResult_t *arr, bool hasError);
 
-/**
- * Callback function definition of direct-pairing
- *
- * @param[in] ctx - User context which will be returned wth callback
- * @param[in] peer - pairing device info.
- * @param[in] result - It's returned with 'OC_STACK_XXX'. It will return 'OC_STACK_OK'
- *                                   if D2D pairing is success without error
- */
-typedef void (*OCDirectPairingResultCB)(void *ctx, OCDirectPairingDev_t *peer, OCStackResult result);
-
-
 #ifdef __cplusplus
 }
 #endif
index 457bdba..f408049 100644 (file)
@@ -66,10 +66,9 @@ extern "C"
 #define _30_PROVIS_PAIR_DEVS_       30
 #define _31_PROVIS_CRED_            31
 #define _32_PROVIS_ACL_             32
-#define _33_PROVIS_DP_              33
-#define _34_CHECK_LINK_STATUS_      34
-#define _35_SAVE_ACL_               35
-#define _36_PROVIS_CERT_            36
+#define _33_CHECK_LINK_STATUS_      33
+#define _34_SAVE_ACL_               34
+#define _35_PROVIS_CERT_            35
 #define _40_UNLINK_PAIR_DEVS_       40
 #define _50_REMOVE_SELEC_DEV_       50
 #define _51_REMOVE_DEV_WITH_UUID_   51
@@ -135,7 +134,6 @@ static void setDevProtocol(OCProvisionDev_t* dev_lst);
 // function declaration(s) for calling them before implementing
 static OicSecAcl_t* createAcl(const int);
 static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid);
-static OicSecPdAcl_t* createPdAcl(const int);
 static OCProvisionDev_t* getDevInst(const OCProvisionDev_t*, const int);
 static int printDevList(const OCProvisionDev_t*);
 static size_t printUuidList(const OCUuidList_t*);
@@ -386,20 +384,6 @@ exit:
     g_doneCB = true;
 }
 
-static void provisionDPCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError)
-{
-    if(!hasError)
-    {
-        OIC_LOG_V(INFO, TAG, "Provision Direct-Pairing SUCCEEDED - ctx: %s", (char*) ctx);
-    }
-    else
-    {
-        OIC_LOG_V(ERROR, TAG, "Provision Direct-Pairing FAILED - ctx: %s", (char*) ctx);
-        printResultList((const OCProvisionResult_t*) arr, nOfRes);
-    }
-    g_doneCB = true;
-}
-
 static void unlinkDevicesCB(void* ctx, size_t nOfRes, OCProvisionResult_t* arr, bool hasError)
 {
     if(!hasError)
@@ -1281,104 +1265,6 @@ PVACL_ERROR:
     return -1;
 }
 
-static int provisionDirectPairing(void)
-{
-    // check |own_list| for provisioning direct-pairing
-    if(!g_own_list || 1>g_own_cnt)
-    {
-        printf("   > Owned Device List, to Provision ACL, is Empty\n");
-        printf("   > Please Register Unowned Devices first, with [20] Menu\n");
-        return 0;  // normal case
-    }
-
-    // select device for provisioning direct-pairing
-    int dev_num = 0;
-    for( ; ; )
-    {
-        printf("   > Enter Device Number, for Provisioning Direct-Pairing: ");
-        for(int ret=0; 1!=ret; )
-        {
-            ret = scanf("%d", &dev_num);
-            for( ; 0x20<=getchar(); );  // for removing overflow garbages
-                                        // '0x20<=code' is character region
-        }
-        if(0<dev_num && g_own_cnt>=dev_num)
-        {
-            break;
-        }
-        printf("     Entered Wrong Number. Please Enter Again\n");
-    }
-
-    // create Direct-Pairing Configuration(PIN, PDACL) for selected device
-    // TODO: default acl -> input from user !
-    OicSecPconf_t pconf;
-    memset(&pconf, 0, sizeof(OicSecPconf_t));
-
-    // set enable dp
-    pconf.edp = true;
-
-    // set default supported PRM types
-    pconf.prmLen = sizeof(SUPPORTED_PRMS)/sizeof(OicSecPrm_t);
-    pconf.prm = (OicSecPrm_t *)OICCalloc(pconf.prmLen, sizeof(OicSecPrm_t));
-    if(pconf.prm)
-    {
-        for (size_t i=0; i<pconf.prmLen; i++)
-        {
-            pconf.prm[i] = SUPPORTED_PRMS[i];
-        }
-    }
-    else
-    {
-        OIC_LOG(ERROR, TAG, "create prm error return");
-        goto PVDP_ERROR;
-    }
-
-    // set default pin
-    const char DP_DEFAULT_PIN[] = "00000000";
-    memcpy(pconf.pin.val, DP_DEFAULT_PIN, DP_PIN_LENGTH);
-
-    // set default pdacl
-    pconf.pdacls = createPdAcl(dev_num);
-    if(!pconf.pdacls)
-    {
-        OIC_LOG(ERROR, TAG, "createPdAcl error return");
-        goto PVDP_ERROR;
-    }
-
-    // call |OCProvisionDirectPairing| API
-    // calling this API with callback actually acts like blocking
-    // for error checking, the return value saved and printed
-    g_doneCB = false;
-    printf("   Atempt Direct-Pairing Provisioning (PIN : [%s])..\n", (char*)pconf.pin.val);
-    OCStackResult rst = OCProvisionDirectPairing((void*) g_ctx,
-                                       getDevInst((const OCProvisionDev_t*) g_own_list, dev_num),
-                                       &pconf, (OCProvisionResultCB)provisionDPCB);
-    if(OC_STACK_OK != rst)
-    {
-        OIC_LOG_V(ERROR, TAG, "OCProvisionDirectPairing API error: %d", rst);
-        if (OC_STACK_UNAUTHORIZED_REQ == rst)
-        {
-            OIC_LOG(ERROR, TAG, "Target Server NOT Support Direct-Pairing !!! (DPC == false)");
-        }
-        goto PVDP_ERROR;
-    }
-    if(waitCallbackRet())  // input |g_doneCB| flag implicitly
-    {
-        OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error");
-        goto PVDP_ERROR;
-    }
-    OCDeletePdAclList(pconf.pdacls);
-
-    // display the PCONF-provisioned result
-    printf("   > SUCCESS to provision Direct-Pairing !!\n");
-
-    return 0;
-
-PVDP_ERROR:
-    OCDeletePdAclList(pconf.pdacls);  // after here |acl| points nothing
-    return -1;
-}
-
 static int checkLinkedStatus(void)
 {
     // check |own_list| for checking selected link status on PRVN DB
@@ -2444,59 +2330,6 @@ static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid)
     return acl;
 }
 
-static OicSecPdAcl_t* createPdAcl(const int dev_num)
-{
-    if(0>=dev_num || g_own_cnt<dev_num)
-    {
-        OIC_LOG(ERROR, TAG, "createAcl invalid parameters");
-        return NULL;  // not need to 'goto' |ERROR| before allocating |acl|
-    }
-
-    // allocate memory for |pdacl| struct
-    printf("   **** Create PDACL for the Selected Device[%d]\n", dev_num);
-    OicSecPdAcl_t* pdAcl = (OicSecPdAcl_t*) OICCalloc(1, sizeof(OicSecPdAcl_t));
-    if(!pdAcl)
-    {
-        OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return");
-        return NULL;  // not need to 'goto' |ERROR| before allocating |acl|
-    }
-
-
-    // number of resources
-    char rsrc_in[][ACL_RESRC_MAX_LEN+1] = {"*", "/rsrc/*"};
-    pdAcl->resourcesLen = 1;
-
-    // resource
-    size_t num = pdAcl->resourcesLen;
-    pdAcl->resources = (char**) OICCalloc(num, sizeof(char*));
-    if(!pdAcl->resources)
-    {
-        OIC_LOG(ERROR, TAG, "createPdAcl: OICCalloc error return");
-        goto CRPDACL_ERROR;
-    }
-    for (size_t i = 0; num > i; ++i)
-    {
-        size_t len = strlen(rsrc_in[i]) + 1;  // '1' for null termination
-        char* rsrc = (char*) OICCalloc(len, sizeof(char));
-        if(!rsrc)
-        {
-            OIC_LOG(ERROR, TAG, "createPdAcl: OICCalloc error return");
-            goto CRPDACL_ERROR;
-        }
-        OICStrcpy(rsrc, len, rsrc_in[i]);
-        pdAcl->resources[i] = rsrc;  // after here, |rsrc| points nothing
-    }
-
-    // permission
-    pdAcl->permission = PERMISSION_FULL_CONTROL;
-
-    return pdAcl;
-
-CRPDACL_ERROR:
-    OCDeletePdAclList(pdAcl);
-    return NULL;
-}
-
 static OCProvisionDev_t* getDevInst(const OCProvisionDev_t* dev_lst, const int dev_num)
 {
     if(!dev_lst || 0>=dev_num)
@@ -2832,10 +2665,9 @@ static void printMenu(void)
     printf("** 30. Provision/Link Pairwise Things\n");
     printf("** 31. Provision Credentials for Pairwise Things\n");
     printf("** 32. Provision the Selected Access Control List(ACL)\n");
-    printf("** 33. Provision Direct-Pairing Configuration\n");
-    printf("** 34. Check Linked Status of the Selected Device on PRVN DB\n");
-    printf("** 35. Save the Selected Access Control List(ACL) into local SVR DB\n");
-    printf("** 36. Provision certificate credential\n\n");
+    printf("** 33. Check Linked Status of the Selected Device on PRVN DB\n");
+    printf("** 34. Save the Selected Access Control List(ACL) into local SVR DB\n");
+    printf("** 35. Provision certificate credential\n\n");
 
 
     printf("** [D] UNLINK PAIRWISE THINGS\n");
@@ -2990,25 +2822,19 @@ int main()
                 OIC_LOG(ERROR, TAG, "_32_PROVIS_ACL_: error");
             }
             break;
-        case _33_PROVIS_DP_:
-            if(provisionDirectPairing())
-            {
-                OIC_LOG(ERROR, TAG, "_33_PROVIS_DP_: error");
-            }
-            break;
-        case _34_CHECK_LINK_STATUS_:
+        case _33_CHECK_LINK_STATUS_:
             if(checkLinkedStatus())
             {
                 OIC_LOG(ERROR, TAG, "_34_CHECK_LINK_STATUS_: error");
             }
             break;
-        case _35_SAVE_ACL_:
+        case _34_SAVE_ACL_:
             if(saveAcl())
             {
                 OIC_LOG(ERROR, TAG, "_35_SAVE_ACL_: error");
             }
             break;
-        case _36_PROVIS_CERT_:
+        case _35_PROVIS_CERT_:
             if (provisionCert())
             {
                 OIC_LOG(ERROR, TAG, "_36_PROVIS_CERT_: error");
index cf71ad4..384a700 100644 (file)
@@ -34,7 +34,6 @@
 #include "credresource.h"
 #include "utlist.h"
 #include "aclresource.h" //Note: SRM internal header
-#include "pconfresource.h"
 #include "psinterface.h"
 
 #define TAG "OIC_OCPMAPI"
@@ -551,22 +550,6 @@ OCStackResult OC_CALL OCProvisionCertificate(void *ctx,
 }
 #endif
 
-/**
- * this function sends Direct-Pairing Configuration to a device.
- *
- * @param[in] ctx Application context would be returned in result callback.
- * @param[in] selectedDeviceInfo Selected target device.
- * @param[in] pconf PCONF pointer.
- * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
-              request recieves a response from resource server.
- * @return  OC_STACK_OK in case of success and other value otherwise.
- */
-OCStackResult OC_CALL OCProvisionDirectPairing(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecPconf_t *pconf,
-                             OCProvisionResultCB resultCallback)
-{
-    return SRPProvisionDirectPairing(ctx, selectedDeviceInfo, pconf, resultCallback);
-}
-
 #ifdef MULTIPLE_OWNER
 static void AddPreconfPinOxMCB(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
 {
@@ -1455,16 +1438,6 @@ void OC_CALL OCDeleteACLList(OicSecAcl_t* pAcl)
     DeleteACLList(pAcl);
 }
 
-/**
- * This function deletes PDACL data.
- *
- * @param pPdAcl Pointer to OicSecPdAcl_t structure.
- */
-void OC_CALL OCDeletePdAclList(OicSecPdAcl_t* pPdAcl)
-{
-    FreePdAclList(pPdAcl);
-}
-
 #ifdef MULTIPLE_OWNER
 /**
  * API to update 'doxm.mom' to resource server.
index 8cac6ae..1b8e6b5 100644 (file)
@@ -37,7 +37,6 @@
 #include "csrresource.h"
 #include "rolesresource.h"
 #include "doxmresource.h"
-#include "pconfresource.h"
 #include "credentialgenerator.h"
 #include "cainterface.h"
 #include "oic_string.h"
@@ -149,19 +148,6 @@ struct GetRolesData {
     size_t numOfResults;                        /**< Number of results in result array.**/
 };
 
-/**
- * Structure to carry PCONF provision API data to callback.
- */
-typedef struct PconfData PconfData_t;
-struct PconfData
-{
-    void *ctx;                                  /**< Pointer to user context.**/
-    const OCProvisionDev_t *deviceInfo;         /**< Pointer to PMDevInfo_t.**/
-    OCProvisionResultCB resultCallback;         /**< Pointer to result callback.**/
-    OCProvisionResult_t *resArr;                /**< Result array.**/
-    int numOfResults;                           /**< Number of results in result array.**/
-};
-
 // Enum type index for unlink callback.
 typedef enum {
     IDX_FIRST_DEVICE_RES = 0, // index for resulf of the first device
@@ -1878,153 +1864,6 @@ OCStackResult SRPSaveACL(const OicSecAcl_t *acl)
     return res;
 }
 
-/**
- * Internal Function to store results in result array during Direct-Pairing provisioning.
- */
-static void registerResultForDirectPairingProvisioning(PconfData_t *pconfData,
-                                             OCStackResult stackresult)
-{
-   OIC_LOG_V(INFO, TAG, "Inside registerResultForDirectPairingProvisioning "
-           "pconfData->numOfResults is %d", pconfData->numOfResults);
-   memcpy(pconfData->resArr[(pconfData->numOfResults)].deviceId.id,
-          pconfData->deviceInfo->doxm->deviceID.id, UUID_LENGTH);
-   pconfData->resArr[(pconfData->numOfResults)].res = stackresult;
-   ++(pconfData->numOfResults);
-}
-
-/**
- * Callback handler of SRPProvisionDirectPairing.
- *
- * @param[in] ctx             ctx value passed to callback from calling function.
- * @param[in] UNUSED          handle to an invocation
- * @param[in] clientResponse  Response from queries to remote servers.
- * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
- *          and  OC_STACK_KEEP_TRANSACTION to keep it.
- */
-static OCStackApplicationResult SRPProvisionDirectPairingCB(void *ctx, OCDoHandle UNUSED,
-                                                  OCClientResponse *clientResponse)
-{
-    OIC_LOG_V(INFO, TAG, "Inside SRPProvisionDirectPairingCB.");
-    (void)UNUSED;
-    VERIFY_NOT_NULL_RETURN(TAG, ctx, ERROR, OC_STACK_DELETE_TRANSACTION);
-    PconfData_t *pconfData = (PconfData_t*)ctx;
-    OCProvisionResultCB resultCallback = pconfData->resultCallback;
-
-    if (clientResponse)
-    {
-        if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
-        {
-            registerResultForDirectPairingProvisioning(pconfData, OC_STACK_OK);
-            ((OCProvisionResultCB)(resultCallback))(pconfData->ctx, pconfData->numOfResults,
-                                                    pconfData->resArr,
-                                                    false);
-             OICFree(pconfData->resArr);
-             OICFree(pconfData);
-             return OC_STACK_DELETE_TRANSACTION;
-        }
-    }
-    registerResultForDirectPairingProvisioning(pconfData, OC_STACK_ERROR);
-    ((OCProvisionResultCB)(resultCallback))(pconfData->ctx, pconfData->numOfResults,
-                                            pconfData->resArr,
-                                            true);
-    OIC_LOG_V(ERROR, TAG, "SRPProvisionDirectPairingCB received Null clientResponse");
-    OICFree(pconfData->resArr);
-    OICFree(pconfData);
-    return OC_STACK_DELETE_TRANSACTION;
-}
-
-OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
-        OicSecPconf_t *pconf, OCProvisionResultCB resultCallback)
-{
-    VERIFY_NOT_NULL_RETURN(TAG, selectedDeviceInfo, ERROR,  OC_STACK_INVALID_PARAM);
-    VERIFY_NOT_NULL_RETURN(TAG, pconf, ERROR,  OC_STACK_INVALID_PARAM);
-    VERIFY_NOT_NULL_RETURN(TAG, resultCallback, ERROR,  OC_STACK_INVALID_CALLBACK);
-
-    // check direct-pairing capability
-    if (true != selectedDeviceInfo->doxm->dpc)
-    {
-        OIC_LOG(ERROR, TAG, "Resouce server does not have Direct-Pairing Capability ");
-        return OC_STACK_UNAUTHORIZED_REQ;
-    }
-
-    OicUuid_t provTooldeviceID =   {.id={0}};
-    if (OC_STACK_OK != GetDoxmDeviceID(&provTooldeviceID))
-    {
-        OIC_LOG(ERROR, TAG, "Error while retrieving provisioning tool's device ID");
-        return OC_STACK_ERROR;
-    }
-    memcpy(&pconf->rownerID, &provTooldeviceID, sizeof(OicUuid_t));
-
-    OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
-    if(!secPayload)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to allocate memory");
-        return OC_STACK_NO_MEMORY;
-    }
-    secPayload->base.type = PAYLOAD_TYPE_SECURITY;
-
-    if (OC_STACK_OK != PconfToCBORPayload(pconf, &(secPayload->securityData),
-                &(secPayload->payloadSize)))
-    {
-        OCPayloadDestroy((OCPayload*)secPayload);
-        OIC_LOG(ERROR, TAG, "Failed to PconfToCborPayload");
-        return OC_STACK_NO_MEMORY;
-    }
-    OIC_LOG(DEBUG, TAG, "Created payload for pconf set");
-    OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
-
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
-    if(!PMGenerateQuery(true,
-                selectedDeviceInfo->endpoint.addr,
-                selectedDeviceInfo->securePort,
-                selectedDeviceInfo->connType,
-                query, sizeof(query), OIC_RSRC_PCONF_URI))
-    {
-        OIC_LOG(ERROR, TAG, "SRPProvisionDirectPairing : Failed to generate query");
-        return OC_STACK_ERROR;
-    }
-    OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
-    OCCallbackData cbData =  {.context=NULL, .cb=NULL, .cd=NULL};
-    cbData.cb = &SRPProvisionDirectPairingCB;
-    PconfData_t *pconfData = (PconfData_t *) OICCalloc(1, sizeof(PconfData_t));
-    if (NULL == pconfData)
-    {
-        OCPayloadDestroy((OCPayload*)secPayload);
-        OIC_LOG(ERROR, TAG, "Unable to allocate memory");
-        return OC_STACK_NO_MEMORY;
-    }
-    pconfData->deviceInfo = selectedDeviceInfo;
-    pconfData->resultCallback = resultCallback;
-    pconfData->numOfResults=0;
-    pconfData->ctx = ctx;
-    // call to provision PCONF to device1.
-    int noOfRiCalls = 1;
-    pconfData->resArr = (OCProvisionResult_t*)OICCalloc(noOfRiCalls, sizeof(OCProvisionResult_t));
-    if (NULL == pconfData->resArr)
-    {
-        OICFree(pconfData);
-        OCPayloadDestroy((OCPayload*)secPayload);
-        OIC_LOG(ERROR, TAG, "Unable to allocate memory");
-        return OC_STACK_NO_MEMORY;
-    }
-    cbData.context = (void *)pconfData;
-    cbData.cd = NULL;
-    OCMethod method = OC_REST_POST;
-    OCDoHandle handle = NULL;
-    OIC_LOG(DEBUG, TAG, "Sending PCONF info to resource server");
-    OCStackResult ret = OCDoResource(&handle, method, query,
-            &selectedDeviceInfo->endpoint, (OCPayload*)secPayload,
-            selectedDeviceInfo->connType, OC_HIGH_QOS, &cbData, NULL, 0);
-    if (OC_STACK_OK != ret)
-    {
-        OICFree(pconfData->resArr);
-        OICFree(pconfData);
-    }
-    VERIFY_SUCCESS_RETURN(TAG, (OC_STACK_OK == ret), ERROR, OC_STACK_ERROR);
-    return OC_STACK_OK;
-}
-
 static void DeleteUnlinkData_t(UnlinkData_t *unlinkData)
 {
     if (unlinkData)
index 44336b8..0c07753 100644 (file)
@@ -213,12 +213,6 @@ TEST(OCDeleteACLListTest, NullACLList)
     EXPECT_EQ(1, 1);
 }
 
-TEST(OCDeletePdAclListTest, NullPdACLList)
-{
-    OCDeletePdAclList(NULL);
-    EXPECT_EQ(1, 1);
-}
-
 TEST(OCDeleteDiscoveredDevicesTest, NullProvisionDevList)
 {
     OCDeleteDiscoveredDevices(NULL);
index 234a9a1..b9aa6c4 100644 (file)
@@ -25,7 +25,6 @@ static OCProvisionDev_t pDev1;
 static OCProvisionDev_t pDev2;
 static OicSecCredType_t credType = SYMMETRIC_PAIR_WISE_KEY;
 static OCProvisionDev_t selectedDeviceInfo;
-static OicSecPconf_t pconf;
 static OicSecOxm_t oicSecDoxmJustWorks = OIC_JUST_WORKS;
 static OicSecOxm_t oicSecDoxmRandomPin = OIC_RANDOM_DEVICE_PIN;
 static unsigned short timeout = 60;
@@ -162,21 +161,6 @@ TEST(SRPRemoveDeviceTest, ZeroWaitTime)
     EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPRemoveDevice(NULL, 0, &dev1, NULL));
 }
 
-TEST(SRPProvisionDirectPairingTest, NullselectedDeviceInfo)
-{
-    EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionDirectPairing(NULL, NULL, &pconf, &provisioningCB));
-}
-
-TEST(SRPProvisionDirectPairingTest, Nullpconf)
-{
-    EXPECT_EQ(OC_STACK_INVALID_PARAM, SRPProvisionDirectPairing(NULL, &selectedDeviceInfo, NULL, &provisioningCB));
-}
-
-TEST(SRPProvisionDirectPairingTest, Nullcallback)
-{
-    EXPECT_EQ(OC_STACK_INVALID_CALLBACK, SRPProvisionDirectPairing(NULL, &selectedDeviceInfo, &pconf, NULL));
-}
-
 const char *SECURE_RESOURCE_PROVIDER_TEST_FILE_NAME = "secureresourceprovider.dat";
 OCPersistentStorage ps = { NULL, NULL, NULL, NULL, NULL};
 
diff --git a/resource/csdk/security/src/directpairing.c b/resource/csdk/security/src/directpairing.c
deleted file mode 100644 (file)
index 0cc97a4..0000000
+++ /dev/null
@@ -1,1059 +0,0 @@
-/* *****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * *****************************************************************/
-#ifndef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200112L
-#endif
-#include "iotivity_config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include "ocstack.h"
-#include "oic_malloc.h"
-#include "oic_string.h"
-#include "logger.h"
-#include "utlist.h"
-#include "ocpayload.h"
-#include "payload_logging.h"
-#include "cainterface.h"
-#include "directpairing.h"
-#include "srmresourcestrings.h" //@note: SRM's internal header
-#include "doxmresource.h"       //@note: SRM's internal header
-#include "pconfresource.h"       //@note: SRM's internal header
-#include "dpairingresource.h"       //@note: SRM's internal header
-#include "credresource.h"
-#include "pmtypes.h"
-#include "pmutility.h"
-#include "srmutility.h"
-#include "ocstackinternal.h"
-#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
-#include <mbedtls/ssl_ciphersuites.h>
-#endif
-
-#define TAG ("OIC_DP")
-static const uint16_t CBOR_SIZE = 1024;
-
-/**
- * Structure to carry direct-pairing API data to callback.
- */
-typedef struct DPairData
-{
-    OCDirectPairingDev_t        *peer;                         /**< Pointer to pairing target info.**/
-    char                                  pin[DP_PIN_LENGTH];  /**< PIN **/
-    OCDirectPairingResultCB    resultCallback;           /**< Pointer to result callback.**/
-    void *userCtx;                                      /** < user context to pass in callback **/
-} DPairData_t;
-
-static OCDirectPairingDev_t *g_dp_paired = NULL;
-static OCDirectPairingDev_t *g_dp_discover = NULL;
-static DPairData_t *g_dp_proceed_ctx = NULL;
-
-
-/**
- * Function to search node in linked list that matches given IP and port.
- *
- * @param[in] pList         List of OCProvisionDev_t.
- * @param[in] addr          address of target device.
- * @param[in] port          port of remote server.
- *
- * @return pointer of OCProvisionDev_t if exist, otherwise NULL
- */
-OCDirectPairingDev_t* getDev(OCDirectPairingDev_t **ppList, const char* addr, const uint16_t port)
-{
-    if(NULL == addr)
-    {
-        OIC_LOG_V(ERROR, TAG, "Invalid Input parameters in [%s]\n", __FUNCTION__);
-        return NULL;
-    }
-
-    OCDirectPairingDev_t *ptr = NULL;
-    LL_FOREACH(*ppList, ptr)
-    {
-        if( strcmp(ptr->endpoint.addr, addr) == 0 && port == ptr->endpoint.port)
-        {
-            return ptr;
-        }
-    }
-
-    return NULL;
-}
-
-
-
-/**
- * Add device information to list.
- *
- * @param[in] pList         List of OCProvisionDev_t.
- * @param[in] addr          address of target device.
- * @param[in] port          port of remote server.
- * @param[in] adapter       adapter type of endpoint.
- * @param[in] doxm          pointer to doxm instance.
- * @param[in] connType  connectivity type of endpoint
- *
- * @return OC_STACK_OK for success and errorcode otherwise.
- */
-OCStackResult addDev(OCDirectPairingDev_t **ppList, OCDevAddr *endpoint,
-                                      OCConnectivityType conn, OicSecPconf_t *pconf)
-{
-    if(NULL == endpoint || NULL == pconf)
-    {
-        OIC_LOG_V(ERROR, TAG, "Invalid Input parameters in [%s]\n", __FUNCTION__);
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OCDirectPairingDev_t *ptr = getDev(ppList, endpoint->addr, endpoint->port);
-    if(!ptr)
-    {
-        ptr = (OCDirectPairingDev_t *)OICCalloc(1, sizeof (OCDirectPairingDev_t));
-        if (NULL == ptr)
-        {
-            OIC_LOG(ERROR, TAG, "Error while allocating memory for linkedlist node !!");
-            return OC_STACK_NO_MEMORY;
-        }
-
-        memcpy(&ptr->endpoint, endpoint, sizeof(OCDevAddr));
-        ptr->connType = conn;
-        ptr->securePort = DEFAULT_SECURE_PORT;
-        ptr->edp = pconf->edp;
-        ptr->prm = pconf->prm;
-        pconf->prm = NULL;  // to prevent free
-        ptr->prmLen = pconf->prmLen;
-        memcpy(&ptr->deviceID, &pconf->deviceID, sizeof(OicUuid_t));
-        memcpy(&ptr->rowner, &pconf->rownerID, sizeof(OicUuid_t));
-        ptr->next = NULL;
-
-        LL_PREPEND(*ppList, ptr);
-        OIC_LOG(INFO, TAG, "device added !");
-    }
-
-    return OC_STACK_OK;
-}
-
-
-/**
- * Add device information to list.
- *
- * @param[in] ppList         List of OCProvisionDev_t.
- * @param[in] pDev          target device.
- *
- * @return OC_STACK_OK for success and errorcode otherwise.
- */
-OCStackResult addDev2(OCDirectPairingDev_t **ppList, OCDirectPairingDev_t *pDev)
-{
-    if(NULL == pDev)
-    {
-        OIC_LOG_V(ERROR, TAG, "Invalid Input parameters in [%s]\n", __FUNCTION__);
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OCDirectPairingDev_t *ptr = getDev(ppList, pDev->endpoint.addr, pDev->endpoint.port);
-    if(!ptr)
-    {
-        ptr = (OCDirectPairingDev_t *)OICCalloc(1, sizeof (OCDirectPairingDev_t));
-        if (NULL == ptr)
-        {
-            OIC_LOG(ERROR, TAG, "Error while allocating memory for linkedlist node !!");
-            return OC_STACK_NO_MEMORY;
-        }
-
-        memcpy(&ptr->endpoint, &pDev->endpoint, sizeof(OCDevAddr));
-        ptr->connType = pDev->connType;
-        ptr->securePort = pDev->securePort;
-        ptr->edp = pDev->edp;
-        ptr->prmLen = pDev->prmLen;
-        ptr->prm = (OicSecPrm_t*)OICCalloc(ptr->prmLen, sizeof (OicSecPrm_t));
-        if (NULL == ptr->prm)
-        {
-            OIC_LOG(ERROR, TAG, "Error while allocating memory for prm !!");
-            return OC_STACK_NO_MEMORY;
-        }
-        memcpy(ptr->prm, pDev->prm, sizeof(OicSecPrm_t)*ptr->prmLen);
-        memcpy(&ptr->deviceID, &pDev->deviceID, sizeof(OicUuid_t));
-        memcpy(&ptr->rowner, &pDev->rowner, sizeof(OicUuid_t));
-        ptr->next = NULL;
-
-        LL_PREPEND(*ppList, ptr);
-        OIC_LOG(INFO, TAG, "device added !");
-    }
-
-    return OC_STACK_OK;
-}
-
-
-
-/**
- * This function deletes list of provision target devices
- *
- * @param[in] pDevicesList         List of OCProvisionDev_t.
- */
-void delList(OCDirectPairingDev_t *pList)
-{
-    if(pList)
-    {
-        OCDirectPairingDev_t *del = NULL, *tmp = NULL;
-        LL_FOREACH_SAFE(pList, del, tmp)
-        {
-            LL_DELETE(pList, del);
-            if (del && del->prm)
-            {
-                OICFree(del->prm);
-            }
-        }
-    }
-}
-
-bool DPGenerateQuery(bool isSecure,
-                     const char* address, const uint16_t port,
-                     const OCConnectivityType connType,
-                     char* buffer, size_t bufferSize, const char* uri)
-{
-    if(!address || !buffer || !uri)
-    {
-        OIC_LOG(ERROR, TAG, "DPGenerateQuery : Invalid parameters.");
-        return false;
-    }
-
-    static char QPREFIX_COAP[] =  "coap://";
-    static char QPREFIX_COAPS[] = "coaps://";
-    static char QPREFIX_COAP_TCP[] =  "coap+tcp://";
-    static char QPREFIX_COAPS_TCP[] = "coaps+tcp://";
-
-    int snRet = 0;
-    char* prefix = (isSecure == true) ? QPREFIX_COAPS : QPREFIX_COAP;
-
-    switch(connType & CT_MASK_ADAPTER)
-    {
-// @todo: Remove this ifdef. On Arduino, CT_ADAPTER_TCP resolves to the same value
-// as CT_ADAPTER_IP, resulting in a compiler error.
-#ifdef WITH_TCP
-#ifndef WITH_ARDUINO
-        case CT_ADAPTER_TCP:
-            prefix = (isSecure == true) ? QPREFIX_COAPS_TCP : QPREFIX_COAP_TCP;
-            // intentional fall through don't add break
-#endif
-#endif
-        case CT_ADAPTER_IP:
-            switch(connType & CT_MASK_FLAGS & ~CT_FLAG_SECURE)
-            {
-                case CT_IP_USE_V4:
-                    snRet = snprintf(buffer, bufferSize, "%s%s:%d%s",
-                                     prefix, address, port, uri);
-                    break;
-                case CT_IP_USE_V6:
-                {
-                    char addressEncoded[CA_MAX_URI_LENGTH] = {0};
-
-                    OCStackResult result = OCEncodeAddressForRFC6874(addressEncoded,
-                                                                     sizeof(addressEncoded),
-                                                                     address);
-                    if (OC_STACK_OK != result)
-                    {
-                        OIC_LOG_V(ERROR, TAG, "DPGenerateQuery : encoding error %d\n", result);
-                        return false;
-                    }
-
-                    snRet = snprintf(buffer, bufferSize, "%s[%s]:%d%s",
-                                     prefix, addressEncoded, port, uri);
-                    break;
-                }
-                default:
-                    OIC_LOG(ERROR, TAG, "Unknown address format.");
-                    return false;
-            }
-            // snprintf return value check
-            if (snRet < 0)
-            {
-                OIC_LOG_V(ERROR, TAG, "DPGenerateQuery : Error (snprintf) %d\n", snRet);
-                return false;
-            }
-            else if ((size_t)snRet >= bufferSize)
-            {
-                OIC_LOG_V(ERROR, TAG, "DPGenerateQuery : Truncated (snprintf) %d\n", snRet);
-                return false;
-            }
-
-            break;
-#ifndef WITH_ARDUINO
-        // TODO: We need to verify tinyDTLS in below cases
-        case CT_ADAPTER_GATT_BTLE:
-        case CT_ADAPTER_RFCOMM_BTEDR:
-            OIC_LOG(ERROR, TAG, "Not supported connectivity adapter.");
-            return false;
-#endif
-        default:
-            OIC_LOG(ERROR, TAG, "Unknown connectivity adapter.");
-            return false;
-    }
-
-    return true;
-}
-
-const OCDirectPairingDev_t* DPGetDiscoveredDevices()
-{
-    return g_dp_discover;
-}
-
-const OCDirectPairingDev_t* DPGetPairedDevices()
-{
-    return g_dp_paired;
-}
-
-void DPDeleteLists()
-{
-    delList(g_dp_discover);
-    delList(g_dp_paired);
-}
-
-/**
- * Callback handler of FinalizeDirectPairing.
- *
- * @param[in] ctx             ctx value passed to callback from calling function.
- * @param[in] UNUSED          handle to an invocation
- * @param[in] clientResponse  Response from queries to remote servers.
- * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
- *          and  OC_STACK_KEEP_TRANSACTION to keep it.
- */
-static OCStackApplicationResult DirectPairingFinalizeHandler(void *ctx, OCDoHandle UNUSED,
-                                                  OCClientResponse *clientResponse)
-{
-    OIC_LOG(INFO, TAG, "IN DirectPairingFinalizeHandler()");
-    (void)UNUSED;
-    if(NULL == ctx)
-    {
-        OIC_LOG(ERROR, TAG, "Context is Null");
-        return OC_STACK_DELETE_TRANSACTION;
-    }
-
-    OCStackResult res;
-    DPairData_t *dpairData = (DPairData_t*)ctx;
-    OCDirectPairingDev_t *peer = dpairData->peer;
-    OCDirectPairingResultCB resultCallback = dpairData->resultCallback;
-
-    if (clientResponse)
-    {
-        if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
-        {
-            // result
-            OIC_LOG(INFO, TAG, "DirectPairingFinalizeHandler : success PUT"
-                    " request to /oic/sec/dpairing");
-
-            CAEndpoint_t endpoint;
-            memset(&endpoint, 0x00, sizeof(CAEndpoint_t));
-            OICStrcpy(endpoint.addr, MAX_ADDR_STR_SIZE_CA, peer->endpoint.addr);
-            endpoint.addr[MAX_ADDR_STR_SIZE_CA - 1] = '\0';
-            endpoint.port = peer->securePort;
-
-            OicUuid_t ptDeviceID = {.id={0}};
-            if (OC_STACK_OK != GetDoxmDeviceID(&ptDeviceID))
-            {
-                OIC_LOG(ERROR, TAG, "Error while retrieving provisioning tool's device ID");
-                resultCallback(dpairData->userCtx, peer, OC_STACK_ERROR);
-                return OC_STACK_DELETE_TRANSACTION;
-            }
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-            res = SavePairingPSK((OCDevAddr*)&endpoint, &peer->deviceID, &ptDeviceID, false);
-            if(OC_STACK_OK != res)
-            {
-                OIC_LOG(ERROR, TAG, "Failed to PairingPSK generation");
-                resultCallback(dpairData->userCtx, peer, res);
-                return OC_STACK_DELETE_TRANSACTION;
-            }
-
-            //  close temporary sesion
-            CAResult_t caResult = CAcloseSslSession((const CAEndpoint_t*)&endpoint);
-            if(CA_STATUS_OK != caResult)
-            {
-                OIC_LOG(INFO, TAG, "Fail to close temporary dtls session");
-            }
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-            OIC_LOG(INFO, TAG, "Direct-Papring was successfully completed.");
-
-            // update paired list
-            OCDirectPairingDev_t *dev = getDev(&g_dp_discover, peer->endpoint.addr,
-                    peer->endpoint.port);
-            res = addDev2(&g_dp_paired, dev);
-            if (OC_STACK_OK != res)
-            {
-                OIC_LOG(ERROR, TAG, "Error while adding a device to paired list.");
-            }
-
-            resultCallback(dpairData->userCtx, peer, OC_STACK_OK);
-
-            return OC_STACK_DELETE_TRANSACTION;
-        }
-        else
-        {
-            OIC_LOG(INFO, TAG, "Direct-Papring received error response.");
-        }
-    }
-    else
-    {
-        OIC_LOG(ERROR, TAG, "DirectPairingFinalizeHandler received Null clientResponse");
-    }
-
-    resultCallback(dpairData->userCtx, peer, OC_STACK_ERROR);
-    OICFree(dpairData);
-    return OC_STACK_DELETE_TRANSACTION;
-}
-
-/**
- * Finalize direct-pairing .
- *
- * @param[in] peer  target device to establish direct-pairing.
- * @param[in] resultCallback  result event callback.
- *
- * @return OC_STACK_OK on success otherwise error.
- */
-OCStackResult FinalizeDirectPairing(void *ctx, OCDirectPairingDev_t* peer,
-                                                     OCDirectPairingResultCB resultCallback)
-{
-    if(NULL == peer)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OicUuid_t deviceID =   {.id={0}};
-    if (OC_STACK_OK != GetDoxmDeviceID(&deviceID))
-    {
-        OIC_LOG(ERROR, TAG, "Error while retrieving device ID");
-        return OC_STACK_ERROR;
-    }
-
-    OicSecDpairing_t dpair;
-    memset(&dpair, 0, sizeof(OicSecDpairing_t));
-    dpair.spm = (OicSecPrm_t)PRM_NOT_ALLOWED;
-    memcpy(&dpair.pdeviceID, &deviceID, sizeof(OicUuid_t));
-
-    OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
-    if(!secPayload)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to memory allocation");
-        return OC_STACK_NO_MEMORY;
-    }
-    secPayload->base.type = PAYLOAD_TYPE_SECURITY;
-
-    OCStackResult ret = DpairingToCBORPayload(&dpair, &(secPayload->securityData),
-            &(secPayload->payloadSize));
-
-    if(OC_STACK_OK != ret)
-    {
-        OICFree(secPayload);
-        OIC_LOG(ERROR, TAG, "Failed to DpairingToCBORPayload");
-        return OC_STACK_NO_MEMORY;
-    }
-    OIC_LOG(DEBUG, TAG, "DPARING CBOR data:");
-    OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
-
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
-    if(!DPGenerateQuery(true,
-                        peer->endpoint.addr,
-                        peer->securePort,
-                        peer->connType,
-                        query, sizeof(query), OIC_RSRC_DPAIRING_URI))
-    {
-        OIC_LOG(ERROR, TAG, "DPDirectPairing : Failed to generate query");
-        return OC_STACK_ERROR;
-    }
-    OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
-    DPairData_t *dpairData = (DPairData_t *) OICCalloc(1, sizeof(DPairData_t));
-    if (dpairData == NULL)
-    {
-        OICFree(secPayload->securityData);
-        OICFree(secPayload);
-        OIC_LOG(ERROR, TAG, "Unable to allocate memory");
-        return OC_STACK_NO_MEMORY;
-    }
-    dpairData->peer = peer;
-    dpairData->resultCallback = resultCallback;
-    dpairData->userCtx = ctx;
-
-    OCCallbackData cbData;
-    memset(&cbData, 0, sizeof(cbData));
-    cbData.cb = DirectPairingFinalizeHandler;
-    cbData.context = (void*)dpairData;
-    cbData.cd = NULL;
-
-    OCMethod method = OC_REST_PUT;
-    OCDoHandle handle = NULL;
-    OIC_LOG(DEBUG, TAG, "Sending DPAIRNG setting to resource server");
-    ret = OCDoResource(&handle, method, query,
-            &peer->endpoint, (OCPayload*)secPayload,
-            peer->connType, OC_LOW_QOS, &cbData, NULL, 0);
-    if(OC_STACK_OK != ret)
-    {
-        OIC_LOG(ERROR, TAG, "error in OCDoResource");
-        return OC_STACK_ERROR;
-    }
-
-    return OC_STACK_OK;
- }
-
-/**
- * Function to handle the handshake result in Direct-Pairing.
- * This function will be invoked after DTLS handshake
- * @param   endPoint  [IN] The remote endpoint.
- * @param   errorInfo [IN] Error information from the endpoint.
- * @return  NONE
- */
-CAResult_t DirectPairingDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
-{
-    OIC_LOG(INFO, TAG, "IN DirectPairingDTLSHandshakeCB");
-    CAResult_t result = CA_STATUS_OK;
-
-    if(g_dp_proceed_ctx && g_dp_proceed_ctx->peer && endpoint && info)
-    {
-        OIC_LOG_V(INFO, TAG, "Received status from remote device(%s:%d) : %d",
-                 endpoint->addr, endpoint->port, info->result);
-
-        OCDirectPairingDev_t *peer = g_dp_proceed_ctx->peer;
-        OCDirectPairingResultCB resultCallback = g_dp_proceed_ctx->resultCallback;
-        OCStackResult res;
-
-        //Make sure the address matches.
-        if(strncmp(peer->endpoint.addr, endpoint->addr, sizeof(endpoint->addr)) == 0 &&
-                         peer->securePort == endpoint->port)
-        {
-            //In case of success, send next coaps request.
-            if(CA_STATUS_OK == info->result)
-            {
-                OIC_LOG(INFO, TAG, "Now, finalize Direct-Pairing procedure.");
-
-                res = FinalizeDirectPairing(g_dp_proceed_ctx->userCtx, peer, resultCallback);
-                if(OC_STACK_OK != res)
-                {
-                    OIC_LOG(ERROR, TAG, "Failed to finalize direct-pairing");
-                    result = CA_HANDLE_ERROR_OTHER_MODULE;
-                }
-            }
-            else if(CA_DTLS_AUTHENTICATION_FAILURE == info->result)
-            {
-                OIC_LOG(INFO, TAG, "DirectPairingDTLSHandshakeCB - Authentication failed");
-                result = CA_HANDLE_ERROR_OTHER_MODULE;
-            }
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-            CAregisterSslHandshakeCallback(NULL);
-#endif // __WITH_DTLS__ or __WITH_TLS__
-            res = RemoveCredential(&peer->deviceID);
-            if(OC_STACK_RESOURCE_DELETED != res)
-            {
-                OIC_LOG_V(ERROR, TAG, "Failed to remove temporal PSK : %d", res);
-            }
-
-            OICFree(g_dp_proceed_ctx);
-            g_dp_proceed_ctx = NULL;
-        }
-        else
-        {
-            OIC_LOG(INFO, TAG, "DirectPairingDTLSHandshakeCB - Not matched to peer address");
-        }
-    }
-
-    OIC_LOG(INFO, TAG, "OUT DirectPairingDTLSHandshakeCB");
-    return result;
-}
-
-/**
- * Callback handler of DPDirectPairing.
- *
- * @param[in] ctx             ctx value passed to callback from calling function.
- * @param[in] UNUSED          handle to an invocation
- * @param[in] clientResponse  Response from queries to remote servers.
- * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
- *          and  OC_STACK_KEEP_TRANSACTION to keep it.
- */
-static OCStackApplicationResult DirectPairingHandler(void *ctx, OCDoHandle UNUSED,
-                                                  OCClientResponse *clientResponse)
-{
-    OIC_LOG(INFO, TAG, "IN DirectPairingHandler.");
-    (void)UNUSED;
-    if(NULL == ctx)
-    {
-        OIC_LOG(ERROR, TAG, "Context is Null");
-        return OC_STACK_DELETE_TRANSACTION;
-    }
-
-    OCStackResult res = OC_STACK_ERROR;
-    DPairData_t *dpairData = (DPairData_t*)ctx;
-    OCDirectPairingResultCB resultCallback = (OCDirectPairingResultCB)dpairData->resultCallback;
-    OicUuid_t subjectId = {.id={0}};
-
-    if (clientResponse)
-    {
-        if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
-        {
-            // result
-            OIC_LOG(INFO, TAG, "DirectPairingHandler : success POST request to /oic/sec/dpairing");
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-            // Add temporary psk
-            res = AddTmpPskWithPIN(&dpairData->peer->deviceID,
-                           SYMMETRIC_PAIR_WISE_KEY,
-                           (char*)dpairData->pin, DP_PIN_LENGTH,
-                           &dpairData->peer->rowner, &subjectId);
-            VERIFY_SUCCESS(TAG, OC_STACK_OK == res, ERROR);
-
-
-            // Start to establish a secure channel with Pin-based PSK cipher suite
-            CAResult_t caresult;
-
-            caresult = CAEnableAnonECDHCipherSuite(false);
-            VERIFY_SUCCESS(TAG, CA_STATUS_OK == caresult, ERROR);
-
-            caresult = CASelectCipherSuite(MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, CA_ADAPTER_IP);
-            VERIFY_SUCCESS(TAG, CA_STATUS_OK == caresult, ERROR);
-
-            //Register proceeding peer info. & DTLS event handler to catch the dtls event while handshake
-            g_dp_proceed_ctx = dpairData;
-            res = CAregisterSslHandshakeCallback(DirectPairingDTLSHandshakeCB);
-            VERIFY_SUCCESS(TAG, CA_STATUS_OK == caresult, ERROR);
-
-            // initiate dtls
-            CAEndpoint_t endpoint;
-            CopyDevAddrToEndpoint(&dpairData->peer->endpoint, &endpoint);
-            endpoint.port = dpairData->peer->securePort;
-            OIC_LOG_V(INFO, TAG, "Initiate DTLS handshake to %s(%d)", endpoint.addr,
-                    endpoint.port);
-            caresult = CAInitiateHandshake(&endpoint);
-            VERIFY_SUCCESS(TAG, CA_STATUS_OK == caresult, ERROR);
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-            res = OC_STACK_OK;
-        }
-        else
-        {
-            // result
-            OIC_LOG(INFO, TAG, "DirectPairingHandler : fail POST request to /oic/sec/dpairing");
-        }
-    }
-    else
-    {
-        OIC_LOG(ERROR, TAG, "DirectPairingHandler received Null clientResponse");
-    }
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-exit:
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-    if (OC_STACK_OK != res)
-    {
-        if (0 < strlen((const char*)subjectId.id))
-        {
-            RemoveCredential(&dpairData->peer->deviceID);
-            OICFree(dpairData);
-            g_dp_proceed_ctx = NULL;
-            OIC_LOG_V(INFO, TAG, "OUT DirectPairingHandler.");
-            return OC_STACK_DELETE_TRANSACTION;
-        }
-
-        resultCallback(dpairData->userCtx, dpairData->peer, res);
-    }
-    OIC_LOG(INFO, TAG, "OUT DirectPairingHandler.");
-    return OC_STACK_DELETE_TRANSACTION;
-}
-
-/**
- * Start direct-pairing .
- *
- * @param[in] peer  target device to establish direct-pairing.
- * @param[in] pmSel  selected pairing method.
- * @param[in] pinNumber  secret value for dtls connection.
- *
- * @return OC_STACK_OK on success otherwise error.
- */
-OCStackResult DPDirectPairing(void *ctx, OCDirectPairingDev_t* peer, OicSecPrm_t pmSel,
-                                char *pinNumber, OCDirectPairingResultCB resultCallback)
-{
-    if(NULL == peer || NULL == pinNumber)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OicUuid_t deviceID =   {.id={0}};
-    if (OC_STACK_OK != GetDoxmDeviceID(&deviceID))
-    {
-        OIC_LOG(ERROR, TAG, "Error while retrieving device ID");
-        return OC_STACK_ERROR;
-    }
-
-    OicSecDpairing_t dpair;
-    memset(&dpair, 0, sizeof(OicSecDpairing_t));
-    dpair.spm = pmSel;
-    memcpy(&dpair.pdeviceID, &deviceID, sizeof(OicUuid_t));
-
-    OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
-    if(!secPayload)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to memory allocation");
-        return OC_STACK_NO_MEMORY;
-    }
-    secPayload->base.type = PAYLOAD_TYPE_SECURITY;
-
-    OCStackResult ret = DpairingToCBORPayload(&dpair, &(secPayload->securityData),
-            &(secPayload->payloadSize));
-
-    if(OC_STACK_OK != ret)
-    {
-        OICFree(secPayload);
-        OIC_LOG(ERROR, TAG, "Failed to DpairingToCBORPayload");
-        return OC_STACK_NO_MEMORY;
-    }
-    OIC_LOG(DEBUG, TAG, "DPARING CBOR data:");
-    OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
-
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
-    if(!DPGenerateQuery(false,
-                        peer->endpoint.addr,
-                        peer->endpoint.port,
-                        //peer->securePort,
-                        peer->connType,
-                        query, sizeof(query), OIC_RSRC_DPAIRING_URI))
-    {
-        OIC_LOG(ERROR, TAG, "DPDirectPairing : Failed to generate query");
-        return OC_STACK_ERROR;
-    }
-    OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
-    DPairData_t *dpairData = (DPairData_t *) OICCalloc(1, sizeof(DPairData_t));
-    if (dpairData == NULL)
-    {
-        OICFree(secPayload->securityData);
-        OICFree(secPayload);
-        OIC_LOG(ERROR, TAG, "Unable to allocate memory");
-        return OC_STACK_NO_MEMORY;
-    }
-    dpairData->peer = peer;
-    memcpy(dpairData->pin, pinNumber, DP_PIN_LENGTH);
-    dpairData->resultCallback = resultCallback;
-    dpairData->userCtx = ctx;
-
-    OCCallbackData cbData;
-    memset(&cbData, 0, sizeof(cbData));
-    cbData.cb = DirectPairingHandler;
-    cbData.context = (void*)dpairData;
-    cbData.cd = NULL;
-
-    OCMethod method = OC_REST_POST;
-    OCDoHandle handle = NULL;
-    OIC_LOG(DEBUG, TAG, "Sending DPAIRNG setting to resource server");
-    ret = OCDoResource(&handle, method, query,
-            &peer->endpoint, (OCPayload*)secPayload,
-            peer->connType, OC_LOW_QOS, &cbData, NULL, 0);
-    if(OC_STACK_OK != ret)
-    {
-        OIC_LOG(ERROR, TAG, "error in OCDoResource");
-        return OC_STACK_ERROR;
-    }
-
-    return OC_STACK_OK;
-
- }
-
-/**
- * Callback handler for getting secure port information using /oic/res discovery.
- *
- * @param[in] ctx             user context
- * @param[in] handle          Handle for response
- * @param[in] clientResponse  Response information(It will contain payload)
- *
- * @return OC_STACK_KEEP_TRANSACTION to keep transaction and
- *         OC_STACK_DELETE_TRANSACTION to delete it.
- */
-static OCStackApplicationResult DirectPairingPortDiscoveryHandler(void *ctx, OCDoHandle UNUSED,
-                                 OCClientResponse *clientResponse)
-{
-    OIC_LOG(INFO, TAG, "Callback Context for Direct-Pairing Secure Port DISCOVER "
-            "query recvd successfully");
-
-    (void)ctx;
-    (void)UNUSED;
-    if (clientResponse)
-    {
-        if  (NULL == clientResponse->payload)
-        {
-            OIC_LOG(INFO, TAG, "Skiping Null payload");
-        }
-        else
-        {
-            if (PAYLOAD_TYPE_DISCOVERY != clientResponse->payload->type)
-            {
-                OIC_LOG(INFO, TAG, "Wrong payload type");
-                return OC_STACK_DELETE_TRANSACTION;
-            }
-
-            uint16_t securePort = 0;
-            OCResourcePayload* resPayload = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
-            OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
-
-            if (resPayload && resPayload->secure)
-            {
-                securePort = resPayload->port;
-            }
-            else
-            {
-                OIC_LOG(INFO, TAG, "Can not find secure port information.");
-                return OC_STACK_DELETE_TRANSACTION;
-            }
-
-            OCDirectPairingDev_t *ptr = getDev(&g_dp_discover,
-                    clientResponse->devAddr.addr, clientResponse->devAddr.port);
-            if(!ptr)
-            {
-                OIC_LOG(ERROR, TAG, "Can not find device information in the discovery device list");
-                return OC_STACK_DELETE_TRANSACTION;
-            }
-            ptr->securePort = securePort;
-
-            OIC_LOG(INFO, TAG, "Exiting DirectPairingPortDiscoveryHandler.");
-        }
-
-        return  OC_STACK_DELETE_TRANSACTION;
-    }
-    else
-    {
-        OIC_LOG(INFO, TAG, "Skiping Null response");
-    }
-    return  OC_STACK_DELETE_TRANSACTION;
-}
-
-/**
- * Callback handler for DPDeviceDiscovery API.
- *
- * @param[in] ctx             User context
- * @param[in] handle          Handler for response
- * @param[in] clientResponse  Response information (It will contain payload)
- * @return OC_STACK_KEEP_TRANSACTION to keep transaction and
- *         OC_STACK_DELETE_TRANSACTION to delete it.
- */
-static OCStackApplicationResult DirectPairingDiscoveryHandler(void* ctx, OCDoHandle UNUSED,
-        OCClientResponse * clientResponse)
-{
-    OIC_LOG(INFO, TAG, "Callback Context for Direct-Pairing DISCOVER query recvd successfully");
-
-    (void)ctx;
-    (void)UNUSED;
-    if (clientResponse)
-    {
-        OIC_LOG_V(INFO, TAG, "StackResult: %d", clientResponse->result);
-        OIC_LOG_V(INFO, TAG,
-                "Device =============> Discovered @ %s:%d",
-                clientResponse->devAddr.addr,
-                clientResponse->devAddr.port);
-
-        if  (NULL == clientResponse->payload)
-        {
-            OIC_LOG(INFO, TAG, "Skiping Null payload");
-            return OC_STACK_KEEP_TRANSACTION;
-        }
-        if (OC_STACK_OK != clientResponse->result)
-        {
-            OIC_LOG(INFO, TAG, "Error in response");
-            return OC_STACK_KEEP_TRANSACTION;
-        }
-
-        OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
-        OicSecPconf_t *pconf = NULL;
-
-        OCStackResult res = CBORPayloadToPconf(
-                ((OCSecurityPayload*)clientResponse->payload)->securityData,
-                CBOR_SIZE,&pconf);
-        if (OC_STACK_OK != res )
-        {
-            OIC_LOG(INFO, TAG, "Ignoring malformed CBOR");
-            return OC_STACK_KEEP_TRANSACTION;
-        }
-        else
-        {
-            if(pconf->edp)
-            {
-                OCDevAddr endpoint;
-                memcpy(&endpoint, &clientResponse->devAddr, sizeof(OCDevAddr));
-
-                res = addDev(&g_dp_discover, &endpoint, clientResponse->connType, pconf);
-                DeletePconfBinData(pconf);
-                if (OC_STACK_OK != res)
-                {
-                    OIC_LOG(ERROR, TAG, "Error while adding data to linkedlist.");
-                    return OC_STACK_KEEP_TRANSACTION;
-                }
-
-                char rsrc_uri[MAX_URI_LENGTH+1] = {0};
-                int wr_len = snprintf(rsrc_uri, sizeof(rsrc_uri), "%s?%s=%s",
-                          OC_RSRVD_WELL_KNOWN_URI, OC_RSRVD_RESOURCE_TYPE, OIC_RSRC_TYPE_SEC_DPAIRING);
-                if(wr_len <= 0 || (size_t)wr_len >= sizeof(rsrc_uri))
-                {
-                    OIC_LOG(ERROR, TAG, "rsrc_uri_string_print failed");
-                    return OC_STACK_KEEP_TRANSACTION;
-                }
-
-                //Try to the unicast discovery to getting secure port
-                char query[MAX_URI_LENGTH+MAX_QUERY_LENGTH+1] = {0};
-                if(!DPGenerateQuery(false,
-                                    clientResponse->devAddr.addr, clientResponse->devAddr.port,
-                                    clientResponse->connType,
-                                    query, sizeof(query), rsrc_uri))
-                {
-                    OIC_LOG(ERROR, TAG, "DirectPairingDiscoveryHandler : Failed to generate query");
-                    return OC_STACK_KEEP_TRANSACTION;
-                }
-                OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
-                OCCallbackData cbData;
-                cbData.cb = &DirectPairingPortDiscoveryHandler;
-                cbData.context = NULL;
-                cbData.cd = NULL;
-                res = OCDoResource(NULL, OC_REST_DISCOVER, query, 0, 0,
-                        clientResponse->connType, OC_LOW_QOS, &cbData, NULL, 0);
-                if(OC_STACK_OK != res)
-                {
-                    OIC_LOG(ERROR, TAG, "Failed to Secure Port Discovery");
-                    return OC_STACK_KEEP_TRANSACTION;
-                }
-                else
-                {
-                    OIC_LOG_V(INFO, TAG, "OCDoResource with [%s] Success", query);
-                }
-            }
-            return  OC_STACK_KEEP_TRANSACTION;
-        }
-    }
-    else
-    {
-        OIC_LOG(INFO, TAG, "Skiping Null response");
-    }
-
-    return OC_STACK_DELETE_TRANSACTION;
-}
-#ifndef WITH_ARDUINO
-/**
- * Discover direct-pairing devices in the same IP subnet. .
- *
- * @param[in] waittime  Timeout in seconds.
- *
- * @return OC_STACK_OK on success otherwise error.
- */
-OCStackResult DPDeviceDiscovery(unsigned short waittime)
-{
-    OIC_LOG(DEBUG, TAG, "IN DPDeviceDiscovery");
-
-    if (g_dp_discover)
-    {
-        delList(g_dp_discover);
-        g_dp_discover = NULL;
-    }
-
-    OCStackResult ret;
-
-    const char DP_DISCOVERY_QUERY[] = "/oic/sec/pconf";
-
-    OCCallbackData cbData;
-    cbData.cb = DirectPairingDiscoveryHandler;
-    cbData.context = NULL;
-    cbData.cd = NULL;
-
-    /* Start a DP discovery query*/
-    OIC_LOG_V(INFO, TAG, "Initiating Direct-Pairing Discovery : %s\n", DP_DISCOVERY_QUERY);
-    OCDoHandle handle = NULL;
-    ret = OCDoResource(&handle, OC_REST_DISCOVER, DP_DISCOVERY_QUERY, 0, 0, CT_DEFAULT,
-                       OC_LOW_QOS, &cbData, NULL, 0);
-    if (ret != OC_STACK_OK)
-    {
-        OIC_LOG(ERROR, TAG, "OCStack resource error");
-        return ret;
-    }
-
-    // wait..
-
-    int clock_res = -1;
-#if defined(_MSC_VER)
-    time_t startTime = 0;
-    clock_res = (time(&startTime) == -1);
-#else
-    struct timespec startTime = {.tv_sec=0, .tv_nsec=0};
-#if defined(__ANDROID__) || _POSIX_TIMERS > 0
-    clock_res = clock_gettime(CLOCK_MONOTONIC, &startTime);
-#endif
-#endif
-    if (0 != clock_res)
-    {
-        OIC_LOG(ERROR, TAG, "clock error");
-        if(OC_STACK_OK !=  OCCancel(handle, OC_LOW_QOS, NULL, 0))
-        {
-            OIC_LOG(ERROR, TAG, "Failed to remove registered callback");
-        }
-        return OC_STACK_ERROR;
-    }
-
-    while (1)
-    {
-#if defined(_MSC_VER)
-        time_t currTime = 0;
-        clock_res = (time(&currTime) == -1);
-#else
-        struct timespec currTime  = {.tv_sec=0, .tv_nsec=0};
-#if defined(__ANDROID__) || _POSIX_TIMERS > 0
-        clock_res = clock_gettime(CLOCK_MONOTONIC, &currTime);
-#endif
-#endif
-        if (0 != clock_res)
-        {
-            OIC_LOG(ERROR, TAG, "clock error");
-            ret = OC_STACK_ERROR;
-            break;
-        }
-#if defined(_MSC_VER)
-        time_t elapsed = currTime - startTime;
-#else
-        time_t elapsed = (currTime.tv_sec - startTime.tv_sec);
-#endif
-        if (elapsed > waittime)
-        {
-            break;
-        }
-        else
-        {
-            struct timespec timeout = {.tv_sec=0, .tv_nsec=100000000L};
-            OCProcess();
-            nanosleep(&timeout, NULL);
-        }
-    }
-
-    // Waiting for each response.
-    ret = OCCancel(handle, OC_LOW_QOS, NULL, 0);
-    if (OC_STACK_OK != ret)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to remove registered callback");
-    }
-    OIC_LOG(DEBUG, TAG, "OUT DPDeviceDiscovery");
-    return ret;
-}
-#endif
index 9fc886b..cfaa327 100644 (file)
@@ -41,8 +41,6 @@
 #include "deviceonboardingstate.h"
 #include "aclresource.h"
 #include "amaclresource.h"
-#include "pconfresource.h"
-#include "dpairingresource.h"
 #include "psinterface.h"
 #include "srmresourcestrings.h"
 #include "credresource.h"
@@ -1284,19 +1282,6 @@ int HandleDoxmPostRequestSVR()
         OIC_LOG_V(ERROR, TAG, "%s: set pstat RownerId", __func__);
         return 1;
     }
-    ownerRes = SetDpairingRownerId(&gDoxm->owner);
-    if (OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
-    {
-        OIC_LOG_V(ERROR, TAG, "%s: set dpairing RownerId", __func__);
-        return 1;
-    }
-    ownerRes = SetPconfRownerId(&gDoxm->owner);
-    if (OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
-    {
-        OIC_LOG_V(ERROR, TAG, "%s: set pconf RownerId", __func__);
-        return 1;
-    }
-
     return 0;
 }
 
diff --git a/resource/csdk/security/src/dpairingresource.c b/resource/csdk/security/src/dpairingresource.c
deleted file mode 100644 (file)
index a8f271a..0000000
+++ /dev/null
@@ -1,826 +0,0 @@
-/* *****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * *****************************************************************/
-
-#include "iotivity_config.h"
-#include <stdlib.h>
-#include <string.h>
-#include "ocstack.h"
-#include "logger.h"
-#include "oic_malloc.h"
-#include "oic_string.h"
-#include "base64.h"
-#include "resourcemanager.h"
-#include "dpairingresource.h"
-#include "psinterface.h"
-#include "utlist.h"
-#include "srmresourcestrings.h"
-#include "cainterface.h"
-#include "doxmresource.h"
-#include "pconfresource.h"
-#include "credresource.h"
-#include "aclresource.h"
-#include "srmutility.h"
-#include "ocserverrequest.h"
-#include "ocpayload.h"
-#include "ocpayloadcbor.h"
-#include "payload_logging.h"
-#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
-#include <mbedtls/ssl_ciphersuites.h>
-#endif
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#define TAG  "OIC_SRM_DPAIRING"
-
-/** Default cbor payload size. This value is increased in case of CborErrorOutOfMemory.
- * The value of payload size is increased until reaching belox max cbor size. */
-static const uint16_t CBOR_SIZE = 1024;
-
-/** Max cbor size payload. */
-static const uint16_t CBOR_MAX_SIZE = 4400;
-
-/** DOXM Map size - Number of mandatory items. */
-static const uint8_t DPAIR_MAP_SIZE = 3;
-
-static OicSecDpairing_t     *gDpair = NULL;
-static OCResourceHandle   gDpairHandle = NULL;
-static OicSecDpairing_t      gDefaultDpair =
-{
-    PRM_NOT_ALLOWED,       /* OicSecPrm_t spm */
-    {.id = {0}},                   /* OicUuid_t pdeviceID */
-    {.id = {0}},                   /* OicUuid_t rowner */
-};
-
-void DeleteDpairingBinData(OicSecDpairing_t* dpair)
-{
-    if (dpair)
-    {
-        //Clean dpairing itself
-        OICFree(dpair);
-    }
-}
-
-/**
- * Get the default value.
- * @retval  the gDefaultDpair pointer;
- */
-static OicSecDpairing_t* GetDpairingDefault()
-{
-    OIC_LOG (DEBUG, TAG, "GetDpairingDefault");
-
-    return &gDefaultDpair;
-}
-
-/**
- * This method is used by SRM to retrieve Dpairing resource data..
- */
-void SetDpairingResourceOwner(OicUuid_t *rowner)
-{
-    OIC_LOG (DEBUG, TAG, "SetDpairingResourceOwner");
-    if (gDpair)
-    {
-        memcpy(&gDpair->rownerID, rowner, sizeof(OicUuid_t));
-    }
-}
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-/**
- * Function to save PairingPSK.
- *
- * @param[in] endpoint   current endpoint.
- * @param[in] peerDevID   peer device indentitiy.
- * @param[in] isPairingServer   indicate if it generates PairingPSK for server or client.
- *
- * @return  OC_STACK_OK on success
- */
-OCStackResult SavePairingPSK(OCDevAddr *endpoint,
-            OicUuid_t *peerDevID, OicUuid_t *owner, bool isPairingServer)
-{
-    OIC_LOG(DEBUG, TAG, "IN SavePairingPSK");
-
-    if(NULL == endpoint || NULL == peerDevID || NULL == owner)
-    {
-        OIC_LOG_V(ERROR, TAG, "Invalid Input parameters in [%s]\n", __FUNCTION__);
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OCStackResult res = OC_STACK_ERROR;
-
-    OicUuid_t ptDeviceID = {.id={0}};
-    if (OC_STACK_OK != GetDoxmDeviceID(&ptDeviceID))
-    {
-        OIC_LOG(ERROR, TAG, "Error while retrieving provisioning tool's device ID");
-        return res;
-    }
-
-    uint8_t pairingPSK[OWNER_PSK_LENGTH_128] = {0};
-    OicSecKey_t pairingKey;
-    memset(&pairingKey, 0, sizeof(pairingKey));
-    pairingKey.data = pairingPSK;
-    pairingKey.len = OWNER_PSK_LENGTH_128;
-    pairingKey.encoding = OIC_ENCODING_RAW;
-
-    //Generating PairingPSK using OwnerPSK scheme
-    CAResult_t pskRet = CAGenerateOwnerPSK((const CAEndpoint_t *)endpoint,
-            (uint8_t *)OIC_RSRC_TYPE_SEC_DPAIRING,
-            strlen(OIC_RSRC_TYPE_SEC_DPAIRING),
-            (isPairingServer ? ptDeviceID.id : peerDevID->id), sizeof(OicUuid_t), // server
-            (isPairingServer ? peerDevID->id : ptDeviceID.id), sizeof(OicUuid_t), // client
-            pairingPSK, OWNER_PSK_LENGTH_128);
-
-    if (CA_STATUS_OK == pskRet)
-    {
-        OIC_LOG(DEBUG, TAG, "pairingPSK dump:\n");
-        OIC_LOG_BUFFER(DEBUG, TAG, pairingPSK, OWNER_PSK_LENGTH_128);
-        //Generating new credential for direct-pairing client
-
-        OicSecCred_t *cred = GenerateCredential(peerDevID,
-                SYMMETRIC_PAIR_WISE_KEY, NULL,
-                &pairingKey, owner, NULL);
-        OICClearMemory(pairingPSK, sizeof(pairingPSK));
-        VERIFY_NOT_NULL(TAG, cred, ERROR);
-
-        res = AddCredential(cred);
-        if(res != OC_STACK_OK)
-        {
-            DeleteCredList(cred);
-            return res;
-        }
-    }
-    else
-    {
-        OIC_LOG(ERROR, TAG, "CAGenerateOwnerPSK failed");
-    }
-
-    OIC_LOG(DEBUG, TAG, "OUT SavePairingPSK");
-exit:
-    return res;
-}
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-OCStackResult DpairingToCBORPayload(const OicSecDpairing_t *dpair, uint8_t **payload, size_t *size)
-{
-    if (NULL == dpair || NULL == payload || NULL != *payload || NULL == size)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    size_t cborLen = *size;
-    if (0 == cborLen)
-    {
-        cborLen = CBOR_SIZE;
-    }
-
-    *payload = NULL;
-    *size = 0;
-
-    OCStackResult ret = OC_STACK_ERROR;
-
-    CborEncoder encoder;
-    CborEncoder dpairMap;
-
-    int64_t cborEncoderResult = CborNoError;
-    uint8_t mapSize = DPAIR_MAP_SIZE;
-
-    uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
-    VERIFY_NOT_NULL_RETURN(TAG, outPayload, ERROR, OC_STACK_ERROR);
-
-    cbor_encoder_init(&encoder, outPayload, cborLen, 0);
-
-    cborEncoderResult = cbor_encoder_create_map(&encoder, &dpairMap, mapSize);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Creating DPAIRING Map");
-
-    //spm -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_SPM_NAME,
-        strlen(OIC_JSON_SPM_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SPM name tag");
-    cborEncoderResult = cbor_encode_int(&dpairMap, dpair->spm);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SPM value");
-
-    //PDEVICEID -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_PDEVICE_ID_NAME,
-        strlen(OIC_JSON_PDEVICE_ID_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding PDeviceID tag");
-    {
-        char *deviceId = NULL;
-        ret = ConvertUuidToStr(&dpair->pdeviceID, &deviceId);
-        VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-        cborEncoderResult = cbor_encode_text_string(&dpairMap, deviceId, strlen(deviceId));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode PDeviceID value");
-        OICFree(deviceId);
-    }
-
-    //ROWNER -- Mandatory
-    {
-        char *rowner = NULL;
-        cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_ROWNERID_NAME,
-            strlen(OIC_JSON_ROWNERID_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding ROWNER tag");
-        ret = ConvertUuidToStr(&dpair->rownerID, &rowner);
-        VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-        cborEncoderResult = cbor_encode_text_string(&dpairMap, rowner, strlen(rowner));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Rowner ID value");
-        OICFree(rowner);
-    }
-
-    cborEncoderResult = cbor_encoder_close_container(&encoder, &dpairMap);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close dpairMap");
-
-     if (CborNoError == cborEncoderResult)
-    {
-        *size = cbor_encoder_get_buffer_size(&encoder, outPayload);
-        *payload = outPayload;
-        ret = OC_STACK_OK;
-    }
-
-exit:
-    if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE))
-    {
-       // reallocate and try again!
-       OICFree(outPayload);
-       outPayload = NULL;
-       // Since the allocated initial memory failed, double the memory.
-       cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
-       cborEncoderResult = CborNoError;
-       ret = DpairingToCBORPayload(dpair, payload, &cborLen);
-       *size = cborLen;
-    }
-
-    if ((CborNoError != cborEncoderResult) || (OC_STACK_OK != ret))
-    {
-       OICFree(outPayload);
-       outPayload = NULL;
-       *payload = NULL;
-       *size = 0;
-       ret = OC_STACK_ERROR;
-    }
-
-    return ret;
-}
-
-OCStackResult CBORPayloadToDpair(const uint8_t *cborPayload, size_t size,
-                                OicSecDpairing_t **secDpair)
-{
-    if (NULL == cborPayload || NULL == secDpair || NULL != *secDpair || 0 == size)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    OCStackResult ret = OC_STACK_ERROR;
-    *secDpair = NULL;
-
-    CborValue dpairCbor = { .parser = NULL };
-    CborParser parser = { .end = NULL };
-    CborError cborFindResult = CborNoError;
-
-    cbor_parser_init(cborPayload, size, 0, &parser, &dpairCbor);
-    CborValue dpairMap = { .parser = NULL };
-    OicSecDpairing_t *dpair = NULL;
-    cborFindResult = cbor_value_enter_container(&dpairCbor, &dpairMap);
-    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering DPairing Map");
-
-    dpair = (OicSecDpairing_t *)OICCalloc(1, sizeof(*dpair));
-    VERIFY_NOT_NULL(TAG, dpair, ERROR);
-
-    while (cbor_value_is_valid(&dpairMap) && cbor_value_is_text_string(&dpairMap))
-    {
-        char *name = NULL;
-        size_t len = 0;
-        CborType type = CborInvalidType;
-        cborFindResult = cbor_value_dup_text_string(&dpairMap, &name, &len, NULL);
-        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding tag name");
-        cborFindResult = cbor_value_advance(&dpairMap);
-        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing a value in DPair map");
-
-        type = cbor_value_get_type(&dpairMap);
-        if (0 == strcmp(OIC_JSON_SPM_NAME, name) && cbor_value_is_integer(&dpairMap))
-        {
-            int spm;
-
-            cborFindResult = cbor_value_get_int(&dpairMap, &spm);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding SPM Value");
-            dpair->spm = (OicSecPrm_t)spm;
-        }
-
-        if (0 == strcmp(OIC_JSON_PDEVICE_ID_NAME, name))
-        {
-            char *id = NULL;
-            cborFindResult = cbor_value_dup_text_string(&dpairMap, &id, &len, NULL);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding PDeviceID value");
-            ret = ConvertStrToUuid(id, &dpair->pdeviceID);
-            VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-            OICFree(id);
-        }
-
-        if (0 == strcmp(OIC_JSON_ROWNERID_NAME, name))
-        {
-            char *id = NULL;
-            cborFindResult = cbor_value_dup_text_string(&dpairMap, &id, &len, NULL);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RownerID value");
-            ret = ConvertStrToUuid(id, &dpair->rownerID);
-            VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-            OICFree(id);
-        }
-
-        if (CborMapType != type && cbor_value_is_valid(&dpairMap))
-        {
-            cborFindResult = cbor_value_advance(&dpairMap);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing the Dpair Map");
-        }
-        OICFree(name);
-    }
-
-    *secDpair = dpair;
-    ret = OC_STACK_OK;
-
-exit:
-    if (CborNoError != cborFindResult)
-    {
-        OIC_LOG (ERROR, TAG, "CBORPayloadToDoxm failed");
-        DeleteDpairingBinData(dpair);
-        dpair = NULL;
-        *secDpair = NULL;
-        ret = OC_STACK_ERROR;
-    }
-    return ret;
-}
-/**
- * Function to handle the handshake result in Direct-Pairing.
- * This function will be invoked after DTLS handshake
- * @param   endPoint  [IN] The remote endpoint.
- * @param   errorInfo [IN] Error information from the endpoint.
- * @return  NONE
- */
-CAResult_t DPairingDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
-{
-    OIC_LOG(INFO, TAG, "IN DPairingDTLSHandshakeCB");
-
-    if(gDpair && endpoint && info)
-    {
-        OIC_LOG_V(INFO, TAG, "Received status from remote device(%s:%d) : %d",
-                 endpoint->addr, endpoint->port, info->result);
-
-        if(CA_STATUS_OK == info->result)
-        {
-            OIC_LOG(INFO, TAG, "DPairingDTLSHandshakeCB - Connection success.");
-        }
-        else if(CA_DTLS_AUTHENTICATION_FAILURE == info->result)
-        {
-            OIC_LOG(INFO, TAG, "DPairingDTLSHandshakeCB - Authentication failed");
-
-        }
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-        CAregisterSslHandshakeCallback(NULL);
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-        // delete temporary key
-        RemoveCredential(&gDpair->pdeviceID);
-    }
-
-    OIC_LOG(INFO, TAG, "OUT DPairingDTLSHandshakeCB");
-    return CA_STATUS_OK;
-}
-
-static OCEntityHandlerResult HandleDpairingPostRequest (const OCEntityHandlerRequest * ehRequest)
-{
-    OIC_LOG (DEBUG, TAG, "Dpairing EntityHandle  processing POST request");
-    OCEntityHandlerResult ehRet = OC_EH_ERROR;
-    OicSecDpairing_t* newDpair = NULL;
-    OCStackResult res = OC_STACK_OK;
-
-    const OicSecPconf_t *pconf = GetPconfResourceData();
-    if (true == pconf->edp)
-    {
-        uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData;
-        size_t size = ((OCSecurityPayload*)ehRequest->payload)->payloadSize;
-        if (payload)
-        {
-            res = CBORPayloadToDpair(payload, size, &newDpair);
-        }
-    }
-    else
-    {
-        OIC_LOG (DEBUG, TAG, "EDP == false : Direct-Pairing Disabled");
-        ehRet = OC_EH_ERROR;
-    }
-
-    if (OC_STACK_OK == res && newDpair && false == IsPairedDevice(&newDpair->pdeviceID))
-    {
-        // Check if valid Post request
-        bool prmMached = false;
-        for (size_t i=0; i<pconf->prmLen; i++)
-        {
-            if (newDpair->spm == pconf->prm[i])
-            {
-                prmMached = true;
-                break;
-            }
-        }
-        OIC_LOG_V(DEBUG, TAG, "Parsed spm is %s", prmMached ? "valid" :
-                "invalid, send error response");
-
-        // Update local Dpairing with new Dpairing & prepare dtls session
-        if (prmMached && '\0' != (char)newDpair->pdeviceID.id[0])
-        {
-            if(!gDpair)
-            {
-                gDpair = GetDpairingDefault();
-            }
-            gDpair->spm = newDpair->spm;
-            memcpy(&gDpair->pdeviceID, &newDpair->pdeviceID, sizeof(OicUuid_t));
-            memcpy(&gDpair->rownerID, &pconf->rownerID, sizeof(OicUuid_t));
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-            // Add temporary psk
-            OCStackResult result;
-            OicUuid_t subjectId = {.id={0}};
-            result = AddTmpPskWithPIN(&gDpair->pdeviceID,
-                           SYMMETRIC_PAIR_WISE_KEY,
-                           (char*)pconf->pin.val, DP_PIN_LENGTH,
-                           &gDpair->rownerID, &subjectId);
-            if(result != OC_STACK_OK ||
-                    memcmp(&gDpair->pdeviceID, &subjectId, sizeof(OicUuid_t)))
-            {
-                OIC_LOG_V(ERROR, TAG, "Failed to save the temporal PSK : %d", result);
-                goto exit;
-            }
-
-            // Prepare to establish a secure channel with Pin-based PSK cipher suite
-            if (CA_STATUS_OK != CAEnableAnonECDHCipherSuite(false) ||
-                CA_STATUS_OK != CASelectCipherSuite(MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, CA_ADAPTER_IP))
-            {
-                OIC_LOG_V(ERROR, TAG, "Failed to select TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256");
-                goto exit;
-            }
-
-            if(CA_STATUS_OK != CAregisterSslHandshakeCallback(DPairingDTLSHandshakeCB))
-            {
-                OIC_LOG(WARNING, TAG, "DirectPairingHandler : Failed to register"
-                        " DTLS handshake callback.");
-                goto exit;
-            }
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-            // should be lock /oic/sec/dpairing resource if Direct-Pairing starts normally ?
-            OIC_LOG (DEBUG, TAG, "/oic/sec/dpairing resource created");
-
-            ehRet = OC_EH_RESOURCE_CREATED;
-        }
-        else
-        {
-            OIC_LOG(ERROR, TAG, "Error in request check");
-        }
-    }
-
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-exit:
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-    // Send payload to request originator
-    if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
-    {
-        ehRet = OC_EH_ERROR;
-        OIC_LOG (ERROR, TAG, "SendSRMResponse failed in HandleDpairingPostRequest");
-    }
-
-    if (OC_EH_ERROR == ehRet && gDpair)
-    {
-        RemoveCredential(&gDpair->pdeviceID);
-        gDpair = NULL;
-    }
-
-    DeleteDpairingBinData(newDpair);
-    OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
-    return ehRet;
-}
-
-static OCEntityHandlerResult HandleDpairingPutRequest (const OCEntityHandlerRequest * ehRequest)
-{
-    OIC_LOG (DEBUG, TAG, "Dpairing EntityHandle  processing PUT request (Comfirmation)");
-
-    OCEntityHandlerResult ehRet = OC_EH_ERROR;
-    OicSecDpairing_t* newDpair = NULL;
-    OCStackResult res = OC_STACK_OK;
-
-    const OicSecPconf_t *pconf = GetPconfResourceData();
-    if (true == pconf->edp)
-    {
-        uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData;
-        size_t size = ((OCSecurityPayload*)ehRequest->payload)->payloadSize;
-        if (payload)
-        {
-            res = CBORPayloadToDpair(payload, size, &newDpair);
-        }
-    }
-    else
-    {
-        OIC_LOG (DEBUG, TAG, "EDP == false : Direct-Pairing Disabled");
-        ehRet = OC_EH_ERROR;
-    }
-
-
-    if ((OC_STACK_OK == res) && gDpair && newDpair)
-    {
-        OIC_LOG(DEBUG, TAG, "Received direct-pairing finalization request");
-
-        // Check if valid Put request
-        VERIFY_SUCCESS(TAG, PRM_NOT_ALLOWED == newDpair->spm, ERROR);
-
-        const OicSecPconf_t *secPconf = GetPconfResourceData();
-        VERIFY_NOT_NULL(TAG, secPconf, ERROR);
-
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-        OCServerRequest * request = (OCServerRequest *)ehRequest->requestHandle;
-        VERIFY_SUCCESS(TAG, (request->devAddr.flags | OC_FLAG_SECURE), ERROR);
-
-        //Generate new credential
-        OIC_LOG_V(INFO, TAG, "SavePairingPSK for %s(%d)", request->devAddr.addr,
-                request->devAddr.port);
-        OCStackResult result = SavePairingPSK(&request->devAddr, &newDpair->pdeviceID,
-                (OicUuid_t *)&secPconf->rownerID, true);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == result, ERROR);
-#endif // __WITH_DTLS__ or __WITH_TLS__
-
-        //Generate new acl
-        OicSecPdAcl_t *pdAcl;
-        LL_FOREACH(secPconf->pdacls, pdAcl)
-        {
-            OicSecAcl_t* acl = (OicSecAcl_t*)OICCalloc(1, sizeof(OicSecAcl_t));
-            VERIFY_NOT_NULL(TAG, acl, ERROR);
-
-            OicSecAce_t* ace = (OicSecAce_t*)OICCalloc(1, sizeof(OicSecAce_t));
-            VERIFY_NOT_NULL(TAG, ace, ERROR);
-
-            LL_APPEND(acl->aces, ace);
-
-            ace->subjectType = OicSecAceUuidSubject;
-            memcpy(&ace->subjectuuid, &gDpair->pdeviceID, sizeof(OicUuid_t));
-
-            for(size_t i = 0; i < pdAcl->resourcesLen; i++)
-            {
-                OicSecRsrc_t* rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t));
-                VERIFY_NOT_NULL(TAG, rsrc, ERROR);
-                LL_APPEND(ace->resources, rsrc);
-
-                //href
-                rsrc->href = OICStrdup(pdAcl->resources[i]);
-
-                // TODO: Append 'if' and 'rt' as workaround
-                // if
-                rsrc->interfaceLen = 1;
-                rsrc->interfaces = (char**)OICCalloc(rsrc->interfaceLen, sizeof(char));
-                VERIFY_NOT_NULL(TAG, (rsrc->interfaces), ERROR);
-                rsrc->interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
-                VERIFY_NOT_NULL(TAG, (rsrc->interfaces[0]), ERROR);
-
-                //rt
-                rsrc->typeLen = 1;
-                rsrc->types = (char**)OICCalloc(rsrc->typeLen, sizeof(char));
-                VERIFY_NOT_NULL(TAG, (rsrc->types), ERROR);
-                rsrc->types[0] = OICStrdup("oic.core");
-                VERIFY_NOT_NULL(TAG, (rsrc->types[0]), ERROR);
-            }
-
-            ace->permission = pdAcl->permission;
-
-            //Copy the validity
-            if(pdAcl->periods || pdAcl->recurrences)
-            {
-                OicSecValidity_t* validity = (OicSecValidity_t*)OICCalloc(1, sizeof(OicSecValidity_t));
-                VERIFY_NOT_NULL(TAG, validity, ERROR);
-
-                if(pdAcl->periods && pdAcl->periods[0])
-                {
-                    validity->period = OICStrdup(pdAcl->periods[0]);
-                    VERIFY_NOT_NULL(TAG, (validity->period), ERROR);
-                }
-
-                if(pdAcl->recurrences && 0 < pdAcl->prdRecrLen)
-                {
-                    validity->recurrenceLen = pdAcl->prdRecrLen;
-                    validity->recurrences = (char**)OICMalloc(sizeof(char*) * pdAcl->prdRecrLen);
-                    VERIFY_NOT_NULL(TAG, (validity->recurrences), ERROR);
-
-                    for(size_t i = 0; i < pdAcl->prdRecrLen; i++)
-                    {
-                        validity->recurrences[i] = OICStrdup(pdAcl->recurrences[i]);
-                        VERIFY_NOT_NULL(TAG, (validity->recurrences[i]), ERROR);
-                    }
-                }
-
-                LL_APPEND(ace->validities, validity);
-            }
-
-            size_t size = 0;
-            uint8_t *payload = NULL;
-            // TODO IOT-2052 update to /acl2
-            if (OC_STACK_OK == AclToCBORPayload(acl, OIC_SEC_ACL_V1, &payload, &size))
-            {
-                AppendACL(payload, size);
-                OICFree(payload);
-            }
-            DeleteACLList(acl);
-        }
-
-        //update pconf device list
-        AddPairedDevice(&newDpair->pdeviceID);
-
-        //Initialize dpairing resource
-        gDpair = NULL;
-
-        OIC_LOG (DEBUG, TAG, "/oic/sec/dpairing resource updated,"
-                "direct-pairing finalization success");
-        ehRet = OC_EH_OK;
-    }
-
-exit:
-
-    //Send payload to request originator
-    if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
-    {
-        ehRet = OC_EH_ERROR;
-        OIC_LOG (ERROR, TAG, "SendSRMResponse failed in HandleDpairingPutRequest");
-    }
-
-    DeleteDpairingBinData(newDpair);
-    OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
-    return ehRet;
-}
-/*
- * This internal method is the entity handler for Dpairing resources and
- * will handle REST request (GET/POST) for them.
- */
-OCEntityHandlerResult DpairingEntityHandler (OCEntityHandlerFlag flag,
-                                        OCEntityHandlerRequest * ehRequest,
-                                        void* callbackParameter)
-{
-    OIC_LOG(DEBUG, TAG, "Received request DpairingEntityHandler");
-    (void)callbackParameter;
-    OCEntityHandlerResult ehRet = OC_EH_ERROR;
-
-    if (!ehRequest)
-    {
-        return ehRet;
-    }
-
-    if (flag & OC_REQUEST_FLAG)
-    {
-        OIC_LOG (DEBUG, TAG, "Flag includes OC_REQUEST_FLAG");
-        switch (ehRequest->method)
-        {
-            case OC_REST_GET:
-                break;
-
-            case OC_REST_POST:
-                ehRet = HandleDpairingPostRequest(ehRequest);
-                break;
-
-            case OC_REST_PUT:
-                ehRet = HandleDpairingPutRequest(ehRequest);
-                break;
-
-            case OC_REST_DELETE:
-                break;
-
-            default:
-                ehRet = OC_EH_ERROR;
-                SendSRMResponse(ehRequest, ehRet, NULL, 0);
-        }
-    }
-
-    return ehRet;
-}
-
-/*
- * This internal method is used to create '/oic/sec/dpairing' resource.
- */
-OCStackResult CreateDpairingResource()
-{
-    OCStackResult ret;
-
-    ret = OCCreateResource(&gDpairHandle,
-                           OIC_RSRC_TYPE_SEC_DPAIRING,
-                           OC_RSRVD_INTERFACE_DEFAULT,
-                           OIC_RSRC_DPAIRING_URI,
-                           DpairingEntityHandler,
-                           NULL,
-                           OC_SECURE | OC_EXPLICIT_DISCOVERABLE);
-
-    if (OC_STACK_OK != ret)
-    {
-        OIC_LOG (ERROR, TAG, "Unable to instantiate Dpairing resource");
-        DeInitDpairingResource();
-    }
-    return ret;
-}
-
-/**
- * Initialize Dpairing resource by loading data from persistent storage.
- *
- * @retval  OC_STACK_OK for Success, otherwise some error value
- */
-OCStackResult InitDpairingResource()
-{
-    OCStackResult ret = OC_STACK_ERROR;
-
-    // Instantiate 'oic.sec.dpairing'
-    ret = CreateDpairingResource();
-    if (OC_STACK_OK != ret)
-    {
-        DeInitDpairingResource();
-    }
-    return ret;
-}
-
-/**
- * Perform cleanup for Dpairing resources.
- *
- * @return
- * OC_STACK_OK    - no error
- * OC_STACK_ERROR - stack process error
- *
- */
-OCStackResult DeInitDpairingResource()
-{
-    OCStackResult ret = OCDeleteResource(gDpairHandle);
-    gDpair = NULL;
-
-    if(OC_STACK_OK == ret)
-    {
-        return OC_STACK_OK;
-    }
-    else
-    {
-        return OC_STACK_ERROR;
-    }
-}
-
-OCStackResult SetDpairingRownerId(const OicUuid_t* newROwner)
-{
-    OCStackResult ret = OC_STACK_ERROR;
-    uint8_t *cborPayload = NULL;
-    size_t size = 0;
-    OicUuid_t prevId = {.id={0}};
-
-    if(NULL == newROwner)
-    {
-        ret = OC_STACK_INVALID_PARAM;
-    }
-    if(NULL == gDpair)
-    {
-        ret = OC_STACK_NO_RESOURCE;
-    }
-
-    if(newROwner && gDpair)
-    {
-        memcpy(prevId.id, gDpair->rownerID.id, sizeof(prevId.id));
-        memcpy(gDpair->rownerID.id, newROwner->id, sizeof(newROwner->id));
-
-        ret = DpairingToCBORPayload(gDpair, &cborPayload, &size);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-
-        ret = UpdateSecureResourceInPS(OIC_JSON_DPAIRING_NAME, cborPayload, size);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-
-        OICFree(cborPayload);
-    }
-
-    return ret;
-
-exit:
-    OICFree(cborPayload);
-    memcpy(gDpair->rownerID.id, prevId.id, sizeof(prevId.id));
-    return ret;
-}
-
-OCStackResult GetDpairingRownerId(OicUuid_t *rowneruuid)
-{
-    OCStackResult retVal = OC_STACK_ERROR;
-    if (gDpair)
-    {
-        *rowneruuid = gDpair->rownerID;
-        retVal = OC_STACK_OK;
-    }
-    return retVal;
-}
diff --git a/resource/csdk/security/src/pconfresource.c b/resource/csdk/security/src/pconfresource.c
deleted file mode 100644 (file)
index 672bd2c..0000000
+++ /dev/null
@@ -1,1304 +0,0 @@
-/* *****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * *****************************************************************/
-
-#include "iotivity_config.h"
-#include <stdlib.h>
-#include <string.h>
-#include "ocstack.h"
-#include "logger.h"
-#include "oic_malloc.h"
-#include "oic_string.h"
-#include "base64.h"
-#include "ocpayload.h"
-#include "ocpayloadcbor.h"
-#include "payload_logging.h"
-#include "resourcemanager.h"
-#include "pconfresource.h"
-#include "psinterface.h"
-#include "utlist.h"
-#include "srmresourcestrings.h"
-#include "doxmresource.h"
-#include "srmutility.h"
-#include "ocserverrequest.h"
-#include "psinterface.h"
-#include "security_internals.h"
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#define TAG  "OIC_SRM_PCONF"
-
-static const uint16_t CBOR_SIZE = 1024;
-static const uint64_t CBOR_MAX_SIZE = 4400;
-static const uint8_t  PCONF_MAP_SIZE = 4;
-static const uint8_t  PCONF_RESOURCE_MAP_SIZE = 4;
-
-static OicSecPconf_t          *gPconf = NULL;
-static OCResourceHandle   gPconfHandle = NULL;
-static OicSecPconf_t         gDefaultPconf =
-{
-    false,                  /* bool edp */
-    NULL,                  /* OicSecPrm *prm */
-    0,                       /* size_t prmLen */
-    {.val = {0}},       /* OicDpPin_t pin */
-    NULL,                  /* OicSecPdAcl_t *pdacls */
-    NULL,                  /* OicUuid_t *pddevs */
-    0,                       /* size_t pddevLen */
-    {.id = {0}},        /* OicUuid_t deviceID */
-    {.id = {0}},        /* OicUuid_t rowner */
-};
-
-/**
- * This function frees OicSecPdAcl_t object's fields and object itself.
- */
-void FreePdAclList(OicSecPdAcl_t* pdacls)
-{
-    if (pdacls)
-    {
-        size_t i = 0;
-
-        //Clean pdacl objecs
-        OicSecPdAcl_t *aclTmp1 = NULL;
-        OicSecPdAcl_t *aclTmp2 = NULL;
-        LL_FOREACH_SAFE(pdacls, aclTmp1, aclTmp2)
-        {
-            LL_DELETE(pdacls, aclTmp1);
-
-            // Clean Resources
-            for (i = 0; i < aclTmp1->resourcesLen; i++)
-            {
-                OICFree(aclTmp1->resources[i]);
-            }
-            OICFree(aclTmp1->resources);
-
-            //Clean Period
-            if(aclTmp1->periods)
-            {
-                for(i = 0; i < aclTmp1->prdRecrLen; i++)
-                {
-                    OICFree(aclTmp1->periods[i]);
-                }
-                OICFree(aclTmp1->periods);
-            }
-
-            //Clean Recurrence
-            if(aclTmp1->recurrences)
-            {
-                for(i = 0; i < aclTmp1->prdRecrLen; i++)
-                {
-                    OICFree(aclTmp1->recurrences[i]);
-                }
-                OICFree(aclTmp1->recurrences);
-            }
-        }
-
-        //Clean pconf itself
-        OICFree(pdacls);
-    }
-}
-
-void DeletePconfBinData(OicSecPconf_t* pconf)
-{
-    if (pconf)
-    {
-        //Clean prm
-        OICFree(pconf->prm);
-
-        //Clean pdacl
-        if (pconf->pdacls)
-        {
-            FreePdAclList(pconf->pdacls);
-        }
-
-        //Clean pddev
-        OICFree(pconf->pddevs);
-
-        //Clean pconf itself
-        OICFree(pconf);
-    }
-}
-
-static size_t OicPdAclSize(const OicSecPdAcl_t *pdAcl)
-{
-    if (!pdAcl)
-    {
-        return 0;
-    }
-
-    OicSecPdAcl_t *tmp = (OicSecPdAcl_t *)pdAcl;
-    size_t size = 0;
-    while (tmp)
-    {
-        size++;
-        tmp = tmp->next;
-    }
-    return size;
-}
-
-OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,size_t *size)
-{
-    if (NULL == pconf || NULL == payload || NULL != *payload || NULL == size)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-    size_t cborLen = *size;
-    if(0 == cborLen)
-    {
-        cborLen = CBOR_SIZE;
-    }
-    *payload = NULL;
-
-    OCStackResult ret = OC_STACK_ERROR;
-    CborEncoder encoder;
-    CborEncoder pconfMap;
-
-    int64_t cborEncoderResult = CborNoError;
-    uint8_t mapSize = PCONF_MAP_SIZE;
-
-    if (pconf->prmLen > 0)
-    {
-        mapSize++;
-    }
-    if (pconf->pdacls)
-    {
-        mapSize++;
-    }
-    if (pconf->pddevs)
-    {
-        mapSize++;
-    }
-
-    uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
-    VERIFY_NOT_NULL_RETURN(TAG, outPayload, ERROR, OC_STACK_ERROR);
-
-    cbor_encoder_init(&encoder, outPayload, cborLen, 0);
-    cborEncoderResult = cbor_encoder_create_map(&encoder, &pconfMap, mapSize);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Creating Pconf Map.");
-
-    //edp  -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_EDP_NAME,
-            strlen(OIC_JSON_EDP_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Encode EDP String.");
-    cborEncoderResult = cbor_encode_boolean(&pconfMap, pconf->edp);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Convert PconfEDP value");
-
-    //PRM type -- Not Mandatory
-    if(pconf->prmLen > 0)
-    {
-        CborEncoder prm;
-        cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PRM_NAME,
-                strlen(OIC_JSON_PRM_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Convert Pconf PRM NAME");
-        cborEncoderResult = cbor_encoder_create_array(&pconfMap, &prm, pconf->prmLen);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Convert Pconf PRM value");
-
-        for (size_t i = 0; i < pconf->prmLen; i++)
-        {
-            cborEncoderResult = cbor_encode_int(&prm, pconf->prm[i]);
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Convert Pconf PRM Array");
-        }
-        cborEncoderResult = cbor_encoder_close_container(&pconfMap, &prm);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close encode array");
-    }
-
-    //PIN -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PIN_NAME,
-            strlen(OIC_JSON_PIN_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create OIC_JSON_PIN_NAME");
-    cborEncoderResult = cbor_encode_byte_string(&pconfMap, pconf->pin.val, sizeof(pconf->pin.val));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to convert pin value");
-
-    //PDACL -- Mandatory
-    if (pconf->pdacls)
-    {
-        OicSecPdAcl_t *pdacl = pconf->pdacls;
-        CborEncoder pdAclArray;
-        cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PDACL_NAME,
-                strlen(OIC_JSON_PDACL_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create OIC_JSON_PDACL_NAME");
-        cborEncoderResult = cbor_encoder_create_array(&pconfMap, &pdAclArray,
-                OicPdAclSize(pconf->pdacls));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to creeate _pdacl array");
-
-        while(pdacl)
-        {
-            CborEncoder pdAclMap;
-            // PDACL Map size - Number of mandatory items
-            uint8_t aclMapSize = 2;
-
-            if (pdacl->prdRecrLen)
-            {
-                ++aclMapSize;
-            }
-            if (pdacl->recurrences)
-            {
-                ++aclMapSize;
-            }
-
-            cborEncoderResult = cbor_encoder_create_map(&pdAclArray, &pdAclMap, aclMapSize);
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,  "Failed to creeate _pdacl array");
-
-            // Resources -- Mandatory
-            cborEncoderResult = cbor_encode_text_string(&pdAclMap, OIC_JSON_RESOURCES_NAME,
-                    strlen(OIC_JSON_RESOURCES_NAME));
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,  "Failed to encode resource result");
-
-            CborEncoder resources;
-            cborEncoderResult = cbor_encoder_create_array(&pdAclMap, &resources,
-                    pdacl->resourcesLen);
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,  "Failed to create resource array");
-
-            for (size_t i = 0; i < pdacl->resourcesLen; i++)
-            {
-                CborEncoder rMap;
-                cborEncoderResult = cbor_encoder_create_map(&resources, &rMap,
-                        PCONF_RESOURCE_MAP_SIZE);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Resource Map.");
-
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_HREF_NAME,
-                        strlen(OIC_JSON_HREF_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding HREF Name Tag.");
-                cborEncoderResult = cbor_encode_text_string(&rMap, pdacl->resources[i],
-                        strlen(pdacl->resources[i]));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding HREF Value in Map.");
-
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_REL_NAME,
-                        strlen(OIC_JSON_REL_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding REL Name Tag.");
-
-                // TODO : Need to assign real value of REL
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_EMPTY_STRING,
-                        strlen(OIC_JSON_EMPTY_STRING));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding REL Value.");
-
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_RT_NAME,
-                        strlen(OIC_JSON_RT_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RT Name Tag.");
-
-                // TODO : Need to assign real value of RT
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_EMPTY_STRING,
-                        strlen(OIC_JSON_EMPTY_STRING));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RT Value.");
-
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_IF_NAME,
-                        strlen(OIC_JSON_IF_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding IF Name Tag.");
-
-                // TODO : Need to assign real value of IF
-                cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_EMPTY_STRING,
-                        strlen(OIC_JSON_EMPTY_STRING));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding IF Value.");
-
-                cborEncoderResult = cbor_encoder_close_container(&resources, &rMap);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Resource Map.");
-            }
-
-            cborEncoderResult = cbor_encoder_close_container(&pdAclMap, &resources);
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,  "Failed to close resource array");
-
-            // Permissions -- Mandatory
-            cborEncoderResult = cbor_encode_text_string(&pdAclMap, OIC_JSON_PERMISSION_NAME,
-                    strlen(OIC_JSON_PERMISSION_NAME));
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,  "Failed to create permition string");
-            cborEncoderResult = cbor_encode_int(&pdAclMap, pdacl->permission);
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode permition calue");
-
-            // Period -- Not Mandatory
-            if (pdacl->periods)
-            {
-                CborEncoder period;
-                cborEncoderResult = cbor_encode_text_string(&pdAclMap, OIC_JSON_PERIODS_NAME,
-                        strlen(OIC_JSON_PERIODS_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode period value");
-                cborEncoderResult = cbor_encoder_create_array(&pdAclMap, &period,
-                        pdacl->prdRecrLen);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create array");
-
-                for (size_t i = 0; i < pdacl->prdRecrLen; i++)
-                {
-                    cborEncoderResult = cbor_encode_text_string(&period, pdacl->periods[i],
-                            strlen(pdacl->periods[i]));
-                    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode period");
-                }
-                cborEncoderResult = cbor_encoder_close_container(&pdAclMap, &period);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,"Failed to close period array");
-            }
-
-            // Period -- Not Mandatory
-            if(0 != pdacl->prdRecrLen && pdacl->recurrences)
-            {
-                CborEncoder recurrences;
-                cborEncoderResult = cbor_encode_text_string(&pdAclMap, OIC_JSON_RECURRENCES_NAME,
-                        strlen(OIC_JSON_RECURRENCES_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,"Failed to encode recurrences");
-                cborEncoderResult = cbor_encoder_create_array(&pdAclMap, &recurrences,
-                        pdacl->prdRecrLen);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create rec array");
-
-                for (size_t i = 0; i < pdacl->prdRecrLen; i++)
-                {
-                    cborEncoderResult = cbor_encode_text_string(&recurrences,
-                            pdacl->recurrences[i], strlen(pdacl->recurrences[i]));
-                    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode recurrences");
-                }
-                cborEncoderResult = cbor_encoder_close_container(&pdAclMap, &recurrences);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close rec array");
-            }
-            cborEncoderResult = cbor_encoder_close_container(&pdAclArray, &pdAclMap);
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close acl map");
-
-            pdacl = pdacl->next;
-        }
-        //clsoe the array
-        cborEncoderResult = cbor_encoder_close_container(&pconfMap, &pdAclArray);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close acl array");
-    }
-
-    //PDDev -- Mandatory
-    //There may not be paired devices if it did not pairing before
-    if (pconf->pddevs && 0 < pconf->pddevLen)
-    {
-        CborEncoder pddev;
-        cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PDDEV_LIST_NAME,
-                strlen(OIC_JSON_PDDEV_LIST_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode pddev");
-        cborEncoderResult = cbor_encoder_create_array(&pconfMap, &pddev,  pconf->pddevLen);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create array");
-
-        for (size_t i = 0; i < pconf->pddevLen; i++)
-        {
-            char *pddevId = NULL;
-            ret = ConvertUuidToStr(&pconf->pddevs[i], &pddevId);
-            VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-            cborEncoderResult = cbor_encode_text_string(&pddev, pddevId, strlen(pddevId));
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding pddev Id Value.");
-            OICFree(pddevId);
-        }
-        cborEncoderResult = cbor_encoder_close_container(&pconfMap, &pddev);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close pddev array");
-    }
-
-    //DeviceId -- Mandatory
-    //There may not be devicd id if caller is provisoning tool
-    cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_DEVICE_ID_NAME,
-            strlen(OIC_JSON_DEVICE_ID_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode device id");
-    {
-        char *deviceId = NULL;
-        ret = ConvertUuidToStr(&pconf->deviceID, &deviceId);
-        VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-        cborEncoderResult = cbor_encode_text_string(&pconfMap, deviceId, strlen(deviceId));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode deviceID value");
-        OICFree(deviceId);
-    }
-
-    //ROwner -- Mandatory
-    {
-        char *rowner = NULL;
-        cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_ROWNERID_NAME,
-                strlen(OIC_JSON_ROWNERID_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rowner string");
-        ret = ConvertUuidToStr(&pconf->rownerID, &rowner);
-        VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-        cborEncoderResult = cbor_encode_text_string(&pconfMap, rowner, strlen(rowner));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rwoner value");
-        OICFree(rowner);
-    }
-
-    cborEncoderResult = cbor_encoder_close_container(&encoder, &pconfMap);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close pconfMap");
-
-    *size = cbor_encoder_get_buffer_size(&encoder, outPayload);
-    *payload = outPayload;
-    ret = OC_STACK_OK;
-exit:
-    if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE))
-    {
-        // reallocate and try again!
-        OICFree(outPayload);
-        // Since the allocated initial memory failed, double the memory.
-        cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
-        cborEncoderResult = CborNoError;
-        ret = PconfToCBORPayload(pconf, payload, &cborLen);
-        *size = cborLen;
-    }
-    if ((CborNoError != cborEncoderResult) || (OC_STACK_OK != ret))
-    {
-        OICFree(outPayload);
-        outPayload = NULL;
-        *payload = NULL;
-        *size = 0;
-        ret = OC_STACK_ERROR;
-    }
-    return ret;
-}
-
-OCStackResult CBORPayloadToPconf(const uint8_t *cborPayload, size_t size, OicSecPconf_t **secPconf)
-{
-    if (NULL == cborPayload || NULL == secPconf || NULL != *secPconf || 0 == size)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-    OCStackResult ret = OC_STACK_ERROR;
-    *secPconf = NULL;
-    CborValue pconfCbor = { .parser = NULL };
-    CborParser parser = { .end = NULL };
-    CborError cborFindResult = CborNoError;
-
-    cbor_parser_init(cborPayload, size, 0, &parser, &pconfCbor);
-    CborValue pconfMap = { .parser = NULL } ;
-    OicSecPconf_t *pconf = NULL;
-    cborFindResult = cbor_value_enter_container(&pconfCbor, &pconfMap);
-    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter map");
-    pconf = (OicSecPconf_t *)OICCalloc(1, sizeof(*pconf));
-    VERIFY_NOT_NULL(TAG, pconf, ERROR);
-    while (cbor_value_is_valid(&pconfMap))
-    {
-        char *name = NULL;
-        size_t len = 0;
-        CborType type = cbor_value_get_type(&pconfMap);
-        if (type == CborTextStringType && cbor_value_is_text_string(&pconfMap))
-        {
-            cborFindResult = cbor_value_dup_text_string(&pconfMap, &name, &len, NULL);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-            cborFindResult = cbor_value_advance(&pconfMap);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance value");
-        }
-
-        if (name)
-        {
-            //EDP -- Mandatory
-            if(0 == strcmp(OIC_JSON_EDP_NAME, name) && cbor_value_is_boolean(&pconfMap))
-            {
-                cborFindResult = cbor_value_get_boolean(&pconfMap, &pconf->edp);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-            }
-            if (0 == strcmp(OIC_JSON_PRM_NAME, name))
-            {
-                int i = 0;
-                CborValue prm = { .parser = NULL };
-                cborFindResult = cbor_value_get_array_length(&pconfMap, &pconf->prmLen);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get length");
-                VERIFY_SUCCESS(TAG, pconf->prmLen != 0, ERROR);
-
-                pconf->prm = (OicSecPrm_t *)OICCalloc(pconf->prmLen, sizeof(OicSecPrm_t));
-                VERIFY_NOT_NULL(TAG, pconf->prm, ERROR);
-                cborFindResult = cbor_value_enter_container(&pconfMap, &prm);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to eneter array");
-
-                while (cbor_value_is_valid(&prm) && cbor_value_is_integer(&prm))
-                {
-                    int prm_val;
-
-                    cborFindResult = cbor_value_get_int(&prm, &prm_val);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-                    pconf->prm[i++] = (OicSecPrm_t)prm_val;
-                    cborFindResult = cbor_value_advance(&prm);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance value");
-                }
-            }
-            //PIN -- Mandatory
-            if (0 == strcmp(OIC_JSON_PIN_NAME, name) && cbor_value_is_byte_string(&pconfMap))
-            {
-                uint8_t *pin = NULL;
-                cborFindResult = cbor_value_dup_byte_string(&pconfMap, &pin, &len, NULL);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-                if (sizeof(pconf->pin.val) < len)
-                {
-                    OIC_LOG (ERROR, TAG, "PIN length is too long");
-                    goto exit;
-                }
-                memcpy(pconf->pin.val, pin, len);
-                OICFree(pin);
-            }
-
-            //PDACL -- Mandatory
-            if (0 == strcmp(OIC_JSON_PDACL_NAME, name))
-            {
-                CborValue pdAclArray = { .parser = NULL};
-                OicSecPdAcl_t *headPdacl = NULL;
-
-                cborFindResult = cbor_value_enter_container(&pconfMap, &pdAclArray);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter");
-
-                while (cbor_value_is_valid(&pdAclArray))
-                {
-                    CborValue pdAclMap = { .parser = NULL };
-                    OicSecPdAcl_t *pdacl = (OicSecPdAcl_t *) OICCalloc(1, sizeof(OicSecPdAcl_t));
-                    VERIFY_NOT_NULL(TAG, pdacl, ERROR);
-
-                    cborFindResult = cbor_value_enter_container(&pdAclArray, &pdAclMap);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter");
-
-                    while (cbor_value_is_valid(&pdAclMap))
-                    {
-                        char* pdAclMapName = NULL;
-                        size_t tempLen = 0;
-                        CborType pdAclMapType = cbor_value_get_type(&pdAclMap);
-                        if ((pdAclMapType == CborTextStringType) && cbor_value_is_text_string(&pdAclMap))
-                        {
-                            cborFindResult = cbor_value_dup_text_string(&pdAclMap, &pdAclMapName,
-                                    &tempLen, NULL);
-                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get text");
-                            cborFindResult = cbor_value_advance(&pdAclMap);
-                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance value");
-                        }
-                        if (pdAclMapName)
-                        {
-                            // Resources -- Mandatory
-                            if (strcmp(pdAclMapName, OIC_JSON_RESOURCES_NAME) == 0 && cbor_value_is_array(&pdAclMap))
-                            {
-                                int i = 0;
-                                CborValue resources = { .parser = NULL };
-                                cborFindResult = cbor_value_get_array_length(&pdAclMap,
-                                        &pdacl->resourcesLen);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get length");
-                                cborFindResult = cbor_value_enter_container(&pdAclMap, &resources);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter");
-                                pdacl->resources = (char **) OICCalloc(pdacl->resourcesLen,
-                                        sizeof(char*));
-                                VERIFY_NOT_NULL(TAG, pdacl->resources, ERROR);
-
-                                while (cbor_value_is_valid(&resources))
-                                {
-                                    CborValue rMap = { .parser = NULL  };
-                                    cborFindResult = cbor_value_enter_container(&resources, &rMap);
-                                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering Resource Map");
-
-                                    while(cbor_value_is_valid(&rMap) && cbor_value_is_text_string(&rMap))
-                                    {
-                                        char *rMapName = NULL;
-                                        size_t rMapNameLen = 0;
-                                        cborFindResult = cbor_value_dup_text_string(&rMap, &rMapName, &rMapNameLen, NULL);
-                                        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RMap Data Name Tag.");
-                                        cborFindResult = cbor_value_advance(&rMap);
-                                        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RMap Data Value.");
-
-                                        // "href"
-                                        if (0 == strcmp(OIC_JSON_HREF_NAME, rMapName))
-                                        {
-                                            // TODO : Need to check data structure of OicSecPdAcl_t based on RAML spec.
-                                            cborFindResult = cbor_value_dup_text_string(&rMap, &pdacl->resources[i++], &tempLen, NULL);
-                                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Href Value.");
-                                        }
-
-                                        // "rel"
-                                        if (0 == strcmp(OIC_JSON_REL_NAME, rMapName))
-                                        {
-                                            // TODO : Need to check data structure of OicSecPdAcl_t and assign based on RAML spec.
-                                            char *relData = NULL;
-                                            cborFindResult = cbor_value_dup_text_string(&rMap, &relData, &len, NULL);
-                                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding REL Value.");
-                                            OICFree(relData);
-                                        }
-
-                                        // "rt"
-                                        if (0 == strcmp(OIC_JSON_RT_NAME, rMapName))
-                                        {
-                                            // TODO : Need to check data structure of OicSecPdAcl_t and assign based on RAML spec.
-                                            char *rtData = NULL;
-                                            cborFindResult = cbor_value_dup_text_string(&rMap, &rtData, &tempLen, NULL);
-                                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RT Value.");
-                                            OICFree(rtData);
-                                        }
-
-                                        // "if"
-                                        if (0 == strcmp(OIC_JSON_IF_NAME, rMapName))
-                                        {
-                                            // TODO : Need to check data structure of OicSecPdAcl_t and assign based on RAML spec.
-                                            char *ifData = NULL;
-                                            cborFindResult = cbor_value_dup_text_string(&rMap, &ifData, &tempLen, NULL);
-                                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding IF Value.");
-                                            OICFree(ifData);
-                                        }
-
-                                        if (cbor_value_is_valid(&rMap))
-                                        {
-                                            cborFindResult = cbor_value_advance(&rMap);
-                                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Rlist Map.");
-                                        }
-                                        OICFree(rMapName);
-                                    }
-
-                                    if (cbor_value_is_valid(&resources))
-                                    {
-                                        cborFindResult = cbor_value_advance(&resources);
-                                        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-                                    }
-                                }
-                            }
-
-                            // Permissions -- Mandatory
-                            if (strcmp(pdAclMapName, OIC_JSON_PERMISSION_NAME) == 0 && cbor_value_is_unsigned_integer(&pdAclMap))
-                            {
-                                uint64_t permission = 0;
-                                cborFindResult = cbor_value_get_uint64(&pdAclMap, &permission);
-                                pdacl->permission = (uint16_t)permission;
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-                            }
-
-                            // Period -- Not mandatory
-                            if (strcmp(pdAclMapName, OIC_JSON_PERIODS_NAME) == 0 && cbor_value_is_array(&pdAclMap))
-                            {
-                                int i = 0;
-                                CborValue period = { .parser = NULL };
-                                cborFindResult = cbor_value_get_array_length(&pdAclMap,
-                                        &pdacl->prdRecrLen);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get length");
-                                cborFindResult = cbor_value_enter_container(&pdAclMap, &period);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter");
-                                pdacl->periods = (char **) OICCalloc(pdacl->prdRecrLen, sizeof(char*));
-                                VERIFY_NOT_NULL(TAG, pdacl->periods, ERROR);
-
-                                while (cbor_value_is_text_string(&period) && cbor_value_is_text_string(&period))
-                                {
-                                    cborFindResult = cbor_value_dup_text_string(&period,
-                                            &pdacl->periods[i++], &tempLen, NULL);
-                                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get text");
-                                    cborFindResult = cbor_value_advance(&period);
-                                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-                                    pdacl->prdRecrLen++;
-                                }
-                            }
-
-                            // Recurrence -- Not mandatory
-                            if (strcmp(pdAclMapName, OIC_JSON_RECURRENCES_NAME) == 0 && cbor_value_is_array(&pdAclMap))
-                            {
-                                int i = 0;
-                                CborValue recurrences = { .parser = NULL };
-                                cborFindResult = cbor_value_get_array_length(&pdAclMap, &pdacl->prdRecrLen);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get length");
-                                cborFindResult = cbor_value_enter_container(&pdAclMap, &recurrences);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter");
-                                pdacl->recurrences = (char **) OICCalloc(pdacl->prdRecrLen, sizeof(char*));
-                                VERIFY_NOT_NULL(TAG, pdacl->recurrences, ERROR);
-
-                                while (cbor_value_is_text_string(&recurrences) && cbor_value_is_text_string(&recurrences))
-                                {
-                                    cborFindResult = cbor_value_dup_text_string(&recurrences,
-                                            &pdacl->recurrences[i++], &tempLen, NULL);
-                                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-                                    cborFindResult = cbor_value_advance(&recurrences);
-                                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-                                }
-                            }
-                            if (pdAclMapType != CborMapType && cbor_value_is_valid(&pdAclMap))
-                            {
-                                cborFindResult = cbor_value_advance(&pdAclMap);
-                                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-                            }
-                        }
-                        if (cbor_value_is_valid(&pdAclArray))
-                        {
-                            cborFindResult = cbor_value_advance(&pdAclArray);
-                            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-                        }
-                        OICFree(pdAclMapName);
-                        pdAclMapName = NULL;
-                    }
-                    pdacl->next = NULL;
-                    if (headPdacl == NULL)
-                    {
-                        headPdacl = pdacl;
-                    }
-                    else
-                    {
-                        OicSecPdAcl_t *temp = headPdacl;
-                        while (temp->next)
-                        {
-                            temp = temp->next;
-                        }
-                        temp->next = pdacl;
-                    }
-                }
-                pconf->pdacls = headPdacl;
-            }
-
-            //PDDev -- Mandatory
-            if (strcmp(name, OIC_JSON_PDDEV_LIST_NAME) == 0 && cbor_value_is_array(&pconfMap))
-            {
-                int i = 0;
-                CborValue pddevs = { .parser = NULL };
-                cborFindResult = cbor_value_get_array_length(&pconfMap, &pconf->pddevLen);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get length");
-                cborFindResult = cbor_value_enter_container(&pconfMap, &pddevs);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter");
-
-                pconf->pddevs = (OicUuid_t *)OICMalloc(pconf->pddevLen * sizeof(OicUuid_t));
-                VERIFY_NOT_NULL(TAG, pconf->pddevs, ERROR);
-                while (cbor_value_is_valid(&pddevs) && cbor_value_is_text_string(&pddevs))
-                {
-                    char *pddev = NULL;
-                    cborFindResult = cbor_value_dup_text_string(&pddevs, &pddev, &len, NULL);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
-                    cborFindResult = cbor_value_advance(&pddevs);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-                    ret = ConvertStrToUuid(pddev, &pconf->pddevs[i++]);
-                    VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-                    OICFree(pddev);
-                }
-            }
-
-            //Mandatory - Device Id
-            if (0 == strcmp(OIC_JSON_DEVICE_ID_NAME, name) && cbor_value_is_text_string(&pconfMap))
-            {
-                char *deviceId = NULL;
-                cborFindResult = cbor_value_dup_text_string(&pconfMap, &deviceId, &len, NULL);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get deviceID");
-                ret = ConvertStrToUuid(deviceId, &pconf->deviceID);
-                VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-                OICFree(deviceId);
-            }
-
-            // ROwner -- Mandatory
-            if (0 == strcmp(OIC_JSON_ROWNERID_NAME, name) && cbor_value_is_text_string(&pconfMap))
-            {
-                char *rowner = NULL;
-                cborFindResult = cbor_value_dup_text_string(&pconfMap, &rowner, &len, NULL);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get rowner");
-                ret = ConvertStrToUuid(rowner, &pconf->rownerID);
-                VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-                OICFree(rowner);
-            }
-        }
-        if (CborMapType != type && cbor_value_is_valid(&pconfMap))
-        {
-            cborFindResult = cbor_value_advance(&pconfMap);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance");
-        }
-        OICFree(name);
-        name = NULL;
-    }
-    *secPconf=pconf;
-    ret = OC_STACK_OK;
-exit:
-    if (CborNoError != cborFindResult)
-    {
-        OIC_LOG (ERROR, TAG, "CBORPayloadToPconf failed");
-        DeletePconfBinData(pconf);
-        pconf = NULL;
-        *secPconf = NULL;
-        ret = OC_STACK_ERROR;
-    }
-    return ret;
-}
-
-static bool UpdatePersistentStorage(const OicSecPconf_t * pconf)
-{
-    bool ret = false;
-
-    // Convert PCONF data into Cborpayload for update to persistent storage
-    uint8_t *payload = NULL;
-    size_t size = 0;
-    if (OC_STACK_OK == PconfToCBORPayload(pconf, &payload, &size) && NULL !=payload)
-    {
-        if (OC_STACK_OK == UpdateSecureResourceInPS(OIC_JSON_PCONF_NAME, payload, size))
-        {
-            ret = true;
-        }
-        OICFree(payload);
-    }
-    return ret;
-}
-
-static OCEntityHandlerResult HandlePconfGetRequest (const OCEntityHandlerRequest * ehRequest)
-{
-    uint8_t* payload = NULL;
-    size_t size = 0;
-    const OicSecDoxm_t *m_doxm = NULL;
-    OCEntityHandlerResult ehRet = OC_EH_OK;
-
-    OicSecPconf_t pconf;
-    memset(&pconf, 0, sizeof(OicSecPconf_t));
-
-    OIC_LOG (DEBUG, TAG, "Pconf EntityHandle processing GET request");
-
-    m_doxm = GetDoxmResourceData();
-    if (NULL == m_doxm)
-    {
-      OIC_LOG (DEBUG, TAG, "Doxm resource Data is NULL");
-    }
-
-    if ((m_doxm) && (true == m_doxm->dpc))
-    {
-        //Making response elements for Get request
-        if( (true == gPconf->edp) &&
-            (gPconf->prm && 0 < gPconf->prmLen) &&
-            (0 < strlen((const char*)gPconf->deviceID.id)) &&
-            (0 < strlen((const char*)gPconf->rownerID.id)))
-        {
-            pconf.edp = true;
-            pconf.prm = gPconf->prm;
-            pconf.prmLen = gPconf->prmLen;
-            memcpy(&pconf.deviceID, &gPconf->deviceID, sizeof(OicUuid_t));
-            memcpy(&pconf.rownerID, &gPconf->rownerID, sizeof(OicUuid_t));
-            OIC_LOG (DEBUG, TAG, "PCONF - direct pairing enabled");
-        }
-        else if (false == gPconf->edp)
-        {
-            pconf.edp = false;
-            memcpy(&pconf.rownerID, &gPconf->rownerID, sizeof(OicUuid_t));
-            OIC_LOG (DEBUG, TAG, "PCONF - direct pairing disable");
-        }
-        else
-        {
-            ehRet= OC_EH_ERROR;
-            OIC_LOG (DEBUG, TAG, "PCONF - error");
-        }
-    }
-    else
-    {
-        OIC_LOG (DEBUG, TAG, "DPC == false : Direct-Pairing Disabled");
-    }
-
-
-    if (OC_STACK_OK != PconfToCBORPayload(gPconf, &payload, &size))
-    {
-        ehRet = OC_EH_ERROR;
-    }
-
-    if(OC_EH_OK == ehRet)
-    {
-        ehRet = (payload ? OC_EH_OK : OC_EH_ERROR);
-    }
-    else
-    {
-        OICFree(payload);
-        payload = NULL;
-        size = 0;
-    }
-
-    // Send response payload to request originator
-    if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, payload, size))
-    {
-        ehRet = OC_EH_ERROR;
-        OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandlePconfGetRequest");
-    }
-    OIC_LOG_V(DEBUG, TAG, "%s RetVal %d", __func__, ehRet);
-
-    OICFree(payload);
-    return ehRet;
-}
-
-static OCEntityHandlerResult HandlePconfPostRequest (const OCEntityHandlerRequest * ehRequest)
-{
-    OCEntityHandlerResult ehRet = OC_EH_OK;
-    OCStackResult res=OC_STACK_OK;
-    OicSecPconf_t* newPconf = NULL;
-
-    if (NULL != GetDoxmResourceData() && true == GetDoxmResourceData()->dpc)
-    {
-        // Convert CBOR PCONF data into binary. This will also validate the PCONF data received.
-        uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
-        size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
-
-        if(payload){
-            res = CBORPayloadToPconf(payload, size, &newPconf);
-        }
-    }
-    else
-    {
-        OIC_LOG (DEBUG, TAG, "DPC == false : Direct-Pairing Disabled");
-        ehRet = OC_EH_ERROR;
-    }
-
-    if (newPconf && res == OC_STACK_OK)
-    {
-        // Check if valid Post request
-        if ((true == newPconf->edp) && (0 < newPconf->prmLen) &&
-                DP_PIN_LENGTH == sizeof(newPconf->pin.val))
-        {
-            OicSecPrm_t *oldPrm = gPconf->prm;
-            OicSecPdAcl_t *oldPdacl = gPconf->pdacls;
-
-            // Update local PCONF with new PCONF
-            gPconf->edp = true;
-            memcpy(&gPconf->pin, &newPconf->pin, sizeof(OicDpPin_t));
-            gPconf->prm = newPconf->prm;
-            gPconf->prmLen = newPconf->prmLen;
-            gPconf->pdacls = newPconf->pdacls;
-            memcpy(&gPconf->rownerID, &newPconf->rownerID, sizeof(OicUuid_t));
-
-            // to delete old value(prm, pdacl)
-            newPconf->prm = oldPrm;
-            newPconf->pdacls = oldPdacl;
-        }
-        else if (false == newPconf->edp)
-        {
-            gPconf->edp = false;
-        }
-        else
-        {
-            ehRet = OC_EH_ERROR;
-        }
-
-        // Update storage
-        if(OC_EH_ERROR != ehRet && true == UpdatePersistentStorage(gPconf))
-        {
-            ehRet = OC_EH_CHANGED;
-        }
-
-        DeletePconfBinData(newPconf);
-    }
-    else
-    {
-        ehRet = OC_EH_ERROR;
-    }
-
-    // Send payload to request originator
-    if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
-    {
-        ehRet = OC_EH_ERROR;
-        OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandlePconfPostRequest");
-    }
-
-    OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
-    return ehRet;
-}
-
-/*
- * This internal method is the entity handler for PCONF resources and
- * will handle REST request (POST) for them.
- */
-OCEntityHandlerResult PconfEntityHandler (OCEntityHandlerFlag flag,
-                                        OCEntityHandlerRequest * ehRequest,
-                                        void* callbackParameter)
-{
-    OIC_LOG(DEBUG, TAG, "Received request PconfEntityHandler");
-    (void)callbackParameter;
-    OCEntityHandlerResult ehRet = OC_EH_ERROR;
-
-    if (!ehRequest)
-    {
-        return ehRet;
-    }
-
-    if (flag & OC_REQUEST_FLAG)
-    {
-        OIC_LOG (DEBUG, TAG, "Flag includes OC_REQUEST_FLAG");
-        switch (ehRequest->method)
-        {
-            case OC_REST_GET:
-                ehRet = HandlePconfGetRequest(ehRequest);
-                break;
-
-            case OC_REST_POST:
-                ehRet = HandlePconfPostRequest(ehRequest);
-                break;
-
-            case OC_REST_DELETE:
-                break;
-
-            default:
-                ehRet = OC_EH_ERROR;
-                SendSRMResponse(ehRequest, ehRet, NULL, 0);
-        }
-    }
-
-    return ehRet;
-}
-
-/*
- * This internal method is used to create '/oic/sec/pconf' resource.
- */
-OCStackResult CreatePconfResource()
-{
-    OCStackResult ret;
-
-    ret = OCCreateResource(&gPconfHandle,
-                           OIC_RSRC_TYPE_SEC_PCONF,
-                           OC_RSRVD_INTERFACE_DEFAULT,
-                           OIC_RSRC_PCONF_URI,
-                           PconfEntityHandler,
-                           NULL,
-                           OC_SECURE | OC_EXPLICIT_DISCOVERABLE);
-
-    if (OC_STACK_OK != ret)
-    {
-        OIC_LOG (ERROR, TAG, "Unable to instantiate PCONF resource");
-        DeInitPconfResource();
-    }
-    return ret;
-}
-
-/**
- * Get the default value.
- * @retval  the gDefaultPconf pointer;
- */
-static OicSecPconf_t* GetPconfDefault()
-{
-    OIC_LOG (DEBUG, TAG, "GetPconfDefault");
-
-    return &gDefaultPconf;
-}
-
-/**
- * This method is used by SRM to retrieve PCONF resource data..
- *
- * @retval  reference to @ref OicSecPconf_t, binary format of Pconf resource data
- */
-const OicSecPconf_t* GetPconfResourceData()
-{
-    return gPconf;
-}
-
-/**
- * Initialize PCONF resource by loading data from persistent storage.
- *
- * @retval  OC_STACK_OK for Success, otherwise some error value
- */
-OCStackResult InitPconfResource()
-{
-    OCStackResult ret = OC_STACK_ERROR;
-
-    uint8_t *data = NULL;
-    size_t size = 0;
-
-    ret = GetSecureVirtualDatabaseFromPS(OIC_JSON_PCONF_NAME, &data, &size);
-    // If database read failed
-    if (ret != OC_STACK_OK)
-    {
-        OIC_LOG(DEBUG, TAG, "ReadSVDataFromPS failed");
-    }
-    if (data)
-    {
-        CBORPayloadToPconf(data, size, &gPconf);
-    }
-
-    if (!data || !gPconf)
-    {
-        gPconf = GetPconfDefault();
-
-        // Device id from doxm
-        OicUuid_t deviceId = {.id = {0}};
-        ret = GetDoxmDeviceID(&deviceId);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-        memcpy(&gPconf->deviceID, &deviceId, sizeof(OicUuid_t));
-    }
-    VERIFY_NOT_NULL(TAG, gPconf, ERROR);
-
-    // Instantiate 'oic.sec.pconf'
-    ret = CreatePconfResource();
-
-exit:
-    if (OC_STACK_OK != ret)
-    {
-        DeInitPconfResource();
-    }
-    OICFree(data);
-    return ret;
-}
-
-/**
- * Perform cleanup for PCONF resources.
- *
- * @return
- * OC_STACK_OK    - no error
- * OC_STACK_ERROR - stack process error
- *
- */
-OCStackResult DeInitPconfResource()
-{
-    OCStackResult ret = OCDeleteResource(gPconfHandle);
-    if(gPconf!= &gDefaultPconf)
-    {
-        DeletePconfBinData(gPconf);
-    }
-    gPconf = NULL;
-
-    if(OC_STACK_OK == ret)
-    {
-        return OC_STACK_OK;
-    }
-    else
-    {
-        return OC_STACK_ERROR;
-    }
-}
-
-/**
- * This method might be used to add a paired device id after direct-pairing process complete.
- *
- * @param pdeviceId ID of the paired device.
- *
- * @retval  OC_STACK_OK for Success, otherwise some error value
- */
-OCStackResult AddPairedDevice(OicUuid_t *pdeviceId)
-{
-    if (!gPconf || !pdeviceId)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-
-
-    OicUuid_t *prevList = gPconf->pddevs;
-    gPconf->pddevs = (OicUuid_t *)OICCalloc(gPconf->pddevLen+1, sizeof(OicUuid_t));
-    if(!gPconf->pddevs)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-    for (size_t i=0; i<gPconf->pddevLen; i++)
-    {
-        memcpy(&gPconf->pddevs[i], &prevList[i], sizeof(OicUuid_t));
-    }
-
-    // add new paired device id
-    memcpy(&gPconf->pddevs[gPconf->pddevLen], pdeviceId, sizeof(OicUuid_t));
-    gPconf->pddevLen++;
-
-    // Update storage
-    if(true != UpdatePersistentStorage(gPconf))
-    {
-        OIC_LOG (ERROR, TAG, "Fail to update pconf resource");
-        return OC_STACK_ERROR;
-    }
-
-    OIC_LOG (ERROR, TAG, "Add paired device success");
-    return OC_STACK_OK;
-}
-
-/**
- * This method might be used by PolicyEngine to retrieve PDACL for a Subject.
- *
- * @param subjectId ID of the subject for which PDACL is required.
- * @param savePtr is used internally by @ref GetACLResourceData to maintain index between
- *                successive calls for same subjectId.
- *
- * @retval  reference to @ref OicSecPdAcl_t if PDACL is found, else NULL
- */
-const OicSecPdAcl_t* GetPdAclData(const OicUuid_t* subjectId, OicSecPdAcl_t **savePtr)
-{
-    OicSecPdAcl_t *pdacl = NULL;
-
-    if ( NULL == subjectId)
-    {
-        return NULL;
-    }
-
-    /*
-     * savePtr MUST point to NULL if this is the 'first' call to retrieve PDACL for
-     * subjectID.
-     */
-    if (NULL == *savePtr)
-    {
-        pdacl = gPconf->pdacls;
-
-        // Find if 'subjectID' is in paired device list.
-        for(size_t i=0; i<gPconf->pddevLen; i++)
-        {
-            if (memcmp(&(gPconf->pddevs[i]), subjectId, sizeof(OicUuid_t)) == 0)
-            {
-                *savePtr = pdacl;
-                return pdacl;
-            }
-        }
-    }
-    else
-    {
-        OicSecPdAcl_t *temp = NULL;
-
-        /*
-         * If this is a 'successive' call, search for location pointed by
-         * savePtr and assign 'begin' to the next PDACL after it in the linked
-         * list and start searching from there.
-         */
-        LL_FOREACH(gPconf->pdacls, temp)
-        {
-            if (temp == *savePtr)
-            {
-                pdacl = temp->next;
-                *savePtr = pdacl;
-                return pdacl;
-            }
-        }
-    }
-
-    // Cleanup in case no PDACL is found
-    *savePtr = NULL;
-    return NULL;
-}
-
-/**
- * This method return whether device is paired or not.
- *
- * @param pdeviceId Target device ID to find in paired list.
- * @retval  ture if device is already paired, else false
- */
-bool IsPairedDevice(const OicUuid_t* pdeviceId)
-{
-    // Find if 'pdeviceId' is in paired device list.
-    for(size_t i=0; i<gPconf->pddevLen; i++)
-    {
-        if (memcmp(&(gPconf->pddevs[i]), pdeviceId, sizeof(OicUuid_t)) == 0)
-        {
-            return true;
-        }
-    }
-    return false;
-}
-
-OCStackResult SetPconfRownerId(const OicUuid_t* newROwner)
-{
-    OCStackResult ret = OC_STACK_ERROR;
-    uint8_t *cborPayload = NULL;
-    size_t size = 0;
-    OicUuid_t prevId = {.id={0}};
-
-    if(NULL == newROwner)
-    {
-        ret = OC_STACK_INVALID_PARAM;
-    }
-    if(NULL == gPconf)
-    {
-        ret = OC_STACK_NO_RESOURCE;
-    }
-
-    if(newROwner && gPconf)
-    {
-        memcpy(prevId.id, gPconf->rownerID.id, sizeof(prevId.id));
-        memcpy(gPconf->rownerID.id, newROwner->id, sizeof(newROwner->id));
-
-        ret = PconfToCBORPayload(gPconf, &cborPayload, &size);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-
-        ret = UpdateSecureResourceInPS(OIC_JSON_PCONF_NAME, cborPayload, size);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-
-        OICFree(cborPayload);
-    }
-
-    return ret;
-
-exit:
-    OICFree(cborPayload);
-    memcpy(gPconf->rownerID.id, prevId.id, sizeof(prevId.id));
-    return ret;
-}
-
-OCStackResult GetPconfRownerId(OicUuid_t *rowneruuid)
-{
-    OCStackResult retVal = OC_STACK_ERROR;
-    if (gPconf)
-    {
-        *rowneruuid = gPconf->rownerID;
-        retVal = OC_STACK_OK;
-    }
-    return retVal;
-}
index 8684ed1..230f3bc 100644 (file)
@@ -32,8 +32,6 @@
 #include "doxmresource.h"
 #include "iotvticalendar.h"
 #include "pstatresource.h"
-#include "dpairingresource.h"
-#include "pconfresource.h"
 #include "amaclresource.h"
 #include "credresource.h"
 #include "rolesresource.h"
@@ -224,8 +222,8 @@ static GetSvrRownerId_t GetSvrRownerId[OIC_SEC_SVR_TYPE_COUNT + 1] = {
     GetCredRownerId,
     NULL,               // crl doesn't have rowneruuid.
     GetDoxmRownerId,
-    GetDpairingRownerId,
-    GetPconfRownerId,
+    NULL,               //Direct Pairing has been removed
+    NULL,                              //GetPconfRownerId,
     GetPstatRownerId,
     NULL,               // sacl is not implemented yet.
     NULL,               // svc has been removed from the OCF 1.0 Security spec.
index 02d208f..b7e6c6e 100644 (file)
@@ -249,7 +249,6 @@ OCStackResult UpdateResourceInPS(const char *databaseName, const char *resourceN
     uint8_t *doxmCbor = NULL;
     uint8_t *amaclCbor = NULL;
     uint8_t *credCbor = NULL;
-    uint8_t *pconfCbor = NULL;
     uint8_t *resetPfCbor = NULL;
     uint8_t *crlCbor = NULL;
     uint8_t *dpCbor = NULL;
@@ -265,7 +264,6 @@ OCStackResult UpdateResourceInPS(const char *databaseName, const char *resourceN
         size_t doxmCborLen = 0;
         size_t amaclCborLen = 0;
         size_t credCborLen = 0;
-        size_t pconfCborLen = 0;
         size_t resetPfCborLen = 0;
         size_t crlCborLen = 0;
         size_t dpCborLen = 0;
@@ -319,12 +317,6 @@ OCStackResult UpdateResourceInPS(const char *databaseName, const char *resourceN
                     cborFindResult = cbor_value_dup_byte_string(&curVal, &credCbor, &credCborLen, NULL);
                     VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CRED Name Value.");
                 }
-                cborFindResult = cbor_value_map_find_value(&cbor, OIC_JSON_PCONF_NAME, &curVal);
-                if ((CborNoError == cborFindResult) && cbor_value_is_byte_string(&curVal))
-                {
-                    cborFindResult = cbor_value_dup_byte_string(&curVal, &pconfCbor, &pconfCborLen, NULL);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding PCONF Name Value.");
-                }
                 cborFindResult = cbor_value_map_find_value(&cbor, OIC_JSON_RESET_PF_NAME, &curVal);
                 if ((CborNoError == cborFindResult) && cbor_value_is_byte_string(&curVal))
                 {
@@ -363,7 +355,7 @@ OCStackResult UpdateResourceInPS(const char *databaseName, const char *resourceN
             if (PS_DATABASE_SECURITY == database)
             {
                 allocSize = aclCborLen + pstatCborLen + doxmCborLen + amaclCborLen
-                          + credCborLen + pconfCborLen + resetPfCborLen + crlCborLen
+                          + credCborLen + /* pconfCborLen + */ resetPfCborLen + crlCborLen
                           + size + CBOR_ENCODING_SIZE_ADDITION;
             }
             else
@@ -431,13 +423,6 @@ OCStackResult UpdateResourceInPS(const char *databaseName, const char *resourceN
                     cborEncoderResult |= cbor_encode_byte_string(&resource, credCbor, credCborLen);
                     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Cred Value.");
                 }
-                if (strcmp(OIC_JSON_PCONF_NAME, resourceName) && pconfCborLen)
-                {
-                    cborEncoderResult |= cbor_encode_text_string(&resource, OIC_JSON_PCONF_NAME, strlen(OIC_JSON_PCONF_NAME));
-                    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Pconf Name.");
-                    cborEncoderResult |= cbor_encode_byte_string(&resource, pconfCbor, pconfCborLen);
-                    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Pconf Value.");
-                }
                 if (strcmp(OIC_JSON_RESET_PF_NAME, resourceName) && resetPfCborLen)
                 {
                     cborEncoderResult |= cbor_encode_text_string(&resource, OIC_JSON_RESET_PF_NAME, strlen(OIC_JSON_RESET_PF_NAME));
@@ -505,7 +490,6 @@ exit:
     OICFree(doxmCbor);
     OICFree(amaclCbor);
     OICFree(credCbor);
-    OICFree(pconfCbor);
     OICFree(resetPfCbor);
     OICFree(crlCbor);
     OICFree(dpCbor);
index a822378..1030c28 100644 (file)
 #include "utlist.h"
 #include "psinterface.h"
 
-//#ifdef DIRECT_PAIRING
-#include "pconfresource.h"
-#include "dpairingresource.h"
-//#endif // DIRECT_PAIRING
 
 #define TAG "OIC_SRM_RM"
 
@@ -115,16 +111,6 @@ OCStackResult InitSecureResources( )
         ret = InitAmaclResource();
     }
 #endif // AMACL_RESOURCE_IMPLEMENTATION_COMPLETE
-//#ifdef DIRECT_PAIRING
-    if(OC_STACK_OK == ret)
-    {
-        ret = InitPconfResource();
-    }
-    if(OC_STACK_OK == ret)
-    {
-        ret = InitDpairingResource();
-    }
-//#endif // DIRECT_PAIRING
     if(OC_STACK_OK != ret)
     {
         //TODO: Update the default behavior if one of the SVR fails
@@ -147,10 +133,6 @@ OCStackResult DestroySecureResources( )
     DeInitRolesResource();
 #endif // __WITH_DTLS__ || __WITH_TLS__
     DeInitAmaclResource();
-//#ifdef DIRECT_PAIRING
-    DeInitPconfResource();
-    DeInitDpairingResource();
-//#endif // DIRECT_PAIRING
 
     OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
 
index e50219f..545181a 100644 (file)
@@ -464,8 +464,6 @@ bool SRMIsSecurityResourceURI(const char* uri)
         OIC_RSRC_ACL2_URI,
         OIC_RSRC_DOXM_URI,
         OIC_RSRC_PSTAT_URI,
-        OIC_RSRC_PCONF_URI,
-        OIC_RSRC_DPAIRING_URI,
         OIC_RSRC_VER_URI,
         OIC_RSRC_ROLES_URI,
         OC_RSRVD_PROV_CRL_URL
@@ -584,24 +582,6 @@ OicSecSvrType_t GetSvrTypeFromUri(const char* uri)
         }
     }
 
-    svrLen = strlen(OIC_RSRC_DPAIRING_URI);
-    if (uriLen == svrLen)
-    {
-        if (0 == strncmp(uri, OIC_RSRC_DPAIRING_URI, svrLen))
-        {
-            return OIC_R_DPAIRING_TYPE;
-        }
-    }
-
-    svrLen = strlen(OIC_RSRC_PCONF_URI);
-    if (uriLen == svrLen)
-    {
-        if (0 == strncmp(uri, OIC_RSRC_PCONF_URI, svrLen))
-        {
-            return OIC_R_PCONF_TYPE;
-        }
-    }
-
     svrLen = strlen(OIC_RSRC_PSTAT_URI);
     if (uriLen == svrLen)
     {
index 19e4398..aa3a1b1 100644 (file)
@@ -85,16 +85,6 @@ const char * OIC_RSRC_TYPE_SEC_SVC = "oic.r.svc";
 const char * OIC_RSRC_SVC_URI =  "/oic/sec/svc";
 const char * OIC_JSON_SVC_NAME = "svc";
 
-//pconf
-const char * OIC_RSRC_TYPE_SEC_PCONF = "oic.r.pconf";
-const char * OIC_RSRC_PCONF_URI =  "/oic/sec/pconf";
-const char * OIC_JSON_PCONF_NAME = "pconf";
-
-//dpairing
-const char * OIC_RSRC_TYPE_SEC_DPAIRING = "oic.r.dpairing";
-const char * OIC_RSRC_DPAIRING_URI =  "/oic/sec/dpairing";
-const char * OIC_JSON_DPAIRING_NAME = "dpairing";
-
 //version
 const char * OIC_RSRC_TYPE_SEC_VER = "oic.r.ver";
 const char * OIC_RSRC_VER_URI =  "/oic/sec/ver";
index 6c81321..1e103be 100644 (file)
@@ -99,7 +99,6 @@ unittest = srmtest_env.Program('unittest', [
     'base64tests.cpp',
     'pbkdf2tests.cpp',
     'srmtestcommon.cpp',
-    'directpairingtest.cpp',
     'crlresourcetest.cpp'
 ])
 
diff --git a/resource/csdk/security/unittest/directpairingtest.cpp b/resource/csdk/security/unittest/directpairingtest.cpp
deleted file mode 100644 (file)
index c99b928..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-//******************************************************************
-//
-// Copyright 2016 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include <gtest/gtest.h>
-#include "directpairing.h"
-
-using namespace std;
-
-#define TAG  "DIRECTPAIRING-UT"
-
-static OCDirectPairingDev_t peer;
-static OicSecPrm_t pmSel;
-static char pinNumber;
-
-static void ResultCB(void *UNUSED1, OCDirectPairingDev_t *UNUSED2, OCStackResult UNUSED3)
-{
-    //dummy callback
-    (void) UNUSED1;
-    (void) UNUSED2;
-    (void) UNUSED3;
-}
-
-TEST(DPDirectPairingTest, NullPeer)
-{
-    EXPECT_EQ(OC_STACK_INVALID_PARAM, DPDirectPairing(NULL, NULL, pmSel, &pinNumber, &ResultCB));
-}
-
-TEST(DPDirectPairingTest, NullPinNumber)
-{
-    EXPECT_EQ(OC_STACK_INVALID_PARAM, DPDirectPairing(NULL, &peer, pmSel, NULL, &ResultCB));
-}
-
index 7a94b8c..bb088ed 100644 (file)
@@ -643,42 +643,6 @@ OCStackResult OC_CALL OCNotifyListOfObservers (OCResourceHandle handle,
  */
 OCStackResult OC_CALL OCDoResponse(OCEntityHandlerResponse *response);
 
-//#ifdef DIRECT_PAIRING
-/**
- * The function is responsible for discovery of direct-pairing device is current subnet. It will list
- * all the device in subnet which support direct-pairing.
- * Caller must NOT free returned constant pointer
- *
- * @param[in] waittime Timeout in seconds, value till which function will listen to responses from
- *                     client before returning the list of devices.
- * @return OCDirectPairingDev_t pointer in case of success and NULL otherwise.
- */
-const OCDPDev_t* OC_CALL OCDiscoverDirectPairingDevices(unsigned short waittime);
-
-/**
- * The function is responsible for return of paired device list via direct-pairing. It will list
- * all the device which is previousely paired with client.
- * Caller must NOT free returned constant pointer
- *
- * @return OCDirectPairingDev_t pointer in case of success and NULL otherwise.
- */
-const OCDPDev_t* OC_CALL OCGetDirectPairedDevices();
-
-/**
- * The function is responsible for establishment of direct-pairing. It will proceed mode negotiation
- * and connect PIN based dtls session.
- *
- * @param[in] ctx user context passed back with resultCallback.
- * @param[in] peer Target device to establish direct-pairing.
- * @param[in] pmSel Selected mode of pairing.
- * @param[in] pinNumber PIN number for authentication, pin lenght is defined DP_PIN_LENGTH(8).
- * @param[in] resultCallback Callback fucntion to event status of process.
- * @return OTM_SUCCESS in case of success and other value otherwise.
- */
-OCStackResult OC_CALL OCDoDirectPairing(void *ctx, OCDPDev_t* peer, OCPrm_t pmSel, char *pinNumber,
-                                OCDirectPairingCB resultCallback);
-//#endif // DIRECT_PAIRING
-
 /**
  * This function sets uri being used for proxy.
  *
index f040360..0d73f32 100644 (file)
@@ -29,7 +29,6 @@ OCCreateResourceWithEp
 OCDeleteResource
 OCDiagnosticPayloadCreate
 OCDiagnosticPayloadDestroy
-OCDiscoverDirectPairingDevices
 OCDiscoveryEndpointDestroy
 OCDiscoveryPayloadAddResource
 OCDiscoveryPayloadAddNewResource
@@ -38,7 +37,6 @@ OCDiscoveryPayloadDestroy
 OCDiscoveryPayloadGetResource
 OCDiscoveryPayloadGetResourceCount
 OCDiscoveryResourceDestroy
-OCDoDirectPairing
 OCDoResource
 OCDoResponse
 OCDoRequest
@@ -48,7 +46,6 @@ OCEndpointPayloadGetEndpointCount
 OCFreeOCStringLL
 OCGetDeviceId
 OCGetDeviceOwnedState
-OCGetDirectPairedDevices
 OCGetHeaderOption
 OCGetIpv6AddrScope
 OCGetNumberOfResources
index 2ba3693..9b3f8c3 100644 (file)
@@ -6,7 +6,6 @@ OCConfigSelfOwnership
 OCConvertDerCSRToPem
 OCDeleteACLList
 OCDeleteDiscoveredDevices
-OCDeletePdAclList
 OCDeleteRoleCertificateByCredId
 OCDeleteUuidList
 OCDiscoverOwnedDevices
@@ -35,7 +34,6 @@ OCProvisionACL
 OCSaveACL
 OCProvisionCertificate
 OCProvisionCredentials
-OCProvisionDirectPairing
 OCProvisionPairwiseDevices
 OCProvisionSymmetricRoleCredentials
 OCProvisionTrustCertChain
index c1af966..c03a335 100644 (file)
@@ -76,10 +76,6 @@ occlientbasicops = samples_env.Program(
 ocamsservice = samples_env.Program(
     'ocamsservice', ['common.cpp', 'ocamsservice.cpp'])
 ocsamples = [ocserverbasicops, occlientbasicops, ocamsservice]
-if samples_env.get('SECURED') == '1':
-    occlientdirectpairing = samples_env.Program(
-        'occlientdirectpairing', 'occlientdirectpairing.cpp')
-    ocsamples.append(occlientdirectpairing)
 Alias("samples", ocsamples)
 samples_env.AppendTarget('samples')
 
@@ -104,17 +100,6 @@ samples_env.Alias(
     "install",
     samples_env.Install(sec_samples_build_dir,
                         sec_samples_src_dir + 'oic_amss_db.json'))
-if samples_env.get('SECURED') == '1':
-    samples_env.Alias(
-        "install",
-        samples_env.Install(
-            sec_samples_build_dir,
-            sec_samples_src_dir + 'oic_svr_db_client_directpairing.json'))
-    samples_env.Alias(
-        "install",
-        samples_env.Install(
-            sec_samples_build_dir,
-            sec_samples_src_dir + 'oic_svr_db_client_directpairing.dat'))
 
 samples_env.Alias(
     "install",
diff --git a/resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp b/resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp
deleted file mode 100644 (file)
index 776a695..0000000
+++ /dev/null
@@ -1,662 +0,0 @@
-//******************************************************************\r
-//\r
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the "License");\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//      http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-\r
-#include "iotivity_config.h"\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <signal.h>\r
-#ifdef HAVE_UNISTD_H\r
-#include <unistd.h>\r
-#endif\r
-#ifdef HAVE_PTHREAD_H\r
-#include <pthread.h>\r
-#endif\r
-#include <iostream>\r
-#include <sstream>\r
-#if defined(HAVE_WINDOWS_H)\r
-#include <windows.h>\r
-/** @todo stop-gap for naming issue. Windows.h does not like us to use ERROR */\r
-#ifdef ERROR\r
-#undef ERROR\r
-#endif\r
-#endif // defined(HAVE_WINDOWS_H)\r
-#include "ocstack.h"\r
-#include "logger.h"\r
-#include "ocpayload.h"\r
-#include "payload_logging.h"\r
-#include "oic_malloc.h"\r
-#include "oic_string.h"\r
-#include "utlist.h"\r
-\r
-#define TAG "occlient-directpairing"\r
-\r
-#define BOLD_BEGIN    "\033[1m"\r
-#define RED_BEGIN      "\033[1;31m"\r
-#define GREEN_BEGIN  "\033[1;92m"\r
-#define COLOR_END      "\033[0m"\r
-#define MAX_LINE (1024)\r
-#define DP_DISCOVERY_TIMEOUT   3  // 3 sec\r
-#define DP_PIN_LENGTH 8 // 8 digit\r
-\r
-static char DISCOVERY_QUERY[] = "%s/oic/res";\r
-\r
-//Secure Virtual Resource database for Iotivity Client application\r
-//It contains Client's Identity and the PSK credentials\r
-//of other devices which the client trusts\r
-static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";\r
-\r
-static const OCDPDev_t *discoveredDevs = NULL;\r
-static const OCDPDev_t *pairedDevs = NULL;\r
-\r
-int gQuitFlag = 0;\r
-\r
-//-----------------------------------------------------------------------------\r
-// Function prototype\r
-//-----------------------------------------------------------------------------\r
-\r
-\r
-\r
-\r
-//-----------------------------------------------------------------------------\r
-// Function body\r
-//-----------------------------------------------------------------------------\r
-\r
-/* SIGINT handler: set gQuitFlag to 1 for graceful termination */\r
-void handleSigInt(int signum)\r
-{\r
-    if (signum == SIGINT)\r
-    {\r
-        gQuitFlag = 1;\r
-    }\r
-}\r
-\r
-const char *readline(const char *in, const char *defaultStr)\r
-{\r
-    static char rbuffer[MAX_LINE] = {0,};\r
-    char *cptr, *p;\r
-\r
-    size_t in_len = strlen(in);\r
-    for (size_t i=0; i<in_len; i++)\r
-    {\r
-        fprintf(stdout, "%c", in[i]);\r
-    }\r
-\r
-    if (NULL != (cptr = fgets(rbuffer, MAX_LINE, stdin)))\r
-    {\r
-        /* kill preceding whitespace but leave \n so we're guaranteed to have something */\r
-        /*while(*cptr == ' ' || *cptr == '\t')\r
-        {\r
-            cptr++;\r
-        }*/\r
-\r
-        if ( (p = strchr(cptr, '\n')) != NULL )\r
-        {\r
-            *p = '\0';\r
-        }\r
-\r
-        if (strlen(cptr)==0 && defaultStr)\r
-        {\r
-            return defaultStr;\r
-        }\r
-        return cptr;\r
-    }\r
-    else\r
-    {\r
-        return 0;\r
-    }\r
-}\r
-\r
-const char *getResult(OCStackResult result) {\r
-    switch (result) {\r
-    case OC_STACK_OK:\r
-        return "OC_STACK_OK";\r
-    case OC_STACK_RESOURCE_CREATED:\r
-        return "OC_STACK_RESOURCE_CREATED";\r
-    case OC_STACK_RESOURCE_DELETED:\r
-        return "OC_STACK_RESOURCE_DELETED";\r
-    case OC_STACK_INVALID_URI:\r
-        return "OC_STACK_INVALID_URI";\r
-    case OC_STACK_INVALID_QUERY:\r
-        return "OC_STACK_INVALID_QUERY";\r
-    case OC_STACK_INVALID_IP:\r
-        return "OC_STACK_INVALID_IP";\r
-    case OC_STACK_INVALID_PORT:\r
-        return "OC_STACK_INVALID_PORT";\r
-    case OC_STACK_INVALID_CALLBACK:\r
-        return "OC_STACK_INVALID_CALLBACK";\r
-    case OC_STACK_INVALID_METHOD:\r
-        return "OC_STACK_INVALID_METHOD";\r
-    case OC_STACK_NO_MEMORY:\r
-        return "OC_STACK_NO_MEMORY";\r
-    case OC_STACK_COMM_ERROR:\r
-        return "OC_STACK_COMM_ERROR";\r
-    case OC_STACK_INVALID_PARAM:\r
-        return "OC_STACK_INVALID_PARAM";\r
-    case OC_STACK_NOTIMPL:\r
-        return "OC_STACK_NOTIMPL";\r
-    case OC_STACK_NO_RESOURCE:\r
-        return "OC_STACK_NO_RESOURCE";\r
-    case OC_STACK_RESOURCE_ERROR:\r
-        return "OC_STACK_RESOURCE_ERROR";\r
-    case OC_STACK_SLOW_RESOURCE:\r
-        return "OC_STACK_SLOW_RESOURCE";\r
-    case OC_STACK_NO_OBSERVERS:\r
-        return "OC_STACK_NO_OBSERVERS";\r
-    #ifdef WITH_PRESENCE\r
-    case OC_STACK_PRESENCE_STOPPED:\r
-        return "OC_STACK_PRESENCE_STOPPED";\r
-    #endif\r
-    case OC_STACK_ERROR:\r
-        return "OC_STACK_ERROR";\r
-    default:\r
-        return "UNKNOWN";\r
-    }\r
-}\r
-\r
-OCDPDev_t* getDev(const OCDPDev_t* pList, const uint32_t dev_num)\r
-{\r
-    if(NULL == pList)\r
-    {\r
-        printf("     Device List is Empty..\n");\r
-        return NULL;\r
-    }\r
-\r
-    OCDPDev_t* lst =  (OCDPDev_t*)pList;\r
-    for(size_t i=0; lst; )\r
-    {\r
-        if(dev_num == ++i)\r
-        {\r
-            return lst;\r
-        }\r
-        lst = lst->next;\r
-    }\r
-\r
-    return NULL;  // in here |lst| is always |NULL|\r
-}\r
-\r
-int printList(const OCDPDev_t* pList)\r
-{\r
-    if(!pList)\r
-    {\r
-        printf("     Device List is Empty..\n\n");\r
-        return 0;\r
-    }\r
-\r
-    const OCDPDev_t* lst = pList;\r
-    int lst_cnt = 0;\r
-    for( ; lst; )\r
-    {\r
-        printf("     [%d] ", ++lst_cnt);\r
-        for(int i=0; i<UUID_IDENTITY_SIZE; i++)\r
-        {\r
-            fprintf(stdout, "%c", (char)lst->deviceID.id[i]);\r
-        }\r
-        printf("\n");\r
-        lst = lst->next;\r
-    }\r
-    printf("\n");\r
-\r
-    return lst_cnt;\r
-}\r
-\r
-bool printPairingMethod(const OCDPDev_t* pDev)\r
-{\r
-    printf("\n   * List of supported pairing method\n");\r
-\r
-    if(!pDev || false == pDev->edp)\r
-    {\r
-        printf("     Invalid device or Not support direct-pairing..\n\n");\r
-        return false;\r
-    }\r
-\r
-    if(!pDev->prm || 0 == pDev->prmLen)\r
-    {\r
-        printf("     Not exist any support method..\n\n");\r
-        return false;\r
-    }\r
-\r
-    bool bAvailable = true;\r
-    for (size_t i = 0; i < pDev->prmLen; i++)\r
-    {\r
-        printf("     [%" PRIuPTR "] ", i + 1);\r
-        switch (pDev->prm[i])\r
-        {\r
-            case DP_PRE_CONFIGURED:\r
-                printf("Pre-Configured PIN");\r
-                break;\r
-            case DP_RANDOM_PIN:\r
-                printf("Random PIN");\r
-                break;\r
-            default:\r
-                printf("NOT Allowed (%d)", pDev->prm[i]);\r
-                bAvailable = false;\r
-                break;\r
-        }\r
-        printf("\n");\r
-    }\r
-    printf("\n");\r
-\r
-    return bAvailable;\r
-}\r
-\r
-// This is a function called back when a device is discovered\r
-OCStackApplicationResult discoveryReqCB(void*, OCDoHandle,\r
-        OCClientResponse * clientResponse)\r
-{\r
-    OIC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");\r
-\r
-    if (clientResponse)\r
-    {\r
-        OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));\r
-        OIC_LOG_V(INFO, TAG,\r
-                "Device =============> Discovered @ %s:%d",\r
-                clientResponse->devAddr.addr,\r
-                clientResponse->devAddr.port);\r
-\r
-        if (clientResponse->result == OC_STACK_OK)\r
-        {\r
-            OIC_LOG_PAYLOAD(INFO, clientResponse->payload);\r
-        }\r
-    }\r
-\r
-    return OC_STACK_DELETE_TRANSACTION;\r
-\r
-}\r
-\r
-// This is a function called back when direct-pairing status is changed\r
-void pairingReqCB(void *ctx, OCDPDev_t* peer, OCStackResult result)\r
-{\r
-    OIC_LOG(INFO, TAG, "Callback Context for Direct-Pairing establishment\n");\r
-\r
-    (void) ctx;\r
-    if (OC_STACK_OK == result)\r
-    {\r
-        OIC_LOG_V(INFO, TAG,\r
-                "Direct-Pairing SUCCESS =============> Target @ %s:%d\n",\r
-                peer->endpoint.addr,\r
-                peer->endpoint.port);\r
-    }\r
-    else\r
-    {\r
-        OIC_LOG(ERROR, TAG, "Direct-Pairing FAILED..\n");\r
-    }\r
-}\r
-\r
-OCStackApplicationResult getReqCB(void * ctx, OCDoHandle handle, OCClientResponse *clientResponse)\r
-{\r
-    OIC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");\r
-\r
-    (void)ctx;\r
-    (void)handle;\r
-    if (clientResponse)\r
-    {\r
-        OIC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));\r
-        OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);\r
-        OIC_LOG_PAYLOAD(INFO, clientResponse->payload);\r
-        if ((OCSecurityPayload*)clientResponse->payload)\r
-        {\r
-            OIC_LOG(INFO, TAG, PCF("=============> Get Response"));\r
-        }\r
-    }\r
-    return OC_STACK_DELETE_TRANSACTION;\r
-}\r
-\r
-int DeviceDiscovery()\r
-{\r
-    OCStackResult ret;\r
-    OCCallbackData cbData;\r
-    char queryUri[200];\r
-    char ipaddr[100] = { '\0' };\r
-\r
-    snprintf(queryUri, sizeof (queryUri), DISCOVERY_QUERY, ipaddr);\r
-\r
-    cbData.cb = discoveryReqCB;\r
-    cbData.context = NULL;\r
-    cbData.cd = NULL;\r
-\r
-    /* Start a discovery query*/\r
-    OIC_LOG_V(INFO, TAG, "Resource Discovery : %s\n", queryUri);\r
-\r
-    ret = OCDoRequest(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,\r
-                      OC_LOW_QOS, &cbData, NULL, 0);\r
-    if (ret != OC_STACK_OK)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "OCStack resource error");\r
-    }\r
-    return ret;\r
-}\r
-\r
-OCStackResult DirectPairingDiscovery()\r
-{\r
-    // initiate direct pairing discovery\r
-    OIC_LOG(INFO, TAG, "   Discovering Only Owned Devices on Network..");\r
-    discoveredDevs = OCDiscoverDirectPairingDevices(DP_DISCOVERY_TIMEOUT);\r
-    if(NULL == discoveredDevs)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "OCDiscoverDirectPairingDevices API error");\r
-        return OC_STACK_ERROR;\r
-    }\r
-\r
-    // display the discovered unowned list\r
-    printf("   > Discovered Direct-Pairing Support Devices\n");\r
-    printList(discoveredDevs);\r
-\r
-    return OC_STACK_OK;\r
-}\r
-\r
-OCStackResult DoDirectPairing(OCDPDev_t* peer, OCPrm_t pmSel, char *pinNumber)\r
-{\r
-    if (NULL == peer || NULL == pinNumber)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "invalid parameter");\r
-        return OC_STACK_INVALID_PARAM;\r
-    }\r
-\r
-    // start direct pairing\r
-    OIC_LOG(INFO, TAG, "   Start Direct Pairing..");\r
-    if(OC_STACK_OK != OCDoDirectPairing(NULL, peer, pmSel, pinNumber, pairingReqCB))\r
-    {\r
-        OIC_LOG(ERROR, TAG, "OCDoDirectPairing API error");\r
-        return OC_STACK_ERROR;\r
-    }\r
-\r
-    return OC_STACK_OK;\r
-}\r
-\r
-OCStackResult SendGetRequest(OCDPDev_t* peer)\r
-{\r
-    OIC_LOG(INFO, TAG, "Send Get REQ to Led server");\r
-\r
-    char szQueryUri[] = "/a/led";\r
-    OCDoHandle handle;\r
-    OCCallbackData cbData;\r
-    OCDevAddr endpoint;\r
-    OCStackResult ret;\r
-\r
-    memcpy(&endpoint, &peer->endpoint, sizeof(OCDevAddr));\r
-    endpoint.port = peer->securePort;\r
-    endpoint.flags = (OCTransportFlags)(endpoint.flags | OC_SECURE);\r
-\r
-    cbData.cb = getReqCB;\r
-    cbData.context = NULL;\r
-    cbData.cd = NULL;\r
-\r
-    OIC_LOG(INFO, TAG, "Request to /a/light ");\r
-    ret = OCDoRequest(&handle, OC_REST_GET, szQueryUri,\r
-                      &endpoint, NULL, peer->connType, OC_LOW_QOS, &cbData, NULL, 0);\r
-    if (ret != OC_STACK_OK)\r
-    {\r
-        OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, OC_REST_GET);\r
-    }\r
-\r
-    return ret;\r
-}\r
-\r
-FILE* client_fopen(const char *path, const char *mode)\r
-{\r
-    if (0 == strcmp(path, OC_SECURITY_DB_DAT_FILE_NAME))\r
-    {\r
-        return fopen(CRED_FILE, mode);\r
-    }\r
-    else\r
-    {\r
-        return fopen(path, mode);\r
-    }\r
-}\r
-\r
-void *CLInterface(void *data)\r
-{\r
-    printf(RED_BEGIN "#Ready to operation ('h' for help)#\n" COLOR_END);\r
-\r
-    (void)data;\r
-    OCStackResult ret;\r
-    char query[MAX_LINE] = {0};\r
-    const char prompt[] = BOLD_BEGIN "IoTivity-DP#" COLOR_END" ";\r
-    const char* helpmsg[6] = {\r
-            GREEN_BEGIN "# h  (or help) : show help message" COLOR_END,\r
-            GREEN_BEGIN "# dd (DP device discovery) : discover Direct-Pairing devices" COLOR_END,\r
-            GREEN_BEGIN "# dp (start Direct-Pairing) : negotiate DP method & start Direct-Pairing" COLOR_END,\r
-            GREEN_BEGIN "# sd (send data) : send data to device" COLOR_END,\r
-            GREEN_BEGIN "# ll (list all device) : list all discovered/paired devices" COLOR_END,\r
-            GREEN_BEGIN "# q  (quit) : quit test" COLOR_END,\r
-        };\r
-\r
-    for (size_t i=0; i<(sizeof(helpmsg)/sizeof(char*)); i++)\r
-    {\r
-        fprintf(stderr, "%s\n", helpmsg[i]);\r
-    }\r
-    printf("\n");\r
-\r
-    // cli\r
-    for (;;)\r
-    {\r
-        const char *input = readline(prompt, NULL);\r
-        if (!input) {\r
-            continue;\r
-        }\r
-\r
-        strncpy(query, input, MAX_LINE);\r
-        if (!strlen(query))\r
-        {\r
-            continue;\r
-        }\r
-        else if (!strcmp(query, "h") || !strcmp(query, "help"))\r
-        {\r
-            for (size_t i=0; i<(sizeof(helpmsg)/sizeof(char*)); i++)\r
-            {\r
-                fprintf(stderr, "%s\n", helpmsg[i]);\r
-            }\r
-            continue;\r
-        }\r
-        else\r
-        {\r
-            if (!strcmp(query, "dd"))\r
-            {\r
-                OIC_LOG(INFO, TAG, "- Direct-Pairing device discovery -");\r
-\r
-                ret = DirectPairingDiscovery();\r
-                if (OC_STACK_OK != ret)\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Error in DirectPairingDiscovery()");\r
-                }\r
-            }\r
-            else if (!strcmp(query, "dp"))\r
-            {\r
-                OIC_LOG(INFO, TAG, "- Negotiate DP method & Start Direct-Pairing -");\r
-\r
-                printf("\n   * List of  discovered device\n");\r
-                printList(discoveredDevs);\r
-\r
-                // target peer\r
-                OCDPDev_t *peer = NULL;\r
-                long peerIdx;\r
-                input = readline("   > Enter Peer Device Number to initiate Direct-Pairing: ", NULL);\r
-                if (!input || !strlen(input))\r
-                {\r
-                    continue;\r
-                }\r
-                char *ptr;\r
-                peerIdx = strtol(input, &ptr, 10);\r
-\r
-                peer = getDev(discoveredDevs, (uint32_t)peerIdx);\r
-                if (NULL == peer)\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Not found the peer in discovered list");\r
-                    continue;\r
-                }\r
-\r
-                // get pairing method\r
-                long pmIdx;\r
-                OCPrm_t pmSel = DP_NOT_ALLOWED;\r
-                if (false == printPairingMethod(peer))\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Target does not support the Direct-Pairing");\r
-                    continue;\r
-                }\r
-                input = readline("   > Enter pairing method: ", NULL);\r
-                if (!input || !strlen(input))\r
-                {\r
-                    continue;\r
-                }\r
-                pmIdx = strtol(input, &ptr, 10);\r
-                printf("\n");\r
-                if (0 >= pmIdx || peer->prmLen+1 < (size_t)pmIdx)\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Invalid mode selection");\r
-                    continue;\r
-                }\r
-                pmSel = peer->prm[pmIdx-1];\r
-\r
-                // get PIN\r
-                char pinNumber[DP_PIN_LENGTH+1];\r
-                input = readline("   > Enter PIN Number for authentication (ex - '00000000' [8 digit] ): ", NULL);\r
-                if (!input || DP_PIN_LENGTH != strlen(input))\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Invalid PIN");\r
-                    continue;\r
-                }\r
-                sscanf(input, "%8s", pinNumber);\r
-                printf("\n");\r
-\r
-                ret = DoDirectPairing(peer, pmSel, pinNumber);\r
-                if (OC_STACK_OK != ret)\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Error in DoDirectPairing()");\r
-                }\r
-            }\r
-            else if (!strcmp(query, "sd"))\r
-            {\r
-                OIC_LOG(INFO, TAG, "- Send data(GET Request) to device(led server) -");\r
-\r
-                //pairedDevs = OCGetDirectPairedDevices();\r
-                //printList(pairedDevs);\r
-                printList(discoveredDevs);\r
-\r
-                // target peer\r
-                OCDPDev_t *peer = NULL;\r
-                long peerIdx;\r
-                input = readline("   > Enter Peer Device Number to initiate Direct-Pairing: ", NULL);\r
-                if (!input || !strlen(input))\r
-                {\r
-                    continue;\r
-                }\r
-                char *ptr;\r
-                peerIdx = strtol(input, &ptr, 10);\r
-\r
-                //peer = getDev(pairedDevs, peerIdx);\r
-                peer = getDev(discoveredDevs, (uint32_t)peerIdx);\r
-                if (NULL == peer)\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Not found the peer in discovered list");\r
-                    continue;\r
-                }\r
-\r
-                // send Get Req\r
-                ret = SendGetRequest(peer);\r
-                if (OC_STACK_OK != ret)\r
-                {\r
-                    OIC_LOG(ERROR, TAG, "Error in SendGetRequest()");\r
-                }\r
-            }\r
-            else if (!strcmp(query, "ll"))\r
-            {\r
-                OIC_LOG(INFO, TAG, "- List all discovered and paired devices) -");\r
-\r
-                printf("  > List of discovered devices\n");\r
-                printList(discoveredDevs);\r
-                printf("\n");\r
-\r
-                printf("  > List of paired devices\n");\r
-                pairedDevs = OCGetDirectPairedDevices();\r
-                printList(pairedDevs);\r
-                printf("\n");\r
-            }\r
-            else if (!strcmp(query, "q"))\r
-            {\r
-                printf("QUIT\n");\r
-                gQuitFlag = 1;\r
-                break;\r
-            }\r
-        }\r
-    }\r
-\r
-    return 0;\r
-}\r
-\r
-int main(void)\r
-{\r
-    struct timespec timeout;\r
-\r
-    // Initialize Persistent Storage for SVR database\r
-    OCPersistentStorage ps = { client_fopen, fread, fwrite, fclose, unlink };\r
-    OCRegisterPersistentStorageHandler(&ps);\r
-\r
-    /* Initialize OCStack*/\r
-    if (OCInit(NULL, 0, OC_CLIENT_SERVER) != OC_STACK_OK)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "OCStack init error");\r
-        return 0;\r
-    }\r
-\r
-//    DeviceDiscovery();\r
-\r
-    timeout.tv_sec  = 0;\r
-    timeout.tv_nsec = 100000000L;\r
-\r
-    // Break from loop with Ctrl+C\r
-    OIC_LOG(INFO, TAG, "Entering occlient main loop...");\r
-    signal(SIGINT, handleSigInt);\r
-\r
-    // CLI\r
-    int thr_id;\r
-    pthread_t p_thread;\r
-    thr_id = pthread_create(&p_thread, NULL, CLInterface, (void *)NULL);\r
-    if (thr_id < 0)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "create CLI Thread error");\r
-        return 0;\r
-    }\r
-\r
-    // loop\r
-    while (!gQuitFlag)\r
-    {\r
-        if (OCProcess() != OC_STACK_OK)\r
-        {\r
-            OIC_LOG(ERROR, TAG, "OCStack process error");\r
-            return 0;\r
-        }\r
-\r
-#if defined(_WIN32)\r
-        Sleep(100);\r
-#else\r
-        nanosleep(&timeout, NULL);\r
-#endif // defined(_WIN32)\r
-\r
-    }\r
-    OIC_LOG(INFO, TAG, "Exiting occlient main loop...");\r
-\r
-    if (OCStop() != OC_STACK_OK)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "OCStack stop error");\r
-    }\r
-\r
-    return 0;\r
-}\r
index 3c80031..fc039e1 100644 (file)
 #include "oickeepalive.h"
 #endif
 
-//#ifdef DIRECT_PAIRING
-#include "directpairing.h"
-//#endif
-
 #ifdef HAVE_ARDUINO_TIME_H
 #include "Time.h"
 #endif
@@ -5053,44 +5049,6 @@ OCStackResult OC_CALL OCDoResponse(OCEntityHandlerResponse *ehResponse)
     return result;
 }
 
-//#ifdef DIRECT_PAIRING
-const OCDPDev_t* OC_CALL OCDiscoverDirectPairingDevices(unsigned short waittime)
-{
-    OIC_LOG(INFO, TAG, "Start OCDiscoverDirectPairingDevices");
-    if(OC_STACK_OK != DPDeviceDiscovery(waittime))
-    {
-        OIC_LOG(ERROR, TAG, "Fail to discover Direct-Pairing device");
-        return NULL;
-    }
-
-    return (const OCDPDev_t*)DPGetDiscoveredDevices();
-}
-
-const OCDPDev_t* OC_CALL OCGetDirectPairedDevices()
-{
-    return (const OCDPDev_t*)DPGetPairedDevices();
-}
-
-OCStackResult OC_CALL OCDoDirectPairing(void *ctx, OCDPDev_t* peer, OCPrm_t pmSel, char *pinNumber,
-                                        OCDirectPairingCB resultCallback)
-{
-    OIC_LOG(INFO, TAG, "Start OCDoDirectPairing");
-    if(NULL ==  peer || NULL == pinNumber)
-    {
-        OIC_LOG(ERROR, TAG, "Invalid parameters");
-        return OC_STACK_INVALID_PARAM;
-    }
-    if (NULL == resultCallback)
-    {
-        OIC_LOG(ERROR, TAG, "Invalid callback");
-        return OC_STACK_INVALID_CALLBACK;
-    }
-
-    return DPDirectPairing(ctx, (OCDirectPairingDev_t*)peer, (OicSecPrm_t)pmSel,
-                                           pinNumber, (OCDirectPairingResultCB)resultCallback);
-}
-//#endif // DIRECT_PAIRING
-
 //-----------------------------------------------------------------------------
 // Private internal function definitions
 //-----------------------------------------------------------------------------
index 3b0fd53..02f08fa 100644 (file)
@@ -99,13 +99,6 @@ extern "C"  OCStackApplicationResult asyncDoResourcesCallback(void* ctx,
     return OC_STACK_KEEP_TRANSACTION;
 }
 
-static void resultCallback(void *UNUSED1, OCDPDev_t *UNUSED2, OCStackResult UNUSED3)
-{
-    (void) (UNUSED1);
-    (void) (UNUSED2);
-    (void) (UNUSED3);
-}
-
 extern "C" OCStackApplicationResult discoveryCallback(void* ctx,
         OCDoHandle /*handle*/, OCClientResponse * clientResponse)
 {
@@ -2349,21 +2342,6 @@ TEST(PODTests, OCCallbackData)
 }
 #endif
 
-TEST(OCDoDirectPairingTests, Nullpeer)
-{
-    EXPECT_EQ(OC_STACK_INVALID_PARAM,OCDoDirectPairing(NULL, NULL, pmSel, &pinNumber, &resultCallback));
-}
-
-TEST(OCDoDirectPairingTests, NullCallback)
-{
-    EXPECT_EQ(OC_STACK_INVALID_CALLBACK,OCDoDirectPairing(NULL, &peer, pmSel, &pinNumber, NULL));
-}
-
-TEST(OCDoDirectPairingTests, NullpinNumber)
-{
-    EXPECT_EQ(OC_STACK_INVALID_PARAM,OCDoDirectPairing(NULL, &peer, pmSel, NULL, &resultCallback));
-}
-
 TEST(StackResource, MultipleResourcesDiscovery)
 {
     itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
index 3441feb..6b8fae7 100644 (file)
@@ -86,7 +86,6 @@ def make_single_file_cpp_program(program_name):
 example_names = [
     'simpleserver', 'simpleclient',
     'simpleclientserver',
-    'directpairingclient',
     'devicediscoveryserver', 'devicediscoveryclient',
     'simpleserverHQ', 'simpleclientHQ',
     ]
@@ -120,10 +119,7 @@ serverjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/exa
 light_introspection_json = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'light_introspection.json')
 
-directpairingdat = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
-                examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client_directpairing.dat')
-
-examples += [clientjson, serverjson, directpairingdat]
+examples += [clientjson, serverjson]
 
 if target_os in ['msys_nt', 'windows']:
     winUIClient = examples_env.Program('winUIClient', ['winuiclientgui.cpp', 'winuiclient.cpp'])
diff --git a/resource/examples/directpairingclient.cpp b/resource/examples/directpairingclient.cpp
deleted file mode 100644 (file)
index 16e84d7..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-/* *****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * *****************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string>
-#include <map>
-#include <cstdlib>
-#include <mutex>
-#include <condition_variable>
-
-#include "logger.h"
-#include "oic_malloc.h"
-#include "oic_string.h"
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-#define MAX_PERMISSION_LENGTH (5)
-#define CREATE (1)
-#define READ (2)
-#define UPDATE (4)
-#define DELETE (8)
-#define NOTIFY (16)
-#define DASH '-'
-#define PREDEFINED_TIMEOUT (10)
-#define MAX_OWNED_DEVICE (10)
-#define TAG  "provisioningclient"
-
-#define JSON_DB_PATH "./oic_svr_db_client.json"
-#define DAT_DB_PATH "./oic_svr_db_client.dat"
-#define DEV_STATUS_ON "DEV_STATUS_ON"
-#define DEV_STATUS_OFF "DEV_STATUS_OFF"
-
-#define DP_DISCOVERY_TIMEOUT 4
-#define DP_PIN_LENGTH 8
-
-#define BOLD_BEGIN    "\033[1m"
-#define RED_BEGIN     "\033[1;31m"
-#define GREEN_BEGIN   "\033[1;92m"
-#define COLOR_END     "\033[0m"
-
-using namespace OC;
-
-static int ask = 1;
-static PairedDevices discoveredDeviceList, pairedDeviceList;
-
-static FILE* client_open(const char* path, const char* mode)
-{
-    if (0 == strcmp(path, OC_SECURITY_DB_DAT_FILE_NAME))
-    {
-        return fopen(DAT_DB_PATH, mode);
-    }
-    else
-    {
-        return fopen(path, mode);
-    }
-}
-
-
-static void printMenu()
-{
-    std::cout << GREEN_BEGIN "Choose an option:" COLOR_END<<std::endl;
-    std::cout << GREEN_BEGIN "# 1 (DP device discovery) : discover Direct-Pairing devices"
-        COLOR_END<<std::endl;
-    std::cout << GREEN_BEGIN "# 2 (start Direct-Pairing) : negotiate DP method & start Direct-Pairin"
-        COLOR_END<<std::endl;
-    std::cout << GREEN_BEGIN "# 3 (list all device) : list all discovered/paired devices"
-        COLOR_END<<std::endl;
-    std::cout << GREEN_BEGIN "# 4 (send data) : send data to device" COLOR_END<<std::endl;
-    std::cout << GREEN_BEGIN "# 9 (quit) : quit test " COLOR_END<<std::endl;
-}
-
-static void printPrompt()
-{
-    std::cout << BOLD_BEGIN "IoTivity-DP#" COLOR_END" ";
-}
-
-static void printDevices(PairedDevices& list)
-{
-    for (size_t i = 0; i < list.size(); i++)
-    {
-        std::cout << "["<< i+1 << "]" << " ID: " << list[i]->getDeviceID() << std::endl;
-    }
-}
-
-static void findCallback(PairedDevices discoveredDevList)
-{
-
-    if (0 == discoveredDevList.size())
-    {
-        std::cout<< "No Direct-pairing Support device Found" << std::endl;
-    }
-    else
-    {
-        std::cout << "Discovered Direct-Pairing Support Device"<< std::endl;
-        discoveredDeviceList = discoveredDevList;
-        printDevices(discoveredDevList);
-    }
-
-    printMenu();
-    printPrompt();
-    fflush(NULL);
-}
-
-static bool printPairingMethod(int choice)
-{
-    if (NULL == discoveredDeviceList[choice])// || false == discoveredDeviceList[choice]->edp)
-    {
-        std::cout<< "Invalid device or Not support direct-pairing..\n\n" << std::endl;
-        return false;
-    }
-
-    auto prms = discoveredDeviceList[choice]->getPairingMethods();
-    if (0 == prms.size())
-    {
-        std::cout << "Not exist any support method..\n\n" << std::endl;
-        return false;
-    }
-
-    bool ret = true;
-    std::cout << "\n* List of supported pairing methods *" << std::endl;
-
-    for (unsigned int i = 0; i < prms.size(); i++)
-    {
-        std::cout<< "[" << i+1 << "]";
-        switch (prms[i])
-        {
-            case DP_PRE_CONFIGURED:
-                std::cout<<"Pre-Configured PIN"<<std::endl;;
-                break;
-            case DP_RANDOM_PIN:
-                std::cout<<"Random PIN"<<std::endl;;
-                break;
-            default:
-                std::cout<<"NOT Allowed ("<< prms[i]<<")"<<std::endl;
-                ret = false;
-                break;
-        }
-        std::cout<<std::endl;
-    }
-
-    return ret;
-}
-
-static void resultCallback(std::shared_ptr<OCDirectPairing> ptr, OCStackResult result)
-{
-
-    if (OC_STACK_OK == result)
-    {
-        std::cout << " Direct-Pairing SUCCESS" << std::endl;
-        std::cout << "Taget Add info:" << ptr->getHost() << std::endl;
-    }
-    else {
-        std::cout <<" Direct-Pairing FAILED" << std::endl;
-    }
-
-    printMenu();
-    printPrompt();
-    fflush(NULL);
-}
-
-static void pairedDevListCB(PairedDevices pairedDevList)
-{
-
-    if (0 == pairedDevList.size())
-    {
-        std::cout << "No Paired Devcie  Found" << std::endl;
-    }
-    else
-    {
-        pairedDeviceList = pairedDevList;
-        printDevices(pairedDevList);
-    }
-
-    printMenu();
-    printPrompt();
-    fflush(NULL);
-}
-
-static void getCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
-{
-    (void)(headerOptions);
-    try
-    {
-        if (OC_STACK_OK == eCode)
-        {
-            std::cout << "Callback Context for GET query recvd successfully" << std::endl;
-            std::cout << "Resource URI: " << rep.getUri() << std::endl;
-
-            bool state = false;
-            int power = 0;
-            rep.getValue("state", state);
-            rep.getValue("power", power);
-
-            std::cout << "\tstate: " << state << std::endl;
-            std::cout << "\tpower: " << power << std::endl;
-        }
-        else
-        {
-            std::cout << "getCallback Response error: " << eCode << std::endl;
-        }
-    }
-    catch(std::exception& e)
-    {
-        std::cout << "Exception: " << e.what() << " in onGet" << std::endl;
-    }
-}
-
-static bool InputPIN(std::string& pin)
-{
-    std::cout <<"   > Enter PIN Number for authentication (ex - '00000000' [8 digit] ):" ;
-
-    std::cin >> pin;
-
-    if (pin.size() != DP_PIN_LENGTH)
-    {
-        std::cout<<"Invalid PIN"<<std::endl;
-        return false;
-    }
-
-    return true;
-}
-
-int main(void)
-{
-    OCPersistentStorage ps {client_open, fread, fwrite, fclose, unlink };
-
-    // Create PlatformConfig object
-    PlatformConfig cfg {
-        OC::ServiceType::InProc,
-            OC::ModeType::Both,
-            &ps
-    };
-
-    OCPlatform::Configure(cfg);
-
-    try
-    {
-        OC_VERIFY(OCPlatform::start() == OC_STACK_OK);
-
-        unsigned int choice;
-        for (int out = 0; !out;)
-        {
-            if (ask)
-            {
-                printMenu();
-                printPrompt();
-                fflush(NULL);
-            }
-            std::cin >> choice;
-
-            switch(choice) {
-                case 1:
-                    {
-                        OCStackResult result = OC::OCPlatform::findDirectPairingDevices(
-                                DP_DISCOVERY_TIMEOUT, findCallback);
-
-                        if (OC_STACK_NO_RESOURCE == result)
-                        {
-                            std::cout << "!! No Direct-Pairing Support Device found"<<std::endl;
-                            break;
-                        }
-
-                        if (OC_STACK_OK != result)
-                        {
-                            std::cout << "!!Error - findDirectPairingDevices failed."<<std::endl;
-                        }
-                        ask = 0;
-                        break;
-                    }
-                case 2:
-                    {
-                        unsigned int pMethodIDx = 0;
-                        std::string pin("");
-
-                        std::cout << "- Negotiate DP method & Start Direct-Pairing - ";
-                        std::cout << "* List of  discovered device" << std::endl;
-                        printDevices(discoveredDeviceList);
-                        std::cout << "   > Enter Peer Device Number to initiate Direct-Pairing:" << std::endl;
-                        printPrompt();
-                        std::cin >> choice;
-                        if (choice < 1 || choice > discoveredDeviceList.size())
-                        {
-                            std::cout << "!!Device Number is incorrect, Try Again" << std::endl;
-                            break;
-                        }
-                        OCPrm_t pmSel = DP_NOT_ALLOWED;
-                        choice--;
-                        if (false == printPairingMethod(choice))
-                        {
-                            std::cout << "Target does not support the Direct-Pairing" << std::endl;
-                            break;
-                        }
-
-                        std::cout << " > Enter pairing method: "<< std::endl;
-                        printPrompt();
-                        std::cin >> pMethodIDx;
-                        auto prms = discoveredDeviceList[choice]->getPairingMethods();
-                        if (0 == pMethodIDx || prms.size() < pMethodIDx)
-                        {
-                            std::cout <<"Invalid mode selection" << std::endl;
-                            break;
-                        }
-
-                        pmSel =  prms[pMethodIDx - 1];
-                        if (false == InputPIN(pin))
-                        {
-                            break;
-                        }
-
-                        OCStackResult result = OC::OCPlatform::doDirectPairing(discoveredDeviceList[choice], pmSel, pin, resultCallback);
-
-                        if (OC_STACK_OK != result)
-                        {
-                            std::cout << "!!Error - doDirectPairing failed." << std::endl;
-                        }
-                        ask = 0;
-                        break;
-                    }
-                case 3:
-                    {
-                        std::cout << "- List all discovered and paired devices) -";
-                        std::cout << "  > List of discovered devices" << std::endl;
-                        printDevices(discoveredDeviceList);
-                        std::cout << std::endl;
-
-                        std::cout << "  > List of paired devices" << std::endl;
-                        OCStackResult result = OC::OCPlatform::getDirectPairedDevices(pairedDevListCB);
-                        printDevices(pairedDeviceList);
-                        std::cout << std::endl;
-
-                        if (OC_STACK_NO_RESOURCE == result)
-                        {
-                            std::cout << "!! No Paired device found"<<std::endl;
-                            break;
-                        }
-                        if (OC_STACK_OK != result)
-                        {
-                            std::cout << "!!Error - getDirectPairedDevices failed."<<std::endl;
-                        }
-                        break;
-                    }
-                case 4:
-                    {
-                        std::cout << "- Send data(GET Request) to device(led server) -" << std::endl;
-                        printDevices(pairedDeviceList);
-                        pairedDeviceList = discoveredDeviceList;
-                        printMenu();
-                        std::cout << "Enter device number to GET data: ";
-                        std::cin >> choice;
-                        choice--;
-
-                        std::vector<std::string> ledTypes = {"core.led"};
-                        std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
-
-                        OCConnectivityType ct = pairedDeviceList[choice]->getConnType();
-
-                        std::cout << "\n\n HOST address is : " << pairedDeviceList[choice]->getHost() << "\n\n";
-                        OCResource::Ptr led = OC::OCPlatform::constructResourceObject(
-                                pairedDeviceList[choice]->getHost(),
-                                "/a/led", ct, false, ledTypes, ifaces);
-
-                        if(!led)
-                        {
-                            std::cout << "Error: Led Object construction returned null" << std::endl;
-                            break;
-                        }
-                        OCStackResult res = led->get(QueryParamsMap(), getCallback);
-
-                        if (OC_STACK_OK != res)
-                        {
-                            std::cout << "Error: get Failed for Led" << std::endl;
-                        }
-                        break;
-                    }
-                case 9:
-                    {
-                        out = 1;
-                        break;
-                    }
-                default:
-                    {
-                        std::cout << GREEN_BEGIN "Wrong Option : Try Again" COLOR_END << std::endl;
-                        printMenu();
-                        printPrompt();
-                        break;
-                    }
-            }
-        }
-
-        OC_VERIFY(OCPlatform::stop() == OC_STACK_OK);
-    }
-    catch(OCException& e)
-    {
-        oclog() << "Exception in main: "<< e.what();
-    }
-
-    return 0;
-}
index 52a400f..13245b5 100644 (file)
@@ -134,15 +134,6 @@ namespace OC
 
         virtual OCStackResult GetDefaultQos(QualityOfService& qos) = 0;
 
-        virtual OCStackResult FindDirectPairingDevices(unsigned short waittime,
-                        GetDirectPairedCallback& callback) = 0;
-
-        virtual OCStackResult GetDirectPairedDevices(GetDirectPairedCallback& callback) = 0;
-
-        virtual OCStackResult DoDirectPairing(std::shared_ptr< OCDirectPairing > peer,
-                                              const OCPrm_t& pmSel, const std::string& pinNumber,
-                                              DirectPairingCallback& resultCallback) = 0;
-
 #ifdef WITH_MQ
         virtual OCStackResult ListenForMQTopic(
             const OCDevAddr& devAddr,
index 4bfd512..51acc62 100644 (file)
@@ -113,13 +113,6 @@ namespace OC
             ObserveContext(ObserveCallback cb) : callback(cb){}
         };
 
-        struct DirectPairingContext
-        {
-            DirectPairingCallback callback;
-            DirectPairingContext(DirectPairingCallback cb) : callback(cb){}
-
-        };
-
 #ifdef WITH_MQ
         struct MQTopicContext
         {
@@ -220,14 +213,6 @@ namespace OC
 
         OCStackResult GetDefaultQos(QualityOfService& QoS);
 
-        virtual OCStackResult FindDirectPairingDevices(unsigned short waittime,
-                       GetDirectPairedCallback& callback);
-
-        virtual OCStackResult GetDirectPairedDevices(GetDirectPairedCallback& callback);
-
-        virtual OCStackResult DoDirectPairing(std::shared_ptr<OCDirectPairing> peer, const OCPrm_t& pmSel,
-                const std::string& pinNumber, DirectPairingCallback& resultCallback);
-
 #ifdef WITH_MQ
         virtual OCStackResult ListenForMQTopic(
             const OCDevAddr& devAddr,
@@ -253,7 +238,6 @@ namespace OC
         OCPayload* assembleSetResourcePayload(const OCRepresentation& attributes);
         OCHeaderOption* assembleHeaderOptions(OCHeaderOption options[],
            const HeaderOptions& headerOptions);
-        void convert(const OCDPDev_t *list, PairedDevices& dpList);
         std::thread m_listeningThread;
         bool m_threadRun;
         std::weak_ptr<std::recursive_mutex> m_csdkLock;
index af97215..524dc51 100644 (file)
@@ -45,7 +45,6 @@ namespace OC
     class OCResource;
     class OCResourceRequest;
     class OCResourceResponse;
-    class OCDirectPairing;
 } // namespace OC
 
 namespace OC
@@ -355,7 +354,6 @@ namespace OC
     const std::string GROUP_INTERFACE = "oic.mi.grp";
 
     //Typedef for list direct paired devices
-    typedef std::vector<std::shared_ptr<OCDirectPairing>> PairedDevices;
 
     typedef std::function<void(std::shared_ptr<OCResource>)> FindCallback;
 
@@ -387,10 +385,6 @@ namespace OC
     typedef std::function<void(const HeaderOptions&,
                                 const OCRepresentation&, const int, const int)> ObserveCallback;
 
-    typedef std::function<void(std::shared_ptr<OCDirectPairing>, OCStackResult)> DirectPairingCallback;
-
-    typedef std::function<void(const PairedDevices&)> GetDirectPairedCallback;
-
     typedef std::function<void(const int, const std::string&,
                                std::shared_ptr<OCResource>)> MQTopicCallback;
 } // namespace OC
diff --git a/resource/include/OCDirectPairing.h b/resource/include/OCDirectPairing.h
deleted file mode 100644 (file)
index 3f27b83..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-//******************************************************************
-//
-// Copyright 2016 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef OC_DIRECT_PAIRING_H_
-#define OC_DIRECT_PAIRING_H_
-#include <OCApi.h>
-
-namespace OC
-{
-    class OCDirectPairing
-    {
-        public:
-            OCDirectPairing(OCDPDev_t *ptr);
-            /**
-             * Function to get the host address of direct pairing device.
-             *
-             * @return Returns host address in the format
-             *           <coaps>:IP:securePort
-             */
-            std::string getHost();
-
-            /**
-             * Function to get the device ID of the direct pairing device.
-             *
-             * @return Returns device ID (UUID)
-             */
-            std::string getDeviceID();
-
-            /**
-             * Function to get the pairing methods supported by direct pairing device.
-             *
-             * @return Returns vector of pairing methods supported.
-             *   DP_NOT_ALLOWED
-             *   DP_PRE_CONFIGURED
-             *   DP_RANDOM_PIN
-             */
-            std::vector<OCPrm_t> getPairingMethods();
-
-            /**
-             * Function to get the connectivity Type.
-             *
-             * @return Returns connectivity Type
-             */
-            OCConnectivityType getConnType();
-
-            OCDPDev_t* getDev();
-
-        private:
-            OCDPDev_t *m_devPtr;
-    };
-}
-#endif //OC_DIRECT_PAIRING_H_
index 8946650..e0bec2f 100644 (file)
@@ -720,39 +720,6 @@ namespace OC
          */
         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
 
-        /**
-         * Find all the Direct Pairing capable devices.
-         *
-         * @param waittime timeoutbefore the callback is called
-         * @param callback function to callback with discovered devices after timeout
-         *
-         * @return Returns ::OC_STACK_OK if success
-         */
-        OCStackResult findDirectPairingDevices(unsigned short waittime,
-                                     GetDirectPairedCallback callback);
-
-        /**
-         * Get all the Direct paired devices.
-         *
-         * @param callback function to callback with the list of paired devices
-         *
-         * @return Returns ::OC_STACK_OK if success
-         */
-        OCStackResult getDirectPairedDevices(GetDirectPairedCallback callback);
-
-        /**
-         * Perform the Direct Pairing with the selected peer device
-         *
-         * @param peer device to direct pair with
-         * @param pmSel Selected pairing method
-         * @param pinNumber pin to validate peer & perform the direct pairing
-         * @param resultCallback callback function that will get the result of the operation
-         *
-         * @return Returns ::OC_STACK_OK if success
-         */
-        OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
-                                     const std::string& pinNumber,
-                                     DirectPairingCallback resultCallback);
 #ifdef WITH_CLOUD
         /**
          * Create an account manager object that can be used for doing request to account server.
index bfbab03..9ec48c4 100644 (file)
@@ -37,7 +37,6 @@
 #include "OCResourceRequest.h"
 #include "OCResourceResponse.h"
 #include "OCRepresentation.h"
-#include "OCDirectPairing.h"
 
 #ifdef WITH_CLOUD
 #include "OCAccountManager.h"
@@ -320,14 +319,6 @@ namespace OC
         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
         std::weak_ptr<std::recursive_mutex> csdkLock();
 
-        OCStackResult findDirectPairingDevices(unsigned short waittime,
-                                         GetDirectPairedCallback callback);
-
-        OCStackResult getDirectPairedDevices(GetDirectPairedCallback callback);
-
-        OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
-                                         const std::string& pinNumber,
-                                         DirectPairingCallback resultCallback);
 #ifdef WITH_CLOUD
         OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
                                                             OCConnectivityType connectivityType);
index c7a4d11..9cca654 100644 (file)
@@ -653,17 +653,6 @@ namespace OC
             OCStackResult removeDevice(unsigned short waitTimeForOwnedDeviceDiscovery,
                     ResultCallBack resultCallback);
 
-            /**
-             * API to provision DirectPairing to devices.
-             *
-             * @param pconf pointer to PCONF (Pairing Configuration).
-             * @param resultCallback Callback will be called when provisioning request receives
-             *                           a response from first resource server.
-             * @return  ::OC_STACK_OK in case of success and other value otherwise.
-             */
-            OCStackResult provisionDirectPairing(const OicSecPconf_t *pconf,
-                    ResultCallBack resultCallback);
-
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
             /**
              * API to provision cert.
index 1178367..74d9b67 100644 (file)
@@ -161,18 +161,6 @@ namespace OC
         virtual OCStackResult GetDefaultQos(QualityOfService& /*QoS*/)
             {return OC_STACK_NOTIMPL;}
 
-        virtual OCStackResult FindDirectPairingDevices(unsigned short /*waittime*/,
-                       GetDirectPairedCallback& /*callback*/)
-            {return OC_STACK_NOTIMPL;}
-
-        virtual OCStackResult GetDirectPairedDevices(GetDirectPairedCallback& /*callback*/)
-            {return OC_STACK_NOTIMPL;}
-
-        virtual OCStackResult DoDirectPairing(std::shared_ptr<OCDirectPairing> /*peer*/,
-                const OCPrm_t& /*pmSel*/,
-                const std::string& /*pinNumber*/, DirectPairingCallback& /*resultCallback*/)
-            {return OC_STACK_NOTIMPL;}
-
 #ifdef WITH_MQ
         virtual OCStackResult ListenForMQTopic(const OCDevAddr& /*devAddr*/,
                                                const std::string& /*resourceUri*/,
index c811e25..2bd8565 100644 (file)
@@ -67,7 +67,6 @@ using namespace OC;
 
 DeviceList_t pUnownedDevList, pOwnedDevList, pMOTEnabledDeviceList;
 static int transferDevIdx, ask = 1;
-static OicSecPconf_t g_pconf;
 static uint16_t g_credId = 0;
 
 static FILE* client_open(const char *path, const char *mode)
@@ -96,20 +95,19 @@ void printMenu()
     std::cout << "   9. Remove Device using UUID"<<std::endl;
     std::cout << "  10. Get Linked Devices"<<std::endl;
     std::cout << "  11. Get Device Status"<<std::endl;
-    std::cout << "  12. Provision Direct-Pairing Configuration"<<std::endl;
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-    std::cout << "  13. Save the Trust Cert. Chain into Cred of SVR"<<std::endl;
-    std::cout << "  14. Provision the Trust Cert. Chain"<<std::endl;
-    std::cout << "  15. Read trust cert chain"<<std::endl;
+    std::cout << "  12. Save the Trust Cert. Chain into Cred of SVR"<<std::endl;
+    std::cout << "  13. Provision the Trust Cert. Chain"<<std::endl;
+    std::cout << "  14. Read trust cert chain"<<std::endl;
 #endif // __WITH_DTLS__ || __WITH_TLS__
 #ifdef MULTIPLE_OWNER
-    std::cout << "  16. Change Multiple Ownership Transfer Mode"<<std::endl;
-    std::cout << "  17. Select OxM method for Multiple Ownership Transfer"<<std::endl;
-    std::cout << "  18. Multiple Ownership Transfer Enabled Devices Discovery"<<std::endl;
-    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;
+    std::cout << "  15. Change Multiple Ownership Transfer Mode"<<std::endl;
+    std::cout << "  16. Select OxM method for Multiple Ownership Transfer"<<std::endl;
+    std::cout << "  17. Multiple Ownership Transfer Enabled Devices Discovery"<<std::endl;
+    std::cout << "  18. Provision pre configure PIN for Multiple Ownership Transfer Mode"<<std::endl;
+    std::cout << "  19. Add pre configure PIN for Multiple Ownership Transfer Mode"<<std::endl;
 #endif
-    std::cout << "  21. Configure SVRdb as Self-OwnerShip"<<std::endl;
+    std::cout << "  20. Configure SVRdb as Self-OwnerShip"<<std::endl;
     std::cout << "  99. Exit loop"<<std::endl;
 }
 
@@ -626,27 +624,6 @@ static int InputCredentials(Credential &cred)
    return 0;
 }
 
-static void deletePconf()
-{
-    OICFree(g_pconf.prm);
-    //free pdacl
-    OicSecPdAcl_t* acl = g_pconf.pdacls;
-    if (acl)
-    {
-        /* Clean Resources */
-        for (unsigned int i = 0; i < (acl)->resourcesLen; i++)
-        {
-            OICFree((acl)->resources[i]);
-        }
-        OICFree((acl)->resources);
-
-        /* Clean ACL node itself */
-        /* Required only if acl was created in heap */
-        OICFree((acl));
-    }
-    memset(&g_pconf, 0, sizeof(OicSecPconf_t));
-}
-
 static OicSecPdAcl_t* InputPdACL()
 {
     int ret;
@@ -725,97 +702,6 @@ static OicSecPdAcl_t* InputPdACL()
     return acl;
 }
 
-void provisionDirectPairingCB(PMResultList_t *result, int hasError)
-{
-    if (hasError)
-    {
-        std::cout << "Error in provisioning operation!"<<std::endl;
-    }
-    else
-    {
-        std::cout<< "\nReceived provisioning results: Direct Pairing is successful ";
-        for (unsigned int i = 0; i < result->size(); i++)
-        {
-            std::cout << "Result is = " << result->at(i).res <<" for device ";
-            printUuid(result->at(i).deviceId);
-        }
-
-        delete result;
-    }
-    deletePconf();
-    printMenu();
-    ask = 1;
-}
-
-static void provisionDP(int dev_num)
-{
-    OCStackResult rst;
-    std::string pin("");
-
-    // set enable dp
-    g_pconf.edp = true;
-
-    // set default supported PRM types
-    g_pconf.prmLen = sizeof(SUPPORTED_PRMS)/sizeof(OicSecPrm_t);
-    g_pconf.prm = (OicSecPrm_t *)OICCalloc(g_pconf.prmLen, sizeof(OicSecPrm_t));
-    if(g_pconf.prm)
-    {
-        for (size_t i=0; i < g_pconf.prmLen; i++)
-        {
-            g_pconf.prm[i] = SUPPORTED_PRMS[i];
-        }
-    }
-    else
-    {
-        OIC_LOG(ERROR, TAG, "create prm error return");
-        goto PVDP_ERROR;
-    }
-
-    std::cout << "Enter PIN to be configured: ";
-    while (1)
-    {
-        std::cin >> pin;
-        if (pin.length() == DP_PIN_LENGTH)
-        {
-            break;
-        }
-        else
-        {
-            std::cout << "PIN length should be 8, Enter again: ";
-        }
-    }
-
-    memcpy(g_pconf.pin.val, pin.c_str(), DP_PIN_LENGTH);
-
-    // set default pdacl
-
-    g_pconf.pdacls = InputPdACL();
-    if(!g_pconf.pdacls)
-    {
-        OIC_LOG(ERROR, TAG, "InputPdACL error return");
-        goto PVDP_ERROR;
-    }
-
-    // call |OCProvisionDirectPairing| API actually
-    // calling this API with callback actually acts like blocking
-    // for error checking, the return value saved and printed
-    rst = pOwnedDevList[dev_num-1]->provisionDirectPairing(&g_pconf, provisionDirectPairingCB);
-    if(OC_STACK_OK != rst)
-    {
-        OIC_LOG_V(ERROR, TAG, "OCProvisionDirectPairing API error: %d", rst);
-        if (OC_STACK_UNAUTHORIZED_REQ == rst)
-        {
-            OIC_LOG(ERROR, TAG, "Target Server NOT Support Direct-Pairing !!! (DPC == false)");
-        }
-        goto PVDP_ERROR;
-    }
-    return;
-
-PVDP_ERROR:
-    deletePconf();  // after here |acl| points nothing
-    ask = 1;
-}
-
 OCStackResult displayMutualVerifNumCB(uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN])
 {
     OC_UNUSED(mutualVerifNum);
@@ -1324,38 +1210,8 @@ int main(void)
                         break;
                     }
 
-                case 12:
-                    {
-                        unsigned int devNum;
-
-                        if (!pOwnedDevList.size())
-                        {
-                            std::cout <<"There are no Owned devices yet,"
-                                " may need to discover"<<std::endl;
-                            break;
-                        }
-
-                        for (unsigned int i = 0; i < pOwnedDevList.size(); i++ )
-                        {
-                            std::cout << i+1 << ": "<< pOwnedDevList[i]->getDeviceID() <<" From IP:";
-                            std::cout << pOwnedDevList[i]->getDevAddr() <<std::endl;
-                        }
-
-                        std::cout <<"Select device number: "<<std::endl;
-                        std::cin >> devNum;
-                        if (devNum > pOwnedDevList.size())
-                        {
-                            std::cout <<"Invalid device number"<<std::endl;
-                            break;
-                        }
-
-                        ask = 0;
-                        provisionDP(devNum);
-
-                        break;
-                    }
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-                case 13:
+                case 12:
                     {
                         std::cout<< "registering cert chain change notifier"<<std::endl;
                         OCSecure::registerTrustCertChangeNotifier(certChainCallBack);
@@ -1367,7 +1223,7 @@ int main(void)
                         OCSecure::removeTrustCertChangeNotifier();
                         break;
                     }
-                case 14:
+                case 13:
                     {
                         int index;
 
@@ -1386,7 +1242,7 @@ int main(void)
                         }
                         break;
                     }
-                case 15:
+                case 14:
                     {
                         if (0==g_credId)
                         {
@@ -1409,7 +1265,7 @@ int main(void)
                     }
 #endif //__WITH_DTLS__ || __WITH_TLS__
 #ifdef MULTIPLE_OWNER
-                 case 16:
+                 case 15:
                     {
                         if (!pOwnedDevList.size() && !pMOTEnabledDeviceList.size())
                         {
@@ -1505,7 +1361,7 @@ int main(void)
                         }
                          break;
                     }
-                case 17:
+                case 16:
                     {
                         if (!pMOTEnabledDeviceList.size())
                         {
@@ -1556,7 +1412,7 @@ int main(void)
                         }
                          break;
                     }
-                case 18:
+                case 17:
                     {
                         pMOTEnabledDeviceList.clear();
                         std::cout << "Started MOT Enabled device discovery..." <<std::endl;
@@ -1578,7 +1434,7 @@ int main(void)
                         }
                         break;
                     }
-                case 19:
+                case 18:
                     {
                         if (!pMOTEnabledDeviceList.size())
                         {
@@ -1616,7 +1472,7 @@ int main(void)
                         }
                         break;
                     }
-                    case 20:
+                    case 19:
                     {
                         if (!pMOTEnabledDeviceList.size())
                         {
@@ -1655,7 +1511,7 @@ int main(void)
                         break;
                     }
 #endif //MULTIPLE_OWNER
-                case 21:
+                case 20:
                     {
                         OCStackResult result;
                         result = OCSecure::configSelfOwnership();
index 14ba4ae..5dfb632 100644 (file)
@@ -1442,40 +1442,6 @@ namespace OC
         return result;
     }
 
-    OCStackResult OCSecureResource::provisionDirectPairing( const OicSecPconf_t* pconf,
-            ResultCallBack resultCallback)
-    {
-        if (!pconf)
-        {
-            oclog() <<"PCONF can't be null";
-            return OC_STACK_INVALID_PARAM;
-        }
-        if (!resultCallback)
-        {
-            oclog() <<"result callback can not be null";
-            return OC_STACK_INVALID_CALLBACK;
-        }
-
-        OCStackResult result;
-        auto cLock = m_csdkLock.lock();
-
-        if (cLock)
-        {
-            ProvisionContext* context = new ProvisionContext(resultCallback);
-
-            std::lock_guard<std::recursive_mutex> lock(*cLock);
-            result = OCProvisionDirectPairing(static_cast<void*>(context),
-                    devPtr, const_cast<OicSecPconf_t*>(pconf),
-                    &OCSecureResource::callbackWrapper);
-        }
-        else
-        {
-            oclog() <<"Mutex not found";
-            result = OC_STACK_ERROR;
-        }
-        return result;
-    }
-
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     OCStackResult OCSecureResource::provisionTrustCertChain(OicSecCredType_t type, uint16_t credId,
                     ResultCallBack resultCallback)
index 3f4385d..760ad37 100644 (file)
@@ -236,25 +236,6 @@ namespace OCProvisioningTest
         OICFree(acl2);
     }
 
-    TEST(ProvisionDirectPairingTest, ProvisionDirectPairingTestNullPconf)
-    {
-        OCSecureResource device;
-        EXPECT_EQ(OC_STACK_INVALID_PARAM, device.provisionDirectPairing(nullptr, resultCallback));
-    }
-
-    TEST(ProvisionDirectPairingTest, ProvisionDirectPairingTestNullCallback)
-    {
-        OCSecureResource device;
-        OicSecPconf_t *pconf = (OicSecPconf_t *)OICCalloc(1,sizeof(OicSecPconf_t));
-        EXPECT_EQ(OC_STACK_INVALID_CALLBACK, device.provisionDirectPairing(pconf, nullptr));
-        OICFree(pconf);
-    }
-
-    TEST(ProvisionDirectPairingTest, ProvisionDirectPairingTestNullCallbackNUllPconf)
-    {
-        OCSecureResource device;
-        EXPECT_EQ(OC_STACK_INVALID_PARAM, device.provisionDirectPairing(nullptr, nullptr));
-    }
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     TEST(setDeviceIdSeed, NullParam)
     {
index 9158c3d..7c8d2e4 100644 (file)
@@ -1525,146 +1525,4 @@ namespace OC
         return options;
     }
 
-    std::shared_ptr<OCDirectPairing> cloneDevice(const OCDPDev_t* dev)
-    {
-        if (!dev)
-        {
-            return nullptr;
-        }
-
-        OCDPDev_t* result = new OCDPDev_t(*dev);
-        result->prm = new OCPrm_t[dev->prmLen];
-        memcpy(result->prm, dev->prm, sizeof(OCPrm_t)*dev->prmLen);
-        return std::shared_ptr<OCDirectPairing>(new OCDirectPairing(result));
-    }
-
-    void InProcClientWrapper::convert(const OCDPDev_t *list, PairedDevices& dpList)
-    {
-        while(list)
-        {
-            dpList.push_back(cloneDevice(list));
-            list = list->next;
-        }
-    }
-
-    OCStackResult InProcClientWrapper::FindDirectPairingDevices(unsigned short waittime,
-            GetDirectPairedCallback& callback)
-    {
-        if (!callback || 0 == waittime)
-        {
-            return OC_STACK_INVALID_PARAM;
-        }
-
-        OCStackResult result = OC_STACK_ERROR;
-        const OCDPDev_t *list = nullptr;
-        PairedDevices dpDeviceList;
-
-        auto cLock = m_csdkLock.lock();
-
-        if (cLock)
-        {
-            std::lock_guard<std::recursive_mutex> lock(*cLock);
-
-            list = OCDiscoverDirectPairingDevices(waittime);
-            if (NULL == list)
-            {
-                result = OC_STACK_NO_RESOURCE;
-                oclog() << "findDirectPairingDevices(): No device found for direct pairing"
-                    << std::flush;
-            }
-            else {
-                OIC_LOG_V(DEBUG, TAG, "%s: call response callback", __func__);
-                convert(list, dpDeviceList);
-                std::thread exec(callback, dpDeviceList);
-                exec.detach();
-                result = OC_STACK_OK;
-            }
-        }
-        else
-        {
-            result = OC_STACK_ERROR;
-        }
-
-        return result;
-    }
-
-    OCStackResult InProcClientWrapper::GetDirectPairedDevices(GetDirectPairedCallback& callback)
-    {
-        if (!callback)
-        {
-            return OC_STACK_INVALID_PARAM;
-        }
-
-        OCStackResult result = OC_STACK_ERROR;
-        const OCDPDev_t *list = nullptr;
-        PairedDevices dpDeviceList;
-
-        auto cLock = m_csdkLock.lock();
-
-        if (cLock)
-        {
-            std::lock_guard<std::recursive_mutex> lock(*cLock);
-
-            list = OCGetDirectPairedDevices();
-            if (NULL == list)
-            {
-                result = OC_STACK_NO_RESOURCE;
-                OIC_LOG_V(DEBUG, TAG, "%s: No device found for direct pairing", __func__);
-            }
-            else {
-                OIC_LOG_V(DEBUG, TAG, "%s: call response callback", __func__);
-                convert(list, dpDeviceList);
-                std::thread exec(callback, dpDeviceList);
-                exec.detach();
-                result = OC_STACK_OK;
-            }
-        }
-        else
-        {
-            result = OC_STACK_ERROR;
-        }
-
-        return result;
-    }
-
-    void directPairingCallback(void *ctx, OCDPDev_t *peer,
-            OCStackResult result)
-    {
-
-        ClientCallbackContext::DirectPairingContext* context =
-            static_cast<ClientCallbackContext::DirectPairingContext*>(ctx);
-
-        OIC_LOG_V(DEBUG, TAG, "%s: call response callback", __func__);
-        std::thread exec(context->callback, cloneDevice(peer), result);
-        exec.detach();
-    }
-
-    OCStackResult InProcClientWrapper::DoDirectPairing(std::shared_ptr<OCDirectPairing> peer,
-            const OCPrm_t& pmSel, const std::string& pinNumber, DirectPairingCallback& callback)
-    {
-        if (!peer || !callback)
-        {
-            oclog() << "Invalid parameters" << std::flush;
-            return OC_STACK_INVALID_PARAM;
-        }
-
-        OCStackResult result = OC_STACK_ERROR;
-        ClientCallbackContext::DirectPairingContext* context =
-            new ClientCallbackContext::DirectPairingContext(callback);
-
-        auto cLock = m_csdkLock.lock();
-        if (cLock)
-        {
-            std::lock_guard<std::recursive_mutex> lock(*cLock);
-            result = OCDoDirectPairing(static_cast<void*>(context), peer->getDev(),
-                    pmSel, const_cast<char*>(pinNumber.c_str()), directPairingCallback);
-            delete context;
-        }
-        else
-        {
-            delete context;
-            result = OC_STACK_ERROR;
-        }
-        return result;
-    }
 }
diff --git a/resource/src/OCDirectPairing.cpp b/resource/src/OCDirectPairing.cpp
deleted file mode 100644 (file)
index 4e50ac7..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-//******************************************************************
-//
-// Copyright 2016 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "OCDirectPairing.h"
-#include <iomanip>
-
-namespace OC
-{
-    static const char COAP[] = "coap://";
-    static const char COAPS[] = "coaps://";
-    static const int UUID_LENGTH = (128/8); //UUID length
-
-    OCDirectPairing::OCDirectPairing(OCDPDev_t *ptr):m_devPtr(ptr)
-    {
-    }
-
-    std::string OCDirectPairing::getHost()
-    {
-        bool ipv6 = false;
-        std::ostringstream host("");
-        if (m_devPtr->connType & CT_IP_USE_V6)
-        {
-            ipv6 = true;
-        }
-
-        host << COAPS << (ipv6?"[":"") << m_devPtr->endpoint.addr;
-        host << (ipv6?"]:":":") << m_devPtr->securePort;
-
-        return host.str();
-    }
-
-    std::string OCDirectPairing::getDeviceID()
-    {
-        std::ostringstream deviceId("");
-
-        for (int i = 0; i < UUID_LENGTH; i++)
-        {
-            if (i == 4 || i == 6 || i == 8 || i == 10)
-            {
-                deviceId << '-';
-            }
-            deviceId << std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned>(m_devPtr->deviceID.id[i]);
-        }
-
-        return deviceId.str();
-    }
-
-    std::vector<OCPrm_t> OCDirectPairing::getPairingMethods()
-    {
-        std::vector<OCPrm_t> prms;
-
-        for (size_t i = 0; i < m_devPtr->prmLen; i++)
-        {
-            prms.push_back(m_devPtr->prm[i]);
-        }
-        return prms;
-    }
-
-    OCConnectivityType OCDirectPairing::getConnType()
-    {
-        return m_devPtr->connType;
-    }
-
-    OCDPDev_t* OCDirectPairing::getDev()
-    {
-        return m_devPtr;
-    }
-}
index 0fa1db3..bce9e79 100644 (file)
@@ -356,25 +356,6 @@ namespace OC
             return OCPlatform_impl::Instance().sendResponse(pResponse);
         }
 
-        OCStackResult findDirectPairingDevices(unsigned short waittime,
-                                         GetDirectPairedCallback directPairingHandler)
-        {
-            return OCPlatform_impl::Instance().findDirectPairingDevices(waittime,
-                                         directPairingHandler);
-        }
-
-        OCStackResult getDirectPairedDevices(GetDirectPairedCallback directPairingHandler)
-        {
-            return OCPlatform_impl::Instance().getDirectPairedDevices(directPairingHandler);
-        }
-
-        OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
-                                 const std::string& pinNumber,
-                                 DirectPairingCallback resultCallback)
-        {
-            return OCPlatform_impl::Instance().doDirectPairing(peer, pmSel,
-                                             pinNumber, resultCallback);
-        }
 #ifdef WITH_CLOUD
         OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
                                                             OCConnectivityType connectivityType)
index b24da35..93ccecd 100644 (file)
@@ -644,30 +644,6 @@ namespace OC
         return m_csdkLock;
     }
 
-    OCStackResult OCPlatform_impl::findDirectPairingDevices(unsigned short waittime,
-                             GetDirectPairedCallback directPairingHandler)
-    {
-        return checked_guard(m_client, &IClientWrapper::FindDirectPairingDevices,
-                             waittime, directPairingHandler);
-
-    }
-
-    OCStackResult OCPlatform_impl::getDirectPairedDevices(
-                             GetDirectPairedCallback directPairingHandler)
-    {
-
-        return checked_guard(m_client, &IClientWrapper::GetDirectPairedDevices,
-                             directPairingHandler);
-    }
-
-    OCStackResult OCPlatform_impl::doDirectPairing(std::shared_ptr<OCDirectPairing> peer,
-                             OCPrm_t pmSel,
-                             const std::string& pinNumber,
-                             DirectPairingCallback resultCallback)
-    {
-        return checked_guard(m_client, &IClientWrapper::DoDirectPairing,
-                             peer, pmSel, pinNumber, resultCallback);
-    }
 #ifdef WITH_CLOUD
     OCAccountManager::Ptr OCPlatform_impl::constructAccountManagerObject(const std::string& host,
                                                             OCConnectivityType connectivityType)
index 9c1e980..c74feda 100644 (file)
@@ -117,18 +117,17 @@ if 'BROKER' in with_mq:
 # Source files and Targets
 ######################################################################
 oclib_src = [
-    'OCPlatform.cpp',
-    'OCPlatform_impl.cpp',
-    'OCResource.cpp',
-    'OCUtilities.cpp',
-    'OCException.cpp',
-    'OCRepresentation.cpp',
-    'InProcServerWrapper.cpp',
-    'InProcClientWrapper.cpp',
-    'OCResourceRequest.cpp',
-    'CAManager.cpp',
-    'OCDirectPairing.cpp'
-]
+               'OCPlatform.cpp',
+               'OCPlatform_impl.cpp',
+               'OCResource.cpp',
+               'OCUtilities.cpp',
+               'OCException.cpp',
+               'OCRepresentation.cpp',
+               'InProcServerWrapper.cpp',
+               'InProcClientWrapper.cpp',
+               'OCResourceRequest.cpp',
+               'CAManager.cpp',
+       ]
 
 if with_cloud:
     oclib_src = oclib_src + ['OCAccountManager.cpp']
@@ -191,10 +190,7 @@ oclib_env.UserInstallTargetHeader(
 oclib_env.UserInstallTargetHeader(
     header_dir + 'OCUtilities.h', 'resource', 'OCUtilities.h')
 
-oclib_env.UserInstallTargetHeader(
-    header_dir + 'CAManager.h', 'resource', 'CAManager.h')
-oclib_env.UserInstallTargetHeader(
-    header_dir + 'OCDirectPairing.h', 'resource', 'OCDirectPairing.h')
+oclib_env.UserInstallTargetHeader(header_dir + 'CAManager.h', 'resource', 'CAManager.h')
 
 if with_cloud:
     oclib_env.UserInstallTargetHeader(
index dd0a41a..e3054f0 100644 (file)
@@ -76,14 +76,6 @@ namespace OCPlatformTest
     }
 #endif
 
-    void directPairHandler(std::shared_ptr<OCDirectPairing> /*dev*/, OCStackResult /*res*/)
-    {
-    }
-
-    void pairedHandler(const PairedDevices& /*list*/)
-    {
-    }
-
     //Helper methods
     void DeleteStringLL(OCStringLL* ll)
     {
@@ -1111,61 +1103,4 @@ namespace OCPlatformTest
         EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle));
     }
 #endif
-
-    TEST(FindDirectPairingTest, FindDirectPairingNullCallback)
-    {
-        Framework framework;
-        ASSERT_TRUE(OC_STACK_OK == framework.start());
-        EXPECT_ANY_THROW(OCPlatform::findDirectPairingDevices(1, nullptr));
-    }
-
-    TEST(FindDirectPairingTest, FindDirectPairingZeroTimeout)
-    {
-        Framework framework;
-        ASSERT_TRUE(OC_STACK_OK == framework.start());
-        EXPECT_ANY_THROW(OCPlatform::findDirectPairingDevices(0, &pairedHandler));
-    }
-
-    TEST(GetDirectPairedTest, GetDirectPairedNullCallback)
-    {
-        Framework framework;
-        ASSERT_TRUE(OC_STACK_OK == framework.start());
-        EXPECT_ANY_THROW(OCPlatform::getDirectPairedDevices(nullptr));
-    }
-
-    TEST(DoDirectPairingTest, DoDirectPairingNullCallback)
-    {
-        Framework framework;
-        ASSERT_TRUE(OC_STACK_OK == framework.start());
-
-        OCDPDev_t peer;
-        OCPrm_t pmSel = DP_PRE_CONFIGURED;
-        std::string pin("");
-        std::shared_ptr<OCDirectPairing> s_dp(new OCDirectPairing(&peer));
-        EXPECT_ANY_THROW(OCPlatform::doDirectPairing(s_dp, pmSel, pin, nullptr));
-    }
-
-    TEST(DoDirectPairingTest, DoDirectPairingNullPeer)
-    {
-        Framework framework;
-        ASSERT_TRUE(OC_STACK_OK == framework.start());
-
-        OCDPDev_t peer;
-        OCPrm_t pmSel = DP_PRE_CONFIGURED;
-        std::string pin("");
-        std::shared_ptr<OCDirectPairing> s_dp(new OCDirectPairing(&peer));
-        EXPECT_ANY_THROW(OCPlatform::doDirectPairing(nullptr, pmSel, pin, &directPairHandler));
-    }
-
-    TEST(DoDirectPairingTest, DoDirectPairingNullPeerNullCallback)
-    {
-        Framework framework;
-        ASSERT_TRUE(OC_STACK_OK == framework.start());
-
-        OCDPDev_t peer;
-        OCPrm_t pmSel = DP_PRE_CONFIGURED;
-        std::string pin("");
-        std::shared_ptr<OCDirectPairing> s_dp(new OCDirectPairing(&peer));
-        EXPECT_ANY_THROW(OCPlatform::doDirectPairing(nullptr, pmSel, pin, nullptr));
-    }
 }