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 2017/08/18 06:01:24 UTC
[trafficserver] branch quic-latest updated: Exchange Transport
Parameters
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
The following commit(s) were added to refs/heads/quic-latest by this push:
new 71f4048 Exchange Transport Parameters
71f4048 is described below
commit 71f40486164fdc29a86bd80f0a730e1d6ccbda6c
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Fri Aug 18 14:59:41 2017 +0900
Exchange Transport Parameters
This commit just enable to exhcange the parameters, and the parameters are not
loded from configuration nor processed.
---
iocore/net/P_QUICNetVConnection.h | 5 ++
iocore/net/P_QUICPacketHandler.h | 3 +-
iocore/net/QUICNetProcessor.cc | 7 ++
iocore/net/QUICNetVConnection.cc | 27 ++++++-
iocore/net/quic/Makefile.am | 2 +
iocore/net/quic/Mock.h | 88 ++++++++++++++++++++++
iocore/net/quic/QUICConnection.h | 15 ++--
iocore/net/quic/QUICCrypto.cc | 4 +-
iocore/net/quic/QUICCrypto.h | 2 +-
iocore/net/quic/QUICGlobals.cc | 3 +
.../net/quic/{QUICConnection.h => QUICGlobals.h} | 23 +++---
iocore/net/quic/QUICPacket.cc | 6 --
iocore/net/quic/QUICPacket.h | 4 -
iocore/net/quic/QUICTransportParameters.cc | 60 +++++++++++++--
iocore/net/quic/QUICTransportParameters.h | 28 +++++--
iocore/net/quic/QUICTypes.cc | 6 ++
iocore/net/quic/QUICTypes.h | 5 ++
iocore/net/quic/test/Makefile.am | 11 ++-
iocore/net/quic/test/test_QUICCrypto.cc | 5 +-
.../net/quic/test/test_QUICTransportParameters.cc | 4 +-
20 files changed, 257 insertions(+), 51 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index 8f51030..dda0d7c 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -167,6 +167,8 @@ public:
uint32_t minimum_quic_packet_size() override;
uint32_t maximum_stream_frame_data_size() override;
uint32_t pmtu() override;
+ void set_transport_parameters(std::unique_ptr<QUICTransportParameters> tp) override;
+ const QUICTransportParameters &local_transport_parameters() override;
void close(QUICError error) override;
// QUICConnection (QUICPacketTransmitter)
@@ -190,6 +192,9 @@ private:
uint32_t _pmtu = 1280;
+ std::unique_ptr<QUICTransportParameters> _local_transport_parameters;
+ std::unique_ptr<QUICTransportParameters> _remote_transport_parameters;
+
// TODO: use custom allocator and make them std::unique_ptr or std::shared_ptr
// or make them just member variables.
QUICVersionNegotiator *_version_negotiator = nullptr;
diff --git a/iocore/net/P_QUICPacketHandler.h b/iocore/net/P_QUICPacketHandler.h
index 4d21060..64463e4 100644
--- a/iocore/net/P_QUICPacketHandler.h
+++ b/iocore/net/P_QUICPacketHandler.h
@@ -26,7 +26,8 @@
#include "ts/ink_platform.h"
#include "P_Connection.h"
#include "P_NetAccept.h"
-#include "P_QUICNetVConnection.h"
+
+class QUICNetVConnection;
struct QUICPacketHandler : public NetAccept {
public:
diff --git a/iocore/net/QUICNetProcessor.cc b/iocore/net/QUICNetProcessor.cc
index 2eab6f8..f635210 100644
--- a/iocore/net/QUICNetProcessor.cc
+++ b/iocore/net/QUICNetProcessor.cc
@@ -24,7 +24,9 @@
#include "P_Net.h"
#include "ts/I_Layout.h"
#include "I_RecHttp.h"
+#include "QUICGlobals.h"
#include "QUICConfig.h"
+#include "QUICTransportParameters.h"
// #include "P_QUICUtils.h"
//
@@ -51,6 +53,7 @@ QUICNetProcessor::cleanup()
int
QUICNetProcessor::start(int, size_t stacksize)
{
+ QUIC::init();
// This initialization order matters ...
// QUICInitializeLibrary();
QUICConfig::startup();
@@ -65,6 +68,10 @@ QUICNetProcessor::start(int, size_t stacksize)
this->_ssl_ctx = SSL_CTX_new(TLS_method());
SSL_CTX_set_min_proto_version(this->_ssl_ctx, TLS1_3_VERSION);
SSL_CTX_set_max_proto_version(this->_ssl_ctx, TLS1_3_VERSION);
+ SSL_CTX_add_custom_ext(this->_ssl_ctx, QUICTransportParametersHandler::TRANSPORT_PARAMETER_ID,
+ SSL_EXT_TLS_ONLY | SSL_EXT_CLIENT_HELLO | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS,
+ &QUICTransportParametersHandler::add, &QUICTransportParametersHandler::free, nullptr,
+ &QUICTransportParametersHandler::parse, nullptr);
SSLConfig::scoped_config params;
SSLParseCertificateConfiguration(params, this->_ssl_ctx);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index b09e930..4d2c7cb 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -88,7 +88,7 @@ void
QUICNetVConnection::start(SSL_CTX *ssl_ctx)
{
this->_version_negotiator = new QUICVersionNegotiator(&this->_packet_factory, this);
- this->_crypto = new QUICCrypto(ssl_ctx, this->netvc_context);
+ this->_crypto = new QUICCrypto(ssl_ctx, this);
this->_packet_factory.set_crypto_module(this->_crypto);
// FIXME Should these have to be shared_ptr?
@@ -101,6 +101,19 @@ QUICNetVConnection::start(SSL_CTX *ssl_ctx)
std::shared_ptr<QUICCongestionController> congestionController = std::make_shared<QUICCongestionController>();
this->_frame_dispatcher =
new QUICFrameDispatcher(this, this->_stream_manager, flowController, congestionController, this->_loss_detector);
+
+ // FIXME Fill appropriate values
+ // MUSTs
+ QUICTransportParametersInEncryptedExtensions *tp = new QUICTransportParametersInEncryptedExtensions();
+ tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA, {reinterpret_cast<const uint8_t *>("\x00\x00\x00\x00"), 4});
+ tp->add(QUICTransportParameterId::INITIAL_MAX_DATA, {reinterpret_cast<const uint8_t *>("\x00\x00\x00\x00"), 4});
+ tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_ID, {reinterpret_cast<const uint8_t *>("\x00\x00\x00\x00"), 4});
+ tp->add(QUICTransportParameterId::IDLE_TIMEOUT, {reinterpret_cast<const uint8_t *>("\x00\x00"), 2});
+ tp->add_version(QUIC_SUPPORTED_VERSIONS[0]);
+ // MAYs
+ // this->_local_transport_parameters.add(QUICTransportParameterId::TRUNCATE_CONNECTION_ID, {});
+ // this->_local_transport_parameters.add(QUICTransportParameterId::MAX_PACKET_SIZE, {{0x00, 0x00}, 2});
+ this->_local_transport_parameters = std::unique_ptr<QUICTransportParameters>(tp);
}
void
@@ -140,6 +153,18 @@ QUICNetVConnection::pmtu()
return this->_pmtu;
}
+void
+QUICNetVConnection::set_transport_parameters(std::unique_ptr<QUICTransportParameters> tp)
+{
+ this->_remote_transport_parameters = std::move(tp);
+}
+
+const QUICTransportParameters &
+QUICNetVConnection::local_transport_parameters()
+{
+ return *this->_local_transport_parameters;
+}
+
uint32_t
QUICNetVConnection::minimum_quic_packet_size()
{
diff --git a/iocore/net/quic/Makefile.am b/iocore/net/quic/Makefile.am
index 21e1fca..3316dc4 100644
--- a/iocore/net/quic/Makefile.am
+++ b/iocore/net/quic/Makefile.am
@@ -40,6 +40,7 @@ QUICCrypto_impl = QUICCrypto_openssl.cc
endif
libquic_a_SOURCES = \
+ QUICGlobals.cc \
QUICTypes.cc \
QUICPacket.cc \
QUICFrame.cc \
@@ -54,6 +55,7 @@ libquic_a_SOURCES = \
QUICHandshake.cc \
QUICCrypto.cc \
$(QUICCrypto_impl) \
+ QUICTransportParameters.cc \
QUICAckFrameCreator.cc \
QUICConfig.cc \
QUICDebugNames.cc \
diff --git a/iocore/net/quic/Mock.h b/iocore/net/quic/Mock.h
index 561feeb..05d7af9 100644
--- a/iocore/net/quic/Mock.h
+++ b/iocore/net/quic/Mock.h
@@ -28,6 +28,74 @@
#include "QUICEvents.h"
#include "QUICPacketTransmitter.h"
+class MockNetVConnection : public NetVConnection
+{
+public:
+ MockNetVConnection(NetVConnectionContext_t context = NET_VCONNECTION_OUT) : NetVConnection() { netvc_context = context; }
+ VIO *
+ do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf)
+ {
+ return nullptr;
+ };
+ VIO *
+ do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner = false)
+ {
+ return nullptr;
+ };
+ void do_io_close(int lerrno = -1){};
+ void do_io_shutdown(ShutdownHowTo_t howto){};
+ void reenable(VIO *vio){};
+ void reenable_re(VIO *vio){};
+ void set_active_timeout(ink_hrtime timeout_in){};
+ void set_inactivity_timeout(ink_hrtime timeout_in){};
+ void cancel_active_timeout(){};
+ void cancel_inactivity_timeout(){};
+ void add_to_keep_alive_queue(){};
+ void remove_from_keep_alive_queue(){};
+ bool
+ add_to_active_queue()
+ {
+ return true;
+ };
+ ink_hrtime
+ get_active_timeout()
+ {
+ return 0;
+ }
+ ink_hrtime
+ get_inactivity_timeout()
+ {
+ return 0;
+ }
+ void
+ apply_options()
+ {
+ }
+ SOCKET
+ get_socket()
+ {
+ return 0;
+ }
+ int
+ set_tcp_init_cwnd(int init_cwnd)
+ {
+ return 0;
+ }
+ int
+ set_tcp_congestion_control(int side)
+ {
+ return 0;
+ }
+ void set_local_addr(){};
+ void set_remote_addr(){};
+
+ NetVConnectionContext_t
+ get_context() const
+ {
+ return netvc_context;
+ }
+};
+
class MockQUICConnection : public QUICConnection
{
public:
@@ -100,6 +168,17 @@ public:
}
void
+ set_transport_parameters(std::unique_ptr<QUICTransportParameters> tp) override
+ {
+ }
+
+ const QUICTransportParameters &
+ local_transport_parameters() override
+ {
+ return dummy_transport_parameters;
+ }
+
+ void
close(QUICError error) override
{
}
@@ -115,6 +194,8 @@ public:
Ptr<ProxyMutex> _mutex;
int _totalFrameCount = 0;
int _frameCount[256] = {0};
+
+ QUICTransportParametersInEncryptedExtensions dummy_transport_parameters;
};
class MockQUICPacketTransmitter : public QUICPacketTransmitter
@@ -303,3 +384,10 @@ private:
int _totalFrameCount = 0;
int _frameCount[256] = {0};
};
+
+void NetVConnection::cancel_OOB(){};
+Action *
+NetVConnection::send_OOB(Continuation *, char *, int)
+{
+ return nullptr;
+}
diff --git a/iocore/net/quic/QUICConnection.h b/iocore/net/quic/QUICConnection.h
index 22f373e..4efb317 100644
--- a/iocore/net/quic/QUICConnection.h
+++ b/iocore/net/quic/QUICConnection.h
@@ -26,6 +26,7 @@
#include "QUICPacketTransmitter.h"
#include "QUICFrameTransmitter.h"
#include "QUICFrameHandler.h"
+#include "QUICTransportParameters.h"
class QUICApplication;
class QUICCrypto;
@@ -33,10 +34,12 @@ class QUICCrypto;
class QUICConnection : public QUICPacketTransmitter, public QUICFrameTransmitter, public QUICFrameHandler
{
public:
- virtual QUICApplication *get_application(QUICStreamId stream_id) = 0;
- virtual QUICCrypto *get_crypto() = 0;
- virtual uint32_t maximum_quic_packet_size() = 0;
- virtual uint32_t minimum_quic_packet_size() = 0;
- virtual uint32_t pmtu() = 0;
- virtual void close(QUICError error) = 0;
+ virtual QUICApplication *get_application(QUICStreamId stream_id) = 0;
+ virtual QUICCrypto *get_crypto() = 0;
+ virtual uint32_t maximum_quic_packet_size() = 0;
+ virtual uint32_t minimum_quic_packet_size() = 0;
+ virtual uint32_t pmtu() = 0;
+ virtual void set_transport_parameters(std::unique_ptr<QUICTransportParameters> tp) = 0;
+ virtual const QUICTransportParameters &local_transport_parameters() = 0;
+ virtual void close(QUICError error) = 0;
};
diff --git a/iocore/net/quic/QUICCrypto.cc b/iocore/net/quic/QUICCrypto.cc
index f3df0a6..8eb1385 100644
--- a/iocore/net/quic/QUICCrypto.cc
+++ b/iocore/net/quic/QUICCrypto.cc
@@ -20,6 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "QUICGlobals.h"
#include "QUICCrypto.h"
#include <openssl/err.h>
@@ -82,9 +83,10 @@ QUICPacketProtection::key_phase() const
//
// QUICCrypto
//
-QUICCrypto::QUICCrypto(SSL_CTX *ssl_ctx, NetVConnectionContext_t c) : _netvc_context(c)
+QUICCrypto::QUICCrypto(SSL_CTX *ssl_ctx, NetVConnection *vc) : _netvc_context(vc->get_context())
{
this->_ssl = SSL_new(ssl_ctx);
+ SSL_set_ex_data(this->_ssl, QUIC::ssl_quic_vc_index, vc);
if (this->_netvc_context == NET_VCONNECTION_IN) {
SSL_set_accept_state(this->_ssl);
} else if (this->_netvc_context == NET_VCONNECTION_OUT) {
diff --git a/iocore/net/quic/QUICCrypto.h b/iocore/net/quic/QUICCrypto.h
index e018680..0c704b2 100644
--- a/iocore/net/quic/QUICCrypto.h
+++ b/iocore/net/quic/QUICCrypto.h
@@ -66,7 +66,7 @@ private:
class QUICCrypto
{
public:
- QUICCrypto(SSL_CTX *, NetVConnectionContext_t);
+ QUICCrypto(SSL_CTX *, NetVConnection *);
~QUICCrypto();
bool handshake(uint8_t *out, size_t &out_len, size_t max_out_len, const uint8_t *in, size_t in_len);
diff --git a/iocore/net/quic/QUICGlobals.cc b/iocore/net/quic/QUICGlobals.cc
new file mode 100644
index 0000000..68571b5
--- /dev/null
+++ b/iocore/net/quic/QUICGlobals.cc
@@ -0,0 +1,3 @@
+#include "QUICGlobals.h"
+
+int QUIC::ssl_quic_vc_index = -1;
diff --git a/iocore/net/quic/QUICConnection.h b/iocore/net/quic/QUICGlobals.h
similarity index 55%
copy from iocore/net/quic/QUICConnection.h
copy to iocore/net/quic/QUICGlobals.h
index 22f373e..2dcdef3 100644
--- a/iocore/net/quic/QUICConnection.h
+++ b/iocore/net/quic/QUICGlobals.h
@@ -1,6 +1,6 @@
/** @file
*
- * A brief file description
+ * QUIC Globals
*
* @section license License
*
@@ -23,20 +23,15 @@
#pragma once
-#include "QUICPacketTransmitter.h"
-#include "QUICFrameTransmitter.h"
-#include "QUICFrameHandler.h"
+#include <openssl/ssl.h>
-class QUICApplication;
-class QUICCrypto;
-
-class QUICConnection : public QUICPacketTransmitter, public QUICFrameTransmitter, public QUICFrameHandler
+class QUIC
{
public:
- virtual QUICApplication *get_application(QUICStreamId stream_id) = 0;
- virtual QUICCrypto *get_crypto() = 0;
- virtual uint32_t maximum_quic_packet_size() = 0;
- virtual uint32_t minimum_quic_packet_size() = 0;
- virtual uint32_t pmtu() = 0;
- virtual void close(QUICError error) = 0;
+ static void
+ init()
+ {
+ ssl_quic_vc_index = SSL_get_ex_new_index(0, (void *)"NetVC index", nullptr, nullptr, nullptr);
+ }
+ static int ssl_quic_vc_index;
};
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index cb45080..278daae 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -31,12 +31,6 @@ static const int OFFSET_PAYLOAD = 17;
static const int LONGHEADER_LENGTH = 17;
static const int FNV1A_HASH_LEN = 8;
-ats_unique_buf
-ats_unique_malloc(size_t size)
-{
- return ats_unique_buf(reinterpret_cast<uint8_t *>(ats_malloc(size)), [](void *p) { ats_free(p); });
-}
-
const uint8_t *
QUICPacketHeader::buf()
{
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index e719236..32a087b 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -36,10 +36,6 @@
#define QUIC_FIELD_OFFSET_PACKET_NUMBER 4
#define QUIC_FIELD_OFFSET_PAYLOAD 5
-// TODO: move to lib/ts/ink_memory.h?
-using ats_unique_buf = std::unique_ptr<uint8_t, decltype(&ats_free)>;
-ats_unique_buf ats_unique_malloc(size_t size);
-
class QUICPacketHeader
{
public:
diff --git a/iocore/net/quic/QUICTransportParameters.cc b/iocore/net/quic/QUICTransportParameters.cc
index c7fe736..fe0d0d8 100644
--- a/iocore/net/quic/QUICTransportParameters.cc
+++ b/iocore/net/quic/QUICTransportParameters.cc
@@ -22,13 +22,24 @@
*/
#include <cstdlib>
+#include "QUICGlobals.h"
#include "QUICTransportParameters.h"
+#include "QUICConnection.h"
+#include "../P_QUICNetVConnection.h"
+
+const static int TRANSPORT_PARAMETERS_MAXIMUM_SIZE = 65535;
+
+QUICTransportParameters::QUICTransportParameters(const uint8_t *buf, size_t len)
+{
+ this->_buf = ats_unique_malloc(len);
+ memcpy(this->_buf.get(), buf, len);
+}
QUICTransportParameterValue
QUICTransportParameters::get(QUICTransportParameterId tpid) const
{
QUICTransportParameterValue value;
- const uint8_t *p = this->_buf + this->_parameters_offset();
+ const uint8_t *p = this->_buf.get() + this->_parameters_offset();
uint16_t n = (p[0] << 8) + p[1];
p += 2;
@@ -110,13 +121,13 @@ QUICTransportParametersInClientHello::_parameters_offset() const
QUICVersion
QUICTransportParametersInClientHello::negotiated_version() const
{
- return QUICTypeUtil::read_QUICVersion(this->_buf);
+ return QUICTypeUtil::read_QUICVersion(this->_buf.get());
}
QUICVersion
QUICTransportParametersInClientHello::initial_version() const
{
- return QUICTypeUtil::read_QUICVersion(this->_buf + sizeof(QUICVersion));
+ return QUICTypeUtil::read_QUICVersion(this->_buf.get() + sizeof(QUICVersion));
}
void
@@ -138,8 +149,9 @@ QUICTransportParametersInEncryptedExtensions::_store(uint8_t *buf, uint16_t *len
const uint8_t *
QUICTransportParametersInEncryptedExtensions::supported_versions(uint16_t *n) const
{
- *n = (this->_buf[0] << 8) + this->_buf[1];
- return this->_buf + 2;
+ uint8_t *b = this->_buf.get();
+ *n = (b[0] << 8) + b[1];
+ return b + 2;
}
void
@@ -151,5 +163,41 @@ QUICTransportParametersInEncryptedExtensions::add_version(QUICVersion version)
std::ptrdiff_t
QUICTransportParametersInEncryptedExtensions::_parameters_offset() const
{
- return 2 + 4 * ((this->_buf[0] << 8) + this->_buf[1]);
+ const uint8_t *b = this->_buf.get();
+ return 2 + 4 * ((b[0] << 8) + b[1]);
+}
+
+//
+// QUICTransportParametersHandler
+//
+
+int
+QUICTransportParametersHandler::add(SSL *s, unsigned int ext_type, unsigned int context, const unsigned char **out, size_t *outlen,
+ X509 *x, size_t chainidx, int *al, void *add_arg)
+{
+ QUICConnection *qc =
+ static_cast<QUICConnection *>(static_cast<QUICNetVConnection *>(SSL_get_ex_data(s, QUIC::ssl_quic_vc_index)));
+ *out = reinterpret_cast<const unsigned char *>(ats_malloc(TRANSPORT_PARAMETERS_MAXIMUM_SIZE));
+ qc->local_transport_parameters().store(const_cast<uint8_t *>(*out), reinterpret_cast<uint16_t *>(outlen));
+
+ return 1;
+}
+
+void
+QUICTransportParametersHandler::free(SSL *s, unsigned int ext_type, unsigned int context, const unsigned char *out, void *add_arg)
+{
+ ats_free(const_cast<unsigned char *>(out));
+}
+
+int
+QUICTransportParametersHandler::parse(SSL *s, unsigned int ext_type, unsigned int context, const unsigned char *in, size_t inlen,
+ X509 *x, size_t chainidx, int *al, void *parse_arg)
+{
+ QUICConnection *qc =
+ static_cast<QUICConnection *>(static_cast<QUICNetVConnection *>(SSL_get_ex_data(s, QUIC::ssl_quic_vc_index)));
+ QUICTransportParametersInClientHello *tp = new QUICTransportParametersInClientHello(in, inlen);
+ std::unique_ptr<QUICTransportParameters> utp = std::unique_ptr<QUICTransportParameters>(tp);
+ qc->set_transport_parameters(std::move(utp));
+
+ return 1;
}
diff --git a/iocore/net/quic/QUICTransportParameters.h b/iocore/net/quic/QUICTransportParameters.h
index 244b33e..40373b4 100644
--- a/iocore/net/quic/QUICTransportParameters.h
+++ b/iocore/net/quic/QUICTransportParameters.h
@@ -23,6 +23,7 @@
#pragma once
+#include <openssl/ssl.h>
#include "QUICTypes.h"
#include "ts/Map.h"
#include <cstddef>
@@ -73,15 +74,16 @@ typedef struct _QUICTransportParameterValue {
class QUICTransportParameters
{
public:
- QUICTransportParameters(const uint8_t *buf) : _buf(buf){};
+ QUICTransportParameters(const uint8_t *buf, size_t len);
QUICTransportParameterValue get(QUICTransportParameterId id) const;
void add(QUICTransportParameterId id, QUICTransportParameterValue value);
void store(uint8_t *buf, uint16_t *len) const;
protected:
+ QUICTransportParameters(){};
virtual std::ptrdiff_t _parameters_offset() const = 0;
virtual void _store(uint8_t *buf, uint16_t *len) const = 0;
- const uint8_t *_buf;
+ ats_unique_buf _buf = {nullptr, [](void *p) { ats_free(p); }};
Map<QUICTransportParameterId, QUICTransportParameterValue> _parameters;
};
@@ -89,8 +91,8 @@ class QUICTransportParametersInClientHello : public QUICTransportParameters
{
public:
QUICTransportParametersInClientHello(QUICVersion negotiated_version, QUICVersion initial_version)
- : QUICTransportParameters(nullptr), _negotiated_version(negotiated_version), _initial_version(initial_version){};
- QUICTransportParametersInClientHello(const uint8_t *buf) : QUICTransportParameters(buf){};
+ : QUICTransportParameters(), _negotiated_version(negotiated_version), _initial_version(initial_version){};
+ QUICTransportParametersInClientHello(const uint8_t *buf, size_t len) : QUICTransportParameters(buf, len){};
QUICVersion negotiated_version() const;
QUICVersion initial_version() const;
@@ -106,8 +108,8 @@ private:
class QUICTransportParametersInEncryptedExtensions : public QUICTransportParameters
{
public:
- QUICTransportParametersInEncryptedExtensions() : QUICTransportParameters(nullptr){};
- QUICTransportParametersInEncryptedExtensions(const uint8_t *buf) : QUICTransportParameters(buf){};
+ QUICTransportParametersInEncryptedExtensions() : QUICTransportParameters(){};
+ QUICTransportParametersInEncryptedExtensions(const uint8_t *buf, size_t len) : QUICTransportParameters(buf, len){};
const uint8_t *supported_versions(uint16_t *n) const;
void add_version(QUICVersion version);
@@ -118,3 +120,17 @@ protected:
uint8_t _n_versions = 0;
QUICVersion _versions[256] = {};
};
+
+class QUICTransportParametersHandler
+{
+public:
+ static constexpr int TRANSPORT_PARAMETER_ID = 26;
+
+ static int add(SSL *s, unsigned int ext_type, unsigned int context, const unsigned char **out, size_t *outlen, X509 *x,
+ size_t chainidx, int *al, void *add_arg);
+
+ static void free(SSL *s, unsigned int ext_type, unsigned int context, const unsigned char *out, void *add_arg);
+
+ static int parse(SSL *s, unsigned int ext_type, unsigned int context, const unsigned char *in, size_t inlen, X509 *x,
+ size_t chainidx, int *al, void *parse_arg);
+};
diff --git a/iocore/net/quic/QUICTypes.cc b/iocore/net/quic/QUICTypes.cc
index cf45000..e77f71f 100644
--- a/iocore/net/quic/QUICTypes.cc
+++ b/iocore/net/quic/QUICTypes.cc
@@ -23,6 +23,12 @@
#include "QUICTypes.h"
+ats_unique_buf
+ats_unique_malloc(size_t size)
+{
+ return ats_unique_buf(reinterpret_cast<uint8_t *>(ats_malloc(size)), [](void *p) { ats_free(p); });
+}
+
const QUICStreamId STREAM_ID_FOR_HANDSHAKE = 0;
bool
diff --git a/iocore/net/quic/QUICTypes.h b/iocore/net/quic/QUICTypes.h
index f01a4c7..f6898d9 100644
--- a/iocore/net/quic/QUICTypes.h
+++ b/iocore/net/quic/QUICTypes.h
@@ -36,12 +36,17 @@
#include <random>
#include <cstdint>
+#include "ts/ink_memory.h"
// These magical defines should be removed when we implement seriously
#define MAGIC_NUMBER_0 0
#define MAGIC_NUMBER_1 1
#define MAGIC_NUMBER_TRUE true
+// TODO: move to lib/ts/ink_memory.h?
+using ats_unique_buf = std::unique_ptr<uint8_t, decltype(&ats_free)>;
+ats_unique_buf ats_unique_malloc(size_t size);
+
typedef uint64_t QUICPacketNumber;
typedef uint32_t QUICVersion;
typedef uint32_t QUICStreamId;
diff --git a/iocore/net/quic/test/Makefile.am b/iocore/net/quic/test/Makefile.am
index 5837352..fc06666 100644
--- a/iocore/net/quic/test/Makefile.am
+++ b/iocore/net/quic/test/Makefile.am
@@ -120,6 +120,7 @@ test_QUICFrame_LDFLAGS = \
test_QUICFrame_SOURCES = \
main.cc \
test_QUICFrame.cc \
+ ../QUICGlobals.cc \
../QUICFrame.cc \
../QUICPacket.cc \
../QUICCrypto.cc \
@@ -142,7 +143,9 @@ test_QUICFrameDispatcher_LDFLAGS = \
test_QUICFrameDispatcher_SOURCES = \
main.cc \
test_QUICFrameDispatcher.cc \
+ ../QUICGlobals.cc \
../QUICFrameDispatcher.cc \
+ ../QUICTransportParameters.cc \
../QUICStreamManager.cc \
../QUICFlowController.cc \
../QUICCongestionController.cc \
@@ -236,11 +239,13 @@ test_QUICTransportParameters_LDFLAGS = \
test_QUICTransportParameters_SOURCES = \
main.cc \
test_QUICTransportParameters.cc \
+ ../QUICGlobals.cc \
../QUICTransportParameters.cc \
../QUICTypes.cc
test_QUICTransportParameters_LDADD = \
$(top_builddir)/lib/ts/libtsutil.la \
+ $(top_builddir)/proxy/shared/libUglyLogStubs.a \
$(top_builddir)/iocore/eventsystem/libinkevent.a
#
@@ -256,6 +261,7 @@ test_QUICCrypto_LDFLAGS = \
test_QUICCrypto_LDADD = \
@OPENSSL_LIBS@ \
$(top_builddir)/lib/ts/libtsutil.la \
+ $(top_builddir)/proxy/shared/libUglyLogStubs.a \
$(top_builddir)/iocore/eventsystem/libinkevent.a
test_QUICCrypto_SOURCES = \
@@ -263,7 +269,8 @@ test_QUICCrypto_SOURCES = \
test_QUICCrypto.cc \
../QUICCrypto.cc \
$(QUICCrypto_impl) \
- ../QUICCrypto.h
+ ../QUICCrypto.h \
+ ../QUICGlobals.cc
#
# test_QUICLossDetector
@@ -329,6 +336,7 @@ test_QUICAckFrameCreator_SOURCES = \
main.cc \
test_QUICAckFrameCreator.cc \
../QUICAckFrameCreator.cc \
+ ../QUICGlobals.cc \
../QUICTypes.cc \
../QUICFrame.cc \
../QUICPacket.cc \
@@ -354,6 +362,7 @@ test_QUICVersionNegotiator_LDADD = \
test_QUICVersionNegotiator_SOURCES = \
main.cc \
test_QUICVersionNegotiator.cc \
+ ../QUICGlobals.cc \
../QUICTypes.cc \
../QUICPacket.cc \
../QUICCrypto.cc \
diff --git a/iocore/net/quic/test/test_QUICCrypto.cc b/iocore/net/quic/test/test_QUICCrypto.cc
index f3c13c2..58d84e9 100644
--- a/iocore/net/quic/test/test_QUICCrypto.cc
+++ b/iocore/net/quic/test/test_QUICCrypto.cc
@@ -33,6 +33,7 @@
#include <openssl/ssl.h>
+#include "Mock.h"
#include "QUICCrypto.h"
const static uint32_t MAX_HANDSHAKE_MSG_LEN = 2048;
@@ -108,7 +109,7 @@ TEST_CASE("QUICCrypto 1-RTT", "[quic]")
SSL_CTX *client_ssl_ctx = SSL_CTX_new(TLS_method());
SSL_CTX_set_min_proto_version(client_ssl_ctx, TLS1_3_VERSION);
SSL_CTX_set_max_proto_version(client_ssl_ctx, TLS1_3_VERSION);
- QUICCrypto *client = new QUICCrypto(client_ssl_ctx, NET_VCONNECTION_OUT);
+ QUICCrypto *client = new QUICCrypto(client_ssl_ctx, new MockNetVConnection(NET_VCONNECTION_OUT));
// Server
SSL_CTX *server_ssl_ctx = SSL_CTX_new(TLS_method());
@@ -118,7 +119,7 @@ TEST_CASE("QUICCrypto 1-RTT", "[quic]")
SSL_CTX_use_certificate(server_ssl_ctx, PEM_read_bio_X509(crt_bio, nullptr, nullptr, nullptr));
BIO *key_bio(BIO_new_mem_buf(server_key, sizeof(server_key)));
SSL_CTX_use_PrivateKey(server_ssl_ctx, PEM_read_bio_PrivateKey(key_bio, nullptr, nullptr, nullptr));
- QUICCrypto *server = new QUICCrypto(server_ssl_ctx, NET_VCONNECTION_IN);
+ QUICCrypto *server = new QUICCrypto(server_ssl_ctx, new MockNetVConnection(NET_VCONNECTION_IN));
// Client Hello
uint8_t client_hello[MAX_HANDSHAKE_MSG_LEN] = {0};
diff --git a/iocore/net/quic/test/test_QUICTransportParameters.cc b/iocore/net/quic/test/test_QUICTransportParameters.cc
index 7999789..864eee6 100644
--- a/iocore/net/quic/test/test_QUICTransportParameters.cc
+++ b/iocore/net/quic/test/test_QUICTransportParameters.cc
@@ -45,7 +45,7 @@ TEST_CASE("QUICTransportParametersInClientHello_read", "[quic]")
0xab, 0xcd, // value
};
- QUICTransportParametersInClientHello params_in_ch(buf);
+ QUICTransportParametersInClientHello params_in_ch(buf, sizeof(buf));
CHECK(params_in_ch.negotiated_version() == 0x01020304);
CHECK(params_in_ch.initial_version() == 0x05060708);
QUICTransportParameterValue value;
@@ -111,7 +111,7 @@ TEST_CASE("QUICTransportParametersInEncryptedExtensions_read", "[quic]")
0xab, 0xcd, // value
};
- QUICTransportParametersInEncryptedExtensions params_in_ee(buf);
+ QUICTransportParametersInEncryptedExtensions params_in_ee(buf, sizeof(buf));
const uint8_t *versions;
uint16_t nversion;
versions = params_in_ee.supported_versions(&nversion);
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].