Mixe for Privacy and Anonymity in the Internet
CAReplayControlChannel.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 
14  - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15  may be used to endorse or promote products derived from this software without specific
16  prior written permission.
17 
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27 */
28 #include "StdAfx.h"
29 #ifdef REPLAY_DETECTION
32 
35  {
36  #ifdef DEBUG
37  CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel - constructor - pProcessor=%p\n",pProcessor);
38  #endif
39  m_pProcessor=pProcessor;
40  }
41 
43  {
44  //@todo: delete m_MsgBuff of superclass CASyncControlChannel
45  }
46 
47 SINT32 CAReplayControlChannel::processXMLMessage(const XERCES_CPP_NAMESPACE::DOMDocument* doc)
48  {
49  #ifdef DEBUG
50  CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel::processXMLMessage()\n");
51  #endif
52  DOMElement* elemRoot=doc->getDocumentElement();
53  if(elemRoot==NULL)
54  return E_UNKNOWN;
55 
56  if(equals(elemRoot->getNodeName(),"GetTimestamp"))
57  {
58  UINT8 buff[255];
59  UINT32 bufflen=255;
60  if(getDOMElementAttribute(elemRoot,"id",buff,&bufflen)!=E_SUCCESS)
61  return E_UNKNOWN;
62  buff[bufflen]=0;
64  }
65  else if(equals(elemRoot->getNodeName(),"Mix"))
66  {
67  #ifdef DEBUG
68  CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel::processXMLMessage() - got a timestamp\n");
69  #endif
70  UINT8 buff[255];
71  UINT32 bufflen=255;
72  if(getDOMElementAttribute(elemRoot,"id",buff,&bufflen)!=E_SUCCESS)
73  return E_UNKNOWN;
74  buff[bufflen]=0;
75  DOMElement *child;
76  getDOMChildByName(elemRoot,"Replay",child,false);
77  DOMElement *elemReplayTimestamp;
78  getDOMChildByName(child,"ReplayOffset",elemReplayTimestamp,false);
79  UINT32 offset=0;
80  if( getDOMElementValue(elemReplayTimestamp,offset,0)!=E_SUCCESS)
81  return E_UNKNOWN;
82  #ifdef DEBUG
83  CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel::processXMLMessage() - call m_pProcessor->proccessGotTimestamp() - m_pProcessor=%p\n",m_pProcessor);
84  #endif
85  m_pProcessor->proccessGotTimestamp(this,buff,offset);
86  }
87  return E_SUCCESS;
88  }
89 
90 #endif
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.
Definition: CAUtil.cpp:746
bool equals(const XMLCh *const e1, const char *const e2)
Definition: CAUtil.cpp:645
SINT32 getDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
Definition: CAUtil.cpp:458
SINT32 getDOMElementAttribute(const DOMNode *const elem, const char *attrName, UINT8 *value, UINT32 *len)
Definition: CAUtil.cpp:780
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
const CAReplayCtrlChannelMsgProc * m_pProcessor
virtual SINT32 processXMLMessage(const XERCES_CPP_NAMESPACE::DOMDocument *doc)
Reads incoming replay timestamps or timestamp requests and delegates them to the associated CAReplayC...
CAReplayControlChannel(const CAReplayCtrlChannelMsgProc *pProcessor)
SINT32 proccessGotTimestamp(const CAReplayControlChannel *pReceiver, const UINT8 *strMixID, const UINT32 offset) const
Proccesses a received replay timestamp rt from mix strMixID.
SINT32 proccessGetTimestamp(const CAReplayControlChannel *pReceiver, const UINT8 *strMixID) const
Proccesses a getTimeStamps request on a reply control channel.
A synchronous control channel.
#define REPLAY_CONTROL_CHANNEL_ID
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3