libcoap  4.3.0rc2
coap_block_internal.h
Go to the documentation of this file.
1 /*
2  * coap_block_internal.h -- Structures, Enums & Functions that are not
3  * exposed to application programming
4  *
5  * Copyright (C) 2010-2021 Olaf Bergmann <bergmann@tzi.org>
6  * Copyright (C) 2021 Jon Shallow <supjps-libcoap@jpshallow.com>
7  *
8  * This file is part of the CoAP library libcoap. Please see README for terms
9  * of use.
10  */
11 
17 #ifndef COAP_BLOCK_INTERNAL_H_
18 #define COAP_BLOCK_INTERNAL_H_
19 
20 #include "coap_pdu_internal.h"
21 #include "resource.h"
22 
29 typedef enum {
33 
34 struct coap_lg_range {
35  uint32_t begin;
36  uint32_t end;
37 };
38 
39 #define COAP_RBLOCK_CNT 4
43 typedef struct coap_rblock_t {
44  uint32_t used;
45  uint32_t retry;
49 
54 typedef struct coap_l_block1_t {
56  uint8_t token[8];
57  size_t token_length;
58  uint32_t count;
60 
65 typedef struct coap_l_block2_t {
68  uint64_t etag;
71 
77  uint8_t blk_size;
78  uint16_t option;
79  int last_block;
80  const uint8_t *data;
81  size_t length;
82  size_t offset;
83  union {
86  } b;
91  void *app_ptr;
92 };
93 
99  uint8_t observe[3];
100  uint8_t observe_length;
101  uint8_t observe_set;
102  uint8_t etag_set;
103  uint8_t etag_length;
104  uint8_t etag[8];
105  uint16_t content_format;
106  uint8_t last_type;
107  uint8_t initial;
108  uint8_t szx;
109  size_t total_len;
112  uint8_t base_token[8];
114  uint8_t token[8];
115  size_t token_length;
119  uint16_t block_option;
120 };
121 
127  uint8_t observe[3];
128  uint8_t observe_length;
129  uint8_t observe_set;
130  uint8_t rtag_set;
131  uint8_t rtag_length;
132  uint8_t rtag[8];
133  uint16_t content_format;
134  uint8_t last_type;
135  uint8_t szx;
136  size_t total_len;
138  size_t amount_so_far;
142  uint8_t last_token[8];
146  uint16_t block_option;
147 };
148 
150  coap_pdu_t *pdu);
151 
153  coap_lg_crcv_t *lg_crcv);
154 
156  coap_tick_t now);
157 
159  coap_lg_srcv_t *lg_srcv);
160 
162  coap_tick_t now);
163 
165  coap_pdu_t *pdu,
166  coap_pdu_t *response,
168  coap_string_t *query);
169 
171  coap_session_t *session,
172  coap_pdu_t *pdu,
173  coap_pdu_t *response,
177  coap_binary_t *token,
178  coap_string_t *query,
180  int *added_block);
181 
183 
185  coap_session_t *session,
186  coap_pdu_t *sent,
187  coap_pdu_t *rcvd,
188  coap_recurse_t recursive);
189 
191  coap_lg_xmit_t *lg_xmit);
192 
214  coap_pdu_t *pdu,
216  const coap_string_t *query,
217  int maxage,
218  uint64_t etag,
219  size_t length,
220  const uint8_t *data,
221  coap_release_large_data_t release_func,
222  void *app_ptr);
223 
233 void coap_check_code_lg_xmit(coap_session_t *session, coap_pdu_t *response,
235 
238 #endif /* COAP_BLOCK_INTERNAL_H_ */
CoAP PDU internal information.
struct coap_rblock_t coap_rblock_t
Structure to keep track of received blocks.
int coap_handle_request_put_block(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu, coap_pdu_t *response, coap_resource_t *resource, coap_string_t *uri_path, coap_opt_t *observe, coap_binary_t *token, coap_string_t *query, coap_method_handler_t h, int *added_block)
Definition: block.c:1240
coap_tick_t coap_block_check_lg_srcv_timeouts(coap_session_t *session, coap_tick_t now)
Definition: block.c:806
void coap_block_delete_lg_srcv(coap_session_t *session, coap_lg_srcv_t *lg_srcv)
Definition: block.c:895
#define COAP_RBLOCK_CNT
void coap_block_delete_lg_crcv(coap_session_t *session, coap_lg_crcv_t *lg_crcv)
Definition: block.c:880
struct coap_l_block1_t coap_l_block1_t
Structure to keep track of block1 specific information (Requests)
int coap_handle_response_get_block(coap_context_t *context, coap_session_t *session, coap_pdu_t *sent, coap_pdu_t *rcvd, coap_recurse_t recursive)
Definition: block.c:1630
struct coap_l_block2_t coap_l_block2_t
Structure to keep track of block2 specific information (Responses)
coap_recurse_t
void coap_block_delete_lg_xmit(coap_session_t *session, coap_lg_xmit_t *lg_xmit)
Definition: block.c:908
void coap_check_code_lg_xmit(coap_session_t *session, coap_pdu_t *response, coap_resource_t *resource, coap_string_t *query)
The function checks that the code in a newly formed lg_xmit created by coap_add_data_large_response()...
Definition: block.c:1970
int coap_add_data_large_internal(coap_session_t *session, coap_pdu_t *pdu, coap_resource_t *resource, const coap_string_t *query, int maxage, uint64_t etag, size_t length, const uint8_t *data, coap_release_large_data_t release_func, void *app_ptr)
The function that does all the work for the coap_add_data_large*() functions.
Definition: block.c:335
coap_tick_t coap_block_check_lg_crcv_timeouts(coap_session_t *session, coap_tick_t now)
Definition: block.c:752
int coap_handle_request_send_block(coap_session_t *session, coap_pdu_t *pdu, coap_pdu_t *response, coap_resource_t *resource, coap_string_t *query)
Definition: block.c:969
coap_lg_crcv_t * coap_block_new_lg_crcv(coap_session_t *session, coap_pdu_t *pdu)
Definition: block.c:828
int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *rcvd)
Definition: block.c:1466
@ COAP_RECURSE_OK
@ COAP_RECURSE_NO
void(* coap_release_large_data_t)(coap_session_t *session, void *app_ptr)
Callback handler for de-allocating the data based on app_ptr provided to coap_add_data_large_*() func...
Definition: block.h:201
time_t coap_time_t
CoAP time in seconds since epoch.
Definition: coap_time.h:125
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:120
void(* coap_method_handler_t)(coap_context_t *, coap_resource_t *, coap_session_t *, coap_pdu_t *, coap_binary_t *, coap_string_t *, coap_pdu_t *)
Definition of message handler function.
Definition: resource.h:41
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Definition: pdu.h:229
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
Definition: option.h:26
Generic resource handling.
CoAP binary data definition.
Definition: str.h:48
The CoAP stack's global state is stored in a coap_context_t object.
Structure to keep track of block1 specific information (Requests)
size_t token_length
length of token
uint32_t count
the number of packets sent for payload
coap_binary_t * app_token
original PDU token
uint8_t token[8]
last used token
Structure to keep track of block2 specific information (Responses)
coap_string_t * query
Associated query for the resource.
uint64_t etag
ETag value.
coap_resource_t * resource
associated resource
coap_time_t maxage_expire
When this entry expires.
Structure to hold large body (many blocks) client receive information.
uint16_t block_option
Block option in use.
uint8_t etag[8]
ETag for block checking.
uint8_t etag_length
ETag length.
uint8_t last_type
Last request type (CON/NON)
uint8_t observe_length
Length of observe data.
uint8_t observe[3]
Observe data (if set) (only 24 bits)
uint8_t etag_set
Set if ETag is in receive PDU.
coap_rblock_t rec_blocks
struct coap_lg_crcv_t * next
uint8_t initial
If set, has not been used yet.
uint8_t szx
size of individual blocks
uint16_t content_format
Content format for the set of blocks.
coap_pdu_t pdu
skeletal PDU
coap_tick_t last_used
< list of received blocks
coap_binary_t * app_token
app requesting PDU token
uint8_t token[8]
last used token
uint8_t base_token[8]
established base PDU token
size_t token_length
length of token
size_t base_token_length
length of token
coap_binary_t * body_data
Used for re-assembling entire body.
uint8_t observe_set
Set if this is an observe receive PDU.
size_t total_len
Length as indicated by SIZE2 option.
Structure to hold large body (many blocks) server receive information.
uint8_t rtag[8]
RTag for block checking.
coap_mid_t last_mid
Last received mid for this set of packets.
uint8_t last_token[8]
< list of received blocks
uint8_t rtag_set
Set if RTag is in receive PDU.
uint16_t block_option
Block option in use.
size_t total_len
Length as indicated by SIZE1 option.
struct coap_lg_srcv_t * next
uint8_t observe_length
Length of observe data.
coap_rblock_t rec_blocks
set to uri_path if unknown resource
coap_binary_t * body_data
Used for re-assembling entire body.
coap_resource_t * resource
associated resource
size_t last_token_length
length of token
uint8_t observe_set
Set if this is an observe receive PDU.
uint8_t rtag_length
RTag length.
uint8_t last_type
Last request type (CON/NON)
uint8_t szx
size of individual blocks
size_t amount_so_far
Amount of data seen so far.
coap_tick_t last_used
Last time data sent or 0.
uint8_t observe[3]
Observe data (if set) (only 24 bits)
uint16_t content_format
Content format for the set of blocks.
coap_str_const_t * uri_path
Structure to hold large body (many blocks) transmission information.
coap_release_large_data_t release_func
large data de-alloc function
uint8_t blk_size
large block transmission size
union coap_lg_xmit_t::@1 b
const uint8_t * data
large data ptr
int last_block
last acknowledged block number
coap_tick_t last_payload
Last time MAX_PAYLOAD was sent or 0.
size_t offset
large data next offset to transmit
coap_pdu_t pdu
skeletal PDU
size_t length
large data length
coap_tick_t last_used
Last time all data sent or 0.
coap_l_block1_t b1
coap_l_block2_t b2
uint16_t option
large block transmisson CoAP option
struct coap_lg_xmit_t * next
void * app_ptr
applicaton provided ptr for de-alloc function
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Structure to keep track of received blocks.
coap_tick_t last_seen
struct coap_lg_range range[COAP_RBLOCK_CNT]
Abstraction of resource that can be attached to coap_context_t.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
CoAP string data definition with const data.
Definition: str.h:38
CoAP string data definition.
Definition: str.h:30