1 /* nmcli - command-line tool to control NetworkManager
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 * Copyright 2010 - 2015 Red Hat, Inc.
20 #include "nm-default.h"
25 #include <arpa/inet.h>
30 /* Forward declarations */
31 static char *wep_key_type_to_string (NMWepKeyType type);
34 NMC_PROPERTY_GET_PRETTY,
35 NMC_PROPERTY_GET_PARSABLE,
38 /* Helper macro to define fields */
39 #define SETTING_FIELD(setting) { setting, N_(setting), 0, NULL, FALSE, FALSE, 0 }
41 /* Available fields for NM_SETTING_CONNECTION_SETTING_NAME */
42 NmcOutputField nmc_fields_setting_connection[] = {
43 SETTING_FIELD ("name"), /* 0 */
44 SETTING_FIELD (NM_SETTING_CONNECTION_ID), /* 1 */
45 SETTING_FIELD (NM_SETTING_CONNECTION_UUID), /* 2 */
46 SETTING_FIELD (NM_SETTING_CONNECTION_INTERFACE_NAME), /* 3 */
47 SETTING_FIELD (NM_SETTING_CONNECTION_TYPE), /* 4 */
48 SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT), /* 5 */
49 SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), /* 6 */
50 SETTING_FIELD (NM_SETTING_CONNECTION_TIMESTAMP), /* 7 */
51 SETTING_FIELD (NM_SETTING_CONNECTION_READ_ONLY), /* 8 */
52 SETTING_FIELD (NM_SETTING_CONNECTION_PERMISSIONS), /* 9 */
53 SETTING_FIELD (NM_SETTING_CONNECTION_ZONE), /* 10 */
54 SETTING_FIELD (NM_SETTING_CONNECTION_MASTER), /* 11 */
55 SETTING_FIELD (NM_SETTING_CONNECTION_SLAVE_TYPE), /* 12 */
56 SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), /* 13 */
57 SETTING_FIELD (NM_SETTING_CONNECTION_SECONDARIES), /* 14 */
58 SETTING_FIELD (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), /* 15 */
59 SETTING_FIELD (NM_SETTING_CONNECTION_METERED), /* 16 */
60 SETTING_FIELD (NM_SETTING_CONNECTION_LLDP), /* 17 */
61 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
63 #define NMC_FIELDS_SETTING_CONNECTION_ALL "name"","\
64 NM_SETTING_CONNECTION_ID","\
65 NM_SETTING_CONNECTION_UUID","\
66 NM_SETTING_CONNECTION_INTERFACE_NAME","\
67 NM_SETTING_CONNECTION_TYPE","\
68 NM_SETTING_CONNECTION_AUTOCONNECT","\
69 NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY","\
70 NM_SETTING_CONNECTION_TIMESTAMP","\
71 NM_SETTING_CONNECTION_READ_ONLY","\
72 NM_SETTING_CONNECTION_PERMISSIONS","\
73 NM_SETTING_CONNECTION_ZONE","\
74 NM_SETTING_CONNECTION_MASTER","\
75 NM_SETTING_CONNECTION_SLAVE_TYPE","\
76 NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES","\
77 NM_SETTING_CONNECTION_SECONDARIES","\
78 NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT","\
79 NM_SETTING_CONNECTION_METERED","\
80 NM_SETTING_CONNECTION_LLDP
82 /* Available fields for NM_SETTING_WIRED_SETTING_NAME */
83 NmcOutputField nmc_fields_setting_wired[] = {
84 SETTING_FIELD ("name"), /* 0 */
85 SETTING_FIELD (NM_SETTING_WIRED_PORT), /* 1 */
86 SETTING_FIELD (NM_SETTING_WIRED_SPEED), /* 2 */
87 SETTING_FIELD (NM_SETTING_WIRED_DUPLEX), /* 3 */
88 SETTING_FIELD (NM_SETTING_WIRED_AUTO_NEGOTIATE), /* 4 */
89 SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS), /* 5 */
90 SETTING_FIELD (NM_SETTING_WIRED_CLONED_MAC_ADDRESS), /* 6 */
91 SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), /* 7 */
92 SETTING_FIELD (NM_SETTING_WIRED_MTU), /* 8 */
93 SETTING_FIELD (NM_SETTING_WIRED_S390_SUBCHANNELS), /* 9 */
94 SETTING_FIELD (NM_SETTING_WIRED_S390_NETTYPE), /* 10 */
95 SETTING_FIELD (NM_SETTING_WIRED_S390_OPTIONS), /* 11 */
96 SETTING_FIELD (NM_SETTING_WIRED_WAKE_ON_LAN), /* 12 */
97 SETTING_FIELD (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD), /* 13 */
98 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
100 #define NMC_FIELDS_SETTING_WIRED_ALL "name"","\
101 NM_SETTING_WIRED_PORT","\
102 NM_SETTING_WIRED_SPEED","\
103 NM_SETTING_WIRED_DUPLEX","\
104 NM_SETTING_WIRED_AUTO_NEGOTIATE","\
105 NM_SETTING_WIRED_MAC_ADDRESS","\
106 NM_SETTING_WIRED_CLONED_MAC_ADDRESS","\
107 NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST","\
108 NM_SETTING_WIRED_MTU","\
109 NM_SETTING_WIRED_S390_SUBCHANNELS","\
110 NM_SETTING_WIRED_S390_NETTYPE","\
111 NM_SETTING_WIRED_S390_OPTIONS","\
112 NM_SETTING_WIRED_WAKE_ON_LAN","\
113 NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD
115 /* Available fields for NM_SETTING_802_1X_SETTING_NAME */
116 NmcOutputField nmc_fields_setting_8021X[] = {
117 SETTING_FIELD ("name"), /* 0 */
118 SETTING_FIELD (NM_SETTING_802_1X_EAP), /* 1 */
119 SETTING_FIELD (NM_SETTING_802_1X_IDENTITY), /* 2 */
120 SETTING_FIELD (NM_SETTING_802_1X_ANONYMOUS_IDENTITY), /* 3 */
121 SETTING_FIELD (NM_SETTING_802_1X_PAC_FILE), /* 4 */
122 SETTING_FIELD (NM_SETTING_802_1X_CA_CERT), /* 5 */
123 SETTING_FIELD (NM_SETTING_802_1X_CA_PATH), /* 6 */
124 SETTING_FIELD (NM_SETTING_802_1X_SUBJECT_MATCH), /* 7 */
125 SETTING_FIELD (NM_SETTING_802_1X_ALTSUBJECT_MATCHES), /* 8 */
126 SETTING_FIELD (NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH), /* 9 */
127 SETTING_FIELD (NM_SETTING_802_1X_CLIENT_CERT), /* 10 */
128 SETTING_FIELD (NM_SETTING_802_1X_PHASE1_PEAPVER), /* 11 */
129 SETTING_FIELD (NM_SETTING_802_1X_PHASE1_PEAPLABEL), /* 12 */
130 SETTING_FIELD (NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), /* 13 */
131 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_AUTH), /* 14 */
132 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_AUTHEAP), /* 15 */
133 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CA_CERT), /* 16 */
134 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CA_PATH), /* 17 */
135 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH), /* 18 */
136 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), /* 19 */
137 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH), /* 20 */
138 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CLIENT_CERT), /* 21 */
139 SETTING_FIELD (NM_SETTING_802_1X_PASSWORD), /* 22 */
140 SETTING_FIELD (NM_SETTING_802_1X_PASSWORD_FLAGS), /* 23 */
141 SETTING_FIELD (NM_SETTING_802_1X_PASSWORD_RAW), /* 24 */
142 SETTING_FIELD (NM_SETTING_802_1X_PASSWORD_RAW_FLAGS), /* 25 */
143 SETTING_FIELD (NM_SETTING_802_1X_PRIVATE_KEY), /* 26 */
144 SETTING_FIELD (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), /* 27 */
145 SETTING_FIELD (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS), /* 28 */
146 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY), /* 29 */
147 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), /* 30 */
148 SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), /* 31 */
149 SETTING_FIELD (NM_SETTING_802_1X_PIN), /* 32 */
150 SETTING_FIELD (NM_SETTING_802_1X_PIN_FLAGS), /* 33 */
151 SETTING_FIELD (NM_SETTING_802_1X_SYSTEM_CA_CERTS), /* 34 */
152 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
154 #define NMC_FIELDS_SETTING_802_1X_ALL "name"","\
155 NM_SETTING_802_1X_EAP","\
156 NM_SETTING_802_1X_IDENTITY","\
157 NM_SETTING_802_1X_ANONYMOUS_IDENTITY","\
158 NM_SETTING_802_1X_PAC_FILE","\
159 NM_SETTING_802_1X_CA_CERT","\
160 NM_SETTING_802_1X_CA_PATH","\
161 NM_SETTING_802_1X_SUBJECT_MATCH","\
162 NM_SETTING_802_1X_ALTSUBJECT_MATCHES","\
163 NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH","\
164 NM_SETTING_802_1X_CLIENT_CERT","\
165 NM_SETTING_802_1X_PHASE1_PEAPVER","\
166 NM_SETTING_802_1X_PHASE1_PEAPLABEL","\
167 NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING","\
168 NM_SETTING_802_1X_PHASE2_AUTH","\
169 NM_SETTING_802_1X_PHASE2_AUTHEAP","\
170 NM_SETTING_802_1X_PHASE2_CA_CERT","\
171 NM_SETTING_802_1X_PHASE2_CA_PATH","\
172 NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH","\
173 NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES","\
174 NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH","\
175 NM_SETTING_802_1X_PHASE2_CLIENT_CERT","\
176 NM_SETTING_802_1X_PASSWORD","\
177 NM_SETTING_802_1X_PASSWORD_FLAGS","\
178 NM_SETTING_802_1X_PASSWORD_RAW","\
179 NM_SETTING_802_1X_PASSWORD_RAW_FLAGS","\
180 NM_SETTING_802_1X_PRIVATE_KEY","\
181 NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD","\
182 NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS","\
183 NM_SETTING_802_1X_PHASE2_PRIVATE_KEY","\
184 NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD","\
185 NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS","\
186 NM_SETTING_802_1X_PIN","\
187 NM_SETTING_802_1X_PIN_FLAGS","\
188 NM_SETTING_802_1X_SYSTEM_CA_CERTS
190 /* Available fields for NM_SETTING_WIRELESS_SETTING_NAME */
191 NmcOutputField nmc_fields_setting_wireless[] = {
192 SETTING_FIELD ("name"), /* 0 */
193 SETTING_FIELD (NM_SETTING_WIRELESS_SSID), /* 1 */
194 SETTING_FIELD (NM_SETTING_WIRELESS_MODE), /* 2 */
195 SETTING_FIELD (NM_SETTING_WIRELESS_BAND), /* 3 */
196 SETTING_FIELD (NM_SETTING_WIRELESS_CHANNEL), /* 4 */
197 SETTING_FIELD (NM_SETTING_WIRELESS_BSSID), /* 5 */
198 SETTING_FIELD (NM_SETTING_WIRELESS_RATE), /* 6 */
199 SETTING_FIELD (NM_SETTING_WIRELESS_TX_POWER), /* 7 */
200 SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS), /* 8 */
201 SETTING_FIELD (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), /* 9 */
202 SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), /* 10 */
203 SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION), /* 11 */
204 SETTING_FIELD (NM_SETTING_WIRELESS_MTU), /* 12 */
205 SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS), /* 13 */
206 SETTING_FIELD (NM_SETTING_WIRELESS_HIDDEN), /* 14 */
207 SETTING_FIELD (NM_SETTING_WIRELESS_POWERSAVE), /* 15 */
208 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
210 #define NMC_FIELDS_SETTING_WIRELESS_ALL "name"","\
211 NM_SETTING_WIRELESS_SSID","\
212 NM_SETTING_WIRELESS_MODE","\
213 NM_SETTING_WIRELESS_BAND","\
214 NM_SETTING_WIRELESS_CHANNEL","\
215 NM_SETTING_WIRELESS_BSSID","\
216 NM_SETTING_WIRELESS_RATE","\
217 NM_SETTING_WIRELESS_TX_POWER","\
218 NM_SETTING_WIRELESS_MAC_ADDRESS","\
219 NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS","\
220 NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST","\
221 NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION","\
222 NM_SETTING_WIRELESS_MTU","\
223 NM_SETTING_WIRELESS_SEEN_BSSIDS","\
224 NM_SETTING_WIRELESS_HIDDEN"," \
225 NM_SETTING_WIRELESS_POWERSAVE
227 /* Available fields for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */
228 NmcOutputField nmc_fields_setting_wireless_security[] = {
229 SETTING_FIELD ("name"), /* 0 */
230 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), /* 1 */
231 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), /* 2 */
232 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), /* 3 */
233 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PROTO), /* 4 */
234 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PAIRWISE), /* 5 */
235 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_GROUP), /* 6 */
236 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), /* 7 */
237 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), /* 8 */
238 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), /* 9 */
239 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), /* 10 */
240 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), /* 11 */
241 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), /* 12 */
242 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), /* 13 */
243 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PSK), /* 14 */
244 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), /* 15 */
245 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), /* 16 */
246 SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), /* 17 */
247 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
249 #define NMC_FIELDS_SETTING_WIRELESS_SECURITY_ALL "name"","\
250 NM_SETTING_WIRELESS_SECURITY_KEY_MGMT","\
251 NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX","\
252 NM_SETTING_WIRELESS_SECURITY_AUTH_ALG","\
253 NM_SETTING_WIRELESS_SECURITY_PROTO","\
254 NM_SETTING_WIRELESS_SECURITY_PAIRWISE","\
255 NM_SETTING_WIRELESS_SECURITY_GROUP","\
256 NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME","\
257 NM_SETTING_WIRELESS_SECURITY_WEP_KEY0","\
258 NM_SETTING_WIRELESS_SECURITY_WEP_KEY1","\
259 NM_SETTING_WIRELESS_SECURITY_WEP_KEY2","\
260 NM_SETTING_WIRELESS_SECURITY_WEP_KEY3","\
261 NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS","\
262 NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE","\
263 NM_SETTING_WIRELESS_SECURITY_PSK","\
264 NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS","\
265 NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD","\
266 NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS
268 /* Available fields for NM_SETTING_IP4_CONFIG_SETTING_NAME */
269 NmcOutputField nmc_fields_setting_ip4_config[] = {
270 SETTING_FIELD ("name"), /* 0 */
271 SETTING_FIELD (NM_SETTING_IP_CONFIG_METHOD), /* 1 */
272 SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS), /* 2 */
273 SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_SEARCH), /* 3 */
274 SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_OPTIONS), /* 4 */
275 SETTING_FIELD (NM_SETTING_IP_CONFIG_ADDRESSES), /* 5 */
276 SETTING_FIELD (NM_SETTING_IP_CONFIG_GATEWAY), /* 6 */
277 SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTES), /* 7 */
278 SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTE_METRIC), /* 8 */
279 SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), /* 9 */
280 SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), /* 10 */
281 SETTING_FIELD (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), /* 11 */
282 SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT), /* 12 */
283 SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), /* 13 */
284 SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), /* 14 */
285 SETTING_FIELD (NM_SETTING_IP4_CONFIG_DHCP_FQDN), /* 15 */
286 SETTING_FIELD (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), /* 16 */
287 SETTING_FIELD (NM_SETTING_IP_CONFIG_MAY_FAIL), /* 17 */
288 SETTING_FIELD (NM_SETTING_IP_CONFIG_DAD_TIMEOUT), /* 18 */
289 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
291 #define NMC_FIELDS_SETTING_IP4_CONFIG_ALL "name"","\
292 NM_SETTING_IP_CONFIG_METHOD","\
293 NM_SETTING_IP_CONFIG_DNS","\
294 NM_SETTING_IP_CONFIG_DNS_SEARCH","\
295 NM_SETTING_IP_CONFIG_DNS_OPTIONS","\
296 NM_SETTING_IP_CONFIG_ADDRESSES","\
297 NM_SETTING_IP_CONFIG_GATEWAY","\
298 NM_SETTING_IP_CONFIG_ROUTES","\
299 NM_SETTING_IP_CONFIG_ROUTE_METRIC","\
300 NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES","\
301 NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS","\
302 NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID","\
303 NM_SETTING_IP_CONFIG_DHCP_TIMEOUT","\
304 NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME","\
305 NM_SETTING_IP_CONFIG_DHCP_HOSTNAME","\
306 NM_SETTING_IP4_CONFIG_DHCP_FQDN","\
307 NM_SETTING_IP_CONFIG_NEVER_DEFAULT","\
308 NM_SETTING_IP_CONFIG_MAY_FAIL","\
309 NM_SETTING_IP_CONFIG_DAD_TIMEOUT
311 /* Available fields for NM_SETTING_IP6_CONFIG_SETTING_NAME */
312 NmcOutputField nmc_fields_setting_ip6_config[] = {
313 SETTING_FIELD ("name"), /* 0 */
314 SETTING_FIELD (NM_SETTING_IP_CONFIG_METHOD), /* 1 */
315 SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS), /* 2 */
316 SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_SEARCH), /* 3 */
317 SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_OPTIONS), /* 4 */
318 SETTING_FIELD (NM_SETTING_IP_CONFIG_ADDRESSES), /* 5 */
319 SETTING_FIELD (NM_SETTING_IP_CONFIG_GATEWAY), /* 6 */
320 SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTES), /* 7 */
321 SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTE_METRIC), /* 8 */
322 SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), /* 9 */
323 SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), /* 10 */
324 SETTING_FIELD (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), /* 11 */
325 SETTING_FIELD (NM_SETTING_IP_CONFIG_MAY_FAIL), /* 12 */
326 SETTING_FIELD (NM_SETTING_IP6_CONFIG_IP6_PRIVACY), /* 13 */
327 SETTING_FIELD (NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE), /* 14 */
328 SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), /* 15 */
329 SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), /* 16 */
330 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
332 #define NMC_FIELDS_SETTING_IP6_CONFIG_ALL "name"","\
333 NM_SETTING_IP_CONFIG_METHOD","\
334 NM_SETTING_IP_CONFIG_DNS","\
335 NM_SETTING_IP_CONFIG_DNS_SEARCH","\
336 NM_SETTING_IP_CONFIG_DNS_OPTIONS","\
337 NM_SETTING_IP_CONFIG_ADDRESSES","\
338 NM_SETTING_IP_CONFIG_GATEWAY","\
339 NM_SETTING_IP_CONFIG_ROUTES","\
340 NM_SETTING_IP_CONFIG_ROUTE_METRIC","\
341 NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES","\
342 NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS","\
343 NM_SETTING_IP_CONFIG_NEVER_DEFAULT","\
344 NM_SETTING_IP_CONFIG_MAY_FAIL","\
345 NM_SETTING_IP6_CONFIG_IP6_PRIVACY","\
346 NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE","\
347 NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME","\
348 NM_SETTING_IP_CONFIG_DHCP_HOSTNAME
350 /* Available fields for NM_SETTING_SERIAL_SETTING_NAME */
351 NmcOutputField nmc_fields_setting_serial[] = {
352 SETTING_FIELD ("name"), /* 0 */
353 SETTING_FIELD (NM_SETTING_SERIAL_BAUD), /* 1 */
354 SETTING_FIELD (NM_SETTING_SERIAL_BITS), /* 2 */
355 SETTING_FIELD (NM_SETTING_SERIAL_PARITY), /* 3 */
356 SETTING_FIELD (NM_SETTING_SERIAL_STOPBITS), /* 4 */
357 SETTING_FIELD (NM_SETTING_SERIAL_SEND_DELAY), /* 5 */
358 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
360 #define NMC_FIELDS_SETTING_SERIAL_ALL "name"","\
361 NM_SETTING_SERIAL_BAUD","\
362 NM_SETTING_SERIAL_BITS","\
363 NM_SETTING_SERIAL_PARITY","\
364 NM_SETTING_SERIAL_STOPBITS","\
365 NM_SETTING_SERIAL_SEND_DELAY
367 /* Available fields for NM_SETTING_PPP_SETTING_NAME */
368 NmcOutputField nmc_fields_setting_ppp[] = {
369 SETTING_FIELD ("name"), /* 0 */
370 SETTING_FIELD (NM_SETTING_PPP_NOAUTH), /* 1 */
371 SETTING_FIELD (NM_SETTING_PPP_REFUSE_EAP), /* 2 */
372 SETTING_FIELD (NM_SETTING_PPP_REFUSE_PAP), /* 3 */
373 SETTING_FIELD (NM_SETTING_PPP_REFUSE_CHAP), /* 4 */
374 SETTING_FIELD (NM_SETTING_PPP_REFUSE_MSCHAP), /* 5 */
375 SETTING_FIELD (NM_SETTING_PPP_REFUSE_MSCHAPV2), /* 6 */
376 SETTING_FIELD (NM_SETTING_PPP_NOBSDCOMP), /* 7 */
377 SETTING_FIELD (NM_SETTING_PPP_NODEFLATE), /* 8 */
378 SETTING_FIELD (NM_SETTING_PPP_NO_VJ_COMP), /* 9 */
379 SETTING_FIELD (NM_SETTING_PPP_REQUIRE_MPPE), /* 10 */
380 SETTING_FIELD (NM_SETTING_PPP_REQUIRE_MPPE_128), /* 11 */
381 SETTING_FIELD (NM_SETTING_PPP_MPPE_STATEFUL), /* 12 */
382 SETTING_FIELD (NM_SETTING_PPP_CRTSCTS), /* 13 */
383 SETTING_FIELD (NM_SETTING_PPP_BAUD), /* 14 */
384 SETTING_FIELD (NM_SETTING_PPP_MRU), /* 15 */
385 SETTING_FIELD (NM_SETTING_PPP_MTU), /* 16 */
386 SETTING_FIELD (NM_SETTING_PPP_LCP_ECHO_FAILURE), /* 17 */
387 SETTING_FIELD (NM_SETTING_PPP_LCP_ECHO_INTERVAL), /* 18 */
388 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
390 #define NMC_FIELDS_SETTING_PPP_ALL "name"","\
391 NM_SETTING_PPP_NOAUTH","\
392 NM_SETTING_PPP_REFUSE_EAP","\
393 NM_SETTING_PPP_REFUSE_PAP","\
394 NM_SETTING_PPP_REFUSE_CHAP","\
395 NM_SETTING_PPP_REFUSE_MSCHAP","\
396 NM_SETTING_PPP_REFUSE_MSCHAPV2","\
397 NM_SETTING_PPP_NOBSDCOMP","\
398 NM_SETTING_PPP_NODEFLATE","\
399 NM_SETTING_PPP_NO_VJ_COMP","\
400 NM_SETTING_PPP_REQUIRE_MPPE","\
401 NM_SETTING_PPP_REQUIRE_MPPE_128","\
402 NM_SETTING_PPP_MPPE_STATEFUL","\
403 NM_SETTING_PPP_CRTSCTS","\
404 NM_SETTING_PPP_BAUD","\
405 NM_SETTING_PPP_MRU","\
406 NM_SETTING_PPP_MTU","\
407 NM_SETTING_PPP_LCP_ECHO_FAILURE","\
408 NM_SETTING_PPP_LCP_ECHO_INTERVAL
410 /* Available fields for NM_SETTING_PPPOE_SETTING_NAME */
411 NmcOutputField nmc_fields_setting_pppoe[] = {
412 SETTING_FIELD ("name"), /* 0 */
413 SETTING_FIELD (NM_SETTING_PPPOE_SERVICE), /* 1 */
414 SETTING_FIELD (NM_SETTING_PPPOE_USERNAME), /* 2 */
415 SETTING_FIELD (NM_SETTING_PPPOE_PASSWORD), /* 3 */
416 SETTING_FIELD (NM_SETTING_PPPOE_PASSWORD_FLAGS), /* 4 */
417 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
419 #define NMC_FIELDS_SETTING_PPPOE_ALL "name"","\
420 NM_SETTING_PPPOE_SERVICE","\
421 NM_SETTING_PPPOE_USERNAME","\
422 NM_SETTING_PPPOE_PASSWORD","\
423 NM_SETTING_PPPOE_PASSWORD_FLAGS
425 /* Available fields for NM_SETTING_ADSL_SETTING_NAME */
426 NmcOutputField nmc_fields_setting_adsl[] = {
427 SETTING_FIELD ("name"), /* 0 */
428 SETTING_FIELD (NM_SETTING_ADSL_USERNAME), /* 1 */
429 SETTING_FIELD (NM_SETTING_ADSL_PASSWORD), /* 2 */
430 SETTING_FIELD (NM_SETTING_ADSL_PASSWORD_FLAGS), /* 3 */
431 SETTING_FIELD (NM_SETTING_ADSL_PROTOCOL), /* 4 */
432 SETTING_FIELD (NM_SETTING_ADSL_ENCAPSULATION), /* 5 */
433 SETTING_FIELD (NM_SETTING_ADSL_VPI), /* 6 */
434 SETTING_FIELD (NM_SETTING_ADSL_VCI), /* 7 */
435 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
437 #define NMC_FIELDS_SETTING_ADSL_ALL "name"","\
438 NM_SETTING_ADSL_USERNAME","\
439 NM_SETTING_ADSL_PASSWORD","\
440 NM_SETTING_ADSL_PASSWORD_FLAGS","\
441 NM_SETTING_ADSL_PROTOCOL","\
442 NM_SETTING_ADSL_ENCAPSULATION","\
443 NM_SETTING_ADSL_VPI","\
446 /* Available fields for NM_SETTING_GSM_SETTING_NAME */
447 NmcOutputField nmc_fields_setting_gsm[] = {
448 SETTING_FIELD ("name"), /* 0 */
449 SETTING_FIELD (NM_SETTING_GSM_NUMBER), /* 1 */
450 SETTING_FIELD (NM_SETTING_GSM_USERNAME), /* 2 */
451 SETTING_FIELD (NM_SETTING_GSM_PASSWORD), /* 3 */
452 SETTING_FIELD (NM_SETTING_GSM_PASSWORD_FLAGS), /* 4 */
453 SETTING_FIELD (NM_SETTING_GSM_APN), /* 5 */
454 SETTING_FIELD (NM_SETTING_GSM_NETWORK_ID), /* 6 */
455 SETTING_FIELD (NM_SETTING_GSM_PIN), /* 7 */
456 SETTING_FIELD (NM_SETTING_GSM_PIN_FLAGS), /* 8 */
457 SETTING_FIELD (NM_SETTING_GSM_HOME_ONLY), /* 9 */
458 SETTING_FIELD (NM_SETTING_GSM_DEVICE_ID), /* 10 */
459 SETTING_FIELD (NM_SETTING_GSM_SIM_ID), /* 11 */
460 SETTING_FIELD (NM_SETTING_GSM_SIM_OPERATOR_ID), /* 12 */
461 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
463 #define NMC_FIELDS_SETTING_GSM_ALL "name"","\
464 NM_SETTING_GSM_NUMBER","\
465 NM_SETTING_GSM_USERNAME","\
466 NM_SETTING_GSM_PASSWORD","\
467 NM_SETTING_GSM_PASSWORD_FLAGS","\
468 NM_SETTING_GSM_APN","\
469 NM_SETTING_GSM_NETWORK_ID","\
470 NM_SETTING_GSM_PIN","\
471 NM_SETTING_GSM_PIN_FLAGS","\
472 NM_SETTING_GSM_HOME_ONLY","\
473 NM_SETTING_GSM_DEVICE_ID","\
474 NM_SETTING_GSM_SIM_ID","\
475 NM_SETTING_GSM_SIM_OPERATOR_ID
477 /* Available fields for NM_SETTING_CDMA_SETTING_NAME */
478 NmcOutputField nmc_fields_setting_cdma[] = {
479 SETTING_FIELD ("name"), /* 0 */
480 SETTING_FIELD (NM_SETTING_CDMA_NUMBER), /* 1 */
481 SETTING_FIELD (NM_SETTING_CDMA_USERNAME), /* 2 */
482 SETTING_FIELD (NM_SETTING_CDMA_PASSWORD), /* 3 */
483 SETTING_FIELD (NM_SETTING_CDMA_PASSWORD_FLAGS), /* 4 */
484 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
486 #define NMC_FIELDS_SETTING_CDMA_ALL "name"","\
487 NM_SETTING_CDMA_NUMBER","\
488 NM_SETTING_CDMA_USERNAME","\
489 NM_SETTING_CDMA_PASSWORD","\
490 NM_SETTING_CDMA_PASSWORD_FLAGS
492 /* Available fields for NM_SETTING_BLUETOOTH_SETTING_NAME */
493 NmcOutputField nmc_fields_setting_bluetooth[] = {
494 SETTING_FIELD ("name"), /* 0 */
495 SETTING_FIELD (NM_SETTING_BLUETOOTH_BDADDR), /* 1 */
496 SETTING_FIELD (NM_SETTING_BLUETOOTH_TYPE), /* 2 */
497 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
499 #define NMC_FIELDS_SETTING_BLUETOOTH_ALL "name"","\
500 NM_SETTING_BLUETOOTH_BDADDR","\
501 NM_SETTING_BLUETOOTH_TYPE
503 /* Available fields for NM_SETTING_OLPC_MESH_SETTING_NAME */
504 NmcOutputField nmc_fields_setting_olpc_mesh[] = {
505 SETTING_FIELD ("name"), /* 0 */
506 SETTING_FIELD (NM_SETTING_OLPC_MESH_SSID), /* 1 */
507 SETTING_FIELD (NM_SETTING_OLPC_MESH_CHANNEL), /* 2 */
508 SETTING_FIELD (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS), /* 3 */
509 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
511 #define NMC_FIELDS_SETTING_OLPC_MESH_ALL "name"","\
512 NM_SETTING_OLPC_MESH_SSID","\
513 NM_SETTING_OLPC_MESH_CHANNEL","\
514 NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS
516 /* Available fields for NM_SETTING_VPN_SETTING_NAME */
517 NmcOutputField nmc_fields_setting_vpn[] = {
518 SETTING_FIELD ("name"), /* 0 */
519 SETTING_FIELD (NM_SETTING_VPN_SERVICE_TYPE), /* 1 */
520 SETTING_FIELD (NM_SETTING_VPN_USER_NAME), /* 2 */
521 SETTING_FIELD (NM_SETTING_VPN_DATA), /* 3 */
522 SETTING_FIELD (NM_SETTING_VPN_SECRETS), /* 4 */
523 SETTING_FIELD (NM_SETTING_VPN_PERSISTENT), /* 5 */
524 SETTING_FIELD (NM_SETTING_VPN_TIMEOUT), /* 6 */
525 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
527 #define NMC_FIELDS_SETTING_VPN_ALL "name"","\
528 NM_SETTING_VPN_SERVICE_TYPE","\
529 NM_SETTING_VPN_USER_NAME","\
530 NM_SETTING_VPN_DATA","\
531 NM_SETTING_VPN_SECRETS","\
532 NM_SETTING_VPN_PERSISTENT","\
533 NM_SETTING_VPN_TIMEOUT
535 /* Available fields for NM_SETTING_WIMAX_SETTING_NAME */
536 NmcOutputField nmc_fields_setting_wimax[] = {
537 SETTING_FIELD ("name"), /* 0 */
538 SETTING_FIELD (NM_SETTING_WIMAX_MAC_ADDRESS), /* 1 */
539 SETTING_FIELD (NM_SETTING_WIMAX_NETWORK_NAME), /* 2 */
540 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
542 #define NMC_FIELDS_SETTING_WIMAX_ALL "name"","\
543 NM_SETTING_WIMAX_MAC_ADDRESS","\
544 NM_SETTING_WIMAX_NETWORK_NAME
546 /* Available fields for NM_SETTING_INFINIBAND_SETTING_NAME */
547 NmcOutputField nmc_fields_setting_infiniband[] = {
548 SETTING_FIELD ("name"), /* 0 */
549 SETTING_FIELD (NM_SETTING_INFINIBAND_MAC_ADDRESS), /* 1 */
550 SETTING_FIELD (NM_SETTING_INFINIBAND_MTU), /* 2 */
551 SETTING_FIELD (NM_SETTING_INFINIBAND_TRANSPORT_MODE), /* 3 */
552 SETTING_FIELD (NM_SETTING_INFINIBAND_P_KEY), /* 4 */
553 SETTING_FIELD (NM_SETTING_INFINIBAND_PARENT), /* 5 */
554 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
556 #define NMC_FIELDS_SETTING_INFINIBAND_ALL "name"","\
557 NM_SETTING_INFINIBAND_MAC_ADDRESS","\
558 NM_SETTING_INFINIBAND_MTU"," \
559 NM_SETTING_INFINIBAND_TRANSPORT_MODE"," \
560 NM_SETTING_INFINIBAND_P_KEY"," \
561 NM_SETTING_INFINIBAND_PARENT
563 /* Available fields for NM_SETTING_BOND_SETTING_NAME */
564 NmcOutputField nmc_fields_setting_bond[] = {
565 SETTING_FIELD ("name"), /* 0 */
566 SETTING_FIELD (NM_SETTING_BOND_OPTIONS), /* 1 */
567 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
569 #define NMC_FIELDS_SETTING_BOND_ALL "name"","\
570 NM_SETTING_BOND_OPTIONS
572 /* Available fields for NM_SETTING_VLAN_SETTING_NAME */
573 NmcOutputField nmc_fields_setting_vlan[] = {
574 SETTING_FIELD ("name"), /* 0 */
575 SETTING_FIELD (NM_SETTING_VLAN_PARENT), /* 1 */
576 SETTING_FIELD (NM_SETTING_VLAN_ID), /* 2 */
577 SETTING_FIELD (NM_SETTING_VLAN_FLAGS), /* 3 */
578 SETTING_FIELD (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), /* 4 */
579 SETTING_FIELD (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), /* 5 */
580 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
582 #define NMC_FIELDS_SETTING_VLAN_ALL "name"","\
583 NM_SETTING_VLAN_PARENT","\
584 NM_SETTING_VLAN_ID","\
585 NM_SETTING_VLAN_FLAGS","\
586 NM_SETTING_VLAN_INGRESS_PRIORITY_MAP","\
587 NM_SETTING_VLAN_EGRESS_PRIORITY_MAP
589 /* Available fields for NM_SETTING_BRIDGE_SETTING_NAME */
590 NmcOutputField nmc_fields_setting_bridge[] = {
591 SETTING_FIELD ("name"), /* 0 */
592 SETTING_FIELD (NM_SETTING_BRIDGE_MAC_ADDRESS), /* 1 */
593 SETTING_FIELD (NM_SETTING_BRIDGE_STP), /* 2 */
594 SETTING_FIELD (NM_SETTING_BRIDGE_PRIORITY), /* 3 */
595 SETTING_FIELD (NM_SETTING_BRIDGE_FORWARD_DELAY), /* 4 */
596 SETTING_FIELD (NM_SETTING_BRIDGE_HELLO_TIME), /* 5 */
597 SETTING_FIELD (NM_SETTING_BRIDGE_MAX_AGE), /* 6 */
598 SETTING_FIELD (NM_SETTING_BRIDGE_AGEING_TIME), /* 7 */
599 SETTING_FIELD (NM_SETTING_BRIDGE_MULTICAST_SNOOPING), /* 8 */
600 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
602 #define NMC_FIELDS_SETTING_BRIDGE_ALL "name"","\
603 NM_SETTING_BRIDGE_MAC_ADDRESS","\
604 NM_SETTING_BRIDGE_STP","\
605 NM_SETTING_BRIDGE_PRIORITY","\
606 NM_SETTING_BRIDGE_FORWARD_DELAY","\
607 NM_SETTING_BRIDGE_HELLO_TIME","\
608 NM_SETTING_BRIDGE_MAX_AGE","\
609 NM_SETTING_BRIDGE_AGEING_TIME","\
610 NM_SETTING_BRIDGE_MULTICAST_SNOOPING
612 /* Available fields for NM_SETTING_BRIDGE_PORT_SETTING_NAME */
613 NmcOutputField nmc_fields_setting_bridge_port[] = {
614 SETTING_FIELD ("name"), /* 0 */
615 SETTING_FIELD (NM_SETTING_BRIDGE_PORT_PRIORITY), /* 1 */
616 SETTING_FIELD (NM_SETTING_BRIDGE_PORT_PATH_COST), /* 2 */
617 SETTING_FIELD (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE), /* 3 */
618 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
620 #define NMC_FIELDS_SETTING_BRIDGE_PORT_ALL "name"","\
621 NM_SETTING_BRIDGE_PORT_PRIORITY","\
622 NM_SETTING_BRIDGE_PORT_PATH_COST","\
623 NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE
625 /* Available fields for NM_SETTING_TEAM_SETTING_NAME */
626 NmcOutputField nmc_fields_setting_team[] = {
627 SETTING_FIELD ("name"), /* 0 */
628 SETTING_FIELD (NM_SETTING_TEAM_CONFIG), /* 1 */
629 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
631 #define NMC_FIELDS_SETTING_TEAM_ALL "name"","\
632 NM_SETTING_TEAM_CONFIG
634 /* Available fields for NM_SETTING_TEAM_PORT_SETTING_NAME */
635 NmcOutputField nmc_fields_setting_team_port[] = {
636 SETTING_FIELD ("name"), /* 0 */
637 SETTING_FIELD (NM_SETTING_TEAM_PORT_CONFIG), /* 1 */
638 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
640 #define NMC_FIELDS_SETTING_TEAM_PORT_ALL "name"","\
641 NM_SETTING_TEAM_PORT_CONFIG
643 /* Available fields for NM_SETTING_DCB_SETTING_NAME */
644 NmcOutputField nmc_fields_setting_dcb[] = {
645 SETTING_FIELD ("name"), /* 0 */
646 SETTING_FIELD (NM_SETTING_DCB_APP_FCOE_FLAGS), /* 1 */
647 SETTING_FIELD (NM_SETTING_DCB_APP_FCOE_PRIORITY), /* 2 */
648 SETTING_FIELD (NM_SETTING_DCB_APP_FCOE_MODE), /* 3 */
649 SETTING_FIELD (NM_SETTING_DCB_APP_ISCSI_FLAGS), /* 4 */
650 SETTING_FIELD (NM_SETTING_DCB_APP_ISCSI_PRIORITY), /* 5 */
651 SETTING_FIELD (NM_SETTING_DCB_APP_FIP_FLAGS), /* 6 */
652 SETTING_FIELD (NM_SETTING_DCB_APP_FIP_PRIORITY), /* 7 */
653 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS), /* 8 */
654 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL), /* 9 */
655 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS), /* 10 */
656 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_GROUP_ID), /* 11 */
657 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH), /* 12 */
658 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_BANDWIDTH), /* 13 */
659 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH), /* 14 */
660 SETTING_FIELD (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS), /* 15 */
661 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
663 #define NMC_FIELDS_SETTING_DCB_ALL "name"","\
664 NM_SETTING_DCB_APP_FCOE_FLAGS","\
665 NM_SETTING_DCB_APP_FCOE_PRIORITY","\
666 NM_SETTING_DCB_APP_FCOE_MODE","\
667 NM_SETTING_DCB_APP_ISCSI_FLAGS","\
668 NM_SETTING_DCB_APP_ISCSI_PRIORITY","\
669 NM_SETTING_DCB_APP_FIP_FLAGS","\
670 NM_SETTING_DCB_APP_FIP_PRIORITY","\
671 NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS","\
672 NM_SETTING_DCB_PRIORITY_FLOW_CONTROL","\
673 NM_SETTING_DCB_PRIORITY_GROUP_FLAGS","\
674 NM_SETTING_DCB_PRIORITY_GROUP_ID","\
675 NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH","\
676 NM_SETTING_DCB_PRIORITY_BANDWIDTH","\
677 NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH","\
678 NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS
680 /* Available fields for NM_SETTING_TUN_SETTING_NAME */
681 NmcOutputField nmc_fields_setting_tun[] = {
682 SETTING_FIELD ("name"), /* 0 */
683 SETTING_FIELD (NM_SETTING_TUN_MODE), /* 1 */
684 SETTING_FIELD (NM_SETTING_TUN_OWNER), /* 2 */
685 SETTING_FIELD (NM_SETTING_TUN_GROUP), /* 3 */
686 SETTING_FIELD (NM_SETTING_TUN_PI), /* 4 */
687 SETTING_FIELD (NM_SETTING_TUN_VNET_HDR), /* 5 */
688 SETTING_FIELD (NM_SETTING_TUN_MULTI_QUEUE), /* 6 */
689 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
691 #define NMC_FIELDS_SETTING_TUN_ALL "name"","\
692 NM_SETTING_TUN_MODE","\
693 NM_SETTING_TUN_OWNER","\
694 NM_SETTING_TUN_GROUP","\
695 NM_SETTING_TUN_PI","\
696 NM_SETTING_TUN_VNET_HDR","\
697 NM_SETTING_TUN_MULTI_QUEUE
699 /* Available fields for NM_SETTING_IP_TUNNEL_SETTING_NAME */
700 NmcOutputField nmc_fields_setting_ip_tunnel[] = {
701 SETTING_FIELD ("name"), /* 0 */
702 SETTING_FIELD (NM_SETTING_IP_TUNNEL_MODE), /* 1 */
703 SETTING_FIELD (NM_SETTING_IP_TUNNEL_PARENT), /* 2 */
704 SETTING_FIELD (NM_SETTING_IP_TUNNEL_LOCAL), /* 3 */
705 SETTING_FIELD (NM_SETTING_IP_TUNNEL_REMOTE), /* 4 */
706 SETTING_FIELD (NM_SETTING_IP_TUNNEL_TTL), /* 5 */
707 SETTING_FIELD (NM_SETTING_IP_TUNNEL_TOS), /* 6 */
708 SETTING_FIELD (NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), /* 7 */
709 SETTING_FIELD (NM_SETTING_IP_TUNNEL_INPUT_KEY), /* 8 */
710 SETTING_FIELD (NM_SETTING_IP_TUNNEL_OUTPUT_KEY), /* 9 */
711 SETTING_FIELD (NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), /* 10 */
712 SETTING_FIELD (NM_SETTING_IP_TUNNEL_FLOW_LABEL), /* 11 */
713 SETTING_FIELD (NM_SETTING_IP_TUNNEL_MTU), /* 12 */
714 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
716 #define NMC_FIELDS_SETTING_IP_TUNNEL_ALL "name"","\
717 NM_SETTING_IP_TUNNEL_MODE","\
718 NM_SETTING_IP_TUNNEL_PARENT","\
719 NM_SETTING_IP_TUNNEL_LOCAL","\
720 NM_SETTING_IP_TUNNEL_REMOTE","\
721 NM_SETTING_IP_TUNNEL_TTL","\
722 NM_SETTING_IP_TUNNEL_TOS","\
723 NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY","\
724 NM_SETTING_IP_TUNNEL_INPUT_KEY","\
725 NM_SETTING_IP_TUNNEL_OUTPUT_KEY","\
726 NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT","\
727 NM_SETTING_IP_TUNNEL_FLOW_LABEL","\
728 NM_SETTING_IP_TUNNEL_MTU
730 /* Available fields for NM_SETTING_MACVLAN_SETTING_NAME */
731 NmcOutputField nmc_fields_setting_macvlan[] = {
732 SETTING_FIELD ("name"), /* 0 */
733 SETTING_FIELD (NM_SETTING_MACVLAN_PARENT), /* 1 */
734 SETTING_FIELD (NM_SETTING_MACVLAN_MODE), /* 2 */
735 SETTING_FIELD (NM_SETTING_MACVLAN_PROMISCUOUS), /* 3 */
736 SETTING_FIELD (NM_SETTING_MACVLAN_TAP), /* 4 */
737 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
739 #define NMC_FIELDS_SETTING_MACVLAN_ALL "name"","\
740 NM_SETTING_MACVLAN_PARENT","\
741 NM_SETTING_MACVLAN_MODE","\
742 NM_SETTING_MACVLAN_PROMISCUOUS","\
743 NM_SETTING_MACVLAN_TAP
745 /* Available fields for NM_SETTING_VXLAN_SETTING_NAME */
746 NmcOutputField nmc_fields_setting_vxlan[] = {
747 SETTING_FIELD ("name"), /* 0 */
748 SETTING_FIELD (NM_SETTING_VXLAN_PARENT), /* 1 */
749 SETTING_FIELD (NM_SETTING_VXLAN_ID), /* 2 */
750 SETTING_FIELD (NM_SETTING_VXLAN_LOCAL), /* 3 */
751 SETTING_FIELD (NM_SETTING_VXLAN_REMOTE), /* 4 */
752 SETTING_FIELD (NM_SETTING_VXLAN_SOURCE_PORT_MIN), /* 5 */
753 SETTING_FIELD (NM_SETTING_VXLAN_SOURCE_PORT_MAX), /* 6 */
754 SETTING_FIELD (NM_SETTING_VXLAN_DESTINATION_PORT), /* 7 */
755 SETTING_FIELD (NM_SETTING_VXLAN_TOS), /* 8 */
756 SETTING_FIELD (NM_SETTING_VXLAN_TTL), /* 9 */
757 SETTING_FIELD (NM_SETTING_VXLAN_AGEING), /* 10 */
758 SETTING_FIELD (NM_SETTING_VXLAN_LIMIT), /* 11 */
759 SETTING_FIELD (NM_SETTING_VXLAN_LEARNING), /* 12 */
760 SETTING_FIELD (NM_SETTING_VXLAN_PROXY), /* 13 */
761 SETTING_FIELD (NM_SETTING_VXLAN_RSC), /* 14 */
762 SETTING_FIELD (NM_SETTING_VXLAN_L2_MISS), /* 15 */
763 SETTING_FIELD (NM_SETTING_VXLAN_L3_MISS), /* 16 */
764 {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
766 #define NMC_FIELDS_SETTING_VXLAN_ALL "name"","\
767 NM_SETTING_VXLAN_PARENT","\
768 NM_SETTING_VXLAN_ID","\
769 NM_SETTING_VXLAN_LOCAL","\
770 NM_SETTING_VXLAN_REMOTE","\
771 NM_SETTING_VXLAN_SOURCE_PORT_MIN","\
772 NM_SETTING_VXLAN_SOURCE_PORT_MAX","\
773 NM_SETTING_VXLAN_DESTINATION_PORT","\
774 NM_SETTING_VXLAN_TOS","\
775 NM_SETTING_VXLAN_TTL","\
776 NM_SETTING_VXLAN_AGEING","\
777 NM_SETTING_VXLAN_LIMIT","\
778 NM_SETTING_VXLAN_LEARNING","\
779 NM_SETTING_VXLAN_PROXY","\
780 NM_SETTING_VXLAN_RSC","\
781 NM_SETTING_VXLAN_L2_MISS","\
782 NM_SETTING_VXLAN_L3_MISS
784 /*----------------------------------------------------------------------------*/
786 wep_key_type_to_string (NMWepKeyType type)
789 case NM_WEP_KEY_TYPE_KEY:
790 return g_strdup_printf (_("%d (key)"), type);
791 case NM_WEP_KEY_TYPE_PASSPHRASE:
792 return g_strdup_printf (_("%d (passphrase)"), type);
793 case NM_WEP_KEY_TYPE_UNKNOWN:
795 return g_strdup_printf (_("%d (unknown)"), type);
800 bytes_to_string (GBytes *bytes)
804 GString *cert = NULL;
809 data = g_bytes_get_data (bytes, &len);
811 cert = g_string_new (NULL);
812 for (i = 0; i < len; i++)
813 g_string_append_printf (cert, "%02X", data[i]);
815 return g_string_free (cert, FALSE);
819 vlan_flags_to_string (guint32 flags)
824 return g_strdup (_("0 (NONE)"));
826 flag_str = g_string_new (NULL);
827 g_string_printf (flag_str, "%d (", flags);
829 if (flags & NM_VLAN_FLAG_REORDER_HEADERS)
830 g_string_append (flag_str, _("REORDER_HEADERS, "));
831 if (flags & NM_VLAN_FLAG_GVRP)
832 g_string_append (flag_str, _("GVRP, "));
833 if (flags & NM_VLAN_FLAG_LOOSE_BINDING)
834 g_string_append (flag_str, _("LOOSE_BINDING, "));
835 if (flags & NM_VLAN_FLAG_MVRP)
836 g_string_append (flag_str, _("MVRP, "));
838 if (flag_str->str[flag_str->len-1] == '(')
839 g_string_append (flag_str, _("unknown"));
841 g_string_truncate (flag_str, flag_str->len-2); /* chop off trailing ', ' */
843 g_string_append_c (flag_str, ')');
845 return g_string_free (flag_str, FALSE);
849 vlan_priorities_to_string (NMSettingVlan *s_vlan, NMVlanPriorityMap map)
854 priorities = g_string_new (NULL);
855 for (i = 0; i < nm_setting_vlan_get_num_priorities (s_vlan, map); i++) {
858 if (nm_setting_vlan_get_priority (s_vlan, map, i, &from, &to))
859 g_string_append_printf (priorities, "%d:%d,", from, to);
862 g_string_truncate (priorities, priorities->len-1); /* chop off trailing ',' */
864 return g_string_free (priorities, FALSE);
868 ip6_privacy_to_string (NMSettingIP6ConfigPrivacy ip6_privacy, NmcPropertyGetType get_type)
870 if (get_type == NMC_PROPERTY_GET_PARSABLE)
871 return g_strdup_printf ("%d", ip6_privacy);
873 switch (ip6_privacy) {
874 case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED:
875 return g_strdup_printf (_("%d (disabled)"), ip6_privacy);
876 case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR:
877 return g_strdup_printf (_("%d (enabled, prefer public IP)"), ip6_privacy);
878 case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR:
879 return g_strdup_printf (_("%d (enabled, prefer temporary IP)"), ip6_privacy);
881 return g_strdup_printf (_("%d (unknown)"), ip6_privacy);
886 autoconnect_slaves_to_string (NMSettingConnectionAutoconnectSlaves autoconnect_slaves,
887 NmcPropertyGetType get_type)
889 if (get_type == NMC_PROPERTY_GET_PARSABLE)
890 return g_strdup_printf ("%d", autoconnect_slaves);
892 switch (autoconnect_slaves) {
893 case NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO:
894 return g_strdup_printf (_("%d (no)"), autoconnect_slaves);
895 case NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES:
896 return g_strdup_printf (_("%d (yes)"), autoconnect_slaves);
897 case NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT:
899 return g_strdup_printf (_("%d (default)"), autoconnect_slaves);
904 secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type)
908 if (get_type == NMC_PROPERTY_GET_PARSABLE)
909 return g_strdup_printf ("%u", flags);
912 return g_strdup (_("0 (none)"));
914 flag_str = g_string_new (NULL);
915 g_string_printf (flag_str, "%u (", flags);
917 if (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED)
918 g_string_append (flag_str, _("agent-owned, "));
919 if (flags & NM_SETTING_SECRET_FLAG_NOT_SAVED)
920 g_string_append (flag_str, _("not saved, "));
921 if (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
922 g_string_append (flag_str, _("not required, "));
924 if (flag_str->str[flag_str->len-1] == '(')
925 g_string_append (flag_str, _("unknown"));
927 g_string_truncate (flag_str, flag_str->len-2); /* chop off trailing ', ' */
929 g_string_append_c (flag_str, ')');
931 return g_string_free (flag_str, FALSE);
935 vpn_data_item (const char *key, const char *value, gpointer user_data)
937 GString *ret_str = (GString *) user_data;
939 if (ret_str->len != 0)
940 g_string_append (ret_str, ", ");
942 g_string_append_printf (ret_str, "%s = %s", key, value);
946 /* === property get functions === */
947 #define DEFINE_GETTER(func_name, property_name) \
949 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
952 GValue val = G_VALUE_INIT; \
953 g_value_init (&val, G_TYPE_STRING); \
954 g_object_get_property (G_OBJECT (setting), property_name, &val); \
955 s = g_value_dup_string (&val); \
956 g_value_unset (&val); \
960 #define DEFINE_GETTER_WITH_DEFAULT(func_name, property_name, check_is_default) \
962 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
966 GValue val = G_VALUE_INIT; \
968 if ((check_is_default)) { \
969 if (get_type == NMC_PROPERTY_GET_PARSABLE) \
970 return g_strdup (""); \
971 return g_strdup (_("(default)")); \
974 g_value_init (&val, G_TYPE_STRING); \
975 g_object_get_property (G_OBJECT (setting), property_name, &val); \
976 s = g_value_get_string (&val); \
977 if (get_type == NMC_PROPERTY_GET_PARSABLE) \
978 s_full = g_strdup (s && *s ? s : " "); \
980 s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); \
981 g_value_unset (&val); \
985 #define DEFINE_SECRET_FLAGS_GETTER(func_name, property_name) \
987 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
990 GValue val = G_VALUE_INIT; \
991 g_value_init (&val, G_TYPE_UINT); \
992 g_object_get_property (G_OBJECT (setting), property_name, &val); \
993 v = g_value_get_uint (&val); \
994 g_value_unset (&val); \
995 return secret_flags_to_string (v, get_type); \
998 /* --- NM_SETTING_802_1X_SETTING_NAME property get functions --- */
999 DEFINE_GETTER (nmc_property_802_1X_get_eap, NM_SETTING_802_1X_EAP)
1000 DEFINE_GETTER (nmc_property_802_1X_get_identity, NM_SETTING_802_1X_IDENTITY)
1001 DEFINE_GETTER (nmc_property_802_1X_get_anonymous_identity, NM_SETTING_802_1X_ANONYMOUS_IDENTITY)
1002 DEFINE_GETTER (nmc_property_802_1X_get_pac_file, NM_SETTING_802_1X_PAC_FILE)
1003 DEFINE_GETTER (nmc_property_802_1X_get_ca_path, NM_SETTING_802_1X_CA_PATH)
1004 DEFINE_GETTER (nmc_property_802_1X_get_subject_match, NM_SETTING_802_1X_SUBJECT_MATCH)
1005 DEFINE_GETTER (nmc_property_802_1X_get_altsubject_matches, NM_SETTING_802_1X_ALTSUBJECT_MATCHES)
1006 DEFINE_GETTER (nmc_property_802_1X_get_domain_suffix_match, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH)
1007 DEFINE_GETTER (nmc_property_802_1X_get_phase1_peapver, NM_SETTING_802_1X_PHASE1_PEAPVER)
1008 DEFINE_GETTER (nmc_property_802_1X_get_phase1_peaplabel, NM_SETTING_802_1X_PHASE1_PEAPLABEL)
1009 DEFINE_GETTER (nmc_property_802_1X_get_phase1_fast_provisioning, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING)
1010 DEFINE_GETTER (nmc_property_802_1X_get_phase2_auth, NM_SETTING_802_1X_PHASE2_AUTH)
1011 DEFINE_GETTER (nmc_property_802_1X_get_phase2_autheap, NM_SETTING_802_1X_PHASE2_AUTHEAP)
1012 DEFINE_GETTER (nmc_property_802_1X_get_phase2_ca_path, NM_SETTING_802_1X_PHASE2_CA_PATH)
1013 DEFINE_GETTER (nmc_property_802_1X_get_phase2_subject_match, NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH)
1014 DEFINE_GETTER (nmc_property_802_1X_get_phase2_altsubject_matches, NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES)
1015 DEFINE_GETTER (nmc_property_802_1X_get_phase2_domain_suffix_match, NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH)
1016 DEFINE_GETTER (nmc_property_802_1X_get_password, NM_SETTING_802_1X_PASSWORD)
1017 DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_password_flags, NM_SETTING_802_1X_PASSWORD_FLAGS)
1018 DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_password_raw_flags, NM_SETTING_802_1X_PASSWORD_RAW_FLAGS)
1019 DEFINE_GETTER (nmc_property_802_1X_get_private_key_password, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD)
1020 DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_private_key_password_flags, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS)
1021 DEFINE_GETTER (nmc_property_802_1X_get_phase2_private_key_password, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD)
1022 DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_phase2_private_key_password_flags, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS)
1023 DEFINE_GETTER (nmc_property_802_1X_get_pin, NM_SETTING_802_1X_PIN)
1024 DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_pin_flags, NM_SETTING_802_1X_PIN_FLAGS)
1025 DEFINE_GETTER (nmc_property_802_1X_get_system_ca_certs, NM_SETTING_802_1X_SYSTEM_CA_CERTS)
1028 nmc_property_802_1X_get_ca_cert (NMSetting *setting, NmcPropertyGetType get_type)
1030 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1031 NMSetting8021xCKScheme scheme;
1032 char *ca_cert_str = NULL;
1034 scheme = nm_setting_802_1x_get_ca_cert_scheme (s_8021X);
1035 if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
1036 ca_cert_str = bytes_to_string (nm_setting_802_1x_get_ca_cert_blob (s_8021X));
1037 if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
1038 ca_cert_str = g_strdup (nm_setting_802_1x_get_ca_cert_path (s_8021X));
1044 nmc_property_802_1X_get_client_cert (NMSetting *setting, NmcPropertyGetType get_type)
1046 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1047 NMSetting8021xCKScheme scheme;
1048 char *client_cert_str = NULL;
1050 scheme = nm_setting_802_1x_get_client_cert_scheme (s_8021X);
1051 if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
1052 client_cert_str = bytes_to_string (nm_setting_802_1x_get_client_cert_blob (s_8021X));
1053 if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
1054 client_cert_str = g_strdup (nm_setting_802_1x_get_client_cert_path (s_8021X));
1056 return client_cert_str;
1060 nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting, NmcPropertyGetType get_type)
1062 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1063 NMSetting8021xCKScheme scheme;
1064 char *phase2_ca_cert_str = NULL;
1066 scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (s_8021X);
1067 if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
1068 phase2_ca_cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_ca_cert_blob (s_8021X));
1069 if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
1070 phase2_ca_cert_str = g_strdup (nm_setting_802_1x_get_phase2_ca_cert_path (s_8021X));
1072 return phase2_ca_cert_str;
1076 nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting, NmcPropertyGetType get_type)
1078 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1079 NMSetting8021xCKScheme scheme;
1080 char *phase2_client_cert_str = NULL;
1082 scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (s_8021X);
1083 if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
1084 phase2_client_cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_client_cert_blob (s_8021X));
1085 if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
1086 phase2_client_cert_str = g_strdup (nm_setting_802_1x_get_phase2_client_cert_path (s_8021X));
1088 return phase2_client_cert_str;
1092 nmc_property_802_1X_get_password_raw (NMSetting *setting, NmcPropertyGetType get_type)
1094 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1095 return bytes_to_string (nm_setting_802_1x_get_password_raw (s_8021X));
1099 nmc_property_802_1X_get_private_key (NMSetting *setting, NmcPropertyGetType get_type)
1101 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1102 NMSetting8021xCKScheme scheme;
1103 char *private_key_str = NULL;
1105 scheme = nm_setting_802_1x_get_private_key_scheme (s_8021X);
1106 if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
1107 private_key_str = bytes_to_string (nm_setting_802_1x_get_private_key_blob (s_8021X));
1108 if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
1109 private_key_str = g_strdup (nm_setting_802_1x_get_private_key_path (s_8021X));
1111 return private_key_str;
1115 nmc_property_802_1X_get_phase2_private_key (NMSetting *setting, NmcPropertyGetType get_type)
1117 NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1118 NMSetting8021xCKScheme scheme;
1119 char *phase2_private_key_str = NULL;
1121 scheme = nm_setting_802_1x_get_phase2_private_key_scheme (s_8021X);
1122 if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
1123 phase2_private_key_str = bytes_to_string (nm_setting_802_1x_get_phase2_private_key_blob (s_8021X));
1124 if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
1125 phase2_private_key_str = g_strdup (nm_setting_802_1x_get_phase2_private_key_path (s_8021X));
1127 return phase2_private_key_str;
1130 /* --- NM_SETTING_ADSL_SETTING_NAME property get functions --- */
1131 DEFINE_GETTER (nmc_property_adsl_get_username, NM_SETTING_ADSL_USERNAME)
1132 DEFINE_GETTER (nmc_property_adsl_get_password, NM_SETTING_ADSL_PASSWORD)
1133 DEFINE_SECRET_FLAGS_GETTER (nmc_property_adsl_get_password_flags, NM_SETTING_ADSL_PASSWORD_FLAGS)
1134 DEFINE_GETTER (nmc_property_adsl_get_protocol, NM_SETTING_ADSL_PROTOCOL)
1135 DEFINE_GETTER (nmc_property_adsl_get_encapsulation, NM_SETTING_ADSL_ENCAPSULATION)
1136 DEFINE_GETTER (nmc_property_adsl_get_vpi, NM_SETTING_ADSL_VPI)
1137 DEFINE_GETTER (nmc_property_adsl_get_vci, NM_SETTING_ADSL_VCI)
1139 /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property get functions --- */
1140 DEFINE_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR)
1141 DEFINE_GETTER (nmc_property_bluetooth_get_type, NM_SETTING_BLUETOOTH_TYPE)
1144 nmc_property_bond_get_options (NMSetting *setting, NmcPropertyGetType get_type)
1146 NMSettingBond *s_bond = NM_SETTING_BOND (setting);
1147 GString *bond_options_s;
1150 bond_options_s = g_string_new (NULL);
1151 for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) {
1152 const char *key, *value;
1154 nm_setting_bond_get_option (s_bond, i, &key, &value);
1155 g_string_append_printf (bond_options_s, "%s=%s,", key, value);
1157 g_string_truncate (bond_options_s, bond_options_s->len-1); /* chop off trailing ',' */
1159 return g_string_free (bond_options_s, FALSE);
1162 /* --- NM_SETTING_BRIDGE_SETTING_NAME property get functions --- */
1163 DEFINE_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS)
1164 DEFINE_GETTER (nmc_property_bridge_get_stp, NM_SETTING_BRIDGE_STP)
1165 DEFINE_GETTER (nmc_property_bridge_get_priority, NM_SETTING_BRIDGE_PRIORITY)
1166 DEFINE_GETTER (nmc_property_bridge_get_forward_delay, NM_SETTING_BRIDGE_FORWARD_DELAY)
1167 DEFINE_GETTER (nmc_property_bridge_get_hello_time, NM_SETTING_BRIDGE_HELLO_TIME)
1168 DEFINE_GETTER (nmc_property_bridge_get_max_age, NM_SETTING_BRIDGE_MAX_AGE)
1169 DEFINE_GETTER (nmc_property_bridge_get_ageing_time, NM_SETTING_BRIDGE_AGEING_TIME)
1170 DEFINE_GETTER (nmc_property_bridge_get_multicast_snooping, NM_SETTING_BRIDGE_MULTICAST_SNOOPING)
1172 /* --- NM_SETTING_BRIDGE_PORT_SETTING_NAME property get functions --- */
1173 DEFINE_GETTER (nmc_property_bridge_port_get_priority, NM_SETTING_BRIDGE_PORT_PRIORITY)
1174 DEFINE_GETTER (nmc_property_bridge_port_get_path_cost, NM_SETTING_BRIDGE_PORT_PATH_COST)
1175 DEFINE_GETTER (nmc_property_bridge_port_get_hairpin_mode, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE)
1177 /* --- NM_SETTING_TEAM_SETTING_NAME property get functions --- */
1178 DEFINE_GETTER (nmc_property_team_get_config, NM_SETTING_TEAM_CONFIG)
1180 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property get functions --- */
1181 DEFINE_GETTER (nmc_property_team_port_get_config, NM_SETTING_TEAM_PORT_CONFIG)
1183 /* --- NM_SETTING_CDMA_SETTING_NAME property get functions --- */
1184 DEFINE_GETTER (nmc_property_cdma_get_number, NM_SETTING_CDMA_NUMBER)
1185 DEFINE_GETTER (nmc_property_cdma_get_username, NM_SETTING_CDMA_USERNAME)
1186 DEFINE_GETTER (nmc_property_cdma_get_password, NM_SETTING_CDMA_PASSWORD)
1188 DEFINE_SECRET_FLAGS_GETTER (nmc_property_cdma_get_password_flags, NM_SETTING_CDMA_PASSWORD_FLAGS)
1190 /* --- NM_SETTING_CONNECTION_SETTING_NAME property get functions --- */
1191 DEFINE_GETTER (nmc_property_connection_get_id, NM_SETTING_CONNECTION_ID)
1192 DEFINE_GETTER (nmc_property_connection_get_uuid, NM_SETTING_CONNECTION_UUID)
1193 DEFINE_GETTER (nmc_property_connection_get_interface_name, NM_SETTING_CONNECTION_INTERFACE_NAME)
1194 DEFINE_GETTER (nmc_property_connection_get_type, NM_SETTING_CONNECTION_TYPE)
1195 DEFINE_GETTER (nmc_property_connection_get_autoconnect, NM_SETTING_CONNECTION_AUTOCONNECT)
1196 DEFINE_GETTER (nmc_property_connection_get_autoconnect_priority, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY)
1197 DEFINE_GETTER (nmc_property_connection_get_timestamp, NM_SETTING_CONNECTION_TIMESTAMP)
1198 DEFINE_GETTER (nmc_property_connection_get_read_only, NM_SETTING_CONNECTION_READ_ONLY)
1201 nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType get_type)
1203 NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1204 GString *perm = NULL;
1205 const char *perm_item;
1206 const char *perm_type;
1209 perm = g_string_new (NULL);
1210 for (i = 0; i < nm_setting_connection_get_num_permissions (s_con); i++) {
1211 if (nm_setting_connection_get_permission (s_con, i, &perm_type, &perm_item, NULL))
1212 g_string_append_printf (perm, "%s:%s,", perm_type, perm_item);
1215 g_string_truncate (perm, perm->len-1); /* remove trailing , */
1217 return g_string_free (perm, FALSE);
1220 DEFINE_GETTER (nmc_property_connection_get_zone, NM_SETTING_CONNECTION_ZONE)
1221 DEFINE_GETTER (nmc_property_connection_get_master, NM_SETTING_CONNECTION_MASTER)
1222 DEFINE_GETTER (nmc_property_connection_get_slave_type, NM_SETTING_CONNECTION_SLAVE_TYPE)
1225 nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyGetType get_type)
1227 NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1228 return autoconnect_slaves_to_string (nm_setting_connection_get_autoconnect_slaves (s_con), get_type);
1231 DEFINE_GETTER (nmc_property_connection_get_secondaries, NM_SETTING_CONNECTION_SECONDARIES)
1232 DEFINE_GETTER (nmc_property_connection_get_gateway_ping_timeout, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT)
1234 /* --- NM_SETTING_DCB_SETTING_NAME property get functions --- */
1236 dcb_flags_to_string (NMSettingDcbFlags flags)
1241 return g_strdup (_("0 (disabled)"));
1243 flag_str = g_string_new (NULL);
1244 g_string_printf (flag_str, "%d (", flags);
1246 if (flags & NM_SETTING_DCB_FLAG_ENABLE)
1247 g_string_append (flag_str, _("enabled, "));
1248 if (flags & NM_SETTING_DCB_FLAG_ADVERTISE)
1249 g_string_append (flag_str, _("advertise, "));
1250 if (flags & NM_SETTING_DCB_FLAG_WILLING)
1251 g_string_append (flag_str, _("willing, "));
1253 if (flag_str->str[flag_str->len-1] == '(')
1254 g_string_append (flag_str, _("unknown"));
1256 g_string_truncate (flag_str, flag_str->len-2); /* chop off trailing ', ' */
1258 g_string_append_c (flag_str, ')');
1260 return g_string_free (flag_str, FALSE);
1263 #define DEFINE_DCB_FLAGS_GETTER(func_name, property_name) \
1265 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1268 GValue val = G_VALUE_INIT; \
1269 g_value_init (&val, G_TYPE_UINT); \
1270 g_object_get_property (G_OBJECT (setting), property_name, &val); \
1271 v = g_value_get_uint (&val); \
1272 g_value_unset (&val); \
1273 return dcb_flags_to_string (v); \
1277 dcb_app_priority_to_string (gint priority)
1279 return (priority == -1) ? g_strdup (_("-1 (unset)")) : g_strdup_printf ("%d", priority);
1282 #define DEFINE_DCB_APP_PRIORITY_GETTER(func_name, property_name) \
1284 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1287 GValue val = G_VALUE_INIT; \
1288 g_value_init (&val, G_TYPE_INT); \
1289 g_object_get_property (G_OBJECT (setting), property_name, &val); \
1290 v = g_value_get_int (&val); \
1291 g_value_unset (&val); \
1292 return dcb_app_priority_to_string (v); \
1295 #define DEFINE_DCB_BOOL_GETTER(func_name, getter_func_name) \
1297 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1299 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1303 str = g_string_new (NULL); \
1304 for (i = 0; i < 8; i++) { \
1305 if (getter_func_name (s_dcb, i)) \
1306 g_string_append_c (str, '1'); \
1308 g_string_append_c (str, '0'); \
1311 g_string_append_c (str, ','); \
1314 return g_string_free (str, FALSE); \
1317 #define DEFINE_DCB_UINT_GETTER(func_name, getter_func_name) \
1319 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1321 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1325 str = g_string_new (NULL); \
1326 for (i = 0; i < 8; i++) { \
1327 g_string_append_printf (str, "%u", getter_func_name (s_dcb, i)); \
1329 g_string_append_c (str, ','); \
1332 return g_string_free (str, FALSE); \
1335 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS)
1336 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fcoe_priority, NM_SETTING_DCB_APP_FCOE_PRIORITY)
1337 DEFINE_GETTER (nmc_property_dcb_get_app_fcoe_mode, NM_SETTING_DCB_APP_FCOE_MODE)
1338 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS)
1339 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_iscsi_priority, NM_SETTING_DCB_APP_ISCSI_PRIORITY)
1340 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS)
1341 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fip_priority, NM_SETTING_DCB_APP_FIP_PRIORITY)
1343 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS)
1344 DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pfc, nm_setting_dcb_get_priority_flow_control)
1346 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pg_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS)
1347 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_id, nm_setting_dcb_get_priority_group_id)
1348 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_bandwidth, nm_setting_dcb_get_priority_group_bandwidth)
1349 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_bandwidth, nm_setting_dcb_get_priority_bandwidth)
1350 DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pg_strict, nm_setting_dcb_get_priority_strict_bandwidth)
1351 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_traffic_class, nm_setting_dcb_get_priority_traffic_class)
1353 /* --- NM_SETTING_GSM_SETTING_NAME property get functions --- */
1354 DEFINE_GETTER (nmc_property_gsm_get_number, NM_SETTING_GSM_NUMBER)
1355 DEFINE_GETTER (nmc_property_gsm_get_username, NM_SETTING_GSM_USERNAME)
1356 DEFINE_GETTER (nmc_property_gsm_get_password, NM_SETTING_GSM_PASSWORD)
1357 DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_password_flags, NM_SETTING_GSM_PASSWORD_FLAGS)
1358 DEFINE_GETTER (nmc_property_gsm_get_apn, NM_SETTING_GSM_APN)
1359 DEFINE_GETTER (nmc_property_gsm_get_network_id, NM_SETTING_GSM_NETWORK_ID)
1360 DEFINE_GETTER (nmc_property_gsm_get_pin, NM_SETTING_GSM_PIN)
1361 DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_pin_flags, NM_SETTING_GSM_PIN_FLAGS)
1362 DEFINE_GETTER (nmc_property_gsm_get_home_only, NM_SETTING_GSM_HOME_ONLY)
1363 DEFINE_GETTER (nmc_property_gsm_get_device_id, NM_SETTING_GSM_DEVICE_ID)
1364 DEFINE_GETTER (nmc_property_gsm_get_sim_id, NM_SETTING_GSM_SIM_ID)
1365 DEFINE_GETTER (nmc_property_gsm_get_sim_operator_id, NM_SETTING_GSM_SIM_OPERATOR_ID)
1367 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property get functions --- */
1368 DEFINE_GETTER (nmc_property_ib_get_mac_address, NM_SETTING_INFINIBAND_MAC_ADDRESS)
1369 DEFINE_GETTER (nmc_property_ib_get_transport_mode, NM_SETTING_INFINIBAND_TRANSPORT_MODE)
1371 /* --- NM_SETTING_TUN_SETTING_NAME property get functions --- */
1372 DEFINE_GETTER (nmc_property_tun_get_owner, NM_SETTING_TUN_OWNER);
1373 DEFINE_GETTER (nmc_property_tun_get_group, NM_SETTING_TUN_GROUP);
1374 DEFINE_GETTER (nmc_property_tun_get_pi, NM_SETTING_TUN_PI);
1375 DEFINE_GETTER (nmc_property_tun_get_vnet_hdr, NM_SETTING_TUN_VNET_HDR);
1376 DEFINE_GETTER (nmc_property_tun_get_multi_queue, NM_SETTING_TUN_MULTI_QUEUE);
1378 /* --- NM_SETTING_IP_TUNNEL_SETTING_NAME property get functions --- */
1379 DEFINE_GETTER (nmc_property_ip_tunnel_get_parent, NM_SETTING_IP_TUNNEL_PARENT);
1380 DEFINE_GETTER (nmc_property_ip_tunnel_get_local, NM_SETTING_IP_TUNNEL_LOCAL);
1381 DEFINE_GETTER (nmc_property_ip_tunnel_get_remote, NM_SETTING_IP_TUNNEL_REMOTE);
1382 DEFINE_GETTER (nmc_property_ip_tunnel_get_ttl, NM_SETTING_IP_TUNNEL_TTL);
1383 DEFINE_GETTER (nmc_property_ip_tunnel_get_tos, NM_SETTING_IP_TUNNEL_TOS);
1384 DEFINE_GETTER (nmc_property_ip_tunnel_get_path_mtu_discovery, NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY);
1385 DEFINE_GETTER (nmc_property_ip_tunnel_get_input_key, NM_SETTING_IP_TUNNEL_INPUT_KEY);
1386 DEFINE_GETTER (nmc_property_ip_tunnel_get_output_key, NM_SETTING_IP_TUNNEL_OUTPUT_KEY);
1387 DEFINE_GETTER (nmc_property_ip_tunnel_get_encapsulation_limit, NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT);
1388 DEFINE_GETTER (nmc_property_ip_tunnel_get_flow_label, NM_SETTING_IP_TUNNEL_FLOW_LABEL);
1389 DEFINE_GETTER (nmc_property_ip_tunnel_get_mtu, NM_SETTING_IP_TUNNEL_MTU);
1391 static const char **
1392 nmc_property_ip_tunnel_allowed_mode (NMSetting *setting, const char *prop)
1394 static const char **words = NULL;
1397 words = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1398 NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1404 nmc_property_ib_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1406 NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1409 mtu = nm_setting_infiniband_get_mtu (s_infiniband);
1411 return g_strdup (_("auto"));
1413 return g_strdup_printf ("%d", mtu);
1417 nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type)
1419 NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1422 p_key = nm_setting_infiniband_get_p_key (s_infiniband);
1424 return g_strdup (_("default"));
1426 return g_strdup_printf ("0x%04x", p_key);
1429 DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
1431 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property get functions --- */
1432 DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP_CONFIG_METHOD)
1433 DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP_CONFIG_DNS)
1434 DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH)
1435 DEFINE_GETTER_WITH_DEFAULT (nmc_property_ipv4_get_dns_options, NM_SETTING_IP_CONFIG_DNS_OPTIONS, !nm_setting_ip_config_has_dns_options ((NMSettingIPConfig *) setting))
1438 nmc_property_ip_get_addresses (NMSetting *setting, NmcPropertyGetType get_type)
1440 NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1442 guint32 num_addresses, i;
1445 printable = g_string_new (NULL);
1447 num_addresses = nm_setting_ip_config_get_num_addresses (s_ip);
1448 for (i = 0; i < num_addresses; i++) {
1449 addr = nm_setting_ip_config_get_address (s_ip, i);
1451 if (printable->len > 0)
1452 g_string_append (printable, ", ");
1454 g_string_append_printf (printable, "%s/%u",
1455 nm_ip_address_get_address (addr),
1456 nm_ip_address_get_prefix (addr));
1459 return g_string_free (printable, FALSE);
1463 nmc_property_ipvx_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1465 NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1467 guint32 num_routes, i;
1470 printable = g_string_new (NULL);
1472 num_routes = nm_setting_ip_config_get_num_routes (s_ip);
1473 for (i = 0; i < num_routes; i++) {
1474 route = nm_setting_ip_config_get_route (s_ip, i);
1476 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1477 if (printable->len > 0)
1478 g_string_append (printable, ", ");
1480 g_string_append_printf (printable, "%s/%u",
1481 nm_ip_route_get_dest (route),
1482 nm_ip_route_get_prefix (route));
1484 if (nm_ip_route_get_next_hop (route))
1485 g_string_append_printf (printable, " %s", nm_ip_route_get_next_hop (route));
1486 if (nm_ip_route_get_metric (route) != -1)
1487 g_string_append_printf (printable, " %u", (guint32) nm_ip_route_get_metric (route));
1489 if (printable->len > 0)
1490 g_string_append (printable, "; ");
1492 g_string_append (printable, "{ ");
1494 g_string_append_printf (printable, "ip = %s/%u",
1495 nm_ip_route_get_dest (route),
1496 nm_ip_route_get_prefix (route));
1498 if (nm_ip_route_get_next_hop (route)) {
1499 g_string_append_printf (printable, ", nh = %s",
1500 nm_ip_route_get_next_hop (route));
1503 if (nm_ip_route_get_metric (route) != -1)
1504 g_string_append_printf (printable, ", mt = %u", (guint32) nm_ip_route_get_metric (route));
1506 g_string_append (printable, " }");
1510 return g_string_free (printable, FALSE);
1514 nmc_property_ipv4_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1516 return nmc_property_ipvx_get_routes (setting, get_type);
1519 DEFINE_GETTER (nmc_property_ipv4_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY)
1520 DEFINE_GETTER (nmc_property_ipv4_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC)
1521 DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
1522 DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
1523 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)
1524 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_timeout, NM_SETTING_IP_CONFIG_DHCP_TIMEOUT)
1525 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
1526 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
1527 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_fqdn, NM_SETTING_IP4_CONFIG_DHCP_FQDN)
1528 DEFINE_GETTER (nmc_property_ipv4_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
1529 DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL)
1532 nmc_property_ipv4_get_dad_timeout (NMSetting *setting, NmcPropertyGetType get_type)
1534 NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1537 dad_timeout = nm_setting_ip_config_get_dad_timeout (s_ip);
1538 if (get_type == NMC_PROPERTY_GET_PARSABLE)
1539 return g_strdup_printf ("%d", dad_timeout);
1541 switch (dad_timeout) {
1543 return g_strdup_printf (_("%d (default)"), dad_timeout);
1545 return g_strdup_printf (_("%d (off)"), dad_timeout);
1547 return g_strdup_printf ("%d", dad_timeout);
1551 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property get functions --- */
1552 DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP_CONFIG_METHOD)
1553 DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP_CONFIG_DNS)
1554 DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH)
1555 DEFINE_GETTER_WITH_DEFAULT (nmc_property_ipv6_get_dns_options, NM_SETTING_IP_CONFIG_DNS_OPTIONS, !nm_setting_ip_config_has_dns_options ((NMSettingIPConfig *) setting))
1558 nmc_property_ipv6_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1560 return nmc_property_ipvx_get_routes (setting, get_type);
1563 DEFINE_GETTER (nmc_property_ipv6_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY)
1564 DEFINE_GETTER (nmc_property_ipv6_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC)
1565 DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
1566 DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
1567 DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
1568 DEFINE_GETTER (nmc_property_ipv6_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL)
1569 DEFINE_GETTER (nmc_property_ipv6_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
1570 DEFINE_GETTER (nmc_property_ipv6_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
1573 nmc_property_ipv6_get_ip6_privacy (NMSetting *setting, NmcPropertyGetType get_type)
1575 NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
1576 return ip6_privacy_to_string (nm_setting_ip6_config_get_ip6_privacy (s_ip6), get_type);
1579 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property get functions --- */
1580 DEFINE_GETTER (nmc_property_olpc_get_channel, NM_SETTING_OLPC_MESH_CHANNEL)
1581 DEFINE_GETTER (nmc_property_olpc_get_anycast_address, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)
1584 nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1586 NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
1588 char *ssid_str = NULL;
1590 ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
1592 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1593 g_bytes_get_size (ssid));
1599 /* --- NM_SETTING_PPP_SETTING_NAME property get functions --- */
1600 DEFINE_GETTER (nmc_property_ppp_get_noauth, NM_SETTING_PPP_NOAUTH)
1601 DEFINE_GETTER (nmc_property_ppp_get_refuse_eap, NM_SETTING_PPP_REFUSE_EAP)
1602 DEFINE_GETTER (nmc_property_ppp_get_refuse_pap, NM_SETTING_PPP_REFUSE_PAP)
1603 DEFINE_GETTER (nmc_property_ppp_get_refuse_chap, NM_SETTING_PPP_REFUSE_CHAP)
1604 DEFINE_GETTER (nmc_property_ppp_get_refuse_mschap, NM_SETTING_PPP_REFUSE_MSCHAP)
1605 DEFINE_GETTER (nmc_property_ppp_get_refuse_mschapv2, NM_SETTING_PPP_REFUSE_MSCHAPV2)
1606 DEFINE_GETTER (nmc_property_ppp_get_nobsdcomp, NM_SETTING_PPP_NOBSDCOMP)
1607 DEFINE_GETTER (nmc_property_ppp_get_nodeflate, NM_SETTING_PPP_NODEFLATE)
1608 DEFINE_GETTER (nmc_property_ppp_get_no_vj_comp, NM_SETTING_PPP_NO_VJ_COMP)
1609 DEFINE_GETTER (nmc_property_ppp_get_require_mppe, NM_SETTING_PPP_REQUIRE_MPPE)
1610 DEFINE_GETTER (nmc_property_ppp_get_require_mppe_128, NM_SETTING_PPP_REQUIRE_MPPE_128)
1611 DEFINE_GETTER (nmc_property_ppp_get_mppe_stateful, NM_SETTING_PPP_MPPE_STATEFUL)
1612 DEFINE_GETTER (nmc_property_ppp_get_crtscts, NM_SETTING_PPP_CRTSCTS)
1613 DEFINE_GETTER (nmc_property_ppp_get_baud, NM_SETTING_PPP_BAUD)
1614 DEFINE_GETTER (nmc_property_ppp_get_mru, NM_SETTING_PPP_MRU)
1615 DEFINE_GETTER (nmc_property_ppp_get_mtu, NM_SETTING_PPP_MTU)
1616 DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_failure, NM_SETTING_PPP_LCP_ECHO_FAILURE)
1617 DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_interval, NM_SETTING_PPP_LCP_ECHO_INTERVAL)
1619 /* --- NM_SETTING_PPPOE_SETTING_NAME property get functions --- */
1620 DEFINE_GETTER (nmc_property_pppoe_get_service, NM_SETTING_PPPOE_SERVICE)
1621 DEFINE_GETTER (nmc_property_pppoe_get_username, NM_SETTING_PPPOE_USERNAME)
1622 DEFINE_GETTER (nmc_property_pppoe_get_password, NM_SETTING_PPPOE_PASSWORD)
1623 DEFINE_SECRET_FLAGS_GETTER (nmc_property_pppoe_get_password_flags, NM_SETTING_PPPOE_PASSWORD_FLAGS)
1625 /* --- NM_SETTING_SERIAL_SETTING_NAME property get functions --- */
1626 DEFINE_GETTER (nmc_property_serial_get_baud, NM_SETTING_SERIAL_BAUD)
1627 DEFINE_GETTER (nmc_property_serial_get_bits, NM_SETTING_SERIAL_BITS)
1628 DEFINE_GETTER (nmc_property_serial_get_stopbits, NM_SETTING_SERIAL_STOPBITS)
1629 DEFINE_GETTER (nmc_property_serial_get_send_delay, NM_SETTING_SERIAL_SEND_DELAY)
1631 /* --- NM_SETTING_VLAN_SETTING_NAME property get functions --- */
1632 DEFINE_GETTER (nmc_property_vlan_get_parent, NM_SETTING_VLAN_PARENT)
1633 DEFINE_GETTER (nmc_property_vlan_get_id, NM_SETTING_VLAN_ID)
1637 nmc_property_vlan_get_flags (NMSetting *setting, NmcPropertyGetType get_type)
1639 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1640 return vlan_flags_to_string (nm_setting_vlan_get_flags (s_vlan));
1644 nmc_property_vlan_get_ingress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1646 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1647 return vlan_priorities_to_string (s_vlan, NM_VLAN_INGRESS_MAP);
1651 nmc_property_vlan_get_egress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1653 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1654 return vlan_priorities_to_string (s_vlan, NM_VLAN_EGRESS_MAP);
1657 /* --- NM_SETTING_VPN_SETTING_NAME property get functions --- */
1658 DEFINE_GETTER (nmc_property_vpn_get_service_type, NM_SETTING_VPN_SERVICE_TYPE)
1659 DEFINE_GETTER (nmc_property_vpn_get_user_name, NM_SETTING_VPN_USER_NAME)
1662 nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type)
1664 NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1665 GString *data_item_str;
1667 data_item_str = g_string_new (NULL);
1668 nm_setting_vpn_foreach_data_item (s_vpn, &vpn_data_item, data_item_str);
1670 return g_string_free (data_item_str, FALSE);
1674 nmc_property_vpn_get_secrets (NMSetting *setting, NmcPropertyGetType get_type)
1676 NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1677 GString *secret_str;
1679 secret_str = g_string_new (NULL);
1680 nm_setting_vpn_foreach_secret (s_vpn, &vpn_data_item, secret_str);
1682 return g_string_free (secret_str, FALSE);
1685 DEFINE_GETTER (nmc_property_vpn_get_persistent, NM_SETTING_VPN_PERSISTENT)
1686 DEFINE_GETTER (nmc_property_vpn_get_timeout, NM_SETTING_VPN_TIMEOUT)
1688 /* --- NM_SETTING_WIMAX_SETTING_NAME property get functions --- */
1689 DEFINE_GETTER (nmc_property_wimax_get_network_name, NM_SETTING_WIMAX_NETWORK_NAME)
1690 DEFINE_GETTER (nmc_property_wimax_get_mac_address, NM_SETTING_WIMAX_MAC_ADDRESS)
1692 /* --- NM_SETTING_WIRED_SETTING_NAME property get functions --- */
1693 DEFINE_GETTER (nmc_property_wired_get_port, NM_SETTING_WIRED_PORT)
1694 DEFINE_GETTER (nmc_property_wired_get_speed, NM_SETTING_WIRED_SPEED)
1695 DEFINE_GETTER (nmc_property_wired_get_duplex, NM_SETTING_WIRED_DUPLEX)
1696 DEFINE_GETTER (nmc_property_wired_get_auto_negotiate, NM_SETTING_WIRED_AUTO_NEGOTIATE)
1697 DEFINE_GETTER (nmc_property_wired_get_mac_address, NM_SETTING_WIRED_MAC_ADDRESS)
1698 DEFINE_GETTER (nmc_property_wired_get_cloned_mac_address, NM_SETTING_WIRED_CLONED_MAC_ADDRESS)
1699 DEFINE_GETTER (nmc_property_wired_get_mac_address_blacklist, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST)
1700 DEFINE_GETTER (nmc_property_wired_get_s390_subchannels, NM_SETTING_WIRED_S390_SUBCHANNELS)
1701 DEFINE_GETTER (nmc_property_wired_get_s390_nettype, NM_SETTING_WIRED_S390_NETTYPE)
1702 DEFINE_GETTER (nmc_property_wired_get_s390_options, NM_SETTING_WIRED_S390_OPTIONS)
1703 DEFINE_GETTER (nmc_property_wired_get_wake_on_lan_password, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD)
1706 nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1708 NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1711 mtu = nm_setting_wired_get_mtu (s_wired);
1713 return g_strdup (_("auto"));
1715 return g_strdup_printf ("%d", mtu);
1719 nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type)
1721 NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1722 NMSettingWiredWakeOnLan wol;
1725 wol = nm_setting_wired_get_wake_on_lan (s_wired);
1726 tmp = nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (), wol);
1727 if (get_type == NMC_PROPERTY_GET_PARSABLE)
1728 str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "none");
1730 str = g_strdup_printf ("%d (%s)", wol, tmp && *tmp ? tmp : "none");
1736 nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
1737 const char *val, GError **error)
1739 NMSettingWiredWakeOnLan wol;
1740 gs_free char *err_token = NULL;
1744 if (nmc_string_to_int_base (val, 0, TRUE, 0,
1745 NM_SETTING_WIRED_WAKE_ON_LAN_ALL
1746 | NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS,
1748 wol = (NMSettingWiredWakeOnLan) t;
1750 ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val,
1751 (int *) &wol, &err_token);
1754 if ( g_ascii_strcasecmp (err_token, "none") == 0
1755 || g_ascii_strcasecmp (err_token, "disable") == 0
1756 || g_ascii_strcasecmp (err_token, "disabled") == 0)
1757 wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
1759 g_set_error (error, 1, 0, _("invalid option '%s', use a combination of [%s] or 'ignore', 'default' or 'none'"),
1761 nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (),
1762 NM_SETTING_WIRED_WAKE_ON_LAN_ALL));
1768 if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
1769 && !nm_utils_is_power_of_two (wol)) {
1770 g_set_error_literal (error, 1, 0, _("'default' and 'ignore' are incompatible with other flags"));
1774 g_object_set (setting, prop, (guint) wol, NULL);
1779 nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1781 NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
1782 NMIPTunnelMode mode;
1784 mode = nm_setting_ip_tunnel_get_mode (s_ip_tunnel);
1785 return nm_utils_enum_to_str (nm_ip_tunnel_mode_get_type (), mode);
1789 nmc_property_ip_tunnel_set_mode (NMSetting *setting, const char *prop,
1790 const char *val, GError **error)
1792 NMIPTunnelMode mode;
1795 ret = nm_utils_enum_from_str (nm_ip_tunnel_mode_get_type(), val,
1796 (int *) &mode, NULL);
1799 gs_free const char **values = NULL;
1800 gs_free char *values_str = NULL;
1802 values = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1803 NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1805 values_str = g_strjoinv (",", (char **) values);
1806 g_set_error (error, 1, 0, _("invalid mode '%s', use one of %s"),
1812 g_object_set (setting, prop, mode, NULL);
1816 /* --- NM_SETTING_WIRELESS_SETTING_NAME property get functions --- */
1817 DEFINE_GETTER (nmc_property_wireless_get_mode, NM_SETTING_WIRELESS_MODE)
1818 DEFINE_GETTER (nmc_property_wireless_get_band, NM_SETTING_WIRELESS_BAND)
1819 DEFINE_GETTER (nmc_property_wireless_get_channel, NM_SETTING_WIRELESS_CHANNEL)
1820 DEFINE_GETTER (nmc_property_wireless_get_bssid, NM_SETTING_WIRELESS_BSSID)
1821 DEFINE_GETTER (nmc_property_wireless_get_rate, NM_SETTING_WIRELESS_RATE)
1822 DEFINE_GETTER (nmc_property_wireless_get_tx_power, NM_SETTING_WIRELESS_TX_POWER)
1823 DEFINE_GETTER (nmc_property_wireless_get_mac_address, NM_SETTING_WIRELESS_MAC_ADDRESS)
1824 DEFINE_GETTER (nmc_property_wireless_get_cloned_mac_address, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS)
1825 DEFINE_GETTER (nmc_property_wireless_get_mac_address_blacklist, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST)
1826 DEFINE_GETTER (nmc_property_wireless_get_seen_bssids, NM_SETTING_WIRELESS_SEEN_BSSIDS)
1827 DEFINE_GETTER (nmc_property_wireless_get_hidden, NM_SETTING_WIRELESS_HIDDEN)
1830 nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1832 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1834 char *ssid_str = NULL;
1836 ssid = nm_setting_wireless_get_ssid (s_wireless);
1838 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1839 g_bytes_get_size (ssid));
1846 nmc_property_wireless_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1848 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1851 mtu = nm_setting_wireless_get_mtu (s_wireless);
1853 return g_strdup (_("auto"));
1855 return g_strdup_printf ("%d", mtu);
1859 nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_type)
1861 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1862 NMSettingWirelessPowersave powersave;
1863 gs_free char *str = NULL;
1866 powersave = nm_setting_wireless_get_powersave (s_wireless);
1867 str = nm_utils_enum_to_str (nm_setting_wireless_powersave_get_type (), powersave);
1869 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1874 return g_strdup_printf ("%s (%u)", str, powersave);
1878 nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcPropertyGetType get_type)
1880 NMSettingWireless *s_wifi = NM_SETTING_WIRELESS (setting);
1881 NMSettingMacRandomization randomization = nm_setting_wireless_get_mac_address_randomization (s_wifi);
1883 if (randomization == NM_SETTING_MAC_RANDOMIZATION_DEFAULT)
1884 return g_strdup (_("default"));
1885 else if (randomization == NM_SETTING_MAC_RANDOMIZATION_NEVER)
1886 return g_strdup (_("never"));
1887 else if (randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
1888 return g_strdup_printf (_("always"));
1890 return g_strdup_printf (_("unknown"));
1894 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property get functions --- */
1895 DEFINE_GETTER (nmc_property_wifi_sec_get_key_mgmt, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT)
1896 DEFINE_GETTER (nmc_property_wifi_sec_get_wep_tx_keyidx, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX)
1897 DEFINE_GETTER (nmc_property_wifi_sec_get_auth_alg, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG)
1898 DEFINE_GETTER (nmc_property_wifi_sec_get_proto, NM_SETTING_WIRELESS_SECURITY_PROTO)
1899 DEFINE_GETTER (nmc_property_wifi_sec_get_pairwise, NM_SETTING_WIRELESS_SECURITY_PAIRWISE)
1900 DEFINE_GETTER (nmc_property_wifi_sec_get_group, NM_SETTING_WIRELESS_SECURITY_GROUP)
1901 DEFINE_GETTER (nmc_property_wifi_sec_get_leap_username, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME)
1902 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_wep_key_flags, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS)
1903 DEFINE_GETTER (nmc_property_wifi_sec_get_psk, NM_SETTING_WIRELESS_SECURITY_PSK)
1904 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_psk_flags, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS)
1905 DEFINE_GETTER (nmc_property_wifi_sec_get_leap_password, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)
1906 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_leap_password_flags, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS)
1909 nmc_property_wifi_sec_get_wep_key0 (NMSetting *setting, NmcPropertyGetType get_type)
1911 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1912 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 0));
1916 nmc_property_wifi_sec_get_wep_key1 (NMSetting *setting, NmcPropertyGetType get_type)
1918 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1919 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1));
1923 nmc_property_wifi_sec_get_wep_key2 (NMSetting *setting, NmcPropertyGetType get_type)
1925 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1926 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2));
1930 nmc_property_wifi_sec_get_wep_key3 (NMSetting *setting, NmcPropertyGetType get_type)
1932 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1933 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3));
1937 nmc_property_wifi_sec_get_wep_key_type (NMSetting *setting, NmcPropertyGetType get_type)
1939 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1940 return wep_key_type_to_string (nm_setting_wireless_security_get_wep_key_type (s_wireless_sec));
1943 /* --- NM_SETTING_MACVLAN_SETTING_NAME property get functions --- */
1944 DEFINE_GETTER (nmc_property_macvlan_get_parent, NM_SETTING_MACVLAN_PARENT)
1945 DEFINE_GETTER (nmc_property_macvlan_get_promiscuous, NM_SETTING_MACVLAN_PROMISCUOUS)
1946 DEFINE_GETTER (nmc_property_macvlan_get_tap, NM_SETTING_MACVLAN_TAP)
1949 nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1951 NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
1952 NMSettingMacvlanMode mode;
1955 mode = nm_setting_macvlan_get_mode (s_macvlan);
1956 tmp = nm_utils_enum_to_str (nm_setting_macvlan_mode_get_type (), mode);
1958 if (get_type == NMC_PROPERTY_GET_PARSABLE)
1959 str = g_strdup (tmp ? tmp : "");
1961 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
1968 nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop,
1969 const char *val, GError **error)
1971 NMSettingMacvlanMode mode;
1972 gs_free const char **options = NULL;
1973 gs_free char *options_str = NULL;
1977 if (nmc_string_to_int_base (val, 0, TRUE, 0, _NM_SETTING_MACVLAN_MODE_NUM - 1, &t))
1978 mode = (NMSettingMacvlanMode) t;
1980 ret = nm_utils_enum_from_str (nm_setting_macvlan_mode_get_type (), val,
1981 (int *) &mode, NULL);
1984 options = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
1985 NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
1987 options_str = g_strjoinv (",", (char **) options);
1988 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
1994 g_object_set (setting, prop, (guint) mode, NULL);
1998 static const char **
1999 nmc_property_macvlan_allowed_mode (NMSetting *setting, const char *prop)
2001 static const char **words = NULL;
2004 words = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
2005 NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
2010 /* --- NM_SETTING_VXLAN_SETTING_NAME property get functions --- */
2011 DEFINE_GETTER (nmc_property_vxlan_get_parent, NM_SETTING_VXLAN_PARENT)
2012 DEFINE_GETTER (nmc_property_vxlan_get_id, NM_SETTING_VXLAN_ID)
2013 DEFINE_GETTER (nmc_property_vxlan_get_local, NM_SETTING_VXLAN_LOCAL)
2014 DEFINE_GETTER (nmc_property_vxlan_get_remote, NM_SETTING_VXLAN_REMOTE)
2015 DEFINE_GETTER (nmc_property_vxlan_get_source_port_min, NM_SETTING_VXLAN_SOURCE_PORT_MIN)
2016 DEFINE_GETTER (nmc_property_vxlan_get_source_port_max, NM_SETTING_VXLAN_SOURCE_PORT_MAX)
2017 DEFINE_GETTER (nmc_property_vxlan_get_destination_port, NM_SETTING_VXLAN_DESTINATION_PORT)
2018 DEFINE_GETTER (nmc_property_vxlan_get_tos, NM_SETTING_VXLAN_TOS)
2019 DEFINE_GETTER (nmc_property_vxlan_get_ttl, NM_SETTING_VXLAN_TTL)
2020 DEFINE_GETTER (nmc_property_vxlan_get_ageing, NM_SETTING_VXLAN_AGEING)
2021 DEFINE_GETTER (nmc_property_vxlan_get_limit, NM_SETTING_VXLAN_LIMIT)
2022 DEFINE_GETTER (nmc_property_vxlan_get_learning, NM_SETTING_VXLAN_LEARNING)
2023 DEFINE_GETTER (nmc_property_vxlan_get_proxy, NM_SETTING_VXLAN_PROXY)
2024 DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC)
2025 DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS)
2026 DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS)
2028 /*----------------------------------------------------------------------------*/
2031 nmc_value_transform_bool_string (const GValue *src_value,
2034 dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_int ? "yes" : "no");
2038 nmc_value_transform_char_string (const GValue *src_value,
2041 dest_value->data[0].v_pointer = g_strdup_printf ("%c", src_value->data[0].v_uint);
2044 static void __attribute__((constructor))
2045 register_nmcli_value_transforms (void)
2047 g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_STRING, nmc_value_transform_bool_string);
2048 g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_STRING, nmc_value_transform_char_string);
2051 /*----------------------------------------------------------------------------*/
2053 /* Main hash table storing function pointer for manipulating properties */
2054 static GHashTable *nmc_properties = NULL;
2055 typedef char * (*NmcPropertyGetFunc) (NMSetting *, NmcPropertyGetType);
2056 typedef gboolean (*NmcPropertySetFunc) (NMSetting *, const char *, const char *, GError **);
2057 typedef gboolean (*NmcPropertyRemoveFunc) (NMSetting *, const char *, const char *, guint32, GError **);
2058 typedef const char * (*NmcPropertyDescribeFunc) (NMSetting *, const char *);
2059 typedef const char ** (*NmcPropertyValuesFunc) (NMSetting *, const char *);
2062 /* The order of the fields is important as they correspond
2063 * to the order as _nmc_add_prop_funcs() passes the arguments. */
2064 #define NmcPropertyFuncsFields \
2065 NmcPropertyGetFunc get_func; /* func getting property values */ \
2066 NmcPropertySetFunc set_func; /* func adding/setting property values */ \
2067 NmcPropertyRemoveFunc remove_func; /* func removing items from container options */ \
2068 NmcPropertyDescribeFunc describe_func; /* func returning property description */ \
2069 NmcPropertyValuesFunc values_func; /* func returning allowed property values */ \
2071 NmcPropertyFuncsFields
2075 * We need NmCli in some _set_property functions, and they aren't passed NmCli.
2076 * So use the global variable.
2078 /* Global variable defined in nmcli.c */
2079 extern NmCli nm_cli;
2082 nmc_setting_new_for_name (const char *name)
2085 NMSetting *setting = NULL;
2088 stype = nm_setting_lookup_type (name);
2089 if (stype != G_TYPE_INVALID) {
2090 setting = g_object_new (stype, NULL);
2091 g_warn_if_fail (NM_IS_SETTING (setting));
2098 get_answer (const char *prop, const char *value)
2102 gboolean answer = FALSE;
2105 question = g_strdup_printf (_("Do you also want to set '%s' to '%s'? [yes]: "), prop, value);
2107 question = g_strdup_printf (_("Do you also want to clear '%s'? [yes]: "), prop);
2108 tmp_str = nmc_get_user_input (question);
2109 if (!tmp_str || matches (tmp_str, "yes") == 0)
2116 static void ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data);
2117 static void ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data);
2120 ipv4_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2122 static gboolean answered = FALSE;
2123 static gboolean answer = FALSE;
2125 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2127 /* If we have some IP addresses set method to 'manual'.
2128 * Else if the method was 'manual', change it back to 'auto'.
2130 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2131 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
2134 answer = get_answer ("ipv4.method", "manual");
2137 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL);
2141 if (!g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
2142 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
2145 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2149 ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2151 static GValue value = G_VALUE_INIT;
2152 static gboolean answered = FALSE;
2153 static gboolean answer = FALSE;
2155 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2157 /* If method != manual, remove addresses (save them for restoring them later when method becomes 'manual' */
2158 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
2159 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2162 answer = get_answer ("ipv4.addresses", NULL);
2165 if (G_IS_VALUE (&value))
2166 g_value_unset (&value);
2167 nmc_property_get_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2168 g_object_set (object, NM_SETTING_IP_CONFIG_ADDRESSES, NULL, NULL);
2173 if (G_IS_VALUE (&value)) {
2174 nmc_property_set_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2175 g_value_unset (&value);
2179 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2183 ipv6_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2185 static gboolean answered = FALSE;
2186 static gboolean answer = FALSE;
2188 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2190 /* If we have some IP addresses set method to 'manual'.
2191 * Else if the method was 'manual', change it back to 'auto'.
2193 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2194 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
2197 answer = get_answer ("ipv6.method", "manual");
2200 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL);
2204 if (!g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
2205 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
2208 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2212 ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2214 static GValue value = G_VALUE_INIT;
2215 static gboolean answered = FALSE;
2216 static gboolean answer = FALSE;
2218 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2220 /* If method != manual, remove addresses (save them for restoring them later when method becomes 'manual' */
2221 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
2222 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2225 answer = get_answer ("ipv6.addresses", NULL);
2228 if (G_IS_VALUE (&value))
2229 g_value_unset (&value);
2230 nmc_property_get_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2231 g_object_set (object, NM_SETTING_IP_CONFIG_ADDRESSES, NULL, NULL);
2236 if (G_IS_VALUE (&value)) {
2237 nmc_property_set_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2238 g_value_unset (&value);
2242 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2246 wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2248 const char *value = NULL, *mode;
2250 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (object);
2252 if (strcmp (g_param_spec_get_name (pspec), NM_SETTING_WIRELESS_BAND) == 0) {
2253 value = nm_setting_wireless_get_band (s_wireless);
2257 guint32 channel = nm_setting_wireless_get_channel (s_wireless);
2262 g_snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless));
2266 mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (object));
2267 if (!mode || !*mode || strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
2268 g_print (_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
2269 nm_setting_get_name (NM_SETTING (s_wireless)), g_param_spec_get_name (pspec),
2275 connection_master_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2277 NMSettingConnection *s_con = NM_SETTING_CONNECTION (object);
2278 NMConnection *connection = NM_CONNECTION (user_data);
2279 NMSetting *s_ipv4, *s_ipv6;
2280 const char *value, *tmp_str;
2282 value = nm_setting_connection_get_master (s_con);
2284 s_ipv4 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP4_CONFIG_SETTING_NAME);
2285 s_ipv6 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP6_CONFIG_SETTING_NAME);
2286 if (s_ipv4 || s_ipv6) {
2287 g_print (_("Warning: setting %s.%s requires removing ipv4 and ipv6 settings\n"),
2288 nm_setting_get_name (NM_SETTING (s_con)), g_param_spec_get_name (pspec));
2289 tmp_str = nmc_get_user_input (_("Do you want to remove them? [yes] "));
2290 if (!tmp_str || matches (tmp_str, "yes") == 0) {
2292 nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv4));
2294 nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv6));
2301 nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting)
2303 g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
2305 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_ADDRESSES,
2306 G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2307 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_METHOD,
2308 G_CALLBACK (ipv4_method_changed_cb), NULL);
2312 nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting)
2314 g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
2316 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_ADDRESSES,
2317 G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2318 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_METHOD,
2319 G_CALLBACK (ipv6_method_changed_cb), NULL);
2323 nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
2325 g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
2327 g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_BAND,
2328 G_CALLBACK (wireless_band_channel_changed_cb), NULL);
2329 g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_CHANNEL,
2330 G_CALLBACK (wireless_band_channel_changed_cb), NULL);
2334 nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection)
2336 g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
2338 g_signal_connect (setting, "notify::" NM_SETTING_CONNECTION_MASTER,
2339 G_CALLBACK (connection_master_changed_cb), connection);
2343 * Customize some properties of the setting so that the setting has sensible
2347 nmc_setting_custom_init (NMSetting *setting)
2349 g_return_if_fail (NM_IS_SETTING (setting));
2351 if (NM_IS_SETTING_IP4_CONFIG (setting)) {
2352 g_object_set (NM_SETTING_IP_CONFIG (setting),
2353 NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
2355 nmc_setting_ip4_connect_handlers (NM_SETTING_IP_CONFIG (setting));
2356 } else if (NM_IS_SETTING_IP6_CONFIG (setting)) {
2357 g_object_set (NM_SETTING_IP_CONFIG (setting),
2358 NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
2360 nmc_setting_ip6_connect_handlers (NM_SETTING_IP_CONFIG (setting));
2361 } else if (NM_IS_SETTING_WIRELESS (setting)) {
2362 g_object_set (NM_SETTING_WIRELESS (setting),
2363 NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
2365 nmc_setting_wireless_connect_handlers (NM_SETTING_WIRELESS (setting));
2369 /* === SetFunc, RemoveFunc, DescribeFunc, ValuesFunc functions === */
2371 verify_string_list (char **strv,
2373 gboolean (*validate_func) (const char *),
2378 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2380 for (iter = strv; iter && *iter; iter++) {
2383 if (validate_func) {
2384 if (!validate_func (*iter)) {
2385 g_set_error (error, 1, 0, _("'%s' is not valid"),
2394 /* Validate 'val' number against to int property spec */
2396 validate_int (NMSetting *setting, const char* prop, gint val, GError **error)
2399 GValue value = G_VALUE_INIT;
2400 gboolean success = TRUE;
2402 g_value_init (&value, G_TYPE_INT);
2403 g_value_set_int (&value, val);
2404 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2405 g_assert (G_IS_PARAM_SPEC (pspec));
2406 if (g_param_value_validate (pspec, &value)) {
2407 GParamSpecInt *pspec_int = (GParamSpecInt *) pspec;
2408 g_set_error (error, 1, 0, _("'%d' is not valid; use <%d-%d>"),
2409 val, pspec_int->minimum, pspec_int->maximum);
2412 g_value_unset (&value);
2417 validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error)
2420 GValue value = G_VALUE_INIT;
2421 gboolean success = TRUE;
2423 g_value_init (&value, G_TYPE_INT64);
2424 g_value_set_int64 (&value, val);
2425 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2426 g_assert (G_IS_PARAM_SPEC (pspec));
2427 if (g_param_value_validate (pspec, &value)) {
2428 GParamSpecInt64 *pspec_int = (GParamSpecInt64 *) pspec;
2429 G_STATIC_ASSERT (sizeof (long long) >= sizeof (gint64));
2430 g_set_error (error, 1, 0, _("'%lld' is not valid; use <%lld-%lld>"),
2431 (long long) val, (long long) pspec_int->minimum, (long long) pspec_int->maximum);
2434 g_value_unset (&value);
2438 /* Validate 'val' number against to uint property spec */
2440 validate_uint (NMSetting *setting, const char* prop, guint val, GError **error)
2443 GValue value = G_VALUE_INIT;
2444 gboolean success = TRUE;
2446 g_value_init (&value, G_TYPE_UINT);
2447 g_value_set_uint (&value, val);
2448 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2449 g_assert (G_IS_PARAM_SPEC (pspec));
2450 if (g_param_value_validate (pspec, &value)) {
2451 GParamSpecUInt *pspec_uint = (GParamSpecUInt *) pspec;
2452 g_set_error (error, 1, 0, _("'%u' is not valid; use <%u-%u>"),
2453 val, pspec_uint->minimum, pspec_uint->maximum);
2456 g_value_unset (&value);
2461 flag_values_to_string (GFlagsValue *array, guint n)
2466 str = g_string_new (NULL);
2467 for (i = 0; i < n; i++)
2468 g_string_append_printf (str, "%u, ", array[i].value);
2470 g_string_truncate (str, str->len-2); /* chop off trailing ', ' */
2471 return g_string_free (str, FALSE);
2475 validate_flags (NMSetting *setting, const char* prop, guint val, GError **error)
2478 GValue value = G_VALUE_INIT;
2479 gboolean success = TRUE;
2481 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2482 g_assert (G_IS_PARAM_SPEC (pspec));
2484 g_value_init (&value, pspec->value_type);
2485 g_value_set_flags (&value, val);
2487 if (g_param_value_validate (pspec, &value)) {
2488 GParamSpecFlags *pspec_flags = (GParamSpecFlags *) pspec;
2489 char *flag_values = flag_values_to_string (pspec_flags->flags_class->values,
2490 pspec_flags->flags_class->n_values);
2491 g_set_error (error, 1, 0, _("'%u' flags are not valid; use combination of %s"),
2493 g_free (flag_values);
2496 g_value_unset (&value);
2501 check_and_set_string (NMSetting *setting,
2504 const char **valid_strv,
2507 const char *checked_val;
2509 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2511 checked_val = nmc_string_is_valid (val, valid_strv, error);
2515 g_object_set (setting, prop, checked_val, NULL);
2519 #define DEFINE_SETTER_STR_LIST_MULTI(def_func, s_macro, set_func) \
2521 def_func (NMSetting *setting, \
2524 const char **valid_strv, \
2527 char **strv = NULL, **iter; \
2529 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2530 strv = nmc_strsplit_set (val, " \t,", 0); \
2531 for (iter = strv; iter && *iter; iter++) { \
2532 if (!(item = nmc_string_is_valid (g_strstrip (*iter), valid_strv, error))) { \
2533 g_strfreev (strv); \
2536 set_func (s_macro (setting), item); \
2538 g_strfreev (strv); \
2542 #define DEFINE_SETTER_OPTIONS(def_func, s_macro, s_type, add_func, valid_func1, valid_func2) \
2544 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2546 char **strv = NULL, **iter; \
2547 const char **(*valid_func1_p) (s_type *) = valid_func1; \
2548 const char * (*valid_func2_p) (const char *, const char *, GError **) = valid_func2; \
2549 const char *opt_name, *opt_val; \
2551 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2553 strv = nmc_strsplit_set (val, ",", 0); \
2554 for (iter = strv; iter && *iter; iter++) { \
2555 char *left = g_strstrip (*iter); \
2556 char *right = strchr (left, '='); \
2558 g_set_error (error, 1, 0, _("'%s' is not valid; use <option>=<value>"), *iter); \
2559 g_strfreev (strv); \
2564 if (valid_func1_p) { \
2565 const char **valid_options = valid_func1_p (s_macro (setting)); \
2566 if (!(opt_name = nmc_string_is_valid (g_strstrip (left), valid_options, error))) { \
2567 g_strfreev (strv); \
2571 opt_name = g_strstrip (left);\
2573 opt_val = g_strstrip (right); \
2574 if (valid_func2_p) { \
2575 if (!(opt_val = valid_func2_p ((const char *) left, (const char *) opt_val, error))) { \
2576 g_strfreev (strv); \
2580 add_func (s_macro (setting), opt_name, opt_val); \
2582 g_strfreev (strv); \
2586 #define DEFINE_REMOVER_INDEX(def_func, s_macro, num_func, rem_func) \
2588 def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2592 g_set_error (error, 1, 0, _("index '%s' is not valid"), option); \
2595 num = num_func (s_macro (setting)); \
2597 g_set_error_literal (error, 1, 0, _("no item to remove")); \
2601 g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2604 rem_func (s_macro (setting), idx); \
2608 #define DEFINE_REMOVER_INDEX_OR_VALUE(def_func, s_macro, num_func, rem_func_idx, rem_func_val) \
2610 def_func (NMSetting *setting, const char *prop, const char *value, guint32 idx, GError **error) \
2615 char *value_stripped = g_strstrip (g_strdup (value)); \
2616 ret = rem_func_val (s_macro (setting), value_stripped, error); \
2617 g_free (value_stripped); \
2620 num = num_func (s_macro (setting)); \
2622 g_set_error_literal (error, 1, 0, _("no item to remove")); \
2626 g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2629 rem_func_idx (s_macro (setting), idx); \
2633 #define DEFINE_REMOVER_OPTION(def_func, s_macro, rem_func) \
2635 def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2637 gboolean success = FALSE; \
2638 if (option && *option) { \
2639 success = rem_func (s_macro (setting), option); \
2641 g_set_error (error, 1, 0, _("invalid option '%s'"), option); \
2643 g_set_error_literal (error, 1, 0, _("missing option")); \
2647 #define DEFINE_ALLOWED_VAL_FUNC(def_func, valid_values) \
2648 static const char ** \
2649 def_func (NMSetting *setting, const char *prop) \
2651 return valid_values; \
2654 /* --- generic property setter functions --- */
2656 nmc_property_set_string (NMSetting *setting, const char *prop, const char *val, GError **error)
2658 g_object_set (setting, prop, val, NULL);
2663 nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GError **error)
2665 unsigned long val_int;
2667 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2669 if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
2670 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2674 /* Validate the number according to the property spec */
2675 if (!validate_uint (setting, prop, (guint) val_int, error))
2678 g_object_set (setting, prop, (guint) val_int, NULL);
2683 nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error)
2687 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2689 if (!nmc_string_to_int (val, TRUE, G_MININT, G_MAXINT, &val_int)) {
2690 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2694 /* Validate the number according to the property spec */
2695 if (!validate_int (setting, prop, (gint) val_int, error))
2698 g_object_set (setting, prop, (gint) val_int, NULL);
2703 nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, GError **error)
2707 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2709 if (!nmc_string_to_int (val, FALSE, 0, 0, &val_int)) {
2710 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2714 /* Validate the number according to the property spec */
2715 if (!validate_int64 (setting, prop, (gint64) val_int, error))
2718 g_object_set (setting, prop, (gint64) val_int, NULL);
2723 nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2725 unsigned long val_int;
2727 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2729 if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
2730 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2734 /* Validate the flags according to the property spec */
2735 if (!validate_flags (setting, prop, (guint) val_int, error))
2738 g_object_set (setting, prop, (guint) val_int, NULL);
2743 nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error)
2747 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2749 if (!nmc_string_to_bool (val, &val_bool, error))
2752 g_object_set (setting, prop, val_bool, NULL);
2757 nmc_property_set_trilean (NMSetting *setting, const char *prop, const char *val, GError **error)
2761 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2763 if (!nmc_string_to_int (val, TRUE, -1, 1, &val_int)) {
2764 g_set_error (error, 1, 0, _("'%s' is not a valid value; use -1, 0 or 1"), val);
2768 g_object_set (setting, prop, val_int, NULL);
2773 nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error)
2777 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2779 if (strlen (val) > 32) {
2780 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
2784 ssid = g_bytes_new (val, strlen (val));
2785 g_object_set (setting, prop, ssid, NULL);
2786 g_bytes_unref (ssid);
2791 nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
2793 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2795 if (!nm_utils_hwaddr_valid (val, ETH_ALEN)) {
2796 g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), val);
2800 g_object_set (setting, prop, val, NULL);
2805 nmc_property_set_mtu (NMSetting *setting, const char *prop, const char *val, GError **error)
2807 const char *mtu = val;
2809 if (strcmp (mtu, "auto") == 0)
2812 return nmc_property_set_uint (setting, prop, mtu, error);
2816 nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, GError **error)
2818 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2820 if (!nm_utils_iface_valid_name (val)) {
2821 g_set_error (error, 1, 0, _("'%s' is not a valid interface name"), val);
2824 g_object_set (setting, prop, val, NULL);
2828 #define ALL_SECRET_FLAGS \
2829 (NM_SETTING_SECRET_FLAG_NONE | \
2830 NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
2831 NM_SETTING_SECRET_FLAG_NOT_SAVED | \
2832 NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
2835 nmc_property_set_secret_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2837 char **strv = NULL, **iter;
2838 unsigned long flags = 0, val_int;
2840 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2842 strv = nmc_strsplit_set (val, " \t,", 0);
2843 for (iter = strv; iter && *iter; iter++) {
2844 if (!nmc_string_to_uint (*iter, TRUE, 0, ALL_SECRET_FLAGS, &val_int)) {
2845 g_set_error (error, 1, 0, _("'%s' is not a valid flag number; use <0-%d>"),
2846 *iter, ALL_SECRET_FLAGS);
2854 /* Validate the flags number */
2855 if (flags > ALL_SECRET_FLAGS) {
2856 flags = ALL_SECRET_FLAGS;
2857 g_print (_("Warning: '%s' sum is higher than all flags => all flags set\n"), val);
2860 g_object_set (setting, prop, (guint) flags, NULL);
2865 nmc_util_is_domain (const char *domain)
2872 nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *val, GError **error)
2874 char **strv = NULL, **iter;
2876 const char *delimiters = " \t,";
2879 GByteArray *array = NULL;
2880 gboolean success = TRUE;
2882 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2884 val_strip = g_strstrip (g_strdup (val));
2886 /* First try hex string in the format of AAbbCCDd */
2887 bytes = nm_utils_hexstr2bin (val_strip);
2889 array = g_bytes_unref_to_array (bytes);
2893 /* Otherwise, consider the following format: AA b 0xCc D */
2894 strv = nmc_strsplit_set (val_strip, delimiters, 0);
2895 array = g_byte_array_sized_new (g_strv_length (strv));
2896 for (iter = strv; iter && *iter; iter++) {
2897 if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) {
2898 g_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
2902 g_byte_array_append (array, (const guint8 *) &val_int, 1);
2907 g_object_set (setting, prop, array, NULL);
2911 g_byte_array_free (array, TRUE);
2915 #define DEFINE_SETTER_MAC_BLACKLIST(def_func, s_macro, add_func) \
2917 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2920 char **list = NULL, **iter; \
2921 GSList *macaddr_blacklist = NULL; \
2923 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2925 list = nmc_strsplit_set (val, " \t,", 0); \
2926 for (iter = list; iter && *iter; iter++) { \
2927 if (!nm_utils_hwaddr_aton (*iter, buf, ETH_ALEN)) { \
2928 g_set_error (error, 1, 0, _("'%s' is not a valid MAC"), *iter); \
2929 g_strfreev (list); \
2930 g_slist_free (macaddr_blacklist); \
2935 for (iter = list; iter && *iter; iter++) \
2936 add_func (s_macro (setting), *iter); \
2938 g_strfreev (list); \
2942 /* --- NM_SETTING_CONNECTION_SETTING_NAME property setter functions --- */
2945 * Setting/removing UUID has been forbidden.
2946 * Should it be enabled later, this function can be used.
2949 nmc_property_con_set_uuid (NMSetting *setting, const char *prop, const char *val, GError **error)
2951 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2953 if (!nm_utils_is_uuid (val)) {
2954 g_set_error (error, 1, 0, _("'%s' is not a valid UUID"), val);
2957 g_object_set (setting, prop, val, NULL);
2963 /* define from libnm-core/nm-setting-connection.c */
2964 #define PERM_USER_PREFIX "user:"
2967 permissions_valid (const char *perm)
2969 if (!perm || perm[0] == '\0')
2972 if (strncmp (perm, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0) {
2973 if ( strlen (perm) <= strlen (PERM_USER_PREFIX)
2974 || strchr (perm + strlen (PERM_USER_PREFIX), ':'))
2977 if (strchr (perm, ':'))
2985 nmc_property_connection_set_permissions (NMSetting *setting, const char *prop, const char *val, GError **error)
2990 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2992 strv = nmc_strsplit_set (val, " \t,", 0);
2993 if (!verify_string_list (strv, prop, permissions_valid, error)) {
2998 for (i = 0; strv && strv[i]; i++) {
3001 if (strncmp (strv[i], PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0)
3002 user = strv[i]+strlen (PERM_USER_PREFIX);
3006 nm_setting_connection_add_permission (NM_SETTING_CONNECTION (setting), "user", user, NULL);
3013 _validate_and_remove_connection_permission (NMSettingConnection *setting,
3019 ret = nm_setting_connection_remove_permission_by_value (setting, "user", perm, NULL);
3021 g_set_error (error, 1, 0, _("the property doesn't contain permission '%s'"), perm);
3024 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_permissions,
3025 NM_SETTING_CONNECTION,
3026 nm_setting_connection_get_num_permissions,
3027 nm_setting_connection_remove_permission,
3028 _validate_and_remove_connection_permission)
3031 nmc_property_connection_describe_permissions (NMSetting *setting, const char *prop)
3033 return _("Enter a list of user permissions. This is a list of user names formatted as:\n"
3034 " [user:]<user name 1>, [user:]<user name 2>,...\n"
3035 "The items can be separated by commas or spaces.\n\n"
3036 "Example: alice bob charlie\n");
3041 nmc_property_con_set_master (NMSetting *setting, const char *prop, const char *val, GError **error)
3043 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3049 else if ( !nm_utils_iface_valid_name (val)
3050 && !nm_utils_is_uuid (val)) {
3051 g_set_error (error, 1, 0,
3052 _("'%s' is not valid master; use ifname or connection UUID"),
3056 g_object_set (setting, prop, val, NULL);
3061 static const char *con_valid_slave_types[] = {
3062 NM_SETTING_BOND_SETTING_NAME,
3063 NM_SETTING_BRIDGE_SETTING_NAME,
3064 NM_SETTING_TEAM_SETTING_NAME,
3069 nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3071 return check_and_set_string (setting, prop, val, con_valid_slave_types, error);
3075 DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_types)
3079 nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error)
3082 char **strv = NULL, **iter;
3085 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3087 strv = nmc_strsplit_set (val, " \t,", 0);
3088 for (iter = strv; iter && *iter; iter++) {
3092 if (nm_utils_is_uuid (*iter)) {
3093 con = nmc_find_connection (nm_cli.connections,
3094 "uuid", *iter, NULL);
3096 g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
3098 /* Currenly NM only supports VPN connections as secondaries */
3099 if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
3100 g_set_error (error, 1, 0, _("'%s' is not a VPN connection profile"), *iter);
3106 con = nmc_find_connection (nm_cli.connections,
3109 g_set_error (error, 1, 0, _("'%s' is not a name of any exiting profile"), *iter);
3114 /* Currenly NM only supports VPN connections as secondaries */
3115 if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
3116 g_set_error (error, 1, 0, _("'%s' is not a VPN connection profile"), *iter);
3121 /* translate id to uuid */
3123 *iter = g_strdup (nm_connection_get_uuid (con));
3127 while (strv && strv[i])
3128 nm_setting_connection_add_secondary (NM_SETTING_CONNECTION (setting), strv[i++]);
3135 _validate_and_remove_connection_secondary (NMSettingConnection *setting,
3136 const char *secondary_uuid,
3141 if (!nm_utils_is_uuid (secondary_uuid)) {
3142 g_set_error (error, 1, 0,
3143 _("the value '%s' is not a valid UUID"), secondary_uuid);
3147 ret = nm_setting_connection_remove_secondary_by_value (setting, secondary_uuid);
3149 g_set_error (error, 1, 0,
3150 _("the property doesn't contain UUID '%s'"), secondary_uuid);
3153 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_secondaries,
3154 NM_SETTING_CONNECTION,
3155 nm_setting_connection_get_num_secondaries,
3156 nm_setting_connection_remove_secondary,
3157 _validate_and_remove_connection_secondary)
3160 nmc_property_connection_describe_secondaries (NMSetting *setting, const char *prop)
3162 return _("Enter secondary connections that should be activated when this connection is\n"
3163 "activated. Connections can be specified either by UUID or ID (name). nmcli\n"
3164 "transparently translates names to UUIDs. Note that NetworkManager only supports\n"
3165 "VPNs as secondary connections at the moment.\n"
3166 "The items can be separated by commas or spaces.\n\n"
3167 "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n");
3172 nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type)
3174 NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3176 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
3177 switch (nm_setting_connection_get_metered (s_conn)) {
3178 case NM_METERED_YES:
3179 return g_strdup ("yes");
3181 return g_strdup ("no");
3182 case NM_METERED_UNKNOWN:
3184 return g_strdup ("unknown");
3187 switch (nm_setting_connection_get_metered (s_conn)) {
3188 case NM_METERED_YES:
3189 return g_strdup (_("yes"));
3191 return g_strdup (_("no"));
3192 case NM_METERED_UNKNOWN:
3194 return g_strdup (_("unknown"));
3199 nmc_property_connection_set_metered (NMSetting *setting, const char *prop,
3200 const char *val, GError **error)
3203 NMCTriStateValue ts_val;
3205 if (!nmc_string_to_tristate (val, &ts_val, error))
3209 case NMC_TRI_STATE_YES:
3210 metered = NM_METERED_YES;
3212 case NMC_TRI_STATE_NO:
3213 metered = NM_METERED_NO;
3215 case NMC_TRI_STATE_UNKNOWN:
3216 metered = NM_METERED_UNKNOWN;
3219 g_assert_not_reached();
3222 g_object_set (setting, prop, metered, NULL);
3227 nmc_property_connection_describe_metered (NMSetting *setting, const char *prop)
3229 return _("Enter a value which indicates whether the connection is subject to a data\n"
3230 "quota, usage costs or other limitations. Accepted options are:\n"
3231 "'true','yes','on' to set the connection as metered\n"
3232 "'false','no','off' to set the connection as not metered\n"
3233 "'unknown' to let NetworkManager choose a value using some heuristics\n");
3238 nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type)
3240 NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3241 NMSettingConnectionLldp lldp;
3244 lldp = nm_setting_connection_get_lldp (s_conn);
3245 tmp = nm_utils_enum_to_str (nm_setting_connection_lldp_get_type (), lldp);
3246 if (get_type == NMC_PROPERTY_GET_PARSABLE)
3247 str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "default");
3249 str = g_strdup_printf ("%d (%s)", lldp, tmp && *tmp ? tmp : "default");
3255 nmc_property_connection_set_lldp (NMSetting *setting, const char *prop,
3256 const char *val, GError **error)
3258 NMSettingConnectionLldp lldp;
3262 if (nmc_string_to_int_base (val, 0, TRUE,
3263 NM_SETTING_CONNECTION_LLDP_DEFAULT,
3264 NM_SETTING_CONNECTION_LLDP_ENABLE_RX,
3268 ret = nm_utils_enum_from_str (nm_setting_connection_lldp_get_type (), val,
3269 (int *) &lldp, NULL);
3272 if (g_ascii_strcasecmp (val, "enable") == 0)
3273 lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX;
3275 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
3276 val, "default,disable,enable-rx,enable");
3282 g_object_set (setting, prop, lldp, NULL);
3286 /* --- NM_SETTING_802_1X_SETTING_NAME property setter functions --- */
3287 #define DEFINE_SETTER_STR_LIST(def_func, set_func) \
3289 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3291 char **strv = NULL; \
3294 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
3296 strv = nmc_strsplit_set (val, " \t,", 0); \
3297 while (strv && strv[i]) \
3298 set_func (NM_SETTING_802_1X (setting), strv[i++]); \
3299 g_strfreev (strv); \
3303 #define DEFINE_SETTER_CERT(def_func, set_func) \
3305 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3307 char *val_strip = g_strstrip (g_strdup (val)); \
3308 char *p = val_strip; \
3311 if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
3312 p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
3314 success = set_func (NM_SETTING_802_1X (setting), \
3316 NM_SETTING_802_1X_CK_SCHEME_PATH, \
3319 g_free (val_strip); \
3323 #define DEFINE_SETTER_PRIV_KEY(def_func, pwd_func, set_func) \
3325 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3327 char **strv = NULL; \
3328 char *val_strip = g_strstrip (g_strdup (val)); \
3329 char *p = val_strip; \
3330 const char *path, *password; \
3333 if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
3334 p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
3336 strv = nmc_strsplit_set (p, " \t,", 2); \
3338 if (g_strv_length (strv) == 2) \
3339 password = strv[1]; \
3341 password = pwd_func (NM_SETTING_802_1X (setting)); \
3343 char *tmp_pwd = g_strdup (password); \
3344 success = set_func (NM_SETTING_802_1X (setting), \
3347 NM_SETTING_802_1X_CK_SCHEME_PATH, \
3353 g_set_error_literal (error, 1, 0, _("private key password not provided")); \
3355 g_free (val_strip); \
3356 g_strfreev (strv); \
3361 static const char *valid_eap[] = { "leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", NULL };
3363 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_802_1X_eap,
3365 nm_setting_802_1x_add_eap_method)
3367 nmc_property_802_1X_set_eap (NMSetting *setting, const char *prop, const char *val, GError **error)
3369 return check_and_add_802_1X_eap (setting, prop, val, valid_eap, error);
3373 _validate_and_remove_eap_method (NMSetting8021x *setting,
3379 ret = nm_setting_802_1x_remove_eap_method_by_value(setting, eap);
3381 g_set_error (error, 1, 0, _("the property doesn't contain EAP method '%s'"), eap);
3384 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_eap,
3386 nm_setting_802_1x_get_num_eap_methods,
3387 nm_setting_802_1x_remove_eap_method,
3388 _validate_and_remove_eap_method)
3390 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_eap, valid_eap)
3393 DEFINE_SETTER_CERT (nmc_property_802_1X_set_ca_cert, nm_setting_802_1x_set_ca_cert)
3396 nmc_property_802_1X_describe_ca_cert (NMSetting *setting, const char *prop)
3398 return _("Enter file path to CA certificate (optionally prefixed with file://).\n"
3399 " [file://]<file path>\n"
3400 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3401 "Example: /home/cimrman/cacert.crt\n");
3404 /* 'altsubject-matches' */
3405 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_altsubject_matches, nm_setting_802_1x_add_altsubject_match)
3408 _validate_and_remove_altsubject_match (NMSetting8021x *setting,
3409 const char *altsubject_match,
3414 ret = nm_setting_802_1x_remove_altsubject_match_by_value (setting, altsubject_match);
3416 g_set_error (error, 1, 0,
3417 _("the property doesn't contain alternative subject match '%s'"),
3421 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_altsubject_matches,
3423 nm_setting_802_1x_get_num_altsubject_matches,
3424 nm_setting_802_1x_remove_altsubject_match,
3425 _validate_and_remove_altsubject_match)
3428 DEFINE_SETTER_CERT (nmc_property_802_1X_set_client_cert, nm_setting_802_1x_set_client_cert)
3431 nmc_property_802_1X_describe_client_cert (NMSetting *setting, const char *prop)
3433 return _("Enter file path to client certificate (optionally prefixed with file://).\n"
3434 " [file://]<file path>\n"
3435 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3436 "Example: /home/cimrman/jara.crt\n");
3439 /* 'phase2-ca-cert' */
3440 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert)
3443 nmc_property_802_1X_describe_phase2_ca_cert (NMSetting *setting, const char *prop)
3445 return _("Enter file path to CA certificate for inner authentication (optionally prefixed\n"
3447 " [file://]<file path>\n"
3448 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3449 "Example: /home/cimrman/ca-zweite-phase.crt\n");
3452 /* 'phase2-altsubject-matches' */
3453 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_phase2_altsubject_matches, nm_setting_802_1x_add_phase2_altsubject_match)
3456 _validate_and_remove_phase2_altsubject_match (NMSetting8021x *setting,
3457 const char *phase2_altsubject_match,
3462 ret = nm_setting_802_1x_remove_phase2_altsubject_match_by_value (setting, phase2_altsubject_match);
3464 g_set_error (error, 1, 0,
3465 _("the property doesn't contain \"phase2\" alternative subject match '%s'"),
3466 phase2_altsubject_match);
3469 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_phase2_altsubject_matches,
3471 nm_setting_802_1x_get_num_phase2_altsubject_matches,
3472 nm_setting_802_1x_remove_phase2_altsubject_match,
3473 _validate_and_remove_phase2_altsubject_match)
3475 /* 'phase2-client-cert' */
3476 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert)
3479 nmc_property_802_1X_describe_phase2_client_cert (NMSetting *setting, const char *prop)
3481 return _("Enter file path to client certificate for inner authentication (optionally prefixed\n"
3483 " [file://]<file path>\n"
3484 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3485 "Example: /home/cimrman/jara-zweite-phase.crt\n");
3489 DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_private_key,
3490 nm_setting_802_1x_get_private_key_password,
3491 nm_setting_802_1x_set_private_key)
3493 /* 'phase2-private-key' */
3494 DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_phase2_private_key,
3495 nm_setting_802_1x_get_phase2_private_key_password,
3496 nm_setting_802_1x_set_phase2_private_key)
3499 nmc_property_802_1X_describe_private_key (NMSetting *setting, const char *prop)
3501 return _("Enter path to a private key and the key password (if not set yet):\n"
3502 " [file://]<file path> [<password>]\n"
3503 "Note that nmcli does not support specifying private key as raw blob data.\n"
3504 "Example: /home/cimrman/jara-priv-key Dardanely\n");
3507 /* 'phase1-peapver' */
3508 static const char *_802_1X_valid_phase1_peapvers[] = { "0", "1", NULL };
3511 nmc_property_802_1X_set_phase1_peapver (NMSetting *setting, const char *prop, const char *val, GError **error)
3513 return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peapvers, error);
3516 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peapver, _802_1X_valid_phase1_peapvers)
3518 /* 'phase1-peaplabel' */
3519 static const char *_802_1X_valid_phase1_peaplabels[] = { "0", "1", NULL };
3522 nmc_property_802_1X_set_phase1_peaplabel (NMSetting *setting, const char *prop, const char *val, GError **error)
3524 return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peaplabels, error);
3527 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peaplabel, _802_1X_valid_phase1_peaplabels)
3529 /* 'phase1-fast-provisioning' */
3530 static const char *_802_1X_valid_phase1_fast_provisionings[] = { "0", "1", "2", "3", NULL };
3533 nmc_property_802_1X_set_phase1_fast_provisioning (NMSetting *setting, const char *prop, const char *val, GError **error)
3535 return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_fast_provisionings, error);
3538 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_fast_provisioning, _802_1X_valid_phase1_fast_provisionings)
3541 static const char *_802_1X_valid_phase2_auths[] =
3542 { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL };
3545 nmc_property_802_1X_set_phase2_auth (NMSetting *setting, const char *prop, const char *val, GError **error)
3547 return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_auths, error);
3550 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_auth, _802_1X_valid_phase2_auths)
3552 /* 'phase2-autheap' */
3553 static const char *_802_1X_valid_phase2_autheaps[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL };
3555 nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, const char *val, GError **error)
3557 return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_autheaps, error);
3560 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_valid_phase2_autheaps)
3562 /* 'password-raw' */
3564 nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error)
3566 return nmc_property_set_byte_array (setting, prop, val, error);
3570 nmc_property_802_1X_describe_password_raw (NMSetting *setting, const char *prop)
3572 return _("Enter bytes as a list of hexadecimal values.\n"
3573 "Two formats are accepted:\n"
3574 "(a) a string of hexadecimal digits, where each two digits represent one byte\n"
3575 "(b) space-separated list of bytes written as hexadecimal digits "
3576 "(with optional 0x/0X prefix, and optional leading 0).\n\n"
3577 "Examples: ab0455a6ea3a74C2\n"
3578 " ab 4 55 0xa6 ea 3a 74 C2\n");
3581 /* --- NM_SETTING_ADSL_SETTING_NAME property setter functions --- */
3583 static const char *adsl_valid_protocols[] = {
3584 NM_SETTING_ADSL_PROTOCOL_PPPOA,
3585 NM_SETTING_ADSL_PROTOCOL_PPPOE,
3586 NM_SETTING_ADSL_PROTOCOL_IPOATM,
3591 nmc_property_adsl_set_protocol (NMSetting *setting, const char *prop, const char *val, GError **error)
3593 return check_and_set_string (setting, prop, val, adsl_valid_protocols, error);
3596 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_protocol, adsl_valid_protocols)
3598 /* 'encapsulation' */
3599 static const char *adsl_valid_encapsulations[] = {
3600 NM_SETTING_ADSL_ENCAPSULATION_VCMUX,
3601 NM_SETTING_ADSL_ENCAPSULATION_LLC,
3606 nmc_property_adsl_set_encapsulation (NMSetting *setting, const char *prop, const char *val, GError **error)
3608 return check_and_set_string (setting, prop, val, adsl_valid_encapsulations, error);
3611 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_encapsulation, adsl_valid_encapsulations)
3613 /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property setter functions --- */
3616 nmc_property_bluetooth_set_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3618 const char *types[] = {
3619 NM_SETTING_BLUETOOTH_TYPE_DUN,
3620 NM_SETTING_BLUETOOTH_TYPE_PANU,
3623 return check_and_set_string (setting, prop, val, types, error);
3626 /* --- NM_SETTING_BOND_SETTING_NAME property setter functions --- */
3628 /* example: miimon=100,mode=balance-rr, updelay=5 */
3630 _validate_and_remove_bond_option (NMSettingBond *setting, const char *option)
3633 const char **valid_options;
3635 valid_options = nm_setting_bond_get_valid_options (setting);
3636 opt = nmc_string_is_valid (option, valid_options, NULL);
3639 return nm_setting_bond_remove_option (setting, opt);
3644 /* Validate bonding 'options' values */
3646 _validate_bond_option_value (const char *option, const char *value, GError **error)
3648 if (!g_strcmp0 (option, NM_SETTING_BOND_OPTION_MODE))
3649 return nmc_bond_validate_mode (value, error);
3654 DEFINE_SETTER_OPTIONS (nmc_property_bond_set_options,
3657 nm_setting_bond_add_option,
3658 nm_setting_bond_get_valid_options,
3659 _validate_bond_option_value)
3660 DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options,
3662 _validate_and_remove_bond_option)
3665 nmc_property_bond_describe_options (NMSetting *setting, const char *prop)
3667 static char *desc = NULL;
3668 const char **valid_options;
3671 if (G_UNLIKELY (desc == NULL)) {
3672 valid_options = nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3673 options_str = g_strjoinv (", ", (char **) valid_options);
3675 desc = g_strdup_printf (_("Enter a list of bonding options formatted as:\n"
3676 " option = <value>, option = <value>,... \n"
3677 "Valid options are: %s\n"
3678 "'mode' can be provided as a name or a number:\n"
3680 "active-backup = 1\n"
3685 "balance-alb = 6\n\n"
3686 "Example: mode=2,miimon=120\n"), options_str);
3687 g_free (options_str);
3692 static const char **
3693 nmc_property_bond_allowed_options (NMSetting *setting, const char *prop)
3695 return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3698 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property setter functions --- */
3701 nmc_property_ib_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
3703 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3705 if (!nm_utils_hwaddr_valid (val, INFINIBAND_ALEN)) {
3706 g_set_error (error, 1, 0, _("'%s' is not a valid InfiniBand MAC"), val);
3710 g_object_set (setting, prop, val, NULL);
3714 /* 'transport-mode' */
3715 static const char *ib_valid_transport_modes[] = { "datagram", "connected", NULL };
3718 nmc_property_ib_set_transport_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
3720 return check_and_set_string (setting, prop, val, ib_valid_transport_modes, error);
3723 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ib_allowed_transport_mode, ib_valid_transport_modes)
3727 nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val, GError **error)
3729 gboolean p_key_valid = FALSE;
3732 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3734 if (!strncasecmp (val, "0x", 2))
3735 p_key_valid = nmc_string_to_int_base (val + 2, 16, TRUE, 0, G_MAXUINT16, &p_key_int);
3737 p_key_valid = nmc_string_to_int (val, TRUE, -1, G_MAXUINT16, &p_key_int);
3740 if (strcmp (val, "default") == 0)
3743 g_set_error (error, 1, 0, _("'%s' is not a valid IBoIP P_Key"), val);
3747 g_object_set (setting, prop, (gint) p_key_int, NULL);
3751 /* --- IP4 / IP6 shared functions --- */
3752 static NMIPAddress *
3753 _parse_ip_address (int family, const char *address, GError **error)
3755 char *value = g_strdup (address);
3756 NMIPAddress *ipaddr;
3758 ipaddr = nmc_parse_and_build_address (family, g_strstrip (value), error);
3764 _parse_ip_route (int family, const char *route, GError **error)
3766 char *value = g_strdup (route);
3769 NMIPRoute *iproute = NULL;
3771 routev = nmc_strsplit_set (g_strstrip (value), " \t", 0);
3772 len = g_strv_length (routev);
3773 if (len < 1 || len > 3) {
3774 g_set_error (error, 1, 0, _("'%s' is not valid (the format is: ip[/prefix] [next-hop] [metric])"),
3778 iproute = nmc_parse_and_build_route (family, routev[0], routev[1], len >= 2 ? routev[2] : NULL, error);
3782 g_strfreev (routev);
3786 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property setter functions --- */
3788 static const char *ipv4_valid_methods[] = {
3789 NM_SETTING_IP4_CONFIG_METHOD_AUTO,
3790 NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
3791 NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
3792 NM_SETTING_IP4_CONFIG_METHOD_SHARED,
3793 NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
3798 nmc_property_ipv4_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
3800 /* Silently accept "static" and convert to "manual" */
3801 if (val && strlen (val) > 1 && matches (val, "static") == 0)
3802 val = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
3804 return check_and_set_string (setting, prop, val, ipv4_valid_methods, error);
3807 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods)
3811 nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
3813 char **strv = NULL, **iter, *addr;
3816 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3818 strv = nmc_strsplit_set (val, " \t,", 0);
3819 for (iter = strv; iter && *iter; iter++) {
3820 addr = g_strstrip (*iter);
3821 if (inet_pton (AF_INET, addr, &ip4_addr) < 1) {
3822 g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), addr);
3826 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
3833 _validate_and_remove_ipv4_dns (NMSettingIPConfig *setting,
3840 if (inet_pton (AF_INET, dns, &ip4_addr) < 1) {
3841 g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), dns);
3845 ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
3847 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
3850 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns,
3851 NM_SETTING_IP_CONFIG,
3852 nm_setting_ip_config_get_num_dns,
3853 nm_setting_ip_config_remove_dns,
3854 _validate_and_remove_ipv4_dns)
3857 nmc_property_ipv4_describe_dns (NMSetting *setting, const char *prop)
3859 return _("Enter a list of IPv4 addresses of DNS servers.\n\n"
3860 "Example: 8.8.8.8, 8.8.4.4\n");
3865 nmc_property_ipv4_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
3870 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3872 strv = nmc_strsplit_set (val, " \t,", 0);
3873 if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
3878 while (strv && strv[i])
3879 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3886 _validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting,
3887 const char *dns_search,
3892 ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
3894 g_set_error (error, 1, 0,
3895 _("the property doesn't contain DNS search domain '%s'"),
3899 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_search,
3900 NM_SETTING_IP_CONFIG,
3901 nm_setting_ip_config_get_num_dns_searches,
3902 nm_setting_ip_config_remove_dns_search,
3903 _validate_and_remove_ipv4_dns_search)
3907 nmc_property_ipv4_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
3912 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3914 nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
3915 strv = nmc_strsplit_set (val, " \t,", 0);
3916 while (strv && strv[i])
3917 nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3924 _validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting,
3925 const char *dns_option,
3930 ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
3932 g_set_error (error, 1, 0,
3933 _("the property doesn't contain DNS option '%s'"),
3937 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_option,
3938 NM_SETTING_IP_CONFIG,
3939 nm_setting_ip_config_get_num_dns_options,
3940 nm_setting_ip_config_remove_dns_option,
3941 _validate_and_remove_ipv4_dns_option)
3944 static NMIPAddress *
3945 _parse_ipv4_address (const char *address, GError **error)
3947 return _parse_ip_address (AF_INET, address, error);
3951 nmc_property_ipv4_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
3953 char **strv = NULL, **iter;
3954 NMIPAddress *ip4addr;
3956 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3958 strv = nmc_strsplit_set (val, ",", 0);
3959 for (iter = strv; iter && *iter; iter++) {
3960 ip4addr = _parse_ipv4_address (*iter, error);
3965 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip4addr);
3966 nm_ip_address_unref (ip4addr);
3973 _validate_and_remove_ipv4_address (NMSettingIPConfig *setting,
3974 const char *address,
3977 NMIPAddress *ip4addr;
3980 ip4addr = _parse_ipv4_address (address, error);
3984 ret = nm_setting_ip_config_remove_address_by_value (setting, ip4addr);
3986 g_set_error (error, 1, 0,
3987 _("the property doesn't contain IP address '%s'"), address);
3988 nm_ip_address_unref (ip4addr);
3991 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_addresses,
3992 NM_SETTING_IP_CONFIG,
3993 nm_setting_ip_config_get_num_addresses,
3994 nm_setting_ip_config_remove_address,
3995 _validate_and_remove_ipv4_address)
3998 nmc_property_ipv4_describe_addresses (NMSetting *setting, const char *prop)
4000 return _("Enter a list of IPv4 addresses formatted as:\n"
4001 " ip[/prefix], ip[/prefix],...\n"
4002 "Missing prefix is regarded as prefix of 32.\n\n"
4003 "Example: 192.168.1.5/24, 10.0.0.11/24\n");
4008 nmc_property_ipv4_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4010 NMIPAddress *ip4addr;
4012 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4014 if (strchr (val, '/')) {
4015 g_set_error (error, 1, 0,
4016 _("invalid gateway address '%s'"), val);
4019 ip4addr = _parse_ipv4_address (val, error);
4023 g_object_set (setting, prop, val, NULL);
4024 nm_ip_address_unref (ip4addr);
4030 _parse_ipv4_route (const char *route, GError **error)
4032 return _parse_ip_route (AF_INET, route, error);
4036 nmc_property_ipv4_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4038 char **strv = NULL, **iter;
4039 NMIPRoute *ip4route;
4041 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4043 strv = nmc_strsplit_set (val, ",", 0);
4044 for (iter = strv; iter && *iter; iter++) {
4045 ip4route = _parse_ipv4_route (*iter, error);
4050 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip4route);
4051 nm_ip_route_unref (ip4route);
4058 _validate_and_remove_ipv4_route (NMSettingIPConfig *setting,
4062 NMIPRoute *ip4route;
4065 ip4route = _parse_ipv4_route (route, error);
4069 ret = nm_setting_ip_config_remove_route_by_value (setting, ip4route);
4071 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4072 nm_ip_route_unref (ip4route);
4075 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_routes,
4076 NM_SETTING_IP_CONFIG,
4077 nm_setting_ip_config_get_num_routes,
4078 nm_setting_ip_config_remove_route,
4079 _validate_and_remove_ipv4_route)
4082 nmc_property_ipv4_describe_routes (NMSetting *setting, const char *prop)
4084 return _("Enter a list of IPv4 routes formatted as:\n"
4085 " ip[/prefix] [next-hop] [metric],...\n\n"
4086 "Missing prefix is regarded as a prefix of 32.\n"
4087 "Missing next-hop is regarded as 0.0.0.0.\n"
4088 "Missing metric means default (NM/kernel will set a default value).\n\n"
4089 "Examples: 192.168.2.0/24 192.168.2.1 3, 10.1.0.0/16 10.0.0.254\n"
4093 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property setter functions --- */
4095 static const char *ipv6_valid_methods[] = {
4096 NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
4097 NM_SETTING_IP6_CONFIG_METHOD_AUTO,
4098 NM_SETTING_IP6_CONFIG_METHOD_DHCP,
4099 NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
4100 NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
4101 NM_SETTING_IP6_CONFIG_METHOD_SHARED,
4106 nmc_property_ipv6_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
4108 /* Silently accept "static" and convert to "manual" */
4109 if (val && strlen (val) > 1 && matches (val, "static") == 0)
4110 val = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
4112 return check_and_set_string (setting, prop, val, ipv6_valid_methods, error);
4115 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods)
4119 nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
4121 char **strv = NULL, **iter, *addr;
4122 struct in6_addr ip6_addr;
4124 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4126 strv = nmc_strsplit_set (val, " \t,", 0);
4127 for (iter = strv; iter && *iter; iter++) {
4128 addr = g_strstrip (*iter);
4129 if (inet_pton (AF_INET6, addr, &ip6_addr) < 1) {
4130 g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), addr);
4134 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
4141 _validate_and_remove_ipv6_dns (NMSettingIPConfig *setting,
4145 struct in6_addr ip6_addr;
4148 if (inet_pton (AF_INET6, dns, &ip6_addr) < 1) {
4149 g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), dns);
4153 ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
4155 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
4158 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns,
4159 NM_SETTING_IP_CONFIG,
4160 nm_setting_ip_config_get_num_dns,
4161 nm_setting_ip_config_remove_dns,
4162 _validate_and_remove_ipv6_dns)
4165 nmc_property_ipv6_describe_dns (NMSetting *setting, const char *prop)
4167 return _("Enter a list of IPv6 addresses of DNS servers. If the IPv6 "
4168 "configuration method is 'auto' these DNS servers are appended "
4169 "to those (if any) returned by automatic configuration. DNS "
4170 "servers cannot be used with the 'shared' or 'link-local' IPv6 "
4171 "configuration methods, as there is no upstream network. In "
4172 "all other IPv6 configuration methods, these DNS "
4173 "servers are used as the only DNS servers for this connection.\n\n"
4174 "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n");
4179 nmc_property_ipv6_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
4184 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4186 strv = nmc_strsplit_set (val, " \t,", 0);
4187 if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
4192 while (strv && strv[i])
4193 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4200 _validate_and_remove_ipv6_dns_search (NMSettingIPConfig *setting,
4201 const char *dns_search,
4206 ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
4208 g_set_error (error, 1, 0,
4209 _("the property doesn't contain DNS search domain '%s'"),
4213 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_search,
4214 NM_SETTING_IP_CONFIG,
4215 nm_setting_ip_config_get_num_dns_searches,
4216 nm_setting_ip_config_remove_dns_search,
4217 _validate_and_remove_ipv6_dns_search)
4221 nmc_property_ipv6_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
4226 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4228 nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
4229 strv = nmc_strsplit_set (val, " \t,", 0);
4230 while (strv && strv[i])
4231 nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4238 _validate_and_remove_ipv6_dns_option (NMSettingIPConfig *setting,
4239 const char *dns_option,
4244 ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
4246 g_set_error (error, 1, 0,
4247 _("the property doesn't contain DNS option '%s'"),
4251 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_option,
4252 NM_SETTING_IP_CONFIG,
4253 nm_setting_ip_config_get_num_dns_options,
4254 nm_setting_ip_config_remove_dns_option,
4255 _validate_and_remove_ipv6_dns_option)
4258 static NMIPAddress *
4259 _parse_ipv6_address (const char *address, GError **error)
4261 return _parse_ip_address (AF_INET6, address, error);
4265 nmc_property_ipv6_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
4267 char **strv = NULL, **iter;
4268 NMIPAddress *ip6addr;
4270 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4272 strv = nmc_strsplit_set (val, ",", 0);
4273 for (iter = strv; iter && *iter; iter++) {
4274 ip6addr = _parse_ipv6_address (*iter, error);
4279 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip6addr);
4280 nm_ip_address_unref (ip6addr);
4287 _validate_and_remove_ipv6_address (NMSettingIPConfig *setting,
4288 const char *address,
4291 NMIPAddress *ip6addr;
4294 ip6addr = _parse_ipv6_address (address, error);
4298 ret = nm_setting_ip_config_remove_address_by_value (setting, ip6addr);
4300 g_set_error (error, 1, 0, _("the property doesn't contain IP address '%s'"), address);
4301 nm_ip_address_unref (ip6addr);
4304 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_addresses,
4305 NM_SETTING_IP_CONFIG,
4306 nm_setting_ip_config_get_num_addresses,
4307 nm_setting_ip_config_remove_address,
4308 _validate_and_remove_ipv6_address)
4311 nmc_property_ipv6_describe_addresses (NMSetting *setting, const char *prop)
4313 return _("Enter a list of IPv6 addresses formatted as:\n"
4314 " ip[/prefix], ip[/prefix],...\n"
4315 "Missing prefix is regarded as prefix of 128.\n\n"
4316 "Example: 2607:f0d0:1002:51::4/64, 1050:0:0:0:5:600:300c:326b\n");
4321 nmc_property_ipv6_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4323 NMIPAddress *ip6addr;
4325 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4327 if (strchr (val, '/')) {
4328 g_set_error (error, 1, 0,
4329 _("invalid gateway address '%s'"), val);
4332 ip6addr = _parse_ipv6_address (val, error);
4336 g_object_set (setting, prop, val, NULL);
4337 nm_ip_address_unref (ip6addr);
4343 _parse_ipv6_route (const char *route, GError **error)
4345 return _parse_ip_route (AF_INET6, route, error);
4349 nmc_property_ipv6_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4351 char **strv = NULL, **iter;
4352 NMIPRoute *ip6route;
4354 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4356 strv = nmc_strsplit_set (val, ",", 0);
4357 for (iter = strv; iter && *iter; iter++) {
4358 ip6route = _parse_ipv6_route (*iter, error);
4363 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip6route);
4364 nm_ip_route_unref (ip6route);
4371 _validate_and_remove_ipv6_route (NMSettingIPConfig *setting,
4375 NMIPRoute *ip6route;
4378 ip6route = _parse_ipv6_route (route, error);
4382 ret = nm_setting_ip_config_remove_route_by_value (setting, ip6route);
4384 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4385 nm_ip_route_unref (ip6route);
4388 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_routes,
4389 NM_SETTING_IP_CONFIG,
4390 nm_setting_ip_config_get_num_routes,
4391 nm_setting_ip_config_remove_route,
4392 _validate_and_remove_ipv6_route)
4395 nmc_property_ipv6_describe_routes (NMSetting *setting, const char *prop)
4397 return _("Enter a list of IPv6 routes formatted as:\n"
4398 " ip[/prefix] [next-hop] [metric],...\n\n"
4399 "Missing prefix is regarded as a prefix of 128.\n"
4400 "Missing next-hop is regarded as \"::\".\n"
4401 "Missing metric means default (NM/kernel will set a default value).\n\n"
4402 "Examples: 2001:db8:beef:2::/64 2001:db8:beef::2, 2001:db8:beef:3::/64 2001:db8:beef::3 2\n"
4407 nmc_property_ipv6_set_ip6_privacy (NMSetting *setting, const char *prop, const char *val, GError **error)
4409 unsigned long val_int;
4411 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4413 if (!nmc_string_to_uint (val, FALSE, 0, 0, &val_int)) {
4414 g_set_error (error, 1, 0, _("'%s' is not a number"), val);
4418 if ( val_int != NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED
4419 && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR
4420 && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) {
4421 g_set_error (error, 1, 0, _("'%s' is not valid; use 0, 1, or 2"), val);
4425 g_object_set (setting, prop, val_int, NULL);
4429 /* 'addr_gen_mode' */
4431 nmc_property_ipv6_get_addr_gen_mode (NMSetting *setting, NmcPropertyGetType get_type)
4433 NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
4434 NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4436 addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode (s_ip6);
4437 return nm_utils_enum_to_str (nm_setting_ip6_config_addr_gen_mode_get_type (), addr_gen_mode);
4442 nmc_property_ipv6_set_addr_gen_mode (NMSetting *setting, const char *prop,
4443 const char *val, GError **error)
4445 NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4447 if (!nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), val,
4448 (int *) &addr_gen_mode, NULL)) {
4449 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
4450 val, "eui64,stable-privacy");
4454 g_object_set (setting, prop, addr_gen_mode, NULL);
4459 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property setter functions --- */
4461 nmc_property_olpc_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4463 unsigned long chan_int;
4465 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4467 if (!nmc_string_to_uint (val, TRUE, 1, 13, &chan_int)) {
4468 g_set_error (error, 1, 0, _("'%s' is not a valid channel; use <1-13>"), val);
4471 g_object_set (setting, prop, chan_int, NULL);
4476 /* --- NM_SETTING_SERIAL_SETTING_NAME property setter functions --- */
4478 nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type)
4480 NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
4482 switch (nm_setting_serial_get_parity (s_serial)) {
4483 case NM_SETTING_SERIAL_PARITY_EVEN:
4484 return g_strdup ("even");
4485 case NM_SETTING_SERIAL_PARITY_ODD:
4486 return g_strdup ("odd");
4488 case NM_SETTING_SERIAL_PARITY_NONE:
4489 return g_strdup ("none");
4494 nmc_property_serial_set_parity (NMSetting *setting, const char *prop, const char *val, GError **error)
4496 NMSettingSerialParity parity;
4498 if (val[0] == 'E' || val[0] == 'e')
4499 parity = NM_SETTING_SERIAL_PARITY_EVEN;
4500 else if (val[0] == 'O' || val[0] == 'o')
4501 parity = NM_SETTING_SERIAL_PARITY_ODD;
4502 else if (val[0] == 'N' || val[0] == 'n')
4503 parity = NM_SETTING_SERIAL_PARITY_NONE;
4505 g_set_error (error, 1, 0, _("'%s' is not valid; use [e, o, n]"), val);
4509 g_object_set (setting, prop, parity, NULL);
4513 /* --- NM_SETTING_TEAM_SETTING_NAME property functions --- */
4514 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property functions --- */
4516 nmc_property_team_set_config (NMSetting *setting, const char *prop, const char *val, GError **error)
4520 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4522 if (!nmc_team_check_config (val, &json, error)) {
4525 g_object_set (setting, prop, json, NULL);
4531 nmc_property_team_describe_config (NMSetting *setting, const char *prop)
4533 return _("nmcli can accepts both direct JSON configuration data and a file name containing "
4534 "the configuration. In the latter case the file is read and the contents is put "
4535 "into this property.\n\n"
4536 "Examples: set team.config "
4537 "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n"
4538 " set team.config /etc/my-team.conf\n");
4541 /* --- NM_SETTING_VLAN_SETTING_NAME property setter functions --- */
4543 nmc_property_vlan_set_prio_map (NMSetting *setting,
4546 NMVlanPriorityMap map_type,
4549 char **prio_map, **p;
4551 prio_map = nmc_vlan_parse_priority_maps (val, map_type, error);
4555 for (p = prio_map; p && *p; p++)
4556 nm_setting_vlan_add_priority_str (NM_SETTING_VLAN (setting), map_type, *p);
4558 g_strfreev (prio_map);
4563 nmc_property_vlan_remove_prio_map (NMSetting *setting,
4566 NMVlanPriorityMap map_type,
4571 num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type);
4573 g_set_error_literal (error, 1, 0, _("no priority to remove"));
4577 g_set_error (error, 1, 0, _("index '%d' is not in the range of <0-%d>"),
4582 nm_setting_vlan_remove_priority (NM_SETTING_VLAN (setting), map_type, idx);
4587 nmc_property_vlan_set_ingress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4589 return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_INGRESS_MAP, error);
4593 nmc_property_vlan_set_egress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4595 return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_EGRESS_MAP, error);
4599 nmc_property_vlan_remove_priority_map (NMSetting *setting,
4603 NMVlanPriorityMap map,
4606 /* If value != NULL, remove by value */
4610 char *val = g_strdup (value);
4612 prio_map = nmc_vlan_parse_priority_maps (val, map, error);
4616 g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
4618 ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
4623 g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]);
4625 g_strfreev (prio_map);
4629 /* Else remove by index */
4630 return nmc_property_vlan_remove_prio_map (setting, prop, idx, map, error);
4634 nmc_property_vlan_remove_ingress_priority_map (NMSetting *setting,
4640 return nmc_property_vlan_remove_priority_map (setting,
4644 NM_VLAN_INGRESS_MAP,
4649 nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
4655 return nmc_property_vlan_remove_priority_map (setting,
4663 /* --- NM_SETTING_VPN_SETTING_NAME property setter functions --- */
4664 /* Validate value of vpn 'data' and 'secret' options */
4666 _validate_vpn_hash_value (const char *option, const char *value, GError **error)
4668 /* nm_setting_vpn_add_data_item() and nm_setting_vpn_add_secret() does not
4669 * allow empty strings */
4670 if (!value || !*value) {
4671 g_set_error (error, 1, 0, _("'%s' cannot be empty"), option);
4678 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
4681 nm_setting_vpn_add_data_item,
4683 _validate_vpn_hash_value)
4684 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
4686 nm_setting_vpn_remove_data_item)
4689 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
4692 nm_setting_vpn_add_secret,
4694 _validate_vpn_hash_value)
4695 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret,
4697 nm_setting_vpn_remove_secret)
4699 /* --- NM_SETTING_WIMAX_SETTING_NAME property setter functions --- */
4700 /* No specific functions */
4702 /* --- NM_SETTING_WIRED_SETTING_NAME property setter functions --- */
4705 * Do not allow setting 'port' and 'duplex' for now. They are not implemented in
4706 * NM core, nor in ifcfg-rh plugin. Enable this when it gets done.
4709 static const char *wired_valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
4712 nmc_property_wired_set_port (NMSetting *setting, const char *prop, const char *val, GError **error)
4714 return check_and_set_string (setting, prop, val, wired_valid_ports, error);
4717 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_port, wired_valid_ports)
4720 static const char *wired_valid_duplexes[] = { "half", "full", NULL };
4723 nmc_property_wired_set_duplex (NMSetting *setting, const char *prop, const char *val, GError **error)
4725 return check_and_set_string (setting, prop, val, wired_valid_duplexes, error);
4728 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_duplex, wired_valid_duplexes)
4731 /* 'mac-address-blacklist' */
4732 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wired_set_mac_address_blacklist,
4734 nm_setting_wired_add_mac_blacklist_item)
4737 _validate_and_remove_wired_mac_blacklist_item (NMSettingWired *setting,
4744 if (!nm_utils_hwaddr_aton (mac, buf, ETH_ALEN)) {
4745 g_set_error (error, 1, 0, _("'%s' is not a valid MAC address"), mac);
4749 ret = nm_setting_wired_remove_mac_blacklist_item_by_value (setting, mac);
4751 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4754 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wired_remove_mac_address_blacklist,
4756 nm_setting_wired_get_num_mac_blacklist_items,
4757 nm_setting_wired_remove_mac_blacklist_item,
4758 _validate_and_remove_wired_mac_blacklist_item)
4760 /* 's390-subchannels' */
4762 nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, const char *val, GError **error)
4767 strv = nmc_strsplit_set (val, " ,\t", 0);
4768 len = g_strv_length (strv);
4769 if (len != 2 && len != 3) {
4770 g_set_error (error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"),
4776 g_object_set (setting, prop, strv, NULL);
4782 nmc_property_wired_describe_s390_subchannels (NMSetting *setting, const char *prop)
4784 return _("Enter a list of subchannels (comma or space separated).\n\n"
4785 "Example: 0.0.0e20 0.0.0e21 0.0.0e22\n");
4788 /* 's390-nettype' */
4789 static const char *wired_valid_s390_nettypes[] = { "qeth", "lcs", "ctc", NULL };
4792 nmc_property_wired_set_s390_nettype (NMSetting *setting, const char *prop, const char *val, GError **error)
4794 return check_and_set_string (setting, prop, val, wired_valid_s390_nettypes, error);
4797 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_s390_nettype, wired_valid_s390_nettypes)
4799 /* 's390-options' */
4800 /* Validate value of 's390-options' */
4802 _validate_s390_option_value (const char *option, const char *value, GError **error)
4804 /* nm_setting_wired_add_s390_option() requires value len in <1,199> interval */
4805 if (!value || !*value || strlen (value) >= 200) {
4806 g_set_error (error, 1, 0, _("'%s' string value should consist of 1 - 199 characters"), option);
4811 DEFINE_SETTER_OPTIONS (nmc_property_wired_set_s390_options,
4814 nm_setting_wired_add_s390_option,
4815 nm_setting_wired_get_valid_s390_options,
4816 _validate_s390_option_value)
4817 DEFINE_REMOVER_OPTION (nmc_property_wired_remove_option_s390_options,
4819 nm_setting_wired_remove_s390_option)
4821 static const char **
4822 nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop)
4824 return nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4828 nmc_property_wired_describe_s390_options (NMSetting *setting, const char *prop)
4830 static char *desc = NULL;
4831 const char **valid_options;
4834 if (G_UNLIKELY (desc == NULL)) {
4835 valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4836 options_str = g_strjoinv (", ", (char **) valid_options);
4838 desc = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n"
4839 " option = <value>, option = <value>,...\n"
4840 "Valid options are: %s\n"),
4842 g_free (options_str);
4847 /* --- NM_SETTING_WIRELESS_SETTING_NAME property setter functions --- */
4849 static const char *wifi_valid_modes[] = {
4850 NM_SETTING_WIRELESS_MODE_INFRA,
4851 NM_SETTING_WIRELESS_MODE_ADHOC,
4852 NM_SETTING_WIRELESS_MODE_AP,
4857 nmc_property_wifi_set_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
4859 return check_and_set_string (setting, prop, val, wifi_valid_modes, error);
4862 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_mode, wifi_valid_modes)
4865 static const char *wifi_valid_bands[] = { "a", "bg", NULL };
4868 nmc_property_wifi_set_band (NMSetting *setting, const char *prop, const char *val, GError **error)
4870 return check_and_set_string (setting, prop, val, wifi_valid_bands, error);
4873 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_band, wifi_valid_bands)
4877 nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4879 unsigned long chan_int;
4881 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4883 if (!nmc_string_to_uint (val, FALSE, 0, 0, &chan_int)) {
4884 g_set_error (error, 1, 0, _("'%s' is not a valid channel"), val);
4888 if ( !nm_utils_wifi_is_channel_valid (chan_int, "a")
4889 && !nm_utils_wifi_is_channel_valid (chan_int, "bg")) {
4890 g_set_error (error, 1, 0, _("'%ld' is not a valid channel"), chan_int);
4894 g_object_set (setting, prop, chan_int, NULL);
4898 /* 'mac-address-blacklist' */
4899 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wireless_set_mac_address_blacklist,
4900 NM_SETTING_WIRELESS,
4901 nm_setting_wireless_add_mac_blacklist_item)
4904 _validate_and_remove_wifi_mac_blacklist_item (NMSettingWireless *setting,
4911 if (!nm_utils_hwaddr_aton (mac, buf, ETH_ALEN)) {
4912 g_set_error (error, 1, 0, _("'%s' is not a valid MAC address"), mac);
4916 ret = nm_setting_wireless_remove_mac_blacklist_item_by_value (setting, mac);
4918 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4921 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wireless_remove_mac_address_blacklist,
4922 NM_SETTING_WIRELESS,
4923 nm_setting_wireless_get_num_mac_blacklist_items,
4924 nm_setting_wireless_remove_mac_blacklist_item,
4925 _validate_and_remove_wifi_mac_blacklist_item)
4929 nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const char *val, GError **error)
4931 NMSettingWirelessPowersave powersave;
4932 gs_free const char **options = NULL;
4933 gs_free char *options_str = NULL;
4937 if (nmc_string_to_int_base (val, 0, TRUE,
4938 NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4939 NM_SETTING_WIRELESS_POWERSAVE_LAST,
4941 powersave = (NMSettingWirelessPowersave) t;
4943 ret = nm_utils_enum_from_str (nm_setting_wireless_powersave_get_type (),
4948 options = nm_utils_enum_get_values (nm_setting_wireless_powersave_get_type (),
4949 NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4950 NM_SETTING_WIRELESS_POWERSAVE_LAST);
4951 options_str = g_strjoinv (",", (char **) options);
4952 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), val, options_str);
4957 g_object_set (setting, prop, (guint) powersave, NULL);
4962 nmc_property_wireless_set_mac_address_randomization (NMSetting *setting,
4967 NMSettingMacRandomization randomization;
4968 gs_free char *err_token = NULL;
4972 if (nmc_string_to_int_base (val, 0, TRUE,
4973 NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
4974 NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
4976 randomization = (NMSettingMacRandomization) t;
4978 ret = nm_utils_enum_from_str (nm_setting_mac_randomization_get_type (),
4980 (int *) &randomization,
4984 g_set_error (error, 1, 0, _("invalid option '%s', use 'default', 'never' or 'always'"),
4990 g_object_set (setting, prop, (guint) randomization, NULL);
4994 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property setter functions --- */
4996 static const char *wifi_sec_valid_key_mgmts[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
4999 nmc_property_wifi_sec_set_key_mgmt (NMSetting *setting, const char *prop, const char *val, GError **error)
5001 return check_and_set_string (setting, prop, val, wifi_sec_valid_key_mgmts, error);
5004 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_key_mgmt, wifi_sec_valid_key_mgmts)
5007 static const char *wifi_sec_valid_auth_algs[] = { "open", "shared", "leap", NULL };
5010 nmc_property_wifi_sec_set_auth_alg (NMSetting *setting, const char *prop, const char *val, GError **error)
5012 return check_and_set_string (setting, prop, val, wifi_sec_valid_auth_algs, error);
5015 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_auth_alg, wifi_sec_valid_auth_algs)
5018 static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL };
5020 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_proto,
5021 NM_SETTING_WIRELESS_SECURITY,
5022 nm_setting_wireless_security_add_proto)
5025 nmc_property_wifi_sec_set_proto (NMSetting *setting, const char *prop, const char *val, GError **error)
5027 return check_and_add_wifi_sec_proto (setting, prop, val, wifi_sec_valid_protos, error);
5031 _validate_and_remove_wifi_sec_proto (NMSettingWirelessSecurity *setting,
5038 valid = nmc_string_is_valid (proto, wifi_sec_valid_protos, error);
5042 ret = nm_setting_wireless_security_remove_proto_by_value (setting, proto);
5044 g_set_error (error, 1, 0,
5045 _("the property doesn't contain protocol '%s'"), proto);
5048 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_proto,
5049 NM_SETTING_WIRELESS_SECURITY,
5050 nm_setting_wireless_security_get_num_protos,
5051 nm_setting_wireless_security_remove_proto,
5052 _validate_and_remove_wifi_sec_proto)
5054 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_proto, wifi_sec_valid_protos)
5057 static const char *wifi_sec_valid_pairwises[] = { "tkip", "ccmp", NULL };
5059 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_pairwise,
5060 NM_SETTING_WIRELESS_SECURITY,
5061 nm_setting_wireless_security_add_pairwise)
5064 nmc_property_wifi_sec_set_pairwise (NMSetting *setting, const char *prop, const char *val, GError **error)
5066 return check_and_add_wifi_sec_pairwise (setting, prop, val, wifi_sec_valid_pairwises, error);
5070 _validate_and_remove_wifi_sec_pairwise (NMSettingWirelessSecurity *setting,
5071 const char *pairwise,
5077 valid = nmc_string_is_valid (pairwise, wifi_sec_valid_pairwises, error);
5081 ret = nm_setting_wireless_security_remove_pairwise_by_value (setting, pairwise);
5083 g_set_error (error, 1, 0,
5084 _("the property doesn't contain protocol '%s'"), pairwise);
5087 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_pairwise,
5088 NM_SETTING_WIRELESS_SECURITY,
5089 nm_setting_wireless_security_get_num_pairwise,
5090 nm_setting_wireless_security_remove_pairwise,
5091 _validate_and_remove_wifi_sec_pairwise)
5093 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_pairwise, wifi_sec_valid_pairwises)
5096 static const char *wifi_sec_valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
5098 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_group,
5099 NM_SETTING_WIRELESS_SECURITY,
5100 nm_setting_wireless_security_add_group)
5103 nmc_property_wifi_sec_set_group (NMSetting *setting, const char *prop, const char *val, GError **error)
5105 return check_and_add_wifi_sec_group (setting, prop, val, wifi_sec_valid_groups, error);
5109 _validate_and_remove_wifi_sec_group (NMSettingWirelessSecurity *setting,
5116 valid = nmc_string_is_valid (group, wifi_sec_valid_groups, error);
5120 ret = nm_setting_wireless_security_remove_group_by_value (setting, group);
5122 g_set_error (error, 1, 0,
5123 _("the property doesn't contain protocol '%s'"), group);
5126 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_group,
5127 NM_SETTING_WIRELESS_SECURITY,
5128 nm_setting_wireless_security_get_num_groups,
5129 nm_setting_wireless_security_remove_group,
5130 _validate_and_remove_wifi_sec_group)
5131 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_group, wifi_sec_valid_groups)
5135 nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char *val, GError **error)
5137 NMWepKeyType guessed_type = NM_WEP_KEY_TYPE_UNKNOWN;
5139 guint32 prev_idx, idx;
5141 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5143 /* Get currently set type */
5144 type = nm_setting_wireless_security_get_wep_key_type (NM_SETTING_WIRELESS_SECURITY (setting));
5146 /* Guess key type */
5147 if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_KEY))
5148 guessed_type = NM_WEP_KEY_TYPE_KEY;
5149 else if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_PASSPHRASE))
5150 guessed_type = NM_WEP_KEY_TYPE_PASSPHRASE;
5152 if (guessed_type == NM_WEP_KEY_TYPE_UNKNOWN) {
5153 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
5157 if (type != NM_WEP_KEY_TYPE_UNKNOWN && type != guessed_type) {
5158 if (nm_utils_wep_key_valid (val, type))
5159 guessed_type = type;
5161 g_set_error (error, 1, 0,
5162 _("'%s' not compatible with %s '%s', please change the key or set the right %s first."),
5163 val, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_key_type_to_string (type),
5164 NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
5168 prev_idx = nm_setting_wireless_security_get_wep_tx_keyidx (NM_SETTING_WIRELESS_SECURITY (setting));
5169 idx = prop[strlen (prop) - 1] - '0';
5170 g_print (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
5171 if (idx != prev_idx)
5172 g_print (_("WEP key index set to '%d'\n"), idx);
5174 g_object_set (setting, prop, val, NULL);
5175 g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, guessed_type, NULL);
5176 if (idx != prev_idx)
5177 g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, idx, NULL);
5181 /* 'wep-key-type' */
5183 nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const char *val, GError **error)
5185 unsigned long type_int;
5186 const char *valid_wep_types[] = { "unknown", "key", "passphrase", NULL };
5187 const char *type_str = NULL;
5188 const char *key0, *key1,* key2, *key3;
5189 NMWepKeyType type = NM_WEP_KEY_TYPE_UNKNOWN;
5191 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5193 if (!nmc_string_to_uint (val, TRUE, 0, 2, &type_int)) {
5194 if (!(type_str = nmc_string_is_valid (val, valid_wep_types, NULL))) {
5195 g_set_error (error, 1, 0, _("'%s' not among [0 (unknown), 1 (key), 2 (passphrase)]"), val);
5198 if (type_str == valid_wep_types[1])
5199 type = NM_WEP_KEY_TYPE_KEY;
5200 else if (type_str == valid_wep_types[2])
5201 type = NM_WEP_KEY_TYPE_PASSPHRASE;
5203 type = (NMWepKeyType) type_int;
5205 /* Check type compatibility with set keys */
5206 key0 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 0);
5207 key1 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 1);
5208 key2 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 2);
5209 key3 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 3);
5210 if (key0 && !nm_utils_wep_key_valid (key0, type))
5211 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5212 NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
5213 if (key1 && !nm_utils_wep_key_valid (key1, type))
5214 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5215 NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
5216 if (key2 && !nm_utils_wep_key_valid (key2, type))
5217 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5218 NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
5219 if (key3 && !nm_utils_wep_key_valid (key3, type))
5220 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5221 NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
5223 g_object_set (setting, prop, type, NULL);
5228 nmc_property_wifi_describe_wep_key_type (NMSetting *setting, const char *prop)
5230 static char *desc = NULL;
5232 if (G_UNLIKELY (desc == NULL)) {
5233 desc = g_strdup_printf (_("Enter the type of WEP keys. The accepted values are: "
5234 "0 or unknown, 1 or key, and 2 or passphrase.\n"));
5241 nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val, GError **error)
5243 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5245 if (!nm_utils_wpa_psk_valid (val)) {
5246 g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), val);
5249 g_object_set (setting, prop, val, NULL);
5253 #define DCB_ALL_FLAGS (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING)
5257 nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
5259 char **strv = NULL, **iter;
5260 NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5263 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5265 /* Check for overall hex numeric value */
5266 if (nmc_string_to_int_base (val, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5269 /* Check for individual flag numbers */
5270 strv = nmc_strsplit_set (val, " \t,", 0);
5271 for (iter = strv; iter && *iter; iter++) {
5272 if (!nmc_string_to_int_base (*iter, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5275 if ( g_ascii_strcasecmp (*iter, "enable") == 0
5276 || g_ascii_strcasecmp (*iter, "enabled") == 0
5277 || t == NM_SETTING_DCB_FLAG_ENABLE)
5278 flags |= NM_SETTING_DCB_FLAG_ENABLE;
5279 else if ( g_ascii_strcasecmp (*iter, "advertise") == 0
5280 || t == NM_SETTING_DCB_FLAG_ADVERTISE)
5281 flags |= NM_SETTING_DCB_FLAG_ADVERTISE;
5282 else if ( g_ascii_strcasecmp (*iter, "willing") == 0
5283 || t == NM_SETTING_DCB_FLAG_WILLING)
5284 flags |= NM_SETTING_DCB_FLAG_WILLING;
5285 else if ( g_ascii_strcasecmp (*iter, "disable") == 0
5286 || g_ascii_strcasecmp (*iter, "disabled") == 0
5290 g_set_error (error, 1, 0, _("'%s' is not a valid DCB flag"), *iter);
5297 /* Validate the flags according to the property spec */
5298 if (!validate_flags (setting, prop, (guint) flags, error))
5301 g_object_set (setting, prop, (guint) flags, NULL);
5306 nmc_property_dcb_set_priority (NMSetting *setting, const char *prop, const char *val, GError **error)
5308 long int priority = 0;
5310 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5312 if (!nmc_string_to_int (val, FALSE, -1, 7, &priority)) {
5313 g_set_error (error, 1, 0, _("'%s' is not a DCB app priority"), val);
5317 /* Validate the number according to the property spec */
5318 if (!validate_int (setting, prop, (gint) priority, error))
5321 g_object_set (setting, prop, (gint) priority, NULL);
5326 dcb_parse_uint_array (const char *val,
5332 char **items, **iter;
5335 g_return_val_if_fail (out_array != NULL, FALSE);
5337 items = g_strsplit_set (val, ",", -1);
5338 if (g_strv_length (items) != 8) {
5339 g_set_error_literal (error, 1, 0, _("must contain 8 comma-separated numbers"));
5343 for (iter = items; iter && *iter; iter++) {
5347 *iter = g_strstrip (*iter);
5348 success = nmc_string_to_int_base (*iter, 10, TRUE, 0, other ? other : max, &num);
5350 /* If number is greater than 'max' it must equal 'other' */
5351 if (success && other && (num > max) && (num != other))
5356 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive) or %u"),
5359 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive)"),
5364 out_array[i++] = (guint) num;
5375 dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop)
5377 NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5379 g_object_get (s_dcb, flags_prop, &flags, NULL);
5380 if (!(flags & NM_SETTING_DCB_FLAG_ENABLE))
5381 g_print (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
5385 nmc_property_dcb_set_pfc (NMSetting *setting, const char *prop, const char *val, GError **error)
5388 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5390 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5392 if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5395 for (i = 0; i < 8; i++)
5396 nm_setting_dcb_set_priority_flow_control (NM_SETTING_DCB (setting), i, !!nums[i]);
5398 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS);
5403 nmc_property_dcb_set_pg_group_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5406 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5408 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5410 if (!dcb_parse_uint_array (val, 7, 15, nums, error))
5413 for (i = 0; i < 8; i++)
5414 nm_setting_dcb_set_priority_group_id (NM_SETTING_DCB (setting), i, nums[i]);
5416 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5421 nmc_property_dcb_set_pg_group_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5423 guint i = 0, sum = 0;
5424 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5426 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5428 if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5431 for (i = 0; i < 8; i++)
5434 g_set_error_literal (error, 1, 0, _("bandwidth percentages must total 100%%"));
5438 for (i = 0; i < 8; i++)
5439 nm_setting_dcb_set_priority_group_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5441 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5446 nmc_property_dcb_set_pg_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5449 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5451 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5453 if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5456 for (i = 0; i < 8; i++)
5457 nm_setting_dcb_set_priority_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5459 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5464 nmc_property_dcb_set_pg_strict (NMSetting *setting, const char *prop, const char *val, GError **error)
5467 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5469 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5471 if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5474 for (i = 0; i < 8; i++)
5475 nm_setting_dcb_set_priority_strict_bandwidth (NM_SETTING_DCB (setting), i, !!nums[i]);
5477 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5482 nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, const char *val, GError **error)
5485 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5487 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5489 if (!dcb_parse_uint_array (val, 7, 0, nums, error))
5492 for (i = 0; i < 8; i++)
5493 nm_setting_dcb_set_priority_traffic_class (NM_SETTING_DCB (setting), i, nums[i]);
5495 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5499 /* 'app-fcoe-mode' */
5500 static const char *_dcb_valid_fcoe_modes[] = { NM_SETTING_DCB_FCOE_MODE_FABRIC,
5501 NM_SETTING_DCB_FCOE_MODE_VN2VN,
5505 nmc_property_dcb_set_app_fcoe_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
5507 return check_and_set_string (setting, prop, val, _dcb_valid_fcoe_modes, error);
5510 DEFINE_ALLOWED_VAL_FUNC (nmc_property_dcb_allowed_app_fcoe_modes, _dcb_valid_fcoe_modes)
5513 nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5515 const char *p = val;
5517 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5519 if (strlen (val) != 5 && strlen (val) != 6) {
5520 g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code"));
5525 if (!g_ascii_isdigit (*p++)) {
5526 g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code"));
5530 g_object_set (G_OBJECT (setting),
5531 NM_SETTING_GSM_SIM_OPERATOR_ID,
5538 nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
5540 NMSettingTun *s_tun = NM_SETTING_TUN (setting);
5541 NMSettingTunMode mode;
5544 mode = nm_setting_tun_get_mode (s_tun);
5545 tmp = nm_utils_enum_to_str (nm_setting_tun_mode_get_type (), mode);
5546 if (get_type == NMC_PROPERTY_GET_PARSABLE)
5547 str = g_strdup_printf ("%s", tmp ? tmp : "");
5549 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
5555 nmc_property_tun_set_mode (NMSetting *setting, const char *prop,
5556 const char *val, GError **error)
5558 NMSettingTunMode mode;
5562 if (nmc_string_to_int_base (val, 0, TRUE, 0, NM_SETTING_TUN_MODE_TAP, &t))
5563 mode = (NMSettingTunMode) t;
5565 ret = nm_utils_enum_from_str (nm_setting_tun_mode_get_type (), val,
5566 (int *) &mode, NULL);
5569 g_set_error (error, 1, 0, _("invalid option '%s', use '%s' or '%s'"),
5575 g_object_set (setting, prop, (guint) mode, NULL);
5579 static const char *tun_valid_modes[] = { "tun", "tap", "unknown", NULL };
5581 DEFINE_ALLOWED_VAL_FUNC (nmc_property_tun_allowed_mode, tun_valid_modes)
5583 /*----------------------------------------------------------------------------*/
5586 _nmc_add_prop_funcs (const char *key,
5587 const NmcPropertyFuncs *item_init)
5589 NmcPropertyFuncs *item;
5591 item = g_malloc (sizeof (NmcPropertyFuncs));
5593 g_hash_table_insert (nmc_properties, (gpointer) key, item);
5596 #define nmc_add_prop_funcs(key, ...) \
5599 NmcPropertyFuncsFields; \
5600 /* The _dummy field is here so that the last argument can be always
5601 * NULL. That means every call to nmc_add_prop_funcs() below ends
5602 * with a separate line "NULL);". */ \
5608 nm_assert (_item_init._dummy == NULL); \
5609 _nmc_add_prop_funcs ("" key, (NmcPropertyFuncs *) &_item_init); \
5612 /* concatenate setting name and property name */
5613 #define GLUE(A,B) "" NM_SETTING_##A##_SETTING_NAME "" NM_SETTING_##A##_##B ""
5614 #define GLUE_IP(A,B) "" NM_SETTING_IP##A##_CONFIG_SETTING_NAME "" NM_SETTING_IP_CONFIG_##B ""
5617 nmc_properties_init (void)
5619 if (G_LIKELY (nmc_properties))
5622 /* create properties hash table */
5623 nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
5625 /* Add editable properties for NM_SETTING_802_1X_SETTING_NAME */
5626 nmc_add_prop_funcs (GLUE (802_1X, EAP),
5627 nmc_property_802_1X_get_eap,
5628 nmc_property_802_1X_set_eap,
5629 nmc_property_802_1X_remove_eap,
5631 nmc_property_802_1X_allowed_eap,
5633 nmc_add_prop_funcs (GLUE (802_1X, IDENTITY),
5634 nmc_property_802_1X_get_identity,
5635 nmc_property_set_string,
5640 nmc_add_prop_funcs (GLUE (802_1X, ANONYMOUS_IDENTITY),
5641 nmc_property_802_1X_get_anonymous_identity,
5642 nmc_property_set_string,
5647 nmc_add_prop_funcs (GLUE (802_1X, PAC_FILE),
5648 nmc_property_802_1X_get_pac_file,
5649 nmc_property_set_string,
5654 nmc_add_prop_funcs (GLUE (802_1X, CA_CERT),
5655 nmc_property_802_1X_get_ca_cert,
5656 nmc_property_802_1X_set_ca_cert,
5658 nmc_property_802_1X_describe_ca_cert,
5661 nmc_add_prop_funcs (GLUE (802_1X, CA_PATH),
5662 nmc_property_802_1X_get_ca_path,
5663 nmc_property_set_string,
5668 nmc_add_prop_funcs (GLUE (802_1X, SUBJECT_MATCH),
5669 nmc_property_802_1X_get_subject_match,
5670 nmc_property_set_string,
5675 nmc_add_prop_funcs (GLUE (802_1X, ALTSUBJECT_MATCHES),
5676 nmc_property_802_1X_get_altsubject_matches,
5677 nmc_property_802_1X_set_altsubject_matches,
5678 nmc_property_802_1X_remove_altsubject_matches,
5682 nmc_add_prop_funcs (GLUE (802_1X, DOMAIN_SUFFIX_MATCH),
5683 nmc_property_802_1X_get_domain_suffix_match,
5684 nmc_property_set_string,
5689 nmc_add_prop_funcs (GLUE (802_1X, CLIENT_CERT),
5690 nmc_property_802_1X_get_client_cert,
5691 nmc_property_802_1X_set_client_cert,
5693 nmc_property_802_1X_describe_client_cert,
5696 nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPVER),
5697 nmc_property_802_1X_get_phase1_peapver,
5698 nmc_property_802_1X_set_phase1_peapver,
5701 nmc_property_802_1X_allowed_phase1_peapver,
5703 nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPLABEL),
5704 nmc_property_802_1X_get_phase1_peaplabel,
5705 nmc_property_802_1X_set_phase1_peaplabel,
5708 nmc_property_802_1X_allowed_phase1_peaplabel,
5710 nmc_add_prop_funcs (GLUE (802_1X, PHASE1_FAST_PROVISIONING),
5711 nmc_property_802_1X_get_phase1_fast_provisioning,
5712 nmc_property_802_1X_set_phase1_fast_provisioning,
5715 nmc_property_802_1X_allowed_phase1_fast_provisioning,
5717 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTH),
5718 nmc_property_802_1X_get_phase2_auth,
5719 nmc_property_802_1X_set_phase2_auth,
5722 nmc_property_802_1X_allowed_phase2_auth,
5724 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTHEAP),
5725 nmc_property_802_1X_get_phase2_autheap,
5726 nmc_property_802_1X_set_phase2_autheap,
5729 nmc_property_802_1X_allowed_phase2_autheap,
5731 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_CERT),
5732 nmc_property_802_1X_get_phase2_ca_cert,
5733 nmc_property_802_1X_set_phase2_ca_cert,
5735 nmc_property_802_1X_describe_phase2_ca_cert,
5738 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_PATH),
5739 nmc_property_802_1X_get_phase2_ca_path,
5740 nmc_property_set_string,
5745 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_SUBJECT_MATCH),
5746 nmc_property_802_1X_get_phase2_subject_match,
5747 nmc_property_set_string,
5752 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_ALTSUBJECT_MATCHES),
5753 nmc_property_802_1X_get_phase2_altsubject_matches,
5754 nmc_property_802_1X_set_phase2_altsubject_matches,
5755 nmc_property_802_1X_remove_phase2_altsubject_matches,
5759 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_DOMAIN_SUFFIX_MATCH),
5760 nmc_property_802_1X_get_phase2_domain_suffix_match,
5761 nmc_property_set_string,
5766 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CLIENT_CERT),
5767 nmc_property_802_1X_get_phase2_client_cert,
5768 nmc_property_802_1X_set_phase2_client_cert,
5770 nmc_property_802_1X_describe_phase2_client_cert,
5773 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD),
5774 nmc_property_802_1X_get_password,
5775 nmc_property_set_string,
5780 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_FLAGS),
5781 nmc_property_802_1X_get_password_flags,
5782 nmc_property_set_secret_flags,
5787 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW),
5788 nmc_property_802_1X_get_password_raw,
5789 nmc_property_802_1X_set_password_raw,
5791 nmc_property_802_1X_describe_password_raw,
5794 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW_FLAGS),
5795 nmc_property_802_1X_get_password_raw_flags,
5796 nmc_property_set_secret_flags,
5801 nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY),
5802 nmc_property_802_1X_get_private_key,
5803 nmc_property_802_1X_set_private_key,
5805 nmc_property_802_1X_describe_private_key,
5808 nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD),
5809 nmc_property_802_1X_get_private_key_password,
5810 nmc_property_set_string,
5815 nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD_FLAGS),
5816 nmc_property_802_1X_get_private_key_password_flags,
5817 nmc_property_set_secret_flags,
5822 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY),
5823 nmc_property_802_1X_get_phase2_private_key,
5824 nmc_property_802_1X_set_phase2_private_key,
5826 nmc_property_802_1X_describe_private_key,
5829 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD),
5830 nmc_property_802_1X_get_phase2_private_key_password,
5831 nmc_property_set_string,
5836 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD_FLAGS),
5837 nmc_property_802_1X_get_phase2_private_key_password_flags,
5838 nmc_property_set_secret_flags,
5843 nmc_add_prop_funcs (GLUE (802_1X, PIN),
5844 nmc_property_802_1X_get_pin,
5845 nmc_property_set_string,
5850 nmc_add_prop_funcs (GLUE (802_1X, PIN_FLAGS),
5851 nmc_property_802_1X_get_pin_flags,
5852 nmc_property_set_secret_flags,
5857 nmc_add_prop_funcs (GLUE (802_1X, SYSTEM_CA_CERTS),
5858 nmc_property_802_1X_get_system_ca_certs,
5859 nmc_property_set_bool,
5865 /* Add editable properties for NM_SETTING_ADSL_SETTING_NAME */
5866 nmc_add_prop_funcs (GLUE (ADSL, USERNAME),
5867 nmc_property_adsl_get_username,
5868 nmc_property_set_string,
5873 nmc_add_prop_funcs (GLUE (ADSL, PASSWORD),
5874 nmc_property_adsl_get_password,
5875 nmc_property_set_string,
5880 nmc_add_prop_funcs (GLUE (ADSL, PASSWORD_FLAGS),
5881 nmc_property_adsl_get_password_flags,
5882 nmc_property_set_secret_flags,
5887 nmc_add_prop_funcs (GLUE (ADSL, PROTOCOL),
5888 nmc_property_adsl_get_protocol,
5889 nmc_property_adsl_set_protocol,
5892 nmc_property_adsl_allowed_protocol,
5894 nmc_add_prop_funcs (GLUE (ADSL, ENCAPSULATION),
5895 nmc_property_adsl_get_encapsulation,
5896 nmc_property_adsl_set_encapsulation,
5899 nmc_property_adsl_allowed_encapsulation,
5901 nmc_add_prop_funcs (GLUE (ADSL, VPI),
5902 nmc_property_adsl_get_vpi,
5903 nmc_property_set_uint,
5908 nmc_add_prop_funcs (GLUE (ADSL, VCI),
5909 nmc_property_adsl_get_vci,
5910 nmc_property_set_uint,
5916 /* Add editable properties for NM_SETTING_BLUETOOTH_SETTING_NAME */
5917 nmc_add_prop_funcs (GLUE (BLUETOOTH, BDADDR),
5918 nmc_property_bluetooth_get_bdaddr,
5919 nmc_property_set_mac,
5924 nmc_add_prop_funcs (GLUE (BLUETOOTH, TYPE),
5925 nmc_property_bluetooth_get_type,
5926 nmc_property_bluetooth_set_type,
5932 /* Add editable properties for NM_SETTING_BOND_SETTING_NAME */
5933 nmc_add_prop_funcs (GLUE (BOND, OPTIONS),
5934 nmc_property_bond_get_options,
5935 nmc_property_bond_set_options,
5936 nmc_property_bond_remove_option_options,
5937 nmc_property_bond_describe_options,
5938 nmc_property_bond_allowed_options,
5941 /* Add editable properties for NM_SETTING_BRIDGE_SETTING_NAME */
5942 nmc_add_prop_funcs (GLUE (BRIDGE, MAC_ADDRESS),
5943 nmc_property_bridge_get_mac_address,
5944 nmc_property_set_mac,
5949 nmc_add_prop_funcs (GLUE (BRIDGE, STP),
5950 nmc_property_bridge_get_stp,
5951 nmc_property_set_bool,
5956 nmc_add_prop_funcs (GLUE (BRIDGE, PRIORITY),
5957 nmc_property_bridge_get_priority,
5958 nmc_property_set_uint,
5963 nmc_add_prop_funcs (GLUE (BRIDGE, FORWARD_DELAY),
5964 nmc_property_bridge_get_forward_delay,
5965 nmc_property_set_uint,
5970 nmc_add_prop_funcs (GLUE (BRIDGE, HELLO_TIME),
5971 nmc_property_bridge_get_hello_time,
5972 nmc_property_set_uint,
5977 nmc_add_prop_funcs (GLUE (BRIDGE, MAX_AGE),
5978 nmc_property_bridge_get_max_age,
5979 nmc_property_set_uint,
5984 nmc_add_prop_funcs (GLUE (BRIDGE, AGEING_TIME),
5985 nmc_property_bridge_get_ageing_time,
5986 nmc_property_set_uint,
5992 nmc_add_prop_funcs (GLUE (BRIDGE, MULTICAST_SNOOPING),
5993 nmc_property_bridge_get_multicast_snooping,
5994 nmc_property_set_bool,
6000 /* Add editable properties for NM_SETTING_BRIDGE_PORT_SETTING_NAME */
6001 nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PRIORITY),
6002 nmc_property_bridge_port_get_priority,
6003 nmc_property_set_uint,
6008 nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PATH_COST),
6009 nmc_property_bridge_port_get_path_cost,
6010 nmc_property_set_uint,
6015 nmc_add_prop_funcs (GLUE (BRIDGE_PORT, HAIRPIN_MODE),
6016 nmc_property_bridge_port_get_hairpin_mode,
6017 nmc_property_set_bool,
6023 /* Add editable properties for NM_SETTING_CDMA_SETTING_NAME */
6024 nmc_add_prop_funcs (GLUE (CDMA, NUMBER),
6025 nmc_property_cdma_get_number,
6026 nmc_property_set_string,
6031 nmc_add_prop_funcs (GLUE (CDMA, USERNAME),
6032 nmc_property_cdma_get_username,
6033 nmc_property_set_string,
6038 nmc_add_prop_funcs (GLUE (CDMA, PASSWORD),
6039 nmc_property_cdma_get_password,
6040 nmc_property_set_string,
6045 nmc_add_prop_funcs (GLUE (CDMA, PASSWORD_FLAGS),
6046 nmc_property_cdma_get_password_flags,
6047 nmc_property_set_secret_flags,
6053 /* Add editable properties for NM_SETTING_CONNECTION_SETTING_NAME */
6054 nmc_add_prop_funcs (GLUE (CONNECTION, ID),
6055 nmc_property_connection_get_id,
6056 nmc_property_set_string,
6061 nmc_add_prop_funcs (GLUE (CONNECTION, UUID),
6062 nmc_property_connection_get_uuid,
6063 NULL, /* forbid setting/removing UUID */
6068 nmc_add_prop_funcs (GLUE (CONNECTION, INTERFACE_NAME),
6069 nmc_property_connection_get_interface_name,
6070 nmc_property_set_ifname,
6075 nmc_add_prop_funcs (GLUE (CONNECTION, TYPE),
6076 nmc_property_connection_get_type,
6077 NULL, /* read-only */
6082 nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT),
6083 nmc_property_connection_get_autoconnect,
6084 nmc_property_set_bool,
6089 nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_PRIORITY),
6090 nmc_property_connection_get_autoconnect_priority,
6091 nmc_property_set_int,
6096 nmc_add_prop_funcs (GLUE (CONNECTION, TIMESTAMP),
6097 nmc_property_connection_get_timestamp,
6098 NULL, /* read-only */
6103 nmc_add_prop_funcs (GLUE (CONNECTION, READ_ONLY),
6104 nmc_property_connection_get_read_only,
6105 NULL, /* 'read-only' is read-only :-) */
6110 nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS),
6111 nmc_property_connection_get_permissions,
6112 nmc_property_connection_set_permissions,
6113 nmc_property_connection_remove_permissions,
6114 nmc_property_connection_describe_permissions,
6117 nmc_add_prop_funcs (GLUE (CONNECTION, ZONE),
6118 nmc_property_connection_get_zone,
6119 nmc_property_set_string,
6124 nmc_add_prop_funcs (GLUE (CONNECTION, MASTER),
6125 nmc_property_connection_get_master,
6126 nmc_property_con_set_master,
6131 nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE),
6132 nmc_property_connection_get_slave_type,
6133 nmc_property_con_set_slave_type,
6136 nmc_property_con_allowed_slave_type,
6138 nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_SLAVES),
6139 nmc_property_connection_get_autoconnect_slaves,
6140 nmc_property_set_trilean,
6145 nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES),
6146 nmc_property_connection_get_secondaries,
6147 nmc_property_connection_set_secondaries,
6148 nmc_property_connection_remove_secondaries,
6149 nmc_property_connection_describe_secondaries,
6152 nmc_add_prop_funcs (GLUE (CONNECTION, GATEWAY_PING_TIMEOUT),
6153 nmc_property_connection_get_gateway_ping_timeout,
6154 nmc_property_set_uint,
6159 nmc_add_prop_funcs (GLUE (CONNECTION, METERED),
6160 nmc_property_connection_get_metered,
6161 nmc_property_connection_set_metered,
6163 nmc_property_connection_describe_metered,
6166 nmc_add_prop_funcs (GLUE (CONNECTION, LLDP),
6167 nmc_property_connection_get_lldp,
6168 nmc_property_connection_set_lldp,
6174 /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */
6175 nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_FLAGS),
6176 nmc_property_dcb_get_app_fcoe_flags,
6177 nmc_property_dcb_set_flags,
6182 nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_MODE),
6183 nmc_property_dcb_get_app_fcoe_mode,
6184 nmc_property_dcb_set_app_fcoe_mode,
6187 nmc_property_dcb_allowed_app_fcoe_modes,
6189 nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_PRIORITY),
6190 nmc_property_dcb_get_app_fcoe_priority,
6191 nmc_property_dcb_set_priority,
6196 nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_FLAGS),
6197 nmc_property_dcb_get_app_iscsi_flags,
6198 nmc_property_dcb_set_flags,
6203 nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_PRIORITY),
6204 nmc_property_dcb_get_app_iscsi_priority,
6205 nmc_property_dcb_set_priority,
6210 nmc_add_prop_funcs (GLUE (DCB, APP_FIP_FLAGS),
6211 nmc_property_dcb_get_app_fip_flags,
6212 nmc_property_dcb_set_flags,
6217 nmc_add_prop_funcs (GLUE (DCB, APP_FIP_PRIORITY),
6218 nmc_property_dcb_get_app_fip_priority,
6219 nmc_property_dcb_set_priority,
6224 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL_FLAGS),
6225 nmc_property_dcb_get_pfc_flags,
6226 nmc_property_dcb_set_flags,
6231 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL),
6232 nmc_property_dcb_get_pfc,
6233 nmc_property_dcb_set_pfc,
6238 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_FLAGS),
6239 nmc_property_dcb_get_pg_flags,
6240 nmc_property_dcb_set_flags,
6245 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_ID),
6246 nmc_property_dcb_get_pg_group_id,
6247 nmc_property_dcb_set_pg_group_id,
6252 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_BANDWIDTH),
6253 nmc_property_dcb_get_pg_group_bandwidth,
6254 nmc_property_dcb_set_pg_group_bandwidth,
6259 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_BANDWIDTH),
6260 nmc_property_dcb_get_pg_bandwidth,
6261 nmc_property_dcb_set_pg_bandwidth,
6266 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_STRICT_BANDWIDTH),
6267 nmc_property_dcb_get_pg_strict,
6268 nmc_property_dcb_set_pg_strict,
6273 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_TRAFFIC_CLASS),
6274 nmc_property_dcb_get_pg_traffic_class,
6275 nmc_property_dcb_set_pg_traffic_class,
6281 /* Add editable properties for NM_SETTING_GSM_SETTING_NAME */
6282 nmc_add_prop_funcs (GLUE (GSM, NUMBER),
6283 nmc_property_gsm_get_number,
6284 nmc_property_set_string,
6289 nmc_add_prop_funcs (GLUE (GSM, USERNAME),
6290 nmc_property_gsm_get_username,
6291 nmc_property_set_string,
6296 nmc_add_prop_funcs (GLUE (GSM, PASSWORD),
6297 nmc_property_gsm_get_password,
6298 nmc_property_set_string,
6303 nmc_add_prop_funcs (GLUE (GSM, PASSWORD_FLAGS),
6304 nmc_property_gsm_get_password_flags,
6305 nmc_property_set_secret_flags,
6310 nmc_add_prop_funcs (GLUE (GSM, APN),
6311 nmc_property_gsm_get_apn,
6312 nmc_property_set_string,
6317 nmc_add_prop_funcs (GLUE (GSM, NETWORK_ID),
6318 nmc_property_gsm_get_network_id,
6319 nmc_property_set_string,
6324 nmc_add_prop_funcs (GLUE (GSM, PIN),
6325 nmc_property_gsm_get_pin,
6326 nmc_property_set_string,
6331 nmc_add_prop_funcs (GLUE (GSM, PIN_FLAGS),
6332 nmc_property_gsm_get_pin_flags,
6333 nmc_property_set_secret_flags,
6338 nmc_add_prop_funcs (GLUE (GSM, HOME_ONLY),
6339 nmc_property_gsm_get_home_only,
6340 nmc_property_set_bool,
6345 nmc_add_prop_funcs (GLUE (GSM, DEVICE_ID),
6346 nmc_property_gsm_get_device_id,
6347 nmc_property_set_string,
6352 nmc_add_prop_funcs (GLUE (GSM, SIM_ID),
6353 nmc_property_gsm_get_sim_id,
6354 nmc_property_set_string,
6359 nmc_add_prop_funcs (GLUE (GSM, SIM_OPERATOR_ID),
6360 nmc_property_gsm_get_sim_operator_id,
6361 nmc_property_gsm_set_sim_operator_id,
6367 /* Add editable properties for NM_SETTING_INFINIBAND_SETTING_NAME */
6368 nmc_add_prop_funcs (GLUE (INFINIBAND, MAC_ADDRESS),
6369 nmc_property_ib_get_mac_address,
6370 nmc_property_ib_set_mac,
6375 nmc_add_prop_funcs (GLUE (INFINIBAND, MTU),
6376 nmc_property_ib_get_mtu,
6377 nmc_property_set_mtu,
6382 nmc_add_prop_funcs (GLUE (INFINIBAND, TRANSPORT_MODE),
6383 nmc_property_ib_get_transport_mode,
6384 nmc_property_ib_set_transport_mode,
6387 nmc_property_ib_allowed_transport_mode,
6389 nmc_add_prop_funcs (GLUE (INFINIBAND, P_KEY),
6390 nmc_property_ib_get_p_key,
6391 nmc_property_ib_set_p_key,
6396 nmc_add_prop_funcs (GLUE (INFINIBAND, PARENT),
6397 nmc_property_ib_get_parent,
6398 nmc_property_set_ifname,
6404 /* Add editable properties for NM_SETTING_IP4_CONFIG_SETTING_NAME */
6405 nmc_add_prop_funcs (GLUE_IP (4, METHOD),
6406 nmc_property_ipv4_get_method,
6407 nmc_property_ipv4_set_method,
6410 nmc_property_ipv4_allowed_method,
6412 nmc_add_prop_funcs (GLUE_IP (4, DNS),
6413 nmc_property_ipv4_get_dns,
6414 nmc_property_ipv4_set_dns,
6415 nmc_property_ipv4_remove_dns,
6416 nmc_property_ipv4_describe_dns,
6419 nmc_add_prop_funcs (GLUE_IP (4, DNS_SEARCH),
6420 nmc_property_ipv4_get_dns_search,
6421 nmc_property_ipv4_set_dns_search,
6422 nmc_property_ipv4_remove_dns_search,
6426 nmc_add_prop_funcs (GLUE_IP (4, DNS_OPTIONS),
6427 nmc_property_ipv4_get_dns_options,
6428 nmc_property_ipv4_set_dns_options,
6429 nmc_property_ipv4_remove_dns_option,
6433 nmc_add_prop_funcs (GLUE_IP (4, ADDRESSES),
6434 nmc_property_ip_get_addresses,
6435 nmc_property_ipv4_set_addresses,
6436 nmc_property_ipv4_remove_addresses,
6437 nmc_property_ipv4_describe_addresses,
6440 nmc_add_prop_funcs (GLUE_IP (4, GATEWAY),
6441 nmc_property_ipv4_get_gateway,
6442 nmc_property_ipv4_set_gateway,
6447 nmc_add_prop_funcs (GLUE_IP (4, ROUTES),
6448 nmc_property_ipv4_get_routes,
6449 nmc_property_ipv4_set_routes,
6450 nmc_property_ipv4_remove_routes,
6451 nmc_property_ipv4_describe_routes,
6454 nmc_add_prop_funcs (GLUE_IP (4, ROUTE_METRIC),
6455 nmc_property_ipv4_get_route_metric,
6456 nmc_property_set_int64,
6461 nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_ROUTES),
6462 nmc_property_ipv4_get_ignore_auto_routes,
6463 nmc_property_set_bool,
6468 nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_DNS),
6469 nmc_property_ipv4_get_ignore_auto_dns,
6470 nmc_property_set_bool,
6475 nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_CLIENT_ID),
6476 nmc_property_ipv4_get_dhcp_client_id,
6477 nmc_property_set_string,
6482 nmc_add_prop_funcs (GLUE_IP (4, DHCP_TIMEOUT),
6483 nmc_property_ipv4_get_dhcp_timeout,
6484 nmc_property_set_int,
6489 nmc_add_prop_funcs (GLUE_IP (4, DHCP_SEND_HOSTNAME),
6490 nmc_property_ipv4_get_dhcp_send_hostname,
6491 nmc_property_set_bool,
6496 nmc_add_prop_funcs (GLUE_IP (4, DHCP_HOSTNAME),
6497 nmc_property_ipv4_get_dhcp_hostname,
6498 nmc_property_set_string,
6503 nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_FQDN),
6504 nmc_property_ipv4_get_dhcp_fqdn,
6505 nmc_property_set_string,
6510 nmc_add_prop_funcs (GLUE_IP (4, NEVER_DEFAULT),
6511 nmc_property_ipv4_get_never_default,
6512 nmc_property_set_bool,
6517 nmc_add_prop_funcs (GLUE_IP (4, MAY_FAIL),
6518 nmc_property_ipv4_get_may_fail,
6519 nmc_property_set_bool,
6524 nmc_add_prop_funcs (GLUE_IP (4, DAD_TIMEOUT),
6525 nmc_property_ipv4_get_dad_timeout,
6526 nmc_property_set_int,
6532 /* Add editable properties for NM_SETTING_IP6_CONFIG_SETTING_NAME */
6533 nmc_add_prop_funcs (GLUE_IP (6, METHOD),
6534 nmc_property_ipv6_get_method,
6535 nmc_property_ipv6_set_method,
6538 nmc_property_ipv6_allowed_method,
6540 nmc_add_prop_funcs (GLUE_IP (6, DNS),
6541 nmc_property_ipv6_get_dns,
6542 nmc_property_ipv6_set_dns,
6543 nmc_property_ipv6_remove_dns,
6544 nmc_property_ipv6_describe_dns,
6547 nmc_add_prop_funcs (GLUE_IP (6, DNS_SEARCH),
6548 nmc_property_ipv6_get_dns_search,
6549 nmc_property_ipv6_set_dns_search,
6550 nmc_property_ipv6_remove_dns_search,
6554 nmc_add_prop_funcs (GLUE_IP (6, DNS_OPTIONS),
6555 nmc_property_ipv6_get_dns_options,
6556 nmc_property_ipv6_set_dns_options,
6557 nmc_property_ipv6_remove_dns_option,
6561 nmc_add_prop_funcs (GLUE_IP (6, ADDRESSES),
6562 nmc_property_ip_get_addresses,
6563 nmc_property_ipv6_set_addresses,
6564 nmc_property_ipv6_remove_addresses,
6565 nmc_property_ipv6_describe_addresses,
6568 nmc_add_prop_funcs (GLUE_IP (6, GATEWAY),
6569 nmc_property_ipv6_get_gateway,
6570 nmc_property_ipv6_set_gateway,
6575 nmc_add_prop_funcs (GLUE_IP (6, ROUTES),
6576 nmc_property_ipv6_get_routes,
6577 nmc_property_ipv6_set_routes,
6578 nmc_property_ipv6_remove_routes,
6579 nmc_property_ipv6_describe_routes,
6582 nmc_add_prop_funcs (GLUE_IP (6, ROUTE_METRIC),
6583 nmc_property_ipv6_get_route_metric,
6584 nmc_property_set_int64,
6589 nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_ROUTES),
6590 nmc_property_ipv6_get_ignore_auto_routes,
6591 nmc_property_set_bool,
6596 nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_DNS),
6597 nmc_property_ipv6_get_ignore_auto_dns,
6598 nmc_property_set_bool,
6603 nmc_add_prop_funcs (GLUE_IP (6, NEVER_DEFAULT),
6604 nmc_property_ipv6_get_never_default,
6605 nmc_property_set_bool,
6610 nmc_add_prop_funcs (GLUE_IP (6, MAY_FAIL),
6611 nmc_property_ipv6_get_may_fail,
6612 nmc_property_set_bool,
6617 nmc_add_prop_funcs (GLUE (IP6_CONFIG, IP6_PRIVACY),
6618 nmc_property_ipv6_get_ip6_privacy,
6619 nmc_property_ipv6_set_ip6_privacy,
6624 nmc_add_prop_funcs (GLUE (IP6_CONFIG, ADDR_GEN_MODE),
6625 nmc_property_ipv6_get_addr_gen_mode,
6626 nmc_property_ipv6_set_addr_gen_mode,
6631 nmc_add_prop_funcs (GLUE_IP (6, DHCP_SEND_HOSTNAME),
6632 nmc_property_ipv6_get_dhcp_send_hostname,
6633 nmc_property_set_bool,
6638 nmc_add_prop_funcs (GLUE_IP (6, DHCP_HOSTNAME),
6639 nmc_property_ipv6_get_dhcp_hostname,
6640 nmc_property_set_string,
6646 /* Add editable properties for NM_SETTING_OLPC_MESH_SETTING_NAME */
6647 nmc_add_prop_funcs (GLUE (OLPC_MESH, SSID),
6648 nmc_property_olpc_get_ssid,
6649 nmc_property_set_ssid,
6654 nmc_add_prop_funcs (GLUE (OLPC_MESH, CHANNEL),
6655 nmc_property_olpc_get_channel,
6656 nmc_property_olpc_set_channel,
6661 nmc_add_prop_funcs (GLUE (OLPC_MESH, DHCP_ANYCAST_ADDRESS),
6662 nmc_property_olpc_get_anycast_address,
6663 nmc_property_set_mac,
6669 /* Add editable properties for NM_SETTING_PPP_SETTING_NAME */
6670 nmc_add_prop_funcs (GLUE (PPP, NOAUTH),
6671 nmc_property_ppp_get_noauth,
6672 nmc_property_set_bool,
6677 nmc_add_prop_funcs (GLUE (PPP, REFUSE_EAP),
6678 nmc_property_ppp_get_refuse_eap,
6679 nmc_property_set_bool,
6684 nmc_add_prop_funcs (GLUE (PPP, REFUSE_PAP),
6685 nmc_property_ppp_get_refuse_pap,
6686 nmc_property_set_bool,
6691 nmc_add_prop_funcs (GLUE (PPP, REFUSE_CHAP),
6692 nmc_property_ppp_get_refuse_chap,
6693 nmc_property_set_bool,
6698 nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAP),
6699 nmc_property_ppp_get_refuse_mschap,
6700 nmc_property_set_bool,
6705 nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAPV2),
6706 nmc_property_ppp_get_refuse_mschapv2,
6707 nmc_property_set_bool,
6712 nmc_add_prop_funcs (GLUE (PPP, NOBSDCOMP),
6713 nmc_property_ppp_get_nobsdcomp,
6714 nmc_property_set_bool,
6719 nmc_add_prop_funcs (GLUE (PPP, NODEFLATE),
6720 nmc_property_ppp_get_nodeflate,
6721 nmc_property_set_bool,
6726 nmc_add_prop_funcs (GLUE (PPP, NO_VJ_COMP),
6727 nmc_property_ppp_get_no_vj_comp,
6728 nmc_property_set_bool,
6733 nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE),
6734 nmc_property_ppp_get_require_mppe,
6735 nmc_property_set_bool,
6740 nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE_128),
6741 nmc_property_ppp_get_require_mppe_128,
6742 nmc_property_set_bool,
6747 nmc_add_prop_funcs (GLUE (PPP, MPPE_STATEFUL),
6748 nmc_property_ppp_get_mppe_stateful,
6749 nmc_property_set_bool,
6754 nmc_add_prop_funcs (GLUE (PPP, CRTSCTS),
6755 nmc_property_ppp_get_crtscts,
6756 nmc_property_set_bool,
6761 nmc_add_prop_funcs (GLUE (PPP, BAUD),
6762 nmc_property_ppp_get_baud,
6763 nmc_property_set_uint,
6768 nmc_add_prop_funcs (GLUE (PPP, MRU),
6769 nmc_property_ppp_get_mru,
6770 nmc_property_set_uint,
6775 nmc_add_prop_funcs (GLUE (PPP, MTU),
6776 nmc_property_ppp_get_mtu,
6777 nmc_property_set_mtu,
6782 nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_FAILURE),
6783 nmc_property_ppp_get_lcp_echo_failure,
6784 nmc_property_set_uint,
6789 nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_INTERVAL),
6790 nmc_property_ppp_get_lcp_echo_interval,
6791 nmc_property_set_uint,
6797 /* Add editable properties for NM_SETTING_PPPOE_SETTING_NAME */
6798 nmc_add_prop_funcs (GLUE (PPPOE, SERVICE),
6799 nmc_property_pppoe_get_service,
6800 nmc_property_set_string,
6805 nmc_add_prop_funcs (GLUE (PPPOE, USERNAME),
6806 nmc_property_pppoe_get_username,
6807 nmc_property_set_string,
6812 nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD),
6813 nmc_property_pppoe_get_password,
6814 nmc_property_set_string,
6819 nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD_FLAGS),
6820 nmc_property_pppoe_get_password_flags,
6821 nmc_property_set_secret_flags,
6827 /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */
6828 nmc_add_prop_funcs (GLUE (SERIAL, BAUD),
6829 nmc_property_serial_get_baud,
6830 nmc_property_set_uint,
6835 nmc_add_prop_funcs (GLUE (SERIAL, BITS),
6836 nmc_property_serial_get_bits,
6837 nmc_property_set_uint,
6842 nmc_add_prop_funcs (GLUE (SERIAL, PARITY),
6843 nmc_property_serial_get_parity,
6844 nmc_property_serial_set_parity,
6849 nmc_add_prop_funcs (GLUE (SERIAL, STOPBITS),
6850 nmc_property_serial_get_stopbits,
6851 nmc_property_set_uint,
6856 nmc_add_prop_funcs (GLUE (SERIAL, SEND_DELAY),
6857 nmc_property_serial_get_send_delay,
6858 nmc_property_set_uint,
6864 /* Add editable properties for NM_SETTING_TEAM_SETTING_NAME */
6865 nmc_add_prop_funcs (GLUE (TEAM, CONFIG),
6866 nmc_property_team_get_config,
6867 nmc_property_team_set_config,
6869 nmc_property_team_describe_config,
6873 /* Add editable properties for NM_SETTING_TEAM_PORT_SETTING_NAME */
6874 nmc_add_prop_funcs (GLUE (TEAM_PORT, CONFIG),
6875 nmc_property_team_port_get_config,
6876 nmc_property_team_set_config,
6878 nmc_property_team_describe_config,
6882 /* Add editable properties for NM_SETTING_VLAN_SETTING_NAME */
6883 nmc_add_prop_funcs (GLUE (VLAN, PARENT),
6884 nmc_property_vlan_get_parent,
6885 nmc_property_set_string,
6890 nmc_add_prop_funcs (GLUE (VLAN, ID),
6891 nmc_property_vlan_get_id,
6892 nmc_property_set_uint,
6897 nmc_add_prop_funcs (GLUE (VLAN, FLAGS),
6898 nmc_property_vlan_get_flags,
6899 nmc_property_set_flags,
6904 nmc_add_prop_funcs (GLUE (VLAN, INGRESS_PRIORITY_MAP),
6905 nmc_property_vlan_get_ingress_priority_map,
6906 nmc_property_vlan_set_ingress_priority_map,
6907 nmc_property_vlan_remove_ingress_priority_map,
6911 nmc_add_prop_funcs (GLUE (VLAN, EGRESS_PRIORITY_MAP),
6912 nmc_property_vlan_get_egress_priority_map,
6913 nmc_property_vlan_set_egress_priority_map,
6914 nmc_property_vlan_remove_egress_priority_map,
6919 /* Add editable properties for NM_SETTING_VPN_SETTING_NAME */
6920 nmc_add_prop_funcs (GLUE (VPN, SERVICE_TYPE),
6921 nmc_property_vpn_get_service_type,
6922 nmc_property_set_string,
6927 nmc_add_prop_funcs (GLUE (VPN, USER_NAME),
6928 nmc_property_vpn_get_user_name,
6929 nmc_property_set_string,
6934 nmc_add_prop_funcs (GLUE (VPN, DATA),
6935 nmc_property_vpn_get_data,
6936 nmc_property_vpn_set_data,
6937 nmc_property_vpn_remove_option_data,
6941 nmc_add_prop_funcs (GLUE (VPN, SECRETS),
6942 nmc_property_vpn_get_secrets,
6943 nmc_property_vpn_set_secrets,
6944 nmc_property_vpn_remove_option_secret,
6948 nmc_add_prop_funcs (GLUE (VPN, PERSISTENT),
6949 nmc_property_vpn_get_persistent,
6950 nmc_property_set_bool,
6956 nmc_add_prop_funcs (GLUE (VPN, TIMEOUT),
6957 nmc_property_vpn_get_timeout,
6958 nmc_property_set_uint,
6964 /* Add editable properties for NM_SETTING_WIMAX_SETTING_NAME */
6965 nmc_add_prop_funcs (GLUE (WIMAX, NETWORK_NAME),
6966 nmc_property_wimax_get_network_name,
6967 nmc_property_set_string,
6972 nmc_add_prop_funcs (GLUE (WIMAX, MAC_ADDRESS),
6973 nmc_property_wimax_get_mac_address,
6974 nmc_property_set_mac,
6980 /* Add editable properties for NM_SETTING_WIRED_SETTING_NAME */
6981 nmc_add_prop_funcs (GLUE (WIRED, PORT),
6982 nmc_property_wired_get_port,
6983 NULL, /*nmc_property_wired_set_port,*/
6986 NULL, /*nmc_property_wired_allowed_port,*/
6988 nmc_add_prop_funcs (GLUE (WIRED, SPEED),
6989 nmc_property_wired_get_speed,
6995 nmc_add_prop_funcs (GLUE (WIRED, DUPLEX),
6996 nmc_property_wired_get_duplex,
6997 NULL, /*nmc_property_wired_set_duplex,*/
7001 NULL); /*nmc_property_wired_allowed_duplex);*/
7002 nmc_add_prop_funcs (GLUE (WIRED, AUTO_NEGOTIATE),
7003 nmc_property_wired_get_auto_negotiate,
7009 nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS),
7010 nmc_property_wired_get_mac_address,
7011 nmc_property_set_mac,
7016 nmc_add_prop_funcs (GLUE (WIRED, CLONED_MAC_ADDRESS),
7017 nmc_property_wired_get_cloned_mac_address,
7018 nmc_property_set_mac,
7023 nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS_BLACKLIST),
7024 nmc_property_wired_get_mac_address_blacklist,
7025 nmc_property_wired_set_mac_address_blacklist,
7026 nmc_property_wired_remove_mac_address_blacklist,
7030 nmc_add_prop_funcs (GLUE (WIRED, MTU),
7031 nmc_property_wired_get_mtu,
7032 nmc_property_set_mtu,
7037 nmc_add_prop_funcs (GLUE (WIRED, S390_SUBCHANNELS),
7038 nmc_property_wired_get_s390_subchannels,
7039 nmc_property_wired_set_s390_subchannels,
7041 nmc_property_wired_describe_s390_subchannels,
7044 nmc_add_prop_funcs (GLUE (WIRED, S390_NETTYPE),
7045 nmc_property_wired_get_s390_nettype,
7046 nmc_property_wired_set_s390_nettype,
7049 nmc_property_wired_allowed_s390_nettype,
7051 nmc_add_prop_funcs (GLUE (WIRED, S390_OPTIONS),
7052 nmc_property_wired_get_s390_options,
7053 nmc_property_wired_set_s390_options,
7054 nmc_property_wired_remove_option_s390_options,
7055 nmc_property_wired_describe_s390_options,
7056 nmc_property_wired_allowed_s390_options,
7058 nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN),
7059 nmc_property_wired_get_wake_on_lan,
7060 nmc_property_wired_set_wake_on_lan,
7065 nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN_PASSWORD),
7066 nmc_property_wired_get_wake_on_lan_password,
7067 nmc_property_set_mac,
7073 /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */
7074 nmc_add_prop_funcs (GLUE (WIRELESS, SSID),
7075 nmc_property_wireless_get_ssid,
7076 nmc_property_set_ssid,
7081 nmc_add_prop_funcs (GLUE (WIRELESS, MODE),
7082 nmc_property_wireless_get_mode,
7083 nmc_property_wifi_set_mode,
7086 nmc_property_wifi_allowed_mode,
7088 nmc_add_prop_funcs (GLUE (WIRELESS, BAND),
7089 nmc_property_wireless_get_band,
7090 nmc_property_wifi_set_band,
7093 nmc_property_wifi_allowed_band,
7095 nmc_add_prop_funcs (GLUE (WIRELESS, CHANNEL),
7096 nmc_property_wireless_get_channel,
7097 nmc_property_wifi_set_channel,
7102 nmc_add_prop_funcs (GLUE (WIRELESS, BSSID),
7103 nmc_property_wireless_get_bssid,
7104 nmc_property_set_mac,
7110 * Do not allow setting 'rate' and 'tx-power'. They are not implemented in
7111 * NM core, nor in ifcfg-rh plugin (thus not preserved over re-reading).
7113 nmc_add_prop_funcs (GLUE (WIRELESS, RATE),
7114 nmc_property_wireless_get_rate,
7115 NULL, /* editing rate disabled */
7120 nmc_add_prop_funcs (GLUE (WIRELESS, TX_POWER),
7121 nmc_property_wireless_get_tx_power,
7122 NULL, /* editing tx-power disabled */
7127 nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS),
7128 nmc_property_wireless_get_mac_address,
7129 nmc_property_set_mac,
7134 nmc_add_prop_funcs (GLUE (WIRELESS, CLONED_MAC_ADDRESS),
7135 nmc_property_wireless_get_cloned_mac_address,
7136 nmc_property_set_mac,
7141 nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_BLACKLIST),
7142 nmc_property_wireless_get_mac_address_blacklist,
7143 nmc_property_wireless_set_mac_address_blacklist,
7144 nmc_property_wireless_remove_mac_address_blacklist,
7148 nmc_add_prop_funcs (GLUE (WIRELESS, SEEN_BSSIDS),
7149 nmc_property_wireless_get_seen_bssids,
7150 NULL, /* read-only */
7155 nmc_add_prop_funcs (GLUE (WIRELESS, MTU),
7156 nmc_property_wireless_get_mtu,
7157 nmc_property_set_mtu,
7162 nmc_add_prop_funcs (GLUE (WIRELESS, HIDDEN),
7163 nmc_property_wireless_get_hidden,
7164 nmc_property_set_bool,
7169 nmc_add_prop_funcs (GLUE (WIRELESS, POWERSAVE),
7170 nmc_property_wireless_get_powersave,
7171 nmc_property_wireless_set_powersave,
7176 nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_RANDOMIZATION),
7177 nmc_property_wireless_get_mac_address_randomization,
7178 nmc_property_wireless_set_mac_address_randomization,
7184 /* Add editable properties for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */
7185 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, KEY_MGMT),
7186 nmc_property_wifi_sec_get_key_mgmt,
7187 nmc_property_wifi_sec_set_key_mgmt,
7190 nmc_property_wifi_sec_allowed_key_mgmt,
7192 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_TX_KEYIDX),
7193 nmc_property_wifi_sec_get_wep_tx_keyidx,
7194 nmc_property_set_uint,
7199 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, AUTH_ALG),
7200 nmc_property_wifi_sec_get_auth_alg,
7201 nmc_property_wifi_sec_set_auth_alg,
7204 nmc_property_wifi_sec_allowed_auth_alg,
7206 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PROTO),
7207 nmc_property_wifi_sec_get_proto,
7208 nmc_property_wifi_sec_set_proto,
7209 nmc_property_wifi_sec_remove_proto,
7211 nmc_property_wifi_sec_allowed_proto,
7213 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PAIRWISE),
7214 nmc_property_wifi_sec_get_pairwise,
7215 nmc_property_wifi_sec_set_pairwise,
7216 nmc_property_wifi_sec_remove_pairwise,
7218 nmc_property_wifi_sec_allowed_pairwise,
7220 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, GROUP),
7221 nmc_property_wifi_sec_get_group,
7222 nmc_property_wifi_sec_set_group,
7223 nmc_property_wifi_sec_remove_group,
7225 nmc_property_wifi_sec_allowed_group,
7227 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_USERNAME),
7228 nmc_property_wifi_sec_get_leap_username,
7229 nmc_property_set_string,
7234 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY0),
7235 nmc_property_wifi_sec_get_wep_key0,
7236 nmc_property_wifi_set_wep_key,
7241 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY1),
7242 nmc_property_wifi_sec_get_wep_key1,
7243 nmc_property_wifi_set_wep_key,
7248 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY2),
7249 nmc_property_wifi_sec_get_wep_key2,
7250 nmc_property_wifi_set_wep_key,
7255 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY3),
7256 nmc_property_wifi_sec_get_wep_key3,
7257 nmc_property_wifi_set_wep_key,
7262 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_FLAGS),
7263 nmc_property_wifi_sec_get_wep_key_flags,
7264 nmc_property_set_secret_flags,
7269 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_TYPE),
7270 nmc_property_wifi_sec_get_wep_key_type,
7271 nmc_property_wifi_set_wep_key_type,
7273 nmc_property_wifi_describe_wep_key_type,
7276 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK),
7277 nmc_property_wifi_sec_get_psk,
7278 nmc_property_wifi_set_psk,
7283 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK_FLAGS),
7284 nmc_property_wifi_sec_get_psk_flags,
7285 nmc_property_set_secret_flags,
7290 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD),
7291 nmc_property_wifi_sec_get_leap_password,
7292 nmc_property_set_string,
7297 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD_FLAGS),
7298 nmc_property_wifi_sec_get_leap_password_flags,
7299 nmc_property_set_secret_flags,
7305 /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */
7306 nmc_add_prop_funcs (GLUE (TUN, MODE),
7307 nmc_property_tun_get_mode,
7308 nmc_property_tun_set_mode,
7311 nmc_property_tun_allowed_mode,
7313 nmc_add_prop_funcs (GLUE (TUN, OWNER),
7314 nmc_property_tun_get_owner,
7315 nmc_property_set_string,
7320 nmc_add_prop_funcs (GLUE (TUN, GROUP),
7321 nmc_property_tun_get_group,
7322 nmc_property_set_string,
7327 nmc_add_prop_funcs (GLUE (TUN, PI),
7328 nmc_property_tun_get_pi,
7329 nmc_property_set_bool,
7334 nmc_add_prop_funcs (GLUE (TUN, VNET_HDR),
7335 nmc_property_tun_get_vnet_hdr,
7336 nmc_property_set_bool,
7341 nmc_add_prop_funcs (GLUE (TUN, MULTI_QUEUE),
7342 nmc_property_tun_get_multi_queue,
7343 nmc_property_set_bool,
7349 /* Add editable properties for NM_SETTING_IP_TUNNEL_SETTING_NAME */
7350 nmc_add_prop_funcs (GLUE (IP_TUNNEL, MODE),
7351 nmc_property_ip_tunnel_get_mode,
7352 nmc_property_ip_tunnel_set_mode,
7355 nmc_property_ip_tunnel_allowed_mode,
7357 nmc_add_prop_funcs (GLUE (IP_TUNNEL, PARENT),
7358 nmc_property_ip_tunnel_get_parent,
7359 nmc_property_set_string,
7364 nmc_add_prop_funcs (GLUE (IP_TUNNEL, LOCAL),
7365 nmc_property_ip_tunnel_get_local,
7366 nmc_property_set_string,
7371 nmc_add_prop_funcs (GLUE (IP_TUNNEL, REMOTE),
7372 nmc_property_ip_tunnel_get_remote,
7373 nmc_property_set_string,
7378 nmc_add_prop_funcs (GLUE (IP_TUNNEL, TTL),
7379 nmc_property_ip_tunnel_get_ttl,
7380 nmc_property_set_uint,
7385 nmc_add_prop_funcs (GLUE (IP_TUNNEL, TOS),
7386 nmc_property_ip_tunnel_get_tos,
7387 nmc_property_set_uint,
7392 nmc_add_prop_funcs (GLUE (IP_TUNNEL, PATH_MTU_DISCOVERY),
7393 nmc_property_ip_tunnel_get_path_mtu_discovery,
7394 nmc_property_set_bool,
7399 nmc_add_prop_funcs (GLUE (IP_TUNNEL, INPUT_KEY),
7400 nmc_property_ip_tunnel_get_input_key,
7401 nmc_property_set_string,
7406 nmc_add_prop_funcs (GLUE (IP_TUNNEL, OUTPUT_KEY),
7407 nmc_property_ip_tunnel_get_output_key,
7408 nmc_property_set_string,
7413 nmc_add_prop_funcs (GLUE (IP_TUNNEL, ENCAPSULATION_LIMIT),
7414 nmc_property_ip_tunnel_get_encapsulation_limit,
7415 nmc_property_set_uint,
7420 nmc_add_prop_funcs (GLUE (IP_TUNNEL, FLOW_LABEL),
7421 nmc_property_ip_tunnel_get_flow_label,
7422 nmc_property_set_uint,
7427 nmc_add_prop_funcs (GLUE (IP_TUNNEL, MTU),
7428 nmc_property_ip_tunnel_get_mtu,
7429 nmc_property_set_uint,
7435 /* Add editable properties for NM_SETTING_MACVLAN_SETTING_NAME */
7436 nmc_add_prop_funcs (GLUE (MACVLAN, PARENT),
7437 nmc_property_macvlan_get_parent,
7438 nmc_property_set_string,
7443 nmc_add_prop_funcs (GLUE (MACVLAN, MODE),
7444 nmc_property_macvlan_get_mode,
7445 nmc_property_macvlan_set_mode,
7448 nmc_property_macvlan_allowed_mode,
7450 nmc_add_prop_funcs (GLUE (MACVLAN, PROMISCUOUS),
7451 nmc_property_macvlan_get_promiscuous,
7452 nmc_property_set_bool,
7457 nmc_add_prop_funcs (GLUE (MACVLAN, TAP),
7458 nmc_property_macvlan_get_tap,
7459 nmc_property_set_bool,
7465 /* Add editable properties for NM_SETTING_VXLAN_SETTING_NAME */
7466 nmc_add_prop_funcs (GLUE (VXLAN, PARENT),
7467 nmc_property_vxlan_get_parent,
7468 nmc_property_set_string,
7473 nmc_add_prop_funcs (GLUE (VXLAN, ID),
7474 nmc_property_vxlan_get_id,
7475 nmc_property_set_uint,
7480 nmc_add_prop_funcs (GLUE (VXLAN, LOCAL),
7481 nmc_property_vxlan_get_local,
7482 nmc_property_set_string,
7487 nmc_add_prop_funcs (GLUE (VXLAN, REMOTE),
7488 nmc_property_vxlan_get_remote,
7489 nmc_property_set_string,
7494 nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MIN),
7495 nmc_property_vxlan_get_source_port_min,
7496 nmc_property_set_uint,
7501 nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MAX),
7502 nmc_property_vxlan_get_source_port_max,
7503 nmc_property_set_uint,
7508 nmc_add_prop_funcs (GLUE (VXLAN, DESTINATION_PORT),
7509 nmc_property_vxlan_get_destination_port,
7510 nmc_property_set_uint,
7515 nmc_add_prop_funcs (GLUE (VXLAN, TOS),
7516 nmc_property_vxlan_get_tos,
7517 nmc_property_set_uint,
7522 nmc_add_prop_funcs (GLUE (VXLAN, TTL),
7523 nmc_property_vxlan_get_ttl,
7524 nmc_property_set_uint,
7529 nmc_add_prop_funcs (GLUE (VXLAN, AGEING),
7530 nmc_property_vxlan_get_ageing,
7531 nmc_property_set_uint,
7536 nmc_add_prop_funcs (GLUE (VXLAN, LIMIT),
7537 nmc_property_vxlan_get_limit,
7538 nmc_property_set_uint,
7543 nmc_add_prop_funcs (GLUE (VXLAN, LEARNING),
7544 nmc_property_vxlan_get_learning,
7545 nmc_property_set_bool,
7550 nmc_add_prop_funcs (GLUE (VXLAN, PROXY),
7551 nmc_property_vxlan_get_proxy,
7552 nmc_property_set_bool,
7557 nmc_add_prop_funcs (GLUE (VXLAN, RSC),
7558 nmc_property_vxlan_get_rsc,
7559 nmc_property_set_bool,
7564 nmc_add_prop_funcs (GLUE (VXLAN, L2_MISS),
7565 nmc_property_vxlan_get_l2_miss,
7566 nmc_property_set_bool,
7571 nmc_add_prop_funcs (GLUE (VXLAN, L3_MISS),
7572 nmc_property_vxlan_get_l3_miss,
7573 nmc_property_set_bool,
7581 nmc_properties_cleanup ()
7584 g_hash_table_destroy (nmc_properties);
7587 static const NmcPropertyFuncs *
7588 nmc_properties_find (const char *s_name, const char *p_name)
7593 nmc_properties_init ();
7595 s_l = strlen (s_name);
7596 p_l = strlen (p_name);
7597 key = g_alloca (s_l + p_l + 1);
7598 memcpy (&key[ 0], s_name, s_l);
7599 memcpy (&key[s_l], p_name, p_l + 1);
7600 return (NmcPropertyFuncs *) g_hash_table_lookup (nmc_properties, key);
7604 get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error)
7606 const NmcPropertyFuncs *item;
7608 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7609 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7611 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7612 if (item && item->get_func)
7613 return item->get_func (setting, get_type);
7615 g_set_error_literal (error, 1, 0, _("don't know how to get the property value"));
7620 * Generic function for getting property value.
7622 * Gets property value as a string by calling specialized functions.
7624 * Returns: current property value. The caller must free the returned string.
7627 nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error)
7629 return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, error);
7633 * Similar to nmc_setting_get_property(), but returns the property in a string
7634 * format that can be parsed via nmc_setting_set_property().
7637 nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError **error)
7639 return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, error);
7643 * Generic function for setting property value.
7645 * Sets property=val in setting by calling specialized functions.
7646 * If val is NULL then default property value is set.
7648 * Returns: TRUE on success; FALSE on failure and sets error
7651 nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error)
7653 const NmcPropertyFuncs *item;
7655 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7656 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7658 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7659 if (item && item->set_func) {
7661 /* No value argument sets default value */
7662 nmc_property_set_default_value (setting, prop);
7665 return item->set_func (setting, prop, val, error);
7668 g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7673 nmc_property_set_default_value (NMSetting *setting, const char *prop)
7675 GValue value = G_VALUE_INIT;
7676 GParamSpec *param_spec;
7678 param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7680 g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
7681 g_param_value_set_default (param_spec, &value);
7682 g_object_set_property (G_OBJECT (setting), prop, &value);
7687 * Generic function for reseting (single value) properties.
7689 * The function resets the property value to the default one. It respects
7690 * nmcli restrictions for changing properties. So if 'set_func' is NULL,
7691 * reseting the value is denied.
7693 * Returns: TRUE on success; FALSE on failure and sets error
7696 nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error)
7698 const NmcPropertyFuncs *item;
7700 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7701 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7703 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7704 if (item && item->set_func) {
7705 nmc_property_set_default_value (setting, prop);
7708 g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7713 * Generic function for removing items for collection-type properties.
7715 * If 'option' is not NULL, it tries to remove it, otherwise 'idx' is used.
7716 * For single-value properties (not having specialized remove function) this
7717 * function does nothing and just returns TRUE.
7719 * Returns: TRUE on success; FALSE on failure and sets error
7722 nmc_setting_remove_property_option (NMSetting *setting,
7728 const NmcPropertyFuncs *item;
7730 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7731 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7733 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7734 if (item && item->remove_func)
7735 return item->remove_func (setting, prop, option, idx, error);
7741 * Get valid property names for a setting.
7743 * Returns: string array with the properties or NULL on failure.
7744 * The returned value should be freed with g_strfreev()
7747 nmc_setting_get_valid_properties (NMSetting *setting)
7749 char **valid_props = NULL;
7750 GParamSpec **props, **iter;
7754 /* Iterate through properties */
7756 props = g_object_class_list_properties (G_OBJECT_GET_CLASS (G_OBJECT (setting)), &num);
7757 valid_props = g_malloc0 (sizeof (char*) * (num + 1));
7758 for (iter = props; iter && *iter; iter++) {
7759 const char *key_name = g_param_spec_get_name (*iter);
7761 /* Add all properties except for "name" that is non-editable */
7762 if (g_strcmp0 (key_name, "name") != 0)
7763 valid_props[i++] = g_strdup (key_name);
7765 valid_props[i] = NULL;
7772 * Return allowed values for 'prop' as a string.
7775 nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop)
7778 const NmcPropertyFuncs *item;
7780 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7782 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7783 if (item && item->values_func)
7784 return item->values_func (setting, prop);
7789 #if defined (BUILD_SETTING_DOCS) || defined (HAVE_SETTING_DOCS)
7790 #include "settings-docs.c"
7792 #define nmc_setting_get_property_doc(setting, prop) _("(not available)")
7796 * Create a description string for a property.
7798 * It returns a description got from property documentation, concatenated with
7799 * nmcli specific description (if it exists).
7801 * Returns: property description or NULL on failure. The caller must free the string.
7804 nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
7806 const NmcPropertyFuncs *item;
7807 const char *setting_desc = NULL;
7808 const char *setting_desc_title = "";
7809 const char *nmcli_desc = NULL;
7810 const char *nmcli_desc_title = "";
7811 const char *nmcli_nl = "";
7813 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7815 setting_desc = nmc_setting_get_property_doc (setting, prop);
7817 setting_desc_title = _("[NM property description]");
7819 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7820 if (item && item->describe_func) {
7821 nmcli_desc = item->describe_func (setting, prop);
7822 nmcli_desc_title = _("[nmcli specific description]");
7826 return g_strdup_printf ("%s\n%s\n%s%s%s%s",
7828 setting_desc ? setting_desc : "",
7829 nmcli_nl, nmcli_desc_title, nmcli_nl,
7830 nmcli_desc ? nmcli_desc : "");
7834 * Gets setting:prop property value and returns it in 'value'.
7835 * Caller is responsible for freeing the GValue resources using g_value_unset()
7838 nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value)
7840 GParamSpec *param_spec;
7842 param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7844 memset (value, 0, sizeof (GValue));
7845 g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
7846 g_object_get_property (G_OBJECT (setting), prop, value);
7853 * Sets setting:prop property value from 'value'.
7856 nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value)
7858 GParamSpec *param_spec;
7860 param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7861 if (param_spec && G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (param_spec)) {
7862 g_object_set_property (G_OBJECT (setting), prop, value);
7868 /*----------------------------------------------------------------------------*/
7870 #define GET_SECRET(show, setting, func) \
7871 (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_("<hidden>")))
7874 setting_connection_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
7876 NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
7877 NmcOutputField *tmpl, *arr;
7880 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (s_con), FALSE);
7882 tmpl = nmc_fields_setting_connection;
7883 tmpl_len = sizeof (nmc_fields_setting_connection);
7884 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CONNECTION_ALL,
7885 tmpl, FALSE, NULL, NULL);
7886 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7887 g_ptr_array_add (nmc->output_data, arr);
7889 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7890 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7891 set_val_str (arr, 1, nmc_property_connection_get_id (setting, NMC_PROPERTY_GET_PRETTY));
7892 set_val_str (arr, 2, nmc_property_connection_get_uuid (setting, NMC_PROPERTY_GET_PRETTY));
7893 set_val_str (arr, 3, nmc_property_connection_get_interface_name (setting, NMC_PROPERTY_GET_PRETTY));
7894 set_val_str (arr, 4, nmc_property_connection_get_type (setting, NMC_PROPERTY_GET_PRETTY));
7895 set_val_str (arr, 5, nmc_property_connection_get_autoconnect (setting, NMC_PROPERTY_GET_PRETTY));
7896 set_val_str (arr, 6, nmc_property_connection_get_autoconnect_priority (setting, NMC_PROPERTY_GET_PRETTY));
7897 set_val_str (arr, 7, nmc_property_connection_get_timestamp (setting, NMC_PROPERTY_GET_PRETTY));
7898 set_val_str (arr, 8, nmc_property_connection_get_read_only (setting, NMC_PROPERTY_GET_PRETTY));
7899 set_val_str (arr, 9, nmc_property_connection_get_permissions (setting, NMC_PROPERTY_GET_PRETTY));
7900 set_val_str (arr, 10, nmc_property_connection_get_zone (setting, NMC_PROPERTY_GET_PRETTY));
7901 set_val_str (arr, 11, nmc_property_connection_get_master (setting, NMC_PROPERTY_GET_PRETTY));
7902 set_val_str (arr, 12, nmc_property_connection_get_slave_type (setting, NMC_PROPERTY_GET_PRETTY));
7903 set_val_str (arr, 13, nmc_property_connection_get_autoconnect_slaves (setting, NMC_PROPERTY_GET_PRETTY));
7904 set_val_str (arr, 14, nmc_property_connection_get_secondaries (setting, NMC_PROPERTY_GET_PRETTY));
7905 set_val_str (arr, 15, nmc_property_connection_get_gateway_ping_timeout (setting, NMC_PROPERTY_GET_PRETTY));
7906 set_val_str (arr, 16, nmc_property_connection_get_metered (setting, NMC_PROPERTY_GET_PRETTY));
7907 set_val_str (arr, 17, nmc_property_connection_get_lldp (setting, NMC_PROPERTY_GET_PRETTY));
7908 g_ptr_array_add (nmc->output_data, arr);
7910 print_data (nmc); /* Print all data */
7916 setting_wired_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
7918 NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
7919 NmcOutputField *tmpl, *arr;
7922 g_return_val_if_fail (NM_IS_SETTING_WIRED (s_wired), FALSE);
7924 tmpl = nmc_fields_setting_wired;
7925 tmpl_len = sizeof (nmc_fields_setting_wired);
7926 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRED_ALL,
7927 tmpl, FALSE, NULL, NULL);
7928 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7929 g_ptr_array_add (nmc->output_data, arr);
7931 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7932 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7933 set_val_str (arr, 1, nmc_property_wired_get_port (setting, NMC_PROPERTY_GET_PRETTY));
7934 set_val_str (arr, 2, nmc_property_wired_get_speed (setting, NMC_PROPERTY_GET_PRETTY));
7935 set_val_str (arr, 3, nmc_property_wired_get_duplex (setting, NMC_PROPERTY_GET_PRETTY));
7936 set_val_str (arr, 4, nmc_property_wired_get_auto_negotiate (setting, NMC_PROPERTY_GET_PRETTY));
7937 set_val_str (arr, 5, nmc_property_wired_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
7938 set_val_str (arr, 6, nmc_property_wired_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
7939 set_val_str (arr, 7, nmc_property_wired_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY));
7940 set_val_str (arr, 8, nmc_property_wired_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
7941 set_val_str (arr, 9, nmc_property_wired_get_s390_subchannels (setting, NMC_PROPERTY_GET_PRETTY));
7942 set_val_str (arr, 10, nmc_property_wired_get_s390_nettype (setting, NMC_PROPERTY_GET_PRETTY));
7943 set_val_str (arr, 11, nmc_property_wired_get_s390_options (setting, NMC_PROPERTY_GET_PRETTY));
7944 set_val_str (arr, 12, nmc_property_wired_get_wake_on_lan (setting, NMC_PROPERTY_GET_PRETTY));
7945 set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan_password (setting, NMC_PROPERTY_GET_PRETTY));
7946 g_ptr_array_add (nmc->output_data, arr);
7948 print_data (nmc); /* Print all data */
7954 setting_802_1X_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
7956 NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting);
7957 NmcOutputField *tmpl, *arr;
7960 g_return_val_if_fail (NM_IS_SETTING_802_1X (s_8021x), FALSE);
7962 tmpl = nmc_fields_setting_8021X;
7963 tmpl_len = sizeof (nmc_fields_setting_8021X);
7964 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_802_1X_ALL,
7965 tmpl, FALSE, NULL, NULL);
7966 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7967 g_ptr_array_add (nmc->output_data, arr);
7969 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7970 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7971 set_val_str (arr, 1, nmc_property_802_1X_get_eap (setting, NMC_PROPERTY_GET_PRETTY));
7972 set_val_str (arr, 2, nmc_property_802_1X_get_identity (setting, NMC_PROPERTY_GET_PRETTY));
7973 set_val_str (arr, 3, nmc_property_802_1X_get_anonymous_identity (setting, NMC_PROPERTY_GET_PRETTY));
7974 set_val_str (arr, 4, nmc_property_802_1X_get_pac_file (setting, NMC_PROPERTY_GET_PRETTY));
7975 set_val_str (arr, 5, nmc_property_802_1X_get_ca_cert (setting, NMC_PROPERTY_GET_PRETTY));
7976 set_val_str (arr, 6, nmc_property_802_1X_get_ca_path (setting, NMC_PROPERTY_GET_PRETTY));
7977 set_val_str (arr, 7, nmc_property_802_1X_get_subject_match (setting, NMC_PROPERTY_GET_PRETTY));
7978 set_val_str (arr, 8, nmc_property_802_1X_get_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY));
7979 set_val_str (arr, 9, nmc_property_802_1X_get_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY));
7980 set_val_str (arr, 10, nmc_property_802_1X_get_client_cert (setting, NMC_PROPERTY_GET_PRETTY));
7981 set_val_str (arr, 11, nmc_property_802_1X_get_phase1_peapver (setting, NMC_PROPERTY_GET_PRETTY));
7982 set_val_str (arr, 12, nmc_property_802_1X_get_phase1_peaplabel (setting, NMC_PROPERTY_GET_PRETTY));
7983 set_val_str (arr, 13, nmc_property_802_1X_get_phase1_fast_provisioning (setting, NMC_PROPERTY_GET_PRETTY));
7984 set_val_str (arr, 14, nmc_property_802_1X_get_phase2_auth (setting, NMC_PROPERTY_GET_PRETTY));
7985 set_val_str (arr, 15, nmc_property_802_1X_get_phase2_autheap (setting, NMC_PROPERTY_GET_PRETTY));
7986 set_val_str (arr, 16, nmc_property_802_1X_get_phase2_ca_cert (setting, NMC_PROPERTY_GET_PRETTY));
7987 set_val_str (arr, 17, nmc_property_802_1X_get_phase2_ca_path (setting, NMC_PROPERTY_GET_PRETTY));
7988 set_val_str (arr, 18, nmc_property_802_1X_get_phase2_subject_match (setting, NMC_PROPERTY_GET_PRETTY));
7989 set_val_str (arr, 19, nmc_property_802_1X_get_phase2_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY));
7990 set_val_str (arr, 20, nmc_property_802_1X_get_phase2_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY));
7991 set_val_str (arr, 21, nmc_property_802_1X_get_phase2_client_cert (setting, NMC_PROPERTY_GET_PRETTY));
7992 set_val_str (arr, 22, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password));
7993 set_val_str (arr, 23, nmc_property_802_1X_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
7994 set_val_str (arr, 24, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password_raw));
7995 set_val_str (arr, 25, nmc_property_802_1X_get_password_raw_flags (setting, NMC_PROPERTY_GET_PRETTY));
7996 set_val_str (arr, 26, nmc_property_802_1X_get_private_key (setting, NMC_PROPERTY_GET_PRETTY));
7997 set_val_str (arr, 27, GET_SECRET (secrets, setting, nmc_property_802_1X_get_private_key_password));
7998 set_val_str (arr, 28, nmc_property_802_1X_get_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
7999 set_val_str (arr, 29, nmc_property_802_1X_get_phase2_private_key (setting, NMC_PROPERTY_GET_PRETTY));
8000 set_val_str (arr, 30, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_private_key_password));
8001 set_val_str (arr, 31, nmc_property_802_1X_get_phase2_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8002 set_val_str (arr, 32, GET_SECRET (secrets, setting, nmc_property_802_1X_get_pin));
8003 set_val_str (arr, 33, nmc_property_802_1X_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY));
8004 set_val_str (arr, 34, nmc_property_802_1X_get_system_ca_certs (setting, NMC_PROPERTY_GET_PRETTY));
8005 g_ptr_array_add (nmc->output_data, arr);
8007 print_data (nmc); /* Print all data */
8013 setting_wireless_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8015 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
8016 NmcOutputField *tmpl, *arr;
8019 g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE);
8021 tmpl = nmc_fields_setting_wireless;
8022 tmpl_len = sizeof (nmc_fields_setting_wireless);
8023 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_ALL,
8024 tmpl, FALSE, NULL, NULL);
8025 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8026 g_ptr_array_add (nmc->output_data, arr);
8028 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8029 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8030 set_val_str (arr, 1, nmc_property_wireless_get_ssid (setting, NMC_PROPERTY_GET_PRETTY));
8031 set_val_str (arr, 2, nmc_property_wireless_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8032 set_val_str (arr, 3, nmc_property_wireless_get_band (setting, NMC_PROPERTY_GET_PRETTY));
8033 set_val_str (arr, 4, nmc_property_wireless_get_channel (setting, NMC_PROPERTY_GET_PRETTY));
8034 set_val_str (arr, 5, nmc_property_wireless_get_bssid (setting, NMC_PROPERTY_GET_PRETTY));
8035 set_val_str (arr, 6, nmc_property_wireless_get_rate (setting, NMC_PROPERTY_GET_PRETTY));
8036 set_val_str (arr, 7, nmc_property_wireless_get_tx_power (setting, NMC_PROPERTY_GET_PRETTY));
8037 set_val_str (arr, 8, nmc_property_wireless_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8038 set_val_str (arr, 9, nmc_property_wireless_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8039 set_val_str (arr, 10, nmc_property_wireless_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY));
8040 set_val_str (arr, 11, nmc_property_wireless_get_mac_address_randomization (setting, NMC_PROPERTY_GET_PRETTY));
8041 set_val_str (arr, 12, nmc_property_wireless_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8042 set_val_str (arr, 13, nmc_property_wireless_get_seen_bssids (setting, NMC_PROPERTY_GET_PRETTY));
8043 set_val_str (arr, 14, nmc_property_wireless_get_hidden (setting, NMC_PROPERTY_GET_PRETTY));
8044 set_val_str (arr, 15, nmc_property_wireless_get_powersave (setting, NMC_PROPERTY_GET_PRETTY));
8045 g_ptr_array_add (nmc->output_data, arr);
8047 print_data (nmc); /* Print all data */
8053 setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8055 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
8056 NmcOutputField *tmpl, *arr;
8059 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (s_wireless_sec), FALSE);
8061 tmpl = nmc_fields_setting_wireless_security;
8062 tmpl_len = sizeof (nmc_fields_setting_wireless_security);
8063 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_SECURITY_ALL,
8064 tmpl, FALSE, NULL, NULL);
8065 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8066 g_ptr_array_add (nmc->output_data, arr);
8068 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8069 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8070 set_val_str (arr, 1, nmc_property_wifi_sec_get_key_mgmt (setting, NMC_PROPERTY_GET_PRETTY));
8071 set_val_str (arr, 2, nmc_property_wifi_sec_get_wep_tx_keyidx (setting, NMC_PROPERTY_GET_PRETTY));
8072 set_val_str (arr, 3, nmc_property_wifi_sec_get_auth_alg (setting, NMC_PROPERTY_GET_PRETTY));
8073 set_val_str (arr, 4, nmc_property_wifi_sec_get_proto (setting, NMC_PROPERTY_GET_PRETTY));
8074 set_val_str (arr, 5, nmc_property_wifi_sec_get_pairwise (setting, NMC_PROPERTY_GET_PRETTY));
8075 set_val_str (arr, 6, nmc_property_wifi_sec_get_group (setting, NMC_PROPERTY_GET_PRETTY));
8076 set_val_str (arr, 7, nmc_property_wifi_sec_get_leap_username (setting, NMC_PROPERTY_GET_PRETTY));
8077 set_val_str (arr, 8, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key0));
8078 set_val_str (arr, 9, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key1));
8079 set_val_str (arr, 10, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key2));
8080 set_val_str (arr, 11, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key3));
8081 set_val_str (arr, 12, nmc_property_wifi_sec_get_wep_key_flags (setting, NMC_PROPERTY_GET_PRETTY));
8082 set_val_str (arr, 13, nmc_property_wifi_sec_get_wep_key_type (setting, NMC_PROPERTY_GET_PRETTY));
8083 set_val_str (arr, 14, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_psk));
8084 set_val_str (arr, 15, nmc_property_wifi_sec_get_psk_flags (setting, NMC_PROPERTY_GET_PRETTY));
8085 set_val_str (arr, 16, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_leap_password));
8086 set_val_str (arr, 17, nmc_property_wifi_sec_get_leap_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8087 g_ptr_array_add (nmc->output_data, arr);
8089 print_data (nmc); /* Print all data */
8095 setting_ip4_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8097 NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting);
8098 NmcOutputField *tmpl, *arr;
8101 g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (s_ip4), FALSE);
8103 tmpl = nmc_fields_setting_ip4_config;
8104 tmpl_len = sizeof (nmc_fields_setting_ip4_config);
8105 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP4_CONFIG_ALL,
8106 tmpl, FALSE, NULL, NULL);
8107 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8108 g_ptr_array_add (nmc->output_data, arr);
8110 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8111 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8112 set_val_str (arr, 1, nmc_property_ipv4_get_method (setting, NMC_PROPERTY_GET_PRETTY));
8113 set_val_str (arr, 2, nmc_property_ipv4_get_dns (setting, NMC_PROPERTY_GET_PRETTY));
8114 set_val_str (arr, 3, nmc_property_ipv4_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY));
8115 set_val_str (arr, 4, nmc_property_ipv4_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY));
8116 set_val_str (arr, 5, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY));
8117 set_val_str (arr, 6, nmc_property_ipv4_get_gateway (setting, NMC_PROPERTY_GET_PRETTY));
8118 set_val_str (arr, 7, nmc_property_ipv4_get_routes (setting, NMC_PROPERTY_GET_PRETTY));
8119 set_val_str (arr, 8, nmc_property_ipv4_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY));
8120 set_val_str (arr, 9, nmc_property_ipv4_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
8121 set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
8122 set_val_str (arr, 11, nmc_property_ipv4_get_dhcp_client_id (setting, NMC_PROPERTY_GET_PRETTY));
8123 set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8124 set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8125 set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8126 set_val_str (arr, 15, nmc_property_ipv4_get_dhcp_fqdn (setting, NMC_PROPERTY_GET_PRETTY));
8127 set_val_str (arr, 16, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
8128 set_val_str (arr, 17, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
8129 set_val_str (arr, 18, nmc_property_ipv4_get_dad_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8130 g_ptr_array_add (nmc->output_data, arr);
8132 print_data (nmc); /* Print all data */
8138 setting_ip6_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8140 NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting);
8141 NmcOutputField *tmpl, *arr;
8144 g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (s_ip6), FALSE);
8146 tmpl = nmc_fields_setting_ip6_config;
8147 tmpl_len = sizeof (nmc_fields_setting_ip6_config);
8148 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP6_CONFIG_ALL,
8149 tmpl, FALSE, NULL, NULL);
8150 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8151 g_ptr_array_add (nmc->output_data, arr);
8153 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8154 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8155 set_val_str (arr, 1, nmc_property_ipv6_get_method (setting, NMC_PROPERTY_GET_PRETTY));
8156 set_val_str (arr, 2, nmc_property_ipv6_get_dns (setting, NMC_PROPERTY_GET_PRETTY));
8157 set_val_str (arr, 3, nmc_property_ipv6_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY));
8158 set_val_str (arr, 4, nmc_property_ipv6_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY));
8159 set_val_str (arr, 5, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY));
8160 set_val_str (arr, 6, nmc_property_ipv6_get_gateway (setting, NMC_PROPERTY_GET_PRETTY));
8161 set_val_str (arr, 7, nmc_property_ipv6_get_routes (setting, NMC_PROPERTY_GET_PRETTY));
8162 set_val_str (arr, 8, nmc_property_ipv6_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY));
8163 set_val_str (arr, 9, nmc_property_ipv6_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
8164 set_val_str (arr, 10, nmc_property_ipv6_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
8165 set_val_str (arr, 11, nmc_property_ipv6_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
8166 set_val_str (arr, 12, nmc_property_ipv6_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
8167 set_val_str (arr, 13, nmc_property_ipv6_get_ip6_privacy (setting, NMC_PROPERTY_GET_PRETTY));
8168 set_val_str (arr, 14, nmc_property_ipv6_get_addr_gen_mode (setting, NMC_PROPERTY_GET_PRETTY));
8169 set_val_str (arr, 15, nmc_property_ipv6_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8170 set_val_str (arr, 16, nmc_property_ipv6_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8171 g_ptr_array_add (nmc->output_data, arr);
8173 print_data (nmc); /* Print all data */
8179 setting_serial_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8181 NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
8182 NmcOutputField *tmpl, *arr;
8185 g_return_val_if_fail (NM_IS_SETTING_SERIAL (s_serial), FALSE);
8187 tmpl = nmc_fields_setting_serial;
8188 tmpl_len = sizeof (nmc_fields_setting_serial);
8189 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_SERIAL_ALL,
8190 tmpl, FALSE, NULL, NULL);
8191 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8192 g_ptr_array_add (nmc->output_data, arr);
8194 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8195 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8196 set_val_str (arr, 1, nmc_property_serial_get_baud (setting, NMC_PROPERTY_GET_PRETTY));
8197 set_val_str (arr, 2, nmc_property_serial_get_bits (setting, NMC_PROPERTY_GET_PRETTY));
8198 set_val_str (arr, 3, nmc_property_serial_get_parity (setting, NMC_PROPERTY_GET_PRETTY));
8199 set_val_str (arr, 4, nmc_property_serial_get_stopbits (setting, NMC_PROPERTY_GET_PRETTY));
8200 set_val_str (arr, 5, nmc_property_serial_get_send_delay (setting, NMC_PROPERTY_GET_PRETTY));
8201 g_ptr_array_add (nmc->output_data, arr);
8203 print_data (nmc); /* Print all data */
8209 setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8211 NMSettingPpp *s_ppp = NM_SETTING_PPP (setting);
8212 NmcOutputField *tmpl, *arr;
8215 g_return_val_if_fail (NM_IS_SETTING_PPP (s_ppp), FALSE);
8217 tmpl = nmc_fields_setting_ppp;
8218 tmpl_len = sizeof (nmc_fields_setting_ppp);
8219 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPP_ALL,
8220 tmpl, FALSE, NULL, NULL);
8221 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8222 g_ptr_array_add (nmc->output_data, arr);
8224 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8225 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8226 set_val_str (arr, 1, nmc_property_ppp_get_noauth (setting, NMC_PROPERTY_GET_PRETTY));
8227 set_val_str (arr, 2, nmc_property_ppp_get_refuse_eap (setting, NMC_PROPERTY_GET_PRETTY));
8228 set_val_str (arr, 3, nmc_property_ppp_get_refuse_pap (setting, NMC_PROPERTY_GET_PRETTY));
8229 set_val_str (arr, 4, nmc_property_ppp_get_refuse_chap (setting, NMC_PROPERTY_GET_PRETTY));
8230 set_val_str (arr, 5, nmc_property_ppp_get_refuse_mschap (setting, NMC_PROPERTY_GET_PRETTY));
8231 set_val_str (arr, 6, nmc_property_ppp_get_refuse_mschapv2 (setting, NMC_PROPERTY_GET_PRETTY));
8232 set_val_str (arr, 7, nmc_property_ppp_get_nobsdcomp (setting, NMC_PROPERTY_GET_PRETTY));
8233 set_val_str (arr, 8, nmc_property_ppp_get_nodeflate (setting, NMC_PROPERTY_GET_PRETTY));
8234 set_val_str (arr, 9, nmc_property_ppp_get_no_vj_comp (setting, NMC_PROPERTY_GET_PRETTY));
8235 set_val_str (arr, 10, nmc_property_ppp_get_require_mppe (setting, NMC_PROPERTY_GET_PRETTY));
8236 set_val_str (arr, 11, nmc_property_ppp_get_require_mppe_128 (setting, NMC_PROPERTY_GET_PRETTY));
8237 set_val_str (arr, 12, nmc_property_ppp_get_mppe_stateful (setting, NMC_PROPERTY_GET_PRETTY));
8238 set_val_str (arr, 13, nmc_property_ppp_get_crtscts (setting, NMC_PROPERTY_GET_PRETTY));
8239 set_val_str (arr, 14, nmc_property_ppp_get_baud (setting, NMC_PROPERTY_GET_PRETTY));
8240 set_val_str (arr, 15, nmc_property_ppp_get_mru (setting, NMC_PROPERTY_GET_PRETTY));
8241 set_val_str (arr, 16, nmc_property_ppp_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8242 set_val_str (arr, 17, nmc_property_ppp_get_lcp_echo_failure (setting, NMC_PROPERTY_GET_PRETTY));
8243 set_val_str (arr, 18, nmc_property_ppp_get_lcp_echo_interval (setting, NMC_PROPERTY_GET_PRETTY));
8244 g_ptr_array_add (nmc->output_data, arr);
8246 print_data (nmc); /* Print all data */
8252 setting_pppoe_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8254 NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting);
8255 NmcOutputField *tmpl, *arr;
8258 g_return_val_if_fail (NM_IS_SETTING_PPPOE (s_pppoe), FALSE);
8260 tmpl = nmc_fields_setting_pppoe;
8261 tmpl_len = sizeof (nmc_fields_setting_pppoe);
8262 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPPOE_ALL,
8263 tmpl, FALSE, NULL, NULL);
8264 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8265 g_ptr_array_add (nmc->output_data, arr);
8267 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8268 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8269 set_val_str (arr, 1, nmc_property_pppoe_get_service (setting, NMC_PROPERTY_GET_PRETTY));
8270 set_val_str (arr, 2, nmc_property_pppoe_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8271 set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_pppoe_get_password));
8272 set_val_str (arr, 4, nmc_property_pppoe_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8273 g_ptr_array_add (nmc->output_data, arr);
8275 print_data (nmc); /* Print all data */
8281 setting_gsm_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8283 NMSettingGsm *s_gsm = NM_SETTING_GSM (setting);
8284 NmcOutputField *tmpl, *arr;
8287 g_return_val_if_fail (NM_IS_SETTING_GSM (s_gsm), FALSE);
8289 tmpl = nmc_fields_setting_gsm;
8290 tmpl_len = sizeof (nmc_fields_setting_gsm);
8291 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_GSM_ALL,
8292 tmpl, FALSE, NULL, NULL);
8293 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8294 g_ptr_array_add (nmc->output_data, arr);
8296 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8297 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8298 set_val_str (arr, 1, nmc_property_gsm_get_number (setting, NMC_PROPERTY_GET_PRETTY));
8299 set_val_str (arr, 2, nmc_property_gsm_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8300 set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_gsm_get_password));
8301 set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8302 set_val_str (arr, 5, nmc_property_gsm_get_apn (setting, NMC_PROPERTY_GET_PRETTY));
8303 set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting, NMC_PROPERTY_GET_PRETTY));
8304 set_val_str (arr, 7, GET_SECRET (secrets, setting, nmc_property_gsm_get_pin));
8305 set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY));
8306 set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting, NMC_PROPERTY_GET_PRETTY));
8307 set_val_str (arr, 10, nmc_property_gsm_get_device_id (setting, NMC_PROPERTY_GET_PRETTY));
8308 set_val_str (arr, 11, nmc_property_gsm_get_sim_id (setting, NMC_PROPERTY_GET_PRETTY));
8309 set_val_str (arr, 12, nmc_property_gsm_get_sim_operator_id (setting, NMC_PROPERTY_GET_PRETTY));
8310 g_ptr_array_add (nmc->output_data, arr);
8312 print_data (nmc); /* Print all data */
8318 setting_cdma_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8320 NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting);
8321 NmcOutputField *tmpl, *arr;
8324 g_return_val_if_fail (NM_IS_SETTING_CDMA (s_cdma), FALSE);
8326 tmpl = nmc_fields_setting_cdma;
8327 tmpl_len = sizeof (nmc_fields_setting_cdma);
8328 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CDMA_ALL,
8329 tmpl, FALSE, NULL, NULL);
8330 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8331 g_ptr_array_add (nmc->output_data, arr);
8333 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8334 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8335 set_val_str (arr, 1, nmc_property_cdma_get_number (setting, NMC_PROPERTY_GET_PRETTY));
8336 set_val_str (arr, 2, nmc_property_cdma_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8337 set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_cdma_get_password));
8338 set_val_str (arr, 4, nmc_property_cdma_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8339 g_ptr_array_add (nmc->output_data, arr);
8341 print_data (nmc); /* Print all data */
8347 setting_bluetooth_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8349 NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting);
8350 NmcOutputField *tmpl, *arr;
8353 g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (s_bluetooth), FALSE);
8355 tmpl = nmc_fields_setting_bluetooth;
8356 tmpl_len = sizeof (nmc_fields_setting_bluetooth);
8357 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BLUETOOTH_ALL,
8358 tmpl, FALSE, NULL, NULL);
8359 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8360 g_ptr_array_add (nmc->output_data, arr);
8362 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8363 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8364 set_val_str (arr, 1, nmc_property_bluetooth_get_bdaddr (setting, NMC_PROPERTY_GET_PRETTY));
8365 set_val_str (arr, 2, nmc_property_bluetooth_get_type (setting, NMC_PROPERTY_GET_PRETTY));
8366 g_ptr_array_add (nmc->output_data, arr);
8368 print_data (nmc); /* Print all data */
8374 setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8376 NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
8377 NmcOutputField *tmpl, *arr;
8380 g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (s_olpc_mesh), FALSE);
8382 tmpl = nmc_fields_setting_olpc_mesh;
8383 tmpl_len = sizeof (nmc_fields_setting_olpc_mesh);
8384 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_OLPC_MESH_ALL,
8385 tmpl, FALSE, NULL, NULL);
8386 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8387 g_ptr_array_add (nmc->output_data, arr);
8389 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8390 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8391 set_val_str (arr, 1, nmc_property_olpc_get_ssid (setting, NMC_PROPERTY_GET_PRETTY));
8392 set_val_str (arr, 2, nmc_property_olpc_get_channel (setting, NMC_PROPERTY_GET_PRETTY));
8393 set_val_str (arr, 3, nmc_property_olpc_get_anycast_address (setting, NMC_PROPERTY_GET_PRETTY));
8394 g_ptr_array_add (nmc->output_data, arr);
8396 print_data (nmc); /* Print all data */
8402 setting_vpn_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8404 NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
8405 NmcOutputField *tmpl, *arr;
8408 g_return_val_if_fail (NM_IS_SETTING_VPN (s_vpn), FALSE);
8410 tmpl = nmc_fields_setting_vpn;
8411 tmpl_len = sizeof (nmc_fields_setting_vpn);
8412 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VPN_ALL,
8413 tmpl, FALSE, NULL, NULL);
8414 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8415 g_ptr_array_add (nmc->output_data, arr);
8417 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8418 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8419 set_val_str (arr, 1, nmc_property_vpn_get_service_type (setting, NMC_PROPERTY_GET_PRETTY));
8420 set_val_str (arr, 2, nmc_property_vpn_get_user_name (setting, NMC_PROPERTY_GET_PRETTY));
8421 set_val_str (arr, 3, nmc_property_vpn_get_data (setting, NMC_PROPERTY_GET_PRETTY));
8422 set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_vpn_get_secrets));
8423 set_val_str (arr, 5, nmc_property_vpn_get_persistent (setting, NMC_PROPERTY_GET_PRETTY));
8424 set_val_str (arr, 6, nmc_property_vpn_get_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8425 g_ptr_array_add (nmc->output_data, arr);
8427 print_data (nmc); /* Print all data */
8433 setting_wimax_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8435 NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting);
8436 NmcOutputField *tmpl, *arr;
8439 g_return_val_if_fail (NM_IS_SETTING_WIMAX (s_wimax), FALSE);
8441 tmpl = nmc_fields_setting_wimax;
8442 tmpl_len = sizeof (nmc_fields_setting_wimax);
8443 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIMAX_ALL,
8444 tmpl, FALSE, NULL, NULL);
8445 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8446 g_ptr_array_add (nmc->output_data, arr);
8448 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8449 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8450 set_val_str (arr, 1, nmc_property_wimax_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8451 set_val_str (arr, 2, nmc_property_wimax_get_network_name (setting, NMC_PROPERTY_GET_PRETTY));
8452 g_ptr_array_add (nmc->output_data, arr);
8454 print_data (nmc); /* Print all data */
8460 setting_infiniband_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8462 NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
8463 NmcOutputField *tmpl, *arr;
8466 g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (s_infiniband), FALSE);
8468 tmpl = nmc_fields_setting_infiniband;
8469 tmpl_len = sizeof (nmc_fields_setting_infiniband);
8470 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_INFINIBAND_ALL,
8471 tmpl, FALSE, NULL, NULL);
8472 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8473 g_ptr_array_add (nmc->output_data, arr);
8475 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8476 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8477 set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8478 set_val_str (arr, 2, nmc_property_ib_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8479 set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting, NMC_PROPERTY_GET_PRETTY));
8480 set_val_str (arr, 4, nmc_property_ib_get_p_key (setting, NMC_PROPERTY_GET_PRETTY));
8481 set_val_str (arr, 5, nmc_property_ib_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8482 g_ptr_array_add (nmc->output_data, arr);
8484 print_data (nmc); /* Print all data */
8490 setting_bond_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8492 NMSettingBond *s_bond = NM_SETTING_BOND (setting);
8493 NmcOutputField *tmpl, *arr;
8496 g_return_val_if_fail (NM_IS_SETTING_BOND (s_bond), FALSE);
8498 tmpl = nmc_fields_setting_bond;
8499 tmpl_len = sizeof (nmc_fields_setting_bond);
8500 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BOND_ALL,
8501 tmpl, FALSE, NULL, NULL);
8502 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8503 g_ptr_array_add (nmc->output_data, arr);
8505 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8506 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8507 set_val_str (arr, 1, nmc_property_bond_get_options (setting, NMC_PROPERTY_GET_PRETTY));
8508 g_ptr_array_add (nmc->output_data, arr);
8510 print_data (nmc); /* Print all data */
8516 setting_vlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8518 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
8519 NmcOutputField *tmpl, *arr;
8522 g_return_val_if_fail (NM_IS_SETTING_VLAN (s_vlan), FALSE);
8524 tmpl = nmc_fields_setting_vlan;
8525 tmpl_len = sizeof (nmc_fields_setting_vlan);
8526 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VLAN_ALL,
8527 tmpl, FALSE, NULL, NULL);
8528 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8529 g_ptr_array_add (nmc->output_data, arr);
8531 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8532 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8533 set_val_str (arr, 1, nmc_property_vlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8534 set_val_str (arr, 2, nmc_property_vlan_get_id (setting, NMC_PROPERTY_GET_PRETTY));
8535 set_val_str (arr, 3, nmc_property_vlan_get_flags (setting, NMC_PROPERTY_GET_PRETTY));
8536 set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting, NMC_PROPERTY_GET_PRETTY));
8537 set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting, NMC_PROPERTY_GET_PRETTY));
8538 g_ptr_array_add (nmc->output_data, arr);
8540 print_data (nmc); /* Print all data */
8546 setting_adsl_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8548 NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting);
8549 NmcOutputField *tmpl, *arr;
8552 g_return_val_if_fail (NM_IS_SETTING_ADSL (s_adsl), FALSE);
8554 tmpl = nmc_fields_setting_adsl;
8555 tmpl_len = sizeof (nmc_fields_setting_adsl);
8556 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_ADSL_ALL,
8557 tmpl, FALSE, NULL, NULL);
8558 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8559 g_ptr_array_add (nmc->output_data, arr);
8561 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8562 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8563 set_val_str (arr, 1, nmc_property_adsl_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8564 set_val_str (arr, 2, GET_SECRET (secrets, setting, nmc_property_adsl_get_password));
8565 set_val_str (arr, 3, nmc_property_adsl_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8566 set_val_str (arr, 4, nmc_property_adsl_get_protocol (setting, NMC_PROPERTY_GET_PRETTY));
8567 set_val_str (arr, 5, nmc_property_adsl_get_encapsulation (setting, NMC_PROPERTY_GET_PRETTY));
8568 set_val_str (arr, 6, nmc_property_adsl_get_vpi (setting, NMC_PROPERTY_GET_PRETTY));
8569 set_val_str (arr, 7, nmc_property_adsl_get_vci (setting, NMC_PROPERTY_GET_PRETTY));
8570 g_ptr_array_add (nmc->output_data, arr);
8572 print_data (nmc); /* Print all data */
8578 setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8580 NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting);
8581 NmcOutputField *tmpl, *arr;
8584 g_return_val_if_fail (NM_IS_SETTING_BRIDGE (s_bridge), FALSE);
8586 tmpl = nmc_fields_setting_bridge;
8587 tmpl_len = sizeof (nmc_fields_setting_bridge);
8588 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_ALL,
8589 tmpl, FALSE, NULL, NULL);
8590 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8591 g_ptr_array_add (nmc->output_data, arr);
8593 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8594 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8595 set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8596 set_val_str (arr, 2, nmc_property_bridge_get_stp (setting, NMC_PROPERTY_GET_PRETTY));
8597 set_val_str (arr, 3, nmc_property_bridge_get_priority (setting, NMC_PROPERTY_GET_PRETTY));
8598 set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting, NMC_PROPERTY_GET_PRETTY));
8599 set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting, NMC_PROPERTY_GET_PRETTY));
8600 set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting, NMC_PROPERTY_GET_PRETTY));
8601 set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting, NMC_PROPERTY_GET_PRETTY));
8602 set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting, NMC_PROPERTY_GET_PRETTY));
8603 g_ptr_array_add (nmc->output_data, arr);
8605 print_data (nmc); /* Print all data */
8611 setting_bridge_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8613 NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting);
8614 NmcOutputField *tmpl, *arr;
8617 g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (s_bridge_port), FALSE);
8619 tmpl = nmc_fields_setting_bridge_port;
8620 tmpl_len = sizeof (nmc_fields_setting_bridge_port);
8621 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_PORT_ALL,
8622 tmpl, FALSE, NULL, NULL);
8623 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8624 g_ptr_array_add (nmc->output_data, arr);
8626 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8627 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8628 set_val_str (arr, 1, nmc_property_bridge_port_get_priority (setting, NMC_PROPERTY_GET_PRETTY));
8629 set_val_str (arr, 2, nmc_property_bridge_port_get_path_cost (setting, NMC_PROPERTY_GET_PRETTY));
8630 set_val_str (arr, 3, nmc_property_bridge_port_get_hairpin_mode (setting, NMC_PROPERTY_GET_PRETTY));
8631 g_ptr_array_add (nmc->output_data, arr);
8633 print_data (nmc); /* Print all data */
8639 setting_team_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8641 NMSettingTeam *s_team = NM_SETTING_TEAM (setting);
8642 NmcOutputField *tmpl, *arr;
8645 g_return_val_if_fail (NM_IS_SETTING_TEAM (s_team), FALSE);
8647 tmpl = nmc_fields_setting_team;
8648 tmpl_len = sizeof (nmc_fields_setting_team);
8649 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_ALL,
8650 tmpl, FALSE, NULL, NULL);
8651 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8652 g_ptr_array_add (nmc->output_data, arr);
8654 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8655 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8656 set_val_str (arr, 1, nmc_property_team_get_config (setting, NMC_PROPERTY_GET_PRETTY));
8657 g_ptr_array_add (nmc->output_data, arr);
8659 print_data (nmc); /* Print all data */
8665 setting_team_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8667 NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting);
8668 NmcOutputField *tmpl, *arr;
8671 g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (s_team_port), FALSE);
8673 tmpl = nmc_fields_setting_team_port;
8674 tmpl_len = sizeof (nmc_fields_setting_team_port);
8675 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_PORT_ALL,
8676 tmpl, FALSE, NULL, NULL);
8677 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8678 g_ptr_array_add (nmc->output_data, arr);
8680 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8681 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8682 set_val_str (arr, 1, nmc_property_team_port_get_config (setting, NMC_PROPERTY_GET_PRETTY));
8683 g_ptr_array_add (nmc->output_data, arr);
8685 print_data (nmc); /* Print all data */
8691 setting_dcb_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8693 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting);
8694 NmcOutputField *tmpl, *arr;
8697 g_return_val_if_fail (NM_IS_SETTING_DCB (s_dcb), FALSE);
8699 tmpl = nmc_fields_setting_dcb;
8700 tmpl_len = sizeof (nmc_fields_setting_dcb);
8701 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_DCB_ALL,
8702 tmpl, FALSE, NULL, NULL);
8703 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8704 g_ptr_array_add (nmc->output_data, arr);
8706 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8707 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8708 set_val_str (arr, 1, nmc_property_dcb_get_app_fcoe_flags (setting, NMC_PROPERTY_GET_PRETTY));
8709 set_val_str (arr, 2, nmc_property_dcb_get_app_fcoe_priority (setting, NMC_PROPERTY_GET_PRETTY));
8710 set_val_str (arr, 3, nmc_property_dcb_get_app_fcoe_mode (setting, NMC_PROPERTY_GET_PRETTY));
8711 set_val_str (arr, 4, nmc_property_dcb_get_app_iscsi_flags (setting, NMC_PROPERTY_GET_PRETTY));
8712 set_val_str (arr, 5, nmc_property_dcb_get_app_iscsi_priority (setting, NMC_PROPERTY_GET_PRETTY));
8713 set_val_str (arr, 6, nmc_property_dcb_get_app_fip_flags (setting, NMC_PROPERTY_GET_PRETTY));
8714 set_val_str (arr, 7, nmc_property_dcb_get_app_fip_priority (setting, NMC_PROPERTY_GET_PRETTY));
8715 set_val_str (arr, 8, nmc_property_dcb_get_pfc_flags (setting, NMC_PROPERTY_GET_PRETTY));
8716 set_val_str (arr, 9, nmc_property_dcb_get_pfc (setting, NMC_PROPERTY_GET_PRETTY));
8717 set_val_str (arr, 10, nmc_property_dcb_get_pg_flags (setting, NMC_PROPERTY_GET_PRETTY));
8718 set_val_str (arr, 11, nmc_property_dcb_get_pg_group_id (setting, NMC_PROPERTY_GET_PRETTY));
8719 set_val_str (arr, 12, nmc_property_dcb_get_pg_group_bandwidth (setting, NMC_PROPERTY_GET_PRETTY));
8720 set_val_str (arr, 13, nmc_property_dcb_get_pg_bandwidth (setting, NMC_PROPERTY_GET_PRETTY));
8721 set_val_str (arr, 14, nmc_property_dcb_get_pg_strict (setting, NMC_PROPERTY_GET_PRETTY));
8722 set_val_str (arr, 15, nmc_property_dcb_get_pg_traffic_class (setting, NMC_PROPERTY_GET_PRETTY));
8723 g_ptr_array_add (nmc->output_data, arr);
8725 print_data (nmc); /* Print all data */
8731 setting_tun_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8733 NMSettingTun *s_tun = NM_SETTING_TUN (setting);
8734 NmcOutputField *tmpl, *arr;
8737 g_return_val_if_fail (NM_IS_SETTING_TUN (s_tun), FALSE);
8739 tmpl = nmc_fields_setting_tun;
8740 tmpl_len = sizeof (nmc_fields_setting_tun);
8741 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TUN_ALL,
8742 tmpl, FALSE, NULL, NULL);
8743 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8744 g_ptr_array_add (nmc->output_data, arr);
8746 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8747 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8748 set_val_str (arr, 1, nmc_property_tun_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8749 set_val_str (arr, 2, nmc_property_tun_get_owner (setting, NMC_PROPERTY_GET_PRETTY));
8750 set_val_str (arr, 3, nmc_property_tun_get_group (setting, NMC_PROPERTY_GET_PRETTY));
8751 set_val_str (arr, 4, nmc_property_tun_get_pi (setting, NMC_PROPERTY_GET_PRETTY));
8752 set_val_str (arr, 5, nmc_property_tun_get_vnet_hdr (setting, NMC_PROPERTY_GET_PRETTY));
8753 set_val_str (arr, 6, nmc_property_tun_get_multi_queue (setting, NMC_PROPERTY_GET_PRETTY));
8754 g_ptr_array_add (nmc->output_data, arr);
8756 print_data (nmc); /* Print all data */
8762 setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8764 NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
8765 NmcOutputField *tmpl, *arr;
8768 g_return_val_if_fail (NM_IS_SETTING_IP_TUNNEL (s_ip_tunnel), FALSE);
8770 tmpl = nmc_fields_setting_ip_tunnel;
8771 tmpl_len = sizeof (nmc_fields_setting_ip_tunnel);
8772 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP_TUNNEL_ALL,
8773 tmpl, FALSE, NULL, NULL);
8774 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8775 g_ptr_array_add (nmc->output_data, arr);
8777 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8778 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8779 set_val_str (arr, 1, nmc_property_ip_tunnel_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8780 set_val_str (arr, 2, nmc_property_ip_tunnel_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8781 set_val_str (arr, 3, nmc_property_ip_tunnel_get_local (setting, NMC_PROPERTY_GET_PRETTY));
8782 set_val_str (arr, 4, nmc_property_ip_tunnel_get_remote (setting, NMC_PROPERTY_GET_PRETTY));
8783 set_val_str (arr, 5, nmc_property_ip_tunnel_get_ttl (setting, NMC_PROPERTY_GET_PRETTY));
8784 set_val_str (arr, 6, nmc_property_ip_tunnel_get_tos (setting, NMC_PROPERTY_GET_PRETTY));
8785 set_val_str (arr, 7, nmc_property_ip_tunnel_get_path_mtu_discovery (setting, NMC_PROPERTY_GET_PRETTY));
8786 set_val_str (arr, 8, nmc_property_ip_tunnel_get_input_key (setting, NMC_PROPERTY_GET_PRETTY));
8787 set_val_str (arr, 9, nmc_property_ip_tunnel_get_output_key (setting, NMC_PROPERTY_GET_PRETTY));
8788 set_val_str (arr, 10, nmc_property_ip_tunnel_get_encapsulation_limit (setting, NMC_PROPERTY_GET_PRETTY));
8789 set_val_str (arr, 11, nmc_property_ip_tunnel_get_flow_label (setting, NMC_PROPERTY_GET_PRETTY));
8790 set_val_str (arr, 12, nmc_property_ip_tunnel_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8791 g_ptr_array_add (nmc->output_data, arr);
8793 print_data (nmc); /* Print all data */
8799 setting_macvlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8801 NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
8802 NmcOutputField *tmpl, *arr;
8805 g_return_val_if_fail (NM_IS_SETTING_MACVLAN (s_macvlan), FALSE);
8807 tmpl = nmc_fields_setting_macvlan;
8808 tmpl_len = sizeof (nmc_fields_setting_macvlan);
8809 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_MACVLAN_ALL,
8810 tmpl, FALSE, NULL, NULL);
8811 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8812 g_ptr_array_add (nmc->output_data, arr);
8814 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8815 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8816 set_val_str (arr, 1, nmc_property_macvlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8817 set_val_str (arr, 2, nmc_property_macvlan_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8818 set_val_str (arr, 3, nmc_property_macvlan_get_promiscuous (setting, NMC_PROPERTY_GET_PRETTY));
8819 set_val_str (arr, 4, nmc_property_macvlan_get_tap (setting, NMC_PROPERTY_GET_PRETTY));
8820 g_ptr_array_add (nmc->output_data, arr);
8822 print_data (nmc); /* Print all data */
8828 setting_vxlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8830 NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting);
8831 NmcOutputField *tmpl, *arr;
8834 g_return_val_if_fail (NM_IS_SETTING_VXLAN (s_vxlan), FALSE);
8836 tmpl = nmc_fields_setting_vxlan;
8837 tmpl_len = sizeof (nmc_fields_setting_vxlan);
8838 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VXLAN_ALL,
8839 tmpl, FALSE, NULL, NULL);
8840 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8841 g_ptr_array_add (nmc->output_data, arr);
8843 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8844 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8845 set_val_str (arr, 1, nmc_property_vxlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8846 set_val_str (arr, 2, nmc_property_vxlan_get_id (setting, NMC_PROPERTY_GET_PRETTY));
8847 set_val_str (arr, 3, nmc_property_vxlan_get_local (setting, NMC_PROPERTY_GET_PRETTY));
8848 set_val_str (arr, 4, nmc_property_vxlan_get_remote (setting, NMC_PROPERTY_GET_PRETTY));
8849 set_val_str (arr, 5, nmc_property_vxlan_get_source_port_min (setting, NMC_PROPERTY_GET_PRETTY));
8850 set_val_str (arr, 6, nmc_property_vxlan_get_source_port_max (setting, NMC_PROPERTY_GET_PRETTY));
8851 set_val_str (arr, 7, nmc_property_vxlan_get_destination_port (setting, NMC_PROPERTY_GET_PRETTY));
8852 set_val_str (arr, 8, nmc_property_vxlan_get_tos (setting, NMC_PROPERTY_GET_PRETTY));
8853 set_val_str (arr, 9, nmc_property_vxlan_get_ttl (setting, NMC_PROPERTY_GET_PRETTY));
8854 set_val_str (arr, 10, nmc_property_vxlan_get_ageing (setting, NMC_PROPERTY_GET_PRETTY));
8855 set_val_str (arr, 11, nmc_property_vxlan_get_limit (setting, NMC_PROPERTY_GET_PRETTY));
8856 set_val_str (arr, 12, nmc_property_vxlan_get_learning (setting, NMC_PROPERTY_GET_PRETTY));
8857 set_val_str (arr, 13, nmc_property_vxlan_get_proxy (setting, NMC_PROPERTY_GET_PRETTY));
8858 set_val_str (arr, 14, nmc_property_vxlan_get_rsc (setting, NMC_PROPERTY_GET_PRETTY));
8859 set_val_str (arr, 15, nmc_property_vxlan_get_l2_miss (setting, NMC_PROPERTY_GET_PRETTY));
8860 set_val_str (arr, 16, nmc_property_vxlan_get_l3_miss (setting, NMC_PROPERTY_GET_PRETTY));
8861 g_ptr_array_add (nmc->output_data, arr);
8863 print_data (nmc); /* Print all data */
8870 gboolean (*func) (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets);
8873 static const SettingDetails detail_printers[] = {
8874 { NM_SETTING_CONNECTION_SETTING_NAME, setting_connection_details },
8875 { NM_SETTING_WIRED_SETTING_NAME, setting_wired_details },
8876 { NM_SETTING_802_1X_SETTING_NAME, setting_802_1X_details },
8877 { NM_SETTING_WIRELESS_SETTING_NAME, setting_wireless_details },
8878 { NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, setting_wireless_security_details },
8879 { NM_SETTING_IP4_CONFIG_SETTING_NAME, setting_ip4_config_details },
8880 { NM_SETTING_IP6_CONFIG_SETTING_NAME, setting_ip6_config_details },
8881 { NM_SETTING_SERIAL_SETTING_NAME, setting_serial_details },
8882 { NM_SETTING_PPP_SETTING_NAME, setting_ppp_details },
8883 { NM_SETTING_PPPOE_SETTING_NAME, setting_pppoe_details },
8884 { NM_SETTING_GSM_SETTING_NAME, setting_gsm_details },
8885 { NM_SETTING_CDMA_SETTING_NAME, setting_cdma_details },
8886 { NM_SETTING_BLUETOOTH_SETTING_NAME, setting_bluetooth_details },
8887 { NM_SETTING_OLPC_MESH_SETTING_NAME, setting_olpc_mesh_details },
8888 { NM_SETTING_VPN_SETTING_NAME, setting_vpn_details },
8889 { NM_SETTING_WIMAX_SETTING_NAME, setting_wimax_details },
8890 { NM_SETTING_INFINIBAND_SETTING_NAME, setting_infiniband_details },
8891 { NM_SETTING_BOND_SETTING_NAME, setting_bond_details },
8892 { NM_SETTING_VLAN_SETTING_NAME, setting_vlan_details },
8893 { NM_SETTING_ADSL_SETTING_NAME, setting_adsl_details },
8894 { NM_SETTING_BRIDGE_SETTING_NAME, setting_bridge_details },
8895 { NM_SETTING_BRIDGE_PORT_SETTING_NAME, setting_bridge_port_details },
8896 { NM_SETTING_TEAM_SETTING_NAME, setting_team_details },
8897 { NM_SETTING_TEAM_PORT_SETTING_NAME, setting_team_port_details },
8898 { NM_SETTING_DCB_SETTING_NAME, setting_dcb_details },
8899 { NM_SETTING_TUN_SETTING_NAME, setting_tun_details },
8900 { NM_SETTING_IP_TUNNEL_SETTING_NAME, setting_ip_tunnel_details },
8901 { NM_SETTING_MACVLAN_SETTING_NAME, setting_macvlan_details },
8902 { NM_SETTING_VXLAN_SETTING_NAME, setting_vxlan_details },
8907 setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8909 const SettingDetails *iter = &detail_printers[0];
8911 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
8913 while (iter->sname) {
8914 if (nm_setting_lookup_type (iter->sname) == G_OBJECT_TYPE (setting))
8915 return iter->func (setting, nmc, one_prop, secrets);
8919 g_assert_not_reached ();