From e14729093b066c2ee90c25196e1a4d91ef8bb50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Thu, 5 Nov 2020 11:05:04 +0100 Subject: [PATCH] mesh: Transport tx fields overflow The transport segmented TX nack and seg_pending fields must be at least 6 bits to avoid overflow for 32 segment messages. This change rearranges the seg_tx fields to gather all state flag fields in one byte, while making the counter fields whole bytes. this is port of 4a2e56d42a432f603df0ae3101b00f4a0fe350e6 --- nimble/host/mesh/src/transport.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nimble/host/mesh/src/transport.c b/nimble/host/mesh/src/transport.c index 92dcfe943..bccc2c954 100644 --- a/nimble/host/mesh/src/transport.c +++ b/nimble/host/mesh/src/transport.c @@ -78,16 +78,14 @@ static struct seg_tx { ctl:1, aszmic:1, friend_cred:1; - u8_t seg_o:6,/* Segment being sent. 6 bits to - * prevent overflow in loop. - */ - started:1, /* Start cb called */ - sending:1; /* Sending is in progress */ - u8_t nack_count:5, /* Number of unacked segs */ - blocked:1; /* Blocked by ongoing tx */ + u8_t seg_o; /* Segment being sent. */ + u8_t nack_count; /* Number of unacked segs */ u8_t ttl; - u8_t seg_pending:5, /* Number of segments pending */ - attempts:3; + u8_t seg_pending; /* Number of segments pending */ + u8_t attempts; /* Transmit attempts */ + u8_t started:1, /* Start cb called */ + sending:1, /* Sending is in progress */ + blocked:1; /* Blocked by ongoing tx */ const struct bt_mesh_send_cb *cb; void *cb_data; struct k_delayed_work retransmit; /* Retransmit timer */