NetworkManager r3685 - in trunk: . libnm-util src



Author: tambeti
Date: Fri May 23 07:35:43 2008
New Revision: 3685
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3685&view=rev

Log:
2008-05-23  Tambet Ingo  <tambet gmail com>

	Add a flag to NMSettingIP4Config to make it possible to ignore the DNS
	information received from DHCP.

	* libnm-util/nm-setting-ip4-config.c: Add a new membet "ignore_dhcp_dns"
	to make it possible to ignore the DNS information (both servers and
	searches) returned by DHCP server.

	* src/NetworkManagerUtils.c (nm_utils_merge_ip4_config): Reset the
	name servers and searches if "ignore_dhcp_dns" is set.

	* src/nm-ip4-config.c (nm_ip4_config_reset_nameservers)
	(nm_ip4_config_reset_searches): Implement.


Modified:
   trunk/ChangeLog
   trunk/libnm-util/nm-setting-ip4-config.c
   trunk/libnm-util/nm-setting-ip4-config.h
   trunk/src/NetworkManagerUtils.c
   trunk/src/nm-ip4-config.c
   trunk/src/nm-ip4-config.h

Modified: trunk/libnm-util/nm-setting-ip4-config.c
==============================================================================
--- trunk/libnm-util/nm-setting-ip4-config.c	(original)
+++ trunk/libnm-util/nm-setting-ip4-config.c	Fri May 23 07:35:43 2008
@@ -16,6 +16,7 @@
 	PROP_DNS,
 	PROP_DNS_SEARCH,
 	PROP_ADDRESSES,
+	PROP_IGNORE_DHCP_DNS,
 
 	LAST_PROP
 };
@@ -111,6 +112,9 @@
 		nm_utils_slist_free (setting->addresses, g_free);
 		setting->addresses = nm_utils_ip4_addresses_from_gvalue (value);
 		break;
+	case PROP_IGNORE_DHCP_DNS:
+		setting->ignore_dhcp_dns = g_value_get_boolean (value);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -136,6 +140,9 @@
 	case PROP_ADDRESSES:
 		nm_utils_ip4_addresses_to_gvalue (setting->addresses, value);
 		break;
+	case PROP_IGNORE_DHCP_DNS:
+		g_value_set_boolean (value, setting->ignore_dhcp_dns);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -186,4 +193,12 @@
 							   "List of NMSettingIP4Addresses",
 							   DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
 							   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+
+	g_object_class_install_property
+		(object_class, PROP_IGNORE_DHCP_DNS,
+		 g_param_spec_boolean (NM_SETTING_IP4_CONFIG_IGNORE_DHCP_DNS,
+						   "Ignore DHCP DNS",
+						   "Ignore DHCP DNS",
+						   FALSE,
+						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
 }

Modified: trunk/libnm-util/nm-setting-ip4-config.h
==============================================================================
--- trunk/libnm-util/nm-setting-ip4-config.h	(original)
+++ trunk/libnm-util/nm-setting-ip4-config.h	Fri May 23 07:35:43 2008
@@ -16,10 +16,11 @@
 
 #define NM_SETTING_IP4_CONFIG_SETTING_NAME "ipv4"
 
-#define NM_SETTING_IP4_CONFIG_METHOD     "method"
-#define NM_SETTING_IP4_CONFIG_DNS        "dns"
-#define NM_SETTING_IP4_CONFIG_DNS_SEARCH "dns-search"
-#define NM_SETTING_IP4_CONFIG_ADDRESSES  "addresses"
+#define NM_SETTING_IP4_CONFIG_METHOD          "method"
+#define NM_SETTING_IP4_CONFIG_DNS             "dns"
+#define NM_SETTING_IP4_CONFIG_DNS_SEARCH      "dns-search"
+#define NM_SETTING_IP4_CONFIG_ADDRESSES       "addresses"
+#define NM_SETTING_IP4_CONFIG_IGNORE_DHCP_DNS "ignore-dhcp-dns"
 
 #define NM_SETTING_IP4_CONFIG_METHOD_DHCP   "dhcp"
 #define NM_SETTING_IP4_CONFIG_METHOD_AUTOIP "autoip"
@@ -38,6 +39,7 @@
 	GArray *dns;        /* array of guint32 */
 	GSList *dns_search; /* list of strings */
 	GSList *addresses;  /* array of NMSettingIP4Address */
+	gboolean ignore_dhcp_dns;
 } NMSettingIP4Config;
 
 typedef struct {

Modified: trunk/src/NetworkManagerUtils.c
==============================================================================
--- trunk/src/NetworkManagerUtils.c	(original)
+++ trunk/src/NetworkManagerUtils.c	Fri May 23 07:35:43 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -242,6 +244,11 @@
 	if (!setting)
 		return; /* Defaults are just fine */
 
+	if (setting->ignore_dhcp_dns) {
+		nm_ip4_config_reset_nameservers (ip4_config);
+		nm_ip4_config_reset_searches (ip4_config);
+	}
+
 	if (setting->dns) {
 		int i, j;
 

Modified: trunk/src/nm-ip4-config.c
==============================================================================
--- trunk/src/nm-ip4-config.c	(original)
+++ trunk/src/nm-ip4-config.c	Fri May 23 07:35:43 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -238,6 +240,16 @@
 	return NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers->len;
 }
 
+void nm_ip4_config_reset_nameservers (NMIP4Config *config)
+{
+	NMIP4ConfigPrivate *priv;
+
+	g_return_if_fail (NM_IS_IP4_CONFIG (config));
+
+	priv = NM_IP4_CONFIG_GET_PRIVATE (config);
+	g_array_remove_range (priv->nameservers, 0, priv->nameservers->len);
+}
+
 void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server)
 {
 	g_return_if_fail (NM_IS_IP4_CONFIG (config));
@@ -366,6 +378,16 @@
 	return NM_IP4_CONFIG_GET_PRIVATE (config)->searches->len;
 }
 
+void nm_ip4_config_reset_searches (NMIP4Config *config)
+{
+	NMIP4ConfigPrivate *priv;
+
+	g_return_if_fail (NM_IS_IP4_CONFIG (config));
+
+	priv = NM_IP4_CONFIG_GET_PRIVATE (config);
+	g_ptr_array_remove_range (priv->searches, 0, priv->searches->len);
+}
+
 guint32 nm_ip4_config_get_mtu (NMIP4Config *config)
 {
 	g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);

Modified: trunk/src/nm-ip4-config.h
==============================================================================
--- trunk/src/nm-ip4-config.h	(original)
+++ trunk/src/nm-ip4-config.h	Fri May 23 07:35:43 2008
@@ -70,6 +70,7 @@
 void			nm_ip4_config_add_nameserver		(NMIP4Config *config, guint32 nameserver);
 guint32		nm_ip4_config_get_nameserver		(NMIP4Config *config, guint i);
 guint32		nm_ip4_config_get_num_nameservers	(NMIP4Config *config);
+void			nm_ip4_config_reset_nameservers		(NMIP4Config *config);
 
 void			nm_ip4_config_add_nis_server		(NMIP4Config *config, guint32 nis_server);
 guint32		nm_ip4_config_get_nis_server		(NMIP4Config *config, guint i);
@@ -92,6 +93,7 @@
 void			nm_ip4_config_add_search			(NMIP4Config *config, const char *search);
 const char *	nm_ip4_config_get_search			(NMIP4Config *config, guint i);
 guint32		nm_ip4_config_get_num_searches		(NMIP4Config *config);
+void			nm_ip4_config_reset_searches		(NMIP4Config *config);
 
 guint32		nm_ip4_config_get_mtu			(NMIP4Config *config);
 void			nm_ip4_config_set_mtu			(NMIP4Config *config, guint32 mtu);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]