49 #define JAP_DIGEST_LENGTH 28
112 new Hashtable((
UINT32 (*)(
void *))Hashtable::hashUINT64, (
SINT32 (*)(
void *,
void *))Hashtable::compareUINT64, 2000);
115 new Hashtable((
UINT32 (*)(
void *))Hashtable::stringHash, (
SINT32 (*)(
void *,
void *))Hashtable::stringCompare);
182 CAMsg::printMsg( LOG_DEBUG,
"CAAccountingInstance: Clearing accounts hashtable...\n");
184 CAMsg::printMsg( LOG_DEBUG,
"CAAccountingInstance: Deleting accounts hashtable...\n" );
190 CAMsg::printMsg( LOG_DEBUG,
"CAAccountingInstance: Accounts hashtable deleted.\n" );
201 m_certHashCC->clear(HASH_EMPTY_NONE, HASH_EMPTY_DELETE);
228 if (pHashEntry == NULL)
235 if (pAccInfo == NULL)
257 CAMsg::printMsg(LOG_CRIT,
"CAAccountingInstance: Trying to access Hashtable after it has been disposed!!.\n");
269 BEGIN_STACK(
"CAAccountingInstance::processThread");
272 bool bDelete =
false;
273 DOMElement *elem = item->
pDomDoc->getDocumentElement();
288 CAMsg::printMsg(LOG_INFO,
"CAAccountingInstance: Deleting account entry from AI thread.\n");
293 CAMsg::printMsg(LOG_CRIT,
"CAAccountingInstance: AI thread found negative handle queue!\n");
338 BEGIN_STACK(
"CAAccountingInstance::handleJapPacket");
363 CAMsg::printMsg(LOG_ERR,
"CAAccountingInstance: User violates login protocol");
376 if (a_bControlMessage)
387 IncrementShmPacketCount();
406 SAVE_STACK(
"CAAccountingInstance::handleJapPacket",
"before accounts hash");
437 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: Fixing bytes from outdated CC for account %s...\n", tmp);
439 CAXMLCostConfirmation * pCC = NULL;
443 if(dbInterface != NULL)
467 CAMsg::printMsg(LOG_ERR,
"CAAccountingInstance: While trying to fix bytes from outdated CC,"
468 "another CC was received! Waiting for settlement... \n");
475 CAMsg::printMsg(LOG_ERR,
"CAAccountingInstance: Bytes from outdated CC could not be fixed!\n");
496 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: Account %llu empty with %d prepaid bytes, (transferred bytes: %llu, confirmed bytes: %llu)!\n",
516 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: Kicking out user with account %llu due to database error...\n", pAccInfo->
accountNumber);
528 CAMsg::printMsg(LOG_CRIT,
"CAAccountingInstance: handleJapPacket %s,%s did not find user login hash entry for account %llu, owner/accInfo: %p/%p!\n",
529 (a_bMessageToJAP ?
"downstream" :
"upstream"),
530 (a_bControlMessage ?
"ctl" :
"data"),
549 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: Account %llu empty! Kicking out user...\n",
570 SAVE_STACK(
"CAAccountingInstance::handleJapPacket",
"before err");
597 CAMsg::printMsg(LOG_ERR,
"CAAccountingInstance: Hard limit of %d bytes triggered in %d seconds \n",
603 || (prepaidBytes < 0 && (
UINT32)(prepaidBytes * (-1)) >= prepaidInterval) )
609 strReason =
"timeout";
613 strReason =
"negative prepaid interval exceeded";
616 "to send cost confirmation (HARDLIMIT EXCEEDED, %s). "
617 "PrepaidBytes were: %d\n", strReason, prepaidBytes);
663 if (pAccInfo == NULL)
673 if ((prepaidBytes > 0) && (prepaidBytes & 0x7FFFFFFF00000000LL))
675 CAMsg::printMsg(LOG_CRIT,
"PrepaidBytes overflow: %lld\n", prepaidBytes);
678 return (
SINT32) prepaidBytes;
718 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: should kick out user with account %s now...\n", tmp);
751 XERCES_CPP_NAMESPACE::DOMDocument* doc=NULL;
756 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: before prepare Kickout send...\n");
766 CAMsg::printMsg(LOG_CRIT,
"AccountingInstance: Should send error message, but none is available!\n");
775 XERCES_CPP_NAMESPACE::DOMDocument* doc=NULL;
780 CAMsg::printMsg(LOG_ERR,
"cannot send initial CC request, ret: %d\n", ret);
785 UINT8 debugout[3000];
787 debugout[debuglen] = 0;
788 CAMsg::printMsg(LOG_DEBUG,
"the CC sent looks like this: %s \n",debugout);
802 BEGIN_STACK(
"CAAccountingInstance::sendCCRequest");
804 XERCES_CPP_NAMESPACE::DOMDocument* doc=NULL;
825 UINT8 debugout[3000];
827 debugout[debuglen] = 0;
828 CAMsg::printMsg(LOG_DEBUG,
"the CC sent looks like this: %s \n",debugout);
852 for (
UINT32 i = 0; i < pCC->getNumberOfHashes(); i++)
854 certHash = pCC->getPriceCertHash(i);
895 elemRoot->appendChild(elemCC);
898 elemCC->appendChild(elemAiName);
902 XERCES_CPP_NAMESPACE::DOMDocument* cascadeInfoDoc=NULL;
905 DOMElement* cascadeInfoElem = cascadeInfoDoc->getDocumentElement();
907 UINT32 nrOfMixes = allMixes->getLength();
908 DOMNode** mixNodes =
new DOMNode*[nrOfMixes];
910 DOMNode* curMixNode=NULL;
911 for (
UINT32 i = 0, j = 0, count = nrOfMixes; i < count; i++, j++){
913 curMixNode = allMixes->item(i);
922 UINT8 digest[SHA_DIGEST_LENGTH];
926 DOMNode* skiNode=NULL;
927 for (
UINT32 i = 0; i < nrOfMixes; i++){
936 SHA1(out,outlen,digest);
942 memset(tmpBuff, 0,
len+1);
960 allSkis[i] = (
UINT8*) XMLString::transcode(skiNode->getFirstChild()->getNodeValue());
966 for (
UINT32 j = 0; j < nrOfMixes; j++)
972 "Too many/too long hash values, ran out of allocated memory\n");
986 DOMElement* elemCert=NULL;
987 for (
UINT32 i = 0; i < nrOfMixes; i++)
999 elemPriceCerts->appendChild(elemCert);
1001 elemCC->appendChild(elemPriceCerts);
1022 if( (pCC == NULL) || (pCC->getXMLDocument() == NULL) ||
1023 (pCC->getXMLDocument()->getDocumentElement() == NULL) )
1025 CAMsg::printMsg(LOG_ERR,
"Error creating initial CCrequest (pCC ref: %p)\n", pCC);
1028 DOMNode* elemCC=NULL;
1031 DOMNode *ccRoot = doc->importNode(pCC->getXMLDocument()->getDocumentElement(),
true);
1041 doc->getDocumentElement()->replaceChild(ccRoot, elemCC);
1042 doc->getDocumentElement()->appendChild(elemPrepaidBytes);
1049 BEGIN_STACK(
"CAAccountingInstance::makeCCRequest");
1051 DOMNode* elemCC=NULL;
1060 elemCC->appendChild(elemAccount);
1063 elemCC->appendChild(elemBytes);
1080 doc->appendChild(elemRoot);
1084 UINT8 debugout[3000];
1086 debugout[debuglen] = 0;
1087 CAMsg::printMsg(LOG_DEBUG,
"the AILogin Confirmation sent looks like this: %s \n",debugout);
1109 BEGIN_STACK(
"CAAccountingInstance::processJapMessage");
1111 if (pHashEntry == NULL)
1116 DOMElement* root = a_DomDoc->getDocumentElement();
1119 CAMsg::printMsg(LOG_DEBUG,
"ProcessJapMessage: getDocument Element is null!!!\n" );
1122 char* docElementName = XMLString::transcode(root->getTagName());
1127 if ( strcmp( docElementName,
"AccountCertificate" ) == 0 )
1130 CAMsg::printMsg( LOG_DEBUG,
"Received an AccountCertificate. Calling handleAccountCertificate()\n" );
1136 else if ( strcmp( docElementName,
"Response" ) == 0)
1139 CAMsg::printMsg( LOG_DEBUG,
"Received a Response (challenge-response)\n" );
1161 else if ( strcmp( docElementName,
"CC" ) == 0 )
1164 CAMsg::printMsg( LOG_DEBUG,
"Received a CC. Calling handleCostConfirmation()\n" );
1177 "AI Received XML message with unknown root element \"%s\". This is not accepted!\n",
1181 SAVE_STACK(
"CAAccountingInstance::processJapMessage",
"error");
1182 XMLString::release(&docElementName);
1187 XMLString::release(&docElementName);
1214 FINISH_STACK(
"CAAccountingInstance::processJapMessage");
1219 UINT32 handlerReturnValue,
1220 bool lastLoginMessage)
1237 XERCES_CPP_NAMESPACE::DOMDocument *errDoc = NULL;
1262 (
UINT8*)
"You are already logged in.");
1268 (
UINT8 *)
"AI login: error occured while connecting, access denied");
1288 else if(lastLoginMessage)
1302 if(pHashEntry == NULL)
1328 UINT64 accountNumber = 0;
1344 if(pHashEntry == NULL)
1370 CAMsg::printMsg(LOG_WARNING,
"CAAccountingInstance::finishLoginProcess: No CC was settled for account %llu. Using DB status %u.\n",
1371 accountNumber, statusCode);
1377 CAMsg::printMsg(LOG_WARNING,
"CAAccountingInstance::finishLoginProcess: No CC was settled for account %llu. Could not fetch status from DB!.\n");
1401 XERCES_CPP_NAMESPACE::DOMDocument *errDoc = NULL;
1409 (
UINT8 *)
"AI login: access denied because your account is blocked");
1410 CAMsg::printMsg(LOG_WARNING,
"CAAccountingInstance::finishLoginProcess: Account %llu seems blocked.\n", accountNumber);
1415 (
UINT8 *)
"AI login: access denied because your account is empty");
1437 CAMsg::printMsg(LOG_WARNING,
"CAAccountingInstance::finishLoginProcess: Account %llu seems empty.\n", accountNumber);
1442 (
UINT8 *)
"AI login: access denied because your account is not valid");
1443 CAMsg::printMsg(LOG_WARNING,
"CAAccountingInstance::finishLoginProcess: Account %llu seems invalid.\n", accountNumber);
1448 (
UINT8 *)
"AI login: error occured while connecting, access denied");
1449 CAMsg::printMsg(LOG_WARNING,
"CAAccountingInstance::finishLoginProcess: Unknown error was found for account %llu.\n", accountNumber);
1494 FINISH_STACK(
"CAAccountingInstance::handleAccountCertificate");
1509 BEGIN_STACK(
"CAAccountingInstance::handleAccountCertificate");
1514 DOMElement* elGeneral=NULL;
1519 if (pAccInfo == NULL)
1535 CAMsg::printMsg(LOG_DEBUG,
"Already got an account cert. Ignoring...");
1539 (
UINT8*)
"You have already sent an Account Certificate"
1541 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
1557 CAMsg::printMsg( LOG_ERR,
"AccountCertificate has wrong or no accountnumber. Ignoring...\n");
1559 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
1579 CAMsg::printMsg( LOG_ERR,
"AccountCertificate has no Payment Instance ID. Ignoring...\n");
1581 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
1600 CAMsg::printMsg( LOG_ERR,
"AccountCertificate contains no public key. Ignoring...\n");
1602 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
1626 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
1643 CAMsg::printMsg( LOG_INFO,
"CAAccountingInstance::handleAccountCertificate(): Bad Jpi signature\n" );
1650 UINT8 * arbChallenge;
1651 UINT8 b64Challenge[ 512 ];
1657 arbChallenge =
new UINT8[222];
1670 doc->appendChild( elemRoot );
1671 elemRoot->appendChild( elemPanic );
1672 elemRoot->appendChild( elemPrepaid );
1674 SINT32 prepaidAmount = 0;
1680 if(dbInterface != NULL)
1688 SINT32 prepaidIvalLowerBound = 0;
1689 if (prepaidAmount < prepaidIvalLowerBound)
1691 prepaidAmount = prepaidIvalLowerBound;
1719 FINISH_STACK(
"CAAccountingInstance::handleChallengeResponse");
1732 BEGIN_STACK(
"CAAccountingInstance::handleChallengeResponse");
1738 UINT8 decodeBuffer[ 512 ];
1739 UINT32 decodeBufferLen = 512;
1743 SINT32 prepaidAmount = 0;
1745 CAXMLCostConfirmation* pCC = NULL;
1746 bool bSendCCRequest =
true;
1751 if (pAccInfo == NULL)
1776 CAMsg::printMsg( LOG_DEBUG,
"ChallengeResponse has wrong XML format. Ignoring\n" );
1780 DOMElement *elemClientVersion = NULL;
1782 if(elemClientVersion != NULL)
1785 UINT8 *clientVersionStr =
new UINT8[clientVersionStrLen];
1786 memset(clientVersionStr, 0, clientVersionStrLen);
1789 delete [] clientVersionStr;
1790 clientVersionStr = NULL;
1795 (clientVersionStr != NULL ? clientVersionStr : (
UINT8*)
"<not set>"));
1803 decodeBuffer[decodeBufferLen] = 0;
1805 usedLen = decodeBufferLen;
1806 decodeBufferLen = 512;
1823 UINT8 accountNrAsString[32];
1825 CAMsg::printMsg(LOG_ERR,
"Challenge-response authentication failed for account %s!\n", accountNrAsString);
1838 if(loginEntry != NULL)
1841 if(ownerRef != NULL)
1851 CAMsg::printMsg(LOG_DEBUG,
"Exiting because login is occupied for owner %p of account %llu.\n", ownerRef);
1859 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
1864 CAMsg::printMsg(LOG_DEBUG,
"Kickout was requested for owner %p of account %llu, waiting...\n", ownerRef,
1888 if(loginEntry != NULL)
1891 CAMsg::printMsg(LOG_INFO,
"finally cleaning up loginEntry %p for former owner %p of account %llu\n",
1902 CAMsg::printMsg(LOG_CRIT,
"BUG: ownerRef of an active login entry MUST NOT be null. Please report.\n");
1911 loginEntry->
count = 1;
1927 CAMsg::printMsg(LOG_DEBUG,
"Checking database for previously prepaid bytes...\n");
1930 if(dbInterface != NULL)
1947 CAMsg::printMsg(LOG_INFO,
"CC do not match current Cascade. Discarding CC.\n");
1958 CAMsg::printMsg(LOG_DEBUG,
"pAccInfo->transferredBytes is %llu, confirmedBytes: %llu, pCC->transferredBytes is %llu\n",
1966 CAMsg::printMsg(LOG_DEBUG,
"Setting confirmedBytes to %llu, pAccInfo->transferredBytes is now %s\n",
1975 CAMsg::printMsg(LOG_INFO,
"CAAccountingInstance: Cost confirmation for account %s not found in database. This seems to be a new user.\n", tmp);
2045 if (prepaidAmount > 0)
2047 CAMsg::printMsg(LOG_INFO,
"CAAccountingInstance: Got %d prepaid bytes for account nr. %s.\n",prepaidAmount, tmp);
2059 CAMsg::printMsg(LOG_ERR,
"CAAccountingInstance: Transferred bytes of %s for account %s are lower than prepaid amount! "
2060 "Maybe we lost a CC?\n",tmp2, tmp);
2067 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: No database record for prepaid bytes found for account nr. %s.\n", tmp);
2077 if(dbInterface != NULL);
2088 CAMsg::printMsg(LOG_ERR,
"CAAccountingInstance: Could not check status for account %s!\n", tmp);
2095 CAMsg::printMsg(LOG_INFO,
"CAAccountingInstance: Illegal status %u for account %llu found.\n",
2132 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: Sending pcc to sign with %llu transferred bytes\n", pCC->getTransferredBytes());
2140 pAccInfo->
bytesToConfirm = (prepaidIval - prepaidAmount) + pCC->getTransferredBytes();
2142 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: before CC request, bytesToConfirm: %llu, prepaidIval: %u, "
2143 "prepaidAmount: %d, transferred bytes: %llu\n",
2165 if (prepaidAmount > 0)
2201 FINISH_STACK(
"CAAccountingInstance::handleCostConfirmation");
2210 BEGIN_STACK(
"CAAccountingInstance::handleCostConfirmation");
2212 if (pAccInfo == NULL)
2223 "CAAccountingInstance::handleCostConfirmation Ignoring CC, restricted flags set: %s %s\n",
2237 "CAAccountingInstance::handleCostConfirmation CC was received but has not been requested! Ignoring...\n");
2243 CAXMLCostConfirmation* pCC = CAXMLCostConfirmation::getInstance(root);
2256 CAMsg::printMsg( LOG_INFO,
"CostConfirmation has INVALID SIGNATURE!\n" );
2258 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
2281 CAMsg::printMsg( LOG_INFO,
"CostConfirmation has illegal number of price cert hashes!\n" );
2283 (
UINT8*)
"CostConfirmation has illegal number of price cert hashes");
2284 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
2331 CAMsg::printMsg( LOG_INFO,
"CostConfirmation has invalid price cert hashes!\n" );
2333 (
UINT8*)
"CostConfirmation has invalid price cert hashes");
2334 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
2356 CAMsg::printMsg( LOG_DEBUG,
"received cost confirmation for %llu transferred bytes where confirmed bytes are %llu, we need %llu bytes to confirm"
2357 ", mix already counted %llu transferred bytes\n",
2364 CAMsg::printMsg( LOG_ERR,
"Warning: ignoring this CC for account %llu "
2365 "because it tries to confirm %lld prepaid bytes where only %u prepaid bytes are allowed (cc->tranferredbytes: %llu, accInfo->tranferredBytes: %llu)\n",
2371 (
UINT8*)
"More bytes confirmed than allowed.");
2372 XERCES_CPP_NAMESPACE::DOMDocument* errDoc=NULL;
2391 CAMsg::printMsg( LOG_ERR,
"CostConfirmation has insufficient number of bytes:\n");
2392 CAMsg::printMsg( LOG_ERR,
"CC->transferredBytes: %llu < confirmedBytesBytes: %llu\n", pCC->getTransferredBytes(), pAccInfo->
confirmedBytes);
2413 CAMsg::printMsg(LOG_WARNING,
"Received CostConfirmation for account %llu has no difference in bytes to current CC (%llu bytes).\n",
2425 if(dbInterface != NULL)
2434 print64(tmp,pCC->getAccountNumber());
2435 CAMsg::printMsg( LOG_INFO,
"CostConfirmation for account %s could not be stored in database!\n", tmp );
2441 CAMsg::printMsg( LOG_INFO,
"Handle CC: pCC->transBytes: %llu\n", pCC->getTransferredBytes() );
2450 UINT8 tmpStrCurrentMillis[50];
2452 print64(tmpStrCurrentMillis,currentMillis);
2453 CAMsg::printMsg(LOG_DEBUG,
"AccountingSettleThread: Settle ini: %s\n", tmpStrCurrentMillis);
2461 CAMsg::printMsg(LOG_ERR,
"Handle CC request: pAccInfo->confirmedBytes: %llu, ppAccInfo->transferredBytes: %llu\n",
2476 CAMsg::printMsg(LOG_ERR,
"AccountingSettleThread: Requested CC value has NOT been confirmed by account nr %llu! "
2477 "Received Bytes: %llu/%llu "
2478 "Client should not be allowed to login.\n",
2479 pCC->getAccountNumber(),
2480 pCC->getTransferredBytes(),
2514 BEGIN_STACK(
"CAAccountingInstance::initTableEntry");
2518 if (pHashEntry == NULL)
2520 FINISH_STACK(
"CAAccountingInstance::initTableEntry:NULL");
2527 SAVE_STACK(
"CAAccountingInstance::initTableEntry",
"After memset");
2562 BEGIN_STACK(
"CAAccountingInstance::cleanupTableEntry");
2570 if (pAccInfo == NULL)
2572 SAVE_STACK(
"CAAccountingInstance::cleanupTableEntry",
"acc info null");
2583 CAMsg::printMsg(LOG_INFO,
"cleaning up entry %p of accountno. %llu (pAccInfo ref: %p)\n",
2605 if (prepaidBytes > 0)
2607 if (prepaidBytes > prepaidInterval)
2615 "PrepaidBytes of %d for account %s are higher than prepaid interval! "
2616 "The client (owner %x) did not behave according to specification. "
2617 "Deleting prepaid bytes!\n", prepaidBytes, tmp, pHashEntry);
2630 if(dbInterface != NULL)
2647 CAMsg::printMsg(LOG_INFO,
"Cleaning: Leaving loginEntry %x cleanup of owner %x to the next owner due to double-login of a user.\n",
2672 CAMsg::printMsg(LOG_CRIT,
"CAAccountingInstance: Cleanup did not find user login hash entry!\n");
2679 CAMsg::printMsg(LOG_DEBUG,
"CAAccountingInstance: Cleanup method found account zero.\n");
2720 CAMsg::printMsg(LOG_CRIT,
"CAAccountingInstance: Cleanup method found negative handle queue!\n");
2727 delete pAccInfo->
mutex;
2728 pAccInfo->
mutex = NULL;
2738 for (
UINT32 iAccount = 0; iAccount < nrOfSurveillanceAccounts; iAccount++)
2740 if (accountNumber == surveillanceAccounts[iAccount])
2753 CAMsg::printMsg(LOG_INFO,
"CAAccountingInstance: Cleanup method sent account deletion request to AI thread!\n");
2757 FINISH_STACK(
"CAAccountingInstance::cleanupTableEntry");
2778 CAXMLCostConfirmation **allUnsettledCCs = NULL;
2782 UINT32 nrOfCCs = 0, i = 0;
2794 if(dbInterface == NULL)
2797 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: could not connect to Database. Retry later...\n");
2805 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: DB connections established!\n");
2809 *nrOfSettledCCs = nrOfCCs;
2811 if (allUnsettledCCs == NULL)
2813 CAMsg::printMsg(LOG_INFO,
"Settlement transaction %llu: thread %x looked for unsettled CCs, found no CCs to settle\n", iCurrentSettleTransactionNr, pthread_self());
2820 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction %llu: thread %x looked for unsettled CCs, found %u cost confirmations to settle\n", iCurrentSettleTransactionNr, pthread_self(), nrOfCCs);
2842 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction: could not connect to BI. Try later...\n");
2854 if(settleException != NULL)
2860 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: BI reported settlement not successful: "
2861 "code: %i, %s \n", settleException->getErrorCode(),
2862 (settleException->getDescription() != NULL ?
2863 settleException->getDescription() : (
UINT8*)
"<no description given>") );
2868 if(pErrMsgs == NULL)
2876 CAMsg::printMsg(LOG_CRIT,
"Settlement transaction: ErrorMessages are null.\n");
2882 for(i = 0; i < nrOfCCs; i++)
2884 nextEntry =
__handleSettleResult(allUnsettledCCs[i], pErrMsgs[i], dbInterface, iCurrentSettleTransactionNr);
2885 if(nextEntry != NULL)
2887 nextEntry->nextEntry = entry;
2915 CAMsg::printMsg(LOG_INFO,
"Settlement transaction %llu: Thread %x must wait to alter login table after settling (1): %llu before him in the queue\n",
2920 CAMsg::printMsg(LOG_INFO,
"Settlement transaction %llu: Thread %x may continue (1).\n", iCurrentSettleTransactionNr, pthread_self());
2924 bool debugWarn =
false;
2929 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction %llu: Apply changes to database. Other settlement transactions seem to wait...\n", iCurrentSettleTransactionNr);
2941 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction %llu: Removing settlement mutex lock. Other settlement transactions seem to wait...\n", iCurrentSettleTransactionNr);
2950 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction %llu: Entering login hashtable. Other settlement transactions seem to wait...\n", iCurrentSettleTransactionNr);
2955 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction %llu: thread %x with wait nr %llu alters hashtable.\n", iCurrentSettleTransactionNr, pthread_self(), myWaitNr);
2962 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction %llu: After commiting to login hashtable, before last lock. Other settlement transactions seem to wait...\n", iCurrentSettleTransactionNr);
2973 CAMsg::printMsg(LOG_INFO,
"Thread %x waking up next Thread. %llu are still waiting.\n", pthread_self(),
2981 if(dbInterface != NULL)
2987 if(allUnsettledCCs != NULL)
2989 for(i = 0; i < nrOfCCs; i++)
2991 delete allUnsettledCCs[i];
2992 allUnsettledCCs[i] = NULL;
2994 delete [] allUnsettledCCs;
2995 allUnsettledCCs = NULL;
2998 if(pErrMsgs != NULL)
3000 for(i = 0; i < nrOfCCs; i++)
3008 while (entry != NULL)
3015 delete settleException;
3016 settleException = NULL;
3019 CAMsg::printMsg(LOG_INFO,
"Settlement transaction %llu finished.\n", iCurrentSettleTransactionNr);
3025 UINT64 a_iCurrentSettleTransactionNr)
3027 bool bDeleteCC =
false;
3029 UINT32 authRemoveFlags = 0;
3030 UINT64 confirmedBytes = 0;
3041 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Communication with BI failed!\n");
3045 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction: BI reported error no. %d (%s)\n",
3058 if (msgConfirmedBytes)
3060 confirmedBytes = *msgConfirmedBytes;
3061 if (confirmedBytes < pCC->getTransferredBytes())
3063 diffBytes = pCC->getTransferredBytes() - confirmedBytes;
3070 print64(tmp3, pCC->getTransferredBytes());
3071 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: Received %s confirmed bytes and %s diff bytes while having %s transferred bytes!\n", tmp, tmp2, tmp3);
3075 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: Account empty, no message object received. User will be kicked out.\n");
3081 pCC->getTransferredBytes());
3083 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: settling %llu bytes for account %llu\n",
3084 pCC->getTransferredBytes(), pCC->getAccountNumber());
3098 CAXMLCostConfirmation* attachedCC = (CAXMLCostConfirmation*) pErrMsg->
getMessageObject();
3102 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: tried outdated CC, received last valid CC back\n");
3109 attachedCC->getTransferredBytes()) !=
E_SUCCESS)
3111 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Could not mark last valid CC as settled."
3112 "Maybe a new CC has been added meanwhile?\n");
3117 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: storing last valid CC in db failed!\n");
3120 confirmedBytes = attachedCC->getTransferredBytes();
3124 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: Did not receive last valid CC - maybe old Payment instance?\n");
3160 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: unusable cost confirmation was deleted\n");
3164 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: cost confirmation is unusable, but could not delete it from database\n");
3174 pCC->getTransferredBytes()) !=
E_SUCCESS)
3176 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Could not mark CC as settled. Maybe a new CC has been added meanwhile?\n");
3179 CAMsg::printMsg(LOG_INFO,
"Settlement transaction %llu: CC OK for account %llu with %llu transferred bytes!\n",
3180 a_iCurrentSettleTransactionNr, pCC->getAccountNumber(), pCC->getTransferredBytes());
3184 if (authFlags || authRemoveFlags)
3200 SettleEntry *entry = entryList, *nextEntry = NULL;
3201 while (entry != NULL && dbInterface != NULL)
3214 if (prepaidBytes > 0)
3237 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: clearing account empty status for %llu\n",
3244 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: clearing account blocked status for %llu\n",
3251 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: clearing account invalid status for %llu\n",
3266 SettleEntry *entry = entryList, *nextEntry = NULL;
3267 while (entry != NULL)
3293 BEGIN_STACK(
"CAAccountingInstance::settlementTransaction");
3297 CAXMLCostConfirmation * pCC = NULL;
3299 CAXMLCostConfirmation **allUnsettledCCs = NULL;
3308 FINISH_STACK(
"CAAccountingInstance::settlementTransaction");
3314 FINISH_STACK(
"CAAccountingInstance::settlementTransaction");
3319 if(dbInterface == NULL)
3321 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: could not connect to Database. Retry later...\n");
3323 FINISH_STACK(
"CAAccountingInstance::settlementTransaction");
3330 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: DB connections established!\n");
3336 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: finished gettings CCs, found no CCs to settle\n");
3337 if(dbInterface != NULL)
3343 FINISH_STACK(
"CAAccountingInstance::settlementTransaction");
3348 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: finished gettings CCs, found %u cost confirmations to settle\n",nrOfCCs);
3350 SAVE_STACK(
"CAAccountingInstance::settlementTransaction",
"After getting unsettled CCs");
3354 for(i = 0; i < nrOfCCs; i++)
3373 pCC = allUnsettledCCs[i];
3378 CAMsg::printMsg(LOG_CRIT,
"Settlement transaction: Cost confirmation is NULL!\n");
3383 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: Connecting to payment instance...\n");
3398 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: could not connect to BI. Try later...\n");
3407 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: successfully connected to payment instance");
3415 bool bDeleteCC =
false;
3417 UINT32 authRemoveFlags = 0;
3418 UINT64 confirmedBytes = 0;
3428 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Communication with BI failed!\n");
3432 CAMsg::printMsg(LOG_WARNING,
"Settlement transaction: BI reported error no. %d (%s)\n",
3445 if (msgConfirmedBytes)
3447 confirmedBytes = *msgConfirmedBytes;
3448 if (confirmedBytes < pCC->getTransferredBytes())
3450 diffBytes = pCC->getTransferredBytes() - confirmedBytes;
3457 print64(tmp3, pCC->getTransferredBytes());
3458 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: Received %s confirmed bytes and %s diff bytes while having %s transferred bytes!\n", tmp, tmp2, tmp3);
3462 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Account empty, but no message object received! "
3463 "This may lead to too much prepaid bytes!\n");
3469 pCC->getTransferredBytes());
3471 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: settling %llu bytes for account %llu\n",
3472 pCC->getTransferredBytes(), pCC->getAccountNumber());
3486 CAXMLCostConfirmation* attachedCC = (CAXMLCostConfirmation*) pErrMsg->
getMessageObject();
3490 CAMsg::printMsg(LOG_DEBUG,
"Settlement transaction: tried outdated CC, received last valid CC back\n");
3497 attachedCC->getTransferredBytes()) !=
E_SUCCESS)
3499 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Could not mark last valid CC as settled."
3500 "Maybe a new CC has been added meanwhile?\n");
3505 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: storing last valid CC in db failed!\n");
3508 confirmedBytes = attachedCC->getTransferredBytes();
3512 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: Did not receive last valid CC - maybe old Payment instance?\n");
3548 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: unusable cost confirmation was deleted\n");
3552 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: cost confirmation is unusable, but could not delete it from database\n");
3562 pCC->getTransferredBytes()) !=
E_SUCCESS)
3564 CAMsg::printMsg(LOG_ERR,
"Settlement transaction: Could not mark CC as settled. Maybe a new CC has been added meanwhile?\n");
3570 if (authFlags || authRemoveFlags)
3574 nextEntry->authFlags = authFlags;
3575 nextEntry->authRemoveFlags = authRemoveFlags;
3576 nextEntry->confirmedBytes = confirmedBytes;
3577 nextEntry->diffBytes = diffBytes;
3578 nextEntry->nextEntry = entry;
3588 if (pErrMsg != NULL)
3595 if(allUnsettledCCs != NULL)
3597 for(i = 0; i < nrOfCCs; i++)
3599 delete allUnsettledCCs[i];
3600 allUnsettledCCs[i] = NULL;
3602 delete [] allUnsettledCCs;
3603 allUnsettledCCs = NULL;
3606 SAVE_STACK(
"CAAccountingInstance::settlementTransaction",
"After settling unsettled CCs with BI");
3624 SAVE_STACK(
"CAAccountingInstance::settlementTransaction",
"wait for altering hashtable");
3632 CAMsg::printMsg(LOG_INFO,
"Thread %x must wait to alter login table after settling (2): %llu before him in the queue\n", pthread_self(),
3636 CAMsg::printMsg(LOG_INFO,
"Thread %x may continue (2).\n", pthread_self());
3639 SAVE_STACK(
"CAAccountingInstance::settlementTransaction",
"altering DB entries");
3640 while (entry != NULL && dbInterface != NULL)
3653 if (prepaidBytes > 0)
3676 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: clearing account empty status for %llu\n",
3683 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: clearing account blocked status for %llu\n",
3690 CAMsg::printMsg(LOG_INFO,
"Settlement transaction: clearing account invalid status for %llu\n",
3708 SAVE_STACK(
"CAAccountingInstance::settlementTransaction",
"altering hashtable");
3710 CAMsg::printMsg(LOG_DEBUG,
"Settlement thread with wait nr %llu alters hashtable.\n", myWaitNr);
3714 while (entry != NULL)
3740 SAVE_STACK(
"CAAccountingInstance::settlementTransaction",
"waking up waiting threads for altering hashtable");
3743 CAMsg::printMsg(LOG_INFO,
"Thread %x Waking up next Thread %llu are waiting.\n", pthread_self(),
3755 FINISH_STACK(
"CAAccountingInstance::settlementTransaction");
3765 bool success =
false;
3795 if (loginEntry != NULL)
3800 return accountNumber;
3808 bool success =
false;
3850 return (loginEntry->
ownerRef == ownerRef);
bool testAndSetLoginOwner(struct AccountLoginHashEntry *loginEntry, fmHashTableEntry *ownerRef)
if the current login entry isn't locked by a login thread the calling login-thread obtains ownership
bool testLoginEntryOwner(struct AccountLoginHashEntry *loginEntry, fmHashTableEntry *ownerRef)
tests whether the corresponding ownerEntry owns this loginEntry.
bool isLoginOngoing(struct AccountLoginHashEntry *loginEntry, fmHashTableEntry *ownerRef)
test whether this entry is currently resrved by an ongoing login process.
bool testLoginEntryOwner_internal(struct AccountLoginHashEntry *loginEntry, fmHashTableEntry *ownerRef)
bool resetLoginOngoing(struct AccountLoginHashEntry *loginEntry, fmHashTableEntry *ownerRef)
indicates that the ongoing login process for this entry is finished but doesn't reset ownership.
#define PREPAID_PROTO_CLIENT_VERSION
#define CRITICAL_SUBSEQUENT_BI_CONN_ERRORS
#define CRITICAL_SETTLE_FLAGS
#define HARD_LIMIT_TIMEOUT
#define CLIENT_VERSION_STR_LEN
#define MONITORING_FIRE_PAY_EVENT(e_type)
#define BEGIN_STACK(methodName)
#define FINISH_STACK(methodName)
#define SAVE_STACK(methodName, methodPosition)
SINT32 setDOMElementAttribute(DOMNode *pElem, const char *attrName, const char *value)
SINT32 getcurrentTimeMillis(UINT64 &u64Time)
Gets the current Systemtime in milli seconds.
SINT32 getDOMElementValue(const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
Returns the content of the text node(s) under elem as null-terminated C String.
SINT32 setDOMElementValue(DOMElement *pElem, SINT32 value)
UINT32 strtrim(UINT8 *s)
Removes leading and ending whitespaces (chars<=32) from a zero terminated string.
DOMNodeList * getElementsByTagName(DOMElement *pElem, const char *const name)
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
XERCES_CPP_NAMESPACE::DOMDocument * createDOMDocument()
Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in...
DOMElement * createDOMElement(XERCES_CPP_NAMESPACE::DOMDocument *pOwnerDoc, const char *const name)
Creates a new DOMElement with the given name which belongs to the DOMDocument owernDoc.
SINT32 getDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
SINT32 getcurrentTime(timespec &t)
Gets the current Systemtime in milli seconds.
void print64(UINT8 *buff, UINT64 num)
#define NUM_LOGIN_WORKER_TRHEADS
#define THREAD_RETURN_SUCCESS
SINT32 sendXMLMessage(const XERCES_CPP_NAMESPACE::DOMDocument *pDocMsg) const
Call to send a XML message via this control channel.
SINT32 toXmlDocument(XERCES_CPP_NAMESPACE::DOMDocument *&pDoc)
returns a pointer to the tagname of this XML structure's top level element.
This class encapsulates the connection to the JPI.
SINT32 terminateBIConnection()
Terminate HTTP(s) connection to the BI (JPI)
SINT32 initBIConnection()
Establishes HTTP(s) connection to the BI (JPI)
CAXMLErrorMessage ** settleAll(CAXMLCostConfirmation **CCs, UINT32 nrOfCCs, CAXMLErrorMessage **settleException)
SINT32 setPIServerConfiguration(CAXMLBI *pPiServerConfig)
CAXMLErrorMessage * settle(CAXMLCostConfirmation &cc)
Send a cost confirmation to the JPI.
SINT32 storePrepaidAmount(UINT64 accountNumber, SINT32 prepaidBytes, UINT8 *cascadeId)
static CAAccountingDBInterface * getConnection()
SINT32 storeCostConfirmation(CAXMLCostConfirmation &cc, UINT8 *ccCascade)
Creates the tables we need in the DB.
SINT32 clearAccountStatus(UINT64 a_accountNumber)
static SINT32 releaseConnection(CAAccountingDBInterface *dbIf)
SINT32 getCostConfirmation(UINT64 accountNumber, UINT8 *cascadeId, CAXMLCostConfirmation **pCC, bool &a_bSettled)
SINT32 getAccountStatus(UINT64 a_accountNumber, UINT32 &a_statusCode)
SINT32 deleteCC(UINT64 accountNumber, UINT8 *cascadeId)
if the BI reports an error while trying to settle a CC, this will be called to delete it from the dat...
SINT32 getUnsettledCostConfirmations(CAXMLCostConfirmation ***resultCCs, UINT8 *cascadeId, UINT32 *nrOfCCs, UINT32 a_maxCCs)
Fills the CAQueue with all non-settled cost confirmations.
SINT32 storeAccountStatus(UINT64 a_accountNumber, UINT32 a_statusCode)
SINT32 markAsSettled(UINT64 accountNumber, UINT8 *cascadeId, UINT64 a_transferredBytes)
Marks this account as settled.
SINT32 getPrepaidAmount(UINT64 accountNumber, UINT8 *cascadeId, bool a_bDelete)
This is the AI (accounting instance or abrechnungsinstanz in german) class.
static const SINT32 HANDLE_PACKET_CONNECTION_OK
static SettleEntry * __handleSettleResult(CAXMLCostConfirmation *pCC, CAXMLErrorMessage *pErrMsg, CAAccountingDBInterface *dbInterface, UINT64 a_iSettlementTransactionNr)
static const UINT32 MAX_SETTLED_CCS
UINT8 * m_currentCascade
current cascade (identified by the concatenated hash values of the price certificates)
static SINT32 getPrepaidBytes(tAiAccountingInfo *pAccInfos)
volatile UINT64 m_settleWaitNr
static SINT32 returnPrepareKickout(tAiAccountingInfo *pAccInfo, CAXMLErrorMessage *a_error)
UINT32 handleCostConfirmation(tAiAccountingInfo *pAccInfo, DOMElement *root)
Handles a cost confirmation sent by a jap.
static SINT32 sendAILoginConfirmation(tAiAccountingInfo *pAccInfo, const UINT32 code, UINT8 *message)
CAAccountingInstance(CAFirstMix *callingMix)
private Constructor
static SINT32 m_prepaidBytesMinimum
static SINT32 handleJapPacket_internal(fmHashTableEntry *pHashEntry, bool a_bControlMessage, bool a_bMessageToJAP)
Called by FirstMix for each incoming JAP packet.
volatile UINT64 m_nextSettleNr
static const SINT32 HANDLE_PACKET_CLOSE_CONNECTION
~CAAccountingInstance()
private destructor
static SINT32 makeInitialCCRequest(CAXMLCostConfirmation *pCC, XERCES_CPP_NAMESPACE::DOMDocument *&doc, SINT32 prepaidBytes)
new initialCCRequest containing the last CC and the prepaid bytes (this is a replacement for sending ...
static SINT32 returnKickout(tAiAccountingInfo *pAccInfo)
When receiving this message, the Mix should kick the user out immediately.
static void setPrepaidBytesToZero_internal(tAiAccountingInfo *pAccInfo)
CAAccountingSettleThread * m_pSettleThread
Signature verifying instance for BI signatures.
CAMutex * m_pMutex
this is for synchronizing the write access to the HashEntries
static void __commitSettlementToLoginTable(SettleEntry *entryList)
only for internal use during the settleTransaction because no login table locks are acquired
static const SINT32 HANDLE_PACKET_HOLD_CONNECTION
static const UINT32 MAX_TOLERATED_MULTIPLE_LOGINS
static SINT32 processJapMessage(fmHashTableEntry *pHashEntry, const XERCES_CPP_NAMESPACE::DOMDocument *a_DomDoc)
Handle a user (xml) message sent to us by the Jap through the ControlChannel.
volatile UINT32 m_seqBIConnErrors
static SINT32 handleJapPacket(fmHashTableEntry *pHashEntry, bool a_bControlMessage, bool a_bMessageToJAP)
This should be called by the FirstMix for every incoming Jap packet.
static void setPrepaidBytesToZero(tAiAccountingInfo *pAccInfo)
static SINT32 loginProcessStatus(fmHashTableEntry *pHashEntry)
UINT32 handleCostConfirmation_internal(tAiAccountingInfo *pAccInfo, DOMElement *root)
Handles a cost confirmation sent by a jap.
CAThreadPool * m_aiThreadPool
reads messages from the queue and processes them
UINT32 handleChallengeResponse(tAiAccountingInfo *pAccInfo, DOMElement *root)
Checks the response of the challenge-response auth.
static SINT32 settlementTransaction()
CAAccountingBIInterface * m_pPiInterface
the interface to the database
static SINT32 initTableEntry(fmHashTableEntry *pHashEntry)
This must be called whenever a JAP is connecting to init our per-user data structures.
static SINT32 newSettlementTransaction()
static CAAccountingInstance * ms_pInstance
Singleton: This is the reference to the only instance of this class.
static void __commitSettlementToDatabase(SettleEntry *entryList, CAAccountingDBInterface *dbInterface)
only for internal use during the settleTransaction because the global settlement lock is not acquired
UINT8 ** m_allHashes
The hash values of the Mixes ordered beginning with the AI Mix.
UINT8 * m_AiName
the name of this accounting instance
static const UINT64 PACKETS_BEFORE_NEXT_CHECK
static volatile UINT64 m_iCurrentSettleTransactionNr
UINT32 handleChallengeResponse_internal(tAiAccountingInfo *pAccInfo, DOMElement *root)
Handles the response to our challenge.
static UINT64 unlockLogin(fmHashTableEntry *ownerRef)
release login (particularly for use in error case) this function is thread-safe.
SINT32 prepareCCRequest(CAMix *callingMix, UINT8 *a_AiName)
creating the xml of a new CC is really the responsability of the CAXMLCostConfirmation class knowledg...
UINT32 handleAccountCertificate_internal(tAiAccountingInfo *pAccInfo, DOMElement *root)
Handles an account certificate of a newly connected Jap.
static SINT32 sendCCRequest(tAiAccountingInfo *pAccInfo)
UINT32 handleAccountCertificate(tAiAccountingInfo *pAccInfo, DOMElement *root)
Handles an account certificate of a newly connected Jap.
static UINT32 getAuthFlags(fmHashTableEntry *pHashEntry)
static const SINT32 HANDLE_PACKET_CONNECTION_UNCHECKED
Hashtable * m_currentAccountsHashtable
Stores the account number of all users currently logged in.
static SINT32 __newSettlementTransaction(UINT32 *nrOfSettledCCs)
bool cascadeMatchesCC(CAXMLCostConfirmation *pCC)
static THREAD_RETURN processThread(void *a_param)
The main loop of the AI thread - reads messages from the queue and starts process threads for these m...
static SINT32 cleanupTableEntry(fmHashTableEntry *pHashEntry)
This should always be called when closing a JAP connection to cleanup the data structures.
static SINT32 makeCCRequest(const UINT64 accountNumber, const UINT64 transferredBytes, XERCES_CPP_NAMESPACE::DOMDocument *&doc)
static SINT32 sendInitialCCRequest(tAiAccountingInfo *pAccInfo, CAXMLCostConfirmation *pCC, SINT32 prepaidBytes)
static UINT32 getNrOfUsers()
static const SINT32 HANDLE_PACKET_PREPARE_FOR_CLOSING_CONNECTION
CAConditionVariable * m_pSettlementMutex
static XERCES_CPP_NAMESPACE::DOMDocument * m_preparedCCRequest
static void processJapMessageLoginHelper(fmHashTableEntry *pHashEntry, UINT32 handlerReturnvalue, bool finishLogin)
static SINT32 finishLoginProcess(fmHashTableEntry *pHashEntry)
this method is for the corresponding CAFirstMix login thread to verify the result of the settlement.
A thread that settles CCs with the BI.
static SINT32 encode(const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
static SINT32 decode(const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
SINT32 getAiID(UINT8 *id, UINT32 len)
UINT32 getPrepaidInterval()
UINT32 getPaymentHardLimit()
UINT32 getPaymentSoftLimit()
SINT32 signal()
Signals this object.
SINT32 wait()
Waits for a signal or for a timeout.
CAMutex * getLoginMutex()
bool forceKickout(fmHashTableEntry *pHashTableEntry, const XERCES_CPP_NAMESPACE::DOMDocument *pErrDoc=NULL)
static CACmdLnOptions * getOptions()
SINT32 getMixCascadeInfo(XERCES_CPP_NAMESPACE::DOMDocument *&docMixCascadeInfo)
Returns the Mix-Cascade info which should be send to the InfoService.
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
static SINT32 verifyXML(const UINT8 *const in, UINT32 inlen, CACertificate *a_cert)
SINT32 verifyDER(UINT8 *in, UINT32 inlen, const UINT8 *dsaSig, const UINT32 sigLen)
Verifies an ASN.1 DER encoded SHA1-DSA signature.
SINT32 setVerifyKey(CACertificate *pCert)
Set the key for signature testing to the one include in pCert.
SINT32 verifyXML(DOMNode *node, CACertStore *pTrustedCerts=NULL)
Verifies a XML Signature under node root.
This class encapsulates an error or success message.
static const UINT32 ERR_BAD_REQUEST
static const UINT32 ERR_WRONG_DATA
static const UINT32 ERR_BAD_SIGNATURE
static const UINT32 ERR_ACCOUNT_EMPTY
static const UINT32 ERR_NO_ERROR_GIVEN
static const UINT32 ERR_WRONG_FORMAT
static const UINT32 ERR_OUTDATED_CC
static const UINT32 ERR_MULTIPLE_LOGIN
static const UINT32 ERR_DATABASE_ERROR
static const UINT32 ERR_NO_CONFIRMATION
static const UINT32 ERR_OK
static const UINT32 ERR_NO_RECORD_FOUND
void * getMessageObject()
static const UINT32 ERR_NO_BALANCE
static const UINT32 ERR_KEY_NOT_FOUND
static const UINT32 ERR_BLOCKED
static const UINT32 ERR_INTERNAL_SERVER_ERROR
static const UINT32 ERR_SUCCESS_BUT_WITH_ERRORS
static SINT32 makeCanonical(const DOMNode *node, UINT8 *buff, UINT32 *size)
Dumps the node and all childs in a 'cannonical form' into buff.
static SINT32 dumpToMem(const DOMNode *node, UINT8 *buff, UINT32 *size)
Dumps the node and all childs into buff.
void cleanup()
do necessary cleanups of libraries etc.
struct t_fmhashtableentry * ownerRef
tAiAccountingInfo * pAccInfo
void(CAAccountingInstance::* handleFunc)(tAiAccountingInfo *, DOMElement *)
XERCES_CPP_NAMESPACE::DOMDocument * pDomDoc
Structure that holds all per-user payment information Included in CAFirstMixChannelList (struct fmHas...
CASignature * pPublicKey
the signature verifying instance for this user
UINT64 bytesToConfirm
The bytes the user could confirm in the last CC sent to him.
SINT32 lastHardLimitSeconds
timestamp when last HardLimit was reached
UINT8 * pstrBIID
ID of payment instance belonging to this account.
struct t_fmhashtableentry * ownerRef
SINT32 challengeSentSeconds
timestamp when last PayRequest was sent
SINT32 authTimeoutStartSeconds
UINT8 * pChallenge
we store the challenge here to verify the response later
UINT32 authFlags
Flags, see above AUTH_*.
UINT64 sessionPackets
The number of packets transfered.
UINT64 accountNumber
the user's account number
UINT64 userID
The same value as in fmHashTableEntry.
UINT64 confirmedBytes
the number of bytes that was confirmed by the account user
CAAccountingControlChannel * pControlChannel
a pointer to the user-specific control channel object
UINT64 transferredBytes
the number of bytes that was transferred (as counted by the AI) Elmar: since last CC,...
CAConditionVariable * cleanupNotifier
tAiAccountingInfo * pAccountingInfo
#define AUTH_HARD_LIMIT_REACHED
struct t_accountinginfo tAiAccountingInfo
#define AUTH_MULTIPLE_LOGIN
#define AUTH_ACCOUNT_EMPTY
the account is empty
#define AUTH_LOGIN_NOT_FINISHED
#define AUTH_FAKE
the user tried to fake something
#define AUTH_CHALLENGE_SENT
we have sent a challenge and not yet received the response
#define AUTH_INVALID_ACCOUNT
Account does not exist.
#define AUTH_LOGIN_FAILED
#define AUTH_WAITING_FOR_FIRST_SETTLED_CC
First CC from client has not been settled yet.
#define AUTH_SENT_ACCOUNT_REQUEST
we have sent one request for an accountcertificate
#define AUTH_FATAL_ERROR
a fatal error occured earlier
#define AUTH_ACCOUNT_OK
format and signature of all received certificates was OK
#define AUTH_GOT_ACCOUNTCERT
user has sent an account certificate
#define AUTH_BLOCKED
Account has been blocked temporarly.
#define AUTH_TIMEOUT_STARTED
#define AUTH_DELETE_ENTRY
#define AUTH_SENT_CC_REQUEST
we have sent one or two CC requests
#define AUTH_LOGIN_SKIP_SETTLEMENT
#define AUTH_DATABASE
A database error occured (internal or in the BI)
#define AUTH_SETTLED_ONCE