2020-09-11 18:03:33 +03:00
|
|
|
/* $NetBSD: nd6.h,v 1.91 2020/09/11 15:03:33 roy Exp $ */
|
2002-06-09 01:22:29 +04:00
|
|
|
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
|
1999-07-04 01:24:45 +04:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
2000-04-16 19:00:56 +04:00
|
|
|
*
|
1999-06-28 10:36:47 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2000-04-16 19:00:56 +04:00
|
|
|
*
|
1999-06-28 10:36:47 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETINET6_ND6_H_
|
|
|
|
#define _NETINET6_ND6_H_
|
|
|
|
|
|
|
|
#include <sys/queue.h>
|
2000-03-23 10:01:25 +03:00
|
|
|
#include <sys/callout.h>
|
1999-06-28 10:36:47 +04:00
|
|
|
|
2020-09-11 18:03:33 +03:00
|
|
|
#ifndef _KERNEL
|
|
|
|
/* Backwards compat */
|
|
|
|
#include <net/nd.h>
|
|
|
|
#define ND6_LLINFO_PURGE ND_LLINFO_PURGE
|
|
|
|
#define ND6_LLINFO_NOSTATE ND_LLINFO_NOSTATE
|
|
|
|
#define ND6_LLINFO_WAITDELETE ND_LLINFO_WAITDELETE
|
|
|
|
#define ND6_LLINFO_INCOMPLETE ND_LLINFO_INCOMPLETE
|
|
|
|
#define ND6_LLINFO_REACHABLE ND_LLINFO_REACHABLE
|
|
|
|
#define ND6_LLINFO_STALE ND_LLINFO_STALE
|
|
|
|
#define ND6_LLINFO_DELAY ND_LLINFO_DELAY
|
|
|
|
#define ND6_LLINFO_PROBE ND_LLINFO_PROBE
|
|
|
|
#endif
|
2002-05-29 11:53:39 +04:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_ifinfo {
|
2020-06-12 14:04:44 +03:00
|
|
|
uint8_t chlim; /* CurHopLimit */
|
|
|
|
uint32_t basereachable; /* BaseReachableTime */
|
|
|
|
uint32_t retrans; /* Retrans Timer */
|
|
|
|
uint32_t flags; /* Flags */
|
|
|
|
};
|
|
|
|
#ifdef _KERNEL
|
|
|
|
struct nd_kifinfo {
|
|
|
|
uint8_t chlim; /* CurHopLimit */
|
|
|
|
uint32_t basereachable; /* BaseReachableTime */
|
|
|
|
uint32_t retrans; /* Retrans Timer */
|
|
|
|
uint32_t flags; /* Flags */
|
1999-12-13 18:17:17 +03:00
|
|
|
int recalctm; /* BaseReacable re-calculation timer */
|
2020-06-12 14:04:44 +03:00
|
|
|
uint32_t reachable; /* Reachable Time */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
2020-06-12 14:04:44 +03:00
|
|
|
#endif
|
1999-06-28 10:36:47 +04:00
|
|
|
|
2009-11-06 23:41:22 +03:00
|
|
|
#define ND6_IFF_PERFORMNUD 0x01
|
2020-06-12 14:04:44 +03:00
|
|
|
/* 0x02 was ND6_IFF_ACCEPT_RTADV */
|
2009-11-06 23:41:22 +03:00
|
|
|
#define ND6_IFF_PREFER_SOURCE 0x04 /* XXX: not related to ND. */
|
|
|
|
#define ND6_IFF_IFDISABLED 0x08 /* IPv6 operation is disabled due to
|
|
|
|
* DAD failure. (XXX: not ND-specific)
|
|
|
|
*/
|
2020-06-12 14:04:44 +03:00
|
|
|
/* 0x10 was ND6_IFF_OVERRIDE_RTADV */
|
2014-06-05 20:06:49 +04:00
|
|
|
#define ND6_IFF_AUTO_LINKLOCAL 0x20
|
2009-11-06 23:41:22 +03:00
|
|
|
|
2002-05-29 11:53:39 +04:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#define ND_IFINFO(ifp) \
|
|
|
|
(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
|
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct in6_nbrinfo {
|
|
|
|
char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
|
|
|
|
struct in6_addr addr; /* IPv6 address of the neighbor */
|
|
|
|
long asked; /* number of queries already sent for this addr */
|
|
|
|
int isrouter; /* if it acts as a router */
|
|
|
|
int state; /* reachability state */
|
|
|
|
int expire; /* lifetime for NDP state transition */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct in6_ndireq {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
struct nd_ifinfo ndi;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* protocol constants */
|
2001-12-18 06:04:02 +03:00
|
|
|
#define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
|
2009-01-15 21:20:48 +03:00
|
|
|
#define ND6_INFINITE_LIFETIME ((u_int32_t)~0)
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
#ifdef _KERNEL
|
2003-02-01 09:23:35 +03:00
|
|
|
#include <sys/mallocvar.h>
|
|
|
|
MALLOC_DECLARE(M_IP6NDP);
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/* nd6.c */
|
|
|
|
extern int nd6_prune;
|
|
|
|
extern int nd6_useloopback;
|
2001-02-07 11:59:47 +03:00
|
|
|
extern int nd6_debug;
|
|
|
|
|
2020-09-11 18:03:33 +03:00
|
|
|
extern struct nd_domain nd6_nd_domain;
|
|
|
|
|
2016-04-01 11:12:00 +03:00
|
|
|
#define nd6log(level, fmt, args...) \
|
|
|
|
do { if (nd6_debug) log(level, "%s: " fmt, __func__, ##args);} while (0)
|
1999-06-28 10:36:47 +04:00
|
|
|
|
2016-12-19 10:51:34 +03:00
|
|
|
extern krwlock_t nd6_lock;
|
|
|
|
|
|
|
|
#define ND6_RLOCK() rw_enter(&nd6_lock, RW_READER)
|
|
|
|
#define ND6_WLOCK() rw_enter(&nd6_lock, RW_WRITER)
|
|
|
|
#define ND6_UNLOCK() rw_exit(&nd6_lock)
|
|
|
|
#define ND6_ASSERT_WLOCK() KASSERT(rw_write_held(&nd6_lock))
|
|
|
|
#define ND6_ASSERT_LOCK() KASSERT(rw_lock_held(&nd6_lock))
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
union nd_opts {
|
2018-03-06 13:57:00 +03:00
|
|
|
struct nd_opt_hdr *nd_opt_array[16]; /* max = ND_OPT_NONCE */
|
1999-06-28 10:36:47 +04:00
|
|
|
struct {
|
|
|
|
struct nd_opt_hdr *zero;
|
|
|
|
struct nd_opt_hdr *src_lladdr;
|
|
|
|
struct nd_opt_hdr *tgt_lladdr;
|
2002-05-29 11:53:39 +04:00
|
|
|
struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_opt_rd_hdr *rh;
|
|
|
|
struct nd_opt_mtu *mtu;
|
2018-03-06 13:57:00 +03:00
|
|
|
struct nd_opt_hdr *__res6;
|
|
|
|
struct nd_opt_hdr *__res7;
|
|
|
|
struct nd_opt_hdr *__res8;
|
|
|
|
struct nd_opt_hdr *__res9;
|
|
|
|
struct nd_opt_hdr *__res10;
|
|
|
|
struct nd_opt_hdr *__res11;
|
|
|
|
struct nd_opt_hdr *__res12;
|
|
|
|
struct nd_opt_hdr *__res13;
|
|
|
|
struct nd_opt_nonce *nonce;
|
|
|
|
struct nd_opt_hdr *__res15;
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_opt_hdr *search; /* multiple opts */
|
|
|
|
struct nd_opt_hdr *last; /* multiple opts */
|
|
|
|
int done;
|
|
|
|
struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
|
|
|
|
} nd_opt_each;
|
|
|
|
};
|
|
|
|
#define nd_opts_src_lladdr nd_opt_each.src_lladdr
|
|
|
|
#define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr
|
|
|
|
#define nd_opts_pi nd_opt_each.pi_beg
|
|
|
|
#define nd_opts_pi_end nd_opt_each.pi_end
|
|
|
|
#define nd_opts_rh nd_opt_each.rh
|
|
|
|
#define nd_opts_mtu nd_opt_each.mtu
|
2018-03-06 13:57:00 +03:00
|
|
|
#define nd_opts_nonce nd_opt_each.nonce
|
1999-06-28 10:36:47 +04:00
|
|
|
#define nd_opts_search nd_opt_each.search
|
|
|
|
#define nd_opts_last nd_opt_each.last
|
|
|
|
#define nd_opts_done nd_opt_each.done
|
|
|
|
|
2015-11-25 09:21:26 +03:00
|
|
|
#include <net/if_llatbl.h>
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/* XXX: need nd6_var.h?? */
|
|
|
|
/* nd6.c */
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_init(void);
|
2019-09-25 12:52:32 +03:00
|
|
|
void nd6_nbr_init(void);
|
2020-06-12 14:04:44 +03:00
|
|
|
struct nd_kifinfo *nd6_ifattach(struct ifnet *);
|
2015-02-23 22:15:59 +03:00
|
|
|
void nd6_ifdetach(struct ifnet *, struct in6_ifextra *);
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_option_init(void *, int, union nd_opts *);
|
|
|
|
int nd6_options(union nd_opts *);
|
2016-04-04 10:37:07 +03:00
|
|
|
struct llentry *nd6_lookup(const struct in6_addr *, const struct ifnet *, bool);
|
|
|
|
struct llentry *nd6_create(const struct in6_addr *, const struct ifnet *);
|
2015-02-23 22:15:59 +03:00
|
|
|
void nd6_purge(struct ifnet *, struct in6_ifextra *);
|
2015-07-15 12:20:18 +03:00
|
|
|
void nd6_nud_hint(struct rtentry *);
|
2017-02-14 06:05:06 +03:00
|
|
|
int nd6_resolve(struct ifnet *, const struct rtentry *, struct mbuf *,
|
|
|
|
const struct sockaddr *, uint8_t *, size_t);
|
2008-10-24 21:07:33 +04:00
|
|
|
void nd6_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
|
2007-03-16 02:35:25 +03:00
|
|
|
int nd6_ioctl(u_long, void *, struct ifnet *);
|
2015-07-17 05:21:08 +03:00
|
|
|
void nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
|
2007-03-16 02:35:25 +03:00
|
|
|
char *, int, int, int);
|
|
|
|
int nd6_sysctl(int, void *, size_t *, void *, size_t);
|
|
|
|
int nd6_need_cache(struct ifnet *);
|
2016-04-04 10:37:07 +03:00
|
|
|
void nd6_llinfo_release_pkts(struct llentry *, struct ifnet *);
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
/* nd6_nbr.c */
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_na_input(struct mbuf *, int, int);
|
|
|
|
void nd6_na_output(struct ifnet *, const struct in6_addr *,
|
2007-08-07 08:35:42 +04:00
|
|
|
const struct in6_addr *, u_long, int, const struct sockaddr *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_ns_input(struct mbuf *, int, int);
|
|
|
|
void nd6_ns_output(struct ifnet *, const struct in6_addr *,
|
2020-08-20 14:01:02 +03:00
|
|
|
const struct in6_addr *, const struct in6_addr *, const uint8_t *);
|
Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.
Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.
Avoid using sizeof(struct sockaddr_dl) in the kernel.
Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.
Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().
Constify: LLADDR() -> CLLADDR().
Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 06:17:34 +04:00
|
|
|
const void *nd6_ifptomac(const struct ifnet *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_dad_start(struct ifaddr *, int);
|
|
|
|
void nd6_dad_stop(struct ifaddr *);
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
/* nd6_rtr.c */
|
2020-06-12 14:04:44 +03:00
|
|
|
void nd6_rtr_cache(struct mbuf *, int, int, int);
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
2005-12-11 02:31:41 +03:00
|
|
|
#endif /* !_NETINET6_ND6_H_ */
|