Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / csdk / stack / include / internal / ocstackinternal.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5 //
6
7 //-----------------------------------------------------------------------------
8 // Internal include file used by lower layers of the OC stack
9 //-----------------------------------------------------------------------------
10 #ifndef OCSTACKINTERNAL_H_
11 #define OCSTACKINTERNAL_H_
12
13 //-----------------------------------------------------------------------------
14 // Includes
15 //-----------------------------------------------------------------------------
16 #include "ocstack.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif // __cplusplus
21
22 //-----------------------------------------------------------------------------
23 // Defines
24 //-----------------------------------------------------------------------------
25
26 //-----------------------------------------------------------------------------
27 // Forward declarations
28 //-----------------------------------------------------------------------------
29 struct rsrc_t;
30
31 //-----------------------------------------------------------------------------
32 // Typedefs
33 //-----------------------------------------------------------------------------
34 typedef struct resourcetype_t {
35     struct resourcetype_t *next; // linked list; for multiple types on resource
36
37     // Name of the type; this string is ‘.’ (dot) separate list of segments where each segment is a
38     // namespace and the final segment is the type; type and sub-types can be separate with ‘-‘ (dash)
39     // usually only two segments would be defined. Either way this string is meant to be human friendly
40     // and is used opaquely and not parsed by code
41     // This name is used in the “rt=” parameter of a resource description when resources are introspected
42     // and is also use in the <base URI>/types list of available types
43     char *resourcetypename;
44     // An array of strings; each string defines the attribute and attribute data type.
45     // NOTE: this is not the same as the request/response payload representation;
46     // but is the definition of attribute/value pairs that go into the payload
47     char *typerepresentation;
48 } OCResourceType;
49
50 typedef struct attr_t {
51     struct attr_t *next; // Points to next resource in list
52
53     // The name of the attribute; used to look up the attribute in list;
54     // for a given attribute SHOULD not be changed once assigned
55     const char *attrName;
56     char *attrValue; // value of the attribute as string
57 } OCAttribute;
58
59 typedef struct resourceinterface_t {
60     struct resourceinterface_t *next; // linked list; for multiple interfaces on resource
61
62     // Name of the interface; this is ‘.’ (dot) separate list of segments where each segment is
63     // a namespace and the final segment is the interface; usually only two segments would be defined.
64     // Either way this string is opaque and not parsed by segment
65     char *name ;
66     // Allowed methods on this resource through this interface
67     // Use the methods in OCMethod to create a bitmap
68     // Example: OC_REST_GET|OC_REST_PUT.
69     uint8_t allowedMethods;
70     // Supported content types to serialize request and response on this interface
71     // (REMOVE for V1 – only jSON for all but core.ll that uses Link Format)
72 #if 0
73     char *inputContentType ;
74     char *outputContentType ;
75 #endif
76     /*** Future placeholder for access control and policy ***/
77 } OCResourceInterface;
78
79 typedef struct rsrc_t {
80     struct rsrc_t *next; // Points to next resource in list
81     // Relative path on the device; will be combined with base url to create fully qualified path
82     char *uri;
83     OCResourceType *rsrcType; // Resource type(s); linked list
84     OCResourceInterface *rsrcInterface; // Resource interface(s); linked list
85     OCAttribute *rsrcAttributes; // Resource interface(s); linked list
86     // Array of pointers to resources; can be used to represent a container of resources
87     // (i.e. hierarchies of resources) or for reference resources (i.e. for a resource collection)
88     struct rsrc_t *rsrcResources[MAX_CONTAINED_RESOURCES];
89     //struct rsrc_t *rsrcResources;
90     // Pointer to function that handles the entity bound to the resource.
91     // This handler has to be explicitly defined by the programmer
92     OCEntityHandler entityHandler;
93     // Properties on the resource – defines meta information on the resource
94     OCResourceProperty resourceProperties ; /* ACTIVE, DISCOVERABLE etc */
95     // Pointer to an opaque object where app/user specific data can be placed with the resource;
96     // this could be information for the entity handler between invocations
97     void *context;
98     // NOTE: Methods supported by this resource should be based on the interface targeted
99     // i.e. look into the interface structure based on the query request Can be removed here; place holder for the note above
100     /* method_t methods; */
101 } OCResource;
102
103 // following structure will be created in occoap and passed up the stack on the server side
104 typedef struct {
105     // resourceUrl will be filled in occoap using the path options in received request PDU
106     unsigned char * resourceUrl;
107     // resourceUrl will be filled in occoap using the query options in received request PDU
108     unsigned char * query;
109     // qos is indicating if the request is CON or NON
110     OCQualityOfService qos;
111     // this structure will be passed to entity handler
112     OCEntityHandlerRequest * entityHandlerRequest;
113 } OCRequest;
114
115 // following structure will be created in occoap and passed up the stack on the client side
116 typedef struct {
117     // token is copied from the received response PDU
118     OCToken * token;
119     // this structure will be passed to client
120     OCClientResponse * clientResponse;
121 } OCResponse;
122
123 //-----------------------------------------------------------------------------
124 // Internal function prototypes
125 //-----------------------------------------------------------------------------
126
127 OCStackResult OCStackHandleReceiveRequest(OCRequest * request);
128 void OCStackHandleReceiveResponse(OCResponse * response);
129
130
131 #ifdef __cplusplus
132 }
133 #endif // __cplusplus
134
135 #endif /* OCSTACKINTERNAL_H_ */