Mixe for Privacy and Anonymity in the Internet
CAReplayControlChannel.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000, The JAP-Team 
00003 All rights reserved.
00004 Redistribution and use in source and binary forms, with or without modification, 
00005 are permitted provided that the following conditions are met:
00006 
00007   - Redistributions of source code must retain the above copyright notice, 
00008     this list of conditions and the following disclaimer.
00009 
00010   - Redistributions in binary form must reproduce the above copyright notice, 
00011     this list of conditions and the following disclaimer in the documentation and/or 
00012     other materials provided with the distribution.
00013 
00014   - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors 
00015     may be used to endorse or promote products derived from this software without specific 
00016     prior written permission. 
00017 
00018   
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 
00020 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
00021 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
00022 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
00024 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
00025 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00026 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00027 */
00028 #include "StdAfx.h"
00029 #ifdef REPLAY_DETECTION
00030 #include "CAReplayControlChannel.hpp"
00031 #include "CAReplayCtrlChannelMsgProc.hpp"
00032 
00033 CAReplayControlChannel::CAReplayControlChannel(const CAReplayCtrlChannelMsgProc* pProcessor)
00034   :CASyncControlChannel(REPLAY_CONTROL_CHANNEL_ID,false)
00035   {
00036     #ifdef DEBUG
00037       CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel - constructor - pProcessor=%p\n",pProcessor);
00038     #endif  
00039     m_pProcessor=pProcessor;
00040   }
00041 
00042 CAReplayControlChannel::~CAReplayControlChannel(void)
00043   {
00044     //@todo: delete m_MsgBuff of superclass CASyncControlChannel
00045   }
00046 
00047 SINT32 CAReplayControlChannel::processXMLMessage(const XERCES_CPP_NAMESPACE::DOMDocument* doc)
00048   {
00049     #ifdef DEBUG
00050       CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel::processXMLMessage()\n");
00051     #endif
00052     DOMElement* elemRoot=doc->getDocumentElement();
00053     if(elemRoot==NULL)
00054       return E_UNKNOWN;
00055 
00056     if(equals(elemRoot->getNodeName(),"GetTimestamp"))
00057       {
00058         UINT8 buff[255];
00059         UINT32 bufflen=255;
00060         if(getDOMElementAttribute(elemRoot,"id",buff,&bufflen)!=E_SUCCESS)
00061           return E_UNKNOWN;
00062         buff[bufflen]=0;
00063         m_pProcessor->proccessGetTimestamp(this,buff);
00064       }
00065     else if(equals(elemRoot->getNodeName(),"Mix"))
00066       {
00067         #ifdef DEBUG
00068           CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel::processXMLMessage() - got a timestamp\n");
00069         #endif
00070         UINT8 buff[255];
00071         UINT32 bufflen=255;
00072         if(getDOMElementAttribute(elemRoot,"id",buff,&bufflen)!=E_SUCCESS)
00073           return E_UNKNOWN;
00074         buff[bufflen]=0;
00075         DOMElement *child;
00076         getDOMChildByName(elemRoot,"Replay",child,false);
00077         DOMElement *elemReplayTimestamp;
00078         getDOMChildByName(child,"ReplayOffset",elemReplayTimestamp,false);
00079         UINT32 offset=0;
00080         if( getDOMElementValue(elemReplayTimestamp,offset,0)!=E_SUCCESS)
00081           return E_UNKNOWN;
00082         #ifdef DEBUG
00083           CAMsg::printMsg(LOG_DEBUG,"CAReplayControlChannel::processXMLMessage() - call m_pProcessor->proccessGotTimestamp() - m_pProcessor=%p\n",m_pProcessor);
00084         #endif
00085         m_pProcessor->proccessGotTimestamp(this,buff,offset);
00086       }
00087     return E_SUCCESS;
00088   }
00089 
00090 #endif