Debugging: Add coap_debug_set_packet_fail() for testing network failures

This is similar to coap_debug_set_packet_loss() which drops packets that are
to be sent, but emulates network reported errors by reporting ECONNREFUSED.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2026-03-20 09:13:41 +00:00
1 parent c0ee83bcfb
commit 21b7a9a0eb
10 files changed
+139 -11

No files matched your search

+15
View File
@@ -408,6 +408,21 @@ const char *coap_print_ip_addr(const coap_address_t *address,
*/
int coap_debug_set_packet_loss(const char *loss_level);
/**
* Set the packet transmit fail level for testing. This can be in one of two forms.
*
* Percentage : 0% to 100%. Use the specified probability.
* 0% is send all packets, 100% is fail all packets.
*
* List: A comma separated list of numbers or number ranges that are the
* packets to fail.
*
* @param fail_level The defined fail level (percentage or list).
*
* @return @c 1 If fail level set, @c 0 if there is an error.
*/
int coap_debug_set_packet_fail(const char *fail_level);
#ifdef __cplusplus
}
#endif