summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-06-21 21:13:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-23 13:34:07 +0200
commite03f80b26ce527d2fc262ca09bd16f55f3d3df20 (patch)
treebe3c9194e5abf1af74561f5954c73e0b15553fae
parent45a5fdf884b533dd6fb11342b089306a0b066e34 (diff)
downloadbarebox-e03f80b26ce527d2fc262ca09bd16f55f3d3df20.tar.gz
barebox-e03f80b26ce527d2fc262ca09bd16f55f3d3df20.tar.xz
ratp: fix sending ACKs without data
All ACKs without data must be built in the same way from the input message: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> The code was actually doing this instead: <SN=0><AN=SN><CTL=ACK> This change fixes how the retransmissions are ACK-ed by the peer, and would have affected the barebox<->bbremote interactions. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--lib/ratp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/ratp.c b/lib/ratp.c
index 321721ab71..5c52d3b5f6 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -364,13 +364,12 @@ static bool ratp_sn_expected(struct ratp_internal *ri, struct ratp_header *hdr)
static int ratp_send_ack(struct ratp_internal *ri, struct ratp_header *hdr)
{
- uint8_t control = RATP_CONTROL_ACK;
+ uint8_t control;
int ret;
- if (hdr->control & RATP_CONTROL_SN)
- control |= RATP_CONTROL_AN;
- else
- control |= 0;
+ control = ratp_set_sn(ratp_an(hdr)) |
+ ratp_set_an(ratp_sn(hdr) + 1) |
+ RATP_CONTROL_ACK;
ret = ratp_send_hdr(ri, control);
if (ret)