|
Mixe for Privacy and Anonymity in the Internet
|
A synchronous control channel. More...
#include <CASyncControlChannel.hpp>
Public Member Functions | |
| CASyncControlChannel (UINT8 id, bool bIsEncrypted) | |
| Constructor for a synchronized (e.g. | |
| virtual | ~CASyncControlChannel () |
| virtual SINT32 | processXMLMessage (const XERCES_CPP_NAMESPACE::DOMDocument *docMsg)=0 |
| Override this method to receive a XML Message. | |
Protected Member Functions | |
| SINT32 | proccessMessage (const UINT8 *msg, UINT32 msglen) |
| Processes some bytes of a message we got from the communication channel. | |
| SINT32 | proccessMessageComplete () |
| Parses the bytes in m_MsgBuff and calls processXMLMessage() | |
Protected Attributes | |
| UINT8 * | m_MsgBuff |
| buffer for assembling the parts of the message | |
| UINT32 | m_aktIndex |
| how much bytes have we received already? | |
| UINT32 | m_MsgBytesLeft |
| how much bytes we need until all bytes are received? | |
A synchronous control channel.
This means, that every control message will be proccessed imedially. You have to override proccessXMLMessage().
Definition at line 36 of file CASyncControlChannel.hpp.
| CASyncControlChannel::CASyncControlChannel | ( | UINT8 | id, |
| bool | bIsEncrypted | ||
| ) | [inline] |
Constructor for a synchronized (e.g.
received messages are proccessed imedially) control channel.
| id | id of the control channel |
| bIsEncrypted | if true the control channel is encrypted - NOT IMPLEMENTED at the moment |
Definition at line 43 of file CASyncControlChannel.hpp.
References m_aktIndex, m_MsgBuff, and m_MsgBytesLeft.
:
CAAbstractControlChannel(id,bIsEncrypted)
{
m_MsgBuff=new UINT8[0xFFFF+32];
m_aktIndex=0;
m_MsgBytesLeft=0;
}
| CASyncControlChannel::~CASyncControlChannel | ( | ) | [virtual] |
Definition at line 32 of file CASyncControlChannel.cpp.
References m_MsgBuff.
| SINT32 CASyncControlChannel::proccessMessage | ( | const UINT8 * | msg, |
| UINT32 | msglen | ||
| ) | [inline, protected, virtual] |
Processes some bytes of a message we got from the communication channel.
We reassemble this fragments in a buffer. If all parts are received we call proccessMessagesComplete()
Implements CAAbstractControlChannel.
Definition at line 59 of file CASyncControlChannel.hpp.
References CAControlChannelDispatcher::decryptMessage(), E_SUCCESS, E_UNKNOWN, CAControlChannelDispatcher::isKeySet(), m_aktIndex, CAAbstractControlChannel::m_bIsEncrypted, m_MsgBuff, m_MsgBytesLeft, CAAbstractControlChannel::m_pDispatcher, CAMsg::printMsg(), and proccessMessageComplete().
{
#ifdef DEBUG
CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessage - msglen=%u\n",msglen);
#endif
if(m_MsgBytesLeft==0)//start of new XML Msg
{
if(msglen<2)//this should never happen...
return E_UNKNOWN;
m_MsgBytesLeft=(msg[0]<<8)|msg[1];
if(m_bIsEncrypted && m_pDispatcher->isKeySet()) // note: the second check is just a workaround for the time the encryption is not support by all JAPs/Mixes
{
m_MsgBytesLeft+=16;//auth tag
}
#ifdef DEBUG
CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessage - start of a new msg of len=%u\n",m_MsgBytesLeft);
#endif
msglen-=2;
m_aktIndex=msglen;
m_MsgBytesLeft-=msglen;
memcpy(m_MsgBuff,msg+2,msglen);
}
else//received some part...
{
msglen=min(m_MsgBytesLeft,msglen);
memcpy(m_MsgBuff+m_aktIndex,msg,msglen);
m_aktIndex+=msglen;
m_MsgBytesLeft-=msglen;
}
if(m_MsgBytesLeft==0)
{//whole msg receveid
if(m_bIsEncrypted)
{
UINT8* buff=new UINT8[m_aktIndex];
memcpy(buff,m_MsgBuff,m_aktIndex);
m_pDispatcher->decryptMessage(buff,m_aktIndex,m_MsgBuff,&m_aktIndex);
delete[]buff;
}
return proccessMessageComplete();
}
return E_SUCCESS;
}
| SINT32 CASyncControlChannel::proccessMessageComplete | ( | ) | [inline, protected, virtual] |
Parses the bytes in m_MsgBuff and calls processXMLMessage()
Implements CAAbstractControlChannel.
Definition at line 103 of file CASyncControlChannel.hpp.
References E_UNKNOWN, m_aktIndex, m_MsgBuff, m_MsgBytesLeft, parseDOMDocument(), CAMsg::printMsg(), and processXMLMessage().
Referenced by proccessMessage().
{
#ifdef DEBUG
if(m_aktIndex<0xFFFF)
{
m_MsgBuff[m_aktIndex]=0;
CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessageComplete() - msg=%s\n",m_MsgBuff);
}
else
CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessageComplete() \n");
#endif
XERCES_CPP_NAMESPACE::DOMDocument* doc=parseDOMDocument(m_MsgBuff,m_aktIndex);
m_aktIndex=0;
m_MsgBytesLeft=0;
if(doc==NULL)
{
CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel:: received XML document could not be parsed\n");
return E_UNKNOWN;
}
#ifdef DEBUG
CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessageComplete() call processXMLMessage()\n");
#endif
SINT32 ret=processXMLMessage(doc);
if (doc != NULL)
{
doc->release();
doc = NULL;
}
return ret;
}
| virtual SINT32 CASyncControlChannel::processXMLMessage | ( | const XERCES_CPP_NAMESPACE::DOMDocument * | docMsg | ) | [pure virtual] |
Override this method to receive a XML Message.
Note: The DOMDocument reference is valid only within this call, i.e. will be delete afterwards form the caller! If you need to store it for later processing, make a copy of the DOMDocument using docMsg->cloneNode(true)
Implemented in CAAccountingControlChannel, and CAReplayControlChannel.
Referenced by proccessMessageComplete().
UINT32 CASyncControlChannel::m_aktIndex [protected] |
how much bytes have we received already?
Definition at line 138 of file CASyncControlChannel.hpp.
Referenced by CASyncControlChannel(), proccessMessage(), and proccessMessageComplete().
UINT8* CASyncControlChannel::m_MsgBuff [protected] |
buffer for assembling the parts of the message
Definition at line 136 of file CASyncControlChannel.hpp.
Referenced by CASyncControlChannel(), proccessMessage(), proccessMessageComplete(), and ~CASyncControlChannel().
UINT32 CASyncControlChannel::m_MsgBytesLeft [protected] |
how much bytes we need until all bytes are received?
Definition at line 140 of file CASyncControlChannel.hpp.
Referenced by CASyncControlChannel(), proccessMessage(), and proccessMessageComplete().
1.7.6.1