1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 //-----------------------------------------------------------------------------
8 // Internal include file used by lower layers of the OC stack
9 //-----------------------------------------------------------------------------
10 #ifndef OCSTACKINTERNAL_H_
11 #define OCSTACKINTERNAL_H_
13 //-----------------------------------------------------------------------------
15 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
27 // Forward declarations
28 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
34 typedef struct resourcetype_t {
35 struct resourcetype_t *next; // linked list; for multiple types on resource
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;
50 typedef struct attr_t {
51 struct attr_t *next; // Points to next resource in list
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
56 char *attrValue; // value of the attribute as string
59 typedef struct resourceinterface_t {
60 struct resourceinterface_t *next; // linked list; for multiple interfaces on resource
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
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)
73 char *inputContentType ;
74 char *outputContentType ;
76 /*** Future placeholder for access control and policy ***/
77 } OCResourceInterface;
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
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
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; */
103 // following structure will be created in occoap and passed up the stack on the server side
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;
115 // following structure will be created in occoap and passed up the stack on the client side
117 // token is copied from the received response PDU
119 // this structure will be passed to client
120 OCClientResponse * clientResponse;
123 //-----------------------------------------------------------------------------
124 // Internal function prototypes
125 //-----------------------------------------------------------------------------
127 OCStackResult OCStackHandleReceiveRequest(OCRequest * request);
128 void OCStackHandleReceiveResponse(OCResponse * response);
133 #endif // __cplusplus
135 #endif /* OCSTACKINTERNAL_H_ */