diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /netwerk/sctp | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/sctp')
-rw-r--r-- | netwerk/sctp/datachannel/DataChannel.cpp | 156 | ||||
-rw-r--r-- | netwerk/sctp/datachannel/DataChannel.h | 35 |
2 files changed, 4 insertions, 187 deletions
diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index 8af9a558b8..81f54e775d 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -268,7 +268,6 @@ class DataChannelRegistry { DeinitUsrSctp(); } -#ifdef SCTP_DTLS_SUPPORTED static int SctpDtlsOutput(void* addr, void* buffer, size_t length, uint8_t tos, uint8_t set_df) { uintptr_t id = reinterpret_cast<uintptr_t>(addr); @@ -278,7 +277,6 @@ class DataChannelRegistry { } return connection->SctpDtlsOutput(addr, buffer, length, tos, set_df); } -#endif void InitUsrSctp() { #ifndef MOZ_PEERCONNECTION @@ -1083,160 +1081,6 @@ int DataChannelConnection::SctpDtlsOutput(void* addr, void* buffer, } #endif -#ifdef ALLOW_DIRECT_SCTP_LISTEN_CONNECT -// listen for incoming associations -// Blocks! - Don't call this from main thread! - -bool DataChannelConnection::Listen(unsigned short port) { - struct sockaddr_in addr = {}; - socklen_t addr_len; - - NS_WARNING_ASSERTION(!NS_IsMainThread(), - "Blocks, do not call from main thread!!!"); - - /* Acting as the 'server' */ -# ifdef HAVE_SIN_LEN - addr.sin_len = sizeof(struct sockaddr_in); -# endif - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr = htonl(INADDR_ANY); - DC_DEBUG(("Waiting for connections on port %u", ntohs(addr.sin_port))); - { - MutexAutoLock lock(mLock); - SetState(DataChannelConnectionState::Connecting); - } - if (usrsctp_bind(mMasterSocket, reinterpret_cast<struct sockaddr*>(&addr), - sizeof(struct sockaddr_in)) < 0) { - DC_ERROR(("***Failed userspace_bind")); - return false; - } - if (usrsctp_listen(mMasterSocket, 1) < 0) { - DC_ERROR(("***Failed userspace_listen")); - return false; - } - - DC_DEBUG(("Accepting connection")); - addr_len = 0; - if ((mSocket = usrsctp_accept(mMasterSocket, nullptr, &addr_len)) == - nullptr) { - DC_ERROR(("***Failed accept")); - return false; - } - - { - MutexAutoLock lock(mLock); - SetState(DataChannelConnectionState::Open); - } - - struct linger l; - l.l_onoff = 1; - l.l_linger = 0; - if (usrsctp_setsockopt(mSocket, SOL_SOCKET, SO_LINGER, (const void*)&l, - (socklen_t)sizeof(struct linger)) < 0) { - DC_WARN(("Couldn't set SO_LINGER on SCTP socket")); - } - - // Notify Connection open - // XXX We need to make sure connection sticks around until the message is - // delivered - DC_DEBUG(("%s: sending ON_CONNECTION for %p", __FUNCTION__, this)); - Dispatch(do_AddRef(new DataChannelOnMessageAvailable( - DataChannelOnMessageAvailable::EventType::OnConnection, this, - (DataChannel*)nullptr))); - return true; -} - -// Blocks! - Don't call this from main thread! -bool DataChannelConnection::Connect(const char* addr, unsigned short port) { - struct sockaddr_in addr4 = {}; - struct sockaddr_in6 addr6 = {}; - - NS_WARNING_ASSERTION(!NS_IsMainThread(), - "Blocks, do not call from main thread!!!"); - - /* Acting as the connector */ - DC_DEBUG(("Connecting to %s, port %u", addr, port)); -# ifdef HAVE_SIN_LEN - addr4.sin_len = sizeof(struct sockaddr_in); -# endif -# ifdef HAVE_SIN6_LEN - addr6.sin6_len = sizeof(struct sockaddr_in6); -# endif - addr4.sin_family = AF_INET; - addr6.sin6_family = AF_INET6; - addr4.sin_port = htons(port); - addr6.sin6_port = htons(port); - { - MutexAutoLock lock(mLock); - SetState(DataChannelConnectionState::Connecting); - } -# if !defined(__Userspace_os_Windows) - if (inet_pton(AF_INET6, addr, &addr6.sin6_addr) == 1) { - if (usrsctp_connect(mMasterSocket, - reinterpret_cast<struct sockaddr*>(&addr6), - sizeof(struct sockaddr_in6)) < 0) { - DC_ERROR(("*** Failed userspace_connect")); - return false; - } - } else if (inet_pton(AF_INET, addr, &addr4.sin_addr) == 1) { - if (usrsctp_connect(mMasterSocket, - reinterpret_cast<struct sockaddr*>(&addr4), - sizeof(struct sockaddr_in)) < 0) { - DC_ERROR(("*** Failed userspace_connect")); - return false; - } - } else { - DC_ERROR(("*** Illegal destination address.")); - } -# else - { - struct sockaddr_storage ss; - int sslen = sizeof(ss); - - if (!WSAStringToAddressA(const_cast<char*>(addr), AF_INET6, nullptr, - (struct sockaddr*)&ss, &sslen)) { - addr6.sin6_addr = - (reinterpret_cast<struct sockaddr_in6*>(&ss))->sin6_addr; - if (usrsctp_connect(mMasterSocket, - reinterpret_cast<struct sockaddr*>(&addr6), - sizeof(struct sockaddr_in6)) < 0) { - DC_ERROR(("*** Failed userspace_connect")); - return false; - } - } else if (!WSAStringToAddressA(const_cast<char*>(addr), AF_INET, nullptr, - (struct sockaddr*)&ss, &sslen)) { - addr4.sin_addr = (reinterpret_cast<struct sockaddr_in*>(&ss))->sin_addr; - if (usrsctp_connect(mMasterSocket, - reinterpret_cast<struct sockaddr*>(&addr4), - sizeof(struct sockaddr_in)) < 0) { - DC_ERROR(("*** Failed userspace_connect")); - return false; - } - } else { - DC_ERROR(("*** Illegal destination address.")); - } - } -# endif - - mSocket = mMasterSocket; - - DC_DEBUG(("connect() succeeded! Entering connected mode")); - { - MutexAutoLock lock(mLock); - SetState(DataChannelConnectionState::Open); - } - // Notify Connection open - // XXX We need to make sure connection sticks around until the message is - // delivered - DC_DEBUG(("%s: sending ON_CONNECTION for %p", __FUNCTION__, this)); - Dispatch(do_AddRef(new DataChannelOnMessageAvailable( - DataChannelOnMessageAvailable::EventType::OnConnection, this, - (DataChannel*)nullptr))); - return true; -} -#endif - DataChannel* DataChannelConnection::FindChannelByStream(uint16_t stream) { return mChannels.Get(stream).get(); } diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h index 76fb6aeced..f3586f48a2 100644 --- a/netwerk/sctp/datachannel/DataChannel.h +++ b/netwerk/sctp/datachannel/DataChannel.h @@ -7,10 +7,6 @@ #ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNEL_H_ #define NETWERK_SCTP_DATACHANNEL_DATACHANNEL_H_ -#ifdef MOZ_WEBRTC_SIGNALING -# define SCTP_DTLS_SUPPORTED 1 -#endif - #include <memory> #include <string> #include <vector> @@ -30,10 +26,8 @@ #include "mozilla/net/NeckoTargetHolder.h" #include "DataChannelLog.h" -#ifdef SCTP_DTLS_SUPPORTED -# include "transport/sigslot.h" -# include "transport/transportlayer.h" // For TransportLayer::State -#endif +#include "transport/sigslot.h" +#include "transport/transportlayer.h" // For TransportLayer::State #ifndef EALREADY # define EALREADY WSAEALREADY @@ -120,12 +114,8 @@ class QueuedDataMessage { }; // One per PeerConnection -class DataChannelConnection final : public net::NeckoTargetHolder -#ifdef SCTP_DTLS_SUPPORTED - , - public sigslot::has_slots<> -#endif -{ +class DataChannelConnection final : public net::NeckoTargetHolder, + public sigslot::has_slots<> { friend class DataChannel; friend class DataChannelOnMessageAvailable; friend class DataChannelConnectRunnable; @@ -182,15 +172,7 @@ class DataChannelConnection final : public net::NeckoTargetHolder void AppendStatsToReport(const UniquePtr<dom::RTCStatsCollection>& aReport, const DOMHighResTimeStamp aTimestamp) const; -#ifdef ALLOW_DIRECT_SCTP_LISTEN_CONNECT - // These block; they require something to decide on listener/connector - // (though you can do simultaneous Connect()). Do not call these from - // the main thread! - bool Listen(unsigned short port); - bool Connect(const char* addr, unsigned short port); -#endif -#ifdef SCTP_DTLS_SUPPORTED bool ConnectToTransport(const std::string& aTransportId, const bool aClient, const uint16_t aLocalPort, const uint16_t aRemotePort); @@ -198,7 +180,6 @@ class DataChannelConnection final : public net::NeckoTargetHolder TransportLayer::State aState); void CompleteConnect(); void SetSignals(const std::string& aTransportId); -#endif [[nodiscard]] already_AddRefed<DataChannel> Open( const nsACString& label, const nsACString& protocol, @@ -235,10 +216,8 @@ class DataChannelConnection final : public net::NeckoTargetHolder bool SendDeferredMessages() MOZ_REQUIRES(mLock); -#ifdef SCTP_DTLS_SUPPORTED int SctpDtlsOutput(void* addr, void* buffer, size_t length, uint8_t tos, uint8_t set_df); -#endif bool InShutdown() const { #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED @@ -296,12 +275,10 @@ class DataChannelConnection final : public net::NeckoTargetHolder static int OnThresholdEvent(struct socket* sock, uint32_t sb_free, void* ulp_info); -#ifdef SCTP_DTLS_SUPPORTED static void DTLSConnectThread(void* data); void SendPacket(std::unique_ptr<MediaPacket>&& packet); void SctpDtlsInput(const std::string& aTransportId, const MediaPacket& packet); -#endif DataChannel* FindChannelByStream(uint16_t stream) MOZ_REQUIRES(mLock); uint16_t FindFreeStream() const MOZ_REQUIRES(mLock); bool RequestMoreStreams(int32_t aNeeded = 16) MOZ_REQUIRES(mLock); @@ -373,7 +350,6 @@ class DataChannelConnection final : public net::NeckoTargetHolder void HandleNotification(const union sctp_notification* notif, size_t n) MOZ_REQUIRES(mLock); -#ifdef SCTP_DTLS_SUPPORTED bool IsSTSThread() const { bool on = false; if (mSTS) { @@ -381,7 +357,6 @@ class DataChannelConnection final : public net::NeckoTargetHolder } return on; } -#endif mutable Mutex mLock; // Avoid cycles with PeerConnectionImpl @@ -420,12 +395,10 @@ class DataChannelConnection final : public net::NeckoTargetHolder DataChannelConnectionState mState MOZ_GUARDED_BY(mLock) = DataChannelConnectionState::Closed; -#ifdef SCTP_DTLS_SUPPORTED std::string mTransportId; bool mConnectedToTransportHandler = false; RefPtr<MediaTransportHandler> mTransportHandler; nsCOMPtr<nsIEventTarget> mSTS; -#endif uint16_t mLocalPort = 0; // Accessed from connect thread uint16_t mRemotePort = 0; |