[SPIN] Fix the connman bugs.
[platform/upstream/connman.git] / src / main.c
old mode 100644 (file)
new mode 100755 (executable)
index 4f635de..2d91c2f
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/signalfd.h>
+#include <sys/types.h>
+#include <sys/resource.h>
 #include <getopt.h>
 #include <sys/stat.h>
 #include <net/if.h>
@@ -73,6 +75,10 @@ static struct {
        bool single_tech;
        char **tethering_technologies;
        bool persistent_tethering_mode;
+       bool enable_6to4;
+#if defined TIZEN_EXT
+       char **cellular_interfaces;
+#endif
 } connman_settings  = {
        .bg_scan = true,
        .pref_timeservers = NULL,
@@ -86,6 +92,10 @@ static struct {
        .single_tech = false,
        .tethering_technologies = NULL,
        .persistent_tethering_mode = false,
+       .enable_6to4 = false,
+#if defined TIZEN_EXT
+       .cellular_interfaces = NULL,
+#endif
 };
 
 #define CONF_BG_SCAN                    "BackgroundScanning"
@@ -100,6 +110,10 @@ static struct {
 #define CONF_SINGLE_TECH                "SingleConnectedTechnology"
 #define CONF_TETHERING_TECHNOLOGIES      "TetheringTechnologies"
 #define CONF_PERSISTENT_TETHERING_MODE  "PersistentTetheringMode"
+#define CONF_ENABLE_6TO4                "Enable6to4"
+#if defined TIZEN_EXT
+#define CONF_CELLULAR_INTERFACE         "NetworkCellularInterfaceList"
+#endif
 
 static const char *supported_options[] = {
        CONF_BG_SCAN,
@@ -114,6 +128,10 @@ static const char *supported_options[] = {
        CONF_SINGLE_TECH,
        CONF_TETHERING_TECHNOLOGIES,
        CONF_PERSISTENT_TETHERING_MODE,
+       CONF_ENABLE_6TO4,
+#if defined TIZEN_EXT
+       CONF_CELLULAR_INTERFACE,
+#endif
        NULL
 };
 
@@ -228,6 +246,38 @@ static void check_config(GKeyFile *config)
        g_strfreev(keys);
 }
 
+#if defined TIZEN_EXT
+static void check_Tizen_configuration(GKeyFile *config)
+{
+       GError *error = NULL;
+       char **cellular_interfaces;
+       gsize len;
+
+       cellular_interfaces = g_key_file_get_string_list(config, "General",
+                       CONF_CELLULAR_INTERFACE, &len, &error);
+
+       if (error == NULL)
+               connman_settings.cellular_interfaces = cellular_interfaces;
+
+       g_clear_error(&error);
+}
+
+static void set_nofile_inc(void)
+{
+       int err;
+       struct rlimit rlim;
+
+       rlim.rlim_cur = 8192;
+       rlim.rlim_max = 8192;
+
+       err = setrlimit(RLIMIT_NOFILE, &rlim);
+       if (err)
+               DBG("fail to increase FILENO err(%d)", err);
+
+       return;
+}
+#endif
+
 static void parse_config(GKeyFile *config)
 {
        GError *error = NULL;
@@ -354,12 +404,26 @@ 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);
+
+#if defined TIZEN_EXT
+       check_Tizen_configuration(config);
+#endif
 }
 
 static int config_init(const char *file)
 {
        GKeyFile *config;
 
+#if defined TIZEN_EXT
+       set_nofile_inc();
+#endif
        config = load_config(file);
        check_config(config);
        parse_config(config);
@@ -528,6 +592,9 @@ 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;
+
        return false;
 }
 
@@ -545,6 +612,11 @@ char **connman_setting_get_string_list(const char *key)
        if (g_str_equal(key, CONF_TETHERING_TECHNOLOGIES))
                return connman_settings.tethering_technologies;
 
+#if defined TIZEN_EXT
+       if (g_str_equal(key, CONF_CELLULAR_INTERFACE))
+               return connman_settings.cellular_interfaces;
+#endif
+
        return NULL;
 }
 
@@ -639,11 +711,13 @@ int main(int argc, char *argv[])
        else
                config_init(option_config);
 
+       __connman_util_init();
        __connman_inotify_init();
        __connman_technology_init();
        __connman_notifier_init();
        __connman_agent_init();
        __connman_service_init();
+       __connman_peer_service_init();
        __connman_peer_init();
        __connman_provider_init();
        __connman_network_init();
@@ -667,7 +741,9 @@ int main(int argc, char *argv[])
        __connman_proxy_init();
        __connman_detect_init();
        __connman_session_init();
+#if !defined TIZEN_EXT || defined TIZEN_CONNMAN_NTP
        __connman_timeserver_init();
+#endif
        __connman_connection_init();
 
        __connman_plugin_init(option_plugin, option_noplugin);
@@ -678,6 +754,7 @@ int main(int argc, char *argv[])
        __connman_wpad_init();
        __connman_wispr_init();
        __connman_rfkill_init();
+       __connman_machine_init();
 
        g_free(option_config);
        g_free(option_device);
@@ -689,6 +766,7 @@ int main(int argc, char *argv[])
 
        g_source_remove(signal);
 
+       __connman_machine_cleanup();
        __connman_rfkill_cleanup();
        __connman_wispr_cleanup();
        __connman_wpad_cleanup();
@@ -697,7 +775,9 @@ int main(int argc, char *argv[])
        __connman_plugin_cleanup();
        __connman_provider_cleanup();
        __connman_connection_cleanup();
+#if !defined TIZEN_EXT || defined TIZEN_CONNMAN_NTP
        __connman_timeserver_cleanup();
+#endif
        __connman_detect_cleanup();
        __connman_proxy_cleanup();
        __connman_task_cleanup();
@@ -713,18 +793,20 @@ int main(int argc, char *argv[])
        __connman_nat_cleanup();
        __connman_firewall_cleanup();
        __connman_iptables_cleanup();
+       __connman_peer_service_cleanup();
+       __connman_peer_cleanup();
        __connman_ippool_cleanup();
        __connman_device_cleanup();
        __connman_network_cleanup();
        __connman_dhcp_cleanup();
        __connman_service_cleanup();
-       __connman_peer_cleanup();
        __connman_agent_cleanup();
        __connman_ipconfig_cleanup();
        __connman_notifier_cleanup();
        __connman_technology_cleanup();
        __connman_inotify_cleanup();
 
+       __connman_util_cleanup();
        __connman_dbus_cleanup();
 
        __connman_log_cleanup(option_backtrace);
@@ -743,6 +825,7 @@ int main(int argc, char *argv[])
        g_strfreev(connman_settings.tethering_technologies);
 
        g_free(option_debug);
+       g_free(option_wifi);
 
        return 0;
 }