Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsNSSIOLayer.h File Reference
#include "prtypes.h"
#include "prio.h"
#include "certt.h"
#include "nsString.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsITransportSecurityInfo.h"
#include "nsISSLSocketControl.h"
#include "nsISSLStatus.h"
#include "nsISSLStatusProvider.h"
#include "nsXPIDLString.h"
#include "nsNSSShutDown.h"
#include "nsIClientAuthDialogs.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nsSSLSocketThreadData
class  nsNSSSocketInfo
class  nsSSLIOLayerHelpers

Functions

nsresult nsSSLIOLayerNewSocket (PRInt32 family, const char *host, PRInt32 port, const char *proxyHost, PRInt32 proxyPort, PRFileDesc **fd, nsISupports **securityInfo, PRBool forSTARTTLS)
nsresult nsSSLIOLayerAddToSocket (PRInt32 family, const char *host, PRInt32 port, const char *proxyHost, PRInt32 proxyPort, PRFileDesc *fd, nsISupports **securityInfo, PRBool forSTARTTLS)
nsresult nsSSLIOLayerFreeTLSIntolerantSites ()
nsresult displayUnknownCertErrorAlert (nsNSSSocketInfo *infoObject, int error)

Function Documentation

nsresult nsSSLIOLayerAddToSocket ( PRInt32  family,
const char *  host,
PRInt32  port,
const char *  proxyHost,
PRInt32  proxyPort,
PRFileDesc fd,
nsISupports **  securityInfo,
PRBool  forSTARTTLS 
)

Definition at line 2791 of file nsNSSIOLayer.cpp.

{
  nsNSSShutDownPreventionLock locker;
  PRFileDesc* layer = nsnull;
  nsresult rv;

  nsNSSSocketInfo* infoObject = new nsNSSSocketInfo();
  if (!infoObject) return NS_ERROR_FAILURE;
  
  NS_ADDREF(infoObject);
  infoObject->SetForSTARTTLS(forSTARTTLS);
  infoObject->SetHostName(host);
  infoObject->SetPort(port);

  PRFileDesc *sslSock = nsSSLIOLayerImportFD(fd, infoObject, host);
  if (!sslSock) {
    NS_ASSERTION(PR_FALSE, "NSS: Error importing socket");
    goto loser;
  }

  infoObject->SetFileDescPtr(sslSock);

  rv = nsSSLIOLayerSetOptions(sslSock, forSTARTTLS, proxyHost, host, port,
                              infoObject);

  if (NS_FAILED(rv))
    goto loser;

  /* Now, layer ourselves on top of the SSL socket... */
  layer = PR_CreateIOLayerStub(nsSSLIOLayerHelpers::nsSSLIOLayerIdentity,
                               &nsSSLIOLayerHelpers::nsSSLIOLayerMethods);
  if (!layer)
    goto loser;
  
  layer->secret = (PRFilePrivate*) infoObject;
  rv = PR_PushIOLayer(sslSock, PR_GetLayersIdentity(sslSock), layer);
  
  if (NS_FAILED(rv)) {
    goto loser;
  }
  
  nsNSSShutDownList::trackSSLSocketCreate();

  PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("[%p] Socket set up\n", (void*)sslSock));
  infoObject->QueryInterface(NS_GET_IID(nsISupports), (void**) (info));

  // We are going use a clear connection first //
  if (forSTARTTLS || proxyHost) {
    infoObject->SetHandshakePending(PR_FALSE);
  }

  return NS_OK;
 loser:
  NS_IF_RELEASE(infoObject);
  if (layer) {
    layer->dtor(layer);
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsSSLIOLayerNewSocket ( PRInt32  family,
const char *  host,
PRInt32  port,
const char *  proxyHost,
PRInt32  proxyPort,
PRFileDesc **  fd,
nsISupports **  securityInfo,
PRBool  forSTARTTLS 
)

Definition at line 1555 of file nsNSSIOLayer.cpp.

{

  PRFileDesc* sock = PR_OpenTCPSocket(family);
  if (!sock) return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv = nsSSLIOLayerAddToSocket(family, host, port, proxyHost, proxyPort,
                                        sock, info, forSTARTTLS);
  if (NS_FAILED(rv)) {
    PR_Close(sock);
    return rv;
  }

  *fd = sock;
  return NS_OK;
}

Here is the call graph for this function: