Mixe for Privacy and Anonymity in the Internet
|
#include <CAMuxSocket.hpp>
Public Member Functions | |
CAMuxSocket (SYMCHANNELCIPHER_ALGORITHM algCipher) | |
~CAMuxSocket () | |
SINT32 | getHashKey () |
Returns a Hashkey which uniquely identifies this socket. More... | |
SINT32 | accept (UINT16 port) |
SINT32 | accept (const CASocketAddr &oAddr) |
Waits for an incoming connection on oAddr. More... | |
SINT32 | connect (CASocketAddr &psa) |
SINT32 | connect (CASocketAddr &psa, UINT retry, UINT32 time) |
SINT32 | close () |
Closes the underlying socket. More... | |
SINT32 | send (MIXPACKET *pPacket) |
Sends a MixPacket over the Network. More... | |
SINT32 | send (MIXPACKET *pPacket, UINT8 *buff) |
SINT32 | prepareForSend (MIXPACKET *inoutPacket) |
SINT32 | receive (MIXPACKET *pPacket) |
Receives a whole MixPacket. More... | |
SINT32 | receive (MIXPACKET *pPacket, UINT32 timeout) |
Trys to receive a Mix-Packet. More... | |
SINT32 | receiveFully (UINT8 *buff, UINT32 len) |
Receives some "plain" bytes from the underlying socket - just a convenient function... More... | |
SINT32 | receiveFully (UINT8 *buff, UINT32 len, UINT32 msTimeOut) |
CASocket * | getCASocket () |
SINT32 | setCASocket (CASocket *pSocket) |
This will set the underlying CASocket. More... | |
SOCKET | getSocket () |
SINT32 | setCrypt (bool b) |
bool | getIsEncrypted () |
SINT32 | setCipher (SYMCHANNELCIPHER_ALGORITHM algCipher) |
SINT32 | setKey (UINT8 *key, UINT32 keyLen) |
Sets the symmetric keys used for de-/encrypting the Mux connection. More... | |
SINT32 | setSendKey (UINT8 *key, UINT32 keyLen) |
SINT32 | setReceiveKey (UINT8 *key, UINT32 keyLen) |
Static Public Member Functions | |
static SINT32 | init () |
static SINT32 | cleanup () |
Private Attributes | |
CASocket * | m_pSocket |
UINT32 | m_aktBuffPos |
UINT8 * | m_Buff |
CASymCipherMuxSocket * | m_pCipherIn |
CASymCipherMuxSocket * | m_pCipherOut |
bool | m_bIsCrypted |
CAMutex | m_csSend |
CAMutex | m_csReceive |
t_hashkeylistEntry * | m_pHashKeyEntry |
Static Private Attributes | |
static t_hashkeylistEntry * | ms_phashkeylistAvailableHashKeys =NULL |
static SINT32 | ms_nMaxHashKeyValue =0 |
static CAMutex * | ms_pcsHashKeyList =NULL |
Definition at line 45 of file CAMuxSocket.hpp.
CAMuxSocket::CAMuxSocket | ( | SYMCHANNELCIPHER_ALGORITHM | algCipher | ) |
Definition at line 42 of file CAMuxSocket.cpp.
References __t_hash_key_entry__::hashkey, CAMutex::lock(), m_aktBuffPos, m_bIsCrypted, m_Buff, m_pCipherIn, m_pCipherOut, m_pHashKeyEntry, m_pSocket, MIXPACKET_SIZE, ms_nMaxHashKeyValue, ms_pcsHashKeyList, ms_phashkeylistAvailableHashKeys, __t_hash_key_entry__::next, setCipher(), and CAMutex::unlock().
CAMuxSocket::~CAMuxSocket | ( | ) |
Definition at line 67 of file CAMuxSocket.cpp.
References close(), CAMutex::lock(), m_Buff, m_pCipherIn, m_pCipherOut, m_pHashKeyEntry, m_pSocket, ms_pcsHashKeyList, ms_phashkeylistAvailableHashKeys, __t_hash_key_entry__::next, and CAMutex::unlock().
SINT32 CAMuxSocket::accept | ( | const CASocketAddr & | oAddr | ) |
Waits for an incoming connection on oAddr.
E_SUCCESS,if | successful |
E_SOCKET_BIND,E_SOCKET_LISTEN | |
E_UNKOWN |
Definition at line 146 of file CAMuxSocket.cpp.
References CASocket::accept(), CASocket::close(), CASocket::create(), E_SUCCESS, E_UNKNOWN, CASocketAddr::getType(), CASocket::listen(), m_aktBuffPos, m_pSocket, and CASocket::setReuseAddr().
Definition at line 126 of file CAMuxSocket.cpp.
References CASocket::accept(), CASocket::close(), CASocket::create(), E_SUCCESS, E_UNKNOWN, CASocket::listen(), m_aktBuffPos, m_pSocket, and CASocket::setReuseAddr().
Referenced by CALastMix::init(), and CAMiddleMix::init().
|
inlinestatic |
Definition at line 172 of file CAMuxSocket.hpp.
References E_SUCCESS, ms_pcsHashKeyList, ms_phashkeylistAvailableHashKeys, and __t_hash_key_entry__::next.
Referenced by CALibProxytest::cleanup().
SINT32 CAMuxSocket::close | ( | ) |
Closes the underlying socket.
Definition at line 175 of file CAMuxSocket.cpp.
References CASocket::close(), m_aktBuffPos, and m_pSocket.
Referenced by CAFirstMix::clean(), CALastMix::clean(), CALocalProxy::clean(), CAMiddleMix::clean(), CAMiddleMix::loop(), CAFirstMixB::loop(), CALastMixB::loop(), and ~CAMuxSocket().
SINT32 CAMuxSocket::connect | ( | CASocketAddr & | psa | ) |
Definition at line 163 of file CAMuxSocket.cpp.
Referenced by CAFirstMix::connectToNextMix(), CAMiddleMix::connectToNextMix(), and CALocalProxy::init().
SINT32 CAMuxSocket::connect | ( | CASocketAddr & | psa, |
UINT | retry, | ||
UINT32 | time | ||
) |
Definition at line 168 of file CAMuxSocket.cpp.
References CASocket::connect(), m_aktBuffPos, and m_pSocket.
|
inline |
Definition at line 84 of file CAMuxSocket.hpp.
References m_pSocket.
Referenced by CASocketGroupEpoll::add(), CAFirstMixChannelList::add(), CAFirstMix::doUserLogin_internal(), CAFirstMix::init(), CALastMix::init(), CALocalProxy::init(), CAMiddleMix::init(), CAFirstMixB::loop(), CALastMix::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALocalProxy::processKeyExchange(), CASocketGroupEpoll::remove(), CAFirstMixA::sendToUsers(), and CAFirstMixChannelList::test().
|
inline |
Returns a Hashkey which uniquely identifies this socket.
Definition at line 52 of file CAMuxSocket.hpp.
References __t_hash_key_entry__::hashkey, and m_pHashKeyEntry.
Referenced by CAFirstMixChannelList::add(), CAFirstMixChannelList::addChannel(), CAFirstMix::doUserLogin_internal(), CAFirstMixChannelList::get(), CAFirstMixChannelList::getFirstChannelForSocket(), CAFirstMixChannelList::remove(), and CAFirstMixChannelList::removeChannel().
|
inline |
Definition at line 96 of file CAMuxSocket.hpp.
References m_bIsCrypted.
|
inline |
Definition at line 92 of file CAMuxSocket.hpp.
References CASocket::getSocket(), and m_pSocket.
Referenced by CASocketGroup::add(), CASocketGroup::isSignaled(), CASocketGroupEpoll::isSignaled(), CAFirstMixB::loop(), and CASocketGroup::remove().
|
inlinestatic |
Definition at line 166 of file CAMuxSocket.hpp.
References E_SUCCESS, and ms_pcsHashKeyList.
Referenced by CALibProxytest::init().
Definition at line 232 of file CAMuxSocket.cpp.
References t_MixPacket::channel, t_MixPacket::flags, CAMutex::lock(), m_csSend, m_pCipherOut, MIXPACKET_SIZE, and CAMutex::unlock().
Referenced by CAFirstMix::doUserLogin_internal(), CAFirstMixB::loop(), and CAFirstMixA::sendToUsers().
Receives a whole MixPacket.
Blocks until a packet is received or a socket error occurs.
pPacket | on return stores the received MixPacket |
SOCKET_ERROR,in | case of an error |
MIXPACKET_SIZE | otherwise |
Definition at line 249 of file CAMuxSocket.cpp.
References t_MixPacket::channel, E_SUCCESS, E_UNKNOWN, t_MixPacket::flags, CAMutex::lock(), m_bIsCrypted, m_csReceive, m_pCipherIn, m_pSocket, MIXPACKET_SIZE, CAMsg::printMsg(), CAClientSocket::receiveFully(), SOCKET_ERROR, and CAMutex::unlock().
Referenced by CAFirstMix::doUserLogin_internal(), CALocalProxy::loop(), CAFirstMixA::loop(), and CAFirstMixB::loop().
Trys to receive a Mix-Packet.
If after timout milliseconds not a whole packet is available E_AGAIN will be returned. In this case you should later try to get the rest of the packet
Definition at line 278 of file CAMuxSocket.cpp.
References CASocketGroup::add(), add64(), t_MixPacket::channel, diff64(), E_AGAIN, E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, t_MixPacket::flags, GET_NET_ERROR, GET_NET_ERROR_STR, getcurrentTimeMillis(), CASocket::isClosed(), isEqual64(), isGreater64(), len, CAMutex::lock(), m_aktBuffPos, m_bIsCrypted, m_Buff, m_csReceive, m_pCipherIn, m_pSocket, MIXPACKET_SIZE, CAMsg::printMsg(), CASocket::receive(), CASocketGroup::select(), and CAMutex::unlock().
Receives some "plain" bytes from the underlying socket - just a convenient function...
Definition at line 69 of file CAMuxSocket.hpp.
References len, m_pSocket, and CAClientSocket::receiveFully().
Referenced by CALastMix::processKeyExchange(), and CAMiddleMix::processKeyExchange().
Definition at line 74 of file CAMuxSocket.hpp.
References len, m_pSocket, and CASocket::receiveFullyT().
Sends a MixPacket over the Network.
Will block until the whole packet is send.
pPacket | MixPacket to send |
MIXPACKET_SIZE | if MixPacket was successful send |
E_UNKNOWN | otherwise |
Definition at line 186 of file CAMuxSocket.cpp.
References t_MixPacket::channel, E_SUCCESS, E_UNKNOWN, t_MixPacket::flags, GET_NET_ERROR, CAMutex::lock(), m_bIsCrypted, m_csSend, m_pCipherOut, m_pSocket, MIXPACKET_SIZE, CAMsg::printMsg(), CASocket::sendFully(), and CAMutex::unlock().
Referenced by CALocalProxy::loop(), and CALocalProxy::processKeyExchange().
Definition at line 215 of file CAMuxSocket.cpp.
References t_MixPacket::channel, t_MixPacket::flags, CAMutex::lock(), m_bIsCrypted, m_csSend, m_pCipherOut, MIXPACKET_SIZE, and CAMutex::unlock().
This will set the underlying CASocket.
Note: The object will be under full controll of CAMuxSocket. It will be destroyed by CAMuxSocket, if not longer needed. Therefore it must have be dynamically allocated.
pSocket | the new CASocket to use, should not be NULL |
Definition at line 81 of file CAMuxSocket.cpp.
SINT32 CAMuxSocket::setCipher | ( | SYMCHANNELCIPHER_ALGORITHM | algCipher | ) |
Definition at line 90 of file CAMuxSocket.cpp.
References CASymChannelCipherFactory::createCipher(), E_SUCCESS, E_UNKNOWN, m_pCipherIn, m_pCipherOut, NULL_CIPHER, CAMsg::printMsg(), and UNDEFINED_CIPHER.
Referenced by CAMuxSocket(), and CALocalProxy::processKeyExchange().
SINT32 CAMuxSocket::setCrypt | ( | bool | b | ) |
Definition at line 115 of file CAMuxSocket.cpp.
References E_SUCCESS, CAMutex::lock(), m_bIsCrypted, m_csReceive, m_csSend, and CAMutex::unlock().
Referenced by CAFirstMix::doUserLogin_internal(), CAMiddleMix::loop(), CALastMix::processKeyExchange(), and CALocalProxy::processKeyExchange().
Sets the symmetric keys used for de-/encrypting the Mux connection.
key | buffer conntaining the key bits |
keyLen | size of the buffer (keys) if keylen=16, then the key is used for incomming and outgoing direction (key only) if keylen=32, then the first bytes are used for incoming and the last bytes are used for outgoing |
E_SUCCESS | if successful |
E_UNKNOWN | otherwise |
Definition at line 115 of file CAMuxSocket.hpp.
References E_SUCCESS, E_UNKNOWN, m_pCipherIn, and m_pCipherOut.
Definition at line 148 of file CAMuxSocket.hpp.
References E_SUCCESS, E_UNKNOWN, and m_pCipherIn.
Referenced by CAFirstMix::doUserLogin_internal(), CALastMix::processKeyExchange(), CAMiddleMix::processKeyExchange(), and CALocalProxy::processKeyExchange().
Definition at line 132 of file CAMuxSocket.hpp.
References E_SUCCESS, E_UNKNOWN, and m_pCipherOut.
Referenced by CAFirstMix::doUserLogin_internal(), CALastMix::processKeyExchange(), CAMiddleMix::processKeyExchange(), and CALocalProxy::processKeyExchange().
|
private |
Definition at line 187 of file CAMuxSocket.hpp.
Referenced by accept(), CAMuxSocket(), close(), connect(), and receive().
|
private |
Definition at line 191 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), getIsEncrypted(), receive(), send(), and setCrypt().
|
private |
Definition at line 188 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), receive(), and ~CAMuxSocket().
|
private |
Definition at line 193 of file CAMuxSocket.hpp.
Referenced by receive(), and setCrypt().
|
private |
Definition at line 192 of file CAMuxSocket.hpp.
Referenced by prepareForSend(), send(), and setCrypt().
|
private |
Definition at line 189 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), receive(), setCipher(), setKey(), setReceiveKey(), and ~CAMuxSocket().
|
private |
Definition at line 190 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), prepareForSend(), send(), setCipher(), setKey(), setSendKey(), and ~CAMuxSocket().
|
private |
Definition at line 194 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), getHashKey(), and ~CAMuxSocket().
|
private |
Definition at line 186 of file CAMuxSocket.hpp.
Referenced by accept(), CAMuxSocket(), close(), connect(), getCASocket(), getSocket(), receive(), receiveFully(), send(), setCASocket(), and ~CAMuxSocket().
|
staticprivate |
Definition at line 197 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket().
|
staticprivate |
Definition at line 198 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), cleanup(), init(), and ~CAMuxSocket().
|
staticprivate |
Definition at line 196 of file CAMuxSocket.hpp.
Referenced by CAMuxSocket(), cleanup(), and ~CAMuxSocket().