/** Resource Type.*/
#define OC_RSRVD_RESOURCE_TYPES_URI "/oic/res/types/d"
-#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
+
/** Gateway URI.*/
#define OC_RSRVD_GATEWAY_URI "/oic/gateway"
-#endif
-#ifdef WITH_PRESENCE
+
+/** MQ Broker URI.*/
+#define OC_RSRVD_WELL_KNOWN_MQ_URI "/oic/ps"
+
+
+/** Presence */
/** Presence URI through which the OIC devices advertise their presence.*/
#define OC_RSRVD_PRESENCE_URI "/oic/ad"
+/** Presence URI through which the OIC devices advertise their device presence.*/
+#define OC_RSRVD_DEVICE_PRESENCE_URI "/oic/prs"
+
/** Sets the default time to live (TTL) for presence.*/
-#define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
+#define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
/** For multicast Discovery mechanism.*/
-#define OC_MULTICAST_DISCOVERY_URI "/oic/res"
+#define OC_MULTICAST_DISCOVERY_URI "/oic/res"
/** Separator for multiple query string.*/
-#define OC_QUERY_SEPARATOR "&;"
+#define OC_QUERY_SEPARATOR "&;"
/**
* OC_DEFAULT_PRESENCE_TTL_SECONDS sets the default time to live (TTL) for presence.
* 60 sec/min * 60 min/hr * 24 hr/day
*/
#define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24)
-#endif
+
/**
* Presence "Announcement Triggers".
#define OC_RSRVD_OC "oic"
+
/** For payload. */
#define OC_RSRVD_PAYLOAD "payload"
/** To represent resource type with platform.*/
#define OC_RSRVD_RESOURCE_TYPE_PLATFORM "oic.wk.p"
+/** To represent resource type with RES.*/
+#define OC_RSRVD_RESOURCE_TYPE_RES "oic.wk.res"
+
+/** To represent content type with MQ Broker.*/
+#define OC_RSRVD_RESOURCE_TYPE_MQ_BROKER "oic.wk.ps"
+
+/** To represent content type with MQ Topic.*/
+#define OC_RSRVD_RESOURCE_TYPE_MQ_TOPIC "oic.wk.ps.topic"
+
+
/** To represent interface.*/
#define OC_RSRVD_INTERFACE "if"
+/** To indicate how long RD should publish this item.*/
+#define OC_RSRVD_DEVICE_TTL "lt"
+
/** To represent time to live.*/
#define OC_RSRVD_TTL "ttl"
/** Port. */
#define OC_RSRVD_HOSTING_PORT "port"
+/** TCP Port. */
+#define OC_RSRVD_TCP_PORT "x.org.iotivity.tcp"
+
/** For Server instance ID.*/
#define OC_RSRVD_SERVER_INSTANCE_ID "sid"
#define OC_RSRVD_SUPPORT_URL "mnsl"
/** System time for the platform. */
-#define OC_RSRVD_SYSTEM_TIME "st"
+#define OC_RSRVD_SYSTEM_TIME "st"
/**
* Device.
#define OC_RSRVD_DATA_MODEL_VERSION "dmv"
/** Device specification version.*/
-#define OC_SPEC_VERSION "core.1.0.0"
+#define OC_SPEC_VERSION "core.1.0.0"
/** Device Data Model version.*/
-#define OC_DATA_MODEL_VERSION "res.1.0.0"
+#define OC_DATA_MODEL_VERSION "res.1.0.0"
/**
* These provide backward compatibility - their use is deprecated.
#ifndef GOING_AWAY
/** Multicast Prefix.*/
-#define OC_MULTICAST_PREFIX "224.0.1.187:5683"
+#define OC_MULTICAST_PREFIX "224.0.1.187:5683"
/** Multicast IP address.*/
-#define OC_MULTICAST_IP "224.0.1.187"
+#define OC_MULTICAST_IP "224.0.1.187"
/** Multicast Port.*/
-#define OC_MULTICAST_PORT 5683
+#define OC_MULTICAST_PORT (5683)
#endif // GOING_AWAY
/** Max Device address size. */
#ifdef RA_ADAPTER
#define MAX_ADDR_STR_SIZE (256)
#else
-/** Max Address could be "coap+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:xxxxx" */
-#define MAX_ADDR_STR_SIZE (59)
+/** Max Address could be
+ * "coaps+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx"
+ * +1 for null terminator.
+ */
+#define MAX_ADDR_STR_SIZE (66)
#endif
/** Length of MAC address */
#define MAC_ADDR_BLOCKS (6)
/** Max identity size. */
-#define MAX_IDENTITY_SIZE (32)
+#define MAX_IDENTITY_SIZE (37)
/** Universal unique identity size. */
#define UUID_IDENTITY_SIZE (128/8)
#define OC_RSRVD_TITLE "title"
/** Defines URI. */
-#define OC_RSRVD_URI "uri"
+#define OC_RSRVD_URI "anchor"
/** Defines media type. */
-#define OC_RSRVD_MEDIA_TYPE "mt"
+#define OC_RSRVD_MEDIA_TYPE "type"
/** To represent resource type with Publish RD.*/
-#define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdPub"
+#define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdpub"
+
+/** Cloud Account */
+
+/** Account URI.*/
+#define OC_RSRVD_ACCOUNT_URI "/oic/account"
+
+/** Account session URI.*/
+#define OC_RSRVD_ACCOUNT_SESSION_URI "/oic/account/session"
+
+/** Account token refresh URI.*/
+#define OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI "/oic/account/tokenrefresh"
+
+/** ACL group URI.*/
+#define OC_RSRVD_ACL_GROUP_URI "/oic/acl/group"
+
+/** ACL invite URI.*/
+#define OC_RSRVD_ACL_INVITE_URI "/oic/acl/invite"
+
+/** Defines auth provider. */
+#define OC_RSRVD_AUTHPROVIDER "authprovider"
+
+/** Defines auth code. */
+#define OC_RSRVD_AUTHCODE "authcode"
+
+/** Defines access token. */
+#define OC_RSRVD_ACCESS_TOKEN "accesstoken"
+
+/** Defines login. */
+#define OC_RSRVD_LOGIN "login"
+
+/** Defines search. */
+#define OC_RSRVD_SEARCH "search"
+
+/** Defines grant type. */
+#define OC_RSRVD_GRANT_TYPE "granttype"
+
+/** Defines refresh token. */
+#define OC_RSRVD_REFRESH_TOKEN "refreshtoken"
+
+/** Defines user UUID. */
+#define OC_RSRVD_USER_UUID "uid"
+
+/** Defines user ID. */
+#define OC_RSRVD_USER_ID "userid"
+
+/** Defines group ID. */
+#define OC_RSRVD_GROUP_ID "gid"
+
+/** Defines group Master ID. */
+#define OC_RSRVD_GROUP_MASTER_ID "gmid"
+
+/** Defines group type. */
+#define OC_RSRVD_GROUP_TYPE "gtype"
+
+/** Defines member of group ID. */
+#define OC_RSRVD_MEMBER_ID "mid"
+
+/** Defines device ID list. */
+#define OC_RSRVD_DEVICE_ID_LIST "dilist"
+
+/** Defines public. */
+#define OC_RSRVD_PUBLIC "Public"
+
+/** Defines private. */
+#define OC_RSRVD_PRIVATE "Private"
+
+/** Defines options. */
+#define OC_RSRVD_INVITE "invite"
+
+/** Defines options. */
+#define OC_RSRVD_OPTIONS "options"
+
+/** To represent grant type with refresh token. */
+#define OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN "refresh_token"
+
+/**
+ * Mark a parameter as unused. Used to prevent unused variable compiler warnings.
+ * Used in three cases:
+ * 1. in callbacks when one of the parameters are unused
+ * 2. when due to code changes a functions parameter is no longer
+ * used but must be left in place for backward compatibility
+ * reasons.
+ * 3. a variable is only used in the debug build variant and would
+ * give a build warning in release mode.
+ */
+#define OC_UNUSED(x) (void)(x)
/**
* These enums (OCTransportAdapter and OCTransportFlags) must
OC_FLAG_SECURE = (1 << 4),
/** IPv4 & IPv6 auto-selection is the default.*/
- /** IP adapter only.*/
+ /** IP & TCP adapter only.*/
OC_IP_USE_V6 = (1 << 5),
- /** IP adapter only.*/
+ /** IP & TCP adapter only.*/
OC_IP_USE_V4 = (1 << 6),
- /** internal use only.*/
- OC_RESERVED1 = (1 << 7), // internal use only
+ /** Multicast only.*/
+ OC_MULTICAST = (1 << 7),
/** Link-Local multicast is the default multicast scope for IPv6.
* These are placed here to correspond to the IPv6 multicast address bits.*/
char addr[MAX_ADDR_STR_SIZE];
/** usually zero for default interface.*/
- uint32_t interface;
+ uint32_t ifindex;
#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
char routeData[MAX_ADDR_STR_SIZE]; //destination GatewayID:ClientId
#endif
/** De-register observation, intended for internal use.*/
OC_REST_CANCEL_OBSERVE = (1 << 6),
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
/** Subscribe for all presence notifications of a particular resource.*/
OC_REST_PRESENCE = (1 << 7),
- #endif
+#endif
/** Allows OCDoResource caller to do discovery.*/
OC_REST_DISCOVER = (1 << 8)
} OCMethod;
* processing its requests from clients.*/
OC_SLOW = (1 << 3),
+#ifdef __WITH_DTLS__
/** When this bit is set, the resource is a secure resource.*/
OC_SECURE = (1 << 4),
+#else
+ OC_SECURE = (0),
+#endif
/** When this bit is set, the resource is allowed to be discovered only
* if discovery request contains an explicit querystring.
* Ex: GET /oic/res?rt=oic.sec.acl */
OC_EXPLICIT_DISCOVERABLE = (1 << 5)
+
+#ifdef WITH_MQ
+ /** When this bit is set, the resource is allowed to be published */
+ ,OC_MQ_PUBLISHER = (1 << 6)
+#endif
+
+#ifdef MQ_BROKER
+ /** When this bit is set, the resource is allowed to be notified as MQ broker.*/
+ ,OC_MQ_BROKER = (1 << 7)
+#endif
} OCResourceProperty;
/**
OC_STACK_RESOURCE_CREATED,
OC_STACK_RESOURCE_DELETED,
OC_STACK_CONTINUE,
+ OC_STACK_RESOURCE_CHANGED,
/** Success status code - END HERE.*/
/** Error status code - START HERE.*/
/** Request is not authorized by Resource Server. */
OC_STACK_UNAUTHORIZED_REQ,
+ OC_STACK_TOO_LARGE_REQ,
/** Error code from PDM */
OC_STACK_PDM_IS_NOT_INITIALIZED,
OC_STACK_AUTHENTICATION_FAILURE,
/** Insert all new error codes here!.*/
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
OC_STACK_PRESENCE_STOPPED = 128,
OC_STACK_PRESENCE_TIMEOUT,
OC_STACK_PRESENCE_DO_NOT_HANDLE,
- #endif
+#endif
/** ERROR in stack.*/
OC_STACK_ERROR = 255
/** Error status code - END HERE.*/
OC_OBSERVE_DEREGISTER = 1,
/** Others. */
- OC_OBSERVE_NO_OPTION = 2
+ OC_OBSERVE_NO_OPTION = 2,
+
} OCObserveAction;
* Persistent storage handlers. An APP must provide OCPersistentStorage handler pointers
* when it calls OCRegisterPersistentStorageHandler.
* Persistent storage open handler points to default file path.
+ * It should check file path and whether the file is symbolic link or no.
* Application can point to appropriate SVR database path for it's IoTivity Server.
*/
typedef struct {
{
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
+ OC_EH_RESOURCE_CREATED, // 2.01
+ OC_EH_RESOURCE_DELETED, // 2.02
+ OC_EH_SLOW, // 2.05
+ OC_EH_FORBIDDEN, // 4.03
+ OC_EH_RESOURCE_NOT_FOUND, // 4.04
+ OC_EH_VALID, // 2.03
+ OC_EH_CHANGED, // 2.04
+ OC_EH_CONTENT, // 2.05
+ OC_EH_BAD_REQ, // 4.00
+ OC_EH_UNAUTHORIZED_REQ, // 4.01
+ OC_EH_BAD_OPT, // 4.02
+ OC_EH_METHOD_NOT_ALLOWED, // 4.05
+ OC_EH_NOT_ACCEPTABLE, // 4.06
+ OC_EH_INTERNAL_SERVER_ERROR, // 5.00
+ OC_EH_RETRANSMIT_TIMEOUT // 5.04
} OCEntityHandlerResult;
/**
char *deviceName;
/** Pointer to the types.*/
OCStringLL *types;
+ /** Pointer to the device specification version.*/
+ char *specVersion;
+ /** Pointer to the device data model versions (in CSV format).*/
+ OCStringLL *dataModelVersions;
} OCDeviceInfo;
#ifdef RA_ADAPTER
/** Enum to describe the type of object held by the OCPayload object.*/
typedef enum
{
+ /** Contents of the payload are invalid */
PAYLOAD_TYPE_INVALID,
+ /** The payload is an OCDiscoveryPayload */
PAYLOAD_TYPE_DISCOVERY,
+ /** The payload is an OCDevicePayload */
PAYLOAD_TYPE_DEVICE,
+ /** The payload is an OCPlatformPayload */
PAYLOAD_TYPE_PLATFORM,
+ /** The payload is an OCRepPayload */
PAYLOAD_TYPE_REPRESENTATION,
+ /** The payload is an OCSecurityPayload */
PAYLOAD_TYPE_SECURITY,
+ /** The payload is an OCPresencePayload */
PAYLOAD_TYPE_PRESENCE,
+ /** The payload is an OCRDPayload */
PAYLOAD_TYPE_RD
} OCPayloadType;
+/**
+ * A generic struct representing a payload returned from a resource operation
+ *
+ * A pointer to OCPayLoad can be cast to a more specific struct to access members
+ * for the its type.
+ */
typedef struct
{
- // The type of message that was received
+ /** The type of message that was received */
OCPayloadType type;
} OCPayload;
uint8_t bitmap;
bool secure;
uint16_t port;
+#ifdef TCP_ADAPTER
+ uint16_t tcpPort;
+#endif
struct OCResourcePayload* next;
} OCResourcePayload;
{
/** This is the target relative URI. */
char *href;
+ /** The relation of the target URI referenced by the link to the context URI;
+ * The default value is null. */
+ char *rel;
/** Resource Type - A standard OIC specified or vendor defined resource
* type of the resource referenced by the target URI. */
OCStringLL *rt;
/** Interface - The interfaces supported by the resource referenced by the target URI. */
OCStringLL *itf;
- /** The relation of the target URI referenced by the link to the context URI;
- * The default value is null. */
- char *rel;
- /** Specifies if the resource referenced by the target URIis observable or not. */
- bool obs;
+ /** Bitmap - The bitmap holds observable, discoverable, secure option flag. */
+ uint8_t p;
/** A title for the link relation. Can be used by the UI to provide a context. */
char *title;
/** This is used to override the context URI e.g. override the URI of the containing collection. */
- char *uri;
+ char *anchor;
/** The instance identifier for this web link in an array of web links - used in links. */
union
{
/** Use UUID for universal uniqueness - used in /oic/res to identify the device. */
OCIdentity uniqueUUID;
};
+ /** Time to keep holding resource.*/
+ uint64_t ttl;
/** A hint of the media type of the representation of the resource referenced by the target URI. */
- OCStringLL *mt;
+ OCStringLL *type;
/** Holding address of the next resource. */
struct OCLinksPayload *next;
} OCLinksPayload;
OCDeviceInfo n;
/** Device identifier. */
OCIdentity di;
- /** The base URI where the resources are hold. */
- char *baseURI;
- /** Bitmap holds observable, discoverable, secure option flag.*/
- uint8_t bitmap;
- /** Port set in case, the secure flag is set above. */
- uint16_t port;
- /** Id for each set of links i.e. tag. */
- union
- {
- /** An ordinal number that is not repeated - must be unique in the collection context. */
- uint8_t ins;
- /** Any unique string including a URI. */
- char *uniqueStr;
- /** Use UUID for universal uniqueness - used in /oic/res to identify the device. */
- OCIdentity uniqueUUID;
- };
- /** Defines the list of allowable resource types (for Target and anchors) in links included
- * in the collection; new links being created can only be from this list. */
- char *rts;
- /** When specified this is the default relationship to use when an OIC Link does not specify
- * an explicit relationship with *rel* parameter. */
- char *drel;
/** Time to keep holding resource.*/
- uint32_t ttl;
+ uint64_t ttl;
} OCTagsPayload;
/** Resource collection payload. */
OCTagsPayload *tags;
/** Array of links payload. */
OCLinksPayload *setLinks;
- /** Holding address of the next resource. */
- struct OCResourceCollectionPayload *next;
} OCResourceCollectionPayload;
-typedef struct
+typedef struct OCDiscoveryPayload
{
OCPayload base;
+ /** Device Id */
char *sid;
/** A special case for handling RD address. */
char* baseURI;
+ /** Name */
+ char *name;
+
+ /** HREF */
+ char *uri;
+
+ /** Resource Type */
+ OCStringLL *type;
+
+ /** Interface */
+ OCStringLL *iface;
+
/** This structure holds the old /oic/res response. */
OCResourcePayload *resources;
+ /** Holding address of the next DiscoveryPayload. */
+ struct OCDiscoveryPayload *next;
+
} OCDiscoveryPayload;
/**
{
OCPayload base;
char *sid;
- OCStringLL *types;
char* deviceName;
char* specVersion;
- char* dataModelVersion;
+ OCStringLL *dataModelVersions;
+ OCStringLL *interfaces;
+ OCStringLL *types;
} OCDevicePayload;
typedef struct
OCPayload base;
char* uri;
OCPlatformInfo info;
- char* rt;
+ OCStringLL* rt;
OCStringLL* interfaces;
} OCPlatformPayload;
typedef struct
{
OCPayload base;
- char* securityData;
- uint8_t *securityData1;
+ uint8_t* securityData;
size_t payloadSize;
} OCSecurityPayload;
/** Pointer to the array of the received vendor specific header options.*/
OCHeaderOption * rcvdVendorSpecificHeaderOptions;
+ /** Message id.*/
+ uint16_t messageID;
+
/** the payload from the request PDU.*/
OCPayload *payload;
} OCEntityHandlerFlag;
/**
- * Possible returned values from client application.
+ * Possible return values from client application callback
+ *
+ * A client application callback returns an OCStackApplicationResult to indicate whether
+ * the stack should continue to keep the callback registered.
*/
typedef enum
{
+ /** Make no more calls to the callback and call the OCClientContextDeleter for this callback */
OC_STACK_DELETE_TRANSACTION = 0,
+ /** Keep this callback registered and call it if an apropriate event occurs */
OC_STACK_KEEP_TRANSACTION
} OCStackApplicationResult;
/**
* Application server implementations must implement this callback to consume requests OTA.
* Entity handler callback needs to fill the resPayload of the entityHandlerRequest.
+ *
+ * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
+ * OC_EH_SLOW and etc in entity handler callback,
+ * ocstack will be not send response automatically to client
+ * except for error return value like OC_EH_ERROR.
+ *
+ * If you want to send response to client with specific result,
+ * OCDoResponse API should be called with the result value.
+ *
+ * e.g)
+ *
+ * OCEntityHandlerResponse response;
+ *
+ * ..
+ *
+ * response.ehResult = OC_EH_CHANGED;
+ *
+ * ..
+ *
+ * OCDoResponse(&response)
+ *
+ * ..
+ *
+ * return OC_EH_OK;
*/
typedef OCEntityHandlerResult (*OCEntityHandler)
(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void* callbackParam);
/**
* Device Entity handler need to use this call back instead of OCEntityHandler.
+ *
+ * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
+ * OC_EH_SLOW and etc in entity handler callback,
+ * ocstack will be not send response automatically to client
+ * except for error return value like OC_EH_ERROR.
+ *
+ * If you want to send response to client with specific result,
+ * OCDoResponse API should be called with the result value.
+ *
+ * e.g)
+ *
+ * OCEntityHandlerResponse response;
+ *
+ * ..
+ *
+ * response.ehResult = OC_EH_CHANGED;
+ *
+ * ..
+ *
+ * OCDoResponse(&response)
+ *
+ * ..
+ *
+ * return OC_EH_OK;
*/
typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri, void* callbackParam);
/**
* 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)(OCDPDev_t *peer, OCStackResult result);
+typedef void (*OCDirectPairingCB)(void *ctx, OCDPDev_t *peer, OCStackResult result);
//#endif // DIRECT_PAIRING
#ifdef __cplusplus