From e41bee377d860ad79f7134947775348d4b8833ff Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 2 Jun 2021 10:50:08 -0500 Subject: [PATCH] band: Add band.[ch] Move the band definition out of wiphy.c and into band.[ch]. This is done to make certain utilities that depend on band information capable of being tested from unit tests. The band concept will most likely grow over time. For now, the only user will be wiphy.c and unit tests, so the structures are kept public. --- Makefile.am | 1 + src/band.c | 28 ++++++++++++++++++++++++++++ src/band.h | 34 ++++++++++++++++++++++++++++++++++ src/wiphy.c | 17 +---------------- 4 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 src/band.c create mode 100644 src/band.h diff --git a/Makefile.am b/Makefile.am index 083bc95a..808734c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -244,6 +244,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h src/missing.h \ src/wscutil.h src/wscutil.c \ src/diagnostic.h src/diagnostic.c \ src/ip-pool.h src/ip-pool.c \ + src/band.h src/band.c \ $(eap_sources) \ $(builtin_sources) diff --git a/src/band.c b/src/band.c new file mode 100644 index 00000000..c5908d24 --- /dev/null +++ b/src/band.c @@ -0,0 +1,28 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2021 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "band.h" + +void band_free(struct band *band) +{ + l_free(band); +} diff --git a/src/band.h b/src/band.h new file mode 100644 index 00000000..e3b11c91 --- /dev/null +++ b/src/band.h @@ -0,0 +1,34 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2021 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +struct band { + uint8_t vht_mcs_set[8]; + uint8_t vht_capabilities[4]; + bool vht_supported : 1; + uint8_t ht_mcs_set[16]; + uint8_t ht_capabilities[2]; + bool ht_supported : 1; + uint16_t supported_rates_len; + uint8_t supported_rates[]; +}; + +void band_free(struct band *band); diff --git a/src/wiphy.c b/src/wiphy.c index 25ea352f..9aedb8b6 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -55,6 +55,7 @@ #include "src/watchlist.h" #include "src/nl80211util.h" #include "src/nl80211cmd.h" +#include "src/band.h" #define EXT_CAP_LEN 10 @@ -66,17 +67,6 @@ static int mac_randomize_bytes = 6; static char regdom_country[2]; static uint32_t work_ids; -struct band { - uint8_t vht_mcs_set[8]; - uint8_t vht_capabilities[4]; - bool vht_supported : 1; - uint8_t ht_mcs_set[16]; - uint8_t ht_capabilities[2]; - bool ht_supported : 1; - uint16_t supported_rates_len; - uint8_t supported_rates[]; -}; - struct wiphy { uint32_t id; char name[20]; @@ -138,11 +128,6 @@ enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy, uint16_t mask) return 0; } -static void band_free(struct band *band) -{ - l_free(band); -} - static bool wiphy_can_connect_sae(struct wiphy *wiphy) { /*