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 definition, types and APIs for resource(s) be implemented.
31 #include "iotivity_config.h"
32 #include "ocstackconfig.h"
42 /** For the feature presence.*/
45 #include "ocpresence.h"
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 /** Version of IoTivity. */
52 #define IOTIVITY_VERSION "1.3.0"
55 * OIC Virtual resources supported by every OIC device.
58 * Default discovery mechanism using '/oic/res' is supported by all OIC devices
59 * That are Discoverable.
61 #define OC_RSRVD_WELL_KNOWN_URI "/oic/res"
64 #define OC_RSRVD_DEVICE_URI "/oic/d"
67 #define OC_RSRVD_PLATFORM_URI "/oic/p"
70 #define OC_RSRVD_RESOURCE_TYPES_URI "/oic/res/types/d"
73 #define OC_RSRVD_GATEWAY_URI "/oic/gateway"
76 #define OC_RSRVD_WELL_KNOWN_MQ_URI "/oic/ps"
79 #define OC_RSRVD_KEEPALIVE_URI "/oic/ping"
81 /** Introspection URI.*/
82 #define OC_RSRVD_INTROSPECTION_URI "/oic/introspection"
84 /** Introspection payload URI.*/
85 #define OC_RSRVD_INTROSPECTION_PAYLOAD_URI "/oic/introspection/payload"
89 /** Presence URI through which the OIC devices advertise their presence.*/
90 #define OC_RSRVD_PRESENCE_URI "/oic/ad"
92 /** Presence URI through which the OIC devices advertise their device presence.*/
93 #define OC_RSRVD_DEVICE_PRESENCE_URI "/oic/prs"
95 /** Sets the default time to live (TTL) for presence.*/
96 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
98 /** For multicast Discovery mechanism.*/
99 #define OC_MULTICAST_DISCOVERY_URI "/oic/res"
101 /** Separator for multiple query string.*/
102 #define OC_QUERY_SEPARATOR "&;"
104 /** Delimeter for keys and values in query string.*/
105 #define OC_KEY_VALUE_DELIMITER "="
108 * OC_DEFAULT_PRESENCE_TTL_SECONDS sets the default time to live (TTL) for presence.
110 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
113 * OC_MAX_PRESENCE_TTL_SECONDS sets the maximum time to live (TTL) for presence.
114 * NOTE: Changing the setting to a longer duration may lead to unsupported and untested
116 * 60 sec/min * 60 min/hr * 24 hr/day
118 #define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24)
122 * Presence "Announcement Triggers".
126 #define OC_RSRVD_TRIGGER_CREATE "create"
129 #define OC_RSRVD_TRIGGER_CHANGE "change"
132 #define OC_RSRVD_TRIGGER_DELETE "delete"
135 * Attributes used to form a proper OIC conforming JSON message.
138 #define OC_RSRVD_OC "oic"
143 #define OC_RSRVD_PAYLOAD "payload"
145 /** To represent href */
146 #define OC_RSRVD_HREF "href"
148 /** To represent property*/
149 #define OC_RSRVD_PROPERTY "prop"
151 /** For representation.*/
152 #define OC_RSRVD_REPRESENTATION "rep"
154 /** To represent content type.*/
155 #define OC_RSRVD_CONTENT_TYPE "ct"
157 /** To represent resource type.*/
158 #define OC_RSRVD_RESOURCE_TYPE "rt"
160 /** To represent resource type with presence.*/
161 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad"
163 /** To represent resource type with device.*/
164 #define OC_RSRVD_RESOURCE_TYPE_DEVICE "oic.wk.d"
166 /** To represent resource type with platform.*/
167 #define OC_RSRVD_RESOURCE_TYPE_PLATFORM "oic.wk.p"
169 /** To represent resource type with collection.*/
170 #define OC_RSRVD_RESOURCE_TYPE_COLLECTION "oic.wk.col"
172 /** To represent resource type with RES.*/
173 #define OC_RSRVD_RESOURCE_TYPE_RES "oic.wk.res"
175 /** To represent content type with MQ Broker.*/
176 #define OC_RSRVD_RESOURCE_TYPE_MQ_BROKER "oic.wk.ps"
178 /** To represent content type with MQ Topic.*/
179 #define OC_RSRVD_RESOURCE_TYPE_MQ_TOPIC "oic.wk.ps.topic"
181 /** To represent resource type with introspection.*/
182 #define OC_RSRVD_RESOURCE_TYPE_INTROSPECTION "oic.wk.introspection"
184 /** To represent resource type with introspection payload.*/
185 #define OC_RSRVD_RESOURCE_TYPE_INTROSPECTION_PAYLOAD "oic.wk.introspection.payload"
187 /** To represent interface.*/
188 #define OC_RSRVD_INTERFACE "if"
190 /** To indicate how long RD should publish this item.*/
191 #define OC_RSRVD_DEVICE_TTL "lt"
193 /** To represent time to live.*/
194 #define OC_RSRVD_TTL "ttl"
196 /** To represent non*/
197 #define OC_RSRVD_NONCE "non"
199 /** To represent trigger type.*/
200 #define OC_RSRVD_TRIGGER "trg"
202 /** To represent links.*/
203 #define OC_RSRVD_LINKS "links"
205 /** To represent default interface.*/
206 #define OC_RSRVD_INTERFACE_DEFAULT "oic.if.baseline"
208 /** To represent read-only interface.*/
209 #define OC_RSRVD_INTERFACE_READ "oic.if.r"
211 /** To represent read-write interface.*/
212 #define OC_RSRVD_INTERFACE_READ_WRITE "oic.if.rw"
214 /** To represent ll interface.*/
215 #define OC_RSRVD_INTERFACE_LL "oic.if.ll"
217 /** To represent batch interface.*/
218 #define OC_RSRVD_INTERFACE_BATCH "oic.if.b"
220 /** To represent actuator interface.*/
221 #define OC_RSRVD_INTERFACE_ACTUATOR "oic.if.a"
223 /** To represent sensor interface.*/
224 #define OC_RSRVD_INTERFACE_SENSOR "oic.if.s"
226 /** To represent interface group.*/
227 #define OC_RSRVD_INTERFACE_GROUP "oic.mi.grp"
229 /** To represent FW version.*/
230 #define OC_RSRVD_FW_VERSION "mnfv"
232 /** To represent host name.*/
233 #define OC_RSRVD_HOST_NAME "hn"
235 /** To represent policy.*/
236 #define OC_RSRVD_POLICY "p"
238 /** To represent bitmap.*/
239 #define OC_RSRVD_BITMAP "bm"
242 #define OC_RSRVD_SECURE "sec"
244 /** Security Database persistent store name(json).*/
245 #define OC_SECURITY_DB_FILE_NAME "oic_svr_db.json"
247 /** Security Database persistent store name(dat).*/
248 #define OC_SECURITY_DB_DAT_FILE_NAME "oic_svr_db.dat"
251 #define OC_RSRVD_HOSTING_PORT "port"
254 #define OC_RSRVD_TCP_PORT "x.org.iotivity.tcp"
257 #define OC_RSRVD_TLS_PORT "x.org.iotivity.tls"
259 /** For Server instance ID.*/
260 #define OC_RSRVD_SERVER_INSTANCE_ID "sid"
262 /** To represent endpoints.*/
263 #define OC_RSRVD_ENDPOINTS "eps"
265 /** To represent endpoint.*/
266 #define OC_RSRVD_ENDPOINT "ep"
268 /** To represent priority.*/
269 #define OC_RSRVD_PRIORITY "pri"
276 #define OC_RSRVD_PLATFORM_ID "pi"
278 /** Platform MFG NAME. */
279 #define OC_RSRVD_MFG_NAME "mnmn"
282 #define OC_RSRVD_MFG_URL "mnml"
285 #define OC_RSRVD_MODEL_NUM "mnmo"
287 /** Platform MFG Date.*/
288 #define OC_RSRVD_MFG_DATE "mndt"
290 /** Platform versio.n */
291 #define OC_RSRVD_PLATFORM_VERSION "mnpv"
293 /** Platform Operating system version. */
294 #define OC_RSRVD_OS_VERSION "mnos"
296 /** Platform Hardware version. */
297 #define OC_RSRVD_HARDWARE_VERSION "mnhw"
299 /**Platform Firmware version. */
300 #define OC_RSRVD_FIRMWARE_VERSION "mnfv"
302 /** Support URL for the platform. */
303 #define OC_RSRVD_SUPPORT_URL "mnsl"
305 /** System time for the platform. */
306 #define OC_RSRVD_SYSTEM_TIME "st"
308 /** VID for the platform. */
309 #define OC_RSRVD_VID "vid"
315 #define OC_RSRVD_DEVICE_ID "di"
318 #define OC_RSRVD_DEVICE_NAME "n"
320 /** Device specification version.*/
321 #define OC_RSRVD_SPEC_VERSION "icv"
323 /** Device data model.*/
324 #define OC_RSRVD_DATA_MODEL_VERSION "dmv"
326 /** Device specification version.*/
327 #define OC_SPEC_VERSION "core.1.1.0"
329 /** Integer value of spec version.*/
330 #define OC_SPEC_VERSION_VALUE 0
332 /** Device Data Model version.*/
333 #define OC_DATA_MODEL_VERSION "res.1.1.0,sh.1.1.0"
335 /** Protocol-Independent ID.*/
336 #define OC_RSRVD_PROTOCOL_INDEPENDENT_ID "piid"
342 #define OC_RSRVD_INTROSPECTION_NAME "name"
345 #define OC_RSRVD_INTROSPECTION_NAME_VALUE "Introspection"
347 /** Url info Object.*/
348 #define OC_RSRVD_INTROSPECTION_URL_INFO "urlInfo"
351 #define OC_RSRVD_INTROSPECTION_URL "url"
353 /** Protocol property.*/
354 #define OC_RSRVD_INTROSPECTION_PROTOCOL "protocol"
356 /** Content-Type property.*/
357 #define OC_RSRVD_INTROSPECTION_CONTENT_TYPE "content-type"
359 /** Content-Type property value.*/
360 #define OC_RSRVD_INTROSPECTION_CONTENT_TYPE_VALUE "application/cbor"
362 /** Version property.*/
363 #define OC_RSRVD_INTROSPECTION_VERSION "version"
365 /** Version property value.*/
366 #define OC_RSRVD_INTROSPECTION_VERSION_VALUE 1
368 /** Introspection payload data property name.*/
369 #define OC_RSRVD_INTROSPECTION_DATA_NAME "data"
371 /** Introspection persistent store name.*/
372 #define OC_INTROSPECTION_FILE_NAME "introspection.json"
375 * These provide backward compatibility - their use is deprecated.
379 /** Multicast Prefix.*/
380 #define OC_MULTICAST_PREFIX "224.0.1.187:5683"
382 /** Multicast IP address.*/
383 #define OC_MULTICAST_IP "224.0.1.187"
385 /** Multicast Port.*/
386 #define OC_MULTICAST_PORT (5683)
389 /** Max Device address size. */
391 #define MAX_ADDR_STR_SIZE (256)
393 /** Max Address could be
394 * "coaps+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx"
395 * +1 for null terminator.
397 #define MAX_ADDR_STR_SIZE (66)
400 /** Length of MAC address */
401 #define MAC_ADDR_STR_SIZE (17)
403 /** Blocks of MAC address */
404 #define MAC_ADDR_BLOCKS (6)
406 /** Max identity size. */
407 #define MAX_IDENTITY_SIZE (37)
409 /** Universal unique identity size. */
410 #define UUID_IDENTITY_SIZE (128/8)
412 /** Resource Directory */
414 /** Resource Directory URI used to Discover RD and Publish resources.*/
415 #define OC_RSRVD_RD_URI "/oic/rd"
417 /** To represent resource type with rd.*/
418 #define OC_RSRVD_RESOURCE_TYPE_RD "oic.wk.rd"
420 /** RD Discovery bias factor type. */
421 #define OC_RSRVD_RD_DISCOVERY_SEL "sel"
423 /** Resource URI used to discover Proxy */
424 #define OC_RSRVD_PROXY_URI "/oic/chp"
426 /** Resource URI used to discover Proxy */
427 #define OC_RSRVD_PROXY_OPTION_ID 35
430 #define OC_RSRVD_BASE_URI "baseURI"
432 /** Unique value per collection/link. */
433 #define OC_RSRVD_INS "ins"
435 /** Allowable resource types in the links. */
436 #define OC_RSRVD_RTS "rts"
438 /** Default relationship. */
439 #define OC_RSRVD_DREL "drel"
441 /** Defines relationship between links. */
442 #define OC_RSRVD_REL "rel"
444 /** Defines title. */
445 #define OC_RSRVD_TITLE "title"
448 #define OC_RSRVD_URI "anchor"
450 /** Defines media type. */
451 #define OC_RSRVD_MEDIA_TYPE "type"
453 /** To represent resource type with Publish RD.*/
454 #define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdpub"
459 #define OC_RSRVD_ACCOUNT_URI "/oic/account"
461 /** Account user URI.*/
462 #define OC_RSRVD_ACCOUNT_SEARCH_URI "/oic/account/search"
464 /** Account session URI.*/
465 #define OC_RSRVD_ACCOUNT_SESSION_URI "/oic/account/session"
467 /** Account token refresh URI.*/
468 #define OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI "/oic/account/tokenrefresh"
471 #define OC_RSRVD_ACL_GROUP_URI "/oic/acl/group"
473 /** ACL invite URI.*/
474 #define OC_RSRVD_ACL_INVITE_URI "/oic/acl/invite"
476 /** Defines auth provider. */
477 #define OC_RSRVD_AUTHPROVIDER "authprovider"
479 /** Defines auth code. */
480 #define OC_RSRVD_AUTHCODE "authcode"
482 /** Defines access token. */
483 #define OC_RSRVD_ACCESS_TOKEN "accesstoken"
485 /** Defines login. */
486 #define OC_RSRVD_LOGIN "login"
488 /** Defines search. */
489 #define OC_RSRVD_SEARCH "search"
491 /** Defines grant type. */
492 #define OC_RSRVD_GRANT_TYPE "granttype"
494 /** Defines refresh token. */
495 #define OC_RSRVD_REFRESH_TOKEN "refreshtoken"
497 /** Defines user UUID. */
498 #define OC_RSRVD_USER_UUID "uid"
500 /** Defines group ID. */
501 #define OC_RSRVD_GROUP_ID "gid"
503 /** Defines member of group ID. */
504 #define OC_RSRVD_MEMBER_ID "mid"
506 /** Defines invite. */
507 #define OC_RSRVD_INVITE "invite"
509 /** Defines accept. */
510 #define OC_RSRVD_ACCEPT "accept"
512 /** Defines operation. */
513 #define OC_RSRVD_OPERATION "op"
516 #define OC_RSRVD_ADD "add"
518 /** Defines delete. */
519 #define OC_RSRVD_DELETE "delete"
521 /** Defines owner. */
522 #define OC_RSRVD_OWNER "owner"
524 /** Defines members. */
525 #define OC_RSRVD_MEMBERS "members"
527 /** To represent grant type with refresh token. */
528 #define OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN "refresh_token"
531 #define OC_RSRVD_PROV_CRL_URL "/oic/credprov/crl"
533 #define OC_RSRVD_LAST_UPDATE "lu"
535 #define OC_RSRVD_THIS_UPDATE "tu"
537 #define OC_RSRVD_NEXT_UPDATE "nu"
539 #define OC_RSRVD_SERIAL_NUMBERS "rcsn"
541 #define OC_RSRVD_CRL "crl"
543 #define OC_RSRVD_CRL_ID "crlid"
546 #define OC_RSRVD_GROUP_URL "/oic/group"
548 #define OC_RSRVD_ACL_GROUP_URL "/oic/acl/group"
550 #define OC_RSRVD_ACL_INVITE_URL "/oic/acl/invite"
552 #define OC_RSRVD_ACL_VERIFY_URL "/oic/acl/verify"
554 #define OC_RSRVD_ACL_ID_URL "/oic/acl/id"
556 #define OC_RSRVD_MEMBER_ID "mid"
558 #define OC_RSRVD_GROUP_ID "gid"
560 #define OC_RSRVD_OWNER_ID "oid"
562 #define OC_RSRVD_ACL_ID "aclid"
564 #define OC_RSRVD_ACE_ID "aceid"
566 #define OC_RSRVD_DEVICE_ID "di"
568 #define OC_RSRVD_SUBJECT_ID "sid"
570 #define OC_RSRVD_REQUEST_METHOD "rm"
572 #define OC_RSRVD_REQUEST_URI "uri"
574 #define OC_RSRVD_GROUP_MASTER_ID "gmid"
576 #define OC_RSRVD_GROUP_TYPE "gtype"
578 #define OC_RSRVD_SUBJECT_TYPE "stype"
580 #define OC_RSRVD_GROUP_ID_LIST "gidlist"
582 #define OC_RSRVD_MEMBER_ID_LIST "midlist"
584 #define OC_RSRVD_DEVICE_ID_LIST "dilist"
586 #define OC_RSRVD_ACCESS_CONTROL_LIST "aclist"
588 #define OC_RSRVD_RESOURCES "resources"
590 #define OC_RSRVD_VALIDITY "validity"
592 #define OC_RSRVD_PERIOD "period"
594 #define OC_RSRVD_RECURRENCE "recurrence"
596 #define OC_RSRVD_INVITE "invite"
598 #define OC_RSRVD_INVITED "invited"
600 #define OC_RSRVD_ENCODING "encoding"
602 #define OC_OIC_SEC "oic.sec"
604 #define OC_RSRVD_BASE64 "base64"
606 #define OC_RSRVD_DER "der"
608 #define OC_RSRVD_PEM "pem"
610 #define OC_RSRVD_RAW "raw"
612 #define OC_RSRVD_UNKNOWN "unknown"
614 #define OC_RSRVD_DATA "data"
616 #define OC_RSRVD_RESOURCE_OWNER_UUID "rowneruuid"
618 #define OC_RSRVD_SUBJECT_UUID "subjectuuid"
620 #define OC_RSRVD_PERMISSION_MASK "permission"
622 #define OC_RSRVD_GROUP_PERMISSION "gp"
624 #define OC_RSRVD_GROUP_ACL "gacl"
626 /** Certificete Sign Request */
627 #define OC_RSRVD_PROV_CERT_URI "/oic/credprov/cert"
629 #define OC_RSRVD_CSR "csr"
631 #define OC_RSRVD_CERT "cert"
633 #define OC_RSRVD_CACERT "certchain"
635 #define OC_RSRVD_TOKEN_TYPE "tokentype"
637 #define OC_RSRVD_EXPIRES_IN "expiresin"
639 #define OC_RSRVD_REDIRECT_URI "redirecturi"
641 #define OC_RSRVD_CERTIFICATE "certificate"
643 * Mark a parameter as unused. Used to prevent unused variable compiler warnings.
644 * Used in three cases:
645 * 1. in callbacks when one of the parameters are unused
646 * 2. when due to code changes a functions parameter is no longer
647 * used but must be left in place for backward compatibility
649 * 3. a variable is only used in the debug build variant and would
650 * give a build warning in release mode.
652 #define OC_UNUSED(x) (void)(x)
655 * These enums (OCTransportAdapter and OCTransportFlags) must
656 * be kept synchronized with OCConnectivityType (below) as well as
657 * CATransportAdapter and CATransportFlags (in CACommon.h).
661 /** value zero indicates discovery.*/
662 OC_DEFAULT_ADAPTER = 0,
664 /** IPv4 and IPv6, including 6LoWPAN.*/
665 OC_ADAPTER_IP = (1 << 0),
667 /** GATT over Bluetooth LE.*/
668 OC_ADAPTER_GATT_BTLE = (1 << 1),
670 /** RFCOMM over Bluetooth EDR.*/
671 OC_ADAPTER_RFCOMM_BTEDR = (1 << 2),
673 /**Remote Access over XMPP.*/
674 OC_ADAPTER_REMOTE_ACCESS = (1 << 3),
677 OC_ADAPTER_TCP = (1 << 4),
679 /** NFC Transport for Messaging.*/
680 OC_ADAPTER_NFC = (1 << 5)
681 } OCTransportAdapter;
685 /** default flag is 0.*/
686 OC_DEFAULT_BT_FLAGS = 0,
687 /** disable BLE advertisement.*/
688 OC_LE_ADV_DISABLE = 0x1,
689 /** enable BLE advertisement.*/
690 OC_LE_ADV_ENABLE = 0x2,
691 /** disable gatt server.*/
692 OC_LE_SERVER_DISABLE = (1 << 4),
693 /** disable rfcomm server.*/
694 OC_EDR_SERVER_DISABLE = (1 << 7)
695 } OCTransportBTFlags_t;
698 * Log level to print can be controlled through this enum.
699 * And privacy logs contained uid, Token, Device id, etc can also disable.
700 * This enum (OCLogLevel) must be kept synchronized with
701 * CAUtilLogLevel_t (in CACommon.h).
705 OC_LOG_LEVEL_ALL = 1, // all logs.
706 OC_LOG_LEVEL_INFO, // debug level is disabled.
710 * Enum layout assumes some targets have 16-bit integer (e.g., Arduino).
714 /** default flag is 0*/
715 OC_DEFAULT_FLAGS = 0,
717 /** Insecure transport is the default (subject to change).*/
718 /** secure the transport path*/
719 OC_FLAG_SECURE = (1 << 4),
721 /** IPv4 & IPv6 auto-selection is the default.*/
722 /** IP & TCP adapter only.*/
723 OC_IP_USE_V6 = (1 << 5),
725 /** IP & TCP adapter only.*/
726 OC_IP_USE_V4 = (1 << 6),
728 /** Multicast only.*/
729 OC_MULTICAST = (1 << 7),
731 /** Link-Local multicast is the default multicast scope for IPv6.
732 * These are placed here to correspond to the IPv6 multicast address bits.*/
734 /** IPv6 Interface-Local scope (loopback).*/
735 OC_SCOPE_INTERFACE = 0x1,
737 /** IPv6 Link-Local scope (default).*/
740 /** IPv6 Realm-Local scope. */
741 OC_SCOPE_REALM = 0x3,
743 /** IPv6 Admin-Local scope. */
744 OC_SCOPE_ADMIN = 0x4,
746 /** IPv6 Site-Local scope. */
749 /** IPv6 Organization-Local scope. */
752 /**IPv6 Global scope. */
753 OC_SCOPE_GLOBAL = 0xE,
757 /** Bit mask for scope.*/
758 #define OC_MASK_SCOPE (0x000F)
760 /** Bit mask for Mods.*/
761 #define OC_MASK_MODS (0x0FF0)
762 #define OC_MASK_FAMS (OC_IP_USE_V6|OC_IP_USE_V4)
764 typedef struct OCStringLL
766 struct OCStringLL *next;
771 * End point identity.
775 /** Identity Length */
778 /** Array of end point identity.*/
779 unsigned char id[MAX_IDENTITY_SIZE];
783 * Universally unique identifier.
787 /** identitifier string.*/
788 unsigned char id[UUID_IDENTITY_SIZE];
792 * Data structure to encapsulate IPv4/IPv6/Contiki/lwIP device addresses.
793 * OCDevAddr must be the same as CAEndpoint (in CACommon.h).
798 OCTransportAdapter adapter;
800 /** transport modifiers.*/
801 OCTransportFlags flags;
806 /** address for all adapters.*/
807 char addr[MAX_ADDR_STR_SIZE];
809 /** usually zero for default interface.*/
812 /** destination GatewayID:ClientId.*/
813 char routeData[MAX_ADDR_STR_SIZE];
815 /** device ID of remote.*/
816 char remoteId[MAX_IDENTITY_SIZE];
821 * This enum type includes elements of both ::OCTransportAdapter and ::OCTransportFlags.
822 * It is defined conditionally because the smaller definition limits expandability on 32/64 bit
823 * integer machines, and the larger definition won't fit into an enum on 16-bit integer machines
826 * This structure must directly correspond to ::OCTransportAdapter and ::OCTransportFlags.
830 /** use when defaults are ok. */
833 /** IPv4 and IPv6, including 6LoWPAN.*/
834 CT_ADAPTER_IP = (1 << 16),
836 /** GATT over Bluetooth LE.*/
837 CT_ADAPTER_GATT_BTLE = (1 << 17),
839 /** RFCOMM over Bluetooth EDR.*/
840 CT_ADAPTER_RFCOMM_BTEDR = (1 << 18),
843 /** Remote Access over XMPP.*/
844 CT_ADAPTER_REMOTE_ACCESS = (1 << 19),
847 CT_ADAPTER_TCP = (1 << 20),
850 CT_ADAPTER_NFC = (1 << 21),
852 /** Insecure transport is the default (subject to change).*/
854 /** secure the transport path.*/
855 CT_FLAG_SECURE = (1 << 4),
857 /** IPv4 & IPv6 autoselection is the default.*/
859 /** IP adapter only.*/
860 CT_IP_USE_V6 = (1 << 5),
862 /** IP adapter only.*/
863 CT_IP_USE_V4 = (1 << 6),
865 /** Link-Local multicast is the default multicast scope for IPv6.
866 * These are placed here to correspond to the IPv6 address bits.*/
868 /** IPv6 Interface-Local scope(loopback).*/
869 CT_SCOPE_INTERFACE = 0x1,
871 /** IPv6 Link-Local scope (default).*/
874 /** IPv6 Realm-Local scope.*/
875 CT_SCOPE_REALM = 0x3,
877 /** IPv6 Admin-Local scope.*/
878 CT_SCOPE_ADMIN = 0x4,
880 /** IPv6 Site-Local scope.*/
883 /** IPv6 Organization-Local scope.*/
886 /** IPv6 Global scope.*/
887 CT_SCOPE_GLOBAL = 0xE,
888 } OCConnectivityType;
890 /** bit shift required for connectivity adapter.*/
891 #define CT_ADAPTER_SHIFT 16
894 #define CT_MASK_FLAGS 0xFFFF
897 #define CT_MASK_ADAPTER 0xFFFF0000
900 * OCDoResource methods to dispatch the request
904 OC_REST_NOMETHOD = 0,
907 OC_REST_GET = (1 << 0),
910 OC_REST_PUT = (1 << 1),
913 OC_REST_POST = (1 << 2),
916 OC_REST_DELETE = (1 << 3),
918 /** Register observe request for most up date notifications ONLY.*/
919 OC_REST_OBSERVE = (1 << 4),
921 /** Register observe request for all notifications, including stale notifications.*/
922 OC_REST_OBSERVE_ALL = (1 << 5),
925 /** Subscribe for all presence notifications of a particular resource.*/
926 OC_REST_PRESENCE = (1 << 7),
929 /** Allows OCDoResource caller to do discovery.*/
930 OC_REST_DISCOVER = (1 << 8)
934 * Formats for payload encoding.
939 OC_FORMAT_VND_OCF_CBOR,
942 OC_FORMAT_UNSUPPORTED,
946 * Host Mode of Operation.
953 OC_GATEWAY /**< Client server mode along with routing capabilities.*/
957 * Quality of Service attempts to abstract the guarantees provided by the underlying transport
958 * protocol. The precise definitions of each quality of service level depend on the
959 * implementation. In descriptions below are for the current implementation and may changed
964 /** Packet delivery is best effort.*/
967 /** Packet delivery is best effort.*/
970 /** Acknowledgments are used to confirm delivery.*/
973 /** No Quality is defined, let the stack decide.*/
975 } OCQualityOfService;
978 * Resource Properties.
979 * The value of a policy property is defined as bitmap.
980 * The LSB represents OC_DISCOVERABLE and Second LSB bit represents OC_OBSERVABLE and so on.
981 * Not including the policy property is equivalent to zero.
986 /** When none of the bits are set, the resource is non-discoverable &
987 * non-observable by the client.*/
988 OC_RES_PROP_NONE = (0),
990 /** When this bit is set, the resource is allowed to be discovered by clients.*/
991 OC_DISCOVERABLE = (1 << 0),
993 /** When this bit is set, the resource is allowed to be observed by clients.*/
994 OC_OBSERVABLE = (1 << 1),
996 /** When this bit is set, the resource is initialized, otherwise the resource
997 * is 'inactive'. 'inactive' signifies that the resource has been marked for
998 * deletion or is already deleted.*/
999 OC_ACTIVE = (1 << 2),
1001 /** When this bit is set, the resource has been marked as 'slow'.
1002 * 'slow' signifies that responses from this resource can expect delays in
1003 * processing its requests from clients.*/
1006 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
1007 /** When this bit is set, the resource is a secure resource.*/
1008 OC_SECURE = (1 << 4),
1013 /** When this bit is set, the resource is allowed to be discovered only
1014 * if discovery request contains an explicit querystring.
1015 * Ex: GET /oic/res?rt=oic.sec.acl */
1016 OC_EXPLICIT_DISCOVERABLE = (1 << 5)
1019 /** When this bit is set, the resource is allowed to be published */
1021 // Since this property is not defined on OCF Spec. it should be set 0 until define it
1022 ,OC_MQ_PUBLISHER = (0)
1026 /** When this bit is set, the resource is allowed to be notified as MQ broker.*/
1028 // Since this property is not defined on OCF Spec. it should be set 0 until define it
1031 } OCResourceProperty;
1034 * Transport Protocol IDs.
1038 /** For invalid ID.*/
1039 OC_INVALID_ID = (1 << 0),
1042 OC_COAP_ID = (1 << 1)
1043 } OCTransportProtocolID;
1046 * Declares Stack Results & Errors.
1050 /** Success status code - START HERE.*/
1051 OC_STACK_OK = 0, /** 203, 205*/
1052 OC_STACK_RESOURCE_CREATED, /** 201*/
1053 OC_STACK_RESOURCE_DELETED, /** 202*/
1055 OC_STACK_RESOURCE_CHANGED, /** 204*/
1056 /** Success status code - END HERE.*/
1058 /** Error status code - START HERE.*/
1059 OC_STACK_INVALID_URI = 20,
1060 OC_STACK_INVALID_QUERY, /** 400*/
1061 OC_STACK_INVALID_IP,
1062 OC_STACK_INVALID_PORT,
1063 OC_STACK_INVALID_CALLBACK,
1064 OC_STACK_INVALID_METHOD,
1066 /** Invalid parameter.*/
1067 OC_STACK_INVALID_PARAM,
1068 OC_STACK_INVALID_OBSERVE_PARAM,
1070 OC_STACK_COMM_ERROR, /** 504*/
1072 OC_STACK_ADAPTER_NOT_ENABLED,
1075 /** Resource not found.*/
1076 OC_STACK_NO_RESOURCE, /** 404*/
1078 /** e.g: not supported method or interface.*/
1079 OC_STACK_RESOURCE_ERROR,
1080 OC_STACK_SLOW_RESOURCE,
1081 OC_STACK_DUPLICATE_REQUEST,
1083 /** Resource has no registered observers.*/
1084 OC_STACK_NO_OBSERVERS,
1085 OC_STACK_OBSERVER_NOT_FOUND,
1086 OC_STACK_VIRTUAL_DO_NOT_HANDLE,
1087 OC_STACK_INVALID_OPTION, /** 402*/
1089 /** The remote reply contained malformed data.*/
1090 OC_STACK_MALFORMED_RESPONSE,
1091 OC_STACK_PERSISTENT_BUFFER_REQUIRED,
1092 OC_STACK_INVALID_REQUEST_HANDLE,
1093 OC_STACK_INVALID_DEVICE_INFO,
1094 OC_STACK_INVALID_JSON,
1096 /** Request is not authorized by Resource Server. */
1097 OC_STACK_UNAUTHORIZED_REQ, /** 401*/
1098 OC_STACK_TOO_LARGE_REQ, /** 413*/
1100 /** Error code from PDM */
1101 OC_STACK_PDM_IS_NOT_INITIALIZED,
1102 OC_STACK_DUPLICATE_UUID,
1103 OC_STACK_INCONSISTENT_DB,
1106 * Error code from OTM
1107 * This error is pushed from DTLS interface when handshake failure happens
1109 OC_STACK_AUTHENTICATION_FAILURE,
1110 OC_STACK_NOT_ALLOWED_OXM,
1112 /** Request come from endpoint which is not mapped to the resource. */
1113 OC_STACK_BAD_ENDPOINT,
1115 /** Insert all new error codes here!.*/
1116 #ifdef WITH_PRESENCE
1117 OC_STACK_PRESENCE_STOPPED = 128,
1118 OC_STACK_PRESENCE_TIMEOUT,
1119 OC_STACK_PRESENCE_DO_NOT_HANDLE,
1122 /** Request is denied by the user*/
1123 OC_STACK_USER_DENIED_REQ,
1124 OC_STACK_NOT_ACCEPTABLE,
1126 /** ERROR code from server */
1127 OC_STACK_FORBIDDEN_REQ, /** 403*/
1128 OC_STACK_INTERNAL_SERVER_ERROR, /** 500*/
1130 /** ERROR in stack.*/
1131 OC_STACK_ERROR = 255
1132 /** Error status code - END HERE.*/
1136 * Handle to an OCDoResource invocation.
1138 typedef void * OCDoHandle;
1141 * Handle to an OCResource object owned by the OCStack.
1143 typedef void * OCResourceHandle;
1146 * Handle to an OCRequest object owned by the OCStack.
1148 typedef void * OCRequestHandle;
1151 * Unique identifier for each observation request. Used when observations are
1152 * registered or de-registered. Used by entity handler to signal specific
1153 * observers to be notified of resource changes.
1154 * There can be maximum of 256 observations per server.
1156 typedef uint8_t OCObservationId;
1159 * Sequence number is a 24 bit field,
1160 * per https://tools.ietf.org/html/rfc7641.
1162 #define MAX_SEQUENCE_NUMBER (0xFFFFFF)
1165 * Action associated with observation.
1170 OC_OBSERVE_REGISTER = 0,
1172 /** To Deregister. */
1173 OC_OBSERVE_DEREGISTER = 1,
1176 OC_OBSERVE_NO_OPTION = 2,
1182 * Persistent storage handlers. An APP must provide OCPersistentStorage handler pointers
1183 * when it calls OCRegisterPersistentStorageHandler.
1184 * Persistent storage open handler points to default file path.
1185 * It should check file path and whether the file is symbolic link or no.
1186 * Application can point to appropriate SVR database path for it's IoTivity Server.
1189 /** Persistent storage file path.*/
1190 FILE* (* open)(const char *path, const char *mode);
1192 /** Persistent storage read handler.*/
1193 size_t (* read)(void *ptr, size_t size, size_t nmemb, FILE *stream);
1195 /** Persistent storage write handler.*/
1196 size_t (* write)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
1198 /** Persistent storage close handler.*/
1199 int (* close)(FILE *fp);
1201 /** Persistent storage unlink handler.*/
1202 int (* unlink)(const char *path);
1203 } OCPersistentStorage;
1206 * Possible returned values from entity handler.
1210 /** Action associated with observation request.*/
1211 OCObserveAction action;
1213 /** Identifier for observation being registered/deregistered.*/
1214 OCObservationId obsId;
1215 } OCObservationInfo;
1218 * Possible returned values from entity handler.
1225 OC_EH_RESOURCE_CREATED = 201,
1226 OC_EH_RESOURCE_DELETED = 202,
1228 OC_EH_CHANGED = 204,
1229 OC_EH_CONTENT = 205,
1230 OC_EH_BAD_REQ = 400,
1231 OC_EH_UNAUTHORIZED_REQ = 401,
1232 OC_EH_BAD_OPT = 402,
1233 OC_EH_FORBIDDEN = 403,
1234 OC_EH_RESOURCE_NOT_FOUND = 404,
1235 OC_EH_METHOD_NOT_ALLOWED = 405,
1236 OC_EH_NOT_ACCEPTABLE = 406,
1237 OC_EH_TOO_LARGE = 413,
1238 OC_EH_UNSUPPORTED_MEDIA_TYPE = 415,
1239 OC_EH_INTERNAL_SERVER_ERROR = 500,
1240 OC_EH_BAD_GATEWAY = 502,
1241 OC_EH_SERVICE_UNAVAILABLE = 503,
1242 OC_EH_RETRANSMIT_TIMEOUT = 504
1243 } OCEntityHandlerResult;
1246 * This structure will be used to define the vendor specific header options to be included
1247 * in communication packets.
1249 typedef struct OCHeaderOption
1251 /** The protocol ID this option applies to.*/
1252 OCTransportProtocolID protocolID;
1254 /** The header option ID which will be added to communication packets.*/
1257 /** its length 191.*/
1258 uint16_t optionLength;
1260 /** pointer to its data.*/
1261 uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
1263 #ifdef SUPPORTS_DEFAULT_CTOR
1264 OCHeaderOption() = default;
1265 OCHeaderOption(OCTransportProtocolID pid,
1268 const uint8_t* optData)
1271 optionLength(optlen)
1274 // parameter includes the null terminator.
1275 optionLength = optionLength < MAX_HEADER_OPTION_DATA_LENGTH ?
1276 optionLength : MAX_HEADER_OPTION_DATA_LENGTH;
1277 memcpy(optionData, optData, optionLength);
1278 optionData[optionLength - 1] = '\0';
1284 * This structure describes the platform properties. All non-Null properties will be
1285 * included in a platform discovery request.
1286 * @deprecated: Use OCSetPropertyValue to set platform value.
1293 /** Manufacturer name.*/
1294 char *manufacturerName;
1296 /** Manufacturer URL for platform property.*/
1297 char *manufacturerUrl;
1302 /** Manufacturer date.*/
1303 char *dateOfManufacture;
1305 /** Platform version.*/
1306 char *platformVersion;
1308 /** Operating system version.*/
1309 char *operatingSystemVersion;
1312 char *hardwareVersion;
1315 char *firmwareVersion;
1317 /** Platform support URL.*/
1326 * This structure is expected as input for device properties.
1327 * device name is mandatory and expected from the application.
1328 * device id of type UUID will be generated by the stack.
1329 * @deprecated: Use OCSetPropertyValue to set device value.
1333 /** Pointer to the device name.*/
1335 /** Pointer to the types.*/
1337 /** Pointer to the device specification version.*/
1339 /** Pointer to the device data model versions (in CSV format).*/
1340 OCStringLL *dataModelVersions;
1344 * This enum type for indicate Transport Protocol Suites
1348 /** For initialize */
1355 OC_COAPS = (1 << 1),
1359 OC_COAP_TCP = (1 << 2),
1362 OC_COAPS_TCP = (1 << 3),
1369 OC_HTTPS = (1 << 5),
1372 /** coap + rfcomm */
1373 OC_COAP_RFCOMM = (1 << 6),
1377 OC_COAP_GATT = (1 << 7),
1381 OC_COAP_NFC = (1 << 8),
1384 /** coap + remote_access */
1385 OC_COAP_RA = (1 << 9),
1387 /** Allow all endpoint.*/
1393 * callback for bound JID
1395 typedef void (*jid_bound_cb)(char *jid);
1398 * CA Remote Access information for XMPP Client
1403 char *hostname; /**< XMPP server hostname */
1404 uint16_t port; /**< XMPP server serivce port */
1405 char *xmpp_domain; /**< XMPP login domain */
1406 char *username; /**< login username */
1407 char *password; /**< login password */
1408 char *resource; /**< specific resource for login */
1409 char *user_jid; /**< specific JID for login */
1410 jid_bound_cb jidbound; /**< callback when JID bound */
1412 #endif /* RA_ADAPTER */
1415 /** Enum to describe the type of object held by the OCPayload object.*/
1418 /** Contents of the payload are invalid */
1419 PAYLOAD_TYPE_INVALID,
1420 /** The payload is an OCDiscoveryPayload */
1421 PAYLOAD_TYPE_DISCOVERY,
1422 /** The payload of the device */
1423 PAYLOAD_TYPE_DEVICE,
1424 /** The payload type of the platform */
1425 PAYLOAD_TYPE_PLATFORM,
1426 /** The payload is an OCRepPayload */
1427 PAYLOAD_TYPE_REPRESENTATION,
1428 /** The payload is an OCSecurityPayload */
1429 PAYLOAD_TYPE_SECURITY,
1430 /** The payload is an OCPresencePayload */
1431 PAYLOAD_TYPE_PRESENCE
1435 * A generic struct representing a payload returned from a resource operation
1437 * A pointer to OCPayLoad can be cast to a more specific struct to access members
1442 /** The type of message that was received */
1453 OCREP_PROP_BYTE_STRING,
1456 }OCRepPayloadPropType;
1458 /** This structure will be used to represent a binary string for CBOR payloads.*/
1461 /** pointer to data bytes.*/
1464 /** number of data bytes.*/
1468 #define MAX_REP_ARRAY_DEPTH 3
1471 OCRepPayloadPropType type;
1472 size_t dimensions[MAX_REP_ARRAY_DEPTH];
1481 /** pointer to ByteString array.*/
1482 OCByteString* ocByteStrArray;
1484 struct OCRepPayload** objArray;
1486 } OCRepPayloadValueArray;
1488 typedef struct OCRepPayloadValue
1491 OCRepPayloadPropType type;
1499 /** ByteString object.*/
1500 OCByteString ocByteStr;
1502 struct OCRepPayload* obj;
1503 OCRepPayloadValueArray arr;
1505 struct OCRepPayloadValue* next;
1507 } OCRepPayloadValue;
1509 // used for get/set/put/observe/etc representations
1510 typedef struct OCRepPayload
1515 OCStringLL* interfaces;
1516 OCRepPayloadValue* values;
1517 struct OCRepPayload* next;
1520 // used inside a resource payload
1521 typedef struct OCEndpointPayload
1525 OCTransportFlags family;
1528 struct OCEndpointPayload* next;
1529 } OCEndpointPayload;
1531 // used inside a discovery payload
1532 typedef struct OCResourcePayload
1537 OCStringLL* interfaces;
1544 struct OCResourcePayload* next;
1545 OCEndpointPayload* eps;
1546 } OCResourcePayload;
1548 typedef struct OCDiscoveryPayload
1555 /** A special case for handling RD address. */
1561 /** Resource Type */
1567 /** This structure holds the old /oic/res response. */
1568 OCResourcePayload *resources;
1570 /** Holding address of the next DiscoveryPayload. */
1571 struct OCDiscoveryPayload *next;
1573 } OCDiscoveryPayload;
1578 uint8_t* securityData;
1580 } OCSecurityPayload;
1582 #ifdef WITH_PRESENCE
1586 uint32_t sequenceNumber;
1588 OCPresenceTrigger trigger;
1590 } OCPresencePayload;
1594 * Incoming requests handled by the server. Requests are passed in as a parameter to the
1595 * OCEntityHandler callback API.
1596 * The OCEntityHandler callback API must be implemented in the application in order
1597 * to receive these requests.
1601 /** Associated resource.*/
1602 OCResourceHandle resource;
1604 /** Associated request handle.*/
1605 OCRequestHandle requestHandle;
1607 /** the REST method retrieved from received request PDU.*/
1610 /** description of endpoint that sent the request.*/
1613 /** resource query send by client.*/
1616 /** Information associated with observation - valid only when OCEntityHandler flag includes
1617 * ::OC_OBSERVE_FLAG.*/
1618 OCObservationInfo obsInfo;
1620 /** Number of the received vendor specific header options.*/
1621 uint8_t numRcvdVendorSpecificHeaderOptions;
1623 /** Pointer to the array of the received vendor specific header options.*/
1624 OCHeaderOption * rcvdVendorSpecificHeaderOptions;
1629 /** the payload from the request PDU.*/
1632 } OCEntityHandlerRequest;
1636 * Response from queries to remote servers. Queries are made by calling the OCDoResource API.
1640 /** Address of remote server.*/
1643 /** backward compatibility (points to devAddr).*/
1646 /** backward compatibility.*/
1647 OCConnectivityType connType;
1649 /** the security identity of the remote server.*/
1650 OCIdentity identity;
1652 /** the is the result of our stack, OCStackResult should contain coap/other error codes.*/
1653 OCStackResult result;
1655 /** If associated with observe, this will represent the sequence of notifications from server.*/
1656 uint32_t sequenceNumber;
1659 const char * resourceUri;
1661 /** the payload for the response PDU.*/
1664 /** Number of the received vendor specific header options.*/
1665 uint8_t numRcvdVendorSpecificHeaderOptions;
1667 /** An array of the received vendor specific header options.*/
1668 OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
1672 * Request handle is passed to server via the entity handler for each incoming request.
1673 * Stack assigns when request is received, server sets to indicate what request response is for.
1677 /** Request handle.*/
1678 OCRequestHandle requestHandle;
1680 /** Resource handle.*/
1681 OCResourceHandle resourceHandle;
1683 /** Allow the entity handler to pass a result with the response.*/
1684 OCEntityHandlerResult ehResult;
1686 /** This is the pointer to server payload data to be transferred.*/
1689 /** number of the vendor specific header options .*/
1690 uint8_t numSendVendorSpecificHeaderOptions;
1692 /** An array of the vendor specific header options the entity handler wishes to use in response.*/
1693 OCHeaderOption sendVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
1695 /** URI of new resource that entity handler might create.*/
1696 char resourceUri[MAX_URI_LENGTH];
1698 /** Server sets to true for persistent response buffer,false for non-persistent response buffer*/
1699 uint8_t persistentBufferFlag;
1700 } OCEntityHandlerResponse;
1707 /** Request state.*/
1708 OC_REQUEST_FLAG = (1 << 1),
1709 /** Observe state.*/
1710 OC_OBSERVE_FLAG = (1 << 2)
1711 } OCEntityHandlerFlag;
1714 * Possible return values from client application callback
1716 * A client application callback returns an OCStackApplicationResult to indicate whether
1717 * the stack should continue to keep the callback registered.
1721 /** Make no more calls to the callback and call the OCClientContextDeleter for this callback */
1722 OC_STACK_DELETE_TRANSACTION = 0,
1723 /** Keep this callback registered and call it if an apropriate event occurs */
1724 OC_STACK_KEEP_TRANSACTION
1725 } OCStackApplicationResult;
1728 //#ifdef DIRECT_PAIRING
1730 * @brief direct pairing Method Type.
1732 * 1: pre-configured pin
1737 DP_NOT_ALLOWED = 0x0,
1738 DP_PRE_CONFIGURED = (0x1 << 0),
1739 DP_RANDOM_PIN = (0x1 << 1),
1743 * Device Information of discoverd direct pairing device(s).
1745 typedef struct OCDPDev
1748 OCConnectivityType connType;
1749 uint16_t securePort;
1753 OCUUIdentity deviceID;
1754 OCUUIdentity rowner;
1755 struct OCDPDev *next;
1757 //#endif // DIRECT_PAIRING
1760 * -------------------------------------------------------------------------------------------
1761 * Callback function definitions
1762 * -------------------------------------------------------------------------------------------
1766 * Client applications implement this callback to consume responses received from Servers.
1768 typedef OCStackApplicationResult (* OCClientResponseHandler)(void *context, OCDoHandle handle,
1769 OCClientResponse * clientResponse);
1772 * Client applications using a context pointer implement this callback to delete the
1773 * context upon removal of the callback/context pointer from the internal callback-list.
1775 typedef void (* OCClientContextDeleter)(void *context);
1778 * This info is passed from application to OC Stack when initiating a request to Server.
1780 typedef struct OCCallbackData
1782 /** Pointer to the context.*/
1785 /** The pointer to a function the stack will call to handle the requests.*/
1786 OCClientResponseHandler cb;
1788 /** A pointer to a function to delete the context when this callback is removed.*/
1789 OCClientContextDeleter cd;
1791 #ifdef SUPPORTS_DEFAULT_CTOR
1792 OCCallbackData() = default;
1793 OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter)
1794 :context(ctx), cb(callback), cd(deleter){}
1799 * Application server implementations must implement this callback to consume requests OTA.
1800 * Entity handler callback needs to fill the resPayload of the entityHandlerRequest.
1802 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
1803 * OC_EH_SLOW and etc in entity handler callback,
1804 * ocstack will be not send response automatically to client
1805 * except for error return value like OC_EH_ERROR.
1807 * If you want to send response to client with specific result,
1808 * OCDoResponse API should be called with the result value.
1812 * OCEntityHandlerResponse response;
1816 * response.ehResult = OC_EH_CHANGED;
1820 * OCDoResponse(&response)
1826 typedef OCEntityHandlerResult (*OCEntityHandler)
1827 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void* callbackParam);
1830 * Device Entity handler need to use this call back instead of OCEntityHandler.
1832 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
1833 * OC_EH_SLOW and etc in entity handler callback,
1834 * ocstack will be not send response automatically to client
1835 * except for error return value like OC_EH_ERROR.
1837 * If you want to send response to client with specific result,
1838 * OCDoResponse API should be called with the result value.
1842 * OCEntityHandlerResponse response;
1846 * response.ehResult = OC_EH_CHANGED;
1850 * OCDoResponse(&response)
1856 typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
1857 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri, void* callbackParam);
1859 //#ifdef DIRECT_PAIRING
1861 * Callback function definition of direct-pairing
1863 * @param[OUT] ctx - user context returned in the callback.
1864 * @param[OUT] peer - pairing device info.
1865 * @param[OUT] result - It's returned with 'OC_STACK_XXX'. It will return 'OC_STACK_OK'
1866 * if D2D pairing is success without error
1868 typedef void (*OCDirectPairingCB)(void *ctx, OCDPDev_t *peer, OCStackResult result);
1869 //#endif // DIRECT_PAIRING
1870 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
1872 * Callback function definition for Change in TrustCertChain
1874 * @param[IN] ctx - user context returned in the callback.
1875 * @param[IN] credId - trustCertChain changed for this ID
1876 * @param[IN] trustCertChain - trustcertchain binary blob.
1877 * @param[IN] chainSize - size of trustchain
1879 typedef void (*TrustCertChainChangeCB)(void *ctx, uint16_t credId, uint8_t *trustCertChain,
1883 * certChain context structure.
1885 typedef struct trustCertChainContext
1887 TrustCertChainChangeCB callback;
1889 } trustCertChainContext_t;
1892 #if defined(TCP_ADAPTER) && defined(WITH_CLOUD)
1894 * User Preference of connectivity channel
1899 OC_USER_PREF_CLOUD = 0,
1901 OC_USER_PREF_LOCAL_UDP = 1,
1903 OC_USER_PREF_LOCAL_TCP =2
1904 } OCConnectUserPref_t;
1910 #endif // __cplusplus
1912 #endif /* OCTYPES_H_ */