| 266 | } |
| 267 | |
| 268 | BOOL __ETHPostSend(u8 ltps , void (*callback)(u8), void *prev) { |
| 269 | ETHHeader *eh; |
| 270 | IPHeader *ip; |
| 271 | TCPHeader *tcp; |
| 272 | TCPResetInfo *ri; |
| 273 | u8 digest[16]; |
| 274 | |
| 275 | ri = &Ri; |
| 276 | |
| 277 | if (ri->flag == 0) { |
| 278 | ri = NULL; |
| 279 | } |
| 280 | else if (prev != SendBuf) { |
| 281 | eh = prev; |
| 282 | ip = (IPHeader *)(eh + 1); |
| 283 | tcp = (TCPHeader *)(ip + 1); |
| 284 | if (*((u32*)ip->dst) == *((u32*)ri->srcAddr) && *((u32*)ip->src) == *((u32*)ri->dstAddr) |
| 285 | && tcp->src == ri->dstPort && tcp->dst == ri->srcPort) { |
| 286 | |
| 287 | if (tcp->flag & 4) { |
| 288 | ri->flag = 0; |
| 289 | ri = NULL; |
| 290 | } |
| 291 | else { |
| 292 | ri->seq = tcp->seq + GetTcpSegLen(ip, tcp); |
| 293 | ri->ack = tcp->ack; |
| 294 | ri->flag |= tcp->flag & 0x10; |
| 295 | |
| 296 | ri->id = ip->id - 0x4000; |
| 297 | if (ri->id == 0) { |
| 298 | ri->id = 1; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | if (ri != NULL && ri->id != 0) { |
| 305 | eh = (ETHHeader *)SendBuf; |
| 306 | ip = (IPHeader *)(eh + 1); |
| 307 | eh->type = 0x800; |
| 308 | memmove(SendBuf, ri, 6); |
| 309 | ETHGetMACAddr(eh->src); |
| 310 | |
| 311 | ip->verlen = 0x45; |
| 312 | ip->tos = 0; |
| 313 | ip->len = 0x40; |
| 314 | ip->id = ri->id; |
| 315 | ip->frag = 0x4000; |
| 316 | ip->ttl = 0xff; |
| 317 | ip->proto = IP_PROTO_TCP; |
| 318 | ip->sum = 0; |
| 319 | memmove(ip->dst, ri->srcAddr, sizeof(ip->dst)); |
| 320 | memmove(ip->src, ri->dstAddr, sizeof(ip->src)); |
| 321 | |
| 322 | |
| 323 | tcp = (TCPHeader *)((u32)ip + ((ip->verlen & 0xf) << 2)); |
| 324 | tcp->src = ri->dstPort; |
| 325 | tcp->dst = ri->srcPort; |
no test coverage detected