29 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX || defined INCLUDE_LAST_MIX
58 m_bCascadeEstablished =
false;
59 m_bReconfigured =
false;
61 #ifdef DATA_RETENTION_LOG
62 m_pDataRetentionLog=NULL;
68 #ifdef DATA_RETENTION_LOG
69 if(m_pDataRetentionLog!=NULL)
71 delete m_pDataRetentionLog;
72 m_pDataRetentionLog=NULL;
80 #ifdef DATA_RETENTION_LOG
84 if(m_pDataRetentionLog->setPublicEncryptionKey(pKey)!=
E_SUCCESS)
89 m_pDataRetentionLog->setLogDir(strDir)!=
E_SUCCESS)
91 CAMsg::printMsg(LOG_ERR,
"Data Retention Error: Could not set log dir to %s!\n",strDir);
96 CAMsg::printMsg(LOG_INFO,
"Data Retention: Set log dir to: %s\n",strDir);
115 CAMsg::printMsg(LOG_DEBUG,
"CAMix start: creating InfoService object\n");
184 m_bCascadeEstablished =
true;
185 m_bReconfigured =
false;
193 m_bCascadeEstablished =
false;
198 CAMsg::printMsg(LOG_DEBUG,
"CAMix main: loop() returned, maybe connection lost.\n");
202 CAMsg::printMsg(LOG_DEBUG,
"Mix has been stopped. Waiting for shutdown...\n");
329 UINT8* cascadeID=NULL;
334 DOMElement* elem = NULL;
340 elemRoot->appendChild(elem);
348 elemRoot->appendChild(elem);
350 elem->appendChild(elemListenerInterfaces);
362 DOMElement* elemTmpLI=NULL;
364 elemListenerInterfaces->appendChild(elemTmpLI);
371 DOMElement* elemMix=NULL;
380 CAMsg::printMsg(LOG_DEBUG,
"Could not sign KeyInfo sent to users...\n");
387 elemRoot->appendChild(elemMixesDocCascade);
392 DOMNode* node=mixes->getFirstChild();
395 if(node->getNodeType()==DOMNode::ELEMENT_NODE&&
equals(node->getNodeName(),
"Mix"))
401 node=node->getNextSibling();
411 CAMsg::printMsg(LOG_DEBUG,
"Could not sign KeyInfo sent to users...\n");
420 if(cascadeID != NULL)
425 elemRoot->appendChild(elemPayment);
440 XERCES_CPP_NAMESPACE::DOMDocument* docMixInfo=NULL;
445 DOMNode* nodeMixInfo = a_element->getOwnerDocument()->importNode(docMixInfo->getDocumentElement(),
true);
446 if (a_bForceFirstNode && a_element->hasChildNodes())
448 a_element->insertBefore(nodeMixInfo, a_element->getFirstChild());
452 a_element->appendChild(nodeMixInfo);
458 DOMNode *CAMix::appendTermsAndConditionsExtension(XERCES_CPP_NAMESPACE::DOMDocument *ownerDoc,DOMElement *root)
462 if( (root == NULL) || (ownerDoc == NULL) )
467 DOMElement *elemTnCExtension = NULL, *elemExtensions = NULL,
468 *elemTemplates = NULL;
473 if(elemExtensions == NULL)
476 root->appendChild(elemExtensions);
483 if(elemTnCExtension == NULL)
486 elemExtensions->appendChild(elemTnCExtension);
492 if(nrOfTemplates > 0)
494 UINT32 nrOfSentTemplates = 0;
495 UINT8 **sentTemplatesRefIds = NULL;
497 if(elemTemplates == NULL)
500 elemTnCExtension->appendChild(elemTemplates);
505 nrOfSentTemplates = nl->getLength();
506 if(nrOfSentTemplates > 0)
508 sentTemplatesRefIds =
new UINT8*[nrOfSentTemplates];
509 for (
UINT32 i = 0; i < nrOfSentTemplates; i++)
517 UINT8 *currentTemplateRefId = NULL;
518 bool duplicate =
false;
519 for(
UINT32 i = 0; i < nrOfTemplates; i++)
521 currentTemplateRefId =
524 if(currentTemplateRefId != NULL)
526 for(
UINT32 j=0; j < nrOfSentTemplates; j++)
528 if(strncmp((
char *)currentTemplateRefId, (
char *)sentTemplatesRefIds[j],
TEMPLATE_REFID_MAXLEN) == 0)
537 elemTemplates->appendChild(ownerDoc->importNode(
538 allTemplates[i]->getDocumentElement(),
true));
543 CAMsg::printMsg(LOG_DEBUG,
"template '%s' already sent.\n", currentTemplateRefId);
545 delete [] currentTemplateRefId;
546 currentTemplateRefId = NULL;
550 for(
UINT32 i = 0; i < nrOfSentTemplates; i++)
552 delete [] sentTemplatesRefIds[i];
553 sentTemplatesRefIds[i] = NULL;
555 delete [] sentTemplatesRefIds;
556 sentTemplatesRefIds = NULL;
562 memset(tmpOpSKIBuff, 0, tmpOpSKILen);
567 for (XMLSize_t i = 0; i < tncDefEntryList->getLength(); i++)
572 elemTnCExtension->appendChild(elemTnCs);
573 return elemTnCExtension;
581 DOMNode *CAMix::termsAndConditionsInfoNode(XERCES_CPP_NAMESPACE::DOMDocument *ownerDoc)
588 memset(tmpBuff, 0, tmpLen);
591 DOMElement *iterator = NULL;
592 DOMElement *currentInfoNode = NULL;
593 bool defaultLangDefined =
false;
594 for (XMLSize_t i = 0; i < list->getLength(); i++)
596 iterator = (DOMElement *) list->item(i);
602 if(defaultLangDefined)
606 defaultLangDefined =
false;
613 elemTnCInfos->appendChild(currentInfoNode);
636 DOMElement* elemCompatibility=
createDOMElement(a_parent->getOwnerDocument(),
"Compatibility");
638 a_parent->appendChild(elemCompatibility);
640 DOMElement* elemFlags=NULL;
641 DOMElement* elemFlag=NULL;
644 elemCompatibility->appendChild(elemFlags);
650 elemFlags->appendChild(elemFlag);
655 elemFlags->appendChild(elemFlag);
659 elemFlags->appendChild(elemFlag);
661 #ifdef WITH_INTEGRITY_CHECK
664 elemFlags->appendChild(elemFlag);
673 DOMElement* elemCompatibility=NULL;
674 DOMElement* elemFlags=NULL;
675 DOMElement* elemDummy=NULL;
676 UINT8 strAllFlags[500];
678 UINT8 strNodeName[50];
680 UINT8 strVersion[50];
685 UINT32 iLogLevel = LOG_INFO;
686 bool bCompatible =
true;
687 bool bCompatibleFlags =
true;
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);
700 strComment = (
UINT8*)
" We have the same version.";
702 else if (iCompare < 0)
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;
710 if (strncmp (
"00.08.71", (
char*)strVersion,
len) > 0)
712 strComment = (
UINT8*)
" This version is NOT COMPATIBLE with our version (" MIX_VERSION ")! The mixes will not work together in a cascade.";
714 iLogLevel = LOG_CRIT;
718 strComment = (
UINT8*)
" We have a newer version (" MIX_VERSION "), but both are known to work fine together.";
722 CAMsg::printMsg(iLogLevel,
"The software version of the %s mix is %s.%s\n", a_mixPosition, strVersion, strComment);
733 #ifdef WITH_INTEGRITY_CHECK
739 DOMNodeList*
flags = elemFlags->getChildNodes();
740 if (
flags->getLength() != iCountFlags)
742 bCompatibleFlags =
false;
750 bCompatibleFlags =
false;
755 bCompatibleFlags =
false;
759 bCompatibleFlags =
false;
761 #ifdef WITH_INTEGRITY_CHECK
764 bCompatibleFlags =
false;
768 if (!bCompatibleFlags)
778 lenAllFlags += strlen((
char*)strNodeName) + 1;
779 if (lenAllFlags > 500)
783 strcat((
char*)strAllFlags,
" ");
784 strcat((
char*)strAllFlags, (
char*)strNodeName);
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);
872 SINT32 CAMix::dynaReconfigure(
bool a_bChangeMixType)
878 m_bReconfigured =
true;
881 if(m_bCascadeEstablished)
889 for(
UINT32 i=1; i<=interfaces; i++)
900 CAMsg::printMsg(LOG_CRIT,
"Reason: no useable (non virtual) interface found!\n");
#define OPTIONS_ATTRIBUTE_TNC_ID
#define OPTIONS_NODE_TNCS_TEMPLATES
#define OPTIONS_ATTRIBUTE_TNC_DEFAULT_LANG
#define OPTIONS_ATTRIBUTE_TNC_DATE
#define OPTIONS_ATTRIBUTE_TNC_LOCALE
#define OPTIONS_ATTRIBUTE_TNC_DEFAULT_LANG_DEFINED
#define OPTIONS_ATTRIBUTE_TNC_TEMPLATE_REFID
#define OPTIONS_NODE_TNCS_TRANSLATION
#define KEYINFO_NODE_TNC_EXTENSION
#define KEYINFO_NODE_EXTENSIONS
#define KEYINFO_NODE_TNC_INFO
#define KEYINFO_NODE_TNC_INFOS
#define MONITORING_FIRE_SYS_EVENT(e_type)
SINT32 getNodeName(const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
SINT32 setDOMElementAttribute(DOMNode *pElem, const char *attrName, const char *value)
SINT32 getcurrentTimeMillis(UINT64 &u64Time)
Gets the current Systemtime in milli seconds.
SINT32 setDOMElementValue(DOMElement *pElem, SINT32 value)
bool equals(const XMLCh *const e1, const char *const e2)
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
UINT8 * getTermsAndConditionsTemplateRefId(DOMNode *tcTemplateRoot)
DOMNodeList * getElementsByTagName(DOMElement *pElem, const char *const name)
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 getLastDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&a_child)
#define TEMPLATE_REFID_MAXLEN
#define WITH_INTEGRITY_CHECK_COMPATIBILITY
#define NEW_FLOW_CONTROL_COMPATIBILITY
#define NEW_CHANNEL_ENCRYPTION_COMPATIBILITY
#define PAYMENT_COMPATIBILITY
#define CHANNELS_PER_CLIENT
#define MIX_VERSION_COMPATIBILITY
UINT32 getListenerInterfaceCount()
SINT32 getMixId(UINT8 *id, UINT32 len)
UINT32 getNumberOfTermsAndConditionsTemplates()
Get the XML describing the Mix.
bool acceptReconfiguration()
SINT32 getOperatorSubjectKeyIdentifier(UINT8 *buffer, UINT32 *length)
Returns a COPY of the public test certifcate for that mix.
CAListenerInterface * getListenerInterface(UINT32 nr)
XERCES_CPP_NAMESPACE::DOMDocument ** getAllTermsAndConditionsTemplates()
UINT32 getTargetInterfaceCount()
SINT32 getTargetInterface(CATargetInterface &oTargetInterface, UINT32 nr)
Fills a TargetInterface struct with the values which belongs to the target interface nr.
SINT32 setMultiSignature(CAMultiSignature *pMultiSignature)
void setConfiguring(bool a_configuring)
void setSerial(UINT64 a_serial)
static CACmdLnOptions * getOptions()
CASocketAddr * getAddr() const
SINT32 toDOMElement(DOMElement *&elem, XERCES_CPP_NAMESPACE::DOMDocument *ownerDoc) const
NetworkType getType() const
volatile bool m_bConnected
SINT32 appendCompatibilityInfo(DOMNode *a_parent)
SINT32 checkCompatibility(DOMNode *a_parent, const char *a_mixPosition)
CAInfoService * m_pInfoService
SINT32 signXML(DOMNode *a_element)
static const UINT32 TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT
volatile UINT32 m_lLastConnectionTime
SINT32 addMixInfo(DOMNode *a_element, bool a_bForceFirstNode)
CAControlChannelDispatcher * m_pMuxOutControlChannelDispatcher
CAControlChannelDispatcher * m_pMuxInControlChannelDispatcher
UINT32 m_u32KeepAliveRecvInterval
CAMultiSignature * m_pMultiSignature
virtual SINT32 initMixCascadeInfo(DOMElement *elemMixes)
This will initialize the XML Cascade Info struct XMLFirstMixToInfoService that is sent to the InfoSer...
bool needAutoConfig()
This method checks if target interfaces (network adress and port of next mix) have been specified in ...
virtual SINT32 initOnce()
volatile bool m_bShutDown
XERCES_CPP_NAMESPACE::DOMDocument * m_docMixCascadeInfo
UINT32 m_u32KeepAliveSendInterval
bool m_acceptReconfiguration
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
SINT32 signXML(DOMNode *a_node, bool appendCerts)
This is an abstract class for representing a socket address used in CASocket, CADatagramSocket and CA...
virtual SINT32 connect(const CASocketAddr &psa)
TargetType getTargetType() const