2005-04-15 15:43:42 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* Dan Williams <dcbw@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* (C) Copyright 2005 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "NetworkManager.h"
|
2005-12-04 02:23:29 +00:00
|
|
|
#include "NetworkManagerUtils.h"
|
2005-04-15 15:43:42 +00:00
|
|
|
#include "nm-ip4-config.h"
|
|
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
#include <netlink/route/addr.h>
|
|
|
|
|
#include <netlink/utils.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
struct NMIP4Config
|
|
|
|
|
{
|
|
|
|
|
guint refcount;
|
2006-01-16 22:58:13 +00:00
|
|
|
|
2006-03-17 18:40:00 +00:00
|
|
|
guint32 ip4_address;
|
2006-01-16 22:58:13 +00:00
|
|
|
guint32 ip4_ptp_address;
|
2005-04-15 15:43:42 +00:00
|
|
|
guint32 ip4_gateway;
|
|
|
|
|
guint32 ip4_netmask;
|
|
|
|
|
guint32 ip4_broadcast;
|
2006-01-16 22:58:13 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
guint32 mtu; /* Maximum Transmission Unit of the interface */
|
|
|
|
|
guint32 mss; /* Maximum Segment Size of the route */
|
|
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
GSList * nameservers;
|
|
|
|
|
GSList * domains;
|
|
|
|
|
|
2006-03-17 18:37:46 +00:00
|
|
|
gchar * hostname;
|
2005-12-14 16:23:15 +00:00
|
|
|
gchar * nis_domain;
|
|
|
|
|
GSList * nis_servers;
|
2005-12-13 21:03:57 +00:00
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
/* If this is a VPN/etc config that requires
|
|
|
|
|
* another device (like Ethernet) to already have
|
|
|
|
|
* an IP4Config before it can be used.
|
|
|
|
|
*/
|
|
|
|
|
gboolean secondary;
|
2005-04-15 15:43:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NMIP4Config *nm_ip4_config_new (void)
|
|
|
|
|
{
|
2006-08-04 15:46:06 +00:00
|
|
|
NMIP4Config *config = g_slice_new0 (NMIP4Config);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
config->refcount = 1;
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
|
|
|
|
|
{
|
|
|
|
|
NMIP4Config * dst_config;
|
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (src_config != NULL, NULL);
|
|
|
|
|
|
2006-08-04 15:46:06 +00:00
|
|
|
dst_config = g_slice_new0 (NMIP4Config);
|
2005-04-15 15:43:42 +00:00
|
|
|
dst_config->refcount = 1;
|
|
|
|
|
|
|
|
|
|
dst_config->ip4_address = nm_ip4_config_get_address (src_config);
|
2006-01-16 22:58:13 +00:00
|
|
|
dst_config->ip4_ptp_address = nm_ip4_config_get_ptp_address (src_config);
|
2005-04-15 15:43:42 +00:00
|
|
|
dst_config->ip4_gateway = nm_ip4_config_get_gateway (src_config);
|
|
|
|
|
dst_config->ip4_netmask = nm_ip4_config_get_netmask (src_config);
|
|
|
|
|
dst_config->ip4_broadcast = nm_ip4_config_get_broadcast (src_config);
|
|
|
|
|
|
2006-01-23 21:02:39 +00:00
|
|
|
dst_config->hostname = g_strdup (nm_ip4_config_get_hostname (src_config));
|
2005-12-14 16:23:15 +00:00
|
|
|
dst_config->nis_domain = g_strdup (nm_ip4_config_get_nis_domain (src_config));
|
2005-12-13 21:03:57 +00:00
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
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));
|
|
|
|
|
|
2005-12-13 21:03:57 +00:00
|
|
|
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));
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
return dst_config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_ref (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->refcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_unref (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->refcount--;
|
|
|
|
|
if (config->refcount <= 0)
|
|
|
|
|
{
|
2006-01-23 21:02:39 +00:00
|
|
|
g_free (config->hostname);
|
2005-12-13 21:03:57 +00:00
|
|
|
g_free (config->nis_domain);
|
2005-04-15 15:43:42 +00:00
|
|
|
g_slist_free (config->nameservers);
|
2005-09-28 14:42:57 +00:00
|
|
|
g_slist_foreach (config->domains, (GFunc) g_free, NULL);
|
2005-04-15 15:43:42 +00:00
|
|
|
g_slist_free (config->domains);
|
2005-12-13 21:03:57 +00:00
|
|
|
g_slist_free (config->nis_servers);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
memset (config, 0, sizeof (NMIP4Config));
|
2006-08-04 15:46:06 +00:00
|
|
|
g_slice_free (NMIP4Config, config);
|
2005-04-15 15:43:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
gboolean nm_ip4_config_get_secondary (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return config->secondary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_secondary (NMIP4Config *config, gboolean secondary)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->secondary = secondary;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
guint32 nm_ip4_config_get_address (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->ip4_address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_address (NMIP4Config *config, guint32 addr)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->ip4_address = addr;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-16 22:58:13 +00:00
|
|
|
guint32 nm_ip4_config_get_ptp_address (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->ip4_ptp_address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_ptp_address (NMIP4Config *config, guint32 ptp_addr)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->ip4_ptp_address = ptp_addr;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
guint32 nm_ip4_config_get_gateway (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->ip4_gateway;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->ip4_gateway = gateway;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 nm_ip4_config_get_netmask (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->ip4_netmask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_netmask (NMIP4Config *config, guint32 netmask)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->ip4_netmask = netmask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 nm_ip4_config_get_broadcast (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->ip4_broadcast;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_broadcast (NMIP4Config *config, guint32 broadcast)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->ip4_broadcast = broadcast;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 nameserver)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
2006-08-07 18:09:16 +00:00
|
|
|
if (nameserver != 0)
|
|
|
|
|
config->nameservers = g_slist_append (config->nameservers, GINT_TO_POINTER (nameserver));
|
2005-04-15 15:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
guint32 nm_ip4_config_get_nameserver (NMIP4Config *config, guint i)
|
2005-04-15 15:43:42 +00:00
|
|
|
{
|
2005-10-17 19:04:01 +00:00
|
|
|
guint nameserver;
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
g_return_val_if_fail (i < g_slist_length (config->nameservers), 0);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
if ((nameserver = GPOINTER_TO_UINT (g_slist_nth_data (config->nameservers, i))))
|
2005-09-28 14:42:57 +00:00
|
|
|
return nameserver;
|
2005-04-15 15:43:42 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 nm_ip4_config_get_num_nameservers (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return (g_slist_length (config->nameservers));
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-13 21:03:57 +00:00
|
|
|
void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->nis_servers = g_slist_append (config->nis_servers, GINT_TO_POINTER (nis_server));
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i)
|
2005-12-13 21:03:57 +00:00
|
|
|
{
|
|
|
|
|
guint nis_server;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
g_return_val_if_fail (i < g_slist_length (config->nis_servers), 0);
|
2005-12-13 21:03:57 +00:00
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
if ((nis_server = GPOINTER_TO_UINT (g_slist_nth_data (config->nis_servers, i))))
|
2005-12-13 21:03:57 +00:00
|
|
|
return nis_server;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return (g_slist_length (config->nis_servers));
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
g_return_if_fail (domain != NULL);
|
|
|
|
|
|
|
|
|
|
if (!strlen (domain))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
config->domains = g_slist_append (config->domains, g_strdup (domain));
|
2005-04-15 15:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-23 21:02:39 +00:00
|
|
|
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
g_return_if_fail (hostname != NULL);
|
|
|
|
|
|
|
|
|
|
if (!strlen (hostname))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
config->hostname = g_strdup (hostname);
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-03 17:40:44 +00:00
|
|
|
const char *nm_ip4_config_get_hostname (NMIP4Config *config)
|
2006-01-23 21:02:39 +00:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return config->hostname;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-13 21:03:57 +00:00
|
|
|
void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
g_return_if_fail (domain != NULL);
|
|
|
|
|
|
|
|
|
|
if (!strlen (domain))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-12-14 16:23:15 +00:00
|
|
|
config->nis_domain = g_strdup (domain);
|
2005-12-13 21:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-03 17:40:44 +00:00
|
|
|
const char *nm_ip4_config_get_nis_domain (NMIP4Config *config)
|
2005-12-13 21:03:57 +00:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail( config != NULL, NULL);
|
|
|
|
|
return config->nis_domain;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
const char *nm_ip4_config_get_domain (NMIP4Config *config, guint i)
|
2005-04-15 15:43:42 +00:00
|
|
|
{
|
2005-09-28 14:42:57 +00:00
|
|
|
const char *domain;
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, NULL);
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
g_return_val_if_fail (i < g_slist_length (config->domains), NULL);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
if ((domain = (const char *) g_slist_nth_data (config->domains, i)))
|
2005-09-28 14:42:57 +00:00
|
|
|
return domain;
|
2005-04-15 15:43:42 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 nm_ip4_config_get_num_domains (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return (g_slist_length (config->domains));
|
|
|
|
|
}
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
guint32 nm_ip4_config_get_mtu (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->mtu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->mtu = mtu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32 nm_ip4_config_get_mss (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return config->mss;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
|
|
|
|
config->mss = mss;
|
|
|
|
|
}
|
2005-10-28 03:16:02 +00:00
|
|
|
|
|
|
|
|
/* libnl convenience/conversion functions */
|
|
|
|
|
|
|
|
|
|
static int ip4_addr_to_rtnl_local (guint32 ip4_address, struct rtnl_addr *addr)
|
|
|
|
|
{
|
|
|
|
|
struct nl_addr * local = NULL;
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (addr != NULL, -1);
|
|
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
local = nm_utils_ip4_addr_to_nl_addr (ip4_address);
|
2005-10-28 03:16:02 +00:00
|
|
|
err = rtnl_addr_set_local (addr, local);
|
|
|
|
|
nl_addr_put (local);
|
2005-12-04 02:23:29 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ip4_addr_to_rtnl_peer (guint32 ip4_address, struct rtnl_addr *addr)
|
|
|
|
|
{
|
|
|
|
|
struct nl_addr * peer = NULL;
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (addr != NULL, -1);
|
|
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
peer = nm_utils_ip4_addr_to_nl_addr (ip4_address);
|
2005-10-28 03:16:02 +00:00
|
|
|
err = rtnl_addr_set_peer (addr, peer);
|
|
|
|
|
nl_addr_put (peer);
|
2005-12-04 02:23:29 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ip4_addr_to_rtnl_prefixlen (guint32 ip4_netmask, struct rtnl_addr *addr)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (addr != NULL);
|
|
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
rtnl_addr_set_prefixlen (addr, nm_utils_ip4_netmask_to_prefix (ip4_netmask));
|
2005-10-28 03:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ip4_addr_to_rtnl_broadcast (guint32 ip4_broadcast, struct rtnl_addr *addr)
|
|
|
|
|
{
|
|
|
|
|
struct nl_addr * local = NULL;
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (addr != NULL, -1);
|
|
|
|
|
|
2005-12-04 02:23:29 +00:00
|
|
|
local = nm_utils_ip4_addr_to_nl_addr (ip4_broadcast);
|
2005-10-28 03:16:02 +00:00
|
|
|
err = rtnl_addr_set_broadcast (addr, local);
|
|
|
|
|
nl_addr_put (local);
|
2005-12-04 02:23:29 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flags)
|
|
|
|
|
{
|
|
|
|
|
struct rtnl_addr * addr = NULL;
|
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (!(addr = rtnl_addr_alloc()))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (flags & NM_RTNL_ADDR_ADDR)
|
|
|
|
|
success = (ip4_addr_to_rtnl_local (config->ip4_address, addr) >= 0);
|
|
|
|
|
|
|
|
|
|
if (flags & NM_RTNL_ADDR_PTP_ADDR)
|
2006-01-16 22:58:13 +00:00
|
|
|
success = (ip4_addr_to_rtnl_peer (config->ip4_ptp_address, addr) >= 0);
|
2005-10-28 03:16:02 +00:00
|
|
|
|
|
|
|
|
if (flags & NM_RTNL_ADDR_NETMASK)
|
|
|
|
|
ip4_addr_to_rtnl_prefixlen (config->ip4_netmask, addr);
|
|
|
|
|
|
|
|
|
|
if (flags & NM_RTNL_ADDR_BROADCAST)
|
|
|
|
|
success = (ip4_addr_to_rtnl_broadcast (config->ip4_broadcast, addr) >= 0);
|
|
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
{
|
|
|
|
|
rtnl_addr_put (addr);
|
|
|
|
|
addr = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
|
}
|