Remove expect and received flight hooks.
Instead, the DTLS driver can detect these states implicitly based on
when we write flights and when the handshake completes. When we flush a
new flight, the peer has enough information to send their reply, so we
start a timer. When we begin assembling a new flight, we must have
received the final message in the peer's flight. (If there are
asynchronous events between, we may stop the timer later, but we may
freely stop the timer anytime before we next try to read something.)
The only place this fails is if we were the last to write a flight,
we'll have a stray timer. Clear it in a handshake completion hook.
Change-Id: I973c592ee5721192949a45c259b93192fa309edb
Reviewed-on: https://boringssl-review.googlesource.com/18864
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/internal.h b/ssl/internal.h
index 2dbf063..2d3557c 100644
--- a/ssl/internal.h
+++ b/ssl/internal.h
@@ -1800,6 +1800,11 @@
* the peer in this epoch. */
bool has_change_cipher_spec:1;
+ /* outgoing_messages_complete is true if |outgoing_messages| has been
+ * completed by an attempt to flush it. Future calls to |add_message| and
+ * |add_change_cipher_spec| will start a new flight. */
+ bool outgoing_messages_complete:1;
+
uint8_t cookie[DTLS1_COOKIE_LENGTH];
size_t cookie_len;
@@ -2202,7 +2207,6 @@
void dtls1_start_timer(SSL *ssl);
void dtls1_stop_timer(SSL *ssl);
int dtls1_is_timer_expired(SSL *ssl);
-void dtls1_double_timeout(SSL *ssl);
unsigned int dtls1_min_mtu(void);
int dtls1_new(SSL *ssl);
@@ -2398,12 +2402,8 @@
/* flush_flight flushes the pending flight to the transport. It returns one on
* success and <= 0 on error. */
int (*flush_flight)(SSL *ssl);
- /* expect_flight is called when the handshake expects a flight of messages from
- * the peer. */
- void (*expect_flight)(SSL *ssl);
- /* received_flight is called when the handshake has received a flight of
- * messages from the peer. */
- void (*received_flight)(SSL *ssl);
+ /* on_handshake_complete is called when the handshake is complete. */
+ void (*on_handshake_complete)(SSL *ssl);
/* set_read_state sets |ssl|'s read cipher state to |aead_ctx|. It returns
* one on success and zero if changing the read state is forbidden at this
* point. */