Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

evarequeststart.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by yunfan                                          *
00003  *   yunfan_zg@163.com                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "evarequeststart.h"
00022 #include <string.h>
00023 #ifdef _WIN32
00024 #include <winsock.h>
00025 #else
00026 #include <arpa/inet.h>
00027 #endif
00028 
00029 EvaRequestStartPacket::EvaRequestStartPacket()
00030         : EvaPicOutPacket(QQ_05_CMD_REQUEST_START, true), requestSend(true)
00031 {
00032         cryptPosition = 12;
00033 }
00034 
00035 EvaRequestStartPacket::EvaRequestStartPacket(const EvaRequestStartPacket &rhs)
00036         : EvaPicOutPacket(rhs)
00037 {
00038         *this = rhs;
00039 }
00040 
00041 EvaRequestStartPacket &EvaRequestStartPacket::operator=(const EvaRequestStartPacket &rhs)
00042 {
00043         *((EvaPicOutPacket*)this) = (EvaPicOutPacket)rhs;
00044         sessionID = rhs.getSessionID();
00045         memcpy(md5, rhs.getMd5(), 16);
00046         requestSend = rhs.isRequestSend();
00047         return *this;
00048 }
00049 
00050 void EvaRequestStartPacket::setMd5(const unsigned char *value)
00051 {
00052         memcpy(md5, value, 16);
00053 }
00054 
00055 int EvaRequestStartPacket::putBody(unsigned char *buf)
00056 {
00057         int pos=0;
00058         unsigned int tmp4_1=1, tmp4_2=0;
00059         if(requestSend){
00060                 buf[pos++] = 0x01;
00061                 memcpy(buf+pos, md5+4, 7), pos+=7;
00062         }else{
00063                 memcpy(buf+pos, &tmp4_1, 4); pos+=4;
00064                 memcpy(buf+pos, &tmp4_2, 4); pos+=4;
00065         }
00066         
00067         tmp4_1 = htonl(sessionID);
00068         memcpy(buf+pos, &tmp4_1, 4); pos+=4;
00069         
00070         if(requestSend){
00071                 buf[pos++] = 0x04;
00072                 buf[pos++] = 0x4c;
00073         }else{
00074                 memset(buf+pos, 0, 2);pos+=2;
00075         }
00076         
00077         return pos;
00078 }
00079 
00080 
00081 /* =========================================================== */
00082 
00083 
00084 EvaRequestStartReplyPacket::EvaRequestStartReplyPacket(unsigned char *buf, int len)
00085         : EvaPicInPacket(buf, len, 12)
00086 {
00087 }
00088 
00089 EvaRequestStartReplyPacket::EvaRequestStartReplyPacket(const EvaRequestStartReplyPacket &rhs)
00090         : EvaPicInPacket(rhs)
00091 {
00092         *this = rhs;
00093 }
00094 
00095 EvaRequestStartReplyPacket &EvaRequestStartReplyPacket::operator=(const EvaRequestStartReplyPacket &rhs)
00096 {
00097         *((EvaPicInPacket*)this) = (EvaPicInPacket)rhs;
00098         sessionID = rhs.getSessionID();
00099         return *this;
00100 }
00101 
00102 void EvaRequestStartReplyPacket::parseBody()
00103 {
00104         int pos = 0;
00105         pos+=8;
00106         unsigned int tmp4;
00107         memcpy(&tmp4, decryptedBuf+pos, 4);
00108         sessionID = ntohl(tmp4);
00109 }
00110 

Generated on Mon May 15 20:48:42 2006 for libeva by  doxygen 1.4.4