Mixe for Privacy and Anonymity in the Internet
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CAInfoService Class Reference

#include <CAInfoService.hpp>

Collaboration diagram for CAInfoService:

Classes

struct  InfoServiceHeloMsg
 

Public Member Functions

 CAInfoService ()
 
 CAInfoService (CAMix *pMix)
 
 ~CAInfoService ()
 
SINT32 sendMixHelo (SINT32 requestCommand=-1, const UINT8 *param=NULL)
 
SINT32 sendStatus (bool bIncludeCerts)
 
bool isRunning ()
 
void setConfiguring (bool a_configuring)
 
bool isConfiguring ()
 
void setSerial (UINT64 a_serial)
 
SINT32 start ()
 
SINT32 stop ()
 
SINT32 signal ()
 
SINT32 setMultiSignature (CAMultiSignature *pMultiSignature)
 
SINT32 sendCascadeHelo ()
 
SINT32 getPaymentInstance (const UINT8 *a_pstrPIID, CAXMLBI **pXMLBI)
 

Static Public Attributes

static const UINT64 MINUTE = 60
 
static const UINT64 SEND_LOOP_SLEEP = 60
 
static const UINT64 SEND_CASCADE_INFO_WAIT = MINUTE * 10
 
static const UINT64 SEND_MIX_INFO_WAIT = MINUTE * 10
 
static const UINT64 SEND_STATUS_INFO_WAIT = MINUTE
 
static const UINT32 SEND_INFO_TIMEOUT_MS = 3000
 
static const UINT32 REPEAT_ON_STATUS_SENT_ERROR = 3
 

Private Member Functions

SINT32 getPaymentInstance (const UINT8 *a_pstrPIID, CAXMLBI **pXMLBI, CASocketAddrINet *a_socketAddress)
 Gets a payment instance from the InfoService. More...
 
UINT8getCascadeHeloXMLAsString (UINT32 &len)
 
SINT32 sendCascadeHelo (const UINT8 *xml, UINT32 len, const CASocketAddrINet *a_socketAddress) const
 POSTs the HELO message for a whole cascade to the InfoService. More...
 
UINT8 ** getOperatorTnCsAsStrings (UINT32 **lengths, UINT32 *nrOfTnCs)
 POSTs the MIXINFO message for a mix to the InfoService. More...
 
SINT32 sendOperatorTnCData ()
 
SINT32 handleConfigEvent (XERCES_CPP_NAMESPACE::DOMDocument *doc) const
 
SINT32 sendMixHelo (const UINT8 *strMixHeloXML, UINT32 len, SINT32 requestCommand, const UINT8 *param, const CASocketAddrINet *a_socketAddress)
 POSTs the HELO message for a mix to the InfoService. More...
 
UINT8getMixHeloXMLAsString (UINT32 &len)
 
UINT8xmlDocToStringWithSignature (DOMNode *a_node, UINT32 &a_len, bool bIncludeCerts)
 
SINT32 sendHelo (UINT8 *a_strXML, UINT32 a_len, THREAD_RETURN(*a_thread)(void *), UINT8 *a_strThreadName, SINT32 requestCommand, const UINT8 *param=NULL)
 
SINT32 getLevel (SINT32 *puser, SINT32 *prisk, SINT32 *ptraffic)
 
SINT32 getMixedPackets (UINT64 &ppackets)
 
UINT8getStatusXMLAsString (bool bIncludeCerts, UINT32 &len)
 
SINT32 sendStatus (const UINT8 *strStatusXML, UINT32 len, const CASocketAddrINet *a_socketAddress) const
 POSTs mix status to the InfoService. More...
 

Static Private Member Functions

static THREAD_RETURN TCascadeHelo (void *p)
 
static THREAD_RETURN TCascadeStatus (void *p)
 
static THREAD_RETURN TMixHelo (void *p)
 
static THREAD_RETURN InfoLoop (void *p)
 

Private Attributes

volatile bool m_bRun
 
UINT64 m_serial
 
bool m_bConfiguring
 
CAMixm_pMix
 
CAConditionVariablem_pLoopCV
 
CAMultiSignaturem_pMultiSignature
 
UINT64 m_lastMixedPackets
 
UINT32 m_minuts
 
SINT32 m_expectedMixRelPos
 
CAThreadm_pthreadRunLoop
 

Detailed Description

Definition at line 61 of file CAInfoService.hpp.

Constructor & Destructor Documentation

◆ CAInfoService() [1/2]

CAInfoService::CAInfoService ( )

Definition at line 398 of file CAInfoService.cpp.

399 {
400  m_pMix = NULL;
401  m_bRun = false;
402  //m_pSignature=NULL;
403  m_pMultiSignature = NULL;
404  m_minuts = 0;
405  m_lastMixedPackets = 0;
408  m_pthreadRunLoop = new CAThread((UINT8*)"InfoServiceThread");
409 #ifdef DYNAMIC_MIX
410  m_bReconfig = false;
411 #endif
412 }
unsigned char UINT8
Definition: basetypedefs.h:135
CAThread * m_pthreadRunLoop
CAConditionVariable * m_pLoopCV
CAMultiSignature * m_pMultiSignature
SINT32 m_expectedMixRelPos
volatile bool m_bRun
UINT64 m_lastMixedPackets

References m_bRun, m_expectedMixRelPos, m_lastMixedPackets, m_minuts, m_pLoopCV, m_pMix, m_pMultiSignature, and m_pthreadRunLoop.

◆ CAInfoService() [2/2]

CAInfoService::CAInfoService ( CAMix pMix)

Definition at line 413 of file CAInfoService.cpp.

414 {
415  m_pMix = NULL;
416  m_bRun = false;
417  //m_pSignature=NULL;
418  m_pMultiSignature = NULL;
419  m_minuts = 0;
420  m_lastMixedPackets = 0;
423  m_pthreadRunLoop = new CAThread((UINT8*)"InfoServiceThread");
424  m_pMix = pMix;
425 #ifdef DYNAMIC_MIX
426  m_bReconfig = false;
427 #endif
428 }
CAMix * pMix
Definition: proxytest.cpp:75

References m_bRun, m_expectedMixRelPos, m_lastMixedPackets, m_minuts, m_pLoopCV, m_pMix, m_pMultiSignature, m_pthreadRunLoop, and pMix.

◆ ~CAInfoService()

CAInfoService::~CAInfoService ( )

Definition at line 430 of file CAInfoService.cpp.

431 {
432  stop();
433  delete m_pLoopCV;
434  m_pLoopCV = NULL;
435  delete m_pthreadRunLoop;
436  m_pthreadRunLoop = NULL;
437 }

References m_pLoopCV, m_pthreadRunLoop, and stop().

Here is the call graph for this function:

Member Function Documentation

◆ getCascadeHeloXMLAsString()

UINT8 * CAInfoService::getCascadeHeloXMLAsString ( UINT32 len)
private

Definition at line 1229 of file CAInfoService.cpp.

1230 {
1231  a_len = 0;
1232  UINT32 sendBuffLen;
1233  UINT8* sendBuff = NULL;
1234  XERCES_CPP_NAMESPACE::DOMDocument* docMixInfo = NULL;
1235  DOMElement* elemTimeStamp = NULL;
1236  DOMElement* elemRoot = NULL;
1237 
1238  if (m_pMix->getMixCascadeInfo(docMixInfo) != E_SUCCESS)
1239  {
1240  // CAMsg::printMsg(LOG_INFO,"InfoService: Cascade not yet configured.\n");
1241  goto ERR;
1242  }
1243  //insert (or update) the Timestamp
1244  elemRoot = docMixInfo->getDocumentElement();
1245 
1246  if (getDOMChildByName(elemRoot, "LastUpdate", elemTimeStamp, false) != E_SUCCESS)
1247  {
1248  elemTimeStamp = createDOMElement(docMixInfo, "LastUpdate");
1249  elemRoot->appendChild(elemTimeStamp);
1250  }
1251  UINT64 currentMillis;
1252  getcurrentTimeMillis(currentMillis);
1253  UINT8 tmpStrCurrentMillis[50];
1254  print64(tmpStrCurrentMillis, currentMillis);
1255  setDOMElementValue(elemTimeStamp, tmpStrCurrentMillis);
1256 
1257  if (m_serial != 0)
1258  {
1259  print64(tmpStrCurrentMillis, m_serial);
1260  setDOMElementAttribute(elemRoot, ATTRIBUTE_SERIAL, tmpStrCurrentMillis);
1261  }
1262 
1263  if (m_pMultiSignature->signXML(docMixInfo, true) != E_SUCCESS)
1264  {
1265  goto ERR;
1266  }
1267 
1268  sendBuff = DOM_Output::dumpToMem(docMixInfo, &sendBuffLen);
1269  if (sendBuff == NULL)
1270  {
1271  goto ERR;
1272  }
1273 
1274  a_len = sendBuffLen;
1275  return sendBuff;
1276 ERR:
1277  delete[]sendBuff;
1278  sendBuff = NULL;
1279  return NULL;
1280 }
#define ATTRIBUTE_SERIAL
SINT32 setDOMElementAttribute(DOMNode *pElem, const char *attrName, const char *value)
Definition: CAUtil.cpp:831
SINT32 getcurrentTimeMillis(UINT64 &u64Time)
Gets the current Systemtime in milli seconds.
Definition: CAUtil.cpp:252
SINT32 setDOMElementValue(DOMElement *pElem, SINT32 value)
Definition: CAUtil.cpp:939
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
SINT32 getDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
Definition: CAUtil.cpp:458
void print64(UINT8 *buff, UINT64 num)
Definition: CAUtil.hpp:482
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 getMixCascadeInfo(XERCES_CPP_NAMESPACE::DOMDocument *&docMixCascadeInfo)
Returns the Mix-Cascade info which should be send to the InfoService.
Definition: CAMix.hpp:96
SINT32 signXML(DOMNode *a_node, bool appendCerts)
static SINT32 dumpToMem(const DOMNode *node, UINT8 *buff, UINT32 *size)
Dumps the node and all childs into buff.
Definition: DOM_Output.hpp:161
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2

References ATTRIBUTE_SERIAL, createDOMElement(), DOM_Output::dumpToMem(), E_SUCCESS, getcurrentTimeMillis(), getDOMChildByName(), CAMix::getMixCascadeInfo(), m_pMix, m_pMultiSignature, m_serial, print64(), setDOMElementAttribute(), setDOMElementValue(), and CAMultiSignature::signXML().

Referenced by sendCascadeHelo().

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

◆ getLevel()

SINT32 CAInfoService::getLevel ( SINT32 puser,
SINT32 prisk,
SINT32 ptraffic 
)
private

Definition at line 444 of file CAInfoService.cpp.

445 {
446 #if !defined ONLY_LOCAL_PROXY
447  if (m_pMix != NULL && CALibProxytest::getOptions()->isFirstMix())
448  {
449  return ((CAFirstMix*)m_pMix)->getLevel(puser, prisk, ptraffic);
450  }
451 #endif
452  return E_UNKNOWN;
453 }
static CACmdLnOptions * getOptions()
#define E_UNKNOWN
Definition: errorcodes.hpp:3

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

Referenced by getStatusXMLAsString().

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

◆ getMixedPackets()

SINT32 CAInfoService::getMixedPackets ( UINT64 ppackets)
private

Definition at line 455 of file CAInfoService.cpp.

456 {
457 #if ! defined ONLY_LOCAL_PROXY
458  if (m_pMix != NULL && CALibProxytest::getOptions()->isFirstMix())
459  {
460  return ((CAFirstMix*)m_pMix)->getMixedPackets(ppackets);
461  }
462 #endif
463  return E_UNKNOWN;
464 }

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

Referenced by getStatusXMLAsString().

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

◆ getMixHeloXMLAsString()

UINT8 * CAInfoService::getMixHeloXMLAsString ( UINT32 len)
private

Definition at line 770 of file CAInfoService.cpp.

771 {
772  XERCES_CPP_NAMESPACE::DOMDocument* docMixInfo = NULL;
773  DOMElement* mixInfoRoot = NULL;
774 
775  if ((CALibProxytest::getOptions()->getMixXml(docMixInfo) != E_SUCCESS) ||
776  (docMixInfo == NULL))
777  {
778  return NULL;
779  }
780 
781  if (m_serial != 0)
782  {
783  mixInfoRoot = docMixInfo->getDocumentElement();
784  if (mixInfoRoot != NULL)
785  {
787  }
788  }
789  return xmlDocToStringWithSignature(docMixInfo, a_len, true);
790 }
UINT8 * xmlDocToStringWithSignature(DOMNode *a_node, UINT32 &a_len, bool bIncludeCerts)

References ATTRIBUTE_SERIAL, E_SUCCESS, CALibProxytest::getOptions(), m_serial, setDOMElementAttribute(), and xmlDocToStringWithSignature().

Referenced by sendMixHelo().

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

◆ getOperatorTnCsAsStrings()

UINT8 ** CAInfoService::getOperatorTnCsAsStrings ( UINT32 **  lengths,
UINT32 nrOfTnCs 
)
private

POSTs the MIXINFO message for a mix to the InfoService.

returns a string array with all signed Terms and Condition-Objects NOTE: this method has a side-effect: the DOMNodes are all signed and thus modified

Parameters
lengthscontains the lengths of each corresponding object. Its memory is allocated by this method and has to be freed explicitly by calling delete []
nrOfTnCsis the length of the returned array
Return values
alist with all Terms and conditions object which has to be freed explicitly by calling delete []

Definition at line 1071 of file CAInfoService.cpp.

1072 {
1073 
1074  DOMElement *tnCs = CALibProxytest::getOptions()->getTermsAndConditions();
1075  if (tnCs == NULL)
1076  {
1077  return NULL;
1078  }
1079 
1080  DOMNodeList *docTnCsList =
1082 
1083  if (docTnCsList == NULL)
1084  {
1085  return NULL;
1086  }
1087 
1088  UINT8 **elementList = NULL;
1089  DOMNode *iterator = NULL;
1090  UINT32 i = 0;
1091 
1092  UINT8 tmpOpSKIBuff[TMP_BUFF_SIZE];
1093  UINT32 tmpOpSKILen = TMP_BUFF_SIZE;
1094 
1095  CALibProxytest::getOptions()->getOperatorSubjectKeyIdentifier(tmpOpSKIBuff, &tmpOpSKILen);
1096  if (tmpOpSKILen == 0)
1097  {
1098  return NULL;
1099  }
1100 
1101  UINT8 tmpDate[TMP_BUFF_SIZE];
1102  UINT32 tmpDateLen = TMP_BUFF_SIZE;
1103 
1104  getDOMElementAttribute(tnCs, OPTIONS_ATTRIBUTE_TNC_DATE, tmpDate, &tmpDateLen);
1105  if (tmpDateLen == 0)
1106  {
1107  return NULL;
1108  }
1109 
1110  UINT8 tmpVersion[TMP_BUFF_SIZE];
1111  UINT32 tmpVersionLen = TMP_BUFF_SIZE;
1112 
1113  UINT8* serial = NULL;
1114 
1115  getDOMElementAttribute(tnCs, OPTIONS_ATTRIBUTE_TNC_VERSION, tmpVersion, &tmpVersionLen);
1116  if (tmpVersionLen > 0)
1117  {
1118  serial = new UINT8[tmpDateLen + tmpVersionLen + 1];
1119  memcpy(serial, tmpDate, tmpDateLen);
1120  memcpy(serial + tmpDateLen, tmpVersion, tmpVersionLen);
1121  serial[tmpDateLen + tmpVersionLen] = 0;
1122  }
1123  else
1124  {
1125  serial = new UINT8[tmpDateLen + 1];
1126  memcpy(serial, tmpDate, tmpDateLen);
1127  serial[tmpDateLen] = 0;
1128  }
1129 
1130  UINT32 locale_len = 3;
1131  UINT8* id = new UINT8[tmpOpSKILen + locale_len + 1];
1132  UINT8* locale = new UINT8[locale_len];
1133 
1134  locale[locale_len - 1] = 0;
1135 
1136  memcpy(id, tmpOpSKIBuff, tmpOpSKILen);
1137  id[tmpOpSKILen] = 0;
1138  id[tmpOpSKILen + (locale_len - 1) + 1] = 0;
1139 
1140  (*nrOfTnCs) = docTnCsList->getLength();
1141  elementList = new UINT8 *[(*nrOfTnCs)];
1142  (*lengths) = new UINT32[(*nrOfTnCs)];
1143  for (; i < (*nrOfTnCs); i++)
1144  {
1145  //after every loop turn locale is explicitly reset to 3 because ...
1146  locale_len = 3;
1147  iterator = docTnCsList->item(i);
1148  //... it is modified by getDOMElementAttribute
1149  getDOMElementAttribute(iterator, OPTIONS_ATTRIBUTE_TNC_LOCALE, locale, &locale_len);
1150  if (locale_len == 0)
1151  {
1152  elementList[i] = NULL;
1153  continue;
1154  }
1155  //only append the locale code to the id when it is
1156  //not the default locale
1157  if (strncasecmp((char *)locale, LOCALE_DEFAULT, 2) == 0)
1158  {
1159  id[tmpOpSKILen] = 0;
1160  }
1161  else
1162  {
1163  id[tmpOpSKILen] = '_';
1164  memcpy((id + tmpOpSKILen + 1), locale, locale_len);
1165  }
1166 
1168  {
1169  elementList[i] = NULL;
1170  continue;
1171  }
1172  if (setDOMElementAttribute(iterator, OPTIONS_ATTRIBUTE_TNC_DATE, tmpDate) != E_SUCCESS)
1173  {
1174  elementList[i] = NULL;
1175  continue;
1176  }
1178  {
1179  elementList[i] = NULL;
1180  continue;
1181  }
1183  elementList[i] = xmlDocToStringWithSignature(iterator, (*lengths)[i], true);
1184  }
1185 
1186  delete[] serial;
1187  delete[] id;
1188  delete[] locale;
1189  return elementList;
1190 
1191 }
#define OPTIONS_ATTRIBUTE_TNC_ID
#define OPTIONS_ATTRIBUTE_TNC_VERSION
#define OPTIONS_ATTRIBUTE_TNC_SERIAL
#define OPTIONS_ATTRIBUTE_TNC_DATE
#define OPTIONS_ATTRIBUTE_TNC_LOCALE
#define OPTIONS_NODE_TNCS_TRANSLATION
#define LOCALE_DEFAULT
SINT32 setCurrentTimeMilliesAsDOMAttribute(DOMNode *pElem)
Definition: CAUtil.cpp:848
DOMNodeList * getElementsByTagName(DOMElement *pElem, const char *const name)
Definition: CAUtil.cpp:1711
SINT32 getDOMElementAttribute(const DOMNode *const elem, const char *attrName, UINT8 *value, UINT32 *len)
Definition: CAUtil.cpp:780
#define TMP_BUFF_SIZE
Definition: CAUtil.hpp:38
DOMElement * getTermsAndConditions()
SINT32 getOperatorSubjectKeyIdentifier(UINT8 *buffer, UINT32 *length)
Returns a COPY of the public test certifcate for that mix.

References E_SUCCESS, getDOMElementAttribute(), getElementsByTagName(), CACmdLnOptions::getOperatorSubjectKeyIdentifier(), CALibProxytest::getOptions(), CACmdLnOptions::getTermsAndConditions(), LOCALE_DEFAULT, OPTIONS_ATTRIBUTE_TNC_DATE, OPTIONS_ATTRIBUTE_TNC_ID, OPTIONS_ATTRIBUTE_TNC_LOCALE, OPTIONS_ATTRIBUTE_TNC_SERIAL, OPTIONS_ATTRIBUTE_TNC_VERSION, OPTIONS_NODE_TNCS_TRANSLATION, setCurrentTimeMilliesAsDOMAttribute(), setDOMElementAttribute(), TMP_BUFF_SIZE, and xmlDocToStringWithSignature().

Here is the call graph for this function:

◆ getPaymentInstance() [1/2]

SINT32 CAInfoService::getPaymentInstance ( const UINT8 a_pstrPIID,
CAXMLBI **  pXMLBI 
)

Definition at line 1444 of file CAInfoService.cpp.

1445 {
1446  SINT32 returnValue = E_UNKNOWN;
1447  SINT32 currentValue;
1448  UINT32 nrAddresses;
1449  CAListenerInterface** socketAddresses = CALibProxytest::getOptions()->getInfoServices(nrAddresses);
1450  for (UINT32 i = 0; i < nrAddresses; i++)
1451  {
1452  currentValue = getPaymentInstance(a_pstrPIID, a_pXMLBI,
1453  (CASocketAddrINet*)socketAddresses[i]->getAddr());
1454  if (currentValue == E_SUCCESS)
1455  {
1456  returnValue = currentValue;
1457  }
1458  }
1459  return returnValue;
1460 }
signed int SINT32
Definition: basetypedefs.h:132
CAListenerInterface ** getInfoServices(UINT32 &r_size)
SINT32 getPaymentInstance(const UINT8 *a_pstrPIID, CAXMLBI **pXMLBI, CASocketAddrINet *a_socketAddress)
Gets a payment instance from the InfoService.
This class represents a socket address for Internet (IP) connections.

References E_SUCCESS, E_UNKNOWN, CACmdLnOptions::getInfoServices(), CALibProxytest::getOptions(), and getPaymentInstance().

Here is the call graph for this function:

◆ getPaymentInstance() [2/2]

SINT32 CAInfoService::getPaymentInstance ( const UINT8 a_pstrPIID,
CAXMLBI **  a_pXMLBI,
CASocketAddrINet a_socketAddress 
)
private

Gets a payment instance from the InfoService.

Parameters
a_pstrPIIDid of the payment instance for which the information is requested
a_pXMLBIa pointer to a pointer which on a successful return will point to a newly created CAXMLBI object
a_socketAddressadress of the InfoService from which the information is to be requested
Return values
E_SUCCESSif succesful
E_UNKNOWNif an error occured
Returns
a_pXMLBI will point to a pointer to the newly created CAXMLBI object or to NULL

Definition at line 1471 of file CAInfoService.cpp.

1473 {
1474  CASocket socket;
1475  CASocketAddrINet address;
1476  UINT8 hostname[255];
1477  UINT8 request[255];
1478  CAHttpClient httpClient;
1479  UINT32 status, contentLength;
1480  *a_pXMLBI=NULL;
1481  //Connect to InfoService
1482  if(a_socketAddress->getIPAsStr(hostname, 255)!=E_SUCCESS)
1483  {
1484  socket.close();
1485  return E_UNKNOWN;
1486  }
1487 
1488  address.setAddr(hostname,a_socketAddress->getPort());
1489 
1490  if(socket.connect(address)!=E_SUCCESS)
1491  {
1492  socket.close();
1493  return E_UNKNOWN;
1494  }
1495 
1496  //#ifdef DEBUG
1497  CAMsg::printMsg(LOG_DEBUG, "CAInfoService::getPaymentInstance() - connected to InfoService %s:%d\n",hostname, a_socketAddress->getPort());
1498  //#endif
1499 
1500  //Send request
1501  httpClient.setSocket(&socket);
1502  sprintf((char*) request, "/paymentinstance/%s", (char*) a_pstrPIID);
1503  httpClient.sendGetRequest(request);
1504  httpClient.parseHTTPHeader(&contentLength, &status);
1505 #ifdef DEBUG
1506  CAMsg::printMsg(LOG_DEBUG, "CAInfoService::getPaymentInstance() - Request sent, HTTP status: %i, content length: %i\n", status, contentLength);
1507 #endif
1508  if(status!=200||contentLength>0x00FFFF)
1509  {
1510  socket.close();
1511  return E_UNKNOWN;
1512  }
1513 
1514  UINT8* content=new UINT8[contentLength+1];
1515  if(httpClient.getContent(content, &contentLength)!=E_SUCCESS)
1516  {
1517  delete []content;
1518  content = NULL;
1519  socket.close();
1520  return E_UNKNOWN;
1521  }
1522  socket.close();
1523  //Parse XML
1524  XERCES_CPP_NAMESPACE::DOMDocument* doc = parseDOMDocument(content,contentLength);
1525  delete []content;
1526  content = NULL;
1527  if(doc==NULL)
1528  {
1529  return E_UNKNOWN;
1530  }
1531  DOMElement* elemRoot=doc->getDocumentElement();
1532 
1533  *a_pXMLBI = CAXMLBI::getInstance(elemRoot);
1534  CAMsg::printMsg(LOG_DEBUG, "CAInfoService::getPaymentInstance(): XML doc not needed anymore\n");
1535  if (*a_pXMLBI != NULL)
1536  {
1537  return E_SUCCESS;
1538  }
1539  else
1540  {
1541  return E_UNKNOWN;
1542  }
1543 }
XERCES_CPP_NAMESPACE::DOMDocument * parseDOMDocument(const UINT8 *const buff, UINT32 len)
Parses a buffer containing an XML document and returns this document.
Definition: CAUtil.cpp:663
Very simple http client.
SINT32 sendGetRequest(const UINT8 *url)
Sends a HTTP GET request to the server.
SINT32 getContent(UINT8 *a_pContent, UINT32 *a_pLength)
Retruns the content of the response.
SINT32 parseHTTPHeader(UINT32 *contentLength, UINT32 *statusCode=NULL, UINT32 msTimeOut=3000)
receives the HTTP header and parses the content length
SINT32 setSocket(CASocket *pSocket)
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
SINT32 setAddr(const UINT8 *szIP, UINT16 port)
Sets the address to szIP and port.
SINT32 getIPAsStr(UINT8 *buff, UINT32 len) const
Returns the IP-Number as an address string (doted-format).
UINT16 getPort() const
Returns the port value of the address.
virtual SINT32 close()
Definition: CASocket.cpp:351
virtual SINT32 connect(const CASocketAddr &psa)
Definition: CASocket.hpp:64

References CASocket::close(), CASocket::connect(), E_SUCCESS, E_UNKNOWN, CAHttpClient::getContent(), CASocketAddrINet::getIPAsStr(), CASocketAddrINet::getPort(), parseDOMDocument(), CAHttpClient::parseHTTPHeader(), CAMsg::printMsg(), CAHttpClient::sendGetRequest(), CASocketAddrINet::setAddr(), and CAHttpClient::setSocket().

Referenced by getPaymentInstance().

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

◆ getStatusXMLAsString()

UINT8 * CAInfoService::getStatusXMLAsString ( bool  bIncludeCerts,
UINT32 len 
)
private

Definition at line 547 of file CAInfoService.cpp.

548 {
549  SINT32 tmpUser, tmpRisk, tmpTraffic;
550  UINT64 tmpPackets;
551 
552  //httpClient.setSocket(&oSocket);
553  UINT8 strMixId[255];
554  CALibProxytest::getOptions()->getMixId(strMixId, 255);
555 
556  tmpUser = tmpTraffic = tmpRisk = -1;
557  set64(tmpPackets, (UINT32)-1);
558  getLevel(&tmpUser, &tmpRisk, &tmpTraffic);
559  SINT32 ret = getMixedPackets(tmpPackets);
560  if (ret == E_SUCCESS)
561  {
562  UINT32 avgTraffic = div64(tmpPackets, m_minuts);
563  UINT32 diffTraffic = diff64(tmpPackets, m_lastMixedPackets);
564  if (avgTraffic == 0)
565  {
566  if (diffTraffic == 0)
567  {
568  tmpTraffic = 0;
569  }
570  else
571  {
572  tmpTraffic = 100;
573  }
574  }
575  else
576  {
577  double dTmp = (double)diffTraffic / (double)avgTraffic;
578  tmpTraffic = min(SINT32(50.*dTmp), 100);
579  }
580  set64(m_lastMixedPackets, tmpPackets);
581  }
582  m_minuts++;
583  //let the attributes in alphabetical order..
584 #define XML_MIX_CASCADE_STATUS "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
585  <MixCascadeStatus LastUpdate=\"%s\" currentRisk=\"%i\" id=\"%s\" mixedPackets=\"%s\" nrOfActiveUsers=\"%i\" trafficSituation=\"%i\"\
586  ></MixCascadeStatus>"
587 
588  UINT32 buffLen = 8192;
589  UINT8* buff = new UINT8[buffLen];
590  memset(buff, 0, buffLen);
591  UINT8 tmpBuff[1024];
592  UINT8 buffMixedPackets[50];
593  print64(buffMixedPackets, tmpPackets);
594  UINT64 currentMillis;
595  UINT8 tmpStrCurrentMillis[50];
596  if (getcurrentTimeMillis(currentMillis) == E_SUCCESS)
597  {
598  print64(tmpStrCurrentMillis, currentMillis);
599  }
600  else
601  {
602  tmpStrCurrentMillis[0] = 0;
603  }
604  sprintf((char*)tmpBuff, XML_MIX_CASCADE_STATUS, tmpStrCurrentMillis, tmpRisk, strMixId, buffMixedPackets, tmpUser, tmpTraffic);
605 
606 
607  if (m_pMultiSignature->signXML(tmpBuff, strlen((char*)tmpBuff), buff, &buffLen, bIncludeCerts) != E_SUCCESS)
608  {
609  delete[] buff;
610  buff = NULL;
611  }
612  else
613  {
614  len = buffLen;
615  }
616  return buff;
617 }
#define XML_MIX_CASCADE_STATUS
UINT32 diff64(const UINT64 &bigop, const UINT64 &smallop)
Definition: CAUtil.hpp:398
UINT32 div64(UINT64 &op1, UINT32 op2)
Definition: CAUtil.hpp:407
void set64(UINT64 &op1, UINT32 op2)
Definition: CAUtil.hpp:321
#define min(a, b)
Definition: StdAfx.h:649
SINT32 getMixId(UINT8 *id, UINT32 len)
SINT32 getMixedPackets(UINT64 &ppackets)
SINT32 getLevel(SINT32 *puser, SINT32 *prisk, SINT32 *ptraffic)
UINT16 len
Definition: typedefs.hpp:0

References diff64(), div64(), E_SUCCESS, getcurrentTimeMillis(), getLevel(), getMixedPackets(), CACmdLnOptions::getMixId(), CALibProxytest::getOptions(), len, m_lastMixedPackets, m_minuts, m_pMultiSignature, min, print64(), set64(), CAMultiSignature::signXML(), and XML_MIX_CASCADE_STATUS.

Referenced by sendStatus().

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

◆ handleConfigEvent()

SINT32 CAInfoService::handleConfigEvent ( XERCES_CPP_NAMESPACE::DOMDocument *  doc) const
private

‍*** Nedd redesigning!*‍/

Definition at line 1366 of file CAInfoService.cpp.

1367 {
1369  /* CAMsg::printMsg(LOG_INFO,"InfoService: Cascade info received from InfoService\n");
1370 
1371  DOM_Element root=doc.getDocumentElement();
1372  DOM_Node mixesElement;
1373  getDOMChildByName(root,(UINT8*)"Mixes", mixesElement, false);
1374  char* mixId;
1375  char* prevMixId = NULL;
1376  char* myNextMixId = NULL;
1377  char* myPrevMixId = NULL;
1378  bool bFoundMix = false;
1379  UINT8 myMixId[64];
1380  CALibProxytest::getOptions()->getMixId(myMixId,64);
1381  DOM_Node child = mixesElement.getFirstChild();
1382  while(child!=NULL)
1383  {
1384  if(child.getNodeName().equals("Mix") && child.getNodeType() == DOM_Node::ELEMENT_NODE)
1385  {
1386  mixId = static_cast<const DOM_Element&>(child).getAttribute("id").transcode();
1387  if(strcmp(mixId,(char*)myMixId) == 0)
1388  {
1389  bFoundMix = true;
1390  myPrevMixId = prevMixId;
1391  }
1392  else if(bFoundMix == true)
1393  {
1394  myNextMixId = mixId;
1395  break;
1396  }
1397  prevMixId = mixId;
1398  }
1399  child = child.getNextSibling();
1400  }
1401 
1402  SINT32 ret = 0;
1403  //char* c;
1404 
1405  if(myPrevMixId != NULL)
1406  {
1407  CAMsg::printMsg(LOG_INFO,"InfoService: Asking InfoService about previous mix ...\n");
1408 
1409  m_expectedMixRelPos = -1;
1410  //c = new char[8+strlen(myPrevMixId)+1];
1411  //strcpy(c,"mixinfo/");
1412  //strcat(c,myPrevMixId);
1413  ret = sendMixInfo((UINT8*)myPrevMixId);
1414  //delete[] c;
1415  if(ret != E_SUCCESS)
1416  {
1417  CAMsg::printMsg(LOG_CRIT,"InfoService: Error retrieving mix info from InfoService!\n");
1418  return ret;
1419  }
1420  }
1421 
1422  if(myNextMixId != NULL)
1423  {
1424  CAMsg::printMsg(LOG_INFO,"InfoService: Asking InfoService about next mix ...\n");
1425 
1426  m_expectedMixRelPos = 1;
1427  //c = new char[8+strlen(myNextMixId)+1];
1428  //strcpy(c,"mixinfo/");
1429  //strcat(c,myNextMixId);
1430  ret = sendMixInfo((UINT8*)myNextMixId);
1431  //delete[] c;
1432  if(ret != E_SUCCESS)
1433  {
1434  CAMsg::printMsg(LOG_CRIT,"InfoService: Error retrieving mix info from InfoService!\n");
1435  return ret;
1436  }
1437 
1438  }
1439  */
1440  return E_SUCCESS;
1441 }

References E_SUCCESS.

◆ InfoLoop()

THREAD_RETURN CAInfoService::InfoLoop ( void *  p)
staticprivate

Definition at line 86 of file CAInfoService.cpp.

87 {
88  INIT_STACK;
89  BEGIN_STACK("CAInfoService::InfoLoop");
90 
91  CAMsg::printMsg(LOG_DEBUG, "CAInfoService - InfoLoop() started\n");
92  CAMsg::printMsg(LOG_DEBUG, "CAInfoService - InfoLoop() PID: %i\n", getpid());
93  CAInfoService* pInfoService = (CAInfoService*)p;
94  bool bIsFirst = true; //send our own certifcate only the first time
95  bool bOneUpdateDone = false;
96 
97  UINT32 currentTime;
98  UINT32 lastCascadeUpdate;
99  UINT32 lastStatusUpdate;
100  UINT32 lastMixInfoUpdate;
101  UINT32 nextUpdate;
102 #ifdef DYNAMIC_MIX
103  UINT32 loops = 4;
104  UINT32 interval = 0;
105 #endif
106  lastCascadeUpdate = lastMixInfoUpdate = lastStatusUpdate = (UINT32)time(NULL);
107  // tell the algorithm it is time to update
108  lastCascadeUpdate -= CAInfoService::SEND_CASCADE_INFO_WAIT;
109  lastMixInfoUpdate -= CAInfoService::SEND_MIX_INFO_WAIT;
110  lastStatusUpdate -= CAInfoService::SEND_STATUS_INFO_WAIT;
111  UINT32 statusSentErrorBurst = 0;
112 
113  pInfoService->m_pLoopCV->lock();
114  pInfoService->m_pLoopCV->wait(CAInfoService::SEND_LOOP_SLEEP * 1000);
115  pInfoService->m_pLoopCV->unlock();
116 
117  while (pInfoService->isRunning())
118  {
119 #ifdef DYNAMIC_MIX
121  if(loops < 4)
122  {
123  sSleep(interval);
124  loops++;
125  continue;
126  }
127 #endif
128  // TODO: the "pInfoService->m_pMix->getLastConnectionTime() < (currentTime - (SEND_LOOP_SLEEP / 2))" is just a work-around until we have a proper synchronization with the xml nodes...
129 
130  currentTime = time(NULL);
131  if (currentTime >= (lastStatusUpdate + CAInfoService::SEND_STATUS_INFO_WAIT))
132  {
133  if (pInfoService->m_pMix->isConnected() && pInfoService->m_pMix->getLastConnectionTime() < (currentTime - (SEND_LOOP_SLEEP / 2)) &&
134  pInfoService->sendStatus(bIsFirst) == E_SUCCESS)
135  {
136  lastStatusUpdate = time(NULL);
137  bIsFirst = false;
138  bOneUpdateDone = true;
139  statusSentErrorBurst = 0;
140  //CAMsg::printMsg(LOG_DEBUG,"InfoService: Successfully sent Status information.\n");
141  }
142  else
143  if (pInfoService->m_pMix->isConnected() && pInfoService->m_pMix->getLastConnectionTime() < (currentTime - (SEND_LOOP_SLEEP / 2)))
144  {
145  statusSentErrorBurst++;
146  CAMsg::printMsg(LOG_WARNING, "InfoService: Could not send Status information.\n");
147  }
148  /* send terms and conditions */
149  //pInfoService->sendOperatorTnCData();
150  }
151 
152  // check every minute if configuring, every 10 minutes otherwise
153  currentTime = time(NULL);
154  if (currentTime >= (lastCascadeUpdate + CAInfoService::SEND_CASCADE_INFO_WAIT) || pInfoService->isConfiguring())
155  {
156  if (CALibProxytest::getOptions()->isFirstMix() || (CALibProxytest::getOptions()->isLastMix() && pInfoService->isConfiguring()))
157  {
158  if (pInfoService->m_pMix->isConnected() && pInfoService->m_pMix->getLastConnectionTime() < (currentTime - (SEND_LOOP_SLEEP / 2))
159  && pInfoService->sendCascadeHelo() == E_SUCCESS)
160  {
161  lastCascadeUpdate = time(NULL);
162  bOneUpdateDone = true;
163  CAMsg::printMsg(LOG_INFO, "InfoService: Successfully sent Cascade information.\n");
164  }
165  else
166  if (pInfoService->m_pMix->isConnected() && pInfoService->m_pMix->getLastConnectionTime() < (currentTime - (SEND_LOOP_SLEEP / 2)))
167  {
168  CAMsg::printMsg(LOG_WARNING, "InfoService: Could not send Cascade information.\n");
169  }
170  }
171  currentTime = time(NULL);
172  if ((currentTime >= (lastMixInfoUpdate + CAInfoService::SEND_MIX_INFO_WAIT) &&
173  pInfoService->m_pMix->getLastConnectionTime() < (currentTime - (SEND_LOOP_SLEEP / 2))) || pInfoService->isConfiguring())
174  {
175  if (pInfoService->sendMixHelo() != E_SUCCESS)
176  {
177  CAMsg::printMsg(LOG_WARNING, "InfoService: Could not send MixInfo information.\n");
178  }
179  else
180  {
181  lastMixInfoUpdate = time(NULL);
182  bOneUpdateDone = true;
183  CAMsg::printMsg(LOG_INFO, "InfoService: Successfully sent MixInfo information.\n");
184  }
185  }
186  }
187 #ifdef DYNAMIC_MIX
188  // LERNGRUPPE
189  // Check regulary for new cascade information
195  if( CALibProxytest::getOptions()->isDynamic() )
196  {
197  pInfoService->dynamicCascadeConfiguration();
198  }
199 #endif
200  currentTime = time(NULL);
201  //@TODO BUGGy -- because it assumes knowledge about update times, which are configurable in StdAfx.hpp
202  // wait CAInfoService::SEND_LOOP_SLEEP seconds at most
203  /*temp = (currentTime - lastStatusUpdate);
204  if (bOneUpdateDone && temp > 0)
205  {
206  if (temp <= CAInfoService::SEND_LOOP_SLEEP)
207  {
208  bPreventLoop = false;
209  nextUpdate = CAInfoService::SEND_LOOP_SLEEP - temp;
210  }
211  else if (bPreventLoop)
212  {
213  // prevent infinite loops
214  bPreventLoop = false;
215  nextUpdate = CAInfoService::SEND_LOOP_SLEEP;
216  }
217  else
218  {
219  bPreventLoop = true;
220  nextUpdate = 0;
221  }
222  }
223  else
224  {
225  bPreventLoop = false;
226  nextUpdate = CAInfoService::SEND_LOOP_SLEEP;
227  }*/
228 
229  /* Not the optimal solution; would be best, if infoservice send
230  * routines can be called by other threads if certain events occur, i.e.
231  * cascade reconnection, etc.
232  */
233  if (bOneUpdateDone && (statusSentErrorBurst > 0))
234  {
235  //TODO: handle case when status sent error burst exceeds an upper limit */
237  }
238  else
239  {
240  nextUpdate = CAInfoService::SEND_LOOP_SLEEP;
241  }
242 #ifdef DYNAMIC_MIX
243  interval = nextUpdate / 4;
244  CAMsg::printMsg(LOG_DEBUG,"InfoService: Next update in %i seconds...interval %i\n", nextUpdate, interval);
245  loops = 0;
246 #else
247  if (nextUpdate > 20)
248  {
249  CAMsg::printMsg(LOG_DEBUG, "InfoService: Next update in %i seconds...\n", nextUpdate);
250  }
251  /* We can interrupt this thread if the mix is shutting down */
252  pInfoService->m_pLoopCV->lock();
253  pInfoService->m_pLoopCV->wait(nextUpdate * 1000);
254  pInfoService->m_pLoopCV->unlock();
255 
256  //sSleep(nextUpdate);
257 #endif
258  }
259  CAMsg::printMsg(LOG_DEBUG, "CAInfoService - InfoLoop() exited\n");
260  FINISH_STACK("CAInfoService::InfoLoop");
262 }
#define INIT_STACK
Definition: CAThread.hpp:48
#define BEGIN_STACK(methodName)
Definition: CAThread.hpp:49
#define FINISH_STACK(methodName)
Definition: CAThread.hpp:50
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
Definition: CAUtil.cpp:425
#define THREAD_RETURN_SUCCESS
Definition: StdAfx.h:542
SINT32 wait()
Waits for a signal or for a timeout.
static const UINT32 REPEAT_ON_STATUS_SENT_ERROR
bool isConfiguring()
SINT32 sendStatus(bool bIncludeCerts)
static const UINT64 SEND_STATUS_INFO_WAIT
SINT32 sendMixHelo(SINT32 requestCommand=-1, const UINT8 *param=NULL)
static const UINT64 SEND_MIX_INFO_WAIT
SINT32 sendCascadeHelo()
static const UINT64 SEND_LOOP_SLEEP
static const UINT64 SEND_CASCADE_INFO_WAIT
bool isConnected()
Definition: CAMix.hpp:130
UINT32 getLastConnectionTime()
Definition: CAMix.hpp:125
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41

References BEGIN_STACK, E_SUCCESS, FINISH_STACK, CAMix::getLastConnectionTime(), CALibProxytest::getOptions(), INIT_STACK, isConfiguring(), CAMix::isConnected(), isRunning(), CAMutex::lock(), m_pLoopCV, m_pMix, CAMsg::printMsg(), REPEAT_ON_STATUS_SENT_ERROR, SEND_CASCADE_INFO_WAIT, SEND_LOOP_SLEEP, SEND_MIX_INFO_WAIT, SEND_STATUS_INFO_WAIT, sendCascadeHelo(), sendMixHelo(), sendStatus(), sSleep(), THREAD_RETURN_SUCCESS, CAMutex::unlock(), and CAConditionVariable::wait().

Referenced by start().

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

◆ isConfiguring()

bool CAInfoService::isConfiguring ( )
inline

Definition at line 84 of file CAInfoService.hpp.

85  {
86  return m_bConfiguring;
87  }

References m_bConfiguring.

Referenced by InfoLoop().

Here is the caller graph for this function:

◆ isRunning()

bool CAInfoService::isRunning ( )
inline

Definition at line 74 of file CAInfoService.hpp.

75  {
76  return m_bRun;
77  }

References m_bRun.

Referenced by InfoLoop(), and CAMix::start().

Here is the caller graph for this function:

◆ sendCascadeHelo() [1/2]

SINT32 CAInfoService::sendCascadeHelo ( )

Definition at line 1198 of file CAInfoService.cpp.

1199 {
1200  if (CALibProxytest::getOptions()->isMiddleMix())
1201  {
1202  return E_SUCCESS;
1203  }
1204 
1205  UINT32 len;
1206  SINT32 ret;
1207  UINT8* strCascadeHeloXML = getCascadeHeloXMLAsString(len);
1208  if (strCascadeHeloXML == NULL)
1209  {
1210  return E_UNKNOWN;
1211  }
1212 
1213  if (!(m_pMix->isConnected()))
1214  {
1215 #ifdef DEBUG
1216  CAMsg::printMsg(LOG_INFO, "not connected: skipping cascade helo.\n");
1217 #endif
1218  delete[] strCascadeHeloXML;
1219  strCascadeHeloXML = NULL;
1220  return E_UNKNOWN;
1221  }
1222 
1223  ret = sendHelo(strCascadeHeloXML, len, TCascadeHelo, (UINT8*)"Cascade Helo Thread", REQUEST_COMMAND_CASCADE);
1224  delete[] strCascadeHeloXML;
1225  strCascadeHeloXML = NULL;
1226  return ret;
1227 }
#define REQUEST_COMMAND_CASCADE
SINT32 sendHelo(UINT8 *a_strXML, UINT32 a_len, THREAD_RETURN(*a_thread)(void *), UINT8 *a_strThreadName, SINT32 requestCommand, const UINT8 *param=NULL)
static THREAD_RETURN TCascadeHelo(void *p)
UINT8 * getCascadeHeloXMLAsString(UINT32 &len)

References E_SUCCESS, E_UNKNOWN, getCascadeHeloXMLAsString(), CALibProxytest::getOptions(), CAMix::isConnected(), len, m_pMix, CAMsg::printMsg(), REQUEST_COMMAND_CASCADE, sendHelo(), and TCascadeHelo().

Referenced by InfoLoop(), CAMix::start(), and TCascadeHelo().

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

◆ sendCascadeHelo() [2/2]

SINT32 CAInfoService::sendCascadeHelo ( const UINT8 a_strCascadeHeloXML,
UINT32  a_len,
const CASocketAddrINet a_pSocketAddress 
) const
private

POSTs the HELO message for a whole cascade to the InfoService.

If the running mix is a last mix, this method is used to inform the InfoService that it wants to create a new cascade. The InfoService then tells all involved mixes to join this cascade. If the current mix is a middle mix, this method does nothing.

Return values
E_SUCCESSon success
E_UNKNOWNon any error

Definition at line 1290 of file CAInfoService.cpp.

1291 {
1292  if (CALibProxytest::getOptions()->isMiddleMix() || (CALibProxytest::getOptions()->isLastMix() && !m_bConfiguring))
1293  {
1294  return E_SUCCESS;
1295  }
1296  CASocket oSocket(true);
1297  UINT8 hostname[255];
1298  UINT8 buffHeader[255];
1299  UINT64 currentTimeout = MIX_TO_INFOSERVICE_TIMEOUT;
1300  UINT64 startupTime, currentMillis;
1301 
1302  if (a_pSocketAddress == NULL)
1303  {
1304  goto ERR;
1305  }
1306 
1307  if (a_pSocketAddress->getIPAsStr(hostname, 255) != E_SUCCESS)
1308  {
1309  goto ERR;
1310  }
1311  if (oSocket.connect(*a_pSocketAddress, MIX_TO_INFOSERVICE_TIMEOUT) == E_SUCCESS)
1312  {
1313  if (CALibProxytest::getOptions()->isFirstMix())
1314  {
1315  CAMsg::printMsg(LOG_DEBUG, "InfoService: Sending cascade helo to InfoService %s:%d.\r\n", hostname, a_pSocketAddress->getPort());
1316  }
1317  else
1318  {
1319  CAMsg::printMsg(LOG_DEBUG, "InfoService: Sending cascade configuration request to InfoService %s:%d.\r\n", hostname, a_pSocketAddress->getPort());
1320  }
1321  // LERNGRUPPE
1322  // Semi-dynamic cascades are temporary cascades, not yet established! InfoService can cope with them now
1323  // using the /dynacascade command
1324  if (CALibProxytest::getOptions()->isLastMix() && m_bConfiguring)
1325  {
1326  sprintf((char*)buffHeader, "POST /dynacascade HTTP/1.0\r\nContent-Length: %u\r\n\r\n", a_len);
1327  }
1328  else
1329  {
1330  sprintf((char*)buffHeader, "POST /cascade HTTP/1.0\r\nContent-Length: %u\r\n\r\n", a_len);
1331  }
1332 
1333  getcurrentTimeMillis(startupTime);
1334  if (oSocket.sendFullyTimeOut(buffHeader, strlen((char*)buffHeader), currentTimeout, SEND_INFO_TIMEOUT_MS) != E_SUCCESS)
1335  {
1336  goto ERR;
1337  }
1338  getcurrentTimeMillis(currentMillis);
1339  currentTimeout -= (currentMillis - startupTime);
1340  if (currentTimeout <= 0 ||
1341  oSocket.sendFullyTimeOut(a_strCascadeHeloXML, a_len, currentTimeout, SEND_INFO_TIMEOUT_MS) != E_SUCCESS)
1342  {
1343  goto ERR;
1344  }
1345  //Receive answer --> 200 Ok or failure
1346  //HTTP/1.1 200 Ok
1347  getcurrentTimeMillis(currentMillis);
1348  currentTimeout -= (currentMillis - startupTime);
1349  if (currentTimeout <= 0 ||
1350  oSocket.receiveFullyT(buffHeader, 12, currentTimeout) != E_SUCCESS)
1351  {
1352  goto ERR;
1353  }
1354  if (memcmp(buffHeader + 9, "200", 3) != 0)
1355  {
1356  goto ERR;
1357  }
1358  oSocket.close();
1359  return E_SUCCESS;
1360  }
1361 ERR:
1362  oSocket.close();
1363  return E_UNKNOWN;
1364 }
#define MIX_TO_INFOSERVICE_TIMEOUT
Definition: StdAfx.h:201
static const UINT32 SEND_INFO_TIMEOUT_MS

References CASocket::close(), CASocket::connect(), E_SUCCESS, E_UNKNOWN, getcurrentTimeMillis(), CASocketAddrINet::getIPAsStr(), CALibProxytest::getOptions(), CASocketAddrINet::getPort(), m_bConfiguring, MIX_TO_INFOSERVICE_TIMEOUT, CAMsg::printMsg(), CASocket::receiveFullyT(), SEND_INFO_TIMEOUT_MS, and CASocket::sendFullyTimeOut().

Here is the call graph for this function:

◆ sendHelo()

SINT32 CAInfoService::sendHelo ( UINT8 a_strXML,
UINT32  a_len,
THREAD_RETURN(*)(void *)  a_thread,
UINT8 a_strThreadName,
SINT32  requestCommand,
const UINT8 param = NULL 
)
private

Definition at line 619 of file CAInfoService.cpp.

620 {
621  SINT32 returnValue = E_UNKNOWN;
622  UINT32 nrAddresses;
623  CAListenerInterface** socketAddresses = CALibProxytest::getOptions()->getInfoServices(nrAddresses);
624  CAThread** threads = new CAThread*[nrAddresses];
625  InfoServiceHeloMsg** messages = new InfoServiceHeloMsg*[nrAddresses];
626 
627  for (UINT32 i = 0; i < nrAddresses; i++)
628  {
629  messages[i] = new InfoServiceHeloMsg();
630  messages[i]->addr = (CASocketAddrINet*)socketAddresses[i]->getAddr();
631  messages[i]->len = a_len;
632  messages[i]->strXML = a_strXML;
633  messages[i]->is = this;
634  messages[i]->requestCommand = requestCommand;
635  messages[i]->param = param;
636 #if !defined(NO_INFOSERVICE_TRHEADS)
637  threads[i] = new CAThread(a_strThreadName);
638  threads[i]->setMainLoop((THREAD_RETURN (*)(void *))a_thread);
639  threads[i]->start((void*)(messages[i]), false, true);
640 #else
641  (*a_thread)(messages[i]);
642  if (messages[i]->retVal == E_SUCCESS)
643  {
644  returnValue = E_SUCCESS;
645  }
646 #endif
647  }
648 
649  for (UINT32 i = 0; i < nrAddresses; i++)
650  {
651 #if !defined(NO_INFOSERVICE_TRHEADS)
652  if (threads[i]->join() == E_SUCCESS)
653  {
654  // CAMsg::printMsg(LOG_DEBUG,"InfoService: helo thread %u joined.\n", i);
655  if (messages[i]->retVal == E_SUCCESS)
656  {
657  returnValue = E_SUCCESS;
658  }
659  }
660  delete threads[i];
661  threads[i] = NULL;
662 #endif
663  delete messages[i]->addr;
664  messages[i]->addr = NULL;
665  delete messages[i];
666  messages[i] = NULL;
667  }
668  //Message looks senseless but please keep it because Rolf reported a helo thread deadlock.
669  //Perhaps there is a problem when the threads are joined.
670  // CAMsg::printMsg(LOG_DEBUG,"InfoService: all helo threads joined. continue.\n");
671  delete[] messages;
672  messages = NULL;
673  delete[] threads;
674  threads = NULL;
675 
676  return returnValue;
677 }
#define THREAD_RETURN
Definition: StdAfx.h:540
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
Definition: CAThread.cpp:115
SINT32 setMainLoop(THREAD_MAIN_TYP fnc)
Sets the main function which will be executed within this thread.
Definition: CAThread.hpp:148

References CAInfoService::InfoServiceHeloMsg::addr, E_SUCCESS, E_UNKNOWN, CACmdLnOptions::getInfoServices(), CALibProxytest::getOptions(), CAInfoService::InfoServiceHeloMsg::is, CAInfoService::InfoServiceHeloMsg::len, CAInfoService::InfoServiceHeloMsg::param, CAInfoService::InfoServiceHeloMsg::requestCommand, CAThread::setMainLoop(), CAThread::start(), CAInfoService::InfoServiceHeloMsg::strXML, and THREAD_RETURN.

Referenced by sendCascadeHelo(), sendMixHelo(), and sendStatus().

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

◆ sendMixHelo() [1/2]

SINT32 CAInfoService::sendMixHelo ( const UINT8 strMixHeloXML,
UINT32  len,
SINT32  requestCommand,
const UINT8 param,
const CASocketAddrINet a_socketAddress 
)
private

POSTs the HELO message for a mix to the InfoService.

Definition at line 819 of file CAInfoService.cpp.

821 {
822  UINT8* recvBuff = NULL;
823  SINT32 ret = E_SUCCESS;
824  UINT32 len = 0;
825 
826  CASocket oSocket(true);
827  UINT8 hostname[255];
828  UINT8 buffHeader[255];
829  CAHttpClient httpClient;
830 
831  UINT64 currentTimeout = MIX_TO_INFOSERVICE_TIMEOUT;
832  UINT64 startupTime, currentMillis;
833 
834  UINT32 requestType = REQUEST_TYPE_POST;
835  bool receiveAnswer = false;
836 
837  if (a_pSocketAddress == NULL)
838  {
839  goto ERR;
840  }
841 
842  if (requestCommand < 0)
843  {
844  if (m_bConfiguring)
845  {
846  requestCommand = REQUEST_COMMAND_CONFIGURE;
847  receiveAnswer = true;
848  }
849  else
850  {
851  requestCommand = REQUEST_COMMAND_HELO;
852  receiveAnswer = true;
853  }
854  }
855  else
856  if (requestCommand == REQUEST_COMMAND_MIXINFO)
857  {
858  requestType = REQUEST_TYPE_GET;
859  receiveAnswer = true;
860  }
861 
862  if (a_pSocketAddress->getIPAsStr(hostname, 255) != E_SUCCESS)
863  {
864  goto ERR;
865  }
866 
867  oSocket.setRecvBuff(255);
868  if ((ret = oSocket.connect(*a_pSocketAddress, MIX_TO_INFOSERVICE_TIMEOUT)) == E_SUCCESS)
869  {
870  httpClient.setSocket(&oSocket);
871  const char* strRequestCommand = STRINGS_REQUEST_COMMANDS[requestCommand];
872  const char* strRequestType = STRINGS_REQUEST_TYPES[requestType];
873  CAMsg::printMsg(LOG_DEBUG, "InfoService: Sending [%s] %s to InfoService %s:%d.\r\n", strRequestType, strRequestCommand, hostname, a_pSocketAddress->getPort());
874  if (requestCommand == REQUEST_COMMAND_MIXINFO)
875  {
876  sprintf((char*)buffHeader, "%s /%s%s HTTP/1.0\r\nContent-Length: %u\r\n\r\n", strRequestType, strRequestCommand, param, a_len);
877  }
878  else
879  {
880  sprintf((char*)buffHeader, "%s /%s HTTP/1.0\r\nContent-Length: %u\r\n\r\n", strRequestType, strRequestCommand, a_len);
881  }
882 
883  getcurrentTimeMillis(startupTime);
884  if (oSocket.sendFullyTimeOut(buffHeader, strlen((char*)buffHeader), currentTimeout, SEND_INFO_TIMEOUT_MS) != E_SUCCESS)
885  {
886  goto ERR;
887  }
888 
889  // CAMsg::printMsg(LOG_DEBUG,"InfoService: Sending XML data...\n");
890  getcurrentTimeMillis(currentMillis);
891  currentTimeout -= (currentMillis - startupTime);
892  if (currentTimeout <= 0 ||
893  oSocket.sendFullyTimeOut(a_strMixHeloXML, a_len, currentTimeout, SEND_INFO_TIMEOUT_MS) != E_SUCCESS)
894  {
895  goto ERR;
896  }
897 
898  if (receiveAnswer)
899  {
900  // CAMsg::printMsg(LOG_DEBUG,"InfoService: Parsing header...\n");
901  getcurrentTimeMillis(currentMillis);
902  currentTimeout -= (currentMillis - startupTime);
903  if (currentTimeout <= 0 || httpClient.parseHTTPHeader(&len) != E_SUCCESS)
904  {
905  goto ERR;
906  }
907  // CAMsg::printMsg(LOG_DEBUG,"InfoService: Header parsed!\n");
908 
909  if (len > 0)
910  {
911  getcurrentTimeMillis(currentMillis);
912  currentTimeout -= (currentMillis - startupTime);
913 
914  recvBuff = new UINT8[len + 1];
915  CAMsg::printMsg(LOG_DEBUG, "InfoService: Receiving answer...\n");
916  if (currentTimeout <= 0 ||
917  oSocket.receiveFullyT(recvBuff, len, currentTimeout) != E_SUCCESS)
918  {
919  delete[]recvBuff;
920  recvBuff = NULL;
921  goto ERR;
922  }
923  recvBuff[len] = 0;
924  CAMsg::printMsg(LOG_DEBUG, "Received from Infoservice:\n");
925  CAMsg::printMsg(LOG_DEBUG, (char*)recvBuff);
926  CAMsg::printMsg(LOG_DEBUG, "\n");
927  }
928  }
929  oSocket.close();
930 
931  if (recvBuff != NULL)
932  {
933  delete[] recvBuff;
934  recvBuff = NULL;
935  }
936  /* REMOVED by Rolf Wendolsky on 2009-12-11 becuase this looks dangerous: each InfoService may reconfigure the Mix! Without verificaton!
937  if(recvBuff != NULL)
938  {
939  XERCES_CPP_NAMESPACE::DOMDocument* doc=parseDOMDocument(recvBuff,len);
940  delete[] recvBuff;
941  recvBuff=NULL;
942  DOMElement* root=NULL;
943  if(doc!=NULL && (root = doc->getDocumentElement()) != NULL)
944  {
945  if(equals(root->getNodeName(),"MixCascade"))
946  {
947  ret = handleConfigEvent(doc);
948  if(ret == E_SUCCESS)
949  m_bConfiguring = false;
950  else
951  return ret;
952  }
953  else if(equals(root->getNodeName(),"Mix"))
954  {
955  if(m_expectedMixRelPos < 0)
956  {
957  XMLCh* id=XMLString::transcode("id");
958  char* tmpStr=XMLString::transcode(root->getAttribute(id));
959  CAMsg::printMsg(LOG_DEBUG,"InfoService: Setting new previous mix: %s\n",tmpStr);
960  XMLString::release(&tmpStr);
961  XMLString::release(&id);
962  CALibProxytest::getOptions()->setPrevMix(doc);
963  }
964  else if(m_expectedMixRelPos > 0)
965  {
966  XMLCh* id=XMLString::transcode("id");
967  char* tmpStr=XMLString::transcode(root->getAttribute(id));
968  CAMsg::printMsg(LOG_DEBUG,"InfoService: Setting new next mix: %s\n",tmpStr);
969  XMLString::release(&id);
970  XMLString::release(&tmpStr);
971  CALibProxytest::getOptions()->setNextMix(doc);
972  }
973  }
974  CAMsg::printMsg(LOG_DEBUG,"InfoService::sendMixHelo(): XML infoservice doc 0x%x not needed anymore.\n",
975  doc);
976  }
977  else
978  {
979  CAMsg::printMsg(LOG_CRIT,"InfoService: Error parsing answer from InfoService!\n");
980  }
981  }*/
982  return E_SUCCESS;
983  }
984  else
985  {
986  if (ret != E_UNKNOWN)
987  {
988  CAMsg::printMsg(LOG_ERR, "InfoService: sendMixHelo() connecting to InfoService %s:%d failed for reason: %s (%i)\n",
989  hostname, a_pSocketAddress->getPort(), GET_NET_ERROR_STR(GET_NET_ERROR), GET_NET_ERROR);
990  }
991  else
992  {
993  CAMsg::printMsg(LOG_ERR, "InfoService: sendMixHelo() connecting to InfoService %s:%d failed!\n",
994  hostname, a_pSocketAddress->getPort());
995  }
996  }
997 ERR:
998 
999  //CAMsg::printMsg(LOG_DEBUG,"InfoService: Closing socket to %s:%d due to error...\n", hostname, a_pSocketAddress->getPort());
1000  oSocket.close();
1001  //CAMsg::printMsg(LOG_DEBUG,"InfoService: Socket closed to %s:%d due to error.\n", hostname, a_pSocketAddress->getPort());
1002  return E_UNKNOWN;
1003 }
const char * STRINGS_REQUEST_TYPES[NR_REQUEST_TYPES]
const char * STRINGS_REQUEST_COMMANDS[NR_REQUEST_COMMANDS]
#define REQUEST_TYPE_POST
#define REQUEST_COMMAND_MIXINFO
#define REQUEST_COMMAND_CONFIGURE
#define REQUEST_TYPE_GET
#define REQUEST_COMMAND_HELO
#define GET_NET_ERROR
Definition: StdAfx.h:469
#define GET_NET_ERROR_STR(x)
Definition: StdAfx.h:471

References CASocket::close(), CASocket::connect(), E_SUCCESS, E_UNKNOWN, GET_NET_ERROR, GET_NET_ERROR_STR, getcurrentTimeMillis(), CASocketAddrINet::getIPAsStr(), CASocketAddrINet::getPort(), len, m_bConfiguring, MIX_TO_INFOSERVICE_TIMEOUT, CAHttpClient::parseHTTPHeader(), CAMsg::printMsg(), CASocket::receiveFullyT(), REQUEST_COMMAND_CONFIGURE, REQUEST_COMMAND_HELO, REQUEST_COMMAND_MIXINFO, REQUEST_TYPE_GET, REQUEST_TYPE_POST, SEND_INFO_TIMEOUT_MS, CASocket::sendFullyTimeOut(), CASocket::setRecvBuff(), CAHttpClient::setSocket(), STRINGS_REQUEST_COMMANDS, and STRINGS_REQUEST_TYPES.

Here is the call graph for this function:

◆ sendMixHelo() [2/2]

SINT32 CAInfoService::sendMixHelo ( SINT32  requestCommand = -1,
const UINT8 param = NULL 
)

Definition at line 749 of file CAInfoService.cpp.

750 {
751  UINT32 len;
752  SINT32 ret;
753  UINT8* strMixHeloXML = getMixHeloXMLAsString(len);
754 
755  if (strMixHeloXML == NULL)
756  {
757  CAMsg::printMsg(LOG_DEBUG, "InfoService:sendMixHelo() -- Error: getMixHeloXMLAsString() returned NULL!\n");
758  return E_UNKNOWN;
759  }
760 
761  // CAMsg::printMsg(LOG_DEBUG,"InfoService:sendMixHelo(): Initialising helo thread...\n");
762  ret = sendHelo(strMixHeloXML, len, TMixHelo, (UINT8*)"Mix Helo Thread", requestCommand, param);
763  // CAMsg::printMsg(LOG_DEBUG,"InfoService:sendMixHelo(): Finished helo thread!\n");
764 
765  delete[] strMixHeloXML;
766  strMixHeloXML = NULL;
767  return ret;
768 }
UINT8 * getMixHeloXMLAsString(UINT32 &len)
static THREAD_RETURN TMixHelo(void *p)

References E_UNKNOWN, getMixHeloXMLAsString(), len, CAMsg::printMsg(), sendHelo(), and TMixHelo().

Referenced by InfoLoop(), and TMixHelo().

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

◆ sendOperatorTnCData()

SINT32 CAInfoService::sendOperatorTnCData ( )
private

Definition at line 1009 of file CAInfoService.cpp.

1010 {
1011  /*SINT32 ret = E_SUCCESS;
1012  UINT32 *lengths_ptr = NULL;
1013  XMLSize_t nrOfTnCs = 0;
1014  UINT32 i = 0;
1015  UINT8 **tncData = getOperatorTnCsAsStrings(&lengths_ptr, &nrOfTnCs);
1016 
1017  if(tncData != NULL)
1018  {
1019  for (;i < nrOfTnCs; i++)
1020  {
1021  #ifdef DEBUG
1022  CAMsg::printMsg(LOG_DEBUG,"InfoService:sendMixTnCData(), object: %s, len: %u\n",
1023  tncData[i], lengths_ptr[i]);
1024  #endif
1025  if( tncData[i] != NULL )
1026  {
1027  ret |= sendHelo(tncData[i], lengths_ptr[i],
1028  TMixHelo, (UINT8*)"Mix TnC Thread",
1029  REQUEST_COMMAND_TNC_DATA, NULL);
1030  delete [] tncData[i];
1031  tncData[i] = NULL;
1032  }
1033  else
1034  {
1035  CAMsg::printMsg(LOG_ERR,"InfoService:sendMixTnCData() -- Element %u is invalid!\n", (i+1) );
1036  ret |= E_UNKNOWN;
1037  }
1038 
1039  }
1040  delete [] lengths_ptr;
1041  lengths_ptr = NULL;
1042 
1043  delete [] tncData;
1044  }
1045  else
1046  {
1047  CAMsg::printMsg(LOG_DEBUG,"InfoService:sendMixTnCData() -- No TnC data specified!\n");
1048  return E_SUCCESS;
1049  }
1050  return ret;*/
1051  return E_SUCCESS;
1052 }

References E_SUCCESS.

◆ sendStatus() [1/2]

SINT32 CAInfoService::sendStatus ( bool  bIncludeCerts)

Definition at line 507 of file CAInfoService.cpp.

508 {
509  if (!CALibProxytest::getOptions()->isFirstMix())
510  {
511  return E_SUCCESS;
512  }
513 
514 
515  if (!(m_pMix->isConnected())) // && !bIncludeCerts )
516  {
517 #ifdef DEBUG
518  CAMsg::printMsg(LOG_INFO, "Mix not connected. Skipping status.\n");
519 #endif
520  return E_UNKNOWN;
521  }
522 
523  UINT32 len = 0;
524  SINT32 ret = E_UNKNOWN;
525  UINT8* strStatusXML = getStatusXMLAsString(bIncludeCerts, len);
526 
527  if (strStatusXML == NULL)
528  {
529  return E_UNKNOWN;
530  }
531 
532  if (!(m_pMix->isConnected()))
533  {
534  CAMsg::printMsg(LOG_INFO, "Mix not connected. Skip sending already created status message.\n");
535  }
536  else
537  {
538  ret = sendHelo(strStatusXML, len, TCascadeStatus, (UINT8*)"Status Thread", REQUEST_COMMAND_STATUS);
539  }
540 
541  delete[] strStatusXML;
542  strStatusXML = NULL;
543  return ret;
544 }
#define REQUEST_COMMAND_STATUS
static THREAD_RETURN TCascadeStatus(void *p)
UINT8 * getStatusXMLAsString(bool bIncludeCerts, UINT32 &len)

References E_SUCCESS, E_UNKNOWN, CALibProxytest::getOptions(), getStatusXMLAsString(), CAMix::isConnected(), len, m_pMix, CAMsg::printMsg(), REQUEST_COMMAND_STATUS, sendHelo(), and TCascadeStatus().

Referenced by InfoLoop(), and TCascadeStatus().

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

◆ sendStatus() [2/2]

SINT32 CAInfoService::sendStatus ( const UINT8 a_strStatusXML,
UINT32  a_len,
const CASocketAddrINet a_pSocketAddress 
) const
private

POSTs mix status to the InfoService.

[only first mix does this at the moment]

Return values
E_UNKNOWNif something goes wrong
E_SUCCESSotherwise todo use httpclient class

Definition at line 688 of file CAInfoService.cpp.

689 {
690  UINT8 buffHeader[512];
691  SINT32 ret = E_UNKNOWN;
692  UINT8 hostname[255];
693  UINT32 currentTimeout = MIX_TO_INFOSERVICE_TIMEOUT;
694  UINT64 startupTime, currentMillis;
695 
696 
697 #ifdef DEBUG
698  CAMsg::printMsg(LOG_DEBUG, "CAInfoService::sendStatus()\n");
699 #endif
700  if (!CALibProxytest::getOptions()->isFirstMix())
701  {
702  return E_SUCCESS;
703  }
704  CASocket oSocket(true);
705  if (a_pSocketAddress == NULL)
706  {
707  oSocket.close();
708  return E_UNKNOWN;
709  }
710 
711 
712  if (oSocket.connect(*a_pSocketAddress, MIX_TO_INFOSERVICE_TIMEOUT) != E_SUCCESS)
713  {
714  if (a_pSocketAddress->getIPAsStr(hostname, 255) == E_SUCCESS)
715  {
716  CAMsg::printMsg(LOG_DEBUG, "InfoService: Could not connect to InfoService %s:%d. Reason: %s (%i)\n",
717  hostname, a_pSocketAddress->getPort(), GET_NET_ERROR_STR(GET_NET_ERROR), GET_NET_ERROR);
718  }
719  else
720  {
721  CAMsg::printMsg(LOG_DEBUG, "InfoService: Could not connect to InfoService (host unknown) at port %d. Reason: %s (%i)\n",
722  a_pSocketAddress->getPort(), GET_NET_ERROR_STR(GET_NET_ERROR), GET_NET_ERROR);
723  }
724  oSocket.close();
725  return E_UNKNOWN;
726  }
727 
728  if (a_pSocketAddress->getIPAsStr(hostname, 255) == E_SUCCESS)
729  {
730  CAMsg::printMsg(LOG_DEBUG, "InfoService: Sending current status to InfoService %s:%d.\n", hostname, a_pSocketAddress->getPort());
731  sprintf((char*)buffHeader, "POST /feedback HTTP/1.0\r\nContent-Length: %u\r\n\r\n", a_len);
732 
733  getcurrentTimeMillis(startupTime);
734  oSocket.sendFullyTimeOut(buffHeader, strlen((char*)buffHeader), currentTimeout, SEND_INFO_TIMEOUT_MS);
735 
736  getcurrentTimeMillis(currentMillis);
737  currentTimeout -= (currentMillis - startupTime);
738  ret = oSocket.sendFullyTimeOut(a_strStatusXML, a_len, currentTimeout, SEND_INFO_TIMEOUT_MS);
739  }
740 
741  oSocket.close();
742  if (ret == E_SUCCESS)
743  {
744  return E_SUCCESS;
745  }
746  CAMsg::printMsg(LOG_DEBUG, "InfoService: Sending status failed, ret: %d \n", ret);
747  return E_UNKNOWN;
748 }

References CASocket::close(), CASocket::connect(), E_SUCCESS, E_UNKNOWN, GET_NET_ERROR, GET_NET_ERROR_STR, getcurrentTimeMillis(), CASocketAddrINet::getIPAsStr(), CALibProxytest::getOptions(), CASocketAddrINet::getPort(), MIX_TO_INFOSERVICE_TIMEOUT, CAMsg::printMsg(), SEND_INFO_TIMEOUT_MS, and CASocket::sendFullyTimeOut().

Here is the call graph for this function:

◆ setConfiguring()

void CAInfoService::setConfiguring ( bool  a_configuring)
inline

Definition at line 79 of file CAInfoService.hpp.

80  {
81  m_bConfiguring = a_configuring;
82  }

References m_bConfiguring.

Referenced by CAMix::start().

Here is the caller graph for this function:

◆ setMultiSignature()

SINT32 CAInfoService::setMultiSignature ( CAMultiSignature pMultiSignature)

Definition at line 438 of file CAInfoService.cpp.

439 {
440  m_pMultiSignature = pMultiSig;
441  return E_SUCCESS;
442 }

References E_SUCCESS, and m_pMultiSignature.

Referenced by CAMix::start().

Here is the caller graph for this function:

◆ setSerial()

void CAInfoService::setSerial ( UINT64  a_serial)
inline

Definition at line 88 of file CAInfoService.hpp.

89  {
90  m_serial = a_serial;
91  }

References m_serial.

Referenced by CAMix::start().

Here is the caller graph for this function:

◆ signal()

SINT32 CAInfoService::signal ( )

Definition at line 484 of file CAInfoService.cpp.

485 {
486  m_pLoopCV->lock();
487  m_pLoopCV->signal();
488  m_pLoopCV->unlock();
489  return E_SUCCESS;
490 }
SINT32 signal()
Signals this object.

References E_SUCCESS, CAMutex::lock(), m_pLoopCV, CAConditionVariable::signal(), and CAMutex::unlock().

Referenced by CAMix::start().

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

◆ start()

SINT32 CAInfoService::start ( )

Definition at line 466 of file CAInfoService.cpp.

467 {
468  if (m_pMultiSignature == NULL)
469  {
470  return E_UNKNOWN;
471  }
472  m_bRun = true;
474  m_minuts = 1;
476 #ifdef DEBUG
477  CAMsg::printMsg(LOG_DEBUG, "CAInfoService::start() - starting InfoService thread\n");
478 #endif
479 
480  return m_pthreadRunLoop->start(this);
481 }
static THREAD_RETURN InfoLoop(void *p)

References E_UNKNOWN, InfoLoop(), m_bRun, m_lastMixedPackets, m_minuts, m_pMultiSignature, m_pthreadRunLoop, CAMsg::printMsg(), set64(), CAThread::setMainLoop(), and CAThread::start().

Referenced by CAMix::start().

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

◆ stop()

SINT32 CAInfoService::stop ( )

Definition at line 492 of file CAInfoService.cpp.

493 {
494  if (m_bRun)
495  {
496  m_bRun = false;
497  /* Interrupt this thread */
498  m_pLoopCV->lock();
499  m_pLoopCV->signal();
500  m_pLoopCV->unlock();
501 
503  }
504  return E_SUCCESS;
505 }
SINT32 join()
Waits for the main function to finish execution.
Definition: CAThread.cpp:187

References E_SUCCESS, CAThread::join(), CAMutex::lock(), m_bRun, m_pLoopCV, m_pthreadRunLoop, CAConditionVariable::signal(), and CAMutex::unlock().

Referenced by CAFirstMix::clean(), CAFirstMixA::shutDown(), CAMix::start(), and ~CAInfoService().

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

◆ TCascadeHelo()

THREAD_RETURN CAInfoService::TCascadeHelo ( void *  p)
staticprivate

Definition at line 291 of file CAInfoService.cpp.

292 {
293  INIT_STACK;
294  BEGIN_STACK("CAInfoService::TCascadeHelo");
295 
296  InfoServiceHeloMsg* message = (InfoServiceHeloMsg*)p;
297  message->retVal = message->is->sendCascadeHelo(message->strXML, message->len, message->addr);
298  FINISH_STACK("CAInfoService::TCascadeHelo");
300 }

References CAInfoService::InfoServiceHeloMsg::addr, BEGIN_STACK, FINISH_STACK, INIT_STACK, CAInfoService::InfoServiceHeloMsg::is, CAInfoService::InfoServiceHeloMsg::len, CAInfoService::InfoServiceHeloMsg::retVal, sendCascadeHelo(), CAInfoService::InfoServiceHeloMsg::strXML, and THREAD_RETURN_SUCCESS.

Referenced by sendCascadeHelo().

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

◆ TCascadeStatus()

THREAD_RETURN CAInfoService::TCascadeStatus ( void *  p)
staticprivate

Definition at line 264 of file CAInfoService.cpp.

265 {
266  INIT_STACK;
267  BEGIN_STACK("CAInfoService::TCascadeStatus");
268 
269  InfoServiceHeloMsg* message = (InfoServiceHeloMsg*)p;
270  message->retVal = message->is->sendStatus(message->strXML, message->len, message->addr);
271 
272  FINISH_STACK("CAInfoService::TCascadeStatus");
274 }

References CAInfoService::InfoServiceHeloMsg::addr, BEGIN_STACK, FINISH_STACK, INIT_STACK, CAInfoService::InfoServiceHeloMsg::is, CAInfoService::InfoServiceHeloMsg::len, CAInfoService::InfoServiceHeloMsg::retVal, sendStatus(), CAInfoService::InfoServiceHeloMsg::strXML, and THREAD_RETURN_SUCCESS.

Referenced by sendStatus().

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

◆ TMixHelo()

THREAD_RETURN CAInfoService::TMixHelo ( void *  p)
staticprivate

Definition at line 276 of file CAInfoService.cpp.

277 {
278  INIT_STACK;
279  BEGIN_STACK("CAInfoService::TMixHelo");
280 
281  InfoServiceHeloMsg* message = (InfoServiceHeloMsg*)p;
282  message->retVal = message->is->sendMixHelo(message->strXML, message->len, message->requestCommand, message->param, message->addr);
283 
284  FINISH_STACK("CAInfoService::TMixHelo");
286 }

References CAInfoService::InfoServiceHeloMsg::addr, BEGIN_STACK, FINISH_STACK, INIT_STACK, CAInfoService::InfoServiceHeloMsg::is, CAInfoService::InfoServiceHeloMsg::len, CAInfoService::InfoServiceHeloMsg::param, CAInfoService::InfoServiceHeloMsg::requestCommand, CAInfoService::InfoServiceHeloMsg::retVal, sendMixHelo(), CAInfoService::InfoServiceHeloMsg::strXML, and THREAD_RETURN_SUCCESS.

Referenced by sendMixHelo().

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

◆ xmlDocToStringWithSignature()

UINT8 * CAInfoService::xmlDocToStringWithSignature ( DOMNode *  a_node,
UINT32 a_len,
bool  bIncludeCerts 
)
private

Definition at line 792 of file CAInfoService.cpp.

793 {
794  a_len = 0;
795 
796  UINT32 sendBuffLen = 0;
797  UINT8* sendBuff = NULL;
798 
799  if (a_node == NULL)
800  {
801  return NULL;
802  }
803  if (m_pMultiSignature->signXML(a_node, bIncludeCerts) != E_SUCCESS)
804  {
805  return NULL;
806  }
807 
808  sendBuff = DOM_Output::dumpToMem(a_node, &sendBuffLen);
809  if (sendBuff == NULL)
810  {
811  return NULL;
812  }
813  a_len = sendBuffLen;
814  return sendBuff;
815 }

References DOM_Output::dumpToMem(), E_SUCCESS, m_pMultiSignature, and CAMultiSignature::signXML().

Referenced by getMixHeloXMLAsString(), and getOperatorTnCsAsStrings().

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

Member Data Documentation

◆ m_bConfiguring

bool CAInfoService::m_bConfiguring
private

Definition at line 151 of file CAInfoService.hpp.

Referenced by isConfiguring(), sendCascadeHelo(), sendMixHelo(), and setConfiguring().

◆ m_bRun

volatile bool CAInfoService::m_bRun
private

Definition at line 149 of file CAInfoService.hpp.

Referenced by CAInfoService(), isRunning(), start(), and stop().

◆ m_expectedMixRelPos

SINT32 CAInfoService::m_expectedMixRelPos
private

Definition at line 157 of file CAInfoService.hpp.

Referenced by CAInfoService().

◆ m_lastMixedPackets

UINT64 CAInfoService::m_lastMixedPackets
private

Definition at line 155 of file CAInfoService.hpp.

Referenced by CAInfoService(), getStatusXMLAsString(), and start().

◆ m_minuts

UINT32 CAInfoService::m_minuts
private

Definition at line 156 of file CAInfoService.hpp.

Referenced by CAInfoService(), getStatusXMLAsString(), and start().

◆ m_pLoopCV

CAConditionVariable* CAInfoService::m_pLoopCV
private

Definition at line 153 of file CAInfoService.hpp.

Referenced by CAInfoService(), InfoLoop(), signal(), stop(), and ~CAInfoService().

◆ m_pMix

CAMix* CAInfoService::m_pMix
private

◆ m_pMultiSignature

CAMultiSignature* CAInfoService::m_pMultiSignature
private

◆ m_pthreadRunLoop

CAThread* CAInfoService::m_pthreadRunLoop
private

Definition at line 158 of file CAInfoService.hpp.

Referenced by CAInfoService(), start(), stop(), and ~CAInfoService().

◆ m_serial

UINT64 CAInfoService::m_serial
private

Definition at line 150 of file CAInfoService.hpp.

Referenced by getCascadeHeloXMLAsString(), getMixHeloXMLAsString(), and setSerial().

◆ MINUTE

const UINT64 CAInfoService::MINUTE = 60
static

Definition at line 162 of file CAInfoService.hpp.

◆ REPEAT_ON_STATUS_SENT_ERROR

const UINT32 CAInfoService::REPEAT_ON_STATUS_SENT_ERROR = 3
static

Definition at line 168 of file CAInfoService.hpp.

Referenced by InfoLoop().

◆ SEND_CASCADE_INFO_WAIT

const UINT64 CAInfoService::SEND_CASCADE_INFO_WAIT = MINUTE * 10
static

Definition at line 164 of file CAInfoService.hpp.

Referenced by InfoLoop().

◆ SEND_INFO_TIMEOUT_MS

const UINT32 CAInfoService::SEND_INFO_TIMEOUT_MS = 3000
static

Definition at line 167 of file CAInfoService.hpp.

Referenced by sendCascadeHelo(), sendMixHelo(), and sendStatus().

◆ SEND_LOOP_SLEEP

const UINT64 CAInfoService::SEND_LOOP_SLEEP = 60
static

Definition at line 163 of file CAInfoService.hpp.

Referenced by InfoLoop().

◆ SEND_MIX_INFO_WAIT

const UINT64 CAInfoService::SEND_MIX_INFO_WAIT = MINUTE * 10
static

Definition at line 165 of file CAInfoService.hpp.

Referenced by InfoLoop().

◆ SEND_STATUS_INFO_WAIT

const UINT64 CAInfoService::SEND_STATUS_INFO_WAIT = MINUTE
static

Definition at line 166 of file CAInfoService.hpp.

Referenced by InfoLoop().


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