Move OCGetServerInstanceId in OCStack
[platform/upstream/iotivity.git] / service / resource-directory / include / rd_types.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics 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 #ifndef _RESOURCE_DIRECTORY_TYPES_H_
21 #define _RESOURCE_DIRECTORY_TYPES_H_
22
23 #include "ocpayload.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif // __cplusplus
28
29 /** Resource Directory URI used to Discover RD and Publish resources.*/
30 #define OC_RSRVD_RD_URI                  "/oic/rd"
31
32 /** To represent resource type with rd.*/
33 #define OC_RSRVD_RESOURCE_TYPE_RD        "oic.wk.rd"
34
35 /** RD Discovery bias factor type. */
36 #define OC_RSRVD_RD_DISCOVERY_SEL        "sel"
37
38 /** To represent resource type with Publish RD.*/
39 #define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdPub"
40
41 /** Max ADDR SIZE */
42 #define MAX_ADDR_STR_SIZE (40)
43
44 /** Callback function for returning RDDiscovery Result. */
45 typedef int (* OCRDBiasFactorCB)(char addr[MAX_ADDR_STR_SIZE], uint16_t port);
46
47 /** Context structure used sending it as part of the callback context. */
48 typedef struct
49 {
50     /** Stores the context value of the message sent. */
51     void *context;
52     /** Pointing to the callback function that OCRDDiscover() received. */
53     OCRDBiasFactorCB cbFunc;
54 } OCRDClientContextCB;
55
56 /**
57  * Structure holding discovery payload.
58  */
59 typedef struct
60 {
61     /** Value holding the bias factor of the RD. */
62     uint8_t sel;
63 } OCRDDiscoveryPayload;
64
65 /**
66  * Structure holding RD Links Payload. It is a sub-structure used in
67  * OCRDPublishPayload.
68  */
69 typedef struct OCRDLinksPayload
70 {
71     /** Web Link Address of the resource. */
72     char *href;
73     /** Resource type of the resource. */
74     char *rt;
75     /** Interace type of the resource. */
76     char *itf;
77     /** Holding address of the next resource. */
78     struct OCRDLinksPayload *next;
79 } OCRDLinksPayload;
80
81 /**
82  * Structure holding RD Publish payload.
83  */
84 typedef struct
85 {
86     /** Device Name. */
87     OCDeviceInfo deviceName;
88     /** Device id. */
89     OCIdentity deviceId;
90     /** Time to keep holding resource.*/
91     uint32_t ttl;
92     /** List of resource information that will be stored at RD.*/
93     OCRDLinksPayload *links;
94 } OCRDPublishPayload;
95
96 /**
97  * Enum values of multiple RD type payload.
98  */
99 typedef enum
100 {
101     /** Value of the RD discovery payload. */
102     RD_PAYLOAD_TYPE_DISCOVERY,
103     /** Value of the RD publish payload. */
104     RD_PAYLOAD_TYPE_PUBLISH,
105     /** Value of the RD response in the payload. */
106     RD_PAYLOAD_TYPE_RESPONSE
107 } OCRDPayloadType;
108
109 /**
110  * RD Payload that will be transmitted over the wire.
111  */
112 typedef struct
113 {
114     /** Used in ocpayload to check type of the packet. This matches other OC payload.*/
115     OCPayload base;
116     /** Used internally in RD to check the payload whether discovery or publish.*/
117     OCRDPayloadType payloadType;
118     /** Pointer to the discovery response payload.*/
119     OCRDDiscoveryPayload *rdDiscovery;
120     /** Pointer to the publish payload.*/
121     OCRDPublishPayload *rdPublish;
122 } OCRDPayload;
123
124 #ifdef __cplusplus
125 }
126 #endif // __cplusplus
127
128 #endif