Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: net/quic/quic_config.cc

Issue 2011933002: Add alternate server address to QuicConfig. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@122546126
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_config.h ('k') | net/quic/quic_config_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_config.cc
diff --git a/net/quic/quic_config.cc b/net/quic/quic_config.cc
index 9083ca641acfef7a5aa5e047f8ebc19faf7bad58..7fd0c41b9f218620110a7cabe1e9815af01c4492 100644
--- a/net/quic/quic_config.cc
+++ b/net/quic/quic_config.cc
@@ -10,6 +10,7 @@
#include "net/quic/crypto/crypto_handshake_message.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/quic/quic_bug_tracker.h"
+#include "net/quic/quic_socket_address_coder.h"
#include "net/quic/quic_utils.h"
using std::min;
@@ -335,6 +336,71 @@ QuicErrorCode QuicFixedTagVector::ProcessPeerHello(
return error;
}
+QuicFixedIPEndPoint::QuicFixedIPEndPoint(QuicTag tag,
+ QuicConfigPresence presence)
+ : QuicConfigValue(tag, presence),
+ has_send_value_(false),
+ has_receive_value_(false) {}
+
+QuicFixedIPEndPoint::~QuicFixedIPEndPoint() {}
+
+bool QuicFixedIPEndPoint::HasSendValue() const {
+ return has_send_value_;
+}
+
+const IPEndPoint& QuicFixedIPEndPoint::GetSendValue() const {
+ QUIC_BUG_IF(!has_send_value_) << "No send value to get for tag:"
+ << QuicUtils::TagToString(tag_);
+ return send_value_;
+}
+
+void QuicFixedIPEndPoint::SetSendValue(const IPEndPoint& value) {
+ has_send_value_ = true;
+ send_value_ = value;
+}
+
+bool QuicFixedIPEndPoint::HasReceivedValue() const {
+ return has_receive_value_;
+}
+
+const IPEndPoint& QuicFixedIPEndPoint::GetReceivedValue() const {
+ QUIC_BUG_IF(!has_receive_value_) << "No receive value to get for tag:"
+ << QuicUtils::TagToString(tag_);
+ return receive_value_;
+}
+
+void QuicFixedIPEndPoint::SetReceivedValue(const IPEndPoint& value) {
+ has_receive_value_ = true;
+ receive_value_ = value;
+}
+
+void QuicFixedIPEndPoint::ToHandshakeMessage(
+ CryptoHandshakeMessage* out) const {
+ if (has_send_value_) {
+ QuicSocketAddressCoder address_coder(send_value_);
+ out->SetStringPiece(tag_, address_coder.Encode());
+ }
+}
+
+QuicErrorCode QuicFixedIPEndPoint::ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
+ string* error_details) {
+ base::StringPiece address;
+ if (!peer_hello.GetStringPiece(tag_, &address)) {
+ if (presence_ == PRESENCE_REQUIRED) {
+ *error_details = "Missing " + QuicUtils::TagToString(tag_);
+ return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND;
+ }
+ } else {
+ QuicSocketAddressCoder address_coder;
+ if (address_coder.Decode(address.data(), address.length())) {
+ SetReceivedValue(IPEndPoint(address_coder.ip(), address_coder.port()));
+ }
+ }
+ return QUIC_NO_ERROR;
+}
+
QuicConfig::QuicConfig()
: max_time_before_crypto_handshake_(QuicTime::Delta::Zero()),
max_idle_time_before_crypto_handshake_(QuicTime::Delta::Zero()),
@@ -349,7 +415,8 @@ QuicConfig::QuicConfig()
initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL),
socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL),
multipath_enabled_(kMPTH, PRESENCE_OPTIONAL),
- connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL) {
+ connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL),
+ alternate_server_address_(kASAD, PRESENCE_OPTIONAL) {
SetDefaults();
}
@@ -545,6 +612,19 @@ bool QuicConfig::DisableConnectionMigration() const {
return connection_migration_disabled_.HasReceivedValue();
}
+void QuicConfig::SetAlternateServerAddressToSend(
+ const IPEndPoint& alternate_server_address) {
+ alternate_server_address_.SetSendValue(alternate_server_address);
+}
+
+bool QuicConfig::HasReceivedAlternateServerAddress() const {
+ return alternate_server_address_.HasReceivedValue();
+}
+
+const IPEndPoint& QuicConfig::ReceivedAlternateServerAddress() const {
+ return alternate_server_address_.GetReceivedValue();
+}
+
bool QuicConfig::negotiated() const {
// TODO(ianswett): Add the negotiated parameters once and iterate over all
// of them in negotiated, ToHandshakeMessage, ProcessClientHello, and
@@ -580,6 +660,7 @@ void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const {
socket_receive_buffer_.ToHandshakeMessage(out);
connection_migration_disabled_.ToHandshakeMessage(out);
connection_options_.ToHandshakeMessage(out);
+ alternate_server_address_.ToHandshakeMessage(out);
}
QuicErrorCode QuicConfig::ProcessPeerHello(
@@ -629,6 +710,10 @@ QuicErrorCode QuicConfig::ProcessPeerHello(
error = connection_options_.ProcessPeerHello(peer_hello, hello_type,
error_details);
}
+ if (error == QUIC_NO_ERROR) {
+ error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type,
+ error_details);
+ }
return error;
}
« no previous file with comments | « net/quic/quic_config.h ('k') | net/quic/quic_config_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698