| 520 | } |
| 521 | |
| 522 | static int |
| 523 | IcmpAliasOut2(struct libalias *la, struct ip *pip) |
| 524 | { |
| 525 | /* |
| 526 | Alias outgoing ICMP error messages containing |
| 527 | IP header and first 64 bits of datagram. |
| 528 | */ |
| 529 | struct ip *ip; |
| 530 | struct icmp *ic, *ic2; |
| 531 | struct udphdr *ud; |
| 532 | struct tcphdr *tc; |
| 533 | struct alias_link *lnk; |
| 534 | |
| 535 | LIBALIAS_LOCK_ASSERT(la); |
| 536 | ic = (struct icmp *)ip_next(pip); |
| 537 | ip = &ic->icmp_ip; |
| 538 | |
| 539 | ud = (struct udphdr *)ip_next(ip); |
| 540 | tc = (struct tcphdr *)ip_next(ip); |
| 541 | ic2 = (struct icmp *)ip_next(ip); |
| 542 | |
| 543 | if (ip->ip_p == IPPROTO_UDP) |
| 544 | lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src, |
| 545 | ud->uh_dport, ud->uh_sport, |
| 546 | IPPROTO_UDP, 0); |
| 547 | else if (ip->ip_p == IPPROTO_TCP) |
| 548 | lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src, |
| 549 | tc->th_dport, tc->th_sport, |
| 550 | IPPROTO_TCP, 0); |
| 551 | else if (ip->ip_p == IPPROTO_ICMP) { |
| 552 | if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP) |
| 553 | lnk = FindIcmpOut(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0); |
| 554 | else |
| 555 | lnk = NULL; |
| 556 | } else |
| 557 | lnk = NULL; |
| 558 | |
| 559 | if (lnk != NULL) { |
| 560 | if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) { |
| 561 | int accumulate; |
| 562 | struct in_addr alias_address; |
| 563 | u_short alias_port; |
| 564 | |
| 565 | alias_address = GetAliasAddress(lnk); |
| 566 | alias_port = GetAliasPort(lnk); |
| 567 | |
| 568 | /* Adjust ICMP checksum */ |
| 569 | accumulate = twowords(&ip->ip_dst); |
| 570 | accumulate -= twowords(&alias_address); |
| 571 | accumulate += ud->uh_dport; |
| 572 | accumulate -= alias_port; |
| 573 | ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); |
| 574 | |
| 575 | /* |
| 576 | * Alias address in IP header if it comes from the host |
| 577 | * the original TCP/UDP packet was destined for. |
| 578 | */ |
| 579 | if (pip->ip_src.s_addr == ip->ip_dst.s_addr) { |
no test coverage detected