2007-09-10 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h - Kill NMNetworkType; AP types don't matter any more * src/NetworkManagerAPList.c src/NetworkManagerAPList.h src/Makefile.am - Kill; NMAccessPointList has outlived it's usefulness * src/NetworkManagerAP.c src/NetworkManagerAP.h - (match_cipher, security_compatible, nm_ap_check_compatible): new functions; check if an NMConnection object is compatible with the settings of this AP - (freq_to_channel, channel_to_freq): utility functions for channel <-> frequency conversion * src/nm-device.c src/nm-device.h - (nm_device_get_best_connection): pass the specific object around (which might be the object path of a specific AP to connect to). The get_best_connection() call should populate this on return if needed (wireless does). * src/nm-device-802-3-ethernet.c - (real_get_best_connection): handle specific_object argument * src/NetworkManager.c src/NetworkManagerMain.h - Remove unused includes * src/nm-device-802-11-wireless.c src/nm-device-802-11-wireless.h - Convert the ap_list into a GSList from an NMAccessPointList - No need for caching the 'activation_ap' since this is now determined from the specific_object of the activation request, which is populated from the get_best_connection() call or from a user request - (nm_device_802_11_wireless_update_bssid): fix warning - (get_wireless_capabilities): fix error message format arguments - (nm_device_802_11_wireless_copy_allowed_to_dev_list): remove, unused - (find_best_connection, real_get_best_connection): implement - (ap_list_get_ap_by_ssid, nm_device_802_11_wireless_ap_list_print): move here from NetworkManagerAPList - (ap_need_secrets): remove; moved to nm-connection.c where it belongs - (real_act_stage1_prepare): just ensure an AP exists, connection is already verified earlier - (real_act_stage2_config): use nm_connection_need_secrets() * src/NetworkManagerPolicy.c - (nm_policy_auto_get_best_device): handle specific objects - (create_connection): remove; automatic connection creation functionality is handled by the Connection objects - (nm_policy_device_change_check): handle specific_object * libnm-util/nm-connection.c - (wireless_sec_need_secrets, nm_connection_need_secrets): implement git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2778 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "NetworkManagerPolicy.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "NetworkManagerAP.h"
|
||||
#include "NetworkManagerAPList.h"
|
||||
#include "nm-activation-request.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-device-interface.h"
|
||||
@@ -66,25 +65,31 @@ static NMPolicy *global_policy;
|
||||
*/
|
||||
static NMDevice *
|
||||
nm_policy_auto_get_best_device (NMPolicy *policy,
|
||||
NMConnection **connection)
|
||||
NMConnection **connection,
|
||||
char **specific_object)
|
||||
{
|
||||
GSList * elt;
|
||||
NMDevice8023Ethernet * best_wired_dev = NULL;
|
||||
guint best_wired_prio = 0;
|
||||
NMConnection * best_wired_connection = NULL;
|
||||
char * best_wired_specific_object = NULL;
|
||||
NMDevice80211Wireless * best_wireless_dev = NULL;
|
||||
guint best_wireless_prio = 0;
|
||||
NMConnection * best_wireless_connection = NULL;
|
||||
char * best_wireless_specific_object = NULL;
|
||||
NMDevice * highest_priority_dev = NULL;
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
g_return_val_if_fail (*connection == NULL, NULL);
|
||||
g_return_val_if_fail (specific_object != NULL, NULL);
|
||||
g_return_val_if_fail (*specific_object == NULL, NULL);
|
||||
|
||||
if (nm_manager_get_state (policy->manager) == NM_STATE_ASLEEP)
|
||||
return NULL;
|
||||
|
||||
for (elt = nm_manager_get_devices (policy->manager); elt; elt = elt->next) {
|
||||
NMConnection *tmp_con = NULL;
|
||||
char *tmp_obj = NULL;
|
||||
gboolean link_active;
|
||||
guint prio = 0;
|
||||
NMDevice * dev = (NMDevice *)(elt->data);
|
||||
@@ -93,7 +98,7 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
|
||||
link_active = nm_device_has_active_link (dev);
|
||||
caps = nm_device_get_capabilities (dev);
|
||||
|
||||
tmp_con = nm_device_get_best_connection (dev);
|
||||
tmp_con = nm_device_get_best_connection (dev, &tmp_obj);
|
||||
if (tmp_con == NULL)
|
||||
continue;
|
||||
|
||||
@@ -108,6 +113,7 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
|
||||
best_wired_dev = NM_DEVICE_802_3_ETHERNET (dev);
|
||||
best_wired_prio = prio;
|
||||
best_wired_connection = tmp_con;
|
||||
best_wired_specific_object = tmp_obj;
|
||||
}
|
||||
}
|
||||
else if (NM_IS_DEVICE_802_11_WIRELESS (dev) &&
|
||||
@@ -125,6 +131,7 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
|
||||
best_wireless_dev = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
best_wireless_prio = prio;
|
||||
best_wireless_connection = tmp_con;
|
||||
best_wireless_specific_object = tmp_obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,6 +139,7 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
|
||||
if (best_wired_dev) {
|
||||
highest_priority_dev = NM_DEVICE (best_wired_dev);
|
||||
*connection = best_wired_connection;
|
||||
*specific_object = best_wired_specific_object;
|
||||
} else if (best_wireless_dev) {
|
||||
gboolean can_activate;
|
||||
|
||||
@@ -139,6 +147,7 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
|
||||
if (can_activate) {
|
||||
highest_priority_dev = NM_DEVICE (best_wireless_dev);
|
||||
*connection = best_wireless_connection;
|
||||
*specific_object = best_wireless_specific_object;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,49 +172,6 @@ out:
|
||||
return *connection ? highest_priority_dev : NULL;
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
create_connection (NMDevice *device, NMAccessPoint *ap)
|
||||
{
|
||||
NMConnection *connection = NULL;
|
||||
NMSetting *setting = NULL;
|
||||
|
||||
if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
|
||||
nm_info ("Will activate connection '%s'.", nm_device_get_iface (device));
|
||||
setting = nm_setting_wired_new ();
|
||||
} else if (NM_IS_DEVICE_802_11_WIRELESS (device) && ap) {
|
||||
NMSettingWireless *wireless;
|
||||
const GByteArray * ssid = nm_ap_get_ssid (ap);
|
||||
|
||||
nm_info ("Will activate connection '%s/%s'.",
|
||||
nm_device_get_iface (device),
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
|
||||
|
||||
setting = nm_setting_wireless_new ();
|
||||
wireless = (NMSettingWireless *) setting;
|
||||
|
||||
wireless->ssid = g_byte_array_sized_new (ssid->len);
|
||||
g_byte_array_append (wireless->ssid, ssid->data, ssid->len);
|
||||
|
||||
wireless->mode = g_strdup ("infrastructure");
|
||||
} else {
|
||||
nm_warning ("Unhandled device type '%s'", G_OBJECT_CLASS_NAME (device));
|
||||
}
|
||||
|
||||
if (setting) {
|
||||
NMSettingConnection *scon;
|
||||
|
||||
connection = nm_connection_new ();
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
scon = (NMSettingConnection *) nm_setting_connection_new ();
|
||||
scon->name = g_strdup ("Auto");
|
||||
scon->devtype = g_strdup (setting->name);
|
||||
nm_connection_add_setting (connection, (NMSetting *) scon);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_policy_device_change_check
|
||||
*
|
||||
@@ -223,6 +189,7 @@ nm_policy_device_change_check (gpointer user_data)
|
||||
NMPolicy *policy = (NMPolicy *) user_data;
|
||||
GSList *iter;
|
||||
NMConnection * connection = NULL;
|
||||
char * specific_object = NULL;
|
||||
NMDevice * new_dev = NULL;
|
||||
NMDevice * old_dev = NULL;
|
||||
gboolean do_switch = FALSE;
|
||||
@@ -266,7 +233,7 @@ nm_policy_device_change_check (gpointer user_data)
|
||||
}
|
||||
}
|
||||
|
||||
new_dev = nm_policy_auto_get_best_device (policy, &connection);
|
||||
new_dev = nm_policy_auto_get_best_device (policy, &connection, &specific_object);
|
||||
|
||||
/* Four cases here:
|
||||
*
|
||||
@@ -372,7 +339,7 @@ nm_policy_device_change_check (gpointer user_data)
|
||||
|
||||
if (new_dev) {
|
||||
nm_device_interface_activate (NM_DEVICE_INTERFACE (new_dev),
|
||||
connection, NULL, FALSE);
|
||||
connection, specific_object, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user