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