|
libschc
|
#include <stdint.h>#include <stddef.h>Go to the source code of this file.
Classes | |
| struct | pcoap_option_names |
| struct | pcoap_pdu |
| Packet Data Unit. More... | |
| struct | pcoap_option |
| CoAP Option. More... | |
| struct | pcoap_payload |
| CoAP Payload. More... | |
Macros | |
| #define | COAP_ACK_TIMEOUT 2 |
| CoAP Defined Parameters. More... | |
| #define | COAP_ACK_RANDOM_FACTOR 1.5 |
| #define | COAP_MAX_RETRANSMIT 4 |
| #define | COAP_NSTART 1 |
| #define | COAP_DEFAULT_LEISURE 5 |
| #define | COAP_PROBING_RATE 1 |
| #define | COAP_MAX_TRANSMIT_SPAN 45 |
| #define | COAP_MAX_TRANSMIT_WAIT 93 |
| #define | COAP_MAX_LATENCY 100 |
| #define | COAP_PROCESSING_DELAY 2 |
| #define | COAP_MAX_RTT 202 |
| #define | COAP_EXCHANGE_LIFETIME 247 |
| #define | COAP_NON_LIFETIME 145 |
| #define | COAP_OPTIONS_LENGTH 16 |
Typedefs | |
| typedef enum coap_error | pcoap_error |
| Status Codes. More... | |
| typedef enum coap_version | pcoap_version |
| Protocol Versions. More... | |
| typedef enum coap_type | pcoap_type |
| Message Types. More... | |
| typedef enum pcoap_code | pcoap_code |
| Message Codes. More... | |
| typedef enum pcoap_option_number | pcoap_option_number |
| Option Numbers. More... | |
| typedef struct pcoap_pdu | pcoap_pdu |
| Packet Data Unit. More... | |
| typedef struct pcoap_option | pcoap_option |
| CoAP Option. More... | |
| typedef struct pcoap_payload | pcoap_payload |
| CoAP Payload. More... | |
Functions | |
| uint8_t | pcoap_get_coap_offset (pcoap_pdu *pdu) |
| Finds the length of the CoAP header. More... | |
| pcoap_error | pcoap_validate_pkt (pcoap_pdu *pdu) |
| Validate Packet. More... | |
| static pcoap_version | pcoap_get_version (pcoap_pdu *pdu) |
| Get Version. More... | |
| static pcoap_type | pcoap_get_type (pcoap_pdu *pdu) |
| Get Message Type. More... | |
| static uint8_t | pcoap_get_tkl (pcoap_pdu *pdu) |
| Get Token Length. More... | |
| static pcoap_code | pcoap_get_code (pcoap_pdu *pdu) |
| Get Message Code. More... | |
| static uint8_t | pcoap_get_code_class (pcoap_pdu *pdu) |
| Get Message Code Class. More... | |
| static uint8_t | pcoap_get_code_detail (pcoap_pdu *pdu) |
| Get Message Code Detail. More... | |
| static uint16_t | pcoap_get_mid (pcoap_pdu *pdu) |
| Get Message ID. More... | |
| uint8_t | pcoap_get_token (pcoap_pdu *pdu, uint8_t *ptr) |
| Get Message Token. More... | |
| pcoap_option | pcoap_get_option (pcoap_pdu *pdu, pcoap_option *last) |
| Get Option. More... | |
| pcoap_option | pcoap_get_option_by_num (pcoap_pdu *pdu, pcoap_option_number num, uint8_t occ) |
| Get Option by Option Number. More... | |
| pcoap_payload | pcoap_get_payload (pcoap_pdu *pdu) |
| Get Option. More... | |
| pcoap_error | pcoap_decode_option (uint8_t *pkt_ptr, size_t pkt_len, uint16_t *option_number, size_t *option_length, uint8_t **value) |
| Internal Method. More... | |
| pcoap_error | pcoap_init_pdu (pcoap_pdu *pdu) |
| Initialize Packet. More... | |
| pcoap_error | pcoap_set_version (pcoap_pdu *pdu, pcoap_version ver) |
| Set Version. More... | |
| pcoap_error | pcoap_set_type (pcoap_pdu *pdu, pcoap_type mtype) |
| Set Message Type. More... | |
| pcoap_error | pcoap_set_code (pcoap_pdu *pdu, pcoap_code code) |
| Set Message Code. More... | |
| pcoap_error | pcoap_set_mid (pcoap_pdu *pdu, uint16_t mid) |
| Set Message ID. More... | |
| pcoap_error | pcoap_set_token (pcoap_pdu *pdu, uint8_t *token, uint8_t tkl) |
| Set Message Token. More... | |
| pcoap_error | pcoap_add_option (pcoap_pdu *pdu, int32_t opt_num, uint8_t *value, uint16_t opt_len) |
| Add Message Option. More... | |
| pcoap_error | pcoap_set_payload (pcoap_pdu *pdu, uint8_t *payload, size_t payload_len) |
| Add Message Option. More... | |
| static uint8_t | pcoap_build_code (uint8_t _class, uint8_t detail) |
| Build Message Code from Class and Detail. More... | |
| pcoap_error | pcoap_adjust_option_deltas (uint8_t *opts, size_t *opts_len, size_t max_len, int32_t offset) |
| Internal Method. More... | |
| int8_t | pcoap_build_option_header (uint8_t *buf, size_t max_len, int32_t opt_delta, int32_t opt_len) |
| Internal Method. More... | |
| int8_t | pcoap_compute_option_header_len (int32_t opt_delta, int32_t opt_len) |
| Internal Method. More... | |
Variables | |
| static struct pcoap_option_names | coap_options [COAP_OPTIONS_LENGTH] |
| #define COAP_ACK_RANDOM_FACTOR 1.5 |
| #define COAP_ACK_TIMEOUT 2 |
CoAP Defined Parameters.
| #define COAP_DEFAULT_LEISURE 5 |
| #define COAP_EXCHANGE_LIFETIME 247 |
| #define COAP_MAX_LATENCY 100 |
| #define COAP_MAX_RETRANSMIT 4 |
| #define COAP_MAX_RTT 202 |
| #define COAP_MAX_TRANSMIT_SPAN 45 |
| #define COAP_MAX_TRANSMIT_WAIT 93 |
| #define COAP_NON_LIFETIME 145 |
| #define COAP_NSTART 1 |
| #define COAP_OPTIONS_LENGTH 16 |
| #define COAP_PROBING_RATE 1 |
| #define COAP_PROCESSING_DELAY 2 |
| typedef enum pcoap_code pcoap_code |
Message Codes.
All known message request/response codes.
| typedef enum coap_error pcoap_error |
Status Codes.
These codes represent the possible errors that functions in this library can return.
| typedef struct pcoap_option pcoap_option |
CoAP Option.
One option in a CoAP message.
| typedef enum pcoap_option_number pcoap_option_number |
Option Numbers.
All known option numbers.
| typedef struct pcoap_payload pcoap_payload |
CoAP Payload.
Payload container.
Packet Data Unit.
This contains all information about the message buffer.
| typedef enum coap_type pcoap_type |
Message Types.
The four types of messages possible.
| typedef enum coap_version pcoap_version |
Protocol Versions.
All known version of the protocol.
| enum coap_error |
Status Codes.
These codes represent the possible errors that functions in this library can return.
| enum coap_type |
| enum coap_version |
| enum pcoap_code |
Message Codes.
All known message request/response codes.
| enum pcoap_option_number |
| pcoap_error pcoap_add_option | ( | pcoap_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.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | opt | option container. |
| pcoap_error pcoap_adjust_option_deltas | ( | uint8_t * | opts, |
| size_t * | opts_len, | ||
| size_t | max_len, | ||
| int32_t | offset | ||
| ) |
Internal Method.
|
inlinestatic |
Build Message Code from Class and Detail.
Gets the class portion of the message code.
| [in] | class | the code class. |
| [in] | detail | the code detail. |
| int8_t pcoap_build_option_header | ( | uint8_t * | buf, |
| size_t | max_len, | ||
| int32_t | opt_delta, | ||
| int32_t | opt_len | ||
| ) |
Internal Method.
| int8_t pcoap_compute_option_header_len | ( | int32_t | opt_delta, |
| int32_t | opt_len | ||
| ) |
Internal Method.
| pcoap_error pcoap_decode_option | ( | uint8_t * | pkt_ptr, |
| size_t | pkt_len, | ||
| uint16_t * | option_number, | ||
| size_t * | option_length, | ||
| uint8_t ** | value | ||
| ) |
Internal Method.
| uint8_t pcoap_get_coap_offset | ( | pcoap_pdu * | pdu | ) |
Finds the length of the CoAP header.
| pdu | the CoAP pdu, containing the header and payload |
|
inlinestatic |
Get Message Code.
Extracts the message code from the given message.
| [in] | pdu | pointer to the coap message struct. |
|
inlinestatic |
Get Message Code Class.
Gets the class portion of the message code.
| [in] | pdu | pointer to the coap message struct. |
|
inlinestatic |
Get Message Code Detail.
Gets the detail portion of the message code.
| [in] | pdu | pointer to the coap message struct. |
|
inlinestatic |
Get Message ID.
Extracts the message ID from the given message.
| [in] | pdu | pointer to the coap message struct. |
| pcoap_option pcoap_get_option | ( | pcoap_pdu * | pdu, |
| pcoap_option * | last | ||
| ) |
Get Option.
Iterates over the options in the given message.
| [in] | pdu | pointer to the coap message struct. |
| [in,out] | pointer | to the last/next option, pass 0 for the first option. |
| pcoap_option pcoap_get_option_by_num | ( | pcoap_pdu * | pdu, |
| pcoap_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.
| [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. |
| pcoap_payload pcoap_get_payload | ( | pcoap_pdu * | pdu | ) |
Get Option.
Extracts the option with the given index in the given message.
| [in] | pdu | pointer to the coap message struct. |
|
inlinestatic |
Get Token Length.
Extracts the token length from the given message.
| [in] | pdu | pointer to the coap message struct. |
| uint8_t pcoap_get_token | ( | pcoap_pdu * | pdu, |
| uint8_t * | ptr | ||
| ) |
Get Message Token.
Extracts the token from the given message.
| [in] | pdu | pointer to the coap message struct. |
|
inlinestatic |
Get Message Type.
Extracts the message type from the given message.
| [in] | pdu | pointer to the coap message struct. |
|
inlinestatic |
Get Version.
Extracts the CoAP version from the given message.
| [in] | pdu | pointer to the coap message struct. |
| pcoap_error pcoap_init_pdu | ( | pcoap_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.
| [in,out] | pdu | pointer to the coap message struct. |
| pcoap_error pcoap_set_code | ( | pcoap_pdu * | pdu, |
| pcoap_code | code | ||
| ) |
Set Message Code.
Sets the message type header field.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | code | code to set. |
| pcoap_error pcoap_set_mid | ( | pcoap_pdu * | pdu, |
| uint16_t | mid | ||
| ) |
Set Message ID.
Sets the message ID header field.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | mid | message ID to set. |
| pcoap_error pcoap_set_payload | ( | pcoap_pdu * | pdu, |
| uint8_t * | payload, | ||
| size_t | payload_len | ||
| ) |
Add Message Option.
Sets the payload of the given message to the value in payload.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | pl | payload container. |
| pcoap_error pcoap_set_token | ( | pcoap_pdu * | pdu, |
| uint8_t * | token, | ||
| uint8_t | tkl | ||
| ) |
Set Message Token.
Sets the message token header field.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | token | pointer to the token array to set. |
| pcoap_error pcoap_set_type | ( | pcoap_pdu * | pdu, |
| pcoap_type | mtype | ||
| ) |
Set Message Type.
Sets the message type header field.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | mtype | type to set. |
| pcoap_error pcoap_set_version | ( | pcoap_pdu * | pdu, |
| pcoap_version | ver | ||
| ) |
Set Version.
Sets the version number header field.
| [in,out] | pdu | pointer to the coap message struct. |
| [in] | ver | version to set. Must be COAP_V1. |
| pcoap_error pcoap_validate_pkt | ( | pcoap_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.
| [in] | pdu | pointer to the coap message struct. |
|
static |
1.8.17