📄 evaimsend.cpp
字号:
(SendIM)(*this) = (SendIM)rhs; m_FileName = rhs.getFileName(); m_FileSize = rhs.getFileSize(); m_DirectPort = rhs.getDirectPort(); m_WanPort = rhs.getWanPort(); m_WanIp = rhs.getWanIp(); m_TransferType = rhs.getTransferType(); return *this;}int SendFileRequestPacket::putContents( unsigned char * buf ){ int pos = 0; memset(buf, 0, 11);pos+=11; // 11 bytes 0x00 buf[pos++] = m_TransferType; // transfer File or custom-picture buf[pos++] = 0x00; pos+=EvaUtil::write32(buf+pos, m_WanIp); pos+=EvaUtil::write16(buf+pos, m_WanPort); pos+=EvaUtil::write16(buf+pos, m_DirectPort); memset(buf+pos, 6, 0); pos+=6; buf[pos++] = 0x20; buf[pos++] = 0x1f; int len = strlen(m_FileName.c_str()); memcpy(buf+pos, m_FileName.c_str(), len); pos+=len; buf[pos++] = 0x1f;#ifdef WIN32 char* strSize; strSize=(char*)_alloca(100);#else char strSize[100];#endif memset(strSize, 100, 0); sprintf(strSize, "%d", m_FileSize); len = strlen(strSize); memcpy(buf+pos, strSize, len); pos+=len; buf[pos++] = 0x20; // chinese for "byte"(zijie) encoded in GB18030 buf[pos++] = 0xd7; buf[pos++] = 0xd6; buf[pos++] = 0xbd; buf[pos++] = 0xda; return pos;}/* ======================================================= */SendFileExRequestPacket::SendFileExRequestPacket( const short cmd ) : SendIM(cmd) , m_FileName("") , m_FileSize(0) , m_WanPort(0) , m_WanIp(0) , m_TransferType(QQ_TRANSFER_FILE){}SendFileExRequestPacket::SendFileExRequestPacket( const SendFileExRequestPacket & rhs ) : SendIM(rhs){ *this = rhs;}SendFileExRequestPacket & SendFileExRequestPacket::operator =( const SendFileExRequestPacket & rhs ){ (SendIM)(*this) = (SendIM)rhs; m_FileName = rhs.getFileName(); m_FileSize = rhs.getFileSize(); m_WanPort = rhs.getWanPort(); m_WanIp = rhs.getWanIp(); m_TransferType = rhs.getTransferType(); m_SessionId = rhs.getSessionId(); return *this;}int SendFileExRequestPacket::putContents( unsigned char * buf ){ int pos = 0; memset(buf, 0, 11);pos+=11; // 11 bytes 0x00 buf[pos++] = m_TransferType; // transfer File or custom-picture buf[pos++] = 0x00; buf[pos++] = 0x66; // unknown byte, 0x66, but sometimes is 0x67 // 2 bytes, 0x0000 ( if is Cancellation Request,this part still here? // no, if not QQ_IM_EX_REQUEST_CANCELED command, this part will be here.:) if(getContentType() != QQ_IM_EX_REQUEST_CANCELLED) pos+=EvaUtil::write16(buf+pos, 0x00); pos+=EvaUtil::write32(buf+pos, 1); // 4 bytes, 0x00000001 pos+=EvaUtil::write16(buf+pos, 0x00); // 2 bytes, 0x0000 pos+=EvaUtil::write16(buf+pos, m_SessionId); // can it be random number ? if(getContentType() != QQ_IM_EX_REQUEST_CANCELLED){ if(getContentType() == QQ_IM_EX_REQUEST_ACCEPTED){ pos+=EvaUtil::write32(buf+pos, m_WanIp); // big endian memset(buf+pos, 0, 8); pos+=8; }else { // this may include ip(4 bytes) and port(4 bytes) and 0x00000000(4 bytes) memset(buf+pos, 0, 12); pos+=12; } buf[pos++] = 0x02; // unknown, 0x02 or 0x04 if(getContentType() == QQ_IM_TCP_REQUEST) EvaUtil::write16(buf+pos, 0x0102); else memset(buf+pos, 0, 2); pos+=2; } pos+=EvaUtil::write32(buf+pos, 1); // unknown 4 bytes, 0x00000000 or 0x00000001 memset(buf+pos, 0, 2); pos+=2; if(getContentType() == QQ_IM_EX_REQUEST_ACCEPTED){ // QQ_IM_EX_REQUEST_ACCEPTED finished here memset(buf+pos, 0, 2); pos+=2; return pos; } if(getContentType() == QQ_IM_EX_REQUEST_CANCELLED){ // QQ_IM_EX_REQUEST_CANCELED finished here memset(buf+pos, 0, 6); pos+=6; return pos; } int offset = 0; if(getContentType() == QQ_IM_EX_UDP_REQUEST){ offset = pos; pos+=2; buf[pos++] = 0x01; // unknown pos+=2; // this part this the following part length again! so offset will be offset+3 } buf[pos++] = 0x20; buf[pos++] = 0x1f; int len = strlen(m_FileName.c_str()); memcpy(buf+pos, m_FileName.c_str(), len); pos+=len; buf[pos++] = 0x1f;#ifdef WIN32 char* strSize; strSize=(char*)_alloca(100);#else char strSize[100];#endif memset(strSize, 100, 0); sprintf(strSize, "%d", m_FileSize); len = strlen(strSize); memcpy(buf+pos, strSize, len); pos+=len; buf[pos++] = 0x20; // chinese for "byte"(zijie) encoded in GB18030 buf[pos++] = 0xd7; buf[pos++] = 0xd6; buf[pos++] = 0xbd; buf[pos++] = 0xda; // now we set the 2 lengths EvaUtil::write16(buf+offset, pos-offset-2); EvaUtil::write16(buf+offset+3, pos-offset-2-3-2);// printf("\n----====== SendFileExRequestPacket::putContents ======----");// for(int i=0; i<pos; i++){// if(!(i%8)) printf("\n%d: ",i);// char t = buf[i];// printf("%2x ", (uint8_t)t);// }// printf("\n ----====== UDP EX Request Sent ======----\n\n"); return pos;}/* ======================================================= */SendIpExNotifyPacket::SendIpExNotifyPacket( const bool isSender ) : SendIM(QQ_IM_EX_NOTIFY_IP) , m_IsSender(isSender) , m_TransferType(QQ_TRANSFER_FILE) , m_ConnectMode(QQ_TRANSFER_FILE_UDP) , m_SessionId(0) , m_WanIp1(0), m_WanPort1(0) , m_WanIp2(0), m_WanPort2(0) , m_WanIp3(0), m_WanPort3(0) , m_LanIp1(0), m_LanPort1(0) , m_LanIp2(0), m_LanPort2(0) , m_LanIp3(0), m_LanPort3(0) , m_SyncIp(0), m_SyncPort(0) , m_SyncSession(0){}SendIpExNotifyPacket::SendIpExNotifyPacket( const SendIpExNotifyPacket & rhs ) : SendIM(rhs){ *this = rhs;}SendIpExNotifyPacket & SendIpExNotifyPacket::operator =( const SendIpExNotifyPacket & rhs ){ (SendIM)(*this) = (SendIM)rhs; m_IsSender = rhs.isSender(); m_TransferType = rhs.getTransferType(); m_ConnectMode = rhs.getConnectMode(); m_SessionId = rhs.getSessionId(); m_WanIp1 = rhs.getWanIp1(); m_WanPort1 = rhs.getWanPort1(); m_WanIp2 = rhs.getWanIp2(); m_WanPort2 = rhs.getWanPort2(); m_WanIp3 = rhs.getWanIp3(); m_WanPort3 = rhs.getWanPort3(); m_LanIp1 = rhs.getLanIp1(); m_LanPort1 = rhs.getLanPort1(); m_LanIp2 = rhs.getLanIp2(); m_LanPort2 = rhs.getLanPort2(); m_LanIp3 = rhs.getLanIp3(); m_LanPort3 = rhs.getLanPort3(); m_SyncIp = rhs.getSyncIp(); m_SyncPort = rhs.getSyncPort(); m_SyncSession = rhs.getSyncSession(); return *this;}int SendIpExNotifyPacket::putContents( unsigned char * buf ){ int pos = 0; memset(buf, 0, 11);pos+=11; // 11 bytes 0x00 buf[pos++] = m_TransferType; // transfer File or custom-picture buf[pos++] = m_ConnectMode; buf[pos++] = 0x66; // unknown byte, 0x66, but sometimes is 0x67 // 2 bytes, 0x0000 ( if is Cancellation Request,this part still here? //pos+=EvaUtil::write16(buf+pos, 0x00); pos+=EvaUtil::write32(buf+pos, 1); // 4 bytes, 0x00000001 pos+=EvaUtil::write32(buf+pos, m_SessionId); // following 2 bytes maybe a unsigned short sequence id for this session buf[pos++] = 0x00; buf[pos++] = m_IsSender?0x01:0x02; int offset = pos; pos+=2; // length of following; memcpy(buf+pos, &m_WanIp1, 4); pos+=4; // little endian pos+=EvaUtil::write16(buf+pos, m_WanPort1); // 2 bytes memcpy(buf+pos, &m_WanIp2, 4); pos+=4; // little endian pos+=EvaUtil::write16(buf+pos, m_WanPort2); // 2 bytes memcpy(buf+pos, &m_LanIp1, 4); pos+=4; // little endian pos+=EvaUtil::write16(buf+pos, m_LanPort1); // 2 bytes // this part looks always 6 0x00s memcpy(buf+pos, &m_LanIp2, 4); pos+=4; // little endian pos+=EvaUtil::write16(buf+pos, m_LanPort2); // 2 bytes memcpy(buf+pos, &m_LanIp3, 4); pos+=4; // little endian pos+=EvaUtil::write16(buf+pos, m_LanPort3); // 2 bytes if(m_IsSender){ //unsigned int agent= 0xdb503185; memcpy(buf+pos, &m_SyncIp, 4); pos+=4; // little endian //unsigned short aport = 0x1f40; pos+=EvaUtil::write16(buf+pos, m_SyncPort); // 2 bytes pos+=EvaUtil::write32(buf+pos, m_SyncSession); } memcpy(buf+pos, &m_WanIp3, 4); pos+=4; // little endian pos+=EvaUtil::write16(buf+pos, m_WanPort3); // 2 bytes memset(buf+pos, 0, 10); pos+=10; if(m_IsSender){ memset(buf+pos, 0, 2); pos+=2; }// memset(buf+pos, 0, 2); pos+=2;// buf[pos++] = 0x14; // unknown byte// buf[pos++] = 0x00;// pos+=EvaUtil::write16(buf+pos, 0x40d5); // unknown 2 bytes// // memset(buf+pos, 0, 4); pos+=4; // maybe a another ip? we try all 0 buf[pos++] = 0x12; buf[pos++] = 0x00; // write the length EvaUtil::write16(buf+offset, pos-offset-2); printf("\n----====== SendIpExNotifyPacket::putContents ======----"); for(int i=0; i<pos; i++){ if(!(i%8)) printf("\n%d: ",i); char t = buf[i]; printf("%2x ", (uint8_t)t); } printf("\n----====== IP Notification Built ======----\n\n"); return pos;}/** ====================================================================== */SendFileNotifyAgentPacket::SendFileNotifyAgentPacket() : SendIM(QQ_IM_NOTIFY_FILE_AGENT_INFO) , m_TransferType(QQ_TRANSFER_FILE) , m_ConnectMode(QQ_TRANSFER_FILE_TCP){}SendFileNotifyAgentPacket::SendFileNotifyAgentPacket(const SendFileAcceptPacket &rhs) : SendIM(rhs){ *this = rhs;}SendFileNotifyAgentPacket &SendFileNotifyAgentPacket::operator=(const SendFileNotifyAgentPacket &rhs){ (SendIM)(*this) = (SendIM)rhs; m_Ip = rhs.getAgentIp(); m_Port = rhs.getAgentPort(); m_Session = rhs.getAgentSession(); return *this;}int SendFileNotifyAgentPacket::putContents(unsigned char *buf){ int pos = 0; memset(buf, 0, 11);pos+=11; // 11 bytes 0x00 buf[pos++] = m_TransferType; // transfer File or custom-picture buf[pos++] = m_ConnectMode; memset(buf+pos, 0, 12); pos+=12; pos += EvaUtil::write32(buf+pos, m_Ip); pos += EvaUtil::write16(buf+pos, m_Port); pos += EvaUtil::write32(buf+pos, m_Session); memcpy(buf+pos, getFileAgentKey(), 16); pos+=16; buf[pos++] = 0x01; // unknown byte printf("SendFileNotifyAgentPacket::putContents -- ip:%8x\tport:%d\n", m_Ip, m_Port); for(int i=0; i<pos; i++){ if(!(i%8)) printf("\n%d: ",i); char t = buf[i]; printf("%2x ", (uint8_t)t); } printf("\n --------------------------------------\n\n"); return pos; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -