2008-04-20 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerUtils.c src/NetworkManagerUtils.h - (nm_utils_merge_ip4_config): new function; merge settings from an NMSettingIP4Config to an NMIP4Config object * src/nm-device.c - (merge_ip4_config): move to NetworkManagerUtils.c * src/vpn-manager/nm-vpn-connection.c - (nm_vpn_connection_ip4_config_get): merge in user-specified settings too git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3580 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2008-04-20 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* src/NetworkManagerUtils.c
|
||||||
|
src/NetworkManagerUtils.h
|
||||||
|
- (nm_utils_merge_ip4_config): new function; merge settings from an
|
||||||
|
NMSettingIP4Config to an NMIP4Config object
|
||||||
|
|
||||||
|
* src/nm-device.c
|
||||||
|
- (merge_ip4_config): move to NetworkManagerUtils.c
|
||||||
|
|
||||||
|
* src/vpn-manager/nm-vpn-connection.c
|
||||||
|
- (nm_vpn_connection_ip4_config_get): merge in user-specified settings
|
||||||
|
too
|
||||||
|
|
||||||
2008-04-18 Dan Williams <dcbw@redhat.com>
|
2008-04-18 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* libnm-util/nm-setting-ppp.c
|
* libnm-util/nm-setting-ppp.c
|
||||||
|
@@ -361,3 +361,70 @@ nm_ether_ntop (const struct ether_addr *mac)
|
|||||||
mac->ether_addr_octet[4], mac->ether_addr_octet[5]);
|
mac->ether_addr_octet[4], mac->ether_addr_octet[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_utils_merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting)
|
||||||
|
{
|
||||||
|
if (!setting)
|
||||||
|
return; /* Defaults are just fine */
|
||||||
|
|
||||||
|
if (setting->dns) {
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < setting->dns->len; i++) {
|
||||||
|
guint32 ns;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
|
||||||
|
/* Avoid dupes */
|
||||||
|
ns = g_array_index (setting->dns, guint32, i);
|
||||||
|
for (j = 0; j < nm_ip4_config_get_num_nameservers (ip4_config); j++) {
|
||||||
|
if (nm_ip4_config_get_nameserver (ip4_config, j) == ns) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
nm_ip4_config_add_nameserver (ip4_config, ns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting->dns_search) {
|
||||||
|
GSList *iter;
|
||||||
|
|
||||||
|
for (iter = setting->dns_search; iter; iter = iter->next) {
|
||||||
|
int i;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
|
||||||
|
/* Avoid dupes */
|
||||||
|
for (i = 0; i < nm_ip4_config_get_num_searches (ip4_config); i++) {
|
||||||
|
const char *search = nm_ip4_config_get_search (ip4_config, i);
|
||||||
|
|
||||||
|
if (!strcmp (search, (char *) iter->data)) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
nm_ip4_config_add_search (ip4_config, (char *) iter->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting->addresses) {
|
||||||
|
/* FIXME; add support for more than one set of address/netmask/gateway for NMIP4Config */
|
||||||
|
NMSettingIP4Address *addr = (NMSettingIP4Address *) setting->addresses->data;
|
||||||
|
|
||||||
|
/* Avoid dupes, but override if anything is different */
|
||||||
|
if ( (nm_ip4_config_get_address (ip4_config) != addr->address)
|
||||||
|
|| (nm_ip4_config_get_netmask (ip4_config) != addr->netmask)
|
||||||
|
|| (addr->gateway && (nm_ip4_config_get_gateway (ip4_config) != addr->gateway))) {
|
||||||
|
nm_ip4_config_set_address (ip4_config, addr->address);
|
||||||
|
nm_ip4_config_set_netmask (ip4_config, addr->netmask);
|
||||||
|
|
||||||
|
if (addr->gateway)
|
||||||
|
nm_ip4_config_set_gateway (ip4_config, addr->gateway);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
|
#include "nm-ip4-config.h"
|
||||||
|
#include "nm-setting-ip4-config.h"
|
||||||
|
|
||||||
int nm_null_safe_strcmp (const char *s1, const char *s2);
|
int nm_null_safe_strcmp (const char *s1, const char *s2);
|
||||||
|
|
||||||
@@ -51,5 +53,7 @@ char * nm_utils_hexstr2bin (const char *hex, size_t len);
|
|||||||
|
|
||||||
char *nm_ether_ntop (const struct ether_addr *mac);
|
char *nm_ether_ntop (const struct ether_addr *mac);
|
||||||
|
|
||||||
|
void nm_utils_merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -654,73 +654,6 @@ nm_device_new_ip4_autoip_config (NMDevice *self)
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting)
|
|
||||||
{
|
|
||||||
if (!setting)
|
|
||||||
return; /* Defaults are just fine */
|
|
||||||
|
|
||||||
if (setting->dns) {
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (i = 0; i < setting->dns->len; i++) {
|
|
||||||
guint32 ns;
|
|
||||||
gboolean found = FALSE;
|
|
||||||
|
|
||||||
/* Avoid dupes */
|
|
||||||
ns = g_array_index (setting->dns, guint32, i);
|
|
||||||
for (j = 0; j < nm_ip4_config_get_num_nameservers (ip4_config); j++) {
|
|
||||||
if (nm_ip4_config_get_nameserver (ip4_config, j) == ns) {
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
nm_ip4_config_add_nameserver (ip4_config, ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting->dns_search) {
|
|
||||||
GSList *iter;
|
|
||||||
|
|
||||||
for (iter = setting->dns_search; iter; iter = iter->next) {
|
|
||||||
int i;
|
|
||||||
gboolean found = FALSE;
|
|
||||||
|
|
||||||
/* Avoid dupes */
|
|
||||||
for (i = 0; i < nm_ip4_config_get_num_searches (ip4_config); i++) {
|
|
||||||
const char *search = nm_ip4_config_get_search (ip4_config, i);
|
|
||||||
|
|
||||||
if (!strcmp (search, (char *) iter->data)) {
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
nm_ip4_config_add_search (ip4_config, (char *) iter->data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting->addresses) {
|
|
||||||
/* FIXME; add support for more than one set of address/netmask/gateway for NMIP4Config */
|
|
||||||
NMSettingIP4Address *addr = (NMSettingIP4Address *) setting->addresses->data;
|
|
||||||
|
|
||||||
/* Avoid dupes, but override if anything is different */
|
|
||||||
if ( (nm_ip4_config_get_address (ip4_config) != addr->address)
|
|
||||||
|| (nm_ip4_config_get_netmask (ip4_config) != addr->netmask)
|
|
||||||
|| (addr->gateway && (nm_ip4_config_get_gateway (ip4_config) != addr->gateway))) {
|
|
||||||
nm_ip4_config_set_address (ip4_config, addr->address);
|
|
||||||
nm_ip4_config_set_netmask (ip4_config, addr->netmask);
|
|
||||||
|
|
||||||
if (addr->gateway)
|
|
||||||
nm_ip4_config_set_gateway (ip4_config, addr->gateway);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static NMActStageReturn
|
static NMActStageReturn
|
||||||
real_act_stage4_get_ip4_config (NMDevice *self,
|
real_act_stage4_get_ip4_config (NMDevice *self,
|
||||||
NMIP4Config **config)
|
NMIP4Config **config)
|
||||||
@@ -740,7 +673,7 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
|||||||
if (nm_device_get_use_dhcp (self)) {
|
if (nm_device_get_use_dhcp (self)) {
|
||||||
*config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
*config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
||||||
nm_device_get_iface (self));
|
nm_device_get_iface (self));
|
||||||
merge_ip4_config (*config, s_ip4);
|
nm_utils_merge_ip4_config (*config, s_ip4);
|
||||||
} else {
|
} else {
|
||||||
g_assert (s_ip4);
|
g_assert (s_ip4);
|
||||||
|
|
||||||
@@ -748,7 +681,7 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
|||||||
nm_device_new_ip4_autoip_config (self);
|
nm_device_new_ip4_autoip_config (self);
|
||||||
} else if (!strcmp (s_ip4->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
|
} else if (!strcmp (s_ip4->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
|
||||||
*config = nm_ip4_config_new ();
|
*config = nm_ip4_config_new ();
|
||||||
merge_ip4_config (*config, s_ip4);
|
nm_utils_merge_ip4_config (*config, s_ip4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1241,7 +1174,7 @@ handle_dhcp_lease_change (NMDevice *device)
|
|||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
|
|
||||||
s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
|
||||||
merge_ip4_config (config, s_ip4);
|
nm_utils_merge_ip4_config (config, s_ip4);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
|
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "nm-setting-connection.h"
|
#include "nm-setting-connection.h"
|
||||||
#include "nm-setting-vpn.h"
|
#include "nm-setting-vpn.h"
|
||||||
#include "nm-setting-vpn-properties.h"
|
#include "nm-setting-vpn-properties.h"
|
||||||
|
#include "nm-setting-ip4-config.h"
|
||||||
#include "nm-dbus-manager.h"
|
#include "nm-dbus-manager.h"
|
||||||
#include "nm-manager.h"
|
#include "nm-manager.h"
|
||||||
#include "NetworkManagerSystem.h"
|
#include "NetworkManagerSystem.h"
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
#include "nm-active-connection.h"
|
#include "nm-active-connection.h"
|
||||||
#include "nm-properties-changed-signal.h"
|
#include "nm-properties-changed-signal.h"
|
||||||
#include "nm-dbus-glib-types.h"
|
#include "nm-dbus-glib-types.h"
|
||||||
|
#include "NetworkManagerUtils.h"
|
||||||
|
|
||||||
#define CONNECTION_GET_SECRETS_CALL_TAG "get-secrets-call"
|
#define CONNECTION_GET_SECRETS_CALL_TAG "get-secrets-call"
|
||||||
|
|
||||||
@@ -250,6 +252,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||||||
{
|
{
|
||||||
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
|
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
|
||||||
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||||
|
NMSettingIP4Config *s_ip4;
|
||||||
NMIP4Config *config;
|
NMIP4Config *config;
|
||||||
GValue *val;
|
GValue *val;
|
||||||
int i;
|
int i;
|
||||||
@@ -325,6 +328,10 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||||||
priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||||
priv->ip4_config = config;
|
priv->ip4_config = config;
|
||||||
|
|
||||||
|
/* Merge in user overrides from the NMConnection's IPv4 setting */
|
||||||
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_IP4_CONFIG));
|
||||||
|
nm_utils_merge_ip4_config (config, s_ip4);
|
||||||
|
|
||||||
if (nm_system_vpn_device_set_from_ip4_config (priv->parent_dev, priv->tundev, priv->ip4_config,
|
if (nm_system_vpn_device_set_from_ip4_config (priv->parent_dev, priv->tundev, priv->ip4_config,
|
||||||
nm_vpn_connection_get_routes (connection))) {
|
nm_vpn_connection_get_routes (connection))) {
|
||||||
nm_info ("VPN connection '%s' (IP Config Get) complete.",
|
nm_info ("VPN connection '%s' (IP Config Get) complete.",
|
||||||
|
Reference in New Issue
Block a user