diff options
author | Michael Trimarchi <michael@amarulasolutions.com> | 2021-10-07 23:30:19 +0200 |
---|---|---|
committer | Daniel Wagner <wagi@monom.org> | 2021-10-15 09:00:58 +0200 |
commit | c08b686638490fe4225197638e92921280bafa42 (patch) | |
tree | 44a6100d63a76d3d288c42bad345df0d5bbb1ee7 | |
parent | 8be99d69c7510804821a2a8c308f787f69e24071 (diff) | |
download | connman-c08b686638490fe4225197638e92921280bafa42.tar.gz |
tethering: Add possibility to configure the access point frequency
When the tethering mode is started, a WiFi AP is created using the fixed
channel 1 (2412 MHz). Add a way to configure the channel.
-rw-r--r-- | include/technology.h | 2 | ||||
-rw-r--r-- | plugins/iwd.c | 3 | ||||
-rw-r--r-- | plugins/neard.c | 4 | ||||
-rw-r--r-- | plugins/wifi.c | 9 | ||||
-rw-r--r-- | src/technology.c | 41 |
5 files changed, 52 insertions, 7 deletions
diff --git a/include/technology.h b/include/technology.h index 381a48df..fcd658e8 100644 --- a/include/technology.h +++ b/include/technology.h @@ -46,7 +46,7 @@ enum connman_service_type connman_technology_get_type (struct connman_technology *technology); bool connman_technology_get_wifi_tethering(const struct connman_technology *technology, - const char **ssid, const char **psk); + const char **ssid, const char **psk, int *freq); bool connman_technology_is_tethering_allowed(enum connman_service_type type); diff --git a/plugins/iwd.c b/plugins/iwd.c index 1c46c649..b0e17a4d 100644 --- a/plugins/iwd.c +++ b/plugins/iwd.c @@ -822,8 +822,9 @@ static int cm_tech_tethering(struct connman_technology *technology, int err = 0, res; const char *ssid; const char *psk; + int freq; - connman_technology_get_wifi_tethering(technology, &ssid, &psk); + connman_technology_get_wifi_tethering(technology, &ssid, &psk, &freq); g_hash_table_iter_init(&iter, devices); diff --git a/plugins/neard.c b/plugins/neard.c index 051978e9..caaea853 100644 --- a/plugins/neard.c +++ b/plugins/neard.c @@ -223,9 +223,9 @@ static DBusMessage *create_request_oob_reply(DBusMessage *message) DBusMessageIter dict; const char *ssid, *psk; uint8_t *tlv_msg; - int length; + int length, freq; - if (!connman_technology_get_wifi_tethering(NULL, &ssid, &psk)) + if (!connman_technology_get_wifi_tethering(NULL, &ssid, &psk, &freq)) return get_reply_on_error(message, ENOTSUP); tlv_msg = encode_to_tlv(ssid, psk, &length); diff --git a/plugins/wifi.c b/plugins/wifi.c index de5356bf..e947b169 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -3337,6 +3337,7 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology { GSupplicantSSID *ap; const char *ssid, *passphrase; + int freq; bool ret; ap = g_try_malloc0(sizeof(GSupplicantSSID)); @@ -3344,7 +3345,8 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology return NULL; ret = connman_technology_get_wifi_tethering(technology, - &ssid, &passphrase); + &ssid, &passphrase, + &freq); if (ret == false) return NULL; @@ -3352,7 +3354,10 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology ap->ssid = ssid; ap->ssid_len = strlen(ssid); ap->scan_ssid = 0; - ap->freq = 2412; + if (freq) + ap->freq = freq; + else + ap->freq = 2412; if (!passphrase || strlen(passphrase) == 0) { ap->security = G_SUPPLICANT_SECURITY_NONE; diff --git a/src/technology.c b/src/technology.c index 8548f6d4..97419150 100644 --- a/src/technology.c +++ b/src/technology.c @@ -66,6 +66,7 @@ struct connman_technology { */ char *tethering_ident; char *tethering_passphrase; + int tethering_freq; bool enable_persistent; /* Save the tech state */ @@ -192,6 +193,13 @@ static void technology_save(struct connman_technology *technology) g_free(enc); } + if (technology->tethering_freq == 0) + technology->tethering_freq = 2412; + + g_key_file_set_integer(keyfile, identifier, + "Tethering.Freq", + technology->tethering_freq); + done: g_free(identifier); @@ -356,7 +364,8 @@ enum connman_service_type connman_technology_get_type } bool connman_technology_get_wifi_tethering(const struct connman_technology *technology, - const char **ssid, const char **psk) + const char **ssid, const char **psk, + int *freq) { if (!ssid || !psk) return false; @@ -375,6 +384,7 @@ bool connman_technology_get_wifi_tethering(const struct connman_technology *tech *ssid = technology->tethering_ident; *psk = technology->tethering_passphrase; + *freq = technology->tethering_freq; return true; } @@ -443,6 +453,10 @@ static void technology_load(struct connman_technology *technology) identifier, "Tethering.Passphrase", NULL); if (enc) technology->tethering_passphrase = g_strcompress(enc); + + technology->tethering_freq = g_key_file_get_integer(keyfile, + identifier, "Tethering.Freq", NULL); + done: g_free(identifier); @@ -554,6 +568,10 @@ static void append_properties(DBusMessageIter *iter, DBUS_TYPE_STRING, &technology->tethering_passphrase); + connman_dbus_dict_append_basic(&dict, "TetheringFreq", + DBUS_TYPE_INT32, + &technology->tethering_freq); + connman_dbus_dict_close(iter, &dict); } @@ -968,6 +986,27 @@ static DBusMessage *set_property(DBusConnection *conn, DBUS_TYPE_STRING, &technology->tethering_passphrase); } + } else if (g_str_equal(name, "TetheringFreq")) { + dbus_int32_t freq; + + if (type != DBUS_TYPE_INT32) + return __connman_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&value, &freq); + + if (technology->type != CONNMAN_SERVICE_TYPE_WIFI) + return __connman_error_not_supported(msg); + + if (freq >= 0) { + technology->tethering_freq = freq; + technology_save(technology); + + connman_dbus_property_changed_basic(technology->path, + CONNMAN_TECHNOLOGY_INTERFACE, + "TetheringFreq", + DBUS_TYPE_INT32, + &technology->tethering_freq); + } } else if (g_str_equal(name, "Powered")) { dbus_bool_t enable; |