libcoap  4.0.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
block.h File Reference
#include "option.h"
#include "encode.h"
#include "pdu.h"

Go to the source code of this file.

Data Structures

struct  coap_block_t
 Structure of Block options. More...

Macros

#define COAP_OPT_BLOCK_LAST(opt)   ( COAP_OPT_VALUE(opt) + (COAP_OPT_LENGTH(opt) - 1) )
 Returns the value of the least significant byte of a Block option opt.
#define COAP_OPT_BLOCK_MORE(opt)   ( *COAP_OPT_BLOCK_LAST(opt) & 0x08 )
 Returns the value of the More-bit of a Block option opt.
#define COAP_OPT_BLOCK_SZX(opt)   ( *COAP_OPT_BLOCK_LAST(opt) & 0x07 )
 Returns the value of the SZX-field of a Block option opt.
#define COAP_OPT_BLOCK_NUM(Block)   _coap_block_num_impl(Block)
 Returns the value of field num in the given block option Block.

Functions

static unsigned int _coap_block_num_impl (const coap_opt_t *block_opt)
 Implementation of COAP_OPT_BLOCK_NUM.
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 << (szx + 4).
static void coap_opt_block_set_m (coap_opt_t *block_opt, int m)
 Sets the More-bit in block_opt.
int coap_get_block (coap_pdu_t *pdu, unsigned short type, coap_block_t *block)
 Initializes block from pdu.
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.
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.