2004-06-24 14:18:37 +00:00
|
|
|
/* 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 <glib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/socket.h>
|
2004-07-06 01:34:10 +00:00
|
|
|
#include <linux/sockios.h>
|
2004-09-08 18:14:42 +00:00
|
|
|
#include <syslog.h>
|
2004-06-24 14:18:37 +00:00
|
|
|
|
|
|
|
|
#include "NetworkManager.h"
|
|
|
|
|
#include "NetworkManagerUtils.h"
|
|
|
|
|
|
|
|
|
|
|
2004-10-13 20:57:23 +00:00
|
|
|
/*#define LOCKING_DEBUG */
|
2004-08-11 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c:
- (main): clean up Seth's code style
* info-daemon/NetworkManagerInfoDbus.c:
- Use the more aptly-named path/service/interface constants from NetworkManager
- Don't return empty strings ("") as object paths ever, instead return errors
* panel-applet/NMWirelessApplet.c:
- Clean up Seth's code style
* src/NetworkManager.[ch]
- (nm_remove_device_from_list): remove anything having to do with pending_device
- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon
* src/NetworkManagerAPList.[ch]
- Move Iter struct right above the iter functions to preserve opacity
- (nm_ap_list_remove_ap): implement
- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
remove AP if NetworkManagerInfo doesn't know anything about it
- (nm_ap_list_diff): user NMAPList iterators
- (nm_ap_list_print_members): implement debugging function
* src/NetworkManagerDbus.[ch]
- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
and move the actual key setting stuff into NetworkManagerDevice.c
- (nm_dbus_get_network_priority): return -1 now on errors
- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
get lost, and force the active device to update its "best" ap when AP lists change
- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
method call due to pending_device member removal
* src/NetworkManagerDevice.[ch]
- Move NMDevice structure to the top
- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
- Remove Pending Action stuff from everywhere
- (nm_device_activation_*): We now "begin" activation and start a thread to do the
activation for us. This thread blocks until all conditions for activation have
been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
then setup up the interface and runs dhclient. We have to do this because there
is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
run our main loop and respond to dbus method calls or HAL device removals/inserts
- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
can tell nm_device_activation_worker() that we've got a key
- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here
* src/NetworkManagerPolicy.c
- Remove anything to do with pending_device
- Adjust device activation to deal with activation-in-worker-thread
* src/NetworkManagerUtils.c
- Clean up locking debugging a bit
* src/NetworkManagerWireless.[ch]
- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap(). This function
was badly named and is better as a device function
* panel-applet/.cvsignore: add
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-11 18:14:02 +00:00
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/*
|
|
|
|
|
* nm_try_acquire_mutex
|
|
|
|
|
*
|
|
|
|
|
* Tries to acquire a given mutex, sleeping a bit between tries.
|
|
|
|
|
*
|
|
|
|
|
* Returns: FALSE if mutex was not acquired
|
|
|
|
|
* TRUE if mutex was successfully acquired
|
|
|
|
|
*/
|
|
|
|
|
gboolean nm_try_acquire_mutex (GMutex *mutex, const char *func)
|
|
|
|
|
{
|
|
|
|
|
gint i = 5;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (mutex != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
while (i > 0)
|
|
|
|
|
{
|
|
|
|
|
if (g_mutex_trylock (mutex))
|
|
|
|
|
{
|
2004-08-24 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerAP.[ch]
- Add a "enc_method_good" member and accessors to an Access Point
to signal when we've found the correct encryption method
for an access point
- Add a "timestamp" member and accessors, remove "priority" member
and accessors (use timestamps instead)
- Rename "wep_key"->"enc_key"
- (nm_ap_get_enc_key_hashed): new, return the correct mangled key
for a specified encryption method using the access points
source encryption key/passphrase
* src/NetworkManagerAPList.c
- When updating a network with dbus, grab timestamp now instead of
priority
* src/NetworkManagerDBus.[ch]
- Add signal for "DeviceActivating"
- Switch priority->timestamp
* src/NetworkManagerDevice.c
- Change references of "wep_key" -> "enc_key" or "key"
- Signal DeviceActivating when starting activation
- When activating a wireless device, if the access point we are connecting
to is encrypted, and we have a source key, try to generate a mangled
key and use that (ie, generate real WEP key from a passphrase)
- Rework device activation to fallback to other encryption methods if
a previous one didn't work (ie, try mangling a key as a 104-bit passphrase
first, then if that doesn't work fall back to direct hex key).
- (nm_device_update_best_ap): fix a deadlock, and use timestamps instead of
priority. We now prefer the latest access point used, rather than using
a priority scheme
- (nm_device_do_normal_scan): make the encryption method "unknown" on access
points we've just discovered, and merge in correct info from the global
access point lists
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@68 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-25 22:41:12 +00:00
|
|
|
#ifdef LOCKING_DEBUG
|
2004-08-23 19:20:49 +00:00
|
|
|
if (func) syslog (LOG_DEBUG, "MUTEX: %s got mutex 0x%X", func, mutex);
|
2004-08-11 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c:
- (main): clean up Seth's code style
* info-daemon/NetworkManagerInfoDbus.c:
- Use the more aptly-named path/service/interface constants from NetworkManager
- Don't return empty strings ("") as object paths ever, instead return errors
* panel-applet/NMWirelessApplet.c:
- Clean up Seth's code style
* src/NetworkManager.[ch]
- (nm_remove_device_from_list): remove anything having to do with pending_device
- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon
* src/NetworkManagerAPList.[ch]
- Move Iter struct right above the iter functions to preserve opacity
- (nm_ap_list_remove_ap): implement
- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
remove AP if NetworkManagerInfo doesn't know anything about it
- (nm_ap_list_diff): user NMAPList iterators
- (nm_ap_list_print_members): implement debugging function
* src/NetworkManagerDbus.[ch]
- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
and move the actual key setting stuff into NetworkManagerDevice.c
- (nm_dbus_get_network_priority): return -1 now on errors
- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
get lost, and force the active device to update its "best" ap when AP lists change
- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
method call due to pending_device member removal
* src/NetworkManagerDevice.[ch]
- Move NMDevice structure to the top
- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
- Remove Pending Action stuff from everywhere
- (nm_device_activation_*): We now "begin" activation and start a thread to do the
activation for us. This thread blocks until all conditions for activation have
been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
then setup up the interface and runs dhclient. We have to do this because there
is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
run our main loop and respond to dbus method calls or HAL device removals/inserts
- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
can tell nm_device_activation_worker() that we've got a key
- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here
* src/NetworkManagerPolicy.c
- Remove anything to do with pending_device
- Adjust device activation to deal with activation-in-worker-thread
* src/NetworkManagerUtils.c
- Clean up locking debugging a bit
* src/NetworkManagerWireless.[ch]
- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap(). This function
was badly named and is better as a device function
* panel-applet/.cvsignore: add
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-11 18:14:02 +00:00
|
|
|
#endif
|
2004-06-24 14:18:37 +00:00
|
|
|
return (TRUE);
|
|
|
|
|
}
|
2004-08-11 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c:
- (main): clean up Seth's code style
* info-daemon/NetworkManagerInfoDbus.c:
- Use the more aptly-named path/service/interface constants from NetworkManager
- Don't return empty strings ("") as object paths ever, instead return errors
* panel-applet/NMWirelessApplet.c:
- Clean up Seth's code style
* src/NetworkManager.[ch]
- (nm_remove_device_from_list): remove anything having to do with pending_device
- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon
* src/NetworkManagerAPList.[ch]
- Move Iter struct right above the iter functions to preserve opacity
- (nm_ap_list_remove_ap): implement
- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
remove AP if NetworkManagerInfo doesn't know anything about it
- (nm_ap_list_diff): user NMAPList iterators
- (nm_ap_list_print_members): implement debugging function
* src/NetworkManagerDbus.[ch]
- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
and move the actual key setting stuff into NetworkManagerDevice.c
- (nm_dbus_get_network_priority): return -1 now on errors
- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
get lost, and force the active device to update its "best" ap when AP lists change
- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
method call due to pending_device member removal
* src/NetworkManagerDevice.[ch]
- Move NMDevice structure to the top
- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
- Remove Pending Action stuff from everywhere
- (nm_device_activation_*): We now "begin" activation and start a thread to do the
activation for us. This thread blocks until all conditions for activation have
been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
then setup up the interface and runs dhclient. We have to do this because there
is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
run our main loop and respond to dbus method calls or HAL device removals/inserts
- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
can tell nm_device_activation_worker() that we've got a key
- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here
* src/NetworkManagerPolicy.c
- Remove anything to do with pending_device
- Adjust device activation to deal with activation-in-worker-thread
* src/NetworkManagerUtils.c
- Clean up locking debugging a bit
* src/NetworkManagerWireless.[ch]
- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap(). This function
was badly named and is better as a device function
* panel-applet/.cvsignore: add
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-11 18:14:02 +00:00
|
|
|
g_usleep (G_USEC_PER_SEC / 2);
|
2004-06-24 14:18:37 +00:00
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-13 20:57:23 +00:00
|
|
|
#ifdef LOCKING_DEBUG
|
|
|
|
|
if (func) syslog (LOG_DEBUG, "MUTEX: %s FAILED to get mutex 0x%X", func, mutex);
|
|
|
|
|
#endif
|
2004-06-24 14:18:37 +00:00
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_unlock_mutex
|
|
|
|
|
*
|
|
|
|
|
* Simply unlocks a mutex, balances nm_try_acquire_mutex()
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void nm_unlock_mutex (GMutex *mutex, const char *func)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (mutex != NULL);
|
|
|
|
|
|
2004-08-11 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c:
- (main): clean up Seth's code style
* info-daemon/NetworkManagerInfoDbus.c:
- Use the more aptly-named path/service/interface constants from NetworkManager
- Don't return empty strings ("") as object paths ever, instead return errors
* panel-applet/NMWirelessApplet.c:
- Clean up Seth's code style
* src/NetworkManager.[ch]
- (nm_remove_device_from_list): remove anything having to do with pending_device
- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon
* src/NetworkManagerAPList.[ch]
- Move Iter struct right above the iter functions to preserve opacity
- (nm_ap_list_remove_ap): implement
- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
remove AP if NetworkManagerInfo doesn't know anything about it
- (nm_ap_list_diff): user NMAPList iterators
- (nm_ap_list_print_members): implement debugging function
* src/NetworkManagerDbus.[ch]
- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
and move the actual key setting stuff into NetworkManagerDevice.c
- (nm_dbus_get_network_priority): return -1 now on errors
- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
get lost, and force the active device to update its "best" ap when AP lists change
- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
method call due to pending_device member removal
* src/NetworkManagerDevice.[ch]
- Move NMDevice structure to the top
- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
- Remove Pending Action stuff from everywhere
- (nm_device_activation_*): We now "begin" activation and start a thread to do the
activation for us. This thread blocks until all conditions for activation have
been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
then setup up the interface and runs dhclient. We have to do this because there
is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
run our main loop and respond to dbus method calls or HAL device removals/inserts
- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
can tell nm_device_activation_worker() that we've got a key
- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here
* src/NetworkManagerPolicy.c
- Remove anything to do with pending_device
- Adjust device activation to deal with activation-in-worker-thread
* src/NetworkManagerUtils.c
- Clean up locking debugging a bit
* src/NetworkManagerWireless.[ch]
- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap(). This function
was badly named and is better as a device function
* panel-applet/.cvsignore: add
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-11 18:14:02 +00:00
|
|
|
#ifdef LOCKING_DEBUG
|
2004-08-23 19:20:49 +00:00
|
|
|
if (func) syslog (LOG_DEBUG, "MUTEX: %s released mutex 0x%X", func, mutex);
|
2004-08-11 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c:
- (main): clean up Seth's code style
* info-daemon/NetworkManagerInfoDbus.c:
- Use the more aptly-named path/service/interface constants from NetworkManager
- Don't return empty strings ("") as object paths ever, instead return errors
* panel-applet/NMWirelessApplet.c:
- Clean up Seth's code style
* src/NetworkManager.[ch]
- (nm_remove_device_from_list): remove anything having to do with pending_device
- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon
* src/NetworkManagerAPList.[ch]
- Move Iter struct right above the iter functions to preserve opacity
- (nm_ap_list_remove_ap): implement
- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
remove AP if NetworkManagerInfo doesn't know anything about it
- (nm_ap_list_diff): user NMAPList iterators
- (nm_ap_list_print_members): implement debugging function
* src/NetworkManagerDbus.[ch]
- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
and move the actual key setting stuff into NetworkManagerDevice.c
- (nm_dbus_get_network_priority): return -1 now on errors
- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
get lost, and force the active device to update its "best" ap when AP lists change
- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
method call due to pending_device member removal
* src/NetworkManagerDevice.[ch]
- Move NMDevice structure to the top
- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
- Remove Pending Action stuff from everywhere
- (nm_device_activation_*): We now "begin" activation and start a thread to do the
activation for us. This thread blocks until all conditions for activation have
been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
then setup up the interface and runs dhclient. We have to do this because there
is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
run our main loop and respond to dbus method calls or HAL device removals/inserts
- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
can tell nm_device_activation_worker() that we've got a key
- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here
* src/NetworkManagerPolicy.c
- Remove anything to do with pending_device
- Adjust device activation to deal with activation-in-worker-thread
* src/NetworkManagerUtils.c
- Clean up locking debugging a bit
* src/NetworkManagerWireless.[ch]
- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap(). This function
was badly named and is better as a device function
* panel-applet/.cvsignore: add
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-11 18:14:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
g_mutex_unlock (mutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_null_safe_strcmp
|
|
|
|
|
*
|
|
|
|
|
* Doesn't freaking segfault if s1/s2 are NULL
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
int nm_null_safe_strcmp (const char *s1, const char *s2)
|
|
|
|
|
{
|
|
|
|
|
if (!s1 && !s2)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!s1 && s2)
|
|
|
|
|
return -1;
|
|
|
|
|
if (s1 && !s2)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return (strcmp (s1, s2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_get_network_control_socket
|
|
|
|
|
*
|
|
|
|
|
* Get a control socket for network operations.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
int nm_get_network_control_socket (void)
|
|
|
|
|
{
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
/* Try to grab a control socket */
|
|
|
|
|
fd = socket(PF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd >= 0)
|
|
|
|
|
return (fd);
|
|
|
|
|
fd = socket(PF_PACKET, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd >= 0)
|
|
|
|
|
return (fd);
|
|
|
|
|
fd = socket(PF_INET6, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd >= 0)
|
|
|
|
|
return (fd);
|
|
|
|
|
|
2004-08-23 19:20:49 +00:00
|
|
|
syslog (LOG_ERR, "nm_get_network_control_socket() could not get network control socket.");
|
2004-06-24 14:18:37 +00:00
|
|
|
return (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-07-06 01:34:10 +00:00
|
|
|
/*
|
|
|
|
|
* nm_ethernet_address_is_valid
|
|
|
|
|
*
|
|
|
|
|
* Compares an ethernet address against known invalid addresses.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean nm_ethernet_address_is_valid (struct ether_addr *test_addr)
|
|
|
|
|
{
|
|
|
|
|
gboolean valid = FALSE;
|
|
|
|
|
struct ether_addr invalid_addr1 = { {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} };
|
|
|
|
|
struct ether_addr invalid_addr2 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
|
|
|
|
|
struct ether_addr invalid_addr3 = { {0x44, 0x44, 0x44, 0x44, 0x44, 0x44} };
|
|
|
|
|
|
2004-07-15 Dan Williams <dcbw@redhat.com>
* src/Makefile.am
- Turn on warnings
* src/NetworkManager.c
- nm_create_device_and_add_to_list(): call nm_device_deactivate() rather
that doing the deactivation ourselves
- Cancel an pending actions on a device if its being removed
- Break up link state checking a bit, make non-active wireless cards
deactivated to save power
- Remove unused variables
* src/NetworkManager.h
- Add support for "pending" device
* src/NetworkManagerAP.h
src/NetworkManagerAP.c
- Add support for determining whether and AP has encryption enabled or not
- AP address is now "struct ether_addr" rather than a string
* src/NetworkManagerDbus.h
src/NetworkManagerDbus.c
- Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only)
- Changes for AP address from struct ether_addr->string
* src/NetworkManagerDevice.h
src/NetworkManagerDevice.c
- Remove unused variables, fix warnings
- Add support for Pending Actions (things that block a device from being "active"
until they are completed).
- First pending action: Get a WEP key from the user
- Add nm_device_is_wire[d|less](), rename nm_device_is_wireless()
- Clean up explicit testing of dev->iface_type to use nm_device_is_wireless()
- Update wireless link checking to try to determine if the AP we are associated
with is correct, but the WEP key we are using is just wrong. If its wrong,
trigger the GetUserKey pending action on the device
- If dhclient can't get an IP address, it brings the device down. Bring it back
up in that case, otherwise we can't scan or link-check on it
- Add IP address change notifications at appropriate points (still needs some work)
- Add nm_device_need_ap_switch(), checks whether we need to switch access points or not
* src/NetworkManagerPolicy.h
src/NetworkManagerPolicy.c
- Split out "best" access point determiniation into separate function
- Make device activation 2-stage: first the device is pending, then
in the next iteration through it becomes "active" unless it has
pending actions
* src/NetworkManagerUtils.h
src/NetworkManagerUtils.c
- Clean up unused variables and warnings
- Wrap our debug macros in {} to prevent possible confusion
* src/NetworkManagerWireless.c
- Forgot to return current best priority, which lead to last available AP always
being chosen no matter what its priority was. Corrected.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
|
|
|
g_return_val_if_fail (test_addr != NULL, FALSE);
|
2004-07-06 01:34:10 +00:00
|
|
|
|
|
|
|
|
/* Compare the AP address the card has with invalid ethernet MAC addresses. */
|
|
|
|
|
if ( (memcmp(test_addr, &invalid_addr1, sizeof(struct ether_addr)) != 0)
|
|
|
|
|
&& (memcmp(test_addr, &invalid_addr2, sizeof(struct ether_addr)) != 0)
|
|
|
|
|
&& (memcmp(test_addr, &invalid_addr3, sizeof(struct ether_addr)) != 0))
|
|
|
|
|
valid = TRUE;
|
|
|
|
|
|
|
|
|
|
return (valid);
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_dispose_scan_results
|
|
|
|
|
*
|
|
|
|
|
* Free memory used by the wireless scan results structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void nm_dispose_scan_results (wireless_scan *result_list)
|
|
|
|
|
{
|
|
|
|
|
wireless_scan *tmp = result_list;
|
|
|
|
|
|
|
|
|
|
while (tmp)
|
|
|
|
|
{
|
|
|
|
|
wireless_scan *tmp2 = tmp;
|
|
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
|
free (tmp2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-06 01:34:10 +00:00
|
|
|
|
2004-08-12 Dan Williams <dcbw@redhat.com>
* info-daemon/passphrase.glade
- Set window title to " "
* panel-applet/Makefile.am
panel-applet/keyring.png
- Deliver to correct place
* panel-applet/NMWirelessApplet.[ch]
- Add comments
- Remove applet->have_active_device as its no longer used
- (nmwa_load_theme): load keyring.png too
- (error_dialog): remove
- (show_warning_dialog): subsume functionality of error dialog too
- (nmwa_destroy, nmwa_new): create and dispose of an application-wide GConfClient
- (nmwa_handle_network_choice): add to deal with user clicking on an item from
the networks menu
- (nmwa_menu_item_activated): GtkMenuItem "activate" signal handler
- (nmwa_button_clicked, nmwa_setup_widgets): create and populate the menu on startup
and when we get broadcasts of changed wireless access points only, not when the
user clicks on the button to display the menu (too long of a wait)
- (nmwa_add_menu_item): Make active network bold, and place a keyring icon beside
networks that are encrypted
- (nmwa_dispose_menu, nmwa_menu_item_data_free): dispose of the data we place on each
menu item with g_object_set_data()
* panel-applet/NMWirelessAppletDbus.[ch]
- (nmwa_dbus_get_bool): add method to return boolean value from dbus message
- (nmwa_dbus_get_active_network): add (nmwa_dbus_get_string() wrapper to get active network)
- (nmwa_dbus_add_networks_to_menu): clean up, only show one instance of each ESSID in the menu
- (nmwa_dbus_set_network): force NetworkManager to use a particular network for wireless cards
- (nmwa_dbus_init, nmwa_dbus_filter): Trap network appear/disappear and device
activation/deactivation signals and rebuild the menu when they happen
* src/NetworkManager.c
- (main): use new nm_spawn_process() rather than system()
* src/NetworkManagerDbus.c
- (nm_dbus_devices_handle_request): don't compare AP structure addresses directly, but essids
instead. Since we can now force best_aps to stick around, the AP structure to which
dev->options.wireless.best_ap points to won't necessarily be in the device's device list
if a scan has happened since the best_ap was frozen. Also add "setNetwork" method
to freeze the best_ap.
* src/NetworkManagerDevice.[ch]
- (nm_device_activation_worker): Use new nm_spawn_process() call rather than system()
- (nm_device_*_best_ap): add freeze/unfreeze/get_frozen functions, and don't really update
the best_ap in nm_device_update_best_ap() if the best_ap is frozen AND in the device's
ap list
* src/NetworkManagerUtils.[ch]
- (nm_spawn_process): add replacement for system() usage
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@48 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-12 19:58:01 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_spawn_process
|
|
|
|
|
*
|
|
|
|
|
* Wrap g_spawn_sync in a usable manner
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
int nm_spawn_process (char *args)
|
|
|
|
|
{
|
|
|
|
|
gint num_args;
|
|
|
|
|
char **argv;
|
|
|
|
|
int exit_status;
|
2004-10-12 11:15:47 +00:00
|
|
|
GError *error = NULL;
|
2004-08-12 Dan Williams <dcbw@redhat.com>
* info-daemon/passphrase.glade
- Set window title to " "
* panel-applet/Makefile.am
panel-applet/keyring.png
- Deliver to correct place
* panel-applet/NMWirelessApplet.[ch]
- Add comments
- Remove applet->have_active_device as its no longer used
- (nmwa_load_theme): load keyring.png too
- (error_dialog): remove
- (show_warning_dialog): subsume functionality of error dialog too
- (nmwa_destroy, nmwa_new): create and dispose of an application-wide GConfClient
- (nmwa_handle_network_choice): add to deal with user clicking on an item from
the networks menu
- (nmwa_menu_item_activated): GtkMenuItem "activate" signal handler
- (nmwa_button_clicked, nmwa_setup_widgets): create and populate the menu on startup
and when we get broadcasts of changed wireless access points only, not when the
user clicks on the button to display the menu (too long of a wait)
- (nmwa_add_menu_item): Make active network bold, and place a keyring icon beside
networks that are encrypted
- (nmwa_dispose_menu, nmwa_menu_item_data_free): dispose of the data we place on each
menu item with g_object_set_data()
* panel-applet/NMWirelessAppletDbus.[ch]
- (nmwa_dbus_get_bool): add method to return boolean value from dbus message
- (nmwa_dbus_get_active_network): add (nmwa_dbus_get_string() wrapper to get active network)
- (nmwa_dbus_add_networks_to_menu): clean up, only show one instance of each ESSID in the menu
- (nmwa_dbus_set_network): force NetworkManager to use a particular network for wireless cards
- (nmwa_dbus_init, nmwa_dbus_filter): Trap network appear/disappear and device
activation/deactivation signals and rebuild the menu when they happen
* src/NetworkManager.c
- (main): use new nm_spawn_process() rather than system()
* src/NetworkManagerDbus.c
- (nm_dbus_devices_handle_request): don't compare AP structure addresses directly, but essids
instead. Since we can now force best_aps to stick around, the AP structure to which
dev->options.wireless.best_ap points to won't necessarily be in the device's device list
if a scan has happened since the best_ap was frozen. Also add "setNetwork" method
to freeze the best_ap.
* src/NetworkManagerDevice.[ch]
- (nm_device_activation_worker): Use new nm_spawn_process() call rather than system()
- (nm_device_*_best_ap): add freeze/unfreeze/get_frozen functions, and don't really update
the best_ap in nm_device_update_best_ap() if the best_ap is frozen AND in the device's
ap list
* src/NetworkManagerUtils.[ch]
- (nm_spawn_process): add replacement for system() usage
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@48 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-12 19:58:01 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (args != NULL, -1);
|
|
|
|
|
|
|
|
|
|
if (g_shell_parse_argv (args, &num_args, &argv, NULL))
|
|
|
|
|
{
|
2004-10-12 11:15:47 +00:00
|
|
|
if (g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &exit_status, &error))
|
2004-08-12 Dan Williams <dcbw@redhat.com>
* info-daemon/passphrase.glade
- Set window title to " "
* panel-applet/Makefile.am
panel-applet/keyring.png
- Deliver to correct place
* panel-applet/NMWirelessApplet.[ch]
- Add comments
- Remove applet->have_active_device as its no longer used
- (nmwa_load_theme): load keyring.png too
- (error_dialog): remove
- (show_warning_dialog): subsume functionality of error dialog too
- (nmwa_destroy, nmwa_new): create and dispose of an application-wide GConfClient
- (nmwa_handle_network_choice): add to deal with user clicking on an item from
the networks menu
- (nmwa_menu_item_activated): GtkMenuItem "activate" signal handler
- (nmwa_button_clicked, nmwa_setup_widgets): create and populate the menu on startup
and when we get broadcasts of changed wireless access points only, not when the
user clicks on the button to display the menu (too long of a wait)
- (nmwa_add_menu_item): Make active network bold, and place a keyring icon beside
networks that are encrypted
- (nmwa_dispose_menu, nmwa_menu_item_data_free): dispose of the data we place on each
menu item with g_object_set_data()
* panel-applet/NMWirelessAppletDbus.[ch]
- (nmwa_dbus_get_bool): add method to return boolean value from dbus message
- (nmwa_dbus_get_active_network): add (nmwa_dbus_get_string() wrapper to get active network)
- (nmwa_dbus_add_networks_to_menu): clean up, only show one instance of each ESSID in the menu
- (nmwa_dbus_set_network): force NetworkManager to use a particular network for wireless cards
- (nmwa_dbus_init, nmwa_dbus_filter): Trap network appear/disappear and device
activation/deactivation signals and rebuild the menu when they happen
* src/NetworkManager.c
- (main): use new nm_spawn_process() rather than system()
* src/NetworkManagerDbus.c
- (nm_dbus_devices_handle_request): don't compare AP structure addresses directly, but essids
instead. Since we can now force best_aps to stick around, the AP structure to which
dev->options.wireless.best_ap points to won't necessarily be in the device's device list
if a scan has happened since the best_ap was frozen. Also add "setNetwork" method
to freeze the best_ap.
* src/NetworkManagerDevice.[ch]
- (nm_device_activation_worker): Use new nm_spawn_process() call rather than system()
- (nm_device_*_best_ap): add freeze/unfreeze/get_frozen functions, and don't really update
the best_ap in nm_device_update_best_ap() if the best_ap is frozen AND in the device's
ap list
* src/NetworkManagerUtils.[ch]
- (nm_spawn_process): add replacement for system() usage
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@48 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-12 19:58:01 +00:00
|
|
|
{
|
|
|
|
|
g_strfreev (argv);
|
|
|
|
|
return (exit_status);
|
|
|
|
|
}
|
2004-10-12 11:15:47 +00:00
|
|
|
else
|
|
|
|
|
syslog (LOG_ERR, "nm_spawn_process('%s'): could not spawn process. (%s)\n", args, error->message);
|
|
|
|
|
|
2004-08-12 Dan Williams <dcbw@redhat.com>
* info-daemon/passphrase.glade
- Set window title to " "
* panel-applet/Makefile.am
panel-applet/keyring.png
- Deliver to correct place
* panel-applet/NMWirelessApplet.[ch]
- Add comments
- Remove applet->have_active_device as its no longer used
- (nmwa_load_theme): load keyring.png too
- (error_dialog): remove
- (show_warning_dialog): subsume functionality of error dialog too
- (nmwa_destroy, nmwa_new): create and dispose of an application-wide GConfClient
- (nmwa_handle_network_choice): add to deal with user clicking on an item from
the networks menu
- (nmwa_menu_item_activated): GtkMenuItem "activate" signal handler
- (nmwa_button_clicked, nmwa_setup_widgets): create and populate the menu on startup
and when we get broadcasts of changed wireless access points only, not when the
user clicks on the button to display the menu (too long of a wait)
- (nmwa_add_menu_item): Make active network bold, and place a keyring icon beside
networks that are encrypted
- (nmwa_dispose_menu, nmwa_menu_item_data_free): dispose of the data we place on each
menu item with g_object_set_data()
* panel-applet/NMWirelessAppletDbus.[ch]
- (nmwa_dbus_get_bool): add method to return boolean value from dbus message
- (nmwa_dbus_get_active_network): add (nmwa_dbus_get_string() wrapper to get active network)
- (nmwa_dbus_add_networks_to_menu): clean up, only show one instance of each ESSID in the menu
- (nmwa_dbus_set_network): force NetworkManager to use a particular network for wireless cards
- (nmwa_dbus_init, nmwa_dbus_filter): Trap network appear/disappear and device
activation/deactivation signals and rebuild the menu when they happen
* src/NetworkManager.c
- (main): use new nm_spawn_process() rather than system()
* src/NetworkManagerDbus.c
- (nm_dbus_devices_handle_request): don't compare AP structure addresses directly, but essids
instead. Since we can now force best_aps to stick around, the AP structure to which
dev->options.wireless.best_ap points to won't necessarily be in the device's device list
if a scan has happened since the best_ap was frozen. Also add "setNetwork" method
to freeze the best_ap.
* src/NetworkManagerDevice.[ch]
- (nm_device_activation_worker): Use new nm_spawn_process() call rather than system()
- (nm_device_*_best_ap): add freeze/unfreeze/get_frozen functions, and don't really update
the best_ap in nm_device_update_best_ap() if the best_ap is frozen AND in the device's
ap list
* src/NetworkManagerUtils.[ch]
- (nm_spawn_process): add replacement for system() usage
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@48 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-12 19:58:01 +00:00
|
|
|
g_strfreev (argv);
|
2004-10-12 11:15:47 +00:00
|
|
|
if (error)
|
|
|
|
|
g_error_free (error);
|
2004-08-12 Dan Williams <dcbw@redhat.com>
* info-daemon/passphrase.glade
- Set window title to " "
* panel-applet/Makefile.am
panel-applet/keyring.png
- Deliver to correct place
* panel-applet/NMWirelessApplet.[ch]
- Add comments
- Remove applet->have_active_device as its no longer used
- (nmwa_load_theme): load keyring.png too
- (error_dialog): remove
- (show_warning_dialog): subsume functionality of error dialog too
- (nmwa_destroy, nmwa_new): create and dispose of an application-wide GConfClient
- (nmwa_handle_network_choice): add to deal with user clicking on an item from
the networks menu
- (nmwa_menu_item_activated): GtkMenuItem "activate" signal handler
- (nmwa_button_clicked, nmwa_setup_widgets): create and populate the menu on startup
and when we get broadcasts of changed wireless access points only, not when the
user clicks on the button to display the menu (too long of a wait)
- (nmwa_add_menu_item): Make active network bold, and place a keyring icon beside
networks that are encrypted
- (nmwa_dispose_menu, nmwa_menu_item_data_free): dispose of the data we place on each
menu item with g_object_set_data()
* panel-applet/NMWirelessAppletDbus.[ch]
- (nmwa_dbus_get_bool): add method to return boolean value from dbus message
- (nmwa_dbus_get_active_network): add (nmwa_dbus_get_string() wrapper to get active network)
- (nmwa_dbus_add_networks_to_menu): clean up, only show one instance of each ESSID in the menu
- (nmwa_dbus_set_network): force NetworkManager to use a particular network for wireless cards
- (nmwa_dbus_init, nmwa_dbus_filter): Trap network appear/disappear and device
activation/deactivation signals and rebuild the menu when they happen
* src/NetworkManager.c
- (main): use new nm_spawn_process() rather than system()
* src/NetworkManagerDbus.c
- (nm_dbus_devices_handle_request): don't compare AP structure addresses directly, but essids
instead. Since we can now force best_aps to stick around, the AP structure to which
dev->options.wireless.best_ap points to won't necessarily be in the device's device list
if a scan has happened since the best_ap was frozen. Also add "setNetwork" method
to freeze the best_ap.
* src/NetworkManagerDevice.[ch]
- (nm_device_activation_worker): Use new nm_spawn_process() call rather than system()
- (nm_device_*_best_ap): add freeze/unfreeze/get_frozen functions, and don't really update
the best_ap in nm_device_update_best_ap() if the best_ap is frozen AND in the device's
ap list
* src/NetworkManagerUtils.[ch]
- (nm_spawn_process): add replacement for system() usage
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@48 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-12 19:58:01 +00:00
|
|
|
}
|
2004-10-12 11:15:47 +00:00
|
|
|
else
|
|
|
|
|
syslog (LOG_ERR, "nm_spawn_process('%s'): could not parse arguments (%s)\n", args, error->message);
|
2004-08-12 Dan Williams <dcbw@redhat.com>
* info-daemon/passphrase.glade
- Set window title to " "
* panel-applet/Makefile.am
panel-applet/keyring.png
- Deliver to correct place
* panel-applet/NMWirelessApplet.[ch]
- Add comments
- Remove applet->have_active_device as its no longer used
- (nmwa_load_theme): load keyring.png too
- (error_dialog): remove
- (show_warning_dialog): subsume functionality of error dialog too
- (nmwa_destroy, nmwa_new): create and dispose of an application-wide GConfClient
- (nmwa_handle_network_choice): add to deal with user clicking on an item from
the networks menu
- (nmwa_menu_item_activated): GtkMenuItem "activate" signal handler
- (nmwa_button_clicked, nmwa_setup_widgets): create and populate the menu on startup
and when we get broadcasts of changed wireless access points only, not when the
user clicks on the button to display the menu (too long of a wait)
- (nmwa_add_menu_item): Make active network bold, and place a keyring icon beside
networks that are encrypted
- (nmwa_dispose_menu, nmwa_menu_item_data_free): dispose of the data we place on each
menu item with g_object_set_data()
* panel-applet/NMWirelessAppletDbus.[ch]
- (nmwa_dbus_get_bool): add method to return boolean value from dbus message
- (nmwa_dbus_get_active_network): add (nmwa_dbus_get_string() wrapper to get active network)
- (nmwa_dbus_add_networks_to_menu): clean up, only show one instance of each ESSID in the menu
- (nmwa_dbus_set_network): force NetworkManager to use a particular network for wireless cards
- (nmwa_dbus_init, nmwa_dbus_filter): Trap network appear/disappear and device
activation/deactivation signals and rebuild the menu when they happen
* src/NetworkManager.c
- (main): use new nm_spawn_process() rather than system()
* src/NetworkManagerDbus.c
- (nm_dbus_devices_handle_request): don't compare AP structure addresses directly, but essids
instead. Since we can now force best_aps to stick around, the AP structure to which
dev->options.wireless.best_ap points to won't necessarily be in the device's device list
if a scan has happened since the best_ap was frozen. Also add "setNetwork" method
to freeze the best_ap.
* src/NetworkManagerDevice.[ch]
- (nm_device_activation_worker): Use new nm_spawn_process() call rather than system()
- (nm_device_*_best_ap): add freeze/unfreeze/get_frozen functions, and don't really update
the best_ap in nm_device_update_best_ap() if the best_ap is frozen AND in the device's
ap list
* src/NetworkManagerUtils.[ch]
- (nm_spawn_process): add replacement for system() usage
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@48 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-12 19:58:01 +00:00
|
|
|
|
|
|
|
|
return (-1);
|
|
|
|
|
}
|
2004-08-16 19:46:43 +00:00
|
|
|
|
2004-10-21 17:42:14 +00:00
|
|
|
|
|
|
|
|
typedef struct driver_support
|
|
|
|
|
{
|
|
|
|
|
char *name;
|
|
|
|
|
NMDriverSupportLevel level;
|
|
|
|
|
} driver_support;
|
|
|
|
|
|
|
|
|
|
/* The list of wireless drivers we support and how well we support each */
|
|
|
|
|
static driver_support wireless_driver_support_list[] =
|
|
|
|
|
{
|
|
|
|
|
/* Fully supported drivers */
|
|
|
|
|
{"airo_cs", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"airo", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"atmel_cs", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"atmel", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"atmel_pci", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"prism54", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"wl3501_cs", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"ipw2100", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"ipw2200", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"ath_pci", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
{"ath_cs", NM_DRIVER_FULLY_SUPPORTED},
|
|
|
|
|
/* Semi-supported drivers, for example ones that don't support
|
|
|
|
|
* wireless scanning yet in-kernel
|
|
|
|
|
*/
|
|
|
|
|
{"hermes", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"netwave_cs", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"orinoco_cs", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"orinoco", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"orinoco_pci", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"orinoco_plx", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"orinoco_tmd", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"wavelan_cs", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{"wavelan", NM_DRIVER_SEMI_SUPPORTED},
|
|
|
|
|
{NULL, NM_DRIVER_UNSUPPORTED}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Blacklist of unsupported wired drivers */
|
|
|
|
|
static driver_support wired_driver_blacklist[] =
|
|
|
|
|
{
|
|
|
|
|
/* Completely unsupported drivers */
|
|
|
|
|
{NULL, NM_DRIVER_UNSUPPORTED}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_get_device_driver_name
|
|
|
|
|
*
|
|
|
|
|
* Checks either /proc/sys/bus/devices or /var/lib/pcmcia/stab to determine
|
|
|
|
|
* which driver is bound to the device.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
char *nm_get_device_driver_name (LibHalContext *ctx, NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
FILE *f;
|
|
|
|
|
char *driver_name = NULL;
|
|
|
|
|
int vendor;
|
|
|
|
|
int product;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (dev != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
vendor = hal_device_get_property_int (ctx, nm_device_get_udi (dev), "pci.vendor_id");
|
|
|
|
|
product = hal_device_get_property_int (ctx, nm_device_get_udi (dev), "pci.product_id");
|
|
|
|
|
|
|
|
|
|
if (vendor && product)
|
|
|
|
|
{
|
|
|
|
|
if ((f = fopen ("/proc/bus/pci/devices", "r")))
|
|
|
|
|
{
|
|
|
|
|
char buf[200];
|
|
|
|
|
char id[9];
|
|
|
|
|
|
|
|
|
|
snprintf (&id[0], 9, "%4X%4X", vendor, product);
|
|
|
|
|
id[8] = '\0';
|
|
|
|
|
while (fgets (&buf[0], 200, f) && !feof (f))
|
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
char s[9];
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
/* Whack newline */
|
|
|
|
|
buf[199] = '\0';
|
|
|
|
|
len = strlen (buf);
|
|
|
|
|
if ((buf[len-1] == '\n') || (buf[len-1] == '\r'))
|
|
|
|
|
{
|
|
|
|
|
buf[len-1] = '\0';
|
|
|
|
|
len--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p = strchr (buf, '\t');
|
|
|
|
|
s[8] = '\0';
|
|
|
|
|
strncpy (&s[0], p+1, 8);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (&s[0], &id[0]))
|
|
|
|
|
{
|
|
|
|
|
/* Yay, we've got a match. Pull the driver name from the
|
|
|
|
|
* last word in the line.
|
|
|
|
|
*/
|
|
|
|
|
char *m = strrchr (&buf[0], '\t');
|
|
|
|
|
if (m && (m > &buf[0]) && (m < &buf[len]))
|
|
|
|
|
{
|
|
|
|
|
driver_name = strdup (m+1);
|
|
|
|
|
syslog (LOG_INFO, "PCI driver for '%s' is '%s'", nm_device_get_iface (dev), driver_name);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fclose (f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Might be a PCMCIA card, try /var/lib/pcmcia/stab and match the interface name.
|
|
|
|
|
*
|
|
|
|
|
* stab has a format like this:
|
|
|
|
|
* Socket 0: Belkin F5D6020 rev.2
|
|
|
|
|
* 0 network atmel_cs 0 eth2
|
|
|
|
|
* Socket 1: Belkin-5020
|
|
|
|
|
* 1 network pcnet_cs 0 eth1
|
|
|
|
|
*/
|
|
|
|
|
if (!driver_name && (f = fopen ("/var/lib/pcmcia/stab", "r")))
|
|
|
|
|
{
|
|
|
|
|
char buf[200];
|
|
|
|
|
|
|
|
|
|
while (fgets (&buf[0], 200, f) && !feof (f))
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
|
/* Whack newline */
|
|
|
|
|
buf[199] = '\0';
|
|
|
|
|
len = strlen (buf);
|
|
|
|
|
if ((buf[len-1] == '\n') || (buf[len-1] == '\r'))
|
|
|
|
|
{
|
|
|
|
|
buf[len-1] = '\0';
|
|
|
|
|
len--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ignore lines that start with "Socket" */
|
|
|
|
|
if (strncmp (&buf[0], "Socket", 6) && (p = strrchr (&buf[0], '\t')))
|
|
|
|
|
{
|
|
|
|
|
/* See if this device's interface matches our device's interface */
|
|
|
|
|
if (!strcmp (++p, nm_device_get_iface (dev)))
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
/* Pull out driver name by seeking to _second_ tab */
|
|
|
|
|
if ((p = strchr (&buf[0], '\t')) && *(p++) && (p = strchr (p, '\t')))
|
|
|
|
|
{
|
|
|
|
|
p++;
|
|
|
|
|
end = strchr (p, '\t');
|
|
|
|
|
if (p && end)
|
|
|
|
|
{
|
|
|
|
|
*end = '\0';
|
|
|
|
|
driver_name = strdup (p);
|
|
|
|
|
syslog (LOG_INFO, "PCMCIA driver for '%s' is '%s'", nm_device_get_iface (dev), driver_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fclose (f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (driver_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_get_wireless_driver_support_level
|
|
|
|
|
*
|
|
|
|
|
* Checks either /proc/sys/bus/devices or /var/lib/pcmcia/stab to determine
|
|
|
|
|
* wether or not the card's driver is supported and how well, using a whitelist.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
NMDriverSupportLevel nm_get_wireless_driver_support_level (LibHalContext *ctx, NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
NMDriverSupportLevel level = NM_DRIVER_UNSUPPORTED;
|
|
|
|
|
char *driver_name = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (dev != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if ((driver_name = nm_get_device_driver_name (ctx, dev)))
|
|
|
|
|
{
|
|
|
|
|
driver_support *driver = &wireless_driver_support_list[0];
|
|
|
|
|
while (driver->name != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (driver->name, driver_name))
|
|
|
|
|
{
|
|
|
|
|
level = driver->level;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
driver++;
|
|
|
|
|
}
|
|
|
|
|
g_free (driver_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (level);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_get_wired_driver_support_level
|
|
|
|
|
*
|
|
|
|
|
* Blacklist certain devices.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
NMDriverSupportLevel nm_get_wired_driver_support_level (LibHalContext *ctx, NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
NMDriverSupportLevel level = NM_DRIVER_FULLY_SUPPORTED;
|
|
|
|
|
char *driver_name = NULL;
|
|
|
|
|
char *usb_test;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (dev != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if ((driver_name = nm_get_device_driver_name (ctx, dev)))
|
|
|
|
|
{
|
|
|
|
|
driver_support *driver = &wired_driver_blacklist[0];
|
|
|
|
|
while (driver->name != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (driver->name, driver_name))
|
|
|
|
|
{
|
|
|
|
|
level = driver->level;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
driver++;
|
|
|
|
|
}
|
|
|
|
|
g_free (driver_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cipsec devices are also explicitly unsupported at this time */
|
|
|
|
|
if (strstr (nm_device_get_iface (dev), "cipsec"))
|
|
|
|
|
level = NM_DRIVER_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
/* Ignore Ethernet-over-USB devices too for the moment (Red Hat #135722) */
|
|
|
|
|
if ((usb_test = hal_device_get_property_string (ctx, nm_device_get_udi (dev), "usb.interface.class")))
|
|
|
|
|
{
|
|
|
|
|
hal_free_string (usb_test);
|
|
|
|
|
level = NM_DRIVER_UNSUPPORTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (level);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_get_driver_support_level
|
|
|
|
|
*
|
|
|
|
|
* Return the driver support level for a particular device.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
NMDriverSupportLevel nm_get_driver_support_level (LibHalContext *ctx, NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
NMDriverSupportLevel level = NM_DRIVER_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (ctx != NULL, NM_DRIVER_UNSUPPORTED);
|
|
|
|
|
g_return_val_if_fail (dev != NULL, NM_DRIVER_UNSUPPORTED);
|
|
|
|
|
|
|
|
|
|
if (nm_device_is_wireless (dev))
|
|
|
|
|
level = nm_get_wireless_driver_support_level (ctx, dev);
|
|
|
|
|
else if (nm_device_is_wired (dev))
|
|
|
|
|
level = nm_get_wired_driver_support_level (ctx, dev);
|
|
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
|
{
|
|
|
|
|
case NM_DRIVER_SEMI_SUPPORTED:
|
|
|
|
|
syslog (LOG_INFO, "%s: Driver support level is semi-supported", nm_device_get_iface (dev));
|
|
|
|
|
break;
|
|
|
|
|
case NM_DRIVER_FULLY_SUPPORTED:
|
|
|
|
|
syslog (LOG_INFO, "%s: Driver support level is fully-supported", nm_device_get_iface (dev));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
syslog (LOG_INFO, "%s: Driver support level is unsupported", nm_device_get_iface (dev));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (level);
|
|
|
|
|
}
|