libcoap  4.3.0beta
block.h File Reference
#include "encode.h"
#include "option.h"
#include "pdu.h"
+ Include dependency graph for block.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coap_block_t
 Structure of Block options. More...
 

Macros

#define COAP_MAX_BLOCK_SZX   6
 The largest value for the SZX component in a Block option. More...
 
#define COAP_OPT_BLOCK_LAST(opt)    (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
 Returns the value of the least significant byte of a Block option opt. More...
 
#define COAP_OPT_BLOCK_MORE(opt)    (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0)
 Returns the value of the More-bit of a Block option opt. More...
 
#define COAP_OPT_BLOCK_SZX(opt)    (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0)
 Returns the value of the SZX-field of a Block option opt. More...
 

Functions

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. More...
 
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 << (szx + 4). More...
 
int coap_get_block (coap_pdu_t *pdu, uint16_t type, coap_block_t *block)
 Initializes block from pdu. More...
 
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. More...
 
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. More...
 
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. More...