Formatting and parsing of CoAP options. More...
#include "core/net.h"#include "coap/coap_client.h"#include "coap/coap_server.h"#include "coap/coap_option.h"#include "debug.h"Go to the source code of this file.
| Macros | |
| #define | TRACE_LEVEL COAP_TRACE_LEVEL | 
| Functions | |
| error_t | coapParseOptions (const uint8_t *p, size_t length, size_t *consumed) | 
| Parse the list of CoAP options.  More... | |
| error_t | coapParseOption (const uint8_t *p, size_t length, uint16_t prevOptionNum, CoapOption *option, size_t *consumed) | 
| Parse CoAP option.  More... | |
| error_t | coapFormatOption (uint8_t *p, uint16_t prevOptionNum, CoapOption *option, size_t *written) | 
| Format CoAP option.  More... | |
| error_t | coapSetOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex, const uint8_t *optionValue, size_t optionLen) | 
| Add an option to the specified CoAP message.  More... | |
| error_t | coapSetUintOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex, uint32_t optionValue) | 
| Add a uint option to the specified CoAP message.  More... | |
| error_t | coapGetOption (const CoapMessage *message, uint16_t optionNum, uint_t optionIndex, const uint8_t **optionValue, size_t *optionLen) | 
| Get the value of the specified option.  More... | |
| error_t | coapGetUintOption (const CoapMessage *message, uint16_t optionNum, uint_t optionIndex, uint32_t *optionValue) | 
| Get the value of the specified uint option.  More... | |
| error_t | coapDeleteOption (CoapMessage *message, uint16_t optionNum, uint_t optionIndex) | 
| Remove an option from the specified CoAP message.  More... | |
| error_t | coapSplitRepeatableOption (CoapMessage *message, uint16_t optionNum, const char_t *optionValue, char_t separator) | 
| Encode a path or query component into multiple repeatable options.  More... | |
| error_t | coapJoinRepeatableOption (const CoapMessage *message, uint16_t optionNum, char_t *optionValue, size_t maxLen, char_t separator) | 
| Decode a path or query component from multiple repeatable options.  More... | |
| const CoapOptionParameters * | coapGetOptionParameters (uint16_t optionNum) | 
| Retrieve parameters for a given option number.  More... | |
| Variables | |
| const CoapOptionParameters | coapOptionList [] | 
| List of supported CoAP options.  More... | |
Detailed Description
Formatting and parsing of CoAP options.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 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.
- Version
- 2.5.4
Definition in file coap_option.c.
Macro Definition Documentation
◆ TRACE_LEVEL
| #define TRACE_LEVEL COAP_TRACE_LEVEL | 
Definition at line 32 of file coap_option.c.
Function Documentation
◆ coapDeleteOption()
| error_t coapDeleteOption | ( | CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| uint_t | optionIndex | ||
| ) | 
Remove an option from the specified CoAP message.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) 
- Returns
- Error code
Definition at line 688 of file coap_option.c.
◆ coapFormatOption()
| error_t coapFormatOption | ( | uint8_t * | p, | 
| uint16_t | prevOptionNum, | ||
| CoapOption * | option, | ||
| size_t * | written | ||
| ) | 
Format CoAP option.
- Parameters
- 
  [in] p Buffer where to format the CoAP option (optional parameter) [in] prevOptionNum Option number of the previous instance [in] option CoAP option content [out] written Total number of bytes that have been written 
- Returns
- Error code
Definition at line 262 of file coap_option.c.
◆ coapGetOption()
| error_t coapGetOption | ( | const CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| uint_t | optionIndex, | ||
| const uint8_t ** | optionValue, | ||
| size_t * | optionLen | ||
| ) | 
Get the value of the specified option.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) [out] optionValue Pointer to the first byte of the option value [out] optionLen Length of the option, in bytes 
- Returns
- Error code
Definition at line 571 of file coap_option.c.
◆ coapGetOptionParameters()
| const CoapOptionParameters* coapGetOptionParameters | ( | uint16_t | optionNum | ) | 
Retrieve parameters for a given option number.
- Parameters
- 
  [in] optionNum Option number 
- Returns
- Option parameters
Definition at line 950 of file coap_option.c.
◆ coapGetUintOption()
| error_t coapGetUintOption | ( | const CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| uint_t | optionIndex, | ||
| uint32_t * | optionValue | ||
| ) | 
Get the value of the specified uint option.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number to search for [in] optionIndex Occurrence index (for repeatable options only) [out] optionValue Option value (unsigned integer) 
- Returns
- Error code
Definition at line 651 of file coap_option.c.
◆ coapJoinRepeatableOption()
| error_t coapJoinRepeatableOption | ( | const CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| char_t * | optionValue, | ||
| size_t | maxLen, | ||
| char_t | separator | ||
| ) | 
Decode a path or query component from multiple repeatable options.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number [out] optionValue Buffer where to copy the path or query component [in] maxLen Maximum number of characters the buffer can hold [in] separator Delimiting character 
- Returns
- Error code
Definition at line 877 of file coap_option.c.
◆ coapParseOption()
| error_t coapParseOption | ( | const uint8_t * | p, | 
| size_t | length, | ||
| uint16_t | prevOptionNum, | ||
| CoapOption * | option, | ||
| size_t * | consumed | ||
| ) | 
Parse CoAP option.
- Parameters
- 
  [in] p Input stream where to read the CoAP option [in] length Number of bytes available in the input stream [in] prevOptionNum Option number of the previous instance [out] option CoAP option content [out] consumed Total number of bytes that have been consumed 
- Returns
- Error code
Definition at line 133 of file coap_option.c.
◆ coapParseOptions()
| error_t coapParseOptions | ( | const uint8_t * | p, | 
| size_t | length, | ||
| size_t * | consumed | ||
| ) | 
Parse the list of CoAP options.
- Parameters
- 
  [in] p Input stream where to read the CoAP options [in] length Number of bytes available in the input stream [out] consumed Total number of bytes that have been consumed 
- Returns
- Error code
Definition at line 81 of file coap_option.c.
◆ coapSetOption()
| error_t coapSetOption | ( | CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| uint_t | optionIndex, | ||
| const uint8_t * | optionValue, | ||
| size_t | optionLen | ||
| ) | 
Add an option to the specified CoAP message.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) [in] optionValue Pointer to the first byte of the option value [in] optionLen Length of the option, in bytes 
- Returns
- Error code
Definition at line 388 of file coap_option.c.
◆ coapSetUintOption()
| error_t coapSetUintOption | ( | CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| uint_t | optionIndex, | ||
| uint32_t | optionValue | ||
| ) | 
Add a uint option to the specified CoAP message.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number [in] optionIndex Occurrence index (for repeatable options only) [in] optionValue Option value (unsigned integer) 
- Returns
- Error code
Definition at line 543 of file coap_option.c.
◆ coapSplitRepeatableOption()
| error_t coapSplitRepeatableOption | ( | CoapMessage * | message, | 
| uint16_t | optionNum, | ||
| const char_t * | optionValue, | ||
| char_t | separator | ||
| ) | 
Encode a path or query component into multiple repeatable options.
- Parameters
- 
  [in] message Pointer to the CoAP message [in] optionNum Option number [in] optionValue Path or a query component to be encoded [in] separator Delimiting character 
- Returns
- Error code
Definition at line 822 of file coap_option.c.
Variable Documentation
◆ coapOptionList
| const CoapOptionParameters coapOptionList[] | 
List of supported CoAP options.
Definition at line 49 of file coap_option.c.
