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;
1153 gs_free char *tmp_value = NULL;
1156 nm_setting_bond_get_option (s_bond, i, &key, &value);
1158 if (nm_streq0 (key, NM_SETTING_BOND_OPTION_ARP_IP_TARGET)) {
1159 value = tmp_value = g_strdup (value);
1160 for (p = tmp_value; p && *p; p++) {
1166 g_string_append_printf (bond_options_s, "%s=%s,", key, value);
1168 g_string_truncate (bond_options_s, bond_options_s->len-1); /* chop off trailing ',' */
1170 return g_string_free (bond_options_s, FALSE);
1173 /* --- NM_SETTING_BRIDGE_SETTING_NAME property get functions --- */
1174 DEFINE_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS)
1175 DEFINE_GETTER (nmc_property_bridge_get_stp, NM_SETTING_BRIDGE_STP)
1176 DEFINE_GETTER (nmc_property_bridge_get_priority, NM_SETTING_BRIDGE_PRIORITY)
1177 DEFINE_GETTER (nmc_property_bridge_get_forward_delay, NM_SETTING_BRIDGE_FORWARD_DELAY)
1178 DEFINE_GETTER (nmc_property_bridge_get_hello_time, NM_SETTING_BRIDGE_HELLO_TIME)
1179 DEFINE_GETTER (nmc_property_bridge_get_max_age, NM_SETTING_BRIDGE_MAX_AGE)
1180 DEFINE_GETTER (nmc_property_bridge_get_ageing_time, NM_SETTING_BRIDGE_AGEING_TIME)
1181 DEFINE_GETTER (nmc_property_bridge_get_multicast_snooping, NM_SETTING_BRIDGE_MULTICAST_SNOOPING)
1183 /* --- NM_SETTING_BRIDGE_PORT_SETTING_NAME property get functions --- */
1184 DEFINE_GETTER (nmc_property_bridge_port_get_priority, NM_SETTING_BRIDGE_PORT_PRIORITY)
1185 DEFINE_GETTER (nmc_property_bridge_port_get_path_cost, NM_SETTING_BRIDGE_PORT_PATH_COST)
1186 DEFINE_GETTER (nmc_property_bridge_port_get_hairpin_mode, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE)
1188 /* --- NM_SETTING_TEAM_SETTING_NAME property get functions --- */
1189 DEFINE_GETTER (nmc_property_team_get_config, NM_SETTING_TEAM_CONFIG)
1191 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property get functions --- */
1192 DEFINE_GETTER (nmc_property_team_port_get_config, NM_SETTING_TEAM_PORT_CONFIG)
1194 /* --- NM_SETTING_CDMA_SETTING_NAME property get functions --- */
1195 DEFINE_GETTER (nmc_property_cdma_get_number, NM_SETTING_CDMA_NUMBER)
1196 DEFINE_GETTER (nmc_property_cdma_get_username, NM_SETTING_CDMA_USERNAME)
1197 DEFINE_GETTER (nmc_property_cdma_get_password, NM_SETTING_CDMA_PASSWORD)
1199 DEFINE_SECRET_FLAGS_GETTER (nmc_property_cdma_get_password_flags, NM_SETTING_CDMA_PASSWORD_FLAGS)
1201 /* --- NM_SETTING_CONNECTION_SETTING_NAME property get functions --- */
1202 DEFINE_GETTER (nmc_property_connection_get_id, NM_SETTING_CONNECTION_ID)
1203 DEFINE_GETTER (nmc_property_connection_get_uuid, NM_SETTING_CONNECTION_UUID)
1204 DEFINE_GETTER (nmc_property_connection_get_interface_name, NM_SETTING_CONNECTION_INTERFACE_NAME)
1205 DEFINE_GETTER (nmc_property_connection_get_type, NM_SETTING_CONNECTION_TYPE)
1206 DEFINE_GETTER (nmc_property_connection_get_autoconnect, NM_SETTING_CONNECTION_AUTOCONNECT)
1207 DEFINE_GETTER (nmc_property_connection_get_autoconnect_priority, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY)
1208 DEFINE_GETTER (nmc_property_connection_get_timestamp, NM_SETTING_CONNECTION_TIMESTAMP)
1209 DEFINE_GETTER (nmc_property_connection_get_read_only, NM_SETTING_CONNECTION_READ_ONLY)
1212 nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType get_type)
1214 NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1215 GString *perm = NULL;
1216 const char *perm_item;
1217 const char *perm_type;
1220 perm = g_string_new (NULL);
1221 for (i = 0; i < nm_setting_connection_get_num_permissions (s_con); i++) {
1222 if (nm_setting_connection_get_permission (s_con, i, &perm_type, &perm_item, NULL))
1223 g_string_append_printf (perm, "%s:%s,", perm_type, perm_item);
1226 g_string_truncate (perm, perm->len-1); /* remove trailing , */
1228 return g_string_free (perm, FALSE);
1231 DEFINE_GETTER (nmc_property_connection_get_zone, NM_SETTING_CONNECTION_ZONE)
1232 DEFINE_GETTER (nmc_property_connection_get_master, NM_SETTING_CONNECTION_MASTER)
1233 DEFINE_GETTER (nmc_property_connection_get_slave_type, NM_SETTING_CONNECTION_SLAVE_TYPE)
1236 nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyGetType get_type)
1238 NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1239 return autoconnect_slaves_to_string (nm_setting_connection_get_autoconnect_slaves (s_con), get_type);
1242 DEFINE_GETTER (nmc_property_connection_get_secondaries, NM_SETTING_CONNECTION_SECONDARIES)
1243 DEFINE_GETTER (nmc_property_connection_get_gateway_ping_timeout, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT)
1245 /* --- NM_SETTING_DCB_SETTING_NAME property get functions --- */
1247 dcb_flags_to_string (NMSettingDcbFlags flags)
1252 return g_strdup (_("0 (disabled)"));
1254 flag_str = g_string_new (NULL);
1255 g_string_printf (flag_str, "%d (", flags);
1257 if (flags & NM_SETTING_DCB_FLAG_ENABLE)
1258 g_string_append (flag_str, _("enabled, "));
1259 if (flags & NM_SETTING_DCB_FLAG_ADVERTISE)
1260 g_string_append (flag_str, _("advertise, "));
1261 if (flags & NM_SETTING_DCB_FLAG_WILLING)
1262 g_string_append (flag_str, _("willing, "));
1264 if (flag_str->str[flag_str->len-1] == '(')
1265 g_string_append (flag_str, _("unknown"));
1267 g_string_truncate (flag_str, flag_str->len-2); /* chop off trailing ', ' */
1269 g_string_append_c (flag_str, ')');
1271 return g_string_free (flag_str, FALSE);
1274 #define DEFINE_DCB_FLAGS_GETTER(func_name, property_name) \
1276 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1279 GValue val = G_VALUE_INIT; \
1280 g_value_init (&val, G_TYPE_UINT); \
1281 g_object_get_property (G_OBJECT (setting), property_name, &val); \
1282 v = g_value_get_uint (&val); \
1283 g_value_unset (&val); \
1284 return dcb_flags_to_string (v); \
1288 dcb_app_priority_to_string (gint priority)
1290 return (priority == -1) ? g_strdup (_("-1 (unset)")) : g_strdup_printf ("%d", priority);
1293 #define DEFINE_DCB_APP_PRIORITY_GETTER(func_name, property_name) \
1295 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1298 GValue val = G_VALUE_INIT; \
1299 g_value_init (&val, G_TYPE_INT); \
1300 g_object_get_property (G_OBJECT (setting), property_name, &val); \
1301 v = g_value_get_int (&val); \
1302 g_value_unset (&val); \
1303 return dcb_app_priority_to_string (v); \
1306 #define DEFINE_DCB_BOOL_GETTER(func_name, getter_func_name) \
1308 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1310 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1314 str = g_string_new (NULL); \
1315 for (i = 0; i < 8; i++) { \
1316 if (getter_func_name (s_dcb, i)) \
1317 g_string_append_c (str, '1'); \
1319 g_string_append_c (str, '0'); \
1322 g_string_append_c (str, ','); \
1325 return g_string_free (str, FALSE); \
1328 #define DEFINE_DCB_UINT_GETTER(func_name, getter_func_name) \
1330 func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1332 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1336 str = g_string_new (NULL); \
1337 for (i = 0; i < 8; i++) { \
1338 g_string_append_printf (str, "%u", getter_func_name (s_dcb, i)); \
1340 g_string_append_c (str, ','); \
1343 return g_string_free (str, FALSE); \
1346 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS)
1347 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fcoe_priority, NM_SETTING_DCB_APP_FCOE_PRIORITY)
1348 DEFINE_GETTER (nmc_property_dcb_get_app_fcoe_mode, NM_SETTING_DCB_APP_FCOE_MODE)
1349 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS)
1350 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_iscsi_priority, NM_SETTING_DCB_APP_ISCSI_PRIORITY)
1351 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS)
1352 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fip_priority, NM_SETTING_DCB_APP_FIP_PRIORITY)
1354 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS)
1355 DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pfc, nm_setting_dcb_get_priority_flow_control)
1357 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pg_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS)
1358 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_id, nm_setting_dcb_get_priority_group_id)
1359 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_bandwidth, nm_setting_dcb_get_priority_group_bandwidth)
1360 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_bandwidth, nm_setting_dcb_get_priority_bandwidth)
1361 DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pg_strict, nm_setting_dcb_get_priority_strict_bandwidth)
1362 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_traffic_class, nm_setting_dcb_get_priority_traffic_class)
1364 /* --- NM_SETTING_GSM_SETTING_NAME property get functions --- */
1365 DEFINE_GETTER (nmc_property_gsm_get_number, NM_SETTING_GSM_NUMBER)
1366 DEFINE_GETTER (nmc_property_gsm_get_username, NM_SETTING_GSM_USERNAME)
1367 DEFINE_GETTER (nmc_property_gsm_get_password, NM_SETTING_GSM_PASSWORD)
1368 DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_password_flags, NM_SETTING_GSM_PASSWORD_FLAGS)
1369 DEFINE_GETTER (nmc_property_gsm_get_apn, NM_SETTING_GSM_APN)
1370 DEFINE_GETTER (nmc_property_gsm_get_network_id, NM_SETTING_GSM_NETWORK_ID)
1371 DEFINE_GETTER (nmc_property_gsm_get_pin, NM_SETTING_GSM_PIN)
1372 DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_pin_flags, NM_SETTING_GSM_PIN_FLAGS)
1373 DEFINE_GETTER (nmc_property_gsm_get_home_only, NM_SETTING_GSM_HOME_ONLY)
1374 DEFINE_GETTER (nmc_property_gsm_get_device_id, NM_SETTING_GSM_DEVICE_ID)
1375 DEFINE_GETTER (nmc_property_gsm_get_sim_id, NM_SETTING_GSM_SIM_ID)
1376 DEFINE_GETTER (nmc_property_gsm_get_sim_operator_id, NM_SETTING_GSM_SIM_OPERATOR_ID)
1378 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property get functions --- */
1379 DEFINE_GETTER (nmc_property_ib_get_mac_address, NM_SETTING_INFINIBAND_MAC_ADDRESS)
1380 DEFINE_GETTER (nmc_property_ib_get_transport_mode, NM_SETTING_INFINIBAND_TRANSPORT_MODE)
1382 /* --- NM_SETTING_TUN_SETTING_NAME property get functions --- */
1383 DEFINE_GETTER (nmc_property_tun_get_owner, NM_SETTING_TUN_OWNER);
1384 DEFINE_GETTER (nmc_property_tun_get_group, NM_SETTING_TUN_GROUP);
1385 DEFINE_GETTER (nmc_property_tun_get_pi, NM_SETTING_TUN_PI);
1386 DEFINE_GETTER (nmc_property_tun_get_vnet_hdr, NM_SETTING_TUN_VNET_HDR);
1387 DEFINE_GETTER (nmc_property_tun_get_multi_queue, NM_SETTING_TUN_MULTI_QUEUE);
1389 /* --- NM_SETTING_IP_TUNNEL_SETTING_NAME property get functions --- */
1390 DEFINE_GETTER (nmc_property_ip_tunnel_get_parent, NM_SETTING_IP_TUNNEL_PARENT);
1391 DEFINE_GETTER (nmc_property_ip_tunnel_get_local, NM_SETTING_IP_TUNNEL_LOCAL);
1392 DEFINE_GETTER (nmc_property_ip_tunnel_get_remote, NM_SETTING_IP_TUNNEL_REMOTE);
1393 DEFINE_GETTER (nmc_property_ip_tunnel_get_ttl, NM_SETTING_IP_TUNNEL_TTL);
1394 DEFINE_GETTER (nmc_property_ip_tunnel_get_tos, NM_SETTING_IP_TUNNEL_TOS);
1395 DEFINE_GETTER (nmc_property_ip_tunnel_get_path_mtu_discovery, NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY);
1396 DEFINE_GETTER (nmc_property_ip_tunnel_get_input_key, NM_SETTING_IP_TUNNEL_INPUT_KEY);
1397 DEFINE_GETTER (nmc_property_ip_tunnel_get_output_key, NM_SETTING_IP_TUNNEL_OUTPUT_KEY);
1398 DEFINE_GETTER (nmc_property_ip_tunnel_get_encapsulation_limit, NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT);
1399 DEFINE_GETTER (nmc_property_ip_tunnel_get_flow_label, NM_SETTING_IP_TUNNEL_FLOW_LABEL);
1400 DEFINE_GETTER (nmc_property_ip_tunnel_get_mtu, NM_SETTING_IP_TUNNEL_MTU);
1402 static const char **
1403 nmc_property_ip_tunnel_allowed_mode (NMSetting *setting, const char *prop)
1405 static const char **words = NULL;
1408 words = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1409 NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1415 nmc_property_ib_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1417 NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1420 mtu = nm_setting_infiniband_get_mtu (s_infiniband);
1422 return g_strdup (_("auto"));
1424 return g_strdup_printf ("%d", mtu);
1428 nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type)
1430 NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1433 p_key = nm_setting_infiniband_get_p_key (s_infiniband);
1435 return g_strdup (_("default"));
1437 return g_strdup_printf ("0x%04x", p_key);
1440 DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
1442 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property get functions --- */
1443 DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP_CONFIG_METHOD)
1444 DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP_CONFIG_DNS)
1445 DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH)
1446 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))
1449 nmc_property_ip_get_addresses (NMSetting *setting, NmcPropertyGetType get_type)
1451 NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1453 guint32 num_addresses, i;
1456 printable = g_string_new (NULL);
1458 num_addresses = nm_setting_ip_config_get_num_addresses (s_ip);
1459 for (i = 0; i < num_addresses; i++) {
1460 addr = nm_setting_ip_config_get_address (s_ip, i);
1462 if (printable->len > 0)
1463 g_string_append (printable, ", ");
1465 g_string_append_printf (printable, "%s/%u",
1466 nm_ip_address_get_address (addr),
1467 nm_ip_address_get_prefix (addr));
1470 return g_string_free (printable, FALSE);
1474 nmc_property_ipvx_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1476 NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1478 guint32 num_routes, i;
1481 printable = g_string_new (NULL);
1483 num_routes = nm_setting_ip_config_get_num_routes (s_ip);
1484 for (i = 0; i < num_routes; i++) {
1485 route = nm_setting_ip_config_get_route (s_ip, i);
1487 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1488 if (printable->len > 0)
1489 g_string_append (printable, ", ");
1491 g_string_append_printf (printable, "%s/%u",
1492 nm_ip_route_get_dest (route),
1493 nm_ip_route_get_prefix (route));
1495 if (nm_ip_route_get_next_hop (route))
1496 g_string_append_printf (printable, " %s", nm_ip_route_get_next_hop (route));
1497 if (nm_ip_route_get_metric (route) != -1)
1498 g_string_append_printf (printable, " %u", (guint32) nm_ip_route_get_metric (route));
1500 if (printable->len > 0)
1501 g_string_append (printable, "; ");
1503 g_string_append (printable, "{ ");
1505 g_string_append_printf (printable, "ip = %s/%u",
1506 nm_ip_route_get_dest (route),
1507 nm_ip_route_get_prefix (route));
1509 if (nm_ip_route_get_next_hop (route)) {
1510 g_string_append_printf (printable, ", nh = %s",
1511 nm_ip_route_get_next_hop (route));
1514 if (nm_ip_route_get_metric (route) != -1)
1515 g_string_append_printf (printable, ", mt = %u", (guint32) nm_ip_route_get_metric (route));
1517 g_string_append (printable, " }");
1521 return g_string_free (printable, FALSE);
1525 nmc_property_ipv4_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1527 return nmc_property_ipvx_get_routes (setting, get_type);
1530 DEFINE_GETTER (nmc_property_ipv4_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY)
1531 DEFINE_GETTER (nmc_property_ipv4_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC)
1532 DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
1533 DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
1534 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)
1535 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_timeout, NM_SETTING_IP_CONFIG_DHCP_TIMEOUT)
1536 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
1537 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
1538 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_fqdn, NM_SETTING_IP4_CONFIG_DHCP_FQDN)
1539 DEFINE_GETTER (nmc_property_ipv4_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
1540 DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL)
1543 nmc_property_ipv4_get_dad_timeout (NMSetting *setting, NmcPropertyGetType get_type)
1545 NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1548 dad_timeout = nm_setting_ip_config_get_dad_timeout (s_ip);
1549 if (get_type == NMC_PROPERTY_GET_PARSABLE)
1550 return g_strdup_printf ("%d", dad_timeout);
1552 switch (dad_timeout) {
1554 return g_strdup_printf (_("%d (default)"), dad_timeout);
1556 return g_strdup_printf (_("%d (off)"), dad_timeout);
1558 return g_strdup_printf ("%d", dad_timeout);
1562 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property get functions --- */
1563 DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP_CONFIG_METHOD)
1564 DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP_CONFIG_DNS)
1565 DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH)
1566 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))
1569 nmc_property_ipv6_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1571 return nmc_property_ipvx_get_routes (setting, get_type);
1574 DEFINE_GETTER (nmc_property_ipv6_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY)
1575 DEFINE_GETTER (nmc_property_ipv6_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC)
1576 DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
1577 DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
1578 DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
1579 DEFINE_GETTER (nmc_property_ipv6_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL)
1580 DEFINE_GETTER (nmc_property_ipv6_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
1581 DEFINE_GETTER (nmc_property_ipv6_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
1584 nmc_property_ipv6_get_ip6_privacy (NMSetting *setting, NmcPropertyGetType get_type)
1586 NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
1587 return ip6_privacy_to_string (nm_setting_ip6_config_get_ip6_privacy (s_ip6), get_type);
1590 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property get functions --- */
1591 DEFINE_GETTER (nmc_property_olpc_get_channel, NM_SETTING_OLPC_MESH_CHANNEL)
1592 DEFINE_GETTER (nmc_property_olpc_get_anycast_address, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)
1595 nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1597 NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
1599 char *ssid_str = NULL;
1601 ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
1603 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1604 g_bytes_get_size (ssid));
1610 /* --- NM_SETTING_PPP_SETTING_NAME property get functions --- */
1611 DEFINE_GETTER (nmc_property_ppp_get_noauth, NM_SETTING_PPP_NOAUTH)
1612 DEFINE_GETTER (nmc_property_ppp_get_refuse_eap, NM_SETTING_PPP_REFUSE_EAP)
1613 DEFINE_GETTER (nmc_property_ppp_get_refuse_pap, NM_SETTING_PPP_REFUSE_PAP)
1614 DEFINE_GETTER (nmc_property_ppp_get_refuse_chap, NM_SETTING_PPP_REFUSE_CHAP)
1615 DEFINE_GETTER (nmc_property_ppp_get_refuse_mschap, NM_SETTING_PPP_REFUSE_MSCHAP)
1616 DEFINE_GETTER (nmc_property_ppp_get_refuse_mschapv2, NM_SETTING_PPP_REFUSE_MSCHAPV2)
1617 DEFINE_GETTER (nmc_property_ppp_get_nobsdcomp, NM_SETTING_PPP_NOBSDCOMP)
1618 DEFINE_GETTER (nmc_property_ppp_get_nodeflate, NM_SETTING_PPP_NODEFLATE)
1619 DEFINE_GETTER (nmc_property_ppp_get_no_vj_comp, NM_SETTING_PPP_NO_VJ_COMP)
1620 DEFINE_GETTER (nmc_property_ppp_get_require_mppe, NM_SETTING_PPP_REQUIRE_MPPE)
1621 DEFINE_GETTER (nmc_property_ppp_get_require_mppe_128, NM_SETTING_PPP_REQUIRE_MPPE_128)
1622 DEFINE_GETTER (nmc_property_ppp_get_mppe_stateful, NM_SETTING_PPP_MPPE_STATEFUL)
1623 DEFINE_GETTER (nmc_property_ppp_get_crtscts, NM_SETTING_PPP_CRTSCTS)
1624 DEFINE_GETTER (nmc_property_ppp_get_baud, NM_SETTING_PPP_BAUD)
1625 DEFINE_GETTER (nmc_property_ppp_get_mru, NM_SETTING_PPP_MRU)
1626 DEFINE_GETTER (nmc_property_ppp_get_mtu, NM_SETTING_PPP_MTU)
1627 DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_failure, NM_SETTING_PPP_LCP_ECHO_FAILURE)
1628 DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_interval, NM_SETTING_PPP_LCP_ECHO_INTERVAL)
1630 /* --- NM_SETTING_PPPOE_SETTING_NAME property get functions --- */
1631 DEFINE_GETTER (nmc_property_pppoe_get_service, NM_SETTING_PPPOE_SERVICE)
1632 DEFINE_GETTER (nmc_property_pppoe_get_username, NM_SETTING_PPPOE_USERNAME)
1633 DEFINE_GETTER (nmc_property_pppoe_get_password, NM_SETTING_PPPOE_PASSWORD)
1634 DEFINE_SECRET_FLAGS_GETTER (nmc_property_pppoe_get_password_flags, NM_SETTING_PPPOE_PASSWORD_FLAGS)
1636 /* --- NM_SETTING_SERIAL_SETTING_NAME property get functions --- */
1637 DEFINE_GETTER (nmc_property_serial_get_baud, NM_SETTING_SERIAL_BAUD)
1638 DEFINE_GETTER (nmc_property_serial_get_bits, NM_SETTING_SERIAL_BITS)
1639 DEFINE_GETTER (nmc_property_serial_get_stopbits, NM_SETTING_SERIAL_STOPBITS)
1640 DEFINE_GETTER (nmc_property_serial_get_send_delay, NM_SETTING_SERIAL_SEND_DELAY)
1642 /* --- NM_SETTING_VLAN_SETTING_NAME property get functions --- */
1643 DEFINE_GETTER (nmc_property_vlan_get_parent, NM_SETTING_VLAN_PARENT)
1644 DEFINE_GETTER (nmc_property_vlan_get_id, NM_SETTING_VLAN_ID)
1648 nmc_property_vlan_get_flags (NMSetting *setting, NmcPropertyGetType get_type)
1650 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1651 return vlan_flags_to_string (nm_setting_vlan_get_flags (s_vlan));
1655 nmc_property_vlan_get_ingress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1657 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1658 return vlan_priorities_to_string (s_vlan, NM_VLAN_INGRESS_MAP);
1662 nmc_property_vlan_get_egress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1664 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1665 return vlan_priorities_to_string (s_vlan, NM_VLAN_EGRESS_MAP);
1668 /* --- NM_SETTING_VPN_SETTING_NAME property get functions --- */
1669 DEFINE_GETTER (nmc_property_vpn_get_service_type, NM_SETTING_VPN_SERVICE_TYPE)
1670 DEFINE_GETTER (nmc_property_vpn_get_user_name, NM_SETTING_VPN_USER_NAME)
1673 nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type)
1675 NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1676 GString *data_item_str;
1678 data_item_str = g_string_new (NULL);
1679 nm_setting_vpn_foreach_data_item (s_vpn, &vpn_data_item, data_item_str);
1681 return g_string_free (data_item_str, FALSE);
1685 nmc_property_vpn_get_secrets (NMSetting *setting, NmcPropertyGetType get_type)
1687 NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1688 GString *secret_str;
1690 secret_str = g_string_new (NULL);
1691 nm_setting_vpn_foreach_secret (s_vpn, &vpn_data_item, secret_str);
1693 return g_string_free (secret_str, FALSE);
1696 DEFINE_GETTER (nmc_property_vpn_get_persistent, NM_SETTING_VPN_PERSISTENT)
1697 DEFINE_GETTER (nmc_property_vpn_get_timeout, NM_SETTING_VPN_TIMEOUT)
1699 /* --- NM_SETTING_WIMAX_SETTING_NAME property get functions --- */
1700 DEFINE_GETTER (nmc_property_wimax_get_network_name, NM_SETTING_WIMAX_NETWORK_NAME)
1701 DEFINE_GETTER (nmc_property_wimax_get_mac_address, NM_SETTING_WIMAX_MAC_ADDRESS)
1703 /* --- NM_SETTING_WIRED_SETTING_NAME property get functions --- */
1704 DEFINE_GETTER (nmc_property_wired_get_port, NM_SETTING_WIRED_PORT)
1705 DEFINE_GETTER (nmc_property_wired_get_speed, NM_SETTING_WIRED_SPEED)
1706 DEFINE_GETTER (nmc_property_wired_get_duplex, NM_SETTING_WIRED_DUPLEX)
1707 DEFINE_GETTER (nmc_property_wired_get_auto_negotiate, NM_SETTING_WIRED_AUTO_NEGOTIATE)
1708 DEFINE_GETTER (nmc_property_wired_get_mac_address, NM_SETTING_WIRED_MAC_ADDRESS)
1709 DEFINE_GETTER (nmc_property_wired_get_cloned_mac_address, NM_SETTING_WIRED_CLONED_MAC_ADDRESS)
1710 DEFINE_GETTER (nmc_property_wired_get_mac_address_blacklist, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST)
1711 DEFINE_GETTER (nmc_property_wired_get_s390_subchannels, NM_SETTING_WIRED_S390_SUBCHANNELS)
1712 DEFINE_GETTER (nmc_property_wired_get_s390_nettype, NM_SETTING_WIRED_S390_NETTYPE)
1713 DEFINE_GETTER (nmc_property_wired_get_s390_options, NM_SETTING_WIRED_S390_OPTIONS)
1714 DEFINE_GETTER (nmc_property_wired_get_wake_on_lan_password, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD)
1717 nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1719 NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1722 mtu = nm_setting_wired_get_mtu (s_wired);
1724 return g_strdup (_("auto"));
1726 return g_strdup_printf ("%d", mtu);
1730 nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type)
1732 NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1733 NMSettingWiredWakeOnLan wol;
1736 wol = nm_setting_wired_get_wake_on_lan (s_wired);
1737 tmp = nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (), wol);
1738 if (get_type == NMC_PROPERTY_GET_PARSABLE)
1739 str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "none");
1741 str = g_strdup_printf ("%d (%s)", wol, tmp && *tmp ? tmp : "none");
1747 nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
1748 const char *val, GError **error)
1750 NMSettingWiredWakeOnLan wol;
1751 gs_free char *err_token = NULL;
1755 if (nmc_string_to_int_base (val, 0, TRUE, 0,
1756 NM_SETTING_WIRED_WAKE_ON_LAN_ALL
1757 | NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS,
1759 wol = (NMSettingWiredWakeOnLan) t;
1761 ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val,
1762 (int *) &wol, &err_token);
1765 if ( g_ascii_strcasecmp (err_token, "none") == 0
1766 || g_ascii_strcasecmp (err_token, "disable") == 0
1767 || g_ascii_strcasecmp (err_token, "disabled") == 0)
1768 wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
1770 g_set_error (error, 1, 0, _("invalid option '%s', use a combination of [%s] or 'ignore', 'default' or 'none'"),
1772 nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (),
1773 NM_SETTING_WIRED_WAKE_ON_LAN_ALL));
1779 if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
1780 && !nm_utils_is_power_of_two (wol)) {
1781 g_set_error_literal (error, 1, 0, _("'default' and 'ignore' are incompatible with other flags"));
1785 g_object_set (setting, prop, (guint) wol, NULL);
1790 nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1792 NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
1793 NMIPTunnelMode mode;
1795 mode = nm_setting_ip_tunnel_get_mode (s_ip_tunnel);
1796 return nm_utils_enum_to_str (nm_ip_tunnel_mode_get_type (), mode);
1800 nmc_property_ip_tunnel_set_mode (NMSetting *setting, const char *prop,
1801 const char *val, GError **error)
1803 NMIPTunnelMode mode;
1806 ret = nm_utils_enum_from_str (nm_ip_tunnel_mode_get_type(), val,
1807 (int *) &mode, NULL);
1810 gs_free const char **values = NULL;
1811 gs_free char *values_str = NULL;
1813 values = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1814 NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1816 values_str = g_strjoinv (",", (char **) values);
1817 g_set_error (error, 1, 0, _("invalid mode '%s', use one of %s"),
1823 g_object_set (setting, prop, mode, NULL);
1827 /* --- NM_SETTING_WIRELESS_SETTING_NAME property get functions --- */
1828 DEFINE_GETTER (nmc_property_wireless_get_mode, NM_SETTING_WIRELESS_MODE)
1829 DEFINE_GETTER (nmc_property_wireless_get_band, NM_SETTING_WIRELESS_BAND)
1830 DEFINE_GETTER (nmc_property_wireless_get_channel, NM_SETTING_WIRELESS_CHANNEL)
1831 DEFINE_GETTER (nmc_property_wireless_get_bssid, NM_SETTING_WIRELESS_BSSID)
1832 DEFINE_GETTER (nmc_property_wireless_get_rate, NM_SETTING_WIRELESS_RATE)
1833 DEFINE_GETTER (nmc_property_wireless_get_tx_power, NM_SETTING_WIRELESS_TX_POWER)
1834 DEFINE_GETTER (nmc_property_wireless_get_mac_address, NM_SETTING_WIRELESS_MAC_ADDRESS)
1835 DEFINE_GETTER (nmc_property_wireless_get_cloned_mac_address, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS)
1836 DEFINE_GETTER (nmc_property_wireless_get_mac_address_blacklist, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST)
1837 DEFINE_GETTER (nmc_property_wireless_get_seen_bssids, NM_SETTING_WIRELESS_SEEN_BSSIDS)
1838 DEFINE_GETTER (nmc_property_wireless_get_hidden, NM_SETTING_WIRELESS_HIDDEN)
1841 nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1843 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1845 char *ssid_str = NULL;
1847 ssid = nm_setting_wireless_get_ssid (s_wireless);
1849 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1850 g_bytes_get_size (ssid));
1857 nmc_property_wireless_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1859 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1862 mtu = nm_setting_wireless_get_mtu (s_wireless);
1864 return g_strdup (_("auto"));
1866 return g_strdup_printf ("%d", mtu);
1870 nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_type)
1872 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1873 NMSettingWirelessPowersave powersave;
1874 gs_free char *str = NULL;
1877 powersave = nm_setting_wireless_get_powersave (s_wireless);
1878 str = nm_utils_enum_to_str (nm_setting_wireless_powersave_get_type (), powersave);
1880 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1885 return g_strdup_printf ("%s (%u)", str, powersave);
1889 nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcPropertyGetType get_type)
1891 NMSettingWireless *s_wifi = NM_SETTING_WIRELESS (setting);
1892 NMSettingMacRandomization randomization = nm_setting_wireless_get_mac_address_randomization (s_wifi);
1894 if (randomization == NM_SETTING_MAC_RANDOMIZATION_DEFAULT)
1895 return g_strdup (_("default"));
1896 else if (randomization == NM_SETTING_MAC_RANDOMIZATION_NEVER)
1897 return g_strdup (_("never"));
1898 else if (randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
1899 return g_strdup_printf (_("always"));
1901 return g_strdup_printf (_("unknown"));
1905 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property get functions --- */
1906 DEFINE_GETTER (nmc_property_wifi_sec_get_key_mgmt, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT)
1907 DEFINE_GETTER (nmc_property_wifi_sec_get_wep_tx_keyidx, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX)
1908 DEFINE_GETTER (nmc_property_wifi_sec_get_auth_alg, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG)
1909 DEFINE_GETTER (nmc_property_wifi_sec_get_proto, NM_SETTING_WIRELESS_SECURITY_PROTO)
1910 DEFINE_GETTER (nmc_property_wifi_sec_get_pairwise, NM_SETTING_WIRELESS_SECURITY_PAIRWISE)
1911 DEFINE_GETTER (nmc_property_wifi_sec_get_group, NM_SETTING_WIRELESS_SECURITY_GROUP)
1912 DEFINE_GETTER (nmc_property_wifi_sec_get_leap_username, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME)
1913 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_wep_key_flags, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS)
1914 DEFINE_GETTER (nmc_property_wifi_sec_get_psk, NM_SETTING_WIRELESS_SECURITY_PSK)
1915 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_psk_flags, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS)
1916 DEFINE_GETTER (nmc_property_wifi_sec_get_leap_password, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)
1917 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_leap_password_flags, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS)
1920 nmc_property_wifi_sec_get_wep_key0 (NMSetting *setting, NmcPropertyGetType get_type)
1922 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1923 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 0));
1927 nmc_property_wifi_sec_get_wep_key1 (NMSetting *setting, NmcPropertyGetType get_type)
1929 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1930 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1));
1934 nmc_property_wifi_sec_get_wep_key2 (NMSetting *setting, NmcPropertyGetType get_type)
1936 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1937 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2));
1941 nmc_property_wifi_sec_get_wep_key3 (NMSetting *setting, NmcPropertyGetType get_type)
1943 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1944 return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3));
1948 nmc_property_wifi_sec_get_wep_key_type (NMSetting *setting, NmcPropertyGetType get_type)
1950 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1951 return wep_key_type_to_string (nm_setting_wireless_security_get_wep_key_type (s_wireless_sec));
1954 /* --- NM_SETTING_MACVLAN_SETTING_NAME property get functions --- */
1955 DEFINE_GETTER (nmc_property_macvlan_get_parent, NM_SETTING_MACVLAN_PARENT)
1956 DEFINE_GETTER (nmc_property_macvlan_get_promiscuous, NM_SETTING_MACVLAN_PROMISCUOUS)
1957 DEFINE_GETTER (nmc_property_macvlan_get_tap, NM_SETTING_MACVLAN_TAP)
1960 nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1962 NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
1963 NMSettingMacvlanMode mode;
1966 mode = nm_setting_macvlan_get_mode (s_macvlan);
1967 tmp = nm_utils_enum_to_str (nm_setting_macvlan_mode_get_type (), mode);
1969 if (get_type == NMC_PROPERTY_GET_PARSABLE)
1970 str = g_strdup (tmp ? tmp : "");
1972 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
1979 nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop,
1980 const char *val, GError **error)
1982 NMSettingMacvlanMode mode;
1983 gs_free const char **options = NULL;
1984 gs_free char *options_str = NULL;
1988 if (nmc_string_to_int_base (val, 0, TRUE, 0, _NM_SETTING_MACVLAN_MODE_NUM - 1, &t))
1989 mode = (NMSettingMacvlanMode) t;
1991 ret = nm_utils_enum_from_str (nm_setting_macvlan_mode_get_type (), val,
1992 (int *) &mode, NULL);
1995 options = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
1996 NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
1998 options_str = g_strjoinv (",", (char **) options);
1999 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
2005 g_object_set (setting, prop, (guint) mode, NULL);
2009 static const char **
2010 nmc_property_macvlan_allowed_mode (NMSetting *setting, const char *prop)
2012 static const char **words = NULL;
2015 words = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
2016 NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
2021 /* --- NM_SETTING_VXLAN_SETTING_NAME property get functions --- */
2022 DEFINE_GETTER (nmc_property_vxlan_get_parent, NM_SETTING_VXLAN_PARENT)
2023 DEFINE_GETTER (nmc_property_vxlan_get_id, NM_SETTING_VXLAN_ID)
2024 DEFINE_GETTER (nmc_property_vxlan_get_local, NM_SETTING_VXLAN_LOCAL)
2025 DEFINE_GETTER (nmc_property_vxlan_get_remote, NM_SETTING_VXLAN_REMOTE)
2026 DEFINE_GETTER (nmc_property_vxlan_get_source_port_min, NM_SETTING_VXLAN_SOURCE_PORT_MIN)
2027 DEFINE_GETTER (nmc_property_vxlan_get_source_port_max, NM_SETTING_VXLAN_SOURCE_PORT_MAX)
2028 DEFINE_GETTER (nmc_property_vxlan_get_destination_port, NM_SETTING_VXLAN_DESTINATION_PORT)
2029 DEFINE_GETTER (nmc_property_vxlan_get_tos, NM_SETTING_VXLAN_TOS)
2030 DEFINE_GETTER (nmc_property_vxlan_get_ttl, NM_SETTING_VXLAN_TTL)
2031 DEFINE_GETTER (nmc_property_vxlan_get_ageing, NM_SETTING_VXLAN_AGEING)
2032 DEFINE_GETTER (nmc_property_vxlan_get_limit, NM_SETTING_VXLAN_LIMIT)
2033 DEFINE_GETTER (nmc_property_vxlan_get_learning, NM_SETTING_VXLAN_LEARNING)
2034 DEFINE_GETTER (nmc_property_vxlan_get_proxy, NM_SETTING_VXLAN_PROXY)
2035 DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC)
2036 DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS)
2037 DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS)
2039 /*----------------------------------------------------------------------------*/
2042 nmc_value_transform_bool_string (const GValue *src_value,
2045 dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_int ? "yes" : "no");
2049 nmc_value_transform_char_string (const GValue *src_value,
2052 dest_value->data[0].v_pointer = g_strdup_printf ("%c", src_value->data[0].v_uint);
2055 static void __attribute__((constructor))
2056 register_nmcli_value_transforms (void)
2058 g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_STRING, nmc_value_transform_bool_string);
2059 g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_STRING, nmc_value_transform_char_string);
2062 /*----------------------------------------------------------------------------*/
2064 /* Main hash table storing function pointer for manipulating properties */
2065 static GHashTable *nmc_properties = NULL;
2066 typedef char * (*NmcPropertyGetFunc) (NMSetting *, NmcPropertyGetType);
2067 typedef gboolean (*NmcPropertySetFunc) (NMSetting *, const char *, const char *, GError **);
2068 typedef gboolean (*NmcPropertyRemoveFunc) (NMSetting *, const char *, const char *, guint32, GError **);
2069 typedef const char * (*NmcPropertyDescribeFunc) (NMSetting *, const char *);
2070 typedef const char ** (*NmcPropertyValuesFunc) (NMSetting *, const char *);
2073 /* The order of the fields is important as they correspond
2074 * to the order as _nmc_add_prop_funcs() passes the arguments. */
2075 #define NmcPropertyFuncsFields \
2076 NmcPropertyGetFunc get_func; /* func getting property values */ \
2077 NmcPropertySetFunc set_func; /* func adding/setting property values */ \
2078 NmcPropertyRemoveFunc remove_func; /* func removing items from container options */ \
2079 NmcPropertyDescribeFunc describe_func; /* func returning property description */ \
2080 NmcPropertyValuesFunc values_func; /* func returning allowed property values */ \
2082 NmcPropertyFuncsFields
2086 * We need NmCli in some _set_property functions, and they aren't passed NmCli.
2087 * So use the global variable.
2089 /* Global variable defined in nmcli.c */
2090 extern NmCli nm_cli;
2093 nmc_setting_new_for_name (const char *name)
2096 NMSetting *setting = NULL;
2099 stype = nm_setting_lookup_type (name);
2100 if (stype != G_TYPE_INVALID) {
2101 setting = g_object_new (stype, NULL);
2102 g_warn_if_fail (NM_IS_SETTING (setting));
2109 get_answer (const char *prop, const char *value)
2113 gboolean answer = FALSE;
2116 question = g_strdup_printf (_("Do you also want to set '%s' to '%s'? [yes]: "), prop, value);
2118 question = g_strdup_printf (_("Do you also want to clear '%s'? [yes]: "), prop);
2119 tmp_str = nmc_get_user_input (question);
2120 if (!tmp_str || matches (tmp_str, "yes") == 0)
2127 static void ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data);
2128 static void ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data);
2131 ipv4_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2133 static gboolean answered = FALSE;
2134 static gboolean answer = FALSE;
2136 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2138 /* If we have some IP addresses set method to 'manual'.
2139 * Else if the method was 'manual', change it back to 'auto'.
2141 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2142 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
2145 answer = get_answer ("ipv4.method", "manual");
2148 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL);
2152 if (!g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
2153 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
2156 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2160 ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2162 static GValue value = G_VALUE_INIT;
2163 static gboolean answered = FALSE;
2164 static gboolean answer = FALSE;
2166 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2168 /* If method != manual, remove addresses (save them for restoring them later when method becomes 'manual' */
2169 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
2170 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2173 answer = get_answer ("ipv4.addresses", NULL);
2176 if (G_IS_VALUE (&value))
2177 g_value_unset (&value);
2178 nmc_property_get_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2179 g_object_set (object, NM_SETTING_IP_CONFIG_ADDRESSES, NULL, NULL);
2184 if (G_IS_VALUE (&value)) {
2185 nmc_property_set_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2186 g_value_unset (&value);
2190 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2194 ipv6_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2196 static gboolean answered = FALSE;
2197 static gboolean answer = FALSE;
2199 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2201 /* If we have some IP addresses set method to 'manual'.
2202 * Else if the method was 'manual', change it back to 'auto'.
2204 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2205 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
2208 answer = get_answer ("ipv6.method", "manual");
2211 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL);
2215 if (!g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
2216 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
2219 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2223 ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2225 static GValue value = G_VALUE_INIT;
2226 static gboolean answered = FALSE;
2227 static gboolean answer = FALSE;
2229 g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2231 /* If method != manual, remove addresses (save them for restoring them later when method becomes 'manual' */
2232 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
2233 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2236 answer = get_answer ("ipv6.addresses", NULL);
2239 if (G_IS_VALUE (&value))
2240 g_value_unset (&value);
2241 nmc_property_get_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2242 g_object_set (object, NM_SETTING_IP_CONFIG_ADDRESSES, NULL, NULL);
2247 if (G_IS_VALUE (&value)) {
2248 nmc_property_set_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2249 g_value_unset (&value);
2253 g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2257 wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2259 const char *value = NULL, *mode;
2261 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (object);
2263 if (strcmp (g_param_spec_get_name (pspec), NM_SETTING_WIRELESS_BAND) == 0) {
2264 value = nm_setting_wireless_get_band (s_wireless);
2268 guint32 channel = nm_setting_wireless_get_channel (s_wireless);
2273 g_snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless));
2277 mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (object));
2278 if (!mode || !*mode || strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
2279 g_print (_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
2280 nm_setting_get_name (NM_SETTING (s_wireless)), g_param_spec_get_name (pspec),
2286 connection_master_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2288 NMSettingConnection *s_con = NM_SETTING_CONNECTION (object);
2289 NMConnection *connection = NM_CONNECTION (user_data);
2290 NMSetting *s_ipv4, *s_ipv6;
2291 const char *value, *tmp_str;
2293 value = nm_setting_connection_get_master (s_con);
2295 s_ipv4 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP4_CONFIG_SETTING_NAME);
2296 s_ipv6 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP6_CONFIG_SETTING_NAME);
2297 if (s_ipv4 || s_ipv6) {
2298 g_print (_("Warning: setting %s.%s requires removing ipv4 and ipv6 settings\n"),
2299 nm_setting_get_name (NM_SETTING (s_con)), g_param_spec_get_name (pspec));
2300 tmp_str = nmc_get_user_input (_("Do you want to remove them? [yes] "));
2301 if (!tmp_str || matches (tmp_str, "yes") == 0) {
2303 nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv4));
2305 nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv6));
2312 nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting)
2314 g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
2316 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_ADDRESSES,
2317 G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2318 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_METHOD,
2319 G_CALLBACK (ipv4_method_changed_cb), NULL);
2323 nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting)
2325 g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
2327 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_ADDRESSES,
2328 G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2329 g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_METHOD,
2330 G_CALLBACK (ipv6_method_changed_cb), NULL);
2334 nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
2336 g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
2338 g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_BAND,
2339 G_CALLBACK (wireless_band_channel_changed_cb), NULL);
2340 g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_CHANNEL,
2341 G_CALLBACK (wireless_band_channel_changed_cb), NULL);
2345 nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection)
2347 g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
2349 g_signal_connect (setting, "notify::" NM_SETTING_CONNECTION_MASTER,
2350 G_CALLBACK (connection_master_changed_cb), connection);
2354 * Customize some properties of the setting so that the setting has sensible
2358 nmc_setting_custom_init (NMSetting *setting)
2360 g_return_if_fail (NM_IS_SETTING (setting));
2362 if (NM_IS_SETTING_IP4_CONFIG (setting)) {
2363 g_object_set (NM_SETTING_IP_CONFIG (setting),
2364 NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
2366 nmc_setting_ip4_connect_handlers (NM_SETTING_IP_CONFIG (setting));
2367 } else if (NM_IS_SETTING_IP6_CONFIG (setting)) {
2368 g_object_set (NM_SETTING_IP_CONFIG (setting),
2369 NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
2371 nmc_setting_ip6_connect_handlers (NM_SETTING_IP_CONFIG (setting));
2372 } else if (NM_IS_SETTING_WIRELESS (setting)) {
2373 g_object_set (NM_SETTING_WIRELESS (setting),
2374 NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
2376 nmc_setting_wireless_connect_handlers (NM_SETTING_WIRELESS (setting));
2380 /* === SetFunc, RemoveFunc, DescribeFunc, ValuesFunc functions === */
2382 verify_string_list (char **strv,
2384 gboolean (*validate_func) (const char *),
2389 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2391 for (iter = strv; iter && *iter; iter++) {
2394 if (validate_func) {
2395 if (!validate_func (*iter)) {
2396 g_set_error (error, 1, 0, _("'%s' is not valid"),
2405 /* Validate 'val' number against to int property spec */
2407 validate_int (NMSetting *setting, const char* prop, gint val, GError **error)
2410 GValue value = G_VALUE_INIT;
2411 gboolean success = TRUE;
2413 g_value_init (&value, G_TYPE_INT);
2414 g_value_set_int (&value, val);
2415 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2416 g_assert (G_IS_PARAM_SPEC (pspec));
2417 if (g_param_value_validate (pspec, &value)) {
2418 GParamSpecInt *pspec_int = (GParamSpecInt *) pspec;
2419 g_set_error (error, 1, 0, _("'%d' is not valid; use <%d-%d>"),
2420 val, pspec_int->minimum, pspec_int->maximum);
2423 g_value_unset (&value);
2428 validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error)
2431 GValue value = G_VALUE_INIT;
2432 gboolean success = TRUE;
2434 g_value_init (&value, G_TYPE_INT64);
2435 g_value_set_int64 (&value, val);
2436 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2437 g_assert (G_IS_PARAM_SPEC (pspec));
2438 if (g_param_value_validate (pspec, &value)) {
2439 GParamSpecInt64 *pspec_int = (GParamSpecInt64 *) pspec;
2440 G_STATIC_ASSERT (sizeof (long long) >= sizeof (gint64));
2441 g_set_error (error, 1, 0, _("'%lld' is not valid; use <%lld-%lld>"),
2442 (long long) val, (long long) pspec_int->minimum, (long long) pspec_int->maximum);
2445 g_value_unset (&value);
2449 /* Validate 'val' number against to uint property spec */
2451 validate_uint (NMSetting *setting, const char* prop, guint val, GError **error)
2454 GValue value = G_VALUE_INIT;
2455 gboolean success = TRUE;
2457 g_value_init (&value, G_TYPE_UINT);
2458 g_value_set_uint (&value, val);
2459 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2460 g_assert (G_IS_PARAM_SPEC (pspec));
2461 if (g_param_value_validate (pspec, &value)) {
2462 GParamSpecUInt *pspec_uint = (GParamSpecUInt *) pspec;
2463 g_set_error (error, 1, 0, _("'%u' is not valid; use <%u-%u>"),
2464 val, pspec_uint->minimum, pspec_uint->maximum);
2467 g_value_unset (&value);
2472 flag_values_to_string (GFlagsValue *array, guint n)
2477 str = g_string_new (NULL);
2478 for (i = 0; i < n; i++)
2479 g_string_append_printf (str, "%u, ", array[i].value);
2481 g_string_truncate (str, str->len-2); /* chop off trailing ', ' */
2482 return g_string_free (str, FALSE);
2486 validate_flags (NMSetting *setting, const char* prop, guint val, GError **error)
2489 GValue value = G_VALUE_INIT;
2490 gboolean success = TRUE;
2492 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2493 g_assert (G_IS_PARAM_SPEC (pspec));
2495 g_value_init (&value, pspec->value_type);
2496 g_value_set_flags (&value, val);
2498 if (g_param_value_validate (pspec, &value)) {
2499 GParamSpecFlags *pspec_flags = (GParamSpecFlags *) pspec;
2500 char *flag_values = flag_values_to_string (pspec_flags->flags_class->values,
2501 pspec_flags->flags_class->n_values);
2502 g_set_error (error, 1, 0, _("'%u' flags are not valid; use combination of %s"),
2504 g_free (flag_values);
2507 g_value_unset (&value);
2512 check_and_set_string (NMSetting *setting,
2515 const char **valid_strv,
2518 const char *checked_val;
2520 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2522 checked_val = nmc_string_is_valid (val, valid_strv, error);
2526 g_object_set (setting, prop, checked_val, NULL);
2530 #define DEFINE_SETTER_STR_LIST_MULTI(def_func, s_macro, set_func) \
2532 def_func (NMSetting *setting, \
2535 const char **valid_strv, \
2538 char **strv = NULL, **iter; \
2540 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2541 strv = nmc_strsplit_set (val, " \t,", 0); \
2542 for (iter = strv; iter && *iter; iter++) { \
2543 if (!(item = nmc_string_is_valid (g_strstrip (*iter), valid_strv, error))) { \
2544 g_strfreev (strv); \
2547 set_func (s_macro (setting), item); \
2549 g_strfreev (strv); \
2553 #define DEFINE_SETTER_OPTIONS(def_func, s_macro, s_type, add_func, valid_func1, valid_func2) \
2555 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2557 char **strv = NULL, **iter; \
2558 const char **(*valid_func1_p) (s_type *) = valid_func1; \
2559 const char * (*valid_func2_p) (const char *, const char *, GError **) = valid_func2; \
2560 const char *opt_name, *opt_val; \
2562 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2564 strv = nmc_strsplit_set (val, ",", 0); \
2565 for (iter = strv; iter && *iter; iter++) { \
2566 char *left = g_strstrip (*iter); \
2567 char *right = strchr (left, '='); \
2569 g_set_error (error, 1, 0, _("'%s' is not valid; use <option>=<value>"), *iter); \
2570 g_strfreev (strv); \
2575 if (valid_func1_p) { \
2576 const char **valid_options = valid_func1_p (s_macro (setting)); \
2577 if (!(opt_name = nmc_string_is_valid (g_strstrip (left), valid_options, error))) { \
2578 g_strfreev (strv); \
2582 opt_name = g_strstrip (left);\
2584 opt_val = g_strstrip (right); \
2585 if (valid_func2_p) { \
2586 if (!(opt_val = valid_func2_p ((const char *) left, (const char *) opt_val, error))) { \
2587 g_strfreev (strv); \
2591 add_func (s_macro (setting), opt_name, opt_val); \
2593 g_strfreev (strv); \
2597 #define DEFINE_REMOVER_INDEX(def_func, s_macro, num_func, rem_func) \
2599 def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2603 g_set_error (error, 1, 0, _("index '%s' is not valid"), option); \
2606 num = num_func (s_macro (setting)); \
2608 g_set_error_literal (error, 1, 0, _("no item to remove")); \
2612 g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2615 rem_func (s_macro (setting), idx); \
2619 #define DEFINE_REMOVER_INDEX_OR_VALUE(def_func, s_macro, num_func, rem_func_idx, rem_func_val) \
2621 def_func (NMSetting *setting, const char *prop, const char *value, guint32 idx, GError **error) \
2626 char *value_stripped = g_strstrip (g_strdup (value)); \
2627 ret = rem_func_val (s_macro (setting), value_stripped, error); \
2628 g_free (value_stripped); \
2631 num = num_func (s_macro (setting)); \
2633 g_set_error_literal (error, 1, 0, _("no item to remove")); \
2637 g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2640 rem_func_idx (s_macro (setting), idx); \
2644 #define DEFINE_REMOVER_OPTION(def_func, s_macro, rem_func) \
2646 def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2648 gboolean success = FALSE; \
2649 if (option && *option) { \
2650 success = rem_func (s_macro (setting), option); \
2652 g_set_error (error, 1, 0, _("invalid option '%s'"), option); \
2654 g_set_error_literal (error, 1, 0, _("missing option")); \
2658 #define DEFINE_ALLOWED_VAL_FUNC(def_func, valid_values) \
2659 static const char ** \
2660 def_func (NMSetting *setting, const char *prop) \
2662 return valid_values; \
2665 /* --- generic property setter functions --- */
2667 nmc_property_set_string (NMSetting *setting, const char *prop, const char *val, GError **error)
2669 g_object_set (setting, prop, val, NULL);
2674 nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GError **error)
2676 unsigned long val_int;
2678 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2680 if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
2681 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2685 /* Validate the number according to the property spec */
2686 if (!validate_uint (setting, prop, (guint) val_int, error))
2689 g_object_set (setting, prop, (guint) val_int, NULL);
2694 nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error)
2698 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2700 if (!nmc_string_to_int (val, TRUE, G_MININT, G_MAXINT, &val_int)) {
2701 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2705 /* Validate the number according to the property spec */
2706 if (!validate_int (setting, prop, (gint) val_int, error))
2709 g_object_set (setting, prop, (gint) val_int, NULL);
2714 nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, GError **error)
2718 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2720 if (!nmc_string_to_int (val, FALSE, 0, 0, &val_int)) {
2721 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2725 /* Validate the number according to the property spec */
2726 if (!validate_int64 (setting, prop, (gint64) val_int, error))
2729 g_object_set (setting, prop, (gint64) val_int, NULL);
2734 nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2736 unsigned long val_int;
2738 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2740 if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
2741 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2745 /* Validate the flags according to the property spec */
2746 if (!validate_flags (setting, prop, (guint) val_int, error))
2749 g_object_set (setting, prop, (guint) val_int, NULL);
2754 nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error)
2758 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2760 if (!nmc_string_to_bool (val, &val_bool, error))
2763 g_object_set (setting, prop, val_bool, NULL);
2768 nmc_property_set_trilean (NMSetting *setting, const char *prop, const char *val, GError **error)
2772 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2774 if (!nmc_string_to_int (val, TRUE, -1, 1, &val_int)) {
2775 g_set_error (error, 1, 0, _("'%s' is not a valid value; use -1, 0 or 1"), val);
2779 g_object_set (setting, prop, val_int, NULL);
2784 nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error)
2788 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2790 if (strlen (val) > 32) {
2791 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
2795 ssid = g_bytes_new (val, strlen (val));
2796 g_object_set (setting, prop, ssid, NULL);
2797 g_bytes_unref (ssid);
2802 nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
2804 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2806 if (!nm_utils_hwaddr_valid (val, ETH_ALEN)) {
2807 g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), val);
2811 g_object_set (setting, prop, val, NULL);
2816 nmc_property_set_mtu (NMSetting *setting, const char *prop, const char *val, GError **error)
2818 const char *mtu = val;
2820 if (strcmp (mtu, "auto") == 0)
2823 return nmc_property_set_uint (setting, prop, mtu, error);
2827 nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, GError **error)
2829 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2831 if (!nm_utils_iface_valid_name (val)) {
2832 g_set_error (error, 1, 0, _("'%s' is not a valid interface name"), val);
2835 g_object_set (setting, prop, val, NULL);
2839 #define ALL_SECRET_FLAGS \
2840 (NM_SETTING_SECRET_FLAG_NONE | \
2841 NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
2842 NM_SETTING_SECRET_FLAG_NOT_SAVED | \
2843 NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
2846 nmc_property_set_secret_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2848 char **strv = NULL, **iter;
2849 unsigned long flags = 0, val_int;
2851 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2853 strv = nmc_strsplit_set (val, " \t,", 0);
2854 for (iter = strv; iter && *iter; iter++) {
2855 if (!nmc_string_to_uint (*iter, TRUE, 0, ALL_SECRET_FLAGS, &val_int)) {
2856 g_set_error (error, 1, 0, _("'%s' is not a valid flag number; use <0-%d>"),
2857 *iter, ALL_SECRET_FLAGS);
2865 /* Validate the flags number */
2866 if (flags > ALL_SECRET_FLAGS) {
2867 flags = ALL_SECRET_FLAGS;
2868 g_print (_("Warning: '%s' sum is higher than all flags => all flags set\n"), val);
2871 g_object_set (setting, prop, (guint) flags, NULL);
2876 nmc_util_is_domain (const char *domain)
2883 nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *val, GError **error)
2885 char **strv = NULL, **iter;
2887 const char *delimiters = " \t,";
2890 GByteArray *array = NULL;
2891 gboolean success = TRUE;
2893 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2895 val_strip = g_strstrip (g_strdup (val));
2897 /* First try hex string in the format of AAbbCCDd */
2898 bytes = nm_utils_hexstr2bin (val_strip);
2900 array = g_bytes_unref_to_array (bytes);
2904 /* Otherwise, consider the following format: AA b 0xCc D */
2905 strv = nmc_strsplit_set (val_strip, delimiters, 0);
2906 array = g_byte_array_sized_new (g_strv_length (strv));
2907 for (iter = strv; iter && *iter; iter++) {
2908 if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) {
2909 g_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
2913 g_byte_array_append (array, (const guint8 *) &val_int, 1);
2918 g_object_set (setting, prop, array, NULL);
2922 g_byte_array_free (array, TRUE);
2926 #define DEFINE_SETTER_MAC_BLACKLIST(def_func, s_macro, add_func) \
2928 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2931 char **list = NULL, **iter; \
2932 GSList *macaddr_blacklist = NULL; \
2934 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2936 list = nmc_strsplit_set (val, " \t,", 0); \
2937 for (iter = list; iter && *iter; iter++) { \
2938 if (!nm_utils_hwaddr_aton (*iter, buf, ETH_ALEN)) { \
2939 g_set_error (error, 1, 0, _("'%s' is not a valid MAC"), *iter); \
2940 g_strfreev (list); \
2941 g_slist_free (macaddr_blacklist); \
2946 for (iter = list; iter && *iter; iter++) \
2947 add_func (s_macro (setting), *iter); \
2949 g_strfreev (list); \
2953 /* --- NM_SETTING_CONNECTION_SETTING_NAME property setter functions --- */
2956 * Setting/removing UUID has been forbidden.
2957 * Should it be enabled later, this function can be used.
2960 nmc_property_con_set_uuid (NMSetting *setting, const char *prop, const char *val, GError **error)
2962 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2964 if (!nm_utils_is_uuid (val)) {
2965 g_set_error (error, 1, 0, _("'%s' is not a valid UUID"), val);
2968 g_object_set (setting, prop, val, NULL);
2974 /* define from libnm-core/nm-setting-connection.c */
2975 #define PERM_USER_PREFIX "user:"
2978 permissions_valid (const char *perm)
2980 if (!perm || perm[0] == '\0')
2983 if (strncmp (perm, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0) {
2984 if ( strlen (perm) <= strlen (PERM_USER_PREFIX)
2985 || strchr (perm + strlen (PERM_USER_PREFIX), ':'))
2988 if (strchr (perm, ':'))
2996 nmc_property_connection_set_permissions (NMSetting *setting, const char *prop, const char *val, GError **error)
3001 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3003 strv = nmc_strsplit_set (val, " \t,", 0);
3004 if (!verify_string_list (strv, prop, permissions_valid, error)) {
3009 for (i = 0; strv && strv[i]; i++) {
3012 if (strncmp (strv[i], PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0)
3013 user = strv[i]+strlen (PERM_USER_PREFIX);
3017 nm_setting_connection_add_permission (NM_SETTING_CONNECTION (setting), "user", user, NULL);
3024 _validate_and_remove_connection_permission (NMSettingConnection *setting,
3030 ret = nm_setting_connection_remove_permission_by_value (setting, "user", perm, NULL);
3032 g_set_error (error, 1, 0, _("the property doesn't contain permission '%s'"), perm);
3035 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_permissions,
3036 NM_SETTING_CONNECTION,
3037 nm_setting_connection_get_num_permissions,
3038 nm_setting_connection_remove_permission,
3039 _validate_and_remove_connection_permission)
3042 nmc_property_connection_describe_permissions (NMSetting *setting, const char *prop)
3044 return _("Enter a list of user permissions. This is a list of user names formatted as:\n"
3045 " [user:]<user name 1>, [user:]<user name 2>,...\n"
3046 "The items can be separated by commas or spaces.\n\n"
3047 "Example: alice bob charlie\n");
3052 nmc_property_con_set_master (NMSetting *setting, const char *prop, const char *val, GError **error)
3054 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3060 else if ( !nm_utils_iface_valid_name (val)
3061 && !nm_utils_is_uuid (val)) {
3062 g_set_error (error, 1, 0,
3063 _("'%s' is not valid master; use ifname or connection UUID"),
3067 g_object_set (setting, prop, val, NULL);
3072 static const char *con_valid_slave_types[] = {
3073 NM_SETTING_BOND_SETTING_NAME,
3074 NM_SETTING_BRIDGE_SETTING_NAME,
3075 NM_SETTING_TEAM_SETTING_NAME,
3080 nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3082 return check_and_set_string (setting, prop, val, con_valid_slave_types, error);
3086 DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_types)
3090 nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error)
3093 char **strv = NULL, **iter;
3096 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3098 strv = nmc_strsplit_set (val, " \t,", 0);
3099 for (iter = strv; iter && *iter; iter++) {
3103 if (nm_utils_is_uuid (*iter)) {
3104 con = nmc_find_connection (nm_cli.connections,
3105 "uuid", *iter, NULL);
3107 g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
3109 /* Currenly NM only supports VPN connections as secondaries */
3110 if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
3111 g_set_error (error, 1, 0, _("'%s' is not a VPN connection profile"), *iter);
3117 con = nmc_find_connection (nm_cli.connections,
3120 g_set_error (error, 1, 0, _("'%s' is not a name of any exiting profile"), *iter);
3125 /* Currenly NM only supports VPN connections as secondaries */
3126 if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
3127 g_set_error (error, 1, 0, _("'%s' is not a VPN connection profile"), *iter);
3132 /* translate id to uuid */
3134 *iter = g_strdup (nm_connection_get_uuid (con));
3138 while (strv && strv[i])
3139 nm_setting_connection_add_secondary (NM_SETTING_CONNECTION (setting), strv[i++]);
3146 _validate_and_remove_connection_secondary (NMSettingConnection *setting,
3147 const char *secondary_uuid,
3152 if (!nm_utils_is_uuid (secondary_uuid)) {
3153 g_set_error (error, 1, 0,
3154 _("the value '%s' is not a valid UUID"), secondary_uuid);
3158 ret = nm_setting_connection_remove_secondary_by_value (setting, secondary_uuid);
3160 g_set_error (error, 1, 0,
3161 _("the property doesn't contain UUID '%s'"), secondary_uuid);
3164 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_secondaries,
3165 NM_SETTING_CONNECTION,
3166 nm_setting_connection_get_num_secondaries,
3167 nm_setting_connection_remove_secondary,
3168 _validate_and_remove_connection_secondary)
3171 nmc_property_connection_describe_secondaries (NMSetting *setting, const char *prop)
3173 return _("Enter secondary connections that should be activated when this connection is\n"
3174 "activated. Connections can be specified either by UUID or ID (name). nmcli\n"
3175 "transparently translates names to UUIDs. Note that NetworkManager only supports\n"
3176 "VPNs as secondary connections at the moment.\n"
3177 "The items can be separated by commas or spaces.\n\n"
3178 "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n");
3183 nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type)
3185 NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3187 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
3188 switch (nm_setting_connection_get_metered (s_conn)) {
3189 case NM_METERED_YES:
3190 return g_strdup ("yes");
3192 return g_strdup ("no");
3193 case NM_METERED_UNKNOWN:
3195 return g_strdup ("unknown");
3198 switch (nm_setting_connection_get_metered (s_conn)) {
3199 case NM_METERED_YES:
3200 return g_strdup (_("yes"));
3202 return g_strdup (_("no"));
3203 case NM_METERED_UNKNOWN:
3205 return g_strdup (_("unknown"));
3210 nmc_property_connection_set_metered (NMSetting *setting, const char *prop,
3211 const char *val, GError **error)
3214 NMCTriStateValue ts_val;
3216 if (!nmc_string_to_tristate (val, &ts_val, error))
3220 case NMC_TRI_STATE_YES:
3221 metered = NM_METERED_YES;
3223 case NMC_TRI_STATE_NO:
3224 metered = NM_METERED_NO;
3226 case NMC_TRI_STATE_UNKNOWN:
3227 metered = NM_METERED_UNKNOWN;
3230 g_assert_not_reached();
3233 g_object_set (setting, prop, metered, NULL);
3238 nmc_property_connection_describe_metered (NMSetting *setting, const char *prop)
3240 return _("Enter a value which indicates whether the connection is subject to a data\n"
3241 "quota, usage costs or other limitations. Accepted options are:\n"
3242 "'true','yes','on' to set the connection as metered\n"
3243 "'false','no','off' to set the connection as not metered\n"
3244 "'unknown' to let NetworkManager choose a value using some heuristics\n");
3249 nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type)
3251 NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3252 NMSettingConnectionLldp lldp;
3255 lldp = nm_setting_connection_get_lldp (s_conn);
3256 tmp = nm_utils_enum_to_str (nm_setting_connection_lldp_get_type (), lldp);
3257 if (get_type == NMC_PROPERTY_GET_PARSABLE)
3258 str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "default");
3260 str = g_strdup_printf ("%d (%s)", lldp, tmp && *tmp ? tmp : "default");
3266 nmc_property_connection_set_lldp (NMSetting *setting, const char *prop,
3267 const char *val, GError **error)
3269 NMSettingConnectionLldp lldp;
3273 if (nmc_string_to_int_base (val, 0, TRUE,
3274 NM_SETTING_CONNECTION_LLDP_DEFAULT,
3275 NM_SETTING_CONNECTION_LLDP_ENABLE_RX,
3279 ret = nm_utils_enum_from_str (nm_setting_connection_lldp_get_type (), val,
3280 (int *) &lldp, NULL);
3283 if (g_ascii_strcasecmp (val, "enable") == 0)
3284 lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX;
3286 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
3287 val, "default,disable,enable-rx,enable");
3293 g_object_set (setting, prop, lldp, NULL);
3297 /* --- NM_SETTING_802_1X_SETTING_NAME property setter functions --- */
3298 #define DEFINE_SETTER_STR_LIST(def_func, set_func) \
3300 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3302 char **strv = NULL; \
3305 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
3307 strv = nmc_strsplit_set (val, " \t,", 0); \
3308 while (strv && strv[i]) \
3309 set_func (NM_SETTING_802_1X (setting), strv[i++]); \
3310 g_strfreev (strv); \
3314 #define DEFINE_SETTER_CERT(def_func, set_func) \
3316 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3318 char *val_strip = g_strstrip (g_strdup (val)); \
3319 char *p = val_strip; \
3322 if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
3323 p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
3325 success = set_func (NM_SETTING_802_1X (setting), \
3327 NM_SETTING_802_1X_CK_SCHEME_PATH, \
3330 g_free (val_strip); \
3334 #define DEFINE_SETTER_PRIV_KEY(def_func, pwd_func, set_func) \
3336 def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3338 char **strv = NULL; \
3339 char *val_strip = g_strstrip (g_strdup (val)); \
3340 char *p = val_strip; \
3341 const char *path, *password; \
3344 if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
3345 p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
3347 strv = nmc_strsplit_set (p, " \t,", 2); \
3349 if (g_strv_length (strv) == 2) \
3350 password = strv[1]; \
3352 password = pwd_func (NM_SETTING_802_1X (setting)); \
3354 char *tmp_pwd = g_strdup (password); \
3355 success = set_func (NM_SETTING_802_1X (setting), \
3358 NM_SETTING_802_1X_CK_SCHEME_PATH, \
3364 g_set_error_literal (error, 1, 0, _("private key password not provided")); \
3366 g_free (val_strip); \
3367 g_strfreev (strv); \
3372 static const char *valid_eap[] = { "leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", NULL };
3374 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_802_1X_eap,
3376 nm_setting_802_1x_add_eap_method)
3378 nmc_property_802_1X_set_eap (NMSetting *setting, const char *prop, const char *val, GError **error)
3380 return check_and_add_802_1X_eap (setting, prop, val, valid_eap, error);
3384 _validate_and_remove_eap_method (NMSetting8021x *setting,
3390 ret = nm_setting_802_1x_remove_eap_method_by_value(setting, eap);
3392 g_set_error (error, 1, 0, _("the property doesn't contain EAP method '%s'"), eap);
3395 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_eap,
3397 nm_setting_802_1x_get_num_eap_methods,
3398 nm_setting_802_1x_remove_eap_method,
3399 _validate_and_remove_eap_method)
3401 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_eap, valid_eap)
3404 DEFINE_SETTER_CERT (nmc_property_802_1X_set_ca_cert, nm_setting_802_1x_set_ca_cert)
3407 nmc_property_802_1X_describe_ca_cert (NMSetting *setting, const char *prop)
3409 return _("Enter file path to CA certificate (optionally prefixed with file://).\n"
3410 " [file://]<file path>\n"
3411 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3412 "Example: /home/cimrman/cacert.crt\n");
3415 /* 'altsubject-matches' */
3416 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_altsubject_matches, nm_setting_802_1x_add_altsubject_match)
3419 _validate_and_remove_altsubject_match (NMSetting8021x *setting,
3420 const char *altsubject_match,
3425 ret = nm_setting_802_1x_remove_altsubject_match_by_value (setting, altsubject_match);
3427 g_set_error (error, 1, 0,
3428 _("the property doesn't contain alternative subject match '%s'"),
3432 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_altsubject_matches,
3434 nm_setting_802_1x_get_num_altsubject_matches,
3435 nm_setting_802_1x_remove_altsubject_match,
3436 _validate_and_remove_altsubject_match)
3439 DEFINE_SETTER_CERT (nmc_property_802_1X_set_client_cert, nm_setting_802_1x_set_client_cert)
3442 nmc_property_802_1X_describe_client_cert (NMSetting *setting, const char *prop)
3444 return _("Enter file path to client certificate (optionally prefixed with file://).\n"
3445 " [file://]<file path>\n"
3446 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3447 "Example: /home/cimrman/jara.crt\n");
3450 /* 'phase2-ca-cert' */
3451 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert)
3454 nmc_property_802_1X_describe_phase2_ca_cert (NMSetting *setting, const char *prop)
3456 return _("Enter file path to CA certificate for inner authentication (optionally prefixed\n"
3458 " [file://]<file path>\n"
3459 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3460 "Example: /home/cimrman/ca-zweite-phase.crt\n");
3463 /* 'phase2-altsubject-matches' */
3464 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_phase2_altsubject_matches, nm_setting_802_1x_add_phase2_altsubject_match)
3467 _validate_and_remove_phase2_altsubject_match (NMSetting8021x *setting,
3468 const char *phase2_altsubject_match,
3473 ret = nm_setting_802_1x_remove_phase2_altsubject_match_by_value (setting, phase2_altsubject_match);
3475 g_set_error (error, 1, 0,
3476 _("the property doesn't contain \"phase2\" alternative subject match '%s'"),
3477 phase2_altsubject_match);
3480 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_phase2_altsubject_matches,
3482 nm_setting_802_1x_get_num_phase2_altsubject_matches,
3483 nm_setting_802_1x_remove_phase2_altsubject_match,
3484 _validate_and_remove_phase2_altsubject_match)
3486 /* 'phase2-client-cert' */
3487 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert)
3490 nmc_property_802_1X_describe_phase2_client_cert (NMSetting *setting, const char *prop)
3492 return _("Enter file path to client certificate for inner authentication (optionally prefixed\n"
3494 " [file://]<file path>\n"
3495 "Note that nmcli does not support specifying certificates as raw blob data.\n"
3496 "Example: /home/cimrman/jara-zweite-phase.crt\n");
3500 DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_private_key,
3501 nm_setting_802_1x_get_private_key_password,
3502 nm_setting_802_1x_set_private_key)
3504 /* 'phase2-private-key' */
3505 DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_phase2_private_key,
3506 nm_setting_802_1x_get_phase2_private_key_password,
3507 nm_setting_802_1x_set_phase2_private_key)
3510 nmc_property_802_1X_describe_private_key (NMSetting *setting, const char *prop)
3512 return _("Enter path to a private key and the key password (if not set yet):\n"
3513 " [file://]<file path> [<password>]\n"
3514 "Note that nmcli does not support specifying private key as raw blob data.\n"
3515 "Example: /home/cimrman/jara-priv-key Dardanely\n");
3518 /* 'phase1-peapver' */
3519 static const char *_802_1X_valid_phase1_peapvers[] = { "0", "1", NULL };
3522 nmc_property_802_1X_set_phase1_peapver (NMSetting *setting, const char *prop, const char *val, GError **error)
3524 return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peapvers, error);
3527 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peapver, _802_1X_valid_phase1_peapvers)
3529 /* 'phase1-peaplabel' */
3530 static const char *_802_1X_valid_phase1_peaplabels[] = { "0", "1", NULL };
3533 nmc_property_802_1X_set_phase1_peaplabel (NMSetting *setting, const char *prop, const char *val, GError **error)
3535 return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peaplabels, error);
3538 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peaplabel, _802_1X_valid_phase1_peaplabels)
3540 /* 'phase1-fast-provisioning' */
3541 static const char *_802_1X_valid_phase1_fast_provisionings[] = { "0", "1", "2", "3", NULL };
3544 nmc_property_802_1X_set_phase1_fast_provisioning (NMSetting *setting, const char *prop, const char *val, GError **error)
3546 return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_fast_provisionings, error);
3549 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_fast_provisioning, _802_1X_valid_phase1_fast_provisionings)
3552 static const char *_802_1X_valid_phase2_auths[] =
3553 { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL };
3556 nmc_property_802_1X_set_phase2_auth (NMSetting *setting, const char *prop, const char *val, GError **error)
3558 return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_auths, error);
3561 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_auth, _802_1X_valid_phase2_auths)
3563 /* 'phase2-autheap' */
3564 static const char *_802_1X_valid_phase2_autheaps[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL };
3566 nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, const char *val, GError **error)
3568 return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_autheaps, error);
3571 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_valid_phase2_autheaps)
3573 /* 'password-raw' */
3575 nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error)
3577 return nmc_property_set_byte_array (setting, prop, val, error);
3581 nmc_property_802_1X_describe_password_raw (NMSetting *setting, const char *prop)
3583 return _("Enter bytes as a list of hexadecimal values.\n"
3584 "Two formats are accepted:\n"
3585 "(a) a string of hexadecimal digits, where each two digits represent one byte\n"
3586 "(b) space-separated list of bytes written as hexadecimal digits "
3587 "(with optional 0x/0X prefix, and optional leading 0).\n\n"
3588 "Examples: ab0455a6ea3a74C2\n"
3589 " ab 4 55 0xa6 ea 3a 74 C2\n");
3592 /* --- NM_SETTING_ADSL_SETTING_NAME property setter functions --- */
3594 static const char *adsl_valid_protocols[] = {
3595 NM_SETTING_ADSL_PROTOCOL_PPPOA,
3596 NM_SETTING_ADSL_PROTOCOL_PPPOE,
3597 NM_SETTING_ADSL_PROTOCOL_IPOATM,
3602 nmc_property_adsl_set_protocol (NMSetting *setting, const char *prop, const char *val, GError **error)
3604 return check_and_set_string (setting, prop, val, adsl_valid_protocols, error);
3607 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_protocol, adsl_valid_protocols)
3609 /* 'encapsulation' */
3610 static const char *adsl_valid_encapsulations[] = {
3611 NM_SETTING_ADSL_ENCAPSULATION_VCMUX,
3612 NM_SETTING_ADSL_ENCAPSULATION_LLC,
3617 nmc_property_adsl_set_encapsulation (NMSetting *setting, const char *prop, const char *val, GError **error)
3619 return check_and_set_string (setting, prop, val, adsl_valid_encapsulations, error);
3622 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_encapsulation, adsl_valid_encapsulations)
3624 /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property setter functions --- */
3627 nmc_property_bluetooth_set_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3629 const char *types[] = {
3630 NM_SETTING_BLUETOOTH_TYPE_DUN,
3631 NM_SETTING_BLUETOOTH_TYPE_PANU,
3634 return check_and_set_string (setting, prop, val, types, error);
3637 /* --- NM_SETTING_BOND_SETTING_NAME property setter functions --- */
3639 /* example: miimon=100,mode=balance-rr, updelay=5 */
3641 _validate_and_remove_bond_option (NMSettingBond *setting, const char *option)
3644 const char **valid_options;
3646 valid_options = nm_setting_bond_get_valid_options (setting);
3647 opt = nmc_string_is_valid (option, valid_options, NULL);
3650 return nm_setting_bond_remove_option (setting, opt);
3655 /* Validate bonding 'options' values */
3657 _validate_bond_option_value (const char *option, const char *value, GError **error)
3659 if (!g_strcmp0 (option, NM_SETTING_BOND_OPTION_MODE))
3660 return nmc_bond_validate_mode (value, error);
3666 _bond_add_option (NMSettingBond *setting,
3670 gs_free char *tmp_value = NULL;
3673 if (nm_streq0 (name, NM_SETTING_BOND_OPTION_ARP_IP_TARGET)) {
3674 value = tmp_value = g_strdup (value);
3675 for (p = tmp_value; p && *p; p++)
3680 return nm_setting_bond_add_option (setting, name, value);
3683 DEFINE_SETTER_OPTIONS (nmc_property_bond_set_options,
3687 nm_setting_bond_get_valid_options,
3688 _validate_bond_option_value)
3689 DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options,
3691 _validate_and_remove_bond_option)
3694 nmc_property_bond_describe_options (NMSetting *setting, const char *prop)
3696 static char *desc = NULL;
3697 const char **valid_options;
3700 if (G_UNLIKELY (desc == NULL)) {
3701 valid_options = nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3702 options_str = g_strjoinv (", ", (char **) valid_options);
3704 desc = g_strdup_printf (_("Enter a list of bonding options formatted as:\n"
3705 " option = <value>, option = <value>,... \n"
3706 "Valid options are: %s\n"
3707 "'mode' can be provided as a name or a number:\n"
3709 "active-backup = 1\n"
3714 "balance-alb = 6\n\n"
3715 "Example: mode=2,miimon=120\n"), options_str);
3716 g_free (options_str);
3721 static const char **
3722 nmc_property_bond_allowed_options (NMSetting *setting, const char *prop)
3724 return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3727 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property setter functions --- */
3730 nmc_property_ib_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
3732 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3734 if (!nm_utils_hwaddr_valid (val, INFINIBAND_ALEN)) {
3735 g_set_error (error, 1, 0, _("'%s' is not a valid InfiniBand MAC"), val);
3739 g_object_set (setting, prop, val, NULL);
3743 /* 'transport-mode' */
3744 static const char *ib_valid_transport_modes[] = { "datagram", "connected", NULL };
3747 nmc_property_ib_set_transport_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
3749 return check_and_set_string (setting, prop, val, ib_valid_transport_modes, error);
3752 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ib_allowed_transport_mode, ib_valid_transport_modes)
3756 nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val, GError **error)
3758 gboolean p_key_valid = FALSE;
3761 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3763 if (!strncasecmp (val, "0x", 2))
3764 p_key_valid = nmc_string_to_int_base (val + 2, 16, TRUE, 0, G_MAXUINT16, &p_key_int);
3766 p_key_valid = nmc_string_to_int (val, TRUE, -1, G_MAXUINT16, &p_key_int);
3769 if (strcmp (val, "default") == 0)
3772 g_set_error (error, 1, 0, _("'%s' is not a valid IBoIP P_Key"), val);
3776 g_object_set (setting, prop, (gint) p_key_int, NULL);
3780 /* --- IP4 / IP6 shared functions --- */
3781 static NMIPAddress *
3782 _parse_ip_address (int family, const char *address, GError **error)
3784 char *value = g_strdup (address);
3785 NMIPAddress *ipaddr;
3787 ipaddr = nmc_parse_and_build_address (family, g_strstrip (value), error);
3793 _parse_ip_route (int family, const char *route, GError **error)
3795 char *value = g_strdup (route);
3798 NMIPRoute *iproute = NULL;
3800 routev = nmc_strsplit_set (g_strstrip (value), " \t", 0);
3801 len = g_strv_length (routev);
3802 if (len < 1 || len > 3) {
3803 g_set_error (error, 1, 0, _("'%s' is not valid (the format is: ip[/prefix] [next-hop] [metric])"),
3807 iproute = nmc_parse_and_build_route (family, routev[0], routev[1], len >= 2 ? routev[2] : NULL, error);
3811 g_strfreev (routev);
3815 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property setter functions --- */
3817 static const char *ipv4_valid_methods[] = {
3818 NM_SETTING_IP4_CONFIG_METHOD_AUTO,
3819 NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
3820 NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
3821 NM_SETTING_IP4_CONFIG_METHOD_SHARED,
3822 NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
3827 nmc_property_ipv4_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
3829 /* Silently accept "static" and convert to "manual" */
3830 if (val && strlen (val) > 1 && matches (val, "static") == 0)
3831 val = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
3833 return check_and_set_string (setting, prop, val, ipv4_valid_methods, error);
3836 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods)
3840 nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
3842 char **strv = NULL, **iter, *addr;
3845 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3847 strv = nmc_strsplit_set (val, " \t,", 0);
3848 for (iter = strv; iter && *iter; iter++) {
3849 addr = g_strstrip (*iter);
3850 if (inet_pton (AF_INET, addr, &ip4_addr) < 1) {
3851 g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), addr);
3855 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
3862 _validate_and_remove_ipv4_dns (NMSettingIPConfig *setting,
3869 if (inet_pton (AF_INET, dns, &ip4_addr) < 1) {
3870 g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), dns);
3874 ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
3876 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
3879 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns,
3880 NM_SETTING_IP_CONFIG,
3881 nm_setting_ip_config_get_num_dns,
3882 nm_setting_ip_config_remove_dns,
3883 _validate_and_remove_ipv4_dns)
3886 nmc_property_ipv4_describe_dns (NMSetting *setting, const char *prop)
3888 return _("Enter a list of IPv4 addresses of DNS servers.\n\n"
3889 "Example: 8.8.8.8, 8.8.4.4\n");
3894 nmc_property_ipv4_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
3899 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3901 strv = nmc_strsplit_set (val, " \t,", 0);
3902 if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
3907 while (strv && strv[i])
3908 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3915 _validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting,
3916 const char *dns_search,
3921 ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
3923 g_set_error (error, 1, 0,
3924 _("the property doesn't contain DNS search domain '%s'"),
3928 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_search,
3929 NM_SETTING_IP_CONFIG,
3930 nm_setting_ip_config_get_num_dns_searches,
3931 nm_setting_ip_config_remove_dns_search,
3932 _validate_and_remove_ipv4_dns_search)
3936 nmc_property_ipv4_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
3941 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3943 nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
3944 strv = nmc_strsplit_set (val, " \t,", 0);
3945 while (strv && strv[i])
3946 nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3953 _validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting,
3954 const char *dns_option,
3959 ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
3961 g_set_error (error, 1, 0,
3962 _("the property doesn't contain DNS option '%s'"),
3966 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_option,
3967 NM_SETTING_IP_CONFIG,
3968 nm_setting_ip_config_get_num_dns_options,
3969 nm_setting_ip_config_remove_dns_option,
3970 _validate_and_remove_ipv4_dns_option)
3973 static NMIPAddress *
3974 _parse_ipv4_address (const char *address, GError **error)
3976 return _parse_ip_address (AF_INET, address, error);
3980 nmc_property_ipv4_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
3982 char **strv = NULL, **iter;
3983 NMIPAddress *ip4addr;
3985 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3987 strv = nmc_strsplit_set (val, ",", 0);
3988 for (iter = strv; iter && *iter; iter++) {
3989 ip4addr = _parse_ipv4_address (*iter, error);
3994 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip4addr);
3995 nm_ip_address_unref (ip4addr);
4002 _validate_and_remove_ipv4_address (NMSettingIPConfig *setting,
4003 const char *address,
4006 NMIPAddress *ip4addr;
4009 ip4addr = _parse_ipv4_address (address, error);
4013 ret = nm_setting_ip_config_remove_address_by_value (setting, ip4addr);
4015 g_set_error (error, 1, 0,
4016 _("the property doesn't contain IP address '%s'"), address);
4017 nm_ip_address_unref (ip4addr);
4020 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_addresses,
4021 NM_SETTING_IP_CONFIG,
4022 nm_setting_ip_config_get_num_addresses,
4023 nm_setting_ip_config_remove_address,
4024 _validate_and_remove_ipv4_address)
4027 nmc_property_ipv4_describe_addresses (NMSetting *setting, const char *prop)
4029 return _("Enter a list of IPv4 addresses formatted as:\n"
4030 " ip[/prefix], ip[/prefix],...\n"
4031 "Missing prefix is regarded as prefix of 32.\n\n"
4032 "Example: 192.168.1.5/24, 10.0.0.11/24\n");
4037 nmc_property_ipv4_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4039 NMIPAddress *ip4addr;
4041 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4043 if (strchr (val, '/')) {
4044 g_set_error (error, 1, 0,
4045 _("invalid gateway address '%s'"), val);
4048 ip4addr = _parse_ipv4_address (val, error);
4052 g_object_set (setting, prop, val, NULL);
4053 nm_ip_address_unref (ip4addr);
4059 _parse_ipv4_route (const char *route, GError **error)
4061 return _parse_ip_route (AF_INET, route, error);
4065 nmc_property_ipv4_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4067 char **strv = NULL, **iter;
4068 NMIPRoute *ip4route;
4070 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4072 strv = nmc_strsplit_set (val, ",", 0);
4073 for (iter = strv; iter && *iter; iter++) {
4074 ip4route = _parse_ipv4_route (*iter, error);
4079 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip4route);
4080 nm_ip_route_unref (ip4route);
4087 _validate_and_remove_ipv4_route (NMSettingIPConfig *setting,
4091 NMIPRoute *ip4route;
4094 ip4route = _parse_ipv4_route (route, error);
4098 ret = nm_setting_ip_config_remove_route_by_value (setting, ip4route);
4100 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4101 nm_ip_route_unref (ip4route);
4104 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_routes,
4105 NM_SETTING_IP_CONFIG,
4106 nm_setting_ip_config_get_num_routes,
4107 nm_setting_ip_config_remove_route,
4108 _validate_and_remove_ipv4_route)
4111 nmc_property_ipv4_describe_routes (NMSetting *setting, const char *prop)
4113 return _("Enter a list of IPv4 routes formatted as:\n"
4114 " ip[/prefix] [next-hop] [metric],...\n\n"
4115 "Missing prefix is regarded as a prefix of 32.\n"
4116 "Missing next-hop is regarded as 0.0.0.0.\n"
4117 "Missing metric means default (NM/kernel will set a default value).\n\n"
4118 "Examples: 192.168.2.0/24 192.168.2.1 3, 10.1.0.0/16 10.0.0.254\n"
4122 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property setter functions --- */
4124 static const char *ipv6_valid_methods[] = {
4125 NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
4126 NM_SETTING_IP6_CONFIG_METHOD_AUTO,
4127 NM_SETTING_IP6_CONFIG_METHOD_DHCP,
4128 NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
4129 NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
4130 NM_SETTING_IP6_CONFIG_METHOD_SHARED,
4135 nmc_property_ipv6_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
4137 /* Silently accept "static" and convert to "manual" */
4138 if (val && strlen (val) > 1 && matches (val, "static") == 0)
4139 val = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
4141 return check_and_set_string (setting, prop, val, ipv6_valid_methods, error);
4144 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods)
4148 nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
4150 char **strv = NULL, **iter, *addr;
4151 struct in6_addr ip6_addr;
4153 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4155 strv = nmc_strsplit_set (val, " \t,", 0);
4156 for (iter = strv; iter && *iter; iter++) {
4157 addr = g_strstrip (*iter);
4158 if (inet_pton (AF_INET6, addr, &ip6_addr) < 1) {
4159 g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), addr);
4163 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
4170 _validate_and_remove_ipv6_dns (NMSettingIPConfig *setting,
4174 struct in6_addr ip6_addr;
4177 if (inet_pton (AF_INET6, dns, &ip6_addr) < 1) {
4178 g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), dns);
4182 ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
4184 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
4187 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns,
4188 NM_SETTING_IP_CONFIG,
4189 nm_setting_ip_config_get_num_dns,
4190 nm_setting_ip_config_remove_dns,
4191 _validate_and_remove_ipv6_dns)
4194 nmc_property_ipv6_describe_dns (NMSetting *setting, const char *prop)
4196 return _("Enter a list of IPv6 addresses of DNS servers. If the IPv6 "
4197 "configuration method is 'auto' these DNS servers are appended "
4198 "to those (if any) returned by automatic configuration. DNS "
4199 "servers cannot be used with the 'shared' or 'link-local' IPv6 "
4200 "configuration methods, as there is no upstream network. In "
4201 "all other IPv6 configuration methods, these DNS "
4202 "servers are used as the only DNS servers for this connection.\n\n"
4203 "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n");
4208 nmc_property_ipv6_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
4213 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4215 strv = nmc_strsplit_set (val, " \t,", 0);
4216 if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
4221 while (strv && strv[i])
4222 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4229 _validate_and_remove_ipv6_dns_search (NMSettingIPConfig *setting,
4230 const char *dns_search,
4235 ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
4237 g_set_error (error, 1, 0,
4238 _("the property doesn't contain DNS search domain '%s'"),
4242 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_search,
4243 NM_SETTING_IP_CONFIG,
4244 nm_setting_ip_config_get_num_dns_searches,
4245 nm_setting_ip_config_remove_dns_search,
4246 _validate_and_remove_ipv6_dns_search)
4250 nmc_property_ipv6_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
4255 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4257 nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
4258 strv = nmc_strsplit_set (val, " \t,", 0);
4259 while (strv && strv[i])
4260 nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4267 _validate_and_remove_ipv6_dns_option (NMSettingIPConfig *setting,
4268 const char *dns_option,
4273 ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
4275 g_set_error (error, 1, 0,
4276 _("the property doesn't contain DNS option '%s'"),
4280 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_option,
4281 NM_SETTING_IP_CONFIG,
4282 nm_setting_ip_config_get_num_dns_options,
4283 nm_setting_ip_config_remove_dns_option,
4284 _validate_and_remove_ipv6_dns_option)
4287 static NMIPAddress *
4288 _parse_ipv6_address (const char *address, GError **error)
4290 return _parse_ip_address (AF_INET6, address, error);
4294 nmc_property_ipv6_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
4296 char **strv = NULL, **iter;
4297 NMIPAddress *ip6addr;
4299 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4301 strv = nmc_strsplit_set (val, ",", 0);
4302 for (iter = strv; iter && *iter; iter++) {
4303 ip6addr = _parse_ipv6_address (*iter, error);
4308 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip6addr);
4309 nm_ip_address_unref (ip6addr);
4316 _validate_and_remove_ipv6_address (NMSettingIPConfig *setting,
4317 const char *address,
4320 NMIPAddress *ip6addr;
4323 ip6addr = _parse_ipv6_address (address, error);
4327 ret = nm_setting_ip_config_remove_address_by_value (setting, ip6addr);
4329 g_set_error (error, 1, 0, _("the property doesn't contain IP address '%s'"), address);
4330 nm_ip_address_unref (ip6addr);
4333 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_addresses,
4334 NM_SETTING_IP_CONFIG,
4335 nm_setting_ip_config_get_num_addresses,
4336 nm_setting_ip_config_remove_address,
4337 _validate_and_remove_ipv6_address)
4340 nmc_property_ipv6_describe_addresses (NMSetting *setting, const char *prop)
4342 return _("Enter a list of IPv6 addresses formatted as:\n"
4343 " ip[/prefix], ip[/prefix],...\n"
4344 "Missing prefix is regarded as prefix of 128.\n\n"
4345 "Example: 2607:f0d0:1002:51::4/64, 1050:0:0:0:5:600:300c:326b\n");
4350 nmc_property_ipv6_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4352 NMIPAddress *ip6addr;
4354 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4356 if (strchr (val, '/')) {
4357 g_set_error (error, 1, 0,
4358 _("invalid gateway address '%s'"), val);
4361 ip6addr = _parse_ipv6_address (val, error);
4365 g_object_set (setting, prop, val, NULL);
4366 nm_ip_address_unref (ip6addr);
4372 _parse_ipv6_route (const char *route, GError **error)
4374 return _parse_ip_route (AF_INET6, route, error);
4378 nmc_property_ipv6_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4380 char **strv = NULL, **iter;
4381 NMIPRoute *ip6route;
4383 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4385 strv = nmc_strsplit_set (val, ",", 0);
4386 for (iter = strv; iter && *iter; iter++) {
4387 ip6route = _parse_ipv6_route (*iter, error);
4392 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip6route);
4393 nm_ip_route_unref (ip6route);
4400 _validate_and_remove_ipv6_route (NMSettingIPConfig *setting,
4404 NMIPRoute *ip6route;
4407 ip6route = _parse_ipv6_route (route, error);
4411 ret = nm_setting_ip_config_remove_route_by_value (setting, ip6route);
4413 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4414 nm_ip_route_unref (ip6route);
4417 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_routes,
4418 NM_SETTING_IP_CONFIG,
4419 nm_setting_ip_config_get_num_routes,
4420 nm_setting_ip_config_remove_route,
4421 _validate_and_remove_ipv6_route)
4424 nmc_property_ipv6_describe_routes (NMSetting *setting, const char *prop)
4426 return _("Enter a list of IPv6 routes formatted as:\n"
4427 " ip[/prefix] [next-hop] [metric],...\n\n"
4428 "Missing prefix is regarded as a prefix of 128.\n"
4429 "Missing next-hop is regarded as \"::\".\n"
4430 "Missing metric means default (NM/kernel will set a default value).\n\n"
4431 "Examples: 2001:db8:beef:2::/64 2001:db8:beef::2, 2001:db8:beef:3::/64 2001:db8:beef::3 2\n"
4436 nmc_property_ipv6_set_ip6_privacy (NMSetting *setting, const char *prop, const char *val, GError **error)
4438 unsigned long val_int;
4440 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4442 if (!nmc_string_to_uint (val, FALSE, 0, 0, &val_int)) {
4443 g_set_error (error, 1, 0, _("'%s' is not a number"), val);
4447 if ( val_int != NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED
4448 && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR
4449 && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) {
4450 g_set_error (error, 1, 0, _("'%s' is not valid; use 0, 1, or 2"), val);
4454 g_object_set (setting, prop, val_int, NULL);
4458 /* 'addr_gen_mode' */
4460 nmc_property_ipv6_get_addr_gen_mode (NMSetting *setting, NmcPropertyGetType get_type)
4462 NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
4463 NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4465 addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode (s_ip6);
4466 return nm_utils_enum_to_str (nm_setting_ip6_config_addr_gen_mode_get_type (), addr_gen_mode);
4471 nmc_property_ipv6_set_addr_gen_mode (NMSetting *setting, const char *prop,
4472 const char *val, GError **error)
4474 NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4476 if (!nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), val,
4477 (int *) &addr_gen_mode, NULL)) {
4478 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
4479 val, "eui64,stable-privacy");
4483 g_object_set (setting, prop, addr_gen_mode, NULL);
4488 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property setter functions --- */
4490 nmc_property_olpc_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4492 unsigned long chan_int;
4494 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4496 if (!nmc_string_to_uint (val, TRUE, 1, 13, &chan_int)) {
4497 g_set_error (error, 1, 0, _("'%s' is not a valid channel; use <1-13>"), val);
4500 g_object_set (setting, prop, chan_int, NULL);
4505 /* --- NM_SETTING_SERIAL_SETTING_NAME property setter functions --- */
4507 nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type)
4509 NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
4511 switch (nm_setting_serial_get_parity (s_serial)) {
4512 case NM_SETTING_SERIAL_PARITY_EVEN:
4513 return g_strdup ("even");
4514 case NM_SETTING_SERIAL_PARITY_ODD:
4515 return g_strdup ("odd");
4517 case NM_SETTING_SERIAL_PARITY_NONE:
4518 return g_strdup ("none");
4523 nmc_property_serial_set_parity (NMSetting *setting, const char *prop, const char *val, GError **error)
4525 NMSettingSerialParity parity;
4527 if (val[0] == 'E' || val[0] == 'e')
4528 parity = NM_SETTING_SERIAL_PARITY_EVEN;
4529 else if (val[0] == 'O' || val[0] == 'o')
4530 parity = NM_SETTING_SERIAL_PARITY_ODD;
4531 else if (val[0] == 'N' || val[0] == 'n')
4532 parity = NM_SETTING_SERIAL_PARITY_NONE;
4534 g_set_error (error, 1, 0, _("'%s' is not valid; use [e, o, n]"), val);
4538 g_object_set (setting, prop, parity, NULL);
4542 /* --- NM_SETTING_TEAM_SETTING_NAME property functions --- */
4543 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property functions --- */
4545 nmc_property_team_set_config (NMSetting *setting, const char *prop, const char *val, GError **error)
4549 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4551 if (!nmc_team_check_config (val, &json, error)) {
4554 g_object_set (setting, prop, json, NULL);
4560 nmc_property_team_describe_config (NMSetting *setting, const char *prop)
4562 return _("nmcli can accepts both direct JSON configuration data and a file name containing "
4563 "the configuration. In the latter case the file is read and the contents is put "
4564 "into this property.\n\n"
4565 "Examples: set team.config "
4566 "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n"
4567 " set team.config /etc/my-team.conf\n");
4570 /* --- NM_SETTING_VLAN_SETTING_NAME property setter functions --- */
4572 nmc_property_vlan_set_prio_map (NMSetting *setting,
4575 NMVlanPriorityMap map_type,
4578 char **prio_map, **p;
4580 prio_map = nmc_vlan_parse_priority_maps (val, map_type, error);
4584 for (p = prio_map; p && *p; p++)
4585 nm_setting_vlan_add_priority_str (NM_SETTING_VLAN (setting), map_type, *p);
4587 g_strfreev (prio_map);
4592 nmc_property_vlan_remove_prio_map (NMSetting *setting,
4595 NMVlanPriorityMap map_type,
4600 num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type);
4602 g_set_error_literal (error, 1, 0, _("no priority to remove"));
4606 g_set_error (error, 1, 0, _("index '%d' is not in the range of <0-%d>"),
4611 nm_setting_vlan_remove_priority (NM_SETTING_VLAN (setting), map_type, idx);
4616 nmc_property_vlan_set_ingress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4618 return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_INGRESS_MAP, error);
4622 nmc_property_vlan_set_egress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4624 return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_EGRESS_MAP, error);
4628 nmc_property_vlan_remove_priority_map (NMSetting *setting,
4632 NMVlanPriorityMap map,
4635 /* If value != NULL, remove by value */
4639 char *val = g_strdup (value);
4641 prio_map = nmc_vlan_parse_priority_maps (val, map, error);
4645 g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
4647 ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
4652 g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]);
4654 g_strfreev (prio_map);
4658 /* Else remove by index */
4659 return nmc_property_vlan_remove_prio_map (setting, prop, idx, map, error);
4663 nmc_property_vlan_remove_ingress_priority_map (NMSetting *setting,
4669 return nmc_property_vlan_remove_priority_map (setting,
4673 NM_VLAN_INGRESS_MAP,
4678 nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
4684 return nmc_property_vlan_remove_priority_map (setting,
4692 /* --- NM_SETTING_VPN_SETTING_NAME property setter functions --- */
4693 /* Validate value of vpn 'data' and 'secret' options */
4695 _validate_vpn_hash_value (const char *option, const char *value, GError **error)
4697 /* nm_setting_vpn_add_data_item() and nm_setting_vpn_add_secret() does not
4698 * allow empty strings */
4699 if (!value || !*value) {
4700 g_set_error (error, 1, 0, _("'%s' cannot be empty"), option);
4707 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
4710 nm_setting_vpn_add_data_item,
4712 _validate_vpn_hash_value)
4713 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
4715 nm_setting_vpn_remove_data_item)
4718 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
4721 nm_setting_vpn_add_secret,
4723 _validate_vpn_hash_value)
4724 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret,
4726 nm_setting_vpn_remove_secret)
4728 /* --- NM_SETTING_WIMAX_SETTING_NAME property setter functions --- */
4729 /* No specific functions */
4731 /* --- NM_SETTING_WIRED_SETTING_NAME property setter functions --- */
4734 * Do not allow setting 'port' and 'duplex' for now. They are not implemented in
4735 * NM core, nor in ifcfg-rh plugin. Enable this when it gets done.
4738 static const char *wired_valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
4741 nmc_property_wired_set_port (NMSetting *setting, const char *prop, const char *val, GError **error)
4743 return check_and_set_string (setting, prop, val, wired_valid_ports, error);
4746 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_port, wired_valid_ports)
4749 static const char *wired_valid_duplexes[] = { "half", "full", NULL };
4752 nmc_property_wired_set_duplex (NMSetting *setting, const char *prop, const char *val, GError **error)
4754 return check_and_set_string (setting, prop, val, wired_valid_duplexes, error);
4757 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_duplex, wired_valid_duplexes)
4760 /* 'mac-address-blacklist' */
4761 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wired_set_mac_address_blacklist,
4763 nm_setting_wired_add_mac_blacklist_item)
4766 _validate_and_remove_wired_mac_blacklist_item (NMSettingWired *setting,
4773 if (!nm_utils_hwaddr_aton (mac, buf, ETH_ALEN)) {
4774 g_set_error (error, 1, 0, _("'%s' is not a valid MAC address"), mac);
4778 ret = nm_setting_wired_remove_mac_blacklist_item_by_value (setting, mac);
4780 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4783 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wired_remove_mac_address_blacklist,
4785 nm_setting_wired_get_num_mac_blacklist_items,
4786 nm_setting_wired_remove_mac_blacklist_item,
4787 _validate_and_remove_wired_mac_blacklist_item)
4789 /* 's390-subchannels' */
4791 nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, const char *val, GError **error)
4796 strv = nmc_strsplit_set (val, " ,\t", 0);
4797 len = g_strv_length (strv);
4798 if (len != 2 && len != 3) {
4799 g_set_error (error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"),
4805 g_object_set (setting, prop, strv, NULL);
4811 nmc_property_wired_describe_s390_subchannels (NMSetting *setting, const char *prop)
4813 return _("Enter a list of subchannels (comma or space separated).\n\n"
4814 "Example: 0.0.0e20 0.0.0e21 0.0.0e22\n");
4817 /* 's390-nettype' */
4818 static const char *wired_valid_s390_nettypes[] = { "qeth", "lcs", "ctc", NULL };
4821 nmc_property_wired_set_s390_nettype (NMSetting *setting, const char *prop, const char *val, GError **error)
4823 return check_and_set_string (setting, prop, val, wired_valid_s390_nettypes, error);
4826 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_s390_nettype, wired_valid_s390_nettypes)
4828 /* 's390-options' */
4829 /* Validate value of 's390-options' */
4831 _validate_s390_option_value (const char *option, const char *value, GError **error)
4833 /* nm_setting_wired_add_s390_option() requires value len in <1,199> interval */
4834 if (!value || !*value || strlen (value) >= 200) {
4835 g_set_error (error, 1, 0, _("'%s' string value should consist of 1 - 199 characters"), option);
4840 DEFINE_SETTER_OPTIONS (nmc_property_wired_set_s390_options,
4843 nm_setting_wired_add_s390_option,
4844 nm_setting_wired_get_valid_s390_options,
4845 _validate_s390_option_value)
4846 DEFINE_REMOVER_OPTION (nmc_property_wired_remove_option_s390_options,
4848 nm_setting_wired_remove_s390_option)
4850 static const char **
4851 nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop)
4853 return nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4857 nmc_property_wired_describe_s390_options (NMSetting *setting, const char *prop)
4859 static char *desc = NULL;
4860 const char **valid_options;
4863 if (G_UNLIKELY (desc == NULL)) {
4864 valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4865 options_str = g_strjoinv (", ", (char **) valid_options);
4867 desc = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n"
4868 " option = <value>, option = <value>,...\n"
4869 "Valid options are: %s\n"),
4871 g_free (options_str);
4876 /* --- NM_SETTING_WIRELESS_SETTING_NAME property setter functions --- */
4878 static const char *wifi_valid_modes[] = {
4879 NM_SETTING_WIRELESS_MODE_INFRA,
4880 NM_SETTING_WIRELESS_MODE_ADHOC,
4881 NM_SETTING_WIRELESS_MODE_AP,
4886 nmc_property_wifi_set_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
4888 return check_and_set_string (setting, prop, val, wifi_valid_modes, error);
4891 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_mode, wifi_valid_modes)
4894 static const char *wifi_valid_bands[] = { "a", "bg", NULL };
4897 nmc_property_wifi_set_band (NMSetting *setting, const char *prop, const char *val, GError **error)
4899 return check_and_set_string (setting, prop, val, wifi_valid_bands, error);
4902 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_band, wifi_valid_bands)
4906 nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4908 unsigned long chan_int;
4910 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4912 if (!nmc_string_to_uint (val, FALSE, 0, 0, &chan_int)) {
4913 g_set_error (error, 1, 0, _("'%s' is not a valid channel"), val);
4917 if ( !nm_utils_wifi_is_channel_valid (chan_int, "a")
4918 && !nm_utils_wifi_is_channel_valid (chan_int, "bg")) {
4919 g_set_error (error, 1, 0, _("'%ld' is not a valid channel"), chan_int);
4923 g_object_set (setting, prop, chan_int, NULL);
4927 /* 'mac-address-blacklist' */
4928 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wireless_set_mac_address_blacklist,
4929 NM_SETTING_WIRELESS,
4930 nm_setting_wireless_add_mac_blacklist_item)
4933 _validate_and_remove_wifi_mac_blacklist_item (NMSettingWireless *setting,
4940 if (!nm_utils_hwaddr_aton (mac, buf, ETH_ALEN)) {
4941 g_set_error (error, 1, 0, _("'%s' is not a valid MAC address"), mac);
4945 ret = nm_setting_wireless_remove_mac_blacklist_item_by_value (setting, mac);
4947 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4950 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wireless_remove_mac_address_blacklist,
4951 NM_SETTING_WIRELESS,
4952 nm_setting_wireless_get_num_mac_blacklist_items,
4953 nm_setting_wireless_remove_mac_blacklist_item,
4954 _validate_and_remove_wifi_mac_blacklist_item)
4958 nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const char *val, GError **error)
4960 NMSettingWirelessPowersave powersave;
4961 gs_free const char **options = NULL;
4962 gs_free char *options_str = NULL;
4966 if (nmc_string_to_int_base (val, 0, TRUE,
4967 NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4968 NM_SETTING_WIRELESS_POWERSAVE_LAST,
4970 powersave = (NMSettingWirelessPowersave) t;
4972 ret = nm_utils_enum_from_str (nm_setting_wireless_powersave_get_type (),
4977 options = nm_utils_enum_get_values (nm_setting_wireless_powersave_get_type (),
4978 NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4979 NM_SETTING_WIRELESS_POWERSAVE_LAST);
4980 options_str = g_strjoinv (",", (char **) options);
4981 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), val, options_str);
4986 g_object_set (setting, prop, (guint) powersave, NULL);
4991 nmc_property_wireless_set_mac_address_randomization (NMSetting *setting,
4996 NMSettingMacRandomization randomization;
4997 gs_free char *err_token = NULL;
5001 if (nmc_string_to_int_base (val, 0, TRUE,
5002 NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
5003 NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
5005 randomization = (NMSettingMacRandomization) t;
5007 ret = nm_utils_enum_from_str (nm_setting_mac_randomization_get_type (),
5009 (int *) &randomization,
5013 g_set_error (error, 1, 0, _("invalid option '%s', use 'default', 'never' or 'always'"),
5019 g_object_set (setting, prop, (guint) randomization, NULL);
5023 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property setter functions --- */
5025 static const char *wifi_sec_valid_key_mgmts[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
5028 nmc_property_wifi_sec_set_key_mgmt (NMSetting *setting, const char *prop, const char *val, GError **error)
5030 return check_and_set_string (setting, prop, val, wifi_sec_valid_key_mgmts, error);
5033 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_key_mgmt, wifi_sec_valid_key_mgmts)
5036 static const char *wifi_sec_valid_auth_algs[] = { "open", "shared", "leap", NULL };
5039 nmc_property_wifi_sec_set_auth_alg (NMSetting *setting, const char *prop, const char *val, GError **error)
5041 return check_and_set_string (setting, prop, val, wifi_sec_valid_auth_algs, error);
5044 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_auth_alg, wifi_sec_valid_auth_algs)
5047 static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL };
5049 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_proto,
5050 NM_SETTING_WIRELESS_SECURITY,
5051 nm_setting_wireless_security_add_proto)
5054 nmc_property_wifi_sec_set_proto (NMSetting *setting, const char *prop, const char *val, GError **error)
5056 return check_and_add_wifi_sec_proto (setting, prop, val, wifi_sec_valid_protos, error);
5060 _validate_and_remove_wifi_sec_proto (NMSettingWirelessSecurity *setting,
5067 valid = nmc_string_is_valid (proto, wifi_sec_valid_protos, error);
5071 ret = nm_setting_wireless_security_remove_proto_by_value (setting, proto);
5073 g_set_error (error, 1, 0,
5074 _("the property doesn't contain protocol '%s'"), proto);
5077 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_proto,
5078 NM_SETTING_WIRELESS_SECURITY,
5079 nm_setting_wireless_security_get_num_protos,
5080 nm_setting_wireless_security_remove_proto,
5081 _validate_and_remove_wifi_sec_proto)
5083 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_proto, wifi_sec_valid_protos)
5086 static const char *wifi_sec_valid_pairwises[] = { "tkip", "ccmp", NULL };
5088 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_pairwise,
5089 NM_SETTING_WIRELESS_SECURITY,
5090 nm_setting_wireless_security_add_pairwise)
5093 nmc_property_wifi_sec_set_pairwise (NMSetting *setting, const char *prop, const char *val, GError **error)
5095 return check_and_add_wifi_sec_pairwise (setting, prop, val, wifi_sec_valid_pairwises, error);
5099 _validate_and_remove_wifi_sec_pairwise (NMSettingWirelessSecurity *setting,
5100 const char *pairwise,
5106 valid = nmc_string_is_valid (pairwise, wifi_sec_valid_pairwises, error);
5110 ret = nm_setting_wireless_security_remove_pairwise_by_value (setting, pairwise);
5112 g_set_error (error, 1, 0,
5113 _("the property doesn't contain protocol '%s'"), pairwise);
5116 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_pairwise,
5117 NM_SETTING_WIRELESS_SECURITY,
5118 nm_setting_wireless_security_get_num_pairwise,
5119 nm_setting_wireless_security_remove_pairwise,
5120 _validate_and_remove_wifi_sec_pairwise)
5122 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_pairwise, wifi_sec_valid_pairwises)
5125 static const char *wifi_sec_valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
5127 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_group,
5128 NM_SETTING_WIRELESS_SECURITY,
5129 nm_setting_wireless_security_add_group)
5132 nmc_property_wifi_sec_set_group (NMSetting *setting, const char *prop, const char *val, GError **error)
5134 return check_and_add_wifi_sec_group (setting, prop, val, wifi_sec_valid_groups, error);
5138 _validate_and_remove_wifi_sec_group (NMSettingWirelessSecurity *setting,
5145 valid = nmc_string_is_valid (group, wifi_sec_valid_groups, error);
5149 ret = nm_setting_wireless_security_remove_group_by_value (setting, group);
5151 g_set_error (error, 1, 0,
5152 _("the property doesn't contain protocol '%s'"), group);
5155 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_group,
5156 NM_SETTING_WIRELESS_SECURITY,
5157 nm_setting_wireless_security_get_num_groups,
5158 nm_setting_wireless_security_remove_group,
5159 _validate_and_remove_wifi_sec_group)
5160 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_group, wifi_sec_valid_groups)
5164 nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char *val, GError **error)
5166 NMWepKeyType guessed_type = NM_WEP_KEY_TYPE_UNKNOWN;
5168 guint32 prev_idx, idx;
5170 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5172 /* Get currently set type */
5173 type = nm_setting_wireless_security_get_wep_key_type (NM_SETTING_WIRELESS_SECURITY (setting));
5175 /* Guess key type */
5176 if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_KEY))
5177 guessed_type = NM_WEP_KEY_TYPE_KEY;
5178 else if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_PASSPHRASE))
5179 guessed_type = NM_WEP_KEY_TYPE_PASSPHRASE;
5181 if (guessed_type == NM_WEP_KEY_TYPE_UNKNOWN) {
5182 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
5186 if (type != NM_WEP_KEY_TYPE_UNKNOWN && type != guessed_type) {
5187 if (nm_utils_wep_key_valid (val, type))
5188 guessed_type = type;
5190 g_set_error (error, 1, 0,
5191 _("'%s' not compatible with %s '%s', please change the key or set the right %s first."),
5192 val, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_key_type_to_string (type),
5193 NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
5197 prev_idx = nm_setting_wireless_security_get_wep_tx_keyidx (NM_SETTING_WIRELESS_SECURITY (setting));
5198 idx = prop[strlen (prop) - 1] - '0';
5199 g_print (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
5200 if (idx != prev_idx)
5201 g_print (_("WEP key index set to '%d'\n"), idx);
5203 g_object_set (setting, prop, val, NULL);
5204 g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, guessed_type, NULL);
5205 if (idx != prev_idx)
5206 g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, idx, NULL);
5210 /* 'wep-key-type' */
5212 nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const char *val, GError **error)
5214 unsigned long type_int;
5215 const char *valid_wep_types[] = { "unknown", "key", "passphrase", NULL };
5216 const char *type_str = NULL;
5217 const char *key0, *key1,* key2, *key3;
5218 NMWepKeyType type = NM_WEP_KEY_TYPE_UNKNOWN;
5220 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5222 if (!nmc_string_to_uint (val, TRUE, 0, 2, &type_int)) {
5223 if (!(type_str = nmc_string_is_valid (val, valid_wep_types, NULL))) {
5224 g_set_error (error, 1, 0, _("'%s' not among [0 (unknown), 1 (key), 2 (passphrase)]"), val);
5227 if (type_str == valid_wep_types[1])
5228 type = NM_WEP_KEY_TYPE_KEY;
5229 else if (type_str == valid_wep_types[2])
5230 type = NM_WEP_KEY_TYPE_PASSPHRASE;
5232 type = (NMWepKeyType) type_int;
5234 /* Check type compatibility with set keys */
5235 key0 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 0);
5236 key1 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 1);
5237 key2 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 2);
5238 key3 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 3);
5239 if (key0 && !nm_utils_wep_key_valid (key0, type))
5240 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5241 NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
5242 if (key1 && !nm_utils_wep_key_valid (key1, type))
5243 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5244 NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
5245 if (key2 && !nm_utils_wep_key_valid (key2, type))
5246 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5247 NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
5248 if (key3 && !nm_utils_wep_key_valid (key3, type))
5249 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5250 NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
5252 g_object_set (setting, prop, type, NULL);
5257 nmc_property_wifi_describe_wep_key_type (NMSetting *setting, const char *prop)
5259 static char *desc = NULL;
5261 if (G_UNLIKELY (desc == NULL)) {
5262 desc = g_strdup_printf (_("Enter the type of WEP keys. The accepted values are: "
5263 "0 or unknown, 1 or key, and 2 or passphrase.\n"));
5270 nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val, GError **error)
5272 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5274 if (!nm_utils_wpa_psk_valid (val)) {
5275 g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), val);
5278 g_object_set (setting, prop, val, NULL);
5282 #define DCB_ALL_FLAGS (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING)
5286 nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
5288 char **strv = NULL, **iter;
5289 NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5292 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5294 /* Check for overall hex numeric value */
5295 if (nmc_string_to_int_base (val, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5298 /* Check for individual flag numbers */
5299 strv = nmc_strsplit_set (val, " \t,", 0);
5300 for (iter = strv; iter && *iter; iter++) {
5301 if (!nmc_string_to_int_base (*iter, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5304 if ( g_ascii_strcasecmp (*iter, "enable") == 0
5305 || g_ascii_strcasecmp (*iter, "enabled") == 0
5306 || t == NM_SETTING_DCB_FLAG_ENABLE)
5307 flags |= NM_SETTING_DCB_FLAG_ENABLE;
5308 else if ( g_ascii_strcasecmp (*iter, "advertise") == 0
5309 || t == NM_SETTING_DCB_FLAG_ADVERTISE)
5310 flags |= NM_SETTING_DCB_FLAG_ADVERTISE;
5311 else if ( g_ascii_strcasecmp (*iter, "willing") == 0
5312 || t == NM_SETTING_DCB_FLAG_WILLING)
5313 flags |= NM_SETTING_DCB_FLAG_WILLING;
5314 else if ( g_ascii_strcasecmp (*iter, "disable") == 0
5315 || g_ascii_strcasecmp (*iter, "disabled") == 0
5319 g_set_error (error, 1, 0, _("'%s' is not a valid DCB flag"), *iter);
5326 /* Validate the flags according to the property spec */
5327 if (!validate_flags (setting, prop, (guint) flags, error))
5330 g_object_set (setting, prop, (guint) flags, NULL);
5335 nmc_property_dcb_set_priority (NMSetting *setting, const char *prop, const char *val, GError **error)
5337 long int priority = 0;
5339 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5341 if (!nmc_string_to_int (val, FALSE, -1, 7, &priority)) {
5342 g_set_error (error, 1, 0, _("'%s' is not a DCB app priority"), val);
5346 /* Validate the number according to the property spec */
5347 if (!validate_int (setting, prop, (gint) priority, error))
5350 g_object_set (setting, prop, (gint) priority, NULL);
5355 dcb_parse_uint_array (const char *val,
5361 char **items, **iter;
5364 g_return_val_if_fail (out_array != NULL, FALSE);
5366 items = g_strsplit_set (val, ",", -1);
5367 if (g_strv_length (items) != 8) {
5368 g_set_error_literal (error, 1, 0, _("must contain 8 comma-separated numbers"));
5372 for (iter = items; iter && *iter; iter++) {
5376 *iter = g_strstrip (*iter);
5377 success = nmc_string_to_int_base (*iter, 10, TRUE, 0, other ? other : max, &num);
5379 /* If number is greater than 'max' it must equal 'other' */
5380 if (success && other && (num > max) && (num != other))
5385 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive) or %u"),
5388 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive)"),
5393 out_array[i++] = (guint) num;
5404 dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop)
5406 NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5408 g_object_get (s_dcb, flags_prop, &flags, NULL);
5409 if (!(flags & NM_SETTING_DCB_FLAG_ENABLE))
5410 g_print (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
5414 nmc_property_dcb_set_pfc (NMSetting *setting, const char *prop, const char *val, GError **error)
5417 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5419 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5421 if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5424 for (i = 0; i < 8; i++)
5425 nm_setting_dcb_set_priority_flow_control (NM_SETTING_DCB (setting), i, !!nums[i]);
5427 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS);
5432 nmc_property_dcb_set_pg_group_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5435 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5437 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5439 if (!dcb_parse_uint_array (val, 7, 15, nums, error))
5442 for (i = 0; i < 8; i++)
5443 nm_setting_dcb_set_priority_group_id (NM_SETTING_DCB (setting), i, nums[i]);
5445 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5450 nmc_property_dcb_set_pg_group_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5452 guint i = 0, sum = 0;
5453 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5455 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5457 if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5460 for (i = 0; i < 8; i++)
5463 g_set_error_literal (error, 1, 0, _("bandwidth percentages must total 100%%"));
5467 for (i = 0; i < 8; i++)
5468 nm_setting_dcb_set_priority_group_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5470 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5475 nmc_property_dcb_set_pg_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5478 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5480 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5482 if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5485 for (i = 0; i < 8; i++)
5486 nm_setting_dcb_set_priority_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5488 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5493 nmc_property_dcb_set_pg_strict (NMSetting *setting, const char *prop, const char *val, GError **error)
5496 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5498 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5500 if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5503 for (i = 0; i < 8; i++)
5504 nm_setting_dcb_set_priority_strict_bandwidth (NM_SETTING_DCB (setting), i, !!nums[i]);
5506 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5511 nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, const char *val, GError **error)
5514 guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5516 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5518 if (!dcb_parse_uint_array (val, 7, 0, nums, error))
5521 for (i = 0; i < 8; i++)
5522 nm_setting_dcb_set_priority_traffic_class (NM_SETTING_DCB (setting), i, nums[i]);
5524 dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5528 /* 'app-fcoe-mode' */
5529 static const char *_dcb_valid_fcoe_modes[] = { NM_SETTING_DCB_FCOE_MODE_FABRIC,
5530 NM_SETTING_DCB_FCOE_MODE_VN2VN,
5534 nmc_property_dcb_set_app_fcoe_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
5536 return check_and_set_string (setting, prop, val, _dcb_valid_fcoe_modes, error);
5539 DEFINE_ALLOWED_VAL_FUNC (nmc_property_dcb_allowed_app_fcoe_modes, _dcb_valid_fcoe_modes)
5542 nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5544 const char *p = val;
5546 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5548 if (strlen (val) != 5 && strlen (val) != 6) {
5549 g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code"));
5554 if (!g_ascii_isdigit (*p++)) {
5555 g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code"));
5559 g_object_set (G_OBJECT (setting),
5560 NM_SETTING_GSM_SIM_OPERATOR_ID,
5567 nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
5569 NMSettingTun *s_tun = NM_SETTING_TUN (setting);
5570 NMSettingTunMode mode;
5573 mode = nm_setting_tun_get_mode (s_tun);
5574 tmp = nm_utils_enum_to_str (nm_setting_tun_mode_get_type (), mode);
5575 if (get_type == NMC_PROPERTY_GET_PARSABLE)
5576 str = g_strdup_printf ("%s", tmp ? tmp : "");
5578 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
5584 nmc_property_tun_set_mode (NMSetting *setting, const char *prop,
5585 const char *val, GError **error)
5587 NMSettingTunMode mode;
5591 if (nmc_string_to_int_base (val, 0, TRUE, 0, NM_SETTING_TUN_MODE_TAP, &t))
5592 mode = (NMSettingTunMode) t;
5594 ret = nm_utils_enum_from_str (nm_setting_tun_mode_get_type (), val,
5595 (int *) &mode, NULL);
5598 g_set_error (error, 1, 0, _("invalid option '%s', use '%s' or '%s'"),
5604 g_object_set (setting, prop, (guint) mode, NULL);
5608 static const char *tun_valid_modes[] = { "tun", "tap", "unknown", NULL };
5610 DEFINE_ALLOWED_VAL_FUNC (nmc_property_tun_allowed_mode, tun_valid_modes)
5612 /*----------------------------------------------------------------------------*/
5615 _nmc_add_prop_funcs (const char *key,
5616 const NmcPropertyFuncs *item_init)
5618 NmcPropertyFuncs *item;
5620 item = g_malloc (sizeof (NmcPropertyFuncs));
5622 g_hash_table_insert (nmc_properties, (gpointer) key, item);
5625 #define nmc_add_prop_funcs(key, ...) \
5628 NmcPropertyFuncsFields; \
5629 /* The _dummy field is here so that the last argument can be always
5630 * NULL. That means every call to nmc_add_prop_funcs() below ends
5631 * with a separate line "NULL);". */ \
5637 nm_assert (_item_init._dummy == NULL); \
5638 _nmc_add_prop_funcs ("" key, (NmcPropertyFuncs *) &_item_init); \
5641 /* concatenate setting name and property name */
5642 #define GLUE(A,B) "" NM_SETTING_##A##_SETTING_NAME "" NM_SETTING_##A##_##B ""
5643 #define GLUE_IP(A,B) "" NM_SETTING_IP##A##_CONFIG_SETTING_NAME "" NM_SETTING_IP_CONFIG_##B ""
5646 nmc_properties_init (void)
5648 if (G_LIKELY (nmc_properties))
5651 /* create properties hash table */
5652 nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
5654 /* Add editable properties for NM_SETTING_802_1X_SETTING_NAME */
5655 nmc_add_prop_funcs (GLUE (802_1X, EAP),
5656 nmc_property_802_1X_get_eap,
5657 nmc_property_802_1X_set_eap,
5658 nmc_property_802_1X_remove_eap,
5660 nmc_property_802_1X_allowed_eap,
5662 nmc_add_prop_funcs (GLUE (802_1X, IDENTITY),
5663 nmc_property_802_1X_get_identity,
5664 nmc_property_set_string,
5669 nmc_add_prop_funcs (GLUE (802_1X, ANONYMOUS_IDENTITY),
5670 nmc_property_802_1X_get_anonymous_identity,
5671 nmc_property_set_string,
5676 nmc_add_prop_funcs (GLUE (802_1X, PAC_FILE),
5677 nmc_property_802_1X_get_pac_file,
5678 nmc_property_set_string,
5683 nmc_add_prop_funcs (GLUE (802_1X, CA_CERT),
5684 nmc_property_802_1X_get_ca_cert,
5685 nmc_property_802_1X_set_ca_cert,
5687 nmc_property_802_1X_describe_ca_cert,
5690 nmc_add_prop_funcs (GLUE (802_1X, CA_PATH),
5691 nmc_property_802_1X_get_ca_path,
5692 nmc_property_set_string,
5697 nmc_add_prop_funcs (GLUE (802_1X, SUBJECT_MATCH),
5698 nmc_property_802_1X_get_subject_match,
5699 nmc_property_set_string,
5704 nmc_add_prop_funcs (GLUE (802_1X, ALTSUBJECT_MATCHES),
5705 nmc_property_802_1X_get_altsubject_matches,
5706 nmc_property_802_1X_set_altsubject_matches,
5707 nmc_property_802_1X_remove_altsubject_matches,
5711 nmc_add_prop_funcs (GLUE (802_1X, DOMAIN_SUFFIX_MATCH),
5712 nmc_property_802_1X_get_domain_suffix_match,
5713 nmc_property_set_string,
5718 nmc_add_prop_funcs (GLUE (802_1X, CLIENT_CERT),
5719 nmc_property_802_1X_get_client_cert,
5720 nmc_property_802_1X_set_client_cert,
5722 nmc_property_802_1X_describe_client_cert,
5725 nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPVER),
5726 nmc_property_802_1X_get_phase1_peapver,
5727 nmc_property_802_1X_set_phase1_peapver,
5730 nmc_property_802_1X_allowed_phase1_peapver,
5732 nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPLABEL),
5733 nmc_property_802_1X_get_phase1_peaplabel,
5734 nmc_property_802_1X_set_phase1_peaplabel,
5737 nmc_property_802_1X_allowed_phase1_peaplabel,
5739 nmc_add_prop_funcs (GLUE (802_1X, PHASE1_FAST_PROVISIONING),
5740 nmc_property_802_1X_get_phase1_fast_provisioning,
5741 nmc_property_802_1X_set_phase1_fast_provisioning,
5744 nmc_property_802_1X_allowed_phase1_fast_provisioning,
5746 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTH),
5747 nmc_property_802_1X_get_phase2_auth,
5748 nmc_property_802_1X_set_phase2_auth,
5751 nmc_property_802_1X_allowed_phase2_auth,
5753 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTHEAP),
5754 nmc_property_802_1X_get_phase2_autheap,
5755 nmc_property_802_1X_set_phase2_autheap,
5758 nmc_property_802_1X_allowed_phase2_autheap,
5760 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_CERT),
5761 nmc_property_802_1X_get_phase2_ca_cert,
5762 nmc_property_802_1X_set_phase2_ca_cert,
5764 nmc_property_802_1X_describe_phase2_ca_cert,
5767 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_PATH),
5768 nmc_property_802_1X_get_phase2_ca_path,
5769 nmc_property_set_string,
5774 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_SUBJECT_MATCH),
5775 nmc_property_802_1X_get_phase2_subject_match,
5776 nmc_property_set_string,
5781 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_ALTSUBJECT_MATCHES),
5782 nmc_property_802_1X_get_phase2_altsubject_matches,
5783 nmc_property_802_1X_set_phase2_altsubject_matches,
5784 nmc_property_802_1X_remove_phase2_altsubject_matches,
5788 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_DOMAIN_SUFFIX_MATCH),
5789 nmc_property_802_1X_get_phase2_domain_suffix_match,
5790 nmc_property_set_string,
5795 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CLIENT_CERT),
5796 nmc_property_802_1X_get_phase2_client_cert,
5797 nmc_property_802_1X_set_phase2_client_cert,
5799 nmc_property_802_1X_describe_phase2_client_cert,
5802 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD),
5803 nmc_property_802_1X_get_password,
5804 nmc_property_set_string,
5809 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_FLAGS),
5810 nmc_property_802_1X_get_password_flags,
5811 nmc_property_set_secret_flags,
5816 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW),
5817 nmc_property_802_1X_get_password_raw,
5818 nmc_property_802_1X_set_password_raw,
5820 nmc_property_802_1X_describe_password_raw,
5823 nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW_FLAGS),
5824 nmc_property_802_1X_get_password_raw_flags,
5825 nmc_property_set_secret_flags,
5830 nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY),
5831 nmc_property_802_1X_get_private_key,
5832 nmc_property_802_1X_set_private_key,
5834 nmc_property_802_1X_describe_private_key,
5837 nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD),
5838 nmc_property_802_1X_get_private_key_password,
5839 nmc_property_set_string,
5844 nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD_FLAGS),
5845 nmc_property_802_1X_get_private_key_password_flags,
5846 nmc_property_set_secret_flags,
5851 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY),
5852 nmc_property_802_1X_get_phase2_private_key,
5853 nmc_property_802_1X_set_phase2_private_key,
5855 nmc_property_802_1X_describe_private_key,
5858 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD),
5859 nmc_property_802_1X_get_phase2_private_key_password,
5860 nmc_property_set_string,
5865 nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD_FLAGS),
5866 nmc_property_802_1X_get_phase2_private_key_password_flags,
5867 nmc_property_set_secret_flags,
5872 nmc_add_prop_funcs (GLUE (802_1X, PIN),
5873 nmc_property_802_1X_get_pin,
5874 nmc_property_set_string,
5879 nmc_add_prop_funcs (GLUE (802_1X, PIN_FLAGS),
5880 nmc_property_802_1X_get_pin_flags,
5881 nmc_property_set_secret_flags,
5886 nmc_add_prop_funcs (GLUE (802_1X, SYSTEM_CA_CERTS),
5887 nmc_property_802_1X_get_system_ca_certs,
5888 nmc_property_set_bool,
5894 /* Add editable properties for NM_SETTING_ADSL_SETTING_NAME */
5895 nmc_add_prop_funcs (GLUE (ADSL, USERNAME),
5896 nmc_property_adsl_get_username,
5897 nmc_property_set_string,
5902 nmc_add_prop_funcs (GLUE (ADSL, PASSWORD),
5903 nmc_property_adsl_get_password,
5904 nmc_property_set_string,
5909 nmc_add_prop_funcs (GLUE (ADSL, PASSWORD_FLAGS),
5910 nmc_property_adsl_get_password_flags,
5911 nmc_property_set_secret_flags,
5916 nmc_add_prop_funcs (GLUE (ADSL, PROTOCOL),
5917 nmc_property_adsl_get_protocol,
5918 nmc_property_adsl_set_protocol,
5921 nmc_property_adsl_allowed_protocol,
5923 nmc_add_prop_funcs (GLUE (ADSL, ENCAPSULATION),
5924 nmc_property_adsl_get_encapsulation,
5925 nmc_property_adsl_set_encapsulation,
5928 nmc_property_adsl_allowed_encapsulation,
5930 nmc_add_prop_funcs (GLUE (ADSL, VPI),
5931 nmc_property_adsl_get_vpi,
5932 nmc_property_set_uint,
5937 nmc_add_prop_funcs (GLUE (ADSL, VCI),
5938 nmc_property_adsl_get_vci,
5939 nmc_property_set_uint,
5945 /* Add editable properties for NM_SETTING_BLUETOOTH_SETTING_NAME */
5946 nmc_add_prop_funcs (GLUE (BLUETOOTH, BDADDR),
5947 nmc_property_bluetooth_get_bdaddr,
5948 nmc_property_set_mac,
5953 nmc_add_prop_funcs (GLUE (BLUETOOTH, TYPE),
5954 nmc_property_bluetooth_get_type,
5955 nmc_property_bluetooth_set_type,
5961 /* Add editable properties for NM_SETTING_BOND_SETTING_NAME */
5962 nmc_add_prop_funcs (GLUE (BOND, OPTIONS),
5963 nmc_property_bond_get_options,
5964 nmc_property_bond_set_options,
5965 nmc_property_bond_remove_option_options,
5966 nmc_property_bond_describe_options,
5967 nmc_property_bond_allowed_options,
5970 /* Add editable properties for NM_SETTING_BRIDGE_SETTING_NAME */
5971 nmc_add_prop_funcs (GLUE (BRIDGE, MAC_ADDRESS),
5972 nmc_property_bridge_get_mac_address,
5973 nmc_property_set_mac,
5978 nmc_add_prop_funcs (GLUE (BRIDGE, STP),
5979 nmc_property_bridge_get_stp,
5980 nmc_property_set_bool,
5985 nmc_add_prop_funcs (GLUE (BRIDGE, PRIORITY),
5986 nmc_property_bridge_get_priority,
5987 nmc_property_set_uint,
5992 nmc_add_prop_funcs (GLUE (BRIDGE, FORWARD_DELAY),
5993 nmc_property_bridge_get_forward_delay,
5994 nmc_property_set_uint,
5999 nmc_add_prop_funcs (GLUE (BRIDGE, HELLO_TIME),
6000 nmc_property_bridge_get_hello_time,
6001 nmc_property_set_uint,
6006 nmc_add_prop_funcs (GLUE (BRIDGE, MAX_AGE),
6007 nmc_property_bridge_get_max_age,
6008 nmc_property_set_uint,
6013 nmc_add_prop_funcs (GLUE (BRIDGE, AGEING_TIME),
6014 nmc_property_bridge_get_ageing_time,
6015 nmc_property_set_uint,
6021 nmc_add_prop_funcs (GLUE (BRIDGE, MULTICAST_SNOOPING),
6022 nmc_property_bridge_get_multicast_snooping,
6023 nmc_property_set_bool,
6029 /* Add editable properties for NM_SETTING_BRIDGE_PORT_SETTING_NAME */
6030 nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PRIORITY),
6031 nmc_property_bridge_port_get_priority,
6032 nmc_property_set_uint,
6037 nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PATH_COST),
6038 nmc_property_bridge_port_get_path_cost,
6039 nmc_property_set_uint,
6044 nmc_add_prop_funcs (GLUE (BRIDGE_PORT, HAIRPIN_MODE),
6045 nmc_property_bridge_port_get_hairpin_mode,
6046 nmc_property_set_bool,
6052 /* Add editable properties for NM_SETTING_CDMA_SETTING_NAME */
6053 nmc_add_prop_funcs (GLUE (CDMA, NUMBER),
6054 nmc_property_cdma_get_number,
6055 nmc_property_set_string,
6060 nmc_add_prop_funcs (GLUE (CDMA, USERNAME),
6061 nmc_property_cdma_get_username,
6062 nmc_property_set_string,
6067 nmc_add_prop_funcs (GLUE (CDMA, PASSWORD),
6068 nmc_property_cdma_get_password,
6069 nmc_property_set_string,
6074 nmc_add_prop_funcs (GLUE (CDMA, PASSWORD_FLAGS),
6075 nmc_property_cdma_get_password_flags,
6076 nmc_property_set_secret_flags,
6082 /* Add editable properties for NM_SETTING_CONNECTION_SETTING_NAME */
6083 nmc_add_prop_funcs (GLUE (CONNECTION, ID),
6084 nmc_property_connection_get_id,
6085 nmc_property_set_string,
6090 nmc_add_prop_funcs (GLUE (CONNECTION, UUID),
6091 nmc_property_connection_get_uuid,
6092 NULL, /* forbid setting/removing UUID */
6097 nmc_add_prop_funcs (GLUE (CONNECTION, INTERFACE_NAME),
6098 nmc_property_connection_get_interface_name,
6099 nmc_property_set_ifname,
6104 nmc_add_prop_funcs (GLUE (CONNECTION, TYPE),
6105 nmc_property_connection_get_type,
6106 NULL, /* read-only */
6111 nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT),
6112 nmc_property_connection_get_autoconnect,
6113 nmc_property_set_bool,
6118 nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_PRIORITY),
6119 nmc_property_connection_get_autoconnect_priority,
6120 nmc_property_set_int,
6125 nmc_add_prop_funcs (GLUE (CONNECTION, TIMESTAMP),
6126 nmc_property_connection_get_timestamp,
6127 NULL, /* read-only */
6132 nmc_add_prop_funcs (GLUE (CONNECTION, READ_ONLY),
6133 nmc_property_connection_get_read_only,
6134 NULL, /* 'read-only' is read-only :-) */
6139 nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS),
6140 nmc_property_connection_get_permissions,
6141 nmc_property_connection_set_permissions,
6142 nmc_property_connection_remove_permissions,
6143 nmc_property_connection_describe_permissions,
6146 nmc_add_prop_funcs (GLUE (CONNECTION, ZONE),
6147 nmc_property_connection_get_zone,
6148 nmc_property_set_string,
6153 nmc_add_prop_funcs (GLUE (CONNECTION, MASTER),
6154 nmc_property_connection_get_master,
6155 nmc_property_con_set_master,
6160 nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE),
6161 nmc_property_connection_get_slave_type,
6162 nmc_property_con_set_slave_type,
6165 nmc_property_con_allowed_slave_type,
6167 nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_SLAVES),
6168 nmc_property_connection_get_autoconnect_slaves,
6169 nmc_property_set_trilean,
6174 nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES),
6175 nmc_property_connection_get_secondaries,
6176 nmc_property_connection_set_secondaries,
6177 nmc_property_connection_remove_secondaries,
6178 nmc_property_connection_describe_secondaries,
6181 nmc_add_prop_funcs (GLUE (CONNECTION, GATEWAY_PING_TIMEOUT),
6182 nmc_property_connection_get_gateway_ping_timeout,
6183 nmc_property_set_uint,
6188 nmc_add_prop_funcs (GLUE (CONNECTION, METERED),
6189 nmc_property_connection_get_metered,
6190 nmc_property_connection_set_metered,
6192 nmc_property_connection_describe_metered,
6195 nmc_add_prop_funcs (GLUE (CONNECTION, LLDP),
6196 nmc_property_connection_get_lldp,
6197 nmc_property_connection_set_lldp,
6203 /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */
6204 nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_FLAGS),
6205 nmc_property_dcb_get_app_fcoe_flags,
6206 nmc_property_dcb_set_flags,
6211 nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_MODE),
6212 nmc_property_dcb_get_app_fcoe_mode,
6213 nmc_property_dcb_set_app_fcoe_mode,
6216 nmc_property_dcb_allowed_app_fcoe_modes,
6218 nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_PRIORITY),
6219 nmc_property_dcb_get_app_fcoe_priority,
6220 nmc_property_dcb_set_priority,
6225 nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_FLAGS),
6226 nmc_property_dcb_get_app_iscsi_flags,
6227 nmc_property_dcb_set_flags,
6232 nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_PRIORITY),
6233 nmc_property_dcb_get_app_iscsi_priority,
6234 nmc_property_dcb_set_priority,
6239 nmc_add_prop_funcs (GLUE (DCB, APP_FIP_FLAGS),
6240 nmc_property_dcb_get_app_fip_flags,
6241 nmc_property_dcb_set_flags,
6246 nmc_add_prop_funcs (GLUE (DCB, APP_FIP_PRIORITY),
6247 nmc_property_dcb_get_app_fip_priority,
6248 nmc_property_dcb_set_priority,
6253 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL_FLAGS),
6254 nmc_property_dcb_get_pfc_flags,
6255 nmc_property_dcb_set_flags,
6260 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL),
6261 nmc_property_dcb_get_pfc,
6262 nmc_property_dcb_set_pfc,
6267 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_FLAGS),
6268 nmc_property_dcb_get_pg_flags,
6269 nmc_property_dcb_set_flags,
6274 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_ID),
6275 nmc_property_dcb_get_pg_group_id,
6276 nmc_property_dcb_set_pg_group_id,
6281 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_BANDWIDTH),
6282 nmc_property_dcb_get_pg_group_bandwidth,
6283 nmc_property_dcb_set_pg_group_bandwidth,
6288 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_BANDWIDTH),
6289 nmc_property_dcb_get_pg_bandwidth,
6290 nmc_property_dcb_set_pg_bandwidth,
6295 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_STRICT_BANDWIDTH),
6296 nmc_property_dcb_get_pg_strict,
6297 nmc_property_dcb_set_pg_strict,
6302 nmc_add_prop_funcs (GLUE (DCB, PRIORITY_TRAFFIC_CLASS),
6303 nmc_property_dcb_get_pg_traffic_class,
6304 nmc_property_dcb_set_pg_traffic_class,
6310 /* Add editable properties for NM_SETTING_GSM_SETTING_NAME */
6311 nmc_add_prop_funcs (GLUE (GSM, NUMBER),
6312 nmc_property_gsm_get_number,
6313 nmc_property_set_string,
6318 nmc_add_prop_funcs (GLUE (GSM, USERNAME),
6319 nmc_property_gsm_get_username,
6320 nmc_property_set_string,
6325 nmc_add_prop_funcs (GLUE (GSM, PASSWORD),
6326 nmc_property_gsm_get_password,
6327 nmc_property_set_string,
6332 nmc_add_prop_funcs (GLUE (GSM, PASSWORD_FLAGS),
6333 nmc_property_gsm_get_password_flags,
6334 nmc_property_set_secret_flags,
6339 nmc_add_prop_funcs (GLUE (GSM, APN),
6340 nmc_property_gsm_get_apn,
6341 nmc_property_set_string,
6346 nmc_add_prop_funcs (GLUE (GSM, NETWORK_ID),
6347 nmc_property_gsm_get_network_id,
6348 nmc_property_set_string,
6353 nmc_add_prop_funcs (GLUE (GSM, PIN),
6354 nmc_property_gsm_get_pin,
6355 nmc_property_set_string,
6360 nmc_add_prop_funcs (GLUE (GSM, PIN_FLAGS),
6361 nmc_property_gsm_get_pin_flags,
6362 nmc_property_set_secret_flags,
6367 nmc_add_prop_funcs (GLUE (GSM, HOME_ONLY),
6368 nmc_property_gsm_get_home_only,
6369 nmc_property_set_bool,
6374 nmc_add_prop_funcs (GLUE (GSM, DEVICE_ID),
6375 nmc_property_gsm_get_device_id,
6376 nmc_property_set_string,
6381 nmc_add_prop_funcs (GLUE (GSM, SIM_ID),
6382 nmc_property_gsm_get_sim_id,
6383 nmc_property_set_string,
6388 nmc_add_prop_funcs (GLUE (GSM, SIM_OPERATOR_ID),
6389 nmc_property_gsm_get_sim_operator_id,
6390 nmc_property_gsm_set_sim_operator_id,
6396 /* Add editable properties for NM_SETTING_INFINIBAND_SETTING_NAME */
6397 nmc_add_prop_funcs (GLUE (INFINIBAND, MAC_ADDRESS),
6398 nmc_property_ib_get_mac_address,
6399 nmc_property_ib_set_mac,
6404 nmc_add_prop_funcs (GLUE (INFINIBAND, MTU),
6405 nmc_property_ib_get_mtu,
6406 nmc_property_set_mtu,
6411 nmc_add_prop_funcs (GLUE (INFINIBAND, TRANSPORT_MODE),
6412 nmc_property_ib_get_transport_mode,
6413 nmc_property_ib_set_transport_mode,
6416 nmc_property_ib_allowed_transport_mode,
6418 nmc_add_prop_funcs (GLUE (INFINIBAND, P_KEY),
6419 nmc_property_ib_get_p_key,
6420 nmc_property_ib_set_p_key,
6425 nmc_add_prop_funcs (GLUE (INFINIBAND, PARENT),
6426 nmc_property_ib_get_parent,
6427 nmc_property_set_ifname,
6433 /* Add editable properties for NM_SETTING_IP4_CONFIG_SETTING_NAME */
6434 nmc_add_prop_funcs (GLUE_IP (4, METHOD),
6435 nmc_property_ipv4_get_method,
6436 nmc_property_ipv4_set_method,
6439 nmc_property_ipv4_allowed_method,
6441 nmc_add_prop_funcs (GLUE_IP (4, DNS),
6442 nmc_property_ipv4_get_dns,
6443 nmc_property_ipv4_set_dns,
6444 nmc_property_ipv4_remove_dns,
6445 nmc_property_ipv4_describe_dns,
6448 nmc_add_prop_funcs (GLUE_IP (4, DNS_SEARCH),
6449 nmc_property_ipv4_get_dns_search,
6450 nmc_property_ipv4_set_dns_search,
6451 nmc_property_ipv4_remove_dns_search,
6455 nmc_add_prop_funcs (GLUE_IP (4, DNS_OPTIONS),
6456 nmc_property_ipv4_get_dns_options,
6457 nmc_property_ipv4_set_dns_options,
6458 nmc_property_ipv4_remove_dns_option,
6462 nmc_add_prop_funcs (GLUE_IP (4, ADDRESSES),
6463 nmc_property_ip_get_addresses,
6464 nmc_property_ipv4_set_addresses,
6465 nmc_property_ipv4_remove_addresses,
6466 nmc_property_ipv4_describe_addresses,
6469 nmc_add_prop_funcs (GLUE_IP (4, GATEWAY),
6470 nmc_property_ipv4_get_gateway,
6471 nmc_property_ipv4_set_gateway,
6476 nmc_add_prop_funcs (GLUE_IP (4, ROUTES),
6477 nmc_property_ipv4_get_routes,
6478 nmc_property_ipv4_set_routes,
6479 nmc_property_ipv4_remove_routes,
6480 nmc_property_ipv4_describe_routes,
6483 nmc_add_prop_funcs (GLUE_IP (4, ROUTE_METRIC),
6484 nmc_property_ipv4_get_route_metric,
6485 nmc_property_set_int64,
6490 nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_ROUTES),
6491 nmc_property_ipv4_get_ignore_auto_routes,
6492 nmc_property_set_bool,
6497 nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_DNS),
6498 nmc_property_ipv4_get_ignore_auto_dns,
6499 nmc_property_set_bool,
6504 nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_CLIENT_ID),
6505 nmc_property_ipv4_get_dhcp_client_id,
6506 nmc_property_set_string,
6511 nmc_add_prop_funcs (GLUE_IP (4, DHCP_TIMEOUT),
6512 nmc_property_ipv4_get_dhcp_timeout,
6513 nmc_property_set_int,
6518 nmc_add_prop_funcs (GLUE_IP (4, DHCP_SEND_HOSTNAME),
6519 nmc_property_ipv4_get_dhcp_send_hostname,
6520 nmc_property_set_bool,
6525 nmc_add_prop_funcs (GLUE_IP (4, DHCP_HOSTNAME),
6526 nmc_property_ipv4_get_dhcp_hostname,
6527 nmc_property_set_string,
6532 nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_FQDN),
6533 nmc_property_ipv4_get_dhcp_fqdn,
6534 nmc_property_set_string,
6539 nmc_add_prop_funcs (GLUE_IP (4, NEVER_DEFAULT),
6540 nmc_property_ipv4_get_never_default,
6541 nmc_property_set_bool,
6546 nmc_add_prop_funcs (GLUE_IP (4, MAY_FAIL),
6547 nmc_property_ipv4_get_may_fail,
6548 nmc_property_set_bool,
6553 nmc_add_prop_funcs (GLUE_IP (4, DAD_TIMEOUT),
6554 nmc_property_ipv4_get_dad_timeout,
6555 nmc_property_set_int,
6561 /* Add editable properties for NM_SETTING_IP6_CONFIG_SETTING_NAME */
6562 nmc_add_prop_funcs (GLUE_IP (6, METHOD),
6563 nmc_property_ipv6_get_method,
6564 nmc_property_ipv6_set_method,
6567 nmc_property_ipv6_allowed_method,
6569 nmc_add_prop_funcs (GLUE_IP (6, DNS),
6570 nmc_property_ipv6_get_dns,
6571 nmc_property_ipv6_set_dns,
6572 nmc_property_ipv6_remove_dns,
6573 nmc_property_ipv6_describe_dns,
6576 nmc_add_prop_funcs (GLUE_IP (6, DNS_SEARCH),
6577 nmc_property_ipv6_get_dns_search,
6578 nmc_property_ipv6_set_dns_search,
6579 nmc_property_ipv6_remove_dns_search,
6583 nmc_add_prop_funcs (GLUE_IP (6, DNS_OPTIONS),
6584 nmc_property_ipv6_get_dns_options,
6585 nmc_property_ipv6_set_dns_options,
6586 nmc_property_ipv6_remove_dns_option,
6590 nmc_add_prop_funcs (GLUE_IP (6, ADDRESSES),
6591 nmc_property_ip_get_addresses,
6592 nmc_property_ipv6_set_addresses,
6593 nmc_property_ipv6_remove_addresses,
6594 nmc_property_ipv6_describe_addresses,
6597 nmc_add_prop_funcs (GLUE_IP (6, GATEWAY),
6598 nmc_property_ipv6_get_gateway,
6599 nmc_property_ipv6_set_gateway,
6604 nmc_add_prop_funcs (GLUE_IP (6, ROUTES),
6605 nmc_property_ipv6_get_routes,
6606 nmc_property_ipv6_set_routes,
6607 nmc_property_ipv6_remove_routes,
6608 nmc_property_ipv6_describe_routes,
6611 nmc_add_prop_funcs (GLUE_IP (6, ROUTE_METRIC),
6612 nmc_property_ipv6_get_route_metric,
6613 nmc_property_set_int64,
6618 nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_ROUTES),
6619 nmc_property_ipv6_get_ignore_auto_routes,
6620 nmc_property_set_bool,
6625 nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_DNS),
6626 nmc_property_ipv6_get_ignore_auto_dns,
6627 nmc_property_set_bool,
6632 nmc_add_prop_funcs (GLUE_IP (6, NEVER_DEFAULT),
6633 nmc_property_ipv6_get_never_default,
6634 nmc_property_set_bool,
6639 nmc_add_prop_funcs (GLUE_IP (6, MAY_FAIL),
6640 nmc_property_ipv6_get_may_fail,
6641 nmc_property_set_bool,
6646 nmc_add_prop_funcs (GLUE (IP6_CONFIG, IP6_PRIVACY),
6647 nmc_property_ipv6_get_ip6_privacy,
6648 nmc_property_ipv6_set_ip6_privacy,
6653 nmc_add_prop_funcs (GLUE (IP6_CONFIG, ADDR_GEN_MODE),
6654 nmc_property_ipv6_get_addr_gen_mode,
6655 nmc_property_ipv6_set_addr_gen_mode,
6660 nmc_add_prop_funcs (GLUE_IP (6, DHCP_SEND_HOSTNAME),
6661 nmc_property_ipv6_get_dhcp_send_hostname,
6662 nmc_property_set_bool,
6667 nmc_add_prop_funcs (GLUE_IP (6, DHCP_HOSTNAME),
6668 nmc_property_ipv6_get_dhcp_hostname,
6669 nmc_property_set_string,
6675 /* Add editable properties for NM_SETTING_OLPC_MESH_SETTING_NAME */
6676 nmc_add_prop_funcs (GLUE (OLPC_MESH, SSID),
6677 nmc_property_olpc_get_ssid,
6678 nmc_property_set_ssid,
6683 nmc_add_prop_funcs (GLUE (OLPC_MESH, CHANNEL),
6684 nmc_property_olpc_get_channel,
6685 nmc_property_olpc_set_channel,
6690 nmc_add_prop_funcs (GLUE (OLPC_MESH, DHCP_ANYCAST_ADDRESS),
6691 nmc_property_olpc_get_anycast_address,
6692 nmc_property_set_mac,
6698 /* Add editable properties for NM_SETTING_PPP_SETTING_NAME */
6699 nmc_add_prop_funcs (GLUE (PPP, NOAUTH),
6700 nmc_property_ppp_get_noauth,
6701 nmc_property_set_bool,
6706 nmc_add_prop_funcs (GLUE (PPP, REFUSE_EAP),
6707 nmc_property_ppp_get_refuse_eap,
6708 nmc_property_set_bool,
6713 nmc_add_prop_funcs (GLUE (PPP, REFUSE_PAP),
6714 nmc_property_ppp_get_refuse_pap,
6715 nmc_property_set_bool,
6720 nmc_add_prop_funcs (GLUE (PPP, REFUSE_CHAP),
6721 nmc_property_ppp_get_refuse_chap,
6722 nmc_property_set_bool,
6727 nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAP),
6728 nmc_property_ppp_get_refuse_mschap,
6729 nmc_property_set_bool,
6734 nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAPV2),
6735 nmc_property_ppp_get_refuse_mschapv2,
6736 nmc_property_set_bool,
6741 nmc_add_prop_funcs (GLUE (PPP, NOBSDCOMP),
6742 nmc_property_ppp_get_nobsdcomp,
6743 nmc_property_set_bool,
6748 nmc_add_prop_funcs (GLUE (PPP, NODEFLATE),
6749 nmc_property_ppp_get_nodeflate,
6750 nmc_property_set_bool,
6755 nmc_add_prop_funcs (GLUE (PPP, NO_VJ_COMP),
6756 nmc_property_ppp_get_no_vj_comp,
6757 nmc_property_set_bool,
6762 nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE),
6763 nmc_property_ppp_get_require_mppe,
6764 nmc_property_set_bool,
6769 nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE_128),
6770 nmc_property_ppp_get_require_mppe_128,
6771 nmc_property_set_bool,
6776 nmc_add_prop_funcs (GLUE (PPP, MPPE_STATEFUL),
6777 nmc_property_ppp_get_mppe_stateful,
6778 nmc_property_set_bool,
6783 nmc_add_prop_funcs (GLUE (PPP, CRTSCTS),
6784 nmc_property_ppp_get_crtscts,
6785 nmc_property_set_bool,
6790 nmc_add_prop_funcs (GLUE (PPP, BAUD),
6791 nmc_property_ppp_get_baud,
6792 nmc_property_set_uint,
6797 nmc_add_prop_funcs (GLUE (PPP, MRU),
6798 nmc_property_ppp_get_mru,
6799 nmc_property_set_uint,
6804 nmc_add_prop_funcs (GLUE (PPP, MTU),
6805 nmc_property_ppp_get_mtu,
6806 nmc_property_set_mtu,
6811 nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_FAILURE),
6812 nmc_property_ppp_get_lcp_echo_failure,
6813 nmc_property_set_uint,
6818 nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_INTERVAL),
6819 nmc_property_ppp_get_lcp_echo_interval,
6820 nmc_property_set_uint,
6826 /* Add editable properties for NM_SETTING_PPPOE_SETTING_NAME */
6827 nmc_add_prop_funcs (GLUE (PPPOE, SERVICE),
6828 nmc_property_pppoe_get_service,
6829 nmc_property_set_string,
6834 nmc_add_prop_funcs (GLUE (PPPOE, USERNAME),
6835 nmc_property_pppoe_get_username,
6836 nmc_property_set_string,
6841 nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD),
6842 nmc_property_pppoe_get_password,
6843 nmc_property_set_string,
6848 nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD_FLAGS),
6849 nmc_property_pppoe_get_password_flags,
6850 nmc_property_set_secret_flags,
6856 /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */
6857 nmc_add_prop_funcs (GLUE (SERIAL, BAUD),
6858 nmc_property_serial_get_baud,
6859 nmc_property_set_uint,
6864 nmc_add_prop_funcs (GLUE (SERIAL, BITS),
6865 nmc_property_serial_get_bits,
6866 nmc_property_set_uint,
6871 nmc_add_prop_funcs (GLUE (SERIAL, PARITY),
6872 nmc_property_serial_get_parity,
6873 nmc_property_serial_set_parity,
6878 nmc_add_prop_funcs (GLUE (SERIAL, STOPBITS),
6879 nmc_property_serial_get_stopbits,
6880 nmc_property_set_uint,
6885 nmc_add_prop_funcs (GLUE (SERIAL, SEND_DELAY),
6886 nmc_property_serial_get_send_delay,
6887 nmc_property_set_uint,
6893 /* Add editable properties for NM_SETTING_TEAM_SETTING_NAME */
6894 nmc_add_prop_funcs (GLUE (TEAM, CONFIG),
6895 nmc_property_team_get_config,
6896 nmc_property_team_set_config,
6898 nmc_property_team_describe_config,
6902 /* Add editable properties for NM_SETTING_TEAM_PORT_SETTING_NAME */
6903 nmc_add_prop_funcs (GLUE (TEAM_PORT, CONFIG),
6904 nmc_property_team_port_get_config,
6905 nmc_property_team_set_config,
6907 nmc_property_team_describe_config,
6911 /* Add editable properties for NM_SETTING_VLAN_SETTING_NAME */
6912 nmc_add_prop_funcs (GLUE (VLAN, PARENT),
6913 nmc_property_vlan_get_parent,
6914 nmc_property_set_string,
6919 nmc_add_prop_funcs (GLUE (VLAN, ID),
6920 nmc_property_vlan_get_id,
6921 nmc_property_set_uint,
6926 nmc_add_prop_funcs (GLUE (VLAN, FLAGS),
6927 nmc_property_vlan_get_flags,
6928 nmc_property_set_flags,
6933 nmc_add_prop_funcs (GLUE (VLAN, INGRESS_PRIORITY_MAP),
6934 nmc_property_vlan_get_ingress_priority_map,
6935 nmc_property_vlan_set_ingress_priority_map,
6936 nmc_property_vlan_remove_ingress_priority_map,
6940 nmc_add_prop_funcs (GLUE (VLAN, EGRESS_PRIORITY_MAP),
6941 nmc_property_vlan_get_egress_priority_map,
6942 nmc_property_vlan_set_egress_priority_map,
6943 nmc_property_vlan_remove_egress_priority_map,
6948 /* Add editable properties for NM_SETTING_VPN_SETTING_NAME */
6949 nmc_add_prop_funcs (GLUE (VPN, SERVICE_TYPE),
6950 nmc_property_vpn_get_service_type,
6951 nmc_property_set_string,
6956 nmc_add_prop_funcs (GLUE (VPN, USER_NAME),
6957 nmc_property_vpn_get_user_name,
6958 nmc_property_set_string,
6963 nmc_add_prop_funcs (GLUE (VPN, DATA),
6964 nmc_property_vpn_get_data,
6965 nmc_property_vpn_set_data,
6966 nmc_property_vpn_remove_option_data,
6970 nmc_add_prop_funcs (GLUE (VPN, SECRETS),
6971 nmc_property_vpn_get_secrets,
6972 nmc_property_vpn_set_secrets,
6973 nmc_property_vpn_remove_option_secret,
6977 nmc_add_prop_funcs (GLUE (VPN, PERSISTENT),
6978 nmc_property_vpn_get_persistent,
6979 nmc_property_set_bool,
6985 nmc_add_prop_funcs (GLUE (VPN, TIMEOUT),
6986 nmc_property_vpn_get_timeout,
6987 nmc_property_set_uint,
6993 /* Add editable properties for NM_SETTING_WIMAX_SETTING_NAME */
6994 nmc_add_prop_funcs (GLUE (WIMAX, NETWORK_NAME),
6995 nmc_property_wimax_get_network_name,
6996 nmc_property_set_string,
7001 nmc_add_prop_funcs (GLUE (WIMAX, MAC_ADDRESS),
7002 nmc_property_wimax_get_mac_address,
7003 nmc_property_set_mac,
7009 /* Add editable properties for NM_SETTING_WIRED_SETTING_NAME */
7010 nmc_add_prop_funcs (GLUE (WIRED, PORT),
7011 nmc_property_wired_get_port,
7012 NULL, /*nmc_property_wired_set_port,*/
7015 NULL, /*nmc_property_wired_allowed_port,*/
7017 nmc_add_prop_funcs (GLUE (WIRED, SPEED),
7018 nmc_property_wired_get_speed,
7024 nmc_add_prop_funcs (GLUE (WIRED, DUPLEX),
7025 nmc_property_wired_get_duplex,
7026 NULL, /*nmc_property_wired_set_duplex,*/
7030 NULL); /*nmc_property_wired_allowed_duplex);*/
7031 nmc_add_prop_funcs (GLUE (WIRED, AUTO_NEGOTIATE),
7032 nmc_property_wired_get_auto_negotiate,
7038 nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS),
7039 nmc_property_wired_get_mac_address,
7040 nmc_property_set_mac,
7045 nmc_add_prop_funcs (GLUE (WIRED, CLONED_MAC_ADDRESS),
7046 nmc_property_wired_get_cloned_mac_address,
7047 nmc_property_set_mac,
7052 nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS_BLACKLIST),
7053 nmc_property_wired_get_mac_address_blacklist,
7054 nmc_property_wired_set_mac_address_blacklist,
7055 nmc_property_wired_remove_mac_address_blacklist,
7059 nmc_add_prop_funcs (GLUE (WIRED, MTU),
7060 nmc_property_wired_get_mtu,
7061 nmc_property_set_mtu,
7066 nmc_add_prop_funcs (GLUE (WIRED, S390_SUBCHANNELS),
7067 nmc_property_wired_get_s390_subchannels,
7068 nmc_property_wired_set_s390_subchannels,
7070 nmc_property_wired_describe_s390_subchannels,
7073 nmc_add_prop_funcs (GLUE (WIRED, S390_NETTYPE),
7074 nmc_property_wired_get_s390_nettype,
7075 nmc_property_wired_set_s390_nettype,
7078 nmc_property_wired_allowed_s390_nettype,
7080 nmc_add_prop_funcs (GLUE (WIRED, S390_OPTIONS),
7081 nmc_property_wired_get_s390_options,
7082 nmc_property_wired_set_s390_options,
7083 nmc_property_wired_remove_option_s390_options,
7084 nmc_property_wired_describe_s390_options,
7085 nmc_property_wired_allowed_s390_options,
7087 nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN),
7088 nmc_property_wired_get_wake_on_lan,
7089 nmc_property_wired_set_wake_on_lan,
7094 nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN_PASSWORD),
7095 nmc_property_wired_get_wake_on_lan_password,
7096 nmc_property_set_mac,
7102 /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */
7103 nmc_add_prop_funcs (GLUE (WIRELESS, SSID),
7104 nmc_property_wireless_get_ssid,
7105 nmc_property_set_ssid,
7110 nmc_add_prop_funcs (GLUE (WIRELESS, MODE),
7111 nmc_property_wireless_get_mode,
7112 nmc_property_wifi_set_mode,
7115 nmc_property_wifi_allowed_mode,
7117 nmc_add_prop_funcs (GLUE (WIRELESS, BAND),
7118 nmc_property_wireless_get_band,
7119 nmc_property_wifi_set_band,
7122 nmc_property_wifi_allowed_band,
7124 nmc_add_prop_funcs (GLUE (WIRELESS, CHANNEL),
7125 nmc_property_wireless_get_channel,
7126 nmc_property_wifi_set_channel,
7131 nmc_add_prop_funcs (GLUE (WIRELESS, BSSID),
7132 nmc_property_wireless_get_bssid,
7133 nmc_property_set_mac,
7139 * Do not allow setting 'rate' and 'tx-power'. They are not implemented in
7140 * NM core, nor in ifcfg-rh plugin (thus not preserved over re-reading).
7142 nmc_add_prop_funcs (GLUE (WIRELESS, RATE),
7143 nmc_property_wireless_get_rate,
7144 NULL, /* editing rate disabled */
7149 nmc_add_prop_funcs (GLUE (WIRELESS, TX_POWER),
7150 nmc_property_wireless_get_tx_power,
7151 NULL, /* editing tx-power disabled */
7156 nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS),
7157 nmc_property_wireless_get_mac_address,
7158 nmc_property_set_mac,
7163 nmc_add_prop_funcs (GLUE (WIRELESS, CLONED_MAC_ADDRESS),
7164 nmc_property_wireless_get_cloned_mac_address,
7165 nmc_property_set_mac,
7170 nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_BLACKLIST),
7171 nmc_property_wireless_get_mac_address_blacklist,
7172 nmc_property_wireless_set_mac_address_blacklist,
7173 nmc_property_wireless_remove_mac_address_blacklist,
7177 nmc_add_prop_funcs (GLUE (WIRELESS, SEEN_BSSIDS),
7178 nmc_property_wireless_get_seen_bssids,
7179 NULL, /* read-only */
7184 nmc_add_prop_funcs (GLUE (WIRELESS, MTU),
7185 nmc_property_wireless_get_mtu,
7186 nmc_property_set_mtu,
7191 nmc_add_prop_funcs (GLUE (WIRELESS, HIDDEN),
7192 nmc_property_wireless_get_hidden,
7193 nmc_property_set_bool,
7198 nmc_add_prop_funcs (GLUE (WIRELESS, POWERSAVE),
7199 nmc_property_wireless_get_powersave,
7200 nmc_property_wireless_set_powersave,
7205 nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_RANDOMIZATION),
7206 nmc_property_wireless_get_mac_address_randomization,
7207 nmc_property_wireless_set_mac_address_randomization,
7213 /* Add editable properties for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */
7214 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, KEY_MGMT),
7215 nmc_property_wifi_sec_get_key_mgmt,
7216 nmc_property_wifi_sec_set_key_mgmt,
7219 nmc_property_wifi_sec_allowed_key_mgmt,
7221 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_TX_KEYIDX),
7222 nmc_property_wifi_sec_get_wep_tx_keyidx,
7223 nmc_property_set_uint,
7228 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, AUTH_ALG),
7229 nmc_property_wifi_sec_get_auth_alg,
7230 nmc_property_wifi_sec_set_auth_alg,
7233 nmc_property_wifi_sec_allowed_auth_alg,
7235 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PROTO),
7236 nmc_property_wifi_sec_get_proto,
7237 nmc_property_wifi_sec_set_proto,
7238 nmc_property_wifi_sec_remove_proto,
7240 nmc_property_wifi_sec_allowed_proto,
7242 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PAIRWISE),
7243 nmc_property_wifi_sec_get_pairwise,
7244 nmc_property_wifi_sec_set_pairwise,
7245 nmc_property_wifi_sec_remove_pairwise,
7247 nmc_property_wifi_sec_allowed_pairwise,
7249 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, GROUP),
7250 nmc_property_wifi_sec_get_group,
7251 nmc_property_wifi_sec_set_group,
7252 nmc_property_wifi_sec_remove_group,
7254 nmc_property_wifi_sec_allowed_group,
7256 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_USERNAME),
7257 nmc_property_wifi_sec_get_leap_username,
7258 nmc_property_set_string,
7263 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY0),
7264 nmc_property_wifi_sec_get_wep_key0,
7265 nmc_property_wifi_set_wep_key,
7270 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY1),
7271 nmc_property_wifi_sec_get_wep_key1,
7272 nmc_property_wifi_set_wep_key,
7277 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY2),
7278 nmc_property_wifi_sec_get_wep_key2,
7279 nmc_property_wifi_set_wep_key,
7284 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY3),
7285 nmc_property_wifi_sec_get_wep_key3,
7286 nmc_property_wifi_set_wep_key,
7291 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_FLAGS),
7292 nmc_property_wifi_sec_get_wep_key_flags,
7293 nmc_property_set_secret_flags,
7298 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_TYPE),
7299 nmc_property_wifi_sec_get_wep_key_type,
7300 nmc_property_wifi_set_wep_key_type,
7302 nmc_property_wifi_describe_wep_key_type,
7305 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK),
7306 nmc_property_wifi_sec_get_psk,
7307 nmc_property_wifi_set_psk,
7312 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK_FLAGS),
7313 nmc_property_wifi_sec_get_psk_flags,
7314 nmc_property_set_secret_flags,
7319 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD),
7320 nmc_property_wifi_sec_get_leap_password,
7321 nmc_property_set_string,
7326 nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD_FLAGS),
7327 nmc_property_wifi_sec_get_leap_password_flags,
7328 nmc_property_set_secret_flags,
7334 /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */
7335 nmc_add_prop_funcs (GLUE (TUN, MODE),
7336 nmc_property_tun_get_mode,
7337 nmc_property_tun_set_mode,
7340 nmc_property_tun_allowed_mode,
7342 nmc_add_prop_funcs (GLUE (TUN, OWNER),
7343 nmc_property_tun_get_owner,
7344 nmc_property_set_string,
7349 nmc_add_prop_funcs (GLUE (TUN, GROUP),
7350 nmc_property_tun_get_group,
7351 nmc_property_set_string,
7356 nmc_add_prop_funcs (GLUE (TUN, PI),
7357 nmc_property_tun_get_pi,
7358 nmc_property_set_bool,
7363 nmc_add_prop_funcs (GLUE (TUN, VNET_HDR),
7364 nmc_property_tun_get_vnet_hdr,
7365 nmc_property_set_bool,
7370 nmc_add_prop_funcs (GLUE (TUN, MULTI_QUEUE),
7371 nmc_property_tun_get_multi_queue,
7372 nmc_property_set_bool,
7378 /* Add editable properties for NM_SETTING_IP_TUNNEL_SETTING_NAME */
7379 nmc_add_prop_funcs (GLUE (IP_TUNNEL, MODE),
7380 nmc_property_ip_tunnel_get_mode,
7381 nmc_property_ip_tunnel_set_mode,
7384 nmc_property_ip_tunnel_allowed_mode,
7386 nmc_add_prop_funcs (GLUE (IP_TUNNEL, PARENT),
7387 nmc_property_ip_tunnel_get_parent,
7388 nmc_property_set_string,
7393 nmc_add_prop_funcs (GLUE (IP_TUNNEL, LOCAL),
7394 nmc_property_ip_tunnel_get_local,
7395 nmc_property_set_string,
7400 nmc_add_prop_funcs (GLUE (IP_TUNNEL, REMOTE),
7401 nmc_property_ip_tunnel_get_remote,
7402 nmc_property_set_string,
7407 nmc_add_prop_funcs (GLUE (IP_TUNNEL, TTL),
7408 nmc_property_ip_tunnel_get_ttl,
7409 nmc_property_set_uint,
7414 nmc_add_prop_funcs (GLUE (IP_TUNNEL, TOS),
7415 nmc_property_ip_tunnel_get_tos,
7416 nmc_property_set_uint,
7421 nmc_add_prop_funcs (GLUE (IP_TUNNEL, PATH_MTU_DISCOVERY),
7422 nmc_property_ip_tunnel_get_path_mtu_discovery,
7423 nmc_property_set_bool,
7428 nmc_add_prop_funcs (GLUE (IP_TUNNEL, INPUT_KEY),
7429 nmc_property_ip_tunnel_get_input_key,
7430 nmc_property_set_string,
7435 nmc_add_prop_funcs (GLUE (IP_TUNNEL, OUTPUT_KEY),
7436 nmc_property_ip_tunnel_get_output_key,
7437 nmc_property_set_string,
7442 nmc_add_prop_funcs (GLUE (IP_TUNNEL, ENCAPSULATION_LIMIT),
7443 nmc_property_ip_tunnel_get_encapsulation_limit,
7444 nmc_property_set_uint,
7449 nmc_add_prop_funcs (GLUE (IP_TUNNEL, FLOW_LABEL),
7450 nmc_property_ip_tunnel_get_flow_label,
7451 nmc_property_set_uint,
7456 nmc_add_prop_funcs (GLUE (IP_TUNNEL, MTU),
7457 nmc_property_ip_tunnel_get_mtu,
7458 nmc_property_set_uint,
7464 /* Add editable properties for NM_SETTING_MACVLAN_SETTING_NAME */
7465 nmc_add_prop_funcs (GLUE (MACVLAN, PARENT),
7466 nmc_property_macvlan_get_parent,
7467 nmc_property_set_string,
7472 nmc_add_prop_funcs (GLUE (MACVLAN, MODE),
7473 nmc_property_macvlan_get_mode,
7474 nmc_property_macvlan_set_mode,
7477 nmc_property_macvlan_allowed_mode,
7479 nmc_add_prop_funcs (GLUE (MACVLAN, PROMISCUOUS),
7480 nmc_property_macvlan_get_promiscuous,
7481 nmc_property_set_bool,
7486 nmc_add_prop_funcs (GLUE (MACVLAN, TAP),
7487 nmc_property_macvlan_get_tap,
7488 nmc_property_set_bool,
7494 /* Add editable properties for NM_SETTING_VXLAN_SETTING_NAME */
7495 nmc_add_prop_funcs (GLUE (VXLAN, PARENT),
7496 nmc_property_vxlan_get_parent,
7497 nmc_property_set_string,
7502 nmc_add_prop_funcs (GLUE (VXLAN, ID),
7503 nmc_property_vxlan_get_id,
7504 nmc_property_set_uint,
7509 nmc_add_prop_funcs (GLUE (VXLAN, LOCAL),
7510 nmc_property_vxlan_get_local,
7511 nmc_property_set_string,
7516 nmc_add_prop_funcs (GLUE (VXLAN, REMOTE),
7517 nmc_property_vxlan_get_remote,
7518 nmc_property_set_string,
7523 nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MIN),
7524 nmc_property_vxlan_get_source_port_min,
7525 nmc_property_set_uint,
7530 nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MAX),
7531 nmc_property_vxlan_get_source_port_max,
7532 nmc_property_set_uint,
7537 nmc_add_prop_funcs (GLUE (VXLAN, DESTINATION_PORT),
7538 nmc_property_vxlan_get_destination_port,
7539 nmc_property_set_uint,
7544 nmc_add_prop_funcs (GLUE (VXLAN, TOS),
7545 nmc_property_vxlan_get_tos,
7546 nmc_property_set_uint,
7551 nmc_add_prop_funcs (GLUE (VXLAN, TTL),
7552 nmc_property_vxlan_get_ttl,
7553 nmc_property_set_uint,
7558 nmc_add_prop_funcs (GLUE (VXLAN, AGEING),
7559 nmc_property_vxlan_get_ageing,
7560 nmc_property_set_uint,
7565 nmc_add_prop_funcs (GLUE (VXLAN, LIMIT),
7566 nmc_property_vxlan_get_limit,
7567 nmc_property_set_uint,
7572 nmc_add_prop_funcs (GLUE (VXLAN, LEARNING),
7573 nmc_property_vxlan_get_learning,
7574 nmc_property_set_bool,
7579 nmc_add_prop_funcs (GLUE (VXLAN, PROXY),
7580 nmc_property_vxlan_get_proxy,
7581 nmc_property_set_bool,
7586 nmc_add_prop_funcs (GLUE (VXLAN, RSC),
7587 nmc_property_vxlan_get_rsc,
7588 nmc_property_set_bool,
7593 nmc_add_prop_funcs (GLUE (VXLAN, L2_MISS),
7594 nmc_property_vxlan_get_l2_miss,
7595 nmc_property_set_bool,
7600 nmc_add_prop_funcs (GLUE (VXLAN, L3_MISS),
7601 nmc_property_vxlan_get_l3_miss,
7602 nmc_property_set_bool,
7610 nmc_properties_cleanup ()
7613 g_hash_table_destroy (nmc_properties);
7616 static const NmcPropertyFuncs *
7617 nmc_properties_find (const char *s_name, const char *p_name)
7622 nmc_properties_init ();
7624 s_l = strlen (s_name);
7625 p_l = strlen (p_name);
7626 key = g_alloca (s_l + p_l + 1);
7627 memcpy (&key[ 0], s_name, s_l);
7628 memcpy (&key[s_l], p_name, p_l + 1);
7629 return (NmcPropertyFuncs *) g_hash_table_lookup (nmc_properties, key);
7633 get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error)
7635 const NmcPropertyFuncs *item;
7637 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7638 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7640 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7641 if (item && item->get_func)
7642 return item->get_func (setting, get_type);
7644 g_set_error_literal (error, 1, 0, _("don't know how to get the property value"));
7649 * Generic function for getting property value.
7651 * Gets property value as a string by calling specialized functions.
7653 * Returns: current property value. The caller must free the returned string.
7656 nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error)
7658 return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, error);
7662 * Similar to nmc_setting_get_property(), but returns the property in a string
7663 * format that can be parsed via nmc_setting_set_property().
7666 nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError **error)
7668 return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, error);
7672 * Generic function for setting property value.
7674 * Sets property=val in setting by calling specialized functions.
7675 * If val is NULL then default property value is set.
7677 * Returns: TRUE on success; FALSE on failure and sets error
7680 nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error)
7682 const NmcPropertyFuncs *item;
7684 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7685 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7687 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7688 if (item && item->set_func) {
7690 /* No value argument sets default value */
7691 nmc_property_set_default_value (setting, prop);
7694 return item->set_func (setting, prop, val, error);
7697 g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7702 nmc_property_set_default_value (NMSetting *setting, const char *prop)
7704 GValue value = G_VALUE_INIT;
7705 GParamSpec *param_spec;
7707 param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7709 g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
7710 g_param_value_set_default (param_spec, &value);
7711 g_object_set_property (G_OBJECT (setting), prop, &value);
7716 * Generic function for reseting (single value) properties.
7718 * The function resets the property value to the default one. It respects
7719 * nmcli restrictions for changing properties. So if 'set_func' is NULL,
7720 * reseting the value is denied.
7722 * Returns: TRUE on success; FALSE on failure and sets error
7725 nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error)
7727 const NmcPropertyFuncs *item;
7729 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7730 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7732 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7733 if (item && item->set_func) {
7734 nmc_property_set_default_value (setting, prop);
7737 g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7742 * Generic function for removing items for collection-type properties.
7744 * If 'option' is not NULL, it tries to remove it, otherwise 'idx' is used.
7745 * For single-value properties (not having specialized remove function) this
7746 * function does nothing and just returns TRUE.
7748 * Returns: TRUE on success; FALSE on failure and sets error
7751 nmc_setting_remove_property_option (NMSetting *setting,
7757 const NmcPropertyFuncs *item;
7759 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7760 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7762 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7763 if (item && item->remove_func)
7764 return item->remove_func (setting, prop, option, idx, error);
7770 * Get valid property names for a setting.
7772 * Returns: string array with the properties or NULL on failure.
7773 * The returned value should be freed with g_strfreev()
7776 nmc_setting_get_valid_properties (NMSetting *setting)
7778 char **valid_props = NULL;
7779 GParamSpec **props, **iter;
7783 /* Iterate through properties */
7785 props = g_object_class_list_properties (G_OBJECT_GET_CLASS (G_OBJECT (setting)), &num);
7786 valid_props = g_malloc0 (sizeof (char*) * (num + 1));
7787 for (iter = props; iter && *iter; iter++) {
7788 const char *key_name = g_param_spec_get_name (*iter);
7790 /* Add all properties except for "name" that is non-editable */
7791 if (g_strcmp0 (key_name, "name") != 0)
7792 valid_props[i++] = g_strdup (key_name);
7794 valid_props[i] = NULL;
7801 * Return allowed values for 'prop' as a string.
7804 nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop)
7807 const NmcPropertyFuncs *item;
7809 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7811 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7812 if (item && item->values_func)
7813 return item->values_func (setting, prop);
7818 #if defined (BUILD_SETTING_DOCS) || defined (HAVE_SETTING_DOCS)
7819 #include "settings-docs.c"
7821 #define nmc_setting_get_property_doc(setting, prop) _("(not available)")
7825 * Create a description string for a property.
7827 * It returns a description got from property documentation, concatenated with
7828 * nmcli specific description (if it exists).
7830 * Returns: property description or NULL on failure. The caller must free the string.
7833 nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
7835 const NmcPropertyFuncs *item;
7836 const char *setting_desc = NULL;
7837 const char *setting_desc_title = "";
7838 const char *nmcli_desc = NULL;
7839 const char *nmcli_desc_title = "";
7840 const char *nmcli_nl = "";
7842 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7844 setting_desc = nmc_setting_get_property_doc (setting, prop);
7846 setting_desc_title = _("[NM property description]");
7848 item = nmc_properties_find (nm_setting_get_name (setting), prop);
7849 if (item && item->describe_func) {
7850 nmcli_desc = item->describe_func (setting, prop);
7851 nmcli_desc_title = _("[nmcli specific description]");
7855 return g_strdup_printf ("%s\n%s\n%s%s%s%s",
7857 setting_desc ? setting_desc : "",
7858 nmcli_nl, nmcli_desc_title, nmcli_nl,
7859 nmcli_desc ? nmcli_desc : "");
7863 * Gets setting:prop property value and returns it in 'value'.
7864 * Caller is responsible for freeing the GValue resources using g_value_unset()
7867 nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value)
7869 GParamSpec *param_spec;
7871 param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7873 memset (value, 0, sizeof (GValue));
7874 g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
7875 g_object_get_property (G_OBJECT (setting), prop, value);
7882 * Sets setting:prop property value from 'value'.
7885 nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value)
7887 GParamSpec *param_spec;
7889 param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7890 if (param_spec && G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (param_spec)) {
7891 g_object_set_property (G_OBJECT (setting), prop, value);
7897 /*----------------------------------------------------------------------------*/
7899 #define GET_SECRET(show, setting, func) \
7900 (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_("<hidden>")))
7903 setting_connection_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
7905 NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
7906 NmcOutputField *tmpl, *arr;
7909 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (s_con), FALSE);
7911 tmpl = nmc_fields_setting_connection;
7912 tmpl_len = sizeof (nmc_fields_setting_connection);
7913 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CONNECTION_ALL,
7914 tmpl, FALSE, NULL, NULL);
7915 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7916 g_ptr_array_add (nmc->output_data, arr);
7918 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7919 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7920 set_val_str (arr, 1, nmc_property_connection_get_id (setting, NMC_PROPERTY_GET_PRETTY));
7921 set_val_str (arr, 2, nmc_property_connection_get_uuid (setting, NMC_PROPERTY_GET_PRETTY));
7922 set_val_str (arr, 3, nmc_property_connection_get_interface_name (setting, NMC_PROPERTY_GET_PRETTY));
7923 set_val_str (arr, 4, nmc_property_connection_get_type (setting, NMC_PROPERTY_GET_PRETTY));
7924 set_val_str (arr, 5, nmc_property_connection_get_autoconnect (setting, NMC_PROPERTY_GET_PRETTY));
7925 set_val_str (arr, 6, nmc_property_connection_get_autoconnect_priority (setting, NMC_PROPERTY_GET_PRETTY));
7926 set_val_str (arr, 7, nmc_property_connection_get_timestamp (setting, NMC_PROPERTY_GET_PRETTY));
7927 set_val_str (arr, 8, nmc_property_connection_get_read_only (setting, NMC_PROPERTY_GET_PRETTY));
7928 set_val_str (arr, 9, nmc_property_connection_get_permissions (setting, NMC_PROPERTY_GET_PRETTY));
7929 set_val_str (arr, 10, nmc_property_connection_get_zone (setting, NMC_PROPERTY_GET_PRETTY));
7930 set_val_str (arr, 11, nmc_property_connection_get_master (setting, NMC_PROPERTY_GET_PRETTY));
7931 set_val_str (arr, 12, nmc_property_connection_get_slave_type (setting, NMC_PROPERTY_GET_PRETTY));
7932 set_val_str (arr, 13, nmc_property_connection_get_autoconnect_slaves (setting, NMC_PROPERTY_GET_PRETTY));
7933 set_val_str (arr, 14, nmc_property_connection_get_secondaries (setting, NMC_PROPERTY_GET_PRETTY));
7934 set_val_str (arr, 15, nmc_property_connection_get_gateway_ping_timeout (setting, NMC_PROPERTY_GET_PRETTY));
7935 set_val_str (arr, 16, nmc_property_connection_get_metered (setting, NMC_PROPERTY_GET_PRETTY));
7936 set_val_str (arr, 17, nmc_property_connection_get_lldp (setting, NMC_PROPERTY_GET_PRETTY));
7937 g_ptr_array_add (nmc->output_data, arr);
7939 print_data (nmc); /* Print all data */
7945 setting_wired_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
7947 NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
7948 NmcOutputField *tmpl, *arr;
7951 g_return_val_if_fail (NM_IS_SETTING_WIRED (s_wired), FALSE);
7953 tmpl = nmc_fields_setting_wired;
7954 tmpl_len = sizeof (nmc_fields_setting_wired);
7955 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRED_ALL,
7956 tmpl, FALSE, NULL, NULL);
7957 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7958 g_ptr_array_add (nmc->output_data, arr);
7960 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7961 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7962 set_val_str (arr, 1, nmc_property_wired_get_port (setting, NMC_PROPERTY_GET_PRETTY));
7963 set_val_str (arr, 2, nmc_property_wired_get_speed (setting, NMC_PROPERTY_GET_PRETTY));
7964 set_val_str (arr, 3, nmc_property_wired_get_duplex (setting, NMC_PROPERTY_GET_PRETTY));
7965 set_val_str (arr, 4, nmc_property_wired_get_auto_negotiate (setting, NMC_PROPERTY_GET_PRETTY));
7966 set_val_str (arr, 5, nmc_property_wired_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
7967 set_val_str (arr, 6, nmc_property_wired_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
7968 set_val_str (arr, 7, nmc_property_wired_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY));
7969 set_val_str (arr, 8, nmc_property_wired_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
7970 set_val_str (arr, 9, nmc_property_wired_get_s390_subchannels (setting, NMC_PROPERTY_GET_PRETTY));
7971 set_val_str (arr, 10, nmc_property_wired_get_s390_nettype (setting, NMC_PROPERTY_GET_PRETTY));
7972 set_val_str (arr, 11, nmc_property_wired_get_s390_options (setting, NMC_PROPERTY_GET_PRETTY));
7973 set_val_str (arr, 12, nmc_property_wired_get_wake_on_lan (setting, NMC_PROPERTY_GET_PRETTY));
7974 set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan_password (setting, NMC_PROPERTY_GET_PRETTY));
7975 g_ptr_array_add (nmc->output_data, arr);
7977 print_data (nmc); /* Print all data */
7983 setting_802_1X_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
7985 NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting);
7986 NmcOutputField *tmpl, *arr;
7989 g_return_val_if_fail (NM_IS_SETTING_802_1X (s_8021x), FALSE);
7991 tmpl = nmc_fields_setting_8021X;
7992 tmpl_len = sizeof (nmc_fields_setting_8021X);
7993 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_802_1X_ALL,
7994 tmpl, FALSE, NULL, NULL);
7995 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7996 g_ptr_array_add (nmc->output_data, arr);
7998 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7999 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8000 set_val_str (arr, 1, nmc_property_802_1X_get_eap (setting, NMC_PROPERTY_GET_PRETTY));
8001 set_val_str (arr, 2, nmc_property_802_1X_get_identity (setting, NMC_PROPERTY_GET_PRETTY));
8002 set_val_str (arr, 3, nmc_property_802_1X_get_anonymous_identity (setting, NMC_PROPERTY_GET_PRETTY));
8003 set_val_str (arr, 4, nmc_property_802_1X_get_pac_file (setting, NMC_PROPERTY_GET_PRETTY));
8004 set_val_str (arr, 5, nmc_property_802_1X_get_ca_cert (setting, NMC_PROPERTY_GET_PRETTY));
8005 set_val_str (arr, 6, nmc_property_802_1X_get_ca_path (setting, NMC_PROPERTY_GET_PRETTY));
8006 set_val_str (arr, 7, nmc_property_802_1X_get_subject_match (setting, NMC_PROPERTY_GET_PRETTY));
8007 set_val_str (arr, 8, nmc_property_802_1X_get_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY));
8008 set_val_str (arr, 9, nmc_property_802_1X_get_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY));
8009 set_val_str (arr, 10, nmc_property_802_1X_get_client_cert (setting, NMC_PROPERTY_GET_PRETTY));
8010 set_val_str (arr, 11, nmc_property_802_1X_get_phase1_peapver (setting, NMC_PROPERTY_GET_PRETTY));
8011 set_val_str (arr, 12, nmc_property_802_1X_get_phase1_peaplabel (setting, NMC_PROPERTY_GET_PRETTY));
8012 set_val_str (arr, 13, nmc_property_802_1X_get_phase1_fast_provisioning (setting, NMC_PROPERTY_GET_PRETTY));
8013 set_val_str (arr, 14, nmc_property_802_1X_get_phase2_auth (setting, NMC_PROPERTY_GET_PRETTY));
8014 set_val_str (arr, 15, nmc_property_802_1X_get_phase2_autheap (setting, NMC_PROPERTY_GET_PRETTY));
8015 set_val_str (arr, 16, nmc_property_802_1X_get_phase2_ca_cert (setting, NMC_PROPERTY_GET_PRETTY));
8016 set_val_str (arr, 17, nmc_property_802_1X_get_phase2_ca_path (setting, NMC_PROPERTY_GET_PRETTY));
8017 set_val_str (arr, 18, nmc_property_802_1X_get_phase2_subject_match (setting, NMC_PROPERTY_GET_PRETTY));
8018 set_val_str (arr, 19, nmc_property_802_1X_get_phase2_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY));
8019 set_val_str (arr, 20, nmc_property_802_1X_get_phase2_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY));
8020 set_val_str (arr, 21, nmc_property_802_1X_get_phase2_client_cert (setting, NMC_PROPERTY_GET_PRETTY));
8021 set_val_str (arr, 22, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password));
8022 set_val_str (arr, 23, nmc_property_802_1X_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8023 set_val_str (arr, 24, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password_raw));
8024 set_val_str (arr, 25, nmc_property_802_1X_get_password_raw_flags (setting, NMC_PROPERTY_GET_PRETTY));
8025 set_val_str (arr, 26, nmc_property_802_1X_get_private_key (setting, NMC_PROPERTY_GET_PRETTY));
8026 set_val_str (arr, 27, GET_SECRET (secrets, setting, nmc_property_802_1X_get_private_key_password));
8027 set_val_str (arr, 28, nmc_property_802_1X_get_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8028 set_val_str (arr, 29, nmc_property_802_1X_get_phase2_private_key (setting, NMC_PROPERTY_GET_PRETTY));
8029 set_val_str (arr, 30, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_private_key_password));
8030 set_val_str (arr, 31, nmc_property_802_1X_get_phase2_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8031 set_val_str (arr, 32, GET_SECRET (secrets, setting, nmc_property_802_1X_get_pin));
8032 set_val_str (arr, 33, nmc_property_802_1X_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY));
8033 set_val_str (arr, 34, nmc_property_802_1X_get_system_ca_certs (setting, NMC_PROPERTY_GET_PRETTY));
8034 g_ptr_array_add (nmc->output_data, arr);
8036 print_data (nmc); /* Print all data */
8042 setting_wireless_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8044 NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
8045 NmcOutputField *tmpl, *arr;
8048 g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE);
8050 tmpl = nmc_fields_setting_wireless;
8051 tmpl_len = sizeof (nmc_fields_setting_wireless);
8052 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_ALL,
8053 tmpl, FALSE, NULL, NULL);
8054 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8055 g_ptr_array_add (nmc->output_data, arr);
8057 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8058 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8059 set_val_str (arr, 1, nmc_property_wireless_get_ssid (setting, NMC_PROPERTY_GET_PRETTY));
8060 set_val_str (arr, 2, nmc_property_wireless_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8061 set_val_str (arr, 3, nmc_property_wireless_get_band (setting, NMC_PROPERTY_GET_PRETTY));
8062 set_val_str (arr, 4, nmc_property_wireless_get_channel (setting, NMC_PROPERTY_GET_PRETTY));
8063 set_val_str (arr, 5, nmc_property_wireless_get_bssid (setting, NMC_PROPERTY_GET_PRETTY));
8064 set_val_str (arr, 6, nmc_property_wireless_get_rate (setting, NMC_PROPERTY_GET_PRETTY));
8065 set_val_str (arr, 7, nmc_property_wireless_get_tx_power (setting, NMC_PROPERTY_GET_PRETTY));
8066 set_val_str (arr, 8, nmc_property_wireless_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8067 set_val_str (arr, 9, nmc_property_wireless_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8068 set_val_str (arr, 10, nmc_property_wireless_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY));
8069 set_val_str (arr, 11, nmc_property_wireless_get_mac_address_randomization (setting, NMC_PROPERTY_GET_PRETTY));
8070 set_val_str (arr, 12, nmc_property_wireless_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8071 set_val_str (arr, 13, nmc_property_wireless_get_seen_bssids (setting, NMC_PROPERTY_GET_PRETTY));
8072 set_val_str (arr, 14, nmc_property_wireless_get_hidden (setting, NMC_PROPERTY_GET_PRETTY));
8073 set_val_str (arr, 15, nmc_property_wireless_get_powersave (setting, NMC_PROPERTY_GET_PRETTY));
8074 g_ptr_array_add (nmc->output_data, arr);
8076 print_data (nmc); /* Print all data */
8082 setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8084 NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
8085 NmcOutputField *tmpl, *arr;
8088 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (s_wireless_sec), FALSE);
8090 tmpl = nmc_fields_setting_wireless_security;
8091 tmpl_len = sizeof (nmc_fields_setting_wireless_security);
8092 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_SECURITY_ALL,
8093 tmpl, FALSE, NULL, NULL);
8094 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8095 g_ptr_array_add (nmc->output_data, arr);
8097 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8098 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8099 set_val_str (arr, 1, nmc_property_wifi_sec_get_key_mgmt (setting, NMC_PROPERTY_GET_PRETTY));
8100 set_val_str (arr, 2, nmc_property_wifi_sec_get_wep_tx_keyidx (setting, NMC_PROPERTY_GET_PRETTY));
8101 set_val_str (arr, 3, nmc_property_wifi_sec_get_auth_alg (setting, NMC_PROPERTY_GET_PRETTY));
8102 set_val_str (arr, 4, nmc_property_wifi_sec_get_proto (setting, NMC_PROPERTY_GET_PRETTY));
8103 set_val_str (arr, 5, nmc_property_wifi_sec_get_pairwise (setting, NMC_PROPERTY_GET_PRETTY));
8104 set_val_str (arr, 6, nmc_property_wifi_sec_get_group (setting, NMC_PROPERTY_GET_PRETTY));
8105 set_val_str (arr, 7, nmc_property_wifi_sec_get_leap_username (setting, NMC_PROPERTY_GET_PRETTY));
8106 set_val_str (arr, 8, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key0));
8107 set_val_str (arr, 9, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key1));
8108 set_val_str (arr, 10, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key2));
8109 set_val_str (arr, 11, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key3));
8110 set_val_str (arr, 12, nmc_property_wifi_sec_get_wep_key_flags (setting, NMC_PROPERTY_GET_PRETTY));
8111 set_val_str (arr, 13, nmc_property_wifi_sec_get_wep_key_type (setting, NMC_PROPERTY_GET_PRETTY));
8112 set_val_str (arr, 14, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_psk));
8113 set_val_str (arr, 15, nmc_property_wifi_sec_get_psk_flags (setting, NMC_PROPERTY_GET_PRETTY));
8114 set_val_str (arr, 16, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_leap_password));
8115 set_val_str (arr, 17, nmc_property_wifi_sec_get_leap_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8116 g_ptr_array_add (nmc->output_data, arr);
8118 print_data (nmc); /* Print all data */
8124 setting_ip4_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8126 NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting);
8127 NmcOutputField *tmpl, *arr;
8130 g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (s_ip4), FALSE);
8132 tmpl = nmc_fields_setting_ip4_config;
8133 tmpl_len = sizeof (nmc_fields_setting_ip4_config);
8134 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP4_CONFIG_ALL,
8135 tmpl, FALSE, NULL, NULL);
8136 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8137 g_ptr_array_add (nmc->output_data, arr);
8139 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8140 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8141 set_val_str (arr, 1, nmc_property_ipv4_get_method (setting, NMC_PROPERTY_GET_PRETTY));
8142 set_val_str (arr, 2, nmc_property_ipv4_get_dns (setting, NMC_PROPERTY_GET_PRETTY));
8143 set_val_str (arr, 3, nmc_property_ipv4_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY));
8144 set_val_str (arr, 4, nmc_property_ipv4_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY));
8145 set_val_str (arr, 5, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY));
8146 set_val_str (arr, 6, nmc_property_ipv4_get_gateway (setting, NMC_PROPERTY_GET_PRETTY));
8147 set_val_str (arr, 7, nmc_property_ipv4_get_routes (setting, NMC_PROPERTY_GET_PRETTY));
8148 set_val_str (arr, 8, nmc_property_ipv4_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY));
8149 set_val_str (arr, 9, nmc_property_ipv4_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
8150 set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
8151 set_val_str (arr, 11, nmc_property_ipv4_get_dhcp_client_id (setting, NMC_PROPERTY_GET_PRETTY));
8152 set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8153 set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8154 set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8155 set_val_str (arr, 15, nmc_property_ipv4_get_dhcp_fqdn (setting, NMC_PROPERTY_GET_PRETTY));
8156 set_val_str (arr, 16, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
8157 set_val_str (arr, 17, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
8158 set_val_str (arr, 18, nmc_property_ipv4_get_dad_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8159 g_ptr_array_add (nmc->output_data, arr);
8161 print_data (nmc); /* Print all data */
8167 setting_ip6_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8169 NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting);
8170 NmcOutputField *tmpl, *arr;
8173 g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (s_ip6), FALSE);
8175 tmpl = nmc_fields_setting_ip6_config;
8176 tmpl_len = sizeof (nmc_fields_setting_ip6_config);
8177 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP6_CONFIG_ALL,
8178 tmpl, FALSE, NULL, NULL);
8179 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8180 g_ptr_array_add (nmc->output_data, arr);
8182 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8183 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8184 set_val_str (arr, 1, nmc_property_ipv6_get_method (setting, NMC_PROPERTY_GET_PRETTY));
8185 set_val_str (arr, 2, nmc_property_ipv6_get_dns (setting, NMC_PROPERTY_GET_PRETTY));
8186 set_val_str (arr, 3, nmc_property_ipv6_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY));
8187 set_val_str (arr, 4, nmc_property_ipv6_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY));
8188 set_val_str (arr, 5, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY));
8189 set_val_str (arr, 6, nmc_property_ipv6_get_gateway (setting, NMC_PROPERTY_GET_PRETTY));
8190 set_val_str (arr, 7, nmc_property_ipv6_get_routes (setting, NMC_PROPERTY_GET_PRETTY));
8191 set_val_str (arr, 8, nmc_property_ipv6_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY));
8192 set_val_str (arr, 9, nmc_property_ipv6_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
8193 set_val_str (arr, 10, nmc_property_ipv6_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
8194 set_val_str (arr, 11, nmc_property_ipv6_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
8195 set_val_str (arr, 12, nmc_property_ipv6_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
8196 set_val_str (arr, 13, nmc_property_ipv6_get_ip6_privacy (setting, NMC_PROPERTY_GET_PRETTY));
8197 set_val_str (arr, 14, nmc_property_ipv6_get_addr_gen_mode (setting, NMC_PROPERTY_GET_PRETTY));
8198 set_val_str (arr, 15, nmc_property_ipv6_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8199 set_val_str (arr, 16, nmc_property_ipv6_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8200 g_ptr_array_add (nmc->output_data, arr);
8202 print_data (nmc); /* Print all data */
8208 setting_serial_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8210 NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
8211 NmcOutputField *tmpl, *arr;
8214 g_return_val_if_fail (NM_IS_SETTING_SERIAL (s_serial), FALSE);
8216 tmpl = nmc_fields_setting_serial;
8217 tmpl_len = sizeof (nmc_fields_setting_serial);
8218 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_SERIAL_ALL,
8219 tmpl, FALSE, NULL, NULL);
8220 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8221 g_ptr_array_add (nmc->output_data, arr);
8223 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8224 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8225 set_val_str (arr, 1, nmc_property_serial_get_baud (setting, NMC_PROPERTY_GET_PRETTY));
8226 set_val_str (arr, 2, nmc_property_serial_get_bits (setting, NMC_PROPERTY_GET_PRETTY));
8227 set_val_str (arr, 3, nmc_property_serial_get_parity (setting, NMC_PROPERTY_GET_PRETTY));
8228 set_val_str (arr, 4, nmc_property_serial_get_stopbits (setting, NMC_PROPERTY_GET_PRETTY));
8229 set_val_str (arr, 5, nmc_property_serial_get_send_delay (setting, NMC_PROPERTY_GET_PRETTY));
8230 g_ptr_array_add (nmc->output_data, arr);
8232 print_data (nmc); /* Print all data */
8238 setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8240 NMSettingPpp *s_ppp = NM_SETTING_PPP (setting);
8241 NmcOutputField *tmpl, *arr;
8244 g_return_val_if_fail (NM_IS_SETTING_PPP (s_ppp), FALSE);
8246 tmpl = nmc_fields_setting_ppp;
8247 tmpl_len = sizeof (nmc_fields_setting_ppp);
8248 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPP_ALL,
8249 tmpl, FALSE, NULL, NULL);
8250 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8251 g_ptr_array_add (nmc->output_data, arr);
8253 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8254 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8255 set_val_str (arr, 1, nmc_property_ppp_get_noauth (setting, NMC_PROPERTY_GET_PRETTY));
8256 set_val_str (arr, 2, nmc_property_ppp_get_refuse_eap (setting, NMC_PROPERTY_GET_PRETTY));
8257 set_val_str (arr, 3, nmc_property_ppp_get_refuse_pap (setting, NMC_PROPERTY_GET_PRETTY));
8258 set_val_str (arr, 4, nmc_property_ppp_get_refuse_chap (setting, NMC_PROPERTY_GET_PRETTY));
8259 set_val_str (arr, 5, nmc_property_ppp_get_refuse_mschap (setting, NMC_PROPERTY_GET_PRETTY));
8260 set_val_str (arr, 6, nmc_property_ppp_get_refuse_mschapv2 (setting, NMC_PROPERTY_GET_PRETTY));
8261 set_val_str (arr, 7, nmc_property_ppp_get_nobsdcomp (setting, NMC_PROPERTY_GET_PRETTY));
8262 set_val_str (arr, 8, nmc_property_ppp_get_nodeflate (setting, NMC_PROPERTY_GET_PRETTY));
8263 set_val_str (arr, 9, nmc_property_ppp_get_no_vj_comp (setting, NMC_PROPERTY_GET_PRETTY));
8264 set_val_str (arr, 10, nmc_property_ppp_get_require_mppe (setting, NMC_PROPERTY_GET_PRETTY));
8265 set_val_str (arr, 11, nmc_property_ppp_get_require_mppe_128 (setting, NMC_PROPERTY_GET_PRETTY));
8266 set_val_str (arr, 12, nmc_property_ppp_get_mppe_stateful (setting, NMC_PROPERTY_GET_PRETTY));
8267 set_val_str (arr, 13, nmc_property_ppp_get_crtscts (setting, NMC_PROPERTY_GET_PRETTY));
8268 set_val_str (arr, 14, nmc_property_ppp_get_baud (setting, NMC_PROPERTY_GET_PRETTY));
8269 set_val_str (arr, 15, nmc_property_ppp_get_mru (setting, NMC_PROPERTY_GET_PRETTY));
8270 set_val_str (arr, 16, nmc_property_ppp_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8271 set_val_str (arr, 17, nmc_property_ppp_get_lcp_echo_failure (setting, NMC_PROPERTY_GET_PRETTY));
8272 set_val_str (arr, 18, nmc_property_ppp_get_lcp_echo_interval (setting, NMC_PROPERTY_GET_PRETTY));
8273 g_ptr_array_add (nmc->output_data, arr);
8275 print_data (nmc); /* Print all data */
8281 setting_pppoe_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8283 NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting);
8284 NmcOutputField *tmpl, *arr;
8287 g_return_val_if_fail (NM_IS_SETTING_PPPOE (s_pppoe), FALSE);
8289 tmpl = nmc_fields_setting_pppoe;
8290 tmpl_len = sizeof (nmc_fields_setting_pppoe);
8291 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPPOE_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_pppoe_get_service (setting, NMC_PROPERTY_GET_PRETTY));
8299 set_val_str (arr, 2, nmc_property_pppoe_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8300 set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_pppoe_get_password));
8301 set_val_str (arr, 4, nmc_property_pppoe_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8302 g_ptr_array_add (nmc->output_data, arr);
8304 print_data (nmc); /* Print all data */
8310 setting_gsm_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8312 NMSettingGsm *s_gsm = NM_SETTING_GSM (setting);
8313 NmcOutputField *tmpl, *arr;
8316 g_return_val_if_fail (NM_IS_SETTING_GSM (s_gsm), FALSE);
8318 tmpl = nmc_fields_setting_gsm;
8319 tmpl_len = sizeof (nmc_fields_setting_gsm);
8320 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_GSM_ALL,
8321 tmpl, FALSE, NULL, NULL);
8322 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8323 g_ptr_array_add (nmc->output_data, arr);
8325 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8326 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8327 set_val_str (arr, 1, nmc_property_gsm_get_number (setting, NMC_PROPERTY_GET_PRETTY));
8328 set_val_str (arr, 2, nmc_property_gsm_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8329 set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_gsm_get_password));
8330 set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8331 set_val_str (arr, 5, nmc_property_gsm_get_apn (setting, NMC_PROPERTY_GET_PRETTY));
8332 set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting, NMC_PROPERTY_GET_PRETTY));
8333 set_val_str (arr, 7, GET_SECRET (secrets, setting, nmc_property_gsm_get_pin));
8334 set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY));
8335 set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting, NMC_PROPERTY_GET_PRETTY));
8336 set_val_str (arr, 10, nmc_property_gsm_get_device_id (setting, NMC_PROPERTY_GET_PRETTY));
8337 set_val_str (arr, 11, nmc_property_gsm_get_sim_id (setting, NMC_PROPERTY_GET_PRETTY));
8338 set_val_str (arr, 12, nmc_property_gsm_get_sim_operator_id (setting, NMC_PROPERTY_GET_PRETTY));
8339 g_ptr_array_add (nmc->output_data, arr);
8341 print_data (nmc); /* Print all data */
8347 setting_cdma_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8349 NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting);
8350 NmcOutputField *tmpl, *arr;
8353 g_return_val_if_fail (NM_IS_SETTING_CDMA (s_cdma), FALSE);
8355 tmpl = nmc_fields_setting_cdma;
8356 tmpl_len = sizeof (nmc_fields_setting_cdma);
8357 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CDMA_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_cdma_get_number (setting, NMC_PROPERTY_GET_PRETTY));
8365 set_val_str (arr, 2, nmc_property_cdma_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8366 set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_cdma_get_password));
8367 set_val_str (arr, 4, nmc_property_cdma_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8368 g_ptr_array_add (nmc->output_data, arr);
8370 print_data (nmc); /* Print all data */
8376 setting_bluetooth_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8378 NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting);
8379 NmcOutputField *tmpl, *arr;
8382 g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (s_bluetooth), FALSE);
8384 tmpl = nmc_fields_setting_bluetooth;
8385 tmpl_len = sizeof (nmc_fields_setting_bluetooth);
8386 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BLUETOOTH_ALL,
8387 tmpl, FALSE, NULL, NULL);
8388 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8389 g_ptr_array_add (nmc->output_data, arr);
8391 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8392 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8393 set_val_str (arr, 1, nmc_property_bluetooth_get_bdaddr (setting, NMC_PROPERTY_GET_PRETTY));
8394 set_val_str (arr, 2, nmc_property_bluetooth_get_type (setting, NMC_PROPERTY_GET_PRETTY));
8395 g_ptr_array_add (nmc->output_data, arr);
8397 print_data (nmc); /* Print all data */
8403 setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8405 NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
8406 NmcOutputField *tmpl, *arr;
8409 g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (s_olpc_mesh), FALSE);
8411 tmpl = nmc_fields_setting_olpc_mesh;
8412 tmpl_len = sizeof (nmc_fields_setting_olpc_mesh);
8413 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_OLPC_MESH_ALL,
8414 tmpl, FALSE, NULL, NULL);
8415 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8416 g_ptr_array_add (nmc->output_data, arr);
8418 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8419 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8420 set_val_str (arr, 1, nmc_property_olpc_get_ssid (setting, NMC_PROPERTY_GET_PRETTY));
8421 set_val_str (arr, 2, nmc_property_olpc_get_channel (setting, NMC_PROPERTY_GET_PRETTY));
8422 set_val_str (arr, 3, nmc_property_olpc_get_anycast_address (setting, NMC_PROPERTY_GET_PRETTY));
8423 g_ptr_array_add (nmc->output_data, arr);
8425 print_data (nmc); /* Print all data */
8431 setting_vpn_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8433 NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
8434 NmcOutputField *tmpl, *arr;
8437 g_return_val_if_fail (NM_IS_SETTING_VPN (s_vpn), FALSE);
8439 tmpl = nmc_fields_setting_vpn;
8440 tmpl_len = sizeof (nmc_fields_setting_vpn);
8441 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VPN_ALL,
8442 tmpl, FALSE, NULL, NULL);
8443 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8444 g_ptr_array_add (nmc->output_data, arr);
8446 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8447 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8448 set_val_str (arr, 1, nmc_property_vpn_get_service_type (setting, NMC_PROPERTY_GET_PRETTY));
8449 set_val_str (arr, 2, nmc_property_vpn_get_user_name (setting, NMC_PROPERTY_GET_PRETTY));
8450 set_val_str (arr, 3, nmc_property_vpn_get_data (setting, NMC_PROPERTY_GET_PRETTY));
8451 set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_vpn_get_secrets));
8452 set_val_str (arr, 5, nmc_property_vpn_get_persistent (setting, NMC_PROPERTY_GET_PRETTY));
8453 set_val_str (arr, 6, nmc_property_vpn_get_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8454 g_ptr_array_add (nmc->output_data, arr);
8456 print_data (nmc); /* Print all data */
8462 setting_wimax_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8464 NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting);
8465 NmcOutputField *tmpl, *arr;
8468 g_return_val_if_fail (NM_IS_SETTING_WIMAX (s_wimax), FALSE);
8470 tmpl = nmc_fields_setting_wimax;
8471 tmpl_len = sizeof (nmc_fields_setting_wimax);
8472 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIMAX_ALL,
8473 tmpl, FALSE, NULL, NULL);
8474 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8475 g_ptr_array_add (nmc->output_data, arr);
8477 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8478 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8479 set_val_str (arr, 1, nmc_property_wimax_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8480 set_val_str (arr, 2, nmc_property_wimax_get_network_name (setting, NMC_PROPERTY_GET_PRETTY));
8481 g_ptr_array_add (nmc->output_data, arr);
8483 print_data (nmc); /* Print all data */
8489 setting_infiniband_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8491 NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
8492 NmcOutputField *tmpl, *arr;
8495 g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (s_infiniband), FALSE);
8497 tmpl = nmc_fields_setting_infiniband;
8498 tmpl_len = sizeof (nmc_fields_setting_infiniband);
8499 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_INFINIBAND_ALL,
8500 tmpl, FALSE, NULL, NULL);
8501 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8502 g_ptr_array_add (nmc->output_data, arr);
8504 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8505 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8506 set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8507 set_val_str (arr, 2, nmc_property_ib_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8508 set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting, NMC_PROPERTY_GET_PRETTY));
8509 set_val_str (arr, 4, nmc_property_ib_get_p_key (setting, NMC_PROPERTY_GET_PRETTY));
8510 set_val_str (arr, 5, nmc_property_ib_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8511 g_ptr_array_add (nmc->output_data, arr);
8513 print_data (nmc); /* Print all data */
8519 setting_bond_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8521 NMSettingBond *s_bond = NM_SETTING_BOND (setting);
8522 NmcOutputField *tmpl, *arr;
8525 g_return_val_if_fail (NM_IS_SETTING_BOND (s_bond), FALSE);
8527 tmpl = nmc_fields_setting_bond;
8528 tmpl_len = sizeof (nmc_fields_setting_bond);
8529 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BOND_ALL,
8530 tmpl, FALSE, NULL, NULL);
8531 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8532 g_ptr_array_add (nmc->output_data, arr);
8534 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8535 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8536 set_val_str (arr, 1, nmc_property_bond_get_options (setting, NMC_PROPERTY_GET_PRETTY));
8537 g_ptr_array_add (nmc->output_data, arr);
8539 print_data (nmc); /* Print all data */
8545 setting_vlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8547 NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
8548 NmcOutputField *tmpl, *arr;
8551 g_return_val_if_fail (NM_IS_SETTING_VLAN (s_vlan), FALSE);
8553 tmpl = nmc_fields_setting_vlan;
8554 tmpl_len = sizeof (nmc_fields_setting_vlan);
8555 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VLAN_ALL,
8556 tmpl, FALSE, NULL, NULL);
8557 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8558 g_ptr_array_add (nmc->output_data, arr);
8560 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8561 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8562 set_val_str (arr, 1, nmc_property_vlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8563 set_val_str (arr, 2, nmc_property_vlan_get_id (setting, NMC_PROPERTY_GET_PRETTY));
8564 set_val_str (arr, 3, nmc_property_vlan_get_flags (setting, NMC_PROPERTY_GET_PRETTY));
8565 set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting, NMC_PROPERTY_GET_PRETTY));
8566 set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting, NMC_PROPERTY_GET_PRETTY));
8567 g_ptr_array_add (nmc->output_data, arr);
8569 print_data (nmc); /* Print all data */
8575 setting_adsl_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8577 NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting);
8578 NmcOutputField *tmpl, *arr;
8581 g_return_val_if_fail (NM_IS_SETTING_ADSL (s_adsl), FALSE);
8583 tmpl = nmc_fields_setting_adsl;
8584 tmpl_len = sizeof (nmc_fields_setting_adsl);
8585 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_ADSL_ALL,
8586 tmpl, FALSE, NULL, NULL);
8587 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8588 g_ptr_array_add (nmc->output_data, arr);
8590 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8591 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8592 set_val_str (arr, 1, nmc_property_adsl_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8593 set_val_str (arr, 2, GET_SECRET (secrets, setting, nmc_property_adsl_get_password));
8594 set_val_str (arr, 3, nmc_property_adsl_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8595 set_val_str (arr, 4, nmc_property_adsl_get_protocol (setting, NMC_PROPERTY_GET_PRETTY));
8596 set_val_str (arr, 5, nmc_property_adsl_get_encapsulation (setting, NMC_PROPERTY_GET_PRETTY));
8597 set_val_str (arr, 6, nmc_property_adsl_get_vpi (setting, NMC_PROPERTY_GET_PRETTY));
8598 set_val_str (arr, 7, nmc_property_adsl_get_vci (setting, NMC_PROPERTY_GET_PRETTY));
8599 g_ptr_array_add (nmc->output_data, arr);
8601 print_data (nmc); /* Print all data */
8607 setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8609 NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting);
8610 NmcOutputField *tmpl, *arr;
8613 g_return_val_if_fail (NM_IS_SETTING_BRIDGE (s_bridge), FALSE);
8615 tmpl = nmc_fields_setting_bridge;
8616 tmpl_len = sizeof (nmc_fields_setting_bridge);
8617 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_ALL,
8618 tmpl, FALSE, NULL, NULL);
8619 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8620 g_ptr_array_add (nmc->output_data, arr);
8622 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8623 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8624 set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8625 set_val_str (arr, 2, nmc_property_bridge_get_stp (setting, NMC_PROPERTY_GET_PRETTY));
8626 set_val_str (arr, 3, nmc_property_bridge_get_priority (setting, NMC_PROPERTY_GET_PRETTY));
8627 set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting, NMC_PROPERTY_GET_PRETTY));
8628 set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting, NMC_PROPERTY_GET_PRETTY));
8629 set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting, NMC_PROPERTY_GET_PRETTY));
8630 set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting, NMC_PROPERTY_GET_PRETTY));
8631 set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting, NMC_PROPERTY_GET_PRETTY));
8632 g_ptr_array_add (nmc->output_data, arr);
8634 print_data (nmc); /* Print all data */
8640 setting_bridge_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8642 NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting);
8643 NmcOutputField *tmpl, *arr;
8646 g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (s_bridge_port), FALSE);
8648 tmpl = nmc_fields_setting_bridge_port;
8649 tmpl_len = sizeof (nmc_fields_setting_bridge_port);
8650 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_PORT_ALL,
8651 tmpl, FALSE, NULL, NULL);
8652 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8653 g_ptr_array_add (nmc->output_data, arr);
8655 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8656 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8657 set_val_str (arr, 1, nmc_property_bridge_port_get_priority (setting, NMC_PROPERTY_GET_PRETTY));
8658 set_val_str (arr, 2, nmc_property_bridge_port_get_path_cost (setting, NMC_PROPERTY_GET_PRETTY));
8659 set_val_str (arr, 3, nmc_property_bridge_port_get_hairpin_mode (setting, NMC_PROPERTY_GET_PRETTY));
8660 g_ptr_array_add (nmc->output_data, arr);
8662 print_data (nmc); /* Print all data */
8668 setting_team_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8670 NMSettingTeam *s_team = NM_SETTING_TEAM (setting);
8671 NmcOutputField *tmpl, *arr;
8674 g_return_val_if_fail (NM_IS_SETTING_TEAM (s_team), FALSE);
8676 tmpl = nmc_fields_setting_team;
8677 tmpl_len = sizeof (nmc_fields_setting_team);
8678 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_ALL,
8679 tmpl, FALSE, NULL, NULL);
8680 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8681 g_ptr_array_add (nmc->output_data, arr);
8683 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8684 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8685 set_val_str (arr, 1, nmc_property_team_get_config (setting, NMC_PROPERTY_GET_PRETTY));
8686 g_ptr_array_add (nmc->output_data, arr);
8688 print_data (nmc); /* Print all data */
8694 setting_team_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8696 NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting);
8697 NmcOutputField *tmpl, *arr;
8700 g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (s_team_port), FALSE);
8702 tmpl = nmc_fields_setting_team_port;
8703 tmpl_len = sizeof (nmc_fields_setting_team_port);
8704 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_PORT_ALL,
8705 tmpl, FALSE, NULL, NULL);
8706 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8707 g_ptr_array_add (nmc->output_data, arr);
8709 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8710 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8711 set_val_str (arr, 1, nmc_property_team_port_get_config (setting, NMC_PROPERTY_GET_PRETTY));
8712 g_ptr_array_add (nmc->output_data, arr);
8714 print_data (nmc); /* Print all data */
8720 setting_dcb_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8722 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting);
8723 NmcOutputField *tmpl, *arr;
8726 g_return_val_if_fail (NM_IS_SETTING_DCB (s_dcb), FALSE);
8728 tmpl = nmc_fields_setting_dcb;
8729 tmpl_len = sizeof (nmc_fields_setting_dcb);
8730 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_DCB_ALL,
8731 tmpl, FALSE, NULL, NULL);
8732 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8733 g_ptr_array_add (nmc->output_data, arr);
8735 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8736 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8737 set_val_str (arr, 1, nmc_property_dcb_get_app_fcoe_flags (setting, NMC_PROPERTY_GET_PRETTY));
8738 set_val_str (arr, 2, nmc_property_dcb_get_app_fcoe_priority (setting, NMC_PROPERTY_GET_PRETTY));
8739 set_val_str (arr, 3, nmc_property_dcb_get_app_fcoe_mode (setting, NMC_PROPERTY_GET_PRETTY));
8740 set_val_str (arr, 4, nmc_property_dcb_get_app_iscsi_flags (setting, NMC_PROPERTY_GET_PRETTY));
8741 set_val_str (arr, 5, nmc_property_dcb_get_app_iscsi_priority (setting, NMC_PROPERTY_GET_PRETTY));
8742 set_val_str (arr, 6, nmc_property_dcb_get_app_fip_flags (setting, NMC_PROPERTY_GET_PRETTY));
8743 set_val_str (arr, 7, nmc_property_dcb_get_app_fip_priority (setting, NMC_PROPERTY_GET_PRETTY));
8744 set_val_str (arr, 8, nmc_property_dcb_get_pfc_flags (setting, NMC_PROPERTY_GET_PRETTY));
8745 set_val_str (arr, 9, nmc_property_dcb_get_pfc (setting, NMC_PROPERTY_GET_PRETTY));
8746 set_val_str (arr, 10, nmc_property_dcb_get_pg_flags (setting, NMC_PROPERTY_GET_PRETTY));
8747 set_val_str (arr, 11, nmc_property_dcb_get_pg_group_id (setting, NMC_PROPERTY_GET_PRETTY));
8748 set_val_str (arr, 12, nmc_property_dcb_get_pg_group_bandwidth (setting, NMC_PROPERTY_GET_PRETTY));
8749 set_val_str (arr, 13, nmc_property_dcb_get_pg_bandwidth (setting, NMC_PROPERTY_GET_PRETTY));
8750 set_val_str (arr, 14, nmc_property_dcb_get_pg_strict (setting, NMC_PROPERTY_GET_PRETTY));
8751 set_val_str (arr, 15, nmc_property_dcb_get_pg_traffic_class (setting, NMC_PROPERTY_GET_PRETTY));
8752 g_ptr_array_add (nmc->output_data, arr);
8754 print_data (nmc); /* Print all data */
8760 setting_tun_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8762 NMSettingTun *s_tun = NM_SETTING_TUN (setting);
8763 NmcOutputField *tmpl, *arr;
8766 g_return_val_if_fail (NM_IS_SETTING_TUN (s_tun), FALSE);
8768 tmpl = nmc_fields_setting_tun;
8769 tmpl_len = sizeof (nmc_fields_setting_tun);
8770 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TUN_ALL,
8771 tmpl, FALSE, NULL, NULL);
8772 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8773 g_ptr_array_add (nmc->output_data, arr);
8775 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8776 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8777 set_val_str (arr, 1, nmc_property_tun_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8778 set_val_str (arr, 2, nmc_property_tun_get_owner (setting, NMC_PROPERTY_GET_PRETTY));
8779 set_val_str (arr, 3, nmc_property_tun_get_group (setting, NMC_PROPERTY_GET_PRETTY));
8780 set_val_str (arr, 4, nmc_property_tun_get_pi (setting, NMC_PROPERTY_GET_PRETTY));
8781 set_val_str (arr, 5, nmc_property_tun_get_vnet_hdr (setting, NMC_PROPERTY_GET_PRETTY));
8782 set_val_str (arr, 6, nmc_property_tun_get_multi_queue (setting, NMC_PROPERTY_GET_PRETTY));
8783 g_ptr_array_add (nmc->output_data, arr);
8785 print_data (nmc); /* Print all data */
8791 setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8793 NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
8794 NmcOutputField *tmpl, *arr;
8797 g_return_val_if_fail (NM_IS_SETTING_IP_TUNNEL (s_ip_tunnel), FALSE);
8799 tmpl = nmc_fields_setting_ip_tunnel;
8800 tmpl_len = sizeof (nmc_fields_setting_ip_tunnel);
8801 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP_TUNNEL_ALL,
8802 tmpl, FALSE, NULL, NULL);
8803 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8804 g_ptr_array_add (nmc->output_data, arr);
8806 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8807 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8808 set_val_str (arr, 1, nmc_property_ip_tunnel_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8809 set_val_str (arr, 2, nmc_property_ip_tunnel_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8810 set_val_str (arr, 3, nmc_property_ip_tunnel_get_local (setting, NMC_PROPERTY_GET_PRETTY));
8811 set_val_str (arr, 4, nmc_property_ip_tunnel_get_remote (setting, NMC_PROPERTY_GET_PRETTY));
8812 set_val_str (arr, 5, nmc_property_ip_tunnel_get_ttl (setting, NMC_PROPERTY_GET_PRETTY));
8813 set_val_str (arr, 6, nmc_property_ip_tunnel_get_tos (setting, NMC_PROPERTY_GET_PRETTY));
8814 set_val_str (arr, 7, nmc_property_ip_tunnel_get_path_mtu_discovery (setting, NMC_PROPERTY_GET_PRETTY));
8815 set_val_str (arr, 8, nmc_property_ip_tunnel_get_input_key (setting, NMC_PROPERTY_GET_PRETTY));
8816 set_val_str (arr, 9, nmc_property_ip_tunnel_get_output_key (setting, NMC_PROPERTY_GET_PRETTY));
8817 set_val_str (arr, 10, nmc_property_ip_tunnel_get_encapsulation_limit (setting, NMC_PROPERTY_GET_PRETTY));
8818 set_val_str (arr, 11, nmc_property_ip_tunnel_get_flow_label (setting, NMC_PROPERTY_GET_PRETTY));
8819 set_val_str (arr, 12, nmc_property_ip_tunnel_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8820 g_ptr_array_add (nmc->output_data, arr);
8822 print_data (nmc); /* Print all data */
8828 setting_macvlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8830 NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
8831 NmcOutputField *tmpl, *arr;
8834 g_return_val_if_fail (NM_IS_SETTING_MACVLAN (s_macvlan), FALSE);
8836 tmpl = nmc_fields_setting_macvlan;
8837 tmpl_len = sizeof (nmc_fields_setting_macvlan);
8838 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_MACVLAN_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_macvlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8846 set_val_str (arr, 2, nmc_property_macvlan_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8847 set_val_str (arr, 3, nmc_property_macvlan_get_promiscuous (setting, NMC_PROPERTY_GET_PRETTY));
8848 set_val_str (arr, 4, nmc_property_macvlan_get_tap (setting, NMC_PROPERTY_GET_PRETTY));
8849 g_ptr_array_add (nmc->output_data, arr);
8851 print_data (nmc); /* Print all data */
8857 setting_vxlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8859 NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting);
8860 NmcOutputField *tmpl, *arr;
8863 g_return_val_if_fail (NM_IS_SETTING_VXLAN (s_vxlan), FALSE);
8865 tmpl = nmc_fields_setting_vxlan;
8866 tmpl_len = sizeof (nmc_fields_setting_vxlan);
8867 nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VXLAN_ALL,
8868 tmpl, FALSE, NULL, NULL);
8869 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8870 g_ptr_array_add (nmc->output_data, arr);
8872 arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8873 set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8874 set_val_str (arr, 1, nmc_property_vxlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8875 set_val_str (arr, 2, nmc_property_vxlan_get_id (setting, NMC_PROPERTY_GET_PRETTY));
8876 set_val_str (arr, 3, nmc_property_vxlan_get_local (setting, NMC_PROPERTY_GET_PRETTY));
8877 set_val_str (arr, 4, nmc_property_vxlan_get_remote (setting, NMC_PROPERTY_GET_PRETTY));
8878 set_val_str (arr, 5, nmc_property_vxlan_get_source_port_min (setting, NMC_PROPERTY_GET_PRETTY));
8879 set_val_str (arr, 6, nmc_property_vxlan_get_source_port_max (setting, NMC_PROPERTY_GET_PRETTY));
8880 set_val_str (arr, 7, nmc_property_vxlan_get_destination_port (setting, NMC_PROPERTY_GET_PRETTY));
8881 set_val_str (arr, 8, nmc_property_vxlan_get_tos (setting, NMC_PROPERTY_GET_PRETTY));
8882 set_val_str (arr, 9, nmc_property_vxlan_get_ttl (setting, NMC_PROPERTY_GET_PRETTY));
8883 set_val_str (arr, 10, nmc_property_vxlan_get_ageing (setting, NMC_PROPERTY_GET_PRETTY));
8884 set_val_str (arr, 11, nmc_property_vxlan_get_limit (setting, NMC_PROPERTY_GET_PRETTY));
8885 set_val_str (arr, 12, nmc_property_vxlan_get_learning (setting, NMC_PROPERTY_GET_PRETTY));
8886 set_val_str (arr, 13, nmc_property_vxlan_get_proxy (setting, NMC_PROPERTY_GET_PRETTY));
8887 set_val_str (arr, 14, nmc_property_vxlan_get_rsc (setting, NMC_PROPERTY_GET_PRETTY));
8888 set_val_str (arr, 15, nmc_property_vxlan_get_l2_miss (setting, NMC_PROPERTY_GET_PRETTY));
8889 set_val_str (arr, 16, nmc_property_vxlan_get_l3_miss (setting, NMC_PROPERTY_GET_PRETTY));
8890 g_ptr_array_add (nmc->output_data, arr);
8892 print_data (nmc); /* Print all data */
8899 gboolean (*func) (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets);
8902 static const SettingDetails detail_printers[] = {
8903 { NM_SETTING_CONNECTION_SETTING_NAME, setting_connection_details },
8904 { NM_SETTING_WIRED_SETTING_NAME, setting_wired_details },
8905 { NM_SETTING_802_1X_SETTING_NAME, setting_802_1X_details },
8906 { NM_SETTING_WIRELESS_SETTING_NAME, setting_wireless_details },
8907 { NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, setting_wireless_security_details },
8908 { NM_SETTING_IP4_CONFIG_SETTING_NAME, setting_ip4_config_details },
8909 { NM_SETTING_IP6_CONFIG_SETTING_NAME, setting_ip6_config_details },
8910 { NM_SETTING_SERIAL_SETTING_NAME, setting_serial_details },
8911 { NM_SETTING_PPP_SETTING_NAME, setting_ppp_details },
8912 { NM_SETTING_PPPOE_SETTING_NAME, setting_pppoe_details },
8913 { NM_SETTING_GSM_SETTING_NAME, setting_gsm_details },
8914 { NM_SETTING_CDMA_SETTING_NAME, setting_cdma_details },
8915 { NM_SETTING_BLUETOOTH_SETTING_NAME, setting_bluetooth_details },
8916 { NM_SETTING_OLPC_MESH_SETTING_NAME, setting_olpc_mesh_details },
8917 { NM_SETTING_VPN_SETTING_NAME, setting_vpn_details },
8918 { NM_SETTING_WIMAX_SETTING_NAME, setting_wimax_details },
8919 { NM_SETTING_INFINIBAND_SETTING_NAME, setting_infiniband_details },
8920 { NM_SETTING_BOND_SETTING_NAME, setting_bond_details },
8921 { NM_SETTING_VLAN_SETTING_NAME, setting_vlan_details },
8922 { NM_SETTING_ADSL_SETTING_NAME, setting_adsl_details },
8923 { NM_SETTING_BRIDGE_SETTING_NAME, setting_bridge_details },
8924 { NM_SETTING_BRIDGE_PORT_SETTING_NAME, setting_bridge_port_details },
8925 { NM_SETTING_TEAM_SETTING_NAME, setting_team_details },
8926 { NM_SETTING_TEAM_PORT_SETTING_NAME, setting_team_port_details },
8927 { NM_SETTING_DCB_SETTING_NAME, setting_dcb_details },
8928 { NM_SETTING_TUN_SETTING_NAME, setting_tun_details },
8929 { NM_SETTING_IP_TUNNEL_SETTING_NAME, setting_ip_tunnel_details },
8930 { NM_SETTING_MACVLAN_SETTING_NAME, setting_macvlan_details },
8931 { NM_SETTING_VXLAN_SETTING_NAME, setting_vxlan_details },
8936 setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8938 const SettingDetails *iter = &detail_printers[0];
8940 g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
8942 while (iter->sname) {
8943 if (nm_setting_lookup_type (iter->sname) == G_OBJECT_TYPE (setting))
8944 return iter->func (setting, nmc, one_prop, secrets);
8948 g_assert_not_reached ();