aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-09-08 10:40:36 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-11 15:53:35 -0400
commit37ffc8da803a1151e887f2a80f08f0c49d1dc1d5 (patch)
tree9d7a5e76210cfbf33b9187287cbc0b2f7ee80cb4
parent5fd12d4da198647e834f93f163e20bfcdd33bad8 (diff)
mac80211: move IE parsing to util file
Since IE parsing is required for the mlme and mesh code, it's not a static function anyway, and it's much better to have it in util rather than the overly large mlme.c Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/mlme.c145
-rw-r--r--net/mac80211/util.c144
2 files changed, 144 insertions, 145 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2341e5b3c248..b03f1f3ef2ed 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -91,151 +91,6 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata,
91static void sta_rx_agg_session_timer_expired(unsigned long data); 91static void sta_rx_agg_session_timer_expired(unsigned long data);
92 92
93 93
94void ieee802_11_parse_elems(u8 *start, size_t len,
95 struct ieee802_11_elems *elems)
96{
97 size_t left = len;
98 u8 *pos = start;
99
100 memset(elems, 0, sizeof(*elems));
101 elems->ie_start = start;
102 elems->total_len = len;
103
104 while (left >= 2) {
105 u8 id, elen;
106
107 id = *pos++;
108 elen = *pos++;
109 left -= 2;
110
111 if (elen > left)
112 return;
113
114 switch (id) {
115 case WLAN_EID_SSID:
116 elems->ssid = pos;
117 elems->ssid_len = elen;
118 break;
119 case WLAN_EID_SUPP_RATES:
120 elems->supp_rates = pos;
121 elems->supp_rates_len = elen;
122 break;
123 case WLAN_EID_FH_PARAMS:
124 elems->fh_params = pos;
125 elems->fh_params_len = elen;
126 break;
127 case WLAN_EID_DS_PARAMS:
128 elems->ds_params = pos;
129 elems->ds_params_len = elen;
130 break;
131 case WLAN_EID_CF_PARAMS:
132 elems->cf_params = pos;
133 elems->cf_params_len = elen;
134 break;
135 case WLAN_EID_TIM:
136 elems->tim = pos;
137 elems->tim_len = elen;
138 break;
139 case WLAN_EID_IBSS_PARAMS:
140 elems->ibss_params = pos;
141 elems->ibss_params_len = elen;
142 break;
143 case WLAN_EID_CHALLENGE:
144 elems->challenge = pos;
145 elems->challenge_len = elen;
146 break;
147 case WLAN_EID_WPA:
148 if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 &&
149 pos[2] == 0xf2) {
150 /* Microsoft OUI (00:50:F2) */
151 if (pos[3] == 1) {
152 /* OUI Type 1 - WPA IE */
153 elems->wpa = pos;
154 elems->wpa_len = elen;
155 } else if (elen >= 5 && pos[3] == 2) {
156 if (pos[4] == 0) {
157 elems->wmm_info = pos;
158 elems->wmm_info_len = elen;
159 } else if (pos[4] == 1) {
160 elems->wmm_param = pos;
161 elems->wmm_param_len = elen;
162 }
163 }
164 }
165 break;
166 case WLAN_EID_RSN:
167 elems->rsn = pos;
168 elems->rsn_len = elen;
169 break;
170 case WLAN_EID_ERP_INFO:
171 elems->erp_info = pos;
172 elems->erp_info_len = elen;
173 break;
174 case WLAN_EID_EXT_SUPP_RATES:
175 elems->ext_supp_rates = pos;
176 elems->ext_supp_rates_len = elen;
177 break;
178 case WLAN_EID_HT_CAPABILITY:
179 elems->ht_cap_elem = pos;
180 elems->ht_cap_elem_len = elen;
181 break;
182 case WLAN_EID_HT_EXTRA_INFO:
183 elems->ht_info_elem = pos;
184 elems->ht_info_elem_len = elen;
185 break;
186 case WLAN_EID_MESH_ID:
187 elems->mesh_id = pos;
188 elems->mesh_id_len = elen;
189 break;
190 case WLAN_EID_MESH_CONFIG:
191 elems->mesh_config = pos;
192 elems->mesh_config_len = elen;
193 break;
194 case WLAN_EID_PEER_LINK:
195 elems->peer_link = pos;
196 elems->peer_link_len = elen;
197 break;
198 case WLAN_EID_PREQ:
199 elems->preq = pos;
200 elems->preq_len = elen;
201 break;
202 case WLAN_EID_PREP:
203 elems->prep = pos;
204 elems->prep_len = elen;
205 break;
206 case WLAN_EID_PERR:
207 elems->perr = pos;
208 elems->perr_len = elen;
209 break;
210 case WLAN_EID_CHANNEL_SWITCH:
211 elems->ch_switch_elem = pos;
212 elems->ch_switch_elem_len = elen;
213 break;
214 case WLAN_EID_QUIET:
215 if (!elems->quiet_elem) {
216 elems->quiet_elem = pos;
217 elems->quiet_elem_len = elen;
218 }
219 elems->num_of_quiet_elem++;
220 break;
221 case WLAN_EID_COUNTRY:
222 elems->country_elem = pos;
223 elems->country_elem_len = elen;
224 break;
225 case WLAN_EID_PWR_CONSTRAINT:
226 elems->pwr_constr_elem = pos;
227 elems->pwr_constr_elem_len = elen;
228 break;
229 default:
230 break;
231 }
232
233 left -= elen;
234 pos += elen;
235 }
236}
237
238
239static u8 * ieee80211_bss_get_ie(struct ieee80211_sta_bss *bss, u8 ie) 94static u8 * ieee80211_bss_get_ie(struct ieee80211_sta_bss *bss, u8 ie)
240{ 95{
241 u8 *end, *pos; 96 u8 *end, *pos;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index f40c060341ae..e19c74cada39 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -428,3 +428,147 @@ void ieee80211_iterate_active_interfaces_atomic(
428 rcu_read_unlock(); 428 rcu_read_unlock();
429} 429}
430EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic); 430EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic);
431
432void ieee802_11_parse_elems(u8 *start, size_t len,
433 struct ieee802_11_elems *elems)
434{
435 size_t left = len;
436 u8 *pos = start;
437
438 memset(elems, 0, sizeof(*elems));
439 elems->ie_start = start;
440 elems->total_len = len;
441
442 while (left >= 2) {
443 u8 id, elen;
444
445 id = *pos++;
446 elen = *pos++;
447 left -= 2;
448
449 if (elen > left)
450 return;
451
452 switch (id) {
453 case WLAN_EID_SSID:
454 elems->ssid = pos;
455 elems->ssid_len = elen;
456 break;
457 case WLAN_EID_SUPP_RATES:
458 elems->supp_rates = pos;
459 elems->supp_rates_len = elen;
460 break;
461 case WLAN_EID_FH_PARAMS:
462 elems->fh_params = pos;
463 elems->fh_params_len = elen;
464 break;
465 case WLAN_EID_DS_PARAMS:
466 elems->ds_params = pos;
467 elems->ds_params_len = elen;
468 break;
469 case WLAN_EID_CF_PARAMS:
470 elems->cf_params = pos;
471 elems->cf_params_len = elen;
472 break;
473 case WLAN_EID_TIM:
474 elems->tim = pos;
475 elems->tim_len = elen;
476 break;
477 case WLAN_EID_IBSS_PARAMS:
478 elems->ibss_params = pos;
479 elems->ibss_params_len = elen;
480 break;
481 case WLAN_EID_CHALLENGE:
482 elems->challenge = pos;
483 elems->challenge_len = elen;
484 break;
485 case WLAN_EID_WPA:
486 if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 &&
487 pos[2] == 0xf2) {
488 /* Microsoft OUI (00:50:F2) */
489 if (pos[3] == 1) {
490 /* OUI Type 1 - WPA IE */
491 elems->wpa = pos;
492 elems->wpa_len = elen;
493 } else if (elen >= 5 && pos[3] == 2) {
494 if (pos[4] == 0) {
495 elems->wmm_info = pos;
496 elems->wmm_info_len = elen;
497 } else if (pos[4] == 1) {
498 elems->wmm_param = pos;
499 elems->wmm_param_len = elen;
500 }
501 }
502 }
503 break;
504 case WLAN_EID_RSN:
505 elems->rsn = pos;
506 elems->rsn_len = elen;
507 break;
508 case WLAN_EID_ERP_INFO:
509 elems->erp_info = pos;
510 elems->erp_info_len = elen;
511 break;
512 case WLAN_EID_EXT_SUPP_RATES:
513 elems->ext_supp_rates = pos;
514 elems->ext_supp_rates_len = elen;
515 break;
516 case WLAN_EID_HT_CAPABILITY:
517 elems->ht_cap_elem = pos;
518 elems->ht_cap_elem_len = elen;
519 break;
520 case WLAN_EID_HT_EXTRA_INFO:
521 elems->ht_info_elem = pos;
522 elems->ht_info_elem_len = elen;
523 break;
524 case WLAN_EID_MESH_ID:
525 elems->mesh_id = pos;
526 elems->mesh_id_len = elen;
527 break;
528 case WLAN_EID_MESH_CONFIG:
529 elems->mesh_config = pos;
530 elems->mesh_config_len = elen;
531 break;
532 case WLAN_EID_PEER_LINK:
533 elems->peer_link = pos;
534 elems->peer_link_len = elen;
535 break;
536 case WLAN_EID_PREQ:
537 elems->preq = pos;
538 elems->preq_len = elen;
539 break;
540 case WLAN_EID_PREP:
541 elems->prep = pos;
542 elems->prep_len = elen;
543 break;
544 case WLAN_EID_PERR:
545 elems->perr = pos;
546 elems->perr_len = elen;
547 break;
548 case WLAN_EID_CHANNEL_SWITCH:
549 elems->ch_switch_elem = pos;
550 elems->ch_switch_elem_len = elen;
551 break;
552 case WLAN_EID_QUIET:
553 if (!elems->quiet_elem) {
554 elems->quiet_elem = pos;
555 elems->quiet_elem_len = elen;
556 }
557 elems->num_of_quiet_elem++;
558 break;
559 case WLAN_EID_COUNTRY:
560 elems->country_elem = pos;
561 elems->country_elem_len = elen;
562 break;
563 case WLAN_EID_PWR_CONSTRAINT:
564 elems->pwr_constr_elem = pos;
565 elems->pwr_constr_elem_len = elen;
566 break;
567 default:
568 break;
569 }
570
571 left -= elen;
572 pos += elen;
573 }
574}