30 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
36 #ifdef HAVE_UNIX_DOMAIN_PROTOCOL
94 CAMsg::printMsg(LOG_INFO,
"Error receiving Key Info length from next Mix. Reason: '%s' (%i)\n",
99 CAMsg::printMsg(LOG_INFO,
"Error receiving Key Info length from next Mix.");
109 CAMsg::printMsg(LOG_WARNING,
"Unrealistic length for key info: %u We might not be able to get a connection.\n",
len);
119 CAMsg::printMsg(LOG_INFO,
"Error receiving Key Info from next Mix. Reason: '%s' (%i)\n",
146 DOMElement* root=doc->getDocumentElement();
149 bool bFoundNextMix=
false;
150 DOMNode* child=root->getFirstChild();
155 if(
equals(child->getNodeName(),
"Mix"))
161 if(nextMixCert != NULL)
163 CAMsg::printMsg(LOG_DEBUG,
"Next mix certificate was verified by a trusted root CA.\n");
168 CAMsg::printMsg(LOG_ERR,
"Could not verify certificate received from next mix!\n");
184 CAMsg::printMsg(LOG_CRIT,
"Could not verify the symmetric key from next mix! The operator of the next mix has to send you his current mix certificate, and you will have to import it in your configuration.\n");
194 DOMElement* elemNonce;
202 CAMsg::printMsg(LOG_INFO,
"No nonce found in Key Info from next Mix!\n");
220 DOMNode* rsaKey=child->getFirstChild();
224 #ifdef SET_STATIC_MUX_SOCKET_KEY
225 CAMsg::printMsg(LOG_CRIT,
"Warning! Will use an all zero MuxSocket key - do not use this Mix in a productive environment -- only for testing!\n");
231 DOMElement* elemRoot=NULL;
233 docSymKey->appendChild(elemRoot);
239 elemRoot->appendChild(elemNonceHash);
242 DOMElement *elemKeepAlive;
243 DOMElement *elemKeepAliveSendInterval;
244 DOMElement *elemKeepAliveRecvInterval;
247 getDOMChildByName(elemKeepAlive,
"ReceiveInterval",elemKeepAliveRecvInterval,
false);
248 UINT32 tmpSendInterval,tmpRecvInterval;
251 CAMsg::printMsg(LOG_DEBUG,
"KeepAlive-Traffic: Getting offer -- SendInterval %u -- ReceiveInterval %u\n",tmpSendInterval,tmpRecvInterval);
258 elemKeepAlive->appendChild(elemKeepAliveSendInterval);
259 elemKeepAlive->appendChild(elemKeepAliveRecvInterval);
262 elemRoot->appendChild(elemKeepAlive);
263 CAMsg::printMsg(LOG_DEBUG,
"KeepAlive-Traffic: Offering -- SendInterval %u -- Receive Interval %u\n",u32KeepAliveSendInterval,u32KeepAliveRecvInterval);
287 UINT32 size=htonl(outlen);
290 if (docSymKey != NULL)
292 docSymKey->release();
300 child=child->getNextSibling();
306 CAMsg::printMsg(LOG_INFO,
"Error -- no Key Info found for next Mix!\n");
334 DOMElement* mixNode=NULL;
342 DOMElement* elemMixProtocolVersion=
createDOMElement(doc,
"MixProtocolVersion");
343 mixNode->appendChild(elemMixProtocolVersion);
346 DOMElement* elemKey=NULL;
348 mixNode->appendChild(elemKey);
360 mixNode->appendChild(elemNonce);
363 DOMElement* elemKeepAlive;
367 DOMElement* elemKeepAliveSendInterval;
368 DOMElement* elemKeepAliveRecvInterval;
371 elemKeepAlive->appendChild(elemKeepAliveSendInterval);
372 elemKeepAlive->appendChild(elemKeepAliveRecvInterval);
375 mixNode->appendChild(elemKeepAlive);
376 CAMsg::printMsg(LOG_DEBUG,
"KeepAlive-Traffic: Offering -- SendInterval %u -- Receive Interval %u\n",u32KeepAliveSendInterval,u32KeepAliveRecvInterval);
385 appendTermsAndConditionsExtension(doc, root);
386 mixNode->appendChild(termsAndConditionsInfoNode(doc));
392 CAMsg::printMsg(LOG_DEBUG,
"Could not sign KeyInfo send to users...\n");
412 if( (ret < 0) || (ret != (
SINT32)outlen) )
426 CAMsg::printMsg(LOG_INFO,
"Waiting for length of symmetric key from previous Mix...\n");
432 CAMsg::printMsg(LOG_CRIT,
"Error receiving symmetric key info length from the previous mix! Reason: '%s' (%i)\n",
437 CAMsg::printMsg(LOG_CRIT,
"Error receiving symmetric key info length from the previous mix!");
446 CAMsg::printMsg(LOG_WARNING,
"Unrealistic length for key info: %u We might not be able to get a connection.\n",
len);
458 CAMsg::printMsg(LOG_ERR,
"Socket error occurred while receiving the symmetric key from the previous mix! Reason: '%s' (%i) The previous mix might be unable to verify our Mix certificate(s) and therefore closed the connection. Please ask the operator for the log, and exchange your certificates if necessary.\n",
463 CAMsg::printMsg(LOG_ERR,
"Socket error occurred while receiving the symmetric key from the previous mix! The previous mix might be unable to verify our Mix certificate(s) and therefore closed the connection. Please ask the operator for the log, and exchange your certificates if necessary.\n");
484 CAMsg::printMsg(LOG_INFO,
"Error parsing Key Info from previous Mix!\n");
487 DOMElement* elemRoot=doc->getDocumentElement();
492 if(prevMixCert != NULL)
494 CAMsg::printMsg(LOG_DEBUG,
"Previous mix certificate was verified by a trusted root CA.\n");
499 CAMsg::printMsg(LOG_ERR,
"Could not verify certificate received from previous mix!\n");
515 CAMsg::printMsg(LOG_CRIT,
"Could not verify the symmetric key from previous mix! The operator of the previous mix has to send you his current mix certificate, and you will have to import it in your configuration.\n");
534 return resultCompatibility;
541 memset(tmpBuff,0,tmpLen);
544 tmpLen!=SHA_DIGEST_LENGTH ||
545 memcmp(SHA1(arNonce,16,NULL),tmpBuff,SHA_DIGEST_LENGTH)!=0
549 CAMsg::printMsg(LOG_CRIT,
"Could not verify the Nonce from previous mix!\n");
557 CAMsg::printMsg(LOG_INFO,
"Verified the symmetric key of the previous mix!\n");
607 CAMsg::printMsg(LOG_CRIT,
"Could not set the symmetric key from previous mix to be used by the MuxSocket!\n");
621 elemKeepAliveSendInterval=NULL;
622 elemKeepAliveRecvInterval=NULL;
626 UINT32 tmpSendInterval,tmpRecvInterval;
629 CAMsg::printMsg(LOG_DEBUG,
"KeepAlive-Traffic: Getting offer -- SendInterval %u -- Receive Interval %u\n",tmpSendInterval,tmpRecvInterval);
652 m_bBreakNeeded = m_bReconfigured;
654 #ifdef WITH_SGX_IGNORED
658 int upstreamShMemPre_fd,upstreamShMemPost_fd;
659 int downstreamShMemPre_fd,downstreamShMemPost_fd;
660 void *upstreamShMemPreData, *upstreamShMemPostData;
661 void *downstreamShMemPreData, *downstreamShMemPostData;
663 upstreamShMemPre_fd = shm_open(
upstreamMemoryPreName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
664 upstreamShMemPost_fd = shm_open(
upstreamMemoryPostName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
665 downstreamShMemPre_fd = shm_open(
downstreamMemoryPreName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
666 downstreamShMemPost_fd = shm_open(
downstreamMemoryPostName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
668 ftruncate(upstreamShMemPre_fd,SIZE);
669 ftruncate(upstreamShMemPost_fd, SIZE);
670 ftruncate(downstreamShMemPre_fd,SIZE);
671 ftruncate(downstreamShMemPost_fd, SIZE);
673 upstreamShMemPreData = mmap(0,SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, upstreamShMemPre_fd, 0);
674 if (upstreamShMemPreData == MAP_FAILED) {
675 printf(
"Map failed\n");
678 upstreamShMemPostData = mmap(0,SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, upstreamShMemPost_fd, 0);
679 if (upstreamShMemPostData == MAP_FAILED) {
680 printf(
"Map failed\n");
683 downstreamShMemPreData = mmap(0,SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, downstreamShMemPre_fd, 0);
684 if (downstreamShMemPreData == MAP_FAILED) {
685 printf(
"Map failed\n");
688 downstreamShMemPostData = mmap(0,SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, downstreamShMemPost_fd, 0);
689 if (downstreamShMemPostData == MAP_FAILED) {
690 printf(
"Map failed\n");
695 union semun sunionUpstreamPre;
696 union semun sunionUpstreamPost;
697 union semun sunionDownstreamPre;
698 union semun sunionDownstreamPost;
708 sunionUpstreamPre.val = 1;
710 sunionUpstreamPre.val = 0;
712 sunionUpstreamPost.val = 1;
714 sunionUpstreamPost.val = 0;
717 sunionDownstreamPre.val = 1;
719 sunionDownstreamPre.val = 0;
721 sunionDownstreamPost.val = 1;
723 sunionDownstreamPost.val = 0;
739 UINT32 keyFileBuffLen=8096;
758 #ifdef EXPORT_ASYM_PRIVATE_KEY
761 UINT32 keyFileBuffLen=8096;
765 m_pRSA->setPrivateKeyAsXML(keyBuff,keyFileBuffLen);
766 delete[] keyFileBuff;
778 #ifdef EXPORT_ASYM_PRIVATE_KEY
781 UINT32 keyFileBuffLen=8096;
785 m_pRSA->getPrivateKeyAsXML(keyBuff,&keyFileBuffLen);
786 saveFile(keyFileBuff,keyBuff,keyFileBuffLen);
787 delete[] keyFileBuff;
815 CAMsg::printMsg(LOG_CRIT,
"Init: Cannot create SOCKET for outgoing connection...\n");
824 for(
UINT32 i=1;i<=interfaces;i++)
834 CAMsg::printMsg(LOG_CRIT,
"Failed to initialize socket for previous mix! Reason: no usable (non virtual) listener interface found!\n");
844 CAMsg::printMsg(LOG_INFO,
"Waiting for connection from previous Mix on %s...\n", buff);
849 if(m_bBreakNeeded != m_bReconfigured)
859 CAMsg::printMsg(LOG_CRIT,
"Error waiting for previous Mix... -- restart!\n");
879 CAMsg::printMsg(LOG_DEBUG,
"CAMiddleMix::init - Unable to connect to next mix\n");
903 #ifdef REPLAY_DETECTION
911 #ifdef LOG_PACKET_TIMES
912 m_pLogPacketStats =
new CALogPacketStats();
914 m_pLogPacketStats->start();
953 CAMsg::printMsg(LOG_ERR,
"CAFirstMix::lm_loopSendToMixAfter - Error in dequeueing MixPaket\n");
960 CAMsg::printMsg(LOG_ERR,
"CAFirstMix::lm_loopSendToMixAfter - Error in sending MixPaket\n");
963 #ifdef LOG_PACKET_TIMES
964 if(!
isZero64(pPoolEntry->timestamp_proccessing_start))
967 pMiddleMix->m_pLogPacketStats->addToTimeingStats(*pPoolEntry, pMixPacket->
flags,
true);
971 pMiddleMix->
m_bRun =
false;
1001 CAMsg::printMsg(LOG_INFO,
"SendToMixBefore thread: was interrupted.\n");
1013 CAMsg::printMsg(LOG_ERR,
"CAFirstMix::lm_loopSendToMixBefore - Error in dequeueing MixPaket\n");
1020 CAMsg::printMsg(LOG_ERR,
"CAFirstMix::lm_loopSendToMixBefore - Error in sending MixPaket\n");
1023 #ifdef LOG_PACKET_TIMES
1024 if(!
isZero64(pPoolEntry->timestamp_proccessing_start))
1027 pMiddleMix->m_pLogPacketStats->addToTimeingStats(*pPoolEntry,pMixPacket->
flags,
true);
1031 pMiddleMix->
m_bRun =
false;
1040 #define MIDDLE_MIX_SIZE_OF_SYMMETRIC_KEYS 2*KEY_SIZE
1041 #define MIDDLE_MIX_ASYM_PADDING_SIZE 42
1062 oSocketGroup.
add(*(
pMix->m_pMuxIn));
1079 ret=oSocketGroup.
select(1000);
1093 pPool->
pool(pPoolEntry);
1109 CAMsg::printMsg(LOG_CRIT,
"loopUpStream -- Fehler bei select() -- goto ERR!\n");
1116 ret=
pMix->m_pMuxIn->receive(pMixPacket);
1136 pPool->
pool(pPoolEntry);
1165 channelIn = pMixPacket->
channel;
1167 if(
pMix->m_pMiddleMixChannelList->getInToOut(pMixPacket->
channel,&channelOut,&pCipher)!=
E_SUCCESS)
1174 if (
pMix->m_pRSA->decryptOAEP(pMixPacket->
data, tmpRSABuff, &rsaOutLen) !=
E_SUCCESS)
1176 CAMsg::printMsg(LOG_ERR,
"Received wrongly decrypted Channel Open Packet!\n");
1179 #ifdef REPLAY_DETECTION
1183 if(
pMix->m_pReplayDB->insert(tmpRSABuff,stamp+
pMix->m_u64ReferenceTime)!=
E_SUCCESS)
1198 pMix->m_pMiddleMixChannelList->add(pMixPacket->
channel,pCipher,&channelOut);
1199 pMixPacket->
channel=channelOut;
1201 pPool->
pool(pPoolEntry);
1204 crimeSurveillanceUpstream(pMixPacket, channelIn);
1214 pPool->
pool(pPoolEntry);
1218 pMix->m_pMiddleMixChannelList->remove(pMixPacket->
channel);
1220 pMixPacket->
channel=channelOut;
1222 crimeSurveillanceUpstream(pMixPacket, channelIn);
1230 CAMsg::printMsg(LOG_CRIT,
"loopReadFromMixBefore -- Exiting clean ups...\n");
1234 if(
pMix->m_pQueueSendToMixBefore!=NULL)
1238 if(
pMix->m_pQueueSendToMixAfter!=NULL)
1242 delete[] tmpRSABuff;
1265 oSocketGroup.
add(*(
pMix->m_pMuxOut));
1267 CAQueue* pQueueSendtoMix=
pMix->m_pQueueSendToMixBefore;
1283 ret=oSocketGroup.
select(1000);
1297 pPool->
pool(pPoolEntry);
1313 CAMsg::printMsg(LOG_CRIT,
"loopReadFromMixAfter -- Error on select() while waiting for data from next mix -- goto ERR!\n");
1320 ret=
pMix->m_pMuxOut->receive(pMixPacket);
1328 CAMsg::printMsg(LOG_CRIT,
"loopReadFromMixAfter -- Error while receiving data from next mix. Reason: %s (%i)\n",
1338 pPool->
pool(pPoolEntry);
1352 #ifdef REPLAY_DETECTION
1358 else if(
pMix->m_pMiddleMixChannelList->getOutToIn(&channelIn,pMixPacket->
channel,&pCipher)==
E_SUCCESS)
1374 pMixPacket->
channel=channelIn;
1380 CAMsg::printMsg(LOG_CRIT,
"Detecting crime activity - previous mix channel: %u, "
1381 "next mix channel: %u\n", channelIn, channelOut);
1388 pPool->
pool(pPoolEntry);
1392 pMix->m_pMiddleMixChannelList->remove(channelIn);
1394 pMix->putMixPacketIntoQueueSendToMixBefore(pPoolEntry);
1399 CAMsg::printMsg(LOG_CRIT,
"loopReadFromMixAfter -- Exiting clean ups...\n");
1403 if(
pMix->m_pQueueSendToMixBefore!=NULL)
1407 if(
pMix->m_pQueueSendToMixAfter!=NULL)
1431 #define RETRYTIME 10
1434 CAMsg::printMsg(LOG_INFO,
"Try to connect to next Mix on %s ...\n",buff);
1442 if(m_bBreakNeeded != m_bReconfigured)
1444 CAMsg::printMsg(LOG_DEBUG,
"CAMiddleMix::connectToNextMix - Broken the connect loop!\n");
1457 CAMsg::printMsg(LOG_ERR,
"Cannot connect to next Mix on %s. Reason: %s (%i)\n",
1462 if (errLast != err || i % 10 == 0)
1464 CAMsg::printMsg(LOG_ERR,
"Cannot connect to next Mix on %s. Reason: %s (%i). Retrying...\n",
1497 oThread.
start(
this);
1501 bThread.
start(
this);
1505 cThread.
start(
this);
1509 dThread.
start(
this);
1523 CAMsg::printMsg(LOG_CRIT,
"loop(): Seems that we are restarting now!!\n");
1534 #ifdef REPLAY_DETECTION
1556 #ifdef WITH_SGX_IGNORED
1565 printf (
"Fehler beim Löschen des Semaphors pre.\n");
1568 printf (
"Fehler beim Löschen des Semaphors post.\n");
1571 printf (
"Fehler beim Löschen des Semaphors pre.\n");
1574 printf (
"Fehler beim Löschen des Semaphors post.\n");
1597 #ifdef LOG_PACKET_TIMES
1598 if (m_pLogPacketStats != NULL)
1600 CAMsg::printMsg(LOG_CRIT,
"Wait for LoopLogPacketStats to terminate!\n");
1601 m_pLogPacketStats->stop();
1602 delete m_pLogPacketStats;
1604 m_pLogPacketStats = NULL;
1613 static void crimeSurveillanceUpstream(
MIXPACKET *pMixPacket,
HCHANNEL prevMixChannel)
1617 CAMsg::printMsg(LOG_CRIT,
"Crime detection: User surveillance, previous mix channel: %u, "
1618 "next mix channel %u\n", prevMixChannel, pMixPacket->
channel);
THREAD_RETURN mm_loopSendToMixBefore(void *param)
DOWNSTREAM (to Client) Take the packets from the Queue and write them to the Socket.
#define MIDDLE_MIX_ASYM_PADDING_SIZE
THREAD_RETURN mm_loopSendToMixAfter(void *param)
UPSTREAM (to WEB) Take the packets from the Queue and write them to the Socket.
#define MIDDLE_MIX_SIZE_OF_SYMMETRIC_KEYS
THREAD_RETURN mm_loopReadFromMixAfter(void *param)
THREAD_RETURN mm_loopReadFromMixBefore(void *param)
#define MONITORING_FIRE_NET_EVENT(e_type)
#define BEGIN_STACK(methodName)
#define FINISH_STACK(methodName)
SINT32 setDOMElementAttribute(DOMNode *pElem, const char *attrName, const char *value)
SINT32 getDOMElementValue(const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
Returns the content of the text node(s) under elem as null-terminated C String.
UINT8 * readFile(const UINT8 *const name, UINT32 *size)
ONLY_LOCAL_PROXY or first.
SINT32 setDOMElementValue(DOMElement *pElem, SINT32 value)
SINT32 getcurrentTimeMicros(UINT64 &u64Time)
Gets the current Systemtime in micros seconds.
bool equals(const XMLCh *const e1, const char *const e2)
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
XERCES_CPP_NAMESPACE::DOMDocument * parseDOMDocument(const UINT8 *const buff, UINT32 len)
Parses a buffer containing an XML document and returns this document.
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
XERCES_CPP_NAMESPACE::DOMDocument * createDOMDocument()
Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in...
DOMElement * createDOMElement(XERCES_CPP_NAMESPACE::DOMDocument *pOwnerDoc, const char *const name)
Creates a new DOMElement with the given name which belongs to the DOMDocument owernDoc.
SINT32 getDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
SINT32 getDOMElementAttribute(const DOMNode *const elem, const char *attrName, UINT8 *value, UINT32 *len)
SINT32 saveFile(const UINT8 *const name, const UINT8 *const buff, UINT32 buffSize)
SINT32 encodeXMLEncryptedKey(UINT8 *key, UINT32 keylen, UINT8 *xml, UINT32 *xmllen, CAASymCipher *pRSA)
SINT32 decodeXMLEncryptedKey(UINT8 *key, UINT32 *keylen, const UINT8 *const xml, UINT32 xmllen, CAASymCipher *pRSA)
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
bool isZero64(UINT64 &op1)
#define MAX_READ_FROM_PREV_MIX_QUEUE_SIZE
#define GET_NET_ERROR_STR(x)
#define REPLAY_TIMESTAMP_PROPAGATION_INTERVALL
#define ERR_INTERN_CONNREFUSED
#define THREAD_RETURN_SUCCESS
#define MAX_READ_FROM_NEXT_MIX_QUEUE_SIZE
#define ERR_INTERN_TIMEDOUT
#define FM_PACKET_STATS_LOG_INTERVALL
SINT32 getPublicKeyAsDOMElement(DOMElement *&elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner)
SINT32 setPublicKeyAsDOMNode(DOMNode *node)
SINT32 setPublicKeyAsXML(const UINT8 *buff, UINT32 len)
Sets the public key to the values stored in key.
SINT32 generateKeyPair(UINT32 size)
Generates a new random key-pair of size bits.
static SINT32 encode(const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
static SINT32 decode(const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
CACertificate * verifyMixCert(DOMNode *mixNode)
This function parses the certificates from a <Mix>-node and tries to build a certPath to the trusted ...
UINT32 getListenerInterfaceCount()
SINT32 getMixId(UINT8 *id, UINT32 len)
SINT32 setPrevMixTestCertificate(CACertificate *cert)
UINT32 getKeepAliveRecvInterval()
CAMultiSignature * getMultiSigner()
CAListenerInterface * getListenerInterface(UINT32 nr)
CACertificate * getNextMixTestCertificate()
SINT32 setNextMixTestCertificate(CACertificate *cert)
UINT32 getKeepAliveSendInterval()
CACertStore * getTrustedCertificateStore()
UINT32 getTargetInterfaceCount()
CACertificate * getPrevMixTestCertificate()
SINT32 getTargetInterface(CATargetInterface &oTargetInterface, UINT32 nr)
Fills a TargetInterface struct with the values which belongs to the target interface nr.
This class "dispatches" messages which it receives via proccessMixPacket() to the associated control ...
static CACmdLnOptions * getOptions()
CASocketAddr * getAddr() const
SINT32 unlock()
Unlocks the lockable object by threadsafe decrementing a reference counter.
Data structure that stores all information about the currently open Mix channels.
UINT32 m_u32KeepAliveSendInterval2
CAQueue * m_pQueueSendToMixAfter
friend THREAD_RETURN mm_loopReadFromMixAfter(void *)
friend THREAD_RETURN mm_loopSendToMixAfter(void *)
UPSTREAM (to WEB) Take the packets from the Queue and write them to the Socket.
UINT32 m_u32KeepAliveRecvInterval2
const char * downstreamMemoryPreName
virtual SINT32 processKeyExchange()
Processes key exchange with Mix n+1 and Mix n-1.
SINT32 loop()
Processes Upstream-MixPackets.
const char * downstreamMemoryPostName
void * downstreamPreBuffer
SINT32 connectToNextMix(CASocketAddr *a_pAddrNext)
const char * upstreamMemoryPreName
CAQueue * m_pQueueSendToMixBefore
friend THREAD_RETURN mm_loopReadFromMixBefore(void *)
friend THREAD_RETURN mm_loopSendToMixBefore(void *)
DOWNSTREAM (to Client) Take the packets from the Queue and write them to the Socket.
const char * upstreamMemoryPostName
void * downstreamPostBuffer
CAMiddleMixChannelList * m_pMiddleMixChannelList
SINT32 putMixPacketIntoQueueSendToMixBefore(tPoolEntry *pPoolEntry)
void * upstreamPostBuffer
SINT32 appendCompatibilityInfo(DOMNode *a_parent)
SINT32 checkCompatibility(DOMNode *a_parent, const char *a_mixPosition)
SINT32 signXML(DOMNode *a_element)
static const UINT32 TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT
SINT32 addMixInfo(DOMNode *a_element, bool a_bForceFirstNode)
CAControlChannelDispatcher * m_pMuxInControlChannelDispatcher
UINT32 m_u32KeepAliveRecvInterval
CAMultiSignature * m_pMultiSignature
volatile bool m_bShutDown
UINT32 m_u32KeepAliveSendInterval
UINT64 m_u64ReferenceTime
CAReplayCtrlChannelMsgProc * m_pReplayMsgProc
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
static SINT32 verifyXML(const UINT8 *const in, UINT32 inlen, CACertificate *a_cert)
SINT32 signXML(DOMNode *a_node, bool appendCerts)
SINT32 close()
Closes the underlying socket.
SINT32 accept(UINT16 port)
SINT32 connect(CASocketAddr &psa)
SINT32 setSendKey(UINT8 *key, UINT32 keyLen)
SINT32 setReceiveKey(UINT8 *key, UINT32 keyLen)
SINT32 send(MIXPACKET *pPacket)
Sends a MixPacket over the Network.
SINT32 receiveFully(UINT8 *buff, UINT32 len)
Receives some "plain" bytes from the underlying socket - just a convenient function....
This class implements the pool strategie of a Mix.
SINT32 pool(tPoolEntry *pPoolEntry)
This is a simple FIFO-Queue.
SINT32 add(const void *buff, UINT32 size)
Adds data to the Queue.
SINT32 getOrWait(UINT8 *pbuff, UINT32 *psize)
Gets data from the Queue or waits until some data is available, if the Queue is empty.
UINT32 getSize()
Returns the size of stored data in byte.
SINT32 startTimeStampPorpagation(UINT32 minutesPropagationIntervall)
Sends the current replay timestamp periodically on the downstream replay control channel.
This is an abstract class for representing a socket address used in CASocket, CADatagramSocket and CA...
virtual SINT32 getType() const =0
The type (family) of socket for which this address is useful.
virtual SINT32 toString(UINT8 *buff, UINT32 bufflen) const =0
Returns a string which describes this address in a human readable form.
virtual SINT32 send(const UINT8 *buff, UINT32 len)
Sends some data over the network.
virtual SINT32 setKeepAlive(bool b)
Enables/disables the socket keep-alive option.
virtual SINT32 setRecvBuff(UINT32 r)
virtual SINT32 setSendBuff(SINT32 r)
Returns < 0 on error, otherwise the new sendbuffersize (which may be less than r)
static CASymChannelCipher * createCipher(SYMCHANNELCIPHER_ALGORITHM alg)
virtual SINT32 setKeys(const UINT8 *key, UINT32 keysize)=0
Sets the keys for crypt1() and crypt2() either to the same key (if keysize==KEY_SIZE) or to different...
virtual SINT32 crypt2(const UINT8 *in, UINT8 *out, UINT32 len)=0
virtual SINT32 crypt1(const UINT8 *in, UINT8 *out, UINT32 len)=0
TargetType getTargetType() const
CASocketAddr * getAddr() const
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
SINT32 setMainLoop(THREAD_MAIN_TYP fnc)
Sets the main function which will be executed within this thread.
SINT32 join()
Waits for the main function to finish execution.
static SINT32 dumpToMem(const DOMNode *node, UINT8 *buff, UINT32 *size)
Dumps the node and all childs into buff.
#define REPLAY_CONTROL_CHANNEL_ID
@ ev_net_nextConnectionClosed
@ ev_net_keyExchangePrevSuccessful
@ ev_net_prevConnectionClosed
@ ev_net_keyExchangeNextSuccessful
@ ev_net_keyExchangePrevFailed
@ ev_net_keyExchangeNextFailed
#define CHANNEL_ALLOWED_FLAGS
struct t_queue_entry tQueueEntry
#define CHANNEL_SIG_CRIME