replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / stack / include / ocstack.h
index 6769fc1..2a9f595 100644 (file)
@@ -57,6 +57,19 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
 /**
  * This function Initializes the OC Stack.  Must be called prior to starting the stack.
  *
+ * @param mode            OCMode Host device is client, server, or client-server.
+ * @param serverFlags     OCTransportFlags Default server transport flags.
+ * @param clientFlags     OCTransportFlags Default client transport flags.
+ * @param transportType   OCTransportAdapter value to initialize.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags,
+                      OCTransportAdapter transportType);
+
+/**
+ * This function Initializes the OC Stack.  Must be called prior to starting the stack.
+ *
  * @param ipAddr      IP Address of host device. Deprecated parameter.
  * @param port        Port of host device. Deprecated parameter.
  * @param mode        OCMode Host device is client, server, or client-server.
@@ -118,6 +131,8 @@ OCStackResult OCProcess();
  * This function discovers or Perform requests on a specified resource
  * (specified by that Resource's respective URI).
  *
+ * @deprecated: Use OCDoRequest instead which does not free given payload.
+ *
  * @param handle            To refer to the request sent out on behalf of
  *                          calling this API. This handle can be used to cancel this operation
  *                          via the OCCancel API.
@@ -125,10 +140,11 @@ OCStackResult OCProcess();
  *                          the consumer.  A NULL handle is permitted in the event where the caller
  *                          has no use for the return value.
  * @param method            To perform on the resource.
- * @param requestUri       URI of the resource to interact with. (Address prefix is deprecated in
+ * @param requestUri        URI of the resource to interact with. (Address prefix is deprecated in
  *                          favor of destination.)
  * @param destination       Complete description of destination.
- * @param payload           Encoded request payload.
+ * @param payload           Encoded request payload,
+                            OCDoResource will free given payload when return OC_STATUS_OK.
  * @param connectivityType  Modifier flags when destination is not given.
  * @param qos               Quality of service. Note that if this API is called on a uri with the
  *                          well-known multicast IP address, the qos will be forced to ::OC_LOW_QOS
@@ -157,6 +173,52 @@ OCStackResult OCDoResource(OCDoHandle *handle,
                            OCCallbackData *cbData,
                            OCHeaderOption *options,
                            uint8_t numOptions);
+
+/**
+ * This function discovers or Perform requests on a specified resource
+ * (specified by that Resource's respective URI).
+ *
+ * @param handle            To refer to the request sent out on behalf of
+ *                          calling this API. This handle can be used to cancel this operation
+ *                          via the OCCancel API.
+ *                          @note: This reference is handled internally, and should not be free'd by
+ *                          the consumer.  A NULL handle is permitted in the event where the caller
+ *                          has no use for the return value.
+ * @param method            To perform on the resource.
+ * @param requestUri        URI of the resource to interact with. (Address prefix is deprecated in
+ *                          favor of destination.)
+ * @param destination       Complete description of destination.
+ * @param payload           Encoded request payload.
+                            OCDoRequest does not free given payload.
+ * @param connectivityType  Modifier flags when destination is not given.
+ * @param qos               Quality of service. Note that if this API is called on a uri with the
+ *                          well-known multicast IP address, the qos will be forced to ::OC_LOW_QOS
+ *                          since it is impractical to send other QOS levels on such addresses.
+ * @param cbData            Asynchronous callback function that is invoked by the stack when
+ *                          discovery or resource interaction is received. The discovery could be
+ *                          related to filtered/scoped/particular resource. The callback is
+ *                          generated for each response received.
+ * @param options           The address of an array containing the vendor specific header options
+ *                          to be sent with the request.
+ * @param numOptions        Number of header options to be included.
+ *
+ * @note: Presence subscription amendments (i.e. adding additional resource type filters by calling
+ * this API again) require the use of the same base URI as the original request to successfully
+ * amend the presence filters.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCDoRequest(OCDoHandle *handle,
+                          OCMethod method,
+                          const char *requestUri,
+                          const OCDevAddr *destination,
+                          OCPayload* payload,
+                          OCConnectivityType connectivityType,
+                          OCQualityOfService qos,
+                          OCCallbackData *cbData,
+                          OCHeaderOption *options,
+                          uint8_t numOptions);
+
 /**
  * This function cancels a request associated with a specific @ref OCDoResource invocation.
  *
@@ -215,7 +277,7 @@ OCStackResult OCStartPresence(const uint32_t ttl);
  */
 
 OCStackResult OCStopPresence();
-#endif
+#endif // WITH_PRESENCE
 
 
 /**
@@ -576,7 +638,7 @@ OCStackResult OCSetProxyURI(const char *uri);
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-OCStackResult OCBindResourceInsToResource(OCResourceHandle handle, uint8_t ins);
+OCStackResult OCBindResourceInsToResource(OCResourceHandle handle, int64_t ins);
 
 /**
  * This function gets the resource unique id for a resource.
@@ -586,7 +648,7 @@ OCStackResult OCBindResourceInsToResource(OCResourceHandle handle, uint8_t ins);
  *
  * @return Ins if resource found or 0 resource not found.
  */
-OCStackResult OCGetResourceIns(OCResourceHandle handle, uint8_t *ins);
+OCStackResult OCGetResourceIns(OCResourceHandle handle, int64_t *ins);
 
 #endif
 
@@ -670,6 +732,14 @@ OCStackResult OCGetDeviceId(OCUUIdentity *deviceId);
  */
 OCStackResult OCSetDeviceId(const OCUUIdentity *deviceId);
 
+ /**
+ * Gets the bool state of "isOwned" property on the doxm resource.
+ *
+ * @param isOwned a pointer to be assigned to isOwned property
+ * @return Returns ::OC_STACK_OK if success.
+ */
+OCStackResult OCGetDeviceOwnedState(bool *isOwned);
+
 /**
  * Encode an address string to match RFC 6874.
  *
@@ -730,6 +800,84 @@ OCStackResult OCSetPropertyValue(OCPayloadType type, const char *propName, const
  */
 OCStackResult OCGetPropertyValue(OCPayloadType type, const char *propName, void **value);
 
+/**
+* Delete client callback info all.
+*/
+void OCClearCallBackList();
+
+/**
+ * Delete observer info all.
+ */
+void OCClearObserverlist();
+
+/**
+ * API to encrypt the un-encrypted DB file before OCRegisterPersistentStorageHandler
+ * If the API is successful, un-encrypted file will be removed, and if the encrypted file
+ * is currupted, then it restores encrypted file using rescue file.
+ *
+ * @param[in] key key used for encryption
+ * @param[in] psPlain OCPersistentStorage for the plain DB
+ * @param[in] psEnc OCPersistentStorage for the encrypted DB
+ * @param[in] psRescue OCPersistentStorage for the rescue DB
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+OCStackResult OCSetSecurePSI(const unsigned char *key, const OCPersistentStorage *psPlain,
+        const OCPersistentStorage *psEnc, const OCPersistentStorage *psRescue);
+
+/**
+ * Generic Encryption function to encrypt data buffer in pt
+ * and update in ct and len in ct_len. (AES-CBC-HMAC)
+ *
+ * @param[in] pt plaintext to be encrypted
+ * @param[in] pt_len length of plaintext
+ * @param[out] ct ciphered text
+ * @param[out] ct_len is length of the ciphered text.
+ *
+ * @return ::0 for Success.
+ */
+int OCEncrypt(const unsigned char *pt, size_t pt_len,
+        unsigned char **ct, size_t *ct_len);
+
+/**
+ * Generic Decryption fucntion to decrypt data buffer in ct
+ * and update in pt and len in pt_len. (AES-CBC-HMAC)
+ *
+ * @param[in] ct ciphered to be decrypted
+ * @param[in] ct_len length of cipher text
+ * @param[out] pt plaintext text
+ * @param[out] pt_len is length of the palintext text.
+ *
+ * @return ::0 for Success.
+ */
+int OCDecrypt(const unsigned char *ct, size_t ct_len,
+        unsigned char **pt, size_t *pt_len);
+
+/**
+ * API to set key to psi
+ *
+ * @param[in] key key used for encryption
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
+ */
+OCStackResult OCSetKey(const unsigned char* key);
+
+/**
+ * API to get key from psi
+ *
+ * @param[out] key key used for encryption
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
+ */
+OCStackResult OCGetKey(unsigned char* key);
+
+/**
+ * API to register OTM event handler
+ *
+ * @param[in] ctx user context returned in the callback
+ * @param[in] cb callback function to receive the OTM event on server side
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
+ */
+OCStackResult OCSetOtmEventHandler(void *ctx, OCOtmEventHandler cb);
+
 #ifdef __cplusplus
 }
 #endif // __cplusplus