23 #ifndef COAP_MAX_BLOCK_SZX
27 #define COAP_MAX_BLOCK_SZX 6
44 #define COAP_OPT_BLOCK_LAST(opt) \
45 (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
48 #define COAP_OPT_BLOCK_MORE(opt) \
49 (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0)
52 #define COAP_OPT_BLOCK_SZX(opt) \
53 (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0)
66 return ((num+1) << (szx + 4)) < data_len;
72 coap_opt_block_set_m(
coap_opt_t *block_opt,
int m) {
135 unsigned int block_num,
136 unsigned char block_szx);
int coap_write_block_opt(coap_block_t *block, uint16_t type, coap_pdu_t *pdu, size_t data_length)
Writes a block option of type type to message pdu.
void coap_add_data_blocked_response(struct coap_resource_t *resource, struct coap_session_t *session, coap_pdu_t *request, coap_pdu_t *response, const coap_binary_t *token, 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_get_block(coap_pdu_t *pdu, uint16_t type, coap_block_t *block)
Initializes block from 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.
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 <...
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.
uint32_t coap_opt_length(const coap_opt_t *opt)
Returns the length of the given option.
const uint8_t * coap_opt_value(const coap_opt_t *opt)
Returns a pointer to the value of the given option.
#define COAP_STATIC_INLINE
Helpers for handling options in CoAP PDUs.
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
Pre-defined constants that reflect defaults for CoAP.
CoAP binary data definition.
Structure of Block options.
unsigned int num
block number
unsigned int szx
block size
unsigned int m
1 if more blocks follow, 0 otherwise
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...