19#ifndef COAP_BLOCK_INTERNAL_H_
20#define COAP_BLOCK_INTERNAL_H_
34#define STATE_MAX_BLK_CNT_BITS 20
35#define STATE_TOKEN_BASE(t) ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS))
36#define STATE_TOKEN_RETRY(t) ((uint64_t)(t) >> (64 - STATE_MAX_BLK_CNT_BITS))
37#define STATE_TOKEN_FULL(t,r) (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << (64 - STATE_MAX_BLK_CNT_BITS)))
39#if COAP_Q_BLOCK_SUPPORT
40#define COAP_BLOCK_SET_MASK (COAP_BLOCK_USE_LIBCOAP | \
41 COAP_BLOCK_SINGLE_BODY | \
42 COAP_BLOCK_TRY_Q_BLOCK | \
43 COAP_BLOCK_USE_M_Q_BLOCK | \
44 COAP_BLOCK_NO_PREEMPTIVE_RTAG | \
45 COAP_BLOCK_STLESS_FETCH | \
46 COAP_BLOCK_STLESS_BLOCK2 | \
47 COAP_BLOCK_NOT_RANDOM_BLOCK1 | \
48 COAP_BLOCK_CACHE_RESPONSE | \
49 COAP_BLOCK_FORCE_Q_BLOCK)
51#define COAP_BLOCK_SET_MASK (COAP_BLOCK_USE_LIBCOAP | \
52 COAP_BLOCK_SINGLE_BODY | \
53 COAP_BLOCK_NO_PREEMPTIVE_RTAG | \
54 COAP_BLOCK_STLESS_FETCH | \
55 COAP_BLOCK_STLESS_BLOCK2 | \
56 COAP_BLOCK_NOT_RANDOM_BLOCK1 | \
57 COAP_BLOCK_CACHE_RESPONSE)
60#define COAP_BLOCK_MAX_SIZE_MASK 0x7000000
61#define COAP_BLOCK_MAX_SIZE_SHIFT 24
62#define COAP_BLOCK_MAX_SIZE_GET(a) (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT)
63#define COAP_BLOCK_MAX_SIZE_SET(a) (((a) << COAP_BLOCK_MAX_SIZE_SHIFT) & COAP_BLOCK_MAX_SIZE_MASK)
65#if COAP_Q_BLOCK_SUPPORT
67#define COAP_BLOCK_HAS_Q_BLOCK 0x40000000
68#define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000
70#define set_block_mode_probe_q(block_mode) \
72 block_mode |= COAP_BLOCK_PROBE_Q_BLOCK; \
73 block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK | COAP_BLOCK_HAS_Q_BLOCK); \
76#define set_block_mode_has_q(block_mode) \
78 block_mode |= COAP_BLOCK_HAS_Q_BLOCK; \
79 block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK | COAP_BLOCK_PROBE_Q_BLOCK); \
82#define set_block_mode_drop_q(block_mode) \
84 block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK |\
85 COAP_BLOCK_PROBE_Q_BLOCK |\
86 COAP_BLOCK_HAS_Q_BLOCK | \
87 COAP_BLOCK_USE_M_Q_BLOCK | \
88 COAP_BLOCK_FORCE_Q_BLOCK); \
91#define COAP_SINGLE_BLOCK_OR_Q (COAP_BLOCK_SINGLE_BODY|COAP_BLOCK_HAS_Q_BLOCK)
93#define COAP_SINGLE_BLOCK_OR_Q (COAP_BLOCK_SINGLE_BODY)
106#define COAP_RBLOCK_CNT 4
113#if COAP_Q_BLOCK_SUPPORT
114 uint32_t processing_payload_set;
115 uint32_t latest_payload_set;
178#if COAP_Q_BLOCK_SUPPORT
183#if COAP_CLIENT_SUPPORT
190 uint8_t observe_length;
196 uint16_t content_format;
199 uint16_t block_option;
200 uint16_t retry_counter;
206 size_t obs_token_cnt;
207 uint16_t o_block_option;
209 uint64_t state_token;
218#if COAP_SERVER_SUPPORT
225 uint8_t observe_length;
227 uint8_t no_more_seen;
231 uint16_t content_format;
234 uint16_t block_option;
235 uint8_t dont_timeout;
247#if COAP_Q_BLOCK_SUPPORT
254#if COAP_CLIENT_SUPPORT
266#if COAP_Q_BLOCK_SUPPORT
270 coap_send_pdu_t send_request);
289#if COAP_Q_BLOCK_SUPPORT
294 coap_send_pdu_t send_pdu);
297#if COAP_SERVER_SUPPORT
305#if COAP_Q_BLOCK_SUPPORT
324 coap_send_pdu_t send_response);
415#if COAP_CLIENT_SUPPORT
460#if COAP_Q_BLOCK_SUPPORT
504 uint32_t block_mode);
524#if COAP_CLIENT_SUPPORT
631#define coap_check_update_token(a,b)
struct coap_lg_crcv_t coap_lg_crcv_t
struct coap_resource_t coap_resource_t
struct coap_lg_srcv_t coap_lg_srcv_t
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
#define coap_check_update_token(a, b)
int coap_context_set_max_block_size_lkd(coap_context_t *context, size_t max_block_size)
Set the context level maximum block size that the server supports when sending or receiving packets w...
void coap_context_set_block_mode_lkd(coap_context_t *context, uint32_t block_mode)
Set the context level CoAP block handling bits for handling RFC7959.
void coap_check_code_lg_xmit(const coap_session_t *session, const coap_pdu_t *request, coap_pdu_t *response, const coap_resource_t *resource, const coap_string_t *query)
The function checks that the code in a newly formed lg_xmit created by coap_add_data_large_response_l...
void coap_block_delete_lg_xmit(coap_session_t *session, coap_lg_xmit_t *lg_xmit)
coap_lg_xmit_t * coap_find_lg_xmit(coap_session_t *session, coap_pdu_t *pdu)
Find the current lg_xmit for the session that matches the pdu.
int coap_block_check_lg_xmit_timeouts(coap_session_t *session, coap_tick_t now, coap_tick_t *tim_rem)
int(* coap_get_large_data_t)(coap_session_t *session, size_t max, size_t offset, uint8_t *data, size_t *length, void *app_ptr)
Callback handler for getting the data based on app_ptr provided to coap_add_data_large_request_app() ...
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_*() func...
time_t coap_time_t
CoAP time in seconds since epoch.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
coap_pdu_code_t
Set of codes available for a PDU.
Multi-purpose address abstraction.
CoAP binary data definition with const data.
CoAP binary data definition.
Structure of Block options with BERT support.
The CoAP stack's global state is stored in a coap_context_t object.
Structure to keep track of block1 specific information (Requests)
uint64_t state_token
state token
size_t bert_size
size of last BERT block
uint32_t count
the number of packets sent for payload
coap_binary_t * app_token
original PDU token
Structure to keep track of block2 specific information (Responses)
coap_pdu_code_t request_method
Method used to request this data.
uint8_t rtag_length
RTag length.
coap_string_t * query
Associated query for the resource.
coap_resource_t * resource
associated resource
coap_time_t maxage_expire
When this entry expires.
uint8_t rtag_set
Set if RTag is in receive PDU.
uint8_t rtag[8]
RTag for block checking.
coap_get_large_data_t get_func
Where to get data id needed.
void * app_ptr
applicaton provided ptr for de-alloc function
uint32_t ref
Reference count.
const uint8_t * data
large data ptr
size_t length
large data length
coap_release_large_data_t release_func
large data de-alloc function
Structure to hold large body (many blocks) transmission information.
coap_tick_t last_all_sent
Last time all data sent or 0.
uint8_t blk_size
large block transmission size
coap_tick_t last_sent
Last time any data sent.
union coap_lg_xmit_t::@1 b
coap_lg_xmit_data_t * data_info
Pointer to large data information.
int last_block
last acknowledged block number Block1 last transmitted Q-Block2
coap_tick_t last_payload
Last time MAX_PAYLOAD was sent or 0.
size_t offset
large data next offset to transmit
coap_pdu_t * sent_pdu
The sent pdu with all the data.
uint16_t option
large block transmisson CoAP option
struct coap_lg_xmit_t * next
coap_tick_t last_obs
Last time used (Observe tracking) or 0.
Structure to keep track of received blocks.
uint32_t total_blocks
Set to block no + 1 when More bit unset.
uint32_t used
Number of range blocks in use.
struct coap_lg_range range[COAP_RBLOCK_CNT]
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
CoAP string data definition with const data.
CoAP string data definition.