mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-11 06:58:17 +02:00
2006-01-07 Dan Williams <dcbw@redhat.com>
* src/nm-device-802-11-wireless.c - Add a link timeout so we allow the supplicant time to reassociate if it can, before we deactivate the card - Fix up link status and link updating so things work better git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1288 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
becb92ea92
commit
e4aaefce40
2 changed files with 68 additions and 25 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
2006-01-07 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* src/nm-device-802-11-wireless.c
|
||||||
|
- Add a link timeout so we allow the supplicant time to
|
||||||
|
reassociate if it can, before we deactivate the card
|
||||||
|
- Fix up link status and link updating so things work better
|
||||||
|
|
||||||
2006-01-07 Dan Williams <dcbw@redhat.com>
|
2006-01-07 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/nm-device-802-11-wireless.c
|
* src/nm-device-802-11-wireless.c
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,6 @@ struct _NMDevice80211WirelessPrivate
|
||||||
iwqual max_qual;
|
iwqual max_qual;
|
||||||
iwqual avg_qual;
|
iwqual avg_qual;
|
||||||
|
|
||||||
guint failed_link_count;
|
|
||||||
|
|
||||||
gint8 num_freqs;
|
gint8 num_freqs;
|
||||||
double freqs[IW_MAX_FREQUENCIES];
|
double freqs[IW_MAX_FREQUENCIES];
|
||||||
|
|
||||||
|
|
@ -75,6 +73,9 @@ struct _NMDevice80211WirelessPrivate
|
||||||
struct wpa_ctrl * sup_ctrl;
|
struct wpa_ctrl * sup_ctrl;
|
||||||
GSource * sup_timeout;
|
GSource * sup_timeout;
|
||||||
|
|
||||||
|
guint32 failed_link_count;
|
||||||
|
GSource * link_timeout;
|
||||||
|
|
||||||
/* Static options from driver */
|
/* Static options from driver */
|
||||||
guint8 we_version;
|
guint8 we_version;
|
||||||
guint32 capabilities;
|
guint32 capabilities;
|
||||||
|
|
@ -131,6 +132,8 @@ static gboolean link_to_specific_ap (NMDevice80211Wireless *self,
|
||||||
|
|
||||||
static void supplicant_cleanup (NMDevice80211Wireless *self);
|
static void supplicant_cleanup (NMDevice80211Wireless *self);
|
||||||
|
|
||||||
|
static void remove_link_timeout (NMDevice80211Wireless *self);
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
real_get_generic_capabilities (NMDevice *dev)
|
real_get_generic_capabilities (NMDevice *dev)
|
||||||
{
|
{
|
||||||
|
|
@ -289,29 +292,14 @@ real_init (NMDevice *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
probe_link (NMDevice80211Wireless *self)
|
|
||||||
{
|
|
||||||
gboolean link = FALSE;
|
|
||||||
NMActRequest * req;
|
|
||||||
|
|
||||||
if ((req = nm_device_get_act_request (NM_DEVICE (self))))
|
|
||||||
{
|
|
||||||
NMAccessPoint * ap;
|
|
||||||
if ((ap = nm_act_request_get_ap (req)))
|
|
||||||
link = link_to_specific_ap (self, ap, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
real_update_link (NMDevice *dev)
|
real_update_link (NMDevice *dev)
|
||||||
{
|
{
|
||||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||||
|
|
||||||
nm_device_set_active_link (NM_DEVICE (self), probe_link (self));
|
/* If the supplicant isn't running, we can't possibly have a link */
|
||||||
|
if (!self->priv->sup_pid)
|
||||||
|
nm_device_set_active_link (NM_DEVICE (self), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -329,7 +317,6 @@ nm_device_802_11_periodic_update (gpointer data)
|
||||||
g_return_val_if_fail (self != NULL, TRUE);
|
g_return_val_if_fail (self != NULL, TRUE);
|
||||||
|
|
||||||
nm_device_802_11_wireless_update_signal_strength (self);
|
nm_device_802_11_wireless_update_signal_strength (self);
|
||||||
nm_device_set_active_link (NM_DEVICE (self), probe_link (self));
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -374,6 +361,7 @@ real_deactivate (NMDevice *dev)
|
||||||
g_assert (app_data);
|
g_assert (app_data);
|
||||||
|
|
||||||
supplicant_cleanup (self);
|
supplicant_cleanup (self);
|
||||||
|
remove_link_timeout (self);
|
||||||
|
|
||||||
/* Clean up stuff, don't leave the card associated */
|
/* Clean up stuff, don't leave the card associated */
|
||||||
nm_device_802_11_wireless_set_essid (self, "");
|
nm_device_802_11_wireless_set_essid (self, "");
|
||||||
|
|
@ -2369,6 +2357,18 @@ wireless_configure_infra (NMDevice80211Wireless *self,
|
||||||
#define WPA_SUPPLICANT_BINARY "/usr/sbin/wpa_supplicant"
|
#define WPA_SUPPLICANT_BINARY "/usr/sbin/wpa_supplicant"
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_link_timeout (NMDevice80211Wireless *self)
|
||||||
|
{
|
||||||
|
g_return_if_fail (self != NULL);
|
||||||
|
|
||||||
|
if (self->priv->link_timeout != NULL)
|
||||||
|
{
|
||||||
|
g_source_destroy (self->priv->link_timeout);
|
||||||
|
self->priv->link_timeout = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
supplicant_remove_timeout (NMDevice80211Wireless *self)
|
supplicant_remove_timeout (NMDevice80211Wireless *self)
|
||||||
{
|
{
|
||||||
|
|
@ -2410,6 +2410,7 @@ supplicant_cleanup (NMDevice80211Wireless *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
supplicant_remove_timeout (self);
|
supplicant_remove_timeout (self);
|
||||||
|
remove_link_timeout (self);
|
||||||
|
|
||||||
/* HACK: should be fixed in wpa_supplicant */
|
/* HACK: should be fixed in wpa_supplicant */
|
||||||
unlink (WPA_SUPPLICANT_GLOBAL_SOCKET);
|
unlink (WPA_SUPPLICANT_GLOBAL_SOCKET);
|
||||||
|
|
@ -2420,6 +2421,7 @@ supplicant_watch_cb (GPid pid,
|
||||||
gint status,
|
gint status,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
NMDevice * dev = NM_DEVICE (user_data);
|
||||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (user_data);
|
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (user_data);
|
||||||
|
|
||||||
g_assert (self);
|
g_assert (self);
|
||||||
|
|
@ -2435,9 +2437,25 @@ supplicant_watch_cb (GPid pid,
|
||||||
|
|
||||||
supplicant_cleanup (self);
|
supplicant_cleanup (self);
|
||||||
|
|
||||||
/* FIXME: deal with disconnection; device no longer has a link */
|
nm_device_set_active_link (dev, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
link_timeout_cb (gpointer user_data)
|
||||||
|
{
|
||||||
|
NMDevice * dev = NM_DEVICE (user_data);
|
||||||
|
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (user_data);
|
||||||
|
|
||||||
|
g_assert (dev);
|
||||||
|
|
||||||
|
nm_info ("%s: link timed out.", nm_device_get_iface (dev));
|
||||||
|
nm_device_set_active_link (dev, FALSE);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define MESSAGE_LEN 2048
|
#define MESSAGE_LEN 2048
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -2445,16 +2463,20 @@ supplicant_status_cb (GIOChannel *source,
|
||||||
GIOCondition condition,
|
GIOCondition condition,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
NMDevice * dev = NM_DEVICE (user_data);
|
||||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (user_data);
|
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (user_data);
|
||||||
char * message;
|
char * message;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct wpa_ctrl * ctrl;
|
struct wpa_ctrl * ctrl;
|
||||||
|
NMActRequest * req;
|
||||||
|
|
||||||
g_assert (self);
|
g_assert (self);
|
||||||
|
|
||||||
ctrl = self->priv->sup_ctrl;
|
ctrl = self->priv->sup_ctrl;
|
||||||
g_return_val_if_fail (ctrl != NULL, FALSE);
|
g_return_val_if_fail (ctrl != NULL, FALSE);
|
||||||
|
|
||||||
|
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||||
|
|
||||||
message = g_malloc (MESSAGE_LEN);
|
message = g_malloc (MESSAGE_LEN);
|
||||||
len = MESSAGE_LEN;
|
len = MESSAGE_LEN;
|
||||||
wpa_ctrl_recv (ctrl, message, &len);
|
wpa_ctrl_recv (ctrl, message, &len);
|
||||||
|
|
@ -2462,7 +2484,8 @@ supplicant_status_cb (GIOChannel *source,
|
||||||
|
|
||||||
if (strstr (message, WPA_EVENT_CONNECTED) != NULL)
|
if (strstr (message, WPA_EVENT_CONNECTED) != NULL)
|
||||||
{
|
{
|
||||||
NMActRequest * req = nm_device_get_act_request (NM_DEVICE (self));
|
remove_link_timeout (self);
|
||||||
|
nm_device_set_active_link (dev, TRUE);
|
||||||
|
|
||||||
/* If this is the initial association during device activation,
|
/* If this is the initial association during device activation,
|
||||||
* schedule the next activation stage.
|
* schedule the next activation stage.
|
||||||
|
|
@ -2481,8 +2504,21 @@ supplicant_status_cb (GIOChannel *source,
|
||||||
}
|
}
|
||||||
else if (strstr (message, WPA_EVENT_DISCONNECTED) != NULL)
|
else if (strstr (message, WPA_EVENT_DISCONNECTED) != NULL)
|
||||||
{
|
{
|
||||||
printf("DOWN\n");
|
if (nm_device_is_activated (dev) || nm_device_is_activating (dev))
|
||||||
/* FIXME: deal with disconnection; device no longer has a link */
|
{
|
||||||
|
/* Start the link timeout so we allow some time for reauthentication */
|
||||||
|
if (self->priv->link_timeout == NULL)
|
||||||
|
{
|
||||||
|
GMainContext * context = nm_device_get_main_context (dev);
|
||||||
|
self->priv->link_timeout = g_timeout_source_new (8000);
|
||||||
|
g_source_set_callback (self->priv->link_timeout, link_timeout_cb, self, NULL);
|
||||||
|
g_source_attach (self->priv->link_timeout, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nm_device_set_active_link (dev, FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue