Repository navigation
Commit c871332
committed
Implement DTLSv1_get_timeout and DTLSv1_handle_timeout
wolfSSL_DTLSv1_get_timeout always returned 0 and reported the full
timeout instead of the time left, and wolfSSL_DTLSv1_handle_timeout was
a stub that did nothing. OpenSSL style event loops that wait for
get_timeout and then call handle_timeout never retransmitted a lost
flight.
Reporting the time left needs to know when the flight went out, which
the library did not record outside the non-blocking socket path in
EmbedReceiveFrom. Add dtls_timer_start, set when a DTLS 1.2 message is
stored for retransmission or the pool is resent, and when a DTLS 1.3
record is stored for retransmission or the buffered records are resent.
It reads TimeNowInMilliseconds where the library builds it (TLS 1.3
tickets, PSK or DTLS 1.3) and LowResTimer otherwise. A whole second
reading is rounded down by one second so the timer never expires early.
A valid handshake message from the peer, which already resets the
timeout, also restarts the timer while a flight waits, as the socket
path re-arms its receive timeout on every read. A stateless server
keeps no flight, so its state stays untouched. Dtls13RtxSendBuffered
takes the timestamp after lastRtx, so the timer never expires inside
DTLS13_MIN_RTX_INTERVAL of the last retransmission.
get_timeout returns 1 with the time left while a flight waits for the
peer and 0 otherwise. A DTLS 1.2 flight waits while it is stored and
the handshake has not finished, a DTLS 1.3 flight while records are
kept for retransmission. No timer runs while the object's own output is
still pending or the handshake is suspended, so a blocked write or a
slow asynchronous signature cannot trigger a retransmission of a partly
sent flight. No timer runs once a fatal alert or close_notify closed the
connection, so the stored flight is not resent after the alert. A
timeout of 0 means no timeout, so no timer runs.
handle_timeout returns 0 when no timer runs or it has not expired yet.
Otherwise it calls wolfSSL_dtls_got_timeout and returns 1, or -1 when
that fails, for example once the timeout reached its maximum. For DTLS
1.3 it clears the quick timeout flag first, since the full timeout
expired, so the call sends any pending ACKs and retransmits instead of
only sending the ACKs. Both return 0 when NO_ASN_TIME leaves no clock.
The DTLS 1.3 quick timeout is not reported by get_timeout, so with
these APIs the ACKs for a partly received flight go out with the next
full timeout.1 parent bd5eead commit c871332
7 files changed
Lines changed: 766 additions & 19 deletions
File tree
- src
- tests/api
- wolfssl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
1042 | | - | |
| 1042 | + | |
1043 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
1044 | 1046 | | |
1045 | 1047 | | |
1046 | 1048 | | |
| |||
1672 | 1674 | | |
1673 | 1675 | | |
1674 | 1676 | | |
| 1677 | + | |
1675 | 1678 | | |
1676 | 1679 | | |
1677 | 1680 | | |
1678 | 1681 | | |
| 1682 | + | |
| 1683 | + | |
1679 | 1684 | | |
1680 | 1685 | | |
1681 | 1686 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12051 | 12051 | | |
12052 | 12052 | | |
12053 | 12053 | | |
| 12054 | + | |
12054 | 12055 | | |
12055 | 12056 | | |
12056 | 12057 | | |
| |||
12073 | 12074 | | |
12074 | 12075 | | |
12075 | 12076 | | |
| 12077 | + | |
| 12078 | + | |
| 12079 | + | |
| 12080 | + | |
| 12081 | + | |
| 12082 | + | |
| 12083 | + | |
| 12084 | + | |
| 12085 | + | |
| 12086 | + | |
| 12087 | + | |
| 12088 | + | |
| 12089 | + | |
| 12090 | + | |
| 12091 | + | |
| 12092 | + | |
| 12093 | + | |
| 12094 | + | |
| 12095 | + | |
| 12096 | + | |
| 12097 | + | |
| 12098 | + | |
| 12099 | + | |
| 12100 | + | |
| 12101 | + | |
| 12102 | + | |
| 12103 | + | |
| 12104 | + | |
| 12105 | + | |
| 12106 | + | |
| 12107 | + | |
12076 | 12108 | | |
12077 | 12109 | | |
12078 | 12110 | | |
| |||
12283 | 12315 | | |
12284 | 12316 | | |
12285 | 12317 | | |
| 12318 | + | |
| 12319 | + | |
12286 | 12320 | | |
12287 | 12321 | | |
12288 | 12322 | | |
| |||
28298 | 28332 | | |
28299 | 28333 | | |
28300 | 28334 | | |
| 28335 | + | |
| 28336 | + | |
28301 | 28337 | | |
28302 | 28338 | | |
28303 | 28339 | | |
| |||
28344 | 28380 | | |
28345 | 28381 | | |
28346 | 28382 | | |
| 28383 | + | |
| 28384 | + | |
28347 | 28385 | | |
28348 | 28386 | | |
28349 | 28387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1195 | 1195 | | |
1196 | 1196 | | |
1197 | 1197 | | |
1198 | | - | |
| 1198 | + | |
1199 | 1199 | | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
1203 | 1204 | | |
1204 | | - | |
| 1205 | + | |
1205 | 1206 | | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1210 | 1239 | | |
| 1240 | + | |
1211 | 1241 | | |
1212 | 1242 | | |
1213 | | - | |
1214 | | - | |
| 1243 | + | |
1215 | 1244 | | |
1216 | | - | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1217 | 1267 | | |
1218 | 1268 | | |
1219 | | - | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1220 | 1272 | | |
1221 | 1273 | | |
1222 | 1274 | | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
1226 | 1288 | | |
1227 | 1289 | | |
| 1290 | + | |
1228 | 1291 | | |
1229 | 1292 | | |
1230 | 1293 | | |
| |||
0 commit comments