Loading...
Searching...
No Matches
coap_block.h File Reference

CoAP Block information. More...

`#include "coap_encode.h"`
`#include "coap_option.h"`
`#include "coap_pdu.h"`
Include dependency graph for coap_block.h:

Go to the source code of this file.

## Data Structures

struct | coap_block_t
| Structure of Block options. More...
struct | coap_block_b_t
| Structure of Block options with BERT support. More...

## Macros

#define | COAP_MAX_BLOCK_SZX 6
| The largest value for the SZX component in a Block option.
#define | COAP_BLOCK_USE_LIBCOAP 0x01 /* Use libcoap to do block requests */
#define | COAP_BLOCK_SINGLE_BODY 0x02 /* Deliver the data as a single body */
#define | COAP_BLOCK_TRY_Q_BLOCK 0x04 /* Try Q-Block method */
#define | COAP_BLOCK_USE_M_Q_BLOCK 0x08 /* Use M bit when recovering Q-Block2 */
#define | COAP_BLOCK_NO_PREEMPTIVE_RTAG 0x10 /* Don't use pre-emptive Request-Tags */
#define | COAP_OPT_BLOCK_LAST(opt) (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
| Returns the value of the least significant byte of a Block option `opt`.
#define | COAP_OPT_BLOCK_END_BYTE(opt)
| Returns the value of the last byte of `opt`.
#define | COAP_OPT_BLOCK_MORE(opt) (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x08) : 0)
| Returns the value of the More-bit of a Block option `opt`.
#define | COAP_OPT_BLOCK_SZX(opt) (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
| Returns the value of the SZX-field of a Block option `opt`.

## Typedefs

typedef void(* | coap_release_large_data_t) (coap_session_t *session, void *app_ptr)
| Callback handler for de-allocating the data based on `app_ptr` provided to coap_add_data_large_*() functions following transmission of the supplied data.

## Functions

int | coap_q_block_is_supported (void)
| Returns `1` if libcoap was built with option Q-BlockX support, `0` otherwise.
unsigned int | coap_opt_block_num (const coap_opt_t *block_opt)
| Returns the value of field `num` in the given block option `block_opt`.
COAP_STATIC_INLINE int | coap_more_blocks (size_t data_len, unsigned int num, uint16_t szx)
| Checks if more than `num` blocks are required to deliver `data_len` bytes of data for a block size of 1 << (`szx` + 4).
int | coap_get_block (const coap_pdu_t *pdu, coap_option_num_t number, coap_block_t *block)
| Initializes `block` from `pdu`.
int | coap_get_block_b (const coap_session_t *session, const coap_pdu_t *pdu, coap_option_num_t number, coap_block_b_t *block)
| Initializes `block` from `pdu`.
int | coap_write_block_opt (coap_block_t *block, coap_option_num_t number, coap_pdu_t *pdu, size_t data_length)
| Writes a block option of type `number` to message `pdu`.
int | coap_write_block_b_opt (coap_session_t *session, coap_block_b_t *block, coap_option_num_t number, coap_pdu_t *pdu, size_t data_length)
| Writes a block option of type `number` to message `pdu`.
int | coap_add_block (coap_pdu_t *pdu, size_t len, const uint8_t *data, unsigned int block_num, unsigned char block_szx)
| Adds the `block_num` block of size 1 << (`block_szx` + 4) from source `data` to `pdu`.
int | coap_add_block_b_data (coap_pdu_t *pdu, size_t len, const uint8_t *data, coap_block_b_t *block)
| Adds the appropriate payload data of the body to the `pdu`.
coap_binary_t * | coap_block_build_body (coap_binary_t *body_data, size_t length, const uint8_t *data, size_t offset, size_t total)
| Re-assemble payloads into a body.
void | coap_add_data_blocked_response (const coap_pdu_t *request, coap_pdu_t *response, uint16_t media_type, int maxage, size_t length, const uint8_t *data)
| Adds the appropriate part of `data` to the `response` pdu.
int | coap_add_data_large_request (coap_session_t *session, coap_pdu_t *pdu, size_t length, const uint8_t *data, coap_release_large_data_t release_func, void *app_ptr)
| Associates given data with the `pdu` that is passed as second parameter.
int | coap_add_data_large_response (coap_resource_t *resource, coap_session_t *session, const coap_pdu_t *request, coap_pdu_t *response, const coap_string_t *query, uint16_t media_type, int maxage, uint64_t etag, size_t length, const uint8_t *data, coap_release_large_data_t release_func, void *app_ptr)
| Associates given data with the `response` pdu that is passed as fourth parameter.
void | coap_context_set_block_mode (coap_context_t *context, uint8_t block_mode)
| Set the context level CoAP block handling bits for handling RFC7959.
int | coap_cancel_observe (coap_session_t *session, coap_binary_t *token, coap_pdu_type_t message_type)
| Cancel an observe that is being tracked by the client large receive logic.

## Detailed Description

CoAP Block information.

Definition in file coap_block.h.