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