1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //******************************************************************
25 * This file contains the definitions, types and APIs for resources to be implemented.
31 #include "ocstackconfig.h"
41 /** For the feature presence.*/
44 #include "ocpresence.h"
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 /** Version of IoTivity. */
51 #define IOTIVITY_VERSION "2.0.0"
54 * OIC Virtual resources supported by every OIC device.
57 * Default discovery mechanism using '/oic/res' is supported by all OIC devices
58 * That are Discoverable.
60 #define OC_RSRVD_WELL_KNOWN_URI "/oic/res"
63 #define OC_RSRVD_DEVICE_URI "/oic/d"
66 #define OC_RSRVD_PLATFORM_URI "/oic/p"
69 #define OC_RSRVD_RESOURCE_TYPES_URI "/oic/res/types/d"
72 #define OC_RSRVD_GATEWAY_URI "/oic/gateway"
75 #define OC_RSRVD_WELL_KNOWN_MQ_URI "/oic/ps"
78 #define OC_RSRVD_KEEPALIVE_URI "/oic/ping"
81 #define OC_RSRVD_CLOUDCONF_URI "/CoapCloudConfResURI"
85 /** Presence URI through which the OIC devices advertise their presence.*/
86 #define OC_RSRVD_PRESENCE_URI "/oic/ad"
88 /** Presence URI through which the OIC devices advertise their device presence.*/
89 #define OC_RSRVD_DEVICE_PRESENCE_URI "/oic/prs"
91 /** Sets the default time to live (TTL) for presence.*/
92 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
94 /** For multicast Discovery mechanism.*/
95 #define OC_MULTICAST_DISCOVERY_URI "/oic/res"
97 /** Separator for multiple query string.*/
98 #define OC_QUERY_SEPARATOR "&;"
100 /** Delimeter for keys and values in query string.*/
101 #define OC_KEY_VALUE_DELIMITER "="
104 * OC_DEFAULT_PRESENCE_TTL_SECONDS sets the default time to live (TTL) for presence.
106 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
109 * OC_MAX_PRESENCE_TTL_SECONDS sets the maximum time to live (TTL) for presence.
110 * NOTE: Changing the setting to a longer duration may lead to unsupported and untested
112 * 60 sec/min * 60 min/hr * 24 hr/day
114 #define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24)
118 * Presence "Announcement Triggers".
122 #define OC_RSRVD_TRIGGER_CREATE "create"
125 #define OC_RSRVD_TRIGGER_CHANGE "change"
128 #define OC_RSRVD_TRIGGER_DELETE "delete"
131 * Attributes used to form a proper OIC conforming JSON message.
134 #define OC_RSRVD_OC "oic"
139 #define OC_RSRVD_PAYLOAD "payload"
141 /** To represent href */
142 #define OC_RSRVD_HREF "href"
144 /** To represent property*/
145 #define OC_RSRVD_PROPERTY "prop"
147 /** For representation.*/
148 #define OC_RSRVD_REPRESENTATION "rep"
150 /** To represent content type.*/
151 #define OC_RSRVD_CONTENT_TYPE "ct"
153 /** To represent resource type.*/
154 #define OC_RSRVD_RESOURCE_TYPE "rt"
156 /** To represent resource type with presence.*/
157 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad"
159 /** To represent resource type with device.*/
160 #define OC_RSRVD_RESOURCE_TYPE_DEVICE "oic.wk.d"
162 /** To represent resource type with platform.*/
163 #define OC_RSRVD_RESOURCE_TYPE_PLATFORM "oic.wk.p"
165 /** To represent resource type with maintenance.*/
166 #define OC_RSRVD_RESOURCE_TYPE_MAINTENANCE "oic.wk.mnt"
168 /** To represent resource type with collection.*/
169 #define OC_RSRVD_RESOURCE_TYPE_COLLECTION "oic.wk.col"
171 /** To represent resource type with RES.*/
172 #define OC_RSRVD_RESOURCE_TYPE_RES "oic.wk.res"
174 /** To represent content type with MQ Broker.*/
175 #define OC_RSRVD_RESOURCE_TYPE_MQ_BROKER "oic.wk.ps"
177 /** To represent content type with MQ Topic.*/
178 #define OC_RSRVD_RESOURCE_TYPE_MQ_TOPIC "oic.wk.ps.topic"
180 /** To represent resource type with introspection.*/
181 #define OC_RSRVD_RESOURCE_TYPE_INTROSPECTION "oic.wk.introspection"
183 /** To represent resource type with introspection payload.*/
184 #define OC_RSRVD_RESOURCE_TYPE_INTROSPECTION_PAYLOAD "oic.wk.introspection.payload"
186 /** To represent interface.*/
187 #define OC_RSRVD_INTERFACE "if"
189 /** To represent time to live.*/
190 #define OC_RSRVD_TTL "ttl"
192 /** To indicate how long RD should publish this item.*/
193 #define OC_RSRVD_DEVICE_TTL OC_RSRVD_TTL
195 /** To represent non*/
196 #define OC_RSRVD_NONCE "non"
198 /** To represent trigger type.*/
199 #define OC_RSRVD_TRIGGER "trg"
201 /** To represent links.*/
202 #define OC_RSRVD_LINKS "links"
204 /** To represent default interface.*/
205 #define OC_RSRVD_INTERFACE_DEFAULT "oic.if.baseline"
207 /** To represent read-only interface.*/
208 #define OC_RSRVD_INTERFACE_READ "oic.if.r"
210 /** To represent read-write interface.*/
211 #define OC_RSRVD_INTERFACE_READ_WRITE "oic.if.rw"
213 /** To represent ll interface.*/
214 #define OC_RSRVD_INTERFACE_LL "oic.if.ll"
216 /** To represent batch interface.*/
217 #define OC_RSRVD_INTERFACE_BATCH "oic.if.b"
219 /** To represent actuator interface.*/
220 #define OC_RSRVD_INTERFACE_ACTUATOR "oic.if.a"
222 /** To represent sensor interface.*/
223 #define OC_RSRVD_INTERFACE_SENSOR "oic.if.s"
225 /** To represent interface group.*/
226 #define OC_RSRVD_INTERFACE_GROUP "oic.mi.grp"
228 /** To represent FW version.*/
229 #define OC_RSRVD_FW_VERSION "mnfv"
231 /** To represent host name.*/
232 #define OC_RSRVD_HOST_NAME "hn"
234 /** To represent policy.*/
235 #define OC_RSRVD_POLICY "p"
237 /** To represent bitmap.*/
238 #define OC_RSRVD_BITMAP "bm"
241 #define OC_RSRVD_SECURE "sec"
243 /** Security Database persistent store name(json).*/
244 #define OC_SECURITY_DB_FILE_NAME "oic_svr_db.json"
246 /** Security Database persistent store name(dat).*/
247 #define OC_SECURITY_DB_DAT_FILE_NAME "oic_svr_db.dat"
250 #define OC_RSRVD_HOSTING_PORT "port"
253 #define OC_RSRVD_TCP_PORT "x.org.iotivity.tcp"
256 #define OC_RSRVD_TLS_PORT "x.org.iotivity.tls"
258 /** For Server instance ID.*/
259 #define OC_RSRVD_SERVER_INSTANCE_ID "sid"
261 /** To represent endpoints.*/
262 #define OC_RSRVD_ENDPOINTS "eps"
264 /** To represent endpoint.*/
265 #define OC_RSRVD_ENDPOINT "ep"
267 /** To represent priority.*/
268 #define OC_RSRVD_PRIORITY "pri"
270 /** For resource instance ID.*/
271 #define OC_RSRVD_INSTANCE_ID "id"
278 #define OC_RSRVD_PLATFORM_ID "pi"
280 /** Platform MFG NAME. */
281 #define OC_RSRVD_MFG_NAME "mnmn"
284 #define OC_RSRVD_MFG_URL "mnml"
287 #define OC_RSRVD_MODEL_NUM "mnmo"
289 /** Platform MFG Date.*/
290 #define OC_RSRVD_MFG_DATE "mndt"
292 /** Platform versio.n */
293 #define OC_RSRVD_PLATFORM_VERSION "mnpv"
295 /** Platform Operating system version. */
296 #define OC_RSRVD_OS_VERSION "mnos"
298 /** Platform Hardware version. */
299 #define OC_RSRVD_HARDWARE_VERSION "mnhw"
301 /**Platform Firmware version. */
302 #define OC_RSRVD_FIRMWARE_VERSION "mnfv"
304 /** Support URL for the platform. */
305 #define OC_RSRVD_SUPPORT_URL "mnsl"
307 /** System time for the platform. */
308 #define OC_RSRVD_SYSTEM_TIME "st"
310 /** VID for the platform. */
311 #define OC_RSRVD_VID "vid"
318 #define OC_RSRVD_DEVICE_ID "di"
321 #define OC_RSRVD_DEVICE_NAME "n"
323 /** Device specification version.*/
324 #define OC_RSRVD_SPEC_VERSION "icv"
326 /** Device data model.*/
327 #define OC_RSRVD_DATA_MODEL_VERSION "dmv"
329 /** Device description, localized */
330 #define OC_RSRVD_DEVICE_DESCRIPTION "ld"
332 /** Device software version */
333 #define OC_RSRVD_SOFTWARE_VERSION "sv"
335 /** Device manufacturer name, localized */
336 #define OC_RSRVD_DEVICE_MFG_NAME "dmn"
338 /** Device model number */
339 #define OC_RSRVD_DEVICE_MODEL_NUM "dmno"
341 /** Protocol-Independent ID.*/
342 #define OC_RSRVD_PROTOCOL_INDEPENDENT_ID "piid"
344 /** Device specification version.*/
345 #define OC_SPEC_VERSION "ocf.1.1.0"
347 /** Integer value of spec version (OCF1.0 0b0000:1000:0000:0000).*/
348 #define OC_SPEC_VERSION_VALUE 2048
350 /** Device Data Model version.*/
351 #define OC_DATA_MODEL_VERSION "ocf.res.1.1.0,ocf.sh.1.1.0"
356 /** Name property name(n).*/
357 #define OC_RSRVD_INTROSPECTION_NAME "n"
360 #define OC_RSRVD_INTROSPECTION_NAME_VALUE "Introspection"
362 /** Url info Object.*/
363 #define OC_RSRVD_INTROSPECTION_URL_INFO "urlInfo"
366 #define OC_RSRVD_INTROSPECTION_URL "url"
368 /** Protocol property.*/
369 #define OC_RSRVD_INTROSPECTION_PROTOCOL "protocol"
371 /** Content-Type property.*/
372 #define OC_RSRVD_INTROSPECTION_CONTENT_TYPE "content-type"
374 /** Content-Type property value.*/
375 #define OC_RSRVD_INTROSPECTION_CONTENT_TYPE_VALUE "application/cbor"
377 /** Version property.*/
378 #define OC_RSRVD_INTROSPECTION_VERSION "version"
380 /** Version property value.*/
381 #define OC_RSRVD_INTROSPECTION_VERSION_VALUE 1
383 /** Introspection persistent store name.*/
384 #define OC_INTROSPECTION_FILE_NAME "introspection.dat"
387 * These provide backward compatibility - their use is deprecated.
391 /** Multicast Prefix.*/
392 #define OC_MULTICAST_PREFIX "224.0.1.187:5683"
394 /** Multicast IP address.*/
395 #define OC_MULTICAST_IP "224.0.1.187"
397 /** Multicast Port.*/
398 #define OC_MULTICAST_PORT (5683)
401 /** Max Device address size. */
403 #define MAX_ADDR_STR_SIZE (256)
405 /** Max Address could be
406 * "coaps+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx"
407 * +1 for null terminator.
409 #define MAX_ADDR_STR_SIZE (66)
412 /** Length of MAC address */
413 #define MAC_ADDR_STR_SIZE (17)
415 /** Blocks of MAC address */
416 #define MAC_ADDR_BLOCKS (6)
418 /** Max identity size. */
419 #define MAX_IDENTITY_SIZE (37)
421 /** Universal unique identity size. */
422 #define UUID_IDENTITY_SIZE (128/8)
424 /** Resource Directory */
426 /** Resource Directory URI used to Discover RD and Publish resources.*/
427 #define OC_RSRVD_RD_URI "/oic/rd"
429 /** To represent resource type with rd.*/
430 #define OC_RSRVD_RESOURCE_TYPE_RD "oic.wk.rd"
432 /** RD Discovery bias factor type. */
433 #define OC_RSRVD_RD_DISCOVERY_SEL "sel"
435 /** Resource URI used to discover Proxy */
436 #define OC_RSRVD_PROXY_URI "/oic/chp"
438 /** Resource URI used to discover Proxy */
439 #define OC_RSRVD_PROXY_OPTION_ID 35
441 /** Unique value per collection/link. */
442 #define OC_RSRVD_INS "ins"
444 /** Allowable resource types in the links. */
445 #define OC_RSRVD_RTS "rts"
447 /** Default relationship. */
448 #define OC_RSRVD_DREL "drel"
450 /** Defines relationship between links. */
451 #define OC_RSRVD_REL "rel"
453 /** Defines title. */
454 #define OC_RSRVD_TITLE "title"
457 #define OC_RSRVD_URI "anchor"
459 /** Defines media type. */
460 #define OC_RSRVD_MEDIA_TYPE "type"
462 /** To represent resource type with Publish RD.*/
463 #define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdpub"
468 #define OC_RSRVD_ACCOUNT_URI "/oic/sec/account"
470 /** Account user URI.*/
471 #define OC_RSRVD_ACCOUNT_SEARCH_URI "/oic/account/search"
473 /** Account session URI.*/
474 #define OC_RSRVD_ACCOUNT_SESSION_URI "/oic/sec/session"
476 /** Account token refresh URI.*/
477 #define OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI "/oic/sec/tokenrefresh"
480 #define OC_RSRVD_ACL_GROUP_URI "/oic/acl/group"
482 /** ACL invite URI.*/
483 #define OC_RSRVD_ACL_INVITE_URI "/oic/acl/invite"
485 /** Defines auth provider. */
486 #define OC_RSRVD_AUTHPROVIDER "authprovider"
488 /** Defines auth code. */
489 #define OC_RSRVD_AUTHCODE "authcode"
491 /** Defines access token. */
492 #define OC_RSRVD_ACCESS_TOKEN "accesstoken"
494 /** Defines login. */
495 #define OC_RSRVD_LOGIN "login"
497 /** Defines search. */
498 #define OC_RSRVD_SEARCH "search"
500 /** Defines grant type. */
501 #define OC_RSRVD_GRANT_TYPE "granttype"
503 /** Defines refresh token. */
504 #define OC_RSRVD_REFRESH_TOKEN "refreshtoken"
506 /** Defines user UUID. */
507 #define OC_RSRVD_USER_UUID "uid"
509 /** Defines group ID. */
510 #define OC_RSRVD_GROUP_ID "gid"
512 /** Defines member of group ID. */
513 #define OC_RSRVD_MEMBER_ID "mid"
515 /** Defines invite. */
516 #define OC_RSRVD_INVITE "invite"
518 /** Defines accept. */
519 #define OC_RSRVD_ACCEPT "accept"
521 /** Defines operation. */
522 #define OC_RSRVD_OPERATION "op"
525 #define OC_RSRVD_ADD "add"
527 /** Defines delete. */
528 #define OC_RSRVD_DELETE "delete"
530 /** Defines owner. */
531 #define OC_RSRVD_OWNER "owner"
533 /** Defines members. */
534 #define OC_RSRVD_MEMBERS "members"
536 /** To represent grant type with refresh token. */
537 #define OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN "refresh_token"
540 #define OC_RSRVD_PROV_CRL_URL "/oic/credprov/crl"
542 #define OC_RSRVD_LAST_UPDATE "lu"
544 #define OC_RSRVD_THIS_UPDATE "thisupdate"
546 #define OC_RSRVD_NEXT_UPDATE "nu"
548 #define OC_RSRVD_SERIAL_NUMBERS "rcsn"
550 #define OC_RSRVD_CRL "crldata"
552 #define OC_RSRVD_CRL_ID "crlid"
555 #define OC_RSRVD_GROUP_URL "/oic/group"
557 #define OC_RSRVD_ACL_GROUP_URL "/oic/acl/group"
559 #define OC_RSRVD_ACL_INVITE_URL "/oic/acl/invite"
561 #define OC_RSRVD_ACL_VERIFY_URL "/oic/acl/verify"
563 #define OC_RSRVD_ACL_ID_URL "/oic/acl/id"
565 #define OC_RSRVD_MEMBER_ID "mid"
567 #define OC_RSRVD_GROUP_ID "gid"
569 #define OC_RSRVD_OWNER_ID "oid"
571 #define OC_RSRVD_ACL_ID "aclid"
573 #define OC_RSRVD_ACE_ID "aceid"
575 #define OC_RSRVD_DEVICE_ID "di"
577 #define OC_RSRVD_SUBJECT_ID "sid"
579 #define OC_RSRVD_REQUEST_METHOD "rm"
581 #define OC_RSRVD_REQUEST_URI "uri"
583 #define OC_RSRVD_GROUP_MASTER_ID "gmid"
585 #define OC_RSRVD_GROUP_TYPE "gtype"
587 #define OC_RSRVD_SUBJECT_TYPE "stype"
589 #define OC_RSRVD_GROUP_ID_LIST "gidlist"
591 #define OC_RSRVD_MEMBER_ID_LIST "midlist"
593 #define OC_RSRVD_DEVICE_ID_LIST "dilist"
595 #define OC_RSRVD_ACCESS_CONTROL_LIST "aclist"
597 #define OC_RSRVD_RESOURCES "resources"
599 #define OC_RSRVD_VALIDITY "validity"
601 #define OC_RSRVD_PERIOD "period"
603 #define OC_RSRVD_RECURRENCE "recurrence"
605 #define OC_RSRVD_INVITE "invite"
607 #define OC_RSRVD_INVITED "invited"
609 #define OC_RSRVD_ENCODING "encoding"
611 #define OC_OIC_SEC "oic.sec"
613 #define OC_RSRVD_BASE64 "base64"
615 #define OC_RSRVD_DER "der"
617 #define OC_RSRVD_PEM "pem"
619 #define OC_RSRVD_RAW "raw"
621 #define OC_RSRVD_UNKNOWN "unknown"
623 #define OC_RSRVD_DATA "data"
625 #define OC_RSRVD_RESOURCE_OWNER_UUID "rowneruuid"
627 #define OC_RSRVD_SUBJECT_UUID "subjectuuid"
629 #define OC_RSRVD_PERMISSION_MASK "permission"
631 #define OC_RSRVD_GROUP_PERMISSION "gp"
633 #define OC_RSRVD_GROUP_ACL "gacl"
635 /** Certificete Sign Request */
636 #define OC_RSRVD_PROV_CERT_URI "/oic/credprov/cert"
638 #define OC_RSRVD_CSR "csr"
640 #define OC_RSRVD_CERT "cert"
642 #define OC_RSRVD_CACERT "certchain"
644 #define OC_RSRVD_TOKEN_TYPE "tokentype"
646 #define OC_RSRVD_EXPIRES_IN "expiresin"
648 #define OC_RSRVD_REDIRECT_URI "redirecturi"
650 #define OC_RSRVD_CERTIFICATE "certificate"
653 * TODO: Move these COAP defines to CoAP lib once approved.
655 #define COAP_OPTION_ACCEPT_VERSION 2049
656 #define COAP_OPTION_CONTENT_VERSION 2053
659 * These enums (OCTransportAdapter and OCTransportFlags) must
660 * be kept synchronized with OCConnectivityType (below) as well as
661 * CATransportAdapter and CATransportFlags (in CACommon.h).
665 /** value zero indicates discovery.*/
666 OC_DEFAULT_ADAPTER = 0,
668 /** IPv4 and IPv6, including 6LoWPAN.*/
669 OC_ADAPTER_IP = (1 << 0),
671 /** GATT over Bluetooth LE.*/
672 OC_ADAPTER_GATT_BTLE = (1 << 1),
674 /** RFCOMM over Bluetooth EDR.*/
675 OC_ADAPTER_RFCOMM_BTEDR = (1 << 2),
677 /**Remote Access over XMPP.*/
678 OC_ADAPTER_REMOTE_ACCESS = (1 << 3),
681 OC_ADAPTER_TCP = (1 << 4),
683 /** NFC Transport for Messaging.*/
684 OC_ADAPTER_NFC = (1 << 5)
685 } OCTransportAdapter;
689 /** default flag is 0.*/
690 OC_DEFAULT_BT_FLAGS = 0,
691 /** disable BLE advertisement.*/
692 OC_LE_ADV_DISABLE = 0x1,
693 /** enable BLE advertisement.*/
694 OC_LE_ADV_ENABLE = 0x2,
695 /** disable gatt server.*/
696 OC_LE_SERVER_DISABLE = (1 << 4),
697 /** disable rfcomm server.*/
698 OC_EDR_SERVER_DISABLE = (1 << 7)
699 } OCTransportBTFlags_t;
702 * Log level to print can be controlled through this enum.
703 * And privacy logs contained uid, Token, Device id, etc can also disable.
704 * This enum (OCLogLevel) must be kept synchronized with
705 * CAUtilLogLevel_t (in CACommon.h).
709 OC_LOG_LEVEL_ALL = 1, // all logs.
710 OC_LOG_LEVEL_INFO, // debug level is disabled.
714 * Enum layout assumes some targets have 16-bit integer (e.g., Arduino).
718 /** default flag is 0*/
719 OC_DEFAULT_FLAGS = 0,
721 /** Insecure transport is the default (subject to change).*/
722 /** secure the transport path*/
723 OC_FLAG_SECURE = (1 << 4),
725 /** IPv4 & IPv6 auto-selection is the default.*/
726 /** IP & TCP adapter only.*/
727 OC_IP_USE_V6 = (1 << 5),
729 /** IP & TCP adapter only.*/
730 OC_IP_USE_V4 = (1 << 6),
732 /** Multicast only.*/
733 OC_MULTICAST = (1 << 7),
735 /** Link-Local multicast is the default multicast scope for IPv6.
736 * These are placed here to correspond to the IPv6 multicast address bits.*/
738 /** IPv6 Interface-Local scope (loopback).*/
739 OC_SCOPE_INTERFACE = 0x1,
741 /** IPv6 Link-Local scope (default).*/
744 /** IPv6 Realm-Local scope. */
745 OC_SCOPE_REALM = 0x3,
747 /** IPv6 Admin-Local scope. */
748 OC_SCOPE_ADMIN = 0x4,
750 /** IPv6 Site-Local scope. */
753 /** IPv6 Organization-Local scope. */
756 /**IPv6 Global scope. */
757 OC_SCOPE_GLOBAL = 0xE,
761 /** Bit mask for scope.*/
762 #define OC_MASK_SCOPE (0x000F)
764 /** Bit mask for Mods.*/
765 #define OC_MASK_MODS (0x0FF0)
766 #define OC_MASK_FAMS (OC_IP_USE_V6|OC_IP_USE_V4)
768 typedef struct OCStringLL
770 struct OCStringLL *next;
775 * End point identity.
779 /** Identity Length */
782 /** Array of end point identity.*/
783 unsigned char id[MAX_IDENTITY_SIZE];
787 * Universally unique identifier.
791 /** identitifier string.*/
792 unsigned char id[UUID_IDENTITY_SIZE];
796 * Data structure to encapsulate IPv4/IPv6/Contiki/lwIP device addresses.
797 * OCDevAddr must be the same as CAEndpoint (in CACommon.h).
802 OCTransportAdapter adapter;
804 /** transport modifiers.*/
805 OCTransportFlags flags;
810 /** address for all adapters.*/
811 char addr[MAX_ADDR_STR_SIZE];
813 /** usually zero for default interface.*/
816 /** destination GatewayID:ClientId.*/
817 char routeData[MAX_ADDR_STR_SIZE];
819 /** device ID of remote.*/
820 char remoteId[MAX_IDENTITY_SIZE];
825 * This enum type includes elements of both ::OCTransportAdapter and ::OCTransportFlags.
826 * It is defined conditionally because the smaller definition limits expandability on 32/64 bit
827 * integer machines, and the larger definition won't fit into an enum on 16-bit integer machines
830 * This structure must directly correspond to ::OCTransportAdapter and ::OCTransportFlags.
834 /** use when defaults are ok. */
837 /** IPv4 and IPv6, including 6LoWPAN.*/
838 CT_ADAPTER_IP = (1 << 16),
840 /** GATT over Bluetooth LE.*/
841 CT_ADAPTER_GATT_BTLE = (1 << 17),
843 /** RFCOMM over Bluetooth EDR.*/
844 CT_ADAPTER_RFCOMM_BTEDR = (1 << 18),
847 /** Remote Access over XMPP.*/
848 CT_ADAPTER_REMOTE_ACCESS = (1 << 19),
851 CT_ADAPTER_TCP = (1 << 20),
854 CT_ADAPTER_NFC = (1 << 21),
856 /** Insecure transport is the default (subject to change).*/
858 /** secure the transport path.*/
859 CT_FLAG_SECURE = (1 << 4),
861 /** IPv4 & IPv6 autoselection is the default.*/
863 /** IP adapter only.*/
864 CT_IP_USE_V6 = (1 << 5),
866 /** IP adapter only.*/
867 CT_IP_USE_V4 = (1 << 6),
869 /** Link-Local multicast is the default multicast scope for IPv6.
870 * These are placed here to correspond to the IPv6 address bits.*/
872 /** IPv6 Interface-Local scope(loopback).*/
873 CT_SCOPE_INTERFACE = 0x1,
875 /** IPv6 Link-Local scope (default).*/
878 /** IPv6 Realm-Local scope.*/
879 CT_SCOPE_REALM = 0x3,
881 /** IPv6 Admin-Local scope.*/
882 CT_SCOPE_ADMIN = 0x4,
884 /** IPv6 Site-Local scope.*/
887 /** IPv6 Organization-Local scope.*/
890 /** IPv6 Global scope.*/
891 CT_SCOPE_GLOBAL = 0xE,
892 } OCConnectivityType;
894 /** bit shift required for connectivity adapter.*/
895 #define CT_ADAPTER_SHIFT 16
898 #define CT_MASK_FLAGS 0xFFFF
901 #define CT_MASK_ADAPTER 0xFFFF0000
904 * OCDoResource methods to dispatch the request
908 OC_REST_NOMETHOD = 0,
911 OC_REST_GET = (1 << 0),
914 OC_REST_PUT = (1 << 1),
917 OC_REST_POST = (1 << 2),
920 OC_REST_DELETE = (1 << 3),
922 /** Register observe request for most up date notifications ONLY.*/
923 OC_REST_OBSERVE = (1 << 4),
925 /** Register observe request for all notifications, including stale notifications.*/
926 OC_REST_OBSERVE_ALL = (1 << 5),
929 /** Subscribe for all presence notifications of a particular resource.*/
930 OC_REST_PRESENCE = (1 << 7),
933 /** Allows OCDoResource caller to do discovery.*/
934 OC_REST_DISCOVER = (1 << 8)
938 * Formats for payload encoding.
943 OC_FORMAT_VND_OCF_CBOR,
946 OC_FORMAT_UNSUPPORTED,
950 * Host Mode of Operation.
957 OC_GATEWAY /**< Client server mode along with routing capabilities.*/
961 * Quality of Service attempts to abstract the guarantees provided by the underlying transport
962 * protocol. The precise definitions of each quality of service level depend on the
963 * implementation. In descriptions below are for the current implementation and may changed
968 /** Packet delivery is best effort.*/
971 /** Packet delivery is best effort.*/
974 /** Acknowledgments are used to confirm delivery.*/
977 /** No Quality is defined, let the stack decide.*/
979 } OCQualityOfService;
982 * Resource Properties.
983 * The value of a policy property is defined as bitmap.
984 * The LSB represents OC_DISCOVERABLE and Second LSB bit represents OC_OBSERVABLE and so on.
985 * Not including the policy property is equivalent to zero.
990 /** When none of the bits are set, the resource is non-secure, non-discoverable &
991 * non-observable by the client.*/
992 OC_RES_PROP_NONE = (0),
994 /** When this bit is set, the resource is allowed to be discovered by clients.*/
995 OC_DISCOVERABLE = (1 << 0),
997 /** When this bit is set, the resource is allowed to be observed by clients.*/
998 OC_OBSERVABLE = (1 << 1),
1000 /** When this bit is set, the resource is initialized, otherwise the resource
1001 * is 'inactive'. 'inactive' signifies that the resource has been marked for
1002 * deletion or is already deleted.*/
1003 OC_ACTIVE = (1 << 2),
1005 /** When this bit is set, the resource has been marked as 'slow'.
1006 * 'slow' signifies that responses from this resource can expect delays in
1007 * processing its requests from clients.*/
1010 /** When this bit is set, the resource supports access via non-secure endpoints. */
1011 OC_NONSECURE = (1 << 6),
1013 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
1014 /** When this bit is set, the resource is a secure resource.*/
1015 OC_SECURE = (1 << 4),
1020 /** When this bit is set, the resource is allowed to be discovered only
1021 * if discovery request contains an explicit querystring.
1022 * Ex: GET /oic/res?rt=oic.sec.acl */
1023 OC_EXPLICIT_DISCOVERABLE = (1 << 5)
1026 /** When this bit is set, the resource is allowed to be published */
1028 // Since this property is not defined on OCF Spec. it should be set 0 until define it
1029 ,OC_MQ_PUBLISHER = (0)
1033 /** When this bit is set, the resource is allowed to be notified as MQ broker.*/
1035 // Since this property is not defined on OCF Spec. it should be set 0 until define it
1038 } OCResourceProperty;
1040 #define OC_MASK_RESOURCE_SECURE (OC_NONSECURE | OC_SECURE)
1043 * Transport Protocol IDs.
1047 /** For invalid ID.*/
1048 OC_INVALID_ID = (1 << 0),
1051 OC_COAP_ID = (1 << 1)
1052 } OCTransportProtocolID;
1055 * Declares Stack Results & Errors.
1059 /** Success status code - START HERE.*/
1060 OC_STACK_OK = 0, /** 203, 205*/
1061 OC_STACK_RESOURCE_CREATED, /** 201*/
1062 OC_STACK_RESOURCE_DELETED, /** 202*/
1064 OC_STACK_RESOURCE_CHANGED, /** 204*/
1065 /** Success status code - END HERE.*/
1067 /** Error status code - START HERE.*/
1068 OC_STACK_INVALID_URI = 20,
1069 OC_STACK_INVALID_QUERY, /** 400*/
1070 OC_STACK_INVALID_IP,
1071 OC_STACK_INVALID_PORT,
1072 OC_STACK_INVALID_CALLBACK,
1073 OC_STACK_INVALID_METHOD, /** 405 */
1075 /** Invalid parameter.*/
1076 OC_STACK_INVALID_PARAM,
1077 OC_STACK_INVALID_OBSERVE_PARAM,
1079 OC_STACK_COMM_ERROR, /** 504*/
1081 OC_STACK_ADAPTER_NOT_ENABLED,
1084 /** Resource not found.*/
1085 OC_STACK_NO_RESOURCE, /** 404*/
1087 /** e.g: not supported method or interface.*/
1088 OC_STACK_RESOURCE_ERROR,
1089 OC_STACK_SLOW_RESOURCE,
1090 OC_STACK_DUPLICATE_REQUEST,
1092 /** Resource has no registered observers.*/
1093 OC_STACK_NO_OBSERVERS,
1094 OC_STACK_OBSERVER_NOT_FOUND,
1095 OC_STACK_VIRTUAL_DO_NOT_HANDLE,
1096 OC_STACK_INVALID_OPTION, /** 402*/
1098 /** The remote reply contained malformed data.*/
1099 OC_STACK_MALFORMED_RESPONSE,
1100 OC_STACK_PERSISTENT_BUFFER_REQUIRED,
1101 OC_STACK_INVALID_REQUEST_HANDLE,
1102 OC_STACK_INVALID_DEVICE_INFO,
1103 OC_STACK_INVALID_JSON,
1105 /** Request is not authorized by Resource Server. */
1106 OC_STACK_UNAUTHORIZED_REQ, /** 401*/
1107 OC_STACK_TOO_LARGE_REQ, /** 413*/
1109 /** Error code from PDM */
1110 OC_STACK_PDM_IS_NOT_INITIALIZED,
1111 OC_STACK_DUPLICATE_UUID,
1112 OC_STACK_INCONSISTENT_DB,
1115 * Error code from OTM
1116 * This error is pushed from DTLS interface when handshake failure happens
1118 OC_STACK_AUTHENTICATION_FAILURE,
1119 OC_STACK_NOT_ALLOWED_OXM,
1120 OC_STACK_CONTINUE_OPERATION,
1122 /** Request come from endpoint which is not mapped to the resource. */
1123 OC_STACK_BAD_ENDPOINT,
1125 /** Insert all new error codes here!.*/
1126 #ifdef WITH_PRESENCE
1127 OC_STACK_PRESENCE_STOPPED = 128,
1128 OC_STACK_PRESENCE_TIMEOUT,
1129 OC_STACK_PRESENCE_DO_NOT_HANDLE,
1132 /** Request is denied by the user*/
1133 OC_STACK_USER_DENIED_REQ,
1134 OC_STACK_NOT_ACCEPTABLE, /** 406 */
1136 /** ERROR code from server */
1137 OC_STACK_FORBIDDEN_REQ, /** 403*/
1138 OC_STACK_INTERNAL_SERVER_ERROR, /** 500*/
1139 OC_STACK_GATEWAY_TIMEOUT, /** 504*/
1140 OC_STACK_SERVICE_UNAVAILABLE, /** 503*/
1142 /** ERROR in stack.*/
1143 OC_STACK_ERROR = 255
1144 /** Error status code - END HERE.*/
1148 * Handle to an OCDoResource invocation.
1150 typedef void * OCDoHandle;
1153 * Handle to an OCResource object owned by the OCStack.
1155 typedef void * OCResourceHandle;
1158 * Handle to an OCRequest object owned by the OCStack.
1160 typedef void * OCRequestHandle;
1163 * Unique identifier for each observation request. Used when observations are
1164 * registered or de-registered. Used by entity handler to signal specific
1165 * observers to be notified of resource changes.
1166 * There can be maximum of 256 observations per server.
1168 typedef uint8_t OCObservationId;
1171 * Sequence number is a 24 bit field,
1172 * per https://tools.ietf.org/html/rfc7641.
1174 #define MAX_SEQUENCE_NUMBER (0xFFFFFF)
1177 * Action associated with observation.
1182 OC_OBSERVE_REGISTER = 0,
1184 /** To Deregister. */
1185 OC_OBSERVE_DEREGISTER = 1,
1188 OC_OBSERVE_NO_OPTION = 2,
1194 * Persistent storage handlers. An APP must provide OCPersistentStorage handler pointers
1195 * when it calls OCRegisterPersistentStorageHandler.
1196 * Persistent storage open handler points to default file path.
1197 * It should check file path and whether the file is symbolic link or no.
1198 * Application can point to appropriate SVR database path for it's IoTivity Server.
1201 /** Persistent storage file path.*/
1202 FILE* (* open)(const char *path, const char *mode);
1204 /** Persistent storage read handler.*/
1205 size_t (* read)(void *ptr, size_t size, size_t nmemb, FILE *stream);
1207 /** Persistent storage write handler.*/
1208 size_t (* write)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
1210 /** Persistent storage close handler.*/
1211 int (* close)(FILE *fp);
1213 /** Persistent storage unlink handler.*/
1214 int (* unlink)(const char *path);
1215 } OCPersistentStorage;
1218 * Possible returned values from entity handler.
1222 /** Action associated with observation request.*/
1223 OCObserveAction action;
1225 /** Identifier for observation being registered/deregistered.*/
1226 OCObservationId obsId;
1227 } OCObservationInfo;
1230 * Possible returned values from entity handler.
1237 OC_EH_RESOURCE_CREATED = 201,
1238 OC_EH_RESOURCE_DELETED = 202,
1240 OC_EH_CHANGED = 204,
1241 OC_EH_CONTENT = 205,
1242 OC_EH_BAD_REQ = 400,
1243 OC_EH_UNAUTHORIZED_REQ = 401,
1244 OC_EH_BAD_OPT = 402,
1245 OC_EH_FORBIDDEN = 403,
1246 OC_EH_RESOURCE_NOT_FOUND = 404,
1247 OC_EH_METHOD_NOT_ALLOWED = 405,
1248 OC_EH_NOT_ACCEPTABLE = 406,
1249 OC_EH_TOO_LARGE = 413,
1250 OC_EH_UNSUPPORTED_MEDIA_TYPE = 415,
1251 OC_EH_INTERNAL_SERVER_ERROR = 500,
1252 OC_EH_BAD_GATEWAY = 502,
1253 OC_EH_SERVICE_UNAVAILABLE = 503,
1254 OC_EH_RETRANSMIT_TIMEOUT = 504
1255 } OCEntityHandlerResult;
1258 * This structure will be used to define the vendor specific header options to be included
1259 * in communication packets.
1261 typedef struct OCHeaderOption
1263 /** The protocol ID this option applies to.*/
1264 OCTransportProtocolID protocolID;
1266 /** The header option ID which will be added to communication packets.*/
1269 /** its length 191.*/
1270 uint16_t optionLength;
1272 /** pointer to its data.*/
1273 uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
1276 OCHeaderOption() = default;
1277 OCHeaderOption(OCTransportProtocolID pid,
1280 const uint8_t* optData)
1283 optionLength(optlen)
1286 // parameter includes the null terminator.
1287 optionLength = optionLength < MAX_HEADER_OPTION_DATA_LENGTH ?
1288 optionLength : MAX_HEADER_OPTION_DATA_LENGTH;
1289 memcpy(optionData, optData, optionLength);
1290 optionData[optionLength - 1] = '\0';
1292 #endif // __cplusplus
1296 * This structure describes the platform properties. All non-Null properties will be
1297 * included in a platform discovery request.
1298 * @deprecated: Use OCSetPropertyValue to set platform value.
1305 /** Manufacturer name.*/
1306 char *manufacturerName;
1308 /** Manufacturer URL for platform property.*/
1309 char *manufacturerUrl;
1314 /** Manufacturer date.*/
1315 char *dateOfManufacture;
1317 /** Platform version.*/
1318 char *platformVersion;
1320 /** Operating system version.*/
1321 char *operatingSystemVersion;
1324 char *hardwareVersion;
1327 char *firmwareVersion;
1329 /** Platform support URL.*/
1338 * This structure is expected as input for device properties.
1339 * device name is mandatory and expected from the application.
1340 * device id of type UUID will be generated by the stack.
1341 * @deprecated: Use OCSetPropertyValue to set device value.
1345 /** Pointer to the device name.*/
1347 /** Pointer to the types.*/
1349 /** Pointer to the device specification version.*/
1351 /** Pointer to the device data model versions (in CSV format).*/
1352 OCStringLL *dataModelVersions;
1356 * This enum type for indicate Transport Protocol Suites
1360 /** For initialize */
1367 OC_COAPS = (1 << 1),
1371 OC_COAP_TCP = (1 << 2),
1374 OC_COAPS_TCP = (1 << 3),
1381 OC_HTTPS = (1 << 5),
1384 /** coap + rfcomm */
1385 OC_COAP_RFCOMM = (1 << 6),
1389 OC_COAP_GATT = (1 << 7),
1393 OC_COAP_NFC = (1 << 8),
1396 /** coap + remote_access */
1397 OC_COAP_RA = (1 << 9),
1399 /** Allow all endpoint.*/
1405 * callback for bound JID
1407 typedef void (*jid_bound_cb)(char *jid);
1410 * CA Remote Access information for XMPP Client
1415 char *hostname; /**< XMPP server hostname */
1416 uint16_t port; /**< XMPP server serivce port */
1417 char *xmpp_domain; /**< XMPP login domain */
1418 char *username; /**< login username */
1419 char *password; /**< login password */
1420 char *resource; /**< specific resource for login */
1421 char *user_jid; /**< specific JID for login */
1422 jid_bound_cb jidbound; /**< callback when JID bound */
1424 #endif /* RA_ADAPTER */
1427 /** Enum to describe the type of object held by the OCPayload object.*/
1430 /** Contents of the payload are invalid */
1431 PAYLOAD_TYPE_INVALID,
1432 /** The payload is an OCDiscoveryPayload */
1433 PAYLOAD_TYPE_DISCOVERY,
1434 /** The payload of the device */
1435 PAYLOAD_TYPE_DEVICE,
1436 /** The payload type of the platform */
1437 PAYLOAD_TYPE_PLATFORM,
1438 /** The payload is an OCRepPayload */
1439 PAYLOAD_TYPE_REPRESENTATION,
1440 /** The payload is an OCSecurityPayload */
1441 PAYLOAD_TYPE_SECURITY,
1442 /** The payload is an OCPresencePayload */
1443 PAYLOAD_TYPE_PRESENCE,
1444 /** The payload is an OCDiagnosticPayload */
1445 PAYLOAD_TYPE_DIAGNOSTIC,
1446 /** The payload is an OCIntrospectionPayload */
1447 PAYLOAD_TYPE_INTROSPECTION
1451 * A generic struct representing a payload returned from a resource operation
1453 * A pointer to OCPayLoad can be cast to a more specific struct to access members
1458 /** The type of message that was received */
1469 OCREP_PROP_BYTE_STRING,
1472 }OCRepPayloadPropType;
1474 /** This structure will be used to represent a binary string for CBOR payloads.*/
1477 /** pointer to data bytes.*/
1480 /** number of data bytes.*/
1484 #define MAX_REP_ARRAY_DEPTH 3
1487 OCRepPayloadPropType type;
1488 size_t dimensions[MAX_REP_ARRAY_DEPTH];
1497 /** pointer to ByteString array.*/
1498 OCByteString* ocByteStrArray;
1500 struct OCRepPayload** objArray;
1502 } OCRepPayloadValueArray;
1504 typedef struct OCRepPayloadValue
1507 OCRepPayloadPropType type;
1515 /** ByteString object.*/
1516 OCByteString ocByteStr;
1518 struct OCRepPayload* obj;
1519 OCRepPayloadValueArray arr;
1521 struct OCRepPayloadValue* next;
1523 } OCRepPayloadValue;
1525 // used for get/set/put/observe/etc representations
1526 typedef struct OCRepPayload
1531 OCStringLL* interfaces;
1532 OCRepPayloadValue* values;
1533 struct OCRepPayload* next;
1536 // used inside a resource payload
1537 typedef struct OCEndpointPayload
1541 OCTransportFlags family;
1544 struct OCEndpointPayload* next;
1545 } OCEndpointPayload;
1547 // used inside a discovery payload
1548 typedef struct OCResourcePayload
1554 OCStringLL* interfaces;
1561 struct OCResourcePayload* next;
1562 OCEndpointPayload* eps;
1563 } OCResourcePayload;
1565 typedef struct OCDiscoveryPayload
1575 /** Resource Type */
1581 /** This structure holds the old /oic/res response. */
1582 OCResourcePayload *resources;
1584 /** Holding address of the next DiscoveryPayload. */
1585 struct OCDiscoveryPayload *next;
1587 } OCDiscoveryPayload;
1592 uint8_t* securityData;
1594 } OCSecurityPayload;
1596 #ifdef WITH_PRESENCE
1600 uint32_t sequenceNumber;
1602 OCPresenceTrigger trigger;
1604 } OCPresencePayload;
1611 } OCDiagnosticPayload;
1616 OCByteString cborPayload;
1617 } OCIntrospectionPayload;
1620 * Incoming requests handled by the server. Requests are passed in as a parameter to the
1621 * OCEntityHandler callback API.
1622 * The OCEntityHandler callback API must be implemented in the application in order
1623 * to receive these requests.
1627 /** Associated resource.*/
1628 OCResourceHandle resource;
1630 /** Associated request handle.*/
1631 OCRequestHandle requestHandle;
1633 /** the REST method retrieved from received request PDU.*/
1636 /** description of endpoint that sent the request.*/
1639 /** resource query send by client.*/
1642 /** Information associated with observation - valid only when OCEntityHandler flag includes
1643 * ::OC_OBSERVE_FLAG.*/
1644 OCObservationInfo obsInfo;
1646 /** Number of the received vendor specific header options.*/
1647 uint8_t numRcvdVendorSpecificHeaderOptions;
1649 /** Pointer to the array of the received vendor specific header options.*/
1650 OCHeaderOption * rcvdVendorSpecificHeaderOptions;
1655 /** the payload from the request PDU.*/
1658 } OCEntityHandlerRequest;
1662 * Response from queries to remote servers. Queries are made by calling the OCDoResource API.
1666 /** Address of remote server.*/
1669 /** backward compatibility (points to devAddr).*/
1672 /** backward compatibility.*/
1673 OCConnectivityType connType;
1675 /** the security identity of the remote server.*/
1676 OCIdentity identity;
1678 /** the is the result of our stack, OCStackResult should contain coap/other error codes.*/
1679 OCStackResult result;
1681 /** If associated with observe, this will represent the sequence of notifications from server.*/
1682 uint32_t sequenceNumber;
1685 const char * resourceUri;
1687 /** the payload for the response PDU.*/
1690 /** Number of the received vendor specific header options.*/
1691 uint8_t numRcvdVendorSpecificHeaderOptions;
1693 /** An array of the received vendor specific header options.*/
1694 OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
1698 * Request handle is passed to server via the entity handler for each incoming request.
1699 * Stack assigns when request is received, server sets to indicate what request response is for.
1703 /** Request handle.*/
1704 OCRequestHandle requestHandle;
1706 /** Resource handle. (@deprecated: This parameter is not used.) */
1707 OCResourceHandle resourceHandle;
1709 /** Allow the entity handler to pass a result with the response.*/
1710 OCEntityHandlerResult ehResult;
1712 /** This is the pointer to server payload data to be transferred.*/
1715 /** number of the vendor specific header options .*/
1716 uint8_t numSendVendorSpecificHeaderOptions;
1718 /** An array of the vendor specific header options the entity handler wishes to use in response.*/
1719 OCHeaderOption sendVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
1721 /** Resource path of new resource that entity handler might create.*/
1722 char resourceUri[MAX_URI_LENGTH];
1724 /** Server sets to true for persistent response buffer,false for non-persistent response buffer*/
1725 uint8_t persistentBufferFlag;
1726 } OCEntityHandlerResponse;
1733 /** Request state.*/
1734 OC_REQUEST_FLAG = (1 << 1),
1735 /** Observe state.*/
1736 OC_OBSERVE_FLAG = (1 << 2)
1737 } OCEntityHandlerFlag;
1740 * Possible return values from client application callback
1742 * A client application callback returns an OCStackApplicationResult to indicate whether
1743 * the stack should continue to keep the callback registered.
1747 /** Make no more calls to the callback and call the OCClientContextDeleter for this callback */
1748 OC_STACK_DELETE_TRANSACTION = 0,
1749 /** Keep this callback registered and call it if an apropriate event occurs */
1750 OC_STACK_KEEP_TRANSACTION
1751 } OCStackApplicationResult;
1754 //#ifdef DIRECT_PAIRING
1756 * @brief direct pairing Method Type.
1758 * 1: pre-configured pin
1763 DP_NOT_ALLOWED = 0x0,
1764 DP_PRE_CONFIGURED = (0x1 << 0),
1765 DP_RANDOM_PIN = (0x1 << 1),
1769 * Device Information of discoverd direct pairing device(s).
1771 typedef struct OCDPDev
1774 OCConnectivityType connType;
1775 uint16_t securePort;
1779 OCUUIdentity deviceID;
1780 OCUUIdentity rowner;
1781 struct OCDPDev *next;
1783 //#endif // DIRECT_PAIRING
1786 * -------------------------------------------------------------------------------------------
1787 * Callback function definitions
1788 * -------------------------------------------------------------------------------------------
1792 * Client applications implement this callback to consume responses received from Servers.
1794 typedef OCStackApplicationResult (* OCClientResponseHandler)(void *context, OCDoHandle handle,
1795 OCClientResponse * clientResponse);
1798 * Client applications using a context pointer implement this callback to delete the
1799 * context upon removal of the callback/context pointer from the internal callback-list.
1801 typedef void (* OCClientContextDeleter)(void *context);
1804 * This info is passed from application to OC Stack when initiating a request to Server.
1806 typedef struct OCCallbackData
1808 /** Pointer to the context.*/
1811 /** The pointer to a function the stack will call to handle the requests.*/
1812 OCClientResponseHandler cb;
1814 /** A pointer to a function to delete the context when this callback is removed.*/
1815 OCClientContextDeleter cd;
1818 OCCallbackData() = default;
1819 OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter)
1820 :context(ctx), cb(callback), cd(deleter){}
1821 #endif // __cplusplus
1825 * Application server implementations must implement this callback to consume requests OTA.
1826 * Entity handler callback needs to fill the resPayload of the entityHandlerRequest.
1828 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
1829 * OC_EH_SLOW and etc in entity handler callback,
1830 * ocstack will be not send response automatically to client
1831 * except for error return value like OC_EH_ERROR.
1833 * If you want to send response to client with specific result,
1834 * OCDoResponse API should be called with the result value.
1838 * OCEntityHandlerResponse response;
1842 * response.ehResult = OC_EH_CHANGED;
1846 * OCDoResponse(&response)
1852 typedef OCEntityHandlerResult (*OCEntityHandler)
1853 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void* callbackParam);
1856 * Device Entity handler need to use this call back instead of OCEntityHandler.
1858 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
1859 * OC_EH_SLOW and etc in entity handler callback,
1860 * ocstack will be not send response automatically to client
1861 * except for error return value like OC_EH_ERROR.
1863 * If you want to send response to client with specific result,
1864 * OCDoResponse API should be called with the result value.
1868 * OCEntityHandlerResponse response;
1872 * response.ehResult = OC_EH_CHANGED;
1876 * OCDoResponse(&response)
1882 typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
1883 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri, void* callbackParam);
1885 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
1887 * Callback function definition for Change in TrustCertChain
1889 * @param[in] ctx - user context returned in the callback.
1890 * @param[in] credId - trustCertChain changed for this ID
1891 * @param[in] trustCertChain - trustcertchain binary blob.
1892 * @param[in] chainSize - size of trustchain
1894 typedef void (*TrustCertChainChangeCB)(void *ctx, uint16_t credId, uint8_t *trustCertChain,
1898 * certChain context structure.
1900 typedef struct trustCertChainContext
1902 TrustCertChainChangeCB callback;
1904 } trustCertChainContext_t;
1907 #if defined(TCP_ADAPTER) && defined(WITH_CLOUD)
1909 * User Preference of connectivity channel
1914 OC_USER_PREF_CLOUD = 0,
1916 OC_USER_PREF_LOCAL_UDP = 1,
1918 OC_USER_PREF_LOCAL_TCP =2
1919 } OCConnectUserPref_t;
1925 #endif // __cplusplus
1927 #endif /* OCTYPES_H_ */