Module Name:    src
Committed By:   phil
Date:           Mon Jul 16 20:11:12 UTC 2018

Modified Files:
        src/sys/dev/usb [phil-wifi]: if_urtwn.c if_urtwnvar.h
        src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_acl.c
            ieee80211_amrr.c ieee80211_crypto.c ieee80211_crypto_tkip.c
            ieee80211_crypto_wep.c ieee80211_ht.c ieee80211_hwmp.c
            ieee80211_input.c ieee80211_ioctl.c ieee80211_mesh.c
            ieee80211_netbsd.c ieee80211_netbsd.h ieee80211_node.c
            ieee80211_output.c ieee80211_proto.c ieee80211_proto.h
            ieee80211_ratectl.c ieee80211_ratectl.h ieee80211_ratectl_none.c
            ieee80211_rssadapt.c ieee80211_scan.c ieee80211_scan_sta.c
            ieee80211_var.h ieee80211_xauth.c

Log Message:
State save.
urtwn now can attach and shows up in the "ifconfig -a" list.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.1 -r1.59.2.2 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.10 -r1.10.16.1 src/sys/dev/usb/if_urtwnvar.h
cvs rdiff -u -r1.56.18.2 -r1.56.18.3 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.9.54.2 -r1.9.54.3 src/sys/net80211/ieee80211_acl.c
cvs rdiff -u -r1.3.18.2 -r1.3.18.3 src/sys/net80211/ieee80211_amrr.c
cvs rdiff -u -r1.23.2.2 -r1.23.2.3 src/sys/net80211/ieee80211_crypto.c
cvs rdiff -u -r1.14.4.2 -r1.14.4.3 src/sys/net80211/ieee80211_crypto_tkip.c
cvs rdiff -u -r1.12.2.2 -r1.12.2.3 src/sys/net80211/ieee80211_crypto_wep.c
cvs rdiff -u -r1.1.56.3 -r1.1.56.4 src/sys/net80211/ieee80211_ht.c \
    src/sys/net80211/ieee80211_scan.c src/sys/net80211/ieee80211_scan_sta.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/net80211/ieee80211_hwmp.c \
    src/sys/net80211/ieee80211_mesh.c src/sys/net80211/ieee80211_ratectl.c \
    src/sys/net80211/ieee80211_ratectl_none.c
cvs rdiff -u -r1.114.2.2 -r1.114.2.3 src/sys/net80211/ieee80211_input.c
cvs rdiff -u -r1.60.18.2 -r1.60.18.3 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.31.2.2 -r1.31.2.3 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.3 -r1.21.2.4 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.75.4.2 -r1.75.4.3 src/sys/net80211/ieee80211_node.c
cvs rdiff -u -r1.63.2.2 -r1.63.2.3 src/sys/net80211/ieee80211_output.c
cvs rdiff -u -r1.34.14.2 -r1.34.14.3 src/sys/net80211/ieee80211_proto.c
cvs rdiff -u -r1.23.16.3 -r1.23.16.4 src/sys/net80211/ieee80211_proto.h
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/net80211/ieee80211_ratectl.h
cvs rdiff -u -r1.21.16.2 -r1.21.16.3 src/sys/net80211/ieee80211_rssadapt.c
cvs rdiff -u -r1.33.2.3 -r1.33.2.4 src/sys/net80211/ieee80211_var.h
cvs rdiff -u -r1.5.158.2 -r1.5.158.3 src/sys/net80211/ieee80211_xauth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.1 src/sys/dev/usb/if_urtwn.c:1.59.2.2
--- src/sys/dev/usb/if_urtwn.c:1.59.2.1	Thu Jul 12 16:35:33 2018
+++ src/sys/dev/usb/if_urtwn.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.1 2018/07/12 16:35:33 phil Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.2 2018/07/16 20:11:11 phil Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.1 2018/07/12 16:35:33 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.2 2018/07/16 20:11:11 phil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v
 #include <sys/sysctl.h>
 #include <sys/mbuf.h>
 #include <sys/kernel.h>
+#include <sys/kmem.h>
 #include <sys/socket.h>
 #include <sys/systm.h>
 #include <sys/module.h>
@@ -92,7 +93,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v
 #define	DBG_RF		__BIT(5)
 #define	DBG_REG		__BIT(6)
 #define	DBG_ALL		0xffffffffU
-u_int urtwn_debug = 0;
+/* NNN Reset urtwn_debug to 0 when done debugging. */
+u_int urtwn_debug = DBG_INIT|DBG_FN|DBG_STM;
 #define DPRINTFN(n, s)	\
 	do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
 #else
@@ -258,7 +260,7 @@ static void	urtwn_set_led(struct urtwn_s
 static void	urtwn_calib_to(void *);
 static void	urtwn_calib_to_cb(struct urtwn_softc *, void *);
 static void	urtwn_next_scan(void *);
-static int	urtwn_newstate(struct urtwn_softc *, enum ieee80211_state,
+static int	urtwn_newstate(struct ieee80211vap *, enum ieee80211_state,
 		    int);
 static void	urtwn_newstate_cb(struct urtwn_softc *, void *);
 static int	urtwn_wme_update(struct ieee80211com *);
@@ -275,7 +277,6 @@ static struct urtwn_tx_data *
 		urtwn_get_tx_data(struct urtwn_softc *, size_t);
 static void	urtwn_start(struct ifnet *);
 static void	urtwn_watchdog(struct ifnet *);
-static int	urtwn_ioctl(struct ifnet *, u_long, void *);
 static int	urtwn_r92c_power_on(struct urtwn_softc *);
 static int	urtwn_r92e_power_on(struct urtwn_softc *);
 static int	urtwn_r88e_power_on(struct urtwn_softc *);
@@ -306,10 +307,17 @@ static void	urtwn_lc_calib(struct urtwn_
 static void	urtwn_temp_calib(struct urtwn_softc *);
 static int	urtwn_init(struct ifnet *);
 static void	urtwn_stop(struct ifnet *, int);
-static int	urtwn_reset(struct ifnet *);
+static int	urtwn_reset(struct ieee80211vap *, u_long);
 static void	urtwn_chip_stop(struct urtwn_softc *);
 static void	urtwn_newassoc(struct ieee80211_node *, int);
 static void	urtwn_delay_ms(struct urtwn_softc *, int ms);
+static struct ieee80211vap *
+		urtwn_vap_create(struct ieee80211com *,
+		    const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
+		    const uint8_t [IEEE80211_ADDR_LEN],
+		    const uint8_t [IEEE80211_ADDR_LEN]);
+static void	urtwn_vap_delete(struct ieee80211vap *);
+static int	urtwn_ioctl(struct ifnet *, u_long, void *);
 
 /* Aliases. */
 #define	urtwn_bb_write	urtwn_write_4
@@ -339,7 +347,6 @@ urtwn_attach(device_t parent, device_t s
 {
 	struct urtwn_softc *sc = device_private(self);
 	struct ieee80211com *ic = &sc->sc_ic;
-	struct ifnet *ifp = &sc->sc_if;
 	struct usb_attach_arg *uaa = aux;
 	char *devinfop;
 	const struct urtwn_dev *dev;
@@ -447,8 +454,7 @@ urtwn_attach(device_t parent, device_t s
 	/*
 	 * Setup the 802.11 device.
 	 */
-	/* ic->ic_ifp = ifp; NNN need to do this later... */
-	/* ic->ic_state = IEEE80211_S_INIT; NNN do this to the vap */
+	ic->ic_softc = sc;
 	ic->ic_phytype = IEEE80211_T_OFDM;	/* Not only, but not used. */
 	ic->ic_opmode = IEEE80211_M_STA;	/* Default to BSS mode. */
 
@@ -462,8 +468,11 @@ urtwn_attach(device_t parent, device_t s
 	    IEEE80211_C_WME |		/* 802.11e */
 	    IEEE80211_C_WPA;		/* 802.11i */
 
+	ic->ic_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+
 	/* Set supported .11b and .11g channels (1 through 14). */
-	for (i = 1; i <= 14; i++) {
+	ic->ic_nchans = 14;  /* NNN ? get this from somewhere? */
+	for (i = 0; i < 14; i++) {
 		ic->ic_channels[i].ic_freq =
 		    ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ);
 		ic->ic_channels[i].ic_flags =
@@ -471,33 +480,34 @@ urtwn_attach(device_t parent, device_t s
 		    IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
 	}
 
-	ifp->if_softc = sc;
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-	ifp->if_init = urtwn_init;
-	ifp->if_ioctl = urtwn_ioctl;
-	ifp->if_start = urtwn_start;
-	ifp->if_watchdog = urtwn_watchdog;
-	IFQ_SET_READY(&ifp->if_snd);
-	memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
+	printf ("eurtwn: Calling ieee80211_ifattach()\n");
 
-	if_attach(ifp);
 	ieee80211_ifattach(ic);
 
+	printf ("urtwn: Returned from ieee80211_ifattach().\n");
+
 	/* override default methods NNN Need a lot more here!!! */
 	ic->ic_newassoc = urtwn_newassoc;
 	ic->ic_wme.wme_update = urtwn_wme_update;
+	ic->ic_vap_create = urtwn_vap_create;
+	ic->ic_vap_delete = urtwn_vap_delete;
 
-#if  0
-	/* XXX .... vap routines ... in vap_create? */
-	vap->iv_reset = urtwn_reset;
+	/* Shouldn't do it, but call vap_create??? */
+	uint8_t bssid[IEEE80211_ADDR_LEN] = {0};
 
-	/* Override state transition machine. */
-	sc->sc_newstate = ic->ic_newstate;
-	ic->ic_newstate = urtwn_newstate;
-	ieee80211_media_init(ic, urtwn_media_change, ieee80211_media_status);
-#endif
+	struct ieee80211vap *vap =
+	    urtwn_vap_create(ic, device_xname(sc->sc_dev),
+	        device_unit(sc->sc_dev), IEEE80211_M_IBSS,
+	        IEEE80211_CLONE_MACADDR, bssid, ic->ic_macaddr);
+
+	if (vap == NULL) {
+		/* Didn't work ... now what! */
+		printf ("vap_create didn't work ...\n");
+		ieee80211_ifdetach(ic);
+		goto fail;
+	}
 
-	bpf_attach2(ifp, DLT_IEEE802_11_RADIO,
+	bpf_attach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
 	    sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
 	    &sc->sc_drvbpf);
 
@@ -517,6 +527,7 @@ urtwn_attach(device_t parent, device_t s
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	SET(sc->sc_flags, URTWN_FLAG_ATTACHED);
+printf ("urtwn: Finished attach.\n");
 	return;
 
  fail:
@@ -528,7 +539,6 @@ static int
 urtwn_detach(device_t self, int flags)
 {
 	struct urtwn_softc *sc = device_private(self);
-	struct ifnet *ifp = &sc->sc_if;
 	int s;
 
 	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -544,12 +554,8 @@ urtwn_detach(device_t self, int flags)
 
 	if (ISSET(sc->sc_flags, URTWN_FLAG_ATTACHED)) {
 		usb_rem_task(sc->sc_udev, &sc->sc_task);
-		urtwn_stop(ifp, 0);
 
-		ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
-		bpf_detach(ifp);
 		ieee80211_ifdetach(&sc->sc_ic);
-		if_detach(ifp);
 
 		/* Close Tx/Rx pipes.  Abort done by urtwn_stop. */
 		urtwn_close_pipes(sc);
@@ -574,18 +580,14 @@ urtwn_detach(device_t self, int flags)
 static int
 urtwn_activate(device_t self, enum devact act)
 {
-#if notyet
 	struct urtwn_softc *sc = device_private(self);
-#endif
 
 	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
 	switch (act) {
 	case DVACT_DEACTIVATE:
-#if notyet
-		FOR_EACH(vap in  sc->sc_vaps)  ???
-		if_deactivate(vap->iv_ifp);
-#endif
+		if_deactivate(TAILQ_FIRST(&(sc->sc_ic.ic_vaps))->iv_ifp);
+
 		return 0;
 	default:
 		return EOPNOTSUPP;
@@ -1832,8 +1834,9 @@ urtwn_newassoc(struct ieee80211_node *ni
 }
 
 static __unused int
-urtwn_newstate(struct urtwn_softc *sc, enum ieee80211_state nstate, int arg)
+urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
 {
+	struct urtwn_softc *sc = vap->iv_ic->ic_softc;
 	struct urtwn_cmd_newstate cmd;
 
 	DPRINTFN(DBG_FN, ("%s: %s: nstate=%s(%d), arg=%d\n",
@@ -2151,7 +2154,7 @@ urtwn_newstate_cb(struct urtwn_softc *sc
 		break;
 	}
 
-	(*sc->sc_newstate)(ic, nstate, cmd->arg);
+	(*sc->sc_newstate)(vap, nstate, cmd->arg);
 
 	mutex_exit(&sc->sc_write_mtx);
 	splx(s);
@@ -2561,7 +2564,7 @@ urtwn_txeof(struct usbd_xfer *xfer, void
 {
 	struct urtwn_tx_data *data = priv;
 	struct urtwn_softc *sc = data->sc;
-	struct ifnet *ifp = &sc->sc_if;
+	struct ifnet *ifp = TAILQ_FIRST(&sc->sc_ic.ic_vaps)->iv_ifp;
 	size_t pidx = data->pidx;
 	int s;
 
@@ -2955,10 +2958,85 @@ urtwn_watchdog(struct ifnet *ifp)
 //NNN	ieee80211_watchdog(&sc->sc_ic);  Not sure what is happening!
 }
 
+/*
+ *  Create a VAP node for use with the urtwn driver.
+ */
+
+static struct ieee80211vap *
+urtwn_vap_create(struct ieee80211com *ic,  const char name[IFNAMSIZ],
+    int  unit, enum ieee80211_opmode opmode, int flags,
+    const uint8_t bssid[IEEE80211_ADDR_LEN],
+    const uint8_t macaddr[IEEE80211_ADDR_LEN])
+{
+	printf ("in urtwn_vap_create ... \n");
+
+	struct urtwn_softc *sc = ic->ic_softc;
+	struct ifnet *ifp;
+	struct ieee80211vap *vap;
+
+	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+
+	/* Allow only one VAP for the urtwn driver. */
+	if (!TAILQ_EMPTY(&ic->ic_vaps))
+		return NULL;
+
+	/* Allocate the vap and setup. */
+	vap = kmem_zalloc(sizeof(struct ieee80211vap), KM_SLEEP);
+	if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
+	    flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) {
+		kmem_free(vap, sizeof(struct ieee80211vap));
+		return NULL;
+	}
+
+	printf ("vap_create:  after vap_setup\n");
+
+	/* Local setup */
+	vap->iv_reset = urtwn_reset;
+
+	ifp = vap->iv_ifp;
+	ifp->if_init = urtwn_init;
+	ifp->if_ioctl = urtwn_ioctl;
+	ifp->if_start = urtwn_start;
+	ifp->if_watchdog = urtwn_watchdog;
+	IFQ_SET_READY(&ifp->if_snd);
+	memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
+
+	/* NNN needed ??? */
+	/* if_attach(ifp); */
+
+	/* Override state transition machine. */
+	sc->sc_newstate = vap->iv_newstate;
+	vap->iv_newstate = urtwn_newstate;
+
+	/* Finish setup */
+	ieee80211_vap_attach(vap, urtwn_media_change,
+	    ieee80211_media_status, macaddr);
+	ic->ic_opmode = opmode;
+
+	return vap;
+}
+
+static void
+urtwn_vap_delete(struct ieee80211vap *vap)
+{
+	struct ifnet *ifp = vap->iv_ifp;
+	struct urtwn_softc *sc __unused =vap->iv_ic->ic_softc;
+
+	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+
+	urtwn_stop(ifp, 0);
+	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	bpf_detach(ifp);
+	if_detach(ifp);
+	kmem_free(vap, sizeof(struct ieee80211vap));
+}
+
 static int
 urtwn_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
-	struct urtwn_softc *sc __unused = ifp->if_softc;
+
+	struct ieee80211vap *vap = ifp->if_softc;
+	struct urtwn_softc *sc __unused = vap->iv_ic->ic_softc;
 	int s, error = 0;
 
 	DPRINTFN(DBG_FN, ("%s: %s: cmd=0x%08lx, data=%p\n",
@@ -4999,9 +5077,10 @@ urtwn_stop(struct ifnet *ifp, int disabl
 		urtwn_chip_stop(sc);
 }
 
-static __unused int
-urtwn_reset(struct ifnet *ifp)
+static int
+urtwn_reset(struct ieee80211vap *vap, u_long arg)
 {
+	struct ifnet *ifp = vap->iv_ifp;
 	struct urtwn_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = &sc->sc_ic;
 

Index: src/sys/dev/usb/if_urtwnvar.h
diff -u src/sys/dev/usb/if_urtwnvar.h:1.10 src/sys/dev/usb/if_urtwnvar.h:1.10.16.1
--- src/sys/dev/usb/if_urtwnvar.h:1.10	Wed Oct 12 03:23:29 2016
+++ src/sys/dev/usb/if_urtwnvar.h	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwnvar.h,v 1.10 2016/10/12 03:23:29 nat Exp $	*/
+/*	$NetBSD: if_urtwnvar.h,v 1.10.16.1 2018/07/16 20:11:11 phil Exp $	*/
 /*	$OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $	*/
 
 /*-
@@ -111,9 +111,9 @@ struct urtwn_host_cmd_ring {
 struct urtwn_softc {
 	device_t			sc_dev;
 	struct ieee80211com		sc_ic;
-	struct ethercom			sc_ec;
-#define sc_if   sc_ec.ec_if
-	int				(*sc_newstate)(struct ieee80211com *,
+	//	struct ethercom			sc_ec;
+	//#define sc_if   sc_ec.ec_if
+	int				(*sc_newstate)(struct ieee80211vap *,
 					    enum ieee80211_state, int);
 
 	struct usbd_device *		sc_udev;

Index: src/sys/net80211/ieee80211.c
diff -u src/sys/net80211/ieee80211.c:1.56.18.2 src/sys/net80211/ieee80211.c:1.56.18.3
--- src/sys/net80211/ieee80211.c:1.56.18.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.56.18.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211.c,v 1.56.18.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -330,6 +330,8 @@ static struct mtx ic_list_mtx;
 MTX_SYSINIT(ic_list, &ic_list_mtx, "ieee80211com list", MTX_DEF);
 #elif __NetBSD__
 static kmutex_t ic_list_mtx;
+static uint     ic_list_mtx_needsinit = 1;
+static uint     ic_list_mtx_ready = 0;
 #endif
 
 #if notyet
@@ -370,12 +372,29 @@ SYSCTL_PROC(_net_wlan, OID_AUTO, devices
 void
 ieee80211_ifattach(struct ieee80211com *ic)
 {
+#if __NetBSD__
+	/* Initialize the ic_list_mtx the first time here.
+	 * Only want to use the big lock on first try to initialize.
+         * Once initialized, it won't use the big lock any more.
+         */
+	if (ic_list_mtx_needsinit) {
+		KERNEL_LOCK(1, NULL);
+		if (!ic_list_mtx_ready) {
+			mutex_init(&ic_list_mtx, MUTEX_DEFAULT, IPL_NET);
+			ic_list_mtx_ready = 1;
+			ic_list_mtx_needsinit = 0;
+			/* Doing this one-time initialization here also. */
+			ieee80211_auth_setup();
+		}
+		KERNEL_UNLOCK_ONE(NULL);
+	}
+#endif
 
 	IEEE80211_LOCK_INIT(ic, ic->ic_name);
 	IEEE80211_TX_LOCK_INIT(ic, ic->ic_name);
 	TAILQ_INIT(&ic->ic_vaps);
 
-#ifdef notyet
+#if __FreeBSD__
 	/* Create a taskqueue for all state changes */
 	ic->ic_tq = taskqueue_create("ic_taskq", M_WAITOK | M_ZERO,
 	    taskqueue_thread_enqueue, &ic->ic_tq);
@@ -383,7 +402,12 @@ ieee80211_ifattach(struct ieee80211com *
 	    ic->ic_name);
 	ic->ic_ierrors = counter_u64_alloc(M_WAITOK);
 	ic->ic_oerrors = counter_u64_alloc(M_WAITOK);
+#elif__NetBSD__
+	/* NNN task/workqueue get it ready.... */
+	ic->ic_ierrors = 0;
+	ic->ic_oerrors = 0;
 #endif
+
 	/*
 	 * Fill in 802.11 available channel set, mark all
 	 * available channels as active, and pick a default
@@ -567,21 +591,22 @@ ieee80211_vap_setup(struct ieee80211com 
 		    __func__);
 		return ENOMEM;
 	}
+#if __NetBSD__
+	if_initialize(ifp);
+#endif
 	if_initname(ifp, name, unit);
 	ifp->if_softc = vap;			/* back pointer */
 	ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
 	ifp->if_transmit = ieee80211_vap_transmit;
-#ifdef __FreeBSD__
+#if __FreeBSD__
 	ifp->if_qflush = ieee80211_vap_qflush;
 #endif
-#ifdef notyet
 	ifp->if_ioctl = ieee80211_ioctl;
 	ifp->if_init = ieee80211_init;
-#endif
-#ifdef __FreeBSD__
+
+#if notyet
 	ifp->if_get_counter = ieee80211_get_counter;
 #endif
-
 	vap->iv_ifp = ifp;
 	vap->iv_ic = ic;
 	vap->iv_flags = ic->ic_flags;		/* propagate common flags */
@@ -728,10 +753,9 @@ ieee80211_vap_attach(struct ieee80211vap
 	ether_ifattach(ifp, macaddr);
 	IEEE80211_ADDR_COPY(vap->iv_myaddr, IF_LLADDR(ifp));
 	/* hook output method setup by ether_ifattach */
-#ifdef notyet
 	vap->iv_output = ifp->if_output;
 	ifp->if_output = ieee80211_output;
-#endif
+
 	/* NB: if_mtu set by ether_ifattach to ETHERMTU */
 
 	IEEE80211_LOCK(ic);
@@ -752,6 +776,10 @@ ieee80211_vap_attach(struct ieee80211vap
 	ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT160);
 	IEEE80211_UNLOCK(ic);
 
+#if __NetBSD__
+	if_register(ifp);
+#endif
+
 	return 1;
 }
 

Index: src/sys/net80211/ieee80211_acl.c
diff -u src/sys/net80211/ieee80211_acl.c:1.9.54.2 src/sys/net80211/ieee80211_acl.c:1.9.54.3
--- src/sys/net80211/ieee80211_acl.c:1.9.54.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_acl.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_acl.c,v 1.9.54.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_acl.c,v 1.9.54.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 __FBSDID("$FreeBSD$");
 #endif
 
@@ -57,8 +57,10 @@ __FBSDID("$FreeBSD$");
 
 #include <net/if.h>
 #include <net/if_media.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 #include <net/ethernet.h>
+#elif __NetBSD__
+#include <net/if_ether.h>
 #endif
 #include <net/route.h>
 
@@ -101,7 +103,7 @@ struct aclstate {
 #define	ACL_HASH(addr)	\
 	(((const uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % ACL_HASHSIZE)
 
-#ifdef __FreeBSD__
+#if __FreeBSD__
 static MALLOC_DEFINE(M_80211_ACL, "acl", "802.11 station acl");
 #endif
 

Index: src/sys/net80211/ieee80211_amrr.c
diff -u src/sys/net80211/ieee80211_amrr.c:1.3.18.2 src/sys/net80211/ieee80211_amrr.c:1.3.18.3
--- src/sys/net80211/ieee80211_amrr.c:1.3.18.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_amrr.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_amrr.c,v 1.3.18.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_amrr.c,v 1.3.18.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*	$OpenBSD: ieee80211_amrr.c,v 1.1 2006/06/17 19:07:19 damien Exp $	*/
 
@@ -97,10 +97,10 @@ static void	amrr_node_stats(struct ieee8
 /* number of references from net80211 layer */
 static	int nrefs = 0;
 
-#ifdef notyet
+#if __FreeBSD__
 static const struct ieee80211_ratectl amrr = {
 #else
-static const struct ieee80211_ratectl __unused amrr = {
+const struct ieee80211_ratectl ratectl_amrr = {
 #endif
 	.ir_name	= "amrr",
 	.ir_attach	= NULL,
@@ -115,11 +115,9 @@ static const struct ieee80211_ratectl __
 	.ir_setinterval	= amrr_setinterval,
 	.ir_node_stats	= amrr_node_stats,
 };
+#if __FreeBSD__
 IEEE80211_RATECTL_MODULE(amrr, 1);
 IEEE80211_RATECTL_ALG(amrr, IEEE80211_RATECTL_AMRR, amrr);
-
-#ifdef __NetBSD__
-#define amrr amrr0
 #endif
 
 static void

Index: src/sys/net80211/ieee80211_crypto.c
diff -u src/sys/net80211/ieee80211_crypto.c:1.23.2.2 src/sys/net80211/ieee80211_crypto.c:1.23.2.3
--- src/sys/net80211/ieee80211_crypto.c:1.23.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_crypto.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_crypto.c,v 1.23.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_crypto.c,v 1.23.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 __FBSDID("$FreeBSD$");
 #endif
 
@@ -47,10 +47,11 @@ __FBSDID("$FreeBSD$");
 
 #include <net/if.h>
 #include <net/if_media.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 #include <net/ethernet.h>		/* XXX ETHER_HDR_LEN */
 #endif
-#ifdef __NetBSD__
+#if __NetBSD__
+#include <net/if_ether.h>
 #include <net/route.h>
 #endif
 
@@ -248,7 +249,7 @@ ieee80211_crypto_available(u_int cipher)
 	return cipher < IEEE80211_CIPHER_MAX && ciphers[cipher] != NULL;
 }
 
-#ifdef __FreeBSD__ 
+#if __FreeBSD__ 
 /* XXX well-known names! */
 static const char *cipher_modnames[IEEE80211_CIPHER_MAX] = {
 	[IEEE80211_CIPHER_WEP]	   = "wlan_wep",

Index: src/sys/net80211/ieee80211_crypto_tkip.c
diff -u src/sys/net80211/ieee80211_crypto_tkip.c:1.14.4.2 src/sys/net80211/ieee80211_crypto_tkip.c:1.14.4.3
--- src/sys/net80211/ieee80211_crypto_tkip.c:1.14.4.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_crypto_tkip.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_crypto_tkip.c,v 1.14.4.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_crypto_tkip.c,v 1.14.4.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -205,12 +205,22 @@ tkip_encap(struct ieee80211_key *k, stru
 	 * Handle TKIP counter measures requirement.
 	 */
 	if (vap->iv_flags & IEEE80211_F_COUNTERM) {
+#if __FreeBSD__
 #ifdef IEEE80211_DEBUG
 		struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *);
 #endif
 
 		IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
 		    "discard frame due to countermeasures (%s)", __func__);
+#elif __NetBSD__
+#ifdef IEEE80211_DEBUG
+		struct ieee80211_frame *wh1 = mtod(m, struct ieee80211_frame *);
+#endif
+
+		IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, 
+		    (const __uint8_t *)wh1->i_addr2,
+		    "discard frame due to countermeasures (%s)", __func__);
+#endif
 		vap->iv_stats.is_crypto_tkipcm++;
 		return 0;
 	}

Index: src/sys/net80211/ieee80211_crypto_wep.c
diff -u src/sys/net80211/ieee80211_crypto_wep.c:1.12.2.2 src/sys/net80211/ieee80211_crypto_wep.c:1.12.2.3
--- src/sys/net80211/ieee80211_crypto_wep.c:1.12.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_crypto_wep.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_crypto_wep.c,v 1.12.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_crypto_wep.c,v 1.12.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <net/ethernet.h>
 #endif
 #ifdef __NetBSD__
+#include <net/if_ether.h>
 #include <net/route.h>
 #endif
 
@@ -413,8 +414,13 @@ wep_encrypt(struct ieee80211_key *key, s
 		if (m->m_next == NULL) {
 			if (data_len != 0) {		/* out of data */
 				IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO,
+#if __FreeBSD__
 				    ether_sprintf(mtod(m0,
 					struct ieee80211_frame *)->i_addr2),
+#elif __NetBSD__
+				    ether_sprintf((const __uint8_t *)mtod(m0,
+					struct ieee80211_frame *)->i_addr2),
+#endif
 				    "out of data for WEP (data_len %zu)",
 				    data_len);
 				/* XXX stat */

Index: src/sys/net80211/ieee80211_ht.c
diff -u src/sys/net80211/ieee80211_ht.c:1.1.56.3 src/sys/net80211/ieee80211_ht.c:1.1.56.4
--- src/sys/net80211/ieee80211_ht.c:1.1.56.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_ht.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ht.c,v 1.1.56.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_ht.c,v 1.1.56.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -2023,7 +2023,11 @@ ieee80211_setup_basic_htrates(struct iee
 static void
 ampdu_tx_setup(struct ieee80211_tx_ampdu *tap)
 {
+#if __FreeBSD__
 	callout_init(&tap->txa_timer, 1);
+#elif __NetBSD__
+	callout_init(&tap->txa_timer, CALLOUT_MPSAFE);
+#endif
 	tap->txa_flags |= IEEE80211_AGGR_SETUP;
 	tap->txa_lastsample = ticks;
 }
Index: src/sys/net80211/ieee80211_scan.c
diff -u src/sys/net80211/ieee80211_scan.c:1.1.56.3 src/sys/net80211/ieee80211_scan.c:1.1.56.4
--- src/sys/net80211/ieee80211_scan.c:1.1.56.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_scan.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_scan.c,v 1.1.56.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_scan.c,v 1.1.56.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 __FBSDID("$FreeBSD$");
 #endif
 
@@ -47,14 +47,15 @@ __FBSDID("$FreeBSD$");
 #include <sys/socket.h>
 
 #include <net/if.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 #include <net/if_var.h>
 #endif
 #include <net/if_media.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 #include <net/ethernet.h>
 #endif
-#ifdef __NetBSD__
+#if __NetBSD__
+#include <net/if_ether.h>
 #include <net/route.h>
 #endif
 
Index: src/sys/net80211/ieee80211_scan_sta.c
diff -u src/sys/net80211/ieee80211_scan_sta.c:1.1.56.3 src/sys/net80211/ieee80211_scan_sta.c:1.1.56.4
--- src/sys/net80211/ieee80211_scan_sta.c:1.1.56.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_scan_sta.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_scan_sta.c,v 1.1.56.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_scan_sta.c,v 1.1.56.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 __FBSDID("$FreeBSD$");
 #endif
 
@@ -50,14 +50,15 @@ __FBSDID("$FreeBSD$");
 #include <sys/socket.h>
 
 #include <net/if.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 #include <net/if_var.h>
 #endif
 #include <net/if_media.h>
-#ifdef __FreeBSD__
+#if __FreeBSD__
 #include <net/ethernet.h>
 #endif
-#ifdef __NetBSD__
+#if __NetBSD__
+#include <net/if_ether.h>
 #include <net/route.h>
 #endif
 

Index: src/sys/net80211/ieee80211_hwmp.c
diff -u src/sys/net80211/ieee80211_hwmp.c:1.1.2.2 src/sys/net80211/ieee80211_hwmp.c:1.1.2.3
--- src/sys/net80211/ieee80211_hwmp.c:1.1.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_hwmp.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_hwmp.c,v 1.1.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_hwmp.c,v 1.1.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*- 
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include <net/ethernet.h>
 #endif
 #ifdef __NetBSD__
+#include <net/if_ether.h>
 #include <net/route.h>
 #endif
 
@@ -276,7 +277,11 @@ hwmp_vattach(struct ieee80211vap *vap)
 		return;
 	}
 	hs->hs_maxhops = IEEE80211_HWMP_DEFAULT_MAXHOPS;
+#if __FreeBSD__
 	callout_init(&hs->hs_roottimer, 1);
+#elif __NetBSD__
+	callout_init(&hs->hs_roottimer, CALLOUT_MPSAFE);
+#endif
 	vap->iv_hwmp = hs;
 }
 
Index: src/sys/net80211/ieee80211_mesh.c
diff -u src/sys/net80211/ieee80211_mesh.c:1.1.2.2 src/sys/net80211/ieee80211_mesh.c:1.1.2.3
--- src/sys/net80211/ieee80211_mesh.c:1.1.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_mesh.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_mesh.c,v 1.1.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_mesh.c,v 1.1.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*- 
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -228,7 +228,11 @@ mesh_rt_add_locked(struct ieee80211vap *
 		IEEE80211_ADDR_COPY(rt->rt_dest, dest);
 		rt->rt_priv = (void *)ALIGN(&rt[1]);
 		MESH_RT_ENTRY_LOCK_INIT(rt, "MBSS_RT");
+#if __FreeBSD__
 		callout_init(&rt->rt_discovery, 1);
+#elif __NetBSD__
+		callout_init(&rt->rt_discovery, CALLOUT_MPSAFE);
+#endif
 		rt->rt_updtime = ticks;	/* create time */
 		TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next);
 	}
@@ -688,8 +692,13 @@ mesh_vattach(struct ieee80211vap *vap)
 	TAILQ_INIT(&ms->ms_known_gates);
 	TAILQ_INIT(&ms->ms_routes);
 	MESH_RT_LOCK_INIT(ms, "MBSS");
+#if __FreeBSD__
 	callout_init(&ms->ms_cleantimer, 1);
 	callout_init(&ms->ms_gatetimer, 1);
+#elif __NetBSD__
+	callout_init(&ms->ms_cleantimer, CALLOUT_MPSAFE);
+	callout_init(&ms->ms_gatetimer, CALLOUT_MPSAFE);
+#endif
 	ms->ms_gateseq = 0;
 	mesh_select_proto_metric(vap, "AIRTIME");
 	KASSERT(ms->ms_pmetric, ("ms_pmetric == NULL"));
@@ -1298,7 +1307,11 @@ mesh_decap(struct ieee80211vap *vap, str
 		WHDIR(wh) == IEEE80211_FC1_DIR_DSTODS,
 	    ("bogus dir, fc 0x%x:0x%x", wh->i_fc[0], wh->i_fc[1]));
 
+#if __FreeBSD__
 	llc = (struct llc *)(mtod(m, caddr_t) + hdrlen);
+#elif __NetBSD__
+	llc = (struct llc *)(mtod(m, __uint8_t *) + hdrlen);
+#endif
 	if (llc->llc_dsap == LLC_SNAP_LSAP && llc->llc_ssap == LLC_SNAP_LSAP &&
 	    llc->llc_control == LLC_UI && llc->llc_snap.org_code[0] == 0 &&
 	    llc->llc_snap.org_code[1] == 0 && llc->llc_snap.org_code[2] == 0 &&
@@ -3397,8 +3410,13 @@ void
 ieee80211_mesh_node_init(struct ieee80211vap *vap, struct ieee80211_node *ni)
 {
 	ni->ni_flags |= IEEE80211_NODE_QOS;
+#if __FreeBSD__
 	callout_init(&ni->ni_mltimer, 1);
 	callout_init(&ni->ni_mlhtimer, 1);
+#elif __NetBSD__
+	callout_init(&ni->ni_mltimer, CALLOUT_MPSAFE);
+	callout_init(&ni->ni_mlhtimer, CALLOUT_MPSAFE);
+#endif
 }
 
 /*
Index: src/sys/net80211/ieee80211_ratectl.c
diff -u src/sys/net80211/ieee80211_ratectl.c:1.1.2.2 src/sys/net80211/ieee80211_ratectl.c:1.1.2.3
--- src/sys/net80211/ieee80211_ratectl.c:1.1.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_ratectl.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ratectl.c,v 1.1.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_ratectl.c,v 1.1.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -49,17 +49,32 @@ __FBSDID("$FreeBSD$");
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_ratectl.h>
 
+#if __FreeBSD__
 static const struct ieee80211_ratectl *ratectls[IEEE80211_RATECTL_MAX];
 
-static const char *ratectl_modnames[IEEE80211_RATECTL_MAX] __unused = {
+static const char *ratectl_modnames[IEEE80211_RATECTL_MAX] = {
 	[IEEE80211_RATECTL_AMRR]	= "wlan_amrr",
 	[IEEE80211_RATECTL_RSSADAPT]	= "wlan_rssadapt",
 	[IEEE80211_RATECTL_ONOE]	= "wlan_onoe",
 	[IEEE80211_RATECTL_SAMPLE]	= "wlan_sample",
 	[IEEE80211_RATECTL_NONE]	= "wlan_none",
-};
 
 MALLOC_DEFINE(M_80211_RATECTL, "80211ratectl", "802.11 rate control");
+};
+#elif __NetBSD__
+extern const struct ieee80211_ratectl ratectl_amrr;
+extern const struct ieee80211_ratectl ratectl_rssadapt;
+extern const struct ieee80211_ratectl ratectl_none;
+
+static const struct ieee80211_ratectl *ratectls[IEEE80211_RATECTL_MAX] = {
+	[IEEE80211_RATECTL_AMRR]	= &ratectl_amrr,
+	[IEEE80211_RATECTL_RSSADAPT]	= &ratectl_rssadapt,
+	[IEEE80211_RATECTL_ONOE]	= NULL,
+	[IEEE80211_RATECTL_SAMPLE]	= NULL,
+	[IEEE80211_RATECTL_NONE]	= &ratectl_none,
+};
+#endif
+
 
 void
 ieee80211_ratectl_register(int type, const struct ieee80211_ratectl *ratectl)
@@ -117,9 +132,12 @@ ieee80211_ratectl_sysctl_stats(SYSCTL_HA
 void
 ieee80211_ratectl_init(struct ieee80211vap *vap)
 {
+	printf ("ratectl_init enter\n");
 	if (vap->iv_rate == ratectls[IEEE80211_RATECTL_NONE])
 		ieee80211_ratectl_set(vap, IEEE80211_RATECTL_AMRR);
+	printf ("ratectl_init middle\n");
 	vap->iv_rate->ir_init(vap);
+	printf ("ratectl_init end\n");
 
 #ifdef notyet
 	/* Attach generic stats sysctl */
@@ -134,8 +152,8 @@ ieee80211_ratectl_set(struct ieee80211va
 {
 	if (type >= IEEE80211_RATECTL_MAX)
 		return;
-#ifdef notyet
 	if (ratectls[type] == NULL) {
+#if __FreeBSD__
 		ieee80211_load_module(ratectl_modnames[type]);
 		if (ratectls[type] == NULL) {
 			IEEE80211_DPRINTF(vap, IEEE80211_MSG_RATECTL,
@@ -144,7 +162,11 @@ ieee80211_ratectl_set(struct ieee80211va
 			vap->iv_rate = ratectls[IEEE80211_RATECTL_NONE];
 			return;
 		}
-	}
+#elsif __NetBSD__
+		type = IEEE80211_RATECTL_NONE;
 #endif
+	}
+
+
 	vap->iv_rate = ratectls[type];
 }
Index: src/sys/net80211/ieee80211_ratectl_none.c
diff -u src/sys/net80211/ieee80211_ratectl_none.c:1.1.2.2 src/sys/net80211/ieee80211_ratectl_none.c:1.1.2.3
--- src/sys/net80211/ieee80211_ratectl_none.c:1.1.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_ratectl_none.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ratectl_none.c,v 1.1.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_ratectl_none.c,v 1.1.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -114,7 +114,11 @@ none_setinterval(const struct ieee80211v
 /* number of references from net80211 layer */
 static	int nrefs __unused = 0;
 
-static const struct ieee80211_ratectl none __unused = {
+#if __FreeBSD__
+static const struct ieee80211_ratectl none = {
+#elif __NetBSD__
+const struct ieee80211_ratectl ratectl_none = {
+#endif
 	.ir_name	= "none",
 	.ir_attach	= NULL,
 	.ir_detach	= NULL,
@@ -127,7 +131,8 @@ static const struct ieee80211_ratectl no
 	.ir_tx_update	= none_tx_update,
 	.ir_setinterval	= none_setinterval,
 };
-#ifdef notyet
+
+#if __FreeBSD__
 IEEE80211_RATECTL_MODULE(ratectl_none, 1);
 IEEE80211_RATECTL_ALG(none, IEEE80211_RATECTL_NONE, none);
 #endif

Index: src/sys/net80211/ieee80211_input.c
diff -u src/sys/net80211/ieee80211_input.c:1.114.2.2 src/sys/net80211/ieee80211_input.c:1.114.2.3
--- src/sys/net80211/ieee80211_input.c:1.114.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_input.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_input.c,v 1.114.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_input.c,v 1.114.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -342,7 +342,11 @@ ieee80211_decap(struct ieee80211vap *vap
 		return NULL;
 	}
 	memcpy(&wh, mtod(m, caddr_t), hdrlen);
+#if __FreeBSD__
 	llc = (struct llc *)(mtod(m, caddr_t) + hdrlen);
+#elif __NetBSD__
+	llc = (struct llc *)(mtod(m, __uint8_t *) + hdrlen);
+#endif
 	if (llc->llc_dsap == LLC_SNAP_LSAP && llc->llc_ssap == LLC_SNAP_LSAP &&
 	    llc->llc_control == LLC_UI && llc->llc_snap.org_code[0] == 0 &&
 	    llc->llc_snap.org_code[1] == 0 && llc->llc_snap.org_code[2] == 0 &&
@@ -932,7 +936,11 @@ ieee80211_getbssid(const struct ieee8021
 	return wh->i_addr3;
 }
 
+#if __FreeBSD__
 #include <machine/stdarg.h>
+#elif __NetBSD__
+#include <sys/stdarg.h>
+#endif
 
 void
 ieee80211_note(const struct ieee80211vap *vap, const char *fmt, ...)

Index: src/sys/net80211/ieee80211_ioctl.c
diff -u src/sys/net80211/ieee80211_ioctl.c:1.60.18.2 src/sys/net80211/ieee80211_ioctl.c:1.60.18.3
--- src/sys/net80211/ieee80211_ioctl.c:1.60.18.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_ioctl.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ioctl.c,v 1.60.18.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_ioctl.c,v 1.60.18.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -784,7 +784,7 @@ IEEE80211_IOCTL_GET(dummy, dummy_ioctl_g
 static int
 ieee80211_ioctl_getdefault(struct ieee80211vap *vap, struct ieee80211req *ireq)
 {
-#ifdef notyet
+#if notyet
 	ieee80211_ioctl_getfunc * const *get;
 	int error;
 
@@ -793,6 +793,8 @@ ieee80211_ioctl_getdefault(struct ieee80
 		if (error != ENOSYS)
 			return error;
 	}
+#else
+	printf ("i33380211_ioctl_getdefault called\n");
 #endif
 	return EINVAL;
 }
@@ -2712,6 +2714,8 @@ ieee80211_ioctl_setdefault(struct ieee80
 		if (error != ENOSYS)
 			return error;
 	}
+#else
+	printf ("ieee80211_ioctl_setdefault called\n");
 #endif
 	return EINVAL;
 }
@@ -3496,7 +3500,12 @@ ieee80211_ioctl_set80211(struct ieee8021
 	if (error == ENETRESET) {
 		/* XXX need to re-think AUTO handling */
 		if (IS_UP_AUTO(vap))
+#if __FreeBSD__
 			ieee80211_init(vap);
+#elif __NetBSD__
+			/* arg is a vap in 802.11 code */ 
+			ieee80211_init((struct ifnet *)vap);
+#endif
 		error = 0;
 	}
 	return error;

Index: src/sys/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.31.2.2 src/sys/net80211/ieee80211_netbsd.c:1.31.2.3
--- src/sys/net80211/ieee80211_netbsd.c:1.31.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_netbsd.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_netbsd.c,v 1.31.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_netbsd.c,v 1.31.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 /*  __FBSDID("$FreeBSD$");  */
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.2 2018/07/12 16:35:34 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.3 2018/07/16 20:11:11 phil Exp $");
 
 /*
  * IEEE 802.11 support (NetBSD-specific code)
@@ -69,16 +69,15 @@ static int	ieee80211_debug = 0;
 SYSCTL_INT(_net_wlan, OID_AUTO, debug, CTLFLAG_RW, &ieee80211_debug,
 	    0, "debugging printfs");
 #endif
-#endif /* notyet */
 
-/* static MALLOC_DEFINE(M_80211_COM, "80211com", "802.11 com state"); NNN */
+static struct if_clone *wlan_cloner;
+#endif 
+/* notyet */
 
-#ifdef notyet
 static const char wlanname[] = "wlan";
-static struct if_clone *wlan_cloner;
 
-static int
-wlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
+static __unused int
+wlan_clone_create(struct if_clone *ifc, int unit, void * params)
 {
 	struct ieee80211_clone_params cp;
 	struct ieee80211vap *vap;
@@ -119,7 +118,7 @@ wlan_clone_create(struct if_clone *ifc, 
 	return (vap == NULL ? EIO : 0);
 }
 
-static void
+static __unused void
 wlan_clone_destroy(struct ifnet *ifp)
 {
 	struct ieee80211vap *vap = ifp->if_softc;
@@ -127,7 +126,6 @@ wlan_clone_destroy(struct ifnet *ifp)
 
 	ic->ic_vap_delete(vap);
 }
-#endif 
 
 void
 ieee80211_vap_destroy(struct ieee80211vap *vap)
@@ -137,7 +135,7 @@ ieee80211_vap_destroy(struct ieee80211va
 	if_clone_destroyif(wlan_cloner, vap->iv_ifp);
 	CURVNET_RESTORE();
 #else
-	panic("ieee80211_vap_destroy");
+	printf ("vap_destroy called ... what next?\n");
 #endif
 }
 
@@ -929,11 +927,10 @@ ieee80211_notify_radio(struct ieee80211c
 	}
 }
 
+#ifdef notyet
 void
 ieee80211_load_module(const char *modname)
 {
-
-#ifdef notyet
 	struct thread *td = curthread;
 
 	if (suser(td) == 0 && securelevel_gt(td->td_ucred, 0) == 0) {
@@ -941,10 +938,8 @@ ieee80211_load_module(const char *modnam
 		(void) linker_load_module(modname, NULL, NULL, NULL, NULL);
 		mtx_unlock(&Giant);
 	}
-#else
-	printf("%s: load the %s module by hand for now.\n", __func__, modname);
-#endif
 }
+#endif
 
 #ifdef notyet
 static eventhandler_tag wlan_bpfevent;
@@ -1198,8 +1193,8 @@ m_unshare(struct mbuf *m0, int how)
 			if (mprev && (mprev->m_flags & M_EXT) &&
 			    m->m_len <= M_TRAILINGSPACE(mprev)) {
 				/* XXX: this ignores mbuf types */
-				memcpy(mtod(mprev, caddr_t) + mprev->m_len,
-				    mtod(m, caddr_t), m->m_len);
+				memcpy(mtod(mprev, __uint8_t *) + mprev->m_len,
+				    mtod(m, __uint8_t *), m->m_len);
 				mprev->m_len += m->m_len;
 				mprev->m_next = m->m_next;	/* unlink from chain */
 				m_free(m);			/* reclaim mbuf */
@@ -1227,8 +1222,8 @@ m_unshare(struct mbuf *m0, int how)
 		if (mprev != NULL && (mprev->m_flags & M_EXT) &&
 		    m->m_len <= M_TRAILINGSPACE(mprev)) {
 			/* XXX: this ignores mbuf types */
-			memcpy(mtod(mprev, caddr_t) + mprev->m_len,
-			    mtod(m, caddr_t), m->m_len);
+			memcpy(mtod(mprev, __uint8_t *) + mprev->m_len,
+			    mtod(m, __uint8_t *), m->m_len);
 			mprev->m_len += m->m_len;
 			mprev->m_next = m->m_next;	/* unlink from chain */
 			m_free(m);			/* reclaim mbuf */
@@ -1259,7 +1254,7 @@ m_unshare(struct mbuf *m0, int how)
 		mlast = NULL;
 		for (;;) {
 			int cc = min(len, MCLBYTES);
-			memcpy(mtod(n, caddr_t), mtod(m, caddr_t) + off, cc);
+			memcpy(mtod(n, __uint8_t *), mtod(m, __uint8_t *) + off, cc);
 			n->m_len = cc;
 			if (mlast != NULL)
 				mlast->m_next = n;

Index: src/sys/net80211/ieee80211_netbsd.h
diff -u src/sys/net80211/ieee80211_netbsd.h:1.21.2.3 src/sys/net80211/ieee80211_netbsd.h:1.21.2.4
--- src/sys/net80211/ieee80211_netbsd.h:1.21.2.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_netbsd.h	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_netbsd.h,v 1.21.2.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_netbsd.h,v 1.21.2.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -60,7 +60,7 @@
 #define __offsetof(type, field)  __builtin_offsetof(type, field)
 #define arc4random  cprng_fast32
 #define atomic_subtract_int(var,val) atomic_add_int(var,-(val))
-#define caddr_t __caddr_t
+#define caddr_t void *
 #define callout_drain(x)  callout_halt(x, NULL)
 #define m_catpkt(x,y)    m_cat(x,y)
 #define mtx_lock(mtx) 		mutex_enter(mtx)
@@ -482,7 +482,6 @@ SYSCTL_DECL(_net_wlan);
 int	ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
 #endif 
 
-void	ieee80211_load_module(const char *);
 
 #ifdef notyet
 

Index: src/sys/net80211/ieee80211_node.c
diff -u src/sys/net80211/ieee80211_node.c:1.75.4.2 src/sys/net80211/ieee80211_node.c:1.75.4.3
--- src/sys/net80211/ieee80211_node.c:1.75.4.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_node.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_node.c,v 1.75.4.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_node.c,v 1.75.4.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -131,7 +131,11 @@ ieee80211_node_attach(struct ieee80211co
 	    "802.11 staging q");
 	ieee80211_node_table_init(ic, &ic->ic_sta, "station",
 		IEEE80211_INACT_INIT, ic->ic_max_keyix);
+#if __FreeBSD__
 	callout_init(&ic->ic_inact, 1);
+#elif __NetBSD__
+	callout_init(&ic->ic_inact, CALLOUT_MPSAFE);
+#endif
 	callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz,
 		ieee80211_node_timeout, ic);
 
@@ -460,16 +464,27 @@ ieee80211_create_ibss(struct ieee80211va
 void
 ieee80211_reset_bss(struct ieee80211vap *vap)
 {
+	printf ("reset_bss: vap is 0x%lx\n", (unsigned long) vap);
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ieee80211_node *ni, *obss;
 
+	printf ("reset_bss: ic is 0x%lx\n", (unsigned long) ic);
+
 	ieee80211_node_table_reset(&ic->ic_sta, vap);
+
+	printf ("reset_bss: after table_reset\n");
 	/* XXX multi-bss: wrong */
 	ieee80211_reset_erp(ic);
 
+	printf ("reset_bss: after reset_erp\n");
+
 	ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr);
 	KASSERT(ni != NULL, ("unable to setup initial BSS node"));
+
+	printf ("reset_bss: after alloc_node\n");
+
 	obss = vap->iv_bss;
+printf ("reset_bss: obss is 0x%lx\n", (unsigned long int)obss);
 	vap->iv_bss = ieee80211_ref_node(ni);
 	if (obss != NULL) {
 		copy_bss(ni, obss);
@@ -1442,7 +1457,9 @@ ieee80211_alloc_node(struct ieee80211_no
 	IEEE80211_NOTE(vap, IEEE80211_MSG_INACT, ni,
 	    "%s: inact_reload %u", __func__, ni->ni_inact_reload);
 
+	printf ("before ratectl_node_init call\n");
 	ieee80211_ratectl_node_init(ni);
+	printf ("after ratectl_node_init\n");
 
 	return ni;
 }

Index: src/sys/net80211/ieee80211_output.c
diff -u src/sys/net80211/ieee80211_output.c:1.63.2.2 src/sys/net80211/ieee80211_output.c:1.63.2.3
--- src/sys/net80211/ieee80211_output.c:1.63.2.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_output.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_output.c,v 1.63.2.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_output.c,v 1.63.2.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -644,9 +644,15 @@ ieee80211_validate_frame(struct mbuf *m,
  * connect bpf write calls to the 802.11 layer for injecting
  * raw 802.11 frames.
  */
+#if __FreeBSD__
 int
 ieee80211_output(struct ifnet *ifp, struct mbuf *m,
 	const struct sockaddr *dst, struct route *ro)
+#elif __NetBSD__
+int
+ieee80211_output(struct ifnet *ifp, struct mbuf *m,
+	const struct sockaddr *dst, const struct rtentry *ro)
+#endif
 {
 #define senderr(e) do { error = (e); goto bad;} while (0)
 	const struct ieee80211_bpf_params *params = NULL;

Index: src/sys/net80211/ieee80211_proto.c
diff -u src/sys/net80211/ieee80211_proto.c:1.34.14.2 src/sys/net80211/ieee80211_proto.c:1.34.14.3
--- src/sys/net80211/ieee80211_proto.c:1.34.14.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_proto.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_proto.c,v 1.34.14.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_proto.c,v 1.34.14.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -81,6 +81,10 @@ __FBSDID("$FreeBSD$");
 #define KASSERT(__cond, __complaint) FBSDKASSERT(__cond, __complaint)
 #endif
 
+#if __NetBSD__
+extern const struct ieee80211_authenticator auth_xauth;
+#endif
+
 /* XXX tunables */
 #define	AGGRESSIVE_MODE_SWITCH_HYSTERESIS	3	/* pkts / 100ms */
 #define	HIGH_PRI_SWITCH_THRESH			10	/* pkts / 100ms */
@@ -357,8 +361,11 @@ ieee80211_proto_vattach(struct ieee80211
 	vap->iv_bmiss_max = IEEE80211_BMISS_MAX;
 #if __FreeBSD__
 	callout_init_mtx(&vap->iv_swbmiss, IEEE80211_LOCK_OBJ(ic), 0);
-#endif
 	callout_init(&vap->iv_mgtsend, 1);
+#elif __NetBSD__
+	/* NNN need to do something with iv_swbmiss ... */
+	callout_init(&vap->iv_mgtsend, CALLOUT_MPSAFE);
+#endif
 	TASK_INIT(&vap->iv_nstate_task, 0, ieee80211_newstate_cb, vap);
 	TASK_INIT(&vap->iv_swbmiss_task, 0, beacon_swmiss, vap);
 	TASK_INIT(&vap->iv_wme_task, 0, vap_update_wme, vap);
@@ -450,6 +457,7 @@ ieee80211_proto_vdetach(struct ieee80211
 
 #define	IEEE80211_AUTH_MAX	(IEEE80211_AUTH_WPA+1)
 /* XXX well-known names */
+#if __FreeBSD__
 static const char *auth_modnames[IEEE80211_AUTH_MAX] = {
 	"wlan_internal",	/* IEEE80211_AUTH_NONE */
 	"wlan_internal",	/* IEEE80211_AUTH_OPEN */
@@ -458,6 +466,8 @@ static const char *auth_modnames[IEEE802
 	"wlan_internal",	/* IEEE80211_AUTH_AUTO */
 	"wlan_xauth",		/* IEEE80211_AUTH_WPA */
 };
+#endif
+
 static const struct ieee80211_authenticator *authenticators[IEEE80211_AUTH_MAX];
 
 static const struct ieee80211_authenticator auth_internal = {
@@ -468,15 +478,24 @@ static const struct ieee80211_authentica
 	.ia_node_leave		= NULL,
 };
 
+
 /*
  * Setup internal authenticators once; they are never unregistered.
  */
-static __unused void
+#if __FreeBSD__
+static void
+#elif __NetBSD__
+void
+#endif
 ieee80211_auth_setup(void)
 {
 	ieee80211_authenticator_register(IEEE80211_AUTH_OPEN, &auth_internal);
 	ieee80211_authenticator_register(IEEE80211_AUTH_SHARED, &auth_internal);
 	ieee80211_authenticator_register(IEEE80211_AUTH_AUTO, &auth_internal);
+#if __NetBSD__
+	ieee80211_authenticator_register(IEEE80211_AUTH_8021X, &auth_xauth);
+	ieee80211_authenticator_register(IEEE80211_AUTH_WPA, &auth_xauth);
+#endif
 }
 SYSINIT(wlan_auth, SI_SUB_DRIVERS, SI_ORDER_FIRST, ieee80211_auth_setup, NULL);
 
@@ -485,8 +504,10 @@ ieee80211_authenticator_get(int auth)
 {
 	if (auth >= IEEE80211_AUTH_MAX)
 		return NULL;
+#if __FreeBSD__
 	if (authenticators[auth] == NULL)
 		ieee80211_load_module(auth_modnames[auth]);
+#endif
 	return authenticators[auth];
 }
 
@@ -532,8 +553,10 @@ ieee80211_aclator_unregister(const struc
 const struct ieee80211_aclator *
 ieee80211_aclator_get(const char *name)
 {
+#if __FreeBSD__
 	if (acl == NULL)
 		ieee80211_load_module("wlan_acl");
+#endif
 	return acl != NULL && strcmp(acl->iac_name, name) == 0 ? acl : NULL;
 }
 
@@ -1600,6 +1623,7 @@ ieee80211_start_locked(struct ieee80211v
 /*
  * Start a single vap.
  */
+#if __FreeBSD__
 void
 ieee80211_init(void *arg)
 {
@@ -1612,6 +1636,21 @@ ieee80211_init(void *arg)
 	ieee80211_start_locked(vap);
 	IEEE80211_UNLOCK(vap->iv_ic);
 }
+#elif __NetBSD__
+int
+ieee80211_init(struct ifnet *ifp)
+{
+	struct ieee80211vap *vap = ifp->if_softc;
+
+	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
+	    "%s\n", __func__);
+
+	IEEE80211_LOCK(vap->iv_ic);
+	ieee80211_start_locked(vap);
+	IEEE80211_UNLOCK(vap->iv_ic);
+	return 0;
+}
+#endif
 
 /*
  * Start all runnable vap's on a device.

Index: src/sys/net80211/ieee80211_proto.h
diff -u src/sys/net80211/ieee80211_proto.h:1.23.16.3 src/sys/net80211/ieee80211_proto.h:1.23.16.4
--- src/sys/net80211/ieee80211_proto.h:1.23.16.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_proto.h	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_proto.h,v 1.23.16.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_proto.h,v 1.23.16.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -70,6 +70,10 @@ ieee80211_ctl_subtype_name(uint8_t subty
 		   IEEE80211_FC0_SUBTYPE_SHIFT];
 }
 
+#if __NetBSD__
+void	ieee80211_auth_setup(void);
+#endif
+
 const char *ieee80211_reason_to_string(uint16_t);
 
 void	ieee80211_proto_attach(struct ieee80211com *);
@@ -96,8 +100,13 @@ int	ieee80211_mgmt_output(struct ieee802
 		struct ieee80211_bpf_params *);
 int	ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *,
 		const struct ieee80211_bpf_params *);
+#if __FreeBSD__
 int	ieee80211_output(struct ifnet *, struct mbuf *,
                const struct sockaddr *, struct route *ro);
+#elif __NetBSD__
+int	ieee80211_output(struct ifnet *, struct mbuf *,
+               const struct sockaddr *, const struct rtentry *ro);
+#endif
 int	ieee80211_vap_pkt_send_dest(struct ieee80211vap *, struct mbuf *,
 		struct ieee80211_node *);
 int	ieee80211_raw_output(struct ieee80211vap *, struct ieee80211_node *,
@@ -334,7 +343,11 @@ ieee80211_gettid(const struct ieee80211_
 
 void	ieee80211_waitfor_parent(struct ieee80211com *);
 void	ieee80211_start_locked(struct ieee80211vap *);
+#if __FreeBSD__
 void	ieee80211_init(void *);
+#elif __NetBSD__
+int	ieee80211_init(struct ifnet *);
+#endif
 void	ieee80211_start_all(struct ieee80211com *);
 void	ieee80211_stop_locked(struct ieee80211vap *);
 void	ieee80211_stop(struct ieee80211vap *);

Index: src/sys/net80211/ieee80211_ratectl.h
diff -u src/sys/net80211/ieee80211_ratectl.h:1.1.2.3 src/sys/net80211/ieee80211_ratectl.h:1.1.2.4
--- src/sys/net80211/ieee80211_ratectl.h:1.1.2.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_ratectl.h	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ratectl.h,v 1.1.2.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_ratectl.h,v 1.1.2.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -117,6 +117,9 @@ ieee80211_ratectl_node_init(struct ieee8
 {
 	const struct ieee80211vap *vap = ni->ni_vap;
 
+	printf ("ratectl_node_init, vap->iv_rate is 0x%lx\n",
+		(unsigned long)vap->iv_rate);
+
 	vap->iv_rate->ir_node_init(ni);
 }
 

Index: src/sys/net80211/ieee80211_rssadapt.c
diff -u src/sys/net80211/ieee80211_rssadapt.c:1.21.16.2 src/sys/net80211/ieee80211_rssadapt.c:1.21.16.3
--- src/sys/net80211/ieee80211_rssadapt.c:1.21.16.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_rssadapt.c	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_rssadapt.c,v 1.21.16.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_rssadapt.c,v 1.21.16.3 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
@@ -113,7 +113,11 @@ static void	rssadapt_sysctlattach(struct
 /* number of references from net80211 layer */
 static	int nrefs = 0;
 
-static const struct ieee80211_ratectl rssadapt __unused = {
+#if __FreeBSD__
+static const struct ieee80211_ratectl rssadapt = {
+#elif __NetBSD__
+const struct ieee80211_ratectl ratectl_rssadapt = {
+#endif
 	.ir_name	= "rssadapt",
 	.ir_attach	= NULL,
 	.ir_detach	= NULL,
@@ -126,8 +130,10 @@ static const struct ieee80211_ratectl rs
 	.ir_tx_update	= NULL,
 	.ir_setinterval	= rssadapt_setinterval,
 };
+#if __FreeBSD__
 IEEE80211_RATECTL_MODULE(rssadapt, 1);
 IEEE80211_RATECTL_ALG(rssadapt, IEEE80211_RATECTL_RSSADAPT, rssadapt);
+#endif
 
 static void
 rssadapt_setinterval(const struct ieee80211vap *vap, int msecs)

Index: src/sys/net80211/ieee80211_var.h
diff -u src/sys/net80211/ieee80211_var.h:1.33.2.3 src/sys/net80211/ieee80211_var.h:1.33.2.4
--- src/sys/net80211/ieee80211_var.h:1.33.2.3	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_var.h	Mon Jul 16 20:11:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_var.h,v 1.33.2.3 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_var.h,v 1.33.2.4 2018/07/16 20:11:11 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -560,9 +560,14 @@ struct ieee80211vap {
 	int			(*iv_newstate)(struct ieee80211vap *,
 				    enum ieee80211_state, int);
 	/* 802.3 output method for raw frame xmit */
+#if __FreeBSD__
 	int			(*iv_output)(struct ifnet *, struct mbuf *,
 				    const struct sockaddr *, struct route *);
-
+#elif __NetBSD__
+	int			(*iv_output)(struct ifnet *, struct mbuf *,
+				    const struct sockaddr *,
+				    const struct rtentry *);
+#endif
 	int			(*iv_wme_update)(struct ieee80211vap *,
 				    const struct wmeParams *wme_params);
 	struct task		iv_wme_task;	/* deferred VAP WME update */

Index: src/sys/net80211/ieee80211_xauth.c
diff -u src/sys/net80211/ieee80211_xauth.c:1.5.158.2 src/sys/net80211/ieee80211_xauth.c:1.5.158.3
--- src/sys/net80211/ieee80211_xauth.c:1.5.158.2	Thu Jul 12 16:35:34 2018
+++ src/sys/net80211/ieee80211_xauth.c	Mon Jul 16 20:11:12 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_xauth.c,v 1.5.158.2 2018/07/12 16:35:34 phil Exp $ */
+/*	$NetBSD: ieee80211_xauth.c,v 1.5.158.3 2018/07/16 20:11:12 phil Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -72,7 +72,11 @@ static	int nrefs __unused = 0;
  * One module handles everything for now.  May want
  * to split things up for embedded applications.
  */
-static const struct ieee80211_authenticator xauth __unused = {
+#if __FreeBSD__
+static const struct ieee80211_authenticator xauth = {
+#elif __NetBSD__
+const struct ieee80211_authenticator auth_xauth = {
+#endif
 	.ia_name	= "external",
 	.ia_attach	= NULL,
 	.ia_detach	= NULL,
@@ -80,6 +84,8 @@ static const struct ieee80211_authentica
 	.ia_node_leave	= NULL,
 };
 
+#if __FreeBSD__
 IEEE80211_AUTH_MODULE(xauth, 1);
 IEEE80211_AUTH_ALG(x8021x, IEEE80211_AUTH_8021X, xauth);
 IEEE80211_AUTH_ALG(wpa, IEEE80211_AUTH_WPA, xauth);
+#endif

Reply via email to