diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/p2p/base/stun_server.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/p2p/base/stun_server.cc')
-rw-r--r-- | third_party/libwebrtc/p2p/base/stun_server.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/third_party/libwebrtc/p2p/base/stun_server.cc b/third_party/libwebrtc/p2p/base/stun_server.cc index 7827a0bb81..e37c5baf26 100644 --- a/third_party/libwebrtc/p2p/base/stun_server.cc +++ b/third_party/libwebrtc/p2p/base/stun_server.cc @@ -14,42 +14,49 @@ #include <utility> #include "absl/strings/string_view.h" +#include "api/sequence_checker.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/logging.h" +#include "rtc_base/network/received_packet.h" namespace cricket { StunServer::StunServer(rtc::AsyncUDPSocket* socket) : socket_(socket) { - socket_->SignalReadPacket.connect(this, &StunServer::OnPacket); + socket_->RegisterReceivedPacketCallback( + [&](rtc::AsyncPacketSocket* socket, const rtc::ReceivedPacket& packet) { + OnPacket(socket, packet); + }); } StunServer::~StunServer() { - socket_->SignalReadPacket.disconnect(this); + RTC_DCHECK_RUN_ON(&sequence_checker_); + socket_->DeregisterReceivedPacketCallback(); } void StunServer::OnPacket(rtc::AsyncPacketSocket* socket, - const char* buf, - size_t size, - const rtc::SocketAddress& remote_addr, - const int64_t& /* packet_time_us */) { + const rtc::ReceivedPacket& packet) { + RTC_DCHECK_RUN_ON(&sequence_checker_); // Parse the STUN message; eat any messages that fail to parse. - rtc::ByteBufferReader bbuf(buf, size); + rtc::ByteBufferReader bbuf(packet.payload()); StunMessage msg; if (!msg.Read(&bbuf)) { return; } - // TODO(?): If unknown non-optional (<= 0x7fff) attributes are found, send a + // TODO(?): If unknown non-optional (<= 0x7fff) attributes are found, + // send a // 420 "Unknown Attribute" response. // Send the message to the appropriate handler function. switch (msg.type()) { case STUN_BINDING_REQUEST: - OnBindingRequest(&msg, remote_addr); + OnBindingRequest(&msg, packet.source_address()); break; default: - SendErrorResponse(msg, remote_addr, 600, "Operation Not Supported"); + SendErrorResponse(msg, packet.source_address(), 600, + "Operation Not Supported"); } } |