#ifndef _NETINET6_ND6_H_
#define _NETINET6_ND6_H_
#include <sys/queue.h>
#include <sys/callout.h>
#ifndef _KERNEL
#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
struct nd_ifinfo {
uint8_t chlim;
uint32_t basereachable;
uint32_t retrans;
uint32_t flags;
};
#ifdef _KERNEL
struct nd_kifinfo {
uint8_t chlim;
uint32_t basereachable;
uint32_t retrans;
uint32_t flags;
int recalctm;
uint32_t reachable;
};
#endif
#define ND6_IFF_PERFORMNUD 0x01
#define ND6_IFF_PREFER_SOURCE 0x04
#define ND6_IFF_IFDISABLED 0x08
#define ND6_IFF_AUTO_LINKLOCAL 0x20
#ifdef _KERNEL
#define ND_IFINFO(ifp) \
(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
#endif
struct in6_nbrinfo {
char ifname[IFNAMSIZ];
struct in6_addr addr;
long asked;
int isrouter;
int state;
int expire;
};
struct in6_ndireq {
char ifname[IFNAMSIZ];
struct nd_ifinfo ndi;
};
#define MAX_RTR_SOLICITATION_DELAY 1
#define ND6_INFINITE_LIFETIME ((u_int32_t)~0)
#ifdef _KERNEL
#include <sys/mallocvar.h>
MALLOC_DECLARE(M_IP6NDP);
extern int nd6_prune;
extern int nd6_useloopback;
extern int nd6_debug;
extern struct nd_domain nd6_nd_domain;
#define nd6log(level, fmt, args...) \
do { if (nd6_debug) log(level, "%s: " fmt, __func__, ##args);} while (0)
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))
union nd_opts {
struct nd_opt_hdr *nd_opt_array[16];
struct {
struct nd_opt_hdr *zero;
struct nd_opt_hdr *src_lladdr;
struct nd_opt_hdr *tgt_lladdr;
struct nd_opt_prefix_info *pi_beg;
struct nd_opt_rd_hdr *rh;
struct nd_opt_mtu *mtu;
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;
struct nd_opt_hdr *search;
struct nd_opt_hdr *last;
int done;
struct nd_opt_prefix_info *pi_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
#define nd_opts_nonce nd_opt_each.nonce
#define nd_opts_search nd_opt_each.search
#define nd_opts_last nd_opt_each.last
#define nd_opts_done nd_opt_each.done
#include <net/if_llatbl.h>
void nd6_init(void);
void nd6_nbr_init(void);
struct nd_kifinfo *nd6_ifattach(struct ifnet *);
void nd6_ifdetach(struct ifnet *, struct in6_ifextra *);
int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *);
void nd6_option_init(void *, int, union nd_opts *);
int nd6_options(union nd_opts *);
struct llentry *nd6_lookup(const struct in6_addr *, const struct ifnet *, bool);
struct llentry *nd6_create(const struct in6_addr *, const struct ifnet *);
void nd6_purge(struct ifnet *, struct in6_ifextra *);
void nd6_nud_hint(struct rtentry *);
int nd6_resolve(struct ifnet *, const struct rtentry *, struct mbuf *,
const struct sockaddr *, uint8_t *, size_t);
void nd6_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
int nd6_ioctl(u_long, void *, struct ifnet *);
void nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
char *, int, int, int);
int nd6_sysctl(int, void *, size_t *, void *, size_t);
int nd6_need_cache(struct ifnet *);
void nd6_llinfo_release_pkts(struct llentry *, struct ifnet *);
void nd6_na_input(struct mbuf *, int, int);
void nd6_na_output(struct ifnet *, const struct in6_addr *,
const struct in6_addr *, u_long, int, const struct sockaddr *);
void nd6_ns_input(struct mbuf *, int, int);
void nd6_ns_output(struct ifnet *, const struct in6_addr *,
const struct in6_addr *, const struct in6_addr *, const uint8_t *);
const void *nd6_ifptomac(const struct ifnet *);
void nd6_dad_start(struct ifaddr *, int);
void nd6_dad_stop(struct ifaddr *);
void nd6_rtr_cache(struct mbuf *, int, int, int);
#endif
#endif