cli: allow setting multiple IPs in bond 'arp_ip_target' option
[NetworkManager.git] / clients / cli / settings.c
1 /* nmcli - command-line tool to control NetworkManager
2  *
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.
7  *
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.
12  *
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.
16  *
17  * Copyright 2010 - 2015 Red Hat, Inc.
18  */
19
20 #include "nm-default.h"
21
22 #include "settings.h"
23
24 #include <stdlib.h>
25 #include <arpa/inet.h>
26
27 #include "utils.h"
28 #include "common.h"
29
30 /* Forward declarations */
31 static char *wep_key_type_to_string (NMWepKeyType type);
32
33 typedef enum {
34         NMC_PROPERTY_GET_PRETTY,
35         NMC_PROPERTY_GET_PARSABLE,
36 } NmcPropertyGetType;
37
38 /* Helper macro to define fields */
39 #define SETTING_FIELD(setting) { setting, N_(setting), 0, NULL, FALSE, FALSE, 0 }
40
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}
62 };
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
81
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}
99 };
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
114
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}
153 };
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
189
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}
209 };
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
226
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}
248 };
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
267
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}
290 };
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
310
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}
331 };
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
349
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}
359 };
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
366
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}
389 };
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
409
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}
418 };
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
424
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}
436 };
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","\
444                                         NM_SETTING_ADSL_VCI
445
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}
462 };
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
476
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}
485 };
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
491
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}
498 };
499 #define NMC_FIELDS_SETTING_BLUETOOTH_ALL     "name"","\
500                                              NM_SETTING_BLUETOOTH_BDADDR","\
501                                              NM_SETTING_BLUETOOTH_TYPE
502
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}
510 };
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
515
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}
526 };
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
534
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}
541 };
542 #define NMC_FIELDS_SETTING_WIMAX_ALL     "name"","\
543                                          NM_SETTING_WIMAX_MAC_ADDRESS","\
544                                          NM_SETTING_WIMAX_NETWORK_NAME
545
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}
555 };
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
562
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}
568 };
569 #define NMC_FIELDS_SETTING_BOND_ALL     "name"","\
570                                         NM_SETTING_BOND_OPTIONS
571
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}
581 };
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
588
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}
601 };
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
611
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}
619 };
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
624
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}
630 };
631 #define NMC_FIELDS_SETTING_TEAM_ALL     "name"","\
632                                         NM_SETTING_TEAM_CONFIG
633
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}
639 };
640 #define NMC_FIELDS_SETTING_TEAM_PORT_ALL     "name"","\
641                                              NM_SETTING_TEAM_PORT_CONFIG
642
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}
662 };
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
679
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}
690 };
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
698
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}
715 };
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
729
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}
738 };
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
744
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}
765 };
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
783
784 /*----------------------------------------------------------------------------*/
785 static char *
786 wep_key_type_to_string (NMWepKeyType type)
787 {
788         switch (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:
794         default:
795                 return g_strdup_printf (_("%d (unknown)"), type);
796         }
797 }
798
799 static char *
800 bytes_to_string (GBytes *bytes)
801 {
802         const guint8 *data;
803         gsize len;
804         GString *cert = NULL;
805         int i;
806
807         if (!bytes)
808                 return NULL;
809         data = g_bytes_get_data (bytes, &len);
810
811         cert = g_string_new (NULL);
812         for (i = 0; i < len; i++)
813                 g_string_append_printf (cert, "%02X", data[i]);
814
815         return g_string_free (cert, FALSE);
816 }
817
818 static char *
819 vlan_flags_to_string (guint32 flags)
820 {
821         GString *flag_str;
822
823         if (flags == 0)
824                 return g_strdup (_("0 (NONE)"));
825
826         flag_str = g_string_new (NULL);
827         g_string_printf (flag_str, "%d (", flags);
828
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, "));
837
838         if (flag_str->str[flag_str->len-1] == '(')
839                 g_string_append (flag_str, _("unknown"));
840         else
841                 g_string_truncate (flag_str, flag_str->len-2);  /* chop off trailing ', ' */
842
843         g_string_append_c (flag_str, ')');
844
845         return g_string_free (flag_str, FALSE);
846 }
847
848 static char *
849 vlan_priorities_to_string (NMSettingVlan *s_vlan, NMVlanPriorityMap map)
850 {
851         GString *priorities;
852         int i;
853
854         priorities = g_string_new (NULL);
855         for (i = 0; i < nm_setting_vlan_get_num_priorities (s_vlan, map); i++) {
856                 guint32 from, to;
857
858                 if (nm_setting_vlan_get_priority (s_vlan, map, i, &from, &to))
859                         g_string_append_printf (priorities, "%d:%d,", from, to);
860         }
861         if (priorities->len)
862                 g_string_truncate (priorities, priorities->len-1);  /* chop off trailing ',' */
863
864         return g_string_free (priorities, FALSE);
865 }
866
867 static char *
868 ip6_privacy_to_string (NMSettingIP6ConfigPrivacy ip6_privacy, NmcPropertyGetType get_type)
869 {
870         if (get_type == NMC_PROPERTY_GET_PARSABLE)
871                 return g_strdup_printf ("%d", ip6_privacy);
872
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);
880         default:
881                 return g_strdup_printf (_("%d (unknown)"), ip6_privacy);
882         }
883 }
884
885 static char *
886 autoconnect_slaves_to_string (NMSettingConnectionAutoconnectSlaves autoconnect_slaves,
887                               NmcPropertyGetType get_type)
888 {
889         if (get_type == NMC_PROPERTY_GET_PARSABLE)
890                 return g_strdup_printf ("%d", autoconnect_slaves);
891
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:
898         default:
899                 return g_strdup_printf (_("%d (default)"), autoconnect_slaves);
900         }
901 }
902
903 static char *
904 secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type)
905 {
906         GString *flag_str;
907
908         if (get_type == NMC_PROPERTY_GET_PARSABLE)
909                 return g_strdup_printf ("%u", flags);
910
911         if (flags == 0)
912                 return g_strdup (_("0 (none)"));
913
914         flag_str = g_string_new (NULL);
915         g_string_printf (flag_str, "%u (", flags);
916
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, "));
923
924         if (flag_str->str[flag_str->len-1] == '(')
925                 g_string_append (flag_str, _("unknown"));
926         else
927                 g_string_truncate (flag_str, flag_str->len-2);  /* chop off trailing ', ' */
928
929         g_string_append_c (flag_str, ')');
930
931         return g_string_free (flag_str, FALSE);
932 }
933
934 static void
935 vpn_data_item (const char *key, const char *value, gpointer user_data)
936 {
937         GString *ret_str = (GString *) user_data;
938
939         if (ret_str->len != 0)
940                 g_string_append (ret_str, ", ");
941
942         g_string_append_printf (ret_str, "%s = %s", key, value);
943 }
944
945
946 /* === property get functions === */
947 #define DEFINE_GETTER(func_name, property_name) \
948         static char * \
949         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
950         { \
951                 char *s; \
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); \
957                 return s; \
958         }
959
960 #define DEFINE_GETTER_WITH_DEFAULT(func_name, property_name, check_is_default) \
961         static char * \
962         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
963         { \
964                 const char *s; \
965                 char *s_full; \
966                 GValue val = G_VALUE_INIT; \
967                 \
968                 if ((check_is_default)) { \
969                         if (get_type == NMC_PROPERTY_GET_PARSABLE) \
970                                 return g_strdup (""); \
971                         return g_strdup (_("(default)")); \
972                 } \
973                 \
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 : " "); \
979                 else \
980                         s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); \
981                 g_value_unset (&val); \
982                 return s_full; \
983         }
984
985 #define DEFINE_SECRET_FLAGS_GETTER(func_name, property_name) \
986         static char * \
987         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
988         { \
989                 guint v; \
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); \
996         }
997
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)
1026
1027 static char *
1028 nmc_property_802_1X_get_ca_cert (NMSetting *setting, NmcPropertyGetType get_type)
1029 {
1030         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1031         NMSetting8021xCKScheme scheme;
1032         char *ca_cert_str = NULL;
1033
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));
1039
1040         return ca_cert_str;
1041 }
1042
1043 static char *
1044 nmc_property_802_1X_get_client_cert (NMSetting *setting, NmcPropertyGetType get_type)
1045 {
1046         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1047         NMSetting8021xCKScheme scheme;
1048         char *client_cert_str = NULL;
1049
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));
1055
1056         return client_cert_str;
1057 }
1058
1059 static char *
1060 nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting, NmcPropertyGetType get_type)
1061 {
1062         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1063         NMSetting8021xCKScheme scheme;
1064         char *phase2_ca_cert_str = NULL;
1065
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));
1071
1072         return phase2_ca_cert_str;
1073 }
1074
1075 static char *
1076 nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting, NmcPropertyGetType get_type)
1077 {
1078         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1079         NMSetting8021xCKScheme scheme;
1080         char *phase2_client_cert_str = NULL;
1081
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));
1087
1088         return phase2_client_cert_str;
1089 }
1090
1091 static char *
1092 nmc_property_802_1X_get_password_raw (NMSetting *setting, NmcPropertyGetType get_type)
1093 {
1094         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1095         return bytes_to_string (nm_setting_802_1x_get_password_raw (s_8021X));
1096 }
1097
1098 static char *
1099 nmc_property_802_1X_get_private_key (NMSetting *setting, NmcPropertyGetType get_type)
1100 {
1101         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1102         NMSetting8021xCKScheme scheme;
1103         char *private_key_str = NULL;
1104
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));
1110
1111         return private_key_str;
1112 }
1113
1114 static char *
1115 nmc_property_802_1X_get_phase2_private_key (NMSetting *setting, NmcPropertyGetType get_type)
1116 {
1117         NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
1118         NMSetting8021xCKScheme scheme;
1119         char *phase2_private_key_str = NULL;
1120
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));
1126
1127         return phase2_private_key_str;
1128 }
1129
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)
1138
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)
1142
1143 static char *
1144 nmc_property_bond_get_options (NMSetting *setting, NmcPropertyGetType get_type)
1145 {
1146         NMSettingBond *s_bond = NM_SETTING_BOND (setting);
1147         GString *bond_options_s;
1148         int i;
1149
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;
1154                 char *p;
1155
1156                 nm_setting_bond_get_option (s_bond, i, &key, &value);
1157
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++) {
1161                                 if (*p == ',')
1162                                         *p = ' ';
1163                         }
1164                 }
1165
1166                 g_string_append_printf (bond_options_s, "%s=%s,", key, value);
1167         }
1168         g_string_truncate (bond_options_s, bond_options_s->len-1);  /* chop off trailing ',' */
1169
1170         return g_string_free (bond_options_s, FALSE);
1171 }
1172
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)
1182
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)
1187
1188 /* --- NM_SETTING_TEAM_SETTING_NAME property get functions --- */
1189 DEFINE_GETTER (nmc_property_team_get_config, NM_SETTING_TEAM_CONFIG)
1190
1191 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property get functions --- */
1192 DEFINE_GETTER (nmc_property_team_port_get_config, NM_SETTING_TEAM_PORT_CONFIG)
1193
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)
1198
1199 DEFINE_SECRET_FLAGS_GETTER (nmc_property_cdma_get_password_flags, NM_SETTING_CDMA_PASSWORD_FLAGS)
1200
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)
1210
1211 static char *
1212 nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType get_type)
1213 {
1214         NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1215         GString *perm = NULL;
1216         const char *perm_item;
1217         const char *perm_type;
1218         int i;
1219
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);
1224         }
1225         if (perm->len > 0)
1226                 g_string_truncate (perm, perm->len-1); /* remove trailing , */
1227
1228         return g_string_free (perm, FALSE);
1229 }
1230
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)
1234
1235 static char *
1236 nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyGetType get_type)
1237 {
1238         NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1239         return autoconnect_slaves_to_string (nm_setting_connection_get_autoconnect_slaves (s_con), get_type);
1240 }
1241
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)
1244
1245 /* --- NM_SETTING_DCB_SETTING_NAME property get functions --- */
1246 static char *
1247 dcb_flags_to_string (NMSettingDcbFlags flags)
1248 {
1249         GString *flag_str;
1250
1251         if (flags == 0)
1252                 return g_strdup (_("0 (disabled)"));
1253
1254         flag_str = g_string_new (NULL);
1255         g_string_printf (flag_str, "%d (", flags);
1256
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, "));
1263
1264         if (flag_str->str[flag_str->len-1] == '(')
1265                 g_string_append (flag_str, _("unknown"));
1266         else
1267                 g_string_truncate (flag_str, flag_str->len-2);  /* chop off trailing ', ' */
1268
1269         g_string_append_c (flag_str, ')');
1270
1271         return g_string_free (flag_str, FALSE);
1272 }
1273
1274 #define DEFINE_DCB_FLAGS_GETTER(func_name, property_name) \
1275         static char * \
1276         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1277         { \
1278                 guint v; \
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); \
1285         }
1286
1287 static char *
1288 dcb_app_priority_to_string (gint priority)
1289 {
1290         return (priority == -1) ? g_strdup (_("-1 (unset)")) : g_strdup_printf ("%d", priority);
1291 }
1292
1293 #define DEFINE_DCB_APP_PRIORITY_GETTER(func_name, property_name) \
1294         static char * \
1295         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1296         { \
1297                 int v; \
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); \
1304         }
1305
1306 #define DEFINE_DCB_BOOL_GETTER(func_name, getter_func_name) \
1307         static char * \
1308         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1309         { \
1310                 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1311                 GString *str; \
1312                 guint i; \
1313  \
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'); \
1318                         else \
1319                                 g_string_append_c (str, '0'); \
1320 \
1321                         if (i < 7) \
1322                                 g_string_append_c (str, ','); \
1323                 } \
1324 \
1325                 return g_string_free (str, FALSE); \
1326         }
1327
1328 #define DEFINE_DCB_UINT_GETTER(func_name, getter_func_name) \
1329         static char * \
1330         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1331         { \
1332                 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1333                 GString *str; \
1334                 guint i; \
1335  \
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)); \
1339                         if (i < 7) \
1340                                 g_string_append_c (str, ','); \
1341                 } \
1342 \
1343                 return g_string_free (str, FALSE); \
1344         }
1345
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)
1353
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)
1356
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)
1363
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)
1377
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)
1381
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);
1388
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);
1401
1402 static const char **
1403 nmc_property_ip_tunnel_allowed_mode (NMSetting *setting, const char *prop)
1404 {
1405         static const char **words = NULL;
1406
1407         if (!words)
1408                 words = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1409                                                   NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1410                                                   G_MAXINT);
1411         return words;
1412 }
1413
1414 static char *
1415 nmc_property_ib_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1416 {
1417         NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1418         int mtu;
1419
1420         mtu = nm_setting_infiniband_get_mtu (s_infiniband);
1421         if (mtu == 0)
1422                 return g_strdup (_("auto"));
1423         else
1424                 return g_strdup_printf ("%d", mtu);
1425 }
1426
1427 static char *
1428 nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type)
1429 {
1430         NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1431         int p_key;
1432
1433         p_key = nm_setting_infiniband_get_p_key (s_infiniband);
1434         if (p_key == -1)
1435                 return g_strdup (_("default"));
1436         else
1437                 return g_strdup_printf ("0x%04x", p_key);
1438 }
1439
1440 DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
1441
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))
1447
1448 static char *
1449 nmc_property_ip_get_addresses (NMSetting *setting, NmcPropertyGetType get_type)
1450 {
1451         NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1452         GString *printable;
1453         guint32 num_addresses, i;
1454         NMIPAddress *addr;
1455
1456         printable = g_string_new (NULL);
1457
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);
1461
1462                 if (printable->len > 0)
1463                         g_string_append (printable, ", ");
1464
1465                 g_string_append_printf (printable, "%s/%u",
1466                                         nm_ip_address_get_address (addr),
1467                                         nm_ip_address_get_prefix (addr));
1468         }
1469
1470         return g_string_free (printable, FALSE);
1471 }
1472
1473 static char *
1474 nmc_property_ipvx_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1475 {
1476         NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1477         GString *printable;
1478         guint32 num_routes, i;
1479         NMIPRoute *route;
1480
1481         printable = g_string_new (NULL);
1482
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);
1486
1487                 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1488                         if (printable->len > 0)
1489                                 g_string_append (printable, ", ");
1490
1491                         g_string_append_printf (printable, "%s/%u",
1492                                                 nm_ip_route_get_dest (route),
1493                                                 nm_ip_route_get_prefix (route));
1494
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));
1499                 } else {
1500                         if (printable->len > 0)
1501                                 g_string_append (printable, "; ");
1502
1503                         g_string_append (printable, "{ ");
1504
1505                         g_string_append_printf (printable, "ip = %s/%u",
1506                                                 nm_ip_route_get_dest (route),
1507                                                 nm_ip_route_get_prefix (route));
1508
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));
1512                         }
1513
1514                         if (nm_ip_route_get_metric (route) != -1)
1515                                 g_string_append_printf (printable, ", mt = %u", (guint32) nm_ip_route_get_metric (route));
1516
1517                         g_string_append (printable, " }");
1518                 }
1519         }
1520
1521         return g_string_free (printable, FALSE);
1522 }
1523
1524 static char *
1525 nmc_property_ipv4_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1526 {
1527         return nmc_property_ipvx_get_routes (setting, get_type);
1528 }
1529
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)
1541
1542 static char *
1543 nmc_property_ipv4_get_dad_timeout (NMSetting *setting, NmcPropertyGetType get_type)
1544 {
1545         NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1546         gint dad_timeout;
1547
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);
1551
1552         switch (dad_timeout) {
1553         case -1:
1554                 return g_strdup_printf (_("%d (default)"), dad_timeout);
1555         case 0:
1556                 return g_strdup_printf (_("%d (off)"), dad_timeout);
1557         default:
1558                 return g_strdup_printf ("%d", dad_timeout);
1559         }
1560 }
1561
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))
1567
1568 static char *
1569 nmc_property_ipv6_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1570 {
1571         return nmc_property_ipvx_get_routes (setting, get_type);
1572 }
1573
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)
1582
1583 static char *
1584 nmc_property_ipv6_get_ip6_privacy (NMSetting *setting, NmcPropertyGetType get_type)
1585 {
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);
1588 }
1589
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)
1593
1594 static char *
1595 nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1596 {
1597         NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
1598         GBytes *ssid;
1599         char *ssid_str = NULL;
1600
1601         ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
1602         if (ssid) {
1603                 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1604                                                   g_bytes_get_size (ssid));
1605         }
1606
1607         return ssid_str;
1608 }
1609
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)
1629
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)
1635
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)
1641
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)
1645
1646
1647 static char *
1648 nmc_property_vlan_get_flags (NMSetting *setting, NmcPropertyGetType get_type)
1649 {
1650         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1651         return vlan_flags_to_string (nm_setting_vlan_get_flags (s_vlan));
1652 }
1653
1654 static char *
1655 nmc_property_vlan_get_ingress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1656 {
1657         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1658         return vlan_priorities_to_string (s_vlan, NM_VLAN_INGRESS_MAP);
1659 }
1660
1661 static char *
1662 nmc_property_vlan_get_egress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1663 {
1664         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1665         return vlan_priorities_to_string (s_vlan, NM_VLAN_EGRESS_MAP);
1666 }
1667
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)
1671
1672 static char *
1673 nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type)
1674 {
1675         NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1676         GString *data_item_str;
1677
1678         data_item_str = g_string_new (NULL);
1679         nm_setting_vpn_foreach_data_item (s_vpn, &vpn_data_item, data_item_str);
1680
1681         return g_string_free (data_item_str, FALSE);
1682 }
1683
1684 static char *
1685 nmc_property_vpn_get_secrets (NMSetting *setting, NmcPropertyGetType get_type)
1686 {
1687         NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1688         GString *secret_str;
1689
1690         secret_str = g_string_new (NULL);
1691         nm_setting_vpn_foreach_secret (s_vpn, &vpn_data_item, secret_str);
1692
1693         return g_string_free (secret_str, FALSE);
1694 }
1695
1696 DEFINE_GETTER (nmc_property_vpn_get_persistent, NM_SETTING_VPN_PERSISTENT)
1697 DEFINE_GETTER (nmc_property_vpn_get_timeout, NM_SETTING_VPN_TIMEOUT)
1698
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)
1702
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)
1715
1716 static char *
1717 nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1718 {
1719         NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1720         int mtu;
1721
1722         mtu = nm_setting_wired_get_mtu (s_wired);
1723         if (mtu == 0)
1724                 return g_strdup (_("auto"));
1725         else
1726                 return g_strdup_printf ("%d", mtu);
1727 }
1728
1729 static char *
1730 nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type)
1731 {
1732         NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1733         NMSettingWiredWakeOnLan wol;
1734         char *tmp, *str;
1735
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");
1740         else
1741                 str = g_strdup_printf ("%d (%s)", wol, tmp && *tmp ? tmp : "none");
1742         g_free (tmp);
1743         return str;
1744 }
1745
1746 static gboolean
1747 nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
1748                                     const char *val, GError **error)
1749 {
1750         NMSettingWiredWakeOnLan wol;
1751         gs_free char *err_token = NULL;
1752         gboolean ret;
1753         long int t;
1754
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,
1758                                     &t))
1759                 wol = (NMSettingWiredWakeOnLan) t;
1760         else {
1761                 ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val,
1762                                               (int *) &wol, &err_token);
1763
1764                 if (!ret) {
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;
1769                         else {
1770                                 g_set_error (error, 1, 0, _("invalid option '%s', use a combination of [%s] or 'ignore', 'default' or 'none'"),
1771                                              err_token,
1772                                              nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (),
1773                                                                    NM_SETTING_WIRED_WAKE_ON_LAN_ALL));
1774                                 return FALSE;
1775                         }
1776                 }
1777         }
1778
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"));
1782                 return FALSE;
1783         }
1784
1785         g_object_set (setting, prop, (guint) wol, NULL);
1786         return TRUE;
1787 }
1788
1789 static char *
1790 nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1791 {
1792         NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
1793         NMIPTunnelMode mode;
1794
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);
1797 }
1798
1799 static gboolean
1800 nmc_property_ip_tunnel_set_mode (NMSetting *setting, const char *prop,
1801                                   const char *val, GError **error)
1802 {
1803         NMIPTunnelMode mode;
1804         gboolean ret;
1805
1806         ret = nm_utils_enum_from_str (nm_ip_tunnel_mode_get_type(), val,
1807                                        (int *) &mode, NULL);
1808
1809         if (!ret) {
1810                 gs_free const char **values = NULL;
1811                 gs_free char *values_str = NULL;
1812
1813                 values = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1814                                                    NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1815                                                    G_MAXINT);
1816                 values_str = g_strjoinv (",", (char **) values);
1817                 g_set_error (error, 1, 0, _("invalid mode '%s', use one of %s"),
1818                              val, values_str);
1819
1820                 return FALSE;
1821         }
1822
1823         g_object_set (setting, prop, mode, NULL);
1824         return TRUE;
1825 }
1826
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)
1839
1840 static char *
1841 nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1842 {
1843         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1844         GBytes *ssid;
1845         char *ssid_str = NULL;
1846
1847         ssid = nm_setting_wireless_get_ssid (s_wireless);
1848         if (ssid) {
1849                 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1850                                                   g_bytes_get_size (ssid));
1851         }
1852
1853         return ssid_str;
1854 }
1855
1856 static char *
1857 nmc_property_wireless_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1858 {
1859         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1860         int mtu;
1861
1862         mtu = nm_setting_wireless_get_mtu (s_wireless);
1863         if (mtu == 0)
1864                 return g_strdup (_("auto"));
1865         else
1866                 return g_strdup_printf ("%d", mtu);
1867 }
1868
1869 static char *
1870 nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_type)
1871 {
1872         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1873         NMSettingWirelessPowersave powersave;
1874         gs_free char *str = NULL;
1875         char *ret;
1876
1877         powersave = nm_setting_wireless_get_powersave (s_wireless);
1878         str = nm_utils_enum_to_str (nm_setting_wireless_powersave_get_type (), powersave);
1879
1880         if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1881                 ret = str;
1882                 str = NULL;
1883                 return ret;
1884         } else
1885                 return g_strdup_printf ("%s (%u)", str, powersave);
1886 }
1887
1888 static char *
1889 nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcPropertyGetType get_type)
1890 {
1891         NMSettingWireless *s_wifi = NM_SETTING_WIRELESS (setting);
1892         NMSettingMacRandomization randomization = nm_setting_wireless_get_mac_address_randomization (s_wifi);
1893
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"));
1900         else
1901                 return g_strdup_printf (_("unknown"));
1902 }
1903
1904
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)
1918
1919 static char *
1920 nmc_property_wifi_sec_get_wep_key0 (NMSetting *setting, NmcPropertyGetType get_type)
1921 {
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));
1924 }
1925
1926 static char *
1927 nmc_property_wifi_sec_get_wep_key1 (NMSetting *setting, NmcPropertyGetType get_type)
1928 {
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));
1931 }
1932
1933 static char *
1934 nmc_property_wifi_sec_get_wep_key2 (NMSetting *setting, NmcPropertyGetType get_type)
1935 {
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));
1938 }
1939
1940 static char *
1941 nmc_property_wifi_sec_get_wep_key3 (NMSetting *setting, NmcPropertyGetType get_type)
1942 {
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));
1945 }
1946
1947 static char *
1948 nmc_property_wifi_sec_get_wep_key_type (NMSetting *setting, NmcPropertyGetType get_type)
1949 {
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));
1952 }
1953
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)
1958
1959 static char *
1960 nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1961 {
1962         NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
1963         NMSettingMacvlanMode mode;
1964         char *tmp, *str;
1965
1966         mode = nm_setting_macvlan_get_mode (s_macvlan);
1967         tmp = nm_utils_enum_to_str (nm_setting_macvlan_mode_get_type (), mode);
1968
1969         if (get_type == NMC_PROPERTY_GET_PARSABLE)
1970                 str = g_strdup (tmp ? tmp : "");
1971         else
1972                 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
1973         g_free (tmp);
1974
1975         return str;
1976 }
1977
1978 static gboolean
1979 nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop,
1980                                const char *val, GError **error)
1981 {
1982         NMSettingMacvlanMode mode;
1983         gs_free const char **options = NULL;
1984         gs_free char *options_str = NULL;
1985         long int t;
1986         gboolean ret;
1987
1988         if (nmc_string_to_int_base (val, 0, TRUE, 0, _NM_SETTING_MACVLAN_MODE_NUM - 1, &t))
1989                 mode = (NMSettingMacvlanMode) t;
1990         else {
1991                 ret = nm_utils_enum_from_str (nm_setting_macvlan_mode_get_type (), val,
1992                                               (int *) &mode, NULL);
1993
1994                 if (!ret) {
1995                                 options = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
1996                                                                     NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
1997                                                                     G_MAXINT);
1998                                 options_str = g_strjoinv (",", (char **) options);
1999                                 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
2000                                              val, options_str);
2001                                 return FALSE;
2002                         }
2003                 }
2004
2005         g_object_set (setting, prop, (guint) mode, NULL);
2006         return TRUE;
2007 }
2008
2009 static const char **
2010 nmc_property_macvlan_allowed_mode (NMSetting *setting, const char *prop)
2011 {
2012         static const char **words = NULL;
2013
2014         if (!words)
2015                 words = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
2016                                                   NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
2017                                                   G_MAXINT);
2018         return words;
2019 }
2020
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)
2038
2039 /*----------------------------------------------------------------------------*/
2040
2041 static void
2042 nmc_value_transform_bool_string (const GValue *src_value,
2043                                  GValue       *dest_value)
2044 {
2045         dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_int ? "yes" : "no");
2046 }
2047
2048 static void
2049 nmc_value_transform_char_string (const GValue *src_value,
2050                                  GValue       *dest_value)
2051 {
2052         dest_value->data[0].v_pointer = g_strdup_printf ("%c", src_value->data[0].v_uint);
2053 }
2054
2055 static void __attribute__((constructor))
2056 register_nmcli_value_transforms (void)
2057 {
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);
2060 }
2061
2062 /*----------------------------------------------------------------------------*/
2063
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 *);
2071
2072 typedef struct {
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 */ \
2081         ;
2082         NmcPropertyFuncsFields
2083 } NmcPropertyFuncs;
2084
2085 /*
2086  * We need NmCli in some _set_property functions, and they aren't passed NmCli.
2087  * So use the global variable.
2088  */
2089 /* Global variable defined in nmcli.c */
2090 extern NmCli nm_cli;
2091
2092 NMSetting *
2093 nmc_setting_new_for_name (const char *name)
2094 {
2095         GType stype;
2096         NMSetting *setting = NULL;
2097
2098         if (name) {
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));
2103                 }
2104         }
2105         return setting;
2106 }
2107
2108 static gboolean
2109 get_answer (const char *prop, const char *value)
2110 {
2111         char *tmp_str;
2112         char *question;
2113         gboolean answer = FALSE;
2114
2115         if (value)
2116                 question = g_strdup_printf (_("Do you also want to set '%s' to '%s'? [yes]: "), prop, value);
2117         else
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)
2121                 answer = TRUE;
2122         g_free (tmp_str);
2123         g_free (question);
2124         return answer;
2125 }
2126
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);
2129
2130 static void
2131 ipv4_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2132 {
2133         static gboolean answered = FALSE;
2134         static gboolean answer = FALSE;
2135
2136         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2137
2138         /* If we have some IP addresses set method to 'manual'.
2139          * Else if the method was 'manual', change it back to 'auto'.
2140          */
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)) {
2143                         if (!answered) {
2144                                 answered = TRUE;
2145                                 answer = get_answer ("ipv4.method", "manual");
2146                         }
2147                         if (answer)
2148                                 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL);
2149                 }
2150         } else {
2151                 answered = FALSE;
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);
2154         }
2155
2156         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2157 }
2158
2159 static void
2160 ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2161 {
2162         static GValue value = G_VALUE_INIT;
2163         static gboolean answered = FALSE;
2164         static gboolean answer = FALSE;
2165
2166         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2167
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))) {
2171                         if (!answered) {
2172                                 answered = TRUE;
2173                                 answer = get_answer ("ipv4.addresses", NULL);
2174                         }
2175                         if (answer) {
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);
2180                         }
2181                 }
2182         } else {
2183                 answered = FALSE;
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);
2187                 }
2188         }
2189
2190         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2191 }
2192
2193 static void
2194 ipv6_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2195 {
2196         static gboolean answered = FALSE;
2197         static gboolean answer = FALSE;
2198
2199         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2200
2201         /* If we have some IP addresses set method to 'manual'.
2202          * Else if the method was 'manual', change it back to 'auto'.
2203          */
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)) {
2206                         if (!answered) {
2207                                 answered = TRUE;
2208                                 answer = get_answer ("ipv6.method", "manual");
2209                         }
2210                         if (answer)
2211                                 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL);
2212                 }
2213         } else {
2214                 answered = FALSE;
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);
2217         }
2218
2219         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2220 }
2221
2222 static void
2223 ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2224 {
2225         static GValue value = G_VALUE_INIT;
2226         static gboolean answered = FALSE;
2227         static gboolean answer = FALSE;
2228
2229         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2230
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))) {
2234                         if (!answered) {
2235                                 answered = TRUE;
2236                                 answer = get_answer ("ipv6.addresses", NULL);
2237                         }
2238                         if (answer) {
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);
2243                         }
2244                 }
2245         } else {
2246                 answered = FALSE;
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);
2250                 }
2251         }
2252
2253         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2254 }
2255
2256 static void
2257 wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2258 {
2259         const char *value = NULL, *mode;
2260         char str[16];
2261         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (object);
2262
2263         if (strcmp (g_param_spec_get_name (pspec), NM_SETTING_WIRELESS_BAND) == 0) {
2264                 value = nm_setting_wireless_get_band (s_wireless);
2265                 if (!value)
2266                         return;
2267         } else {
2268                 guint32 channel = nm_setting_wireless_get_channel (s_wireless);
2269
2270                 if (channel == 0)
2271                         return;
2272
2273                 g_snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless));
2274                 value = str;
2275         }
2276
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),
2281                          value);
2282         }
2283 }
2284
2285 static void
2286 connection_master_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2287 {
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;
2292
2293         value = nm_setting_connection_get_master (s_con);
2294         if (value) {
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) {
2302                                 if (s_ipv4)
2303                                         nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv4));
2304                                 if (s_ipv6)
2305                                         nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv6));
2306                         }
2307                 }
2308         }
2309 }
2310
2311 void
2312 nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting)
2313 {
2314         g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
2315
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);
2320 }
2321
2322 void
2323 nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting)
2324 {
2325         g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
2326
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);
2331 }
2332
2333 void
2334 nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
2335 {
2336         g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
2337
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);
2342 }
2343
2344 void
2345 nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection)
2346 {
2347         g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
2348
2349         g_signal_connect (setting, "notify::" NM_SETTING_CONNECTION_MASTER,
2350                           G_CALLBACK (connection_master_changed_cb), connection);
2351 }
2352
2353 /*
2354  * Customize some properties of the setting so that the setting has sensible
2355  * values.
2356  */
2357 void
2358 nmc_setting_custom_init (NMSetting *setting)
2359 {
2360         g_return_if_fail (NM_IS_SETTING (setting));
2361
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,
2365                               NULL);
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,
2370                               NULL);
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,
2375                               NULL);
2376                 nmc_setting_wireless_connect_handlers (NM_SETTING_WIRELESS (setting));
2377         }
2378 }
2379
2380 /* === SetFunc, RemoveFunc, DescribeFunc, ValuesFunc functions === */
2381 static gboolean
2382 verify_string_list (char **strv,
2383                     const char *prop,
2384                     gboolean (*validate_func) (const char *),
2385                     GError **error)
2386 {
2387         char **iter;
2388
2389         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2390
2391         for (iter = strv; iter && *iter; iter++) {
2392                 if (**iter == '\0')
2393                         continue;
2394                 if (validate_func) {
2395                         if (!validate_func (*iter)) {
2396                                 g_set_error (error, 1, 0, _("'%s' is not valid"),
2397                                              *iter);
2398                                 return FALSE;
2399                         }
2400                 }
2401         }
2402         return TRUE;
2403 }
2404
2405 /* Validate 'val' number against to int property spec */
2406 static gboolean
2407 validate_int (NMSetting *setting, const char* prop, gint val, GError **error)
2408 {
2409         GParamSpec *pspec;
2410         GValue value = G_VALUE_INIT;
2411         gboolean success = TRUE;
2412
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);
2421                 success = FALSE;
2422         }
2423         g_value_unset (&value);
2424         return success;
2425 }
2426
2427 static gboolean
2428 validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error)
2429 {
2430         GParamSpec *pspec;
2431         GValue value = G_VALUE_INIT;
2432         gboolean success = TRUE;
2433
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);
2443                 success = FALSE;
2444         }
2445         g_value_unset (&value);
2446         return success;
2447 }
2448
2449 /* Validate 'val' number against to uint property spec */
2450 static gboolean
2451 validate_uint (NMSetting *setting, const char* prop, guint val, GError **error)
2452 {
2453         GParamSpec *pspec;
2454         GValue value = G_VALUE_INIT;
2455         gboolean success = TRUE;
2456
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);
2465                 success = FALSE;
2466         }
2467         g_value_unset (&value);
2468         return success;
2469 }
2470
2471 static char *
2472 flag_values_to_string (GFlagsValue *array, guint n)
2473 {
2474         GString *str;
2475         guint i;
2476
2477         str = g_string_new (NULL);
2478         for (i = 0; i < n; i++)
2479                 g_string_append_printf (str, "%u, ", array[i].value);
2480         if (str->len)
2481                 g_string_truncate (str, str->len-2);  /* chop off trailing ', ' */
2482         return g_string_free (str, FALSE);
2483 }
2484
2485 static gboolean
2486 validate_flags (NMSetting *setting, const char* prop, guint val, GError **error)
2487 {
2488         GParamSpec *pspec;
2489         GValue value = G_VALUE_INIT;
2490         gboolean success = TRUE;
2491
2492         pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2493         g_assert (G_IS_PARAM_SPEC (pspec));
2494
2495         g_value_init (&value, pspec->value_type);
2496         g_value_set_flags (&value, val);
2497
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"),
2503                              val, flag_values);
2504                 g_free (flag_values);
2505                 success = FALSE;
2506         }
2507         g_value_unset (&value);
2508         return success;
2509 }
2510
2511 static gboolean
2512 check_and_set_string (NMSetting *setting,
2513                       const char *prop,
2514                       const char *val,
2515                       const char **valid_strv,
2516                       GError **error)
2517 {
2518         const char *checked_val;
2519
2520         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2521
2522         checked_val = nmc_string_is_valid (val, valid_strv, error);
2523         if (!checked_val)
2524                 return FALSE;
2525
2526         g_object_set (setting, prop, checked_val, NULL);
2527         return TRUE;
2528 }
2529
2530 #define DEFINE_SETTER_STR_LIST_MULTI(def_func, s_macro, set_func) \
2531         static gboolean \
2532         def_func (NMSetting *setting, \
2533                   const char *prop, \
2534                   const char *val, \
2535                   const char **valid_strv, \
2536                   GError **error) \
2537         { \
2538                 char **strv = NULL, **iter; \
2539                 const char *item; \
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); \
2545                                 return FALSE; \
2546                         } \
2547                         set_func (s_macro (setting), item); \
2548                 } \
2549                 g_strfreev (strv); \
2550                 return TRUE; \
2551         }
2552
2553 #define DEFINE_SETTER_OPTIONS(def_func, s_macro, s_type, add_func, valid_func1, valid_func2) \
2554         static gboolean \
2555         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2556         { \
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; \
2561                 \
2562                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2563                 \
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, '='); \
2568                         if (!right) { \
2569                                 g_set_error (error, 1, 0, _("'%s' is not valid; use <option>=<value>"), *iter); \
2570                                 g_strfreev (strv); \
2571                                 return FALSE; \
2572                         } \
2573                         *right++ = '\0'; \
2574                         \
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); \
2579                                         return FALSE; \
2580                                 } \
2581                         } else \
2582                                 opt_name = g_strstrip (left);\
2583                         \
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); \
2588                                         return FALSE; \
2589                                 }\
2590                         }\
2591                         add_func (s_macro (setting), opt_name, opt_val); \
2592                 } \
2593                 g_strfreev (strv); \
2594                 return TRUE; \
2595         }
2596
2597 #define DEFINE_REMOVER_INDEX(def_func, s_macro, num_func, rem_func) \
2598         static gboolean \
2599         def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2600         { \
2601                 guint32 num; \
2602                 if (option) { \
2603                         g_set_error (error, 1, 0, _("index '%s' is not valid"), option); \
2604                         return FALSE; \
2605                 } \
2606                 num = num_func (s_macro (setting)); \
2607                 if (num == 0) { \
2608                         g_set_error_literal (error, 1, 0, _("no item to remove")); \
2609                         return FALSE; \
2610                 } \
2611                 if (idx >= num) { \
2612                         g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2613                         return FALSE; \
2614                 } \
2615                 rem_func (s_macro (setting), idx); \
2616                 return TRUE; \
2617         }
2618
2619 #define DEFINE_REMOVER_INDEX_OR_VALUE(def_func, s_macro, num_func, rem_func_idx, rem_func_val) \
2620         static gboolean \
2621         def_func (NMSetting *setting, const char *prop, const char *value, guint32 idx, GError **error) \
2622         { \
2623                 guint32 num; \
2624                 if (value) { \
2625                         gboolean ret; \
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); \
2629                         return ret; \
2630                 } \
2631                 num = num_func (s_macro (setting)); \
2632                 if (num == 0) { \
2633                         g_set_error_literal (error, 1, 0, _("no item to remove")); \
2634                         return FALSE; \
2635                 } \
2636                 if (idx >= num) { \
2637                         g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2638                         return FALSE; \
2639                 } \
2640                 rem_func_idx (s_macro (setting), idx); \
2641                 return TRUE; \
2642         }
2643
2644 #define DEFINE_REMOVER_OPTION(def_func, s_macro, rem_func) \
2645         static gboolean \
2646         def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2647         { \
2648                 gboolean success = FALSE; \
2649                 if (option && *option) { \
2650                         success = rem_func (s_macro (setting), option); \
2651                         if (!success) \
2652                                 g_set_error (error, 1, 0, _("invalid option '%s'"), option); \
2653                 } else \
2654                         g_set_error_literal (error, 1, 0, _("missing option")); \
2655                 return success; \
2656         }
2657
2658 #define DEFINE_ALLOWED_VAL_FUNC(def_func, valid_values) \
2659         static const char ** \
2660         def_func (NMSetting *setting, const char *prop) \
2661         { \
2662                 return valid_values; \
2663         }
2664
2665 /* --- generic property setter functions --- */
2666 static gboolean
2667 nmc_property_set_string (NMSetting *setting, const char *prop, const char *val, GError **error)
2668 {
2669         g_object_set (setting, prop, val, NULL);
2670         return TRUE;
2671 }
2672
2673 static gboolean
2674 nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GError **error)
2675 {
2676         unsigned long val_int;
2677
2678         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2679
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);
2682                 return FALSE;
2683         }
2684
2685         /* Validate the number according to the property spec */
2686         if (!validate_uint (setting, prop, (guint) val_int, error))
2687                 return FALSE;
2688
2689         g_object_set (setting, prop, (guint) val_int, NULL);
2690         return TRUE;
2691 }
2692
2693 static gboolean
2694 nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error)
2695 {
2696         long int val_int;
2697
2698         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2699
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);
2702                 return FALSE;
2703         }
2704
2705         /* Validate the number according to the property spec */
2706         if (!validate_int (setting, prop, (gint) val_int, error))
2707                 return FALSE;
2708
2709         g_object_set (setting, prop, (gint) val_int, NULL);
2710         return TRUE;
2711 }
2712
2713 static gboolean
2714 nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, GError **error)
2715 {
2716         long val_int;
2717
2718         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2719
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);
2722                 return FALSE;
2723         }
2724
2725         /* Validate the number according to the property spec */
2726         if (!validate_int64 (setting, prop, (gint64) val_int, error))
2727                 return FALSE;
2728
2729         g_object_set (setting, prop, (gint64) val_int, NULL);
2730         return TRUE;
2731 }
2732
2733 static gboolean
2734 nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2735 {
2736         unsigned long val_int;
2737
2738         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2739
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);
2742                 return FALSE;
2743         }
2744
2745         /* Validate the flags according to the property spec */
2746         if (!validate_flags (setting, prop, (guint) val_int, error))
2747                 return FALSE;
2748
2749         g_object_set (setting, prop, (guint) val_int, NULL);
2750         return TRUE;
2751 }
2752
2753 static gboolean
2754 nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error)
2755 {
2756         gboolean val_bool;
2757
2758         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2759
2760         if (!nmc_string_to_bool (val, &val_bool, error))
2761                 return FALSE;
2762
2763         g_object_set (setting, prop, val_bool, NULL);
2764         return TRUE;
2765 }
2766
2767 static gboolean
2768 nmc_property_set_trilean (NMSetting *setting, const char *prop, const char *val, GError **error)
2769 {
2770         long int val_int;
2771
2772         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2773
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);
2776                 return FALSE;
2777         }
2778
2779         g_object_set (setting, prop, val_int, NULL);
2780         return TRUE;
2781 }
2782
2783 static gboolean
2784 nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error)
2785 {
2786         GBytes *ssid;
2787
2788         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2789
2790         if (strlen (val) > 32) {
2791                 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
2792                 return FALSE;
2793         }
2794
2795         ssid = g_bytes_new (val, strlen (val));
2796         g_object_set (setting, prop, ssid, NULL);
2797         g_bytes_unref (ssid);
2798         return TRUE;
2799 }
2800
2801 static gboolean
2802 nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
2803 {
2804         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2805
2806         if (!nm_utils_hwaddr_valid (val, ETH_ALEN)) {
2807                 g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), val);
2808                 return FALSE;
2809         }
2810
2811         g_object_set (setting, prop, val, NULL);
2812         return TRUE;
2813 }
2814
2815 static gboolean
2816 nmc_property_set_mtu (NMSetting *setting, const char *prop, const char *val, GError **error)
2817 {
2818         const char *mtu = val;
2819
2820         if (strcmp (mtu, "auto") == 0)
2821                 mtu = "0";
2822
2823         return nmc_property_set_uint (setting, prop, mtu, error);
2824 }
2825
2826 static gboolean
2827 nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, GError **error)
2828 {
2829         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2830
2831         if (!nm_utils_iface_valid_name (val)) {
2832                 g_set_error (error, 1, 0, _("'%s' is not a valid interface name"), val);
2833                 return FALSE;
2834         }
2835         g_object_set (setting, prop, val, NULL);
2836         return TRUE;
2837 }
2838
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)
2844
2845 static gboolean
2846 nmc_property_set_secret_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2847 {
2848         char **strv = NULL, **iter;
2849         unsigned long flags = 0, val_int;
2850
2851         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2852
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);
2858                         g_strfreev (strv);
2859                         return FALSE;
2860                 }
2861                 flags += val_int;
2862         }
2863         g_strfreev (strv);
2864
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);
2869         }
2870
2871         g_object_set (setting, prop, (guint) flags, NULL);
2872         return TRUE;
2873 }
2874
2875 static gboolean
2876 nmc_util_is_domain (const char *domain)
2877 {
2878         //FIXME: implement
2879         return TRUE;
2880 }
2881
2882 static gboolean
2883 nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *val, GError **error)
2884 {
2885         char **strv = NULL, **iter;
2886         char *val_strip;
2887         const char *delimiters = " \t,";
2888         long int val_int;
2889         GBytes *bytes;
2890         GByteArray *array = NULL;
2891         gboolean success = TRUE;
2892
2893         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2894
2895         val_strip = g_strstrip (g_strdup (val));
2896
2897         /* First try hex string in the format of AAbbCCDd */
2898         bytes = nm_utils_hexstr2bin (val_strip);
2899         if (bytes) {
2900                 array = g_bytes_unref_to_array (bytes);
2901                 goto done;
2902         }
2903
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);
2910                         success = FALSE;
2911                         goto done;
2912                 }
2913                 g_byte_array_append (array, (const guint8 *) &val_int, 1);
2914         }
2915
2916 done:
2917         if (success)
2918                 g_object_set (setting, prop, array, NULL);
2919
2920         g_strfreev (strv);
2921         if (array)
2922                 g_byte_array_free (array, TRUE);
2923         return success;
2924 }
2925
2926 #define DEFINE_SETTER_MAC_BLACKLIST(def_func, s_macro, add_func) \
2927         static gboolean \
2928         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2929         { \
2930                 guint8 buf[32]; \
2931                 char **list = NULL, **iter; \
2932                 GSList *macaddr_blacklist = NULL; \
2933                 \
2934                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2935                 \
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); \
2942                                 return FALSE; \
2943                         } \
2944                 } \
2945                 \
2946                 for (iter = list; iter && *iter; iter++) \
2947                         add_func (s_macro (setting), *iter); \
2948                 \
2949                 g_strfreev (list); \
2950                 return TRUE; \
2951         }
2952
2953 /* --- NM_SETTING_CONNECTION_SETTING_NAME property setter functions --- */
2954 #if 0
2955 /*
2956  * Setting/removing UUID has been forbidden.
2957  * Should it be enabled later, this function can be used.
2958  */
2959 static gboolean
2960 nmc_property_con_set_uuid (NMSetting *setting, const char *prop, const char *val, GError **error)
2961 {
2962         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2963
2964         if (!nm_utils_is_uuid (val)) {
2965                 g_set_error (error, 1, 0, _("'%s' is not a valid UUID"), val);
2966                 return FALSE;
2967         }
2968         g_object_set (setting, prop, val, NULL);
2969         return TRUE;
2970 }
2971 #endif
2972
2973 /* 'permissions' */
2974 /* define from libnm-core/nm-setting-connection.c */
2975 #define PERM_USER_PREFIX  "user:"
2976
2977 static gboolean
2978 permissions_valid (const char *perm)
2979 {
2980         if (!perm || perm[0] == '\0')
2981                 return FALSE;
2982
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), ':'))
2986                         return  FALSE;
2987         } else {
2988                 if (strchr (perm, ':'))
2989                         return  FALSE;
2990         }
2991
2992         return TRUE;
2993 }
2994
2995 static gboolean
2996 nmc_property_connection_set_permissions (NMSetting *setting, const char *prop, const char *val, GError **error)
2997 {
2998         char **strv = NULL;
2999         guint i = 0;
3000
3001         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3002
3003         strv = nmc_strsplit_set (val, " \t,", 0);
3004         if (!verify_string_list (strv, prop, permissions_valid, error)) {
3005                 g_strfreev (strv);
3006                 return FALSE;
3007         }
3008
3009         for (i = 0; strv && strv[i]; i++) {
3010                 const char *user;
3011
3012                 if (strncmp (strv[i], PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0)
3013                         user = strv[i]+strlen (PERM_USER_PREFIX);
3014                 else
3015                         user = strv[i];
3016
3017                 nm_setting_connection_add_permission (NM_SETTING_CONNECTION (setting), "user", user, NULL);
3018         }
3019
3020         return TRUE;
3021 }
3022
3023 static gboolean
3024 _validate_and_remove_connection_permission (NMSettingConnection *setting,
3025                                             const char *perm,
3026                                             GError **error)
3027 {
3028         gboolean ret;
3029
3030         ret = nm_setting_connection_remove_permission_by_value (setting, "user", perm, NULL);
3031         if (!ret)
3032                 g_set_error (error, 1, 0, _("the property doesn't contain permission '%s'"), perm);
3033         return ret;
3034 }
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)
3040
3041 static const char *
3042 nmc_property_connection_describe_permissions (NMSetting *setting, const char *prop)
3043 {
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");
3048 }
3049
3050 /* 'master' */
3051 static gboolean
3052 nmc_property_con_set_master (NMSetting *setting, const char *prop, const char *val, GError **error)
3053 {
3054         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3055
3056         if (!val)
3057                 ;
3058         else if (!*val)
3059                 val = NULL;
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"),
3064                              val);
3065                 return FALSE;
3066         }
3067         g_object_set (setting, prop, val, NULL);
3068         return TRUE;
3069 }
3070
3071 /* 'slave-type' */
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,
3076         NULL
3077 };
3078
3079 static gboolean
3080 nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3081 {
3082         return check_and_set_string (setting, prop, val, con_valid_slave_types, error);
3083 }
3084
3085
3086 DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_types)
3087
3088 /* 'secondaries' */
3089 static gboolean
3090 nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error)
3091 {
3092         NMConnection *con;
3093         char **strv = NULL, **iter;
3094         guint i = 0;
3095
3096         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3097
3098         strv = nmc_strsplit_set (val, " \t,", 0);
3099         for (iter = strv; iter && *iter; iter++) {
3100                 if (**iter == '\0')
3101                         continue;
3102
3103                 if (nm_utils_is_uuid (*iter)) {
3104                         con = nmc_find_connection (nm_cli.connections,
3105                                                    "uuid", *iter, NULL);
3106                         if (!con)
3107                                 g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
3108                         else {
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);
3112                                         g_strfreev (strv);
3113                                         return FALSE;
3114                                 }
3115                         }
3116                 } else {
3117                         con = nmc_find_connection (nm_cli.connections,
3118                                                    "id", *iter, NULL);
3119                         if (!con) {
3120                                 g_set_error (error, 1, 0, _("'%s' is not a name of any exiting profile"), *iter);
3121                                 g_strfreev (strv);
3122                                 return FALSE;
3123                         }
3124
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);
3128                                 g_strfreev (strv);
3129                                 return FALSE;
3130                         }
3131
3132                         /* translate id to uuid */
3133                         g_free (*iter);
3134                         *iter = g_strdup (nm_connection_get_uuid (con));
3135                 }
3136         }
3137
3138         while (strv && strv[i])
3139                 nm_setting_connection_add_secondary (NM_SETTING_CONNECTION (setting), strv[i++]);
3140         g_strfreev (strv);
3141
3142         return TRUE;
3143 }
3144
3145 static gboolean
3146 _validate_and_remove_connection_secondary (NMSettingConnection *setting,
3147                                            const char *secondary_uuid,
3148                                            GError **error)
3149 {
3150         gboolean ret;
3151
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);
3155                 return FALSE;
3156         }
3157
3158         ret = nm_setting_connection_remove_secondary_by_value (setting, secondary_uuid);
3159         if (!ret)
3160                 g_set_error (error, 1, 0,
3161                              _("the property doesn't contain UUID '%s'"), secondary_uuid);
3162         return ret;
3163 }
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)
3169
3170 static const char *
3171 nmc_property_connection_describe_secondaries (NMSetting *setting, const char *prop)
3172 {
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");
3179 }
3180
3181 /* 'metered' */
3182 static char *
3183 nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type)
3184 {
3185         NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3186
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");
3191                 case NM_METERED_NO:
3192                         return g_strdup ("no");
3193                 case NM_METERED_UNKNOWN:
3194                 default:
3195                         return g_strdup ("unknown");
3196                 }
3197         }
3198         switch (nm_setting_connection_get_metered (s_conn)) {
3199         case NM_METERED_YES:
3200                 return g_strdup (_("yes"));
3201         case NM_METERED_NO:
3202                 return g_strdup (_("no"));
3203         case NM_METERED_UNKNOWN:
3204         default:
3205                 return g_strdup (_("unknown"));
3206         }
3207 }
3208
3209 static gboolean
3210 nmc_property_connection_set_metered (NMSetting *setting, const char *prop,
3211                                      const char *val, GError **error)
3212 {
3213         NMMetered metered;
3214         NMCTriStateValue ts_val;
3215
3216         if (!nmc_string_to_tristate (val, &ts_val, error))
3217                 return FALSE;
3218
3219         switch (ts_val) {
3220         case NMC_TRI_STATE_YES:
3221                 metered = NM_METERED_YES;
3222                 break;
3223         case NMC_TRI_STATE_NO:
3224                 metered = NM_METERED_NO;
3225                 break;
3226         case NMC_TRI_STATE_UNKNOWN:
3227                 metered = NM_METERED_UNKNOWN;
3228                 break;
3229         default:
3230                 g_assert_not_reached();
3231         }
3232
3233         g_object_set (setting, prop, metered, NULL);
3234         return TRUE;
3235 }
3236
3237 static const char *
3238 nmc_property_connection_describe_metered (NMSetting *setting, const char *prop)
3239 {
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");
3245 }
3246
3247 /* 'lldp' */
3248 static char *
3249 nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type)
3250 {
3251         NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3252         NMSettingConnectionLldp lldp;
3253         char *tmp, *str;
3254
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");
3259         else
3260                 str = g_strdup_printf ("%d (%s)", lldp, tmp && *tmp ? tmp : "default");
3261         g_free (tmp);
3262         return str;
3263 }
3264
3265 static gboolean
3266 nmc_property_connection_set_lldp (NMSetting *setting, const char *prop,
3267                                   const char *val, GError **error)
3268 {
3269         NMSettingConnectionLldp lldp;
3270         gboolean ret;
3271         long int t;
3272
3273         if (nmc_string_to_int_base (val, 0, TRUE,
3274                                    NM_SETTING_CONNECTION_LLDP_DEFAULT,
3275                                    NM_SETTING_CONNECTION_LLDP_ENABLE_RX,
3276                                    &t))
3277                 lldp = t;
3278         else {
3279                 ret = nm_utils_enum_from_str (nm_setting_connection_lldp_get_type (), val,
3280                                               (int *) &lldp, NULL);
3281
3282                 if (!ret) {
3283                         if (g_ascii_strcasecmp (val, "enable") == 0)
3284                                 lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX;
3285                         else {
3286                                 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
3287                                              val, "default,disable,enable-rx,enable");
3288                                 return FALSE;
3289                         }
3290                 }
3291         }
3292
3293         g_object_set (setting, prop, lldp, NULL);
3294         return TRUE;
3295 }
3296
3297 /* --- NM_SETTING_802_1X_SETTING_NAME property setter functions --- */
3298 #define DEFINE_SETTER_STR_LIST(def_func, set_func) \
3299         static gboolean \
3300         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3301         { \
3302                 char **strv = NULL; \
3303                 guint i = 0; \
3304                 \
3305                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
3306                 \
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); \
3311                 return TRUE; \
3312         }
3313
3314 #define DEFINE_SETTER_CERT(def_func, set_func) \
3315         static gboolean \
3316         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3317         { \
3318                 char *val_strip = g_strstrip (g_strdup (val)); \
3319                 char *p = val_strip; \
3320                 gboolean success; \
3321                 \
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); \
3324                 \
3325                 success = set_func (NM_SETTING_802_1X (setting), \
3326                                     p, \
3327                                     NM_SETTING_802_1X_CK_SCHEME_PATH, \
3328                                     NULL, \
3329                                     error); \
3330                 g_free (val_strip); \
3331                 return success; \
3332         }
3333
3334 #define DEFINE_SETTER_PRIV_KEY(def_func, pwd_func, set_func) \
3335         static gboolean \
3336         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3337         { \
3338                 char **strv = NULL; \
3339                 char *val_strip = g_strstrip (g_strdup (val)); \
3340                 char *p = val_strip; \
3341                 const char *path, *password; \
3342                 gboolean success; \
3343                 \
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); \
3346                 \
3347                 strv = nmc_strsplit_set (p, " \t,", 2); \
3348                 path = strv[0]; \
3349                 if (g_strv_length (strv) == 2) \
3350                         password = strv[1]; \
3351                 else \
3352                         password = pwd_func (NM_SETTING_802_1X (setting)); \
3353                 if (password) { \
3354                         char *tmp_pwd = g_strdup (password); \
3355                         success = set_func (NM_SETTING_802_1X (setting), \
3356                                             path, \
3357                                             tmp_pwd, \
3358                                             NM_SETTING_802_1X_CK_SCHEME_PATH, \
3359                                             NULL, \
3360                                             error); \
3361                         g_free (tmp_pwd); \
3362                 } else { \
3363                         success = FALSE; \
3364                         g_set_error_literal  (error, 1, 0, _("private key password not provided")); \
3365                 } \
3366                 g_free (val_strip); \
3367                 g_strfreev (strv); \
3368                 return success; \
3369         }
3370
3371 /* 'eap' */
3372 static const char *valid_eap[] = { "leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", NULL };
3373
3374 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_802_1X_eap,
3375                               NM_SETTING_802_1X,
3376                               nm_setting_802_1x_add_eap_method)
3377 static gboolean
3378 nmc_property_802_1X_set_eap (NMSetting *setting, const char *prop, const char *val, GError **error)
3379 {
3380         return check_and_add_802_1X_eap (setting, prop, val, valid_eap, error);
3381 }
3382
3383 static gboolean
3384 _validate_and_remove_eap_method (NMSetting8021x *setting,
3385                                  const char *eap,
3386                                  GError **error)
3387 {
3388         gboolean ret;
3389
3390         ret = nm_setting_802_1x_remove_eap_method_by_value(setting, eap);
3391         if (!ret)
3392                 g_set_error (error, 1, 0, _("the property doesn't contain EAP method '%s'"), eap);
3393         return ret;
3394 }
3395 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_eap,
3396                                NM_SETTING_802_1X,
3397                                nm_setting_802_1x_get_num_eap_methods,
3398                                nm_setting_802_1x_remove_eap_method,
3399                                _validate_and_remove_eap_method)
3400
3401 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_eap, valid_eap)
3402
3403 /* 'ca-cert' */
3404 DEFINE_SETTER_CERT (nmc_property_802_1X_set_ca_cert, nm_setting_802_1x_set_ca_cert)
3405
3406 static const char *
3407 nmc_property_802_1X_describe_ca_cert (NMSetting *setting, const char *prop)
3408 {
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");
3413 }
3414
3415 /* 'altsubject-matches' */
3416 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_altsubject_matches, nm_setting_802_1x_add_altsubject_match)
3417
3418 static gboolean
3419 _validate_and_remove_altsubject_match (NMSetting8021x *setting,
3420                                        const char *altsubject_match,
3421                                        GError **error)
3422 {
3423         gboolean ret;
3424
3425         ret = nm_setting_802_1x_remove_altsubject_match_by_value (setting, altsubject_match);
3426         if (!ret)
3427                 g_set_error (error, 1, 0,
3428                              _("the property doesn't contain alternative subject match '%s'"),
3429                              altsubject_match);
3430         return ret;
3431 }
3432 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_altsubject_matches,
3433                                NM_SETTING_802_1X,
3434                                nm_setting_802_1x_get_num_altsubject_matches,
3435                                nm_setting_802_1x_remove_altsubject_match,
3436                                _validate_and_remove_altsubject_match)
3437
3438 /* 'client-cert' */
3439 DEFINE_SETTER_CERT (nmc_property_802_1X_set_client_cert, nm_setting_802_1x_set_client_cert)
3440
3441 static const char *
3442 nmc_property_802_1X_describe_client_cert (NMSetting *setting, const char *prop)
3443 {
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");
3448 }
3449
3450 /* 'phase2-ca-cert' */
3451 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert)
3452
3453 static const char *
3454 nmc_property_802_1X_describe_phase2_ca_cert (NMSetting *setting, const char *prop)
3455 {
3456         return _("Enter file path to CA certificate for inner authentication (optionally prefixed\n"
3457                  "with file://).\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");
3461 }
3462
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)
3465
3466 static gboolean
3467 _validate_and_remove_phase2_altsubject_match (NMSetting8021x *setting,
3468                                               const char *phase2_altsubject_match,
3469                                               GError **error)
3470 {
3471         gboolean ret;
3472
3473         ret = nm_setting_802_1x_remove_phase2_altsubject_match_by_value (setting, phase2_altsubject_match);
3474         if (!ret)
3475                 g_set_error (error, 1, 0,
3476                              _("the property doesn't contain \"phase2\" alternative subject match '%s'"),
3477                              phase2_altsubject_match);
3478         return ret;
3479 }
3480 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_phase2_altsubject_matches,
3481                                NM_SETTING_802_1X,
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)
3485
3486 /* 'phase2-client-cert' */
3487 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert)
3488
3489 static const char *
3490 nmc_property_802_1X_describe_phase2_client_cert (NMSetting *setting, const char *prop)
3491 {
3492         return _("Enter file path to client certificate for inner authentication (optionally prefixed\n"
3493                  "with file://).\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");
3497 }
3498
3499 /* 'private-key' */
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)
3503
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)
3508
3509 static const char *
3510 nmc_property_802_1X_describe_private_key (NMSetting *setting, const char *prop)
3511 {
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");
3516 }
3517
3518 /* 'phase1-peapver' */
3519 static const char *_802_1X_valid_phase1_peapvers[] = { "0", "1", NULL };
3520
3521 static gboolean
3522 nmc_property_802_1X_set_phase1_peapver (NMSetting *setting, const char *prop, const char *val, GError **error)
3523 {
3524         return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peapvers, error);
3525 }
3526
3527 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peapver, _802_1X_valid_phase1_peapvers)
3528
3529 /* 'phase1-peaplabel' */
3530 static const char *_802_1X_valid_phase1_peaplabels[] = { "0", "1", NULL };
3531
3532 static gboolean
3533 nmc_property_802_1X_set_phase1_peaplabel (NMSetting *setting, const char *prop, const char *val, GError **error)
3534 {
3535         return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peaplabels, error);
3536 }
3537
3538 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peaplabel, _802_1X_valid_phase1_peaplabels)
3539
3540 /* 'phase1-fast-provisioning' */
3541 static const char *_802_1X_valid_phase1_fast_provisionings[] = { "0", "1", "2", "3", NULL };
3542
3543 static gboolean
3544 nmc_property_802_1X_set_phase1_fast_provisioning (NMSetting *setting, const char *prop, const char *val, GError **error)
3545 {
3546         return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_fast_provisionings, error);
3547 }
3548
3549 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_fast_provisioning, _802_1X_valid_phase1_fast_provisionings)
3550
3551 /* 'phase2-auth' */
3552 static const char *_802_1X_valid_phase2_auths[] =
3553         { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL };
3554
3555 static gboolean
3556 nmc_property_802_1X_set_phase2_auth (NMSetting *setting, const char *prop, const char *val, GError **error)
3557 {
3558         return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_auths, error);
3559 }
3560
3561 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_auth, _802_1X_valid_phase2_auths)
3562
3563 /* 'phase2-autheap' */
3564 static const char *_802_1X_valid_phase2_autheaps[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL };
3565 static gboolean
3566 nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, const char *val, GError **error)
3567 {
3568         return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_autheaps, error);
3569 }
3570
3571 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_valid_phase2_autheaps)
3572
3573 /* 'password-raw' */
3574 static gboolean
3575 nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error)
3576 {
3577         return nmc_property_set_byte_array (setting, prop, val, error);
3578 }
3579
3580 static const char *
3581 nmc_property_802_1X_describe_password_raw (NMSetting *setting, const char *prop)
3582 {
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");
3590 }
3591
3592 /* --- NM_SETTING_ADSL_SETTING_NAME property setter functions --- */
3593 /* 'protocol' */
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,
3598         NULL
3599 };
3600
3601 static gboolean
3602 nmc_property_adsl_set_protocol (NMSetting *setting, const char *prop, const char *val, GError **error)
3603 {
3604         return check_and_set_string (setting, prop, val, adsl_valid_protocols, error);
3605 }
3606
3607 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_protocol, adsl_valid_protocols)
3608
3609 /* 'encapsulation' */
3610 static const char *adsl_valid_encapsulations[] = {
3611         NM_SETTING_ADSL_ENCAPSULATION_VCMUX,
3612         NM_SETTING_ADSL_ENCAPSULATION_LLC,
3613         NULL
3614 };
3615
3616 static gboolean
3617 nmc_property_adsl_set_encapsulation (NMSetting *setting, const char *prop, const char *val, GError **error)
3618 {
3619         return check_and_set_string (setting, prop, val, adsl_valid_encapsulations, error);
3620 }
3621
3622 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_encapsulation, adsl_valid_encapsulations)
3623
3624 /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property setter functions --- */
3625 /* 'type' */
3626 static gboolean
3627 nmc_property_bluetooth_set_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3628 {
3629         const char *types[] = {
3630             NM_SETTING_BLUETOOTH_TYPE_DUN,
3631             NM_SETTING_BLUETOOTH_TYPE_PANU,
3632             NULL };
3633
3634         return check_and_set_string (setting, prop, val, types, error);
3635 }
3636
3637 /* --- NM_SETTING_BOND_SETTING_NAME property setter functions --- */
3638 /* 'options' */
3639 /*  example: miimon=100,mode=balance-rr, updelay=5 */
3640 static gboolean
3641 _validate_and_remove_bond_option (NMSettingBond *setting, const char *option)
3642 {
3643         const char *opt;
3644         const char **valid_options;
3645
3646         valid_options = nm_setting_bond_get_valid_options (setting);
3647         opt = nmc_string_is_valid (option, valid_options, NULL);
3648
3649         if (opt)
3650                 return nm_setting_bond_remove_option (setting, opt);
3651         else
3652                 return FALSE;
3653 }
3654
3655 /* Validate bonding 'options' values */
3656 static const char *
3657 _validate_bond_option_value (const char *option, const char *value, GError **error)
3658 {
3659         if (!g_strcmp0 (option, NM_SETTING_BOND_OPTION_MODE))
3660                 return nmc_bond_validate_mode (value, error);
3661
3662         return value;
3663 }
3664
3665 static gboolean
3666 _bond_add_option (NMSettingBond *setting,
3667                   const char *name,
3668                   const char *value)
3669 {
3670         gs_free char *tmp_value = NULL;
3671         char *p;
3672
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++)
3676                         if (*p == ' ')
3677                                 *p = ',';
3678         }
3679
3680         return nm_setting_bond_add_option (setting, name, value);
3681 }
3682
3683 DEFINE_SETTER_OPTIONS (nmc_property_bond_set_options,
3684                        NM_SETTING_BOND,
3685                        NMSettingBond,
3686                        _bond_add_option,
3687                        nm_setting_bond_get_valid_options,
3688                        _validate_bond_option_value)
3689 DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options,
3690                        NM_SETTING_BOND,
3691                        _validate_and_remove_bond_option)
3692
3693 static const char *
3694 nmc_property_bond_describe_options (NMSetting *setting, const char *prop)
3695 {
3696         static char *desc = NULL;
3697         const char **valid_options;
3698         char *options_str;
3699
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);
3703
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"
3708                                           "balance-rr    = 0\n"
3709                                           "active-backup = 1\n"
3710                                           "balance-xor   = 2\n"
3711                                           "broadcast     = 3\n"
3712                                           "802.3ad       = 4\n"
3713                                           "balance-tlb   = 5\n"
3714                                           "balance-alb   = 6\n\n"
3715                                           "Example: mode=2,miimon=120\n"), options_str);
3716                 g_free (options_str);
3717         }
3718         return desc;
3719 }
3720
3721 static const char **
3722 nmc_property_bond_allowed_options (NMSetting *setting, const char *prop)
3723 {
3724         return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3725 }
3726
3727 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property setter functions --- */
3728 /* 'mac-address' */
3729 static gboolean
3730 nmc_property_ib_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
3731 {
3732         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3733
3734         if (!nm_utils_hwaddr_valid (val, INFINIBAND_ALEN)) {
3735                 g_set_error (error, 1, 0, _("'%s' is not a valid InfiniBand MAC"), val);
3736                 return FALSE;
3737         }
3738
3739         g_object_set (setting, prop, val, NULL);
3740         return TRUE;
3741 }
3742
3743 /* 'transport-mode' */
3744 static const char *ib_valid_transport_modes[] = { "datagram", "connected", NULL };
3745
3746 static gboolean
3747 nmc_property_ib_set_transport_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
3748 {
3749         return check_and_set_string (setting, prop, val, ib_valid_transport_modes, error);
3750 }
3751
3752 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ib_allowed_transport_mode, ib_valid_transport_modes)
3753
3754 /* 'p-key' */
3755 static gboolean
3756 nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val, GError **error)
3757 {
3758         gboolean p_key_valid = FALSE;
3759         long p_key_int;
3760
3761         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3762
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);
3765         else
3766                 p_key_valid = nmc_string_to_int (val, TRUE, -1, G_MAXUINT16, &p_key_int);
3767
3768         if (!p_key_valid) {
3769                 if (strcmp (val, "default") == 0)
3770                         p_key_int = -1;
3771                 else {
3772                         g_set_error (error, 1, 0, _("'%s' is not a valid IBoIP P_Key"), val);
3773                         return FALSE;
3774                 }
3775         }
3776         g_object_set (setting, prop, (gint) p_key_int, NULL);
3777         return TRUE;
3778 }
3779
3780 /* --- IP4 / IP6 shared functions --- */
3781 static NMIPAddress *
3782 _parse_ip_address (int family, const char *address, GError **error)
3783 {
3784         char *value = g_strdup (address);
3785         NMIPAddress *ipaddr;
3786
3787         ipaddr = nmc_parse_and_build_address (family, g_strstrip (value), error);
3788         g_free (value);
3789         return ipaddr;
3790 }
3791
3792 static NMIPRoute *
3793 _parse_ip_route (int family, const char *route, GError **error)
3794 {
3795         char *value = g_strdup (route);
3796         char **routev;
3797         guint len;
3798         NMIPRoute *iproute = NULL;
3799
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])"),
3804                              route);
3805                 goto finish;
3806         }
3807         iproute = nmc_parse_and_build_route (family, routev[0], routev[1], len >= 2 ? routev[2] : NULL, error);
3808
3809 finish:
3810         g_free (value);
3811         g_strfreev (routev);
3812         return iproute;
3813 }
3814
3815 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property setter functions --- */
3816 /* 'method' */
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,
3823         NULL
3824 };
3825
3826 static gboolean
3827 nmc_property_ipv4_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
3828 {
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;
3832
3833         return check_and_set_string (setting, prop, val, ipv4_valid_methods, error);
3834 }
3835
3836 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods)
3837
3838 /* 'dns' */
3839 static gboolean
3840 nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
3841 {
3842         char **strv = NULL, **iter, *addr;
3843         guint32 ip4_addr;
3844
3845         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3846
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);
3852                         g_strfreev (strv);
3853                         return FALSE;
3854                 }
3855                 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
3856         }
3857         g_strfreev (strv);
3858         return TRUE;
3859 }
3860
3861 static gboolean
3862 _validate_and_remove_ipv4_dns (NMSettingIPConfig *setting,
3863                                const char *dns,
3864                                GError **error)
3865 {
3866         guint32 ip4_addr;
3867         gboolean ret;
3868
3869         if (inet_pton (AF_INET, dns, &ip4_addr) < 1) {
3870                 g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), dns);
3871                 return FALSE;
3872         }
3873
3874         ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
3875         if (!ret)
3876                 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
3877         return ret;
3878 }
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)
3884
3885 static const char *
3886 nmc_property_ipv4_describe_dns (NMSetting *setting, const char *prop)
3887 {
3888         return _("Enter a list of IPv4 addresses of DNS servers.\n\n"
3889                  "Example: 8.8.8.8, 8.8.4.4\n");
3890 }
3891
3892 /* 'dns-search' */
3893 static gboolean
3894 nmc_property_ipv4_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
3895 {
3896         char **strv = NULL;
3897         guint i = 0;
3898
3899         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3900
3901         strv = nmc_strsplit_set (val, " \t,", 0);
3902         if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
3903                 g_strfreev (strv);
3904                 return FALSE;
3905         }
3906
3907         while (strv && strv[i])
3908                 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3909         g_strfreev (strv);
3910
3911         return TRUE;
3912 }
3913
3914 static gboolean
3915 _validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting,
3916                                       const char *dns_search,
3917                                       GError **error)
3918 {
3919         gboolean ret;
3920
3921         ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
3922         if (!ret)
3923                 g_set_error (error, 1, 0,
3924                              _("the property doesn't contain DNS search domain '%s'"),
3925                              dns_search);
3926         return ret;
3927 }
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)
3933
3934 /* 'dns-options' */
3935 static gboolean
3936 nmc_property_ipv4_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
3937 {
3938         char **strv = NULL;
3939         guint i = 0;
3940
3941         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3942
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++]);
3947         g_strfreev (strv);
3948
3949         return TRUE;
3950 }
3951
3952 static gboolean
3953 _validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting,
3954                                       const char *dns_option,
3955                                       GError **error)
3956 {
3957         gboolean ret;
3958
3959         ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
3960         if (!ret)
3961                 g_set_error (error, 1, 0,
3962                              _("the property doesn't contain DNS option '%s'"),
3963                              dns_option);
3964         return ret;
3965 }
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)
3971
3972 /* 'addresses' */
3973 static NMIPAddress *
3974 _parse_ipv4_address (const char *address, GError **error)
3975 {
3976         return _parse_ip_address (AF_INET, address, error);
3977 }
3978
3979 static gboolean
3980 nmc_property_ipv4_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
3981 {
3982         char **strv = NULL, **iter;
3983         NMIPAddress *ip4addr;
3984
3985         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3986
3987         strv = nmc_strsplit_set (val, ",", 0);
3988         for (iter = strv; iter && *iter; iter++) {
3989                 ip4addr = _parse_ipv4_address (*iter, error);
3990                 if (!ip4addr) {
3991                         g_strfreev (strv);
3992                         return FALSE;
3993                 }
3994                 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip4addr);
3995                 nm_ip_address_unref (ip4addr);
3996         }
3997         g_strfreev (strv);
3998         return TRUE;
3999 }
4000
4001 static gboolean
4002 _validate_and_remove_ipv4_address (NMSettingIPConfig *setting,
4003                                    const char *address,
4004                                    GError **error)
4005 {
4006         NMIPAddress *ip4addr;
4007         gboolean ret;
4008
4009         ip4addr = _parse_ipv4_address (address, error);
4010         if (!ip4addr)
4011                 return FALSE;
4012
4013         ret = nm_setting_ip_config_remove_address_by_value (setting, ip4addr);
4014         if (!ret)
4015                 g_set_error (error, 1, 0,
4016                              _("the property doesn't contain IP address '%s'"), address);
4017         nm_ip_address_unref (ip4addr);
4018         return ret;
4019 }
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)
4025
4026 static const char *
4027 nmc_property_ipv4_describe_addresses (NMSetting *setting, const char *prop)
4028 {
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");
4033 }
4034
4035 /* 'gateway' */
4036 static gboolean
4037 nmc_property_ipv4_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4038 {
4039         NMIPAddress *ip4addr;
4040
4041         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4042
4043         if (strchr (val, '/')) {
4044                 g_set_error (error, 1, 0,
4045                              _("invalid gateway address '%s'"), val);
4046                 return FALSE;
4047         }
4048         ip4addr = _parse_ipv4_address (val, error);
4049         if (!ip4addr)
4050                 return FALSE;
4051
4052         g_object_set (setting, prop, val, NULL);
4053         nm_ip_address_unref (ip4addr);
4054         return TRUE;
4055 }
4056
4057 /* 'routes' */
4058 static NMIPRoute *
4059 _parse_ipv4_route (const char *route, GError **error)
4060 {
4061         return _parse_ip_route (AF_INET, route, error);
4062 }
4063
4064 static gboolean
4065 nmc_property_ipv4_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4066 {
4067         char **strv = NULL, **iter;
4068         NMIPRoute *ip4route;
4069
4070         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4071
4072         strv = nmc_strsplit_set (val, ",", 0);
4073         for (iter = strv; iter && *iter; iter++) {
4074                 ip4route = _parse_ipv4_route (*iter, error);
4075                 if (!ip4route) {
4076                         g_strfreev (strv);
4077                         return FALSE;
4078                 }
4079                 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip4route);
4080                 nm_ip_route_unref (ip4route);
4081         }
4082         g_strfreev (strv);
4083         return TRUE;
4084 }
4085
4086 static gboolean
4087 _validate_and_remove_ipv4_route (NMSettingIPConfig *setting,
4088                                  const char *route,
4089                                  GError **error)
4090 {
4091         NMIPRoute *ip4route;
4092         gboolean ret;
4093
4094         ip4route = _parse_ipv4_route (route, error);
4095         if (!ip4route)
4096                 return FALSE;
4097
4098         ret = nm_setting_ip_config_remove_route_by_value (setting, ip4route);
4099         if (!ret)
4100                 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4101         nm_ip_route_unref (ip4route);
4102         return ret;
4103 }
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)
4109
4110 static const char *
4111 nmc_property_ipv4_describe_routes (NMSetting *setting, const char *prop)
4112 {
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"
4119                  "          10.1.2.0/24\n");
4120 }
4121
4122 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property setter functions --- */
4123 /* 'method' */
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,
4131         NULL
4132 };
4133
4134 static gboolean
4135 nmc_property_ipv6_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
4136 {
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;
4140
4141         return check_and_set_string (setting, prop, val, ipv6_valid_methods, error);
4142 }
4143
4144 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods)
4145
4146 /* 'dns' */
4147 static gboolean
4148 nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
4149 {
4150         char **strv = NULL, **iter, *addr;
4151         struct in6_addr ip6_addr;
4152
4153         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4154
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);
4160                         g_strfreev (strv);
4161                         return FALSE;
4162                 }
4163                 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
4164         }
4165         g_strfreev (strv);
4166         return TRUE;
4167 }
4168
4169 static gboolean
4170 _validate_and_remove_ipv6_dns (NMSettingIPConfig *setting,
4171                                const char *dns,
4172                                GError **error)
4173 {
4174         struct in6_addr ip6_addr;
4175         gboolean ret;
4176
4177         if (inet_pton (AF_INET6, dns, &ip6_addr) < 1) {
4178                 g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), dns);
4179                 return FALSE;
4180         }
4181
4182         ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
4183         if (!ret)
4184                 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
4185         return ret;
4186 }
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)
4192
4193 static const char *
4194 nmc_property_ipv6_describe_dns (NMSetting *setting, const char *prop)
4195 {
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");
4204 }
4205
4206 /* 'dns-search' */
4207 static gboolean
4208 nmc_property_ipv6_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
4209 {
4210         char **strv = NULL;
4211         guint i = 0;
4212
4213         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4214
4215         strv = nmc_strsplit_set (val, " \t,", 0);
4216         if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
4217                 g_strfreev (strv);
4218                 return FALSE;
4219         }
4220
4221         while (strv && strv[i])
4222                 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4223         g_strfreev (strv);
4224
4225         return TRUE;
4226 }
4227
4228 static gboolean
4229 _validate_and_remove_ipv6_dns_search (NMSettingIPConfig *setting,
4230                                       const char *dns_search,
4231                                       GError **error)
4232 {
4233         gboolean ret;
4234
4235         ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
4236         if (!ret)
4237                 g_set_error (error, 1, 0,
4238                              _("the property doesn't contain DNS search domain '%s'"),
4239                              dns_search);
4240         return ret;
4241 }
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)
4247
4248 /* 'dns-options' */
4249 static gboolean
4250 nmc_property_ipv6_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
4251 {
4252         char **strv = NULL;
4253         guint i = 0;
4254
4255         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4256
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++]);
4261         g_strfreev (strv);
4262
4263         return TRUE;
4264 }
4265
4266 static gboolean
4267 _validate_and_remove_ipv6_dns_option (NMSettingIPConfig *setting,
4268                                       const char *dns_option,
4269                                       GError **error)
4270 {
4271         gboolean ret;
4272
4273         ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
4274         if (!ret)
4275                 g_set_error (error, 1, 0,
4276                              _("the property doesn't contain DNS option '%s'"),
4277                              dns_option);
4278         return ret;
4279 }
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)
4285
4286 /* 'addresses' */
4287 static NMIPAddress *
4288 _parse_ipv6_address (const char *address, GError **error)
4289 {
4290         return _parse_ip_address (AF_INET6, address, error);
4291 }
4292
4293 static gboolean
4294 nmc_property_ipv6_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
4295 {
4296         char **strv = NULL, **iter;
4297         NMIPAddress *ip6addr;
4298
4299         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4300
4301         strv = nmc_strsplit_set (val, ",", 0);
4302         for (iter = strv; iter && *iter; iter++) {
4303                 ip6addr = _parse_ipv6_address (*iter, error);
4304                 if (!ip6addr) {
4305                         g_strfreev (strv);
4306                         return FALSE;
4307                 }
4308                 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip6addr);
4309                 nm_ip_address_unref (ip6addr);
4310         }
4311         g_strfreev (strv);
4312         return TRUE;
4313 }
4314
4315 static gboolean
4316 _validate_and_remove_ipv6_address (NMSettingIPConfig *setting,
4317                                    const char *address,
4318                                    GError **error)
4319 {
4320         NMIPAddress *ip6addr;
4321         gboolean ret;
4322
4323         ip6addr = _parse_ipv6_address (address, error);
4324         if (!ip6addr)
4325                 return FALSE;
4326
4327         ret = nm_setting_ip_config_remove_address_by_value (setting, ip6addr);
4328         if (!ret)
4329                 g_set_error (error, 1, 0, _("the property doesn't contain IP address '%s'"), address);
4330         nm_ip_address_unref (ip6addr);
4331         return ret;
4332 }
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)
4338
4339 static const char *
4340 nmc_property_ipv6_describe_addresses (NMSetting *setting, const char *prop)
4341 {
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");
4346 }
4347
4348 /* 'gateway' */
4349 static gboolean
4350 nmc_property_ipv6_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4351 {
4352         NMIPAddress *ip6addr;
4353
4354         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4355
4356         if (strchr (val, '/')) {
4357                 g_set_error (error, 1, 0,
4358                              _("invalid gateway address '%s'"), val);
4359                 return FALSE;
4360         }
4361         ip6addr = _parse_ipv6_address (val, error);
4362         if (!ip6addr)
4363                 return FALSE;
4364
4365         g_object_set (setting, prop, val, NULL);
4366         nm_ip_address_unref (ip6addr);
4367         return TRUE;
4368 }
4369
4370 /* 'routes' */
4371 static NMIPRoute *
4372 _parse_ipv6_route (const char *route, GError **error)
4373 {
4374         return _parse_ip_route (AF_INET6, route, error);
4375 }
4376
4377 static gboolean
4378 nmc_property_ipv6_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4379 {
4380         char **strv = NULL, **iter;
4381         NMIPRoute *ip6route;
4382
4383         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4384
4385         strv = nmc_strsplit_set (val, ",", 0);
4386         for (iter = strv; iter && *iter; iter++) {
4387                 ip6route = _parse_ipv6_route (*iter, error);
4388                 if (!ip6route) {
4389                         g_strfreev (strv);
4390                         return FALSE;
4391                 }
4392                 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip6route);
4393                 nm_ip_route_unref (ip6route);
4394         }
4395         g_strfreev (strv);
4396         return TRUE;
4397 }
4398
4399 static gboolean
4400 _validate_and_remove_ipv6_route (NMSettingIPConfig *setting,
4401                                  const char *route,
4402                                  GError **error)
4403 {
4404         NMIPRoute *ip6route;
4405         gboolean ret;
4406
4407         ip6route = _parse_ipv6_route (route, error);
4408         if (!ip6route)
4409                 return FALSE;
4410
4411         ret = nm_setting_ip_config_remove_route_by_value (setting, ip6route);
4412         if (!ret)
4413                 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4414         nm_ip_route_unref (ip6route);
4415         return ret;
4416 }
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)
4422
4423 static const char *
4424 nmc_property_ipv6_describe_routes (NMSetting *setting, const char *prop)
4425 {
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"
4432                  "          abbe::/64 55\n");
4433 }
4434
4435 static gboolean
4436 nmc_property_ipv6_set_ip6_privacy (NMSetting *setting, const char *prop, const char *val, GError **error)
4437 {
4438         unsigned long val_int;
4439
4440         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4441
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);
4444                 return FALSE;
4445         }
4446
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);
4451                 return FALSE;
4452         }
4453
4454         g_object_set (setting, prop, val_int, NULL);
4455         return TRUE;
4456 }
4457
4458 /* 'addr_gen_mode' */
4459 static char *
4460 nmc_property_ipv6_get_addr_gen_mode (NMSetting *setting, NmcPropertyGetType get_type)
4461 {
4462         NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
4463         NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4464
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);
4467 }
4468
4469
4470 static gboolean
4471 nmc_property_ipv6_set_addr_gen_mode (NMSetting *setting, const char *prop,
4472                                      const char *val, GError **error)
4473 {
4474         NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4475
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");
4480                         return FALSE;
4481         }
4482
4483         g_object_set (setting, prop, addr_gen_mode, NULL);
4484         return TRUE;
4485 }
4486
4487
4488 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property setter functions --- */
4489 static gboolean
4490 nmc_property_olpc_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4491 {
4492         unsigned long chan_int;
4493
4494         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4495
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);
4498                 return FALSE;
4499         }
4500         g_object_set (setting, prop, chan_int, NULL);
4501         return TRUE;
4502 }
4503
4504
4505 /* --- NM_SETTING_SERIAL_SETTING_NAME property setter functions --- */
4506 static char *
4507 nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type)
4508 {
4509         NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
4510
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");
4516         default:
4517         case NM_SETTING_SERIAL_PARITY_NONE:
4518                 return g_strdup ("none");
4519         }
4520 }
4521
4522 static gboolean
4523 nmc_property_serial_set_parity (NMSetting *setting, const char *prop, const char *val, GError **error)
4524 {
4525         NMSettingSerialParity parity;
4526
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;
4533         else {
4534                 g_set_error (error, 1, 0, _("'%s' is not valid; use [e, o, n]"), val);
4535                 return FALSE;
4536         }
4537
4538         g_object_set (setting, prop, parity, NULL);
4539         return TRUE;
4540 }
4541
4542 /* --- NM_SETTING_TEAM_SETTING_NAME property functions --- */
4543 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property functions --- */
4544 static gboolean
4545 nmc_property_team_set_config (NMSetting *setting, const char *prop, const char *val, GError **error)
4546 {
4547         char *json = NULL;
4548
4549         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4550
4551         if (!nmc_team_check_config (val, &json, error)) {
4552                 return FALSE;
4553         }
4554         g_object_set (setting, prop, json, NULL);
4555         g_free (json);
4556         return TRUE;
4557 }
4558
4559 static const char *
4560 nmc_property_team_describe_config (NMSetting *setting, const char *prop)
4561 {
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");
4568 }
4569
4570 /* --- NM_SETTING_VLAN_SETTING_NAME property setter functions --- */
4571 static gboolean
4572 nmc_property_vlan_set_prio_map (NMSetting *setting,
4573                                 const char *prop,
4574                                 const char *val,
4575                                 NMVlanPriorityMap map_type,
4576                                 GError **error)
4577 {
4578         char **prio_map, **p;
4579
4580         prio_map = nmc_vlan_parse_priority_maps (val, map_type, error);
4581         if (!prio_map)
4582                 return FALSE;
4583
4584         for (p = prio_map; p && *p; p++)
4585                 nm_setting_vlan_add_priority_str (NM_SETTING_VLAN (setting), map_type, *p);
4586
4587         g_strfreev (prio_map);
4588         return TRUE;
4589 }
4590
4591 static gboolean
4592 nmc_property_vlan_remove_prio_map (NMSetting *setting,
4593                                    const char *prop,
4594                                    guint32 idx,
4595                                    NMVlanPriorityMap map_type,
4596                                    GError **error)
4597 {
4598         guint32 num;
4599
4600         num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type);
4601         if (num == 0) {
4602                 g_set_error_literal (error, 1, 0, _("no priority to remove"));
4603                 return FALSE;
4604         }
4605         if (idx >= num) {
4606                 g_set_error (error, 1, 0, _("index '%d' is not in the range of <0-%d>"),
4607                              idx, num - 1);
4608                 return FALSE;
4609         }
4610
4611         nm_setting_vlan_remove_priority (NM_SETTING_VLAN (setting), map_type, idx);
4612         return TRUE;
4613 }
4614
4615 static gboolean
4616 nmc_property_vlan_set_ingress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4617 {
4618         return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_INGRESS_MAP, error);
4619 }
4620
4621 static gboolean
4622 nmc_property_vlan_set_egress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4623 {
4624         return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_EGRESS_MAP, error);
4625 }
4626
4627 static gboolean
4628 nmc_property_vlan_remove_priority_map (NMSetting *setting,
4629                                        const char *prop,
4630                                        const char *value,
4631                                        guint32 idx,
4632                                        NMVlanPriorityMap map,
4633                                        GError **error)
4634 {
4635         /* If value != NULL, remove by value */
4636         if (value) {
4637                 gboolean ret;
4638                 char **prio_map;
4639                 char *val = g_strdup (value);
4640
4641                 prio_map = nmc_vlan_parse_priority_maps (val, map, error);
4642                 if (!prio_map)
4643                         return FALSE;
4644                 if (prio_map[1])
4645                         g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
4646                                  prio_map[0]);
4647                 ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
4648                                                                     map,
4649                                                                     prio_map[0]);
4650
4651                 if (!ret)
4652                         g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]);
4653                 g_free (val);
4654                 g_strfreev (prio_map);
4655                 return ret;
4656         }
4657
4658         /* Else remove by index */
4659         return nmc_property_vlan_remove_prio_map (setting, prop, idx, map, error);
4660 }
4661
4662 static gboolean
4663 nmc_property_vlan_remove_ingress_priority_map (NMSetting *setting,
4664                                                const char *prop,
4665                                                const char *value,
4666                                                guint32 idx,
4667                                                GError **error)
4668 {
4669         return nmc_property_vlan_remove_priority_map (setting,
4670                                                       prop,
4671                                                       value,
4672                                                       idx,
4673                                                       NM_VLAN_INGRESS_MAP,
4674                                                       error);
4675 }
4676
4677 static gboolean
4678 nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
4679                                               const char *prop,
4680                                               const char *value,
4681                                               guint32 idx,
4682                                               GError **error)
4683 {
4684         return nmc_property_vlan_remove_priority_map (setting,
4685                                                       prop,
4686                                                       value,
4687                                                       idx,
4688                                                       NM_VLAN_EGRESS_MAP,
4689                                                       error);
4690 }
4691
4692 /* --- NM_SETTING_VPN_SETTING_NAME property setter functions --- */
4693 /* Validate value of vpn 'data' and 'secret'  options */
4694 static const char *
4695 _validate_vpn_hash_value (const char *option, const char *value, GError **error)
4696 {
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);
4701                 return NULL;
4702         }
4703         return value;
4704 }
4705
4706 /* 'data' */
4707 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
4708                        NM_SETTING_VPN,
4709                        NMSettingVpn,
4710                        nm_setting_vpn_add_data_item,
4711                        NULL,
4712                        _validate_vpn_hash_value)
4713 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
4714                        NM_SETTING_VPN,
4715                        nm_setting_vpn_remove_data_item)
4716
4717 /* 'secrets' */
4718 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
4719                        NM_SETTING_VPN,
4720                        NMSettingVpn,
4721                        nm_setting_vpn_add_secret,
4722                        NULL,
4723                        _validate_vpn_hash_value)
4724 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret,
4725                        NM_SETTING_VPN,
4726                        nm_setting_vpn_remove_secret)
4727
4728 /* --- NM_SETTING_WIMAX_SETTING_NAME property setter functions --- */
4729 /* No specific functions */
4730
4731 /* --- NM_SETTING_WIRED_SETTING_NAME property setter functions --- */
4732 #if 0
4733 /*
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.
4736  */
4737 /* 'port' */
4738 static const char *wired_valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
4739
4740 static gboolean
4741 nmc_property_wired_set_port (NMSetting *setting, const char *prop, const char *val, GError **error)
4742 {
4743         return check_and_set_string (setting, prop, val, wired_valid_ports, error);
4744 }
4745
4746 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_port, wired_valid_ports)
4747
4748 /* 'duplex' */
4749 static const char *wired_valid_duplexes[] = { "half", "full", NULL };
4750
4751 static gboolean
4752 nmc_property_wired_set_duplex (NMSetting *setting, const char *prop, const char *val, GError **error)
4753 {
4754         return check_and_set_string (setting, prop, val, wired_valid_duplexes, error);
4755 }
4756
4757 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_duplex, wired_valid_duplexes)
4758 #endif
4759
4760 /* 'mac-address-blacklist' */
4761 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wired_set_mac_address_blacklist,
4762                              NM_SETTING_WIRED,
4763                              nm_setting_wired_add_mac_blacklist_item)
4764
4765 static gboolean
4766 _validate_and_remove_wired_mac_blacklist_item (NMSettingWired *setting,
4767                                               const char *mac,
4768                                               GError **error)
4769 {
4770         gboolean ret;
4771         guint8 buf[32];
4772
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);
4775                 return FALSE;
4776         }
4777
4778         ret = nm_setting_wired_remove_mac_blacklist_item_by_value (setting, mac);
4779         if (!ret)
4780                 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4781         return ret;
4782 }
4783 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wired_remove_mac_address_blacklist,
4784                                NM_SETTING_WIRED,
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)
4788
4789 /* 's390-subchannels' */
4790 static gboolean
4791 nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, const char *val, GError **error)
4792 {
4793         char **strv = NULL;
4794         int len;
4795
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"),
4800                              val);
4801                 g_strfreev (strv);
4802                 return FALSE;
4803         }
4804
4805         g_object_set (setting, prop, strv, NULL);
4806         g_strfreev (strv);
4807         return TRUE;
4808 }
4809
4810 static const char *
4811 nmc_property_wired_describe_s390_subchannels (NMSetting *setting, const char *prop)
4812 {
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");
4815 }
4816
4817 /* 's390-nettype' */
4818 static const char *wired_valid_s390_nettypes[] = { "qeth", "lcs", "ctc", NULL };
4819
4820 static gboolean
4821 nmc_property_wired_set_s390_nettype (NMSetting *setting, const char *prop, const char *val, GError **error)
4822 {
4823         return check_and_set_string (setting, prop, val, wired_valid_s390_nettypes, error);
4824 }
4825
4826 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_s390_nettype, wired_valid_s390_nettypes)
4827
4828 /* 's390-options' */
4829 /* Validate value of 's390-options' */
4830 static const char *
4831 _validate_s390_option_value (const char *option, const char *value, GError **error)
4832 {
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);
4836                 return NULL;
4837         }
4838         return value;
4839 }
4840 DEFINE_SETTER_OPTIONS (nmc_property_wired_set_s390_options,
4841                        NM_SETTING_WIRED,
4842                        NMSettingWired,
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,
4847                        NM_SETTING_WIRED,
4848                        nm_setting_wired_remove_s390_option)
4849
4850 static const char **
4851 nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop)
4852 {
4853         return nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4854 }
4855
4856 static const char *
4857 nmc_property_wired_describe_s390_options (NMSetting *setting, const char *prop)
4858 {
4859         static char *desc = NULL;
4860         const char **valid_options;
4861         char *options_str;
4862
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);
4866
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"),
4870                                         options_str);
4871                 g_free (options_str);
4872         }
4873         return desc;
4874 }
4875
4876 /* --- NM_SETTING_WIRELESS_SETTING_NAME property setter functions --- */
4877 /* 'mode' */
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,
4882         NULL
4883 };
4884
4885 static gboolean
4886 nmc_property_wifi_set_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
4887 {
4888         return check_and_set_string (setting, prop, val, wifi_valid_modes, error);
4889 }
4890
4891 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_mode, wifi_valid_modes)
4892
4893 /* 'band' */
4894 static const char *wifi_valid_bands[] = { "a", "bg", NULL };
4895
4896 static gboolean
4897 nmc_property_wifi_set_band (NMSetting *setting, const char *prop, const char *val, GError **error)
4898 {
4899         return check_and_set_string (setting, prop, val, wifi_valid_bands, error);
4900 }
4901
4902 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_band, wifi_valid_bands)
4903
4904 /* 'channel' */
4905 static gboolean
4906 nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4907 {
4908         unsigned long chan_int;
4909
4910         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4911
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);
4914                 return FALSE;
4915         }
4916
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);
4920                 return FALSE;
4921         }
4922
4923         g_object_set (setting, prop, chan_int, NULL);
4924         return TRUE;
4925 }
4926
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)
4931
4932 static gboolean
4933 _validate_and_remove_wifi_mac_blacklist_item (NMSettingWireless *setting,
4934                                               const char *mac,
4935                                               GError **error)
4936 {
4937         gboolean ret;
4938         guint8 buf[32];
4939
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);
4942                 return FALSE;
4943         }
4944
4945         ret = nm_setting_wireless_remove_mac_blacklist_item_by_value (setting, mac);
4946         if (!ret)
4947                 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4948         return ret;
4949 }
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)
4955
4956 /* 'powersave' */
4957 static gboolean
4958 nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const char *val, GError **error)
4959 {
4960         NMSettingWirelessPowersave powersave;
4961         gs_free const char **options = NULL;
4962         gs_free char *options_str = NULL;
4963         long int t;
4964         gboolean ret;
4965
4966         if (nmc_string_to_int_base (val, 0, TRUE,
4967                                     NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4968                                     NM_SETTING_WIRELESS_POWERSAVE_LAST,
4969                                     &t))
4970                 powersave = (NMSettingWirelessPowersave) t;
4971         else {
4972                 ret = nm_utils_enum_from_str (nm_setting_wireless_powersave_get_type (),
4973                                               val,
4974                                               (int *) &powersave,
4975                                               NULL);
4976                 if (!ret) {
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);
4982                         return FALSE;
4983                 }
4984         }
4985
4986         g_object_set (setting, prop, (guint) powersave, NULL);
4987         return TRUE;
4988 }
4989
4990 static gboolean
4991 nmc_property_wireless_set_mac_address_randomization (NMSetting *setting,
4992                                                      const char *prop,
4993                                                      const char *val,
4994                                                      GError **error)
4995 {
4996         NMSettingMacRandomization randomization;
4997         gs_free char *err_token = NULL;
4998         gboolean ret;
4999         long int t;
5000
5001         if (nmc_string_to_int_base (val, 0, TRUE,
5002                                     NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
5003                                     NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
5004                                     &t))
5005                 randomization = (NMSettingMacRandomization) t;
5006         else {
5007                 ret = nm_utils_enum_from_str (nm_setting_mac_randomization_get_type (),
5008                                               val,
5009                                               (int *) &randomization,
5010                                               &err_token);
5011
5012                 if (!ret) {
5013                         g_set_error (error, 1, 0, _("invalid option '%s', use 'default', 'never' or 'always'"),
5014                                      err_token);
5015                         return FALSE;
5016                 }
5017         }
5018
5019         g_object_set (setting, prop, (guint) randomization, NULL);
5020         return TRUE;
5021 }
5022
5023 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property setter functions --- */
5024 /* 'key-mgmt' */
5025 static const char *wifi_sec_valid_key_mgmts[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
5026
5027 static gboolean
5028 nmc_property_wifi_sec_set_key_mgmt (NMSetting *setting, const char *prop, const char *val, GError **error)
5029 {
5030         return check_and_set_string (setting, prop, val, wifi_sec_valid_key_mgmts, error);
5031 }
5032
5033 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_key_mgmt, wifi_sec_valid_key_mgmts)
5034
5035 /* 'auth-alg' */
5036 static const char *wifi_sec_valid_auth_algs[] = { "open", "shared", "leap", NULL };
5037
5038 static gboolean
5039 nmc_property_wifi_sec_set_auth_alg (NMSetting *setting, const char *prop, const char *val, GError **error)
5040 {
5041         return check_and_set_string (setting, prop, val, wifi_sec_valid_auth_algs, error);
5042 }
5043
5044 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_auth_alg, wifi_sec_valid_auth_algs)
5045
5046 /* 'proto' */
5047 static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL };
5048
5049 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_proto,
5050                               NM_SETTING_WIRELESS_SECURITY,
5051                               nm_setting_wireless_security_add_proto)
5052
5053 static gboolean
5054 nmc_property_wifi_sec_set_proto (NMSetting *setting, const char *prop, const char *val, GError **error)
5055 {
5056         return check_and_add_wifi_sec_proto (setting, prop, val, wifi_sec_valid_protos, error);
5057 }
5058
5059 static gboolean
5060 _validate_and_remove_wifi_sec_proto (NMSettingWirelessSecurity *setting,
5061                                      const char *proto,
5062                                      GError **error)
5063 {
5064         gboolean ret;
5065         const char *valid;
5066
5067         valid = nmc_string_is_valid (proto, wifi_sec_valid_protos, error);
5068         if (!valid)
5069                 return FALSE;
5070
5071         ret = nm_setting_wireless_security_remove_proto_by_value (setting, proto);
5072         if (!ret)
5073                 g_set_error (error, 1, 0,
5074                              _("the property doesn't contain protocol '%s'"), proto);
5075         return ret;
5076 }
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)
5082
5083 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_proto, wifi_sec_valid_protos)
5084
5085 /* 'pairwise' */
5086 static const char *wifi_sec_valid_pairwises[] = { "tkip", "ccmp", NULL };
5087
5088 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_pairwise,
5089                               NM_SETTING_WIRELESS_SECURITY,
5090                               nm_setting_wireless_security_add_pairwise)
5091
5092 static gboolean
5093 nmc_property_wifi_sec_set_pairwise (NMSetting *setting, const char *prop, const char *val, GError **error)
5094 {
5095         return check_and_add_wifi_sec_pairwise (setting, prop, val, wifi_sec_valid_pairwises, error);
5096 }
5097
5098 static gboolean
5099 _validate_and_remove_wifi_sec_pairwise (NMSettingWirelessSecurity *setting,
5100                                         const char *pairwise,
5101                                         GError **error)
5102 {
5103         gboolean ret;
5104         const char *valid;
5105
5106         valid = nmc_string_is_valid (pairwise, wifi_sec_valid_pairwises, error);
5107         if (!valid)
5108                 return FALSE;
5109
5110         ret = nm_setting_wireless_security_remove_pairwise_by_value (setting, pairwise);
5111         if (!ret)
5112                 g_set_error (error, 1, 0,
5113                              _("the property doesn't contain protocol '%s'"), pairwise);
5114         return ret;
5115 }
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)
5121
5122 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_pairwise, wifi_sec_valid_pairwises)
5123
5124 /* 'group' */
5125 static const char *wifi_sec_valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
5126
5127 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_group,
5128                               NM_SETTING_WIRELESS_SECURITY,
5129                               nm_setting_wireless_security_add_group)
5130
5131 static gboolean
5132 nmc_property_wifi_sec_set_group (NMSetting *setting, const char *prop, const char *val, GError **error)
5133 {
5134         return check_and_add_wifi_sec_group (setting, prop, val, wifi_sec_valid_groups, error);
5135 }
5136
5137 static gboolean
5138 _validate_and_remove_wifi_sec_group (NMSettingWirelessSecurity *setting,
5139                                      const char *group,
5140                                      GError **error)
5141 {
5142         gboolean ret;
5143         const char *valid;
5144
5145         valid = nmc_string_is_valid (group, wifi_sec_valid_groups, error);
5146         if (!valid)
5147                 return FALSE;
5148
5149         ret = nm_setting_wireless_security_remove_group_by_value (setting, group);
5150         if (!ret)
5151                 g_set_error (error, 1, 0,
5152                              _("the property doesn't contain protocol '%s'"), group);
5153         return ret;
5154 }
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)
5161
5162 /* 'wep-key' */
5163 static gboolean
5164 nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char *val, GError **error)
5165 {
5166         NMWepKeyType guessed_type = NM_WEP_KEY_TYPE_UNKNOWN;
5167         NMWepKeyType type;
5168         guint32 prev_idx, idx;
5169
5170         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5171
5172         /* Get currently set type */
5173         type = nm_setting_wireless_security_get_wep_key_type (NM_SETTING_WIRELESS_SECURITY (setting));
5174
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;
5180
5181         if (guessed_type == NM_WEP_KEY_TYPE_UNKNOWN) {
5182                 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
5183                 return FALSE;
5184         }
5185
5186         if (type != NM_WEP_KEY_TYPE_UNKNOWN && type != guessed_type) {
5187                 if (nm_utils_wep_key_valid (val, type))
5188                         guessed_type = type;
5189                 else {
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);
5194                         return FALSE;
5195                 }
5196         }
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);
5202
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);
5207         return TRUE;
5208 }
5209
5210 /* 'wep-key-type' */
5211 static gboolean
5212 nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const char *val, GError **error)
5213 {
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;
5219
5220         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5221
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);
5225                         return FALSE;
5226                 }
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;
5231         } else
5232                 type = (NMWepKeyType) type_int;
5233
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));
5251
5252         g_object_set (setting, prop, type, NULL);
5253         return TRUE;
5254 }
5255
5256 static const char *
5257 nmc_property_wifi_describe_wep_key_type (NMSetting *setting, const char *prop)
5258 {
5259         static char *desc = NULL;
5260
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"));
5264         }
5265         return desc;
5266 }
5267
5268 /* 'psk' */
5269 static gboolean
5270 nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val, GError **error)
5271 {
5272         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5273
5274         if (!nm_utils_wpa_psk_valid (val)) {
5275                 g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), val);
5276                 return FALSE;
5277         }
5278         g_object_set (setting, prop, val, NULL);
5279         return TRUE;
5280 }
5281
5282 #define DCB_ALL_FLAGS (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING)
5283
5284 /* DCB stuff */
5285 static gboolean
5286 nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
5287 {
5288         char **strv = NULL, **iter;
5289         NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5290         long int t;
5291
5292         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5293
5294         /* Check for overall hex numeric value */
5295         if (nmc_string_to_int_base (val, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5296                 flags = (guint) t;
5297         else {
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))
5302                                 t = -1;
5303
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
5316                                  || t == 0) {
5317                                 /* pass */
5318                         } else {
5319                                 g_set_error (error, 1, 0, _("'%s' is not a valid DCB flag"), *iter);
5320                                 return FALSE;
5321                         }
5322                 }
5323                 g_strfreev (strv);
5324         }
5325
5326         /* Validate the flags according to the property spec */
5327         if (!validate_flags (setting, prop, (guint) flags, error))
5328                 return FALSE;
5329
5330         g_object_set (setting, prop, (guint) flags, NULL);
5331         return TRUE;
5332 }
5333
5334 static gboolean
5335 nmc_property_dcb_set_priority (NMSetting *setting, const char *prop, const char *val, GError **error)
5336 {
5337         long int priority = 0;
5338
5339         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5340
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);
5343                 return FALSE;
5344         }
5345
5346         /* Validate the number according to the property spec */
5347         if (!validate_int (setting, prop, (gint) priority, error))
5348                 return FALSE;
5349
5350         g_object_set (setting, prop, (gint) priority, NULL);
5351         return TRUE;
5352 }
5353
5354 static gboolean
5355 dcb_parse_uint_array (const char *val,
5356                       guint max,
5357                       guint other,
5358                       guint *out_array,
5359                       GError **error)
5360 {
5361         char **items, **iter;
5362         guint i = 0;
5363
5364         g_return_val_if_fail (out_array != NULL, FALSE);
5365
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"));
5369                 goto error;
5370         }
5371
5372         for (iter = items; iter && *iter; iter++) {
5373                 long int num = 0;
5374                 gboolean success;
5375
5376                 *iter = g_strstrip (*iter);
5377                 success = nmc_string_to_int_base (*iter, 10, TRUE, 0, other ? other : max, &num);
5378
5379                 /* If number is greater than 'max' it must equal 'other' */
5380                 if (success && other && (num > max) && (num != other))
5381                         success = FALSE;
5382
5383                 if (!success) {
5384                         if (other) {
5385                                 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive) or %u"),
5386                                              *iter, max, other);
5387                         } else {
5388                                 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive)"),
5389                                              *iter, max);
5390                         }
5391                         goto error;
5392                 }
5393                 out_array[i++] = (guint) num;
5394         }
5395
5396         return TRUE;
5397
5398 error:
5399         g_strfreev (items);
5400         return FALSE;
5401 }
5402
5403 static void
5404 dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop)
5405 {
5406         NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5407
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);
5411 }
5412
5413 static gboolean
5414 nmc_property_dcb_set_pfc (NMSetting *setting, const char *prop, const char *val, GError **error)
5415 {
5416         guint i = 0;
5417         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5418
5419         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5420
5421         if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5422                 return FALSE;
5423
5424         for (i = 0; i < 8; i++)
5425                 nm_setting_dcb_set_priority_flow_control (NM_SETTING_DCB (setting), i, !!nums[i]);
5426
5427         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS);
5428         return TRUE;
5429 }
5430
5431 static gboolean
5432 nmc_property_dcb_set_pg_group_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5433 {
5434         guint i = 0;
5435         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5436
5437         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5438
5439         if (!dcb_parse_uint_array (val, 7, 15, nums, error))
5440                 return FALSE;
5441
5442         for (i = 0; i < 8; i++)
5443                 nm_setting_dcb_set_priority_group_id (NM_SETTING_DCB (setting), i, nums[i]);
5444
5445         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5446         return TRUE;
5447 }
5448
5449 static gboolean
5450 nmc_property_dcb_set_pg_group_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5451 {
5452         guint i = 0, sum = 0;
5453         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5454
5455         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5456
5457         if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5458                 return FALSE;
5459
5460         for (i = 0; i < 8; i++)
5461                 sum += nums[i];
5462         if (sum != 100) {
5463                 g_set_error_literal (error, 1, 0, _("bandwidth percentages must total 100%%"));
5464                 return FALSE;
5465         }
5466
5467         for (i = 0; i < 8; i++)
5468                 nm_setting_dcb_set_priority_group_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5469
5470         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5471         return TRUE;
5472 }
5473
5474 static gboolean
5475 nmc_property_dcb_set_pg_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5476 {
5477         guint i = 0;
5478         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5479
5480         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5481
5482         if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5483                 return FALSE;
5484
5485         for (i = 0; i < 8; i++)
5486                 nm_setting_dcb_set_priority_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5487
5488         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5489         return TRUE;
5490 }
5491
5492 static gboolean
5493 nmc_property_dcb_set_pg_strict (NMSetting *setting, const char *prop, const char *val, GError **error)
5494 {
5495         guint i = 0;
5496         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5497
5498         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5499
5500         if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5501                 return FALSE;
5502
5503         for (i = 0; i < 8; i++)
5504                 nm_setting_dcb_set_priority_strict_bandwidth (NM_SETTING_DCB (setting), i, !!nums[i]);
5505
5506         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5507         return TRUE;
5508 }
5509
5510 static gboolean
5511 nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, const char *val, GError **error)
5512 {
5513         guint i = 0;
5514         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5515
5516         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5517
5518         if (!dcb_parse_uint_array (val, 7, 0, nums, error))
5519                 return FALSE;
5520
5521         for (i = 0; i < 8; i++)
5522                 nm_setting_dcb_set_priority_traffic_class (NM_SETTING_DCB (setting), i, nums[i]);
5523
5524         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5525         return TRUE;
5526 }
5527
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,
5531                                                NULL };
5532
5533 static gboolean
5534 nmc_property_dcb_set_app_fcoe_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
5535 {
5536         return check_and_set_string (setting, prop, val, _dcb_valid_fcoe_modes, error);
5537 }
5538
5539 DEFINE_ALLOWED_VAL_FUNC (nmc_property_dcb_allowed_app_fcoe_modes, _dcb_valid_fcoe_modes)
5540
5541 static gboolean
5542 nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5543 {
5544         const char *p = val;
5545
5546         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5547
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"));
5550                 return FALSE;
5551         }
5552
5553         while (p && *p) {
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"));
5556                         return FALSE;
5557                 }
5558         }
5559         g_object_set (G_OBJECT (setting),
5560                       NM_SETTING_GSM_SIM_OPERATOR_ID,
5561                       val,
5562                       NULL);
5563         return TRUE;
5564 }
5565
5566 static char *
5567 nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
5568 {
5569         NMSettingTun *s_tun = NM_SETTING_TUN (setting);
5570         NMSettingTunMode mode;
5571         char *tmp, *str;
5572
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 : "");
5577         else
5578                 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
5579         g_free (tmp);
5580         return str;
5581 }
5582
5583 static gboolean
5584 nmc_property_tun_set_mode (NMSetting *setting, const char *prop,
5585                            const char *val, GError **error)
5586 {
5587         NMSettingTunMode mode;
5588         gboolean ret;
5589         long int t;
5590
5591         if (nmc_string_to_int_base (val, 0, TRUE, 0, NM_SETTING_TUN_MODE_TAP, &t))
5592                 mode = (NMSettingTunMode) t;
5593         else {
5594                 ret = nm_utils_enum_from_str (nm_setting_tun_mode_get_type (), val,
5595                                               (int *) &mode, NULL);
5596
5597                 if (!ret) {
5598                         g_set_error (error, 1, 0, _("invalid option '%s', use '%s' or '%s'"),
5599                                      val, "tun", "tap");
5600                         return FALSE;
5601                 }
5602         }
5603
5604         g_object_set (setting, prop, (guint) mode, NULL);
5605         return TRUE;
5606 }
5607
5608 static const char *tun_valid_modes[] = { "tun", "tap", "unknown", NULL };
5609
5610 DEFINE_ALLOWED_VAL_FUNC (nmc_property_tun_allowed_mode, tun_valid_modes)
5611
5612 /*----------------------------------------------------------------------------*/
5613
5614 static inline void
5615 _nmc_add_prop_funcs (const char *key,
5616                      const NmcPropertyFuncs *item_init)
5617 {
5618         NmcPropertyFuncs *item;
5619
5620         item = g_malloc (sizeof (NmcPropertyFuncs));
5621         *item = *item_init;
5622         g_hash_table_insert (nmc_properties, (gpointer) key, item);
5623 }
5624
5625 #define nmc_add_prop_funcs(key, ...) \
5626         G_STMT_START { \
5627                 struct { \
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);". */ \
5632                         gpointer _dummy; \
5633                 } _item_init = { \
5634                         __VA_ARGS__ \
5635                 };\
5636                 \
5637                 nm_assert (_item_init._dummy == NULL); \
5638                 _nmc_add_prop_funcs ("" key, (NmcPropertyFuncs *) &_item_init); \
5639         } G_STMT_END
5640
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 ""
5644
5645 void
5646 nmc_properties_init (void)
5647 {
5648         if (G_LIKELY (nmc_properties))
5649                 return;
5650
5651         /* create properties hash table */
5652         nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
5653
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,
5659                             NULL,
5660                             nmc_property_802_1X_allowed_eap,
5661                             NULL);
5662         nmc_add_prop_funcs (GLUE (802_1X, IDENTITY),
5663                             nmc_property_802_1X_get_identity,
5664                             nmc_property_set_string,
5665                             NULL,
5666                             NULL,
5667                             NULL,
5668                             NULL);
5669         nmc_add_prop_funcs (GLUE (802_1X, ANONYMOUS_IDENTITY),
5670                             nmc_property_802_1X_get_anonymous_identity,
5671                             nmc_property_set_string,
5672                             NULL,
5673                             NULL,
5674                             NULL,
5675                             NULL);
5676         nmc_add_prop_funcs (GLUE (802_1X, PAC_FILE),
5677                             nmc_property_802_1X_get_pac_file,
5678                             nmc_property_set_string,
5679                             NULL,
5680                             NULL,
5681                             NULL,
5682                             NULL);
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,
5686                             NULL,
5687                             nmc_property_802_1X_describe_ca_cert,
5688                             NULL,
5689                             NULL);
5690         nmc_add_prop_funcs (GLUE (802_1X, CA_PATH),
5691                             nmc_property_802_1X_get_ca_path,
5692                             nmc_property_set_string,
5693                             NULL,
5694                             NULL,
5695                             NULL,
5696                             NULL);
5697         nmc_add_prop_funcs (GLUE (802_1X, SUBJECT_MATCH),
5698                             nmc_property_802_1X_get_subject_match,
5699                             nmc_property_set_string,
5700                             NULL,
5701                             NULL,
5702                             NULL,
5703                             NULL);
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,
5708                             NULL,
5709                             NULL,
5710                             NULL);
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,
5714                             NULL,
5715                             NULL,
5716                             NULL,
5717                             NULL);
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,
5721                             NULL,
5722                             nmc_property_802_1X_describe_client_cert,
5723                             NULL,
5724                             NULL);
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,
5728                             NULL,
5729                             NULL,
5730                             nmc_property_802_1X_allowed_phase1_peapver,
5731                             NULL);
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,
5735                             NULL,
5736                             NULL,
5737                             nmc_property_802_1X_allowed_phase1_peaplabel,
5738                             NULL);
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,
5742                             NULL,
5743                             NULL,
5744                             nmc_property_802_1X_allowed_phase1_fast_provisioning,
5745                             NULL);
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,
5749                             NULL,
5750                             NULL,
5751                             nmc_property_802_1X_allowed_phase2_auth,
5752                             NULL);
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,
5756                             NULL,
5757                             NULL,
5758                             nmc_property_802_1X_allowed_phase2_autheap,
5759                             NULL);
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,
5763                             NULL,
5764                             nmc_property_802_1X_describe_phase2_ca_cert,
5765                             NULL,
5766                             NULL);
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,
5770                             NULL,
5771                             NULL,
5772                             NULL,
5773                             NULL);
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,
5777                             NULL,
5778                             NULL,
5779                             NULL,
5780                             NULL);
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,
5785                             NULL,
5786                             NULL,
5787                             NULL);
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,
5791                             NULL,
5792                             NULL,
5793                             NULL,
5794                             NULL);
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,
5798                             NULL,
5799                             nmc_property_802_1X_describe_phase2_client_cert,
5800                             NULL,
5801                             NULL);
5802         nmc_add_prop_funcs (GLUE (802_1X, PASSWORD),
5803                             nmc_property_802_1X_get_password,
5804                             nmc_property_set_string,
5805                             NULL,
5806                             NULL,
5807                             NULL,
5808                             NULL);
5809         nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_FLAGS),
5810                             nmc_property_802_1X_get_password_flags,
5811                             nmc_property_set_secret_flags,
5812                             NULL,
5813                             NULL,
5814                             NULL,
5815                             NULL);
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,
5819                             NULL,
5820                             nmc_property_802_1X_describe_password_raw,
5821                             NULL,
5822                             NULL);
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,
5826                             NULL,
5827                             NULL,
5828                             NULL,
5829                             NULL);
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,
5833                             NULL,
5834                             nmc_property_802_1X_describe_private_key,
5835                             NULL,
5836                             NULL);
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,
5840                             NULL,
5841                             NULL,
5842                             NULL,
5843                             NULL);
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,
5847                             NULL,
5848                             NULL,
5849                             NULL,
5850                             NULL);
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,
5854                             NULL,
5855                             nmc_property_802_1X_describe_private_key,
5856                             NULL,
5857                             NULL);
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,
5861                             NULL,
5862                             NULL,
5863                             NULL,
5864                             NULL);
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,
5868                             NULL,
5869                             NULL,
5870                             NULL,
5871                             NULL);
5872         nmc_add_prop_funcs (GLUE (802_1X, PIN),
5873                             nmc_property_802_1X_get_pin,
5874                             nmc_property_set_string,
5875                             NULL,
5876                             NULL,
5877                             NULL,
5878                             NULL);
5879         nmc_add_prop_funcs (GLUE (802_1X, PIN_FLAGS),
5880                             nmc_property_802_1X_get_pin_flags,
5881                             nmc_property_set_secret_flags,
5882                             NULL,
5883                             NULL,
5884                             NULL,
5885                             NULL);
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,
5889                             NULL,
5890                             NULL,
5891                             NULL,
5892                             NULL);
5893
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,
5898                             NULL,
5899                             NULL,
5900                             NULL,
5901                             NULL);
5902         nmc_add_prop_funcs (GLUE (ADSL, PASSWORD),
5903                             nmc_property_adsl_get_password,
5904                             nmc_property_set_string,
5905                             NULL,
5906                             NULL,
5907                             NULL,
5908                             NULL);
5909         nmc_add_prop_funcs (GLUE (ADSL, PASSWORD_FLAGS),
5910                             nmc_property_adsl_get_password_flags,
5911                             nmc_property_set_secret_flags,
5912                             NULL,
5913                             NULL,
5914                             NULL,
5915                             NULL);
5916         nmc_add_prop_funcs (GLUE (ADSL, PROTOCOL),
5917                             nmc_property_adsl_get_protocol,
5918                             nmc_property_adsl_set_protocol,
5919                             NULL,
5920                             NULL,
5921                             nmc_property_adsl_allowed_protocol,
5922                             NULL);
5923         nmc_add_prop_funcs (GLUE (ADSL, ENCAPSULATION),
5924                             nmc_property_adsl_get_encapsulation,
5925                             nmc_property_adsl_set_encapsulation,
5926                             NULL,
5927                             NULL,
5928                             nmc_property_adsl_allowed_encapsulation,
5929                             NULL);
5930         nmc_add_prop_funcs (GLUE (ADSL, VPI),
5931                             nmc_property_adsl_get_vpi,
5932                             nmc_property_set_uint,
5933                             NULL,
5934                             NULL,
5935                             NULL,
5936                             NULL);
5937         nmc_add_prop_funcs (GLUE (ADSL, VCI),
5938                             nmc_property_adsl_get_vci,
5939                             nmc_property_set_uint,
5940                             NULL,
5941                             NULL,
5942                             NULL,
5943                             NULL);
5944
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,
5949                             NULL,
5950                             NULL,
5951                             NULL,
5952                             NULL);
5953         nmc_add_prop_funcs (GLUE (BLUETOOTH, TYPE),
5954                             nmc_property_bluetooth_get_type,
5955                             nmc_property_bluetooth_set_type,
5956                             NULL,
5957                             NULL,
5958                             NULL,
5959                             NULL);
5960
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,
5968                             NULL);
5969
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,
5974                             NULL,
5975                             NULL,
5976                             NULL,
5977                             NULL);
5978         nmc_add_prop_funcs (GLUE (BRIDGE, STP),
5979                             nmc_property_bridge_get_stp,
5980                             nmc_property_set_bool,
5981                             NULL,
5982                             NULL,
5983                             NULL,
5984                             NULL);
5985         nmc_add_prop_funcs (GLUE (BRIDGE, PRIORITY),
5986                             nmc_property_bridge_get_priority,
5987                             nmc_property_set_uint,
5988                             NULL,
5989                             NULL,
5990                             NULL,
5991                             NULL);
5992         nmc_add_prop_funcs (GLUE (BRIDGE, FORWARD_DELAY),
5993                             nmc_property_bridge_get_forward_delay,
5994                             nmc_property_set_uint,
5995                             NULL,
5996                             NULL,
5997                             NULL,
5998                             NULL);
5999         nmc_add_prop_funcs (GLUE (BRIDGE, HELLO_TIME),
6000                             nmc_property_bridge_get_hello_time,
6001                             nmc_property_set_uint,
6002                             NULL,
6003                             NULL,
6004                             NULL,
6005                             NULL);
6006         nmc_add_prop_funcs (GLUE (BRIDGE, MAX_AGE),
6007                             nmc_property_bridge_get_max_age,
6008                             nmc_property_set_uint,
6009                             NULL,
6010                             NULL,
6011                             NULL,
6012                             NULL);
6013         nmc_add_prop_funcs (GLUE (BRIDGE, AGEING_TIME),
6014                             nmc_property_bridge_get_ageing_time,
6015                             nmc_property_set_uint,
6016                             NULL,
6017                             NULL,
6018                             NULL,
6019                             NULL);
6020
6021         nmc_add_prop_funcs (GLUE (BRIDGE, MULTICAST_SNOOPING),
6022                             nmc_property_bridge_get_multicast_snooping,
6023                             nmc_property_set_bool,
6024                             NULL,
6025                             NULL,
6026                             NULL,
6027                             NULL);
6028
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,
6033                             NULL,
6034                             NULL,
6035                             NULL,
6036                             NULL);
6037         nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PATH_COST),
6038                             nmc_property_bridge_port_get_path_cost,
6039                             nmc_property_set_uint,
6040                             NULL,
6041                             NULL,
6042                             NULL,
6043                             NULL);
6044         nmc_add_prop_funcs (GLUE (BRIDGE_PORT, HAIRPIN_MODE),
6045                             nmc_property_bridge_port_get_hairpin_mode,
6046                             nmc_property_set_bool,
6047                             NULL,
6048                             NULL,
6049                             NULL,
6050                             NULL);
6051
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,
6056                             NULL,
6057                             NULL,
6058                             NULL,
6059                             NULL);
6060         nmc_add_prop_funcs (GLUE (CDMA, USERNAME),
6061                             nmc_property_cdma_get_username,
6062                             nmc_property_set_string,
6063                             NULL,
6064                             NULL,
6065                             NULL,
6066                             NULL);
6067         nmc_add_prop_funcs (GLUE (CDMA, PASSWORD),
6068                             nmc_property_cdma_get_password,
6069                             nmc_property_set_string,
6070                             NULL,
6071                             NULL,
6072                             NULL,
6073                             NULL);
6074         nmc_add_prop_funcs (GLUE (CDMA, PASSWORD_FLAGS),
6075                             nmc_property_cdma_get_password_flags,
6076                             nmc_property_set_secret_flags,
6077                             NULL,
6078                             NULL,
6079                             NULL,
6080                             NULL);
6081
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,
6086                             NULL,
6087                             NULL,
6088                             NULL,
6089                             NULL);
6090         nmc_add_prop_funcs (GLUE (CONNECTION, UUID),
6091                             nmc_property_connection_get_uuid,
6092                             NULL, /* forbid setting/removing UUID */
6093                             NULL,
6094                             NULL,
6095                             NULL,
6096                             NULL);
6097         nmc_add_prop_funcs (GLUE (CONNECTION, INTERFACE_NAME),
6098                             nmc_property_connection_get_interface_name,
6099                             nmc_property_set_ifname,
6100                             NULL,
6101                             NULL,
6102                             NULL,
6103                             NULL);
6104         nmc_add_prop_funcs (GLUE (CONNECTION, TYPE),
6105                             nmc_property_connection_get_type,
6106                             NULL, /* read-only */
6107                             NULL,
6108                             NULL,
6109                             NULL,
6110                             NULL);
6111         nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT),
6112                             nmc_property_connection_get_autoconnect,
6113                             nmc_property_set_bool,
6114                             NULL,
6115                             NULL,
6116                             NULL,
6117                             NULL);
6118         nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_PRIORITY),
6119                             nmc_property_connection_get_autoconnect_priority,
6120                             nmc_property_set_int,
6121                             NULL,
6122                             NULL,
6123                             NULL,
6124                             NULL);
6125         nmc_add_prop_funcs (GLUE (CONNECTION, TIMESTAMP),
6126                             nmc_property_connection_get_timestamp,
6127                             NULL, /* read-only */
6128                             NULL,
6129                             NULL,
6130                             NULL,
6131                             NULL);
6132         nmc_add_prop_funcs (GLUE (CONNECTION, READ_ONLY),
6133                             nmc_property_connection_get_read_only,
6134                             NULL, /* 'read-only' is read-only :-) */
6135                             NULL,
6136                             NULL,
6137                             NULL,
6138                             NULL);
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,
6144                             NULL,
6145                             NULL);
6146         nmc_add_prop_funcs (GLUE (CONNECTION, ZONE),
6147                             nmc_property_connection_get_zone,
6148                             nmc_property_set_string,
6149                             NULL,
6150                             NULL,
6151                             NULL,
6152                             NULL);
6153         nmc_add_prop_funcs (GLUE (CONNECTION, MASTER),
6154                             nmc_property_connection_get_master,
6155                             nmc_property_con_set_master,
6156                             NULL,
6157                             NULL,
6158                             NULL,
6159                             NULL);
6160         nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE),
6161                             nmc_property_connection_get_slave_type,
6162                             nmc_property_con_set_slave_type,
6163                             NULL,
6164                             NULL,
6165                             nmc_property_con_allowed_slave_type,
6166                             NULL);
6167         nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_SLAVES),
6168                             nmc_property_connection_get_autoconnect_slaves,
6169                             nmc_property_set_trilean,
6170                             NULL,
6171                             NULL,
6172                             NULL,
6173                             NULL);
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,
6179                             NULL,
6180                             NULL);
6181         nmc_add_prop_funcs (GLUE (CONNECTION, GATEWAY_PING_TIMEOUT),
6182                             nmc_property_connection_get_gateway_ping_timeout,
6183                             nmc_property_set_uint,
6184                             NULL,
6185                             NULL,
6186                             NULL,
6187                             NULL);
6188         nmc_add_prop_funcs (GLUE (CONNECTION, METERED),
6189                             nmc_property_connection_get_metered,
6190                             nmc_property_connection_set_metered,
6191                             NULL,
6192                             nmc_property_connection_describe_metered,
6193                             NULL,
6194                             NULL);
6195         nmc_add_prop_funcs (GLUE (CONNECTION, LLDP),
6196                             nmc_property_connection_get_lldp,
6197                             nmc_property_connection_set_lldp,
6198                             NULL,
6199                             NULL,
6200                             NULL,
6201                             NULL);
6202
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,
6207                             NULL,
6208                             NULL,
6209                             NULL,
6210                             NULL);
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,
6214                             NULL,
6215                             NULL,
6216                             nmc_property_dcb_allowed_app_fcoe_modes,
6217                             NULL);
6218         nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_PRIORITY),
6219                             nmc_property_dcb_get_app_fcoe_priority,
6220                             nmc_property_dcb_set_priority,
6221                             NULL,
6222                             NULL,
6223                             NULL,
6224                             NULL);
6225         nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_FLAGS),
6226                             nmc_property_dcb_get_app_iscsi_flags,
6227                             nmc_property_dcb_set_flags,
6228                             NULL,
6229                             NULL,
6230                             NULL,
6231                             NULL);
6232         nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_PRIORITY),
6233                             nmc_property_dcb_get_app_iscsi_priority,
6234                             nmc_property_dcb_set_priority,
6235                             NULL,
6236                             NULL,
6237                             NULL,
6238                             NULL);
6239         nmc_add_prop_funcs (GLUE (DCB, APP_FIP_FLAGS),
6240                             nmc_property_dcb_get_app_fip_flags,
6241                             nmc_property_dcb_set_flags,
6242                             NULL,
6243                             NULL,
6244                             NULL,
6245                             NULL);
6246         nmc_add_prop_funcs (GLUE (DCB, APP_FIP_PRIORITY),
6247                             nmc_property_dcb_get_app_fip_priority,
6248                             nmc_property_dcb_set_priority,
6249                             NULL,
6250                             NULL,
6251                             NULL,
6252                             NULL);
6253         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL_FLAGS),
6254                             nmc_property_dcb_get_pfc_flags,
6255                             nmc_property_dcb_set_flags,
6256                             NULL,
6257                             NULL,
6258                             NULL,
6259                             NULL);
6260         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL),
6261                             nmc_property_dcb_get_pfc,
6262                             nmc_property_dcb_set_pfc,
6263                             NULL,
6264                             NULL,
6265                             NULL,
6266                             NULL);
6267         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_FLAGS),
6268                             nmc_property_dcb_get_pg_flags,
6269                             nmc_property_dcb_set_flags,
6270                             NULL,
6271                             NULL,
6272                             NULL,
6273                             NULL);
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,
6277                             NULL,
6278                             NULL,
6279                             NULL,
6280                             NULL);
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,
6284                             NULL,
6285                             NULL,
6286                             NULL,
6287                             NULL);
6288         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_BANDWIDTH),
6289                             nmc_property_dcb_get_pg_bandwidth,
6290                             nmc_property_dcb_set_pg_bandwidth,
6291                             NULL,
6292                             NULL,
6293                             NULL,
6294                             NULL);
6295         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_STRICT_BANDWIDTH),
6296                             nmc_property_dcb_get_pg_strict,
6297                             nmc_property_dcb_set_pg_strict,
6298                             NULL,
6299                             NULL,
6300                             NULL,
6301                             NULL);
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,
6305                             NULL,
6306                             NULL,
6307                             NULL,
6308                             NULL);
6309
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,
6314                             NULL,
6315                             NULL,
6316                             NULL,
6317                             NULL);
6318         nmc_add_prop_funcs (GLUE (GSM, USERNAME),
6319                             nmc_property_gsm_get_username,
6320                             nmc_property_set_string,
6321                             NULL,
6322                             NULL,
6323                             NULL,
6324                             NULL);
6325         nmc_add_prop_funcs (GLUE (GSM, PASSWORD),
6326                             nmc_property_gsm_get_password,
6327                             nmc_property_set_string,
6328                             NULL,
6329                             NULL,
6330                             NULL,
6331                             NULL);
6332         nmc_add_prop_funcs (GLUE (GSM, PASSWORD_FLAGS),
6333                             nmc_property_gsm_get_password_flags,
6334                             nmc_property_set_secret_flags,
6335                             NULL,
6336                             NULL,
6337                             NULL,
6338                             NULL);
6339         nmc_add_prop_funcs (GLUE (GSM, APN),
6340                             nmc_property_gsm_get_apn,
6341                             nmc_property_set_string,
6342                             NULL,
6343                             NULL,
6344                             NULL,
6345                             NULL);
6346         nmc_add_prop_funcs (GLUE (GSM, NETWORK_ID),
6347                             nmc_property_gsm_get_network_id,
6348                             nmc_property_set_string,
6349                             NULL,
6350                             NULL,
6351                             NULL,
6352                             NULL);
6353         nmc_add_prop_funcs (GLUE (GSM, PIN),
6354                             nmc_property_gsm_get_pin,
6355                             nmc_property_set_string,
6356                             NULL,
6357                             NULL,
6358                             NULL,
6359                             NULL);
6360         nmc_add_prop_funcs (GLUE (GSM, PIN_FLAGS),
6361                             nmc_property_gsm_get_pin_flags,
6362                             nmc_property_set_secret_flags,
6363                             NULL,
6364                             NULL,
6365                             NULL,
6366                             NULL);
6367         nmc_add_prop_funcs (GLUE (GSM, HOME_ONLY),
6368                             nmc_property_gsm_get_home_only,
6369                             nmc_property_set_bool,
6370                             NULL,
6371                             NULL,
6372                             NULL,
6373                             NULL);
6374         nmc_add_prop_funcs (GLUE (GSM, DEVICE_ID),
6375                             nmc_property_gsm_get_device_id,
6376                             nmc_property_set_string,
6377                             NULL,
6378                             NULL,
6379                             NULL,
6380                             NULL);
6381         nmc_add_prop_funcs (GLUE (GSM, SIM_ID),
6382                             nmc_property_gsm_get_sim_id,
6383                             nmc_property_set_string,
6384                             NULL,
6385                             NULL,
6386                             NULL,
6387                             NULL);
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,
6391                             NULL,
6392                             NULL,
6393                             NULL,
6394                             NULL);
6395
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,
6400                             NULL,
6401                             NULL,
6402                             NULL,
6403                             NULL);
6404         nmc_add_prop_funcs (GLUE (INFINIBAND, MTU),
6405                             nmc_property_ib_get_mtu,
6406                             nmc_property_set_mtu,
6407                             NULL,
6408                             NULL,
6409                             NULL,
6410                             NULL);
6411         nmc_add_prop_funcs (GLUE (INFINIBAND, TRANSPORT_MODE),
6412                             nmc_property_ib_get_transport_mode,
6413                             nmc_property_ib_set_transport_mode,
6414                             NULL,
6415                             NULL,
6416                             nmc_property_ib_allowed_transport_mode,
6417                             NULL);
6418         nmc_add_prop_funcs (GLUE (INFINIBAND, P_KEY),
6419                             nmc_property_ib_get_p_key,
6420                             nmc_property_ib_set_p_key,
6421                             NULL,
6422                             NULL,
6423                             NULL,
6424                             NULL);
6425         nmc_add_prop_funcs (GLUE (INFINIBAND, PARENT),
6426                             nmc_property_ib_get_parent,
6427                             nmc_property_set_ifname,
6428                             NULL,
6429                             NULL,
6430                             NULL,
6431                             NULL);
6432
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,
6437                             NULL,
6438                             NULL,
6439                             nmc_property_ipv4_allowed_method,
6440                             NULL);
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,
6446                             NULL,
6447                             NULL);
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,
6452                             NULL,
6453                             NULL,
6454                             NULL);
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,
6459                             NULL,
6460                             NULL,
6461                             NULL);
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,
6467                             NULL,
6468                             NULL);
6469         nmc_add_prop_funcs (GLUE_IP (4, GATEWAY),
6470                             nmc_property_ipv4_get_gateway,
6471                             nmc_property_ipv4_set_gateway,
6472                             NULL,
6473                             NULL,
6474                             NULL,
6475                             NULL);
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,
6481                             NULL,
6482                             NULL);
6483         nmc_add_prop_funcs (GLUE_IP (4, ROUTE_METRIC),
6484                             nmc_property_ipv4_get_route_metric,
6485                             nmc_property_set_int64,
6486                             NULL,
6487                             NULL,
6488                             NULL,
6489                             NULL);
6490         nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_ROUTES),
6491                             nmc_property_ipv4_get_ignore_auto_routes,
6492                             nmc_property_set_bool,
6493                             NULL,
6494                             NULL,
6495                             NULL,
6496                             NULL);
6497         nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_DNS),
6498                             nmc_property_ipv4_get_ignore_auto_dns,
6499                             nmc_property_set_bool,
6500                             NULL,
6501                             NULL,
6502                             NULL,
6503                             NULL);
6504         nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_CLIENT_ID),
6505                             nmc_property_ipv4_get_dhcp_client_id,
6506                             nmc_property_set_string,
6507                             NULL,
6508                             NULL,
6509                             NULL,
6510                             NULL);
6511         nmc_add_prop_funcs (GLUE_IP (4, DHCP_TIMEOUT),
6512                             nmc_property_ipv4_get_dhcp_timeout,
6513                             nmc_property_set_int,
6514                             NULL,
6515                             NULL,
6516                             NULL,
6517                             NULL);
6518         nmc_add_prop_funcs (GLUE_IP (4, DHCP_SEND_HOSTNAME),
6519                             nmc_property_ipv4_get_dhcp_send_hostname,
6520                             nmc_property_set_bool,
6521                             NULL,
6522                             NULL,
6523                             NULL,
6524                             NULL);
6525         nmc_add_prop_funcs (GLUE_IP (4, DHCP_HOSTNAME),
6526                             nmc_property_ipv4_get_dhcp_hostname,
6527                             nmc_property_set_string,
6528                             NULL,
6529                             NULL,
6530                             NULL,
6531                             NULL);
6532         nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_FQDN),
6533                             nmc_property_ipv4_get_dhcp_fqdn,
6534                             nmc_property_set_string,
6535                             NULL,
6536                             NULL,
6537                             NULL,
6538                             NULL);
6539         nmc_add_prop_funcs (GLUE_IP (4, NEVER_DEFAULT),
6540                             nmc_property_ipv4_get_never_default,
6541                             nmc_property_set_bool,
6542                             NULL,
6543                             NULL,
6544                             NULL,
6545                             NULL);
6546         nmc_add_prop_funcs (GLUE_IP (4, MAY_FAIL),
6547                             nmc_property_ipv4_get_may_fail,
6548                             nmc_property_set_bool,
6549                             NULL,
6550                             NULL,
6551                             NULL,
6552                             NULL);
6553         nmc_add_prop_funcs (GLUE_IP (4, DAD_TIMEOUT),
6554                             nmc_property_ipv4_get_dad_timeout,
6555                             nmc_property_set_int,
6556                             NULL,
6557                             NULL,
6558                             NULL,
6559                             NULL);
6560
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,
6565                             NULL,
6566                             NULL,
6567                             nmc_property_ipv6_allowed_method,
6568                             NULL);
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,
6574                             NULL,
6575                             NULL);
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,
6580                             NULL,
6581                             NULL,
6582                             NULL);
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,
6587                             NULL,
6588                             NULL,
6589                             NULL);
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,
6595                             NULL,
6596                             NULL);
6597         nmc_add_prop_funcs (GLUE_IP (6, GATEWAY),
6598                             nmc_property_ipv6_get_gateway,
6599                             nmc_property_ipv6_set_gateway,
6600                             NULL,
6601                             NULL,
6602                             NULL,
6603                             NULL);
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,
6609                             NULL,
6610                             NULL);
6611         nmc_add_prop_funcs (GLUE_IP (6, ROUTE_METRIC),
6612                             nmc_property_ipv6_get_route_metric,
6613                             nmc_property_set_int64,
6614                             NULL,
6615                             NULL,
6616                             NULL,
6617                             NULL);
6618         nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_ROUTES),
6619                             nmc_property_ipv6_get_ignore_auto_routes,
6620                             nmc_property_set_bool,
6621                             NULL,
6622                             NULL,
6623                             NULL,
6624                             NULL);
6625         nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_DNS),
6626                             nmc_property_ipv6_get_ignore_auto_dns,
6627                             nmc_property_set_bool,
6628                             NULL,
6629                             NULL,
6630                             NULL,
6631                             NULL);
6632         nmc_add_prop_funcs (GLUE_IP (6, NEVER_DEFAULT),
6633                             nmc_property_ipv6_get_never_default,
6634                             nmc_property_set_bool,
6635                             NULL,
6636                             NULL,
6637                             NULL,
6638                             NULL);
6639         nmc_add_prop_funcs (GLUE_IP (6, MAY_FAIL),
6640                             nmc_property_ipv6_get_may_fail,
6641                             nmc_property_set_bool,
6642                             NULL,
6643                             NULL,
6644                             NULL,
6645                             NULL);
6646         nmc_add_prop_funcs (GLUE (IP6_CONFIG, IP6_PRIVACY),
6647                             nmc_property_ipv6_get_ip6_privacy,
6648                             nmc_property_ipv6_set_ip6_privacy,
6649                             NULL,
6650                             NULL,
6651                             NULL,
6652                             NULL);
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,
6656                             NULL,
6657                             NULL,
6658                             NULL,
6659                             NULL);
6660         nmc_add_prop_funcs (GLUE_IP (6, DHCP_SEND_HOSTNAME),
6661                             nmc_property_ipv6_get_dhcp_send_hostname,
6662                             nmc_property_set_bool,
6663                             NULL,
6664                             NULL,
6665                             NULL,
6666                             NULL);
6667         nmc_add_prop_funcs (GLUE_IP (6, DHCP_HOSTNAME),
6668                             nmc_property_ipv6_get_dhcp_hostname,
6669                             nmc_property_set_string,
6670                             NULL,
6671                             NULL,
6672                             NULL,
6673                             NULL);
6674
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,
6679                             NULL,
6680                             NULL,
6681                             NULL,
6682                             NULL);
6683         nmc_add_prop_funcs (GLUE (OLPC_MESH, CHANNEL),
6684                             nmc_property_olpc_get_channel,
6685                             nmc_property_olpc_set_channel,
6686                             NULL,
6687                             NULL,
6688                             NULL,
6689                             NULL);
6690         nmc_add_prop_funcs (GLUE (OLPC_MESH, DHCP_ANYCAST_ADDRESS),
6691                             nmc_property_olpc_get_anycast_address,
6692                             nmc_property_set_mac,
6693                             NULL,
6694                             NULL,
6695                             NULL,
6696                             NULL);
6697
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,
6702                             NULL,
6703                             NULL,
6704                             NULL,
6705                             NULL);
6706         nmc_add_prop_funcs (GLUE (PPP, REFUSE_EAP),
6707                             nmc_property_ppp_get_refuse_eap,
6708                             nmc_property_set_bool,
6709                             NULL,
6710                             NULL,
6711                             NULL,
6712                             NULL);
6713         nmc_add_prop_funcs (GLUE (PPP, REFUSE_PAP),
6714                             nmc_property_ppp_get_refuse_pap,
6715                             nmc_property_set_bool,
6716                             NULL,
6717                             NULL,
6718                             NULL,
6719                             NULL);
6720         nmc_add_prop_funcs (GLUE (PPP, REFUSE_CHAP),
6721                             nmc_property_ppp_get_refuse_chap,
6722                             nmc_property_set_bool,
6723                             NULL,
6724                             NULL,
6725                             NULL,
6726                             NULL);
6727         nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAP),
6728                             nmc_property_ppp_get_refuse_mschap,
6729                             nmc_property_set_bool,
6730                             NULL,
6731                             NULL,
6732                             NULL,
6733                             NULL);
6734         nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAPV2),
6735                             nmc_property_ppp_get_refuse_mschapv2,
6736                             nmc_property_set_bool,
6737                             NULL,
6738                             NULL,
6739                             NULL,
6740                             NULL);
6741         nmc_add_prop_funcs (GLUE (PPP, NOBSDCOMP),
6742                             nmc_property_ppp_get_nobsdcomp,
6743                             nmc_property_set_bool,
6744                             NULL,
6745                             NULL,
6746                             NULL,
6747                             NULL);
6748         nmc_add_prop_funcs (GLUE (PPP, NODEFLATE),
6749                             nmc_property_ppp_get_nodeflate,
6750                             nmc_property_set_bool,
6751                             NULL,
6752                             NULL,
6753                             NULL,
6754                             NULL);
6755         nmc_add_prop_funcs (GLUE (PPP, NO_VJ_COMP),
6756                             nmc_property_ppp_get_no_vj_comp,
6757                             nmc_property_set_bool,
6758                             NULL,
6759                             NULL,
6760                             NULL,
6761                             NULL);
6762         nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE),
6763                             nmc_property_ppp_get_require_mppe,
6764                             nmc_property_set_bool,
6765                             NULL,
6766                             NULL,
6767                             NULL,
6768                             NULL);
6769         nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE_128),
6770                             nmc_property_ppp_get_require_mppe_128,
6771                             nmc_property_set_bool,
6772                             NULL,
6773                             NULL,
6774                             NULL,
6775                             NULL);
6776         nmc_add_prop_funcs (GLUE (PPP, MPPE_STATEFUL),
6777                             nmc_property_ppp_get_mppe_stateful,
6778                             nmc_property_set_bool,
6779                             NULL,
6780                             NULL,
6781                             NULL,
6782                             NULL);
6783         nmc_add_prop_funcs (GLUE (PPP, CRTSCTS),
6784                             nmc_property_ppp_get_crtscts,
6785                             nmc_property_set_bool,
6786                             NULL,
6787                             NULL,
6788                             NULL,
6789                             NULL);
6790         nmc_add_prop_funcs (GLUE (PPP, BAUD),
6791                             nmc_property_ppp_get_baud,
6792                             nmc_property_set_uint,
6793                             NULL,
6794                             NULL,
6795                             NULL,
6796                             NULL);
6797         nmc_add_prop_funcs (GLUE (PPP, MRU),
6798                             nmc_property_ppp_get_mru,
6799                             nmc_property_set_uint,
6800                             NULL,
6801                             NULL,
6802                             NULL,
6803                             NULL);
6804         nmc_add_prop_funcs (GLUE (PPP, MTU),
6805                             nmc_property_ppp_get_mtu,
6806                             nmc_property_set_mtu,
6807                             NULL,
6808                             NULL,
6809                             NULL,
6810                             NULL);
6811         nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_FAILURE),
6812                             nmc_property_ppp_get_lcp_echo_failure,
6813                             nmc_property_set_uint,
6814                             NULL,
6815                             NULL,
6816                             NULL,
6817                             NULL);
6818         nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_INTERVAL),
6819                             nmc_property_ppp_get_lcp_echo_interval,
6820                             nmc_property_set_uint,
6821                             NULL,
6822                             NULL,
6823                             NULL,
6824                             NULL);
6825
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,
6830                             NULL,
6831                             NULL,
6832                             NULL,
6833                             NULL);
6834         nmc_add_prop_funcs (GLUE (PPPOE, USERNAME),
6835                             nmc_property_pppoe_get_username,
6836                             nmc_property_set_string,
6837                             NULL,
6838                             NULL,
6839                             NULL,
6840                             NULL);
6841         nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD),
6842                             nmc_property_pppoe_get_password,
6843                             nmc_property_set_string,
6844                             NULL,
6845                             NULL,
6846                             NULL,
6847                             NULL);
6848         nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD_FLAGS),
6849                             nmc_property_pppoe_get_password_flags,
6850                             nmc_property_set_secret_flags,
6851                             NULL,
6852                             NULL,
6853                             NULL,
6854                             NULL);
6855
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,
6860                             NULL,
6861                             NULL,
6862                             NULL,
6863                             NULL);
6864         nmc_add_prop_funcs (GLUE (SERIAL, BITS),
6865                             nmc_property_serial_get_bits,
6866                             nmc_property_set_uint,
6867                             NULL,
6868                             NULL,
6869                             NULL,
6870                             NULL);
6871         nmc_add_prop_funcs (GLUE (SERIAL, PARITY),
6872                             nmc_property_serial_get_parity,
6873                             nmc_property_serial_set_parity,
6874                             NULL,
6875                             NULL,
6876                             NULL,
6877                             NULL);
6878         nmc_add_prop_funcs (GLUE (SERIAL, STOPBITS),
6879                             nmc_property_serial_get_stopbits,
6880                             nmc_property_set_uint,
6881                             NULL,
6882                             NULL,
6883                             NULL,
6884                             NULL);
6885         nmc_add_prop_funcs (GLUE (SERIAL, SEND_DELAY),
6886                             nmc_property_serial_get_send_delay,
6887                             nmc_property_set_uint,
6888                             NULL,
6889                             NULL,
6890                             NULL,
6891                             NULL);
6892
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,
6897                             NULL,
6898                             nmc_property_team_describe_config,
6899                             NULL,
6900                             NULL);
6901
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,
6906                             NULL,
6907                             nmc_property_team_describe_config,
6908                             NULL,
6909                             NULL);
6910
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,
6915                             NULL,
6916                             NULL,
6917                             NULL,
6918                             NULL);
6919         nmc_add_prop_funcs (GLUE (VLAN, ID),
6920                             nmc_property_vlan_get_id,
6921                             nmc_property_set_uint,
6922                             NULL,
6923                             NULL,
6924                             NULL,
6925                             NULL);
6926         nmc_add_prop_funcs (GLUE (VLAN, FLAGS),
6927                             nmc_property_vlan_get_flags,
6928                             nmc_property_set_flags,
6929                             NULL,
6930                             NULL,
6931                             NULL,
6932                             NULL);
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,
6937                             NULL,
6938                             NULL,
6939                             NULL);
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,
6944                             NULL,
6945                             NULL,
6946                             NULL);
6947
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,
6952                             NULL,
6953                             NULL,
6954                             NULL,
6955                             NULL);
6956         nmc_add_prop_funcs (GLUE (VPN, USER_NAME),
6957                             nmc_property_vpn_get_user_name,
6958                             nmc_property_set_string,
6959                             NULL,
6960                             NULL,
6961                             NULL,
6962                             NULL);
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,
6967                             NULL,
6968                             NULL,
6969                             NULL);
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,
6974                             NULL,
6975                             NULL,
6976                             NULL);
6977         nmc_add_prop_funcs (GLUE (VPN, PERSISTENT),
6978                             nmc_property_vpn_get_persistent,
6979                             nmc_property_set_bool,
6980                             NULL,
6981                             NULL,
6982                             NULL,
6983                             NULL);
6984
6985         nmc_add_prop_funcs (GLUE (VPN, TIMEOUT),
6986                             nmc_property_vpn_get_timeout,
6987                             nmc_property_set_uint,
6988                             NULL,
6989                             NULL,
6990                             NULL,
6991                             NULL);
6992
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,
6997                             NULL,
6998                             NULL,
6999                             NULL,
7000                             NULL);
7001         nmc_add_prop_funcs (GLUE (WIMAX, MAC_ADDRESS),
7002                             nmc_property_wimax_get_mac_address,
7003                             nmc_property_set_mac,
7004                             NULL,
7005                             NULL,
7006                             NULL,
7007                             NULL);
7008
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,*/
7013                             NULL,
7014                             NULL,
7015                             NULL, /*nmc_property_wired_allowed_port,*/
7016                             NULL);
7017         nmc_add_prop_funcs (GLUE (WIRED, SPEED),
7018                             nmc_property_wired_get_speed,
7019                             NULL,
7020                             NULL,
7021                             NULL,
7022                             NULL,
7023                             NULL);
7024         nmc_add_prop_funcs (GLUE (WIRED, DUPLEX),
7025                             nmc_property_wired_get_duplex,
7026                             NULL, /*nmc_property_wired_set_duplex,*/
7027                             NULL,
7028                             NULL,
7029                             NULL,
7030                             NULL); /*nmc_property_wired_allowed_duplex);*/
7031         nmc_add_prop_funcs (GLUE (WIRED, AUTO_NEGOTIATE),
7032                             nmc_property_wired_get_auto_negotiate,
7033                             NULL,
7034                             NULL,
7035                             NULL,
7036                             NULL,
7037                             NULL);
7038         nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS),
7039                             nmc_property_wired_get_mac_address,
7040                             nmc_property_set_mac,
7041                             NULL,
7042                             NULL,
7043                             NULL,
7044                             NULL);
7045         nmc_add_prop_funcs (GLUE (WIRED, CLONED_MAC_ADDRESS),
7046                             nmc_property_wired_get_cloned_mac_address,
7047                             nmc_property_set_mac,
7048                             NULL,
7049                             NULL,
7050                             NULL,
7051                             NULL);
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,
7056                             NULL,
7057                             NULL,
7058                             NULL);
7059         nmc_add_prop_funcs (GLUE (WIRED, MTU),
7060                             nmc_property_wired_get_mtu,
7061                             nmc_property_set_mtu,
7062                             NULL,
7063                             NULL,
7064                             NULL,
7065                             NULL);
7066         nmc_add_prop_funcs (GLUE (WIRED, S390_SUBCHANNELS),
7067                             nmc_property_wired_get_s390_subchannels,
7068                             nmc_property_wired_set_s390_subchannels,
7069                             NULL,
7070                             nmc_property_wired_describe_s390_subchannels,
7071                             NULL,
7072                             NULL);
7073         nmc_add_prop_funcs (GLUE (WIRED, S390_NETTYPE),
7074                             nmc_property_wired_get_s390_nettype,
7075                             nmc_property_wired_set_s390_nettype,
7076                             NULL,
7077                             NULL,
7078                             nmc_property_wired_allowed_s390_nettype,
7079                             NULL);
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,
7086                             NULL);
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,
7090                             NULL,
7091                             NULL,
7092                             NULL,
7093                             NULL);
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,
7097                             NULL,
7098                             NULL,
7099                             NULL,
7100                             NULL);
7101
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,
7106                             NULL,
7107                             NULL,
7108                             NULL,
7109                             NULL);
7110         nmc_add_prop_funcs (GLUE (WIRELESS, MODE),
7111                             nmc_property_wireless_get_mode,
7112                             nmc_property_wifi_set_mode,
7113                             NULL,
7114                             NULL,
7115                             nmc_property_wifi_allowed_mode,
7116                             NULL);
7117         nmc_add_prop_funcs (GLUE (WIRELESS, BAND),
7118                             nmc_property_wireless_get_band,
7119                             nmc_property_wifi_set_band,
7120                             NULL,
7121                             NULL,
7122                             nmc_property_wifi_allowed_band,
7123                             NULL);
7124         nmc_add_prop_funcs (GLUE (WIRELESS, CHANNEL),
7125                             nmc_property_wireless_get_channel,
7126                             nmc_property_wifi_set_channel,
7127                             NULL,
7128                             NULL,
7129                             NULL,
7130                             NULL);
7131         nmc_add_prop_funcs (GLUE (WIRELESS, BSSID),
7132                             nmc_property_wireless_get_bssid,
7133                             nmc_property_set_mac,
7134                             NULL,
7135                             NULL,
7136                             NULL,
7137                             NULL);
7138         /*
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).
7141          */
7142         nmc_add_prop_funcs (GLUE (WIRELESS, RATE),
7143                             nmc_property_wireless_get_rate,
7144                             NULL, /* editing rate disabled */
7145                             NULL,
7146                             NULL,
7147                             NULL,
7148                             NULL);
7149         nmc_add_prop_funcs (GLUE (WIRELESS, TX_POWER),
7150                             nmc_property_wireless_get_tx_power,
7151                             NULL, /* editing tx-power disabled */
7152                             NULL,
7153                             NULL,
7154                             NULL,
7155                             NULL);
7156         nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS),
7157                             nmc_property_wireless_get_mac_address,
7158                             nmc_property_set_mac,
7159                             NULL,
7160                             NULL,
7161                             NULL,
7162                             NULL);
7163         nmc_add_prop_funcs (GLUE (WIRELESS, CLONED_MAC_ADDRESS),
7164                             nmc_property_wireless_get_cloned_mac_address,
7165                             nmc_property_set_mac,
7166                             NULL,
7167                             NULL,
7168                             NULL,
7169                             NULL);
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,
7174                             NULL,
7175                             NULL,
7176                             NULL);
7177         nmc_add_prop_funcs (GLUE (WIRELESS, SEEN_BSSIDS),
7178                             nmc_property_wireless_get_seen_bssids,
7179                             NULL, /* read-only */
7180                             NULL,
7181                             NULL,
7182                             NULL,
7183                             NULL);
7184         nmc_add_prop_funcs (GLUE (WIRELESS, MTU),
7185                             nmc_property_wireless_get_mtu,
7186                             nmc_property_set_mtu,
7187                             NULL,
7188                             NULL,
7189                             NULL,
7190                             NULL);
7191         nmc_add_prop_funcs (GLUE (WIRELESS, HIDDEN),
7192                             nmc_property_wireless_get_hidden,
7193                             nmc_property_set_bool,
7194                             NULL,
7195                             NULL,
7196                             NULL,
7197                             NULL);
7198         nmc_add_prop_funcs (GLUE (WIRELESS, POWERSAVE),
7199                             nmc_property_wireless_get_powersave,
7200                             nmc_property_wireless_set_powersave,
7201                             NULL,
7202                             NULL,
7203                             NULL,
7204                             NULL);
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,
7208                             NULL,
7209                             NULL,
7210                             NULL,
7211                             NULL);
7212
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,
7217                             NULL,
7218                             NULL,
7219                             nmc_property_wifi_sec_allowed_key_mgmt,
7220                             NULL);
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,
7224                             NULL,
7225                             NULL,
7226                             NULL,
7227                             NULL);
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,
7231                             NULL,
7232                             NULL,
7233                             nmc_property_wifi_sec_allowed_auth_alg,
7234                             NULL);
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,
7239                             NULL,
7240                             nmc_property_wifi_sec_allowed_proto,
7241                             NULL);
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,
7246                             NULL,
7247                             nmc_property_wifi_sec_allowed_pairwise,
7248                             NULL);
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,
7253                             NULL,
7254                             nmc_property_wifi_sec_allowed_group,
7255                             NULL);
7256         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_USERNAME),
7257                             nmc_property_wifi_sec_get_leap_username,
7258                             nmc_property_set_string,
7259                             NULL,
7260                             NULL,
7261                             NULL,
7262                             NULL);
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,
7266                             NULL,
7267                             NULL,
7268                             NULL,
7269                             NULL);
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,
7273                             NULL,
7274                             NULL,
7275                             NULL,
7276                             NULL);
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,
7280                             NULL,
7281                             NULL,
7282                             NULL,
7283                             NULL);
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,
7287                             NULL,
7288                             NULL,
7289                             NULL,
7290                             NULL);
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,
7294                             NULL,
7295                             NULL,
7296                             NULL,
7297                             NULL);
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,
7301                             NULL,
7302                             nmc_property_wifi_describe_wep_key_type,
7303                             NULL,
7304                             NULL);
7305         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK),
7306                             nmc_property_wifi_sec_get_psk,
7307                             nmc_property_wifi_set_psk,
7308                             NULL,
7309                             NULL,
7310                             NULL,
7311                             NULL);
7312         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK_FLAGS),
7313                             nmc_property_wifi_sec_get_psk_flags,
7314                             nmc_property_set_secret_flags,
7315                             NULL,
7316                             NULL,
7317                             NULL,
7318                             NULL);
7319         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD),
7320                             nmc_property_wifi_sec_get_leap_password,
7321                             nmc_property_set_string,
7322                             NULL,
7323                             NULL,
7324                             NULL,
7325                             NULL);
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,
7329                             NULL,
7330                             NULL,
7331                             NULL,
7332                             NULL);
7333
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,
7338                             NULL,
7339                             NULL,
7340                             nmc_property_tun_allowed_mode,
7341                             NULL);
7342         nmc_add_prop_funcs (GLUE (TUN, OWNER),
7343                             nmc_property_tun_get_owner,
7344                             nmc_property_set_string,
7345                             NULL,
7346                             NULL,
7347                             NULL,
7348                             NULL);
7349         nmc_add_prop_funcs (GLUE (TUN, GROUP),
7350                             nmc_property_tun_get_group,
7351                             nmc_property_set_string,
7352                             NULL,
7353                             NULL,
7354                             NULL,
7355                             NULL);
7356         nmc_add_prop_funcs (GLUE (TUN, PI),
7357                             nmc_property_tun_get_pi,
7358                             nmc_property_set_bool,
7359                             NULL,
7360                             NULL,
7361                             NULL,
7362                             NULL);
7363         nmc_add_prop_funcs (GLUE (TUN, VNET_HDR),
7364                             nmc_property_tun_get_vnet_hdr,
7365                             nmc_property_set_bool,
7366                             NULL,
7367                             NULL,
7368                             NULL,
7369                             NULL);
7370         nmc_add_prop_funcs (GLUE (TUN, MULTI_QUEUE),
7371                             nmc_property_tun_get_multi_queue,
7372                             nmc_property_set_bool,
7373                             NULL,
7374                             NULL,
7375                             NULL,
7376                             NULL);
7377
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,
7382                             NULL,
7383                             NULL,
7384                             nmc_property_ip_tunnel_allowed_mode,
7385                             NULL);
7386         nmc_add_prop_funcs (GLUE (IP_TUNNEL, PARENT),
7387                             nmc_property_ip_tunnel_get_parent,
7388                             nmc_property_set_string,
7389                             NULL,
7390                             NULL,
7391                             NULL,
7392                             NULL);
7393         nmc_add_prop_funcs (GLUE (IP_TUNNEL, LOCAL),
7394                             nmc_property_ip_tunnel_get_local,
7395                             nmc_property_set_string,
7396                             NULL,
7397                             NULL,
7398                             NULL,
7399                             NULL);
7400         nmc_add_prop_funcs (GLUE (IP_TUNNEL, REMOTE),
7401                             nmc_property_ip_tunnel_get_remote,
7402                             nmc_property_set_string,
7403                             NULL,
7404                             NULL,
7405                             NULL,
7406                             NULL);
7407         nmc_add_prop_funcs (GLUE (IP_TUNNEL, TTL),
7408                             nmc_property_ip_tunnel_get_ttl,
7409                             nmc_property_set_uint,
7410                             NULL,
7411                             NULL,
7412                             NULL,
7413                             NULL);
7414         nmc_add_prop_funcs (GLUE (IP_TUNNEL, TOS),
7415                             nmc_property_ip_tunnel_get_tos,
7416                             nmc_property_set_uint,
7417                             NULL,
7418                             NULL,
7419                             NULL,
7420                             NULL);
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,
7424                             NULL,
7425                             NULL,
7426                             NULL,
7427                             NULL);
7428         nmc_add_prop_funcs (GLUE (IP_TUNNEL, INPUT_KEY),
7429                             nmc_property_ip_tunnel_get_input_key,
7430                             nmc_property_set_string,
7431                             NULL,
7432                             NULL,
7433                             NULL,
7434                             NULL);
7435         nmc_add_prop_funcs (GLUE (IP_TUNNEL, OUTPUT_KEY),
7436                             nmc_property_ip_tunnel_get_output_key,
7437                             nmc_property_set_string,
7438                             NULL,
7439                             NULL,
7440                             NULL,
7441                             NULL);
7442         nmc_add_prop_funcs (GLUE (IP_TUNNEL, ENCAPSULATION_LIMIT),
7443                             nmc_property_ip_tunnel_get_encapsulation_limit,
7444                             nmc_property_set_uint,
7445                             NULL,
7446                             NULL,
7447                             NULL,
7448                             NULL);
7449         nmc_add_prop_funcs (GLUE (IP_TUNNEL, FLOW_LABEL),
7450                             nmc_property_ip_tunnel_get_flow_label,
7451                             nmc_property_set_uint,
7452                             NULL,
7453                             NULL,
7454                             NULL,
7455                             NULL);
7456         nmc_add_prop_funcs (GLUE (IP_TUNNEL, MTU),
7457                             nmc_property_ip_tunnel_get_mtu,
7458                             nmc_property_set_uint,
7459                             NULL,
7460                             NULL,
7461                             NULL,
7462                             NULL);
7463
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,
7468                             NULL,
7469                             NULL,
7470                             NULL,
7471                             NULL);
7472         nmc_add_prop_funcs (GLUE (MACVLAN, MODE),
7473                             nmc_property_macvlan_get_mode,
7474                             nmc_property_macvlan_set_mode,
7475                             NULL,
7476                             NULL,
7477                             nmc_property_macvlan_allowed_mode,
7478                             NULL);
7479         nmc_add_prop_funcs (GLUE (MACVLAN, PROMISCUOUS),
7480                             nmc_property_macvlan_get_promiscuous,
7481                             nmc_property_set_bool,
7482                             NULL,
7483                             NULL,
7484                             NULL,
7485                             NULL);
7486         nmc_add_prop_funcs (GLUE (MACVLAN, TAP),
7487                             nmc_property_macvlan_get_tap,
7488                             nmc_property_set_bool,
7489                             NULL,
7490                             NULL,
7491                             NULL,
7492                             NULL);
7493
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,
7498                             NULL,
7499                             NULL,
7500                             NULL,
7501                             NULL);
7502         nmc_add_prop_funcs (GLUE (VXLAN, ID),
7503                             nmc_property_vxlan_get_id,
7504                             nmc_property_set_uint,
7505                             NULL,
7506                             NULL,
7507                             NULL,
7508                             NULL);
7509         nmc_add_prop_funcs (GLUE (VXLAN, LOCAL),
7510                             nmc_property_vxlan_get_local,
7511                             nmc_property_set_string,
7512                             NULL,
7513                             NULL,
7514                             NULL,
7515                             NULL);
7516         nmc_add_prop_funcs (GLUE (VXLAN, REMOTE),
7517                             nmc_property_vxlan_get_remote,
7518                             nmc_property_set_string,
7519                             NULL,
7520                             NULL,
7521                             NULL,
7522                             NULL);
7523         nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MIN),
7524                             nmc_property_vxlan_get_source_port_min,
7525                             nmc_property_set_uint,
7526                             NULL,
7527                             NULL,
7528                             NULL,
7529                             NULL);
7530         nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MAX),
7531                             nmc_property_vxlan_get_source_port_max,
7532                             nmc_property_set_uint,
7533                             NULL,
7534                             NULL,
7535                             NULL,
7536                             NULL);
7537         nmc_add_prop_funcs (GLUE (VXLAN, DESTINATION_PORT),
7538                             nmc_property_vxlan_get_destination_port,
7539                             nmc_property_set_uint,
7540                             NULL,
7541                             NULL,
7542                             NULL,
7543                             NULL);
7544         nmc_add_prop_funcs (GLUE (VXLAN, TOS),
7545                             nmc_property_vxlan_get_tos,
7546                             nmc_property_set_uint,
7547                             NULL,
7548                             NULL,
7549                             NULL,
7550                             NULL);
7551         nmc_add_prop_funcs (GLUE (VXLAN, TTL),
7552                             nmc_property_vxlan_get_ttl,
7553                             nmc_property_set_uint,
7554                             NULL,
7555                             NULL,
7556                             NULL,
7557                             NULL);
7558         nmc_add_prop_funcs (GLUE (VXLAN, AGEING),
7559                             nmc_property_vxlan_get_ageing,
7560                             nmc_property_set_uint,
7561                             NULL,
7562                             NULL,
7563                             NULL,
7564                             NULL);
7565         nmc_add_prop_funcs (GLUE (VXLAN, LIMIT),
7566                             nmc_property_vxlan_get_limit,
7567                             nmc_property_set_uint,
7568                             NULL,
7569                             NULL,
7570                             NULL,
7571                             NULL);
7572         nmc_add_prop_funcs (GLUE (VXLAN, LEARNING),
7573                             nmc_property_vxlan_get_learning,
7574                             nmc_property_set_bool,
7575                             NULL,
7576                             NULL,
7577                             NULL,
7578                             NULL);
7579         nmc_add_prop_funcs (GLUE (VXLAN, PROXY),
7580                             nmc_property_vxlan_get_proxy,
7581                             nmc_property_set_bool,
7582                             NULL,
7583                             NULL,
7584                             NULL,
7585                             NULL);
7586         nmc_add_prop_funcs (GLUE (VXLAN, RSC),
7587                             nmc_property_vxlan_get_rsc,
7588                             nmc_property_set_bool,
7589                             NULL,
7590                             NULL,
7591                             NULL,
7592                             NULL);
7593         nmc_add_prop_funcs (GLUE (VXLAN, L2_MISS),
7594                             nmc_property_vxlan_get_l2_miss,
7595                             nmc_property_set_bool,
7596                             NULL,
7597                             NULL,
7598                             NULL,
7599                             NULL);
7600         nmc_add_prop_funcs (GLUE (VXLAN, L3_MISS),
7601                             nmc_property_vxlan_get_l3_miss,
7602                             nmc_property_set_bool,
7603                             NULL,
7604                             NULL,
7605                             NULL,
7606                             NULL);
7607 }
7608
7609 void
7610 nmc_properties_cleanup ()
7611 {
7612         if (nmc_properties)
7613                 g_hash_table_destroy (nmc_properties);
7614 }
7615
7616 static const NmcPropertyFuncs *
7617 nmc_properties_find (const char *s_name, const char *p_name)
7618 {
7619         char *key;
7620         gsize p_l, s_l;
7621
7622         nmc_properties_init ();
7623
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);
7630 }
7631
7632 static char *
7633 get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error)
7634 {
7635         const NmcPropertyFuncs *item;
7636
7637         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7638         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7639
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);
7643
7644         g_set_error_literal (error, 1, 0, _("don't know how to get the property value"));
7645         return NULL;
7646 }
7647
7648 /*
7649  * Generic function for getting property value.
7650  *
7651  * Gets property value as a string by calling specialized functions.
7652  *
7653  * Returns: current property value. The caller must free the returned string.
7654  */
7655 char *
7656 nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error)
7657 {
7658         return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, error);
7659 }
7660
7661 /*
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().
7664  */
7665 char *
7666 nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError **error)
7667 {
7668         return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, error);
7669 }
7670
7671 /*
7672  * Generic function for setting property value.
7673  *
7674  * Sets property=val in setting by calling specialized functions.
7675  * If val is NULL then default property value is set.
7676  *
7677  * Returns: TRUE on success; FALSE on failure and sets error
7678  */
7679 gboolean
7680 nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error)
7681 {
7682         const NmcPropertyFuncs *item;
7683
7684         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7685         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7686
7687         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7688         if (item && item->set_func) {
7689                 if (!val) {
7690                         /* No value argument sets default value */
7691                         nmc_property_set_default_value (setting, prop);
7692                         return TRUE;
7693                 }
7694                 return item->set_func (setting, prop, val, error);
7695         }
7696
7697         g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7698         return FALSE;
7699 }
7700
7701 void
7702 nmc_property_set_default_value (NMSetting *setting, const char *prop)
7703 {
7704         GValue value = G_VALUE_INIT;
7705         GParamSpec *param_spec;
7706
7707         param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7708         if (param_spec) {
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);
7712         }
7713 }
7714
7715 /*
7716  * Generic function for reseting (single value) properties.
7717  *
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.
7721  *
7722  * Returns: TRUE on success; FALSE on failure and sets error
7723  */
7724 gboolean
7725 nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error)
7726 {
7727         const NmcPropertyFuncs *item;
7728
7729         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7730         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7731
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);
7735                 return TRUE;
7736         }
7737         g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7738         return FALSE;
7739 }
7740
7741 /*
7742  * Generic function for removing items for collection-type properties.
7743  *
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.
7747  *
7748  * Returns: TRUE on success; FALSE on failure and sets error
7749  */
7750 gboolean
7751 nmc_setting_remove_property_option (NMSetting *setting,
7752                                     const char *prop,
7753                                     const char *option,
7754                                     guint32 idx,
7755                                     GError **error)
7756 {
7757         const NmcPropertyFuncs *item;
7758
7759         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7760         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7761
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);
7765
7766         return TRUE;
7767 }
7768
7769 /*
7770  * Get valid property names for a setting.
7771  *
7772  * Returns: string array with the properties or NULL on failure.
7773  *          The returned value should be freed with g_strfreev()
7774  */
7775 char **
7776 nmc_setting_get_valid_properties (NMSetting *setting)
7777 {
7778         char **valid_props = NULL;
7779         GParamSpec **props, **iter;
7780         guint num;
7781         int i;
7782
7783         /* Iterate through properties */
7784         i = 0;
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);
7789
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);
7793         }
7794         valid_props[i] = NULL;
7795         g_free (props);
7796
7797         return valid_props;
7798 }
7799
7800 /*
7801  * Return allowed values for 'prop' as a string.
7802  */
7803 const char **
7804 nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop)
7805 {
7806
7807         const NmcPropertyFuncs *item;
7808
7809         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7810
7811         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7812         if (item && item->values_func)
7813                 return item->values_func (setting, prop);
7814
7815         return NULL;
7816 }
7817
7818 #if defined (BUILD_SETTING_DOCS) || defined (HAVE_SETTING_DOCS)
7819 #include "settings-docs.c"
7820 #else
7821 #define nmc_setting_get_property_doc(setting, prop) _("(not available)")
7822 #endif
7823
7824 /*
7825  * Create a description string for a property.
7826  *
7827  * It returns a description got from property documentation, concatenated with
7828  * nmcli specific description (if it exists).
7829  *
7830  * Returns: property description or NULL on failure. The caller must free the string.
7831  */
7832 char *
7833 nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
7834 {
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 = "";
7841
7842         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7843
7844         setting_desc = nmc_setting_get_property_doc (setting, prop);
7845         if (setting_desc)
7846                 setting_desc_title = _("[NM property description]");
7847
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]");
7852                 nmcli_nl = "\n";
7853         }
7854
7855         return g_strdup_printf ("%s\n%s\n%s%s%s%s",
7856                                 setting_desc_title,
7857                                 setting_desc ? setting_desc : "",
7858                                 nmcli_nl, nmcli_desc_title, nmcli_nl,
7859                                 nmcli_desc ? nmcli_desc : "");
7860 }
7861
7862 /*
7863  * Gets setting:prop property value and returns it in 'value'.
7864  * Caller is responsible for freeing the GValue resources using g_value_unset()
7865  */
7866 gboolean
7867 nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value)
7868 {
7869         GParamSpec *param_spec;
7870
7871         param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7872         if (param_spec) {
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);
7876                 return TRUE;
7877         }
7878         return FALSE;
7879 }
7880
7881 /*
7882  * Sets setting:prop property value from 'value'.
7883  */
7884 gboolean
7885 nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value)
7886 {
7887         GParamSpec *param_spec;
7888
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);
7892                 return TRUE;
7893         }
7894         return FALSE;
7895 }
7896
7897 /*----------------------------------------------------------------------------*/
7898
7899 #define GET_SECRET(show, setting, func) \
7900         (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_("<hidden>")))
7901
7902 static gboolean
7903 setting_connection_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
7904 {
7905         NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
7906         NmcOutputField *tmpl, *arr;
7907         size_t tmpl_len;
7908
7909         g_return_val_if_fail (NM_IS_SETTING_CONNECTION (s_con), FALSE);
7910
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);
7917
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);
7938
7939         print_data (nmc);  /* Print all data */
7940
7941         return TRUE;
7942 }
7943
7944 static gboolean
7945 setting_wired_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
7946 {
7947         NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
7948         NmcOutputField *tmpl, *arr;
7949         size_t tmpl_len;
7950
7951         g_return_val_if_fail (NM_IS_SETTING_WIRED (s_wired), FALSE);
7952
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);
7959
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);
7976
7977         print_data (nmc);  /* Print all data */
7978
7979         return TRUE;
7980 }
7981
7982 static gboolean
7983 setting_802_1X_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
7984 {
7985         NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting);
7986         NmcOutputField *tmpl, *arr;
7987         size_t tmpl_len;
7988
7989         g_return_val_if_fail (NM_IS_SETTING_802_1X (s_8021x), FALSE);
7990
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);
7997
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);
8035
8036         print_data (nmc);  /* Print all data */
8037
8038         return TRUE;
8039 }
8040
8041 static gboolean
8042 setting_wireless_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8043 {
8044         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
8045         NmcOutputField *tmpl, *arr;
8046         size_t tmpl_len;
8047
8048         g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE);
8049
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);
8056
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);
8075
8076         print_data (nmc);  /* Print all data */
8077
8078         return TRUE;
8079 }
8080
8081 static gboolean
8082 setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8083 {
8084         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
8085         NmcOutputField *tmpl, *arr;
8086         size_t tmpl_len;
8087
8088         g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (s_wireless_sec), FALSE);
8089
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);
8096
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);
8117
8118         print_data (nmc);  /* Print all data */
8119
8120         return TRUE;
8121 }
8122
8123 static gboolean
8124 setting_ip4_config_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8125 {
8126         NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting);
8127         NmcOutputField *tmpl, *arr;
8128         size_t tmpl_len;
8129
8130         g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (s_ip4), FALSE);
8131
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);
8138
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);
8160
8161         print_data (nmc);  /* Print all data */
8162
8163         return TRUE;
8164 }
8165
8166 static gboolean
8167 setting_ip6_config_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8168 {
8169         NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting);
8170         NmcOutputField *tmpl, *arr;
8171         size_t tmpl_len;
8172
8173         g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (s_ip6), FALSE);
8174
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);
8181
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);
8201
8202         print_data (nmc);  /* Print all data */
8203
8204         return TRUE;
8205 }
8206
8207 static gboolean
8208 setting_serial_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8209 {
8210         NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
8211         NmcOutputField *tmpl, *arr;
8212         size_t tmpl_len;
8213
8214         g_return_val_if_fail (NM_IS_SETTING_SERIAL (s_serial), FALSE);
8215
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);
8222
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);
8231
8232         print_data (nmc);  /* Print all data */
8233
8234         return TRUE;
8235 }
8236
8237 static gboolean
8238 setting_ppp_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8239 {
8240         NMSettingPpp *s_ppp = NM_SETTING_PPP (setting);
8241         NmcOutputField *tmpl, *arr;
8242         size_t tmpl_len;
8243
8244         g_return_val_if_fail (NM_IS_SETTING_PPP (s_ppp), FALSE);
8245
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);
8252
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);
8274
8275         print_data (nmc);  /* Print all data */
8276
8277         return TRUE;
8278 }
8279
8280 static gboolean
8281 setting_pppoe_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8282 {
8283         NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting);
8284         NmcOutputField *tmpl, *arr;
8285         size_t tmpl_len;
8286
8287         g_return_val_if_fail (NM_IS_SETTING_PPPOE (s_pppoe), FALSE);
8288
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);
8295
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);
8303
8304         print_data (nmc);  /* Print all data */
8305
8306         return TRUE;
8307 }
8308
8309 static gboolean
8310 setting_gsm_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8311 {
8312         NMSettingGsm *s_gsm = NM_SETTING_GSM (setting);
8313         NmcOutputField *tmpl, *arr;
8314         size_t tmpl_len;
8315
8316         g_return_val_if_fail (NM_IS_SETTING_GSM (s_gsm), FALSE);
8317
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);
8324
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);
8340
8341         print_data (nmc);  /* Print all data */
8342
8343         return TRUE;
8344 }
8345
8346 static gboolean
8347 setting_cdma_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8348 {
8349         NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting);
8350         NmcOutputField *tmpl, *arr;
8351         size_t tmpl_len;
8352
8353         g_return_val_if_fail (NM_IS_SETTING_CDMA (s_cdma), FALSE);
8354
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);
8361
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);
8369
8370         print_data (nmc);  /* Print all data */
8371
8372         return TRUE;
8373 }
8374
8375 static gboolean
8376 setting_bluetooth_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8377 {
8378         NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting);
8379         NmcOutputField *tmpl, *arr;
8380         size_t tmpl_len;
8381
8382         g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (s_bluetooth), FALSE);
8383
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);
8390
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);
8396
8397         print_data (nmc);  /* Print all data */
8398
8399         return TRUE;
8400 }
8401
8402 static gboolean
8403 setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8404 {
8405         NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
8406         NmcOutputField *tmpl, *arr;
8407         size_t tmpl_len;
8408
8409         g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (s_olpc_mesh), FALSE);
8410
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);
8417
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);
8424
8425         print_data (nmc);  /* Print all data */
8426
8427         return TRUE;
8428 }
8429
8430 static gboolean
8431 setting_vpn_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8432 {
8433         NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
8434         NmcOutputField *tmpl, *arr;
8435         size_t tmpl_len;
8436
8437         g_return_val_if_fail (NM_IS_SETTING_VPN (s_vpn), FALSE);
8438
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);
8445
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);
8455
8456         print_data (nmc);  /* Print all data */
8457
8458         return TRUE;
8459 }
8460
8461 static gboolean
8462 setting_wimax_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8463 {
8464         NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting);
8465         NmcOutputField *tmpl, *arr;
8466         size_t tmpl_len;
8467
8468         g_return_val_if_fail (NM_IS_SETTING_WIMAX (s_wimax), FALSE);
8469
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);
8476
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);
8482
8483         print_data (nmc);  /* Print all data */
8484
8485         return TRUE;
8486 }
8487
8488 static gboolean
8489 setting_infiniband_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8490 {
8491         NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
8492         NmcOutputField *tmpl, *arr;
8493         size_t tmpl_len;
8494
8495         g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (s_infiniband), FALSE);
8496
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);
8503
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);
8512
8513         print_data (nmc);  /* Print all data */
8514
8515         return TRUE;
8516 }
8517
8518 static gboolean
8519 setting_bond_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8520 {
8521         NMSettingBond *s_bond = NM_SETTING_BOND (setting);
8522         NmcOutputField *tmpl, *arr;
8523         size_t tmpl_len;
8524
8525         g_return_val_if_fail (NM_IS_SETTING_BOND (s_bond), FALSE);
8526
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);
8533
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);
8538
8539         print_data (nmc);  /* Print all data */
8540
8541         return TRUE;
8542 }
8543
8544 static gboolean
8545 setting_vlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8546 {
8547         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
8548         NmcOutputField *tmpl, *arr;
8549         size_t tmpl_len;
8550
8551         g_return_val_if_fail (NM_IS_SETTING_VLAN (s_vlan), FALSE);
8552
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);
8559
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);
8568
8569         print_data (nmc);  /* Print all data */
8570
8571         return TRUE;
8572 }
8573
8574 static gboolean
8575 setting_adsl_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8576 {
8577         NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting);
8578         NmcOutputField *tmpl, *arr;
8579         size_t tmpl_len;
8580
8581         g_return_val_if_fail (NM_IS_SETTING_ADSL (s_adsl), FALSE);
8582
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);
8589
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);
8600
8601         print_data (nmc);  /* Print all data */
8602
8603         return TRUE;
8604 }
8605
8606 static gboolean
8607 setting_bridge_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8608 {
8609         NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting);
8610         NmcOutputField *tmpl, *arr;
8611         size_t tmpl_len;
8612
8613         g_return_val_if_fail (NM_IS_SETTING_BRIDGE (s_bridge), FALSE);
8614
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);
8621
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);
8633
8634         print_data (nmc);  /* Print all data */
8635
8636         return TRUE;
8637 }
8638
8639 static gboolean
8640 setting_bridge_port_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8641 {
8642         NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting);
8643         NmcOutputField *tmpl, *arr;
8644         size_t tmpl_len;
8645
8646         g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (s_bridge_port), FALSE);
8647
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);
8654
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);
8661
8662         print_data (nmc);  /* Print all data */
8663
8664         return TRUE;
8665 }
8666
8667 static gboolean
8668 setting_team_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8669 {
8670         NMSettingTeam *s_team = NM_SETTING_TEAM (setting);
8671         NmcOutputField *tmpl, *arr;
8672         size_t tmpl_len;
8673
8674         g_return_val_if_fail (NM_IS_SETTING_TEAM (s_team), FALSE);
8675
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);
8682
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);
8687
8688         print_data (nmc);  /* Print all data */
8689
8690         return TRUE;
8691 }
8692
8693 static gboolean
8694 setting_team_port_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8695 {
8696         NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting);
8697         NmcOutputField *tmpl, *arr;
8698         size_t tmpl_len;
8699
8700         g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (s_team_port), FALSE);
8701
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);
8708
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);
8713
8714         print_data (nmc);  /* Print all data */
8715
8716         return TRUE;
8717 }
8718
8719 static gboolean
8720 setting_dcb_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8721 {
8722         NMSettingDcb *s_dcb = NM_SETTING_DCB (setting);
8723         NmcOutputField *tmpl, *arr;
8724         size_t tmpl_len;
8725
8726         g_return_val_if_fail (NM_IS_SETTING_DCB (s_dcb), FALSE);
8727
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);
8734
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);
8753
8754         print_data (nmc);  /* Print all data */
8755
8756         return TRUE;
8757 }
8758
8759 static gboolean
8760 setting_tun_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8761 {
8762         NMSettingTun *s_tun = NM_SETTING_TUN (setting);
8763         NmcOutputField *tmpl, *arr;
8764         size_t tmpl_len;
8765
8766         g_return_val_if_fail (NM_IS_SETTING_TUN (s_tun), FALSE);
8767
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);
8774
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);
8784
8785         print_data (nmc);  /* Print all data */
8786
8787         return TRUE;
8788 }
8789
8790 static gboolean
8791 setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8792 {
8793         NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
8794         NmcOutputField *tmpl, *arr;
8795         size_t tmpl_len;
8796
8797         g_return_val_if_fail (NM_IS_SETTING_IP_TUNNEL (s_ip_tunnel), FALSE);
8798
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);
8805
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);
8821
8822         print_data (nmc);  /* Print all data */
8823
8824         return TRUE;
8825 }
8826
8827 static gboolean
8828 setting_macvlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8829 {
8830         NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
8831         NmcOutputField *tmpl, *arr;
8832         size_t tmpl_len;
8833
8834         g_return_val_if_fail (NM_IS_SETTING_MACVLAN (s_macvlan), FALSE);
8835
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);
8842
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);
8850
8851         print_data (nmc);  /* Print all data */
8852
8853         return TRUE;
8854 }
8855
8856  static gboolean
8857 setting_vxlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8858 {
8859         NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting);
8860         NmcOutputField *tmpl, *arr;
8861         size_t tmpl_len;
8862
8863         g_return_val_if_fail (NM_IS_SETTING_VXLAN (s_vxlan), FALSE);
8864
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);
8871
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);
8891
8892         print_data (nmc);  /* Print all data */
8893
8894         return TRUE;
8895 }
8896
8897 typedef struct {
8898         const char *sname;
8899         gboolean (*func) (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets);
8900 } SettingDetails;
8901
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 },
8932         { NULL },
8933 };
8934
8935 gboolean
8936 setting_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8937 {
8938         const SettingDetails *iter = &detail_printers[0];
8939
8940         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
8941
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);
8945                 iter++;
8946         }
8947
8948         g_assert_not_reached ();
8949         return FALSE;
8950 }
8951