mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-01 07:25:47 +03:00
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