tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsUDPSocketProvider.cpp (1553B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "nsUDPSocketProvider.h"
      6 
      7 #include "nspr.h"
      8 
      9 using mozilla::OriginAttributes;
     10 
     11 NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider)
     12 
     13 NS_IMETHODIMP
     14 nsUDPSocketProvider::NewSocket(int32_t aFamily, const char* aHost,
     15                               int32_t aPort, nsIProxyInfo* aProxy,
     16                               const OriginAttributes& originAttributes,
     17                               uint32_t aFlags, uint32_t aTlsFlags,
     18                               PRFileDesc** aFileDesc,
     19                               nsITLSSocketControl** aTLSSocketControl) {
     20  NS_ENSURE_ARG_POINTER(aFileDesc);
     21 
     22  PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily);
     23  if (!udpFD) return NS_ERROR_FAILURE;
     24 
     25  *aFileDesc = udpFD;
     26  return NS_OK;
     27 }
     28 
     29 NS_IMETHODIMP
     30 nsUDPSocketProvider::AddToSocket(int32_t aFamily, const char* aHost,
     31                                 int32_t aPort, nsIProxyInfo* aProxy,
     32                                 const OriginAttributes& originAttributes,
     33                                 uint32_t aFlags, uint32_t aTlsFlags,
     34                                 struct PRFileDesc* aFileDesc,
     35                                 nsITLSSocketControl** aTLSSocketControl) {
     36  // does not make sense to strap a UDP socket onto an existing socket
     37  MOZ_ASSERT_UNREACHABLE("Cannot layer UDP socket on an existing socket");
     38  return NS_ERROR_UNEXPECTED;
     39 }