a71e5c5756403c9bd04a065fbd70c6f472be8b4f
[platform/upstream/iotivity.git] / resource / csdk / stack / include / octypes.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //******************************************************************
20
21
22 /**
23  * @file
24  *
25  * This file contains the definition, types and APIs for resource(s) be implemented.
26  */
27
28 #ifndef OCTYPES_H_
29 #define OCTYPES_H_
30
31 #include "platform_features.h"
32 #include "ocstackconfig.h"
33 #include <stdbool.h>
34 #include <stdint.h>
35 #include <stdio.h>
36 #ifdef __cplusplus
37 #include <string.h>
38
39 extern "C" {
40 #endif // __cplusplus
41
42 /** For the feature presence.*/
43 #define WITH_PRESENCE
44
45 #include "ocpresence.h"
46 //-----------------------------------------------------------------------------
47 // Defines
48 //-----------------------------------------------------------------------------
49
50 /**
51  * OIC Virtual resources supported by every OIC device.
52  */
53 /**
54  *  Default discovery mechanism using '/oic/res' is supported by all OIC devices
55  *  That are Discoverable.
56  */
57 #define OC_RSRVD_WELL_KNOWN_URI               "/oic/res"
58
59 /** Device URI.*/
60 #define OC_RSRVD_DEVICE_URI                   "/oic/d"
61
62 /** Platform URI.*/
63 #define OC_RSRVD_PLATFORM_URI                 "/oic/p"
64
65 /** Resource Type.*/
66 #define OC_RSRVD_RESOURCE_TYPES_URI           "/oic/res/types/d"
67 #if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
68 /** Gateway URI.*/
69 #define OC_RSRVD_GATEWAY_URI                  "/oic/gateway"
70 #endif
71 #ifdef WITH_PRESENCE
72
73 /** Presence URI through which the OIC devices advertise their presence.*/
74 #define OC_RSRVD_PRESENCE_URI                 "/oic/ad"
75
76 /** Sets the default time to live (TTL) for presence.*/
77 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
78
79 /** For multicast Discovery mechanism.*/
80 #define OC_MULTICAST_DISCOVERY_URI           "/oic/res"
81
82 /** Separator for multiple query string.*/
83 #define OC_QUERY_SEPARATOR                "&;"
84
85 /**
86  *  OC_DEFAULT_PRESENCE_TTL_SECONDS sets the default time to live (TTL) for presence.
87  */
88 #define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
89
90 /**
91  *  OC_MAX_PRESENCE_TTL_SECONDS sets the maximum time to live (TTL) for presence.
92  *  NOTE: Changing the setting to a longer duration may lead to unsupported and untested
93  *  operation.
94  *  60 sec/min * 60 min/hr * 24 hr/day
95  */
96 #define OC_MAX_PRESENCE_TTL_SECONDS     (60 * 60 * 24)
97 #endif
98
99 /**
100  *  Presence "Announcement Triggers".
101  */
102
103 /** To create.*/
104 #define OC_RSRVD_TRIGGER_CREATE         "create"
105
106 /** To change.*/
107 #define OC_RSRVD_TRIGGER_CHANGE         "change"
108
109 /** To delete.*/
110 #define OC_RSRVD_TRIGGER_DELETE         "delete"
111
112 /**
113  *  Attributes used to form a proper OIC conforming JSON message.
114  */
115
116 #define OC_RSRVD_OC                     "oic"
117
118 /** For payload. */
119
120 #define OC_RSRVD_PAYLOAD                "payload"
121
122 /** To represent href */
123 #define OC_RSRVD_HREF                   "href"
124
125 /** To represent property*/
126 #define OC_RSRVD_PROPERTY               "prop"
127
128 /** For representation.*/
129 #define OC_RSRVD_REPRESENTATION         "rep"
130
131 /** To represent content type.*/
132 #define OC_RSRVD_CONTENT_TYPE           "ct"
133
134 /** To represent resource type.*/
135 #define OC_RSRVD_RESOURCE_TYPE          "rt"
136
137 /** To represent resource type with presence.*/
138 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad"
139
140 /** To represent resource type with device.*/
141 #define OC_RSRVD_RESOURCE_TYPE_DEVICE   "oic.wk.d"
142
143 /** To represent resource type with platform.*/
144 #define OC_RSRVD_RESOURCE_TYPE_PLATFORM "oic.wk.p"
145
146 /** To represent resource type with RES.*/
147 #define OC_RSRVD_RESOURCE_TYPE_RES    "oic.wk.res"
148
149 /** To represent interface.*/
150 #define OC_RSRVD_INTERFACE              "if"
151
152 /** To represent time to live.*/
153 #define OC_RSRVD_TTL                    "ttl"
154
155 /** To represent non*/
156 #define OC_RSRVD_NONCE                  "non"
157
158 /** To represent trigger type.*/
159 #define OC_RSRVD_TRIGGER                "trg"
160
161 /** To represent links.*/
162 #define OC_RSRVD_LINKS                  "links"
163
164 /** To represent default interface.*/
165 #define OC_RSRVD_INTERFACE_DEFAULT      "oic.if.baseline"
166
167 /** To represent read-only interface.*/
168 #define OC_RSRVD_INTERFACE_READ         "oic.if.r"
169
170 /** To represent ll interface.*/
171 #define OC_RSRVD_INTERFACE_LL           "oic.if.ll"
172
173 /** To represent batch interface.*/
174 #define OC_RSRVD_INTERFACE_BATCH        "oic.if.b"
175
176 /** To represent interface group.*/
177 #define OC_RSRVD_INTERFACE_GROUP        "oic.mi.grp"
178
179 /** To represent MFG date.*/
180 #define OC_RSRVD_MFG_DATE               "mndt"
181
182 /** To represent FW version.*/
183 #define OC_RSRVD_FW_VERSION             "mnfv"
184
185 /** To represent host name.*/
186 #define OC_RSRVD_HOST_NAME              "hn"
187
188 /** To represent policy.*/
189 #define OC_RSRVD_POLICY                 "p"
190
191 /** To represent bitmap.*/
192 #define OC_RSRVD_BITMAP                 "bm"
193
194 /** For security.*/
195 #define OC_RSRVD_SECURE                 "sec"
196
197 /** Port. */
198 #define OC_RSRVD_HOSTING_PORT           "port"
199
200 /** TCP Port. */
201 #define OC_RSRVD_TCP_PORT               "x.org.iotivity.tcp"
202
203 /** For Server instance ID.*/
204 #define OC_RSRVD_SERVER_INSTANCE_ID     "sid"
205
206 /**
207  *  Platform.
208  */
209
210 /** Platform ID. */
211 #define OC_RSRVD_PLATFORM_ID            "pi"
212
213 /** Platform MFG NAME. */
214 #define OC_RSRVD_MFG_NAME               "mnmn"
215
216 /** Platform URL. */
217 #define OC_RSRVD_MFG_URL                "mnml"
218
219 /** Model Number.*/
220 #define OC_RSRVD_MODEL_NUM              "mnmo"
221
222 /** Platform MFG Date.*/
223 #define OC_RSRVD_MFG_DATE               "mndt"
224
225 /** Platform versio.n */
226 #define OC_RSRVD_PLATFORM_VERSION       "mnpv"
227
228 /** Platform Operating system version. */
229 #define OC_RSRVD_OS_VERSION             "mnos"
230
231 /** Platform Hardware version. */
232 #define OC_RSRVD_HARDWARE_VERSION       "mnhw"
233
234 /**Platform Firmware version. */
235 #define OC_RSRVD_FIRMWARE_VERSION       "mnfv"
236
237 /** Support URL for the platform. */
238 #define OC_RSRVD_SUPPORT_URL            "mnsl"
239
240 /** System time for the platform. */
241 #define OC_RSRVD_SYSTEM_TIME             "st"
242
243 /**
244  *  Device.
245  */
246
247 /** Device ID.*/
248 #define OC_RSRVD_DEVICE_ID              "di"
249
250 /** Device Name.*/
251 #define OC_RSRVD_DEVICE_NAME            "n"
252
253 /** Device specification version.*/
254 #define OC_RSRVD_SPEC_VERSION           "icv"
255
256 /** Device data model.*/
257 #define OC_RSRVD_DATA_MODEL_VERSION     "dmv"
258
259 /** Device specification version.*/
260 #define OC_SPEC_VERSION                "core.1.0.0"
261
262 /** Device Data Model version.*/
263 #define OC_DATA_MODEL_VERSION          "res.1.0.0"
264
265 /**
266  *  These provide backward compatibility - their use is deprecated.
267  */
268 #ifndef GOING_AWAY
269
270 /** Multicast Prefix.*/
271 #define OC_MULTICAST_PREFIX                  "224.0.1.187:5683"
272
273 /** Multicast IP address.*/
274 #define OC_MULTICAST_IP                      "224.0.1.187"
275
276 /** Multicast Port.*/
277 #define OC_MULTICAST_PORT                    5683
278 #endif // GOING_AWAY
279
280 /** Max Device address size. */
281 #ifdef RA_ADAPTER
282 #define MAX_ADDR_STR_SIZE (256)
283 #else
284 /** Max Address could be "coap+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:xxxxx" */
285 #define MAX_ADDR_STR_SIZE (59)
286 #endif
287
288 /** Length of MAC address */
289 #define MAC_ADDR_STR_SIZE (17)
290
291 /** Blocks of MAC address */
292 #define MAC_ADDR_BLOCKS (6)
293
294 /** Max identity size. */
295 #define MAX_IDENTITY_SIZE (32)
296
297 /** Universal unique identity size. */
298 #define UUID_IDENTITY_SIZE (128/8)
299
300 /** Resource Directory */
301
302 /** Resource Directory URI used to Discover RD and Publish resources.*/
303 #define OC_RSRVD_RD_URI                  "/oic/rd"
304
305 /** To represent resource type with rd.*/
306 #define OC_RSRVD_RESOURCE_TYPE_RD        "oic.wk.rd"
307
308 /** RD Discovery bias factor type. */
309 #define OC_RSRVD_RD_DISCOVERY_SEL        "sel"
310
311 /** Base URI. */
312 #define OC_RSRVD_BASE_URI                "baseURI"
313
314 /** Unique value per collection/link. */
315 #define OC_RSRVD_INS                     "ins"
316
317 /** Allowable resource types in the links. */
318 #define OC_RSRVD_RTS                     "rts"
319
320 /** Default relationship. */
321 #define OC_RSRVD_DREL                    "drel"
322
323 /** Defines relationship between links. */
324 #define OC_RSRVD_REL                     "rel"
325
326 /** Defines title. */
327 #define OC_RSRVD_TITLE                   "title"
328
329 /** Defines URI. */
330 #define OC_RSRVD_URI                     "uri"
331
332 /** Defines media type. */
333 #define OC_RSRVD_MEDIA_TYPE              "mt"
334
335 /** To represent resource type with Publish RD.*/
336 #define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdpub"
337
338 /**
339  * These enums (OCTransportAdapter and OCTransportFlags) must
340  * be kept synchronized with OCConnectivityType (below) as well as
341  * CATransportAdapter and CATransportFlags (in CACommon.h).
342  */
343 typedef enum
344 {
345     /** value zero indicates discovery.*/
346     OC_DEFAULT_ADAPTER = 0,
347
348     /** IPv4 and IPv6, including 6LoWPAN.*/
349     OC_ADAPTER_IP           = (1 << 0),
350
351     /** GATT over Bluetooth LE.*/
352     OC_ADAPTER_GATT_BTLE    = (1 << 1),
353
354     /** RFCOMM over Bluetooth EDR.*/
355     OC_ADAPTER_RFCOMM_BTEDR = (1 << 2),
356 #ifdef RA_ADAPTER
357     /**Remote Access over XMPP.*/
358     OC_ADAPTER_REMOTE_ACCESS = (1 << 3),
359 #endif
360     /** CoAP over TCP.*/
361     OC_ADAPTER_TCP           = (1 << 4),
362
363     /** NFC Transport for Messaging.*/
364     OC_ADAPTER_NFC           = (1 << 5)
365 } OCTransportAdapter;
366
367 /**
368  *  Enum layout assumes some targets have 16-bit integer (e.g., Arduino).
369  */
370 typedef enum
371 {
372     /** default flag is 0*/
373     OC_DEFAULT_FLAGS = 0,
374
375     /** Insecure transport is the default (subject to change).*/
376     /** secure the transport path*/
377     OC_FLAG_SECURE     = (1 << 4),
378
379     /** IPv4 & IPv6 auto-selection is the default.*/
380     /** IP & TCP adapter only.*/
381     OC_IP_USE_V6       = (1 << 5),
382
383     /** IP & TCP adapter only.*/
384     OC_IP_USE_V4       = (1 << 6),
385
386     /** Multicast only.*/
387     OC_MULTICAST       = (1 << 7),
388
389     /** Link-Local multicast is the default multicast scope for IPv6.
390      *  These are placed here to correspond to the IPv6 multicast address bits.*/
391
392     /** IPv6 Interface-Local scope (loopback).*/
393     OC_SCOPE_INTERFACE = 0x1,
394
395     /** IPv6 Link-Local scope (default).*/
396     OC_SCOPE_LINK      = 0x2,
397
398     /** IPv6 Realm-Local scope. */
399     OC_SCOPE_REALM     = 0x3,
400
401     /** IPv6 Admin-Local scope. */
402     OC_SCOPE_ADMIN     = 0x4,
403
404     /** IPv6 Site-Local scope. */
405     OC_SCOPE_SITE      = 0x5,
406
407     /** IPv6 Organization-Local scope. */
408     OC_SCOPE_ORG       = 0x8,
409
410     /**IPv6 Global scope. */
411     OC_SCOPE_GLOBAL    = 0xE,
412
413 } OCTransportFlags;
414
415 /** Bit mask for scope.*/
416 #define OC_MASK_SCOPE    (0x000F)
417
418 /** Bit mask for Mods.*/
419 #define OC_MASK_MODS     (0x0FF0)
420 #define OC_MASK_FAMS     (OC_IP_USE_V6|OC_IP_USE_V4)
421
422 typedef struct OCStringLL
423 {
424     struct OCStringLL *next;
425     char* value;
426 } OCStringLL;
427
428 /**
429  * End point identity.
430  */
431 typedef struct
432 {
433     /** Identity Length */
434     uint16_t id_length;
435
436     /** Array of end point identity.*/
437     unsigned char id[MAX_IDENTITY_SIZE];
438 } OCIdentity;
439
440 /**
441  * Universally unique identifier.
442  */
443 typedef struct
444 {
445     /** identitifier string.*/
446     unsigned char id[UUID_IDENTITY_SIZE];
447 } OCUUIdentity;
448
449 /**
450  * Data structure to encapsulate IPv4/IPv6/Contiki/lwIP device addresses.
451  * OCDevAddr must be the same as CAEndpoint (in CACommon.h).
452  */
453 typedef struct
454 {
455     /** adapter type.*/
456     OCTransportAdapter      adapter;
457
458     /** transport modifiers.*/
459     OCTransportFlags        flags;
460
461     /** for IP.*/
462     uint16_t                port;
463
464     /** address for all adapters.*/
465     char                    addr[MAX_ADDR_STR_SIZE];
466
467     /** usually zero for default interface.*/
468     uint32_t                interface;
469 #if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
470     char                    routeData[MAX_ADDR_STR_SIZE]; //destination GatewayID:ClientId
471 #endif
472 } OCDevAddr;
473
474 /**
475  * This enum type includes elements of both ::OCTransportAdapter and ::OCTransportFlags.
476  * It is defined conditionally because the smaller definition limits expandability on 32/64 bit
477  * integer machines, and the larger definition won't fit into an enum on 16-bit integer machines
478  * like Arduino.
479  *
480  * This structure must directly correspond to ::OCTransportAdapter and ::OCTransportFlags.
481  */
482 typedef enum
483 {
484     /** use when defaults are ok. */
485     CT_DEFAULT = 0,
486
487     /** IPv4 and IPv6, including 6LoWPAN.*/
488     CT_ADAPTER_IP           = (1 << 16),
489
490     /** GATT over Bluetooth LE.*/
491     CT_ADAPTER_GATT_BTLE    = (1 << 17),
492
493     /** RFCOMM over Bluetooth EDR.*/
494     CT_ADAPTER_RFCOMM_BTEDR = (1 << 18),
495
496 #ifdef RA_ADAPTER
497     /** Remote Access over XMPP.*/
498     CT_ADAPTER_REMOTE_ACCESS = (1 << 19),
499 #endif
500     /** CoAP over TCP.*/
501     CT_ADAPTER_TCP     = (1 << 20),
502
503     /** NFC Transport.*/
504     CT_ADAPTER_NFC     = (1 << 21),
505
506     /** Insecure transport is the default (subject to change).*/
507
508     /** secure the transport path.*/
509     CT_FLAG_SECURE     = (1 << 4),
510
511     /** IPv4 & IPv6 autoselection is the default.*/
512
513     /** IP adapter only.*/
514     CT_IP_USE_V6       = (1 << 5),
515
516     /** IP adapter only.*/
517     CT_IP_USE_V4       = (1 << 6),
518
519     /** Link-Local multicast is the default multicast scope for IPv6.
520      * These are placed here to correspond to the IPv6 address bits.*/
521
522     /** IPv6 Interface-Local scope(loopback).*/
523     CT_SCOPE_INTERFACE = 0x1,
524
525     /** IPv6 Link-Local scope (default).*/
526     CT_SCOPE_LINK      = 0x2,
527
528     /** IPv6 Realm-Local scope.*/
529     CT_SCOPE_REALM     = 0x3,
530
531     /** IPv6 Admin-Local scope.*/
532     CT_SCOPE_ADMIN     = 0x4,
533
534     /** IPv6 Site-Local scope.*/
535     CT_SCOPE_SITE      = 0x5,
536
537     /** IPv6 Organization-Local scope.*/
538     CT_SCOPE_ORG       = 0x8,
539
540     /** IPv6 Global scope.*/
541     CT_SCOPE_GLOBAL    = 0xE,
542 } OCConnectivityType;
543
544 /** bit shift required for connectivity adapter.*/
545 #define CT_ADAPTER_SHIFT 16
546
547 /** Mask Flag.*/
548 #define CT_MASK_FLAGS 0xFFFF
549
550 /** Mask Adapter.*/
551 #define CT_MASK_ADAPTER 0xFFFF0000
552
553 /**
554  *  OCDoResource methods to dispatch the request
555  */
556 typedef enum
557 {
558     OC_REST_NOMETHOD       = 0,
559
560     /** Read.*/
561     OC_REST_GET            = (1 << 0),
562
563     /** Write.*/
564     OC_REST_PUT            = (1 << 1),
565
566     /** Update.*/
567     OC_REST_POST           = (1 << 2),
568
569     /** Delete.*/
570     OC_REST_DELETE         = (1 << 3),
571
572     /** Register observe request for most up date notifications ONLY.*/
573     OC_REST_OBSERVE        = (1 << 4),
574
575     /** Register observe request for all notifications, including stale notifications.*/
576     OC_REST_OBSERVE_ALL    = (1 << 5),
577
578     /** De-register observation, intended for internal use.*/
579     OC_REST_CANCEL_OBSERVE = (1 << 6),
580
581 #ifdef WITH_PRESENCE
582     /** Subscribe for all presence notifications of a particular resource.*/
583     OC_REST_PRESENCE       = (1 << 7),
584
585 #endif
586     /** Allows OCDoResource caller to do discovery.*/
587     OC_REST_DISCOVER       = (1 << 8)
588 } OCMethod;
589
590 /**
591  *  Formats for payload encoding.
592  */
593 typedef enum
594 {
595     OC_FORMAT_CBOR,
596     OC_FORMAT_UNDEFINED,
597     OC_FORMAT_UNSUPPORTED,
598 } OCPayloadFormat;
599
600 /**
601  * Host Mode of Operation.
602  */
603 typedef enum
604 {
605     OC_CLIENT = 0,
606     OC_SERVER,
607     OC_CLIENT_SERVER,
608     OC_GATEWAY          /**< Client server mode along with routing capabilities.*/
609 } OCMode;
610
611 /**
612  * Quality of Service attempts to abstract the guarantees provided by the underlying transport
613  * protocol. The precise definitions of each quality of service level depend on the
614  * implementation. In descriptions below are for the current implementation and may changed
615  * over time.
616  */
617 typedef enum
618 {
619     /** Packet delivery is best effort.*/
620     OC_LOW_QOS = 0,
621
622     /** Packet delivery is best effort.*/
623     OC_MEDIUM_QOS,
624
625     /** Acknowledgments are used to confirm delivery.*/
626     OC_HIGH_QOS,
627
628     /** No Quality is defined, let the stack decide.*/
629     OC_NA_QOS
630 } OCQualityOfService;
631
632 /**
633  * Resource Properties.
634  * The value of a policy property is defined as bitmap.
635  * The LSB represents OC_DISCOVERABLE and Second LSB bit represents OC_OBSERVABLE and so on.
636  * Not including the policy property is equivalent to zero.
637  *
638  */
639 typedef enum
640 {
641     /** When none of the bits are set, the resource is non-discoverable &
642      *  non-observable by the client.*/
643     OC_RES_PROP_NONE = (0),
644
645     /** When this bit is set, the resource is allowed to be discovered by clients.*/
646     OC_DISCOVERABLE  = (1 << 0),
647
648     /** When this bit is set, the resource is allowed to be observed by clients.*/
649     OC_OBSERVABLE    = (1 << 1),
650
651     /** When this bit is set, the resource is initialized, otherwise the resource
652      *  is 'inactive'. 'inactive' signifies that the resource has been marked for
653      *  deletion or is already deleted.*/
654     OC_ACTIVE        = (1 << 2),
655
656     /** When this bit is set, the resource has been marked as 'slow'.
657      * 'slow' signifies that responses from this resource can expect delays in
658      *  processing its requests from clients.*/
659     OC_SLOW          = (1 << 3),
660
661 #ifdef __WITH_DTLS__
662     /** When this bit is set, the resource is a secure resource.*/
663     OC_SECURE        = (1 << 4),
664 #else
665     OC_SECURE        = (0),
666 #endif
667
668     /** When this bit is set, the resource is allowed to be discovered only
669      *  if discovery request contains an explicit querystring.
670      *  Ex: GET /oic/res?rt=oic.sec.acl */
671     OC_EXPLICIT_DISCOVERABLE   = (1 << 5)
672 } OCResourceProperty;
673
674 /**
675  * Transport Protocol IDs.
676  */
677 typedef enum
678 {
679     /** For invalid ID.*/
680     OC_INVALID_ID   = (1 << 0),
681
682     /* For coap ID.*/
683     OC_COAP_ID      = (1 << 1)
684 } OCTransportProtocolID;
685
686 /**
687  * Declares Stack Results & Errors.
688  */
689 typedef enum
690 {
691     /** Success status code - START HERE.*/
692     OC_STACK_OK = 0,
693     OC_STACK_RESOURCE_CREATED,
694     OC_STACK_RESOURCE_DELETED,
695     OC_STACK_CONTINUE,
696     OC_STACK_RESOURCE_CHANGED,
697     /** Success status code - END HERE.*/
698
699     /** Error status code - START HERE.*/
700     OC_STACK_INVALID_URI = 20,
701     OC_STACK_INVALID_QUERY,
702     OC_STACK_INVALID_IP,
703     OC_STACK_INVALID_PORT,
704     OC_STACK_INVALID_CALLBACK,
705     OC_STACK_INVALID_METHOD,
706
707     /** Invalid parameter.*/
708     OC_STACK_INVALID_PARAM,
709     OC_STACK_INVALID_OBSERVE_PARAM,
710     OC_STACK_NO_MEMORY,
711     OC_STACK_COMM_ERROR,
712     OC_STACK_TIMEOUT,
713     OC_STACK_ADAPTER_NOT_ENABLED,
714     OC_STACK_NOTIMPL,
715
716     /** Resource not found.*/
717     OC_STACK_NO_RESOURCE,
718
719     /** e.g: not supported method or interface.*/
720     OC_STACK_RESOURCE_ERROR,
721     OC_STACK_SLOW_RESOURCE,
722     OC_STACK_DUPLICATE_REQUEST,
723
724     /** Resource has no registered observers.*/
725     OC_STACK_NO_OBSERVERS,
726     OC_STACK_OBSERVER_NOT_FOUND,
727     OC_STACK_VIRTUAL_DO_NOT_HANDLE,
728     OC_STACK_INVALID_OPTION,
729
730     /** The remote reply contained malformed data.*/
731     OC_STACK_MALFORMED_RESPONSE,
732     OC_STACK_PERSISTENT_BUFFER_REQUIRED,
733     OC_STACK_INVALID_REQUEST_HANDLE,
734     OC_STACK_INVALID_DEVICE_INFO,
735     OC_STACK_INVALID_JSON,
736
737     /** Request is not authorized by Resource Server. */
738     OC_STACK_UNAUTHORIZED_REQ,
739
740     /** Error code from PDM */
741     OC_STACK_PDM_IS_NOT_INITIALIZED,
742     OC_STACK_DUPLICATE_UUID,
743     OC_STACK_INCONSISTENT_DB,
744
745     /**
746      * Error code from OTM
747      * This error is pushed from DTLS interface when handshake failure happens
748      */
749     OC_STACK_AUTHENTICATION_FAILURE,
750
751     /** Insert all new error codes here!.*/
752 #ifdef WITH_PRESENCE
753     OC_STACK_PRESENCE_STOPPED = 128,
754     OC_STACK_PRESENCE_TIMEOUT,
755     OC_STACK_PRESENCE_DO_NOT_HANDLE,
756 #endif
757     /** ERROR in stack.*/
758     OC_STACK_ERROR = 255
759     /** Error status code - END HERE.*/
760 } OCStackResult;
761
762 /**
763  * Handle to an OCDoResource invocation.
764  */
765 typedef void * OCDoHandle;
766
767 /**
768  * Handle to an OCResource object owned by the OCStack.
769  */
770 typedef void * OCResourceHandle;
771
772 /**
773  * Handle to an OCRequest object owned by the OCStack.
774  */
775 typedef void * OCRequestHandle;
776
777 /**
778  * Unique identifier for each observation request. Used when observations are
779  * registered or de-registered. Used by entity handler to signal specific
780  * observers to be notified of resource changes.
781  * There can be maximum of 256 observations per server.
782  */
783 typedef uint8_t OCObservationId;
784
785 /**
786  * Action associated with observation.
787  */
788 typedef enum
789 {
790     /** To Register. */
791     OC_OBSERVE_REGISTER = 0,
792
793     /** To Deregister. */
794     OC_OBSERVE_DEREGISTER = 1,
795
796     /** Others. */
797     OC_OBSERVE_NO_OPTION = 2
798 } OCObserveAction;
799
800
801 /**
802  * Persistent storage handlers. An APP must provide OCPersistentStorage handler pointers
803  * when it calls OCRegisterPersistentStorageHandler.
804  * Persistent storage open handler points to default file path.
805  * It should check file path and whether the file is symbolic link or no.
806  * Application can point to appropriate SVR database path for it's IoTivity Server.
807  */
808 typedef struct {
809     /** Persistent storage file path.*/
810     FILE* (* open)(const char *path, const char *mode);
811
812     /** Persistent storage read handler.*/
813     size_t (* read)(void *ptr, size_t size, size_t nmemb, FILE *stream);
814
815     /** Persistent storage write handler.*/
816     size_t (* write)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
817
818     /** Persistent storage close handler.*/
819     int (* close)(FILE *fp);
820
821     /** Persistent storage unlink handler.*/
822     int (* unlink)(const char *path);
823 } OCPersistentStorage;
824
825 /**
826  * Possible returned values from entity handler.
827  */
828 typedef struct
829 {
830     /** Action associated with observation request.*/
831     OCObserveAction action;
832
833     /** Identifier for observation being registered/deregistered.*/
834     OCObservationId obsId;
835 } OCObservationInfo;
836
837 /**
838  * Possible returned values from entity handler.
839  */
840 typedef enum
841 {
842     OC_EH_OK = 0,
843     OC_EH_ERROR,
844     OC_EH_RESOURCE_CREATED, // 2.01
845     OC_EH_RESOURCE_DELETED, // 2.02
846     OC_EH_SLOW, // 2.05
847     OC_EH_FORBIDDEN, // 4.03
848     OC_EH_RESOURCE_NOT_FOUND, // 4.04
849     OC_EH_VALID,   // 2.03
850     OC_EH_CHANGED, // 2.04
851     OC_EH_CONTENT, // 2.05
852     OC_EH_BAD_REQ, // 4.00
853     OC_EH_UNAUTHORIZED_REQ, // 4.01
854     OC_EH_BAD_OPT, // 4.02
855     OC_EH_METHOD_NOT_ALLOWED, // 4.05
856     OC_EH_NOT_ACCEPTABLE, // 4.06
857     OC_EH_INTERNAL_SERVER_ERROR, // 5.00
858     OC_EH_RETRANSMIT_TIMEOUT // 5.04
859 } OCEntityHandlerResult;
860
861 /**
862  * This structure will be used to define the vendor specific header options to be included
863  * in communication packets.
864  */
865 typedef struct OCHeaderOption
866 {
867     /** The protocol ID this option applies to.*/
868     OCTransportProtocolID protocolID;
869
870     /** The header option ID which will be added to communication packets.*/
871     uint16_t optionID;
872
873     /** its length 191.*/
874     uint16_t optionLength;
875
876     /** pointer to its data.*/
877     uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
878
879 #ifdef SUPPORTS_DEFAULT_CTOR
880     OCHeaderOption() = default;
881     OCHeaderOption(OCTransportProtocolID pid,
882                    uint16_t optId,
883                    uint16_t optlen,
884                    const uint8_t* optData)
885         : protocolID(pid),
886           optionID(optId),
887           optionLength(optlen)
888     {
889
890         // parameter includes the null terminator.
891         optionLength = optionLength < MAX_HEADER_OPTION_DATA_LENGTH ?
892                         optionLength : MAX_HEADER_OPTION_DATA_LENGTH;
893         memcpy(optionData, optData, optionLength);
894         optionData[optionLength - 1] = '\0';
895     }
896 #endif
897 } OCHeaderOption;
898
899
900 /**
901  * This structure describes the platform properties. All non-Null properties will be
902  * included in a platform discovery request.
903  */
904 typedef struct
905 {
906     /** Platform ID.*/
907     char *platformID;
908
909     /** Manufacturer name.*/
910     char *manufacturerName;
911
912     /** Manufacturer URL for platform property.*/
913     char *manufacturerUrl;
914
915     /** Model number.*/
916     char *modelNumber;
917
918     /** Manufacturer date.*/
919     char *dateOfManufacture;
920
921     /** Platform version.*/
922     char *platformVersion;
923
924     /** Operating system version.*/
925     char *operatingSystemVersion;
926
927     /** HW version.*/
928     char *hardwareVersion;
929
930     /** FW version.*/
931     char *firmwareVersion;
932
933     /** Platform support URL.*/
934     char *supportUrl;
935
936     /** System time.*/
937     char *systemTime;
938
939 } OCPlatformInfo;
940
941 /**
942  * This structure is expected as input for device properties.
943  * device name is mandatory and expected from the application.
944  * device id of type UUID will be generated by the stack.
945  */
946 typedef struct
947 {
948     /** Pointer to the device name.*/
949     char *deviceName;
950     /** Pointer to the types.*/
951     OCStringLL *types;
952     /** Pointer to the device specification version.*/
953     char *specVersion;
954     /** Pointer to the device data model versions (in CSV format).*/
955     OCStringLL *dataModelVersions;
956 } OCDeviceInfo;
957
958 #ifdef RA_ADAPTER
959 /**
960  * callback for bound JID
961  */
962 typedef void (*jid_bound_cb)(char *jid);
963
964 /**
965  * CA Remote Access information for XMPP Client
966  *
967  */
968 typedef struct
969 {
970     char *hostname;     /**< XMPP server hostname */
971     uint16_t   port;    /**< XMPP server serivce port */
972     char *xmpp_domain;  /**< XMPP login domain */
973     char *username;     /**< login username */
974     char *password;     /**< login password */
975     char *resource;     /**< specific resource for login */
976     char *user_jid;     /**< specific JID for login */
977     jid_bound_cb jidbound;  /**< callback when JID bound */
978 } OCRAInfo_t;
979 #endif  /* RA_ADAPTER */
980
981
982 /** Enum to describe the type of object held by the OCPayload object.*/
983 typedef enum
984 {
985     /** Contents of the payload are invalid */
986     PAYLOAD_TYPE_INVALID,
987     /** The payload is an OCDiscoveryPayload */
988     PAYLOAD_TYPE_DISCOVERY,
989     /** The payload is an OCDevicePayload */
990     PAYLOAD_TYPE_DEVICE,
991     /** The payload is an OCPlatformPayload */
992     PAYLOAD_TYPE_PLATFORM,
993     /** The payload is an OCRepPayload */
994     PAYLOAD_TYPE_REPRESENTATION,
995     /** The payload is an OCSecurityPayload */
996     PAYLOAD_TYPE_SECURITY,
997     /** The payload is an OCPresencePayload */
998     PAYLOAD_TYPE_PRESENCE,
999     /** The payload is an OCRDPayload */
1000     PAYLOAD_TYPE_RD
1001 } OCPayloadType;
1002
1003 /**
1004  * A generic struct representing a payload returned from a resource operation
1005  *
1006  * A pointer to OCPayLoad can be cast to a more specific struct to access members
1007  * for the its type.
1008  */
1009 typedef struct
1010 {
1011     /** The type of message that was received */
1012     OCPayloadType type;
1013 } OCPayload;
1014
1015 typedef enum
1016 {
1017     OCREP_PROP_NULL,
1018     OCREP_PROP_INT,
1019     OCREP_PROP_DOUBLE,
1020     OCREP_PROP_BOOL,
1021     OCREP_PROP_STRING,
1022     OCREP_PROP_BYTE_STRING,
1023     OCREP_PROP_OBJECT,
1024     OCREP_PROP_ARRAY
1025 }OCRepPayloadPropType;
1026
1027 /** This structure will be used to represent a binary string for CBOR payloads.*/
1028 typedef struct
1029 {
1030     /** pointer to data bytes.*/
1031     uint8_t* bytes;
1032
1033     /** number of data bytes.*/
1034     size_t   len;
1035 } OCByteString;
1036
1037 #define MAX_REP_ARRAY_DEPTH 3
1038 typedef struct
1039 {
1040     OCRepPayloadPropType type;
1041     size_t dimensions[MAX_REP_ARRAY_DEPTH];
1042
1043     union
1044     {
1045         int64_t* iArray;
1046         double* dArray;
1047         bool* bArray;
1048         char** strArray;
1049
1050         /** pointer to ByteString array.*/
1051         OCByteString* ocByteStrArray;
1052
1053         struct OCRepPayload** objArray;
1054     };
1055 } OCRepPayloadValueArray;
1056
1057 typedef struct OCRepPayloadValue
1058 {
1059     char* name;
1060     OCRepPayloadPropType type;
1061     union
1062     {
1063         int64_t i;
1064         double d;
1065         bool b;
1066         char* str;
1067
1068         /** ByteString object.*/
1069         OCByteString ocByteStr;
1070
1071         struct OCRepPayload* obj;
1072         OCRepPayloadValueArray arr;
1073     };
1074     struct OCRepPayloadValue* next;
1075
1076 } OCRepPayloadValue;
1077
1078 // used for get/set/put/observe/etc representations
1079 typedef struct OCRepPayload
1080 {
1081     OCPayload base;
1082     char* uri;
1083     OCStringLL* types;
1084     OCStringLL* interfaces;
1085     OCRepPayloadValue* values;
1086     struct OCRepPayload* next;
1087 } OCRepPayload;
1088
1089 // used inside a discovery payload
1090 typedef struct OCResourcePayload
1091 {
1092     char* uri;
1093     OCStringLL* types;
1094     OCStringLL* interfaces;
1095     uint8_t bitmap;
1096     bool secure;
1097     uint16_t port;
1098 #ifdef TCP_ADAPTER
1099     uint16_t tcpPort;
1100 #endif
1101     struct OCResourcePayload* next;
1102 } OCResourcePayload;
1103
1104 /**
1105  * Structure holding Links Payload. It is a sub-structure used in
1106  * OCResourceCollectionPayload.
1107  */
1108 typedef struct OCLinksPayload
1109 {
1110     /** This is the target relative URI. */
1111     char *href;
1112     /** Resource Type - A standard OIC specified or vendor defined resource
1113      * type of the resource referenced by the target URI. */
1114     OCStringLL *rt;
1115     /** Interface - The interfaces supported by the resource referenced by the target URI. */
1116     OCStringLL *itf;
1117     /** The relation of the target URI referenced by the link to the context URI;
1118      * The default value is null. */
1119     char *rel;
1120     /** Specifies if the resource referenced by the target URIis observable or not. */
1121     bool obs;
1122     /** A title for the link relation. Can be used by the UI to provide a context. */
1123     char *title;
1124     /** This is used to override the context URI e.g. override the URI of the containing collection. */
1125     char *uri;
1126     /** The instance identifier for this web link in an array of web links - used in links. */
1127     union
1128     {
1129         /** An ordinal number that is not repeated - must be unique in the collection context. */
1130         uint8_t ins;
1131         /** Any unique string including a URI. */
1132         char *uniqueStr;
1133         /** Use UUID for universal uniqueness - used in /oic/res to identify the device. */
1134         OCIdentity uniqueUUID;
1135     };
1136     /** A hint of the media type of the representation of the resource referenced by the target URI. */
1137     OCStringLL *mt;
1138     /** Holding address of the next resource. */
1139     struct OCLinksPayload *next;
1140 } OCLinksPayload;
1141
1142 /** Structure holding tags value of the links payload. */
1143 typedef struct
1144 {
1145     /** Name of tags. */
1146     OCDeviceInfo n;
1147     /** Device identifier. */
1148     OCIdentity di;
1149     /** The base URI where the resources are hold. */
1150     char *baseURI;
1151     /** Bitmap holds observable, discoverable, secure option flag.*/
1152     uint8_t bitmap;
1153     /** Port set in case, the secure flag is set above. */
1154     uint16_t port;
1155     /** Id for each set of links i.e. tag. */
1156     union
1157     {
1158         /** An ordinal number that is not repeated - must be unique in the collection context. */
1159         uint8_t ins;
1160         /** Any unique string including a URI. */
1161         char *uniqueStr;
1162         /** Use UUID for universal uniqueness - used in /oic/res to identify the device. */
1163         OCIdentity uniqueUUID;
1164     };
1165     /** Defines the list of allowable resource types (for Target and anchors) in links included
1166      * in the collection; new links being created can only be from this list. */
1167     char *rts;
1168     /** When specified this is the default relationship to use when an OIC Link does not specify
1169      * an explicit relationship with *rel* parameter. */
1170     char *drel;
1171     /** Time to keep holding resource.*/
1172     uint32_t ttl;
1173 } OCTagsPayload;
1174
1175 /** Resource collection payload. */
1176 typedef struct OCResourceCollectionPayload
1177 {
1178     /** Collection tags payload.*/
1179     OCTagsPayload *tags;
1180     /** Array of links payload. */
1181     OCLinksPayload *setLinks;
1182     /** Holding address of the next resource. */
1183     struct OCResourceCollectionPayload *next;
1184 } OCResourceCollectionPayload;
1185
1186 typedef struct
1187 {
1188     OCPayload base;
1189
1190     /** Device Id */
1191     char *sid;
1192
1193     /** A special case for handling RD address. */
1194     char* baseURI;
1195
1196     /** Name */
1197     char *name;
1198
1199     /** HREF */
1200     char *uri;
1201
1202     /** Resource Type */
1203     OCStringLL *type;
1204
1205     /** Interface */
1206     OCStringLL *interface;
1207
1208     /** This structure holds the old /oic/res response. */
1209     OCResourcePayload *resources;
1210
1211 } OCDiscoveryPayload;
1212
1213 /**
1214  * Structure holding discovery payload.
1215  */
1216 typedef struct
1217 {
1218     /** Device Name. */
1219     OCDeviceInfo n;
1220     /** Device Identity. */
1221     OCIdentity di;
1222     /** Value holding the bias factor of the RD. */
1223     uint8_t sel;
1224 } OCRDDiscoveryPayload;
1225
1226 /**
1227  * RD Payload that will be transmitted over the wire.
1228  */
1229 typedef struct
1230 {
1231     OCPayload base;
1232     /** Pointer to the discovery response payload.*/
1233     OCRDDiscoveryPayload *rdDiscovery;
1234     /** Pointer to the publish payload.*/
1235     OCResourceCollectionPayload *rdPublish;
1236 } OCRDPayload;
1237
1238 typedef struct
1239 {
1240     OCPayload base;
1241     char *sid;
1242     char* deviceName;
1243     char* specVersion;
1244     OCStringLL *dataModelVersions;
1245     OCStringLL *interfaces;
1246     OCStringLL *types;
1247 } OCDevicePayload;
1248
1249 typedef struct
1250 {
1251     OCPayload base;
1252     char* uri;
1253     OCPlatformInfo info;
1254     OCStringLL* rt;
1255     OCStringLL* interfaces;
1256 } OCPlatformPayload;
1257
1258 typedef struct
1259 {
1260     OCPayload base;
1261     uint8_t* securityData;
1262     size_t payloadSize;
1263 } OCSecurityPayload;
1264
1265 #ifdef WITH_PRESENCE
1266 typedef struct
1267 {
1268     OCPayload base;
1269     uint32_t sequenceNumber;
1270     uint32_t maxAge;
1271     OCPresenceTrigger trigger;
1272     char* resourceType;
1273 } OCPresencePayload;
1274 #endif
1275
1276 /**
1277  * Incoming requests handled by the server. Requests are passed in as a parameter to the
1278  * OCEntityHandler callback API.
1279  * The OCEntityHandler callback API must be implemented in the application in order
1280  * to receive these requests.
1281  */
1282 typedef struct
1283 {
1284     /** Associated resource.*/
1285     OCResourceHandle resource;
1286
1287     /** Associated request handle.*/
1288     OCRequestHandle requestHandle;
1289
1290     /** the REST method retrieved from received request PDU.*/
1291     OCMethod method;
1292
1293     /** description of endpoint that sent the request.*/
1294     OCDevAddr devAddr;
1295
1296     /** resource query send by client.*/
1297     char * query;
1298
1299     /** Information associated with observation - valid only when OCEntityHandler flag includes
1300      * ::OC_OBSERVE_FLAG.*/
1301     OCObservationInfo obsInfo;
1302
1303     /** Number of the received vendor specific header options.*/
1304     uint8_t numRcvdVendorSpecificHeaderOptions;
1305
1306     /** Pointer to the array of the received vendor specific header options.*/
1307     OCHeaderOption * rcvdVendorSpecificHeaderOptions;
1308
1309     /** Message id.*/
1310     uint16_t messageID;
1311
1312     /** the payload from the request PDU.*/
1313     OCPayload *payload;
1314
1315 } OCEntityHandlerRequest;
1316
1317
1318 /**
1319  * Response from queries to remote servers. Queries are made by calling the OCDoResource API.
1320  */
1321 typedef struct
1322 {
1323     /** Address of remote server.*/
1324     OCDevAddr devAddr;
1325
1326     /** backward compatibility (points to devAddr).*/
1327     OCDevAddr *addr;
1328
1329     /** backward compatibility.*/
1330     OCConnectivityType connType;
1331
1332     /** the security identity of the remote server.*/
1333     OCIdentity identity;
1334
1335     /** the is the result of our stack, OCStackResult should contain coap/other error codes.*/
1336     OCStackResult result;
1337
1338     /** If associated with observe, this will represent the sequence of notifications from server.*/
1339     uint32_t sequenceNumber;
1340
1341     /** resourceURI.*/
1342     const char * resourceUri;
1343
1344     /** the payload for the response PDU.*/
1345     OCPayload *payload;
1346
1347     /** Number of the received vendor specific header options.*/
1348     uint8_t numRcvdVendorSpecificHeaderOptions;
1349
1350     /** An array of the received vendor specific header options.*/
1351     OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
1352 } OCClientResponse;
1353
1354 /**
1355  * Request handle is passed to server via the entity handler for each incoming request.
1356  * Stack assigns when request is received, server sets to indicate what request response is for.
1357  */
1358 typedef struct
1359 {
1360     /** Request handle.*/
1361     OCRequestHandle requestHandle;
1362
1363     /** Resource handle.*/
1364     OCResourceHandle resourceHandle;
1365
1366     /** Allow the entity handler to pass a result with the response.*/
1367     OCEntityHandlerResult  ehResult;
1368
1369     /** This is the pointer to server payload data to be transferred.*/
1370     OCPayload* payload;
1371
1372     /** number of the vendor specific header options .*/
1373     uint8_t numSendVendorSpecificHeaderOptions;
1374
1375     /** An array of the vendor specific header options the entity handler wishes to use in response.*/
1376     OCHeaderOption sendVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
1377
1378     /** URI of new resource that entity handler might create.*/
1379     char resourceUri[MAX_URI_LENGTH];
1380
1381     /** Server sets to true for persistent response buffer,false for non-persistent response buffer*/
1382     uint8_t persistentBufferFlag;
1383 } OCEntityHandlerResponse;
1384
1385 /**
1386  * Entity's state
1387  */
1388 typedef enum
1389 {
1390     /** Request state.*/
1391     OC_REQUEST_FLAG = (1 << 1),
1392     /** Observe state.*/
1393     OC_OBSERVE_FLAG = (1 << 2)
1394 } OCEntityHandlerFlag;
1395
1396 /**
1397  * Possible return values from client application callback
1398  *
1399  * A client application callback returns an OCStackApplicationResult to indicate whether
1400  * the stack should continue to keep the callback registered.
1401  */
1402 typedef enum
1403 {
1404     /** Make no more calls to the callback and call the OCClientContextDeleter for this callback */
1405     OC_STACK_DELETE_TRANSACTION = 0,
1406     /** Keep this callback registered and call it if an apropriate event occurs */
1407     OC_STACK_KEEP_TRANSACTION
1408 } OCStackApplicationResult;
1409
1410
1411 //#ifdef DIRECT_PAIRING
1412 /**
1413  * @brief   direct pairing Method Type.
1414  *              0:  not allowed
1415  *              1:  pre-configured pin
1416  *              2:  random pin
1417  */
1418 typedef enum OCPrm
1419 {
1420     DP_NOT_ALLOWED             = 0x0,
1421     DP_PRE_CONFIGURED        = (0x1 << 0),
1422     DP_RANDOM_PIN               = (0x1 << 1),
1423 } OCPrm_t;
1424
1425 /**
1426  * Device Information of discoverd direct pairing device(s).
1427  */
1428 typedef struct OCDPDev
1429 {
1430     OCDevAddr               endpoint;
1431     OCConnectivityType   connType;
1432     uint16_t                     securePort;
1433     bool                  edp;
1434     OCPrm_t           *prm;
1435     size_t                prmLen;
1436     OCUUIdentity     deviceID;
1437     OCUUIdentity     rowner;
1438     struct OCDPDev *next;
1439 } OCDPDev_t;
1440 //#endif // DIRECT_PAIRING
1441
1442 /*
1443  * -------------------------------------------------------------------------------------------
1444  * Callback function definitions
1445  * -------------------------------------------------------------------------------------------
1446  */
1447
1448 /**
1449  * Client applications implement this callback to consume responses received from Servers.
1450  */
1451 typedef OCStackApplicationResult (* OCClientResponseHandler)(void *context, OCDoHandle handle,
1452     OCClientResponse * clientResponse);
1453
1454 /**
1455  * Client applications using a context pointer implement this callback to delete the
1456  * context upon removal of the callback/context pointer from the internal callback-list.
1457  */
1458 typedef void (* OCClientContextDeleter)(void *context);
1459
1460 /**
1461  * This info is passed from application to OC Stack when initiating a request to Server.
1462  */
1463 typedef struct OCCallbackData
1464 {
1465     /** Pointer to the context.*/
1466     void *context;
1467
1468     /** The pointer to a function the stack will call to handle the requests.*/
1469     OCClientResponseHandler cb;
1470
1471     /** A pointer to a function to delete the context when this callback is removed.*/
1472     OCClientContextDeleter cd;
1473
1474 #ifdef SUPPORTS_DEFAULT_CTOR
1475     OCCallbackData() = default;
1476     OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter)
1477         :context(ctx), cb(callback), cd(deleter){}
1478 #endif
1479 } OCCallbackData;
1480
1481 /**
1482  * Application server implementations must implement this callback to consume requests OTA.
1483  * Entity handler callback needs to fill the resPayload of the entityHandlerRequest.
1484  */
1485 typedef OCEntityHandlerResult (*OCEntityHandler)
1486 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void* callbackParam);
1487
1488 /**
1489  * Device Entity handler need to use this call back instead of OCEntityHandler.
1490  */
1491 typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
1492 (OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri, void* callbackParam);
1493
1494 //#ifdef DIRECT_PAIRING
1495 /**
1496  * Callback function definition of direct-pairing
1497  *
1498  * @param[OUT] ctx - user context returned in the callback.
1499  * @param[OUT] peer - pairing device info.
1500  * @param[OUT} result - It's returned with 'OC_STACK_XXX'. It will return 'OC_STACK_OK'
1501  *                                   if D2D pairing is success without error
1502  */
1503 typedef void (*OCDirectPairingCB)(void *ctx, OCDPDev_t *peer, OCStackResult result);
1504 //#endif // DIRECT_PAIRING
1505
1506 #ifdef __cplusplus
1507 }
1508 #endif // __cplusplus
1509
1510 #endif /* OCTYPES_H_ */