Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
coap.h File Reference
CoAP Message Parsing. More...
Go to the source code of this file.
Data Structures | |
| struct | coap_pdu |
| Packet Data Unit. More... | |
| struct | coap_option |
| CoAP Option. More... | |
| struct | coap_payload |
| CoAP Payload. More... | |
Typedefs | |
| typedef enum coap_error | coap_error |
| Status Codes. | |
| typedef enum coap_version | coap_version |
| Protocol Versions. | |
| typedef enum coap_type | coap_type |
| Message Types. | |
| typedef enum coap_code | coap_code |
| Message Codes. | |
| typedef enum coap_option_number | coap_option_number |
| Option Numbers. | |
| typedef struct coap_pdu | coap_pdu |
| Packet Data Unit. | |
| typedef struct coap_option | coap_option |
| CoAP Option. | |
| typedef struct coap_payload | coap_payload |
| CoAP Payload. | |
Enumerations | |
| enum | coap_error |
Status Codes. More... | |
| enum | coap_version |
Protocol Versions. More... | |
| enum | coap_type |
Message Types. More... | |
| enum | coap_code |
Message Codes. More... | |
| enum | coap_option_number |
Option Numbers. More... | |
Functions | |
| coap_error | coap_validate_pkt (coap_pdu *pdu) |
| Validate Packet. | |
| static coap_version | coap_get_version (coap_pdu *pdu) |
| Get Version. | |
| static coap_type | coap_get_type (coap_pdu *pdu) |
| Get Message Type. | |
| static uint8_t | coap_get_tkl (coap_pdu *pdu) |
| Get Token Length. | |
| static coap_code | coap_get_code (coap_pdu *pdu) |
| Get Message Code. | |
| static uint8_t | coap_get_code_class (coap_pdu *pdu) |
| Get Message Code Class. | |
| static uint8_t | coap_get_code_detail (coap_pdu *pdu) |
| Get Message Code Detail. | |
| static uint16_t | coap_get_mid (coap_pdu *pdu) |
| Get Message ID. | |
| uint64_t | coap_get_token (coap_pdu *pdu) |
| Get Message Token. | |
| coap_option | coap_get_option (coap_pdu *pdu, coap_option *last) |
| Get Option. | |
| coap_option | coap_get_option_by_num (coap_pdu *pdu, coap_option_number num, uint8_t occ) |
| Get Option by Option Number. | |
| coap_payload | coap_get_payload (coap_pdu *pdu) |
| Get Option. | |
| coap_error | coap_decode_option (uint8_t *pkt_ptr, size_t pkt_len, uint16_t *option_number, size_t *option_length, uint8_t **value) |
| Internal Method. | |
| coap_error | coap_init_pdu (coap_pdu *pdu) |
| Initialize Packet. | |
| coap_error | coap_set_version (coap_pdu *pdu, coap_version ver) |
| Set Version. | |
| coap_error | coap_set_type (coap_pdu *pdu, coap_type mtype) |
| Set Message Type. | |
| coap_error | coap_set_code (coap_pdu *pdu, coap_code code) |
| Set Message Code. | |
| coap_error | coap_set_mid (coap_pdu *pdu, uint16_t mid) |
| Set Message ID. | |
| coap_error | coap_set_token (coap_pdu *pdu, uint64_t token, uint8_t tkl) |
| Set Message Token. | |
| coap_error | coap_add_option (coap_pdu *pdu, int32_t opt_num, uint8_t *value, uint16_t opt_len) |
| Add Message Option. | |
| coap_error | coap_set_payload (coap_pdu *pdu, uint8_t *payload, size_t payload_len) |
| Add Message Option. | |
| static uint8_t | coap_build_code (uint8_t _class, uint8_t detail) |
| Build Message Code from Class and Detail. | |
| coap_error | coap_adjust_option_deltas (uint8_t *opts, size_t *opts_len, size_t max_len, int32_t offset) |
| Internal Method. | |
| int8_t | coap_build_option_header (uint8_t *buf, size_t max_len, int32_t opt_delta, int32_t opt_len) |
| Internal Method. | |
| int8_t | coap_compute_option_header_len (int32_t opt_delta, int32_t opt_len) |
| Internal Method. | |
Detailed Description
CoAP Message Parsing.
- Date:
- 2014-07-10
This file provides functions for parsing and building CoAP message packets using only the actual binary of the message, not needing additional memory for secondary data structures.
Definition in file coap.h.
Typedef Documentation
| typedef enum coap_error coap_error |
Status Codes.
These codes represent the possible errors that functions in this library can return.
| typedef struct coap_option coap_option |
CoAP Option.
One option in a CoAP message.
| typedef enum coap_option_number coap_option_number |
Option Numbers.
All known option numbers.
| typedef struct coap_payload coap_payload |
CoAP Payload.
Payload container.
Packet Data Unit.
This contains all information about the message buffer.
| typedef enum coap_version coap_version |
Protocol Versions.
All known version of the protocol.
Enumeration Type Documentation
| enum coap_code |
| enum coap_error |
| enum coap_option_number |
| enum coap_type |
| enum coap_version |
Function Documentation
| coap_error coap_add_option | ( | coap_pdu * | pdu, |
| int32_t | opt_num, | ||
| uint8_t * | value, | ||
| uint16_t | opt_len | ||
| ) |
Add Message Option.
Adds an option to the existing message. Options SHOULD be added in order of option number. In the case of multiple options of the same type, they are sorted in the order that they are added.
- Parameters:
-
[in,out] pdu pointer to the coap message struct. [in] opt option container.
- Returns:
- coap_error (0 == no error)
| coap_error coap_adjust_option_deltas | ( | uint8_t * | opts, |
| size_t * | opts_len, | ||
| size_t | max_len, | ||
| int32_t | offset | ||
| ) |
| static uint8_t coap_build_code | ( | uint8_t | _class, |
| uint8_t | detail | ||
| ) | [static] |
Build Message Code from Class and Detail.
Gets the class portion of the message code.
- Parameters:
-
[in] class the code class. [in] detail the code detail.
- See also:
- coap_get_code
| int8_t coap_build_option_header | ( | uint8_t * | buf, |
| size_t | max_len, | ||
| int32_t | opt_delta, | ||
| int32_t | opt_len | ||
| ) |
| int8_t coap_compute_option_header_len | ( | int32_t | opt_delta, |
| int32_t | opt_len | ||
| ) |
| coap_error coap_decode_option | ( | uint8_t * | pkt_ptr, |
| size_t | pkt_len, | ||
| uint16_t * | option_number, | ||
| size_t * | option_length, | ||
| uint8_t ** | value | ||
| ) |
| static uint8_t coap_get_code_class | ( | coap_pdu * | pdu ) | [static] |
Get Message Code Class.
Gets the class portion of the message code.
- Parameters:
-
[in] pdu pointer to the coap message struct.
- See also:
- coap_get_code
| static uint8_t coap_get_code_detail | ( | coap_pdu * | pdu ) | [static] |
Get Message Code Detail.
Gets the detail portion of the message code.
- Parameters:
-
[in] pdu pointer to the coap message struct.
- See also:
- coap_get_code
| static uint16_t coap_get_mid | ( | coap_pdu * | pdu ) | [static] |
| coap_option coap_get_option | ( | coap_pdu * | pdu, |
| coap_option * | last | ||
| ) |
Get Option.
Iterates over the options in the given message.
- Parameters:
-
[in] pdu pointer to the coap message struct. [in,out] pointer to the last/next option, pass 0 for the first option.
- Returns:
- coap_option
| coap_option coap_get_option_by_num | ( | coap_pdu * | pdu, |
| coap_option_number | num, | ||
| uint8_t | occ | ||
| ) |
Get Option by Option Number.
Gets a single specified by the option number and index of which occurrence of that option number you'd like.
- Parameters:
-
[in] pdu pointer to the coap message struct. [in] num option number to get. [in] occ occurrence of to get (0th, 1st, 2nd, etc) 0 for the first option.
- Returns:
- coap_option
| coap_payload coap_get_payload | ( | coap_pdu * | pdu ) |
Get Option.
Extracts the option with the given index in the given message.
- Parameters:
-
[in] pdu pointer to the coap message struct.
- Returns:
- coap_payload
| static uint8_t coap_get_tkl | ( | coap_pdu * | pdu ) | [static] |
| uint64_t coap_get_token | ( | coap_pdu * | pdu ) |
| static coap_version coap_get_version | ( | coap_pdu * | pdu ) | [static] |
Get Version.
Extracts the CoAP version from the given message.
- Parameters:
-
[in] pdu pointer to the coap message struct.
- Returns:
- version.
- See also:
- coap_version
| coap_error coap_init_pdu | ( | coap_pdu * | pdu ) |
Initialize Packet.
Initializes on an empty buffer for creating new CoAP packets. This function (or coap_validate for parsing packets) must be called and must return CE_NONE before you can use any of the getters or setter. The packet is initialized to a CoAP Ping.
- Parameters:
-
[in,out] pdu pointer to the coap message struct.
- Returns:
- coap_error (0 == no error)
| coap_error coap_set_code | ( | coap_pdu * | pdu, |
| coap_code | code | ||
| ) |
| coap_error coap_set_mid | ( | coap_pdu * | pdu, |
| uint16_t | mid | ||
| ) |
| coap_error coap_set_payload | ( | coap_pdu * | pdu, |
| uint8_t * | payload, | ||
| size_t | payload_len | ||
| ) |
| coap_error coap_set_token | ( | coap_pdu * | pdu, |
| uint64_t | token, | ||
| uint8_t | tkl | ||
| ) |
| coap_error coap_set_type | ( | coap_pdu * | pdu, |
| coap_type | mtype | ||
| ) |
| coap_error coap_set_version | ( | coap_pdu * | pdu, |
| coap_version | ver | ||
| ) |
Set Version.
Sets the version number header field.
- Parameters:
-
[in,out] pdu pointer to the coap message struct. [in] ver version to set. Must be COAP_V1.
- Returns:
- coap_error (0 == no error)
- See also:
- coap_version
| coap_error coap_validate_pkt | ( | coap_pdu * | pdu ) |
Validate Packet.
Parses the given packet to check if it is a valid CoAP message. This function (or coap_init_pdu for creating new packets) must be called and must return CE_NONE before you can use any of the getters or setter.
- Parameters:
-
[in] pdu pointer to the coap message struct.
- Returns:
- error code (CE_NONE == 0 == no error).
- See also:
- coap_error
- coap_init_pdu
Generated on Tue Jul 12 2022 18:09:07 by
1.7.2