How to configure an IoT wifi setup
by KeithG
Group,
I am not sure if this is the right terminology but this is what I am
trying to do:
Power up a headless device. If it does not get an ethernet or wifi
connection, it launches AP mode of some sort and allows a device to
connect then configure the wifi connection by selecting an AP and
typing in a password.
This works with hostapd/dsnmasq, currently. I want to switch over to
connman and/or iwd to do this, but have not been successful in doing
this.
If I set up connman by:
"# connmanctl tether wifi on SSID password" I can connect and 'see' my
new SSID, but I cannot scan for any APs to set up. I do not know how
to set the SSID IP address, if this has been enabled in connman.
I have tried with iwctl as well:
set up /etc/iwd/main.conf
[General]
EnableNetworkConfiguration=true
APRanges=192.168.1.0/24
# iwctl device wlan0 set-property Mode ap
# iwctl ap wlan0 start SSID password
With this I can connect, but once again, I cannot scan for any
available SSIDs to connect to. It is not important that I be able to
connect, but I do need to see the SSIDs so the user can set it up then
reboot (or restart connman/iwd) to connect to the new 'known' SSID.
Thanks,
Keith
12 months
[PATCH v2 1/7] ie: fix ie_parse_data_rates to handle NULL
by James Prestwood
The code was partially there to handle NULL IEs but not
quite. If NULL IEs are passed in base the data rate totally
on the basic rate RSSI table.
---
src/ie.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/ie.c b/src/ie.c
index 0f430b98..0b471f1b 100644
--- a/src/ie.c
+++ b/src/ie.c
@@ -1688,14 +1688,16 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
max_rate = map->rate;
}
- /* Find highest rate in Supported Rates IE */
- rates = ie_tlv_iter_get_data(supp_rates_iter);
+ if (supp_rates_iter) {
+ /* Find highest rate in Supported Rates IE */
+ rates = ie_tlv_iter_get_data(supp_rates_iter);
- for (i = 0; i < len; i++) {
- uint8_t r = rates[i] & 0x7f;
+ for (i = 0; i < len; i++) {
+ uint8_t r = rates[i] & 0x7f;
- if (r <= max_rate && r > highest)
- highest = r;
+ if (r <= max_rate && r > highest)
+ highest = r;
+ }
}
/* Find highest rate in Extended Supported Rates IE */
@@ -1711,7 +1713,10 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
}
}
- *data_rate = (highest / 2) * 1000000;
+ if (highest)
+ *data_rate = (highest / 2) * 1000000;
+ else
+ *data_rate = (max_rate / 2) * 1000000;
return 0;
}
--
2.31.1
12 months
[PATCH] network: use L_AUTO_FREE_VAR
by Marc-Antoine Perennou
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine(a)Perennou.com>
---
src/network.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/network.c b/src/network.c
index 9e858663..0eb3687e 100644
--- a/src/network.c
+++ b/src/network.c
@@ -380,10 +380,10 @@ static int network_load_psk(struct network *network, bool need_passphrase)
size_t psk_len;
uint8_t *psk = l_settings_get_bytes(network->settings, "Security",
"PreSharedKey", &psk_len);
- _auto_(l_free) char *passphrase =
+ L_AUTO_FREE_VAR(char *, passphrase) =
l_settings_get_string(network->settings,
"Security", "Passphrase");
- _auto_(l_free) char *path =
+ L_AUTO_FREE_VAR(char *, path) =
storage_get_network_file_path(security, ssid);
int r;
--
2.30.0
12 months
[PATCH 1/2] eap: avoid nested functions
by Marc-Antoine Perennou
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine(a)Perennou.com>
---
src/eap.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/eap.c b/src/eap.c
index 0645be47..53e35b5e 100644
--- a/src/eap.c
+++ b/src/eap.c
@@ -416,6 +416,8 @@ static const char *eap_type_to_str(enum eap_type type, uint32_t vendor_id,
#define IS_EXPANDED_RESPONSE(id, t) \
(type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
+#define response_is(wanted) ((type == wanted) || IS_EXPANDED_RESPONSE(0, wanted))
+
static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
size_t len)
{
@@ -428,14 +430,6 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
eap->method->vendor_id[2];
uint32_t our_vendor_type = eap->method->vendor_type;
- bool response_is(enum eap_type wanted)
- {
- if (type == wanted)
- return true;
-
- return IS_EXPANDED_RESPONSE(0, wanted);
- }
-
if (len < 1)
/* Invalid packets to be ignored */
return;
--
2.30.0
12 months
[PATCH 1/9] ap: Make rtnl global static
by Andrew Zaborowski
---
src/ap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ap.c b/src/ap.c
index 8851cb85..7eac07d7 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -141,7 +141,7 @@ struct ap_ip_pool {
struct ap_ip_pool pool;
static uint32_t netdev_watch;
-struct l_netlink *rtnl;
+static struct l_netlink *rtnl;
/*
* Creates pool of IPs which AP intefaces can use. Each call to ip_pool_get
--
2.27.0
12 months
[PATCH v3 1/2] ie: refactor parsing supported data rates
by James Prestwood
Both ext/supported rates IEs are obtained from scan results. These
IEs are passed to ie_tlv_init/ie_tlv_next, as well as direct length
checks (for supported rates at least, extended supported rates can
be as long as a single byte integer can hold, 1 - 255) which verifies
that the length in the IE matches the overall IE length that is
stored in scan_bss. Because of this, ie_parse_supported_rates_from_data
was doing double duty re-initializing a TLV iterator.
Intead, since we know the IE length is within bounds, the length/data
can simply be directly accessed out of the buffer. This avoids the need
for a wrapper function entirely.
The length parameters were also removed, since this is now obtained
directly from the IE.
---
src/ie.c | 76 +++++++++++++++-----------------------------------------
src/ie.h | 6 -----
2 files changed, 20 insertions(+), 62 deletions(-)
v3:
* Added back in len == 0 check. This is NOT verified in scan.c, only
the total length is sanity checked.
diff --git a/src/ie.c b/src/ie.c
index 0b471f1b..53636049 100644
--- a/src/ie.c
+++ b/src/ie.c
@@ -1662,10 +1662,9 @@ static const struct basic_rate_map rate_rssi_map[] = {
{ -65, 108 },
};
-static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
- struct ie_tlv_iter *ext_supp_rates_iter,
- int32_t rssi,
- uint64_t *data_rate)
+static int ie_parse_supported_rates_from_data(const uint8_t *supp_rates_ie,
+ const uint8_t *ext_supp_rates_ie,
+ int32_t rssi, uint64_t *data_rate)
{
uint8_t max_rate = 0;
uint8_t highest = 0;
@@ -1673,11 +1672,6 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
unsigned int len;
unsigned int i;
- len = ie_tlv_iter_get_length(supp_rates_iter);
-
- if (len == 0)
- return -EINVAL;
-
/* Find highest rates possible with our RSSI */
for (i = 0; i < L_ARRAY_SIZE(rate_rssi_map); i++) {
const struct basic_rate_map *map = &rate_rssi_map[i];
@@ -1688,9 +1682,17 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
max_rate = map->rate;
}
- if (supp_rates_iter) {
- /* Find highest rate in Supported Rates IE */
- rates = ie_tlv_iter_get_data(supp_rates_iter);
+ /*
+ * Find highest rate in Supported Rates IE. These IEs have at least
+ * been verfied that the length is within the buffer bounds (as has
+ * ext_supp_rates_ie).
+ */
+ if (supp_rates_ie) {
+ len = supp_rates_ie[1];
+ if (len == 0)
+ return -EINVAL;
+
+ rates = supp_rates_ie + 2;
for (i = 0; i < len; i++) {
uint8_t r = rates[i] & 0x7f;
@@ -1701,9 +1703,12 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
}
/* Find highest rate in Extended Supported Rates IE */
- if (ext_supp_rates_iter) {
- len = ie_tlv_iter_get_length(ext_supp_rates_iter);
- rates = ie_tlv_iter_get_data(ext_supp_rates_iter);
+ if (ext_supp_rates_ie) {
+ len = ext_supp_rates_ie[1];
+ if (len == 0)
+ return -EINVAL;
+
+ rates = ext_supp_rates_ie + 2;
for (i = 0; i < len; i++) {
uint8_t r = rates[i] & 0x7f;
@@ -1721,45 +1726,6 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
return 0;
}
-int ie_parse_supported_rates_from_data(const uint8_t *supp_rates_ie,
- uint8_t supp_rates_len,
- const uint8_t *ext_supp_rates_ie,
- uint8_t ext_supp_rates_len,
- int32_t rssi, uint64_t *data_rate)
-{
- struct ie_tlv_iter supp_rates_iter;
- struct ie_tlv_iter ext_supp_rates_iter;
-
- if (supp_rates_ie) {
- ie_tlv_iter_init(&supp_rates_iter, supp_rates_ie,
- supp_rates_len);
-
- if (!ie_tlv_iter_next(&supp_rates_iter))
- return -EMSGSIZE;
-
- if (ie_tlv_iter_get_tag(&supp_rates_iter) !=
- IE_TYPE_SUPPORTED_RATES)
- return -EPROTOTYPE;
- }
-
- if (ext_supp_rates_ie) {
- ie_tlv_iter_init(&ext_supp_rates_iter, ext_supp_rates_ie,
- ext_supp_rates_len);
-
- if (!ie_tlv_iter_next(&ext_supp_rates_iter))
- return -EMSGSIZE;
-
- if (ie_tlv_iter_get_tag(&ext_supp_rates_iter) !=
- IE_TYPE_EXTENDED_SUPPORTED_RATES)
- return -EPROTOTYPE;
- }
-
- return ie_parse_supported_rates(
- (supp_rates_ie) ? &supp_rates_iter : NULL,
- (ext_supp_rates_ie) ? &ext_supp_rates_iter : NULL,
- rssi, data_rate);
-}
-
enum ht_vht_channel_width {
HT_VHT_CHANNEL_WIDTH_20MHZ = 0,
HT_VHT_CHANNEL_WIDTH_40MHZ,
@@ -2173,9 +2139,7 @@ int ie_parse_data_rates(const uint8_t *supp_rates_ie,
if (supp_rates_ie || ext_supp_rates_ie) {
ret = ie_parse_supported_rates_from_data(supp_rates_ie,
- IE_LEN(supp_rates_ie),
ext_supp_rates_ie,
- IE_LEN(supp_rates_ie),
rssi, &rate);
if (ret == 0)
goto done;
diff --git a/src/ie.h b/src/ie.h
index 538ca9a8..5f7fa199 100644
--- a/src/ie.h
+++ b/src/ie.h
@@ -484,12 +484,6 @@ int ie_parse_bss_load_from_data(const uint8_t *data, uint8_t len,
uint8_t *out_channel_utilization,
uint16_t *out_admission_capacity);
-int ie_parse_supported_rates_from_data(const uint8_t *supp_rates_ie,
- uint8_t supp_rates_len,
- const uint8_t *ext_supp_rates_ie,
- uint8_t ext_supp_rates_len,
- int32_t rssi, uint64_t *data_rate);
-
int ie_parse_data_rates(const uint8_t *supp_rates_ie,
const uint8_t *ext_supp_rates_ie,
const uint8_t *ht_ie,
--
2.31.1
1 year
[PATCH v2] ie: refactor parsing supported data rates
by James Prestwood
Both ext/supported rates IEs are obtained from scan results. These
IEs are passed to ie_tlv_init/ie_tlv_next, as well as direct length
checks (for supported rates at least, extended supported rates can
be as long as a single byte integer can hold, 1 - 255) which verifies
that the length in the IE matches the overall IE length that is
stored in scan_bss. Because of this, ie_parse_supported_rates_from_data
was doing double duty re-initializing a TLV iterator.
Intead, since we know the IE length is within bounds, the length/data
can simply be directly accessed out of the buffer. This avoids the need
for a wrapper function entirely.
---
src/ie.c | 70 +++++++++++++-------------------------------------------
src/ie.h | 6 -----
2 files changed, 16 insertions(+), 60 deletions(-)
v2:
* Refactored rather than fix the static analysis warning directly. This
change should eliminate that warning as well.
* Removed exposure of ie_parse_supported_rates_from_data in ie.h
* Removed tlv parsing as this already happened in scan.c. Changed to do
direct data access since the length has been verified.
diff --git a/src/ie.c b/src/ie.c
index 0b471f1b..6b8e3621 100644
--- a/src/ie.c
+++ b/src/ie.c
@@ -1662,10 +1662,11 @@ static const struct basic_rate_map rate_rssi_map[] = {
{ -65, 108 },
};
-static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
- struct ie_tlv_iter *ext_supp_rates_iter,
- int32_t rssi,
- uint64_t *data_rate)
+static int ie_parse_supported_rates_from_data(const uint8_t *supp_rates_ie,
+ uint8_t supp_rates_len,
+ const uint8_t *ext_supp_rates_ie,
+ uint8_t ext_supp_rates_len,
+ int32_t rssi, uint64_t *data_rate)
{
uint8_t max_rate = 0;
uint8_t highest = 0;
@@ -1673,11 +1674,6 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
unsigned int len;
unsigned int i;
- len = ie_tlv_iter_get_length(supp_rates_iter);
-
- if (len == 0)
- return -EINVAL;
-
/* Find highest rates possible with our RSSI */
for (i = 0; i < L_ARRAY_SIZE(rate_rssi_map); i++) {
const struct basic_rate_map *map = &rate_rssi_map[i];
@@ -1688,9 +1684,14 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
max_rate = map->rate;
}
- if (supp_rates_iter) {
- /* Find highest rate in Supported Rates IE */
- rates = ie_tlv_iter_get_data(supp_rates_iter);
+ /*
+ * Find highest rate in Supported Rates IE. These IEs have at least
+ * been verfied that the length is within the buffer bounds (as has
+ * ext_supp_rates_ie).
+ */
+ if (supp_rates_ie) {
+ len = supp_rates_ie[1];
+ rates = supp_rates_ie + 2;
for (i = 0; i < len; i++) {
uint8_t r = rates[i] & 0x7f;
@@ -1701,9 +1702,9 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
}
/* Find highest rate in Extended Supported Rates IE */
- if (ext_supp_rates_iter) {
- len = ie_tlv_iter_get_length(ext_supp_rates_iter);
- rates = ie_tlv_iter_get_data(ext_supp_rates_iter);
+ if (ext_supp_rates_ie) {
+ len = ext_supp_rates_ie[1];
+ rates = ext_supp_rates_ie + 2;
for (i = 0; i < len; i++) {
uint8_t r = rates[i] & 0x7f;
@@ -1721,45 +1722,6 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
return 0;
}
-int ie_parse_supported_rates_from_data(const uint8_t *supp_rates_ie,
- uint8_t supp_rates_len,
- const uint8_t *ext_supp_rates_ie,
- uint8_t ext_supp_rates_len,
- int32_t rssi, uint64_t *data_rate)
-{
- struct ie_tlv_iter supp_rates_iter;
- struct ie_tlv_iter ext_supp_rates_iter;
-
- if (supp_rates_ie) {
- ie_tlv_iter_init(&supp_rates_iter, supp_rates_ie,
- supp_rates_len);
-
- if (!ie_tlv_iter_next(&supp_rates_iter))
- return -EMSGSIZE;
-
- if (ie_tlv_iter_get_tag(&supp_rates_iter) !=
- IE_TYPE_SUPPORTED_RATES)
- return -EPROTOTYPE;
- }
-
- if (ext_supp_rates_ie) {
- ie_tlv_iter_init(&ext_supp_rates_iter, ext_supp_rates_ie,
- ext_supp_rates_len);
-
- if (!ie_tlv_iter_next(&ext_supp_rates_iter))
- return -EMSGSIZE;
-
- if (ie_tlv_iter_get_tag(&ext_supp_rates_iter) !=
- IE_TYPE_EXTENDED_SUPPORTED_RATES)
- return -EPROTOTYPE;
- }
-
- return ie_parse_supported_rates(
- (supp_rates_ie) ? &supp_rates_iter : NULL,
- (ext_supp_rates_ie) ? &ext_supp_rates_iter : NULL,
- rssi, data_rate);
-}
-
enum ht_vht_channel_width {
HT_VHT_CHANNEL_WIDTH_20MHZ = 0,
HT_VHT_CHANNEL_WIDTH_40MHZ,
diff --git a/src/ie.h b/src/ie.h
index 538ca9a8..5f7fa199 100644
--- a/src/ie.h
+++ b/src/ie.h
@@ -484,12 +484,6 @@ int ie_parse_bss_load_from_data(const uint8_t *data, uint8_t len,
uint8_t *out_channel_utilization,
uint16_t *out_admission_capacity);
-int ie_parse_supported_rates_from_data(const uint8_t *supp_rates_ie,
- uint8_t supp_rates_len,
- const uint8_t *ext_supp_rates_ie,
- uint8_t ext_supp_rates_len,
- int32_t rssi, uint64_t *data_rate);
-
int ie_parse_data_rates(const uint8_t *supp_rates_ie,
const uint8_t *ext_supp_rates_ie,
const uint8_t *ht_ie,
--
2.31.1
1 year
[PATCH] ie: fix static analysis warning
by James Prestwood
The supp_rates_iter was being used prior to the NULL check. This
was fixed as well as some reordering to make the function consistent
between supp_rates_iter and ext_supp_rates_iter.
---
src/ie.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/ie.c b/src/ie.c
index 0b471f1b..352ce469 100644
--- a/src/ie.c
+++ b/src/ie.c
@@ -1673,11 +1673,6 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
unsigned int len;
unsigned int i;
- len = ie_tlv_iter_get_length(supp_rates_iter);
-
- if (len == 0)
- return -EINVAL;
-
/* Find highest rates possible with our RSSI */
for (i = 0; i < L_ARRAY_SIZE(rate_rssi_map); i++) {
const struct basic_rate_map *map = &rate_rssi_map[i];
@@ -1688,8 +1683,9 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
max_rate = map->rate;
}
+ /* Find highest rate in Supported Rates IE */
if (supp_rates_iter) {
- /* Find highest rate in Supported Rates IE */
+ len = ie_tlv_iter_get_length(supp_rates_iter);
rates = ie_tlv_iter_get_data(supp_rates_iter);
for (i = 0; i < len; i++) {
--
2.31.1
1 year
Consider supporting building with clang
by keruspe+ml01@gmail.com
Hello,
Since the introduction of the _auto_ destructor macros, ell and iwd generate nested functions, which are a gnu extension not supported by clang.
While adding support for that in clang would also benefit other projects, I don't think this idea is going anywhere as it has been brought up numerous times in the past and never went forward.
The way e.g. glib deals with it is by splitting this in two, first define the destructor function alonside the struct it is going to destruct, then hook it up with a macro like _auto_ here, this way no nested functions are needed. Would this make sense for ell/iwd too? I can provide patches if required.
1 year
[PATCH v3 01/11] station: factor out logic for choosing FT
by James Prestwood
---
src/station.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/station.c b/src/station.c
index 479f81f5..bdb8859a 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1823,13 +1823,30 @@ static void station_preauthenticate_cb(struct netdev *netdev,
station_transition_reassociate(station, bss, new_hs);
}
+static bool station_can_fast_transition(struct handshake_state *hs,
+ struct scan_bss *bss)
+{
+ uint16_t mdid;
+
+ if (!hs->mde)
+ return false;
+
+ if (ie_parse_mobility_domain_from_data(hs->mde, hs->mde[1] + 2,
+ &mdid, NULL, NULL) < 0)
+ return false;
+
+ if (bss->mde_present && l_get_le16(bss->mde) == mdid)
+ return true;
+
+ return false;
+}
+
static void station_transition_start(struct station *station,
struct scan_bss *bss)
{
struct handshake_state *hs = netdev_get_handshake(station->netdev);
struct network *connected = station->connected_network;
enum security security = network_get_security(connected);
- uint16_t mdid;
struct handshake_state *new_hs;
struct ie_rsn_info cur_rsne, target_rsne;
@@ -1839,12 +1856,8 @@ static void station_transition_start(struct station *station,
/* Reset AP roam flag, at this point the roaming behaves the same */
station->ap_directed_roaming = false;
- if (hs->mde)
- ie_parse_mobility_domain_from_data(hs->mde, hs->mde[1] + 2,
- &mdid, NULL, NULL);
-
/* Can we use Fast Transition? */
- if (hs->mde && bss->mde_present && l_get_le16(bss->mde) == mdid) {
+ if (station_can_fast_transition(hs, bss)) {
/* Rebuild handshake RSN for target AP */
if (station_build_handshake_rsn(hs, station->wiphy,
station->connected_network, bss) < 0) {
--
2.31.1
1 year