Mixes for Privacy and Anonymity in the Internet
|
Public Member Functions | |
CATLSClientSocket () | |
~CATLSClientSocket () | |
SINT32 | sendFully (const UINT8 *buff, UINT32 len) |
Sends all data over the network. More... | |
SINT32 | send (const UINT8 *buff, UINT32 len) |
Sends all data over the network. More... | |
SINT32 | receive (UINT8 *buff, UINT32 len) |
Will receive some bytes from the socket. More... | |
SINT32 | close () |
Shuts down the socket. More... | |
SINT32 | connect (const CASocketAddr &psa, UINT32 msTimeout) |
Establishes the actual TCP/IP connection and performs the TLS handshake. More... | |
SINT32 | setServerCertificate (CACertificate *pCert) |
Sets the Certifcate we accept as server identification. More... | |
Public Member Functions inherited from CASocket | |
CASocket (bool bIsReserved=false) | |
~CASocket () | |
virtual SINT32 | create () |
virtual SINT32 | create (bool a_bShowTypicalError) |
virtual SINT32 | create (SINT32 type) |
virtual SINT32 | listen (const CASocketAddr &psa) |
Starts listening on address psa. More... | |
virtual SINT32 | listen (UINT16 port) |
virtual SINT32 | accept (CASocket &s) |
Accepts a new connection. More... | |
virtual SINT32 | connect (const CASocketAddr &psa) |
virtual SINT32 | connect (const CASocketAddr &psa, UINT32 retry, UINT32 sWaitTime) |
Tries to connect to the peer described by psa. More... | |
virtual SINT32 | sendFullyTimeOut (const UINT8 *buff, UINT32 len, UINT32 msTimeOut, UINT32 msTimeOutSingleSend) |
Sends all data over the network. More... | |
virtual SINT32 | sendTimeOut (const UINT8 *buff, UINT32 len, UINT32 msTimeOut) |
Sends some data over the network. More... | |
virtual SINT32 | receiveFullyT (UINT8 *buff, UINT32 len, UINT32 msTimeOut) |
Trys to receive all bytes. More... | |
virtual SINT32 | receiveLine (UINT8 *line, UINT32 maxLen, UINT32 msTimeOut) |
virtual SINT32 | peek (UINT8 *buff, UINT32 len) |
Will peek some bytes from the socket read queue. More... | |
SOCKET | getSocket () |
Returns the number of the Socket used. More... | |
virtual SINT32 | getLocalIP (UINT8 r_Ip[4]) |
LERNGRUPPE Returns the source address of the socket. More... | |
virtual SINT32 | getLocalPort () |
virtual SINT32 | getPeerIP (UINT8 ip[4]) |
virtual SINT32 | getPeerPort () |
virtual SINT32 | setReuseAddr (bool b) |
virtual SINT32 | setSendTimeOut (UINT32 msTimeOut) |
virtual SINT32 | getSendTimeOut () |
virtual SINT32 | setRecvBuff (UINT32 r) |
virtual SINT32 | getRecvBuff () |
virtual SINT32 | setSendBuff (SINT32 r) |
Returns < 0 on error, otherwise the new sendbuffersize (which may be less than r) More... | |
virtual SINT32 | getSendBuff () |
virtual SINT32 | setKeepAlive (bool b) |
Enables/disables the socket keep-alive option. More... | |
virtual SINT32 | setKeepAlive (UINT32 sec) |
Enables the socket keep-alive option with a given ping time (in seconds). More... | |
virtual SINT32 | setNonBlocking (bool b) |
virtual SINT32 | getNonBlocking (bool *b) |
virtual bool | isClosed () |
Public Member Functions inherited from CAClientSocket | |
virtual | ~CAClientSocket () |
SINT32 | receiveFully (UINT8 *buff, UINT32 len) |
Receives all len bytes. More... | |
Private Member Functions | |
SINT32 | doTLSConnect (const CASocketAddr &psa) |
Does the TLS handshake. More... | |
Private Attributes | |
SSL * | m_pSSL |
SSL_CTX * | m_pCtx |
CACertificate * | m_pRootCert |
bool | m_bConnectedTLS |
is the TLS layer established ? More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from CASocket | |
static SINT32 | init () |
static SINT32 | cleanup () |
static SINT32 | setMaxNormalSockets (UINT32 u) |
Sets the max number of allowed "normal" sockets. More... | |
static SINT32 | getMaxOpenSockets () |
Tries to find out how many socket we can open by open as many socket as possible witthout errors. More... | |
static UINT32 | countOpenSockets () |
Protected Attributes inherited from CASocket | |
volatile bool | m_bSocketIsClosed |
check More... | |
SOCKET | m_Socket |
CASingleSocketGroup * | m_pSingleSocketGroupRead |
CATLSClientSocket::CATLSClientSocket | ( | ) |
References m_bConnectedTLS, m_pCtx, m_pRootCert, and m_pSSL.
CATLSClientSocket::~CATLSClientSocket | ( | ) |
References close(), m_pCtx, and m_pRootCert.
|
virtual |
Shuts down the socket.
This is an overridden virtual function which shuts down the TLS layer first
Reimplemented from CASocket.
References CASocket::close(), m_bConnectedTLS, and m_pSSL.
Referenced by doTLSConnect(), CAAccountingBIInterface::initBIConnection(), CAAccountingBIInterface::terminateBIConnection(), and ~CATLSClientSocket().
|
virtual |
Establishes the actual TCP/IP connection and performs the TLS handshake.
Establishes the TCP/IP connection, performs the TLS handshake and checks the server certificate validity.
Reimplemented from CASocket.
References CASocket::close(), CASocket::connect(), doTLSConnect(), and E_SUCCESS.
Referenced by CAAccountingBIInterface::initBIConnection().
|
private |
Does the TLS handshake.
The TCP Connection must be established first and openSSL library must be initialized
References close(), E_SUCCESS, E_UNKNOWN, CACertificate::getX509(), m_bConnectedTLS, m_pCtx, m_pRootCert, m_pSSL, CASocket::m_Socket, and CAMsg::printMsg().
Referenced by connect().
Will receive some bytes from the socket.
May block or not depending on whatever this socket was set to blocking or non-blocking mode. Warning: If socket is in blocking mode and receive is called, receive will block until some data is available, EVEN IF AN OTHER THREAD WILL CLOSE THIS SOCKET!
buff | the buffer which get the received data |
len | size of buff |
E_AGAIN,if | socket was in non-blocking mode and receive would block or a timeout was reached |
0 | if socket was gracefully closed |
Reimplemented from CASocket.
References E_AGAIN, len, m_pSSL, CAMsg::printMsg(), SOCKET_ERROR, and strerror().
Sends all data over the network.
This may block, until all data was sent.
buff | the buffer of data to send |
len | content length |
E_UNKNOWN | if an error occured |
E_SUCCESS | if successfull |
Reimplemented from CASocket.
References E_AGAIN, E_SUCCESS, len, m_pSSL, CAMsg::printMsg(), SOCKET_ERROR, and strerror().
SINT32 CATLSClientSocket::setServerCertificate | ( | CACertificate * | pCert | ) |
Sets the Certifcate we accept as server identification.
Init the SSL object.
Set to NULL if you do not want any certificate checking. @Note At the moment only a depth of verification path of zero or one is supported!
SSL_init_library() must be called before this!
References CACertificate::clone(), E_SUCCESS, and m_pRootCert.
Referenced by CAAccountingBIInterface::initBIConnection().
|
private |
is the TLS layer established ?
Referenced by CATLSClientSocket(), close(), and doTLSConnect().
|
private |
Referenced by CATLSClientSocket(), doTLSConnect(), and ~CATLSClientSocket().
|
private |
Referenced by CATLSClientSocket(), doTLSConnect(), setServerCertificate(), and ~CATLSClientSocket().
|
private |
Referenced by CATLSClientSocket(), close(), doTLSConnect(), receive(), send(), and sendFully().