-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFC9175: Add in support for the Echo and Request-Tag options
A unique Request-Tag is added to any PUT/POST/FETCH request that contains a large body. The server is then able to differentiate between concurrent sending of large data using the same session. If a server responds with a 4.01 and includes an Echo option, then the libcoap client retransmits the request adding in the received Echo option with the same value. If the server responds normally with an Echo option, then the next request from the libcoap client (internally added by libcoap) will contain that Echo option. It is the responsibility of the server application to add in the Echo option if required and validate the next request unless the Echo is triggered by OSCORE (RFC8613 Appendix B.1.2).
- Loading branch information
Showing
15 changed files
with
265 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* block.h -- block transfer | ||
* | ||
* Copyright (C) 2010-2012,2014-2015 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2022 Jon Shallow <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
|
@@ -24,7 +25,7 @@ | |
/** | ||
* @ingroup application_api | ||
* @defgroup block Block Transfer | ||
* API for handling PDUs using CoAP BLOCK options (RFC7959) | ||
* API for handling PDUs using CoAP Block options (RFC7959) | ||
* @{ | ||
*/ | ||
|
||
|
@@ -239,7 +240,7 @@ coap_block_build_body(coap_binary_t *body_data, size_t length, | |
/** | ||
* Adds the appropriate part of @p data to the @p response pdu. If blocks are | ||
* required, then the appropriate block will be added to the PDU and sent. | ||
* Adds a ETAG option that is the hash of the entire data if the data is to be | ||
* Adds a ETag option that is the hash of the entire data if the data is to be | ||
* split into blocks | ||
* Used by a request handler. | ||
* | ||
|
@@ -287,15 +288,15 @@ typedef void (*coap_release_large_data_t)(coap_session_t *session, | |
* Used for a client request. | ||
* | ||
* If the data spans multiple PDUs, then the data will get transmitted using | ||
* BLOCK1 option with the addition of the SIZE1 option. | ||
* Block1 option with the addition of the Size1 and Request-Tag options. | ||
* The underlying library will handle the transmission of the individual blocks. | ||
* Once the body of data has been transmitted (or a failure occurred), then | ||
* @p release_func (if not NULL) will get called so the application can | ||
* de-allocate the @p data based on @p app_data. It is the responsibility of | ||
* the application not to change the contents of @p data until the data | ||
* transfer has completed. | ||
* | ||
* There is no need for the application to include the BLOCK1 option in the | ||
* There is no need for the application to include the Block1 option in the | ||
* @p pdu. | ||
* | ||
* coap_add_data_large_request() (or the alternative coap_add_data_large_*() | ||
|
@@ -332,21 +333,21 @@ int coap_add_data_large_request(coap_session_t *session, | |
* | ||
* If all the data can be transmitted in a single PDU, this is functionally | ||
* the same as coap_add_data() except @p release_func (if not NULL) will get | ||
* invoked after data transmission. The MEDIA_TYPE, MAXAGE and ETAG options may | ||
* be added in as appropriate. | ||
* invoked after data transmission. The Content-Format, Max-Age and ETag | ||
* options may be added in as appropriate. | ||
* | ||
* Used by a server request handler to create the response. | ||
* | ||
* If the data spans multiple PDUs, then the data will get transmitted using | ||
* BLOCK2 (response) option with the addition of the SIZE2 and ETAG | ||
* Block2 (response) option with the addition of the Size2 and ETag | ||
* options. The underlying library will handle the transmission of the | ||
* individual blocks. Once the body of data has been transmitted (or a | ||
* failure occurred), then @p release_func (if not NULL) will get called so the | ||
* application can de-allocate the @p data based on @p app_data. It is the | ||
* responsibility of the application not to change the contents of @p data | ||
* until the data transfer has completed. | ||
* | ||
* There is no need for the application to include the BLOCK2 option in the | ||
* There is no need for the application to include the Block2 option in the | ||
* @p pdu. | ||
* | ||
* coap_add_data_large_response() (or the alternative coap_add_data_large_*() | ||
|
@@ -361,7 +362,7 @@ int coap_add_data_large_request(coap_session_t *session, | |
* @param request The requesting pdu. | ||
* @param response The response pdu. | ||
* @param query The query taken from the (original) requesting pdu. | ||
* @param media_type The format of the data. | ||
* @param media_type The content format of the data. | ||
* @param maxage The maxmimum life of the data. If @c -1, then there | ||
* is no maxage. | ||
* @param etag ETag to use if not 0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* coap_block_internal.h -- Structures, Enums & Functions that are not | ||
* exposed to application programming | ||
* | ||
* Copyright (C) 2010-2021 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2021 Jon Shallow <[email protected]> | ||
* Copyright (C) 2010-2022 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2021-2022 Jon Shallow <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
|
@@ -191,7 +191,8 @@ int coap_handle_request_put_block(coap_context_t *context, | |
#endif /* COAP_SERVER_SUPPORT */ | ||
|
||
#if COAP_CLIENT_SUPPORT | ||
int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *rcvd); | ||
int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *sent, | ||
coap_pdu_t *rcvd); | ||
|
||
int coap_handle_response_get_block(coap_context_t *context, | ||
coap_session_t *session, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* coap_cache.h -- Caching of CoAP requests | ||
* | ||
* Copyright (C) 2020 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2020-2022 Olaf Bergmann <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
|
@@ -50,7 +50,7 @@ typedef enum coap_cache_record_pdu_t { | |
* for an explanation of CoAP cache keys. | ||
* | ||
* Specific CoAP options can be removed from the cache-key. Examples of | ||
* this are the BLOCK1 and BLOCK2 options - which make no real sense including | ||
* this are the Block1 and Block2 options - which make no real sense including | ||
* them in a client or server environment, but should be included in a proxy | ||
* caching environment where things are cached on a per block basis. | ||
* This is done globally by calling the coap_cache_ignore_options() | ||
|
@@ -78,7 +78,7 @@ coap_cache_key_t *coap_cache_derive_key(const coap_session_t *session, | |
* for an explanation of CoAP cache keys. | ||
* | ||
* Specific CoAP options can be removed from the cache-key. Examples of | ||
* this are the BLOCK1 and BLOCK2 options - which make no real sense including | ||
* this are the Block1 and Block2 options - which make no real sense including | ||
* them in a client or server environment, but should be included in a proxy | ||
* caching environment where things are cached on a per block basis. | ||
* This is done individually by specifying @p cache_ignore_count and | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* coap_event.h -- libcoap Event API | ||
* | ||
* Copyright (C) 2016 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2021-2022 Jon Shallow <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
|
@@ -54,7 +55,7 @@ typedef enum coap_event_t { | |
COAP_EVENT_SESSION_FAILED = 0x2003, | ||
|
||
/** | ||
* (Q-)BLOCK receive errors | ||
* (Q-)Block receive errors | ||
*/ | ||
COAP_EVENT_PARTIAL_BLOCK = 0x3001, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* coap_session_internal.h -- Structures, Enums & Functions that are not | ||
* exposed to application programming | ||
* | ||
* Copyright (C) 2010-2019 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2010-2022 Olaf Bergmann <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
|
@@ -145,7 +145,9 @@ struct coap_session_t { | |
uint8_t doing_first; /**< Set if doing client's first request */ | ||
uint8_t proxy_session; /**< Set if this is an ongoing proxy session */ | ||
uint8_t delay_recursive; /**< Set if in coap_client_delay_first() */ | ||
uint32_t tx_rtag; /**< Next Request-Tag number to use */ | ||
uint64_t tx_token; /**< Next token number to use */ | ||
coap_bin_const_t *echo; /**< Echo value to send with next request */ | ||
}; | ||
|
||
#if COAP_SERVER_SUPPORT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* pdu.h -- CoAP message structure | ||
* | ||
* Copyright (C) 2010-2014 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2021-2022 Jon Shallow <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
|
@@ -130,7 +131,9 @@ typedef enum coap_request_t { | |
#define COAP_OPTION_PROXY_URI 35 /* CU-___U, String, 1-1034 B, RFC7252 */ | ||
#define COAP_OPTION_PROXY_SCHEME 39 /* CU-___U, String, 1-255 B, RFC7252 */ | ||
#define COAP_OPTION_SIZE1 60 /* __N_E_U, uint, 0-4 B, RFC7252 */ | ||
#define COAP_OPTION_ECHO 252 /* _N__E_U, opaque, 0-40 B, RFC9175 */ | ||
#define COAP_OPTION_NORESPONSE 258 /* _U-_E_U, uint, 0-1 B, RFC7967 */ | ||
#define COAP_OPTION_RTAG 292 /* ___RE_U, opaque, 0-8 B, RFC9175 */ | ||
|
||
#define COAP_MAX_OPT 65535 /**< the highest option number we know */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.