In order not to overload ConnMan's main.conf with wifi plugin specific
settings (aka wpa_supplicant's settings...), let's have a quick
dedicated config file. Currently the 2 supported settings are used for
P2P and thus are not mandatory to be set, thus ignoring any errors
related to parsing this file to make it simple.
---
plugins/wifi.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 1c7e810..32e41cc 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -58,6 +58,9 @@
#include <gsupplicant/gsupplicant.h>
+#define CONF_FILE "wifi.conf"
+#define WIFI_CONFIG_FILE CONFIGDIR "/" CONF_FILE
+
#define CLEANUP_TIMEOUT 8 /* in seconds */
#define INACTIVE_TIMEOUT 12 /* in seconds */
#define FAVORITE_MAXIMUM_RETRIES 2
@@ -70,6 +73,17 @@
#define P2P_LISTEN_PERIOD 500
#define P2P_LISTEN_INTERVAL 2000
+static struct {
+ char *primary_dev_type;
+ char *secondary_dev_types;
+} wifi_settings = {
+ .primary_dev_type = NULL,
+ .secondary_dev_types = NULL,
+};
+
+#define CONF_PRIMARY_DEV_TYPE "PrimaryDeviceType"
+#define CONF_SECONDARY_DEV_TYPES "SecondaryDeviceTypes"
+
static struct connman_technology *wifi_technology = NULL;
static struct connman_technology *p2p_technology = NULL;
@@ -2453,7 +2467,8 @@ static void p2p_support(GSupplicantInterface *interface)
hostname = "ConnMan";
g_supplicant_interface_set_p2p_device_config(interface,
- hostname, NULL, NULL);
+ hostname, wifi_settings.primary_dev_type,
+ wifi_settings.secondary_dev_types);
connman_peer_driver_register(&peer_driver);
}
@@ -3050,6 +3065,38 @@ static struct connman_technology_driver tech_driver = {
.set_regdom = tech_set_regdom,
};
+static void load_wifi_settings(void)
+{
+ GKeyFile *keyfile;
+ char *str;
+
+ keyfile = g_key_file_new();
+
+ if (!g_key_file_load_from_file(keyfile, WIFI_CONFIG_FILE, 0, NULL))
+ goto out;
+
+ str = g_key_file_get_string(keyfile, "General",
+ CONF_PRIMARY_DEV_TYPE, NULL);
+ if (str)
+ wifi_settings.primary_dev_type = g_strchomp(str);
+
+ str = g_key_file_get_string(keyfile, "General",
+ CONF_SECONDARY_DEV_TYPES, NULL);
+ if (str)
+ wifi_settings.secondary_dev_types = g_strchomp(str);
+out:
+ g_key_file_free(keyfile);
+}
+
+static void unload_wifi_settings(void)
+{
+ g_free(wifi_settings.primary_dev_type);
+ wifi_settings.primary_dev_type = NULL;
+
+ g_free(wifi_settings.secondary_dev_types);
+ wifi_settings.secondary_dev_types = NULL;
+}
+
static int wifi_init(void)
{
int err;
@@ -3071,6 +3118,8 @@ static int wifi_init(void)
return err;
}
+ load_wifi_settings();
+
return 0;
}
@@ -3083,6 +3132,8 @@ static void wifi_exit(void)
g_supplicant_unregister(&callbacks);
connman_network_driver_unregister(&network_driver);
+
+ unload_wifi_settings();
}
CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
--
1.8.5.5
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman