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"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device.h"
|
|
|
|
|
#include "nm-device-802-11-wireless.h"
|
|
|
|
|
#include "nm-device-802-3-ethernet.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;
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
char *iface;
|
2005-04-06 16:45:48 +00:00
|
|
|
};
|
|
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
static GSList * sock_list = NULL;
|
2004-06-24 14:18:37 +00:00
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
NMSock *
|
|
|
|
|
nm_dev_sock_open (const char *iface, SockType type, const char *func_name, const char *desc)
|
2005-04-06 16:45:48 +00:00
|
|
|
{
|
|
|
|
|
NMSock *sock = NULL;
|
|
|
|
|
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
sock = g_slice_new (NMSock);
|
2005-04-06 16:45:48 +00:00
|
|
|
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)
|
|
|
|
|
{
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
g_slice_free (NMSock, sock);
|
|
|
|
|
nm_warning ("Could not open control socket for device '%s'.", iface ? iface : "none");
|
2005-04-06 16:45:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sock->func = func_name ? g_strdup (func_name) : NULL;
|
|
|
|
|
sock->desc = desc ? g_strdup (desc) : NULL;
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
sock->iface = iface ? g_strdup (iface) : NULL;
|
2005-04-06 16:45:48 +00:00
|
|
|
|
|
|
|
|
/* Add the sock to our global sock list for tracking */
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
sock_list = g_slist_prepend (sock_list, sock);
|
2005-04-06 16:45:48 +00:00
|
|
|
|
|
|
|
|
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);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
g_free (sock->iface);
|
2005-04-06 16:45:48 +00:00
|
|
|
|
|
|
|
|
memset (sock, 0, sizeof (NMSock));
|
|
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
for (elt = sock_list; elt; elt = g_slist_next (elt)) {
|
2005-04-06 16:45:48 +00:00
|
|
|
NMSock *temp_sock = (NMSock *)(elt->data);
|
2007-01-04 12:06:26 +00:00
|
|
|
if (temp_sock == sock) {
|
2005-04-06 16:45:48 +00:00
|
|
|
sock_list = g_slist_remove_link (sock_list, elt);
|
|
|
|
|
g_slist_free (elt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
g_slice_free (NMSock, sock);
|
2005-04-06 16:45:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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:");
|
2007-01-04 12:06:26 +00:00
|
|
|
for (elt = sock_list; elt; elt = g_slist_next (elt)) {
|
2005-04-06 16:45:48 +00:00
|
|
|
NMSock *sock = (NMSock *)(elt->data);
|
2007-01-04 12:06:26 +00:00
|
|
|
if (sock) {
|
2005-04-06 16:45:48 +00:00
|
|
|
i++;
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
nm_debug (" %d: %s fd:%d F:'%s' D:'%s'", i, sock->iface ? sock->iface : "",
|
|
|
|
|
sock->fd, sock->func, sock->desc);
|
2005-04-06 16:45:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
*
|
2006-05-17 15:02:57 +00:00
|
|
|
* Compares an Ethernet address against known invalid addresses.
|
2004-07-06 01:34:10 +00:00
|
|
|
*
|
|
|
|
|
*/
|
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
|
|
|
|
2006-05-17 15:02:57 +00:00
|
|
|
/*
|
|
|
|
|
* nm_ethernet_addresses_are_equal
|
|
|
|
|
*
|
|
|
|
|
* Compare two Ethernet addresses and return TRUE if equal and FALSE if not.
|
|
|
|
|
*/
|
|
|
|
|
gboolean nm_ethernet_addresses_are_equal (const struct ether_addr *a, const struct ether_addr *b)
|
|
|
|
|
{
|
|
|
|
|
if (memcmp (a, b, sizeof (struct ether_addr)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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);
|
2006-07-09 22:08:18 +00:00
|
|
|
if (!driver)
|
|
|
|
|
driver = "<unknown>";
|
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
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
if (NM_IS_DEVICE_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
|
|
|
}
|
|
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
else if (NM_IS_DEVICE_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))
|
2005-12-07 15:56:47 +00:00
|
|
|
syslog(log_level, "%s", message);
|
2005-03-26 03:42:05 +00:00
|
|
|
|
|
|
|
|
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))
|
2005-12-07 15:56:47 +00:00
|
|
|
syslog(log_level, "%s", message);
|
2005-03-26 03:42:05 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2006-08-24 11:01:37 +00:00
|
|
|
g_return_val_if_fail (ip4_netmask != 0, 0);
|
|
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
/* 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));
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-27 16:18:52 +00:00
|
|
|
/* Shamelessly ripped from the Linux kernel ieee80211 stack */
|
|
|
|
|
gboolean
|
|
|
|
|
nm_utils_is_empty_ssid (const char * ssid, int len)
|
|
|
|
|
{
|
|
|
|
|
/* Single white space is for Linksys APs */
|
|
|
|
|
if (len == 1 && ssid[0] == ' ')
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
/* Otherwise, if the entire ssid is 0, we assume it is hidden */
|
|
|
|
|
while (len--) {
|
|
|
|
|
if (ssid[len] != '\0')
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_utils_escape_ssid (const char * ssid, guint32 len)
|
|
|
|
|
{
|
|
|
|
|
static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
|
|
|
|
|
const char *s = ssid;
|
|
|
|
|
char *d = escaped;
|
|
|
|
|
|
|
|
|
|
if (nm_utils_is_empty_ssid (ssid, len)) {
|
|
|
|
|
memcpy (escaped, "<hidden>", sizeof ("<hidden>"));
|
|
|
|
|
return escaped;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
len = MIN (len, (guint32) IW_ESSID_MAX_SIZE);
|
|
|
|
|
while (len--) {
|
|
|
|
|
if (*s == '\0') {
|
|
|
|
|
*d++ = '\\';
|
|
|
|
|
*d++ = '0';
|
|
|
|
|
s++;
|
|
|
|
|
} else {
|
|
|
|
|
*d++ = *s++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*d = '\0';
|
|
|
|
|
return escaped;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
2007-08-15 01:56:02 +00:00
|
|
|
nm_utils_same_ssid (const GByteArray * ssid1,
|
|
|
|
|
const GByteArray * ssid2,
|
|
|
|
|
gboolean ignore_trailing_null)
|
2007-06-27 16:18:52 +00:00
|
|
|
{
|
2007-08-15 01:56:02 +00:00
|
|
|
guint32 ssid1_len, ssid2_len;
|
|
|
|
|
|
2007-06-27 16:18:52 +00:00
|
|
|
if (ssid1 == ssid2)
|
|
|
|
|
return TRUE;
|
|
|
|
|
if ((ssid1 && !ssid2) || (!ssid1 && ssid2))
|
|
|
|
|
return FALSE;
|
2007-08-15 01:56:02 +00:00
|
|
|
|
|
|
|
|
ssid1_len = ssid1->len;
|
|
|
|
|
ssid2_len = ssid2->len;
|
|
|
|
|
if (ssid1_len && ssid2_len && ignore_trailing_null) {
|
|
|
|
|
if (ssid1->data[ssid1_len - 1] == '\0')
|
|
|
|
|
ssid1_len--;
|
|
|
|
|
if (ssid2->data[ssid2_len - 1] == '\0')
|
|
|
|
|
ssid2_len--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ssid1_len != ssid2_len)
|
2007-06-27 16:18:52 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2007-08-15 01:56:02 +00:00
|
|
|
return memcmp (ssid1->data, ssid2->data, ssid1_len) == 0 ? TRUE : FALSE;
|
2007-06-27 16:18:52 +00:00
|
|
|
}
|