#ifndef _NETINET6_IP6_VAR_H_
#define _NETINET6_IP6_VAR_H_
#include <sys/epoch.h>
#ifdef _KERNEL
struct ip6asfrag;
TAILQ_HEAD(ip6fraghead, ip6asfrag);
struct ip6q {
struct ip6fraghead ip6q_frags;
u_int32_t ip6q_ident;
u_int8_t ip6q_nxt;
u_int8_t ip6q_ecn;
u_int16_t ip6q_ttl;
struct in6_addr ip6q_src, ip6q_dst;
TAILQ_ENTRY(ip6q) ip6q_tq;
int ip6q_unfrglen;
int ip6q_nfrag;
struct label *ip6q_label;
};
#endif
struct ip6_direct_ctx {
uint32_t ip6dc_nxt;
uint32_t ip6dc_off;
};
#if defined(_NETINET6_IN6_VAR_H_) && defined(_KERNEL)
struct ip6_moptions {
struct ifnet *im6o_multicast_ifp;
u_char im6o_multicast_hlim;
u_char im6o_multicast_loop;
struct ip6_mfilter_head im6o_head;
};
#else
struct ip6_moptions;
#endif
struct ip6po_rhinfo {
struct ip6_rthdr *ip6po_rhi_rthdr;
struct route_in6 ip6po_rhi_route;
};
#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
#define ip6po_route ip6po_rhinfo.ip6po_rhi_route
struct ip6po_nhinfo {
struct sockaddr *ip6po_nhi_nexthop;
struct route_in6 ip6po_nhi_route;
};
#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route
struct ip6_pktopts {
uint32_t ip6po_valid;
#define IP6PO_VALID_HLIM 0x0001
#define IP6PO_VALID_PKTINFO 0x0002
#define IP6PO_VALID_NHINFO 0x0004
#define IP6PO_VALID_HBH 0x0008
#define IP6PO_VALID_DEST1 0x0010
#define IP6PO_VALID_RHINFO 0x0020
#define IP6PO_VALID_DEST2 0x0040
#define IP6PO_VALID_TC 0x0080
int ip6po_hlim;
int ip6po_tclass;
int ip6po_minmtu;
#define IP6PO_MINMTU_MCASTONLY -1
#define IP6PO_MINMTU_DISABLE 0
#define IP6PO_MINMTU_ALL 1
int ip6po_prefer_tempaddr;
#define IP6PO_TEMPADDR_SYSTEM -1
#define IP6PO_TEMPADDR_NOTPREFER 0
#define IP6PO_TEMPADDR_PREFER 1
int ip6po_flags;
#if 0
#define IP6PO_REACHCONF 0x01
#define IP6PO_MINMTU 0x02
#endif
#define IP6PO_DONTFRAG 0x04
#define IP6PO_USECOA 0x08
struct mbuf *ip6po_m;
struct in6_pktinfo *ip6po_pktinfo;
struct ip6po_nhinfo ip6po_nhinfo;
struct ip6_hbh *ip6po_hbh;
struct ip6_dest *ip6po_dest1;
struct ip6po_rhinfo ip6po_rhinfo;
struct ip6_dest *ip6po_dest2;
};
struct ip6stat {
uint64_t ip6s_total;
uint64_t ip6s_tooshort;
uint64_t ip6s_toosmall;
uint64_t ip6s_fragments;
uint64_t ip6s_fragdropped;
uint64_t ip6s_fragtimeout;
uint64_t ip6s_fragoverflow;
uint64_t ip6s_forward;
uint64_t ip6s_cantforward;
uint64_t ip6s_redirectsent;
uint64_t ip6s_delivered;
uint64_t ip6s_localout;
uint64_t ip6s_odropped;
uint64_t ip6s_reassembled;
uint64_t ip6s_atomicfrags;
uint64_t ip6s_fragmented;
uint64_t ip6s_ofragments;
uint64_t ip6s_cantfrag;
uint64_t ip6s_badoptions;
uint64_t ip6s_noroute;
uint64_t ip6s_badvers;
uint64_t ip6s_rawout;
uint64_t ip6s_badscope;
uint64_t ip6s_notmember;
#define IP6S_HDRCNT 256
uint64_t ip6s_nxthist[IP6S_HDRCNT];
uint64_t ip6s_m1;
#define IP6S_M2MMAX 32
uint64_t ip6s_m2m[IP6S_M2MMAX];
uint64_t ip6s_mext1;
uint64_t ip6s_mext2m;
uint64_t ip6s_exthdrtoolong;
uint64_t ip6s_nogif;
uint64_t ip6s_toomanyhdr;
#define IP6S_RULESMAX 16
#define IP6S_SCOPECNT 16
uint64_t ip6s_sources_none;
uint64_t ip6s_sources_sameif[IP6S_SCOPECNT];
uint64_t ip6s_sources_otherif[IP6S_SCOPECNT];
uint64_t ip6s_sources_samescope[IP6S_SCOPECNT];
uint64_t ip6s_sources_otherscope[IP6S_SCOPECNT];
uint64_t ip6s_sources_deprecated[IP6S_SCOPECNT];
uint64_t ip6s_sources_rule[IP6S_RULESMAX];
};
#ifdef _KERNEL
#include <sys/counter.h>
#include <netinet/in_kdtrace.h>
VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat);
#define IP6STAT_ADD(name, val) \
do { \
MIB_SDT_PROBE1(ip6, count, name, (val)); \
VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)); \
} while (0)
#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val))
#define IP6STAT_INC(name) IP6STAT_ADD(name, 1)
#define IP6STAT_INC2(name, type) \
do { \
MIB_SDT_PROBE2(ip6, count, name, 1, type); \
VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, 1); \
} while (0)
#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1)
#endif
#ifdef _KERNEL
#define IPV6_UNSPECSRC 0x01
#define IPV6_FORWARDING 0x02
#define IPV6_MINMTU 0x04
#ifdef __NO_STRICT_ALIGNMENT
#define IP6_HDR_ALIGNED_P(ip) 1
#else
#define IP6_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0)
#endif
VNET_DECLARE(int, ip6_defhlim);
VNET_DECLARE(int, ip6_defmcasthlim);
VNET_DECLARE(int, ip6_forwarding);
VNET_DECLARE(int, ip6_use_deprecated);
VNET_DECLARE(int, ip6_rr_prune);
VNET_DECLARE(int, ip6_mcast_pmtu);
VNET_DECLARE(int, ip6_v6only);
#define V_ip6_defhlim VNET(ip6_defhlim)
#define V_ip6_defmcasthlim VNET(ip6_defmcasthlim)
#define V_ip6_forwarding VNET(ip6_forwarding)
#define V_ip6_use_deprecated VNET(ip6_use_deprecated)
#define V_ip6_rr_prune VNET(ip6_rr_prune)
#define V_ip6_mcast_pmtu VNET(ip6_mcast_pmtu)
#define V_ip6_v6only VNET(ip6_v6only)
VNET_DECLARE(int, ip6_sendredirects);
VNET_DECLARE(int, ip6_accept_rtadv);
VNET_DECLARE(int, ip6_no_radr);
VNET_DECLARE(int, ip6_norbit_raif);
VNET_DECLARE(int, ip6_rfc6204w3);
VNET_DECLARE(int, ip6_hdrnestlimit);
VNET_DECLARE(int, ip6_dad_count);
VNET_DECLARE(int, ip6_grand_count);
#define V_ip6_sendredirects VNET(ip6_sendredirects)
#define V_ip6_accept_rtadv VNET(ip6_accept_rtadv)
#define V_ip6_no_radr VNET(ip6_no_radr)
#define V_ip6_norbit_raif VNET(ip6_norbit_raif)
#define V_ip6_rfc6204w3 VNET(ip6_rfc6204w3)
#define V_ip6_hdrnestlimit VNET(ip6_hdrnestlimit)
#define V_ip6_dad_count VNET(ip6_dad_count)
#define V_ip6_grand_count VNET(ip6_grand_count)
VNET_DECLARE(int, ip6_auto_flowlabel);
VNET_DECLARE(int, ip6_auto_linklocal);
#define V_ip6_auto_flowlabel VNET(ip6_auto_flowlabel)
#define V_ip6_auto_linklocal VNET(ip6_auto_linklocal)
VNET_DECLARE(int, ip6_use_tempaddr);
VNET_DECLARE(int, ip6_prefer_tempaddr);
VNET_DECLARE(bool, ip6_use_stableaddr);
#define V_ip6_use_tempaddr VNET(ip6_use_tempaddr)
#define V_ip6_prefer_tempaddr VNET(ip6_prefer_tempaddr)
#define V_ip6_use_stableaddr VNET(ip6_use_stableaddr)
#define IP6_IDGEN_RETRIES 3
VNET_DECLARE(u_int, ip6_stableaddr_maxretries);
#define V_ip6_stableaddr_maxretries VNET(ip6_stableaddr_maxretries)
#define IP6_STABLEADDR_NETIFSRC_NAME 0
#define IP6_STABLEADDR_NETIFSRC_ID 1
#define IP6_STABLEADDR_NETIFSRC_MAC 2
VNET_DECLARE(int, ip6_stableaddr_netifsource);
#define V_ip6_stableaddr_netifsource VNET(ip6_stableaddr_netifsource)
VNET_DECLARE(int, ip6_use_defzone);
#define V_ip6_use_defzone VNET(ip6_use_defzone)
VNET_DECLARE(struct pfil_head *, inet6_pfil_head);
#define V_inet6_pfil_head VNET(inet6_pfil_head)
#define PFIL_INET6_NAME "inet6"
VNET_DECLARE(struct pfil_head *, inet6_local_pfil_head);
#define V_inet6_local_pfil_head VNET(inet6_local_pfil_head)
#define PFIL_INET6_LOCAL_NAME "inet6-local"
#ifdef IPSTEALTH
VNET_DECLARE(int, ip6stealth);
#define V_ip6stealth VNET(ip6stealth)
#endif
VNET_DECLARE(bool, ip6_log_cannot_forward);
#define V_ip6_log_cannot_forward VNET(ip6_log_cannot_forward)
extern struct pr_usrreqs rip6_usrreqs;
struct inpcb;
struct socket;
struct sockopt;
struct ucred;
int icmp6_ctloutput(struct socket *, struct sockopt *sopt);
void ip6_input(struct mbuf *);
void ip6_direct_input(struct mbuf *);
void ip6_freepcbopts(struct ip6_pktopts *);
int ip6_unknown_opt(u_int8_t *, struct mbuf *, int);
int ip6_get_prevhdr(const struct mbuf *, int);
int ip6_nexthdr(const struct mbuf *, int, int, int *);
int ip6_lasthdr(const struct mbuf *, int, int, int *);
extern int (*ip6_mforward)(struct ip6_hdr *, struct ifnet *,
struct mbuf *);
int ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *);
struct mbuf **ip6_savecontrol_v4(struct inpcb *, struct mbuf *,
struct mbuf **, int *);
void ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **);
void ip6_notify_pmtu(struct inpcb *, struct sockaddr_in6 *, u_int32_t);
int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
void ip6_forward(struct mbuf *, int);
void ip6_mloopback(struct ifnet *, struct mbuf *);
int ip6_output(struct mbuf *, struct ip6_pktopts *,
struct route_in6 *,
int,
struct ip6_moptions *, struct ifnet **,
struct inpcb *);
int ip6_ctloutput(struct socket *, struct sockopt *);
int ip6_raw_ctloutput(struct socket *, struct sockopt *);
void ip6_initpktopts(struct ip6_pktopts *);
int ip6_setpktopts(struct mbuf *, struct ip6_pktopts *,
struct ip6_pktopts *, struct ucred *, int);
void ip6_clearpktopts(struct ip6_pktopts *, int);
struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int);
int ip6_optlen(struct inpcb *);
int ip6_deletefraghdr(struct mbuf *, int, int);
int ip6_fragment(struct ifnet *, struct mbuf *, int, u_char, int,
uint32_t);
int route6_input(struct mbuf **, int *, int);
void frag6_init(void);
void frag6_destroy(void);
int frag6_input(struct mbuf **, int *, int);
void frag6_drain(void *, int);
void rip6_init(void);
int rip6_ctloutput(struct socket *, struct sockopt *);
int rip6_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *);
int dest6_input(struct mbuf **, int *, int);
int none_input(struct mbuf **, int *, int);
int in6_selectsrc_socket(struct sockaddr_in6 *, struct ip6_pktopts *,
struct inpcb *, struct ucred *, int, struct in6_addr *, int *);
int in6_selectsrc_addr(uint32_t, const struct in6_addr *,
uint32_t, struct ifnet *, struct in6_addr *, int *);
int in6_selectsrc_nbr(uint32_t, const struct in6_addr *,
struct ip6_moptions *, struct ifnet *, struct in6_addr *);
int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
struct ip6_moptions *, struct route_in6 *, struct ifnet **,
struct nhop_object **, u_int, uint32_t);
u_int32_t ip6_randomid(void);
u_int32_t ip6_randomflowlabel(void);
void in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset);
int ip6_log_ratelimit(void);
struct ip6ctlparam {
struct mbuf *ip6c_m;
struct icmp6_hdr *ip6c_icmp6;
struct ip6_hdr *ip6c_ip6;
int ip6c_off;
struct sockaddr_in6 *ip6c_src;
struct sockaddr_in6 *ip6c_dst;
struct sockaddr_in6 *ip6c_finaldst;
void *ip6c_cmdarg;
u_int8_t ip6c_nxt;
};
typedef int ip6proto_input_t(struct mbuf **, int *, int);
typedef void ip6proto_ctlinput_t(struct ip6ctlparam *);
int ip6proto_register(uint8_t, ip6proto_input_t, ip6proto_ctlinput_t);
int ip6proto_unregister(uint8_t);
#define IP6PROTO_REGISTER(prot, input, ctl) do { \
int error __diagused; \
error = ip6proto_register(prot, input, ctl); \
MPASS(error == 0); \
} while (0)
ip6proto_input_t rip6_input;
ip6proto_ctlinput_t rip6_ctlinput;
#endif
#endif