We usually use read/write rather than recv/send to describe the two sides. Change-Id: Ie3ac8c52c59ea9a5143f56b894f58cecd351dc7d Reviewed-on: https://boringssl-review.googlesource.com/21304 Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> Reviewed-by: Steven Valdez <svaldez@google.com>kris/onging/CECPQ3_patch15
@@ -130,7 +130,7 @@ namespace bssl { | |||
int dtls1_get_record(SSL *ssl) { | |||
again: | |||
switch (ssl->s3->recv_shutdown) { | |||
switch (ssl->s3->read_shutdown) { | |||
case ssl_shutdown_none: | |||
break; | |||
case ssl_shutdown_fatal_alert: | |||
@@ -291,8 +291,8 @@ void dtls1_read_close_notify(SSL *ssl) { | |||
// alerts also aren't delivered reliably, so we may even time out because the | |||
// peer never received our close_notify. Report to the caller that the channel | |||
// has fully shut down. | |||
if (ssl->s3->recv_shutdown == ssl_shutdown_none) { | |||
ssl->s3->recv_shutdown = ssl_shutdown_close_notify; | |||
if (ssl->s3->read_shutdown == ssl_shutdown_none) { | |||
ssl->s3->read_shutdown = ssl_shutdown_close_notify; | |||
} | |||
} | |||
@@ -1754,12 +1754,11 @@ struct SSL3_STATE { | |||
int wpend_ret; // number of bytes submitted | |||
const uint8_t *wpend_buf; | |||
// recv_shutdown is the shutdown state for the receive half of the | |||
// connection. | |||
enum ssl_shutdown_t recv_shutdown; | |||
// read_shutdown is the shutdown state for the read half of the connection. | |||
enum ssl_shutdown_t read_shutdown; | |||
// recv_shutdown is the shutdown state for the send half of the connection. | |||
enum ssl_shutdown_t send_shutdown; | |||
// write_shutdown is the shutdown state for the write half of the connection. | |||
enum ssl_shutdown_t write_shutdown; | |||
int alert_dispatch; | |||
@@ -131,7 +131,7 @@ static int do_ssl3_write(SSL *ssl, int type, const uint8_t *buf, unsigned len); | |||
// more data is needed. | |||
static int ssl3_get_record(SSL *ssl) { | |||
again: | |||
switch (ssl->s3->recv_shutdown) { | |||
switch (ssl->s3->read_shutdown) { | |||
case ssl_shutdown_none: | |||
break; | |||
case ssl_shutdown_fatal_alert: | |||
@@ -536,17 +536,17 @@ int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len) { | |||
int ssl3_send_alert(SSL *ssl, int level, int desc) { | |||
// It is illegal to send an alert when we've already sent a closing one. | |||
if (ssl->s3->send_shutdown != ssl_shutdown_none) { | |||
if (ssl->s3->write_shutdown != ssl_shutdown_none) { | |||
OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN); | |||
return -1; | |||
} | |||
if (level == SSL3_AL_WARNING && desc == SSL_AD_CLOSE_NOTIFY) { | |||
ssl->s3->send_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->write_shutdown = ssl_shutdown_close_notify; | |||
} else { | |||
assert(level == SSL3_AL_FATAL); | |||
assert(desc != SSL_AD_CLOSE_NOTIFY); | |||
ssl->s3->send_shutdown = ssl_shutdown_fatal_alert; | |||
ssl->s3->write_shutdown = ssl_shutdown_fatal_alert; | |||
} | |||
ssl->s3->alert_dispatch = 1; | |||
@@ -978,7 +978,7 @@ int SSL_write(SSL *ssl, const void *buf, int num) { | |||
return -1; | |||
} | |||
if (ssl->s3->send_shutdown != ssl_shutdown_none) { | |||
if (ssl->s3->write_shutdown != ssl_shutdown_none) { | |||
OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN); | |||
return -1; | |||
} | |||
@@ -1021,8 +1021,8 @@ int SSL_shutdown(SSL *ssl) { | |||
if (ssl->quiet_shutdown) { | |||
// Do nothing if configured not to send a close_notify. | |||
ssl->s3->send_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->recv_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->write_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->read_shutdown = ssl_shutdown_close_notify; | |||
return 1; | |||
} | |||
@@ -1030,7 +1030,7 @@ int SSL_shutdown(SSL *ssl) { | |||
// waits for a close_notify to come in. Perform exactly one action and return | |||
// whether or not it succeeds. | |||
if (ssl->s3->send_shutdown != ssl_shutdown_close_notify) { | |||
if (ssl->s3->write_shutdown != ssl_shutdown_close_notify) { | |||
// Send a close_notify. | |||
if (ssl3_send_alert(ssl, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY) <= 0) { | |||
return -1; | |||
@@ -1040,16 +1040,16 @@ int SSL_shutdown(SSL *ssl) { | |||
if (ssl->method->dispatch_alert(ssl) <= 0) { | |||
return -1; | |||
} | |||
} else if (ssl->s3->recv_shutdown != ssl_shutdown_close_notify) { | |||
} else if (ssl->s3->read_shutdown != ssl_shutdown_close_notify) { | |||
// Wait for the peer's close_notify. | |||
ssl->method->read_close_notify(ssl); | |||
if (ssl->s3->recv_shutdown != ssl_shutdown_close_notify) { | |||
if (ssl->s3->read_shutdown != ssl_shutdown_close_notify) { | |||
return -1; | |||
} | |||
} | |||
// Return 0 for unidirectional shutdown and 1 for bidirectional shutdown. | |||
return ssl->s3->recv_shutdown == ssl_shutdown_close_notify; | |||
return ssl->s3->read_shutdown == ssl_shutdown_close_notify; | |||
} | |||
int SSL_send_fatal_alert(SSL *ssl, uint8_t alert) { | |||
@@ -1137,7 +1137,7 @@ int SSL_get_error(const SSL *ssl, int ret_code) { | |||
} | |||
if (ret_code == 0) { | |||
if (ssl->s3->recv_shutdown == ssl_shutdown_close_notify) { | |||
if (ssl->s3->read_shutdown == ssl_shutdown_close_notify) { | |||
return SSL_ERROR_ZERO_RETURN; | |||
} | |||
// An EOF was observed which violates the protocol, and the underlying | |||
@@ -2091,24 +2091,24 @@ void SSL_set_shutdown(SSL *ssl, int mode) { | |||
assert((SSL_get_shutdown(ssl) & mode) == SSL_get_shutdown(ssl)); | |||
if (mode & SSL_RECEIVED_SHUTDOWN && | |||
ssl->s3->recv_shutdown == ssl_shutdown_none) { | |||
ssl->s3->recv_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->read_shutdown == ssl_shutdown_none) { | |||
ssl->s3->read_shutdown = ssl_shutdown_close_notify; | |||
} | |||
if (mode & SSL_SENT_SHUTDOWN && | |||
ssl->s3->send_shutdown == ssl_shutdown_none) { | |||
ssl->s3->send_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->write_shutdown == ssl_shutdown_none) { | |||
ssl->s3->write_shutdown = ssl_shutdown_close_notify; | |||
} | |||
} | |||
int SSL_get_shutdown(const SSL *ssl) { | |||
int ret = 0; | |||
if (ssl->s3->recv_shutdown != ssl_shutdown_none) { | |||
if (ssl->s3->read_shutdown != ssl_shutdown_none) { | |||
// Historically, OpenSSL set |SSL_RECEIVED_SHUTDOWN| on both close_notify | |||
// and fatal alert. | |||
ret |= SSL_RECEIVED_SHUTDOWN; | |||
} | |||
if (ssl->s3->send_shutdown == ssl_shutdown_close_notify) { | |||
if (ssl->s3->write_shutdown == ssl_shutdown_close_notify) { | |||
// Historically, OpenSSL set |SSL_SENT_SHUTDOWN| on only close_notify. | |||
ret |= SSL_SENT_SHUTDOWN; | |||
} | |||
@@ -535,7 +535,7 @@ enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert, | |||
if (alert_level == SSL3_AL_WARNING) { | |||
if (alert_descr == SSL_AD_CLOSE_NOTIFY) { | |||
ssl->s3->recv_shutdown = ssl_shutdown_close_notify; | |||
ssl->s3->read_shutdown = ssl_shutdown_close_notify; | |||
return ssl_open_record_close_notify; | |||
} | |||
@@ -557,7 +557,7 @@ enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert, | |||
} | |||
if (alert_level == SSL3_AL_FATAL) { | |||
ssl->s3->recv_shutdown = ssl_shutdown_fatal_alert; | |||
ssl->s3->read_shutdown = ssl_shutdown_fatal_alert; | |||
char tmp[16]; | |||
OPENSSL_PUT_ERROR(SSL, SSL_AD_REASON_OFFSET + alert_descr); | |||