[StunMessage] Remove/deprecate StunMessage::SetType

Removes all remaining usage of SetType and marks the method as
deprecated.

Bug: none
Change-Id: I98dc613978ffe7ad8a4ffd951dd974d56ed92983
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265100
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37137}
This commit is contained in:
Tommi 2022-06-04 09:50:22 +02:00 committed by WebRTC LUCI CQ
parent 45d66a59d6
commit b5af6ee6df
5 changed files with 8 additions and 14 deletions

View File

@ -178,7 +178,7 @@ class StunMessage {
// is determined by the lengths of the transaction ID.
bool IsLegacy() const;
void SetType(int type) { type_ = static_cast<uint16_t>(type); }
[[deprecated]] void SetType(int type) { type_ = static_cast<uint16_t>(type); }
[[deprecated]] bool SetTransactionID(absl::string_view transaction_id) {
if (!IsValidTransactionId(transaction_id))
return false;

View File

@ -3747,8 +3747,7 @@ TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) {
// Simulate a binding request being received, creating a peer reflexive
// candidate pair while we still don't have remote ICE parameters.
IceMessage request;
request.SetType(STUN_BINDING_REQUEST);
IceMessage request(STUN_BINDING_REQUEST);
request.AddAttribute(std::make_unique<StunByteStringAttribute>(
STUN_ATTR_USERNAME, kIceUfrag[1]));
uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24;
@ -3916,8 +3915,7 @@ TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) {
kMediumTimeout);
// Create a minimal STUN message with prflx priority.
IceMessage request;
request.SetType(STUN_BINDING_REQUEST);
IceMessage request(STUN_BINDING_REQUEST);
request.AddAttribute(std::make_unique<StunByteStringAttribute>(
STUN_ATTR_USERNAME, kIceUfrag[1]));
uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24;
@ -4172,8 +4170,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
ch.SetIceRole(ICEROLE_CONTROLLED);
ch.MaybeStartGathering();
// A minimal STUN message with prflx priority.
IceMessage request;
request.SetType(STUN_BINDING_REQUEST);
IceMessage request(STUN_BINDING_REQUEST);
request.AddAttribute(std::make_unique<StunByteStringAttribute>(
STUN_ATTR_USERNAME, kIceUfrag[1]));
uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24;
@ -4268,8 +4265,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
// Now another STUN message with an unknown address and use_candidate will
// nominate the selected connection.
IceMessage request;
request.SetType(STUN_BINDING_REQUEST);
IceMessage request(STUN_BINDING_REQUEST);
request.AddAttribute(std::make_unique<StunByteStringAttribute>(
STUN_ATTR_USERNAME, kIceUfrag[1]));
uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24;

View File

@ -3409,8 +3409,7 @@ TEST_F(PortTest, TestErrorResponseMakesGoogPingFallBackToStunBinding) {
ASSERT_EQ(response2->type(), GOOG_PING_RESPONSE);
// But rather than the RESPONSE...feedback an error.
StunMessage error_response;
error_response.SetType(GOOG_PING_ERROR_RESPONSE);
StunMessage error_response(GOOG_PING_ERROR_RESPONSE);
error_response.SetTransactionIdForTesting(response2->transaction_id());
error_response.AddMessageIntegrity32("rpass");
rtc::ByteBufferWriter buf;

View File

@ -1649,7 +1649,7 @@ TurnCreatePermissionRequest::TurnCreatePermissionRequest(
this, &TurnCreatePermissionRequest::OnEntryDestroyed);
StunMessage* message = mutable_msg();
// Create the request as indicated in RFC5766, Section 9.1.
message->SetType(TURN_CREATE_PERMISSION_REQUEST);
RTC_DCHECK_EQ(message->type(), TURN_CREATE_PERMISSION_REQUEST);
message->AddAttribute(std::make_unique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
if (port_->field_trials_ &&

View File

@ -651,8 +651,7 @@ TEST(NetworkEmulationManagerTURNTest, ClientTraffic) {
int port = ep->BindReceiver(0, &recv).value();
// Construct a STUN BINDING.
cricket::StunMessage ping;
ping.SetType(cricket::STUN_BINDING_REQUEST);
cricket::StunMessage ping(cricket::STUN_BINDING_REQUEST);
rtc::ByteBufferWriter buf;
ping.Write(&buf);
rtc::CopyOnWriteBuffer packet(buf.Data(), buf.Length());