Multiple Ownership Transfer support.
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / pmutility.h
index ce2f69d..897ee94 100644 (file)
@@ -37,6 +37,25 @@ extern "C"
 #define COAPS_QUERY "coaps://%s:%d%s"
 #define COAP_QUERY "coap://%s:%d%s"
 
+#define COAP_TCP_PREFIX "coap+tcp://"
+#define COAP_TCP_QUERY "coap+tcp://%s:%d%s"
+#define COAPS_TCP_PREFIX "coaps+tcp://"
+#define COAPS_TCP_QUERY "coaps+tcp://%s:%d%s"
+
+/**
+ * Discover owned/unowned device in the specified endpoint/deviceID.
+ * It will return the found device even though timeout is not exceeded.
+ *
+ * @param[in] waittime           Timeout in seconds
+ * @param[in] deviceID           deviceID of target device.
+ * @param[out] ppFoundDevice     OCProvisionDev_t of found device
+ *
+ * @return OC_STACK_OK on success otherwise error.\n
+ *         OC_STACK_INVALID_PARAM when deviceID is NULL or ppFoundDevice is not initailized.
+ */
+OCStackResult PMSingleDeviceDiscovery(unsigned short waittime, const OicUuid_t* deviceID,
+                                 OCProvisionDev_t **ppFoundDevice);
+
 /**
  * Discover owned/unowned devices in the same IP subnet. .
  *
@@ -48,12 +67,44 @@ extern "C"
  */
 OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisionDev_t **ppList);
 
+#ifdef _ENABLE_MULTIPLE_OWNER_
+/**
+ * Discover multiple OTM enabled devices in the same IP subnet.
+ *
+ * @param[in] waittime      Timeout in seconds.
+ * @param[in] isMultipleOwned       bool flag for MOT enabled / multiple owned discovery
+ * @param[in] ppDevicesList        List of OCProvisionDev_t.
+ *
+ * @return OC_STACK_OK on success otherwise error.
+ */
+OCStackResult PMMultipleOwnerDeviceDiscovery(unsigned short waittime, bool isMultipleOwned, OCProvisionDev_t **ppDevicesList);
+#endif //_ENABLE_MULTIPLE_OWNER_
+
 /**
  * This function deletes list of provision target devices
  *
  * @param[in] pList         List of OCProvisionDev_t.
  */
-void DeleteDeviceList(OCProvisionDev_t **pList);
+void PMDeleteDeviceList(OCProvisionDev_t *pList);
+
+/**
+ * Timeout implementation for secure discovery. When performing secure discovery,
+ * we should wait a certain period of time for getting response of each devices.
+ *
+ * @param[in]  waittime  Timeout in seconds.
+ * @param[in]  waitForStackResponse if true timeout function will call OCProcess while waiting.
+ * @return OC_STACK_OK on success otherwise error.
+ */
+OCStackResult PMTimeout(unsigned short waittime, bool waitForStackResponse);
+
+/**
+ * Function to clone OCProvisionDev_t
+ *
+ * @param[in] src pointer of OCProvisionDev_t to be copied.
+ *
+ * @return copied OCProvisionDev_t on success otherwise NULL.
+ */
+OCProvisionDev_t* PMCloneOCProvisionDev(const OCProvisionDev_t* src);
 
 
 /**
@@ -74,6 +125,24 @@ bool PMGenerateQuery(bool isSecure,
                      OCConnectivityType connType,
                      char* buffer, size_t bufferSize, const char* uri);
 
+/**
+ * Function to print OCProvisionDev_t for debug purpose.
+ *
+ * @param[in] pDev Pointer to OCProvisionDev_t. It's information will be printed by OIC_LOG_XX
+ *
+ */
+void PMPrintOCProvisionDev(const OCProvisionDev_t* pDev);
+
+/** Function to delete matched UUID from the UUIDlist.
+ *
+ * @param[in] pUuidList a pointer to UUID list.
+ * @param[in] targetId  a pointer to UUID to be deleted in the list.
+ *
+ * @return true when deletion is happened, false when no deletion is occured. In case either of
+ * two arguments is null it will return false.
+ */
+bool PMDeleteFromUUIDList(OCUuidList_t **pUuidList, OicUuid_t *targetId);
+
 #ifdef __cplusplus
 }
 #endif