To come on this changeset: All convergences between and server and client observation...
[platform/upstream/iotivity.git] / csdk / occoap / include / occoaphelper.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation 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 #ifndef OCCOAPHELPER_H_
23 #define OCCOAPHELPER_H_
24
25 //-----------------------------------------------------------------------------
26 // Includes
27 //-----------------------------------------------------------------------------
28 #include <unistd.h>
29 #include <limits.h>
30 #include <ctype.h>
31 #include "coap.h"
32 #include "ocstack.h"
33 #include "occoaptoken.h"
34 #include "ocstackinternal.h"
35
36 // Convert OCStack code to CoAP code
37 uint8_t OCToCoAPResponseCode(OCStackResult result);
38
39 // Convert CoAP code to OCStack code
40 OCStackResult CoAPToOCResponseCode(uint8_t coapCode);
41
42 // Internal function to generate a coap pdu based on passed parameters
43 coap_pdu_t *
44 GenerateCoAPPdu(uint8_t msgType, uint8_t code, unsigned short id,
45         size_t tokenLength, uint8_t * token, unsigned char * payloadJSON,
46         coap_list_t *options);
47
48 // Call back function used by libcoap to order option in coap pdu
49 int OrderOptions(void *a, void *b);
50
51 // Internal function to create an option node for coap pdu
52 coap_list_t *
53 CreateNewOptionNode(unsigned short key, unsigned int length,
54         unsigned char *data);
55
56 // Internal function to create OCRequest struct at the server from a received coap pdu
57 OCStackResult FormOCRequest(const coap_queue_t * rcvdRequest,
58         OCRequest * * requestLoc, unsigned char * uriBuf,
59         unsigned char * queryBuf);
60
61 // Internal function to create OCEntityHandlerRequest at the server from a received coap pdu
62 OCStackResult FormOCEntityHandlerRequest(const coap_queue_t * rcvdRequest,
63         OCEntityHandlerRequest * * entityHandlerRequestLoc,
64         unsigned char * bufRes, unsigned char * query);
65
66 // Internal function to retrieve a Token from received coap pdu
67 OCStackResult RetrieveOCCoAPToken(const coap_queue_t * rcvdRequest,
68         OCCoAPToken * * rcvdTokenLoc);
69
70 // Internal function to create OCResponse struct at the client from a received coap pdu
71 OCStackResult FormOCResponse(const coap_queue_t * rcvdResponse,
72         OCResponse * * responseLoc);
73
74 // Internal function to create OCClientResponse struct at the client from a received coap pdu
75 OCStackResult FormOCClientResponse(const coap_queue_t * rcvdResponse,
76         OCClientResponse * * clientResponseLoc);
77
78 #endif /* OCCOAPHELPER_H_ */