1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* The contents of this file are subject to the Mozilla Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is mozilla.org code.
15
* The Initial Developer of the Original Code is Netscape
16
* Communications Corporation. Portions created by Netscape are
17
* Copyright (C) 1998 Netscape Communications Corporation. All
21
* Justin Bradford <jab@atdot.org>
22
* Darin Fisher <darin@meer.net>
25
#include "nsIServiceManager.h"
26
#include "nsSOCKSSocketProvider.h"
27
#include "nsSOCKSIOLayer.h"
29
#include "nsNetError.h"
31
//////////////////////////////////////////////////////////////////////////
33
NS_IMPL_THREADSAFE_ISUPPORTS1(nsSOCKSSocketProvider, nsISocketProvider)
36
nsSOCKSSocketProvider::CreateV4(nsISupports *aOuter, REFNSIID aIID, void **aResult)
39
nsCOMPtr<nsISocketProvider> inst =
40
new nsSOCKSSocketProvider(NS_SOCKS_VERSION_4);
42
rv = NS_ERROR_OUT_OF_MEMORY;
44
rv = inst->QueryInterface(aIID, aResult);
49
nsSOCKSSocketProvider::CreateV5(nsISupports *aOuter, REFNSIID aIID, void **aResult)
52
nsCOMPtr<nsISocketProvider> inst =
53
new nsSOCKSSocketProvider(NS_SOCKS_VERSION_5);
55
rv = NS_ERROR_OUT_OF_MEMORY;
57
rv = inst->QueryInterface(aIID, aResult);
62
nsSOCKSSocketProvider::NewSocket(PRInt32 family,
65
const char *proxyHost,
68
nsISupports **socksInfo)
72
sock = PR_OpenTCPSocket(family);
74
return NS_ERROR_OUT_OF_MEMORY;
76
nsresult rv = nsSOCKSIOLayerAddToSocket(family,
84
if (NS_SUCCEEDED(rv)) {
89
return NS_ERROR_SOCKET_CREATE_FAILED;
93
nsSOCKSSocketProvider::AddToSocket(PRInt32 family,
96
const char *proxyHost,
99
nsISupports **socksInfo)
101
nsresult rv = nsSOCKSIOLayerAddToSocket(family,
111
rv = NS_ERROR_SOCKET_CREATE_FAILED;