summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-06-21 21:13:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-23 13:34:07 +0200
commitb5114cf8a1b87219330fba4d3189788d8fc1a8d1 (patch)
tree0302811b43afed3c318e75f60c6efa4c37922553 /lib
parent285a05487a6bb9ef023163a62006524a17835e0a (diff)
downloadbarebox-b5114cf8a1b87219330fba4d3189788d8fc1a8d1.tar.gz
barebox-b5114cf8a1b87219330fba4d3189788d8fc1a8d1.tar.xz
ratp: add missing transition to SYN-RECEIVED in behavior B
The reference says: If the SYN flag was set but the ACK was not set then the other end of the connection has executed an active open also. Acknowledge the SYN, choose your MDL, and send: <SN=0><AN=received SN+1 modulo 2><CTL=SYN, ACK><LENGTH=MDL> Go to the SYN-RECEIVED state without any further processing. Add this missing step. This fix isn't related to any barebox<->bbremote interaction issue, because the case where both ends start an active connection doesn't apply in this case. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/ratp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/ratp.c b/lib/ratp.c
index 22e83636fd..0d384aa4e9 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -619,21 +619,25 @@ static void ratp_behaviour_b(struct ratp_internal *ri, void *pkt)
if (hdr->control & RATP_CONTROL_SYN) {
uint8_t control;
+ ri->sn_received = ratp_sn(hdr);
+
if (hdr->control & RATP_CONTROL_ACK) {
control = ratp_set_sn(ratp_an(hdr)) |
ratp_set_an(!ratp_sn(hdr)) |
RATP_CONTROL_ACK;
+ ratp_send_hdr(ri, control);
+ ratp_state_change(ri, RATP_STATE_ESTABLISHED);
} else {
+ struct ratp_header synack = {};
+
control = ratp_set_an(!ratp_sn(hdr)) |
RATP_CONTROL_SYN |
RATP_CONTROL_ACK;
+ ratp_create_packet(ri, &synack, control, 255);
+ ratp_send_pkt(ri, &synack, sizeof(synack));
+ ratp_state_change(ri, RATP_STATE_SYN_RECEIVED);
}
-
- ri->sn_received = ratp_sn(hdr);
-
- ratp_send_hdr(ri, control);
- ratp_state_change(ri, RATP_STATE_ESTABLISHED);
}
}