1 diff -urN NetworkManager-0.6.5.orig/configure.in NetworkManager-0.6.5/configure.in
2 --- NetworkManager-0.6.5.orig/configure.in 2007-07-23 19:44:13.000000000 +0200
3 +++ NetworkManager-0.6.5/configure.in 2007-07-23 20:09:37.000000000 +0200
8 - redhat|suse|gentoo|debian|slackware|arch) ;;
9 + redhat|suse|gentoo|debian|slackware|arch|pld) ;;
11 echo "Your distribution (${with_distro}) is not yet supported! (patches welcome)"
14 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
15 AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
16 AM_CONDITIONAL(TARGET_ARCH, test x"$with_distro" = xarch)
17 +AM_CONDITIONAL(TARGET_PLD, test x"$with_distro" = xpld)
19 AC_MSG_CHECKING([for wireless-tools >= 28pre9])
20 AC_TRY_COMPILE([#include <iwlib.h>],
21 diff -urN NetworkManager-0.6.5.orig/src/backends/Makefile.am NetworkManager-0.6.5/src/backends/Makefile.am
22 --- NetworkManager-0.6.5.orig/src/backends/Makefile.am 2007-07-23 19:44:13.000000000 +0200
23 +++ NetworkManager-0.6.5/src/backends/Makefile.am 2007-07-23 20:12:37.000000000 +0200
25 libnmbackend_la_SOURCES += NetworkManagerArch.c
29 +libnmbackend_la_SOURCES += NetworkManagerPLD.c \
34 libnmbackend_la_LIBADD = $(DBUS_LIBS) $(GTHREAD_LIBS)
35 libnmbackend_la_CPPFLAGS = $(DBUS_CFLAGS) \
37 diff -urN NetworkManager-0.6.5.orig/src/backends/NetworkManagerPLD.c NetworkManager-0.6.5/src/backends/NetworkManagerPLD.c
38 --- NetworkManager-0.6.5.orig/src/backends/NetworkManagerPLD.c 1970-01-01 01:00:00.000000000 +0100
39 +++ NetworkManager-0.6.5/src/backends/NetworkManagerPLD.c 2007-10-29 23:09:06.000000000 +0100
41 +/* NetworkManager -- Network link manager
43 + * Narayan Newton <narayan_newton@yahoo.com>
45 + * This program is free software; you can redistribute it and/or modify
46 + * it under the terms of the GNU General Public License as published by
47 + * the Free Software Foundation; either version 2 of the License, or
48 + * (at your option) any later version.
50 + * This program is distributed in the hope that it will be useful,
51 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
52 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53 + * GNU General Public License for more details.
55 + * You should have received a copy of the GNU General Public License
56 + * along with this program; if not, write to the Free Software
57 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
59 + * (C) Copyright 2004 RedHat, Inc.
60 + * (C) Copyright 2004 Narayan Newton
61 + * (C) Copyright 2005 wrobell <wrobell@pld-linux.org>
62 + * (C) Copyright 2005 Patryk Zawadzki <patrys@pld-linux.org>
63 + * (C) Copyright 2007 Marcin Banasiak <megabajt@pld-linux.org>
67 +#include <sys/types.h>
69 +#include "NetworkManagerSystem.h"
70 +#include "NetworkManagerUtils.h"
71 +#include "nm-device.h"
72 +#include "nm-device-802-3-ethernet.h"
73 +#include "nm-device-802-11-wireless.h"
74 +#include "nm-utils.h"
80 + * Initializes the distribution-specific system backend
83 +void nm_system_init (void)
85 + /* Kill any dhclients lying around */
86 + nm_system_kill_all_dhcp_daemons();
90 + * nm_system_device_flush_routes
92 + * Flush all routes associated with a network device
95 +void nm_system_device_flush_routes (NMDevice *dev)
97 + g_return_if_fail (dev != NULL);
99 + /* Not really applicable for test devices */
100 + if (nm_device_is_test_device (dev))
103 + nm_system_device_flush_routes_with_iface (nm_device_get_iface (dev));
107 + * nm_system_device_flush_routes_with_iface
109 + * Flush all routes associated with a network device
112 +void nm_system_device_flush_routes_with_iface (const char *iface)
116 + g_return_if_fail (iface != NULL);
118 + /* Remove routing table entries */
119 + buf = g_strdup_printf (IP_BINARY_PATH" route flush dev %s", iface);
120 + nm_spawn_process (buf);
125 + * nm_system_device_flush_addresses
127 + * Flush all network addresses associated with a network device
130 +void nm_system_device_flush_addresses (NMDevice *dev)
132 + g_return_if_fail (dev != NULL);
134 + /* Not really applicable for test devices */
135 + if (nm_device_is_test_device (dev))
137 + nm_system_device_flush_addresses_with_iface (nm_device_get_iface (dev));
141 + * nm_system_device_flush_addresses_with_iface
143 + * Flush all network addresses associated with a network device
146 +void nm_system_device_flush_addresses_with_iface (const char *iface)
150 + g_return_if_fail (iface != NULL);
152 + /* Remove all IP addresses for a device */
153 + buf = g_strdup_printf (IP_BINARY_PATH" addr flush dev %s", iface);
154 + nm_spawn_process (buf);
158 +typedef struct PLDSystemConfigData
160 + NMIP4Config *config;
162 +} PLDSystemConfigData;
165 + * set_ip4_config_from_resolv_conf
167 + * Add nameservers and search names from a resolv.conf format file.
170 +static void set_ip4_config_from_resolv_conf (const char *filename, NMIP4Config *ip4_config)
172 + char *contents = NULL;
173 + char **split_contents = NULL;
176 + g_return_if_fail (filename != NULL);
177 + g_return_if_fail (ip4_config != NULL);
179 + if (!g_file_get_contents (filename, &contents, NULL, NULL) || (contents == NULL))
182 + if (!(split_contents = g_strsplit (contents, "\n", 0)))
185 + len = g_strv_length (split_contents);
186 + for (i = 0; i < len; i++)
188 + char *line = split_contents[i];
190 + /* Ignore comments */
191 + if (!line || (line[0] == ';') || (line[0] == '#'))
194 + line = g_strstrip (line);
195 + if ((strncmp (line, "search", 6) == 0) && (strlen (line) > 6))
197 + char *searches = g_strdup (line + 7);
198 + char **split_searches = NULL;
200 + if (!searches || !strlen (searches))
203 + /* Allow space-separated search domains */
204 + if ((split_searches = g_strsplit (searches, " ", 0)))
208 + srch_len = g_strv_length (split_searches);
209 + for (m = 0; m < srch_len; m++)
211 + if (split_searches[m])
212 + nm_ip4_config_add_domain (ip4_config, split_searches[m]);
214 + g_strfreev (split_searches);
218 + /* Only 1 item, add the whole line */
219 + nm_ip4_config_add_domain (ip4_config, searches);
224 + else if ((strncmp (line, "nameserver", 10) == 0) && (strlen (line) > 10))
226 + guint32 addr = (guint32) (inet_addr (line + 11));
228 + if (addr != (guint32) -1)
229 + nm_ip4_config_add_nameserver (ip4_config, addr);
233 + g_strfreev (split_contents);
240 + * nm_system_device_get_system_config
242 + * Retrieve any relevant configuration info for a particular device
243 + * from the system network configuration information. Clear out existing
244 + * info before setting stuff too.
247 +void *nm_system_device_get_system_config (NMDevice *dev, NMData *app_data)
249 + char *cfg_file_path = NULL;
250 + shvarFile *file, *gateway_file;
252 + int i, ip[4], prefix;
253 + PLDSystemConfigData *sys_data = NULL;
254 + gboolean error = FALSE;
256 + g_return_val_if_fail (dev != NULL, NULL);
258 + /* PLD stores this information in
259 + * /etc/sysconfig/interfaces/ifcfg-* where * is the interface
263 + sys_data = g_malloc0 (sizeof (PLDSystemConfigData));
264 + sys_data->use_dhcp = TRUE;
266 + cfg_file_path = g_strdup_printf (SYSCONFDIR"/sysconfig/interfaces/ifcfg-%s", nm_device_get_iface (dev));
267 + if (!cfg_file_path)
270 + if (!(file = svNewFile (cfg_file_path)))
272 + g_free (cfg_file_path);
275 + g_free (cfg_file_path);
277 + /* Make sure this config file is for this device */
278 + buf = svGetValue (file, "DEVICE");
279 + if (!buf || strcmp (buf, nm_device_get_iface (dev)))
285 + if ((buf = svGetValue (file, "BOOTPROTO")))
287 + if (strcasecmp (buf, "dhcp"))
288 + sys_data->use_dhcp = FALSE;
292 + sys_data->config = nm_ip4_config_new ();
294 + if (!(sys_data->use_dhcp))
296 + if ((buf = svGetValue (file, "IPADDR")))
298 + sscanf (buf, "%d.%d.%d.%d/%d", &ip[0], &ip[1], &ip[2], &ip[3], &prefix);
299 + sprintf (buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
300 + nm_ip4_config_set_address (sys_data->config, inet_addr (buf));
302 + if (prefix >= 0 && prefix <= 32)
304 + for (i = 0; i <= 3; i++)
339 + prefix = prefix - 8;
341 + sprintf (buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
342 + nm_ip4_config_set_netmask (sys_data->config, inet_addr (buf));
347 + nm_warning ("Prefix for device '%s' was invalid (should be between 0 and 32). "
348 + "Try to make default. ", nm_device_get_iface (dev));
350 + guint32 addr = nm_ip4_config_get_address (sys_data->config);
352 + if (((ntohl (addr) & 0xFF000000) >> 24) <= 127)
353 + nm_ip4_config_set_netmask (sys_data->config, htonl (0xFF000000));
354 + else if (((ntohl (addr) & 0xFF000000) >> 24) <= 191)
355 + nm_ip4_config_set_netmask (sys_data->config, htonl (0xFFFF0000));
357 + nm_ip4_config_set_netmask (sys_data->config, htonl (0xFFFFFF00));
362 + nm_warning ("Network configuration for device '%s' was invalid (non-DHCP configuration, "
363 + "but no IP address specified. Will use DHCP instead.", nm_device_get_iface (dev));
368 + if (gateway_file = svNewFile (SYSCONFDIR"/sysconfig/network"))
370 + buf = svGetValue (gateway_file, "GATEWAYDEV");
372 + /* Make sure that GATEWAY is set for this device */
373 + if (!buf || strcmp (buf, nm_device_get_iface (dev)))
375 + nm_warning ("Network configuration for device '%s' was invalid (non-DHCP configuration, "
376 + "but no gateway specified - GATEWAYDEV set for other device or unset). Will "
377 + "use DHCP instead.", nm_device_get_iface (dev));
380 + svCloseFile (gateway_file);
385 + if ((buf = svGetValue (gateway_file, "GATEWAY")))
387 + nm_ip4_config_set_gateway (sys_data->config, inet_addr (buf));
389 + svCloseFile (gateway_file);
393 + nm_warning ("Network configuration for device '%s' was invalid (non-DHCP configuration, "
394 + "but no gateway specified. Will use DHCP instead.", nm_device_get_iface (dev));
395 + svCloseFile (gateway_file);
401 + if ((buf = svGetValue (file, "BROADCAST")))
403 + nm_ip4_config_set_broadcast (sys_data->config, inet_addr (buf));
408 + guint32 broadcast = ((nm_ip4_config_get_address (sys_data->config) & nm_ip4_config_get_netmask (sys_data->config))
409 + | ~nm_ip4_config_get_netmask (sys_data->config));
410 + nm_ip4_config_set_broadcast (sys_data->config, broadcast);
414 + /* If we're using Static IP, grab DNS servers from the config file */
415 + if (!sys_data->use_dhcp)
417 + set_ip4_config_from_resolv_conf (SYSCONFDIR"/resolv.conf", sys_data->config);
421 + svCloseFile (file);
425 + sys_data->use_dhcp = TRUE;
426 + /* Clear out the config */
427 + nm_ip4_config_unref (sys_data->config);
428 + sys_data->config = NULL;
431 + return (void *)sys_data;
435 + * nm_system_device_has_active_routes
437 + * Find out whether the specified device has any routes in the routing
441 +gboolean nm_system_device_has_active_routes (NMDevice *dev)
447 + * nm_system_enable_loopback
449 + * Bring up the loopback interface
452 +void nm_system_enable_loopback (void)
454 + nm_system_device_set_up_down_with_iface ("lo", TRUE);
455 + nm_spawn_process (IP_BINARY_PATH" addr add 127.0.0.1/8 brd 127.255.255.255 dev lo scope host label loopback");
459 + * nm_system_delete_default_route
461 + * Remove the old default route in preparation for a new one
464 +void nm_system_delete_default_route (void)
466 + nm_spawn_process (IP_BINARY_PATH" route del default");
470 + * nm_system_kill_all_dhcp_daemons
472 + * Kill all DHCP daemons currently running, done at startup.
475 +void nm_system_kill_all_dhcp_daemons (void)
477 + nm_spawn_process ("/bin/killall -q dhclient");
481 + * nm_system_update_dns
483 + * Make glibc/nscd aware of any changes to the resolv.conf file by
487 +void nm_system_update_dns (void)
489 + /* I'm not running nscd */
493 + * nm_system_restart_mdns_responder
495 + * Restart the multicast DNS responder so that it knows about new
496 + * network interfaces and IP addresses.
499 +void nm_system_restart_mdns_responder (void)
501 + /* not implemented */
505 + * nm_system_device_add_ip6_link_address
507 + * Add a default link-local IPv6 address to a device.
510 +void nm_system_device_add_ip6_link_address (NMDevice *dev)
513 + struct ether_addr hw_addr;
514 + unsigned char eui[8];
516 + nm_device_get_hw_address (dev, &hw_addr);
517 + memcpy (eui, &(hw_addr.ether_addr_octet), sizeof (hw_addr.ether_addr_octet));
518 + memmove (eui+5, eui+3, 3);
523 + /* Add the default link-local IPv6 address to a device */
524 + buf = g_strdup_printf (IP_BINARY_PATH" -6 addr add fe80::%x%02x:%x%02x:%x%02x:%x%02x/64 dev %s",
525 + eui[0], eui[1], eui[2], eui[3], eui[4], eui[5],
526 + eui[6], eui[7], nm_device_get_iface (dev));
527 + nm_spawn_process (buf);
532 + * nm_system_device_add_route_via_device_with_iface
534 + * Add route to the given device
537 +void nm_system_device_add_route_via_device_with_iface (const char *iface, const char *route)
541 + g_return_if_fail (iface != NULL);
543 + /* Add default gateway */
544 + buf = g_strdup_printf (IP_BINARY_PATH" route add %s dev %s", route, iface);
545 + nm_spawn_process (buf);
550 + * nm_system_device_add_default_route_via_device
552 + * Flush all routes associated with a network device
555 +void nm_system_device_add_default_route_via_device (NMDevice *dev)
557 + g_return_if_fail (dev != NULL);
559 + /* Not really applicable for test devices */
560 + if (nm_device_is_test_device (dev))
563 + nm_system_device_add_default_route_via_device_with_iface (nm_device_get_iface (dev));
567 + * * nm_system_device_add_default_route_via_device_with_iface
569 + * * Add default route to the given device
572 +void nm_system_device_add_default_route_via_device_with_iface (const char *iface)
576 + g_return_if_fail (iface != NULL);
578 + /* Add default gateway */
579 + buf = g_strdup_printf (IP_BINARY_PATH" route add default dev %s", iface);
580 + nm_spawn_process (buf);
585 + * nm_system_flush_loopback_routes
587 + * Flush all routes associated with the loopback device, because it
588 + * sometimes gets the first route for ZeroConf/Link-Local traffic.
591 +void nm_system_flush_loopback_routes (void)
593 + /* Remove routing table entries for lo */
594 + nm_spawn_process (IP_BINARY_PATH" route flush dev lo");
598 + * nm_system_flush_arp_cache
600 + * Flush all entries in the arp cache.
603 +void nm_system_flush_arp_cache (void)
605 + nm_spawn_process (IP_BINARY_PATH" neigh flush all");
608 +void nm_system_deactivate_all_dialup (GSList *list)
612 +gboolean nm_system_deactivate_dialup (GSList *list, const char *dialup)
617 +gboolean nm_system_activate_dialup (GSList *list, const char *dialup)
623 + * nm_system_get_dialup_config
625 + * Enumerate dial up options on this system, allocate NMDialUpConfig's,
626 + * fill them out, and return.
629 +GSList * nm_system_get_dialup_config (void)
634 +void nm_system_device_free_system_config (NMDevice *dev, void *system_config_data)
636 + PLDSystemConfigData *sys_data = (PLDSystemConfigData *)system_config_data;
638 + g_return_if_fail (dev != NULL);
643 + if (sys_data->config)
644 + nm_ip4_config_unref (sys_data->config);
647 +NMIP4Config *nm_system_device_new_ip4_system_config (NMDevice *dev)
649 + PLDSystemConfigData *sys_data;
650 + NMIP4Config *new_config = NULL;
652 + g_return_val_if_fail (dev != NULL, NULL);
654 + if ((sys_data = nm_device_get_system_config_data (dev)))
655 + new_config = nm_ip4_config_copy (sys_data->config);
660 +gboolean nm_system_device_get_use_dhcp (NMDevice *dev)
662 + PLDSystemConfigData *sys_data;
664 + g_return_val_if_fail (dev != NULL, TRUE);
666 + if ((sys_data = nm_device_get_system_config_data (dev)))
667 + return sys_data->use_dhcp;
673 + * nm_system_device_get_disabled
675 + * Return whether the distro-specific system config tells us to use
676 + * dhcp for this device.
679 +gboolean nm_system_device_get_disabled (NMDevice *dev)
685 + * nm_system_activate_nis
687 + * set up the nis domain and write a yp.conf
690 +void nm_system_activate_nis (NMIP4Config *config)
695 + * nm_system_shutdown_nis
700 +void nm_system_shutdown_nis (void)
705 + * nm_system_set_hostname
710 +void nm_system_set_hostname (NMIP4Config *config)
715 + * nm_system_should_modify_resolv_conf
717 + * Can NM update resolv.conf, or is it locked down?
719 +gboolean nm_system_should_modify_resolv_conf (void)
726 + * nm_system_get_mtu
728 + * Return a user-provided or system-mandated MTU for this device or zero if
729 + * no such MTU is provided.
731 +unsigned int nm_system_get_mtu (NMDevice *dev)