diff options
author | Lukas Maerdian <lukas.maerdian@canonical.com> | 2020-04-07 18:46:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 18:46:59 +0200 |
commit | 9a1633af7cf341474edc52fd6ee838f3b5ed52dd (patch) | |
tree | df127433b942f6c1a3c5e7ea2b149377ce8813a5 /src/networkd.c | |
parent | 0586a8d539326cc3273c2ea6f36c6dfe1cbe211b (diff) |
Implement WiFi flags for bssid/band/channel (#125)
* nm: write wifi-bssid/band/channel fields
* parse: create & use generic handler functions
* parse: add wifi band/channel/bssid fields
* parse:nm: implement 'seen-bssids' array for NM backend
* networkd: implement wifi - bssid/seen-bssids/band/channel
* util: match wifi channel & frequency
* nm: validate WiFi channels
* doc: note about seen-bssids compatibility
* doc: util: networkd: Review fixes
* Review and language fixes
* NM: remove deprecated seen-bssids option
The "wifi.seen-bssids" setting is deprecated.
NetworkManager will not read this option or use it internally.
Instead, it reads this data from it's internal state db at:
/var/lib/NetworkManager/seen-bssids
This is why we do not need to support this field for netplan.io
Diffstat (limited to 'src/networkd.c')
-rw-r--r-- | src/networkd.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/networkd.c b/src/networkd.c index bb1c45b..e8b8984 100644 --- a/src/networkd.c +++ b/src/networkd.c @@ -29,6 +29,15 @@ #include "parse.h" #include "util.h" +/** + * Append WiFi frequencies to wpa_supplicant's freq_list= + */ +static void +wifi_append_freq(gpointer key, gpointer value, gpointer user_data) +{ + GString* s = user_data; + g_string_append_printf(s, "%d ", GPOINTER_TO_INT(value)); +} /** * Append [Match] section of @def to @s. @@ -819,6 +828,34 @@ write_wpa_conf(const NetplanNetDefinition* def, const char* rootdir) g_hash_table_iter_init(&iter, def->access_points); while (g_hash_table_iter_next(&iter, NULL, (gpointer) &ap)) { g_string_append_printf(s, "network={\n ssid=\"%s\"\n", ap->ssid); + if (ap->bssid) { + g_string_append_printf(s, " bssid=%s\n", ap->bssid); + } + if (ap->band == NETPLAN_WIFI_BAND_24) { + // initialize 2.4GHz frequency hashtable + if(!wifi_frequency_24) + wifi_get_freq24(1); + if (ap->channel) { + g_string_append_printf(s, " freq_list=%d\n", wifi_get_freq24(ap->channel)); + } else { + g_string_append_printf(s, " freq_list="); + g_hash_table_foreach(wifi_frequency_24, wifi_append_freq, s); + // overwrite last whitespace with newline + s = g_string_overwrite(s, s->len-1, "\n"); + } + } else if (ap->band == NETPLAN_WIFI_BAND_5) { + // initialize 5GHz frequency hashtable + if(!wifi_frequency_5) + wifi_get_freq5(7); + if (ap->channel) { + g_string_append_printf(s, " freq_list=%d\n", wifi_get_freq5(ap->channel)); + } else { + g_string_append_printf(s, " freq_list="); + g_hash_table_foreach(wifi_frequency_5, wifi_append_freq, s); + // overwrite last whitespace with newline + s = g_string_overwrite(s, s->len-1, "\n"); + } + } switch (ap->mode) { case NETPLAN_WIFI_MODE_INFRASTRUCTURE: /* default in wpasupplicant */ |