3fb841a1547f4e62858289edd91e1f1f0dd459bf
[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
1154                 nm_setting_bond_get_option (s_bond, i, &key, &value);
1155                 g_string_append_printf (bond_options_s, "%s=%s,", key, value);
1156         }
1157         g_string_truncate (bond_options_s, bond_options_s->len-1);  /* chop off trailing ',' */
1158
1159         return g_string_free (bond_options_s, FALSE);
1160 }
1161
1162 /* --- NM_SETTING_BRIDGE_SETTING_NAME property get functions --- */
1163 DEFINE_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS)
1164 DEFINE_GETTER (nmc_property_bridge_get_stp, NM_SETTING_BRIDGE_STP)
1165 DEFINE_GETTER (nmc_property_bridge_get_priority, NM_SETTING_BRIDGE_PRIORITY)
1166 DEFINE_GETTER (nmc_property_bridge_get_forward_delay, NM_SETTING_BRIDGE_FORWARD_DELAY)
1167 DEFINE_GETTER (nmc_property_bridge_get_hello_time, NM_SETTING_BRIDGE_HELLO_TIME)
1168 DEFINE_GETTER (nmc_property_bridge_get_max_age, NM_SETTING_BRIDGE_MAX_AGE)
1169 DEFINE_GETTER (nmc_property_bridge_get_ageing_time, NM_SETTING_BRIDGE_AGEING_TIME)
1170 DEFINE_GETTER (nmc_property_bridge_get_multicast_snooping, NM_SETTING_BRIDGE_MULTICAST_SNOOPING)
1171
1172 /* --- NM_SETTING_BRIDGE_PORT_SETTING_NAME property get functions --- */
1173 DEFINE_GETTER (nmc_property_bridge_port_get_priority, NM_SETTING_BRIDGE_PORT_PRIORITY)
1174 DEFINE_GETTER (nmc_property_bridge_port_get_path_cost, NM_SETTING_BRIDGE_PORT_PATH_COST)
1175 DEFINE_GETTER (nmc_property_bridge_port_get_hairpin_mode, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE)
1176
1177 /* --- NM_SETTING_TEAM_SETTING_NAME property get functions --- */
1178 DEFINE_GETTER (nmc_property_team_get_config, NM_SETTING_TEAM_CONFIG)
1179
1180 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property get functions --- */
1181 DEFINE_GETTER (nmc_property_team_port_get_config, NM_SETTING_TEAM_PORT_CONFIG)
1182
1183 /* --- NM_SETTING_CDMA_SETTING_NAME property get functions --- */
1184 DEFINE_GETTER (nmc_property_cdma_get_number, NM_SETTING_CDMA_NUMBER)
1185 DEFINE_GETTER (nmc_property_cdma_get_username, NM_SETTING_CDMA_USERNAME)
1186 DEFINE_GETTER (nmc_property_cdma_get_password, NM_SETTING_CDMA_PASSWORD)
1187
1188 DEFINE_SECRET_FLAGS_GETTER (nmc_property_cdma_get_password_flags, NM_SETTING_CDMA_PASSWORD_FLAGS)
1189
1190 /* --- NM_SETTING_CONNECTION_SETTING_NAME property get functions --- */
1191 DEFINE_GETTER (nmc_property_connection_get_id, NM_SETTING_CONNECTION_ID)
1192 DEFINE_GETTER (nmc_property_connection_get_uuid, NM_SETTING_CONNECTION_UUID)
1193 DEFINE_GETTER (nmc_property_connection_get_interface_name, NM_SETTING_CONNECTION_INTERFACE_NAME)
1194 DEFINE_GETTER (nmc_property_connection_get_type, NM_SETTING_CONNECTION_TYPE)
1195 DEFINE_GETTER (nmc_property_connection_get_autoconnect, NM_SETTING_CONNECTION_AUTOCONNECT)
1196 DEFINE_GETTER (nmc_property_connection_get_autoconnect_priority, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY)
1197 DEFINE_GETTER (nmc_property_connection_get_timestamp, NM_SETTING_CONNECTION_TIMESTAMP)
1198 DEFINE_GETTER (nmc_property_connection_get_read_only, NM_SETTING_CONNECTION_READ_ONLY)
1199
1200 static char *
1201 nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType get_type)
1202 {
1203         NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1204         GString *perm = NULL;
1205         const char *perm_item;
1206         const char *perm_type;
1207         int i;
1208
1209         perm = g_string_new (NULL);
1210         for (i = 0; i < nm_setting_connection_get_num_permissions (s_con); i++) {
1211                 if (nm_setting_connection_get_permission (s_con, i, &perm_type, &perm_item, NULL))
1212                         g_string_append_printf (perm, "%s:%s,", perm_type, perm_item);
1213         }
1214         if (perm->len > 0)
1215                 g_string_truncate (perm, perm->len-1); /* remove trailing , */
1216
1217         return g_string_free (perm, FALSE);
1218 }
1219
1220 DEFINE_GETTER (nmc_property_connection_get_zone, NM_SETTING_CONNECTION_ZONE)
1221 DEFINE_GETTER (nmc_property_connection_get_master, NM_SETTING_CONNECTION_MASTER)
1222 DEFINE_GETTER (nmc_property_connection_get_slave_type, NM_SETTING_CONNECTION_SLAVE_TYPE)
1223
1224 static char *
1225 nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyGetType get_type)
1226 {
1227         NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
1228         return autoconnect_slaves_to_string (nm_setting_connection_get_autoconnect_slaves (s_con), get_type);
1229 }
1230
1231 DEFINE_GETTER (nmc_property_connection_get_secondaries, NM_SETTING_CONNECTION_SECONDARIES)
1232 DEFINE_GETTER (nmc_property_connection_get_gateway_ping_timeout, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT)
1233
1234 /* --- NM_SETTING_DCB_SETTING_NAME property get functions --- */
1235 static char *
1236 dcb_flags_to_string (NMSettingDcbFlags flags)
1237 {
1238         GString *flag_str;
1239
1240         if (flags == 0)
1241                 return g_strdup (_("0 (disabled)"));
1242
1243         flag_str = g_string_new (NULL);
1244         g_string_printf (flag_str, "%d (", flags);
1245
1246         if (flags & NM_SETTING_DCB_FLAG_ENABLE)
1247                 g_string_append (flag_str, _("enabled, "));
1248         if (flags & NM_SETTING_DCB_FLAG_ADVERTISE)
1249                 g_string_append (flag_str, _("advertise, "));
1250         if (flags & NM_SETTING_DCB_FLAG_WILLING)
1251                 g_string_append (flag_str, _("willing, "));
1252
1253         if (flag_str->str[flag_str->len-1] == '(')
1254                 g_string_append (flag_str, _("unknown"));
1255         else
1256                 g_string_truncate (flag_str, flag_str->len-2);  /* chop off trailing ', ' */
1257
1258         g_string_append_c (flag_str, ')');
1259
1260         return g_string_free (flag_str, FALSE);
1261 }
1262
1263 #define DEFINE_DCB_FLAGS_GETTER(func_name, property_name) \
1264         static char * \
1265         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1266         { \
1267                 guint v; \
1268                 GValue val = G_VALUE_INIT; \
1269                 g_value_init (&val, G_TYPE_UINT); \
1270                 g_object_get_property (G_OBJECT (setting), property_name, &val); \
1271                 v = g_value_get_uint (&val); \
1272                 g_value_unset (&val); \
1273                 return dcb_flags_to_string (v); \
1274         }
1275
1276 static char *
1277 dcb_app_priority_to_string (gint priority)
1278 {
1279         return (priority == -1) ? g_strdup (_("-1 (unset)")) : g_strdup_printf ("%d", priority);
1280 }
1281
1282 #define DEFINE_DCB_APP_PRIORITY_GETTER(func_name, property_name) \
1283         static char * \
1284         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1285         { \
1286                 int v; \
1287                 GValue val = G_VALUE_INIT; \
1288                 g_value_init (&val, G_TYPE_INT); \
1289                 g_object_get_property (G_OBJECT (setting), property_name, &val); \
1290                 v = g_value_get_int (&val); \
1291                 g_value_unset (&val); \
1292                 return dcb_app_priority_to_string (v); \
1293         }
1294
1295 #define DEFINE_DCB_BOOL_GETTER(func_name, getter_func_name) \
1296         static char * \
1297         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1298         { \
1299                 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1300                 GString *str; \
1301                 guint i; \
1302  \
1303                 str = g_string_new (NULL); \
1304                 for (i = 0; i < 8; i++) { \
1305                         if (getter_func_name (s_dcb,  i)) \
1306                                 g_string_append_c (str, '1'); \
1307                         else \
1308                                 g_string_append_c (str, '0'); \
1309 \
1310                         if (i < 7) \
1311                                 g_string_append_c (str, ','); \
1312                 } \
1313 \
1314                 return g_string_free (str, FALSE); \
1315         }
1316
1317 #define DEFINE_DCB_UINT_GETTER(func_name, getter_func_name) \
1318         static char * \
1319         func_name (NMSetting *setting, NmcPropertyGetType get_type) \
1320         { \
1321                 NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \
1322                 GString *str; \
1323                 guint i; \
1324  \
1325                 str = g_string_new (NULL); \
1326                 for (i = 0; i < 8; i++) { \
1327                         g_string_append_printf (str, "%u", getter_func_name (s_dcb, i)); \
1328                         if (i < 7) \
1329                                 g_string_append_c (str, ','); \
1330                 } \
1331 \
1332                 return g_string_free (str, FALSE); \
1333         }
1334
1335 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS)
1336 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fcoe_priority, NM_SETTING_DCB_APP_FCOE_PRIORITY)
1337 DEFINE_GETTER (nmc_property_dcb_get_app_fcoe_mode, NM_SETTING_DCB_APP_FCOE_MODE)
1338 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS)
1339 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_iscsi_priority, NM_SETTING_DCB_APP_ISCSI_PRIORITY)
1340 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS)
1341 DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fip_priority, NM_SETTING_DCB_APP_FIP_PRIORITY)
1342
1343 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS)
1344 DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pfc, nm_setting_dcb_get_priority_flow_control)
1345
1346 DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pg_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS)
1347 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_id, nm_setting_dcb_get_priority_group_id)
1348 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_bandwidth, nm_setting_dcb_get_priority_group_bandwidth)
1349 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_bandwidth, nm_setting_dcb_get_priority_bandwidth)
1350 DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pg_strict, nm_setting_dcb_get_priority_strict_bandwidth)
1351 DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_traffic_class, nm_setting_dcb_get_priority_traffic_class)
1352
1353 /* --- NM_SETTING_GSM_SETTING_NAME property get functions --- */
1354 DEFINE_GETTER (nmc_property_gsm_get_number, NM_SETTING_GSM_NUMBER)
1355 DEFINE_GETTER (nmc_property_gsm_get_username, NM_SETTING_GSM_USERNAME)
1356 DEFINE_GETTER (nmc_property_gsm_get_password, NM_SETTING_GSM_PASSWORD)
1357 DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_password_flags, NM_SETTING_GSM_PASSWORD_FLAGS)
1358 DEFINE_GETTER (nmc_property_gsm_get_apn, NM_SETTING_GSM_APN)
1359 DEFINE_GETTER (nmc_property_gsm_get_network_id, NM_SETTING_GSM_NETWORK_ID)
1360 DEFINE_GETTER (nmc_property_gsm_get_pin, NM_SETTING_GSM_PIN)
1361 DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_pin_flags, NM_SETTING_GSM_PIN_FLAGS)
1362 DEFINE_GETTER (nmc_property_gsm_get_home_only, NM_SETTING_GSM_HOME_ONLY)
1363 DEFINE_GETTER (nmc_property_gsm_get_device_id, NM_SETTING_GSM_DEVICE_ID)
1364 DEFINE_GETTER (nmc_property_gsm_get_sim_id, NM_SETTING_GSM_SIM_ID)
1365 DEFINE_GETTER (nmc_property_gsm_get_sim_operator_id, NM_SETTING_GSM_SIM_OPERATOR_ID)
1366
1367 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property get functions --- */
1368 DEFINE_GETTER (nmc_property_ib_get_mac_address, NM_SETTING_INFINIBAND_MAC_ADDRESS)
1369 DEFINE_GETTER (nmc_property_ib_get_transport_mode, NM_SETTING_INFINIBAND_TRANSPORT_MODE)
1370
1371 /* --- NM_SETTING_TUN_SETTING_NAME property get functions --- */
1372 DEFINE_GETTER (nmc_property_tun_get_owner, NM_SETTING_TUN_OWNER);
1373 DEFINE_GETTER (nmc_property_tun_get_group, NM_SETTING_TUN_GROUP);
1374 DEFINE_GETTER (nmc_property_tun_get_pi, NM_SETTING_TUN_PI);
1375 DEFINE_GETTER (nmc_property_tun_get_vnet_hdr, NM_SETTING_TUN_VNET_HDR);
1376 DEFINE_GETTER (nmc_property_tun_get_multi_queue, NM_SETTING_TUN_MULTI_QUEUE);
1377
1378 /* --- NM_SETTING_IP_TUNNEL_SETTING_NAME property get functions --- */
1379 DEFINE_GETTER (nmc_property_ip_tunnel_get_parent, NM_SETTING_IP_TUNNEL_PARENT);
1380 DEFINE_GETTER (nmc_property_ip_tunnel_get_local, NM_SETTING_IP_TUNNEL_LOCAL);
1381 DEFINE_GETTER (nmc_property_ip_tunnel_get_remote, NM_SETTING_IP_TUNNEL_REMOTE);
1382 DEFINE_GETTER (nmc_property_ip_tunnel_get_ttl, NM_SETTING_IP_TUNNEL_TTL);
1383 DEFINE_GETTER (nmc_property_ip_tunnel_get_tos, NM_SETTING_IP_TUNNEL_TOS);
1384 DEFINE_GETTER (nmc_property_ip_tunnel_get_path_mtu_discovery, NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY);
1385 DEFINE_GETTER (nmc_property_ip_tunnel_get_input_key, NM_SETTING_IP_TUNNEL_INPUT_KEY);
1386 DEFINE_GETTER (nmc_property_ip_tunnel_get_output_key, NM_SETTING_IP_TUNNEL_OUTPUT_KEY);
1387 DEFINE_GETTER (nmc_property_ip_tunnel_get_encapsulation_limit, NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT);
1388 DEFINE_GETTER (nmc_property_ip_tunnel_get_flow_label, NM_SETTING_IP_TUNNEL_FLOW_LABEL);
1389 DEFINE_GETTER (nmc_property_ip_tunnel_get_mtu, NM_SETTING_IP_TUNNEL_MTU);
1390
1391 static const char **
1392 nmc_property_ip_tunnel_allowed_mode (NMSetting *setting, const char *prop)
1393 {
1394         static const char **words = NULL;
1395
1396         if (!words)
1397                 words = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1398                                                   NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1399                                                   G_MAXINT);
1400         return words;
1401 }
1402
1403 static char *
1404 nmc_property_ib_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1405 {
1406         NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1407         int mtu;
1408
1409         mtu = nm_setting_infiniband_get_mtu (s_infiniband);
1410         if (mtu == 0)
1411                 return g_strdup (_("auto"));
1412         else
1413                 return g_strdup_printf ("%d", mtu);
1414 }
1415
1416 static char *
1417 nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type)
1418 {
1419         NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
1420         int p_key;
1421
1422         p_key = nm_setting_infiniband_get_p_key (s_infiniband);
1423         if (p_key == -1)
1424                 return g_strdup (_("default"));
1425         else
1426                 return g_strdup_printf ("0x%04x", p_key);
1427 }
1428
1429 DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
1430
1431 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property get functions --- */
1432 DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP_CONFIG_METHOD)
1433 DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP_CONFIG_DNS)
1434 DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH)
1435 DEFINE_GETTER_WITH_DEFAULT (nmc_property_ipv4_get_dns_options, NM_SETTING_IP_CONFIG_DNS_OPTIONS, !nm_setting_ip_config_has_dns_options ((NMSettingIPConfig *) setting))
1436
1437 static char *
1438 nmc_property_ip_get_addresses (NMSetting *setting, NmcPropertyGetType get_type)
1439 {
1440         NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1441         GString *printable;
1442         guint32 num_addresses, i;
1443         NMIPAddress *addr;
1444
1445         printable = g_string_new (NULL);
1446
1447         num_addresses = nm_setting_ip_config_get_num_addresses (s_ip);
1448         for (i = 0; i < num_addresses; i++) {
1449                 addr = nm_setting_ip_config_get_address (s_ip, i);
1450
1451                 if (printable->len > 0)
1452                         g_string_append (printable, ", ");
1453
1454                 g_string_append_printf (printable, "%s/%u",
1455                                         nm_ip_address_get_address (addr),
1456                                         nm_ip_address_get_prefix (addr));
1457         }
1458
1459         return g_string_free (printable, FALSE);
1460 }
1461
1462 static char *
1463 nmc_property_ipvx_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1464 {
1465         NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1466         GString *printable;
1467         guint32 num_routes, i;
1468         NMIPRoute *route;
1469
1470         printable = g_string_new (NULL);
1471
1472         num_routes = nm_setting_ip_config_get_num_routes (s_ip);
1473         for (i = 0; i < num_routes; i++) {
1474                 route = nm_setting_ip_config_get_route (s_ip, i);
1475
1476                 if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1477                         if (printable->len > 0)
1478                                 g_string_append (printable, ", ");
1479
1480                         g_string_append_printf (printable, "%s/%u",
1481                                                 nm_ip_route_get_dest (route),
1482                                                 nm_ip_route_get_prefix (route));
1483
1484                         if (nm_ip_route_get_next_hop (route))
1485                                 g_string_append_printf (printable, " %s", nm_ip_route_get_next_hop (route));
1486                         if (nm_ip_route_get_metric (route) != -1)
1487                                 g_string_append_printf (printable, " %u", (guint32) nm_ip_route_get_metric (route));
1488                 } else {
1489                         if (printable->len > 0)
1490                                 g_string_append (printable, "; ");
1491
1492                         g_string_append (printable, "{ ");
1493
1494                         g_string_append_printf (printable, "ip = %s/%u",
1495                                                 nm_ip_route_get_dest (route),
1496                                                 nm_ip_route_get_prefix (route));
1497
1498                         if (nm_ip_route_get_next_hop (route)) {
1499                                 g_string_append_printf (printable, ", nh = %s",
1500                                                         nm_ip_route_get_next_hop (route));
1501                         }
1502
1503                         if (nm_ip_route_get_metric (route) != -1)
1504                                 g_string_append_printf (printable, ", mt = %u", (guint32) nm_ip_route_get_metric (route));
1505
1506                         g_string_append (printable, " }");
1507                 }
1508         }
1509
1510         return g_string_free (printable, FALSE);
1511 }
1512
1513 static char *
1514 nmc_property_ipv4_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1515 {
1516         return nmc_property_ipvx_get_routes (setting, get_type);
1517 }
1518
1519 DEFINE_GETTER (nmc_property_ipv4_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY)
1520 DEFINE_GETTER (nmc_property_ipv4_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC)
1521 DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
1522 DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
1523 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)
1524 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_timeout, NM_SETTING_IP_CONFIG_DHCP_TIMEOUT)
1525 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
1526 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
1527 DEFINE_GETTER (nmc_property_ipv4_get_dhcp_fqdn, NM_SETTING_IP4_CONFIG_DHCP_FQDN)
1528 DEFINE_GETTER (nmc_property_ipv4_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
1529 DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL)
1530
1531 static char *
1532 nmc_property_ipv4_get_dad_timeout (NMSetting *setting, NmcPropertyGetType get_type)
1533 {
1534         NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
1535         gint dad_timeout;
1536
1537         dad_timeout = nm_setting_ip_config_get_dad_timeout (s_ip);
1538         if (get_type == NMC_PROPERTY_GET_PARSABLE)
1539                 return g_strdup_printf ("%d", dad_timeout);
1540
1541         switch (dad_timeout) {
1542         case -1:
1543                 return g_strdup_printf (_("%d (default)"), dad_timeout);
1544         case 0:
1545                 return g_strdup_printf (_("%d (off)"), dad_timeout);
1546         default:
1547                 return g_strdup_printf ("%d", dad_timeout);
1548         }
1549 }
1550
1551 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property get functions --- */
1552 DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP_CONFIG_METHOD)
1553 DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP_CONFIG_DNS)
1554 DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH)
1555 DEFINE_GETTER_WITH_DEFAULT (nmc_property_ipv6_get_dns_options, NM_SETTING_IP_CONFIG_DNS_OPTIONS, !nm_setting_ip_config_has_dns_options ((NMSettingIPConfig *) setting))
1556
1557 static char *
1558 nmc_property_ipv6_get_routes (NMSetting *setting, NmcPropertyGetType get_type)
1559 {
1560         return nmc_property_ipvx_get_routes (setting, get_type);
1561 }
1562
1563 DEFINE_GETTER (nmc_property_ipv6_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY)
1564 DEFINE_GETTER (nmc_property_ipv6_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC)
1565 DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
1566 DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
1567 DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
1568 DEFINE_GETTER (nmc_property_ipv6_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL)
1569 DEFINE_GETTER (nmc_property_ipv6_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
1570 DEFINE_GETTER (nmc_property_ipv6_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
1571
1572 static char *
1573 nmc_property_ipv6_get_ip6_privacy (NMSetting *setting, NmcPropertyGetType get_type)
1574 {
1575         NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
1576         return ip6_privacy_to_string (nm_setting_ip6_config_get_ip6_privacy (s_ip6), get_type);
1577 }
1578
1579 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property get functions --- */
1580 DEFINE_GETTER (nmc_property_olpc_get_channel, NM_SETTING_OLPC_MESH_CHANNEL)
1581 DEFINE_GETTER (nmc_property_olpc_get_anycast_address, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)
1582
1583 static char *
1584 nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1585 {
1586         NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
1587         GBytes *ssid;
1588         char *ssid_str = NULL;
1589
1590         ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
1591         if (ssid) {
1592                 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1593                                                   g_bytes_get_size (ssid));
1594         }
1595
1596         return ssid_str;
1597 }
1598
1599 /* --- NM_SETTING_PPP_SETTING_NAME property get functions --- */
1600 DEFINE_GETTER (nmc_property_ppp_get_noauth, NM_SETTING_PPP_NOAUTH)
1601 DEFINE_GETTER (nmc_property_ppp_get_refuse_eap, NM_SETTING_PPP_REFUSE_EAP)
1602 DEFINE_GETTER (nmc_property_ppp_get_refuse_pap, NM_SETTING_PPP_REFUSE_PAP)
1603 DEFINE_GETTER (nmc_property_ppp_get_refuse_chap, NM_SETTING_PPP_REFUSE_CHAP)
1604 DEFINE_GETTER (nmc_property_ppp_get_refuse_mschap, NM_SETTING_PPP_REFUSE_MSCHAP)
1605 DEFINE_GETTER (nmc_property_ppp_get_refuse_mschapv2, NM_SETTING_PPP_REFUSE_MSCHAPV2)
1606 DEFINE_GETTER (nmc_property_ppp_get_nobsdcomp, NM_SETTING_PPP_NOBSDCOMP)
1607 DEFINE_GETTER (nmc_property_ppp_get_nodeflate, NM_SETTING_PPP_NODEFLATE)
1608 DEFINE_GETTER (nmc_property_ppp_get_no_vj_comp, NM_SETTING_PPP_NO_VJ_COMP)
1609 DEFINE_GETTER (nmc_property_ppp_get_require_mppe, NM_SETTING_PPP_REQUIRE_MPPE)
1610 DEFINE_GETTER (nmc_property_ppp_get_require_mppe_128, NM_SETTING_PPP_REQUIRE_MPPE_128)
1611 DEFINE_GETTER (nmc_property_ppp_get_mppe_stateful, NM_SETTING_PPP_MPPE_STATEFUL)
1612 DEFINE_GETTER (nmc_property_ppp_get_crtscts, NM_SETTING_PPP_CRTSCTS)
1613 DEFINE_GETTER (nmc_property_ppp_get_baud, NM_SETTING_PPP_BAUD)
1614 DEFINE_GETTER (nmc_property_ppp_get_mru, NM_SETTING_PPP_MRU)
1615 DEFINE_GETTER (nmc_property_ppp_get_mtu, NM_SETTING_PPP_MTU)
1616 DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_failure, NM_SETTING_PPP_LCP_ECHO_FAILURE)
1617 DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_interval, NM_SETTING_PPP_LCP_ECHO_INTERVAL)
1618
1619 /* --- NM_SETTING_PPPOE_SETTING_NAME property get functions --- */
1620 DEFINE_GETTER (nmc_property_pppoe_get_service, NM_SETTING_PPPOE_SERVICE)
1621 DEFINE_GETTER (nmc_property_pppoe_get_username, NM_SETTING_PPPOE_USERNAME)
1622 DEFINE_GETTER (nmc_property_pppoe_get_password, NM_SETTING_PPPOE_PASSWORD)
1623 DEFINE_SECRET_FLAGS_GETTER (nmc_property_pppoe_get_password_flags, NM_SETTING_PPPOE_PASSWORD_FLAGS)
1624
1625 /* --- NM_SETTING_SERIAL_SETTING_NAME property get functions --- */
1626 DEFINE_GETTER (nmc_property_serial_get_baud, NM_SETTING_SERIAL_BAUD)
1627 DEFINE_GETTER (nmc_property_serial_get_bits, NM_SETTING_SERIAL_BITS)
1628 DEFINE_GETTER (nmc_property_serial_get_stopbits, NM_SETTING_SERIAL_STOPBITS)
1629 DEFINE_GETTER (nmc_property_serial_get_send_delay, NM_SETTING_SERIAL_SEND_DELAY)
1630
1631 /* --- NM_SETTING_VLAN_SETTING_NAME property get functions --- */
1632 DEFINE_GETTER (nmc_property_vlan_get_parent, NM_SETTING_VLAN_PARENT)
1633 DEFINE_GETTER (nmc_property_vlan_get_id, NM_SETTING_VLAN_ID)
1634
1635
1636 static char *
1637 nmc_property_vlan_get_flags (NMSetting *setting, NmcPropertyGetType get_type)
1638 {
1639         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1640         return vlan_flags_to_string (nm_setting_vlan_get_flags (s_vlan));
1641 }
1642
1643 static char *
1644 nmc_property_vlan_get_ingress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1645 {
1646         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1647         return vlan_priorities_to_string (s_vlan, NM_VLAN_INGRESS_MAP);
1648 }
1649
1650 static char *
1651 nmc_property_vlan_get_egress_priority_map (NMSetting *setting, NmcPropertyGetType get_type)
1652 {
1653         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
1654         return vlan_priorities_to_string (s_vlan, NM_VLAN_EGRESS_MAP);
1655 }
1656
1657 /* --- NM_SETTING_VPN_SETTING_NAME property get functions --- */
1658 DEFINE_GETTER (nmc_property_vpn_get_service_type, NM_SETTING_VPN_SERVICE_TYPE)
1659 DEFINE_GETTER (nmc_property_vpn_get_user_name, NM_SETTING_VPN_USER_NAME)
1660
1661 static char *
1662 nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type)
1663 {
1664         NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1665         GString *data_item_str;
1666
1667         data_item_str = g_string_new (NULL);
1668         nm_setting_vpn_foreach_data_item (s_vpn, &vpn_data_item, data_item_str);
1669
1670         return g_string_free (data_item_str, FALSE);
1671 }
1672
1673 static char *
1674 nmc_property_vpn_get_secrets (NMSetting *setting, NmcPropertyGetType get_type)
1675 {
1676         NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
1677         GString *secret_str;
1678
1679         secret_str = g_string_new (NULL);
1680         nm_setting_vpn_foreach_secret (s_vpn, &vpn_data_item, secret_str);
1681
1682         return g_string_free (secret_str, FALSE);
1683 }
1684
1685 DEFINE_GETTER (nmc_property_vpn_get_persistent, NM_SETTING_VPN_PERSISTENT)
1686 DEFINE_GETTER (nmc_property_vpn_get_timeout, NM_SETTING_VPN_TIMEOUT)
1687
1688 /* --- NM_SETTING_WIMAX_SETTING_NAME property get functions --- */
1689 DEFINE_GETTER (nmc_property_wimax_get_network_name, NM_SETTING_WIMAX_NETWORK_NAME)
1690 DEFINE_GETTER (nmc_property_wimax_get_mac_address, NM_SETTING_WIMAX_MAC_ADDRESS)
1691
1692 /* --- NM_SETTING_WIRED_SETTING_NAME property get functions --- */
1693 DEFINE_GETTER (nmc_property_wired_get_port, NM_SETTING_WIRED_PORT)
1694 DEFINE_GETTER (nmc_property_wired_get_speed, NM_SETTING_WIRED_SPEED)
1695 DEFINE_GETTER (nmc_property_wired_get_duplex, NM_SETTING_WIRED_DUPLEX)
1696 DEFINE_GETTER (nmc_property_wired_get_auto_negotiate, NM_SETTING_WIRED_AUTO_NEGOTIATE)
1697 DEFINE_GETTER (nmc_property_wired_get_mac_address, NM_SETTING_WIRED_MAC_ADDRESS)
1698 DEFINE_GETTER (nmc_property_wired_get_cloned_mac_address, NM_SETTING_WIRED_CLONED_MAC_ADDRESS)
1699 DEFINE_GETTER (nmc_property_wired_get_mac_address_blacklist, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST)
1700 DEFINE_GETTER (nmc_property_wired_get_s390_subchannels, NM_SETTING_WIRED_S390_SUBCHANNELS)
1701 DEFINE_GETTER (nmc_property_wired_get_s390_nettype, NM_SETTING_WIRED_S390_NETTYPE)
1702 DEFINE_GETTER (nmc_property_wired_get_s390_options, NM_SETTING_WIRED_S390_OPTIONS)
1703 DEFINE_GETTER (nmc_property_wired_get_wake_on_lan_password, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD)
1704
1705 static char *
1706 nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1707 {
1708         NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1709         int mtu;
1710
1711         mtu = nm_setting_wired_get_mtu (s_wired);
1712         if (mtu == 0)
1713                 return g_strdup (_("auto"));
1714         else
1715                 return g_strdup_printf ("%d", mtu);
1716 }
1717
1718 static char *
1719 nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type)
1720 {
1721         NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
1722         NMSettingWiredWakeOnLan wol;
1723         char *tmp, *str;
1724
1725         wol = nm_setting_wired_get_wake_on_lan (s_wired);
1726         tmp = nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (), wol);
1727         if (get_type == NMC_PROPERTY_GET_PARSABLE)
1728                 str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "none");
1729         else
1730                 str = g_strdup_printf ("%d (%s)", wol, tmp && *tmp ? tmp : "none");
1731         g_free (tmp);
1732         return str;
1733 }
1734
1735 static gboolean
1736 nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
1737                                     const char *val, GError **error)
1738 {
1739         NMSettingWiredWakeOnLan wol;
1740         gs_free char *err_token = NULL;
1741         gboolean ret;
1742         long int t;
1743
1744         if (nmc_string_to_int_base (val, 0, TRUE, 0,
1745                                     NM_SETTING_WIRED_WAKE_ON_LAN_ALL
1746                                     | NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS,
1747                                     &t))
1748                 wol = (NMSettingWiredWakeOnLan) t;
1749         else {
1750                 ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val,
1751                                               (int *) &wol, &err_token);
1752
1753                 if (!ret) {
1754                         if (   g_ascii_strcasecmp (err_token, "none") == 0
1755                             || g_ascii_strcasecmp (err_token, "disable") == 0
1756                             || g_ascii_strcasecmp (err_token, "disabled") == 0)
1757                                 wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
1758                         else {
1759                                 g_set_error (error, 1, 0, _("invalid option '%s', use a combination of [%s] or 'ignore', 'default' or 'none'"),
1760                                              err_token,
1761                                              nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (),
1762                                                                    NM_SETTING_WIRED_WAKE_ON_LAN_ALL));
1763                                 return FALSE;
1764                         }
1765                 }
1766         }
1767
1768         if (   NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
1769             && !nm_utils_is_power_of_two (wol)) {
1770                 g_set_error_literal (error, 1, 0, _("'default' and 'ignore' are incompatible with other flags"));
1771                 return FALSE;
1772         }
1773
1774         g_object_set (setting, prop, (guint) wol, NULL);
1775         return TRUE;
1776 }
1777
1778 static char *
1779 nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1780 {
1781         NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
1782         NMIPTunnelMode mode;
1783
1784         mode = nm_setting_ip_tunnel_get_mode (s_ip_tunnel);
1785         return nm_utils_enum_to_str (nm_ip_tunnel_mode_get_type (), mode);
1786 }
1787
1788 static gboolean
1789 nmc_property_ip_tunnel_set_mode (NMSetting *setting, const char *prop,
1790                                   const char *val, GError **error)
1791 {
1792         NMIPTunnelMode mode;
1793         gboolean ret;
1794
1795         ret = nm_utils_enum_from_str (nm_ip_tunnel_mode_get_type(), val,
1796                                        (int *) &mode, NULL);
1797
1798         if (!ret) {
1799                 gs_free const char **values = NULL;
1800                 gs_free char *values_str = NULL;
1801
1802                 values = nm_utils_enum_get_values (nm_ip_tunnel_mode_get_type (),
1803                                                    NM_IP_TUNNEL_MODE_UNKNOWN + 1,
1804                                                    G_MAXINT);
1805                 values_str = g_strjoinv (",", (char **) values);
1806                 g_set_error (error, 1, 0, _("invalid mode '%s', use one of %s"),
1807                              val, values_str);
1808
1809                 return FALSE;
1810         }
1811
1812         g_object_set (setting, prop, mode, NULL);
1813         return TRUE;
1814 }
1815
1816 /* --- NM_SETTING_WIRELESS_SETTING_NAME property get functions --- */
1817 DEFINE_GETTER (nmc_property_wireless_get_mode, NM_SETTING_WIRELESS_MODE)
1818 DEFINE_GETTER (nmc_property_wireless_get_band, NM_SETTING_WIRELESS_BAND)
1819 DEFINE_GETTER (nmc_property_wireless_get_channel, NM_SETTING_WIRELESS_CHANNEL)
1820 DEFINE_GETTER (nmc_property_wireless_get_bssid, NM_SETTING_WIRELESS_BSSID)
1821 DEFINE_GETTER (nmc_property_wireless_get_rate, NM_SETTING_WIRELESS_RATE)
1822 DEFINE_GETTER (nmc_property_wireless_get_tx_power, NM_SETTING_WIRELESS_TX_POWER)
1823 DEFINE_GETTER (nmc_property_wireless_get_mac_address, NM_SETTING_WIRELESS_MAC_ADDRESS)
1824 DEFINE_GETTER (nmc_property_wireless_get_cloned_mac_address, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS)
1825 DEFINE_GETTER (nmc_property_wireless_get_mac_address_blacklist, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST)
1826 DEFINE_GETTER (nmc_property_wireless_get_seen_bssids, NM_SETTING_WIRELESS_SEEN_BSSIDS)
1827 DEFINE_GETTER (nmc_property_wireless_get_hidden, NM_SETTING_WIRELESS_HIDDEN)
1828
1829 static char *
1830 nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type)
1831 {
1832         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1833         GBytes *ssid;
1834         char *ssid_str = NULL;
1835
1836         ssid = nm_setting_wireless_get_ssid (s_wireless);
1837         if (ssid) {
1838                 ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
1839                                                   g_bytes_get_size (ssid));
1840         }
1841
1842         return ssid_str;
1843 }
1844
1845 static char *
1846 nmc_property_wireless_get_mtu (NMSetting *setting, NmcPropertyGetType get_type)
1847 {
1848         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1849         int mtu;
1850
1851         mtu = nm_setting_wireless_get_mtu (s_wireless);
1852         if (mtu == 0)
1853                 return g_strdup (_("auto"));
1854         else
1855                 return g_strdup_printf ("%d", mtu);
1856 }
1857
1858 static char *
1859 nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_type)
1860 {
1861         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
1862         NMSettingWirelessPowersave powersave;
1863         gs_free char *str = NULL;
1864         char *ret;
1865
1866         powersave = nm_setting_wireless_get_powersave (s_wireless);
1867         str = nm_utils_enum_to_str (nm_setting_wireless_powersave_get_type (), powersave);
1868
1869         if (get_type == NMC_PROPERTY_GET_PARSABLE) {
1870                 ret = str;
1871                 str = NULL;
1872                 return ret;
1873         } else
1874                 return g_strdup_printf ("%s (%u)", str, powersave);
1875 }
1876
1877 static char *
1878 nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcPropertyGetType get_type)
1879 {
1880         NMSettingWireless *s_wifi = NM_SETTING_WIRELESS (setting);
1881         NMSettingMacRandomization randomization = nm_setting_wireless_get_mac_address_randomization (s_wifi);
1882
1883         if (randomization == NM_SETTING_MAC_RANDOMIZATION_DEFAULT)
1884                 return g_strdup (_("default"));
1885         else if (randomization == NM_SETTING_MAC_RANDOMIZATION_NEVER)
1886                 return g_strdup (_("never"));
1887         else if (randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
1888                 return g_strdup_printf (_("always"));
1889         else
1890                 return g_strdup_printf (_("unknown"));
1891 }
1892
1893
1894 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property get functions --- */
1895 DEFINE_GETTER (nmc_property_wifi_sec_get_key_mgmt, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT)
1896 DEFINE_GETTER (nmc_property_wifi_sec_get_wep_tx_keyidx, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX)
1897 DEFINE_GETTER (nmc_property_wifi_sec_get_auth_alg, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG)
1898 DEFINE_GETTER (nmc_property_wifi_sec_get_proto, NM_SETTING_WIRELESS_SECURITY_PROTO)
1899 DEFINE_GETTER (nmc_property_wifi_sec_get_pairwise, NM_SETTING_WIRELESS_SECURITY_PAIRWISE)
1900 DEFINE_GETTER (nmc_property_wifi_sec_get_group, NM_SETTING_WIRELESS_SECURITY_GROUP)
1901 DEFINE_GETTER (nmc_property_wifi_sec_get_leap_username, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME)
1902 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_wep_key_flags, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS)
1903 DEFINE_GETTER (nmc_property_wifi_sec_get_psk, NM_SETTING_WIRELESS_SECURITY_PSK)
1904 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_psk_flags, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS)
1905 DEFINE_GETTER (nmc_property_wifi_sec_get_leap_password, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)
1906 DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_leap_password_flags, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS)
1907
1908 static char *
1909 nmc_property_wifi_sec_get_wep_key0 (NMSetting *setting, NmcPropertyGetType get_type)
1910 {
1911         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1912         return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 0));
1913 }
1914
1915 static char *
1916 nmc_property_wifi_sec_get_wep_key1 (NMSetting *setting, NmcPropertyGetType get_type)
1917 {
1918         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1919         return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1));
1920 }
1921
1922 static char *
1923 nmc_property_wifi_sec_get_wep_key2 (NMSetting *setting, NmcPropertyGetType get_type)
1924 {
1925         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1926         return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2));
1927 }
1928
1929 static char *
1930 nmc_property_wifi_sec_get_wep_key3 (NMSetting *setting, NmcPropertyGetType get_type)
1931 {
1932         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1933         return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3));
1934 }
1935
1936 static char *
1937 nmc_property_wifi_sec_get_wep_key_type (NMSetting *setting, NmcPropertyGetType get_type)
1938 {
1939         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
1940         return wep_key_type_to_string (nm_setting_wireless_security_get_wep_key_type (s_wireless_sec));
1941 }
1942
1943 /* --- NM_SETTING_MACVLAN_SETTING_NAME property get functions --- */
1944 DEFINE_GETTER (nmc_property_macvlan_get_parent, NM_SETTING_MACVLAN_PARENT)
1945 DEFINE_GETTER (nmc_property_macvlan_get_promiscuous, NM_SETTING_MACVLAN_PROMISCUOUS)
1946 DEFINE_GETTER (nmc_property_macvlan_get_tap, NM_SETTING_MACVLAN_TAP)
1947
1948 static char *
1949 nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
1950 {
1951         NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
1952         NMSettingMacvlanMode mode;
1953         char *tmp, *str;
1954
1955         mode = nm_setting_macvlan_get_mode (s_macvlan);
1956         tmp = nm_utils_enum_to_str (nm_setting_macvlan_mode_get_type (), mode);
1957
1958         if (get_type == NMC_PROPERTY_GET_PARSABLE)
1959                 str = g_strdup (tmp ? tmp : "");
1960         else
1961                 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
1962         g_free (tmp);
1963
1964         return str;
1965 }
1966
1967 static gboolean
1968 nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop,
1969                                const char *val, GError **error)
1970 {
1971         NMSettingMacvlanMode mode;
1972         gs_free const char **options = NULL;
1973         gs_free char *options_str = NULL;
1974         long int t;
1975         gboolean ret;
1976
1977         if (nmc_string_to_int_base (val, 0, TRUE, 0, _NM_SETTING_MACVLAN_MODE_NUM - 1, &t))
1978                 mode = (NMSettingMacvlanMode) t;
1979         else {
1980                 ret = nm_utils_enum_from_str (nm_setting_macvlan_mode_get_type (), val,
1981                                               (int *) &mode, NULL);
1982
1983                 if (!ret) {
1984                                 options = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
1985                                                                     NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
1986                                                                     G_MAXINT);
1987                                 options_str = g_strjoinv (",", (char **) options);
1988                                 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
1989                                              val, options_str);
1990                                 return FALSE;
1991                         }
1992                 }
1993
1994         g_object_set (setting, prop, (guint) mode, NULL);
1995         return TRUE;
1996 }
1997
1998 static const char **
1999 nmc_property_macvlan_allowed_mode (NMSetting *setting, const char *prop)
2000 {
2001         static const char **words = NULL;
2002
2003         if (!words)
2004                 words = nm_utils_enum_get_values (nm_setting_macvlan_mode_get_type(),
2005                                                   NM_SETTING_MACVLAN_MODE_UNKNOWN + 1,
2006                                                   G_MAXINT);
2007         return words;
2008 }
2009
2010 /* --- NM_SETTING_VXLAN_SETTING_NAME property get functions --- */
2011 DEFINE_GETTER (nmc_property_vxlan_get_parent, NM_SETTING_VXLAN_PARENT)
2012 DEFINE_GETTER (nmc_property_vxlan_get_id, NM_SETTING_VXLAN_ID)
2013 DEFINE_GETTER (nmc_property_vxlan_get_local, NM_SETTING_VXLAN_LOCAL)
2014 DEFINE_GETTER (nmc_property_vxlan_get_remote, NM_SETTING_VXLAN_REMOTE)
2015 DEFINE_GETTER (nmc_property_vxlan_get_source_port_min, NM_SETTING_VXLAN_SOURCE_PORT_MIN)
2016 DEFINE_GETTER (nmc_property_vxlan_get_source_port_max, NM_SETTING_VXLAN_SOURCE_PORT_MAX)
2017 DEFINE_GETTER (nmc_property_vxlan_get_destination_port, NM_SETTING_VXLAN_DESTINATION_PORT)
2018 DEFINE_GETTER (nmc_property_vxlan_get_tos, NM_SETTING_VXLAN_TOS)
2019 DEFINE_GETTER (nmc_property_vxlan_get_ttl, NM_SETTING_VXLAN_TTL)
2020 DEFINE_GETTER (nmc_property_vxlan_get_ageing, NM_SETTING_VXLAN_AGEING)
2021 DEFINE_GETTER (nmc_property_vxlan_get_limit, NM_SETTING_VXLAN_LIMIT)
2022 DEFINE_GETTER (nmc_property_vxlan_get_learning, NM_SETTING_VXLAN_LEARNING)
2023 DEFINE_GETTER (nmc_property_vxlan_get_proxy, NM_SETTING_VXLAN_PROXY)
2024 DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC)
2025 DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS)
2026 DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS)
2027
2028 /*----------------------------------------------------------------------------*/
2029
2030 static void
2031 nmc_value_transform_bool_string (const GValue *src_value,
2032                                  GValue       *dest_value)
2033 {
2034         dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_int ? "yes" : "no");
2035 }
2036
2037 static void
2038 nmc_value_transform_char_string (const GValue *src_value,
2039                                  GValue       *dest_value)
2040 {
2041         dest_value->data[0].v_pointer = g_strdup_printf ("%c", src_value->data[0].v_uint);
2042 }
2043
2044 static void __attribute__((constructor))
2045 register_nmcli_value_transforms (void)
2046 {
2047         g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_STRING, nmc_value_transform_bool_string);
2048         g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_STRING, nmc_value_transform_char_string);
2049 }
2050
2051 /*----------------------------------------------------------------------------*/
2052
2053 /* Main hash table storing function pointer for manipulating properties */
2054 static GHashTable *nmc_properties = NULL;
2055 typedef char *        (*NmcPropertyGetFunc)      (NMSetting *, NmcPropertyGetType);
2056 typedef gboolean      (*NmcPropertySetFunc)      (NMSetting *, const char *, const char *, GError **);
2057 typedef gboolean      (*NmcPropertyRemoveFunc)   (NMSetting *, const char *, const char *, guint32, GError **);
2058 typedef const char *  (*NmcPropertyDescribeFunc) (NMSetting *, const char *);
2059 typedef const char ** (*NmcPropertyValuesFunc)   (NMSetting *, const char *);
2060
2061 typedef struct {
2062         /* The order of the fields is important as they correspond
2063          * to the order as _nmc_add_prop_funcs() passes the arguments. */
2064 #define NmcPropertyFuncsFields \
2065         NmcPropertyGetFunc get_func;           /* func getting property values */ \
2066         NmcPropertySetFunc set_func;           /* func adding/setting property values */ \
2067         NmcPropertyRemoveFunc remove_func;     /* func removing items from container options */ \
2068         NmcPropertyDescribeFunc describe_func; /* func returning property description */ \
2069         NmcPropertyValuesFunc values_func;     /* func returning allowed property values */ \
2070         ;
2071         NmcPropertyFuncsFields
2072 } NmcPropertyFuncs;
2073
2074 /*
2075  * We need NmCli in some _set_property functions, and they aren't passed NmCli.
2076  * So use the global variable.
2077  */
2078 /* Global variable defined in nmcli.c */
2079 extern NmCli nm_cli;
2080
2081 NMSetting *
2082 nmc_setting_new_for_name (const char *name)
2083 {
2084         GType stype;
2085         NMSetting *setting = NULL;
2086
2087         if (name) {
2088                 stype = nm_setting_lookup_type (name);
2089                 if (stype != G_TYPE_INVALID) {
2090                         setting = g_object_new (stype, NULL);
2091                         g_warn_if_fail (NM_IS_SETTING (setting));
2092                 }
2093         }
2094         return setting;
2095 }
2096
2097 static gboolean
2098 get_answer (const char *prop, const char *value)
2099 {
2100         char *tmp_str;
2101         char *question;
2102         gboolean answer = FALSE;
2103
2104         if (value)
2105                 question = g_strdup_printf (_("Do you also want to set '%s' to '%s'? [yes]: "), prop, value);
2106         else
2107                 question = g_strdup_printf (_("Do you also want to clear '%s'? [yes]: "), prop);
2108         tmp_str = nmc_get_user_input (question);
2109         if (!tmp_str || matches (tmp_str, "yes") == 0)
2110                 answer = TRUE;
2111         g_free (tmp_str);
2112         g_free (question);
2113         return answer;
2114 }
2115
2116 static void ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data);
2117 static void ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data);
2118
2119 static void
2120 ipv4_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2121 {
2122         static gboolean answered = FALSE;
2123         static gboolean answer = FALSE;
2124
2125         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2126
2127         /* If we have some IP addresses set method to 'manual'.
2128          * Else if the method was 'manual', change it back to 'auto'.
2129          */
2130         if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2131                 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
2132                         if (!answered) {
2133                                 answered = TRUE;
2134                                 answer = get_answer ("ipv4.method", "manual");
2135                         }
2136                         if (answer)
2137                                 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL);
2138                 }
2139         } else {
2140                 answered = FALSE;
2141                 if (!g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
2142                         g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
2143         }
2144
2145         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_method_changed_cb), NULL);
2146 }
2147
2148 static void
2149 ipv4_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2150 {
2151         static GValue value = G_VALUE_INIT;
2152         static gboolean answered = FALSE;
2153         static gboolean answer = FALSE;
2154
2155         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2156
2157         /* If method != manual, remove addresses (save them for restoring them later when method becomes 'manual' */
2158         if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
2159                 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2160                         if (!answered) {
2161                                 answered = TRUE;
2162                                 answer = get_answer ("ipv4.addresses", NULL);
2163                         }
2164                         if (answer) {
2165                                 if (G_IS_VALUE (&value))
2166                                         g_value_unset (&value);
2167                                 nmc_property_get_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2168                                 g_object_set (object, NM_SETTING_IP_CONFIG_ADDRESSES, NULL, NULL);
2169                         }
2170                 }
2171         } else {
2172                 answered = FALSE;
2173                 if (G_IS_VALUE (&value)) {
2174                         nmc_property_set_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2175                         g_value_unset (&value);
2176                 }
2177         }
2178
2179         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2180 }
2181
2182 static void
2183 ipv6_addresses_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2184 {
2185         static gboolean answered = FALSE;
2186         static gboolean answer = FALSE;
2187
2188         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2189
2190         /* If we have some IP addresses set method to 'manual'.
2191          * Else if the method was 'manual', change it back to 'auto'.
2192          */
2193         if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2194                 if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
2195                         if (!answered) {
2196                                 answered = TRUE;
2197                                 answer = get_answer ("ipv6.method", "manual");
2198                         }
2199                         if (answer)
2200                                 g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL);
2201                 }
2202         } else {
2203                 answered = FALSE;
2204                 if (!g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
2205                         g_object_set (object, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
2206         }
2207
2208         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_method_changed_cb), NULL);
2209 }
2210
2211 static void
2212 ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2213 {
2214         static GValue value = G_VALUE_INIT;
2215         static gboolean answered = FALSE;
2216         static gboolean answer = FALSE;
2217
2218         g_signal_handlers_block_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2219
2220         /* If method != manual, remove addresses (save them for restoring them later when method becomes 'manual' */
2221         if (g_strcmp0 (nm_setting_ip_config_get_method (NM_SETTING_IP_CONFIG (object)), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
2222                 if (nm_setting_ip_config_get_num_addresses (NM_SETTING_IP_CONFIG (object))) {
2223                         if (!answered) {
2224                                 answered = TRUE;
2225                                 answer = get_answer ("ipv6.addresses", NULL);
2226                         }
2227                         if (answer) {
2228                                 if (G_IS_VALUE (&value))
2229                                         g_value_unset (&value);
2230                                 nmc_property_get_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2231                                 g_object_set (object, NM_SETTING_IP_CONFIG_ADDRESSES, NULL, NULL);
2232                         }
2233                 }
2234         } else {
2235                 answered = FALSE;
2236                 if (G_IS_VALUE (&value)) {
2237                         nmc_property_set_gvalue (NM_SETTING (object), NM_SETTING_IP_CONFIG_ADDRESSES, &value);
2238                         g_value_unset (&value);
2239                 }
2240         }
2241
2242         g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2243 }
2244
2245 static void
2246 wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2247 {
2248         const char *value = NULL, *mode;
2249         char str[16];
2250         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (object);
2251
2252         if (strcmp (g_param_spec_get_name (pspec), NM_SETTING_WIRELESS_BAND) == 0) {
2253                 value = nm_setting_wireless_get_band (s_wireless);
2254                 if (!value)
2255                         return;
2256         } else {
2257                 guint32 channel = nm_setting_wireless_get_channel (s_wireless);
2258
2259                 if (channel == 0)
2260                         return;
2261
2262                 g_snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless));
2263                 value = str;
2264         }
2265
2266         mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (object));
2267         if (!mode || !*mode || strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
2268                 g_print (_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
2269                          nm_setting_get_name (NM_SETTING (s_wireless)), g_param_spec_get_name (pspec),
2270                          value);
2271         }
2272 }
2273
2274 static void
2275 connection_master_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
2276 {
2277         NMSettingConnection *s_con = NM_SETTING_CONNECTION (object);
2278         NMConnection *connection = NM_CONNECTION (user_data);
2279         NMSetting *s_ipv4, *s_ipv6;
2280         const char *value, *tmp_str;
2281
2282         value = nm_setting_connection_get_master (s_con);
2283         if (value) {
2284                 s_ipv4 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP4_CONFIG_SETTING_NAME);
2285                 s_ipv6 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP6_CONFIG_SETTING_NAME);
2286                 if (s_ipv4 || s_ipv6) {
2287                         g_print (_("Warning: setting %s.%s requires removing ipv4 and ipv6 settings\n"),
2288                                  nm_setting_get_name (NM_SETTING (s_con)), g_param_spec_get_name (pspec));
2289                         tmp_str = nmc_get_user_input (_("Do you want to remove them? [yes] "));
2290                         if (!tmp_str || matches (tmp_str, "yes") == 0) {
2291                                 if (s_ipv4)
2292                                         nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv4));
2293                                 if (s_ipv6)
2294                                         nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv6));
2295                         }
2296                 }
2297         }
2298 }
2299
2300 void
2301 nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting)
2302 {
2303         g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
2304
2305         g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_ADDRESSES,
2306                           G_CALLBACK (ipv4_addresses_changed_cb), NULL);
2307         g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_METHOD,
2308                           G_CALLBACK (ipv4_method_changed_cb), NULL);
2309 }
2310
2311 void
2312 nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting)
2313 {
2314         g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting));
2315
2316         g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_ADDRESSES,
2317                           G_CALLBACK (ipv6_addresses_changed_cb), NULL);
2318         g_signal_connect (setting, "notify::" NM_SETTING_IP_CONFIG_METHOD,
2319                           G_CALLBACK (ipv6_method_changed_cb), NULL);
2320 }
2321
2322 void
2323 nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
2324 {
2325         g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
2326
2327         g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_BAND,
2328                           G_CALLBACK (wireless_band_channel_changed_cb), NULL);
2329         g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_CHANNEL,
2330                           G_CALLBACK (wireless_band_channel_changed_cb), NULL);
2331 }
2332
2333 void
2334 nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection)
2335 {
2336         g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
2337
2338         g_signal_connect (setting, "notify::" NM_SETTING_CONNECTION_MASTER,
2339                           G_CALLBACK (connection_master_changed_cb), connection);
2340 }
2341
2342 /*
2343  * Customize some properties of the setting so that the setting has sensible
2344  * values.
2345  */
2346 void
2347 nmc_setting_custom_init (NMSetting *setting)
2348 {
2349         g_return_if_fail (NM_IS_SETTING (setting));
2350
2351         if (NM_IS_SETTING_IP4_CONFIG (setting)) {
2352                 g_object_set (NM_SETTING_IP_CONFIG (setting),
2353                               NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
2354                               NULL);
2355                 nmc_setting_ip4_connect_handlers (NM_SETTING_IP_CONFIG (setting));
2356         } else if (NM_IS_SETTING_IP6_CONFIG (setting)) {
2357                 g_object_set (NM_SETTING_IP_CONFIG (setting),
2358                               NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
2359                               NULL);
2360                 nmc_setting_ip6_connect_handlers (NM_SETTING_IP_CONFIG (setting));
2361         } else if (NM_IS_SETTING_WIRELESS (setting)) {
2362                 g_object_set (NM_SETTING_WIRELESS (setting),
2363                               NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
2364                               NULL);
2365                 nmc_setting_wireless_connect_handlers (NM_SETTING_WIRELESS (setting));
2366         }
2367 }
2368
2369 /* === SetFunc, RemoveFunc, DescribeFunc, ValuesFunc functions === */
2370 static gboolean
2371 verify_string_list (char **strv,
2372                     const char *prop,
2373                     gboolean (*validate_func) (const char *),
2374                     GError **error)
2375 {
2376         char **iter;
2377
2378         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2379
2380         for (iter = strv; iter && *iter; iter++) {
2381                 if (**iter == '\0')
2382                         continue;
2383                 if (validate_func) {
2384                         if (!validate_func (*iter)) {
2385                                 g_set_error (error, 1, 0, _("'%s' is not valid"),
2386                                              *iter);
2387                                 return FALSE;
2388                         }
2389                 }
2390         }
2391         return TRUE;
2392 }
2393
2394 /* Validate 'val' number against to int property spec */
2395 static gboolean
2396 validate_int (NMSetting *setting, const char* prop, gint val, GError **error)
2397 {
2398         GParamSpec *pspec;
2399         GValue value = G_VALUE_INIT;
2400         gboolean success = TRUE;
2401
2402         g_value_init (&value, G_TYPE_INT);
2403         g_value_set_int (&value, val);
2404         pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2405         g_assert (G_IS_PARAM_SPEC (pspec));
2406         if (g_param_value_validate (pspec, &value)) {
2407                 GParamSpecInt *pspec_int = (GParamSpecInt *) pspec;
2408                 g_set_error (error, 1, 0, _("'%d' is not valid; use <%d-%d>"),
2409                              val, pspec_int->minimum, pspec_int->maximum);
2410                 success = FALSE;
2411         }
2412         g_value_unset (&value);
2413         return success;
2414 }
2415
2416 static gboolean
2417 validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error)
2418 {
2419         GParamSpec *pspec;
2420         GValue value = G_VALUE_INIT;
2421         gboolean success = TRUE;
2422
2423         g_value_init (&value, G_TYPE_INT64);
2424         g_value_set_int64 (&value, val);
2425         pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2426         g_assert (G_IS_PARAM_SPEC (pspec));
2427         if (g_param_value_validate (pspec, &value)) {
2428                 GParamSpecInt64 *pspec_int = (GParamSpecInt64 *) pspec;
2429                 G_STATIC_ASSERT (sizeof (long long) >= sizeof (gint64));
2430                 g_set_error (error, 1, 0, _("'%lld' is not valid; use <%lld-%lld>"),
2431                              (long long) val, (long long) pspec_int->minimum, (long long) pspec_int->maximum);
2432                 success = FALSE;
2433         }
2434         g_value_unset (&value);
2435         return success;
2436 }
2437
2438 /* Validate 'val' number against to uint property spec */
2439 static gboolean
2440 validate_uint (NMSetting *setting, const char* prop, guint val, GError **error)
2441 {
2442         GParamSpec *pspec;
2443         GValue value = G_VALUE_INIT;
2444         gboolean success = TRUE;
2445
2446         g_value_init (&value, G_TYPE_UINT);
2447         g_value_set_uint (&value, val);
2448         pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2449         g_assert (G_IS_PARAM_SPEC (pspec));
2450         if (g_param_value_validate (pspec, &value)) {
2451                 GParamSpecUInt *pspec_uint = (GParamSpecUInt *) pspec;
2452                 g_set_error (error, 1, 0, _("'%u' is not valid; use <%u-%u>"),
2453                              val, pspec_uint->minimum, pspec_uint->maximum);
2454                 success = FALSE;
2455         }
2456         g_value_unset (&value);
2457         return success;
2458 }
2459
2460 static char *
2461 flag_values_to_string (GFlagsValue *array, guint n)
2462 {
2463         GString *str;
2464         guint i;
2465
2466         str = g_string_new (NULL);
2467         for (i = 0; i < n; i++)
2468                 g_string_append_printf (str, "%u, ", array[i].value);
2469         if (str->len)
2470                 g_string_truncate (str, str->len-2);  /* chop off trailing ', ' */
2471         return g_string_free (str, FALSE);
2472 }
2473
2474 static gboolean
2475 validate_flags (NMSetting *setting, const char* prop, guint val, GError **error)
2476 {
2477         GParamSpec *pspec;
2478         GValue value = G_VALUE_INIT;
2479         gboolean success = TRUE;
2480
2481         pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
2482         g_assert (G_IS_PARAM_SPEC (pspec));
2483
2484         g_value_init (&value, pspec->value_type);
2485         g_value_set_flags (&value, val);
2486
2487         if (g_param_value_validate (pspec, &value)) {
2488                 GParamSpecFlags *pspec_flags = (GParamSpecFlags *) pspec;
2489                 char *flag_values = flag_values_to_string (pspec_flags->flags_class->values,
2490                                                            pspec_flags->flags_class->n_values);
2491                 g_set_error (error, 1, 0, _("'%u' flags are not valid; use combination of %s"),
2492                              val, flag_values);
2493                 g_free (flag_values);
2494                 success = FALSE;
2495         }
2496         g_value_unset (&value);
2497         return success;
2498 }
2499
2500 static gboolean
2501 check_and_set_string (NMSetting *setting,
2502                       const char *prop,
2503                       const char *val,
2504                       const char **valid_strv,
2505                       GError **error)
2506 {
2507         const char *checked_val;
2508
2509         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2510
2511         checked_val = nmc_string_is_valid (val, valid_strv, error);
2512         if (!checked_val)
2513                 return FALSE;
2514
2515         g_object_set (setting, prop, checked_val, NULL);
2516         return TRUE;
2517 }
2518
2519 #define DEFINE_SETTER_STR_LIST_MULTI(def_func, s_macro, set_func) \
2520         static gboolean \
2521         def_func (NMSetting *setting, \
2522                   const char *prop, \
2523                   const char *val, \
2524                   const char **valid_strv, \
2525                   GError **error) \
2526         { \
2527                 char **strv = NULL, **iter; \
2528                 const char *item; \
2529                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2530                 strv = nmc_strsplit_set (val, " \t,", 0); \
2531                 for (iter = strv; iter && *iter; iter++) { \
2532                         if (!(item = nmc_string_is_valid (g_strstrip (*iter), valid_strv, error))) { \
2533                                 g_strfreev (strv); \
2534                                 return FALSE; \
2535                         } \
2536                         set_func (s_macro (setting), item); \
2537                 } \
2538                 g_strfreev (strv); \
2539                 return TRUE; \
2540         }
2541
2542 #define DEFINE_SETTER_OPTIONS(def_func, s_macro, s_type, add_func, valid_func1, valid_func2) \
2543         static gboolean \
2544         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2545         { \
2546                 char **strv = NULL, **iter; \
2547                 const char **(*valid_func1_p) (s_type *) = valid_func1; \
2548                 const char * (*valid_func2_p) (const char *, const char *, GError **) = valid_func2; \
2549                 const char *opt_name, *opt_val; \
2550                 \
2551                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2552                 \
2553                 strv = nmc_strsplit_set (val, ",", 0); \
2554                 for (iter = strv; iter && *iter; iter++) { \
2555                         char *left = g_strstrip (*iter); \
2556                         char *right = strchr (left, '='); \
2557                         if (!right) { \
2558                                 g_set_error (error, 1, 0, _("'%s' is not valid; use <option>=<value>"), *iter); \
2559                                 g_strfreev (strv); \
2560                                 return FALSE; \
2561                         } \
2562                         *right++ = '\0'; \
2563                         \
2564                         if (valid_func1_p) { \
2565                                 const char **valid_options = valid_func1_p (s_macro (setting)); \
2566                                 if (!(opt_name = nmc_string_is_valid (g_strstrip (left), valid_options, error))) { \
2567                                         g_strfreev (strv); \
2568                                         return FALSE; \
2569                                 } \
2570                         } else \
2571                                 opt_name = g_strstrip (left);\
2572                         \
2573                         opt_val = g_strstrip (right); \
2574                         if (valid_func2_p) { \
2575                                 if (!(opt_val = valid_func2_p ((const char *) left, (const char *) opt_val, error))) { \
2576                                         g_strfreev (strv); \
2577                                         return FALSE; \
2578                                 }\
2579                         }\
2580                         add_func (s_macro (setting), opt_name, opt_val); \
2581                 } \
2582                 g_strfreev (strv); \
2583                 return TRUE; \
2584         }
2585
2586 #define DEFINE_REMOVER_INDEX(def_func, s_macro, num_func, rem_func) \
2587         static gboolean \
2588         def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2589         { \
2590                 guint32 num; \
2591                 if (option) { \
2592                         g_set_error (error, 1, 0, _("index '%s' is not valid"), option); \
2593                         return FALSE; \
2594                 } \
2595                 num = num_func (s_macro (setting)); \
2596                 if (num == 0) { \
2597                         g_set_error_literal (error, 1, 0, _("no item to remove")); \
2598                         return FALSE; \
2599                 } \
2600                 if (idx >= num) { \
2601                         g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2602                         return FALSE; \
2603                 } \
2604                 rem_func (s_macro (setting), idx); \
2605                 return TRUE; \
2606         }
2607
2608 #define DEFINE_REMOVER_INDEX_OR_VALUE(def_func, s_macro, num_func, rem_func_idx, rem_func_val) \
2609         static gboolean \
2610         def_func (NMSetting *setting, const char *prop, const char *value, guint32 idx, GError **error) \
2611         { \
2612                 guint32 num; \
2613                 if (value) { \
2614                         gboolean ret; \
2615                         char *value_stripped = g_strstrip (g_strdup (value)); \
2616                         ret = rem_func_val (s_macro (setting), value_stripped, error); \
2617                         g_free (value_stripped); \
2618                         return ret; \
2619                 } \
2620                 num = num_func (s_macro (setting)); \
2621                 if (num == 0) { \
2622                         g_set_error_literal (error, 1, 0, _("no item to remove")); \
2623                         return FALSE; \
2624                 } \
2625                 if (idx >= num) { \
2626                         g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \
2627                         return FALSE; \
2628                 } \
2629                 rem_func_idx (s_macro (setting), idx); \
2630                 return TRUE; \
2631         }
2632
2633 #define DEFINE_REMOVER_OPTION(def_func, s_macro, rem_func) \
2634         static gboolean \
2635         def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \
2636         { \
2637                 gboolean success = FALSE; \
2638                 if (option && *option) { \
2639                         success = rem_func (s_macro (setting), option); \
2640                         if (!success) \
2641                                 g_set_error (error, 1, 0, _("invalid option '%s'"), option); \
2642                 } else \
2643                         g_set_error_literal (error, 1, 0, _("missing option")); \
2644                 return success; \
2645         }
2646
2647 #define DEFINE_ALLOWED_VAL_FUNC(def_func, valid_values) \
2648         static const char ** \
2649         def_func (NMSetting *setting, const char *prop) \
2650         { \
2651                 return valid_values; \
2652         }
2653
2654 /* --- generic property setter functions --- */
2655 static gboolean
2656 nmc_property_set_string (NMSetting *setting, const char *prop, const char *val, GError **error)
2657 {
2658         g_object_set (setting, prop, val, NULL);
2659         return TRUE;
2660 }
2661
2662 static gboolean
2663 nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GError **error)
2664 {
2665         unsigned long val_int;
2666
2667         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2668
2669         if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
2670                 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2671                 return FALSE;
2672         }
2673
2674         /* Validate the number according to the property spec */
2675         if (!validate_uint (setting, prop, (guint) val_int, error))
2676                 return FALSE;
2677
2678         g_object_set (setting, prop, (guint) val_int, NULL);
2679         return TRUE;
2680 }
2681
2682 static gboolean
2683 nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error)
2684 {
2685         long int val_int;
2686
2687         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2688
2689         if (!nmc_string_to_int (val, TRUE, G_MININT, G_MAXINT, &val_int)) {
2690                 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2691                 return FALSE;
2692         }
2693
2694         /* Validate the number according to the property spec */
2695         if (!validate_int (setting, prop, (gint) val_int, error))
2696                 return FALSE;
2697
2698         g_object_set (setting, prop, (gint) val_int, NULL);
2699         return TRUE;
2700 }
2701
2702 static gboolean
2703 nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, GError **error)
2704 {
2705         long val_int;
2706
2707         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2708
2709         if (!nmc_string_to_int (val, FALSE, 0, 0, &val_int)) {
2710                 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2711                 return FALSE;
2712         }
2713
2714         /* Validate the number according to the property spec */
2715         if (!validate_int64 (setting, prop, (gint64) val_int, error))
2716                 return FALSE;
2717
2718         g_object_set (setting, prop, (gint64) val_int, NULL);
2719         return TRUE;
2720 }
2721
2722 static gboolean
2723 nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2724 {
2725         unsigned long val_int;
2726
2727         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2728
2729         if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) {
2730                 g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val);
2731                 return FALSE;
2732         }
2733
2734         /* Validate the flags according to the property spec */
2735         if (!validate_flags (setting, prop, (guint) val_int, error))
2736                 return FALSE;
2737
2738         g_object_set (setting, prop, (guint) val_int, NULL);
2739         return TRUE;
2740 }
2741
2742 static gboolean
2743 nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error)
2744 {
2745         gboolean val_bool;
2746
2747         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2748
2749         if (!nmc_string_to_bool (val, &val_bool, error))
2750                 return FALSE;
2751
2752         g_object_set (setting, prop, val_bool, NULL);
2753         return TRUE;
2754 }
2755
2756 static gboolean
2757 nmc_property_set_trilean (NMSetting *setting, const char *prop, const char *val, GError **error)
2758 {
2759         long int val_int;
2760
2761         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2762
2763         if (!nmc_string_to_int (val, TRUE, -1, 1, &val_int)) {
2764                 g_set_error (error, 1, 0, _("'%s' is not a valid value; use -1, 0 or 1"), val);
2765                 return FALSE;
2766         }
2767
2768         g_object_set (setting, prop, val_int, NULL);
2769         return TRUE;
2770 }
2771
2772 static gboolean
2773 nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error)
2774 {
2775         GBytes *ssid;
2776
2777         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2778
2779         if (strlen (val) > 32) {
2780                 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
2781                 return FALSE;
2782         }
2783
2784         ssid = g_bytes_new (val, strlen (val));
2785         g_object_set (setting, prop, ssid, NULL);
2786         g_bytes_unref (ssid);
2787         return TRUE;
2788 }
2789
2790 static gboolean
2791 nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
2792 {
2793         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2794
2795         if (!nm_utils_hwaddr_valid (val, ETH_ALEN)) {
2796                 g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), val);
2797                 return FALSE;
2798         }
2799
2800         g_object_set (setting, prop, val, NULL);
2801         return TRUE;
2802 }
2803
2804 static gboolean
2805 nmc_property_set_mtu (NMSetting *setting, const char *prop, const char *val, GError **error)
2806 {
2807         const char *mtu = val;
2808
2809         if (strcmp (mtu, "auto") == 0)
2810                 mtu = "0";
2811
2812         return nmc_property_set_uint (setting, prop, mtu, error);
2813 }
2814
2815 static gboolean
2816 nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, GError **error)
2817 {
2818         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2819
2820         if (!nm_utils_iface_valid_name (val)) {
2821                 g_set_error (error, 1, 0, _("'%s' is not a valid interface name"), val);
2822                 return FALSE;
2823         }
2824         g_object_set (setting, prop, val, NULL);
2825         return TRUE;
2826 }
2827
2828 #define ALL_SECRET_FLAGS \
2829         (NM_SETTING_SECRET_FLAG_NONE | \
2830          NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
2831          NM_SETTING_SECRET_FLAG_NOT_SAVED | \
2832          NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
2833
2834 static gboolean
2835 nmc_property_set_secret_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
2836 {
2837         char **strv = NULL, **iter;
2838         unsigned long flags = 0, val_int;
2839
2840         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2841
2842         strv = nmc_strsplit_set (val, " \t,", 0);
2843         for (iter = strv; iter && *iter; iter++) {
2844                 if (!nmc_string_to_uint (*iter, TRUE, 0, ALL_SECRET_FLAGS, &val_int)) {
2845                         g_set_error (error, 1, 0, _("'%s' is not a valid flag number; use <0-%d>"),
2846                                      *iter, ALL_SECRET_FLAGS);
2847                         g_strfreev (strv);
2848                         return FALSE;
2849                 }
2850                 flags += val_int;
2851         }
2852         g_strfreev (strv);
2853
2854         /* Validate the flags number */
2855         if (flags > ALL_SECRET_FLAGS) {
2856                 flags = ALL_SECRET_FLAGS;
2857                 g_print (_("Warning: '%s' sum is higher than all flags => all flags set\n"), val);
2858         }
2859
2860         g_object_set (setting, prop, (guint) flags, NULL);
2861         return TRUE;
2862 }
2863
2864 static gboolean
2865 nmc_util_is_domain (const char *domain)
2866 {
2867         //FIXME: implement
2868         return TRUE;
2869 }
2870
2871 static gboolean
2872 nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *val, GError **error)
2873 {
2874         char **strv = NULL, **iter;
2875         char *val_strip;
2876         const char *delimiters = " \t,";
2877         long int val_int;
2878         GBytes *bytes;
2879         GByteArray *array = NULL;
2880         gboolean success = TRUE;
2881
2882         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2883
2884         val_strip = g_strstrip (g_strdup (val));
2885
2886         /* First try hex string in the format of AAbbCCDd */
2887         bytes = nm_utils_hexstr2bin (val_strip);
2888         if (bytes) {
2889                 array = g_bytes_unref_to_array (bytes);
2890                 goto done;
2891         }
2892
2893         /* Otherwise, consider the following format: AA b 0xCc D */
2894         strv = nmc_strsplit_set (val_strip, delimiters, 0);
2895         array = g_byte_array_sized_new (g_strv_length (strv));
2896         for (iter = strv; iter && *iter; iter++) {
2897                 if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) {
2898                         g_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
2899                         success = FALSE;
2900                         goto done;
2901                 }
2902                 g_byte_array_append (array, (const guint8 *) &val_int, 1);
2903         }
2904
2905 done:
2906         if (success)
2907                 g_object_set (setting, prop, array, NULL);
2908
2909         g_strfreev (strv);
2910         if (array)
2911                 g_byte_array_free (array, TRUE);
2912         return success;
2913 }
2914
2915 #define DEFINE_SETTER_MAC_BLACKLIST(def_func, s_macro, add_func) \
2916         static gboolean \
2917         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
2918         { \
2919                 guint8 buf[32]; \
2920                 char **list = NULL, **iter; \
2921                 GSList *macaddr_blacklist = NULL; \
2922                 \
2923                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
2924                 \
2925                 list = nmc_strsplit_set (val, " \t,", 0); \
2926                 for (iter = list; iter && *iter; iter++) { \
2927                         if (!nm_utils_hwaddr_aton (*iter, buf, ETH_ALEN)) { \
2928                                 g_set_error (error, 1, 0, _("'%s' is not a valid MAC"), *iter); \
2929                                 g_strfreev (list); \
2930                                 g_slist_free (macaddr_blacklist); \
2931                                 return FALSE; \
2932                         } \
2933                 } \
2934                 \
2935                 for (iter = list; iter && *iter; iter++) \
2936                         add_func (s_macro (setting), *iter); \
2937                 \
2938                 g_strfreev (list); \
2939                 return TRUE; \
2940         }
2941
2942 /* --- NM_SETTING_CONNECTION_SETTING_NAME property setter functions --- */
2943 #if 0
2944 /*
2945  * Setting/removing UUID has been forbidden.
2946  * Should it be enabled later, this function can be used.
2947  */
2948 static gboolean
2949 nmc_property_con_set_uuid (NMSetting *setting, const char *prop, const char *val, GError **error)
2950 {
2951         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2952
2953         if (!nm_utils_is_uuid (val)) {
2954                 g_set_error (error, 1, 0, _("'%s' is not a valid UUID"), val);
2955                 return FALSE;
2956         }
2957         g_object_set (setting, prop, val, NULL);
2958         return TRUE;
2959 }
2960 #endif
2961
2962 /* 'permissions' */
2963 /* define from libnm-core/nm-setting-connection.c */
2964 #define PERM_USER_PREFIX  "user:"
2965
2966 static gboolean
2967 permissions_valid (const char *perm)
2968 {
2969         if (!perm || perm[0] == '\0')
2970                 return FALSE;
2971
2972         if (strncmp (perm, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0) {
2973                 if (   strlen (perm) <= strlen (PERM_USER_PREFIX)
2974                     || strchr (perm + strlen (PERM_USER_PREFIX), ':'))
2975                         return  FALSE;
2976         } else {
2977                 if (strchr (perm, ':'))
2978                         return  FALSE;
2979         }
2980
2981         return TRUE;
2982 }
2983
2984 static gboolean
2985 nmc_property_connection_set_permissions (NMSetting *setting, const char *prop, const char *val, GError **error)
2986 {
2987         char **strv = NULL;
2988         guint i = 0;
2989
2990         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2991
2992         strv = nmc_strsplit_set (val, " \t,", 0);
2993         if (!verify_string_list (strv, prop, permissions_valid, error)) {
2994                 g_strfreev (strv);
2995                 return FALSE;
2996         }
2997
2998         for (i = 0; strv && strv[i]; i++) {
2999                 const char *user;
3000
3001                 if (strncmp (strv[i], PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0)
3002                         user = strv[i]+strlen (PERM_USER_PREFIX);
3003                 else
3004                         user = strv[i];
3005
3006                 nm_setting_connection_add_permission (NM_SETTING_CONNECTION (setting), "user", user, NULL);
3007         }
3008
3009         return TRUE;
3010 }
3011
3012 static gboolean
3013 _validate_and_remove_connection_permission (NMSettingConnection *setting,
3014                                             const char *perm,
3015                                             GError **error)
3016 {
3017         gboolean ret;
3018
3019         ret = nm_setting_connection_remove_permission_by_value (setting, "user", perm, NULL);
3020         if (!ret)
3021                 g_set_error (error, 1, 0, _("the property doesn't contain permission '%s'"), perm);
3022         return ret;
3023 }
3024 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_permissions,
3025                                NM_SETTING_CONNECTION,
3026                                nm_setting_connection_get_num_permissions,
3027                                nm_setting_connection_remove_permission,
3028                                _validate_and_remove_connection_permission)
3029
3030 static const char *
3031 nmc_property_connection_describe_permissions (NMSetting *setting, const char *prop)
3032 {
3033         return _("Enter a list of user permissions. This is a list of user names formatted as:\n"
3034                  "  [user:]<user name 1>, [user:]<user name 2>,...\n"
3035                  "The items can be separated by commas or spaces.\n\n"
3036                  "Example: alice bob charlie\n");
3037 }
3038
3039 /* 'master' */
3040 static gboolean
3041 nmc_property_con_set_master (NMSetting *setting, const char *prop, const char *val, GError **error)
3042 {
3043         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3044
3045         if (!val)
3046                 ;
3047         else if (!*val)
3048                 val = NULL;
3049         else if (   !nm_utils_iface_valid_name (val)
3050                  && !nm_utils_is_uuid (val)) {
3051                 g_set_error (error, 1, 0,
3052                              _("'%s' is not valid master; use ifname or connection UUID"),
3053                              val);
3054                 return FALSE;
3055         }
3056         g_object_set (setting, prop, val, NULL);
3057         return TRUE;
3058 }
3059
3060 /* 'slave-type' */
3061 static const char *con_valid_slave_types[] = {
3062         NM_SETTING_BOND_SETTING_NAME,
3063         NM_SETTING_BRIDGE_SETTING_NAME,
3064         NM_SETTING_TEAM_SETTING_NAME,
3065         NULL
3066 };
3067
3068 static gboolean
3069 nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3070 {
3071         return check_and_set_string (setting, prop, val, con_valid_slave_types, error);
3072 }
3073
3074
3075 DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_types)
3076
3077 /* 'secondaries' */
3078 static gboolean
3079 nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error)
3080 {
3081         NMConnection *con;
3082         char **strv = NULL, **iter;
3083         guint i = 0;
3084
3085         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3086
3087         strv = nmc_strsplit_set (val, " \t,", 0);
3088         for (iter = strv; iter && *iter; iter++) {
3089                 if (**iter == '\0')
3090                         continue;
3091
3092                 if (nm_utils_is_uuid (*iter)) {
3093                         con = nmc_find_connection (nm_cli.connections,
3094                                                    "uuid", *iter, NULL);
3095                         if (!con)
3096                                 g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
3097                         else {
3098                                 /* Currenly NM only supports VPN connections as secondaries */
3099                                 if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
3100                                         g_set_error (error, 1, 0, _("'%s' is not a VPN connection profile"), *iter);
3101                                         g_strfreev (strv);
3102                                         return FALSE;
3103                                 }
3104                         }
3105                 } else {
3106                         con = nmc_find_connection (nm_cli.connections,
3107                                                    "id", *iter, NULL);
3108                         if (!con) {
3109                                 g_set_error (error, 1, 0, _("'%s' is not a name of any exiting profile"), *iter);
3110                                 g_strfreev (strv);
3111                                 return FALSE;
3112                         }
3113
3114                         /* Currenly NM only supports VPN connections as secondaries */
3115                         if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
3116                                 g_set_error (error, 1, 0, _("'%s' is not a VPN connection profile"), *iter);
3117                                 g_strfreev (strv);
3118                                 return FALSE;
3119                         }
3120
3121                         /* translate id to uuid */
3122                         g_free (*iter);
3123                         *iter = g_strdup (nm_connection_get_uuid (con));
3124                 }
3125         }
3126
3127         while (strv && strv[i])
3128                 nm_setting_connection_add_secondary (NM_SETTING_CONNECTION (setting), strv[i++]);
3129         g_strfreev (strv);
3130
3131         return TRUE;
3132 }
3133
3134 static gboolean
3135 _validate_and_remove_connection_secondary (NMSettingConnection *setting,
3136                                            const char *secondary_uuid,
3137                                            GError **error)
3138 {
3139         gboolean ret;
3140
3141         if (!nm_utils_is_uuid (secondary_uuid)) {
3142                 g_set_error (error, 1, 0,
3143                              _("the value '%s' is not a valid UUID"), secondary_uuid);
3144                 return FALSE;
3145         }
3146
3147         ret = nm_setting_connection_remove_secondary_by_value (setting, secondary_uuid);
3148         if (!ret)
3149                 g_set_error (error, 1, 0,
3150                              _("the property doesn't contain UUID '%s'"), secondary_uuid);
3151         return ret;
3152 }
3153 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_secondaries,
3154                                NM_SETTING_CONNECTION,
3155                                nm_setting_connection_get_num_secondaries,
3156                                nm_setting_connection_remove_secondary,
3157                                _validate_and_remove_connection_secondary)
3158
3159 static const char *
3160 nmc_property_connection_describe_secondaries (NMSetting *setting, const char *prop)
3161 {
3162         return _("Enter secondary connections that should be activated when this connection is\n"
3163                  "activated. Connections can be specified either by UUID or ID (name). nmcli\n"
3164                  "transparently translates names to UUIDs. Note that NetworkManager only supports\n"
3165                  "VPNs as secondary connections at the moment.\n"
3166                  "The items can be separated by commas or spaces.\n\n"
3167                  "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n");
3168 }
3169
3170 /* 'metered' */
3171 static char *
3172 nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type)
3173 {
3174         NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3175
3176         if (get_type == NMC_PROPERTY_GET_PARSABLE) {
3177                 switch (nm_setting_connection_get_metered (s_conn)) {
3178                 case NM_METERED_YES:
3179                         return g_strdup ("yes");
3180                 case NM_METERED_NO:
3181                         return g_strdup ("no");
3182                 case NM_METERED_UNKNOWN:
3183                 default:
3184                         return g_strdup ("unknown");
3185                 }
3186         }
3187         switch (nm_setting_connection_get_metered (s_conn)) {
3188         case NM_METERED_YES:
3189                 return g_strdup (_("yes"));
3190         case NM_METERED_NO:
3191                 return g_strdup (_("no"));
3192         case NM_METERED_UNKNOWN:
3193         default:
3194                 return g_strdup (_("unknown"));
3195         }
3196 }
3197
3198 static gboolean
3199 nmc_property_connection_set_metered (NMSetting *setting, const char *prop,
3200                                      const char *val, GError **error)
3201 {
3202         NMMetered metered;
3203         NMCTriStateValue ts_val;
3204
3205         if (!nmc_string_to_tristate (val, &ts_val, error))
3206                 return FALSE;
3207
3208         switch (ts_val) {
3209         case NMC_TRI_STATE_YES:
3210                 metered = NM_METERED_YES;
3211                 break;
3212         case NMC_TRI_STATE_NO:
3213                 metered = NM_METERED_NO;
3214                 break;
3215         case NMC_TRI_STATE_UNKNOWN:
3216                 metered = NM_METERED_UNKNOWN;
3217                 break;
3218         default:
3219                 g_assert_not_reached();
3220         }
3221
3222         g_object_set (setting, prop, metered, NULL);
3223         return TRUE;
3224 }
3225
3226 static const char *
3227 nmc_property_connection_describe_metered (NMSetting *setting, const char *prop)
3228 {
3229         return _("Enter a value which indicates whether the connection is subject to a data\n"
3230                  "quota, usage costs or other limitations. Accepted options are:\n"
3231                  "'true','yes','on' to set the connection as metered\n"
3232                  "'false','no','off' to set the connection as not metered\n"
3233                  "'unknown' to let NetworkManager choose a value using some heuristics\n");
3234 }
3235
3236 /* 'lldp' */
3237 static char *
3238 nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type)
3239 {
3240         NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting);
3241         NMSettingConnectionLldp lldp;
3242         char *tmp, *str;
3243
3244         lldp = nm_setting_connection_get_lldp (s_conn);
3245         tmp = nm_utils_enum_to_str (nm_setting_connection_lldp_get_type (), lldp);
3246         if (get_type == NMC_PROPERTY_GET_PARSABLE)
3247                 str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "default");
3248         else
3249                 str = g_strdup_printf ("%d (%s)", lldp, tmp && *tmp ? tmp : "default");
3250         g_free (tmp);
3251         return str;
3252 }
3253
3254 static gboolean
3255 nmc_property_connection_set_lldp (NMSetting *setting, const char *prop,
3256                                   const char *val, GError **error)
3257 {
3258         NMSettingConnectionLldp lldp;
3259         gboolean ret;
3260         long int t;
3261
3262         if (nmc_string_to_int_base (val, 0, TRUE,
3263                                    NM_SETTING_CONNECTION_LLDP_DEFAULT,
3264                                    NM_SETTING_CONNECTION_LLDP_ENABLE_RX,
3265                                    &t))
3266                 lldp = t;
3267         else {
3268                 ret = nm_utils_enum_from_str (nm_setting_connection_lldp_get_type (), val,
3269                                               (int *) &lldp, NULL);
3270
3271                 if (!ret) {
3272                         if (g_ascii_strcasecmp (val, "enable") == 0)
3273                                 lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX;
3274                         else {
3275                                 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
3276                                              val, "default,disable,enable-rx,enable");
3277                                 return FALSE;
3278                         }
3279                 }
3280         }
3281
3282         g_object_set (setting, prop, lldp, NULL);
3283         return TRUE;
3284 }
3285
3286 /* --- NM_SETTING_802_1X_SETTING_NAME property setter functions --- */
3287 #define DEFINE_SETTER_STR_LIST(def_func, set_func) \
3288         static gboolean \
3289         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3290         { \
3291                 char **strv = NULL; \
3292                 guint i = 0; \
3293                 \
3294                 g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \
3295                 \
3296                 strv = nmc_strsplit_set (val, " \t,", 0); \
3297                 while (strv && strv[i]) \
3298                         set_func (NM_SETTING_802_1X (setting), strv[i++]); \
3299                 g_strfreev (strv); \
3300                 return TRUE; \
3301         }
3302
3303 #define DEFINE_SETTER_CERT(def_func, set_func) \
3304         static gboolean \
3305         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3306         { \
3307                 char *val_strip = g_strstrip (g_strdup (val)); \
3308                 char *p = val_strip; \
3309                 gboolean success; \
3310                 \
3311                 if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
3312                         p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
3313                 \
3314                 success = set_func (NM_SETTING_802_1X (setting), \
3315                                     p, \
3316                                     NM_SETTING_802_1X_CK_SCHEME_PATH, \
3317                                     NULL, \
3318                                     error); \
3319                 g_free (val_strip); \
3320                 return success; \
3321         }
3322
3323 #define DEFINE_SETTER_PRIV_KEY(def_func, pwd_func, set_func) \
3324         static gboolean \
3325         def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \
3326         { \
3327                 char **strv = NULL; \
3328                 char *val_strip = g_strstrip (g_strdup (val)); \
3329                 char *p = val_strip; \
3330                 const char *path, *password; \
3331                 gboolean success; \
3332                 \
3333                 if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
3334                         p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
3335                 \
3336                 strv = nmc_strsplit_set (p, " \t,", 2); \
3337                 path = strv[0]; \
3338                 if (g_strv_length (strv) == 2) \
3339                         password = strv[1]; \
3340                 else \
3341                         password = pwd_func (NM_SETTING_802_1X (setting)); \
3342                 if (password) { \
3343                         char *tmp_pwd = g_strdup (password); \
3344                         success = set_func (NM_SETTING_802_1X (setting), \
3345                                             path, \
3346                                             tmp_pwd, \
3347                                             NM_SETTING_802_1X_CK_SCHEME_PATH, \
3348                                             NULL, \
3349                                             error); \
3350                         g_free (tmp_pwd); \
3351                 } else { \
3352                         success = FALSE; \
3353                         g_set_error_literal  (error, 1, 0, _("private key password not provided")); \
3354                 } \
3355                 g_free (val_strip); \
3356                 g_strfreev (strv); \
3357                 return success; \
3358         }
3359
3360 /* 'eap' */
3361 static const char *valid_eap[] = { "leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", NULL };
3362
3363 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_802_1X_eap,
3364                               NM_SETTING_802_1X,
3365                               nm_setting_802_1x_add_eap_method)
3366 static gboolean
3367 nmc_property_802_1X_set_eap (NMSetting *setting, const char *prop, const char *val, GError **error)
3368 {
3369         return check_and_add_802_1X_eap (setting, prop, val, valid_eap, error);
3370 }
3371
3372 static gboolean
3373 _validate_and_remove_eap_method (NMSetting8021x *setting,
3374                                  const char *eap,
3375                                  GError **error)
3376 {
3377         gboolean ret;
3378
3379         ret = nm_setting_802_1x_remove_eap_method_by_value(setting, eap);
3380         if (!ret)
3381                 g_set_error (error, 1, 0, _("the property doesn't contain EAP method '%s'"), eap);
3382         return ret;
3383 }
3384 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_eap,
3385                                NM_SETTING_802_1X,
3386                                nm_setting_802_1x_get_num_eap_methods,
3387                                nm_setting_802_1x_remove_eap_method,
3388                                _validate_and_remove_eap_method)
3389
3390 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_eap, valid_eap)
3391
3392 /* 'ca-cert' */
3393 DEFINE_SETTER_CERT (nmc_property_802_1X_set_ca_cert, nm_setting_802_1x_set_ca_cert)
3394
3395 static const char *
3396 nmc_property_802_1X_describe_ca_cert (NMSetting *setting, const char *prop)
3397 {
3398         return _("Enter file path to CA certificate (optionally prefixed with file://).\n"
3399                  "  [file://]<file path>\n"
3400                  "Note that nmcli does not support specifying certificates as raw blob data.\n"
3401                  "Example: /home/cimrman/cacert.crt\n");
3402 }
3403
3404 /* 'altsubject-matches' */
3405 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_altsubject_matches, nm_setting_802_1x_add_altsubject_match)
3406
3407 static gboolean
3408 _validate_and_remove_altsubject_match (NMSetting8021x *setting,
3409                                        const char *altsubject_match,
3410                                        GError **error)
3411 {
3412         gboolean ret;
3413
3414         ret = nm_setting_802_1x_remove_altsubject_match_by_value (setting, altsubject_match);
3415         if (!ret)
3416                 g_set_error (error, 1, 0,
3417                              _("the property doesn't contain alternative subject match '%s'"),
3418                              altsubject_match);
3419         return ret;
3420 }
3421 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_altsubject_matches,
3422                                NM_SETTING_802_1X,
3423                                nm_setting_802_1x_get_num_altsubject_matches,
3424                                nm_setting_802_1x_remove_altsubject_match,
3425                                _validate_and_remove_altsubject_match)
3426
3427 /* 'client-cert' */
3428 DEFINE_SETTER_CERT (nmc_property_802_1X_set_client_cert, nm_setting_802_1x_set_client_cert)
3429
3430 static const char *
3431 nmc_property_802_1X_describe_client_cert (NMSetting *setting, const char *prop)
3432 {
3433         return _("Enter file path to client certificate (optionally prefixed with file://).\n"
3434                  "  [file://]<file path>\n"
3435                  "Note that nmcli does not support specifying certificates as raw blob data.\n"
3436                  "Example: /home/cimrman/jara.crt\n");
3437 }
3438
3439 /* 'phase2-ca-cert' */
3440 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert)
3441
3442 static const char *
3443 nmc_property_802_1X_describe_phase2_ca_cert (NMSetting *setting, const char *prop)
3444 {
3445         return _("Enter file path to CA certificate for inner authentication (optionally prefixed\n"
3446                  "with file://).\n"
3447                  "  [file://]<file path>\n"
3448                  "Note that nmcli does not support specifying certificates as raw blob data.\n"
3449                  "Example: /home/cimrman/ca-zweite-phase.crt\n");
3450 }
3451
3452 /* 'phase2-altsubject-matches' */
3453 DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_phase2_altsubject_matches, nm_setting_802_1x_add_phase2_altsubject_match)
3454
3455 static gboolean
3456 _validate_and_remove_phase2_altsubject_match (NMSetting8021x *setting,
3457                                               const char *phase2_altsubject_match,
3458                                               GError **error)
3459 {
3460         gboolean ret;
3461
3462         ret = nm_setting_802_1x_remove_phase2_altsubject_match_by_value (setting, phase2_altsubject_match);
3463         if (!ret)
3464                 g_set_error (error, 1, 0,
3465                              _("the property doesn't contain \"phase2\" alternative subject match '%s'"),
3466                              phase2_altsubject_match);
3467         return ret;
3468 }
3469 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_phase2_altsubject_matches,
3470                                NM_SETTING_802_1X,
3471                                nm_setting_802_1x_get_num_phase2_altsubject_matches,
3472                                nm_setting_802_1x_remove_phase2_altsubject_match,
3473                                _validate_and_remove_phase2_altsubject_match)
3474
3475 /* 'phase2-client-cert' */
3476 DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert)
3477
3478 static const char *
3479 nmc_property_802_1X_describe_phase2_client_cert (NMSetting *setting, const char *prop)
3480 {
3481         return _("Enter file path to client certificate for inner authentication (optionally prefixed\n"
3482                  "with file://).\n"
3483                  "  [file://]<file path>\n"
3484                  "Note that nmcli does not support specifying certificates as raw blob data.\n"
3485                  "Example: /home/cimrman/jara-zweite-phase.crt\n");
3486 }
3487
3488 /* 'private-key' */
3489 DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_private_key,
3490                         nm_setting_802_1x_get_private_key_password,
3491                         nm_setting_802_1x_set_private_key)
3492
3493 /* 'phase2-private-key' */
3494 DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_phase2_private_key,
3495                         nm_setting_802_1x_get_phase2_private_key_password,
3496                         nm_setting_802_1x_set_phase2_private_key)
3497
3498 static const char *
3499 nmc_property_802_1X_describe_private_key (NMSetting *setting, const char *prop)
3500 {
3501         return _("Enter path to a private key and the key password (if not set yet):\n"
3502                  "  [file://]<file path> [<password>]\n"
3503                  "Note that nmcli does not support specifying private key as raw blob data.\n"
3504                  "Example: /home/cimrman/jara-priv-key Dardanely\n");
3505 }
3506
3507 /* 'phase1-peapver' */
3508 static const char *_802_1X_valid_phase1_peapvers[] = { "0", "1", NULL };
3509
3510 static gboolean
3511 nmc_property_802_1X_set_phase1_peapver (NMSetting *setting, const char *prop, const char *val, GError **error)
3512 {
3513         return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peapvers, error);
3514 }
3515
3516 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peapver, _802_1X_valid_phase1_peapvers)
3517
3518 /* 'phase1-peaplabel' */
3519 static const char *_802_1X_valid_phase1_peaplabels[] = { "0", "1", NULL };
3520
3521 static gboolean
3522 nmc_property_802_1X_set_phase1_peaplabel (NMSetting *setting, const char *prop, const char *val, GError **error)
3523 {
3524         return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peaplabels, error);
3525 }
3526
3527 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peaplabel, _802_1X_valid_phase1_peaplabels)
3528
3529 /* 'phase1-fast-provisioning' */
3530 static const char *_802_1X_valid_phase1_fast_provisionings[] = { "0", "1", "2", "3", NULL };
3531
3532 static gboolean
3533 nmc_property_802_1X_set_phase1_fast_provisioning (NMSetting *setting, const char *prop, const char *val, GError **error)
3534 {
3535         return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_fast_provisionings, error);
3536 }
3537
3538 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_fast_provisioning, _802_1X_valid_phase1_fast_provisionings)
3539
3540 /* 'phase2-auth' */
3541 static const char *_802_1X_valid_phase2_auths[] =
3542         { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL };
3543
3544 static gboolean
3545 nmc_property_802_1X_set_phase2_auth (NMSetting *setting, const char *prop, const char *val, GError **error)
3546 {
3547         return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_auths, error);
3548 }
3549
3550 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_auth, _802_1X_valid_phase2_auths)
3551
3552 /* 'phase2-autheap' */
3553 static const char *_802_1X_valid_phase2_autheaps[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL };
3554 static gboolean
3555 nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, const char *val, GError **error)
3556 {
3557         return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_autheaps, error);
3558 }
3559
3560 DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_valid_phase2_autheaps)
3561
3562 /* 'password-raw' */
3563 static gboolean
3564 nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error)
3565 {
3566         return nmc_property_set_byte_array (setting, prop, val, error);
3567 }
3568
3569 static const char *
3570 nmc_property_802_1X_describe_password_raw (NMSetting *setting, const char *prop)
3571 {
3572         return _("Enter bytes as a list of hexadecimal values.\n"
3573                  "Two formats are accepted:\n"
3574                  "(a) a string of hexadecimal digits, where each two digits represent one byte\n"
3575                  "(b) space-separated list of bytes written as hexadecimal digits "
3576                  "(with optional 0x/0X prefix, and optional leading 0).\n\n"
3577                  "Examples: ab0455a6ea3a74C2\n"
3578                  "          ab 4 55 0xa6 ea 3a 74 C2\n");
3579 }
3580
3581 /* --- NM_SETTING_ADSL_SETTING_NAME property setter functions --- */
3582 /* 'protocol' */
3583 static const char *adsl_valid_protocols[] = {
3584         NM_SETTING_ADSL_PROTOCOL_PPPOA,
3585         NM_SETTING_ADSL_PROTOCOL_PPPOE,
3586         NM_SETTING_ADSL_PROTOCOL_IPOATM,
3587         NULL
3588 };
3589
3590 static gboolean
3591 nmc_property_adsl_set_protocol (NMSetting *setting, const char *prop, const char *val, GError **error)
3592 {
3593         return check_and_set_string (setting, prop, val, adsl_valid_protocols, error);
3594 }
3595
3596 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_protocol, adsl_valid_protocols)
3597
3598 /* 'encapsulation' */
3599 static const char *adsl_valid_encapsulations[] = {
3600         NM_SETTING_ADSL_ENCAPSULATION_VCMUX,
3601         NM_SETTING_ADSL_ENCAPSULATION_LLC,
3602         NULL
3603 };
3604
3605 static gboolean
3606 nmc_property_adsl_set_encapsulation (NMSetting *setting, const char *prop, const char *val, GError **error)
3607 {
3608         return check_and_set_string (setting, prop, val, adsl_valid_encapsulations, error);
3609 }
3610
3611 DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_encapsulation, adsl_valid_encapsulations)
3612
3613 /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property setter functions --- */
3614 /* 'type' */
3615 static gboolean
3616 nmc_property_bluetooth_set_type (NMSetting *setting, const char *prop, const char *val, GError **error)
3617 {
3618         const char *types[] = {
3619             NM_SETTING_BLUETOOTH_TYPE_DUN,
3620             NM_SETTING_BLUETOOTH_TYPE_PANU,
3621             NULL };
3622
3623         return check_and_set_string (setting, prop, val, types, error);
3624 }
3625
3626 /* --- NM_SETTING_BOND_SETTING_NAME property setter functions --- */
3627 /* 'options' */
3628 /*  example: miimon=100,mode=balance-rr, updelay=5 */
3629 static gboolean
3630 _validate_and_remove_bond_option (NMSettingBond *setting, const char *option)
3631 {
3632         const char *opt;
3633         const char **valid_options;
3634
3635         valid_options = nm_setting_bond_get_valid_options (setting);
3636         opt = nmc_string_is_valid (option, valid_options, NULL);
3637
3638         if (opt)
3639                 return nm_setting_bond_remove_option (setting, opt);
3640         else
3641                 return FALSE;
3642 }
3643
3644 /* Validate bonding 'options' values */
3645 static const char *
3646 _validate_bond_option_value (const char *option, const char *value, GError **error)
3647 {
3648         if (!g_strcmp0 (option, NM_SETTING_BOND_OPTION_MODE))
3649                 return nmc_bond_validate_mode (value, error);
3650
3651         return value;
3652 }
3653
3654 DEFINE_SETTER_OPTIONS (nmc_property_bond_set_options,
3655                        NM_SETTING_BOND,
3656                        NMSettingBond,
3657                        nm_setting_bond_add_option,
3658                        nm_setting_bond_get_valid_options,
3659                        _validate_bond_option_value)
3660 DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options,
3661                        NM_SETTING_BOND,
3662                        _validate_and_remove_bond_option)
3663
3664 static const char *
3665 nmc_property_bond_describe_options (NMSetting *setting, const char *prop)
3666 {
3667         static char *desc = NULL;
3668         const char **valid_options;
3669         char *options_str;
3670
3671         if (G_UNLIKELY (desc == NULL)) {
3672                 valid_options = nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3673                 options_str = g_strjoinv (", ", (char **) valid_options);
3674
3675                 desc = g_strdup_printf (_("Enter a list of bonding options formatted as:\n"
3676                                           "  option = <value>, option = <value>,... \n"
3677                                           "Valid options are: %s\n"
3678                                           "'mode' can be provided as a name or a number:\n"
3679                                           "balance-rr    = 0\n"
3680                                           "active-backup = 1\n"
3681                                           "balance-xor   = 2\n"
3682                                           "broadcast     = 3\n"
3683                                           "802.3ad       = 4\n"
3684                                           "balance-tlb   = 5\n"
3685                                           "balance-alb   = 6\n\n"
3686                                           "Example: mode=2,miimon=120\n"), options_str);
3687                 g_free (options_str);
3688         }
3689         return desc;
3690 }
3691
3692 static const char **
3693 nmc_property_bond_allowed_options (NMSetting *setting, const char *prop)
3694 {
3695         return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting));
3696 }
3697
3698 /* --- NM_SETTING_INFINIBAND_SETTING_NAME property setter functions --- */
3699 /* 'mac-address' */
3700 static gboolean
3701 nmc_property_ib_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
3702 {
3703         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3704
3705         if (!nm_utils_hwaddr_valid (val, INFINIBAND_ALEN)) {
3706                 g_set_error (error, 1, 0, _("'%s' is not a valid InfiniBand MAC"), val);
3707                 return FALSE;
3708         }
3709
3710         g_object_set (setting, prop, val, NULL);
3711         return TRUE;
3712 }
3713
3714 /* 'transport-mode' */
3715 static const char *ib_valid_transport_modes[] = { "datagram", "connected", NULL };
3716
3717 static gboolean
3718 nmc_property_ib_set_transport_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
3719 {
3720         return check_and_set_string (setting, prop, val, ib_valid_transport_modes, error);
3721 }
3722
3723 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ib_allowed_transport_mode, ib_valid_transport_modes)
3724
3725 /* 'p-key' */
3726 static gboolean
3727 nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val, GError **error)
3728 {
3729         gboolean p_key_valid = FALSE;
3730         long p_key_int;
3731
3732         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3733
3734         if (!strncasecmp (val, "0x", 2))
3735                 p_key_valid = nmc_string_to_int_base (val + 2, 16, TRUE, 0, G_MAXUINT16, &p_key_int);
3736         else
3737                 p_key_valid = nmc_string_to_int (val, TRUE, -1, G_MAXUINT16, &p_key_int);
3738
3739         if (!p_key_valid) {
3740                 if (strcmp (val, "default") == 0)
3741                         p_key_int = -1;
3742                 else {
3743                         g_set_error (error, 1, 0, _("'%s' is not a valid IBoIP P_Key"), val);
3744                         return FALSE;
3745                 }
3746         }
3747         g_object_set (setting, prop, (gint) p_key_int, NULL);
3748         return TRUE;
3749 }
3750
3751 /* --- IP4 / IP6 shared functions --- */
3752 static NMIPAddress *
3753 _parse_ip_address (int family, const char *address, GError **error)
3754 {
3755         char *value = g_strdup (address);
3756         NMIPAddress *ipaddr;
3757
3758         ipaddr = nmc_parse_and_build_address (family, g_strstrip (value), error);
3759         g_free (value);
3760         return ipaddr;
3761 }
3762
3763 static NMIPRoute *
3764 _parse_ip_route (int family, const char *route, GError **error)
3765 {
3766         char *value = g_strdup (route);
3767         char **routev;
3768         guint len;
3769         NMIPRoute *iproute = NULL;
3770
3771         routev = nmc_strsplit_set (g_strstrip (value), " \t", 0);
3772         len = g_strv_length (routev);
3773         if (len < 1 || len > 3) {
3774                 g_set_error (error, 1, 0, _("'%s' is not valid (the format is: ip[/prefix] [next-hop] [metric])"),
3775                              route);
3776                 goto finish;
3777         }
3778         iproute = nmc_parse_and_build_route (family, routev[0], routev[1], len >= 2 ? routev[2] : NULL, error);
3779
3780 finish:
3781         g_free (value);
3782         g_strfreev (routev);
3783         return iproute;
3784 }
3785
3786 /* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property setter functions --- */
3787 /* 'method' */
3788 static const char *ipv4_valid_methods[] = {
3789         NM_SETTING_IP4_CONFIG_METHOD_AUTO,
3790         NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
3791         NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
3792         NM_SETTING_IP4_CONFIG_METHOD_SHARED,
3793         NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
3794         NULL
3795 };
3796
3797 static gboolean
3798 nmc_property_ipv4_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
3799 {
3800         /* Silently accept "static" and convert to "manual" */
3801         if (val && strlen (val) > 1 && matches (val, "static") == 0)
3802                 val = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
3803
3804         return check_and_set_string (setting, prop, val, ipv4_valid_methods, error);
3805 }
3806
3807 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods)
3808
3809 /* 'dns' */
3810 static gboolean
3811 nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
3812 {
3813         char **strv = NULL, **iter, *addr;
3814         guint32 ip4_addr;
3815
3816         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3817
3818         strv = nmc_strsplit_set (val, " \t,", 0);
3819         for (iter = strv; iter && *iter; iter++) {
3820                 addr = g_strstrip (*iter);
3821                 if (inet_pton (AF_INET, addr, &ip4_addr) < 1) {
3822                         g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), addr);
3823                         g_strfreev (strv);
3824                         return FALSE;
3825                 }
3826                 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
3827         }
3828         g_strfreev (strv);
3829         return TRUE;
3830 }
3831
3832 static gboolean
3833 _validate_and_remove_ipv4_dns (NMSettingIPConfig *setting,
3834                                const char *dns,
3835                                GError **error)
3836 {
3837         guint32 ip4_addr;
3838         gboolean ret;
3839
3840         if (inet_pton (AF_INET, dns, &ip4_addr) < 1) {
3841                 g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), dns);
3842                 return FALSE;
3843         }
3844
3845         ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
3846         if (!ret)
3847                 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
3848         return ret;
3849 }
3850 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns,
3851                                NM_SETTING_IP_CONFIG,
3852                                nm_setting_ip_config_get_num_dns,
3853                                nm_setting_ip_config_remove_dns,
3854                                _validate_and_remove_ipv4_dns)
3855
3856 static const char *
3857 nmc_property_ipv4_describe_dns (NMSetting *setting, const char *prop)
3858 {
3859         return _("Enter a list of IPv4 addresses of DNS servers.\n\n"
3860                  "Example: 8.8.8.8, 8.8.4.4\n");
3861 }
3862
3863 /* 'dns-search' */
3864 static gboolean
3865 nmc_property_ipv4_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
3866 {
3867         char **strv = NULL;
3868         guint i = 0;
3869
3870         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3871
3872         strv = nmc_strsplit_set (val, " \t,", 0);
3873         if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
3874                 g_strfreev (strv);
3875                 return FALSE;
3876         }
3877
3878         while (strv && strv[i])
3879                 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3880         g_strfreev (strv);
3881
3882         return TRUE;
3883 }
3884
3885 static gboolean
3886 _validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting,
3887                                       const char *dns_search,
3888                                       GError **error)
3889 {
3890         gboolean ret;
3891
3892         ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
3893         if (!ret)
3894                 g_set_error (error, 1, 0,
3895                              _("the property doesn't contain DNS search domain '%s'"),
3896                              dns_search);
3897         return ret;
3898 }
3899 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_search,
3900                                NM_SETTING_IP_CONFIG,
3901                                nm_setting_ip_config_get_num_dns_searches,
3902                                nm_setting_ip_config_remove_dns_search,
3903                                _validate_and_remove_ipv4_dns_search)
3904
3905 /* 'dns-options' */
3906 static gboolean
3907 nmc_property_ipv4_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
3908 {
3909         char **strv = NULL;
3910         guint i = 0;
3911
3912         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3913
3914         nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
3915         strv = nmc_strsplit_set (val, " \t,", 0);
3916         while (strv && strv[i])
3917                 nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]);
3918         g_strfreev (strv);
3919
3920         return TRUE;
3921 }
3922
3923 static gboolean
3924 _validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting,
3925                                       const char *dns_option,
3926                                       GError **error)
3927 {
3928         gboolean ret;
3929
3930         ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
3931         if (!ret)
3932                 g_set_error (error, 1, 0,
3933                              _("the property doesn't contain DNS option '%s'"),
3934                              dns_option);
3935         return ret;
3936 }
3937 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_option,
3938                                NM_SETTING_IP_CONFIG,
3939                                nm_setting_ip_config_get_num_dns_options,
3940                                nm_setting_ip_config_remove_dns_option,
3941                                _validate_and_remove_ipv4_dns_option)
3942
3943 /* 'addresses' */
3944 static NMIPAddress *
3945 _parse_ipv4_address (const char *address, GError **error)
3946 {
3947         return _parse_ip_address (AF_INET, address, error);
3948 }
3949
3950 static gboolean
3951 nmc_property_ipv4_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
3952 {
3953         char **strv = NULL, **iter;
3954         NMIPAddress *ip4addr;
3955
3956         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
3957
3958         strv = nmc_strsplit_set (val, ",", 0);
3959         for (iter = strv; iter && *iter; iter++) {
3960                 ip4addr = _parse_ipv4_address (*iter, error);
3961                 if (!ip4addr) {
3962                         g_strfreev (strv);
3963                         return FALSE;
3964                 }
3965                 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip4addr);
3966                 nm_ip_address_unref (ip4addr);
3967         }
3968         g_strfreev (strv);
3969         return TRUE;
3970 }
3971
3972 static gboolean
3973 _validate_and_remove_ipv4_address (NMSettingIPConfig *setting,
3974                                    const char *address,
3975                                    GError **error)
3976 {
3977         NMIPAddress *ip4addr;
3978         gboolean ret;
3979
3980         ip4addr = _parse_ipv4_address (address, error);
3981         if (!ip4addr)
3982                 return FALSE;
3983
3984         ret = nm_setting_ip_config_remove_address_by_value (setting, ip4addr);
3985         if (!ret)
3986                 g_set_error (error, 1, 0,
3987                              _("the property doesn't contain IP address '%s'"), address);
3988         nm_ip_address_unref (ip4addr);
3989         return ret;
3990 }
3991 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_addresses,
3992                                NM_SETTING_IP_CONFIG,
3993                                nm_setting_ip_config_get_num_addresses,
3994                                nm_setting_ip_config_remove_address,
3995                                _validate_and_remove_ipv4_address)
3996
3997 static const char *
3998 nmc_property_ipv4_describe_addresses (NMSetting *setting, const char *prop)
3999 {
4000         return _("Enter a list of IPv4 addresses formatted as:\n"
4001                  "  ip[/prefix], ip[/prefix],...\n"
4002                  "Missing prefix is regarded as prefix of 32.\n\n"
4003                  "Example: 192.168.1.5/24, 10.0.0.11/24\n");
4004 }
4005
4006 /* 'gateway' */
4007 static gboolean
4008 nmc_property_ipv4_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4009 {
4010         NMIPAddress *ip4addr;
4011
4012         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4013
4014         if (strchr (val, '/')) {
4015                 g_set_error (error, 1, 0,
4016                              _("invalid gateway address '%s'"), val);
4017                 return FALSE;
4018         }
4019         ip4addr = _parse_ipv4_address (val, error);
4020         if (!ip4addr)
4021                 return FALSE;
4022
4023         g_object_set (setting, prop, val, NULL);
4024         nm_ip_address_unref (ip4addr);
4025         return TRUE;
4026 }
4027
4028 /* 'routes' */
4029 static NMIPRoute *
4030 _parse_ipv4_route (const char *route, GError **error)
4031 {
4032         return _parse_ip_route (AF_INET, route, error);
4033 }
4034
4035 static gboolean
4036 nmc_property_ipv4_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4037 {
4038         char **strv = NULL, **iter;
4039         NMIPRoute *ip4route;
4040
4041         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4042
4043         strv = nmc_strsplit_set (val, ",", 0);
4044         for (iter = strv; iter && *iter; iter++) {
4045                 ip4route = _parse_ipv4_route (*iter, error);
4046                 if (!ip4route) {
4047                         g_strfreev (strv);
4048                         return FALSE;
4049                 }
4050                 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip4route);
4051                 nm_ip_route_unref (ip4route);
4052         }
4053         g_strfreev (strv);
4054         return TRUE;
4055 }
4056
4057 static gboolean
4058 _validate_and_remove_ipv4_route (NMSettingIPConfig *setting,
4059                                  const char *route,
4060                                  GError **error)
4061 {
4062         NMIPRoute *ip4route;
4063         gboolean ret;
4064
4065         ip4route = _parse_ipv4_route (route, error);
4066         if (!ip4route)
4067                 return FALSE;
4068
4069         ret = nm_setting_ip_config_remove_route_by_value (setting, ip4route);
4070         if (!ret)
4071                 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4072         nm_ip_route_unref (ip4route);
4073         return ret;
4074 }
4075 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_routes,
4076                                NM_SETTING_IP_CONFIG,
4077                                nm_setting_ip_config_get_num_routes,
4078                                nm_setting_ip_config_remove_route,
4079                                _validate_and_remove_ipv4_route)
4080
4081 static const char *
4082 nmc_property_ipv4_describe_routes (NMSetting *setting, const char *prop)
4083 {
4084         return _("Enter a list of IPv4 routes formatted as:\n"
4085                  "  ip[/prefix] [next-hop] [metric],...\n\n"
4086                  "Missing prefix is regarded as a prefix of 32.\n"
4087                  "Missing next-hop is regarded as 0.0.0.0.\n"
4088                  "Missing metric means default (NM/kernel will set a default value).\n\n"
4089                  "Examples: 192.168.2.0/24 192.168.2.1 3, 10.1.0.0/16 10.0.0.254\n"
4090                  "          10.1.2.0/24\n");
4091 }
4092
4093 /* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property setter functions --- */
4094 /* 'method' */
4095 static const char *ipv6_valid_methods[] = {
4096         NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
4097         NM_SETTING_IP6_CONFIG_METHOD_AUTO,
4098         NM_SETTING_IP6_CONFIG_METHOD_DHCP,
4099         NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
4100         NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
4101         NM_SETTING_IP6_CONFIG_METHOD_SHARED,
4102         NULL
4103 };
4104
4105 static gboolean
4106 nmc_property_ipv6_set_method (NMSetting *setting, const char *prop, const char *val, GError **error)
4107 {
4108         /* Silently accept "static" and convert to "manual" */
4109         if (val && strlen (val) > 1 && matches (val, "static") == 0)
4110                 val = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
4111
4112         return check_and_set_string (setting, prop, val, ipv6_valid_methods, error);
4113 }
4114
4115 DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods)
4116
4117 /* 'dns' */
4118 static gboolean
4119 nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
4120 {
4121         char **strv = NULL, **iter, *addr;
4122         struct in6_addr ip6_addr;
4123
4124         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4125
4126         strv = nmc_strsplit_set (val, " \t,", 0);
4127         for (iter = strv; iter && *iter; iter++) {
4128                 addr = g_strstrip (*iter);
4129                 if (inet_pton (AF_INET6, addr, &ip6_addr) < 1) {
4130                         g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), addr);
4131                         g_strfreev (strv);
4132                         return FALSE;
4133                 }
4134                 nm_setting_ip_config_add_dns (NM_SETTING_IP_CONFIG (setting), addr);
4135         }
4136         g_strfreev (strv);
4137         return TRUE;
4138 }
4139
4140 static gboolean
4141 _validate_and_remove_ipv6_dns (NMSettingIPConfig *setting,
4142                                const char *dns,
4143                                GError **error)
4144 {
4145         struct in6_addr ip6_addr;
4146         gboolean ret;
4147
4148         if (inet_pton (AF_INET6, dns, &ip6_addr) < 1) {
4149                 g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), dns);
4150                 return FALSE;
4151         }
4152
4153         ret = nm_setting_ip_config_remove_dns_by_value (setting, dns);
4154         if (!ret)
4155                 g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
4156         return ret;
4157 }
4158 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns,
4159                                NM_SETTING_IP_CONFIG,
4160                                nm_setting_ip_config_get_num_dns,
4161                                nm_setting_ip_config_remove_dns,
4162                                _validate_and_remove_ipv6_dns)
4163
4164 static const char *
4165 nmc_property_ipv6_describe_dns (NMSetting *setting, const char *prop)
4166 {
4167         return _("Enter a list of IPv6 addresses of DNS servers.  If the IPv6 "
4168                  "configuration method is 'auto' these DNS servers are appended "
4169                  "to those (if any) returned by automatic configuration.  DNS "
4170                  "servers cannot be used with the 'shared' or 'link-local' IPv6 "
4171                  "configuration methods, as there is no upstream network. In "
4172                  "all other IPv6 configuration methods, these DNS "
4173                  "servers are used as the only DNS servers for this connection.\n\n"
4174                  "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n");
4175 }
4176
4177 /* 'dns-search' */
4178 static gboolean
4179 nmc_property_ipv6_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error)
4180 {
4181         char **strv = NULL;
4182         guint i = 0;
4183
4184         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4185
4186         strv = nmc_strsplit_set (val, " \t,", 0);
4187         if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) {
4188                 g_strfreev (strv);
4189                 return FALSE;
4190         }
4191
4192         while (strv && strv[i])
4193                 nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4194         g_strfreev (strv);
4195
4196         return TRUE;
4197 }
4198
4199 static gboolean
4200 _validate_and_remove_ipv6_dns_search (NMSettingIPConfig *setting,
4201                                       const char *dns_search,
4202                                       GError **error)
4203 {
4204         gboolean ret;
4205
4206         ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
4207         if (!ret)
4208                 g_set_error (error, 1, 0,
4209                              _("the property doesn't contain DNS search domain '%s'"),
4210                              dns_search);
4211         return ret;
4212 }
4213 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_search,
4214                                NM_SETTING_IP_CONFIG,
4215                                nm_setting_ip_config_get_num_dns_searches,
4216                                nm_setting_ip_config_remove_dns_search,
4217                                _validate_and_remove_ipv6_dns_search)
4218
4219 /* 'dns-options' */
4220 static gboolean
4221 nmc_property_ipv6_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error)
4222 {
4223         char **strv = NULL;
4224         guint i = 0;
4225
4226         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4227
4228         nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
4229         strv = nmc_strsplit_set (val, " \t,", 0);
4230         while (strv && strv[i])
4231                 nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]);
4232         g_strfreev (strv);
4233
4234         return TRUE;
4235 }
4236
4237 static gboolean
4238 _validate_and_remove_ipv6_dns_option (NMSettingIPConfig *setting,
4239                                       const char *dns_option,
4240                                       GError **error)
4241 {
4242         gboolean ret;
4243
4244         ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
4245         if (!ret)
4246                 g_set_error (error, 1, 0,
4247                              _("the property doesn't contain DNS option '%s'"),
4248                              dns_option);
4249         return ret;
4250 }
4251 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_option,
4252                                NM_SETTING_IP_CONFIG,
4253                                nm_setting_ip_config_get_num_dns_options,
4254                                nm_setting_ip_config_remove_dns_option,
4255                                _validate_and_remove_ipv6_dns_option)
4256
4257 /* 'addresses' */
4258 static NMIPAddress *
4259 _parse_ipv6_address (const char *address, GError **error)
4260 {
4261         return _parse_ip_address (AF_INET6, address, error);
4262 }
4263
4264 static gboolean
4265 nmc_property_ipv6_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error)
4266 {
4267         char **strv = NULL, **iter;
4268         NMIPAddress *ip6addr;
4269
4270         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4271
4272         strv = nmc_strsplit_set (val, ",", 0);
4273         for (iter = strv; iter && *iter; iter++) {
4274                 ip6addr = _parse_ipv6_address (*iter, error);
4275                 if (!ip6addr) {
4276                         g_strfreev (strv);
4277                         return FALSE;
4278                 }
4279                 nm_setting_ip_config_add_address (NM_SETTING_IP_CONFIG (setting), ip6addr);
4280                 nm_ip_address_unref (ip6addr);
4281         }
4282         g_strfreev (strv);
4283         return TRUE;
4284 }
4285
4286 static gboolean
4287 _validate_and_remove_ipv6_address (NMSettingIPConfig *setting,
4288                                    const char *address,
4289                                    GError **error)
4290 {
4291         NMIPAddress *ip6addr;
4292         gboolean ret;
4293
4294         ip6addr = _parse_ipv6_address (address, error);
4295         if (!ip6addr)
4296                 return FALSE;
4297
4298         ret = nm_setting_ip_config_remove_address_by_value (setting, ip6addr);
4299         if (!ret)
4300                 g_set_error (error, 1, 0, _("the property doesn't contain IP address '%s'"), address);
4301         nm_ip_address_unref (ip6addr);
4302         return ret;
4303 }
4304 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_addresses,
4305                                NM_SETTING_IP_CONFIG,
4306                                nm_setting_ip_config_get_num_addresses,
4307                                nm_setting_ip_config_remove_address,
4308                                _validate_and_remove_ipv6_address)
4309
4310 static const char *
4311 nmc_property_ipv6_describe_addresses (NMSetting *setting, const char *prop)
4312 {
4313         return _("Enter a list of IPv6 addresses formatted as:\n"
4314                  "  ip[/prefix], ip[/prefix],...\n"
4315                  "Missing prefix is regarded as prefix of 128.\n\n"
4316                  "Example: 2607:f0d0:1002:51::4/64, 1050:0:0:0:5:600:300c:326b\n");
4317 }
4318
4319 /* 'gateway' */
4320 static gboolean
4321 nmc_property_ipv6_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error)
4322 {
4323         NMIPAddress *ip6addr;
4324
4325         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4326
4327         if (strchr (val, '/')) {
4328                 g_set_error (error, 1, 0,
4329                              _("invalid gateway address '%s'"), val);
4330                 return FALSE;
4331         }
4332         ip6addr = _parse_ipv6_address (val, error);
4333         if (!ip6addr)
4334                 return FALSE;
4335
4336         g_object_set (setting, prop, val, NULL);
4337         nm_ip_address_unref (ip6addr);
4338         return TRUE;
4339 }
4340
4341 /* 'routes' */
4342 static NMIPRoute *
4343 _parse_ipv6_route (const char *route, GError **error)
4344 {
4345         return _parse_ip_route (AF_INET6, route, error);
4346 }
4347
4348 static gboolean
4349 nmc_property_ipv6_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error)
4350 {
4351         char **strv = NULL, **iter;
4352         NMIPRoute *ip6route;
4353
4354         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4355
4356         strv = nmc_strsplit_set (val, ",", 0);
4357         for (iter = strv; iter && *iter; iter++) {
4358                 ip6route = _parse_ipv6_route (*iter, error);
4359                 if (!ip6route) {
4360                         g_strfreev (strv);
4361                         return FALSE;
4362                 }
4363                 nm_setting_ip_config_add_route (NM_SETTING_IP_CONFIG (setting), ip6route);
4364                 nm_ip_route_unref (ip6route);
4365         }
4366         g_strfreev (strv);
4367         return TRUE;
4368 }
4369
4370 static gboolean
4371 _validate_and_remove_ipv6_route (NMSettingIPConfig *setting,
4372                                  const char *route,
4373                                  GError **error)
4374 {
4375         NMIPRoute *ip6route;
4376         gboolean ret;
4377
4378         ip6route = _parse_ipv6_route (route, error);
4379         if (!ip6route)
4380                 return FALSE;
4381
4382         ret = nm_setting_ip_config_remove_route_by_value (setting, ip6route);
4383         if (!ret)
4384                 g_set_error (error, 1, 0, _("the property doesn't contain route '%s'"), route);
4385         nm_ip_route_unref (ip6route);
4386         return ret;
4387 }
4388 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_routes,
4389                                NM_SETTING_IP_CONFIG,
4390                                nm_setting_ip_config_get_num_routes,
4391                                nm_setting_ip_config_remove_route,
4392                                _validate_and_remove_ipv6_route)
4393
4394 static const char *
4395 nmc_property_ipv6_describe_routes (NMSetting *setting, const char *prop)
4396 {
4397         return _("Enter a list of IPv6 routes formatted as:\n"
4398                  "  ip[/prefix] [next-hop] [metric],...\n\n"
4399                  "Missing prefix is regarded as a prefix of 128.\n"
4400                  "Missing next-hop is regarded as \"::\".\n"
4401                  "Missing metric means default (NM/kernel will set a default value).\n\n"
4402                  "Examples: 2001:db8:beef:2::/64 2001:db8:beef::2, 2001:db8:beef:3::/64 2001:db8:beef::3 2\n"
4403                  "          abbe::/64 55\n");
4404 }
4405
4406 static gboolean
4407 nmc_property_ipv6_set_ip6_privacy (NMSetting *setting, const char *prop, const char *val, GError **error)
4408 {
4409         unsigned long val_int;
4410
4411         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4412
4413         if (!nmc_string_to_uint (val, FALSE, 0, 0, &val_int)) {
4414                 g_set_error (error, 1, 0, _("'%s' is not a number"), val);
4415                 return FALSE;
4416         }
4417
4418         if (   val_int != NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED
4419             && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR
4420             && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) {
4421                 g_set_error (error, 1, 0, _("'%s' is not valid; use 0, 1, or 2"), val);
4422                 return FALSE;
4423         }
4424
4425         g_object_set (setting, prop, val_int, NULL);
4426         return TRUE;
4427 }
4428
4429 /* 'addr_gen_mode' */
4430 static char *
4431 nmc_property_ipv6_get_addr_gen_mode (NMSetting *setting, NmcPropertyGetType get_type)
4432 {
4433         NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
4434         NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4435
4436         addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode (s_ip6);
4437         return nm_utils_enum_to_str (nm_setting_ip6_config_addr_gen_mode_get_type (), addr_gen_mode);
4438 }
4439
4440
4441 static gboolean
4442 nmc_property_ipv6_set_addr_gen_mode (NMSetting *setting, const char *prop,
4443                                      const char *val, GError **error)
4444 {
4445         NMSettingIP6ConfigAddrGenMode addr_gen_mode;
4446
4447         if (!nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), val,
4448                                      (int *) &addr_gen_mode, NULL)) {
4449                 g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"),
4450                              val, "eui64,stable-privacy");
4451                         return FALSE;
4452         }
4453
4454         g_object_set (setting, prop, addr_gen_mode, NULL);
4455         return TRUE;
4456 }
4457
4458
4459 /* --- NM_SETTING_OLPC_MESH_SETTING_NAME property setter functions --- */
4460 static gboolean
4461 nmc_property_olpc_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4462 {
4463         unsigned long chan_int;
4464
4465         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4466
4467         if (!nmc_string_to_uint (val, TRUE, 1, 13, &chan_int)) {
4468                 g_set_error (error, 1, 0, _("'%s' is not a valid channel; use <1-13>"), val);
4469                 return FALSE;
4470         }
4471         g_object_set (setting, prop, chan_int, NULL);
4472         return TRUE;
4473 }
4474
4475
4476 /* --- NM_SETTING_SERIAL_SETTING_NAME property setter functions --- */
4477 static char *
4478 nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type)
4479 {
4480         NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
4481
4482         switch (nm_setting_serial_get_parity (s_serial)) {
4483         case NM_SETTING_SERIAL_PARITY_EVEN:
4484                 return g_strdup ("even");
4485         case NM_SETTING_SERIAL_PARITY_ODD:
4486                 return g_strdup ("odd");
4487         default:
4488         case NM_SETTING_SERIAL_PARITY_NONE:
4489                 return g_strdup ("none");
4490         }
4491 }
4492
4493 static gboolean
4494 nmc_property_serial_set_parity (NMSetting *setting, const char *prop, const char *val, GError **error)
4495 {
4496         NMSettingSerialParity parity;
4497
4498         if (val[0] == 'E' || val[0] == 'e')
4499                 parity = NM_SETTING_SERIAL_PARITY_EVEN;
4500         else if (val[0] == 'O' || val[0] == 'o')
4501                 parity = NM_SETTING_SERIAL_PARITY_ODD;
4502         else if (val[0] == 'N' || val[0] == 'n')
4503                 parity = NM_SETTING_SERIAL_PARITY_NONE;
4504         else {
4505                 g_set_error (error, 1, 0, _("'%s' is not valid; use [e, o, n]"), val);
4506                 return FALSE;
4507         }
4508
4509         g_object_set (setting, prop, parity, NULL);
4510         return TRUE;
4511 }
4512
4513 /* --- NM_SETTING_TEAM_SETTING_NAME property functions --- */
4514 /* --- NM_SETTING_TEAM_PORT_SETTING_NAME property functions --- */
4515 static gboolean
4516 nmc_property_team_set_config (NMSetting *setting, const char *prop, const char *val, GError **error)
4517 {
4518         char *json = NULL;
4519
4520         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4521
4522         if (!nmc_team_check_config (val, &json, error)) {
4523                 return FALSE;
4524         }
4525         g_object_set (setting, prop, json, NULL);
4526         g_free (json);
4527         return TRUE;
4528 }
4529
4530 static const char *
4531 nmc_property_team_describe_config (NMSetting *setting, const char *prop)
4532 {
4533         return _("nmcli can accepts both direct JSON configuration data and a file name containing "
4534                  "the configuration. In the latter case the file is read and the contents is put "
4535                  "into this property.\n\n"
4536                  "Examples: set team.config "
4537                  "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n"
4538                  "          set team.config /etc/my-team.conf\n");
4539 }
4540
4541 /* --- NM_SETTING_VLAN_SETTING_NAME property setter functions --- */
4542 static gboolean
4543 nmc_property_vlan_set_prio_map (NMSetting *setting,
4544                                 const char *prop,
4545                                 const char *val,
4546                                 NMVlanPriorityMap map_type,
4547                                 GError **error)
4548 {
4549         char **prio_map, **p;
4550
4551         prio_map = nmc_vlan_parse_priority_maps (val, map_type, error);
4552         if (!prio_map)
4553                 return FALSE;
4554
4555         for (p = prio_map; p && *p; p++)
4556                 nm_setting_vlan_add_priority_str (NM_SETTING_VLAN (setting), map_type, *p);
4557
4558         g_strfreev (prio_map);
4559         return TRUE;
4560 }
4561
4562 static gboolean
4563 nmc_property_vlan_remove_prio_map (NMSetting *setting,
4564                                    const char *prop,
4565                                    guint32 idx,
4566                                    NMVlanPriorityMap map_type,
4567                                    GError **error)
4568 {
4569         guint32 num;
4570
4571         num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type);
4572         if (num == 0) {
4573                 g_set_error_literal (error, 1, 0, _("no priority to remove"));
4574                 return FALSE;
4575         }
4576         if (idx >= num) {
4577                 g_set_error (error, 1, 0, _("index '%d' is not in the range of <0-%d>"),
4578                              idx, num - 1);
4579                 return FALSE;
4580         }
4581
4582         nm_setting_vlan_remove_priority (NM_SETTING_VLAN (setting), map_type, idx);
4583         return TRUE;
4584 }
4585
4586 static gboolean
4587 nmc_property_vlan_set_ingress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4588 {
4589         return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_INGRESS_MAP, error);
4590 }
4591
4592 static gboolean
4593 nmc_property_vlan_set_egress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error)
4594 {
4595         return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_EGRESS_MAP, error);
4596 }
4597
4598 static gboolean
4599 nmc_property_vlan_remove_priority_map (NMSetting *setting,
4600                                        const char *prop,
4601                                        const char *value,
4602                                        guint32 idx,
4603                                        NMVlanPriorityMap map,
4604                                        GError **error)
4605 {
4606         /* If value != NULL, remove by value */
4607         if (value) {
4608                 gboolean ret;
4609                 char **prio_map;
4610                 char *val = g_strdup (value);
4611
4612                 prio_map = nmc_vlan_parse_priority_maps (val, map, error);
4613                 if (!prio_map)
4614                         return FALSE;
4615                 if (prio_map[1])
4616                         g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
4617                                  prio_map[0]);
4618                 ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
4619                                                                     map,
4620                                                                     prio_map[0]);
4621
4622                 if (!ret)
4623                         g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]);
4624                 g_free (val);
4625                 g_strfreev (prio_map);
4626                 return ret;
4627         }
4628
4629         /* Else remove by index */
4630         return nmc_property_vlan_remove_prio_map (setting, prop, idx, map, error);
4631 }
4632
4633 static gboolean
4634 nmc_property_vlan_remove_ingress_priority_map (NMSetting *setting,
4635                                                const char *prop,
4636                                                const char *value,
4637                                                guint32 idx,
4638                                                GError **error)
4639 {
4640         return nmc_property_vlan_remove_priority_map (setting,
4641                                                       prop,
4642                                                       value,
4643                                                       idx,
4644                                                       NM_VLAN_INGRESS_MAP,
4645                                                       error);
4646 }
4647
4648 static gboolean
4649 nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
4650                                               const char *prop,
4651                                               const char *value,
4652                                               guint32 idx,
4653                                               GError **error)
4654 {
4655         return nmc_property_vlan_remove_priority_map (setting,
4656                                                       prop,
4657                                                       value,
4658                                                       idx,
4659                                                       NM_VLAN_EGRESS_MAP,
4660                                                       error);
4661 }
4662
4663 /* --- NM_SETTING_VPN_SETTING_NAME property setter functions --- */
4664 /* Validate value of vpn 'data' and 'secret'  options */
4665 static const char *
4666 _validate_vpn_hash_value (const char *option, const char *value, GError **error)
4667 {
4668         /* nm_setting_vpn_add_data_item() and nm_setting_vpn_add_secret() does not
4669          * allow empty strings */
4670         if (!value || !*value) {
4671                 g_set_error (error, 1, 0, _("'%s' cannot be empty"), option);
4672                 return NULL;
4673         }
4674         return value;
4675 }
4676
4677 /* 'data' */
4678 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
4679                        NM_SETTING_VPN,
4680                        NMSettingVpn,
4681                        nm_setting_vpn_add_data_item,
4682                        NULL,
4683                        _validate_vpn_hash_value)
4684 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
4685                        NM_SETTING_VPN,
4686                        nm_setting_vpn_remove_data_item)
4687
4688 /* 'secrets' */
4689 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
4690                        NM_SETTING_VPN,
4691                        NMSettingVpn,
4692                        nm_setting_vpn_add_secret,
4693                        NULL,
4694                        _validate_vpn_hash_value)
4695 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret,
4696                        NM_SETTING_VPN,
4697                        nm_setting_vpn_remove_secret)
4698
4699 /* --- NM_SETTING_WIMAX_SETTING_NAME property setter functions --- */
4700 /* No specific functions */
4701
4702 /* --- NM_SETTING_WIRED_SETTING_NAME property setter functions --- */
4703 #if 0
4704 /*
4705  * Do not allow setting 'port' and 'duplex' for now. They are not implemented in
4706  * NM core, nor in ifcfg-rh plugin. Enable this when it gets done.
4707  */
4708 /* 'port' */
4709 static const char *wired_valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
4710
4711 static gboolean
4712 nmc_property_wired_set_port (NMSetting *setting, const char *prop, const char *val, GError **error)
4713 {
4714         return check_and_set_string (setting, prop, val, wired_valid_ports, error);
4715 }
4716
4717 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_port, wired_valid_ports)
4718
4719 /* 'duplex' */
4720 static const char *wired_valid_duplexes[] = { "half", "full", NULL };
4721
4722 static gboolean
4723 nmc_property_wired_set_duplex (NMSetting *setting, const char *prop, const char *val, GError **error)
4724 {
4725         return check_and_set_string (setting, prop, val, wired_valid_duplexes, error);
4726 }
4727
4728 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_duplex, wired_valid_duplexes)
4729 #endif
4730
4731 /* 'mac-address-blacklist' */
4732 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wired_set_mac_address_blacklist,
4733                              NM_SETTING_WIRED,
4734                              nm_setting_wired_add_mac_blacklist_item)
4735
4736 static gboolean
4737 _validate_and_remove_wired_mac_blacklist_item (NMSettingWired *setting,
4738                                               const char *mac,
4739                                               GError **error)
4740 {
4741         gboolean ret;
4742         guint8 buf[32];
4743
4744         if (!nm_utils_hwaddr_aton (mac, buf, ETH_ALEN)) {
4745                 g_set_error (error, 1, 0, _("'%s' is not a valid MAC address"), mac);
4746                 return FALSE;
4747         }
4748
4749         ret = nm_setting_wired_remove_mac_blacklist_item_by_value (setting, mac);
4750         if (!ret)
4751                 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4752         return ret;
4753 }
4754 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wired_remove_mac_address_blacklist,
4755                                NM_SETTING_WIRED,
4756                                nm_setting_wired_get_num_mac_blacklist_items,
4757                                nm_setting_wired_remove_mac_blacklist_item,
4758                                _validate_and_remove_wired_mac_blacklist_item)
4759
4760 /* 's390-subchannels' */
4761 static gboolean
4762 nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, const char *val, GError **error)
4763 {
4764         char **strv = NULL;
4765         int len;
4766
4767         strv = nmc_strsplit_set (val, " ,\t", 0);
4768         len = g_strv_length (strv);
4769         if (len != 2 && len != 3) {
4770                 g_set_error (error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"),
4771                              val);
4772                 g_strfreev (strv);
4773                 return FALSE;
4774         }
4775
4776         g_object_set (setting, prop, strv, NULL);
4777         g_strfreev (strv);
4778         return TRUE;
4779 }
4780
4781 static const char *
4782 nmc_property_wired_describe_s390_subchannels (NMSetting *setting, const char *prop)
4783 {
4784         return _("Enter a list of subchannels (comma or space separated).\n\n"
4785                  "Example: 0.0.0e20 0.0.0e21 0.0.0e22\n");
4786 }
4787
4788 /* 's390-nettype' */
4789 static const char *wired_valid_s390_nettypes[] = { "qeth", "lcs", "ctc", NULL };
4790
4791 static gboolean
4792 nmc_property_wired_set_s390_nettype (NMSetting *setting, const char *prop, const char *val, GError **error)
4793 {
4794         return check_and_set_string (setting, prop, val, wired_valid_s390_nettypes, error);
4795 }
4796
4797 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_s390_nettype, wired_valid_s390_nettypes)
4798
4799 /* 's390-options' */
4800 /* Validate value of 's390-options' */
4801 static const char *
4802 _validate_s390_option_value (const char *option, const char *value, GError **error)
4803 {
4804         /*  nm_setting_wired_add_s390_option() requires value len in <1,199> interval */
4805         if (!value || !*value || strlen (value) >= 200) {
4806                 g_set_error (error, 1, 0, _("'%s' string value should consist of 1 - 199 characters"), option);
4807                 return NULL;
4808         }
4809         return value;
4810 }
4811 DEFINE_SETTER_OPTIONS (nmc_property_wired_set_s390_options,
4812                        NM_SETTING_WIRED,
4813                        NMSettingWired,
4814                        nm_setting_wired_add_s390_option,
4815                        nm_setting_wired_get_valid_s390_options,
4816                        _validate_s390_option_value)
4817 DEFINE_REMOVER_OPTION (nmc_property_wired_remove_option_s390_options,
4818                        NM_SETTING_WIRED,
4819                        nm_setting_wired_remove_s390_option)
4820
4821 static const char **
4822 nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop)
4823 {
4824         return nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4825 }
4826
4827 static const char *
4828 nmc_property_wired_describe_s390_options (NMSetting *setting, const char *prop)
4829 {
4830         static char *desc = NULL;
4831         const char **valid_options;
4832         char *options_str;
4833
4834         if (G_UNLIKELY (desc == NULL)) {
4835                 valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting));
4836                 options_str = g_strjoinv (", ", (char **) valid_options);
4837
4838                 desc = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n"
4839                                           "  option = <value>, option = <value>,...\n"
4840                                           "Valid options are: %s\n"),
4841                                         options_str);
4842                 g_free (options_str);
4843         }
4844         return desc;
4845 }
4846
4847 /* --- NM_SETTING_WIRELESS_SETTING_NAME property setter functions --- */
4848 /* 'mode' */
4849 static const char *wifi_valid_modes[] = {
4850         NM_SETTING_WIRELESS_MODE_INFRA,
4851         NM_SETTING_WIRELESS_MODE_ADHOC,
4852         NM_SETTING_WIRELESS_MODE_AP,
4853         NULL
4854 };
4855
4856 static gboolean
4857 nmc_property_wifi_set_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
4858 {
4859         return check_and_set_string (setting, prop, val, wifi_valid_modes, error);
4860 }
4861
4862 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_mode, wifi_valid_modes)
4863
4864 /* 'band' */
4865 static const char *wifi_valid_bands[] = { "a", "bg", NULL };
4866
4867 static gboolean
4868 nmc_property_wifi_set_band (NMSetting *setting, const char *prop, const char *val, GError **error)
4869 {
4870         return check_and_set_string (setting, prop, val, wifi_valid_bands, error);
4871 }
4872
4873 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_band, wifi_valid_bands)
4874
4875 /* 'channel' */
4876 static gboolean
4877 nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error)
4878 {
4879         unsigned long chan_int;
4880
4881         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
4882
4883         if (!nmc_string_to_uint (val, FALSE, 0, 0, &chan_int)) {
4884                 g_set_error (error, 1, 0, _("'%s' is not a valid channel"), val);
4885                 return FALSE;
4886         }
4887
4888         if (   !nm_utils_wifi_is_channel_valid (chan_int, "a")
4889             && !nm_utils_wifi_is_channel_valid (chan_int, "bg")) {
4890                 g_set_error (error, 1, 0, _("'%ld' is not a valid channel"), chan_int);
4891                 return FALSE;
4892         }
4893
4894         g_object_set (setting, prop, chan_int, NULL);
4895         return TRUE;
4896 }
4897
4898 /* 'mac-address-blacklist' */
4899 DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wireless_set_mac_address_blacklist,
4900                              NM_SETTING_WIRELESS,
4901                              nm_setting_wireless_add_mac_blacklist_item)
4902
4903 static gboolean
4904 _validate_and_remove_wifi_mac_blacklist_item (NMSettingWireless *setting,
4905                                               const char *mac,
4906                                               GError **error)
4907 {
4908         gboolean ret;
4909         guint8 buf[32];
4910
4911         if (!nm_utils_hwaddr_aton (mac, buf, ETH_ALEN)) {
4912                 g_set_error (error, 1, 0, _("'%s' is not a valid MAC address"), mac);
4913                 return FALSE;
4914         }
4915
4916         ret = nm_setting_wireless_remove_mac_blacklist_item_by_value (setting, mac);
4917         if (!ret)
4918                 g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac);
4919         return ret;
4920 }
4921 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wireless_remove_mac_address_blacklist,
4922                                NM_SETTING_WIRELESS,
4923                                nm_setting_wireless_get_num_mac_blacklist_items,
4924                                nm_setting_wireless_remove_mac_blacklist_item,
4925                                _validate_and_remove_wifi_mac_blacklist_item)
4926
4927 /* 'powersave' */
4928 static gboolean
4929 nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const char *val, GError **error)
4930 {
4931         NMSettingWirelessPowersave powersave;
4932         gs_free const char **options = NULL;
4933         gs_free char *options_str = NULL;
4934         long int t;
4935         gboolean ret;
4936
4937         if (nmc_string_to_int_base (val, 0, TRUE,
4938                                     NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4939                                     NM_SETTING_WIRELESS_POWERSAVE_LAST,
4940                                     &t))
4941                 powersave = (NMSettingWirelessPowersave) t;
4942         else {
4943                 ret = nm_utils_enum_from_str (nm_setting_wireless_powersave_get_type (),
4944                                               val,
4945                                               (int *) &powersave,
4946                                               NULL);
4947                 if (!ret) {
4948                         options = nm_utils_enum_get_values (nm_setting_wireless_powersave_get_type (),
4949                                                             NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
4950                                                             NM_SETTING_WIRELESS_POWERSAVE_LAST);
4951                         options_str = g_strjoinv (",", (char **) options);
4952                         g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), val, options_str);
4953                         return FALSE;
4954                 }
4955         }
4956
4957         g_object_set (setting, prop, (guint) powersave, NULL);
4958         return TRUE;
4959 }
4960
4961 static gboolean
4962 nmc_property_wireless_set_mac_address_randomization (NMSetting *setting,
4963                                                      const char *prop,
4964                                                      const char *val,
4965                                                      GError **error)
4966 {
4967         NMSettingMacRandomization randomization;
4968         gs_free char *err_token = NULL;
4969         gboolean ret;
4970         long int t;
4971
4972         if (nmc_string_to_int_base (val, 0, TRUE,
4973                                     NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
4974                                     NM_SETTING_MAC_RANDOMIZATION_ALWAYS,
4975                                     &t))
4976                 randomization = (NMSettingMacRandomization) t;
4977         else {
4978                 ret = nm_utils_enum_from_str (nm_setting_mac_randomization_get_type (),
4979                                               val,
4980                                               (int *) &randomization,
4981                                               &err_token);
4982
4983                 if (!ret) {
4984                         g_set_error (error, 1, 0, _("invalid option '%s', use 'default', 'never' or 'always'"),
4985                                      err_token);
4986                         return FALSE;
4987                 }
4988         }
4989
4990         g_object_set (setting, prop, (guint) randomization, NULL);
4991         return TRUE;
4992 }
4993
4994 /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property setter functions --- */
4995 /* 'key-mgmt' */
4996 static const char *wifi_sec_valid_key_mgmts[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
4997
4998 static gboolean
4999 nmc_property_wifi_sec_set_key_mgmt (NMSetting *setting, const char *prop, const char *val, GError **error)
5000 {
5001         return check_and_set_string (setting, prop, val, wifi_sec_valid_key_mgmts, error);
5002 }
5003
5004 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_key_mgmt, wifi_sec_valid_key_mgmts)
5005
5006 /* 'auth-alg' */
5007 static const char *wifi_sec_valid_auth_algs[] = { "open", "shared", "leap", NULL };
5008
5009 static gboolean
5010 nmc_property_wifi_sec_set_auth_alg (NMSetting *setting, const char *prop, const char *val, GError **error)
5011 {
5012         return check_and_set_string (setting, prop, val, wifi_sec_valid_auth_algs, error);
5013 }
5014
5015 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_auth_alg, wifi_sec_valid_auth_algs)
5016
5017 /* 'proto' */
5018 static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL };
5019
5020 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_proto,
5021                               NM_SETTING_WIRELESS_SECURITY,
5022                               nm_setting_wireless_security_add_proto)
5023
5024 static gboolean
5025 nmc_property_wifi_sec_set_proto (NMSetting *setting, const char *prop, const char *val, GError **error)
5026 {
5027         return check_and_add_wifi_sec_proto (setting, prop, val, wifi_sec_valid_protos, error);
5028 }
5029
5030 static gboolean
5031 _validate_and_remove_wifi_sec_proto (NMSettingWirelessSecurity *setting,
5032                                      const char *proto,
5033                                      GError **error)
5034 {
5035         gboolean ret;
5036         const char *valid;
5037
5038         valid = nmc_string_is_valid (proto, wifi_sec_valid_protos, error);
5039         if (!valid)
5040                 return FALSE;
5041
5042         ret = nm_setting_wireless_security_remove_proto_by_value (setting, proto);
5043         if (!ret)
5044                 g_set_error (error, 1, 0,
5045                              _("the property doesn't contain protocol '%s'"), proto);
5046         return ret;
5047 }
5048 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_proto,
5049                                NM_SETTING_WIRELESS_SECURITY,
5050                                nm_setting_wireless_security_get_num_protos,
5051                                nm_setting_wireless_security_remove_proto,
5052                                _validate_and_remove_wifi_sec_proto)
5053
5054 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_proto, wifi_sec_valid_protos)
5055
5056 /* 'pairwise' */
5057 static const char *wifi_sec_valid_pairwises[] = { "tkip", "ccmp", NULL };
5058
5059 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_pairwise,
5060                               NM_SETTING_WIRELESS_SECURITY,
5061                               nm_setting_wireless_security_add_pairwise)
5062
5063 static gboolean
5064 nmc_property_wifi_sec_set_pairwise (NMSetting *setting, const char *prop, const char *val, GError **error)
5065 {
5066         return check_and_add_wifi_sec_pairwise (setting, prop, val, wifi_sec_valid_pairwises, error);
5067 }
5068
5069 static gboolean
5070 _validate_and_remove_wifi_sec_pairwise (NMSettingWirelessSecurity *setting,
5071                                         const char *pairwise,
5072                                         GError **error)
5073 {
5074         gboolean ret;
5075         const char *valid;
5076
5077         valid = nmc_string_is_valid (pairwise, wifi_sec_valid_pairwises, error);
5078         if (!valid)
5079                 return FALSE;
5080
5081         ret = nm_setting_wireless_security_remove_pairwise_by_value (setting, pairwise);
5082         if (!ret)
5083                 g_set_error (error, 1, 0,
5084                              _("the property doesn't contain protocol '%s'"), pairwise);
5085         return ret;
5086 }
5087 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_pairwise,
5088                                NM_SETTING_WIRELESS_SECURITY,
5089                                nm_setting_wireless_security_get_num_pairwise,
5090                                nm_setting_wireless_security_remove_pairwise,
5091                                _validate_and_remove_wifi_sec_pairwise)
5092
5093 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_pairwise, wifi_sec_valid_pairwises)
5094
5095 /* 'group' */
5096 static const char *wifi_sec_valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
5097
5098 DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_group,
5099                               NM_SETTING_WIRELESS_SECURITY,
5100                               nm_setting_wireless_security_add_group)
5101
5102 static gboolean
5103 nmc_property_wifi_sec_set_group (NMSetting *setting, const char *prop, const char *val, GError **error)
5104 {
5105         return check_and_add_wifi_sec_group (setting, prop, val, wifi_sec_valid_groups, error);
5106 }
5107
5108 static gboolean
5109 _validate_and_remove_wifi_sec_group (NMSettingWirelessSecurity *setting,
5110                                      const char *group,
5111                                      GError **error)
5112 {
5113         gboolean ret;
5114         const char *valid;
5115
5116         valid = nmc_string_is_valid (group, wifi_sec_valid_groups, error);
5117         if (!valid)
5118                 return FALSE;
5119
5120         ret = nm_setting_wireless_security_remove_group_by_value (setting, group);
5121         if (!ret)
5122                 g_set_error (error, 1, 0,
5123                              _("the property doesn't contain protocol '%s'"), group);
5124         return ret;
5125 }
5126 DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_group,
5127                                NM_SETTING_WIRELESS_SECURITY,
5128                                nm_setting_wireless_security_get_num_groups,
5129                                nm_setting_wireless_security_remove_group,
5130                                _validate_and_remove_wifi_sec_group)
5131 DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_group, wifi_sec_valid_groups)
5132
5133 /* 'wep-key' */
5134 static gboolean
5135 nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char *val, GError **error)
5136 {
5137         NMWepKeyType guessed_type = NM_WEP_KEY_TYPE_UNKNOWN;
5138         NMWepKeyType type;
5139         guint32 prev_idx, idx;
5140
5141         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5142
5143         /* Get currently set type */
5144         type = nm_setting_wireless_security_get_wep_key_type (NM_SETTING_WIRELESS_SECURITY (setting));
5145
5146         /* Guess key type */
5147         if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_KEY))
5148                 guessed_type = NM_WEP_KEY_TYPE_KEY;
5149         else if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_PASSPHRASE))
5150                 guessed_type = NM_WEP_KEY_TYPE_PASSPHRASE;
5151
5152         if (guessed_type == NM_WEP_KEY_TYPE_UNKNOWN) {
5153                 g_set_error (error, 1, 0, _("'%s' is not valid"), val);
5154                 return FALSE;
5155         }
5156
5157         if (type != NM_WEP_KEY_TYPE_UNKNOWN && type != guessed_type) {
5158                 if (nm_utils_wep_key_valid (val, type))
5159                         guessed_type = type;
5160                 else {
5161                         g_set_error (error, 1, 0,
5162                                      _("'%s' not compatible with %s '%s', please change the key or set the right %s first."),
5163                                      val, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_key_type_to_string (type),
5164                                      NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
5165                         return FALSE;
5166                 }
5167         }
5168         prev_idx = nm_setting_wireless_security_get_wep_tx_keyidx (NM_SETTING_WIRELESS_SECURITY (setting));
5169         idx = prop[strlen (prop) - 1] - '0';
5170         g_print (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
5171         if (idx != prev_idx)
5172                 g_print (_("WEP key index set to '%d'\n"), idx);
5173
5174         g_object_set (setting, prop, val, NULL);
5175         g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, guessed_type, NULL);
5176         if (idx != prev_idx)
5177                 g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, idx, NULL);
5178         return TRUE;
5179 }
5180
5181 /* 'wep-key-type' */
5182 static gboolean
5183 nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const char *val, GError **error)
5184 {
5185         unsigned long  type_int;
5186         const char *valid_wep_types[] = { "unknown", "key", "passphrase", NULL };
5187         const char *type_str = NULL;
5188         const char *key0, *key1,* key2, *key3;
5189         NMWepKeyType type = NM_WEP_KEY_TYPE_UNKNOWN;
5190
5191         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5192
5193         if (!nmc_string_to_uint (val, TRUE, 0, 2, &type_int)) {
5194                 if (!(type_str = nmc_string_is_valid (val, valid_wep_types, NULL))) {
5195                         g_set_error (error, 1, 0, _("'%s' not among [0 (unknown), 1 (key), 2 (passphrase)]"), val);
5196                         return FALSE;
5197                 }
5198                 if (type_str == valid_wep_types[1])
5199                         type = NM_WEP_KEY_TYPE_KEY;
5200                 else if (type_str == valid_wep_types[2])
5201                         type = NM_WEP_KEY_TYPE_PASSPHRASE;
5202         } else
5203                 type = (NMWepKeyType) type_int;
5204
5205         /* Check type compatibility with set keys */
5206         key0 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 0);
5207         key1 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 1);
5208         key2 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 2);
5209         key3 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 3);
5210         if (key0 && !nm_utils_wep_key_valid (key0, type))
5211                 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5212                          NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
5213         if (key1 && !nm_utils_wep_key_valid (key1, type))
5214                 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5215                          NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
5216         if (key2 && !nm_utils_wep_key_valid (key2, type))
5217                 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5218                          NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
5219         if (key3 && !nm_utils_wep_key_valid (key3, type))
5220                 g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
5221                          NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
5222
5223         g_object_set (setting, prop, type, NULL);
5224         return TRUE;
5225 }
5226
5227 static const char *
5228 nmc_property_wifi_describe_wep_key_type (NMSetting *setting, const char *prop)
5229 {
5230         static char *desc = NULL;
5231
5232         if (G_UNLIKELY (desc == NULL)) {
5233                 desc = g_strdup_printf (_("Enter the type of WEP keys. The accepted values are: "
5234                                           "0 or unknown, 1 or key, and 2 or passphrase.\n"));
5235         }
5236         return desc;
5237 }
5238
5239 /* 'psk' */
5240 static gboolean
5241 nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val, GError **error)
5242 {
5243         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5244
5245         if (!nm_utils_wpa_psk_valid (val)) {
5246                 g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), val);
5247                 return FALSE;
5248         }
5249         g_object_set (setting, prop, val, NULL);
5250         return TRUE;
5251 }
5252
5253 #define DCB_ALL_FLAGS (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING)
5254
5255 /* DCB stuff */
5256 static gboolean
5257 nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error)
5258 {
5259         char **strv = NULL, **iter;
5260         NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5261         long int t;
5262
5263         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5264
5265         /* Check for overall hex numeric value */
5266         if (nmc_string_to_int_base (val, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5267                 flags = (guint) t;
5268         else {
5269                 /* Check for individual flag numbers */
5270                 strv = nmc_strsplit_set (val, " \t,", 0);
5271                 for (iter = strv; iter && *iter; iter++) {
5272                         if (!nmc_string_to_int_base (*iter, 0, TRUE, 0, DCB_ALL_FLAGS, &t))
5273                                 t = -1;
5274
5275                         if (   g_ascii_strcasecmp (*iter, "enable") == 0
5276                             || g_ascii_strcasecmp (*iter, "enabled") == 0
5277                             || t == NM_SETTING_DCB_FLAG_ENABLE)
5278                                 flags |= NM_SETTING_DCB_FLAG_ENABLE;
5279                         else if (   g_ascii_strcasecmp (*iter, "advertise") == 0
5280                                  || t == NM_SETTING_DCB_FLAG_ADVERTISE)
5281                                 flags |= NM_SETTING_DCB_FLAG_ADVERTISE;
5282                         else if (   g_ascii_strcasecmp (*iter, "willing") == 0
5283                                  || t == NM_SETTING_DCB_FLAG_WILLING)
5284                                 flags |= NM_SETTING_DCB_FLAG_WILLING;
5285                         else if (   g_ascii_strcasecmp (*iter, "disable") == 0
5286                                  || g_ascii_strcasecmp (*iter, "disabled") == 0
5287                                  || t == 0) {
5288                                 /* pass */
5289                         } else {
5290                                 g_set_error (error, 1, 0, _("'%s' is not a valid DCB flag"), *iter);
5291                                 return FALSE;
5292                         }
5293                 }
5294                 g_strfreev (strv);
5295         }
5296
5297         /* Validate the flags according to the property spec */
5298         if (!validate_flags (setting, prop, (guint) flags, error))
5299                 return FALSE;
5300
5301         g_object_set (setting, prop, (guint) flags, NULL);
5302         return TRUE;
5303 }
5304
5305 static gboolean
5306 nmc_property_dcb_set_priority (NMSetting *setting, const char *prop, const char *val, GError **error)
5307 {
5308         long int priority = 0;
5309
5310         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5311
5312         if (!nmc_string_to_int (val, FALSE, -1, 7, &priority)) {
5313                 g_set_error (error, 1, 0, _("'%s' is not a DCB app priority"), val);
5314                 return FALSE;
5315         }
5316
5317         /* Validate the number according to the property spec */
5318         if (!validate_int (setting, prop, (gint) priority, error))
5319                 return FALSE;
5320
5321         g_object_set (setting, prop, (gint) priority, NULL);
5322         return TRUE;
5323 }
5324
5325 static gboolean
5326 dcb_parse_uint_array (const char *val,
5327                       guint max,
5328                       guint other,
5329                       guint *out_array,
5330                       GError **error)
5331 {
5332         char **items, **iter;
5333         guint i = 0;
5334
5335         g_return_val_if_fail (out_array != NULL, FALSE);
5336
5337         items = g_strsplit_set (val, ",", -1);
5338         if (g_strv_length (items) != 8) {
5339                 g_set_error_literal (error, 1, 0, _("must contain 8 comma-separated numbers"));
5340                 goto error;
5341         }
5342
5343         for (iter = items; iter && *iter; iter++) {
5344                 long int num = 0;
5345                 gboolean success;
5346
5347                 *iter = g_strstrip (*iter);
5348                 success = nmc_string_to_int_base (*iter, 10, TRUE, 0, other ? other : max, &num);
5349
5350                 /* If number is greater than 'max' it must equal 'other' */
5351                 if (success && other && (num > max) && (num != other))
5352                         success = FALSE;
5353
5354                 if (!success) {
5355                         if (other) {
5356                                 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive) or %u"),
5357                                              *iter, max, other);
5358                         } else {
5359                                 g_set_error (error, 1, 0, _("'%s' not a number between 0 and %u (inclusive)"),
5360                                              *iter, max);
5361                         }
5362                         goto error;
5363                 }
5364                 out_array[i++] = (guint) num;
5365         }
5366
5367         return TRUE;
5368
5369 error:
5370         g_strfreev (items);
5371         return FALSE;
5372 }
5373
5374 static void
5375 dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop)
5376 {
5377         NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE;
5378
5379         g_object_get (s_dcb, flags_prop, &flags, NULL);
5380         if (!(flags & NM_SETTING_DCB_FLAG_ENABLE))
5381                 g_print (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
5382 }
5383
5384 static gboolean
5385 nmc_property_dcb_set_pfc (NMSetting *setting, const char *prop, const char *val, GError **error)
5386 {
5387         guint i = 0;
5388         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5389
5390         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5391
5392         if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5393                 return FALSE;
5394
5395         for (i = 0; i < 8; i++)
5396                 nm_setting_dcb_set_priority_flow_control (NM_SETTING_DCB (setting), i, !!nums[i]);
5397
5398         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS);
5399         return TRUE;
5400 }
5401
5402 static gboolean
5403 nmc_property_dcb_set_pg_group_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5404 {
5405         guint i = 0;
5406         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5407
5408         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5409
5410         if (!dcb_parse_uint_array (val, 7, 15, nums, error))
5411                 return FALSE;
5412
5413         for (i = 0; i < 8; i++)
5414                 nm_setting_dcb_set_priority_group_id (NM_SETTING_DCB (setting), i, nums[i]);
5415
5416         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5417         return TRUE;
5418 }
5419
5420 static gboolean
5421 nmc_property_dcb_set_pg_group_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5422 {
5423         guint i = 0, sum = 0;
5424         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5425
5426         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5427
5428         if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5429                 return FALSE;
5430
5431         for (i = 0; i < 8; i++)
5432                 sum += nums[i];
5433         if (sum != 100) {
5434                 g_set_error_literal (error, 1, 0, _("bandwidth percentages must total 100%%"));
5435                 return FALSE;
5436         }
5437
5438         for (i = 0; i < 8; i++)
5439                 nm_setting_dcb_set_priority_group_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5440
5441         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5442         return TRUE;
5443 }
5444
5445 static gboolean
5446 nmc_property_dcb_set_pg_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error)
5447 {
5448         guint i = 0;
5449         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5450
5451         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5452
5453         if (!dcb_parse_uint_array (val, 100, 0, nums, error))
5454                 return FALSE;
5455
5456         for (i = 0; i < 8; i++)
5457                 nm_setting_dcb_set_priority_bandwidth (NM_SETTING_DCB (setting), i, nums[i]);
5458
5459         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5460         return TRUE;
5461 }
5462
5463 static gboolean
5464 nmc_property_dcb_set_pg_strict (NMSetting *setting, const char *prop, const char *val, GError **error)
5465 {
5466         guint i = 0;
5467         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5468
5469         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5470
5471         if (!dcb_parse_uint_array (val, 1, 0, nums, error))
5472                 return FALSE;
5473
5474         for (i = 0; i < 8; i++)
5475                 nm_setting_dcb_set_priority_strict_bandwidth (NM_SETTING_DCB (setting), i, !!nums[i]);
5476
5477         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5478         return TRUE;
5479 }
5480
5481 static gboolean
5482 nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, const char *val, GError **error)
5483 {
5484         guint i = 0;
5485         guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5486
5487         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5488
5489         if (!dcb_parse_uint_array (val, 7, 0, nums, error))
5490                 return FALSE;
5491
5492         for (i = 0; i < 8; i++)
5493                 nm_setting_dcb_set_priority_traffic_class (NM_SETTING_DCB (setting), i, nums[i]);
5494
5495         dcb_check_feature_enabled (NM_SETTING_DCB (setting), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS);
5496         return TRUE;
5497 }
5498
5499 /* 'app-fcoe-mode' */
5500 static const char *_dcb_valid_fcoe_modes[] = { NM_SETTING_DCB_FCOE_MODE_FABRIC,
5501                                                NM_SETTING_DCB_FCOE_MODE_VN2VN,
5502                                                NULL };
5503
5504 static gboolean
5505 nmc_property_dcb_set_app_fcoe_mode (NMSetting *setting, const char *prop, const char *val, GError **error)
5506 {
5507         return check_and_set_string (setting, prop, val, _dcb_valid_fcoe_modes, error);
5508 }
5509
5510 DEFINE_ALLOWED_VAL_FUNC (nmc_property_dcb_allowed_app_fcoe_modes, _dcb_valid_fcoe_modes)
5511
5512 static gboolean
5513 nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, const char *val, GError **error)
5514 {
5515         const char *p = val;
5516
5517         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
5518
5519         if (strlen (val) != 5 && strlen (val) != 6) {
5520                 g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code"));
5521                 return FALSE;
5522         }
5523
5524         while (p && *p) {
5525                 if (!g_ascii_isdigit (*p++)) {
5526                         g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code"));
5527                         return FALSE;
5528                 }
5529         }
5530         g_object_set (G_OBJECT (setting),
5531                       NM_SETTING_GSM_SIM_OPERATOR_ID,
5532                       val,
5533                       NULL);
5534         return TRUE;
5535 }
5536
5537 static char *
5538 nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type)
5539 {
5540         NMSettingTun *s_tun = NM_SETTING_TUN (setting);
5541         NMSettingTunMode mode;
5542         char *tmp, *str;
5543
5544         mode = nm_setting_tun_get_mode (s_tun);
5545         tmp = nm_utils_enum_to_str (nm_setting_tun_mode_get_type (), mode);
5546         if (get_type == NMC_PROPERTY_GET_PARSABLE)
5547                 str = g_strdup_printf ("%s", tmp ? tmp : "");
5548         else
5549                 str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : "");
5550         g_free (tmp);
5551         return str;
5552 }
5553
5554 static gboolean
5555 nmc_property_tun_set_mode (NMSetting *setting, const char *prop,
5556                            const char *val, GError **error)
5557 {
5558         NMSettingTunMode mode;
5559         gboolean ret;
5560         long int t;
5561
5562         if (nmc_string_to_int_base (val, 0, TRUE, 0, NM_SETTING_TUN_MODE_TAP, &t))
5563                 mode = (NMSettingTunMode) t;
5564         else {
5565                 ret = nm_utils_enum_from_str (nm_setting_tun_mode_get_type (), val,
5566                                               (int *) &mode, NULL);
5567
5568                 if (!ret) {
5569                         g_set_error (error, 1, 0, _("invalid option '%s', use '%s' or '%s'"),
5570                                      val, "tun", "tap");
5571                         return FALSE;
5572                 }
5573         }
5574
5575         g_object_set (setting, prop, (guint) mode, NULL);
5576         return TRUE;
5577 }
5578
5579 static const char *tun_valid_modes[] = { "tun", "tap", "unknown", NULL };
5580
5581 DEFINE_ALLOWED_VAL_FUNC (nmc_property_tun_allowed_mode, tun_valid_modes)
5582
5583 /*----------------------------------------------------------------------------*/
5584
5585 static inline void
5586 _nmc_add_prop_funcs (const char *key,
5587                      const NmcPropertyFuncs *item_init)
5588 {
5589         NmcPropertyFuncs *item;
5590
5591         item = g_malloc (sizeof (NmcPropertyFuncs));
5592         *item = *item_init;
5593         g_hash_table_insert (nmc_properties, (gpointer) key, item);
5594 }
5595
5596 #define nmc_add_prop_funcs(key, ...) \
5597         G_STMT_START { \
5598                 struct { \
5599                         NmcPropertyFuncsFields; \
5600                         /* The _dummy field is here so that the last argument can be always
5601                          * NULL. That means every call to nmc_add_prop_funcs() below ends
5602                          * with a separate line "NULL);". */ \
5603                         gpointer _dummy; \
5604                 } _item_init = { \
5605                         __VA_ARGS__ \
5606                 };\
5607                 \
5608                 nm_assert (_item_init._dummy == NULL); \
5609                 _nmc_add_prop_funcs ("" key, (NmcPropertyFuncs *) &_item_init); \
5610         } G_STMT_END
5611
5612 /* concatenate setting name and property name */
5613 #define GLUE(A,B) "" NM_SETTING_##A##_SETTING_NAME "" NM_SETTING_##A##_##B ""
5614 #define GLUE_IP(A,B) "" NM_SETTING_IP##A##_CONFIG_SETTING_NAME "" NM_SETTING_IP_CONFIG_##B ""
5615
5616 void
5617 nmc_properties_init (void)
5618 {
5619         if (G_LIKELY (nmc_properties))
5620                 return;
5621
5622         /* create properties hash table */
5623         nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
5624
5625         /* Add editable properties for NM_SETTING_802_1X_SETTING_NAME */
5626         nmc_add_prop_funcs (GLUE (802_1X, EAP),
5627                             nmc_property_802_1X_get_eap,
5628                             nmc_property_802_1X_set_eap,
5629                             nmc_property_802_1X_remove_eap,
5630                             NULL,
5631                             nmc_property_802_1X_allowed_eap,
5632                             NULL);
5633         nmc_add_prop_funcs (GLUE (802_1X, IDENTITY),
5634                             nmc_property_802_1X_get_identity,
5635                             nmc_property_set_string,
5636                             NULL,
5637                             NULL,
5638                             NULL,
5639                             NULL);
5640         nmc_add_prop_funcs (GLUE (802_1X, ANONYMOUS_IDENTITY),
5641                             nmc_property_802_1X_get_anonymous_identity,
5642                             nmc_property_set_string,
5643                             NULL,
5644                             NULL,
5645                             NULL,
5646                             NULL);
5647         nmc_add_prop_funcs (GLUE (802_1X, PAC_FILE),
5648                             nmc_property_802_1X_get_pac_file,
5649                             nmc_property_set_string,
5650                             NULL,
5651                             NULL,
5652                             NULL,
5653                             NULL);
5654         nmc_add_prop_funcs (GLUE (802_1X, CA_CERT),
5655                             nmc_property_802_1X_get_ca_cert,
5656                             nmc_property_802_1X_set_ca_cert,
5657                             NULL,
5658                             nmc_property_802_1X_describe_ca_cert,
5659                             NULL,
5660                             NULL);
5661         nmc_add_prop_funcs (GLUE (802_1X, CA_PATH),
5662                             nmc_property_802_1X_get_ca_path,
5663                             nmc_property_set_string,
5664                             NULL,
5665                             NULL,
5666                             NULL,
5667                             NULL);
5668         nmc_add_prop_funcs (GLUE (802_1X, SUBJECT_MATCH),
5669                             nmc_property_802_1X_get_subject_match,
5670                             nmc_property_set_string,
5671                             NULL,
5672                             NULL,
5673                             NULL,
5674                             NULL);
5675         nmc_add_prop_funcs (GLUE (802_1X, ALTSUBJECT_MATCHES),
5676                             nmc_property_802_1X_get_altsubject_matches,
5677                             nmc_property_802_1X_set_altsubject_matches,
5678                             nmc_property_802_1X_remove_altsubject_matches,
5679                             NULL,
5680                             NULL,
5681                             NULL);
5682         nmc_add_prop_funcs (GLUE (802_1X, DOMAIN_SUFFIX_MATCH),
5683                             nmc_property_802_1X_get_domain_suffix_match,
5684                             nmc_property_set_string,
5685                             NULL,
5686                             NULL,
5687                             NULL,
5688                             NULL);
5689         nmc_add_prop_funcs (GLUE (802_1X, CLIENT_CERT),
5690                             nmc_property_802_1X_get_client_cert,
5691                             nmc_property_802_1X_set_client_cert,
5692                             NULL,
5693                             nmc_property_802_1X_describe_client_cert,
5694                             NULL,
5695                             NULL);
5696         nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPVER),
5697                             nmc_property_802_1X_get_phase1_peapver,
5698                             nmc_property_802_1X_set_phase1_peapver,
5699                             NULL,
5700                             NULL,
5701                             nmc_property_802_1X_allowed_phase1_peapver,
5702                             NULL);
5703         nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPLABEL),
5704                             nmc_property_802_1X_get_phase1_peaplabel,
5705                             nmc_property_802_1X_set_phase1_peaplabel,
5706                             NULL,
5707                             NULL,
5708                             nmc_property_802_1X_allowed_phase1_peaplabel,
5709                             NULL);
5710         nmc_add_prop_funcs (GLUE (802_1X, PHASE1_FAST_PROVISIONING),
5711                             nmc_property_802_1X_get_phase1_fast_provisioning,
5712                             nmc_property_802_1X_set_phase1_fast_provisioning,
5713                             NULL,
5714                             NULL,
5715                             nmc_property_802_1X_allowed_phase1_fast_provisioning,
5716                             NULL);
5717         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTH),
5718                             nmc_property_802_1X_get_phase2_auth,
5719                             nmc_property_802_1X_set_phase2_auth,
5720                             NULL,
5721                             NULL,
5722                             nmc_property_802_1X_allowed_phase2_auth,
5723                             NULL);
5724         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTHEAP),
5725                             nmc_property_802_1X_get_phase2_autheap,
5726                             nmc_property_802_1X_set_phase2_autheap,
5727                             NULL,
5728                             NULL,
5729                             nmc_property_802_1X_allowed_phase2_autheap,
5730                             NULL);
5731         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_CERT),
5732                             nmc_property_802_1X_get_phase2_ca_cert,
5733                             nmc_property_802_1X_set_phase2_ca_cert,
5734                             NULL,
5735                             nmc_property_802_1X_describe_phase2_ca_cert,
5736                             NULL,
5737                             NULL);
5738         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_PATH),
5739                             nmc_property_802_1X_get_phase2_ca_path,
5740                             nmc_property_set_string,
5741                             NULL,
5742                             NULL,
5743                             NULL,
5744                             NULL);
5745         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_SUBJECT_MATCH),
5746                             nmc_property_802_1X_get_phase2_subject_match,
5747                             nmc_property_set_string,
5748                             NULL,
5749                             NULL,
5750                             NULL,
5751                             NULL);
5752         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_ALTSUBJECT_MATCHES),
5753                             nmc_property_802_1X_get_phase2_altsubject_matches,
5754                             nmc_property_802_1X_set_phase2_altsubject_matches,
5755                             nmc_property_802_1X_remove_phase2_altsubject_matches,
5756                             NULL,
5757                             NULL,
5758                             NULL);
5759         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_DOMAIN_SUFFIX_MATCH),
5760                             nmc_property_802_1X_get_phase2_domain_suffix_match,
5761                             nmc_property_set_string,
5762                             NULL,
5763                             NULL,
5764                             NULL,
5765                             NULL);
5766         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CLIENT_CERT),
5767                             nmc_property_802_1X_get_phase2_client_cert,
5768                             nmc_property_802_1X_set_phase2_client_cert,
5769                             NULL,
5770                             nmc_property_802_1X_describe_phase2_client_cert,
5771                             NULL,
5772                             NULL);
5773         nmc_add_prop_funcs (GLUE (802_1X, PASSWORD),
5774                             nmc_property_802_1X_get_password,
5775                             nmc_property_set_string,
5776                             NULL,
5777                             NULL,
5778                             NULL,
5779                             NULL);
5780         nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_FLAGS),
5781                             nmc_property_802_1X_get_password_flags,
5782                             nmc_property_set_secret_flags,
5783                             NULL,
5784                             NULL,
5785                             NULL,
5786                             NULL);
5787         nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW),
5788                             nmc_property_802_1X_get_password_raw,
5789                             nmc_property_802_1X_set_password_raw,
5790                             NULL,
5791                             nmc_property_802_1X_describe_password_raw,
5792                             NULL,
5793                             NULL);
5794         nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW_FLAGS),
5795                             nmc_property_802_1X_get_password_raw_flags,
5796                             nmc_property_set_secret_flags,
5797                             NULL,
5798                             NULL,
5799                             NULL,
5800                             NULL);
5801         nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY),
5802                             nmc_property_802_1X_get_private_key,
5803                             nmc_property_802_1X_set_private_key,
5804                             NULL,
5805                             nmc_property_802_1X_describe_private_key,
5806                             NULL,
5807                             NULL);
5808         nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD),
5809                             nmc_property_802_1X_get_private_key_password,
5810                             nmc_property_set_string,
5811                             NULL,
5812                             NULL,
5813                             NULL,
5814                             NULL);
5815         nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD_FLAGS),
5816                             nmc_property_802_1X_get_private_key_password_flags,
5817                             nmc_property_set_secret_flags,
5818                             NULL,
5819                             NULL,
5820                             NULL,
5821                             NULL);
5822         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY),
5823                             nmc_property_802_1X_get_phase2_private_key,
5824                             nmc_property_802_1X_set_phase2_private_key,
5825                             NULL,
5826                             nmc_property_802_1X_describe_private_key,
5827                             NULL,
5828                             NULL);
5829         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD),
5830                             nmc_property_802_1X_get_phase2_private_key_password,
5831                             nmc_property_set_string,
5832                             NULL,
5833                             NULL,
5834                             NULL,
5835                             NULL);
5836         nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD_FLAGS),
5837                             nmc_property_802_1X_get_phase2_private_key_password_flags,
5838                             nmc_property_set_secret_flags,
5839                             NULL,
5840                             NULL,
5841                             NULL,
5842                             NULL);
5843         nmc_add_prop_funcs (GLUE (802_1X, PIN),
5844                             nmc_property_802_1X_get_pin,
5845                             nmc_property_set_string,
5846                             NULL,
5847                             NULL,
5848                             NULL,
5849                             NULL);
5850         nmc_add_prop_funcs (GLUE (802_1X, PIN_FLAGS),
5851                             nmc_property_802_1X_get_pin_flags,
5852                             nmc_property_set_secret_flags,
5853                             NULL,
5854                             NULL,
5855                             NULL,
5856                             NULL);
5857         nmc_add_prop_funcs (GLUE (802_1X, SYSTEM_CA_CERTS),
5858                             nmc_property_802_1X_get_system_ca_certs,
5859                             nmc_property_set_bool,
5860                             NULL,
5861                             NULL,
5862                             NULL,
5863                             NULL);
5864
5865         /* Add editable properties for NM_SETTING_ADSL_SETTING_NAME */
5866         nmc_add_prop_funcs (GLUE (ADSL, USERNAME),
5867                             nmc_property_adsl_get_username,
5868                             nmc_property_set_string,
5869                             NULL,
5870                             NULL,
5871                             NULL,
5872                             NULL);
5873         nmc_add_prop_funcs (GLUE (ADSL, PASSWORD),
5874                             nmc_property_adsl_get_password,
5875                             nmc_property_set_string,
5876                             NULL,
5877                             NULL,
5878                             NULL,
5879                             NULL);
5880         nmc_add_prop_funcs (GLUE (ADSL, PASSWORD_FLAGS),
5881                             nmc_property_adsl_get_password_flags,
5882                             nmc_property_set_secret_flags,
5883                             NULL,
5884                             NULL,
5885                             NULL,
5886                             NULL);
5887         nmc_add_prop_funcs (GLUE (ADSL, PROTOCOL),
5888                             nmc_property_adsl_get_protocol,
5889                             nmc_property_adsl_set_protocol,
5890                             NULL,
5891                             NULL,
5892                             nmc_property_adsl_allowed_protocol,
5893                             NULL);
5894         nmc_add_prop_funcs (GLUE (ADSL, ENCAPSULATION),
5895                             nmc_property_adsl_get_encapsulation,
5896                             nmc_property_adsl_set_encapsulation,
5897                             NULL,
5898                             NULL,
5899                             nmc_property_adsl_allowed_encapsulation,
5900                             NULL);
5901         nmc_add_prop_funcs (GLUE (ADSL, VPI),
5902                             nmc_property_adsl_get_vpi,
5903                             nmc_property_set_uint,
5904                             NULL,
5905                             NULL,
5906                             NULL,
5907                             NULL);
5908         nmc_add_prop_funcs (GLUE (ADSL, VCI),
5909                             nmc_property_adsl_get_vci,
5910                             nmc_property_set_uint,
5911                             NULL,
5912                             NULL,
5913                             NULL,
5914                             NULL);
5915
5916         /* Add editable properties for NM_SETTING_BLUETOOTH_SETTING_NAME */
5917         nmc_add_prop_funcs (GLUE (BLUETOOTH, BDADDR),
5918                             nmc_property_bluetooth_get_bdaddr,
5919                             nmc_property_set_mac,
5920                             NULL,
5921                             NULL,
5922                             NULL,
5923                             NULL);
5924         nmc_add_prop_funcs (GLUE (BLUETOOTH, TYPE),
5925                             nmc_property_bluetooth_get_type,
5926                             nmc_property_bluetooth_set_type,
5927                             NULL,
5928                             NULL,
5929                             NULL,
5930                             NULL);
5931
5932         /* Add editable properties for NM_SETTING_BOND_SETTING_NAME */
5933         nmc_add_prop_funcs (GLUE (BOND, OPTIONS),
5934                             nmc_property_bond_get_options,
5935                             nmc_property_bond_set_options,
5936                             nmc_property_bond_remove_option_options,
5937                             nmc_property_bond_describe_options,
5938                             nmc_property_bond_allowed_options,
5939                             NULL);
5940
5941         /* Add editable properties for NM_SETTING_BRIDGE_SETTING_NAME */
5942         nmc_add_prop_funcs (GLUE (BRIDGE, MAC_ADDRESS),
5943                             nmc_property_bridge_get_mac_address,
5944                             nmc_property_set_mac,
5945                             NULL,
5946                             NULL,
5947                             NULL,
5948                             NULL);
5949         nmc_add_prop_funcs (GLUE (BRIDGE, STP),
5950                             nmc_property_bridge_get_stp,
5951                             nmc_property_set_bool,
5952                             NULL,
5953                             NULL,
5954                             NULL,
5955                             NULL);
5956         nmc_add_prop_funcs (GLUE (BRIDGE, PRIORITY),
5957                             nmc_property_bridge_get_priority,
5958                             nmc_property_set_uint,
5959                             NULL,
5960                             NULL,
5961                             NULL,
5962                             NULL);
5963         nmc_add_prop_funcs (GLUE (BRIDGE, FORWARD_DELAY),
5964                             nmc_property_bridge_get_forward_delay,
5965                             nmc_property_set_uint,
5966                             NULL,
5967                             NULL,
5968                             NULL,
5969                             NULL);
5970         nmc_add_prop_funcs (GLUE (BRIDGE, HELLO_TIME),
5971                             nmc_property_bridge_get_hello_time,
5972                             nmc_property_set_uint,
5973                             NULL,
5974                             NULL,
5975                             NULL,
5976                             NULL);
5977         nmc_add_prop_funcs (GLUE (BRIDGE, MAX_AGE),
5978                             nmc_property_bridge_get_max_age,
5979                             nmc_property_set_uint,
5980                             NULL,
5981                             NULL,
5982                             NULL,
5983                             NULL);
5984         nmc_add_prop_funcs (GLUE (BRIDGE, AGEING_TIME),
5985                             nmc_property_bridge_get_ageing_time,
5986                             nmc_property_set_uint,
5987                             NULL,
5988                             NULL,
5989                             NULL,
5990                             NULL);
5991
5992         nmc_add_prop_funcs (GLUE (BRIDGE, MULTICAST_SNOOPING),
5993                             nmc_property_bridge_get_multicast_snooping,
5994                             nmc_property_set_bool,
5995                             NULL,
5996                             NULL,
5997                             NULL,
5998                             NULL);
5999
6000         /* Add editable properties for NM_SETTING_BRIDGE_PORT_SETTING_NAME */
6001         nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PRIORITY),
6002                             nmc_property_bridge_port_get_priority,
6003                             nmc_property_set_uint,
6004                             NULL,
6005                             NULL,
6006                             NULL,
6007                             NULL);
6008         nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PATH_COST),
6009                             nmc_property_bridge_port_get_path_cost,
6010                             nmc_property_set_uint,
6011                             NULL,
6012                             NULL,
6013                             NULL,
6014                             NULL);
6015         nmc_add_prop_funcs (GLUE (BRIDGE_PORT, HAIRPIN_MODE),
6016                             nmc_property_bridge_port_get_hairpin_mode,
6017                             nmc_property_set_bool,
6018                             NULL,
6019                             NULL,
6020                             NULL,
6021                             NULL);
6022
6023         /* Add editable properties for NM_SETTING_CDMA_SETTING_NAME */
6024         nmc_add_prop_funcs (GLUE (CDMA, NUMBER),
6025                             nmc_property_cdma_get_number,
6026                             nmc_property_set_string,
6027                             NULL,
6028                             NULL,
6029                             NULL,
6030                             NULL);
6031         nmc_add_prop_funcs (GLUE (CDMA, USERNAME),
6032                             nmc_property_cdma_get_username,
6033                             nmc_property_set_string,
6034                             NULL,
6035                             NULL,
6036                             NULL,
6037                             NULL);
6038         nmc_add_prop_funcs (GLUE (CDMA, PASSWORD),
6039                             nmc_property_cdma_get_password,
6040                             nmc_property_set_string,
6041                             NULL,
6042                             NULL,
6043                             NULL,
6044                             NULL);
6045         nmc_add_prop_funcs (GLUE (CDMA, PASSWORD_FLAGS),
6046                             nmc_property_cdma_get_password_flags,
6047                             nmc_property_set_secret_flags,
6048                             NULL,
6049                             NULL,
6050                             NULL,
6051                             NULL);
6052
6053         /* Add editable properties for NM_SETTING_CONNECTION_SETTING_NAME */
6054         nmc_add_prop_funcs (GLUE (CONNECTION, ID),
6055                             nmc_property_connection_get_id,
6056                             nmc_property_set_string,
6057                             NULL,
6058                             NULL,
6059                             NULL,
6060                             NULL);
6061         nmc_add_prop_funcs (GLUE (CONNECTION, UUID),
6062                             nmc_property_connection_get_uuid,
6063                             NULL, /* forbid setting/removing UUID */
6064                             NULL,
6065                             NULL,
6066                             NULL,
6067                             NULL);
6068         nmc_add_prop_funcs (GLUE (CONNECTION, INTERFACE_NAME),
6069                             nmc_property_connection_get_interface_name,
6070                             nmc_property_set_ifname,
6071                             NULL,
6072                             NULL,
6073                             NULL,
6074                             NULL);
6075         nmc_add_prop_funcs (GLUE (CONNECTION, TYPE),
6076                             nmc_property_connection_get_type,
6077                             NULL, /* read-only */
6078                             NULL,
6079                             NULL,
6080                             NULL,
6081                             NULL);
6082         nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT),
6083                             nmc_property_connection_get_autoconnect,
6084                             nmc_property_set_bool,
6085                             NULL,
6086                             NULL,
6087                             NULL,
6088                             NULL);
6089         nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_PRIORITY),
6090                             nmc_property_connection_get_autoconnect_priority,
6091                             nmc_property_set_int,
6092                             NULL,
6093                             NULL,
6094                             NULL,
6095                             NULL);
6096         nmc_add_prop_funcs (GLUE (CONNECTION, TIMESTAMP),
6097                             nmc_property_connection_get_timestamp,
6098                             NULL, /* read-only */
6099                             NULL,
6100                             NULL,
6101                             NULL,
6102                             NULL);
6103         nmc_add_prop_funcs (GLUE (CONNECTION, READ_ONLY),
6104                             nmc_property_connection_get_read_only,
6105                             NULL, /* 'read-only' is read-only :-) */
6106                             NULL,
6107                             NULL,
6108                             NULL,
6109                             NULL);
6110         nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS),
6111                             nmc_property_connection_get_permissions,
6112                             nmc_property_connection_set_permissions,
6113                             nmc_property_connection_remove_permissions,
6114                             nmc_property_connection_describe_permissions,
6115                             NULL,
6116                             NULL);
6117         nmc_add_prop_funcs (GLUE (CONNECTION, ZONE),
6118                             nmc_property_connection_get_zone,
6119                             nmc_property_set_string,
6120                             NULL,
6121                             NULL,
6122                             NULL,
6123                             NULL);
6124         nmc_add_prop_funcs (GLUE (CONNECTION, MASTER),
6125                             nmc_property_connection_get_master,
6126                             nmc_property_con_set_master,
6127                             NULL,
6128                             NULL,
6129                             NULL,
6130                             NULL);
6131         nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE),
6132                             nmc_property_connection_get_slave_type,
6133                             nmc_property_con_set_slave_type,
6134                             NULL,
6135                             NULL,
6136                             nmc_property_con_allowed_slave_type,
6137                             NULL);
6138         nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_SLAVES),
6139                             nmc_property_connection_get_autoconnect_slaves,
6140                             nmc_property_set_trilean,
6141                             NULL,
6142                             NULL,
6143                             NULL,
6144                             NULL);
6145         nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES),
6146                             nmc_property_connection_get_secondaries,
6147                             nmc_property_connection_set_secondaries,
6148                             nmc_property_connection_remove_secondaries,
6149                             nmc_property_connection_describe_secondaries,
6150                             NULL,
6151                             NULL);
6152         nmc_add_prop_funcs (GLUE (CONNECTION, GATEWAY_PING_TIMEOUT),
6153                             nmc_property_connection_get_gateway_ping_timeout,
6154                             nmc_property_set_uint,
6155                             NULL,
6156                             NULL,
6157                             NULL,
6158                             NULL);
6159         nmc_add_prop_funcs (GLUE (CONNECTION, METERED),
6160                             nmc_property_connection_get_metered,
6161                             nmc_property_connection_set_metered,
6162                             NULL,
6163                             nmc_property_connection_describe_metered,
6164                             NULL,
6165                             NULL);
6166         nmc_add_prop_funcs (GLUE (CONNECTION, LLDP),
6167                             nmc_property_connection_get_lldp,
6168                             nmc_property_connection_set_lldp,
6169                             NULL,
6170                             NULL,
6171                             NULL,
6172                             NULL);
6173
6174         /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */
6175         nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_FLAGS),
6176                             nmc_property_dcb_get_app_fcoe_flags,
6177                             nmc_property_dcb_set_flags,
6178                             NULL,
6179                             NULL,
6180                             NULL,
6181                             NULL);
6182         nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_MODE),
6183                             nmc_property_dcb_get_app_fcoe_mode,
6184                             nmc_property_dcb_set_app_fcoe_mode,
6185                             NULL,
6186                             NULL,
6187                             nmc_property_dcb_allowed_app_fcoe_modes,
6188                             NULL);
6189         nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_PRIORITY),
6190                             nmc_property_dcb_get_app_fcoe_priority,
6191                             nmc_property_dcb_set_priority,
6192                             NULL,
6193                             NULL,
6194                             NULL,
6195                             NULL);
6196         nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_FLAGS),
6197                             nmc_property_dcb_get_app_iscsi_flags,
6198                             nmc_property_dcb_set_flags,
6199                             NULL,
6200                             NULL,
6201                             NULL,
6202                             NULL);
6203         nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_PRIORITY),
6204                             nmc_property_dcb_get_app_iscsi_priority,
6205                             nmc_property_dcb_set_priority,
6206                             NULL,
6207                             NULL,
6208                             NULL,
6209                             NULL);
6210         nmc_add_prop_funcs (GLUE (DCB, APP_FIP_FLAGS),
6211                             nmc_property_dcb_get_app_fip_flags,
6212                             nmc_property_dcb_set_flags,
6213                             NULL,
6214                             NULL,
6215                             NULL,
6216                             NULL);
6217         nmc_add_prop_funcs (GLUE (DCB, APP_FIP_PRIORITY),
6218                             nmc_property_dcb_get_app_fip_priority,
6219                             nmc_property_dcb_set_priority,
6220                             NULL,
6221                             NULL,
6222                             NULL,
6223                             NULL);
6224         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL_FLAGS),
6225                             nmc_property_dcb_get_pfc_flags,
6226                             nmc_property_dcb_set_flags,
6227                             NULL,
6228                             NULL,
6229                             NULL,
6230                             NULL);
6231         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL),
6232                             nmc_property_dcb_get_pfc,
6233                             nmc_property_dcb_set_pfc,
6234                             NULL,
6235                             NULL,
6236                             NULL,
6237                             NULL);
6238         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_FLAGS),
6239                             nmc_property_dcb_get_pg_flags,
6240                             nmc_property_dcb_set_flags,
6241                             NULL,
6242                             NULL,
6243                             NULL,
6244                             NULL);
6245         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_ID),
6246                             nmc_property_dcb_get_pg_group_id,
6247                             nmc_property_dcb_set_pg_group_id,
6248                             NULL,
6249                             NULL,
6250                             NULL,
6251                             NULL);
6252         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_BANDWIDTH),
6253                             nmc_property_dcb_get_pg_group_bandwidth,
6254                             nmc_property_dcb_set_pg_group_bandwidth,
6255                             NULL,
6256                             NULL,
6257                             NULL,
6258                             NULL);
6259         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_BANDWIDTH),
6260                             nmc_property_dcb_get_pg_bandwidth,
6261                             nmc_property_dcb_set_pg_bandwidth,
6262                             NULL,
6263                             NULL,
6264                             NULL,
6265                             NULL);
6266         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_STRICT_BANDWIDTH),
6267                             nmc_property_dcb_get_pg_strict,
6268                             nmc_property_dcb_set_pg_strict,
6269                             NULL,
6270                             NULL,
6271                             NULL,
6272                             NULL);
6273         nmc_add_prop_funcs (GLUE (DCB, PRIORITY_TRAFFIC_CLASS),
6274                             nmc_property_dcb_get_pg_traffic_class,
6275                             nmc_property_dcb_set_pg_traffic_class,
6276                             NULL,
6277                             NULL,
6278                             NULL,
6279                             NULL);
6280
6281         /* Add editable properties for NM_SETTING_GSM_SETTING_NAME */
6282         nmc_add_prop_funcs (GLUE (GSM, NUMBER),
6283                             nmc_property_gsm_get_number,
6284                             nmc_property_set_string,
6285                             NULL,
6286                             NULL,
6287                             NULL,
6288                             NULL);
6289         nmc_add_prop_funcs (GLUE (GSM, USERNAME),
6290                             nmc_property_gsm_get_username,
6291                             nmc_property_set_string,
6292                             NULL,
6293                             NULL,
6294                             NULL,
6295                             NULL);
6296         nmc_add_prop_funcs (GLUE (GSM, PASSWORD),
6297                             nmc_property_gsm_get_password,
6298                             nmc_property_set_string,
6299                             NULL,
6300                             NULL,
6301                             NULL,
6302                             NULL);
6303         nmc_add_prop_funcs (GLUE (GSM, PASSWORD_FLAGS),
6304                             nmc_property_gsm_get_password_flags,
6305                             nmc_property_set_secret_flags,
6306                             NULL,
6307                             NULL,
6308                             NULL,
6309                             NULL);
6310         nmc_add_prop_funcs (GLUE (GSM, APN),
6311                             nmc_property_gsm_get_apn,
6312                             nmc_property_set_string,
6313                             NULL,
6314                             NULL,
6315                             NULL,
6316                             NULL);
6317         nmc_add_prop_funcs (GLUE (GSM, NETWORK_ID),
6318                             nmc_property_gsm_get_network_id,
6319                             nmc_property_set_string,
6320                             NULL,
6321                             NULL,
6322                             NULL,
6323                             NULL);
6324         nmc_add_prop_funcs (GLUE (GSM, PIN),
6325                             nmc_property_gsm_get_pin,
6326                             nmc_property_set_string,
6327                             NULL,
6328                             NULL,
6329                             NULL,
6330                             NULL);
6331         nmc_add_prop_funcs (GLUE (GSM, PIN_FLAGS),
6332                             nmc_property_gsm_get_pin_flags,
6333                             nmc_property_set_secret_flags,
6334                             NULL,
6335                             NULL,
6336                             NULL,
6337                             NULL);
6338         nmc_add_prop_funcs (GLUE (GSM, HOME_ONLY),
6339                             nmc_property_gsm_get_home_only,
6340                             nmc_property_set_bool,
6341                             NULL,
6342                             NULL,
6343                             NULL,
6344                             NULL);
6345         nmc_add_prop_funcs (GLUE (GSM, DEVICE_ID),
6346                             nmc_property_gsm_get_device_id,
6347                             nmc_property_set_string,
6348                             NULL,
6349                             NULL,
6350                             NULL,
6351                             NULL);
6352         nmc_add_prop_funcs (GLUE (GSM, SIM_ID),
6353                             nmc_property_gsm_get_sim_id,
6354                             nmc_property_set_string,
6355                             NULL,
6356                             NULL,
6357                             NULL,
6358                             NULL);
6359         nmc_add_prop_funcs (GLUE (GSM, SIM_OPERATOR_ID),
6360                             nmc_property_gsm_get_sim_operator_id,
6361                             nmc_property_gsm_set_sim_operator_id,
6362                             NULL,
6363                             NULL,
6364                             NULL,
6365                             NULL);
6366
6367         /* Add editable properties for NM_SETTING_INFINIBAND_SETTING_NAME */
6368         nmc_add_prop_funcs (GLUE (INFINIBAND, MAC_ADDRESS),
6369                             nmc_property_ib_get_mac_address,
6370                             nmc_property_ib_set_mac,
6371                             NULL,
6372                             NULL,
6373                             NULL,
6374                             NULL);
6375         nmc_add_prop_funcs (GLUE (INFINIBAND, MTU),
6376                             nmc_property_ib_get_mtu,
6377                             nmc_property_set_mtu,
6378                             NULL,
6379                             NULL,
6380                             NULL,
6381                             NULL);
6382         nmc_add_prop_funcs (GLUE (INFINIBAND, TRANSPORT_MODE),
6383                             nmc_property_ib_get_transport_mode,
6384                             nmc_property_ib_set_transport_mode,
6385                             NULL,
6386                             NULL,
6387                             nmc_property_ib_allowed_transport_mode,
6388                             NULL);
6389         nmc_add_prop_funcs (GLUE (INFINIBAND, P_KEY),
6390                             nmc_property_ib_get_p_key,
6391                             nmc_property_ib_set_p_key,
6392                             NULL,
6393                             NULL,
6394                             NULL,
6395                             NULL);
6396         nmc_add_prop_funcs (GLUE (INFINIBAND, PARENT),
6397                             nmc_property_ib_get_parent,
6398                             nmc_property_set_ifname,
6399                             NULL,
6400                             NULL,
6401                             NULL,
6402                             NULL);
6403
6404         /* Add editable properties for NM_SETTING_IP4_CONFIG_SETTING_NAME */
6405         nmc_add_prop_funcs (GLUE_IP (4, METHOD),
6406                             nmc_property_ipv4_get_method,
6407                             nmc_property_ipv4_set_method,
6408                             NULL,
6409                             NULL,
6410                             nmc_property_ipv4_allowed_method,
6411                             NULL);
6412         nmc_add_prop_funcs (GLUE_IP (4, DNS),
6413                             nmc_property_ipv4_get_dns,
6414                             nmc_property_ipv4_set_dns,
6415                             nmc_property_ipv4_remove_dns,
6416                             nmc_property_ipv4_describe_dns,
6417                             NULL,
6418                             NULL);
6419         nmc_add_prop_funcs (GLUE_IP (4, DNS_SEARCH),
6420                             nmc_property_ipv4_get_dns_search,
6421                             nmc_property_ipv4_set_dns_search,
6422                             nmc_property_ipv4_remove_dns_search,
6423                             NULL,
6424                             NULL,
6425                             NULL);
6426         nmc_add_prop_funcs (GLUE_IP (4, DNS_OPTIONS),
6427                             nmc_property_ipv4_get_dns_options,
6428                             nmc_property_ipv4_set_dns_options,
6429                             nmc_property_ipv4_remove_dns_option,
6430                             NULL,
6431                             NULL,
6432                             NULL);
6433         nmc_add_prop_funcs (GLUE_IP (4, ADDRESSES),
6434                             nmc_property_ip_get_addresses,
6435                             nmc_property_ipv4_set_addresses,
6436                             nmc_property_ipv4_remove_addresses,
6437                             nmc_property_ipv4_describe_addresses,
6438                             NULL,
6439                             NULL);
6440         nmc_add_prop_funcs (GLUE_IP (4, GATEWAY),
6441                             nmc_property_ipv4_get_gateway,
6442                             nmc_property_ipv4_set_gateway,
6443                             NULL,
6444                             NULL,
6445                             NULL,
6446                             NULL);
6447         nmc_add_prop_funcs (GLUE_IP (4, ROUTES),
6448                             nmc_property_ipv4_get_routes,
6449                             nmc_property_ipv4_set_routes,
6450                             nmc_property_ipv4_remove_routes,
6451                             nmc_property_ipv4_describe_routes,
6452                             NULL,
6453                             NULL);
6454         nmc_add_prop_funcs (GLUE_IP (4, ROUTE_METRIC),
6455                             nmc_property_ipv4_get_route_metric,
6456                             nmc_property_set_int64,
6457                             NULL,
6458                             NULL,
6459                             NULL,
6460                             NULL);
6461         nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_ROUTES),
6462                             nmc_property_ipv4_get_ignore_auto_routes,
6463                             nmc_property_set_bool,
6464                             NULL,
6465                             NULL,
6466                             NULL,
6467                             NULL);
6468         nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_DNS),
6469                             nmc_property_ipv4_get_ignore_auto_dns,
6470                             nmc_property_set_bool,
6471                             NULL,
6472                             NULL,
6473                             NULL,
6474                             NULL);
6475         nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_CLIENT_ID),
6476                             nmc_property_ipv4_get_dhcp_client_id,
6477                             nmc_property_set_string,
6478                             NULL,
6479                             NULL,
6480                             NULL,
6481                             NULL);
6482         nmc_add_prop_funcs (GLUE_IP (4, DHCP_TIMEOUT),
6483                             nmc_property_ipv4_get_dhcp_timeout,
6484                             nmc_property_set_int,
6485                             NULL,
6486                             NULL,
6487                             NULL,
6488                             NULL);
6489         nmc_add_prop_funcs (GLUE_IP (4, DHCP_SEND_HOSTNAME),
6490                             nmc_property_ipv4_get_dhcp_send_hostname,
6491                             nmc_property_set_bool,
6492                             NULL,
6493                             NULL,
6494                             NULL,
6495                             NULL);
6496         nmc_add_prop_funcs (GLUE_IP (4, DHCP_HOSTNAME),
6497                             nmc_property_ipv4_get_dhcp_hostname,
6498                             nmc_property_set_string,
6499                             NULL,
6500                             NULL,
6501                             NULL,
6502                             NULL);
6503         nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_FQDN),
6504                             nmc_property_ipv4_get_dhcp_fqdn,
6505                             nmc_property_set_string,
6506                             NULL,
6507                             NULL,
6508                             NULL,
6509                             NULL);
6510         nmc_add_prop_funcs (GLUE_IP (4, NEVER_DEFAULT),
6511                             nmc_property_ipv4_get_never_default,
6512                             nmc_property_set_bool,
6513                             NULL,
6514                             NULL,
6515                             NULL,
6516                             NULL);
6517         nmc_add_prop_funcs (GLUE_IP (4, MAY_FAIL),
6518                             nmc_property_ipv4_get_may_fail,
6519                             nmc_property_set_bool,
6520                             NULL,
6521                             NULL,
6522                             NULL,
6523                             NULL);
6524         nmc_add_prop_funcs (GLUE_IP (4, DAD_TIMEOUT),
6525                             nmc_property_ipv4_get_dad_timeout,
6526                             nmc_property_set_int,
6527                             NULL,
6528                             NULL,
6529                             NULL,
6530                             NULL);
6531
6532         /* Add editable properties for NM_SETTING_IP6_CONFIG_SETTING_NAME */
6533         nmc_add_prop_funcs (GLUE_IP (6, METHOD),
6534                             nmc_property_ipv6_get_method,
6535                             nmc_property_ipv6_set_method,
6536                             NULL,
6537                             NULL,
6538                             nmc_property_ipv6_allowed_method,
6539                             NULL);
6540         nmc_add_prop_funcs (GLUE_IP (6, DNS),
6541                             nmc_property_ipv6_get_dns,
6542                             nmc_property_ipv6_set_dns,
6543                             nmc_property_ipv6_remove_dns,
6544                             nmc_property_ipv6_describe_dns,
6545                             NULL,
6546                             NULL);
6547         nmc_add_prop_funcs (GLUE_IP (6, DNS_SEARCH),
6548                             nmc_property_ipv6_get_dns_search,
6549                             nmc_property_ipv6_set_dns_search,
6550                             nmc_property_ipv6_remove_dns_search,
6551                             NULL,
6552                             NULL,
6553                             NULL);
6554         nmc_add_prop_funcs (GLUE_IP (6, DNS_OPTIONS),
6555                             nmc_property_ipv6_get_dns_options,
6556                             nmc_property_ipv6_set_dns_options,
6557                             nmc_property_ipv6_remove_dns_option,
6558                             NULL,
6559                             NULL,
6560                             NULL);
6561         nmc_add_prop_funcs (GLUE_IP (6, ADDRESSES),
6562                             nmc_property_ip_get_addresses,
6563                             nmc_property_ipv6_set_addresses,
6564                             nmc_property_ipv6_remove_addresses,
6565                             nmc_property_ipv6_describe_addresses,
6566                             NULL,
6567                             NULL);
6568         nmc_add_prop_funcs (GLUE_IP (6, GATEWAY),
6569                             nmc_property_ipv6_get_gateway,
6570                             nmc_property_ipv6_set_gateway,
6571                             NULL,
6572                             NULL,
6573                             NULL,
6574                             NULL);
6575         nmc_add_prop_funcs (GLUE_IP (6, ROUTES),
6576                             nmc_property_ipv6_get_routes,
6577                             nmc_property_ipv6_set_routes,
6578                             nmc_property_ipv6_remove_routes,
6579                             nmc_property_ipv6_describe_routes,
6580                             NULL,
6581                             NULL);
6582         nmc_add_prop_funcs (GLUE_IP (6, ROUTE_METRIC),
6583                             nmc_property_ipv6_get_route_metric,
6584                             nmc_property_set_int64,
6585                             NULL,
6586                             NULL,
6587                             NULL,
6588                             NULL);
6589         nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_ROUTES),
6590                             nmc_property_ipv6_get_ignore_auto_routes,
6591                             nmc_property_set_bool,
6592                             NULL,
6593                             NULL,
6594                             NULL,
6595                             NULL);
6596         nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_DNS),
6597                             nmc_property_ipv6_get_ignore_auto_dns,
6598                             nmc_property_set_bool,
6599                             NULL,
6600                             NULL,
6601                             NULL,
6602                             NULL);
6603         nmc_add_prop_funcs (GLUE_IP (6, NEVER_DEFAULT),
6604                             nmc_property_ipv6_get_never_default,
6605                             nmc_property_set_bool,
6606                             NULL,
6607                             NULL,
6608                             NULL,
6609                             NULL);
6610         nmc_add_prop_funcs (GLUE_IP (6, MAY_FAIL),
6611                             nmc_property_ipv6_get_may_fail,
6612                             nmc_property_set_bool,
6613                             NULL,
6614                             NULL,
6615                             NULL,
6616                             NULL);
6617         nmc_add_prop_funcs (GLUE (IP6_CONFIG, IP6_PRIVACY),
6618                             nmc_property_ipv6_get_ip6_privacy,
6619                             nmc_property_ipv6_set_ip6_privacy,
6620                             NULL,
6621                             NULL,
6622                             NULL,
6623                             NULL);
6624         nmc_add_prop_funcs (GLUE (IP6_CONFIG, ADDR_GEN_MODE),
6625                             nmc_property_ipv6_get_addr_gen_mode,
6626                             nmc_property_ipv6_set_addr_gen_mode,
6627                             NULL,
6628                             NULL,
6629                             NULL,
6630                             NULL);
6631         nmc_add_prop_funcs (GLUE_IP (6, DHCP_SEND_HOSTNAME),
6632                             nmc_property_ipv6_get_dhcp_send_hostname,
6633                             nmc_property_set_bool,
6634                             NULL,
6635                             NULL,
6636                             NULL,
6637                             NULL);
6638         nmc_add_prop_funcs (GLUE_IP (6, DHCP_HOSTNAME),
6639                             nmc_property_ipv6_get_dhcp_hostname,
6640                             nmc_property_set_string,
6641                             NULL,
6642                             NULL,
6643                             NULL,
6644                             NULL);
6645
6646         /* Add editable properties for NM_SETTING_OLPC_MESH_SETTING_NAME */
6647         nmc_add_prop_funcs (GLUE (OLPC_MESH, SSID),
6648                             nmc_property_olpc_get_ssid,
6649                             nmc_property_set_ssid,
6650                             NULL,
6651                             NULL,
6652                             NULL,
6653                             NULL);
6654         nmc_add_prop_funcs (GLUE (OLPC_MESH, CHANNEL),
6655                             nmc_property_olpc_get_channel,
6656                             nmc_property_olpc_set_channel,
6657                             NULL,
6658                             NULL,
6659                             NULL,
6660                             NULL);
6661         nmc_add_prop_funcs (GLUE (OLPC_MESH, DHCP_ANYCAST_ADDRESS),
6662                             nmc_property_olpc_get_anycast_address,
6663                             nmc_property_set_mac,
6664                             NULL,
6665                             NULL,
6666                             NULL,
6667                             NULL);
6668
6669         /* Add editable properties for NM_SETTING_PPP_SETTING_NAME */
6670         nmc_add_prop_funcs (GLUE (PPP, NOAUTH),
6671                             nmc_property_ppp_get_noauth,
6672                             nmc_property_set_bool,
6673                             NULL,
6674                             NULL,
6675                             NULL,
6676                             NULL);
6677         nmc_add_prop_funcs (GLUE (PPP, REFUSE_EAP),
6678                             nmc_property_ppp_get_refuse_eap,
6679                             nmc_property_set_bool,
6680                             NULL,
6681                             NULL,
6682                             NULL,
6683                             NULL);
6684         nmc_add_prop_funcs (GLUE (PPP, REFUSE_PAP),
6685                             nmc_property_ppp_get_refuse_pap,
6686                             nmc_property_set_bool,
6687                             NULL,
6688                             NULL,
6689                             NULL,
6690                             NULL);
6691         nmc_add_prop_funcs (GLUE (PPP, REFUSE_CHAP),
6692                             nmc_property_ppp_get_refuse_chap,
6693                             nmc_property_set_bool,
6694                             NULL,
6695                             NULL,
6696                             NULL,
6697                             NULL);
6698         nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAP),
6699                             nmc_property_ppp_get_refuse_mschap,
6700                             nmc_property_set_bool,
6701                             NULL,
6702                             NULL,
6703                             NULL,
6704                             NULL);
6705         nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAPV2),
6706                             nmc_property_ppp_get_refuse_mschapv2,
6707                             nmc_property_set_bool,
6708                             NULL,
6709                             NULL,
6710                             NULL,
6711                             NULL);
6712         nmc_add_prop_funcs (GLUE (PPP, NOBSDCOMP),
6713                             nmc_property_ppp_get_nobsdcomp,
6714                             nmc_property_set_bool,
6715                             NULL,
6716                             NULL,
6717                             NULL,
6718                             NULL);
6719         nmc_add_prop_funcs (GLUE (PPP, NODEFLATE),
6720                             nmc_property_ppp_get_nodeflate,
6721                             nmc_property_set_bool,
6722                             NULL,
6723                             NULL,
6724                             NULL,
6725                             NULL);
6726         nmc_add_prop_funcs (GLUE (PPP, NO_VJ_COMP),
6727                             nmc_property_ppp_get_no_vj_comp,
6728                             nmc_property_set_bool,
6729                             NULL,
6730                             NULL,
6731                             NULL,
6732                             NULL);
6733         nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE),
6734                             nmc_property_ppp_get_require_mppe,
6735                             nmc_property_set_bool,
6736                             NULL,
6737                             NULL,
6738                             NULL,
6739                             NULL);
6740         nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE_128),
6741                             nmc_property_ppp_get_require_mppe_128,
6742                             nmc_property_set_bool,
6743                             NULL,
6744                             NULL,
6745                             NULL,
6746                             NULL);
6747         nmc_add_prop_funcs (GLUE (PPP, MPPE_STATEFUL),
6748                             nmc_property_ppp_get_mppe_stateful,
6749                             nmc_property_set_bool,
6750                             NULL,
6751                             NULL,
6752                             NULL,
6753                             NULL);
6754         nmc_add_prop_funcs (GLUE (PPP, CRTSCTS),
6755                             nmc_property_ppp_get_crtscts,
6756                             nmc_property_set_bool,
6757                             NULL,
6758                             NULL,
6759                             NULL,
6760                             NULL);
6761         nmc_add_prop_funcs (GLUE (PPP, BAUD),
6762                             nmc_property_ppp_get_baud,
6763                             nmc_property_set_uint,
6764                             NULL,
6765                             NULL,
6766                             NULL,
6767                             NULL);
6768         nmc_add_prop_funcs (GLUE (PPP, MRU),
6769                             nmc_property_ppp_get_mru,
6770                             nmc_property_set_uint,
6771                             NULL,
6772                             NULL,
6773                             NULL,
6774                             NULL);
6775         nmc_add_prop_funcs (GLUE (PPP, MTU),
6776                             nmc_property_ppp_get_mtu,
6777                             nmc_property_set_mtu,
6778                             NULL,
6779                             NULL,
6780                             NULL,
6781                             NULL);
6782         nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_FAILURE),
6783                             nmc_property_ppp_get_lcp_echo_failure,
6784                             nmc_property_set_uint,
6785                             NULL,
6786                             NULL,
6787                             NULL,
6788                             NULL);
6789         nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_INTERVAL),
6790                             nmc_property_ppp_get_lcp_echo_interval,
6791                             nmc_property_set_uint,
6792                             NULL,
6793                             NULL,
6794                             NULL,
6795                             NULL);
6796
6797         /* Add editable properties for NM_SETTING_PPPOE_SETTING_NAME */
6798         nmc_add_prop_funcs (GLUE (PPPOE, SERVICE),
6799                             nmc_property_pppoe_get_service,
6800                             nmc_property_set_string,
6801                             NULL,
6802                             NULL,
6803                             NULL,
6804                             NULL);
6805         nmc_add_prop_funcs (GLUE (PPPOE, USERNAME),
6806                             nmc_property_pppoe_get_username,
6807                             nmc_property_set_string,
6808                             NULL,
6809                             NULL,
6810                             NULL,
6811                             NULL);
6812         nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD),
6813                             nmc_property_pppoe_get_password,
6814                             nmc_property_set_string,
6815                             NULL,
6816                             NULL,
6817                             NULL,
6818                             NULL);
6819         nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD_FLAGS),
6820                             nmc_property_pppoe_get_password_flags,
6821                             nmc_property_set_secret_flags,
6822                             NULL,
6823                             NULL,
6824                             NULL,
6825                             NULL);
6826
6827         /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */
6828         nmc_add_prop_funcs (GLUE (SERIAL, BAUD),
6829                             nmc_property_serial_get_baud,
6830                             nmc_property_set_uint,
6831                             NULL,
6832                             NULL,
6833                             NULL,
6834                             NULL);
6835         nmc_add_prop_funcs (GLUE (SERIAL, BITS),
6836                             nmc_property_serial_get_bits,
6837                             nmc_property_set_uint,
6838                             NULL,
6839                             NULL,
6840                             NULL,
6841                             NULL);
6842         nmc_add_prop_funcs (GLUE (SERIAL, PARITY),
6843                             nmc_property_serial_get_parity,
6844                             nmc_property_serial_set_parity,
6845                             NULL,
6846                             NULL,
6847                             NULL,
6848                             NULL);
6849         nmc_add_prop_funcs (GLUE (SERIAL, STOPBITS),
6850                             nmc_property_serial_get_stopbits,
6851                             nmc_property_set_uint,
6852                             NULL,
6853                             NULL,
6854                             NULL,
6855                             NULL);
6856         nmc_add_prop_funcs (GLUE (SERIAL, SEND_DELAY),
6857                             nmc_property_serial_get_send_delay,
6858                             nmc_property_set_uint,
6859                             NULL,
6860                             NULL,
6861                             NULL,
6862                             NULL);
6863
6864         /* Add editable properties for NM_SETTING_TEAM_SETTING_NAME */
6865         nmc_add_prop_funcs (GLUE (TEAM, CONFIG),
6866                             nmc_property_team_get_config,
6867                             nmc_property_team_set_config,
6868                             NULL,
6869                             nmc_property_team_describe_config,
6870                             NULL,
6871                             NULL);
6872
6873         /* Add editable properties for NM_SETTING_TEAM_PORT_SETTING_NAME */
6874         nmc_add_prop_funcs (GLUE (TEAM_PORT, CONFIG),
6875                             nmc_property_team_port_get_config,
6876                             nmc_property_team_set_config,
6877                             NULL,
6878                             nmc_property_team_describe_config,
6879                             NULL,
6880                             NULL);
6881
6882         /* Add editable properties for NM_SETTING_VLAN_SETTING_NAME */
6883         nmc_add_prop_funcs (GLUE (VLAN, PARENT),
6884                             nmc_property_vlan_get_parent,
6885                             nmc_property_set_string,
6886                             NULL,
6887                             NULL,
6888                             NULL,
6889                             NULL);
6890         nmc_add_prop_funcs (GLUE (VLAN, ID),
6891                             nmc_property_vlan_get_id,
6892                             nmc_property_set_uint,
6893                             NULL,
6894                             NULL,
6895                             NULL,
6896                             NULL);
6897         nmc_add_prop_funcs (GLUE (VLAN, FLAGS),
6898                             nmc_property_vlan_get_flags,
6899                             nmc_property_set_flags,
6900                             NULL,
6901                             NULL,
6902                             NULL,
6903                             NULL);
6904         nmc_add_prop_funcs (GLUE (VLAN, INGRESS_PRIORITY_MAP),
6905                             nmc_property_vlan_get_ingress_priority_map,
6906                             nmc_property_vlan_set_ingress_priority_map,
6907                             nmc_property_vlan_remove_ingress_priority_map,
6908                             NULL,
6909                             NULL,
6910                             NULL);
6911         nmc_add_prop_funcs (GLUE (VLAN, EGRESS_PRIORITY_MAP),
6912                             nmc_property_vlan_get_egress_priority_map,
6913                             nmc_property_vlan_set_egress_priority_map,
6914                             nmc_property_vlan_remove_egress_priority_map,
6915                             NULL,
6916                             NULL,
6917                             NULL);
6918
6919         /* Add editable properties for NM_SETTING_VPN_SETTING_NAME */
6920         nmc_add_prop_funcs (GLUE (VPN, SERVICE_TYPE),
6921                             nmc_property_vpn_get_service_type,
6922                             nmc_property_set_string,
6923                             NULL,
6924                             NULL,
6925                             NULL,
6926                             NULL);
6927         nmc_add_prop_funcs (GLUE (VPN, USER_NAME),
6928                             nmc_property_vpn_get_user_name,
6929                             nmc_property_set_string,
6930                             NULL,
6931                             NULL,
6932                             NULL,
6933                             NULL);
6934         nmc_add_prop_funcs (GLUE (VPN, DATA),
6935                             nmc_property_vpn_get_data,
6936                             nmc_property_vpn_set_data,
6937                             nmc_property_vpn_remove_option_data,
6938                             NULL,
6939                             NULL,
6940                             NULL);
6941         nmc_add_prop_funcs (GLUE (VPN, SECRETS),
6942                             nmc_property_vpn_get_secrets,
6943                             nmc_property_vpn_set_secrets,
6944                             nmc_property_vpn_remove_option_secret,
6945                             NULL,
6946                             NULL,
6947                             NULL);
6948         nmc_add_prop_funcs (GLUE (VPN, PERSISTENT),
6949                             nmc_property_vpn_get_persistent,
6950                             nmc_property_set_bool,
6951                             NULL,
6952                             NULL,
6953                             NULL,
6954                             NULL);
6955
6956         nmc_add_prop_funcs (GLUE (VPN, TIMEOUT),
6957                             nmc_property_vpn_get_timeout,
6958                             nmc_property_set_uint,
6959                             NULL,
6960                             NULL,
6961                             NULL,
6962                             NULL);
6963
6964         /* Add editable properties for NM_SETTING_WIMAX_SETTING_NAME */
6965         nmc_add_prop_funcs (GLUE (WIMAX, NETWORK_NAME),
6966                             nmc_property_wimax_get_network_name,
6967                             nmc_property_set_string,
6968                             NULL,
6969                             NULL,
6970                             NULL,
6971                             NULL);
6972         nmc_add_prop_funcs (GLUE (WIMAX, MAC_ADDRESS),
6973                             nmc_property_wimax_get_mac_address,
6974                             nmc_property_set_mac,
6975                             NULL,
6976                             NULL,
6977                             NULL,
6978                             NULL);
6979
6980         /* Add editable properties for NM_SETTING_WIRED_SETTING_NAME */
6981         nmc_add_prop_funcs (GLUE (WIRED, PORT),
6982                             nmc_property_wired_get_port,
6983                             NULL, /*nmc_property_wired_set_port,*/
6984                             NULL,
6985                             NULL,
6986                             NULL, /*nmc_property_wired_allowed_port,*/
6987                             NULL);
6988         nmc_add_prop_funcs (GLUE (WIRED, SPEED),
6989                             nmc_property_wired_get_speed,
6990                             NULL,
6991                             NULL,
6992                             NULL,
6993                             NULL,
6994                             NULL);
6995         nmc_add_prop_funcs (GLUE (WIRED, DUPLEX),
6996                             nmc_property_wired_get_duplex,
6997                             NULL, /*nmc_property_wired_set_duplex,*/
6998                             NULL,
6999                             NULL,
7000                             NULL,
7001                             NULL); /*nmc_property_wired_allowed_duplex);*/
7002         nmc_add_prop_funcs (GLUE (WIRED, AUTO_NEGOTIATE),
7003                             nmc_property_wired_get_auto_negotiate,
7004                             NULL,
7005                             NULL,
7006                             NULL,
7007                             NULL,
7008                             NULL);
7009         nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS),
7010                             nmc_property_wired_get_mac_address,
7011                             nmc_property_set_mac,
7012                             NULL,
7013                             NULL,
7014                             NULL,
7015                             NULL);
7016         nmc_add_prop_funcs (GLUE (WIRED, CLONED_MAC_ADDRESS),
7017                             nmc_property_wired_get_cloned_mac_address,
7018                             nmc_property_set_mac,
7019                             NULL,
7020                             NULL,
7021                             NULL,
7022                             NULL);
7023         nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS_BLACKLIST),
7024                             nmc_property_wired_get_mac_address_blacklist,
7025                             nmc_property_wired_set_mac_address_blacklist,
7026                             nmc_property_wired_remove_mac_address_blacklist,
7027                             NULL,
7028                             NULL,
7029                             NULL);
7030         nmc_add_prop_funcs (GLUE (WIRED, MTU),
7031                             nmc_property_wired_get_mtu,
7032                             nmc_property_set_mtu,
7033                             NULL,
7034                             NULL,
7035                             NULL,
7036                             NULL);
7037         nmc_add_prop_funcs (GLUE (WIRED, S390_SUBCHANNELS),
7038                             nmc_property_wired_get_s390_subchannels,
7039                             nmc_property_wired_set_s390_subchannels,
7040                             NULL,
7041                             nmc_property_wired_describe_s390_subchannels,
7042                             NULL,
7043                             NULL);
7044         nmc_add_prop_funcs (GLUE (WIRED, S390_NETTYPE),
7045                             nmc_property_wired_get_s390_nettype,
7046                             nmc_property_wired_set_s390_nettype,
7047                             NULL,
7048                             NULL,
7049                             nmc_property_wired_allowed_s390_nettype,
7050                             NULL);
7051         nmc_add_prop_funcs (GLUE (WIRED, S390_OPTIONS),
7052                             nmc_property_wired_get_s390_options,
7053                             nmc_property_wired_set_s390_options,
7054                             nmc_property_wired_remove_option_s390_options,
7055                             nmc_property_wired_describe_s390_options,
7056                             nmc_property_wired_allowed_s390_options,
7057                             NULL);
7058         nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN),
7059                             nmc_property_wired_get_wake_on_lan,
7060                             nmc_property_wired_set_wake_on_lan,
7061                             NULL,
7062                             NULL,
7063                             NULL,
7064                             NULL);
7065         nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN_PASSWORD),
7066                             nmc_property_wired_get_wake_on_lan_password,
7067                             nmc_property_set_mac,
7068                             NULL,
7069                             NULL,
7070                             NULL,
7071                             NULL);
7072
7073         /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */
7074         nmc_add_prop_funcs (GLUE (WIRELESS, SSID),
7075                             nmc_property_wireless_get_ssid,
7076                             nmc_property_set_ssid,
7077                             NULL,
7078                             NULL,
7079                             NULL,
7080                             NULL);
7081         nmc_add_prop_funcs (GLUE (WIRELESS, MODE),
7082                             nmc_property_wireless_get_mode,
7083                             nmc_property_wifi_set_mode,
7084                             NULL,
7085                             NULL,
7086                             nmc_property_wifi_allowed_mode,
7087                             NULL);
7088         nmc_add_prop_funcs (GLUE (WIRELESS, BAND),
7089                             nmc_property_wireless_get_band,
7090                             nmc_property_wifi_set_band,
7091                             NULL,
7092                             NULL,
7093                             nmc_property_wifi_allowed_band,
7094                             NULL);
7095         nmc_add_prop_funcs (GLUE (WIRELESS, CHANNEL),
7096                             nmc_property_wireless_get_channel,
7097                             nmc_property_wifi_set_channel,
7098                             NULL,
7099                             NULL,
7100                             NULL,
7101                             NULL);
7102         nmc_add_prop_funcs (GLUE (WIRELESS, BSSID),
7103                             nmc_property_wireless_get_bssid,
7104                             nmc_property_set_mac,
7105                             NULL,
7106                             NULL,
7107                             NULL,
7108                             NULL);
7109         /*
7110          * Do not allow setting 'rate' and 'tx-power'. They are not implemented in
7111          * NM core, nor in ifcfg-rh plugin (thus not preserved over re-reading).
7112          */
7113         nmc_add_prop_funcs (GLUE (WIRELESS, RATE),
7114                             nmc_property_wireless_get_rate,
7115                             NULL, /* editing rate disabled */
7116                             NULL,
7117                             NULL,
7118                             NULL,
7119                             NULL);
7120         nmc_add_prop_funcs (GLUE (WIRELESS, TX_POWER),
7121                             nmc_property_wireless_get_tx_power,
7122                             NULL, /* editing tx-power disabled */
7123                             NULL,
7124                             NULL,
7125                             NULL,
7126                             NULL);
7127         nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS),
7128                             nmc_property_wireless_get_mac_address,
7129                             nmc_property_set_mac,
7130                             NULL,
7131                             NULL,
7132                             NULL,
7133                             NULL);
7134         nmc_add_prop_funcs (GLUE (WIRELESS, CLONED_MAC_ADDRESS),
7135                             nmc_property_wireless_get_cloned_mac_address,
7136                             nmc_property_set_mac,
7137                             NULL,
7138                             NULL,
7139                             NULL,
7140                             NULL);
7141         nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_BLACKLIST),
7142                             nmc_property_wireless_get_mac_address_blacklist,
7143                             nmc_property_wireless_set_mac_address_blacklist,
7144                             nmc_property_wireless_remove_mac_address_blacklist,
7145                             NULL,
7146                             NULL,
7147                             NULL);
7148         nmc_add_prop_funcs (GLUE (WIRELESS, SEEN_BSSIDS),
7149                             nmc_property_wireless_get_seen_bssids,
7150                             NULL, /* read-only */
7151                             NULL,
7152                             NULL,
7153                             NULL,
7154                             NULL);
7155         nmc_add_prop_funcs (GLUE (WIRELESS, MTU),
7156                             nmc_property_wireless_get_mtu,
7157                             nmc_property_set_mtu,
7158                             NULL,
7159                             NULL,
7160                             NULL,
7161                             NULL);
7162         nmc_add_prop_funcs (GLUE (WIRELESS, HIDDEN),
7163                             nmc_property_wireless_get_hidden,
7164                             nmc_property_set_bool,
7165                             NULL,
7166                             NULL,
7167                             NULL,
7168                             NULL);
7169         nmc_add_prop_funcs (GLUE (WIRELESS, POWERSAVE),
7170                             nmc_property_wireless_get_powersave,
7171                             nmc_property_wireless_set_powersave,
7172                             NULL,
7173                             NULL,
7174                             NULL,
7175                             NULL);
7176         nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_RANDOMIZATION),
7177                             nmc_property_wireless_get_mac_address_randomization,
7178                             nmc_property_wireless_set_mac_address_randomization,
7179                             NULL,
7180                             NULL,
7181                             NULL,
7182                             NULL);
7183
7184         /* Add editable properties for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */
7185         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, KEY_MGMT),
7186                             nmc_property_wifi_sec_get_key_mgmt,
7187                             nmc_property_wifi_sec_set_key_mgmt,
7188                             NULL,
7189                             NULL,
7190                             nmc_property_wifi_sec_allowed_key_mgmt,
7191                             NULL);
7192         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_TX_KEYIDX),
7193                             nmc_property_wifi_sec_get_wep_tx_keyidx,
7194                             nmc_property_set_uint,
7195                             NULL,
7196                             NULL,
7197                             NULL,
7198                             NULL);
7199         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, AUTH_ALG),
7200                             nmc_property_wifi_sec_get_auth_alg,
7201                             nmc_property_wifi_sec_set_auth_alg,
7202                             NULL,
7203                             NULL,
7204                             nmc_property_wifi_sec_allowed_auth_alg,
7205                             NULL);
7206         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PROTO),
7207                             nmc_property_wifi_sec_get_proto,
7208                             nmc_property_wifi_sec_set_proto,
7209                             nmc_property_wifi_sec_remove_proto,
7210                             NULL,
7211                             nmc_property_wifi_sec_allowed_proto,
7212                             NULL);
7213         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PAIRWISE),
7214                             nmc_property_wifi_sec_get_pairwise,
7215                             nmc_property_wifi_sec_set_pairwise,
7216                             nmc_property_wifi_sec_remove_pairwise,
7217                             NULL,
7218                             nmc_property_wifi_sec_allowed_pairwise,
7219                             NULL);
7220         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, GROUP),
7221                             nmc_property_wifi_sec_get_group,
7222                             nmc_property_wifi_sec_set_group,
7223                             nmc_property_wifi_sec_remove_group,
7224                             NULL,
7225                             nmc_property_wifi_sec_allowed_group,
7226                             NULL);
7227         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_USERNAME),
7228                             nmc_property_wifi_sec_get_leap_username,
7229                             nmc_property_set_string,
7230                             NULL,
7231                             NULL,
7232                             NULL,
7233                             NULL);
7234         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY0),
7235                             nmc_property_wifi_sec_get_wep_key0,
7236                             nmc_property_wifi_set_wep_key,
7237                             NULL,
7238                             NULL,
7239                             NULL,
7240                             NULL);
7241         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY1),
7242                             nmc_property_wifi_sec_get_wep_key1,
7243                             nmc_property_wifi_set_wep_key,
7244                             NULL,
7245                             NULL,
7246                             NULL,
7247                             NULL);
7248         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY2),
7249                             nmc_property_wifi_sec_get_wep_key2,
7250                             nmc_property_wifi_set_wep_key,
7251                             NULL,
7252                             NULL,
7253                             NULL,
7254                             NULL);
7255         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY3),
7256                             nmc_property_wifi_sec_get_wep_key3,
7257                             nmc_property_wifi_set_wep_key,
7258                             NULL,
7259                             NULL,
7260                             NULL,
7261                             NULL);
7262         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_FLAGS),
7263                             nmc_property_wifi_sec_get_wep_key_flags,
7264                             nmc_property_set_secret_flags,
7265                             NULL,
7266                             NULL,
7267                             NULL,
7268                             NULL);
7269         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_TYPE),
7270                             nmc_property_wifi_sec_get_wep_key_type,
7271                             nmc_property_wifi_set_wep_key_type,
7272                             NULL,
7273                             nmc_property_wifi_describe_wep_key_type,
7274                             NULL,
7275                             NULL);
7276         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK),
7277                             nmc_property_wifi_sec_get_psk,
7278                             nmc_property_wifi_set_psk,
7279                             NULL,
7280                             NULL,
7281                             NULL,
7282                             NULL);
7283         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK_FLAGS),
7284                             nmc_property_wifi_sec_get_psk_flags,
7285                             nmc_property_set_secret_flags,
7286                             NULL,
7287                             NULL,
7288                             NULL,
7289                             NULL);
7290         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD),
7291                             nmc_property_wifi_sec_get_leap_password,
7292                             nmc_property_set_string,
7293                             NULL,
7294                             NULL,
7295                             NULL,
7296                             NULL);
7297         nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD_FLAGS),
7298                             nmc_property_wifi_sec_get_leap_password_flags,
7299                             nmc_property_set_secret_flags,
7300                             NULL,
7301                             NULL,
7302                             NULL,
7303                             NULL);
7304
7305         /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */
7306         nmc_add_prop_funcs (GLUE (TUN, MODE),
7307                             nmc_property_tun_get_mode,
7308                             nmc_property_tun_set_mode,
7309                             NULL,
7310                             NULL,
7311                             nmc_property_tun_allowed_mode,
7312                             NULL);
7313         nmc_add_prop_funcs (GLUE (TUN, OWNER),
7314                             nmc_property_tun_get_owner,
7315                             nmc_property_set_string,
7316                             NULL,
7317                             NULL,
7318                             NULL,
7319                             NULL);
7320         nmc_add_prop_funcs (GLUE (TUN, GROUP),
7321                             nmc_property_tun_get_group,
7322                             nmc_property_set_string,
7323                             NULL,
7324                             NULL,
7325                             NULL,
7326                             NULL);
7327         nmc_add_prop_funcs (GLUE (TUN, PI),
7328                             nmc_property_tun_get_pi,
7329                             nmc_property_set_bool,
7330                             NULL,
7331                             NULL,
7332                             NULL,
7333                             NULL);
7334         nmc_add_prop_funcs (GLUE (TUN, VNET_HDR),
7335                             nmc_property_tun_get_vnet_hdr,
7336                             nmc_property_set_bool,
7337                             NULL,
7338                             NULL,
7339                             NULL,
7340                             NULL);
7341         nmc_add_prop_funcs (GLUE (TUN, MULTI_QUEUE),
7342                             nmc_property_tun_get_multi_queue,
7343                             nmc_property_set_bool,
7344                             NULL,
7345                             NULL,
7346                             NULL,
7347                             NULL);
7348
7349         /* Add editable properties for NM_SETTING_IP_TUNNEL_SETTING_NAME */
7350         nmc_add_prop_funcs (GLUE (IP_TUNNEL, MODE),
7351                             nmc_property_ip_tunnel_get_mode,
7352                             nmc_property_ip_tunnel_set_mode,
7353                             NULL,
7354                             NULL,
7355                             nmc_property_ip_tunnel_allowed_mode,
7356                             NULL);
7357         nmc_add_prop_funcs (GLUE (IP_TUNNEL, PARENT),
7358                             nmc_property_ip_tunnel_get_parent,
7359                             nmc_property_set_string,
7360                             NULL,
7361                             NULL,
7362                             NULL,
7363                             NULL);
7364         nmc_add_prop_funcs (GLUE (IP_TUNNEL, LOCAL),
7365                             nmc_property_ip_tunnel_get_local,
7366                             nmc_property_set_string,
7367                             NULL,
7368                             NULL,
7369                             NULL,
7370                             NULL);
7371         nmc_add_prop_funcs (GLUE (IP_TUNNEL, REMOTE),
7372                             nmc_property_ip_tunnel_get_remote,
7373                             nmc_property_set_string,
7374                             NULL,
7375                             NULL,
7376                             NULL,
7377                             NULL);
7378         nmc_add_prop_funcs (GLUE (IP_TUNNEL, TTL),
7379                             nmc_property_ip_tunnel_get_ttl,
7380                             nmc_property_set_uint,
7381                             NULL,
7382                             NULL,
7383                             NULL,
7384                             NULL);
7385         nmc_add_prop_funcs (GLUE (IP_TUNNEL, TOS),
7386                             nmc_property_ip_tunnel_get_tos,
7387                             nmc_property_set_uint,
7388                             NULL,
7389                             NULL,
7390                             NULL,
7391                             NULL);
7392         nmc_add_prop_funcs (GLUE (IP_TUNNEL, PATH_MTU_DISCOVERY),
7393                             nmc_property_ip_tunnel_get_path_mtu_discovery,
7394                             nmc_property_set_bool,
7395                             NULL,
7396                             NULL,
7397                             NULL,
7398                             NULL);
7399         nmc_add_prop_funcs (GLUE (IP_TUNNEL, INPUT_KEY),
7400                             nmc_property_ip_tunnel_get_input_key,
7401                             nmc_property_set_string,
7402                             NULL,
7403                             NULL,
7404                             NULL,
7405                             NULL);
7406         nmc_add_prop_funcs (GLUE (IP_TUNNEL, OUTPUT_KEY),
7407                             nmc_property_ip_tunnel_get_output_key,
7408                             nmc_property_set_string,
7409                             NULL,
7410                             NULL,
7411                             NULL,
7412                             NULL);
7413         nmc_add_prop_funcs (GLUE (IP_TUNNEL, ENCAPSULATION_LIMIT),
7414                             nmc_property_ip_tunnel_get_encapsulation_limit,
7415                             nmc_property_set_uint,
7416                             NULL,
7417                             NULL,
7418                             NULL,
7419                             NULL);
7420         nmc_add_prop_funcs (GLUE (IP_TUNNEL, FLOW_LABEL),
7421                             nmc_property_ip_tunnel_get_flow_label,
7422                             nmc_property_set_uint,
7423                             NULL,
7424                             NULL,
7425                             NULL,
7426                             NULL);
7427         nmc_add_prop_funcs (GLUE (IP_TUNNEL, MTU),
7428                             nmc_property_ip_tunnel_get_mtu,
7429                             nmc_property_set_uint,
7430                             NULL,
7431                             NULL,
7432                             NULL,
7433                             NULL);
7434
7435         /* Add editable properties for NM_SETTING_MACVLAN_SETTING_NAME */
7436         nmc_add_prop_funcs (GLUE (MACVLAN, PARENT),
7437                             nmc_property_macvlan_get_parent,
7438                             nmc_property_set_string,
7439                             NULL,
7440                             NULL,
7441                             NULL,
7442                             NULL);
7443         nmc_add_prop_funcs (GLUE (MACVLAN, MODE),
7444                             nmc_property_macvlan_get_mode,
7445                             nmc_property_macvlan_set_mode,
7446                             NULL,
7447                             NULL,
7448                             nmc_property_macvlan_allowed_mode,
7449                             NULL);
7450         nmc_add_prop_funcs (GLUE (MACVLAN, PROMISCUOUS),
7451                             nmc_property_macvlan_get_promiscuous,
7452                             nmc_property_set_bool,
7453                             NULL,
7454                             NULL,
7455                             NULL,
7456                             NULL);
7457         nmc_add_prop_funcs (GLUE (MACVLAN, TAP),
7458                             nmc_property_macvlan_get_tap,
7459                             nmc_property_set_bool,
7460                             NULL,
7461                             NULL,
7462                             NULL,
7463                             NULL);
7464
7465         /* Add editable properties for NM_SETTING_VXLAN_SETTING_NAME */
7466         nmc_add_prop_funcs (GLUE (VXLAN, PARENT),
7467                             nmc_property_vxlan_get_parent,
7468                             nmc_property_set_string,
7469                             NULL,
7470                             NULL,
7471                             NULL,
7472                             NULL);
7473         nmc_add_prop_funcs (GLUE (VXLAN, ID),
7474                             nmc_property_vxlan_get_id,
7475                             nmc_property_set_uint,
7476                             NULL,
7477                             NULL,
7478                             NULL,
7479                             NULL);
7480         nmc_add_prop_funcs (GLUE (VXLAN, LOCAL),
7481                             nmc_property_vxlan_get_local,
7482                             nmc_property_set_string,
7483                             NULL,
7484                             NULL,
7485                             NULL,
7486                             NULL);
7487         nmc_add_prop_funcs (GLUE (VXLAN, REMOTE),
7488                             nmc_property_vxlan_get_remote,
7489                             nmc_property_set_string,
7490                             NULL,
7491                             NULL,
7492                             NULL,
7493                             NULL);
7494         nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MIN),
7495                             nmc_property_vxlan_get_source_port_min,
7496                             nmc_property_set_uint,
7497                             NULL,
7498                             NULL,
7499                             NULL,
7500                             NULL);
7501         nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MAX),
7502                             nmc_property_vxlan_get_source_port_max,
7503                             nmc_property_set_uint,
7504                             NULL,
7505                             NULL,
7506                             NULL,
7507                             NULL);
7508         nmc_add_prop_funcs (GLUE (VXLAN, DESTINATION_PORT),
7509                             nmc_property_vxlan_get_destination_port,
7510                             nmc_property_set_uint,
7511                             NULL,
7512                             NULL,
7513                             NULL,
7514                             NULL);
7515         nmc_add_prop_funcs (GLUE (VXLAN, TOS),
7516                             nmc_property_vxlan_get_tos,
7517                             nmc_property_set_uint,
7518                             NULL,
7519                             NULL,
7520                             NULL,
7521                             NULL);
7522         nmc_add_prop_funcs (GLUE (VXLAN, TTL),
7523                             nmc_property_vxlan_get_ttl,
7524                             nmc_property_set_uint,
7525                             NULL,
7526                             NULL,
7527                             NULL,
7528                             NULL);
7529         nmc_add_prop_funcs (GLUE (VXLAN, AGEING),
7530                             nmc_property_vxlan_get_ageing,
7531                             nmc_property_set_uint,
7532                             NULL,
7533                             NULL,
7534                             NULL,
7535                             NULL);
7536         nmc_add_prop_funcs (GLUE (VXLAN, LIMIT),
7537                             nmc_property_vxlan_get_limit,
7538                             nmc_property_set_uint,
7539                             NULL,
7540                             NULL,
7541                             NULL,
7542                             NULL);
7543         nmc_add_prop_funcs (GLUE (VXLAN, LEARNING),
7544                             nmc_property_vxlan_get_learning,
7545                             nmc_property_set_bool,
7546                             NULL,
7547                             NULL,
7548                             NULL,
7549                             NULL);
7550         nmc_add_prop_funcs (GLUE (VXLAN, PROXY),
7551                             nmc_property_vxlan_get_proxy,
7552                             nmc_property_set_bool,
7553                             NULL,
7554                             NULL,
7555                             NULL,
7556                             NULL);
7557         nmc_add_prop_funcs (GLUE (VXLAN, RSC),
7558                             nmc_property_vxlan_get_rsc,
7559                             nmc_property_set_bool,
7560                             NULL,
7561                             NULL,
7562                             NULL,
7563                             NULL);
7564         nmc_add_prop_funcs (GLUE (VXLAN, L2_MISS),
7565                             nmc_property_vxlan_get_l2_miss,
7566                             nmc_property_set_bool,
7567                             NULL,
7568                             NULL,
7569                             NULL,
7570                             NULL);
7571         nmc_add_prop_funcs (GLUE (VXLAN, L3_MISS),
7572                             nmc_property_vxlan_get_l3_miss,
7573                             nmc_property_set_bool,
7574                             NULL,
7575                             NULL,
7576                             NULL,
7577                             NULL);
7578 }
7579
7580 void
7581 nmc_properties_cleanup ()
7582 {
7583         if (nmc_properties)
7584                 g_hash_table_destroy (nmc_properties);
7585 }
7586
7587 static const NmcPropertyFuncs *
7588 nmc_properties_find (const char *s_name, const char *p_name)
7589 {
7590         char *key;
7591         gsize p_l, s_l;
7592
7593         nmc_properties_init ();
7594
7595         s_l = strlen (s_name);
7596         p_l = strlen (p_name);
7597         key = g_alloca (s_l + p_l + 1);
7598         memcpy (&key[  0], s_name, s_l);
7599         memcpy (&key[s_l], p_name, p_l + 1);
7600         return (NmcPropertyFuncs *) g_hash_table_lookup (nmc_properties, key);
7601 }
7602
7603 static char *
7604 get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error)
7605 {
7606         const NmcPropertyFuncs *item;
7607
7608         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7609         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7610
7611         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7612         if (item && item->get_func)
7613                 return item->get_func (setting, get_type);
7614
7615         g_set_error_literal (error, 1, 0, _("don't know how to get the property value"));
7616         return NULL;
7617 }
7618
7619 /*
7620  * Generic function for getting property value.
7621  *
7622  * Gets property value as a string by calling specialized functions.
7623  *
7624  * Returns: current property value. The caller must free the returned string.
7625  */
7626 char *
7627 nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error)
7628 {
7629         return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, error);
7630 }
7631
7632 /*
7633  * Similar to nmc_setting_get_property(), but returns the property in a string
7634  * format that can be parsed via nmc_setting_set_property().
7635  */
7636 char *
7637 nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError **error)
7638 {
7639         return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, error);
7640 }
7641
7642 /*
7643  * Generic function for setting property value.
7644  *
7645  * Sets property=val in setting by calling specialized functions.
7646  * If val is NULL then default property value is set.
7647  *
7648  * Returns: TRUE on success; FALSE on failure and sets error
7649  */
7650 gboolean
7651 nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error)
7652 {
7653         const NmcPropertyFuncs *item;
7654
7655         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7656         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7657
7658         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7659         if (item && item->set_func) {
7660                 if (!val) {
7661                         /* No value argument sets default value */
7662                         nmc_property_set_default_value (setting, prop);
7663                         return TRUE;
7664                 }
7665                 return item->set_func (setting, prop, val, error);
7666         }
7667
7668         g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7669         return FALSE;
7670 }
7671
7672 void
7673 nmc_property_set_default_value (NMSetting *setting, const char *prop)
7674 {
7675         GValue value = G_VALUE_INIT;
7676         GParamSpec *param_spec;
7677
7678         param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7679         if (param_spec) {
7680                 g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
7681                 g_param_value_set_default (param_spec, &value);
7682                 g_object_set_property (G_OBJECT (setting), prop, &value);
7683         }
7684 }
7685
7686 /*
7687  * Generic function for reseting (single value) properties.
7688  *
7689  * The function resets the property value to the default one. It respects
7690  * nmcli restrictions for changing properties. So if 'set_func' is NULL,
7691  * reseting the value is denied.
7692  *
7693  * Returns: TRUE on success; FALSE on failure and sets error
7694  */
7695 gboolean
7696 nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error)
7697 {
7698         const NmcPropertyFuncs *item;
7699
7700         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7701         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7702
7703         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7704         if (item && item->set_func) {
7705                 nmc_property_set_default_value (setting, prop);
7706                 return TRUE;
7707         }
7708         g_set_error_literal (error, 1, 0, _("the property can't be changed"));
7709         return FALSE;
7710 }
7711
7712 /*
7713  * Generic function for removing items for collection-type properties.
7714  *
7715  * If 'option' is not NULL, it tries to remove it, otherwise 'idx' is used.
7716  * For single-value properties (not having specialized remove function) this
7717  * function does nothing and just returns TRUE.
7718  *
7719  * Returns: TRUE on success; FALSE on failure and sets error
7720  */
7721 gboolean
7722 nmc_setting_remove_property_option (NMSetting *setting,
7723                                     const char *prop,
7724                                     const char *option,
7725                                     guint32 idx,
7726                                     GError **error)
7727 {
7728         const NmcPropertyFuncs *item;
7729
7730         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7731         g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
7732
7733         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7734         if (item && item->remove_func)
7735                 return item->remove_func (setting, prop, option, idx, error);
7736
7737         return TRUE;
7738 }
7739
7740 /*
7741  * Get valid property names for a setting.
7742  *
7743  * Returns: string array with the properties or NULL on failure.
7744  *          The returned value should be freed with g_strfreev()
7745  */
7746 char **
7747 nmc_setting_get_valid_properties (NMSetting *setting)
7748 {
7749         char **valid_props = NULL;
7750         GParamSpec **props, **iter;
7751         guint num;
7752         int i;
7753
7754         /* Iterate through properties */
7755         i = 0;
7756         props = g_object_class_list_properties (G_OBJECT_GET_CLASS (G_OBJECT (setting)), &num);
7757         valid_props = g_malloc0 (sizeof (char*) * (num + 1));
7758         for (iter = props; iter && *iter; iter++) {
7759                 const char *key_name = g_param_spec_get_name (*iter);
7760
7761                 /* Add all properties except for "name" that is non-editable */
7762                 if (g_strcmp0 (key_name, "name") != 0)
7763                         valid_props[i++] = g_strdup (key_name);
7764         }
7765         valid_props[i] = NULL;
7766         g_free (props);
7767
7768         return valid_props;
7769 }
7770
7771 /*
7772  * Return allowed values for 'prop' as a string.
7773  */
7774 const char **
7775 nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop)
7776 {
7777
7778         const NmcPropertyFuncs *item;
7779
7780         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7781
7782         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7783         if (item && item->values_func)
7784                 return item->values_func (setting, prop);
7785
7786         return NULL;
7787 }
7788
7789 #if defined (BUILD_SETTING_DOCS) || defined (HAVE_SETTING_DOCS)
7790 #include "settings-docs.c"
7791 #else
7792 #define nmc_setting_get_property_doc(setting, prop) _("(not available)")
7793 #endif
7794
7795 /*
7796  * Create a description string for a property.
7797  *
7798  * It returns a description got from property documentation, concatenated with
7799  * nmcli specific description (if it exists).
7800  *
7801  * Returns: property description or NULL on failure. The caller must free the string.
7802  */
7803 char *
7804 nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
7805 {
7806         const NmcPropertyFuncs *item;
7807         const char *setting_desc = NULL;
7808         const char *setting_desc_title = "";
7809         const char *nmcli_desc = NULL;
7810         const char *nmcli_desc_title = "";
7811         const char *nmcli_nl = "";
7812
7813         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
7814
7815         setting_desc = nmc_setting_get_property_doc (setting, prop);
7816         if (setting_desc)
7817                 setting_desc_title = _("[NM property description]");
7818
7819         item = nmc_properties_find (nm_setting_get_name (setting), prop);
7820         if (item && item->describe_func) {
7821                 nmcli_desc = item->describe_func (setting, prop);
7822                 nmcli_desc_title = _("[nmcli specific description]");
7823                 nmcli_nl = "\n";
7824         }
7825
7826         return g_strdup_printf ("%s\n%s\n%s%s%s%s",
7827                                 setting_desc_title,
7828                                 setting_desc ? setting_desc : "",
7829                                 nmcli_nl, nmcli_desc_title, nmcli_nl,
7830                                 nmcli_desc ? nmcli_desc : "");
7831 }
7832
7833 /*
7834  * Gets setting:prop property value and returns it in 'value'.
7835  * Caller is responsible for freeing the GValue resources using g_value_unset()
7836  */
7837 gboolean
7838 nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value)
7839 {
7840         GParamSpec *param_spec;
7841
7842         param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7843         if (param_spec) {
7844                 memset (value, 0, sizeof (GValue));
7845                 g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
7846                 g_object_get_property (G_OBJECT (setting), prop, value);
7847                 return TRUE;
7848         }
7849         return FALSE;
7850 }
7851
7852 /*
7853  * Sets setting:prop property value from 'value'.
7854  */
7855 gboolean
7856 nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value)
7857 {
7858         GParamSpec *param_spec;
7859
7860         param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
7861         if (param_spec && G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (param_spec)) {
7862                 g_object_set_property (G_OBJECT (setting), prop, value);
7863                 return TRUE;
7864         }
7865         return FALSE;
7866 }
7867
7868 /*----------------------------------------------------------------------------*/
7869
7870 #define GET_SECRET(show, setting, func) \
7871         (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_("<hidden>")))
7872
7873 static gboolean
7874 setting_connection_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
7875 {
7876         NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting);
7877         NmcOutputField *tmpl, *arr;
7878         size_t tmpl_len;
7879
7880         g_return_val_if_fail (NM_IS_SETTING_CONNECTION (s_con), FALSE);
7881
7882         tmpl = nmc_fields_setting_connection;
7883         tmpl_len = sizeof (nmc_fields_setting_connection);
7884         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CONNECTION_ALL,
7885                                                          tmpl, FALSE, NULL, NULL);
7886         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7887         g_ptr_array_add (nmc->output_data, arr);
7888
7889         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7890         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7891         set_val_str (arr, 1, nmc_property_connection_get_id (setting, NMC_PROPERTY_GET_PRETTY));
7892         set_val_str (arr, 2, nmc_property_connection_get_uuid (setting, NMC_PROPERTY_GET_PRETTY));
7893         set_val_str (arr, 3, nmc_property_connection_get_interface_name (setting, NMC_PROPERTY_GET_PRETTY));
7894         set_val_str (arr, 4, nmc_property_connection_get_type (setting, NMC_PROPERTY_GET_PRETTY));
7895         set_val_str (arr, 5, nmc_property_connection_get_autoconnect (setting, NMC_PROPERTY_GET_PRETTY));
7896         set_val_str (arr, 6, nmc_property_connection_get_autoconnect_priority (setting, NMC_PROPERTY_GET_PRETTY));
7897         set_val_str (arr, 7, nmc_property_connection_get_timestamp (setting, NMC_PROPERTY_GET_PRETTY));
7898         set_val_str (arr, 8, nmc_property_connection_get_read_only (setting, NMC_PROPERTY_GET_PRETTY));
7899         set_val_str (arr, 9, nmc_property_connection_get_permissions (setting, NMC_PROPERTY_GET_PRETTY));
7900         set_val_str (arr, 10, nmc_property_connection_get_zone (setting, NMC_PROPERTY_GET_PRETTY));
7901         set_val_str (arr, 11, nmc_property_connection_get_master (setting, NMC_PROPERTY_GET_PRETTY));
7902         set_val_str (arr, 12, nmc_property_connection_get_slave_type (setting, NMC_PROPERTY_GET_PRETTY));
7903         set_val_str (arr, 13, nmc_property_connection_get_autoconnect_slaves (setting, NMC_PROPERTY_GET_PRETTY));
7904         set_val_str (arr, 14, nmc_property_connection_get_secondaries (setting, NMC_PROPERTY_GET_PRETTY));
7905         set_val_str (arr, 15, nmc_property_connection_get_gateway_ping_timeout (setting, NMC_PROPERTY_GET_PRETTY));
7906         set_val_str (arr, 16, nmc_property_connection_get_metered (setting, NMC_PROPERTY_GET_PRETTY));
7907         set_val_str (arr, 17, nmc_property_connection_get_lldp (setting, NMC_PROPERTY_GET_PRETTY));
7908         g_ptr_array_add (nmc->output_data, arr);
7909
7910         print_data (nmc);  /* Print all data */
7911
7912         return TRUE;
7913 }
7914
7915 static gboolean
7916 setting_wired_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
7917 {
7918         NMSettingWired *s_wired = NM_SETTING_WIRED (setting);
7919         NmcOutputField *tmpl, *arr;
7920         size_t tmpl_len;
7921
7922         g_return_val_if_fail (NM_IS_SETTING_WIRED (s_wired), FALSE);
7923
7924         tmpl = nmc_fields_setting_wired;
7925         tmpl_len = sizeof (nmc_fields_setting_wired);
7926         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRED_ALL,
7927                                                          tmpl, FALSE, NULL, NULL);
7928         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7929         g_ptr_array_add (nmc->output_data, arr);
7930
7931         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7932         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7933         set_val_str (arr, 1, nmc_property_wired_get_port (setting, NMC_PROPERTY_GET_PRETTY));
7934         set_val_str (arr, 2, nmc_property_wired_get_speed (setting, NMC_PROPERTY_GET_PRETTY));
7935         set_val_str (arr, 3, nmc_property_wired_get_duplex (setting, NMC_PROPERTY_GET_PRETTY));
7936         set_val_str (arr, 4, nmc_property_wired_get_auto_negotiate (setting, NMC_PROPERTY_GET_PRETTY));
7937         set_val_str (arr, 5, nmc_property_wired_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
7938         set_val_str (arr, 6, nmc_property_wired_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
7939         set_val_str (arr, 7, nmc_property_wired_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY));
7940         set_val_str (arr, 8, nmc_property_wired_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
7941         set_val_str (arr, 9, nmc_property_wired_get_s390_subchannels (setting, NMC_PROPERTY_GET_PRETTY));
7942         set_val_str (arr, 10, nmc_property_wired_get_s390_nettype (setting, NMC_PROPERTY_GET_PRETTY));
7943         set_val_str (arr, 11, nmc_property_wired_get_s390_options (setting, NMC_PROPERTY_GET_PRETTY));
7944         set_val_str (arr, 12, nmc_property_wired_get_wake_on_lan (setting, NMC_PROPERTY_GET_PRETTY));
7945         set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan_password (setting, NMC_PROPERTY_GET_PRETTY));
7946         g_ptr_array_add (nmc->output_data, arr);
7947
7948         print_data (nmc);  /* Print all data */
7949
7950         return TRUE;
7951 }
7952
7953 static gboolean
7954 setting_802_1X_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
7955 {
7956         NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting);
7957         NmcOutputField *tmpl, *arr;
7958         size_t tmpl_len;
7959
7960         g_return_val_if_fail (NM_IS_SETTING_802_1X (s_8021x), FALSE);
7961
7962         tmpl = nmc_fields_setting_8021X;
7963         tmpl_len = sizeof (nmc_fields_setting_8021X);
7964         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_802_1X_ALL,
7965                                                          tmpl, FALSE, NULL, NULL);
7966         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
7967         g_ptr_array_add (nmc->output_data, arr);
7968
7969         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
7970         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
7971         set_val_str (arr, 1, nmc_property_802_1X_get_eap (setting, NMC_PROPERTY_GET_PRETTY));
7972         set_val_str (arr, 2, nmc_property_802_1X_get_identity (setting, NMC_PROPERTY_GET_PRETTY));
7973         set_val_str (arr, 3, nmc_property_802_1X_get_anonymous_identity (setting, NMC_PROPERTY_GET_PRETTY));
7974         set_val_str (arr, 4, nmc_property_802_1X_get_pac_file (setting, NMC_PROPERTY_GET_PRETTY));
7975         set_val_str (arr, 5, nmc_property_802_1X_get_ca_cert (setting, NMC_PROPERTY_GET_PRETTY));
7976         set_val_str (arr, 6, nmc_property_802_1X_get_ca_path (setting, NMC_PROPERTY_GET_PRETTY));
7977         set_val_str (arr, 7, nmc_property_802_1X_get_subject_match (setting, NMC_PROPERTY_GET_PRETTY));
7978         set_val_str (arr, 8, nmc_property_802_1X_get_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY));
7979         set_val_str (arr, 9, nmc_property_802_1X_get_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY));
7980         set_val_str (arr, 10, nmc_property_802_1X_get_client_cert (setting, NMC_PROPERTY_GET_PRETTY));
7981         set_val_str (arr, 11, nmc_property_802_1X_get_phase1_peapver (setting, NMC_PROPERTY_GET_PRETTY));
7982         set_val_str (arr, 12, nmc_property_802_1X_get_phase1_peaplabel (setting, NMC_PROPERTY_GET_PRETTY));
7983         set_val_str (arr, 13, nmc_property_802_1X_get_phase1_fast_provisioning (setting, NMC_PROPERTY_GET_PRETTY));
7984         set_val_str (arr, 14, nmc_property_802_1X_get_phase2_auth (setting, NMC_PROPERTY_GET_PRETTY));
7985         set_val_str (arr, 15, nmc_property_802_1X_get_phase2_autheap (setting, NMC_PROPERTY_GET_PRETTY));
7986         set_val_str (arr, 16, nmc_property_802_1X_get_phase2_ca_cert (setting, NMC_PROPERTY_GET_PRETTY));
7987         set_val_str (arr, 17, nmc_property_802_1X_get_phase2_ca_path (setting, NMC_PROPERTY_GET_PRETTY));
7988         set_val_str (arr, 18, nmc_property_802_1X_get_phase2_subject_match (setting, NMC_PROPERTY_GET_PRETTY));
7989         set_val_str (arr, 19, nmc_property_802_1X_get_phase2_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY));
7990         set_val_str (arr, 20, nmc_property_802_1X_get_phase2_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY));
7991         set_val_str (arr, 21, nmc_property_802_1X_get_phase2_client_cert (setting, NMC_PROPERTY_GET_PRETTY));
7992         set_val_str (arr, 22, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password));
7993         set_val_str (arr, 23, nmc_property_802_1X_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
7994         set_val_str (arr, 24, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password_raw));
7995         set_val_str (arr, 25, nmc_property_802_1X_get_password_raw_flags (setting, NMC_PROPERTY_GET_PRETTY));
7996         set_val_str (arr, 26, nmc_property_802_1X_get_private_key (setting, NMC_PROPERTY_GET_PRETTY));
7997         set_val_str (arr, 27, GET_SECRET (secrets, setting, nmc_property_802_1X_get_private_key_password));
7998         set_val_str (arr, 28, nmc_property_802_1X_get_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
7999         set_val_str (arr, 29, nmc_property_802_1X_get_phase2_private_key (setting, NMC_PROPERTY_GET_PRETTY));
8000         set_val_str (arr, 30, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_private_key_password));
8001         set_val_str (arr, 31, nmc_property_802_1X_get_phase2_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8002         set_val_str (arr, 32, GET_SECRET (secrets, setting, nmc_property_802_1X_get_pin));
8003         set_val_str (arr, 33, nmc_property_802_1X_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY));
8004         set_val_str (arr, 34, nmc_property_802_1X_get_system_ca_certs (setting, NMC_PROPERTY_GET_PRETTY));
8005         g_ptr_array_add (nmc->output_data, arr);
8006
8007         print_data (nmc);  /* Print all data */
8008
8009         return TRUE;
8010 }
8011
8012 static gboolean
8013 setting_wireless_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8014 {
8015         NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
8016         NmcOutputField *tmpl, *arr;
8017         size_t tmpl_len;
8018
8019         g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE);
8020
8021         tmpl = nmc_fields_setting_wireless;
8022         tmpl_len = sizeof (nmc_fields_setting_wireless);
8023         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_ALL,
8024                                                          tmpl, FALSE, NULL, NULL);
8025         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8026         g_ptr_array_add (nmc->output_data, arr);
8027
8028         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8029         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8030         set_val_str (arr, 1, nmc_property_wireless_get_ssid (setting, NMC_PROPERTY_GET_PRETTY));
8031         set_val_str (arr, 2, nmc_property_wireless_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8032         set_val_str (arr, 3, nmc_property_wireless_get_band (setting, NMC_PROPERTY_GET_PRETTY));
8033         set_val_str (arr, 4, nmc_property_wireless_get_channel (setting, NMC_PROPERTY_GET_PRETTY));
8034         set_val_str (arr, 5, nmc_property_wireless_get_bssid (setting, NMC_PROPERTY_GET_PRETTY));
8035         set_val_str (arr, 6, nmc_property_wireless_get_rate (setting, NMC_PROPERTY_GET_PRETTY));
8036         set_val_str (arr, 7, nmc_property_wireless_get_tx_power (setting, NMC_PROPERTY_GET_PRETTY));
8037         set_val_str (arr, 8, nmc_property_wireless_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8038         set_val_str (arr, 9, nmc_property_wireless_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8039         set_val_str (arr, 10, nmc_property_wireless_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY));
8040         set_val_str (arr, 11, nmc_property_wireless_get_mac_address_randomization (setting, NMC_PROPERTY_GET_PRETTY));
8041         set_val_str (arr, 12, nmc_property_wireless_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8042         set_val_str (arr, 13, nmc_property_wireless_get_seen_bssids (setting, NMC_PROPERTY_GET_PRETTY));
8043         set_val_str (arr, 14, nmc_property_wireless_get_hidden (setting, NMC_PROPERTY_GET_PRETTY));
8044         set_val_str (arr, 15, nmc_property_wireless_get_powersave (setting, NMC_PROPERTY_GET_PRETTY));
8045         g_ptr_array_add (nmc->output_data, arr);
8046
8047         print_data (nmc);  /* Print all data */
8048
8049         return TRUE;
8050 }
8051
8052 static gboolean
8053 setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets)
8054 {
8055         NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting);
8056         NmcOutputField *tmpl, *arr;
8057         size_t tmpl_len;
8058
8059         g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (s_wireless_sec), FALSE);
8060
8061         tmpl = nmc_fields_setting_wireless_security;
8062         tmpl_len = sizeof (nmc_fields_setting_wireless_security);
8063         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_SECURITY_ALL,
8064                                                          tmpl, FALSE, NULL, NULL);
8065         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8066         g_ptr_array_add (nmc->output_data, arr);
8067
8068         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8069         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8070         set_val_str (arr, 1, nmc_property_wifi_sec_get_key_mgmt (setting, NMC_PROPERTY_GET_PRETTY));
8071         set_val_str (arr, 2, nmc_property_wifi_sec_get_wep_tx_keyidx (setting, NMC_PROPERTY_GET_PRETTY));
8072         set_val_str (arr, 3, nmc_property_wifi_sec_get_auth_alg (setting, NMC_PROPERTY_GET_PRETTY));
8073         set_val_str (arr, 4, nmc_property_wifi_sec_get_proto (setting, NMC_PROPERTY_GET_PRETTY));
8074         set_val_str (arr, 5, nmc_property_wifi_sec_get_pairwise (setting, NMC_PROPERTY_GET_PRETTY));
8075         set_val_str (arr, 6, nmc_property_wifi_sec_get_group (setting, NMC_PROPERTY_GET_PRETTY));
8076         set_val_str (arr, 7, nmc_property_wifi_sec_get_leap_username (setting, NMC_PROPERTY_GET_PRETTY));
8077         set_val_str (arr, 8, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key0));
8078         set_val_str (arr, 9, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key1));
8079         set_val_str (arr, 10, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key2));
8080         set_val_str (arr, 11, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key3));
8081         set_val_str (arr, 12, nmc_property_wifi_sec_get_wep_key_flags (setting, NMC_PROPERTY_GET_PRETTY));
8082         set_val_str (arr, 13, nmc_property_wifi_sec_get_wep_key_type (setting, NMC_PROPERTY_GET_PRETTY));
8083         set_val_str (arr, 14, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_psk));
8084         set_val_str (arr, 15, nmc_property_wifi_sec_get_psk_flags (setting, NMC_PROPERTY_GET_PRETTY));
8085         set_val_str (arr, 16, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_leap_password));
8086         set_val_str (arr, 17, nmc_property_wifi_sec_get_leap_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8087         g_ptr_array_add (nmc->output_data, arr);
8088
8089         print_data (nmc);  /* Print all data */
8090
8091         return TRUE;
8092 }
8093
8094 static gboolean
8095 setting_ip4_config_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8096 {
8097         NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting);
8098         NmcOutputField *tmpl, *arr;
8099         size_t tmpl_len;
8100
8101         g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (s_ip4), FALSE);
8102
8103         tmpl = nmc_fields_setting_ip4_config;
8104         tmpl_len = sizeof (nmc_fields_setting_ip4_config);
8105         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP4_CONFIG_ALL,
8106                                                          tmpl, FALSE, NULL, NULL);
8107         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8108         g_ptr_array_add (nmc->output_data, arr);
8109
8110         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8111         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8112         set_val_str (arr, 1, nmc_property_ipv4_get_method (setting, NMC_PROPERTY_GET_PRETTY));
8113         set_val_str (arr, 2, nmc_property_ipv4_get_dns (setting, NMC_PROPERTY_GET_PRETTY));
8114         set_val_str (arr, 3, nmc_property_ipv4_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY));
8115         set_val_str (arr, 4, nmc_property_ipv4_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY));
8116         set_val_str (arr, 5, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY));
8117         set_val_str (arr, 6, nmc_property_ipv4_get_gateway (setting, NMC_PROPERTY_GET_PRETTY));
8118         set_val_str (arr, 7, nmc_property_ipv4_get_routes (setting, NMC_PROPERTY_GET_PRETTY));
8119         set_val_str (arr, 8, nmc_property_ipv4_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY));
8120         set_val_str (arr, 9, nmc_property_ipv4_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
8121         set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
8122         set_val_str (arr, 11, nmc_property_ipv4_get_dhcp_client_id (setting, NMC_PROPERTY_GET_PRETTY));
8123         set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8124         set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8125         set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8126         set_val_str (arr, 15, nmc_property_ipv4_get_dhcp_fqdn (setting, NMC_PROPERTY_GET_PRETTY));
8127         set_val_str (arr, 16, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
8128         set_val_str (arr, 17, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
8129         set_val_str (arr, 18, nmc_property_ipv4_get_dad_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8130         g_ptr_array_add (nmc->output_data, arr);
8131
8132         print_data (nmc);  /* Print all data */
8133
8134         return TRUE;
8135 }
8136
8137 static gboolean
8138 setting_ip6_config_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8139 {
8140         NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting);
8141         NmcOutputField *tmpl, *arr;
8142         size_t tmpl_len;
8143
8144         g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (s_ip6), FALSE);
8145
8146         tmpl = nmc_fields_setting_ip6_config;
8147         tmpl_len = sizeof (nmc_fields_setting_ip6_config);
8148         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP6_CONFIG_ALL,
8149                                                          tmpl, FALSE, NULL, NULL);
8150         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8151         g_ptr_array_add (nmc->output_data, arr);
8152
8153         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8154         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8155         set_val_str (arr, 1, nmc_property_ipv6_get_method (setting, NMC_PROPERTY_GET_PRETTY));
8156         set_val_str (arr, 2, nmc_property_ipv6_get_dns (setting, NMC_PROPERTY_GET_PRETTY));
8157         set_val_str (arr, 3, nmc_property_ipv6_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY));
8158         set_val_str (arr, 4, nmc_property_ipv6_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY));
8159         set_val_str (arr, 5, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY));
8160         set_val_str (arr, 6, nmc_property_ipv6_get_gateway (setting, NMC_PROPERTY_GET_PRETTY));
8161         set_val_str (arr, 7, nmc_property_ipv6_get_routes (setting, NMC_PROPERTY_GET_PRETTY));
8162         set_val_str (arr, 8, nmc_property_ipv6_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY));
8163         set_val_str (arr, 9, nmc_property_ipv6_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
8164         set_val_str (arr, 10, nmc_property_ipv6_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
8165         set_val_str (arr, 11, nmc_property_ipv6_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
8166         set_val_str (arr, 12, nmc_property_ipv6_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
8167         set_val_str (arr, 13, nmc_property_ipv6_get_ip6_privacy (setting, NMC_PROPERTY_GET_PRETTY));
8168         set_val_str (arr, 14, nmc_property_ipv6_get_addr_gen_mode (setting, NMC_PROPERTY_GET_PRETTY));
8169         set_val_str (arr, 15, nmc_property_ipv6_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8170         set_val_str (arr, 16, nmc_property_ipv6_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
8171         g_ptr_array_add (nmc->output_data, arr);
8172
8173         print_data (nmc);  /* Print all data */
8174
8175         return TRUE;
8176 }
8177
8178 static gboolean
8179 setting_serial_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8180 {
8181         NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting);
8182         NmcOutputField *tmpl, *arr;
8183         size_t tmpl_len;
8184
8185         g_return_val_if_fail (NM_IS_SETTING_SERIAL (s_serial), FALSE);
8186
8187         tmpl = nmc_fields_setting_serial;
8188         tmpl_len = sizeof (nmc_fields_setting_serial);
8189         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_SERIAL_ALL,
8190                                                          tmpl, FALSE, NULL, NULL);
8191         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8192         g_ptr_array_add (nmc->output_data, arr);
8193
8194         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8195         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8196         set_val_str (arr, 1, nmc_property_serial_get_baud (setting, NMC_PROPERTY_GET_PRETTY));
8197         set_val_str (arr, 2, nmc_property_serial_get_bits (setting, NMC_PROPERTY_GET_PRETTY));
8198         set_val_str (arr, 3, nmc_property_serial_get_parity (setting, NMC_PROPERTY_GET_PRETTY));
8199         set_val_str (arr, 4, nmc_property_serial_get_stopbits (setting, NMC_PROPERTY_GET_PRETTY));
8200         set_val_str (arr, 5, nmc_property_serial_get_send_delay (setting, NMC_PROPERTY_GET_PRETTY));
8201         g_ptr_array_add (nmc->output_data, arr);
8202
8203         print_data (nmc);  /* Print all data */
8204
8205         return TRUE;
8206 }
8207
8208 static gboolean
8209 setting_ppp_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8210 {
8211         NMSettingPpp *s_ppp = NM_SETTING_PPP (setting);
8212         NmcOutputField *tmpl, *arr;
8213         size_t tmpl_len;
8214
8215         g_return_val_if_fail (NM_IS_SETTING_PPP (s_ppp), FALSE);
8216
8217         tmpl = nmc_fields_setting_ppp;
8218         tmpl_len = sizeof (nmc_fields_setting_ppp);
8219         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPP_ALL,
8220                                                          tmpl, FALSE, NULL, NULL);
8221         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8222         g_ptr_array_add (nmc->output_data, arr);
8223
8224         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8225         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8226         set_val_str (arr, 1, nmc_property_ppp_get_noauth (setting, NMC_PROPERTY_GET_PRETTY));
8227         set_val_str (arr, 2, nmc_property_ppp_get_refuse_eap (setting, NMC_PROPERTY_GET_PRETTY));
8228         set_val_str (arr, 3, nmc_property_ppp_get_refuse_pap (setting, NMC_PROPERTY_GET_PRETTY));
8229         set_val_str (arr, 4, nmc_property_ppp_get_refuse_chap (setting, NMC_PROPERTY_GET_PRETTY));
8230         set_val_str (arr, 5, nmc_property_ppp_get_refuse_mschap (setting, NMC_PROPERTY_GET_PRETTY));
8231         set_val_str (arr, 6, nmc_property_ppp_get_refuse_mschapv2 (setting, NMC_PROPERTY_GET_PRETTY));
8232         set_val_str (arr, 7, nmc_property_ppp_get_nobsdcomp (setting, NMC_PROPERTY_GET_PRETTY));
8233         set_val_str (arr, 8, nmc_property_ppp_get_nodeflate (setting, NMC_PROPERTY_GET_PRETTY));
8234         set_val_str (arr, 9, nmc_property_ppp_get_no_vj_comp (setting, NMC_PROPERTY_GET_PRETTY));
8235         set_val_str (arr, 10, nmc_property_ppp_get_require_mppe (setting, NMC_PROPERTY_GET_PRETTY));
8236         set_val_str (arr, 11, nmc_property_ppp_get_require_mppe_128 (setting, NMC_PROPERTY_GET_PRETTY));
8237         set_val_str (arr, 12, nmc_property_ppp_get_mppe_stateful (setting, NMC_PROPERTY_GET_PRETTY));
8238         set_val_str (arr, 13, nmc_property_ppp_get_crtscts (setting, NMC_PROPERTY_GET_PRETTY));
8239         set_val_str (arr, 14, nmc_property_ppp_get_baud (setting, NMC_PROPERTY_GET_PRETTY));
8240         set_val_str (arr, 15, nmc_property_ppp_get_mru (setting, NMC_PROPERTY_GET_PRETTY));
8241         set_val_str (arr, 16, nmc_property_ppp_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8242         set_val_str (arr, 17, nmc_property_ppp_get_lcp_echo_failure (setting, NMC_PROPERTY_GET_PRETTY));
8243         set_val_str (arr, 18, nmc_property_ppp_get_lcp_echo_interval (setting, NMC_PROPERTY_GET_PRETTY));
8244         g_ptr_array_add (nmc->output_data, arr);
8245
8246         print_data (nmc);  /* Print all data */
8247
8248         return TRUE;
8249 }
8250
8251 static gboolean
8252 setting_pppoe_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8253 {
8254         NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting);
8255         NmcOutputField *tmpl, *arr;
8256         size_t tmpl_len;
8257
8258         g_return_val_if_fail (NM_IS_SETTING_PPPOE (s_pppoe), FALSE);
8259
8260         tmpl = nmc_fields_setting_pppoe;
8261         tmpl_len = sizeof (nmc_fields_setting_pppoe);
8262         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPPOE_ALL,
8263                                                          tmpl, FALSE, NULL, NULL);
8264         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8265         g_ptr_array_add (nmc->output_data, arr);
8266
8267         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8268         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8269         set_val_str (arr, 1, nmc_property_pppoe_get_service (setting, NMC_PROPERTY_GET_PRETTY));
8270         set_val_str (arr, 2, nmc_property_pppoe_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8271         set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_pppoe_get_password));
8272         set_val_str (arr, 4, nmc_property_pppoe_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8273         g_ptr_array_add (nmc->output_data, arr);
8274
8275         print_data (nmc);  /* Print all data */
8276
8277         return TRUE;
8278 }
8279
8280 static gboolean
8281 setting_gsm_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8282 {
8283         NMSettingGsm *s_gsm = NM_SETTING_GSM (setting);
8284         NmcOutputField *tmpl, *arr;
8285         size_t tmpl_len;
8286
8287         g_return_val_if_fail (NM_IS_SETTING_GSM (s_gsm), FALSE);
8288
8289         tmpl = nmc_fields_setting_gsm;
8290         tmpl_len = sizeof (nmc_fields_setting_gsm);
8291         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_GSM_ALL,
8292                                                          tmpl, FALSE, NULL, NULL);
8293         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8294         g_ptr_array_add (nmc->output_data, arr);
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_gsm_get_number (setting, NMC_PROPERTY_GET_PRETTY));
8299         set_val_str (arr, 2, nmc_property_gsm_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8300         set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_gsm_get_password));
8301         set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8302         set_val_str (arr, 5, nmc_property_gsm_get_apn (setting, NMC_PROPERTY_GET_PRETTY));
8303         set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting, NMC_PROPERTY_GET_PRETTY));
8304         set_val_str (arr, 7, GET_SECRET (secrets, setting, nmc_property_gsm_get_pin));
8305         set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY));
8306         set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting, NMC_PROPERTY_GET_PRETTY));
8307         set_val_str (arr, 10, nmc_property_gsm_get_device_id (setting, NMC_PROPERTY_GET_PRETTY));
8308         set_val_str (arr, 11, nmc_property_gsm_get_sim_id (setting, NMC_PROPERTY_GET_PRETTY));
8309         set_val_str (arr, 12, nmc_property_gsm_get_sim_operator_id (setting, NMC_PROPERTY_GET_PRETTY));
8310         g_ptr_array_add (nmc->output_data, arr);
8311
8312         print_data (nmc);  /* Print all data */
8313
8314         return TRUE;
8315 }
8316
8317 static gboolean
8318 setting_cdma_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8319 {
8320         NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting);
8321         NmcOutputField *tmpl, *arr;
8322         size_t tmpl_len;
8323
8324         g_return_val_if_fail (NM_IS_SETTING_CDMA (s_cdma), FALSE);
8325
8326         tmpl = nmc_fields_setting_cdma;
8327         tmpl_len = sizeof (nmc_fields_setting_cdma);
8328         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CDMA_ALL,
8329                                                          tmpl, FALSE, NULL, NULL);
8330         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8331         g_ptr_array_add (nmc->output_data, arr);
8332
8333         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8334         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8335         set_val_str (arr, 1, nmc_property_cdma_get_number (setting, NMC_PROPERTY_GET_PRETTY));
8336         set_val_str (arr, 2, nmc_property_cdma_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8337         set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_cdma_get_password));
8338         set_val_str (arr, 4, nmc_property_cdma_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8339         g_ptr_array_add (nmc->output_data, arr);
8340
8341         print_data (nmc);  /* Print all data */
8342
8343         return TRUE;
8344 }
8345
8346 static gboolean
8347 setting_bluetooth_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8348 {
8349         NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting);
8350         NmcOutputField *tmpl, *arr;
8351         size_t tmpl_len;
8352
8353         g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (s_bluetooth), FALSE);
8354
8355         tmpl = nmc_fields_setting_bluetooth;
8356         tmpl_len = sizeof (nmc_fields_setting_bluetooth);
8357         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BLUETOOTH_ALL,
8358                                                          tmpl, FALSE, NULL, NULL);
8359         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8360         g_ptr_array_add (nmc->output_data, arr);
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_bluetooth_get_bdaddr (setting, NMC_PROPERTY_GET_PRETTY));
8365         set_val_str (arr, 2, nmc_property_bluetooth_get_type (setting, NMC_PROPERTY_GET_PRETTY));
8366         g_ptr_array_add (nmc->output_data, arr);
8367
8368         print_data (nmc);  /* Print all data */
8369
8370         return TRUE;
8371 }
8372
8373 static gboolean
8374 setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8375 {
8376         NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
8377         NmcOutputField *tmpl, *arr;
8378         size_t tmpl_len;
8379
8380         g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (s_olpc_mesh), FALSE);
8381
8382         tmpl = nmc_fields_setting_olpc_mesh;
8383         tmpl_len = sizeof (nmc_fields_setting_olpc_mesh);
8384         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_OLPC_MESH_ALL,
8385                                                          tmpl, FALSE, NULL, NULL);
8386         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8387         g_ptr_array_add (nmc->output_data, arr);
8388
8389         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8390         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8391         set_val_str (arr, 1, nmc_property_olpc_get_ssid (setting, NMC_PROPERTY_GET_PRETTY));
8392         set_val_str (arr, 2, nmc_property_olpc_get_channel (setting, NMC_PROPERTY_GET_PRETTY));
8393         set_val_str (arr, 3, nmc_property_olpc_get_anycast_address (setting, NMC_PROPERTY_GET_PRETTY));
8394         g_ptr_array_add (nmc->output_data, arr);
8395
8396         print_data (nmc);  /* Print all data */
8397
8398         return TRUE;
8399 }
8400
8401 static gboolean
8402 setting_vpn_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8403 {
8404         NMSettingVpn *s_vpn = NM_SETTING_VPN (setting);
8405         NmcOutputField *tmpl, *arr;
8406         size_t tmpl_len;
8407
8408         g_return_val_if_fail (NM_IS_SETTING_VPN (s_vpn), FALSE);
8409
8410         tmpl = nmc_fields_setting_vpn;
8411         tmpl_len = sizeof (nmc_fields_setting_vpn);
8412         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VPN_ALL,
8413                                                          tmpl, FALSE, NULL, NULL);
8414         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8415         g_ptr_array_add (nmc->output_data, arr);
8416
8417         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8418         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8419         set_val_str (arr, 1, nmc_property_vpn_get_service_type (setting, NMC_PROPERTY_GET_PRETTY));
8420         set_val_str (arr, 2, nmc_property_vpn_get_user_name (setting, NMC_PROPERTY_GET_PRETTY));
8421         set_val_str (arr, 3, nmc_property_vpn_get_data (setting, NMC_PROPERTY_GET_PRETTY));
8422         set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_vpn_get_secrets));
8423         set_val_str (arr, 5, nmc_property_vpn_get_persistent (setting, NMC_PROPERTY_GET_PRETTY));
8424         set_val_str (arr, 6, nmc_property_vpn_get_timeout (setting, NMC_PROPERTY_GET_PRETTY));
8425         g_ptr_array_add (nmc->output_data, arr);
8426
8427         print_data (nmc);  /* Print all data */
8428
8429         return TRUE;
8430 }
8431
8432 static gboolean
8433 setting_wimax_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8434 {
8435         NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting);
8436         NmcOutputField *tmpl, *arr;
8437         size_t tmpl_len;
8438
8439         g_return_val_if_fail (NM_IS_SETTING_WIMAX (s_wimax), FALSE);
8440
8441         tmpl = nmc_fields_setting_wimax;
8442         tmpl_len = sizeof (nmc_fields_setting_wimax);
8443         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIMAX_ALL,
8444                                                          tmpl, FALSE, NULL, NULL);
8445         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8446         g_ptr_array_add (nmc->output_data, arr);
8447
8448         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8449         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8450         set_val_str (arr, 1, nmc_property_wimax_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8451         set_val_str (arr, 2, nmc_property_wimax_get_network_name (setting, NMC_PROPERTY_GET_PRETTY));
8452         g_ptr_array_add (nmc->output_data, arr);
8453
8454         print_data (nmc);  /* Print all data */
8455
8456         return TRUE;
8457 }
8458
8459 static gboolean
8460 setting_infiniband_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8461 {
8462         NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
8463         NmcOutputField *tmpl, *arr;
8464         size_t tmpl_len;
8465
8466         g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (s_infiniband), FALSE);
8467
8468         tmpl = nmc_fields_setting_infiniband;
8469         tmpl_len = sizeof (nmc_fields_setting_infiniband);
8470         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_INFINIBAND_ALL,
8471                                                          tmpl, FALSE, NULL, NULL);
8472         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8473         g_ptr_array_add (nmc->output_data, arr);
8474
8475         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8476         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8477         set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8478         set_val_str (arr, 2, nmc_property_ib_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8479         set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting, NMC_PROPERTY_GET_PRETTY));
8480         set_val_str (arr, 4, nmc_property_ib_get_p_key (setting, NMC_PROPERTY_GET_PRETTY));
8481         set_val_str (arr, 5, nmc_property_ib_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8482         g_ptr_array_add (nmc->output_data, arr);
8483
8484         print_data (nmc);  /* Print all data */
8485
8486         return TRUE;
8487 }
8488
8489 static gboolean
8490 setting_bond_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8491 {
8492         NMSettingBond *s_bond = NM_SETTING_BOND (setting);
8493         NmcOutputField *tmpl, *arr;
8494         size_t tmpl_len;
8495
8496         g_return_val_if_fail (NM_IS_SETTING_BOND (s_bond), FALSE);
8497
8498         tmpl = nmc_fields_setting_bond;
8499         tmpl_len = sizeof (nmc_fields_setting_bond);
8500         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BOND_ALL,
8501                                                          tmpl, FALSE, NULL, NULL);
8502         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8503         g_ptr_array_add (nmc->output_data, arr);
8504
8505         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8506         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8507         set_val_str (arr, 1, nmc_property_bond_get_options (setting, NMC_PROPERTY_GET_PRETTY));
8508         g_ptr_array_add (nmc->output_data, arr);
8509
8510         print_data (nmc);  /* Print all data */
8511
8512         return TRUE;
8513 }
8514
8515 static gboolean
8516 setting_vlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8517 {
8518         NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting);
8519         NmcOutputField *tmpl, *arr;
8520         size_t tmpl_len;
8521
8522         g_return_val_if_fail (NM_IS_SETTING_VLAN (s_vlan), FALSE);
8523
8524         tmpl = nmc_fields_setting_vlan;
8525         tmpl_len = sizeof (nmc_fields_setting_vlan);
8526         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VLAN_ALL,
8527                                                          tmpl, FALSE, NULL, NULL);
8528         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8529         g_ptr_array_add (nmc->output_data, arr);
8530
8531         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8532         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8533         set_val_str (arr, 1, nmc_property_vlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8534         set_val_str (arr, 2, nmc_property_vlan_get_id (setting, NMC_PROPERTY_GET_PRETTY));
8535         set_val_str (arr, 3, nmc_property_vlan_get_flags (setting, NMC_PROPERTY_GET_PRETTY));
8536         set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting, NMC_PROPERTY_GET_PRETTY));
8537         set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting, NMC_PROPERTY_GET_PRETTY));
8538         g_ptr_array_add (nmc->output_data, arr);
8539
8540         print_data (nmc);  /* Print all data */
8541
8542         return TRUE;
8543 }
8544
8545 static gboolean
8546 setting_adsl_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8547 {
8548         NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting);
8549         NmcOutputField *tmpl, *arr;
8550         size_t tmpl_len;
8551
8552         g_return_val_if_fail (NM_IS_SETTING_ADSL (s_adsl), FALSE);
8553
8554         tmpl = nmc_fields_setting_adsl;
8555         tmpl_len = sizeof (nmc_fields_setting_adsl);
8556         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_ADSL_ALL,
8557                                                          tmpl, FALSE, NULL, NULL);
8558         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8559         g_ptr_array_add (nmc->output_data, arr);
8560
8561         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8562         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8563         set_val_str (arr, 1, nmc_property_adsl_get_username (setting, NMC_PROPERTY_GET_PRETTY));
8564         set_val_str (arr, 2, GET_SECRET (secrets, setting, nmc_property_adsl_get_password));
8565         set_val_str (arr, 3, nmc_property_adsl_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY));
8566         set_val_str (arr, 4, nmc_property_adsl_get_protocol (setting, NMC_PROPERTY_GET_PRETTY));
8567         set_val_str (arr, 5, nmc_property_adsl_get_encapsulation (setting, NMC_PROPERTY_GET_PRETTY));
8568         set_val_str (arr, 6, nmc_property_adsl_get_vpi (setting, NMC_PROPERTY_GET_PRETTY));
8569         set_val_str (arr, 7, nmc_property_adsl_get_vci (setting, NMC_PROPERTY_GET_PRETTY));
8570         g_ptr_array_add (nmc->output_data, arr);
8571
8572         print_data (nmc);  /* Print all data */
8573
8574         return TRUE;
8575 }
8576
8577 static gboolean
8578 setting_bridge_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8579 {
8580         NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting);
8581         NmcOutputField *tmpl, *arr;
8582         size_t tmpl_len;
8583
8584         g_return_val_if_fail (NM_IS_SETTING_BRIDGE (s_bridge), FALSE);
8585
8586         tmpl = nmc_fields_setting_bridge;
8587         tmpl_len = sizeof (nmc_fields_setting_bridge);
8588         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_ALL,
8589                                                          tmpl, FALSE, NULL, NULL);
8590         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8591         g_ptr_array_add (nmc->output_data, arr);
8592
8593         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8594         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8595         set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY));
8596         set_val_str (arr, 2, nmc_property_bridge_get_stp (setting, NMC_PROPERTY_GET_PRETTY));
8597         set_val_str (arr, 3, nmc_property_bridge_get_priority (setting, NMC_PROPERTY_GET_PRETTY));
8598         set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting, NMC_PROPERTY_GET_PRETTY));
8599         set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting, NMC_PROPERTY_GET_PRETTY));
8600         set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting, NMC_PROPERTY_GET_PRETTY));
8601         set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting, NMC_PROPERTY_GET_PRETTY));
8602         set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting, NMC_PROPERTY_GET_PRETTY));
8603         g_ptr_array_add (nmc->output_data, arr);
8604
8605         print_data (nmc);  /* Print all data */
8606
8607         return TRUE;
8608 }
8609
8610 static gboolean
8611 setting_bridge_port_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8612 {
8613         NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting);
8614         NmcOutputField *tmpl, *arr;
8615         size_t tmpl_len;
8616
8617         g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (s_bridge_port), FALSE);
8618
8619         tmpl = nmc_fields_setting_bridge_port;
8620         tmpl_len = sizeof (nmc_fields_setting_bridge_port);
8621         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_PORT_ALL,
8622                                                          tmpl, FALSE, NULL, NULL);
8623         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8624         g_ptr_array_add (nmc->output_data, arr);
8625
8626         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8627         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8628         set_val_str (arr, 1, nmc_property_bridge_port_get_priority (setting, NMC_PROPERTY_GET_PRETTY));
8629         set_val_str (arr, 2, nmc_property_bridge_port_get_path_cost (setting, NMC_PROPERTY_GET_PRETTY));
8630         set_val_str (arr, 3, nmc_property_bridge_port_get_hairpin_mode (setting, NMC_PROPERTY_GET_PRETTY));
8631         g_ptr_array_add (nmc->output_data, arr);
8632
8633         print_data (nmc);  /* Print all data */
8634
8635         return TRUE;
8636 }
8637
8638 static gboolean
8639 setting_team_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8640 {
8641         NMSettingTeam *s_team = NM_SETTING_TEAM (setting);
8642         NmcOutputField *tmpl, *arr;
8643         size_t tmpl_len;
8644
8645         g_return_val_if_fail (NM_IS_SETTING_TEAM (s_team), FALSE);
8646
8647         tmpl = nmc_fields_setting_team;
8648         tmpl_len = sizeof (nmc_fields_setting_team);
8649         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_ALL,
8650                                                          tmpl, FALSE, NULL, NULL);
8651         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8652         g_ptr_array_add (nmc->output_data, arr);
8653
8654         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8655         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8656         set_val_str (arr, 1, nmc_property_team_get_config (setting, NMC_PROPERTY_GET_PRETTY));
8657         g_ptr_array_add (nmc->output_data, arr);
8658
8659         print_data (nmc);  /* Print all data */
8660
8661         return TRUE;
8662 }
8663
8664 static gboolean
8665 setting_team_port_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8666 {
8667         NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting);
8668         NmcOutputField *tmpl, *arr;
8669         size_t tmpl_len;
8670
8671         g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (s_team_port), FALSE);
8672
8673         tmpl = nmc_fields_setting_team_port;
8674         tmpl_len = sizeof (nmc_fields_setting_team_port);
8675         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_PORT_ALL,
8676                                                          tmpl, FALSE, NULL, NULL);
8677         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8678         g_ptr_array_add (nmc->output_data, arr);
8679
8680         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8681         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8682         set_val_str (arr, 1, nmc_property_team_port_get_config (setting, NMC_PROPERTY_GET_PRETTY));
8683         g_ptr_array_add (nmc->output_data, arr);
8684
8685         print_data (nmc);  /* Print all data */
8686
8687         return TRUE;
8688 }
8689
8690 static gboolean
8691 setting_dcb_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8692 {
8693         NMSettingDcb *s_dcb = NM_SETTING_DCB (setting);
8694         NmcOutputField *tmpl, *arr;
8695         size_t tmpl_len;
8696
8697         g_return_val_if_fail (NM_IS_SETTING_DCB (s_dcb), FALSE);
8698
8699         tmpl = nmc_fields_setting_dcb;
8700         tmpl_len = sizeof (nmc_fields_setting_dcb);
8701         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_DCB_ALL,
8702                                                          tmpl, FALSE, NULL, NULL);
8703         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8704         g_ptr_array_add (nmc->output_data, arr);
8705
8706         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8707         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8708         set_val_str (arr, 1, nmc_property_dcb_get_app_fcoe_flags (setting, NMC_PROPERTY_GET_PRETTY));
8709         set_val_str (arr, 2, nmc_property_dcb_get_app_fcoe_priority (setting, NMC_PROPERTY_GET_PRETTY));
8710         set_val_str (arr, 3, nmc_property_dcb_get_app_fcoe_mode (setting, NMC_PROPERTY_GET_PRETTY));
8711         set_val_str (arr, 4, nmc_property_dcb_get_app_iscsi_flags (setting, NMC_PROPERTY_GET_PRETTY));
8712         set_val_str (arr, 5, nmc_property_dcb_get_app_iscsi_priority (setting, NMC_PROPERTY_GET_PRETTY));
8713         set_val_str (arr, 6, nmc_property_dcb_get_app_fip_flags (setting, NMC_PROPERTY_GET_PRETTY));
8714         set_val_str (arr, 7, nmc_property_dcb_get_app_fip_priority (setting, NMC_PROPERTY_GET_PRETTY));
8715         set_val_str (arr, 8, nmc_property_dcb_get_pfc_flags (setting, NMC_PROPERTY_GET_PRETTY));
8716         set_val_str (arr, 9, nmc_property_dcb_get_pfc (setting, NMC_PROPERTY_GET_PRETTY));
8717         set_val_str (arr, 10, nmc_property_dcb_get_pg_flags (setting, NMC_PROPERTY_GET_PRETTY));
8718         set_val_str (arr, 11, nmc_property_dcb_get_pg_group_id (setting, NMC_PROPERTY_GET_PRETTY));
8719         set_val_str (arr, 12, nmc_property_dcb_get_pg_group_bandwidth (setting, NMC_PROPERTY_GET_PRETTY));
8720         set_val_str (arr, 13, nmc_property_dcb_get_pg_bandwidth (setting, NMC_PROPERTY_GET_PRETTY));
8721         set_val_str (arr, 14, nmc_property_dcb_get_pg_strict (setting, NMC_PROPERTY_GET_PRETTY));
8722         set_val_str (arr, 15, nmc_property_dcb_get_pg_traffic_class (setting, NMC_PROPERTY_GET_PRETTY));
8723         g_ptr_array_add (nmc->output_data, arr);
8724
8725         print_data (nmc);  /* Print all data */
8726
8727         return TRUE;
8728 }
8729
8730 static gboolean
8731 setting_tun_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8732 {
8733         NMSettingTun *s_tun = NM_SETTING_TUN (setting);
8734         NmcOutputField *tmpl, *arr;
8735         size_t tmpl_len;
8736
8737         g_return_val_if_fail (NM_IS_SETTING_TUN (s_tun), FALSE);
8738
8739         tmpl = nmc_fields_setting_tun;
8740         tmpl_len = sizeof (nmc_fields_setting_tun);
8741         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TUN_ALL,
8742                                                          tmpl, FALSE, NULL, NULL);
8743         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8744         g_ptr_array_add (nmc->output_data, arr);
8745
8746         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8747         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8748         set_val_str (arr, 1, nmc_property_tun_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8749         set_val_str (arr, 2, nmc_property_tun_get_owner (setting, NMC_PROPERTY_GET_PRETTY));
8750         set_val_str (arr, 3, nmc_property_tun_get_group (setting, NMC_PROPERTY_GET_PRETTY));
8751         set_val_str (arr, 4, nmc_property_tun_get_pi (setting, NMC_PROPERTY_GET_PRETTY));
8752         set_val_str (arr, 5, nmc_property_tun_get_vnet_hdr (setting, NMC_PROPERTY_GET_PRETTY));
8753         set_val_str (arr, 6, nmc_property_tun_get_multi_queue (setting, NMC_PROPERTY_GET_PRETTY));
8754         g_ptr_array_add (nmc->output_data, arr);
8755
8756         print_data (nmc);  /* Print all data */
8757
8758         return TRUE;
8759 }
8760
8761 static gboolean
8762 setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8763 {
8764         NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting);
8765         NmcOutputField *tmpl, *arr;
8766         size_t tmpl_len;
8767
8768         g_return_val_if_fail (NM_IS_SETTING_IP_TUNNEL (s_ip_tunnel), FALSE);
8769
8770         tmpl = nmc_fields_setting_ip_tunnel;
8771         tmpl_len = sizeof (nmc_fields_setting_ip_tunnel);
8772         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP_TUNNEL_ALL,
8773                                                          tmpl, FALSE, NULL, NULL);
8774         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8775         g_ptr_array_add (nmc->output_data, arr);
8776
8777         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8778         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8779         set_val_str (arr, 1, nmc_property_ip_tunnel_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8780         set_val_str (arr, 2, nmc_property_ip_tunnel_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8781         set_val_str (arr, 3, nmc_property_ip_tunnel_get_local (setting, NMC_PROPERTY_GET_PRETTY));
8782         set_val_str (arr, 4, nmc_property_ip_tunnel_get_remote (setting, NMC_PROPERTY_GET_PRETTY));
8783         set_val_str (arr, 5, nmc_property_ip_tunnel_get_ttl (setting, NMC_PROPERTY_GET_PRETTY));
8784         set_val_str (arr, 6, nmc_property_ip_tunnel_get_tos (setting, NMC_PROPERTY_GET_PRETTY));
8785         set_val_str (arr, 7, nmc_property_ip_tunnel_get_path_mtu_discovery (setting, NMC_PROPERTY_GET_PRETTY));
8786         set_val_str (arr, 8, nmc_property_ip_tunnel_get_input_key (setting, NMC_PROPERTY_GET_PRETTY));
8787         set_val_str (arr, 9, nmc_property_ip_tunnel_get_output_key (setting, NMC_PROPERTY_GET_PRETTY));
8788         set_val_str (arr, 10, nmc_property_ip_tunnel_get_encapsulation_limit (setting, NMC_PROPERTY_GET_PRETTY));
8789         set_val_str (arr, 11, nmc_property_ip_tunnel_get_flow_label (setting, NMC_PROPERTY_GET_PRETTY));
8790         set_val_str (arr, 12, nmc_property_ip_tunnel_get_mtu (setting, NMC_PROPERTY_GET_PRETTY));
8791         g_ptr_array_add (nmc->output_data, arr);
8792
8793         print_data (nmc);  /* Print all data */
8794
8795         return TRUE;
8796 }
8797
8798 static gboolean
8799 setting_macvlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8800 {
8801         NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting);
8802         NmcOutputField *tmpl, *arr;
8803         size_t tmpl_len;
8804
8805         g_return_val_if_fail (NM_IS_SETTING_MACVLAN (s_macvlan), FALSE);
8806
8807         tmpl = nmc_fields_setting_macvlan;
8808         tmpl_len = sizeof (nmc_fields_setting_macvlan);
8809         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_MACVLAN_ALL,
8810                                                          tmpl, FALSE, NULL, NULL);
8811         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8812         g_ptr_array_add (nmc->output_data, arr);
8813
8814         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
8815         set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
8816         set_val_str (arr, 1, nmc_property_macvlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8817         set_val_str (arr, 2, nmc_property_macvlan_get_mode (setting, NMC_PROPERTY_GET_PRETTY));
8818         set_val_str (arr, 3, nmc_property_macvlan_get_promiscuous (setting, NMC_PROPERTY_GET_PRETTY));
8819         set_val_str (arr, 4, nmc_property_macvlan_get_tap (setting, NMC_PROPERTY_GET_PRETTY));
8820         g_ptr_array_add (nmc->output_data, arr);
8821
8822         print_data (nmc);  /* Print all data */
8823
8824         return TRUE;
8825 }
8826
8827  static gboolean
8828 setting_vxlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8829 {
8830         NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting);
8831         NmcOutputField *tmpl, *arr;
8832         size_t tmpl_len;
8833
8834         g_return_val_if_fail (NM_IS_SETTING_VXLAN (s_vxlan), FALSE);
8835
8836         tmpl = nmc_fields_setting_vxlan;
8837         tmpl_len = sizeof (nmc_fields_setting_vxlan);
8838         nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VXLAN_ALL,
8839                                                          tmpl, FALSE, NULL, NULL);
8840         arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
8841         g_ptr_array_add (nmc->output_data, arr);
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_vxlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY));
8846         set_val_str (arr, 2, nmc_property_vxlan_get_id (setting, NMC_PROPERTY_GET_PRETTY));
8847         set_val_str (arr, 3, nmc_property_vxlan_get_local (setting, NMC_PROPERTY_GET_PRETTY));
8848         set_val_str (arr, 4, nmc_property_vxlan_get_remote (setting, NMC_PROPERTY_GET_PRETTY));
8849         set_val_str (arr, 5, nmc_property_vxlan_get_source_port_min (setting, NMC_PROPERTY_GET_PRETTY));
8850         set_val_str (arr, 6, nmc_property_vxlan_get_source_port_max (setting, NMC_PROPERTY_GET_PRETTY));
8851         set_val_str (arr, 7, nmc_property_vxlan_get_destination_port (setting, NMC_PROPERTY_GET_PRETTY));
8852         set_val_str (arr, 8, nmc_property_vxlan_get_tos (setting, NMC_PROPERTY_GET_PRETTY));
8853         set_val_str (arr, 9, nmc_property_vxlan_get_ttl (setting, NMC_PROPERTY_GET_PRETTY));
8854         set_val_str (arr, 10, nmc_property_vxlan_get_ageing (setting, NMC_PROPERTY_GET_PRETTY));
8855         set_val_str (arr, 11, nmc_property_vxlan_get_limit (setting, NMC_PROPERTY_GET_PRETTY));
8856         set_val_str (arr, 12, nmc_property_vxlan_get_learning (setting, NMC_PROPERTY_GET_PRETTY));
8857         set_val_str (arr, 13, nmc_property_vxlan_get_proxy (setting, NMC_PROPERTY_GET_PRETTY));
8858         set_val_str (arr, 14, nmc_property_vxlan_get_rsc (setting, NMC_PROPERTY_GET_PRETTY));
8859         set_val_str (arr, 15, nmc_property_vxlan_get_l2_miss (setting, NMC_PROPERTY_GET_PRETTY));
8860         set_val_str (arr, 16, nmc_property_vxlan_get_l3_miss (setting, NMC_PROPERTY_GET_PRETTY));
8861         g_ptr_array_add (nmc->output_data, arr);
8862
8863         print_data (nmc);  /* Print all data */
8864
8865         return TRUE;
8866 }
8867
8868 typedef struct {
8869         const char *sname;
8870         gboolean (*func) (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets);
8871 } SettingDetails;
8872
8873 static const SettingDetails detail_printers[] = {
8874         { NM_SETTING_CONNECTION_SETTING_NAME,        setting_connection_details },
8875         { NM_SETTING_WIRED_SETTING_NAME,             setting_wired_details },
8876         { NM_SETTING_802_1X_SETTING_NAME,            setting_802_1X_details },
8877         { NM_SETTING_WIRELESS_SETTING_NAME,          setting_wireless_details },
8878         { NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, setting_wireless_security_details },
8879         { NM_SETTING_IP4_CONFIG_SETTING_NAME,        setting_ip4_config_details },
8880         { NM_SETTING_IP6_CONFIG_SETTING_NAME,        setting_ip6_config_details },
8881         { NM_SETTING_SERIAL_SETTING_NAME,            setting_serial_details },
8882         { NM_SETTING_PPP_SETTING_NAME,               setting_ppp_details },
8883         { NM_SETTING_PPPOE_SETTING_NAME,             setting_pppoe_details },
8884         { NM_SETTING_GSM_SETTING_NAME,               setting_gsm_details },
8885         { NM_SETTING_CDMA_SETTING_NAME,              setting_cdma_details },
8886         { NM_SETTING_BLUETOOTH_SETTING_NAME,         setting_bluetooth_details },
8887         { NM_SETTING_OLPC_MESH_SETTING_NAME,         setting_olpc_mesh_details },
8888         { NM_SETTING_VPN_SETTING_NAME,               setting_vpn_details },
8889         { NM_SETTING_WIMAX_SETTING_NAME,             setting_wimax_details },
8890         { NM_SETTING_INFINIBAND_SETTING_NAME,        setting_infiniband_details },
8891         { NM_SETTING_BOND_SETTING_NAME,              setting_bond_details },
8892         { NM_SETTING_VLAN_SETTING_NAME,              setting_vlan_details },
8893         { NM_SETTING_ADSL_SETTING_NAME,              setting_adsl_details },
8894         { NM_SETTING_BRIDGE_SETTING_NAME,            setting_bridge_details },
8895         { NM_SETTING_BRIDGE_PORT_SETTING_NAME,       setting_bridge_port_details },
8896         { NM_SETTING_TEAM_SETTING_NAME,              setting_team_details },
8897         { NM_SETTING_TEAM_PORT_SETTING_NAME,         setting_team_port_details },
8898         { NM_SETTING_DCB_SETTING_NAME,               setting_dcb_details },
8899         { NM_SETTING_TUN_SETTING_NAME,               setting_tun_details },
8900         { NM_SETTING_IP_TUNNEL_SETTING_NAME,         setting_ip_tunnel_details },
8901         { NM_SETTING_MACVLAN_SETTING_NAME,           setting_macvlan_details },
8902         { NM_SETTING_VXLAN_SETTING_NAME,             setting_vxlan_details },
8903         { NULL },
8904 };
8905
8906 gboolean
8907 setting_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
8908 {
8909         const SettingDetails *iter = &detail_printers[0];
8910
8911         g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
8912
8913         while (iter->sname) {
8914                 if (nm_setting_lookup_type (iter->sname) == G_OBJECT_TYPE (setting))
8915                         return iter->func (setting, nmc, one_prop, secrets);
8916                 iter++;
8917         }
8918
8919         g_assert_not_reached ();
8920         return FALSE;
8921 }
8922