MCPcopy Create free account
hub / github.com/F-Stack/f-stack / icmp_send

Function icmp_send

freebsd/netinet/ip_icmp.c:991–1018  ·  view source on GitHub ↗

* Send an icmp packet back to the ip level, * after supplying a checksum. */

Source from the content-addressed store, hash-verified

989 * after supplying a checksum.
990 */
991static void
992icmp_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.

Callers 1

icmp_reflectFunction · 0.85

Calls 4

in_cksumFunction · 0.85
inet_ntoa_rFunction · 0.85
ip_outputFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected