2007-08-28 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerAP.c src/NetworkManagerAP.h - Remove 'fallback' tag, to be replaced by NMConnection/NMSettings 'autoconnect' property instead * src/NetworkManager.c src/NetworkManagerMain.h src/NetworkManagerPolicy.c src/NetworkManagerPolicy.h - Remove the 'allowed_ap_list', which should be replaced by NMConnection/NMSettings instead, since _those_ are the allowed things that NM can connect to * src/nm-device-802-11-wireless.c - Remove both allowed_ap_list usage and 'fallback' checking git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2740 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,21 @@
|
||||
2007-08-28 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/NetworkManagerAP.c
|
||||
src/NetworkManagerAP.h
|
||||
- Remove 'fallback' tag, to be replaced by NMConnection/NMSettings
|
||||
'autoconnect' property instead
|
||||
|
||||
* src/NetworkManager.c
|
||||
src/NetworkManagerMain.h
|
||||
src/NetworkManagerPolicy.c
|
||||
src/NetworkManagerPolicy.h
|
||||
- Remove the 'allowed_ap_list', which should be replaced by
|
||||
NMConnection/NMSettings instead, since _those_ are the allowed
|
||||
things that NM can connect to
|
||||
|
||||
* src/nm-device-802-11-wireless.c
|
||||
- Remove both allowed_ap_list usage and 'fallback' checking
|
||||
|
||||
2007-08-28 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/nm-device.c
|
||||
|
@@ -121,10 +121,8 @@ static NMData *nm_data_new (void)
|
||||
data = g_slice_new0 (NMData);
|
||||
|
||||
/* Initialize the access point lists */
|
||||
data->allowed_ap_list = nm_ap_list_new (NETWORK_TYPE_ALLOWED);
|
||||
data->invalid_ap_list = nm_ap_list_new (NETWORK_TYPE_INVALID);
|
||||
if (!data->allowed_ap_list || !data->invalid_ap_list)
|
||||
{
|
||||
if (!data->invalid_ap_list) {
|
||||
nm_data_free (data);
|
||||
nm_warning ("could not create access point lists.");
|
||||
return NULL;
|
||||
@@ -144,7 +142,6 @@ static void nm_data_free (NMData *data)
|
||||
{
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
nm_ap_list_unref (data->allowed_ap_list);
|
||||
nm_ap_list_unref (data->invalid_ap_list);
|
||||
|
||||
g_slice_free (NMData, data);
|
||||
@@ -162,9 +159,10 @@ nm_name_owner_changed_handler (NMDBusManager *mgr,
|
||||
gboolean new_owner_good = (new && (strlen (new) > 0));
|
||||
|
||||
if (strcmp (name, NMI_DBUS_SERVICE) == 0) {
|
||||
if (!old_owner_good && new_owner_good)
|
||||
if (!old_owner_good && new_owner_good) {
|
||||
/* NMI appeared, update stuff */
|
||||
nm_policy_schedule_allowed_ap_list_update (data);
|
||||
// FIXME: grab NMConnections from the info-daemon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,13 +439,11 @@ main (int argc, char *argv[])
|
||||
goto done;
|
||||
|
||||
/* If NMI is running, grab allowed wireless network lists from it ASAP */
|
||||
#if 0
|
||||
// FIXME: grab NMConnections instead
|
||||
if (nm_dbus_manager_name_has_owner (dbus_mgr, NMI_DBUS_SERVICE))
|
||||
nm_policy_schedule_allowed_ap_list_update (nm_data);
|
||||
|
||||
/* We run dhclient when we need to, and we don't want any stray ones
|
||||
* lying around upon launch.
|
||||
*/
|
||||
// nm_system_kill_all_dhcp_daemons ();
|
||||
#endif
|
||||
|
||||
/* Bring up the loopback interface. */
|
||||
nm_system_enable_loopback ();
|
||||
|
@@ -72,7 +72,6 @@ typedef struct
|
||||
glong last_seen; /* Last time the AP was seen in a scan in seconds */
|
||||
|
||||
/* Things from user prefs/NetworkManagerInfo */
|
||||
gboolean fallback;
|
||||
GTimeVal timestamp;
|
||||
GSList * user_addresses;
|
||||
} NMAccessPointPrivate;
|
||||
@@ -832,26 +831,6 @@ void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get/Set functions to indicate that an access point is
|
||||
* 'fallback'
|
||||
*
|
||||
*/
|
||||
gboolean nm_ap_get_fallback (const NMAccessPoint *ap)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||
|
||||
return NM_AP_GET_PRIVATE (ap)->fallback;
|
||||
}
|
||||
|
||||
void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback)
|
||||
{
|
||||
g_return_if_fail (NM_IS_AP (ap));
|
||||
|
||||
NM_AP_GET_PRIVATE (ap)->fallback = fallback;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get/Set functions to indicate that an access point is
|
||||
* 'artificial', ie whether or not it was actually scanned
|
||||
|
@@ -97,9 +97,6 @@ void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate);
|
||||
gboolean nm_ap_get_invalid (const NMAccessPoint *ap);
|
||||
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid);
|
||||
|
||||
gboolean nm_ap_get_fallback (const NMAccessPoint *ap);
|
||||
void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback);
|
||||
|
||||
gboolean nm_ap_get_artificial (const NMAccessPoint *ap);
|
||||
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial);
|
||||
|
||||
|
@@ -34,7 +34,6 @@ typedef struct NMVPNManager NMVPNManager;
|
||||
|
||||
typedef struct NMData
|
||||
{
|
||||
struct NMAccessPointList *allowed_ap_list;
|
||||
struct NMAccessPointList *invalid_ap_list;
|
||||
} NMData;
|
||||
|
||||
|
@@ -379,124 +379,6 @@ out:
|
||||
}
|
||||
|
||||
|
||||
static guint allowed_list_update_id = 0;
|
||||
|
||||
/*
|
||||
* nm_policy_allowed_ap_list_update
|
||||
*
|
||||
* Requery NetworkManagerInfo for a list of updated
|
||||
* allowed wireless networks.
|
||||
*
|
||||
*/
|
||||
static gboolean
|
||||
nm_policy_allowed_ap_list_update (gpointer user_data)
|
||||
{
|
||||
NMData * data = (NMData *)user_data;
|
||||
|
||||
allowed_list_update_id = 0;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
nm_info ("Updating allowed wireless network lists.");
|
||||
|
||||
// FIXME: convert to getting connections instead
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_policy_schedule_allowed_ap_list_update
|
||||
*
|
||||
* Schedule an update of the allowed AP list in the main thread.
|
||||
*
|
||||
*/
|
||||
void nm_policy_schedule_allowed_ap_list_update (NMData *app_data)
|
||||
{
|
||||
GSource * source;
|
||||
guint id;
|
||||
|
||||
g_return_if_fail (app_data != NULL);
|
||||
|
||||
if (allowed_list_update_id > 0)
|
||||
return;
|
||||
|
||||
id = g_idle_add (nm_policy_allowed_ap_list_update, app_data);
|
||||
allowed_list_update_id = id;
|
||||
source = g_main_context_find_source_by_id (NULL, id);
|
||||
if (source) {
|
||||
g_source_set_priority (source, G_PRIORITY_HIGH_IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static gboolean device_list_update_id = 0;
|
||||
|
||||
/*
|
||||
* nm_policy_device_list_update_from_allowed_list
|
||||
*
|
||||
* Requery NetworkManagerInfo for a list of updated
|
||||
* allowed wireless networks.
|
||||
*
|
||||
*/
|
||||
static gboolean
|
||||
nm_policy_device_list_update_from_allowed_list (gpointer user_data)
|
||||
{
|
||||
NMData * data = (NMData *) user_data;
|
||||
GSList * elt;
|
||||
|
||||
device_list_update_id = 0;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
for (elt = nm_manager_get_devices (global_policy->manager); elt; elt = elt->next) {
|
||||
NMDevice *dev = (NMDevice *)(elt->data);
|
||||
NMDevice80211Wireless * wdev;
|
||||
|
||||
if (!NM_IS_DEVICE_802_11_WIRELESS (dev))
|
||||
continue;
|
||||
|
||||
wdev = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
/* Once we have the list, copy in any relevant information from our
|
||||
* Allowed list and fill in the SSID of base stations that aren't
|
||||
* broadcasting their SSID, if we have their MAC address in our
|
||||
* allowed list.
|
||||
*/
|
||||
nm_ap_list_copy_ssids_by_address (nm_device_802_11_wireless_ap_list_get (wdev),
|
||||
data->allowed_ap_list);
|
||||
nm_ap_list_copy_properties (nm_device_802_11_wireless_ap_list_get (wdev),
|
||||
data->allowed_ap_list);
|
||||
|
||||
nm_ap_list_remove_duplicate_ssids (nm_device_802_11_wireless_ap_list_get (wdev));
|
||||
}
|
||||
|
||||
schedule_change_check ((gpointer) global_policy);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_policy_schedule_device_ap_lists_update_from_allowed
|
||||
*
|
||||
* Schedule an update of each wireless device's AP list from
|
||||
* the allowed list, in the main thread.
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_policy_schedule_device_ap_lists_update_from_allowed (NMData *app_data)
|
||||
{
|
||||
g_return_if_fail (app_data != NULL);
|
||||
|
||||
if (device_list_update_id > 0)
|
||||
return;
|
||||
|
||||
device_list_update_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
|
||||
nm_policy_device_list_update_from_allowed_list,
|
||||
app_data,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
@@ -33,8 +33,4 @@ typedef struct NMPolicy NMPolicy;
|
||||
NMPolicy *nm_policy_new (NMManager *manager);
|
||||
void nm_policy_destroy (NMPolicy *policy);
|
||||
|
||||
|
||||
void nm_policy_schedule_allowed_ap_list_update (NMData *app_data);
|
||||
void nm_policy_schedule_device_ap_lists_update_from_allowed (NMData *app_data);
|
||||
|
||||
#endif /* NETWORK_MANAGER_POLICY_H */
|
||||
|
@@ -788,75 +788,6 @@ get_ap_blacklisted (NMAccessPoint *ap, GSList *addrs)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_best_fallback_ap
|
||||
*
|
||||
* Find and return the most suitable "fallback" network, if any. We "fall back"
|
||||
* on these networks and attempt a brute-force connection, given no better options.
|
||||
*/
|
||||
static NMAccessPoint *
|
||||
get_best_fallback_ap (NMDevice80211Wireless *self)
|
||||
{
|
||||
NMAccessPointList * allowed_list;
|
||||
NMAccessPoint * best_ap = NULL;
|
||||
NMAccessPoint * allowed_ap;
|
||||
GTimeVal best_timestamp = {0, 0};
|
||||
NMAPListIter * iter;
|
||||
NMData * app_data;
|
||||
|
||||
app_data = nm_device_get_app_data (NM_DEVICE (self));
|
||||
allowed_list = app_data->allowed_ap_list;
|
||||
|
||||
iter = nm_ap_list_iter_new (allowed_list);
|
||||
if (!iter)
|
||||
return NULL;
|
||||
|
||||
while ((allowed_ap = nm_ap_list_iter_next (iter)))
|
||||
{
|
||||
const GByteArray * ssid;
|
||||
GSList * user_addrs;
|
||||
const GTimeVal * curtime;
|
||||
gboolean blacklisted;
|
||||
|
||||
/* Only designated fallback networks, natch */
|
||||
if (!nm_ap_get_fallback (allowed_ap))
|
||||
continue;
|
||||
|
||||
/* Only connect to a blacklisted AP if the user has connected to this specific AP before */
|
||||
user_addrs = nm_ap_get_user_addresses (allowed_ap);
|
||||
blacklisted = get_ap_blacklisted (allowed_ap, user_addrs);
|
||||
g_slist_foreach (user_addrs, (GFunc) g_free, NULL);
|
||||
g_slist_free (user_addrs);
|
||||
if (blacklisted)
|
||||
continue;
|
||||
|
||||
/* No fallback to networks on the invalid list -- we probably already tried them and failed */
|
||||
ssid = nm_ap_get_ssid (allowed_ap);
|
||||
if (nm_ap_list_get_ap_by_ssid (app_data->invalid_ap_list, ssid))
|
||||
continue;
|
||||
|
||||
curtime = nm_ap_get_timestamp (allowed_ap);
|
||||
if (curtime->tv_sec > best_timestamp.tv_sec)
|
||||
{
|
||||
best_timestamp = *nm_ap_get_timestamp (allowed_ap);
|
||||
best_ap = allowed_ap;
|
||||
}
|
||||
}
|
||||
nm_ap_list_iter_free (iter);
|
||||
|
||||
if (best_ap) {
|
||||
const GByteArray * ssid;
|
||||
|
||||
nm_ap_set_broadcast (best_ap, FALSE);
|
||||
ssid = nm_ap_get_ssid (best_ap);
|
||||
nm_info ("Attempting to fallback to wireless network '%s'",
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
|
||||
}
|
||||
|
||||
return best_ap;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_update_best_ap
|
||||
*
|
||||
@@ -918,6 +849,9 @@ nm_device_802_11_wireless_get_best_ap (NMDevice80211Wireless *self)
|
||||
if (nm_ap_list_get_ap_by_ssid (app_data->invalid_ap_list, ap_ssid))
|
||||
continue;
|
||||
|
||||
// FIXME: match up an NMConnection with some NMAccessPoint for the
|
||||
// best_ap
|
||||
#if 0
|
||||
if ((tmp_ap = nm_ap_list_get_ap_by_ssid (app_data->allowed_ap_list, ap_ssid)))
|
||||
{
|
||||
const GTimeVal * curtime = nm_ap_get_timestamp (tmp_ap);
|
||||
@@ -935,11 +869,10 @@ nm_device_802_11_wireless_get_best_ap (NMDevice80211Wireless *self)
|
||||
best_ap = scan_ap;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
nm_ap_list_iter_free (iter);
|
||||
|
||||
if (!best_ap)
|
||||
best_ap = get_best_fallback_ap (self);
|
||||
if (best_ap)
|
||||
g_object_ref (best_ap);
|
||||
|
||||
@@ -2065,16 +1998,13 @@ supplicant_iface_scanned_ap_cb (NMSupplicantInterface * iface,
|
||||
*/
|
||||
if (!nm_ap_get_ssid (ap)) {
|
||||
nm_ap_set_broadcast (ap, FALSE);
|
||||
nm_ap_list_copy_one_ssid_by_address (ap, app_data->allowed_ap_list);
|
||||
// FIXME: get the saved BSSID from NMConnection/NMSettings
|
||||
// nm_ap_list_copy_one_ssid_by_address (ap, app_data->allowed_ap_list);
|
||||
}
|
||||
|
||||
/* Add the AP to the device's AP list */
|
||||
merge_scanned_ap (self, ap);
|
||||
|
||||
/* Once we have the list, copy in any relevant information from our Allowed list. */
|
||||
nm_ap_list_copy_properties (nm_device_802_11_wireless_ap_list_get (self),
|
||||
app_data->allowed_ap_list);
|
||||
|
||||
/* Remove outdated access points */
|
||||
cull_scan_list (self);
|
||||
|
||||
|
Reference in New Issue
Block a user