2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2007-05-31 10:07:26 +04:00
|
|
|
|
|
|
|
#include "nsUDPSocketProvider.h"
|
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
|
2017-01-12 19:38:48 +03:00
|
|
|
using mozilla::OriginAttributes;
|
2016-11-21 06:43:06 +03:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider)
|
2007-05-31 10:07:26 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsUDPSocketProvider::NewSocket(int32_t aFamily, const char* aHost,
|
2015-11-25 00:56:00 +03:00
|
|
|
int32_t aPort, nsIProxyInfo* aProxy,
|
2017-01-12 19:38:48 +03:00
|
|
|
const OriginAttributes& originAttributes,
|
2017-08-16 22:41:16 +03:00
|
|
|
uint32_t aFlags, uint32_t aTlsFlags,
|
2007-05-31 10:07:26 +04:00
|
|
|
PRFileDesc** aFileDesc,
|
|
|
|
nsISupports** aSecurityInfo) {
|
|
|
|
NS_ENSURE_ARG_POINTER(aFileDesc);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-05-31 10:07:26 +04:00
|
|
|
PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily);
|
|
|
|
if (!udpFD) return NS_ERROR_FAILURE;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-05-31 10:07:26 +04:00
|
|
|
*aFileDesc = udpFD;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsUDPSocketProvider::AddToSocket(int32_t aFamily, const char* aHost,
|
2015-11-25 00:56:00 +03:00
|
|
|
int32_t aPort, nsIProxyInfo* aProxy,
|
2017-01-12 19:38:48 +03:00
|
|
|
const OriginAttributes& originAttributes,
|
2017-08-16 22:41:16 +03:00
|
|
|
uint32_t aFlags, uint32_t aTlsFlags,
|
2007-05-31 10:07:26 +04:00
|
|
|
struct PRFileDesc* aFileDesc,
|
|
|
|
nsISupports** aSecurityInfo) {
|
|
|
|
// does not make sense to strap a UDP socket onto an existing socket
|
2018-06-18 08:43:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Cannot layer UDP socket on an existing socket");
|
2007-05-31 10:07:26 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|