Rename variables of type StunMessage* from `request` to `message`.
This is just to reduce confusion since StunMessage and StunRequest
instances are frequently used together and message objects are often
configured from within request objects (which makes the name confusing).
Bug: none
Change-Id: I8bf5e774a5149239dd3023817614d411633bf583
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258484
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36533}
diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc
index 38a186d..67e1a5e 100644
--- a/p2p/base/connection.cc
+++ b/p2p/base/connection.cc
@@ -168,54 +168,54 @@
: StunRequest(manager, std::make_unique<IceMessage>()),
connection_(connection) {}
-void ConnectionRequest::Prepare(StunMessage* request) {
+void ConnectionRequest::Prepare(StunMessage* message) {
RTC_DCHECK_RUN_ON(connection_->network_thread_);
- request->SetType(STUN_BINDING_REQUEST);
+ message->SetType(STUN_BINDING_REQUEST);
std::string username;
connection_->port()->CreateStunUsername(
connection_->remote_candidate().username(), &username);
// Note that the order of attributes does not impact the parsing on the
// receiver side. The attribute is retrieved then by iterating and matching
// over all parsed attributes. See StunMessage::GetAttribute.
- request->AddAttribute(
+ message->AddAttribute(
std::make_unique<StunByteStringAttribute>(STUN_ATTR_USERNAME, username));
// connection_ already holds this ping, so subtract one from count.
if (connection_->port()->send_retransmit_count_attribute()) {
- request->AddAttribute(std::make_unique<StunUInt32Attribute>(
+ message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_RETRANSMIT_COUNT,
static_cast<uint32_t>(connection_->pings_since_last_response_.size() -
1)));
}
uint32_t network_info = connection_->port()->Network()->id();
network_info = (network_info << 16) | connection_->port()->network_cost();
- request->AddAttribute(std::make_unique<StunUInt32Attribute>(
+ message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_GOOG_NETWORK_INFO, network_info));
if (connection_->field_trials_->piggyback_ice_check_acknowledgement &&
connection_->last_ping_id_received()) {
- request->AddAttribute(std::make_unique<StunByteStringAttribute>(
+ message->AddAttribute(std::make_unique<StunByteStringAttribute>(
STUN_ATTR_GOOG_LAST_ICE_CHECK_RECEIVED,
connection_->last_ping_id_received().value()));
}
// Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role.
if (connection_->port()->GetIceRole() == ICEROLE_CONTROLLING) {
- request->AddAttribute(std::make_unique<StunUInt64Attribute>(
+ message->AddAttribute(std::make_unique<StunUInt64Attribute>(
STUN_ATTR_ICE_CONTROLLING, connection_->port()->IceTiebreaker()));
// We should have either USE_CANDIDATE attribute or ICE_NOMINATION
// attribute but not both. That was enforced in p2ptransportchannel.
if (connection_->use_candidate_attr()) {
- request->AddAttribute(
+ message->AddAttribute(
std::make_unique<StunByteStringAttribute>(STUN_ATTR_USE_CANDIDATE));
}
if (connection_->nomination_ &&
connection_->nomination_ != connection_->acked_nomination()) {
- request->AddAttribute(std::make_unique<StunUInt32Attribute>(
+ message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_NOMINATION, connection_->nomination_));
}
} else if (connection_->port()->GetIceRole() == ICEROLE_CONTROLLED) {
- request->AddAttribute(std::make_unique<StunUInt64Attribute>(
+ message->AddAttribute(std::make_unique<StunUInt64Attribute>(
STUN_ATTR_ICE_CONTROLLED, connection_->port()->IceTiebreaker()));
} else {
RTC_DCHECK_NOTREACHED();
@@ -234,7 +234,7 @@
uint32_t prflx_priority =
type_preference << 24 |
(connection_->local_candidate().priority() & 0x00FFFFFF);
- request->AddAttribute(std::make_unique<StunUInt32Attribute>(
+ message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_PRIORITY, prflx_priority));
if (connection_->field_trials_->enable_goog_ping &&
@@ -245,16 +245,16 @@
auto list =
StunAttribute::CreateUInt16ListAttribute(STUN_ATTR_GOOG_MISC_INFO);
list->AddTypeAtIndex(kSupportGoogPingVersionRequestIndex, kGoogPingVersion);
- request->AddAttribute(std::move(list));
+ message->AddAttribute(std::move(list));
}
- if (connection_->ShouldSendGoogPing(request)) {
- request->SetType(GOOG_PING_REQUEST);
- request->ClearAttributes();
- request->AddMessageIntegrity32(connection_->remote_candidate().password());
+ if (connection_->ShouldSendGoogPing(message)) {
+ message->SetType(GOOG_PING_REQUEST);
+ message->ClearAttributes();
+ message->AddMessageIntegrity32(connection_->remote_candidate().password());
} else {
- request->AddMessageIntegrity(connection_->remote_candidate().password());
- request->AddFingerprint();
+ message->AddMessageIntegrity(connection_->remote_candidate().password());
+ message->AddFingerprint();
}
}
@@ -576,7 +576,7 @@
if (msg->IntegrityOk()) {
requests_.CheckResponse(msg.get());
}
- // Otherwise silently discard the response message.
+ // Otherwise silently discard the response.
break;
// Remote end point sent an STUN indication instead of regular binding
@@ -699,25 +699,25 @@
}
}
-void Connection::SendStunBindingResponse(const StunMessage* request) {
+void Connection::SendStunBindingResponse(const StunMessage* message) {
RTC_DCHECK_RUN_ON(network_thread_);
- RTC_DCHECK(request->type() == STUN_BINDING_REQUEST);
+ RTC_DCHECK_EQ(message->type(), STUN_BINDING_REQUEST);
- // Retrieve the username from the request.
+ // Retrieve the username from the `message`.
const StunByteStringAttribute* username_attr =
- request->GetByteString(STUN_ATTR_USERNAME);
+ message->GetByteString(STUN_ATTR_USERNAME);
RTC_DCHECK(username_attr != NULL);
if (username_attr == NULL) {
// No valid username, skip the response.
return;
}
- // Fill in the response message.
+ // Fill in the response.
StunMessage response;
response.SetType(STUN_BINDING_RESPONSE);
- response.SetTransactionID(request->transaction_id());
+ response.SetTransactionID(message->transaction_id());
const StunUInt32Attribute* retransmit_attr =
- request->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
+ message->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
if (retransmit_attr) {
// Inherit the incoming retransmit value in the response so the other side
// can see our view of lost pings.
@@ -736,8 +736,8 @@
STUN_ATTR_XOR_MAPPED_ADDRESS, remote_candidate_.address()));
if (field_trials_->announce_goog_ping) {
- // Check if request contains a announce-request.
- auto goog_misc = request->GetUInt16List(STUN_ATTR_GOOG_MISC_INFO);
+ // Check if message contains a announce-request.
+ auto goog_misc = message->GetUInt16List(STUN_ATTR_GOOG_MISC_INFO);
if (goog_misc != nullptr &&
goog_misc->Size() >= kSupportGoogPingVersionRequestIndex &&
// Which version can we handle...currently any >= 1
@@ -756,14 +756,14 @@
SendResponseMessage(response);
}
-void Connection::SendGoogPingResponse(const StunMessage* request) {
+void Connection::SendGoogPingResponse(const StunMessage* message) {
RTC_DCHECK_RUN_ON(network_thread_);
- RTC_DCHECK(request->type() == GOOG_PING_REQUEST);
+ RTC_DCHECK(message->type() == GOOG_PING_REQUEST);
- // Fill in the response message.
+ // Fill in the response.
StunMessage response;
response.SetType(GOOG_PING_RESPONSE);
- response.SetTransactionID(request->transaction_id());
+ response.SetTransactionID(message->transaction_id());
response.AddMessageIntegrity32(local_candidate().password());
SendResponseMessage(response);
}
@@ -773,7 +773,7 @@
// Where I send the response.
const rtc::SocketAddress& addr = remote_candidate_.address();
- // Send the response message.
+ // Send the response.
rtc::ByteBufferWriter buf;
response.Write(&buf);
rtc::PacketOptions options(port_->StunDscpValue());
diff --git a/p2p/base/connection.h b/p2p/base/connection.h
index d871bc4..c606160 100644
--- a/p2p/base/connection.h
+++ b/p2p/base/connection.h
@@ -58,7 +58,7 @@
class ConnectionRequest : public StunRequest {
public:
ConnectionRequest(StunRequestManager& manager, Connection* connection);
- void Prepare(StunMessage* request) override;
+ void Prepare(StunMessage* message) override;
void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override;
void OnTimeout() override;
@@ -306,8 +306,8 @@
// Does not trigger SignalStateChange
void ForgetLearnedState();
- void SendStunBindingResponse(const StunMessage* request);
- void SendGoogPingResponse(const StunMessage* request);
+ void SendStunBindingResponse(const StunMessage* message);
+ void SendGoogPingResponse(const StunMessage* message);
void SendResponseMessage(const StunMessage& response);
// An accessor for unit tests.
diff --git a/p2p/base/port.cc b/p2p/base/port.cc
index 74db59d..4a7daaf 100644
--- a/p2p/base/port.cc
+++ b/p2p/base/port.cc
@@ -739,21 +739,21 @@
return false;
}
-void Port::SendBindingErrorResponse(StunMessage* request,
+void Port::SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr,
int error_code,
const std::string& reason) {
- RTC_DCHECK(request->type() == STUN_BINDING_REQUEST ||
- request->type() == GOOG_PING_REQUEST);
+ RTC_DCHECK(message->type() == STUN_BINDING_REQUEST ||
+ message->type() == GOOG_PING_REQUEST);
// Fill in the response message.
StunMessage response;
- if (request->type() == STUN_BINDING_REQUEST) {
+ if (message->type() == STUN_BINDING_REQUEST) {
response.SetType(STUN_BINDING_ERROR_RESPONSE);
} else {
response.SetType(GOOG_PING_ERROR_RESPONSE);
}
- response.SetTransactionID(request->transaction_id());
+ response.SetTransactionID(message->transaction_id());
// When doing GICE, we need to write out the error code incorrectly to
// maintain backwards compatiblility.
@@ -766,15 +766,15 @@
// because we don't have enough information to determine the shared secret.
if (error_code != STUN_ERROR_BAD_REQUEST &&
error_code != STUN_ERROR_UNAUTHORIZED &&
- request->type() != GOOG_PING_REQUEST) {
- if (request->type() == STUN_BINDING_REQUEST) {
+ message->type() != GOOG_PING_REQUEST) {
+ if (message->type() == STUN_BINDING_REQUEST) {
response.AddMessageIntegrity(password_);
} else {
response.AddMessageIntegrity32(password_);
}
}
- if (request->type() == STUN_BINDING_REQUEST) {
+ if (message->type() == STUN_BINDING_REQUEST) {
response.AddFingerprint();
}
@@ -792,15 +792,15 @@
}
void Port::SendUnknownAttributesErrorResponse(
- StunMessage* request,
+ StunMessage* message,
const rtc::SocketAddress& addr,
const std::vector<uint16_t>& unknown_types) {
- RTC_DCHECK(request->type() == STUN_BINDING_REQUEST);
+ RTC_DCHECK(message->type() == STUN_BINDING_REQUEST);
// Fill in the response message.
StunMessage response;
response.SetType(STUN_BINDING_ERROR_RESPONSE);
- response.SetTransactionID(request->transaction_id());
+ response.SetTransactionID(message->transaction_id());
auto error_attr = StunAttribute::CreateErrorCode();
error_attr->SetCode(STUN_ERROR_UNKNOWN_ATTRIBUTE);
diff --git a/p2p/base/port.h b/p2p/base/port.h
index 56f551d..b2aa9b2 100644
--- a/p2p/base/port.h
+++ b/p2p/base/port.h
@@ -312,12 +312,12 @@
const rtc::SocketAddress& remote_addr) const;
// Sends a response error to the given request.
- void SendBindingErrorResponse(StunMessage* request,
+ void SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr,
int error_code,
const std::string& reason) override;
void SendUnknownAttributesErrorResponse(
- StunMessage* request,
+ StunMessage* message,
const rtc::SocketAddress& addr,
const std::vector<uint16_t>& unknown_types);
diff --git a/p2p/base/port_interface.h b/p2p/base/port_interface.h
index 02fd979..babe27d 100644
--- a/p2p/base/port_interface.h
+++ b/p2p/base/port_interface.h
@@ -107,7 +107,7 @@
// Sends a response message (normal or error) to the given request. One of
// these methods should be called as a response to SignalUnknownAddress.
- virtual void SendBindingErrorResponse(StunMessage* request,
+ virtual void SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr,
int error_code,
const std::string& reason) = 0;
diff --git a/p2p/base/stun_port.cc b/p2p/base/stun_port.cc
index 5d7c426..6d16b9c 100644
--- a/p2p/base/stun_port.cc
+++ b/p2p/base/stun_port.cc
@@ -47,8 +47,8 @@
const rtc::SocketAddress& server_addr() const { return server_addr_; }
- void Prepare(StunMessage* request) override {
- request->SetType(STUN_BINDING_REQUEST);
+ void Prepare(StunMessage* message) override {
+ message->SetType(STUN_BINDING_REQUEST);
}
void OnResponse(StunMessage* response) override {
diff --git a/p2p/base/stun_request.cc b/p2p/base/stun_request.cc
index 0131779..eebdd07 100644
--- a/p2p/base/stun_request.cc
+++ b/p2p/base/stun_request.cc
@@ -191,9 +191,9 @@
}
StunRequest::StunRequest(StunRequestManager& manager,
- std::unique_ptr<StunMessage> request)
+ std::unique_ptr<StunMessage> message)
: manager_(manager),
- msg_(std::move(request)),
+ msg_(std::move(message)),
tstamp_(0),
count_(0),
timeout_(false) {
diff --git a/p2p/base/stun_request.h b/p2p/base/stun_request.h
index e75804d..f4d6b2b 100644
--- a/p2p/base/stun_request.h
+++ b/p2p/base/stun_request.h
@@ -86,7 +86,7 @@
public:
explicit StunRequest(StunRequestManager& manager);
StunRequest(StunRequestManager& manager,
- std::unique_ptr<StunMessage> request);
+ std::unique_ptr<StunMessage> message);
~StunRequest() override;
// Causes our wrapped StunMessage to be Prepared
@@ -117,7 +117,7 @@
// Fills in a request object to be sent. Note that request's transaction ID
// will already be set and cannot be changed.
- virtual void Prepare(StunMessage* request) {}
+ virtual void Prepare(StunMessage* message) {}
// Called when the message receives a response or times out.
virtual void OnResponse(StunMessage* response) {}
diff --git a/p2p/base/stun_request_unittest.cc b/p2p/base/stun_request_unittest.cc
index b551c34..125bb47 100644
--- a/p2p/base/stun_request_unittest.cc
+++ b/p2p/base/stun_request_unittest.cc
@@ -99,8 +99,8 @@
}
virtual void OnTimeout() { test_->OnTimeout(); }
- virtual void Prepare(StunMessage* request) {
- request->SetType(STUN_BINDING_REQUEST);
+ virtual void Prepare(StunMessage* message) {
+ message->SetType(STUN_BINDING_REQUEST);
}
StunRequestTest* test_;
diff --git a/p2p/base/stun_server.cc b/p2p/base/stun_server.cc
index 382b787..25f0634 100644
--- a/p2p/base/stun_server.cc
+++ b/p2p/base/stun_server.cc
@@ -83,15 +83,15 @@
RTC_LOG_ERR(LS_ERROR) << "sendto";
}
-void StunServer::GetStunBindResponse(StunMessage* request,
+void StunServer::GetStunBindResponse(StunMessage* message,
const rtc::SocketAddress& remote_addr,
StunMessage* response) const {
response->SetType(STUN_BINDING_RESPONSE);
- response->SetTransactionID(request->transaction_id());
+ response->SetTransactionID(message->transaction_id());
- // Tell the user the address that we received their request from.
+ // Tell the user the address that we received their message from.
std::unique_ptr<StunAddressAttribute> mapped_addr;
- if (request->IsLegacy()) {
+ if (message->IsLegacy()) {
mapped_addr = StunAttribute::CreateAddress(STUN_ATTR_MAPPED_ADDRESS);
} else {
mapped_addr = StunAttribute::CreateXorAddress(STUN_ATTR_XOR_MAPPED_ADDRESS);
diff --git a/p2p/base/stun_server.h b/p2p/base/stun_server.h
index f2126db..54d8d90 100644
--- a/p2p/base/stun_server.h
+++ b/p2p/base/stun_server.h
@@ -58,7 +58,7 @@
void SendResponse(const StunMessage& msg, const rtc::SocketAddress& addr);
// A helper method to compose a STUN binding response.
- void GetStunBindResponse(StunMessage* request,
+ void GetStunBindResponse(StunMessage* message,
const rtc::SocketAddress& remote_addr,
StunMessage* response) const;
diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc
index 8729a82..e15f352 100644
--- a/p2p/base/turn_port.cc
+++ b/p2p/base/turn_port.cc
@@ -73,7 +73,7 @@
class TurnAllocateRequest : public StunRequest {
public:
explicit TurnAllocateRequest(TurnPort* port);
- void Prepare(StunMessage* request) override;
+ void Prepare(StunMessage* message) override;
void OnSent() override;
void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override;
@@ -91,7 +91,7 @@
class TurnRefreshRequest : public StunRequest {
public:
explicit TurnRefreshRequest(TurnPort* port);
- void Prepare(StunMessage* request) override;
+ void Prepare(StunMessage* message) override;
void OnSent() override;
void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override;
@@ -110,7 +110,7 @@
TurnEntry* entry,
const rtc::SocketAddress& ext_addr,
const std::string& remote_ufrag);
- void Prepare(StunMessage* request) override;
+ void Prepare(StunMessage* message) override;
void OnSent() override;
void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override;
@@ -131,7 +131,7 @@
TurnEntry* entry,
int channel_id,
const rtc::SocketAddress& ext_addr);
- void Prepare(StunMessage* request) override;
+ void Prepare(StunMessage* message) override;
void OnSent() override;
void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override;
@@ -1364,18 +1364,18 @@
: StunRequest(port->request_manager(), std::make_unique<TurnMessage>()),
port_(port) {}
-void TurnAllocateRequest::Prepare(StunMessage* request) {
+void TurnAllocateRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC 5766, Section 6.1.
- request->SetType(TURN_ALLOCATE_REQUEST);
+ message->SetType(TURN_ALLOCATE_REQUEST);
auto transport_attr =
StunAttribute::CreateUInt32(STUN_ATTR_REQUESTED_TRANSPORT);
transport_attr->SetValue(IPPROTO_UDP << 24);
- request->AddAttribute(std::move(transport_attr));
+ message->AddAttribute(std::move(transport_attr));
if (!port_->hash().empty()) {
- port_->AddRequestAuthInfo(request);
+ port_->AddRequestAuthInfo(message);
}
- port_->MaybeAddTurnLoggingId(request);
- port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
+ port_->MaybeAddTurnLoggingId(message);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
}
void TurnAllocateRequest::OnSent() {
@@ -1554,17 +1554,17 @@
port_(port),
lifetime_(-1) {}
-void TurnRefreshRequest::Prepare(StunMessage* request) {
+void TurnRefreshRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC 5766, Section 7.1.
// No attributes need to be included.
- request->SetType(TURN_REFRESH_REQUEST);
+ message->SetType(TURN_REFRESH_REQUEST);
if (lifetime_ > -1) {
- request->AddAttribute(
+ message->AddAttribute(
std::make_unique<StunUInt32Attribute>(STUN_ATTR_LIFETIME, lifetime_));
}
- port_->AddRequestAuthInfo(request);
- port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
+ port_->AddRequestAuthInfo(message);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
}
void TurnRefreshRequest::OnSent() {
@@ -1642,18 +1642,18 @@
this, &TurnCreatePermissionRequest::OnEntryDestroyed);
}
-void TurnCreatePermissionRequest::Prepare(StunMessage* request) {
+void TurnCreatePermissionRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC5766, Section 9.1.
- request->SetType(TURN_CREATE_PERMISSION_REQUEST);
- request->AddAttribute(std::make_unique<StunXorAddressAttribute>(
+ message->SetType(TURN_CREATE_PERMISSION_REQUEST);
+ message->AddAttribute(std::make_unique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
if (port_->field_trials_ &&
port_->field_trials_->IsEnabled("WebRTC-TurnAddMultiMapping")) {
- request->AddAttribute(std::make_unique<cricket::StunByteStringAttribute>(
+ message->AddAttribute(std::make_unique<cricket::StunByteStringAttribute>(
STUN_ATTR_MULTI_MAPPING, remote_ufrag_));
}
- port_->AddRequestAuthInfo(request);
- port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
+ port_->AddRequestAuthInfo(message);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
}
void TurnCreatePermissionRequest::OnSent() {
@@ -1715,15 +1715,15 @@
&TurnChannelBindRequest::OnEntryDestroyed);
}
-void TurnChannelBindRequest::Prepare(StunMessage* request) {
+void TurnChannelBindRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC5766, Section 11.1.
- request->SetType(TURN_CHANNEL_BIND_REQUEST);
- request->AddAttribute(std::make_unique<StunUInt32Attribute>(
+ message->SetType(TURN_CHANNEL_BIND_REQUEST);
+ message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_CHANNEL_NUMBER, channel_id_ << 16));
- request->AddAttribute(std::make_unique<StunXorAddressAttribute>(
+ message->AddAttribute(std::make_unique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
- port_->AddRequestAuthInfo(request);
- port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request);
+ port_->AddRequestAuthInfo(message);
+ port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
}
void TurnChannelBindRequest::OnSent() {