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>
|
2005-09-12 17:44:45 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <arpa/inet.h>
|
2004-07-06 01:34:10 +00:00
|
|
|
#include <linux/sockios.h>
|
2004-09-08 18:14:42 +00:00
|
|
|
#include <syslog.h>
|
2005-03-26 03:42:05 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <string.h>
|
2005-04-03 02:10:27 +00:00
|
|
|
#include <signal.h>
|
2005-04-06 16:45:48 +00:00
|
|
|
#include <iwlib.h>
|
2004-06-24 14:18:37 +00:00
|
|
|
|
|
|
|
|
#include "NetworkManager.h"
|
|
|
|
|
#include "NetworkManagerUtils.h"
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
#include "nm-utils.h"
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
#include <netlink/addr.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2005-04-06 16:45:48 +00:00
|
|
|
struct NMSock
|
|
|
|
|
{
|
|
|
|
|
int fd;
|
|
|
|
|
char *func;
|
|
|
|
|
char *desc;
|
|
|
|
|
NMDevice *dev;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static GSList *sock_list = NULL;
|
|
|
|
|
static GStaticMutex sock_list_mutex = G_STATIC_MUTEX_INIT;
|
|
|
|
|
|
2005-02-02 21:49:14 +00:00
|
|
|
typedef struct MutexDesc
|
|
|
|
|
{
|
|
|
|
|
GMutex *mutex;
|
|
|
|
|
char *desc;
|
|
|
|
|
} MutexDesc;
|
|
|
|
|
|
|
|
|
|
GSList *mutex_descs = NULL;
|
|
|
|
|
|
|
|
|
|
/*#define LOCKING_DEBUG*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static MutexDesc *nm_find_mutex_desc (GMutex *mutex)
|
|
|
|
|
{
|
|
|
|
|
GSList *elt;
|
|
|
|
|
|
|
|
|
|
for (elt = mutex_descs; elt; elt = g_slist_next (elt))
|
|
|
|
|
{
|
|
|
|
|
MutexDesc *desc = (MutexDesc *)(elt->data);
|
|
|
|
|
if (desc && (desc->mutex == mutex))
|
|
|
|
|
return desc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_register_mutex_desc
|
|
|
|
|
*
|
|
|
|
|
* Associate a description with a particular mutex.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-07-13 16:58:13 +00:00
|
|
|
void nm_register_mutex_desc (GMutex *mutex, const char *string)
|
2005-02-02 21:49:14 +00:00
|
|
|
{
|
|
|
|
|
if (!(nm_find_mutex_desc (mutex)))
|
|
|
|
|
{
|
|
|
|
|
MutexDesc *desc = g_malloc0 (sizeof (MutexDesc));
|
|
|
|
|
desc->mutex = mutex;
|
|
|
|
|
desc->desc = g_strdup (string);
|
|
|
|
|
mutex_descs = g_slist_append (mutex_descs, desc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (mutex != NULL, FALSE);
|
|
|
|
|
|
2005-02-02 21:49:14 +00:00
|
|
|
if (g_mutex_trylock (mutex))
|
2004-06-24 14:18:37 +00:00
|
|
|
{
|
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
|
2005-02-02 21:49:14 +00:00
|
|
|
if (func)
|
|
|
|
|
{
|
|
|
|
|
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
nm_debug ("MUTEX: <%s %p> acquired by %s", desc ? desc->desc : "(none)", mutex, func);
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|
2005-02-02 21:49:14 +00:00
|
|
|
#endif
|
|
|
|
|
return (TRUE);
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
2004-10-13 20:57:23 +00:00
|
|
|
#ifdef LOCKING_DEBUG
|
2005-02-02 21:49:14 +00:00
|
|
|
if (func)
|
|
|
|
|
{
|
|
|
|
|
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
nm_debug ("MUTEX: <%s %p> FAILED to be acquired by %s", desc ? desc->desc : "(none)", mutex, func);
|
2005-02-02 21:49:14 +00:00
|
|
|
}
|
2004-10-13 20:57:23 +00:00
|
|
|
#endif
|
2004-06-24 14:18:37 +00:00
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-02 21:49:14 +00:00
|
|
|
/*
|
|
|
|
|
* nm_lock_mutex
|
|
|
|
|
*
|
|
|
|
|
* Blocks until a mutex is grabbed, with debugging.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void nm_lock_mutex (GMutex *mutex, const char *func)
|
|
|
|
|
{
|
|
|
|
|
#ifdef LOCKING_DEBUG
|
|
|
|
|
if (func)
|
|
|
|
|
{
|
|
|
|
|
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
nm_debug ("MUTEX: <%s %p> being acquired by %s", desc ? desc->desc : "(none)", mutex, func);
|
2005-02-02 21:49:14 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
g_mutex_lock (mutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/*
|
|
|
|
|
* 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
|
2005-02-02 21:49:14 +00:00
|
|
|
if (func)
|
|
|
|
|
{
|
|
|
|
|
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
nm_debug ("MUTEX: <%s %p> released by %s", desc ? desc->desc : "(none)", mutex, func);
|
2005-02-02 21:49:14 +00:00
|
|
|
}
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-06 16:45:48 +00:00
|
|
|
/*
|
|
|
|
|
* nm_dev_sock_open
|
|
|
|
|
*
|
|
|
|
|
* Open a socket to a network device and store some debug info about it.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
NMSock *nm_dev_sock_open (NMDevice *dev, SockType type, const char *func_name, const char *desc)
|
|
|
|
|
{
|
|
|
|
|
NMSock *sock = NULL;
|
|
|
|
|
|
|
|
|
|
sock = g_malloc0 (sizeof (NMSock));
|
|
|
|
|
|
|
|
|
|
sock->fd = -1;
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case DEV_WIRELESS:
|
|
|
|
|
sock->fd = iw_sockets_open ();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DEV_GENERAL:
|
|
|
|
|
if ((sock->fd = socket (PF_INET, SOCK_DGRAM, 0)) < 0)
|
|
|
|
|
if ((sock->fd = socket (PF_PACKET, SOCK_DGRAM, 0)) < 0)
|
|
|
|
|
sock->fd = socket (PF_INET6, SOCK_DGRAM, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NETWORK_CONTROL:
|
|
|
|
|
sock->fd = socket (AF_PACKET, SOCK_PACKET, htons (ETH_P_ALL));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sock->fd < 0)
|
|
|
|
|
{
|
|
|
|
|
g_free (sock);
|
|
|
|
|
nm_warning ("Could not open control socket for device '%s'.", dev ? nm_device_get_iface (dev) : "none");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sock->func = func_name ? g_strdup (func_name) : NULL;
|
|
|
|
|
sock->desc = desc ? g_strdup (desc) : NULL;
|
|
|
|
|
sock->dev = dev;
|
|
|
|
|
if (sock->dev)
|
|
|
|
|
nm_device_ref (sock->dev);
|
|
|
|
|
|
|
|
|
|
/* Add the sock to our global sock list for tracking */
|
|
|
|
|
g_static_mutex_lock (&sock_list_mutex);
|
|
|
|
|
sock_list = g_slist_append (sock_list, sock);
|
|
|
|
|
g_static_mutex_unlock (&sock_list_mutex);
|
|
|
|
|
|
|
|
|
|
return sock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_dev_sock_close
|
|
|
|
|
*
|
|
|
|
|
* Close a socket and free its debug data.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void nm_dev_sock_close (NMSock *sock)
|
|
|
|
|
{
|
|
|
|
|
GSList *elt;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (sock != NULL);
|
|
|
|
|
|
|
|
|
|
close (sock->fd);
|
|
|
|
|
g_free (sock->func);
|
|
|
|
|
g_free (sock->desc);
|
|
|
|
|
if (sock->dev)
|
|
|
|
|
nm_device_unref (sock->dev);
|
|
|
|
|
|
|
|
|
|
memset (sock, 0, sizeof (NMSock));
|
|
|
|
|
|
|
|
|
|
g_static_mutex_lock (&sock_list_mutex);
|
|
|
|
|
for (elt = sock_list; elt; elt = g_slist_next (elt))
|
|
|
|
|
{
|
|
|
|
|
NMSock *temp_sock = (NMSock *)(elt->data);
|
|
|
|
|
if (temp_sock == sock)
|
|
|
|
|
{
|
|
|
|
|
sock_list = g_slist_remove_link (sock_list, elt);
|
|
|
|
|
g_slist_free (elt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_static_mutex_unlock (&sock_list_mutex);
|
|
|
|
|
|
|
|
|
|
g_free (sock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_dev_sock_get_fd
|
|
|
|
|
*
|
|
|
|
|
* Return the fd associated with an NMSock
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
int nm_dev_sock_get_fd (NMSock *sock)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (sock != NULL, -1);
|
|
|
|
|
|
|
|
|
|
return sock->fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_print_open_socks
|
|
|
|
|
*
|
|
|
|
|
* Print a list of currently open and registered NMSocks.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void nm_print_open_socks (void)
|
|
|
|
|
{
|
|
|
|
|
GSList *elt = NULL;
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
nm_debug ("Open Sockets List:");
|
|
|
|
|
g_static_mutex_lock (&sock_list_mutex);
|
|
|
|
|
for (elt = sock_list; elt; elt = g_slist_next (elt))
|
|
|
|
|
{
|
|
|
|
|
NMSock *sock = (NMSock *)(elt->data);
|
|
|
|
|
if (sock)
|
|
|
|
|
{
|
|
|
|
|
i++;
|
|
|
|
|
nm_debug (" %d: %s fd:%d F:'%s' D:'%s'", i, sock->dev ? nm_device_get_iface (sock->dev) : "",
|
|
|
|
|
sock->fd, sock->func, sock->desc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_static_mutex_unlock (&sock_list_mutex);
|
|
|
|
|
nm_debug ("Open Sockets List Done.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/*
|
|
|
|
|
* 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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-07-06 01:34:10 +00:00
|
|
|
/*
|
|
|
|
|
* nm_ethernet_address_is_valid
|
|
|
|
|
*
|
|
|
|
|
* Compares an ethernet address against known invalid addresses.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-05-03 Dan Williams <dcbw@redhat.com>
* Kill dhcpcd. We now use "dhcdbd", a dbus daemon that controls dhclient.
This means that NetworkManager shouldn't have DHCP issues anymore. It also
means you need dhcdbd, which you can get here (get the latest one):
http://people.redhat.com/jvdias/dhcdbd/
Technically NetworkManager can use any DHCP daemon that uses the same DBUS
interface as dhcdbd.
* Rewrite device activation to facilitate the new DHCP infrastructure and
future improvements. Its now "activation request" based, ie there is a single
activation request composed of the device, access point, and other info which
follows the entire activation process. There are 5 stages of the activation
process which correspond to:
1) Device preparation
2) Device configuration (bring it up, set ESSID/Key/etc)
3) IP Config Start (fire off DHCP if we're using it)
4) IP Config Get (grab config from DHCP or static config files)
5) IP Config Commit (set device's IP address, DNS, etc)
Note that there is no longer a "scanning" step, since the access point must
be known _before_ activation starts. If the access point drops out or does
not exist for some reason, the entire activation process fails and must be
restarted for a different access point or device.
Patch from Bill Moss:
* gnome/applet/applet.c
- Fix type of vpn_failure dialog -> vpn_banner dialog
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@597 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-05-03 20:41:36 +00:00
|
|
|
gboolean nm_ethernet_address_is_valid (const struct ether_addr *test_addr)
|
2004-07-06 01:34:10 +00:00
|
|
|
{
|
|
|
|
|
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} };
|
2005-02-11 14:54:40 +00:00
|
|
|
struct ether_addr invalid_addr4 = { {0x00, 0x30, 0xb4, 0x00, 0x00, 0x00} }; /* prism54 dummy MAC */
|
2004-07-06 01:34:10 +00:00
|
|
|
|
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)
|
2005-02-11 14:54:40 +00:00
|
|
|
&& (memcmp(test_addr, &invalid_addr3, sizeof(struct ether_addr)) != 0)
|
|
|
|
|
&& (memcmp(test_addr, &invalid_addr4, sizeof(struct ether_addr)) != 0)
|
|
|
|
|
&& ((test_addr->ether_addr_octet[0] & 1) == 0)) /* Multicast addresses */
|
2004-07-06 01:34:10 +00:00
|
|
|
valid = TRUE;
|
|
|
|
|
|
|
|
|
|
return (valid);
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-24 14:18:37 +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
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-07-13 16:58:13 +00:00
|
|
|
int nm_spawn_process (const char *args)
|
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
|
|
|
{
|
|
|
|
|
gint num_args;
|
2004-10-28 19:49:55 +00:00
|
|
|
char **argv = NULL;
|
|
|
|
|
int exit_status = -1;
|
2004-10-12 11:15:47 +00:00
|
|
|
GError *error = NULL;
|
2004-10-28 19:49:55 +00:00
|
|
|
char *so = NULL;
|
|
|
|
|
char *se = 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);
|
|
|
|
|
|
2004-10-28 19:49:55 +00:00
|
|
|
if (g_shell_parse_argv (args, &num_args, &argv, &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-28 19:49:55 +00:00
|
|
|
GError *error2 = NULL;
|
2004-10-12 11:15:47 +00:00
|
|
|
|
2004-10-28 19:49:55 +00:00
|
|
|
if (!g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, &so, &se, &exit_status, &error2))
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
nm_warning ("nm_spawn_process('%s'): could not spawn process. (%s)\n", args, error2->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
|
|
|
|
2004-10-28 19:49:55 +00:00
|
|
|
if (so) g_free(so);
|
|
|
|
|
if (se) g_free(se);
|
|
|
|
|
if (argv) g_strfreev (argv);
|
|
|
|
|
if (error2) g_error_free (error2);
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
} else nm_warning ("nm_spawn_process('%s'): could not parse arguments (%s)\n", args, error->message);
|
2004-10-28 19:49:55 +00:00
|
|
|
|
|
|
|
|
if (error) g_error_free (error);
|
|
|
|
|
|
|
|
|
|
return (exit_status);
|
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-08-16 19:46:43 +00:00
|
|
|
|
2004-10-21 17:42:14 +00:00
|
|
|
|
|
|
|
|
/*
|
2005-10-09 04:39:49 +00:00
|
|
|
* nm_print_device_capabilities
|
2004-10-21 17:42:14 +00:00
|
|
|
*
|
2005-10-09 04:39:49 +00:00
|
|
|
* Return the capabilities for a particular device.
|
2004-10-21 17:42:14 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2005-10-09 04:39:49 +00:00
|
|
|
void nm_print_device_capabilities (NMDevice *dev)
|
2004-10-21 17:42:14 +00:00
|
|
|
{
|
2005-10-09 04:39:49 +00:00
|
|
|
gboolean full_support = TRUE;
|
|
|
|
|
guint32 caps;
|
|
|
|
|
const char * driver = NULL;
|
2004-10-21 17:42:14 +00:00
|
|
|
|
2005-10-09 04:39:49 +00:00
|
|
|
g_return_if_fail (dev != NULL);
|
2004-10-21 17:42:14 +00:00
|
|
|
|
2005-10-09 04:39:49 +00:00
|
|
|
caps = nm_device_get_capabilities (dev);
|
|
|
|
|
driver = nm_device_get_driver (dev);
|
2005-03-24 18:56:23 +00:00
|
|
|
|
2005-10-09 04:39:49 +00:00
|
|
|
if (caps == NM_DEVICE_CAP_NONE || !(NM_DEVICE_CAP_NM_SUPPORTED))
|
|
|
|
|
{
|
|
|
|
|
nm_info ("%s: Driver support level for '%s' is unsupported",
|
|
|
|
|
nm_device_get_iface (dev), driver);
|
|
|
|
|
return;
|
2004-10-21 17:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-07 00:38:33 +00:00
|
|
|
if (nm_device_is_802_3_ethernet (dev))
|
2004-10-21 17:42:14 +00:00
|
|
|
{
|
2005-10-09 04:39:49 +00:00
|
|
|
if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT))
|
2004-10-21 17:42:14 +00:00
|
|
|
{
|
2005-10-09 04:39:49 +00:00
|
|
|
nm_info ("%s: Driver '%s' does not support carrier detection.\n"
|
|
|
|
|
"\tYou must switch to it manually.",
|
|
|
|
|
nm_device_get_iface (dev), driver);
|
|
|
|
|
full_support = FALSE;
|
2004-10-21 17:42:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-12-07 00:38:33 +00:00
|
|
|
else if (nm_device_is_802_11_wireless (dev))
|
2004-10-21 17:42:14 +00:00
|
|
|
{
|
2005-10-09 04:39:49 +00:00
|
|
|
if (!(caps & NM_DEVICE_CAP_WIRELESS_SCAN))
|
2004-10-21 17:42:14 +00:00
|
|
|
{
|
2005-10-09 04:39:49 +00:00
|
|
|
nm_info ("%s: Driver '%s' does not support wireless scanning.\n"
|
|
|
|
|
"\tSome features will not be available.",
|
|
|
|
|
nm_device_get_iface (dev), driver);
|
|
|
|
|
full_support = FALSE;
|
2004-10-21 17:42:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-09 04:39:49 +00:00
|
|
|
if (full_support)
|
2004-10-21 17:42:14 +00:00
|
|
|
{
|
2005-10-09 04:39:49 +00:00
|
|
|
nm_info ("%s: Device is fully-supported using driver '%s'.",
|
|
|
|
|
nm_device_get_iface (dev), driver);
|
2004-10-21 17:42:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-03-26 03:42:05 +00:00
|
|
|
|
|
|
|
|
static inline int nm_timeval_cmp(const struct timeval *a,
|
|
|
|
|
const struct timeval *b)
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
x = a->tv_sec - b->tv_sec;
|
|
|
|
|
x *= G_USEC_PER_SEC;
|
|
|
|
|
if (x)
|
|
|
|
|
return x;
|
|
|
|
|
x = a->tv_usec - b->tv_usec;
|
|
|
|
|
if (x)
|
|
|
|
|
return x;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int nm_timeval_has_passed(const struct timeval *a)
|
|
|
|
|
{
|
|
|
|
|
struct timeval current;
|
|
|
|
|
|
|
|
|
|
gettimeofday(¤t, NULL);
|
|
|
|
|
|
|
|
|
|
return (nm_timeval_cmp(¤t, a) >= 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void nm_timeval_add(struct timeval *a,
|
|
|
|
|
const struct timeval *b)
|
|
|
|
|
{
|
|
|
|
|
struct timeval b1;
|
|
|
|
|
|
|
|
|
|
memmove(&b1, b, sizeof b1);
|
|
|
|
|
|
|
|
|
|
/* normalize a and b to be positive for everything */
|
|
|
|
|
while (a->tv_usec < 0)
|
|
|
|
|
{
|
|
|
|
|
a->tv_sec--;
|
|
|
|
|
a->tv_usec += G_USEC_PER_SEC;
|
|
|
|
|
}
|
|
|
|
|
while (b1.tv_usec < 0)
|
|
|
|
|
{
|
|
|
|
|
b1.tv_sec--;
|
|
|
|
|
b1.tv_usec += G_USEC_PER_SEC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now add secs and usecs */
|
|
|
|
|
a->tv_sec += b1.tv_sec;
|
|
|
|
|
a->tv_usec += b1.tv_usec;
|
|
|
|
|
|
|
|
|
|
/* and handle our overflow */
|
|
|
|
|
if (a->tv_usec > G_USEC_PER_SEC)
|
|
|
|
|
{
|
|
|
|
|
a->tv_sec++;
|
|
|
|
|
a->tv_usec -= G_USEC_PER_SEC;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void nm_v_wait_for_completion_or_timeout(
|
|
|
|
|
const int max_tries,
|
|
|
|
|
const struct timeval *max_time,
|
|
|
|
|
const guint interval_usecs,
|
|
|
|
|
nm_completion_func test_func,
|
|
|
|
|
nm_completion_func action_func,
|
2005-04-28 02:50:54 +00:00
|
|
|
nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
|
|
|
|
int try;
|
|
|
|
|
gboolean finished = FALSE;
|
|
|
|
|
struct timeval finish_time;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (test_func || action_func);
|
|
|
|
|
|
|
|
|
|
if (max_time) {
|
|
|
|
|
gettimeofday(&finish_time, NULL);
|
|
|
|
|
nm_timeval_add(&finish_time, max_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try = -1;
|
|
|
|
|
while (!finished &&
|
|
|
|
|
(max_tries == NM_COMPLETION_TRIES_INFINITY || try < max_tries))
|
|
|
|
|
{
|
|
|
|
|
if (max_time && nm_timeval_has_passed(&finish_time))
|
|
|
|
|
break;
|
|
|
|
|
try++;
|
|
|
|
|
if (test_func)
|
|
|
|
|
{
|
|
|
|
|
finished = (*test_func)(try, args);
|
|
|
|
|
if (finished)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-03 Dan Williams <dcbw@redhat.com>
* Kill dhcpcd. We now use "dhcdbd", a dbus daemon that controls dhclient.
This means that NetworkManager shouldn't have DHCP issues anymore. It also
means you need dhcdbd, which you can get here (get the latest one):
http://people.redhat.com/jvdias/dhcdbd/
Technically NetworkManager can use any DHCP daemon that uses the same DBUS
interface as dhcdbd.
* Rewrite device activation to facilitate the new DHCP infrastructure and
future improvements. Its now "activation request" based, ie there is a single
activation request composed of the device, access point, and other info which
follows the entire activation process. There are 5 stages of the activation
process which correspond to:
1) Device preparation
2) Device configuration (bring it up, set ESSID/Key/etc)
3) IP Config Start (fire off DHCP if we're using it)
4) IP Config Get (grab config from DHCP or static config files)
5) IP Config Commit (set device's IP address, DNS, etc)
Note that there is no longer a "scanning" step, since the access point must
be known _before_ activation starts. If the access point drops out or does
not exist for some reason, the entire activation process fails and must be
restarted for a different access point or device.
Patch from Bill Moss:
* gnome/applet/applet.c
- Fix type of vpn_failure dialog -> vpn_banner dialog
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@597 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-05-03 20:41:36 +00:00
|
|
|
/* #define NM_SLEEP_DEBUG */
|
2005-03-26 03:42:05 +00:00
|
|
|
#ifdef NM_SLEEP_DEBUG
|
2005-08-22 21:29:56 +00:00
|
|
|
syslog (LOG_INFO, "sleeping for %d usecs", interval_usecs);
|
2005-03-26 03:42:05 +00:00
|
|
|
#endif
|
|
|
|
|
g_usleep(interval_usecs);
|
|
|
|
|
if (action_func)
|
|
|
|
|
finished = (*action_func)(try, args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-28 02:50:54 +00:00
|
|
|
/* these should probably be moved to NetworkManagerUtils.h as macros
|
|
|
|
|
* since they don't do varargs stuff any more */
|
2005-03-26 03:42:05 +00:00
|
|
|
void nm_wait_for_completion_or_timeout(
|
|
|
|
|
const int max_tries,
|
|
|
|
|
const struct timeval *max_time,
|
|
|
|
|
const guint interval_usecs,
|
|
|
|
|
nm_completion_func test_func,
|
|
|
|
|
nm_completion_func action_func,
|
2005-04-28 02:50:54 +00:00
|
|
|
nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
|
|
|
|
nm_v_wait_for_completion_or_timeout(max_tries, max_time,
|
|
|
|
|
interval_usecs, test_func,
|
2005-04-28 02:50:54 +00:00
|
|
|
action_func, args);
|
2005-03-26 03:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_wait_for_completion(
|
|
|
|
|
const int max_tries,
|
|
|
|
|
const guint interval_usecs,
|
|
|
|
|
nm_completion_func test_func,
|
|
|
|
|
nm_completion_func action_func,
|
2005-04-28 02:50:54 +00:00
|
|
|
nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
|
|
|
|
nm_v_wait_for_completion_or_timeout(max_tries, NULL,
|
|
|
|
|
interval_usecs, test_func,
|
2005-04-28 02:50:54 +00:00
|
|
|
action_func, args);
|
2005-03-26 03:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_wait_for_timeout(
|
|
|
|
|
const struct timeval *max_time,
|
|
|
|
|
const guint interval_usecs,
|
|
|
|
|
nm_completion_func test_func,
|
|
|
|
|
nm_completion_func action_func,
|
2005-04-28 02:50:54 +00:00
|
|
|
nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
2005-08-22 21:29:56 +00:00
|
|
|
nm_v_wait_for_completion_or_timeout(NM_COMPLETION_TRIES_INFINITY, max_time,
|
|
|
|
|
interval_usecs, test_func, action_func, args);
|
2005-03-26 03:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* you can use these, but they're really just examples */
|
2005-04-28 02:50:54 +00:00
|
|
|
gboolean nm_completion_boolean_test(int tries, nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
2005-04-28 02:50:54 +00:00
|
|
|
gboolean *condition = (gboolean *)args[0];
|
|
|
|
|
char *message = (char *)args[1];
|
2005-06-10 03:47:47 +00:00
|
|
|
int log_level = GPOINTER_TO_INT (args[2]);
|
|
|
|
|
int log_interval = GPOINTER_TO_INT (args[3]);
|
2005-03-26 03:42:05 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (condition != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
if ((log_interval == 0 && tries == 0) || (log_interval != 0 && tries % log_interval == 0))
|
|
|
|
|
{
|
|
|
|
|
if (log_level == LOG_WARNING)
|
|
|
|
|
nm_warning_str (message);
|
|
|
|
|
else if (log_level == LOG_ERR)
|
|
|
|
|
nm_error_str (message);
|
|
|
|
|
else if (log_level == LOG_DEBUG)
|
|
|
|
|
nm_debug_str (message);
|
|
|
|
|
else
|
|
|
|
|
nm_info_str (message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*condition)
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-28 02:50:54 +00:00
|
|
|
gboolean nm_completion_boolean_function1_test(int tries,
|
|
|
|
|
nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
2005-04-28 02:50:54 +00:00
|
|
|
nm_completion_boolean_function_1 condition = args[0];
|
|
|
|
|
char *message = args[1];
|
2005-06-10 03:47:47 +00:00
|
|
|
int log_level = GPOINTER_TO_INT (args[2]);
|
|
|
|
|
int log_interval = GPOINTER_TO_INT (args[3]);
|
2005-04-28 02:50:54 +00:00
|
|
|
u_int64_t arg0;
|
|
|
|
|
|
|
|
|
|
memcpy(&arg0, &args[4], sizeof (arg0));
|
2005-03-26 03:42:05 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (condition, TRUE);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
if ((log_interval == 0 && tries == 0)
|
|
|
|
|
|| (log_interval != 0 && tries % log_interval == 0))
|
|
|
|
|
syslog(log_level, message);
|
|
|
|
|
|
|
|
|
|
if (!(*condition)(arg0))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-28 02:50:54 +00:00
|
|
|
gboolean nm_completion_boolean_function2_test(int tries,
|
|
|
|
|
nm_completion_args args)
|
2005-03-26 03:42:05 +00:00
|
|
|
{
|
2005-04-28 02:50:54 +00:00
|
|
|
nm_completion_boolean_function_2 condition = args[0];
|
|
|
|
|
char *message = args[1];
|
2005-06-10 03:47:47 +00:00
|
|
|
int log_level = GPOINTER_TO_INT (args[2]);
|
|
|
|
|
int log_interval = GPOINTER_TO_INT (args[3]);
|
2005-04-28 02:50:54 +00:00
|
|
|
u_int64_t arg0, arg1;
|
|
|
|
|
|
|
|
|
|
memcpy(&arg0, &args[4], sizeof (arg0));
|
|
|
|
|
memcpy(&arg1, &args[4]+sizeof (arg0), sizeof (arg1));
|
2005-03-26 03:42:05 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (condition, TRUE);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
if ((log_interval == 0 && tries == 0)
|
|
|
|
|
|| (log_interval != 0 && tries % log_interval == 0))
|
|
|
|
|
syslog(log_level, message);
|
|
|
|
|
|
|
|
|
|
if (!(*condition)(arg0, arg1))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-12 17:44:45 +00:00
|
|
|
|
|
|
|
|
gchar *nm_utils_inet_ip4_address_as_string (guint32 ip)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr tmp_addr;
|
|
|
|
|
gchar *ip_string;
|
|
|
|
|
|
|
|
|
|
tmp_addr.s_addr = ip;
|
|
|
|
|
ip_string = inet_ntoa (tmp_addr);
|
|
|
|
|
|
|
|
|
|
return g_strdup (ip_string);
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
|
|
|
|
|
struct nl_addr * nm_utils_ip4_addr_to_nl_addr (guint32 ip4_addr)
|
|
|
|
|
{
|
|
|
|
|
struct nl_addr * nla = NULL;
|
|
|
|
|
|
|
|
|
|
if (!(nla = nl_addr_alloc (sizeof (in_addr_t))))
|
|
|
|
|
return NULL;
|
|
|
|
|
nl_addr_set_family (nla, AF_INET);
|
|
|
|
|
nl_addr_set_binary_addr (nla, &ip4_addr, sizeof (guint32));
|
|
|
|
|
|
|
|
|
|
return nla;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_utils_ip4_netmask_to_prefix
|
|
|
|
|
*
|
|
|
|
|
* Figure out the network prefix from a netmask. Netmask
|
|
|
|
|
* MUST be in network byte order.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
int nm_utils_ip4_netmask_to_prefix (guint32 ip4_netmask)
|
|
|
|
|
{
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
|
|
|
|
/* Just count how many bit shifts we need */
|
|
|
|
|
ip4_netmask = ntohl (ip4_netmask);
|
|
|
|
|
while (!(ip4_netmask & 0x1) && ++i)
|
|
|
|
|
ip4_netmask = ip4_netmask >> 1;
|
|
|
|
|
return (32 - (i-1));
|
|
|
|
|
}
|
|
|
|
|
|