1 /* ****************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
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 ******************************************************************/
23 * This file contains CoAP to HTTP mapping
26 #ifndef COAP_HTTP_MAP_H_
27 #define COAP_HTTP_MAP_H_
34 #include "CoapHttpParser.h"
35 #if defined (__TIZENRT__)
36 #include <apps/netutils/cJSON.h>
42 * Function to get CoAP code for an HTTP code.
43 * @param[in] httpCode HTTP Code.
44 * @param[in] method Request Method type
45 * @param[out] ocfCode Corresponding OCF code.
46 * @return ::OC_STACK_OK or appropriate error code.
48 OCStackResult CHPGetOCCode(const HttpResponseResult_t httpCode, const OCMethod method,
49 OCEntityHandlerResult *ocfCode);
52 * Function to get CoAP option for an HTTP option.
53 * @param[in] httpOption HTTP Option.
54 * @param[out] ret Corresponding CoAP option.
55 * @return ::OC_STACK_OK or appropriate error code.
57 OCStackResult CHPGetOCOption(const HttpHeaderOption_t *httpOption, OCHeaderOption *ret);
60 * Function to get CoAP payload format for HTTP payload format.
61 * @param[in] httpContentType HTTP payload format.
62 * @return CoAP payload format.
64 OCPayloadFormat CHPGetOCContentType(const char *httpContentType);
67 * Function to get HTTP method for OCF method.
68 * @param[in] method OCF method.
69 * @param[out] httpMethod Corresponding HTTP method.
70 * @return ::OC_STACK_OK or appropriate error code.
72 OCStackResult CHPGetHttpMethod(const OCMethod method, HttpMethod_t *httpMethod);
75 * Function to get HTTP option for OCF option.
76 * @param[in] option OCF option.
77 * @param[out] ret Corresponding HTTP option.
78 * @return ::OC_STACK_OK or appropriate error code.
80 OCStackResult CHPGetHttpOption(const OCHeaderOption* option, HttpHeaderOption_t **ret);
83 * Function to convert Json payload to CBOR representational payload.
84 * @param[in] rootJSon Json payload.
85 * @param[out] payload CBor representational payload.
87 void CHPJsonToRepPayload(cJSON* rootJSon, OCRepPayload* payload);
90 * Function to convert CBOR representational payload to Json payload.
91 * @param[in] repData Cbor representational payload.
92 * @return CJson payload.
94 cJSON* CHPRepPayloadToJson(OCRepPayload* repData);