Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsSOCKSIOLayer.h File Reference
#include "prtypes.h"
#include "prio.h"
#include "nscore.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define NSSOCKSIOLayer_h__


nsresult nsSOCKSIOLayerAddToSocket (PRInt32 family, const char *host, PRInt32 port, const char *proxyHost, PRInt32 proxyPort, PRInt32 socksVersion, PRUint32 flags, PRFileDesc *fd, nsISupports **info)

Define Documentation

Definition at line 42 of file nsSOCKSIOLayer.h.

Function Documentation

nsresult nsSOCKSIOLayerAddToSocket ( PRInt32  family,
const char *  host,
PRInt32  port,
const char *  proxyHost,
PRInt32  proxyPort,
PRInt32  socksVersion,
PRUint32  flags,
PRFileDesc fd,
nsISupports **  info 

Definition at line 805 of file nsSOCKSIOLayer.cpp.

    NS_ENSURE_TRUE((socksVersion == 4) || (socksVersion == 5), NS_ERROR_NOT_INITIALIZED);

    if (firstTime)
        nsSOCKSIOLayerIdentity            = PR_GetUniqueIdentity("SOCKS layer");
        nsSOCKSIOLayerMethods             = *PR_GetDefaultIOMethods();

        nsSOCKSIOLayerMethods.connect     = nsSOCKSIOLayerConnect;
        nsSOCKSIOLayerMethods.bind = nsSOCKSIOLayerBind;
        nsSOCKSIOLayerMethods.acceptread = nsSOCKSIOLayerAcceptRead;
        nsSOCKSIOLayerMethods.getsockname = nsSOCKSIOLayerGetName;
        nsSOCKSIOLayerMethods.getpeername = nsSOCKSIOLayerGetPeerName;
        nsSOCKSIOLayerMethods.accept      = nsSOCKSIOLayerAccept;
        nsSOCKSIOLayerMethods.listen      = nsSOCKSIOLayerListen;
        nsSOCKSIOLayerMethods.close       = nsSOCKSIOLayerClose;

        firstTime                  = PR_FALSE;

#if defined(PR_LOGGING)
        gSOCKSLog = PR_NewLogModule("SOCKS");


    LOGDEBUG(("Entering nsSOCKSIOLayerAddToSocket()."));

    PRFileDesc *     layer;
    PRStatus  rv;

    layer = PR_CreateIOLayerStub(nsSOCKSIOLayerIdentity, &nsSOCKSIOLayerMethods);
    if (! layer)
        LOGERROR(("PR_CreateIOLayerStub() failed."));
        return NS_ERROR_FAILURE;

    nsSOCKSSocketInfo * infoObject = new nsSOCKSSocketInfo();
    if (!infoObject)
        // clean up IOLayerStub
        LOGERROR(("Failed to create nsSOCKSSocketInfo()."));
        return NS_ERROR_FAILURE;

    infoObject->Init(socksVersion, proxyHost, proxyPort, host, flags);
    layer->secret = (PRFilePrivate*) infoObject;
    rv = PR_PushIOLayer(fd, PR_GetLayersIdentity(fd), layer);

    if (NS_FAILED(rv))
        LOGERROR(("PR_PushIOLayer() failed. rv = %x.", rv));
        return NS_ERROR_FAILURE;

    *info = infoObject;
    return NS_OK;

Here is the call graph for this function: