1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * 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 --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/netinet6/icmp6.c 191672 2009-04-29 19:19:13Z bms $"); |
65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipsec.h" 69#include "opt_route.h" 70 71#include <sys/param.h> 72#include <sys/domain.h> --- 69 unchanged lines hidden (view full) --- 142 143 144void 145icmp6_init(void) 146{ 147 INIT_VNET_INET6(curvnet); 148 149 V_icmp6errpps_count = 0; |
150} 151 152static void 153icmp6_errcount(struct icmp6errstat *stat, int type, int code) 154{ 155 switch (type) { 156 case ICMP6_DST_UNREACH: 157 switch (code) { --- 264 unchanged lines hidden (view full) --- 422 423 ip6 = mtod(m, struct ip6_hdr *); 424 if (icmp6len < sizeof(struct icmp6_hdr)) { 425 ICMP6STAT_INC(icp6s_tooshort); 426 goto freeit; 427 } 428 429 /* |
430 * Check multicast group membership. 431 * Note: SSM filters are not applied for ICMPv6 traffic. 432 */ 433 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { 434 struct ifnet *ifp; 435 struct in6_multi *inm; 436 437 ifp = m->m_pkthdr.rcvif; 438 inm = in6m_lookup(ifp, &ip6->ip6_dst); 439 if (inm == NULL) { 440 IP6STAT_INC(ip6s_notmember); 441 in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); 442 goto freeit; 443 } 444 } 445 446 /* |
447 * calculate the checksum 448 */ 449#ifndef PULLDOWN_TEST 450 icmp6 = (struct icmp6_hdr *)((caddr_t)ip6 + off); 451#else 452 IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6)); 453 if (icmp6 == NULL) { 454 ICMP6STAT_INC(icp6s_tooshort); --- 170 unchanged lines hidden (view full) --- 625 case ICMP6_ECHO_REPLY: 626 icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_echoreply); 627 if (code != 0) 628 goto badcode; 629 break; 630 631 case MLD_LISTENER_QUERY: 632 case MLD_LISTENER_REPORT: |
633 case MLD_LISTENER_DONE: 634 case MLDV2_LISTENER_REPORT: 635 /* 636 * Drop MLD traffic which is not link-local. 637 * XXX Should we also sanity check that these messages 638 * were directed to a link-local multicast prefix? 639 */ 640 if (ip6->ip6_hlim != 1) |
641 goto freeit; |
642 if (mld_input(m, off, icmp6len) != 0) 643 return (IPPROTO_DONE); |
644 /* m stays. */ 645 break; 646 |
647 case ICMP6_WRUREQUEST: /* ICMP6_FQDN_QUERY */ 648 { 649 enum { WRU, FQDN } mode; 650 651 if (!V_icmp6_nodeinfo) 652 break; 653 654 if (icmp6len == sizeof(struct icmp6_hdr) + 4) --- 1391 unchanged lines hidden (view full) --- 2046 if (opts) 2047 m_freem(opts); 2048 SOCKBUF_UNLOCK(&last->inp_socket->so_rcv); 2049 } else 2050 sorwakeup_locked(last->inp_socket); 2051 INP_RUNLOCK(last); 2052 } else { 2053 m_freem(m); |
2054 IP6STAT_DEC(ip6s_delivered); |
2055 } 2056 return IPPROTO_DONE; 2057} 2058 2059/* 2060 * Reflect the ip6 packet back to the source. 2061 * OFF points to the icmp6 header, counted from the top of the mbuf. 2062 */ --- 155 unchanged lines hidden (view full) --- 2218 m_freem(m); 2219 return; 2220} 2221 2222void 2223icmp6_fasttimo(void) 2224{ 2225 |
2226 mld_fasttimo(); |
2227} 2228 |
2229void 2230icmp6_slowtimo(void) 2231{ 2232 2233 mld_slowtimo(); 2234} 2235 |
2236static const char * 2237icmp6_redirect_diag(struct in6_addr *src6, struct in6_addr *dst6, 2238 struct in6_addr *tgt6) 2239{ 2240 static char buf[1024]; 2241 char ip6bufs[INET6_ADDRSTRLEN]; 2242 char ip6bufd[INET6_ADDRSTRLEN]; 2243 char ip6buft[INET6_ADDRSTRLEN]; --- 599 unchanged lines hidden --- |