./usr/include/msdosfs/msdosfsmount.h minix-comp
./usr/include/ndbm.h minix-comp
./usr/include/net minix-comp
+./usr/include/net/bpf.h minix-comp
+./usr/include/net/bpfdesc.h minix-comp
+./usr/include/net/bpfjit.h minix-comp
./usr/include/net/dlt.h minix-comp
./usr/include/net/ethertypes.h minix-comp
./usr/include/net/gen minix-comp
./usr/include/net/if_arp.h minix-comp
./usr/include/net/if_dl.h minix-comp
./usr/include/net/if_ether.h minix-comp
+./usr/include/net/if_media.h minix-comp
+./usr/include/net/if_types.h minix-comp
./usr/include/net/netlib.h minix-comp
./usr/include/net/pfil.h minix-comp
+./usr/include/net/pfkeyv2.h minix-comp
./usr/include/net/radix.h minix-comp
./usr/include/net/route.h minix-comp
+./usr/include/net80211 minix-comp
+./usr/include/net80211/_ieee80211.h minix-comp
+./usr/include/net80211/ieee80211.h minix-comp
+./usr/include/net80211/ieee80211_crypto.h minix-comp
+./usr/include/net80211/ieee80211_ioctl.h minix-comp
+./usr/include/net80211/ieee80211_netbsd.h minix-comp
+./usr/include/netatalk minix-comp
+./usr/include/netatalk/at.h minix-comp
+./usr/include/netatalk/ddp_var.h minix-comp
./usr/include/netconfig.h minix-comp
./usr/include/netdb.h minix-comp
./usr/include/netgroup.h minix-comp
./usr/include/netinet minix-comp
+./usr/include/netinet/icmp6.h minix-comp
+./usr/include/netinet/icmp_var.h minix-comp
+./usr/include/netinet/if_ether.h minix-comp
+./usr/include/netinet/if_inarp.h minix-comp
+./usr/include/netinet/igmp.h minix-comp
+./usr/include/netinet/igmp_var.h minix-comp
./usr/include/netinet/in.h minix-comp
+./usr/include/netinet/in_pcb.h minix-comp
+./usr/include/netinet/in_pcb_hdr.h minix-comp
./usr/include/netinet/in_systm.h minix-comp
+./usr/include/netinet/in_var.h minix-comp
./usr/include/netinet/ip.h minix-comp
+./usr/include/netinet/ip6.h minix-comp
+./usr/include/netinet/ip_carp.h minix-comp
./usr/include/netinet/ip_icmp.h minix-comp
+./usr/include/netinet/ip_mroute.h minix-comp
./usr/include/netinet/ip_var.h minix-comp
+./usr/include/netinet/pim_var.h minix-comp
./usr/include/netinet/tcp.h minix-comp
+./usr/include/netinet/tcp_debug.h minix-comp
+./usr/include/netinet/tcp_fsm.h minix-comp
+./usr/include/netinet/tcp_seq.h minix-comp
+./usr/include/netinet/tcp_timer.h minix-comp
+./usr/include/netinet/tcp_var.h minix-comp
+./usr/include/netinet/tcp_vtw.h minix-comp
+./usr/include/netinet/tcpip.h minix-comp
./usr/include/netinet/udp.h minix-comp
./usr/include/netinet/udp_var.h minix-comp
./usr/include/netinet6 minix-comp
./usr/include/netinet6/in6.h minix-comp
+./usr/include/netinet6/in6_pcb.h minix-comp
+./usr/include/netinet6/in6_var.h minix-comp
+./usr/include/netinet6/ip6_mroute.h minix-comp
+./usr/include/netinet6/ip6_var.h minix-comp
+./usr/include/netinet6/nd6.h minix-comp
+./usr/include/netinet6/pim6_var.h minix-comp
+./usr/include/netinet6/raw_ip6.h minix-comp
+./usr/include/netinet6/udp6.h minix-comp
+./usr/include/netinet6/udp6_var.h minix-comp
+./usr/include/netmpls minix-comp
+./usr/include/netmpls/mpls.h minix-comp
./usr/include/netpgp minix-comp
./usr/include/netpgp.h minix-comp crypto
./usr/include/netpgp/verify.h minix-comp crypto
./usr/include/minix
./usr/include/msdosfs
./usr/include/net
+./usr/include/net80211
+./usr/include/netatalk
+./usr/include/netinet
+./usr/include/netinet6
+./usr/include/netmpls
./usr/include/netpgp
./usr/include/openssl
./usr/include/ppath
.include <bsd.own.mk>
SUBDIR= altq arch dev fs \
- net netinet netinet6 \
- \
+ net net80211 netatalk netinet netinet6 \
+ netmpls \
sys ufs uvm
.if !defined(__MINIX)
INCSDIR= /usr/include/net
-INCS= dlt.h ethertypes.h if.h if_arp.h \
+INCS= bpf.h bpfdesc.h bpfjit.h dlt.h ethertypes.h if.h if_arp.h \
if_dl.h if_ether.h \
+ if_media.h \
\
- \
- \
- pfil.h radix.h \
+ if_types.h \
+ pfil.h pfkeyv2.h radix.h \
route.h
.if !defined(__MINIX)
--- /dev/null
+/* $NetBSD: bpf.h,v 1.67 2015/09/05 20:01:21 dholland Exp $ */
+
+/*
+ * Copyright (c) 1990, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)bpf.h 8.2 (Berkeley) 1/9/95
+ * @(#) Header: bpf.h,v 1.36 97/06/12 14:29:53 leres Exp (LBL)
+ */
+
+#ifndef _NET_BPF_H_
+#define _NET_BPF_H_
+
+#include <sys/ioccom.h>
+#include <sys/time.h>
+
+/* BSD style release date */
+#define BPF_RELEASE 199606
+
+/* Date when COP instructions and external memory have been released. */
+#define BPF_COP_EXTMEM_RELEASE 20140624
+
+__BEGIN_DECLS
+
+typedef int bpf_int32;
+typedef u_int bpf_u_int32;
+
+/*
+ * Alignment macros. BPF_WORDALIGN rounds up to the next
+ * even multiple of BPF_ALIGNMENT.
+ */
+#define BPF_ALIGNMENT sizeof(long)
+#define BPF_ALIGNMENT32 sizeof(int)
+
+#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
+#define BPF_WORDALIGN32(x) (((x)+(BPF_ALIGNMENT32-1))&~(BPF_ALIGNMENT32-1))
+
+#define BPF_MAXINSNS 512
+#define BPF_DFLTBUFSIZE (1024*1024) /* default static upper limit */
+#define BPF_MAXBUFSIZE (1024*1024*16) /* hard limit on sysctl'able value */
+#define BPF_MINBUFSIZE 32
+
+/*
+ * Structure for BIOCSETF.
+ */
+struct bpf_program {
+ u_int bf_len;
+ struct bpf_insn *bf_insns;
+};
+
+/*
+ * Struct returned by BIOCGSTATS and net.bpf.stats sysctl.
+ */
+struct bpf_stat {
+ uint64_t bs_recv; /* number of packets received */
+ uint64_t bs_drop; /* number of packets dropped */
+ uint64_t bs_capt; /* number of packets captured */
+ uint64_t bs_padding[13];
+};
+
+/*
+ * Struct returned by BIOCGSTATSOLD.
+ */
+struct bpf_stat_old {
+ u_int bs_recv; /* number of packets received */
+ u_int bs_drop; /* number of packets dropped */
+};
+
+/*
+ * Struct return by BIOCVERSION. This represents the version number of
+ * the filter language described by the instruction encodings below.
+ * bpf understands a program iff kernel_major == filter_major &&
+ * kernel_minor >= filter_minor, that is, if the value returned by the
+ * running kernel has the same major number and a minor number equal
+ * equal to or less than the filter being downloaded. Otherwise, the
+ * results are undefined, meaning an error may be returned or packets
+ * may be accepted haphazardly.
+ * It has nothing to do with the source code version.
+ */
+struct bpf_version {
+ u_short bv_major;
+ u_short bv_minor;
+};
+/* Current version number of filter architecture. */
+#define BPF_MAJOR_VERSION 1
+#define BPF_MINOR_VERSION 1
+
+/*
+ * BPF ioctls
+ *
+ * The first set is for compatibility with Sun's pcc style
+ * header files. If your using gcc, we assume that you
+ * have run fixincludes so the latter set should work.
+ */
+#define BIOCGBLEN _IOR('B',102, u_int)
+#define BIOCSBLEN _IOWR('B',102, u_int)
+#define BIOCSETF _IOW('B',103, struct bpf_program)
+#define BIOCFLUSH _IO('B',104)
+#define BIOCPROMISC _IO('B',105)
+#define BIOCGDLT _IOR('B',106, u_int)
+#define BIOCGETIF _IOR('B',107, struct ifreq)
+#define BIOCSETIF _IOW('B',108, struct ifreq)
+#ifdef COMPAT_50
+#include <compat/sys/time.h>
+#define BIOCSORTIMEOUT _IOW('B',109, struct timeval50)
+#define BIOCGORTIMEOUT _IOR('B',110, struct timeval50)
+#endif
+#define BIOCGSTATS _IOR('B',111, struct bpf_stat)
+#define BIOCGSTATSOLD _IOR('B',111, struct bpf_stat_old)
+#define BIOCIMMEDIATE _IOW('B',112, u_int)
+#define BIOCVERSION _IOR('B',113, struct bpf_version)
+#define BIOCSTCPF _IOW('B',114, struct bpf_program)
+#define BIOCSUDPF _IOW('B',115, struct bpf_program)
+#define BIOCGHDRCMPLT _IOR('B',116, u_int)
+#define BIOCSHDRCMPLT _IOW('B',117, u_int)
+#define BIOCSDLT _IOW('B',118, u_int)
+#define BIOCGDLTLIST _IOWR('B',119, struct bpf_dltlist)
+#define BIOCGSEESENT _IOR('B',120, u_int)
+#define BIOCSSEESENT _IOW('B',121, u_int)
+#define BIOCSRTIMEOUT _IOW('B',122, struct timeval)
+#define BIOCGRTIMEOUT _IOR('B',123, struct timeval)
+#define BIOCGFEEDBACK _IOR('B',124, u_int)
+#define BIOCSFEEDBACK _IOW('B',125, u_int)
+#define BIOCFEEDBACK BIOCSFEEDBACK /* FreeBSD name */
+
+/*
+ * Structure prepended to each packet. This is "wire" format, so we
+ * cannot change it unfortunately to 64 bit times on 32 bit systems [yet].
+ */
+struct bpf_timeval {
+ long tv_sec;
+ long tv_usec;
+};
+
+struct bpf_timeval32 {
+ int32_t tv_sec;
+ int32_t tv_usec;
+};
+
+struct bpf_hdr {
+ struct bpf_timeval bh_tstamp; /* time stamp */
+ uint32_t bh_caplen; /* length of captured portion */
+ uint32_t bh_datalen; /* original length of packet */
+ uint16_t bh_hdrlen; /* length of bpf header (this struct
+ plus alignment padding) */
+};
+
+struct bpf_hdr32 {
+ struct bpf_timeval32 bh_tstamp; /* time stamp */
+ uint32_t bh_caplen; /* length of captured portion */
+ uint32_t bh_datalen; /* original length of packet */
+ uint16_t bh_hdrlen; /* length of bpf header (this struct
+ plus alignment padding) */
+};
+/*
+ * Because the structure above is not a multiple of 4 bytes, some compilers
+ * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work.
+ * Only the kernel needs to know about it; applications use bh_hdrlen.
+ * XXX To save a few bytes on 32-bit machines, we avoid end-of-struct
+ * XXX padding by using the size of the header data elements. This is
+ * XXX fail-safe: on new machines, we just use the 'safe' sizeof.
+ */
+#ifdef _KERNEL
+#if defined(__arm32__) || defined(__i386__) || defined(__m68k__) || \
+ defined(__mips__) || defined(__ns32k__) || defined(__vax__) || \
+ defined(__sh__) || (defined(__sparc__) && !defined(__sparc64__))
+#define SIZEOF_BPF_HDR 18
+#define SIZEOF_BPF_HDR32 18
+#else
+#define SIZEOF_BPF_HDR sizeof(struct bpf_hdr)
+#define SIZEOF_BPF_HDR32 sizeof(struct bpf_hdr32)
+#endif
+#endif
+
+/* Pull in data-link level type codes. */
+#include <net/dlt.h>
+
+/*
+ * The instruction encodings.
+ */
+/* instruction classes */
+#define BPF_CLASS(code) ((code) & 0x07)
+#define BPF_LD 0x00
+#define BPF_LDX 0x01
+#define BPF_ST 0x02
+#define BPF_STX 0x03
+#define BPF_ALU 0x04
+#define BPF_JMP 0x05
+#define BPF_RET 0x06
+#define BPF_MISC 0x07
+
+/* ld/ldx fields */
+#define BPF_SIZE(code) ((code) & 0x18)
+#define BPF_W 0x00
+#define BPF_H 0x08
+#define BPF_B 0x10
+/* 0x18 reserved; used by BSD/OS */
+#define BPF_MODE(code) ((code) & 0xe0)
+#define BPF_IMM 0x00
+#define BPF_ABS 0x20
+#define BPF_IND 0x40
+#define BPF_MEM 0x60
+#define BPF_LEN 0x80
+#define BPF_MSH 0xa0
+/* 0xc0 reserved; used by BSD/OS */
+/* 0xe0 reserved; used by BSD/OS */
+
+/* alu/jmp fields */
+#define BPF_OP(code) ((code) & 0xf0)
+#define BPF_ADD 0x00
+#define BPF_SUB 0x10
+#define BPF_MUL 0x20
+#define BPF_DIV 0x30
+#define BPF_OR 0x40
+#define BPF_AND 0x50
+#define BPF_LSH 0x60
+#define BPF_RSH 0x70
+#define BPF_NEG 0x80
+#define BPF_MOD 0x90
+#define BPF_XOR 0xa0
+/* 0xb0 reserved */
+/* 0xc0 reserved */
+/* 0xd0 reserved */
+/* 0xe0 reserved */
+/* 0xf0 reserved */
+#define BPF_JA 0x00
+#define BPF_JEQ 0x10
+#define BPF_JGT 0x20
+#define BPF_JGE 0x30
+#define BPF_JSET 0x40
+/* 0x50 reserved; used by BSD/OS */
+/* 0x60 reserved */
+/* 0x70 reserved */
+/* 0x80 reserved */
+/* 0x90 reserved */
+/* 0xa0 reserved */
+/* 0xb0 reserved */
+/* 0xc0 reserved */
+/* 0xd0 reserved */
+/* 0xe0 reserved */
+/* 0xf0 reserved */
+#define BPF_SRC(code) ((code) & 0x08)
+#define BPF_K 0x00
+#define BPF_X 0x08
+
+/* ret - BPF_K and BPF_X also apply */
+#define BPF_RVAL(code) ((code) & 0x18)
+#define BPF_A 0x10
+/* 0x18 reserved */
+
+/* misc */
+#define BPF_MISCOP(code) ((code) & 0xf8)
+#define BPF_TAX 0x00
+/* 0x10 reserved */
+/* 0x18 reserved */
+#define BPF_COP 0x20
+/* 0x28 reserved */
+/* 0x30 reserved */
+/* 0x38 reserved */
+#define BPF_COPX 0x40 /* XXX: also used by BSD/OS */
+/* 0x48 reserved */
+/* 0x50 reserved */
+/* 0x58 reserved */
+/* 0x60 reserved */
+/* 0x68 reserved */
+/* 0x70 reserved */
+/* 0x78 reserved */
+#define BPF_TXA 0x80
+/* 0x88 reserved */
+/* 0x90 reserved */
+/* 0x98 reserved */
+/* 0xa0 reserved */
+/* 0xa8 reserved */
+/* 0xb0 reserved */
+/* 0xb8 reserved */
+/* 0xc0 reserved; used by BSD/OS */
+/* 0xc8 reserved */
+/* 0xd0 reserved */
+/* 0xd8 reserved */
+/* 0xe0 reserved */
+/* 0xe8 reserved */
+/* 0xf0 reserved */
+/* 0xf8 reserved */
+
+/*
+ * The instruction data structure.
+ */
+struct bpf_insn {
+ uint16_t code;
+ u_char jt;
+ u_char jf;
+ uint32_t k;
+};
+
+/*
+ * Macros for insn array initializers.
+ */
+#define BPF_STMT(code, k) { (uint16_t)(code), 0, 0, k }
+#define BPF_JUMP(code, k, jt, jf) { (uint16_t)(code), jt, jf, k }
+
+/*
+ * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
+ */
+#define BPF_MEMWORDS 16
+
+/*
+ * bpf_memword_init_t: bits indicate which words in the external memory
+ * store will be initialised by the caller before BPF program execution.
+ */
+typedef uint32_t bpf_memword_init_t;
+#define BPF_MEMWORD_INIT(k) (UINT32_C(1) << (k))
+
+/* Note: two most significant bits are reserved by bpfjit. */
+__CTASSERT(BPF_MEMWORDS + 2 <= sizeof(bpf_memword_init_t) * NBBY);
+
+#ifdef _KERNEL
+/*
+ * Max number of external memory words (for BPF_LD|BPF_MEM and BPF_ST).
+ */
+#define BPF_MAX_MEMWORDS 30
+
+__CTASSERT(BPF_MAX_MEMWORDS >= BPF_MEMWORDS);
+__CTASSERT(BPF_MAX_MEMWORDS + 2 <= sizeof(bpf_memword_init_t) * NBBY);
+#endif
+
+/*
+ * Structure to retrieve available DLTs for the interface.
+ */
+struct bpf_dltlist {
+ u_int bfl_len; /* number of bfd_list array */
+ u_int *bfl_list; /* array of DLTs */
+};
+
+struct bpf_ctx;
+typedef struct bpf_ctx bpf_ctx_t;
+
+typedef struct bpf_args {
+ const uint8_t * pkt;
+ size_t wirelen;
+ size_t buflen;
+ /*
+ * The following arguments are used only by some kernel
+ * subsystems.
+ * They aren't required for classical bpf filter programs.
+ * For such programs, bpfjit generated code doesn't read
+ * those arguments at all. Note however that bpf interpreter
+ * always needs a pointer to memstore.
+ */
+ uint32_t * mem; /* pointer to external memory store */
+ void * arg; /* auxiliary argument for a copfunc */
+} bpf_args_t;
+
+#if defined(_KERNEL) || defined(__BPF_PRIVATE)
+
+typedef uint32_t (*bpf_copfunc_t)(const bpf_ctx_t *, bpf_args_t *, uint32_t);
+
+struct bpf_ctx {
+ /*
+ * BPF coprocessor functions and the number of them.
+ */
+ const bpf_copfunc_t * copfuncs;
+ size_t nfuncs;
+
+ /*
+ * The number of memory words in the external memory store.
+ * There may be up to BPF_MAX_MEMWORDS words; if zero is set,
+ * then the internal memory store is used which has a fixed
+ * number of words (BPF_MEMWORDS).
+ */
+ size_t extwords;
+
+ /*
+ * The bitmask indicating which words in the external memstore
+ * will be initialised by the caller.
+ */
+ bpf_memword_init_t preinited;
+};
+#endif
+
+#ifdef _KERNEL
+#include <net/bpfjit.h>
+#include <net/if.h>
+
+struct bpf_if;
+
+struct bpf_ops {
+ void (*bpf_attach)(struct ifnet *, u_int, u_int, struct bpf_if **);
+ void (*bpf_detach)(struct ifnet *);
+ void (*bpf_change_type)(struct ifnet *, u_int, u_int);
+
+ void (*bpf_tap)(struct bpf_if *, u_char *, u_int);
+ void (*bpf_mtap)(struct bpf_if *, struct mbuf *);
+ void (*bpf_mtap2)(struct bpf_if *, void *, u_int, struct mbuf *);
+ void (*bpf_mtap_af)(struct bpf_if *, uint32_t, struct mbuf *);
+ void (*bpf_mtap_sl_in)(struct bpf_if *, u_char *, struct mbuf **);
+ void (*bpf_mtap_sl_out)(struct bpf_if *, u_char *, struct mbuf *);
+};
+
+extern struct bpf_ops *bpf_ops;
+
+static inline void
+bpf_attach(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen)
+{
+ bpf_ops->bpf_attach(_ifp, _dlt, _hdrlen, &_ifp->if_bpf);
+}
+
+static inline void
+bpf_attach2(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen, struct bpf_if **_dp)
+{
+ bpf_ops->bpf_attach(_ifp, _dlt, _hdrlen, _dp);
+}
+
+static inline void
+bpf_tap(struct ifnet *_ifp, u_char *_pkt, u_int _len)
+{
+ if (_ifp->if_bpf)
+ bpf_ops->bpf_tap(_ifp->if_bpf, _pkt, _len);
+}
+
+static inline void
+bpf_mtap(struct ifnet *_ifp, struct mbuf *_m)
+{
+ if (_ifp->if_bpf)
+ bpf_ops->bpf_mtap(_ifp->if_bpf, _m);
+}
+
+static inline void
+bpf_mtap2(struct bpf_if *_bpf, void *_data, u_int _dlen, struct mbuf *_m)
+{
+ bpf_ops->bpf_mtap2(_bpf, _data, _dlen, _m);
+}
+
+static inline void
+bpf_mtap3(struct bpf_if *_bpf, struct mbuf *_m)
+{
+ if (_bpf)
+ bpf_ops->bpf_mtap(_bpf, _m);
+}
+
+static inline void
+bpf_mtap_af(struct ifnet *_ifp, uint32_t _af, struct mbuf *_m)
+{
+ if (_ifp->if_bpf)
+ bpf_ops->bpf_mtap_af(_ifp->if_bpf, _af, _m);
+}
+
+static inline void
+bpf_change_type(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen)
+{
+ bpf_ops->bpf_change_type(_ifp, _dlt, _hdrlen);
+}
+
+static inline void
+bpf_detach(struct ifnet *_ifp)
+{
+ bpf_ops->bpf_detach(_ifp);
+}
+
+static inline void
+bpf_mtap_sl_in(struct ifnet *_ifp, u_char *_hdr, struct mbuf **_m)
+{
+ bpf_ops->bpf_mtap_sl_in(_ifp->if_bpf, _hdr, _m);
+}
+
+static inline void
+bpf_mtap_sl_out(struct ifnet *_ifp, u_char *_hdr, struct mbuf *_m)
+{
+ if (_ifp->if_bpf)
+ bpf_ops->bpf_mtap_sl_out(_ifp->if_bpf, _hdr, _m);
+}
+
+
+void bpf_setops(void);
+
+void bpf_ops_handover_enter(struct bpf_ops *);
+void bpf_ops_handover_exit(void);
+
+void bpfilterattach(int);
+
+bpf_ctx_t *bpf_create(void);
+void bpf_destroy(bpf_ctx_t *);
+
+int bpf_set_cop(bpf_ctx_t *, const bpf_copfunc_t *, size_t);
+int bpf_set_extmem(bpf_ctx_t *, size_t, bpf_memword_init_t);
+u_int bpf_filter_ext(const bpf_ctx_t *, const struct bpf_insn *, bpf_args_t *);
+int bpf_validate_ext(const bpf_ctx_t *, const struct bpf_insn *, int);
+
+bpfjit_func_t bpf_jit_generate(bpf_ctx_t *, void *, size_t);
+void bpf_jit_freecode(bpfjit_func_t);
+
+#endif
+
+int bpf_validate(const struct bpf_insn *, int);
+u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
+
+__END_DECLS
+
+#endif /* !_NET_BPF_H_ */
--- /dev/null
+/* $NetBSD: bpfdesc.h,v 1.38 2013/11/15 00:12:44 rmind Exp $ */
+
+/*
+ * Copyright (c) 1990, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93
+ *
+ * @(#) Header: bpfdesc.h,v 1.14 96/06/16 22:28:07 leres Exp (LBL)
+ */
+
+#ifndef _NET_BPFDESC_H_
+#define _NET_BPFDESC_H_
+
+#include <sys/callout.h>
+#include <sys/selinfo.h> /* for struct selinfo */
+#include <net/if.h> /* for IFNAMSIZ */
+#include <net/bpfjit.h> /* for bpfjit_function_t */
+
+/*
+ * Descriptor associated with each open bpf file.
+ */
+struct bpf_d {
+ struct bpf_d *bd_next; /* Linked list of descriptors */
+ /*
+ * Buffer slots: two mbuf clusters buffer the incoming packets.
+ * The model has three slots. Sbuf is always occupied.
+ * sbuf (store) - Receive interrupt puts packets here.
+ * hbuf (hold) - When sbuf is full, put cluster here and
+ * wakeup read (replace sbuf with fbuf).
+ * fbuf (free) - When read is done, put cluster here.
+ * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
+ */
+ void * bd_sbuf; /* store slot */
+ void * bd_hbuf; /* hold slot */
+ void * bd_fbuf; /* free slot */
+ int bd_slen; /* current length of store buffer */
+ int bd_hlen; /* current length of hold buffer */
+
+ int bd_bufsize; /* absolute length of buffers */
+
+ struct bpf_if * bd_bif; /* interface descriptor */
+ u_long bd_rtout; /* Read timeout in 'ticks' */
+ struct bpf_insn *bd_filter; /* filter code */
+ u_long bd_rcount; /* number of packets received */
+ u_long bd_dcount; /* number of packets dropped */
+ u_long bd_ccount; /* number of packets captured */
+
+ u_char bd_promisc; /* true if listening promiscuously */
+ u_char bd_state; /* idle, waiting, or timed out */
+ u_char bd_immediate; /* true to return on packet arrival */
+ int bd_hdrcmplt; /* false to fill in src lladdr */
+ int bd_seesent; /* true if bpf should see sent packets */
+ int bd_feedback; /* true to feed back sent packets */
+ int bd_async; /* non-zero if packet reception should generate signal */
+ pid_t bd_pgid; /* process or group id for signal */
+#if BSD < 199103
+ u_char bd_selcoll; /* true if selects collide */
+ int bd_timedout;
+ struct proc * bd_selproc; /* process that last selected us */
+#else
+ u_char bd_pad; /* explicit alignment */
+ struct selinfo bd_sel; /* bsd select info */
+#endif
+ callout_t bd_callout; /* for BPF timeouts with select */
+ pid_t bd_pid; /* corresponding PID */
+ LIST_ENTRY(bpf_d) bd_list; /* list of all BPF's */
+ void *bd_sih; /* soft interrupt handle */
+ struct timespec bd_atime; /* access time */
+ struct timespec bd_mtime; /* modification time */
+ struct timespec bd_btime; /* birth time */
+#ifdef _LP64
+ int bd_compat32; /* 32-bit stream on LP64 system */
+#endif
+ bpfjit_func_t bd_jitcode; /* compiled filter program */
+};
+
+
+/* Values for bd_state */
+#define BPF_IDLE 0 /* no select in progress */
+#define BPF_WAITING 1 /* waiting for read timeout in select */
+#define BPF_TIMED_OUT 2 /* read timeout has expired in select */
+
+/*
+ * Description associated with the external representation of each
+ * open bpf file.
+ */
+struct bpf_d_ext {
+ int32_t bde_bufsize;
+ uint8_t bde_promisc;
+ uint8_t bde_state;
+ uint8_t bde_immediate;
+ int32_t bde_hdrcmplt;
+ int32_t bde_seesent;
+ pid_t bde_pid;
+ uint64_t bde_rcount; /* number of packets received */
+ uint64_t bde_dcount; /* number of packets dropped */
+ uint64_t bde_ccount; /* number of packets captured */
+ char bde_ifname[IFNAMSIZ];
+};
+
+
+/*
+ * Descriptor associated with each attached hardware interface.
+ */
+struct bpf_if {
+ struct bpf_if *bif_next; /* list of all interfaces */
+ struct bpf_d *bif_dlist; /* descriptor list */
+ struct bpf_if **bif_driverp; /* pointer into softc */
+ u_int bif_dlt; /* link layer type */
+ u_int bif_hdrlen; /* length of header (with padding) */
+ struct ifnet *bif_ifp; /* corresponding interface */
+};
+
+#ifdef _KERNEL
+int bpf_setf(struct bpf_d *, struct bpf_program *);
+#endif
+
+#endif /* !_NET_BPFDESC_H_ */
--- /dev/null
+/* $NetBSD: bpfjit.h,v 1.4 2014/06/25 19:32:37 alnsn Exp $ */
+
+/*-
+ * Copyright (c) 2011-2014 Alexander Nasonov.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDERS 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 _NET_BPFJIT_H_
+#define _NET_BPFJIT_H_
+
+#ifndef _KERNEL
+#include <stddef.h>
+#include <stdint.h>
+#endif
+
+#include <sys/types.h>
+
+#ifdef __linux
+#include <pcap-bpf.h>
+#else
+#include <net/bpf.h>
+#endif
+
+/*
+ * Return value of a function generated by sljit have sljit_uw type
+ * which can have a greater width. In such cases, we rely on the fact
+ * that calling conventions use same registers for smaller types.
+ * SLJIT_MOV_UI is passed to sljit_emit_return() to make sure that the
+ * return value is truncated to unsigned int.
+ */
+typedef unsigned int (*bpfjit_func_t)(const bpf_ctx_t *, bpf_args_t *);
+
+bpfjit_func_t bpfjit_generate_code(const bpf_ctx_t *,
+ const struct bpf_insn *, size_t);
+void bpfjit_free_code(bpfjit_func_t);
+
+#ifdef _KERNEL
+struct bpfjit_ops {
+ bpfjit_func_t (*bj_generate_code)(const bpf_ctx_t *,
+ const struct bpf_insn *, size_t);
+ void (*bj_free_code)(bpfjit_func_t);
+};
+
+extern struct bpfjit_ops bpfjit_module_ops;
+#endif
+
+#endif /* !_NET_BPFJIT_H_ */
typedef int (*ether_cb_t)(struct ethercom *);
-#if !defined(__minix)
/*
* Structure shared between the ethernet driver modules and
* the multicast list code. For example, each ec_softc or il_softc
struct mowner ec_tx_mowner; /* mbufs transmitted */
#endif
};
-#endif /* !defined(__minix) */
#define ETHERCAP_VLAN_MTU 0x00000001 /* VLAN-compatible MTU */
#define ETHERCAP_VLAN_HWTAGGING 0x00000002 /* hardware VLAN tag support */
#define ETHERCAP_JUMBO_MTU 0x00000004 /* 9000 byte MTU supported */
#define ETHERCAP_MASK 0x00000007
-#if !defined(__minix)
#define ECCAPBITS \
"\020" \
"\1VLAN_MTU" \
int eccr_capabilities; /* supported capabiliites */
int eccr_capenable; /* capabilities enabled */
};
-#endif /* !defined(__minix) */
#ifdef _KERNEL
extern const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN];
void ether_input(struct ifnet *, struct mbuf *);
#endif /* _KERNEL */
-#if !defined(__minix)
/*
* Ethernet multicast address structure. There is one of these for each
* multicast address or range of multicast addresses that we are supposed
uint8_t enm_addrlo[ETHER_ADDR_LEN];
uint8_t enm_addrhi[ETHER_ADDR_LEN];
};
-#endif /* !defined(__minix) */
/*
* Structure used by macros below to remember position when stepping through
--- /dev/null
+/* $NetBSD: if_media.h,v 1.56 2012/10/25 10:59:43 msaitoh Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Copyright (c) 1997
+ * Jonathan Stone and Jason R. Thorpe. All rights reserved.
+ *
+ * This software is derived from information provided by Matt Thomas.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jonathan Stone
+ * and Jason R. Thorpe for the NetBSD Project.
+ * 4. The names of the authors may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHOR 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 _NET_IF_MEDIA_H_
+#define _NET_IF_MEDIA_H_
+
+/*
+ * Prototypes and definitions for BSD/OS-compatible network interface
+ * media selection.
+ *
+ * Where it is safe to do so, this code strays slightly from the BSD/OS
+ * design. Software which uses the API (device drivers, basically)
+ * shouldn't notice any difference.
+ *
+ * Many thanks to Matt Thomas for providing the information necessary
+ * to implement this interface.
+ */
+
+#ifdef _KERNEL
+
+#include <sys/queue.h>
+
+/*
+ * Driver callbacks for media status and change requests.
+ */
+typedef int (*ifm_change_cb_t)(struct ifnet *);
+typedef void (*ifm_stat_cb_t)(struct ifnet *, struct ifmediareq *);
+
+/*
+ * In-kernel representation of a single supported media type.
+ */
+struct ifmedia_entry {
+ TAILQ_ENTRY(ifmedia_entry) ifm_list;
+ u_int ifm_media; /* description of this media attachment */
+ u_int ifm_data; /* for driver-specific use */
+ void *ifm_aux; /* for driver-specific use */
+};
+
+/*
+ * One of these goes into a network interface's softc structure.
+ * It is used to keep general media state.
+ */
+struct ifmedia {
+ u_int ifm_mask; /* mask of changes we don't care about */
+ u_int ifm_media; /* current user-set media word */
+ struct ifmedia_entry *ifm_cur; /* currently selected media */
+ TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
+ ifm_change_cb_t ifm_change; /* media change driver callback */
+ ifm_stat_cb_t ifm_status; /* media status driver callback */
+};
+
+/* Initialize an interface's struct if_media field. */
+void ifmedia_init(struct ifmedia *, int, ifm_change_cb_t, ifm_stat_cb_t);
+
+int ifmedia_change(struct ifmedia *, struct ifnet *);
+
+/* Add one supported medium to a struct ifmedia. */
+void ifmedia_add(struct ifmedia *, int, int, void *);
+
+/* Add an array (of ifmedia_entry) media to a struct ifmedia. */
+void ifmedia_list_add(struct ifmedia *, struct ifmedia_entry *, int);
+
+/* Set default media type on initialization. */
+void ifmedia_set(struct ifmedia *ifm, int mword);
+
+/* Common ioctl function for getting/setting media, called by driver. */
+int ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long);
+
+/* Look up a media entry. */
+struct ifmedia_entry *ifmedia_match(struct ifmedia *, u_int, u_int);
+
+/* Delete all media for a given media instance */
+void ifmedia_delete_instance(struct ifmedia *, u_int);
+
+/* Compute baudrate for a given media. */
+uint64_t ifmedia_baudrate(int);
+
+/* Remove all media */
+void ifmedia_removeall(struct ifmedia *);
+
+#endif /*_KERNEL */
+
+/*
+ * if_media Options word:
+ * Bits Use
+ * ---- -------
+ * 0-4 Media subtype MAX SUBTYPE == 31!
+ * 5-7 Media type
+ * 8-15 Type specific options
+ * 16-18 Mode (for multi-mode devices)
+ * 19 RFU
+ * 20-27 Shared (global) options
+ * 28-31 Instance
+ */
+
+/*
+ * Ethernet
+ */
+#define IFM_ETHER 0x00000020
+#define IFM_10_T 3 /* 10BaseT - RJ45 */
+#define IFM_10_2 4 /* 10Base2 - Thinnet */
+#define IFM_10_5 5 /* 10Base5 - AUI */
+#define IFM_100_TX 6 /* 100BaseTX - RJ45 */
+#define IFM_100_FX 7 /* 100BaseFX - Fiber */
+#define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */
+#define IFM_100_VG 9 /* 100VG-AnyLAN */
+#define IFM_100_T2 10 /* 100BaseT2 */
+#define IFM_1000_SX 11 /* 1000BaseSX - multi-mode fiber */
+#define IFM_10_STP 12 /* 10BaseT over shielded TP */
+#define IFM_10_FL 13 /* 10BaseFL - Fiber */
+#define IFM_1000_LX 14 /* 1000baseLX - single-mode fiber */
+#define IFM_1000_CX 15 /* 1000baseCX - 150ohm STP */
+#define IFM_1000_T 16 /* 1000baseT - 4 pair cat 5 */
+#define IFM_HPNA_1 17 /* HomePNA 1.0 (1Mb/s) */
+#define IFM_10G_LR 18 /* 10GbaseLR - single-mode fiber */
+#define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */
+#define IFM_10G_CX4 20 /* 10GBase CX4 copper */
+#define IFM_2500_SX 21 /* 2500baseSX - multi-mode fiber */
+#define IFM_1000_BX10 22 /* 1000base-BX10 */
+#define IFM_10G_TWINAX 23 /* 10GBase Twinax copper */
+#define IFM_10G_TWINAX_LONG 24 /* 10GBase Twinax Long copper */
+#define IFM_10G_LRM 25 /* 10GBase-LRM 850nm Multi-mode */
+#define IFM_10G_T 26 /* 10GBase-T - RJ45 */
+
+#define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */
+#define IFM_ETH_RXPAUSE 0x00000200 /* receive PAUSE frames */
+#define IFM_ETH_TXPAUSE 0x00000400 /* transmit PAUSE frames */
+
+/*
+ * Token ring
+ */
+#define IFM_TOKEN 0x00000040
+#define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */
+#define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */
+#define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */
+#define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */
+#define IFM_TOK_ETR 0x00000200 /* Early token release */
+#define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */
+#define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */
+
+/*
+ * FDDI
+ */
+#define IFM_FDDI 0x00000060
+#define IFM_FDDI_SMF 3 /* Single-mode fiber */
+#define IFM_FDDI_MMF 4 /* Multi-mode fiber */
+#define IFM_FDDI_UTP 5 /* CDDI / UTP */
+#define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */
+
+/*
+ * IEEE 802.11 Wireless
+ */
+#define IFM_IEEE80211 0x00000080
+#define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */
+#define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */
+#define IFM_IEEE80211_DS2 5 /* Direct Sequence 2Mbps */
+#define IFM_IEEE80211_DS5 6 /* Direct Sequence 5Mbps*/
+#define IFM_IEEE80211_DS11 7 /* Direct Sequence 11Mbps*/
+#define IFM_IEEE80211_DS1 8 /* Direct Sequence 1Mbps */
+#define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */
+#define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */
+#define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */
+#define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */
+#define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */
+#define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */
+#define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */
+#define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */
+#define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */
+#define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */
+#define IFM_IEEE80211_DS354k 19 /* Direct Sequence 354Kbps */
+#define IFM_IEEE80211_DS512k 20 /* Direct Sequence 512Kbps */
+#define IFM_IEEE80211_OFDM3 21 /* OFDM 3Mbps */
+#define IFM_IEEE80211_OFDM4 22 /* OFDM 4.5Mbps */
+#define IFM_IEEE80211_OFDM27 23 /* OFDM 27Mbps */
+/* NB: not enough bits to express MCS fully */
+#define IFM_IEEE80211_MCS 24 /* HT MCS rate */
+
+#define IFM_IEEE80211_ADHOC 0x00000100 /* Operate in Adhoc mode */
+#define IFM_IEEE80211_HOSTAP 0x00000200 /* Operate in Host AP mode */
+#define IFM_IEEE80211_MONITOR 0x00000400 /* Operate in Monitor mode */
+#define IFM_IEEE80211_TURBO 0x00000800 /* Operate in Turbo mode */
+#define IFM_IEEE80211_IBSS 0x00001000 /* Operate in IBSS mode */
+#define IFM_IEEE80211_WDS 0x00002000 /* Operate as an WDS master */
+#define IFM_IEEE80211_MBSS 0x00004000 /* Operate in MBSS mode */
+
+/* operating mode for multi-mode devices */
+#define IFM_IEEE80211_11A 0x00010000 /* 5 GHz, OFDM mode */
+#define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */
+#define IFM_IEEE80211_11G 0x00030000 /* 2 GHz, CCK mode */
+#define IFM_IEEE80211_FH 0x00040000 /* 2 GHz, GFSK mode */
+#define IFM_IEEE80211_11NA 0x00050000 /* 5Ghz, HT mode */
+#define IFM_IEEE80211_11NG 0x00060000 /* 2Ghz, HT mode */
+
+
+/*
+ * Common Address Redundancy Protocol
+ */
+#define IFM_CARP 0x000000c0
+
+/*
+ * Shared media sub-types
+ */
+#define IFM_AUTO 0 /* Autoselect best media */
+#define IFM_MANUAL 1 /* Jumper/dipswitch selects media */
+#define IFM_NONE 2 /* Deselect all media */
+
+/*
+ * Shared options
+ */
+#define IFM_FDX 0x00100000 /* Force full duplex */
+#define IFM_HDX 0x00200000 /* Force half duplex */
+#define IFM_FLOW 0x00400000 /* enable hardware flow control */
+#define IFM_FLAG0 0x01000000 /* Driver defined flag */
+#define IFM_FLAG1 0x02000000 /* Driver defined flag */
+#define IFM_FLAG2 0x04000000 /* Driver defined flag */
+#define IFM_LOOP 0x08000000 /* Put hardware in loopback */
+
+/*
+ * Masks
+ */
+#define IFM_NMASK 0x000000e0 /* Network type */
+#define IFM_TMASK 0x0000001f /* Media sub-type */
+#define IFM_IMASK 0xf0000000 /* Instance */
+#define IFM_ISHIFT 28 /* Instance shift */
+#define IFM_OMASK 0x0000ff00 /* Type specific options */
+#define IFM_MMASK 0x00070000 /* Mode */
+#define IFM_MSHIFT 16 /* Mode shift */
+#define IFM_GMASK 0x0ff00000 /* Global options */
+
+ /* Ethernet flow control mask */
+#define IFM_ETH_FMASK (IFM_FLOW | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE)
+
+#define IFM_NMIN IFM_ETHER /* lowest Network type */
+#define IFM_NMAX IFM_NMASK /* highest Network type */
+
+/*
+ * Status bits
+ */
+#define IFM_AVALID 0x00000001 /* Active bit valid */
+#define IFM_ACTIVE 0x00000002 /* Interface attached to working net */
+
+/* Mask of "status valid" bits, for ifconfig(8). */
+#define IFM_STATUS_VALID IFM_AVALID
+
+/* List of "status valid" bits, for ifconfig(8). */
+#define IFM_STATUS_VALID_LIST { \
+ IFM_AVALID, \
+ 0, \
+}
+
+/*
+ * Macros to extract various bits of information from the media word.
+ */
+#define IFM_TYPE(x) ((x) & IFM_NMASK)
+#define IFM_SUBTYPE(x) ((x) & IFM_TMASK)
+#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT)
+#define IFM_OPTIONS(x) ((x) & (IFM_OMASK | IFM_GMASK))
+#define IFM_MODE(x) ((x) & IFM_MMASK)
+
+#define IFM_INST_MAX IFM_INST(IFM_IMASK)
+#define IFM_INST_ANY ((u_int) -1)
+
+/*
+ * Macro to create a media word.
+ */
+#define IFM_MAKEWORD(type, subtype, options, instance) \
+ ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT))
+#define IFM_MAKEMODE(mode) \
+ (((mode) << IFM_MSHIFT) & IFM_MMASK)
+
+/*
+ * NetBSD extension not defined in the BSDI API. This is used in various
+ * places to get the canonical description for a given type/subtype.
+ *
+ * In the subtype and mediaopt descriptions, the valid TYPE bits are OR'd
+ * in to indicate which TYPE the subtype/option corresponds to. If no
+ * TYPE is present, it is a shared media/mediaopt.
+ *
+ * Note that these are parsed case-insensitive.
+ *
+ * Order is important. The first matching entry is the canonical name
+ * for a media type; subsequent matches are aliases.
+ */
+struct ifmedia_description {
+ int ifmt_word; /* word value; may be masked */
+ const char *ifmt_string; /* description */
+};
+
+#define IFM_TYPE_DESCRIPTIONS { \
+ { IFM_ETHER, "Ethernet" }, \
+ { IFM_ETHER, "ether" }, \
+ { IFM_TOKEN, "TokenRing" }, \
+ { IFM_TOKEN, "token" }, \
+ { IFM_FDDI, "FDDI" }, \
+ { IFM_IEEE80211, "IEEE802.11" }, \
+ { IFM_CARP, "CARP" }, \
+ { 0, NULL }, \
+}
+
+#define IFM_TYPE_MATCH(dt, t) \
+ (IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t)))
+
+#define IFM_SUBTYPE_DESCRIPTIONS { \
+ { IFM_AUTO, "autoselect" }, \
+ { IFM_AUTO, "auto" }, \
+ { IFM_MANUAL, "manual" }, \
+ { IFM_NONE, "none" }, \
+ \
+ { IFM_ETHER | IFM_10_T, "10baseT" }, \
+ { IFM_ETHER | IFM_10_T, "10baseT/UTP" }, \
+ { IFM_ETHER | IFM_10_T, "UTP" }, \
+ { IFM_ETHER | IFM_10_T, "10UTP" }, \
+ { IFM_ETHER | IFM_10_T, "10BASE-T" }, \
+ { IFM_ETHER | IFM_10_2, "10base2" }, \
+ { IFM_ETHER | IFM_10_2, "10base2/BNC" }, \
+ { IFM_ETHER | IFM_10_2, "BNC" }, \
+ { IFM_ETHER | IFM_10_2, "10BNC" }, \
+ { IFM_ETHER | IFM_10_2, "10BASE2" }, \
+ { IFM_ETHER | IFM_10_5, "10base5" }, \
+ { IFM_ETHER | IFM_10_5, "10base5/AUI" }, \
+ { IFM_ETHER | IFM_10_5, "AUI" }, \
+ { IFM_ETHER | IFM_10_5, "10AUI" }, \
+ { IFM_ETHER | IFM_10_5, "10BASE5" }, \
+ { IFM_ETHER | IFM_100_TX, "100baseTX" }, \
+ { IFM_ETHER | IFM_100_TX, "100TX" }, \
+ { IFM_ETHER | IFM_100_TX, "100BASE-TX" }, \
+ { IFM_ETHER | IFM_100_FX, "100baseFX" }, \
+ { IFM_ETHER | IFM_100_FX, "100FX" }, \
+ { IFM_ETHER | IFM_100_FX, "100BASE-FX" }, \
+ { IFM_ETHER | IFM_100_T4, "100baseT4" }, \
+ { IFM_ETHER | IFM_100_T4, "100T4" }, \
+ { IFM_ETHER | IFM_100_T4, "100BASE-T4" }, \
+ { IFM_ETHER | IFM_100_VG, "100baseVG" }, \
+ { IFM_ETHER | IFM_100_VG, "100VG" }, \
+ { IFM_ETHER | IFM_100_VG, "100VG-AnyLAN" }, \
+ { IFM_ETHER | IFM_100_T2, "100baseT2" }, \
+ { IFM_ETHER | IFM_100_T2, "100T2" }, \
+ { IFM_ETHER | IFM_100_T2, "100BASE-T2" }, \
+ { IFM_ETHER | IFM_1000_SX, "1000baseSX" }, \
+ { IFM_ETHER | IFM_1000_SX, "1000SX" }, \
+ { IFM_ETHER | IFM_1000_SX, "1000BASE-SX" }, \
+ { IFM_ETHER | IFM_10_STP, "10baseSTP" }, \
+ { IFM_ETHER | IFM_10_STP, "STP" }, \
+ { IFM_ETHER | IFM_10_STP, "10STP" }, \
+ { IFM_ETHER | IFM_10_STP, "10BASE-STP" }, \
+ { IFM_ETHER | IFM_10_FL, "10baseFL" }, \
+ { IFM_ETHER | IFM_10_FL, "FL" }, \
+ { IFM_ETHER | IFM_10_FL, "10FL" }, \
+ { IFM_ETHER | IFM_10_FL, "10BASE-FL" }, \
+ { IFM_ETHER | IFM_1000_LX, "1000baseLX" }, \
+ { IFM_ETHER | IFM_1000_LX, "1000LX" }, \
+ { IFM_ETHER | IFM_1000_LX, "1000BASE-LX" }, \
+ { IFM_ETHER | IFM_1000_CX, "1000baseCX" }, \
+ { IFM_ETHER | IFM_1000_CX, "1000CX" }, \
+ { IFM_ETHER | IFM_1000_CX, "1000BASE-CX" }, \
+ { IFM_ETHER | IFM_1000_BX10, "1000BASE-BX10" }, \
+ { IFM_ETHER | IFM_1000_T, "1000baseT" }, \
+ { IFM_ETHER | IFM_1000_T, "1000T" }, \
+ { IFM_ETHER | IFM_1000_T, "1000BASE-T" }, \
+ { IFM_ETHER | IFM_HPNA_1, "HomePNA1" }, \
+ { IFM_ETHER | IFM_HPNA_1, "HPNA1" }, \
+ { IFM_ETHER | IFM_10G_LR, "10GbaseLR" }, \
+ { IFM_ETHER | IFM_10G_LR, "10GLR" }, \
+ { IFM_ETHER | IFM_10G_LR, "10GBASE-LR" }, \
+ { IFM_ETHER | IFM_10G_SR, "10GbaseSR" }, \
+ { IFM_ETHER | IFM_10G_SR, "10GSR" }, \
+ { IFM_ETHER | IFM_10G_SR, "10GBASE-SR" }, \
+ { IFM_ETHER | IFM_10G_LRM, "10Gbase-LRM" }, \
+ { IFM_ETHER | IFM_10G_TWINAX, "10Gbase-Twinax" }, \
+ { IFM_ETHER | IFM_10G_TWINAX_LONG, "10Gbase-Twinax-Long" },\
+ { IFM_ETHER | IFM_10G_T, "10Gbase-T" }, \
+ { IFM_ETHER | IFM_10G_CX4, "10GbaseCX4" }, \
+ { IFM_ETHER | IFM_10G_CX4, "10GCX4" }, \
+ { IFM_ETHER | IFM_10G_CX4, "10GBASE-CX4" }, \
+ { IFM_ETHER | IFM_2500_SX, "2500baseSX" }, \
+ { IFM_ETHER | IFM_2500_SX, "2500SX" }, \
+ \
+ { IFM_TOKEN | IFM_TOK_STP4, "DB9/4Mbit" }, \
+ { IFM_TOKEN | IFM_TOK_STP4, "4STP" }, \
+ { IFM_TOKEN | IFM_TOK_STP16, "DB9/16Mbit" }, \
+ { IFM_TOKEN | IFM_TOK_STP16, "16STP" }, \
+ { IFM_TOKEN | IFM_TOK_UTP4, "UTP/4Mbit" }, \
+ { IFM_TOKEN | IFM_TOK_UTP4, "4UTP" }, \
+ { IFM_TOKEN | IFM_TOK_UTP16, "UTP/16Mbit" }, \
+ { IFM_TOKEN | IFM_TOK_UTP16, "16UTP" }, \
+ \
+ { IFM_FDDI | IFM_FDDI_SMF, "Single-mode" }, \
+ { IFM_FDDI | IFM_FDDI_SMF, "SMF" }, \
+ { IFM_FDDI | IFM_FDDI_MMF, "Multi-mode" }, \
+ { IFM_FDDI | IFM_FDDI_MMF, "MMF" }, \
+ { IFM_FDDI | IFM_FDDI_UTP, "UTP" }, \
+ { IFM_FDDI | IFM_FDDI_UTP, "CDDI" }, \
+ \
+ /* \
+ * Short-hand for common media+option combos. \
+ */ \
+ { IFM_ETHER | IFM_10_T | IFM_FDX, "10baseT-FDX" }, \
+ { IFM_ETHER | IFM_10_T | IFM_FDX, "10BASE-T-FDX" }, \
+ { IFM_ETHER | IFM_100_TX | IFM_FDX, "100baseTX-FDX" }, \
+ { IFM_ETHER | IFM_100_TX | IFM_FDX, "100BASE-TX-FDX" }, \
+ { IFM_ETHER | IFM_1000_T | IFM_FDX, "1000baseT-FDX" }, \
+ \
+ /* \
+ * IEEE 802.11 \
+ */ \
+ { IFM_IEEE80211 | IFM_IEEE80211_FH1, "FH1" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_FH2, "FH2" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS1, "DS1" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS2, "DS2" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS5, "DS5" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS11, "DS11" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS22, "DS22" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM6, "OFDM6" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM9, "OFDM9" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM12, "OFDM12" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM18, "OFDM18" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM24, "OFDM24" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM36, "OFDM36" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM48, "OFDM48" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM54, "OFDM54" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM72, "OFDM72" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS354k, "DS/354Kbps" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS512k, "DS/512Kbps" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM3, "OFDM/3Mbps" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM4, "OFDM/4.5Mbps" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM27, "OFDM/27Mbps" }, \
+ \
+ { 0, NULL }, \
+}
+
+#define IFM_MODE_DESCRIPTIONS { \
+ { IFM_AUTO, "autoselect" }, \
+ { IFM_AUTO, "auto" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_11A, "11a" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_11B, "11b" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_11G, "11g" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_FH, "fh" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_11NA, "11na" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_11NG, "11ng" }, \
+ { 0, NULL }, \
+}
+
+#define IFM_OPTION_DESCRIPTIONS { \
+ { IFM_FDX, "full-duplex" }, \
+ { IFM_FDX, "fdx" }, \
+ { IFM_HDX, "half-duplex" }, \
+ { IFM_HDX, "hdx" }, \
+ { IFM_FLOW, "flowcontrol" }, \
+ { IFM_FLOW, "flow" }, \
+ { IFM_FLAG0, "flag0" }, \
+ { IFM_FLAG1, "flag1" }, \
+ { IFM_FLAG2, "flag2" }, \
+ { IFM_LOOP, "loopback" }, \
+ { IFM_LOOP, "hw-loopback"}, \
+ { IFM_LOOP, "loop" }, \
+ \
+ { IFM_ETHER | IFM_ETH_MASTER, "master" }, \
+ { IFM_ETHER | IFM_ETH_RXPAUSE, "rxpause" }, \
+ { IFM_ETHER | IFM_ETH_TXPAUSE, "txpause" }, \
+ \
+ { IFM_TOKEN | IFM_TOK_ETR, "EarlyTokenRelease" }, \
+ { IFM_TOKEN | IFM_TOK_ETR, "ETR" }, \
+ { IFM_TOKEN | IFM_TOK_SRCRT, "SourceRouting" }, \
+ { IFM_TOKEN | IFM_TOK_SRCRT, "SRCRT" }, \
+ { IFM_TOKEN | IFM_TOK_ALLR, "AllRoutes" }, \
+ { IFM_TOKEN | IFM_TOK_ALLR, "ALLR" }, \
+ \
+ { IFM_FDDI | IFM_FDDI_DA, "dual-attach" }, \
+ { IFM_FDDI | IFM_FDDI_DA, "das" }, \
+ \
+ { IFM_IEEE80211 | IFM_IEEE80211_ADHOC, "adhoc" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_HOSTAP, "hostap" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_MONITOR,"monitor" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_TURBO, "turbo" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_IBSS, "ibss" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_WDS, "wds" }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_MBSS, "mesh" }, \
+ \
+ { 0, NULL }, \
+}
+
+/*
+ * Baudrate descriptions for the various media types.
+ */
+struct ifmedia_baudrate {
+ int ifmb_word; /* media word */
+ uint64_t ifmb_baudrate; /* corresponding baudrate */
+};
+
+#define IFM_BAUDRATE_DESCRIPTIONS { \
+ { IFM_ETHER | IFM_10_T, IF_Mbps(10) }, \
+ { IFM_ETHER | IFM_10_2, IF_Mbps(10) }, \
+ { IFM_ETHER | IFM_10_5, IF_Mbps(10) }, \
+ { IFM_ETHER | IFM_100_TX, IF_Mbps(100) }, \
+ { IFM_ETHER | IFM_100_FX, IF_Mbps(100) }, \
+ { IFM_ETHER | IFM_100_T4, IF_Mbps(100) }, \
+ { IFM_ETHER | IFM_100_VG, IF_Mbps(100) }, \
+ { IFM_ETHER | IFM_100_T2, IF_Mbps(100) }, \
+ { IFM_ETHER | IFM_1000_SX, IF_Mbps(1000) }, \
+ { IFM_ETHER | IFM_10_STP, IF_Mbps(10) }, \
+ { IFM_ETHER | IFM_10_FL, IF_Mbps(10) }, \
+ { IFM_ETHER | IFM_1000_LX, IF_Mbps(1000) }, \
+ { IFM_ETHER | IFM_1000_CX, IF_Mbps(1000) }, \
+ { IFM_ETHER | IFM_1000_T, IF_Mbps(1000) }, \
+ { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \
+ { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \
+ { IFM_ETHER | IFM_10G_SR, IF_Gbps(10ULL) }, \
+ { IFM_ETHER | IFM_10G_CX4, IF_Gbps(10ULL) }, \
+ { IFM_ETHER | IFM_2500_SX, IF_Mbps(2500ULL) }, \
+ \
+ { IFM_TOKEN | IFM_TOK_STP4, IF_Mbps(4) }, \
+ { IFM_TOKEN | IFM_TOK_STP16, IF_Mbps(16) }, \
+ { IFM_TOKEN | IFM_TOK_UTP4, IF_Mbps(4) }, \
+ { IFM_TOKEN | IFM_TOK_UTP16, IF_Mbps(16) }, \
+ \
+ { IFM_FDDI | IFM_FDDI_SMF, IF_Mbps(100) }, \
+ { IFM_FDDI | IFM_FDDI_MMF, IF_Mbps(100) }, \
+ { IFM_FDDI | IFM_FDDI_UTP, IF_Mbps(100) }, \
+ \
+ { IFM_IEEE80211 | IFM_IEEE80211_FH1, IF_Mbps(1) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_FH2, IF_Mbps(2) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS2, IF_Mbps(2) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS5, IF_Kbps(5500) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS11, IF_Mbps(11) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS1, IF_Mbps(1) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_DS22, IF_Mbps(22) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \
+ { IFM_IEEE80211 | IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \
+ \
+ { 0, 0 }, \
+}
+
+/*
+ * Status bit descriptions for the various media types.
+ */
+struct ifmedia_status_description {
+ int ifms_type;
+ int ifms_valid;
+ int ifms_bit;
+ const char *ifms_string[2];
+};
+
+#define IFM_STATUS_DESC(ifms, bit) \
+ (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0]
+
+#define IFM_STATUS_DESCRIPTIONS { \
+ { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \
+ { "no carrier", "active" } }, \
+ \
+ { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \
+ { "no ring", "inserted" } }, \
+ \
+ { IFM_TOKEN, IFM_AVALID, IFM_ACTIVE, \
+ { "no ring", "inserted" } }, \
+ \
+ { IFM_IEEE80211, IFM_AVALID, IFM_ACTIVE, \
+ { "no network", "active" } }, \
+ \
+ { IFM_CARP, IFM_AVALID, IFM_ACTIVE, \
+ { "backup", "master" } }, \
+ \
+ { 0, 0, 0, \
+ { NULL, NULL } }, \
+}
+
+#ifndef _KERNEL
+/* Functions for converting media to/from strings, in libutil/if_media.c */
+const char *get_media_type_string(int);
+const char *get_media_subtype_string(int);
+const char *get_media_mode_string(int);
+const char *get_media_option_string(int *);
+int get_media_mode(int, const char *);
+int get_media_subtype(int, const char *);
+int get_media_options(int, const char *, char **);
+int lookup_media_word(struct ifmedia_description *, int, const char *);
+#endif /* _KERNEL */
+
+#endif /* !_NET_IF_MEDIA_H_ */
--- /dev/null
+/* $NetBSD: if_types.h,v 1.26 2012/08/05 21:21:41 wiz Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)if_types.h 8.3 (Berkeley) 4/28/95
+ */
+
+#ifndef _NET_IF_TYPES_H_
+#define _NET_IF_TYPES_H_
+
+/*
+ * Interface types for benefit of parsing media address headers.
+ * This list is derived from the SNMP list of ifTypes, originally
+ * documented in RFC1573, now maintained as:
+ *
+ * <URL:http://www.iana.org/assignments/smi-numbers>
+ */
+
+#define IFT_OTHER 0x1 /* none of the following */
+#define IFT_1822 0x2 /* old-style arpanet imp */
+#define IFT_HDH1822 0x3 /* HDH arpanet imp */
+#define IFT_X25DDN 0x4 /* x25 to imp */
+#define IFT_X25 0x5 /* PDN X25 interface (RFC877) */
+#define IFT_ETHER 0x6 /* Ethernet CSMA/CD */
+#define IFT_ISO88023 0x7 /* CSMA/CD */
+#define IFT_ISO88024 0x8 /* Token Bus */
+#define IFT_ISO88025 0x9 /* Token Ring */
+#define IFT_ISO88026 0xa /* MAN */
+#define IFT_STARLAN 0xb
+#define IFT_P10 0xc /* Proteon 10MBit ring */
+#define IFT_P80 0xd /* Proteon 80MBit ring */
+#define IFT_HY 0xe /* Hyperchannel */
+#define IFT_FDDI 0xf
+#define IFT_LAPB 0x10
+#define IFT_SDLC 0x11
+#define IFT_T1 0x12
+#define IFT_CEPT 0x13 /* E1 - european T1 */
+#define IFT_ISDNBASIC 0x14
+#define IFT_ISDNPRIMARY 0x15
+#define IFT_PTPSERIAL 0x16 /* Proprietary PTP serial */
+#define IFT_PPP 0x17 /* RFC 1331 */
+#define IFT_LOOP 0x18 /* loopback */
+#define IFT_EON 0x19 /* ISO over IP */
+#define IFT_XETHER 0x1a /* obsolete 3MB experimental ethernet */
+#define IFT_NSIP 0x1b /* XNS over IP */
+#define IFT_SLIP 0x1c /* IP over generic TTY */
+#define IFT_ULTRA 0x1d /* Ultra Technologies */
+#define IFT_DS3 0x1e /* Generic T3 */
+#define IFT_SIP 0x1f /* SMDS */
+#define IFT_FRELAY 0x20 /* Frame Relay DTE only */
+#define IFT_RS232 0x21
+#define IFT_PARA 0x22 /* parallel-port */
+#define IFT_ARCNET 0x23
+#define IFT_ARCNETPLUS 0x24
+#define IFT_ATM 0x25 /* ATM cells */
+#define IFT_MIOX25 0x26
+#define IFT_SONET 0x27 /* SONET or SDH */
+#define IFT_X25PLE 0x28
+#define IFT_ISO88022LLC 0x29
+#define IFT_LOCALTALK 0x2a
+#define IFT_SMDSDXI 0x2b
+#define IFT_FRELAYDCE 0x2c /* Frame Relay DCE */
+#define IFT_V35 0x2d
+#define IFT_HSSI 0x2e
+#define IFT_HIPPI 0x2f
+#define IFT_MODEM 0x30 /* Generic Modem */
+#define IFT_AAL5 0x31 /* AAL5 over ATM */
+#define IFT_SONETPATH 0x32
+#define IFT_SONETVT 0x33
+#define IFT_SMDSICIP 0x34 /* SMDS InterCarrier Interface */
+#define IFT_PROPVIRTUAL 0x35 /* Proprietary Virtual/internal */
+#define IFT_PROPMUX 0x36 /* Proprietary Multiplexing */
+#define IFT_IEEE80212 0x37 /* 100BaseVG */
+#define IFT_FIBRECHANNEL 0x38 /* Fibre Channel */
+#define IFT_HIPPIINTERFACE 0x39 /* HIPPI interfaces */
+#define IFT_FRAMERELAYINTERCONNECT 0x3a /* Obsolete, use either 0x20 or 0x2c */
+#define IFT_AFLANE8023 0x3b /* ATM Emulated LAN for 802.3 */
+#define IFT_AFLANE8025 0x3c /* ATM Emulated LAN for 802.5 */
+#define IFT_CCTEMUL 0x3d /* ATM Emulated circuit */
+#define IFT_FASTETHER 0x3e /* Fast Ethernet (100BaseT) */
+#define IFT_ISDN 0x3f /* ISDN and X.25 */
+#define IFT_V11 0x40 /* CCITT V.11/X.21 */
+#define IFT_V36 0x41 /* CCITT V.36 */
+#define IFT_G703AT64K 0x42 /* CCITT G703 at 64Kbps */
+#define IFT_G703AT2MB 0x43 /* Obsolete see DS1-MIB */
+#define IFT_QLLC 0x44 /* SNA QLLC */
+#define IFT_FASTETHERFX 0x45 /* Fast Ethernet (100BaseFX) */
+#define IFT_CHANNEL 0x46 /* channel */
+#define IFT_IEEE80211 0x47 /* radio spread spectrum */
+#define IFT_IBM370PARCHAN 0x48 /* IBM System 360/370 OEMI Channel */
+#define IFT_ESCON 0x49 /* IBM Enterprise Systems Connection */
+#define IFT_DLSW 0x4a /* Data Link Switching */
+#define IFT_ISDNS 0x4b /* ISDN S/T interface */
+#define IFT_ISDNU 0x4c /* ISDN U interface */
+#define IFT_LAPD 0x4d /* Link Access Protocol D */
+#define IFT_IPSWITCH 0x4e /* IP Switching Objects */
+#define IFT_RSRB 0x4f /* Remote Source Route Bridging */
+#define IFT_ATMLOGICAL 0x50 /* ATM Logical Port */
+#define IFT_DS0 0x51 /* Digital Signal Level 0 */
+#define IFT_DS0BUNDLE 0x52 /* group of ds0s on the same ds1 */
+#define IFT_BSC 0x53 /* Bisynchronous Protocol */
+#define IFT_ASYNC 0x54 /* Asynchronous Protocol */
+#define IFT_CNR 0x55 /* Combat Net Radio */
+#define IFT_ISO88025DTR 0x56 /* ISO 802.5r DTR */
+#define IFT_EPLRS 0x57 /* Ext Pos Loc Report Sys */
+#define IFT_ARAP 0x58 /* Appletalk Remote Access Protocol */
+#define IFT_PROPCNLS 0x59 /* Proprietary Connectionless Protocol*/
+#define IFT_HOSTPAD 0x5a /* CCITT-ITU X.29 PAD Protocol */
+#define IFT_TERMPAD 0x5b /* CCITT-ITU X.3 PAD Facility */
+#define IFT_FRAMERELAYMPI 0x5c /* Multiproto Interconnect over FR */
+#define IFT_X213 0x5d /* CCITT-ITU X213 */
+#define IFT_ADSL 0x5e /* Asymmetric Digital Subscriber Loop */
+#define IFT_RADSL 0x5f /* Rate-Adapt. Digital Subscriber Loop*/
+#define IFT_SDSL 0x60 /* Symmetric Digital Subscriber Loop */
+#define IFT_VDSL 0x61 /* Very H-Speed Digital Subscrib. Loop*/
+#define IFT_ISO88025CRFPINT 0x62 /* ISO 802.5 CRFP */
+#define IFT_MYRINET 0x63 /* Myricom Myrinet */
+#define IFT_VOICEEM 0x64 /* voice recEive and transMit */
+#define IFT_VOICEFXO 0x65 /* voice Foreign Exchange Office */
+#define IFT_VOICEFXS 0x66 /* voice Foreign Exchange Station */
+#define IFT_VOICEENCAP 0x67 /* voice encapsulation */
+#define IFT_VOICEOVERIP 0x68 /* voice over IP encapsulation */
+#define IFT_ATMDXI 0x69 /* ATM DXI */
+#define IFT_ATMFUNI 0x6a /* ATM FUNI */
+#define IFT_ATMIMA 0x6b /* ATM IMA */
+#define IFT_PPPMULTILINKBUNDLE 0x6c /* PPP Multilink Bundle */
+#define IFT_IPOVERCDLC 0x6d /* IBM ipOverCdlc */
+#define IFT_IPOVERCLAW 0x6e /* IBM Common Link Access to Workstn */
+#define IFT_STACKTOSTACK 0x6f /* IBM stackToStack */
+#define IFT_VIRTUALIPADDRESS 0x70 /* IBM VIPA */
+#define IFT_MPC 0x71 /* IBM multi-protocol channel support */
+#define IFT_IPOVERATM 0x72 /* IBM ipOverAtm */
+#define IFT_ISO88025FIBER 0x73 /* ISO 802.5j Fiber Token Ring */
+#define IFT_TDLC 0x74 /* IBM twinaxial data link control */
+#define IFT_GIGABITETHERNET 0x75 /* Gigabit Ethernet */
+#define IFT_HDLC 0x76 /* HDLC */
+#define IFT_LAPF 0x77 /* LAP F */
+#define IFT_V37 0x78 /* V.37 */
+#define IFT_X25MLP 0x79 /* Multi-Link Protocol */
+#define IFT_X25HUNTGROUP 0x7a /* X25 Hunt Group */
+#define IFT_TRANSPHDLC 0x7b /* Transp HDLC */
+#define IFT_INTERLEAVE 0x7c /* Interleave channel */
+#define IFT_FAST 0x7d /* Fast channel */
+#define IFT_IP 0x7e /* IP (for APPN HPR in IP networks) */
+#define IFT_DOCSCABLEMACLAYER 0x7f /* CATV Mac Layer */
+#define IFT_DOCSCABLEDOWNSTREAM 0x80 /* CATV Downstream interface */
+#define IFT_DOCSCABLEUPSTREAM 0x81 /* CATV Upstream interface */
+#define IFT_A12MPPSWITCH 0x82 /* Avalon Parallel Processor */
+#define IFT_TUNNEL 0x83 /* Encapsulation interface */
+#define IFT_COFFEE 0x84 /* coffee pot */
+#define IFT_CES 0x85 /* Circiut Emulation Service */
+#define IFT_ATMSUBINTERFACE 0x86 /* (x) ATM Sub Interface */
+#define IFT_L2VLAN 0x87 /* Layer 2 Virtual LAN using 802.1Q */
+#define IFT_L3IPVLAN 0x88 /* Layer 3 Virtual LAN - IP Protocol */
+#define IFT_L3IPXVLAN 0x89 /* Layer 3 Virtual LAN - IPX Prot. */
+#define IFT_DIGITALPOWERLINE 0x8a /* IP over Power Lines */
+#define IFT_MEDIAMAILOVERIP 0x8b /* (xxx) Multimedia Mail over IP */
+#define IFT_DTM 0x8c /* Dynamic synchronous Transfer Mode */
+#define IFT_DCN 0x8d /* Data Communications Network */
+#define IFT_IPFORWARD 0x8e /* IP Forwarding Interface */
+#define IFT_MSDSL 0x8f /* Multi-rate Symmetric DSL */
+#define IFT_IEEE1394 0x90 /* IEEE1394 High Performance SerialBus*/
+#define IFT_IFGSN 0x91 /* HIPPI-6400 */
+#define IFT_DVBRCCMACLAYER 0x92 /* DVB-RCC MAC Layer */
+#define IFT_DVBRCCDOWNSTREAM 0x93 /* DVB-RCC Downstream Channel */
+#define IFT_DVBRCCUPSTREAM 0x94 /* DVB-RCC Upstream Channel */
+#define IFT_ATMVIRTUAL 0x95 /* ATM Virtual Interface */
+#define IFT_MPLSTUNNEL 0x96 /* MPLS Tunnel Virtual Interface */
+#define IFT_SRP 0x97 /* Spatial Reuse Protocol */
+#define IFT_VOICEOVERATM 0x98 /* Voice over ATM */
+#define IFT_VOICEOVERFRAMERELAY 0x99 /* Voice Over Frame Relay */
+#define IFT_IDSL 0x9a /* Digital Subscriber Loop over ISDN */
+#define IFT_COMPOSITELINK 0x9b /* Avici Composite Link Interface */
+#define IFT_SS7SIGLINK 0x9c /* SS7 Signaling Link */
+#define IFT_PROPWIRELESSP2P 0x9d /* Prop. P2P wireless interface */
+#define IFT_FRFORWARD 0x9e /* Frame forward Interface */
+#define IFT_RFC1483 0x9f /* Multiprotocol over ATM AAL5 */
+#define IFT_USB 0xa0 /* USB Interface */
+#define IFT_IEEE8023ADLAG 0xa1 /* IEEE 802.3ad Link Aggregate*/
+#define IFT_BGPPOLICYACCOUNTING 0xa2 /* BGP Policy Accounting */
+#define IFT_FRF16MFRBUNDLE 0xa3 /* FRF.16 Multilik Frame Relay*/
+#define IFT_H323GATEKEEPER 0xa4 /* H323 Gatekeeper */
+#define IFT_H323PROXY 0xa5 /* H323 Voice and Video Proxy */
+#define IFT_MPLS 0xa6 /* MPLS */
+#define IFT_MFSIGLINK 0xa7 /* Multi-frequency signaling link */
+#define IFT_HDSL2 0xa8 /* High Bit-Rate DSL, 2nd gen. */
+#define IFT_SHDSL 0xa9 /* Multirate HDSL2 */
+#define IFT_DS1FDL 0xaa /* Facility Data Link (4Kbps) on a DS1*/
+#define IFT_POS 0xab /* Packet over SONET/SDH Interface */
+#define IFT_DVBASILN 0xac /* DVB-ASI Input */
+#define IFT_DVBASIOUT 0xad /* DVB-ASI Output */
+#define IFT_PLC 0xae /* Power Line Communications */
+#define IFT_NFAS 0xaf /* Non-Facility Associated Signaling */
+#define IFT_TR008 0xb0 /* TROO8 */
+#define IFT_GR303RDT 0xb1 /* Remote Digital Terminal */
+#define IFT_GR303IDT 0xb2 /* Integrated Digital Terminal */
+#define IFT_ISUP 0xb3 /* ISUP */
+#define IFT_PROPDOCSWIRELESSMACLAYER 0xb4 /* prop/Wireless MAC Layer */
+#define IFT_PROPDOCSWIRELESSDOWNSTREAM 0xb5 /* prop/Wireless Downstream */
+#define IFT_PROPDOCSWIRELESSUPSTREAM 0xb6 /* prop/Wireless Upstream */
+#define IFT_HIPERLAN2 0xb7 /* HIPERLAN Type 2 Radio Interface */
+#define IFT_PROPBWAP2MP 0xb8 /* PropBroadbandWirelessAccess P2MP*/
+#define IFT_SONETOVERHEADCHANNEL 0xb9 /* SONET Overhead Channel */
+#define IFT_DIGITALWRAPPEROVERHEADCHANNEL 0xba /* Digital Wrapper Overhead */
+#define IFT_AAL2 0xbb /* ATM adaptation layer 2 */
+#define IFT_RADIOMAC 0xbc /* MAC layer over radio links */
+#define IFT_ATMRADIO 0xbd /* ATM over radio links */
+#define IFT_IMT 0xbe /* Inter-Machine Trunks */
+#define IFT_MVL 0xbf /* Multiple Virtual Lines DSL */
+#define IFT_REACHDSL 0xc0 /* Long Reach DSL */
+#define IFT_FRDLCIENDPT 0xc1 /* Frame Relay DLCI End Point */
+#define IFT_ATMVCIENDPT 0xc2 /* ATM VCI End Point */
+#define IFT_OPTICALCHANNEL 0xc3 /* Optical Channel */
+#define IFT_OPTICALTRANSPORT 0xc4 /* Optical Transport */
+#define IFT_PROPATM 0xc5 /* Proprietary ATM */
+#define IFT_VOICEOVERCABLE 0xc6 /* Voice Over Cable Interface */
+#define IFT_INFINIBAND 0xc7 /* Infiniband */
+#define IFT_TELINK 0xc8 /* TE Link */
+#define IFT_Q2931 0xc9 /* Q.2931 */
+#define IFT_VIRTUALTG 0xca /* Virtual Trunk Group */
+#define IFT_SIPTG 0xcb /* SIP Trunk Group */
+#define IFT_SIPSIG 0xcc /* SIP Signaling */
+#define IFT_DOCSCABLEUPSTREAMCHANNEL 0xcd /* CATV Upstream Channel */
+#define IFT_ECONET 0xce /* Acorn Econet */
+#define IFT_PON155 0xcf /* FSAN 155Mb Symetrical PON interface */
+#define IFT_PON622 0xd0 /* FSAN 622Mb Symetrical PON interface */
+#define IFT_BRIDGE 0xd1 /* Transparent bridge interface */
+#define IFT_LINEGROUP 0xd2 /* Interface common to multiple lines */
+#define IFT_VOICEEMFGD 0xd3 /* voice E&M Feature Group D */
+#define IFT_VOICEFGDEANA 0xd4 /* voice FGD Exchange Access North American */
+#define IFT_VOICEDID 0xd5 /* voice Direct Inward Dialing */
+#define IFT_STF 0xd7 /* 6to4 interface */
+
+/* not based on IANA assignments - how should we treat these? */
+#define IFT_GIF 0xf0
+#define IFT_PVC 0xf1
+#define IFT_FAITH 0xf2
+#define IFT_PFLOG 0xf5 /* Packet filter logging */
+#define IFT_PFSYNC 0xf6 /* Packet filter state syncing */
+#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */
+
+#endif /* !_NET_IF_TYPES_H_ */
--- /dev/null
+/* $NetBSD: pfkeyv2.h,v 1.30 2011/06/09 19:54:18 drochner Exp $ */
+/* $KAME: pfkeyv2.h,v 1.36 2003/07/25 09:33:37 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * This file has been derived rfc 2367,
+ * And added some flags of SADB_KEY_FLAGS_ as SADB_X_EXT_.
+ * sakane@ydc.co.jp
+ */
+
+#ifndef _NET_PFKEYV2_H_
+#define _NET_PFKEYV2_H_
+
+/*
+This file defines structures and symbols for the PF_KEY Version 2
+key management interface. It was written at the U.S. Naval Research
+Laboratory. This file is in the public domain. The authors ask that
+you leave this credit intact on any copies of this file.
+*/
+#ifndef __PFKEY_V2_H
+#define __PFKEY_V2_H 1
+
+#define PF_KEY_V2 2
+#define PFKEYV2_REVISION 199806L
+
+#define SADB_RESERVED 0
+#define SADB_GETSPI 1
+#define SADB_UPDATE 2
+#define SADB_ADD 3
+#define SADB_DELETE 4
+#define SADB_GET 5
+#define SADB_ACQUIRE 6
+#define SADB_REGISTER 7
+#define SADB_EXPIRE 8
+#define SADB_FLUSH 9
+#define SADB_DUMP 10
+#define SADB_X_PROMISC 11
+#define SADB_X_PCHANGE 12
+
+#define SADB_X_SPDUPDATE 13
+#define SADB_X_SPDADD 14
+#define SADB_X_SPDDELETE 15 /* by policy index */
+#define SADB_X_SPDGET 16
+#define SADB_X_SPDACQUIRE 17
+#define SADB_X_SPDDUMP 18
+#define SADB_X_SPDFLUSH 19
+#define SADB_X_SPDSETIDX 20
+#define SADB_X_SPDEXPIRE 21 /* not yet */
+#define SADB_X_SPDDELETE2 22 /* by policy id */
+#define SADB_X_NAT_T_NEW_MAPPING 23
+#if 0
+#define SADB_X_MIGRATE 24 /* KAME */
+#endif
+#define SADB_MAX 23
+
+struct sadb_msg {
+ uint8_t sadb_msg_version;
+ uint8_t sadb_msg_type;
+ uint8_t sadb_msg_errno;
+ uint8_t sadb_msg_satype;
+ uint16_t sadb_msg_len;
+ uint16_t sadb_msg_reserved;
+ uint32_t sadb_msg_seq;
+ uint32_t sadb_msg_pid;
+};
+
+struct sadb_ext {
+ uint16_t sadb_ext_len;
+ uint16_t sadb_ext_type;
+};
+
+struct sadb_sa {
+ uint16_t sadb_sa_len;
+ uint16_t sadb_sa_exttype;
+ uint32_t sadb_sa_spi;
+ uint8_t sadb_sa_replay;
+ uint8_t sadb_sa_state;
+ uint8_t sadb_sa_auth;
+ uint8_t sadb_sa_encrypt;
+ uint32_t sadb_sa_flags;
+};
+
+struct sadb_lifetime {
+ uint16_t sadb_lifetime_len;
+ uint16_t sadb_lifetime_exttype;
+ uint32_t sadb_lifetime_allocations;
+ uint64_t sadb_lifetime_bytes;
+ uint64_t sadb_lifetime_addtime;
+ uint64_t sadb_lifetime_usetime;
+};
+
+struct sadb_address {
+ uint16_t sadb_address_len;
+ uint16_t sadb_address_exttype;
+ uint8_t sadb_address_proto;
+ uint8_t sadb_address_prefixlen;
+ uint16_t sadb_address_reserved;
+};
+
+struct sadb_key {
+ uint16_t sadb_key_len;
+ uint16_t sadb_key_exttype;
+ uint16_t sadb_key_bits;
+ uint16_t sadb_key_reserved;
+};
+
+struct sadb_ident {
+ uint16_t sadb_ident_len;
+ uint16_t sadb_ident_exttype;
+ uint16_t sadb_ident_type;
+ uint16_t sadb_ident_reserved;
+ uint64_t sadb_ident_id;
+};
+
+struct sadb_sens {
+ uint16_t sadb_sens_len;
+ uint16_t sadb_sens_exttype;
+ uint32_t sadb_sens_dpd;
+ uint8_t sadb_sens_sens_level;
+ uint8_t sadb_sens_sens_len;
+ uint8_t sadb_sens_integ_level;
+ uint8_t sadb_sens_integ_len;
+ uint32_t sadb_sens_reserved;
+};
+
+struct sadb_prop {
+ uint16_t sadb_prop_len;
+ uint16_t sadb_prop_exttype;
+ uint8_t sadb_prop_replay;
+ uint8_t sadb_prop_reserved[3];
+};
+
+struct sadb_comb {
+ uint8_t sadb_comb_auth;
+ uint8_t sadb_comb_encrypt;
+ uint16_t sadb_comb_flags;
+ uint16_t sadb_comb_auth_minbits;
+ uint16_t sadb_comb_auth_maxbits;
+ uint16_t sadb_comb_encrypt_minbits;
+ uint16_t sadb_comb_encrypt_maxbits;
+ uint32_t sadb_comb_reserved;
+ uint32_t sadb_comb_soft_allocations;
+ uint32_t sadb_comb_hard_allocations;
+ uint64_t sadb_comb_soft_bytes;
+ uint64_t sadb_comb_hard_bytes;
+ uint64_t sadb_comb_soft_addtime;
+ uint64_t sadb_comb_hard_addtime;
+ uint64_t sadb_comb_soft_usetime;
+ uint64_t sadb_comb_hard_usetime;
+};
+
+struct sadb_supported {
+ uint16_t sadb_supported_len;
+ uint16_t sadb_supported_exttype;
+ uint32_t sadb_supported_reserved;
+};
+
+struct sadb_alg {
+ uint8_t sadb_alg_id;
+ uint8_t sadb_alg_ivlen;
+ uint16_t sadb_alg_minbits;
+ uint16_t sadb_alg_maxbits;
+ uint16_t sadb_alg_reserved;
+};
+
+struct sadb_spirange {
+ uint16_t sadb_spirange_len;
+ uint16_t sadb_spirange_exttype;
+ uint32_t sadb_spirange_min;
+ uint32_t sadb_spirange_max;
+ uint32_t sadb_spirange_reserved;
+};
+
+struct sadb_x_kmprivate {
+ uint16_t sadb_x_kmprivate_len;
+ uint16_t sadb_x_kmprivate_exttype;
+ uint32_t sadb_x_kmprivate_reserved;
+};
+
+/*
+ * XXX Additional SA Extension.
+ * mode: tunnel or transport
+ * reqid: to make SA unique nevertheless the address pair of SA are same.
+ * Mainly it's for VPN.
+ */
+struct sadb_x_sa2 {
+ uint16_t sadb_x_sa2_len;
+ uint16_t sadb_x_sa2_exttype;
+ uint8_t sadb_x_sa2_mode;
+ uint8_t sadb_x_sa2_reserved1;
+ uint16_t sadb_x_sa2_reserved2;
+ uint32_t sadb_x_sa2_sequence;
+ uint32_t sadb_x_sa2_reqid; /* topmost 16bits are always 0 */
+};
+
+/* XXX Policy Extension */
+/* sizeof(struct sadb_x_policy) == 16 */
+struct sadb_x_policy {
+ uint16_t sadb_x_policy_len;
+ uint16_t sadb_x_policy_exttype;
+ uint16_t sadb_x_policy_type; /* See policy type of ipsec.h */
+ uint8_t sadb_x_policy_dir; /* direction, see ipsec.h */
+ uint8_t sadb_x_policy_reserved;
+ uint32_t sadb_x_policy_id;
+ uint32_t sadb_x_policy_reserved2;
+};
+/*
+ * When policy_type == IPSEC, it is followed by some of
+ * the ipsec policy request.
+ * [total length of ipsec policy requests]
+ * = (sadb_x_policy_len * sizeof(uint64_t) - sizeof(struct sadb_x_policy))
+ */
+
+/* XXX IPsec Policy Request Extension */
+/*
+ * This structure is aligned 8 bytes.
+ */
+struct sadb_x_ipsecrequest {
+ uint16_t sadb_x_ipsecrequest_len; /* structure length in 64 bits. */
+ uint16_t sadb_x_ipsecrequest_proto; /* See ipsec.h */
+ uint8_t sadb_x_ipsecrequest_mode; /* See IPSEC_MODE_XX in ipsec.h. */
+ uint8_t sadb_x_ipsecrequest_level; /* See IPSEC_LEVEL_XX in ipsec.h */
+ uint16_t sadb_x_ipsecrequest_reqid; /* See ipsec.h */
+
+ /*
+ * followed by source IP address of SA, and immediately followed by
+ * destination IP address of SA. These encoded into two of sockaddr
+ * structure without any padding. Must set each sa_len exactly.
+ * Each of length of the sockaddr structure are not aligned to 64bits,
+ * but sum of x_request and addresses is aligned to 64bits.
+ */
+};
+
+/* NAT traversal type, see draft-ietf-ipsec-udp-encaps-06 */
+/* sizeof(struct sadb_x_nat_t_type) == 8 */
+struct sadb_x_nat_t_type {
+ uint16_t sadb_x_nat_t_type_len;
+ uint16_t sadb_x_nat_t_type_exttype;
+ uint8_t sadb_x_nat_t_type_type;
+ uint8_t sadb_x_nat_t_type_reserved[3];
+};
+
+/* NAT traversal source or destination port */
+/* sizeof(struct sadb_x_nat_t_port) == 8 */
+struct sadb_x_nat_t_port {
+ uint16_t sadb_x_nat_t_port_len;
+ uint16_t sadb_x_nat_t_port_exttype;
+ uint16_t sadb_x_nat_t_port_port;
+ uint16_t sadb_x_nat_t_port_reserved;
+};
+
+/* ESP fragmentation size */
+/* sizeof(struct sadb_x_nat_t_frag) == 8 */
+struct sadb_x_nat_t_frag {
+ uint16_t sadb_x_nat_t_frag_len;
+ uint16_t sadb_x_nat_t_frag_exttype;
+ uint16_t sadb_x_nat_t_frag_fraglen;
+ uint16_t sadb_x_nat_t_frag_reserved;
+};
+
+
+#define SADB_EXT_RESERVED 0
+#define SADB_EXT_SA 1
+#define SADB_EXT_LIFETIME_CURRENT 2
+#define SADB_EXT_LIFETIME_HARD 3
+#define SADB_EXT_LIFETIME_SOFT 4
+#define SADB_EXT_ADDRESS_SRC 5
+#define SADB_EXT_ADDRESS_DST 6
+#define SADB_EXT_ADDRESS_PROXY 7
+#define SADB_EXT_KEY_AUTH 8
+#define SADB_EXT_KEY_ENCRYPT 9
+#define SADB_EXT_IDENTITY_SRC 10
+#define SADB_EXT_IDENTITY_DST 11
+#define SADB_EXT_SENSITIVITY 12
+#define SADB_EXT_PROPOSAL 13
+#define SADB_EXT_SUPPORTED_AUTH 14
+#define SADB_EXT_SUPPORTED_ENCRYPT 15
+#define SADB_EXT_SPIRANGE 16
+#define SADB_X_EXT_KMPRIVATE 17
+#define SADB_X_EXT_POLICY 18
+#define SADB_X_EXT_SA2 19
+#define SADB_X_EXT_NAT_T_TYPE 20
+#define SADB_X_EXT_NAT_T_SPORT 21
+#define SADB_X_EXT_NAT_T_DPORT 22
+#define SADB_X_EXT_NAT_T_OA 23 /* compat */
+#define SADB_X_EXT_NAT_T_OAI 23
+#define SADB_X_EXT_NAT_T_OAR 24
+#define SADB_X_EXT_NAT_T_FRAG 25
+#if 0
+#define SADB_X_EXT_TAG 25 /* KAME */
+#define SADB_X_EXT_SA3 26 /* KAME */
+#define SADB_X_EXT_PACKET 27 /* KAME */
+#endif
+#define SADB_EXT_MAX 25
+
+#define SADB_SATYPE_UNSPEC 0
+#define SADB_SATYPE_AH 2
+#define SADB_SATYPE_ESP 3
+#define SADB_SATYPE_RSVP 5
+#define SADB_SATYPE_OSPFV2 6
+#define SADB_SATYPE_RIPV2 7
+#define SADB_SATYPE_MIP 8
+#define SADB_X_SATYPE_IPCOMP 9
+/*#define SADB_X_SATYPE_POLICY 10 obsolete, do not reuse */
+#define SADB_X_SATYPE_TCPSIGNATURE 11
+#define SADB_SATYPE_MAX 12
+
+#define SADB_SASTATE_LARVAL 0
+#define SADB_SASTATE_MATURE 1
+#define SADB_SASTATE_DYING 2
+#define SADB_SASTATE_DEAD 3
+#define SADB_SASTATE_MAX 3
+
+#define SADB_SAFLAGS_PFS 1
+
+/* RFC2367 numbers - meets RFC2407 */
+#define SADB_AALG_NONE 0
+#define SADB_AALG_MD5HMAC 2
+#define SADB_AALG_SHA1HMAC 3
+#define SADB_AALG_MAX 251
+/* private allocations - based on RFC2407/IANA assignment */
+#define SADB_X_AALG_SHA2_256 5
+#define SADB_X_AALG_SHA2_384 6
+#define SADB_X_AALG_SHA2_512 7
+#define SADB_X_AALG_RIPEMD160HMAC 8
+#define SADB_X_AALG_AES_XCBC_MAC 9 /* RFC3566 */
+#define SADB_X_AALG_AES128GMAC 11 /* RFC4543 + Errata1821 */
+#define SADB_X_AALG_AES192GMAC 12
+#define SADB_X_AALG_AES256GMAC 13
+/* private allocations should use 249-255 (RFC2407) */
+#define SADB_X_AALG_MD5 249 /* Keyed MD5 */
+#define SADB_X_AALG_SHA 250 /* Keyed SHA */
+#define SADB_X_AALG_NULL 251 /* null authentication */
+#define SADB_X_AALG_TCP_MD5 252 /* Keyed TCP-MD5 (RFC2385) */
+
+/* RFC2367 numbers - meets RFC2407 */
+#define SADB_EALG_NONE 0
+#define SADB_EALG_DESCBC 2
+#define SADB_EALG_3DESCBC 3
+#define SADB_EALG_NULL 11
+#define SADB_EALG_MAX 250
+/* private allocations - based on RFC2407/IANA assignment */
+#define SADB_X_EALG_CAST128CBC 6
+#define SADB_X_EALG_BLOWFISHCBC 7
+#define SADB_X_EALG_RIJNDAELCBC 12
+#define SADB_X_EALG_AES 12
+#define SADB_X_EALG_AESCTR 13 /* RFC3686 */
+#define SADB_X_EALG_AESGCM8 18 /* RFC4106 */
+#define SADB_X_EALG_AESGCM12 19
+#define SADB_X_EALG_AESGCM16 20
+#define SADB_X_EALG_CAMELLIACBC 22 /* RFC4312 */
+#define SADB_X_EALG_AESGMAC 23 /* RFC4543 + Errata1821 */
+/* private allocations should use 249-255 (RFC2407) */
+#define SADB_X_EALG_SKIPJACK 250
+
+/* private allocations - based on RFC2407/IANA assignment */
+#define SADB_X_CALG_NONE 0
+#define SADB_X_CALG_OUI 1
+#define SADB_X_CALG_DEFLATE 2
+#define SADB_X_CALG_LZS 3
+#define SADB_X_CALG_MAX 4
+
+#define SADB_IDENTTYPE_RESERVED 0
+#define SADB_IDENTTYPE_PREFIX 1
+#define SADB_IDENTTYPE_FQDN 2
+#define SADB_IDENTTYPE_USERFQDN 3
+#define SADB_X_IDENTTYPE_ADDR 4
+#define SADB_IDENTTYPE_MAX 4
+
+/* `flags' in sadb_sa structure holds followings */
+#define SADB_X_EXT_NONE 0x0000 /* i.e. new format. */
+#define SADB_X_EXT_OLD 0x0001 /* old format. */
+
+#define SADB_X_EXT_IV4B 0x0010 /* IV length of 4 bytes in use */
+#define SADB_X_EXT_DERIV 0x0020 /* DES derived */
+#define SADB_X_EXT_CYCSEQ 0x0040 /* allowing to cyclic sequence. */
+
+ /* three of followings are exclusive flags each them */
+#define SADB_X_EXT_PSEQ 0x0000 /* sequencial padding for ESP */
+#define SADB_X_EXT_PRAND 0x0100 /* random padding for ESP */
+#define SADB_X_EXT_PZERO 0x0200 /* zero padding for ESP */
+#define SADB_X_EXT_PMASK 0x0300 /* mask for padding flag */
+
+#if 1
+#define SADB_X_EXT_RAWCPI 0x0080 /* use well known CPI (IPComp) */
+#endif
+
+#define SADB_KEY_FLAGS_MAX 0x0fff
+
+/* SPI size for PF_KEYv2 */
+#define PFKEY_SPI_SIZE sizeof(uint32_t)
+
+/* Identifier for menber of lifetime structure */
+#define SADB_X_LIFETIME_ALLOCATIONS 0
+#define SADB_X_LIFETIME_BYTES 1
+#define SADB_X_LIFETIME_ADDTIME 2
+#define SADB_X_LIFETIME_USETIME 3
+
+/* The rate for SOFT lifetime against HARD one. */
+#define PFKEY_SOFT_LIFETIME_RATE 80
+
+/* Utilities */
+#define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1)))
+#define PFKEY_EXTLEN(msg) \
+ PFKEY_UNUNIT64(((const struct sadb_ext *)(const void *)(msg))->sadb_ext_len)
+#define PFKEY_ADDR_PREFIX(ext) \
+ (((const struct sadb_address *)(const void *)(ext))->sadb_address_prefixlen)
+#define PFKEY_ADDR_PROTO(ext) \
+ (((const struct sadb_address *)(const void *)(ext))->sadb_address_proto)
+#define PFKEY_ADDR_SADDR(ext) \
+ ((struct sockaddr *)(void *)((char *)(void *)(ext) + \
+ sizeof(struct sadb_address)))
+
+/* in 64bits */
+#define PFKEY_UNUNIT64(a) ((a) << 3)
+#define PFKEY_UNIT64(a) ((a) >> 3)
+
+#endif /* __PFKEY_V2_H */
+
+#endif /* !_NET_PFKEYV2_H_ */
--- /dev/null
+# $NetBSD: Makefile,v 1.5 2005/12/11 12:24:54 christos Exp $
+
+INCSDIR= /usr/include/net80211
+
+INCS= _ieee80211.h ieee80211.h \
+ ieee80211_crypto.h ieee80211_ioctl.h ieee80211_netbsd.h \
+ \
+
+
+.include <bsd.kinc.mk>
--- /dev/null
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: src/sys/net80211/_ieee80211.h,v 1.3 2005/08/10 17:42:13 sam Exp $
+ */
+#ifndef _NET80211__IEEE80211_H_
+#define _NET80211__IEEE80211_H_
+
+enum ieee80211_phytype {
+ IEEE80211_T_DS, /* direct sequence spread spectrum */
+ IEEE80211_T_FH, /* frequency hopping */
+ IEEE80211_T_OFDM, /* frequency division multiplexing */
+ IEEE80211_T_TURBO /* high rate OFDM, aka turbo mode */
+};
+#define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */
+
+/* XXX not really a mode; there are really multiple PHY's */
+enum ieee80211_phymode {
+ IEEE80211_MODE_AUTO = 0, /* autoselect */
+ IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */
+ IEEE80211_MODE_11B = 2, /* 2GHz, CCK */
+ IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */
+ IEEE80211_MODE_FH = 4, /* 2GHz, GFSK */
+ IEEE80211_MODE_TURBO_A = 5, /* 5GHz, OFDM, 2x clock */
+ IEEE80211_MODE_TURBO_G = 6 /* 2GHz, OFDM, 2x clock */
+};
+#define IEEE80211_MODE_MAX ((int)IEEE80211_MODE_TURBO_G + 1)
+
+enum ieee80211_opmode {
+ IEEE80211_M_STA = 1, /* infrastructure station */
+ IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
+ IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
+ IEEE80211_M_HOSTAP = 6, /* Software Access Point */
+ IEEE80211_M_MONITOR = 8 /* Monitor mode */
+};
+
+/*
+ * 802.11g protection mode.
+ */
+enum ieee80211_protmode {
+ IEEE80211_PROT_NONE = 0, /* no protection */
+ IEEE80211_PROT_CTSONLY = 1, /* CTS to self */
+ IEEE80211_PROT_RTSCTS = 2 /* RTS-CTS */
+};
+
+/*
+ * Authentication mode.
+ */
+enum ieee80211_authmode {
+ IEEE80211_AUTH_NONE = 0,
+ IEEE80211_AUTH_OPEN = 1, /* open */
+ IEEE80211_AUTH_SHARED = 2, /* shared-key */
+ IEEE80211_AUTH_8021X = 3, /* 802.1x */
+ IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
+ /* NB: these are used only for ioctls */
+ IEEE80211_AUTH_WPA = 5 /* WPA/RSN w/ 802.1x/PSK */
+};
+
+/*
+ * Roaming mode is effectively who controls the operation
+ * of the 802.11 state machine when operating as a station.
+ * State transitions are controlled either by the driver
+ * (typically when management frames are processed by the
+ * hardware/firmware), the host (auto/normal operation of
+ * the 802.11 layer), or explicitly through ioctl requests
+ * when applications like wpa_supplicant want control.
+ */
+enum ieee80211_roamingmode {
+ IEEE80211_ROAMING_DEVICE= 0, /* driver/hardware control */
+ IEEE80211_ROAMING_AUTO = 1, /* 802.11 layer control */
+ IEEE80211_ROAMING_MANUAL= 2 /* application control */
+};
+
+/*
+ * Channels are specified by frequency and attributes.
+ */
+struct ieee80211_channel {
+ u_int16_t ic_freq; /* setting in MHz */
+ u_int16_t ic_flags; /* see below */
+};
+
+extern const struct ieee80211_channel ieee80211_channel_anyc;
+
+#define IEEE80211_CHAN_MAX 255
+#define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */
+#define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */
+#define IEEE80211_CHAN_ANYC (__UNCONST(&ieee80211_channel_anyc))
+
+/* bits 0-3 are for private use by drivers */
+/* channel attributes */
+#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
+#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
+#define IEEE80211_CHAN_GSM 0x1000 /* 900 MHz spectrum channel */
+#define IEEE80211_CHAN_HALF 0x4000 /* Half rate channel */
+#define IEEE80211_CHAN_QUARTER 0x8000 /* Quarter rate channel */
+
+/*
+ * Useful combinations of channel characteristics.
+ */
+#define IEEE80211_CHAN_FHSS \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_PUREG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_T \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_108G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+
+#define IEEE80211_CHAN_ALL \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
+ IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_ALLTURBO \
+ (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO)
+
+#define IEEE80211_IS_CHAN_ANYC(_c) \
+ ((_c) == IEEE80211_CHAN_ANYC)
+
+#define _IEEE80211_IS_CHAN(_c, _ch) \
+ (((_c)->ic_flags & IEEE80211_CHAN_ ## _ch) == IEEE80211_CHAN_ ## _ch)
+
+#define IEEE80211_IS_CHAN_FHSS(_c) _IEEE80211_IS_CHAN(_c, FHSS)
+#define IEEE80211_IS_CHAN_A(_c) _IEEE80211_IS_CHAN(_c, A)
+#define IEEE80211_IS_CHAN_B(_c) _IEEE80211_IS_CHAN(_c, B)
+#define IEEE80211_IS_CHAN_PUREG(_c) _IEEE80211_IS_CHAN(_c, PUREG)
+#define IEEE80211_IS_CHAN_G(_c) _IEEE80211_IS_CHAN(_c, G)
+#define IEEE80211_IS_CHAN_ANYG(_c) _IEEE80211_IS_CHAN(_c, ANYG)
+#define IEEE80211_IS_CHAN_T(_c) _IEEE80211_IS_CHAN(_c, T)
+#define IEEE80211_IS_CHAN_108G(_c) _IEEE80211_IS_CHAN(_c, 108G)
+
+#define IEEE80211_IS_CHAN_2GHZ(_c) _IEEE80211_IS_CHAN(_c, 2GHZ)
+#define IEEE80211_IS_CHAN_5GHZ(_c) _IEEE80211_IS_CHAN(_c, 5GHZ)
+#define IEEE80211_IS_CHAN_OFDM(_c) _IEEE80211_IS_CHAN(_c, OFDM)
+#define IEEE80211_IS_CHAN_CCK(_c) _IEEE80211_IS_CHAN(_c, CCK)
+#define IEEE80211_IS_CHAN_GFSK(_c) _IEEE80211_IS_CHAN(_c, GFSK)
+#define IEEE80211_IS_CHAN_HALF(_c) _IEEE80211_IS_CHAN(_c, HALF)
+#define IEEE80211_IS_CHAN_QUARTER(_c) _IEEE80211_IS_CHAN(_c, QUARTER)
+#define IEEE80211_IS_CHAN_FULL(_c) \
+ (!IEEE80211_IS_CHAN_ANYC(_c) && \
+ ((_c)->ic_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF)) == 0)
+
+#define IEEE80211_IS_CHAN_GSM(_c) _IEEE80211_IS_CHAN(_c, GSM)
+#define IEEE80211_IS_CHAN_PASSIVE(_c) _IEEE80211_IS_CHAN(_c, PASSIVE)
+
+
+/* ni_chan encoding for FH phy */
+#define IEEE80211_FH_CHANMOD 80
+#define IEEE80211_FH_CHAN(set,pat) (((set)-1)*IEEE80211_FH_CHANMOD+(pat))
+#define IEEE80211_FH_CHANSET(chan) ((chan)/IEEE80211_FH_CHANMOD+1)
+#define IEEE80211_FH_CHANPAT(chan) ((chan)%IEEE80211_FH_CHANMOD)
+
+/*
+ * 802.11 rate set.
+ */
+#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
+#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
+
+struct ieee80211_rateset {
+ u_int8_t rs_nrates;
+ u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE];
+};
+
+extern const struct ieee80211_rateset ieee80211_std_rateset_11a;
+extern const struct ieee80211_rateset ieee80211_std_rateset_11b;
+extern const struct ieee80211_rateset ieee80211_std_rateset_11g;
+
+#endif /* !_NET80211__IEEE80211_H_ */
--- /dev/null
+/* $NetBSD: ieee80211.h,v 1.26 2013/03/30 14:14:31 christos Exp $ */
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $
+ */
+#ifndef _NET80211_IEEE80211_H_
+#define _NET80211_IEEE80211_H_
+
+/*
+ * 802.11 protocol definitions.
+ */
+
+#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
+/* is 802.11 address multicast/broadcast? */
+#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
+
+/* IEEE 802.11 PLCP header */
+struct ieee80211_plcp_hdr {
+ u_int16_t i_sfd;
+ u_int8_t i_signal;
+ u_int8_t i_service;
+ u_int16_t i_length;
+ u_int16_t i_crc;
+} __packed;
+
+#define IEEE80211_PLCP_SFD 0xF3A0
+#define IEEE80211_PLCP_SERVICE 0x00
+
+/*
+ * generic definitions for IEEE 802.11 frames
+ */
+struct ieee80211_frame {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} __packed;
+
+struct ieee80211_qosframe {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_qos[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} __packed;
+
+struct ieee80211_qoscntl {
+ u_int8_t i_qos[2];
+};
+
+struct ieee80211_frame_addr4 {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_addr4[IEEE80211_ADDR_LEN];
+} __packed;
+
+
+struct ieee80211_qosframe_addr4 {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_addr4[IEEE80211_ADDR_LEN];
+ u_int8_t i_qos[2];
+} __packed;
+
+#define IEEE80211_FC0_VERSION_MASK 0x03
+#define IEEE80211_FC0_VERSION_SHIFT 0
+#define IEEE80211_FC0_VERSION_0 0x00
+#define IEEE80211_FC0_TYPE_MASK 0x0c
+#define IEEE80211_FC0_TYPE_SHIFT 2
+#define IEEE80211_FC0_TYPE_MGT 0x00
+#define IEEE80211_FC0_TYPE_CTL 0x04
+#define IEEE80211_FC0_TYPE_DATA 0x08
+
+#define IEEE80211_FC0_SUBTYPE_MASK 0xf0
+#define IEEE80211_FC0_SUBTYPE_SHIFT 4
+/* for TYPE_MGT */
+#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
+#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
+#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
+#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
+#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
+#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
+#define IEEE80211_FC0_SUBTYPE_BEACON 0x80
+#define IEEE80211_FC0_SUBTYPE_ATIM 0x90
+#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
+#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
+#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
+/* for TYPE_CTL */
+#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
+#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
+#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
+#define IEEE80211_FC0_SUBTYPE_ACK 0xd0
+#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
+#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
+/* for TYPE_DATA (bit combination) */
+#define IEEE80211_FC0_SUBTYPE_DATA 0x00
+#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
+#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
+#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
+#define IEEE80211_FC0_SUBTYPE_NODATA 0x40
+#define IEEE80211_FC0_SUBTYPE_CFACK 0x50
+#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
+#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
+#define IEEE80211_FC0_SUBTYPE_QOS 0x80
+#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
+
+/*
+ * DS bit usage
+ *
+ * TA = transmitter address
+ * RA = receiver address
+ * DA = destination address
+ * SA = source address
+ *
+ * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
+ * -----------------------------------------------------------------
+ * 0 0 DA SA BSSID - IBSS/DLS
+ * 0 1 DA BSSID SA - AP -> STA
+ * 1 0 BSSID SA DA - AP <- STA
+ * 1 1 RA TA DA SA unspecified (WDS)
+ */
+#define IEEE80211_FC1_DIR_MASK 0x03
+#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
+#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
+#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
+#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
+
+#define IEEE80211_FC1_MORE_FRAG 0x04
+#define IEEE80211_FC1_RETRY 0x08
+#define IEEE80211_FC1_PWR_MGT 0x10
+#define IEEE80211_FC1_MORE_DATA 0x20
+#define IEEE80211_FC1_PROTECTED 0x40
+#define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */
+#define IEEE80211_FC1_ORDER 0x80
+
+#define IEEE80211_SEQ_FRAG_MASK 0x000f
+#define IEEE80211_SEQ_FRAG_SHIFT 0
+#define IEEE80211_SEQ_SEQ_MASK 0xfff0
+#define IEEE80211_SEQ_SEQ_SHIFT 4
+
+#define IEEE80211_NWID_LEN 32
+
+/*
+ * QoS Control field (see 7.1.3.5).
+ */
+/* bit 8 is reserved */
+#define IEEE80211_QOS_TXOP 0xff00
+#define IEEE80211_QOS_AMSDU 0x0080 /* 11n */
+#define IEEE80211_QOS_ACKPOLICY_NORMAL 0x0000
+#define IEEE80211_QOS_ACKPOLICY_NOACK 0x0020
+#define IEEE80211_QOS_ACKPOLICY_NOEXPLACK 0x0040
+#define IEEE80211_QOS_ACKPOLICY 0x0060
+#define IEEE80211_QOS_ACKPOLICY_S 5
+#define IEEE80211_QOS_ACKPOLICY_MASK 0x0060
+#define IEEE80211_QOS_ACKPOLICY_BA 0x0060
+#define IEEE80211_QOS_ESOP 0x0010
+#define IEEE80211_QOS_ESOP_S 4
+#define IEEE80211_QOS_TID 0x000f
+
+/*
+ * WME/802.11e information element.
+ */
+struct ieee80211_wme_info {
+ u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t wme_len; /* length in bytes */
+ u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */
+ u_int8_t wme_type; /* OUI type */
+ u_int8_t wme_subtype; /* OUI subtype */
+ u_int8_t wme_version; /* spec revision */
+ u_int8_t wme_info; /* QoS info */
+} __packed;
+
+/*
+ * WME/802.11e Tspec Element
+ */
+struct ieee80211_wme_tspec {
+ u_int8_t ts_id;
+ u_int8_t ts_len;
+ u_int8_t ts_oui[3];
+ u_int8_t ts_oui_type;
+ u_int8_t ts_oui_subtype;
+ u_int8_t ts_version;
+ u_int8_t ts_tsinfo[3];
+ u_int8_t ts_nom_msdu[2];
+ u_int8_t ts_max_msdu[2];
+ u_int8_t ts_min_svc[4];
+ u_int8_t ts_max_svc[4];
+ u_int8_t ts_inactv_intv[4];
+ u_int8_t ts_susp_intv[4];
+ u_int8_t ts_start_svc[4];
+ u_int8_t ts_min_rate[4];
+ u_int8_t ts_mean_rate[4];
+ u_int8_t ts_max_burst[4];
+ u_int8_t ts_min_phy[4];
+ u_int8_t ts_peak_rate[4];
+ u_int8_t ts_delay[4];
+ u_int8_t ts_surplus[2];
+ u_int8_t ts_medium_time[2];
+} __packed;
+
+/*
+ * WME AC parameter field
+ */
+struct ieee80211_wme_acparams {
+ u_int8_t acp_aci_aifsn;
+ u_int8_t acp_logcwminmax;
+ u_int16_t acp_txop;
+} __packed;
+
+/* WME stream classes */
+enum ieee80211_wme_ac {
+ WME_AC_BE = 0, /* best effort */
+ WME_AC_BK = 1, /* background */
+ WME_AC_VI = 2, /* video */
+ WME_AC_VO = 3, /* voice */
+};
+#define WME_NUM_AC 4 /* 4 AC categories */
+
+#define WME_PARAM_ACI 0x60 /* Mask for ACI field */
+#define WME_PARAM_ACI_S 5 /* Shift for ACI field */
+#define WME_PARAM_ACM 0x10 /* Mask for ACM bit */
+#define WME_PARAM_ACM_S 4 /* Shift for ACM bit */
+#define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */
+#define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */
+#define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */
+#define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */
+#define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */
+#define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
+
+#define WME_AC_TO_TID(_ac) ( \
+ ((_ac) == WME_AC_VO) ? 6 : \
+ ((_ac) == WME_AC_VI) ? 5 : \
+ ((_ac) == WME_AC_BK) ? 1 : \
+ 0)
+
+#define TID_TO_WME_AC(_tid) ( \
+ ((_tid) < 1) ? WME_AC_BE : \
+ ((_tid) < 3) ? WME_AC_BK : \
+ ((_tid) < 6) ? WME_AC_VI : \
+ WME_AC_VO)
+
+/*
+ * WME Parameter Element
+ */
+struct ieee80211_wme_param {
+ u_int8_t param_id;
+ u_int8_t param_len;
+ u_int8_t param_oui[3];
+ u_int8_t param_oui_type;
+ u_int8_t param_oui_sybtype;
+ u_int8_t param_version;
+ u_int8_t param_qosInfo;
+#define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */
+ u_int8_t param_reserved;
+ struct ieee80211_wme_acparams params_acParams[WME_NUM_AC];
+} __packed;
+
+/*
+ * Management Notification Frame
+ */
+struct ieee80211_mnf {
+ u_int8_t mnf_category;
+ u_int8_t mnf_action;
+ u_int8_t mnf_dialog;
+ u_int8_t mnf_status;
+} __packed;
+#define MNF_SETUP_REQ 0
+#define MNF_SETUP_RESP 1
+#define MNF_TEARDOWN 2
+
+/*
+ * Control frames.
+ */
+struct ieee80211_frame_min {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_rts {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ u_int8_t i_ta[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_cts {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_ack {
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_pspoll {
+ u_int8_t i_fc[2];
+ u_int8_t i_aid[2];
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t i_ta[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2]; /* should be zero */
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+static __inline int
+ieee80211_has_seq(const struct ieee80211_frame *wh)
+{
+ return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
+ IEEE80211_FC0_TYPE_CTL;
+}
+
+static __inline int
+ieee80211_has_addr4(const struct ieee80211_frame *wh)
+{
+ return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
+ IEEE80211_FC1_DIR_DSTODS;
+}
+
+static __inline int
+ieee80211_has_qos(const struct ieee80211_frame *wh)
+{
+ return (wh->i_fc[0] &
+ (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) ==
+ (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS);
+}
+
+static __inline int
+ieee80211_has_htc(const struct ieee80211_frame *wh)
+{
+ return (wh->i_fc[1] & IEEE80211_FC1_ORDER) &&
+ (ieee80211_has_qos(wh) ||
+ (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
+ IEEE80211_FC0_TYPE_MGT);
+}
+
+static __inline u_int16_t
+ieee80211_get_qos(const struct ieee80211_frame *wh)
+{
+ const u_int8_t *frm;
+
+ if (ieee80211_has_addr4(wh))
+ frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos;
+ else
+ frm = ((const struct ieee80211_qosframe *)wh)->i_qos;
+
+ return le16toh(*(const u_int16_t *)frm);
+}
+
+/*
+ * BEACON management packets
+ *
+ * octet timestamp[8]
+ * octet beacon interval[2]
+ * octet capability information[2]
+ * information element
+ * octet elemid
+ * octet length
+ * octet information[length]
+ */
+
+typedef u_int8_t *ieee80211_mgt_beacon_t;
+
+#define IEEE80211_BEACON_INTERVAL(beacon) \
+ ((beacon)[8] | ((beacon)[9] << 8))
+#define IEEE80211_BEACON_CAPABILITY(beacon) \
+ ((beacon)[10] | ((beacon)[11] << 8))
+
+#define IEEE80211_CAPINFO_ESS 0x0001
+#define IEEE80211_CAPINFO_IBSS 0x0002
+#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
+#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
+#define IEEE80211_CAPINFO_PRIVACY 0x0010
+#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
+#define IEEE80211_CAPINFO_PBCC 0x0040
+#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
+/* bits 8-9 are reserved */
+#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
+#define IEEE80211_CAPINFO_RSN 0x0800
+/* bit 12 is reserved */
+#define IEEE80211_CAPINFO_DSSSOFDM 0x2000
+/* bits 14-15 are reserved */
+
+/*
+ * 802.11i/WPA information element (maximally sized).
+ */
+struct ieee80211_ie_wpa {
+ u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t wpa_len; /* length in bytes */
+ u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
+ u_int8_t wpa_type; /* OUI type */
+ u_int16_t wpa_version; /* spec revision */
+ u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */
+ u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */
+ u_int32_t wpa_uciphers[8];/* ciphers */
+ u_int16_t wpa_authselcnt; /* authentication selector cnt*/
+ u_int32_t wpa_authsels[8];/* selectors */
+ u_int16_t wpa_caps; /* 802.11i capabilities */
+ u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */
+ u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */
+} __packed;
+
+/*
+ * Management information element payloads.
+ */
+
+enum {
+ IEEE80211_ELEMID_SSID = 0,
+ IEEE80211_ELEMID_RATES = 1,
+ IEEE80211_ELEMID_FHPARMS = 2,
+ IEEE80211_ELEMID_DSPARMS = 3,
+ IEEE80211_ELEMID_CFPARMS = 4,
+ IEEE80211_ELEMID_TIM = 5,
+ IEEE80211_ELEMID_IBSSPARMS = 6,
+ IEEE80211_ELEMID_COUNTRY = 7,
+ IEEE80211_ELEMID_EDCAPARMS = 12,
+ IEEE80211_ELEMID_CHALLENGE = 16,
+ /* 17-31 reserved for challenge text extension */
+ IEEE80211_ELEMID_PWRCNSTR = 32,
+ IEEE80211_ELEMID_PWRCAP = 33,
+ IEEE80211_ELEMID_TPCREQ = 34,
+ IEEE80211_ELEMID_TPCREP = 35,
+ IEEE80211_ELEMID_SUPPCHAN = 36,
+ IEEE80211_ELEMID_CHANSWITCHANN = 37,
+ IEEE80211_ELEMID_MEASREQ = 38,
+ IEEE80211_ELEMID_MEASREP = 39,
+ IEEE80211_ELEMID_QUIET = 40,
+ IEEE80211_ELEMID_IBSSDFS = 41,
+ IEEE80211_ELEMID_ERP = 42,
+ IEEE80211_ELEMID_HTCAP = 45, /* 11n */
+ IEEE80211_ELEMID_QOS_CAP = 46,
+ IEEE80211_ELEMID_RSN = 48,
+ IEEE80211_ELEMID_XRATES = 50,
+ IEEE80211_ELEMID_TIE = 56, /* 11r */
+ IEEE80211_ELEMID_HTINFO = 61, /* 11n */
+ IEEE80211_ELEMID_MMIE = 76, /* 11w */
+ IEEE80211_ELEMID_TPC = 150,
+ IEEE80211_ELEMID_CCKM = 156,
+ IEEE80211_ELEMID_VENDOR = 221 /* vendor private */
+};
+
+struct ieee80211_tim_ie {
+ u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */
+ u_int8_t tim_len;
+ u_int8_t tim_count; /* DTIM count */
+ u_int8_t tim_period; /* DTIM period */
+ u_int8_t tim_bitctl; /* bitmap control */
+ u_int8_t tim_bitmap[1]; /* variable-length bitmap */
+} __packed;
+
+struct ieee80211_band {
+ u_int8_t schan; /* starting channel */
+ u_int8_t nchan; /* number channels */
+ u_int8_t maxtxpwr; /* tx power cap */
+} __packed;
+
+struct ieee80211_country_ie {
+ u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */
+ u_int8_t len;
+ u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
+ struct ieee80211_band band[4]; /* up to 4 sub bands */
+} __packed;
+
+#define IEEE80211_CHALLENGE_LEN 128
+
+#define IEEE80211_RATE_BASIC 0x80
+#define IEEE80211_RATE_VAL 0x7f
+
+/* EPR information element flags */
+#define IEEE80211_ERP_NON_ERP_PRESENT 0x01
+#define IEEE80211_ERP_USE_PROTECTION 0x02
+#define IEEE80211_ERP_LONG_PREAMBLE 0x04
+
+/* Atheros private advanced capabilities info */
+#define ATHEROS_CAP_TURBO_PRIME 0x01
+#define ATHEROS_CAP_COMPRESSION 0x02
+#define ATHEROS_CAP_FAST_FRAME 0x04
+/* bits 3-6 reserved */
+#define ATHEROS_CAP_BOOST 0x80
+
+#define ATH_OUI 0x7f0300 /* Atheros OUI */
+#define ATH_OUI_TYPE 0x01
+#define ATH_OUI_VERSION 0x01
+
+#define WPA_OUI 0xf25000
+#define WPA_OUI_TYPE 0x01
+#define WPA_VERSION 1 /* current supported version */
+
+#define WPA_CSE_NULL 0x00
+#define WPA_CSE_WEP40 0x01
+#define WPA_CSE_TKIP 0x02
+#define WPA_CSE_CCMP 0x04
+#define WPA_CSE_WEP104 0x05
+
+#define WPA_ASE_NONE 0x00
+#define WPA_ASE_8021X_UNSPEC 0x01
+#define WPA_ASE_8021X_PSK 0x02
+
+#define RSN_OUI 0xac0f00
+#define RSN_VERSION 1 /* current supported version */
+
+#define RSN_CSE_NULL 0x00
+#define RSN_CSE_WEP40 0x01
+#define RSN_CSE_TKIP 0x02
+#define RSN_CSE_WRAP 0x03
+#define RSN_CSE_CCMP 0x04
+#define RSN_CSE_WEP104 0x05
+
+#define RSN_ASE_NONE 0x00
+#define RSN_ASE_8021X_UNSPEC 0x01
+#define RSN_ASE_8021X_PSK 0x02
+
+#define RSN_CAP_PREAUTH 0x01
+
+#define WME_OUI 0xf25000
+#define WME_OUI_TYPE 0x02
+#define WME_INFO_OUI_SUBTYPE 0x00
+#define WME_PARAM_OUI_SUBTYPE 0x01
+#define WME_VERSION 1
+
+/*
+ * AUTH management packets
+ *
+ * octet algo[2]
+ * octet seq[2]
+ * octet status[2]
+ * octet chal.id
+ * octet chal.length
+ * octet chal.text[253]
+ */
+
+typedef u_int8_t *ieee80211_mgt_auth_t;
+
+#define IEEE80211_AUTH_ALGORITHM(auth) \
+ ((auth)[0] | ((auth)[1] << 8))
+#define IEEE80211_AUTH_TRANSACTION(auth) \
+ ((auth)[2] | ((auth)[3] << 8))
+#define IEEE80211_AUTH_STATUS(auth) \
+ ((auth)[4] | ((auth)[5] << 8))
+
+#define IEEE80211_AUTH_ALG_OPEN 0x0000
+#define IEEE80211_AUTH_ALG_SHARED 0x0001
+#define IEEE80211_AUTH_ALG_LEAP 0x0080
+
+enum {
+ IEEE80211_AUTH_OPEN_REQUEST = 1,
+ IEEE80211_AUTH_OPEN_RESPONSE = 2
+};
+
+enum {
+ IEEE80211_AUTH_SHARED_REQUEST = 1,
+ IEEE80211_AUTH_SHARED_CHALLENGE = 2,
+ IEEE80211_AUTH_SHARED_RESPONSE = 3,
+ IEEE80211_AUTH_SHARED_PASS = 4
+};
+
+/*
+ * Reason codes
+ *
+ * Unlisted codes are reserved
+ */
+
+enum {
+ IEEE80211_REASON_UNSPECIFIED = 1,
+ IEEE80211_REASON_AUTH_EXPIRE = 2,
+ IEEE80211_REASON_AUTH_LEAVE = 3,
+ IEEE80211_REASON_ASSOC_EXPIRE = 4,
+ IEEE80211_REASON_ASSOC_TOOMANY = 5,
+ IEEE80211_REASON_NOT_AUTHED = 6,
+ IEEE80211_REASON_NOT_ASSOCED = 7,
+ IEEE80211_REASON_ASSOC_LEAVE = 8,
+ IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
+
+ IEEE80211_REASON_RSN_REQUIRED = 11,
+ IEEE80211_REASON_RSN_INCONSISTENT = 12,
+ IEEE80211_REASON_IE_INVALID = 13,
+ IEEE80211_REASON_MIC_FAILURE = 14,
+
+ IEEE80211_STATUS_SUCCESS = 0,
+ IEEE80211_STATUS_UNSPECIFIED = 1,
+ IEEE80211_STATUS_CAPINFO = 10,
+ IEEE80211_STATUS_NOT_ASSOCED = 11,
+ IEEE80211_STATUS_OTHER = 12,
+ IEEE80211_STATUS_ALG = 13,
+ IEEE80211_STATUS_SEQUENCE = 14,
+ IEEE80211_STATUS_CHALLENGE = 15,
+ IEEE80211_STATUS_TIMEOUT = 16,
+ IEEE80211_STATUS_TOOMANY = 17,
+ IEEE80211_STATUS_BASIC_RATE = 18,
+ IEEE80211_STATUS_SP_REQUIRED = 19,
+ IEEE80211_STATUS_PBCC_REQUIRED = 20,
+ IEEE80211_STATUS_CA_REQUIRED = 21,
+ IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
+ IEEE80211_STATUS_RATES = 23,
+ IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
+ IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26
+};
+
+#define IEEE80211_WEP_KEYLEN 5 /* 40bit */
+#define IEEE80211_WEP_IVLEN 3 /* 24bit */
+#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
+#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
+#define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \
+ IEEE80211_WEP_KIDLEN + \
+ IEEE80211_WEP_CRCLEN)
+#define IEEE80211_WEP_NKID 4 /* number of key ids */
+
+/*
+ * 802.11i defines an extended IV for use with non-WEP ciphers.
+ * When the EXTIV bit is set in the key id byte an additional
+ * 4 bytes immediately follow the IV for TKIP. For CCMP the
+ * EXTIV bit is likewise set but the 8 bytes represent the
+ * CCMP header rather than IV+extended-IV.
+ */
+#define IEEE80211_WEP_EXTIV 0x20
+#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
+#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
+
+#define IEEE80211_CRC_LEN 4
+
+/*
+ * Maximum acceptable MTU is:
+ * IEEE80211_MAX_LEN - WEP overhead - CRC -
+ * QoS overhead - RSN/WPA overhead
+ * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
+ * mtu is Ethernet-compatible; it's set by ether_ifattach.
+ */
+#define IEEE80211_MTU_MAX 2290
+#define IEEE80211_MTU_MIN 32
+
+#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
+ (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
+#define IEEE80211_ACK_LEN \
+ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
+#define IEEE80211_MIN_LEN \
+ (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
+
+/*
+ * The 802.11 spec says at most 2007 stations may be
+ * associated at once. For most AP's this is way more
+ * than is feasible so we use a default of 128. This
+ * number may be overridden by the driver and/or by
+ * user configuration.
+ */
+#define IEEE80211_AID_MAX 2007
+#define IEEE80211_AID_DEF 128
+
+#define IEEE80211_AID(b) ((b) &~ 0xc000)
+
+/*
+ * RTS frame length parameters. The default is specified in
+ * the 802.11 spec as 512; we treat it as implementation-dependent
+ * so it's defined in ieee80211_var.h. The max may be wrong
+ * for jumbo frames.
+ */
+#define IEEE80211_RTS_MIN 1
+#define IEEE80211_RTS_MAX 2346
+
+/*
+ * TX fragmentation parameters. As above for RTS, we treat
+ * default as implementation-dependent so define it elsewhere.
+ */
+#define IEEE80211_FRAG_MIN 256
+#define IEEE80211_FRAG_MAX 2346
+
+/*
+ * 802.11 frame duration definitions.
+ */
+
+struct ieee80211_duration {
+ uint16_t d_rts_dur;
+ uint16_t d_data_dur;
+ uint16_t d_plcp_len;
+ uint8_t d_residue; /* unused octets in time slot */
+};
+
+/* One Time Unit (TU) is 1Kus = 1024 microseconds. */
+#define IEEE80211_DUR_TU 1024
+
+/* IEEE 802.11b durations for DSSS PHY in microseconds */
+#define IEEE80211_DUR_DS_LONG_PREAMBLE 144
+#define IEEE80211_DUR_DS_SHORT_PREAMBLE 72
+
+#define IEEE80211_DUR_DS_SLOW_PLCPHDR 48
+#define IEEE80211_DUR_DS_FAST_PLCPHDR 24
+#define IEEE80211_DUR_DS_SLOW_ACK 112
+#define IEEE80211_DUR_DS_FAST_ACK 56
+#define IEEE80211_DUR_DS_SLOW_CTS 112
+#define IEEE80211_DUR_DS_FAST_CTS 56
+
+#define IEEE80211_DUR_DS_SLOT 20
+#define IEEE80211_DUR_DS_SIFS 10
+#define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
+#define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \
+ 2 * IEEE80211_DUR_DS_SLOT)
+#define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \
+ IEEE80211_DUR_DS_SLOW_ACK + \
+ IEEE80211_DUR_DS_LONG_PREAMBLE + \
+ IEEE80211_DUR_DS_SLOW_PLCPHDR + \
+ IEEE80211_DUR_DS_DIFS)
+
+
+#endif /* !_NET80211_IEEE80211_H_ */
--- /dev/null
+/* $NetBSD: ieee80211_crypto.h,v 1.11 2009/01/03 03:43:23 yamt Exp $ */
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: src/sys/net80211/ieee80211_crypto.h,v 1.10 2005/08/08 18:46:35 sam Exp $
+ */
+#ifndef _NET80211_IEEE80211_CRYPTO_H_
+#define _NET80211_IEEE80211_CRYPTO_H_
+
+/*
+ * 802.11 protocol crypto-related definitions.
+ */
+#define IEEE80211_KEYBUF_SIZE 16
+#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx+rx keys */
+
+/*
+ * Old WEP-style key. Deprecated.
+ */
+struct ieee80211_wepkey {
+ u_int wk_len; /* key length in bytes */
+ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE];
+};
+
+struct ieee80211_cipher;
+
+/*
+ * Crypto key state. There is sufficient room for all supported
+ * ciphers (see below). The underlying ciphers are handled
+ * separately through loadable cipher modules that register with
+ * the generic crypto support. A key has a reference to an instance
+ * of the cipher; any per-key state is hung off wk_private by the
+ * cipher when it is attached. Ciphers are automatically called
+ * to detach and cleanup any such state when the key is deleted.
+ *
+ * The generic crypto support handles encap/decap of cipher-related
+ * frame contents for both hardware- and software-based implementations.
+ * A key requiring software crypto support is automatically flagged and
+ * the cipher is expected to honor this and do the necessary work.
+ * Ciphers such as TKIP may also support mixed hardware/software
+ * encrypt/decrypt and MIC processing.
+ */
+typedef u_int16_t ieee80211_keyix; /* h/w key index */
+
+struct ieee80211_key {
+ u_int8_t wk_keylen; /* key length in bytes */
+ u_int8_t wk_pad;
+ u_int16_t wk_flags;
+#define IEEE80211_KEY_XMIT 0x01 /* key used for xmit */
+#define IEEE80211_KEY_RECV 0x02 /* key used for recv */
+#define IEEE80211_KEY_GROUP 0x04 /* key used for WPA group operation */
+#define IEEE80211_KEY_SWCRYPT 0x10 /* host-based encrypt/decrypt */
+#define IEEE80211_KEY_SWMIC 0x20 /* host-based enmic/demic */
+ ieee80211_keyix wk_keyix; /* h/w key index */
+ ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */
+ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+#define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */
+#define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */
+ u_int64_t wk_keyrsc; /* key receive sequence counter */
+ u_int64_t wk_keytsc; /* key transmit sequence counter */
+ const struct ieee80211_cipher *wk_cipher;
+ void *wk_private; /* private cipher state */
+};
+#define IEEE80211_KEY_COMMON /* common flags passed in by apps */\
+ (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP)
+
+/*
+ * NB: these values are ordered carefully; there are lots of
+ * of implications in any reordering. In particular beware
+ * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
+ */
+#define IEEE80211_CIPHER_WEP 0
+#define IEEE80211_CIPHER_TKIP 1
+#define IEEE80211_CIPHER_AES_OCB 2
+#define IEEE80211_CIPHER_AES_CCM 3
+#define IEEE80211_CIPHER_CKIP 5
+#define IEEE80211_CIPHER_NONE 6 /* pseudo value */
+
+#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
+
+#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1)
+#define IEEE80211_KEY_UNDEFINED(k) ((k).wk_cipher == &ieee80211_cipher_none)
+
+#if defined(__KERNEL__) || defined(_KERNEL)
+
+struct ieee80211com;
+struct ieee80211_node;
+struct mbuf;
+
+/*
+ * Crypto state kept in each ieee80211com. Some of this
+ * can/should be shared when virtual AP's are supported.
+ *
+ * XXX save reference to ieee80211com to properly encapsulate state.
+ * XXX split out crypto capabilities from ic_caps
+ */
+struct ieee80211_crypto_state {
+ struct ieee80211_key cs_nw_keys[IEEE80211_WEP_NKID];
+ ieee80211_keyix cs_def_txkey; /* default/group tx key index */
+ u_int16_t cs_max_keyix; /* max h/w key index */
+
+ int (*cs_key_alloc)(struct ieee80211com *,
+ const struct ieee80211_key *,
+ ieee80211_keyix *, ieee80211_keyix *);
+ int (*cs_key_delete)(struct ieee80211com *,
+ const struct ieee80211_key *);
+ int (*cs_key_set)(struct ieee80211com *,
+ const struct ieee80211_key *,
+ const u_int8_t mac[IEEE80211_ADDR_LEN]);
+ void (*cs_key_update_begin)(struct ieee80211com *);
+ void (*cs_key_update_end)(struct ieee80211com *);
+};
+
+void ieee80211_crypto_attach(struct ieee80211com *);
+void ieee80211_crypto_detach(struct ieee80211com *);
+int ieee80211_crypto_newkey(struct ieee80211com *,
+ int cipher, int flags, struct ieee80211_key *);
+int ieee80211_crypto_delkey(struct ieee80211com *,
+ struct ieee80211_key *);
+int ieee80211_crypto_setkey(struct ieee80211com *,
+ struct ieee80211_key *, const u_int8_t macaddr[IEEE80211_ADDR_LEN]);
+void ieee80211_crypto_delglobalkeys(struct ieee80211com *);
+
+/*
+ * Template for a supported cipher. Ciphers register with the
+ * crypto code and are typically loaded as separate modules
+ * (the null cipher is always present).
+ * XXX may need refcnts
+ */
+struct ieee80211_cipher {
+ const char *ic_name; /* printable name */
+ u_int ic_cipher; /* IEEE80211_CIPHER_* */
+ u_int ic_header; /* size of privacy header (bytes) */
+ u_int ic_trailer; /* size of privacy trailer (bytes) */
+ u_int ic_miclen; /* size of mic trailer (bytes) */
+ void* (*ic_attach)(struct ieee80211com *, struct ieee80211_key *);
+ void (*ic_detach)(struct ieee80211_key *);
+ int (*ic_setkey)(struct ieee80211_key *);
+ int (*ic_encap)(struct ieee80211_key *, struct mbuf *,
+ u_int8_t keyid);
+ int (*ic_decap)(struct ieee80211_key *, struct mbuf *, int);
+ int (*ic_enmic)(struct ieee80211_key *, struct mbuf *, int);
+ int (*ic_demic)(struct ieee80211_key *, struct mbuf *, int);
+};
+extern const struct ieee80211_cipher ieee80211_cipher_none;
+extern const struct ieee80211_cipher ieee80211_cipher_wep;
+extern const struct ieee80211_cipher ieee80211_cipher_tkip;
+extern const struct ieee80211_cipher ieee80211_cipher_ccmp;
+
+void ieee80211_crypto_register(const struct ieee80211_cipher *);
+void ieee80211_crypto_unregister(const struct ieee80211_cipher *);
+int ieee80211_crypto_available(u_int cipher);
+
+struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211com *,
+ struct ieee80211_node *, struct mbuf *);
+struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211com *,
+ struct ieee80211_node *, struct mbuf *, int);
+
+/*
+ * Check and remove any MIC.
+ */
+static __inline int
+ieee80211_crypto_demic(struct ieee80211com *ic,
+ struct ieee80211_key *k, struct mbuf *m, int force)
+{
+ const struct ieee80211_cipher *cip = k->wk_cipher;
+ return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1);
+}
+
+/*
+ * Add any MIC.
+ */
+static __inline int
+ieee80211_crypto_enmic(struct ieee80211com *ic,
+ struct ieee80211_key *k, struct mbuf *m, int force)
+{
+ const struct ieee80211_cipher *cip = k->wk_cipher;
+ return (cip->ic_miclen > 0 ? cip->ic_enmic(k, m, force) : 1);
+}
+
+/*
+ * Reset key state to an unused state. The crypto
+ * key allocation mechanism insures other state (e.g.
+ * key data) is properly setup before a key is used.
+ */
+static __inline void
+ieee80211_crypto_resetkey(struct ieee80211com *ic,
+ struct ieee80211_key *k, ieee80211_keyix ix)
+{
+ k->wk_cipher = &ieee80211_cipher_none;
+ k->wk_private = k->wk_cipher->ic_attach(ic, k);
+ k->wk_keyix = k->wk_rxkeyix = ix;
+ k->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
+}
+
+/*
+ * Crypt-related notification methods.
+ */
+void ieee80211_notify_replay_failure(struct ieee80211com *,
+ const struct ieee80211_frame *, const struct ieee80211_key *,
+ u_int64_t rsc);
+void ieee80211_notify_michael_failure(struct ieee80211com *,
+ const struct ieee80211_frame *, u_int keyix);
+#endif /* defined(__KERNEL__) || defined(_KERNEL) */
+#endif /* !_NET80211_IEEE80211_CRYPTO_H_ */
--- /dev/null
+/* $NetBSD: ieee80211_ioctl.h,v 1.21 2015/09/06 06:01:01 dholland Exp $ */
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: src/sys/net80211/ieee80211_ioctl.h,v 1.14 2005/08/13 17:31:48 sam Exp $
+ */
+#ifndef _NET80211_IEEE80211_IOCTL_H_
+#define _NET80211_IEEE80211_IOCTL_H_
+
+/*
+ * IEEE 802.11 ioctls.
+ */
+#include <sys/ioccom.h>
+#include <net80211/_ieee80211.h>
+#include <net80211/ieee80211.h>
+#include <net80211/ieee80211_crypto.h>
+
+/*
+ * Per/node (station) statistics available when operating as an AP.
+ */
+struct ieee80211_nodestats {
+ u_int32_t ns_rx_data; /* rx data frames */
+ u_int32_t ns_rx_mgmt; /* rx management frames */
+ u_int32_t ns_rx_ctrl; /* rx control frames */
+ u_int32_t ns_rx_ucast; /* rx unicast frames */
+ u_int32_t ns_rx_mcast; /* rx multi/broadcast frames */
+ u_int64_t ns_rx_bytes; /* rx data count (bytes) */
+ u_int64_t ns_rx_beacons; /* rx beacon frames */
+ u_int32_t ns_rx_proberesp; /* rx probe response frames */
+
+ u_int32_t ns_rx_dup; /* rx discard 'cuz dup */
+ u_int32_t ns_rx_noprivacy; /* rx w/ wep but privacy off */
+ u_int32_t ns_rx_wepfail; /* rx wep processing failed */
+ u_int32_t ns_rx_demicfail; /* rx demic failed */
+ u_int32_t ns_rx_decap; /* rx decapsulation failed */
+ u_int32_t ns_rx_defrag; /* rx defragmentation failed */
+ u_int32_t ns_rx_disassoc; /* rx disassociation */
+ u_int32_t ns_rx_deauth; /* rx deauthentication */
+ u_int32_t ns_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t ns_rx_unauth; /* rx on unauthorized port */
+ u_int32_t ns_rx_unencrypted; /* rx unecrypted w/ privacy */
+
+ u_int32_t ns_tx_data; /* tx data frames */
+ u_int32_t ns_tx_mgmt; /* tx management frames */
+ u_int32_t ns_tx_ucast; /* tx unicast frames */
+ u_int32_t ns_tx_mcast; /* tx multi/broadcast frames */
+ u_int64_t ns_tx_bytes; /* tx data count (bytes) */
+ u_int32_t ns_tx_probereq; /* tx probe request frames */
+
+ u_int32_t ns_tx_novlantag; /* tx discard 'cuz no tag */
+ u_int32_t ns_tx_vlanmismatch; /* tx discard 'cuz bad tag */
+
+ u_int32_t ns_ps_discard; /* ps discard 'cuz of age */
+
+ /* MIB-related state */
+ u_int32_t ns_tx_assoc; /* [re]associations */
+ u_int32_t ns_tx_assoc_fail; /* [re]association failures */
+ u_int32_t ns_tx_auth; /* [re]authentications */
+ u_int32_t ns_tx_auth_fail; /* [re]authentication failures*/
+ u_int32_t ns_tx_deauth; /* deauthentications */
+ u_int32_t ns_tx_deauth_code; /* last deauth reason */
+ u_int32_t ns_tx_disassoc; /* disassociations */
+ u_int32_t ns_tx_disassoc_code; /* last disassociation reason */
+};
+
+#ifdef COMPAT_20
+struct ieee80211_ostats {
+ u_int32_t is_rx_badversion; /* rx frame with bad version */
+ u_int32_t is_rx_tooshort; /* rx frame too short */
+ u_int32_t is_rx_wrongbss; /* rx from wrong bssid */
+ u_int32_t is_rx_dup; /* rx discard 'cuz dup */
+ u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */
+ u_int32_t is_rx_mcastecho; /* rx discard 'cuz mcast echo */
+ u_int32_t is_rx_notassoc; /* rx discard 'cuz sta !assoc */
+ u_int32_t is_rx_nowep; /* rx w/ wep but wep !config */
+ u_int32_t is_rx_wepfail; /* rx wep processing failed */
+ u_int32_t is_rx_decap; /* rx decapsulation failed */
+ u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */
+ u_int32_t is_rx_ctl; /* rx discard ctrl frames */
+ u_int32_t is_rx_rstoobig; /* rx rate set truncated */
+ u_int32_t is_rx_elem_missing; /* rx required element missing*/
+ u_int32_t is_rx_elem_toobig; /* rx element too big */
+ u_int32_t is_rx_elem_toosmall; /* rx element too small */
+ u_int32_t is_rx_elem_unknown; /* rx element unknown */
+ u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */
+ u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */
+ u_int32_t is_rx_nodealloc; /* rx frame dropped */
+ u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */
+ u_int32_t is_rx_auth_unsupported; /* rx w/ unsupported auth alg */
+ u_int32_t is_rx_auth_fail; /* rx sta auth failure */
+ u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */
+ u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */
+ u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */
+ u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */
+ u_int32_t is_rx_deauth; /* rx deauthentication */
+ u_int32_t is_rx_disassoc; /* rx disassociation */
+ u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/
+ u_int32_t is_rx_nombuf; /* rx failed for lack of mbuf */
+ u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/
+ u_int32_t is_rx_bad_auth; /* rx bad auth request */
+ u_int32_t is_tx_nombuf; /* tx failed for lack of mbuf */
+ u_int32_t is_tx_nonode; /* tx failed for no node */
+ u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */
+ u_int32_t is_scan_active; /* active scans started */
+ u_int32_t is_scan_passive; /* passive scans started */
+ u_int32_t is_node_timeout; /* nodes timed out inactivity */
+ u_int32_t is_crypto_nomem; /* no memory for crypto ctx */
+};
+#endif /* COMPAT_20 */
+
+/*
+ * Summary statistics.
+ */
+struct ieee80211_stats {
+ u_int32_t is_rx_badversion; /* rx frame with bad version */
+ u_int32_t is_rx_tooshort; /* rx frame too short */
+ u_int32_t is_rx_wrongbss; /* rx from wrong bssid */
+ u_int32_t is_rx_dup; /* rx discard 'cuz dup */
+ u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */
+ u_int32_t is_rx_mcastecho; /* rx discard 'cuz mcast echo */
+ u_int32_t is_rx_notassoc; /* rx discard 'cuz sta !assoc */
+ u_int32_t is_rx_noprivacy; /* rx w/ wep but privacy off */
+ u_int32_t is_rx_unencrypted; /* rx w/o wep and privacy on */
+ u_int32_t is_rx_wepfail; /* rx wep processing failed */
+ u_int32_t is_rx_decap; /* rx decapsulation failed */
+ u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */
+ u_int32_t is_rx_ctl; /* rx discard ctrl frames */
+ u_int32_t is_rx_beacon; /* rx beacon frames */
+ u_int32_t is_rx_rstoobig; /* rx rate set truncated */
+ u_int32_t is_rx_elem_missing; /* rx required element missing*/
+ u_int32_t is_rx_elem_toobig; /* rx element too big */
+ u_int32_t is_rx_elem_toosmall; /* rx element too small */
+ u_int32_t is_rx_elem_unknown; /* rx element unknown */
+ u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */
+ u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */
+ u_int32_t is_rx_nodealloc; /* rx frame dropped */
+ u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */
+ u_int32_t is_rx_auth_unsupported; /* rx w/ unsupported auth alg */
+ u_int32_t is_rx_auth_fail; /* rx sta auth failure */
+ u_int32_t is_rx_auth_countermeasures;/* rx auth discard 'cuz CM */
+ u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */
+ u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */
+ u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */
+ u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */
+ u_int32_t is_rx_assoc_badwpaie; /* rx assoc w/ bad WPA IE */
+ u_int32_t is_rx_deauth; /* rx deauthentication */
+ u_int32_t is_rx_disassoc; /* rx disassociation */
+ u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/
+ u_int32_t is_rx_nobuf; /* rx failed for lack of buf */
+ u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/
+ u_int32_t is_rx_bad_auth; /* rx bad auth request */
+ u_int32_t is_rx_unauth; /* rx on unauthorized port */
+ u_int32_t is_rx_badkeyid; /* rx w/ incorrect keyid */
+ u_int32_t is_rx_ccmpreplay; /* rx seq# violation (CCMP) */
+ u_int32_t is_rx_ccmpformat; /* rx format bad (CCMP) */
+ u_int32_t is_rx_ccmpmic; /* rx MIC check failed (CCMP) */
+ u_int32_t is_rx_tkipreplay; /* rx seq# violation (TKIP) */
+ u_int32_t is_rx_tkipformat; /* rx format bad (TKIP) */
+ u_int32_t is_rx_tkipmic; /* rx MIC check failed (TKIP) */
+ u_int32_t is_rx_tkipicv; /* rx ICV check failed (TKIP) */
+ u_int32_t is_rx_badcipher; /* rx failed 'cuz key type */
+ u_int32_t is_rx_nocipherctx; /* rx failed 'cuz key !setup */
+ u_int32_t is_rx_acl; /* rx discard 'cuz acl policy */
+ u_int32_t is_tx_nobuf; /* tx failed for lack of buf */
+ u_int32_t is_tx_nonode; /* tx failed for no node */
+ u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */
+ u_int32_t is_tx_badcipher; /* tx failed 'cuz key type */
+ u_int32_t is_tx_nodefkey; /* tx failed 'cuz no defkey */
+ u_int32_t is_tx_noheadroom; /* tx failed 'cuz no space */
+ u_int32_t is_tx_fragframes; /* tx frames fragmented */
+ u_int32_t is_tx_frags; /* tx fragments created */
+ u_int32_t is_scan_active; /* active scans started */
+ u_int32_t is_scan_passive; /* passive scans started */
+ u_int32_t is_node_timeout; /* nodes timed out inactivity */
+ u_int32_t is_crypto_nomem; /* no memory for crypto ctx */
+ u_int32_t is_crypto_tkip; /* tkip crypto done in s/w */
+ u_int32_t is_crypto_tkipenmic; /* tkip en-MIC done in s/w */
+ u_int32_t is_crypto_tkipdemic; /* tkip de-MIC done in s/w */
+ u_int32_t is_crypto_tkipcm; /* tkip counter measures */
+ u_int32_t is_crypto_ccmp; /* ccmp crypto done in s/w */
+ u_int32_t is_crypto_wep; /* wep crypto done in s/w */
+ u_int32_t is_crypto_setkey_cipher;/* cipher rejected key */
+ u_int32_t is_crypto_setkey_nokey; /* no key index for setkey */
+ u_int32_t is_crypto_delkey; /* driver key delete failed */
+ u_int32_t is_crypto_badcipher; /* unknown cipher */
+ u_int32_t is_crypto_nocipher; /* cipher not available */
+ u_int32_t is_crypto_attachfail; /* cipher attach failed */
+ u_int32_t is_crypto_swfallback; /* cipher fallback to s/w */
+ u_int32_t is_crypto_keyfail; /* driver key alloc failed */
+ u_int32_t is_crypto_enmicfail; /* en-MIC failed */
+ u_int32_t is_ibss_capmismatch; /* merge failed-cap mismatch */
+ u_int32_t is_ibss_norate; /* merge failed-rate mismatch */
+ u_int32_t is_ps_unassoc; /* ps-poll for unassoc. sta */
+ u_int32_t is_ps_badaid; /* ps-poll w/ incorrect aid */
+ u_int32_t is_ps_qempty; /* ps-poll w/ nothing to send */
+ u_int32_t is_ff_badhdr; /* fast frame rx'd w/ bad hdr */
+ u_int32_t is_ff_tooshort; /* fast frame rx decap error */
+ u_int32_t is_ff_split; /* fast frame rx split error */
+ u_int32_t is_ff_decap; /* fast frames decap'd */
+ u_int32_t is_ff_encap; /* fast frames encap'd for tx */
+ u_int32_t is_rx_badbintval; /* rx frame w/ bogus bintval */
+ u_int32_t is_spare[9];
+};
+
+/*
+ * Max size of optional information elements. We artificially
+ * constrain this; it's limited only by the max frame size (and
+ * the max parameter size of the wireless extensions).
+ */
+#define IEEE80211_MAX_OPT_IE 256
+
+/*
+ * WPA/RSN get/set key request. Specify the key/cipher
+ * type and whether the key is to be used for sending and/or
+ * receiving. The key index should be set only when working
+ * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
+ * Otherwise a unicast/pairwise key is specified by the bssid
+ * (on a station) or mac address (on an ap). They key length
+ * must include any MIC key data; otherwise it should be no
+ more than IEEE80211_KEYBUF_SIZE.
+ */
+struct ieee80211req_key {
+ u_int8_t ik_type; /* key/cipher type */
+ u_int8_t ik_pad;
+ u_int16_t ik_keyix; /* key index */
+ u_int8_t ik_keylen; /* key length in bytes */
+ u_int8_t ik_flags;
+/* NB: IEEE80211_KEY_XMIT and IEEE80211_KEY_RECV defined elsewhere */
+#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */
+ u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t ik_keyrsc; /* key receive sequence counter */
+ u_int64_t ik_keytsc; /* key transmit sequence counter */
+ u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+};
+
+/*
+ * Delete a key either by index or address. Set the index
+ * to IEEE80211_KEYIX_NONE when deleting a unicast key.
+ */
+struct ieee80211req_del_key {
+ u_int8_t idk_keyix; /* key index */
+ u_int8_t idk_macaddr[IEEE80211_ADDR_LEN];
+};
+
+/*
+ * MLME state manipulation request. IEEE80211_MLME_ASSOC
+ * only makes sense when operating as a station. The other
+ * requests can be used when operating as a station or an
+ * ap (to effect a station).
+ */
+struct ieee80211req_mlme {
+ u_int8_t im_op; /* operation to perform */
+#define IEEE80211_MLME_ASSOC 1 /* associate station */
+#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */
+#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */
+#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */
+#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */
+ u_int8_t im_ssid_len; /* length of optional ssid */
+ u_int16_t im_reason; /* 802.11 reason code */
+ u_int8_t im_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t im_ssid[IEEE80211_NWID_LEN];
+};
+
+/*
+ * MAC ACL operations.
+ */
+enum {
+ IEEE80211_MACCMD_POLICY_OPEN = 0, /* set policy: no ACL's */
+ IEEE80211_MACCMD_POLICY_ALLOW = 1, /* set policy: allow traffic */
+ IEEE80211_MACCMD_POLICY_DENY = 2, /* set policy: deny traffic */
+ IEEE80211_MACCMD_FLUSH = 3, /* flush ACL database */
+ IEEE80211_MACCMD_DETACH = 4, /* detach ACL policy */
+ IEEE80211_MACCMD_POLICY = 5, /* get ACL policy */
+ IEEE80211_MACCMD_LIST = 6 /* get ACL database */
+};
+
+struct ieee80211req_maclist {
+ u_int8_t ml_macaddr[IEEE80211_ADDR_LEN];
+};
+
+/*
+ * Set the active channel list. Note this list is
+ * intersected with the available channel list in
+ * calculating the set of channels actually used in
+ * scanning.
+ */
+struct ieee80211req_chanlist {
+ u_int8_t ic_channels[IEEE80211_CHAN_BYTES];
+};
+
+/*
+ * Get the active channel list info.
+ */
+struct ieee80211req_chaninfo {
+ u_int ic_nchans;
+ struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX];
+};
+
+/*
+ * Retrieve the WPA/RSN information element for an associated station.
+ */
+struct ieee80211req_wpaie {
+ u_int8_t wpa_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t wpa_ie[IEEE80211_MAX_OPT_IE];
+};
+
+/*
+ * Retrieve per-node statistics.
+ */
+struct ieee80211req_sta_stats {
+ union {
+ /* NB: explicitly force 64-bit alignment */
+ u_int8_t macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t pad;
+ } is_u;
+ struct ieee80211_nodestats is_stats;
+};
+
+/*
+ * Station information block; the mac address is used
+ * to retrieve other data like stats, unicast key, etc.
+ */
+struct ieee80211req_sta_info {
+ u_int16_t isi_len; /* length (mult of 4) */
+ u_int16_t isi_freq; /* MHz */
+ u_int16_t isi_flags; /* channel flags */
+ u_int16_t isi_state; /* state flags */
+ u_int8_t isi_authmode; /* authentication algorithm */
+ u_int8_t isi_rssi;
+ u_int8_t isi_capinfo; /* capabilities */
+ u_int8_t isi_erp; /* ERP element */
+ u_int8_t isi_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t isi_nrates;
+ /* negotiated rates */
+ u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isi_txrate; /* index to isi_rates[] */
+ u_int16_t isi_ie_len; /* IE length */
+ u_int16_t isi_associd; /* assoc response */
+ u_int16_t isi_txpower; /* current tx power */
+ u_int16_t isi_vlan; /* vlan tag */
+ u_int16_t isi_txseqs[17]; /* seq to be transmitted */
+ u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/
+ u_int16_t isi_inact; /* inactivity timer */
+ /* XXX frag state? */
+ /* variable length IE data */
+};
+
+/*
+ * Retrieve per-station information; to retrieve all
+ * specify a mac address of ff:ff:ff:ff:ff:ff.
+ */
+struct ieee80211req_sta_req {
+ union {
+ /* NB: explicitly force 64-bit alignment */
+ u_int8_t macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t pad;
+ } is_u;
+ struct ieee80211req_sta_info info[1]; /* variable length */
+};
+
+/*
+ * Get/set per-station tx power cap.
+ */
+struct ieee80211req_sta_txpow {
+ u_int8_t it_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t it_txpow;
+};
+
+/*
+ * WME parameters are set and return using i_val and i_len.
+ * i_val holds the value itself. i_len specifies the AC
+ * and, as appropriate, then high bit specifies whether the
+ * operation is to be applied to the BSS or ourself.
+ */
+#define IEEE80211_WMEPARAM_SELF 0x0000 /* parameter applies to self */
+#define IEEE80211_WMEPARAM_BSS 0x8000 /* parameter applies to BSS */
+#define IEEE80211_WMEPARAM_VAL 0x7fff /* parameter value */
+
+/*
+ * FreeBSD-style ioctls.
+ */
+/* the first member must be matched with struct ifreq */
+struct ieee80211req {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ u_int16_t i_type; /* req type */
+ int16_t i_val; /* Index or simple value */
+ u_int16_t i_len; /* Index or simple value */
+ void *i_data; /* Extra data */
+};
+
+#ifdef __FreeBSD__
+#define SIOCS80211 _IOW('i', 234, struct ieee80211req)
+#define SIOCG80211 _IOWR('i', 235, struct ieee80211req)
+#define SIOCG80211STATS _IOWR('i', 236, struct ifreq)
+#endif /* __FreeBSD__ */
+
+#if defined(__NetBSD__) || defined(__minix)
+#define SIOCS80211 _IOW('i', 244, struct ieee80211req)
+#define SIOCG80211 _IOWR('i', 245, struct ieee80211req)
+#define SIOCG80211STATS _IOWR('i', 246, struct ifreq)
+#define SIOCG80211ZSTATS _IOWR('i', 247, struct ifreq)
+#ifdef COMPAT_20
+#define OSIOCG80211STATS _IOWR('i', 242, struct ifreq)
+#define OSIOCG80211ZSTATS _IOWR('i', 243, struct ifreq)
+#endif /* COMPAT_20 */
+#endif /* defined(__NetBSD__) || defined(__minix) */
+
+#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211)
+#define IEEE80211_IOC_SSID 1
+#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */
+#define IEEE80211_IOC_NUMSSIDS 2
+#define IEEE80211_IOC_WEP 3
+#define IEEE80211_WEP_NOSUP -1
+#define IEEE80211_WEP_OFF 0
+#define IEEE80211_WEP_ON 1
+#define IEEE80211_WEP_MIXED 2
+#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211)
+#define IEEE80211_IOC_WEPKEY 4
+#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */
+#define IEEE80211_IOC_NUMWEPKEYS 5
+#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211)
+#define IEEE80211_IOC_WEPTXKEY 6
+#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */
+#define IEEE80211_IOC_AUTHMODE 7
+#define IEEE80211_IOC_STATIONNAME 8
+#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211)
+#define IEEE80211_IOC_CHANNEL 9
+#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */
+#define IEEE80211_IOC_POWERSAVE 10
+#define IEEE80211_POWERSAVE_NOSUP -1
+#define IEEE80211_POWERSAVE_OFF 0
+#define IEEE80211_POWERSAVE_CAM 1
+#define IEEE80211_POWERSAVE_PSP 2
+#define IEEE80211_POWERSAVE_PSP_CAM 3
+#define IEEE80211_POWERSAVE_ON IEEE80211_POWERSAVE_CAM
+#define IEEE80211_IOC_POWERSAVESLEEP 11
+#define IEEE80211_IOC_RTSTHRESHOLD 12
+#define IEEE80211_IOC_PROTMODE 13
+#define IEEE80211_PROTMODE_OFF 0
+#define IEEE80211_PROTMODE_CTS 1
+#define IEEE80211_PROTMODE_RTSCTS 2
+#define IEEE80211_IOC_TXPOWER 14 /* global tx power limit */
+#if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211)
+#define IEEE80211_IOC_BSSID 15
+#endif /* __FreeBSD__ || COMPAT_FREEBSD_NET80211 */
+#define IEEE80211_IOC_ROAMING 16 /* roaming mode */
+#define IEEE80211_IOC_PRIVACY 17 /* privacy invoked */
+#define IEEE80211_IOC_DROPUNENCRYPTED 18 /* discard unencrypted frames */
+#define IEEE80211_IOC_WPAKEY 19
+#define IEEE80211_IOC_DELKEY 20
+#define IEEE80211_IOC_MLME 21
+#define IEEE80211_IOC_OPTIE 22 /* optional info. element */
+#define IEEE80211_IOC_SCAN_REQ 23
+#define IEEE80211_IOC_SCAN_RESULTS 24
+#define IEEE80211_IOC_COUNTERMEASURES 25 /* WPA/TKIP countermeasures */
+#define IEEE80211_IOC_WPA 26 /* WPA mode (0,1,2) */
+#define IEEE80211_IOC_CHANLIST 27 /* channel list */
+#define IEEE80211_IOC_WME 28 /* WME mode (on, off) */
+#define IEEE80211_IOC_HIDESSID 29 /* hide SSID mode (on, off) */
+#define IEEE80211_IOC_APBRIDGE 30 /* AP inter-sta bridging */
+#define IEEE80211_IOC_MCASTCIPHER 31 /* multicast/default cipher */
+#define IEEE80211_IOC_MCASTKEYLEN 32 /* multicast key length */
+#define IEEE80211_IOC_UCASTCIPHERS 33 /* unicast cipher suites */
+#define IEEE80211_IOC_UCASTCIPHER 34 /* unicast cipher */
+#define IEEE80211_IOC_UCASTKEYLEN 35 /* unicast key length */
+#define IEEE80211_IOC_DRIVER_CAPS 36 /* driver capabilities */
+#define IEEE80211_IOC_KEYMGTALGS 37 /* key management algorithms */
+#define IEEE80211_IOC_RSNCAPS 38 /* RSN capabilities */
+#define IEEE80211_IOC_WPAIE 39 /* WPA information element */
+#define IEEE80211_IOC_STA_STATS 40 /* per-station statistics */
+#define IEEE80211_IOC_MACCMD 41 /* MAC ACL operation */
+#define IEEE80211_IOC_CHANINFO 42 /* channel info list */
+#define IEEE80211_IOC_TXPOWMAX 43 /* max tx power for channel */
+#define IEEE80211_IOC_STA_TXPOW 44 /* per-station tx power limit */
+#define IEEE80211_IOC_STA_INFO 45 /* station/neighbor info */
+#define IEEE80211_IOC_WME_CWMIN 46 /* WME: ECWmin */
+#define IEEE80211_IOC_WME_CWMAX 47 /* WME: ECWmax */
+#define IEEE80211_IOC_WME_AIFS 48 /* WME: AIFSN */
+#define IEEE80211_IOC_WME_TXOPLIMIT 49 /* WME: txops limit */
+#define IEEE80211_IOC_WME_ACM 50 /* WME: ACM (bss only) */
+#define IEEE80211_IOC_WME_ACKPOLICY 51 /* WME: ACK policy (!bss only)*/
+#define IEEE80211_IOC_DTIM_PERIOD 52 /* DTIM period (beacons) */
+#define IEEE80211_IOC_BEACON_INTERVAL 53 /* beacon interval (ms) */
+#define IEEE80211_IOC_ADDMAC 54 /* add sta to MAC ACL table */
+#define IEEE80211_IOC_DELMAC 55 /* del sta from MAC ACL table */
+#define IEEE80211_IOC_PUREG 56 /* pure 11g (no 11b stations) */
+#define IEEE80211_IOC_MCAST_RATE 72 /* tx rate for mcast frames */
+#define IEEE80211_IOC_FRAGTHRESHOLD 73 /* tx fragmentation threshold */
+
+/*
+ * Scan result data returned for IEEE80211_IOC_SCAN_RESULTS.
+ */
+struct ieee80211req_scan_result {
+ u_int16_t isr_len; /* length (mult of 4) */
+ u_int16_t isr_freq; /* MHz */
+ u_int16_t isr_flags; /* channel flags */
+ u_int8_t isr_noise;
+ u_int8_t isr_rssi;
+ u_int8_t isr_intval; /* beacon interval */
+ u_int8_t isr_capinfo; /* capabilities */
+ u_int8_t isr_erp; /* ERP element */
+ u_int8_t isr_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t isr_nrates;
+ u_int8_t isr_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isr_ssid_len; /* SSID length */
+ u_int8_t isr_ie_len; /* IE length */
+ u_int8_t isr_pad[5];
+ /* variable length SSID followed by IE data */
+};
+
+#if defined(__NetBSD__) || defined(__minix)
+/* nwid is pointed at by ifr.ifr_data */
+struct ieee80211_nwid {
+ u_int8_t i_len;
+ u_int8_t i_nwid[IEEE80211_NWID_LEN];
+};
+
+#define SIOCS80211NWID _IOWR('i', 230, struct ifreq)
+#define SIOCG80211NWID _IOWR('i', 231, struct ifreq)
+
+/* the first member must be matched with struct ifreq */
+struct ieee80211_nwkey {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ int i_wepon; /* wep enabled flag */
+ int i_defkid; /* default encrypt key id */
+ struct {
+ int i_keylen;
+ u_int8_t *i_keydat;
+ } i_key[IEEE80211_WEP_NKID];
+};
+#define SIOCS80211NWKEY _IOW('i', 232, struct ieee80211_nwkey)
+#define SIOCG80211NWKEY _IOWR('i', 233, struct ieee80211_nwkey)
+/* i_wepon */
+#define IEEE80211_NWKEY_OPEN 0 /* No privacy */
+#define IEEE80211_NWKEY_WEP 1 /* WEP enabled */
+#define IEEE80211_NWKEY_EAP 2 /* EAP enabled */
+#define IEEE80211_NWKEY_PERSIST 0x100 /* designate persist keyset */
+
+/* power management parameters */
+struct ieee80211_power {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ int i_enabled; /* 1 == on, 0 == off */
+ int i_maxsleep; /* max sleep in ms */
+};
+#define SIOCS80211POWER _IOW('i', 234, struct ieee80211_power)
+#define SIOCG80211POWER _IOWR('i', 235, struct ieee80211_power)
+
+struct ieee80211_auth {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ int i_authtype;
+};
+
+#define IEEE80211_AUTH_NONE 0
+#define IEEE80211_AUTH_OPEN 1
+#define IEEE80211_AUTH_SHARED 2
+
+#define SIOCS80211AUTH _IOW('i', 236, struct ieee80211_auth)
+#define SIOCG80211AUTH _IOWR('i', 237, struct ieee80211_auth)
+
+struct ieee80211chanreq {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ u_int16_t i_channel;
+};
+
+#ifndef IEEE80211_CHAN_ANY
+#define IEEE80211_CHAN_ANY 0xffff
+#endif
+
+#define SIOCS80211CHANNEL _IOW('i', 238, struct ieee80211chanreq)
+#define SIOCG80211CHANNEL _IOWR('i', 239, struct ieee80211chanreq)
+
+struct ieee80211_bssid {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+};
+
+#define SIOCS80211BSSID _IOW('i', 240, struct ieee80211_bssid)
+#define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid)
+
+#endif /* defined(__NetBSD__) || defined(__minix) */
+
+#endif /* !_NET80211_IEEE80211_IOCTL_H_ */
--- /dev/null
+/* $NetBSD: ieee80211_netbsd.h,v 1.19 2014/04/07 00:07:40 pooka Exp $ */
+/*-
+ * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: src/sys/net80211/ieee80211_freebsd.h,v 1.6 2005/08/08 18:46:36 sam Exp $
+ */
+#ifndef _NET80211_IEEE80211_NETBSD_H_
+#define _NET80211_IEEE80211_NETBSD_H_
+
+#ifdef _KERNEL
+#define IASSERT(__cond, __complaint) \
+ do { \
+ if (!(__cond)) \
+ panic __complaint ; \
+ } while (/*CONSTCOND*/0)
+
+void if_printf(struct ifnet *, const char *, ...)
+ __attribute__((__format__(__printf__,2,3)));
+
+#define IEEE80211_LOCK_INIT_IMPL(_ic, _name, _member) \
+ mutex_init(&(_ic)->_member, MUTEX_DEFAULT, IPL_NET)
+#define IEEE80211_LOCK_IMPL(_ic, _member) \
+ mutex_enter(&(_ic)->_member)
+#define IEEE80211_IS_LOCKED_IMPL(_ic, _member) \
+ mutex_owned(&(_ic)->_member)
+#define IEEE80211_UNLOCK_IMPL(_ic, _member) \
+ mutex_exit(&(_ic)->_member)
+#define IEEE80211_LOCK_ASSERT_IMPL(_ic, _member) \
+ IASSERT(mutex_owned(&(_ic)->_member), \
+ ("%s: IEEE80211_LOCK not held", __func__))
+#define IEEE80211_LOCK_DESTROY_IMPL(_ic, _member) \
+ mutex_destroy(&(_ic)->_member)
+
+/*
+ * Beacon locking definitions.
+ */
+typedef kmutex_t ieee80211_beacon_lock_t;
+#define IEEE80211_BEACON_LOCK_INIT(_ic, _name) \
+ IEEE80211_LOCK_INIT_IMPL(_ic, _name, ic_beaconlock)
+#define IEEE80211_BEACON_LOCK_DESTROY(_ic) \
+ IEEE80211_LOCK_DESTROY_IMPL(_ic, ic_beaconlock)
+#define IEEE80211_BEACON_LOCK(_ic) \
+ IEEE80211_LOCK_IMPL(_ic, ic_beaconlock)
+#define IEEE80211_BEACON_UNLOCK(_ic) \
+ IEEE80211_UNLOCK_IMPL(_ic, ic_beaconlock)
+#define IEEE80211_BEACON_LOCK_ASSERT(_ic) \
+ IEEE80211_LOCK_ASSERT_IMPL(_ic, ic_beaconlock)
+
+/*
+ * Node locking definitions.
+ * NB: MTX_DUPOK is because we don't generate per-interface strings.
+ */
+typedef kmutex_t ieee80211_node_lock_t;
+#define IEEE80211_NODE_LOCK_INIT(_nt, _name) \
+ IEEE80211_LOCK_INIT_IMPL(_nt, _name, nt_nodelock)
+#define IEEE80211_NODE_LOCK_DESTROY(_nt) \
+ IEEE80211_LOCK_DESTROY_IMPL(_nt, nt_nodelock)
+#define IEEE80211_NODE_LOCK(_nt) \
+ IEEE80211_LOCK_IMPL(_nt, nt_nodelock)
+#define IEEE80211_NODE_IS_LOCKED(_nt) \
+ IEEE80211_IS_LOCKED_IMPL(_nt, nt_nodelock)
+#define IEEE80211_NODE_UNLOCK(_nt) \
+ IEEE80211_UNLOCK_IMPL(_nt, nt_nodelock)
+#define IEEE80211_NODE_LOCK_ASSERT(_nt) \
+ IEEE80211_LOCK_ASSERT_IMPL(_nt, nt_nodelock)
+
+/*
+ * Node table scangen locking definitions.
+ */
+typedef kmutex_t ieee80211_scan_lock_t;
+#define IEEE80211_SCAN_LOCK_INIT(_nt, _name) \
+ IEEE80211_LOCK_INIT_IMPL(_nt, _name, nt_scanlock)
+#define IEEE80211_SCAN_LOCK_DESTROY(_nt) \
+ IEEE80211_LOCK_DESTROY_IMPL(_nt, nt_scanlock)
+#define IEEE80211_SCAN_LOCK(_nt) \
+ IEEE80211_LOCK_IMPL(_nt, nt_scanlock)
+#define IEEE80211_SCAN_UNLOCK(_nt) \
+ IEEE80211_UNLOCK_IMPL(_nt, nt_scanlock)
+#define IEEE80211_SCAN_LOCK_ASSERT(_nt) \
+ IEEE80211_LOCK_ASSERT_IMPL(_nt, nt_scanlock)
+
+/*
+ * Per-node power-save queue definitions.
+ */
+#define IEEE80211_NODE_SAVEQ_INIT(_ni, _name) do { \
+ (_ni)->ni_savedq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE; \
+} while (0)
+#define IEEE80211_NODE_SAVEQ_DESTROY(_ni)
+#define IEEE80211_NODE_SAVEQ_QLEN(_ni) ((_ni)->ni_savedq.ifq_len)
+#define IEEE80211_NODE_SAVEQ_LOCK(_ni)
+#define IEEE80211_NODE_SAVEQ_UNLOCK(_ni)
+#define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _m, _qlen) do { \
+ IEEE80211_NODE_SAVEQ_LOCK(_ni); \
+ IF_DEQUEUE(&(_ni)->ni_savedq, _m); \
+ (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \
+ IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \
+} while (0)
+#define IEEE80211_NODE_SAVEQ_DRAIN(_ni, _qlen) do { \
+ IEEE80211_NODE_SAVEQ_LOCK(_ni); \
+ (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \
+ IF_PURGE(&(_ni)->ni_savedq); \
+ IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \
+} while (0)
+/* XXX could be optimized */
+#define _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(_ni, _m) do { \
+ IF_DEQUEUE(&(_ni)->ni_savedq, m); \
+} while (0)
+#define _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _m, _qlen, _age) do {\
+ (_m)->m_nextpkt = NULL; \
+ if ((_ni)->ni_savedq.ifq_tail != NULL) { \
+ _age -= M_AGE_GET((_ni)->ni_savedq.ifq_tail); \
+ (_ni)->ni_savedq.ifq_tail->m_nextpkt = (_m); \
+ } else { \
+ (_ni)->ni_savedq.ifq_head = (_m); \
+ } \
+ M_AGE_SET(_m, _age); \
+ (_ni)->ni_savedq.ifq_tail = (_m); \
+ (_qlen) = ++(_ni)->ni_savedq.ifq_len; \
+} while (0)
+
+/*
+ * 802.1x MAC ACL database locking definitions.
+ */
+typedef kmutex_t acl_lock_t;
+#define ACL_LOCK_INIT(_as, _name) \
+ IEEE80211_LOCK_INIT_IMPL(_as, _name, as_lock)
+#define ACL_LOCK_DESTROY(_as) \
+ IEEE80211_LOCK_DESTROY_IMPL(_as, as_lock)
+#define ACL_LOCK(_as) IEEE80211_LOCK_IMPL(_as, as_lock)
+#define ACL_UNLOCK(_as) IEEE80211_UNLOCK_IMPL(_as, as_lock)
+#define ACL_LOCK_ASSERT(_as) IEEE80211_LOCK_ASSERT_IMPL(_as, as_lock)
+
+struct ifqueue;
+void ieee80211_drain_ifq(struct ifqueue *);
+
+struct mbuf *ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen);
+#define M_PWR_SAV M_PROTO1 /* bypass PS handling */
+#define M_MORE_DATA M_LINK3 /* more data frames to follow */
+#define M_FRAG M_LINK4 /* 802.11 fragment */
+#define M_FIRSTFRAG M_LINK5 /* first 802.11 fragment */
+#define M_FF M_LINK6 /* "fast frames" */
+/*
+ * Encode WME access control bits in the PROTO flags.
+ * This is safe since it's passed directly in to the
+ * driver and there's no chance someone else will clobber
+ * them on us.
+ */
+#define M_WME_AC_MASK (M_LINK1|M_LINK2)
+/* XXX 5 is wrong if M_LINK* are redefined */
+#define M_WME_AC_SHIFT 13
+
+#define M_WME_SETAC(m, ac) \
+ ((m)->m_flags = ((m)->m_flags &~ M_WME_AC_MASK) | \
+ ((ac) << M_WME_AC_SHIFT))
+#define M_WME_GETAC(m) (((m)->m_flags >> M_WME_AC_SHIFT) & 0x3)
+
+/*
+ * Mbufs on the power save queue are tagged with an age and
+ * timed out. We reuse the hardware checksum field in the
+ * mbuf packet header to store this data.
+ */
+#define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v)
+#define M_AGE_GET(m) (m->m_pkthdr.csum_data)
+#define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)
+
+struct ieee80211com;
+#endif /* _KERNEL */
+
+/* XXX this stuff belongs elsewhere */
+/*
+ * Message formats for messages from the net80211 layer to user
+ * applications via the routing socket. These messages are appended
+ * to an if_announcemsghdr structure.
+ */
+struct ieee80211_join_event {
+ uint8_t iev_addr[6];
+};
+
+struct ieee80211_leave_event {
+ uint8_t iev_addr[6];
+};
+
+struct ieee80211_replay_event {
+ uint8_t iev_src[6]; /* src MAC */
+ uint8_t iev_dst[6]; /* dst MAC */
+ uint8_t iev_cipher; /* cipher type */
+ uint8_t iev_keyix; /* key id/index */
+ uint64_t iev_keyrsc; /* RSC from key */
+ uint64_t iev_rsc; /* RSC from frame */
+};
+
+struct ieee80211_michael_event {
+ uint8_t iev_src[6]; /* src MAC */
+ uint8_t iev_dst[6]; /* dst MAC */
+ uint8_t iev_cipher; /* cipher type */
+ uint8_t iev_keyix; /* key id/index */
+};
+
+#define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */
+#define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */
+#define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */
+#define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */
+#define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */
+#define RTM_IEEE80211_SCAN 105 /* scan complete, results available */
+#define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */
+#define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */
+#define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */
+
+#ifdef _KERNEL
+#define ticks hardclock_ticks
+#define ovbcopy(__src, __dst, __n) ((void)memmove(__dst, __src, __n))
+
+void if_printf(struct ifnet *, const char *, ...);
+void get_random_bytes(void *, size_t);
+
+void ieee80211_sysctl_attach(struct ieee80211com *);
+void ieee80211_sysctl_detach(struct ieee80211com *);
+void ieee80211_load_module(const char *);
+
+void ieee80211_rssadapt_sysctl_setup(struct sysctllog **);
+
+void ieee80211_init(void);
+#define IEEE80211_CRYPTO_SETUP(name) \
+ static void name(void); \
+ __link_set_add_text(ieee80211_funcs, name); \
+ static void name(void)
+#endif
+
+#endif /* !_NET80211_IEEE80211_NETBSD_H_ */
--- /dev/null
+# $NetBSD: Makefile,v 1.2 2002/11/26 23:30:32 lukem Exp $
+
+INCSDIR= /usr/include/netatalk
+
+INCS= at.h ddp_var.h
+
+.include <bsd.kinc.mk>
--- /dev/null
+/* $NetBSD: at.h,v 1.8 2014/12/02 19:33:44 christos Exp $ */
+
+/*
+ * Copyright (c) 1990,1991 Regents of The University of Michigan.
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation, and that the name of The University
+ * of Michigan not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. This software is supplied as is without expressed or
+ * implied warranties of any kind.
+ *
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ *
+ * Research Systems Unix Group
+ * The University of Michigan
+ * c/o Wesley Craig
+ * 535 W. William Street
+ * Ann Arbor, Michigan
+ * +1-313-764-2278
+ * netatalk@umich.edu
+ */
+
+#ifndef _NETATALK_AT_H_
+#define _NETATALK_AT_H_
+
+#include <sys/ansi.h>
+
+#ifndef sa_family_t
+typedef __sa_family_t sa_family_t;
+#define sa_family_t __sa_family_t
+#endif
+
+/*
+ * Supported protocols
+ */
+#define ATPROTO_DDP 0
+#define ATPROTO_AARP 254
+
+#define DDP_MAXSZ 587
+
+/*
+ * If ATPORT_FIRST <= Port < ATPORT_RESERVED,
+ * Port was created by a privileged process.
+ * If ATPORT_RESERVED <= Port < ATPORT_LAST,
+ * Port was not necessarily created by a
+ * privileged process.
+ */
+#define ATPORT_FIRST 1
+#define ATPORT_RESERVED 128
+#define ATPORT_LAST 255
+
+/*
+ * AppleTalk address.
+ */
+struct at_addr {
+ uint16_t s_net;
+ uint8_t s_node;
+};
+
+#define ATADDR_ANYNET (uint16_t)0x0000
+#define ATADDR_ANYNODE (uint8_t)0x00
+#define ATADDR_ANYPORT (uint8_t)0x00
+#define ATADDR_BCAST (uint8_t)0xff /* There is no BCAST for NET */
+
+struct netrange {
+ uint8_t nr_phase;
+ uint16_t nr_firstnet;
+ uint16_t nr_lastnet;
+};
+
+/*
+ * Socket address, AppleTalk style. We keep magic information in the
+ * zero bytes. There are three types, NONE, CONFIG which has the phase
+ * and a net range, and IFACE which has the network address of an
+ * interface. IFACE may be filled in by the client, and is filled in
+ * by the kernel.
+ */
+struct sockaddr_at {
+ uint8_t sat_len;
+ sa_family_t sat_family;
+ uint8_t sat_port;
+ struct at_addr sat_addr;
+ union {
+ struct netrange r_netrange;
+ char r_zero[8]; /* Hide a struct netrange in
+ * here */
+ } sat_range;
+};
+
+#define sat_zero sat_range.r_zero
+
+#ifdef _KERNEL
+#include <sys/protosw.h>
+
+extern struct domain atalkdomain;
+extern const struct protosw atalksw[];
+#endif
+
+#if defined(_KERNEL) || defined(_TEST)
+#define ATALK_ADDRSTRLEN 10
+
+extern struct domain atalkdomain;
+int at_print(char *, size_t, const struct at_addr *);
+int sat_print(char *, size_t, const void *);
+#endif
+
+#endif /* !_NETATALK_AT_H_ */
--- /dev/null
+/* $NetBSD: ddp_var.h,v 1.4 2008/04/23 15:17:42 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1990,1994 Regents of The University of Michigan.
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation, and that the name of The University
+ * of Michigan not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. This software is supplied as is without expressed or
+ * implied warranties of any kind.
+ *
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ *
+ * Research Systems Unix Group
+ * The University of Michigan
+ * c/o Wesley Craig
+ * 535 W. William Street
+ * Ann Arbor, Michigan
+ * +1-313-764-2278
+ * netatalk@umich.edu
+ */
+
+#ifndef _NETATALK_DDP_VAR_H_
+#define _NETATALK_DDP_VAR_H_
+
+struct ddpcb {
+ struct sockaddr_at ddp_fsat, ddp_lsat;
+ struct route ddp_route;
+ struct socket *ddp_socket;
+ struct ddpcb *ddp_prev, *ddp_next;
+ struct ddpcb *ddp_pprev, *ddp_pnext;
+};
+
+#define sotoddpcb(so) ((struct ddpcb *)(so)->so_pcb)
+
+#define DDP_STAT_SHORT 0 /* short header packets received */
+#define DDP_STAT_LONG 1 /* long header packets received */
+#define DDP_STAT_NOSUM 2 /* no checksum */
+#define DDP_STAT_BADSUM 3 /* bad checksum */
+#define DDP_STAT_TOOSHORT 4 /* packet too short */
+#define DDP_STAT_TOOSMALL 5 /* not enough data */
+#define DDP_STAT_FORWARD 6 /* packets forwarded */
+#define DDP_STAT_ENCAP 7 /* packets encapsulated */
+#define DDP_STAT_CANTFORWARD 8 /* packets rcvd for unreachable net */
+#define DDP_STAT_NOSOCKSPACE 9 /* no space in sockbuf for packet */
+
+#define DDP_NSTATS 10
+
+#ifdef _KERNEL
+extern struct ddpcb *ddp_ports[];
+extern struct ddpcb *ddpcb;
+#endif
+
+#endif /* !_NETATALK_DDP_VAR_H_ */
INCSDIR= /usr/include/netinet
-INCS= \
- in.h \
+INCS= icmp6.h icmp_var.h if_ether.h if_inarp.h igmp.h \
+ igmp_var.h in.h in_pcb.h in_pcb_hdr.h \
in_systm.h \
- ip.h \
- ip_icmp.h ip_var.h \
- tcp.h \
- udp.h udp_var.h \
-
+ in_var.h ip.h ip_carp.h ip6.h \
+ ip_icmp.h ip_mroute.h ip_var.h pim_var.h \
+ tcp.h tcp_debug.h tcp_fsm.h tcp_seq.h tcp_timer.h tcp_var.h \
+ tcpip.h udp.h udp_var.h \
+ tcp_vtw.h
.if !defined(__MINIX)
# ipfilter headers
--- /dev/null
+/* $NetBSD: icmp6.h,v 1.47 2013/07/01 12:43:15 christos Exp $ */
+/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
+
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_ICMP6_H_
+#define _NETINET_ICMP6_H_
+
+#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
+ - sizeof(struct icmp6_hdr) */
+
+struct icmp6_hdr {
+ u_int8_t icmp6_type; /* type field */
+ u_int8_t icmp6_code; /* code field */
+ u_int16_t icmp6_cksum; /* checksum field */
+ union {
+ u_int32_t icmp6_un_data32[1]; /* type-specific field */
+ u_int16_t icmp6_un_data16[2]; /* type-specific field */
+ u_int8_t icmp6_un_data8[4]; /* type-specific field */
+ } icmp6_dataun;
+} __packed;
+
+#define icmp6_data32 icmp6_dataun.icmp6_un_data32
+#define icmp6_data16 icmp6_dataun.icmp6_un_data16
+#define icmp6_data8 icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr icmp6_data32[0] /* parameter prob */
+#define icmp6_mtu icmp6_data32[0] /* packet too big */
+#define icmp6_id icmp6_data16[0] /* echo request/reply */
+#define icmp6_seq icmp6_data16[1] /* echo request/reply */
+#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
+
+#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
+#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
+#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST 128 /* echo service */
+#define ICMP6_ECHO_REPLY 129 /* echo reply */
+#define MLD_LISTENER_QUERY 130 /* multicast listener query */
+#define MLD_LISTENER_REPORT 131 /* multicast listener report */
+#define MLD_LISTENER_DONE 132 /* multicast listener done */
+#define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */
+
+/* RFC2292 decls */
+#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
+#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
+#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
+#define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
+#define MLD6_LISTENER_DONE MLD_LISTENER_DONE
+#endif
+
+#define ND_ROUTER_SOLICIT 133 /* router solicitation */
+#define ND_ROUTER_ADVERT 134 /* router advertisement */
+#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
+#define ND_REDIRECT 137 /* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
+
+#define ICMP6_WRUREQUEST 139 /* who are you request */
+#define ICMP6_WRUREPLY 140 /* who are you reply */
+#define ICMP6_FQDN_QUERY 139 /* FQDN query */
+#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
+#define ICMP6_NI_QUERY 139 /* node information request */
+#define ICMP6_NI_REPLY 140 /* node information reply */
+#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */
+
+/* The definitions below are experimental. TBA */
+#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
+#define MLD_MTRACE 201 /* mtrace messages */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_MTRACE_RESP MLD_MTRACE_RESP
+#define MLD6_MTRACE MLD_MTRACE
+#endif
+
+#define ICMP6_MAXTYPE 201
+
+#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
+#define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */
+#define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */
+#define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
+#define ICMP6_NI_REFUSED 1 /* node information request is refused */
+#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld_hdr {
+ struct icmp6_hdr mld_icmp6_hdr;
+ struct in6_addr mld_addr; /* multicast address */
+} __packed;
+
+/* definitions to provide backward compatibility to old KAME applications */
+#ifndef _KERNEL
+#define mld6_hdr mld_hdr
+#define mld6_type mld_type
+#define mld6_code mld_code
+#define mld6_cksum mld_cksum
+#define mld6_maxdelay mld_maxdelay
+#define mld6_reserved mld_reserved
+#define mld6_addr mld_addr
+#endif
+
+/* shortcut macro definitions */
+#define mld_type mld_icmp6_hdr.icmp6_type
+#define mld_code mld_icmp6_hdr.icmp6_code
+#define mld_cksum mld_icmp6_hdr.icmp6_cksum
+#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
+#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
+
+#define MLD_MINLEN 24
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit { /* router solicitation */
+ struct icmp6_hdr nd_rs_hdr;
+ /* could be followed by options */
+} __packed;
+
+#define nd_rs_type nd_rs_hdr.icmp6_type
+#define nd_rs_code nd_rs_hdr.icmp6_code
+#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert { /* router advertisement */
+ struct icmp6_hdr nd_ra_hdr;
+ u_int32_t nd_ra_reachable; /* reachable time */
+ u_int32_t nd_ra_retransmit; /* retransmit timer */
+ /* could be followed by options */
+} __packed;
+
+#define nd_ra_type nd_ra_hdr.icmp6_type
+#define nd_ra_code nd_ra_hdr.icmp6_code
+#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED 0x80
+#define ND_RA_FLAG_OTHER 0x40
+#define ND_RA_FLAG_HOME_AGENT 0x20
+
+/*
+ * Router preference values based on RFC4191.
+ */
+#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
+
+#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
+#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
+#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
+#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
+
+#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit { /* neighbor solicitation */
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target; /*target address */
+ /* could be followed by options */
+} __packed;
+
+#define nd_ns_type nd_ns_hdr.icmp6_type
+#define nd_ns_code nd_ns_hdr.icmp6_code
+#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert { /* neighbor advertisement */
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target; /* target address */
+ /* could be followed by options */
+} __packed;
+
+#define nd_na_type nd_na_hdr.icmp6_type
+#define nd_na_code nd_na_hdr.icmp6_code
+#define nd_na_cksum nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
+#if BYTE_ORDER == BIG_ENDIAN
+#define ND_NA_FLAG_ROUTER 0x80000000
+#define ND_NA_FLAG_SOLICITED 0x40000000
+#define ND_NA_FLAG_OVERRIDE 0x20000000
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define ND_NA_FLAG_ROUTER 0x80
+#define ND_NA_FLAG_SOLICITED 0x40
+#define ND_NA_FLAG_OVERRIDE 0x20
+#endif
+#endif
+
+struct nd_redirect { /* redirect */
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target; /* target address */
+ struct in6_addr nd_rd_dst; /* destination address */
+ /* could be followed by options */
+} __packed;
+
+#define nd_rd_type nd_rd_hdr.icmp6_type
+#define nd_rd_code nd_rd_hdr.icmp6_code
+#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr { /* Neighbor discovery option header */
+ u_int8_t nd_opt_type;
+ u_int8_t nd_opt_len;
+ /* followed by option specific data*/
+} __packed;
+
+#define ND_OPT_SOURCE_LINKADDR 1
+#define ND_OPT_TARGET_LINKADDR 2
+#define ND_OPT_PREFIX_INFORMATION 3
+#define ND_OPT_REDIRECTED_HEADER 4
+#define ND_OPT_MTU 5
+#define ND_OPT_ADVINTERVAL 7
+#define ND_OPT_HOMEAGENT_INFO 8
+#define ND_OPT_SOURCE_ADDRLIST 9
+#define ND_OPT_TARGET_ADDRLIST 10
+#define ND_OPT_MAP 23 /* RFC 5380 */
+#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */
+#define ND_OPT_RDNSS 25 /* RFC 6016 */
+#define ND_OPT_DNSSL 31 /* RFC 6016 */
+
+struct nd_opt_route_info { /* route info */
+ u_int8_t nd_opt_rti_type;
+ u_int8_t nd_opt_rti_len;
+ u_int8_t nd_opt_rti_prefixlen;
+ u_int8_t nd_opt_rti_flags;
+ u_int32_t nd_opt_rti_lifetime;
+ /* prefix follows */
+};
+
+struct nd_opt_prefix_info { /* prefix information */
+ u_int8_t nd_opt_pi_type;
+ u_int8_t nd_opt_pi_len;
+ u_int8_t nd_opt_pi_prefix_len;
+ u_int8_t nd_opt_pi_flags_reserved;
+ u_int32_t nd_opt_pi_valid_time;
+ u_int32_t nd_opt_pi_preferred_time;
+ u_int32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
+} __packed;
+
+#define ND_OPT_PI_FLAG_ONLINK 0x80
+#define ND_OPT_PI_FLAG_AUTO 0x40
+
+struct nd_opt_rd_hdr { /* redirected header */
+ u_int8_t nd_opt_rh_type;
+ u_int8_t nd_opt_rh_len;
+ u_int16_t nd_opt_rh_reserved1;
+ u_int32_t nd_opt_rh_reserved2;
+ /* followed by IP header and data */
+} __packed;
+
+struct nd_opt_mtu { /* MTU option */
+ u_int8_t nd_opt_mtu_type;
+ u_int8_t nd_opt_mtu_len;
+ u_int16_t nd_opt_mtu_reserved;
+ u_int32_t nd_opt_mtu_mtu;
+} __packed;
+
+struct nd_opt_rdnss { /* RDNSS option RFC 6106 */
+ u_int8_t nd_opt_rdnss_type;
+ u_int8_t nd_opt_rdnss_len;
+ u_int16_t nd_opt_rdnss_reserved;
+ u_int32_t nd_opt_rdnss_lifetime;
+ /* followed by list of IP prefixes */
+} __packed;
+
+struct nd_opt_dnssl { /* DNSSL option RFC 6106 */
+ u_int8_t nd_opt_dnssl_type;
+ u_int8_t nd_opt_dnssl_len;
+ u_int16_t nd_opt_dnssl_reserved;
+ u_int32_t nd_opt_dnssl_lifetime;
+ /* followed by list of IP prefixes */
+} __packed;
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+ struct icmp6_hdr icmp6_nl_hdr;
+ u_int8_t icmp6_nl_nonce[8];
+ int32_t icmp6_nl_ttl;
+#if 0
+ u_int8_t icmp6_nl_len;
+ u_int8_t icmp6_nl_name[3];
+#endif
+ /* could be followed by options */
+} __packed;
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+ struct icmp6_hdr icmp6_ni_hdr;
+ u_int8_t icmp6_ni_nonce[8];
+ /* could be followed by reply data */
+} __packed;
+
+#define ni_type icmp6_ni_hdr.icmp6_type
+#define ni_code icmp6_ni_hdr.icmp6_code
+#define ni_cksum icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP 0 /* NOOP */
+#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME 2 /* DNS Name */
+#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define NI_SUPTYPE_FLAG_COMPRESS 0x1
+#define NI_FQDN_FLAG_VALIDTTL 0x1
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
+#define NI_FQDN_FLAG_VALIDTTL 0x0100
+#endif
+
+#ifdef NAME_LOOKUPS_04
+#if BYTE_ORDER == BIG_ENDIAN
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x1
+#define NI_NODEADDR_FLAG_SITELOCAL 0x2
+#define NI_NODEADDR_FLAG_GLOBAL 0x4
+#define NI_NODEADDR_FLAG_ALL 0x8
+#define NI_NODEADDR_FLAG_TRUNCATE 0x10
+#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
+#define NI_NODEADDR_FLAG_SITELOCAL 0x0200
+#define NI_NODEADDR_FLAG_GLOBAL 0x0400
+#define NI_NODEADDR_FLAG_ALL 0x0800
+#define NI_NODEADDR_FLAG_TRUNCATE 0x1000
+#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
+#endif
+#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
+#if BYTE_ORDER == BIG_ENDIAN
+#define NI_NODEADDR_FLAG_TRUNCATE 0x1
+#define NI_NODEADDR_FLAG_ALL 0x2
+#define NI_NODEADDR_FLAG_COMPAT 0x4
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x8
+#define NI_NODEADDR_FLAG_SITELOCAL 0x10
+#define NI_NODEADDR_FLAG_GLOBAL 0x20
+#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define NI_NODEADDR_FLAG_TRUNCATE 0x0100
+#define NI_NODEADDR_FLAG_ALL 0x0200
+#define NI_NODEADDR_FLAG_COMPAT 0x0400
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
+#define NI_NODEADDR_FLAG_SITELOCAL 0x1000
+#define NI_NODEADDR_FLAG_GLOBAL 0x2000
+#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
+#endif
+#endif
+
+struct ni_reply_fqdn {
+ u_int32_t ni_fqdn_ttl; /* TTL */
+ u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+ u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
+} __packed;
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum { /* router renumbering header */
+ struct icmp6_hdr rr_hdr;
+ u_int8_t rr_segnum;
+ u_int8_t rr_flags;
+ u_int16_t rr_maxdelay;
+ u_int32_t rr_reserved;
+} __packed;
+
+#define ICMP6_RR_FLAGS_TEST 0x80
+#define ICMP6_RR_FLAGS_REQRESULT 0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
+#define ICMP6_RR_FLAGS_SPECSITE 0x10
+#define ICMP6_RR_FLAGS_PREVDONE 0x08
+
+#define rr_type rr_hdr.icmp6_type
+#define rr_code rr_hdr.icmp6_code
+#define rr_cksum rr_hdr.icmp6_cksum
+#define rr_seqnum rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match { /* match prefix part */
+ u_int8_t rpm_code;
+ u_int8_t rpm_len;
+ u_int8_t rpm_ordinal;
+ u_int8_t rpm_matchlen;
+ u_int8_t rpm_minlen;
+ u_int8_t rpm_maxlen;
+ u_int16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
+} __packed;
+
+#define RPM_PCO_ADD 1
+#define RPM_PCO_CHANGE 2
+#define RPM_PCO_SETGLOBAL 3
+#define RPM_PCO_MAX 4
+
+struct rr_pco_use { /* use prefix part */
+ u_int8_t rpu_uselen;
+ u_int8_t rpu_keeplen;
+ u_int8_t rpu_ramask;
+ u_int8_t rpu_raflags;
+ u_int32_t rpu_vltime;
+ u_int32_t rpu_pltime;
+ u_int32_t rpu_flags;
+ struct in6_addr rpu_prefix;
+} __packed;
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
+#endif
+
+struct rr_result { /* router renumbering result message */
+ u_int16_t rrr_flags;
+ u_int8_t rrr_ordinal;
+ u_int8_t rrr_matchedlen;
+ u_int32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
+} __packed;
+#if BYTE_ORDER == BIG_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
+#endif
+
+/*
+ * icmp6 filter structures.
+ */
+
+struct icmp6_filter {
+ u_int32_t icmp6_filt[8];
+};
+
+#define ICMP6_FILTER_SETPASSALL(filterp) \
+ (void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
+#define ICMP6_FILTER_SETBLOCKALL(filterp) \
+ (void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
+#define ICMP6_FILTER_SETPASS(type, filterp) \
+ (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
+#define ICMP6_FILTER_SETBLOCK(type, filterp) \
+ (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
+#define ICMP6_FILTER_WILLPASS(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
+#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
+
+/*
+ * Variables related to this implementation
+ * of the internet control message protocol version 6.
+ */
+
+/*
+ * IPv6 ICMP statistics.
+ * Each counter is an unsigned 64-bit value.
+ */
+#define ICMP6_STAT_ERROR 0 /* # of calls to icmp6_error */
+#define ICMP6_STAT_CANTERROR 1 /* no error (old was icmp) */
+#define ICMP6_STAT_TOOFREQ 2 /* no error (rate limitation) */
+#define ICMP6_STAT_OUTHIST 3 /* # of output messages */
+ /* space for 256 counters */
+#define ICMP6_STAT_BADCODE 259 /* icmp6_code out of range */
+#define ICMP6_STAT_TOOSHORT 260 /* packet < sizeof(struct icmp6_hdr) */
+#define ICMP6_STAT_CHECKSUM 261 /* bad checksum */
+#define ICMP6_STAT_BADLEN 262 /* calculated bound mismatch */
+ /*
+ * number of responses; this member is inherited from the netinet code,
+ * but for netinet6 code, it is already available in outhist[].
+ */
+#define ICMP6_STAT_REFLECT 263
+#define ICMP6_STAT_INHIST 264 /* # of input messages */
+ /* space for 256 counters */
+#define ICMP6_STAT_ND_TOOMANYOPT 520 /* too many ND options */
+#define ICMP6_STAT_OUTERRHIST 521
+ /* space for 13 counters */
+#define ICMP6_STAT_PMTUCHG 534 /* path MTU changes */
+#define ICMP6_STAT_ND_BADOPT 535 /* bad ND options */
+#define ICMP6_STAT_BADNS 536 /* bad neighbor solicititation */
+#define ICMP6_STAT_BADNA 537 /* bad neighbor advertisement */
+#define ICMP6_STAT_BADRS 538 /* bad router solicitiation */
+#define ICMP6_STAT_BADRA 539 /* bad router advertisement */
+#define ICMP6_STAT_BADREDIRECT 540 /* bad redirect message */
+#define ICMP6_STAT_DROPPED_RAROUTE 541 /* discarded routes from router advertisement */
+
+#define ICMP6_NSTATS 542
+
+#define ICMP6_ERRSTAT_DST_UNREACH_NOROUTE 0
+#define ICMP6_ERRSTAT_DST_UNREACH_ADMIN 1
+#define ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE 2
+#define ICMP6_ERRSTAT_DST_UNREACH_ADDR 3
+#define ICMP6_ERRSTAT_DST_UNREACH_NOPORT 4
+#define ICMP6_ERRSTAT_PACKET_TOO_BIG 5
+#define ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT 6
+#define ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY 7
+#define ICMP6_ERRSTAT_PARAMPROB_HEADER 8
+#define ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER 9
+#define ICMP6_ERRSTAT_PARAMPROB_OPTION 10
+#define ICMP6_ERRSTAT_REDIRECT 11
+#define ICMP6_ERRSTAT_UNKNOWN 12
+
+/*
+ * Names for ICMP sysctl objects
+ */
+#define ICMPV6CTL_STATS 1
+#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
+#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
+#if 0 /*obsoleted*/
+#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
+#endif
+#define ICMPV6CTL_ND6_PRUNE 6
+#define ICMPV6CTL_ND6_DELAY 8
+#define ICMPV6CTL_ND6_UMAXTRIES 9
+#define ICMPV6CTL_ND6_MMAXTRIES 10
+#define ICMPV6CTL_ND6_USELOOPBACK 11
+/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
+#define ICMPV6CTL_NODEINFO 13
+#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
+#define ICMPV6CTL_ND6_MAXNUDHINT 15
+#define ICMPV6CTL_MTUDISC_HIWAT 16
+#define ICMPV6CTL_MTUDISC_LOWAT 17
+#define ICMPV6CTL_ND6_DEBUG 18
+#define ICMPV6CTL_ND6_DRLIST 19
+#define ICMPV6CTL_ND6_PRLIST 20
+#define ICMPV6CTL_ND6_MAXQLEN 24
+#define ICMPV6CTL_MAXID 25
+
+#define ICMPV6CTL_NAMES { \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "rediraccept", CTLTYPE_INT }, \
+ { "redirtimeout", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "nd6_prune", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "nd6_delay", CTLTYPE_INT }, \
+ { "nd6_umaxtries", CTLTYPE_INT }, \
+ { "nd6_mmaxtries", CTLTYPE_INT }, \
+ { "nd6_useloopback", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "nodeinfo", CTLTYPE_INT }, \
+ { "errppslimit", CTLTYPE_INT }, \
+ { "nd6_maxnudhint", CTLTYPE_INT }, \
+ { "mtudisc_hiwat", CTLTYPE_INT }, \
+ { "mtudisc_lowat", CTLTYPE_INT }, \
+ { "nd6_debug", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "nd6_maxqueuelen", CTLTYPE_INT }, \
+}
+
+#ifdef _KERNEL
+struct rtentry;
+struct rttimer;
+struct in6_multi;
+
+void icmp6_init(void);
+void icmp6_paramerror(struct mbuf *, int);
+void icmp6_error(struct mbuf *, int, int, int);
+void icmp6_error2(struct mbuf *, int, int, int, struct ifnet *);
+int icmp6_input(struct mbuf **, int *, int);
+void icmp6_fasttimo(void);
+void icmp6_reflect(struct mbuf *, size_t);
+void icmp6_prepare(struct mbuf *);
+void icmp6_redirect_input(struct mbuf *, int);
+void icmp6_redirect_output(struct mbuf *, struct rtentry *);
+int icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
+
+void icmp6_statinc(u_int);
+
+struct ip6ctlparam;
+void icmp6_mtudisc_update(struct ip6ctlparam *, int);
+void icmp6_mtudisc_callback_register(void (*)(struct in6_addr *));
+
+/* XXX: is this the right place for these macros? */
+#define icmp6_ifstat_inc(ifp, tag) \
+do { \
+ if (ifp) \
+ ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
+} while (/*CONSTCOND*/ 0)
+
+#define icmp6_ifoutstat_inc(ifp, type, code) \
+do { \
+ icmp6_ifstat_inc(ifp, ifs6_out_msg); \
+ switch(type) { \
+ case ICMP6_DST_UNREACH: \
+ icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
+ if (code == ICMP6_DST_UNREACH_ADMIN) \
+ icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
+ break; \
+ case ICMP6_PACKET_TOO_BIG: \
+ icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
+ break; \
+ case ICMP6_TIME_EXCEEDED: \
+ icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
+ break; \
+ case ICMP6_PARAM_PROB: \
+ icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
+ break; \
+ case ICMP6_ECHO_REQUEST: \
+ icmp6_ifstat_inc(ifp, ifs6_out_echo); \
+ break; \
+ case ICMP6_ECHO_REPLY: \
+ icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
+ break; \
+ case MLD_LISTENER_QUERY: \
+ icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
+ break; \
+ case MLD_LISTENER_REPORT: \
+ icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
+ break; \
+ case MLD_LISTENER_DONE: \
+ icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
+ break; \
+ case ND_ROUTER_SOLICIT: \
+ icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
+ break; \
+ case ND_ROUTER_ADVERT: \
+ icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
+ break; \
+ case ND_NEIGHBOR_SOLICIT: \
+ icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
+ break; \
+ case ND_NEIGHBOR_ADVERT: \
+ icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
+ break; \
+ case ND_REDIRECT: \
+ icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
+ break; \
+ } \
+} while (/*CONSTCOND*/ 0)
+
+extern int icmp6_rediraccept; /* accept/process redirects */
+extern int icmp6_redirtimeout; /* cache time for redirect routes */
+#endif /* _KERNEL */
+
+#ifdef ICMP6_STRINGS
+/* Info: http://www.iana.org/assignments/icmpv6-parameters */
+
+static const char * const icmp6_type_err[] = {
+ "reserved0", "unreach", "packet_too_big", "timxceed", "paramprob",
+ NULL
+};
+
+static const char * const icmp6_type_info[] = {
+ "echo", "echoreply",
+ "mcastlistenq", "mcastlistenrep", "mcastlistendone",
+ "rtsol", "rtadv", "neighsol", "neighadv", "redirect",
+ "routerrenum", "nodeinfoq", "nodeinfor", "invneighsol", "invneighrep",
+ "mcastlistenrep2", "haad_req", "haad_rep",
+ "mobile_psol", "mobile_padv", "cga_sol", "cga_adv",
+ "experimental150", "mcast_rtadv", "mcast_rtsol", "mcast_rtterm",
+ "fmipv6_msg", "rpl_control", NULL
+};
+
+static const char * const icmp6_code_none[] = { "none", NULL };
+
+static const char * const icmp6_code_unreach[] = {
+ "noroute", "admin", "beyondscope", "addr", "port",
+ "srcaddr_policy", "reject_route", "source_route_err", NULL
+};
+
+static const char * const icmp6_code_timxceed[] = {
+ "intrans", "reass", NULL
+};
+
+static const char * const icmp6_code_paramprob[] = {
+ "hdr_field", "nxthdr_type", "option", NULL
+};
+
+/* not all informational icmps that have codes have a names array */
+#endif
+
+#endif /* !_NETINET_ICMP6_H_ */
--- /dev/null
+/* $NetBSD: icmp_var.h,v 1.30 2015/02/18 17:00:15 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_ICMP_VAR_H_
+#define _NETINET_ICMP_VAR_H_
+
+/*
+ * Variables related to this implementation
+ * of the internet control message protocol.
+ */
+
+/*
+ * ICMP stastistics.
+ * Each counter is an unsigned 64-bit value.
+ */
+#define ICMP_STAT_ERROR 0 /* # of calls to icmp_error */
+#define ICMP_STAT_OLDSHORT 1 /* no error (old ip too short) */
+#define ICMP_STAT_OLDICMP 2 /* no error (old was icmp) */
+#define ICMP_STAT_BADCODE 3 /* icmp_code out of range */
+#define ICMP_STAT_TOOSHORT 4 /* packet < ICMP_MINLEN */
+#define ICMP_STAT_CHECKSUM 5 /* bad checksum */
+#define ICMP_STAT_BADLEN 6 /* calculated bound mismatch */
+#define ICMP_STAT_REFLECT 7 /* number of responses */
+#define ICMP_STAT_PMTUCHG 8 /* path MTU changes */
+#define ICMP_STAT_BMCASTECHO 9 /* b/mcast echo requests dropped */
+#define ICMP_STAT_BMCASTTSTAMP 10 /* b/mcast tstamp requests dropped */
+#define ICMP_STAT_LAST 16 /* Allow for 5 spare ones */
+#define ICMP_STAT_OUTHIST ICMP_STAT_LAST
+#define ICMP_STAT_INHIST (ICMP_STAT_LAST + ICMP_NTYPES)
+#define ICMP_NSTATS (ICMP_STAT_LAST + 2 * ICMP_NTYPES)
+
+/*
+ * Names for ICMP sysctl objects
+ */
+#define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */
+#if 0 /*obsoleted*/
+#define ICMPCTL_ERRRATELIMIT 2 /* error rate limit */
+#endif
+#define ICMPCTL_RETURNDATABYTES 3 /* # of bytes to include in errors */
+#define ICMPCTL_ERRPPSLIMIT 4 /* ICMP error pps limitation */
+#define ICMPCTL_REDIRACCEPT 5 /* Accept redirects from routers */
+#define ICMPCTL_REDIRTIMEOUT 6 /* Remove routes added via redirects */
+#define ICMPCTL_STATS 7 /* ICMP statistics */
+#define ICMPCTL_BMCASTECHO 8 /* allow broad/mult-cast echo */
+#define ICMPCTL_MAXID 9
+
+#define ICMPCTL_NAMES { \
+ { 0, 0 }, \
+ { "maskrepl", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "returndatabytes", CTLTYPE_INT }, \
+ { "errppslimit", CTLTYPE_INT }, \
+ { "rediraccept", CTLTYPE_INT }, \
+ { "redirtimeout", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
+ { "bmcastecho", CTLTYPE_INT }, \
+}
+
+#ifdef _KERNEL
+
+void icmp_statinc(u_int stat);
+
+#endif /* _KERNEL_ */
+
+#endif /* !_NETINET_ICMP_VAR_H_ */
--- /dev/null
+/* $NetBSD: if_ether.h,v 1.34 2007/12/25 18:33:46 perry Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
+ */
+
+#ifndef _NETINET_IF_ETHER_H_
+#define _NETINET_IF_ETHER_H_
+
+
+#ifdef _KERNEL
+#error You should NOT be doing this.
+/*
+ * XXX This file is for compatibility to externally maintained packages
+ * ONLY, or to help porting them if the other way round is not possible.
+ * Kernel drivers should be properly ported.
+ */
+#endif
+
+
+#ifndef _netinet_if_ether_compat_h_
+#define _netinet_if_ether_compat_h_
+
+/* pull in Ethernet-specific definitions and packet structures */
+
+#include <net/if_ether.h>
+
+/* pull in ARP-specific definitions and packet structures */
+
+#include <net/if_arp.h>
+
+/* pull in ARP-over-Ethernet-specific definitions and packet structures */
+#include <netinet/if_inarp.h>
+
+/* ... and define some more which we don't need anymore: */
+
+/*
+ * Ethernet Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. Structure below is not
+ * used by our kernel!!! Only for userland programs which are externally
+ * maintained and need it.
+ */
+
+struct ether_arp {
+ struct arphdr ea_hdr; /* fixed-size header */
+ u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
+ u_int8_t arp_spa[4]; /* sender protocol address */
+ u_int8_t arp_tha[ETHER_ADDR_LEN]; /* target hardware address */
+ u_int8_t arp_tpa[4]; /* target protocol address */
+} __packed;
+#define arp_hrd ea_hdr.ar_hrd
+#define arp_pro ea_hdr.ar_pro
+#define arp_hln ea_hdr.ar_hln
+#define arp_pln ea_hdr.ar_pln
+#define arp_op ea_hdr.ar_op
+
+#endif /* _netinet_if_ether_compat_h_ */
+
+#endif /* !_NETINET_IF_ETHER_H_ */
--- /dev/null
+/* $NetBSD: if_inarp.h,v 1.47 2015/05/21 09:26:18 ozaki-r Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)if_ether.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IF_INARP_H_
+#define _NETINET_IF_INARP_H_
+
+#include <sys/queue.h> /* for LIST_ENTRY */
+#include <netinet/in.h> /* for struct in_addr */
+
+struct llinfo_arp {
+ LIST_ENTRY(llinfo_arp) la_list;
+ struct rtentry *la_rt;
+ struct mbuf *la_hold; /* last packet until resolved/timeout */
+ long la_asked; /* last time we QUERIED for this addr */
+};
+
+struct sockaddr_inarp {
+ u_int8_t sin_len;
+ u_int8_t sin_family;
+ u_int16_t sin_port;
+ struct in_addr sin_addr;
+ struct in_addr sin_srcaddr;
+ u_int16_t sin_tos;
+ u_int16_t sin_other;
+#define SIN_PROXY 1
+};
+
+#ifdef _KERNEL
+
+/* ARP timings from RFC5227 */
+#define PROBE_WAIT 1
+#define PROBE_NUM 3
+#define PROBE_MIN 1
+#define PROBE_MAX 2
+#define ANNOUNCE_WAIT 2
+#define ANNOUNCE_NUM 2
+#define ANNOUNCE_INTERVAL 2
+#define MAX_CONFLICTS 10
+#define RATE_LIMIT_INTERVAL 60
+#define DEFEND_INTERVAL 10
+
+#include <sys/malloc.h>
+MALLOC_DECLARE(M_IPARP);
+
+extern struct ifqueue arpintrq;
+void arp_ifinit(struct ifnet *, struct ifaddr *);
+void arp_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
+int arpresolve(struct ifnet *, struct rtentry *, struct mbuf *,
+ const struct sockaddr *, u_char *);
+void arpintr(void);
+void arprequest(struct ifnet *, const struct in_addr *, const struct in_addr *,
+ const u_int8_t *);
+void arp_drain(void);
+int arpioctl(u_long, void *);
+void arpwhohas(struct ifnet *, struct in_addr *);
+
+void revarpinput(struct mbuf *);
+int revarpwhoarewe(struct ifnet *, struct in_addr *, struct in_addr *);
+#endif
+
+#endif /* !_NETINET_IF_INARP_H_ */
--- /dev/null
+/* $NetBSD: igmp.h,v 1.12 2014/05/29 23:02:48 rmind Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Stephen Deering of Stanford University.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)igmp.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Copyright (c) 1988 Stephen Deering.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Stephen Deering of Stanford University.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)igmp.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IGMP_H_
+#define _NETINET_IGMP_H_
+
+/*
+ * Internet Group Management Protocol (IGMP) definitions.
+ *
+ * MULTICAST 1.3
+ */
+
+/*
+ * IGMP packet format.
+ */
+struct igmp {
+ uint8_t igmp_type; /* version & type of IGMP message */
+ uint8_t igmp_code; /* code for routing sub-messages */
+ uint16_t igmp_cksum; /* IP-style checksum */
+ struct in_addr igmp_group; /* group address being reported */
+} __packed; /* (zero for queries) */
+
+#define IGMP_MINLEN 8
+
+#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* membership query */
+#define IGMP_v1_HOST_MEMBERSHIP_REPORT 0x12 /* v1 membership report */
+#define IGMP_DVMRP 0x13 /* DVMRP routing message */
+#define IGMP_PIM 0x14 /* PIM routing message */
+#define IGMP_v2_HOST_MEMBERSHIP_REPORT 0x16 /* v2 membership report */
+#define IGMP_HOST_LEAVE_MESSAGE 0x17 /* leave-group message */
+#define IGMP_MTRACE_REPLY 0x1e /* traceroute reply */
+#define IGMP_MTRACE_QUERY 0x1f /* traceroute query */
+
+#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
+ /* query (in seconds) */
+
+#define IGMP_TIMER_SCALE 10 /* denominator for igmp_timer */
+
+/*
+ * States for the IGMP v2 state table.
+ */
+#define IGMP_DELAYING_MEMBER 1
+#define IGMP_IDLE_MEMBER 2
+#define IGMP_LAZY_MEMBER 3
+#define IGMP_SLEEPING_MEMBER 4
+#define IGMP_AWAKENING_MEMBER 5
+
+/*
+ * States for IGMP router version cache.
+ */
+#define IGMP_v1_ROUTER 1
+#define IGMP_v2_ROUTER 2
+
+/*
+ * Revert to v2 if we haven't heard from the router in this amount of time.
+ */
+#define IGMP_AGE_THRESHOLD 540
+
+#endif /* !_NETINET_IGMP_H_ */
--- /dev/null
+/* $NetBSD: igmp_var.h,v 1.24 2014/05/29 23:02:48 rmind Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Stephen Deering of Stanford University.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)igmp_var.h 8.1 (Berkeley) 7/19/93
+ */
+
+/*
+ * Copyright (c) 1988 Stephen Deering.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Stephen Deering of Stanford University.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)igmp_var.h 8.1 (Berkeley) 7/19/93
+ */
+
+#ifndef _NETINET_IGMP_VAR_H_
+#define _NETINET_IGMP_VAR_H_
+
+/*
+ * Internet Group Management Protocol (IGMP),
+ * implementation-specific definitions.
+ *
+ * Written by Steve Deering, Stanford, May 1988.
+ * Modified by Rosen Sharma, Stanford, Aug 1994.
+ * Modified by Bill Fenner, Xerox PARC, Feb 1995.
+ *
+ * MULTICAST 1.3
+ */
+
+#define IGMP_STAT_RCV_TOTAL 1 /* total IGMP messages received */
+#define IGMP_STAT_RCV_TOOSHORT 2 /* received with too few bytes */
+#define IGMP_STAT_RCV_BADSUM 3 /* received with bad checksum */
+#define IGMP_STAT_RCV_QUERIES 4 /* received membership queries */
+#define IGMP_STAT_RCV_BADQUERIES 5 /* received invalid queries */
+#define IGMP_STAT_RCV_REPORTS 6 /* received membership reports */
+#define IGMP_STAT_RCV_BADREPORTS 7 /* received invalid reports */
+#define IGMP_STAT_RCV_OURREPORTS 8 /* received reports for our groups */
+#define IGMP_STAT_SND_REPORTS 9 /* sent membership reports */
+
+#define IGMP_NSTATS 10
+
+#ifdef _KERNEL
+/*
+ * Macro to compute a random timer value between 1 and (IGMP_MAX_REPORTING_
+ * DELAY * countdown frequency). We assume that the routine random()
+ * is defined somewhere (and that it returns a positive number).
+ */
+#define IGMP_RANDOM_DELAY(X) (cprng_fast32() % (X) + 1)
+
+#ifdef __NO_STRICT_ALIGNMENT
+#define IGMP_HDR_ALIGNED_P(ig) 1
+#else
+#define IGMP_HDR_ALIGNED_P(ig) ((((vaddr_t) (ig)) & 3) == 0)
+#endif
+
+void igmp_init(void);
+void igmp_input(struct mbuf *, ...);
+int igmp_joingroup(struct in_multi *);
+void igmp_leavegroup(struct in_multi *);
+void igmp_fasttimo(void);
+void igmp_slowtimo(void);
+void igmp_purgeif(struct ifnet *);
+#endif /* _KERNEL */
+
+#endif /* !_NETINET_IGMP_VAR_H_ */
--- /dev/null
+/* $NetBSD: in_pcb.h,v 1.59 2015/05/24 15:43:45 rtr Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IN_PCB_H_
+#define _NETINET_IN_PCB_H_
+
+#include <sys/queue.h>
+#include <netinet/in_pcb_hdr.h>
+
+/*
+ * Common structure pcb for internet protocol implementation.
+ * Here are stored pointers to local and foreign host table
+ * entries, local and foreign socket numbers, and pointers
+ * up (to a socket structure) and down (to a protocol-specific)
+ * control block.
+ */
+struct inpcb {
+ struct inpcb_hdr inp_head;
+#define inp_hash inp_head.inph_hash
+#define inp_queue inp_head.inph_queue
+#define inp_af inp_head.inph_af
+#define inp_ppcb inp_head.inph_ppcb
+#define inp_state inp_head.inph_state
+#define inp_portalgo inp_head.inph_portalgo
+#define inp_socket inp_head.inph_socket
+#define inp_table inp_head.inph_table
+#define inp_sp inp_head.inph_sp
+ struct route inp_route; /* placeholder for routing entry */
+ u_int16_t inp_fport; /* foreign port */
+ u_int16_t inp_lport; /* local port */
+ int inp_flags; /* generic IP/datagram flags */
+ struct ip inp_ip; /* header prototype; should have more */
+ struct mbuf *inp_options; /* IP options */
+ struct ip_moptions *inp_moptions; /* IP multicast options */
+ int inp_errormtu; /* MTU of last xmit status = EMSGSIZE */
+ uint8_t inp_ip_minttl;
+ bool inp_bindportonsend;
+};
+
+#define inp_faddr inp_ip.ip_dst
+#define inp_laddr inp_ip.ip_src
+
+/* flags in inp_flags: */
+#define INP_RECVOPTS 0x0001 /* receive incoming IP options */
+#define INP_RECVRETOPTS 0x0002 /* receive IP options for reply */
+#define INP_RECVDSTADDR 0x0004 /* receive IP dst address */
+#define INP_HDRINCL 0x0008 /* user supplies entire IP header */
+#define INP_HIGHPORT 0x0010 /* (unused; FreeBSD compat) */
+#define INP_LOWPORT 0x0020 /* user wants "low" port binding */
+#define INP_ANONPORT 0x0040 /* port chosen for user */
+#define INP_RECVIF 0x0080 /* receive incoming interface */
+/* XXX should move to an UDP control block */
+#define INP_ESPINUDP 0x0100 /* ESP over UDP for NAT-T */
+#define INP_ESPINUDP_NON_IKE 0x0200 /* ESP over UDP for NAT-T */
+#define INP_ESPINUDP_ALL (INP_ESPINUDP|INP_ESPINUDP_NON_IKE)
+#define INP_NOHEADER 0x0400 /* Kernel removes IP header
+ * before feeding a packet
+ * to the raw socket user.
+ * The socket user will
+ * not supply an IP header.
+ * Cancels INP_HDRINCL.
+ */
+#define INP_RECVTTL 0x0800 /* receive incoming IP TTL */
+#define INP_PKTINFO 0x1000 /* receive dst packet info */
+#define INP_RECVPKTINFO 0x2000 /* receive dst packet info */
+#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
+ INP_RECVIF|INP_RECVTTL|INP_RECVPKTINFO|\
+ INP_PKTINFO)
+
+#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
+
+#ifdef _KERNEL
+void in_losing(struct inpcb *);
+int in_pcballoc(struct socket *, void *);
+int in_pcbbind(void *, struct sockaddr_in *, struct lwp *);
+int in_pcbconnect(void *, struct sockaddr_in *, struct lwp *);
+void in_pcbdetach(void *);
+void in_pcbdisconnect(void *);
+void in_pcbinit(struct inpcbtable *, int, int);
+struct inpcb *
+ in_pcblookup_port(struct inpcbtable *,
+ struct in_addr, u_int, int, struct vestigial_inpcb *);
+struct inpcb *
+ in_pcblookup_bind(struct inpcbtable *,
+ struct in_addr, u_int);
+struct inpcb *
+ in_pcblookup_connect(struct inpcbtable *,
+ struct in_addr, u_int, struct in_addr, u_int,
+ struct vestigial_inpcb *);
+int in_pcbnotify(struct inpcbtable *, struct in_addr, u_int,
+ struct in_addr, u_int, int, void (*)(struct inpcb *, int));
+void in_pcbnotifyall(struct inpcbtable *, struct in_addr, int,
+ void (*)(struct inpcb *, int));
+void in_pcbpurgeif0(struct inpcbtable *, struct ifnet *);
+void in_pcbpurgeif(struct inpcbtable *, struct ifnet *);
+void in_purgeifmcast(struct ip_moptions *, struct ifnet *);
+void in_pcbstate(struct inpcb *, int);
+void in_rtchange(struct inpcb *, int);
+void in_setpeeraddr(struct inpcb *, struct sockaddr_in *);
+void in_setsockaddr(struct inpcb *, struct sockaddr_in *);
+struct rtentry *
+ in_pcbrtentry(struct inpcb *);
+#endif
+
+#endif /* !_NETINET_IN_PCB_H_ */
--- /dev/null
+/* $NetBSD: in_pcb_hdr.h,v 1.11 2014/05/30 01:39:03 christos Exp $ */
+
+/*
+ * Copyright (C) 2003 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IN_PCB_HDR_H_
+#define _NETINET_IN_PCB_HDR_H_
+
+#include <sys/queue.h>
+
+struct inpcbpolicy;
+
+/*
+ * align it with inpcb and in6pcb!
+ */
+struct inpcb_hdr {
+ LIST_ENTRY(inpcb_hdr) inph_hash;
+ LIST_ENTRY(inpcb_hdr) inph_lhash;
+ TAILQ_ENTRY(inpcb_hdr) inph_queue;
+ int inph_af; /* address family - AF_INET */
+ void * inph_ppcb; /* pointer to per-protocol pcb */
+ int inph_state; /* bind/connect state */
+ int inph_portalgo;
+ struct socket *inph_socket; /* back pointer to socket */
+ struct inpcbtable *inph_table;
+ struct inpcbpolicy *inph_sp; /* security policy */
+};
+
+#define sotoinpcb_hdr(so) ((struct inpcb_hdr *)(so)->so_pcb)
+
+LIST_HEAD(inpcbhead, inpcb_hdr);
+
+struct vestigial_inpcb;
+
+/* Hooks for vestigial pcb entries.
+ * If vestigial entries exist for a table (TCP only)
+ * the vestigial pointer is set.
+ */
+typedef struct vestigial_hooks {
+ /* IPv4 hooks */
+ void *(*init_ports4)(struct in_addr, u_int, int);
+ int (*next_port4)(void *, struct vestigial_inpcb *);
+ int (*lookup4)(struct in_addr, uint16_t,
+ struct in_addr, uint16_t,
+ struct vestigial_inpcb *);
+ /* IPv6 hooks */
+ void *(*init_ports6)(const struct in6_addr*, u_int, int);
+ int (*next_port6)(void *, struct vestigial_inpcb *);
+ int (*lookup6)(const struct in6_addr *, uint16_t,
+ const struct in6_addr *, uint16_t,
+ struct vestigial_inpcb *);
+} vestigial_hooks_t;
+
+TAILQ_HEAD(inpcbqueue, inpcb_hdr);
+
+struct inpcbtable {
+ struct inpcbqueue inpt_queue;
+ struct inpcbhead *inpt_porthashtbl;
+ struct inpcbhead *inpt_bindhashtbl;
+ struct inpcbhead *inpt_connecthashtbl;
+ u_long inpt_porthash;
+ u_long inpt_bindhash;
+ u_long inpt_connecthash;
+ u_int16_t inpt_lastport;
+ u_int16_t inpt_lastlow;
+
+ vestigial_hooks_t *vestige;
+};
+#define inpt_lasthi inpt_lastport
+
+/* states in inp_state: */
+#define INP_ATTACHED 0
+#define INP_BOUND 1
+#define INP_CONNECTED 2
+
+#endif /* !_NETINET_IN_PCB_HDR_H_ */
--- /dev/null
+/* $NetBSD: in_var.h,v 1.74 2015/08/31 08:05:20 ozaki-r Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Public Access Networks Corporation ("Panix"). It was developed under
+ * contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)in_var.h 8.2 (Berkeley) 1/9/95
+ */
+
+#ifndef _NETINET_IN_VAR_H_
+#define _NETINET_IN_VAR_H_
+
+#include <sys/queue.h>
+
+#define IN_IFF_TENTATIVE 0x01 /* tentative address */
+#define IN_IFF_DUPLICATED 0x02 /* DAD detected duplicate */
+#define IN_IFF_DETACHED 0x04 /* may be detached from the link */
+#define IN_IFF_TRYTENTATIVE 0x08 /* intent to try DAD */
+
+/* do not input/output */
+#define IN_IFF_NOTREADY \
+ (IN_IFF_TRYTENTATIVE | IN_IFF_TENTATIVE | IN_IFF_DUPLICATED)
+
+/*
+ * Interface address, Internet version. One of these structures
+ * is allocated for each interface with an Internet address.
+ * The ifaddr structure contains the protocol-independent part
+ * of the structure and is assumed to be first.
+ */
+struct in_ifaddr {
+ struct ifaddr ia_ifa; /* protocol-independent info */
+#define ia_ifp ia_ifa.ifa_ifp
+#define ia_flags ia_ifa.ifa_flags
+ /* ia_{,sub}net{,mask} in host order */
+ u_int32_t ia_net; /* network number of interface */
+ u_int32_t ia_netmask; /* mask of net part */
+ u_int32_t ia_subnet; /* subnet number, including net */
+ u_int32_t ia_subnetmask; /* mask of subnet part */
+ struct in_addr ia_netbroadcast; /* to recognize net broadcasts */
+ LIST_ENTRY(in_ifaddr) ia_hash; /* entry in bucket of inet addresses */
+ TAILQ_ENTRY(in_ifaddr) ia_list; /* list of internet addresses */
+ struct sockaddr_in ia_addr; /* reserve space for interface name */
+ struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
+#define ia_broadaddr ia_dstaddr
+ struct sockaddr_in ia_sockmask; /* reserve space for general netmask */
+ LIST_HEAD(, in_multi) ia_multiaddrs; /* list of multicast addresses */
+ struct in_multi *ia_allhosts; /* multicast address record for
+ the allhosts multicast group */
+ uint16_t ia_idsalt; /* ip_id salt for this ia */
+ int ia4_flags; /* address flags */
+ void (*ia_dad_start) (struct ifaddr *); /* DAD start function */
+ void (*ia_dad_stop) (struct ifaddr *); /* DAD stop function */
+};
+
+struct in_aliasreq {
+ char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ struct sockaddr_in ifra_addr;
+ struct sockaddr_in ifra_dstaddr;
+#define ifra_broadaddr ifra_dstaddr
+ struct sockaddr_in ifra_mask;
+};
+
+/*
+ * Given a pointer to an in_ifaddr (ifaddr),
+ * return a pointer to the addr as a sockaddr_in.
+ */
+#define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr))
+
+#ifdef _KERNEL
+
+/* Note: 61, 127, 251, 509, 1021, 2039 are good. */
+#ifndef IN_IFADDR_HASH_SIZE
+#define IN_IFADDR_HASH_SIZE 509
+#endif
+
+/*
+ * This is a bit unconventional, and wastes a little bit of space, but
+ * because we want a very even hash function we don't use & in_ifaddrhash
+ * here, but rather % the hash size, which should obviously be prime.
+ */
+
+#define IN_IFADDR_HASH(x) in_ifaddrhashtbl[(u_long)(x) % IN_IFADDR_HASH_SIZE]
+
+LIST_HEAD(in_ifaddrhashhead, in_ifaddr); /* Type of the hash head */
+TAILQ_HEAD(in_ifaddrhead, in_ifaddr); /* Type of the list head */
+
+extern u_long in_ifaddrhash; /* size of hash table - 1 */
+extern struct in_ifaddrhashhead *in_ifaddrhashtbl; /* Hash table head */
+extern struct in_ifaddrhead in_ifaddrhead; /* List head (in ip_input) */
+
+extern const int inetctlerrmap[];
+
+/*
+ * Macro for finding whether an internet address (in_addr) belongs to one
+ * of our interfaces (in_ifaddr). NULL if the address isn't ours.
+ */
+#define INADDR_TO_IA(addr, ia) \
+ /* struct in_addr addr; */ \
+ /* struct in_ifaddr *ia; */ \
+{ \
+ LIST_FOREACH(ia, &IN_IFADDR_HASH((addr).s_addr), ia_hash) { \
+ if (in_hosteq(ia->ia_addr.sin_addr, (addr))) \
+ break; \
+ } \
+}
+
+/*
+ * Macro for finding the next in_ifaddr structure with the same internet
+ * address as ia. Call only with a valid ia pointer.
+ * Will set ia to NULL if none found.
+ */
+
+#define NEXT_IA_WITH_SAME_ADDR(ia) \
+ /* struct in_ifaddr *ia; */ \
+{ \
+ struct in_addr addr; \
+ addr = ia->ia_addr.sin_addr; \
+ do { \
+ ia = LIST_NEXT(ia, ia_hash); \
+ } while ((ia != NULL) && !in_hosteq(ia->ia_addr.sin_addr, addr)); \
+}
+
+/*
+ * Macro for finding the interface (ifnet structure) corresponding to one
+ * of our IP addresses.
+ */
+#define INADDR_TO_IFP(addr, ifp) \
+ /* struct in_addr addr; */ \
+ /* struct ifnet *ifp; */ \
+{ \
+ struct in_ifaddr *ia; \
+\
+ INADDR_TO_IA(addr, ia); \
+ (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
+}
+
+/*
+ * Macro for finding an internet address structure (in_ifaddr) corresponding
+ * to a given interface (ifnet structure).
+ */
+#define IFP_TO_IA(ifp, ia) \
+ /* struct ifnet *ifp; */ \
+ /* struct in_ifaddr *ia; */ \
+{ \
+ struct ifaddr *ifa; \
+\
+ IFADDR_FOREACH(ifa, ifp) { \
+ if (ifa->ifa_addr->sa_family == AF_INET) \
+ break; \
+ } \
+ (ia) = ifatoia(ifa); \
+}
+
+#include <netinet/in_selsrc.h>
+/*
+ * IPv4 per-interface state.
+ */
+struct in_ifinfo {
+ struct lltable *ii_llt; /* ARP state */
+ struct in_ifsysctl *ii_selsrc;
+};
+
+#endif /* _KERNEL */
+
+/*
+ * Internet multicast address structure. There is one of these for each IP
+ * multicast group to which this host belongs on a given network interface.
+ * They are kept in a linked list, rooted in the interface's in_ifaddr
+ * structure.
+ */
+struct router_info;
+
+struct in_multi {
+ LIST_ENTRY(in_multi) inm_list; /* list of multicast addresses */
+ struct router_info *inm_rti; /* router version info */
+ struct ifnet *inm_ifp; /* back pointer to ifnet */
+ struct in_addr inm_addr; /* IP multicast address */
+ u_int inm_refcount; /* no. membership claims by sockets */
+ u_int inm_timer; /* IGMP membership report timer */
+ u_int inm_state; /* state of membership */
+};
+
+#ifdef _KERNEL
+
+#include <net/pktqueue.h>
+
+extern pktqueue_t *ip_pktq;
+
+extern int ip_dad_count; /* Duplicate Address Detection probes */
+
+/*
+ * Structure used by functions below to remember position when stepping
+ * through all of the in_multi records.
+ */
+struct in_multistep {
+ int i_n;
+ struct in_multi *i_inm;
+};
+
+bool in_multi_group(struct in_addr, struct ifnet *, int);
+struct in_multi *in_first_multi(struct in_multistep *);
+struct in_multi *in_next_multi(struct in_multistep *);
+struct in_multi *in_lookup_multi(struct in_addr, struct ifnet *);
+struct in_multi *in_addmulti(struct in_addr *, struct ifnet *);
+void in_delmulti(struct in_multi *);
+
+void in_multi_lock(int);
+void in_multi_unlock(void);
+int in_multi_lock_held(void);
+
+struct ifaddr;
+
+int in_ifinit(struct ifnet *,
+ struct in_ifaddr *, const struct sockaddr_in *, int, int);
+void in_savemkludge(struct in_ifaddr *);
+void in_restoremkludge(struct in_ifaddr *, struct ifnet *);
+void in_purgemkludge(struct ifnet *);
+void in_ifscrub(struct ifnet *, struct in_ifaddr *);
+void in_setmaxmtu(void);
+const char *in_fmtaddr(struct in_addr);
+int in_control(struct socket *, u_long, void *, struct ifnet *);
+void in_purgeaddr(struct ifaddr *);
+void in_purgeif(struct ifnet *);
+int ipflow_fastforward(struct mbuf *);
+
+struct ipid_state;
+typedef struct ipid_state ipid_state_t;
+
+ipid_state_t * ip_id_init(void);
+void ip_id_fini(ipid_state_t *);
+uint16_t ip_randomid(ipid_state_t *, uint16_t);
+
+extern ipid_state_t * ip_ids;
+extern uint16_t ip_id;
+extern int ip_do_randomid;
+
+/*
+ * ip_newid_range: "allocate" num contiguous IP IDs.
+ *
+ * => Return the first ID.
+ */
+static __inline uint16_t
+ip_newid_range(const struct in_ifaddr *ia, u_int num)
+{
+ uint16_t id;
+
+ if (ip_do_randomid) {
+ /* XXX ignore num */
+ return ip_randomid(ip_ids, ia ? ia->ia_idsalt : 0);
+ }
+
+ /* Never allow an IP ID of 0 (detect wrap). */
+ if ((uint16_t)(ip_id + num) < ip_id) {
+ ip_id = 1;
+ }
+ id = htons(ip_id);
+ ip_id += num;
+ return id;
+}
+
+static __inline uint16_t
+ip_newid(const struct in_ifaddr *ia)
+{
+
+ return ip_newid_range(ia, 1);
+}
+
+#ifdef SYSCTLFN_PROTO
+int sysctl_inpcblist(SYSCTLFN_PROTO);
+#endif
+
+#define LLTABLE(ifp) \
+ ((struct in_ifinfo *)(ifp)->if_afdata[AF_INET])->ii_llt
+
+#endif /* !_KERNEL */
+
+/* INET6 stuff */
+#include <netinet6/in6_var.h>
+
+#endif /* !_NETINET_IN_VAR_H_ */
--- /dev/null
+/* $NetBSD: ip6.h,v 1.23 2007/12/25 18:33:46 perry Exp $ */
+/* $KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)ip.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IP6_H_
+#define _NETINET_IP6_H_
+
+/*
+ * Definition for internet protocol version 6.
+ * RFC 2460
+ */
+
+struct ip6_hdr {
+ union {
+ struct ip6_hdrctl {
+ u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
+ u_int16_t ip6_un1_plen; /* payload length */
+ u_int8_t ip6_un1_nxt; /* next header */
+ u_int8_t ip6_un1_hlim; /* hop limit */
+ } ip6_un1;
+ u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
+ } ip6_ctlun;
+ struct in6_addr ip6_src; /* source address */
+ struct in6_addr ip6_dst; /* destination address */
+} __packed;
+
+#define ip6_vfc ip6_ctlun.ip6_un2_vfc
+#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+#define IPV6_VERSION 0x60
+#define IPV6_VERSION_MASK 0xf0
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */
+#endif /* LITTLE_ENDIAN */
+#endif
+#if 1
+/* ECN bits proposed by Sally Floyd */
+#define IP6TOS_CE 0x01 /* congestion experienced */
+#define IP6TOS_ECT 0x02 /* ECN-capable transport */
+#endif
+
+#ifdef _KERNEL
+/*
+ * for IPv6 pseudo header checksum
+ * XXX nonstandard
+ */
+struct ip6_hdr_pseudo {
+ struct in6_addr ip6ph_src;
+ struct in6_addr ip6ph_dst;
+ u_int32_t ip6ph_len;
+ u_int8_t ip6ph_zero[3];
+ u_int8_t ip6ph_nxt;
+} __packed;
+#endif
+
+/*
+ * Extension Headers
+ */
+
+struct ip6_ext {
+ u_int8_t ip6e_nxt;
+ u_int8_t ip6e_len;
+} __packed;
+
+/* Hop-by-Hop options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_hbh {
+ u_int8_t ip6h_nxt; /* next header */
+ u_int8_t ip6h_len; /* length in units of 8 octets */
+ /* followed by options */
+} __packed;
+
+/* Destination options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_dest {
+ u_int8_t ip6d_nxt; /* next header */
+ u_int8_t ip6d_len; /* length in units of 8 octets */
+ /* followed by options */
+} __packed;
+
+/* Option types and related macros */
+#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
+#define IP6OPT_PADN 0x01 /* 00 0 00001 */
+#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
+#define IP6OPT_NSAP_ADDR 0xC3 /* 11 0 00011 */
+#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */
+#define IP6OPT_RTALERT 0x05 /* 00 0 00101 (KAME definition) */
+#define IP6OPT_ROUTER_ALERT 0x05 /* (RFC3542 def, recommended) */
+
+#define IP6OPT_RTALERT_LEN 4
+#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
+#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
+#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
+#define IP6OPT_MINLEN 2
+
+#define IP6OPT_TYPE(o) ((o) & 0xC0)
+#define IP6OPT_TYPE_SKIP 0x00
+#define IP6OPT_TYPE_DISCARD 0x40
+#define IP6OPT_TYPE_FORCEICMP 0x80
+#define IP6OPT_TYPE_ICMP 0xC0
+
+#define IP6OPT_MUTABLE 0x20
+
+/* IPv6 options: common part */
+struct ip6_opt {
+ u_int8_t ip6o_type;
+ u_int8_t ip6o_len;
+} __packed;
+
+/* Jumbo Payload Option */
+struct ip6_opt_jumbo {
+ u_int8_t ip6oj_type;
+ u_int8_t ip6oj_len;
+ u_int8_t ip6oj_jumbo_len[4];
+} __packed;
+#define IP6OPT_JUMBO_LEN 6
+
+/* NSAP Address Option */
+struct ip6_opt_nsap {
+ u_int8_t ip6on_type;
+ u_int8_t ip6on_len;
+ u_int8_t ip6on_src_nsap_len;
+ u_int8_t ip6on_dst_nsap_len;
+ /* followed by source NSAP */
+ /* followed by destination NSAP */
+} __packed;
+
+/* Tunnel Limit Option */
+struct ip6_opt_tunnel {
+ u_int8_t ip6ot_type;
+ u_int8_t ip6ot_len;
+ u_int8_t ip6ot_encap_limit;
+} __packed;
+
+/* Router Alert Option */
+struct ip6_opt_router {
+ u_int8_t ip6or_type;
+ u_int8_t ip6or_len;
+ u_int8_t ip6or_value[2];
+} __packed;
+/* Router alert values (in network byte order) */
+#if BYTE_ORDER == BIG_ENDIAN
+#define IP6_ALERT_MLD 0x0000
+#define IP6_ALERT_RSVP 0x0001
+#define IP6_ALERT_AN 0x0002
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define IP6_ALERT_MLD 0x0000
+#define IP6_ALERT_RSVP 0x0100
+#define IP6_ALERT_AN 0x0200
+#endif /* LITTLE_ENDIAN */
+#endif
+
+/* Routing header */
+struct ip6_rthdr {
+ u_int8_t ip6r_nxt; /* next header */
+ u_int8_t ip6r_len; /* length in units of 8 octets */
+ u_int8_t ip6r_type; /* routing type */
+ u_int8_t ip6r_segleft; /* segments left */
+ /* followed by routing type specific data */
+} __packed;
+
+/* Type 0 Routing header */
+struct ip6_rthdr0 {
+ u_int8_t ip6r0_nxt; /* next header */
+ u_int8_t ip6r0_len; /* length in units of 8 octets */
+ u_int8_t ip6r0_type; /* always zero */
+ u_int8_t ip6r0_segleft; /* segments left */
+ u_int32_t ip6r0_reserved; /* reserved field */
+} __packed;
+
+/* Fragment header */
+struct ip6_frag {
+ u_int8_t ip6f_nxt; /* next header */
+ u_int8_t ip6f_reserved; /* reserved field */
+ u_int16_t ip6f_offlg; /* offset, reserved, and flag */
+ u_int32_t ip6f_ident; /* identification */
+} __packed;
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+/*
+ * Internet implementation parameters.
+ */
+#define IPV6_MAXHLIM 255 /* maximum hoplimit */
+#define IPV6_DEFHLIM 64 /* default hlim */
+#define IPV6_FRAGTTL 120 /* ttl for fragment packets, in slowtimo tick */
+#define IPV6_HLIMDEC 1 /* subtracted when forwarding */
+
+#define IPV6_MMTU 1280 /* minimal MTU and reassembly. 1024 + 256 */
+#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/
+
+#ifdef _KERNEL
+/*
+ * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
+ * "len") is located in single mbuf, on contiguous memory region.
+ * The pointer to the region will be returned to pointer variable "val",
+ * with type "typ".
+ * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
+ * very top of mbuf. GET0 is likely to make memory copy than GET.
+ *
+ * XXX we're now testing this, needs m_pulldown()
+ */
+#define IP6_EXTHDR_GET(val, typ, m, off, len) \
+do { \
+ struct mbuf *_t; \
+ int _tmp; \
+ if ((m)->m_len >= (off) + (len)) \
+ (val) = (typ)(mtod((m), char *) + (off)); \
+ else { \
+ _t = m_pulldown((m), (off), (len), &_tmp); \
+ if (_t) { \
+ if (_t->m_len < _tmp + (len)) \
+ panic("m_pulldown malfunction"); \
+ (val) = (typ)(mtod(_t, char *) + _tmp); \
+ } else { \
+ (val) = (typ)NULL; \
+ (m) = NULL; \
+ } \
+ } \
+} while (/*CONSTCOND*/ 0)
+
+#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
+do { \
+ struct mbuf *_t; \
+ if ((off) == 0 && (m)->m_len >= len) \
+ (val) = (typ)mtod((m), void *); \
+ else { \
+ _t = m_pulldown((m), (off), (len), NULL); \
+ if (_t) { \
+ if (_t->m_len < (len)) \
+ panic("m_pulldown malfunction"); \
+ (val) = (typ)mtod(_t, void *); \
+ } else { \
+ (val) = (typ)NULL; \
+ (m) = NULL; \
+ } \
+ } \
+} while (/*CONSTCOND*/ 0)
+#endif /*_KERNEL*/
+
+#endif /* !_NETINET_IP6_H_ */
--- /dev/null
+/* $NetBSD: ip_carp.h,v 1.7 2014/07/31 00:58:02 ozaki-r Exp $ */
+/* $OpenBSD: ip_carp.h,v 1.18 2005/04/20 23:00:41 mpf Exp $ */
+
+/*
+ * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
+ * Copyright (c) 2003 Ryan McBride. All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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 _NETINET_IP_CARP_H_
+#define _NETINET_IP_CARP_H_
+
+/*
+ * The CARP header layout is as follows:
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Version| Type | VirtualHostID | AdvSkew | Auth Len |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Reserved | AdvBase | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Counter (1) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Counter (2) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | SHA-1 HMAC (1) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | SHA-1 HMAC (2) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | SHA-1 HMAC (3) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | SHA-1 HMAC (4) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | SHA-1 HMAC (5) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+
+struct carp_header {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ unsigned int carp_type:4,
+ carp_version:4;
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ unsigned int carp_version:4,
+ carp_type:4;
+#endif
+ u_int8_t carp_vhid; /* virtual host id */
+ u_int8_t carp_advskew; /* advertisement skew */
+ u_int8_t carp_authlen; /* size of counter+md, 32bit chunks */
+ u_int8_t carp_pad1; /* reserved */
+ u_int8_t carp_advbase; /* advertisement interval */
+ u_int16_t carp_cksum;
+ u_int32_t carp_counter[2];
+ unsigned char carp_md[20]; /* SHA1 HMAC */
+} __packed;
+
+#define CARP_DFLTTL 255
+
+/* carp_version */
+#define CARP_VERSION 2
+
+/* carp_type */
+#define CARP_ADVERTISEMENT 0x01
+
+#define CARP_KEY_LEN 20 /* a sha1 hash of a passphrase */
+
+/* carp_advbase */
+#define CARP_DFLTINTV 1
+
+/*
+ * Statistics.
+ */
+#define CARP_STAT_IPACKETS 0 /* total input packets, IPv4 */
+#define CARP_STAT_IPACKETS6 1 /* total input packets, IPv6 */
+#define CARP_STAT_BADIF 2 /* wrong interface */
+#define CARP_STAT_BADTTL 3 /* TTL is not CARP_DFLTTL */
+#define CARP_STAT_HDROPS 4 /* packets shorter than hdr */
+#define CARP_STAT_BADSUM 5 /* bad checksum */
+#define CARP_STAT_BADVER 6 /* bad (incl unsupported) version */
+#define CARP_STAT_BADLEN 7 /* data length does not match */
+#define CARP_STAT_BADAUTH 8 /* bad authentication */
+#define CARP_STAT_BADVHID 9 /* bad VHID */
+#define CARP_STAT_BADADDRS 10 /* bad address list */
+#define CARP_STAT_OPACKETS 11 /* total output packets, IPv4 */
+#define CARP_STAT_OPACKETS6 12 /* total output packets, IPv6 */
+#define CARP_STAT_ONOMEM 13 /* no memory for an mbuf */
+#define CARP_STAT_OSTATES 14 /* total state updates sent */
+#define CARP_STAT_PREEMPT 15 /* in enabled, preemptions */
+
+#define CARP_NSTATS 16
+
+#define CARPDEVNAMSIZ 16
+#ifdef IFNAMSIZ
+#if CARPDEVNAMSIZ != IFNAMSIZ
+#error
+#endif
+#endif
+
+/*
+ * Configuration structure for SIOCSVH SIOCGVH
+ */
+struct carpreq {
+ int carpr_state;
+#define CARP_STATES "INIT", "BACKUP", "MASTER"
+#define CARP_MAXSTATE 2
+
+ char carpr_carpdev[CARPDEVNAMSIZ];
+ int carpr_vhid;
+ int carpr_advskew;
+ int carpr_advbase;
+ unsigned char carpr_key[CARP_KEY_LEN];
+};
+
+/*
+ * Names for CARP sysctl objects
+ */
+#define CARPCTL_ALLOW 1 /* accept incoming CARP packets */
+#define CARPCTL_PREEMPT 2 /* high-pri backup preemption mode */
+#define CARPCTL_LOG 3 /* log bad packets */
+#define CARPCTL_ARPBALANCE 4 /* balance arp responses */
+#define CARPCTL_STATS 5 /* carp statistics */
+#define CARPCTL_MAXID 6
+
+#define CARPCTL_NAMES { \
+ { 0, 0 }, \
+ { "allow", CTLTYPE_INT }, \
+ { "preempt", CTLTYPE_INT }, \
+ { "log", CTLTYPE_INT }, \
+ { "arpbalance", CTLTYPE_INT }, \
+}
+
+#ifdef _KERNEL
+void carp_init(void);
+void carp_ifdetach(struct ifnet *);
+void carp_proto_input(struct mbuf *, ...);
+void carp_carpdev_state(void *);
+int carp6_proto_input(struct mbuf **, int *, int);
+int carp_iamatch(struct in_ifaddr *, u_char *,
+ u_int32_t *, u_int32_t);
+struct ifaddr *carp_iamatch6(void *, struct in6_addr *);
+struct ifnet *carp_ourether(void *, struct ether_header *, u_char, int);
+int carp_input(struct mbuf *, u_int8_t *, u_int8_t *, u_int16_t);
+int carp_output(struct ifnet *, struct mbuf *,
+ const struct sockaddr *, struct rtentry *);
+#endif /* _KERNEL */
+#endif /* _NETINET_IP_CARP_H_ */
--- /dev/null
+/* $NetBSD: ip_mroute.h,v 1.31 2008/08/07 06:20:14 cegger Exp $ */
+
+#ifndef _NETINET_IP_MROUTE_H_
+#define _NETINET_IP_MROUTE_H_
+
+/*
+ * Definitions for IP multicast forwarding.
+ *
+ * Written by David Waitzman, BBN Labs, August 1988.
+ * Modified by Steve Deering, Stanford, February 1989.
+ * Modified by Ajit Thyagarajan, PARC, August 1993.
+ * Modified by Ajit Thyagarajan, PARC, August 1994.
+ * Modified by Ahmed Helmy, SGI, June 1996.
+ * Modified by Pavlin Radoslavov, ICSI, October 2002.
+ *
+ * MROUTING Revision: 1.2
+ * and PIM-SMv2 and PIM-DM support, advanced API support,
+ * bandwidth metering and signaling.
+ */
+
+#include <sys/queue.h>
+#include <sys/callout.h>
+
+#ifdef _KERNEL
+struct sockopt; /* from <sys/socketvar.h> */
+#endif
+
+/*
+ * Multicast Routing set/getsockopt commands.
+ */
+#define MRT_INIT 100 /* initialize forwarder */
+#define MRT_DONE 101 /* shut down forwarder */
+#define MRT_ADD_VIF 102 /* create virtual interface */
+#define MRT_DEL_VIF 103 /* delete virtual interface */
+#define MRT_ADD_MFC 104 /* insert forwarding cache entry */
+#define MRT_DEL_MFC 105 /* delete forwarding cache entry */
+#define MRT_VERSION 106 /* get kernel version number */
+#define MRT_ASSERT 107 /* enable assert processing */
+#define MRT_PIM MRT_ASSERT /* enable PIM processing */
+#define MRT_API_SUPPORT 109 /* supported MRT API */
+#define MRT_API_CONFIG 110 /* config MRT API */
+#define MRT_ADD_BW_UPCALL 111 /* create bandwidth monitor */
+#define MRT_DEL_BW_UPCALL 112 /* delete bandwidth monitor */
+
+
+/*
+ * Types and macros for handling bitmaps with one bit per virtual interface.
+ */
+#define MAXVIFS 32
+typedef u_int32_t vifbitmap_t;
+typedef u_int16_t vifi_t; /* type of a vif index */
+
+#define VIFM_SET(n, m) ((m) |= (1 << (n)))
+#define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
+#define VIFM_ISSET(n, m) ((m) & (1 << (n)))
+#define VIFM_SETALL(m) ((m) = 0xffffffff)
+#define VIFM_CLRALL(m) ((m) = 0x00000000)
+#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
+#define VIFM_SAME(m1, m2) ((m1) == (m2))
+
+#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
+#define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */
+#define VIFF_REGISTER 0x4 /* used for PIM Register encap/decap */
+
+/*
+ * Argument structure for MRT_ADD_VIF.
+ * (MRT_DEL_VIF takes a single vifi_t argument.)
+ */
+struct vifctl {
+ vifi_t vifc_vifi; /* the index of the vif to be added */
+ u_int8_t vifc_flags; /* VIFF_ flags defined below */
+ u_int8_t vifc_threshold; /* min ttl required to forward on vif */
+ u_int32_t vifc_rate_limit; /* max rate */
+ struct in_addr vifc_lcl_addr;/* local interface address */
+ struct in_addr vifc_rmt_addr;/* remote address (tunnels only) */
+};
+
+/*
+ * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC.
+ * XXX if you change this, make sure to change struct mfcctl2 as well.
+ */
+struct mfcctl {
+ struct in_addr mfcc_origin; /* ip origin of mcasts */
+ struct in_addr mfcc_mcastgrp; /* multicast group associated */
+ vifi_t mfcc_parent; /* incoming vif */
+ u_int8_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
+};
+
+/*
+ * The new argument structure for MRT_ADD_MFC and MRT_DEL_MFC overlays
+ * and extends the old struct mfcctl.
+ */
+struct mfcctl2 {
+ /* the mfcctl fields */
+ struct in_addr mfcc_origin; /* ip origin of mcasts */
+ struct in_addr mfcc_mcastgrp; /* multicast group associated*/
+ vifi_t mfcc_parent; /* incoming vif */
+ u_int8_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
+
+ /* extension fields */
+ u_int8_t mfcc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */
+ struct in_addr mfcc_rp; /* the RP address */
+};
+/*
+ * The advanced-API flags.
+ *
+ * The MRT_MFC_FLAGS_XXX API flags are also used as flags
+ * for the mfcc_flags field.
+ */
+#define MRT_MFC_FLAGS_DISABLE_WRONGVIF (1 << 0) /* disable WRONGVIF signals */
+#define MRT_MFC_FLAGS_BORDER_VIF (1 << 1) /* border vif */
+#define MRT_MFC_RP (1 << 8) /* enable RP address */
+#define MRT_MFC_BW_UPCALL (1 << 9) /* enable bw upcalls */
+#define MRT_MFC_FLAGS_ALL (MRT_MFC_FLAGS_DISABLE_WRONGVIF | \
+ MRT_MFC_FLAGS_BORDER_VIF)
+#define MRT_API_FLAGS_ALL (MRT_MFC_FLAGS_ALL | \
+ MRT_MFC_RP | \
+ MRT_MFC_BW_UPCALL)
+
+/*
+ * Structure for installing or delivering an upcall if the
+ * measured bandwidth is above or below a threshold.
+ *
+ * User programs (e.g. daemons) may have a need to know when the
+ * bandwidth used by some data flow is above or below some threshold.
+ * This interface allows the userland to specify the threshold (in
+ * bytes and/or packets) and the measurement interval. Flows are
+ * all packet with the same source and destination IP address.
+ * At the moment the code is only used for multicast destinations
+ * but there is nothing that prevents its use for unicast.
+ *
+ * The measurement interval cannot be shorter than some Tmin (currently, 3s).
+ * The threshold is set in packets and/or bytes per_interval.
+ *
+ * Measurement works as follows:
+ *
+ * For >= measurements:
+ * The first packet marks the start of a measurement interval.
+ * During an interval we count packets and bytes, and when we
+ * pass the threshold we deliver an upcall and we are done.
+ * The first packet after the end of the interval resets the
+ * count and restarts the measurement.
+ *
+ * For <= measurement:
+ * We start a timer to fire at the end of the interval, and
+ * then for each incoming packet we count packets and bytes.
+ * When the timer fires, we compare the value with the threshold,
+ * schedule an upcall if we are below, and restart the measurement
+ * (reschedule timer and zero counters).
+ */
+
+struct bw_data {
+ struct timeval b_time;
+ u_int64_t b_packets;
+ u_int64_t b_bytes;
+};
+
+struct bw_upcall {
+ struct in_addr bu_src; /* source address */
+ struct in_addr bu_dst; /* destination address */
+ u_int32_t bu_flags; /* misc flags (see below) */
+#define BW_UPCALL_UNIT_PACKETS (1 << 0) /* threshold (in packets) */
+#define BW_UPCALL_UNIT_BYTES (1 << 1) /* threshold (in bytes) */
+#define BW_UPCALL_GEQ (1 << 2) /* upcall if bw >= threshold */
+#define BW_UPCALL_LEQ (1 << 3) /* upcall if bw <= threshold */
+#define BW_UPCALL_DELETE_ALL (1 << 4) /* delete all upcalls for s,d*/
+ struct bw_data bu_threshold; /* the bw threshold */
+ struct bw_data bu_measured; /* the measured bw */
+};
+
+/* max. number of upcalls to deliver together */
+#define BW_UPCALLS_MAX 128
+/* min. threshold time interval for bandwidth measurement */
+#define BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC 3
+#define BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC 0
+
+/*
+ * Argument structure used by mrouted to get src-grp pkt counts.
+ */
+struct sioc_sg_req {
+ struct in_addr src;
+ struct in_addr grp;
+ u_long pktcnt;
+ u_long bytecnt;
+ u_long wrong_if;
+};
+
+/*
+ * Argument structure used by mrouted to get vif pkt counts.
+ */
+struct sioc_vif_req {
+ vifi_t vifi; /* vif number */
+ u_long icount; /* input packet count on vif */
+ u_long ocount; /* output packet count on vif */
+ u_long ibytes; /* input byte count on vif */
+ u_long obytes; /* output byte count on vif */
+};
+
+
+/*
+ * The kernel's multicast routing statistics.
+ */
+struct mrtstat {
+ u_long mrts_mfc_lookups; /* # forw. cache hash table hits */
+ u_long mrts_mfc_misses; /* # forw. cache hash table misses */
+ u_long mrts_upcalls; /* # calls to mrouted */
+ u_long mrts_no_route; /* no route for packet's origin */
+ u_long mrts_bad_tunnel; /* malformed tunnel options */
+ u_long mrts_cant_tunnel; /* no room for tunnel options */
+ u_long mrts_wrong_if; /* arrived on wrong interface */
+ u_long mrts_upq_ovflw; /* upcall Q overflow */
+ u_long mrts_cache_cleanups; /* # entries with no upcalls */
+ u_long mrts_drop_sel; /* pkts dropped selectively */
+ u_long mrts_q_overflow; /* pkts dropped - Q overflow */
+ u_long mrts_pkt2large; /* pkts dropped - size > BKT SIZE */
+ u_long mrts_upq_sockfull; /* upcalls dropped - socket full */
+};
+
+
+#ifdef _KERNEL
+
+/*
+ * The kernel's virtual-interface structure.
+ */
+struct encaptab;
+struct vif {
+ struct mbuf *tbf_q, **tbf_t; /* packet queue */
+ struct timeval tbf_last_pkt_t; /* arr. time of last pkt */
+ u_int32_t tbf_n_tok; /* no of tokens in bucket */
+ u_int32_t tbf_q_len; /* length of queue at this vif */
+ u_int32_t tbf_max_q_len; /* max. queue length */
+
+ u_int8_t v_flags; /* VIFF_ flags defined above */
+ u_int8_t v_threshold; /* min ttl required to forward on vif */
+ u_int32_t v_rate_limit; /* max rate */
+ struct in_addr v_lcl_addr; /* local interface address */
+ struct in_addr v_rmt_addr; /* remote address (tunnels only) */
+ struct ifnet *v_ifp; /* pointer to interface */
+ u_long v_pkt_in; /* # pkts in on interface */
+ u_long v_pkt_out; /* # pkts out on interface */
+ u_long v_bytes_in; /* # bytes in on interface */
+ u_long v_bytes_out; /* # bytes out on interface */
+ struct route v_route; /* cached route if this is a tunnel */
+ callout_t v_repq_ch; /* for tbf_reprocess_q() */
+#ifdef RSVP_ISI
+ int v_rsvp_on; /* # RSVP listening on this vif */
+ struct socket *v_rsvpd; /* # RSVPD daemon */
+#endif /* RSVP_ISI */
+ const struct encaptab *v_encap_cookie;
+};
+
+/*
+ * The kernel's multicast forwarding cache entry structure.
+ * (A field for the type of service (mfc_tos) is to be added
+ * at a future point.)
+ */
+struct mfc {
+ LIST_ENTRY(mfc) mfc_hash;
+ struct in_addr mfc_origin; /* ip origin of mcasts */
+ struct in_addr mfc_mcastgrp; /* multicast group associated */
+ vifi_t mfc_parent; /* incoming vif */
+ u_int8_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */
+ u_long mfc_pkt_cnt; /* pkt count for src-grp */
+ u_long mfc_byte_cnt; /* byte count for src-grp */
+ u_long mfc_wrong_if; /* wrong if for src-grp */
+ int mfc_expire; /* time to clean entry up */
+ struct timeval mfc_last_assert; /* last time I sent an assert */
+ struct rtdetq *mfc_stall; /* pkts waiting for route */
+ u_int8_t mfc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */
+ struct in_addr mfc_rp; /* the RP address */
+ struct bw_meter *mfc_bw_meter; /* list of bandwidth meters */
+};
+
+/*
+ * Structure used to communicate from kernel to multicast router.
+ * (Note the convenient similarity to an IP packet.)
+ */
+struct igmpmsg {
+ u_int32_t unused1;
+ u_int32_t unused2;
+ u_int8_t im_msgtype; /* what type of message */
+#define IGMPMSG_NOCACHE 1 /* no MFC in the kernel */
+#define IGMPMSG_WRONGVIF 2 /* packet came from wrong interface */
+#define IGMPMSG_WHOLEPKT 3 /* PIM pkt for user level encap. */
+#define IGMPMSG_BW_UPCALL 4 /* BW monitoring upcall */
+ u_int8_t im_mbz; /* must be zero */
+ u_int8_t im_vif; /* vif rec'd on */
+ u_int8_t unused3;
+ struct in_addr im_src, im_dst;
+} __packed;
+
+/*
+ * Argument structure used for pkt info. while upcall is made.
+ */
+struct rtdetq {
+ struct mbuf *m; /* a copy of the packet */
+ struct ifnet *ifp; /* interface pkt came in on */
+#ifdef UPCALL_TIMING
+ struct timeval t; /* timestamp */
+#endif /* UPCALL_TIMING */
+ struct rtdetq *next;
+};
+
+#define MFCTBLSIZ 256
+#define MAX_UPQ 4 /* max. no of pkts in upcall Q */
+
+/*
+ * Token bucket filter code
+ */
+#define MAX_BKT_SIZE 10000 /* 10K bytes size */
+#define MAXQSIZE 10 /* max. no of pkts in token queue */
+
+/*
+ * Structure for measuring the bandwidth and sending an upcall if the
+ * measured bandwidth is above or below a threshold.
+ */
+struct bw_meter {
+ struct bw_meter *bm_mfc_next; /* next bw meter (same mfc) */
+ struct bw_meter *bm_time_next; /* next bw meter (same time) */
+ uint32_t bm_time_hash; /* the time hash value */
+ struct mfc *bm_mfc; /* the corresponding mfc */
+ uint32_t bm_flags; /* misc flags (see below) */
+#define BW_METER_UNIT_PACKETS (1 << 0) /* threshold (in packets) */
+#define BW_METER_UNIT_BYTES (1 << 1) /* threshold (in bytes) */
+#define BW_METER_GEQ (1 << 2) /* upcall if bw >= threshold */
+#define BW_METER_LEQ (1 << 3) /* upcall if bw <= threshold */
+#define BW_METER_USER_FLAGS (BW_METER_UNIT_PACKETS | \
+ BW_METER_UNIT_BYTES | \
+ BW_METER_GEQ | \
+ BW_METER_LEQ)
+
+#define BW_METER_UPCALL_DELIVERED (1 << 24) /* upcall was delivered */
+
+ struct bw_data bm_threshold; /* the upcall threshold */
+ struct bw_data bm_measured; /* the measured bw */
+ struct timeval bm_start_time; /* abs. time */
+};
+
+int ip_mrouter_set(struct socket *, struct sockopt *);
+int ip_mrouter_get(struct socket *, struct sockopt *);
+int mrt_ioctl(struct socket *, u_long, void *);
+int ip_mrouter_done(void);
+void ip_mrouter_detach(struct ifnet *);
+void reset_vif(struct vif *);
+#ifdef RSVP_ISI
+int ip_mforward(struct mbuf *, struct ifnet *, struct ip_moptions *);
+int legal_vif_num(int);
+int ip_rsvp_vif_init(struct socket *, struct mbuf *);
+int ip_rsvp_vif_done(struct socket *, struct mbuf *);
+void ip_rsvp_force_done(struct socket *);
+void rsvp_input(struct mbuf *, int, int);
+#else
+int ip_mforward(struct mbuf *, struct ifnet *);
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* !_NETINET_IP_MROUTE_H_ */
--- /dev/null
+/* $NetBSD: pim_var.h,v 1.2 2005/12/10 23:36:23 elad Exp $ */
+
+/*
+ * Copyright (c) 1998-2000
+ * University of Southern California/Information Sciences Institute.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim_var.h,v 1.1 2003/08/07 18:17:43 hsu Exp $
+ */
+
+#ifndef _NETINET_PIM_VAR_H_
+#define _NETINET_PIM_VAR_H_
+
+/*
+ * Protocol Independent Multicast (PIM),
+ * kernel variables and implementation-specific definitions.
+ *
+ * Written by George Edmond Eddy (Rusty), ISI, February 1998.
+ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, Aug 1999, October 2000.
+ * Modified by Hitoshi Asaeda, WIDE, August 1998.
+ */
+
+/*
+ * PIM statistics kept in the kernel
+ */
+struct pimstat {
+ u_quad_t pims_rcv_total_msgs; /* total PIM messages received */
+ u_quad_t pims_rcv_total_bytes; /* total PIM bytes received */
+ u_quad_t pims_rcv_tooshort; /* rcvd with too few bytes */
+ u_quad_t pims_rcv_badsum; /* rcvd with bad checksum */
+ u_quad_t pims_rcv_badversion; /* rcvd bad PIM version */
+ u_quad_t pims_rcv_registers_msgs; /* rcvd regs. msgs (data only) */
+ u_quad_t pims_rcv_registers_bytes; /* rcvd regs. bytes (data only) */
+ u_quad_t pims_rcv_registers_wrongiif; /* rcvd regs. on wrong iif */
+ u_quad_t pims_rcv_badregisters; /* rcvd invalid registers */
+ u_quad_t pims_snd_registers_msgs; /* sent regs. msgs (data only) */
+ u_quad_t pims_snd_registers_bytes; /* sent regs. bytes (data only) */
+};
+
+/*
+ * Names for PIM sysctl objects
+ */
+#define PIMCTL_STATS 1 /* statistics (read-only) */
+#define PIMCTL_MAXID 2
+
+#define PIMCTL_NAMES { \
+ { 0, 0 }, \
+ { "stats", CTLTYPE_STRUCT }, \
+}
+
+#ifdef _KERNEL
+extern struct pimstat pimstat;
+
+void pim_input(struct mbuf *, ...);
+#endif
+
+#endif /* !_NETINET_PIM_VAR_H_ */
--- /dev/null
+/* $NetBSD: tcp_debug.h,v 1.17 2007/03/04 06:03:22 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)tcp_debug.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_TCP_DEBUG_H_
+#define _NETINET_TCP_DEBUG_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_inet.h"
+#endif
+
+struct tcp_debug {
+ n_time td_time;
+ short td_act;
+ short td_ostate;
+ void * td_tcb;
+ int td_family;
+ struct tcpiphdr td_ti;
+ struct {
+#ifdef INET6
+ struct ip6_hdr ip6;
+#else
+ u_char ip6_dummy[40]; /* just to keep struct align/size */
+#endif
+ struct tcphdr th;
+ } td_ti6;
+ short td_req;
+ struct tcpcb td_cb;
+};
+
+#define TA_INPUT 0
+#define TA_OUTPUT 1
+#define TA_USER 2
+#define TA_RESPOND 3
+#define TA_DROP 4
+
+#ifdef TANAMES
+const char *tanames[] =
+ { "input", "output", "user", "respond", "drop" };
+#endif
+
+#ifndef TCP_NDEBUG
+#define TCP_NDEBUG 100
+#endif
+
+#endif /* !_NETINET_TCP_DEBUG_H_ */
--- /dev/null
+/* $NetBSD: tcp_fsm.h,v 1.15 2005/12/10 23:36:23 elad Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_TCP_FSM_H_
+#define _NETINET_TCP_FSM_H_
+
+/*
+ * TCP FSM state definitions.
+ * Per RFC793, September, 1981.
+ */
+
+#define TCP_NSTATES 11
+
+#define TCPS_CLOSED 0 /* closed */
+#define TCPS_LISTEN 1 /* listening for connection */
+#define TCPS_SYN_SENT 2 /* active, have sent syn */
+#define TCPS_SYN_RECEIVED 3 /* have send and received syn */
+/* states < TCPS_ESTABLISHED are those where connections not established */
+#define TCPS_ESTABLISHED 4 /* established */
+#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
+/* states > TCPS_CLOSE_WAIT are those where user has closed */
+#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
+#define TCPS_CLOSING 7 /* closed xchd FIN; await ACK */
+#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
+/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
+#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
+#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
+
+#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED)
+#define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED)
+#define TCPS_HAVERCVDFIN(s) \
+ ((s) == TCPS_CLOSE_WAIT || ((s) >= TCPS_CLOSING && (s) != TCPS_FIN_WAIT_2))
+
+#ifdef TCPOUTFLAGS
+/*
+ * Flags used when sending segments in tcp_output.
+ * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
+ * determined by state, with the proviso that TH_FIN is sent only
+ * if all data queued for output is included in the segment.
+ */
+const u_char tcp_outflags[TCP_NSTATES] = {
+ TH_RST|TH_ACK, /* CLOSED */
+ 0, /* LISTEN */
+ TH_SYN, /* SYN_SENT */
+ TH_SYN|TH_ACK, /* SYN_RCVD */
+ TH_ACK, /* ESTABLISHED */
+ TH_ACK, /* CLOSE_WAIT */
+ TH_FIN|TH_ACK, /* FIN_WAIT_1 */
+ TH_FIN|TH_ACK, /* CLOSING */
+ TH_FIN|TH_ACK, /* LAST_ACK */
+ TH_ACK, /* FIN_WAIT_2 */
+ TH_ACK, /* TIME_WAIT */
+};
+#endif
+
+#ifdef KPROF
+int tcp_acounts[TCP_NSTATES][PRU_NREQ];
+#endif
+
+#ifdef TCPSTATES
+const char * const tcpstates[] = {
+ "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD",
+ "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING",
+ "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT",
+};
+#elif defined(_KERNEL)
+extern const char * const tcpstates[];
+#endif
+
+#endif /* !_NETINET_TCP_FSM_H_ */
--- /dev/null
+/* $NetBSD: tcp_seq.h,v 1.17 2014/07/25 17:53:59 ryo Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)tcp_seq.h 8.3 (Berkeley) 6/21/95
+ */
+
+#ifndef _NETINET_TCP_SEQ_H_
+#define _NETINET_TCP_SEQ_H_
+
+/*
+ * TCP sequence numbers are 32 bit integers operated
+ * on with modular arithmetic. These macros can be
+ * used to compare such integers.
+ */
+#define SEQ_LT(a,b) ((int)((a)-(b)) < 0)
+#define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0)
+#define SEQ_GT(a,b) ((int)((a)-(b)) > 0)
+#define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0)
+#define SEQ_MIN(a, b) ((SEQ_LT(a, b)) ? (a) : (b))
+#define SEQ_MAX(a, b) ((SEQ_GT(a, b)) ? (a) : (b))
+
+#define SEQ_SUB(a,b) ((long)((a)-(b)))
+
+/*
+ * Macros to initialize tcp sequence numbers for
+ * send and receive from initial send and receive
+ * sequence numbers.
+ */
+#define tcp_rcvseqinit(tp) \
+ (tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1
+
+#define tcp_sendseqinit(tp) \
+ (tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \
+ (tp)->snd_recover = (tp)->snd_high = (tp)->snd_fack = (tp)->iss
+
+#define TCP_ISS_RANDOM_MASK 0x00ffffff /* bits of randomness in a TCP ISS */
+#define TCP_ISSINCR 0x01000000 /* increment per time and per conn */
+
+#ifdef _KERNEL
+extern tcp_seq tcp_iss_seq; /* tcp initial seq # */
+#endif
+
+#endif /* !_NETINET_TCP_SEQ_H_ */
--- /dev/null
+/* $NetBSD: tcp_timer.h,v 1.28 2011/05/24 18:37:52 gdt Exp $ */
+
+/*-
+ * Copyright (c) 2001, 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of Wasabi Systems, Inc.
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_TCP_TIMER_H_
+#define _NETINET_TCP_TIMER_H_
+
+/*
+ * Definitions of the TCP timers. These timers are counted
+ * down PR_SLOWHZ times a second.
+ */
+#define TCPT_NTIMERS 4
+
+#define TCPT_REXMT 0 /* retransmit */
+#define TCPT_PERSIST 1 /* retransmit persistance */
+#define TCPT_KEEP 2 /* keep alive */
+#define TCPT_2MSL 3 /* 2*msl quiet time timer */
+
+/*
+ * The TCPT_REXMT timer is used to force retransmissions.
+ * The TCP has the TCPT_REXMT timer set whenever segments
+ * have been sent for which ACKs are expected but not yet
+ * received. If an ACK is received which advances tp->snd_una,
+ * then the retransmit timer is cleared (if there are no more
+ * outstanding segments) or reset to the base value (if there
+ * are more ACKs expected). Whenever the retransmit timer goes off,
+ * we retransmit one unacknowledged segment, and do a backoff
+ * on the retransmit timer.
+ *
+ * The TCPT_PERSIST timer is used to keep window size information
+ * flowing even if the window goes shut. If all previous transmissions
+ * have been acknowledged (so that there are no retransmissions in progress),
+ * and the window is too small to bother sending anything, then we start
+ * the TCPT_PERSIST timer. When it expires, if the window is nonzero,
+ * we go to transmit state. Otherwise, at intervals send a single byte
+ * into the peer's window to force him to update our window information.
+ * We do this at most as often as TCPT_PERSMIN time intervals,
+ * but no more frequently than the current estimate of round-trip
+ * packet time. The TCPT_PERSIST timer is cleared whenever we receive
+ * a window update from the peer.
+ *
+ * The TCPT_KEEP timer is used to keep connections alive. If an
+ * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time,
+ * but not yet established, then we drop the connection. Once the connection
+ * is established, if the connection is idle for TCPTV_KEEP_IDLE time
+ * (and keepalives have been enabled on the socket), we begin to probe
+ * the connection. We force the peer to send us a segment by sending:
+ * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
+ * This segment is (deliberately) outside the window, and should elicit
+ * an ack segment in response from the peer. If, despite the TCPT_KEEP
+ * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
+ * amount of time probing, then we drop the connection.
+ */
+
+/*
+ * Time constants.
+ * All TCPTV_* constants are in units of slow ticks (typically 500 ms).
+ */
+#define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */
+#define TCPTV_SRTTBASE 0 /* base roundtrip time;
+ if 0, no idea yet */
+#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */
+
+#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */
+#define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */
+
+#define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */
+#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */
+#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */
+#define TCPTV_KEEPCNT 8 /* max probes before drop */
+
+#define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */
+#define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */
+
+#define TCP_LINGERTIME 120 /* linger at most 2 minutes */
+
+#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */
+
+/* Acks are delayed for 1 second; constant is in fast ticks. */
+#define TCP_DELACK_TICKS (hz / PR_FASTHZ) /* time to delay ACK */
+
+#ifdef TCPTIMERS
+const char *tcptimers[] =
+ { "REXMT", "PERSIST", "KEEP", "2MSL" };
+#endif
+
+/*
+ * Init, arm, disarm, and test TCP timers.
+ */
+#define TCP_TIMER_INIT(tp, timer) \
+ callout_setfunc(&(tp)->t_timer[(timer)], \
+ tcp_timer_funcs[(timer)], (tp))
+
+/*
+ * nticks is given in units of slow timeouts,
+ * typically 500 ms (with PR_SLOWHZ at 2).
+ */
+#define TCP_TIMER_ARM(tp, timer, nticks) \
+ callout_schedule(&(tp)->t_timer[(timer)], \
+ (nticks) * (hz / PR_SLOWHZ))
+
+#define TCP_TIMER_DISARM(tp, timer) \
+ callout_stop(&(tp)->t_timer[(timer)])
+
+#define TCP_TIMER_ISARMED(tp, timer) \
+ callout_active(&(tp)->t_timer[(timer)])
+
+/*
+ * Force a time value to be in a certain range.
+ */
+#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
+ (tv) = (value); \
+ if ((tv) < (tvmin)) \
+ (tv) = (tvmin); \
+ if ((tv) > (tvmax)) \
+ (tv) = (tvmax); \
+}
+
+#ifdef _KERNEL
+typedef void (*tcp_timer_func_t)(void *);
+
+extern const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS];
+
+extern u_int tcp_keepinit; /* time before initial connection times out */
+extern u_int tcp_keepidle; /* time before keepalive probes begin */
+extern u_int tcp_keepintvl; /* time between keepalive probes */
+extern u_int tcp_keepcnt; /* number of keepalives, 0=infty */
+extern int tcp_maxpersistidle; /* max idle time in persist */
+extern int tcp_ttl; /* time to live for TCP segs */
+extern const int tcp_backoff[];
+
+void tcp_timer_init(void);
+#endif
+
+#endif /* !_NETINET_TCP_TIMER_H_ */
--- /dev/null
+/* $NetBSD: tcp_var.h,v 1.177 2015/02/14 22:09:53 he Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
+ *
+ * NRL grants permission for redistribution and use in source and binary
+ * forms, with or without modification, of the software and documentation
+ * created at NRL 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgements:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * This product includes software developed at the Information
+ * Technology Division, US Naval Research Laboratory.
+ * 4. Neither the name of the NRL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL 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 NRL 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of the US Naval
+ * Research Laboratory (NRL).
+ */
+
+/*-
+ * Copyright (c) 1997, 1998, 1999, 2001, 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993, 1994, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
+ */
+
+#ifndef _NETINET_TCP_VAR_H_
+#define _NETINET_TCP_VAR_H_
+
+#if defined(_KERNEL_OPT)
+#include "opt_inet.h"
+#include "opt_mbuftrace.h"
+
+#endif
+
+/*
+ * Kernel variables for tcp.
+ */
+
+#include <sys/callout.h>
+
+#ifdef TCP_SIGNATURE
+/*
+ * Defines which are needed by the xform_tcp module and tcp_[in|out]put
+ * for SADB verification and lookup.
+ */
+#define TCP_SIGLEN 16 /* length of computed digest in bytes */
+#define TCP_KEYLEN_MIN 1 /* minimum length of TCP-MD5 key */
+#define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */
+/*
+ * Only a single SA per host may be specified at this time. An SPI is
+ * needed in order for the KEY_ALLOCSA() lookup to work.
+ */
+#define TCP_SIG_SPI 0x1000
+#endif /* TCP_SIGNATURE */
+
+/*
+ * SACK option block.
+ */
+struct sackblk {
+ tcp_seq left; /* Left edge of sack block. */
+ tcp_seq right; /* Right edge of sack block. */
+};
+
+TAILQ_HEAD(sackhead, sackhole);
+struct sackhole {
+ tcp_seq start;
+ tcp_seq end;
+ tcp_seq rxmit;
+
+ TAILQ_ENTRY(sackhole) sackhole_q;
+};
+
+/*
+ * Tcp control block, one per tcp; fields:
+ */
+struct tcpcb {
+ int t_family; /* address family on the wire */
+ struct ipqehead segq; /* sequencing queue */
+ int t_segqlen; /* length of the above */
+ callout_t t_timer[TCPT_NTIMERS];/* tcp timers */
+ short t_state; /* state of this connection */
+ short t_rxtshift; /* log(2) of rexmt exp. backoff */
+ uint32_t t_rxtcur; /* current retransmit value */
+ short t_dupacks; /* consecutive dup acks recd */
+ /*
+ * t_partialacks:
+ * <0 not in fast recovery.
+ * ==0 in fast recovery. has not received partial acks
+ * >0 in fast recovery. has received partial acks
+ */
+ short t_partialacks; /* partials acks during fast rexmit */
+ u_short t_peermss; /* peer's maximum segment size */
+ u_short t_ourmss; /* our's maximum segment size */
+ u_short t_segsz; /* current segment size in use */
+ char t_force; /* 1 if forcing out a byte */
+ u_int t_flags;
+#define TF_ACKNOW 0x0001 /* ack peer immediately */
+#define TF_DELACK 0x0002 /* ack, but try to delay it */
+#define TF_NODELAY 0x0004 /* don't delay packets to coalesce */
+#define TF_NOOPT 0x0008 /* don't use tcp options */
+#define TF_REQ_SCALE 0x0020 /* have/will request window scaling */
+#define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */
+#define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */
+#define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */
+#define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */
+#define TF_SYN_REXMT 0x0400 /* rexmit timer fired on SYN */
+#define TF_WILL_SACK 0x0800 /* try to use SACK */
+#define TF_REASSEMBLING 0x1000 /* we're busy reassembling */
+#define TF_DEAD 0x2000 /* dead and to-be-released */
+#define TF_PMTUD_PEND 0x4000 /* Path MTU Discovery pending */
+#define TF_ECN_PERMIT 0x10000 /* other side said is ECN-ready */
+#define TF_ECN_SND_CWR 0x20000 /* ECN CWR in queue */
+#define TF_ECN_SND_ECE 0x40000 /* ECN ECE in queue */
+#define TF_SIGNATURE 0x400000 /* require MD5 digests (RFC2385) */
+
+
+ struct mbuf *t_template; /* skeletal packet for transmit */
+ struct inpcb *t_inpcb; /* back pointer to internet pcb */
+ struct in6pcb *t_in6pcb; /* back pointer to internet pcb */
+ callout_t t_delack_ch; /* delayed ACK callout */
+/*
+ * The following fields are used as in the protocol specification.
+ * See RFC793, Dec. 1981, page 21.
+ */
+/* send sequence variables */
+ tcp_seq snd_una; /* send unacknowledged */
+ tcp_seq snd_nxt; /* send next */
+ tcp_seq snd_up; /* send urgent pointer */
+ tcp_seq snd_wl1; /* window update seg seq number */
+ tcp_seq snd_wl2; /* window update seg ack number */
+ tcp_seq iss; /* initial send sequence number */
+ u_long snd_wnd; /* send window */
+/*
+ * snd_recover
+ * it's basically same as the "recover" variable in RFC 2852 (NewReno).
+ * when entering fast retransmit, it's set to snd_max.
+ * newreno uses this to detect partial ack.
+ * snd_high
+ * it's basically same as the "send_high" variable in RFC 2852 (NewReno).
+ * on each RTO, it's set to snd_max.
+ * newreno uses this to avoid false fast retransmits.
+ */
+ tcp_seq snd_recover;
+ tcp_seq snd_high;
+/* receive sequence variables */
+ u_long rcv_wnd; /* receive window */
+ tcp_seq rcv_nxt; /* receive next */
+ tcp_seq rcv_up; /* receive urgent pointer */
+ tcp_seq irs; /* initial receive sequence number */
+/*
+ * Additional variables for this implementation.
+ */
+/* receive variables */
+ tcp_seq rcv_adv; /* advertised window */
+
+/*
+ * retransmit variables
+ *
+ * snd_max
+ * the highest sequence number we've ever sent.
+ * used to recognize retransmits.
+ */
+ tcp_seq snd_max;
+
+/* congestion control (for slow start, source quench, retransmit after loss) */
+ u_long snd_cwnd; /* congestion-controlled window */
+ u_long snd_ssthresh; /* snd_cwnd size threshhold for
+ * for slow start exponential to
+ * linear switch
+ */
+/* auto-sizing variables */
+ u_int rfbuf_cnt; /* recv buffer autoscaling byte count */
+ uint32_t rfbuf_ts; /* recv buffer autoscaling timestamp */
+
+/*
+ * transmit timing stuff. See below for scale of srtt and rttvar.
+ * "Variance" is actually smoothed difference.
+ */
+ uint32_t t_rcvtime; /* time last segment received */
+ uint32_t t_rtttime; /* time we started measuring rtt */
+ tcp_seq t_rtseq; /* sequence number being timed */
+ int32_t t_srtt; /* smoothed round-trip time */
+ int32_t t_rttvar; /* variance in round-trip time */
+ uint32_t t_rttmin; /* minimum rtt allowed */
+ u_long max_sndwnd; /* largest window peer has offered */
+
+/* out-of-band data */
+ char t_oobflags; /* have some */
+ char t_iobc; /* input character */
+#define TCPOOB_HAVEDATA 0x01
+#define TCPOOB_HADDATA 0x02
+ short t_softerror; /* possible error not yet reported */
+
+/* RFC 1323 variables */
+ u_char snd_scale; /* window scaling for send window */
+ u_char rcv_scale; /* window scaling for recv window */
+ u_char request_r_scale; /* pending window scaling */
+ u_char requested_s_scale;
+ u_int32_t ts_recent; /* timestamp echo data */
+ u_int32_t ts_recent_age; /* when last updated */
+ u_int32_t ts_timebase; /* our timebase */
+ tcp_seq last_ack_sent;
+
+/* RFC 3465 variables */
+ u_long t_bytes_acked; /* ABC "bytes_acked" parameter */
+
+/* SACK stuff */
+#define TCP_SACK_MAX 3
+#define TCPSACK_NONE 0
+#define TCPSACK_HAVED 1
+ u_char rcv_sack_flags; /* SACK flags. */
+ struct sackblk rcv_dsack_block; /* RX D-SACK block. */
+ struct ipqehead timeq; /* time sequenced queue. */
+ struct sackhead snd_holes; /* TX SACK holes. */
+ int snd_numholes; /* Number of TX SACK holes. */
+ tcp_seq rcv_lastsack; /* last seq number(+1) sack'd by rcv'r*/
+ tcp_seq sack_newdata; /* New data xmitted in this recovery
+ episode starts at this seq number*/
+ tcp_seq snd_fack; /* FACK TCP. Forward-most data held by
+ peer. */
+
+/* CUBIC variables */
+ ulong snd_cubic_wmax; /* W_max */
+ ulong snd_cubic_wmax_last; /* Used for fast convergence */
+ ulong snd_cubic_ctime; /* Last congestion time */
+
+/* pointer for syn cache entries*/
+ LIST_HEAD(, syn_cache) t_sc; /* list of entries by this tcb */
+
+/* prediction of next mbuf when using large window sizes */
+ struct mbuf *t_lastm; /* last mbuf that data was sent from */
+ int t_inoff; /* data offset in previous mbuf */
+ int t_lastoff; /* last data address in mbuf chain */
+ int t_lastlen; /* last length read from mbuf chain */
+
+/* Path-MTU discovery blackhole detection */
+ int t_mtudisc; /* perform mtudisc for this tcb */
+/* Path-MTU Discovery Information */
+ u_int t_pmtud_mss_acked; /* MSS acked, lower bound for MTU */
+ u_int t_pmtud_mtu_sent; /* MTU used, upper bound for MTU */
+ tcp_seq t_pmtud_th_seq; /* TCP SEQ from ICMP payload */
+ u_int t_pmtud_nextmtu; /* Advertised Next-Hop MTU from ICMP */
+ u_short t_pmtud_ip_len; /* IP length from ICMP payload */
+ u_short t_pmtud_ip_hl; /* IP header length from ICMP payload */
+
+ uint8_t t_ecn_retries; /* # of ECN setup retries */
+
+ const struct tcp_congctl *t_congctl; /* per TCB congctl algorithm */
+
+ /* Keepalive per socket */
+ u_int t_keepinit;
+ u_int t_keepidle;
+ u_int t_keepintvl;
+ u_int t_keepcnt;
+ u_int t_maxidle; /* t_keepcnt * t_keepintvl */
+
+ u_int t_msl; /* MSL to use for this connexion */
+
+ /* maintain a few stats per connection: */
+ uint32_t t_rcvoopack; /* out-of-order packets received */
+ uint32_t t_sndrexmitpack; /* retransmit packets sent */
+ uint32_t t_sndzerowin; /* zero-window updates sent */
+};
+
+/*
+ * Macros to aid ECN TCP.
+ */
+#define TCP_ECN_ALLOWED(tp) (tp->t_flags & TF_ECN_PERMIT)
+
+/*
+ * Macros to aid SACK/FACK TCP.
+ */
+#define TCP_SACK_ENABLED(tp) (tp->t_flags & TF_WILL_SACK)
+#define TCP_FACK_FASTRECOV(tp) \
+ (TCP_SACK_ENABLED(tp) && \
+ (SEQ_GT(tp->snd_fack, tp->snd_una + tcprexmtthresh * tp->t_segsz)))
+
+#ifdef _KERNEL
+/*
+ * TCP reassembly queue locks.
+ */
+static __inline int tcp_reass_lock_try (struct tcpcb *)
+ __unused;
+static __inline void tcp_reass_unlock (struct tcpcb *)
+ __unused;
+
+static __inline int
+tcp_reass_lock_try(struct tcpcb *tp)
+{
+ int s;
+
+ /*
+ * Use splvm() -- we're blocking things that would cause
+ * mbuf allocation.
+ */
+ s = splvm();
+ if (tp->t_flags & TF_REASSEMBLING) {
+ splx(s);
+ return (0);
+ }
+ tp->t_flags |= TF_REASSEMBLING;
+ splx(s);
+ return (1);
+}
+
+static __inline void
+tcp_reass_unlock(struct tcpcb *tp)
+{
+ int s;
+
+ s = splvm();
+ KASSERT((tp->t_flags & TF_REASSEMBLING) != 0);
+ tp->t_flags &= ~TF_REASSEMBLING;
+ splx(s);
+}
+
+#ifdef DIAGNOSTIC
+#define TCP_REASS_LOCK(tp) \
+do { \
+ if (tcp_reass_lock_try(tp) == 0) { \
+ printf("%s:%d: tcpcb %p reass already locked\n", \
+ __FILE__, __LINE__, tp); \
+ panic("tcp_reass_lock"); \
+ } \
+} while (/*CONSTCOND*/ 0)
+#define TCP_REASS_LOCK_CHECK(tp) \
+do { \
+ if (((tp)->t_flags & TF_REASSEMBLING) == 0) { \
+ printf("%s:%d: tcpcb %p reass lock not held\n", \
+ __FILE__, __LINE__, tp); \
+ panic("tcp reass lock check"); \
+ } \
+} while (/*CONSTCOND*/ 0)
+#else
+#define TCP_REASS_LOCK(tp) (void) tcp_reass_lock_try((tp))
+#define TCP_REASS_LOCK_CHECK(tp) /* nothing */
+#endif
+
+#define TCP_REASS_UNLOCK(tp) tcp_reass_unlock((tp))
+#endif /* _KERNEL */
+
+/*
+ * Queue for delayed ACK processing.
+ */
+#ifdef _KERNEL
+extern int tcp_delack_ticks;
+void tcp_delack(void *);
+
+#define TCP_RESTART_DELACK(tp) \
+ callout_reset(&(tp)->t_delack_ch, tcp_delack_ticks, \
+ tcp_delack, tp)
+
+#define TCP_SET_DELACK(tp) \
+do { \
+ if (((tp)->t_flags & TF_DELACK) == 0) { \
+ (tp)->t_flags |= TF_DELACK; \
+ TCP_RESTART_DELACK(tp); \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define TCP_CLEAR_DELACK(tp) \
+do { \
+ if ((tp)->t_flags & TF_DELACK) { \
+ (tp)->t_flags &= ~TF_DELACK; \
+ callout_stop(&(tp)->t_delack_ch); \
+ } \
+} while (/*CONSTCOND*/0)
+#endif /* _KERNEL */
+
+/*
+ * Compute the current timestamp for a connection.
+ */
+#define TCP_TIMESTAMP(tp) (tcp_now - (tp)->ts_timebase)
+
+/*
+ * Handy way of passing around TCP option info.
+ */
+struct tcp_opt_info {
+ int ts_present;
+ u_int32_t ts_val;
+ u_int32_t ts_ecr;
+ u_int16_t maxseg;
+};
+
+#define TOF_SIGNATURE 0x0040 /* signature option present */
+#define TOF_SIGLEN 0x0080 /* sigature length valid (RFC2385) */
+
+/*
+ * Data for the TCP compressed state engine.
+ */
+union syn_cache_sa {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+#if 1 /*def INET6*/
+ struct sockaddr_in6 sin6;
+#endif
+};
+
+struct syn_cache {
+ TAILQ_ENTRY(syn_cache) sc_bucketq; /* link on bucket list */
+ callout_t sc_timer; /* rexmt timer */
+ struct route sc_route;
+ long sc_win; /* advertised window */
+ int sc_bucketidx; /* our bucket index */
+ u_int32_t sc_hash;
+ u_int32_t sc_timestamp; /* timestamp from SYN */
+ u_int32_t sc_timebase; /* our local timebase */
+ union syn_cache_sa sc_src;
+ union syn_cache_sa sc_dst;
+ tcp_seq sc_irs;
+ tcp_seq sc_iss;
+ u_int sc_rxtcur; /* current rxt timeout */
+ u_int sc_rxttot; /* total time spend on queues */
+ u_short sc_rxtshift; /* for computing backoff */
+ u_short sc_flags;
+
+#define SCF_UNREACH 0x0001 /* we've had an unreach error */
+#define SCF_TIMESTAMP 0x0002 /* peer will do timestamps */
+#define SCF_DEAD 0x0004 /* this entry to be released */
+#define SCF_SACK_PERMIT 0x0008 /* peer will do SACK */
+#define SCF_ECN_PERMIT 0x0010 /* peer will do ECN */
+#define SCF_SIGNATURE 0x40 /* send MD5 digests */
+
+ struct mbuf *sc_ipopts; /* IP options */
+ u_int16_t sc_peermaxseg;
+ u_int16_t sc_ourmaxseg;
+ u_int8_t sc_request_r_scale : 4,
+ sc_requested_s_scale : 4;
+
+ struct tcpcb *sc_tp; /* tcb for listening socket */
+ LIST_ENTRY(syn_cache) sc_tpq; /* list of entries by same tp */
+};
+
+struct syn_cache_head {
+ TAILQ_HEAD(, syn_cache) sch_bucket; /* bucket entries */
+ u_short sch_length; /* # entries in bucket */
+};
+
+#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
+#ifdef INET6
+#define in6totcpcb(ip) ((struct tcpcb *)(ip)->in6p_ppcb)
+#endif
+#ifndef INET6
+#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
+#else
+#define sototcpcb(so) (((so)->so_proto->pr_domain->dom_family == AF_INET) \
+ ? intotcpcb(sotoinpcb(so)) \
+ : in6totcpcb(sotoin6pcb(so)))
+#endif
+
+/*
+ * See RFC2988 for a discussion of RTO calculation; comments assume
+ * familiarity with that document.
+ *
+ * The smoothed round-trip time and estimated variance are stored as
+ * fixed point numbers. Historically, srtt was scaled by
+ * TCP_RTT_SHIFT bits, and rttvar by TCP_RTTVAR_SHIFT bits. Because
+ * the values coincide with the alpha and beta parameters suggested
+ * for RTO calculation (1/8 for srtt, 1/4 for rttvar), the combination
+ * of computing 1/8 of the new value and transforming it to the
+ * fixed-point representation required zero instructions. However,
+ * the storage representations no longer coincide with the alpha/beta
+ * shifts; instead, more fractional bits are present.
+ *
+ * The storage representation of srtt is 1/32 slow ticks, or 1/64 s.
+ * (The assumption that a slow tick is 500 ms should not be present in
+ * the code.)
+ *
+ * The storage representation of rttvar is 1/16 slow ticks, or 1/32 s.
+ * There may be some confusion about this in the code.
+ *
+ * For historical reasons, these scales are also used in smoothing the
+ * average (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
+ * This results in alpha of 0.125 and beta of 0.25, following RFC2988
+ * section 2.3
+ *
+ * XXX Change SHIFT values to LGWEIGHT and REP_SHIFT, and adjust
+ * the code to use the correct ones.
+ */
+#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */
+#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */
+
+/*
+ * Compute TCP retransmission timer, following RFC2988.
+ * This macro returns a value in slow timeout ticks.
+ *
+ * Section 2.2 requires that the RTO value be
+ * srtt + max(G, 4*RTTVAR)
+ * where G is the clock granularity.
+ *
+ * This comment has not necessarily been updated for the new storage
+ * representation:
+ *
+ * Because of the way we do the smoothing, srtt and rttvar
+ * will each average +1/2 tick of bias. When we compute
+ * the retransmit timer, we want 1/2 tick of rounding and
+ * 1 extra tick because of +-1/2 tick uncertainty in the
+ * firing of the timer. The bias will give us exactly the
+ * 1.5 tick we need. But, because the bias is
+ * statistical, we have to test that we don't drop below
+ * the minimum feasible timer (which is 2 ticks).
+ * This macro assumes that the value of 1<<TCP_RTTVAR_SHIFT
+ * is the same as the multiplier for rttvar.
+ *
+ * This macro appears to be wrong; it should be checking rttvar*4 in
+ * ticks and making sure we use 1 instead if rttvar*4 rounds to 0. It
+ * appears to be treating srtt as being in the old storage
+ * representation, resulting in a factor of 4 extra.
+ */
+#define TCP_REXMTVAL(tp) \
+ ((((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) >> 2)
+
+/*
+ * Compute the initial window for slow start.
+ */
+#define TCP_INITIAL_WINDOW(iw, segsz) \
+ min((iw) * (segsz), max(2 * (segsz), tcp_init_win_max[(iw)]))
+
+/*
+ * TCP statistics.
+ * Each counter is an unsigned 64-bit value.
+ *
+ * Many of these should be kept per connection, but that's inconvenient
+ * at the moment.
+ */
+#define TCP_STAT_CONNATTEMPT 0 /* connections initiated */
+#define TCP_STAT_ACCEPTS 1 /* connections accepted */
+#define TCP_STAT_CONNECTS 2 /* connections established */
+#define TCP_STAT_DROPS 3 /* connections dropped */
+#define TCP_STAT_CONNDROPS 4 /* embryonic connections dropped */
+#define TCP_STAT_CLOSED 5 /* conn. closed (includes drops) */
+#define TCP_STAT_SEGSTIMED 6 /* segs where we tried to get rtt */
+#define TCP_STAT_RTTUPDATED 7 /* times we succeeded */
+#define TCP_STAT_DELACK 8 /* delayed ACKs sent */
+#define TCP_STAT_TIMEOUTDROP 9 /* conn. dropped in rxmt timeout */
+#define TCP_STAT_REXMTTIMEO 10 /* retransmit timeouts */
+#define TCP_STAT_PERSISTTIMEO 11 /* persist timeouts */
+#define TCP_STAT_KEEPTIMEO 12 /* keepalive timeouts */
+#define TCP_STAT_KEEPPROBE 13 /* keepalive probes sent */
+#define TCP_STAT_KEEPDROPS 14 /* connections dropped in keepalive */
+#define TCP_STAT_PERSISTDROPS 15 /* connections dropped in persist */
+#define TCP_STAT_CONNSDRAINED 16 /* connections drained due to memory
+ shortage */
+#define TCP_STAT_PMTUBLACKHOLE 17 /* PMTUD blackhole detected */
+#define TCP_STAT_SNDTOTAL 18 /* total packets sent */
+#define TCP_STAT_SNDPACK 19 /* data packlets sent */
+#define TCP_STAT_SNDBYTE 20 /* data bytes sent */
+#define TCP_STAT_SNDREXMITPACK 21 /* data packets retransmitted */
+#define TCP_STAT_SNDREXMITBYTE 22 /* data bytes retransmitted */
+#define TCP_STAT_SNDACKS 23 /* ACK-only packets sent */
+#define TCP_STAT_SNDPROBE 24 /* window probes sent */
+#define TCP_STAT_SNDURG 25 /* packets sent with URG only */
+#define TCP_STAT_SNDWINUP 26 /* window update-only packets sent */
+#define TCP_STAT_SNDCTRL 27 /* control (SYN|FIN|RST) packets sent */
+#define TCP_STAT_RCVTOTAL 28 /* total packets received */
+#define TCP_STAT_RCVPACK 29 /* packets received in sequence */
+#define TCP_STAT_RCVBYTE 30 /* bytes received in sequence */
+#define TCP_STAT_RCVBADSUM 31 /* packets received with cksum errs */
+#define TCP_STAT_RCVBADOFF 32 /* packets received with bad offset */
+#define TCP_STAT_RCVMEMDROP 33 /* packets dropped for lack of memory */
+#define TCP_STAT_RCVSHORT 34 /* packets received too short */
+#define TCP_STAT_RCVDUPPACK 35 /* duplicate-only packets received */
+#define TCP_STAT_RCVDUPBYTE 36 /* duplicate-only bytes received */
+#define TCP_STAT_RCVPARTDUPPACK 37 /* packets with some duplicate data */
+#define TCP_STAT_RCVPARTDUPBYTE 38 /* dup. bytes in part-dup. packets */
+#define TCP_STAT_RCVOOPACK 39 /* out-of-order packets received */
+#define TCP_STAT_RCVOOBYTE 40 /* out-of-order bytes received */
+#define TCP_STAT_RCVPACKAFTERWIN 41 /* packets with data after window */
+#define TCP_STAT_RCVBYTEAFTERWIN 42 /* bytes received after window */
+#define TCP_STAT_RCVAFTERCLOSE 43 /* packets received after "close" */
+#define TCP_STAT_RCVWINPROBE 44 /* rcvd window probe packets */
+#define TCP_STAT_RCVDUPACK 45 /* rcvd duplicate ACKs */
+#define TCP_STAT_RCVACKTOOMUCH 46 /* rcvd ACKs for unsent data */
+#define TCP_STAT_RCVACKPACK 47 /* rcvd ACK packets */
+#define TCP_STAT_RCVACKBYTE 48 /* bytes ACKed by rcvd ACKs */
+#define TCP_STAT_RCVWINUPD 49 /* rcvd window update packets */
+#define TCP_STAT_PAWSDROP 50 /* segments dropped due to PAWS */
+#define TCP_STAT_PREDACK 51 /* times hdr predict OK for ACKs */
+#define TCP_STAT_PREDDAT 52 /* times hdr predict OK for data pkts */
+#define TCP_STAT_PCBHASHMISS 53 /* input packets missing PCB hash */
+#define TCP_STAT_NOPORT 54 /* no socket on port */
+#define TCP_STAT_BADSYN 55 /* received ACK for which we have
+ no SYN in compressed state */
+#define TCP_STAT_DELAYED_FREE 56 /* delayed pool_put() of tcpcb */
+#define TCP_STAT_SC_ADDED 57 /* # of sc entries added */
+#define TCP_STAT_SC_COMPLETED 58 /* # of sc connections completed */
+#define TCP_STAT_SC_TIMED_OUT 59 /* # of sc entries timed out */
+#define TCP_STAT_SC_OVERFLOWED 60 /* # of sc drops due to overflow */
+#define TCP_STAT_SC_RESET 61 /* # of sc drops due to RST */
+#define TCP_STAT_SC_UNREACH 62 /* # of sc drops due to ICMP unreach */
+#define TCP_STAT_SC_BUCKETOVERFLOW 63 /* # of sc drops due to bucket ovflow */
+#define TCP_STAT_SC_ABORTED 64 /* # of sc entries aborted (no mem) */
+#define TCP_STAT_SC_DUPESYN 65 /* # of duplicate SYNs received */
+#define TCP_STAT_SC_DROPPED 66 /* # of SYNs dropped (no route/mem) */
+#define TCP_STAT_SC_COLLISIONS 67 /* # of sc hash collisions */
+#define TCP_STAT_SC_RETRANSMITTED 68 /* # of sc retransmissions */
+#define TCP_STAT_SC_DELAYED_FREE 69 /* # of delayed pool_put()s */
+#define TCP_STAT_SELFQUENCH 70 /* # of ENOBUFS we get on output */
+#define TCP_STAT_BADSIG 71 /* # of drops due to bad signature */
+#define TCP_STAT_GOODSIG 72 /* # of packets with good signature */
+#define TCP_STAT_ECN_SHS 73 /* # of successful ECN handshakes */
+#define TCP_STAT_ECN_CE 74 /* # of packets with CE bit */
+#define TCP_STAT_ECN_ECT 75 /* # of packets with ECT(0) bit */
+
+#define TCP_NSTATS 76
+
+/*
+ * Names for TCP sysctl objects.
+ */
+#define TCPCTL_RFC1323 1 /* RFC1323 timestamps/scaling */
+#define TCPCTL_SENDSPACE 2 /* default send buffer */
+#define TCPCTL_RECVSPACE 3 /* default recv buffer */
+#define TCPCTL_MSSDFLT 4 /* default seg size */
+#define TCPCTL_SYN_CACHE_LIMIT 5 /* max size of comp. state engine */
+#define TCPCTL_SYN_BUCKET_LIMIT 6 /* max size of hash bucket */
+#if 0 /*obsoleted*/
+#define TCPCTL_SYN_CACHE_INTER 7 /* interval of comp. state timer */
+#endif
+#define TCPCTL_INIT_WIN 8 /* initial window */
+#define TCPCTL_MSS_IFMTU 9 /* mss from interface, not in_maxmtu */
+#define TCPCTL_SACK 10 /* RFC2018 selective acknowledgement */
+#define TCPCTL_WSCALE 11 /* RFC1323 window scaling */
+#define TCPCTL_TSTAMP 12 /* RFC1323 timestamps */
+#define TCPCTL_COMPAT_42 13 /* 4.2BSD TCP bug work-arounds */
+#define TCPCTL_CWM 14 /* Congestion Window Monitoring */
+#define TCPCTL_CWM_BURSTSIZE 15 /* burst size allowed by CWM */
+#define TCPCTL_ACK_ON_PUSH 16 /* ACK immediately on PUSH */
+#define TCPCTL_KEEPIDLE 17 /* keepalive idle time */
+#define TCPCTL_KEEPINTVL 18 /* keepalive probe interval */
+#define TCPCTL_KEEPCNT 19 /* keepalive count */
+#define TCPCTL_SLOWHZ 20 /* PR_SLOWHZ (read-only) */
+#define TCPCTL_NEWRENO 21 /* NewReno Congestion Control */
+#define TCPCTL_LOG_REFUSED 22 /* Log refused connections */
+#if 0 /*obsoleted*/
+#define TCPCTL_RSTRATELIMIT 23 /* RST rate limit */
+#endif
+#define TCPCTL_RSTPPSLIMIT 24 /* RST pps limit */
+#define TCPCTL_DELACK_TICKS 25 /* # ticks to delay ACK */
+#define TCPCTL_INIT_WIN_LOCAL 26 /* initial window for local nets */
+#define TCPCTL_IDENT 27 /* rfc 931 identd */
+#define TCPCTL_ACKDROPRATELIMIT 28 /* SYN/RST -> ACK rate limit */
+#define TCPCTL_LOOPBACKCKSUM 29 /* do TCP checksum on loopback */
+#define TCPCTL_STATS 30 /* TCP statistics */
+#define TCPCTL_DEBUG 31 /* TCP debug sockets */
+#define TCPCTL_DEBX 32 /* # of tcp debug sockets */
+#define TCPCTL_DROP 33 /* drop tcp connection */
+#define TCPCTL_MSL 34 /* Max Segment Life */
+#define TCPCTL_MAXID 35
+
+#define TCPCTL_NAMES { \
+ { 0, 0 }, \
+ { "rfc1323", CTLTYPE_INT }, \
+ { "sendspace", CTLTYPE_INT }, \
+ { "recvspace", CTLTYPE_INT }, \
+ { "mssdflt", CTLTYPE_INT }, \
+ { "syn_cache_limit", CTLTYPE_INT }, \
+ { "syn_bucket_limit", CTLTYPE_INT }, \
+ { 0, 0 },\
+ { "init_win", CTLTYPE_INT }, \
+ { "mss_ifmtu", CTLTYPE_INT }, \
+ { "sack", CTLTYPE_INT }, \
+ { "win_scale", CTLTYPE_INT }, \
+ { "timestamps", CTLTYPE_INT }, \
+ { "compat_42", CTLTYPE_INT }, \
+ { "cwm", CTLTYPE_INT }, \
+ { "cwm_burstsize", CTLTYPE_INT }, \
+ { "ack_on_push", CTLTYPE_INT }, \
+ { "keepidle", CTLTYPE_INT }, \
+ { "keepintvl", CTLTYPE_INT }, \
+ { "keepcnt", CTLTYPE_INT }, \
+ { "slowhz", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "log_refused",CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "rstppslimit", CTLTYPE_INT }, \
+ { "delack_ticks", CTLTYPE_INT }, \
+ { "init_win_local", CTLTYPE_INT }, \
+ { "ident", CTLTYPE_STRUCT }, \
+ { "ackdropppslimit", CTLTYPE_INT }, \
+ { "do_loopback_cksum", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
+ { "debug", CTLTYPE_STRUCT }, \
+ { "debx", CTLTYPE_INT }, \
+ { "drop", CTLTYPE_STRUCT }, \
+ { "msl", CTLTYPE_INT }, \
+}
+
+#ifdef _KERNEL
+
+extern struct inpcbtable tcbtable; /* head of queue of active tcpcb's */
+extern const struct pr_usrreqs tcp_usrreqs;
+
+extern u_int32_t tcp_now; /* for RFC 1323 timestamps */
+extern int tcp_do_rfc1323; /* enabled/disabled? */
+extern int tcp_do_sack; /* SACK enabled/disabled? */
+extern int tcp_do_win_scale; /* RFC1323 window scaling enabled/disabled? */
+extern int tcp_do_timestamps; /* RFC1323 timestamps enabled/disabled? */
+extern int tcp_mssdflt; /* default seg size */
+extern int tcp_minmss; /* minimal seg size */
+extern int tcp_msl; /* max segment life */
+extern int tcp_init_win; /* initial window */
+extern int tcp_init_win_local; /* initial window for local nets */
+extern int tcp_init_win_max[11];/* max sizes for values of tcp_init_win_* */
+extern int tcp_mss_ifmtu; /* take MSS from interface, not in_maxmtu */
+extern int tcp_compat_42; /* work around ancient broken TCP peers */
+extern int tcp_cwm; /* enable Congestion Window Monitoring */
+extern int tcp_cwm_burstsize; /* burst size allowed by CWM */
+extern int tcp_ack_on_push; /* ACK immediately on PUSH */
+extern int tcp_syn_cache_limit; /* max entries for compressed state engine */
+extern int tcp_syn_bucket_limit;/* max entries per hash bucket */
+extern int tcp_log_refused; /* log refused connections */
+extern int tcp_do_ecn; /* TCP ECN enabled/disabled? */
+extern int tcp_ecn_maxretries; /* Max ECN setup retries */
+extern int tcp_do_rfc1948; /* ISS by cryptographic hash */
+extern int tcp_sack_tp_maxholes; /* Max holes per connection. */
+extern int tcp_sack_globalmaxholes; /* Max holes per system. */
+extern int tcp_sack_globalholes; /* Number of holes present. */
+extern int tcp_do_abc; /* RFC3465 ABC enabled/disabled? */
+extern int tcp_abc_aggressive; /* 1: L=2*SMSS 0: L=1*SMSS */
+
+extern int tcp_msl_enable; /* enable TIME_WAIT truncation */
+extern int tcp_msl_loop; /* MSL for loopback */
+extern int tcp_msl_local; /* MSL for 'local' */
+extern int tcp_msl_remote; /* MSL otherwise */
+extern int tcp_msl_remote_threshold; /* RTT threshold */
+extern int tcp_rttlocal; /* Use RTT to decide who's 'local' */
+extern int tcp4_vtw_enable;
+extern int tcp6_vtw_enable;
+extern int tcp_vtw_was_enabled;
+extern int tcp_vtw_entries;
+
+extern int tcp_rst_ppslim;
+extern int tcp_ackdrop_ppslim;
+
+extern int tcp_syn_cache_size;
+extern struct syn_cache_head tcp_syn_cache[];
+extern u_long syn_cache_count;
+
+#ifdef MBUFTRACE
+extern struct mowner tcp_rx_mowner;
+extern struct mowner tcp_tx_mowner;
+extern struct mowner tcp_reass_mowner;
+extern struct mowner tcp_sock_mowner;
+extern struct mowner tcp_sock_rx_mowner;
+extern struct mowner tcp_sock_tx_mowner;
+extern struct mowner tcp_mowner;
+#endif
+
+extern int tcp_do_autorcvbuf;
+extern int tcp_autorcvbuf_inc;
+extern int tcp_autorcvbuf_max;
+extern int tcp_do_autosndbuf;
+extern int tcp_autosndbuf_inc;
+extern int tcp_autosndbuf_max;
+
+
+#define TCPCTL_VARIABLES { \
+ { 0 }, \
+ { 1, 0, &tcp_do_rfc1323 }, \
+ { 1, 0, &tcp_sendspace }, \
+ { 1, 0, &tcp_recvspace }, \
+ { 1, 0, &tcp_mssdflt }, \
+ { 1, 0, &tcp_syn_cache_limit }, \
+ { 1, 0, &tcp_syn_bucket_limit }, \
+ { 0 }, \
+ { 1, 0, &tcp_init_win }, \
+ { 1, 0, &tcp_mss_ifmtu }, \
+ { 1, 0, &tcp_do_sack }, \
+ { 1, 0, &tcp_do_win_scale }, \
+ { 1, 0, &tcp_do_timestamps }, \
+ { 1, 0, &tcp_compat_42 }, \
+ { 1, 0, &tcp_cwm }, \
+ { 1, 0, &tcp_cwm_burstsize }, \
+ { 1, 0, &tcp_ack_on_push }, \
+ { 1, 0, &tcp_keepidle }, \
+ { 1, 0, &tcp_keepintvl }, \
+ { 1, 0, &tcp_keepcnt }, \
+ { 1, 1, 0, PR_SLOWHZ }, \
+ { 0 }, \
+ { 1, 0, &tcp_log_refused }, \
+ { 0 }, \
+ { 1, 0, &tcp_rst_ppslim }, \
+ { 1, 0, &tcp_delack_ticks }, \
+ { 1, 0, &tcp_init_win_local }, \
+ { 1, 0, &tcp_ackdrop_ppslim }, \
+}
+
+struct secasvar;
+
+void tcp_canceltimers(struct tcpcb *);
+struct tcpcb *
+ tcp_close(struct tcpcb *);
+int tcp_isdead(struct tcpcb *);
+#ifdef INET6
+void *tcp6_ctlinput(int, const struct sockaddr *, void *);
+#endif
+void *tcp_ctlinput(int, const struct sockaddr *, void *);
+int tcp_ctloutput(int, struct socket *, struct sockopt *);
+struct tcpcb *
+ tcp_disconnect1(struct tcpcb *);
+struct tcpcb *
+ tcp_drop(struct tcpcb *, int);
+#ifdef TCP_SIGNATURE
+int tcp_signature_apply(void *, void *, u_int);
+struct secasvar *tcp_signature_getsav(struct mbuf *, struct tcphdr *);
+int tcp_signature(struct mbuf *, struct tcphdr *, int, struct secasvar *,
+ char *);
+#endif
+void tcp_drain(void);
+void tcp_drainstub(void);
+void tcp_established(struct tcpcb *);
+void tcp_init(void);
+void tcp_init_common(unsigned);
+#ifdef INET6
+int tcp6_input(struct mbuf **, int *, int);
+#endif
+void tcp_input(struct mbuf *, ...);
+u_int tcp_hdrsz(struct tcpcb *);
+u_long tcp_mss_to_advertise(const struct ifnet *, int);
+void tcp_mss_from_peer(struct tcpcb *, int);
+void tcp_tcpcb_template(void);
+struct tcpcb *
+ tcp_newtcpcb(int, void *);
+void tcp_notify(struct inpcb *, int);
+#ifdef INET6
+void tcp6_notify(struct in6pcb *, int);
+#endif
+u_int tcp_optlen(struct tcpcb *);
+int tcp_output(struct tcpcb *);
+void tcp_pulloutofband(struct socket *,
+ struct tcphdr *, struct mbuf *, int);
+void tcp_quench(struct inpcb *, int);
+#ifdef INET6
+void tcp6_quench(struct in6pcb *, int);
+#endif
+void tcp_mtudisc(struct inpcb *, int);
+#ifdef INET6
+void tcp6_mtudisc_callback(struct in6_addr *);
+#endif
+
+void tcpipqent_init(void);
+struct ipqent *tcpipqent_alloc(void);
+void tcpipqent_free(struct ipqent *);
+
+int tcp_respond(struct tcpcb *, struct mbuf *, struct mbuf *,
+ struct tcphdr *, tcp_seq, tcp_seq, int);
+void tcp_rmx_rtt(struct tcpcb *);
+void tcp_setpersist(struct tcpcb *);
+#ifdef TCP_SIGNATURE
+int tcp_signature_compute(struct mbuf *, struct tcphdr *, int, int,
+ int, u_char *, u_int);
+#endif
+void tcp_slowtimo(void *);
+extern callout_t tcp_slowtimo_ch;
+void tcp_fasttimo(void);
+struct mbuf *
+ tcp_template(struct tcpcb *);
+void tcp_trace(short, short, struct tcpcb *, struct mbuf *, int);
+struct tcpcb *
+ tcp_usrclosed(struct tcpcb *);
+void tcp_usrreq_init(void);
+void tcp_xmit_timer(struct tcpcb *, uint32_t);
+tcp_seq tcp_new_iss(struct tcpcb *, tcp_seq);
+tcp_seq tcp_new_iss1(void *, void *, u_int16_t, u_int16_t, size_t,
+ tcp_seq);
+
+void tcp_sack_init(void);
+void tcp_new_dsack(struct tcpcb *, tcp_seq, u_int32_t);
+void tcp_sack_option(struct tcpcb *, const struct tcphdr *,
+ const u_char *, int);
+void tcp_del_sackholes(struct tcpcb *, const struct tcphdr *);
+void tcp_free_sackholes(struct tcpcb *);
+void tcp_sack_adjust(struct tcpcb *tp);
+struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt);
+int tcp_sack_numblks(const struct tcpcb *);
+#define TCP_SACK_OPTLEN(nblks) ((nblks) * 8 + 2 + 2)
+
+void tcp_statinc(u_int);
+void tcp_statadd(u_int, uint64_t);
+
+int syn_cache_add(struct sockaddr *, struct sockaddr *,
+ struct tcphdr *, unsigned int, struct socket *,
+ struct mbuf *, u_char *, int, struct tcp_opt_info *);
+void syn_cache_unreach(const struct sockaddr *, const struct sockaddr *,
+ struct tcphdr *);
+struct socket *syn_cache_get(struct sockaddr *, struct sockaddr *,
+ struct tcphdr *, unsigned int, unsigned int,
+ struct socket *so, struct mbuf *);
+void syn_cache_init(void);
+void syn_cache_insert(struct syn_cache *, struct tcpcb *);
+struct syn_cache *syn_cache_lookup(const struct sockaddr *, const struct sockaddr *,
+ struct syn_cache_head **);
+void syn_cache_reset(struct sockaddr *, struct sockaddr *,
+ struct tcphdr *);
+int syn_cache_respond(struct syn_cache *, struct mbuf *);
+void syn_cache_timer(void *);
+void syn_cache_cleanup(struct tcpcb *);
+
+int tcp_input_checksum(int, struct mbuf *, const struct tcphdr *, int, int,
+ int);
+#endif
+
+#endif /* !_NETINET_TCP_VAR_H_ */
--- /dev/null
+/* $NetBSD: tcp_vtw.h,v 1.6 2012/11/23 14:48:31 joerg Exp $ */
+/*
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Coyote Point Systems, Inc.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Vestigial time-wait.
+ *
+ * This implementation uses cache-efficient techniques, which will
+ * appear somewhat peculiar. The main philosophy is to optimise the
+ * amount of information available within a cache line. Cache miss is
+ * expensive. So we employ ad-hoc techniques to pull a series of
+ * linked-list follows into a cache line. One cache line, multiple
+ * linked-list equivalents.
+ *
+ * One such ad-hoc technique is fat pointers. Additional degrees of
+ * ad-hoqueness result from having to hand tune it for pointer size
+ * and for cache line size.
+ *
+ * The 'fat pointer' approach aggregates, for x86_32, 15 linked-list
+ * data structures into one cache line. The additional 32 bits in the
+ * cache line are used for linking fat pointers, and for
+ * allocation/bookkeeping.
+ *
+ * The 15 32-bit tags encode the pointers to the linked list elements,
+ * and also encode the results of a search comparison.
+ *
+ * First, some more assumptions/restrictions.
+ *
+ * All the fat pointers are from a contiguous allocation arena. Thus,
+ * we can refer to them by offset from a base, not as full pointers.
+ *
+ * All the linked list data elements are also from a contiguous
+ * allocation arena, again so that we can refer to them as offset from
+ * a base.
+ *
+ * In order to add a data element to a fat pointer, a key value is
+ * computed, based on unique data within the data element. It is the
+ * linear searching of the linked lists of these elements based on
+ * these unique data that are being optimised here.
+ *
+ * Lets call the function that computes the key k(e), where e is the
+ * data element. In this example, k(e) returns 32-bits.
+ *
+ * Consider a set E (say of order 15) of data elements. Let K be
+ * the set of the k(e) for e in E.
+ *
+ * Let O be the set of the offsets from the base of the data elements in E.
+ *
+ * For each x in K, for each matching o in O, let t be x ^ o. These
+ * are the tags. (More or less).
+ *
+ * In order to search all the data elements in E, we compute the
+ * search key, and one at a time, XOR the key into the tags. If any
+ * result is a valid data element index, we have a possible match. If
+ * not, there is no match.
+ *
+ * The no-match cases mean we do not have to de-reference the pointer
+ * to the data element in question. We save cache miss penalty and
+ * cache load decreases. Only in the case of a valid looking data
+ * element index, do we have to look closer.
+ *
+ * Thus, in the absence of false positives, 15 data elements can be
+ * searched with one cache line fill, as opposed to 15 cache line
+ * fills for the usual implementation.
+ *
+ * The vestigial time waits (vtw_t), the data elements in the above, are
+ * searched by faddr, fport, laddr, lport. The key is a function of
+ * these values.
+ *
+ * We hash these keys into the traditional hash chains to reduce the
+ * search time, and use fat pointers to reduce the cache impacts of
+ * searching.
+ *
+ * The vtw_t are, per requirement, in a contiguous chunk. Allocation
+ * is done with a clock hand, and all vtw_t within one allocation
+ * domain have the same lifetime, so they will always be sorted by
+ * age.
+ *
+ * A vtw_t will be allocated, timestamped, and have a fixed future
+ * expiration. It will be added to a hash bucket implemented with fat
+ * pointers, which means that a cache line will be allocated in the
+ * hash bucket, placed at the head (more recent in time) and the vtw_t
+ * will be added to this. As more entries are added, the fat pointer
+ * cache line will fill, requiring additional cache lines for fat
+ * pointers to be allocated. These will be added at the head, and the
+ * aged entries will hang down, tapeworm like. As the vtw_t entries
+ * expire, the corresponding slot in the fat pointer will be
+ * reclaimed, and eventually the cache line will completely empty and
+ * be re-cycled, if not at the head of the chain.
+ *
+ * At times, a time-wait timer is restarted. This corresponds to
+ * deleting the current entry and re-adding it.
+ *
+ * Most of the time, they are just placed here to die.
+ */
+#ifndef _NETINET_TCP_VTW_H
+#define _NETINET_TCP_VTW_H
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <net/if.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/in_pcb.h>
+#include <netinet/in_var.h>
+#include <netinet/ip_var.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_timer.h>
+#include <netinet/tcp_var.h>
+#include <netinet6/in6.h>
+#include <netinet/ip6.h>
+#include <netinet6/ip6_var.h>
+#include <netinet6/in6_pcb.h>
+#include <netinet6/ip6_var.h>
+#include <netinet6/in6_var.h>
+#include <netinet/icmp6.h>
+#include <netinet6/nd6.h>
+
+#define VTW_NCLASS (1+3) /* # different classes */
+
+/*
+ * fat pointers, MI.
+ */
+struct fatp_mi;
+
+typedef uint32_t fatp_word_t;
+
+typedef struct fatp_mi fatp_t;
+
+/* Supported cacheline sizes: 32 64 128 bytes. See fatp_key(),
+ * fatp_slot_from_key(), fatp_xtra[].
+ */
+#define FATP_NTAGS (CACHE_LINE_SIZE / sizeof(fatp_word_t) - 1)
+#define FATP_NXT_WIDTH (sizeof(fatp_word_t) * NBBY - FATP_NTAGS)
+
+#define FATP_MAX (1 << FATP_NXT_WIDTH)
+
+/* Worked example: ULP32 with 64-byte cacheline (32-bit x86):
+ * 15 tags per cacheline. At most 2^17 fat pointers per fatp_ctl_t.
+ * The comments on the fatp_mi members, below, correspond to the worked
+ * example.
+ */
+struct fatp_mi {
+ fatp_word_t inuse : FATP_NTAGS; /* (1+15)*4 == CL_SIZE */
+ fatp_word_t nxt : FATP_NXT_WIDTH;/* at most 2^17 fat pointers */
+ fatp_word_t tag[FATP_NTAGS]; /* 15 tags per CL */
+};
+
+static inline int
+fatp_ntags(void)
+{
+ return FATP_NTAGS;
+}
+
+static inline int
+fatp_full(fatp_t *fp)
+{
+ fatp_t full;
+
+ full.inuse = (1U << FATP_NTAGS) - 1U;
+
+ return (fp->inuse == full.inuse);
+}
+
+struct vtw_common;
+struct vtw_v4;
+struct vtw_v6;
+struct vtw_ctl;
+
+/*!\brief common to all vtw
+ */
+typedef struct vtw_common {
+ struct timeval expire; /* date of birth+msl */
+ uint32_t key; /* hash key: full hash */
+ uint32_t port_key; /* hash key: local port hash */
+ uint32_t rcv_nxt;
+ uint32_t rcv_wnd;
+ uint32_t snd_nxt;
+ uint32_t snd_scale : 8; /* window scaling for send win */
+ uint32_t msl_class : 2; /* TCP MSL class {0,1,2,3} */
+ uint32_t reuse_port : 1;
+ uint32_t reuse_addr : 1;
+ uint32_t v6only : 1;
+ uint32_t hashed : 1; /* reachable via FATP */
+ uint32_t uid;
+} vtw_t;
+
+/*!\brief vestigial timewait for IPv4
+ */
+typedef struct vtw_v4 {
+ vtw_t common; /* must be first */
+ uint16_t lport;
+ uint16_t fport;
+ uint32_t laddr;
+ uint32_t faddr;
+} vtw_v4_t;
+
+/*!\brief vestigial timewait for IPv6
+ */
+typedef struct vtw_v6 {
+ vtw_t common; /* must be first */
+ uint16_t lport;
+ uint16_t fport;
+ struct in6_addr laddr;
+ struct in6_addr faddr;
+} vtw_v6_t;
+
+struct fatp_ctl;
+typedef struct vtw_ctl vtw_ctl_t;
+typedef struct fatp_ctl fatp_ctl_t;
+
+/*
+ * The vestigial time waits are kept in a contiguous chunk.
+ * Allocation and free pointers run as clock hands thru this array.
+ */
+struct vtw_ctl {
+ fatp_ctl_t *fat; /* collection of fatp to use */
+ vtw_ctl_t *ctl; /* <! controller's controller */
+ union {
+ vtw_t *v; /* common */
+ struct vtw_v4 *v4; /* IPv4 resources */
+ struct vtw_v6 *v6; /* IPv6 resources */
+ } base, /* base of vtw_t array */
+ /**/ lim, /* extent of vtw_t array */
+ /**/ alloc, /* allocation pointer */
+ /**/ oldest; /* ^ to oldest */
+ uint32_t nfree; /* # free */
+ uint32_t nalloc; /* # allocated */
+ uint32_t idx_mask; /* mask capturing all index bits*/
+ uint32_t is_v4 : 1;
+ uint32_t is_v6 : 1;
+ uint32_t idx_bits: 6;
+ uint32_t clidx : 3; /* <! class index */
+};
+
+/*!\brief Collections of fat pointers.
+ */
+struct fatp_ctl {
+ vtw_ctl_t *vtw; /* associated VTWs */
+ fatp_t *base; /* base of fatp_t array */
+ fatp_t *lim; /* extent of fatp_t array */
+ fatp_t *free; /* free list */
+ uint32_t mask; /* hash mask */
+ uint32_t nfree; /* # free */
+ uint32_t nalloc; /* # allocated */
+ fatp_t **hash; /* hash anchors */
+ fatp_t **port; /* port hash anchors */
+};
+
+/*!\brief stats
+ */
+struct vtw_stats {
+ uint64_t ins; /* <! inserts */
+ uint64_t del; /* <! deleted */
+ uint64_t kill; /* <! assassination */
+ uint64_t look[2]; /* <! lookup: full hash, port hash */
+ uint64_t hit[2]; /* <! lookups that hit */
+ uint64_t miss[2]; /* <! lookups that miss */
+ uint64_t probe[2]; /* <! hits+miss */
+ uint64_t losing[2]; /* <! misses requiring dereference */
+ uint64_t max_chain[2]; /* <! max fatp chain traversed */
+ uint64_t max_probe[2]; /* <! max probes in any one chain */
+ uint64_t max_loss[2]; /* <! max losing probes in any one
+ * chain
+ */
+};
+
+typedef struct vtw_stats vtw_stats_t;
+
+/*!\brief follow fatp next 'pointer'
+ */
+static inline fatp_t *
+fatp_next(fatp_ctl_t *fat, fatp_t *fp)
+{
+ return fp->nxt ? fat->base + fp->nxt-1 : 0;
+}
+
+/*!\brief determine a collection-relative fat pointer index.
+ */
+static inline uint32_t
+fatp_index(fatp_ctl_t *fat, fatp_t *fp)
+{
+ return fp ? 1 + (fp - fat->base) : 0;
+}
+
+
+static inline uint32_t
+v4_tag(uint32_t faddr, uint32_t fport, uint32_t laddr, uint32_t lport)
+{
+ return (ntohl(faddr) + ntohs(fport)
+ + ntohl(laddr) + ntohs(lport));
+}
+
+static inline uint32_t
+v6_tag(const struct in6_addr *faddr, uint16_t fport,
+ const struct in6_addr *laddr, uint16_t lport)
+{
+#ifdef IN6_HASH
+ return IN6_HASH(faddr, fport, laddr, lport);
+#else
+ return 0;
+#endif
+}
+
+static inline uint32_t
+v4_port_tag(uint16_t lport)
+{
+ uint32_t tag = lport ^ (lport << 11);
+
+ tag ^= tag << 3;
+ tag += tag >> 5;
+ tag ^= tag << 4;
+ tag += tag >> 17;
+ tag ^= tag << 25;
+ tag += tag >> 6;
+
+ return tag;
+}
+
+static inline uint32_t
+v6_port_tag(uint16_t lport)
+{
+ return v4_port_tag(lport);
+}
+
+struct tcpcb;
+struct tcphdr;
+
+int vtw_add(int, struct tcpcb *);
+void vtw_del(vtw_ctl_t *, vtw_t *);
+int vtw_lookup_v4(const struct ip *ip, const struct tcphdr *th,
+ uint32_t faddr, uint16_t fport,
+ uint32_t laddr, uint16_t lport);
+struct ip6_hdr;
+struct in6_addr;
+
+int vtw_lookup_v6(const struct ip6_hdr *ip, const struct tcphdr *th,
+ const struct in6_addr *faddr, uint16_t fport,
+ const struct in6_addr *laddr, uint16_t lport);
+
+typedef struct vestigial_inpcb {
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ } faddr, laddr;
+ uint16_t fport, lport;
+ uint32_t valid : 1;
+ uint32_t v4 : 1;
+ uint32_t reuse_addr : 1;
+ uint32_t reuse_port : 1;
+ uint32_t v6only : 1;
+ uint32_t more_tbd : 1;
+ uint32_t uid;
+ uint32_t rcv_nxt;
+ uint32_t rcv_wnd;
+ uint32_t snd_nxt;
+ struct vtw_common *vtw;
+ struct vtw_ctl *ctl;
+} vestigial_inpcb_t;
+
+#ifdef _KERNEL
+void vtw_restart(vestigial_inpcb_t*);
+int vtw_earlyinit(void);
+int sysctl_tcp_vtw_enable(SYSCTLFN_PROTO);
+#endif /* _KERNEL */
+
+#ifdef VTW_DEBUG
+typedef struct sin_either {
+ uint8_t sin_len;
+ uint8_t sin_family;
+ uint16_t sin_port;
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ } sin_addr;
+} sin_either_t;
+
+int vtw_debug_add(int af, sin_either_t *, sin_either_t *, int, int);
+
+typedef struct vtw_sysargs {
+ uint32_t op;
+ sin_either_t fa;
+ sin_either_t la;
+} vtw_sysargs_t;
+
+#endif /* VTW_DEBUG */
+
+#endif /* _NETINET_TCP_VTW_H */
--- /dev/null
+/* $NetBSD: tcpip.h,v 1.11 2007/12/25 18:33:47 perry Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)tcpip.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_TCPIP_H_
+#define _NETINET_TCPIP_H_
+
+/*
+ * Tcp+ip header, after ip options removed.
+ */
+struct tcpiphdr {
+ struct ipovly ti_i; /* overlaid ip structure */
+ struct tcphdr ti_t; /* tcp header */
+} __packed;
+#define ti_x1 ti_i.ih_x1
+#define ti_pr ti_i.ih_pr
+#define ti_len ti_i.ih_len
+#define ti_src ti_i.ih_src
+#define ti_dst ti_i.ih_dst
+#define ti_sport ti_t.th_sport
+#define ti_dport ti_t.th_dport
+#define ti_seq ti_t.th_seq
+#define ti_ack ti_t.th_ack
+#define ti_x2 ti_t.th_x2
+#define ti_off ti_t.th_off
+#define ti_flags ti_t.th_flags
+#define ti_win ti_t.th_win
+#define ti_sum ti_t.th_sum
+#define ti_urp ti_t.th_urp
+
+#endif /* !_NETINET_TCPIP_H_ */
INCSDIR= /usr/include/netinet6
#__MINIX:
-INCS= in6.h \
- \
- \
-
+INCS= in6.h in6_pcb.h \
+ in6_var.h ip6_mroute.h ip6_var.h \
+ nd6.h pim6_var.h \
+ raw_ip6.h udp6.h udp6_var.h
INCS+=
.include <bsd.kinc.mk>
(a)->ia6_lifetime.ia6t_vltime)
#endif
-#if !defined(__minix)
/*
* Options for use with [gs]etsockopt at the IPV6 level.
* First word of comment is data type; bool is stored in int.
#define IN6_PRINT(b, a) (in6_print((b), sizeof(b), (a)), (b))
int sin6_print(char *, size_t, const void *);
#endif
-#endif /* !defined(__minix) */
#endif /* !_NETINET6_IN6_H_ */
--- /dev/null
+/* $NetBSD: in6_pcb.h,v 1.46 2015/05/24 15:43:45 rtr Exp $ */
+/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET6_IN6_PCB_H_
+#define _NETINET6_IN6_PCB_H_
+
+#include <sys/queue.h>
+#include <netinet/in_pcb_hdr.h>
+#include <netinet/ip6.h>
+
+/*
+ * Common structure pcb for internet protocol implementation.
+ * Here are stored pointers to local and foreign host table
+ * entries, local and foreign socket numbers, and pointers
+ * up (to a socket structure) and down (to a protocol-specific)
+ * control block.
+ */
+struct icmp6_filter;
+
+struct in6pcb {
+ struct inpcb_hdr in6p_head;
+#define in6p_hash in6p_head.inph_hash
+#define in6p_queue in6p_head.inph_queue
+#define in6p_af in6p_head.inph_af
+#define in6p_ppcb in6p_head.inph_ppcb
+#define in6p_state in6p_head.inph_state
+#define in6p_portalgo in6p_head.inph_portalgo
+#define in6p_socket in6p_head.inph_socket
+#define in6p_table in6p_head.inph_table
+#define in6p_sp in6p_head.inph_sp
+ struct route in6p_route; /* placeholder for routing entry */
+ u_int16_t in6p_fport; /* foreign port */
+ u_int16_t in6p_lport; /* local port */
+ u_int32_t in6p_flowinfo; /* priority and flowlabel */
+ int in6p_flags; /* generic IP6/datagram flags */
+ int in6p_hops; /* default hop limit */
+ struct ip6_hdr in6p_ip6; /* header prototype */
+ struct mbuf *in6p_options; /* IP6 options */
+ struct ip6_pktopts *in6p_outputopts; /* IP6 options for outgoing packets */
+ struct ip6_moptions *in6p_moptions; /* IP6 multicast options */
+ struct icmp6_filter *in6p_icmp6filt;
+ int in6p_cksum; /* IPV6_CHECKSUM setsockopt */
+ bool in6p_bindportonsend;
+ struct ip_moptions *in6p_v4moptions;/* IP4 multicast options */
+};
+
+#define in6p_faddr in6p_ip6.ip6_dst
+#define in6p_laddr in6p_ip6.ip6_src
+
+/* states in inp_state: */
+#define IN6P_ATTACHED INP_ATTACHED
+#define IN6P_BOUND INP_BOUND
+#define IN6P_CONNECTED INP_CONNECTED
+
+/*
+ * Flags in in6p_flags
+ * We define KAME's original flags in higher 16 bits as much as possible
+ * for compatibility with *bsd*s.
+ */
+#define IN6P_RECVOPTS 0x001000 /* receive incoming IP6 options */
+#define IN6P_RECVRETOPTS 0x002000 /* receive IP6 options for reply */
+#define IN6P_RECVDSTADDR 0x004000 /* receive IP6 dst address */
+#define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */
+#define IN6P_PKTINFO 0x010000 /* receive IP6 dst and I/F */
+#define IN6P_HOPLIMIT 0x020000 /* receive hoplimit */
+#define IN6P_HOPOPTS 0x040000 /* receive hop-by-hop options */
+#define IN6P_DSTOPTS 0x080000 /* receive dst options after rthdr */
+#define IN6P_RTHDR 0x100000 /* receive routing header */
+#define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */
+#define IN6P_TCLASS 0x400000 /* traffic class */
+
+#define IN6P_HIGHPORT 0x1000000 /* user wants "high" port binding */
+#define IN6P_LOWPORT 0x2000000 /* user wants "low" port binding */
+#define IN6P_ANONPORT 0x4000000 /* port chosen for user */
+#define IN6P_FAITH 0x8000000 /* accept FAITH'ed connections */
+
+#define IN6P_RFC2292 0x40000000 /* RFC2292 */
+#define IN6P_MTU 0x80000000 /* use minimum MTU */
+
+#define IN6P_CONTROLOPTS (IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
+ IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
+ IN6P_TCLASS|IN6P_RFC2292|\
+ IN6P_MTU)
+
+#ifdef _KERNEL
+/* compute hash value for foreign and local in6_addr and port */
+#define IN6_HASH(faddr, fport, laddr, lport) \
+ (((faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \
+ (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3] ^ \
+ (laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \
+ (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3]) \
+ + (fport) + (lport))
+
+#define sotoin6pcb(so) ((struct in6pcb *)(so)->so_pcb)
+
+void in6_losing(struct in6pcb *);
+void in6_pcbinit(struct inpcbtable *, int, int);
+int in6_pcballoc(struct socket *, void *);
+int in6_pcbbind(void *, struct sockaddr_in6 *, struct lwp *);
+int in6_pcbconnect(void *, struct sockaddr_in6 *, struct lwp *);
+void in6_pcbdetach(struct in6pcb *);
+void in6_pcbdisconnect(struct in6pcb *);
+struct in6pcb *in6_pcblookup_port(struct inpcbtable *, struct in6_addr *,
+ u_int, int, struct vestigial_inpcb *);
+int in6_pcbnotify(struct inpcbtable *, const struct sockaddr *,
+ u_int, const struct sockaddr *, u_int, int, void *,
+ void (*)(struct in6pcb *, int));
+void in6_pcbpurgeif0(struct inpcbtable *, struct ifnet *);
+void in6_pcbpurgeif(struct inpcbtable *, struct ifnet *);
+void in6_pcbstate(struct in6pcb *, int);
+void in6_rtchange(struct in6pcb *, int);
+void in6_setpeeraddr(struct in6pcb *, struct sockaddr_in6 *);
+void in6_setsockaddr(struct in6pcb *, struct sockaddr_in6 *);
+
+/* in in6_src.c */
+int in6_selecthlim(struct in6pcb *, struct ifnet *);
+int in6_selecthlim_rt(struct in6pcb *);
+int in6_pcbsetport(struct sockaddr_in6 *, struct in6pcb *, struct lwp *);
+
+extern struct rtentry *
+ in6_pcbrtentry(struct in6pcb *);
+extern struct in6pcb *in6_pcblookup_connect(struct inpcbtable *,
+ const struct in6_addr *, u_int, const struct in6_addr *, u_int, int,
+ struct vestigial_inpcb *);
+extern struct in6pcb *in6_pcblookup_bind(struct inpcbtable *,
+ const struct in6_addr *, u_int, int);
+#endif /* _KERNEL */
+
+#endif /* !_NETINET6_IN6_PCB_H_ */
--- /dev/null
+/* $NetBSD: in6_var.h,v 1.74 2015/09/06 06:01:01 dholland Exp $ */
+/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)in_var.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET6_IN6_VAR_H_
+#define _NETINET6_IN6_VAR_H_
+
+#include <sys/callout.h>
+#include <sys/ioccom.h>
+
+/*
+ * Interface address, Internet version. One of these structures
+ * is allocated for each interface with an Internet address.
+ * The ifaddr structure contains the protocol-independent part
+ * of the structure and is assumed to be first.
+ */
+
+/*
+ * pltime/vltime are just for future reference (required to implements 2
+ * hour rule for hosts). they should never be modified by nd6_timeout or
+ * anywhere else.
+ * userland -> kernel: accept pltime/vltime
+ * kernel -> userland: throw up everything
+ * in kernel: modify preferred/expire only
+ */
+struct in6_addrlifetime {
+ time_t ia6t_expire; /* valid lifetime expiration time */
+ time_t ia6t_preferred; /* preferred lifetime expiration time */
+ u_int32_t ia6t_vltime; /* valid lifetime */
+ u_int32_t ia6t_pltime; /* prefix lifetime */
+};
+
+struct nd_ifinfo;
+struct in6_ifextra {
+ struct in6_ifstat *in6_ifstat;
+ struct icmp6_ifstat *icmp6_ifstat;
+ struct nd_ifinfo *nd_ifinfo;
+ struct scope6_id *scope6_id;
+ int nprefixes;
+ int ndefrouters;
+};
+
+LIST_HEAD(in6_multihead, in6_multi);
+struct in6_ifaddr {
+ struct ifaddr ia_ifa; /* protocol-independent info */
+#define ia_ifp ia_ifa.ifa_ifp
+#define ia_flags ia_ifa.ifa_flags
+ struct sockaddr_in6 ia_addr; /* interface address */
+ struct sockaddr_in6 ia_net; /* network number of interface */
+ struct sockaddr_in6 ia_dstaddr; /* space for destination addr */
+ struct sockaddr_in6 ia_prefixmask; /* prefix mask */
+ u_int32_t ia_plen; /* prefix length */
+ struct in6_ifaddr *ia_next; /* next in6 list of IP6 addresses */
+ struct in6_multihead ia6_multiaddrs;
+ /* list of multicast addresses */
+ int ia6_flags;
+
+ struct in6_addrlifetime ia6_lifetime;
+ time_t ia6_createtime; /* the creation time of this address, which is
+ * currently used for temporary addresses only.
+ */
+ time_t ia6_updatetime;
+
+ /* back pointer to the ND prefix (for autoconfigured addresses only) */
+ struct nd_prefix *ia6_ndpr;
+
+ /* multicast addresses joined from the kernel */
+ LIST_HEAD(, in6_multi_mship) ia6_memberships;
+};
+
+/* control structure to manage address selection policy */
+struct in6_addrpolicy {
+ struct sockaddr_in6 addr; /* prefix address */
+ struct sockaddr_in6 addrmask; /* prefix mask */
+ int preced; /* precedence */
+ int label; /* matching label */
+ u_quad_t use; /* statistics */
+};
+
+/*
+ * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
+ */
+struct in6_ifstat {
+ u_quad_t ifs6_in_receive; /* # of total input datagram */
+ u_quad_t ifs6_in_hdrerr; /* # of datagrams with invalid hdr */
+ u_quad_t ifs6_in_toobig; /* # of datagrams exceeded MTU */
+ u_quad_t ifs6_in_noroute; /* # of datagrams with no route */
+ u_quad_t ifs6_in_addrerr; /* # of datagrams with invalid dst */
+ u_quad_t ifs6_in_protounknown; /* # of datagrams with unknown proto */
+ /* NOTE: increment on final dst if */
+ u_quad_t ifs6_in_truncated; /* # of truncated datagrams */
+ u_quad_t ifs6_in_discard; /* # of discarded datagrams */
+ /* NOTE: fragment timeout is not here */
+ u_quad_t ifs6_in_deliver; /* # of datagrams delivered to ULP */
+ /* NOTE: increment on final dst if */
+ u_quad_t ifs6_out_forward; /* # of datagrams forwarded */
+ /* NOTE: increment on outgoing if */
+ u_quad_t ifs6_out_request; /* # of outgoing datagrams from ULP */
+ /* NOTE: does not include forwrads */
+ u_quad_t ifs6_out_discard; /* # of discarded datagrams */
+ u_quad_t ifs6_out_fragok; /* # of datagrams fragmented */
+ u_quad_t ifs6_out_fragfail; /* # of datagrams failed on fragment */
+ u_quad_t ifs6_out_fragcreat; /* # of fragment datagrams */
+ /* NOTE: this is # after fragment */
+ u_quad_t ifs6_reass_reqd; /* # of incoming fragmented packets */
+ /* NOTE: increment on final dst if */
+ u_quad_t ifs6_reass_ok; /* # of reassembled packets */
+ /* NOTE: this is # after reass */
+ /* NOTE: increment on final dst if */
+ u_quad_t ifs6_reass_fail; /* # of reass failures */
+ /* NOTE: may not be packet count */
+ /* NOTE: increment on final dst if */
+ u_quad_t ifs6_in_mcast; /* # of inbound multicast datagrams */
+ u_quad_t ifs6_out_mcast; /* # of outbound multicast datagrams */
+};
+
+/*
+ * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
+ * XXX: I'm not sure if this file is the right place for this structure...
+ */
+struct icmp6_ifstat {
+ /*
+ * Input statistics
+ */
+ /* ipv6IfIcmpInMsgs, total # of input messages */
+ u_quad_t ifs6_in_msg;
+ /* ipv6IfIcmpInErrors, # of input error messages */
+ u_quad_t ifs6_in_error;
+ /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
+ u_quad_t ifs6_in_dstunreach;
+ /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
+ u_quad_t ifs6_in_adminprohib;
+ /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
+ u_quad_t ifs6_in_timeexceed;
+ /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
+ u_quad_t ifs6_in_paramprob;
+ /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
+ u_quad_t ifs6_in_pkttoobig;
+ /* ipv6IfIcmpInEchos, # of input echo requests */
+ u_quad_t ifs6_in_echo;
+ /* ipv6IfIcmpInEchoReplies, # of input echo replies */
+ u_quad_t ifs6_in_echoreply;
+ /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
+ u_quad_t ifs6_in_routersolicit;
+ /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
+ u_quad_t ifs6_in_routeradvert;
+ /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
+ u_quad_t ifs6_in_neighborsolicit;
+ /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
+ u_quad_t ifs6_in_neighboradvert;
+ /* ipv6IfIcmpInRedirects, # of input redirects */
+ u_quad_t ifs6_in_redirect;
+ /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
+ u_quad_t ifs6_in_mldquery;
+ /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
+ u_quad_t ifs6_in_mldreport;
+ /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
+ u_quad_t ifs6_in_mlddone;
+
+ /*
+ * Output statistics. We should solve unresolved routing problem...
+ */
+ /* ipv6IfIcmpOutMsgs, total # of output messages */
+ u_quad_t ifs6_out_msg;
+ /* ipv6IfIcmpOutErrors, # of output error messages */
+ u_quad_t ifs6_out_error;
+ /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
+ u_quad_t ifs6_out_dstunreach;
+ /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
+ u_quad_t ifs6_out_adminprohib;
+ /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
+ u_quad_t ifs6_out_timeexceed;
+ /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
+ u_quad_t ifs6_out_paramprob;
+ /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
+ u_quad_t ifs6_out_pkttoobig;
+ /* ipv6IfIcmpOutEchos, # of output echo requests */
+ u_quad_t ifs6_out_echo;
+ /* ipv6IfIcmpOutEchoReplies, # of output echo replies */
+ u_quad_t ifs6_out_echoreply;
+ /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
+ u_quad_t ifs6_out_routersolicit;
+ /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
+ u_quad_t ifs6_out_routeradvert;
+ /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
+ u_quad_t ifs6_out_neighborsolicit;
+ /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
+ u_quad_t ifs6_out_neighboradvert;
+ /* ipv6IfIcmpOutRedirects, # of output redirects */
+ u_quad_t ifs6_out_redirect;
+ /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
+ u_quad_t ifs6_out_mldquery;
+ /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
+ u_quad_t ifs6_out_mldreport;
+ /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
+ u_quad_t ifs6_out_mlddone;
+};
+
+/*
+ * If you make changes that change the size of in6_ifreq,
+ * make sure you fix compat/netinet6/in6_var.h
+ */
+struct in6_ifreq {
+ char ifr_name[IFNAMSIZ];
+ union {
+ struct sockaddr_in6 ifru_addr;
+ struct sockaddr_in6 ifru_dstaddr;
+ short ifru_flags;
+ int ifru_flags6;
+ int ifru_metric;
+ void * ifru_data;
+ struct in6_addrlifetime ifru_lifetime;
+ struct in6_ifstat ifru_stat;
+ struct icmp6_ifstat ifru_icmp6stat;
+ } ifr_ifru;
+};
+
+struct in6_aliasreq {
+ char ifra_name[IFNAMSIZ];
+ struct sockaddr_in6 ifra_addr;
+ struct sockaddr_in6 ifra_dstaddr;
+ struct sockaddr_in6 ifra_prefixmask;
+ int ifra_flags;
+ struct in6_addrlifetime ifra_lifetime;
+};
+
+/* prefix type macro */
+#define IN6_PREFIX_ND 1
+#define IN6_PREFIX_RR 2
+
+/*
+ * prefix related flags passed between kernel(NDP related part) and
+ * user land command(ifconfig) and daemon(rtadvd).
+ * Note: We originally intended to use prf_ra{} only within in6_prflags{}, but
+ * it was (probably unintentionally) used in nd6.h as well. Since C++ does
+ * not allow such a reference, prf_ra{} was then moved outside. In general,
+ * however, this structure should not be used directly.
+ */
+struct prf_ra {
+ u_int32_t onlink : 1;
+ u_int32_t autonomous : 1;
+ u_int32_t router : 1;
+ u_int32_t reserved : 5;
+};
+
+struct in6_prflags {
+ struct prf_ra prf_ra;
+ u_char prf_reserved1;
+ u_short prf_reserved2;
+ /* want to put this on 4byte offset */
+ struct prf_rr {
+ u_int32_t decrvalid : 1;
+ u_int32_t decrprefd : 1;
+ u_int32_t reserved : 6;
+ } prf_rr;
+ u_char prf_reserved3;
+ u_short prf_reserved4;
+};
+
+struct in6_prefixreq {
+ char ipr_name[IFNAMSIZ];
+ u_char ipr_origin;
+ u_char ipr_plen;
+ u_int32_t ipr_vltime;
+ u_int32_t ipr_pltime;
+ struct in6_prflags ipr_flags;
+ struct sockaddr_in6 ipr_prefix;
+};
+
+#define PR_ORIG_RA 0
+#define PR_ORIG_RR 1
+#define PR_ORIG_STATIC 2
+#define PR_ORIG_KERNEL 3
+
+#define ipr_raf_onlink ipr_flags.prf_ra.onlink
+#define ipr_raf_auto ipr_flags.prf_ra.autonomous
+
+#define ipr_statef_onlink ipr_flags.prf_state.onlink
+
+#define ipr_rrf_decrvalid ipr_flags.prf_rr.decrvalid
+#define ipr_rrf_decrprefd ipr_flags.prf_rr.decrprefd
+
+struct in6_rrenumreq {
+ char irr_name[IFNAMSIZ];
+ u_char irr_origin;
+ u_char irr_m_len; /* match len for matchprefix */
+ u_char irr_m_minlen; /* minlen for matching prefix */
+ u_char irr_m_maxlen; /* maxlen for matching prefix */
+ u_char irr_u_uselen; /* uselen for adding prefix */
+ u_char irr_u_keeplen; /* keeplen from matching prefix */
+ struct irr_raflagmask {
+ u_int32_t onlink : 1;
+ u_int32_t autonomous : 1;
+ u_int32_t reserved : 6;
+ } irr_raflagmask;
+ u_int32_t irr_vltime;
+ u_int32_t irr_pltime;
+ struct in6_prflags irr_flags;
+ struct sockaddr_in6 irr_matchprefix;
+ struct sockaddr_in6 irr_useprefix;
+};
+
+#define irr_raf_mask_onlink irr_raflagmask.onlink
+#define irr_raf_mask_auto irr_raflagmask.autonomous
+#define irr_raf_mask_reserved irr_raflagmask.reserved
+
+#define irr_raf_onlink irr_flags.prf_ra.onlink
+#define irr_raf_auto irr_flags.prf_ra.autonomous
+
+#define irr_statef_onlink irr_flags.prf_state.onlink
+
+#define irr_rrf irr_flags.prf_rr
+#define irr_rrf_decrvalid irr_flags.prf_rr.decrvalid
+#define irr_rrf_decrprefd irr_flags.prf_rr.decrprefd
+
+/*
+ * Given a pointer to an in6_ifaddr (ifaddr),
+ * return a pointer to the addr as a sockaddr_in6
+ */
+#define IA6_IN6(ia) (&((ia)->ia_addr.sin6_addr))
+#define IA6_DSTIN6(ia) (&((ia)->ia_dstaddr.sin6_addr))
+#define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr))
+#define IA6_SIN6(ia) (&((ia)->ia_addr))
+#define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr))
+#define IFA_IN6(x) (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
+#define IFA_DSTIN6(x) (&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
+
+#ifdef _KERNEL
+#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
+ (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
+ (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
+ (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
+ (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
+#endif
+
+#define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq)
+#define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq)
+
+#ifdef _KERNEL
+/*
+ * SIOCSxxx ioctls should be unused (see comments in in6.c), but
+ * we do not shift numbers for binary compatibility.
+ */
+#define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq)
+#define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq)
+#endif
+
+#define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq)
+#define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq)
+
+#define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
+/* 26 was OSIOCAIFADDR_IN6 */
+
+/* 70 was OSIOCSIFPHYADDR_IN6 */
+#define SIOCGIFPSRCADDR_IN6 _IOWR('i', 71, struct in6_ifreq)
+#define SIOCGIFPDSTADDR_IN6 _IOWR('i', 72, struct in6_ifreq)
+
+#define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
+
+#define SIOCGDRLST_IN6 _IOWR('i', 74, struct in6_drlist)
+#define SIOCGPRLST_IN6 _IOWR('i', 75, struct in6_oprlist)
+#ifdef _KERNEL
+#define OSIOCGIFINFO_IN6 _IOWR('i', 76, struct in6_ondireq)
+#endif
+#define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
+#define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)
+#define SIOCSPFXFLUSH_IN6 _IOWR('i', 79, struct in6_ifreq)
+#define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq)
+/* 81 was old SIOCGIFALIFETIME_IN6 */
+#if 0
+/* withdrawn - do not reuse number 82 */
+#define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq)
+#endif
+#define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq)
+#define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq)
+
+#define SIOCSDEFIFACE_IN6 _IOWR('i', 85, struct in6_ndifreq)
+#define SIOCGDEFIFACE_IN6 _IOWR('i', 86, struct in6_ndifreq)
+
+#define SIOCSIFINFO_FLAGS _IOWR('i', 87, struct in6_ndireq) /* XXX */
+
+#define SIOCSIFPREFIX_IN6 _IOW('i', 100, struct in6_prefixreq) /* set */
+#define SIOCGIFPREFIX_IN6 _IOWR('i', 101, struct in6_prefixreq) /* get */
+#define SIOCDIFPREFIX_IN6 _IOW('i', 102, struct in6_prefixreq) /* del */
+#define SIOCAIFPREFIX_IN6 _IOW('i', 103, struct in6_rrenumreq) /* add */
+#define SIOCCIFPREFIX_IN6 _IOW('i', 104, \
+ struct in6_rrenumreq) /* change */
+#define SIOCSGIFPREFIX_IN6 _IOW('i', 105, \
+ struct in6_rrenumreq) /* set global */
+#define SIOCGIFALIFETIME_IN6 _IOWR('i', 106, struct in6_ifreq)
+#define SIOCAIFADDR_IN6 _IOW('i', 107, struct in6_aliasreq)
+#define SIOCGIFINFO_IN6 _IOWR('i', 108, struct in6_ndireq)
+#define SIOCSIFINFO_IN6 _IOWR('i', 109, struct in6_ndireq)
+#define SIOCSIFPHYADDR_IN6 _IOW('i', 110, struct in6_aliasreq)
+
+
+/* XXX: Someone decided to switch to 'u' here for unknown reasons! */
+#define SIOCGETSGCNT_IN6 _IOWR('u', 106, \
+ struct sioc_sg_req6) /* get s,g pkt cnt */
+#define SIOCGETMIFCNT_IN6 _IOWR('u', 107, \
+ struct sioc_mif_req6) /* get pkt cnt per if */
+#define SIOCAADDRCTL_POLICY _IOW('u', 108, struct in6_addrpolicy)
+#define SIOCDADDRCTL_POLICY _IOW('u', 109, struct in6_addrpolicy)
+
+#define IN6_IFF_ANYCAST 0x01 /* anycast address */
+#define IN6_IFF_TENTATIVE 0x02 /* tentative address */
+#define IN6_IFF_DUPLICATED 0x04 /* DAD detected duplicate */
+#define IN6_IFF_DETACHED 0x08 /* may be detached from the link */
+#define IN6_IFF_DEPRECATED 0x10 /* deprecated address */
+#define IN6_IFF_NODAD 0x20 /* don't perform DAD on this address
+ * (used only at first SIOC* call)
+ */
+#define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */
+#define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */
+
+/* do not input/output */
+#define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
+
+#ifdef _KERNEL
+#define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
+#define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
+#endif
+
+#ifdef _KERNEL
+
+#include <net/pktqueue.h>
+
+extern pktqueue_t *ip6_pktq;
+
+MALLOC_DECLARE(M_IP6OPT);
+
+extern struct in6_ifaddr *in6_ifaddr;
+
+#define in6_ifstat_inc(ifp, tag) \
+do { \
+ if (ifp) \
+ ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \
+} while (/*CONSTCOND*/ 0)
+
+extern const struct in6_addr zeroin6_addr;
+extern const u_char inet6ctlerrmap[];
+extern unsigned long in6_maxmtu;
+extern bool in6_present;
+
+/*
+ * Macro for finding the internet address structure (in6_ifaddr) corresponding
+ * to a given interface (ifnet structure).
+ */
+static inline struct in6_ifaddr *
+ifp_to_ia6(struct ifnet *ifp)
+{
+ struct ifaddr *ifa;
+
+ IFADDR_FOREACH(ifa, ifp) {
+ if (ifa->ifa_addr == NULL)
+ continue;
+ if (ifa->ifa_addr->sa_family == AF_INET6)
+ break;
+ }
+ return (struct in6_ifaddr *)ifa;
+}
+
+#define IFP_TO_IA6(__ifp, __ia) \
+do { \
+ (__ia) = ifp_to_ia6((__ifp)); \
+} while (/*CONSTCOND*/0)
+
+
+#endif /* _KERNEL */
+
+/*
+ * Multi-cast membership entry. One for each group/ifp that a PCB
+ * belongs to.
+ */
+struct in6_multi_mship {
+ struct in6_multi *i6mm_maddr; /* Multicast address pointer */
+ LIST_ENTRY(in6_multi_mship) i6mm_chain; /* multicast options chain */
+};
+
+struct in6_multi {
+ LIST_ENTRY(in6_multi) in6m_entry; /* list glue */
+ struct in6_addr in6m_addr; /* IP6 multicast address */
+ struct ifnet *in6m_ifp; /* back pointer to ifnet */
+ struct in6_ifaddr *in6m_ia; /* back pointer to in6_ifaddr */
+ u_int in6m_refcount; /* # membership claims by sockets */
+ u_int in6m_state; /* state of the membership */
+ int in6m_timer; /* delay to send the 1st report */
+ struct timeval in6m_timer_expire; /* when the timer expires */
+ callout_t in6m_timer_ch;
+};
+
+#define IN6M_TIMER_UNDEF -1
+
+
+#ifdef _KERNEL
+/* flags to in6_update_ifa */
+#define IN6_IFAUPDATE_DADDELAY 0x1 /* first time to configure an address */
+
+/*
+ * Structure used by macros below to remember position when stepping through
+ * all of the in6_multi records.
+ */
+struct in6_multistep {
+ struct in6_ifaddr *i_ia;
+ struct in6_multi *i_in6m;
+};
+
+/*
+ * Macros for looking up the in6_multi record for a given IP6 multicast
+ * address on a given interface. If no matching record is found, "in6m"
+ * returns NULL.
+ */
+
+static inline struct in6_multi *
+in6_lookup_multi(struct in6_addr *addr, struct ifnet *ifp)
+{
+ struct in6_multi *in6m;
+ struct in6_ifaddr *ia;
+
+ if ((ia = ifp_to_ia6(ifp)) == NULL)
+ return NULL;
+ LIST_FOREACH(in6m, &ia->ia6_multiaddrs, in6m_entry) {
+ if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, addr))
+ break;
+ }
+ return in6m;
+}
+
+#define IN6_LOOKUP_MULTI(__addr, __ifp, __in6m) \
+/* struct in6_addr __addr; */ \
+/* struct ifnet *__ifp; */ \
+/* struct in6_multi *__in6m; */ \
+do { \
+ (__in6m) = in6_lookup_multi(&(__addr), (__ifp)); \
+} while (/*CONSTCOND*/ 0)
+
+/*
+ * Macro to step through all of the in6_multi records, one at a time.
+ * The current position is remembered in "step", which the caller must
+ * provide. IN6_FIRST_MULTI(), below, must be called to initialize "step"
+ * and get the first record. Both macros return a NULL "in6m" when there
+ * are no remaining records.
+ */
+static inline struct in6_multi *
+in6_next_multi(struct in6_multistep *step)
+{
+ struct in6_multi *in6m;
+
+ if ((in6m = step->i_in6m) != NULL) {
+ step->i_in6m = LIST_NEXT(in6m, in6m_entry);
+ return in6m;
+ }
+ while (step->i_ia != NULL) {
+ in6m = LIST_FIRST(&step->i_ia->ia6_multiaddrs);
+ step->i_ia = step->i_ia->ia_next;
+ if (in6m != NULL) {
+ step->i_in6m = LIST_NEXT(in6m, in6m_entry);
+ break;
+ }
+ }
+ return in6m;
+}
+
+static inline struct in6_multi *
+in6_first_multi(struct in6_multistep *step)
+{
+ step->i_ia = in6_ifaddr;
+ step->i_in6m = NULL;
+ return in6_next_multi(step);
+}
+
+#define IN6_NEXT_MULTI(__step, __in6m) \
+/* struct in6_multistep __step; */ \
+/* struct in6_multi *__in6m; */ \
+do { \
+ (__in6m) = in6_next_multi(&(__step)); \
+} while (/*CONSTCOND*/ 0)
+
+#define IN6_FIRST_MULTI(__step, __in6m) \
+/* struct in6_multistep __step; */ \
+/* struct in6_multi *__in6m */ \
+do { \
+ (__in6m) = in6_first_multi(&(__step)); \
+} while (/*CONSTCOND*/ 0)
+
+
+#if 0
+/*
+ * Macros for looking up the in6_multi_mship record for a given IP6 multicast
+ * address on a given interface. If no matching record is found, "imm"
+ * returns NULL.
+ */
+static inline struct in6_multi_mship *
+in6_lookup_mship(struct in6_addr *addr, struct ifnet *ifp,
+ struct ip6_moptions *imop)
+{
+ struct in6_multi_mship *imm;
+
+ LIST_FOREACH(imm, &imop->im6o_memberships, i6mm_chain) {
+ if (imm->i6mm_maddr->in6m_ifp != ifp)
+ continue;
+ if (IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr,
+ addr))
+ break;
+ }
+ return imm;
+}
+
+#define IN6_LOOKUP_MSHIP(__addr, __ifp, __imop, __imm) \
+/* struct in6_addr __addr; */ \
+/* struct ifnet *__ifp; */ \
+/* struct ip6_moptions *__imop */ \
+/* struct in6_multi_mship *__imm; */ \
+do { \
+ (__imm) = in6_lookup_mship(&(__addr), (__ifp), (__imop)); \
+} while (/*CONSTCOND*/ 0)
+#endif
+
+struct in6_multi *in6_addmulti(struct in6_addr *, struct ifnet *,
+ int *, int);
+void in6_delmulti(struct in6_multi *);
+struct in6_multi_mship *in6_joingroup(struct ifnet *, struct in6_addr *,
+ int *, int);
+int in6_leavegroup(struct in6_multi_mship *);
+int in6_mask2len(struct in6_addr *, u_char *);
+int in6_control(struct socket *, u_long, void *, struct ifnet *);
+int in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
+ struct in6_ifaddr *, int);
+void in6_purgeaddr(struct ifaddr *);
+void in6_purgeif(struct ifnet *);
+void in6_savemkludge(struct in6_ifaddr *);
+void in6_setmaxmtu (void);
+int in6_if2idlen (struct ifnet *);
+void *in6_domifattach(struct ifnet *);
+void in6_domifdetach(struct ifnet *, void *);
+void in6_restoremkludge(struct in6_ifaddr *, struct ifnet *);
+void in6_ifremlocal(struct ifaddr *);
+void in6_ifaddlocal(struct ifaddr *);
+void in6_createmkludge(struct ifnet *);
+void in6_purgemkludge(struct ifnet *);
+struct in6_ifaddr *in6ifa_ifpforlinklocal(const struct ifnet *, int);
+struct in6_ifaddr *in6ifa_ifpwithaddr(const struct ifnet *,
+ const struct in6_addr *);
+char *ip6_sprintf(const struct in6_addr *);
+int in6_matchlen(struct in6_addr *, struct in6_addr *);
+int in6_are_prefix_equal(struct in6_addr *, struct in6_addr *, int);
+void in6_prefixlen2mask(struct in6_addr *, int);
+void in6_purgeprefix(struct ifnet *);
+
+int ip6flow_fastforward(struct mbuf **); /* IPv6 fast forward routine */
+
+int in6_src_ioctl(u_long, void *);
+int in6_is_addr_deprecated(struct sockaddr_in6 *);
+struct in6pcb;
+#endif /* _KERNEL */
+
+#endif /* !_NETINET6_IN6_VAR_H_ */
--- /dev/null
+/* $NetBSD: ip6_mroute.h,v 1.17 2009/03/18 17:06:52 cegger Exp $ */
+/* $KAME: ip6_mroute.h,v 1.17 2001/02/10 02:05:52 itojun Exp $ */
+
+/*
+ * Copyright (C) 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/* BSDI ip_mroute.h,v 2.5 1996/10/11 16:01:48 pjd Exp */
+
+/*
+ * Definitions for IP multicast forwarding.
+ *
+ * Written by David Waitzman, BBN Labs, August 1988.
+ * Modified by Steve Deering, Stanford, February 1989.
+ * Modified by Ajit Thyagarajan, PARC, August 1993.
+ * Modified by Ajit Thyagarajan, PARC, August 1994.
+ * Modified by Ahmed Helmy, USC, September 1996.
+ *
+ * MROUTING Revision: 1.2
+ */
+
+#ifndef _NETINET6_IP6_MROUTE_H_
+#define _NETINET6_IP6_MROUTE_H_
+
+/*
+ * Multicast Routing set/getsockopt commands.
+ */
+#ifdef _KERNEL
+#define MRT6_OINIT 100 /* initialize forwarder (omrt6msg) */
+#endif
+#define MRT6_DONE 101 /* shut down forwarder */
+#define MRT6_ADD_MIF 102 /* add multicast interface */
+#define MRT6_DEL_MIF 103 /* delete multicast interface */
+#define MRT6_ADD_MFC 104 /* insert forwarding cache entry */
+#define MRT6_DEL_MFC 105 /* delete forwarding cache entry */
+#define MRT6_PIM 107 /* enable pim code */
+#define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */
+
+#if BSD >= 199103
+#define GET_TIME(t) microtime(&t)
+#elif defined(sun)
+#define GET_TIME(t) uniqtime(&t)
+#else
+#define GET_TIME(t) ((t) = time)
+#endif
+
+/*
+ * Types and macros for handling bitmaps with one bit per multicast interface.
+ */
+typedef u_short mifi_t; /* type of a mif index */
+#define MAXMIFS 64
+
+#ifndef IF_SETSIZE
+#define IF_SETSIZE 256
+#endif
+
+typedef u_int32_t if_mask;
+#define NIFBITS (sizeof(if_mask) * NBBY) /* bits per mask */
+
+#ifndef howmany
+#define howmany(x, y) (((x) + ((y) - 1)) / (y))
+#endif
+
+typedef struct if_set {
+ if_mask ifs_bits[howmany(IF_SETSIZE, NIFBITS)];
+} if_set;
+
+#define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
+#define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
+#define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
+#define IF_COPY(f, t) memcpy( t, f, sizeof(*(f)))
+#define IF_ZERO(p) memset(p, 0, sizeof(*(p)))
+
+/*
+ * Argument structure for MRT6_ADD_IF.
+ */
+struct mif6ctl {
+ mifi_t mif6c_mifi; /* the index of the mif to be added */
+ u_char mif6c_flags; /* MIFF_ flags defined below */
+ u_short mif6c_pifi; /* the index of the physical IF */
+#ifdef notyet
+ u_int mif6c_rate_limit; /* max rate */
+#endif
+};
+
+#define MIFF_REGISTER 0x1 /* mif represents a register end-point */
+
+/*
+ * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
+ */
+struct mf6cctl {
+ struct sockaddr_in6 mf6cc_origin; /* IPv6 origin of mcasts */
+ struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */
+ mifi_t mf6cc_parent; /* incoming ifindex */
+ struct if_set mf6cc_ifset; /* set of forwarding ifs */
+};
+
+/*
+ * The kernel's multicast routing statistics.
+ */
+struct mrt6stat {
+ u_quad_t mrt6s_mfc_lookups; /* # forw. cache hash table hits */
+ u_quad_t mrt6s_mfc_misses; /* # forw. cache hash table misses */
+ u_quad_t mrt6s_upcalls; /* # calls to mrouted */
+ u_quad_t mrt6s_no_route; /* no route for packet's origin */
+ u_quad_t mrt6s_bad_tunnel; /* malformed tunnel options */
+ u_quad_t mrt6s_cant_tunnel; /* no room for tunnel options */
+ u_quad_t mrt6s_wrong_if; /* arrived on wrong interface */
+ u_quad_t mrt6s_upq_ovflw; /* upcall Q overflow */
+ u_quad_t mrt6s_cache_cleanups; /* # entries with no upcalls */
+ u_quad_t mrt6s_drop_sel; /* pkts dropped selectively */
+ u_quad_t mrt6s_q_overflow; /* pkts dropped - Q overflow */
+ u_quad_t mrt6s_pkt2large; /* pkts dropped - size > BKT SIZE */
+ u_quad_t mrt6s_upq_sockfull; /* upcalls dropped - socket full */
+};
+
+#ifdef MRT6_OINIT
+/*
+ * Struct used to communicate from kernel to multicast router
+ * note the convenient similarity to an IPv6 header.
+ * XXX old version, superseded by mrt6msg.
+ */
+struct omrt6msg {
+ u_long unused1;
+ u_char im6_msgtype; /* what type of message */
+#if 0
+#define MRT6MSG_NOCACHE 1
+#define MRT6MSG_WRONGMIF 2
+#define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
+#endif
+ u_char im6_mbz; /* must be zero */
+ u_char im6_mif; /* mif rec'd on */
+ u_char unused2;
+ struct in6_addr im6_src, im6_dst;
+};
+#endif
+
+/*
+ * Structure used to communicate from kernel to multicast router.
+ * We'll overlay the structure onto an MLD header (not an IPv6 header
+ * like igmpmsg{} used for IPv4 implementation). This is because this
+ * structure will be passed via an IPv6 raw socket, on which an application
+ * will only receive the payload i.e. the data after the IPv6 header and all
+ * the extension headers. (see Section 3 of draft-ietf-ipngwg-2292bis-01)
+ */
+struct mrt6msg {
+#define MRT6MSG_NOCACHE 1
+#define MRT6MSG_WRONGMIF 2
+#define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
+ u_char im6_mbz; /* must be zero */
+ u_char im6_msgtype; /* what type of message */
+ u_int16_t im6_mif; /* mif rec'd on */
+ u_int32_t im6_pad; /* padding for 64bit arch */
+ struct in6_addr im6_src, im6_dst;
+};
+
+/*
+ * Argument structure used by multicast routing daemon to get src-grp
+ * packet counts
+ */
+struct sioc_sg_req6 {
+ struct sockaddr_in6 src;
+ struct sockaddr_in6 grp;
+ u_quad_t pktcnt;
+ u_quad_t bytecnt;
+ u_quad_t wrong_if;
+};
+
+/*
+ * Argument structure used by mrouted to get mif pkt counts
+ */
+struct sioc_mif_req6 {
+ mifi_t mifi; /* mif number */
+ u_quad_t icount; /* Input packet count on mif */
+ u_quad_t ocount; /* Output packet count on mif */
+ u_quad_t ibytes; /* Input byte count on mif */
+ u_quad_t obytes; /* Output byte count on mif */
+};
+
+#ifdef _KERNEL
+/*
+ * The kernel's multicast-interface structure.
+ */
+struct mif6 {
+ u_char m6_flags; /* MIFF_ flags defined above */
+ u_int m6_rate_limit; /* max rate */
+#ifdef notyet
+ struct tbf *m6_tbf; /* token bucket structure at intf. */
+#endif
+ struct in6_addr m6_lcl_addr; /* local interface address */
+ struct ifnet *m6_ifp; /* pointer to interface */
+ u_quad_t m6_pkt_in; /* # pkts in on interface */
+ u_quad_t m6_pkt_out; /* # pkts out on interface */
+ u_quad_t m6_bytes_in; /* # bytes in on interface */
+ u_quad_t m6_bytes_out; /* # bytes out on interface */
+#ifdef notyet
+ u_int m6_rsvp_on; /* RSVP listening on this vif */
+ struct socket *m6_rsvpd; /* RSVP daemon socket */
+#endif
+};
+
+/*
+ * The kernel's multicast forwarding cache entry structure
+ */
+struct mf6c {
+ struct sockaddr_in6 mf6c_origin; /* IPv6 origin of mcasts */
+ struct sockaddr_in6 mf6c_mcastgrp; /* multicast group associated*/
+ mifi_t mf6c_parent; /* incoming IF */
+ struct if_set mf6c_ifset; /* set of outgoing IFs */
+
+ u_quad_t mf6c_pkt_cnt; /* pkt count for src-grp */
+ u_quad_t mf6c_byte_cnt; /* byte count for src-grp */
+ u_quad_t mf6c_wrong_if; /* wrong if for src-grp */
+ int mf6c_expire; /* time to clean entry up */
+ struct timeval mf6c_last_assert; /* last time I sent an assert*/
+ struct rtdetq *mf6c_stall; /* pkts waiting for route */
+ struct mf6c *mf6c_next; /* hash table linkage */
+};
+
+#define MF6C_INCOMPLETE_PARENT ((mifi_t)-1)
+
+/*
+ * Argument structure used for pkt info. while upcall is made
+ */
+#ifndef _NETINET_IP_MROUTE_H_
+struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */
+ struct mbuf *m; /* A copy of the packet */
+ struct ifnet *ifp; /* Interface pkt came in on */
+#ifdef UPCALL_TIMING
+ struct timeval t; /* Timestamp */
+#endif /* UPCALL_TIMING */
+ struct rtdetq *next;
+};
+#endif /* _NETINET_IP_MROUTE_H_ */
+
+#define MF6CTBLSIZ 256
+#if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */
+#define MF6CHASHMOD(h) ((h) & (MF6CTBLSIZ - 1))
+#else
+#define MF6CHASHMOD(h) ((h) % MF6CTBLSIZ)
+#endif
+
+#define MAX_UPQ6 4 /* max. no of pkts in upcall Q */
+
+int ip6_mrouter_set(struct socket *, struct sockopt *);
+int ip6_mrouter_get(struct socket *, struct sockopt *);
+int ip6_mrouter_done(void);
+void ip6_mrouter_detach(struct ifnet *);
+int mrt6_ioctl(u_long, void *);
+#endif /* _KERNEL */
+
+#endif /* !_NETINET6_IP6_MROUTE_H_ */
--- /dev/null
+/* $NetBSD: ip6_var.h,v 1.64 2015/01/20 21:27:36 roy Exp $ */
+/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET6_IP6_VAR_H_
+#define _NETINET6_IP6_VAR_H_
+
+#include <sys/socketvar.h>
+#include <net/route.h>
+
+/*
+ * IP6 reassembly queue structure. Each fragment
+ * being reassembled is attached to one of these structures.
+ */
+struct ip6q {
+ u_int32_t ip6q_head;
+ u_int16_t ip6q_len;
+ u_int8_t ip6q_nxt; /* ip6f_nxt in first fragment */
+ u_int8_t ip6q_hlim;
+ struct ip6asfrag *ip6q_down;
+ struct ip6asfrag *ip6q_up;
+ u_int32_t ip6q_ident;
+ u_int8_t ip6q_arrive;
+ u_int8_t ip6q_ttl;
+ struct in6_addr ip6q_src, ip6q_dst;
+ struct ip6q *ip6q_next;
+ struct ip6q *ip6q_prev;
+ int ip6q_unfrglen; /* len of unfragmentable part */
+#ifdef notyet
+ u_char *ip6q_nxtp;
+#endif
+ int ip6q_nfrag; /* # of fragments */
+};
+
+struct ip6asfrag {
+ u_int32_t ip6af_head;
+ u_int16_t ip6af_len;
+ u_int8_t ip6af_nxt;
+ u_int8_t ip6af_hlim;
+ /* must not override the above members during reassembling */
+ struct ip6asfrag *ip6af_down;
+ struct ip6asfrag *ip6af_up;
+ struct mbuf *ip6af_m;
+ int ip6af_offset; /* offset in ip6af_m to next header */
+ int ip6af_frglen; /* fragmentable part length */
+ int ip6af_off; /* fragment offset */
+ u_int16_t ip6af_mff; /* more fragment bit in frag off */
+};
+
+#define IP6_REASS_MBUF(ip6af) ((ip6af)->ip6af_m)
+
+struct ip6_moptions {
+ struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
+ u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */
+ u_char im6o_multicast_loop; /* 1 >= hear sends if a member */
+ LIST_HEAD(, in6_multi_mship) im6o_memberships;
+};
+
+/*
+ * Control options for outgoing packets
+ */
+
+/* Routing header related info */
+struct ip6po_rhinfo {
+ struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
+ struct route ip6po_rhi_route; /* Route to the 1st hop */
+};
+#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
+#define ip6po_route ip6po_rhinfo.ip6po_rhi_route
+
+/* Nexthop related info */
+struct ip6po_nhinfo {
+ struct sockaddr *ip6po_nhi_nexthop;
+ struct route ip6po_nhi_route; /* Route to the nexthop */
+};
+#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
+#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route
+
+struct ip6_pktopts {
+ int ip6po_hlim; /* Hoplimit for outgoing packets */
+ struct in6_pktinfo *ip6po_pktinfo; /* Outgoing IF/address information */
+ struct ip6po_nhinfo ip6po_nhinfo; /* Next-hop address information */
+ struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
+ struct ip6_dest *ip6po_dest1; /* Destination options header(1st part) */
+ struct ip6po_rhinfo ip6po_rhinfo; /* Routing header related info. */
+ struct ip6_dest *ip6po_dest2; /* Destination options header(2nd part) */
+ int ip6po_tclass; /* traffic class */
+ int ip6po_minmtu; /* fragment vs PMTU discovery policy */
+#define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast*/
+#define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */
+#define IP6PO_MINMTU_ALL 1 /* always send at min MTU */
+ int ip6po_prefer_tempaddr; /* whether temporary addresses are
+ * preferred as source address */
+#define IP6PO_TEMPADDR_SYSTEM -1 /* follow the system default */
+#define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */
+#define IP6PO_TEMPADDR_PREFER 1 /* prefer temporary address */
+ int ip6po_flags;
+#if 0 /* parameters in this block is obsolete. do not reuse the values. */
+#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */
+#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */
+#endif
+#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
+};
+
+/*
+ * IPv6 statistics.
+ * Each counter is an unsigned 64-bit value.
+ */
+#define IP6_STAT_TOTAL 0 /* total packets received */
+#define IP6_STAT_TOOSHORT 1 /* packet too short */
+#define IP6_STAT_TOOSMALL 2 /* not enough data */
+#define IP6_STAT_FRAGMENTS 3 /* fragments received */
+#define IP6_STAT_FRAGDROPPED 4 /* frags dropped (dups, out of space) */
+#define IP6_STAT_FRAGTIMEOUT 5 /* fragments timed out */
+#define IP6_STAT_FRAGOVERFLOW 6 /* fragments that exceed limit */
+#define IP6_STAT_FORWARD 7 /* packets forwarded */
+#define IP6_STAT_CANTFORWARD 8 /* packets rcvd for uncreachable dst */
+#define IP6_STAT_REDIRECTSENT 9 /* packets forwarded on same net */
+#define IP6_STAT_DELIVERED 10 /* datagrams delivered to upper level */
+#define IP6_STAT_LOCALOUT 11 /* total IP packets generated here */
+#define IP6_STAT_ODROPPED 12 /* lost packets due to nobufs, etc. */
+#define IP6_STAT_REASSEMBLED 13 /* total packets reassembled ok */
+#define IP6_STAT_FRAGMENTED 14 /* datagrams successfully fragmented */
+#define IP6_STAT_OFRAGMENTS 15 /* output fragments created */
+#define IP6_STAT_CANTFRAG 16 /* don't fragment flag was set, etc. */
+#define IP6_STAT_BADOPTIONS 17 /* error in option processing */
+#define IP6_STAT_NOROUTE 18 /* packets discarded due to no route */
+#define IP6_STAT_BADVERS 19 /* ip6 version != 6 */
+#define IP6_STAT_RAWOUT 20 /* total raw ip packets generated */
+#define IP6_STAT_BADSCOPE 21 /* scope error */
+#define IP6_STAT_NOTMEMBER 22 /* don't join this multicast group */
+#define IP6_STAT_NXTHIST 23 /* next header histogram */
+ /* space for 256 counters */
+#define IP6_STAT_M1 279 /* one mbuf */
+#define IP6_STAT_M2M 280 /* two or more mbuf */
+ /* space for 32 counters */
+#define IP6_STAT_MEXT1 312 /* one ext mbuf */
+#define IP6_STAT_MEXT2M 313 /* two or more ext mbuf */
+#define IP6_STAT_EXTHDRTOOLONG 314 /* ext hdr are not contiguous */
+#define IP6_STAT_NOGIF 315 /* no match gif found */
+#define IP6_STAT_TOOMANYHDR 316 /* discarded due to too many headers */
+ /*
+ * statistics for improvement of the source address selection
+ * algorithm:
+ * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
+ */
+#define IP6_STAT_SOURCES_NONE 317 /* number of times that address
+ selection fails */
+#define IP6_STAT_SOURCES_SAMEIF 318 /* number of times that an address
+ on the outgoing I/F is chosen */
+ /* space for 16 counters */
+#define IP6_STAT_SOURCES_OTHERIF 334 /* number of times that an address on
+ a non-outgoing I/F is chosen */
+ /* space for 16 counters */
+#define IP6_STAT_SOURCES_SAMESCOPE 350 /* number of times that an address that
+ has the same scope from the dest.
+ is chosen */
+ /* space for 16 counters */
+#define IP6_STAT_SOURCES_OTHERSCOPE 366 /* number of times that an address that
+ has a different scope from the dest.
+ is chosen */
+ /* space for 16 counters */
+#define IP6_STAT_SOURCES_DEPRECATED 382 /* number of times that a deprecated
+ address is chosen */
+ /* space for 16 counters */
+#define IP6_STAT_FORWARD_CACHEHIT 398
+#define IP6_STAT_FORWARD_CACHEMISS 399
+#define IP6_STAT_FASTFORWARD 400 /* packets fast forwarded */
+#define IP6_STAT_FASTFORWARDFLOWS 401 /* number of fast forward flows */
+
+#define IP6_NSTATS 402
+
+#define IP6FLOW_HASHBITS 6 /* should not be a multiple of 8 */
+
+/*
+ * Structure for an IPv6 flow (ip6_fastforward).
+ */
+struct ip6flow {
+ LIST_ENTRY(ip6flow) ip6f_list; /* next in active list */
+ LIST_ENTRY(ip6flow) ip6f_hash; /* next ip6flow in bucket */
+ struct in6_addr ip6f_dst; /* destination address */
+ struct in6_addr ip6f_src; /* source address */
+ struct route ip6f_ro; /* associated route entry */
+ u_int32_t ip6f_flow; /* flow (tos) */
+ u_quad_t ip6f_uses; /* number of uses in this period */
+ u_quad_t ip6f_last_uses; /* number of uses in last period */
+ u_quad_t ip6f_dropped; /* ENOBUFS returned by if_output */
+ u_quad_t ip6f_forwarded; /* packets forwarded */
+ u_int ip6f_timer; /* lifetime timer */
+};
+
+#ifdef _KERNEL
+/*
+ * Auxiliary attributes of incoming IPv6 packets, which is initialized when we
+ * come into ip6_input().
+ * XXX do not make it a kitchen sink!
+ */
+struct ip6aux {
+ /* ip6.ip6_dst */
+ struct in6_addr ip6a_src;
+ uint32_t ip6a_scope_id;
+ int ip6a_flags;
+};
+
+/* flags passed to ip6_output as last parameter */
+#define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */
+#define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
+#define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */
+
+extern u_int32_t ip6_id; /* fragment identifier */
+extern int ip6_defhlim; /* default hop limit */
+extern int ip6_defmcasthlim; /* default multicast hop limit */
+extern int ip6_forwarding; /* act as router? */
+extern int ip6_sendredirect; /* send ICMPv6 redirect? */
+extern int ip6_forward_srcrt; /* forward src-routed? */
+extern int ip6_use_deprecated; /* allow deprecated addr as source */
+extern int ip6_rr_prune; /* router renumbering prefix
+ * walk list every 5 sec. */
+extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */
+extern int ip6_v6only;
+extern int ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */
+extern int ip6_maxifprefixes; /* Max acceptable prefixes via RA per IF */
+extern int ip6_maxifdefrouters; /* Max acceptable def routers via RA */
+extern int ip6_maxdynroutes; /* Max # of routes created via redirect */
+
+
+extern struct socket *ip6_mrouter; /* multicast routing daemon */
+extern int ip6_sendredirects; /* send IP redirects when forwarding? */
+extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */
+extern int ip6_maxfrags; /* Maximum fragments in reassembly queue */
+extern int ip6_sourcecheck; /* Verify source interface */
+extern int ip6_sourcecheck_interval; /* Interval between log messages */
+extern int ip6_accept_rtadv; /* Acts as a host not a router */
+extern int ip6_rtadv_maxroutes; /* maximum number of routes via rtadv */
+extern int ip6_keepfaith; /* Firewall Aided Internet Translator */
+extern int ip6_log_interval;
+extern time_t ip6_log_time;
+extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */
+extern int ip6_dad_count; /* DupAddrDetectionTransmits */
+
+extern int ip6_auto_flowlabel;
+extern int ip6_auto_linklocal;
+
+extern int ip6_anonportmin; /* minimum ephemeral port */
+extern int ip6_anonportmax; /* maximum ephemeral port */
+extern int ip6_lowportmin; /* minimum reserved port */
+extern int ip6_lowportmax; /* maximum reserved port */
+
+extern int ip6_use_tempaddr; /* whether to use temporary addresses. */
+extern int ip6_prefer_tempaddr; /* whether to prefer temporary addresses
+ in the source address selection */
+extern int ip6_use_defzone; /* whether to use the default scope zone
+ when unspecified */
+
+#ifdef GATEWAY
+extern int ip6_maxflows; /* maximum amount of flows for ip6ff */
+extern int ip6_hashsize; /* size of hash table */
+#endif
+
+struct in6pcb;
+extern const struct pr_usrreqs rip6_usrreqs;
+
+int icmp6_ctloutput(int, struct socket *, struct sockopt *);
+
+struct mbuf;
+void ip6_init(void);
+void ip6_input(struct mbuf *);
+const struct ip6aux *ip6_getdstifaddr(struct mbuf *);
+void ip6_freepcbopts(struct ip6_pktopts *);
+void ip6_freemoptions(struct ip6_moptions *);
+int ip6_unknown_opt(u_int8_t *, struct mbuf *, int);
+u_int8_t *ip6_get_prevhdr(struct mbuf *, int);
+int ip6_nexthdr(struct mbuf *, int, int, int *);
+int ip6_lasthdr(struct mbuf *, int, int, int *);
+
+struct m_tag *ip6_addaux(struct mbuf *);
+struct m_tag *ip6_findaux(struct mbuf *);
+void ip6_delaux(struct mbuf *);
+struct ip6_hdr;
+int ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *);
+int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *);
+void ip6_savecontrol(struct in6pcb *, struct mbuf **, struct ip6_hdr *,
+ struct mbuf *);
+void ip6_notify_pmtu(struct in6pcb *, const 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 *,
+ const struct sockaddr_in6 *);
+int ip6_output(struct mbuf *, struct ip6_pktopts *,
+ struct route *, int,
+ struct ip6_moptions *, struct socket *,
+ struct ifnet **);
+int ip6_ctloutput(int, struct socket *, struct sockopt *);
+int ip6_raw_ctloutput(int, struct socket *, struct sockopt *);
+void ip6_initpktopts(struct ip6_pktopts *);
+int ip6_setpktopts(struct mbuf *, struct ip6_pktopts *,
+ struct ip6_pktopts *, kauth_cred_t, int);
+void ip6_clearpktopts(struct ip6_pktopts *, int);
+struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int);
+int ip6_optlen(struct in6pcb *);
+
+void ip6_statinc(u_int);
+
+int route6_input(struct mbuf **, int *, int);
+
+void frag6_init(void);
+int frag6_input(struct mbuf **, int *, int);
+int ip6_reass_packet(struct mbuf **, int);
+void frag6_slowtimo(void);
+void frag6_fasttimo(void);
+void frag6_drain(void);
+void frag6_drainstub(void);
+
+int ip6flow_init(int);
+void ip6flow_poolinit(void);
+struct ip6flow *ip6flow_reap(int);
+void ip6flow_create(const struct route *, struct mbuf *);
+void ip6flow_slowtimo(void);
+int ip6flow_invalidate_all(int);
+
+void rip6_init(void);
+int rip6_input(struct mbuf **, int *, int);
+void *rip6_ctlinput(int, const struct sockaddr *, void *);
+int rip6_ctloutput(int, struct socket *, struct sockopt *);
+int rip6_output(struct mbuf *, struct socket *, struct sockaddr_in6 *,
+ struct mbuf *);
+int rip6_attach(struct socket *, int);
+int rip6_usrreq(struct socket *,
+ int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
+
+int dest6_input(struct mbuf **, int *, int);
+int none_input(struct mbuf **, int *, int);
+
+struct route;
+
+struct in6_addr *in6_selectsrc(struct sockaddr_in6 *,
+ struct ip6_pktopts *, struct ip6_moptions *, struct route *,
+ struct in6_addr *, struct ifnet **, int *);
+int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
+ struct ip6_moptions *, struct route *, struct ifnet **,
+ struct rtentry **, int);
+int ip6_get_membership(const struct sockopt *, struct ifnet **, void *,
+ size_t);
+
+u_int32_t ip6_randomid(void);
+u_int32_t ip6_randomflowlabel(void);
+#endif /* _KERNEL */
+
+#endif /* !_NETINET6_IP6_VAR_H_ */
--- /dev/null
+/* $NetBSD: nd6.h,v 1.66 2015/07/17 02:21:08 ozaki-r Exp $ */
+/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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>
+#include <sys/callout.h>
+
+struct llinfo_nd6 {
+ struct llinfo_nd6 *ln_next;
+ struct llinfo_nd6 *ln_prev;
+ struct rtentry *ln_rt;
+ struct mbuf *ln_hold; /* last packet until resolved/timeout */
+ long ln_asked; /* number of queries already sent for this addr */
+ u_long ln_expire; /* lifetime for NDP state transition */
+ short ln_state; /* reachability state */
+ short ln_router; /* 2^0: ND6 router bit */
+ int ln_byhint; /* # of times we made it reachable by UL hint */
+
+ long ln_ntick;
+ struct callout ln_timer_ch;
+};
+
+#define ND6_LLINFO_PURGE -3
+#define ND6_LLINFO_NOSTATE -2
+/*
+ * We don't need the WAITDELETE state any more, but we keep the definition
+ * in a comment line instead of removing it. This is necessary to avoid
+ * unintentionally reusing the value for another purpose, which might
+ * affect backward compatibility with old applications.
+ * (20000711 jinmei@kame.net)
+ */
+/* #define ND6_LLINFO_WAITDELETE -1 */
+#define ND6_LLINFO_INCOMPLETE 0
+#define ND6_LLINFO_REACHABLE 1
+#define ND6_LLINFO_STALE 2
+#define ND6_LLINFO_DELAY 3
+#define ND6_LLINFO_PROBE 4
+
+#define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
+#define ND6_LLINFO_PERMANENT(n) (((n)->ln_expire == 0) && ((n)->ln_state > ND6_LLINFO_INCOMPLETE))
+
+struct nd_ifinfo {
+ u_int32_t linkmtu; /* LinkMTU */
+ u_int32_t maxmtu; /* Upper bound of LinkMTU */
+ u_int32_t basereachable; /* BaseReachableTime */
+ u_int32_t reachable; /* Reachable Time */
+ u_int32_t retrans; /* Retrans Timer */
+ u_int32_t flags; /* Flags */
+ int recalctm; /* BaseReacable re-calculation timer */
+ u_int8_t chlim; /* CurHopLimit */
+ u_int8_t initialized; /* Flag to see the entry is initialized */
+ /* the following 3 members are for privacy extension for addrconf */
+ u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
+ u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
+ u_int8_t randomid[8]; /* current random ID */
+};
+
+#define ND6_IFF_PERFORMNUD 0x01
+#define ND6_IFF_ACCEPT_RTADV 0x02 /* See "RTADV Key", below. */
+#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)
+ */
+#define ND6_IFF_OVERRIDE_RTADV 0x10 /* See "RTADV Key", below. */
+#define ND6_IFF_AUTO_LINKLOCAL 0x20
+
+/*
+ * RTADV Key
+ *
+ * The flags ND6_IFF_ACCEPT_RTADV and ND6_IFF_OVERRIDE_RTADV form a
+ * tri-state variable. (There are actually four different states, but
+ * two of the states are functionally identical.)
+ *
+ * ND6_IFF_OVERRIDE_RTADV or 0: This interface does not accept
+ * Router Advertisements.
+ *
+ * ND6_IFF_OVERRIDE_RTADV|
+ * ND6_IFF_ACCEPT_RTADV: This interface accepts Router
+ * Advertisements regardless of the
+ * global setting, ip6_accept_rtadv.
+ *
+ * ND6_IFF_ACCEPT_RTADV: This interface follows the global setting,
+ * ip6_accept_rtadv. If ip6_accept_rtadv == 0,
+ * this interface does not accept Router
+ * Advertisements. If ip6_accept_rtadv != 0,
+ * this interface does accept them.
+ */
+
+#ifdef _KERNEL
+#define ND_IFINFO(ifp) \
+ (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
+#define IN6_LINKMTU(ifp) \
+ ((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \
+ ? ND_IFINFO(ifp)->linkmtu \
+ : ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \
+ ? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))
+#endif
+
+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 */
+};
+
+#define DRLSTSIZ 10
+#define PRLSTSIZ 10
+struct in6_drlist {
+ char ifname[IFNAMSIZ];
+ struct {
+ struct in6_addr rtaddr;
+ u_char flags;
+ u_short rtlifetime;
+ u_long expire;
+ u_short if_index;
+ } defrouter[DRLSTSIZ];
+};
+
+struct in6_defrouter {
+ struct sockaddr_in6 rtaddr;
+ u_char flags;
+ u_short rtlifetime;
+ u_long expire;
+ u_short if_index;
+};
+
+#ifdef _KERNEL
+struct in6_oprlist {
+ char ifname[IFNAMSIZ];
+ struct {
+ struct in6_addr prefix;
+ struct prf_ra raflags;
+ u_char prefixlen;
+ u_char origin;
+ u_long vltime;
+ u_long pltime;
+ u_long expire;
+ u_short if_index;
+ u_short advrtrs; /* number of advertisement routers */
+ struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
+ } prefix[PRLSTSIZ];
+};
+#endif
+
+struct in6_prlist {
+ char ifname[IFNAMSIZ];
+ struct {
+ struct in6_addr prefix;
+ struct prf_ra raflags;
+ u_char prefixlen;
+ u_char origin;
+ u_int32_t vltime;
+ u_int32_t pltime;
+ time_t expire;
+ u_short if_index;
+ u_short advrtrs; /* number of advertisement routers */
+ struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
+ } prefix[PRLSTSIZ];
+};
+
+struct in6_prefix {
+ struct sockaddr_in6 prefix;
+ struct prf_ra raflags;
+ u_char prefixlen;
+ u_char origin;
+ u_int32_t vltime;
+ u_int32_t pltime;
+ time_t expire;
+ u_int32_t flags;
+ int refcnt;
+ u_short if_index;
+ u_short advrtrs; /* number of advertisement routers */
+ /* struct sockaddr_in6 advrtr[] */
+};
+
+#ifdef _KERNEL
+struct in6_ondireq {
+ char ifname[IFNAMSIZ];
+ struct {
+ u_int32_t linkmtu; /* LinkMTU */
+ u_int32_t maxmtu; /* Upper bound of LinkMTU */
+ u_int32_t basereachable; /* BaseReachableTime */
+ u_int32_t reachable; /* Reachable Time */
+ u_int32_t retrans; /* Retrans Timer */
+ u_int32_t flags; /* Flags */
+ int recalctm; /* BaseReacable re-calculation timer */
+ u_int8_t chlim; /* CurHopLimit */
+ u_int8_t receivedra;
+ } ndi;
+};
+#endif
+
+struct in6_ndireq {
+ char ifname[IFNAMSIZ];
+ struct nd_ifinfo ndi;
+};
+
+struct in6_ndifreq {
+ char ifname[IFNAMSIZ];
+ u_long ifindex;
+};
+
+/* Prefix status */
+#define NDPRF_ONLINK 0x1
+#define NDPRF_DETACHED 0x2
+#define NDPRF_HOME 0x4
+
+/* protocol constants */
+#define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
+#define RTR_SOLICITATION_INTERVAL 4 /* 4sec */
+#define MAX_RTR_SOLICITATIONS 3
+
+#define ND6_INFINITE_LIFETIME ((u_int32_t)~0)
+
+#ifdef _KERNEL
+/* node constants */
+#define MAX_REACHABLE_TIME 3600000 /* msec */
+#define REACHABLE_TIME 30000 /* msec */
+#define RETRANS_TIMER 1000 /* msec */
+#define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
+#define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */
+#define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */
+#define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
+#define TEMPADDR_REGEN_ADVANCE 5 /* sec */
+#define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */
+#define ND_COMPUTE_RTIME(x) \
+ (((MIN_RANDOM_FACTOR * (x >> 10)) + (cprng_fast32() & \
+ ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
+
+TAILQ_HEAD(nd_drhead, nd_defrouter);
+struct nd_defrouter {
+ TAILQ_ENTRY(nd_defrouter) dr_entry;
+ struct in6_addr rtaddr;
+ u_char flags; /* flags on RA message */
+ u_short rtlifetime;
+ u_long expire;
+ struct ifnet *ifp;
+ int installed; /* is installed into kernel routing table */
+};
+
+struct nd_prefixctl {
+ struct ifnet *ndprc_ifp;
+
+ /* prefix */
+ struct sockaddr_in6 ndprc_prefix;
+ u_char ndprc_plen;
+
+ u_int32_t ndprc_vltime; /* advertised valid lifetime */
+ u_int32_t ndprc_pltime; /* advertised preferred lifetime */
+
+ struct prf_ra ndprc_flags;
+};
+
+#define ndprc_raf ndprc_flags
+#define ndprc_raf_onlink ndprc_flags.onlink
+#define ndprc_raf_auto ndprc_flags.autonomous
+#define ndprc_raf_router ndprc_flags.router
+
+struct nd_prefix {
+ struct ifnet *ndpr_ifp;
+ LIST_ENTRY(nd_prefix) ndpr_entry;
+ struct sockaddr_in6 ndpr_prefix; /* prefix */
+ struct in6_addr ndpr_mask; /* netmask derived from the prefix */
+
+ u_int32_t ndpr_vltime; /* advertised valid lifetime */
+ u_int32_t ndpr_pltime; /* advertised preferred lifetime */
+
+ time_t ndpr_expire; /* expiration time of the prefix */
+ time_t ndpr_preferred; /* preferred time of the prefix */
+ time_t ndpr_lastupdate; /* reception time of last advertisement */
+
+ struct prf_ra ndpr_flags;
+ u_int32_t ndpr_stateflags; /* actual state flags */
+ /* list of routers that advertise the prefix: */
+ LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
+ u_char ndpr_plen;
+ int ndpr_refcnt; /* reference couter from addresses */
+};
+
+#define ndpr_next ndpr_entry.le_next
+
+#define ndpr_raf ndpr_flags
+#define ndpr_raf_onlink ndpr_flags.onlink
+#define ndpr_raf_auto ndpr_flags.autonomous
+#define ndpr_raf_router ndpr_flags.router
+
+/*
+ * Message format for use in obtaining information about prefixes
+ * from inet6 sysctl function
+ */
+struct inet6_ndpr_msghdr {
+ u_short inpm_msglen; /* to skip over non-understood messages */
+ u_char inpm_version; /* future binary compatibility */
+ u_char inpm_type; /* message type */
+ struct in6_addr inpm_prefix;
+ u_long prm_vltim;
+ u_long prm_pltime;
+ u_long prm_expire;
+ u_long prm_preferred;
+ struct in6_prflags prm_flags;
+ u_short prm_index; /* index for associated ifp */
+ u_char prm_plen; /* length of prefix in bits */
+};
+
+#define prm_raf_onlink prm_flags.prf_ra.onlink
+#define prm_raf_auto prm_flags.prf_ra.autonomous
+
+#define prm_statef_onlink prm_flags.prf_state.onlink
+
+#define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid
+#define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd
+
+struct nd_pfxrouter {
+ LIST_ENTRY(nd_pfxrouter) pfr_entry;
+ struct nd_defrouter *router;
+};
+
+LIST_HEAD(nd_prhead, nd_prefix);
+
+#include <sys/mallocvar.h>
+MALLOC_DECLARE(M_IP6NDP);
+
+/* nd6.c */
+extern int nd6_prune;
+extern int nd6_delay;
+extern int nd6_umaxtries;
+extern int nd6_mmaxtries;
+extern int nd6_useloopback;
+extern int nd6_maxnudhint;
+extern int nd6_gctimer;
+extern struct llinfo_nd6 llinfo_nd6;
+extern struct nd_drhead nd_defrouter;
+extern struct nd_prhead nd_prefix;
+extern int nd6_debug;
+
+#define nd6log(x) do { if (nd6_debug) log x; } while (/*CONSTCOND*/ 0)
+
+extern struct callout nd6_timer_ch;
+
+/* nd6_rtr.c */
+extern int nd6_defifindex;
+extern int ip6_desync_factor; /* seconds */
+extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
+extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
+extern int ip6_temp_regen_advance; /* seconds */
+extern int nd6_numroutes;
+
+union nd_opts {
+ struct nd_opt_hdr *nd_opt_array[8];
+ 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; /* multiple opts, start */
+ struct nd_opt_rd_hdr *rh;
+ struct nd_opt_mtu *mtu;
+ 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
+#define nd_opts_search nd_opt_each.search
+#define nd_opts_last nd_opt_each.last
+#define nd_opts_done nd_opt_each.done
+
+/* XXX: need nd6_var.h?? */
+/* nd6.c */
+void nd6_init(void);
+struct nd_ifinfo *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 *);
+struct nd_opt_hdr *nd6_option(union nd_opts *);
+int nd6_options(union nd_opts *);
+struct rtentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *);
+void nd6_setmtu(struct ifnet *);
+void nd6_llinfo_settimer(struct llinfo_nd6 *, long);
+void nd6_timer(void *);
+void nd6_purge(struct ifnet *, struct in6_ifextra *);
+void nd6_nud_hint(struct rtentry *);
+int nd6_resolve(struct ifnet *, struct rtentry *,
+ struct mbuf *, struct sockaddr *, u_char *);
+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_output(struct ifnet *, struct ifnet *, struct mbuf *,
+ const struct sockaddr_in6 *, struct rtentry *);
+int nd6_storelladdr(const struct ifnet *, const struct rtentry *, struct mbuf *,
+ const struct sockaddr *, uint8_t *, size_t);
+int nd6_sysctl(int, void *, size_t *, void *, size_t);
+int nd6_need_cache(struct ifnet *);
+void nd6_llinfo_release_pkts(struct llinfo_nd6 *, struct ifnet *,
+ struct rtentry *);
+
+/* nd6_nbr.c */
+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 *, struct llinfo_nd6 *, int);
+const void *nd6_ifptomac(const struct ifnet *);
+void nd6_dad_start(struct ifaddr *, int);
+void nd6_dad_stop(struct ifaddr *);
+void nd6_dad_duplicated(struct ifaddr *);
+
+/* nd6_rtr.c */
+void nd6_rs_input(struct mbuf *, int, int);
+void nd6_ra_input(struct mbuf *, int, int);
+void prelist_del(struct nd_prefix *);
+void defrouter_addreq(struct nd_defrouter *);
+void defrouter_reset(void);
+void defrouter_select(void);
+void defrtrlist_del(struct nd_defrouter *, struct in6_ifextra *);
+void prelist_remove(struct nd_prefix *);
+int nd6_prelist_add(struct nd_prefixctl *, struct nd_defrouter *,
+ struct nd_prefix **);
+int nd6_prefix_onlink(struct nd_prefix *);
+int nd6_prefix_offlink(struct nd_prefix *);
+void pfxlist_onlink_check(void);
+struct nd_defrouter *defrouter_lookup(const struct in6_addr *, struct ifnet *);
+struct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *);
+int in6_ifdel(struct ifnet *, struct in6_addr *);
+void rt6_flush(struct in6_addr *, struct ifnet *);
+int nd6_setdefaultiface(int);
+int in6_tmpifadd(const struct in6_ifaddr *, int, int);
+bool nd6_accepts_rtadv(const struct nd_ifinfo *);
+
+#endif /* _KERNEL */
+
+#endif /* !_NETINET6_ND6_H_ */
--- /dev/null
+/* $NetBSD: pim6_var.h,v 1.14 2008/04/15 05:40:15 thorpej Exp $ */
+/* $KAME: pim6_var.h,v 1.8 2000/06/06 08:07:43 jinmei Exp $ */
+
+/*
+ * Copyright (C) 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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_PIM6_VAR_H_
+#define _NETINET6_PIM6_VAR_H_
+
+/*
+ * Protocol Independent Multicast (PIM),
+ * implementation-specific definitions.
+ *
+ * Written by George Edmond Eddy (Rusty), ISI, February 1998
+ * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998
+ */
+
+#define PIM6_STAT_RCV_TOTAL 0 /* total PIM messages received */
+#define PIM6_STAT_RCV_TOOSHORT 1 /* received with too few bytes */
+#define PIM6_STAT_RCV_BADSUM 2 /* received with bad checksum */
+#define PIM6_STAT_RCV_BADVERSION 3 /* received bad PIM version */
+#define PIM6_STAT_RCV_REGISTERS 4 /* received registers */
+#define PIM6_STAT_RCV_BADREGISTERS 5 /* received invalid registers */
+#define PIM6_STAT_SND_REGISTERS 6 /* sent registers */
+
+#define PIM6_NSTATS 7
+
+#if defined(_KERNEL)
+void pim6_init(void);
+int pim6_input(struct mbuf **, int*, int);
+#endif /* _KERNEL */
+
+/*
+ * Names for PIM sysctl objects
+ */
+#define PIM6CTL_STATS 1 /* statistics (read-only) */
+#define PIM6CTL_MAXID 2
+
+#define PIM6CTL_NAMES { \
+ { 0, 0 }, \
+ { "stats", CTLTYPE_STRUCT }, \
+}
+#endif /* !_NETINET6_PIM6_VAR_H_ */
--- /dev/null
+/* $NetBSD: raw_ip6.h,v 1.4 2008/04/15 05:13:37 thorpej Exp $ */
+/* $KAME: raw_ip6.h,v 1.2 2001/05/27 13:28:35 itojun Exp $ */
+
+/*
+ * Copyright (C) 2001 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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_RAW_IP6_H_
+#define _NETINET6_RAW_IP6_H_
+
+/*
+ * ICMPv6 stat is counted separately. see netinet/icmp6.h
+ */
+#define RIP6_STAT_IPACKETS 0 /* total input packets */
+#define RIP6_STAT_ISUM 1 /* input checksum computations */
+#define RIP6_STAT_BADSUM 2 /* of above, checksum error */
+#define RIP6_STAT_NOSOCK 3 /* no matching socket */
+#define RIP6_STAT_NOSOCKMCAST 4 /* of above, arrived as multicast */
+#define RIP6_STAT_FULLSOCK 5 /* not delivered, input socket full */
+#define RIP6_STAT_OPACKETS 6 /* total output packets */
+
+#define RIP6_NSTATS 7
+
+/*
+ * Names for Raw IPv6 sysctl objects
+ */
+#define RAW6CTL_STATS 1
+#define RAW6CTL_MAXID 2
+
+#define RAW6CTL_NAMES { \
+ { 0, 0 }, \
+ { "stats", CTLTYPE_STRUCT }, \
+}
+
+#ifdef _KERNEL
+extern struct rip6stat rip6stat;
+#endif
+
+#endif /* !_NETINET6_RAW_IP6_H_ */
--- /dev/null
+/* $NetBSD: udp6.h,v 1.7 2005/12/10 23:39:56 elad Exp $ */
+/* $KAME: udp6.h,v 1.4 2001/02/10 00:57:54 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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_UDP6_H_
+#define _NETINET6_UDP6_H_
+
+#include <netinet/udp.h>
+
+#endif /* !_NETINET6_UDP6_H_ */
--- /dev/null
+/* $NetBSD: udp6_var.h,v 1.28 2015/05/02 17:18:03 rtr Exp $ */
+/* $KAME: udp6_var.h,v 1.11 2000/06/05 00:14:31 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)udp_var.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET6_UDP6_VAR_H_
+#define _NETINET6_UDP6_VAR_H_
+
+/*
+ * UDP Kernel structures and variables.
+ */
+
+#define UDP6_STAT_IPACKETS 0 /* total input packets */
+#define UDP6_STAT_HDROPS 1 /* packet shorter than header */
+#define UDP6_STAT_BADSUM 2 /* checksum error */
+#define UDP6_STAT_NOSUM 3 /* no checksum */
+#define UDP6_STAT_BADLEN 4 /* data length larger than packet */
+#define UDP6_STAT_NOPORT 5 /* no socket on port */
+#define UDP6_STAT_NOPORTMCAST 6 /* of above, arrived as multicast */
+#define UDP6_STAT_FULLSOCK 7 /* not delivered, input socket full */
+#define UDP6_STAT_PCBCACHEMISS 8 /* input packets missing pcb cache */
+#define UDP6_STAT_OPACKETS 9 /* total output packets */
+
+#define UDP6_NSTATS 10
+
+/*
+ * Names for UDP6 sysctl objects
+ */
+#define UDP6CTL_SENDSPACE 1 /* default send buffer */
+#define UDP6CTL_RECVSPACE 2 /* default recv buffer */
+#define UDP6CTL_LOOPBACKCKSUM 3 /* do UDP checksum on loopback? */
+#define UDP6CTL_STATS 4 /* udp6 statistics */
+#define UDP6CTL_MAXID 5
+
+#define UDP6CTL_NAMES { \
+ { 0, 0 }, \
+ { "sendspace", CTLTYPE_INT }, \
+ { "recvspace", CTLTYPE_INT }, \
+ { "do_loopback_cksum", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
+}
+
+#ifdef _KERNEL
+
+extern const struct pr_usrreqs udp6_usrreqs;
+
+void *udp6_ctlinput(int, const struct sockaddr *, void *);
+int udp6_ctloutput(int, struct socket *, struct sockopt *);
+void udp6_init(void);
+int udp6_input(struct mbuf **, int *, int);
+int udp6_output(struct in6pcb *, struct mbuf *, struct sockaddr_in6 *,
+ struct mbuf *, struct lwp *);
+int udp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
+int udp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
+ struct mbuf *, struct lwp *);
+int udp6_realinput(int, struct sockaddr_in6 *, struct sockaddr_in6 *,
+ struct mbuf *, int);
+int udp6_input_checksum(struct mbuf *, const struct udphdr *, int, int);
+
+void udp6_statinc(u_int);
+#endif /* _KERNEL */
+
+#endif /* !_NETINET6_UDP6_VAR_H_ */
--- /dev/null
+# $NetBSD: Makefile,v 1.1 2010/06/26 14:24:28 kefren Exp $
+
+INCSDIR= /usr/include/netmpls
+
+INCS= mpls.h
+
+.include <bsd.kinc.mk>
--- /dev/null
+/* $NetBSD: mpls.h,v 1.1 2010/06/26 14:24:28 kefren Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Mihai Chelaru <kefren@NetBSD.org>
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 _NETMPLS_MPLS_H_
+#define _NETMPLS_MPLS_H_
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/proc.h>
+#include <sys/queue.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+
+#define MPLS_LABEL_IPV4NULL 0 /* IPv4 Explicit NULL Label */
+#define MPLS_LABEL_RTALERT 1 /* Router Alert Label */
+#define MPLS_LABEL_IPV6NULL 2 /* IPv6 Explicit NULL Label */
+#define MPLS_LABEL_IMPLNULL 3 /* Implicit NULL Label */
+#define MPLS_LABEL_RESMAX 15 /* Maximum reserved Label */
+
+union mpls_shim {
+ uint32_t s_addr; /* the whole shim */
+ struct {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint32_t ttl:8;
+ uint32_t bos:1;
+ uint32_t exp:3;
+ uint32_t label:20;
+#else
+ uint32_t label:20;
+ uint32_t exp:3;
+ uint32_t bos:1;
+ uint32_t ttl:8;
+#endif
+ } shim;
+};
+
+struct sockaddr_mpls {
+ uint8_t smpls_len;
+ uint8_t smpls_family;
+ uint8_t smpls_pad[2];
+ union mpls_shim smpls_addr;
+} __packed;
+
+
+#endif /* !_NETMPLS_MPLS_H_ */