2004-08-31 Dan Williams <dcbw@redhat.com>
* Remove 'debug' extern global from all files since we now use syslog() * src/NetworkManager.[ch] - Break out routine that get the net.interface property from HAL, removing that logic from nm_create_device_and_add_to_list() - (nm_create_device_and_add_to_list): make this a bit more general so it doesn't do the talking to HAL. Also add arguments to facilitate the create of test devices. - (nm_data_mark_state_changed): rename from nm_data_set_state_modified() - (nm_data_new, main, nm_print_usage): add new argument "--enable-test-devices" which makes NetworkManager listen for dbus commands to create test devices, which have no backing hardware. Use when you're on a plane for example, and/or forgot your wireless card at home. Test devices _cannot_ be created unless NM is started with --enable-test-devices. * src/NetworkManagerDbus.[ch] - New "getLinkActive" method for devices - New "setLinkActive" method for devices (only works on test devices) - New "createTestDevice" method on NetworkManager object to create a test device of a specified type (ie wired, wireless). UDI is created from scratch, as is the interface name. Only works when NM is started with --enable-test-devices switch. - New "removeTestDevice" method on NetworkManager object which removes a test device. Only works when NM is started with --enable-test-devices * src/NetworkManagerDevice.[ch] - Logic to facilitate test devices. Add variables to NMDevice struct to indicate whether a device is a test device or not, and what its link status is. - Deal with test devices in most functions. For those that work directly on hardware special-case test devices. - (nm_device_new): don't create a test device if test devices weren't enabled on the command-line. - (nm_device_update_link_active): split out logic for wired and wireless device link checking to separate functions to facilitate test device link checking. - (nm_device_set_enc_key): Since some drivers for wireless cards are daft and don't make a distinction between System Authentication and Encryption (namely Cisco aironet), we use Open System auth when setting a WEP key on the card. We don't deal with Shared Key auth yet. - (nm_device_activation_worker): split the activation cancel check logic out into a separate routine nm_device_activation_cancel_if_needed() - (nm_device_activation_signal_cancel): rename from nm_device_activation_cancel() - (nm_device_fake_ap_list): Test wireless devices obviously cannot scan, so create a list of fake access points that they can "see" - (nm_device_is_test_device): return whether or not a device is a test device * src/NetworkManagerPolicy.c - (nm_policy_get_best_device): attempt to deal with wireless network selection, previously if you "locked"/forced NM to use a wireless device but then selected a wireless network for NM to use, it would switch to a wired device. So, if the active device is wireless and it has a "forced" best AP, use it if the "forced" best AP is still valid - (nm_state_modification_monitor): deal with NULL best devices, for example there were no usable network devices, or the last one was removed * src/backends/NetworkManager*.c - Deal with test devices, mostly just return success for operations like getting a DHCP address * test/nmtestdevices.c - Test tool to create/remove/link-switch test devices git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@112 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
#include "NetworkManagerDbus.h"
|
||||
|
||||
gboolean allowed_ap_worker_exit = FALSE;
|
||||
extern gboolean debug;
|
||||
|
||||
|
||||
/*
|
||||
@@ -173,7 +172,9 @@ static NMDevice * nm_policy_get_best_device (NMData *data)
|
||||
nm_unlock_mutex (data->user_device_mutex, __FUNCTION__);
|
||||
}
|
||||
|
||||
/* Determine whether we need to clear the active device and unlock it. */
|
||||
/* Determine whether we need to clear the active device and unlock it.
|
||||
* This occurs if the best device is removed, for example.
|
||||
*/
|
||||
if (!best_dev && data->active_device_locked)
|
||||
{
|
||||
switch (nm_device_get_type (data->active_device))
|
||||
@@ -198,6 +199,22 @@ static NMDevice * nm_policy_get_best_device (NMData *data)
|
||||
}
|
||||
}
|
||||
|
||||
/* Or, if the current active device is wireless and its "best" access
|
||||
* point is locked, use that device still. This happens when the user
|
||||
* forces a specific wireless network choice. The "best" ap will have
|
||||
* already been set and locked by the dbus message handler, so we just
|
||||
* need to test for a locked "best" ap.
|
||||
*/
|
||||
if (data->active_device && nm_device_is_wireless (data->active_device))
|
||||
{
|
||||
/* Give ourselves a chance to clear the "best" access point if
|
||||
* its gone out of range and no longer in the device's ap list.
|
||||
*/
|
||||
nm_device_update_best_ap (data->active_device);
|
||||
if (nm_device_get_best_ap_frozen (data->active_device))
|
||||
best_dev = data->active_device;
|
||||
}
|
||||
|
||||
/* Fall back to automatic device picking */
|
||||
if (!best_dev)
|
||||
{
|
||||
@@ -276,8 +293,6 @@ gboolean nm_state_modification_monitor (gpointer user_data)
|
||||
|| ( best_dev && nm_device_is_wireless (best_dev) && !nm_device_activating (best_dev)
|
||||
&& (nm_device_need_ap_switch (best_dev) || (nm_device_get_ip4_address (best_dev) == 0))))
|
||||
{
|
||||
syslog (LOG_INFO, "nm_state_modification_monitor(): beginning activation for device '%s'", best_dev ? nm_device_get_iface (best_dev) : "(null)");
|
||||
|
||||
/* Deactivate the old device */
|
||||
if (data->active_device)
|
||||
{
|
||||
@@ -286,10 +301,14 @@ gboolean nm_state_modification_monitor (gpointer user_data)
|
||||
data->active_device = NULL;
|
||||
}
|
||||
|
||||
/* Begin activation on the new device */
|
||||
nm_device_ref (best_dev);
|
||||
data->active_device = best_dev;
|
||||
nm_device_activation_begin (data->active_device);
|
||||
if (best_dev)
|
||||
{
|
||||
/* Begin activation on the new device */
|
||||
syslog (LOG_INFO, "nm_state_modification_monitor(): beginning activation for device '%s'", nm_device_get_iface (best_dev));
|
||||
nm_device_ref (best_dev);
|
||||
data->active_device = best_dev;
|
||||
nm_device_activation_begin (data->active_device);
|
||||
}
|
||||
}
|
||||
|
||||
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
||||
|
Reference in New Issue
Block a user