Implementation of connectivity abstraction feature Release v0.3
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caprotocolmessage.h
1 /******************************************************************
2  *
3  * Copyright 2014 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 __CA_PROTOCOL_MESSAGE_H_
21 #define __CA_PROTOCOL_MESSAGE_H_
22
23 #include "cacommon.h"
24 #include "config.h"
25 #include "coap.h"
26 #include "debug.h"
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 typedef uint32_t code_t;
34
35 /**
36  * function for generating
37  */
38 coap_pdu_t *CAGeneratePdu(const char *uri, const uint32_t code, const CAInfo_t info);
39
40 /**
41  * function for generating
42  */
43 uint32_t CAGetRequestInfoFromPdu(const coap_pdu_t *pdu, CARequestInfo_t *outReqInfo, char *outUri);
44
45 uint32_t CAGetResponseInfoFromPdu(const coap_pdu_t *pdu, CAResponseInfo_t *outResInfo,
46                                   char *outUri);
47
48 coap_pdu_t* CACreatePDUforRequest(const code_t code, coap_list_t *options, const CAInfo_t info);
49
50 coap_pdu_t *CACreatePDUforRequestWithPayload(const code_t code, coap_list_t *optlist,
51         const char* payload, const CAInfo_t info);
52
53 /**
54  * funtion for parsing
55  */
56 void CAParseURI(const char *uriInfo, coap_list_t **options);
57
58 /**
59  * funtion for parsing
60  */
61 void CAParseHeadOption(const uint32_t code, const CAInfo_t info, coap_list_t **optlist);
62
63 coap_list_t *CACreateNewOptionNode(const uint16_t key, const uint32_t length, const uint8_t *data);
64
65 int CAOrderOpts(void *a, void *b);
66
67 uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter);
68
69 uint32_t CAGetOptionData(const uint8_t *data, uint32_t len, uint8_t *result,
70         uint32_t buflen, uint32_t encode_always);
71
72 /**
73  * funtion for get PDU information
74  */
75 void CAGetRequestPDUInfo(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *outInfo, char *outUri);
76
77 /**
78  * funtion for parsing
79  */
80 coap_pdu_t *CAParsePDU(const char *data, uint32_t *outCode);
81
82 /**
83  * function for token
84  */
85 CAResult_t CAGenerateTokenInternal(CAToken_t *token);
86
87 void CADestroyTokenInternal(CAToken_t token);
88
89 /**
90  * Deinitialize
91  */
92 void CADeinitialize(CAInfo_t *info);
93
94 #ifdef __cplusplus
95 } /* extern "C" */
96 #endif
97
98 #endif //#ifndef __CA_PROTOCOL_MESSAGE_H_