Updated connman to version 1.35
[platform/upstream/connman.git] / src / main.c
old mode 100644 (file)
new mode 100755 (executable)
index b78a046..4bc2266
@@ -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>
@@ -79,6 +81,10 @@ static struct {
        bool enable_6to4;
        char *vendor_class_id;
        bool enable_online_check;
+#if defined TIZEN_EXT
+       char **cellular_interfaces;
+       bool tizen_tv_extension;
+#endif
 } connman_settings  = {
        .bg_scan = true,
        .pref_timeservers = NULL,
@@ -96,6 +102,10 @@ static struct {
        .enable_6to4 = false,
        .vendor_class_id = NULL,
        .enable_online_check = true,
+#if defined TIZEN_EXT
+       .cellular_interfaces = NULL,
+       .tizen_tv_extension = false,
+#endif
 };
 
 #define CONF_BG_SCAN                    "BackgroundScanning"
@@ -114,6 +124,10 @@ static struct {
 #define CONF_ENABLE_6TO4                "Enable6to4"
 #define CONF_VENDOR_CLASS_ID            "VendorClassID"
 #define CONF_ENABLE_ONLINE_CHECK        "EnableOnlineCheck"
+#if defined TIZEN_EXT
+#define CONF_CELLULAR_INTERFACE         "NetworkCellularInterfaceList"
+#define CONF_TIZEN_TV_EXT              "TizenTVExtension"
+#endif
 
 static const char *supported_options[] = {
        CONF_BG_SCAN,
@@ -130,8 +144,11 @@ static const char *supported_options[] = {
        CONF_TETHERING_TECHNOLOGIES,
        CONF_PERSISTENT_TETHERING_MODE,
        CONF_ENABLE_6TO4,
-       CONF_VENDOR_CLASS_ID,
        CONF_ENABLE_ONLINE_CHECK,
+#if defined TIZEN_EXT
+       CONF_CELLULAR_INTERFACE,
+       CONF_TIZEN_TV_EXT,
+#endif
        NULL
 };
 
@@ -246,6 +263,46 @@ 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;
+       bool boolean;
+       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);
+
+       boolean = __connman_config_get_bool(config, "General",
+                       CONF_TIZEN_TV_EXT, &error);
+       if (!error)
+               connman_settings.tizen_tv_extension = boolean;
+
+       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;
@@ -408,12 +465,19 @@ static void parse_config(GKeyFile *config)
        }
 
        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);
@@ -632,6 +696,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;
 }
 
@@ -768,8 +837,10 @@ int main(int argc, char *argv[])
        __connman_dhcpv6_init();
        __connman_wpad_init();
        __connman_wispr_init();
+#if !defined TIZEN_EXT
        __connman_rfkill_init();
        __connman_machine_init();
+#endif
 
        g_free(option_config);
        g_free(option_device);
@@ -781,8 +852,10 @@ int main(int argc, char *argv[])
 
        g_source_remove(signal);
 
+#if !defined TIZEN_EXT
        __connman_machine_cleanup();
        __connman_rfkill_cleanup();
+#endif
        __connman_wispr_cleanup();
        __connman_wpad_cleanup();
        __connman_dhcpv6_cleanup();