bss.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /*
  2. * BSS table
  3. * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #include "utils/includes.h"
  15. #include "utils/common.h"
  16. #include "utils/eloop.h"
  17. #include "common/ieee802_11_defs.h"
  18. #include "drivers/driver.h"
  19. #include "wpa_supplicant_i.h"
  20. #include "notify.h"
  21. #include "scan.h"
  22. #include "bss.h"
  23. #ifndef WPA_BSS_MAX_COUNT
  24. #define WPA_BSS_MAX_COUNT 200
  25. #endif /* WPA_BSS_MAX_COUNT */
  26. /**
  27. * WPA_BSS_EXPIRATION_PERIOD - Period of expiration run in seconds
  28. */
  29. #define WPA_BSS_EXPIRATION_PERIOD 10
  30. /**
  31. * WPA_BSS_EXPIRATION_AGE - BSS entry age after which it can be expired
  32. *
  33. * This value control the time in seconds after which a BSS entry gets removed
  34. * if it has not been updated or is not in use.
  35. */
  36. #define WPA_BSS_EXPIRATION_AGE 180
  37. /**
  38. * WPA_BSS_EXPIRATION_SCAN_COUNT - Expire BSS after number of scans
  39. *
  40. * If the BSS entry has not been seen in this many scans, it will be removed.
  41. * Value 1 means that the entry is removed after the first scan without the
  42. * BSSID being seen. Larger values can be used to avoid BSS entries
  43. * disappearing if they are not visible in every scan (e.g., low signal quality
  44. * or interference).
  45. */
  46. #define WPA_BSS_EXPIRATION_SCAN_COUNT 2
  47. #define WPA_BSS_FREQ_CHANGED_FLAG BIT(0)
  48. #define WPA_BSS_SIGNAL_CHANGED_FLAG BIT(1)
  49. #define WPA_BSS_PRIVACY_CHANGED_FLAG BIT(2)
  50. #define WPA_BSS_MODE_CHANGED_FLAG BIT(3)
  51. #define WPA_BSS_WPAIE_CHANGED_FLAG BIT(4)
  52. #define WPA_BSS_RSNIE_CHANGED_FLAG BIT(5)
  53. #define WPA_BSS_WPS_CHANGED_FLAG BIT(6)
  54. #define WPA_BSS_RATES_CHANGED_FLAG BIT(7)
  55. static void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
  56. {
  57. dl_list_del(&bss->list);
  58. dl_list_del(&bss->list_id);
  59. wpa_s->num_bss--;
  60. wpa_printf(MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR " SSID '%s'",
  61. bss->id, MAC2STR(bss->bssid),
  62. wpa_ssid_txt(bss->ssid, bss->ssid_len));
  63. wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id);
  64. os_free(bss);
  65. }
  66. struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
  67. const u8 *ssid, size_t ssid_len)
  68. {
  69. struct wpa_bss *bss;
  70. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  71. if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 &&
  72. bss->ssid_len == ssid_len &&
  73. os_memcmp(bss->ssid, ssid, ssid_len) == 0)
  74. return bss;
  75. }
  76. return NULL;
  77. }
  78. static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
  79. {
  80. os_time_t usec;
  81. dst->flags = src->flags;
  82. os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
  83. dst->freq = src->freq;
  84. dst->beacon_int = src->beacon_int;
  85. dst->caps = src->caps;
  86. dst->qual = src->qual;
  87. dst->noise = src->noise;
  88. dst->level = src->level;
  89. dst->tsf = src->tsf;
  90. os_get_time(&dst->last_update);
  91. dst->last_update.sec -= src->age / 1000;
  92. usec = (src->age % 1000) * 1000;
  93. if (dst->last_update.usec < usec) {
  94. dst->last_update.sec--;
  95. dst->last_update.usec += 1000000;
  96. }
  97. dst->last_update.usec -= usec;
  98. }
  99. static void wpa_bss_add(struct wpa_supplicant *wpa_s,
  100. const u8 *ssid, size_t ssid_len,
  101. struct wpa_scan_res *res)
  102. {
  103. struct wpa_bss *bss;
  104. bss = os_zalloc(sizeof(*bss) + res->ie_len + res->beacon_ie_len);
  105. if (bss == NULL)
  106. return;
  107. bss->id = wpa_s->bss_next_id++;
  108. bss->last_update_idx = wpa_s->bss_update_idx;
  109. wpa_bss_copy_res(bss, res);
  110. os_memcpy(bss->ssid, ssid, ssid_len);
  111. bss->ssid_len = ssid_len;
  112. bss->ie_len = res->ie_len;
  113. bss->beacon_ie_len = res->beacon_ie_len;
  114. os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
  115. dl_list_add_tail(&wpa_s->bss, &bss->list);
  116. dl_list_add_tail(&wpa_s->bss_id, &bss->list_id);
  117. wpa_s->num_bss++;
  118. wpa_printf(MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR " SSID '%s'",
  119. bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len));
  120. wpas_notify_bss_added(wpa_s, bss->bssid, bss->id);
  121. if (wpa_s->num_bss > WPA_BSS_MAX_COUNT) {
  122. /* Remove the oldest entry */
  123. wpa_bss_remove(wpa_s, dl_list_first(&wpa_s->bss,
  124. struct wpa_bss, list));
  125. }
  126. }
  127. static int are_ies_equal(const struct wpa_bss *old,
  128. const struct wpa_scan_res *new, u32 ie)
  129. {
  130. const u8 *old_ie, *new_ie;
  131. struct wpabuf *old_ie_buff = NULL;
  132. struct wpabuf *new_ie_buff = NULL;
  133. int new_ie_len, old_ie_len, ret, is_multi;
  134. switch (ie) {
  135. case WPA_IE_VENDOR_TYPE:
  136. old_ie = wpa_bss_get_vendor_ie(old, ie);
  137. new_ie = wpa_scan_get_vendor_ie(new, ie);
  138. is_multi = 0;
  139. break;
  140. case WPS_IE_VENDOR_TYPE:
  141. old_ie_buff = wpa_bss_get_vendor_ie_multi(old, ie);
  142. new_ie_buff = wpa_scan_get_vendor_ie_multi(new, ie);
  143. is_multi = 1;
  144. break;
  145. case WLAN_EID_RSN:
  146. case WLAN_EID_SUPP_RATES:
  147. case WLAN_EID_EXT_SUPP_RATES:
  148. old_ie = wpa_bss_get_ie(old, ie);
  149. new_ie = wpa_scan_get_ie(new, ie);
  150. is_multi = 0;
  151. break;
  152. default:
  153. wpa_printf(MSG_DEBUG, "bss: %s: cannot compare IEs", __func__);
  154. return 0;
  155. }
  156. if (is_multi) {
  157. /* in case of multiple IEs stored in buffer */
  158. old_ie = old_ie_buff ? wpabuf_head_u8(old_ie_buff) : NULL;
  159. new_ie = new_ie_buff ? wpabuf_head_u8(new_ie_buff) : NULL;
  160. old_ie_len = old_ie_buff ? wpabuf_len(old_ie_buff) : 0;
  161. new_ie_len = new_ie_buff ? wpabuf_len(new_ie_buff) : 0;
  162. } else {
  163. /* in case of single IE */
  164. old_ie_len = old_ie ? old_ie[1] + 2 : 0;
  165. new_ie_len = new_ie ? new_ie[1] + 2 : 0;
  166. }
  167. ret = (old_ie_len == new_ie_len &&
  168. os_memcmp(old_ie, new_ie, old_ie_len) == 0);
  169. wpabuf_free(old_ie_buff);
  170. wpabuf_free(new_ie_buff);
  171. return ret;
  172. }
  173. static u32 wpa_bss_compare_res(const struct wpa_bss *old,
  174. const struct wpa_scan_res *new)
  175. {
  176. u32 changes = 0;
  177. int caps_diff = old->caps ^ new->caps;
  178. if (old->freq != new->freq)
  179. changes |= WPA_BSS_FREQ_CHANGED_FLAG;
  180. if (old->level != new->level)
  181. changes |= WPA_BSS_SIGNAL_CHANGED_FLAG;
  182. if (caps_diff & IEEE80211_CAP_PRIVACY)
  183. changes |= WPA_BSS_PRIVACY_CHANGED_FLAG;
  184. if (caps_diff & IEEE80211_CAP_IBSS)
  185. changes |= WPA_BSS_MODE_CHANGED_FLAG;
  186. if (!are_ies_equal(old, new, WPA_IE_VENDOR_TYPE))
  187. changes |= WPA_BSS_WPAIE_CHANGED_FLAG;
  188. if (!are_ies_equal(old, new, WLAN_EID_RSN))
  189. changes |= WPA_BSS_RSNIE_CHANGED_FLAG;
  190. if (!are_ies_equal(old, new, WPS_IE_VENDOR_TYPE))
  191. changes |= WPA_BSS_WPS_CHANGED_FLAG;
  192. if (!are_ies_equal(old, new, WLAN_EID_SUPP_RATES) ||
  193. !are_ies_equal(old, new, WLAN_EID_EXT_SUPP_RATES))
  194. changes |= WPA_BSS_RATES_CHANGED_FLAG;
  195. return changes;
  196. }
  197. static void notify_bss_changes(struct wpa_supplicant *wpa_s, u32 changes,
  198. const struct wpa_bss *bss)
  199. {
  200. if (changes & WPA_BSS_FREQ_CHANGED_FLAG)
  201. wpas_notify_bss_freq_changed(wpa_s, bss->id);
  202. if (changes & WPA_BSS_SIGNAL_CHANGED_FLAG)
  203. wpas_notify_bss_signal_changed(wpa_s, bss->id);
  204. if (changes & WPA_BSS_PRIVACY_CHANGED_FLAG)
  205. wpas_notify_bss_privacy_changed(wpa_s, bss->id);
  206. if (changes & WPA_BSS_MODE_CHANGED_FLAG)
  207. wpas_notify_bss_mode_changed(wpa_s, bss->id);
  208. if (changes & WPA_BSS_WPAIE_CHANGED_FLAG)
  209. wpas_notify_bss_wpaie_changed(wpa_s, bss->id);
  210. if (changes & WPA_BSS_RSNIE_CHANGED_FLAG)
  211. wpas_notify_bss_rsnie_changed(wpa_s, bss->id);
  212. if (changes & WPA_BSS_WPS_CHANGED_FLAG)
  213. wpas_notify_bss_wps_changed(wpa_s, bss->id);
  214. if (changes & WPA_BSS_RATES_CHANGED_FLAG)
  215. wpas_notify_bss_rates_changed(wpa_s, bss->id);
  216. }
  217. static void wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
  218. struct wpa_scan_res *res)
  219. {
  220. u32 changes;
  221. changes = wpa_bss_compare_res(bss, res);
  222. bss->scan_miss_count = 0;
  223. bss->last_update_idx = wpa_s->bss_update_idx;
  224. wpa_bss_copy_res(bss, res);
  225. /* Move the entry to the end of the list */
  226. dl_list_del(&bss->list);
  227. if (bss->ie_len + bss->beacon_ie_len >=
  228. res->ie_len + res->beacon_ie_len) {
  229. os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
  230. bss->ie_len = res->ie_len;
  231. bss->beacon_ie_len = res->beacon_ie_len;
  232. } else {
  233. struct wpa_bss *nbss;
  234. struct dl_list *prev = bss->list_id.prev;
  235. dl_list_del(&bss->list_id);
  236. nbss = os_realloc(bss, sizeof(*bss) + res->ie_len +
  237. res->beacon_ie_len);
  238. if (nbss) {
  239. bss = nbss;
  240. os_memcpy(bss + 1, res + 1,
  241. res->ie_len + res->beacon_ie_len);
  242. bss->ie_len = res->ie_len;
  243. bss->beacon_ie_len = res->beacon_ie_len;
  244. }
  245. dl_list_add(prev, &bss->list_id);
  246. }
  247. dl_list_add_tail(&wpa_s->bss, &bss->list);
  248. notify_bss_changes(wpa_s, changes, bss);
  249. }
  250. static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
  251. {
  252. return bss == wpa_s->current_bss ||
  253. os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
  254. os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0;
  255. }
  256. void wpa_bss_update_start(struct wpa_supplicant *wpa_s)
  257. {
  258. wpa_s->bss_update_idx++;
  259. wpa_printf(MSG_DEBUG, "BSS: Start scan result update %u",
  260. wpa_s->bss_update_idx);
  261. }
  262. void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
  263. struct wpa_scan_res *res)
  264. {
  265. const u8 *ssid;
  266. struct wpa_bss *bss;
  267. ssid = wpa_scan_get_ie(res, WLAN_EID_SSID);
  268. if (ssid == NULL) {
  269. wpa_printf(MSG_DEBUG, "BSS: No SSID IE included for " MACSTR,
  270. MAC2STR(res->bssid));
  271. return;
  272. }
  273. if (ssid[1] > 32) {
  274. wpa_printf(MSG_DEBUG, "BSS: Too long SSID IE included for "
  275. MACSTR, MAC2STR(res->bssid));
  276. return;
  277. }
  278. /* TODO: add option for ignoring BSSes we are not interested in
  279. * (to save memory) */
  280. bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]);
  281. if (bss == NULL)
  282. wpa_bss_add(wpa_s, ssid + 2, ssid[1], res);
  283. else
  284. wpa_bss_update(wpa_s, bss, res);
  285. }
  286. static int wpa_bss_included_in_scan(const struct wpa_bss *bss,
  287. const struct scan_info *info)
  288. {
  289. int found;
  290. size_t i;
  291. if (info == NULL)
  292. return 1;
  293. if (info->num_freqs) {
  294. found = 0;
  295. for (i = 0; i < info->num_freqs; i++) {
  296. if (bss->freq == info->freqs[i]) {
  297. found = 1;
  298. break;
  299. }
  300. }
  301. if (!found)
  302. return 0;
  303. }
  304. if (info->num_ssids) {
  305. found = 0;
  306. for (i = 0; i < info->num_ssids; i++) {
  307. const struct wpa_driver_scan_ssid *s = &info->ssids[i];
  308. if ((s->ssid == NULL || s->ssid_len == 0) ||
  309. (s->ssid_len == bss->ssid_len &&
  310. os_memcmp(s->ssid, bss->ssid, bss->ssid_len) ==
  311. 0)) {
  312. found = 1;
  313. break;
  314. }
  315. }
  316. if (!found)
  317. return 0;
  318. }
  319. return 1;
  320. }
  321. void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info,
  322. int new_scan)
  323. {
  324. struct wpa_bss *bss, *n;
  325. if (!new_scan)
  326. return; /* do not expire entries without new scan */
  327. dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
  328. if (wpa_bss_in_use(wpa_s, bss))
  329. continue;
  330. if (!wpa_bss_included_in_scan(bss, info))
  331. continue; /* expire only BSSes that were scanned */
  332. if (bss->last_update_idx < wpa_s->bss_update_idx)
  333. bss->scan_miss_count++;
  334. if (bss->scan_miss_count >= WPA_BSS_EXPIRATION_SCAN_COUNT) {
  335. wpa_printf(MSG_DEBUG, "BSS: Expire BSS %u due to no "
  336. "match in scan", bss->id);
  337. wpa_bss_remove(wpa_s, bss);
  338. }
  339. }
  340. }
  341. static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
  342. {
  343. struct wpa_supplicant *wpa_s = eloop_ctx;
  344. struct wpa_bss *bss, *n;
  345. struct os_time t;
  346. if (dl_list_empty(&wpa_s->bss))
  347. return;
  348. os_get_time(&t);
  349. t.sec -= WPA_BSS_EXPIRATION_AGE;
  350. dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
  351. if (wpa_bss_in_use(wpa_s, bss))
  352. continue;
  353. if (os_time_before(&bss->last_update, &t)) {
  354. wpa_printf(MSG_DEBUG, "BSS: Expire BSS %u due to age",
  355. bss->id);
  356. wpa_bss_remove(wpa_s, bss);
  357. } else
  358. break;
  359. }
  360. eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
  361. wpa_bss_timeout, wpa_s, NULL);
  362. }
  363. int wpa_bss_init(struct wpa_supplicant *wpa_s)
  364. {
  365. dl_list_init(&wpa_s->bss);
  366. dl_list_init(&wpa_s->bss_id);
  367. eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
  368. wpa_bss_timeout, wpa_s, NULL);
  369. return 0;
  370. }
  371. void wpa_bss_deinit(struct wpa_supplicant *wpa_s)
  372. {
  373. struct wpa_bss *bss, *n;
  374. eloop_cancel_timeout(wpa_bss_timeout, wpa_s, NULL);
  375. if (wpa_s->bss.next == NULL)
  376. return; /* BSS table not yet initialized */
  377. dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list)
  378. wpa_bss_remove(wpa_s, bss);
  379. }
  380. struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
  381. const u8 *bssid)
  382. {
  383. struct wpa_bss *bss;
  384. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  385. if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
  386. return bss;
  387. }
  388. return NULL;
  389. }
  390. struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id)
  391. {
  392. struct wpa_bss *bss;
  393. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  394. if (bss->id == id)
  395. return bss;
  396. }
  397. return NULL;
  398. }
  399. const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie)
  400. {
  401. const u8 *end, *pos;
  402. pos = (const u8 *) (bss + 1);
  403. end = pos + bss->ie_len;
  404. while (pos + 1 < end) {
  405. if (pos + 2 + pos[1] > end)
  406. break;
  407. if (pos[0] == ie)
  408. return pos;
  409. pos += 2 + pos[1];
  410. }
  411. return NULL;
  412. }
  413. const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type)
  414. {
  415. const u8 *end, *pos;
  416. pos = (const u8 *) (bss + 1);
  417. end = pos + bss->ie_len;
  418. while (pos + 1 < end) {
  419. if (pos + 2 + pos[1] > end)
  420. break;
  421. if (pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 &&
  422. vendor_type == WPA_GET_BE32(&pos[2]))
  423. return pos;
  424. pos += 2 + pos[1];
  425. }
  426. return NULL;
  427. }
  428. struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
  429. u32 vendor_type)
  430. {
  431. struct wpabuf *buf;
  432. const u8 *end, *pos;
  433. buf = wpabuf_alloc(bss->ie_len);
  434. if (buf == NULL)
  435. return NULL;
  436. pos = (const u8 *) (bss + 1);
  437. end = pos + bss->ie_len;
  438. while (pos + 1 < end) {
  439. if (pos + 2 + pos[1] > end)
  440. break;
  441. if (pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 &&
  442. vendor_type == WPA_GET_BE32(&pos[2]))
  443. wpabuf_put_data(buf, pos + 2 + 4, pos[1] - 4);
  444. pos += 2 + pos[1];
  445. }
  446. if (wpabuf_len(buf) == 0) {
  447. wpabuf_free(buf);
  448. buf = NULL;
  449. }
  450. return buf;
  451. }
  452. int wpa_bss_get_max_rate(const struct wpa_bss *bss)
  453. {
  454. int rate = 0;
  455. const u8 *ie;
  456. int i;
  457. ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
  458. for (i = 0; ie && i < ie[1]; i++) {
  459. if ((ie[i + 2] & 0x7f) > rate)
  460. rate = ie[i + 2] & 0x7f;
  461. }
  462. ie = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
  463. for (i = 0; ie && i < ie[1]; i++) {
  464. if ((ie[i + 2] & 0x7f) > rate)
  465. rate = ie[i + 2] & 0x7f;
  466. }
  467. return rate;
  468. }
  469. int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates)
  470. {
  471. const u8 *ie, *ie2;
  472. int i, j;
  473. unsigned int len;
  474. u8 *r;
  475. ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
  476. ie2 = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
  477. len = (ie ? ie[1] : 0) + (ie2 ? ie2[1] : 0);
  478. r = os_malloc(len);
  479. if (!r)
  480. return -1;
  481. for (i = 0; ie && i < ie[1]; i++)
  482. r[i] = ie[i + 2] & 0x7f;
  483. for (j = 0; ie2 && j < ie2[1]; j++)
  484. r[i + j] = ie2[j + 2] & 0x7f;
  485. *rates = r;
  486. return len;
  487. }