Merge tizen_5.0 codes into tizen_4.0
[platform/upstream/iotivity.git] / resource / csdk / stack / include / ocstack.h
index 0ceded3..96bae43 100644 (file)
 // limitations under the License.
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+
+/**
+ * @file
+ *
+ * This file contains APIs for OIC Stack to be implemented.
+ */
 
 #ifndef OCSTACK_H_
 #define OCSTACK_H_
 
+#include <stdio.h>
 #include <stdint.h>
-#include "ocstackconfig.h"
+#include "octypes.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif // __cplusplus
-#define WITH_PRESENCE
-//-----------------------------------------------------------------------------
-// Defines
-//-----------------------------------------------------------------------------
-
-//TODO: May want to refactor this in upcoming sprints.
-//Don't want to expose to application layer that lower level stack is using CoAP.
-
-/// Authority + URI string to prefix well known queries
-#define OC_WELL_KNOWN_QUERY                  "224.0.1.187:5683/oc/core"
-#define OC_EXPLICIT_DEVICE_DISCOVERY_URI     "224.0.1.187:5683/oc/core/d?rt=core.led"
-/// Multicast address and port string to prefix multicast queries
-#define OC_MULTICAST_PREFIX                  "224.0.1.187:5683"
-/// IP Multicast address to use for multicast requests
-#define OC_MULTICAST_IP                      "224.0.1.187"
-/// IP Multicast port to use for multicast requests
-#define OC_MULTICAST_PORT                    5683
-
-#ifdef WITH_PRESENCE
-#define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
-#define OC_MAX_PRESENCE_TTL_SECONDS     (60 * 60 * 24) // 60 sec/min * 60 min/hr * 24 hr/day
-#define OC_PRESENCE_URI                      "/oc/presence"
-#endif
 
-//-----------------------------------------------------------------------------
-// Typedefs
-//-----------------------------------------------------------------------------
-
-/**
- * Data structure to encapsulate IPv4/IPv6/Contiki/lwIP device addresses.
- */
-typedef struct OCDevAddr
-{
-    uint32_t     size;                    // length of the address stored in addr field.
-    uint8_t      addr[DEV_ADDR_SIZE_MAX]; // device address.
-} OCDevAddr;
-
-/**
- * OC Virtual resources supported by every OC device.
- */
-typedef enum
-{
-    OC_WELL_KNOWN_URI= 0,       // "/oc/core"
-    OC_DEVICE_URI,              // "/oc/core/d"
-    OC_RESOURCE_TYPES_URI,      // "/oc/core/d/type"
-    #ifdef WITH_PRESENCE
-    OC_PRESENCE,                // "/oc/presence"
-    #endif
-    OC_MAX_VIRTUAL_RESOURCES    // Max items in the list
-} OCVirtualResources;
-
-/**
- * Standard RESTful HTTP Methods.
- */
-typedef enum
-{
-    OC_REST_NOMETHOD    = 0,
-    OC_REST_GET         = (1 << 0),     // Read
-    OC_REST_PUT         = (1 << 1),     // Write
-    OC_REST_POST        = (1 << 2),     // Update
-    OC_REST_DELETE      = (1 << 3),     // Delete
-    // Register observe request for most up date notifications ONLY.
-    OC_REST_OBSERVE     = (1 << 4),
-    // Register observe request for all notifications, including stale notifications.
-    OC_REST_OBSERVE_ALL = (1 << 5),
-    // Deregister observation, intended for internal use
-    OC_REST_CANCEL_OBSERVE = (1 << 6),
-    #ifdef WITH_PRESENCE
-    // Subscribe for all presence notifications of a particular resource.
-    OC_REST_PRESENCE    = (1 << 7)
-    #endif
-} OCMethod;
-
-/**
- * Host Mode of Operation.
- */
-typedef enum
-{
-    OC_CLIENT = 0,
-    OC_SERVER,
-    OC_CLIENT_SERVER
-} OCMode;
-
-/**
- * Quality of Service.
- */
-typedef enum
-{
-    OC_LOW_QOS = 0,
-    OC_MEDIUM_QOS,
-    OC_HIGH_QOS,
-    OC_NA_QOS // No Quality is defined, let the stack decide
-} OCQualityOfService;
-
-/**
- * Resource Properties.
- *
- * ::OC_ACTIVE       When this bit is set, the resource is initialized, otherwise the resource
- *                   is 'inactive'. 'inactive' signifies that the resource has been marked for
- *                   deletion or is already deleted.
- * ::OC_DISCOVERABLE When this bit is set, the resource is allowed to be discovered by clients.
- * ::OC_OBSERVABLE   When this bit is set, the resource is allowed to be observed by clients.
- * ::OC_SLOW         When this bit is set, the resource has been marked as 'slow'. 'slow' signifies
- *                   that responses from this resource can expect delays in processing its
- *                   requests from clients.
- * ::OC_SECURE       When this bit is set, the resource is a secure resource.
- */
-typedef enum
-{
-    OC_ACTIVE       = (1 << 0),
-    OC_DISCOVERABLE = (1 << 1),
-    OC_OBSERVABLE   = (1 << 2),
-    OC_SLOW         = (1 << 3),
-    OC_SECURE       = (1 << 4)
-} OCResourceProperty;
-
-/**
- * Transport Protocol IDs.
- */
-typedef enum
-{
-    OC_INVALID_ID   = (1 << 0),
-    OC_COAP_ID      = (1 << 1)
-} OCTransportProtocolID;
-
-/**
- * Adaptor types.
- */
-typedef enum
-{
-    OC_ETHERNET = 0,
-    OC_WIFI,
-    OC_EDR,
-    OC_LE,
-    OC_ALL // Multicast message: send over all the interfaces.
-} OCConnectivityType;
-
-/**
- * Declares Stack Results & Errors.
- */
-typedef enum
-{
-    /* Success status code - START HERE */
-    OC_STACK_OK = 0,
-    OC_STACK_RESOURCE_CREATED,
-    OC_STACK_RESOURCE_DELETED,
-    OC_STACK_CONTINUE,
-    /* Success status code - END HERE */
-    /* Error status code - START HERE */
-    OC_STACK_INVALID_URI = 20,
-    OC_STACK_INVALID_QUERY,
-    OC_STACK_INVALID_IP,
-    OC_STACK_INVALID_PORT,
-    OC_STACK_INVALID_CALLBACK,
-    OC_STACK_INVALID_METHOD,
-    OC_STACK_INVALID_PARAM,
-    OC_STACK_INVALID_OBSERVE_PARAM,
-    OC_STACK_NO_MEMORY,
-    OC_STACK_COMM_ERROR,
-    OC_STACK_TIMEOUT,
-    OC_STACK_ADAPTER_NOT_ENABLED,
-    OC_STACK_NOTIMPL,
-    OC_STACK_NO_RESOURCE,               /* resource not found */
-    OC_STACK_RESOURCE_ERROR,            /* ex: not supported method or interface */
-    OC_STACK_SLOW_RESOURCE,
-    OC_STACK_DUPLICATE_REQUEST,
-    OC_STACK_NO_OBSERVERS,              /* resource has no registered observers */
-    OC_STACK_OBSERVER_NOT_FOUND,
-    OC_STACK_VIRTUAL_DO_NOT_HANDLE,
-    OC_STACK_INVALID_OPTION,
-    OC_STACK_MALFORMED_RESPONSE,        /* the remote reply contained malformed data */
-    OC_STACK_PERSISTENT_BUFFER_REQUIRED,
-    OC_STACK_INVALID_REQUEST_HANDLE,
-    OC_STACK_INVALID_DEVICE_INFO,
-    OC_STACK_INVALID_JSON,
-    /* NOTE: Insert all new error codes here!*/
-    #ifdef WITH_PRESENCE
-    OC_STACK_PRESENCE_STOPPED = 128,
-    OC_STACK_PRESENCE_TIMEOUT,
-    OC_STACK_PRESENCE_DO_NOT_HANDLE,
-    #endif
-    OC_STACK_ERROR = 255
-    /* Error status code - END HERE */
-} OCStackResult;
-
-/**
- * Handle to an @ref OCDoResource invocation.
- */
-typedef void * OCDoHandle;
-
-/**
- * Handle to an OCResource object owned by the OCStack.
- */
-typedef void * OCResourceHandle;
-
-typedef void * OCRequestHandle;
-typedef void * OCResponseHandle;
-
-/**
- * Unique identifier for each observation request. Used when observations are
- * registered or deregistering. Used by entity handler to signal specific
- * observers to be notified of resource changes.
- * There can be maximum of 256 observations per server.
- */
-typedef uint8_t OCObservationId;
-
-/**
- * Action associated with observation.
- */
-typedef enum
-{
-    OC_OBSERVE_REGISTER = 0,
-    OC_OBSERVE_DEREGISTER = 1,
-    OC_OBSERVE_NO_OPTION = 2
-} OCObserveAction;
-
-typedef struct
-{
-    // Action associated with observation request
-    OCObserveAction action;
-    // Identifier for observation being registered/deregistered
-    OCObservationId obsId;
-} OCObservationInfo;
-
-/**
- * Possible returned values from entity handler.
- */
-typedef enum
-{
-    OC_EH_OK = 0,
-    OC_EH_ERROR,
-    OC_EH_RESOURCE_CREATED,
-    OC_EH_RESOURCE_DELETED,
-    OC_EH_SLOW,
-    OC_EH_FORBIDDEN,
-    OC_EH_RESOURCE_NOT_FOUND
-} OCEntityHandlerResult;
-
-/**
- * This structure will be used to define the vendor specific header options to be included
- * in communication packets.
- */
-typedef struct OCHeaderOption
-{
-    // The protocol ID this option applies to
-    OCTransportProtocolID protocolID;
-    // The header option ID which will be added to communication packets
-    uint16_t optionID;
-    // its length   191
-    uint16_t optionLength;
-    // pointer to its data
-    uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
-} OCHeaderOption;
-
-/**
- * Incoming requests handled by the server. Requests are passed in as a parameter to the
- * @ref OCEntityHandler callback API.
- * @brief The @ref OCEntityHandler callback API must be implemented in the application in order
- * to receive these requests.
- */
-typedef struct
-{
-    // Associated resource
-    OCResourceHandle resource;
-    OCRequestHandle requestHandle;
-    // the REST method retrieved from received request PDU
-    OCMethod method;
-    // resource query send by client
-    char * query;
-    // Information associated with observation - valid only when OCEntityHandler
-    // flag includes OC_OBSERVE_FLAG
-    OCObservationInfo obsInfo;
-    // An array of the received vendor specific header options
-    uint8_t numRcvdVendorSpecificHeaderOptions;
-    OCHeaderOption * rcvdVendorSpecificHeaderOptions;
-    // reqJSON is retrieved from the payload of the received request PDU
-    char * reqJSONPayload;
-} OCEntityHandlerRequest;
-
-/**
- * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
- */
-typedef struct
-{
-    // Address of remote server
-    OCDevAddr * addr;
-    // Indicates adaptor type on which the response was received
-    OCConnectivityType connType;
-    // the is the result of our stack, OCStackResult should contain coap/other error codes;
-    OCStackResult result;
-    // If associated with observe, this will represent the sequence of notifications from server.
-    uint32_t sequenceNumber;
-    // resJSONPayload is retrieved from the payload of the received request PDU
-    const char * resJSONPayload;
-    // An array of the received vendor specific header options
-    uint8_t numRcvdVendorSpecificHeaderOptions;
-    OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
-} OCClientResponse;
-
-/**
- * This structure describes the device properties. All non-Null properties will be included
- * in a device discovery request.
- */
-typedef struct
-{
-    char *deviceName;
-    char *hostName;
-    char *deviceUUID;
-    char *contentType;
-    char *version;
-    char *manufacturerName;
-    char *manufacturerUrl;
-    char *modelNumber;
-    char *dateOfManufacture;
-    char *platformVersion;
-    char *firmwareVersion;
-    char *supportUrl;
-} OCDeviceInfo;
-
-typedef struct
-{
-    // Request handle is passed to server via the entity handler for each incoming request.
-    // Stack assigns when request is received, server sets to indicate what request response is for
-    OCRequestHandle requestHandle;
-    // New handle for tracking block (or slow) response.  Stack assigns, server uses for subsequent calls
-    OCResponseHandle  *responseHandle;
-    // Resource handle
-    OCResourceHandle resourceHandle;
-    // Allow the entity handler to pass a result with the response
-    OCEntityHandlerResult  ehResult;
-    // this is the pointer to server payload data to be transferred
-    char *payload;
-    // size of server payload data.  I don't think we should rely on null terminated data for size
-    uint16_t payloadSize;
-    // An array of the vendor specific header options the entity handler wishes to use in response
-    uint8_t numSendVendorSpecificHeaderOptions;
-    OCHeaderOption sendVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
-    // URI of new resource that entity handler might create
-    char resourceUri[MAX_URI_LENGTH];
-    // Server sets to true for persistent response buffer, false for non-persistent response buffer
-    uint8_t persistentBufferFlag;
-} OCEntityHandlerResponse;
-
-typedef enum
-{
-    OC_INIT_FLAG    = (1 << 0),
-    OC_REQUEST_FLAG = (1 << 1),
-    OC_OBSERVE_FLAG = (1 << 2)
-} OCEntityHandlerFlag; //entity_handler_flag_t ;
-
-/**
- * Possible returned values from client application.
- */
-typedef enum
-{
-    OC_STACK_DELETE_TRANSACTION = 0,//!< OC_STACK_DELETE_TRANSACTION
-    OC_STACK_KEEP_TRANSACTION       //!< OC_STACK_KEEP_TRANSACTION
-} OCStackApplicationResult;
-
-//-----------------------------------------------------------------------------
-// Callback function definitions
-//-----------------------------------------------------------------------------
-
-/**
- * Client applications implement this callback to consume responses received from Servers.
- */
-typedef OCStackApplicationResult (* OCClientResponseHandler)(void *context, OCDoHandle handle,
-    OCClientResponse * clientResponse);
-
-/**
- * Client applications using a context pointer implement this callback to delete the
- * context upon removal of the callback/context pointer from the internal callback-list.
- */
-typedef void (* OCClientContextDeleter)(void *context);
+/** Macro to use Random port.*/
+#define USE_RANDOM_PORT (0)
 
 /*
- * This info is passed from application to OC Stack when initiating a request to Server.
+ * Function prototypes
  */
-typedef struct
-{
-    void *context;
-    OCClientResponseHandler cb;
-    OCClientContextDeleter cd;
-} OCCallbackData;
 
 /**
- * Application server implementations must implement this callback to consume requests OTA.
- * Entity handler callback needs to fill the resPayload of the entityHandlerRequest.
+ * 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.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-typedef OCEntityHandlerResult (*OCEntityHandler)
-(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest);
+OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags);
 
 /**
- * Device Entity handler need to use this call back instead of OCEntityHandler.
+ * 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.
  */
-typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
-(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri);
-
-//-----------------------------------------------------------------------------
-// Function prototypes
-//-----------------------------------------------------------------------------
+OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags,
+                      OCTransportAdapter transportType);
 
 /**
- * Initialize the OC Stack.  Must be called prior to starting the stack.
+ * 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
- *     Host device is client, server, or client-server.
+ * @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.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode);
 
+#ifdef RA_ADAPTER
 /**
- * Stop the OC stack.  Use for a controlled shutdown.
+ * @brief   Set Remote Access information for XMPP Client.
+ * @param   raInfo            [IN] remote access info.
  *
- * Note: OCStop() performs operations similar to OCStopPresence(), as well as OCDeleteResource() on
+ * @return  ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCSetRAInfo(const OCRAInfo_t *raInfo);
+#endif
+
+/**
+ * This function Stops the OC stack.  Use for a controlled shutdown.
+ *
+ * @note: OCStop() performs operations similar to OCStopPresence(), as well as OCDeleteResource() on
  * all resources this server is hosting. OCDeleteResource() performs operations similar to
  * OCNotifyAllObservers() to notify all client observers that the respective resource is being
  * deleted.
@@ -456,87 +101,173 @@ OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode);
 OCStackResult OCStop();
 
 /**
- * Called in main loop of OC client or server.  Allows low-level processing of
- * stack services.
+ * This function starts receiving the multicast traffic. This can be only called
+ * when stack is in OC_STACK_INITIALIZED state but device is not receiving multicast
+ * traffic.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCStartMulticastServer();
+
+/**
+ * This function stops receiving the multicast traffic. The rest of the stack
+ * keeps working and no resource are deleted. Device can still receive the unicast
+ * traffic. Once this is set, no response to multicast /oic/res will be sent by the
+ * device. This is to be used for devices that uses other entity to push resources.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCStopMulticastServer();
+
+/**
+ * This function is Called in main loop of OC client or server.
+ * Allows low-level processing of stack services.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCProcess();
 
 /**
- * Discover or Perform requests on a specified resource (specified by that Resource's respective
- * URI).
- *
- * @param handle             @ref OCDoHandle 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             @ref OCMethod to perform on the resource.
- * @param requiredUri        URI of the resource to interact with.
- * @param referenceUri       URI of the reference resource.
- * @param request            JSON encoded request.
- * @param conType            @ref OCConnectivityType type of connectivity indicating the
- *                           interface. Example: ::OC_WIFI, ::OC_ETHERNET, ::OC_ALL.
- * @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 complete.
- * @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 (ie. adding additional resource type filters by calling
+ * 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.
+ *                          @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,
+ *                          OCDoResource will 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 OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri,
-            const char *referenceUri, const char *request, OCConnectivityType conType,
-            OCQualityOfService qos, OCCallbackData *cbData,
-            OCHeaderOption * options, uint8_t numOptions);
+OCStackResult OCDoResource(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 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);
 
 /**
- * Cancel a request associated with a specific @ref OCDoResource invocation.
+ * This function cancels a request associated with a specific @ref OCDoResource invocation.
  *
- * @param handle - Used to identify a specific OCDoResource invocation.
- * @param qos    - used to specify Quality of Service (read below for more info)
- * @param options- used to specify vendor specific header options when sending
- *                 explicit observe cancellation
- * @param numOptions- Number of header options to be included
+ * @param handle       Used to identify a specific OCDoResource invocation.
+ * @param qos          Used to specify Quality of Service(read below).
+ * @param options      Used to specify vendor specific header options when sending
+ *                     explicit observe cancellation.
+ * @param numOptions   Number of header options to be included.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-OCStackResult OCCancel(OCDoHandle handle, OCQualityOfService qos, OCHeaderOption * options,
-        uint8_t numOptions);
+OCStackResult OCCancel(OCDoHandle handle,
+                       OCQualityOfService qos,
+                       OCHeaderOption * options,
+                       uint8_t numOptions);
 
-#ifdef WITH_PRESENCE
 /**
- * When operating in @ref OCServer or @ref OCClientServer mode, this API will start sending out
- * presence notifications to clients via multicast. Once this API has been called with a success,
- * clients may query for this server's presence and this server's stack will respond via multicast.
+ * Register Persistent storage callback.
+ * @param   persistentStorageHandler  Pointers to open, read, write, close & unlink handlers.
+ *
+ * @return
+ *     OC_STACK_OK                    No errors; Success.
+ *     OC_STACK_INVALID_PARAM         Invalid parameter.
+ */
+OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
+
+/**
+ * When operating in  OCServer or  OCClientServer mode,
+ * this API will start sending out presence notifications to clients via multicast.
+ * Once this API has been called with a success, clients may query for this server's presence and
+ * this server's stack will respond via multicast.
  *
  * Server can call this function when it comes online for the first time, or when it comes back
  * online from offline mode, or when it re enters network.
  *
- * @param ttl Time To Live in seconds.
- * Note: If ttl is '0', then the default stack value will be used (60 Seconds).
- *
- *       If ttl is greater than OC_MAX_PRESENCE_TTL_SECONDS, then the ttl will be set to
- *       OC_MAX_PRESENCE_TTL_SECONDS.
+ * @param ttl         Time To Live in seconds.
+ *                    @note: If ttl is '0', then the default stack value will be used (60 Seconds).
+ *                    If ttl is greater than ::OC_MAX_PRESENCE_TTL_SECONDS, then the ttl will be
+ *                    set to ::OC_MAX_PRESENCE_TTL_SECONDS.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCStartPresence(const uint32_t ttl);
 
 /**
- * When operating in @ref OCServer or @ref OCClientServer mode, this API will stop sending out
- * presence notifications to clients via multicast. Once this API has been called with a success,
- * this server's stack will not respond to clients querying for this server's presence.
+ * When operating in OCServer or OCClientServer mode, this API will stop sending
+ * out presence notifications to clients via multicast.
+ * Once this API has been called with a success this server's stack will not respond to clients
+ * querying for this server's presence.
  *
  * Server can call this function when it is terminating, going offline, or when going
  * away from network.
@@ -545,115 +276,124 @@ OCStackResult OCStartPresence(const uint32_t ttl);
  */
 
 OCStackResult OCStopPresence();
-#endif
-
 
 /**
- * Set default device entity handler.
+ * This function sets default device entity handler.
  *
- * @param entityHandler Entity handler function that is called by ocstack to handle requests for
- *                      any undefined resources or default actions.
- *                      If NULL is passed it removes the device default entity handler.
+ * @param entityHandler      Entity handler function that is called by ocstack to handle requests
+ *                           for any undefined resources or default actions.If NULL is passed it
+ *                           removes the device default entity handler.
+ * @param callbackParameter  Parameter passed back when entityHandler is called.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler);
+OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler, void* callbackParameter);
 
 /**
- * Set device information.
+ * This function sets device information.
  *
- * @param deviceInfo - Structure passed by the server application containing
- *                     the device information.
+ * Upon call to OCInit, the default Device Type (i.e. "rt") has already been set to the default
+ * Device Type "oic.wk.d". You do not have to specify "oic.wk.d" in the OCDeviceInfo.types linked
+ * list. The default Device Type is mandatory and always specified by this Device as the first
+ * Device Type.
  *
+ * @param deviceInfo   Structure passed by the server application containing the device
+ *                     information.
  *
  * @return
- *     OC_STACK_OK              - no errors
- *     OC_STACK_INVALID_PARAM   - invalid paramerter
- *     OC_STACK_ERROR           - stack process error
+ *     ::OC_STACK_OK               no errors.
+ *     ::OC_STACK_INVALID_PARAM    invalid parameter.
+ *     ::OC_STACK_ERROR            stack process error.
  */
 OCStackResult OCSetDeviceInfo(OCDeviceInfo deviceInfo);
 
 /**
- * Create a resource.
+ * This function sets platform information.
  *
- * @param handle Pointer to handle to newly created resource.  Set by ocstack and
- *               used to refer to resource.
- * @param resourceTypeName Name of resource type.  Example: "core.led".
- * @param resourceInterfaceName Name of resource interface.  Example: "core.rw".
- * @param uri URI of the resource.  Example:  "/a/led".
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
- *                      NULL for default entity handler.
- * @param resourceProperties Properties supported by resource.
- *                           Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE.
+ * @param platformInfo   Structure passed by the server application containing
+ *                       the platform information.
  *
- * @return ::OC_STACK_OK on success, some other value upon failure.
+ *
+ * @return
+ *     ::OC_STACK_OK               no errors.
+ *     ::OC_STACK_INVALID_PARAM    invalid parameter.
+ *     ::OC_STACK_ERROR            stack process error.
  */
-OCStackResult OCCreateResource(OCResourceHandle *handle,
-                               const char *resourceTypeName,
-                               const char *resourceInterfaceName,
-                               const char *uri,
-                               OCEntityHandler entityHandler,
-                               uint8_t resourceProperties);
+OCStackResult OCSetPlatformInfo(OCPlatformInfo platformInfo);
 
 /**
- * Create a resource. with host ip address for remote resource.
+ * This function creates a resource.
  *
- * @param handle Pointer to handle to newly created resource.  Set by ocstack.
- *               Used to refer to resource.
- * @param resourceTypeName Name of resource type.  Example: "core.led".
+ * @param handle                Pointer to handle to newly created resource. Set by ocstack and
+ *                              used to refer to resource.
+ * @param resourceTypeName      Name of resource type.  Example: "core.led".
  * @param resourceInterfaceName Name of resource interface.  Example: "core.rw".
- * @param host HOST address of the remote resource.  Example:  "coap://xxx.xxx.xxx.xxx:xxxxx".
- * @param uri URI of the resource.  Example:  "/a/led".
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
- *                      NULL for default entity handler.
- * @param resourceProperties Properties supported by resource.
- *                           Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE
+ * @param uri                   URI of the resource.  Example:  "/a/led".
+ * @param entityHandler         Entity handler function that is called by ocstack to handle
+ *                              requests, etc.
+ *                              NULL for default entity handler.
+ * @param callbackParam     parameter passed back when entityHandler is called.
+ * @param resourceProperties    Properties supported by resource.
+ *                              Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-OCStackResult OCCreateResourceWithHost(OCResourceHandle *handle,
+OCStackResult OCCreateResource(OCResourceHandle *handle,
                                const char *resourceTypeName,
                                const char *resourceInterfaceName,
-                               const char *host,
                                const char *uri,
                                OCEntityHandler entityHandler,
+                               void* callbackParam,
                                uint8_t resourceProperties);
 
 /**
- * Add a resource to a collection resource.
+ * This function adds a resource to a collection resource.
  *
- * @param collectionHandle Handle to the collection resource.
- * @param resourceHandle Handle to resource to be added to the collection resource.
+ * @param collectionHandle    Handle to the collection resource.
+ * @param resourceHandle      Handle to resource to be added to the collection resource.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCBindResource(OCResourceHandle collectionHandle, OCResourceHandle resourceHandle);
 
 /**
- * Remove a resource from a collection resource.
+ * This function removes a resource from a collection resource.
  *
- * @param collectionHandle Handle to the collection resource.
- * @param resourceHandle Handle to resource to be removed from the collection resource.
+ * @param collectionHandle   Handle to the collection resource.
+ * @param resourceHandle     Handle to resource to be removed from the collection resource.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCUnBindResource(OCResourceHandle collectionHandle, OCResourceHandle resourceHandle);
 
 /**
- * Bind a resourcetype to a resource.
+ * This function binds a resource type to a resource.
  *
- * @param handle Handle to the resource.
- * @param resourceTypeName Name of resource type.  Example: "core.led".
+ * @param handle            Handle to the resource.
+ * @param resourceTypeName  Name of resource type.  Example: "core.led".
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
                                            const char *resourceTypeName);
+
 /**
- * Bind a resource interface to a resource.
+ * This function clears all bound resource types and bind newly passing
+ * resource type to resource.
  *
- * @param handle Handle to the resource.
- * @param resourceInterfaceName Name of resource interface.  Example: "core.rw".
+ * @param handle            Handle to the resource.
+ * @param newResourceType   Name of resource type.  Example: "core.led".
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCResetResourceTypes(OCResourceHandle handle,
+                                   const char *newResourceType);
+
+/**
+ * This function binds a resource interface to a resource.
+ *
+ * @param handle                  Handle to the resource.
+ * @param resourceInterfaceName   Name of resource interface.  Example: "core.rw".
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
@@ -661,88 +401,119 @@ OCStackResult OCBindResourceInterfaceToResource(OCResourceHandle handle,
                                                 const char *resourceInterfaceName);
 
 /**
- * Bind an entity handler to the resource.
+ * This function clears all bound interfaces and bind newly passing
+ * interface to resource.
+ *
+ * @param handle                  Handle to the resource.
+ * @param newResourceInterface    Name of resource interface.  Example: "core.rw".
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult OCResetResourceInterfaces(OCResourceHandle handle,
+                                        const char *newResourceInterface);
+
+/**
+ * This function binds an entity handler to the resource.
+ *
+ * @param handle            Handle to the resource that the contained resource is to be bound.
+ * @param entityHandler     Entity handler function that is called by ocstack to handle requests.
+ * @param callbackParameter Context parameter that will be passed to entityHandler.
  *
- * @param handle Handle to the resource that the contained resource is to be bound.
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-OCStackResult OCBindResourceHandler(OCResourceHandle handle, OCEntityHandler entityHandler);
+OCStackResult OCBindResourceHandler(OCResourceHandle handle,
+                                    OCEntityHandler entityHandler,
+                                    void *callbackParameter);
 
 /**
- * Get the number of resources that have been created in the stack.
+ * This function gets the number of resources that have been created in the stack.
  *
- * @param numResources Pointer to count variable.
+ * @param numResources    Pointer to count variable.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCGetNumberOfResources(uint8_t *numResources);
 
 /**
- * Get a resource handle by index.
+ * This function gets a resource handle by index.
  *
- * @param index Index of resource, 0 to Count - 1.
+ * @param index   Index of resource, 0 to Count - 1.
  *
- * @return Found resource handle or NULL if not found.
+ * @return Found  resource handle or NULL if not found.
  */
 OCResourceHandle OCGetResourceHandle(uint8_t index);
 
 /**
- * Delete resource specified by handle.  Deletes resource and all resourcetype and resourceinterface
- * linked lists.
+ * This function deletes resource specified by handle.  Deletes resource and all
+ * resource type and resource interface linked lists.
  *
- * Note: OCDeleteResource() performs operations similar to OCNotifyAllObservers() to notify all
+ * @note: OCDeleteResource() performs operations similar to OCNotifyAllObservers() to notify all
  * client observers that "this" resource is being deleted.
  *
- * @param handle Handle of resource to be deleted.
+ * @param handle          Handle of resource to be deleted.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCDeleteResource(OCResourceHandle handle);
 
 /**
- * Get the URI of the resource specified by handle.
+ * Get a string representation the server instance ID.
+ * The memory is managed internal to this function, so freeing externally will result
+ * in a runtime error.
+ * Note: This will NOT seed the RNG, so it must be called after the RNG is seeded.
+ * This is done automatically during the OCInit process,
+ * so ensure that this call is done after that.
+ *
+ * @return A string representation  the server instance ID.
+ */
+const char* OCGetServerInstanceIDString(void);
+
+/**
+ * This function gets the URI of the resource specified by handle.
+ *
+ * @param handle     Handle of resource.
  *
- * @param handle Handle of resource.
  * @return URI string if resource found or NULL if not found.
  */
 const char *OCGetResourceUri(OCResourceHandle handle);
 
 /**
- * Get the properties of the resource specified by handle.
- * NOTE: that after a resource is created, the OC_ACTIVE property is set
- * for the resource by the stack.
+ * This function gets the properties of the resource specified by handle.
+ *
+ * @param handle                Handle of resource.
+ *
+ * @return OCResourceProperty   Bitmask or -1 if resource is not found.
  *
- * @param handle Handle of resource.
- * @return OCResourceProperty Bitmask or -1 if resource is not found.
+ * @note that after a resource is created, the OC_ACTIVE property is set for the resource by the
+ * stack.
  */
 OCResourceProperty OCGetResourceProperties(OCResourceHandle handle);
 
 /**
- * Get the number of resource types of the resource.
+ * This function gets the number of resource types of the resource.
  *
- * @param handle Handle of resource.
- * @param numResourceTypes Pointer to count variable.
+ * @param handle            Handle of resource.
+ * @param numResourceTypes  Pointer to count variable.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCGetNumberOfResourceTypes(OCResourceHandle handle, uint8_t *numResourceTypes);
 
 /**
- * Get name of resource type of the resource.
+ * This function gets name of resource type of the resource.
  *
- * @param handle Handle of resource.
- * @param index Index of resource, 0 to Count - 1.
+ * @param handle       Handle of resource.
+ * @param index        Index of resource, 0 to Count - 1.
  *
  * @return Resource type name if resource found or NULL if resource not found.
  */
 const char *OCGetResourceTypeName(OCResourceHandle handle, uint8_t index);
 
 /**
- * Get the number of resource interfaces of the resource.
+ * This function gets the number of resource interfaces of the resource.
  *
- * @param handle Handle of resource.
- * @param numResourceInterfaces Pointer to count variable.
+ * @param handle                 Handle of resource.
+ * @param numResourceInterfaces  Pointer to count variable.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
@@ -750,30 +521,30 @@ OCStackResult OCGetNumberOfResourceInterfaces(OCResourceHandle handle,
         uint8_t *numResourceInterfaces);
 
 /**
- * Get name of resource interface of the resource.
+ * This function gets name of resource interface of the resource.
  *
- * @param handle Handle of resource.
- * @param index Index of resource, 0 to Count - 1.
+ * @param handle      Handle of resource.
+ * @param index       Index of resource, 0 to Count - 1.
  *
  * @return Resource interface name if resource found or NULL if resource not found.
  */
 const char *OCGetResourceInterfaceName(OCResourceHandle handle, uint8_t index);
 
 /**
- * Get methods of resource interface of the resource.
+ * This function gets methods of resource interface of the resource.
  *
- * @param handle Handle of resource.
- * @param index Index of resource, 0 to Count - 1.
+ * @param handle      Handle of resource.
+ * @param index       Index of resource, 0 to Count - 1.
  *
  * @return Allowed methods if resource found or NULL if resource not found.
  */
 uint8_t OCGetResourceInterfaceAllowedMethods(OCResourceHandle handle, uint8_t index);
 
 /**
- * Get resource handle from the collection resource by index.
+ * This function gets resource handle from the collection resource by index.
  *
- * @param collectionHandle Handle of collection resource.
- * @param index Index of contained resource, 0 to Count - 1.
+ * @param collectionHandle   Handle of collection resource.
+ * @param index              Index of contained resource, 0 to Count - 1.
  *
  * @return Handle to contained resource if resource found or NULL if resource not found.
  */
@@ -781,21 +552,21 @@ OCResourceHandle OCGetResourceHandleFromCollection(OCResourceHandle collectionHa
         uint8_t index);
 
 /**
- * Get the entity handler for a resource.
+ * This function gets the entity handler for a resource.
  *
- * @param handle Handle of resource.
+ * @param handle            Handle of resource.
  *
  * @return Entity handler if resource found or NULL resource not found.
  */
 OCEntityHandler OCGetResourceHandler(OCResourceHandle handle);
 
 /**
- * Notify all registered observers that the resource representation has
- * changed. If observation includes a query the client is notified only
- * if the query is valid after the resource representation has changed.
+ * This function notify all registered observers that the resource representation has
+ * changed. If observation includes a query the client is notified only if the query is valid after
+ * the resource representation has changed.
  *
- * @param handle Handle of resource.
- * @param qos    Desired quality of service for the observation notifications.
+ * @param handle   Handle of resource.
+ * @param qos      Desired quality of service for the observation notifications.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
@@ -806,76 +577,339 @@ OCStackResult OCNotifyAllObservers(OCResourceHandle handle, OCQualityOfService q
  * Before this API is invoked by entity handler it has finished processing
  * queries for the associated observers.
  *
- * @param handle Handle of resource.
- * @param obsIdList List of observation ids that need to be notified.
- * @param numberOfIds Number of observation ids included in obsIdList.
- * @param notificationJSONPayload JSON encoded payload to send in notification.
- * @param qos Desired quality of service of the observation notifications.
- * NOTE: The memory for obsIdList and notificationJSONPayload is managed by the
- * entity invoking the API. The maximum size of the notification is 1015 bytes
- * for non-Arduino platforms. For Arduino the maximum size is 247 bytes.
+ * @param handle                    Handle of resource.
+ * @param obsIdList                 List of observation IDs that need to be notified.
+ * @param numberOfIds               Number of observation IDs included in obsIdList.
+ * @param payload                   Object representing the notification
+ * @param qos                       Desired quality of service of the observation notifications.
+ *
+ * @note: The memory for obsIdList and payload is managed by the entity invoking the API.
+ * The maximum size of the notification is 1015 bytes for non-Arduino platforms. For Arduino
+ * the maximum size is 247 bytes.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult
 OCNotifyListOfObservers (OCResourceHandle handle,
-                            OCObservationId  *obsIdList,
-                            uint8_t          numberOfIds,
-                            const char    *notificationJSONPayload,
-                            OCQualityOfService qos);
+                         OCObservationId  *obsIdList,
+                         uint8_t          numberOfIds,
+                         const OCRepPayload *payload,
+                         OCQualityOfService qos);
 
 
 /**
- * Send a response to a request.
+ * This function sends a response to a request.
  * The response can be a normal, slow, or block (i.e. a response that
  * is too large to be sent in a single PDU and must span multiple transmissions).
  *
- * @param response Pointer to structure that contains response parameters.
+ * @param response   Pointer to structure that contains response parameters.
  *
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
 OCStackResult OCDoResponse(OCEntityHandlerResponse *response);
 
+//#ifdef DIRECT_PAIRING
 /**
- * Cancel a response.  Applies to a block response.
+ * 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 responseHandle Response handle set by stack in OCServerResponse after
- *                       OCDoResponse is called.
+ * @param[in] timeout 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* 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 ::OC_STACK_OK on success, some other value upon failure.
+ * @return OCDirectPairingDev_t pointer in case of success and NULL otherwise.
  */
-OCStackResult OCCancelResponse(OCResponseHandle responseHandle);
+const OCDPDev_t* OCGetDirectPairedDevices();
 
-//Utility methods
+/**
+ * The function is responsible for establishment of direct-pairing. It will proceed mode negotiation
+ * and connect PIN based dtls session.
+ *
+ * @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 OCDoDirectPairing(void *ctx, OCDPDev_t* peer, OCPrm_t pmSel, char *pinNumber,
+                                OCDirectPairingCB resultCallback);
 
+#ifdef WITH_CHPROXY
 /**
- * This method is used to retrieved the IPv4 address from OCDev address
- * data structure.
+ * This function sets uri being used for proxy.
  *
- * @param ipAddr OCDevAddr address.
- * @param a first byte of IPv4 address.
- * @param b second byte of IPv4 address.
- * @param c third byte of IPv4 address.
- * @param d fourth byte of IPv4 address.
- * @return ::OC_STACK_OK on success, some other value upon failure.
+ * @param uri            NULL terminated resource uri for CoAP-HTTP Proxy.
  */
-int32_t OCDevAddrToIPv4Addr(OCDevAddr *ipAddr, uint8_t *a, uint8_t *b,
-            uint8_t *c, uint8_t *d );
+OCStackResult OCSetProxyURI(const char *uri);
+#endif
 
+#if defined(RD_CLIENT) || defined(RD_SERVER)
 /**
- * This method is used to retrieve the port number from OCDev address
- * data structure.
+ * This function binds an resource unique id to the resource.
+ *
+ * @param handle            Handle to the resource that the contained resource is to be bound.
+ * @param ins               Unique ID for resource.
  *
- * @param ipAddr OCDevAddr address.
- * @param port Port number.
  * @return ::OC_STACK_OK on success, some other value upon failure.
  */
-int32_t OCDevAddrToPort(OCDevAddr *ipAddr, uint16_t *port);
+OCStackResult OCBindResourceInsToResource(OCResourceHandle handle, int64_t ins);
+
+/**
+ * This function gets the resource unique id for a resource.
+ *
+ * @param handle            Handle of resource.
+ * @param ins               Unique ID for resource.
+ *
+ * @return Ins if resource found or 0 resource not found.
+ */
+OCStackResult OCGetResourceIns(OCResourceHandle handle, int64_t *ins);
+
+#endif
+
+/**
+* This function gets a resource handle by resource uri.
+*
+* @param uri   Uri of Resource to get Resource handle.
+*
+* @return Found  resource handle or NULL if not found.
+*/
+OCResourceHandle OCGetResourceHandleAtUri(const char *uri);
+
+
+#ifdef RD_SERVER
+/**
+* Search the RD database for queries.
+*
+* @param interfaceType is the interface type that is queried.
+* @param resourceType is the resource type that is queried.
+* @param discPayload is NULL if no resource found or else OCDiscoveryPayload with the details
+* about the resource.
+*
+* @return ::OC_STACK_OK in case of success or else other value.
+*/
+OCStackResult OCRDDatabaseCheckResources(const char *interfaceType, const char *resourceType,
+    OCDiscoveryPayload *discPayload);
+#endif
+//#endif // DIRECT_PAIRING
+
+/**
+ *  Add a header option to the given header option array.
+ *
+ * @param ocHdrOpt            Pointer to existing options.
+ * @param numOptions          Number of existing options.
+ * @param optionID            COAP option ID.
+ * @param optionData          Option data value.
+ * @param optionDataLength    Size of Option data value.
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+OCStackResult
+OCSetHeaderOption(OCHeaderOption* ocHdrOpt,
+                  size_t* numOptions,
+                  uint16_t optionID,
+                  const void* optionData,
+                  size_t optionDataLength);
+
+/**
+ *  Get data value of the option with specified option ID from given header option array.
+ *
+ * @param ocHdrOpt            Pointer to existing options.
+ * @param numOptions          Number of existing options.
+ * @param optionID            COAP option ID.
+ * @param optionData          Pointer to option data.
+ * @param optionDataLength    Size of option data value.
+ * @param receivedDatalLength Pointer to the actual length of received data.
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+OCStackResult
+OCGetHeaderOption(OCHeaderOption* ocHdrOpt,
+                  size_t numOptions,
+                  uint16_t optionID,
+                  void* optionData,
+                  size_t optionDataLength,
+                  uint16_t* receivedDatalLength);
+
+/**
+ * gets the deviceId of the client
+ *
+ * @param deviceId pointer.
+ * @return Returns ::OC_STACK_OK if success.
+ */
+OCStackResult OCGetDeviceId(OCUUIdentity *deviceId);
+
+/**
+ * sets the deviceId of the client
+ *
+ * @param deviceId pointer.
+ * @return Returns ::OC_STACK_OK if success.
+ */
+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.
+ *
+ * @param outputAddress    a char array to be written with the encoded string.
+ *
+ * @param outputSize       size of outputAddress buffer.
+ *
+ * @param inputAddress     a char array of size <= CA_MAX_URI_LENGTH
+ *                         containing a valid IPv6 address string.
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+OCStackResult OCEncodeAddressForRFC6874(char* outputAddress,
+                                        size_t outputSize,
+                                        const char* inputAddress);
+
+/**
+ * Decode an address string according to RFC 6874.
+ *
+ * @param outputAddress    a char array to be written with the decoded string.
+ *
+ * @param outputSize       size of outputAddress buffer.
+ *
+ * @param inputAddress     a valid percent-encoded address string.
+ *
+ * @param end              NULL if the entire entire inputAddress is a null-terminated percent-
+ *                         encoded address string.  Otherwise, a pointer to the first byte that
+ *                         is not part of the address string (e.g., ']' in a URI).
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+OCStackResult OCDecodeAddressForRFC6874(char* outputAddress,
+                                        size_t outputSize,
+                                        const char* inputAddress,
+                                        const char* end);
+
+/**
+ * Set the value of /oic/d and /oic/p properties. This function is a generic function that sets for
+ * all OCF defined properties.
+ *
+ * @param type the payload type for device and platform as defined in @ref OCPayloadType.
+ * @param propName the pre-defined property as per OCF spec.
+ * @param value the value of the property to be set.
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+OCStackResult OCSetPropertyValue(OCPayloadType type, const char *propName, const void *value);
+
+/**
+ * Get the value of /oic/d and /oic/p properties. This function is a generic function that get value
+ * for all OCF defined properties.
+ *
+ * @param type the payload type for device and platform as defined in @ref OCPayloadType.
+ * @param propName the pre-defined as per OCF spec.
+ * @param value this holds the return value.  In case of error will be set to NULL.
+ *
+ * @return ::OC_STACK_OK on success and other value otherwise.
+ */
+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);
+
+ /**
+ * Gets the bool state of "isOp" property on the pstat resource
+ * @param isOp a pointer to be assigned to isop property
+ * @return Returns ::OC_STACK_OK.
+ */
+
+OCStackResult OCGetDeviceOperationalState(bool* isOp);
 
 #ifdef __cplusplus
 }
 #endif // __cplusplus
 
 #endif /* OCSTACK_H_ */
-
-