1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
From 4a495b961aab736fa2881057ecf8a7c5044fb4a3 Mon Sep 17 00:00:00 2001
From: Mu Qiao <qiaomuf@gentoo.org>
Date: Wed, 5 Jan 2011 13:30:08 +0800
Subject: [PATCH] Support shared and link-local method for ipv4
Signed-off-by: Mu Qiao <qiaomuf@gentoo.org>
---
system-settings/plugins/ifnet/connection_parser.c | 49 ++++++++++++++++-----
system-settings/plugins/ifnet/net_utils.c | 4 ++
2 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/system-settings/plugins/ifnet/connection_parser.c b/system-settings/plugins/ifnet/connection_parser.c
index f9fae51..def5c4a 100644
--- a/system-settings/plugins/ifnet/connection_parser.c
+++ b/system-settings/plugins/ifnet/connection_parser.c
@@ -557,7 +557,7 @@ make_ip4_setting (NMConnection * connection, gchar * conn_name, GError ** error)
NMSettingIP4Config *ip4_setting =
NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
- gchar *value;
+ gchar *value, *method = NULL;
gboolean is_static_block = is_static_ip4 (conn_name);
ip_block *iblock = NULL;
@@ -569,12 +569,36 @@ make_ip4_setting (NMConnection * connection, gchar * conn_name, GError ** error)
&& strstr (value, "nogateway") ? TRUE : FALSE, NULL);
if (!is_static_block) {
- g_object_set (ip4_setting,
- NM_SETTING_IP4_CONFIG_METHOD,
- NM_SETTING_IP4_CONFIG_METHOD_AUTO,
- NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
- PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Using DHCP for %s",
- conn_name);
+ method = ifnet_get_data (conn_name, "config");
+ if (!strcmp (method, "dhcp"))
+ g_object_set (ip4_setting,
+ NM_SETTING_IP4_CONFIG_METHOD,
+ NM_SETTING_IP4_CONFIG_METHOD_AUTO,
+ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+ else if (!strcmp (method, "autoip")){
+ g_object_set (ip4_setting,
+ NM_SETTING_IP4_CONFIG_METHOD,
+ NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
+ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+ nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
+ return;
+ }
+ else if (!strcmp (method, "shared")){
+ g_object_set (ip4_setting,
+ NM_SETTING_IP4_CONFIG_METHOD,
+ NM_SETTING_IP4_CONFIG_METHOD_SHARED,
+ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+ nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
+ return;
+ }
+ else {
+ g_set_error (error, ifnet_plugin_error_quark (), 0,
+ "Unknown config for %s", conn_name);
+ g_object_unref (ip4_setting);
+ return;
+ }
+ PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Using %s method for %s",
+ method, conn_name);
} else {
iblock = convert_ip4_config_block (conn_name);
if (!iblock) {
@@ -625,7 +649,7 @@ make_ip4_setting (NMConnection * connection, gchar * conn_name, GError ** error)
}
/* add dhcp hostname and client id */
- if (!is_static_block) {
+ if (method && !strcmp (method, "dhcp")) {
gchar *dhcp_hostname, *client_id;
get_dhcp_hostname_and_client_id (&dhcp_hostname, &client_id);
@@ -712,7 +736,6 @@ make_ip4_setting (NMConnection * connection, gchar * conn_name, GError ** error)
iblock = iblock->next;
destroy_ip_block (current_iblock);
}
-
/* Finally add setting to connection */
nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
}
@@ -2443,8 +2466,12 @@ write_ip4_setting (NMConnection * connection, gchar * conn_name,
}
ifnet_set_data (conn_name, "config", ips->str);
g_string_free (ips, TRUE);
- } else
- ifnet_set_data (conn_name, "config", "dhcp");
+ } else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
+ ifnet_set_data (conn_name, "config", "shared");
+ else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
+ ifnet_set_data (conn_name, "config", "autoip");
+ else
+ ifnet_set_data (conn_name, "config", "dhcp");
/* DNS Servers */
ifnet_set_data (conn_name, "dns_servers", NULL);
diff --git a/system-settings/plugins/ifnet/net_utils.c b/system-settings/plugins/ifnet/net_utils.c
index 2dc253c..7e52f10 100644
--- a/system-settings/plugins/ifnet/net_utils.c
+++ b/system-settings/plugins/ifnet/net_utils.c
@@ -278,6 +278,10 @@ is_static_ip4 (gchar * conn_name)
if (!data)
return FALSE;
+ if (!strcmp (data, "shared"))
+ return FALSE;
+ if (!strcmp (data, "autoip"))
+ return FALSE;
dhcp6 = strstr (data, "dhcp6");
if (dhcp6) {
gchar *dhcp4;
--
1.7.2.2
|