mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-26 00:41:42 +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
57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
/*
|
|
* coap_internal.h -- Structures, Enums & Functions that are not exposed to
|
|
* application programming
|
|
*
|
|
* Copyright (C) 2019-2021 Jon Shallow <supjps-libcoap@jpshallow.com>
|
|
*
|
|
* This file is part of the CoAP library libcoap. Please see README for terms
|
|
* of use.
|
|
*/
|
|
|
|
/*
|
|
* All libcoap library files should include this file which then pulls in all
|
|
* of the other appropriate header files.
|
|
*
|
|
* Note: This file should never be included in application code (with the
|
|
* possible exception of internal test suites).
|
|
*/
|
|
|
|
/**
|
|
* @file coap_internal.h
|
|
* @brief Pulls together all the internal only header files
|
|
*/
|
|
|
|
#ifndef COAP_INTERNAL_H_
|
|
#define COAP_INTERNAL_H_
|
|
|
|
#include "coap_config.h"
|
|
|
|
/*
|
|
* Correctly set up assert() based on NDEBUG for libcoap
|
|
*/
|
|
#if defined(HAVE_ASSERT_H) && !defined(assert)
|
|
# include <assert.h>
|
|
#endif
|
|
|
|
#include "coap.h"
|
|
|
|
/*
|
|
* Include all the header files that are for internal use only.
|
|
*/
|
|
|
|
/* Not defined in coap.h - internal usage .h files */
|
|
#include "utlist.h"
|
|
#include "uthash.h"
|
|
#include "coap_hashkey.h"
|
|
#include "coap_mutex.h"
|
|
|
|
/* Specifically defined internal .h files */
|
|
#include "coap_asn1_internal.h"
|
|
#include "coap_block_internal.h"
|
|
#include "coap_cache_internal.h"
|
|
#include "coap_session_internal.h"
|
|
#include "coap_subscribe_internal.h"
|
|
#include "coap_tcp_internal.h"
|
|
|
|
#endif /* COAP_INTERNAL_H_ */
|