Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFC8768: Add in support for CoAP Option Hop Limit loop detection
All this is handled by libcoap with coap-client having the ability to define an initial Hop Count value for testing. No other application support is required. Incoming requests are checked for the Hop Limit option - if found, the value is decremented in the PDU before passing it up to the application. If it decrements to 0, a 5.08 response is generated. coap_add_option() checks if this is a Proxy option for a request. If so, and Hop Limit option does not exist, then the Hop Limit option is inserted into the PDU with the default value (16). coap_send() checks if it is a 5.08 response and if so, prepends the diagnostic data with the IP address of the transmitting interface. If the IP address already exists, then the PDU is dropped as the return path for the 5.08 response is looping. An alternative method for return path looping check is also used by initially setting, then testing and then decrementing the Hop Limit value as response packets pass back through the proxies. If a proxy does not copy the Hop Limit options when returning the 5.08 response, then the IP address duplication is used. Makefile.am: Hide the coap_insert_option(), coap_update_option and coap_pdu_check_resize() function from applications. README.md: Add in RFC8768 is supported by libcoap. examples/client.c: Add in the -H hoplimit option. include/coap2/pdu.h: Add in the default Hop-Limit: option COAP_OPTION_HOP_LIMIT. Re-organize the COAP_OPTION_ descriptions to include the C, U, N, R, E, I and U flags. Expose the internal coap_pdu_check_resize() function so src/net.c can use it. Define the two new internal functions coap_insert_option() and coap_update_option() and expose them so that the test suites can use them. man/coap-client.txt.in: Document the new -H hoplimit option. man/coap.txt.in: Include the new RFC8768. man/coap_pdu_setup.txt.in: Update documentation for the CoAP options. src/coap_debug.c: Add in support for printing out COAP_OPTION_HOP_LIMIT. src/net.c: Make sure that COAP_OPTION_HOP_LIMIT is not returned in an error response. Decrement received Hop-limit in handle_request() and generate 5.08 response if appropriate. Update coap_send() to prepend IP in 5.08 response. Support COAP_OPTION_HOP_LIMIT being used in the 5.08 response message. src/pdu.c: Report on CoAP options that are repeated, but not defined as repeatable. Define new (5.08) Hop Limit Reached error response. Add in new internal coap_insert_option() function. This now means that callers of coap_add_option() no longer have to have the options in the correct order. Add in new internal coap_update_option() function that updates the value of an option. Make coap_pdu_check_resize() non-static. tests/test_pdu.c: Check that options are getting inserted in the correct order when using coap_insert_option(), even though they are provided in a random order. Test the coap_update_option() function.
- Loading branch information
Showing
11 changed files
with
694 additions
and
89 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
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
Oops, something went wrong.