NetworkManager/src/nm-ip4-config.c

989 lines
25 KiB
C
Raw Normal View History

2008-09-18 Dan Williams <dcbw@redhat.com> Implement support for honoring configured and automatic hostnames, and for setting the configured hostname. * introspection/nm-ip4-config.xml src/nm-ip4-config.c src/nm-ip4-config.h src/dhcp-manager/nm-dhcp-manager.c - Remove useless hostname property; it's not really part of the IPv4 config * introspection/nm-settings-system.xml libnm-glib/nm-dbus-settings-system.c libnm-glib/nm-dbus-settings-system.h - Add SetHostname() call to system settings D-Bus interface - Add Hostname property to system settings D-Bus interface - (nm_dbus_settings_system_save_hostname, nm_dbus_settings_system_get_hostname): implement * src/nm-device.c src/nm-device.h - (nm_device_get_dhcp4_config): implement * src/nm-manager.c src/nm-manager.h - Fetch and track system settings service hostname changes, and proxy the changes via a GObject property of the manager * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - Replace nm_system_config_interface_supports_add() with a capabilities bitfield * system-settings/src/nm-system-config-error.c system-settings/src/nm-system-config-error.h - Add additional errors * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - (get_property, nm_sysconfig_settings_class_init): add hostname property; first plugin returning a hostname wins - (impl_settings_add_connection): use plugin capabilities instead of nm_system_config_interface_supports_add() - (impl_settings_save_hostname): implement hostname saving * src/NetworkManagerPolicy.c - (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new, lookup_thread_die): implement an asynchronous hostname lookup thread which given an IPv4 address tries to look up the hostname for that address with reverse DNS - (get_best_device): split out best device code from update_routing_and_dns() - (update_etc_hosts): update /etc/hosts with the machine's new hostname to preserve the 127.0.0.1 reverse mapping that so many things require - (set_system_hostname): set a given hostname - (update_system_hostname): implement hostname policy; a configured hostname (from the system settings service) is used if available, otherwise an automatically determined hostname from DHCP, VPN, etc. If there was no automatically determined hostname, reverse DNS of the best device's IP address will be used, and as a last resort the hostname 'localhost.localdomain' is set. - (update_routing_and_dns): use get_best_device(); update the system hostname when the network config changes - (hostname_changed): update system hostname if the system settings service signals a hostname change - (nm_policy_new): list for system settings service hostname changes - (nm_policy_destroy): ensure that an in-progress hostname lookup thread gets told to die * system-settings/plugins/keyfile/plugin.c system-settings/plugins/ifcfg-suse/plugin.c - (get_property, sc_plugin_ifcfg_class_init): implement hostname and capabilities properties * system-settings/plugins/ifcfg-fedora/shvar.c - (svOpenFile): re-enable R/W access of ifcfg files since the plugin writes out /etc/sysconfig/network now * system-settings/plugins/ifcfg-fedora/plugin.c - (plugin_get_hostname): get hostname from /etc/sysconfig/network - (plugin_set_hostname): save hostname to /etc/sysconfig/network - (sc_network_changed_cb): handle changes to /etc/sysconfig/network - (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes - (get_property, set_property, sc_plugin_ifcfg_class_init): implement hostname get/set and capabilities get git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2013-07-12 11:33:52 +02:00
/* NetworkManager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
2013-07-12 11:33:52 +02:00
* Copyright (C) 2005 - 2013 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
#include <string.h>
2013-07-12 11:33:52 +02:00
#include "nm-ip4-config.h"
2013-07-12 11:33:52 +02:00
#include "gsystem-local-alloc.h"
#include "nm-platform.h"
#include "nm-utils.h"
2013-07-12 11:33:52 +02:00
#include "nm-dbus-manager.h"
#include "nm-dbus-glib-types.h"
2013-07-12 11:33:52 +02:00
#include "nm-ip4-config-glue.h"
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, G_TYPE_OBJECT)
#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
typedef struct {
char *path;
2013-07-12 11:33:52 +02:00
gboolean never_default;
guint32 gateway;
GArray *addresses;
2013-07-12 11:33:52 +02:00
GSList *routes;
GArray *nameservers;
GPtrArray *domains;
GPtrArray *searches;
2013-07-12 11:33:52 +02:00
guint32 mss;
guint32 ptp_address;
2010-07-16 11:28:39 -07:00
GArray *nis;
2013-07-12 11:33:52 +02:00
char *nis_domain;
GArray *wins;
guint32 mtu;
} NMIP4ConfigPrivate;
enum {
PROP_0,
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
PROP_ADDRESSES,
PROP_NAMESERVERS,
PROP_DOMAINS,
PROP_ROUTES,
PROP_WINS_SERVERS,
LAST_PROP
};
NMIP4Config *
nm_ip4_config_new (void)
{
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, NULL);
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_export (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
static guint32 counter = 0;
2013-07-12 11:33:52 +02:00
if (!priv->path) {
priv->path = g_strdup_printf (NM_DBUS_PATH "/IP4Config/%d", counter++);
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, config);
}
}
const char *
nm_ip4_config_get_dbus_path (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return priv->path;
}
static gboolean
same_prefix (guint32 address1, guint32 address2, int plen)
{
guint32 masked1 = ntohl (address1) >> (32 - plen);
guint32 masked2 = ntohl (address2) >> (32 - plen);
2013-07-12 11:33:52 +02:00
return masked1 == masked2;
}
/******************************************************************/
NMIP4Config *
nm_ip4_config_capture (int ifindex)
{
NMIP4Config *config = nm_ip4_config_new ();
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
GArray *routes_array;
NMPlatformIP4Route *routes;
NMIP4Route *route;
int i;
g_array_unref (priv->addresses);
priv->addresses = nm_platform_ip4_address_get_all (ifindex);
/* Require at least one IP address. */
if (!priv->addresses->len) {
g_object_unref (config);
return NULL;
}
routes_array = nm_platform_ip4_route_get_all (ifindex);
routes = (NMPlatformIP4Route *)routes_array->data;
for (i = 0; i < routes_array->len; i++) {
/* Default route ignored; it's handled internally by NM and not
* tracked in the device's IP config.
*/
if (routes[i].plen == 0)
continue;
route = nm_ip4_route_new ();
nm_ip4_route_set_dest (route, routes[i].network);
nm_ip4_route_set_prefix (route, routes[i].plen);
nm_ip4_route_set_next_hop (route, routes[i].gateway);
nm_ip4_route_set_metric (route, routes[i].metric);
2013-07-12 11:33:52 +02:00
nm_ip4_config_take_route (config, route);
}
g_array_unref (routes_array);
2013-07-12 11:33:52 +02:00
return config;
}
gboolean
nm_ip4_config_commit (NMIP4Config *config, int ifindex, int priority)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
/* Addresses */
nm_platform_ip4_address_sync (ifindex, priv->addresses);
/* Routes */
{
int count = nm_ip4_config_get_num_routes (config);
NMIP4Route *config_route;
GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Route), count);
NMPlatformIP4Route route;
for (i = 0; i < count; i++) {
config_route = nm_ip4_config_get_route (config, i);
memset (&route, 0, sizeof (route));
route.network = nm_ip4_route_get_dest (config_route);
route.plen = nm_ip4_route_get_prefix (config_route);
route.gateway = nm_ip4_route_get_next_hop (config_route);
route.metric = priority;
/* Don't add the route if it's more specific than one of the subnets
* the device already has an IP address on.
*/
if (nm_ip4_config_destination_is_direct (config, route.network, route.plen))
continue;
/* Don't add the default route when and the connection
* is never supposed to be the default connection.
*/
if (nm_ip4_config_get_never_default (config) && route.network == 0)
continue;
g_array_append_val (routes, route);
}
nm_platform_ip4_route_sync (ifindex, routes);
g_array_unref (routes);
}
/* MTU */
if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
nm_platform_link_set_mtu (ifindex, mtu);
return TRUE;
}
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting)
{
2013-07-12 11:33:52 +02:00
guint naddresses, nroutes, nnameservers, nsearches;
int i;
if (!setting)
2013-07-12 11:33:52 +02:00
return;
naddresses = nm_setting_ip4_config_get_num_addresses (setting);
nroutes = nm_setting_ip4_config_get_num_routes (setting);
nnameservers = nm_setting_ip4_config_get_num_dns (setting);
nsearches = nm_setting_ip4_config_get_num_dns_searches (setting);
/* Gateway */
if (nm_setting_ip4_config_get_never_default (setting))
nm_ip4_config_set_never_default (config, TRUE);
else if (nm_setting_ip4_config_get_ignore_auto_routes (setting))
nm_ip4_config_set_never_default (config, FALSE);
for (i = 0; i < naddresses; i++) {
guint32 gateway = nm_ip4_address_get_gateway (nm_setting_ip4_config_get_address (setting, i));
if (gateway) {
nm_ip4_config_set_gateway (config, gateway);
break;
}
}
2013-07-12 11:33:52 +02:00
/* Addresses */
for (i = 0; i < naddresses; i++) {
NMIP4Address *s_addr = nm_setting_ip4_config_get_address (setting, i);
NMPlatformIP4Address address;
memset (&address, 0, sizeof (address));
address.address = nm_ip4_address_get_address (s_addr);
address.plen = nm_ip4_address_get_prefix (s_addr);
nm_ip4_config_add_address (config, &address);
}
2013-07-12 11:33:52 +02:00
/* Routes */
if (nm_setting_ip4_config_get_ignore_auto_routes (setting))
2013-07-12 11:33:52 +02:00
nm_ip4_config_reset_routes (config);
for (i = 0; i < nroutes; i++)
nm_ip4_config_add_route (config, nm_setting_ip4_config_get_route (setting, i));
/* DNS */
if (nm_setting_ip4_config_get_ignore_auto_dns (setting)) {
nm_ip4_config_reset_nameservers (config);
nm_ip4_config_reset_domains (config);
nm_ip4_config_reset_searches (config);
}
2013-07-12 11:33:52 +02:00
for (i = 0; i < nnameservers; i++)
nm_ip4_config_add_nameserver (config, nm_setting_ip4_config_get_dns (setting, i));
for (i = 0; i < nsearches; i++)
nm_ip4_config_add_search (config, nm_setting_ip4_config_get_dns_search (setting, i));
}
void
nm_ip4_config_update_setting (NMIP4Config *config, NMSettingIP4Config *setting)
{
guint32 gateway;
guint naddresses, nroutes, nnameservers, nsearches;
const char *method = NULL;
int i;
if (!config)
return;
gateway = nm_ip4_config_get_gateway (config);
naddresses = nm_ip4_config_get_num_addresses (config);
nroutes = nm_ip4_config_get_num_routes (config);
nnameservers = nm_ip4_config_get_num_nameservers (config);
nsearches = nm_ip4_config_get_num_searches (config);
/* Addresses */
for (i = 0; i < naddresses; i++) {
const NMPlatformIP4Address *address = nm_ip4_config_get_address (config, i);
gs_unref_object NMIP4Address *s_addr = nm_ip4_address_new ();
/* Static address found. */
if (!method)
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
nm_ip4_address_set_address (s_addr, address->address);
nm_ip4_address_set_prefix (s_addr, address->plen);
/* For backwards compatibility, attach the gateway to an address if it's
* in the same subnet.
*/
if (same_prefix (address->address, gateway, address->plen))
nm_ip4_address_set_gateway (s_addr, gateway);
nm_setting_ip4_config_add_address (setting, s_addr);
}
if (!method)
method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
g_object_set (setting, NM_SETTING_IP4_CONFIG_METHOD, method, NULL);
/* Routes */
for (i = 0; i < nroutes; i++) {
NMIP4Route *route = nm_ip4_config_get_route (config, i);
/* Ignore default route. */
if (!nm_ip4_route_get_prefix (route))
continue;
nm_setting_ip4_config_add_route (setting, route);
}
/* DNS */
for (i = 0; i < nnameservers; i++) {
guint32 nameserver = nm_ip4_config_get_nameserver (config, i);
nm_setting_ip4_config_add_dns (setting, nameserver);
}
for (i = 0; i < nsearches; i++) {
const char *search = nm_ip4_config_get_search (config, i);
nm_setting_ip4_config_add_dns_search (setting, search);
}
}
/******************************************************************/
gboolean
2013-07-12 11:33:52 +02:00
nm_ip4_config_destination_is_direct (NMIP4Config *config, guint32 network, int plen)
{
2013-07-12 11:33:52 +02:00
guint naddresses = nm_ip4_config_get_num_addresses (config);
int i;
2013-07-12 11:33:52 +02:00
for (i = 0; i < naddresses; i++) {
const NMPlatformIP4Address *item = nm_ip4_config_get_address (config, i);
if (item->plen <= plen && same_prefix (item->address, network, item->plen))
2013-07-12 11:33:52 +02:00
return TRUE;
}
return FALSE;
}
/******************************************************************/
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
priv->never_default = never_default;
}
2013-07-12 11:33:52 +02:00
gboolean
nm_ip4_config_get_never_default (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->never_default;
}
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
priv->gateway = gateway;
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_gateway (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->gateway;
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
void
nm_ip4_config_reset_addresses (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
g_array_set_size (priv->addresses, 0);
}
2013-07-12 11:33:52 +02:00
static gboolean
addresses_are_duplicate (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b)
{
return a->address == b->address;
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *new)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
g_return_if_fail (new != NULL);
for (i = 0; i < priv->addresses->len; i++ ) {
NMPlatformIP4Address *item = &g_array_index (priv->addresses, NMPlatformIP4Address, i);
2013-07-12 11:33:52 +02:00
if (addresses_are_duplicate (item, new)) {
memcpy (item, new, sizeof (*item));
2013-07-12 11:33:52 +02:00
return;
}
}
g_array_append_val (priv->addresses, *new);
}
2013-07-12 11:33:52 +02:00
guint
nm_ip4_config_get_num_addresses (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return priv->addresses->len;
}
const NMPlatformIP4Address *
2013-07-12 11:33:52 +02:00
nm_ip4_config_get_address (NMIP4Config *config, guint i)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return &g_array_index (priv->addresses, NMPlatformIP4Address, i);
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_reset_routes (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
priv->routes = NULL;
}
2013-07-12 11:33:52 +02:00
static gboolean
routes_are_duplicate (NMIP4Route *a, NMIP4Route *b)
{
2013-07-12 11:33:52 +02:00
if (nm_ip4_route_get_dest (a) != nm_ip4_route_get_dest (b))
return FALSE;
if (nm_ip4_route_get_prefix (a) != nm_ip4_route_get_prefix (b))
return FALSE;
2013-07-12 11:33:52 +02:00
return TRUE;
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_add_route (NMIP4Config *config, NMIP4Route *new)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
GSList *iter;
g_return_if_fail (new != NULL);
2013-07-12 11:33:52 +02:00
for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
NMIP4Route *item = (NMIP4Route *) iter->data;
2013-07-12 11:33:52 +02:00
if (routes_are_duplicate (item, new)) {
nm_ip4_route_unref (item);
iter->data = nm_ip4_route_dup (new);
return;
2013-07-12 11:33:52 +02:00
}
}
2013-07-12 11:33:52 +02:00
priv->routes = g_slist_append (priv->routes, nm_ip4_route_dup (new));
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_take_route (NMIP4Config *config, NMIP4Route *route)
{
g_return_if_fail (route != NULL);
2013-07-12 11:33:52 +02:00
nm_ip4_config_add_route (config, route);
nm_ip4_route_unref (route);
}
2013-07-12 11:33:52 +02:00
guint
nm_ip4_config_get_num_routes (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return g_slist_length (priv->routes);
}
2013-07-12 11:33:52 +02:00
NMIP4Route *
nm_ip4_config_get_route (NMIP4Config *config, guint i)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return (NMIP4Route *) g_slist_nth_data (priv->routes, i);
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_reset_nameservers (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
g_array_set_size (priv->nameservers, 0);
}
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 new)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
g_return_if_fail (new != 0);
2013-07-12 11:33:52 +02:00
for (i = 0; i < priv->nameservers->len; i++)
if (new == g_array_index (priv->nameservers, guint32, i))
return;
2013-07-12 11:33:52 +02:00
g_array_append_val (priv->nameservers, new);
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_num_nameservers (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->nameservers->len;
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_nameserver (NMIP4Config *config, guint i)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return g_array_index (priv->nameservers, guint32, i);
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_reset_domains (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
g_ptr_array_set_size (priv->domains, 0);
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_add_domain (NMIP4Config *config, const char *domain)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
g_return_if_fail (domain != NULL);
g_return_if_fail (domain[0] != '\0');
2013-07-12 11:33:52 +02:00
for (i = 0; i < priv->domains->len; i++)
if (!g_strcmp0 (g_ptr_array_index (priv->domains, i), domain))
return;
g_ptr_array_add (priv->domains, g_strdup (domain));
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_num_domains (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->domains->len;
}
2013-07-12 11:33:52 +02:00
const char *
nm_ip4_config_get_domain (NMIP4Config *config, guint i)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return g_ptr_array_index (priv->domains, i);
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_reset_searches (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
g_ptr_array_set_size (priv->searches, 0);
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_add_search (NMIP4Config *config, const char *new)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
g_return_if_fail (new != NULL);
g_return_if_fail (new[0] != '\0');
2013-07-12 11:33:52 +02:00
for (i = 0; i < priv->searches->len; i++)
if (!g_strcmp0 (g_ptr_array_index (priv->searches, i), new))
return;
2013-07-12 11:33:52 +02:00
g_ptr_array_add (priv->searches, g_strdup (new));
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_num_searches (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->searches->len;
}
2013-07-12 11:33:52 +02:00
const char *
nm_ip4_config_get_search (NMIP4Config *config, guint i)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return g_ptr_array_index (priv->searches, i);
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
void
nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
priv->mss = mss;
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_mss (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return priv->mss;
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
void
nm_ip4_config_set_ptp_address (NMIP4Config *config, guint32 ptp_addr)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
priv->ptp_address = ptp_addr;
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_ptp_address (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->ptp_address;
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
void
nm_ip4_config_reset_nis_servers (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
g_array_set_size (priv->nis, 0);
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
for (i = 0; i < priv->nis->len; i++)
if (nis == g_array_index (priv->nis, guint32, i))
return;
2013-07-12 11:33:52 +02:00
g_array_append_val (priv->nis, nis);
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_num_nis_servers (NMIP4Config *config)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
return priv->nis->len;
}
guint32
nm_ip4_config_get_nis_server (NMIP4Config *config, guint i)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return g_array_index (priv->nis, guint32, i);
}
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2013-07-12 11:33:52 +02:00
g_free (priv->nis_domain);
priv->nis_domain = g_strdup (domain);
}
2013-07-12 11:33:52 +02:00
const char *
nm_ip4_config_get_nis_domain (NMIP4Config *config)
2010-07-16 11:28:39 -07:00
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
return priv->nis_domain;
}
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
/******************************************************************/
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_reset_wins (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
g_array_set_size (priv->wins, 0);
2010-07-16 11:28:39 -07:00
}
2013-07-12 11:33:52 +02:00
void
nm_ip4_config_add_wins (NMIP4Config *config, guint32 wins)
2010-07-16 11:28:39 -07:00
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
int i;
g_return_if_fail (wins != 0);
2013-07-12 11:33:52 +02:00
for (i = 0; i < priv->wins->len; i++)
if (wins == g_array_index (priv->wins, guint32, i))
return;
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
g_array_append_val (priv->wins, wins);
2010-07-16 11:28:39 -07:00
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_num_wins (NMIP4Config *config)
2010-07-16 11:28:39 -07:00
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
return priv->wins->len;
2010-07-16 11:28:39 -07:00
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_wins (NMIP4Config *config, guint i)
2010-07-16 11:28:39 -07:00
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
return g_array_index (priv->wins, guint32, i);
2010-07-16 11:28:39 -07:00
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
2010-07-16 11:28:39 -07:00
void
2013-07-12 11:33:52 +02:00
nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu)
2010-07-16 11:28:39 -07:00
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
priv->mtu = mtu;
2010-07-16 11:28:39 -07:00
}
2013-07-12 11:33:52 +02:00
guint32
nm_ip4_config_get_mtu (NMIP4Config *config)
2010-07-16 11:28:39 -07:00
{
2013-07-12 11:33:52 +02:00
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
2010-07-16 11:28:39 -07:00
2013-07-12 11:33:52 +02:00
return priv->mtu;
2010-07-16 11:28:39 -07:00
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
static inline void
hash_u32 (GChecksum *sum, guint32 n)
{
g_checksum_update (sum, (const guint8 *) &n, sizeof (n));
}
void
nm_ip4_config_hash (NMIP4Config *config, GChecksum *sum, gboolean dns_only)
{
guint32 i, n;
const char *s;
g_return_if_fail (config);
g_return_if_fail (sum);
if (!dns_only) {
2013-07-12 11:33:52 +02:00
hash_u32 (sum, nm_ip4_config_get_gateway (config));
for (i = 0; i < nm_ip4_config_get_num_addresses (config); i++) {
const NMPlatformIP4Address *address = nm_ip4_config_get_address (config, i);
hash_u32 (sum, address->address);
hash_u32 (sum, address->plen);
}
for (i = 0; i < nm_ip4_config_get_num_routes (config); i++) {
NMIP4Route *r = nm_ip4_config_get_route (config, i);
hash_u32 (sum, nm_ip4_route_get_dest (r));
hash_u32 (sum, nm_ip4_route_get_prefix (r));
hash_u32 (sum, nm_ip4_route_get_next_hop (r));
hash_u32 (sum, nm_ip4_route_get_metric (r));
}
n = nm_ip4_config_get_ptp_address (config);
if (n)
hash_u32 (sum, n);
for (i = 0; i < nm_ip4_config_get_num_nis_servers (config); i++)
hash_u32 (sum, nm_ip4_config_get_nis_server (config, i));
s = nm_ip4_config_get_nis_domain (config);
if (s)
g_checksum_update (sum, (const guint8 *) s, strlen (s));
}
for (i = 0; i < nm_ip4_config_get_num_nameservers (config); i++)
hash_u32 (sum, nm_ip4_config_get_nameserver (config, i));
for (i = 0; i < nm_ip4_config_get_num_wins (config); i++)
hash_u32 (sum, nm_ip4_config_get_wins (config, i));
for (i = 0; i < nm_ip4_config_get_num_domains (config); i++) {
s = nm_ip4_config_get_domain (config, i);
g_checksum_update (sum, (const guint8 *) s, strlen (s));
}
for (i = 0; i < nm_ip4_config_get_num_searches (config); i++) {
s = nm_ip4_config_get_search (config, i);
g_checksum_update (sum, (const guint8 *) s, strlen (s));
}
}
gboolean
nm_ip4_config_equal (NMIP4Config *a, NMIP4Config *b)
{
GChecksum *a_checksum = g_checksum_new (G_CHECKSUM_SHA1);
GChecksum *b_checksum = g_checksum_new (G_CHECKSUM_SHA1);
gsize a_len = g_checksum_type_get_length (G_CHECKSUM_SHA1);
gsize b_len = g_checksum_type_get_length (G_CHECKSUM_SHA1);
guchar a_data[a_len], b_data[b_len];
gboolean equal;
if (a)
nm_ip4_config_hash (a, a_checksum, FALSE);
if (b)
nm_ip4_config_hash (b, b_checksum, FALSE);
g_checksum_get_digest (a_checksum, a_data, &a_len);
g_checksum_get_digest (b_checksum, b_data, &b_len);
g_assert (a_len == b_len);
equal = !memcmp (a_data, b_data, a_len);
g_checksum_free (a_checksum);
g_checksum_free (b_checksum);
return equal;
}
2013-07-12 11:33:52 +02:00
/******************************************************************/
static void
nm_ip4_config_init (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address));
2013-07-12 11:33:52 +02:00
priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
2010-07-16 11:28:39 -07:00
priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32));
2013-07-12 11:33:52 +02:00
priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32));
}
static void
finalize (GObject *object)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
g_array_unref (priv->addresses);
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
2013-07-12 11:33:52 +02:00
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_array_unref (priv->nis);
2010-07-16 11:28:39 -07:00
g_free (priv->nis_domain);
2013-07-12 11:33:52 +02:00
g_array_unref (priv->wins);
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMIP4Config *config = NM_IP4_CONFIG (object);
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
in_addr_t gateway = nm_ip4_config_get_gateway (config);
switch (prop_id) {
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
case PROP_ADDRESSES:
{
GPtrArray *addresses = g_ptr_array_new ();
int naddr = nm_ip4_config_get_num_addresses (config);
int i;
for (i = 0; i < naddr; i++) {
const NMPlatformIP4Address *address = nm_ip4_config_get_address (config, i);
GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
g_array_append_val (array, address->address);
g_array_append_val (array, address->plen);
g_array_append_val (array, gateway);
g_ptr_array_add (addresses, array);
}
g_value_take_boxed (value, addresses);
}
break;
2013-07-12 11:33:52 +02:00
case PROP_ROUTES:
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
break;
case PROP_NAMESERVERS:
g_value_set_boxed (value, priv->nameservers);
break;
case PROP_DOMAINS:
g_value_set_boxed (value, priv->domains);
break;
case PROP_WINS_SERVERS:
g_value_set_boxed (value, priv->wins);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate));
object_class->get_property = get_property;
object_class->finalize = finalize;
g_object_class_install_property
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
(object_class, PROP_ADDRESSES,
g_param_spec_boxed (NM_IP4_CONFIG_ADDRESSES,
2013-07-12 11:33:52 +02:00
"Addresses",
"IP4 addresses",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_ROUTES,
g_param_spec_boxed (NM_IP4_CONFIG_ROUTES,
"Routes",
"Routes",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_NAMESERVERS,
g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS,
2013-07-12 11:33:52 +02:00
"Nameservers",
"DNS list",
DBUS_TYPE_G_UINT_ARRAY,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_DOMAINS,
g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS,
2013-07-12 11:33:52 +02:00
"Domains",
"Domains",
DBUS_TYPE_G_ARRAY_OF_STRING,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_WINS_SERVERS,
g_param_spec_boxed (NM_IP4_CONFIG_WINS_SERVERS,
2013-07-12 11:33:52 +02:00
"WinsServers",
"WINS server list",
DBUS_TYPE_G_UINT_ARRAY,
G_PARAM_READABLE));
2013-07-12 11:33:52 +02:00
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (config_class), &dbus_glib_nm_ip4_config_object_info);
}