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.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-05-24 14:16:48 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
#include <glib.h>
|
2004-07-27 16:15:36 +00:00
|
|
|
#include <dbus/dbus.h>
|
2004-08-02 21:12:40 +00:00
|
|
|
#include <dbus/dbus-glib-lowlevel.h>
|
2004-06-24 14:18:37 +00:00
|
|
|
#include <dbus/dbus-glib.h>
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdlib.h>
|
2004-12-21 06:49:21 +00:00
|
|
|
#include <signal.h>
|
2004-06-24 14:18:37 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <sys/stat.h>
|
2004-10-15 15:59:25 +00:00
|
|
|
#include <sys/types.h>
|
2006-05-24 15:53:07 +00:00
|
|
|
#include <glib/gi18n.h>
|
2004-06-24 14:18:37 +00:00
|
|
|
|
|
|
|
|
#include "NetworkManager.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
|
|
|
#include "NetworkManagerUtils.h"
|
2007-02-08 15:34:26 +00:00
|
|
|
#include "nm-manager.h"
|
|
|
|
|
#include "nm-hal-manager.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device.h"
|
|
|
|
|
#include "nm-device-802-3-ethernet.h"
|
|
|
|
|
#include "nm-device-802-11-wireless.h"
|
2004-06-24 14:18:37 +00:00
|
|
|
#include "NetworkManagerPolicy.h"
|
|
|
|
|
#include "NetworkManagerDbus.h"
|
2004-08-02 21:12:40 +00:00
|
|
|
#include "NetworkManagerAP.h"
|
2004-07-27 16:15:36 +00:00
|
|
|
#include "NetworkManagerAPList.h"
|
2004-11-16 02:41:53 +00:00
|
|
|
#include "NetworkManagerSystem.h"
|
2004-12-21 06:49:21 +00:00
|
|
|
#include "nm-named-manager.h"
|
2005-10-02 05:02:49 +00:00
|
|
|
#include "nm-vpn-act-request.h"
|
2005-04-15 15:43:42 +00:00
|
|
|
#include "nm-dbus-vpn.h"
|
2006-10-13 19:41:47 +00:00
|
|
|
#include "nm-dbus-nm.h"
|
|
|
|
|
#include "nm-dbus-manager.h"
|
|
|
|
|
#include "nm-dbus-device.h"
|
2006-11-25 15:41:04 +00:00
|
|
|
#include "nm-supplicant-manager.h"
|
2006-10-13 19:41:47 +00:00
|
|
|
#include "nm-dbus-net.h"
|
2005-03-11 20:12:57 +00:00
|
|
|
#include "nm-netlink-monitor.h"
|
2006-02-27 04:31:52 +00:00
|
|
|
#include "nm-logging.h"
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2005-03-11 20:12:57 +00:00
|
|
|
#define NM_WIRELESS_LINK_STATE_POLL_INTERVAL (5 * 1000)
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2006-02-27 20:06:24 +00:00
|
|
|
#define NM_DEFAULT_PID_FILE LOCALSTATEDIR"/run/NetworkManager.pid"
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/*
|
|
|
|
|
* Globals
|
|
|
|
|
*/
|
|
|
|
|
static NMData *nm_data = NULL;
|
2007-02-08 15:34:26 +00:00
|
|
|
static NMManager *manager = NULL;
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2004-12-21 06:49:21 +00:00
|
|
|
static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, gpointer data);
|
2004-06-24 14:18:37 +00:00
|
|
|
static void nm_data_free (NMData *data);
|
|
|
|
|
|
2005-01-12 18:40:04 +00:00
|
|
|
/*
|
2005-04-27 18:05:16 +00:00
|
|
|
* nm_state_change_signal_broadcast
|
2005-01-12 18:40:04 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2005-04-27 18:05:16 +00:00
|
|
|
static gboolean nm_state_change_signal_broadcast (gpointer user_data)
|
2005-01-12 18:40:04 +00:00
|
|
|
{
|
2007-02-08 15:34:26 +00:00
|
|
|
NMState state;
|
|
|
|
|
NMDBusManager *dbus_mgr;
|
|
|
|
|
DBusConnection *dbus_connection;
|
2005-01-12 18:40:04 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
state = nm_manager_get_state (manager);
|
2005-01-12 18:40:04 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
dbus_mgr = nm_dbus_manager_get ();
|
2006-10-13 19:41:47 +00:00
|
|
|
dbus_connection = nm_dbus_manager_get_dbus_connection (dbus_mgr);
|
|
|
|
|
if (dbus_connection)
|
2007-02-08 15:34:26 +00:00
|
|
|
nm_dbus_signal_state_change (dbus_connection, state);
|
2006-10-13 19:41:47 +00:00
|
|
|
g_object_unref (dbus_mgr);
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2005-01-12 18:40:04 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-04-27 18:05:16 +00:00
|
|
|
* nm_schedule_state_change_signal_broadcast
|
2005-01-12 18:40:04 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2005-04-27 18:05:16 +00:00
|
|
|
void nm_schedule_state_change_signal_broadcast (NMData *data)
|
2005-01-12 18:40:04 +00:00
|
|
|
{
|
2007-02-08 15:34:26 +00:00
|
|
|
g_idle_add_full (G_PRIORITY_HIGH,
|
|
|
|
|
nm_state_change_signal_broadcast,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
2005-01-12 18:40:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
static void
|
|
|
|
|
nm_error_monitoring_device_link_state (NmNetlinkMonitor *monitor,
|
|
|
|
|
GError *error,
|
|
|
|
|
NMData *data)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Try to handle the error instead of just printing it. */
|
|
|
|
|
nm_warning ("error monitoring wired ethernet link state: %s\n",
|
|
|
|
|
error->message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NmNetlinkMonitor *
|
|
|
|
|
nm_monitor_setup (NMData *data)
|
|
|
|
|
{
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
NmNetlinkMonitor *monitor;
|
|
|
|
|
|
|
|
|
|
monitor = nm_netlink_monitor_new (data);
|
|
|
|
|
nm_netlink_monitor_open_connection (monitor, &error);
|
|
|
|
|
if (error != NULL)
|
|
|
|
|
{
|
|
|
|
|
nm_warning ("could not monitor wired ethernet devices: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
g_object_unref (monitor);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (monitor), "error",
|
|
|
|
|
G_CALLBACK (nm_error_monitoring_device_link_state),
|
|
|
|
|
data);
|
|
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_netlink_monitor_attach (monitor, NULL);
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
|
|
|
|
|
/* Request initial status of cards */
|
|
|
|
|
nm_netlink_monitor_request_status (monitor, NULL);
|
|
|
|
|
return monitor;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/*
|
|
|
|
|
* nm_data_new
|
|
|
|
|
*
|
|
|
|
|
* Create data structure used in callbacks from libhal.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2004-08-31 Dan Williams <dcbw@redhat.com>
* Remove 'debug' extern global from all files since we now
use syslog()
* src/NetworkManager.[ch]
- Break out routine that get the net.interface property from HAL,
removing that logic from nm_create_device_and_add_to_list()
- (nm_create_device_and_add_to_list): make this a bit more general so
it doesn't do the talking to HAL. Also add arguments to facilitate
the create of test devices.
- (nm_data_mark_state_changed): rename from nm_data_set_state_modified()
- (nm_data_new, main, nm_print_usage): add new argument "--enable-test-devices"
which makes NetworkManager listen for dbus commands to create test
devices, which have no backing hardware. Use when you're on a plane
for example, and/or forgot your wireless card at home. Test devices
_cannot_ be created unless NM is started with --enable-test-devices.
* src/NetworkManagerDbus.[ch]
- New "getLinkActive" method for devices
- New "setLinkActive" method for devices (only works on test devices)
- New "createTestDevice" method on NetworkManager object to create a test
device of a specified type (ie wired, wireless). UDI is created from
scratch, as is the interface name. Only works when NM is started with
--enable-test-devices switch.
- New "removeTestDevice" method on NetworkManager object which removes a
test device. Only works when NM is started with --enable-test-devices
* src/NetworkManagerDevice.[ch]
- Logic to facilitate test devices. Add variables to NMDevice struct to indicate
whether a device is a test device or not, and what its link status is.
- Deal with test devices in most functions. For those that work directly on hardware
special-case test devices.
- (nm_device_new): don't create a test device if test devices weren't enabled on the
command-line.
- (nm_device_update_link_active): split out logic for wired and wireless device link
checking to separate functions to facilitate test device link checking.
- (nm_device_set_enc_key): Since some drivers for wireless cards are daft and
don't make a distinction between System Authentication and Encryption
(namely Cisco aironet), we use Open System auth when setting a WEP key
on the card. We don't deal with Shared Key auth yet.
- (nm_device_activation_worker): split the activation cancel check logic out into
a separate routine nm_device_activation_cancel_if_needed()
- (nm_device_activation_signal_cancel): rename from nm_device_activation_cancel()
- (nm_device_fake_ap_list): Test wireless devices obviously cannot scan, so create
a list of fake access points that they can "see"
- (nm_device_is_test_device): return whether or not a device is a test device
* src/NetworkManagerPolicy.c
- (nm_policy_get_best_device): attempt to deal with wireless network selection,
previously if you "locked"/forced NM to use a wireless device but then
selected a wireless network for NM to use, it would switch to a wired device.
So, if the active device is wireless and it has a "forced" best AP, use it
if the "forced" best AP is still valid
- (nm_state_modification_monitor): deal with NULL best devices, for example
there were no usable network devices, or the last one was removed
* src/backends/NetworkManager*.c
- Deal with test devices, mostly just return success for operations like getting
a DHCP address
* test/nmtestdevices.c
- Test tool to create/remove/link-switch test devices
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@112 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-31 16:09:15 +00:00
|
|
|
static NMData *nm_data_new (gboolean enable_test_devices)
|
2004-06-24 14:18:37 +00:00
|
|
|
{
|
2007-01-04 12:06:26 +00:00
|
|
|
NMData * data;
|
|
|
|
|
guint id;
|
|
|
|
|
|
2006-08-04 15:46:06 +00:00
|
|
|
data = g_slice_new0 (NMData);
|
2004-12-21 06:49:21 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
data->main_loop = g_main_loop_new (NULL, FALSE);
|
2004-12-21 06:49:21 +00:00
|
|
|
|
2006-02-27 04:31:52 +00:00
|
|
|
/* Allow clean shutdowns by having the thread which receives the signal
|
|
|
|
|
* notify the main thread to quit, rather than having the receiving
|
|
|
|
|
* thread try to quit the glib main loop.
|
|
|
|
|
*/
|
2007-01-04 12:06:26 +00:00
|
|
|
if (pipe (data->sigterm_pipe) < 0) {
|
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_error ("Couldn't create pipe: %s", g_strerror (errno));
|
2006-02-02 16:49:11 +00:00
|
|
|
return NULL;
|
2004-12-21 06:49:21 +00:00
|
|
|
}
|
|
|
|
|
data->sigterm_iochannel = g_io_channel_unix_new (data->sigterm_pipe[0]);
|
2007-01-04 12:06:26 +00:00
|
|
|
id = g_io_add_watch (data->sigterm_iochannel,
|
|
|
|
|
G_IO_IN | G_IO_ERR,
|
|
|
|
|
sigterm_pipe_handler,
|
|
|
|
|
data);
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2004-08-06 18:19:06 +00:00
|
|
|
/* Initialize the access point lists */
|
2004-09-08 18:14:42 +00:00
|
|
|
data->allowed_ap_list = nm_ap_list_new (NETWORK_TYPE_ALLOWED);
|
2004-08-05 18:54:29 +00:00
|
|
|
data->invalid_ap_list = nm_ap_list_new (NETWORK_TYPE_INVALID);
|
2004-09-08 18:14:42 +00:00
|
|
|
if (!data->allowed_ap_list || !data->invalid_ap_list)
|
2004-06-24 14:18:37 +00:00
|
|
|
{
|
|
|
|
|
nm_data_free (data);
|
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 ("could not create access point lists.");
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create watch functions that monitor cards for link status. */
|
|
|
|
|
if (!(data->netlink_monitor = nm_monitor_setup (data)))
|
|
|
|
|
{
|
|
|
|
|
nm_data_free (data);
|
|
|
|
|
nm_warning ("could not create netlink monitor.");
|
|
|
|
|
return NULL;
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|
2004-08-05 18:54:29 +00:00
|
|
|
|
2004-08-31 Dan Williams <dcbw@redhat.com>
* Remove 'debug' extern global from all files since we now
use syslog()
* src/NetworkManager.[ch]
- Break out routine that get the net.interface property from HAL,
removing that logic from nm_create_device_and_add_to_list()
- (nm_create_device_and_add_to_list): make this a bit more general so
it doesn't do the talking to HAL. Also add arguments to facilitate
the create of test devices.
- (nm_data_mark_state_changed): rename from nm_data_set_state_modified()
- (nm_data_new, main, nm_print_usage): add new argument "--enable-test-devices"
which makes NetworkManager listen for dbus commands to create test
devices, which have no backing hardware. Use when you're on a plane
for example, and/or forgot your wireless card at home. Test devices
_cannot_ be created unless NM is started with --enable-test-devices.
* src/NetworkManagerDbus.[ch]
- New "getLinkActive" method for devices
- New "setLinkActive" method for devices (only works on test devices)
- New "createTestDevice" method on NetworkManager object to create a test
device of a specified type (ie wired, wireless). UDI is created from
scratch, as is the interface name. Only works when NM is started with
--enable-test-devices switch.
- New "removeTestDevice" method on NetworkManager object which removes a
test device. Only works when NM is started with --enable-test-devices
* src/NetworkManagerDevice.[ch]
- Logic to facilitate test devices. Add variables to NMDevice struct to indicate
whether a device is a test device or not, and what its link status is.
- Deal with test devices in most functions. For those that work directly on hardware
special-case test devices.
- (nm_device_new): don't create a test device if test devices weren't enabled on the
command-line.
- (nm_device_update_link_active): split out logic for wired and wireless device link
checking to separate functions to facilitate test device link checking.
- (nm_device_set_enc_key): Since some drivers for wireless cards are daft and
don't make a distinction between System Authentication and Encryption
(namely Cisco aironet), we use Open System auth when setting a WEP key
on the card. We don't deal with Shared Key auth yet.
- (nm_device_activation_worker): split the activation cancel check logic out into
a separate routine nm_device_activation_cancel_if_needed()
- (nm_device_activation_signal_cancel): rename from nm_device_activation_cancel()
- (nm_device_fake_ap_list): Test wireless devices obviously cannot scan, so create
a list of fake access points that they can "see"
- (nm_device_is_test_device): return whether or not a device is a test device
* src/NetworkManagerPolicy.c
- (nm_policy_get_best_device): attempt to deal with wireless network selection,
previously if you "locked"/forced NM to use a wireless device but then
selected a wireless network for NM to use, it would switch to a wired device.
So, if the active device is wireless and it has a "forced" best AP, use it
if the "forced" best AP is still valid
- (nm_state_modification_monitor): deal with NULL best devices, for example
there were no usable network devices, or the last one was removed
* src/backends/NetworkManager*.c
- Deal with test devices, mostly just return success for operations like getting
a DHCP address
* test/nmtestdevices.c
- Test tool to create/remove/link-switch test devices
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@112 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-31 16:09:15 +00:00
|
|
|
data->enable_test_devices = enable_test_devices;
|
2005-02-07 23:04:05 +00:00
|
|
|
data->wireless_enabled = TRUE;
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
return data;
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_data_free
|
|
|
|
|
*
|
|
|
|
|
* Free data structure used in callbacks.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static void nm_data_free (NMData *data)
|
|
|
|
|
{
|
2005-10-02 05:02:49 +00:00
|
|
|
NMVPNActRequest *req;
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
g_return_if_fail (data != NULL);
|
|
|
|
|
|
2005-05-14 23:57:25 +00:00
|
|
|
/* Kill any active VPN connection */
|
2005-10-02 05:02:49 +00:00
|
|
|
if ((req = nm_vpn_manager_get_vpn_act_request (data->vpn_manager)))
|
|
|
|
|
nm_vpn_manager_deactivate_vpn_connection (data->vpn_manager, nm_vpn_act_request_get_parent_dev (req));
|
2005-05-14 23:57:25 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
if (data->netlink_monitor) {
|
|
|
|
|
g_object_unref (G_OBJECT (data->netlink_monitor));
|
|
|
|
|
data->netlink_monitor = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-08 18:14:42 +00:00
|
|
|
nm_ap_list_unref (data->allowed_ap_list);
|
2004-08-05 18:54:29 +00:00
|
|
|
nm_ap_list_unref (data->invalid_ap_list);
|
2004-07-27 16:15:36 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_dbus_method_list_unref (data->nm_methods);
|
|
|
|
|
nm_dbus_method_list_unref (data->device_methods);
|
|
|
|
|
|
2005-05-05 16:52:04 +00:00
|
|
|
nm_vpn_manager_dispose (data->vpn_manager);
|
|
|
|
|
g_object_unref (data->named_manager);
|
|
|
|
|
|
2005-01-07 18:07:06 +00:00
|
|
|
g_main_loop_unref (data->main_loop);
|
2005-04-15 20:00:28 +00:00
|
|
|
g_io_channel_unref(data->sigterm_iochannel);
|
|
|
|
|
|
2006-08-04 15:46:06 +00:00
|
|
|
g_slice_free (NMData, data);
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-27 04:31:52 +00:00
|
|
|
int nm_get_sigterm_pipe (void)
|
2004-12-21 06:49:21 +00:00
|
|
|
{
|
2006-02-27 04:31:52 +00:00
|
|
|
return nm_data->sigterm_pipe[1];
|
2004-12-21 06:49:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, gpointer user_data)
|
|
|
|
|
{
|
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
|
|
|
NMData * data = user_data;
|
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_info ("Caught terminiation signal");
|
2004-12-21 06:49:21 +00:00
|
|
|
g_main_loop_quit (data->main_loop);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
static void
|
|
|
|
|
nm_name_owner_changed_handler (NMDBusManager *mgr,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *old,
|
|
|
|
|
const char *new,
|
|
|
|
|
gpointer user_data)
|
2005-06-23 12:20:32 +00:00
|
|
|
{
|
2006-10-13 19:41:47 +00:00
|
|
|
NMData * data = (NMData *) user_data;
|
|
|
|
|
gboolean old_owner_good = (old && (strlen (old) > 0));
|
|
|
|
|
gboolean new_owner_good = (new && (strlen (new) > 0));
|
2005-06-23 12:20:32 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
if (strcmp (name, NMI_DBUS_SERVICE) == 0) {
|
2006-10-14 12:50:20 +00:00
|
|
|
if (!old_owner_good && new_owner_good) {
|
|
|
|
|
/* NMI appeared, update stuff */
|
|
|
|
|
nm_policy_schedule_allowed_ap_list_update (data);
|
|
|
|
|
nm_dbus_vpn_schedule_vpn_connections_update (data);
|
|
|
|
|
} else if (old_owner_good && !new_owner_good) {
|
|
|
|
|
/* nothing */
|
2006-10-13 19:41:47 +00:00
|
|
|
}
|
2005-06-23 12:20:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-27 20:00:25 +00:00
|
|
|
static void
|
2006-02-27 05:50:28 +00:00
|
|
|
write_pidfile (const char *pidfile)
|
|
|
|
|
{
|
2006-02-27 20:00:25 +00:00
|
|
|
char pid[16];
|
2006-02-27 05:50:28 +00:00
|
|
|
int fd;
|
2006-02-27 20:00:25 +00:00
|
|
|
|
|
|
|
|
if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0)
|
|
|
|
|
{
|
|
|
|
|
nm_warning ("Opening %s failed: %s", pidfile, strerror (errno));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
snprintf (pid, sizeof (pid), "%d", getpid ());
|
|
|
|
|
if (write (fd, pid, strlen (pid)) < 0)
|
|
|
|
|
nm_warning ("Writing to %s failed: %s", pidfile, strerror (errno));
|
|
|
|
|
if (close (fd))
|
|
|
|
|
nm_warning ("Closing %s failed: %s", pidfile, strerror (errno));
|
2006-02-27 05:50:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_print_usage
|
|
|
|
|
*
|
|
|
|
|
* Prints program usage.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static void nm_print_usage (void)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr,
|
|
|
|
|
"\n"
|
|
|
|
|
"NetworkManager monitors all network connections and automatically\n"
|
|
|
|
|
"chooses the best connection to use. It also allows the user to\n"
|
|
|
|
|
"specify wireless access points which wireless cards in the computer\n"
|
|
|
|
|
"should associate with.\n"
|
|
|
|
|
"\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/*
|
|
|
|
|
* main
|
|
|
|
|
*
|
|
|
|
|
*/
|
2006-10-13 19:41:47 +00:00
|
|
|
int
|
|
|
|
|
main (int argc, char *argv[])
|
2004-06-24 14:18:37 +00:00
|
|
|
{
|
2006-10-13 19:41:47 +00:00
|
|
|
GOptionContext *opt_ctx = NULL;
|
2006-05-28 02:55:44 +00:00
|
|
|
gboolean become_daemon = FALSE;
|
2005-06-23 12:20:32 +00:00
|
|
|
gboolean enable_test_devices = FALSE;
|
2006-05-28 03:30:44 +00:00
|
|
|
gboolean show_usage = FALSE;
|
2006-02-27 05:50:28 +00:00
|
|
|
char * pidfile = NULL;
|
2006-02-27 20:06:24 +00:00
|
|
|
char * user_pidfile = NULL;
|
2007-02-08 15:34:26 +00:00
|
|
|
NMPolicy *policy;
|
|
|
|
|
NMHalManager *hal_manager = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
NMDBusManager * dbus_mgr;
|
|
|
|
|
DBusConnection *dbus_connection;
|
2006-11-25 15:41:04 +00:00
|
|
|
NMSupplicantManager * sup_mgr = NULL;
|
2006-10-13 19:41:47 +00:00
|
|
|
int exit_status = EXIT_FAILURE;
|
2006-11-25 07:09:11 +00:00
|
|
|
guint32 id;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
GOptionEntry options[] = {
|
|
|
|
|
{"no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL},
|
|
|
|
|
{"pid-file", 0, 0, G_OPTION_ARG_STRING, &user_pidfile, "Specify the location of a PID file", NULL},
|
|
|
|
|
{"enable-test-devices", 0, 0, G_OPTION_ARG_NONE, &enable_test_devices, "Allow dummy devices to be created via DBUS methods [DEBUG]", NULL},
|
|
|
|
|
{"info", 0, 0, G_OPTION_ARG_NONE, &show_usage, "Show application information", NULL},
|
|
|
|
|
{NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (getuid () != 0) {
|
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
|
|
|
g_printerr ("You must be root to run NetworkManager!\n");
|
2006-10-13 19:41:47 +00:00
|
|
|
goto exit;
|
2004-10-15 15:59:25 +00:00
|
|
|
}
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2006-05-24 14:16:48 +00:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/* Parse options */
|
2006-10-13 19:41:47 +00:00
|
|
|
opt_ctx = g_option_context_new("");
|
|
|
|
|
g_option_context_add_main_entries(opt_ctx, options, NULL);
|
|
|
|
|
g_option_context_parse(opt_ctx, &argc, &argv, NULL);
|
|
|
|
|
g_option_context_free(opt_ctx);
|
|
|
|
|
|
|
|
|
|
if (show_usage == TRUE) {
|
2006-05-28 03:30:44 +00:00
|
|
|
nm_print_usage();
|
2006-10-13 19:41:47 +00:00
|
|
|
exit_status = EXIT_SUCCESS;
|
|
|
|
|
goto exit;
|
2006-05-28 03:30:44 +00:00
|
|
|
}
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
pidfile = g_strdup (user_pidfile ? user_pidfile : NM_DEFAULT_PID_FILE);
|
|
|
|
|
|
|
|
|
|
/* Tricky: become_daemon is FALSE by default, so unless it's TRUE because
|
|
|
|
|
* of a CLI option, it'll become TRUE after this
|
|
|
|
|
*/
|
|
|
|
|
become_daemon = !become_daemon;
|
|
|
|
|
if (become_daemon) {
|
|
|
|
|
if (daemon (0, 0) < 0) {
|
2006-02-27 20:06:24 +00:00
|
|
|
int saved_errno;
|
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
|
|
|
|
2006-02-27 20:06:24 +00:00
|
|
|
saved_errno = errno;
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_error ("Could not daemonize: %s [error %u]",
|
|
|
|
|
g_strerror (saved_errno),
|
|
|
|
|
saved_errno);
|
|
|
|
|
goto exit;
|
2006-02-27 20:06:24 +00:00
|
|
|
}
|
|
|
|
|
write_pidfile (pidfile);
|
2005-01-22 04:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-05 19:42:20 +00:00
|
|
|
/*
|
|
|
|
|
* Set the umask to 0022, which results in 0666 & ~0022 = 0644.
|
|
|
|
|
* Otherwise, if root (or an su'ing user) has a wacky umask, we could
|
|
|
|
|
* write out an unreadable resolv.conf.
|
|
|
|
|
*/
|
|
|
|
|
umask (022);
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
g_type_init ();
|
|
|
|
|
if (!g_thread_supported ())
|
|
|
|
|
g_thread_init (NULL);
|
2005-01-29 23:34:31 +00:00
|
|
|
dbus_g_thread_init ();
|
2006-02-27 05:50:28 +00:00
|
|
|
|
2006-02-27 04:31:52 +00:00
|
|
|
nm_logging_setup (become_daemon);
|
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_info ("starting...");
|
2004-08-23 19:20:49 +00:00
|
|
|
|
2004-08-25 20:52:19 +00:00
|
|
|
nm_system_init();
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
/* Initialize our instance data */
|
2004-08-31 Dan Williams <dcbw@redhat.com>
* Remove 'debug' extern global from all files since we now
use syslog()
* src/NetworkManager.[ch]
- Break out routine that get the net.interface property from HAL,
removing that logic from nm_create_device_and_add_to_list()
- (nm_create_device_and_add_to_list): make this a bit more general so
it doesn't do the talking to HAL. Also add arguments to facilitate
the create of test devices.
- (nm_data_mark_state_changed): rename from nm_data_set_state_modified()
- (nm_data_new, main, nm_print_usage): add new argument "--enable-test-devices"
which makes NetworkManager listen for dbus commands to create test
devices, which have no backing hardware. Use when you're on a plane
for example, and/or forgot your wireless card at home. Test devices
_cannot_ be created unless NM is started with --enable-test-devices.
* src/NetworkManagerDbus.[ch]
- New "getLinkActive" method for devices
- New "setLinkActive" method for devices (only works on test devices)
- New "createTestDevice" method on NetworkManager object to create a test
device of a specified type (ie wired, wireless). UDI is created from
scratch, as is the interface name. Only works when NM is started with
--enable-test-devices switch.
- New "removeTestDevice" method on NetworkManager object which removes a
test device. Only works when NM is started with --enable-test-devices
* src/NetworkManagerDevice.[ch]
- Logic to facilitate test devices. Add variables to NMDevice struct to indicate
whether a device is a test device or not, and what its link status is.
- Deal with test devices in most functions. For those that work directly on hardware
special-case test devices.
- (nm_device_new): don't create a test device if test devices weren't enabled on the
command-line.
- (nm_device_update_link_active): split out logic for wired and wireless device link
checking to separate functions to facilitate test device link checking.
- (nm_device_set_enc_key): Since some drivers for wireless cards are daft and
don't make a distinction between System Authentication and Encryption
(namely Cisco aironet), we use Open System auth when setting a WEP key
on the card. We don't deal with Shared Key auth yet.
- (nm_device_activation_worker): split the activation cancel check logic out into
a separate routine nm_device_activation_cancel_if_needed()
- (nm_device_activation_signal_cancel): rename from nm_device_activation_cancel()
- (nm_device_fake_ap_list): Test wireless devices obviously cannot scan, so create
a list of fake access points that they can "see"
- (nm_device_is_test_device): return whether or not a device is a test device
* src/NetworkManagerPolicy.c
- (nm_policy_get_best_device): attempt to deal with wireless network selection,
previously if you "locked"/forced NM to use a wireless device but then
selected a wireless network for NM to use, it would switch to a wired device.
So, if the active device is wireless and it has a "forced" best AP, use it
if the "forced" best AP is still valid
- (nm_state_modification_monitor): deal with NULL best devices, for example
there were no usable network devices, or the last one was removed
* src/backends/NetworkManager*.c
- Deal with test devices, mostly just return success for operations like getting
a DHCP address
* test/nmtestdevices.c
- Test tool to create/remove/link-switch test devices
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@112 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-31 16:09:15 +00:00
|
|
|
nm_data = nm_data_new (enable_test_devices);
|
2006-10-13 19:41:47 +00:00
|
|
|
if (!nm_data) {
|
|
|
|
|
nm_error ("Failed to initialize.");
|
|
|
|
|
goto pidfile;
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
}
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
/* Initialize our DBus service & connection */
|
2007-01-04 12:06:26 +00:00
|
|
|
dbus_mgr = nm_dbus_manager_get ();
|
2006-10-13 19:41:47 +00:00
|
|
|
dbus_connection = nm_dbus_manager_get_dbus_connection (dbus_mgr);
|
|
|
|
|
if (!dbus_connection) {
|
|
|
|
|
nm_error ("Failed to initialize. "
|
|
|
|
|
"Either dbus is not running, or the "
|
|
|
|
|
"NetworkManager dbus security policy "
|
|
|
|
|
"was not loaded.");
|
|
|
|
|
goto done;
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|
2006-10-13 19:41:47 +00:00
|
|
|
g_signal_connect (G_OBJECT (dbus_mgr), "name-owner-changed",
|
|
|
|
|
G_CALLBACK (nm_name_owner_changed_handler), nm_data);
|
2006-11-25 07:09:11 +00:00
|
|
|
id = nm_dbus_manager_register_signal_handler (dbus_mgr,
|
|
|
|
|
NMI_DBUS_INTERFACE,
|
|
|
|
|
NULL,
|
|
|
|
|
nm_dbus_nmi_signal_handler,
|
|
|
|
|
nm_data);
|
|
|
|
|
nm_data->nmi_sig_handler_id = id;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
/* Register DBus method handlers for the main NM objects */
|
|
|
|
|
nm_data->nm_methods = nm_dbus_nm_methods_setup (nm_data);
|
|
|
|
|
nm_dbus_manager_register_method_list (dbus_mgr, nm_data->nm_methods);
|
|
|
|
|
nm_data->device_methods = nm_dbus_device_methods_setup (nm_data);
|
|
|
|
|
nm_dbus_manager_register_method_list (dbus_mgr, nm_data->device_methods);
|
|
|
|
|
nm_data->net_methods = nm_dbus_net_methods_setup (nm_data);
|
2005-01-25 18:21:38 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
manager = nm_manager_new ();
|
|
|
|
|
policy = nm_policy_new (manager);
|
|
|
|
|
|
2006-11-25 15:41:04 +00:00
|
|
|
/* Initialize the supplicant manager */
|
|
|
|
|
sup_mgr = nm_supplicant_manager_get ();
|
|
|
|
|
if (!sup_mgr) {
|
|
|
|
|
nm_error ("Failed to initialize the supplicant manager.");
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
nm_data->vpn_manager = nm_vpn_manager_new (manager, nm_data);
|
2006-10-13 19:41:47 +00:00
|
|
|
if (!nm_data->vpn_manager) {
|
|
|
|
|
nm_warning ("Failed to start the VPN manager.");
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
nm_data->named_manager = nm_named_manager_new ();
|
|
|
|
|
if (!nm_data->named_manager) {
|
|
|
|
|
nm_warning ("Failed to start the named manager.");
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Start our DBus service */
|
|
|
|
|
if (!nm_dbus_manager_start_service (dbus_mgr)) {
|
|
|
|
|
nm_warning ("Failed to start the named manager.");
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2004-12-05 21:28:42 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
hal_manager = nm_hal_manager_new (manager, nm_data);
|
|
|
|
|
if (!hal_manager)
|
|
|
|
|
goto done;
|
2006-10-13 19:41:47 +00:00
|
|
|
|
|
|
|
|
/* If NMI is running, grab allowed wireless network lists from it ASAP */
|
|
|
|
|
if (nm_dbus_manager_name_has_owner (dbus_mgr, NMI_DBUS_SERVICE)) {
|
|
|
|
|
nm_policy_schedule_allowed_ap_list_update (nm_data);
|
|
|
|
|
nm_dbus_vpn_schedule_vpn_connections_update (nm_data);
|
|
|
|
|
}
|
2004-08-02 21:12:40 +00:00
|
|
|
|
2004-08-16 19:46:43 +00:00
|
|
|
/* We run dhclient when we need to, and we don't want any stray ones
|
|
|
|
|
* lying around upon launch.
|
|
|
|
|
*/
|
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
|
|
|
// nm_system_kill_all_dhcp_daemons ();
|
2004-08-16 19:46:43 +00:00
|
|
|
|
|
|
|
|
/* Bring up the loopback interface. */
|
2004-08-24 00:31:47 +00:00
|
|
|
nm_system_enable_loopback ();
|
2004-08-16 19:46:43 +00:00
|
|
|
|
2005-08-05 Robert Love <rml@novell.com>
* NetworkManager.h,
gnome/applet/applet-dbus-devices.c,
gnome/applet/applet-dbus-devices.h,
gnome/applet/applet-dbus.c,
gnome/applet/applet.c,
gnome/applet/applet.h,
src/NetworkManager.c,
src/NetworkManagerMain.h,
src/NetworkManagerSystem.h,
src/backends/NetworkManagerRedHat.c,
src/backends/NetworkManagerSuSE.c,
src/nm-dbus-nm.c: basic dialup support using distro infrastructure
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@821 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-08-05 18:58:17 +00:00
|
|
|
/* Get modems, ISDN, and so on's configuration from the system */
|
|
|
|
|
nm_data->dialup_list = nm_system_get_dialup_config ();
|
|
|
|
|
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
/* Run the main loop */
|
|
|
|
|
nm_policy_schedule_device_change_check (nm_data);
|
2005-04-27 18:05:16 +00:00
|
|
|
nm_schedule_state_change_signal_broadcast (nm_data);
|
2006-10-13 19:41:47 +00:00
|
|
|
exit_status = EXIT_SUCCESS;
|
2004-12-05 21:28:42 +00:00
|
|
|
g_main_loop_run (nm_data->main_loop);
|
2004-08-23 19:20:49 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
done:
|
2005-04-06 16:45:48 +00:00
|
|
|
nm_print_open_socks ();
|
2006-11-25 07:09:11 +00:00
|
|
|
|
|
|
|
|
nm_dbus_manager_remove_signal_handler (dbus_mgr, nm_data->nmi_sig_handler_id);
|
|
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
nm_hal_manager_destroy (hal_manager);
|
|
|
|
|
nm_policy_destroy (policy);
|
|
|
|
|
|
|
|
|
|
if (manager)
|
|
|
|
|
g_object_unref (manager);
|
|
|
|
|
|
2004-06-24 14:18:37 +00:00
|
|
|
nm_data_free (nm_data);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
|
|
|
|
if (sup_mgr)
|
|
|
|
|
g_object_unref (sup_mgr);
|
|
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
/* nm_data_free needs the dbus connection, so must kill the
|
|
|
|
|
* dbus manager after that.
|
|
|
|
|
*/
|
|
|
|
|
g_object_unref (dbus_mgr);
|
2006-02-27 04:31:52 +00:00
|
|
|
nm_logging_shutdown ();
|
2004-06-24 14:18:37 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
pidfile:
|
2006-02-27 05:50:28 +00:00
|
|
|
if (pidfile)
|
|
|
|
|
unlink (pidfile);
|
2006-10-13 19:41:47 +00:00
|
|
|
g_free (pidfile);
|
2006-02-27 05:50:28 +00:00
|
|
|
|
2006-10-13 19:41:47 +00:00
|
|
|
exit:
|
|
|
|
|
exit (exit_status);
|
2004-06-24 14:18:37 +00:00
|
|
|
}
|