* Send an icmp packet back to the ip level, * after supplying a checksum. */
| 989 | * after supplying a checksum. |
| 990 | */ |
| 991 | static void |
| 992 | icmp_send(struct mbuf *m, struct mbuf *opts) |
| 993 | { |
| 994 | struct ip *ip = mtod(m, struct ip *); |
| 995 | int hlen; |
| 996 | struct icmp *icp; |
| 997 | |
| 998 | hlen = ip->ip_hl << 2; |
| 999 | m->m_data += hlen; |
| 1000 | m->m_len -= hlen; |
| 1001 | icp = mtod(m, struct icmp *); |
| 1002 | icp->icmp_cksum = 0; |
| 1003 | icp->icmp_cksum = in_cksum(m, ntohs(ip->ip_len) - hlen); |
| 1004 | m->m_data -= hlen; |
| 1005 | m->m_len += hlen; |
| 1006 | m->m_pkthdr.rcvif = (struct ifnet *)0; |
| 1007 | #ifdef ICMPPRINTFS |
| 1008 | if (icmpprintfs) { |
| 1009 | char dstbuf[INET_ADDRSTRLEN]; |
| 1010 | char srcbuf[INET_ADDRSTRLEN]; |
| 1011 | |
| 1012 | printf("icmp_send dst %s src %s\n", |
| 1013 | inet_ntoa_r(ip->ip_dst, dstbuf), |
| 1014 | inet_ntoa_r(ip->ip_src, srcbuf)); |
| 1015 | } |
| 1016 | #endif |
| 1017 | (void) ip_output(m, opts, NULL, 0, NULL, NULL); |
| 1018 | } |
| 1019 | |
| 1020 | /* |
| 1021 | * Return milliseconds since 00:00 UTC in network format. |
no test coverage detected