Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/wolfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3851,9 +3851,21 @@ static int isotp_send_flow_control(struct isotp_wolfssl_ctx *ctx,
static int isotp_receive_flow_control(struct isotp_wolfssl_ctx *ctx)
{
int ret;
int waited;
enum isotp_frame_type type;
enum isotp_flow_control flow_control;
ret = ctx->recv_fn(&ctx->frame, ctx->arg, ISOTP_DEFAULT_TIMEOUT);
/* Wait up to N_Bs for flow control rather than a single 100ms poll: a peer
* that is momentarily late is normal, and every other ISO-TP receive here
* retries. Treating the first miss as fatal aborts healthy transfers. */
waited = 0;
do {
ret = ctx->recv_fn(&ctx->frame, ctx->arg, ISOTP_DEFAULT_TIMEOUT);
if (ret != 0) {
break;
}
waited += ISOTP_DEFAULT_TIMEOUT;
} while (waited < ISOTP_FLOW_CONTROL_TIMEOUT);

if (ret == 0) {
return WOLFSSL_CBIO_ERR_TIMEOUT;
} else if (ret < 0) {
Expand Down
2 changes: 2 additions & 0 deletions wolfssl/wolfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
#endif
#ifdef WOLFSSL_ISOTP
#define ISOTP_DEFAULT_TIMEOUT 100
/* ISO 15765-2 N_Bs: how long a sender waits for flow control */
#define ISOTP_FLOW_CONTROL_TIMEOUT 1000
#define ISOTP_DEFAULT_WAIT_COUNT 3
#define ISOTP_FIRST_FRAME_DATA_SIZE 6
#define ISOTP_SINGLE_FRAME_DATA_SIZE 7
Expand Down
Loading