10 #ifndef _COAP_BLOCK_H_ 11 #define _COAP_BLOCK_H_ 22 #ifndef COAP_MAX_BLOCK_SZX 27 #define COAP_MAX_BLOCK_SZX 4 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;
132 const unsigned char *data,
133 unsigned int block_num,
134 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.
Pre-defined constants that reflect defaults for CoAP.
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)
unsigned int num
block number