netwerk/socket/nsUDPSocketProvider.cpp
author Kartikaya Gupta <kgupta@mozilla.com>
Wed, 11 Sep 2013 18:17:20 -0400
changeset 146653 ce483735e803a650b37b8a334271b304bca93c1d
parent 139615 14bd6018f287849d5a43f0238cb01e9b1a81e29e
child 180485 6c1c7e45c90289a0875b74f82f39e7ecf6a65af3
permissions -rw-r--r--
Bug 912806 - Special-case the resolution behaviour on Fennec to work around other bugs. r=tn

/* 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"

NS_IMPL_ISUPPORTS1(nsUDPSocketProvider, nsISocketProvider)

nsUDPSocketProvider::~nsUDPSocketProvider()
{
}

NS_IMETHODIMP 
nsUDPSocketProvider::NewSocket(int32_t aFamily,
                               const char *aHost, 
                               int32_t aPort, 
                               const char *aProxyHost, 
                               int32_t aProxyPort,
                               uint32_t aFlags,
                               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,
                                 const char *aProxyHost,
                                 int32_t aProxyPort,
                                 uint32_t aFlags,
                                 struct PRFileDesc * aFileDesc,
                                 nsISupports **aSecurityInfo)
{
    // does not make sense to strap a UDP socket onto an existing socket
    NS_NOTREACHED("Cannot layer UDP socket on an existing socket");
    return NS_ERROR_UNEXPECTED;
}