NetworkManager/src/NetworkManagerWireless.c

225 lines
5.5 KiB
C
Raw Normal View History

/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2004 Red Hat, Inc.
*/
#include <stdio.h>
#include <iwlib.h>
#include "config.h"
#ifdef HAVE_GCRYPT
#include <gcrypt.h>
#else
#include "gnome-keyring-md5.h"
#endif
#include "NetworkManager.h"
#include "NetworkManagerDevice.h"
#include "NetworkManagerWireless.h"
#include "NetworkManagerPolicy.h"
#include "NetworkManagerUtils.h"
/*
* nm_wireless_64bit_ascii_to_hex
*
* Convert an ASCII string into a suitable WEP key.
*
*/
char *nm_wireless_64bit_ascii_to_hex (const char *ascii)
{
static char hex_digits[] = "0123456789abcdef";
unsigned char *res;
int i;
res = g_malloc (33);
for (i = 0; i < 16; i++)
{
res[2*i] = hex_digits[ascii[i] >> 4];
res[2*i+1] = hex_digits[ascii[i] & 0xf];
}
/* We chomp it at byte 10, since WEP keys only use 40 bits */
res[10] = 0;
return (res);
}
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
/*
* nm_wireless_128bit_ascii_to_hex
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
*
* Convert an ascii string into a suitable string for use
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
* as a WEP key.
*
* Code originally by Alex Larsson <alexl@redhat.com> and
* copyright Red Hat, Inc. under terms of the LGPL.
*
*/
char *nm_wireless_128bit_ascii_to_hex (const char *ascii)
{
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
static char hex_digits[] = "0123456789abcdef";
unsigned char *res;
int i;
res = g_malloc (33);
for (i = 0; i < 16; i++)
{
res[2*i] = hex_digits[ascii[i] >> 4];
res[2*i+1] = hex_digits[ascii[i] & 0xf];
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
}
/* We chomp it at byte 26, since WEP keys only use 104 bits */
res[26] = 0;
return (res);
}
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
/*
* nm_wireless_128bit_key_from_passphrase
*
* From a passphrase, generate a standard 128-bit WEP key using
* MD5 algorithm.
*
*/
char *nm_wireless_128bit_key_from_passphrase (const char *passphrase)
{
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
char md5_data[65];
unsigned char digest[16];
int passphrase_len;
int i;
g_return_val_if_fail (passphrase != NULL, NULL);
passphrase_len = strlen (passphrase);
if (passphrase_len < 1)
return (NULL);
/* Get at least 64 bits */
for (i = 0; i < 64; i++)
2004-09-08 Dan Williams <dcbw@redhat.com> * panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-09-08 18:14:42 +00:00
md5_data [i] = passphrase [i % passphrase_len];
/* Null terminate md5 data-to-hash and hash it */
md5_data[64] = 0;
#ifdef HAVE_GCRYPT
gcry_md_hash_buffer (GCRY_MD_MD5, digest, md5_data, 64);
#else
gnome_keyring_md5_string (md5_data, digest);
#endif
return (nm_wireless_128bit_ascii_to_hex (digest));
}
/*
* nm_wireless_stats_to_percent
*
* Convert an iw_stats structure from a scan or the card into
* a magical signal strength percentage.
*
*/
int nm_wireless_qual_to_percent (NMDevice *dev, const struct iw_quality *qual)
{
int percent = -1;
g_return_val_if_fail (dev != NULL, -1);
g_return_val_if_fail (qual != NULL, -1);
/* Try using the card's idea of the signal quality first */
if ((nm_device_get_max_quality (dev) == 100) && (qual->qual < 100))
{
/* Atmel driver seems to use qual->qual is the percentage value */
percent = CLAMP (qual->qual, 0, 100);
}
else if (qual->qual >= 1)
{
/* Try it the Gnome Wireless Applet way */
percent = (int)rint ((log (qual->qual) / log (94)) * 100.0);
percent = CLAMP (percent, 0, 100);
}
/* If that failed, try to calculate the signal quality based on other
* values, like Signal-to-Noise ratio.
*/
if (((percent == -1) || (percent == 0)))
{
/* If the statistics are in dBm or relative */
if(qual->level > nm_device_get_max_quality (dev))
{
#define BEST_SIGNAL 85 /* In dBm, stuck card next to AP, this is what I got */
/* Values in dBm (absolute power measurement) */
if (qual->level > 0)
percent = (int)rint ((double)(((256 - qual->level) / (double)BEST_SIGNAL) * 100));
}
else
{
/* FIXME
* Not quite sure what to do here... Above we have a "100% strength" number
* empirically derived, but I don't have any cards that trigger this code below...
*/
#if 0
/* Relative values (0 -> max) */
qual_rel = qual->level;
qual_max_rel = range->max_qual.level;
noise_rel = qual->noise;
noise_max_rel = range->max_qual.noise;
#else
percent = -1;
#endif
}
}
return (percent);
}
/*
* nm_wireless_scan_monitor
*
* Called every 10s to get a list of access points.
*
*/
gboolean nm_wireless_scan_monitor (gpointer user_data)
{
NMData *data = (NMData *)user_data;
2004-09-09 20:02:59 +00:00
GSList *element;
NMDevice *dev;
g_return_val_if_fail (data != NULL, TRUE);
/* Attempt to acquire mutex so that data->active_device sticks around.
* If the acquire fails, just ignore the scan completely.
*/
2004-09-09 20:02:59 +00:00
if (!nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
{
2004-09-09 20:02:59 +00:00
syslog (LOG_ERR, "nm_wireless_scan_monitor() could not acquire device list mutex." );
return (TRUE);
}
2004-09-09 20:02:59 +00:00
element = data->dev_list;
while (element)
{
if ((dev = (NMDevice *)(element->data)) && nm_device_is_wireless (dev))
nm_device_do_wireless_scan (dev);
element = g_slist_next (element);
}
2004-09-09 20:02:59 +00:00
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
return (TRUE);
}