Deleted Added
sdiff udiff text old ( 51282 ) new ( 55009 )
full compact
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/netinet/ip_icmp.c 51282 1999-09-14 16:40:28Z des $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/mbuf.h>
40#include <sys/protosw.h>
41#include <sys/socket.h>
42#include <sys/time.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>

--- 5 unchanged lines hidden (view full) ---

50#include <netinet/in.h>
51#include <netinet/in_systm.h>
52#include <netinet/in_var.h>
53#include <netinet/ip.h>
54#include <netinet/ip_icmp.h>
55#include <netinet/ip_var.h>
56#include <netinet/icmp_var.h>
57
58/*
59 * ICMP routines: error generation, receive packet processing, and
60 * routines to turnaround packets back to the originator, and
61 * host table maintenance routines.
62 */
63
64static struct icmpstat icmpstat;
65SYSCTL_STRUCT(_net_inet_icmp, ICMPCTL_STATS, stats, CTLFLAG_RD,

--- 148 unchanged lines hidden (view full) ---

214static struct sockaddr_in icmpsrc = { sizeof (struct sockaddr_in), AF_INET };
215static struct sockaddr_in icmpdst = { sizeof (struct sockaddr_in), AF_INET };
216static struct sockaddr_in icmpgw = { sizeof (struct sockaddr_in), AF_INET };
217
218/*
219 * Process a received ICMP message.
220 */
221void
222icmp_input(m, hlen)
223 register struct mbuf *m;
224 int hlen;
225{
226 register struct icmp *icp;
227 register struct ip *ip = mtod(m, struct ip *);
228 int icmplen = ip->ip_len;
229 register int i;
230 struct in_ifaddr *ia;
231 void (*ctlfunc) __P((int, struct sockaddr *, void *));
232 int code;
233

--- 24 unchanged lines hidden (view full) ---

258 icp = mtod(m, struct icmp *);
259 if (in_cksum(m, icmplen)) {
260 icmpstat.icps_checksum++;
261 goto freeit;
262 }
263 m->m_len += hlen;
264 m->m_data -= hlen;
265
266#ifdef ICMPPRINTFS
267 if (icmpprintfs)
268 printf("icmp_input, type %d code %d\n", icp->icmp_type,
269 icp->icmp_code);
270#endif
271
272 /*
273 * Message type specific processing.
274 */
275 if (icp->icmp_type > ICMP_MAXTYPE)
276 goto raw;
277 icmpstat.icps_inhist[icp->icmp_type]++;
278 code = icp->icmp_code;
279 switch (icp->icmp_type) {

--- 109 unchanged lines hidden (view full) ---

389 rt->rt_rmx.rmx_mtu = mtu;
390 }
391 }
392 if (rt)
393 RTFREE(rt);
394 }
395
396#endif
397 ctlfunc = inetsw[ip_protox[icp->icmp_ip.ip_p]].pr_ctlinput;
398 if (ctlfunc)
399 (*ctlfunc)(code, (struct sockaddr *)&icmpsrc,
400 (void *)&icp->icmp_ip);
401 break;
402
403 badcode:
404 icmpstat.icps_badcode++;

--- 108 unchanged lines hidden (view full) ---

513 }
514#endif
515 icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
516 rtredirect((struct sockaddr *)&icmpsrc,
517 (struct sockaddr *)&icmpdst,
518 (struct sockaddr *)0, RTF_GATEWAY | RTF_HOST,
519 (struct sockaddr *)&icmpgw, (struct rtentry **)0);
520 pfctlinput(PRC_REDIRECT_HOST, (struct sockaddr *)&icmpsrc);
521 break;
522
523 /*
524 * No kernel processing for the following;
525 * just fall through to send to raw listener.
526 */
527 case ICMP_ECHOREPLY:
528 case ICMP_ROUTERADVERT:
529 case ICMP_ROUTERSOLICIT:
530 case ICMP_TSTAMPREPLY:
531 case ICMP_IREQREPLY:
532 case ICMP_MASKREPLY:
533 default:
534 break;
535 }
536
537raw:
538 rip_input(m, hlen);
539 return;
540
541freeit:
542 m_freem(m);
543}
544
545/*
546 * Reflect the ip packet back to the source

--- 275 unchanged lines hidden ---