Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CASyncControlChannel Class Referenceabstract

A synchronous control channel. More...

#include <CASyncControlChannel.hpp>

Inheritance diagram for CASyncControlChannel:
Collaboration diagram for CASyncControlChannel:

Public Member Functions

 CASyncControlChannel (UINT8 id, bool bIsEncrypted)
 Constructor for a synchronized (e.g. More...
 
virtual ~CASyncControlChannel ()
 
virtual SINT32 processXMLMessage (const XERCES_CPP_NAMESPACE::DOMDocument *docMsg)=0
 Override this method to receive a XML Message. More...
 
- Public Member Functions inherited from CAAbstractControlChannel
 CAAbstractControlChannel (UINT8 id, bool bIsEncrypted)
 
virtual ~CAAbstractControlChannel ()
 
SINT32 sendXMLMessage (const XERCES_CPP_NAMESPACE::DOMDocument *pDocMsg) const
 Call to send a XML message via this control channel. More...
 
SINT32 sendXMLMessage (const UINT8 *msgXML, UINT32 msgLen) const
 Call to send a XML message via this control channel. More...
 
UINT32 getID () const
 Returns the id of this control channel. More...
 

Protected Member Functions

SINT32 proccessMessage (const UINT8 *msg, UINT32 msglen)
 Processes some bytes of a message we got from the communication channel. More...
 
SINT32 proccessMessageComplete ()
 Parses the bytes in m_MsgBuff and calls processXMLMessage() More...
 
- Protected Member Functions inherited from CAAbstractControlChannel
SINT32 setDispatcher (CAControlChannelDispatcher *pDispatcher)
 Sets the Dispatcher. More...
 

Protected Attributes

UINT8m_MsgBuff
 buffer for assembling the parts of the message More...
 
UINT32 m_aktIndex
 how much bytes have we received already? More...
 
UINT32 m_MsgBytesLeft
 how much bytes we need until all bytes are received? More...
 
- Protected Attributes inherited from CAAbstractControlChannel
CAControlChannelDispatcherm_pDispatcher
 
bool m_bIsEncrypted
 
UINT32 m_ID
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CASyncControlChannel()

CASyncControlChannel::CASyncControlChannel ( UINT8  id,
bool  bIsEncrypted 
)
inline

Constructor for a synchronized (e.g.

received messages are proccessed imedially) control channel.

Parameters
idid of the control channel
bIsEncryptedif true the control channel is encrypted - NOT IMPLEMENTED at the moment

Definition at line 43 of file CASyncControlChannel.hpp.

43  :
44  CAAbstractControlChannel(id,bIsEncrypted)
45  {
46  m_MsgBuff=new UINT8[0xFFFF+32];
47  m_aktIndex=0;
49  }
unsigned char UINT8
Definition: basetypedefs.h:135
CAAbstractControlChannel(UINT8 id, bool bIsEncrypted)
UINT8 * m_MsgBuff
buffer for assembling the parts of the message
UINT32 m_MsgBytesLeft
how much bytes we need until all bytes are received?
UINT32 m_aktIndex
how much bytes have we received already?

References m_aktIndex, m_MsgBuff, and m_MsgBytesLeft.

◆ ~CASyncControlChannel()

CASyncControlChannel::~CASyncControlChannel ( )
virtual

Definition at line 33 of file CASyncControlChannel.cpp.

34 {
35  delete[] m_MsgBuff;
36  m_MsgBuff = NULL;
37 }

References m_MsgBuff.

Member Function Documentation

◆ proccessMessage()

SINT32 CASyncControlChannel::proccessMessage ( const UINT8 msg,
UINT32  msglen 
)
inlineprotectedvirtual

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.

60  {
61  #ifdef DEBUG
62  CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessage - msglen=%u\n",msglen);
63  #endif
64  if(m_MsgBytesLeft==0)//start of new XML Msg
65  {
66  if(msglen<2)//this should never happen...
67  return E_UNKNOWN;
68  m_MsgBytesLeft=(msg[0]<<8)|msg[1];
69  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
70  {
71  m_MsgBytesLeft+=16;//auth tag
72  }
73  #ifdef DEBUG
74  CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessage - start of a new msg of len=%u\n",m_MsgBytesLeft);
75  #endif
76  msglen-=2;
77  m_aktIndex=msglen;
78  m_MsgBytesLeft-=msglen;
79  memcpy(m_MsgBuff,msg+2,msglen);
80  }
81  else//received some part...
82  {
83  msglen=min(m_MsgBytesLeft,msglen);
84  memcpy(m_MsgBuff+m_aktIndex,msg,msglen);
85  m_aktIndex+=msglen;
86  m_MsgBytesLeft-=msglen;
87  }
88  if(m_MsgBytesLeft==0)
89  {//whole msg receveid
90  if(m_bIsEncrypted)
91  {
92  UINT8* buff=new UINT8[m_aktIndex];
93  memcpy(buff,m_MsgBuff,m_aktIndex);
95  delete[]buff;
96  }
97  return proccessMessageComplete();
98  }
99  return E_SUCCESS;
100  }
#define min(a, b)
Definition: StdAfx.h:649
CAControlChannelDispatcher * m_pDispatcher
bool isKeySet()
Temp workaorund function - to be removed soon...
SINT32 decryptMessage(const UINT8 *in, UINT32 inlen, UINT8 *out, UINT32 *outlen)
Decrypts a control channel message, which has to be of form: cipher text auth tag - 16 bytes.
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
SINT32 proccessMessageComplete()
Parses the bytes in m_MsgBuff and calls processXMLMessage()
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References CAControlChannelDispatcher::decryptMessage(), E_SUCCESS, E_UNKNOWN, CAControlChannelDispatcher::isKeySet(), m_aktIndex, CAAbstractControlChannel::m_bIsEncrypted, m_MsgBuff, m_MsgBytesLeft, CAAbstractControlChannel::m_pDispatcher, min, CAMsg::printMsg(), and proccessMessageComplete().

Here is the call graph for this function:

◆ proccessMessageComplete()

SINT32 CASyncControlChannel::proccessMessageComplete ( )
inlineprotectedvirtual

Parses the bytes in m_MsgBuff and calls processXMLMessage()

Implements CAAbstractControlChannel.

Definition at line 103 of file CASyncControlChannel.hpp.

104  {
105  #ifdef DEBUG
106  if(m_aktIndex<0xFFFF)
107  {
109  CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessageComplete() - msg=%s\n",m_MsgBuff);
110  }
111  else
112  CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessageComplete() \n");
113  #endif
114 
115  XERCES_CPP_NAMESPACE::DOMDocument* doc=parseDOMDocument(m_MsgBuff,m_aktIndex);
116  m_aktIndex=0;
117  m_MsgBytesLeft=0;
118  if(doc==NULL)
119  {
120  CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel:: received XML document could not be parsed\n");
121  return E_UNKNOWN;
122  }
123  #ifdef DEBUG
124  CAMsg::printMsg(LOG_DEBUG,"CASyncControlChannel::proccessMessageComplete() call processXMLMessage()\n");
125  #endif
126  SINT32 ret=processXMLMessage(doc);
127  if (doc != NULL)
128  {
129  doc->release();
130  doc = NULL;
131  }
132  return ret;
133  }
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
signed int SINT32
Definition: basetypedefs.h:132
virtual SINT32 processXMLMessage(const XERCES_CPP_NAMESPACE::DOMDocument *docMsg)=0
Override this method to receive a XML Message.

References E_UNKNOWN, m_aktIndex, m_MsgBuff, m_MsgBytesLeft, parseDOMDocument(), CAMsg::printMsg(), and processXMLMessage().

Referenced by proccessMessage().

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

◆ processXMLMessage()

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 CAReplayControlChannel, and CAAccountingControlChannel.

Referenced by proccessMessageComplete().

Here is the caller graph for this function:

Member Data Documentation

◆ m_aktIndex

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().

◆ m_MsgBuff

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().

◆ m_MsgBytesLeft

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().


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