本文整理汇总了C++中TCPClient::sendSynAck方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPClient::sendSynAck方法的具体用法?C++ TCPClient::sendSynAck怎么用?C++ TCPClient::sendSynAck使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPClient
的用法示例。
在下文中一共展示了TCPClient::sendSynAck方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tick
//.........这里部分代码省略.........
icmp = (struct icmp_packet *)ipdata;
switch(icmp->type)
{
case ICMP_ECHO:
icmp->type = ICMP_ECHOREPLY;
memcpy(rx.header.ether_dhost,rx.header.ether_shost,6);
memcpy(rx.header.ether_shost,iface->mac,6);
memcpy(ip->daddr,ip->saddr,4);
ip->saddr[3] = iface->ip & 0xFF;
ip->saddr[2] = iface->ip>>8 & 0xFF;
ip->saddr[1] = iface->ip>>16 & 0xFF;
ip->saddr[0] = iface->ip>>24 & 0xFF;
icmp->checksum = 0;
icmp->checksum = htons(checksum16(ipdata,ipdlen,CS_IP));
iface->queueTX((unsigned char *)&rx,len);
break;
}
break;
case IPPROTO_UDP:
udp = (struct udp_packet *)ipdata;
for(i=0; i<MAX_PORTS; i++)
{
if(this->udp_ports[i] != NULL)
{
if(this->udp_ports[i]->port == ntohs(udp->destPort))
{
this->udp_ports[i]->addPacket(len,&rx);
}
}
}
break;
case IPPROTO_TCP:
tcp = (struct tcp_packet *)ipdata;
for(i=0; i<MAX_PORTS; i++)
{
if(this->tcp_clients[i]!=NULL)
{
if(this->tcp_clients[i]->socketMatch(ntohs(tcp->destPort), ntohs(tcp->sourcePort),
quad2ip(ip->saddr[0],ip->saddr[1],ip->saddr[2],ip->saddr[3]))==1)
{
cli = this->tcp_clients[i];
cli->handleIncomingPacket(ip);
}
}
if(this->tcp_servers[i]!=NULL)
{
// Packet coming in to a listening socket
if((this->tcp_servers[i]->localPort == ntohs(tcp->destPort)) &&
(this->tcp_servers[i]->state == TCP_LISTEN))
{
svr = this->tcp_servers[i];
// Try and match it with an existing connection
cli = NULL;
for(i=0; i<MAX_TCP_CONNECTIONS; i++)
{
if(svr->connections[i].state!=TCP_CLOSED)
{
if(svr->connections[i].socketMatch(ntohs(tcp->destPort), ntohs(tcp->sourcePort),
quad2ip(ip->saddr[0],ip->saddr[1],ip->saddr[2],ip->saddr[3]))==1)
{
cli = &svr->connections[i];
cli->handleIncomingPacket(ip);
}
}
}
// Not an existing connections. If it's a SYN then start a connection up
if(cli==NULL)
{
if(tcp->syn==1 && tcp->ack==0)
{
est = svr->getFreeConnection();
if(est!=NULL)
{
est->localPort = svr->localPort;
est->peerPort = ntohs(tcp->sourcePort);
est->peerAddress = quad2ip(ip->saddr[0],ip->saddr[1],ip->saddr[2],ip->saddr[3]);
est->tx_mss=1440;
est->irs = ntohl(tcp->sequence);
est->rx_nxt = est->irs+1;
est->iss = rand();
est->tx_nxt = est->iss;
est->sendSynAck();
est->state=TCP_ESTABLISHED;
}
}
}
}
}
}
break;
default:
break;
}
break;
default:
break;
}