mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 17:40:38 +01:00
2006-05-17 Robert Love <rml@novell.com>
Functionality to automatically add BSSIDs to the allowed-MAC list as one roams from access point to access point on a given network: * src/NetworkManagerUtils.c: Add nm_ethernet_addresses_are_equal(), helper function to compare two ether_addr structures and return TRUE if they contain the same MAC address. * src/NetworkManagerUtils.h: Add nm_ethernet_addresses_are_equal() prototype. * src/nm-device-802-11-wireless.c: New function to update the BSSID stored with the current AP. If the BSSID has indeed changed, we send it out to the applet, allowing the allowed-MAC list to grow automatically in response to roaming. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1739 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
8d0012453a
commit
b428d9d8a2
7 changed files with 165 additions and 79 deletions
18
ChangeLog
18
ChangeLog
|
|
@ -1,7 +1,21 @@
|
|||
2006-05-17 Robert Love <rml@novell.com>
|
||||
|
||||
Functionality to automatically add BSSIDs to the allowed-MAC list as
|
||||
one roams from access point to access point on a given network:
|
||||
* src/NetworkManagerUtils.c: Add nm_ethernet_addresses_are_equal(),
|
||||
helper function to compare two ether_addr structures and return TRUE
|
||||
if they contain the same MAC address.
|
||||
* src/NetworkManagerUtils.h: Add nm_ethernet_addresses_are_equal()
|
||||
prototype.
|
||||
* src/nm-device-802-11-wireless.c: New function to update the BSSID
|
||||
stored with the current AP. If the BSSID has indeed changed, we
|
||||
send it out to the applet, allowing the allowed-MAC list to grow
|
||||
automatically in response to roaming.
|
||||
|
||||
2006-05-16 Robert Love <rml@novell.com>
|
||||
|
||||
* src/backends/NetworkManagerSuSE.c: Don't touch ypbind or autofs unless
|
||||
dhcp:DHCLIENT_MODIFY_NIS_CONF is set to "yes".
|
||||
* src/backends/NetworkManagerSuSE.c: Don't touch ypbind or autofs
|
||||
unless dhcp:DHCLIENT_MODIFY_NIS_CONF is set to "yes".
|
||||
|
||||
2006-05-13 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
|
|
|
|||
|
|
@ -955,7 +955,7 @@ nmi_dbus_update_network_info (DBusConnection *connection,
|
|||
DBusMessage *message,
|
||||
void *user_data)
|
||||
{
|
||||
NMApplet * applet = (NMApplet *) user_data;
|
||||
NMApplet * applet = (NMApplet *) user_data;
|
||||
char * essid = NULL;
|
||||
gboolean automatic;
|
||||
NMGConfWSO * gconf_wso = NULL;
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ int nm_null_safe_strcmp (const char *s1, const char *s2)
|
|||
/*
|
||||
* nm_ethernet_address_is_valid
|
||||
*
|
||||
* Compares an ethernet address against known invalid addresses.
|
||||
* Compares an Ethernet address against known invalid addresses.
|
||||
*
|
||||
*/
|
||||
gboolean nm_ethernet_address_is_valid (const struct ether_addr *test_addr)
|
||||
|
|
@ -358,6 +358,19 @@ gboolean nm_ethernet_address_is_valid (const struct ether_addr *test_addr)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_ethernet_addresses_are_equal
|
||||
*
|
||||
* Compare two Ethernet addresses and return TRUE if equal and FALSE if not.
|
||||
*/
|
||||
gboolean nm_ethernet_addresses_are_equal (const struct ether_addr *a, const struct ether_addr *b)
|
||||
{
|
||||
if (memcmp (a, b, sizeof (struct ether_addr)))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_spawn_process
|
||||
*
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ void nm_print_open_socks (void);
|
|||
int nm_null_safe_strcmp (const char *s1, const char *s2);
|
||||
|
||||
gboolean nm_ethernet_address_is_valid (const struct ether_addr *test_addr);
|
||||
gboolean nm_ethernet_addresses_are_equal (const struct ether_addr *a, const struct ether_addr *b);
|
||||
|
||||
int nm_spawn_process (const char *args);
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection, NMActR
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* nm_dbus_update_network_info
|
||||
*
|
||||
|
|
|
|||
|
|
@ -137,6 +137,137 @@ static void nm_device_802_11_wireless_event (NmNetlinkMonitor *monitor,
|
|||
int data_len,
|
||||
NMDevice80211Wireless *self);
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_802_11_wireless_update_bssid
|
||||
*
|
||||
* Update the current wireless network's BSSID, presumably in response to
|
||||
* roaming.
|
||||
*
|
||||
*/
|
||||
static void
|
||||
nm_device_802_11_wireless_update_bssid (NMDevice80211Wireless *self)
|
||||
{
|
||||
NMAccessPoint * ap;
|
||||
NMActRequest * req;
|
||||
struct ether_addr new_bssid;
|
||||
const struct ether_addr *old_bssid;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
/* Grab the scan lock since the current AP is meaningless during a scan. */
|
||||
if (!nm_try_acquire_mutex (self->priv->scan_mutex, __FUNCTION__))
|
||||
return;
|
||||
|
||||
/* If we aren't the active device with an active AP, there is no meaningful BSSID value */
|
||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||
if (!req)
|
||||
goto out;
|
||||
|
||||
ap = nm_act_request_get_ap (req);
|
||||
if (!ap)
|
||||
goto out;
|
||||
|
||||
/* Get the current BSSID. If it is valid but does not match the stored value, update it. */
|
||||
nm_device_802_11_wireless_get_bssid (self, &new_bssid);
|
||||
old_bssid = nm_ap_get_address (ap);
|
||||
if (nm_ethernet_address_is_valid (&new_bssid) && !nm_ethernet_addresses_are_equal (&new_bssid, old_bssid))
|
||||
{
|
||||
NMData * app_data;
|
||||
gboolean automatic;
|
||||
gchar new_addr[20];
|
||||
gchar old_addr[20];
|
||||
|
||||
memset (new_addr, '\0', sizeof (new_addr));
|
||||
memset (old_addr, '\0', sizeof (old_addr));
|
||||
iw_ether_ntop (&new_bssid, new_addr);
|
||||
iw_ether_ntop (old_bssid, old_addr);
|
||||
nm_debug ("Roamed from BSSID %s to %s on wireless network '%s'", old_addr, new_addr, nm_ap_get_essid (ap));
|
||||
|
||||
nm_ap_set_address (ap, &new_bssid);
|
||||
|
||||
automatic = !nm_act_request_get_user_requested (req);
|
||||
app_data = nm_device_get_app_data (NM_DEVICE (self));
|
||||
g_assert (app_data);
|
||||
nm_dbus_update_network_info (app_data->dbus_connection, ap, automatic);
|
||||
}
|
||||
|
||||
out:
|
||||
nm_unlock_mutex (self->priv->scan_mutex, __func__);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_802_11_wireless_update_signal_strength
|
||||
*
|
||||
* Update the device's idea of the strength of its connection to the
|
||||
* current access point.
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_device_802_11_wireless_update_signal_strength (NMDevice80211Wireless *self)
|
||||
{
|
||||
NMData * app_data;
|
||||
gboolean has_range = FALSE;
|
||||
NMSock * sk;
|
||||
iwrange range;
|
||||
iwstats stats;
|
||||
int percent = -1;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
/* Signal strength is pretty meaningless during a scan */
|
||||
if (self->priv->scanning)
|
||||
return;
|
||||
|
||||
app_data = nm_device_get_app_data (NM_DEVICE (self));
|
||||
g_assert (app_data);
|
||||
|
||||
/* If we aren't the active device, we don't really have a signal strength
|
||||
* that would mean anything.
|
||||
*/
|
||||
if (!nm_device_get_act_request (NM_DEVICE (self)))
|
||||
{
|
||||
self->priv->strength = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_WIRELESS, __FUNCTION__, NULL)))
|
||||
{
|
||||
const char *iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
|
||||
memset (&range, 0, sizeof (iwrange));
|
||||
memset (&stats, 0, sizeof (iwstats));
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'iwrange'.", iface);
|
||||
#endif
|
||||
has_range = (iw_get_range_info (nm_dev_sock_get_fd (sk), iface, &range) >= 0);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'iwstats'.", iface);
|
||||
#endif
|
||||
if (iw_get_stats (nm_dev_sock_get_fd (sk), iface, &stats, &range, has_range) == 0)
|
||||
{
|
||||
percent = wireless_qual_to_percent (&stats.qual, (const iwqual *)(&self->priv->max_qual),
|
||||
(const iwqual *)(&self->priv->avg_qual));
|
||||
}
|
||||
nm_dev_sock_close (sk);
|
||||
}
|
||||
|
||||
/* Try to smooth out the strength. Atmel cards, for example, will give no strength
|
||||
* one second and normal strength the next.
|
||||
*/
|
||||
if ((percent == -1) && (++self->priv->invalid_strength_counter <= 3))
|
||||
percent = self->priv->strength;
|
||||
else
|
||||
self->priv->invalid_strength_counter = 0;
|
||||
|
||||
if (percent != self->priv->strength)
|
||||
nm_dbus_signal_device_strength_change (app_data->dbus_connection, self, percent);
|
||||
|
||||
self->priv->strength = percent;
|
||||
}
|
||||
|
||||
|
||||
static guint nm_wireless_scan_interval_to_seconds (NMWirelessScanInterval interval)
|
||||
{
|
||||
guint seconds;
|
||||
|
|
@ -456,6 +587,7 @@ nm_device_802_11_periodic_update (gpointer data)
|
|||
g_return_val_if_fail (self != NULL, TRUE);
|
||||
|
||||
nm_device_802_11_wireless_update_signal_strength (self);
|
||||
nm_device_802_11_wireless_update_bssid (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1235,77 +1367,6 @@ max_qual->updated);
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_802_11_wireless_update_signal_strength
|
||||
*
|
||||
* Update the device's idea of the strength of its connection to the
|
||||
* current access point.
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_device_802_11_wireless_update_signal_strength (NMDevice80211Wireless *self)
|
||||
{
|
||||
NMData * app_data;
|
||||
gboolean has_range = FALSE;
|
||||
NMSock * sk;
|
||||
iwrange range;
|
||||
iwstats stats;
|
||||
int percent = -1;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
/* Signal strength is pretty meaningless during a scan */
|
||||
if (self->priv->scanning)
|
||||
return;
|
||||
|
||||
app_data = nm_device_get_app_data (NM_DEVICE (self));
|
||||
g_assert (app_data);
|
||||
|
||||
/* If we aren't the active device, we don't really have a signal strength
|
||||
* that would mean anything.
|
||||
*/
|
||||
if (!nm_device_get_act_request (NM_DEVICE (self)))
|
||||
{
|
||||
self->priv->strength = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_WIRELESS, __FUNCTION__, NULL)))
|
||||
{
|
||||
const char *iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
|
||||
memset (&range, 0, sizeof (iwrange));
|
||||
memset (&stats, 0, sizeof (iwstats));
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'iwrange'.", iface);
|
||||
#endif
|
||||
has_range = (iw_get_range_info (nm_dev_sock_get_fd (sk), iface, &range) >= 0);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'iwstats'.", iface);
|
||||
#endif
|
||||
if (iw_get_stats (nm_dev_sock_get_fd (sk), iface, &stats, &range, has_range) == 0)
|
||||
{
|
||||
percent = wireless_qual_to_percent (&stats.qual, (const iwqual *)(&self->priv->max_qual),
|
||||
(const iwqual *)(&self->priv->avg_qual));
|
||||
}
|
||||
nm_dev_sock_close (sk);
|
||||
}
|
||||
|
||||
/* Try to smooth out the strength. Atmel cards, for example, will give no strength
|
||||
* one second and normal strength the next.
|
||||
*/
|
||||
if ((percent == -1) && (++self->priv->invalid_strength_counter <= 3))
|
||||
percent = self->priv->strength;
|
||||
else
|
||||
self->priv->invalid_strength_counter = 0;
|
||||
|
||||
if (percent != self->priv->strength)
|
||||
nm_dbus_signal_device_strength_change (app_data->dbus_connection, self, percent);
|
||||
|
||||
self->priv->strength = percent;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_get_essid
|
||||
*
|
||||
|
|
@ -1630,7 +1691,7 @@ nm_device_802_11_wireless_get_bssid (NMDevice80211Wireless *self,
|
|||
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_WIRELESS, __FUNCTION__, NULL)))
|
||||
{
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWAP.", iface);
|
||||
nm_info ("%s: About to GET IWAP.", iface);
|
||||
#endif
|
||||
if (iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWAP, &wrq) >= 0)
|
||||
memcpy (bssid, &(wrq.u.ap_addr.sa_data), sizeof (struct ether_addr));
|
||||
|
|
|
|||
|
|
@ -120,8 +120,6 @@ int nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *self);
|
|||
|
||||
gint8 nm_device_802_11_wireless_get_signal_strength (NMDevice80211Wireless *self);
|
||||
|
||||
void nm_device_802_11_wireless_update_signal_strength (NMDevice80211Wireless *self);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue