summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntti Kaijanmäki <antti@kaijanmaki.net>2008-08-18 08:30:28 +0000
committerAntti Kaijanmäki <antti@kaijanmaki.net>2008-08-18 08:30:28 +0000
commit2c21a2fe6b0498585fba0beb003ac8aa6351803c (patch)
tree9544edfe2ed9a6c96eda933c35fb5110f1d666c6 /src
parente04934d93efba622123809cc767488af673b2967 (diff)
downloadNetworkManager-mbca.tar.gz
keep up with trunkmbca
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/branches/mbca@3981 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am6
-rw-r--r--src/NetworkManager.c1
-rw-r--r--src/NetworkManagerPolicy.c207
-rw-r--r--src/NetworkManagerSystem.c14
-rw-r--r--src/NetworkManagerSystem.h9
-rw-r--r--src/NetworkManagerUtils.c6
-rw-r--r--src/backends/Makefile.am28
-rw-r--r--src/backends/NetworkManagerArch.c75
-rw-r--r--src/backends/NetworkManagerDebian.c69
-rw-r--r--src/backends/NetworkManagerFrugalware.c72
-rw-r--r--src/backends/NetworkManagerGeneric.c185
-rw-r--r--src/backends/NetworkManagerGeneric.h36
-rw-r--r--src/backends/NetworkManagerGentoo.c70
-rw-r--r--src/backends/NetworkManagerMandriva.c70
-rw-r--r--src/backends/NetworkManagerPaldo.c68
-rw-r--r--src/backends/NetworkManagerRedHat.c69
-rw-r--r--src/backends/NetworkManagerSlackware.c72
-rw-r--r--src/backends/NetworkManagerSuSE.c221
-rw-r--r--src/backends/shvar.c399
-rw-r--r--src/backends/shvar.h103
-rw-r--r--src/dhcp-manager/nm-dhcp-manager.c40
-rw-r--r--src/dnsmasq-manager/nm-dnsmasq-manager.c11
-rw-r--r--src/named-manager/nm-named-manager.c380
-rw-r--r--src/named-manager/nm-named-manager.h5
-rw-r--r--src/nm-activation-request.c106
-rw-r--r--src/nm-activation-request.h7
-rw-r--r--src/nm-cdma-device.c2
-rw-r--r--src/nm-device-ethernet.c2
-rw-r--r--src/nm-device-interface.c4
-rw-r--r--src/nm-device.c168
-rw-r--r--src/nm-device.h2
-rw-r--r--src/nm-dhcp4-config.c8
-rw-r--r--src/nm-dhcp4-config.h2
-rw-r--r--src/nm-gsm-device.c42
-rw-r--r--src/nm-gsm-device.h2
-rw-r--r--src/nm-hal-manager.c57
-rw-r--r--src/nm-hso-gsm-device.c563
-rw-r--r--src/nm-hso-gsm-device.h38
-rw-r--r--src/nm-ip4-config.c162
-rw-r--r--src/nm-ip4-config.h7
-rw-r--r--src/nm-netlink-monitor.c7
-rw-r--r--src/nm-netlink-monitor.h1
-rw-r--r--src/nm-properties-changed-signal.c4
-rw-r--r--src/nm-properties-changed-signal.h2
-rw-r--r--src/ppp-manager/nm-ppp-manager.c4
-rw-r--r--src/vpn-manager/nm-vpn-connection.c17
46 files changed, 1302 insertions, 2121 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 807623dc03..2917c80bc5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,6 +65,8 @@ NetworkManager_SOURCES = \
nm-gsm-device.h \
nm-cdma-device.c \
nm-cdma-device.h \
+ nm-hso-gsm-device.c \
+ nm-hso-gsm-device.h \
wpa.c \
wpa.h \
nm-netlink.c \
@@ -179,10 +181,8 @@ EXTRA_DIST = \
$(NetworkManager_DATA)
rundir=$(localstatedir)/run/NetworkManager
-dispatcherdir=$(sysconfdir)/NetworkManager/dispatcher.d
install-data-hook:
- $(mkinstalldirs) -m 0700 $(DESTDIR)$(rundir)
- $(mkinstalldirs) -m 0755 $(DESTDIR)$(dispatcherdir)
+ $(mkinstalldirs) -m 0700 $(DESTDIR)$(rundir)
CLEANFILES = $(BUILT_SOURCES)
diff --git a/src/NetworkManager.c b/src/NetworkManager.c
index 9468c94ba0..e3079db489 100644
--- a/src/NetworkManager.c
+++ b/src/NetworkManager.c
@@ -287,7 +287,6 @@ main (int argc, char *argv[])
nm_logging_setup (become_daemon);
nm_info ("starting...");
- nm_system_init ();
main_loop = g_main_loop_new (NULL, FALSE);
/* Create watch functions that monitor cards for link status. */
diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c
index 631068fa43..c8fa251b19 100644
--- a/src/NetworkManagerPolicy.c
+++ b/src/NetworkManagerPolicy.c
@@ -20,17 +20,7 @@
* (C) Copyright 2005 Red Hat, Inc.
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/select.h>
#include <string.h>
-#include <stdlib.h>
-#include <sys/wait.h>
#include "NetworkManagerPolicy.h"
#include "NetworkManagerUtils.h"
@@ -41,6 +31,7 @@
#include "nm-device.h"
#include "nm-device-wifi.h"
#include "nm-device-ethernet.h"
+#include "nm-hso-gsm-device.h"
#include "nm-gsm-device.h"
#include "nm-cdma-device.h"
#include "nm-dbus-manager.h"
@@ -122,7 +113,6 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
NMActRequest *best_req = NULL;
GSList *devices, *iter;
NMNamedManager *named_mgr;
- NMIP4Config *config;
devices = nm_manager_get_devices (policy->manager);
for (iter = devices; iter; iter = g_slist_next (iter)) {
@@ -133,7 +123,7 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
NMSettingIP4Config *s_ip4;
guint32 prio;
guint i;
- gboolean have_gateway = FALSE;
+ gboolean can_default = FALSE;
if (nm_device_get_state (dev) != NM_DEVICE_STATE_ACTIVATED)
continue;
@@ -158,12 +148,13 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
addr = nm_ip4_config_get_address (ip4_config, i);
if (addr->gateway) {
- have_gateway = TRUE;
+ can_default = TRUE;
break;
}
}
- if (!have_gateway)
+ /* 'hso' devices never get a gateway from the remote end */
+ if (!can_default && !NM_IS_HSO_GSM_DEVICE (dev))
continue;
prio = get_device_priority (dev);
@@ -196,15 +187,17 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
}
named_mgr = nm_named_manager_get ();
- config = nm_device_get_ip4_config (best);
- nm_named_manager_add_ip4_config (named_mgr, config, NM_NAMED_IP_CONFIG_TYPE_BEST_DEVICE);
+ nm_named_manager_add_ip4_config (named_mgr,
+ nm_device_get_ip_iface (best),
+ nm_device_get_ip4_config (best),
+ NM_NAMED_IP_CONFIG_TYPE_BEST_DEVICE);
g_object_unref (named_mgr);
/* Now set new default active connection _after_ updating DNS info, so that
* if the connection is shared dnsmasq picks up the right stuff.
*/
if (best_req)
- nm_act_request_set_default (best_req, TRUE);
+ nm_act_request_set_default (best_req, TRUE);
nm_info ("Policy set (%s) as default device for routing and DNS.",
nm_device_get_iface (best));
@@ -342,178 +335,6 @@ get_device_connection (NMDevice *device)
return nm_act_request_get_connection (req);
}
-static gboolean
-do_cmd (const char *fmt, ...)
-{
- va_list args;
- char *cmd;
- int ret;
-
- va_start (args, fmt);
- cmd = g_strdup_vprintf (fmt, args);
- va_end (args);
-
- nm_info ("Executing: %s", cmd);
- ret = system (cmd);
- g_free (cmd);
-
- if (ret == -1) {
- nm_info ("** Error executing command.");
- return FALSE;
- } else if (WEXITSTATUS (ret)) {
- nm_info ("** Command returned exit status %d.", WEXITSTATUS (ret));
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-sharing_init (void)
-{
- do_cmd ("echo \"1\" > /proc/sys/net/ipv4/ip_forward");
- do_cmd ("echo \"1\" > /proc/sys/net/ipv4/ip_dynaddr");
- do_cmd ("/sbin/modprobe ip_tables iptable_nat ip_nat_ftp ip_nat_irc");
- do_cmd ("/sbin/iptables -P INPUT ACCEPT");
- do_cmd ("/sbin/iptables -F INPUT");
- do_cmd ("/sbin/iptables -P OUTPUT ACCEPT");
- do_cmd ("/sbin/iptables -F OUTPUT");
- do_cmd ("/sbin/iptables -P FORWARD DROP");
- do_cmd ("/sbin/iptables -F FORWARD");
- do_cmd ("/sbin/iptables -t nat -F");
-}
-
-static void
-sharing_stop (NMActRequest *req)
-{
- do_cmd ("/sbin/iptables -F INPUT");
- do_cmd ("/sbin/iptables -F OUTPUT");
- do_cmd ("/sbin/iptables -P FORWARD DROP");
- do_cmd ("/sbin/iptables -F FORWARD");
- do_cmd ("/sbin/iptables -F -t nat");
-
- // Delete all User-specified chains
- do_cmd ("/sbin/iptables -X");
-
- // Reset all IPTABLES counters
- do_cmd ("/sbin/iptables -Z");
-
- nm_act_request_set_shared (req, FALSE);
-}
-
-/* Given a default activation request, start NAT-ing if there are any shared
- * connections.
- */
-static void
-sharing_restart (NMPolicy *policy, NMActRequest *req)
-{
- GSList *devices, *iter;
- const char *extif;
- gboolean have_shared = FALSE;
-
- if (nm_act_request_get_shared (req))
- sharing_stop (req);
-
- extif = nm_device_get_ip_iface (NM_DEVICE (nm_act_request_get_device (req)));
- g_assert (extif);
-
- /* Start NAT-ing every 'shared' connection */
- devices = nm_manager_get_devices (policy->manager);
- for (iter = devices; iter; iter = g_slist_next (iter)) {
- NMDevice *candidate = NM_DEVICE (iter->data);
- NMSettingIP4Config *s_ip4;
- NMConnection *connection;
- const char *intif;
-
- if (nm_device_get_state (candidate) != NM_DEVICE_STATE_ACTIVATED)
- continue;
-
- connection = get_device_connection (candidate);
- g_assert (connection);
-
- s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
- if (!s_ip4 || strcmp (s_ip4->method, "shared"))
- continue;
-
- /* Init sharing if there's a shared connection to NAT */
- if (!have_shared) {
- sharing_init ();
- have_shared = TRUE;
- }
-
- // FWD: Allow all connections OUT and only existing and related ones IN
- intif = nm_device_get_ip_iface (candidate);
- g_assert (intif);
- do_cmd ("/sbin/iptables -A FORWARD -i %s -o %s -m state --state ESTABLISHED,RELATED -j ACCEPT", extif, intif);
- do_cmd ("/sbin/iptables -A FORWARD -i %s -o %s -j ACCEPT", extif, intif);
- do_cmd ("/sbin/iptables -A FORWARD -i %s -o %s -j ACCEPT", intif, extif);
- }
-
- if (have_shared) {
- // Enabling SNAT (MASQUERADE) functionality on $EXTIF
- do_cmd ("/sbin/iptables -t nat -A POSTROUTING -o %s -j MASQUERADE", extif);
-
- nm_act_request_set_shared (req, TRUE);
- }
-}
-
-static void
-check_sharing (NMPolicy *policy, NMDevice *device, NMConnection *connection)
-{
- NMSettingIP4Config *s_ip4;
- GSList *devices, *iter;
- NMActRequest *default_req = NULL;
-
- if (!connection)
- return;
-
- /* We only care about 'shared' connections going up or down */
- s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
- if (!s_ip4 || strcmp (s_ip4->method, "shared"))
- return;
-
- /* Find the default connection, if any */
- devices = nm_manager_get_devices (policy->manager);
- for (iter = devices; iter; iter = g_slist_next (iter)) {
- NMDevice *candidate = NM_DEVICE (iter->data);
- NMActRequest *req = nm_device_get_act_request (candidate);
-
- if (req && nm_act_request_get_default (req)) {
- default_req = req;
- break;
- }
- }
-
- /* Restart sharing if there's a default active connection */
- if (default_req)
- sharing_restart (policy, default_req);
-}
-
-static void
-active_connection_default_changed (NMActRequest *req,
- GParamSpec *pspec,
- NMPolicy *policy)
-{
- gboolean is_default = nm_act_request_get_default (req);
-
- if (is_default) {
- if (nm_act_request_get_shared (req)) {
- /* Already shared, shouldn't get here */
- nm_warning ("%s: Active connection '%s' already shared.",
- __func__, nm_act_request_get_active_connection_path (req));
- return;
- }
-
- sharing_restart (policy, req);
- } else {
- if (!nm_act_request_get_shared (req))
- return; /* Don't care about non-shared connections */
-
- /* Tear down all NAT-ing */
- sharing_stop (req);
- }
-}
-
static void
device_state_changed (NMDevice *device,
NMDeviceState new_state,
@@ -532,27 +353,19 @@ device_state_changed (NMDevice *device,
nm_info ("Marking connection '%s' invalid.", get_connection_id (connection));
}
schedule_activate_check (policy, device);
- check_sharing (policy, device, connection);
break;
case NM_DEVICE_STATE_ACTIVATED:
/* Clear the invalid tag on the connection */
if (connection)
g_object_set_data (G_OBJECT (connection), INVALID_TAG, NULL);
- g_signal_connect (G_OBJECT (nm_device_get_act_request (device)),
- "notify::default",
- G_CALLBACK (active_connection_default_changed),
- policy);
-
update_routing_and_dns (policy, FALSE);
- check_sharing (policy, device, connection);
break;
case NM_DEVICE_STATE_UNMANAGED:
case NM_DEVICE_STATE_UNAVAILABLE:
case NM_DEVICE_STATE_DISCONNECTED:
update_routing_and_dns (policy, FALSE);
schedule_activate_check (policy, device);
- check_sharing (policy, device, connection);
break;
default:
break;
diff --git a/src/NetworkManagerSystem.c b/src/NetworkManagerSystem.c
index bf6b11d792..c97d18ded2 100644
--- a/src/NetworkManagerSystem.c
+++ b/src/NetworkManagerSystem.c
@@ -385,7 +385,7 @@ nm_system_vpn_device_set_from_ip4_config (NMDevice *active_device,
out:
named_mgr = nm_named_manager_get ();
- nm_named_manager_add_ip4_config (named_mgr, config, NM_NAMED_IP_CONFIG_TYPE_VPN);
+ nm_named_manager_add_ip4_config (named_mgr, iface, config, NM_NAMED_IP_CONFIG_TYPE_VPN);
g_object_unref (named_mgr);
return TRUE;
@@ -406,7 +406,7 @@ gboolean nm_system_vpn_device_unset_from_ip4_config (NMDevice *active_device, co
g_return_val_if_fail (config != NULL, FALSE);
named_mgr = nm_named_manager_get ();
- nm_named_manager_remove_ip4_config (named_mgr, config);
+ nm_named_manager_remove_ip4_config (named_mgr, iface, config);
g_object_unref (named_mgr);
return TRUE;
@@ -428,10 +428,10 @@ gboolean nm_system_device_set_up_down (NMDevice *dev, gboolean up)
gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up)
{
+ struct rtnl_link *request = NULL, *old = NULL;
+ struct nl_handle *nlh;
gboolean success = FALSE;
guint32 idx;
- struct rtnl_link * request = NULL;
- struct rtnl_link * old = NULL;
g_return_val_if_fail (iface != NULL, FALSE);
@@ -446,16 +446,13 @@ gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up
idx = nm_netlink_iface_to_index (iface);
old = nm_netlink_index_to_rtnl_link (idx);
if (old) {
- struct nl_handle *nlh;
-
nlh = nm_netlink_get_default_handle ();
if (nlh)
- rtnl_link_change (nlh, old, request, 0);
+ success = (rtnl_link_change (nlh, old, request, 0) == 0) ? TRUE : FALSE;
}
rtnl_link_put (old);
rtnl_link_put (request);
- success = TRUE;
out:
return success;
@@ -483,6 +480,7 @@ nm_system_device_is_up_with_iface (const char *iface)
}
/* Get device's flags */
+ memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, iface, IFNAMSIZ);
if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0) {
if (errno != ENODEV) {
diff --git a/src/NetworkManagerSystem.h b/src/NetworkManagerSystem.h
index fa2b337957..60e24c6abb 100644
--- a/src/NetworkManagerSystem.h
+++ b/src/NetworkManagerSystem.h
@@ -32,8 +32,6 @@
* implemented in the backend files in backends/ directory
*/
-void nm_system_init (void);
-
void nm_system_device_flush_ip4_routes (NMDevice *dev);
void nm_system_device_flush_ip4_routes_with_iface (const char *iface);
@@ -45,7 +43,6 @@ void nm_system_device_flush_ip4_addresses (NMDevice *dev);
void nm_system_device_flush_ip4_addresses_with_iface (const char *iface);
void nm_system_enable_loopback (void);
-void nm_system_kill_all_dhcp_daemons (void);
void nm_system_update_dns (void);
gboolean nm_system_device_set_from_ip4_config (const char *iface,
@@ -65,12 +62,6 @@ gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean
gboolean nm_system_device_is_up (NMDevice *device);
gboolean nm_system_device_is_up_with_iface (const char *iface);
-void nm_system_set_hostname (NMIP4Config *config);
-void nm_system_activate_nis (NMIP4Config *config);
-void nm_system_shutdown_nis (void);
-
gboolean nm_system_device_set_mtu (const char *iface, guint32 mtu);
-gboolean nm_system_should_modify_resolv_conf (void);
-
#endif
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 66fe990795..a1afc65f1f 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -113,14 +113,14 @@ nm_print_device_capabilities (NMDevice *dev)
driver = "<unknown>";
if (caps == NM_DEVICE_CAP_NONE || !(NM_DEVICE_CAP_NM_SUPPORTED)) {
- nm_info ("%s: Driver support level for '%s' is unsupported",
+ nm_info ("%s: driver '%s' is unsupported",
nm_device_get_iface (dev), driver);
return;
}
if (NM_IS_DEVICE_ETHERNET (dev)) {
if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT)) {
- nm_info ("%s: Driver '%s' does not support carrier detection.\n"
+ 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;
@@ -130,7 +130,7 @@ nm_print_device_capabilities (NMDevice *dev)
}
if (full_support) {
- nm_info ("%s: Device is fully-supported using driver '%s'.",
+ nm_info ("%s: driver is '%s'.",
nm_device_get_iface (dev), driver);
}
}
diff --git a/src/backends/Makefile.am b/src/backends/Makefile.am
index 10830c7bc4..14af1de535 100644
--- a/src/backends/Makefile.am
+++ b/src/backends/Makefile.am
@@ -7,54 +7,46 @@ INCLUDES = -I${top_srcdir} \
noinst_LTLIBRARIES = libnmbackend.la
-libnmbackend_la_SOURCES = NetworkManagerGeneric.c \
+libnmbackend_la_SOURCES = NetworkManagerGeneric.c \
NetworkManagerGeneric.h
libnmbackend_la_LIBADD =
if TARGET_REDHAT
-libnmbackend_la_SOURCES += NetworkManagerRedHat.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerRedHat.c
endif
if TARGET_SUSE
-libnmbackend_la_SOURCES += NetworkManagerSuSE.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerSuSE.c
endif
if TARGET_GENTOO
-libnmbackend_la_SOURCES += NetworkManagerGentoo.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerGentoo.c
endif
if TARGET_DEBIAN
-libnmbackend_la_SOURCES += NetworkManagerDebian.c
+libnmbackend_la_SOURCES += NetworkManagerDebian.c
endif
if TARGET_SLACKWARE
-libnmbackend_la_SOURCES += NetworkManagerSlackware.c
+libnmbackend_la_SOURCES += NetworkManagerSlackware.c
endif
if TARGET_ARCH
-libnmbackend_la_SOURCES += NetworkManagerArch.c
+libnmbackend_la_SOURCES += NetworkManagerArch.c
endif
if TARGET_PALDO
-libnmbackend_la_SOURCES += NetworkManagerPaldo.c
+libnmbackend_la_SOURCES += NetworkManagerPaldo.c
endif
if TARGET_FRUGALWARE
-libnmbackend_la_SOURCES += NetworkManagerFrugalware.c
+libnmbackend_la_SOURCES += NetworkManagerFrugalware.c
libnmbackend_la_LIBADD += -lfwnetconfig -lfwutil
endif
if TARGET_MANDRIVA
-libnmbackend_la_SOURCES += NetworkManagerMandriva.c \
- shvar.c \
- shvar.h
+libnmbackend_la_SOURCES += NetworkManagerMandriva.c
endif
libnmbackend_la_LIBADD += $(DBUS_LIBS) $(GTHREAD_LIBS)
diff --git a/src/backends/NetworkManagerArch.c b/src/backends/NetworkManagerArch.c
index c7dc1bfd37..3ed5677e87 100644
--- a/src/backends/NetworkManagerArch.c
+++ b/src/backends/NetworkManagerArch.c
@@ -36,31 +36,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <arpa/inet.h>
-#include <glib/gprintf.h>
-#include <glib/gfileutils.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -70,22 +51,10 @@ void nm_system_init (void)
*/
void nm_system_enable_loopback (void)
{
- nm_system_device_set_up_down_with_iface ("lo", TRUE);
+ nm_generic_enable_loopback ();
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/usr/bin/killall -q dhclient");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -96,48 +65,6 @@ void nm_system_update_dns (void)
{
/* Check if the daemon was already running - do not start a new instance */
if (g_file_test("/var/run/daemons/nscd", G_FILE_TEST_EXISTS))
- {
nm_spawn_process ("/etc/rc.d/nscd restart");
- }
-}
-
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
}
diff --git a/src/backends/NetworkManagerDebian.c b/src/backends/NetworkManagerDebian.c
index ef6e501460..d4a518befb 100644
--- a/src/backends/NetworkManagerDebian.c
+++ b/src/backends/NetworkManagerDebian.c
@@ -28,28 +28,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -63,18 +47,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/usr/bin/killall -q dhclient");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -84,46 +56,5 @@ void nm_system_kill_all_dhcp_daemons (void)
void nm_system_update_dns (void)
{
nm_spawn_process ("/usr/sbin/invoke-rc.d nscd restart");
-
-}
-
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
}
diff --git a/src/backends/NetworkManagerFrugalware.c b/src/backends/NetworkManagerFrugalware.c
index 301985ddf4..492bf19399 100644
--- a/src/backends/NetworkManagerFrugalware.c
+++ b/src/backends/NetworkManagerFrugalware.c
@@ -24,29 +24,13 @@
*/
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerSystem.h"
-#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-// Provided by the frugalwareutils package on Frugalware
-#include <libfwnetconfig.h>
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
-}
+/* Provided by the frugalwareutils package on Frugalware */
+#include <libfwnetconfig.h>
/*
* nm_system_enable_loopback
@@ -61,18 +45,6 @@ void nm_system_enable_loopback (void)
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/usr/bin/killall -q dhclient");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -84,43 +56,3 @@ void nm_system_update_dns (void)
/* I'm not running nscd */
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerGeneric.c b/src/backends/NetworkManagerGeneric.c
index 1143c4387b..93b1e1262d 100644
--- a/src/backends/NetworkManagerGeneric.c
+++ b/src/backends/NetworkManagerGeneric.c
@@ -34,9 +34,8 @@
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
#include "nm-netlink.h"
+#include "nm-utils.h"
/* Because of a bug in libnl, rtnl.h should be included before route.h */
#include <netlink/route/rtnl.h>
@@ -45,18 +44,6 @@
#include <netlink/netlink.h>
/*
- * nm_generic_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_generic_init (void)
-{
- /* Kill any dhclients lying around */
- nm_system_kill_all_dhcp_daemons ();
-}
-
-/*
* nm_generic_enable_loopback
*
* Bring up the loopback interface
@@ -112,17 +99,6 @@ out:
}
/*
- * nm_generic_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_generic_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_generic_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -133,162 +109,3 @@ void nm_generic_update_dns (void)
{
}
-/*
- * nm_generic_set_ip4_config_from_resolv_conf
- *
- * Add nameservers and search names from a resolv.conf format file.
- *
- */
-void nm_generic_set_ip4_config_from_resolv_conf (const char *filename, NMIP4Config *ip4_config)
-{
- char * contents = NULL;
- char ** split_contents = NULL;
- int i, len;
-
- g_return_if_fail (filename != NULL);
- g_return_if_fail (ip4_config != NULL);
-
- if (!g_file_get_contents (filename, &contents, NULL, NULL) || (contents == NULL))
- return;
-
- if (!(split_contents = g_strsplit (contents, "\n", 0)))
- goto out;
-
- len = g_strv_length (split_contents);
- for (i = 0; i < len; i++)
- {
- char *line = split_contents[i];
-
- /* Ignore comments */
- if (!line || (line[0] == ';') || (line[0] == '#'))
- continue;
-
- line = g_strstrip (line);
- if ((strncmp (line, "search", 6) == 0) && (strlen (line) > 6))
- {
- char *searches = g_strdup (line + 7);
- char **split_searches = NULL;
-
- if (!searches || !strlen (searches))
- continue;
-
- /* Allow space-separated search domains */
- if ((split_searches = g_strsplit (searches, " ", 0)))
- {
- int m, srch_len;
-
- srch_len = g_strv_length (split_searches);
- for (m = 0; m < srch_len; m++)
- {
- if (split_searches[m])
- nm_ip4_config_add_domain (ip4_config, split_searches[m]);
- }
- g_strfreev (split_searches);
- }
- else
- {
- /* Only 1 item, add the whole line */
- nm_ip4_config_add_domain (ip4_config, searches);
- }
-
- g_free (searches);
- }
- else if ((strncmp (line, "nameserver", 10) == 0) && (strlen (line) > 10))
- {
- guint32 addr = (guint32) (inet_addr (line + 11));
-
- if (addr != (guint32) -1)
- nm_ip4_config_add_nameserver (ip4_config, addr);
- }
- }
-
- g_strfreev (split_contents);
-
-out:
- g_free (contents);
-}
-
-
-/*
- * nm_generic_device_get_system_config
- *
- * Retrieve any relevant configuration info for a particular device
- * from the system network configuration information. Clear out existing
- * info before setting stuff too.
- *
- */
-void* nm_generic_device_get_system_config (NMDevice *dev)
-{
- return NULL;
-}
-
-/*
- * nm_generic_device_free_system_config
- *
- * Free stored system config data
- *
- */
-void nm_generic_device_free_system_config (NMDevice *dev, void *system_config_data)
-{
- return;
-}
-
-
-/*
- * nm_generic_device_get_disabled
- *
- * Return whether the distro-specific system config tells us to use
- * dhcp for this device.
- *
- */
-gboolean nm_generic_device_get_disabled (NMDevice *dev)
-{
- return FALSE;
-}
-
-
-NMIP4Config *nm_generic_device_new_ip4_system_config (NMDevice *dev)
-{
- return NULL;
-}
-
-/*
- * nm_generic_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_generic_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_generic_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_generic_shutdown_nis (void)
-{
-}
-
-/*
- * nm_generic_set_hostname
- *
- * set the hostname
- *
- */
-void nm_generic_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_generic_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_generic_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerGeneric.h b/src/backends/NetworkManagerGeneric.h
index 420bc25a4e..0a0a88a215 100644
--- a/src/backends/NetworkManagerGeneric.h
+++ b/src/backends/NetworkManagerGeneric.h
@@ -24,39 +24,7 @@
#ifndef NETWORK_MANAGER_GENERIC_H
#define NETWORK_MANAGER_GENERIC_H
-#include <glib.h>
-#include "nm-device.h"
-#include "nm-ip4-config.h"
-#include "nm-named-manager.h"
-
-/* Prototypes for system/distribution dependent functions,
- * implemented in the backend files in backends/ directory
- */
-
-void nm_generic_init (void);
-
-void nm_generic_enable_loopback (void);
-void nm_generic_kill_all_dhcp_daemons (void);
-void nm_generic_update_dns (void);
-
-void nm_generic_set_ip4_config_from_resolv_conf (const char *filename, NMIP4Config *ip4_config);
-void * nm_generic_device_get_system_config (NMDevice *dev);
-void nm_generic_device_free_system_config (NMDevice *dev, void *system_config_data);
-NMIP4Config * nm_generic_device_new_ip4_system_config (NMDevice *dev);
-
-gboolean nm_generic_device_get_disabled (NMDevice *dev);
-
-gboolean nm_generic_device_set_from_ip4_config (NMDevice *dev);
-gboolean nm_generic_vpn_device_set_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config, char **routes, int num_routes);
-gboolean nm_generic_vpn_device_unset_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config);
-
-gboolean nm_generic_device_set_up_down (NMDevice *dev, gboolean up);
-gboolean nm_generic_device_set_up_down_with_iface (NMDevice *dev, const char *iface, gboolean up);
-
-void nm_generic_set_hostname (NMIP4Config *config);
-void nm_generic_activate_nis (NMIP4Config *config);
-void nm_generic_shutdown_nis (void);
-
-gboolean nm_generic_should_modify_resolv_conf (void);
+void nm_generic_enable_loopback (void);
+void nm_generic_update_dns (void);
#endif
diff --git a/src/backends/NetworkManagerGentoo.c b/src/backends/NetworkManagerGentoo.c
index ee7e0dbddc..7fa12078a1 100644
--- a/src/backends/NetworkManagerGentoo.c
+++ b/src/backends/NetworkManagerGentoo.c
@@ -28,29 +28,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
#include <string.h>
#include <stdlib.h>
-#include <arpa/inet.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -66,18 +49,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- /* TODO */
- /* Tell dhcdbd to kill its dhclient instance */
-}
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -94,44 +65,3 @@ void nm_system_update_dns (void)
#endif
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
-
diff --git a/src/backends/NetworkManagerMandriva.c b/src/backends/NetworkManagerMandriva.c
index f41c4bdc46..527a25d896 100644
--- a/src/backends/NetworkManagerMandriva.c
+++ b/src/backends/NetworkManagerMandriva.c
@@ -26,30 +26,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
-
/*
* nm_system_enable_loopback
@@ -63,17 +45,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -88,44 +59,3 @@ void nm_system_update_dns (void)
}
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerPaldo.c b/src/backends/NetworkManagerPaldo.c
index 017d0cbb94..0147a3b0e4 100644
--- a/src/backends/NetworkManagerPaldo.c
+++ b/src/backends/NetworkManagerPaldo.c
@@ -27,31 +27,15 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
-#include <glib/gkeyfile.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
#include "nm-utils.h"
/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
-
-/*
* nm_system_enable_loopback
*
* Bring up the loopback interface
@@ -63,17 +47,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -86,44 +59,3 @@ void nm_system_update_dns (void)
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerRedHat.c b/src/backends/NetworkManagerRedHat.c
index 284ef40e4e..1e3f7e9652 100644
--- a/src/backends/NetworkManagerRedHat.c
+++ b/src/backends/NetworkManagerRedHat.c
@@ -24,29 +24,12 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -60,17 +43,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -85,44 +57,3 @@ void nm_system_update_dns (void)
}
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerSlackware.c b/src/backends/NetworkManagerSlackware.c
index 91fac1c766..8d7c5bf294 100644
--- a/src/backends/NetworkManagerSlackware.c
+++ b/src/backends/NetworkManagerSlackware.c
@@ -25,31 +25,11 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
-#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "nm-utils.h"
-
-/*
- * Mostly a mix of the Gentoo and RedHat Backends
- */
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -64,18 +44,6 @@ void nm_system_enable_loopback (void)
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
- nm_spawn_process ("/bin/killall -q dhcpcd");
-}
-
-
-/*
* nm_system_update_dns
*
* Make glibc/nscd aware of any changes to the resolv.conf file by
@@ -87,43 +55,3 @@ void nm_system_update_dns (void)
/* I'm not running nscd */
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- return TRUE;
-}
-
diff --git a/src/backends/NetworkManagerSuSE.c b/src/backends/NetworkManagerSuSE.c
index 8578c7b4cb..a0cd1cb105 100644
--- a/src/backends/NetworkManagerSuSE.c
+++ b/src/backends/NetworkManagerSuSE.c
@@ -28,34 +28,13 @@
#endif
#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <errno.h>
#include "NetworkManagerGeneric.h"
#include "NetworkManagerSystem.h"
#include "NetworkManagerUtils.h"
-#include "nm-device.h"
-#include "NetworkManagerPolicy.h"
#include "nm-utils.h"
-#include "shvar.h"
-
-/*
- * nm_system_init
- *
- * Initializes the distribution-specific system backend
- *
- */
-void nm_system_init (void)
-{
- nm_generic_init ();
-}
/*
* nm_system_enable_loopback
@@ -69,17 +48,6 @@ void nm_system_enable_loopback (void)
}
/*
- * nm_system_kill_all_dhcp_daemons
- *
- * Kill all DHCP daemons currently running, done at startup.
- *
- */
-void nm_system_kill_all_dhcp_daemons (void)
-{
-}
-
-
-/*
* nm_system_update_dns
*
* Invalidate the nscd host cache, if it exists, since
@@ -92,192 +60,3 @@ void nm_system_update_dns (void)
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}
-/*
- * nm_system_activate_nis
- *
- * set up the nis domain and write a yp.conf
- *
- */
-void nm_system_activate_nis (NMIP4Config *config)
-{
- shvarFile *file;
- const char *nis_domain;
- char *name, *buf;
- struct in_addr temp_addr;
- int i;
- FILE *ypconf = NULL;
- char addr_buf[INET_ADDRSTRLEN+1];
-
- memset (&addr_buf, '\0', sizeof (addr_buf));
-
- g_return_if_fail (config != NULL);
-
- nis_domain = nm_ip4_config_get_nis_domain(config);
-
- name = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
- file = svNewFile (name);
- if (!file)
- goto out_gfree;
-
- buf = svGetValue (file, "DHCLIENT_SET_DOMAINNAME");
- if (!buf)
- goto out_close;
-
- if ((!strcmp (buf, "yes")) && nis_domain && (setdomainname (nis_domain, strlen (nis_domain)) < 0))
- nm_warning ("Could not set nis domain name.");
- free (buf);
-
- buf = svGetValue (file, "DHCLIENT_MODIFY_NIS_CONF");
- if (!buf)
- goto out_close;
-
- if (!strcmp (buf, "yes")) {
- int num_nis_servers;
-
- num_nis_servers = nm_ip4_config_get_num_nis_servers(config);
- if (num_nis_servers > 0)
- {
- struct stat sb;
-
- /* write out yp.conf and restart the daemon */
-
- ypconf = fopen ("/etc/yp.conf", "w");
-
- if (ypconf)
- {
- fprintf (ypconf, "# generated by NetworkManager, do not edit!\n\n");
- for (i = 0; i < num_nis_servers; i++) {
- temp_addr.s_addr = nm_ip4_config_get_nis_server (config, i);
-
- if (!inet_ntop (AF_INET, &temp_addr, addr_buf, INET_ADDRSTRLEN))
- nm_warning ("%s: error converting IP4 address 0x%X",
- __func__, ntohl (temp_addr.s_addr));
- else
- fprintf (ypconf, "domain %s server %s\n", nis_domain, addr_buf);
- }
- fprintf (ypconf, "\n");
- fclose (ypconf);
- } else
- nm_warning ("Could not commit NIS changes to /etc/yp.conf.");
-
- if (stat ("/usr/sbin/rcautofs", &sb) != -1)
- {
- nm_info ("Restarting autofs.");
- nm_spawn_process ("/usr/sbin/rcautofs reload");
- }
- }
- }
- free (buf);
-
-out_close:
- svCloseFile (file);
-out_gfree:
- g_free (name);
-}
-
-
-/*
- * nm_system_shutdown_nis
- *
- * shutdown ypbind
- *
- */
-void nm_system_shutdown_nis (void)
-{
-}
-
-
-/*
- * nm_system_set_hostname
- *
- * set the hostname
- *
- */
-void nm_system_set_hostname (NMIP4Config *config)
-{
- char *filename, *h_name = NULL, *buf;
- shvarFile *file;
-
- g_return_if_fail (config != NULL);
-
- filename = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
- file = svNewFile (filename);
- if (!file)
- goto out_gfree;
-
- buf = svGetValue (file, "DHCLIENT_SET_HOSTNAME");
- if (!buf)
- goto out_close;
-
- if (!strcmp (buf, "yes"))
- {
- const char *hostname;
-
- hostname = nm_ip4_config_get_hostname (config);
- if (!hostname)
- {
- struct in_addr temp_addr;
- struct hostent *host;
- const NMSettingIP4Address *ip_address;
-
- /* try to get hostname via dns */
- ip_address = nm_ip4_config_get_address (config, 0);
- temp_addr.s_addr = ip_address->address;
- host = gethostbyaddr ((char *) &temp_addr, sizeof (temp_addr), AF_INET);
- if (host)
- {
- h_name = g_strdup (host->h_name);
- hostname = strtok (h_name, ".");
- }
- else
- nm_warning ("nm_system_set_hostname(): gethostbyaddr failed, h_errno = %d", h_errno);
- }
-
- if (hostname)
- {
- nm_info ("Setting hostname to '%s'", hostname);
- if (sethostname (hostname, strlen (hostname)) < 0)
- nm_warning ("Could not set hostname.");
- }
- }
-
- g_free (h_name);
- free (buf);
-out_close:
- svCloseFile (file);
-out_gfree:
- g_free (filename);
-}
-
-/*
- * nm_system_should_modify_resolv_conf
- *
- * Can NM update resolv.conf, or is it locked down?
- */
-gboolean nm_system_should_modify_resolv_conf (void)
-{
- char *name, *buf;
- shvarFile *file;
- gboolean ret = TRUE;
-
- name = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
- file = svNewFile (name);
- if (!file)
- goto out_gfree;
-
- buf = svGetValue (file, "DHCLIENT_MODIFY_RESOLV_CONF");
- if (!buf)
- goto out_close;
-
- if (strcmp (buf, "no") == 0)
- ret = FALSE;
-
- free (buf);
-out_close:
- svCloseFile (file);
-out_gfree:
- g_free (name);
-
- return ret;
-}
-
diff --git a/src/backends/shvar.c b/src/backends/shvar.c
deleted file mode 100644
index 67b3019d48..0000000000
--- a/src/backends/shvar.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * shvar.c
- *
- * Implementation of non-destructively reading/writing files containing
- * only shell variable declarations and full-line comments.
- *
- * Includes explicit inheritance mechanism intended for use with
- * Red Hat Linux ifcfg-* files. There is no protection against
- * inheritance loops; they will generally cause stack overflows.
- * Furthermore, they are only intended for one level of inheritance;
- * the value setting algorithm assumes this.
- *
- * Copyright 1999,2000 Red Hat, Inc.
- *
- * This 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "shvar.h"
-
-/* Open the file <name>, returning a shvarFile on success and NULL on failure.
- Add a wrinkle to let the caller specify whether or not to create the file
- (actually, return a structure anyway) if it doesn't exist. */
-static shvarFile *
-svOpenFile(const char *name, gboolean create)
-{
- shvarFile *s = NULL;
- int closefd = 0;
-
- s = g_malloc0(sizeof(shvarFile));
-
-#if 1 /* NetworkManager local change */
- s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
- if (s->fd != -1) closefd = 1;
-#else
- s->fd = open(name, O_RDWR); /* NOT O_CREAT */
- if (s->fd == -1) {
- /* try read-only */
- s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
- if (s->fd != -1) closefd = 1;
- }
-#endif
- s->fileName = g_strdup(name);
-
- if (s->fd != -1) {
- struct stat buf;
- char *p, *q;
-
- if (fstat(s->fd, &buf) < 0) goto bail;
- s->arena = g_malloc0(buf.st_size + 1);
-
- if (read(s->fd, s->arena, buf.st_size) < 0) goto bail;
-
- /* we'd use g_strsplit() here, but we want a list, not an array */
- for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) {
- s->lineList = g_list_append(s->lineList, g_strndup(p, q - p));
- }
-
- /* closefd is set if we opened the file read-only, so go ahead and
- close it, because we can't write to it anyway */
- if (closefd) {
- close(s->fd);
- s->fd = -1;
- }
-
- return s;
- }
-
- if (create) {
- return s;
- }
-
-bail:
- if (s->fd != -1) close(s->fd);
- if (s->arena) g_free (s->arena);
- if (s->fileName) g_free (s->fileName);
- g_free (s);
- return NULL;
-}
-
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(const char *name)
-{
- return svOpenFile(name, FALSE);
-}
-
-/* Create a new file structure, returning actual data if the file exists,
- * and a suitable starting point if it doesn't. */
-shvarFile *
-svCreateFile(const char *name)
-{
- return svOpenFile(name, TRUE);
-}
-
-/* remove escaped characters in place */
-static void
-unescape(char *s) {
- int len, i;
-
- len = strlen(s);
- if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) {
- i = len - 2;
- memmove(s, s+1, i);
- s[i+1] = '\0';
- len = i;
- }
- for (i = 0; i < len; i++) {
- if (s[i] == '\\') {
- memmove(s+i, s+i+1, len-(i+1));
- len--;
- }
- s[len] = '\0';
- }
-}
-
-
-/* create a new string with all necessary characters escaped.
- * caller must free returned string
- */
-static const char escapees[] = "\"'\\$~`"; /* must be escaped */
-static const char spaces[] = " \t|&;()<>"; /* only require "" */
-static char *
-escape(const char *s) {
- char *new;
- int i, j, mangle = 0, space = 0;
- int newlen, slen;
- static int esclen, splen;
-
- if (!esclen) esclen = strlen(escapees);
- if (!splen) splen = strlen(spaces);
- slen = strlen(s);
-
- for (i = 0; i < slen; i++) {
- if (strchr(escapees, s[i])) mangle++;
- if (strchr(spaces, s[i])) space++;
- }
- if (!mangle && !space) return strdup(s);
-
- newlen = slen + mangle + 3; /* 3 is extra ""\0 */
- new = g_malloc0(newlen);
- if (!new) return NULL;
-
- j = 0;
- new[j++] = '"';
- for (i = 0; i < slen; i++) {
- if (strchr(escapees, s[i])) {
- new[j++] = '\\';
- }
- new[j++] = s[i];
- }
- new[j++] = '"';
- g_assert(j == slen + mangle + 2); /* j is the index of the '\0' */
-
- return new;
-}
-
-/* Get the value associated with the key, and leave the current pointer
- * pointing at the line containing the value. The char* returned MUST
- * be freed by the caller.
- */
-char *
-svGetValue(shvarFile *s, const char *key)
-{
- char *value = NULL;
- char *line;
- char *keyString;
- int len;
-
- g_assert(s);
- g_assert(key);
-
- keyString = g_malloc0(strlen(key) + 2);
- strcpy(keyString, key);
- keyString[strlen(key)] = '=';
- len = strlen(keyString);
-
- for (s->current = s->lineList; s->current; s->current = s->current->next) {
- line = s->current->data;
- if (!strncmp(keyString, line, len)) {
- value = g_strdup(line + len);
- unescape(value);
- break;
- }
- }
- g_free(keyString);
-
- if (value) {
- if (value[0]) {
- return value;
- } else {
- g_free(value);
- return NULL;
- }
- }
- if (s->parent) value = svGetValue(s->parent, key);
- return value;
-}
-
-/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
- * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
- * return <default> otherwise
- */
-int
-svTrueValue(shvarFile *s, const char *key, int def)
-{
- char *tmp;
- int returnValue = def;
-
- tmp = svGetValue(s, key);
- if (!tmp) return returnValue;
-
- if ( (!strcasecmp("yes", tmp)) ||
- (!strcasecmp("true", tmp)) ||
- (!strcasecmp("t", tmp)) ||
- (!strcasecmp("y", tmp)) ) returnValue = 1;
- else
- if ( (!strcasecmp("no", tmp)) ||
- (!strcasecmp("false", tmp)) ||
- (!strcasecmp("f", tmp)) ||
- (!strcasecmp("n", tmp)) ) returnValue = 0;
-
- g_free (tmp);
- return returnValue;
-}
-
-
-/* Set the variable <key> equal to the value <value>.
- * If <key> does not exist, and the <current> pointer is set, append
- * the key=value pair after that line. Otherwise, prepend the pair
- * to the top of the file. Here's the algorithm, as the C code
- * seems to be rather dense:
- *
- * if (value == NULL), then:
- * if val2 (parent): change line to key= or append line key=
- * if val1 (this) : delete line
- * else noop
- * else use this table:
- * val2
- * NULL value other
- * v NULL append line noop append line
- * a
- * l value noop noop noop
- * 1
- * other change line delete line change line
- *
- * No changes are ever made to the parent config file, only to the
- * specific file passed on the command line.
- *
- */
-void
-svSetValue(shvarFile *s, const char *key, const char *value)
-{
- char *newval = NULL, *val1 = NULL, *val2 = NULL;
- char *keyValue;
-
- g_assert(s);
- g_assert(key);
- /* value may be NULL */
-
- if (value) newval = escape(value);
- keyValue = g_strdup_printf("%s=%s", key, newval ? newval : "");
-
- val1 = svGetValue(s, key);
- if (val1 && newval && !strcmp(val1, newval)) goto bail;
- if (s->parent) val2 = svGetValue(s->parent, key);
-
- if (!newval || !newval[0]) {
- /* delete value somehow */
- if (val2) {
- /* change/append line to get key= */
- if (s->current) s->current->data = keyValue;
- else s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- } else if (val1) {
- /* delete line */
- s->lineList = g_list_remove_link(s->lineList, s->current);
- g_list_free_1(s->current);
- s->modified = 1;
- goto bail; /* do not need keyValue */
- }
- goto end;
- }
-
- if (!val1) {
- if (val2 && !strcmp(val2, newval)) goto end;
- /* append line */
- s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- goto end;
- }
-
- /* deal with a whole line of noops */
- if (val1 && !strcmp(val1, newval)) goto end;
-
- /* At this point, val1 && val1 != value */
- if (val2 && !strcmp(val2, newval)) {
- /* delete line */
- s->lineList = g_list_remove_link(s->lineList, s->current);
- g_list_free_1(s->current);
- s->modified = 1;
- goto bail; /* do not need keyValue */
- } else {
- /* change line */
- if (s->current) s->current->data = keyValue;
- else s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- }
-
-end:
- if (newval) free(newval);
- if (val1) free(val1);
- if (val2) free(val2);
- return;
-
-bail:
- if (keyValue) free (keyValue);
- goto end;
-}
-
-/* Write the current contents iff modified. Returns -1 on error
- * and 0 on success. Do not write if no values have been modified.
- * The mode argument is only used if creating the file, not if
- * re-writing an existing file, and is passed unchanged to the
- * open() syscall.
- */
-int
-svWriteFile(shvarFile *s, int mode)
-{
- FILE *f;
- int tmpfd;
-
- if (s->modified) {
- if (s->fd == -1)
- s->fd = open(s->fileName, O_WRONLY|O_CREAT, mode);
- if (s->fd == -1)
- return -1;
- if (ftruncate(s->fd, 0) < 0)
- return -1;
-
- tmpfd = dup(s->fd);
- f = fdopen(tmpfd, "w");
- fseek(f, 0, SEEK_SET);
- for (s->current = s->lineList; s->current; s->current = s->current->next) {
- char *line = s->current->data;
- fprintf(f, "%s\n", line);
- }
- fclose(f);
- }
-
- return 0;
-}
-
-
-/* Close the file descriptor (if open) and delete the shvarFile.
- * Returns -1 on error and 0 on success.
- */
-int
-svCloseFile(shvarFile *s)
-{
-
- g_assert(s);
-
- if (s->fd != -1) close(s->fd);
-
- g_free(s->arena);
- for (s->current = s->freeList; s->current; s->current = s->current->next) {
- g_free(s->current->data);
- }
- g_free(s->fileName);
- g_list_free(s->freeList);
- g_list_foreach (s->lineList, (GFunc) g_free, NULL);
- g_list_free(s->lineList); /* implicitly frees s->current */
- g_free(s);
- return 0;
-}
diff --git a/src/backends/shvar.h b/src/backends/shvar.h
deleted file mode 100644
index 00e1a8e59f..0000000000
--- a/src/backends/shvar.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * shvar.h
- *
- * Interface for non-destructively reading/writing files containing
- * only shell variable declarations and full-line comments.
- *
- * Includes explicit inheritance mechanism intended for use with
- * Red Hat Linux ifcfg-* files. There is no protection against
- * inheritance loops; they will generally cause stack overflows.
- * Furthermore, they are only intended for one level of inheritance;
- * the value setting algorithm assumes this.
- *
- * Copyright 1999 Red Hat, Inc.
- *
- * This 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#ifndef _SHVAR_H
-#define _SHVAR_H
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef struct _shvarFile shvarFile;
-struct _shvarFile {
- char *fileName; /* read-only */
- int fd; /* read-only */
- char *arena; /* ignore */
- GList *lineList; /* read-only */
- GList *freeList; /* ignore */
- GList *current; /* set implicitly or explicitly,
- points to element of lineList */
- shvarFile *parent; /* set explicitly */
- int modified; /* ignore */
-};
-
-
-/* Create the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svCreateFile(const char *name);
-
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(const char *name);
-
-/* Get the value associated with the key, and leave the current pointer
- * pointing at the line containing the value. The char* returned MUST
- * be freed by the caller.
- */
-char *
-svGetValue(shvarFile *s, const char *key);
-
-/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
- * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
- * return <def> otherwise
- */
-int
-svTrueValue(shvarFile *s, const char *key, int def);
-
-/* Set the variable <key> equal to the value <value>.
- * If <key> does not exist, and the <current> pointer is set, append
- * the key=value pair after that line. Otherwise, prepend the pair
- * to the top of the file.
- */
-void
-svSetValue(shvarFile *s, const char *key, const char *value);
-
-
-/* Write the current contents iff modified. Returns -1 on error
- * and 0 on success. Do not write if no values have been modified.
- * The mode argument is only used if creating the file, not if
- * re-writing an existing file, and is passed unchanged to the
- * open() syscall.
- */
-int
-svWriteFile(shvarFile *s, int mode);
-
-/* Close the file descriptor (if open) and delete the shvarFile.
- * Returns -1 on error and 0 on success.
- */
-int
-svCloseFile(shvarFile *s);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* ! _SHVAR_H */
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index 94c4a65c61..c4087e682b 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -747,9 +747,20 @@ nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
}
str = g_hash_table_lookup (device->options, "new_routers");
- if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
- addr->gateway = tmp_addr.s_addr;
- nm_info(" gateway %s", str);
+ if (str) {
+ char **routers = g_strsplit (str, " ", 0);
+ char **s;
+
+ for (s = routers; *s; s++) {
+ /* FIXME: how to handle multiple routers? */
+ if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
+ addr->gateway = tmp_addr.s_addr;
+ nm_info (" gateway %s", *s);
+ break;
+ } else
+ nm_warning ("Ignoring invalid gateway '%s'", *s);
+ }
+ g_strfreev (routers);
}
nm_ip4_config_take_address (ip4_config, addr);
@@ -800,27 +811,6 @@ nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
g_strfreev (searches);
}
- str = g_hash_table_lookup (device->options, "new_nis_domain");
- if (str) {
- nm_ip4_config_set_nis_domain (ip4_config, str);
- nm_info (" nis domain '%s'", str);
- }
-
- str = g_hash_table_lookup (device->options, "new_nis_servers");
- if (str) {
- char **searches = g_strsplit (str, " ", 0);
- char **s;
-
- for (s = searches; *s; s++) {
- if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
- nm_ip4_config_add_nis_server (ip4_config, tmp_addr.s_addr);
- nm_info (" nis server '%s'", *s);
- } else
- nm_warning ("Ignoring invalid nis server '%s'", *s);
- }
- g_strfreev (searches);
- }
-
str = g_hash_table_lookup (device->options, "new_static_routes");
if (str) {
char **searches = g_strsplit (str, " ", 0);
@@ -894,7 +884,7 @@ copy_dhcp4_config_option (gpointer key,
char *tmp_key = NULL;
const char **p;
static const char *filter_options[] = {
- "interface", "pid", "reason", NULL
+ "interface", "pid", "reason", "dhcp_message_type", NULL
};
/* Filter out stuff that's not actually new DHCP options */
diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.c b/src/dnsmasq-manager/nm-dnsmasq-manager.c
index 7ae4ef2224..848507f92e 100644
--- a/src/dnsmasq-manager/nm-dnsmasq-manager.c
+++ b/src/dnsmasq-manager/nm-dnsmasq-manager.c
@@ -236,6 +236,7 @@ create_dm_cmd_line (const char *iface,
const NMSettingIP4Address *tmp;
struct in_addr addr;
char buf[INET_ADDRSTRLEN + 1];
+ char localaddr[INET_ADDRSTRLEN + 1];
dm_binary = nm_find_dnsmasq ();
if (!dm_binary) {
@@ -259,12 +260,12 @@ create_dm_cmd_line (const char *iface,
s = g_string_new ("--listen-address=");
addr.s_addr = tmp->address;
- if (!inet_ntop (AF_INET, &addr, &buf[0], INET_ADDRSTRLEN)) {
+ if (!inet_ntop (AF_INET, &addr, &localaddr[0], INET_ADDRSTRLEN)) {
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
goto error;
}
- g_string_append (s, buf);
+ g_string_append (s, localaddr);
nm_cmd_line_add_string (cmd, s->str);
g_string_free (s, TRUE);
@@ -294,7 +295,11 @@ create_dm_cmd_line (const char *iface,
nm_cmd_line_add_string (cmd, s->str);
g_string_free (s, TRUE);
- nm_cmd_line_add_string (cmd, "--dhcp-option=option:router,0.0.0.0");
+ s = g_string_new ("--dhcp-option=option:router,");
+ g_string_append (s, localaddr);
+ nm_cmd_line_add_string (cmd, s->str);
+ g_string_free (s, TRUE);
+
nm_cmd_line_add_string (cmd, "--dhcp-lease-max=50");
s = g_string_new ("--pid-file=");
diff --git a/src/named-manager/nm-named-manager.c b/src/named-manager/nm-named-manager.c
index 0162ea9657..4fc42c023e 100644
--- a/src/named-manager/nm-named-manager.c
+++ b/src/named-manager/nm-named-manager.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
/*
* Copyright (C) 2004 - 2008 Red Hat, Inc.
*
@@ -26,6 +28,8 @@
#include <stdlib.h>
#include <errno.h>
#include <arpa/inet.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <glib.h>
#include <glib/gi18n.h>
@@ -85,50 +89,6 @@ nm_named_manager_error_quark (void)
return quark;
}
-static char *
-compute_nameservers (NMIP4Config *config)
-{
- int i, num;
- GString *str = NULL;
-
- g_return_val_if_fail (config != NULL, NULL);
-
- num = nm_ip4_config_get_num_nameservers (config);
- if (num == 0)
- return NULL;
-
- str = g_string_new ("");
- for (i = 0; i < num; i++) {
- #define ADDR_BUF_LEN 50
- struct in_addr addr;
- char *buf;
-
- addr.s_addr = nm_ip4_config_get_nameserver (config, i);
- buf = g_malloc0 (ADDR_BUF_LEN);
- if (!buf)
- continue;
-
- if (!inet_ntop (AF_INET, &addr, buf, ADDR_BUF_LEN))
- nm_warning ("%s: error converting IP4 address 0x%X",
- __func__, ntohl (addr.s_addr));
-
- if (i == 3) {
- g_string_append (str, "\n# ");
- g_string_append (str, _("NOTE: the glibc resolver does not support more than 3 nameservers."));
- g_string_append (str, "\n# ");
- g_string_append (str, _("The nameservers listed below may not be recognized."));
- g_string_append_c (str, '\n');
- }
-
- g_string_append (str, "nameserver ");
- g_string_append (str, buf);
- g_string_append_c (str, '\n');
- g_free (buf);
- }
-
- return g_string_free (str, FALSE);
-}
-
static void
merge_one_ip4_config (NMIP4Config *dst, NMIP4Config *src)
{
@@ -155,49 +115,221 @@ merge_one_ip4_config (NMIP4Config *dst, NMIP4Config *src)
}
}
+#if defined(TARGET_SUSE)
+/**********************************/
+/* SUSE */
+
+static void
+netconfig_child_setup (gpointer user_data G_GNUC_UNUSED)
+{
+ pid_t pid = getpid ();
+ setpgid (pid, pid);
+}
+
+static gint
+run_netconfig (GError **error)
+{
+ GPtrArray *argv;
+ gint stdin_fd;
+
+ argv = g_ptr_array_new ();
+ g_ptr_array_add (argv, "/sbin/netconfig");
+ g_ptr_array_add (argv, "modify");
+ g_ptr_array_add (argv, "--service");
+ g_ptr_array_add (argv, "NetworkManager");
+ g_ptr_array_add (argv, NULL);
+
+ if (!g_spawn_async_with_pipes (NULL, (char **) argv->pdata, NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD,
+ netconfig_child_setup,
+ NULL, NULL, &stdin_fd,
+ NULL, NULL, error)) {
+ stdin_fd = -1;
+ }
+
+ g_ptr_array_free (argv, TRUE);
+
+ return stdin_fd;
+}
+
+static void
+write_to_netconfig (gint fd, const char *key, const char *value)
+{
+ char *str;
+ int x;
+
+ str = g_strdup_printf ("%s='%s'\n", key, value);
+ x = write (fd, str, strlen (str));
+ g_free (str);
+}
+
static gboolean
-rewrite_resolv_conf (NMNamedManager *mgr, GError **error)
+update_resolv_conf (const char *iface,
+ const char *domain,
+ char **searches,
+ char **nameservers,
+ GError **error)
{
- NMNamedManagerPrivate *priv;
- const char *tmp_resolv_conf = RESOLV_CONF ".tmp";
- char *searches = NULL, *domain = NULL;
- char *nameservers = NULL;
- guint32 num_domains, num_searches, i;
- NMIP4Config *composite;
- GSList *iter;
- FILE *f;
- GString *str;
+ gint fd;
+ char *str;
- g_return_val_if_fail (error != NULL, FALSE);
- g_return_val_if_fail (*error == NULL, FALSE);
+ fd = run_netconfig (error);
+ if (fd < 0)
+ return FALSE;
- priv = NM_NAMED_MANAGER_GET_PRIVATE (mgr);
+ write_to_netconfig (fd, "INTERFACE", iface);
- /* If the sysadmin disabled modifying resolv.conf, exit silently */
- if (!nm_system_should_modify_resolv_conf ()) {
- nm_info ("DHCP returned name servers but system has disabled dynamic modification!");
- return TRUE;
+ if (searches) {
+ str = g_strjoinv (" ", searches);
+ write_to_netconfig (fd, "DNSDOMAIN", str);
+ g_free (str);
}
+ if (nameservers) {
+ str = g_strjoinv (" ", nameservers);
+ write_to_netconfig (fd, "DNSSERVERS", str);
+ g_free (str);
+ }
+
+ close (fd);
+
+ return TRUE;
+}
+
+#else
+/**********************************/
+/* Generic */
+
+static gboolean
+update_resolv_conf (const char *iface,
+ const char *domain,
+ char **searches,
+ char **nameservers,
+ GError **error)
+{
+ const char *tmp_resolv_conf = RESOLV_CONF ".tmp";
+ char *domain_str = NULL;
+ char *searches_str = NULL;
+ char *nameservers_str = NULL;
+ FILE *f;
+
if ((f = fopen (tmp_resolv_conf, "w")) == NULL) {
g_set_error (error,
- NM_NAMED_MANAGER_ERROR,
- NM_NAMED_MANAGER_ERROR_SYSTEM,
- "Could not open " RESOLV_CONF ": %s\n",
- g_strerror (errno));
+ NM_NAMED_MANAGER_ERROR,
+ NM_NAMED_MANAGER_ERROR_SYSTEM,
+ "Could not open " RESOLV_CONF ": %s\n",
+ g_strerror (errno));
return FALSE;
}
if (fprintf (f, "%s","# generated by NetworkManager, do not edit!\n\n") < 0) {
g_set_error (error,
- NM_NAMED_MANAGER_ERROR,
- NM_NAMED_MANAGER_ERROR_SYSTEM,
- "Could not write " RESOLV_CONF ": %s\n",
- g_strerror (errno));
+ NM_NAMED_MANAGER_ERROR,
+ NM_NAMED_MANAGER_ERROR_SYSTEM,
+ "Could not write " RESOLV_CONF ": %s\n",
+ g_strerror (errno));
fclose (f);
return FALSE;
}
+ if (domain)
+ domain_str = g_strconcat ("domain ", domain, "\n\n", NULL);
+
+ if (searches) {
+ char *tmp_str;
+
+ tmp_str = g_strjoinv (" ", searches);
+ searches_str = g_strconcat ("search ", tmp_str, "\n\n", NULL);
+ g_free (tmp_str);
+ }
+
+ if (nameservers) {
+ GString *str;
+ int num;
+ int i;
+
+ str = g_string_new ("");
+ num = g_strv_length (nameservers);
+
+ for (i = 0; i < num; i++) {
+ if (i == 3) {
+ g_string_append (str, "\n# ");
+ g_string_append (str, _("NOTE: the glibc resolver does not support more than 3 nameservers."));
+ g_string_append (str, "\n# ");
+ g_string_append (str, _("The nameservers listed below may not be recognized."));
+ g_string_append_c (str, '\n');
+ }
+
+ g_string_append (str, "nameserver ");
+ g_string_append (str, nameservers[i]);
+ g_string_append_c (str, '\n');
+ }
+
+ nameservers_str = g_string_free (str, FALSE);
+ }
+
+ if (fprintf (f, "%s%s%s\n",
+ domain_str ? domain_str : "",
+ searches_str ? searches_str : "",
+ nameservers_str ? nameservers_str : "") < 0) {
+ g_set_error (error,
+ NM_NAMED_MANAGER_ERROR,
+ NM_NAMED_MANAGER_ERROR_SYSTEM,
+ "Could not write to " RESOLV_CONF ": %s\n",
+ g_strerror (errno));
+ }
+
+ g_free (domain_str);
+ g_free (searches_str);
+ g_free (nameservers_str);
+
+ if (fclose (f) < 0) {
+ if (*error == NULL) {
+ g_set_error (error,
+ NM_NAMED_MANAGER_ERROR,
+ NM_NAMED_MANAGER_ERROR_SYSTEM,
+ "Could not close " RESOLV_CONF ": %s\n",
+ g_strerror (errno));
+ }
+ }
+
+ if (*error == NULL) {
+ if (rename (tmp_resolv_conf, RESOLV_CONF) < 0) {
+ g_set_error (error,
+ NM_NAMED_MANAGER_ERROR,
+ NM_NAMED_MANAGER_ERROR_SYSTEM,
+ "Could not replace " RESOLV_CONF ": %s\n",
+ g_strerror (errno));
+ }
+ }
+
+ return *error ? FALSE : TRUE;
+}
+#endif
+
+#define ADDR_BUF_LEN 50
+
+static gboolean
+rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
+{
+ NMNamedManagerPrivate *priv;
+ NMIP4Config *composite;
+ GSList *iter;
+ GPtrArray *array;
+ const char *domain = NULL;
+ char **searches = NULL;
+ char **nameservers = NULL;
+ int num_domains;
+ int num_searches;
+ int num_nameservers;
+ int i;
+ gboolean success;
+
+ g_return_val_if_fail (error != NULL, FALSE);
+ g_return_val_if_fail (*error == NULL, FALSE);
+
+ priv = NM_NAMED_MANAGER_GET_PRIVATE (mgr);
+
/* Construct the composite config from all the currently active IP4Configs */
composite = nm_ip4_config_new ();
@@ -239,79 +371,65 @@ rewrite_resolv_conf (NMNamedManager *mgr, GError **error)
num_domains = nm_ip4_config_get_num_domains (composite);
num_searches = nm_ip4_config_get_num_searches (composite);
+ /* Domain */
+ if (num_domains > 0)
+ domain = nm_ip4_config_get_domain (composite, 0);
+
+ /* Searches */
if ((num_searches == 0) && (num_domains > 0)) {
- str = g_string_new ("search");
- for (i = 0; i < num_domains; i++) {
- g_string_append_c (str, ' ');
- g_string_append (str, nm_ip4_config_get_domain (composite, i));
- }
+ array = g_ptr_array_sized_new (num_domains + 1);
+ for (i = 0; i < num_domains; i++)
+ g_ptr_array_add (array, g_strdup (nm_ip4_config_get_domain (composite, i)));
- g_string_append (str, "\n\n");
- searches = g_string_free (str, FALSE);
+ g_ptr_array_add (array, NULL);
+ searches = (char **) g_ptr_array_free (array, FALSE);
} else if (num_searches > 0) {
- str = g_string_new ("search");
- for (i = 0; i < num_searches; i++) {
- g_string_append_c (str, ' ');
- g_string_append (str, nm_ip4_config_get_search (composite, i));
- }
+ array = g_ptr_array_sized_new (num_searches + 1);
+ for (i = 0; i < num_searches; i++)
+ g_ptr_array_add (array, g_strdup (nm_ip4_config_get_search (composite, i)));
- g_string_append (str, "\n\n");
- searches = g_string_free (str, FALSE);
+ g_ptr_array_add (array, NULL);
+ searches = (char **) g_ptr_array_free (array, FALSE);
}
- /* Compute resolv.conf domain */
- if (num_domains > 0) {
- str = g_string_new ("domain ");
- g_string_append (str, nm_ip4_config_get_domain (composite, 0));
- g_string_append (str, "\n\n");
-
- domain = g_string_free (str, FALSE);
- }
+ /* Name servers */
+ num_nameservers = nm_ip4_config_get_num_nameservers (composite);
+ if (num_nameservers > 0) {
+ array = g_ptr_array_sized_new (num_nameservers + 1);
+ for (i = 0; i < num_nameservers; i++) {
+ struct in_addr addr;
+ char *buf;
+
+ addr.s_addr = nm_ip4_config_get_nameserver (composite, i);
+ buf = g_malloc0 (ADDR_BUF_LEN);
+ if (!buf)
+ continue;
+
+ if (inet_ntop (AF_INET, &addr, buf, ADDR_BUF_LEN))
+ g_ptr_array_add (array, buf);
+ else
+ nm_warning ("%s: error converting IP4 address 0x%X",
+ __func__, ntohl (addr.s_addr));
+ }
- /* Using glibc resolver */
- nameservers = compute_nameservers (composite);
- if (fprintf (f, "%s%s%s\n",
- domain ? domain : "",
- searches ? searches : "",
- nameservers ? nameservers : "") < 0) {
- g_set_error (error,
- NM_NAMED_MANAGER_ERROR,
- NM_NAMED_MANAGER_ERROR_SYSTEM,
- "Could not write to " RESOLV_CONF ": %s\n",
- g_strerror (errno));
+ g_ptr_array_add (array, NULL);
+ nameservers = (char **) g_ptr_array_free (array, FALSE);
}
- g_free (nameservers);
- if (fclose (f) < 0) {
- if (*error == NULL) {
- g_set_error (error,
- NM_NAMED_MANAGER_ERROR,
- NM_NAMED_MANAGER_ERROR_SYSTEM,
- "Could not close " RESOLV_CONF ": %s\n",
- g_strerror (errno));
- }
- }
+ success = update_resolv_conf (iface, domain, searches, nameservers, error);
- g_free (domain);
- g_free (searches);
+ g_strfreev (searches);
+ g_strfreev (nameservers);
- if (*error == NULL) {
- if (rename (tmp_resolv_conf, RESOLV_CONF) < 0) {
- g_set_error (error,
- NM_NAMED_MANAGER_ERROR,
- NM_NAMED_MANAGER_ERROR_SYSTEM,
- "Could not replace " RESOLV_CONF ": %s\n",
- g_strerror (errno));
- } else {
- nm_system_update_dns ();
- }
- }
+ if (success)
+ nm_system_update_dns ();
- return *error ? FALSE : TRUE;
+ return success;
}
gboolean
nm_named_manager_add_ip4_config (NMNamedManager *mgr,
+ const char *iface,
NMIP4Config *config,
NMNamedIPConfigType cfg_type)
{
@@ -319,6 +437,7 @@ nm_named_manager_add_ip4_config (NMNamedManager *mgr,
GError *error = NULL;
g_return_val_if_fail (mgr != NULL, FALSE);
+ g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
priv = NM_NAMED_MANAGER_GET_PRIVATE (mgr);
@@ -338,7 +457,7 @@ nm_named_manager_add_ip4_config (NMNamedManager *mgr,
if (!g_slist_find (priv->configs, config))
priv->configs = g_slist_append (priv->configs, g_object_ref (config));
- if (!rewrite_resolv_conf (mgr, &error)) {
+ if (!rewrite_resolv_conf (mgr, iface, &error)) {
nm_warning ("Could not commit DNS changes. Error: '%s'", error ? error->message : "(none)");
g_error_free (error);
}
@@ -347,12 +466,15 @@ nm_named_manager_add_ip4_config (NMNamedManager *mgr,
}
gboolean
-nm_named_manager_remove_ip4_config (NMNamedManager *mgr, NMIP4Config *config)
+nm_named_manager_remove_ip4_config (NMNamedManager *mgr,
+ const char *iface,
+ NMIP4Config *config)
{
NMNamedManagerPrivate *priv;
GError *error = NULL;
g_return_val_if_fail (mgr != NULL, FALSE);
+ g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
priv = NM_NAMED_MANAGER_GET_PRIVATE (mgr);
@@ -371,7 +493,7 @@ nm_named_manager_remove_ip4_config (NMNamedManager *mgr, NMIP4Config *config)
g_object_unref (config);
- if (!rewrite_resolv_conf (mgr, &error)) {
+ if (!rewrite_resolv_conf (mgr, iface, &error)) {
nm_warning ("Could not commit DNS changes. Error: '%s'", error ? error->message : "(none)");
if (error)
g_error_free (error);
diff --git a/src/named-manager/nm-named-manager.h b/src/named-manager/nm-named-manager.h
index 33f4dec181..00787a89bf 100644
--- a/src/named-manager/nm-named-manager.h
+++ b/src/named-manager/nm-named-manager.h
@@ -68,10 +68,13 @@ GType nm_named_manager_get_type (void);
NMNamedManager * nm_named_manager_get (void);
gboolean nm_named_manager_add_ip4_config (NMNamedManager *mgr,
+ const char *iface,
NMIP4Config *config,
NMNamedIPConfigType cfg_type);
-gboolean nm_named_manager_remove_ip4_config (NMNamedManager *mgr, NMIP4Config *config);
+gboolean nm_named_manager_remove_ip4_config (NMNamedManager *mgr,
+ const char *iface,
+ NMIP4Config *config);
G_END_DECLS
diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c
index 4df9f887e9..071511792e 100644
--- a/src/nm-activation-request.c
+++ b/src/nm-activation-request.c
@@ -20,6 +20,9 @@
*/
#include <string.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>
#include <dbus/dbus-glib.h>
#include "nm-activation-request.h"
@@ -49,6 +52,10 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+typedef struct {
+ char *table;
+ char *rule;
+} ShareRule;
typedef struct {
gboolean disposed;
@@ -63,6 +70,7 @@ typedef struct {
NMActiveConnectionState state;
gboolean is_default;
gboolean shared;
+ GSList *share_rules;
char *ac_path;
} NMActRequestPrivate;
@@ -206,12 +214,33 @@ dispose (GObject *object)
cleanup_secrets_dbus_call (NM_ACT_REQUEST (object));
+ /* Clear any share rules */
+ nm_act_request_set_shared (NM_ACT_REQUEST (object), FALSE);
+
g_object_unref (priv->connection);
G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object);
}
static void
+clear_share_rules (NMActRequest *req)
+{
+ NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req);
+ GSList *iter;
+
+ for (iter = priv->share_rules; iter; iter = g_slist_next (iter)) {
+ ShareRule *rule = (ShareRule *) iter->data;
+
+ g_free (rule->table);
+ g_free (rule->rule);
+ g_free (rule);
+ }
+
+ g_slist_free (priv->share_rules);
+ priv->share_rules = NULL;
+}
+
+static void
finalize (GObject *object)
{
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
@@ -219,6 +248,8 @@ finalize (GObject *object)
g_free (priv->specific_object);
g_free (priv->ac_path);
+ clear_share_rules (NM_ACT_REQUEST (object));
+
G_OBJECT_CLASS (nm_act_request_parent_class)->finalize (object);
}
@@ -646,12 +677,69 @@ nm_act_request_get_default (NMActRequest *req)
return NM_ACT_REQUEST_GET_PRIVATE (req)->is_default;
}
+static void
+share_child_setup (gpointer user_data G_GNUC_UNUSED)
+{
+ /* We are in the child process at this point */
+ pid_t pid = getpid ();
+ setpgid (pid, pid);
+}
+
void
nm_act_request_set_shared (NMActRequest *req, gboolean shared)
{
+ NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req);
+ GSList *list, *iter;
+
g_return_if_fail (NM_IS_ACT_REQUEST (req));
NM_ACT_REQUEST_GET_PRIVATE (req)->shared = shared;
+
+ /* Tear the rules down in reverse order when sharing is stopped */
+ list = g_slist_copy (priv->share_rules);
+ if (!shared)
+ list = g_slist_reverse (list);
+
+ /* Send the rules to iptables */
+ for (iter = list; iter; iter = g_slist_next (iter)) {
+ ShareRule *rule = (ShareRule *) iter->data;
+ char *envp[1] = { NULL };
+ char **argv;
+ char *cmd;
+ int status;
+ GError *error = NULL;
+
+ if (shared)
+ cmd = g_strdup_printf ("/sbin/iptables --table %s --insert %s", rule->table, rule->rule);
+ else
+ cmd = g_strdup_printf ("/sbin/iptables --table %s --delete %s", rule->table, rule->rule);
+
+ argv = g_strsplit (cmd, " ", 0);
+ if (!argv || !argv[0]) {
+ continue;
+ g_free (cmd);
+ }
+
+ nm_info ("Executing: %s", cmd);
+ g_free (cmd);
+
+ if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+ share_child_setup, NULL, NULL, NULL, &status, &error)) {
+ nm_info ("Error executing command: (%d) %s",
+ error ? error->code : 0, (error && error->message) ? error->message : "unknown");
+ if (error)
+ g_error_free (error);
+ } else if (WEXITSTATUS (status))
+ nm_info ("** Command returned exit status %d.", WEXITSTATUS (status));
+
+ g_strfreev (argv);
+ }
+
+ g_slist_free (list);
+
+ /* Clear the share rule list when sharing is stopped */
+ if (!shared)
+ clear_share_rules (req);
}
gboolean
@@ -662,6 +750,24 @@ nm_act_request_get_shared (NMActRequest *req)
return NM_ACT_REQUEST_GET_PRIVATE (req)->shared;
}
+void
+nm_act_request_add_share_rule (NMActRequest *req,
+ const char *table,
+ const char *table_rule)
+{
+ NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req);
+ ShareRule *rule;
+
+ g_return_if_fail (NM_IS_ACT_REQUEST (req));
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (table_rule != NULL);
+
+ rule = g_malloc0 (sizeof (ShareRule));
+ rule->table = g_strdup (table);
+ rule->rule = g_strdup (table_rule);
+ priv->share_rules = g_slist_append (priv->share_rules, rule);
+}
+
GObject *
nm_act_request_get_device (NMActRequest *req)
{
diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h
index ff26cc4e35..44dc297f8b 100644
--- a/src/nm-activation-request.h
+++ b/src/nm-activation-request.h
@@ -44,7 +44,8 @@ typedef enum {
SECRETS_CALLER_WIFI,
SECRETS_CALLER_GSM,
SECRETS_CALLER_CDMA,
- SECRETS_CALLER_PPP
+ SECRETS_CALLER_PPP,
+ SECRETS_CALLER_HSO_GSM
} RequestSecretsCaller;
typedef struct {
@@ -94,6 +95,10 @@ gboolean nm_act_request_get_shared (NMActRequest *req);
void nm_act_request_set_shared (NMActRequest *req, gboolean shared);
+void nm_act_request_add_share_rule (NMActRequest *req,
+ const char *table,
+ const char *rule);
+
GObject * nm_act_request_get_device (NMActRequest *req);
#endif /* NM_ACTIVATION_REQUEST_H */
diff --git a/src/nm-cdma-device.c b/src/nm-cdma-device.c
index 9a2fd197b0..31023e17d1 100644
--- a/src/nm-cdma-device.c
+++ b/src/nm-cdma-device.c
@@ -513,7 +513,7 @@ nm_cdma_device_class_init (NMCdmaDeviceClass *klass)
"Monitoring interface",
"Monitoring interface",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT));
/* Signals */
signals[PROPERTIES_CHANGED] =
diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c
index a07f9573c2..7db4063320 100644
--- a/src/nm-device-ethernet.c
+++ b/src/nm-device-ethernet.c
@@ -291,7 +291,7 @@ constructor (GType type,
dev);
if (!nm_netlink_monitor_request_status (monitor, &error)) {
- nm_warning ("couldn't request carrier state: %s", error->message);
+ nm_warning ("couldn't request carrier state: %s", error ? error->message : "unknown");
g_error_free (error);
}
diff --git a/src/nm-device-interface.c b/src/nm-device-interface.c
index 0ae1b974a5..c3d578c2e8 100644
--- a/src/nm-device-interface.c
+++ b/src/nm-device-interface.c
@@ -98,10 +98,10 @@ nm_device_interface_init (gpointer g_iface)
g_object_interface_install_property
(g_iface,
- g_param_spec_object (NM_DEVICE_INTERFACE_DHCP4_CONFIG,
+ g_param_spec_boxed (NM_DEVICE_INTERFACE_DHCP4_CONFIG,
"DHCP4 Config",
"DHCP4 Config",
- G_TYPE_OBJECT,
+ DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READWRITE));
g_object_interface_install_property
diff --git a/src/nm-device.c b/src/nm-device.c
index a97986cd08..37cb500496 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <arpa/inet.h>
+#include <fcntl.h>
#include "nm-device-interface.h"
#include "nm-device.h"
@@ -1199,6 +1200,140 @@ nm_device_activate_schedule_stage4_ip_config_timeout (NMDevice *self)
nm_device_get_iface (self));
}
+static void
+share_child_setup (gpointer user_data G_GNUC_UNUSED)
+{
+ /* We are in the child process at this point */
+ pid_t pid = getpid ();
+ setpgid (pid, pid);
+}
+
+static gboolean
+share_init (void)
+{
+ int fd, count, status;
+ char *modules[] = { "ip_tables", "iptable_nat", "nf_nat_ftp", "nf_nat_irc",
+ "nf_nat_sip", "nf_nat_tftp", "nf_nat_pptp", "nf_nat_h323",
+ NULL };
+ char **iter;
+
+ fd = open ("/proc/sys/net/ipv4/ip_forward", O_WRONLY | O_TRUNC);
+ if (fd) {
+ count = write (fd, "1\n", 2);
+ if (count != 2) {
+ nm_warning ("%s: Error starting IP forwarding: (%d) %s",
+ __func__, errno, strerror (errno));
+ return FALSE;
+ }
+ close (fd);
+ }
+
+ fd = open ("/proc/sys/net/ipv4/ip_dynaddr", O_WRONLY | O_TRUNC);
+ if (fd) {
+ count = write (fd, "1\n", 2);
+ if (count != 2) {
+ nm_warning ("%s: Error starting IP forwarding: (%d) %s",
+ __func__, errno, strerror (errno));
+ }
+ close (fd);
+ }
+
+ for (iter = modules; *iter; iter++) {
+ char *argv[3] = { "/sbin/modprobe", *iter, NULL };
+ char *envp[1] = { NULL };
+ GError *error = NULL;
+
+ if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+ share_child_setup, NULL, NULL, NULL, &status, &error)) {
+ nm_info ("%s: Error loading NAT module %s: (%d) %s",
+ __func__, *iter, error ? error->code : 0,
+ (error && error->message) ? error->message : "unknown");
+ if (error)
+ g_error_free (error);
+ }
+ }
+
+ return TRUE;
+}
+
+static void
+add_share_rule (NMActRequest *req, const char *table, const char *fmt, ...)
+{
+ va_list args;
+ char *cmd;
+
+ va_start (args, fmt);
+ cmd = g_strdup_vprintf (fmt, args);
+ va_end (args);
+
+ nm_act_request_add_share_rule (req, table, cmd);
+ g_free (cmd);
+}
+
+static gboolean
+start_sharing (NMDevice *self)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ NMActRequest *req;
+ GError *error = NULL;
+ char str_addr[INET_ADDRSTRLEN + 1];
+ char str_mask[INET_ADDRSTRLEN + 1];
+ guint32 netmask, network;
+ NMIP4Config *ip4_config;
+ const NMSettingIP4Address *ip4_addr;
+ const char *iface;
+
+ iface = nm_device_get_ip_iface (self);
+ if (!iface)
+ iface = nm_device_get_iface (self);
+
+ ip4_config = nm_device_get_ip4_config (self);
+ if (!ip4_config)
+ return FALSE;
+
+ ip4_addr = nm_ip4_config_get_address (ip4_config, 0);
+ if (!ip4_addr || !ip4_addr->address)
+ return FALSE;
+
+ netmask = nm_utils_ip4_prefix_to_netmask (ip4_addr->prefix);
+ if (!inet_ntop (AF_INET, &netmask, str_mask, sizeof (str_mask)))
+ return FALSE;
+
+ network = ip4_addr->address & netmask;
+ if (!inet_ntop (AF_INET, &network, str_addr, sizeof (str_addr)))
+ return FALSE;
+
+ if (!share_init ())
+ return FALSE;
+
+ req = nm_device_get_act_request (self);
+ g_assert (req);
+
+ add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 53 --jump ACCEPT", iface);
+ add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 53 --jump ACCEPT", iface);
+ add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 67 --jump ACCEPT", iface);
+ add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 67 --jump ACCEPT", iface);
+ add_share_rule (req, "filter", "FORWARD --in-interface %s --jump REJECT", iface);
+ add_share_rule (req, "filter", "FORWARD --out-interface %s --jump REJECT", iface);
+ add_share_rule (req, "filter", "FORWARD --in-interface %s --out-interface %s --jump ACCEPT", iface, iface);
+ add_share_rule (req, "filter", "FORWARD --source %s/%s --in-interface %s --jump ACCEPT", str_addr, str_mask, iface);
+ add_share_rule (req, "filter", "FORWARD --destination %s/%s --out-interface %s --match state --state ESTABLISHED,RELATED --jump ACCEPT", str_addr, str_mask, iface);
+ add_share_rule (req, "nat", "POSTROUTING --source %s/%s --destination ! %s/%s --jump MASQUERADE", str_addr, str_mask, str_addr, str_mask);
+
+ nm_act_request_set_shared (req, TRUE);
+
+ if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, ip4_config, &error)) {
+ nm_warning ("(%s): failed to start dnsmasq: %s", iface, error->message);
+ g_error_free (error);
+ nm_act_request_set_shared (req, FALSE);
+ return FALSE;
+ }
+
+ priv->dnsmasq_state_id = g_signal_connect (priv->dnsmasq_manager, "state-changed",
+ G_CALLBACK (dnsmasq_state_changed_cb),
+ self);
+ return TRUE;
+}
/*
* nm_device_activate_stage5_ip_config_commit
@@ -1237,18 +1372,11 @@ nm_device_activate_stage5_ip_config_commit (gpointer user_data)
connection = nm_act_request_get_connection (nm_device_get_act_request (self));
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
if (s_ip4 && !strcmp (s_ip4->method, "shared")) {
- GError *error = NULL;
-
- if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, ip4_config, &error)) {
- nm_warning ("(%s): failed to start dnsmasq: %s", iface, error->message);
- g_error_free (error);
+ if (!start_sharing (self)) {
+ nm_warning ("Activation (%s) Stage 5 of 5 (IP Configure Commit) start sharing failed.", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
goto out;
}
-
- priv->dnsmasq_state_id = g_signal_connect (priv->dnsmasq_manager, "state-changed",
- G_CALLBACK (dnsmasq_state_changed_cb),
- self);
}
nm_device_state_changed (self, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE);
@@ -1329,8 +1457,6 @@ nm_device_deactivate_quickly (NMDevice *self)
priv = NM_DEVICE_GET_PRIVATE (self);
- nm_system_shutdown_nis ();
-
/* Break the activation chain */
if (priv->act_source_id) {
g_source_remove (priv->act_source_id);
@@ -1363,13 +1489,13 @@ nm_device_deactivate_quickly (NMDevice *self)
aipd_cleanup (self);
- /* Tear down an existing activation request */
- clear_act_request (self);
-
/* Call device type-specific deactivation */
if (NM_DEVICE_GET_CLASS (self)->deactivate_quickly)
NM_DEVICE_GET_CLASS (self)->deactivate_quickly (self);
+ /* Tear down an existing activation request */
+ clear_act_request (self);
+
return TRUE;
}
@@ -1736,13 +1862,14 @@ nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config, NMDeviceStateReas
g_return_val_if_fail (reason != NULL, FALSE);
priv = NM_DEVICE_GET_PRIVATE (self);
+ ip_iface = nm_device_get_ip_iface (self);
if (priv->ip4_config) {
NMNamedManager *named_mgr;
/* Remove any previous IP4 Config from the named manager */
named_mgr = nm_named_manager_get ();
- nm_named_manager_remove_ip4_config (named_mgr, priv->ip4_config);
+ nm_named_manager_remove_ip4_config (named_mgr, ip_iface, priv->ip4_config);
g_object_unref (named_mgr);
g_object_unref (priv->ip4_config);
@@ -1754,14 +1881,9 @@ nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config, NMDeviceStateReas
priv->ip4_config = g_object_ref (config);
- ip_iface = nm_device_get_ip_iface (self);
-
success = nm_system_device_set_from_ip4_config (ip_iface, config);
- if (success) {
+ if (success)
nm_device_update_ip4_address (self);
- nm_system_set_hostname (config);
- nm_system_activate_nis (config);
- }
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_IP4_CONFIG);
@@ -2062,9 +2184,9 @@ get_property (GObject *object, guint prop_id,
case NM_DEVICE_INTERFACE_PROP_DHCP4_CONFIG:
if ( ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
&& nm_device_get_use_dhcp (self))
- g_value_set_object (value, priv->dhcp4_config);
+ g_value_set_boxed (value, nm_dhcp4_config_get_dbus_path (priv->dhcp4_config));
else
- g_value_set_object (value, NULL);
+ g_value_set_boxed (value, "/");
break;
case NM_DEVICE_INTERFACE_PROP_STATE:
g_value_set_uint (value, priv->state);
diff --git a/src/nm-device.h b/src/nm-device.h
index 2c234f0455..6a04d596d4 100644
--- a/src/nm-device.h
+++ b/src/nm-device.h
@@ -60,8 +60,6 @@ struct _NMDevice
NMDevicePrivate *priv;
};
-struct NMData;
-
struct _NMDeviceClass
{
GObjectClass parent;
diff --git a/src/nm-dhcp4-config.c b/src/nm-dhcp4-config.c
index 334a1b0e57..2d5e23c975 100644
--- a/src/nm-dhcp4-config.c
+++ b/src/nm-dhcp4-config.c
@@ -105,6 +105,14 @@ nm_dhcp4_config_get_option (NMDHCP4Config *self, const char *key)
return value ? g_value_get_string (value) : NULL;
}
+const char *
+nm_dhcp4_config_get_dbus_path (NMDHCP4Config *self)
+{
+ g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);
+
+ return NM_DHCP4_CONFIG_GET_PRIVATE (self)->dbus_path;
+}
+
static void
nm_gvalue_destroy (gpointer data)
{
diff --git a/src/nm-dhcp4-config.h b/src/nm-dhcp4-config.h
index 8e6cb03013..dbe716a5cf 100644
--- a/src/nm-dhcp4-config.h
+++ b/src/nm-dhcp4-config.h
@@ -51,6 +51,8 @@ GType nm_dhcp4_config_get_type (void);
NMDHCP4Config *nm_dhcp4_config_new (void);
+const char *nm_dhcp4_config_get_dbus_path (NMDHCP4Config *config);
+
void nm_dhcp4_config_add_option (NMDHCP4Config *config,
const char *key,
const char *option);
diff --git a/src/nm-gsm-device.c b/src/nm-gsm-device.c
index df8471fd6a..284597c2b8 100644
--- a/src/nm-gsm-device.c
+++ b/src/nm-gsm-device.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
#include <stdio.h>
#include <string.h>
@@ -74,13 +74,14 @@ modem_wait_for_reply (NMGsmDevice *self,
guint timeout,
char **responses,
char **terminators,
- NMSerialWaitForReplyFn callback)
+ NMSerialWaitForReplyFn callback,
+ gpointer user_data)
{
NMSerialDevice *serial = NM_SERIAL_DEVICE (self);
guint id = 0;
if (nm_serial_device_send_command_string (serial, command))
- id = nm_serial_device_wait_for_reply (serial, timeout, responses, terminators, callback, NULL);
+ id = nm_serial_device_wait_for_reply (serial, timeout, responses, terminators, callback, user_data);
if (id == 0)
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_UNKNOWN);
@@ -163,7 +164,7 @@ dial_done (NMSerialDevice *device,
}
static void
-do_dial (NMGsmDevice *device, guint cid)
+real_do_dial (NMGsmDevice *device, guint cid)
{
NMSettingGsm *setting;
char *command;
@@ -185,7 +186,7 @@ do_dial (NMGsmDevice *device, guint cid)
} else
command = g_strconcat ("ATDT", setting->number, NULL);
- modem_wait_for_reply (device, command, 60, responses, responses, dial_done);
+ modem_wait_for_reply (device, command, 60, responses, responses, dial_done, NULL);
g_free (command);
}
@@ -196,7 +197,7 @@ set_apn_done (NMSerialDevice *device,
{
switch (reply_index) {
case 0:
- do_dial (NM_GSM_DEVICE (device), 1);
+ NM_GSM_DEVICE_GET_CLASS (device)->do_dial (NM_GSM_DEVICE (device), GPOINTER_TO_UINT (user_data));
break;
default:
nm_warning ("Setting APN failed");
@@ -216,15 +217,14 @@ set_apn (NMGsmDevice *device)
guint cid = 1;
setting = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
-
if (!setting->apn) {
/* APN not set, nothing to do */
- do_dial (device, 0);
+ NM_GSM_DEVICE_GET_CLASS (device)->do_dial (NM_GSM_DEVICE (device), 0);
return;
}
command = g_strdup_printf ("AT+CGDCONT=%d, \"IP\", \"%s\"", cid, setting->apn);
- modem_wait_for_reply (device, command, 3, responses, responses, set_apn_done);
+ modem_wait_for_reply (device, command, 3, responses, responses, set_apn_done, GUINT_TO_POINTER (cid));
g_free (command);
}
@@ -241,7 +241,7 @@ manual_registration_done (NMSerialDevice *device,
nm_warning ("Manual registration timed out");
nm_device_state_changed (NM_DEVICE (device),
NM_DEVICE_STATE_FAILED,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED);
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT);
break;
default:
nm_warning ("Manual registration failed");
@@ -262,7 +262,7 @@ manual_registration (NMGsmDevice *device)
setting = NM_SETTING_GSM (gsm_device_get_setting (device, NM_TYPE_SETTING_GSM));
command = g_strdup_printf ("AT+COPS=1,2,\"%s\"", setting->network_id);
- modem_wait_for_reply (device, command, 30, responses, responses, manual_registration_done);
+ modem_wait_for_reply (device, command, 30, responses, responses, manual_registration_done, NULL);
g_free (command);
}
@@ -304,7 +304,7 @@ automatic_registration_response (NMSerialDevice *device,
nm_warning ("Automatic registration failed: not registered and not searching.");
nm_device_state_changed (NM_DEVICE (device),
NM_DEVICE_STATE_FAILED,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED);
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING);
break;
case 1:
nm_info ("Registered on Home network");
@@ -317,7 +317,7 @@ automatic_registration_response (NMSerialDevice *device,
nm_warning ("Automatic registration failed: registration denied.");
nm_device_state_changed (NM_DEVICE (device),
NM_DEVICE_STATE_FAILED,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED);
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED);
break;
case 4:
nm_info ("Registered on Roaming network");
@@ -327,7 +327,7 @@ automatic_registration_response (NMSerialDevice *device,
nm_warning ("Automatic registration timed out");
nm_device_state_changed (NM_DEVICE (device),
NM_DEVICE_STATE_FAILED,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED);
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT);
break;
default:
nm_warning ("Automatic registration failed");
@@ -344,7 +344,7 @@ automatic_registration (NMGsmDevice *device)
char *responses[] = { "+CREG: 0,0", "+CREG: 0,1", "+CREG: 0,2", "+CREG: 0,3", "+CREG: 0,5", NULL };
char *terminators[] = { "OK", "ERROR", "ERR", NULL };
- modem_wait_for_reply (device, "AT+CREG?", 60, responses, terminators, automatic_registration_response);
+ modem_wait_for_reply (device, "AT+CREG?", 60, responses, terminators, automatic_registration_response, NULL);
}
static void
@@ -393,7 +393,7 @@ init_modem_full (NMGsmDevice *device)
* just breaks stuff since echo-ed commands are interpreted as replies.
* rh #456770
*/
- modem_wait_for_reply (device, "ATZ E0", 10, responses, responses, init_full_done);
+ modem_wait_for_reply (device, "ATZ E0", 10, responses, responses, init_full_done, NULL);
}
static void
@@ -473,7 +473,7 @@ enter_pin (NMGsmDevice *device, gboolean retry)
char *responses[] = { "OK", "ERROR", "ERR", NULL };
command = g_strdup_printf ("AT+CPIN=\"%s\"", secret);
- modem_wait_for_reply (device, command, 3, responses, responses, enter_pin_done);
+ modem_wait_for_reply (device, command, 3, responses, responses, enter_pin_done, NULL);
g_free (command);
} else {
nm_info ("(%s): GSM %s secret required", nm_device_get_iface (NM_DEVICE (device)), secret_name);
@@ -527,7 +527,7 @@ check_pin (NMGsmDevice *self)
char *responses[] = { "READY", "SIM PIN", "SIM PUK", "ERROR", "ERR", NULL };
char *terminators[] = { "OK", "ERROR", "ERR", NULL };
- modem_wait_for_reply (self, "AT+CPIN?", 3, responses, terminators, check_pin_done);
+ modem_wait_for_reply (self, "AT+CPIN?", 3, responses, terminators, check_pin_done, NULL);
}
static void
@@ -559,7 +559,7 @@ init_modem (NMSerialDevice *device, gpointer user_data)
{
char *responses[] = { "OK", "ERROR", "ERR", NULL };
- modem_wait_for_reply (NM_GSM_DEVICE (device), "AT E0", 10, responses, responses, init_done);
+ modem_wait_for_reply (NM_GSM_DEVICE (device), "AT E0", 10, responses, responses, init_done, NULL);
}
static NMActStageReturn
@@ -911,6 +911,8 @@ nm_gsm_device_class_init (NMGsmDeviceClass *klass)
device_class->connection_secrets_updated = real_connection_secrets_updated;
device_class->deactivate_quickly = real_deactivate_quickly;
+ klass->do_dial = real_do_dial;
+
/* Properties */
g_object_class_install_property
(object_class, PROP_MONITOR_IFACE,
@@ -918,7 +920,7 @@ nm_gsm_device_class_init (NMGsmDeviceClass *klass)
"Monitoring interface",
"Monitoring interface",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT));
/* Signals */
signals[PROPERTIES_CHANGED] =
diff --git a/src/nm-gsm-device.h b/src/nm-gsm-device.h
index 1cd122f7e7..5dbd1306d9 100644
--- a/src/nm-gsm-device.h
+++ b/src/nm-gsm-device.h
@@ -23,6 +23,8 @@ typedef struct {
typedef struct {
NMSerialDeviceClass parent;
+ void (*do_dial) (NMGsmDevice *device, guint cid);
+
/* Signals */
void (*properties_changed) (NMGsmDevice *device, GHashTable *properties);
} NMGsmDeviceClass;
diff --git a/src/nm-hal-manager.c b/src/nm-hal-manager.c
index e5e0cb0eb2..0123014578 100644
--- a/src/nm-hal-manager.c
+++ b/src/nm-hal-manager.c
@@ -14,6 +14,7 @@
#include "nm-device-wifi.h"
#include "nm-device-ethernet.h"
#include "nm-gsm-device.h"
+#include "nm-hso-gsm-device.h"
#include "nm-cdma-device.h"
#include "probe-modem.h"
@@ -221,6 +222,50 @@ is_modem_device (NMHalManager *self, const char *udi)
return is_modem;
}
+static char *
+get_hso_netdev (LibHalContext *ctx, const char *udi)
+{
+ char *serial_parent, *netdev = NULL;
+ char **netdevs;
+ int num, i;
+
+ /* Get the serial interface's originating device UDI, used to find the
+ * originating device's netdev.
+ */
+ serial_parent = libhal_device_get_property_string (ctx, udi, "serial.originating_device", NULL);
+ if (!serial_parent)
+ serial_parent = libhal_device_get_property_string (ctx, udi, "info.parent", NULL);
+ if (!serial_parent)
+ return NULL;
+
+ /* Look for the originating device's netdev */
+ netdevs = libhal_find_device_by_capability (ctx, "net", &num, NULL);
+ for (i = 0; netdevs && !netdev && (i < num); i++) {
+ char *netdev_parent, *tmp;
+
+ netdev_parent = libhal_device_get_property_string (ctx, netdevs[i], "net.originating_device", NULL);
+ if (!netdev_parent)
+ netdev_parent = libhal_device_get_property_string (ctx, netdevs[i], "net.physical_device", NULL);
+ if (!netdev_parent)
+ continue;
+
+ if (!strcmp (netdev_parent, serial_parent)) {
+ /* We found it */
+ tmp = libhal_device_get_property_string (ctx, netdevs[i], "net.interface", NULL);
+ if (tmp) {
+ netdev = g_strdup (tmp);
+ libhal_free_string (tmp);
+ }
+ }
+
+ libhal_free_string (netdev_parent);
+ }
+ libhal_free_string_array (netdevs);
+ libhal_free_string (serial_parent);
+
+ return netdev;
+}
+
static GObject *
modem_device_creator (NMHalManager *self, const char *udi, gboolean managed)
{
@@ -233,6 +278,7 @@ modem_device_creator (NMHalManager *self, const char *udi, gboolean managed)
gboolean type_gsm = FALSE;
gboolean type_cdma = FALSE;
gboolean type_v250 = FALSE;
+ char *netdev = NULL;
serial_device = libhal_device_get_property_string (priv->hal_ctx, udi, "serial.device", NULL);
@@ -289,8 +335,15 @@ retry:
}
}
+ /* Special handling of 'hso' cards (until punted out to a modem manager) */
+ if (type_gsm && !strcmp (driver_name, "hso"))
+ netdev = get_hso_netdev (priv->hal_ctx, udi);
+
if (type_gsm)
- device = (GObject *) nm_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
+ if (netdev)
+ device = (GObject *) nm_hso_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, netdev, driver_name, managed);
+ else
+ device = (GObject *) nm_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
else if (type_cdma)
device = (GObject *) nm_cdma_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
@@ -317,7 +370,7 @@ register_built_in_creators (NMHalManager *self)
/* Wireless device */
creator = g_slice_new0 (DeviceCreator);
- creator->device_type_name = g_strdup ("wireless (802.11)");
+ creator->device_type_name = g_strdup ("802.11 WiFi");
creator->capability_str = g_strdup ("net.80211");
creator->is_device_fn = is_wireless_device;
creator->creator_fn = wireless_device_creator;
diff --git a/src/nm-hso-gsm-device.c b/src/nm-hso-gsm-device.c
new file mode 100644
index 0000000000..d659dcba3d
--- /dev/null
+++ b/src/nm-hso-gsm-device.c
@@ -0,0 +1,563 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <dbus/dbus-glib.h>
+
+#include "nm-device.h"
+#include "nm-hso-gsm-device.h"
+#include "nm-gsm-device.h"
+#include "nm-device-interface.h"
+#include "nm-device-private.h"
+#include "nm-setting-gsm.h"
+#include "nm-utils.h"
+#include "nm-properties-changed-signal.h"
+#include "nm-setting-connection.h"
+#include "NetworkManagerSystem.h"
+
+G_DEFINE_TYPE (NMHsoGsmDevice, nm_hso_gsm_device, NM_TYPE_GSM_DEVICE)
+
+#define NM_HSO_GSM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_HSO_GSM_DEVICE, NMHsoGsmDevicePrivate))
+
+extern const DBusGObjectInfo dbus_glib_nm_gsm_device_object_info;
+
+#define GSM_CID "gsm-cid"
+#define HSO_SECRETS_TRIES "gsm-secrets-tries"
+
+typedef struct {
+ char *netdev_iface;
+ NMIP4Config *pending_ip4_config;
+} NMHsoGsmDevicePrivate;
+
+enum {
+ PROP_0,
+ PROP_NETDEV_IFACE,
+
+ LAST_PROP
+};
+
+NMHsoGsmDevice *
+nm_hso_gsm_device_new (const char *udi,
+ const char *data_iface,
+ const char *monitor_iface,
+ const char *netdev_iface,
+ const char *driver,
+ gboolean managed)
+{
+ g_return_val_if_fail (udi != NULL, NULL);
+ g_return_val_if_fail (data_iface != NULL, NULL);
+ g_return_val_if_fail (driver != NULL, NULL);
+ g_return_val_if_fail (netdev_iface != NULL, NULL);
+
+ return (NMHsoGsmDevice *) g_object_new (NM_TYPE_HSO_GSM_DEVICE,
+ NM_DEVICE_INTERFACE_UDI, udi,
+ NM_DEVICE_INTERFACE_IFACE, data_iface,
+ NM_DEVICE_INTERFACE_DRIVER, driver,
+ NM_GSM_DEVICE_MONITOR_IFACE, monitor_iface,
+ NM_HSO_GSM_DEVICE_NETDEV_IFACE, netdev_iface,
+ NM_DEVICE_INTERFACE_MANAGED, managed,
+ NULL);
+}
+
+static void
+modem_wait_for_reply (NMGsmDevice *self,
+ const char *command,
+ guint timeout,
+ char **responses,
+ char **terminators,
+ NMSerialWaitForReplyFn callback,
+ gpointer user_data)
+{
+ NMSerialDevice *serial = NM_SERIAL_DEVICE (self);
+ guint id = 0;
+
+ if (nm_serial_device_send_command_string (serial, command))
+ id = nm_serial_device_wait_for_reply (serial, timeout, responses, terminators, callback, user_data);
+
+ if (id == 0)
+ nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_UNKNOWN);
+}
+
+static void
+modem_get_reply (NMGsmDevice *self,
+ const char *command,
+ guint timeout,
+ const char *terminators,
+ NMSerialGetReplyFn callback)
+{
+ NMSerialDevice *serial = NM_SERIAL_DEVICE (self);
+ guint id = 0;
+
+ if (nm_serial_device_send_command_string (serial, command))
+ id = nm_serial_device_get_reply (serial, timeout, terminators, callback, NULL);
+
+ if (id == 0)
+ nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_UNKNOWN);
+}
+
+static NMSetting *
+gsm_device_get_setting (NMGsmDevice *device, GType setting_type)
+{
+ NMActRequest *req;
+ NMSetting *setting = NULL;
+
+ req = nm_device_get_act_request (NM_DEVICE (device));
+ if (req) {
+ NMConnection *connection;
+
+ connection = nm_act_request_get_connection (req);
+ if (connection)
+ setting = nm_connection_get_setting (connection, setting_type);
+ }
+
+ return setting;
+}
+
+static void
+hso_call_done (NMSerialDevice *device,
+ int reply_index,
+ gpointer user_data)
+{
+ gboolean success = FALSE;
+
+ switch (reply_index) {
+ case 0:
+ nm_info ("Connected, Woo!");
+ success = TRUE;
+ break;
+ default:
+ nm_warning ("Connect request failed");
+ break;
+ }
+
+ if (success)
+ nm_device_activate_schedule_stage3_ip_config_start (NM_DEVICE (device));
+ else
+ nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED);
+}
+
+static void
+hso_clear_done (NMSerialDevice *device,
+ int reply_index,
+ gpointer user_data)
+{
+ char *responses[] = { "_OWANCALL: ", "ERROR", NULL };
+ guint cid = GPOINTER_TO_UINT (user_data);
+ char *command;
+
+ /* Try to connect */
+ command = g_strdup_printf ("AT_OWANCALL=%d,1,1", cid);
+ modem_wait_for_reply (NM_GSM_DEVICE (device), command, 10, responses, responses, hso_call_done, NULL);
+ g_free (command);
+}
+
+static void
+hso_auth_done (NMSerialDevice *device,
+ int reply_index,
+ gpointer user_data)
+{
+ gboolean success = FALSE;
+ char *responses[] = { "_OWANCALL: ", "ERROR", "NO CARRIER", NULL };
+ guint cid = GPOINTER_TO_UINT (user_data);
+ char *command;
+
+ switch (reply_index) {
+ case 0:
+ nm_info ("Authentication successful!");
+ success = TRUE;
+ break;
+ default:
+ nm_warning ("Authentication failed");
+ break;
+ }
+
+ if (!success) {
+ nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED);
+ return;
+ }
+
+ /* Kill any existing connection */
+ command = g_strdup_printf ("AT_OWANCALL=%d,0,1", cid);
+ modem_wait_for_reply (NM_GSM_DEVICE (device), command, 5, responses, responses, hso_clear_done, GUINT_TO_POINTER (cid));
+ g_free (command);
+}
+
+static void
+do_hso_auth (NMHsoGsmDevice *device)
+{
+ NMSettingGsm *s_gsm;
+ NMActRequest *req;
+ char *responses[] = { "OK", "ERROR", NULL };
+ char *command;
+ guint cid;
+
+ req = nm_device_get_act_request (NM_DEVICE (device));
+ g_assert (req);
+
+ cid = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (req), GSM_CID));
+
+ s_gsm = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
+
+ command = g_strdup_printf ("AT$QCPDPP=%d,1,\"%s\",\"%s\"",
+ cid,
+ s_gsm->password ? s_gsm->password : "",
+ s_gsm->username ? s_gsm->username : "");
+ modem_wait_for_reply (NM_GSM_DEVICE (device), command, 5, responses, responses, hso_auth_done, GUINT_TO_POINTER (cid));
+ g_free (command);
+}
+
+static NMActStageReturn
+real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
+{
+ NMActRequest *req;
+ NMConnection *connection;
+ const char *setting_name;
+ GPtrArray *hints = NULL;
+ const char *hint1 = NULL, *hint2 = NULL;
+ guint32 tries;
+
+ req = nm_device_get_act_request (device);
+ g_assert (req);
+ connection = nm_act_request_get_connection (req);
+ g_assert (connection);
+
+ setting_name = nm_connection_need_secrets (connection, &hints);
+ if (!setting_name) {
+ do_hso_auth (NM_HSO_GSM_DEVICE (device));
+ return NM_ACT_STAGE_RETURN_POSTPONE;
+ }
+
+ if (hints) {
+ if (hints->len > 0)
+ hint1 = g_ptr_array_index (hints, 0);
+ if (hints->len > 1)
+ hint2 = g_ptr_array_index (hints, 1);
+ }
+
+ nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
+
+ tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), HSO_SECRETS_TRIES));
+ nm_act_request_request_connection_secrets (req,
+ setting_name,
+ tries ? TRUE : FALSE,
+ SECRETS_CALLER_HSO_GSM,
+ hint1,
+ hint2);
+ g_object_set_data (G_OBJECT (connection), HSO_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
+
+ if (hints)
+ g_ptr_array_free (hints, TRUE);
+
+ return NM_ACT_STAGE_RETURN_POSTPONE;
+}
+
+static void
+real_do_dial (NMGsmDevice *device, guint cid)
+{
+ NMActRequest *req;
+
+ req = nm_device_get_act_request (NM_DEVICE (device));
+ g_assert (req);
+ g_object_set_data (G_OBJECT (req), GSM_CID, GUINT_TO_POINTER (cid));
+
+ nm_device_activate_schedule_stage2_device_config (NM_DEVICE (device));
+}
+
+#define OWANDATA_TAG "_OWANDATA: "
+
+static void
+hso_ip4_config_done (NMSerialDevice *device,
+ const char *response,
+ gpointer user_data)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (device);
+ NMActRequest *req;
+ char **items, **iter;
+ guint cid, i;
+ NMSettingIP4Address addr = { 0, 32, 0 };
+ guint32 dns1 = 0, dns2 = 0;
+
+ if (!response || strncmp (response, OWANDATA_TAG, strlen (OWANDATA_TAG))) {
+ nm_device_activate_schedule_stage4_ip_config_timeout (NM_DEVICE (device));
+ return;
+ }
+
+ req = nm_device_get_act_request (NM_DEVICE (device));
+ g_assert (req);
+ cid = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (req), GSM_CID));
+
+ items = g_strsplit (response + strlen (OWANDATA_TAG), ", ", 0);
+ for (iter = items, i = 0; *iter; iter++, i++) {
+ if (i == 0) { /* CID */
+ long int tmp;
+
+ errno = 0;
+ tmp = strtol (*iter, NULL, 10);
+ if (errno != 0 || tmp < 0 || (guint) tmp != cid) {
+ nm_warning ("%s: unknown CID in OWANDATA response (got %d, expected %d)",
+ nm_device_get_iface (NM_DEVICE (device)),
+ (guint) tmp, cid);
+ goto out;
+ }
+ } else if (i == 1) { /* IP address */
+ if (inet_pton (AF_INET, *iter, &(addr.address)) <= 0)
+ addr.address = 0;
+ } else if (i == 3) { /* DNS 1 */
+ if (inet_pton (AF_INET, *iter, &dns1) <= 0)
+ dns1 = 0;
+ } else if (i == 4) { /* DNS 2 */
+ if (inet_pton (AF_INET, *iter, &dns2) <= 0)
+ dns2 = 0;
+ }
+ }
+
+out:
+ g_strfreev (items);
+
+ if (addr.address) {
+ priv->pending_ip4_config = nm_ip4_config_new ();
+
+ nm_ip4_config_add_address (priv->pending_ip4_config, &addr);
+
+ if (dns1)
+ nm_ip4_config_add_nameserver (priv->pending_ip4_config, dns1);
+ if (dns2)
+ nm_ip4_config_add_nameserver (priv->pending_ip4_config, dns2);
+
+ nm_device_activate_schedule_stage4_ip_config_get (NM_DEVICE (device));
+ } else {
+ nm_device_state_changed (NM_DEVICE (device),
+ NM_DEVICE_STATE_FAILED,
+ NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
+ }
+}
+
+static NMActStageReturn
+real_act_stage3_ip_config_start (NMDevice *device, NMDeviceStateReason *reason)
+{
+ const char terminators[] = { '\r', '\n', '\0' };
+ NMActRequest *req;
+ char *command;
+ gint cid;
+
+ req = nm_device_get_act_request (device);
+ g_assert (req);
+
+ cid = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (req), GSM_CID));
+ command = g_strdup_printf ("AT_OWANDATA=%d", cid);
+ modem_get_reply (NM_GSM_DEVICE (device), command, 5, terminators, hso_ip4_config_done);
+ g_free (command);
+
+ return NM_ACT_STAGE_RETURN_POSTPONE;
+}
+
+static NMActStageReturn
+real_act_stage4_get_ip4_config (NMDevice *device,
+ NMIP4Config **config,
+ NMDeviceStateReason *reason)
+{
+ NMHsoGsmDevice *self = NM_HSO_GSM_DEVICE (device);
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (self);
+
+ g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
+ g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
+
+ nm_device_set_ip_iface (device, priv->netdev_iface);
+ if (!nm_device_hw_bring_up (device, TRUE))
+ return NM_ACT_STAGE_RETURN_FAILURE;
+
+ *config = priv->pending_ip4_config;
+ priv->pending_ip4_config = NULL;
+ return NM_ACT_STAGE_RETURN_SUCCESS;
+}
+
+static void
+real_connection_secrets_updated (NMDevice *device,
+ NMConnection *connection,
+ GSList *updated_settings,
+ RequestSecretsCaller caller)
+{
+ g_return_if_fail (caller == SECRETS_CALLER_HSO_GSM);
+ g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH);
+
+ nm_device_activate_schedule_stage2_device_config (device);
+}
+
+static void
+real_deactivate_quickly (NMDevice *device)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (device);
+ NMActRequest *req;
+ guint cid;
+ char *command;
+
+ if (priv->pending_ip4_config) {
+ g_object_unref (priv->pending_ip4_config);
+ priv->pending_ip4_config = NULL;
+ }
+
+ /* Don't leave the modem connected */
+ req = nm_device_get_act_request (device);
+ if (req) {
+ cid = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (req), GSM_CID));
+ if (cid) {
+ command = g_strdup_printf ("AT_OWANCALL=%d,0,1", cid);
+ nm_serial_device_send_command_string (NM_SERIAL_DEVICE (device), command);
+ g_free (command);
+
+ /* FIXME: doesn't seem to take the command otherwise, perhaps since
+ * the serial port gets closed right away
+ */
+ g_usleep (G_USEC_PER_SEC / 3);
+ }
+ }
+
+
+ if (NM_DEVICE_CLASS (nm_hso_gsm_device_parent_class)->deactivate_quickly)
+ NM_DEVICE_CLASS (nm_hso_gsm_device_parent_class)->deactivate_quickly (device);
+}
+
+static void
+real_deactivate (NMDevice *device)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (device);
+
+ if (priv->netdev_iface) {
+ nm_system_device_flush_ip4_routes_with_iface (priv->netdev_iface);
+ nm_system_device_flush_ip4_addresses_with_iface (priv->netdev_iface);
+ nm_system_device_set_up_down_with_iface (priv->netdev_iface, FALSE);
+ }
+ nm_device_set_ip_iface (device, NULL);
+
+ if (NM_DEVICE_CLASS (nm_hso_gsm_device_parent_class)->deactivate)
+ NM_DEVICE_CLASS (nm_hso_gsm_device_parent_class)->deactivate (device);
+}
+
+static gboolean
+real_hw_is_up (NMDevice *device)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (device);
+ NMDeviceState state;
+
+ state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device));
+
+ if ( priv->pending_ip4_config
+ || (state == NM_DEVICE_STATE_IP_CONFIG)
+ || (state == NM_DEVICE_STATE_ACTIVATED))
+ return nm_system_device_is_up_with_iface (priv->netdev_iface);
+
+ return TRUE;
+}
+
+static gboolean
+real_hw_bring_up (NMDevice *device)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (device);
+ NMDeviceState state;
+
+ state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device));
+
+ if ( priv->pending_ip4_config
+ || (state == NM_DEVICE_STATE_IP_CONFIG)
+ || (state == NM_DEVICE_STATE_ACTIVATED))
+ return nm_system_device_set_up_down_with_iface (priv->netdev_iface, TRUE);
+
+ return TRUE;
+}
+
+static void
+nm_hso_gsm_device_init (NMHsoGsmDevice *self)
+{
+}
+
+static GObject*
+constructor (GType type,
+ guint n_params,
+ GObjectConstructParam *params)
+{
+ return G_OBJECT_CLASS (nm_hso_gsm_device_parent_class)->constructor (type, n_params, params);
+}
+
+static void
+set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (object);
+
+ switch (prop_id) {
+ case PROP_NETDEV_IFACE:
+ /* Construct only */
+ priv->netdev_iface = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (object);
+
+ switch (prop_id) {
+ case PROP_NETDEV_IFACE:
+ g_value_set_string (value, priv->netdev_iface);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+finalize (GObject *object)
+{
+ NMHsoGsmDevicePrivate *priv = NM_HSO_GSM_DEVICE_GET_PRIVATE (object);
+
+ g_free (priv->netdev_iface);
+
+ G_OBJECT_CLASS (nm_hso_gsm_device_parent_class)->finalize (object);
+}
+
+static void
+nm_hso_gsm_device_class_init (NMHsoGsmDeviceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
+ NMGsmDeviceClass *gsm_class = NM_GSM_DEVICE_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (NMHsoGsmDevicePrivate));
+
+ object_class->constructor = constructor;
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ object_class->finalize = finalize;
+
+ device_class->act_stage2_config = real_act_stage2_config;
+ device_class->act_stage3_ip_config_start = real_act_stage3_ip_config_start;
+ device_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
+ device_class->connection_secrets_updated = real_connection_secrets_updated;
+ device_class->deactivate_quickly = real_deactivate_quickly;
+ device_class->deactivate = real_deactivate;
+ device_class->hw_is_up = real_hw_is_up;
+ device_class->hw_bring_up = real_hw_bring_up;
+
+ gsm_class->do_dial = real_do_dial;
+
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_NETDEV_IFACE,
+ g_param_spec_string (NM_HSO_GSM_DEVICE_NETDEV_IFACE,
+ "Network interface",
+ "Network interface",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT));
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
+ &dbus_glib_nm_gsm_device_object_info);
+}
diff --git a/src/nm-hso-gsm-device.h b/src/nm-hso-gsm-device.h
new file mode 100644
index 0000000000..a7498c8394
--- /dev/null
+++ b/src/nm-hso-gsm-device.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+#ifndef NM_HSO_GSM_DEVICE_H
+#define NM_HSO_GSM_DEVICE_H
+
+#include <nm-gsm-device.h>
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_HSO_GSM_DEVICE (nm_hso_gsm_device_get_type ())
+#define NM_HSO_GSM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_HSO_GSM_DEVICE, NMHsoGsmDevice))
+#define NM_HSO_GSM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_HSO_GSM_DEVICE, NMHsoGsmDeviceClass))
+#define NM_IS_HSO_GSM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_HSO_GSM_DEVICE))
+#define NM_IS_HSO_GSM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_HSO_GSM_DEVICE))
+#define NM_HSO_GSM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_HSO_GSM_DEVICE, NMHsoGsmDeviceClass))
+
+#define NM_HSO_GSM_DEVICE_NETDEV_IFACE "netdev-iface"
+
+typedef struct {
+ NMGsmDevice parent;
+} NMHsoGsmDevice;
+
+typedef struct {
+ NMGsmDeviceClass parent;
+} NMHsoGsmDeviceClass;
+
+GType nm_hso_gsm_device_get_type (void);
+
+NMHsoGsmDevice *nm_hso_gsm_device_new (const char *udi,
+ const char *data_iface,
+ const char *monitor_iface,
+ const char *netdev_iface,
+ const char *driver,
+ gboolean managed);
+
+G_END_DECLS
+
+#endif /* NM_HSO_GSM_DEVICE_H */
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index 0bf780b894..718c80cb41 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -56,8 +56,6 @@ typedef struct {
GPtrArray *searches;
gchar *hostname;
- gchar *nis_domain;
- GArray *nis_servers;
GSList *routes;
} NMIP4ConfigPrivate;
@@ -68,8 +66,6 @@ enum {
PROP_HOSTNAME,
PROP_NAMESERVERS,
PROP_DOMAINS,
- PROP_NIS_DOMAIN,
- PROP_NIS_SERVERS,
PROP_ROUTES,
LAST_PROP
@@ -95,56 +91,6 @@ nm_ip4_config_new (void)
return (NMIP4Config *) object;
}
-NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
-{
- NMIP4Config *dst_config;
- NMIP4ConfigPrivate *src_priv;
- int i;
- int len;
- GSList *iter;
-
- g_return_val_if_fail (NM_IS_IP4_CONFIG (src_config), NULL);
-
- dst_config = nm_ip4_config_new ();
- src_priv = NM_IP4_CONFIG_GET_PRIVATE (src_config);
-
- for (iter = src_priv->addresses; iter; iter = g_slist_next (iter)) {
- NMSettingIP4Address *src_addr = (NMSettingIP4Address *) iter->data;
- NMSettingIP4Address *dst_addr;
-
- dst_addr = g_malloc0 (sizeof (NMSettingIP4Address));
- memcpy (dst_addr, src_addr, sizeof (NMSettingIP4Address));
- nm_ip4_config_take_address (dst_config, dst_addr);
- }
-
- nm_ip4_config_set_ptp_address (dst_config, nm_ip4_config_get_ptp_address (src_config));
- nm_ip4_config_set_hostname (dst_config, nm_ip4_config_get_hostname (src_config));
- nm_ip4_config_set_nis_domain (dst_config, nm_ip4_config_get_nis_domain (src_config));
-
- len = nm_ip4_config_get_num_nameservers (src_config);
- for (i = 0; i < len; i++)
- nm_ip4_config_add_nameserver (dst_config, nm_ip4_config_get_nameserver (src_config, i));
-
- len = nm_ip4_config_get_num_domains (src_config);
- for (i = 0; i < len; i++)
- nm_ip4_config_add_domain (dst_config, nm_ip4_config_get_domain (src_config, i));
-
- len = nm_ip4_config_get_num_nis_servers (src_config);
- for (i = 0; i < len; i++)
- nm_ip4_config_add_nis_server (dst_config, nm_ip4_config_get_nis_server (src_config, i));
-
- for (iter = src_priv->routes; iter; iter = g_slist_next (iter)) {
- NMSettingIP4Route *src_route = (NMSettingIP4Route *) iter->data;
- NMSettingIP4Route *dst_route;
-
- dst_route = g_malloc0 (sizeof (NMSettingIP4Route));
- memcpy (dst_route, src_route, sizeof (NMSettingIP4Route));
- nm_ip4_config_take_route (dst_config, dst_route);
- }
-
- return dst_config;
-}
-
void
nm_ip4_config_take_address (NMIP4Config *config,
NMSettingIP4Address *address)
@@ -180,6 +126,7 @@ nm_ip4_config_replace_address (NMIP4Config *config,
NMSettingIP4Address *new_address)
{
NMIP4ConfigPrivate *priv;
+ NMSettingIP4Address *copy;
GSList *old;
g_return_if_fail (NM_IS_IP4_CONFIG (config));
@@ -187,9 +134,11 @@ nm_ip4_config_replace_address (NMIP4Config *config,
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
old = g_slist_nth (priv->addresses, i);
g_return_if_fail (old != NULL);
-
g_free (old->data);
- old->data = new_address;
+
+ copy = g_malloc0 (sizeof (NMSettingIP4Address));
+ memcpy (copy, new_address, sizeof (NMSettingIP4Address));
+ old->data = copy;
}
const NMSettingIP4Address *nm_ip4_config_get_address (NMIP4Config *config, guint i)
@@ -253,27 +202,6 @@ void nm_ip4_config_reset_nameservers (NMIP4Config *config)
g_array_remove_range (priv->nameservers, 0, priv->nameservers->len);
}
-void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server)
-{
- g_return_if_fail (NM_IS_IP4_CONFIG (config));
-
- g_array_append_val (NM_IP4_CONFIG_GET_PRIVATE (config)->nis_servers, nis_server);
-}
-
-guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
-
- return g_array_index (NM_IP4_CONFIG_GET_PRIVATE (config)->nis_servers, guint32, i);
-}
-
-guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config)
-{
- g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
-
- return NM_IP4_CONFIG_GET_PRIVATE (config)->nis_servers->len;
-}
-
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname)
{
g_return_if_fail (NM_IS_IP4_CONFIG (config));
@@ -292,23 +220,6 @@ const char *nm_ip4_config_get_hostname (NMIP4Config *config)
return NM_IP4_CONFIG_GET_PRIVATE (config)->hostname;
}
-void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
-{
- g_return_if_fail (NM_IS_IP4_CONFIG (config));
- g_return_if_fail (domain != NULL);
-
- if (!strlen (domain))
- return;
-
- NM_IP4_CONFIG_GET_PRIVATE (config)->nis_domain = g_strdup (domain);
-}
-
-const char *nm_ip4_config_get_nis_domain (NMIP4Config *config)
-{
- g_return_val_if_fail( NM_IS_IP4_CONFIG (config), NULL);
- return NM_IP4_CONFIG_GET_PRIVATE (config)->nis_domain;
-}
-
void
nm_ip4_config_take_route (NMIP4Config *config,
NMSettingIP4Route *route)
@@ -344,6 +255,7 @@ nm_ip4_config_replace_route (NMIP4Config *config,
NMSettingIP4Route *new_route)
{
NMIP4ConfigPrivate *priv;
+ NMSettingIP4Route *copy;
GSList *old;
g_return_if_fail (NM_IS_IP4_CONFIG (config));
@@ -351,9 +263,11 @@ nm_ip4_config_replace_route (NMIP4Config *config,
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
old = g_slist_nth (priv->routes, i);
g_return_if_fail (old != NULL);
-
g_free (old->data);
- old->data = new_route;
+
+ copy = g_malloc0 (sizeof (NMSettingIP4Route));
+ memcpy (copy, new_route, sizeof (NMSettingIP4Route));
+ old->data = copy;
}
const NMSettingIP4Route *
@@ -565,7 +479,6 @@ nm_ip4_config_init (NMIP4Config *config)
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->nameservers = g_array_new (FALSE, TRUE, sizeof (guint32));
- priv->nis_servers = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->domains = g_ptr_array_new ();
priv->searches = g_ptr_array_new ();
}
@@ -577,44 +490,13 @@ finalize (GObject *object)
nm_utils_slist_free (priv->addresses, g_free);
g_free (priv->hostname);
- g_free (priv->nis_domain);
g_array_free (priv->nameservers, TRUE);
g_ptr_array_free (priv->domains, TRUE);
g_ptr_array_free (priv->searches, TRUE);
- g_array_free (priv->nis_servers, TRUE);
nm_utils_slist_free (priv->routes, g_free);
}
static void
-ip4_addresses_to_gvalue (GSList *list, GValue *value)
-{
- GPtrArray *addresses;
- GSList *iter;
-
- addresses = g_ptr_array_new ();
-
- for (iter = list; iter; iter = iter->next) {
- NMSettingIP4Address *ip4_addr = (NMSettingIP4Address *) iter->data;
- GArray *array;
- const guint32 empty_val = 0;
-
- array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
-
- g_array_append_val (array, ip4_addr->address);
- g_array_append_val (array, ip4_addr->prefix);
-
- if (ip4_addr->gateway)
- g_array_append_val (array, ip4_addr->gateway);
- else
- g_array_append_val (array, empty_val);
-
- g_ptr_array_add (addresses, array);
- }
-
- g_value_take_boxed (value, addresses);
-}
-
-static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
@@ -622,7 +504,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_ADDRESSES:
- ip4_addresses_to_gvalue (priv->addresses, value);
+ nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
break;
case PROP_HOSTNAME:
g_value_set_string (value, priv->hostname);
@@ -633,14 +515,8 @@ get_property (GObject *object, guint prop_id,
case PROP_DOMAINS:
g_value_set_boxed (value, priv->domains);
break;
- case PROP_NIS_DOMAIN:
- g_value_set_string (value, priv->nis_domain);
- break;
- case PROP_NIS_SERVERS:
- g_value_set_boxed (value, priv->nis_servers);
- break;
case PROP_ROUTES:
- ip4_addresses_to_gvalue (priv->routes, value);
+ nm_utils_ip4_routes_to_gvalue (priv->routes, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -688,20 +564,6 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
"Domains",
DBUS_TYPE_G_ARRAY_OF_STRING,
G_PARAM_READABLE));
- g_object_class_install_property
- (object_class, PROP_NIS_DOMAIN,
- g_param_spec_string (NM_IP4_CONFIG_NIS_DOMAIN,
- "NIS domain",
- "NIS domain name",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property
- (object_class, PROP_NIS_SERVERS,
- g_param_spec_boxed (NM_IP4_CONFIG_NIS_SERVERS,
- "NIS servers",
- "NIS servers",
- DBUS_TYPE_G_UINT_ARRAY,
- G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_ROUTES,
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index 00f0f1620d..eb91c9ba75 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -72,10 +72,6 @@ guint32 nm_ip4_config_get_nameserver (NMIP4Config *config, guint i);
guint32 nm_ip4_config_get_num_nameservers (NMIP4Config *config);
void nm_ip4_config_reset_nameservers (NMIP4Config *config);
-void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server);
-guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i);
-guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config);
-
void nm_ip4_config_take_route (NMIP4Config *config, NMSettingIP4Route *route);
void nm_ip4_config_add_route (NMIP4Config *config, NMSettingIP4Route *route);
void nm_ip4_config_replace_route (NMIP4Config *config, guint32 i, NMSettingIP4Route *new_route);
@@ -86,9 +82,6 @@ void nm_ip4_config_reset_routes (NMIP4Config *config);
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname);
const char * nm_ip4_config_get_hostname (NMIP4Config *config);
-void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain);
-const char * nm_ip4_config_get_nis_domain (NMIP4Config *config);
-
void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain);
const char * nm_ip4_config_get_domain (NMIP4Config *config, guint i);
guint32 nm_ip4_config_get_num_domains (NMIP4Config *config);
diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c
index a6d8395409..0e9c87294f 100644
--- a/src/nm-netlink-monitor.c
+++ b/src/nm-netlink-monitor.c
@@ -434,7 +434,10 @@ nm_netlink_monitor_request_status (NMNetlinkMonitor *monitor,
/* Update the link cache with latest state */
if (nl_cache_refill (priv->nlh, priv->nlh_link_cache)) {
- nm_warning ("Error updating link cache: %s", nl_geterror ());
+ g_set_error (error, NM_NETLINK_MONITOR_ERROR,
+ NM_NETLINK_MONITOR_ERROR_LINK_CACHE_UPDATE,
+ _("error updating link cache: %s"),
+ nl_geterror ());
return FALSE;
}
@@ -487,7 +490,7 @@ nm_netlink_monitor_error_handler (GIOChannel *channel,
{
GError *socket_error;
- g_return_val_if_fail (!(io_condition & ~(NM_NETLINK_MONITOR_ERROR_CONDITIONS)), FALSE);
+ g_return_val_if_fail (io_condition & NM_NETLINK_MONITOR_ERROR_CONDITIONS, FALSE);
socket_error = g_error_new (NM_NETLINK_MONITOR_ERROR,
NM_NETLINK_MONITOR_ERROR_WAITING_FOR_SOCKET_DATA,
diff --git a/src/nm-netlink-monitor.h b/src/nm-netlink-monitor.h
index 46497a9580..a74b763a05 100644
--- a/src/nm-netlink-monitor.h
+++ b/src/nm-netlink-monitor.h
@@ -43,6 +43,7 @@ typedef enum {
NM_NETLINK_MONITOR_ERROR_PROCESSING_MESSAGE,
NM_NETLINK_MONITOR_ERROR_BAD_ALLOC,
NM_NETLINK_MONITOR_ERROR_WAITING_FOR_SOCKET_DATA,
+ NM_NETLINK_MONITOR_ERROR_LINK_CACHE_UPDATE
} NMNetlinkMonitorError;
typedef struct {
diff --git a/src/nm-properties-changed-signal.c b/src/nm-properties-changed-signal.c
index bb7427d50a..2dcfc50384 100644
--- a/src/nm-properties-changed-signal.c
+++ b/src/nm-properties-changed-signal.c
@@ -141,6 +141,10 @@ notify (GObject *object, GParamSpec *pspec)
PropertiesChangedInfo *info;
GValue *value;
+ /* Ignore properties that shouldn't be exported */
+ if (pspec->flags & NM_PROPERTY_PARAM_NO_EXPORT)
+ return;
+
info = (PropertiesChangedInfo *) g_object_get_data (object, NM_DBUS_PROPERTY_CHANGED);
if (!info) {
info = properties_changed_info_new ();
diff --git a/src/nm-properties-changed-signal.h b/src/nm-properties-changed-signal.h
index d77f9662a2..9ae342b965 100644
--- a/src/nm-properties-changed-signal.h
+++ b/src/nm-properties-changed-signal.h
@@ -5,6 +5,8 @@
#include <glib-object.h>
+#define NM_PROPERTY_PARAM_NO_EXPORT (1 << (0 + G_PARAM_USER_SHIFT))
+
guint nm_properties_changed_signal_new (GObjectClass *object_class,
guint class_offset);
diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c
index 23bad87c94..dbb95fc3a8 100644
--- a/src/ppp-manager/nm-ppp-manager.c
+++ b/src/ppp-manager/nm-ppp-manager.c
@@ -384,7 +384,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
*/
priv->pending_secrets_context = context;
nm_ppp_manager_update_secrets (manager,
- NULL, /* FIXME: pass device name */
+ priv->parent_iface,
username ? username : "",
password ? password : "",
NULL);
@@ -690,6 +690,8 @@ pppd_timed_out (gpointer data)
nm_warning ("Looks like pppd didn't initialize our dbus module");
nm_ppp_manager_stop (manager);
+ g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD);
+
return FALSE;
}
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index be32ead556..94424e9810 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
@@ -35,7 +35,6 @@
#include "nm-vpn-connection.h"
#include "nm-setting-connection.h"
#include "nm-setting-vpn.h"
-#include "nm-setting-vpn-properties.h"
#include "nm-setting-ip4-config.h"
#include "nm-dbus-manager.h"
#include "nm-manager.h"
@@ -477,7 +476,7 @@ nm_vpn_connection_connect_cb (DBusGProxy *proxy, GError *err, gpointer user_data
nm_vpn_connection_get_name (connection));
if (err) {
- nm_warning ("(VPN connection '%s' could not start. dbus says: '%s'.",
+ nm_warning ("VPN connection '%s' failed to connect: '%s'.",
nm_vpn_connection_get_name (connection), err->message);
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
@@ -660,11 +659,11 @@ update_vpn_properties_secrets (gpointer key, gpointer data, gpointer user_data)
{
NMConnection *connection = NM_CONNECTION (user_data);
- if (strcmp (key, NM_SETTING_VPN_PROPERTIES_SETTING_NAME))
+ if (strcmp (key, NM_SETTING_VPN_SETTING_NAME))
return;
nm_connection_update_secrets (connection,
- NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
+ NM_SETTING_VPN_SETTING_NAME,
(GHashTable *) data);
}
@@ -802,9 +801,9 @@ call_need_secrets (NMVPNConnection *vpn_connection)
}
static void
-connection_vpn_state_changed (NMVPNConnection *connection,
- NMVPNConnectionState state,
- NMVPNConnectionStateReason reason)
+connection_state_changed (NMVPNConnection *connection,
+ NMVPNConnectionState state,
+ NMVPNConnectionStateReason reason)
{
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
@@ -977,7 +976,7 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
g_type_class_add_private (connection_class, sizeof (NMVPNConnectionPrivate));
/* virtual methods */
- connection_class->vpn_state_changed = connection_vpn_state_changed;
+ connection_class->vpn_state_changed = connection_state_changed;
object_class->get_property = get_property;
object_class->dispose = dispose;
object_class->finalize = finalize;