man,libnm-core: fix typos
[NetworkManager.git] / libnm-core / nm-setting-wired.c
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 /*
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301 USA.
18  *
19  * Copyright 2007 - 2014 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #include "nm-default.h"
24
25 #include "nm-setting-wired.h"
26
27 #include <string.h>
28 #include <net/ethernet.h>
29
30 #include "nm-utils.h"
31 #include "nm-utils-private.h"
32 #include "nm-setting-private.h"
33
34 /**
35  * SECTION:nm-setting-wired
36  * @short_description: Describes connection properties for Ethernet-based networks
37  *
38  * The #NMSettingWired object is a #NMSetting subclass that describes properties
39  * necessary for connection to Ethernet networks.
40  **/
41
42 G_DEFINE_TYPE_WITH_CODE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING,
43                          _nm_register_setting (WIRED, 1))
44 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRED)
45
46 #define NM_SETTING_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate))
47
48 typedef struct {
49         char *port;
50         guint32 speed;
51         char *duplex;
52         gboolean auto_negotiate;
53         char *device_mac_address;
54         char *cloned_mac_address;
55         GArray *mac_address_blacklist;
56         guint32 mtu;
57         char **s390_subchannels;
58         char *s390_nettype;
59         GHashTable *s390_options;
60         NMSettingWiredWakeOnLan wol;
61         char *wol_password;
62 } NMSettingWiredPrivate;
63
64 enum {
65         PROP_0,
66         PROP_PORT,
67         PROP_SPEED,
68         PROP_DUPLEX,
69         PROP_AUTO_NEGOTIATE,
70         PROP_MAC_ADDRESS,
71         PROP_CLONED_MAC_ADDRESS,
72         PROP_MAC_ADDRESS_BLACKLIST,
73         PROP_MTU,
74         PROP_S390_SUBCHANNELS,
75         PROP_S390_NETTYPE,
76         PROP_S390_OPTIONS,
77         PROP_WAKE_ON_LAN,
78         PROP_WAKE_ON_LAN_PASSWORD,
79
80         LAST_PROP
81 };
82
83 static const char *valid_s390_opts[] = {
84         "portno", "layer2", "portname", "protocol", "priority_queueing",
85         "buffer_count", "isolation", "total", "inter", "inter_jumbo", "route4",
86         "route6", "fake_broadcast", "broadcast_mode", "canonical_macaddr",
87         "checksumming", "sniffer", "large_send", "ipato_enable", "ipato_invert4",
88         "ipato_add4", "ipato_invert6", "ipato_add6", "vipa_add4", "vipa_add6",
89         "rxip_add4", "rxip_add6", "lancmd_timeout", "ctcprot",
90         NULL
91 };
92
93 /**
94  * nm_setting_wired_new:
95  *
96  * Creates a new #NMSettingWired object with default values.
97  *
98  * Returns: (transfer full): the new empty #NMSettingWired object
99  **/
100 NMSetting *
101 nm_setting_wired_new (void)
102 {
103         return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRED, NULL);
104 }
105
106 /**
107  * nm_setting_wired_get_port:
108  * @setting: the #NMSettingWired
109  *
110  * Returns: the #NMSettingWired:port property of the setting
111  **/
112 const char *
113 nm_setting_wired_get_port (NMSettingWired *setting)
114 {
115         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
116
117         return NM_SETTING_WIRED_GET_PRIVATE (setting)->port;
118 }
119
120 /**
121  * nm_setting_wired_get_speed:
122  * @setting: the #NMSettingWired
123  *
124  * Returns: the #NMSettingWired:speed property of the setting
125  **/
126 guint32
127 nm_setting_wired_get_speed (NMSettingWired *setting)
128 {
129         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
130
131         return NM_SETTING_WIRED_GET_PRIVATE (setting)->speed;
132 }
133
134 /**
135  * nm_setting_wired_get_duplex:
136  * @setting: the #NMSettingWired
137  *
138  * Returns: the #NMSettingWired:duplex property of the setting
139  **/
140 const char *
141 nm_setting_wired_get_duplex (NMSettingWired *setting)
142 {
143         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
144
145         return NM_SETTING_WIRED_GET_PRIVATE (setting)->duplex;
146 }
147
148 /**
149  * nm_setting_wired_get_auto_negotiate:
150  * @setting: the #NMSettingWired
151  *
152  * Returns: the #NMSettingWired:auto-negotiate property of the setting
153  **/
154 gboolean
155 nm_setting_wired_get_auto_negotiate (NMSettingWired *setting)
156 {
157         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
158
159         return NM_SETTING_WIRED_GET_PRIVATE (setting)->auto_negotiate;
160 }
161
162 /**
163  * nm_setting_wired_get_mac_address:
164  * @setting: the #NMSettingWired
165  *
166  * Returns: the #NMSettingWired:mac-address property of the setting
167  **/
168 const char *
169 nm_setting_wired_get_mac_address (NMSettingWired *setting)
170 {
171         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
172
173         return NM_SETTING_WIRED_GET_PRIVATE (setting)->device_mac_address;
174 }
175
176 /**
177  * nm_setting_wired_get_cloned_mac_address:
178  * @setting: the #NMSettingWired
179  *
180  * Returns: the #NMSettingWired:cloned-mac-address property of the setting
181  **/
182 const char *
183 nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting)
184 {
185         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
186
187         return NM_SETTING_WIRED_GET_PRIVATE (setting)->cloned_mac_address;
188 }
189
190 /**
191  * nm_setting_wired_get_mac_address_blacklist:
192  * @setting: the #NMSettingWired
193  *
194  * Returns: the #NMSettingWired:mac-address-blacklist property of the setting
195  **/
196 const char * const *
197 nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting)
198 {
199         NMSettingWiredPrivate *priv;
200
201         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
202
203         priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
204         return (const char * const *) priv->mac_address_blacklist->data;
205 }
206
207 /**
208  * nm_setting_wired_get_num_mac_blacklist_items:
209  * @setting: the #NMSettingWired
210  *
211  * Returns: the number of blacklisted MAC addresses
212  **/
213 guint32
214 nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting)
215 {
216         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
217
218         return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist->len;
219 }
220
221 /**
222  * nm_setting_wired_get_mac_blacklist_item:
223  * @setting: the #NMSettingWired
224  * @idx: the zero-based index of the MAC address entry
225  *
226  * Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
227  * at index @idx
228  **/
229 const char *
230 nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting, guint32 idx)
231 {
232         NMSettingWiredPrivate *priv;
233
234         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
235
236         priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
237         g_return_val_if_fail (idx <= priv->mac_address_blacklist->len, NULL);
238
239         return g_array_index (priv->mac_address_blacklist, const char *, idx);
240 }
241
242 /**
243  * nm_setting_wired_add_mac_blacklist_item:
244  * @setting: the #NMSettingWired
245  * @mac: the MAC address string (hex-digits-and-colons notation) to blacklist
246  *
247  * Adds a new MAC address to the #NMSettingWired:mac-address-blacklist property.
248  *
249  * Returns: %TRUE if the MAC address was added; %FALSE if the MAC address
250  * is invalid or was already present
251  **/
252 gboolean
253 nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting, const char *mac)
254 {
255         NMSettingWiredPrivate *priv;
256         const char *candidate;
257         int i;
258
259         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
260         g_return_val_if_fail (mac != NULL, FALSE);
261
262         if (!nm_utils_hwaddr_valid (mac, ETH_ALEN))
263                 return FALSE;
264
265         priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
266         for (i = 0; i < priv->mac_address_blacklist->len; i++) {
267                 candidate = g_array_index (priv->mac_address_blacklist, char *, i);
268                 if (nm_utils_hwaddr_matches (mac, -1, candidate, -1))
269                         return FALSE;
270         }
271
272         mac = nm_utils_hwaddr_canonical (mac, ETH_ALEN);
273         g_array_append_val (priv->mac_address_blacklist, mac);
274         g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
275         return TRUE;
276 }
277
278 /**
279  * nm_setting_wired_remove_mac_blacklist_item:
280  * @setting: the #NMSettingWired
281  * @idx: index number of the MAC address
282  *
283  * Removes the MAC address at index @idx from the blacklist.
284  **/
285 void
286 nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx)
287 {
288         NMSettingWiredPrivate *priv;
289
290         g_return_if_fail (NM_IS_SETTING_WIRED (setting));
291
292         priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
293         g_return_if_fail (idx < priv->mac_address_blacklist->len);
294
295         g_array_remove_index (priv->mac_address_blacklist, idx);
296         g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
297 }
298
299 /**
300  * nm_setting_wired_remove_mac_blacklist_item_by_value:
301  * @setting: the #NMSettingWired
302  * @mac: the MAC address string (hex-digits-and-colons notation) to remove from
303  * the blacklist
304  *
305  * Removes the MAC address @mac from the blacklist.
306  *
307  * Returns: %TRUE if the MAC address was found and removed; %FALSE if it was not.
308  **/
309 gboolean
310 nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting, const char *mac)
311 {
312         NMSettingWiredPrivate *priv;
313         const char *candidate;
314         int i;
315
316         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
317         g_return_val_if_fail (mac != NULL, FALSE);
318
319         priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
320         for (i = 0; i < priv->mac_address_blacklist->len; i++) {
321                 candidate = g_array_index (priv->mac_address_blacklist, char *, i);
322                 if (!nm_utils_hwaddr_matches (mac, -1, candidate, -1)) {
323                         g_array_remove_index (priv->mac_address_blacklist, i);
324                         g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
325                         return TRUE;
326                 }
327         }
328         return FALSE;
329 }
330
331 /**
332  * nm_setting_wired_clear_mac_blacklist_items:
333  * @setting: the #NMSettingWired
334  *
335  * Removes all blacklisted MAC addresses.
336  **/
337 void
338 nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting)
339 {
340         g_return_if_fail (NM_IS_SETTING_WIRED (setting));
341
342         g_array_set_size (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist, 0);
343         g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
344 }
345
346 /**
347  * nm_setting_wired_get_mtu:
348  * @setting: the #NMSettingWired
349  *
350  * Returns: the #NMSettingWired:mtu property of the setting
351  **/
352 guint32
353 nm_setting_wired_get_mtu (NMSettingWired *setting)
354 {
355         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
356
357         return NM_SETTING_WIRED_GET_PRIVATE (setting)->mtu;
358 }
359
360 /**
361  * nm_setting_wired_get_s390_subchannels:
362  * @setting: the #NMSettingWired
363  *
364  * Return the list of s390 subchannels that identify the device that this
365  * connection is applicable to.  The connection should only be used in
366  * conjunction with that device.
367  *
368  * Returns: (transfer none) (element-type utf8): array of strings, each specifying
369  *   one subchannel the s390 device uses to communicate to the host.
370  **/
371 const char * const *
372 nm_setting_wired_get_s390_subchannels (NMSettingWired *setting)
373 {
374         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
375
376         return (const char * const *) NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
377 }
378
379 /**
380  * nm_setting_wired_get_s390_nettype:
381  * @setting: the #NMSettingWired
382  *
383  * Returns the s390 device type this connection should apply to.  Will be one
384  * of 'qeth', 'lcs', or 'ctc'.
385  *
386  * Returns: the s390 device type
387  **/
388 const char *
389 nm_setting_wired_get_s390_nettype (NMSettingWired *setting)
390 {
391         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
392
393         return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_nettype;
394 }
395
396 /**
397  * nm_setting_wired_get_num_s390_options:
398  * @setting: the #NMSettingWired
399  *
400  * Returns the number of s390-specific options that should be set for this
401  * device when it is activated.  This can be used to retrieve each s390
402  * option individually using nm_setting_wired_get_s390_option().
403  *
404  * Returns: the number of s390-specific device options
405  **/
406 guint32
407 nm_setting_wired_get_num_s390_options (NMSettingWired *setting)
408 {
409         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
410
411         return g_hash_table_size (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options);
412 }
413
414 /**
415  * nm_setting_wired_get_s390_option:
416  * @setting: the #NMSettingWired
417  * @idx: index of the desired option, from 0 to
418  * nm_setting_wired_get_num_s390_options() - 1
419  * @out_key: (out) (transfer none): on return, the key name of the s390 specific
420  *   option; this value is owned by the setting and should not be modified
421  * @out_value: (out) (transfer none): on return, the value of the key of the
422  *   s390 specific option; this value is owned by the setting and should not be
423  *   modified
424  *
425  * Given an index, return the value of the s390 option at that index.  indexes
426  * are *not* guaranteed to be static across modifications to options done by
427  * nm_setting_wired_add_s390_option() and nm_setting_wired_remove_s390_option(),
428  * and should not be used to refer to options except for short periods of time
429  * such as during option iteration.
430  *
431  * Returns: %TRUE on success if the index was valid and an option was found,
432  * %FALSE if the index was invalid (ie, greater than the number of options
433  * currently held by the setting)
434  **/
435 gboolean
436 nm_setting_wired_get_s390_option (NMSettingWired *setting,
437                                   guint32 idx,
438                                   const char **out_key,
439                                   const char **out_value)
440 {
441         const char *_key, *_value;
442         GHashTableIter iter;
443         guint i = 0;
444
445         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
446
447         g_hash_table_iter_init (&iter, NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options);
448         while (g_hash_table_iter_next (&iter, (gpointer) &_key, (gpointer) &_value)) {
449                 if (i == idx) {
450                         if (out_key)
451                                 *out_key = _key;
452                         if (out_value)
453                                 *out_value = _value;
454                         return TRUE;
455                 }
456                 i++;
457         }
458         g_return_val_if_reached (FALSE);
459 }
460
461 /**
462  * nm_setting_wired_get_s390_option_by_key:
463  * @setting: the #NMSettingWired
464  * @key: the key for which to retrieve the value
465  *
466  * Returns the value associated with the s390-specific option specified by
467  * @key, if it exists.
468  *
469  * Returns: the value, or %NULL if the key/value pair was never added to the
470  * setting; the value is owned by the setting and must not be modified
471  **/
472 const char *
473 nm_setting_wired_get_s390_option_by_key (NMSettingWired *setting,
474                                          const char *key)
475 {
476         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
477         g_return_val_if_fail (key != NULL, NULL);
478         g_return_val_if_fail (strlen (key), NULL);
479
480         return g_hash_table_lookup (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key);
481 }
482
483 /**
484  * nm_setting_wired_add_s390_option:
485  * @setting: the #NMSettingWired
486  * @key: key name for the option
487  * @value: value for the option
488  *
489  * Add an option to the table.  The option is compared to an internal list
490  * of allowed options.  Key names may contain only alphanumeric characters
491  * (ie [a-zA-Z0-9]).  Adding a new key replaces any existing key/value pair that
492  * may already exist.
493  *
494  * Returns: %TRUE if the option was valid and was added to the internal option
495  * list, %FALSE if it was not.
496  **/
497 gboolean
498 nm_setting_wired_add_s390_option (NMSettingWired *setting,
499                                   const char *key,
500                                   const char *value)
501 {
502         size_t value_len;
503
504         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
505         g_return_val_if_fail (key != NULL, FALSE);
506         g_return_val_if_fail (strlen (key), FALSE);
507         g_return_val_if_fail (_nm_utils_string_in_list (key, valid_s390_opts), FALSE);
508         g_return_val_if_fail (value != NULL, FALSE);
509
510         value_len = strlen (value);
511         g_return_val_if_fail (value_len > 0 && value_len < 200, FALSE);
512
513         g_hash_table_insert (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options,
514                              g_strdup (key),
515                              g_strdup (value));
516         g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_S390_OPTIONS);
517         return TRUE;
518 }
519
520 /**
521  * nm_setting_wired_remove_s390_option:
522  * @setting: the #NMSettingWired
523  * @key: key name for the option to remove
524  *
525  * Remove the s390-specific option referenced by @key from the internal option
526  * list.
527  *
528  * Returns: %TRUE if the option was found and removed from the internal option
529  * list, %FALSE if it was not.
530  **/
531 gboolean
532 nm_setting_wired_remove_s390_option (NMSettingWired *setting,
533                                      const char *key)
534 {
535         gboolean found;
536
537         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
538         g_return_val_if_fail (key != NULL, FALSE);
539         g_return_val_if_fail (strlen (key), FALSE);
540
541         found = g_hash_table_remove (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key);
542         if (found)
543                 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_S390_OPTIONS);
544         return found;
545 }
546
547 /**
548  * nm_setting_wired_get_valid_s390_options:
549  * @setting: the #NMSettingWired
550  *
551  * Returns a list of valid s390 options.
552  *
553  * Returns: (transfer none): a %NULL-terminated array of strings of valid s390 options.
554  **/
555 const char **
556 nm_setting_wired_get_valid_s390_options (NMSettingWired *setting)
557 {
558         return valid_s390_opts;
559 }
560
561 /**
562  * nm_setting_wired_get_wake_on_lan:
563  * @setting: the #NMSettingWired
564  *
565  * Returns the Wake-on-LAN options enabled for the connection
566  *
567  * Returns: the Wake-on-LAN options
568  *
569  * Since: 1.2
570  */
571 NMSettingWiredWakeOnLan
572 nm_setting_wired_get_wake_on_lan (NMSettingWired *setting)
573 {
574         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NM_SETTING_WIRED_WAKE_ON_LAN_NONE);
575
576         return NM_SETTING_WIRED_GET_PRIVATE (setting)->wol;
577 }
578 NM_BACKPORT_SYMBOL (libnm_1_0_6, NMSettingWiredWakeOnLan, nm_setting_wired_get_wake_on_lan,
579                     (NMSettingWired *setting), (setting));
580
581 /**
582  * nm_setting_wired_get_wake_on_lan_password:
583  * @setting: the #NMSettingWired
584  *
585  * Returns the Wake-on-LAN password. This only applies to
586  * %NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC.
587  *
588  * Returns: the Wake-on-LAN setting password, or %NULL if there is no password.
589  *
590  * Since: 1.2
591  */
592 const char *
593 nm_setting_wired_get_wake_on_lan_password (NMSettingWired *setting)
594 {
595         g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
596
597         return NM_SETTING_WIRED_GET_PRIVATE (setting)->wol_password;
598 }
599 NM_BACKPORT_SYMBOL (libnm_1_0_6, const char *, nm_setting_wired_get_wake_on_lan_password,
600                     (NMSettingWired *setting), (setting));
601
602 NM_BACKPORT_SYMBOL (libnm_1_0_6, GType, nm_setting_wired_wake_on_lan_get_type, (void), ());
603
604 static gboolean
605 verify (NMSetting *setting, NMConnection *connection, GError **error)
606 {
607         NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
608         const char *valid_ports[] = { "tp", "aui", "bnc", "mii", NULL };
609         const char *valid_duplex[] = { "half", "full", NULL };
610         const char *valid_nettype[] = { "qeth", "lcs", "ctc", NULL };
611         GHashTableIter iter;
612         const char *key, *value;
613         int i;
614
615         if (priv->port && !_nm_utils_string_in_list (priv->port, valid_ports)) {
616                 g_set_error (error,
617                              NM_CONNECTION_ERROR,
618                              NM_CONNECTION_ERROR_INVALID_PROPERTY,
619                              _("'%s' is not a valid Ethernet port value"),
620                              priv->port);
621                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_PORT);
622                 return FALSE;
623         }
624
625         if (priv->duplex && !_nm_utils_string_in_list (priv->duplex, valid_duplex)) {
626                 g_set_error (error,
627                              NM_CONNECTION_ERROR,
628                              NM_CONNECTION_ERROR_INVALID_PROPERTY,
629                              _("'%s' is not a valid duplex value"),
630                              priv->duplex);
631                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_DUPLEX);
632                 return FALSE;
633         }
634
635         if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) {
636                 g_set_error_literal (error,
637                                      NM_CONNECTION_ERROR,
638                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
639                                      _("is not a valid MAC address"));
640                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS);
641                 return FALSE;
642         }
643
644         for (i = 0; i < priv->mac_address_blacklist->len; i++) {
645                 const char *mac = g_array_index (priv->mac_address_blacklist, const char *, i);
646
647                 if (!nm_utils_hwaddr_valid (mac, ETH_ALEN)) {
648                         g_set_error (error,
649                                      NM_CONNECTION_ERROR,
650                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
651                                      _("'%s' is not a valid MAC address"),
652                                      mac);
653                         g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
654                         return FALSE;
655                 }
656         }
657
658         if (priv->s390_subchannels) {
659                 int len = g_strv_length (priv->s390_subchannels);
660
661                 if (len != 2 && len != 3) {
662                         g_set_error_literal (error,
663                                              NM_CONNECTION_ERROR,
664                                              NM_CONNECTION_ERROR_INVALID_PROPERTY,
665                                              _("property is invalid"));
666                         g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS);
667                         return FALSE;
668                 }
669         }
670
671         if (priv->s390_nettype && !_nm_utils_string_in_list (priv->s390_nettype, valid_nettype)) {
672                 g_set_error_literal (error,
673                                      NM_CONNECTION_ERROR,
674                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
675                                      _("property is invalid"));
676                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_NETTYPE);
677                 return FALSE;
678         }
679
680         g_hash_table_iter_init (&iter, priv->s390_options);
681         while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
682                 if (   !_nm_utils_string_in_list (key, valid_s390_opts)
683                     || !strlen (value)
684                     || (strlen (value) > 200)) {
685                         g_set_error (error,
686                                      NM_CONNECTION_ERROR,
687                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
688                                      _("invalid '%s' or its value '%s'"),
689                                      key, value);
690                         g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_OPTIONS);
691                         return FALSE;
692                 }
693         }
694
695         if (priv->cloned_mac_address && !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) {
696                 g_set_error_literal (error,
697                                      NM_CONNECTION_ERROR,
698                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
699                                      _("is not a valid MAC address"));
700                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_CLONED_MAC_ADDRESS);
701                 return FALSE;
702         }
703
704         if (   NM_FLAGS_ANY (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
705             && !nm_utils_is_power_of_two (priv->wol)) {
706                 g_set_error_literal (error,
707                                      NM_CONNECTION_ERROR,
708                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
709                                      _("Wake-on-LAN mode 'default' and 'ignore' are exclusive flags"));
710                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN);
711                 return FALSE;
712         }
713
714         if (priv->wol_password && !NM_FLAGS_HAS (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) {
715                 g_set_error_literal (error,
716                                      NM_CONNECTION_ERROR,
717                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
718                                      _("Wake-on-LAN password can only be used with magic packet mode"));
719                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD);
720                 return FALSE;
721         }
722
723         if (priv->wol_password && !nm_utils_hwaddr_valid (priv->wol_password, ETH_ALEN)) {
724                 g_set_error_literal (error,
725                                      NM_CONNECTION_ERROR,
726                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
727                                      _("is not a valid MAC address"));
728                 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD);
729                 return FALSE;
730         }
731
732         return TRUE;
733 }
734
735 static void
736 clear_blacklist_item (char **item_p)
737 {
738         g_free (*item_p);
739 }
740
741 static void
742 nm_setting_wired_init (NMSettingWired *setting)
743 {
744         NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
745
746         priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
747
748         /* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */
749         priv->mac_address_blacklist = g_array_new (TRUE, FALSE, sizeof (char *));
750         g_array_set_clear_func (priv->mac_address_blacklist, (GDestroyNotify) clear_blacklist_item);
751 }
752
753 static void
754 finalize (GObject *object)
755 {
756         NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
757
758         g_free (priv->port);
759         g_free (priv->duplex);
760         g_free (priv->s390_nettype);
761
762         g_hash_table_destroy (priv->s390_options);
763
764         g_free (priv->device_mac_address);
765         g_free (priv->cloned_mac_address);
766         g_array_unref (priv->mac_address_blacklist);
767
768         if (priv->s390_subchannels)
769                 g_strfreev (priv->s390_subchannels);
770
771         g_free (priv->wol_password);
772
773         G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object);
774 }
775
776 static void
777 set_property (GObject *object, guint prop_id,
778               const GValue *value, GParamSpec *pspec)
779 {
780         NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
781         const char * const *blacklist;
782         const char *mac;
783         int i;
784
785         switch (prop_id) {
786         case PROP_PORT:
787                 g_free (priv->port);
788                 priv->port = g_value_dup_string (value);
789                 break;
790         case PROP_SPEED:
791                 priv->speed = g_value_get_uint (value);
792                 break;
793         case PROP_DUPLEX:
794                 g_free (priv->duplex);
795                 priv->duplex = g_value_dup_string (value);
796                 break;
797         case PROP_AUTO_NEGOTIATE:
798                 priv->auto_negotiate = g_value_get_boolean (value);
799                 break;
800         case PROP_MAC_ADDRESS:
801                 g_free (priv->device_mac_address);
802                 priv->device_mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value),
803                                                                                   ETH_ALEN);
804                 break;
805         case PROP_CLONED_MAC_ADDRESS:
806                 g_free (priv->cloned_mac_address);
807                 priv->cloned_mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value),
808                                                                                   ETH_ALEN);
809                 break;
810         case PROP_MAC_ADDRESS_BLACKLIST:
811                 blacklist = g_value_get_boxed (value);
812                 g_array_set_size (priv->mac_address_blacklist, 0);
813                 if (blacklist && *blacklist) {
814                         for (i = 0; blacklist[i]; i++) {
815                                 mac = _nm_utils_hwaddr_canonical_or_invalid (blacklist[i], ETH_ALEN);
816                                 g_array_append_val (priv->mac_address_blacklist, mac);
817                         }
818                 }
819                 break;
820         case PROP_MTU:
821                 priv->mtu = g_value_get_uint (value);
822                 break;
823         case PROP_S390_SUBCHANNELS:
824                 if (priv->s390_subchannels)
825                         g_strfreev (priv->s390_subchannels);
826                 priv->s390_subchannels = g_value_dup_boxed (value);
827                 break;
828         case PROP_S390_NETTYPE:
829                 g_free (priv->s390_nettype);
830                 priv->s390_nettype = g_value_dup_string (value);
831                 break;
832         case PROP_S390_OPTIONS:
833                 g_hash_table_unref (priv->s390_options);
834                 priv->s390_options = _nm_utils_copy_strdict (g_value_get_boxed (value));
835                 break;
836         case PROP_WAKE_ON_LAN:
837                 priv->wol = g_value_get_uint (value);
838                 break;
839         case PROP_WAKE_ON_LAN_PASSWORD:
840                 g_free (priv->wol_password);
841                 priv->wol_password = g_value_dup_string (value);
842                 break;
843         default:
844                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
845                 break;
846         }
847 }
848
849 static void
850 get_property (GObject *object, guint prop_id,
851               GValue *value, GParamSpec *pspec)
852 {
853         NMSettingWired *setting = NM_SETTING_WIRED (object);
854         NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
855
856         switch (prop_id) {
857         case PROP_PORT:
858                 g_value_set_string (value, nm_setting_wired_get_port (setting));
859                 break;
860         case PROP_SPEED:
861                 g_value_set_uint (value, nm_setting_wired_get_speed (setting));
862                 break;
863         case PROP_DUPLEX:
864                 g_value_set_string (value, nm_setting_wired_get_duplex (setting));
865                 break;
866         case PROP_AUTO_NEGOTIATE:
867                 g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting));
868                 break;
869         case PROP_MAC_ADDRESS:
870                 g_value_set_string (value, nm_setting_wired_get_mac_address (setting));
871                 break;
872         case PROP_CLONED_MAC_ADDRESS:
873                 g_value_set_string (value, nm_setting_wired_get_cloned_mac_address (setting));
874                 break;
875         case PROP_MAC_ADDRESS_BLACKLIST:
876                 g_value_set_boxed (value, (char **) priv->mac_address_blacklist->data);
877                 break;
878         case PROP_MTU:
879                 g_value_set_uint (value, nm_setting_wired_get_mtu (setting));
880                 break;
881         case PROP_S390_SUBCHANNELS:
882                 g_value_set_boxed (value, priv->s390_subchannels);
883                 break;
884         case PROP_S390_NETTYPE:
885                 g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting));
886                 break;
887         case PROP_S390_OPTIONS:
888                 g_value_take_boxed (value, _nm_utils_copy_strdict (priv->s390_options));
889                 break;
890         case PROP_WAKE_ON_LAN:
891                 g_value_set_uint (value, priv->wol);
892                 break;
893         case PROP_WAKE_ON_LAN_PASSWORD:
894                 g_value_set_string (value, priv->wol_password);
895                 break;
896         default:
897                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
898                 break;
899         }
900 }
901
902 static void
903 nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
904 {
905         GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
906         NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
907
908         g_type_class_add_private (setting_class, sizeof (NMSettingWiredPrivate));
909
910         /* virtual methods */
911         object_class->set_property = set_property;
912         object_class->get_property = get_property;
913         object_class->finalize     = finalize;
914         parent_class->verify       = verify;
915
916         /* Properties */
917         /**
918          * NMSettingWired:port:
919          *
920          * Specific port type to use if multiple the device supports multiple
921          * attachment methods.  One of "tp" (Twisted Pair), "aui" (Attachment Unit
922          * Interface), "bnc" (Thin Ethernet) or "mii" (Media Independent Interface.
923          * If the device supports only one port type, this setting is ignored.
924          **/
925         /* ---ifcfg-rh---
926          * property: port
927          * variable: (none)
928          * description: The property is not saved by the plugin.
929          * ---end---
930          */
931         g_object_class_install_property
932                 (object_class, PROP_PORT,
933                  g_param_spec_string (NM_SETTING_WIRED_PORT, "", "",
934                                       NULL,
935                                       G_PARAM_READWRITE |
936                                       G_PARAM_STATIC_STRINGS));
937
938         /**
939          * NMSettingWired:speed:
940          *
941          * If non-zero, request that the device use only the specified speed.  In
942          * Mbit/s, ie 100 == 100Mbit/s.
943          **/
944         /* ---ifcfg-rh---
945          * property: speed
946          * variable: (none)
947          * description: The property is not saved by the plugin.
948          * ---end---
949          */
950         g_object_class_install_property
951                 (object_class, PROP_SPEED,
952                  g_param_spec_uint (NM_SETTING_WIRED_SPEED, "", "",
953                                     0, G_MAXUINT32, 0,
954                                     G_PARAM_READWRITE |
955                                     G_PARAM_CONSTRUCT |
956                                     G_PARAM_STATIC_STRINGS));
957
958         /**
959          * NMSettingWired:duplex:
960          *
961          * If specified, request that the device only use the specified duplex mode.
962          * Either "half" or "full".
963          **/
964         /* ---ifcfg-rh---
965          * property: duplex
966          * variable: (none)
967          * description: The property is not saved by the plugin.
968          * ---end---
969          */
970         g_object_class_install_property
971                 (object_class, PROP_DUPLEX,
972                  g_param_spec_string (NM_SETTING_WIRED_DUPLEX, "", "",
973                                       NULL,
974                                       G_PARAM_READWRITE |
975                                       G_PARAM_STATIC_STRINGS));
976
977         /**
978          * NMSettingWired:auto-negotiate:
979          *
980          * If %TRUE, allow auto-negotiation of port speed and duplex mode.  If
981          * %FALSE, do not allow auto-negotiation, in which case the "speed" and
982          * "duplex" properties should be set.
983          **/
984         /* ---ifcfg-rh---
985          * property: auto-negotiate
986          * variable: (none)
987          * description: The property is not saved by the plugin.
988          * ---end---
989          */
990         g_object_class_install_property
991                 (object_class, PROP_AUTO_NEGOTIATE,
992                  g_param_spec_boolean (NM_SETTING_WIRED_AUTO_NEGOTIATE, "", "",
993                                        TRUE,
994                                        G_PARAM_READWRITE |
995                                        G_PARAM_CONSTRUCT |
996                                        G_PARAM_STATIC_STRINGS));
997
998         /**
999          * NMSettingWired:mac-address:
1000          *
1001          * If specified, this connection will only apply to the Ethernet device
1002          * whose permanent MAC address matches. This property does not change the
1003          * MAC address of the device (i.e. MAC spoofing).
1004          **/
1005         /* ---keyfile---
1006          * property: mac-address
1007          * format: usual hex-digits-and-colons notation
1008          * description: MAC address in traditional hex-digits-and-colons notation
1009          *   (e.g. 00:22:68:12:79:A2), or semicolon separated list of 6 bytes (obsolete)
1010          *   (e.g. 0;34;104;18;121;162)
1011          * ---end---
1012          * ---ifcfg-rh---
1013          * property: mac-address
1014          * variable: HWADDR
1015          * description: Hardware address of the device in traditional hex-digits-and-colons
1016          *    notation (e.g. 00:22:68:14:5A:05).
1017          * ---end---
1018          */
1019         g_object_class_install_property
1020                 (object_class, PROP_MAC_ADDRESS,
1021                  g_param_spec_string (NM_SETTING_WIRED_MAC_ADDRESS, "", "",
1022                                       NULL,
1023                                       G_PARAM_READWRITE |
1024                                       NM_SETTING_PARAM_INFERRABLE |
1025                                       G_PARAM_STATIC_STRINGS));
1026         _nm_setting_class_transform_property (parent_class, NM_SETTING_WIRED_MAC_ADDRESS,
1027                                               G_VARIANT_TYPE_BYTESTRING,
1028                                               _nm_utils_hwaddr_to_dbus,
1029                                               _nm_utils_hwaddr_from_dbus);
1030
1031         /**
1032          * NMSettingWired:cloned-mac-address:
1033          *
1034          * If specified, request that the device use this MAC address instead of its
1035          * permanent MAC address.  This is known as MAC cloning or spoofing.
1036          **/
1037         /* ---keyfile---
1038          * property: cloned-mac-address
1039          * format: usual hex-digits-and-colons notation
1040          * description: Cloned MAC address in traditional hex-digits-and-colons notation
1041          *   (e.g. 00:22:68:12:79:B2), or semicolon separated list of 6 bytes (obsolete)
1042          *   (e.g. 0;34;104;18;121;178).
1043          * ---end---
1044          * ---ifcfg-rh---
1045          * property: cloned-mac-address
1046          * variable: MACADDR
1047          * description: Cloned (spoofed) MAC address in traditional hex-digits-and-colons
1048          *    notation (e.g. 00:22:68:14:5A:99).
1049          * ---end---
1050          */
1051         g_object_class_install_property
1052                 (object_class, PROP_CLONED_MAC_ADDRESS,
1053                  g_param_spec_string (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "", "",
1054                                       NULL,
1055                                       G_PARAM_READWRITE |
1056                                       NM_SETTING_PARAM_INFERRABLE |
1057                                       G_PARAM_STATIC_STRINGS));
1058         _nm_setting_class_transform_property (parent_class, NM_SETTING_WIRED_CLONED_MAC_ADDRESS,
1059                                               G_VARIANT_TYPE_BYTESTRING,
1060                                               _nm_utils_hwaddr_to_dbus,
1061                                               _nm_utils_hwaddr_from_dbus);
1062
1063         /**
1064          * NMSettingWired:mac-address-blacklist:
1065          *
1066          * If specified, this connection will never apply to the Ethernet device
1067          * whose permanent MAC address matches an address in the list.  Each MAC
1068          * address is in the standard hex-digits-and-colons notation
1069          * (00:11:22:33:44:55).
1070          **/
1071         /* ---keyfile---
1072          * property: mac-address-blacklist
1073          * format: list of MACs (separated with semicolons)
1074          * description: MAC address blacklist.
1075          * example: mac-address-blacklist= 00:22:68:12:79:A6;00:22:68:12:79:78
1076          * ---end---
1077          * ---ifcfg-rh---
1078          * property: mac-address-blacklist
1079          * variable: HWADDR_BLACKLIST(+)
1080          * description: It denies usage of the connection for any device whose address
1081          *   is listed.
1082          * example: HWADDR_BLACKLIST="00:22:68:11:69:08 00:11:22:11:44:55"
1083          * ---end---
1084          */
1085         g_object_class_install_property
1086                 (object_class, PROP_MAC_ADDRESS_BLACKLIST,
1087                  g_param_spec_boxed (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, "", "",
1088                                      G_TYPE_STRV,
1089                                      G_PARAM_READWRITE |
1090                                      NM_SETTING_PARAM_FUZZY_IGNORE |
1091                                      G_PARAM_STATIC_STRINGS));
1092
1093         /**
1094          * NMSettingWired:mtu:
1095          *
1096          * If non-zero, only transmit packets of the specified size or smaller,
1097          * breaking larger packets up into multiple Ethernet frames.
1098          **/
1099         /* ---ifcfg-rh---
1100          * property: mtu
1101          * variable: MTU
1102          * description: MTU of the interface.
1103          * ---end---
1104          */
1105         g_object_class_install_property
1106                 (object_class, PROP_MTU,
1107                  g_param_spec_uint (NM_SETTING_WIRED_MTU, "", "",
1108                                     0, G_MAXUINT32, 0,
1109                                     G_PARAM_READWRITE |
1110                                     G_PARAM_CONSTRUCT |
1111                                     NM_SETTING_PARAM_FUZZY_IGNORE |
1112                                     G_PARAM_STATIC_STRINGS));
1113
1114         /**
1115          * NMSettingWired:s390-subchannels:
1116          *
1117          * Identifies specific subchannels that this network device uses for
1118          * communication with z/VM or s390 host.  Like the
1119          * #NMSettingWired:mac-address property for non-z/VM devices, this property
1120          * can be used to ensure this connection only applies to the network device
1121          * that uses these subchannels.  The list should contain exactly 3 strings,
1122          * and each string may only be composed of hexadecimal characters and the
1123          * period (.) character.
1124          **/
1125         /* ---ifcfg-rh---
1126          * property: s390-subchannels
1127          * variable: SUBCHANNELS
1128          * description: Subchannels for IBM S390 hosts.
1129          * example: SUBCHANNELS=0.0.b00a,0.0.b00b,0.0.b00c
1130          * ---end---
1131          */
1132         g_object_class_install_property
1133                 (object_class, PROP_S390_SUBCHANNELS,
1134                  g_param_spec_boxed (NM_SETTING_WIRED_S390_SUBCHANNELS, "", "",
1135                                      G_TYPE_STRV,
1136                                      G_PARAM_READWRITE |
1137                                      NM_SETTING_PARAM_INFERRABLE |
1138                                      G_PARAM_STATIC_STRINGS));
1139
1140         /**
1141          * NMSettingWired:s390-nettype:
1142          *
1143          * s390 network device type; one of "qeth", "lcs", or "ctc", representing
1144          * the different types of virtual network devices available on s390 systems.
1145          **/
1146         /* ---ifcfg-rh---
1147          * property: s390-nettype
1148          * variable: NETTYPE
1149          * values: "qeth", "lcs" or "ctc"
1150          * description: Network type of the S390 host.
1151          * example: NETTYPE=qeth
1152          * ---end---
1153          */
1154         g_object_class_install_property
1155                 (object_class, PROP_S390_NETTYPE,
1156                  g_param_spec_string (NM_SETTING_WIRED_S390_NETTYPE, "", "",
1157                                       NULL,
1158                                       G_PARAM_READWRITE |
1159                                       NM_SETTING_PARAM_INFERRABLE |
1160                                       G_PARAM_STATIC_STRINGS));
1161
1162         /**
1163          * NMSettingWired:s390-options:
1164          *
1165          * Dictionary of key/value pairs of s390-specific device options.  Both keys
1166          * and values must be strings.  Allowed keys include "portno", "layer2",
1167          * "portname", "protocol", among others.  Key names must contain only
1168          * alphanumeric characters (ie, [a-zA-Z0-9]).
1169          *
1170          * Type: GHashTable(utf8,utf8)
1171          **/
1172         /* ---ifcfg-rh---
1173          * property: s390-options
1174          * variable: OPTIONS and PORTNAME, CTCPROTO,
1175          * description: S390 device options. All options go to OPTIONS, except for
1176          *   "portname" and "ctcprot" that have their own variables.
1177          * ---end---
1178          */
1179         g_object_class_install_property
1180                 (object_class, PROP_S390_OPTIONS,
1181                  g_param_spec_boxed (NM_SETTING_WIRED_S390_OPTIONS, "", "",
1182                                      G_TYPE_HASH_TABLE,
1183                                      G_PARAM_READWRITE |
1184                                      NM_SETTING_PARAM_INFERRABLE |
1185                                      G_PARAM_STATIC_STRINGS));
1186         _nm_setting_class_transform_property (parent_class, NM_SETTING_WIRED_S390_OPTIONS,
1187                                               G_VARIANT_TYPE ("a{ss}"),
1188                                               _nm_utils_strdict_to_dbus,
1189                                               _nm_utils_strdict_from_dbus);
1190
1191         /**
1192          * NMSettingWired:wake-on-lan:
1193          *
1194          * The #NMSettingWiredWakeOnLan options to enable. Not all devices support all options.
1195          * May be any combination of %NM_SETTING_WIRED_WAKE_ON_LAN_PHY,
1196          * %NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST, %NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST,
1197          * %NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST, %NM_SETTING_WIRED_WAKE_ON_LAN_ARP,
1198          * %NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC or the special values
1199          * %NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT (to use global settings) and
1200          * %NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE (to disable management of Wake-on-LAN in
1201          * NetworkManager).
1202          *
1203          * Since: 1.2
1204          **/
1205         g_object_class_install_property
1206                 (object_class, PROP_WAKE_ON_LAN,
1207                  g_param_spec_uint (NM_SETTING_WIRED_WAKE_ON_LAN, "", "",
1208                                     0, G_MAXUINT32, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT,
1209                                     G_PARAM_CONSTRUCT |
1210                                     G_PARAM_READWRITE |
1211                                     G_PARAM_STATIC_STRINGS));
1212
1213         /**
1214          * NMSettingWired:wake-on-lan-password:
1215          *
1216          * If specified, the password used with magic-packet-based
1217          * Wake-on-LAN, represented as an Ethernet MAC address.  If %NULL,
1218          * no password will be required.
1219          *
1220          * Since: 1.2
1221          **/
1222         g_object_class_install_property
1223                 (object_class, PROP_WAKE_ON_LAN_PASSWORD,
1224                  g_param_spec_string (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, "", "",
1225                                       NULL,
1226                                       G_PARAM_READWRITE |
1227                                       G_PARAM_STATIC_STRINGS));
1228 }