void CSmsCmpp::EncodeConnect(const long& nSecID,const string& sSrcAddr, const string& sPwd, const string& sUser, BYTE nVer)
{
m_smHeader.lCommandLength = 39;
m_smHeader.lCommandId = CMPP_CONNECT;
m_smHeader.lSequenceNumber = nSecID;
EncodeHeader();
string sAuthName;
if(int(sUser.size())>0) {
sAuthName = sUser.c_str();
}
else {
sAuthName = sSrcAddr.c_str();
}
AppendOct(m_Body,(PBYTE)sAuthName.c_str(),6);
vector<BYTE> vAuth;
std::copy(sAuthName.begin(),sAuthName.end(),back_inserter(vAuth));
for(int i=0;i<9;i++) vAuth.push_back(0x00);
std::copy(sPwd.begin(),sPwd.end(),back_inserter(vAuth));
string sStamp = GetCurTime();
std::copy(sStamp.begin(),sStamp.end(),back_inserter(vAuth));
char src[400];
memset(src,0,400);
std::copy(vAuth.begin(),vAuth.end(),src);
PBYTE temp = new BYTE[17];
memset(temp,0,17);
DWord dwSize;
Cryptmd5Hash((PBYTE)src,int(vAuth.size()),temp,dwSize);
ostringstream oss;
oss<<"发送连接包!";
AppendOct(m_Body,(PBYTE)temp,16); //ICP认证码
delete[] temp;
AppendInt(m_Body,nVer);
DWORD lTimeStamp = atoi(sStamp.c_str());
lTimeStamp = htonl(lTimeStamp);
AppendOct(m_Body,(PBYTE)&lTimeStamp,4);
}
新闻热点
疑难解答