X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Finclude%2Foctypes.h;h=f1ed8b1a884b17125ed8eb94ac5f3205ba60a53e;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=e83bb827b0bf0319083ef91a80b2ee6825b8c110;hpb=9c42f3fe634ac3ee088e9a7592a35f319549f745;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/include/octypes.h b/resource/csdk/stack/include/octypes.h index e83bb82..f1ed8b1 100644 --- a/resource/csdk/stack/include/octypes.h +++ b/resource/csdk/stack/include/octypes.h @@ -28,7 +28,7 @@ #ifndef OCTYPES_H_ #define OCTYPES_H_ -#include "platform_features.h" +#include "iotivity_config.h" #include "ocstackconfig.h" #include #include @@ -43,10 +43,18 @@ extern "C" { #define WITH_PRESENCE #include "ocpresence.h" + +// TODO : need for secure psi +#if defined(__WITH_DTLS__) || defined(__WITH_TLS__) +#define __SECURE_PSI__ +#endif + //----------------------------------------------------------------------------- // Defines //----------------------------------------------------------------------------- +#define IOTIVITY_VERSION "1.2.1" + /** * OIC Virtual resources supported by every OIC device. */ @@ -64,24 +72,34 @@ extern "C" { /** 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 + +/** MQ Broker URI.*/ +#define OC_RSRVD_WELL_KNOWN_MQ_URI "/oic/ps" + +/** KeepAlive URI.*/ +#define OC_RSRVD_KEEPALIVE_URI "/oic/ping" + #ifdef WITH_PRESENCE +/** Presence */ /** Presence URI through which the OIC devices advertise their presence.*/ #define OC_RSRVD_PRESENCE_URI "/oic/ad" -/** Sets the default time to live (TTL) for presence.*/ -#define OC_DEFAULT_PRESENCE_TTL_SECONDS (60) +/** Presence URI through which the OIC devices advertise their device presence.*/ +#define OC_RSRVD_DEVICE_PRESENCE_URI "/oic/prs" + +#endif // WITH_PRESENCE /** 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 "&;" +#ifdef WITH_PRESENCE /** * OC_DEFAULT_PRESENCE_TTL_SECONDS sets the default time to live (TTL) for presence. */ @@ -94,7 +112,7 @@ extern "C" { * 60 sec/min * 60 min/hr * 24 hr/day */ #define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24) -#endif + /** * Presence "Announcement Triggers". @@ -109,12 +127,15 @@ extern "C" { /** To delete.*/ #define OC_RSRVD_TRIGGER_DELETE "delete" +#endif // WITH_PRESENCE + /** * Attributes used to form a proper OIC conforming JSON message. */ #define OC_RSRVD_OC "oic" + /** For payload. */ #define OC_RSRVD_PAYLOAD "payload" @@ -134,8 +155,10 @@ extern "C" { /** To represent resource type.*/ #define OC_RSRVD_RESOURCE_TYPE "rt" +#ifdef WITH_PRESENCE /** To represent resource type with presence.*/ #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad" +#endif /** To represent resource type with device.*/ #define OC_RSRVD_RESOURCE_TYPE_DEVICE "oic.wk.d" @@ -143,12 +166,25 @@ extern "C" { /** To represent resource type with platform.*/ #define OC_RSRVD_RESOURCE_TYPE_PLATFORM "oic.wk.p" +/** To represent resource type with collection.*/ +#define OC_RSRVD_RESOURCE_TYPE_COLLECTION "oic.wk.col" + /** To represent resource type with RES.*/ -#define OC_RSRVD_RESOURCE_TYPE_RES "oic.wk.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" @@ -198,7 +234,10 @@ extern "C" { #define OC_RSRVD_HOSTING_PORT "port" /** TCP Port. */ -#define OC_RSRVD_TCP_PORT "tcp" +#define OC_RSRVD_TCP_PORT "x.org.iotivity.tcp" + +/** TLS Port. */ +#define OC_RSRVD_TLS_PORT "x.org.iotivity.tls" /** For Server instance ID.*/ #define OC_RSRVD_SERVER_INSTANCE_ID "sid" @@ -238,8 +277,10 @@ extern "C" { #define OC_RSRVD_SUPPORT_URL "mnsl" /** System time for the platform. */ -#define OC_RSRVD_SYSTEM_TIME "st" +#define OC_RSRVD_SYSTEM_TIME "st" +/** VID for the platform. */ +#define OC_RSRVD_VID "vid" /** * Device. */ @@ -257,32 +298,34 @@ extern "C" { #define OC_RSRVD_DATA_MODEL_VERSION "dmv" /** Device specification version.*/ -#define OC_SPEC_VERSION "core.1.0.0" +#define OC_SPEC_VERSION "core.1.1.0" /** Device Data Model version.*/ -#define OC_DATA_MODEL_VERSION "res.1.0.0" - +#define OC_DATA_MODEL_VERSION "res.1.1.0,sh.1.1.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 */ @@ -292,7 +335,7 @@ extern "C" { #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) @@ -308,6 +351,12 @@ extern "C" { /** RD Discovery bias factor type. */ #define OC_RSRVD_RD_DISCOVERY_SEL "sel" +/** Resource URI used to discover Proxy */ +#define OC_RSRVD_PROXY_URI "/oic/chp" + +/** Resource URI used to discover Proxy */ +#define OC_RSRVD_PROXY_OPTION_ID 35 + /** Base URI. */ #define OC_RSRVD_BASE_URI "baseURI" @@ -327,14 +376,200 @@ extern "C" { #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" +/** Cloud Account */ + +/** Account URI.*/ +#define OC_RSRVD_ACCOUNT_URI "/oic/account" + +/** Account user URI.*/ +#define OC_RSRVD_ACCOUNT_SEARCH_URI "/oic/account/search" + +/** 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 group ID. */ +#define OC_RSRVD_GROUP_ID "gid" + +/** Defines member of group ID. */ +#define OC_RSRVD_MEMBER_ID "mid" + +/** Defines invite. */ +#define OC_RSRVD_INVITE "invite" + +/** Defines accept. */ +#define OC_RSRVD_ACCEPT "accept" + +/** Defines operation. */ +#define OC_RSRVD_OPERATION "op" + +/** Defines add. */ +#define OC_RSRVD_ADD "add" + +/** Defines delete. */ +#define OC_RSRVD_DELETE "delete" + +/** Defines owner. */ +#define OC_RSRVD_OWNER "owner" + +/** Defines members. */ +#define OC_RSRVD_MEMBERS "members" + +/** To represent grant type with refresh token. */ +#define OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN "refresh_token" + +/** Cloud CRL */ +#define OC_RSRVD_PROV_CRL_URL "/oic/credprov/crl" + +#define OC_RSRVD_LAST_UPDATE "lu" + +#define OC_RSRVD_THIS_UPDATE "tu" + +#define OC_RSRVD_NEXT_UPDATE "nu" + +#define OC_RSRVD_SERIAL_NUMBERS "rcsn" + +#define OC_RSRVD_CRL "crl" + +#define OC_RSRVD_CRL_ID "crlid" + +/** Cloud ACL */ +#define OC_RSRVD_GROUP_URL "/oic/group" + +#define OC_RSRVD_ACL_GROUP_URL "/oic/acl/group" + +#define OC_RSRVD_ACL_INVITE_URL "/oic/acl/invite" + +#define OC_RSRVD_ACL_VERIFY_URL "/oic/acl/verify" + +#define OC_RSRVD_ACL_ID_URL "/oic/acl/id" + +#define OC_RSRVD_MEMBER_ID "mid" + +#define OC_RSRVD_GROUP_ID "gid" + +#define OC_RSRVD_OWNER_ID "oid" + +#define OC_RSRVD_ACL_ID "aclid" + +#define OC_RSRVD_ACE_ID "aceid" + +#define OC_RSRVD_DEVICE_ID "di" + +#define OC_RSRVD_SUBJECT_ID "sid" + +#define OC_RSRVD_REQUEST_METHOD "rm" + +#define OC_RSRVD_REQUEST_URI "uri" + +#define OC_RSRVD_GROUP_MASTER_ID "gmid" + +#define OC_RSRVD_GROUP_TYPE "gtype" + +#define OC_RSRVD_SUBJECT_TYPE "stype" + +#define OC_RSRVD_GROUP_ID_LIST "gidlist" + +#define OC_RSRVD_MEMBER_ID_LIST "midlist" + +#define OC_RSRVD_DEVICE_ID_LIST "dilist" + +#define OC_RSRVD_ACCESS_CONTROL_LIST "aclist" + +#define OC_RSRVD_RESOURCES "resources" + +#define OC_RSRVD_VALIDITY "validity" + +#define OC_RSRVD_PERIOD "period" + +#define OC_RSRVD_RECURRENCE "recurrence" + +#define OC_RSRVD_INVITE "invite" + +#define OC_RSRVD_INVITED "invited" + +#define OC_RSRVD_ENCODING "encoding" + +#define OC_OIC_SEC "oic.sec" + +#define OC_RSRVD_BASE64 "base64" + +#define OC_RSRVD_DER "der" + +#define OC_RSRVD_PEM "pem" + +#define OC_RSRVD_RAW "raw" + +#define OC_RSRVD_UNKNOWN "unknown" + +#define OC_RSRVD_DATA "data" + +#define OC_RSRVD_RESOURCE_OWNER_UUID "rowneruuid" + +#define OC_RSRVD_SUBJECT_UUID "subjectuuid" + +#define OC_RSRVD_PERMISSION_MASK "permission" + +#define OC_RSRVD_GROUP_PERMISSION "gp" + +#define OC_RSRVD_GROUP_ACL "gacl" + +/** Certificete Sign Request */ +#define OC_RSRVD_PROV_CERT_URI "/oic/credprov/cert" + +#define OC_RSRVD_CSR "csr" + +#define OC_RSRVD_CERT "cert" + +#define OC_RSRVD_CACERT "certchain" + +#define OC_RSRVD_TOKEN_TYPE "tokentype" + +#define OC_RSRVD_EXPIRES_IN "expiresin" + +#define OC_RSRVD_REDIRECT_URI "redirecturi" + +#define OC_RSRVD_CERTIFICATE "certificate" /** * Mark a parameter as unused. Used to prevent unused variable compiler warnings. * Used in three cases: @@ -376,6 +611,29 @@ typedef enum OC_ADAPTER_NFC = (1 << 5) } OCTransportAdapter; +typedef enum +{ + OC_DEFAULT_BT_FLAGS = 0, + // flags for BLE transport + OC_LE_ADV_DISABLE = 0x1, // disable BLE advertisement. + OC_LE_ADV_ENABLE = 0x2, // enable BLE advertisement. + OC_LE_SERVER_DISABLE = (1 << 4), // disable gatt server. + // flags for EDR transport + OC_EDR_SERVER_DISABLE = (1 << 7) // disable rfcomm server. +} OCTransportBTFlags_t; + +/** + * Log level to print can be controlled through this enum. + * And privacy logs contained uid, Token, Device id, etc can also disable. + * This enum (OCLogLevel) must be kept synchronized with + * CAUtilLogLevel_t (in CACommon.h). + */ +typedef enum +{ + OC_LOG_LEVEL_ALL = 1, // all logs. + OC_LOG_LEVEL_INFO, // debug level is disabled. +} OCLogLevel; + /** * Enum layout assumes some targets have 16-bit integer (e.g., Arduino). */ @@ -395,8 +653,8 @@ typedef enum /** 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.*/ @@ -478,9 +736,12 @@ typedef struct /** usually zero for default interface.*/ uint32_t ifindex; -#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP) - char routeData[MAX_ADDR_STR_SIZE]; //destination GatewayID:ClientId -#endif + + /** destination GatewayID:ClientId.*/ + char routeData[MAX_ADDR_STR_SIZE]; + + /** device ID of remote.*/ + char remoteId[MAX_IDENTITY_SIZE]; } OCDevAddr; /** @@ -587,9 +848,6 @@ typedef enum /** Register observe request for all notifications, including stale notifications.*/ OC_REST_OBSERVE_ALL = (1 << 5), - /** De-register 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), @@ -605,6 +863,7 @@ typedef enum typedef enum { OC_FORMAT_CBOR, + OC_FORMAT_JSON, OC_FORMAT_UNDEFINED, OC_FORMAT_UNSUPPORTED, } OCPayloadFormat; @@ -670,13 +929,27 @@ typedef enum * processing its requests from clients.*/ OC_SLOW = (1 << 3), +#if defined(__WITH_DTLS__) || defined(__WITH_TLS__) /** 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; /** @@ -701,6 +974,7 @@ typedef enum 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.*/ @@ -743,17 +1017,20 @@ typedef enum /** 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_DUPLICATE_UUID, OC_STACK_INCONSISTENT_DB, + OC_STACK_SVR_DB_NOT_EXIST, /** * Error code from OTM * This error is pushed from DTLS interface when handshake failure happens */ OC_STACK_AUTHENTICATION_FAILURE, + OC_STACK_NOT_ALLOWED_OXM, /** Insert all new error codes here!.*/ #ifdef WITH_PRESENCE @@ -761,6 +1038,21 @@ typedef enum OC_STACK_PRESENCE_TIMEOUT, OC_STACK_PRESENCE_DO_NOT_HANDLE, #endif + + /** Request is denied by the user*/ + OC_STACK_USER_DENIED_REQ, + OC_STACK_NOT_ACCEPTABLE, + OC_STACK_METHOD_NOT_ALLOWED, + + /** ERROR code from server */ + OC_STACK_FORBIDDEN_REQ, /** 403*/ + OC_STACK_INTERNAL_SERVER_ERROR, /** 500*/ + OC_STACK_NOT_IMPLEMENTED, /** 501*/ + OC_STACK_BAD_GATEWAY, /** 502*/ + OC_STACK_SERVICE_UNAVAILABLE, /** 503*/ + OC_STACK_GATEWAY_TIMEOUT, /** 504*/ + OC_STACK_PROXY_NOT_SUPPORTED, /** 505*/ + /** ERROR in stack.*/ OC_STACK_ERROR = 255 /** Error status code - END HERE.*/ @@ -779,7 +1071,7 @@ typedef void * OCResourceHandle; /** * Handle to an OCRequest object owned by the OCStack. */ -typedef void * OCRequestHandle; +typedef uint32_t OCRequestHandle; /** * Unique identifier for each observation request. Used when observations are @@ -790,6 +1082,12 @@ typedef void * OCRequestHandle; typedef uint8_t OCObservationId; /** + * Sequence number is a 24 bit field, + * per https://tools.ietf.org/html/rfc7641. + */ +#define MAX_SEQUENCE_NUMBER (0xFFFFFF) + +/** * Action associated with observation. */ typedef enum @@ -801,7 +1099,8 @@ typedef enum OC_OBSERVE_DEREGISTER = 1, /** Others. */ - OC_OBSERVE_NO_OPTION = 2 + OC_OBSERVE_NO_OPTION = 2, + } OCObserveAction; @@ -827,6 +1126,14 @@ typedef struct { /** Persistent storage unlink handler.*/ int (* unlink)(const char *path); + + /** Persistent Storage Handler for Encryption.*/ + int (* encrypt)(const unsigned char *pt, size_t size, + unsigned char**ct, size_t *ct_len); + + /**Persistent Storage Handler for Decryption.*/ + int (* decrypt)(const unsigned char *ct, size_t size, + unsigned char**pt, size_t *pt_len); } OCPersistentStorage; /** @@ -848,11 +1155,27 @@ 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 + OC_EH_RESOURCE_CREATED = 201, + OC_EH_RESOURCE_DELETED = 202, + OC_EH_VALID = 203, + OC_EH_CHANGED = 204, + OC_EH_CONTENT = 205, + OC_EH_BAD_REQ = 400, + OC_EH_UNAUTHORIZED_REQ = 401, + OC_EH_BAD_OPT = 402, + OC_EH_FORBIDDEN = 403, + OC_EH_RESOURCE_NOT_FOUND = 404, + OC_EH_METHOD_NOT_ALLOWED = 405, + OC_EH_NOT_ACCEPTABLE = 406, + OC_EH_TOO_LARGE = 413, + OC_EH_UNSUPPORTED_MEDIA_TYPE = 415, + OC_EH_INTERNAL_SERVER_ERROR = 500, + OC_EH_NOT_IMPLEMENTED = 501, + OC_EH_BAD_GATEWAY = 502, + OC_EH_SERVICE_UNAVAILABLE = 503, + OC_EH_RETRANSMIT_TIMEOUT = 504, + OC_EH_PROXY_NOT_SUPPORTED = 505 } OCEntityHandlerResult; /** @@ -893,10 +1216,10 @@ typedef struct OCHeaderOption #endif } OCHeaderOption; - /** * This structure describes the platform properties. All non-Null properties will be * included in a platform discovery request. + * @deprecated: Use OCSetPropertyValue to set platform value. */ typedef struct { @@ -939,6 +1262,7 @@ typedef struct * This structure is expected as input for device properties. * device name is mandatory and expected from the application. * device id of type UUID will be generated by the stack. + * @deprecated: Use OCSetPropertyValue to set device value. */ typedef struct { @@ -946,6 +1270,10 @@ typedef struct 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 @@ -979,18 +1307,18 @@ typedef enum PAYLOAD_TYPE_INVALID, /** The payload is an OCDiscoveryPayload */ PAYLOAD_TYPE_DISCOVERY, - /** The payload is an OCDevicePayload */ + /** The payload of the device */ PAYLOAD_TYPE_DEVICE, - /** The payload is an OCPlatformPayload */ + /** The payload type of the platform */ PAYLOAD_TYPE_PLATFORM, /** The payload is an OCRepPayload */ PAYLOAD_TYPE_REPRESENTATION, /** The payload is an OCSecurityPayload */ PAYLOAD_TYPE_SECURITY, +#ifdef WITH_PRESENCE /** The payload is an OCPresencePayload */ - PAYLOAD_TYPE_PRESENCE, - /** The payload is an OCRDPayload */ - PAYLOAD_TYPE_RD + PAYLOAD_TYPE_PRESENCE +#endif } OCPayloadType; /** @@ -1094,89 +1422,7 @@ typedef struct OCResourcePayload struct OCResourcePayload* next; } OCResourcePayload; -/** - * Structure holding Links Payload. It is a sub-structure used in - * OCResourceCollectionPayload. - */ -typedef struct OCLinksPayload -{ - /** This is the target relative URI. */ - char *href; - /** 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; - /** 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; - /** The instance identifier for this web link in an array of web links - used in links. */ - 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; - }; - /** A hint of the media type of the representation of the resource referenced by the target URI. */ - OCStringLL *mt; - /** Holding address of the next resource. */ - struct OCLinksPayload *next; -} OCLinksPayload; - -/** Structure holding tags value of the links payload. */ -typedef struct -{ - /** Name of tags. */ - 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; -} OCTagsPayload; - -/** Resource collection payload. */ -typedef struct OCResourceCollectionPayload -{ - /** Collection tags 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; @@ -1189,11 +1435,8 @@ typedef struct /** Name */ char *name; - /** HREF */ - char *uri; - /** Resource Type */ - char *type; + OCStringLL *type; /** Interface */ OCStringLL *iface; @@ -1201,52 +1444,10 @@ typedef struct /** This structure holds the old /oic/res response. */ OCResourcePayload *resources; -} OCDiscoveryPayload; + /** Holding address of the next DiscoveryPayload. */ + struct OCDiscoveryPayload *next; -/** - * Structure holding discovery payload. - */ -typedef struct -{ - /** Device Name. */ - OCDeviceInfo n; - /** Device Identity. */ - OCIdentity di; - /** Value holding the bias factor of the RD. */ - uint8_t sel; -} OCRDDiscoveryPayload; - -/** - * RD Payload that will be transmitted over the wire. - */ -typedef struct -{ - OCPayload base; - /** Pointer to the discovery response payload.*/ - OCRDDiscoveryPayload *rdDiscovery; - /** Pointer to the publish payload.*/ - OCResourceCollectionPayload *rdPublish; -} OCRDPayload; - -typedef struct -{ - OCPayload base; - char *sid; - char* deviceName; - char* specVersion; - char* dataModelVersion; - OCStringLL *interfaces; - OCStringLL *types; -} OCDevicePayload; - -typedef struct -{ - OCPayload base; - char* uri; - OCPlatformInfo info; - char* rt; - OCStringLL* interfaces; -} OCPlatformPayload; +} OCDiscoveryPayload; typedef struct { @@ -1299,6 +1500,9 @@ typedef struct /** 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; @@ -1471,12 +1675,60 @@ typedef struct OCCallbackData /** * 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); @@ -1485,12 +1737,57 @@ typedef OCEntityHandlerResult (*OCDeviceEntityHandler) /** * 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' + * @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 +#if defined(__WITH_DTLS__) || defined(__WITH_TLS__) +/** + * Callback function definition for Change in TrustCertChain + * + * @param[IN] ctx - user context returned in the callback. + * @param[IN] credId - trustCertChain changed for this ID + * @param[IN] trustCertChain - trustcertchain binary blob. + * @param[IN] chainSize - size of trustchain + */ +typedef void (*TrustCertChainChangeCB)(void *ctx, uint16_t credId, uint8_t *trustCertChain, + size_t chainSize); + +/** + * certChain context structure. + */ +typedef struct trustCertChainContext +{ + TrustCertChainChangeCB callback; + void *context; +} trustCertChainContext_t; +#endif + +/** + * OTM State + */ +typedef enum +{ + OC_OTM_READY = 0, + OC_OTM_STARTED = 1, + OC_OTM_DONE = 2, + OC_OTM_ERROR = 3 +} OCOtmEvent_t; + +/** + * Callback function to receive the OTM event on server side. + * + * @param[in] ctx user context returned in the callback + * @param[in] addr PT's address (address can be NULL in case of init state) + * @param[in] port PT's port (It is meaningless in case of init state & BLE) + * @param[in] uuid PT's UUID (UUID can be NULL in case of init state & coap reqest) + * @param[in] event OTM state (@ref OCOtmEvent_t) + */ +typedef void (*OCOtmEventHandler)(void *ctx, const char *addr, uint16_t port, + const char *ownerId, OCOtmEvent_t event); #ifdef __cplusplus }