You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/01/12 09:27:17 UTC
[trafficserver] 01/02: Refactor QUICHandshake constructor & start()
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit b7885e3d75dd2640a56f9a0a2492abf96403c8b1
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Fri Jan 12 17:52:57 2018 +0900
Refactor QUICHandshake constructor & start()
---
iocore/net/QUICNetVConnection.cc | 12 +++++++-----
iocore/net/quic/QUICHandshake.cc | 18 ++++++++++++++----
iocore/net/quic/QUICHandshake.h | 6 ++++++
iocore/net/quic/test/test_QUICHandshake.cc | 5 +----
4 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 8744bff..9411ded 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -93,14 +93,16 @@ QUICNetVConnection::startEvent(int /*event ATS_UNUSED */, Event *e)
void
QUICNetVConnection::start(SSL_CTX *ssl_ctx)
{
- {
+ // Version 0x00000001 uses stream 0 for cryptographic handshake with TLS 1.3, but newer version may not
+ if (this->direction() == NET_VCONNECTION_IN) {
QUICConfig::scoped_config params;
this->_reset_token.generate(this->_quic_connection_id, params->server_id());
+ this->_handshake_handler = new QUICHandshake(this, ssl_ctx, this->_reset_token);
+ } else {
+ this->_handshake_handler = new QUICHandshake(this, ssl_ctx);
+ this->_handshake_handler->start(&this->_packet_factory);
}
-
- // Version 0x00000001 uses stream 0 for cryptographic handshake with TLS 1.3, but newer version may not
- this->_handshake_handler = new QUICHandshake(this, ssl_ctx, this->_reset_token);
- this->_application_map = new QUICApplicationMap();
+ this->_application_map = new QUICApplicationMap();
this->_application_map->set(STREAM_ID_FOR_HANDSHAKE, this->_handshake_handler);
this->_crypto = this->_handshake_handler->crypto_module();
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index a783510..b52efc0 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -83,8 +83,7 @@ static constexpr int UDP_MAXIMUM_PAYLOAD_SIZE = 65527;
// TODO: fix size
static constexpr int MAX_HANDSHAKE_MSG_LEN = 65527;
-QUICHandshake::QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, QUICStatelessResetToken token)
- : QUICApplication(qc), _reset_token(token)
+QUICHandshake::QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx) : QUICApplication(qc)
{
this->_ssl = SSL_new(ssl_ctx);
SSL_set_ex_data(this->_ssl, QUIC::ssl_quic_qc_index, qc);
@@ -94,18 +93,29 @@ QUICHandshake::QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, QUICStateless
this->_version_negotiator = new QUICVersionNegotiator();
this->_crypto->initialize_key_materials(this->_client_qc->original_connection_id());
- // for client initial
- this->_load_local_transport_parameters(QUIC_SUPPORTED_VERSIONS[0]);
SET_HANDLER(&QUICHandshake::state_initial);
}
+QUICHandshake::QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, QUICStatelessResetToken token) : QUICHandshake(qc, ssl_ctx)
+{
+ this->_reset_token = token;
+}
+
QUICHandshake::~QUICHandshake()
{
SSL_free(this->_ssl);
}
QUICErrorUPtr
+QUICHandshake::start(QUICPacketFactory *packet_factory)
+{
+ this->_load_local_transport_parameters(QUIC_SUPPORTED_VERSIONS[0]);
+ packet_factory->set_version(QUIC_SUPPORTED_VERSIONS[0]);
+ return QUICErrorUPtr(new QUICNoError());
+}
+
+QUICErrorUPtr
QUICHandshake::start(const QUICPacket *initial_packet, QUICPacketFactory *packet_factory)
{
// Negotiate version
diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h
index 1f5fbbd..75f2d5d 100644
--- a/iocore/net/quic/QUICHandshake.h
+++ b/iocore/net/quic/QUICHandshake.h
@@ -51,9 +51,15 @@ class SSLNextProtocolSet;
class QUICHandshake : public QUICApplication
{
public:
+ // Constructor for client side
+ QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx);
+ // Constructor for server side
QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, QUICStatelessResetToken token);
~QUICHandshake();
+ // for client side
+ QUICErrorUPtr start(QUICPacketFactory *packet_factory);
+ // for server side
QUICErrorUPtr start(const QUICPacket *initial_packet, QUICPacketFactory *packet_factory);
// States
diff --git a/iocore/net/quic/test/test_QUICHandshake.cc b/iocore/net/quic/test/test_QUICHandshake.cc
index 71d51af..71ea0e6 100644
--- a/iocore/net/quic/test/test_QUICHandshake.cc
+++ b/iocore/net/quic/test/test_QUICHandshake.cc
@@ -41,11 +41,8 @@ TEST_CASE("1-RTT handshake ", "[quic]")
SSL_CTX_set_max_proto_version(client_ssl_ctx, TLS1_3_VERSION);
QUICConnectionId client_conn_id = 0x12345;
- // FIXME: remove this. client side stateless reset token doesn't make sense
- QUICStatelessResetToken client_token;
- client_token.generate(client_conn_id, 0);
- QUICHandshake *client = new QUICHandshake(client_qc, client_ssl_ctx, client_token);
+ QUICHandshake *client = new QUICHandshake(client_qc, client_ssl_ctx);
// setup server
QUICConnection *server_qc = new MockQUICConnection(NET_VCONNECTION_IN);
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.