void QCOMM::readudppendingdatagrams() { char data[512]; while(udpsocket->hasPendingDatagrams()){ unsigned int len = udpsocket->read(data,512); if(len<sizeof(MDHEADER)) continue; HEARTBEATRESULT *heartack = (HEARTBEATRESULT *)data; if(!checkMdHeart(heartack->header)) continue; unsigned short packsize = heartack->header.sizeofpack; if (packsize<len) continue; //if(heartack->header.crc!=qChecksum((char *)&(heartack->funcode), // len-sizeof (heartack->header))) // continue; switch (heartack->funcode){ case UDP_TCPCONNECT:{ QHostAddress addr(ntohl(heartack->ipaddr)); tcpConnect(addr,heartack->port); break; } case UDP_SSHCONNECT:{ unsigned int ipaddr = *(unsigned int *)(heartack->ipaddr); sshConnect(QHostAddress("ipaddr"),ipaddr); break; } case UDP_MACHINEINFO: break; case UDP_HEARTBEATINC: break; default: break; } } }
// sshConnect() is how the client connects to the server bool SSHClient::sshConnect(int fd) { return sshConnect(fd, _hostname); }