cfg80211.h (5edde07c2aba02d0f7d30bbb0f203ec3e920e273) cfg80211.h (5db817d864241232c51d654836996282c69f5e28)
1/*-
2 * Copyright (c) 2020-2021 The FreeBSD Foundation
3 * Copyright (c) 2021-2022 Bjoern A. Zeeb
4 *
5 * This software was developed by Björn Zeeb under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 1307 unchanged lines hidden (view full) ---

1316}
1317
1318struct element {
1319 uint8_t id;
1320 uint8_t datalen;
1321 uint8_t data[0];
1322} __packed;
1323
1/*-
2 * Copyright (c) 2020-2021 The FreeBSD Foundation
3 * Copyright (c) 2021-2022 Bjoern A. Zeeb
4 *
5 * This software was developed by Björn Zeeb under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 1307 unchanged lines hidden (view full) ---

1316}
1317
1318struct element {
1319 uint8_t id;
1320 uint8_t datalen;
1321 uint8_t data[0];
1322} __packed;
1323
1324static __inline const struct element *
1325cfg80211_find_elem(enum ieee80211_eid eid, uint8_t *data, size_t len)
1324static inline const struct element *
1325lkpi_cfg80211_find_elem_pattern(enum ieee80211_eid eid,
1326 const uint8_t *data, size_t len, uint8_t *pattern, size_t plen)
1326{
1327{
1327 TODO();
1328 const struct element *elem;
1329 const uint8_t *p;
1330 size_t ielen;
1331
1332 p = data;
1333 elem = (const struct element *)p;
1334 ielen = len;
1335 while (elem != NULL && ielen > 1) {
1336 if ((2 + elem->datalen) > ielen)
1337 /* Element overruns our memory. */
1338 return (NULL);
1339 if (elem->id == eid) {
1340 if (pattern == NULL)
1341 return (elem);
1342 if (elem->datalen >= plen &&
1343 memcmp(elem->data, pattern, plen) == 0)
1344 return (elem);
1345 }
1346 ielen -= 2 + elem->datalen;
1347 p += 2 + elem->datalen;
1348 elem = (const struct element *)p;
1349 }
1350
1328 return (NULL);
1329}
1330
1351 return (NULL);
1352}
1353
1354static inline const struct element *
1355cfg80211_find_elem(enum ieee80211_eid eid, const uint8_t *data, size_t len)
1356{
1357
1358 return (lkpi_cfg80211_find_elem_pattern(eid, data, len, NULL, 0));
1359}
1360
1361static inline const struct element *
1362ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid)
1363{
1364
1365 if (bss->ies == NULL)
1366 return (NULL);
1367 return (cfg80211_find_elem(eid, bss->ies->data, bss->ies->len));
1368}
1369
1370static inline const uint8_t *
1371ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid)
1372{
1373
1374 return ((const uint8_t *)ieee80211_bss_get_elem(bss, eid));
1375}
1376
1377static inline uint8_t *
1378cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
1379 uint8_t *data, size_t len)
1380{
1381 const struct element *elem;
1382 uint8_t pattern[4] = { oui << 16, oui << 8, oui, oui_type };
1383 uint8_t plen = 4; /* >= 3? oui_type always part of this? */
1384 IMPROVE("plen currently always incl. oui_type");
1385
1386 elem = lkpi_cfg80211_find_elem_pattern(IEEE80211_ELEMID_VENDOR,
1387 data, len, pattern, plen);
1388 if (elem == NULL)
1389 return (NULL);
1390 return (__DECONST(uint8_t *, elem));
1391}
1392
1331static __inline uint32_t
1332cfg80211_calculate_bitrate(struct rate_info *rate)
1333{
1334 TODO();
1335 return (-1);
1336}
1337
1338static __inline uint32_t

--- 95 unchanged lines hidden (view full) ---

1434static __inline void
1435wiphy_read_of_freq_limits(struct wiphy *wiphy)
1436{
1437#ifdef FDT
1438 TODO();
1439#endif
1440}
1441
1393static __inline uint32_t
1394cfg80211_calculate_bitrate(struct rate_info *rate)
1395{
1396 TODO();
1397 return (-1);
1398}
1399
1400static __inline uint32_t

--- 95 unchanged lines hidden (view full) ---

1496static __inline void
1497wiphy_read_of_freq_limits(struct wiphy *wiphy)
1498{
1499#ifdef FDT
1500 TODO();
1501#endif
1502}
1503
1442static __inline uint8_t *
1443cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type,
1444 uint8_t *data, size_t len)
1445{
1446 TODO();
1447 return (NULL);
1448}
1449
1450static __inline void
1451wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1452{
1453
1454 set_bit(ef, wiphy->ext_features);
1455}
1456
1457static __inline void *

--- 298 unchanged lines hidden ---
1504static __inline void
1505wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1506{
1507
1508 set_bit(ef, wiphy->ext_features);
1509}
1510
1511static __inline void *

--- 298 unchanged lines hidden ---