libcoap 4.3.5-develop-7be2515
Loading...
Searching...
No Matches
Block Transfer

Internal API for Block Transfer (RFC7959) More...

+ Collaboration diagram for Block Transfer:

Data Structures

struct  coap_lg_range
 
struct  coap_rblock_t
 Structure to keep track of received blocks. More...
 
struct  coap_l_block1_t
 Structure to keep track of block1 specific information (Requests) More...
 
struct  coap_l_block2_t
 Structure to keep track of block2 specific information (Responses) More...
 
struct  coap_lg_xmit_data_t
 
struct  coap_lg_xmit_t
 Structure to hold large body (many blocks) transmission information. More...
 

Macros

#define STATE_MAX_BLK_CNT_BITS   20
 
#define STATE_TOKEN_BASE(t)   ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS))
 
#define STATE_TOKEN_RETRY(t)   ((uint64_t)(t) >> (64 - STATE_MAX_BLK_CNT_BITS))
 
#define STATE_TOKEN_FULL(t, r)   (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << (64 - STATE_MAX_BLK_CNT_BITS)))
 
#define COAP_BLOCK_SET_MASK
 
#define COAP_BLOCK_MAX_SIZE_MASK   0x7000000 /* (svr)Mask to get the max supported block size */
 
#define COAP_BLOCK_MAX_SIZE_SHIFT   24 /* (svr)Mask shift to get the max supported block size */
 
#define COAP_BLOCK_MAX_SIZE_GET(a)   (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT)
 
#define COAP_BLOCK_MAX_SIZE_SET(a)   (((a) << COAP_BLOCK_MAX_SIZE_SHIFT) & COAP_BLOCK_MAX_SIZE_MASK)
 
#define COAP_SINGLE_BLOCK_OR_Q   (COAP_BLOCK_SINGLE_BODY)
 
#define COAP_RBLOCK_CNT   4
 
#define coap_check_update_token(a, b)
 

Typedefs

typedef struct coap_rblock_t coap_rblock_t
 Structure to keep track of received blocks.
 
typedef struct coap_l_block1_t coap_l_block1_t
 Structure to keep track of block1 specific information (Requests)
 
typedef struct coap_l_block2_t coap_l_block2_t
 Structure to keep track of block2 specific information (Responses)
 
typedef struct coap_lg_xmit_data_t coap_lg_xmit_data_t
 

Enumerations

enum  coap_recurse_t { COAP_RECURSE_OK , COAP_RECURSE_NO }
 

Functions

coap_lg_xmit_tcoap_find_lg_xmit (coap_session_t *session, coap_pdu_t *pdu)
 Find the current lg_xmit for the session that matches the pdu.
 
void coap_block_delete_lg_xmit (coap_session_t *session, coap_lg_xmit_t *lg_xmit)
 
int coap_block_check_lg_xmit_timeouts (coap_session_t *session, coap_tick_t now, coap_tick_t *tim_rem)
 
void coap_check_code_lg_xmit (const coap_session_t *session, const coap_pdu_t *request, coap_pdu_t *response, const coap_resource_t *resource, const coap_string_t *query)
 The function checks that the code in a newly formed lg_xmit created by coap_add_data_large_response_lkd() is updated.
 
void coap_context_set_block_mode_lkd (coap_context_t *context, uint32_t block_mode)
 Set the context level CoAP block handling bits for handling RFC7959.
 
int coap_context_set_max_block_size_lkd (coap_context_t *context, size_t max_block_size)
 Set the context level maximum block size that the server supports when sending or receiving packets with Block1 or Block2 options.
 

Detailed Description

Internal API for Block Transfer (RFC7959)

Macro Definition Documentation

◆ COAP_BLOCK_MAX_SIZE_GET

#define COAP_BLOCK_MAX_SIZE_GET (   a)    (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT)

Definition at line 62 of file coap_block_internal.h.

◆ COAP_BLOCK_MAX_SIZE_MASK

#define COAP_BLOCK_MAX_SIZE_MASK   0x7000000 /* (svr)Mask to get the max supported block size */

Definition at line 60 of file coap_block_internal.h.

◆ COAP_BLOCK_MAX_SIZE_SET

#define COAP_BLOCK_MAX_SIZE_SET (   a)    (((a) << COAP_BLOCK_MAX_SIZE_SHIFT) & COAP_BLOCK_MAX_SIZE_MASK)

Definition at line 63 of file coap_block_internal.h.

◆ COAP_BLOCK_MAX_SIZE_SHIFT

#define COAP_BLOCK_MAX_SIZE_SHIFT   24 /* (svr)Mask shift to get the max supported block size */

Definition at line 61 of file coap_block_internal.h.

◆ COAP_BLOCK_SET_MASK

#define COAP_BLOCK_SET_MASK
Value:
#define COAP_BLOCK_STLESS_BLOCK2
Definition coap_block.h:71
#define COAP_BLOCK_STLESS_FETCH
Definition coap_block.h:70
#define COAP_BLOCK_SINGLE_BODY
Definition coap_block.h:66
#define COAP_BLOCK_NO_PREEMPTIVE_RTAG
Definition coap_block.h:69
#define COAP_BLOCK_NOT_RANDOM_BLOCK1
Definition coap_block.h:72
#define COAP_BLOCK_CACHE_RESPONSE
Definition coap_block.h:73
#define COAP_BLOCK_USE_LIBCOAP
Definition coap_block.h:65

Definition at line 51 of file coap_block_internal.h.

◆ coap_check_update_token

#define coap_check_update_token (   a,
 
)

Definition at line 631 of file coap_block_internal.h.

◆ COAP_RBLOCK_CNT

#define COAP_RBLOCK_CNT   4

Definition at line 106 of file coap_block_internal.h.

◆ COAP_SINGLE_BLOCK_OR_Q

#define COAP_SINGLE_BLOCK_OR_Q   (COAP_BLOCK_SINGLE_BODY)

Definition at line 93 of file coap_block_internal.h.

◆ STATE_MAX_BLK_CNT_BITS

#define STATE_MAX_BLK_CNT_BITS   20

Definition at line 34 of file coap_block_internal.h.

◆ STATE_TOKEN_BASE

#define STATE_TOKEN_BASE (   t)    ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS))

Definition at line 35 of file coap_block_internal.h.

◆ STATE_TOKEN_FULL

#define STATE_TOKEN_FULL (   t,
 
)    (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << (64 - STATE_MAX_BLK_CNT_BITS)))

Definition at line 37 of file coap_block_internal.h.

◆ STATE_TOKEN_RETRY

#define STATE_TOKEN_RETRY (   t)    ((uint64_t)(t) >> (64 - STATE_MAX_BLK_CNT_BITS))

Definition at line 36 of file coap_block_internal.h.

Typedef Documentation

◆ coap_l_block1_t

Structure to keep track of block1 specific information (Requests)

◆ coap_l_block2_t

Structure to keep track of block2 specific information (Responses)

◆ coap_lg_xmit_data_t

◆ coap_rblock_t

typedef struct coap_rblock_t coap_rblock_t

Structure to keep track of received blocks.

Enumeration Type Documentation

◆ coap_recurse_t

Enumerator
COAP_RECURSE_OK 
COAP_RECURSE_NO 

Definition at line 96 of file coap_block_internal.h.

Function Documentation

◆ coap_block_check_lg_xmit_timeouts()

int coap_block_check_lg_xmit_timeouts ( coap_session_t session,
coap_tick_t  now,
coap_tick_t tim_rem 
)

Definition at line 1519 of file coap_block.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_block_delete_lg_xmit()

void coap_block_delete_lg_xmit ( coap_session_t session,
coap_lg_xmit_t lg_xmit 
)

Definition at line 2666 of file coap_block.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_check_code_lg_xmit()

void coap_check_code_lg_xmit ( const coap_session_t session,
const coap_pdu_t request,
coap_pdu_t response,
const coap_resource_t resource,
const coap_string_t query 
)

The function checks that the code in a newly formed lg_xmit created by coap_add_data_large_response_lkd() is updated.

Parameters
sessionThe session.
requestThe request PDU to to check.
responseThe response PDU to to update with response->code.
resourceThe requested resource.
queryThe requested query.

◆ coap_context_set_block_mode_lkd()

void coap_context_set_block_mode_lkd ( coap_context_t context,
uint32_t  block_mode 
)

Set the context level CoAP block handling bits for handling RFC7959.

These bits flow down to a session when a session is created and if the peer does not support something, an appropriate bit may get disabled in the session block_mode. The session block_mode then flows down into coap_crcv_t or coap_srcv_t where again an appropriate bit may get disabled.

Note: This function must be called before the session is set up.

Note: COAP_BLOCK_USE_LIBCOAP must be set if libcoap is to do all the block tracking and requesting, otherwise the application will have to do all of this work (the default if coap_context_set_block_mode() is not called).

Parameters
contextThe coap_context_t object.
block_modeZero or more COAP_BLOCK_ or'd options

Definition at line 423 of file coap_block.c.

+ Here is the caller graph for this function:

◆ coap_context_set_max_block_size_lkd()

int coap_context_set_max_block_size_lkd ( coap_context_t context,
size_t  max_block_size 
)

Set the context level maximum block size that the server supports when sending or receiving packets with Block1 or Block2 options.

This maximum block size flows down to a session when a session is created.

Note: This function must be called before the session is set up.

Note: This function must be called before the session is set up.

Note: COAP_BLOCK_USE_LIBCOAP must be set using coap_context_set_block_mode() if libcoap is to do this work.

Parameters
contextThe coap_context_t object.
max_block_sizeThe maximum block size a server supports. Can be 0 (reset), or must be 16, 32, 64, 128, 256, 512 or 1024.

Definition at line 448 of file coap_block.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_find_lg_xmit()

coap_lg_xmit_t * coap_find_lg_xmit ( coap_session_t session,
coap_pdu_t pdu 
)

Find the current lg_xmit for the session that matches the pdu.

If client and base lg_xmit is a mcast send, then create a secondorary lg_xmit.

Parameters
sessionThe current session.
pduThe pdu that contains the appropriate token.
Returns
The found lg_xmit or NULL.

Definition at line 478 of file coap_block.c.

+ Here is the call graph for this function: