NetworkManager r3580 - in trunk: . src src/vpn-manager
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3580 - in trunk: . src src/vpn-manager
- Date: Mon, 21 Apr 2008 04:02:33 +0100 (BST)
Author: dcbw
Date: Mon Apr 21 03:02:32 2008
New Revision: 3580
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3580&view=rev
Log:
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
Modified:
trunk/ChangeLog
trunk/src/NetworkManagerUtils.c
trunk/src/NetworkManagerUtils.h
trunk/src/nm-device.c
trunk/src/vpn-manager/nm-vpn-connection.c
Modified: trunk/src/NetworkManagerUtils.c
==============================================================================
--- trunk/src/NetworkManagerUtils.c (original)
+++ trunk/src/NetworkManagerUtils.c Mon Apr 21 03:02:32 2008
@@ -361,3 +361,70 @@
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);
+ }
+ }
+}
+
+
Modified: trunk/src/NetworkManagerUtils.h
==============================================================================
--- trunk/src/NetworkManagerUtils.h (original)
+++ trunk/src/NetworkManagerUtils.h Mon Apr 21 03:02:32 2008
@@ -31,6 +31,8 @@
#include "NetworkManager.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);
@@ -51,5 +53,7 @@
char *nm_ether_ntop (const struct ether_addr *mac);
+void nm_utils_merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting);
+
#endif
Modified: trunk/src/nm-device.c
==============================================================================
--- trunk/src/nm-device.c (original)
+++ trunk/src/nm-device.c Mon Apr 21 03:02:32 2008
@@ -654,73 +654,6 @@
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
real_act_stage4_get_ip4_config (NMDevice *self,
NMIP4Config **config)
@@ -740,7 +673,7 @@
if (nm_device_get_use_dhcp (self)) {
*config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
nm_device_get_iface (self));
- merge_ip4_config (*config, s_ip4);
+ nm_utils_merge_ip4_config (*config, s_ip4);
} else {
g_assert (s_ip4);
@@ -748,7 +681,7 @@
nm_device_new_ip4_autoip_config (self);
} else if (!strcmp (s_ip4->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
*config = nm_ip4_config_new ();
- merge_ip4_config (*config, s_ip4);
+ nm_utils_merge_ip4_config (*config, s_ip4);
}
}
@@ -1241,7 +1174,7 @@
g_assert (connection);
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);
Modified: trunk/src/vpn-manager/nm-vpn-connection.c
==============================================================================
--- trunk/src/vpn-manager/nm-vpn-connection.c (original)
+++ trunk/src/vpn-manager/nm-vpn-connection.c Mon Apr 21 03:02:32 2008
@@ -33,6 +33,7 @@
#include "nm-setting-connection.h"
#include "nm-setting-vpn.h"
#include "nm-setting-vpn-properties.h"
+#include "nm-setting-ip4-config.h"
#include "nm-dbus-manager.h"
#include "nm-manager.h"
#include "NetworkManagerSystem.h"
@@ -42,6 +43,7 @@
#include "nm-active-connection.h"
#include "nm-properties-changed-signal.h"
#include "nm-dbus-glib-types.h"
+#include "NetworkManagerUtils.h"
#define CONNECTION_GET_SECRETS_CALL_TAG "get-secrets-call"
@@ -250,6 +252,7 @@
{
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
+ NMSettingIP4Config *s_ip4;
NMIP4Config *config;
GValue *val;
int i;
@@ -325,6 +328,10 @@
priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
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,
nm_vpn_connection_get_routes (connection))) {
nm_info ("VPN connection '%s' (IP Config Get) complete.",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]