#include <sys/sysctl.h>
#include <sys/taskqueue.h>
+#define IF_LOCK(_lock) /* */
+#define IF_UNLOCK(_lock) /* */
+
/*
* Common state locking definitions.
*/
#define IFNET_IS_UP_RUNNING(_ifp) \
(((_ifp)->if_flags & IFF_UP) && \
- ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
+ ((_ifp)->if_flags & IFF_RUNNING))
#define msecs_to_ticks(ms) (((ms)*hz)/1000)
#define ticks_to_msecs(t) (1000*(t) / hz)
* Store the sequence number.
*/
#define M_SEQNO_SET(m, seqno) \
- ((m)->m_pkthdr.tso_segsz = (seqno))
-#define M_SEQNO_GET(m) ((m)->m_pkthdr.tso_segsz)
+ ((m)->m_pkthdr.wlan_seqno = (seqno))
+#define M_SEQNO_GET(m) ((m)->m_pkthdr.wlan_seqno)
#define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */
int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
int ieee80211_output(struct ifnet *, struct mbuf *,
- struct sockaddr *, struct route *ro);
+ struct sockaddr *, struct rtentry *rt);
void ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int,
const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
const uint8_t [IEEE80211_ADDR_LEN]);
enum ieee80211_state, int);
/* 802.3 output method for raw frame xmit */
int (*iv_output)(struct ifnet *, struct mbuf *,
- struct sockaddr *, struct route *);
+ struct sockaddr *, struct rtentry *);
uint64_t iv_spare[8];
};
MALLOC_DECLARE(M_80211_VAP);
struct ieee80211com *ieee80211_find_vap(const uint8_t mac[IEEE80211_ADDR_LEN]);
int ieee80211_media_change(struct ifnet *);
void ieee80211_media_status(struct ifnet *, struct ifmediareq *);
-int ieee80211_ioctl(struct ifnet *, u_long, caddr_t);
+int ieee80211_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
int ieee80211_rate2media(struct ieee80211com *, int,
enum ieee80211_phymode);
int ieee80211_media2rate(int);
SRCS += ieee80211_scan.c ieee80211_scan_sta.c ieee80211_sta.c
SRCS += ieee80211_superg.c ieee80211_tdma.c ieee80211_wds.c
SRCS += bus_if.h device_if.h opt_inet.h opt_inet6.h opt_ipx.h opt_wlan.h
-SRCS += opt_tdma.h
+SRCS += opt_tdma.h opt_ddb.h
.if !defined(BUILDING_WITH_KERNEL)
opt_inet.h:
opt_tdma.h:
echo "" > ${.TARGET}
+opt_ddb.h:
+ echo "#define DDB 1" > ${.TARGET}
+
.endif
.include <bsd.kmod.mk>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
+#include <net/ifq_var.h>
#include <net/ethernet.h>
#include <net/route.h>
sdl->sdl_type = IFT_ETHER; /* XXX IFT_IEEE80211? */
sdl->sdl_alen = IEEE80211_ADDR_LEN;
IEEE80211_ADDR_COPY(LLADDR(sdl), macaddr);
- ifa_free(ifa);
+ IFAFREE(ifa);
}
/*
{
struct ifnet *ifp;
+#ifdef __FreeBSD__
ifp = if_alloc(IFT_ETHER);
+#endif
+ ifp = kmalloc(sizeof(struct ifnet), M_TEMP, M_WAITOK|M_ZERO);
if (ifp == NULL) {
if_printf(ic->ic_ifp, "%s: unable to allocate ifnet\n",
__func__);
return ENOMEM;
}
+ ifp->if_type = IFT_ETHER;
if_initname(ifp, name, unit);
ifp->if_softc = vap; /* back pointer */
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
ifp->if_ioctl = ieee80211_ioctl;
ifp->if_init = ieee80211_init;
/* NB: input+output filled in by ether_ifattach */
- IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
- ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
- IFQ_SET_READY(&ifp->if_snd);
+ ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
+ ifq_set_ready(&ifp->if_snd);
vap->iv_ifp = ifp;
vap->iv_ic = ic;
ether_ifattach(ifp, vap->iv_myaddr, NULL);
if (vap->iv_opmode == IEEE80211_M_MONITOR) {
/* NB: disallow transmit */
+#ifdef __FreeBSD__
ifp->if_transmit = null_transmit;
+#endif
ifp->if_output = null_output;
} else {
/* hook output method setup by ether_ifattach */
ieee80211_draintask(ic, &vap->iv_nstate_task);
ieee80211_draintask(ic, &vap->iv_swbmiss_task);
+#ifdef __FreeBSD__
/* XXX band-aid until ifnet handles this for us */
taskqueue_drain(taskqueue_swi, &ifp->if_linktask);
+#endif
IEEE80211_LOCK(ic);
KASSERT(vap->iv_state == IEEE80211_S_INIT , ("vap still running"));
ieee80211_node_vdetach(vap);
ieee80211_sysctl_vdetach(vap);
+#ifdef __FreeBSD__
if_free(ifp);
+#endif
+ kfree(ifp, M_TEMP);
}
/*
ifp->if_flags &= ~flag;
if ((ifp->if_flags ^ oflags) & flag) {
/* XXX should we return 1/0 and let caller do this? */
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (ifp->if_flags & IFF_RUNNING) {
if (flag == IFF_PROMISC)
ieee80211_runtask(ic, &ic->ic_promisc_task);
else if (flag == IFF_ALLMULTI)
#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/route.h>
-#include <net/vnet.h>
#include <netproto/802_11/ieee80211_var.h>
#ifdef IEEE80211_SUPPORT_TDMA
DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps)
{
- VNET_ITERATOR_DECL(vnet_iter);
const struct ifnet *ifp;
int i, showall = 0;
break;
}
- VNET_FOREACH(vnet_iter) {
- TAILQ_FOREACH(ifp, &V_ifnet, if_list)
- if (ifp->if_type == IFT_IEEE80211) {
- const struct ieee80211com *ic = ifp->if_l2com;
-
- if (!showall) {
- const struct ieee80211vap *vap;
- db_printf("%s: com %p vaps:",
- ifp->if_xname, ic);
- TAILQ_FOREACH(vap, &ic->ic_vaps,
- iv_next)
- db_printf(" %s(%p)",
- vap->iv_ifp->if_xname, vap);
- db_printf("\n");
- } else
- _db_show_com(ic, 1, 1, 1);
- }
+ TAILQ_FOREACH(ifp, &ifnet, if_list) {
+ if (ifp->if_type == IFT_IEEE80211) {
+ const struct ieee80211com *ic = ifp->if_l2com;
+
+ if (!showall) {
+ const struct ieee80211vap *vap;
+ db_printf("%s: com %p vaps:",
+ ifp->if_xname, ic);
+ TAILQ_FOREACH(vap, &ic->ic_vaps,
+ iv_next)
+ db_printf(" %s(%p)",
+ vap->iv_ifp->if_xname, vap);
+ db_printf("\n");
+ } else
+ _db_show_com(ic, 1, 1, 1);
+ }
}
}
}
if (ni->ni_vlan != 0) {
/* attach vlan tag */
- m->m_pkthdr.ether_vtag = ni->ni_vlan;
+ m->m_pkthdr.ether_vlantag = ni->ni_vlan;
m->m_flags |= M_VLANTAG;
}
ifp->if_input(ifp, m);
else
ifp = vap->iv_ifp;
IF_ENQUEUE(&ifp->if_snd, m);
- if_start(ifp);
+ ifp->if_start(ifp);
}
static void
ampdu_tx_setup(struct ieee80211_tx_ampdu *tap)
{
- callout_init(&tap->txa_timer, CALLOUT_MPSAFE);
+ callout_init_mp(&tap->txa_timer);
tap->txa_flags |= IEEE80211_AGGR_SETUP;
}
return;
}
hs->hs_maxhops = IEEE80211_HWMP_DEFAULT_MAXHOPS;
- callout_init(&hs->hs_roottimer, CALLOUT_MPSAFE);
+ callout_init_mp(&hs->hs_roottimer);
vap->iv_hwmp = hs;
}
int error, i;
/* NB: parent must be running */
- if ((ic->ic_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ if ((ic->ic_ifp->if_flags & IFF_RUNNING) == 0)
return ENXIO;
if (ireq->i_len != sizeof(sr))
struct ifnet *ifp = vap->iv_ifp;
struct ifmultiaddr *ifma;
- TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
+ LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
(void) if_addmulti(parent, ifma->ifma_addr, NULL);
}
int
-ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *ucred)
{
struct ieee80211vap *vap = ifp->if_softc;
struct ieee80211com *ic = vap->iv_ic;
*/
if (vap->iv_state == IEEE80211_S_INIT)
ieee80211_start_locked(vap);
- } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ } else if (ifp->if_flags & IFF_RUNNING) {
/*
* Stop ourself. If we are the last vap to be
* marked down the parent will also be taken down.
case SIOCSDRVSPEC:
case SIOCGPRIVATE_0: {
struct ifnet *parent = vap->iv_ic->ic_ifp;
- error = parent->if_ioctl(parent, cmd, data);
+ error = parent->if_ioctl(parent, cmd, data, ucred);
break;
}
default:
ms->ms_ttl = IEEE80211_MESH_DEFAULT_TTL;
TAILQ_INIT(&ms->ms_routes);
lockinit(&ms->ms_rt_lock, "MBSS", 0, 0);
- callout_init(&ms->ms_cleantimer, CALLOUT_MPSAFE);
+ callout_init_mp(&ms->ms_cleantimer);
mesh_select_proto_metric(vap, "AIRTIME");
KASSERT(ms->ms_pmetric, ("ms_pmetric == NULL"));
mesh_select_proto_path(vap, "HWMP");
ieee80211_mesh_node_init(struct ieee80211vap *vap, struct ieee80211_node *ni)
{
ni->ni_flags |= IEEE80211_NODE_QOS;
- callout_init(&ni->ni_mltimer, CALLOUT_MPSAFE);
+ callout_init_mp(&ni->ni_mltimer);
}
/*
"802.11 staging q");
ieee80211_node_table_init(ic, &ic->ic_sta, "station",
IEEE80211_INACT_INIT, ic->ic_max_keyix);
- callout_init(&ic->ic_inact, CALLOUT_MPSAFE);
+ callout_init_mp(&ic->ic_inact);
callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz,
ieee80211_node_timeout, ic);
#include <net/if.h>
#include <net/if_llc.h>
#include <net/if_media.h>
+#include <net/ifq_var.h>
#include <netproto/802_11/ieee80211_var.h>
#include <netproto/802_11/ieee80211_regdomain.h>
"%s: ignore queue, in %s state\n",
__func__, ieee80211_state_name[vap->iv_state]);
vap->iv_stats.is_tx_badstate++;
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ ifp->if_flags |= IFF_OACTIVE;
IEEE80211_UNLOCK(ic);
return;
}
IEEE80211_UNLOCK(ic);
}
for (;;) {
- IFQ_DEQUEUE(&ifp->if_snd, m);
+ ifq_dequeue(&ifp->if_snd, m);
if (m == NULL)
break;
/*
*/
int
ieee80211_output(struct ifnet *ifp, struct mbuf *m,
- struct sockaddr *dst, struct route *ro)
+ struct sockaddr *dst, struct rtentry *rt)
{
#define senderr(e) do { error = (e); goto bad;} while (0)
struct ieee80211_node *ni = NULL;
struct ieee80211_frame *wh;
int error;
- if (ifp->if_drv_flags & IFF_DRV_OACTIVE) {
+ if (ifp->if_flags & IFF_OACTIVE) {
/*
* Short-circuit requests if the vap is marked OACTIVE
* as this can happen because a packet came down through
* a raw 802.11 frame.
*/
if (dst->sa_family != AF_IEEE80211)
- return vap->iv_output(ifp, m, dst, ro);
+ return vap->iv_output(ifp, m, dst, rt);
#ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error)
/* NB: do this outside the psq lock */
/* XXX packets might get reordered if parent is OACTIVE */
if (parent != NULL)
- if_start(parent);
+ parent->if_start(parent);
if (ifp != NULL)
- if_start(ifp);
+ ifp->if_start(ifp);
}
/*
vap->iv_rtsthreshold = IEEE80211_RTS_DEFAULT;
vap->iv_fragthreshold = IEEE80211_FRAG_DEFAULT;
vap->iv_bmiss_max = IEEE80211_BMISS_MAX;
- callout_init(&vap->iv_swbmiss, CALLOUT_MPSAFE);
- callout_init(&vap->iv_mgtsend, CALLOUT_MPSAFE);
+ callout_init_mp(&vap->iv_swbmiss);
+ callout_init_mp(&vap->iv_mgtsend);
TASK_INIT(&vap->iv_nstate_task, 0, ieee80211_newstate_cb, vap);
TASK_INIT(&vap->iv_swbmiss_task, 0, beacon_swmiss, vap);
/*
{
struct ifnet *parent = arg;
- parent->if_ioctl(parent, SIOCSIFFLAGS, NULL);
+ parent->if_ioctl(parent, SIOCSIFFLAGS, NULL, curthread->td_ucred);
}
static void
IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
"start running, %d vaps running\n", ic->ic_nrunning);
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+ if ((ifp->if_flags & IFF_RUNNING) == 0) {
/*
* Mark us running. Note that it's ok to do this first;
* if we need to bring the parent device up we defer that
* through ieee80211_start_all at which point we'll come
* back in here and complete the work.
*/
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ ifp->if_flags |= IFF_RUNNING;
/*
* We are not running; if this we are the first vap
* to be brought up auto-up the parent if necessary.
*/
if (ic->ic_nrunning++ == 0 &&
- (parent->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+ (parent->if_flags & IFF_RUNNING) == 0) {
IEEE80211_DPRINTF(vap,
IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
"%s: up parent %s\n", __func__, parent->if_xname);
* If the parent is up and running, then kick the
* 802.11 state machine as appropriate.
*/
- if ((parent->if_drv_flags & IFF_DRV_RUNNING) &&
+ if ((parent->if_flags & IFF_RUNNING) &&
vap->iv_roaming != IEEE80211_ROAMING_MANUAL) {
if (vap->iv_opmode == IEEE80211_M_STA) {
#if 0
"stop running, %d vaps running\n", ic->ic_nrunning);
ieee80211_new_state_locked(vap, IEEE80211_S_INIT, -1);
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING; /* mark us stopped */
+ if (ifp->if_flags & IFF_RUNNING) {
+ ifp->if_flags &= ~IFF_RUNNING; /* mark us stopped */
if (--ic->ic_nrunning == 0 &&
- (parent->if_drv_flags & IFF_DRV_RUNNING)) {
+ (parent->if_flags & IFF_RUNNING)) {
IEEE80211_DPRINTF(vap,
IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
"down parent %s\n", parent->if_xname);
* Note this can also happen as a result of SLEEP->RUN
* (i.e. coming out of power save mode).
*/
- vap->iv_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ vap->iv_ifp->if_flags &= ~IFF_OACTIVE;
if_start(vap->iv_ifp);
/* bring up any vaps waiting on us */
if (th != NULL && ic->ic_rh != NULL) {
/* radiotap DLT for raw 802.11 frames */
- bpfattach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
+ bpfattach_dlt(vap->iv_ifp, DLT_IEEE802_11_RADIO,
sizeof(struct ieee80211_frame) + le16toh(th->it_len),
&vap->iv_rawbpf);
}
vap->iv_opmode == IEEE80211_M_MONITOR &&
(vap->iv_flags_ext & IEEE80211_FEXT_BPF) &&
vap->iv_state != IEEE80211_S_INIT)
- bpf_mtap2(vap->iv_rawbpf, rh, len, m);
+ bpf_ptap(vap->iv_rawbpf, m, rh, len);
}
}
len = le16toh(th->it_len);
if (vap0->iv_flags_ext & IEEE80211_FEXT_BPF)
- bpf_mtap2(vap0->iv_rawbpf, th, len, m);
+ bpf_ptap(vap0->iv_rawbpf, m, th, len);
/*
* Spam monitor mode vaps.
*/
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kernel.h>
-#include <sys/condvar.h>
#include <sys/socket.h>