* [PATCH 1/2] mac80211: 11h Infrastructure - Parsing @ 2008-06-15 15:23 Tomas Winkler 2008-06-15 15:23 ` [PATCH 2/2] mac80211: 11h - Handling measurement request Tomas Winkler 0 siblings, 1 reply; 5+ messages in thread From: Tomas Winkler @ 2008-06-15 15:23 UTC (permalink / raw) To: linville, johannes, yi.zhu; +Cc: linux-wireless, Assaf Krauss From: Assaf Krauss <assaf.krauss@intel.com> This patch introduces parsing of 11h and 11d related elements from incoming management frames. Signed-off-by: Assaf Krauss <assaf.krauss@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> --- include/linux/ieee80211.h | 54 +++++++++++++++++++++++++++++++++++++++++-- net/mac80211/ieee80211_i.h | 9 +++++++ net/mac80211/mlme.c | 19 +++++++++++++++ 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 2998e3b..8546f09 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -469,6 +469,40 @@ struct ieee80211s_hdr { u8 eaddr3[6]; } __attribute__ ((packed)); +/** + * struct ieee80211_quiet_ie + * + * This structure refers to "Quiet information element" + */ +struct ieee80211_quiet_ie { + u8 count; + u8 period; + __le16 duration; + __le16 offset; +} __attribute__ ((packed)); + +/** + * struct ieee80211_msrment_ie + * + * This structure refers to "Measurement Request/Report information element" + */ +struct ieee80211_msrment_ie { + u8 token; + u8 mode; + u8 type; + u8 request[0]; +} __attribute__ ((packed)); + +/** + * struct ieee80211_channel_sw_ie + * + * This structure refers to "Channel Switch Announcement information element" + */ +struct ieee80211_channel_sw_ie { + u8 mode; + u8 new_ch_num; + u8 count; +} __attribute__ ((packed)); struct ieee80211_mgmt { __le16 frame_control; @@ -544,13 +578,18 @@ struct ieee80211_mgmt { u8 action_code; u8 element_id; u8 length; - u8 switch_mode; - u8 new_chan; - u8 switch_count; + struct ieee80211_channel_sw_ie sw_elem; } __attribute__((packed)) chan_switch; struct{ u8 action_code; u8 dialog_token; + u8 element_id; + u8 length; + struct ieee80211_msrment_ie msr_elem; + } __attribute__((packed)) measurement; + struct{ + u8 action_code; + u8 dialog_token; __le16 capab; __le16 timeout; __le16 start_seq_num; @@ -875,6 +914,15 @@ enum ieee80211_category { WLAN_CATEGORY_WMM = 17, }; +/* SPECTRUM_MGMT action code */ +enum ieee80211_spectrum_mgmt_actioncode { + WLAN_ACTION_SPCT_MSR_REQ = 0, + WLAN_ACTION_SPCT_MSR_RPRT = 1, + WLAN_ACTION_SPCT_TPC_REQ = 2, + WLAN_ACTION_SPCT_TPC_RPRT = 3, + WLAN_ACTION_SPCT_CHL_SWITCH = 4, +}; + /* BACK action code */ enum ieee80211_back_actioncode { WLAN_ACTION_ADDBA_REQ = 0, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4160982..defcc4d 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -790,6 +790,10 @@ struct ieee802_11_elems { u8 *preq; u8 *prep; u8 *perr; + u8 *ch_switch_elem; + u8 *country_elem; + u8 *pwr_constr_elem; + u8 *quiet_elem; /* first quite element */ /* length of them, respectively */ u8 ssid_len; @@ -814,6 +818,11 @@ struct ieee802_11_elems { u8 preq_len; u8 prep_len; u8 perr_len; + u8 ch_switch_elem_len; + u8 country_elem_len; + u8 pwr_constr_elem_len; + u8 quiet_elem_len; + u8 num_of_quiet_elem; /* can be more the one */ }; static inline struct ieee80211_local *hw_to_local( diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 55659a7..866eaa0 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -204,6 +204,25 @@ void ieee802_11_parse_elems(u8 *start, size_t len, elems->perr = pos; elems->perr_len = elen; break; + case WLAN_EID_CHANNEL_SWITCH: + elems->ch_switch_elem = pos; + elems->ch_switch_elem_len = elen; + break; + case WLAN_EID_QUIET: + if (!elems->quiet_elem) { + elems->quiet_elem = pos; + elems->quiet_elem_len = elen; + } + elems->num_of_quiet_elem++; + break; + case WLAN_EID_COUNTRY: + elems->country_elem = pos; + elems->country_elem_len = elen; + break; + case WLAN_EID_PWR_CONSTRAINT: + elems->pwr_constr_elem = pos; + elems->pwr_constr_elem_len = elen; + break; default: break; } -- 1.5.4.1 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] mac80211: 11h - Handling measurement request 2008-06-15 15:23 [PATCH 1/2] mac80211: 11h Infrastructure - Parsing Tomas Winkler @ 2008-06-15 15:23 ` Tomas Winkler 2008-06-16 8:41 ` Johannes Berg 0 siblings, 1 reply; 5+ messages in thread From: Tomas Winkler @ 2008-06-15 15:23 UTC (permalink / raw) To: linville, johannes, yi.zhu; +Cc: linux-wireless, Assaf Krauss From: Assaf Krauss <assaf.krauss@intel.com> This patch handles the 11h measurement request information element. This is minimal requested implementation - refuse measurement. Signed-off-by: Assaf Krauss <assaf.krauss@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> --- net/mac80211/mlme.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.h | 3 ++ 2 files changed, 78 insertions(+), 0 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 866eaa0..86ea68b 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1720,6 +1720,68 @@ void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr) } } +static void ieee80211_send_measurement_req(struct net_device *dev, + struct ieee80211_msrment_ie *request_ie, + const u8 *da, const u8 *bssid, + u8 dialog_token) +{ + struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); + struct sk_buff *skb; + struct ieee80211_mgmt *msr_report; + + skb = dev_alloc_skb(sizeof(*msr_report) + local->hw.extra_tx_headroom + + sizeof(struct ieee80211_msrment_ie)); + + if (!skb) { + printk(KERN_ERR "%s: failed to allocate buffer for " + "measurement report frame\n", dev->name); + return; + } + + skb_reserve(skb, local->hw.extra_tx_headroom); + msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24); + memset(msr_report, 0, 24); + memcpy(msr_report->da, da, ETH_ALEN); + memcpy(msr_report->sa, dev->dev_addr, ETH_ALEN); + memcpy(msr_report->bssid, bssid, ETH_ALEN); + msr_report->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, + IEEE80211_STYPE_ACTION); + + skb_put(skb, 1 + sizeof(msr_report->u.action.u.measurement)); + msr_report->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT; + msr_report->u.action.u.measurement.action_code = + WLAN_ACTION_SPCT_MSR_RPRT; + msr_report->u.action.u.measurement.dialog_token = dialog_token; + + msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT; + msr_report->u.action.u.measurement.length = + sizeof(struct ieee80211_msrment_ie); + + memset(&msr_report->u.action.u.measurement.msr_elem, 0, + sizeof(struct ieee80211_msrment_ie)); + msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; + msr_report->u.action.u.measurement.msr_elem.mode |= MSR_REPORT_REFUSED; + msr_report->u.action.u.measurement.msr_elem.type = request_ie->type; + + ieee80211_sta_tx(dev, skb, 0); +} + +static void ieee80211_sta_process_measurement_req(struct net_device *dev, + struct ieee80211_mgmt *mgmt, + size_t len) +{ + /* + * Ignoring measurement request is spec violation. + * A measurement needs to be refused or preformed. + * For now just refuse + */ + ieee80211_send_measurement_req(dev, + &mgmt->u.action.u.measurement.msr_elem, + mgmt->sa, mgmt->bssid, + mgmt->u.action.u.measurement.dialog_token); +} + + static void ieee80211_rx_mgmt_auth(struct net_device *dev, struct ieee80211_if_sta *ifsta, struct ieee80211_mgmt *mgmt, @@ -3044,11 +3106,24 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, struct ieee80211_rx_status *rx_status) { struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); if (len < IEEE80211_MIN_ACTION_SIZE) return; switch (mgmt->u.action.category) { + case WLAN_CATEGORY_SPECTRUM_MGMT: + if (local->hw.conf.channel->band != IEEE80211_BAND_5GHZ) + break; + switch (mgmt->u.action.u.chan_switch.action_code) { + case WLAN_ACTION_SPCT_MSR_REQ: + if (len < (IEEE80211_MIN_ACTION_SIZE + + sizeof(mgmt->u.action.u.measurement))) + break; + ieee80211_sta_process_measurement_req(dev, mgmt, len); + break; + } + break; case WLAN_CATEGORY_BACK: switch (mgmt->u.action.u.addba_req.action_code) { case WLAN_ACTION_ADDBA_REQ: diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 95753f8..e38e464 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -65,6 +65,9 @@ enum ieee80211_sta_info_flags { HT_ADDBA_RECEIVED_MSK) #define HT_AGG_STATE_DEBUGFS_CTL BIT(7) +/* measurement report mode field - refuse to generate a report */ +#define MSR_REPORT_REFUSED BIT(2) + /** * struct tid_ampdu_tx - TID aggregation information (Tx). * -- 1.5.4.1 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mac80211: 11h - Handling measurement request 2008-06-15 15:23 ` [PATCH 2/2] mac80211: 11h - Handling measurement request Tomas Winkler @ 2008-06-16 8:41 ` Johannes Berg 2008-06-16 9:08 ` Tomas Winkler 0 siblings, 1 reply; 5+ messages in thread From: Johannes Berg @ 2008-06-16 8:41 UTC (permalink / raw) To: Tomas Winkler; +Cc: linville, yi.zhu, linux-wireless, Assaf Krauss [-- Attachment #1: Type: text/plain, Size: 1110 bytes --] > This patch handles the 11h measurement request information element. > This is minimal requested implementation - refuse measurement. I haven't really read 11h or the -2007 wrt. the added material, but this seems a bit odd to me: > +static void ieee80211_send_measurement_req(struct net_device *dev, > + struct ieee80211_msrment_ie *request_ie, > + const u8 *da, const u8 *bssid, > + u8 dialog_token) > + msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT; It's sending a report after all, not a request. Maybe it should just be named "send_measurement_action"? > + msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; > + msr_report->u.action.u.measurement.msr_elem.mode |= MSR_REPORT_REFUSED; Also, it seems to me that should be part of the arguments or you won't be able to use this function for anything else but sending a 'refused' report? > +/* measurement report mode field - refuse to generate a report */ > +#define MSR_REPORT_REFUSED BIT(2) That seems completely misplaced in sta_info.h to me? johannes [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mac80211: 11h - Handling measurement request 2008-06-16 8:41 ` Johannes Berg @ 2008-06-16 9:08 ` Tomas Winkler 2008-06-16 9:11 ` Johannes Berg 0 siblings, 1 reply; 5+ messages in thread From: Tomas Winkler @ 2008-06-16 9:08 UTC (permalink / raw) To: Johannes Berg; +Cc: linville, yi.zhu, linux-wireless, Assaf Krauss On Mon, Jun 16, 2008 at 11:41 AM, Johannes Berg <johannes@sipsolutions.net> wrote: > >> This patch handles the 11h measurement request information element. >> This is minimal requested implementation - refuse measurement. > > I haven't really read 11h or the -2007 wrt. the added material, but this > seems a bit odd to me: > >> +static void ieee80211_send_measurement_req(struct net_device *dev, >> + struct ieee80211_msrment_ie *request_ie, >> + const u8 *da, const u8 *bssid, >> + u8 dialog_token) > >> + msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT; > > It's sending a report after all, not a request. Maybe it should just be > named "send_measurement_action"? Will do. > >> + msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; >> + msr_report->u.action.u.measurement.msr_elem.mode |= MSR_REPORT_REFUSED; > > Also, it seems to me that should be part of the arguments or you won't > be able to use this function for anything else but sending a 'refused' > report? Don't mind to put it into arguments, just the argument list have to be alter anyway if real measurement is performed and results need to be sent out. Currently no plans to implement more then necessary minimum to comply with the spec. > >> +/* measurement report mode field - refuse to generate a report */ >> +#define MSR_REPORT_REFUSED BIT(2) > > That seems completely misplaced in sta_info.h to me? Yep will move it to include/linux/ieee80211.h ? Thanks Tomas ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mac80211: 11h - Handling measurement request 2008-06-16 9:08 ` Tomas Winkler @ 2008-06-16 9:11 ` Johannes Berg 0 siblings, 0 replies; 5+ messages in thread From: Johannes Berg @ 2008-06-16 9:11 UTC (permalink / raw) To: Tomas Winkler; +Cc: linville, yi.zhu, linux-wireless, Assaf Krauss [-- Attachment #1: Type: text/plain, Size: 1095 bytes --] > >> + msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; > >> + msr_report->u.action.u.measurement.msr_elem.mode |= MSR_REPORT_REFUSED; > > > > Also, it seems to me that should be part of the arguments or you won't > > be able to use this function for anything else but sending a 'refused' > > report? > > Don't mind to put it into arguments, just the argument list have to be alter > anyway if real measurement is performed and results need to be sent out. Yeah, true. Or you can just call the function _refuse_measurement_request() instead. > >> +/* measurement report mode field - refuse to generate a report */ > >> +#define MSR_REPORT_REFUSED BIT(2) > > > > That seems completely misplaced in sta_info.h to me? > > Yep will move it to > include/linux/ieee80211.h ? Sounds appropriate, though it should probably be renamed then to have a proper IEEE80211 prefix. Are there other items in that field you might want to collect into an enum? Doesn't matter much to me though, one can always look it up in the spec. johannes [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-16 9:11 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-06-15 15:23 [PATCH 1/2] mac80211: 11h Infrastructure - Parsing Tomas Winkler 2008-06-15 15:23 ` [PATCH 2/2] mac80211: 11h - Handling measurement request Tomas Winkler 2008-06-16 8:41 ` Johannes Berg 2008-06-16 9:08 ` Tomas Winkler 2008-06-16 9:11 ` Johannes Berg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox