[network-manager-applet/dhcp6] editor: add IPv6 DHCP methods



commit 7c17ab50f589c1fe494e5bb6a9d4ec4ba1c24f57
Author: Dan Williams <dcbw redhat com>
Date:   Mon Jan 11 13:35:08 2010 -0800

    editor: add IPv6 DHCP methods

 src/connection-editor/page-ip6.c |   63 ++++++++++++++++++++++++-------------
 1 files changed, 41 insertions(+), 22 deletions(-)
---
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 315e43c..a1c23be 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -83,12 +83,13 @@ typedef struct {
 #define METHOD_COL_NUM  1
 #define METHOD_COL_ENABLED 2
 
-#define IP6_METHOD_IGNORE          0
-#define IP6_METHOD_AUTO            1
-#define IP6_METHOD_AUTO_ADDRESSES  2
-#define IP6_METHOD_MANUAL          3
-#define IP6_METHOD_LINK_LOCAL      4
-#define IP6_METHOD_SHARED          5
+#define IP6_METHOD_IGNORE         0
+#define IP6_METHOD_AUTO           1
+#define IP6_METHOD_AUTO_DHCP      2  /* only for ethernet-based connections */
+#define IP6_METHOD_AUTO_ADDRESSES 3
+#define IP6_METHOD_MANUAL         4
+#define IP6_METHOD_LINK_LOCAL     5
+#define IP6_METHOD_SHARED         6
 
 static void
 ip6_private_init (CEPageIP6 *self, NMConnection *connection)
@@ -98,8 +99,9 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 	GtkTreeIter iter;
 	NMSettingConnection *s_con;
 	const char *connection_type;
-	char *str_auto = NULL, *str_auto_only = NULL;
+	const char *str_auto = NULL, *str_auto_only = NULL, *str_auto_dhcp = NULL;
 	GList *cells;
+	gboolean allow_manual = TRUE, allow_linklocal_shared = TRUE;
 
 	xml = CE_PAGE (self)->xml;
 
@@ -112,17 +114,24 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 
 	if (priv->connection_type == NM_TYPE_SETTING_VPN) {
 		str_auto = _("Automatic (VPN)");
-		str_auto_only = _("Automatic (VPN) addresses only");
+		str_auto_only = _("Automatic (VPN, addresses only)");
+		allow_manual = FALSE;
+		allow_linklocal_shared = FALSE;
 	} else if (   priv->connection_type == NM_TYPE_SETTING_GSM
 	           || priv->connection_type == NM_TYPE_SETTING_CDMA) {
 		str_auto = _("Automatic (PPP)");
-		str_auto_only = _("Automatic (PPP) addresses only");
+		str_auto_only = _("Automatic (PPP, addresses only)");
+		allow_manual = FALSE;
+		allow_linklocal_shared = FALSE;
 	} else if (priv->connection_type == NM_TYPE_SETTING_PPPOE) {
 		str_auto = _("Automatic (PPPoE)");
-		str_auto_only = _("Automatic (PPPoE) addresses only");
+		str_auto_only = _("Automatic (PPPoE, addresses only)");
+		allow_linklocal_shared = FALSE;
 	} else {
-		str_auto = _("Automatic");
-		str_auto_only = _("Automatic, addresses only");
+		/* Ethernet-based connections (wired, wifi, wimax) */
+		str_auto = _("Automatic (router advertisements)");
+		str_auto_dhcp = _("Automatic (DHCP)");
+		str_auto_only = _("Automatic (DHCP, addresses only)");
 	}
 
 	priv->method = GTK_COMBO_BOX (glade_xml_get_widget (xml, "ip6_method"));
@@ -146,6 +155,16 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 						METHOD_COL_ENABLED, TRUE,
 	                    -1);
 
+	/* Only ethernet-based connection types like wired and wifi can use DHCP */
+	if (str_auto_dhcp) {
+		gtk_list_store_append (priv->method_store, &iter);
+		gtk_list_store_set (priv->method_store, &iter,
+		                    METHOD_COL_NAME, str_auto_dhcp,
+		                    METHOD_COL_NUM, IP6_METHOD_AUTO_DHCP,
+							METHOD_COL_ENABLED, TRUE,
+		                    -1);
+	}
+
 	gtk_list_store_append (priv->method_store, &iter);
 	gtk_list_store_set (priv->method_store, &iter,
 	                    METHOD_COL_NAME, str_auto_only,
@@ -153,10 +172,7 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 						METHOD_COL_ENABLED, TRUE,
 	                    -1);
 
-	/* Manual is pointless for Mobile Broadband */
-	if (   priv->connection_type != NM_TYPE_SETTING_GSM
-	    && priv->connection_type != NM_TYPE_SETTING_CDMA
-	    && priv->connection_type != NM_TYPE_SETTING_VPN) {
+	if (allow_manual) {
 		gtk_list_store_append (priv->method_store, &iter);
 		gtk_list_store_set (priv->method_store, &iter,
 		                    METHOD_COL_NAME, _("Manual"),
@@ -165,11 +181,7 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 		                    -1);
 	}
 
-	/* Link-local is pointless for VPNs, Mobile Broadband, and PPPoE */
-	if (   priv->connection_type != NM_TYPE_SETTING_VPN
-	    && priv->connection_type != NM_TYPE_SETTING_PPPOE
-	    && priv->connection_type != NM_TYPE_SETTING_GSM
-	    && priv->connection_type != NM_TYPE_SETTING_CDMA) {
+	if (allow_linklocal_shared) {
 		gtk_list_store_append (priv->method_store, &iter);
 		gtk_list_store_set (priv->method_store, &iter,
 		                    METHOD_COL_NAME, _("Link-Local Only"),
@@ -218,6 +230,7 @@ method_changed (GtkComboBox *combo, gpointer user_data)
 
 	switch (method) {
 	case IP6_METHOD_AUTO:
+	case IP6_METHOD_AUTO_DHCP:
 		addr_enabled = FALSE;
 		routes_enabled = TRUE;
 		break;
@@ -296,6 +309,8 @@ populate_ui (CEPageIP6 *self)
 	if (str_method) {
 		if (!strcmp (str_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))
 			method = IP6_METHOD_AUTO;
+		if (!strcmp (str_method, NM_SETTING_IP6_CONFIG_METHOD_DHCP))
+			method = IP6_METHOD_AUTO_DHCP;
 		else if (!strcmp (str_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
 			method = IP6_METHOD_LINK_LOCAL;
 		else if (!strcmp (str_method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
@@ -304,7 +319,8 @@ populate_ui (CEPageIP6 *self)
 			method = IP6_METHOD_SHARED;
 	}
 
-	if (method == IP6_METHOD_AUTO && nm_setting_ip6_config_get_ignore_auto_dns (setting))
+	if (   (method == IP6_METHOD_AUTO_DHCP)
+	    && nm_setting_ip6_config_get_ignore_auto_dns (setting))
 		method = IP6_METHOD_AUTO_ADDRESSES;
 
 	info.method = method;
@@ -737,6 +753,9 @@ ui_to_setting (CEPageIP6 *self)
 	case IP6_METHOD_AUTO_ADDRESSES:
 		ignore_auto_dns = TRUE;
 		/* fall through */
+	case IP6_METHOD_AUTO_DHCP:
+		method = NM_SETTING_IP6_CONFIG_METHOD_DHCP;
+		break;
 	default:
 		method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
 		break;



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