10 #define _COAP_BLOCK_H_
21 #ifndef COAP_MAX_BLOCK_SZX
27 #define COAP_MAX_BLOCK_SZX 4
30 #if (COAP_MAX_PDU_SIZE - 6) < (1 << (COAP_MAX_BLOCK_SZX + 4))
31 #error "COAP_MAX_BLOCK_SZX too large"
48 #define COAP_OPT_BLOCK_LAST(opt) \
49 (COAP_OPT_LENGTH(opt) ? (COAP_OPT_VALUE(opt) + (COAP_OPT_LENGTH(opt)-1)) : 0)
52 #define COAP_OPT_BLOCK_MORE(opt) \
53 (COAP_OPT_LENGTH(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0)
56 #define COAP_OPT_BLOCK_SZX(opt) \
57 (COAP_OPT_LENGTH(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0)
71 return ((num+1) << (szx + 4)) < data_len;
134 unsigned int block_num,
unsigned char block_szx);
int coap_get_block(coap_pdu_t *pdu, unsigned short type, coap_block_t *block)
Initializes block from pdu.
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.
int coap_write_block_opt(coap_block_t *block, unsigned short type, coap_pdu_t *pdu, size_t data_length)
Writes a block option of type type to message pdu.
static int coap_more_blocks(size_t data_len, unsigned int num, unsigned short szx)
Checks if more than num blocks are required to deliver data_len bytes of data for a block size of 1 <...
helpers for handling options in CoAP PDUs
Header structure for CoAP PDUs.
int coap_add_block(coap_pdu_t *pdu, unsigned int len, const unsigned char *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.
Structure of Block options.
#define COAP_OPT_LENGTH(opt)
unsigned char coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
static void coap_opt_block_set_m(coap_opt_t *block_opt, int m)
Sets the More-bit in block_opt.
#define COAP_OPT_VALUE(opt)