mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-28 17:47:09 +03:00
RFC7641: Move block handling logic down into libcoap
This change removes the need for applications having to know about handling requests for the next block etc. It also gives the application the ability to pass a large body of data to be transmitted and be told when this body is no longer required. This logic is enabled in libcoap by setting COAP_BLOCK_USE_LIBCOAP using coap_context_set_block_mode() This change breaks down into 4 specific areas 1) Client doing a PUT/POST etc. of a large amount of data (BLOCK1). coap_add_data_large_request() is used which provides a 'finished with data' callback function as well as adding required options to the PDUs. This function calls coap_add_data_large_internal(). Internal coap_handle_response_send_block() sends off the subsequent blocks (using session->lg_xmit). 2) Server receiving PUT/POST etc. of a large amount of data (BLOCK1). Internal coap_handle_request_get_block() acknowledges the appropriate blocks (using session->lg_srcv) and either passes in the individual blocks or the body depending on whether COAP_BLOCK_SINGLE_BODY is set or not using coap_context_set_block_mode(). 3) Server sending a large data response to GET / observe (BLOCK2) coap_add_data_large_response() is used which provides a 'finished with data' callback function. This function calls coap_add_data_large_internal() as well as filling in the necessary options for each PDU. Interal coap_handle_request_send_block() will then send the next requested block (using session->lg_xmit). 4) Client receiving a large data response (BLOCK2) coap_send_large() for the initial request sets this up. Internal coap_handle_response_get_block() will then request the next block when previous block received (using session->lg_crcv) and either passes the individual blocks or the body depending on COAP_BLOCK_SINGLE_BODY being set in coap_context_set_block_mode(). ---- The following new internal functions have been added coap_handle_request_get_block() coap_handle_request_send_block() coap_handle_response_get_block() coap_handle_response_send_block() coap_add_data_large_internal() The following new functions have been added. coap_add_data_large_request() coap_add_data_large_response() coap_context_set_block_mode() coap_get_data_large() coap_pdu_duplicate() coap_send_large() coap_session_init_token() coap_session_new_token() The coap_session_init_token() and coap_session_new_token() were added to make the handling of unique tokens for each request/response easier. https://datatracker.ietf.org/doc/html/draft-ietf-core-echo-request-tag-10#section-4 New files include/coap2/coap_block_internal.h: man/coap_block.txt.in: New memory types COAP_LG_XMIT COAP_LG_SRCV COAP_LG_CRCV
This commit is contained in:
1 parent
b7fed2a706
commit
9cb2f62a3e
38 files changed
+3631
-185
No files matched your search
+1
-3
@@ -136,9 +136,7 @@ coap_new_cache_entry(coap_session_t *session, const coap_pdu_t *pdu,
|
||||
}
|
||||
|
||||
memset(entry, 0, sizeof(coap_cache_entry_t));
|
||||
if (session_based == COAP_CACHE_IS_SESSION_BASED) {
|
||||
entry->session = session;
|
||||
}
|
||||
entry->session = session;
|
||||
if (record_pdu == COAP_CACHE_RECORD_PDU) {
|
||||
entry->pdu = coap_pdu_init(pdu->type, pdu->code, pdu->tid, pdu->alloc_size);
|
||||
if (entry->pdu) {
|
||||
|
||||
Reference in new issue
Block a user