Imported Upstream version 1.35
[platform/upstream/connman.git] / src / main.c
index 1c17991..b78a046 100644 (file)
@@ -57,6 +57,8 @@ static char *default_blacklist[] = {
        "vboxnet",
        "virbr",
        "ifb",
+       "ve-",
+       "vb-",
        NULL
 };
 
@@ -65,6 +67,7 @@ static struct {
        char **pref_timeservers;
        unsigned int *auto_connect;
        unsigned int *preferred_techs;
+       unsigned int *always_connected_techs;
        char **fallback_nameservers;
        unsigned int timeout_inputreq;
        unsigned int timeout_browserlaunch;
@@ -73,11 +76,15 @@ static struct {
        bool single_tech;
        char **tethering_technologies;
        bool persistent_tethering_mode;
+       bool enable_6to4;
+       char *vendor_class_id;
+       bool enable_online_check;
 } connman_settings  = {
        .bg_scan = true,
        .pref_timeservers = NULL,
        .auto_connect = NULL,
        .preferred_techs = NULL,
+       .always_connected_techs = NULL,
        .fallback_nameservers = NULL,
        .timeout_inputreq = DEFAULT_INPUT_REQUEST_TIMEOUT,
        .timeout_browserlaunch = DEFAULT_BROWSER_LAUNCH_TIMEOUT,
@@ -86,11 +93,15 @@ static struct {
        .single_tech = false,
        .tethering_technologies = NULL,
        .persistent_tethering_mode = false,
+       .enable_6to4 = false,
+       .vendor_class_id = NULL,
+       .enable_online_check = true,
 };
 
 #define CONF_BG_SCAN                    "BackgroundScanning"
 #define CONF_PREF_TIMESERVERS           "FallbackTimeservers"
 #define CONF_AUTO_CONNECT               "DefaultAutoConnectTechnologies"
+#define CONF_ALWAYS_CONNECTED_TECHS     "AlwaysConnectedTechnologies"
 #define CONF_PREFERRED_TECHS            "PreferredTechnologies"
 #define CONF_FALLBACK_NAMESERVERS       "FallbackNameservers"
 #define CONF_TIMEOUT_INPUTREQ           "InputRequestTimeout"
@@ -100,11 +111,15 @@ static struct {
 #define CONF_SINGLE_TECH                "SingleConnectedTechnology"
 #define CONF_TETHERING_TECHNOLOGIES      "TetheringTechnologies"
 #define CONF_PERSISTENT_TETHERING_MODE  "PersistentTetheringMode"
+#define CONF_ENABLE_6TO4                "Enable6to4"
+#define CONF_VENDOR_CLASS_ID            "VendorClassID"
+#define CONF_ENABLE_ONLINE_CHECK        "EnableOnlineCheck"
 
 static const char *supported_options[] = {
        CONF_BG_SCAN,
        CONF_PREF_TIMESERVERS,
        CONF_AUTO_CONNECT,
+       CONF_ALWAYS_CONNECTED_TECHS,
        CONF_PREFERRED_TECHS,
        CONF_FALLBACK_NAMESERVERS,
        CONF_TIMEOUT_INPUTREQ,
@@ -114,6 +129,9 @@ static const char *supported_options[] = {
        CONF_SINGLE_TECH,
        CONF_TETHERING_TECHNOLOGIES,
        CONF_PERSISTENT_TETHERING_MODE,
+       CONF_ENABLE_6TO4,
+       CONF_VENDOR_CLASS_ID,
+       CONF_ENABLE_ONLINE_CHECK,
        NULL
 };
 
@@ -236,6 +254,7 @@ static void parse_config(GKeyFile *config)
        char **interfaces;
        char **str_list;
        char **tethering;
+        char *vendor_class_id;
        gsize len;
        int timeout;
 
@@ -289,6 +308,17 @@ static void parse_config(GKeyFile *config)
        g_clear_error(&error);
 
        str_list = __connman_config_get_string_list(config, "General",
+                       CONF_ALWAYS_CONNECTED_TECHS, &len, &error);
+
+       if (!error)
+               connman_settings.always_connected_techs =
+                       parse_service_types(str_list, len);
+
+       g_strfreev(str_list);
+
+       g_clear_error(&error);
+
+       str_list = __connman_config_get_string_list(config, "General",
                        CONF_FALLBACK_NAMESERVERS, &len, &error);
 
        if (!error)
@@ -354,6 +384,30 @@ static void parse_config(GKeyFile *config)
                connman_settings.persistent_tethering_mode = boolean;
 
        g_clear_error(&error);
+
+       boolean = __connman_config_get_bool(config, "General",
+                                       CONF_ENABLE_6TO4, &error);
+       if (!error)
+               connman_settings.enable_6to4 = boolean;
+
+       g_clear_error(&error);
+
+       vendor_class_id = __connman_config_get_string(config, "General",
+                                       CONF_VENDOR_CLASS_ID, &error);
+       if (!error)
+               connman_settings.vendor_class_id = vendor_class_id;
+
+       g_clear_error(&error);
+
+       boolean = __connman_config_get_bool(config, "General",
+                                       CONF_ENABLE_ONLINE_CHECK, &error);
+       if (!error) {
+               connman_settings.enable_online_check = boolean;
+               if (!boolean)
+                       connman_info("Online check disabled by main config.");
+       }
+
+       g_clear_error(&error);
 }
 
 static int config_init(const char *file)
@@ -463,10 +517,34 @@ static gboolean option_version = FALSE;
 static bool parse_debug(const char *key, const char *value,
                                        gpointer user_data, GError **error)
 {
-       if (value)
-               option_debug = g_strdup(value);
-       else
+       if (value) {
+               if (option_debug) {
+                       char *prev = option_debug;
+
+                       option_debug = g_strconcat(prev, ",", value, NULL);
+                       g_free(prev);
+               } else {
+                       option_debug = g_strdup(value);
+               }
+       } else {
+               g_free(option_debug);
                option_debug = g_strdup("*");
+       }
+
+       return true;
+}
+
+static bool parse_noplugin(const char *key, const char *value,
+                                       gpointer user_data, GError **error)
+{
+       if (option_noplugin) {
+               char *prev = option_noplugin;
+
+               option_noplugin = g_strconcat(prev, ",", value, NULL);
+               g_free(prev);
+       } else {
+               option_noplugin = g_strdup(value);
+       }
 
        return true;
 }
@@ -484,7 +562,7 @@ static GOptionEntry options[] = {
                        "Specify networking interface to ignore", "DEV" },
        { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
                                "Specify plugins to load", "NAME,..." },
-       { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
+       { "noplugin", 'P', 0, G_OPTION_ARG_CALLBACK, &parse_noplugin,
                                "Specify plugins not to load", "NAME,..." },
        { "wifi", 'W', 0, G_OPTION_ARG_STRING, &option_wifi,
                                "Specify driver for WiFi/Supplicant", "NAME" },
@@ -504,6 +582,9 @@ static GOptionEntry options[] = {
 
 const char *connman_option_get_string(const char *key)
 {
+       if (g_str_equal(key, CONF_VENDOR_CLASS_ID))
+               return connman_settings.vendor_class_id;
+
        if (g_strcmp0(key, "wifi") == 0) {
                if (!option_wifi)
                        return "nl80211,wext";
@@ -528,6 +609,12 @@ bool connman_setting_get_bool(const char *key)
        if (g_str_equal(key, CONF_PERSISTENT_TETHERING_MODE))
                return connman_settings.persistent_tethering_mode;
 
+       if (g_str_equal(key, CONF_ENABLE_6TO4))
+               return connman_settings.enable_6to4;
+
+       if (g_str_equal(key, CONF_ENABLE_ONLINE_CHECK))
+               return connman_settings.enable_online_check;
+
        return false;
 }
 
@@ -556,6 +643,9 @@ unsigned int *connman_setting_get_uint_list(const char *key)
        if (g_str_equal(key, CONF_PREFERRED_TECHS))
                return connman_settings.preferred_techs;
 
+       if (g_str_equal(key, CONF_ALWAYS_CONNECTED_TECHS))
+               return connman_settings.always_connected_techs;
+
        return NULL;
 }
 
@@ -653,7 +743,6 @@ int main(int argc, char *argv[])
        __connman_device_init(option_device, option_nodevice);
 
        __connman_ippool_init();
-       __connman_iptables_init();
        __connman_firewall_init();
        __connman_nat_init();
        __connman_tethering_init();
@@ -662,7 +751,6 @@ int main(int argc, char *argv[])
        __connman_stats_init();
        __connman_clock_init();
 
-       __connman_resolver_init(option_dnsproxy);
        __connman_ipconfig_init();
        __connman_rtnl_init();
        __connman_task_init();
@@ -674,6 +762,7 @@ int main(int argc, char *argv[])
 
        __connman_plugin_init(option_plugin, option_noplugin);
 
+       __connman_resolver_init(option_dnsproxy);
        __connman_rtnl_start();
        __connman_dhcp_init();
        __connman_dhcpv6_init();
@@ -716,7 +805,6 @@ int main(int argc, char *argv[])
        __connman_tethering_cleanup();
        __connman_nat_cleanup();
        __connman_firewall_cleanup();
-       __connman_iptables_cleanup();
        __connman_peer_service_cleanup();
        __connman_peer_cleanup();
        __connman_ippool_cleanup();