#include <gdbus.h>
#include <ctype.h>
#include <stdint.h>
-#include <pwd.h>
-#include <utmpx.h>
#include <connman/storage.h>
#include <connman/setting.h>
#include <connman/agent.h>
+#include "src/shared/util.h"
+
#include "connman.h"
#define CONNECT_TIMEOUT 120
-#define USER_ROOT 0
-#define USER_NONE (uid_t)-1
-
#if defined TIZEN_EXT
#define WIFI_BSSID_STR_LEN 18
+#define MAX_WIFI_PROFILES 200
+
+#define FREQ_RANGE_24GHZ_CHANNEL_1 2412
+#define FREQ_RANGE_24GHZ_CHANNEL_14 2484
+#define FREQ_RANGE_5GHZ_CHANNEL_32 5160
+#define FREQ_RANGE_5GHZ_CHANNEL_165 5825
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#endif
+#define VPN_AUTOCONNECT_TIMEOUT_DEFAULT 1
+#define VPN_AUTOCONNECT_TIMEOUT_STEP 30
+#define VPN_AUTOCONNECT_TIMEOUT_ATTEMPTS_THRESHOLD 270
static DBusConnection *connection = NULL;
static GList *service_list = NULL;
static GHashTable *service_hash = NULL;
static GSList *counter_list = NULL;
-static unsigned int autoconnect_timeout = 0;
-static unsigned int vpn_autoconnect_timeout = 0;
+static unsigned int autoconnect_id = 0;
+static unsigned int vpn_autoconnect_id = 0;
static struct connman_service *current_default = NULL;
static bool services_dirty = false;
+#if defined TIZEN_EXT
+static bool auto_connect_mode = TRUE;
+
+struct saved_profiles {
+ GTimeVal modified;
+ gchar *profile_name;
+};
+
+static unsigned char invalid_bssid[WIFI_BSSID_LEN_MAX] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+#endif
+
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+enum connman_ins_preferred_freq {
+ CONNMAN_INS_PREFERRED_FREQ_UNKNOWN,
+ CONNMAN_INS_PREFERRED_FREQ_24GHZ,
+ CONNMAN_INS_PREFERRED_FREQ_5GHZ,
+};
+
+struct connman_ins_settings {
+ bool last_user_selection;
+ unsigned int last_user_selection_time;
+ unsigned int last_user_selection_score;
+ bool last_connected;
+ unsigned int last_connected_score;
+ enum connman_ins_preferred_freq preferred_freq;
+ unsigned int preferred_freq_score;
+ unsigned int security_priority[CONNMAN_SERVICE_SECURITY_MAX];
+ unsigned int security_priority_count;
+ unsigned int security_priority_score;
+ bool signal;
+ bool internet;
+ unsigned int internet_score;
+ int signal_level3_5ghz;
+ int signal_level3_24ghz;
+};
+
+static struct connman_ins_settings ins_settings;
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
struct connman_stats {
bool valid;
bool enabled;
struct connman_stats stats_roaming;
};
-struct connman_service_user {
- uid_t favorite_user;
- uid_t current_user;
-};
-
struct connman_service {
int refcount;
char *identifier;
bool hidden;
bool ignore;
bool autoconnect;
- GTimeVal modified;
+ struct timeval modified;
unsigned int order;
char *name;
char *passphrase;
bool roaming;
- bool request_passphrase_input;
- struct connman_service_user user;
struct connman_ipconfig *ipconfig_ipv4;
struct connman_ipconfig *ipconfig_ipv6;
struct connman_network *network;
char **nameservers;
char **nameservers_config;
char **nameservers_auto;
+ int nameservers_timeout;
char **domains;
+ bool mdns;
+ bool mdns_config;
char *hostname;
char *domainname;
char **timeservers;
/* 802.1x settings from the config files */
char *eap;
char *identity;
+ char *anonymous_identity;
char *agent_identity;
char *ca_cert_file;
+ char *subject_match;
+ char *altsubject_match;
+ char *domain_suffix_match;
+ char *domain_match;
char *client_cert_file;
char *private_key_file;
char *private_key_passphrase;
char **excludes;
char *pac;
bool wps;
- int online_check_count;
+ bool wps_advertizing;
+ guint online_timeout;
+ int online_check_interval_ipv4;
+ int online_check_interval_ipv6;
bool do_split_routing;
bool new_service;
bool hidden_service;
*/
char *keymgmt_type;
int disconnect_reason;
+ int assoc_status_code;
+ /*
+ * Only for EAP-FAST and EAP-PEAP in EAPoL.
+ */
+ char *phase1;
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ /*
+ * Only for EAP-FAST
+ */
+ char *pac_file;
#endif
-#ifdef TIZEN_EXT
+ /*
+ * Description: To indicate that disconnection triggered by user.
+ */
+ bool disconnection_requested;
+
enum connman_dnsconfig_method dns_config_method_ipv4;
enum connman_dnsconfig_method dns_config_method_ipv6;
#endif
+#if defined TIZEN_EXT
+ char *connector;
+ char *c_sign_key;
+ char *net_access_key;
+ unsigned char last_connected_bssid[WIFI_BSSID_LEN_MAX];
+ bool is_internet_connection;
+ int assoc_reject_count;
+#if defined TIZEN_EXT_INS
+ int score_last_user_selection;
+ int score_last_connected;
+ int score_frequency;
+ int score_security_priority;
+ int score_internet_connection;
+ int score_strength;
+#endif
+ int ins_score;
+#endif
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ /*
+ * To indicate use of EAP over Ethernet.
+ */
+ bool use_eapol;
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
};
static bool allow_property_changed(struct connman_service *service);
int index, enum connman_ipconfig_method method);
static struct connman_ipconfig *create_ip6config(struct connman_service *service,
int index);
-
+static void dns_changed(struct connman_service *service);
+static void vpn_auto_connect(void);
struct find_data {
const char *path;
};
#if defined TIZEN_EXT
+struct assoc_reject_data {
+ char *bssid;
+ GSList *reject_time_list;
+};
+
/*
* Public APIs to use user_pdn_connection_refcount
*/
return "gadget";
case CONNMAN_SERVICE_TYPE_P2P:
return "p2p";
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+ return "mesh";
+#endif
}
return NULL;
if (!strcmp(str, "psk"))
return CONNMAN_SERVICE_SECURITY_PSK;
- if (!strcmp(str, "ieee8021x"))
+ if (!strcmp(str, "ieee8021x") || !strcmp(str, "8021x"))
return CONNMAN_SERVICE_SECURITY_8021X;
- if (!strcmp(str, "none"))
+ if (!strcmp(str, "none") || !strcmp(str, "open"))
return CONNMAN_SERVICE_SECURITY_NONE;
if (!strcmp(str, "wep"))
return CONNMAN_SERVICE_SECURITY_WEP;
#if defined TIZEN_EXT
if (!strcmp(str, "rsn"))
return CONNMAN_SERVICE_SECURITY_RSN;
+ if (!strcmp(str, "sae"))
+ return CONNMAN_SERVICE_SECURITY_SAE;
+ if (!strcmp(str, "owe"))
+ return CONNMAN_SERVICE_SECURITY_OWE;
+ if (!strcmp(str, "dpp"))
+ return CONNMAN_SERVICE_SECURITY_DPP;
#endif
return CONNMAN_SERVICE_SECURITY_UNKNOWN;
return "psk";
case CONNMAN_SERVICE_SECURITY_RSN:
return "rsn";
+ case CONNMAN_SERVICE_SECURITY_SAE:
+ return "sae";
+ case CONNMAN_SERVICE_SECURITY_OWE:
+ return "owe";
+ case CONNMAN_SERVICE_SECURITY_DPP:
+ return "dpp";
#else
case CONNMAN_SERVICE_SECURITY_RSN:
return "psk";
return "login-failed";
case CONNMAN_SERVICE_ERROR_AUTH_FAILED:
return "auth-failed";
+#ifdef TIZEN_EXT
+ case CONNMAN_SERVICE_ERROR_ASSOC_FAILED:
+ return "assoc-failed";
+#endif
case CONNMAN_SERVICE_ERROR_INVALID_KEY:
return "invalid-key";
case CONNMAN_SERVICE_ERROR_BLOCKED:
}
#endif
-static bool
-connman_service_is_user_allowed(struct connman_service *service, uid_t uid)
+static void set_split_routing(struct connman_service *service, bool value)
{
- uid_t favorite_user = service->user.favorite_user;
- uid_t current_user = uid;
-
- DBG("Service favorite UID: %d, current UID: %d", favorite_user, current_user);
- if (favorite_user == USER_NONE || current_user == USER_ROOT)
- return true;
-
- if (favorite_user != current_user || current_user == USER_NONE) {
- DBG("Current user is not a favorite user to this service!");
- return false;
- }
-
- return true;
-}
-
-#if !defined TIZEN_EXT
-static GList *connman_service_get_login_users()
-{
- struct utmpx *utmp;
- struct passwd *pwd;
- GList *user_list = NULL;
-
- setutxent();
-
- while ((utmp = getutxent()) != NULL) {
- DBG("User Name: %s", utmp->ut_user);
-
- pwd = getpwnam(utmp->ut_user);
- if (pwd) {
- if (!g_list_find(user_list, GUINT_TO_POINTER(pwd->pw_uid)))
- user_list = g_list_append(user_list,
- GUINT_TO_POINTER(pwd->pw_uid));
-
- DBG("User Name: %s, UID: %d", utmp->ut_user, pwd->pw_uid);
- }
- }
-
- endutxent();
-
- return user_list;
-}
-#endif
-
-static bool is_service_owner_user_login(struct connman_service *service)
-{
-#if defined TIZEN_EXT
- return true;
-#else
- GList *list, *user_list;
- bool ret = false;
-
- /* Here we only care about wifi service */
- if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
- return true;
-
- DBG("service favorite user id is: %d", service->user.favorite_user);
-
- user_list = connman_service_get_login_users();
- if (user_list == NULL) {
- DBG("Can not get any logged in user info.");
- return true;
- }
-
- for (list = user_list; list; list = list->next) {
- uid_t uid = GPOINTER_TO_UINT(list->data);
-
- DBG("login user id is %d", uid);
-
- if (service->user.favorite_user == uid) {
- ret = true;
- break;
- }
- }
+ if (service->type != CONNMAN_SERVICE_TYPE_VPN)
+ return;
- g_list_free(user_list);
+ service->do_split_routing = value;
- return ret;
-#endif
+ if (service->do_split_routing)
+ service->order = 0;
+ else
+ service->order = 10;
}
int __connman_service_load_modifiable(struct connman_service *service)
case CONNMAN_SERVICE_TYPE_SYSTEM:
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
break;
case CONNMAN_SERVICE_TYPE_VPN:
- service->do_split_routing = g_key_file_get_boolean(keyfile,
- service->identifier, "SplitRouting", NULL);
+ set_split_routing(service, g_key_file_get_boolean(keyfile,
+ service->identifier,
+ "SplitRouting", NULL));
+
/* fall through */
case CONNMAN_SERVICE_TYPE_WIFI:
case CONNMAN_SERVICE_TYPE_GADGET:
str = g_key_file_get_string(keyfile,
service->identifier, "Modified", NULL);
if (str) {
- g_time_val_from_iso8601(str, &service->modified);
+ util_iso8601_to_timeval(str, &service->modified);
g_free(str);
}
return 0;
}
-static int service_load_passphrase(struct connman_service *service)
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+static void __connman_service_cleanup_8021x(struct connman_service *service)
+{
+ if (service == NULL)
+ return;
+
+ DBG("service %p ", service);
+
+ __connman_service_set_string(service, "EAP", NULL);
+ __connman_service_set_string(service, "Identity", NULL);
+ __connman_service_set_string(service, "Passphrase", NULL);
+ __connman_service_set_string(service, "AnonymousIdentity", NULL);
+ __connman_service_set_string(service, "CACertFile", NULL);
+ __connman_service_set_string(service, "ClientCertFile", NULL);
+ __connman_service_set_string(service, "PrivateKeyFile", NULL);
+ __connman_service_set_string(service, "PrivateKeyPassphrase", NULL);
+ __connman_service_set_string(service, "Phase1", NULL);
+ __connman_service_set_string(service, "Phase2", NULL);
+ __connman_service_set_string(service, "PacFile", NULL);
+}
+
+static int connman_service_set_eapol_property(struct connman_service *service,
+ DBusMessageIter *array)
+{
+ DBusMessageIter dict;
+ char *str = NULL;
+
+ __connman_service_cleanup_8021x(service);
+
+ if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+ return -EINVAL;
+
+ dbus_message_iter_recurse(array, &dict);
+
+ while(dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, value;
+ const char *key;
+ int type;
+
+ dbus_message_iter_recurse(&dict, &entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&entry, &key);
+ dbus_message_iter_next(&entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
+ return -EINVAL;
+
+ dbus_message_iter_recurse(&entry, &value);
+
+ type = dbus_message_iter_get_arg_type(&value);
+
+ if (g_str_equal(key, "UseEapol")) {
+ dbus_bool_t use_eapol;
+
+ if (type != DBUS_TYPE_BOOLEAN)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &use_eapol);
+ service->use_eapol = use_eapol;
+
+ } else if (g_str_equal(key, "EAP")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "EAP", str);
+
+ } else if (g_str_equal(key, "Identity")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "Identity", str);
+
+ } else if (g_str_equal(key, "AnonymousIdentity")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "AnonymousIdentity", str);
+
+ } else if (g_str_equal(key, "CACertFile")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "CACertFile", str);
+ } else if (g_str_equal(key, "ClientCertFile")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "ClientCertFile", str);
+ } else if (g_str_equal(key, "PrivateKeyFile")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "PrivateKeyFile", str);
+ } else if (g_str_equal(key, "PrivateKeyPassphrase")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "PrivateKeyPassphrase", str);
+ } else if (g_str_equal(key, "Phase2")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "Phase2", str);
+ } else if (g_str_equal(key, "Phase1")) {
+ int val;
+ char phase1[5] = {0,};
+
+ if (type != DBUS_TYPE_INT32)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &val);
+ sprintf(phase1, "%d", val);
+ __connman_service_set_string(service, "Phase1", phase1);
+ } else if (g_str_equal(key, "PacFile")) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ __connman_service_set_string(service, "PacFile", str);
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+
+ return 0;
+}
+#endif
+
+#if defined TIZEN_EXT
+static void save_assoc_reject(gpointer key, gpointer value, gpointer user_data)
+{
+ struct assoc_reject_data *assoc_rd = value;
+ GString *assoc_reject_str = user_data;
+ GSList *list;
+ char *val_str;
+
+ if (g_slist_length(assoc_rd->reject_time_list) < 1)
+ return;
+
+ for (list = assoc_rd->reject_time_list; list; list = list->next) {
+ time_t assoc_reject_time = GPOINTER_TO_INT(list->data);
+
+ val_str = g_strdup_printf("%s_%ld", assoc_rd->bssid, assoc_reject_time);
+
+ if (assoc_reject_str->len > 0)
+ g_string_append_printf(assoc_reject_str, " %s", val_str);
+ else
+ g_string_append(assoc_reject_str, val_str);
+
+ g_free(val_str);
+ }
+}
+
+static void count_assoc_reject(gpointer key, gpointer value, gpointer user_data)
+{
+ struct assoc_reject_data *assoc_data = value;
+ int *assoc_reject_count = user_data;
+
+ if (assoc_data)
+ *assoc_reject_count += g_slist_length(assoc_data->reject_time_list);
+}
+
+static bool update_assoc_reject(struct connman_service *service)
+{
+ GHashTable *assoc_reject_table;
+ int assoc_reject_count;
+
+ if (!service->network)
+ return false;
+
+ assoc_reject_table = connman_network_get_assoc_reject_table(service->network);
+ if (assoc_reject_table) {
+ assoc_reject_count = 0;
+ g_hash_table_foreach(assoc_reject_table, count_assoc_reject, &assoc_reject_count);
+#if defined TIZEN_EXT_INS
+ DBG("assoc reject count [%d -> %d]",
+ service->assoc_reject_count, assoc_reject_count);
+#endif
+ if (service->assoc_reject_count != assoc_reject_count) {
+ service->assoc_reject_count = assoc_reject_count;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static int service_ext_load(struct connman_service *service)
{
GKeyFile *keyfile;
- gchar *str;
+ GHashTable *reject_table;
+ char **reject_list;
+ gsize reject_len;
+ struct assoc_reject_data *reject_data;
+ char **bssid_time;
+ char *bssid;
+ time_t reject_time;
+ time_t curr_time;
+ time_t ref_time;
+ struct tm* ref_timeinfo;
+ int i;
+ int err = 0;
+
+ if (!simplified_log)
+ DBG("service %p", service);
+
+ if (!service->network)
+ return -EINVAL;
+
+ if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return -EINVAL;
keyfile = connman_storage_load_service(service->identifier);
if (!keyfile)
return -EIO;
- str = g_key_file_get_string(keyfile,
- service->identifier, "Passphrase", NULL);
- if (str)
- service->passphrase = str;
+ reject_table = connman_network_get_assoc_reject_table(service->network);
+
+ reject_list = g_key_file_get_string_list(keyfile,
+ service->identifier, "AssocReject", &reject_len, NULL);
+
+ if (!reject_list || reject_len == 0) {
+ g_strfreev(reject_list);
+ goto done;
+ }
+ /* Only events that occur within one hour are appened. */
+ curr_time = time(NULL);
+ ref_timeinfo = localtime(&curr_time);
+ ref_timeinfo->tm_hour -= 1;
+ ref_time = mktime(ref_timeinfo);
+
+ for (i = 0; reject_list[i]; i++) {
+ bssid_time = g_strsplit(reject_list[i], "_", 0);
+ if (!bssid_time) {
+ err = -ERANGE;
+ continue;
+ }
+
+ bssid = bssid_time[0];
+ reject_time = strtol(bssid_time[1], NULL, 10);
+
+ if (reject_time < ref_time) {
+ g_strfreev(bssid_time);
+ err = -ERANGE;
+ continue;
+ }
+
+ reject_data = g_hash_table_lookup(reject_table, bssid);
+ if (!reject_data) {
+ reject_data = g_try_new0(struct assoc_reject_data, 1);
+ if (!reject_data) {
+ g_strfreev(bssid_time);
+ err = -ERANGE;
+ continue;
+ }
+
+ reject_data->bssid = g_strdup(bssid);
+ g_hash_table_insert(reject_table, reject_data->bssid, reject_data);
+ }
+
+ reject_data->reject_time_list = g_slist_append(reject_data->reject_time_list,
+ GINT_TO_POINTER(reject_time));
+
+#if defined TIZEN_EXT_INS
+ DBG("assoc reject [%s_%ld]", bssid, reject_time);
+#endif
+
+ g_strfreev(bssid_time);
+ }
+
+ g_strfreev(reject_list);
+
+done:
g_key_file_free(keyfile);
+ return err;
+}
- return 0;
+static int service_ext_save(struct connman_service *service)
+{
+ GKeyFile *keyfile;
+ GHashTable *reject_table;
+ GString *reject_str;
+ char **reject_list;
+ guint reject_len;
+ int err = 0;
+
+ DBG("service %p", service);
+
+ if (!service->network)
+ return -EINVAL;
+
+ if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return -EINVAL;
+
+ keyfile = g_key_file_new();
+ if (!keyfile)
+ return -EIO;
+
+ /* Last connected BSSID */
+ if (memcmp(service->last_connected_bssid, invalid_bssid, WIFI_BSSID_LEN_MAX)) {
+ char *identifier = service->identifier;
+ GString *bssid_str;
+ unsigned int i;
+
+ bssid_str = g_string_sized_new(MAC_ADDRESS_LENGTH);
+ if (!bssid_str) {
+ err = -ENOMEM;
+ goto next;
+ }
+
+ for (i = 0; i < WIFI_BSSID_LEN_MAX; i++) {
+ g_string_append_printf(bssid_str,
+ "%02x", service->last_connected_bssid[i]);
+ if (i < WIFI_BSSID_LEN_MAX - 1)
+ g_string_append(bssid_str, ":");
+ }
+
+ g_key_file_set_string(keyfile, identifier,
+ "LastConnectedBSSID", bssid_str->str);
+
+#if defined TIZEN_EXT_INS
+ DBG("last connected bssid[%s]", bssid_str->str);
+#endif
+
+ g_string_free(bssid_str, TRUE);
+ }
+
+next:
+
+ /* Assoc reject */
+ reject_table = connman_network_get_assoc_reject_table(service->network);
+ if (reject_table && g_hash_table_size(reject_table) > 0) {
+ reject_str = g_string_new(NULL);
+ if (!reject_str) {
+ err = -ENOMEM;
+ goto done;
+ }
+
+ g_hash_table_foreach(reject_table, save_assoc_reject, reject_str);
+
+ reject_list = g_strsplit_set(reject_str->str, " ", 0);
+ reject_len = g_strv_length(reject_list);
+
+ g_key_file_set_string_list(keyfile, service->identifier,
+ "AssocReject", (const gchar **)reject_list, reject_len);
+
+#if defined TIZEN_EXT_INS
+ DBG("assoc reject table [%d]", reject_len);
+#endif
+
+ g_strfreev(reject_list);
+ g_string_free(reject_str, TRUE);
+ } else {
+ g_key_file_remove_key(keyfile, service->identifier, "AssocReject", NULL);
+ }
+
+done:
+ __connman_storage_save_service(keyfile, service->identifier);
+
+ g_key_file_free(keyfile);
+ return err;
}
+#endif
static int service_load(struct connman_service *service)
{
bool autoconnect;
unsigned int ssid_len;
int err = 0;
-
+#if defined TIZEN_EXT
+ bool internet_connection;
+#endif
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ bool use_eapol;
+#endif
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("service %p", service);
keyfile = connman_storage_load_service(service->identifier);
case CONNMAN_SERVICE_TYPE_SYSTEM:
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
break;
case CONNMAN_SERVICE_TYPE_VPN:
- service->do_split_routing = g_key_file_get_boolean(keyfile,
- service->identifier, "SplitRouting", NULL);
+ set_split_routing(service, g_key_file_get_boolean(keyfile,
+ service->identifier,
+ "SplitRouting", NULL));
+
autoconnect = g_key_file_get_boolean(keyfile,
service->identifier, "AutoConnect", &error);
if (!error)
g_free(hex_ssid);
}
+
+#if defined TIZEN_EXT
+ /* Last connected BSSID */
+ if (service->network) {
+ gchar *bssid_str;
+ unsigned char last_connected_bssid[WIFI_BSSID_LEN_MAX];
+ char **str_list;
+ unsigned int i;
+
+ bssid_str = g_key_file_get_string(keyfile,
+ service->identifier, "LastConnectedBSSID", NULL);
+
+ if (bssid_str) {
+ str_list = g_strsplit(bssid_str, ":", 0);
+
+ if (str_list) {
+ for (i = 0; i < WIFI_BSSID_LEN_MAX; i++)
+ last_connected_bssid[i] = strtol(str_list[i], NULL, 16);
+
+ memcpy(service->last_connected_bssid,
+ last_connected_bssid, WIFI_BSSID_LEN_MAX);
+
+ connman_network_set_last_connected_bssid(service->network,
+ last_connected_bssid);
+
+ g_strfreev(str_list);
+ }
+
+ g_free(bssid_str);
+ }
+ }
+
+ /* Internet connection */
+ internet_connection = g_key_file_get_boolean(keyfile,
+ service->identifier, "InternetConnection", &error);
+ if (!error)
+ service->is_internet_connection = internet_connection;
+
+ g_clear_error(&error);
+#endif
/* fall through */
case CONNMAN_SERVICE_TYPE_GADGET:
if (!error)
service->autoconnect = autoconnect;
g_clear_error(&error);
+
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ use_eapol = g_key_file_get_boolean(keyfile,
+ service->identifier, "UseEapol", &error);
+ if (!error)
+ service->use_eapol = use_eapol;
+ g_clear_error(&error);
+#endif
break;
}
str = g_key_file_get_string(keyfile,
service->identifier, "Modified", NULL);
if (str) {
- g_time_val_from_iso8601(str, &service->modified);
+ util_iso8601_to_timeval(str, &service->modified);
g_free(str);
}
dns_method = g_key_file_get_string(keyfile, service->identifier,
"Nameservers.IPv4method", NULL);
- service->dns_config_method_ipv4 = __connman_dnsconfig_string2method(dns_method);
+ if (dns_method) {
+ service->dns_config_method_ipv4 = __connman_dnsconfig_string2method(dns_method);
+ g_free(dns_method);
+ }
dns_method = g_key_file_get_string(keyfile, service->identifier,
"Nameservers.IPv6method", NULL);
- service->dns_config_method_ipv6 = __connman_dnsconfig_string2method(dns_method);
+ if (dns_method) {
+ service->dns_config_method_ipv6 = __connman_dnsconfig_string2method(dns_method);
+ g_free(dns_method);
+ }
#endif
service->timeservers_config = g_key_file_get_string_list(keyfile,
service->pac = str;
}
+ service->mdns_config = g_key_file_get_boolean(keyfile,
+ service->identifier, "mDNS", NULL);
+
service->hidden_service = g_key_file_get_boolean(keyfile,
service->identifier, "Hidden", NULL);
#if defined TIZEN_EXT
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
- service->security == CONNMAN_SERVICE_SECURITY_8021X) {
+ if ((service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service->security == CONNMAN_SERVICE_SECURITY_8021X)
+#if defined TIZEN_EXT_EAP_ON_ETHERNET
+ || (service->type == CONNMAN_SERVICE_TYPE_ETHERNET && service->use_eapol)
+#endif
+ ) {
str = g_key_file_get_string(keyfile,
service->identifier, "EAP", NULL);
if (str != NULL) {
service->identity = str;
}
+#if defined TIZEN_EXT_EAP_ON_ETHERNET
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "AnonymousIdentity", NULL);
+ if (str != NULL) {
+ g_free(service->anonymous_identity);
+ service->anonymous_identity = str;
+ }
+#endif
str = g_key_file_get_string(keyfile,
service->identifier, "CACertFile", NULL);
if (str != NULL) {
g_free(service->private_key_passphrase);
service->private_key_passphrase = str;
}
+
+#if defined TIZEN_EXT_EAP_ON_ETHERNET
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "Phase1", NULL);
+ if (str != NULL) {
+ g_free(service->phase1);
+ service->phase1 = str;
+ }
+
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "PacFile", NULL);
+ if (str != NULL) {
+ g_free(service->pac_file);
+ service->pac_file = str;
+ }
+#endif
+ }
+#endif
+#if defined TIZEN_EXT
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service->security == CONNMAN_SERVICE_SECURITY_DPP) {
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "Connector", NULL);
+ if (str != NULL) {
+ g_free(service->connector);
+ service->connector = str;
+ }
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "CSignKey", NULL);
+ if (str != NULL) {
+ g_free(service->c_sign_key);
+ service->c_sign_key = str;
+ }
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "NetAccessKey", NULL);
+ if (str != NULL) {
+ g_free(service->net_access_key);
+ service->net_access_key = str;
+ }
}
#endif
- if (g_key_file_has_key(keyfile, service->identifier, "UID", NULL))
- service->user.favorite_user = g_key_file_get_integer(keyfile,
- service->identifier, "UID", NULL);
done:
g_key_file_free(keyfile);
if (service->new_service)
return -ESRCH;
- keyfile = __connman_storage_open_service(service->identifier);
+ keyfile = g_key_file_new();
if (!keyfile)
return -EIO;
case CONNMAN_SERVICE_TYPE_SYSTEM:
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
break;
case CONNMAN_SERVICE_TYPE_VPN:
g_key_file_set_boolean(keyfile, service->identifier,
if (service->network) {
const unsigned char *ssid;
unsigned int ssid_len = 0;
-
- if (service->user.favorite_user == USER_NONE)
- g_key_file_remove_key(keyfile, service->identifier,
- "UID", NULL);
- else
- g_key_file_set_integer(keyfile, service->identifier,
- "UID", service->user.favorite_user);
+#if defined TIZEN_EXT
+ GHashTable *assoc_reject_table;
+#endif
ssid = connman_network_get_blob(service->network,
"WiFi.SSID", &ssid_len);
freq = connman_network_get_frequency(service->network);
g_key_file_set_integer(keyfile, service->identifier,
"Frequency", freq);
+
+#if defined TIZEN_EXT
+ /* Last connected BSSID */
+ if (memcmp(service->last_connected_bssid, invalid_bssid, WIFI_BSSID_LEN_MAX)) {
+ char *identifier = service->identifier;
+ GString *bssid_str;
+ unsigned int i;
+
+ bssid_str = g_string_sized_new(18);
+ if (!bssid_str) {
+ err = -ENOMEM;
+ goto done;
+ }
+
+ for (i = 0; i < WIFI_BSSID_LEN_MAX; i++) {
+ g_string_append_printf(bssid_str,
+ "%02x", service->last_connected_bssid[i]);
+ if (i < WIFI_BSSID_LEN_MAX - 1)
+ g_string_append(bssid_str, ":");
+ }
+
+ g_key_file_set_string(keyfile, identifier,
+ "LastConnectedBSSID", bssid_str->str);
+
+#if defined TIZEN_EXT_INS
+ DBG("last connected bssid[%s]", bssid_str->str);
+#endif
+
+ g_string_free(bssid_str, TRUE);
+ }
+
+ /* Assoc reject */
+ assoc_reject_table = connman_network_get_assoc_reject_table(service->network);
+ if (assoc_reject_table && g_hash_table_size(assoc_reject_table) > 0) {
+ GString *assoc_reject_str;
+ char **assoc_reject_list;
+ guint assoc_reject_len;
+
+ assoc_reject_str = g_string_new(NULL);
+ if (!assoc_reject_str) {
+ err = -ENOMEM;
+ goto done;
+ }
+
+ g_hash_table_foreach(assoc_reject_table, save_assoc_reject, assoc_reject_str);
+
+ assoc_reject_list = g_strsplit_set(assoc_reject_str->str, " ", 0);
+ assoc_reject_len = g_strv_length(assoc_reject_list);
+
+ g_key_file_set_string_list(keyfile, service->identifier,
+ "AssocReject", (const gchar **)assoc_reject_list, assoc_reject_len);
+
+#if defined TIZEN_EXT_INS
+ DBG("assoc reject table [%d]", assoc_reject_len);
+#endif
+
+ g_strfreev(assoc_reject_list);
+ g_string_free(assoc_reject_str, TRUE);
+ } else
+ g_key_file_remove_key(keyfile, service->identifier, "AssocReject", NULL);
+
+ /* Internet connection */
+ g_key_file_set_boolean(keyfile, service->identifier,
+ "InternetConnection", service->is_internet_connection);
+#if defined TIZEN_EXT_INS
+ DBG("internet connection [%s]", service->is_internet_connection ? "true" : "false");
+#endif
+#endif
}
/* fall through */
g_key_file_set_boolean(keyfile, service->identifier,
"Favorite", service->favorite);
- g_key_file_remove_key(keyfile, service->identifier,
- "Failure", NULL);
-
/* fall through */
case CONNMAN_SERVICE_TYPE_ETHERNET:
if (service->favorite)
g_key_file_set_boolean(keyfile, service->identifier,
"AutoConnect", service->autoconnect);
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ g_key_file_set_boolean(keyfile, service->identifier,
+ "UseEapol", service->use_eapol);
+#endif
break;
}
- str = g_time_val_to_iso8601(&service->modified);
+ str = util_timeval_to_iso8601(&service->modified);
if (str) {
g_key_file_set_string(keyfile, service->identifier,
- "Modified", str);
+ "Modified", str);
g_free(str);
}
- if (service->user.current_user == service->user.favorite_user) {
- if (service->passphrase && strlen(service->passphrase) > 0)
- g_key_file_set_string(keyfile, service->identifier,
- "Passphrase", service->passphrase);
- else
- g_key_file_remove_key(keyfile, service->identifier,
- "Passphrase", NULL);
- }
+ if (service->passphrase && strlen(service->passphrase) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "Passphrase", service->passphrase);
if (service->ipconfig_ipv4)
__connman_ipconfig_save(service->ipconfig_ipv4, keyfile,
- service->identifier, "IPv4.");
+ service->identifier, "IPv4.");
if (service->ipconfig_ipv6)
__connman_ipconfig_save(service->ipconfig_ipv6, keyfile,
- service->identifier, "IPv6.");
+ service->identifier, "IPv6.");
if (service->nameservers_config) {
guint len = g_strv_length(service->nameservers_config);
g_key_file_set_string_list(keyfile, service->identifier,
- "Nameservers",
+ "Nameservers",
(const gchar **) service->nameservers_config, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Nameservers", NULL);
+ }
#if defined TIZEN_EXT
if(service->dns_config_method_ipv4 != 0) {
guint len = g_strv_length(service->timeservers_config);
g_key_file_set_string_list(keyfile, service->identifier,
- "Timeservers",
+ "Timeservers",
(const gchar **) service->timeservers_config, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Timeservers", NULL);
+ }
if (service->domains) {
guint len = g_strv_length(service->domains);
g_key_file_set_string_list(keyfile, service->identifier,
- "Domains",
+ "Domains",
(const gchar **) service->domains, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Domains", NULL);
+ }
cst_str = proxymethod2string(service->proxy_config);
if (cst_str)
g_key_file_set_string_list(keyfile, service->identifier,
"Proxy.Servers",
(const gchar **) service->proxies, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Proxy.Servers", NULL);
+ }
if (service->excludes) {
guint len = g_strv_length(service->excludes);
g_key_file_set_string_list(keyfile, service->identifier,
"Proxy.Excludes",
(const gchar **) service->excludes, len);
- } else
- g_key_file_remove_key(keyfile, service->identifier,
- "Proxy.Excludes", NULL);
+ }
if (service->pac && strlen(service->pac) > 0)
g_key_file_set_string(keyfile, service->identifier,
- "Proxy.URL", service->pac);
- else
- g_key_file_remove_key(keyfile, service->identifier,
- "Proxy.URL", NULL);
+ "Proxy.URL", service->pac);
+
+ if (service->mdns_config)
+ g_key_file_set_boolean(keyfile, service->identifier,
+ "mDNS", TRUE);
if (service->hidden_service)
g_key_file_set_boolean(keyfile, service->identifier, "Hidden",
"Config.ident", service->config_entry);
#if defined TIZEN_EXT
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
- service->security == CONNMAN_SERVICE_SECURITY_8021X) {
+ if ((service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service->security == CONNMAN_SERVICE_SECURITY_8021X)
+#if defined TIZEN_EXT_EAP_ON_ETHERNET
+ || (service->type == CONNMAN_SERVICE_TYPE_ETHERNET)
+#endif
+ ) {
if (service->eap != NULL && strlen(service->eap) > 0)
g_key_file_set_string(keyfile, service->identifier,
"EAP", service->eap);
else
g_key_file_remove_key(keyfile, service->identifier,
"Identity", NULL);
+#if defined TIZEN_EXT_EAP_ON_ETHERNET
+ if (service->anonymous_identity != NULL && strlen(service->anonymous_identity) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "AnonymousIdentity", service->anonymous_identity);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "AnonymousIdentity", NULL);
+#endif
if (service->ca_cert_file != NULL && strlen(service->ca_cert_file) > 0)
g_key_file_set_string(keyfile, service->identifier,
else
g_key_file_remove_key(keyfile, service->identifier,
"PrivateKeyPassphrase", NULL);
+#if defined TIZEN_EXT_EAP_ON_ETHERNET
+ if (service->phase1 != NULL && strlen(service->phase1) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "Phase1", service->phase1);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "Phase1", NULL);
+ if (service->pac_file != NULL && strlen(service->pac_file) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "PacFile", service->pac_file);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "PacFile", NULL);
+#endif
+ }
+
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service->security == CONNMAN_SERVICE_SECURITY_DPP) {
+ if (service->connector != NULL && strlen(service->connector) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "Connector", service->connector);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "Connector", NULL);
+
+ if (service->c_sign_key != NULL && strlen(service->c_sign_key) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "CSignKey", service->c_sign_key);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "CSignKey", NULL);
+
+ if (service->net_access_key != NULL && strlen(service->net_access_key) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "NetAccessKey", service->net_access_key);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "NetAccessKey", NULL);
}
#endif
return err;
}
+#if defined TIZEN_EXT
+static gint sort_entry(gconstpointer a, gconstpointer b, gpointer user_data)
+{
+ GTimeVal *aval = (GTimeVal *)a;
+ GTimeVal *bval = (GTimeVal *)b;
+
+ /* Note that the sort order is ascending */
+ if (aval->tv_sec > bval->tv_sec)
+ return 1;
+
+ if (aval->tv_sec < bval->tv_sec)
+ return -1;
+
+ return 0;
+}
+
+static void free_entry(gpointer data)
+{
+ struct saved_profiles *entry = data;
+ g_free(entry->profile_name);
+ g_free(entry);
+}
+
+static void __connman_manage_saved_profiles()
+{
+ GKeyFile *keyfile;
+ gchar **services = NULL;
+ GTimeVal modified;
+ int i, num_profiles = 0;
+ GSequenceIter *iter;
+ GSequence *profile_list;
+ struct saved_profiles *entry;
+
+ profile_list = g_sequence_new(free_entry);
+ if (!profile_list)
+ return;
+
+ services = connman_storage_get_services();
+
+ /* Check the count of saved profiles */
+ for (i = 0; services && services[i]; i++) {
+ if (strncmp(services[i], "wifi_", 5) != 0)
+ continue;
+
+ keyfile = connman_storage_load_service(services[i]);
+ if (!keyfile)
+ continue;
+
+ gchar *str = g_key_file_get_string(keyfile,
+ services[i], "Modified", NULL);
+ if (!str) {
+ g_key_file_free(keyfile);
+ continue;
+ }
+
+ g_time_val_from_iso8601(str, &modified);
+ g_free(str);
+
+ entry = g_try_new(struct saved_profiles, 1);
+ if (!entry) {
+ g_sequence_free(profile_list);
+ g_key_file_free(keyfile);
+ g_strfreev(services);
+ return;
+ }
+
+ entry->modified = modified;
+ entry->profile_name = g_strdup(services[i]);
+
+ g_sequence_insert_sorted(profile_list, entry,
+ sort_entry, NULL);
+
+ num_profiles++;
+ }
+ DBG("number of profiles: %d", num_profiles);
+
+ if (num_profiles > MAX_WIFI_PROFILES) {
+ iter = g_sequence_get_begin_iter(profile_list);
+
+ entry = g_sequence_get(iter);
+
+ if (__connman_storage_remove_service(entry->profile_name) == false)
+ DBG("Failed to remove service profile: %s", entry->profile_name);
+ }
+
+ g_sequence_free(profile_list);
+ g_strfreev(services);
+}
+#endif
+
void __connman_service_save(struct connman_service *service)
{
if (!service)
return;
service_save(service);
+#if defined TIZEN_EXT
+ /*
+ * Description: Manage the wireless profiles saved in connman.
+ * If the number of saved profiles is more than 200, remove the
+ * profile that is not updated for longer duration.
+ */
+ __connman_manage_saved_profiles();
+#endif
}
static enum connman_service_state combine_state(
return result;
}
-static bool is_connecting_state(struct connman_service *service,
- enum connman_service_state state)
+static bool is_connecting(enum connman_service_state state)
{
switch (state) {
case CONNMAN_SERVICE_STATE_UNKNOWN:
case CONNMAN_SERVICE_STATE_IDLE:
case CONNMAN_SERVICE_STATE_FAILURE:
- if (service->network)
- return connman_network_get_connecting(service->network);
case CONNMAN_SERVICE_STATE_DISCONNECT:
case CONNMAN_SERVICE_STATE_READY:
case CONNMAN_SERVICE_STATE_ONLINE:
return false;
}
-static bool is_connected_state(const struct connman_service *service,
- enum connman_service_state state)
+static bool is_connected(enum connman_service_state state)
{
switch (state) {
case CONNMAN_SERVICE_STATE_UNKNOWN:
return false;
}
-static bool is_idle_state(const struct connman_service *service,
- enum connman_service_state state)
+static bool is_idle(enum connman_service_state state)
{
switch (state) {
+ case CONNMAN_SERVICE_STATE_IDLE:
+ case CONNMAN_SERVICE_STATE_DISCONNECT:
+ case CONNMAN_SERVICE_STATE_FAILURE:
+ return true;
case CONNMAN_SERVICE_STATE_UNKNOWN:
case CONNMAN_SERVICE_STATE_ASSOCIATION:
case CONNMAN_SERVICE_STATE_CONFIGURATION:
case CONNMAN_SERVICE_STATE_READY:
case CONNMAN_SERVICE_STATE_ONLINE:
- case CONNMAN_SERVICE_STATE_DISCONNECT:
- case CONNMAN_SERVICE_STATE_FAILURE:
break;
- case CONNMAN_SERVICE_STATE_IDLE:
- return true;
}
return false;
}
-static bool is_connecting(struct connman_service *service)
+static int nameservers_changed_cb(void *user_data)
{
- return is_connecting_state(service, service->state);
+ struct connman_service *service = user_data;
+
+ DBG("service %p", service);
+
+ service->nameservers_timeout = 0;
+ if ((is_idle(service->state) && !service->nameservers) ||
+ is_connected(service->state))
+ dns_changed(service);
+
+ return FALSE;
}
-static bool is_connected(struct connman_service *service)
+static void nameservers_changed(struct connman_service *service)
{
- return is_connected_state(service, service->state);
+ if (!service->nameservers_timeout)
+ service->nameservers_timeout = g_idle_add(nameservers_changed_cb,
+ service);
}
static bool nameserver_available(struct connman_service *service,
+ enum connman_ipconfig_type type,
const char *ns)
{
int family;
family = connman_inet_check_ipaddress(ns);
- if (family == AF_INET)
- return is_connected_state(service, service->state_ipv4);
+ if (family == AF_INET) {
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
+ return false;
+
+ return is_connected(service->state_ipv4);
+ }
+
+ if (family == AF_INET6) {
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ return false;
- if (family == AF_INET6)
- return is_connected_state(service, service->state_ipv6);
+ return is_connected(service->state_ipv6);
+ }
return false;
}
+static int searchdomain_add_all(struct connman_service *service)
+{
+ int index, i = 0;
+
+ if (!is_connected(service->state))
+ return -ENOTCONN;
+
+ index = __connman_service_get_index(service);
+ if (index < 0)
+ return -ENXIO;
+
+ if (service->domains) {
+ while (service->domains[i]) {
+ connman_resolver_append(index, service->domains[i],
+ NULL);
+ i++;
+ }
+
+ return 0;
+ }
+
+ if (service->domainname)
+ connman_resolver_append(index, service->domainname, NULL);
+
+ return 0;
+
+}
+
+static int searchdomain_remove_all(struct connman_service *service)
+{
+ int index, i = 0;
+
+ if (!is_connected(service->state))
+ return -ENOTCONN;
+
+ index = __connman_service_get_index(service);
+ if (index < 0)
+ return -ENXIO;
+
+ while (service->domains && service->domains[i]) {
+ connman_resolver_remove(index, service->domains[i], NULL);
+ i++;
+ }
+
+ if (service->domainname)
+ connman_resolver_remove(index, service->domainname, NULL);
+
+ return 0;
+}
+
static int nameserver_add(struct connman_service *service,
+ enum connman_ipconfig_type type,
const char *nameserver)
{
- int index;
+ int index, ret;
- if (!nameserver_available(service, nameserver))
+ if (!nameserver_available(service, type, nameserver))
return 0;
index = __connman_service_get_index(service);
#if defined TIZEN_EXT
DBG("Resolver append nameserver: %s", nameserver);
#endif
- return connman_resolver_append(index, NULL, nameserver);
+ ret = connman_resolver_append(index, NULL, nameserver);
+ if (ret >= 0)
+ nameservers_changed(service);
+
+ return ret;
}
-#if defined TIZEN_EXT
static int nameserver_add_all(struct connman_service *service,
- enum connman_ipconfig_type type)
-#else
-static int nameserver_add_all(struct connman_service *service)
-#endif
+ enum connman_ipconfig_type type)
{
int i = 0;
service->nameservers_config[i]) == AF_INET &&
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers_config[i]);
}
break;
service->nameservers_config[i]) == AF_INET6 &&
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers_config[i]);
}
break;
service->nameservers_config[i]) == AF_INET &&
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers_config[i]);
}
if (connman_inet_check_ipaddress(
service->nameservers_config[i]) == AF_INET6 &&
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers_config[i]);
}
break;
break;
}
#else
- nameserver_add(service, service->nameservers_config[i]);
+ nameserver_add(service, type,
+ service->nameservers_config[i]);
#endif
i++;
}
-#if !defined TIZEN_EXT
- return 0;
-#endif
- }
-
-#if defined TIZEN_EXT
- i = 0;
-#endif
- if (service->nameservers) {
+ } else if (service->nameservers) {
while (service->nameservers[i]) {
#if defined TIZEN_EXT
DBG("type %d service->nameservers[%d]: %s",type,
service->nameservers[i]) == AF_INET &&
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_DHCP) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers[i]);
}
break;
service->nameservers[i]) == AF_INET6 &&
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_DHCP) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers[i]);
}
break;
service->nameservers[i]) == AF_INET &&
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_DHCP) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers[i]);
}
if (connman_inet_check_ipaddress(
service->nameservers[i]) == AF_INET6 &&
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_DHCP) {
- nameserver_add(service,
+ nameserver_add(service, type,
service->nameservers[i]);
}
break;
break;
}
#else
- nameserver_add(service, service->nameservers[i]);
+ nameserver_add(service, type,
+ service->nameservers[i]);
#endif
i++;
}
}
+ if (!i)
+ __connman_resolver_append_fallback_nameservers();
+
+#if defined TIZEN_EXT
+ const char *global_dns = connman_option_get_string("GlobalNameserver");
+ if (global_dns)
+ nameserver_add(service, type, global_dns);
+#endif
+
+ searchdomain_add_all(service);
+
return 0;
}
static int nameserver_remove(struct connman_service *service,
+ enum connman_ipconfig_type type,
const char *nameserver)
{
- int index;
+ int index, ret;
- if (!nameserver_available(service, nameserver))
+ if (!nameserver_available(service, type, nameserver))
return 0;
index = __connman_service_get_index(service);
#if defined TIZEN_EXT
DBG("Resolver remove nameserver: %s", nameserver);
#endif
- return connman_resolver_remove(index, NULL, nameserver);
+ ret = connman_resolver_remove(index, NULL, nameserver);
+ if (ret >= 0)
+ nameservers_changed(service);
+
+ return ret;
}
-#if defined TIZEN_EXT
static int nameserver_remove_all(struct connman_service *service,
- enum connman_ipconfig_type type)
-#else
-static int nameserver_remove_all(struct connman_service *service)
-#endif
+ enum connman_ipconfig_type type)
{
#if defined TIZEN_EXT
/**
return -ENXIO;
while (service->nameservers_config && service->nameservers_config[i]) {
+
#if defined TIZEN_EXT
DBG("type %d Remove service->nameservers_config[%d]: %s",
type, i, service->nameservers_config[i]);
CONNMAN_DNSCONFIG_METHOD_DHCP ||
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers_config[i]);
}
break;
CONNMAN_DNSCONFIG_METHOD_DHCP ||
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers_config[i]);
}
break;
CONNMAN_DNSCONFIG_METHOD_DHCP ||
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers_config[i]);
}
if (connman_inet_check_ipaddress(
CONNMAN_DNSCONFIG_METHOD_DHCP ||
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_MANUAL)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers_config[i]);
}
break;
break;
}
#else
- nameserver_remove(service, service->nameservers_config[i]);
+ nameserver_remove(service, type,
+ service->nameservers_config[i]);
#endif
i++;
}
CONNMAN_DNSCONFIG_METHOD_MANUAL ||
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_DHCP)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers[i]);
}
break;
CONNMAN_DNSCONFIG_METHOD_MANUAL ||
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_DHCP)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers[i]);
}
break;
CONNMAN_DNSCONFIG_METHOD_MANUAL ||
service->dns_config_method_ipv4 ==
CONNMAN_DNSCONFIG_METHOD_DHCP)) {
- nameserver_remove(service,
+ nameserver_remove(service, type,
service->nameservers[i]);
}
if (connman_inet_check_ipaddress(
CONNMAN_DNSCONFIG_METHOD_MANUAL ||
service->dns_config_method_ipv6 ==
CONNMAN_DNSCONFIG_METHOD_DHCP)) {
- nameserver_remove(service,
- service->nameservers[i]);
- }
- break;
- case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
- DBG("CONNMAN_IPCONFIG_TYPE_UNKNOWN do nothing");
- break;
- default:
- DBG("default case do nothing");
- break;
- }
-#else
- nameserver_remove(service, service->nameservers[i]);
-#endif
- i++;
- }
-
- return 0;
-}
-
-static int searchdomain_add_all(struct connman_service *service)
-{
- int index, i = 0;
-
- if (!is_connected(service))
- return -ENOTCONN;
-
- index = __connman_service_get_index(service);
- if (index < 0)
- return -ENXIO;
-
- if (service->domains) {
- while (service->domains[i]) {
- connman_resolver_append(index, service->domains[i],
- NULL);
- i++;
- }
-
- return 0;
- }
-
- if (service->domainname)
- connman_resolver_append(index, service->domainname, NULL);
-
- return 0;
-
-}
-
-static int searchdomain_remove_all(struct connman_service *service)
-{
- int index, i = 0;
-
- if (!is_connected(service))
- return -ENOTCONN;
-
- index = __connman_service_get_index(service);
- if (index < 0)
- return -ENXIO;
-
- while (service->domains && service->domains[i]) {
- connman_resolver_remove(index, service->domains[i], NULL);
+ nameserver_remove(service, type,
+ service->nameservers[i]);
+ }
+ break;
+ case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
+ DBG("CONNMAN_IPCONFIG_TYPE_UNKNOWN do nothing");
+ break;
+ default:
+ DBG("default case do nothing");
+ break;
+ }
+#else
+ nameserver_remove(service, type, service->nameservers[i]);
+#endif
i++;
}
- if (service->domainname)
- connman_resolver_remove(index, service->domainname, NULL);
+#if defined TIZEN_EXT
+ const char *global_dns = connman_option_get_string("GlobalNameserver");
+ if (global_dns)
+ nameserver_remove(service, type, global_dns);
+#endif
+ searchdomain_remove_all(service);
return 0;
}
char **nameservers;
int len, i;
- DBG("service %p nameserver %s auto %d", service, nameserver, is_auto);
+ DBG("service %p nameserver %s auto %d", service, nameserver, is_auto);
if (!nameserver)
return -EINVAL;
else
nameservers = service->nameservers;
- for (i = 0; nameservers && nameservers[i]; i++)
-#if defined TIZEN_EXT
- {
- DBG("nameservers[%d] %s, nameserver %s", i, nameservers[i], nameserver);
-#endif
- if (g_strcmp0(nameservers[i], nameserver) == 0)
- return -EEXIST;
+ if (nameservers) {
+ for (i = 0; nameservers[i]; i++) {
#if defined TIZEN_EXT
- }
+ DBG("nameservers[%d] %s, nameserver %s", i, nameservers[i], nameserver);
#endif
+ if (g_strcmp0(nameservers[i], nameserver) == 0)
+ return -EEXIST;
+ }
- if (nameservers) {
len = g_strv_length(nameservers);
nameservers = g_try_renew(char *, nameservers, len + 2);
} else {
#ifdef TIZEN_EXT
if(type == CONNMAN_IPCONFIG_TYPE_IPV4 &&
- service->dns_config_method_ipv4 ==
- CONNMAN_DNSCONFIG_METHOD_UNKNOWN)
+ service->dns_config_method_ipv4 == CONNMAN_DNSCONFIG_METHOD_UNKNOWN)
service->dns_config_method_ipv4 = CONNMAN_DNSCONFIG_METHOD_DHCP;
if(type == CONNMAN_IPCONFIG_TYPE_IPV6 &&
- service->dns_config_method_ipv6 ==
- CONNMAN_DNSCONFIG_METHOD_UNKNOWN)
+ service->dns_config_method_ipv6 == CONNMAN_DNSCONFIG_METHOD_UNKNOWN)
service->dns_config_method_ipv6 = CONNMAN_DNSCONFIG_METHOD_DHCP;
#endif
service->nameservers_auto = nameservers;
} else {
service->nameservers = nameservers;
-#if defined TIZEN_EXT
- DBG("nameserver add: %s, type: %d", nameserver, type);
-#endif
- nameserver_add(service, nameserver);
+ nameserver_add(service, CONNMAN_IPCONFIG_TYPE_ALL, nameserver);
}
+ nameservers_changed(service);
+
+ searchdomain_add_all(service);
+
return 0;
}
if (!nameservers)
return 0;
- for (i = 0; nameservers && nameservers[i]; i++)
+ for (i = 0; nameservers[i]; i++)
if (g_strcmp0(nameservers[i], nameserver) == 0) {
found = true;
break;
service->nameservers = nameservers;
#if defined TIZEN_EXT
DBG("nameserver remove ip_type: %d", type);
+ nameserver_remove(service, type,
+ nameserver);
+#else
+ nameserver_remove(service, CONNMAN_IPCONFIG_TYPE_ALL,
+ nameserver);
#endif
- nameserver_remove(service, nameserver);
}
return 0;
void __connman_service_nameserver_clear(struct connman_service *service)
{
-#if defined TIZEN_EXT
- DBG("nameserver remove all ip_type: CONNMAN_IPCONFIG_TYPE_ALL");
nameserver_remove_all(service, CONNMAN_IPCONFIG_TYPE_ALL);
-#else
- nameserver_remove_all(service);
-#endif
g_strfreev(service->nameservers);
service->nameservers = NULL;
-#if defined TIZEN_EXT
- DBG("nameserver add all ip_type: CONNMAN_IPCONFIG_TYPE_ALL");
nameserver_add_all(service, CONNMAN_IPCONFIG_TYPE_ALL);
-#else
- nameserver_add_all(service);
-#endif
-
}
static void add_nameserver_route(int family, int index, char *nameserver,
nameserver_del_routes(index, service->nameservers, type);
}
+static bool check_proxy_setup(struct connman_service *service)
+{
+ /*
+ * We start WPAD if we haven't got a PAC URL from DHCP and
+ * if our proxy manual configuration is either empty or set
+ * to AUTO with an empty URL.
+ */
+
+ if (service->proxy != CONNMAN_SERVICE_PROXY_METHOD_UNKNOWN)
+ return true;
+
+ if (service->proxy_config != CONNMAN_SERVICE_PROXY_METHOD_UNKNOWN &&
+ (service->proxy_config != CONNMAN_SERVICE_PROXY_METHOD_AUTO ||
+ service->pac))
+ return true;
+
+ if (__connman_wpad_start(service) < 0) {
+ service->proxy = CONNMAN_SERVICE_PROXY_METHOD_DIRECT;
+ __connman_notifier_proxy_changed(service);
+ return true;
+ }
+
+ return false;
+}
+
+static void cancel_online_check(struct connman_service *service)
+{
+ if (service->online_timeout == 0)
+ return;
+
+ g_source_remove(service->online_timeout);
+ service->online_timeout = 0;
+ connman_service_unref(service);
+}
+
+static void start_online_check(struct connman_service *service,
+ enum connman_ipconfig_type type)
+{
+ if (!connman_setting_get_bool("EnableOnlineCheck")) {
+ connman_info("Online check disabled. "
+ "Default service remains in READY state.");
+ return;
+ }
+
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV4 || check_proxy_setup(service)) {
+ cancel_online_check(service);
+ __connman_service_wispr_start(service, type);
+ }
+}
+
+static void address_updated(struct connman_service *service,
+ enum connman_ipconfig_type type)
+{
+ if (is_connected(service->state) &&
+ service == connman_service_get_default()) {
+ nameserver_remove_all(service, type);
+ nameserver_add_all(service, type);
+ start_online_check(service, type);
+
+ __connman_timeserver_sync(service);
+ }
+}
+
static struct connman_stats *stats_get(struct connman_service *service)
{
if (service->roaming)
return FALSE;
}
-static gboolean __connman_service_is_tethering_profile(
- struct connman_service *cellular)
-{
- const char tethering_suffix[] = "_5";
-
- DBG("Service path: %s", cellular->path);
-
- if (g_str_has_suffix(cellular->path, tethering_suffix) == TRUE)
- return TRUE;
-
- return FALSE;
-}
-
struct connman_service *connman_service_get_default_connection(void)
{
GList *list;
state2string(service->state),
__connman_service_type2string(service->type));
+#if defined TIZEN_MAINTAIN_ONLINE
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service->state == CONNMAN_SERVICE_STATE_ONLINE) {
+#else
if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
- is_connected(service) == TRUE) {
+ is_connected(service->state) == TRUE) {
+#endif
return service;
} else if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR &&
__connman_service_is_internet_profile(service) == TRUE) {
if (default_service == NULL)
default_service = service;
- else if (is_connected(service) == TRUE &&
- is_connected(default_service) == FALSE)
+ else if (is_connected(service->state) == TRUE &&
+ is_connected(default_service->state) == FALSE)
default_service = service;
} else if (service->type == CONNMAN_SERVICE_TYPE_ETHERNET &&
- is_connected(service) == TRUE) {
+ is_connected(service->state) == TRUE) {
if (default_service == NULL)
default_service = service;
} else if (service->type == CONNMAN_SERVICE_TYPE_BLUETOOTH &&
- is_connected(service) == TRUE) {
+ is_connected(service->state) == TRUE) {
if (default_service == NULL)
default_service = service;
}
return default_service;
}
+
+struct connman_service *connman_service_get_connected_service(const char *ifname)
+{
+ GList *list;
+ const char *svc_ifname;
+ struct connman_service *service;
+
+ if (!ifname)
+ return NULL;
+
+ for (list = service_list; list; list = list->next) {
+ service = list->data;
+
+ if (!is_connected(service->state))
+ continue;
+
+ svc_ifname = connman_device_get_string(
+ connman_network_get_device(service->network), "Interface");
+
+ if (svc_ifname && g_strcmp0(svc_ifname, ifname) == 0)
+ return service;
+ }
+
+ return NULL;
+}
#endif
-struct connman_service *__connman_service_get_default(void)
+struct connman_service *connman_service_get_default(void)
{
+#if defined TIZEN_MAINTAIN_ONLINE
+ return connman_service_get_default_connection();
+#else
struct connman_service *service;
if (!service_list)
service = service_list->data;
- if (!is_connected(service))
+ if (!is_connected(service->state))
return NULL;
return service;
+#endif
}
bool __connman_service_index_is_default(int index)
if (index < 0)
return false;
- service = __connman_service_get_default();
+ service = connman_service_get_default();
return __connman_service_get_index(service) == index;
}
static void default_changed(void)
{
- struct connman_service *service = __connman_service_get_default();
+#if defined TIZEN_EXT
+ struct connman_service *service = connman_service_get_default_connection();
+#else
+ struct connman_service *service = connman_service_get_default();
+#endif
if (service == current_default)
return;
connman_setting_get_bool("AllowHostnameUpdates"))
__connman_utsname_set_hostname(service->hostname);
- if (service->domainname)
+ if (service->domainname &&
+ connman_setting_get_bool("AllowDomainnameUpdates"))
__connman_utsname_set_domainname(service->domainname);
+
+ /*
+ * Connect VPN automatically when new default service
+ * is set and connected, unless new default is VPN
+ */
+ if (is_connected(service->state) &&
+ service->type != CONNMAN_SERVICE_TYPE_VPN) {
+ DBG("running vpn_auto_connect");
+ vpn_auto_connect();
+ }
}
__connman_notifier_default_changed(service);
}
+#if defined TIZEN_EXT
+static void append_struct(gpointer value, gpointer user_data);
+
+static void emit_state_changed_with_properties(struct connman_service *service)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter;
+
+ if (!service)
+ return;
+
+ signal = dbus_message_new_signal(service->path, CONNMAN_SERVICE_INTERFACE,
+ "StateChangedProperties");
+ if (!signal)
+ return;
+
+ dbus_message_iter_init_append(signal, &iter);
+ append_struct(service, &iter);
+
+ g_dbus_send_message(connection, signal);
+
+ return;
+}
+#endif
+
static void state_changed(struct connman_service *service)
{
const char *str;
#if !defined TIZEN_EXT
if (!allow_property_changed(service))
return;
-#endif
-#if defined TIZEN_EXT
+#else
DBG(" %s, %s", str, service->path);
#endif
+
connman_dbus_property_changed_basic(service->path,
CONNMAN_SERVICE_INTERFACE, "State",
DBUS_TYPE_STRING, &str);
+
+#if defined TIZEN_EXT
+ emit_state_changed_with_properties(service);
+#endif
+}
+
+#if defined TIZEN_EXT
+static void connect_reason_changed(struct connman_service *service)
+{
+#if defined TIZEN_EXT_INS
+ struct connman_device *device;
+#endif
+ if (!service->path)
+ return;
+
+ if (!allow_property_changed(service))
+ return;
+
+#if defined TIZEN_EXT_INS
+ if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER) {
+ device = connman_network_get_device(service->network);
+ if (device) {
+ bool need_save = false;
+
+ need_save |= connman_device_set_last_user_selection_ident(device, service->identifier);
+ need_save |= connman_device_set_last_user_selection_time(device, time(NULL));
+
+ DBG("last user selection ident[%s] time[%ld]",
+ connman_device_get_last_user_selection_ident(device),
+ connman_device_get_last_user_selection_time(device));
+
+ if (need_save)
+ connman_device_save_last_user_selection(device);
+ }
+ }
+#endif
+
+ connman_dbus_property_changed_basic(service->path,
+ CONNMAN_SERVICE_INTERFACE,
+ "ConnectReason",
+ DBUS_TYPE_INT32,
+ &service->connect_reason);
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
+#if defined TIZEN_EXT
+static void disconnection_requested_changed(struct connman_service *service)
+{
+ dbus_bool_t disconnection_requested;
+
+ if (!service->path)
+ return;
+
+ if (!allow_property_changed(service))
+ return;
+
+ disconnection_requested = service->disconnection_requested;
+ connman_dbus_property_changed_basic(service->path,
+ CONNMAN_SERVICE_INTERFACE,
+ "DisconnectionRequested",
+ DBUS_TYPE_BOOLEAN,
+ &disconnection_requested);
}
+void connman_service_set_disconnection_requested(struct connman_service *service,
+ bool disconnection_requested)
+{
+ if (service == NULL)
+ return;
+
+ service->disconnection_requested = disconnection_requested;
+ disconnection_requested_changed(service);
+}
+#endif
+
static void strength_changed(struct connman_service *service)
{
if (service->strength == 0)
DBUS_TYPE_BYTE, &service->strength);
}
+#if defined TIZEN_EXT
+static bool update_last_connected_bssid(struct connman_service *service)
+{
+ const unsigned char *last_connected_bssid;
+
+ if (!service->network)
+ return false;
+
+ last_connected_bssid = connman_network_get_last_connected_bssid(service->network);
+ if (memcmp(last_connected_bssid, invalid_bssid, WIFI_BSSID_LEN_MAX) == 0)
+ return false;
+
+ if (memcmp(last_connected_bssid, service->last_connected_bssid, WIFI_BSSID_LEN_MAX) != 0) {
+ memcpy(service->last_connected_bssid, last_connected_bssid, WIFI_BSSID_LEN_MAX);
+ return true;
+ }
+
+ return false;
+}
+#endif
+
static void favorite_changed(struct connman_service *service)
{
dbus_bool_t favorite;
DBUS_TYPE_BOOLEAN, &autoconnect);
}
+bool connman_service_set_autoconnect(struct connman_service *service,
+ bool autoconnect)
+{
+ if (service->autoconnect == autoconnect)
+ return false;
+
+ service->autoconnect = autoconnect;
+ autoconnect_changed(service);
+
+ return true;
+}
+
static void append_security(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
case CONNMAN_SERVICE_SECURITY_PSK:
case CONNMAN_SERVICE_SECURITY_WPA:
case CONNMAN_SERVICE_SECURITY_RSN:
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_SAE:
+#endif
str = "wps";
dbus_message_iter_append_basic(iter,
DBUS_TYPE_STRING, &str);
break;
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_OWE:
+#endif
case CONNMAN_SERVICE_SECURITY_UNKNOWN:
case CONNMAN_SERVICE_SECURITY_NONE:
case CONNMAN_SERVICE_SECURITY_WEP:
case CONNMAN_SERVICE_SECURITY_8021X:
break;
}
+
+ if (service->wps_advertizing) {
+ str = "wps_advertising";
+ dbus_message_iter_append_basic(iter,
+ DBUS_TYPE_STRING, &str);
+ }
}
}
+static void security_changed(struct connman_service *service)
+{
+ if (!service->path)
+ return;
+
+ if (!allow_property_changed(service))
+ return;
+
+ connman_dbus_property_changed_array(service->path,
+ CONNMAN_SERVICE_INTERFACE, "Security",
+ DBUS_TYPE_STRING, append_security, service);
+}
+
static void append_ethernet(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
iter);
}
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+static void append_eap_over_ethernet(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+ dbus_bool_t val;
+
+ val = service->use_eapol;
+ connman_dbus_dict_append_basic(iter, "UseEapol",
+ DBUS_TYPE_BOOLEAN, &val);
+ if (service->use_eapol) {
+ if (service->eap)
+ connman_dbus_dict_append_basic(iter, "EAP",
+ DBUS_TYPE_STRING, &service->eap);
+
+ if (service->identity)
+ connman_dbus_dict_append_basic(iter, "Identity",
+ DBUS_TYPE_STRING, &service->identity);
+
+ if (service->anonymous_identity)
+ connman_dbus_dict_append_basic(iter, "AnonymousIdentity",
+ DBUS_TYPE_STRING, &service->anonymous_identity);
+
+ if (service->ca_cert_file)
+ connman_dbus_dict_append_basic(iter, "CACertFile",
+ DBUS_TYPE_STRING, &service->ca_cert_file);
+
+ if (service->client_cert_file)
+ connman_dbus_dict_append_basic(iter, "ClientCertFile",
+ DBUS_TYPE_STRING, &service->client_cert_file);
+
+ if (service->private_key_file)
+ connman_dbus_dict_append_basic(iter, "PrivateKeyFile",
+ DBUS_TYPE_STRING, &service->private_key_file);
+
+ if (service->phase2)
+ connman_dbus_dict_append_basic(iter, "Phase2",
+ DBUS_TYPE_STRING, &service->phase2);
+
+ if (service->phase1)
+ connman_dbus_dict_append_basic(iter, "Phase1",
+ DBUS_TYPE_STRING, &service->phase1);
+
+ if (service->pac_file)
+ connman_dbus_dict_append_basic(iter, "PacFile",
+ DBUS_TYPE_STRING, &service->pac_file);
+
+ /* Should we include passphrase? */
+ }
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
+
static void append_ipv4(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
- if (!is_connected_state(service, service->state_ipv4))
+ if (!is_connected(service->state_ipv4))
return;
if (service->ipconfig_ipv4)
{
struct connman_service *service = user_data;
- if (!is_connected_state(service, service->state_ipv6))
+ if (!is_connected(service->state_ipv6))
return;
if (service->ipconfig_ipv6)
for (i = 0; servers[i]; i++) {
if (service)
- available = nameserver_available(service, servers[i]);
-
- DBG("servers[%d] %s available %d", i, servers[i], available);
+ available = nameserver_available(service,
+ CONNMAN_IPCONFIG_TYPE_ALL,
+ servers[i]);
if (available)
dbus_message_iter_append_basic(iter,
bool available = true;
if (service)
- available = nameserver_available(service, server);
+ available = nameserver_available(service,
+ CONNMAN_IPCONFIG_TYPE_ALL, server);
if (available)
dbus_message_iter_append_basic(iter,
bool available = true;
if (service)
- available = nameserver_available(service, server);
+ available = nameserver_available(service,
+ CONNMAN_IPCONFIG_TYPE_ALL, server);
if (available)
dbus_message_iter_append_basic(iter,
int i;
#endif
- if (!is_connected(service))
+ if (!is_connected(service->state))
return;
#ifdef TIZEN_EXT
{
struct connman_service *service = user_data;
- if (!is_connected(service) &&
- !is_connecting(service))
+ if (!is_connected(service->state) &&
+ !is_connecting(service->state))
return;
if (service->domains)
const char *method = proxymethod2string(
CONNMAN_SERVICE_PROXY_METHOD_DIRECT);
- if (!is_connected(service))
+ if (!is_connected(service->state))
return;
proxy = connman_service_get_proxy_method(service);
{
struct connman_service *service = user_data;
- if (!is_connected(service))
+ if (!is_connected(service->state))
return;
if (service->provider)
{
enum connman_ipconfig_type type;
- if (!allow_property_changed(service))
- return;
-
type = __connman_ipconfig_get_config_type(ipconfig);
+ __connman_notifier_ipconfig_changed(service, ipconfig);
+
+ if (!allow_property_changed(service))
+ return;
+
if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
connman_dbus_property_changed_dict(service->path,
CONNMAN_SERVICE_INTERFACE, "IPv4",
connman_dbus_property_changed_dict(service->path,
CONNMAN_SERVICE_INTERFACE, "IPv6",
append_ipv6, service);
-
- __connman_notifier_ipconfig_changed(service, ipconfig);
}
static void ipv4_configuration_changed(struct connman_service *service)
service);
}
+void __connman_service_notify_ipv4_configuration(
+ struct connman_service *service)
+{
+ if (!service)
+ return;
+
+ ipv4_configuration_changed(service);
+}
+
static void ipv6_configuration_changed(struct connman_service *service)
{
if (!allow_property_changed(service))
proxy_changed(service);
}
+static void mdns_changed(struct connman_service *service)
+{
+ dbus_bool_t mdns = service->mdns;
+
+ if (!allow_property_changed(service))
+ return;
+
+ connman_dbus_property_changed_basic(service->path,
+ CONNMAN_SERVICE_INTERFACE, "mDNS", DBUS_TYPE_BOOLEAN,
+ &mdns);
+}
+
+static void mdns_configuration_changed(struct connman_service *service)
+{
+ dbus_bool_t mdns_config = service->mdns_config;
+
+ if (!allow_property_changed(service))
+ return;
+
+ connman_dbus_property_changed_basic(service->path,
+ CONNMAN_SERVICE_INTERFACE, "mDNS.Configuration",
+ DBUS_TYPE_BOOLEAN, &mdns_config);
+}
+
+static int set_mdns(struct connman_service *service,
+ bool enabled)
+{
+ int result;
+
+ result = __connman_resolver_set_mdns(
+ __connman_service_get_index(service), enabled);
+
+ if (result == 0) {
+ if (service->mdns != enabled) {
+ service->mdns = enabled;
+ mdns_changed(service);
+ }
+ }
+
+ return result;
+}
+
static void timeservers_configuration_changed(struct connman_service *service)
{
if (!allow_property_changed(service))
if (!service)
return;
- if (!is_connected(service))
+ if (!is_connected(service->state))
return;
stats_update(service,
counter_list = g_slist_remove(counter_list, counter);
}
-int __connman_service_iterate_services(service_iterate_cb cb, void *user_data)
+int connman_service_iterate_services(connman_service_iterate_cb cb,
+ void *user_data)
{
GList *list;
+ int ret = 0;
- for (list = service_list; list; list = list->next) {
- struct connman_service *service = list->data;
-
- cb(service, user_data);
- }
+ for (list = service_list; list && ret == 0; list = list->next)
+ ret = cb((struct connman_service *)list->data, user_data);
- return 0;
+ return ret;
}
#if defined TIZEN_EXT
+static void append_security_list(DBusMessageIter *iter, void *user_data)
+{
+ GSList *sec_list = (GSList *)user_data;
+ const char *sec_str;
+
+ if (sec_list) {
+ GSList *list;
+ for (list = sec_list; list; list = list->next) {
+ sec_str = (const char *)list->data;
+
+ dbus_message_iter_append_basic(iter,
+ DBUS_TYPE_STRING, &sec_str);
+ }
+ }
+}
+
static void append_wifi_ext_info(DBusMessageIter *dict,
struct connman_network *network)
{
unsigned int ssid_len;
unsigned char *bssid;
unsigned int maxrate;
+ int maxspeed;
unsigned int keymgmt;
uint16_t frequency;
const char *enc_mode;
+ const char *str;
gboolean passpoint;
+ char country_code_buff[WIFI_COUNTRY_CODE_LEN + 1] = {0,};
+ char *country_code_str = country_code_buff;
+ unsigned char *country_code;
+ uint16_t connection_mode;
+ GSList *sec_list = NULL;
ssid = connman_network_get_blob(network, "WiFi.SSID", &ssid_len);
bssid = connman_network_get_bssid(network);
maxrate = connman_network_get_maxrate(network);
+ maxspeed = connman_network_get_maxspeed(network);
frequency = connman_network_get_frequency(network);
enc_mode = connman_network_get_enc_mode(network);
- passpoint = connman_network_get_is_hs20AP(network);
+ passpoint = connman_network_get_bool(network, "WiFi.HS20AP");
keymgmt = connman_network_get_keymgmt(network);
+ country_code = connman_network_get_countrycode(network);
+ connection_mode = connman_network_get_connection_mode(network);
+ sec_list = (GSList *)connman_network_get_sec_list(network);
- snprintf(bssid_str, WIFI_BSSID_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
- bssid[0], bssid[1], bssid[2],
- bssid[3], bssid[4], bssid[5]);
+ snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid));
+
+ snprintf(country_code_str, (WIFI_COUNTRY_CODE_LEN + 1), "%c%c",
+ country_code[0], country_code[1]);
+
+ connman_dbus_dict_append_array(dict, "SecurityList",
+ DBUS_TYPE_STRING,
+ append_security_list, sec_list);
connman_dbus_dict_append_fixed_array(dict, "SSID",
DBUS_TYPE_BYTE, &ssid, ssid_len);
DBUS_TYPE_STRING, &bssid_str);
connman_dbus_dict_append_basic(dict, "MaxRate",
DBUS_TYPE_UINT32, &maxrate);
+ connman_dbus_dict_append_basic(dict, "MaxSpeed",
+ DBUS_TYPE_INT32, &maxspeed);
connman_dbus_dict_append_basic(dict, "Frequency",
DBUS_TYPE_UINT16, &frequency);
connman_dbus_dict_append_basic(dict, "EncryptionMode",
DBUS_TYPE_BOOLEAN, &passpoint);
connman_dbus_dict_append_basic(dict, "Keymgmt",
DBUS_TYPE_UINT32, &keymgmt);
+ connman_dbus_dict_append_basic(dict, "Country", DBUS_TYPE_STRING,
+ &country_code_str);
+ connman_dbus_dict_append_basic(dict, "ConnMode",
+ DBUS_TYPE_UINT16, &connection_mode);
+
+ str = connman_network_get_string(network, "WiFi.Security");
+ if (str != NULL && g_str_equal(str, "ieee8021x") == TRUE) {
+ str = connman_network_get_string(network, "WiFi.EAP");
+ if (str != NULL)
+ connman_dbus_dict_append_basic(dict, "EAP",
+ DBUS_TYPE_STRING, &str);
+
+ str = connman_network_get_string(network, "WiFi.Phase2");
+ if (str != NULL)
+ connman_dbus_dict_append_basic(dict, "Phase2",
+ DBUS_TYPE_STRING, &str);
+
+ str = connman_network_get_string(network, "WiFi.Identity");
+ if (str != NULL)
+ connman_dbus_dict_append_basic(dict, "Identity",
+ DBUS_TYPE_STRING, &str);
+
+ str = connman_network_get_string(network, "WiFi.CACertFile");
+ if (str != NULL)
+ connman_dbus_dict_append_basic(dict, "CACertFile",
+ DBUS_TYPE_STRING, &str);
+
+ str = connman_network_get_string(network,
+ "WiFi.ClientCertFile");
+ if (str != NULL)
+ connman_dbus_dict_append_basic(dict, "ClientCertFile",
+ DBUS_TYPE_STRING, &str);
+
+ str = connman_network_get_string(network,
+ "WiFi.PrivateKeyFile");
+ if (str != NULL)
+ connman_dbus_dict_append_basic(dict, "PrivateKeyFile",
+ DBUS_TYPE_STRING, &str);
+ }
+}
+
+static void append_bssid_info(DBusMessageIter *iter, void *user_data)
+{
+ GSList *bssid_list = NULL;
+ struct connman_network *network = user_data;
+ struct connman_bssids *bssids;
+ char bssid_buf[MAC_ADDRESS_LENGTH] = {0,};
+ char *bssid_str = bssid_buf;
+
+ bssid_list = (GSList *)connman_network_get_bssid_list(network);
+ if(bssid_list) {
+ GSList *list;
+ for (list = bssid_list; list; list = list->next) {
+ bssids = (struct connman_bssids *)list->data;
+ g_snprintf(bssid_buf, MAC_ADDRESS_LENGTH, MACSTR, MAC2STR(bssids->bssid));
+
+ connman_dbus_dict_append_basic(iter, "BSSID",
+ DBUS_TYPE_STRING, &bssid_str);
+
+ connman_dbus_dict_append_basic(iter, "Strength",
+ DBUS_TYPE_UINT16, &bssids->strength);
+
+ connman_dbus_dict_append_basic(iter, "Frequency",
+ DBUS_TYPE_UINT16, &bssids->frequency);
+ }
+ }
}
#endif
#if defined TIZEN_EXT
unsigned int frequency = 0U;
- if (service && service->network) {
+ unsigned char *wifi_vsie;
+ unsigned int wifi_vsie_len;
+ GSList *vsie_list = NULL;
+
+ if (service->network) {
frequency = connman_network_get_frequency(service->network);
connman_dbus_dict_append_basic(dict, "Frequency",
DBUS_TYPE_UINT16, &frequency);
+ vsie_list = (GSList *)connman_network_get_vsie_list(service->network);
+ }
+
+ if (vsie_list) {
+ GSList *list;
+ for (list = vsie_list; list; list = list->next) {
+ wifi_vsie = (unsigned char *)list->data;
+ wifi_vsie_len = wifi_vsie[1] + 2;
+
+ connman_dbus_dict_append_fixed_array(dict, "Vsie", DBUS_TYPE_BYTE,
+ &wifi_vsie, wifi_vsie_len);
+ }
}
#endif
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_VPN:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
break;
case CONNMAN_SERVICE_TYPE_CELLULAR:
val = service->roaming;
break;
case CONNMAN_SERVICE_TYPE_WIFI:
#if defined TIZEN_EXT
- if (service->network != NULL)
+ if (service->network != NULL) {
append_wifi_ext_info(dict, service->network);
+ connman_dbus_dict_append_dict(dict, "BSSID.List",
+ append_bssid_info, service->network);
+ }
connman_dbus_dict_append_dict(dict, "Ethernet",
append_ethernet, service);
+ service->disconnect_reason = connman_network_get_disconnect_reason(service->network);
connman_dbus_dict_append_basic(dict, "DisconnectReason",
DBUS_TYPE_INT32, &service->disconnect_reason);
+ connman_dbus_dict_append_basic(dict, "AssocStatusCode",
+ DBUS_TYPE_INT32, &service->assoc_status_code);
+
+ val = service->hidden_service;
+ connman_dbus_dict_append_basic(dict, "Hidden",
+ DBUS_TYPE_BOOLEAN, &val);
+
break;
#endif
case CONNMAN_SERVICE_TYPE_ETHERNET:
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ connman_dbus_dict_append_dict(dict, "EapOverEthernet",
+ append_eap_over_ethernet, service);
+ /* fall through */
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
case CONNMAN_SERVICE_TYPE_BLUETOOTH:
case CONNMAN_SERVICE_TYPE_GADGET:
connman_dbus_dict_append_dict(dict, "Ethernet",
connman_dbus_dict_append_dict(dict, "Proxy.Configuration",
append_proxyconfig, service);
+ val = service->mdns;
+ connman_dbus_dict_append_basic(dict, "mDNS", DBUS_TYPE_BOOLEAN,
+ &val);
+
+ val = service->mdns_config;
+ connman_dbus_dict_append_basic(dict, "mDNS.Configuration",
+ DBUS_TYPE_BOOLEAN, &val);
+
connman_dbus_dict_append_dict(dict, "Provider",
append_provider, service);
+
+ if (service->network)
+ connman_network_append_acddbus(dict, service->network);
+}
+
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+static void append_ins_bssid_info(DBusMessageIter *iter, void *user_data)
+{
+ GSList *bssid_list = NULL;
+ struct connman_network *network = user_data;
+ struct connman_bssids *bssids;
+ char bssid_buf[MAC_ADDRESS_LENGTH] = {0,};
+ char *bssid_str = bssid_buf;
+
+ bssid_list = (GSList *)connman_network_get_bssid_list(network);
+ if(bssid_list) {
+ GSList *list;
+ for (list = bssid_list; list; list = list->next) {
+ bssids = (struct connman_bssids *)list->data;
+ g_snprintf(bssid_buf, MAC_ADDRESS_LENGTH, MACSTR, MAC2STR(bssids->bssid));
+
+ connman_dbus_dict_append_basic(iter, "BSSID",
+ DBUS_TYPE_STRING, &bssid_str);
+
+ connman_dbus_dict_append_basic(iter, "ScoreINS",
+ DBUS_TYPE_INT32, &bssids->ins_score);
+
+ connman_dbus_dict_append_basic(iter, "ScoreLastConnected",
+ DBUS_TYPE_INT32, &bssids->score_last_connected_bssid);
+
+ connman_dbus_dict_append_basic(iter, "ScoreAssocReject",
+ DBUS_TYPE_INT32, &bssids->score_assoc_reject);
+
+ connman_dbus_dict_append_basic(iter, "Frequency",
+ DBUS_TYPE_UINT16, &bssids->frequency);
+
+ connman_dbus_dict_append_basic(iter, "ScoreFrequency",
+ DBUS_TYPE_INT32, &bssids->score_frequency);
+
+ connman_dbus_dict_append_basic(iter, "Strength",
+ DBUS_TYPE_UINT16, &bssids->strength);
+
+ connman_dbus_dict_append_basic(iter, "ScoreStrength",
+ DBUS_TYPE_INT32, &bssids->score_strength);
+ }
+ }
+}
+
+static void append_ins_properties(DBusMessageIter *dict,
+ struct connman_service *service)
+{
+ const char *str;
+ unsigned int frequency = 0U;
+
+ if (service->name)
+ connman_dbus_dict_append_basic(dict, "Name",
+ DBUS_TYPE_STRING, &service->name);
+
+ connman_dbus_dict_append_basic(dict, "ScoreINS",
+ DBUS_TYPE_INT32, &service->ins_score);
+
+ connman_dbus_dict_append_basic(dict, "ScoreLastUserSelection",
+ DBUS_TYPE_INT32, &service->score_last_user_selection);
+
+ connman_dbus_dict_append_basic(dict, "ScoreLastConnected",
+ DBUS_TYPE_INT32, &service->score_last_connected);
+
+ str = security2string(service->security);
+ if (str)
+ connman_dbus_dict_append_basic(dict, "Security",
+ DBUS_TYPE_STRING, &str);
+
+ connman_dbus_dict_append_basic(dict, "ScoreSecurityPriority",
+ DBUS_TYPE_INT32, &service->score_security_priority);
+
+ connman_dbus_dict_append_basic(dict, "Strength",
+ DBUS_TYPE_BYTE, &service->strength);
+
+ connman_dbus_dict_append_basic(dict, "ScoreStrength",
+ DBUS_TYPE_INT32, &service->score_strength);
+
+ connman_dbus_dict_append_basic(dict, "ScoreInternetConnection",
+ DBUS_TYPE_INT32, &service->score_internet_connection);
+
+ if (service->network) {
+ frequency = connman_network_get_frequency(service->network);
+ connman_dbus_dict_append_basic(dict, "Frequency",
+ DBUS_TYPE_UINT16, &frequency);
+
+ connman_dbus_dict_append_basic(dict, "ScoreFrequency",
+ DBUS_TYPE_INT32, &service->score_frequency);
+
+ connman_dbus_dict_append_dict(dict, "BSSID.List",
+ append_ins_bssid_info, service->network);
+ }
}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
static void append_struct_service(DBusMessageIter *iter,
connman_dbus_append_cb_t function,
append_struct_service(iter, append_dict_properties, service);
}
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+static void append_dict_ins_properties(DBusMessageIter *dict, void *user_data)
+{
+ struct connman_service *service = user_data;
+
+ append_ins_properties(dict, service);
+}
+
+static void append_ins_struct(gpointer value, gpointer user_data)
+{
+ struct connman_service *service = value;
+ DBusMessageIter *iter = user_data;
+
+ if (!service->path)
+ return;
+
+ if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return;
+
+ append_struct_service(iter, append_dict_ins_properties, service);
+}
+
+void __connman_ins_list_struct(DBusMessageIter *iter)
+{
+ g_list_foreach(service_list, append_ins_struct, iter);
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
void __connman_service_list_struct(DBusMessageIter *iter)
{
g_list_foreach(service_list, append_struct, iter);
return;
g_free(service->hostname);
- service->hostname = g_strdup(hostname);
+ service->hostname = NULL;
+
+ if (hostname && g_str_is_ascii(hostname))
+ service->hostname = g_strdup(hostname);
}
const char *__connman_service_get_hostname(struct connman_service *service)
return;
g_free(service->domainname);
- service->domainname = g_strdup(domainname);
+ service->domainname = NULL;
+
+ if (domainname && g_str_is_ascii(domainname))
+ service->domainname = g_strdup(domainname);
domain_changed(service);
}
return service->domainname;
}
+const char *connman_service_get_dbuspath(struct connman_service *service)
+{
+ if (!service)
+ return NULL;
+
+ return service->path;
+}
+
char **connman_service_get_nameservers(struct connman_service *service)
{
if (!service)
return service->pac;
}
+#if defined TIZEN_EXT
+void connman_service_set_internet_connection(struct connman_service *service,
+ bool internet_connection)
+{
+ if (!service)
+ return;
+
+ if (service->is_internet_connection != internet_connection) {
+ service->is_internet_connection = internet_connection;
+
+ g_get_current_time(&service->modified);
+ service_save(service);
+ }
+}
+
+bool connman_service_get_internet_connection(struct connman_service *service)
+{
+ if (!service)
+ return false;
+
+ return service->is_internet_connection;
+}
+
+DBusMessage *connman_service_create_dbus_service_reply(DBusMessage *msg,
+ struct connman_service *service)
+{
+ DBusMessage *reply;
+ DBusMessageIter array, dict;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &array);
+
+ if (service)
+ dbus_message_iter_append_basic(&array, DBUS_TYPE_OBJECT_PATH,
+ &service->path);
+
+ connman_dbus_dict_open(&array, &dict);
+ if (service)
+ append_properties(&dict, FALSE, service);
+ connman_dbus_dict_close(&array, &dict);
+
+ return reply;
+}
+#endif
+
void __connman_service_set_proxy_autoconfig(struct connman_service *service,
const char *url)
{
service->identity);
}
+void __connman_service_set_anonymous_identity(struct connman_service *service,
+ const char *anonymous_identity)
+{
+ if (service->immutable || service->hidden)
+ return;
+
+ g_free(service->anonymous_identity);
+ service->anonymous_identity = g_strdup(anonymous_identity);
+
+ if (service->network)
+ connman_network_set_string(service->network,
+ "WiFi.AnonymousIdentity",
+ service->anonymous_identity);
+}
+
+void __connman_service_set_subject_match(struct connman_service *service,
+ const char *subject_match)
+{
+ if (service->immutable || service->hidden)
+ return;
+
+ g_free(service->subject_match);
+ service->subject_match = g_strdup(subject_match);
+
+ if (service->network)
+ connman_network_set_string(service->network,
+ "WiFi.SubjectMatch",
+ service->subject_match);
+}
+
+void __connman_service_set_altsubject_match(struct connman_service *service,
+ const char *altsubject_match)
+{
+ if (service->immutable || service->hidden)
+ return;
+
+ g_free(service->altsubject_match);
+ service->altsubject_match = g_strdup(altsubject_match);
+
+ if (service->network)
+ connman_network_set_string(service->network,
+ "WiFi.AltSubjectMatch",
+ service->altsubject_match);
+}
+
+void __connman_service_set_domain_suffix_match(struct connman_service *service,
+ const char *domain_suffix_match)
+{
+ if (service->immutable || service->hidden)
+ return;
+
+ g_free(service->domain_suffix_match);
+ service->domain_suffix_match = g_strdup(domain_suffix_match);
+
+ if (service->network)
+ connman_network_set_string(service->network,
+ "WiFi.DomainSuffixMatch",
+ service->domain_suffix_match);
+}
+
+void __connman_service_set_domain_match(struct connman_service *service,
+ const char *domain_match)
+{
+ if (service->immutable || service->hidden)
+ return;
+
+ g_free(service->domain_match);
+ service->domain_match = g_strdup(domain_match);
+
+ if (service->network)
+ connman_network_set_string(service->network,
+ "WiFi.DomainMatch",
+ service->domain_match);
+}
+
void __connman_service_set_agent_identity(struct connman_service *service,
const char *agent_identity)
{
service->agent_identity);
}
-static int check_passphrase(enum connman_service_security security,
+int __connman_service_check_passphrase(enum connman_service_security security,
const char *passphrase)
{
guint i;
case CONNMAN_SERVICE_SECURITY_PSK:
#if defined TIZEN_EXT
case CONNMAN_SERVICE_SECURITY_RSN:
+ /* TO CHECK: We need to check the key length supported by SAE */
+ case CONNMAN_SERVICE_SECURITY_SAE:
#endif
/* A raw key is always 64 bytes length,
* its content is in hex representation.
break;
case CONNMAN_SERVICE_SECURITY_8021X:
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_OWE:
+ case CONNMAN_SERVICE_SECURITY_DPP:
+#endif
break;
}
service->security != CONNMAN_SERVICE_SECURITY_8021X)
return -EINVAL;
- err = check_passphrase(service->security, passphrase);
+#if defined TIZEN_EXT
+ if (service->immutable &&
+ service->security != CONNMAN_SERVICE_SECURITY_DPP)
+ return -EINVAL;
+ /* The encrypted passphrase is used here
+ * and validation is done by net-config before being encrypted.
+ */
+ err = 0;
+ if (service->security != CONNMAN_SERVICE_SECURITY_PSK &&
+ service->security != CONNMAN_SERVICE_SECURITY_RSN &&
+ service->security != CONNMAN_SERVICE_SECURITY_SAE &&
+ service->security != CONNMAN_SERVICE_SECURITY_WEP)
+#endif
+ err = __connman_service_check_passphrase(service->security, passphrase);
if (err < 0)
return err;
connman_network_set_string(service->network, "WiFi.Passphrase",
service->passphrase);
- return 0;
+ return 0;
+}
+
+const char *__connman_service_get_passphrase(struct connman_service *service)
+{
+ if (!service)
+ return NULL;
+
+ return service->passphrase;
+}
+
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+int __connman_service_get_use_eapol(struct connman_service *service)
+{
+ if (!service) {
+ DBG("Service is NULL");
+ return -1;
+ }
+
+ return service->use_eapol;
}
-const char *__connman_service_get_passphrase(struct connman_service *service)
+int __connman_service_get_connect_reason(struct connman_service *service)
{
- if (!service)
- return NULL;
+ if (!service) {
+ DBG("Service is NULL");
+ return -1;
+ }
- return service->passphrase;
+ return service->connect_reason;
}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *user_data)
DBusMessage *reply;
DBusMessageIter array, dict;
- DBG("service %p", service);
-
reply = dbus_message_new_method_return(msg);
if (!reply)
return NULL;
return reply;
}
+static char **remove_empty_strings(char **strv)
+{
+ int index = 0;
+ char **iter = strv;
+
+ while (*iter) {
+ if (**iter)
+ strv[index++] = *iter;
+ else
+ g_free(*iter);
+ iter++;
+ }
+
+ strv[index] = NULL;
+ return strv;
+}
+
static int update_proxy_configuration(struct connman_service *service,
DBusMessageIter *array)
{
if (servers_str) {
g_strfreev(service->proxies);
- if (servers_str->len > 0)
- service->proxies = g_strsplit_set(
+ if (servers_str->len > 0) {
+ char **proxies = g_strsplit_set(
servers_str->str, " ", 0);
- else
+ proxies = remove_empty_strings(proxies);
+ service->proxies = proxies;
+ } else
service->proxies = NULL;
}
if (excludes_str) {
g_strfreev(service->excludes);
- if (excludes_str->len > 0)
- service->excludes = g_strsplit_set(
+ if (excludes_str->len > 0) {
+ char **excludes = g_strsplit_set(
excludes_str->str, " ", 0);
- else
+ excludes = remove_empty_strings(excludes);
+ service->excludes = excludes;
+ } else
service->excludes = NULL;
}
g_free(service->pac);
if (url && strlen(url) > 0)
- service->pac = g_strdup(url);
+ service->pac = g_strstrip(g_strdup(url));
else
service->pac = NULL;
return -EINVAL;
}
+static void do_auto_connect(struct connman_service *service,
+ enum connman_service_connect_reason reason)
+{
+ /*
+ * CONNMAN_SERVICE_CONNECT_REASON_NONE must be ignored for VPNs. VPNs
+ * always have reason CONNMAN_SERVICE_CONNECT_REASON_USER/AUTO.
+ */
+ if (!service || (service->type == CONNMAN_SERVICE_TYPE_VPN &&
+ reason == CONNMAN_SERVICE_CONNECT_REASON_NONE))
+ return;
+
+ /*
+ * Run service auto connect for other than VPN services. Afterwards
+ * start also VPN auto connect process.
+ */
+ if (service->type != CONNMAN_SERVICE_TYPE_VPN)
+ __connman_service_auto_connect(reason);
+ /* Only user interaction should get VPN connected in failure state. */
+ else if (service->state == CONNMAN_SERVICE_STATE_FAILURE &&
+ reason != CONNMAN_SERVICE_CONNECT_REASON_USER)
+ return;
+
+ vpn_auto_connect();
+}
+
int __connman_service_reset_ipconfig(struct connman_service *service,
enum connman_ipconfig_type type, DBusMessageIter *array,
enum connman_service_state *new_state)
new_method = __connman_ipconfig_get_method(new_ipconfig);
}
- if (is_connecting_state(service, state) ||
- is_connected_state(service, state))
+ if (is_connecting(state) || is_connected(state))
__connman_network_clear_ipconfig(service->network, ipconfig);
__connman_ipconfig_unref(ipconfig);
else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
service->ipconfig_ipv6 = new_ipconfig;
- if (is_connecting_state(service, state) ||
- is_connected_state(service, state))
+ if (is_connecting(state) || is_connected(state))
__connman_ipconfig_enable(new_ipconfig);
if (new_state && new_method != old_method) {
else
*new_state = service->state_ipv6;
- __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+ settings_changed(service, new_ipconfig);
+ address_updated(service, type);
+
+ do_auto_connect(service, CONNMAN_SERVICE_CONNECT_REASON_AUTO);
}
DBG("err %d ipconfig %p type %d method %d state %s", err,
return err;
}
+/*
+ * We set the timeout to 1 sec so that we have a chance to get
+ * necessary IPv6 router advertisement messages that might have
+ * DNS data etc.
+ */
+#define ONLINE_CHECK_INITIAL_INTERVAL 1
+#define ONLINE_CHECK_MAX_INTERVAL 12
+
+void __connman_service_wispr_start(struct connman_service *service,
+ enum connman_ipconfig_type type)
+{
+ DBG("service %p type %s", service, __connman_ipconfig_type2string(type));
+
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ service->online_check_interval_ipv4 =
+ ONLINE_CHECK_INITIAL_INTERVAL;
+ else
+ service->online_check_interval_ipv6 =
+ ONLINE_CHECK_INITIAL_INTERVAL;
+
+ __connman_wispr_start(service, type);
+}
+
+static void set_error(struct connman_service *service,
+ enum connman_service_error error);
+
static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __connman_error_invalid_arguments(msg);
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI && is_connected(service)) {
- uid_t uid;
- if (connman_dbus_get_connection_unix_user_sync(conn,
- dbus_message_get_sender(msg),
- &uid) < 0) {
- DBG("Can not get unix user id!");
- return __connman_error_permission_denied(msg);
- }
-
- if (!connman_service_is_user_allowed(service, uid)) {
- DBG("Not allow this user to operate this wifi service now!");
- return __connman_error_permission_denied(msg);
- }
- }
-
dbus_message_iter_get_basic(&iter, &name);
dbus_message_iter_next(&iter);
dbus_message_iter_get_basic(&value, &autoconnect);
- if (service->autoconnect == autoconnect)
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-
- service->autoconnect = autoconnect;
-
- autoconnect_changed(service);
+ if (autoconnect && service->type == CONNMAN_SERVICE_TYPE_VPN) {
+ /*
+ * Changing the autoconnect flag on VPN to "on" should
+ * have the same effect as user connecting the VPN =
+ * clear previous error and change state to idle.
+ */
+ set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
- if (autoconnect)
- __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+ if (service->state == CONNMAN_SERVICE_STATE_FAILURE) {
+ service->state = CONNMAN_SERVICE_STATE_IDLE;
+ state_changed(service);
+ }
+ }
- service_save(service);
+ if (connman_service_set_autoconnect(service, autoconnect)) {
+ service_save(service);
+ if (autoconnect)
+ do_auto_connect(service,
+ CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+ }
} else if (g_str_equal(name, "Nameservers.Configuration")) {
DBusMessageIter entry;
GString *str;
gw = __connman_ipconfig_get_gateway_from_index(index,
CONNMAN_IPCONFIG_TYPE_ALL);
+#if !defined TIZEN_EXT
if (gw && strlen(gw))
__connman_service_nameserver_del_routes(service,
CONNMAN_IPCONFIG_TYPE_ALL);
+#endif
dbus_message_iter_recurse(&value, &entry);
#if defined TIZEN_EXT
continue;
}
#endif
- if (connman_inet_check_ipaddress(val) > 0) {
- if (str->len > 0)
- g_string_append_printf(str, " %s", val);
- else
- g_string_append(str, val);
- }
+ if (!val[0])
+ continue;
+
+ if (str->len > 0)
+ g_string_append_printf(str, " %s", val);
+ else
+ g_string_append(str, val);
}
#if defined TIZEN_EXT
DBG("%s ip_type: %d nameserver remove all", name, ip_type);
nameserver_remove_all(service, ip_type);
#else
- nameserver_remove_all(service);
+ nameserver_remove_all(service, CONNMAN_IPCONFIG_TYPE_ALL);
#endif
g_strfreev(service->nameservers_config);
if (str->len > 0) {
- service->nameservers_config =
- g_strsplit_set(str->str, " ", 0);
+ char **nameservers, **iter;
+
+ nameservers = g_strsplit_set(str->str, " ", 0);
+
+ for (iter = nameservers; *iter; iter++)
+ if (connman_inet_check_ipaddress(*iter) <= 0)
+ *iter[0] = '\0';
+
+ nameservers = remove_empty_strings(nameservers);
+ service->nameservers_config = nameservers;
} else {
service->nameservers_config = NULL;
}
DBG("%s ip_type: %d nameserver add all", name, ip_type);
nameserver_add_all(service, ip_type);
#else
- nameserver_add_all(service);
+ nameserver_add_all(service, CONNMAN_IPCONFIG_TYPE_ALL);
#endif
dns_configuration_changed(service);
if (__connman_service_is_connected_state(service,
CONNMAN_IPCONFIG_TYPE_IPV4))
- __connman_wispr_start(service,
- CONNMAN_IPCONFIG_TYPE_IPV4);
+ __connman_service_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV4);
if (__connman_service_is_connected_state(service,
CONNMAN_IPCONFIG_TYPE_IPV6))
- __connman_wispr_start(service,
- CONNMAN_IPCONFIG_TYPE_IPV6);
+ __connman_service_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV6);
service_save(service);
} else if (g_str_equal(name, "Timeservers.Configuration")) {
DBusMessageIter entry;
- GSList *list = NULL;
- int count = 0;
+ GString *str;
if (service->immutable)
return __connman_error_not_supported(msg);
if (type != DBUS_TYPE_ARRAY)
return __connman_error_invalid_arguments(msg);
+ str = g_string_new(NULL);
+ if (!str)
+ return __connman_error_invalid_arguments(msg);
+
dbus_message_iter_recurse(&value, &entry);
while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) {
const char *val;
- GSList *new_head;
-
dbus_message_iter_get_basic(&entry, &val);
+ dbus_message_iter_next(&entry);
- new_head = __connman_timeserver_add_list(list, val);
- if (list != new_head) {
- count++;
- list = new_head;
- }
+ if (!val[0])
+ continue;
- dbus_message_iter_next(&entry);
+ if (str->len > 0)
+ g_string_append_printf(str, " %s", val);
+ else
+ g_string_append(str, val);
}
g_strfreev(service->timeservers_config);
service->timeservers_config = NULL;
- if (list) {
- service->timeservers_config = g_new0(char *, count+1);
-
- while (list) {
- count--;
- service->timeservers_config[count] = list->data;
- list = g_slist_delete_link(list, list);
- };
+ if (str->len > 0) {
+ char **timeservers = g_strsplit_set(str->str, " ", 0);
+ timeservers = remove_empty_strings(timeservers);
+ service->timeservers_config = timeservers;
}
+ g_string_free(str, TRUE);
+
service_save(service);
timeservers_configuration_changed(service);
- if (service == __connman_service_get_default())
+ if (service == connman_service_get_default())
__connman_timeserver_sync(service);
} else if (g_str_equal(name, "Domains.Configuration")) {
const char *val;
dbus_message_iter_get_basic(&entry, &val);
dbus_message_iter_next(&entry);
+
+ if (!val[0])
+ continue;
+
if (str->len > 0)
g_string_append_printf(str, " %s", val);
else
searchdomain_remove_all(service);
g_strfreev(service->domains);
- if (str->len > 0)
- service->domains = g_strsplit_set(str->str, " ", 0);
- else
+ if (str->len > 0) {
+ char **domains = g_strsplit_set(str->str, " ", 0);
+ domains = remove_empty_strings(domains);
+ service->domains = domains;
+ } else
service->domains = NULL;
g_string_free(str, TRUE);
__connman_notifier_proxy_changed(service);
service_save(service);
+ } else if (g_str_equal(name, "mDNS.Configuration")) {
+ dbus_bool_t val;
+
+ if (service->immutable)
+ return __connman_error_not_supported(msg);
+
+ if (type != DBUS_TYPE_BOOLEAN)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &val);
+ service->mdns_config = val;
+
+ mdns_configuration_changed(service);
+
+ set_mdns(service, service->mdns_config);
+
+ service_save(service);
} else if (g_str_equal(name, "IPv4.Configuration") ||
g_str_equal(name, "IPv6.Configuration")) {
&state);
if (err < 0) {
- if (is_connected_state(service, state) ||
- is_connecting_state(service, state)) {
+ if (is_connected(state) || is_connecting(state)) {
if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
__connman_network_enable_ipconfig(service->network,
service->ipconfig_ipv4);
else
ipv6_configuration_changed(service);
- if (is_connecting(service) || is_connected(service)) {
+ if (is_connecting(service->state) ||
+ is_connected(service->state)) {
if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
__connman_network_enable_ipconfig(service->network,
service->ipconfig_ipv4);
}
service_save(service);
+#if defined TIZEN_EXT
+ /* When AP is connected using WPS without SSID then its password needs
+ * to be saved for autoconnection */
+ } else if (g_str_equal(name, "Passphrase")) {
+ char *passphrase;
+
+ if (type != DBUS_TYPE_STRING)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &passphrase);
+
+ __connman_service_set_passphrase(service, passphrase);
+#endif
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ } else if (g_str_equal(name, "EapOverEthernet")) {
+ int err = connman_service_set_eapol_property(service, &value);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
+
+ service->connect_reason = CONNMAN_SERVICE_CONNECT_REASON_USER;
+ service_save(service);
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
} else
return __connman_error_invalid_property(msg);
DBUS_TYPE_STRING, &str);
}
-static void set_idle(struct connman_service *service)
+static void remove_timeout(struct connman_service *service)
{
- service->state = service->state_ipv4 = service->state_ipv6 =
- CONNMAN_SERVICE_STATE_IDLE;
- set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
- state_changed(service);
+ if (service->timeout > 0) {
+ g_source_remove(service->timeout);
+ service->timeout = 0;
+ }
+}
+
+static void reply_pending(struct connman_service *service, int error)
+{
+ remove_timeout(service);
+
+ if (service->pending) {
+ connman_dbus_reply_pending(service->pending, error, NULL);
+ service->pending = NULL;
+ }
+
+ if (service->provider_pending) {
+ connman_dbus_reply_pending(service->provider_pending,
+ error, service->path);
+ service->provider_pending = NULL;
+ }
+}
+
+static void service_complete(struct connman_service *service)
+{
+ reply_pending(service, EIO);
+
+ if (service->connect_reason != CONNMAN_SERVICE_CONNECT_REASON_USER)
+ do_auto_connect(service, service->connect_reason);
+
+ gettimeofday(&service->modified, NULL);
+ service_save(service);
}
static DBusMessage *clear_property(DBusConnection *conn,
if (g_str_equal(name, "Error")) {
set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
- g_get_current_time(&service->modified);
- service_save(service);
+ __connman_service_clear_error(service);
+ service_complete(service);
} else
return __connman_error_invalid_property(msg);
if (!service->autoconnect)
return true;
- if (service->roaming)
+ if (service->roaming &&
+ !connman_setting_get_bool("AutoConnectRoamingServices"))
return true;
if (service->ignore)
}
static int active_sessions[MAX_CONNMAN_SERVICE_TYPES] = {};
+static int always_connect[MAX_CONNMAN_SERVICE_TYPES] = {};
static int active_count = 0;
void __connman_service_set_active_session(bool enable, GSList *list)
else
active_count--;
- while (list != NULL) {
+ while (list) {
enum connman_service_type type = GPOINTER_TO_INT(list->data);
switch (type) {
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_VPN:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
break;
}
tech_data->preferred_list =
g_list_append(tech_data->preferred_list, service);
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("type %d service %p %s", tech_data->type, service,
service->name);
}
for (list = service_list; list; list = list->next) {
struct connman_service *service = list->data;
- if (!is_connected(service))
+ if (!is_connected(service->state))
break;
if (service->connect_reason ==
return tech_data.preferred_list;
}
+static void set_always_connecting_technologies()
+{
+ unsigned int *always_connected_techs =
+ connman_setting_get_uint_list("AlwaysConnectedTechnologies");
+ int i;
+ for (i = 0; always_connected_techs && always_connected_techs[i]; i++)
+ always_connect[always_connected_techs[i]] = 1;
+}
+
+static bool autoconnect_no_session_active(struct connman_service *service)
+{
+ /*
+ * Test active_count to see if there are no sessions set up and
+ * stop autoconnecting, but continue connecting if the service
+ * belongs to a technology which should always autoconnect.
+ */
+ if (!active_count && !always_connect[service->type])
+ return true;
+
+ return false;
+}
+
+static bool autoconnect_already_connecting(struct connman_service *service,
+ bool autoconnecting)
+{
+ /*
+ * If another service is already connecting and this service type has
+ * not been marked as always connecting, stop the connecting procedure.
+ */
+ if (autoconnecting &&
+ !active_sessions[service->type] &&
+ !always_connect[service->type])
+ return true;
+
+ return false;
+}
+
+static int service_indicate_state(struct connman_service *service);
+
static bool auto_connect_service(GList *services,
enum connman_service_connect_reason reason,
bool preferred)
bool ignore[MAX_CONNMAN_SERVICE_TYPES] = { };
bool autoconnecting = false;
GList *list;
+#if defined TIZEN_EXT
+ GSList *wifi_ignore = NULL;
+#endif
DBG("preferred %d sessions %d reason %s", preferred, active_count,
reason2string(reason));
ignore[CONNMAN_SERVICE_TYPE_VPN] = true;
+#if defined TIZEN_EXT_WIFI_MESH
+ /* Don't auto connect wifi if mesh interface is created */
+ if (connman_mesh_is_interface_created())
+ ignore[CONNMAN_SERVICE_TYPE_WIFI] = true;
+#endif
+
for (list = services; list; list = list->next) {
service = list->data;
+#if defined TIZEN_EXT
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
+ int index = connman_network_get_index(service->network);
+ if (g_slist_find(wifi_ignore, GINT_TO_POINTER(index)) != NULL)
+ continue;
+ } else
+#endif
if (ignore[service->type]) {
DBG("service %p type %s ignore", service,
__connman_service_type2string(service->type));
/* Tizen takes Wi-Fi as the highest priority into consideration. */
if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
- if (is_connecting(service) == TRUE || is_connected(service) == TRUE)
+ if (is_connecting(service->state) == TRUE || is_connected(service->state) == TRUE)
continue;
#endif
if (service->pending ||
- is_connecting(service) ||
- is_connected(service)) {
- if (!active_count)
- return true;
+ is_connecting(service->state) ||
+ is_connected(service->state)) {
+#if defined TIZEN_EXT
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
+ int index = connman_network_get_index(service->network);
+ wifi_ignore = g_slist_prepend(wifi_ignore, GINT_TO_POINTER(index));
+ autoconnecting = true;
+ continue;
+ }
+#else
+ if (autoconnect_no_session_active(service))
+ return true;
+#endif
ignore[service->type] = true;
autoconnecting = true;
#if defined TIZEN_EXT
DBG("Service is not favorite, autoconnecting %d",
autoconnecting);
+ g_slist_free(wifi_ignore);
#endif
return autoconnecting;
}
if (is_ignore(service) || service->state !=
CONNMAN_SERVICE_STATE_IDLE)
continue;
-
- if (autoconnecting && !active_sessions[service->type]) {
+#if defined TIZEN_EXT
+ if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
+#endif
+ if (autoconnect_already_connecting(service, autoconnecting)) {
DBG("service %p type %s has no users", service,
__connman_service_type2string(service->type));
continue;
}
- if (!is_service_owner_user_login(service)) {
- DBG("favorite user not login, wifi auto connect denied");
- continue;
- }
-
DBG("service %p %s %s", service, service->name,
(preferred) ? "preferred" : reason2string(reason));
+#if defined TIZEN_EXT
__connman_service_connect(service, reason);
+#else
+ if (__connman_service_connect(service, reason) == 0)
+ service_indicate_state(service);
- if (!active_count)
+ if (autoconnect_no_session_active(service))
return true;
-
+#endif
+#if defined TIZEN_EXT
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
+ int index = connman_network_get_index(service->network);
+ wifi_ignore = g_slist_prepend(wifi_ignore, GINT_TO_POINTER(index));
+ autoconnecting = true;
+ }
+#endif
ignore[service->type] = true;
}
-
+#if defined TIZEN_EXT
+ g_slist_free(wifi_ignore);
+#endif
return autoconnecting;
}
bool autoconnecting = false;
GList *preferred_tech;
- autoconnect_timeout = 0;
+ autoconnect_id = 0;
DBG("");
return FALSE;
}
+#if defined TIZEN_EXT
+bool __connman_service_get_auto_connect_mode(void)
+{
+ return auto_connect_mode;
+}
+
+void __connman_service_set_auto_connect_mode(bool enable)
+{
+ DBG("set auto_connect_mode = %d", enable);
+
+ if (auto_connect_mode != enable)
+ auto_connect_mode = enable;
+}
+#endif
+
void __connman_service_auto_connect(enum connman_service_connect_reason reason)
{
DBG("");
- if (autoconnect_timeout != 0)
+ if (autoconnect_id != 0)
+ return;
+
+#if defined TIZEN_EXT
+ if (auto_connect_mode == FALSE) {
+ DBG("Currently, not auto connection mode");
return;
+ }
+#endif
if (!__connman_session_policy_autoconnect(reason))
return;
* FAILURE state due to this when connection with AP2 is cancelled
* then autoconnect with AP1 doesn't works because its autoconnection
* is ignored as its last state was FAILURE rather than IDLE */
- autoconnect_timeout = g_timeout_add(500, run_auto_connect,
+ autoconnect_id = g_timeout_add(500, run_auto_connect,
#else
- autoconnect_timeout = g_timeout_add_seconds(0, run_auto_connect,
+ autoconnect_id = g_idle_add(run_auto_connect,
#endif
GUINT_TO_POINTER(reason));
}
static gboolean run_vpn_auto_connect(gpointer data) {
GList *list;
bool need_split = false;
+ bool autoconnectable_vpns = false;
+ int attempts = 0;
+ int timeout = VPN_AUTOCONNECT_TIMEOUT_DEFAULT;
+ struct connman_service *def_service;
+
+ attempts = GPOINTER_TO_INT(data);
+ def_service = connman_service_get_default();
- vpn_autoconnect_timeout = 0;
+ /*
+ * Stop auto connecting VPN if there is no transport service or the
+ * transport service is not connected or if the current default service
+ * is a connected VPN (in ready state).
+ */
+ if (!def_service || !is_connected(def_service->state) ||
+ (def_service->type == CONNMAN_SERVICE_TYPE_VPN &&
+ is_connected(def_service->state))) {
+
+ DBG("stopped, default service %s connected %d",
+ def_service ? def_service->identifier : "NULL",
+ def_service ? is_connected(def_service->state) : -1);
+ goto out;
+ }
for (list = service_list; list; list = list->next) {
struct connman_service *service = list->data;
if (service->type != CONNMAN_SERVICE_TYPE_VPN)
continue;
- if (is_connected(service) || is_connecting(service)) {
+ if (is_connected(service->state) ||
+ is_connecting(service->state)) {
if (!service->do_split_routing)
need_split = true;
+
+ /*
+ * If the service is connecting it must be accounted
+ * for to keep the autoconnection in main loop.
+ */
+ if (is_connecting(service->state))
+ autoconnectable_vpns = true;
+
continue;
}
res = __connman_service_connect(service,
CONNMAN_SERVICE_CONNECT_REASON_AUTO);
- if (res < 0 && res != -EINPROGRESS)
+
+ switch (res) {
+ case 0:
+ service_indicate_state(service);
+ /* fall through */
+ case -EINPROGRESS:
+ autoconnectable_vpns = true;
+ break;
+ default:
continue;
+ }
if (!service->do_split_routing)
need_split = true;
}
- return FALSE;
-}
+ /* Stop if there is no VPN to automatically connect.*/
+ if (!autoconnectable_vpns) {
+ DBG("stopping, no autoconnectable VPNs found");
+ goto out;
+ }
-static void vpn_auto_connect(void)
-{
- if (vpn_autoconnect_timeout)
- return;
+ /* Increase the attempt count up to the threshold.*/
+ if (attempts < VPN_AUTOCONNECT_TIMEOUT_ATTEMPTS_THRESHOLD)
+ attempts++;
- vpn_autoconnect_timeout =
- g_timeout_add_seconds(0, run_vpn_auto_connect, NULL);
-}
+ /*
+ * Timeout increases with 1s after VPN_AUTOCONNECT_TIMEOUT_STEP amount
+ * of attempts made. After VPN_AUTOCONNECT_TIMEOUT_ATTEMPTS_THRESHOLD is
+ * reached the delay does not increase.
+ */
+ timeout = timeout + (int)(attempts / VPN_AUTOCONNECT_TIMEOUT_STEP);
+
+ /* Re add this to main loop */
+ vpn_autoconnect_id =
+ g_timeout_add_seconds(timeout, run_vpn_auto_connect,
+ GINT_TO_POINTER(attempts));
+
+ DBG("re-added to main loop, next VPN autoconnect in %d seconds (#%d)",
+ timeout, attempts);
+
+ return G_SOURCE_REMOVE;
-static void remove_timeout(struct connman_service *service)
-{
- if (service->timeout > 0) {
- g_source_remove(service->timeout);
- service->timeout = 0;
- }
+out:
+ vpn_autoconnect_id = 0;
+ return G_SOURCE_REMOVE;
}
-static void reply_pending(struct connman_service *service, int error)
+static void vpn_auto_connect(void)
{
- remove_timeout(service);
-
- if (service->pending) {
- connman_dbus_reply_pending(service->pending, error, NULL);
- service->pending = NULL;
+ /*
+ * Remove existing autoconnect from main loop to reset the attempt
+ * counter in order to get VPN connected when there is a network change.
+ */
+ if (vpn_autoconnect_id) {
+ if (!g_source_remove(vpn_autoconnect_id))
+ return;
}
- if (service->provider_pending) {
- connman_dbus_reply_pending(service->provider_pending,
- error, service->path);
- service->provider_pending = NULL;
- }
+ vpn_autoconnect_id =
+ g_idle_add(run_vpn_auto_connect, NULL);
}
bool
}
service->provider_pending = msg;
- return;
}
static void check_pending_msg(struct connman_service *service)
else if (service->provider)
connman_provider_disconnect(service->provider);
- __connman_ipconfig_disable(service->ipconfig_ipv4);
- __connman_ipconfig_disable(service->ipconfig_ipv6);
-
__connman_stats_service_unregister(service);
if (service->pending) {
if (autoconnect &&
service->connect_reason !=
CONNMAN_SERVICE_CONNECT_REASON_USER)
- __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+ do_auto_connect(service, CONNMAN_SERVICE_CONNECT_REASON_AUTO);
return FALSE;
}
*/
if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
connman_service_user_pdn_connection_ref(service);
-#endif
-
- if (service->pending)
- return __connman_error_in_progress(msg);
-
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
- uid_t uid;
- if (connman_dbus_get_connection_unix_user_sync(conn,
- dbus_message_get_sender(msg),
- &uid) < 0) {
- DBG("Can not get unix user id!");
- return __connman_error_permission_denied(msg);
- }
- if (!__connman_service_is_user_allowed(CONNMAN_SERVICE_TYPE_WIFI, uid)) {
- DBG("Not allow this user to connect this wifi service now!");
- return __connman_error_permission_denied(msg);
- }
+ /*Reset the Disconnect Reason while issue connect request*/
+ service->disconnect_reason = 0;
- if (uid != USER_ROOT && uid != service->user.favorite_user)
- service->request_passphrase_input = true;
+ /*Reset the association status code while issue connect request*/
+ service->assoc_status_code = 0;
- service->user.current_user = uid;
+ /* Reset the disconnection_requested while issue connect request*/
+ connman_service_set_disconnection_requested(service, false);
+#endif
- if (!service->passphrase && uid == service->user.favorite_user) {
- DBG("Now load this favorite user's passphrase.");
- service_load_passphrase(service);
- }
- }
+ if (service->pending)
+ return __connman_error_in_progress(msg);
#if !defined TIZEN_EXT
index = __connman_service_get_index(service);
if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
break;
#endif
- if (!is_connecting(temp) && !is_connected(temp))
+ if (!is_connecting(temp->state) && !is_connected(temp->state))
break;
if (service == temp)
err = __connman_service_connect(service,
CONNMAN_SERVICE_CONNECT_REASON_USER);
- if (err == -EINPROGRESS)
- return NULL;
-
- if (service->pending) {
- dbus_message_unref(service->pending);
- service->pending = NULL;
- }
-
- if (err < 0)
- return __connman_error_failed(msg, -err);
+ if (err != -EINPROGRESS)
+ reply_pending(service, -err);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ return NULL;
}
static DBusMessage *disconnect_service(DBusConnection *conn,
if (connman_service_user_pdn_connection_unref_and_test(service) != TRUE)
return __connman_error_failed(msg, EISCONN);
- if (is_connected(service) == TRUE &&
+ if (is_connected(service->state) == TRUE &&
service == connman_service_get_default_connection())
return __connman_error_failed(msg, EISCONN);
}
#endif
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
- uid_t uid;
- if (connman_dbus_get_connection_unix_user_sync(conn,
- dbus_message_get_sender(msg),
- &uid) < 0) {
- DBG("Can not get unix user id!");
- return __connman_error_permission_denied(msg);
- }
-
- if (!connman_service_is_user_allowed(service, uid)) {
- DBG("Not allow this user to disconnect this wifi service now!");
- return __connman_error_permission_denied(msg);
- }
- }
-
service->ignore = true;
err = __connman_service_disconnect(service);
connman_network_set_string(service->network, "WiFi.PrivateKeyFile", NULL);
connman_network_set_string(service->network, "WiFi.PrivateKeyPassphrase", NULL);
connman_network_set_string(service->network, "WiFi.Phase2", NULL);
+ connman_network_set_string(service->network, "WiFi.AnonymousIdentity", NULL);
+}
+static void __connman_service_cleanup_network_dpp(struct connman_service *service)
+{
+ if (service == NULL)
+ return;
+
+ DBG("service %p ", service);
+
+ connman_network_set_string(service->network, "WiFi.Connector", NULL);
+ connman_network_set_string(service->network, "WiFi.CSignKey", NULL);
+ connman_network_set_string(service->network, "WiFi.NetAccessKey", NULL);
}
#endif
return false;
#if !defined TIZEN_EXT
- if (!service->favorite && service->state !=
- CONNMAN_SERVICE_STATE_FAILURE)
+ if (!service->favorite && !is_idle(service->state))
return false;
#endif
g_free(service->identity);
service->identity = NULL;
+ g_free(service->anonymous_identity);
+ service->anonymous_identity = NULL;
+
+ g_free(service->subject_match);
+ service->subject_match = NULL;
+
+ g_free(service->altsubject_match);
+ service->altsubject_match = NULL;
+
+ g_free(service->domain_suffix_match);
+ service->domain_suffix_match = NULL;
+
+ g_free(service->domain_match);
+ service->domain_match = NULL;
+
g_free(service->agent_identity);
service->agent_identity = NULL;
g_strfreev(service->nameservers_config);
service->nameservers_config = NULL;
-#endif
+ g_free(service->connector);
+ service->connector = NULL;
-#if defined TIZEN_EXT
- if (service->security != CONNMAN_SERVICE_SECURITY_8021X)
+ g_free(service->c_sign_key);
+ service->c_sign_key = NULL;
+
+ g_free(service->net_access_key);
+ service->net_access_key = NULL;
+
+ __connman_service_cleanup_network_dpp(service);
#endif
- set_idle(service);
service->error = CONNMAN_SERVICE_ERROR_UNKNOWN;
- service->user.favorite_user = USER_NONE;
-
__connman_service_set_favorite(service, false);
__connman_ipconfig_ipv6_reset_privacy(service->ipconfig_ipv6);
DBG("service %p", service);
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
- uid_t uid;
- if (connman_dbus_get_connection_unix_user_sync(conn,
- dbus_message_get_sender(msg),
- &uid) < 0) {
- DBG("Can not get unix user id!");
- return __connman_error_permission_denied(msg);
- }
-
-#if !defined TIZEN_EXT
- if (!connman_service_is_user_allowed(service, uid)) {
- DBG("Not allow this user to remove this wifi service now!");
- return __connman_error_permission_denied(msg);
- }
-#endif
- }
-
if (!__connman_service_remove(service))
return __connman_error_not_supported(msg);
{
struct connman_service *def_service;
- def_service = __connman_service_get_default();
+ def_service = connman_service_get_default();
if (!def_service)
return;
downgrade_state(downgrade_service);
}
+static struct _services_notify {
+ int id;
+ GHashTable *add;
+ GHashTable *remove;
+} *services_notify;
+
+
+static void service_append_added_foreach(gpointer data, gpointer user_data)
+{
+ struct connman_service *service = data;
+ DBusMessageIter *iter = user_data;
+
+ if (!service || !service->path) {
+ DBG("service %p or path is NULL", service);
+ return;
+ }
+
+ if (g_hash_table_lookup(services_notify->add, service->path)) {
+ DBG("new %s", service->path);
+
+ append_struct(service, iter);
+ g_hash_table_remove(services_notify->add, service->path);
+ } else {
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
+ DBG("changed %s", service->path);
+
+ append_struct_service(iter, NULL, service);
+ }
+}
+
+static void service_append_ordered(DBusMessageIter *iter, void *user_data)
+{
+ g_list_foreach(service_list, service_append_added_foreach, iter);
+}
+
+static void append_removed(gpointer key, gpointer value, gpointer user_data)
+{
+ char *objpath = key;
+ DBusMessageIter *iter = user_data;
+
+ DBG("removed %s", objpath);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &objpath);
+}
+
+static void service_append_removed(DBusMessageIter *iter, void *user_data)
+{
+ g_hash_table_foreach(services_notify->remove, append_removed, iter);
+}
+
+static gboolean service_send_changed(gpointer data)
+{
+ DBusMessage *signal;
+
+ DBG("");
+
+ services_notify->id = 0;
+
+ signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "ServicesChanged");
+ if (!signal)
+ return FALSE;
+
+ __connman_dbus_append_objpath_dict_array(signal,
+ service_append_ordered, NULL);
+ __connman_dbus_append_objpath_array(signal,
+ service_append_removed, NULL);
+
+ dbus_connection_send(connection, signal, NULL);
+ dbus_message_unref(signal);
+
+ g_hash_table_remove_all(services_notify->remove);
+ g_hash_table_remove_all(services_notify->add);
+
+ return FALSE;
+}
+
+static void service_schedule_changed(void)
+{
+ if (services_notify->id != 0)
+ return;
+
+ services_notify->id = g_timeout_add(100, service_send_changed, NULL);
+}
+
static DBusMessage *move_service(DBusConnection *conn,
DBusMessage *msg, void *user_data,
bool before)
return __connman_error_invalid_service(msg);
}
- target->do_split_routing = true;
+ set_split_routing(target, true);
} else
- target->do_split_routing = false;
+ set_split_routing(target, false);
- service->do_split_routing = false;
+ set_split_routing(service, false);
target4 = __connman_ipconfig_get_method(target->ipconfig_ipv4);
target6 = __connman_ipconfig_get_method(target->ipconfig_ipv6);
}
}
- g_get_current_time(&service->modified);
+ gettimeofday(&service->modified, NULL);
service_save(service);
service_save(target);
__connman_connection_update_gateway();
+ service_schedule_changed();
+
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-static DBusMessage *get_user_favorite(DBusConnection *conn,
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+static DBusMessage *is_eapol_enabled(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
- DBusMessage *reply;
- uid_t uid = USER_NONE;
- dbus_bool_t user_favorite = false;
struct connman_service *service = user_data;
+ DBG("service: %p path: %s UseEapol: %d", service, service->path, service->use_eapol);
- connman_dbus_get_connection_unix_user_sync(conn,
- dbus_message_get_sender(msg),
- &uid);
- if (uid == USER_ROOT)
- user_favorite = service->favorite;
- else if (uid != USER_NONE && uid == service->user.favorite_user) {
- DBG("The service is favorite to this user!");
- user_favorite = true;
- }
-
- reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
- dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN,
- &user_favorite, DBUS_TYPE_INVALID);
- return reply;
-}
-
-static struct _services_notify {
- int id;
- GHashTable *add;
- GHashTable *remove;
-} *services_notify;
-
-static void service_append_added_foreach(gpointer data, gpointer user_data)
-{
- struct connman_service *service = data;
- DBusMessageIter *iter = user_data;
-
- if (!service || !service->path) {
-#if !defined TIZEN_EXT
- DBG("service %p or path is NULL", service);
-#endif
- return;
- }
-
- if (g_hash_table_lookup(services_notify->add, service->path)) {
-#if !defined TIZEN_EXT
- DBG("new %s", service->path);
-#endif
-
- append_struct(service, iter);
- g_hash_table_remove(services_notify->add, service->path);
- } else {
-#if !defined TIZEN_EXT
- DBG("changed %s", service->path);
-#endif
+ dbus_bool_t eapol_status = service->use_eapol;
- append_struct_service(iter, NULL, service);
+ DBusMessage *reply = dbus_message_new_method_return(msg);
+ if (!reply) {
+ DBG("Failed to initialize reply");
+ return NULL;
}
-}
-
-static void service_append_ordered(DBusMessageIter *iter, void *user_data)
-{
- g_list_foreach(service_list, service_append_added_foreach, iter);
-}
-
-static void append_removed(gpointer key, gpointer value, gpointer user_data)
-{
- char *objpath = key;
- DBusMessageIter *iter = user_data;
-
- DBG("removed %s", objpath);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &objpath);
-}
-static void service_append_removed(DBusMessageIter *iter, void *user_data)
-{
- g_hash_table_foreach(services_notify->remove, append_removed, iter);
+ dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &eapol_status, DBUS_TYPE_INVALID);
+ return reply;
}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
-static gboolean service_send_changed(gpointer data)
+#if defined TIZEN_EXT
+static DBusMessage *downgrade_service(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
{
- DBusMessage *signal;
-
- DBG("");
-
- services_notify->id = 0;
-
- signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "ServicesChanged");
- if (!signal)
- return FALSE;
-
- __connman_dbus_append_objpath_dict_array(signal,
- service_append_ordered, NULL);
- __connman_dbus_append_objpath_array(signal,
- service_append_removed, NULL);
-
- dbus_connection_send(connection, signal, NULL);
- dbus_message_unref(signal);
-
- g_hash_table_remove_all(services_notify->remove);
- g_hash_table_remove_all(services_notify->add);
-
- return FALSE;
-}
+ struct connman_service *service = user_data;
-static void service_schedule_changed(void)
-{
- if (services_notify->id != 0)
- return;
+ downgrade_state(service);
+ __connman_connection_update_gateway();
+ start_online_check(service, CONNMAN_IPCONFIG_TYPE_IPV4);
- services_notify->id = g_timeout_add(100, service_send_changed, NULL);
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
+#endif
static void service_schedule_added(struct connman_service *service)
{
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("service %p", service);
g_hash_table_remove(services_notify->remove, service->path);
return FALSE;
#endif
if (g_hash_table_lookup_extended(services_notify->add, service->path,
- NULL, NULL)) {
- DBG("no property updates for service %p", service);
+ NULL, NULL))
return false;
- }
return true;
}
GDBUS_ARGS({ "service", "o" }), NULL,
move_after) },
{ GDBUS_METHOD("ResetCounters", NULL, NULL, reset_counters) },
- { GDBUS_METHOD("GetUserFavorite",
- NULL, GDBUS_ARGS({ "value", "v" }),
- get_user_favorite) },
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ { GDBUS_METHOD("IsEapolEnabled", NULL, GDBUS_ARGS({ "eapol", "b" }), is_eapol_enabled) },
+#endif
+#if defined TIZEN_EXT
+ { GDBUS_METHOD("Downgrade", NULL, NULL, downgrade_service) },
+#endif
{ },
};
static const GDBusSignalTable service_signals[] = {
{ GDBUS_SIGNAL("PropertyChanged",
GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+#if defined TIZEN_EXT
+ { GDBUS_SIGNAL("StateChangedProperties",
+ GDBUS_ARGS({ "properties", "a{sv}" })) },
+#endif
{ },
};
reply_pending(service, ENOENT);
+ if (service->nameservers_timeout) {
+ g_source_remove(service->nameservers_timeout);
+ dns_changed(service);
+ }
+
__connman_notifier_service_remove(service);
service_schedule_removed(service);
g_free(service->identifier);
g_free(service->eap);
g_free(service->identity);
+ g_free(service->anonymous_identity);
g_free(service->agent_identity);
g_free(service->ca_cert_file);
+ g_free(service->subject_match);
+ g_free(service->altsubject_match);
+ g_free(service->domain_suffix_match);
+ g_free(service->domain_match);
g_free(service->client_cert_file);
g_free(service->private_key_file);
g_free(service->private_key_passphrase);
g_free(service->phase2);
g_free(service->config_file);
g_free(service->config_entry);
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ g_free(service->pac_file);
+ g_free(service->phase1);
+#endif
+
+#if defined TIZEN_EXT
+ g_free(service->connector);
+ g_free(service->c_sign_key);
+ g_free(service->net_access_key);
+#endif
if (service->stats.timer)
g_timer_destroy(service->stats.timer);
static void service_initialize(struct connman_service *service)
{
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("service %p", service);
service->refcount = 1;
service->ignore = false;
- service->user.favorite_user = USER_NONE;
- service->user.current_user = USER_NONE;
-
- service->request_passphrase_input = false;
-
service->connect_reason = CONNMAN_SERVICE_CONNECT_REASON_NONE;
service->order = 0;
service->provider = NULL;
service->wps = false;
+ service->wps_advertizing = false;
+#if defined TIZEN_EXT
+ memset(service->last_connected_bssid, 0, WIFI_BSSID_LEN_MAX);
+ service->is_internet_connection = false;
+ service->assoc_reject_count = 0;
+#endif
#if defined TIZEN_EXT
+ service->disconnection_requested = false;
service->storage_reload = false;
/*
* Description: TIZEN implements system global connection management.
service->user_pdn_connection_refcount = 0;
__sync_synchronize();
#endif
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ service->use_eapol = false;
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
}
/**
g_hash_table_remove(service_hash, service->identifier);
}
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+static int calculate_score_last_user_selection(struct connman_service *service)
+{
+ int score = 0;
+ struct connman_device *device;
+ const char *last_user_selection_ident;
+ time_t last_user_selection_time;
+ unsigned int frequency;
+ time_t curr_time;
+ time_t ref_time;
+ struct tm* ref_timeinfo;
+
+ device = connman_network_get_device(service->network);
+ if (!device)
+ return 0;
+
+ last_user_selection_time = connman_device_get_last_user_selection_time(device);
+ last_user_selection_ident = connman_device_get_last_user_selection_ident(device);
+ frequency = connman_network_get_frequency(service->network);
+
+ if (ins_settings.last_user_selection) {
+ if (g_strcmp0(last_user_selection_ident, service->identifier) == 0 &&
+ (((frequency >= FREQ_RANGE_24GHZ_CHANNEL_1 &&
+ frequency <= FREQ_RANGE_24GHZ_CHANNEL_14) &&
+ service->strength >= ins_settings.signal_level3_24ghz) ||
+ ((frequency >= FREQ_RANGE_5GHZ_CHANNEL_32 &&
+ frequency <= FREQ_RANGE_5GHZ_CHANNEL_165) &&
+ service->strength >= ins_settings.signal_level3_5ghz))) {
+
+ /* Only events that occur within 8 hours are counted. */
+ curr_time = time(NULL);
+ ref_timeinfo = localtime(&curr_time);
+ ref_timeinfo->tm_hour -= 8;
+ ref_time = mktime(ref_timeinfo);
+
+ if (last_user_selection_time > ref_time) {
+ int time_diff = (curr_time - last_user_selection_time) / 60;
+ int denominator = ins_settings.last_user_selection_time - time_diff;
+ int numerator = ins_settings.last_user_selection_time /
+ ins_settings.last_user_selection_score;
+ int last_user_score = denominator / numerator;
+
+ score += (last_user_score > ins_settings.last_user_selection_score ?
+ ins_settings.last_user_selection_score : last_user_score);
+ }
+ }
+ }
+
+ return score;
+}
+
+static int calculate_score_last_connected(struct connman_service *service)
+{
+ int score = 0;
+ struct connman_device *device;
+ const char *last_connected_ident;
+ unsigned int frequency;
+
+ device = connman_network_get_device(service->network);
+ if (!device)
+ return 0;
+
+ last_connected_ident = connman_device_get_last_connected_ident(device);
+ frequency = connman_network_get_frequency(service->network);
+
+ if (ins_settings.last_connected) {
+ if (g_strcmp0(last_connected_ident, service->identifier) == 0 &&
+ (((frequency >= FREQ_RANGE_24GHZ_CHANNEL_1 &&
+ frequency <= FREQ_RANGE_24GHZ_CHANNEL_14) &&
+ service->strength >= ins_settings.signal_level3_24ghz) ||
+ ((frequency >= FREQ_RANGE_5GHZ_CHANNEL_32 &&
+ frequency <= FREQ_RANGE_5GHZ_CHANNEL_165) &&
+ service->strength >= ins_settings.signal_level3_5ghz))) {
+ score += ins_settings.last_connected_score;
+ }
+ }
+
+ return score;
+}
+
+static int calculate_score_frequency(struct connman_service *service)
+{
+ int score = 0;
+ unsigned int frequency;
+
+ frequency = connman_network_get_frequency(service->network);
+
+ switch (ins_settings.preferred_freq) {
+ case CONNMAN_INS_PREFERRED_FREQ_24GHZ:
+ if ((frequency >= FREQ_RANGE_24GHZ_CHANNEL_1 &&
+ frequency <= FREQ_RANGE_24GHZ_CHANNEL_14) &&
+ (service->strength >= ins_settings.signal_level3_24ghz))
+ score += ins_settings.preferred_freq_score;
+
+ break;
+ case CONNMAN_INS_PREFERRED_FREQ_5GHZ:
+ if ((frequency >= FREQ_RANGE_5GHZ_CHANNEL_32 &&
+ frequency <= FREQ_RANGE_5GHZ_CHANNEL_165) &&
+ (service->strength >= ins_settings.signal_level3_5ghz))
+ score += ins_settings.preferred_freq_score;
+
+ break;
+ default:
+ break;
+ }
+
+ return score;
+}
+
+static int calculate_score_security_priority(struct connman_service *service)
+{
+ int score = 0;
+
+ if (ins_settings.security_priority_count)
+ score += ins_settings.security_priority[service->security];
+
+ return score;
+}
+
+static int calculate_score_internet_connection(struct connman_service *service)
+{
+ int score = 0;
+
+ if (ins_settings.internet) {
+ if (service->is_internet_connection)
+ score += ins_settings.internet_score;
+ }
+
+ return score;
+}
+
+static int calculate_score_strength(struct connman_service *service)
+{
+ int score = 0;
+
+ if (ins_settings.signal)
+ score += (((service->strength > 60) ? 60 : service->strength) - 35);
+
+ return score;
+}
+
+static int calculate_score(struct connman_service *service)
+{
+ int score_last_user_selection;
+ int score_last_connected;
+ int score_frequency;
+ int score_security_priority;
+ int score_internet_connection;
+ int score_strength;
+ int score = 0;
+
+ if (service->type != CONNMAN_SERVICE_TYPE_WIFI) {
+ score += calculate_score_internet_connection(service);
+ service->ins_score = score;
+ return score;
+ }
+
+ score_last_user_selection = calculate_score_last_user_selection(service);
+ score_last_connected = calculate_score_last_connected(service);
+ score_frequency = calculate_score_frequency(service);
+ score_security_priority = calculate_score_security_priority(service);
+ score_internet_connection = calculate_score_internet_connection(service);
+ score_strength = calculate_score_strength(service);
+
+ score = score_last_user_selection + score_last_connected +
+ score_frequency + score_security_priority +
+ score_internet_connection + score_strength;
+
+ service->score_last_user_selection = score_last_user_selection;
+ service->score_last_connected = score_last_connected;
+ service->score_frequency = score_frequency;
+ service->score_security_priority = score_security_priority;
+ service->score_internet_connection = score_internet_connection;
+ service->score_strength = score_strength;
+
+ service->ins_score = score;
+ return score;
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
static gint service_compare(gconstpointer a, gconstpointer b)
{
struct connman_service *service_a = (void *) a;
struct connman_service *service_b = (void *) b;
enum connman_service_state state_a, state_b;
bool a_connected, b_connected;
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+ int score_a;
+ int score_b;
+#else /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
gint strength;
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
state_a = service_a->state;
state_b = service_b->state;
- a_connected = is_connected(service_a);
- b_connected = is_connected(service_b);
+ a_connected = is_connected(state_a);
+ b_connected = is_connected(state_b);
+
+#if defined TIZEN_EXT
+ if ((a_connected && b_connected) &&
+ state_a == state_b &&
+ service_a->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service_b->type == CONNMAN_SERVICE_TYPE_WIFI) {
+ const char *default_interface =
+ connman_option_get_string("DefaultWifiInterface");
+ const char *ifname_a = connman_device_get_string(
+ connman_network_get_device(service_a->network), "Interface");
+ const char *ifname_b = connman_device_get_string(
+ connman_network_get_device(service_b->network), "Interface");
+
+ if (g_strcmp0(default_interface, ifname_a) == 0)
+ return -1;
+ else if (g_strcmp0(default_interface, ifname_b) == 0)
+ return 1;
+ }
+#endif
if (a_connected && b_connected) {
if (service_a->order > service_b->order)
if (b_connected)
return 1;
- if (is_connecting(service_a))
+ if (is_connecting(state_a))
return -1;
- if (is_connecting(service_b))
+ if (is_connecting(state_b))
return 1;
}
return 1;
if (service_a->type != service_b->type) {
+ unsigned int *tech_array;
+ int i;
+
+ tech_array = connman_setting_get_uint_list(
+ "PreferredTechnologies");
+ if (tech_array) {
+ for (i = 0; tech_array[i]; i++) {
+ if (tech_array[i] == service_a->type)
+ return -1;
+
+ if (tech_array[i] == service_b->type)
+ return 1;
+ }
+ }
if (service_a->type == CONNMAN_SERVICE_TYPE_ETHERNET)
return -1;
return 1;
}
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+ score_a = calculate_score(service_a);
+ score_b = calculate_score(service_b);
+ if (score_b != score_a)
+ return score_b - score_a;
+#else /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
strength = (gint) service_b->strength - (gint) service_a->strength;
if (strength)
return strength;
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
return g_strcmp0(service_a->name, service_b->name);
}
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+static void print_service_sort(gpointer data, gpointer user_data)
+{
+ struct connman_service *service = data;
+
+ if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return;
+
+ DBG("name[%-20s] total[%2d] last_usr[%2d] last_conn[%2d] "
+ "freq[%2d] sec[%2d] internet[%2d] strength[%2d]",
+ service->name, service->ins_score, service->score_last_user_selection,
+ service->score_last_connected, service->score_frequency,
+ service->score_security_priority, service->score_internet_connection,
+ service->score_strength);
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
static void service_list_sort(void)
{
if (service_list && service_list->next) {
service_list = g_list_sort(service_list, service_compare);
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+ g_list_foreach(service_list, print_service_sort, NULL);
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
service_schedule_changed();
}
}
+int __connman_service_compare(const struct connman_service *a,
+ const struct connman_service *b)
+{
+ return service_compare(a, b);
+}
+
/**
* connman_service_get_type:
* @service: service structure
}
/**
- * __connman_service_is_user_allowed:
- * @type: service type
- * @uid: user id
- *
- * Check a user is allowed to operate a type of service
- */
-bool __connman_service_is_user_allowed(enum connman_service_type type,
- uid_t uid)
-{
- GList *list;
- uid_t owner_user = USER_NONE;
-
- for (list = service_list; list; list = list->next) {
- struct connman_service *service = list->data;
-
- if (service->type != type)
- continue;
-
- if (is_connected(service)) {
- owner_user = service->user.favorite_user;
- break;
- }
- }
-
- if (uid == USER_NONE ||
- (uid != USER_ROOT &&
- owner_user != USER_NONE &&
- owner_user != uid))
- return false;
-
- return true;
-}
-
-/**
* connman_service_get_network:
* @service: service structure
*
case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
break;
case CONNMAN_IPCONFIG_TYPE_IPV4:
- return is_connected_state(service, service->state_ipv4);
+ return is_connected(service->state_ipv4);
case CONNMAN_IPCONFIG_TYPE_IPV6:
- return is_connected_state(service, service->state_ipv6);
+ return is_connected(service->state_ipv6);
case CONNMAN_IPCONFIG_TYPE_ALL:
- return is_connected_state(service,
- CONNMAN_IPCONFIG_TYPE_IPV4) &&
- is_connected_state(service,
- CONNMAN_IPCONFIG_TYPE_IPV6);
+ return is_connected(service->state_ipv4) &&
+ is_connected(service->state_ipv6);
}
return false;
index2 = __connman_service_get_index(service2);
- if (is_connected(service2) && index2 > 0 && index1 == index2)
+ if (is_connected(service2->state) && index2 > 0 && index1 == index2)
count++;
index2 = 0;
service->favorite = favorite;
- if (!delay_ordering)
- __connman_service_get_order(service);
-
favorite_changed(service);
if (!delay_ordering) {
} else if (g_str_equal(key, "Identity")) {
g_free(service->identity);
service->identity = g_strdup(value);
+ } else if (g_str_equal(key, "AnonymousIdentity")) {
+ g_free(service->anonymous_identity);
+ service->anonymous_identity = g_strdup(value);
} else if (g_str_equal(key, "CACertFile")) {
g_free(service->ca_cert_file);
service->ca_cert_file = g_strdup(value);
+ } else if (g_str_equal(key, "SubjectMatch")) {
+ g_free(service->subject_match);
+ service->subject_match = g_strdup(value);
+ } else if (g_str_equal(key, "AltSubjectMatch")) {
+ g_free(service->altsubject_match);
+ service->altsubject_match = g_strdup(value);
+ } else if (g_str_equal(key, "DomainSuffixMatch")) {
+ g_free(service->domain_suffix_match);
+ service->domain_suffix_match = g_strdup(value);
+ } else if (g_str_equal(key, "DomainMatch")) {
+ g_free(service->domain_match);
+ service->domain_match = g_strdup(value);
} else if (g_str_equal(key, "ClientCertFile")) {
g_free(service->client_cert_file);
service->client_cert_file = g_strdup(value);
service->phase2 = g_strdup(value);
} else if (g_str_equal(key, "Passphrase"))
__connman_service_set_passphrase(service, value);
+#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
+ else if (g_str_equal(key, "Phase1")) {
+ g_free(service->phase1);
+ service->phase1 = g_strdup(value);
+ } else if (g_str_equal(key, "PacFile")) {
+ g_free(service->pac_file);
+ service->pac_file = g_strdup(value);
+ }
+#endif
+#if defined TIZEN_EXT
+ else if (g_str_equal(key, "Connector")) {
+ g_free(service->connector);
+ service->connector = g_strdup(value);
+ } else if (g_str_equal(key, "CSignKey")) {
+ g_free(service->c_sign_key);
+ service->c_sign_key = g_strdup(value);
+ } else if (g_str_equal(key, "NetAccessKey")) {
+ g_free(service->net_access_key);
+ service->net_access_key = g_strdup(value);
+ } else
+ DBG("Unknown key: %s", key);
+#endif
}
void __connman_service_set_search_domains(struct connman_service *service,
searchdomain_add_all(service);
}
-static void service_complete(struct connman_service *service)
+int __connman_service_set_mdns(struct connman_service *service,
+ bool enabled)
{
- reply_pending(service, EIO);
-
- if (service->connect_reason != CONNMAN_SERVICE_CONNECT_REASON_USER)
- __connman_service_auto_connect(service->connect_reason);
+ service->mdns_config = enabled;
- g_get_current_time(&service->modified);
- service_save(service);
+ return set_mdns(service, enabled);
}
static void report_error_cb(void *user_context, bool retry,
service->state_ipv4 = service->state_ipv6 =
CONNMAN_SERVICE_STATE_IDLE;
- if (service->error != CONNMAN_SERVICE_ERROR_AUTH_FAILED)
+ if (service->error != CONNMAN_SERVICE_ERROR_AUTH_FAILED &&
+ service->error != CONNMAN_SERVICE_ERROR_ASSOC_FAILED)
set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
#endif
service_complete(service);
if (g_strcmp0(error,
"net.connman.Agent.Error.Canceled") == 0) {
- err = -EINVAL;
+ err = -ECONNABORTED;
if (service->hidden)
__connman_service_return_error(service,
- ECANCELED, user_data);
- goto done;
+ ECONNABORTED,
+ user_data);
} else {
+ err = -ETIMEDOUT;
+
if (service->hidden)
__connman_service_return_error(service,
ETIMEDOUT, user_data);
}
+
+ goto done;
}
if (service->hidden && name_len > 0 && name_len <= 32) {
for (list = service_list; list; list = list->next) {
up_service = list->data;
- if (!is_connected(up_service))
+ if (!is_connected(up_service->state))
continue;
if (up_service->state == CONNMAN_SERVICE_STATE_ONLINE)
#if defined TIZEN_EXT
static gboolean __connman_service_can_drop(struct connman_service *service)
{
- if (is_connected(service) == TRUE || is_connecting(service) == TRUE) {
+ if (is_connected(service->state) == TRUE || is_connecting(service->state) == TRUE) {
if (service->type != CONNMAN_SERVICE_TYPE_CELLULAR)
return TRUE;
else if (connman_service_is_no_ref_user_pdn_connection(service) == TRUE)
static void __connman_service_disconnect_default(struct connman_service *service)
{
struct connman_device *default_device = NULL;
+ struct connman_network *network = __connman_service_get_network(service);
+
+ if (!network)
+ return;
if (default_connecting_device == NULL)
return;
- default_device = connman_network_get_device(
- __connman_service_get_network(service));
+ default_device = connman_network_get_device(network);
DBG("Disconnecting service %p %s", service, service->path);
DBG("Disconnecting device %p %p %s",
default_connecting_device = NULL;
}
+#if defined TIZEN_MAINTAIN_ONLINE
+static void __connman_service_connect_default(struct connman_service *current,
+ enum connman_service_state old_state)
+#else
static void __connman_service_connect_default(struct connman_service *current)
+#endif
{
int err;
GList *list;
}
return;
- } else if (is_connected(current) == TRUE || is_connecting(current) == TRUE)
+#if defined TIZEN_MAINTAIN_ONLINE
+ } else if (current->state == CONNMAN_SERVICE_STATE_READY &&
+ old_state == CONNMAN_SERVICE_STATE_ONLINE) {
+ DBG("Device is downgraded: online --> ready");
+#endif
+ } else if (is_connected(current->state) == TRUE || is_connecting(current->state) == TRUE)
return;
/* Always-on: keep default cellular connection as possible */
if (default_internet) {
default_service = service;
- if (is_connected(default_service) == TRUE ||
- is_connecting(default_service) == TRUE)
+ if (is_connected(default_service->state) == TRUE ||
+ is_connecting(default_service->state) == TRUE)
return;
default_device = connman_network_get_device(default_service->network);
if (service != allowed && service->type != allowed->type &&
__connman_service_can_drop(service) == TRUE)
#else
- if (!is_connected(service))
+ if (!is_connected(service->state))
break;
if (service == allowed)
continue;
#endif
+
services = g_slist_prepend(services, service);
}
for (list = service_list; list; list = list->next) {
service = list->data;
- if (is_connected(service) == FALSE)
+ if (is_connected(service->state) == FALSE)
service->order = 5;
else
+#if defined TIZEN_MAINTAIN_ONLINE
+ {
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+ service->state == CONNMAN_SERVICE_STATE_ONLINE)
+ service->order = 6;
+ else if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
+ service->order = 6;
+ else
+ service->order = 5;
+ }
+#else
service->order = 6;
+#endif
}
}
#endif
if (old_state == new_state)
return -EALREADY;
- def_service = __connman_service_get_default();
+ def_service = connman_service_get_default();
if (new_state == CONNMAN_SERVICE_STATE_ONLINE) {
result = service_update_preferred_order(def_service,
if (old_state == CONNMAN_SERVICE_STATE_ONLINE)
__connman_notifier_leave_online(service->type);
- if (is_connected_state(service, old_state) &&
- !is_connected_state(service, new_state))
+ if (is_connected(old_state) && !is_connected(new_state))
searchdomain_remove_all(service);
service->state = new_state;
+#if defined TIZEN_EXT
+ if (!is_connected(old_state) && is_connected(new_state))
+ connman_device_send_connected_signal(
+ connman_network_get_device(service->network), true);
+ else if (is_connected(old_state) && !is_connected(new_state))
+ connman_device_send_connected_signal(
+ connman_network_get_device(service->network), false);
+#endif
state_changed(service);
+ if (!is_connected(old_state) && is_connected(new_state))
+ searchdomain_add_all(service);
+
switch(new_state) {
case CONNMAN_SERVICE_STATE_UNKNOWN:
default_changed();
- def_service = __connman_service_get_default();
+ def_service = connman_service_get_default();
service_update_preferred_order(def_service, service, new_state);
reply_pending(service, 0);
- g_get_current_time(&service->modified);
- service_save(service);
-
- searchdomain_add_all(service);
- dns_changed(service);
- domain_changed(service);
- proxy_changed(service);
-
- if (old_state != CONNMAN_SERVICE_STATE_ONLINE)
- __connman_notifier_connect(service->type);
-
if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
connman_network_get_bool(service->network,
"WiFi.UseWPS")) {
"WiFi.UseWPS", false);
}
+ gettimeofday(&service->modified, NULL);
+ service_save(service);
+
+ domain_changed(service);
+ proxy_changed(service);
+
+ if (old_state != CONNMAN_SERVICE_STATE_ONLINE)
+ __connman_notifier_connect(service->type);
+
method = __connman_ipconfig_get_method(service->ipconfig_ipv6);
if (method == CONNMAN_IPCONFIG_METHOD_OFF)
__connman_ipconfig_disable_ipv6(
service->ipconfig_ipv6);
+#if !defined TIZEN_MAINTAIN_ONLINE
if (connman_setting_get_bool("SingleConnectedTechnology"))
single_connected_tech(service);
else if (service->type != CONNMAN_SERVICE_TYPE_VPN)
vpn_auto_connect();
+#else
+ if (service->type != CONNMAN_SERVICE_TYPE_VPN)
+ vpn_auto_connect();
+#endif
#if defined TIZEN_EXT
if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
break;
case CONNMAN_SERVICE_STATE_ONLINE:
+#if defined TIZEN_MAINTAIN_ONLINE
+#if defined TIZEN_EXT
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+ set_priority_connected_service();
+#endif
+ if (connman_setting_get_bool("SingleConnectedTechnology"))
+ single_connected_tech(service);
+#endif
+
+#if defined TIZEN_EXT
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+ connman_service_set_internet_connection(service, true);
+#endif
break;
case CONNMAN_SERVICE_STATE_DISCONNECT:
reply_pending(service, ECONNABORTED);
- def_service = __connman_service_get_default();
- service->disconnect_reason = connman_network_get_disconnect_reason(service->network);
-
- if (!__connman_notifier_is_connected() &&
- def_service &&
- def_service->provider)
- connman_provider_disconnect(def_service->provider);
-
default_changed();
__connman_wispr_stop(service);
#if defined TIZEN_EXT
/**
- * Skip the functions if there is any connected profiles
- * that use same interface
- */
+ * Skip the functions if there is any connected profiles
+ * that use same interface
+ */
if (service->type != CONNMAN_SERVICE_TYPE_CELLULAR ||
__connman_service_get_connected_count_of_iface(
service) <= 0) {
#endif
- dns_changed(service);
domain_changed(service);
proxy_changed(service);
#if defined TIZEN_EXT
*/
downgrade_connected_services();
- __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+ do_auto_connect(service, CONNMAN_SERVICE_CONNECT_REASON_AUTO);
break;
case CONNMAN_SERVICE_STATE_FAILURE:
service->order = 5;
__connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
#endif
- if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER &&
+ if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER) {
connman_agent_report_error(service, service->path,
- error2string(service->error),
- report_error_cb,
- get_dbus_sender(service),
- NULL) == -EINPROGRESS)
- return 0;
+ error2string(service->error),
+ report_error_cb,
+ get_dbus_sender(service),
+ NULL);
+ }
service_complete(service);
-
break;
}
service_list_sort();
#if defined TIZEN_EXT
+#if defined TIZEN_MAINTAIN_ONLINE
+ __connman_service_connect_default(service, old_state);
+#else
__connman_service_connect_default(service);
#endif
+ /* Update Wi-Fi Roaming result */
+ if (connman_setting_get_bool("WifiRoaming") &&
+ connman_network_get_bool(service->network, "WiFi.Roaming")) {
+ const char *cur_bssid;
+ const char *dst_bssid;
+ const char *ifname;
+ struct connman_device *device;
+
+ device = connman_network_get_device(service->network);
+ if (device) {
+ ifname = connman_device_get_string(device, "Interface");
+ cur_bssid = connman_network_get_string(service->network,
+ "WiFi.RoamingCurBSSID");
+ dst_bssid = connman_network_get_string(service->network,
+ "WiFi.RoamingDstBSSID");
+ }
+
+ if (device && ifname && cur_bssid && dst_bssid) {
+ switch(new_state) {
+ case CONNMAN_SERVICE_STATE_UNKNOWN:
+ case CONNMAN_SERVICE_STATE_ASSOCIATION:
+ case CONNMAN_SERVICE_STATE_CONFIGURATION:
+ break;
+ case CONNMAN_SERVICE_STATE_READY:
+ case CONNMAN_SERVICE_STATE_ONLINE:
+ __connman_technology_notify_roaming_state(ifname,
+ "success", cur_bssid, dst_bssid);
+ connman_network_set_bool(service->network,
+ "WiFi.Roaming", false);
+ connman_network_set_string(service->network,
+ "WiFi.RoamingCurBSSID", NULL);
+ connman_network_set_string(service->network,
+ "WiFi.RoamingDstBSSID", NULL);
+ break;
+ case CONNMAN_SERVICE_STATE_DISCONNECT:
+ case CONNMAN_SERVICE_STATE_FAILURE:
+ case CONNMAN_SERVICE_STATE_IDLE:
+ __connman_technology_notify_roaming_state(ifname,
+ "failure", cur_bssid, dst_bssid);
+ connman_network_set_bool(service->network,
+ "WiFi.Roaming", false);
+ connman_network_set_string(service->network,
+ "WiFi.RoamingCurBSSID", NULL);
+ connman_network_set_string(service->network,
+ "WiFi.RoamingDstBSSID", NULL);
+ break;
+ }
+ }
+ }
+#endif
__connman_connection_update_gateway();
default_changed();
}
- if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
- service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER &&
- (new_state == CONNMAN_SERVICE_STATE_READY ||
- new_state == CONNMAN_SERVICE_STATE_ONLINE)) {
- if (service->user.favorite_user != service->user.current_user) {
- DBG("Now set service favorite user id from %d to %d",
- service->user.favorite_user, service->user.current_user);
-
- service->user.favorite_user = service->user.current_user;
-
- service_save(service);
- }
- }
-
return 0;
}
{
DBG("service %p state %s", service, state2string(service->state));
- if (!is_connected(service)) {
+ if (!is_connected(service->state)) {
/*
* If service is not yet fully connected, then we must not
* change the default yet. The default gw will be changed
return CONNMAN_SERVICE_STATE_UNKNOWN;
}
-static void check_proxy_setup(struct connman_service *service)
-{
- /*
- * We start WPAD if we haven't got a PAC URL from DHCP and
- * if our proxy manual configuration is either empty or set
- * to AUTO with an empty URL.
- */
-
- if (service->proxy != CONNMAN_SERVICE_PROXY_METHOD_UNKNOWN)
- goto done;
-
- if (service->proxy_config != CONNMAN_SERVICE_PROXY_METHOD_UNKNOWN &&
- (service->proxy_config != CONNMAN_SERVICE_PROXY_METHOD_AUTO ||
- service->pac))
- goto done;
-
- if (__connman_wpad_start(service) < 0) {
- service->proxy = CONNMAN_SERVICE_PROXY_METHOD_DIRECT;
- __connman_notifier_proxy_changed(service);
- goto done;
- }
-
- return;
-
-done:
- __connman_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV4);
-}
-
#if defined TIZEN_EXT
void connman_check_proxy_setup_and_wispr_start(struct connman_service *service){
connected_networks_count = 0;
}
- DBG("%s %s ipconfig %p method %d count %d filter %d",
- connected ? "connected" : "disconnected", service->identifier,
- service->ipconfig_ipv4, method,
- connected_networks_count, original_rp_filter);
+ DBG("%s %s ipconfig %p method %d count %d filter %d",
+ connected ? "connected" : "disconnected", service->identifier,
+ service->ipconfig_ipv4, method,
+ connected_networks_count, original_rp_filter);
+}
+
+static void redo_wispr(struct connman_service *service,
+ enum connman_ipconfig_type type)
+{
+ service->online_timeout = 0;
+ connman_service_unref(service);
+
+ DBG("Retrying %s WISPr for %p %s",
+ __connman_ipconfig_type2string(type),
+ service, service->name);
+
+ __connman_wispr_start(service, type);
}
-static gboolean redo_wispr(gpointer user_data)
+static gboolean redo_wispr_ipv4(gpointer user_data)
{
struct connman_service *service = user_data;
- int refcount = service->refcount - 1;
- connman_service_unref(service);
- if (refcount == 0) {
- DBG("Service %p already removed", service);
- return FALSE;
- }
+#if defined TIZEN_MAINTAIN_ONLINE
+ DBG("");
+
+ __connman_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV4);
+#else
+ redo_wispr(service, CONNMAN_IPCONFIG_TYPE_IPV4);
+#endif
+
+ return FALSE;
+}
- __connman_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV6);
+static gboolean redo_wispr_ipv6(gpointer user_data)
+{
+ struct connman_service *service = user_data;
+
+ redo_wispr(service, CONNMAN_IPCONFIG_TYPE_IPV6);
return FALSE;
}
int __connman_service_online_check_failed(struct connman_service *service,
enum connman_ipconfig_type type)
{
- DBG("service %p type %d count %d", service, type,
- service->online_check_count);
+ GSourceFunc redo_func;
+ int *interval;
- /* currently we only retry IPv6 stuff */
- if (type == CONNMAN_IPCONFIG_TYPE_IPV4 ||
- service->online_check_count != 1) {
- connman_warn("Online check failed for %p %s", service,
- service->name);
- return 0;
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
+ interval = &service->online_check_interval_ipv4;
+ redo_func = redo_wispr_ipv4;
+ } else {
+ interval = &service->online_check_interval_ipv6;
+ redo_func = redo_wispr_ipv6;
}
- service->online_check_count = 0;
+ DBG("service %p type %s interval %d", service,
+ __connman_ipconfig_type2string(type), *interval);
- /*
- * We set the timeout to 1 sec so that we have a chance to get
- * necessary IPv6 router advertisement messages that might have
- * DNS data etc.
+ service->online_timeout = g_timeout_add_seconds(*interval * *interval,
+ redo_func, connman_service_ref(service));
+
+ /* Increment the interval for the next time, set a maximum timeout of
+ * ONLINE_CHECK_MAX_INTERVAL * ONLINE_CHECK_MAX_INTERVAL seconds.
*/
- g_timeout_add_seconds(1, redo_wispr, connman_service_ref(service));
+ if (*interval < ONLINE_CHECK_MAX_INTERVAL)
+ (*interval)++;
return EAGAIN;
}
if (!ipconfig)
return -EINVAL;
+ method = __connman_ipconfig_get_method(ipconfig);
+
+ switch (method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ if (new_state != CONNMAN_SERVICE_STATE_IDLE)
+ connman_warn("ipconfig state %d ipconfig method %d",
+ new_state, method);
+
+#if defined TIZEN_EXT
+ if (old_state != CONNMAN_SERVICE_STATE_READY &&
+ old_state != CONNMAN_SERVICE_STATE_ONLINE)
+#endif
+ new_state = CONNMAN_SERVICE_STATE_IDLE;
+ break;
+
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+ break;
+
+ }
+
/* Any change? */
if (old_state == new_state)
return -EALREADY;
switch (new_state) {
case CONNMAN_SERVICE_STATE_UNKNOWN:
- case CONNMAN_SERVICE_STATE_IDLE:
case CONNMAN_SERVICE_STATE_ASSOCIATION:
break;
case CONNMAN_SERVICE_STATE_CONFIGURATION:
- __connman_ipconfig_enable(ipconfig);
break;
case CONNMAN_SERVICE_STATE_READY:
#if defined TIZEN_EXT
break;
}
#endif
- if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
+ if (connman_setting_get_bool("EnableOnlineCheck"))
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
#if !defined TIZEN_EXT
- check_proxy_setup(service);
+ check_proxy_setup(service);
#endif
+#if defined TIZEN_MAINTAIN_ONLINE
+/* if (old_state == CONNMAN_SERVICE_STATE_ONLINE) */
+ check_proxy_setup(service);
+#endif
+ } else {
+ __connman_service_wispr_start(service, type);
+ }
+ else
+ connman_info("Online check disabled. "
+ "Default service remains in READY state.");
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
service_rp_filter(service, true);
- } else {
- service->online_check_count = 1;
- __connman_wispr_start(service, type);
- }
+ set_mdns(service, service->mdns_config);
break;
case CONNMAN_SERVICE_STATE_ONLINE:
break;
service_rp_filter(service, false);
break;
- case CONNMAN_SERVICE_STATE_FAILURE:
- break;
- }
- /* Keep that state, but if the ipconfig method is OFF, then we set
- the state to IDLE so that it will not affect the combined state
- in the future.
- */
- method = __connman_ipconfig_get_method(ipconfig);
- switch (method) {
- case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
- case CONNMAN_IPCONFIG_METHOD_OFF:
- new_state = CONNMAN_SERVICE_STATE_IDLE;
- break;
+ case CONNMAN_SERVICE_STATE_IDLE:
+ case CONNMAN_SERVICE_STATE_FAILURE:
+ __connman_ipconfig_disable(ipconfig);
- case CONNMAN_IPCONFIG_METHOD_FIXED:
- case CONNMAN_IPCONFIG_METHOD_MANUAL:
- case CONNMAN_IPCONFIG_METHOD_DHCP:
- case CONNMAN_IPCONFIG_METHOD_AUTO:
break;
-
}
- if (is_connected_state(service, old_state) &&
- !is_connected_state(service, new_state))
-#if defined TIZEN_EXT
- {
- DBG("nameserver remove all, type: %d", type);
+ if (is_connected(old_state) && !is_connected(new_state)) {
nameserver_remove_all(service, type);
-#else
- nameserver_remove_all(service);
-#endif
-#if defined TIZEN_EXT
+ cancel_online_check(service);
}
-#endif
if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
service->state_ipv4 = new_state;
else
service->state_ipv6 = new_state;
- if (!is_connected_state(service, old_state) &&
- is_connected_state(service, new_state))
-#if defined TIZEN_EXT
- {
- DBG("nameserver add all, type: %d", type);
+ if (!is_connected(old_state) && is_connected(new_state))
nameserver_add_all(service, type);
-#else
- nameserver_add_all(service);
-#endif
-#if defined TIZEN_EXT
- }
-#endif
+
+ __connman_timeserver_sync(service);
#if defined TIZEN_EXT
int ret = service_indicate_state(service);
connman_network_set_string(service->network, "WiFi.Identity",
service->identity);
+ if (service->anonymous_identity)
+ connman_network_set_string(service->network,
+ "WiFi.AnonymousIdentity",
+ service->anonymous_identity);
+
if (service->ca_cert_file)
connman_network_set_string(service->network, "WiFi.CACertFile",
service->ca_cert_file);
+ if (service->subject_match)
+ connman_network_set_string(service->network, "WiFi.SubjectMatch",
+ service->subject_match);
+
+ if (service->altsubject_match)
+ connman_network_set_string(service->network, "WiFi.AltSubjectMatch",
+ service->altsubject_match);
+
+ if (service->domain_suffix_match)
+ connman_network_set_string(service->network, "WiFi.DomainSuffixMatch",
+ service->domain_suffix_match);
+
+ if (service->domain_match)
+ connman_network_set_string(service->network, "WiFi.DomainMatch",
+ service->domain_match);
+
if (service->client_cert_file)
connman_network_set_string(service->network,
"WiFi.ClientCertFile",
if (service->phase2)
connman_network_set_string(service->network, "WiFi.Phase2",
service->phase2);
+
+#if defined TIZEN_EXT
+ if (service->keymgmt_type)
+ connman_network_set_string(service->network, "WiFi.KeymgmtType",
+ service->keymgmt_type);
+
+ DBG("service->phase1 : %s", service->phase1);
+ if (service->phase1)
+ connman_network_set_string(service->network, "WiFi.Phase1",
+ service->phase1);
+#endif
+}
+#if defined TIZEN_EXT
+
+static bool has_valid_configuration_object(struct connman_service *service)
+{
+ return service->connector && service->c_sign_key && service->net_access_key;
+}
+
+static void prepare_dpp(struct connman_service *service)
+{
+ DBG("prepare dpp");
+ if (service->connector)
+ connman_network_set_string(service->network, "WiFi.Connector",
+ service->connector);
+
+ if (service->c_sign_key)
+ connman_network_set_string(service->network, "WiFi.CSignKey",
+ service->c_sign_key);
+
+ if (service->net_access_key)
+ connman_network_set_string(service->network, "WiFi.NetAccessKey",
+ service->net_access_key);
}
+#endif
static int service_connect(struct connman_service *service)
{
if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
break;
- if (!is_connecting(temp) && !is_connected(temp))
+ if (!is_connecting(temp->state) && !is_connected(temp->state))
break;
if (service == temp)
case CONNMAN_SERVICE_TYPE_SYSTEM:
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
return -EINVAL;
case CONNMAN_SERVICE_TYPE_ETHERNET:
case CONNMAN_SERVICE_TYPE_GADGET:
switch (service->security) {
case CONNMAN_SERVICE_SECURITY_UNKNOWN:
case CONNMAN_SERVICE_SECURITY_NONE:
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_OWE:
+#endif
break;
case CONNMAN_SERVICE_SECURITY_WEP:
case CONNMAN_SERVICE_SECURITY_PSK:
case CONNMAN_SERVICE_SECURITY_WPA:
case CONNMAN_SERVICE_SECURITY_RSN:
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_SAE:
+#endif
if (service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY)
return -ENOKEY;
- if (service->request_passphrase_input) {
- DBG("Now try to connect other user's favorite service");
- service->request_passphrase_input = false;
- return -ENOKEY;
- } else if (!service->passphrase) {
+ if (!service->passphrase) {
if (!service->network)
return -EOPNOTSUPP;
}
break;
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_DPP:
+ if (has_valid_configuration_object(service) &&
+ !service->network)
+ return -EINVAL;
+ break;
+#endif
case CONNMAN_SERVICE_SECURITY_8021X:
- if (!service->eap)
+ if (!service->eap) {
+ connman_warn("EAP type has not been found. "
+ "Most likely ConnMan is not able to "
+ "find a configuration for given "
+ "8021X network. "
+ "Check SSID or Name match with the "
+ "network name.");
return -EINVAL;
+ }
#if defined TIZEN_EXT
/*
* or EAP-AKA (EAP-TLS, EAP-SIM and EAP-AKA networks
* need to be fully provisioned)
*/
+ DBG("service eap: %s", service->eap);
if (g_str_equal(service->eap, "tls") ||
g_str_equal(service->eap, "sim") ||
- g_str_equal(service->eap, "aka"))
+ g_str_equal(service->eap, "aka") ||
+ g_str_equal(service->eap, "aka'") ||
+ g_str_equal(service->eap, "pwd") ||
+ g_str_equal(service->eap, "fast"))
break;
#else
/*
*/
if (g_str_equal(service->eap, "tls"))
break;
+
#endif
/*
* Return -ENOKEY if either identity or passphrase is
case CONNMAN_SERVICE_SECURITY_PSK:
case CONNMAN_SERVICE_SECURITY_WPA:
case CONNMAN_SERVICE_SECURITY_RSN:
+#if defined TIZEN_EXT
+ case CONNMAN_SERVICE_SECURITY_SAE:
+ case CONNMAN_SERVICE_SECURITY_OWE:
+ break;
+ case CONNMAN_SERVICE_SECURITY_DPP:
+ prepare_dpp(service);
+#endif
break;
case CONNMAN_SERVICE_SECURITY_8021X:
prepare_8021x(service);
&service->stats_roaming.data);
}
- if (service->ipconfig_ipv4)
- __connman_ipconfig_enable(service->ipconfig_ipv4);
- if (service->ipconfig_ipv6)
- __connman_ipconfig_enable(service->ipconfig_ipv6);
-
err = __connman_network_connect(service->network);
} else if (service->type == CONNMAN_SERVICE_TYPE_VPN &&
service->provider)
- err = __connman_provider_connect(service->provider);
+ err = __connman_provider_connect(service->provider,
+ get_dbus_sender(service));
else
return -EOPNOTSUPP;
if (err < 0) {
if (err != -EINPROGRESS) {
- __connman_ipconfig_disable(service->ipconfig_ipv4);
- __connman_ipconfig_disable(service->ipconfig_ipv6);
+ __connman_service_ipconfig_indicate_state(service,
+ CONNMAN_SERVICE_STATE_FAILURE,
+ CONNMAN_IPCONFIG_TYPE_IPV4);
+ __connman_service_ipconfig_indicate_state(service,
+ CONNMAN_SERVICE_STATE_FAILURE,
+ CONNMAN_IPCONFIG_TYPE_IPV6);
__connman_stats_service_unregister(service);
}
}
reason2string(service->connect_reason),
reason2string(reason));
- if (is_connected(service))
+ if (is_connected(service->state))
return -EISCONN;
- if (is_connecting(service))
+ if (is_connecting(service->state))
return -EALREADY;
switch (service->type) {
case CONNMAN_SERVICE_TYPE_SYSTEM:
case CONNMAN_SERVICE_TYPE_GPS:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
return -EINVAL;
case CONNMAN_SERVICE_TYPE_ETHERNET:
err = service_connect(service);
+ DBG("service %p err %d", service, err);
+
service->connect_reason = reason;
+#if defined TIZEN_EXT
+ connect_reason_changed(service);
+#endif
+
if (err >= 0)
return 0;
if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER) {
if (err == -ENOKEY || err == -EPERM) {
DBusMessage *pending = NULL;
+ const char *dbus_sender = get_dbus_sender(service);
/*
* We steal the reply here. The idea is that the
err = __connman_agent_request_passphrase_input(service,
request_input_cb,
- get_dbus_sender(service),
+ dbus_sender,
pending);
if (service->hidden && err != -EINPROGRESS)
service->pending = pending;
return err;
}
- reply_pending(service, -err);
}
return err;
connman_agent_cancel(service);
- reply_pending(service, ECONNABORTED);
+ __connman_stats_service_unregister(service);
if (service->network) {
err = __connman_network_disconnect(service->network);
}
#endif
- __connman_stats_service_unregister(service);
-
return err;
}
for (iter = service_list; iter; iter = iter->next) {
service = iter->data;
- if (!is_connected(service))
+ if (!is_connected(service->state))
break;
services = g_slist_prepend(services, service);
return g_hash_table_lookup(service_hash, identifier);
}
+struct connman_service *connman_service_lookup_from_identifier(const char* identifier)
+{
+ return identifier ? lookup_by_identifier(identifier) : NULL;
+}
+
struct provision_user_data {
const char *ident;
int ret;
service = connman_service_create();
if (!service)
return NULL;
-
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("service %p", service);
service->identifier = g_strdup(identifier);
static int service_register(struct connman_service *service)
{
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("service %p", service);
if (service->path)
DBG("path %s", service->path);
+#if defined TIZEN_EXT
+ int ret;
+ service_load(service);
+ ret = service_ext_load(service);
+ if (ret == -ERANGE)
+ service_ext_save(service);
+ ret = __connman_config_provision_service(service);
+ if (ret < 0 && !simplified_log)
+ DBG("Failed to provision service");
+#else
if (__connman_config_provision_service(service) < 0)
service_load(service);
+#endif
g_dbus_register_interface(connection, service->path,
CONNMAN_SERVICE_INTERFACE,
DBG("%s lower down", ifname);
- if (!is_idle_state(service, service->state_ipv4))
- __connman_ipconfig_disable(service->ipconfig_ipv4);
-
- if (!is_idle_state(service, service->state_ipv6))
- __connman_ipconfig_disable(service->ipconfig_ipv6);
-
stats_stop(service);
service_save(service);
}
{
err = __connman_ipconfig_gateway_add(ipconfig, service);
- if(err == 0)
- __connman_connection_gateway_activate(service,
- CONNMAN_IPCONFIG_TYPE_IPV6);
+ if(err < 0)
+ DBG("Failed to add gateway");
}
#else
__connman_service_ipconfig_indicate_state(service,
#endif
settings_changed(service, ipconfig);
+ address_updated(service, type);
}
static void service_ip_release(struct connman_ipconfig *ipconfig,
return NULL;
}
-struct connman_service *__connman_service_lookup_from_ident(const char *identifier)
-{
- return lookup_by_identifier(identifier);
-}
-
-const char *__connman_service_get_ident(struct connman_service *service)
+const char *connman_service_get_identifier(struct connman_service *service)
{
- return service->identifier;
+ return service ? service->identifier : NULL;
}
const char *__connman_service_get_path(struct connman_service *service)
return service->name;
}
-enum connman_service_state __connman_service_get_state(struct connman_service *service)
-{
- return service->state;
-}
-
-unsigned int __connman_service_get_order(struct connman_service *service)
-{
- unsigned int order = 0;
-
- if (!service)
- return 0;
-
- service->order = 0;
-
- if (!service->favorite)
- return 0;
-
-#if defined TIZEN_EXT
- if (service->type == CONNMAN_SERVICE_TYPE_VPN &&
- service->do_split_routing == FALSE)
- order = 10;
- else if (service->type == CONNMAN_SERVICE_TYPE_WIFI) {
- if (service->order < 5)
- order = 5;
- } else if (service->type == CONNMAN_SERVICE_TYPE_ETHERNET)
- order = 4;
- else if (service->type == CONNMAN_SERVICE_TYPE_BLUETOOTH)
- order = 3;
- else if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR &&
- __connman_service_is_internet_profile(service) == TRUE)
- order = 1;
- else if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR &&
- __connman_service_is_tethering_profile(service) == TRUE)
- order = 0;
- else if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
- order = 0;
- else
- order = 2;
-#else
- if (service == service_list->data)
- order = 1;
-
- if (service->type == CONNMAN_SERVICE_TYPE_VPN &&
- !service->do_split_routing) {
- service->order = 10;
- order = 10;
- }
-#endif
- DBG("service %p name %s order %d split %d", service, service->name,
- order, service->do_split_routing);
-
- return order;
-}
-
-void __connman_service_update_ordering(void)
+enum connman_service_state connman_service_get_state(struct connman_service *service)
{
- if (service_list && service_list->next)
- service_list = g_list_sort(service_list, service_compare);
+ return service ? service->state : CONNMAN_SERVICE_STATE_UNKNOWN;
}
static enum connman_service_type convert_network_type(struct connman_network *network)
else if (g_str_equal(security, "rsn"))
return CONNMAN_SERVICE_SECURITY_RSN;
#if defined TIZEN_EXT
+ else if (g_str_equal(security, "sae"))
+ return CONNMAN_SERVICE_SECURITY_SAE;
+ else if (g_str_equal(security, "owe"))
+ return CONNMAN_SERVICE_SECURITY_OWE;
+ else if (g_str_equal(security, "dpp"))
+ return CONNMAN_SERVICE_SECURITY_DPP;
else if (g_str_equal(security, "ft_psk") == TRUE)
return CONNMAN_SERVICE_SECURITY_PSK;
else if (g_str_equal(security, "ft_ieee8021x") == TRUE)
return CONNMAN_SERVICE_SECURITY_UNKNOWN;
}
+#if defined TIZEN_EXT
+int check_passphrase_ext(struct connman_network *network,
+ const char *passphrase)
+{
+ const char *str;
+ enum connman_service_security security;
+
+ str = connman_network_get_string(network, "WiFi.Security");
+ security = convert_wifi_security(str);
+
+ return __connman_service_check_passphrase(security, passphrase);
+}
+#endif
+
+static void update_wps_values(struct connman_service *service,
+ struct connman_network *network)
+{
+ bool wps = connman_network_get_bool(network, "WiFi.WPS");
+ bool wps_advertising = connman_network_get_bool(network,
+ "WiFi.WPSAdvertising");
+
+ if (service->wps != wps ||
+ service->wps_advertizing != wps_advertising) {
+ service->wps = wps;
+ service->wps_advertizing = wps_advertising;
+ security_changed(service);
+ }
+}
+
static void update_from_network(struct connman_service *service,
struct connman_network *network)
{
DBG("service %p network %p", service, network);
- if (is_connected(service))
+ if (is_connected(service->state))
return;
- if (is_connecting(service))
+ if (is_connecting(service->state))
return;
str = connman_network_get_string(network, "Name");
service->security = convert_wifi_security(str);
if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
- service->wps = connman_network_get_bool(network, "WiFi.WPS");
+ update_wps_values(service, network);
if (service->strength > strength && service->network) {
connman_network_unref(service->network);
struct connman_device *device;
const char *ident, *group;
char *name;
- unsigned int *auto_connect_types;
+ unsigned int *auto_connect_types, *favorite_types;
int i, index;
DBG("network %p", network);
}
}
- switch (service->type) {
- case CONNMAN_SERVICE_TYPE_UNKNOWN:
- case CONNMAN_SERVICE_TYPE_SYSTEM:
- case CONNMAN_SERVICE_TYPE_BLUETOOTH:
- case CONNMAN_SERVICE_TYPE_GPS:
- case CONNMAN_SERVICE_TYPE_VPN:
- case CONNMAN_SERVICE_TYPE_GADGET:
- case CONNMAN_SERVICE_TYPE_WIFI:
- case CONNMAN_SERVICE_TYPE_CELLULAR:
- case CONNMAN_SERVICE_TYPE_P2P:
- break;
- case CONNMAN_SERVICE_TYPE_ETHERNET:
- service->favorite = true;
- break;
+ favorite_types = connman_setting_get_uint_list("DefaultFavoriteTechnologies");
+ service->favorite = false;
+ for (i = 0; favorite_types && favorite_types[i] != 0; i++) {
+ if (service->type == favorite_types[i]) {
+ service->favorite = true;
+ break;
+ }
}
service->state_ipv4 = service->state_ipv6 = CONNMAN_SERVICE_STATE_IDLE;
service->ipconfig_ipv6 = create_ip6config(service, index);
service_register(service);
+ service_schedule_added(service);
if (service->favorite) {
device = connman_network_get_device(service->network);
- if (device && !connman_device_get_scanning(device)) {
+ if (device && !connman_device_get_scanning(device,
+ CONNMAN_SERVICE_TYPE_UNKNOWN)) {
switch (service->type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
case CONNMAN_SERVICE_TYPE_SYSTEM:
case CONNMAN_SERVICE_TYPE_P2P:
+#if defined TIZEN_EXT_WIFI_MESH
+ case CONNMAN_SERVICE_TYPE_MESH:
+#endif
break;
case CONNMAN_SERVICE_TYPE_GADGET:
case CONNMAN_SERVICE_TYPE_VPN:
case CONNMAN_SERVICE_TYPE_WIFI:
case CONNMAN_SERVICE_TYPE_CELLULAR:
- __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+ do_auto_connect(service,
+ CONNMAN_SERVICE_CONNECT_REASON_AUTO);
break;
}
}
if (service->phase2 != NULL)
connman_network_set_string(service->network, "WiFi.Phase2",
service->phase2);
+ if (service->eap != NULL)
+ connman_network_set_string(service->network, "WiFi.Connector",
+ service->connector);
+ if (service->identity != NULL)
+ connman_network_set_string(service->network, "WiFi.CSignKey",
+ service->c_sign_key);
+ if (service->phase2 != NULL)
+ connman_network_set_string(service->network, "WiFi.NetAccessKey",
+ service->net_access_key);
#endif
}
__connman_notifier_service_add(service, service->name);
- service_schedule_added(service);
return service;
}
+#if defined TIZEN_EXT
+void __connman_service_notify_strength_changed(struct connman_network *network)
+{
+ struct connman_service *service;
+ uint8_t strength = 0;
+
+ service = connman_service_lookup_from_network(network);
+ if (!service)
+ return;
+
+ if (!service->network)
+ return;
+
+ strength = connman_network_get_strength(service->network);
+ if (strength == service->strength)
+ return;
+
+ service->strength = strength;
+ if (!simplified_log)
+ DBG("Strength %d", strength);
+ strength_changed(service);
+ service_list_sort();
+}
+#endif
+
void __connman_service_update_from_network(struct connman_network *network)
{
bool need_sort = false;
bool roaming;
const char *name;
bool stats_enable;
+#if defined TIZEN_EXT
+ bool need_save = false;
+#endif
service = connman_service_lookup_from_network(network);
if (!service)
}
if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
- service->wps = connman_network_get_bool(network, "WiFi.WPS");
+ update_wps_values(service, network);
strength = connman_network_get_strength(service->network);
if (strength == service->strength)
roaming_changed(service);
sorting:
+#if defined TIZEN_EXT
+ need_save |= update_last_connected_bssid(service);
+ need_save |= update_assoc_reject(service);
+ if (need_save) {
+ g_get_current_time(&service->modified);
+ service_ext_save(service);
+ need_sort = true;
+ }
+#endif
+
if (need_sort) {
service_list_sort();
}
return NULL;
service->type = CONNMAN_SERVICE_TYPE_VPN;
+ service->order = service->do_split_routing ? 0 : 10;
service->provider = connman_provider_ref(provider);
service->autoconnect = false;
service->favorite = true;
.context_unref = agent_context_unref,
};
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+static void ins_setting_init(void)
+{
+ int i;
+ const char *string;
+ char **string_list;
+ unsigned int string_count;
+
+ ins_settings.last_user_selection = connman_setting_get_bool("INSLastUserSelection");
+ ins_settings.last_user_selection_time = connman_setting_get_uint("INSLastUserSelectionTime");
+ ins_settings.last_connected = connman_setting_get_bool("INSLastConnected");
+
+ string = connman_option_get_string("INSPreferredFreq");
+ if (g_strcmp0(string, "5GHz") == 0)
+ ins_settings.preferred_freq = CONNMAN_INS_PREFERRED_FREQ_5GHZ;
+ else if (g_strcmp0(string, "2.4GHz") == 0)
+ ins_settings.preferred_freq = CONNMAN_INS_PREFERRED_FREQ_24GHZ;
+ else
+ ins_settings.preferred_freq = CONNMAN_INS_PREFERRED_FREQ_UNKNOWN;
+
+ ins_settings.security_priority_count = connman_setting_get_uint("INSSecurityPriorityCount");
+ ins_settings.security_priority_score = connman_setting_get_uint("INSSecurityPriorityScore");
+ string_count = ins_settings.security_priority_count;
+
+ memset(ins_settings.security_priority, 0, sizeof(ins_settings.security_priority));
+ string_list = connman_setting_get_string_list("INSSecurityPriority");
+ for (i = 0; string_list && string_list[i]; i++) {
+ unsigned int security_score = string_count * ins_settings.security_priority_score;
+
+ if (g_strcmp0(string_list[i], "WEP") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_WEP] = security_score;
+ else if (g_strcmp0(string_list[i], "PSK") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_PSK] = security_score;
+ else if (g_strcmp0(string_list[i], "8021X") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_8021X] = security_score;
+ else if (g_strcmp0(string_list[i], "WPA") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_WPA] = security_score;
+ else if (g_strcmp0(string_list[i], "RSN") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_RSN] = security_score;
+ else if (g_strcmp0(string_list[i], "SAE") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_SAE] = security_score;
+ else if (g_strcmp0(string_list[i], "OWE") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_OWE] = security_score;
+ else if (g_strcmp0(string_list[i], "DPP") == 0)
+ ins_settings.security_priority[CONNMAN_SERVICE_SECURITY_DPP] = security_score;
+
+ string_count--;
+ }
+
+ ins_settings.signal = connman_setting_get_bool("INSSignal");
+ ins_settings.internet = connman_setting_get_bool("INSInternet");
+
+ ins_settings.last_user_selection_score = connman_setting_get_uint("INSLastUserSelectionScore");
+ ins_settings.last_connected_score = connman_setting_get_uint("INSLastConnectedScore");
+ ins_settings.preferred_freq_score = connman_setting_get_uint("INSPreferredFreqScore");
+ ins_settings.internet_score = connman_setting_get_uint("INSInternetScore");
+
+ /*
+ * In ConnMan, signal strength is used after being converted
+ * to positive value(signal strength + 120).
+ * So the value for comparison should also be converted to the same.
+ */
+ ins_settings.signal_level3_5ghz = connman_setting_get_int("INSSignalLevel3_5GHz") + 120;
+ ins_settings.signal_level3_24ghz = connman_setting_get_int("INSSignalLevel3_24GHz") + 120;
+
+ DBG("last_user_selection [%s]", ins_settings.last_user_selection ? "true" : "false");
+ DBG("last_user_selection_time [%d]", ins_settings.last_user_selection_time);
+ DBG("last_user_selection_score [%d]", ins_settings.last_user_selection_score);
+
+ DBG("last_connected [%s]", ins_settings.last_connected ? "true" : "false");
+ DBG("last_connected_score [%d]", ins_settings.last_connected_score);
+
+ DBG("preferred_freq [%s]", ins_settings.preferred_freq ? "true" : "false");
+ DBG("preferred_freq_score [%d]", ins_settings.preferred_freq_score);
+
+ DBG("security_priority_count [%d]", ins_settings.security_priority_count);
+ for (i = 0; i < CONNMAN_SERVICE_SECURITY_MAX; i++) {
+ if (ins_settings.security_priority[i])
+ DBG("security_priority %s [%d]", security2string(i),
+ ins_settings.security_priority[i]);
+ }
+ DBG("security_priority_score [%d]", ins_settings.security_priority_score);
+
+ DBG("signal [%s]", ins_settings.signal ? "true" : "false");
+
+ DBG("internet [%s]", ins_settings.internet ? "true" : "false");
+ DBG("internet_score [%d]", ins_settings.internet_score);
+
+ DBG("signal_level3_5ghz [%d]", ins_settings.signal_level3_5ghz);
+ DBG("signal_level3_24ghz [%d]", ins_settings.signal_level3_24ghz);
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
int __connman_service_init(void)
{
int err;
return err;
}
+ set_always_connecting_technologies();
+
connection = connman_dbus_get_connection();
service_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
remove_unprovisioned_services();
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+ ins_setting_init();
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
return 0;
}
{
DBG("");
- if (vpn_autoconnect_timeout) {
- g_source_remove(vpn_autoconnect_timeout);
- vpn_autoconnect_timeout = 0;
+ if (vpn_autoconnect_id) {
+ g_source_remove(vpn_autoconnect_id);
+ vpn_autoconnect_id = 0;
}
- if (autoconnect_timeout != 0) {
- g_source_remove(autoconnect_timeout);
- autoconnect_timeout = 0;
+ if (autoconnect_id != 0) {
+ g_source_remove(autoconnect_id);
+ autoconnect_id = 0;
}
connman_agent_driver_unregister(&agent_driver);
if (services_notify->id != 0) {
g_source_remove(services_notify->id);
service_send_changed(NULL);
- g_hash_table_destroy(services_notify->remove);
- g_hash_table_destroy(services_notify->add);
}
+
+ g_hash_table_destroy(services_notify->remove);
+ g_hash_table_destroy(services_notify->add);
g_free(services_notify);
dbus_connection_unref(connection);