1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26 #include <occoaptoken.h>
27 #include <ocresource.h>
29 typedef struct OCPresence {
30 // This is the TTL associated with presence
36 typedef struct OCMulticastNode {
39 struct OCMulticastNode * next;
42 extern OCMulticastNode * mcPresenceNodes;
44 typedef struct ClientCB {
45 // callback method defined in application address space
46 OCClientResponseHandler callBack;
47 // callback context data
49 // callback method to delete context data
50 OCClientContextDeleter deleteCallback;
51 // when a response is recvd with this token, above callback will be invoked
53 // Invocation handle tied to original call to OCDoResource()
55 // This is used to determine if all responses should be consumed or not.
56 // (For now, only pertains to OC_REST_OBSERVE_ALL Vs. OC_REST_OBSERVE functionality)
58 // This is the sequence identifier the server applies to the invocation tied to 'handle'.
59 uint32_t sequenceNumber;
60 // This is the request uri associated with the call back
61 unsigned char * requestUri;
62 // Struct to hold TTL info for presence
64 OCPresence * presence;
65 OCResourceType * filterResourceType;
67 // next node in this list
68 struct ClientCB *next;
71 extern struct ClientCB *cbList;
73 //-- AddClientCB -----------------------------------------------------------
76 * This method is used to add a client callback method in cbList.
78 * @param[out] clientCB
79 * The resulting node from making this call. Null if out of memory.
81 * address to client callback function.
83 * identifier for OTA CoAP comms.
85 * Masked in the public API as an 'invocation handle' - Used for callback management.
86 * @param[in] requestUri
87 * the resource uri of the request.
88 * @param[in] resourceType
89 * the resourceType associated with a presence request.
91 * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
93 * @retval OC_STACK_OK for Success, otherwise some error value
95 //------------------------------------------------------------------------
96 OCStackResult AddClientCB(ClientCB** clientCB, OCCallbackData* cbData,
97 OCCoAPToken * token, OCDoHandle *handle, OCMethod method,
98 unsigned char * requestUri, unsigned char * resourceType);
100 //-- DeleteClientCB -----------------------------------------------------------
103 * This method is used to remove a callback node from cbList.
106 * address to client callback node.
108 //------------------------------------------------------------------------
109 void DeleteClientCB(ClientCB *cbNode);
112 //-- GetClientCB ---------------------------------------------------------
115 * This method is used to search a cb node in cbList.
118 * token to search for.
120 * handle to search for.
121 * @param[in] requestUri
124 * @brief You can search by token OR by handle. Not both.
126 * @retval address of the node if found, otherwise NULL
128 //------------------------------------------------------------------------
129 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, const unsigned char * requestUri);
133 * Inserts a new resource type filter into this clientCB node.
135 * @param cbNode - the node to add the new resourceType filter to
136 * @param resourceTypeName - the value to create the new resourceType filter from
139 * OC_STACK_OK on success
140 * OC_STACK_ERROR with invalid parameters
141 * OC_STACK_NO_MEMORY when out of memory
144 OCStackResult InsertResourceTypeFilter(ClientCB * cbNode, const char * resourceTypeName);
145 #endif // WITH_PRESENCE
147 //-- DeleteClientCBList --------------------------------------------------
150 * This method is used to clear the cbList.
153 //------------------------------------------------------------------------
154 void DeleteClientCBList();
156 //-- FindAndDeleteClientCB -----------------------------------------------
159 * This method is used to verify the presence of a cb node in cbList
160 * and then delete it.
163 * address to client callback node.
165 //------------------------------------------------------------------------
166 void FindAndDeleteClientCB(ClientCB * cbNode);
170 * This method is used to search a multicast presence node from list.
173 * the uri of the request.
175 * @return OCMulticastNode
176 * The resulting node from making this call. Null if doesn't exist.
178 //------------------------------------------------------------------------
179 OCMulticastNode* GetMCPresenceNode(const unsigned char * uri);
183 * This method is used to add a multicast presence node to the list.
185 * @param[out] outnode
186 * The resulting node from making this call. Null if out of memory.
188 * the uri of the server.
190 * current nonce for the server
192 * @return OC_STACK_OK for Success, otherwise some error value
194 //------------------------------------------------------------------------
195 OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, unsigned char* uri, uint32_t nonce);
197 #endif //OC_CLIENT_CB