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}
This commit is contained in:
Tommi 2022-04-12 14:03:40 +02:00 committed by WebRTC LUCI CQ
parent 2545257982
commit 278b19da38
12 changed files with 90 additions and 90 deletions

View File

@ -168,54 +168,54 @@ ConnectionRequest::ConnectionRequest(StunRequestManager& manager,
: StunRequest(manager, std::make_unique<IceMessage>()), : StunRequest(manager, std::make_unique<IceMessage>()),
connection_(connection) {} connection_(connection) {}
void ConnectionRequest::Prepare(StunMessage* request) { void ConnectionRequest::Prepare(StunMessage* message) {
RTC_DCHECK_RUN_ON(connection_->network_thread_); RTC_DCHECK_RUN_ON(connection_->network_thread_);
request->SetType(STUN_BINDING_REQUEST); message->SetType(STUN_BINDING_REQUEST);
std::string username; std::string username;
connection_->port()->CreateStunUsername( connection_->port()->CreateStunUsername(
connection_->remote_candidate().username(), &username); connection_->remote_candidate().username(), &username);
// Note that the order of attributes does not impact the parsing on the // Note that the order of attributes does not impact the parsing on the
// receiver side. The attribute is retrieved then by iterating and matching // receiver side. The attribute is retrieved then by iterating and matching
// over all parsed attributes. See StunMessage::GetAttribute. // over all parsed attributes. See StunMessage::GetAttribute.
request->AddAttribute( message->AddAttribute(
std::make_unique<StunByteStringAttribute>(STUN_ATTR_USERNAME, username)); std::make_unique<StunByteStringAttribute>(STUN_ATTR_USERNAME, username));
// connection_ already holds this ping, so subtract one from count. // connection_ already holds this ping, so subtract one from count.
if (connection_->port()->send_retransmit_count_attribute()) { if (connection_->port()->send_retransmit_count_attribute()) {
request->AddAttribute(std::make_unique<StunUInt32Attribute>( message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_RETRANSMIT_COUNT, STUN_ATTR_RETRANSMIT_COUNT,
static_cast<uint32_t>(connection_->pings_since_last_response_.size() - static_cast<uint32_t>(connection_->pings_since_last_response_.size() -
1))); 1)));
} }
uint32_t network_info = connection_->port()->Network()->id(); uint32_t network_info = connection_->port()->Network()->id();
network_info = (network_info << 16) | connection_->port()->network_cost(); 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)); STUN_ATTR_GOOG_NETWORK_INFO, network_info));
if (connection_->field_trials_->piggyback_ice_check_acknowledgement && if (connection_->field_trials_->piggyback_ice_check_acknowledgement &&
connection_->last_ping_id_received()) { connection_->last_ping_id_received()) {
request->AddAttribute(std::make_unique<StunByteStringAttribute>( message->AddAttribute(std::make_unique<StunByteStringAttribute>(
STUN_ATTR_GOOG_LAST_ICE_CHECK_RECEIVED, STUN_ATTR_GOOG_LAST_ICE_CHECK_RECEIVED,
connection_->last_ping_id_received().value())); connection_->last_ping_id_received().value()));
} }
// Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role. // Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role.
if (connection_->port()->GetIceRole() == ICEROLE_CONTROLLING) { 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())); STUN_ATTR_ICE_CONTROLLING, connection_->port()->IceTiebreaker()));
// We should have either USE_CANDIDATE attribute or ICE_NOMINATION // We should have either USE_CANDIDATE attribute or ICE_NOMINATION
// attribute but not both. That was enforced in p2ptransportchannel. // attribute but not both. That was enforced in p2ptransportchannel.
if (connection_->use_candidate_attr()) { if (connection_->use_candidate_attr()) {
request->AddAttribute( message->AddAttribute(
std::make_unique<StunByteStringAttribute>(STUN_ATTR_USE_CANDIDATE)); std::make_unique<StunByteStringAttribute>(STUN_ATTR_USE_CANDIDATE));
} }
if (connection_->nomination_ && if (connection_->nomination_ &&
connection_->nomination_ != connection_->acked_nomination()) { connection_->nomination_ != connection_->acked_nomination()) {
request->AddAttribute(std::make_unique<StunUInt32Attribute>( message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_NOMINATION, connection_->nomination_)); STUN_ATTR_NOMINATION, connection_->nomination_));
} }
} else if (connection_->port()->GetIceRole() == ICEROLE_CONTROLLED) { } 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())); STUN_ATTR_ICE_CONTROLLED, connection_->port()->IceTiebreaker()));
} else { } else {
RTC_DCHECK_NOTREACHED(); RTC_DCHECK_NOTREACHED();
@ -234,7 +234,7 @@ void ConnectionRequest::Prepare(StunMessage* request) {
uint32_t prflx_priority = uint32_t prflx_priority =
type_preference << 24 | type_preference << 24 |
(connection_->local_candidate().priority() & 0x00FFFFFF); (connection_->local_candidate().priority() & 0x00FFFFFF);
request->AddAttribute(std::make_unique<StunUInt32Attribute>( message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_PRIORITY, prflx_priority)); STUN_ATTR_PRIORITY, prflx_priority));
if (connection_->field_trials_->enable_goog_ping && if (connection_->field_trials_->enable_goog_ping &&
@ -245,16 +245,16 @@ void ConnectionRequest::Prepare(StunMessage* request) {
auto list = auto list =
StunAttribute::CreateUInt16ListAttribute(STUN_ATTR_GOOG_MISC_INFO); StunAttribute::CreateUInt16ListAttribute(STUN_ATTR_GOOG_MISC_INFO);
list->AddTypeAtIndex(kSupportGoogPingVersionRequestIndex, kGoogPingVersion); list->AddTypeAtIndex(kSupportGoogPingVersionRequestIndex, kGoogPingVersion);
request->AddAttribute(std::move(list)); message->AddAttribute(std::move(list));
} }
if (connection_->ShouldSendGoogPing(request)) { if (connection_->ShouldSendGoogPing(message)) {
request->SetType(GOOG_PING_REQUEST); message->SetType(GOOG_PING_REQUEST);
request->ClearAttributes(); message->ClearAttributes();
request->AddMessageIntegrity32(connection_->remote_candidate().password()); message->AddMessageIntegrity32(connection_->remote_candidate().password());
} else { } else {
request->AddMessageIntegrity(connection_->remote_candidate().password()); message->AddMessageIntegrity(connection_->remote_candidate().password());
request->AddFingerprint(); message->AddFingerprint();
} }
} }
@ -576,7 +576,7 @@ void Connection::OnReadPacket(const char* data,
if (msg->IntegrityOk()) { if (msg->IntegrityOk()) {
requests_.CheckResponse(msg.get()); requests_.CheckResponse(msg.get());
} }
// Otherwise silently discard the response message. // Otherwise silently discard the response.
break; break;
// Remote end point sent an STUN indication instead of regular binding // Remote end point sent an STUN indication instead of regular binding
@ -699,25 +699,25 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) {
} }
} }
void Connection::SendStunBindingResponse(const StunMessage* request) { void Connection::SendStunBindingResponse(const StunMessage* message) {
RTC_DCHECK_RUN_ON(network_thread_); 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 = const StunByteStringAttribute* username_attr =
request->GetByteString(STUN_ATTR_USERNAME); message->GetByteString(STUN_ATTR_USERNAME);
RTC_DCHECK(username_attr != NULL); RTC_DCHECK(username_attr != NULL);
if (username_attr == NULL) { if (username_attr == NULL) {
// No valid username, skip the response. // No valid username, skip the response.
return; return;
} }
// Fill in the response message. // Fill in the response.
StunMessage response; StunMessage response;
response.SetType(STUN_BINDING_RESPONSE); response.SetType(STUN_BINDING_RESPONSE);
response.SetTransactionID(request->transaction_id()); response.SetTransactionID(message->transaction_id());
const StunUInt32Attribute* retransmit_attr = const StunUInt32Attribute* retransmit_attr =
request->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); message->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
if (retransmit_attr) { if (retransmit_attr) {
// Inherit the incoming retransmit value in the response so the other side // Inherit the incoming retransmit value in the response so the other side
// can see our view of lost pings. // can see our view of lost pings.
@ -736,8 +736,8 @@ void Connection::SendStunBindingResponse(const StunMessage* request) {
STUN_ATTR_XOR_MAPPED_ADDRESS, remote_candidate_.address())); STUN_ATTR_XOR_MAPPED_ADDRESS, remote_candidate_.address()));
if (field_trials_->announce_goog_ping) { if (field_trials_->announce_goog_ping) {
// Check if request contains a announce-request. // Check if message contains a announce-request.
auto goog_misc = request->GetUInt16List(STUN_ATTR_GOOG_MISC_INFO); auto goog_misc = message->GetUInt16List(STUN_ATTR_GOOG_MISC_INFO);
if (goog_misc != nullptr && if (goog_misc != nullptr &&
goog_misc->Size() >= kSupportGoogPingVersionRequestIndex && goog_misc->Size() >= kSupportGoogPingVersionRequestIndex &&
// Which version can we handle...currently any >= 1 // Which version can we handle...currently any >= 1
@ -756,14 +756,14 @@ void Connection::SendStunBindingResponse(const StunMessage* request) {
SendResponseMessage(response); SendResponseMessage(response);
} }
void Connection::SendGoogPingResponse(const StunMessage* request) { void Connection::SendGoogPingResponse(const StunMessage* message) {
RTC_DCHECK_RUN_ON(network_thread_); 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; StunMessage response;
response.SetType(GOOG_PING_RESPONSE); response.SetType(GOOG_PING_RESPONSE);
response.SetTransactionID(request->transaction_id()); response.SetTransactionID(message->transaction_id());
response.AddMessageIntegrity32(local_candidate().password()); response.AddMessageIntegrity32(local_candidate().password());
SendResponseMessage(response); SendResponseMessage(response);
} }
@ -773,7 +773,7 @@ void Connection::SendResponseMessage(const StunMessage& response) {
// Where I send the response. // Where I send the response.
const rtc::SocketAddress& addr = remote_candidate_.address(); const rtc::SocketAddress& addr = remote_candidate_.address();
// Send the response message. // Send the response.
rtc::ByteBufferWriter buf; rtc::ByteBufferWriter buf;
response.Write(&buf); response.Write(&buf);
rtc::PacketOptions options(port_->StunDscpValue()); rtc::PacketOptions options(port_->StunDscpValue());

View File

@ -58,7 +58,7 @@ struct CandidatePair final : public CandidatePairInterface {
class ConnectionRequest : public StunRequest { class ConnectionRequest : public StunRequest {
public: public:
ConnectionRequest(StunRequestManager& manager, Connection* connection); ConnectionRequest(StunRequestManager& manager, Connection* connection);
void Prepare(StunMessage* request) override; void Prepare(StunMessage* message) override;
void OnResponse(StunMessage* response) override; void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override; void OnErrorResponse(StunMessage* response) override;
void OnTimeout() override; void OnTimeout() override;
@ -306,8 +306,8 @@ class Connection : public CandidatePairInterface, public sigslot::has_slots<> {
// Does not trigger SignalStateChange // Does not trigger SignalStateChange
void ForgetLearnedState(); void ForgetLearnedState();
void SendStunBindingResponse(const StunMessage* request); void SendStunBindingResponse(const StunMessage* message);
void SendGoogPingResponse(const StunMessage* request); void SendGoogPingResponse(const StunMessage* message);
void SendResponseMessage(const StunMessage& response); void SendResponseMessage(const StunMessage& response);
// An accessor for unit tests. // An accessor for unit tests.

View File

@ -739,21 +739,21 @@ bool Port::CanHandleIncomingPacketsFrom(const rtc::SocketAddress&) const {
return false; return false;
} }
void Port::SendBindingErrorResponse(StunMessage* request, void Port::SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
int error_code, int error_code,
const std::string& reason) { const std::string& reason) {
RTC_DCHECK(request->type() == STUN_BINDING_REQUEST || RTC_DCHECK(message->type() == STUN_BINDING_REQUEST ||
request->type() == GOOG_PING_REQUEST); message->type() == GOOG_PING_REQUEST);
// Fill in the response message. // Fill in the response message.
StunMessage response; StunMessage response;
if (request->type() == STUN_BINDING_REQUEST) { if (message->type() == STUN_BINDING_REQUEST) {
response.SetType(STUN_BINDING_ERROR_RESPONSE); response.SetType(STUN_BINDING_ERROR_RESPONSE);
} else { } else {
response.SetType(GOOG_PING_ERROR_RESPONSE); 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 // When doing GICE, we need to write out the error code incorrectly to
// maintain backwards compatiblility. // maintain backwards compatiblility.
@ -766,15 +766,15 @@ void Port::SendBindingErrorResponse(StunMessage* request,
// because we don't have enough information to determine the shared secret. // because we don't have enough information to determine the shared secret.
if (error_code != STUN_ERROR_BAD_REQUEST && if (error_code != STUN_ERROR_BAD_REQUEST &&
error_code != STUN_ERROR_UNAUTHORIZED && error_code != STUN_ERROR_UNAUTHORIZED &&
request->type() != GOOG_PING_REQUEST) { message->type() != GOOG_PING_REQUEST) {
if (request->type() == STUN_BINDING_REQUEST) { if (message->type() == STUN_BINDING_REQUEST) {
response.AddMessageIntegrity(password_); response.AddMessageIntegrity(password_);
} else { } else {
response.AddMessageIntegrity32(password_); response.AddMessageIntegrity32(password_);
} }
} }
if (request->type() == STUN_BINDING_REQUEST) { if (message->type() == STUN_BINDING_REQUEST) {
response.AddFingerprint(); response.AddFingerprint();
} }
@ -792,15 +792,15 @@ void Port::SendBindingErrorResponse(StunMessage* request,
} }
void Port::SendUnknownAttributesErrorResponse( void Port::SendUnknownAttributesErrorResponse(
StunMessage* request, StunMessage* message,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
const std::vector<uint16_t>& unknown_types) { 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. // Fill in the response message.
StunMessage response; StunMessage response;
response.SetType(STUN_BINDING_ERROR_RESPONSE); response.SetType(STUN_BINDING_ERROR_RESPONSE);
response.SetTransactionID(request->transaction_id()); response.SetTransactionID(message->transaction_id());
auto error_attr = StunAttribute::CreateErrorCode(); auto error_attr = StunAttribute::CreateErrorCode();
error_attr->SetCode(STUN_ERROR_UNKNOWN_ATTRIBUTE); error_attr->SetCode(STUN_ERROR_UNKNOWN_ATTRIBUTE);

View File

@ -312,12 +312,12 @@ class Port : public PortInterface,
const rtc::SocketAddress& remote_addr) const; const rtc::SocketAddress& remote_addr) const;
// Sends a response error to the given request. // Sends a response error to the given request.
void SendBindingErrorResponse(StunMessage* request, void SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
int error_code, int error_code,
const std::string& reason) override; const std::string& reason) override;
void SendUnknownAttributesErrorResponse( void SendUnknownAttributesErrorResponse(
StunMessage* request, StunMessage* message,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
const std::vector<uint16_t>& unknown_types); const std::vector<uint16_t>& unknown_types);

View File

@ -107,7 +107,7 @@ class PortInterface {
// Sends a response message (normal or error) to the given request. One of // Sends a response message (normal or error) to the given request. One of
// these methods should be called as a response to SignalUnknownAddress. // these methods should be called as a response to SignalUnknownAddress.
virtual void SendBindingErrorResponse(StunMessage* request, virtual void SendBindingErrorResponse(StunMessage* message,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
int error_code, int error_code,
const std::string& reason) = 0; const std::string& reason) = 0;

View File

@ -47,8 +47,8 @@ class StunBindingRequest : public StunRequest {
const rtc::SocketAddress& server_addr() const { return server_addr_; } const rtc::SocketAddress& server_addr() const { return server_addr_; }
void Prepare(StunMessage* request) override { void Prepare(StunMessage* message) override {
request->SetType(STUN_BINDING_REQUEST); message->SetType(STUN_BINDING_REQUEST);
} }
void OnResponse(StunMessage* response) override { void OnResponse(StunMessage* response) override {

View File

@ -191,9 +191,9 @@ StunRequest::StunRequest(StunRequestManager& manager)
} }
StunRequest::StunRequest(StunRequestManager& manager, StunRequest::StunRequest(StunRequestManager& manager,
std::unique_ptr<StunMessage> request) std::unique_ptr<StunMessage> message)
: manager_(manager), : manager_(manager),
msg_(std::move(request)), msg_(std::move(message)),
tstamp_(0), tstamp_(0),
count_(0), count_(0),
timeout_(false) { timeout_(false) {

View File

@ -86,7 +86,7 @@ class StunRequest : public rtc::MessageHandler {
public: public:
explicit StunRequest(StunRequestManager& manager); explicit StunRequest(StunRequestManager& manager);
StunRequest(StunRequestManager& manager, StunRequest(StunRequestManager& manager,
std::unique_ptr<StunMessage> request); std::unique_ptr<StunMessage> message);
~StunRequest() override; ~StunRequest() override;
// Causes our wrapped StunMessage to be Prepared // Causes our wrapped StunMessage to be Prepared
@ -117,7 +117,7 @@ class StunRequest : public rtc::MessageHandler {
// Fills in a request object to be sent. Note that request's transaction ID // Fills in a request object to be sent. Note that request's transaction ID
// will already be set and cannot be changed. // 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. // Called when the message receives a response or times out.
virtual void OnResponse(StunMessage* response) {} virtual void OnResponse(StunMessage* response) {}

View File

@ -99,8 +99,8 @@ class StunRequestThunker : public StunRequest {
} }
virtual void OnTimeout() { test_->OnTimeout(); } virtual void OnTimeout() { test_->OnTimeout(); }
virtual void Prepare(StunMessage* request) { virtual void Prepare(StunMessage* message) {
request->SetType(STUN_BINDING_REQUEST); message->SetType(STUN_BINDING_REQUEST);
} }
StunRequestTest* test_; StunRequestTest* test_;

View File

@ -83,15 +83,15 @@ void StunServer::SendResponse(const StunMessage& msg,
RTC_LOG_ERR(LS_ERROR) << "sendto"; RTC_LOG_ERR(LS_ERROR) << "sendto";
} }
void StunServer::GetStunBindResponse(StunMessage* request, void StunServer::GetStunBindResponse(StunMessage* message,
const rtc::SocketAddress& remote_addr, const rtc::SocketAddress& remote_addr,
StunMessage* response) const { StunMessage* response) const {
response->SetType(STUN_BINDING_RESPONSE); 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; std::unique_ptr<StunAddressAttribute> mapped_addr;
if (request->IsLegacy()) { if (message->IsLegacy()) {
mapped_addr = StunAttribute::CreateAddress(STUN_ATTR_MAPPED_ADDRESS); mapped_addr = StunAttribute::CreateAddress(STUN_ATTR_MAPPED_ADDRESS);
} else { } else {
mapped_addr = StunAttribute::CreateXorAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); mapped_addr = StunAttribute::CreateXorAddress(STUN_ATTR_XOR_MAPPED_ADDRESS);

View File

@ -58,7 +58,7 @@ class StunServer : public sigslot::has_slots<> {
void SendResponse(const StunMessage& msg, const rtc::SocketAddress& addr); void SendResponse(const StunMessage& msg, const rtc::SocketAddress& addr);
// A helper method to compose a STUN binding response. // A helper method to compose a STUN binding response.
void GetStunBindResponse(StunMessage* request, void GetStunBindResponse(StunMessage* message,
const rtc::SocketAddress& remote_addr, const rtc::SocketAddress& remote_addr,
StunMessage* response) const; StunMessage* response) const;

View File

@ -73,7 +73,7 @@ static int GetRelayPreference(cricket::ProtocolType proto) {
class TurnAllocateRequest : public StunRequest { class TurnAllocateRequest : public StunRequest {
public: public:
explicit TurnAllocateRequest(TurnPort* port); explicit TurnAllocateRequest(TurnPort* port);
void Prepare(StunMessage* request) override; void Prepare(StunMessage* message) override;
void OnSent() override; void OnSent() override;
void OnResponse(StunMessage* response) override; void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override; void OnErrorResponse(StunMessage* response) override;
@ -91,7 +91,7 @@ class TurnAllocateRequest : public StunRequest {
class TurnRefreshRequest : public StunRequest { class TurnRefreshRequest : public StunRequest {
public: public:
explicit TurnRefreshRequest(TurnPort* port); explicit TurnRefreshRequest(TurnPort* port);
void Prepare(StunMessage* request) override; void Prepare(StunMessage* message) override;
void OnSent() override; void OnSent() override;
void OnResponse(StunMessage* response) override; void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override; void OnErrorResponse(StunMessage* response) override;
@ -110,7 +110,7 @@ class TurnCreatePermissionRequest : public StunRequest,
TurnEntry* entry, TurnEntry* entry,
const rtc::SocketAddress& ext_addr, const rtc::SocketAddress& ext_addr,
const std::string& remote_ufrag); const std::string& remote_ufrag);
void Prepare(StunMessage* request) override; void Prepare(StunMessage* message) override;
void OnSent() override; void OnSent() override;
void OnResponse(StunMessage* response) override; void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override; void OnErrorResponse(StunMessage* response) override;
@ -131,7 +131,7 @@ class TurnChannelBindRequest : public StunRequest, public sigslot::has_slots<> {
TurnEntry* entry, TurnEntry* entry,
int channel_id, int channel_id,
const rtc::SocketAddress& ext_addr); const rtc::SocketAddress& ext_addr);
void Prepare(StunMessage* request) override; void Prepare(StunMessage* message) override;
void OnSent() override; void OnSent() override;
void OnResponse(StunMessage* response) override; void OnResponse(StunMessage* response) override;
void OnErrorResponse(StunMessage* response) override; void OnErrorResponse(StunMessage* response) override;
@ -1364,18 +1364,18 @@ TurnAllocateRequest::TurnAllocateRequest(TurnPort* port)
: StunRequest(port->request_manager(), std::make_unique<TurnMessage>()), : StunRequest(port->request_manager(), std::make_unique<TurnMessage>()),
port_(port) {} port_(port) {}
void TurnAllocateRequest::Prepare(StunMessage* request) { void TurnAllocateRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC 5766, Section 6.1. // Create the request as indicated in RFC 5766, Section 6.1.
request->SetType(TURN_ALLOCATE_REQUEST); message->SetType(TURN_ALLOCATE_REQUEST);
auto transport_attr = auto transport_attr =
StunAttribute::CreateUInt32(STUN_ATTR_REQUESTED_TRANSPORT); StunAttribute::CreateUInt32(STUN_ATTR_REQUESTED_TRANSPORT);
transport_attr->SetValue(IPPROTO_UDP << 24); transport_attr->SetValue(IPPROTO_UDP << 24);
request->AddAttribute(std::move(transport_attr)); message->AddAttribute(std::move(transport_attr));
if (!port_->hash().empty()) { if (!port_->hash().empty()) {
port_->AddRequestAuthInfo(request); port_->AddRequestAuthInfo(message);
} }
port_->MaybeAddTurnLoggingId(request); port_->MaybeAddTurnLoggingId(message);
port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request); port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
} }
void TurnAllocateRequest::OnSent() { void TurnAllocateRequest::OnSent() {
@ -1554,17 +1554,17 @@ TurnRefreshRequest::TurnRefreshRequest(TurnPort* port)
port_(port), port_(port),
lifetime_(-1) {} lifetime_(-1) {}
void TurnRefreshRequest::Prepare(StunMessage* request) { void TurnRefreshRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC 5766, Section 7.1. // Create the request as indicated in RFC 5766, Section 7.1.
// No attributes need to be included. // No attributes need to be included.
request->SetType(TURN_REFRESH_REQUEST); message->SetType(TURN_REFRESH_REQUEST);
if (lifetime_ > -1) { if (lifetime_ > -1) {
request->AddAttribute( message->AddAttribute(
std::make_unique<StunUInt32Attribute>(STUN_ATTR_LIFETIME, lifetime_)); std::make_unique<StunUInt32Attribute>(STUN_ATTR_LIFETIME, lifetime_));
} }
port_->AddRequestAuthInfo(request); port_->AddRequestAuthInfo(message);
port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request); port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
} }
void TurnRefreshRequest::OnSent() { void TurnRefreshRequest::OnSent() {
@ -1642,18 +1642,18 @@ TurnCreatePermissionRequest::TurnCreatePermissionRequest(
this, &TurnCreatePermissionRequest::OnEntryDestroyed); this, &TurnCreatePermissionRequest::OnEntryDestroyed);
} }
void TurnCreatePermissionRequest::Prepare(StunMessage* request) { void TurnCreatePermissionRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC5766, Section 9.1. // Create the request as indicated in RFC5766, Section 9.1.
request->SetType(TURN_CREATE_PERMISSION_REQUEST); message->SetType(TURN_CREATE_PERMISSION_REQUEST);
request->AddAttribute(std::make_unique<StunXorAddressAttribute>( message->AddAttribute(std::make_unique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
if (port_->field_trials_ && if (port_->field_trials_ &&
port_->field_trials_->IsEnabled("WebRTC-TurnAddMultiMapping")) { 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_)); STUN_ATTR_MULTI_MAPPING, remote_ufrag_));
} }
port_->AddRequestAuthInfo(request); port_->AddRequestAuthInfo(message);
port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request); port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
} }
void TurnCreatePermissionRequest::OnSent() { void TurnCreatePermissionRequest::OnSent() {
@ -1715,15 +1715,15 @@ TurnChannelBindRequest::TurnChannelBindRequest(
&TurnChannelBindRequest::OnEntryDestroyed); &TurnChannelBindRequest::OnEntryDestroyed);
} }
void TurnChannelBindRequest::Prepare(StunMessage* request) { void TurnChannelBindRequest::Prepare(StunMessage* message) {
// Create the request as indicated in RFC5766, Section 11.1. // Create the request as indicated in RFC5766, Section 11.1.
request->SetType(TURN_CHANNEL_BIND_REQUEST); message->SetType(TURN_CHANNEL_BIND_REQUEST);
request->AddAttribute(std::make_unique<StunUInt32Attribute>( message->AddAttribute(std::make_unique<StunUInt32Attribute>(
STUN_ATTR_CHANNEL_NUMBER, channel_id_ << 16)); 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_)); STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
port_->AddRequestAuthInfo(request); port_->AddRequestAuthInfo(message);
port_->TurnCustomizerMaybeModifyOutgoingStunMessage(request); port_->TurnCustomizerMaybeModifyOutgoingStunMessage(message);
} }
void TurnChannelBindRequest::OnSent() { void TurnChannelBindRequest::OnSent() {