coap_server_request.h File Reference

CoAP request handling. More...

#include "core/net.h"
#include "coap/coap_server.h"
#include "coap/coap_option.h"

Go to the source code of this file.

Functions

error_t coapServerGetMethodCode (CoapServerContext *context, CoapCode *code)
 Get request method. More...
 
error_t coapServerGetUriPath (CoapServerContext *context, char_t *path, size_t maxLen)
 Get Uri-Path option. More...
 
error_t coapServerGetUriQuery (CoapServerContext *context, char_t *queryString, size_t maxLen)
 Get Uri-Query option. More...
 
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. More...
 
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. More...
 
error_t coapServerGetUintOption (CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, uint32_t *optionValue)
 Read an uint option from the CoAP request. More...
 
error_t coapServerGetPayload (CoapServerContext *context, const uint8_t **payload, size_t *payloadLen)
 Get request payload. More...
 
error_t coapServerReadPayload (CoapServerContext *context, void *data, size_t size, size_t *length)
 Read request payload data. More...
 
error_t coapServerSetResponseCode (CoapServerContext *context, CoapCode code)
 Set response method. More...
 
error_t coapServerSetLocationPath (CoapServerContext *context, const char_t *path)
 Set Location-Path option. More...
 
error_t coapServerSetLocationQuery (CoapServerContext *context, const char_t *queryString)
 Set Location-Query option. More...
 
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. More...
 
error_t coapServerSetStringOption (CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, const char_t *optionValue)
 Add a string option to the CoAP response. More...
 
error_t coapServerSetUintOption (CoapServerContext *context, uint16_t optionNum, uint_t optionIndex, uint32_t optionValue)
 Add a uint option to the CoAP response. More...
 
error_t coapServerDeleteOption (CoapServerContext *context, uint16_t optionNum, uint_t optionIndex)
 Remove an option from the CoAP response. More...
 
error_t coapServerSetPayload (CoapServerContext *context, const void *payload, size_t payloadLen)
 Set response payload. More...
 
error_t coapServerWritePayload (CoapServerContext *context, const void *data, size_t length)
 Write payload data. More...
 

Detailed Description

CoAP request handling.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file coap_server_request.h.

Function Documentation

◆ coapServerDeleteOption()

error_t coapServerDeleteOption ( CoapServerContext context,
uint16_t  optionNum,
uint_t  optionIndex 
)

Remove an option from the CoAP response.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number
[in]optionIndexOccurrence index (for repeatable options only)
Returns
Error code

Definition at line 354 of file coap_server_request.c.

◆ coapServerGetMethodCode()

error_t coapServerGetMethodCode ( CoapServerContext context,
CoapCode code 
)

Get request method.

Parameters
[in]contextPointer to the CoAP server context
[out]codeMethod code (GET, POST, PUT or DELETE)
Returns
Error code

Definition at line 50 of file coap_server_request.c.

◆ coapServerGetOpaqueOption()

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.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number to search for
[in]optionIndexOccurrence index (for repeatable options only)
[out]optionValuePointer to the first byte of the option value
[out]optionLenLength of the option, in bytes
Returns
Error code

Definition at line 113 of file coap_server_request.c.

◆ coapServerGetPayload()

error_t coapServerGetPayload ( CoapServerContext context,
const uint8_t **  payload,
size_t *  payloadLen 
)

Get request payload.

Parameters
[in]contextPointer to the CoAP server context
[out]payloadPointer to the first byte of the payload
[out]payloadLenLength of the payload, in bytes
Returns
Error code

Definition at line 179 of file coap_server_request.c.

◆ coapServerGetStringOption()

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.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number to search for
[in]optionIndexOccurrence index (for repeatable options only)
[out]optionValuePointer to the first byte of the option value
[out]optionLenLength of the option, in characters
Returns
Error code

Definition at line 136 of file coap_server_request.c.

◆ coapServerGetUintOption()

error_t coapServerGetUintOption ( CoapServerContext context,
uint16_t  optionNum,
uint_t  optionIndex,
uint32_t *  optionValue 
)

Read an uint option from the CoAP request.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number to search for
[in]optionIndexOccurrence index (for repeatable options only)
[out]optionValueOption value (unsigned integer)
Returns
Error code

Definition at line 158 of file coap_server_request.c.

◆ coapServerGetUriPath()

error_t coapServerGetUriPath ( CoapServerContext context,
char_t path,
size_t  maxLen 
)

Get Uri-Path option.

Parameters
[in]contextPointer to the CoAP server context
[out]pathPointer to the buffer where to copy the path component
[in]maxLenMaximum number of characters the buffer can hold
Returns
Error code

Definition at line 69 of file coap_server_request.c.

◆ coapServerGetUriQuery()

error_t coapServerGetUriQuery ( CoapServerContext context,
char_t queryString,
size_t  maxLen 
)

Get Uri-Query option.

Parameters
[in]contextPointer to the CoAP server context
[out]queryStringPointer to the buffer where to copy the query string
[in]maxLenMaximum number of characters the buffer can hold
Returns
Error code

Definition at line 90 of file coap_server_request.c.

◆ coapServerReadPayload()

error_t coapServerReadPayload ( CoapServerContext context,
void *  data,
size_t  size,
size_t *  length 
)

Read request payload data.

Parameters
[in]contextPointer to the CoAP server context
[out]dataBuffer into which received data will be placed
[in]sizeMaximum number of bytes that can be received
[out]lengthNumber of bytes that have been received
Returns
Error code

Definition at line 200 of file coap_server_request.c.

◆ coapServerSetLocationPath()

error_t coapServerSetLocationPath ( CoapServerContext context,
const char_t path 
)

Set Location-Path option.

Parameters
[in]contextPointer to the CoAP server context
[in]pathNULL-terminated string that contains the path component
Returns
Error code

Definition at line 237 of file coap_server_request.c.

◆ coapServerSetLocationQuery()

error_t coapServerSetLocationQuery ( CoapServerContext context,
const char_t queryString 
)

Set Location-Query option.

Parameters
[in]contextPointer to the CoAP server context
[in]queryStringNULL-terminated string that contains the query string
Returns
Error code

Definition at line 257 of file coap_server_request.c.

◆ coapServerSetOpaqueOption()

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.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number
[in]optionIndexOccurrence index (for repeatable options only)
[in]optionValuePointer to the first byte of the option value
[in]optionLenLength of the option, in bytes
Returns
Error code

Definition at line 280 of file coap_server_request.c.

◆ coapServerSetPayload()

error_t coapServerSetPayload ( CoapServerContext context,
const void *  payload,
size_t  payloadLen 
)

Set response payload.

Parameters
[in]contextPointer to the CoAP server context
[out]payloadPointer to request payload
[out]payloadLenLength of the payload, in bytes
Returns
Error code

Definition at line 374 of file coap_server_request.c.

◆ coapServerSetResponseCode()

error_t coapServerSetResponseCode ( CoapServerContext context,
CoapCode  code 
)

Set response method.

Parameters
[in]contextPointer to the CoAP server context
[in]codeResponse code
Returns
Error code

Definition at line 219 of file coap_server_request.c.

◆ coapServerSetStringOption()

error_t coapServerSetStringOption ( CoapServerContext context,
uint16_t  optionNum,
uint_t  optionIndex,
const char_t optionValue 
)

Add a string option to the CoAP response.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number
[in]optionIndexOccurrence index (for repeatable options only)
[in]optionValueNULL-terminated string that contains the option value
Returns
Error code

Definition at line 306 of file coap_server_request.c.

◆ coapServerSetUintOption()

error_t coapServerSetUintOption ( CoapServerContext context,
uint16_t  optionNum,
uint_t  optionIndex,
uint32_t  optionValue 
)

Add a uint option to the CoAP response.

Parameters
[in]contextPointer to the CoAP server context
[in]optionNumOption number
[in]optionIndexOccurrence index (for repeatable options only)
[in]optionValueOption value (unsigned integer)
Returns
Error code

Definition at line 333 of file coap_server_request.c.

◆ coapServerWritePayload()

error_t coapServerWritePayload ( CoapServerContext context,
const void *  data,
size_t  length 
)

Write payload data.

Parameters
[in]contextPointer to the CoAP server context
[in]dataPointer to a buffer containing the data to be written
[in]lengthNumber of bytes to written
Returns
Error code

Definition at line 398 of file coap_server_request.c.