74#include <sys/domain.h>
76#include <sys/kernel.h>
78#include <sys/malloc.h>
81#include <sys/protosw.h>
82#include <sys/signalvar.h>
83#include <sys/socket.h>
84#include <sys/socketvar.h>
86#include <sys/syslog.h>
91#include <net/if_var.h>
93#include <net/if_llatbl.h>
94#include <net/if_types.h>
96#include <net/route/route_ctl.h>
97#include <net/route/nhop.h>
100#include <netinet/in.h>
101#include <netinet/in_pcb.h>
102#include <netinet/in_var.h>
103#include <netinet/ip6.h>
104#include <netinet/icmp6.h>
105#include <netinet/tcp_var.h>
123VNET_PCPUSTAT_SYSUNINIT(icmp6stat);
132#define V_ripcbinfo VNET(ripcbinfo)
133#define V_icmp6errppslim VNET(icmp6errppslim)
134#define V_icmp6errpps_count VNET(icmp6errpps_count)
135#define V_icmp6errppslim_last VNET(icmp6errppslim_last)
136#define V_icmp6_nodeinfo VNET(icmp6_nodeinfo)
144static struct mbuf *
ni6_input(
struct mbuf *,
int,
struct prison *);
146static int ni6_dnsmatch(
const char *,
int,
const char *,
int);
147static int ni6_addrs(
struct icmp6_nodeinfo *,
struct mbuf *,
148 struct ifnet **,
struct in6_addr *);
149static int ni6_store_addrs(
struct icmp6_nodeinfo *,
struct icmp6_nodeinfo *,
150 struct ifnet *,
int);
164 counter_u64_add(VNET(icmp6stat)[statnum], 1);
171 case ICMP6_DST_UNREACH:
173 case ICMP6_DST_UNREACH_NOROUTE:
174 ICMP6STAT_INC(icp6s_odst_unreach_noroute);
176 case ICMP6_DST_UNREACH_ADMIN:
177 ICMP6STAT_INC(icp6s_odst_unreach_admin);
179 case ICMP6_DST_UNREACH_BEYONDSCOPE:
180 ICMP6STAT_INC(icp6s_odst_unreach_beyondscope);
182 case ICMP6_DST_UNREACH_ADDR:
183 ICMP6STAT_INC(icp6s_odst_unreach_addr);
185 case ICMP6_DST_UNREACH_NOPORT:
186 ICMP6STAT_INC(icp6s_odst_unreach_noport);
190 case ICMP6_PACKET_TOO_BIG:
191 ICMP6STAT_INC(icp6s_opacket_too_big);
193 case ICMP6_TIME_EXCEEDED:
195 case ICMP6_TIME_EXCEED_TRANSIT:
196 ICMP6STAT_INC(icp6s_otime_exceed_transit);
198 case ICMP6_TIME_EXCEED_REASSEMBLY:
199 ICMP6STAT_INC(icp6s_otime_exceed_reassembly);
203 case ICMP6_PARAM_PROB:
205 case ICMP6_PARAMPROB_HEADER:
206 ICMP6STAT_INC(icp6s_oparamprob_header);
208 case ICMP6_PARAMPROB_NEXTHEADER:
209 ICMP6STAT_INC(icp6s_oparamprob_nextheader);
211 case ICMP6_PARAMPROB_OPTION:
212 ICMP6STAT_INC(icp6s_oparamprob_option);
217 ICMP6STAT_INC(icp6s_oredirect);
220 ICMP6STAT_INC(icp6s_ounknown);
236 if (m->m_len <
sizeof(
struct ip6_hdr)) {
237 m = m_pullup(m,
sizeof(
struct ip6_hdr));
243 ip6 = mtod(m,
struct ip6_hdr *);
259 struct ip6_hdr *oip6, *nip6;
260 struct icmp6_hdr *icmp6;
261 struct epoch_tracker et;
266 ICMP6STAT_INC(icp6s_error);
273 ICMP6STAT_INC(icp6s_canterror);
278 if (m->m_len <
sizeof(
struct ip6_hdr)) {
279 m = m_pullup(m,
sizeof(
struct ip6_hdr));
285 oip6 = mtod(m,
struct ip6_hdr *);
298 if ((m->m_flags & (M_BCAST|M_MCAST) ||
300 (type != ICMP6_PACKET_TOO_BIG &&
301 (type != ICMP6_PARAM_PROB ||
302 code != ICMP6_PARAMPROB_OPTION)))
319 if (off >= 0 && nxt == IPPROTO_ICMPV6) {
320 struct icmp6_hdr *icp;
322 if (m->m_len < off +
sizeof(
struct icmp6_hdr)) {
323 m = m_pullup(m, off +
sizeof(
struct icmp6_hdr));
329 oip6 = mtod(m,
struct ip6_hdr *);
330 icp = (
struct icmp6_hdr *)(mtod(m, caddr_t) + off);
332 if (icp->icmp6_type < ICMP6_ECHO_REQUEST ||
333 icp->icmp6_type == ND_REDIRECT) {
339 ICMP6STAT_INC(icp6s_canterror);
350 ICMP6STAT_INC(icp6s_toofreq);
358 if (m->m_pkthdr.len >= ICMPV6_PLD_MAXLEN)
359 m_adj(m, ICMPV6_PLD_MAXLEN - m->m_pkthdr.len);
361 preplen =
sizeof(
struct ip6_hdr) + sizeof(struct icmp6_hdr);
362 M_PREPEND(m, preplen, M_NOWAIT);
364 nd6log((LOG_DEBUG,
"ENOBUFS in icmp6_error %d\n", __LINE__));
368 nip6 = mtod(m,
struct ip6_hdr *);
369 nip6->ip6_src = oip6->ip6_src;
370 nip6->ip6_dst = oip6->ip6_dst;
375 icmp6 = (
struct icmp6_hdr *)(nip6 + 1);
376 icmp6->icmp6_type = type;
377 icmp6->icmp6_code = code;
378 icmp6->icmp6_pptr = htonl((u_int32_t)param);
380 ICMP6STAT_INC(icp6s_outhist[type]);
402 struct ip6_hdr *ip6, *nip6;
403 struct icmp6_hdr *icmp6, *nicmp6;
405 int code, error, icmp6len, ip6len, noff, off, sum;
412 if (m->m_len < off +
sizeof(
struct icmp6_hdr)) {
413 m = m_pullup(m, off +
sizeof(
struct icmp6_hdr));
417 return (IPPROTO_DONE);
426 icmp6len = m->m_pkthdr.len - off;
427 if (icmp6len <
sizeof(
struct icmp6_hdr)) {
428 ICMP6STAT_INC(icp6s_tooshort);
432 ip6 = mtod(m,
struct ip6_hdr *);
433 ifp = m->m_pkthdr.rcvif;
450 icmp6 = (
struct icmp6_hdr *)((caddr_t)ip6 + off);
451 code = icmp6->icmp6_code;
452 if ((sum =
in6_cksum(m, IPPROTO_ICMPV6, off, icmp6len)) != 0) {
454 "ICMP6 checksum error(%d|%x) %s\n",
455 icmp6->icmp6_type, sum,
457 ICMP6STAT_INC(icp6s_checksum);
461 ICMP6STAT_INC(icp6s_inhist[icmp6->icmp6_type]);
462 icmp6_ifstat_inc(ifp, ifs6_in_msg);
463 if (icmp6->icmp6_type < ICMP6_INFOMSG_MASK)
464 icmp6_ifstat_inc(ifp, ifs6_in_error);
466 ip6len =
sizeof(
struct ip6_hdr) + ntohs(ip6->ip6_plen);
467 switch (icmp6->icmp6_type) {
468 case ICMP6_DST_UNREACH:
469 icmp6_ifstat_inc(ifp, ifs6_in_dstunreach);
471 case ICMP6_DST_UNREACH_NOROUTE:
472 case ICMP6_DST_UNREACH_ADDR:
473 code = PRC_UNREACH_NET;
475 case ICMP6_DST_UNREACH_ADMIN:
476 icmp6_ifstat_inc(ifp, ifs6_in_adminprohib);
477 code = PRC_UNREACH_ADMIN_PROHIB;
479 case ICMP6_DST_UNREACH_BEYONDSCOPE:
481 code = PRC_PARAMPROB;
483 case ICMP6_DST_UNREACH_NOPORT:
484 code = PRC_UNREACH_PORT;
492 case ICMP6_PACKET_TOO_BIG:
493 icmp6_ifstat_inc(ifp, ifs6_in_pkttoobig);
506 case ICMP6_TIME_EXCEEDED:
507 icmp6_ifstat_inc(ifp, ifs6_in_timeexceed);
509 case ICMP6_TIME_EXCEED_TRANSIT:
510 code = PRC_TIMXCEED_INTRANS;
512 case ICMP6_TIME_EXCEED_REASSEMBLY:
513 code = PRC_TIMXCEED_REASS;
521 case ICMP6_PARAM_PROB:
522 icmp6_ifstat_inc(ifp, ifs6_in_paramprob);
524 case ICMP6_PARAMPROB_NEXTHEADER:
525 code = PRC_UNREACH_PROTOCOL;
527 case ICMP6_PARAMPROB_HEADER:
528 case ICMP6_PARAMPROB_OPTION:
529 code = PRC_PARAMPROB;
537 case ICMP6_ECHO_REQUEST:
538 icmp6_ifstat_inc(ifp, ifs6_in_echo);
541 if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) {
546 || n->m_len < off +
sizeof(
struct icmp6_hdr)) {
550 CTASSERT(
sizeof(*nip6) +
sizeof(*nicmp6) <= MHLEN);
551 n = m_gethdr(M_NOWAIT, n0->m_type);
558 m_move_pkthdr(n, n0);
559 n0len = n0->m_pkthdr.len;
563 nip6 = mtod(n,
struct ip6_hdr *);
564 bcopy(ip6, nip6,
sizeof(
struct ip6_hdr));
565 nicmp6 = (
struct icmp6_hdr *)(nip6 + 1);
566 bcopy(icmp6, nicmp6,
sizeof(
struct icmp6_hdr));
567 noff =
sizeof(
struct ip6_hdr);
569 n->m_len = noff +
sizeof(
struct icmp6_hdr);
574 m_adj(n0, off +
sizeof(
struct icmp6_hdr));
576 n->m_pkthdr.len = n0len + (noff - off);
579 if (n->m_len < off +
sizeof(*nicmp6)) {
580 n = m_pullup(n, off +
sizeof(*nicmp6));
586 nicmp6 = (
struct icmp6_hdr *)(mtod(n, caddr_t) + off);
590 nicmp6->icmp6_type = ICMP6_ECHO_REPLY;
591 nicmp6->icmp6_code = 0;
592 ICMP6STAT_INC(icp6s_reflect);
593 ICMP6STAT_INC(icp6s_outhist[ICMP6_ECHO_REPLY]);
598 case ICMP6_ECHO_REPLY:
599 icmp6_ifstat_inc(ifp, ifs6_in_echoreply);
604 case MLD_LISTENER_QUERY:
605 case MLD_LISTENER_REPORT:
606 case MLD_LISTENER_DONE:
607 case MLDV2_LISTENER_REPORT:
617 if ((ip6->ip6_hlim != 1) || (m->m_flags &
M_RTALERT_MLD) == 0)
621 return (IPPROTO_DONE);
626 case ICMP6_WRUREQUEST:
628 enum { WRU, FQDN } mode;
634 if (icmp6len ==
sizeof(
struct icmp6_hdr) + 4)
636 else if (icmp6len >=
sizeof(
struct icmp6_nodeinfo))
642 sx_slock(&allprison_lock);
643 TAILQ_FOREACH(pr, &allprison, pr_list)
644 if (pr->pr_vnet == ifp->if_vnet)
646 sx_sunlock(&allprison_lock);
648 pr = curthread->td_ucred->cr_prison;
650 if (m->m_len < off +
sizeof(
struct icmp6_nodeinfo)) {
651 m = m_pullup(m, off +
652 sizeof(
struct icmp6_nodeinfo));
656 return (IPPROTO_DONE);
659 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
663 noff =
sizeof(
struct ip6_hdr);
673 ICMP6_NODEINFO_TMPADDROK)) !=
674 (ICMP6_NODEINFO_FQDNOK | ICMP6_NODEINFO_TMPADDROK))
680 CTASSERT(
sizeof(*nip6) +
sizeof(*nicmp6) + 4 <= MHLEN);
681 n = m_gethdr(M_NOWAIT, m->m_type);
686 if (!m_dup_pkthdr(n, m, M_NOWAIT)) {
701 nip6 = mtod(n,
struct ip6_hdr *);
702 bcopy(ip6, nip6,
sizeof(
struct ip6_hdr));
703 nicmp6 = (
struct icmp6_hdr *)(nip6 + 1);
704 bcopy(icmp6, nicmp6,
sizeof(
struct icmp6_hdr));
705 p = (u_char *)(nicmp6 + 1);
708 maxhlen = M_TRAILINGSPACE(n) -
709 (
sizeof(*nip6) +
sizeof(*nicmp6) + 4);
710 mtx_lock(&pr->pr_mtx);
711 hlen = strlen(pr->pr_hostname);
715 bcopy(pr->pr_hostname, p + 4, maxhlen);
716 mtx_unlock(&pr->pr_mtx);
717 noff =
sizeof(
struct ip6_hdr);
718 n->m_pkthdr.len = n->m_len =
sizeof(
struct ip6_hdr) +
719 sizeof(struct icmp6_hdr) + 4 + maxhlen;
720 nicmp6->icmp6_type = ICMP6_WRUREPLY;
721 nicmp6->icmp6_code = 0;
724 ICMP6STAT_INC(icp6s_reflect);
725 ICMP6STAT_INC(icp6s_outhist[ICMP6_WRUREPLY]);
736 case ND_ROUTER_SOLICIT:
737 icmp6_ifstat_inc(ifp, ifs6_in_routersolicit);
740 if (icmp6len <
sizeof(
struct nd_router_solicit))
743 if (m->m_len < off + icmp6len) {
744 m = m_pullup(m, off + icmp6len);
748 return (IPPROTO_DONE);
757 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
764 case ND_ROUTER_ADVERT:
765 icmp6_ifstat_inc(ifp, ifs6_in_routeradvert);
768 if (icmp6len <
sizeof(
struct nd_router_advert))
777 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
784 case ND_NEIGHBOR_SOLICIT:
785 icmp6_ifstat_inc(ifp, ifs6_in_neighborsolicit);
788 if (icmp6len <
sizeof(
struct nd_neighbor_solicit))
797 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
804 case ND_NEIGHBOR_ADVERT:
805 icmp6_ifstat_inc(ifp, ifs6_in_neighboradvert);
808 if (icmp6len <
sizeof(
struct nd_neighbor_advert))
817 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
825 icmp6_ifstat_inc(ifp, ifs6_in_redirect);
828 if (icmp6len <
sizeof(
struct nd_redirect))
837 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
844 case ICMP6_ROUTER_RENUMBERING:
845 if (code != ICMP6_ROUTER_RENUMBERING_COMMAND &&
846 code != ICMP6_ROUTER_RENUMBERING_RESULT)
848 if (icmp6len <
sizeof(
struct icmp6_router_renum))
854 "icmp6_input: unknown type %d(src=%s, dst=%s, ifid=%d)\n",
855 icmp6->icmp6_type,
ip6_sprintf(ip6bufs, &ip6->ip6_src),
857 ifp ? ifp->if_index : 0));
858 if (icmp6->icmp6_type < ICMP6_ECHO_REQUEST) {
870 return (IPPROTO_DONE);
875 ICMP6STAT_INC(icp6s_badcode);
879 ICMP6STAT_INC(icp6s_badlen);
887 return (IPPROTO_DONE);
892 return (IPPROTO_DONE);
899 struct icmp6_hdr *icmp6;
900 struct ip6_hdr *eip6;
906 if (icmp6len <
sizeof(
struct icmp6_hdr) +
sizeof(
struct ip6_hdr)) {
907 ICMP6STAT_INC(icp6s_tooshort);
911 if (m->m_len < off +
sizeof(*icmp6) +
sizeof(
struct ip6_hdr)) {
912 m = m_pullup(m, off +
sizeof(*icmp6) +
sizeof(
struct ip6_hdr));
919 icmp6 = (
struct icmp6_hdr *)(mtod(m, caddr_t) + off);
920 eip6 = (
struct ip6_hdr *)(icmp6 + 1);
921 bzero(&icmp6dst,
sizeof(icmp6dst));
925 void (*ctlfunc)(int,
struct sockaddr *,
void *);
926 u_int8_t nxt = eip6->ip6_nxt;
927 int eoff = off +
sizeof(
struct icmp6_hdr) +
928 sizeof(struct ip6_hdr);
930 int icmp6type = icmp6->icmp6_type;
932 struct ip6_rthdr *rth;
933 struct ip6_rthdr0 *rth0;
940 case IPPROTO_HOPOPTS:
941 case IPPROTO_DSTOPTS:
943 if (m->m_len < eoff +
sizeof(
struct ip6_ext)) {
944 m = m_pullup(m, eoff +
945 sizeof(
struct ip6_ext));
952 eh = (
struct ip6_ext *)
953 (mtod(m, caddr_t) + eoff);
954 if (nxt == IPPROTO_AH)
955 eoff += (eh->ip6e_len + 2) << 2;
957 eoff += (eh->ip6e_len + 1) << 3;
960 case IPPROTO_ROUTING:
969 if (m->m_len < eoff +
sizeof(*rth)) {
970 m = m_pullup(m, eoff +
sizeof(*rth));
977 rth = (
struct ip6_rthdr *)
978 (mtod(m, caddr_t) + eoff);
979 rthlen = (rth->ip6r_len + 1) << 3;
988 if (rth->ip6r_segleft &&
992 if (m->m_len < eoff + rthlen) {
993 m = m_pullup(m, eoff + rthlen);
1001 rth0 = (
struct ip6_rthdr0 *)
1002 (mtod(m, caddr_t) + eoff);
1005 if ((rth0->ip6r0_len % 2) == 0 &&
1006 (hops = rth0->ip6r0_len/2))
1010 nxt = rth->ip6r_nxt;
1012 case IPPROTO_FRAGMENT:
1013 if (m->m_len < eoff +
sizeof(
struct ip6_frag)) {
1014 m = m_pullup(m, eoff +
1015 sizeof(
struct ip6_frag));
1022 fh = (
struct ip6_frag *)(mtod(m, caddr_t) +
1030 if (fh->ip6f_offlg & IP6F_OFF_MASK)
1033 eoff +=
sizeof(
struct ip6_frag);
1049 icmp6 = (
struct icmp6_hdr *)(mtod(m, caddr_t) + off);
1059 eip6 = (
struct ip6_hdr *)(icmp6 + 1);
1067 bzero(&icmp6src,
sizeof(icmp6src));
1074 (eip6->ip6_flow & IPV6_FLOWLABEL_MASK);
1078 ip6cp.
ip6c_ip6 = (
struct ip6_hdr *)(icmp6 + 1);
1084 if (icmp6type == ICMP6_PACKET_TOO_BIG) {
1085 notifymtu = ntohl(icmp6->icmp6_mtu);
1090 ctlfunc = (void (*)(int,
struct sockaddr *,
void *))
1093 (void) (*ctlfunc)(code, (
struct sockaddr *)&icmp6dst,
1111 struct mbuf *m = ip6cp->
ip6c_m;
1112 u_int mtu = ntohl(icmp6->icmp6_mtu);
1113 struct in_conninfo inc;
1124 if (mtu < IPV6_MMTU)
1132 if (mtu <
sizeof(
struct ip6_hdr) +
sizeof(
struct ip6_frag) + 8)
1144 if (mtu < IPV6_MMTU)
1145 mtu = IPV6_MMTU - 8;
1147 bzero(&inc,
sizeof(inc));
1148 inc.inc_fibnum = M_GETFIB(m);
1149 inc.inc_flags |= INC_ISIPV6;
1150 inc.inc6_faddr = *dst;
1151 if (
in6_setscope(&inc.inc6_faddr, m->m_pkthdr.rcvif, NULL))
1154 if (mtu < tcp_maxmtu6(&inc, NULL)) {
1155 tcp_hc_updatemtu(&inc, mtu);
1156 ICMP6STAT_INC(icp6s_pmtuchg);
1174 struct icmp6_nodeinfo *ni6, *nni6;
1175 struct mbuf *n = NULL;
1178 int replylen =
sizeof(
struct ip6_hdr) + sizeof(struct icmp6_nodeinfo);
1179 struct ni_reply_fqdn *fqdn;
1181 struct ifnet *ifp = NULL;
1183 struct ip6_hdr *ip6;
1188 ip6 = mtod(m,
struct ip6_hdr *);
1189 ni6 = (
struct icmp6_nodeinfo *)(mtod(m, caddr_t) + off);
1228 nd6log((LOG_DEBUG,
"ni6_input: ignore node info to "
1229 "a temporary address in %s:%d",
1230 __FILE__, __LINE__));
1236 qtype = ntohs(ni6->ni_qtype);
1237 subjlen = m->m_pkthdr.len - off -
sizeof(
struct icmp6_nodeinfo);
1240 case NI_QTYPE_SUPTYPES:
1242 if (ni6->ni_code == ICMP6_NI_SUBJ_FQDN && subjlen == 0)
1246 case NI_QTYPE_NODEADDR:
1247 case NI_QTYPE_IPV4ADDR:
1248 switch (ni6->ni_code) {
1249 case ICMP6_NI_SUBJ_IPV6:
1250#if ICMP6_NI_SUBJ_IPV6 != 0
1257 if (qtype == NI_QTYPE_FQDN && ni6->ni_code == 0 &&
1262#if ICMP6_NI_SUBJ_IPV6 != 0
1263 if (ni6->ni_code != ICMP6_NI_SUBJ_IPV6)
1267 if (subjlen !=
sizeof(
struct in6_addr))
1284 m_copydata(m, off +
sizeof(
struct icmp6_nodeinfo),
1285 subjlen, (caddr_t)&in6_subj);
1289 subj = (
char *)&in6_subj;
1304 case ICMP6_NI_SUBJ_FQDN:
1316 mtx_lock(&pr->pr_mtx);
1318 strlen(pr->pr_hostname), 0);
1319 mtx_unlock(&pr->pr_mtx);
1320 if (!n || n->m_next || n->m_len == 0)
1322 if (m->m_len < off +
sizeof(
struct icmp6_nodeinfo) +
1324 m = m_pullup(m, off +
1325 sizeof(
struct icmp6_nodeinfo) + subjlen);
1332 ni6 = (
struct icmp6_nodeinfo *)(mtod(m, caddr_t) + off);
1333 subj = (
char *)(mtod(m, caddr_t) + off +
1334 sizeof(
struct icmp6_nodeinfo));
1335 if (!
ni6_dnsmatch(subj, subjlen, mtod(n,
const char *),
1343 case ICMP6_NI_SUBJ_IPV4:
1356 case NI_QTYPE_NODEADDR:
1357 case NI_QTYPE_IPV4ADDR:
1367 case NI_QTYPE_SUPTYPES:
1368 replylen +=
sizeof(u_int32_t);
1372 replylen += offsetof(
struct ni_reply_fqdn, ni_fqdn_namelen);
1374 case NI_QTYPE_NODEADDR:
1376 if ((replylen += addrs * (
sizeof(
struct in6_addr) +
1377 sizeof(u_int32_t))) > MCLBYTES)
1378 replylen = MCLBYTES;
1380 case NI_QTYPE_IPV4ADDR:
1393 qtype = NI_QTYPE_FQDN;
1395 replylen += offsetof(
struct ni_reply_fqdn, ni_fqdn_namelen);
1401 if (replylen > MCLBYTES) {
1408 if (replylen > MHLEN)
1409 n = m_getcl(M_NOWAIT, m->m_type, M_PKTHDR);
1411 n = m_gethdr(M_NOWAIT, m->m_type);
1416 m_move_pkthdr(n, m);
1417 n->m_pkthdr.len = n->m_len = replylen;
1420 bcopy(mtod(m, caddr_t), mtod(n, caddr_t),
sizeof(
struct ip6_hdr));
1421 nni6 = (
struct icmp6_nodeinfo *)(mtod(n,
struct ip6_hdr *) + 1);
1422 bcopy((caddr_t)ni6, (caddr_t)nni6,
sizeof(
struct icmp6_nodeinfo));
1427 nni6->ni_code = ICMP6_NI_SUCCESS;
1430 case NI_QTYPE_SUPTYPES:
1433 nni6->ni_code = ICMP6_NI_SUCCESS;
1434 nni6->ni_flags = htons(0x0000);
1436 v = (u_int32_t)htonl(0x0000000f);
1437 bcopy(&v, nni6 + 1,
sizeof(u_int32_t));
1441 nni6->ni_code = ICMP6_NI_SUCCESS;
1442 fqdn = (
struct ni_reply_fqdn *)(mtod(n, caddr_t) +
1443 sizeof(
struct ip6_hdr) + sizeof(struct icmp6_nodeinfo));
1445 fqdn->ni_fqdn_ttl = 0;
1449 mtx_lock(&pr->pr_mtx);
1451 strlen(pr->pr_hostname), oldfqdn);
1452 mtx_unlock(&pr->pr_mtx);
1453 if (n->m_next == NULL)
1456 if (n->m_next->m_next != NULL)
1458 n->m_pkthdr.len += n->m_next->m_len;
1460 case NI_QTYPE_NODEADDR:
1464 nni6->ni_code = ICMP6_NI_SUCCESS;
1465 n->m_pkthdr.len = n->m_len =
1466 sizeof(
struct ip6_hdr) + sizeof(struct icmp6_nodeinfo);
1467 lenlim = M_TRAILINGSPACE(n);
1470 n->m_pkthdr.len = n->m_len =
sizeof(
struct ip6_hdr) +
1471 sizeof(struct icmp6_nodeinfo) + copied;
1478 nni6->ni_type = ICMP6_NI_REPLY;
1512 m = m_getcl(M_NOWAIT, MT_DATA, 0);
1514 m = m_get(M_NOWAIT, MT_DATA);
1520 *mtod(m,
char *) = namelen;
1521 bcopy(name, mtod(m,
char *) + 1, namelen);
1525 cp = mtod(m,
char *);
1526 ep = mtod(m,
char *) + M_TRAILINGSPACE(m);
1537 for (p = name; p < name + namelen; p++) {
1538 if (*p && *p ==
'.')
1547 while (cp < ep && p < name + namelen) {
1549 for (q = p; q < name + namelen && *q && *q !=
'.'; q++)
1552 if (cp + i + 1 >= ep)
1559 if (i <= 0 || i >= 64)
1565 if (p < name + namelen && *p ==
'.')
1569 if (cp + nterm >= ep)
1573 m->m_len = cp - mtod(m,
char *);
1577 panic(
"should not reach here");
1594 const char *a0, *b0;
1598 if (alen == blen && bcmp(a, b, alen) == 0)
1605 if (alen < 2 || blen < 2)
1607 if (a0[alen - 1] !=
'\0' || b0[blen - 1] !=
'\0')
1612 while (a - a0 < alen && b - b0 < blen) {
1613 if (a - a0 + 1 > alen || b - b0 + 1 > blen)
1616 if ((
signed char)a[0] < 0 || (
signed char)b[0] < 0)
1619 if (a[0] >= 64 || b[0] >= 64)
1623 if (a[0] == 0 && a - a0 == alen - 1)
1625 if (b[0] == 0 && b - b0 == blen - 1)
1627 if (a[0] == 0 || b[0] == 0)
1633 if (a - a0 + 1 + l > alen || b - b0 + 1 + l > blen)
1635 if (bcmp(a + 1, b + 1, l) != 0)
1642 if (a - a0 == alen && b - b0 == blen)
1652ni6_addrs(
struct icmp6_nodeinfo *ni6,
struct mbuf *m,
struct ifnet **ifpp,
1658 int addrs = 0, addrsofif, iffound = 0;
1659 int niflags = ni6->ni_flags;
1663 if ((niflags & NI_NODEADDR_FLAG_ALL) == 0) {
1664 switch (ni6->ni_code) {
1665 case ICMP6_NI_SUBJ_IPV6:
1678 CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) {
1680 CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
1681 if (ifa->ifa_addr->sa_family != AF_INET6)
1685 if ((niflags & NI_NODEADDR_FLAG_ALL) == 0 &&
1702 if ((niflags & NI_NODEADDR_FLAG_LINKLOCAL) == 0)
1706 if ((niflags & NI_NODEADDR_FLAG_SITELOCAL) == 0)
1710 if ((niflags & NI_NODEADDR_FLAG_GLOBAL) == 0)
1722 (niflags & NI_NODEADDR_FLAG_ANYCAST) == 0)
1743 struct ifnet *ifp0,
int resid)
1748 struct ifnet *ifp_dep = NULL;
1749 int copied = 0, allow_deprecated = 0;
1750 u_char *cp = (u_char *)(nni6 + 1);
1751 int niflags = ni6->ni_flags;
1756 if (ifp0 == NULL && !(niflags & NI_NODEADDR_FLAG_ALL))
1759 ifp = ifp0 ? ifp0 : CK_STAILQ_FIRST(&V_ifnet);
1762 for (; ifp; ifp = CK_STAILQ_NEXT(ifp, if_link)) {
1763 CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
1764 if (ifa->ifa_addr->sa_family != AF_INET6)
1769 allow_deprecated == 0) {
1776 if (ifp_dep == NULL)
1781 allow_deprecated != 0)
1787 if ((niflags & NI_NODEADDR_FLAG_LINKLOCAL) == 0)
1791 if ((niflags & NI_NODEADDR_FLAG_SITELOCAL) == 0)
1795 if ((niflags & NI_NODEADDR_FLAG_GLOBAL) == 0)
1807 (niflags & NI_NODEADDR_FLAG_ANYCAST) == 0)
1815 if (resid <
sizeof(
struct in6_addr) +
1816 sizeof(u_int32_t)) {
1821 nni6->ni_flags |= NI_NODEADDR_FLAG_TRUNCATE;
1850 bcopy(<ime, cp,
sizeof(u_int32_t));
1851 cp +=
sizeof(u_int32_t);
1859 resid -= (
sizeof(
struct in6_addr) + sizeof(u_int32_t));
1860 copied += (
sizeof(
struct in6_addr) + sizeof(u_int32_t));
1866 if (allow_deprecated == 0 && ifp_dep != NULL) {
1868 allow_deprecated = 1;
1879 struct ip6_hdr *ip6 = v;
1881 if ((inp->inp_vflag & INP_IPV6) == 0)
1883 if (inp->inp_ip_p != IPPROTO_ICMPV6)
1900 struct mbuf *n, *m = *mp;
1901 struct ip6_hdr *ip6 = mtod(m,
struct ip6_hdr *);
1902 struct inpcb_iterator inpi = INP_ITERATOR(&
V_ripcbinfo,
1906 struct icmp6_hdr *icmp6;
1907 struct mbuf *opts = NULL;
1911 icmp6 = (
struct icmp6_hdr *)((caddr_t)ip6 + off);
1917 bzero(&fromsa,
sizeof(fromsa));
1924 return (IPPROTO_DONE);
1927 while ((inp = inp_next(&inpi)) != NULL) {
1928 if (ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
1929 inp->in6p_icmp6filt))
1948 if ((m->m_flags & M_EXT) && m->m_next == NULL &&
1949 m->m_len <= MHLEN) {
1950 n = m_get(M_NOWAIT, m->m_type);
1952 if (m_dup_pkthdr(n, m, M_NOWAIT)) {
1953 bcopy(m->m_data, n->m_data, m->m_len);
1954 n->m_len = m->m_len;
1961 n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
1964 if (inp->inp_flags & INP_CONTROLOPTS)
1968 SOCKBUF_LOCK(&inp->inp_socket->so_rcv);
1969 if (sbappendaddr_locked(&inp->inp_socket->so_rcv,
1970 (
struct sockaddr *)&fromsa, n, opts) == 0) {
1971 soroverflow_locked(inp->inp_socket);
1976 sorwakeup_locked(inp->inp_socket);
1985 return (IPPROTO_DONE);
1996 struct ip6_hdr *ip6;
1997 struct icmp6_hdr *icmp6;
1999 struct ifnet *outif = NULL;
2001 int type, code, hlim;
2004 if (off <
sizeof(
struct ip6_hdr)) {
2006 "sanity fail: off=%lx, sizeof(ip6)=%lx in %s:%d\n",
2007 (u_long)off, (u_long)
sizeof(
struct ip6_hdr),
2008 __FILE__, __LINE__));
2017 if (
sizeof(
struct ip6_hdr) +
sizeof(
struct icmp6_hdr) > MHLEN)
2018 panic(
"assumption failed in icmp6_reflect");
2020 if (off >
sizeof(
struct ip6_hdr)) {
2022 struct ip6_hdr nip6;
2024 l = off -
sizeof(
struct ip6_hdr);
2025 m_copydata(m, 0,
sizeof(nip6), (caddr_t)&nip6);
2027 l =
sizeof(
struct ip6_hdr) + sizeof(struct icmp6_hdr);
2029 if ((m = m_pullup(m, l)) == NULL)
2032 bcopy((caddr_t)&nip6, mtod(m, caddr_t),
sizeof(nip6));
2035 l =
sizeof(
struct ip6_hdr) + sizeof(struct icmp6_hdr);
2037 if ((m = m_pullup(m, l)) == NULL)
2041 plen = m->m_pkthdr.len -
sizeof(
struct ip6_hdr);
2042 ip6 = mtod(m,
struct ip6_hdr *);
2043 ip6->ip6_nxt = IPPROTO_ICMPV6;
2044 icmp6 = (
struct icmp6_hdr *)(ip6 + 1);
2045 type = icmp6->icmp6_type;
2046 code = icmp6->icmp6_code;
2064 if (m->m_pkthdr.rcvif != NULL) {
2066 hlim =
ND_IFINFO(m->m_pkthdr.rcvif)->chlim;
2084 scopeid, NULL, &src6, &hlim);
2089 "icmp6_reflect: source can't be determined: "
2090 "dst=%s, error=%d\n",
2100 ip6->ip6_dst = ip6->ip6_src;
2101 ip6->ip6_src = *srcp;
2103 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
2104 ip6->ip6_vfc |= IPV6_VERSION;
2105 ip6->ip6_nxt = IPPROTO_ICMPV6;
2106 ip6->ip6_hlim = hlim;
2108 icmp6->icmp6_cksum = 0;
2109 icmp6->icmp6_cksum =
in6_cksum(m, IPPROTO_ICMPV6,
2110 sizeof(
struct ip6_hdr), plen);
2116 m->m_flags &= ~(M_BCAST|M_MCAST);
2117 m->m_pkthdr.rcvif = NULL;
2118 ip6_output(m, NULL, NULL, 0, NULL, &outif, NULL);
2120 icmp6_ifoutstat_inc(outif, type, code);
2147 static char buf[1024];
2151 snprintf(buf,
sizeof(buf),
"(src=%s dst=%s tgt=%s)",
2161 struct ip6_hdr *ip6;
2162 struct nd_redirect *nd_rd;
2163 struct in6_addr src6, redtgt6, reddst6;
2167 int icmp6len, is_onlink, is_router, lladdrlen;
2170 KASSERT(m->m_pkthdr.rcvif != NULL, (
"%s: no rcvif", __func__));
2175 if (!V_icmp6_rediraccept)
2182 ip6 = mtod(m,
struct ip6_hdr *);
2183 icmp6len = ntohs(ip6->ip6_plen);
2184 if (m->m_len < off + icmp6len) {
2185 m = m_pullup(m, off + icmp6len);
2191 ip6 = mtod(m,
struct ip6_hdr *);
2192 nd_rd = (
struct nd_redirect *)((caddr_t)ip6 + off);
2194 ifp = m->m_pkthdr.rcvif;
2195 redtgt6 = nd_rd->nd_rd_target;
2196 reddst6 = nd_rd->nd_rd_dst;
2204 src6 = ip6->ip6_src;
2207 "ICMP6 redirect sent from %s rejected; "
2208 "must be from linklocal\n",
2212 if (__predict_false(ip6->ip6_hlim != 255)) {
2213 ICMP6STAT_INC(icp6s_invlhlim);
2215 "ICMP6 redirect sent from %s rejected; "
2216 "hlim=%d (must be 255)\n",
2222 struct nhop_object *nh;
2228 nh =
fib6_lookup(ifp->if_fib, &kdst, scopeid, 0, 0);
2231 nh_addr =
ifatoia6(nh->nh_ifa)->ia_addr.sin6_addr;
2232 if ((nh->nh_flags & NHF_GATEWAY) == 0) {
2234 "ICMP6 redirect rejected; no route "
2235 "with inet6 gateway found for redirect dst: %s\n",
2243 nh_addr = nh->gw6_sa.sin6_addr;
2247 "ICMP6 redirect rejected; "
2248 "not equal to gw-for-src=%s (must be same): "
2256 "ICMP6 redirect rejected; "
2257 "no route found for redirect dst: %s\n",
2264 "ICMP6 redirect rejected; "
2265 "redirect dst must be unicast: %s\n",
2270 is_router = is_onlink = 0;
2273 if (bcmp(&redtgt6, &reddst6,
sizeof(redtgt6)) == 0)
2275 if (!is_router && !is_onlink) {
2277 "ICMP6 redirect rejected; "
2278 "neither router case nor onlink case: %s\n",
2283 icmp6len -=
sizeof(*nd_rd);
2286 nd6log((LOG_INFO,
"%s: invalid ND option, rejected: %s\n",
2294 if (ndopts.nd_opts_tgt_lladdr) {
2295 lladdr = (
char *)(ndopts.nd_opts_tgt_lladdr + 1);
2296 lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
2299 if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
2300 nd6log((LOG_INFO,
"%s: lladdrlen mismatch for %s "
2301 "(if %d, icmp6 packet %d): %s\n",
2303 ifp->if_addrlen, lladdrlen - 2,
2312 is_onlink ? ND_REDIRECT_ONLINK : ND_REDIRECT_ROUTER);
2322 struct sockaddr *gw;
2326 bzero(&sdst,
sizeof(sdst));
2327 bzero(&ssrc,
sizeof(ssrc));
2334 bzero(&sgw,
sizeof(sgw));
2339 gw = (
struct sockaddr *)&sgw;
2340 rt_flags |= RTF_GATEWAY;
2342 gw = ifp->if_addr->ifa_addr;
2343 for (fibnum = 0; fibnum < rt_numfibs; fibnum++)
2344 rib_add_redirect(fibnum, (
struct sockaddr *)&sdst, gw,
2345 (
struct sockaddr *)&ssrc, ifp, rt_flags,
2346 V_icmp6_redirtimeout);
2352 bzero(&sdst,
sizeof(sdst));
2356 pfctlinput(PRC_REDIRECT_HOST, (
struct sockaddr *)&sdst);
2364 ICMP6STAT_INC(icp6s_badredirect);
2374 struct ip6_hdr *sip6;
2375 struct mbuf *m = NULL;
2377 struct ip6_hdr *ip6;
2378 struct nd_redirect *nd_rd;
2379 struct llentry *ln = NULL;
2382 struct ifnet *outif = NULL;
2392 if (!m0 || !nh || !(NH_IS_VALID(nh)) || !(ifp = nh->nh_ifp))
2401 sip6 = mtod(m0,
struct ip6_hdr *);
2402 bzero(&src_sa,
sizeof(src_sa));
2420#if IPV6_MMTU >= MCLBYTES
2421# error assumption failed about IPV6_MMTU and MCLBYTES
2423 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
2426 M_SETFIB(m, M_GETFIB(m0));
2427 maxlen = M_TRAILINGSPACE(m);
2428 maxlen = min(IPV6_MMTU, maxlen);
2430 if (maxlen <
sizeof(
struct ip6_hdr) +
sizeof(
struct icmp6_hdr) +
2431 ((
sizeof(
struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7)) {
2448 if (nh->nh_flags & NHF_GATEWAY) {
2453 router_ll6 = (
struct in6_addr *)NULL;
2455 router_ll6 = (
struct in6_addr *)NULL;
2458 ip6 = mtod(m,
struct ip6_hdr *);
2460 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
2461 ip6->ip6_vfc |= IPV6_VERSION;
2463 ip6->ip6_nxt = IPPROTO_ICMPV6;
2464 ip6->ip6_hlim = 255;
2466 bcopy(ifp_ll6, &ip6->ip6_src,
sizeof(
struct in6_addr));
2467 bcopy(&sip6->ip6_src, &ip6->ip6_dst,
sizeof(
struct in6_addr));
2470 nd_rd = (
struct nd_redirect *)(ip6 + 1);
2471 nd_rd->nd_rd_type = ND_REDIRECT;
2472 nd_rd->nd_rd_code = 0;
2473 nd_rd->nd_rd_reserved = 0;
2474 if (nh->nh_flags & NHF_GATEWAY) {
2481 bcopy(router_ll6, &nd_rd->nd_rd_target,
2482 sizeof(nd_rd->nd_rd_target));
2483 bcopy(&sip6->ip6_dst, &nd_rd->nd_rd_dst,
2484 sizeof(nd_rd->nd_rd_dst));
2487 bcopy(&sip6->ip6_dst, &nd_rd->nd_rd_target,
2488 sizeof(nd_rd->nd_rd_target));
2489 bcopy(&sip6->ip6_dst, &nd_rd->nd_rd_dst,
2490 sizeof(nd_rd->nd_rd_dst));
2493 p = (u_char *)(nd_rd + 1);
2501 struct nd_opt_hdr *nd_opt;
2504 ln =
nd6_lookup(router_ll6, LLE_SF(AF_INET6, 0), ifp);
2508 len =
sizeof(*nd_opt) + ifp->if_addrlen;
2509 len = (len + 7) & ~7;
2511 if (len + (p - (u_char *)ip6) > maxlen)
2514 if (ln->la_flags & LLE_VALID) {
2515 nd_opt = (
struct nd_opt_hdr *)p;
2516 nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
2517 nd_opt->nd_opt_len = len >> 3;
2518 lladdr = (
char *)(nd_opt + 1);
2519 bcopy(ln->ll_addr, lladdr, ifp->if_addrlen);
2527 m->m_pkthdr.len = m->m_len = p - (u_char *)ip6;
2534 if (p - (u_char *)ip6 > maxlen)
2540 struct nd_opt_rd_hdr *nd_opt_rh;
2546 len = maxlen - (p - (u_char *)ip6);
2550 if (m0->m_pkthdr.len != m0->m_len) {
2552 m_freem(m0->m_next);
2555 m0->m_pkthdr.len = m0->m_len;
2569 if (m0->m_next || m0->m_pkthdr.len != m0->m_len)
2570 panic(
"assumption failed in %s:%d", __FILE__,
2573 if (len -
sizeof(*nd_opt_rh) < m0->m_pkthdr.len) {
2575 m0->m_pkthdr.len = m0->m_len = len -
2581 extra = m0->m_pkthdr.len % 8;
2584 if (8 - extra <= M_TRAILINGSPACE(m0)) {
2586 m0->m_len += (8 - extra);
2587 m0->m_pkthdr.len += (8 - extra);
2590 m0->m_pkthdr.len -= extra;
2594 len = m0->m_pkthdr.len +
sizeof(*nd_opt_rh);
2595 m0->m_pkthdr.len = m0->m_len = len -
2599 nd_opt_rh = (
struct nd_opt_rd_hdr *)p;
2600 bzero(nd_opt_rh,
sizeof(*nd_opt_rh));
2601 nd_opt_rh->nd_opt_rh_type = ND_OPT_REDIRECTED_HEADER;
2602 nd_opt_rh->nd_opt_rh_len = len >> 3;
2603 p +=
sizeof(*nd_opt_rh);
2604 m->m_pkthdr.len = m->m_len = p - (u_char *)ip6;
2607 m_tag_delete_chain(m0, NULL);
2608 m0->m_flags &= ~M_PKTHDR;
2610 m->m_pkthdr.len = m->m_len + m0->m_len;
2625 ip6->ip6_plen = htons(m->m_pkthdr.len -
sizeof(
struct ip6_hdr));
2627 nd_rd->nd_rd_cksum = 0;
2628 nd_rd->nd_rd_cksum =
in6_cksum(m, IPPROTO_ICMPV6,
2629 sizeof(*ip6), ntohs(ip6->ip6_plen));
2632 mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
sizeof(
unsigned short),
2636 *(
unsigned short *)(mtag + 1) = nd_rd->nd_rd_type;
2637 m_tag_prepend(m, mtag);
2641 ip6_output(m, NULL, NULL, 0, NULL, &outif, NULL);
2643 icmp6_ifstat_inc(outif, ifs6_out_msg);
2644 icmp6_ifstat_inc(outif, ifs6_out_redirect);
2646 ICMP6STAT_INC(icp6s_outhist[ND_REDIRECT]);
2665 struct inpcb *inp = sotoinpcb(so);
2666 int level, op, optname;
2669 level = sopt->sopt_level;
2670 op = sopt->sopt_dir;
2671 optname = sopt->sopt_name;
2672 optlen = sopt->sopt_valsize;
2674 level = op = optname = optlen = 0;
2676 if (level != IPPROTO_ICMPV6) {
2685 struct icmp6_filter ic6f;
2687 if (optlen !=
sizeof(ic6f)) {
2691 error = sooptcopyin(sopt, &ic6f, optlen, optlen);
2694 *inp->in6p_icmp6filt = ic6f;
2701 error = ENOPROTOOPT;
2710 struct icmp6_filter ic6f;
2713 ic6f = *inp->in6p_icmp6filt;
2715 error = sooptcopyout(sopt, &ic6f,
sizeof(ic6f));
2720 error = ENOPROTOOPT;
static int ni6_dnsmatch(const char *, int, const char *, int)
static void icmp6_errcount(int, int)
void icmp6_slowtimo(void)
static int icmp6_notify_error(struct mbuf **, int, int, int)
void icmp6_redirect_output(struct mbuf *m0, struct nhop_object *nh)
static int ni6_addrs(struct icmp6_nodeinfo *, struct mbuf *, struct ifnet **, struct in6_addr *)
void icmp6_fasttimo(void)
static int icmp6_rip6_input(struct mbuf **, int)
static int icmp6_ratelimit(const struct in6_addr *, const int, const int)
void icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
static bool icmp6_rip6_match(const struct inpcb *inp, void *v)
static int ni6_store_addrs(struct icmp6_nodeinfo *, struct icmp6_nodeinfo *, struct ifnet *, int)
#define V_icmp6errppslim_last
VNET_PCPUSTAT_DEFINE(struct icmp6stat, icmp6stat)
void icmp6_error2(struct mbuf *m, int type, int code, int param, struct ifnet *ifp)
struct domain inet6domain
static void icmp6_reflect(struct mbuf *, size_t)
void icmp6_error(struct mbuf *m, int type, int code, int param)
int icmp6_input(struct mbuf **mp, int *offp, int proto)
static struct mbuf * ni6_nametodns(const char *, int, int)
int icmp6_ctloutput(struct socket *so, struct sockopt *sopt)
VNET_PCPUSTAT_SYSINIT(icmp6stat)
static struct mbuf * ni6_input(struct mbuf *, int, struct prison *)
#define V_icmp6errpps_count
void icmp6_redirect_input(struct mbuf *m, int off)
static const char * icmp6_redirect_diag(struct in6_addr *, struct in6_addr *, struct in6_addr *)
VNET_DECLARE(struct inpcbinfo, ripcbinfo)
VNET_DEFINE_STATIC(int, icmp6errpps_count)=0
void kmod_icmp6stat_inc(int statnum)
struct in6_ifaddr * in6ifa_ifpforlinklocal(struct ifnet *ifp, int ignoreflags)
char * ip6_sprintf(char *ip6buf, const struct in6_addr *addr)
struct in6_ifaddr * in6ifa_ifwithaddr(const struct in6_addr *addr, uint32_t zoneid, bool referenced)
#define IPV6_RTHDR_TYPE_0
#define IPV6_ADDR_SCOPE_GLOBAL
int in6_addrscope(const struct in6_addr *)
#define IN6_IS_ADDR_LINKLOCAL(a)
#define IN6_IS_ADDR_MC_LINKLOCAL(a)
#define IN6_IS_ADDR_UNSPECIFIED(a)
#define IN6_IS_ADDR_LOOPBACK(a)
#define IN6_ARE_ADDR_EQUAL(a, b)
int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t)
#define IN6_IS_ADDR_MULTICAST(a)
#define IPV6_ADDR_SCOPE_LINKLOCAL
#define IPV6_ADDR_SCOPE_SITELOCAL
struct nhop_object * fib6_lookup(uint32_t fibnum, const struct in6_addr *dst6, uint32_t scopeid, uint32_t flags, uint32_t flowid)
int in6_selectsrc_addr(uint32_t fibnum, const struct in6_addr *dst, uint32_t scopeid, struct ifnet *ifp, struct in6_addr *srcp, int *hlim)
#define IN6_IFF_DEPRECATED
#define IN6_IFF_TEMPORARY
static __inline struct in6_multi * in6m_lookup(struct ifnet *ifp, const struct in6_addr *mcaddr)
#define in6_ifstat_inc(ifp, tag)
static struct sockaddr_in6 sin6
int ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro, int flags, struct ip6_moptions *im6o, struct ifnet **ifpp, struct inpcb *inp)
#define IP6STAT_INC(name)
#define IP6STAT_DEC(name)
int mld_input(struct mbuf **mp, int off, int icmp6len)
int nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp)
struct llentry * nd6_lookup(const struct in6_addr *addr6, int flags, struct ifnet *ifp)
void nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, int lladdrlen, int type, int code)
int nd6_options(union nd_opts *ndopts)
int(* send_sendso_input_hook)(struct mbuf *, struct ifnet *, int, int)
void nd6_option_init(void *opt, int icmp6len, union nd_opts *ndopts)
void nd6_ra_input(struct mbuf *, int, int)
void nd6_rs_input(struct mbuf *, int, int)
#define ND6_INFINITE_LIFETIME
void nd6_ns_input(struct mbuf *, int, int)
void nd6_na_input(struct mbuf *, int, int)
int in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
void in6_splitscope(const struct in6_addr *src, struct in6_addr *dst, uint32_t *scopeid)
int in6_clearscope(struct in6_addr *in6)
int sa6_recoverscope(struct sockaddr_in6 *sin6)
struct sockaddr_in6 ia_addr
struct in6_addrlifetime ia6_lifetime
struct ip6_hdr * ip6c_ip6
struct icmp6_hdr * ip6c_icmp6
struct in6_addr * ip6c_finaldst
struct sockaddr_in6 * ip6c_src
struct in6_addr sin6_addr