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"
38 * Function to get CoAP code for an HTTP code.
39 * @param[in] httpCode HTTP Code.
40 * @param[in] method Request Method type
41 * @param[out] ocfCode Corresponding OCF code.
42 * @return ::OC_STACK_OK or appropriate error code.
44 OCStackResult CHPGetOCCode(const HttpResponseResult_t httpCode, const OCMethod method,
45 OCEntityHandlerResult *ocfCode);
48 * Function to get CoAP option for an HTTP option.
49 * @param[in] httpOption HTTP Option.
50 * @param[out] ret Corresponding CoAP option.
51 * @return ::OC_STACK_OK or appropriate error code.
53 OCStackResult CHPGetOCOption(const HttpHeaderOption_t *httpOption, OCHeaderOption *ret);
56 * Function to get CoAP payload format for HTTP payload format.
57 * @param[in] httpContentType HTTP payload format.
58 * @return CoAP payload format.
60 OCPayloadFormat CHPGetOCContentType(const char *httpContentType);
63 * Function to get HTTP method for OCF method.
64 * @param[in] method OCF method.
65 * @param[out] httpMethod Corresponding HTTP method.
66 * @return ::OC_STACK_OK or appropriate error code.
68 OCStackResult CHPGetHttpMethod(const OCMethod method, HttpMethod_t *httpMethod);
71 * Function to get HTTP option for OCF option.
72 * @param[in] option OCF option.
73 * @param[out] ret Corresponding HTTP option.
74 * @return ::OC_STACK_OK or appropriate error code.
76 OCStackResult CHPGetHttpOption(const OCHeaderOption* option, HttpHeaderOption_t **ret);
79 * Function to convert Json payload to CBOR representational payload.
80 * @param[in] rootJSon Json payload.
81 * @param[out] payload CBor representational payload.
83 void CHPJsonToRepPayload(cJSON* rootJSon, OCRepPayload* payload);
86 * Function to convert CBOR representational payload to Json payload.
87 * @param[in] repData Cbor representational payload.
88 * @return CJson payload.
90 cJSON* CHPRepPayloadToJson(OCRepPayload* repData);