coap_server_request.h
Go to the documentation of this file.
1 /**
2  * @file coap_server_request.h
3  * @brief CoAP request handling
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _COAP_SERVER_REQUEST_H
32 #define _COAP_SERVER_REQUEST_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "coap/coap_server.h"
37 #include "coap/coap_option.h"
38 
39 //C++ guard
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
45 
47  size_t maxLen);
48 
50  size_t maxLen);
51 
52 error_t coapServerGetOpaqueOption(CoapServerContext *context, uint16_t optionNum,
53  uint_t optionIndex, const uint8_t **optionValue, size_t *optionLen);
54 
55 error_t coapServerGetStringOption(CoapServerContext *context, uint16_t optionNum,
56  uint_t optionIndex, const char_t **optionValue, size_t *optionLen);
57 
58 error_t coapServerGetUintOption(CoapServerContext *context, uint16_t optionNum,
59  uint_t optionIndex, uint32_t *optionValue);
60 
61 error_t coapServerGetPayload(CoapServerContext *context, const uint8_t **payload,
62  size_t *payloadLen);
63 
64 error_t coapServerReadPayload(CoapServerContext *context, void *data, size_t size,
65  size_t *length);
66 
68 
70  const char_t *path);
71 
73  const char_t *queryString);
74 
75 error_t coapServerSetOpaqueOption(CoapServerContext *context, uint16_t optionNum,
76  uint_t optionIndex, const uint8_t *optionValue, size_t optionLen);
77 
78 error_t coapServerSetStringOption(CoapServerContext *context, uint16_t optionNum,
79  uint_t optionIndex, const char_t *optionValue);
80 
81 error_t coapServerSetUintOption(CoapServerContext *context, uint16_t optionNum,
82  uint_t optionIndex, uint32_t optionValue);
83 
84 error_t coapServerDeleteOption(CoapServerContext *context, uint16_t optionNum,
85  uint_t optionIndex);
86 
88  size_t payloadLen);
89 
91  size_t length);
92 
93 //C++ guard
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
uint8_t code
Definition: coap_common.h:179
CoapCode
CoAP method and response codes.
Definition: coap_common.h:113
Formatting and parsing of CoAP options.
CoAP server.
#define CoapServerContext
Definition: coap_server.h:121
error_t coapServerReadPayload(CoapServerContext *context, void *data, size_t size, size_t *length)
Read request payload data.
error_t coapServerGetOpaqueOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, const uint8_t **optionValue, size_t *optionLen)
Read an opaque option from the CoAP request.
error_t coapServerGetUriQuery(CoapServerContext *context, char_t *queryString, size_t maxLen)
Get Uri-Query option.
error_t coapServerGetUintOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, uint32_t *optionValue)
Read an uint option from the CoAP request.
error_t coapServerSetLocationQuery(CoapServerContext *context, const char_t *queryString)
Set Location-Query option.
error_t coapServerSetPayload(CoapServerContext *context, const void *payload, size_t payloadLen)
Set response payload.
error_t coapServerSetResponseCode(CoapServerContext *context, CoapCode code)
Set response method.
error_t coapServerGetUriPath(CoapServerContext *context, char_t *path, size_t maxLen)
Get Uri-Path option.
error_t coapServerGetMethodCode(CoapServerContext *context, CoapCode *code)
Get request method.
error_t coapServerSetLocationPath(CoapServerContext *context, const char_t *path)
Set Location-Path option.
error_t coapServerGetStringOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, const char_t **optionValue, size_t *optionLen)
Read a string option from the CoAP request.
error_t coapServerSetUintOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, uint32_t optionValue)
Add a uint option to the CoAP response.
error_t coapServerGetPayload(CoapServerContext *context, const uint8_t **payload, size_t *payloadLen)
Get request payload.
error_t coapServerSetStringOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, const char_t *optionValue)
Add a string option to the CoAP response.
error_t coapServerDeleteOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex)
Remove an option from the CoAP response.
error_t coapServerSetOpaqueOption(CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, const uint8_t *optionValue, size_t optionLen)
Add an opaque option to the CoAP response.
error_t coapServerWritePayload(CoapServerContext *context, const void *data, size_t length)
Write payload data.
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
error_t
Error codes.
Definition: error.h:43
uint8_t data[]
Definition: ethernet.h:222
uint8_t payload[]
Definition: ipv6.h:277
uint16_t payloadLen
Definition: ipv6.h:272
TCP/IP stack core.
uint8_t length
Definition: tcp.h:368