BUF->ttl = UIP_TTL; //设置TCP包生存时间
BUF->len[0] = (uip_len >> 8); //传送的数据的长度;
BUF->len[1] = (uip_len & 0xff);
BUF->urgp[0] = BUF->urgp[1] = 0;
BUF->tcpchksum = 0;
BUF->tcpchksum = ~(uip_tcpchksum()); //计算TCP校验和
BUF->vhl = 0x45;
BUF->tos = 0;
BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
++ipid;
BUF->ackno[0] = uip_connr->rcv_nxt[0];
BUF->ackno[1] = uip_connr->rcv_nxt[1];
BUF->ackno[2] = uip_connr->rcv_nxt[2];
BUF->ackno[3] = uip_connr->rcv_nxt[3];
if(uip_slen > 0 && uip_connr->len > 0)
{
uip_len = uip_connr->len + UIP_TCPIP_HLEN;
BUF->flags = TCP_ACK | TCP_PSH;
}
BUF->tcpoffset = (UIP_TCPH_LEN / 4) << 4;
BUF->seqno[0] = uip_connr->snd_nxt[0];
BUF->seqno[1] = uip_connr->snd_nxt[1];
BUF->seqno[2] = uip_connr->snd_nxt[2];
BUF->seqno[3] = uip_connr->snd_nxt[3];
BUF->proto = UIP_PROTO_TCP; //TCP协议
BUF->srcport = uip_connr->lport;
BUF->destport = uip_connr->rport;
uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr); //端口号
{
if((uip_flags & UIP_ACKDATA) != 0)
{
uip_connr->len = 0;
}
if(uip_connr->len == 0)
{
if(uip_slen > uip_connr->mss)
{
uip_slen = uip_connr->mss;
BUF->ipid[0] = ipid >> 8;
BUF->ipid[1] = ipid &F->ipchksum = ~(uip_ipchksum()); //IP校验计算
UIP_STAT(++uip_stat.tcp.sent);
UIP_STAT(++uip_stat.ip.sent);
uip_flags = 0;
}
/***************主动发送数据*******/
void tcp_send_s()
{
register struct uip_conn *uip_connr = uip_conn;
uip_send("1234567",7);
if(uip_slen > 0)
uip_ipaddr_copy(BUF->destipaddr, uip_connr->ripaddr); //目标IP地址
BUF->wnd[0] = ((UIP_RECEIVE_WINDOW) >> 8);
BUF->wnd[1] = ((UIP_RECEIVE_WINDOW) & 0xff);
}
uip_connr->len = uip_slen;
}
else
{
uip_slen = uip_connr->len;
}
}
uip_connr->nrtx = 0;
uip_appdata = uip_sappdata;