diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2013-07-25 06:23:26 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2013-07-25 06:23:26 +0000 |
commit | d94b5d358fa86434c05cbac23225e71ae905f014 (patch) | |
tree | c1bfb39e82a64a728cf12d7bf23363e8eb3ef9a0 /sys | |
parent | 9ee05c23e2c5d48beafbce1a2d501f7e3072d79b (diff) | |
download | FreeBSD-src-d94b5d358fa86434c05cbac23225e71ae905f014.zip FreeBSD-src-d94b5d358fa86434c05cbac23225e71ae905f014.tar.gz |
Add ieee80211_add_{qos,wpa,rsn}() functions since they are needed by an
OpenBSD driver that is being ported to FreeBSD.
Reviewed by: adrian
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net80211/ieee80211.h | 1 | ||||
-rw-r--r-- | sys/net80211/ieee80211_output.c | 82 | ||||
-rw-r--r-- | sys/net80211/ieee80211_proto.h | 3 |
3 files changed, 46 insertions, 40 deletions
diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index a3da739..0b1f050 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -711,6 +711,7 @@ enum { IEEE80211_ELEMID_IBSSDFS = 41, IEEE80211_ELEMID_ERP = 42, IEEE80211_ELEMID_HTCAP = 45, + IEEE80211_ELEMID_QOS = 46, IEEE80211_ELEMID_RSN = 48, IEEE80211_ELEMID_XRATES = 50, IEEE80211_ELEMID_HTINFO = 61, diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index defebc9..7e2ac83 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -1883,6 +1883,40 @@ ieee80211_add_countryie(uint8_t *frm, struct ieee80211com *ic) return add_appie(frm, ic->ic_countryie); } +uint8_t * +ieee80211_add_wpa(uint8_t *frm, const struct ieee80211vap *vap) +{ + if (vap->iv_flags & IEEE80211_F_WPA1 && vap->iv_wpa_ie != NULL) + return (add_ie(frm, vap->iv_wpa_ie)); + else { + /* XXX else complain? */ + return (frm); + } +} + +uint8_t * +ieee80211_add_rsn(uint8_t *frm, const struct ieee80211vap *vap) +{ + if (vap->iv_flags & IEEE80211_F_WPA2 && vap->iv_rsn_ie != NULL) + return (add_ie(frm, vap->iv_rsn_ie)); + else { + /* XXX else complain? */ + return (frm); + } +} + +uint8_t * +ieee80211_add_qos(uint8_t *frm, const struct ieee80211_node *ni) +{ + if (ni->ni_flags & IEEE80211_NODE_QOS) { + *frm++ = IEEE80211_ELEMID_QOS; + *frm++ = 1; + *frm++ = 0; + } + + return (frm); +} + /* * Send a probe request frame with the specified ssid * and any optional information element data. @@ -1951,17 +1985,9 @@ ieee80211_send_probereq(struct ieee80211_node *ni, frm = ieee80211_add_ssid(frm, ssid, ssidlen); rs = ieee80211_get_suprates(ic, ic->ic_curchan); frm = ieee80211_add_rates(frm, rs); - if (vap->iv_flags & IEEE80211_F_WPA2) { - if (vap->iv_rsn_ie != NULL) - frm = add_ie(frm, vap->iv_rsn_ie); - /* XXX else complain? */ - } + frm = ieee80211_add_rsn(frm, vap); frm = ieee80211_add_xrates(frm, rs); - if (vap->iv_flags & IEEE80211_F_WPA1) { - if (vap->iv_wpa_ie != NULL) - frm = add_ie(frm, vap->iv_wpa_ie); - /* XXX else complain? */ - } + frm = ieee80211_add_wpa(frm, vap); if (vap->iv_appie_probereq != NULL) frm = add_appie(frm, vap->iv_appie_probereq); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); @@ -2227,11 +2253,7 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) frm = ieee80211_add_ssid(frm, ni->ni_essid, ni->ni_esslen); frm = ieee80211_add_rates(frm, &ni->ni_rates); - if (vap->iv_flags & IEEE80211_F_WPA2) { - if (vap->iv_rsn_ie != NULL) - frm = add_ie(frm, vap->iv_rsn_ie); - /* XXX else complain? */ - } + frm = ieee80211_add_rsn(frm, vap); frm = ieee80211_add_xrates(frm, &ni->ni_rates); if (capinfo & IEEE80211_CAPINFO_SPECTRUM_MGMT) { frm = ieee80211_add_powercapability(frm, @@ -2242,11 +2264,7 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) ni->ni_ies.htcap_ie != NULL && ni->ni_ies.htcap_ie[0] == IEEE80211_ELEMID_HTCAP) frm = ieee80211_add_htcap(frm, ni); - if (vap->iv_flags & IEEE80211_F_WPA1) { - if (vap->iv_wpa_ie != NULL) - frm = add_ie(frm, vap->iv_wpa_ie); - /* XXX else complain */ - } + frm = ieee80211_add_wpa(frm, vap); if ((ic->ic_flags & IEEE80211_F_WME) && ni->ni_ies.wme_ie != NULL) frm = ieee80211_add_wme_info(frm, &ic->ic_wme); @@ -2513,11 +2531,7 @@ ieee80211_alloc_proberesp(struct ieee80211_node *bss, int legacy) if (IEEE80211_IS_CHAN_ANYG(bss->ni_chan)) frm = ieee80211_add_erp(frm, ic); frm = ieee80211_add_xrates(frm, rs); - if (vap->iv_flags & IEEE80211_F_WPA2) { - if (vap->iv_rsn_ie != NULL) - frm = add_ie(frm, vap->iv_rsn_ie); - /* XXX else complain? */ - } + frm = ieee80211_add_rsn(frm, vap); /* * NB: legacy 11b clients do not get certain ie's. * The caller identifies such clients by passing @@ -2529,11 +2543,7 @@ ieee80211_alloc_proberesp(struct ieee80211_node *bss, int legacy) frm = ieee80211_add_htcap(frm, bss); frm = ieee80211_add_htinfo(frm, bss); } - if (vap->iv_flags & IEEE80211_F_WPA1) { - if (vap->iv_wpa_ie != NULL) - frm = add_ie(frm, vap->iv_wpa_ie); - /* XXX else complain? */ - } + frm = ieee80211_add_wpa(frm, vap); if (vap->iv_flags & IEEE80211_F_WME) frm = ieee80211_add_wme_param(frm, &ic->ic_wme); if (IEEE80211_IS_CHAN_HT(bss->ni_chan) && @@ -2831,21 +2841,13 @@ ieee80211_beacon_construct(struct mbuf *m, uint8_t *frm, frm = ieee80211_add_erp(frm, ic); } frm = ieee80211_add_xrates(frm, rs); - if (vap->iv_flags & IEEE80211_F_WPA2) { - if (vap->iv_rsn_ie != NULL) - frm = add_ie(frm, vap->iv_rsn_ie); - /* XXX else complain */ - } + frm = ieee80211_add_rsn(frm, vap); if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) { frm = ieee80211_add_htcap(frm, ni); bo->bo_htinfo = frm; frm = ieee80211_add_htinfo(frm, ni); } - if (vap->iv_flags & IEEE80211_F_WPA1) { - if (vap->iv_wpa_ie != NULL) - frm = add_ie(frm, vap->iv_wpa_ie); - /* XXX else complain */ - } + frm = ieee80211_add_wpa(frm, vap); if (vap->iv_flags & IEEE80211_F_WME) { bo->bo_wme = frm; frm = ieee80211_add_wme_param(frm, &ic->ic_wme); diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h index e4bca5b..6738027 100644 --- a/sys/net80211/ieee80211_proto.h +++ b/sys/net80211/ieee80211_proto.h @@ -136,6 +136,9 @@ struct mbuf *ieee80211_alloc_cts(struct ieee80211com *, uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *); uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *); +uint8_t *ieee80211_add_wpa(uint8_t *, const struct ieee80211vap *); +uint8_t *ieee80211_add_rsn(uint8_t *, const struct ieee80211vap *); +uint8_t *ieee80211_add_qos(uint8_t *, const struct ieee80211_node *); uint16_t ieee80211_getcapinfo(struct ieee80211vap *, struct ieee80211_channel *); |