Rename connection_id to server_connection_id
This is a step on the way to enabling client connection IDs. It will make the code less ambiguous once we introduce client_connection_id.
gfe-relnote: n/a, renaming code only
PiperOrigin-RevId: 249045070
Change-Id: Ia7ba75511f96c896bc6f0f4978dae2cd13e707fb
diff --git a/quic/core/http/quic_spdy_client_session_test.cc b/quic/core/http/quic_spdy_client_session_test.cc
index 77d105c..0d6b36c 100644
--- a/quic/core/http/quic_spdy_client_session_test.cc
+++ b/quic/core/http/quic_spdy_client_session_test.cc
@@ -504,7 +504,7 @@
session_->ProcessUdpPacket(client_address, server_address, valid_packet);
// Verify that a non-decryptable packet doesn't close the connection.
- QuicFramerPeer::SetLastSerializedConnectionId(
+ QuicFramerPeer::SetLastSerializedServerConnectionId(
QuicConnectionPeer::GetFramer(connection_), connection_id);
ParsedQuicVersionVector versions = SupportedVersions(GetParam());
QuicConnectionId destination_connection_id = EmptyQuicConnectionId();
@@ -549,7 +549,7 @@
QuicConnectionId destination_connection_id =
session_->connection()->connection_id();
QuicConnectionId source_connection_id = EmptyQuicConnectionId();
- QuicFramerPeer::SetLastSerializedConnectionId(
+ QuicFramerPeer::SetLastSerializedServerConnectionId(
QuicConnectionPeer::GetFramer(connection_), destination_connection_id);
ParsedQuicVersionVector versions = {GetParam()};
bool version_flag = false;
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index e61bae4..a8672f5 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -219,7 +219,7 @@
(perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ")
QuicConnection::QuicConnection(
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
QuicSocketAddress initial_peer_address,
QuicConnectionHelperInterface* helper,
QuicAlarmFactory* alarm_factory,
@@ -230,7 +230,7 @@
: framer_(supported_versions,
helper->GetClock()->ApproximateNow(),
perspective,
- connection_id.length()),
+ server_connection_id.length()),
current_packet_content_(NO_FRAMES_RECEIVED),
is_current_packet_connectivity_probing_(false),
current_effective_peer_migration_type_(NO_CHANGE),
@@ -242,7 +242,7 @@
encryption_level_(ENCRYPTION_INITIAL),
clock_(helper->GetClock()),
random_generator_(helper->GetRandomGenerator()),
- connection_id_(connection_id),
+ server_connection_id_(server_connection_id),
peer_address_(initial_peer_address),
direct_peer_address_(initial_peer_address),
active_effective_peer_migration_type_(NO_CHANGE),
@@ -302,7 +302,10 @@
&arena_)),
visitor_(nullptr),
debug_visitor_(nullptr),
- packet_generator_(connection_id_, &framer_, random_generator_, this),
+ packet_generator_(server_connection_id_,
+ &framer_,
+ random_generator_,
+ this),
idle_network_timeout_(QuicTime::Delta::Infinite()),
handshake_timeout_(QuicTime::Delta::Infinite()),
time_of_first_packet_sent_after_receiving_(
@@ -374,13 +377,14 @@
QUIC_RELOADABLE_FLAG_COUNT(quic_use_uber_received_packet_manager);
}
QUIC_DLOG(INFO) << ENDPOINT
- << "Created connection with connection_id: " << connection_id
+ << "Created connection with server connection_id: "
+ << server_connection_id
<< " and version: " << ParsedQuicVersionToString(version());
- QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion(connection_id,
+ QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion(server_connection_id,
transport_version()))
- << "QuicConnection: attempted to use connection ID " << connection_id
- << " which is invalid with version "
+ << "QuicConnection: attempted to use server connection ID "
+ << server_connection_id << " which is invalid with version "
<< QuicVersionToString(transport_version());
framer_.set_visitor(this);
@@ -444,7 +448,7 @@
sent_packet_manager_.SetFromConfig(config);
if (config.HasReceivedBytesForConnectionId() &&
can_truncate_connection_ids_) {
- packet_generator_.SetConnectionIdLength(
+ packet_generator_.SetServerConnectionIdLength(
config.ReceivedBytesForConnectionId());
}
max_undecryptable_packets_ = config.max_undecryptable_packets();
@@ -592,7 +596,7 @@
// Check that any public reset packet with a different connection ID that was
// routed to this QuicConnection has been redirected before control reaches
// here. (Check for a bug regression.)
- DCHECK_EQ(connection_id_, packet.connection_id);
+ DCHECK_EQ(server_connection_id_, packet.connection_id);
DCHECK_EQ(perspective_, Perspective::IS_CLIENT);
if (debug_visitor_ != nullptr) {
debug_visitor_->OnPublicResetPacket(packet);
@@ -683,7 +687,7 @@
// Check that any public reset packet with a different connection ID that was
// routed to this QuicConnection has been redirected before control reaches
// here. (Check for a bug regression.)
- DCHECK_EQ(connection_id_, packet.connection_id);
+ DCHECK_EQ(server_connection_id_, packet.connection_id);
if (perspective_ == Perspective::IS_SERVER) {
const std::string error_details =
"Server received version negotiation packet.";
@@ -766,10 +770,10 @@
void QuicConnection::OnRetryPacket(QuicConnectionId original_connection_id,
QuicConnectionId new_connection_id,
QuicStringPiece retry_token) {
- if (original_connection_id != connection_id_) {
+ if (original_connection_id != server_connection_id_) {
QUIC_DLOG(ERROR) << "Ignoring RETRY with original connection ID "
<< original_connection_id << " not matching expected "
- << connection_id_ << " token "
+ << server_connection_id_ << " token "
<< QuicTextUtils::HexEncode(retry_token);
return;
}
@@ -780,17 +784,18 @@
}
retry_has_been_parsed_ = true;
QUIC_DLOG(INFO) << "Received RETRY, replacing connection ID "
- << connection_id_ << " with " << new_connection_id
+ << server_connection_id_ << " with " << new_connection_id
<< ", received token "
<< QuicTextUtils::HexEncode(retry_token);
- connection_id_ = new_connection_id;
- packet_generator_.SetConnectionId(connection_id_);
+ server_connection_id_ = new_connection_id;
+ packet_generator_.SetServerConnectionId(server_connection_id_);
packet_generator_.SetRetryToken(retry_token);
// Reinstall initial crypters because the connection ID changed.
CrypterPair crypters;
- CryptoUtils::CreateTlsInitialCrypters(
- Perspective::IS_CLIENT, transport_version(), connection_id_, &crypters);
+ CryptoUtils::CreateTlsInitialCrypters(Perspective::IS_CLIENT,
+ transport_version(),
+ server_connection_id_, &crypters);
SetEncrypter(ENCRYPTION_INITIAL, std::move(crypters.encrypter));
InstallDecrypter(ENCRYPTION_INITIAL, std::move(crypters.decrypter));
}
@@ -817,21 +822,23 @@
QuicConnectionId server_connection_id =
GetServerConnectionIdAsRecipient(header, perspective_);
- if (server_connection_id == connection_id_ ||
+ if (server_connection_id == server_connection_id_ ||
HasIncomingConnectionId(server_connection_id)) {
return true;
}
if (PacketCanReplaceConnectionId(header, perspective_)) {
QUIC_DLOG(INFO) << ENDPOINT << "Accepting packet with new connection ID "
- << server_connection_id << " instead of " << connection_id_;
+ << server_connection_id << " instead of "
+ << server_connection_id_;
return true;
}
++stats_.packets_dropped;
QUIC_DLOG(INFO) << ENDPOINT
<< "Ignoring packet from unexpected ConnectionId: "
- << server_connection_id << " instead of " << connection_id_;
+ << server_connection_id << " instead of "
+ << server_connection_id_;
if (debug_visitor_ != nullptr) {
debug_visitor_->OnIncorrectConnectionId(server_connection_id);
}
@@ -851,7 +858,7 @@
// routed to this QuicConnection has been redirected before control reaches
// here.
DCHECK(GetServerConnectionIdAsRecipient(header, perspective_) ==
- connection_id_ ||
+ server_connection_id_ ||
HasIncomingConnectionId(
GetServerConnectionIdAsRecipient(header, perspective_)) ||
PacketCanReplaceConnectionId(header, perspective_));
@@ -1109,7 +1116,7 @@
<< " packet_number:" << last_header_.packet_number
<< " largest seen with ack:"
<< GetLargestReceivedPacketWithAck()
- << " connection_id: " << connection_id_;
+ << " server_connection_id: " << server_connection_id_;
// A new ack has a diminished largest_observed value.
// If this was an old packet, we wouldn't even have checked.
CloseConnection(QUIC_INVALID_ACK_DATA, "Largest observed too low.",
@@ -2132,11 +2139,12 @@
}
if (PacketCanReplaceConnectionId(header, perspective_) &&
- connection_id_ != header.source_connection_id) {
- QUIC_DLOG(INFO) << ENDPOINT << "Replacing connection ID " << connection_id_
- << " with " << header.source_connection_id;
- connection_id_ = header.source_connection_id;
- packet_generator_.SetConnectionId(connection_id_);
+ server_connection_id_ != header.source_connection_id) {
+ QUIC_DLOG(INFO) << ENDPOINT << "Replacing connection ID "
+ << server_connection_id_ << " with "
+ << header.source_connection_id;
+ server_connection_id_ = header.source_connection_id;
+ packet_generator_.SetServerConnectionId(server_connection_id_);
}
if (!ValidateReceivedPacketNumber(header.packet_number)) {
@@ -3578,7 +3586,7 @@
QUIC_DLOG(INFO) << ENDPOINT
<< "Sending path probe packet for connection_id = "
- << connection_id_;
+ << server_connection_id_;
OwningSerializedPacketPointer probing_packet;
if (transport_version() != QUIC_VERSION_99) {
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index 8c8ed2b..b274266 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -341,7 +341,7 @@
// |initial_peer_address| using |writer| to write packets. |owns_writer|
// specifies whether the connection takes ownership of |writer|. |helper| must
// outlive this connection.
- QuicConnection(QuicConnectionId connection_id,
+ QuicConnection(QuicConnectionId server_connection_id,
QuicSocketAddress initial_peer_address,
QuicConnectionHelperInterface* helper,
QuicAlarmFactory* alarm_factory,
@@ -582,7 +582,7 @@
const QuicSocketAddress& effective_peer_address() const {
return effective_peer_address_;
}
- QuicConnectionId connection_id() const { return connection_id_; }
+ QuicConnectionId connection_id() const { return server_connection_id_; }
const QuicClock* clock() const { return clock_; }
QuicRandom* random_generator() const { return random_generator_; }
QuicByteCount max_packet_length() const;
@@ -1168,7 +1168,7 @@
const QuicClock* clock_;
QuicRandom* random_generator_;
- QuicConnectionId connection_id_;
+ QuicConnectionId server_connection_id_;
// Address on the last successfully processed packet received from the
// direct peer.
QuicSocketAddress self_address_;
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index 4ecb780..0d09430 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -938,7 +938,7 @@
peer_creator_.SetEncrypter(
level, QuicMakeUnique<NullEncrypter>(peer_framer_.perspective()));
}
- QuicFramerPeer::SetLastSerializedConnectionId(
+ QuicFramerPeer::SetLastSerializedServerConnectionId(
QuicConnectionPeer::GetFramer(&connection_), connection_id_);
if (version().transport_version > QUIC_VERSION_43) {
EXPECT_TRUE(QuicConnectionPeer::GetNoStopWaitingFrames(&connection_));
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index 9af5f84..049a63f 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -115,17 +115,17 @@
// list manager.
class StatelessConnectionTerminator {
public:
- StatelessConnectionTerminator(QuicConnectionId connection_id,
+ StatelessConnectionTerminator(QuicConnectionId server_connection_id,
const ParsedQuicVersion version,
QuicConnectionHelperInterface* helper,
QuicTimeWaitListManager* time_wait_list_manager)
- : connection_id_(connection_id),
+ : server_connection_id_(server_connection_id),
framer_(ParsedQuicVersionVector{version},
/*unused*/ QuicTime::Zero(),
Perspective::IS_SERVER,
/*unused*/ kQuicDefaultConnectionIdLength),
collector_(helper->GetStreamSendBufferAllocator()),
- creator_(connection_id, &framer_, &collector_),
+ creator_(server_connection_id, &framer_, &collector_),
time_wait_list_manager_(time_wait_list_manager) {
framer_.set_data_producer(&collector_);
}
@@ -154,7 +154,7 @@
creator_.Flush();
DCHECK_EQ(1u, collector_.packets()->size());
time_wait_list_manager_->AddConnectionIdToTimeWait(
- connection_id_, ietf_quic,
+ server_connection_id_, ietf_quic,
QuicTimeWaitListManager::SEND_TERMINATION_PACKETS,
quic::ENCRYPTION_INITIAL, collector_.packets());
}
@@ -195,14 +195,15 @@
creator_.Flush();
}
time_wait_list_manager_->AddConnectionIdToTimeWait(
- connection_id_, ietf_quic,
+ server_connection_id_, ietf_quic,
QuicTimeWaitListManager::SEND_TERMINATION_PACKETS, ENCRYPTION_INITIAL,
collector_.packets());
- DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id_));
+ DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(
+ server_connection_id_));
}
private:
- QuicConnectionId connection_id_;
+ QuicConnectionId server_connection_id_;
QuicFramer framer_;
// Set as the visitor of |creator_| to collect any generated packets.
PacketCollector collector_;
@@ -214,7 +215,7 @@
class ChloAlpnExtractor : public ChloExtractor::Delegate {
public:
void OnChlo(QuicTransportVersion version,
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
const CryptoHandshakeMessage& chlo) override {
QuicStringPiece alpn_value;
if (chlo.GetStringPiece(kALPN, &alpn_value)) {
@@ -247,16 +248,17 @@
// ChloExtractor::Delegate implementation.
void OnChlo(QuicTransportVersion version,
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
const CryptoHandshakeMessage& chlo) override {
// Extract the ALPN
- ChloAlpnExtractor::OnChlo(version, connection_id, chlo);
+ ChloAlpnExtractor::OnChlo(version, server_connection_id, chlo);
if (helper_->CanAcceptClientHello(chlo, client_address_, peer_address_,
self_address_, &error_details_)) {
can_accept_ = true;
rejector_->OnChlo(
- version, connection_id,
- helper_->GenerateConnectionIdForReject(version, connection_id), chlo);
+ version, server_connection_id,
+ helper_->GenerateConnectionIdForReject(version, server_connection_id),
+ chlo);
}
}
@@ -305,7 +307,7 @@
last_error_(QUIC_NO_ERROR),
new_sessions_allowed_per_event_loop_(0u),
accept_new_connections_(true),
- allow_short_initial_connection_ids_(false),
+ allow_short_initial_server_connection_ids_(false),
last_version_label_(0),
expected_connection_id_length_(expected_connection_id_length),
should_update_expected_connection_id_length_(false),
@@ -382,34 +384,35 @@
// the next packet does not use them incorrectly.
}
-QuicConnectionId QuicDispatcher::MaybeReplaceConnectionId(
- QuicConnectionId connection_id,
+QuicConnectionId QuicDispatcher::MaybeReplaceServerConnectionId(
+ QuicConnectionId server_connection_id,
ParsedQuicVersion version) {
const uint8_t expected_connection_id_length =
no_framer_ ? expected_connection_id_length_
: framer_.GetExpectedConnectionIdLength();
- if (connection_id.length() == expected_connection_id_length) {
- return connection_id;
+ if (server_connection_id.length() == expected_connection_id_length) {
+ return server_connection_id;
}
DCHECK(QuicUtils::VariableLengthConnectionIdAllowedForVersion(
version.transport_version));
- auto it = connection_id_map_.find(connection_id);
+ auto it = connection_id_map_.find(server_connection_id);
if (it != connection_id_map_.end()) {
return it->second;
}
QuicConnectionId new_connection_id =
session_helper_->GenerateConnectionIdForReject(version.transport_version,
- connection_id);
+ server_connection_id);
DCHECK_EQ(expected_connection_id_length, new_connection_id.length());
- connection_id_map_.insert(std::make_pair(connection_id, new_connection_id));
- QUIC_DLOG(INFO) << "Replacing incoming connection ID " << connection_id
+ connection_id_map_.insert(
+ std::make_pair(server_connection_id, new_connection_id));
+ QUIC_DLOG(INFO) << "Replacing incoming connection ID " << server_connection_id
<< " with " << new_connection_id;
return new_connection_id;
}
bool QuicDispatcher::OnUnauthenticatedPublicHeader(
const QuicPacketHeader& header) {
- current_connection_id_ = header.destination_connection_id;
+ current_server_connection_id_ = header.destination_connection_id;
// Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC.
// Given that we can't even send a reply rejecting the packet, just drop the
@@ -423,7 +426,7 @@
if (header.destination_connection_id_included != CONNECTION_ID_PRESENT) {
return false;
}
- QuicConnectionId connection_id = header.destination_connection_id;
+ QuicConnectionId server_connection_id = header.destination_connection_id;
// The IETF spec requires the client to generate an initial server
// connection ID that is at least 64 bits long. After that initial
@@ -433,42 +436,43 @@
const uint8_t expected_connection_id_length =
no_framer_ ? expected_connection_id_length_
: framer_.GetExpectedConnectionIdLength();
- if (connection_id.length() < kQuicMinimumInitialConnectionIdLength &&
- connection_id.length() < expected_connection_id_length &&
- !allow_short_initial_connection_ids_) {
+ if (server_connection_id.length() < kQuicMinimumInitialConnectionIdLength &&
+ server_connection_id.length() < expected_connection_id_length &&
+ !allow_short_initial_server_connection_ids_) {
DCHECK(header.version_flag);
DCHECK(QuicUtils::VariableLengthConnectionIdAllowedForVersion(
header.version.transport_version));
QUIC_DLOG(INFO) << "Packet with short destination connection ID "
- << connection_id << " expected "
+ << server_connection_id << " expected "
<< static_cast<int>(expected_connection_id_length);
- ProcessUnauthenticatedHeaderFate(kFateTimeWait, connection_id, header.form,
- header.version_flag, header.version);
+ ProcessUnauthenticatedHeaderFate(kFateTimeWait, server_connection_id,
+ header.form, header.version_flag,
+ header.version);
return false;
}
// Packets with connection IDs for active connections are processed
// immediately.
- auto it = session_map_.find(connection_id);
+ auto it = session_map_.find(server_connection_id);
if (it != session_map_.end()) {
- DCHECK(!buffered_packets_.HasBufferedPackets(connection_id));
+ DCHECK(!buffered_packets_.HasBufferedPackets(server_connection_id));
it->second->ProcessUdpPacket(current_self_address_, current_peer_address_,
*current_packet_);
return false;
}
- if (buffered_packets_.HasChloForConnection(connection_id)) {
- BufferEarlyPacket(connection_id, header.form != GOOGLE_QUIC_PACKET,
+ if (buffered_packets_.HasChloForConnection(server_connection_id)) {
+ BufferEarlyPacket(server_connection_id, header.form != GOOGLE_QUIC_PACKET,
header.version);
return false;
}
// Check if we are buffering packets for this connection ID
- if (temporarily_buffered_connections_.find(connection_id) !=
+ if (temporarily_buffered_connections_.find(server_connection_id) !=
temporarily_buffered_connections_.end()) {
// This packet was received while the a CHLO for the same connection ID was
// being processed. Buffer it.
- BufferEarlyPacket(connection_id, header.form != GOOGLE_QUIC_PACKET,
+ BufferEarlyPacket(server_connection_id, header.form != GOOGLE_QUIC_PACKET,
header.version);
return false;
}
@@ -483,7 +487,7 @@
return false;
}
- if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) {
+ if (time_wait_list_manager_->IsConnectionIdInTimeWait(server_connection_id)) {
// This connection ID is already in time-wait state.
time_wait_list_manager_->ProcessPacket(
current_self_address_, current_peer_address_,
@@ -513,7 +517,7 @@
// Since the version is not supported, send a version negotiation
// packet and stop processing the current packet.
time_wait_list_manager()->SendVersionNegotiationPacket(
- connection_id, header.form != GOOGLE_QUIC_PACKET,
+ server_connection_id, header.form != GOOGLE_QUIC_PACKET,
GetSupportedVersions(), current_self_address_,
current_peer_address_, GetPerPacketContext());
}
@@ -539,25 +543,25 @@
}
void QuicDispatcher::ProcessHeader(const QuicPacketHeader& header) {
- QuicConnectionId connection_id = header.destination_connection_id;
+ QuicConnectionId server_connection_id = header.destination_connection_id;
// Packet's connection ID is unknown. Apply the validity checks.
QuicPacketFate fate = ValidityChecks(header);
if (fate == kFateProcess) {
// Execute stateless rejection logic to determine the packet fate, then
// invoke ProcessUnauthenticatedHeaderFate.
- MaybeRejectStatelessly(connection_id, header.form, header.version_flag,
- header.version);
+ MaybeRejectStatelessly(server_connection_id, header.form,
+ header.version_flag, header.version);
} else {
// If the fate is already known, process it without executing stateless
// rejection logic.
- ProcessUnauthenticatedHeaderFate(fate, connection_id, header.form,
+ ProcessUnauthenticatedHeaderFate(fate, server_connection_id, header.form,
header.version_flag, header.version);
}
}
void QuicDispatcher::ProcessUnauthenticatedHeaderFate(
QuicPacketFate fate,
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
PacketHeaderFormat form,
bool version_flag,
ParsedQuicVersion version) {
@@ -570,33 +574,36 @@
// MaybeRejectStatelessly or OnExpiredPackets might have already added the
// connection to time wait, in which case it should not be added again.
if (!GetQuicReloadableFlag(quic_use_cheap_stateless_rejects) ||
- !time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) {
+ !time_wait_list_manager_->IsConnectionIdInTimeWait(
+ server_connection_id)) {
// Add this connection_id to the time-wait state, to safely reject
// future packets.
- QUIC_DLOG(INFO) << "Adding connection ID " << connection_id
+ QUIC_DLOG(INFO) << "Adding connection ID " << server_connection_id
<< " to time-wait list.";
QUIC_CODE_COUNT(quic_reject_fate_time_wait);
StatelesslyTerminateConnection(
- connection_id, form, version_flag, version, QUIC_HANDSHAKE_FAILED,
- "Reject connection",
+ server_connection_id, form, version_flag, version,
+ QUIC_HANDSHAKE_FAILED, "Reject connection",
quic::QuicTimeWaitListManager::SEND_STATELESS_RESET);
}
- DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
+ DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(
+ server_connection_id));
time_wait_list_manager_->ProcessPacket(
- current_self_address_, current_peer_address_, connection_id, form,
- GetPerPacketContext());
+ current_self_address_, current_peer_address_, server_connection_id,
+ form, GetPerPacketContext());
// Any packets which were buffered while the stateless rejector logic was
// running should be discarded. Do not inform the time wait list manager,
// which should already have a made a decision about sending a reject
// based on the CHLO alone.
- buffered_packets_.DiscardPackets(connection_id);
+ buffered_packets_.DiscardPackets(server_connection_id);
break;
case kFateBuffer:
// This packet is a non-CHLO packet which has arrived before the
// corresponding CHLO, *or* this packet was received while the
// corresponding CHLO was being processed. Buffer it.
- BufferEarlyPacket(connection_id, form != GOOGLE_QUIC_PACKET, version);
+ BufferEarlyPacket(server_connection_id, form != GOOGLE_QUIC_PACKET,
+ version);
break;
case kFateDrop:
// Do nothing with the packet.
@@ -775,13 +782,13 @@
DeleteSessions();
}
-void QuicDispatcher::OnConnectionClosed(QuicConnectionId connection_id,
+void QuicDispatcher::OnConnectionClosed(QuicConnectionId server_connection_id,
QuicErrorCode error,
const std::string& error_details,
ConnectionCloseSource source) {
- auto it = session_map_.find(connection_id);
+ auto it = session_map_.find(server_connection_id);
if (it == session_map_.end()) {
- QUIC_BUG << "ConnectionId " << connection_id
+ QUIC_BUG << "ConnectionId " << server_connection_id
<< " does not exist in the session map. Error: "
<< QuicErrorCodeToString(error);
QUIC_BUG << QuicStackTrace();
@@ -789,7 +796,7 @@
}
QUIC_DLOG_IF(INFO, error != QUIC_NO_ERROR)
- << "Closing connection (" << connection_id
+ << "Closing connection (" << server_connection_id
<< ") due to error: " << QuicErrorCodeToString(error)
<< ", with details: " << error_details;
@@ -828,13 +835,13 @@
void QuicDispatcher::OnStopSendingReceived(const QuicStopSendingFrame& frame) {}
void QuicDispatcher::OnConnectionAddedToTimeWaitList(
- QuicConnectionId connection_id) {
- QUIC_DLOG(INFO) << "Connection " << connection_id
+ QuicConnectionId server_connection_id) {
+ QUIC_DLOG(INFO) << "Connection " << server_connection_id
<< " added to time wait list.";
}
void QuicDispatcher::StatelesslyTerminateConnection(
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
PacketHeaderFormat format,
bool version_flag,
ParsedQuicVersion version,
@@ -844,26 +851,27 @@
if (format != IETF_QUIC_LONG_HEADER_PACKET &&
(!GetQuicReloadableFlag(quic_terminate_gquic_connection_as_ietf) ||
!version_flag)) {
- QUIC_DVLOG(1) << "Statelessly terminating " << connection_id
+ QUIC_DVLOG(1) << "Statelessly terminating " << server_connection_id
<< " based on a non-ietf-long packet, action:" << action
<< ", error_code:" << error_code
<< ", error_details:" << error_details;
time_wait_list_manager_->AddConnectionIdToTimeWait(
- connection_id, format != GOOGLE_QUIC_PACKET, action, ENCRYPTION_INITIAL,
- nullptr);
+ server_connection_id, format != GOOGLE_QUIC_PACKET, action,
+ ENCRYPTION_INITIAL, nullptr);
return;
}
// If the version is known and supported by framer, send a connection close.
if (IsSupportedVersion(version)) {
QUIC_DVLOG(1)
- << "Statelessly terminating " << connection_id
+ << "Statelessly terminating " << server_connection_id
<< " based on an ietf-long packet, which has a supported version:"
<< version << ", error_code:" << error_code
<< ", error_details:" << error_details;
- StatelessConnectionTerminator terminator(
- connection_id, version, helper_.get(), time_wait_list_manager_.get());
+ StatelessConnectionTerminator terminator(server_connection_id, version,
+ helper_.get(),
+ time_wait_list_manager_.get());
// This also adds the connection to time wait list.
if (format == GOOGLE_QUIC_PACKET) {
QUIC_RELOADABLE_FLAG_COUNT_N(quic_terminate_gquic_connection_as_ietf, 1,
@@ -875,7 +883,7 @@
}
QUIC_DVLOG(1)
- << "Statelessly terminating " << connection_id
+ << "Statelessly terminating " << server_connection_id
<< " based on an ietf-long packet, which has an unsupported version:"
<< version << ", error_code:" << error_code
<< ", error_details:" << error_details;
@@ -883,13 +891,13 @@
// with an empty version list, which can be understood by the client.
std::vector<std::unique_ptr<QuicEncryptedPacket>> termination_packets;
termination_packets.push_back(QuicFramer::BuildVersionNegotiationPacket(
- connection_id, /*ietf_quic=*/format != GOOGLE_QUIC_PACKET,
+ server_connection_id, /*ietf_quic=*/format != GOOGLE_QUIC_PACKET,
ParsedQuicVersionVector{UnsupportedQuicVersion()}));
if (format == GOOGLE_QUIC_PACKET) {
QUIC_RELOADABLE_FLAG_COUNT_N(quic_terminate_gquic_connection_as_ietf, 2, 2);
}
time_wait_list_manager()->AddConnectionIdToTimeWait(
- connection_id, /*ietf_quic=*/format != GOOGLE_QUIC_PACKET,
+ server_connection_id, /*ietf_quic=*/format != GOOGLE_QUIC_PACKET,
QuicTimeWaitListManager::SEND_TERMINATION_PACKETS, ENCRYPTION_INITIAL,
&termination_packets);
}
@@ -913,7 +921,7 @@
DCHECK(!no_framer_);
QUIC_BUG_IF(
!time_wait_list_manager_->IsConnectionIdInTimeWait(
- current_connection_id_) &&
+ current_server_connection_id_) &&
!ShouldCreateSessionForUnknownVersion(framer_.last_version_label()))
<< "Unexpected version mismatch: "
<< QuicVersionLabelToString(framer_.last_version_label());
@@ -1090,11 +1098,11 @@
}
void QuicDispatcher::OnExpiredPackets(
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
BufferedPacketList early_arrived_packets) {
QUIC_CODE_COUNT(quic_reject_buffered_packets_expired);
StatelesslyTerminateConnection(
- connection_id,
+ server_connection_id,
early_arrived_packets.ietf_quic ? IETF_QUIC_LONG_HEADER_PACKET
: GOOGLE_QUIC_PACKET,
/*version_flag=*/true, early_arrived_packets.version,
@@ -1107,24 +1115,26 @@
new_sessions_allowed_per_event_loop_ = max_connections_to_create;
for (; new_sessions_allowed_per_event_loop_ > 0;
--new_sessions_allowed_per_event_loop_) {
- QuicConnectionId connection_id;
+ QuicConnectionId server_connection_id;
BufferedPacketList packet_list =
- buffered_packets_.DeliverPacketsForNextConnection(&connection_id);
+ buffered_packets_.DeliverPacketsForNextConnection(
+ &server_connection_id);
const std::list<BufferedPacket>& packets = packet_list.buffered_packets;
if (packets.empty()) {
return;
}
- QuicConnectionId original_connection_id = connection_id;
- connection_id =
- MaybeReplaceConnectionId(connection_id, packet_list.version);
+ QuicConnectionId original_connection_id = server_connection_id;
+ server_connection_id = MaybeReplaceServerConnectionId(server_connection_id,
+ packet_list.version);
QuicSession* session =
- CreateQuicSession(connection_id, packets.front().peer_address,
+ CreateQuicSession(server_connection_id, packets.front().peer_address,
packet_list.alpn, packet_list.version);
- if (original_connection_id != connection_id) {
+ if (original_connection_id != server_connection_id) {
session->connection()->AddIncomingConnectionId(original_connection_id);
}
- QUIC_DLOG(INFO) << "Created new session for " << connection_id;
- session_map_.insert(std::make_pair(connection_id, QuicWrapUnique(session)));
+ QUIC_DLOG(INFO) << "Created new session for " << server_connection_id;
+ session_map_.insert(
+ std::make_pair(server_connection_id, QuicWrapUnique(session)));
DeliverPacketsToSession(packets, session);
}
}
@@ -1134,21 +1144,23 @@
}
bool QuicDispatcher::ShouldCreateOrBufferPacketForConnection(
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
bool ietf_quic) {
- QUIC_VLOG(1) << "Received packet from new connection " << connection_id;
+ QUIC_VLOG(1) << "Received packet from new connection "
+ << server_connection_id;
return true;
}
// Return true if there is any packet buffered in the store.
-bool QuicDispatcher::HasBufferedPackets(QuicConnectionId connection_id) {
- return buffered_packets_.HasBufferedPackets(connection_id);
+bool QuicDispatcher::HasBufferedPackets(QuicConnectionId server_connection_id) {
+ return buffered_packets_.HasBufferedPackets(server_connection_id);
}
-void QuicDispatcher::OnBufferPacketFailure(EnqueuePacketResult result,
- QuicConnectionId connection_id) {
- QUIC_DLOG(INFO) << "Fail to buffer packet on connection " << connection_id
- << " because of " << result;
+void QuicDispatcher::OnBufferPacketFailure(
+ EnqueuePacketResult result,
+ QuicConnectionId server_connection_id) {
+ QUIC_DLOG(INFO) << "Fail to buffer packet on connection "
+ << server_connection_id << " because of " << result;
}
bool QuicDispatcher::ShouldAttemptCheapStatelessRejection() {
@@ -1160,21 +1172,22 @@
alarm_factory_.get());
}
-void QuicDispatcher::BufferEarlyPacket(QuicConnectionId connection_id,
+void QuicDispatcher::BufferEarlyPacket(QuicConnectionId server_connection_id,
bool ietf_quic,
ParsedQuicVersion version) {
- bool is_new_connection = !buffered_packets_.HasBufferedPackets(connection_id);
- if (is_new_connection &&
- !ShouldCreateOrBufferPacketForConnection(connection_id, ietf_quic)) {
+ bool is_new_connection =
+ !buffered_packets_.HasBufferedPackets(server_connection_id);
+ if (is_new_connection && !ShouldCreateOrBufferPacketForConnection(
+ server_connection_id, ietf_quic)) {
return;
}
EnqueuePacketResult rs = buffered_packets_.EnqueuePacket(
- connection_id, ietf_quic, *current_packet_, current_self_address_,
+ server_connection_id, ietf_quic, *current_packet_, current_self_address_,
current_peer_address_, /*is_chlo=*/false,
/*alpn=*/"", version);
if (rs != EnqueuePacketResult::SUCCESS) {
- OnBufferPacketFailure(rs, connection_id);
+ OnBufferPacketFailure(rs, server_connection_id);
}
}
@@ -1184,48 +1197,52 @@
// Don't any create new connection.
QUIC_CODE_COUNT(quic_reject_stop_accepting_new_connections);
StatelesslyTerminateConnection(
- current_connection_id(), form, /*version_flag=*/true, version,
+ current_server_connection_id(), form, /*version_flag=*/true, version,
QUIC_HANDSHAKE_FAILED, "Stop accepting new connections",
quic::QuicTimeWaitListManager::SEND_STATELESS_RESET);
// Time wait list will reject the packet correspondingly.
time_wait_list_manager()->ProcessPacket(
- current_self_address(), current_peer_address(), current_connection_id(),
- form, GetPerPacketContext());
+ current_self_address(), current_peer_address(),
+ current_server_connection_id(), form, GetPerPacketContext());
return;
}
- if (!buffered_packets_.HasBufferedPackets(current_connection_id_) &&
- !ShouldCreateOrBufferPacketForConnection(current_connection_id_,
+ if (!buffered_packets_.HasBufferedPackets(current_server_connection_id_) &&
+ !ShouldCreateOrBufferPacketForConnection(current_server_connection_id_,
form != GOOGLE_QUIC_PACKET)) {
return;
}
if (FLAGS_quic_allow_chlo_buffering &&
new_sessions_allowed_per_event_loop_ <= 0) {
// Can't create new session any more. Wait till next event loop.
- QUIC_BUG_IF(buffered_packets_.HasChloForConnection(current_connection_id_));
+ QUIC_BUG_IF(
+ buffered_packets_.HasChloForConnection(current_server_connection_id_));
EnqueuePacketResult rs = buffered_packets_.EnqueuePacket(
- current_connection_id_, form != GOOGLE_QUIC_PACKET, *current_packet_,
- current_self_address_, current_peer_address_,
+ current_server_connection_id_, form != GOOGLE_QUIC_PACKET,
+ *current_packet_, current_self_address_, current_peer_address_,
/*is_chlo=*/true, current_alpn_, version);
if (rs != EnqueuePacketResult::SUCCESS) {
- OnBufferPacketFailure(rs, current_connection_id_);
+ OnBufferPacketFailure(rs, current_server_connection_id_);
}
return;
}
- QuicConnectionId original_connection_id = current_connection_id_;
- current_connection_id_ =
- MaybeReplaceConnectionId(current_connection_id_, version);
+ QuicConnectionId original_connection_id = current_server_connection_id_;
+ current_server_connection_id_ =
+ MaybeReplaceServerConnectionId(current_server_connection_id_, version);
// Creates a new session and process all buffered packets for this connection.
- QuicSession* session = CreateQuicSession(
- current_connection_id_, current_peer_address_, current_alpn_, version);
- if (original_connection_id != current_connection_id_) {
+ QuicSession* session =
+ CreateQuicSession(current_server_connection_id_, current_peer_address_,
+ current_alpn_, version);
+ if (original_connection_id != current_server_connection_id_) {
session->connection()->AddIncomingConnectionId(original_connection_id);
}
- QUIC_DLOG(INFO) << "Created new session for " << current_connection_id_;
+ QUIC_DLOG(INFO) << "Created new session for "
+ << current_server_connection_id_;
session_map_.insert(
- std::make_pair(current_connection_id_, QuicWrapUnique(session)));
+ std::make_pair(current_server_connection_id_, QuicWrapUnique(session)));
std::list<BufferedPacket> packets =
- buffered_packets_.DeliverPackets(current_connection_id_).buffered_packets;
+ buffered_packets_.DeliverPackets(current_server_connection_id_)
+ .buffered_packets;
// Process CHLO at first.
session->ProcessUdpPacket(current_self_address_, current_peer_address_,
*current_packet_);
@@ -1295,12 +1312,13 @@
bool current_version_flag_;
};
-void QuicDispatcher::MaybeRejectStatelessly(QuicConnectionId connection_id,
- PacketHeaderFormat form,
- bool version_flag,
- ParsedQuicVersion version) {
+void QuicDispatcher::MaybeRejectStatelessly(
+ QuicConnectionId server_connection_id,
+ PacketHeaderFormat form,
+ bool version_flag,
+ ParsedQuicVersion version) {
if (version.handshake_protocol == PROTOCOL_TLS1_3) {
- ProcessUnauthenticatedHeaderFate(kFateProcess, connection_id, form,
+ ProcessUnauthenticatedHeaderFate(kFateProcess, server_connection_id, form,
version_flag, version);
return;
// TODO(nharper): Support buffering non-ClientHello packets when using TLS.
@@ -1315,14 +1333,15 @@
if (FLAGS_quic_allow_chlo_buffering &&
!ChloExtractor::Extract(*current_packet_, GetSupportedVersions(),
config_->create_session_tag_indicators(),
- &alpn_extractor, connection_id.length())) {
+ &alpn_extractor,
+ server_connection_id.length())) {
// Buffer non-CHLO packets.
- ProcessUnauthenticatedHeaderFate(kFateBuffer, connection_id, form,
+ ProcessUnauthenticatedHeaderFate(kFateBuffer, server_connection_id, form,
version_flag, version);
return;
}
current_alpn_ = alpn_extractor.ConsumeAlpn();
- ProcessUnauthenticatedHeaderFate(kFateProcess, connection_id, form,
+ ProcessUnauthenticatedHeaderFate(kFateProcess, server_connection_id, form,
version_flag, version);
return;
}
@@ -1337,8 +1356,8 @@
rejector.get());
if (!ChloExtractor::Extract(*current_packet_, GetSupportedVersions(),
config_->create_session_tag_indicators(),
- &validator, connection_id.length())) {
- ProcessUnauthenticatedHeaderFate(kFateBuffer, connection_id, form,
+ &validator, server_connection_id.length())) {
+ ProcessUnauthenticatedHeaderFate(kFateBuffer, server_connection_id, form,
version_flag, version);
return;
}
@@ -1347,13 +1366,13 @@
if (!validator.can_accept()) {
// This CHLO is prohibited by policy.
QUIC_CODE_COUNT(quic_reject_cant_accept_chlo);
- StatelessConnectionTerminator terminator(connection_id, version, helper(),
- time_wait_list_manager_.get());
+ StatelessConnectionTerminator terminator(
+ server_connection_id, version, helper(), time_wait_list_manager_.get());
terminator.CloseConnection(QUIC_HANDSHAKE_FAILED, validator.error_details(),
form != GOOGLE_QUIC_PACKET);
QuicSession::RecordConnectionCloseAtServer(
QUIC_HANDSHAKE_FAILED, ConnectionCloseSource::FROM_SELF);
- ProcessUnauthenticatedHeaderFate(kFateTimeWait, connection_id, form,
+ ProcessUnauthenticatedHeaderFate(kFateTimeWait, server_connection_id, form,
version_flag, version);
return;
}
@@ -1368,10 +1387,10 @@
// Insert into set of connection IDs to buffer
const bool ok =
- temporarily_buffered_connections_.insert(connection_id).second;
+ temporarily_buffered_connections_.insert(server_connection_id).second;
QUIC_BUG_IF(!ok)
<< "Processing multiple stateless rejections for connection ID "
- << connection_id;
+ << server_connection_id;
// Continue stateless rejector processing
std::unique_ptr<StatelessRejectorProcessDoneCallback> cb(
@@ -1395,7 +1414,7 @@
current_peer_address_ = current_peer_address;
current_self_address_ = current_self_address;
current_packet_ = current_packet.get();
- current_connection_id_ = rejector->connection_id();
+ current_server_connection_id_ = rejector->connection_id();
if (!no_framer_) {
framer_.set_version(first_version);
}
diff --git a/quic/core/quic_dispatcher.h b/quic/core/quic_dispatcher.h
index 6adf5f3..1798a0d 100644
--- a/quic/core/quic_dispatcher.h
+++ b/quic/core/quic_dispatcher.h
@@ -76,7 +76,7 @@
// QuicSession::Visitor interface implementation (via inheritance of
// QuicTimeWaitListManager::Visitor):
// Ensure that the closed connection is cleaned up asynchronously.
- void OnConnectionClosed(QuicConnectionId connection_id,
+ void OnConnectionClosed(QuicConnectionId server_connection_id,
QuicErrorCode error,
const std::string& error_details,
ConnectionCloseSource source) override;
@@ -99,7 +99,8 @@
// QuicTimeWaitListManager::Visitor interface implementation
// Called whenever the time wait list manager adds a new connection to the
// time-wait list.
- void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override;
+ void OnConnectionAddedToTimeWaitList(
+ QuicConnectionId server_connection_id) override;
using SessionMap = QuicUnorderedMap<QuicConnectionId,
std::unique_ptr<QuicSession>,
@@ -191,7 +192,7 @@
const QuicIetfStatelessResetPacket& packet) override;
// QuicBufferedPacketStore::VisitorInterface implementation.
- void OnExpiredPackets(QuicConnectionId connection_id,
+ void OnExpiredPackets(QuicConnectionId server_connection_id,
QuicBufferedPacketStore::BufferedPacketList
early_arrived_packets) override;
@@ -202,7 +203,7 @@
virtual bool HasChlosBuffered() const;
protected:
- virtual QuicSession* CreateQuicSession(QuicConnectionId connection_id,
+ virtual QuicSession* CreateQuicSession(QuicConnectionId server_connection_id,
const QuicSocketAddress& peer_address,
QuicStringPiece alpn,
const ParsedQuicVersion& version) = 0;
@@ -238,9 +239,9 @@
// will be owned by the dispatcher as time_wait_list_manager_
virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager();
- // Called when |connection_id| doesn't have an open connection yet, to buffer
- // |current_packet_| until it can be delivered to the connection.
- void BufferEarlyPacket(QuicConnectionId connection_id,
+ // Called when |server_connection_id| doesn't have an open connection yet,
+ // to buffer |current_packet_| until it can be delivered to the connection.
+ void BufferEarlyPacket(QuicConnectionId server_connection_id,
bool ietf_quic,
ParsedQuicVersion version);
@@ -269,8 +270,8 @@
const ParsedQuicVersionVector& GetSupportedVersions();
- QuicConnectionId current_connection_id() const {
- return current_connection_id_;
+ QuicConnectionId current_server_connection_id() const {
+ return current_server_connection_id_;
}
const QuicSocketAddress& current_self_address() const {
return current_self_address_;
@@ -319,15 +320,15 @@
// for CHLO. Returns true if a new connection should be created or its packets
// should be buffered, false otherwise.
virtual bool ShouldCreateOrBufferPacketForConnection(
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
bool ietf_quic);
- bool HasBufferedPackets(QuicConnectionId connection_id);
+ bool HasBufferedPackets(QuicConnectionId server_connection_id);
// Called when BufferEarlyPacket() fail to buffer the packet.
virtual void OnBufferPacketFailure(
QuicBufferedPacketStore::EnqueuePacketResult result,
- QuicConnectionId connection_id);
+ QuicConnectionId server_connection_id);
// Removes the session from the session map and write blocked list, and adds
// the ConnectionId to the time-wait list. If |session_closed_statelessly| is
@@ -344,7 +345,7 @@
// connection to time wait list or 2) directly add connection to time wait
// list with |action|.
void StatelesslyTerminateConnection(
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
PacketHeaderFormat format,
bool version_flag,
ParsedQuicVersion version,
@@ -374,10 +375,11 @@
}
// If true, the dispatcher will allow incoming initial packets that have
- // connection IDs shorter than 64 bits.
- void SetAllowShortInitialConnectionIds(
- bool allow_short_initial_connection_ids) {
- allow_short_initial_connection_ids_ = allow_short_initial_connection_ids;
+ // destination connection IDs shorter than 64 bits.
+ void SetAllowShortInitialServerConnectionIds(
+ bool allow_short_initial_server_connection_ids) {
+ allow_short_initial_server_connection_ids_ =
+ allow_short_initial_server_connection_ids;
}
private:
@@ -395,7 +397,7 @@
// possible and if the current packet contains a CHLO message. Determines a
// fate which describes what subsequent processing should be performed on the
// packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate.
- void MaybeRejectStatelessly(QuicConnectionId connection_id,
+ void MaybeRejectStatelessly(QuicConnectionId server_connection_id,
PacketHeaderFormat form,
bool version_flag,
ParsedQuicVersion version);
@@ -408,7 +410,7 @@
// Perform the appropriate actions on the current packet based on |fate| -
// either process, buffer, or drop it.
void ProcessUnauthenticatedHeaderFate(QuicPacketFate fate,
- QuicConnectionId connection_id,
+ QuicConnectionId server_connection_id,
PacketHeaderFormat form,
bool version_flag,
ParsedQuicVersion version);
@@ -440,8 +442,9 @@
// If the connection ID length is different from what the dispatcher expects,
// replace the connection ID with a random one of the right length,
// and save it to make sure the mapping is persistent.
- QuicConnectionId MaybeReplaceConnectionId(QuicConnectionId connection_id,
- ParsedQuicVersion version);
+ QuicConnectionId MaybeReplaceServerConnectionId(
+ QuicConnectionId server_connection_id,
+ ParsedQuicVersion version);
// Returns true if |version| is a supported protocol version.
bool IsSupportedVersion(const ParsedQuicVersion version);
@@ -505,7 +508,7 @@
const QuicReceivedPacket* current_packet_;
// If |current_packet_| is a CHLO packet, the extracted alpn.
std::string current_alpn_;
- QuicConnectionId current_connection_id_;
+ QuicConnectionId current_server_connection_id_;
// Used to get the supported versions based on flag. Does not own.
QuicVersionManager* version_manager_;
@@ -524,8 +527,9 @@
bool accept_new_connections_;
// If false, the dispatcher follows the IETF spec and rejects packets with
- // invalid connection IDs lengths below 64 bits. If true they are allowed.
- bool allow_short_initial_connection_ids_;
+ // invalid destination connection IDs lengths below 64 bits.
+ // If true they are allowed.
+ bool allow_short_initial_server_connection_ids_;
// The last QUIC version label received. Used when no_framer_ is true.
// TODO(fayang): remove this member variable, instead, add an argument to
diff --git a/quic/core/quic_dispatcher_test.cc b/quic/core/quic_dispatcher_test.cc
index 46c5bc2..de06c52 100644
--- a/quic/core/quic_dispatcher_test.cc
+++ b/quic/core/quic_dispatcher_test.cc
@@ -156,7 +156,7 @@
using QuicDispatcher::current_client_address;
using QuicDispatcher::current_peer_address;
using QuicDispatcher::current_self_address;
- using QuicDispatcher::SetAllowShortInitialConnectionIds;
+ using QuicDispatcher::SetAllowShortInitialServerConnectionIds;
using QuicDispatcher::writer;
};
@@ -686,7 +686,7 @@
QuicUtils::CreateRandomConnectionId(mock_helper_.GetRandomGenerator());
// Disable validation of invalid short connection IDs.
- dispatcher_->SetAllowShortInitialConnectionIds(true);
+ dispatcher_->SetAllowShortInitialServerConnectionIds(true);
// Note that StrayPacketTruncatedConnectionId covers the case where the
// validation is still enabled.
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index 27af834..eff8f49 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -462,7 +462,7 @@
uint8_t expected_connection_id_length)
: visitor_(nullptr),
error_(QUIC_NO_ERROR),
- last_serialized_connection_id_(EmptyQuicConnectionId()),
+ last_serialized_server_connection_id_(EmptyQuicConnectionId()),
last_version_label_(0),
version_(PROTOCOL_UNSUPPORTED, QUIC_VERSION_UNSUPPORTED),
supported_versions_(supported_versions),
@@ -1427,13 +1427,13 @@
// static
std::unique_ptr<QuicEncryptedPacket>
QuicFramer::BuildIetfVersionNegotiationPacket(
- QuicConnectionId connection_id,
+ QuicConnectionId source_connection_id,
const ParsedQuicVersionVector& versions) {
QUIC_DVLOG(1) << "Building IETF version negotiation packet: "
<< ParsedQuicVersionVectorToString(versions);
DCHECK(!versions.empty());
size_t len = kPacketHeaderTypeSize + kConnectionIdLengthSize +
- connection_id.length() +
+ source_connection_id.length() +
(versions.size() + 1) * kQuicVersionSize;
std::unique_ptr<char[]> buffer(new char[len]);
QuicDataWriter writer(len, buffer.get());
@@ -1452,8 +1452,8 @@
return nullptr;
}
- if (!AppendIetfConnectionIds(true, EmptyQuicConnectionId(), connection_id,
- &writer)) {
+ if (!AppendIetfConnectionIds(true, EmptyQuicConnectionId(),
+ source_connection_id, &writer)) {
return nullptr;
}
@@ -2064,14 +2064,14 @@
public_flags |= PACKET_PUBLIC_FLAGS_NONCE;
}
- QuicConnectionId connection_id =
+ QuicConnectionId server_connection_id =
GetServerConnectionIdAsSender(header, perspective_);
- QuicConnectionIdIncluded connection_id_included =
+ QuicConnectionIdIncluded server_connection_id_included =
GetServerConnectionIdIncludedAsSender(header, perspective_);
DCHECK_EQ(CONNECTION_ID_ABSENT,
GetClientConnectionIdIncludedAsSender(header, perspective_));
- switch (connection_id_included) {
+ switch (server_connection_id_included) {
case CONNECTION_ID_ABSENT:
if (!writer->WriteUInt8(public_flags |
PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID)) {
@@ -2080,9 +2080,9 @@
break;
case CONNECTION_ID_PRESENT:
QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion(
- connection_id, transport_version()))
+ server_connection_id, transport_version()))
<< "AppendPacketHeader: attempted to use connection ID "
- << connection_id << " which is invalid with version "
+ << server_connection_id << " which is invalid with version "
<< QuicVersionToString(transport_version());
public_flags |= PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID;
@@ -2090,12 +2090,12 @@
public_flags |= PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID_OLD;
}
if (!writer->WriteUInt8(public_flags) ||
- !writer->WriteConnectionId(connection_id)) {
+ !writer->WriteConnectionId(server_connection_id)) {
return false;
}
break;
}
- last_serialized_connection_id_ = connection_id;
+ last_serialized_server_connection_id_ = server_connection_id;
if (header.version_flag) {
DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
@@ -2194,7 +2194,7 @@
return false;
}
- last_serialized_connection_id_ = server_connection_id;
+ last_serialized_server_connection_id_ = server_connection_id;
if (QuicVersionHasLongHeaderLengths(transport_version()) &&
header.version_flag) {
@@ -2336,7 +2336,7 @@
break;
case PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID:
*header_connection_id_included = CONNECTION_ID_ABSENT;
- *header_connection_id = last_serialized_connection_id_;
+ *header_connection_id = last_serialized_server_connection_id_;
break;
}
@@ -2709,13 +2709,13 @@
header->destination_connection_id = header->source_connection_id;
} else if (header->destination_connection_id_included ==
CONNECTION_ID_ABSENT) {
- header->destination_connection_id = last_serialized_connection_id_;
+ header->destination_connection_id = last_serialized_server_connection_id_;
}
} else {
QUIC_RESTART_FLAG_COUNT_N(quic_do_not_override_connection_id, 5, 5);
if (header->source_connection_id_included == CONNECTION_ID_ABSENT) {
DCHECK_EQ(EmptyQuicConnectionId(), header->source_connection_id);
- header->source_connection_id = last_serialized_connection_id_;
+ header->source_connection_id = last_serialized_server_connection_id_;
}
}
diff --git a/quic/core/quic_framer.h b/quic/core/quic_framer.h
index ab0e8d7..e56aba2 100644
--- a/quic/core/quic_framer.h
+++ b/quic/core/quic_framer.h
@@ -441,7 +441,7 @@
// Returns a new IETF version negotiation packet.
static std::unique_ptr<QuicEncryptedPacket> BuildIetfVersionNegotiationPacket(
- QuicConnectionId connection_id,
+ QuicConnectionId source_connection_id,
const ParsedQuicVersionVector& versions);
// If header.version_flag is set, the version in the
@@ -958,8 +958,8 @@
// Largest successfully decrypted packet number per packet number space. Only
// used when supports_multiple_packet_number_spaces_ is true.
QuicPacketNumber largest_decrypted_packet_numbers_[NUM_PACKET_NUMBER_SPACES];
- // Updated by WritePacketHeader.
- QuicConnectionId last_serialized_connection_id_;
+ // Last server connection ID seen on the wire.
+ QuicConnectionId last_serialized_server_connection_id_;
// The last QUIC version label received.
// TODO(fayang): Remove this when deprecating
// quic_no_framer_object_in_dispatcher.
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index bf87ace..85af7ea 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -1011,8 +1011,8 @@
TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) {
SetDecrypterLevel(ENCRYPTION_FORWARD_SECURE);
- QuicFramerPeer::SetLastSerializedConnectionId(&framer_,
- FramerTestConnectionId());
+ QuicFramerPeer::SetLastSerializedServerConnectionId(&framer_,
+ FramerTestConnectionId());
QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT);
// clang-format off
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc
index c013ce8..77b5971 100644
--- a/quic/core/quic_packet_creator.cc
+++ b/quic/core/quic_packet_creator.cc
@@ -53,15 +53,15 @@
#define ENDPOINT \
(framer_->perspective() == Perspective::IS_SERVER ? "Server: " : "Client: ")
-QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id,
+QuicPacketCreator::QuicPacketCreator(QuicConnectionId server_connection_id,
QuicFramer* framer,
DelegateInterface* delegate)
- : QuicPacketCreator(connection_id,
+ : QuicPacketCreator(server_connection_id,
framer,
QuicRandom::GetInstance(),
delegate) {}
-QuicPacketCreator::QuicPacketCreator(QuicConnectionId connection_id,
+QuicPacketCreator::QuicPacketCreator(QuicConnectionId server_connection_id,
QuicFramer* framer,
QuicRandom* random,
DelegateInterface* delegate)
@@ -72,9 +72,9 @@
send_version_in_packet_(framer->perspective() == Perspective::IS_CLIENT),
have_diversification_nonce_(false),
max_packet_length_(0),
- connection_id_included_(CONNECTION_ID_PRESENT),
+ server_connection_id_included_(CONNECTION_ID_PRESENT),
packet_size_(0),
- connection_id_(connection_id),
+ server_connection_id_(server_connection_id),
packet_(QuicPacketNumber(),
PACKET_1BYTE_PACKET_NUMBER,
nullptr,
@@ -626,8 +626,8 @@
const ParsedQuicVersionVector& supported_versions) {
DCHECK_EQ(Perspective::IS_SERVER, framer_->perspective());
std::unique_ptr<QuicEncryptedPacket> encrypted =
- QuicFramer::BuildVersionNegotiationPacket(connection_id_, ietf_quic,
- supported_versions);
+ QuicFramer::BuildVersionNegotiationPacket(server_connection_id_,
+ ietf_quic, supported_versions);
DCHECK(encrypted);
DCHECK_GE(max_packet_length_, encrypted->length());
return encrypted;
@@ -737,24 +737,24 @@
QuicConnectionId QuicPacketCreator::GetDestinationConnectionId() const {
if (!GetQuicRestartFlag(quic_do_not_override_connection_id)) {
- return connection_id_;
+ return server_connection_id_;
}
QUIC_RESTART_FLAG_COUNT_N(quic_do_not_override_connection_id, 1, 5);
if (framer_->perspective() == Perspective::IS_SERVER) {
return EmptyQuicConnectionId();
}
- return connection_id_;
+ return server_connection_id_;
}
QuicConnectionId QuicPacketCreator::GetSourceConnectionId() const {
if (!GetQuicRestartFlag(quic_do_not_override_connection_id)) {
- return connection_id_;
+ return server_connection_id_;
}
QUIC_RESTART_FLAG_COUNT_N(quic_do_not_override_connection_id, 6, 6);
if (framer_->perspective() == Perspective::IS_CLIENT) {
return EmptyQuicConnectionId();
}
- return connection_id_;
+ return server_connection_id_;
}
QuicConnectionIdIncluded QuicPacketCreator::GetDestinationConnectionIdIncluded()
@@ -767,7 +767,7 @@
? CONNECTION_ID_PRESENT
: CONNECTION_ID_ABSENT;
}
- return connection_id_included_;
+ return server_connection_id_included_;
}
QuicConnectionIdIncluded QuicPacketCreator::GetSourceConnectionIdIncluded()
@@ -779,14 +779,14 @@
if (GetQuicRestartFlag(quic_do_not_override_connection_id) &&
framer_->perspective() == Perspective::IS_SERVER) {
QUIC_RESTART_FLAG_COUNT_N(quic_do_not_override_connection_id, 2, 5);
- return connection_id_included_;
+ return server_connection_id_included_;
}
return CONNECTION_ID_ABSENT;
}
QuicConnectionIdLength QuicPacketCreator::GetDestinationConnectionIdLength()
const {
- DCHECK(QuicUtils::IsConnectionIdValidForVersion(connection_id_,
+ DCHECK(QuicUtils::IsConnectionIdValidForVersion(server_connection_id_,
transport_version()));
return GetDestinationConnectionIdIncluded() == CONNECTION_ID_PRESENT
? static_cast<QuicConnectionIdLength>(
@@ -795,7 +795,7 @@
}
QuicConnectionIdLength QuicPacketCreator::GetSourceConnectionIdLength() const {
- DCHECK(QuicUtils::IsConnectionIdValidForVersion(connection_id_,
+ DCHECK(QuicUtils::IsConnectionIdValidForVersion(server_connection_id_,
transport_version()));
return GetSourceConnectionIdIncluded() == CONNECTION_ID_PRESENT
? static_cast<QuicConnectionIdLength>(
@@ -1019,17 +1019,18 @@
return packet_.encryption_level == ENCRYPTION_INITIAL;
}
-void QuicPacketCreator::SetConnectionIdIncluded(
- QuicConnectionIdIncluded connection_id_included) {
- DCHECK(connection_id_included == CONNECTION_ID_PRESENT ||
- connection_id_included == CONNECTION_ID_ABSENT);
+void QuicPacketCreator::SetServerConnectionIdIncluded(
+ QuicConnectionIdIncluded server_connection_id_included) {
+ DCHECK(server_connection_id_included == CONNECTION_ID_PRESENT ||
+ server_connection_id_included == CONNECTION_ID_ABSENT);
DCHECK(framer_->perspective() == Perspective::IS_SERVER ||
- connection_id_included != CONNECTION_ID_ABSENT);
- connection_id_included_ = connection_id_included;
+ server_connection_id_included != CONNECTION_ID_ABSENT);
+ server_connection_id_included_ = server_connection_id_included;
}
-void QuicPacketCreator::SetConnectionId(QuicConnectionId connection_id) {
- connection_id_ = connection_id;
+void QuicPacketCreator::SetServerConnectionId(
+ QuicConnectionId server_connection_id) {
+ server_connection_id_ = server_connection_id;
}
void QuicPacketCreator::SetTransmissionType(TransmissionType type) {
diff --git a/quic/core/quic_packet_creator.h b/quic/core/quic_packet_creator.h
index 6e1f7a2..259b577 100644
--- a/quic/core/quic_packet_creator.h
+++ b/quic/core/quic_packet_creator.h
@@ -56,10 +56,10 @@
virtual void OnFrameAddedToPacket(const QuicFrame& frame) {}
};
- QuicPacketCreator(QuicConnectionId connection_id,
+ QuicPacketCreator(QuicConnectionId server_connection_id,
QuicFramer* framer,
DelegateInterface* delegate);
- QuicPacketCreator(QuicConnectionId connection_id,
+ QuicPacketCreator(QuicConnectionId server_connection_id,
QuicFramer* framer,
QuicRandom* random,
DelegateInterface* delegate);
@@ -222,11 +222,12 @@
// Returns length of source connection ID to send over the wire.
QuicConnectionIdLength GetSourceConnectionIdLength() const;
- // Sets whether the connection ID should be sent over the wire.
- void SetConnectionIdIncluded(QuicConnectionIdIncluded connection_id_included);
+ // Sets whether the server connection ID should be sent over the wire.
+ void SetServerConnectionIdIncluded(
+ QuicConnectionIdIncluded server_connection_id_included);
// Update the connection ID used in outgoing packets.
- void SetConnectionId(QuicConnectionId connection_id);
+ void SetServerConnectionId(QuicConnectionId server_connection_id);
// Sets the encryption level that will be applied to new packets.
void set_encryption_level(EncryptionLevel level) {
@@ -393,8 +394,8 @@
// Maximum length including headers and encryption (UDP payload length.)
QuicByteCount max_packet_length_;
size_t max_plaintext_size_;
- // Whether the connection_id is sent over the wire.
- QuicConnectionIdIncluded connection_id_included_;
+ // Whether the server_connection_id is sent over the wire.
+ QuicConnectionIdIncluded server_connection_id_included_;
// Frames to be added to the next SerializedPacket
QuicFrames queued_frames_;
@@ -403,7 +404,7 @@
// TODO(ianswett): Move packet_size_ into SerializedPacket once
// QuicEncryptedPacket has been flattened into SerializedPacket.
size_t packet_size_;
- QuicConnectionId connection_id_;
+ QuicConnectionId server_connection_id_;
// Packet used to invoke OnSerializedPacket.
SerializedPacket packet_;
diff --git a/quic/core/quic_packet_generator.cc b/quic/core/quic_packet_generator.cc
index d811f9d..f490900 100644
--- a/quic/core/quic_packet_generator.cc
+++ b/quic/core/quic_packet_generator.cc
@@ -17,12 +17,12 @@
namespace quic {
-QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id,
+QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId server_connection_id,
QuicFramer* framer,
QuicRandom* random_generator,
DelegateInterface* delegate)
: delegate_(delegate),
- packet_creator_(connection_id, framer, random_generator, delegate),
+ packet_creator_(server_connection_id, framer, random_generator, delegate),
next_transmission_type_(NOT_RETRANSMISSION),
flusher_attached_(false),
should_send_ack_(false),
@@ -438,11 +438,11 @@
max_packets_in_flight);
}
-void QuicPacketGenerator::SetConnectionIdLength(uint32_t length) {
+void QuicPacketGenerator::SetServerConnectionIdLength(uint32_t length) {
if (length == 0) {
- packet_creator_.SetConnectionIdIncluded(CONNECTION_ID_ABSENT);
+ packet_creator_.SetServerConnectionIdIncluded(CONNECTION_ID_ABSENT);
} else {
- packet_creator_.SetConnectionIdIncluded(CONNECTION_ID_PRESENT);
+ packet_creator_.SetServerConnectionIdIncluded(CONNECTION_ID_PRESENT);
}
}
@@ -569,8 +569,9 @@
return packet_creator_.GetGuaranteedLargestMessagePayload();
}
-void QuicPacketGenerator::SetConnectionId(QuicConnectionId connection_id) {
- packet_creator_.SetConnectionId(connection_id);
+void QuicPacketGenerator::SetServerConnectionId(
+ QuicConnectionId server_connection_id) {
+ packet_creator_.SetServerConnectionId(server_connection_id);
}
} // namespace quic
diff --git a/quic/core/quic_packet_generator.h b/quic/core/quic_packet_generator.h
index 417fda6..6ea8215 100644
--- a/quic/core/quic_packet_generator.h
+++ b/quic/core/quic_packet_generator.h
@@ -76,7 +76,7 @@
QuicStopWaitingFrame* stop_waiting) = 0;
};
- QuicPacketGenerator(QuicConnectionId connection_id,
+ QuicPacketGenerator(QuicConnectionId server_connection_id,
QuicFramer* framer,
QuicRandom* random_generator,
DelegateInterface* delegate);
@@ -185,8 +185,8 @@
void UpdatePacketNumberLength(QuicPacketNumber least_packet_awaited_by_peer,
QuicPacketCount max_packets_in_flight);
- // Set the minimum number of bytes for the connection id length;
- void SetConnectionIdLength(uint32_t length);
+ // Set the minimum number of bytes for the server connection id length;
+ void SetServerConnectionIdLength(uint32_t length);
// Sets the encrypter to use for the encryption level.
void SetEncrypter(EncryptionLevel level,
@@ -235,8 +235,8 @@
QuicPacketLength GetCurrentLargestMessagePayload() const;
QuicPacketLength GetGuaranteedLargestMessagePayload() const;
- // Update the connection ID used in outgoing packets.
- void SetConnectionId(QuicConnectionId connection_id);
+ // Update the server connection ID used in outgoing packets.
+ void SetServerConnectionId(QuicConnectionId server_connection_id);
void set_debug_delegate(QuicPacketCreator::DebugDelegate* debug_delegate) {
packet_creator_.set_debug_delegate(debug_delegate);
diff --git a/quic/core/quic_packet_generator_test.cc b/quic/core/quic_packet_generator_test.cc
index 676d6e7..e1899ff 100644
--- a/quic/core/quic_packet_generator_test.cc
+++ b/quic/core/quic_packet_generator_test.cc
@@ -1139,12 +1139,12 @@
TEST_F(QuicPacketGeneratorTest, TestConnectionIdLength) {
QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_SERVER);
- generator_.SetConnectionIdLength(0);
+ generator_.SetServerConnectionIdLength(0);
EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID,
creator_->GetDestinationConnectionIdLength());
for (size_t i = 1; i < 10; i++) {
- generator_.SetConnectionIdLength(i);
+ generator_.SetServerConnectionIdLength(i);
if (framer_.transport_version() > QUIC_VERSION_43) {
EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID,
creator_->GetDestinationConnectionIdLength());
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h
index d8f40c9..dc7153a 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -52,7 +52,7 @@
virtual ~Visitor() {}
// Called when the connection is closed after the streams have been closed.
- virtual void OnConnectionClosed(QuicConnectionId connection_id,
+ virtual void OnConnectionClosed(QuicConnectionId server_connection_id,
QuicErrorCode error,
const std::string& error_details,
ConnectionCloseSource source) = 0;
diff --git a/quic/quartc/quartc_dispatcher.cc b/quic/quartc/quartc_dispatcher.cc
index fd4f289..091d56b 100644
--- a/quic/quartc/quartc_dispatcher.cc
+++ b/quic/quartc/quartc_dispatcher.cc
@@ -39,7 +39,7 @@
// Allow incoming packets to set our expected connection ID length.
SetShouldUpdateExpectedConnectionIdLength(true);
// Allow incoming packets with connection ID lengths shorter than allowed.
- SetAllowShortInitialConnectionIds(true);
+ SetAllowShortInitialServerConnectionIds(true);
// QuicDispatcher takes ownership of the writer.
QuicDispatcher::InitializeWithWriter(packet_writer.release());
// NB: This must happen *after* InitializeWithWriter. It can call us back
diff --git a/quic/quartc/quartc_dispatcher.h b/quic/quartc/quartc_dispatcher.h
index 26b52ac..239b6ef 100644
--- a/quic/quartc/quartc_dispatcher.h
+++ b/quic/quartc/quartc_dispatcher.h
@@ -41,7 +41,7 @@
Delegate* delegate);
~QuartcDispatcher() override;
- QuartcSession* CreateQuicSession(QuicConnectionId connection_id,
+ QuartcSession* CreateQuicSession(QuicConnectionId server_connection_id,
const QuicSocketAddress& client_address,
QuicStringPiece alpn,
const ParsedQuicVersion& version) override;
diff --git a/quic/test_tools/quic_framer_peer.cc b/quic/test_tools/quic_framer_peer.cc
index 23486ea..dcb0e94 100644
--- a/quic/test_tools/quic_framer_peer.cc
+++ b/quic/test_tools/quic_framer_peer.cc
@@ -22,10 +22,10 @@
}
// static
-void QuicFramerPeer::SetLastSerializedConnectionId(
+void QuicFramerPeer::SetLastSerializedServerConnectionId(
QuicFramer* framer,
- QuicConnectionId connection_id) {
- framer->last_serialized_connection_id_ = connection_id;
+ QuicConnectionId server_connection_id) {
+ framer->last_serialized_server_connection_id_ = server_connection_id;
}
// static
diff --git a/quic/test_tools/quic_framer_peer.h b/quic/test_tools/quic_framer_peer.h
index 4a5efa6..e363105 100644
--- a/quic/test_tools/quic_framer_peer.h
+++ b/quic/test_tools/quic_framer_peer.h
@@ -22,8 +22,9 @@
QuicPacketNumberLength packet_number_length,
QuicPacketNumber last_packet_number,
uint64_t packet_number);
- static void SetLastSerializedConnectionId(QuicFramer* framer,
- QuicConnectionId connection_id);
+ static void SetLastSerializedServerConnectionId(
+ QuicFramer* framer,
+ QuicConnectionId server_connection_id);
static void SetLargestPacketNumber(QuicFramer* framer,
QuicPacketNumber packet_number);
static void SetPerspective(QuicFramer* framer, Perspective perspective);