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

Public Member Functions

 ~CAMsg ()
 

Static Public Member Functions

static SINT32 init ()
 
static SINT32 cleanup ()
 
static SINT32 setLogOptions (UINT32 options)
 
static SINT32 setLogLevel (UINT32 a_logLevel)
 
static const char *const getLogLevelStr ()
 
static SINT32 setMaxLogFileSize (UINT64 size)
 
static SINT32 printMsg (UINT32 typ, const char *format,...)
 Writes a given message to the log. More...
 
static SINT32 openEncryptedLog ()
 Open a log, where the logged messages are store encrypted. More...
 
static SINT32 closeEncryptedLog ()
 

Private Member Functions

 CAMsg ()
 
SINT32 openLog (UINT32 type)
 
SINT32 closeLog ()
 
SINT32 rotateLog ()
 
char * createLogFileMessage (UINT32 opt)
 
char * createLogDirMessage (UINT32 opt)
 

Private Attributes

SINT64 m_maxLogFileSize
 
UINT32 m_NrOfWrites
 
UINT32 m_uLogType
 
UINT32 m_logLevel
 
UINT32 m_lastLogFileNumber
 
bool m_alreadyOpened
 
int m_hFileEncrypted
 
int m_hFileInfo
 
char * m_strMsgBuff
 
char * m_strLogFile
 
char * m_strLogDir
 
CAMutexm_pcsPrint
 
t_LogEncCipherm_pCipher
 

Static Private Attributes

static CAMsgpMsg =NULL
 
static const char *const ms_arStrLogLevels [5] = { "CRITICAL","ERROR","WARNING","INFO","DEBUG" }
 
static const char *const m_strMsgTypes [6] ={", error ] ",", critical] ",", info ] ",", debug ] ",", special ] ",", warning ] "}
 

Constructor & Destructor Documentation

◆ CAMsg()

CAMsg::CAMsg ( )
private

◆ ~CAMsg()

CAMsg::~CAMsg ( )

Member Function Documentation

◆ cleanup()

static SINT32 CAMsg::cleanup ( )
static

References closeLog(), and E_SUCCESS.

Referenced by CALibProxytest::cleanup(), and main().

◆ closeEncryptedLog()

SINT32 CAMsg::closeEncryptedLog ( )
static

References E_SUCCESS, m_hFileEncrypted, m_pCipher, and pMsg.

Referenced by ~CAMsg().

◆ closeLog()

SINT32 CAMsg::closeLog ( )
private

◆ createLogDirMessage()

char * CAMsg::createLogDirMessage ( UINT32  opt)
private

References m_strLogDir, MSG_COMPRESSED_FILE, MSG_FILE, and pMsg.

Referenced by setLogOptions().

◆ createLogFileMessage()

char * CAMsg::createLogFileMessage ( UINT32  opt)
private

References m_strLogFile, MSG_COMPRESSED_FILE, MSG_FILE, and pMsg.

Referenced by setLogOptions().

◆ getLogLevelStr()

const char *const CAMsg::getLogLevelStr ( )
static

References m_uLogType, ms_arStrLogLevels, and pMsg.

Referenced by main().

◆ init()

static SINT32 CAMsg::init ( )
static

◆ openEncryptedLog()

SINT32 CAMsg::openEncryptedLog ( )
static

Open a log, where the logged messages are store encrypted.

The file format is as follows: NEWLINE "----Start of EncryptionKey----" NEWLINE 128 random bytes (BASE64 encoded of RSA encrpyted block) which are used as sym key (16 bytes starting form 50. byte) and IV (next 16 bytes) NEWLINE "-----End of EncryptionKey-----" NEWLINE encrpyted messages

The message is encrypted using AES-128-OFB.

References E_SUCCESS, E_UNKNOWN, CABase64::encode(), CAASymCipher::encrypt(), FILENAME_ENCRYPTEDLOG, CACmdLnOptions::getLogEncryptionKey(), CALibProxytest::getOptions(), getRandom(), S_LOGENCCIPHER::iv, S_LOGENCCIPHER::iv_off, m_hFileEncrypted, m_pCipher, myfilewrite, O_BINARY, O_LARGEFILE, S_LOGENCCIPHER::oKey, pMsg, S_IREAD, S_IWRITE, and CAASymCipher::setPublicKey().

Referenced by CACmdLnOptions::initLogging().

◆ openLog()

SINT32 CAMsg::openLog ( UINT32  type)
private

◆ printMsg()

SINT32 CAMsg::printMsg ( UINT32  type,
const char *  format,
  ... 
)
static

Writes a given message to the log.

Parameters
typetype of the log message (debug,info warning, error)
formatformat string as in printf()

<return>E_SUCCESS, if log messages was successful written</return> <return>E_UNKNOWN, in case of some error</return>

References closeLog(), E_SUCCESS, E_UNKNOWN, filesize64(), isGreater64(), isZero64(), S_LOGENCCIPHER::iv, S_LOGENCCIPHER::iv_off, CAMutex::lock(), LOG_ENCRYPTED, m_hFileEncrypted, m_hFileInfo, m_logLevel, m_maxLogFileSize, m_NrOfWrites, m_pCipher, m_pcsPrint, m_strMsgBuff, m_strMsgTypes, m_uLogType, MAX_MSG_SIZE, MSG_COMPRESSED_FILE, MSG_FILE, MSG_LOG, MSG_STDOUT, myfilewrite, S_LOGENCCIPHER::oKey, openLog(), pMsg, STRMSGTYPES_SIZE, and CAMutex::unlock().

Referenced by CAAccountingDBInterface::__checkCountAllQuery(), CAAccountingDBInterface::__clearAccountStatus(), CAAccountingInstance::__commitSettlementToDatabase(), CAAccountingDBInterface::__deleteCC(), CAAccountingDBInterface::__getAccountStatus(), CAAccountingDBInterface::__getCostConfirmation(), CAAccountingDBInterface::__getPrepaidAmount(), CAAccountingDBInterface::__getUnsettledCostConfirmations(), CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::__newSettlementTransaction(), CAAccountingDBInterface::__storeAccountStatus(), CAAccountingDBInterface::__storeCostConfirmation(), CAAccountingDBInterface::__storePrepaidAmount(), CASocket::accept(), CAFirstMixA::accountTrafficDownstream(), CAFirstMixA::accountTrafficUpstream(), CAQueue::add(), CAFirstMixChannelList::addChannel(), CACmdLnOptions::addMixIdToMixInfo(), CAMix::addMixInfo(), CAThreadPool::addRequest(), TermsAndConditions::addTranslation(), CACmdLnOptions::appendMixInfo_internal(), CAAccountingControlChannel::CAAccountingControlChannel(), CAAccountingInstance::CAAccountingInstance(), CAAccountingSettleThread::CAAccountingSettleThread(), CAReplayControlChannel::CAReplayControlChannel(), CAReplayCtrlChannelMsgProc::CAReplayCtrlChannelMsgProc(), CAAccountingInstance::cascadeMatchesCC(), CAMix::checkCompatibility(), CAAccountingDBInterface::checkConnectionStatus(), checkSizesOfBaseTypes(), CAFirstMixA::checkUserConnections(), CAMiddleMix::clean(), CALastMix::clean(), CAFirstMix::clean(), CALibProxytest::cleanup(), CAAccountingDBInterface::cleanup(), cleanup(), CAAccountingInstance::cleanupTableEntry(), CATempIPBlockList::cleanupThreadMainLoop(), CASocket::close(), CAFirstMixA::closeConnection(), CASocket::connect(), CAMiddleMix::connectToNextMix(), CAFirstMix::connectToNextMix(), CASocket::create(), CACmdLnOptions::createSockets(), CATLSClientSocket::doTLSConnect(), CAFirstMix::doUserLogin_internal(), CAAccountingInstance::finishLoginProcess(), CAFirstMixA::finishPacket(), fm_loopAcceptUsers(), fm_loopLog(), fm_loopReadFromMix(), fm_loopSendToMix(), CAAccountingDBInterface::getConnection(), CACmdLnOptions::getMixXml(), CAChainTable::getNextEntryInternal(), CAAccountingInstance::getNrOfUsers(), CAInfoService::getPaymentInstance(), CAAccountingInstance::getPrepaidBytes(), CACertificate::getRawSubjectKeyIdentifier(), CACertificate::getSubjectKeyIdentifier(), CASignature::getVerifyKey(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), CAFirstMix::handleTermsAndConditionsExtension(), CAFirstMix::handleTermsAndConditionsLogin(), CAInfoService::InfoLoop(), CALocalProxy::init(), CAMiddleMix::init(), CAAccountingDBInterface::init(), CALastMix::init(), CAFirstMix::init(), CAAccountingBIInterface::initBIConnection(), CAFirstMix::initCountryStats(), CAAccountingDBInterface::initDBConnection(), CACmdLnOptions::initLogging(), CAMix::initMixCascadeInfo(), CALocalProxy::initOnce(), CAMiddleMix::initOnce(), CALastMix::initOnce(), CAMix::initOnce(), CAFirstMix::initOnce(), CAIPList::insertIP(), integrateDOMNode(), CACmdLnOptions::invokeOptionSetters(), iplist_loopDoLogCountries(), isAllowedToPassRestrictions(), CACertificate::isValid(), CAThread::join(), CASocket::listen(), lm_loopLog(), lm_loopReadFromMix(), lm_loopSendToMix(), logMemoryUsage(), CAFirstMixB::loop(), CALastMixA::loop(), CAFirstMixA::loop(), CALastMixB::loop(), CALocalProxy::loop(), CAMiddleMix::loop(), main(), CAAccountingSettleThread::mainLoop(), CAAccountingInstance::makeInitialCCRequest(), CADatabase::measurePerformance(), CAReplayDatabase::measurePerformance(), mm_loopReadFromMixAfter(), mm_loopReadFromMixBefore(), mm_loopSendToMixAfter(), mm_loopSendToMixBefore(), CADatabase::nextClock(), CAReplayDatabase::nextClock(), CAFirstMixA::notifyAllUserChannels(), CACmdLnOptions::parse(), CAHttpClient::parseHTTPHeader(), CASocket::peek(), CAFirstMixChannelList::popTimeoutEntry_internal(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGotTimestamp(), CASyncControlChannel::proccessMessage(), CASyncControlChannel::proccessMessageComplete(), CAChain::processDownstream(), CAAccountingInstance::processJapMessage(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CAAccountingInstance::processThread(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), CAAccountingControlChannel::processXMLMessage(), CAReplayCtrlChannelMsgProc::propagateCurrentReplayTimestamp(), CACmdLnOptions::readXmlConfiguration(), CATLSClientSocket::receive(), CAMuxSocket::receive(), CASocket::receive(), CALastMix::reconfigure(), CAFirstMix::reconfigure(), CALastMixB::reconfigureMix(), Hashtable::rehash(), CAAccountingDBInterface::releaseConnection(), CALastMixChannelList::removeChannel(), CACertificate::removeColons(), CAFirstMixChannelList::removeFromTimeoutList(), CAIPList::removeIP(), CAAccountingInstance::returnKickout(), CAAccountingInstance::returnPrepareKickout(), CACmdLnOptions::saveToFile(), CASocketGroup::select(), CASingleSocketGroup::select_once(), CATLSClientSocket::send(), CAMuxSocket::send(), CASocket::send(), CAAccountingInstance::sendAILoginConfirmation(), CAInfoService::sendCascadeHelo(), CAAccountingInstance::sendCCRequest(), CASocket::sendFully(), CASocket::sendFullyTimeOut(), CAHttpClient::sendGetRequest(), CAAccountingInstance::sendInitialCCRequest(), CAControlChannelDispatcher::sendMessages(), CAInfoService::sendMixHelo(), CAHttpClient::sendPostRequest(), CAInfoService::sendStatus(), CASocket::sendTimeOut(), CAFirstMixA::sendToUsers(), CACmdLnOptions::setAccountingDatabase(), CAFirstMixChannelList::setDelayParameters(), CACmdLnOptions::setDynamicMix(), CASocket::setKeepAlive(), CAFirstMixChannelList::setKickoutForced_internal(), CACmdLnOptions::setListenerInterfaces(), CACmdLnOptions::setLoggingOptions(), setLogOptions(), CACmdLnOptions::setMixCertificateVerification(), CACmdLnOptions::setNextMix(), CACmdLnOptions::setNextMixCertificate(), CACmdLnOptions::setNrOfFileDescriptors(), CACmdLnOptions::setOwnCertificate(), CACmdLnOptions::setPaymentInstance(), CAAccountingBIInterface::setPIServerConfiguration(), CACmdLnOptions::setPrepaidInterval(), CACmdLnOptions::setPrevMix(), CACmdLnOptions::setPriceCertificate(), CACmdLnOptions::setRessourceOptions(), CACmdLnOptions::setServerMonitoring(), CASignature::setSignKey(), CACmdLnOptions::setTargetInterfaces(), CALastMix::setTargets(), CACmdLnOptions::setTermsAndConditions(), CACmdLnOptions::setTermsAndConditionsList(), CACmdLnOptions::setTermsAndConditionsTemplates(), CAAccountingBIInterface::settle(), CAAccountingBIInterface::settleAll(), CAAccountingInstance::settlementTransaction(), CACmdLnOptions::setTrustedRootCertificates(), CACmdLnOptions::setUserID(), CAXMLErrorMessage::setValues(), CASignature::setVerifyKey(), CAFirstMixA::shutDown(), signal_interrupt(), signal_segv(), signal_term(), CAMultiSignature::signXML(), CAMix::signXML(), SIGUSR1_handler(), SIGUSR2_handler(), CALocalProxy::start(), CAMix::start(), CAInfoService::start(), CAThread::start(), CAInfoService::TCascadeHelo(), CAAccountingBIInterface::terminateBIConnection(), CALastMixChannelList::test(), threadReConfigure(), CAFirstMix::updateCountryStats(), CACertificate::verify(), CACertStore::verifyMixCert(), CAMultiSignature::verifyXML(), CAAccountingControlChannel::~CAAccountingControlChannel(), CAAccountingInstance::~CAAccountingInstance(), CAChain::~CAChain(), CAReplayCtrlChannelMsgProc::~CAReplayCtrlChannelMsgProc(), and CATempIPBlockList::~CATempIPBlockList().

◆ rotateLog()

SINT32 CAMsg::rotateLog ( )
private

◆ setLogLevel()

SINT32 CAMsg::setLogLevel ( UINT32  a_logLevel)
static

◆ setLogOptions()

SINT32 CAMsg::setLogOptions ( UINT32  options)
static

◆ setMaxLogFileSize()

static SINT32 CAMsg::setMaxLogFileSize ( UINT64  size)
static

References E_SUCCESS, E_UNKNOWN, m_maxLogFileSize, and set64().

Referenced by openLog().

Member Data Documentation

◆ m_alreadyOpened

bool CAMsg::m_alreadyOpened
private

Referenced by CAMsg(), and openLog().

◆ m_hFileEncrypted

int CAMsg::m_hFileEncrypted
private

◆ m_hFileInfo

int CAMsg::m_hFileInfo
private

Referenced by CAMsg(), closeLog(), openLog(), and printMsg().

◆ m_lastLogFileNumber

UINT32 CAMsg::m_lastLogFileNumber
private

Referenced by CAMsg(), and rotateLog().

◆ m_logLevel

UINT32 CAMsg::m_logLevel
private

Referenced by CAMsg(), printMsg(), and setLogLevel().

◆ m_maxLogFileSize

SINT64 CAMsg::m_maxLogFileSize
private

Referenced by CAMsg(), printMsg(), and setMaxLogFileSize().

◆ m_NrOfWrites

UINT32 CAMsg::m_NrOfWrites
private

Referenced by openLog(), and printMsg().

◆ m_pCipher

t_LogEncCipher* CAMsg::m_pCipher
private

◆ m_pcsPrint

CAMutex* CAMsg::m_pcsPrint
private

Referenced by CAMsg(), printMsg(), and ~CAMsg().

◆ m_strLogDir

char* CAMsg::m_strLogDir
private

Referenced by createLogDirMessage(), and openLog().

◆ m_strLogFile

char* CAMsg::m_strLogFile
private

◆ m_strMsgBuff

char* CAMsg::m_strMsgBuff
private

Referenced by CAMsg(), printMsg(), and ~CAMsg().

◆ m_strMsgTypes

const char *const CAMsg::m_strMsgTypes ={", error ] ",", critical] ",", info ] ",", debug ] ",", special ] ",", warning ] "}
staticprivate

Referenced by printMsg().

◆ m_uLogType

UINT32 CAMsg::m_uLogType
private

◆ ms_arStrLogLevels

const char *const CAMsg::ms_arStrLogLevels = { "CRITICAL","ERROR","WARNING","INFO","DEBUG" }
staticprivate

Referenced by getLogLevelStr(), and setLogLevel().

◆ pMsg

CAMsg * CAMsg::pMsg =NULL
staticprivate