Mixe for Privacy and Anonymity in the Internet
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
CAMix Class Referenceabstract

#include <CAMix.hpp>

Inheritance diagram for CAMix:
Collaboration diagram for CAMix:

Public Types

enum  tMixType { FIRST_MIX , MIDDLE_MIX , LAST_MIX , JAP }
 

Public Member Functions

 CAMix ()
 
virtual ~CAMix ()
 
SINT32 start ()
 
virtual SINT32 reconfigure ()
 
virtual tMixType getType () const =0
 
virtual void shutDown ()
 
virtual bool isShutDown ()
 
SINT32 getMixCascadeInfo (XERCES_CPP_NAMESPACE::DOMDocument *&docMixCascadeInfo)
 Returns the Mix-Cascade info which should be send to the InfoService. More...
 
bool acceptsReconfiguration ()
 
CAControlChannelDispatchergetDownstreamControlChannelDispatcher () const
 
CAControlChannelDispatchergetUpstreamControlChannelDispatcher () const
 
UINT32 getLastConnectionTime ()
 
bool isConnected ()
 

Static Public Attributes

static const UINT32 TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT = 60000
 

Protected Member Functions

virtual SINT32 clean ()=0
 
virtual SINT32 initOnce ()
 
virtual SINT32 init ()=0
 
virtual SINT32 loop ()=0
 
SINT32 checkCompatibility (DOMNode *a_parent, const char *a_mixPosition)
 
SINT32 appendCompatibilityInfo (DOMNode *a_parent)
 
SINT32 addMixInfo (DOMNode *a_element, bool a_bForceFirstNode)
 
virtual SINT32 processKeyExchange ()=0
 
virtual SINT32 initMixCascadeInfo (DOMElement *elemMixes)
 This will initialize the XML Cascade Info struct XMLFirstMixToInfoService that is sent to the InfoService in CAInfoService::sendCascadeHelo() More...
 
SINT32 signXML (DOMNode *a_element)
 

Protected Attributes

volatile bool m_bLoop
 
bool m_bReconfiguring
 
volatile bool m_bShutDown
 
CAMultiSignaturem_pMultiSignature
 
CAInfoServicem_pInfoService
 
UINT32 m_u32KeepAliveRecvInterval
 
UINT32 m_u32KeepAliveSendInterval
 
bool m_acceptReconfiguration
 
volatile bool m_bConnected
 
volatile UINT32 m_lLastConnectionTime
 
XERCES_CPP_NAMESPACE::DOMDocument * m_docMixCascadeInfo
 
CAControlChannelDispatcherm_pMuxOutControlChannelDispatcher
 
CAControlChannelDispatcherm_pMuxInControlChannelDispatcher
 

Private Member Functions

bool needAutoConfig ()
 This method checks if target interfaces (network adress and port of next mix) have been specified in the config file. More...
 

Detailed Description

Definition at line 48 of file CAMix.hpp.

Member Enumeration Documentation

◆ tMixType

Enumerator
FIRST_MIX 
MIDDLE_MIX 
LAST_MIX 
JAP 

Definition at line 51 of file CAMix.hpp.

52  {
53  FIRST_MIX,
54  MIDDLE_MIX,
55  LAST_MIX,
56  JAP
57  };
@ LAST_MIX
Definition: CAMix.hpp:55
@ FIRST_MIX
Definition: CAMix.hpp:53
@ JAP
Definition: CAMix.hpp:56
@ MIDDLE_MIX
Definition: CAMix.hpp:54

Constructor & Destructor Documentation

◆ CAMix()

CAMix::CAMix ( )

Definition at line 39 of file CAMix.cpp.

40  {
42  //m_pSignature=NULL;
43  m_pMultiSignature=NULL;
44  m_pInfoService=NULL;
47  m_u32KeepAliveSendInterval=0;//zero means --> do not use
48  m_u32KeepAliveRecvInterval=0;//zero means --> do not use
49  m_bShutDown = false;
51  m_bConnected = false;
53 //#ifdef DYNAMIC_MIX
54  /* LERNGRUPPE: Run by default */
55  m_bLoop = true;
56 #ifdef DYNAMIC_MIX
57  m_bReconfiguring = false;
58  m_bCascadeEstablished = false;
59  m_bReconfigured = false;
60 #endif
61 #ifdef DATA_RETENTION_LOG
62  m_pDataRetentionLog=NULL;
63 #endif
64  }
bool acceptReconfiguration()
static CACmdLnOptions * getOptions()
volatile bool m_bConnected
Definition: CAMix.hpp:190
bool m_bReconfiguring
Definition: CAMix.hpp:143
volatile bool m_bLoop
Definition: CAMix.hpp:135
CAInfoService * m_pInfoService
Definition: CAMix.hpp:184
volatile UINT32 m_lLastConnectionTime
Definition: CAMix.hpp:191
CAControlChannelDispatcher * m_pMuxOutControlChannelDispatcher
Definition: CAMix.hpp:195
CAControlChannelDispatcher * m_pMuxInControlChannelDispatcher
Definition: CAMix.hpp:196
UINT32 m_u32KeepAliveRecvInterval
Definition: CAMix.hpp:186
CAMultiSignature * m_pMultiSignature
Definition: CAMix.hpp:183
volatile bool m_bShutDown
Definition: CAMix.hpp:144
XERCES_CPP_NAMESPACE::DOMDocument * m_docMixCascadeInfo
Definition: CAMix.hpp:193
UINT32 m_u32KeepAliveSendInterval
Definition: CAMix.hpp:187
bool m_acceptReconfiguration
Definition: CAMix.hpp:189

References CACmdLnOptions::acceptReconfiguration(), CALibProxytest::getOptions(), m_acceptReconfiguration, m_bConnected, m_bLoop, m_bReconfiguring, m_bShutDown, m_docMixCascadeInfo, m_lLastConnectionTime, m_pInfoService, m_pMultiSignature, m_pMuxInControlChannelDispatcher, m_pMuxOutControlChannelDispatcher, m_u32KeepAliveRecvInterval, and m_u32KeepAliveSendInterval.

Here is the call graph for this function:

◆ ~CAMix()

CAMix::~CAMix ( )
virtual

Definition at line 66 of file CAMix.cpp.

67  {
68 #ifdef DATA_RETENTION_LOG
69  if(m_pDataRetentionLog!=NULL)
70  {
71  delete m_pDataRetentionLog;
72  m_pDataRetentionLog=NULL;
73  }
74 #endif
75 
76  }

Member Function Documentation

◆ acceptsReconfiguration()

bool CAMix::acceptsReconfiguration ( )
inline

Definition at line 110 of file CAMix.hpp.

111  {
113  }

References m_acceptReconfiguration.

◆ addMixInfo()

SINT32 CAMix::addMixInfo ( DOMNode *  a_element,
bool  a_bForceFirstNode 
)
protected

Definition at line 437 of file CAMix.cpp.

438  {
439  // this is a complete mixinfo node to be sent to the InfoService
440  XERCES_CPP_NAMESPACE::DOMDocument* docMixInfo=NULL;
441  if(CALibProxytest::getOptions()->getMixXml(docMixInfo)!=E_SUCCESS)
442  {
443  return E_UNKNOWN;
444  }
445  DOMNode* nodeMixInfo = a_element->getOwnerDocument()->importNode(docMixInfo->getDocumentElement(), true);
446  if (a_bForceFirstNode && a_element->hasChildNodes())
447  {
448  a_element->insertBefore(nodeMixInfo, a_element->getFirstChild());
449  }
450  else
451  {
452  a_element->appendChild(nodeMixInfo);
453  }
454  return E_SUCCESS;
455  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References E_SUCCESS, E_UNKNOWN, and CALibProxytest::getOptions().

Referenced by initMixCascadeInfo(), CALastMix::processKeyExchange(), and CAMiddleMix::processKeyExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendCompatibilityInfo()

SINT32 CAMix::appendCompatibilityInfo ( DOMNode *  a_parent)
protected

EDIT HERE FOR INTRODUCING NEW FLAGS!

Definition at line 634 of file CAMix.cpp.

635  {
636  DOMElement* elemCompatibility=createDOMElement(a_parent->getOwnerDocument(),"Compatibility");
637  setDOMElementAttribute(elemCompatibility,"version",(UINT8*)MIX_VERSION);
638  a_parent->appendChild(elemCompatibility);
639 
640  DOMElement* elemFlags=NULL;
641  DOMElement* elemFlag=NULL;
642 
643  elemFlags = createDOMElement(a_parent->getOwnerDocument(), "Flags");
644  elemCompatibility->appendChild(elemFlags);
645 
647 #ifdef PAYMENT
648  elemFlag = createDOMElement(a_parent->getOwnerDocument(), PAYMENT_COMPATIBILITY);
649  //setDOMElementValue(elemFlag,(UINT8*)"true"); // you might add a version number here for a protocol etc.
650  elemFlags->appendChild(elemFlag);
651 #endif
652 
653  elemFlag = createDOMElement(a_parent->getOwnerDocument(), NEW_FLOW_CONTROL_COMPATIBILITY);
654  //setDOMElementValue(elemFlag,(UINT8*)"true");
655  elemFlags->appendChild(elemFlag);
656 
657  elemFlag = createDOMElement(a_parent->getOwnerDocument(), NEW_CHANNEL_ENCRYPTION_COMPATIBILITY);
658  //setDOMElementValue(elemFlag,(UINT8*)"true");
659  elemFlags->appendChild(elemFlag);
660 
661 #ifdef WITH_INTEGRITY_CHECK
662  elemFlag = createDOMElement(a_parent->getOwnerDocument(), WITH_INTEGRITY_CHECK_COMPATIBILITY);
663  //setDOMElementValue(elemFlag,(UINT8*)"true");
664  elemFlags->appendChild(elemFlag);
665 #endif
666 
667  return E_SUCCESS;
668  }
SINT32 setDOMElementAttribute(DOMNode *pElem, const char *attrName, const char *value)
Definition: CAUtil.cpp:831
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.
Definition: CAUtil.cpp:814
#define MIX_VERSION
Definition: StdAfx.h:36
#define WITH_INTEGRITY_CHECK_COMPATIBILITY
Definition: StdAfx.h:735
#define NEW_FLOW_CONTROL_COMPATIBILITY
Definition: StdAfx.h:725
#define NEW_CHANNEL_ENCRYPTION_COMPATIBILITY
Definition: StdAfx.h:728
#define PAYMENT_COMPATIBILITY
Definition: StdAfx.h:712
unsigned char UINT8
Definition: basetypedefs.h:135

References createDOMElement(), E_SUCCESS, MIX_VERSION, NEW_CHANNEL_ENCRYPTION_COMPATIBILITY, NEW_FLOW_CONTROL_COMPATIBILITY, PAYMENT_COMPATIBILITY, setDOMElementAttribute(), and WITH_INTEGRITY_CHECK_COMPATIBILITY.

Referenced by CALastMix::processKeyExchange(), and CAMiddleMix::processKeyExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkCompatibility()

SINT32 CAMix::checkCompatibility ( DOMNode *  a_parent,
const char *  a_mixPosition 
)
protected

EDIT HERE FOR ADDING INCOMPATIBLE VERSIONS!

EDIT HERE FOR INTRODUCING NEW FLAGS!

EDIT HERE FOR INTRODUCING NEW FLAGS!

Definition at line 670 of file CAMix.cpp.

671  {
672  // get compatibility info
673  DOMElement* elemCompatibility=NULL;
674  DOMElement* elemFlags=NULL;
675  DOMElement* elemDummy=NULL;
676  UINT8 strAllFlags[500];
677  UINT32 lenAllFlags;
678  UINT8 strNodeName[50];
679  UINT32 lenNodeName=50;
680  UINT8 strVersion[50];
681  UINT32 len=50;
682  SINT32 iCompare;
683  UINT8* strComment;
684  UINT32 iCountFlags = 0;
685  UINT32 iLogLevel = LOG_INFO;
686  bool bCompatible = true;
687  bool bCompatibleFlags = true;
688 
689  if (getDOMChildByName(a_parent,"Compatibility",elemCompatibility,false) != E_SUCCESS ||
690  getDOMElementAttribute(elemCompatibility, "version", strVersion, &len) != E_SUCCESS)
691  {
692  CAMsg::printMsg(LOG_WARNING,"Could not get any compatibility information from the %s mix. It may or may not be compatible. If the connection fails for an unknown reason, the %s mix should be updated.\n", a_mixPosition, a_mixPosition);
693  return E_SUCCESS;
694  }
695 
696  iCompare = strncmp (MIX_VERSION, (char*)strVersion, len);
697 
698  if (iCompare == 0)
699  {
700  strComment = (UINT8*)" We have the same version.";
701  }
702  else if (iCompare < 0)
703  {
704  strComment = (UINT8*)" Our version (" MIX_VERSION ") might be too old. If the connection fails for an unknown reason, you should think about an update.";
705  iLogLevel = LOG_WARNING;
706  }
707  else
708  {
710  if (strncmp ("00.08.71", (char*)strVersion, len) > 0)
711  {
712  strComment = (UINT8*)" This version is NOT COMPATIBLE with our version (" MIX_VERSION ")! The mixes will not work together in a cascade.";
713  bCompatible = false;
714  iLogLevel = LOG_CRIT;
715  }
716  else
717  {
718  strComment = (UINT8*)" We have a newer version (" MIX_VERSION "), but both are known to work fine together.";
719  }
720  }
721 
722  CAMsg::printMsg(iLogLevel,"The software version of the %s mix is %s.%s\n", a_mixPosition, strVersion, strComment);
723 
725 #ifdef PAYMENT
726  iCountFlags++;
727 #endif
728 
729  iCountFlags++;
730 
731  iCountFlags++;
732 
733 #ifdef WITH_INTEGRITY_CHECK
734  iCountFlags++;
735 #endif
736 
737  if (getDOMChildByName(elemCompatibility, "Flags", elemFlags, false) == E_SUCCESS)
738  {
739  DOMNodeList* flags = elemFlags->getChildNodes();
740  if (flags->getLength() != iCountFlags)
741  {
742  bCompatibleFlags = false;
743  }
744 
746  // Hint: We might also check for a version of the compile flags if available; it should be set in the content of each tag instead of 'true'.
747 #ifdef PAYMENT
748  if (getDOMChildByName(elemFlags, PAYMENT_COMPATIBILITY, elemDummy, false) != E_SUCCESS)
749  {
750  bCompatibleFlags = false;
751  }
752 #endif
753  if (getDOMChildByName(elemFlags, NEW_FLOW_CONTROL_COMPATIBILITY, elemDummy, false) != E_SUCCESS)
754  {
755  bCompatibleFlags = false;
756  }
757  if (getDOMChildByName(elemFlags, NEW_CHANNEL_ENCRYPTION_COMPATIBILITY, elemDummy, false) != E_SUCCESS)
758  {
759  bCompatibleFlags = false;
760  }
761 #ifdef WITH_INTEGRITY_CHECK
762  if (getDOMChildByName(elemFlags, WITH_INTEGRITY_CHECK_COMPATIBILITY, elemDummy, false) != E_SUCCESS)
763  {
764  bCompatibleFlags = false;
765  }
766 #endif
767 
768  if (!bCompatibleFlags)
769  {
770  // get the flags of the other mix
771  strAllFlags[0] = 0;
772  lenAllFlags = 1;
773  for (UINT32 i = 0; i < flags->getLength(); i++)
774  {
775  if (::getNodeName(flags->item(i), strNodeName, &lenNodeName) == E_SUCCESS)
776  {
777 
778  lenAllFlags += strlen((char*)strNodeName) + 1;
779  if (lenAllFlags > 500)
780  {
781  break;
782  }
783  strcat((char*)strAllFlags, " ");
784  strcat((char*)strAllFlags, (char*)strNodeName);
785  }
786 
787  lenNodeName = 50;
788  }
789 
790  CAMsg::printMsg(LOG_CRIT, "The compile flags of the %s mix are NOT COMPATIBLE with our flags. We have: %s They have: %s --> The mixes won't run together.\n", a_mixPosition, MIX_VERSION_COMPATIBILITY, strAllFlags);
791  return E_UNKNOWN;
792 
793  }
794  }
795 
796 
797  if (!bCompatible)
798  {
799  return E_UNKNOWN;
800  }
801 
802  return E_SUCCESS;
803  }
SINT32 getNodeName(const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
Definition: CAUtil.cpp:707
SINT32 getDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
Definition: CAUtil.cpp:458
SINT32 getDOMElementAttribute(const DOMNode *const elem, const char *attrName, UINT8 *value, UINT32 *len)
Definition: CAUtil.cpp:780
#define MIX_VERSION_COMPATIBILITY
Definition: StdAfx.h:762
signed int SINT32
Definition: basetypedefs.h:132
unsigned int UINT32
Definition: basetypedefs.h:131
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
UINT16 flags
Definition: typedefs.hpp:1
UINT16 len
Definition: typedefs.hpp:0

References E_SUCCESS, E_UNKNOWN, flags, getDOMChildByName(), getDOMElementAttribute(), getNodeName(), len, MIX_VERSION, MIX_VERSION_COMPATIBILITY, NEW_CHANNEL_ENCRYPTION_COMPATIBILITY, NEW_FLOW_CONTROL_COMPATIBILITY, PAYMENT_COMPATIBILITY, CAMsg::printMsg(), and WITH_INTEGRITY_CHECK_COMPATIBILITY.

Referenced by CALastMix::processKeyExchange(), and CAMiddleMix::processKeyExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean()

virtual SINT32 CAMix::clean ( )
protectedpure virtual

Implemented in CAMiddleMix, CALastMix, and CAFirstMix.

Referenced by start().

Here is the caller graph for this function:

◆ getDownstreamControlChannelDispatcher()

CAControlChannelDispatcher* CAMix::getDownstreamControlChannelDispatcher ( ) const
inline

Definition at line 115 of file CAMix.hpp.

116  {
118  }

References m_pMuxInControlChannelDispatcher.

Referenced by CAReplayCtrlChannelMsgProc::CAReplayCtrlChannelMsgProc(), and CAReplayCtrlChannelMsgProc::~CAReplayCtrlChannelMsgProc().

Here is the caller graph for this function:

◆ getLastConnectionTime()

UINT32 CAMix::getLastConnectionTime ( )
inline

Definition at line 125 of file CAMix.hpp.

126  {
127  return m_lLastConnectionTime;
128  }

References m_lLastConnectionTime.

Referenced by CAInfoService::InfoLoop().

Here is the caller graph for this function:

◆ getMixCascadeInfo()

SINT32 CAMix::getMixCascadeInfo ( XERCES_CPP_NAMESPACE::DOMDocument *&  docMixCascadeInfo)
inline

Returns the Mix-Cascade info which should be send to the InfoService.

This is NOT a copy!

Parameters
docMixCascadeInfowhere the XML struct would be stored
Return values
E_SUCCESS

Definition at line 96 of file CAMix.hpp.

97  {
98  if (m_docMixCascadeInfo != NULL)
99  {
100  docMixCascadeInfo = m_docMixCascadeInfo;
101  return E_SUCCESS;
102  }
103  else
104  {
105  return E_UNKNOWN;
106  }
107  }

References E_SUCCESS, E_UNKNOWN, and m_docMixCascadeInfo.

Referenced by CAInfoService::getCascadeHeloXMLAsString(), and CAAccountingInstance::prepareCCRequest().

Here is the caller graph for this function:

◆ getType()

virtual tMixType CAMix::getType ( ) const
pure virtual

Implemented in CAMiddleMix, CALastMix, and CAFirstMix.

Referenced by CAReplayCtrlChannelMsgProc::initTimestampsMessageTemplate(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), and CAReplayCtrlChannelMsgProc::proccessGotTimestamp().

Here is the caller graph for this function:

◆ getUpstreamControlChannelDispatcher()

CAControlChannelDispatcher* CAMix::getUpstreamControlChannelDispatcher ( ) const
inline

Definition at line 120 of file CAMix.hpp.

121  {
123  }

References m_pMuxOutControlChannelDispatcher.

Referenced by CAReplayCtrlChannelMsgProc::CAReplayCtrlChannelMsgProc(), and CAReplayCtrlChannelMsgProc::~CAReplayCtrlChannelMsgProc().

Here is the caller graph for this function:

◆ init()

virtual SINT32 CAMix::init ( )
protectedpure virtual

Implemented in CAMiddleMix, CALastMix, and CAFirstMix.

Referenced by start().

Here is the caller graph for this function:

◆ initMixCascadeInfo()

SINT32 CAMix::initMixCascadeInfo ( DOMElement *  mixes)
protectedvirtual

This will initialize the XML Cascade Info struct XMLFirstMixToInfoService that is sent to the InfoService in CAInfoService::sendCascadeHelo()

Parameters
mixesthe <Mixes> element of the XML struct we received from the succeeding mix.
Return values
E_UNKNOWNif processing produces an error
E_SUCCESSotherwise

Reimplemented in CAMiddleMix, and CALastMix.

Definition at line 299 of file CAMix.cpp.

300  {
301  UINT32 count;
303  DOMElement* elemRoot=createDOMElement(m_docMixCascadeInfo,"MixCascade");
304 #ifdef LOG_DIALOG
305  setDOMElementAttribute(elemRoot,"study",(UINT8*)"true");
306 #endif
307  if(CALibProxytest::getOptions()->isFirstMix())
308  {
310  if(maxUsers > 0)
311  {
312  setDOMElementAttribute(elemRoot,"maxUsers", maxUsers);
313  }
314  setDOMElementAttribute(elemRoot, "maxOpenChannels", CHANNELS_PER_CLIENT);
315 
316 #ifdef MANIOQ
317  setDOMElementAttribute(elemRoot,"context", (UINT8*) "jondonym.business");
318 #else
319 
320 #ifdef PAYMENT
321  setDOMElementAttribute(elemRoot,"context", (UINT8*) "jondonym.premium");
322 #else
323  setDOMElementAttribute(elemRoot,"context", (UINT8*) "jondonym");
324 #endif
325 #endif
326  }
327 
328  UINT8 id[50];
329  UINT8* cascadeID=NULL;
331 
332  UINT8 name[255];
333  m_docMixCascadeInfo->appendChild(elemRoot);
334  DOMElement* elem = NULL;
335 
336  if(CALibProxytest::getOptions()->getCascadeName(name,255) == E_SUCCESS)
337  {
338  elem = createDOMElement(m_docMixCascadeInfo,"Name");
339  setDOMElementValue(elem,name);
340  elemRoot->appendChild(elem);
341  }
342  else
343  {
344  CAMsg::printMsg(LOG_ERR,"No cascade name given!\n");
345  }
346 
347  elem=createDOMElement(m_docMixCascadeInfo,"Network");
348  elemRoot->appendChild(elem);
349  DOMElement* elemListenerInterfaces=createDOMElement(m_docMixCascadeInfo,"ListenerInterfaces");
350  elem->appendChild(elemListenerInterfaces);
351 
352 
354  {
356  if(pListener->isHidden())
357  {
358  //do nothing
359  }
360  else if(pListener->getType()==RAW_TCP|| pListener->getType() == RAW_UDP)
361  {//Only TCP or UDP interfaces are meaningfull for external connections...
362  DOMElement* elemTmpLI=NULL;
363  pListener->toDOMElement(elemTmpLI,m_docMixCascadeInfo);
364  elemListenerInterfaces->appendChild(elemTmpLI);
365  }
366  delete pListener;
367  pListener = NULL;
368  }
369 
370  DOMNode* elemMixesDocCascade=createDOMElement(m_docMixCascadeInfo,"Mixes");
371  DOMElement* elemMix=NULL;
372  count=1;
373  if(CALibProxytest::getOptions()->isFirstMix())
374  {
375  addMixInfo(elemMixesDocCascade, false);
376  getDOMChildByName(elemMixesDocCascade, "Mix", elemMix, false);
377  // create signature
378  if (signXML(elemMix) != E_SUCCESS)
379  {
380  CAMsg::printMsg(LOG_DEBUG,"Could not sign KeyInfo sent to users...\n");
381  }
382  //if(m_pSignature->signXML(docMixInfo,m_pcertstoreOwnCerts)!=E_SUCCESS)
383  //m_pSignature, CALibProxytest::getOptions()->getOwnCertificate()
384  /*
385  elemMixesDocCascade.appendChild(elemThisMix);*/
386  }
387  elemRoot->appendChild(elemMixesDocCascade);
388 
389 // UINT8 cascadeId[255];
390 // UINT32 cascadeIdLen=255;
391 
392  DOMNode* node=mixes->getFirstChild();
393  while(node!=NULL)
394  {
395  if(node->getNodeType()==DOMNode::ELEMENT_NODE&&equals(node->getNodeName(),"Mix"))
396  {
397  elemMixesDocCascade->appendChild(m_docMixCascadeInfo->importNode(node,true));
398  count++;
399 // cascadeId = static_cast<const DOM_Element&>(node).getAttribute("id").transcode();
400  }
401  node=node->getNextSibling();
402  }
403 
404  if(CALibProxytest::getOptions()->isLastMix())
405  {
406  addMixInfo(elemMixesDocCascade, false);
407  ::getLastDOMChildByName(elemMixesDocCascade, "Mix", elemMix);
408  // create signature
409  if (signXML(elemMix) != E_SUCCESS)
410  {
411  CAMsg::printMsg(LOG_DEBUG,"Could not sign KeyInfo sent to users...\n");
412  }
413  cascadeID = id;
414  }
415  else if(CALibProxytest::getOptions()->isFirstMix())
416  {
417  cascadeID = id;
418  }
419 
420  if(cascadeID != NULL)
421  { setDOMElementAttribute(elemRoot,"id",cascadeID); }
422  setDOMElementAttribute(elemMixesDocCascade,"count",count);
423 
424  DOMNode* elemPayment=createDOMElement(m_docMixCascadeInfo,"Payment");
425  elemRoot->appendChild(elemPayment);
426 #ifdef PAYMENT
427  setDOMElementAttribute(elemPayment,"required",(UINT8*)"true");
428  setDOMElementAttribute(elemPayment,"version",(UINT8*)PAYMENT_VERSION);
429  setDOMElementAttribute(elemPayment,"prepaidInterval", CALibProxytest::getOptions()->getPrepaidInterval());
430  setDOMElementAttribute(elemPayment,"piid", CALibProxytest::getOptions()->getBI()->getID());
431 #else
432  setDOMElementAttribute(elemPayment,"required",(UINT8*)"false");
433 #endif
434  return E_SUCCESS;
435  }
SINT32 setDOMElementValue(DOMElement *pElem, SINT32 value)
Definition: CAUtil.cpp:939
bool equals(const XMLCh *const e1, const char *const e2)
Definition: CAUtil.cpp:645
XERCES_CPP_NAMESPACE::DOMDocument * createDOMDocument()
Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in...
Definition: CAUtil.cpp:1568
SINT32 getLastDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&a_child)
Definition: CAUtil.cpp:1719
#define PAYMENT_VERSION
Definition: StdAfx.h:274
#define CHANNELS_PER_CLIENT
Definition: StdAfx.h:195
UINT32 getListenerInterfaceCount()
SINT32 getMixId(UINT8 *id, UINT32 len)
UINT32 getMaxNrOfUsers()
CAListenerInterface * getListenerInterface(UINT32 nr)
SINT32 toDOMElement(DOMElement *&elem, XERCES_CPP_NAMESPACE::DOMDocument *ownerDoc) const
NetworkType getType() const
SINT32 signXML(DOMNode *a_element)
Definition: CAMix.cpp:806
SINT32 addMixInfo(DOMNode *a_element, bool a_bForceFirstNode)
Definition: CAMix.cpp:437
@ RAW_TCP
Definition: typedefs.hpp:30
@ RAW_UDP
Definition: typedefs.hpp:30

References addMixInfo(), CHANNELS_PER_CLIENT, createDOMDocument(), createDOMElement(), E_SUCCESS, equals(), getDOMChildByName(), getLastDOMChildByName(), CACmdLnOptions::getListenerInterface(), CACmdLnOptions::getListenerInterfaceCount(), CACmdLnOptions::getMaxNrOfUsers(), CACmdLnOptions::getMixId(), CALibProxytest::getOptions(), CAListenerInterface::getType(), CAListenerInterface::isHidden(), m_docMixCascadeInfo, PAYMENT_VERSION, CAMsg::printMsg(), RAW_TCP, RAW_UDP, setDOMElementAttribute(), setDOMElementValue(), signXML(), and CAListenerInterface::toDOMElement().

Referenced by CALastMix::initMixCascadeInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initOnce()

SINT32 CAMix::initOnce ( )
protectedvirtual

Reimplemented in CAMiddleMix, CALastMix, and CAFirstMix.

Definition at line 78 of file CAMix.cpp.

79  {
80 #ifdef DATA_RETENTION_LOG
81  m_pDataRetentionLog=new CADataRetentionLog();
82  CAASymCipher* pKey=NULL;
83  CALibProxytest::getOptions()->getDataRetentionPublicEncryptionKey(&pKey);
84  if(m_pDataRetentionLog->setPublicEncryptionKey(pKey)!=E_SUCCESS)
85  { return E_UNKNOWN; }
86  UINT8 strDir[4096];
87  strDir[0]=0;
88  if(CALibProxytest::getOptions()->getDataRetentionLogDir(strDir,4096)!=E_SUCCESS ||
89  m_pDataRetentionLog->setLogDir(strDir)!=E_SUCCESS)
90  {
91  CAMsg::printMsg(LOG_ERR,"Data Retention Error: Could not set log dir to %s!\n",strDir);
92  return E_UNKNOWN;
93  }
94  else
95  {
96  CAMsg::printMsg(LOG_INFO,"Data Retention: Set log dir to: %s\n",strDir);
97  CAMsg::printMsg(LOG_INFO,"Data Retention: tQueueEntry size is: %u\n",sizeof(tQueueEntry));
98  }
99 
100 #endif
101  return E_SUCCESS;
102  }
Definition: typedefs.hpp:169

References E_SUCCESS, E_UNKNOWN, CALibProxytest::getOptions(), and CAMsg::printMsg().

Referenced by CAFirstMix::initOnce(), CALastMix::initOnce(), and start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isConnected()

bool CAMix::isConnected ( )
inline

Definition at line 130 of file CAMix.hpp.

131  {
132  return m_bConnected;
133  }

References m_bConnected.

Referenced by CAInfoService::InfoLoop(), CAInfoService::sendCascadeHelo(), and CAInfoService::sendStatus().

Here is the caller graph for this function:

◆ isShutDown()

virtual bool CAMix::isShutDown ( )
inlinevirtual

Definition at line 77 of file CAMix.hpp.

78  {
79  return m_bShutDown;
80  }

References m_bShutDown.

Referenced by my_terminate().

Here is the caller graph for this function:

◆ loop()

virtual SINT32 CAMix::loop ( )
protectedpure virtual

Implemented in CALastMix, CAFirstMix, CALastMixB, CAFirstMixB, CALastMixA, CAFirstMixA, and CAMiddleMix.

Referenced by start().

Here is the caller graph for this function:

◆ needAutoConfig()

bool CAMix::needAutoConfig ( )
private

This method checks if target interfaces (network adress and port of next mix) have been specified in the config file.

A return value of true means that necessary information to bring the cascade online is missing and must be downloaded from the InfoService (if available).

Return values
falseif the target interfaces are configured one way or another
trueif config file contains no target interface info and InfoService is unavailable

Definition at line 263 of file CAMix.cpp.

264  {
265  bool ret = false;
266 
267  if(!CALibProxytest::getOptions()->isLastMix())
268  {
269  ret = true;
270 
271  // look for usable target interfaces
273  {
274  CATargetInterface oNextMix;
276  if(oNextMix.getTargetType()==TARGET_MIX)
277  {
278  ret = false;
279  }
280  oNextMix.cleanAddr();
281  }
282 
283  if(!CALibProxytest::getOptions()->hasNextMixTestCertificate())
284  { ret = true; }
285  }
286 
287  if(!CALibProxytest::getOptions()->isFirstMix() && !CALibProxytest::getOptions()->hasPrevMixTestCertificate())
288  { ret = true; }
289 
290  return ret;
291  }
UINT32 getTargetInterfaceCount()
SINT32 getTargetInterface(CATargetInterface &oTargetInterface, UINT32 nr)
Fills a TargetInterface struct with the values which belongs to the target interface nr.
TargetType getTargetType() const
@ TARGET_MIX
Definition: typedefs.hpp:32

References CATargetInterface::cleanAddr(), CALibProxytest::getOptions(), CACmdLnOptions::getTargetInterface(), CACmdLnOptions::getTargetInterfaceCount(), CATargetInterface::getTargetType(), and TARGET_MIX.

Referenced by start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processKeyExchange()

virtual SINT32 CAMix::processKeyExchange ( )
protectedpure virtual

Implemented in CAMiddleMix, CALastMix, and CAFirstMix.

◆ reconfigure()

virtual SINT32 CAMix::reconfigure ( )
inlinevirtual

Reimplemented in CALastMix, and CAFirstMix.

Definition at line 65 of file CAMix.hpp.

66  {
67  return E_SUCCESS;
68  }

References E_SUCCESS.

◆ shutDown()

virtual void CAMix::shutDown ( )
inlinevirtual

Reimplemented in CAFirstMixA.

Definition at line 71 of file CAMix.hpp.

72  {
73  m_bShutDown = true;
74  m_bLoop=false;
75  }

References m_bLoop, and m_bShutDown.

Referenced by my_terminate().

Here is the caller graph for this function:

◆ signXML()

SINT32 CAMix::signXML ( DOMNode *  a_element)
protected

Definition at line 806 of file CAMix.cpp.

807  {
808  return m_pMultiSignature->signXML(a_element, true);
809  /*CACertStore* tmpCertStore=new CACertStore();
810 
811  CACertificate* ownCert=CALibProxytest::getOptions()->getOwnCertificate();
812  if(ownCert==NULL)
813  {
814  CAMsg::printMsg(LOG_DEBUG,"Own Test Cert is NULL!\n");
815  }
816 
817  // Operator Certificates
818  CACertificate* opCert = CALibProxytest::getOptions()->getOpCertificate();
819  if(opCert==NULL)
820  {
821  CAMsg::printMsg(LOG_DEBUG,"Op Test Cert is NULL!\n");
822  }
823  else
824  {
825  // Own Mix Certificates first, then Operator Certificates
826  tmpCertStore->add(opCert);
827  }
828  tmpCertStore->add(ownCert);
829 
830  if(m_pSignature->signXML(a_element, tmpCertStore)!=E_SUCCESS)
831  {
832  return E_UNKNOWN;
833  }
834 
835  CASignature* test = new CASignature();
836  test->setVerifyKey(ownCert);
837 
838  if(test->verifyXML(a_element) != E_SUCCESS)
839  {
840  CAMsg::printMsg(LOG_DEBUG, "Error verifying own Signature!!\n");
841  m_pSignature->signXML(a_element, tmpCertStore);
842  }
843  else
844  {
845  CAMsg::printMsg(LOG_DEBUG, "Own Signature looks ok!\n");
846  }
847 
848 
849  delete ownCert;
850  ownCert = NULL;
851 
852  delete opCert;
853  opCert = NULL;
854 
855  delete tmpCertStore;
856  tmpCertStore = NULL;
857 
858  return E_SUCCESS;*/
859  }
SINT32 signXML(DOMNode *a_node, bool appendCerts)

References m_pMultiSignature, and CAMultiSignature::signXML().

Referenced by initMixCascadeInfo(), CALastMix::processKeyExchange(), and CAMiddleMix::processKeyExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

SINT32 CAMix::start ( )

Definition at line 104 of file CAMix.cpp.

105  {
106  SINT32 initStatus;
107  m_bConnected = false;
109  m_bLoop=true;
110 
111  if(initOnce()!=E_SUCCESS)
112  { return E_UNKNOWN; }
113  if(m_pMultiSignature != NULL && CALibProxytest::getOptions()->isInfoServiceEnabled())
114  {
115  CAMsg::printMsg(LOG_DEBUG, "CAMix start: creating InfoService object\n");
116  m_pInfoService=new CAInfoService(this);
117 
118  //UINT32 opCertLength;
119  //CACertificate* opCert = CALibProxytest::getOptions()->getOpCertificate();
120  //CACertificate* pOwnCert=CALibProxytest::getOptions()->getOwnCertificate();
122  //delete pOwnCert;
123  //pOwnCert = NULL;
124  UINT64 currentMillis;
125  if (getcurrentTimeMillis(currentMillis) != E_SUCCESS)
126  {
127  currentMillis = 0;
128  }
129  m_pInfoService->setSerial(currentMillis);
130 
131  //delete opCert;
132  //opCert = NULL;
133 
134  bool allowReconf = CALibProxytest::getOptions()->acceptReconfiguration();
135  bool needReconf = needAutoConfig();
136 
137  m_pInfoService->setConfiguring(allowReconf && needReconf);
138  CAMsg::printMsg(LOG_DEBUG, "CAMix start: starting InfoService\n");
140  }
141  else
142  {
143  m_pInfoService = NULL;
144  }
145  bool allowReconf = CALibProxytest::getOptions()->acceptReconfiguration();
146 //#ifdef DYNAMIC_MIX
147  /* LERNGRUPPE: We might want to break out of this loop if the mix-type changes */
148  while(m_bLoop)
149 //#else
150 // for(;;)
151 //#endif
152  {
153  if (m_pInfoService != NULL)
154  { m_pInfoService->setConfiguring(allowReconf && needAutoConfig()); }
155  while(allowReconf && (needAutoConfig() || m_bReconfiguring))
156  {
157  CAMsg::printMsg(LOG_DEBUG, "Not configured -> sleeping\n");
158  sSleep(20);
159  }
160 //#ifdef DYNAMIC_MIX
161  // if we change the mix type, we must not enter init!
162  if(!m_bLoop) { goto SKIP; }
163 //#endif
164  CAMsg::printMsg(LOG_DEBUG, "CAMix main: before init()\n");
165  initStatus = init();
166  if(initStatus == E_SUCCESS)
167  {
168  m_lLastConnectionTime = time(NULL);
169  m_bConnected = true;
170  CAMsg::printMsg(LOG_DEBUG, "CAMix main: init() returned success\n");
171  if(m_pInfoService != NULL)
172  {
174  if( ! m_pInfoService->isRunning())
175  {
177  }
179  }
180 
181  CAMsg::printMsg(LOG_INFO, "The mix is now on-line.\n");
182 #ifdef DYNAMIC_MIX
183  m_bReconfiguring = false;
184  m_bCascadeEstablished = true;
185  m_bReconfigured = false;
186  if(CALibProxytest::getOptions()->isFirstMix() && CALibProxytest::getOptions()->isDynamic())
188 #endif
190  loop();
192 #ifdef DYNAMIC_MIX
193  m_bCascadeEstablished = false;
195  if(!m_bReconfiguring)
196  { m_pInfoService->dynamicCascadeConfiguration(); }
197 #endif
198  CAMsg::printMsg(LOG_DEBUG, "CAMix main: loop() returned, maybe connection lost.\n");
199  }
200  else if (initStatus == E_SHUTDOWN)
201  {
202  CAMsg::printMsg(LOG_DEBUG, "Mix has been stopped. Waiting for shutdown...\n");
203  //break;
204  }
205  else
206  {
207  CAMsg::printMsg(LOG_DEBUG, "init() failed, maybe no connection.\n");
208  }
209 //#ifdef DYNAMIC_MIX
210 SKIP:
211 //#endif
212  if(m_pInfoService != NULL)
213  {
214 //#ifndef DYNAMIC_MIX
215 // if(CALibProxytest::getOptions()->acceptReconfiguration())
216 //#else
217  // Only keep the InfoService alive if the Mix-Type doesn't change
218  if(CALibProxytest::getOptions()->acceptReconfiguration() && m_bLoop)
219 //#endif
221  /*else
222  {
223  CAMsg::printMsg(LOG_DEBUG, "CAMix main: stopping InfoService\n");
224  m_pInfoService->stop();
225  }*/
226  // maybe Cascade information (e.g. certificate validity) will change on next connection
227  UINT64 currentMillis;
228  if (getcurrentTimeMillis(currentMillis) != E_SUCCESS)
229  {
230  currentMillis = 0;
231  }
232  m_pInfoService->setSerial(currentMillis);
233  }
234  m_bConnected = false;
236  CAMsg::printMsg(LOG_DEBUG, "CAMix main: before clean()\n");
237  clean();
238  CAMsg::printMsg(LOG_DEBUG, "CAMix main: after clean()\n");
239 //#ifdef DYNAMIC_MIX
240  if(m_bLoop)
241 //#endif
242  sSleep(10);
243  }// Big loop....
244  if(m_pInfoService != NULL)
245  {
246  m_pInfoService->stop();
247  delete m_pInfoService;
248  m_pInfoService = NULL;
249  }
250  m_pInfoService=NULL;
251  return E_SUCCESS;
252  }
#define MONITORING_FIRE_SYS_EVENT(e_type)
SINT32 getcurrentTimeMillis(UINT64 &u64Time)
Gets the current Systemtime in milli seconds.
Definition: CAUtil.cpp:252
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
Definition: CAUtil.cpp:425
SINT32 setMultiSignature(CAMultiSignature *pMultiSignature)
void setConfiguring(bool a_configuring)
SINT32 sendCascadeHelo()
void setSerial(UINT64 a_serial)
virtual SINT32 loop()=0
virtual SINT32 clean()=0
bool needAutoConfig()
This method checks if target interfaces (network adress and port of next mix) have been specified in ...
Definition: CAMix.cpp:263
virtual SINT32 initOnce()
Definition: CAMix.cpp:78
virtual SINT32 init()=0
#define E_SHUTDOWN
Definition: errorcodes.hpp:4
@ ev_sys_enterMainLoop
@ ev_sys_leavingMainLoop

References CACmdLnOptions::acceptReconfiguration(), clean(), E_SHUTDOWN, E_SUCCESS, E_UNKNOWN, ev_sys_enterMainLoop, ev_sys_leavingMainLoop, getcurrentTimeMillis(), CALibProxytest::getOptions(), init(), initOnce(), CAInfoService::isRunning(), loop(), m_bConnected, m_bLoop, m_bReconfiguring, m_lLastConnectionTime, m_pInfoService, m_pMultiSignature, MONITORING_FIRE_SYS_EVENT, needAutoConfig(), CAMsg::printMsg(), CAInfoService::sendCascadeHelo(), CAInfoService::setConfiguring(), CAInfoService::setMultiSignature(), CAInfoService::setSerial(), CAInfoService::signal(), sSleep(), CAInfoService::start(), and CAInfoService::stop().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_acceptReconfiguration

bool CAMix::m_acceptReconfiguration
protected

Definition at line 189 of file CAMix.hpp.

Referenced by acceptsReconfiguration(), and CAMix().

◆ m_bConnected

volatile bool CAMix::m_bConnected
protected

Definition at line 190 of file CAMix.hpp.

Referenced by CAMix(), isConnected(), and start().

◆ m_bLoop

volatile bool CAMix::m_bLoop
protected

Definition at line 135 of file CAMix.hpp.

Referenced by CAMix(), shutDown(), CAFirstMixA::shutDown(), and start().

◆ m_bReconfiguring

bool CAMix::m_bReconfiguring
protected

Definition at line 143 of file CAMix.hpp.

Referenced by CAMix(), and start().

◆ m_bShutDown

volatile bool CAMix::m_bShutDown
protected

Definition at line 144 of file CAMix.hpp.

Referenced by CAMix(), CAMiddleMix::clean(), isShutDown(), and shutDown().

◆ m_docMixCascadeInfo

XERCES_CPP_NAMESPACE::DOMDocument* CAMix::m_docMixCascadeInfo
protected

◆ m_lLastConnectionTime

volatile UINT32 CAMix::m_lLastConnectionTime
protected

Definition at line 191 of file CAMix.hpp.

Referenced by CAMix(), getLastConnectionTime(), and start().

◆ m_pInfoService

CAInfoService* CAMix::m_pInfoService
protected

◆ m_pMultiSignature

CAMultiSignature* CAMix::m_pMultiSignature
protected

◆ m_pMuxInControlChannelDispatcher

CAControlChannelDispatcher* CAMix::m_pMuxInControlChannelDispatcher
protected

◆ m_pMuxOutControlChannelDispatcher

CAControlChannelDispatcher* CAMix::m_pMuxOutControlChannelDispatcher
protected

◆ m_u32KeepAliveRecvInterval

UINT32 CAMix::m_u32KeepAliveRecvInterval
protected

◆ m_u32KeepAliveSendInterval

UINT32 CAMix::m_u32KeepAliveSendInterval
protected

◆ TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT

const UINT32 CAMix::TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT = 60000
static

Definition at line 59 of file CAMix.hpp.

Referenced by CALastMix::processKeyExchange(), and CAMiddleMix::processKeyExchange().


The documentation for this class was generated from the following files: