netwerk/socket/nsUDPSocketProvider.cpp
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Tue, 28 Jun 2022 19:14:40 +0000
changeset 622284 8e99b54b620b9100f2c9f113b2ed46271e41d3bc
parent 472056 e1993a1f09ac53cd1a04fdf6a87f8cad8e44f73e
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD be -> eb2b08c1435a3577605ac3c821b2450968a6f6cb he -> 5660274011fe5e85fdc42b47b503cdfdb9598478 ia -> ae0f01fb5b7982c1b84cd00b2da21f6bfd9583f8 it -> 337e2d7d008e01f3d233527a7a76b8955dd1602f nn-NO -> aee623f3aa8c88e409851d1ecb42bd1b1e24b986 oc -> 80114c189f5a11fe8ef641ec3b965659618d4a04 ru -> 22416553f0282f7055d5a11cd12e5ce39e66c88d tg -> 6db775921d2d2d4649b7de4241d548ebfb2a4771 tl -> d1bf362357e8fa87f9a426f948dcb5409e3b797a vi -> 9c203d3ebb39f7c339fd3d61690f748416cc7404 zh-CN -> feaf1e52f2b36b210c29f55d53faebf373bdd2f0 zh-TW -> fd1e717e8be4e824abcafb8f266047810c44e4a5

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsUDPSocketProvider.h"

#include "nspr.h"

using mozilla::OriginAttributes;

NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider)

NS_IMETHODIMP
nsUDPSocketProvider::NewSocket(int32_t aFamily, const char* aHost,
                               int32_t aPort, nsIProxyInfo* aProxy,
                               const OriginAttributes& originAttributes,
                               uint32_t aFlags, uint32_t aTlsFlags,
                               PRFileDesc** aFileDesc,
                               nsISupports** aSecurityInfo) {
  NS_ENSURE_ARG_POINTER(aFileDesc);

  PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily);
  if (!udpFD) return NS_ERROR_FAILURE;

  *aFileDesc = udpFD;
  return NS_OK;
}

NS_IMETHODIMP
nsUDPSocketProvider::AddToSocket(int32_t aFamily, const char* aHost,
                                 int32_t aPort, nsIProxyInfo* aProxy,
                                 const OriginAttributes& originAttributes,
                                 uint32_t aFlags, uint32_t aTlsFlags,
                                 struct PRFileDesc* aFileDesc,
                                 nsISupports** aSecurityInfo) {
  // does not make sense to strap a UDP socket onto an existing socket
  MOZ_ASSERT_UNREACHABLE("Cannot layer UDP socket on an existing socket");
  return NS_ERROR_UNEXPECTED;
}