31 #ifndef __CAACCOUNTINGINSTANCE__
32 #define __CAACCOUNTINGINSTANCE__
60 #define CHALLENGE_TIMEOUT 15
61 #define HARD_LIMIT_TIMEOUT 30
62 #define AUTH_TIMEOUT 15
63 #define CRITICAL_SUBSEQUENT_BI_CONN_ERRORS 5
65 #define CLIENT_VERSION_STR_LEN 20
66 #define PREPAID_PROTO_CLIENT_VERSION "00.10.057"
68 #define CRITICAL_SETTLE_FLAGS \
69 (AUTH_INVALID_ACCOUNT | AUTH_ACCOUNT_EMPTY | AUTH_BLOCKED | AUTH_UNKNOWN)
189 UINT64 a_iSettlementTransactionNr);
221 UINT32 handlerReturnvalue,
bool testAndSetLoginOwner(struct AccountLoginHashEntry *loginEntry, struct t_fmhashtableentry *ownerRef)
if the current login entry isn't locked by a login thread the calling login-thread obtains ownership
bool resetLoginOngoing(struct AccountLoginHashEntry *loginEntry, struct t_fmhashtableentry *ownerRef)
indicates that the ongoing login process for this entry is finished but doesn't reset ownership.
bool testLoginEntryOwner(struct AccountLoginHashEntry *loginEntry, fmHashTableEntry *ownerRef)
tests whether the corresponding ownerEntry owns this loginEntry.
bool testLoginEntryOwner_internal(struct AccountLoginHashEntry *loginEntry, struct t_fmhashtableentry *ownerRef)
bool isLoginOngoing(struct AccountLoginHashEntry *loginEntry, struct t_fmhashtableentry *ownerRef)
test whether this entry is currently resrved by an ongoing login process.
#define MONITORING_FIRE_PAY_EVENT(e_type)
This class encapsulates the connection to the JPI.
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 init(CAFirstMix *callingMix)
Returns a reference to the Singleton instance.
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 SINT32 isIPAddressBlocked(const UINT8 ip[4])
Check if an IP address is temporarily blocked by the accounting instance.
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 SINT32 makeAccountRequest(XERCES_CPP_NAMESPACE::DOMDocument *&doc)
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()
CATempIPBlockList * m_pIPBlockList
Users that get kicked out because they sent no authentication certificate get their IP appended to th...
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.
The purpose of this class is storing the IPs of JAP users who tried to hack/attack the payment system...
This class encapsulates an error or success message.
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...