device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-util / nm-setting-dcb.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 2013 Red Hat, Inc.
20  */
21
22 #include "nm-default.h"
23
24 #include <string.h>
25 #include <dbus/dbus-glib.h>
26
27 #include "nm-setting-dcb.h"
28 #include "nm-param-spec-specialized.h"
29 #include "nm-utils.h"
30 #include "nm-utils-private.h"
31 #include "nm-dbus-glib-types.h"
32 #include "nm-setting-private.h"
33
34 /**
35  * SECTION:nm-setting-dcb
36  * @short_description: Connection properties for Data Center Bridging
37  * @include: nm-setting-dcb.h
38  *
39  * The #NMSettingDcb object is a #NMSetting subclass that describes properties
40  * for enabling and using Data Center Bridging (DCB) on Ethernet networks.
41  * DCB is a set of protocols (including 802.1Qbb, 802.1Qaz, 802.1Qau, and
42  * 802.1AB) to eliminate packet loss in Ethernet networks and support the use
43  * of storage technologies like Fibre Channel over Ethernet (FCoE) and iSCSI.
44  *
45  * Since: 0.9.10
46  **/
47
48 /**
49  * nm_setting_dcb_error_quark:
50  *
51  * Registers an error quark for #NMSettingDcb if necessary.
52  *
53  * Returns: the error quark used for #NMSettingDcb errors.
54  *
55  * Since: 0.9.10
56  **/
57 GQuark
58 nm_setting_dcb_error_quark (void)
59 {
60         static GQuark quark;
61
62         if (G_UNLIKELY (!quark))
63                 quark = g_quark_from_static_string ("nm-setting-dcb-error-quark");
64         return quark;
65 }
66
67
68 G_DEFINE_TYPE_WITH_CODE (NMSettingDcb, nm_setting_dcb, NM_TYPE_SETTING,
69                          _nm_register_setting (NM_SETTING_DCB_SETTING_NAME,
70                                                g_define_type_id,
71                                                2,
72                                                NM_SETTING_DCB_ERROR))
73 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DCB)
74
75 #define NM_SETTING_DCB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_DCB, NMSettingDcbPrivate))
76
77 typedef struct {
78         NMSettingDcbFlags app_fcoe_flags;
79         gint              app_fcoe_priority;
80         char *            app_fcoe_mode;
81
82         NMSettingDcbFlags app_iscsi_flags;
83         gint              app_iscsi_priority;
84
85         NMSettingDcbFlags app_fip_flags;
86         gint              app_fip_priority;
87
88         /* Priority Flow Control */
89         NMSettingDcbFlags pfc_flags;
90         guint             pfc[8];
91
92         /* Priority Groups */
93         NMSettingDcbFlags priority_group_flags;
94         guint             priority_group_id[8];
95         guint             priority_group_bandwidth[8];
96         guint             priority_bandwidth[8];
97         guint             priority_strict[8];
98         guint             priority_traffic_class[8];
99 } NMSettingDcbPrivate;
100
101 enum {
102         PROP_0,
103         PROP_APP_FCOE_FLAGS,
104         PROP_APP_FCOE_PRIORITY,
105         PROP_APP_FCOE_MODE,
106
107         PROP_APP_ISCSI_FLAGS,
108         PROP_APP_ISCSI_PRIORITY,
109
110         PROP_APP_FIP_FLAGS,
111         PROP_APP_FIP_PRIORITY,
112
113         PROP_PFC_FLAGS,
114         PROP_PFC,
115
116         PROP_PRIORITY_GROUP_FLAGS,
117         PROP_PRIORITY_GROUP_ID,
118         PROP_PRIORITY_GROUP_BANDWIDTH,
119         PROP_PRIORITY_BANDWIDTH,
120         PROP_PRIORITY_STRICT,
121         PROP_PRIORITY_TRAFFIC_CLASS,
122
123         LAST_PROP
124 };
125
126 /**
127  * nm_setting_dcb_new:
128  *
129  * Creates a new #NMSettingDcb object with default values.
130  *
131  * Returns: (transfer full): the new empty #NMSettingDcb object
132  *
133  * Since: 0.9.10
134  **/
135 NMSetting *
136 nm_setting_dcb_new (void)
137 {
138         return (NMSetting *) g_object_new (NM_TYPE_SETTING_DCB, NULL);
139 }
140
141 /**
142  * nm_setting_dcb_get_app_fcoe_flags:
143  * @setting: the #NMSettingDcb
144  *
145  * Returns: the #NMSettingDcb:app-fcoe-flags property of the setting
146  *
147  * Since: 0.9.10
148  **/
149 NMSettingDcbFlags
150 nm_setting_dcb_get_app_fcoe_flags (NMSettingDcb *setting)
151 {
152         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
153
154         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_flags;
155 }
156
157 /**
158  * nm_setting_dcb_get_app_fcoe_priority:
159  * @setting: the #NMSettingDcb
160  *
161  * Returns: the #NMSettingDcb:app-fcoe-priority property of the setting
162  *
163  * Since: 0.9.10
164  **/
165 gint
166 nm_setting_dcb_get_app_fcoe_priority (NMSettingDcb *setting)
167 {
168         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
169
170         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_priority;
171 }
172
173 /**
174  * nm_setting_dcb_get_app_fcoe_mode:
175  * @setting: the #NMSettingDcb
176  *
177  * Returns: the #NMSettingDcb:app-fcoe-mode property of the setting
178  *
179  * Since: 0.9.10
180  **/
181 const char *
182 nm_setting_dcb_get_app_fcoe_mode (NMSettingDcb *setting)
183 {
184         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), NULL);
185
186         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_mode;
187 }
188
189 /**
190  * nm_setting_dcb_get_app_iscsi_flags:
191  * @setting: the #NMSettingDcb
192  *
193  * Returns: the #NMSettingDcb:app-iscsi-flags property of the setting
194  *
195  * Since: 0.9.10
196  **/
197 NMSettingDcbFlags
198 nm_setting_dcb_get_app_iscsi_flags (NMSettingDcb *setting)
199 {
200         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
201
202         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_iscsi_flags;
203 }
204
205 /**
206  * nm_setting_dcb_get_app_iscsi_priority:
207  * @setting: the #NMSettingDcb
208  *
209  * Returns: the #NMSettingDcb:app-iscsi-priority property of the setting
210  *
211  * Since: 0.9.10
212  **/
213 gint
214 nm_setting_dcb_get_app_iscsi_priority (NMSettingDcb *setting)
215 {
216         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
217
218         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_iscsi_priority;
219 }
220
221 /**
222  * nm_setting_dcb_get_app_fip_flags:
223  * @setting: the #NMSettingDcb
224  *
225  * Returns: the #NMSettingDcb:app-fip-flags property of the setting
226  *
227  * Since: 0.9.10
228  **/
229 NMSettingDcbFlags
230 nm_setting_dcb_get_app_fip_flags (NMSettingDcb *setting)
231 {
232         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
233
234         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fip_flags;
235 }
236
237 /**
238  * nm_setting_dcb_get_app_fip_priority:
239  * @setting: the #NMSettingDcb
240  *
241  * Returns: the #NMSettingDcb:app-fip-priority property of the setting
242  *
243  * Since: 0.9.10
244  **/
245 gint
246 nm_setting_dcb_get_app_fip_priority (NMSettingDcb *setting)
247 {
248         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
249
250         return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fip_priority;
251 }
252
253 /**
254  * nm_setting_dcb_get_priority_flow_control_flags:
255  * @setting: the #NMSettingDcb
256  *
257  * Returns: the #NMSettingDcb:priority-flow-control-flags property of the setting
258  *
259  * Since: 0.9.10
260  **/
261 NMSettingDcbFlags
262 nm_setting_dcb_get_priority_flow_control_flags (NMSettingDcb *setting)
263 {
264         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
265
266         return NM_SETTING_DCB_GET_PRIVATE (setting)->pfc_flags;
267 }
268
269 /**
270  * nm_setting_dcb_get_priority_flow_control:
271  * @setting: the #NMSettingDcb
272  * @user_priority: the User Priority (0 - 7) to retrieve flow control for
273  *
274  * Returns: %TRUE if flow control is enabled for the given @user_priority,
275  * %FALSE if not enabled
276  *
277  * Since: 0.9.10
278  **/
279 gboolean
280 nm_setting_dcb_get_priority_flow_control (NMSettingDcb *setting, guint user_priority)
281 {
282         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), FALSE);
283         g_return_val_if_fail (user_priority <= 7, FALSE);
284
285         return !!NM_SETTING_DCB_GET_PRIVATE (setting)->pfc[user_priority];
286 }
287
288 /**
289  * nm_setting_dcb_set_priority_flow_control:
290  * @setting: the #NMSettingDcb
291  * @user_priority: the User Priority (0 - 7) to set flow control for
292  * @enabled: %TRUE to enable flow control for this priority, %FALSE to disable it
293  *
294  * These values are only valid when #NMSettingDcb:priority-flow-control includes
295  * the %NM_SETTING_DCB_FLAG_ENABLE flag.
296  *
297  * Since: 0.9.10
298  **/
299 void
300 nm_setting_dcb_set_priority_flow_control (NMSettingDcb *setting,
301                                           guint user_priority,
302                                           gboolean enabled)
303 {
304         NMSettingDcbPrivate *priv;
305         guint uint_enabled = enabled ? 1 : 0;
306
307         g_return_if_fail (NM_IS_SETTING_DCB (setting));
308         g_return_if_fail (user_priority <= 7);
309
310         priv = NM_SETTING_DCB_GET_PRIVATE (setting);
311         if (priv->pfc[user_priority] != uint_enabled) {
312                 priv->pfc[user_priority] = uint_enabled;
313                 g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL);
314         }
315 }
316
317 /**
318  * nm_setting_dcb_get_priority_group_flags:
319  * @setting: the #NMSettingDcb
320  *
321  * Returns: the #NMSettingDcb:priority-group-flags property of the setting
322  *
323  * Since: 0.9.10
324  **/
325 NMSettingDcbFlags
326 nm_setting_dcb_get_priority_group_flags (NMSettingDcb *setting)
327 {
328         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
329
330         return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_flags;
331 }
332
333 /**
334  * nm_setting_dcb_get_priority_group_id:
335  * @setting: the #NMSettingDcb
336  * @user_priority: the User Priority (0 - 7) to retrieve the group ID for
337  *
338  * Returns: the group number @user_priority is assigned to.  These values are
339  * only valid when #NMSettingDcb:priority-group-flags includes the
340  * %NM_SETTING_DCB_FLAG_ENABLE flag.
341  *
342  * Since: 0.9.10
343  **/
344 guint
345 nm_setting_dcb_get_priority_group_id (NMSettingDcb *setting, guint user_priority)
346 {
347         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
348         g_return_val_if_fail (user_priority <= 7, 0);
349
350         return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_id[user_priority];
351 }
352
353 /**
354  * nm_setting_dcb_set_priority_group_id:
355  * @setting: the #NMSettingDcb
356  * @user_priority: the User Priority (0 - 7) to set flow control for
357  * @group_id: the group (0 - 7) to assign @user_priority to, or 15 for the
358  * unrestricted group.
359  *
360  * These values are only valid when #NMSettingDcb:priority-group-flags includes
361  * the %NM_SETTING_DCB_FLAG_ENABLE flag.
362  *
363  * Since: 0.9.10
364  **/
365 void
366 nm_setting_dcb_set_priority_group_id (NMSettingDcb *setting,
367                                       guint user_priority,
368                                       guint group_id)
369 {
370         NMSettingDcbPrivate *priv;
371
372         g_return_if_fail (NM_IS_SETTING_DCB (setting));
373         g_return_if_fail (user_priority <= 7);
374         g_return_if_fail (group_id <= 7 || group_id == 15);
375
376         priv = NM_SETTING_DCB_GET_PRIVATE (setting);
377         if (priv->priority_group_id[user_priority] != group_id) {
378                 priv->priority_group_id[user_priority] = group_id;
379                 g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_GROUP_ID);
380         }
381 }
382
383 /**
384  * nm_setting_dcb_get_priority_group_bandwidth:
385  * @setting: the #NMSettingDcb
386  * @group_id: the priority group (0 - 7) to retrieve the bandwidth percentage for
387  *
388  * Returns: the bandwidth percentage assigned to @group_id.  These values are
389  * only valid when #NMSettingDcb:priority-group-flags includes the
390  * %NM_SETTING_DCB_FLAG_ENABLE flag.
391  *
392  * Since: 0.9.10
393  **/
394 guint
395 nm_setting_dcb_get_priority_group_bandwidth (NMSettingDcb *setting, guint group_id)
396 {
397         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
398         g_return_val_if_fail (group_id <= 7, FALSE);
399
400         return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_bandwidth[group_id];
401 }
402
403 /**
404  * nm_setting_dcb_set_priority_group_bandwidth:
405  * @setting: the #NMSettingDcb
406  * @group_id: the priority group (0 - 7) to set the bandwidth percentage for
407  * @bandwidth_percent: the bandwidth percentage (0 - 100) to assign to @group_id to
408  *
409  * These values are only valid when #NMSettingDcb:priority-group-flags includes
410  * the %NM_SETTING_DCB_FLAG_ENABLE flag.
411  *
412  * Since: 0.9.10
413  **/
414 void
415 nm_setting_dcb_set_priority_group_bandwidth (NMSettingDcb *setting,
416                                              guint group_id,
417                                              guint bandwidth_percent)
418 {
419         NMSettingDcbPrivate *priv;
420
421         g_return_if_fail (NM_IS_SETTING_DCB (setting));
422         g_return_if_fail (group_id <= 7);
423         g_return_if_fail (bandwidth_percent <= 100);
424
425         priv = NM_SETTING_DCB_GET_PRIVATE (setting);
426         if (priv->priority_group_bandwidth[group_id] != bandwidth_percent) {
427                 priv->priority_group_bandwidth[group_id] = bandwidth_percent;
428                 g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH);
429         }
430 }
431
432 /**
433  * nm_setting_dcb_get_priority_bandwidth:
434  * @setting: the #NMSettingDcb
435  * @user_priority: the User Priority (0 - 7) to retrieve the group bandwidth percentage for
436  *
437  * Returns: the allowed bandwidth percentage of @user_priority in its priority group.
438  * These values are only valid when #NMSettingDcb:priority-group-flags includes the
439  * %NM_SETTING_DCB_FLAG_ENABLE flag.
440  *
441  * Since: 0.9.10
442  **/
443 guint
444 nm_setting_dcb_get_priority_bandwidth (NMSettingDcb *setting, guint user_priority)
445 {
446         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
447         g_return_val_if_fail (user_priority <= 7, FALSE);
448
449         return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_bandwidth[user_priority];
450 }
451
452 /**
453  * nm_setting_dcb_set_priority_bandwidth:
454  * @setting: the #NMSettingDcb
455  * @user_priority: the User Priority (0 - 7) to set the bandwidth percentage for
456  * @bandwidth_percent: the bandwidth percentage (0 - 100) that @user_priority is
457  * allowed to use within its priority group
458  *
459  * These values are only valid when #NMSettingDcb:priority-group-flags includes
460  * the %NM_SETTING_DCB_FLAG_ENABLE flag.
461  *
462  * Since: 0.9.10
463  **/
464 void
465 nm_setting_dcb_set_priority_bandwidth (NMSettingDcb *setting,
466                                        guint user_priority,
467                                        guint bandwidth_percent)
468 {
469         NMSettingDcbPrivate *priv;
470
471         g_return_if_fail (NM_IS_SETTING_DCB (setting));
472         g_return_if_fail (user_priority <= 7);
473         g_return_if_fail (bandwidth_percent <= 100);
474
475         priv = NM_SETTING_DCB_GET_PRIVATE (setting);
476         if (priv->priority_bandwidth[user_priority] != bandwidth_percent) {
477                 priv->priority_bandwidth[user_priority] = bandwidth_percent;
478                 g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_BANDWIDTH);
479         }
480 }
481
482 /**
483  * nm_setting_dcb_get_priority_strict_bandwidth:
484  * @setting: the #NMSettingDcb
485  * @user_priority: the User Priority (0 - 7) to retrieve strict bandwidth for
486  *
487  * Returns: %TRUE if @user_priority may use all of the bandwidth allocated to its
488  * assigned group, or %FALSE if not. These values are only valid when
489  * #NMSettingDcb:priority-group-flags includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
490  *
491  * Since: 0.9.10
492  **/
493 gboolean
494 nm_setting_dcb_get_priority_strict_bandwidth (NMSettingDcb *setting, guint user_priority)
495 {
496         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
497         g_return_val_if_fail (user_priority <= 7, FALSE);
498
499         return !!NM_SETTING_DCB_GET_PRIVATE (setting)->priority_strict[user_priority];
500 }
501
502 /**
503  * nm_setting_dcb_set_priority_strict_bandwidth:
504  * @setting: the #NMSettingDcb
505  * @user_priority: the User Priority (0 - 7) to set strict bandwidth for
506  * @strict: %TRUE to allow @user_priority to use all the bandwidth allocated to
507  * its priority group, or %FALSE if not
508  *
509  * These values are only valid when #NMSettingDcb:priority-group-flags includes
510  * the %NM_SETTING_DCB_FLAG_ENABLE flag.
511  *
512  * Since: 0.9.10
513  **/
514 void
515 nm_setting_dcb_set_priority_strict_bandwidth (NMSettingDcb *setting,
516                                               guint user_priority,
517                                               gboolean strict)
518 {
519         NMSettingDcbPrivate *priv;
520         guint uint_strict = strict ? 1 : 0;
521
522         g_return_if_fail (NM_IS_SETTING_DCB (setting));
523         g_return_if_fail (user_priority <= 7);
524
525         priv = NM_SETTING_DCB_GET_PRIVATE (setting);
526         if (priv->priority_strict[user_priority] != uint_strict) {
527                 priv->priority_strict[user_priority] = uint_strict;
528                 g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH);
529         }
530 }
531
532 /**
533  * nm_setting_dcb_get_priority_traffic_class:
534  * @setting: the #NMSettingDcb
535  * @user_priority: the User Priority (0 - 7) to retrieve the traffic class for
536  *
537  * Returns: the traffic class assigned to @user_priority. These values are only
538  * valid when #NMSettingDcb:priority-group-flags includes the
539  * %NM_SETTING_DCB_FLAG_ENABLE flag.
540  *
541  * Since: 0.9.10
542  **/
543 guint
544 nm_setting_dcb_get_priority_traffic_class (NMSettingDcb *setting, guint user_priority)
545 {
546         g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
547         g_return_val_if_fail (user_priority <= 7, FALSE);
548
549         return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_traffic_class[user_priority];
550 }
551
552 /**
553  * nm_setting_dcb_set_priority_traffic_clas:
554  * @setting: the #NMSettingDcb
555  * @user_priority: the User Priority (0 - 7) to set the bandwidth percentage for
556  * @traffic_class: the traffic_class (0 - 7) that @user_priority should map to
557  *
558  * These values are only valid when #NMSettingDcb:priority-group-flags includes
559  * the %NM_SETTING_DCB_FLAG_ENABLE flag.
560  *
561  * Since: 0.9.10
562  **/
563 void
564 nm_setting_dcb_set_priority_traffic_class (NMSettingDcb *setting,
565                                            guint user_priority,
566                                            guint traffic_class)
567 {
568         NMSettingDcbPrivate *priv;
569
570         g_return_if_fail (NM_IS_SETTING_DCB (setting));
571         g_return_if_fail (user_priority <= 7);
572         g_return_if_fail (traffic_class <= 7);
573
574         priv = NM_SETTING_DCB_GET_PRIVATE (setting);
575         if (priv->priority_traffic_class[user_priority] != traffic_class) {
576                 priv->priority_traffic_class[user_priority] = traffic_class;
577                 g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS);
578         }
579 }
580
581 /******************************************************************/
582
583 #define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \
584                        NM_SETTING_DCB_FLAG_ADVERTISE | \
585                        NM_SETTING_DCB_FLAG_WILLING)
586
587 static gboolean
588 check_dcb_flags (NMSettingDcbFlags flags, const char *prop_name, GError **error)
589 {
590         if (flags & ~DCB_FLAGS_ALL) {
591                 g_set_error_literal (error,
592                                      NM_SETTING_DCB_ERROR,
593                                      NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
594                                      _("flags invalid"));
595                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
596                 return FALSE;
597         }
598
599         if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (flags & ~NM_SETTING_DCB_FLAG_ENABLE)) {
600                 g_set_error_literal (error,
601                                      NM_SETTING_DCB_ERROR,
602                                      NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
603                                      _("flags invalid - disabled"));
604                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
605                 return FALSE;
606         }
607
608         return TRUE;
609 }
610
611 static gboolean
612 check_uint_array (const guint *array,
613                   guint len,
614                   NMSettingDcbFlags flags,
615                   guint max,
616                   guint extra,
617                   gboolean sum_pct,
618                   const char *prop_name,
619                   GError **error)
620 {
621         guint i, sum = 0;
622
623         /* Ensure each element is <= to max or equals extra */
624         for (i = 0; i < len; i++) {
625                 if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && array[i]) {
626                         g_set_error_literal (error,
627                                              NM_SETTING_DCB_ERROR,
628                                              NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
629                                              _("property invalid (not enabled)"));
630                         g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
631                         return FALSE;
632                 }
633
634                 if ((array[i] > max) && (array[i] != extra)) {
635                         g_set_error_literal (error,
636                                              NM_SETTING_DCB_ERROR,
637                                              NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
638                                              _("element invalid"));
639                         g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
640                         return FALSE;
641                 }
642                 sum += array[i];
643         }
644
645         /* Verify sum of percentages */
646         if (sum_pct) {
647                 if (flags & NM_SETTING_DCB_FLAG_ENABLE) {
648                         /* If the feature is enabled, sum must equal 100% */
649                         if (sum != 100) {
650                                 g_set_error_literal (error,
651                                                      NM_SETTING_DCB_ERROR,
652                                                      NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
653                                                      _("sum not 100%"));
654                                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
655                                 return FALSE;
656                         }
657                 } else {
658                         /* If the feature is disabled, sum must equal 0%, which was checked
659                          * by the for() loop above.
660                          */
661                         g_assert_cmpint (sum, ==, 0);
662                 }
663         }
664
665         return TRUE;
666 }
667
668 static gboolean
669 check_priority (gint val,
670                 NMSettingDcbFlags flags,
671                 const char *prop_name,
672                 GError **error)
673 {
674         if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (val >= 0)) {
675                 g_set_error_literal (error,
676                                      NM_SETTING_DCB_ERROR,
677                                      NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
678                                      _("property invalid (not enabled)"));
679                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
680                 return FALSE;
681         }
682
683         if (val < -1 || val > 7) {
684                 g_set_error_literal (error,
685                                      NM_SETTING_DCB_ERROR,
686                                      NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
687                                      _("property invalid"));
688                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
689                 return FALSE;
690         }
691         return TRUE;
692 }
693
694 static gboolean
695 verify (NMSetting *setting, GSList *all_settings, GError **error)
696 {
697         NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting);
698
699         if (!check_dcb_flags (priv->app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS, error))
700                 return FALSE;
701
702         if (!check_priority (priv->app_fcoe_priority, priv->app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_PRIORITY, error))
703                 return FALSE;
704
705         if (!priv->app_fcoe_mode) {
706                 g_set_error_literal (error,
707                                      NM_SETTING_DCB_ERROR,
708                                      NM_SETTING_DCB_ERROR_MISSING_PROPERTY,
709                                      _("property missing"));
710                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE);
711                 return FALSE;
712         }
713
714         if (strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_FABRIC) &&
715             strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_VN2VN)) {
716                 g_set_error_literal (error,
717                                      NM_SETTING_DCB_ERROR,
718                                      NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
719                                      _("property invalid"));
720                 g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE);
721                 return FALSE;
722         }
723
724         if (!check_dcb_flags (priv->app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS, error))
725                 return FALSE;
726
727         if (!check_priority (priv->app_iscsi_priority, priv->app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_PRIORITY, error))
728                 return FALSE;
729
730         if (!check_dcb_flags (priv->app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS, error))
731                 return FALSE;
732
733         if (!check_priority (priv->app_fip_priority, priv->app_fip_flags, NM_SETTING_DCB_APP_FIP_PRIORITY, error))
734                 return FALSE;
735
736         if (!check_dcb_flags (priv->pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, error))
737                 return FALSE;
738
739         if (!check_uint_array (priv->pfc, G_N_ELEMENTS (priv->pfc), priv->pfc_flags, 1, 0, FALSE, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, error))
740                 return FALSE;
741
742         if (!check_dcb_flags (priv->priority_group_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, error))
743                 return FALSE;
744
745         if (!check_uint_array (priv->priority_group_id,
746                                G_N_ELEMENTS (priv->priority_group_id),
747                                priv->priority_group_flags,
748                                7,
749                                15,
750                                FALSE,
751                                NM_SETTING_DCB_PRIORITY_GROUP_ID,
752                                error))
753                 return FALSE;
754
755         if (!check_uint_array (priv->priority_group_bandwidth,
756                                G_N_ELEMENTS (priv->priority_group_bandwidth),
757                                priv->priority_group_flags,
758                                100,
759                                0,
760                                TRUE,
761                                NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH,
762                                error))
763                 return FALSE;
764
765         /* FIXME: sum bandwidths in each group */
766         if (!check_uint_array (priv->priority_bandwidth,
767                                G_N_ELEMENTS (priv->priority_bandwidth),
768                                priv->priority_group_flags,
769                                100,
770                                0,
771                                FALSE,
772                                NM_SETTING_DCB_PRIORITY_BANDWIDTH,
773                                error))
774                 return FALSE;
775
776         if (!check_uint_array (priv->priority_strict,
777                                G_N_ELEMENTS (priv->priority_strict),
778                                priv->priority_group_flags,
779                                1,
780                                0,
781                                FALSE,
782                                NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH,
783                                error))
784                 return FALSE;
785
786         if (!check_uint_array (priv->priority_traffic_class,
787                                G_N_ELEMENTS (priv->priority_traffic_class),
788                                priv->priority_group_flags,
789                                7,
790                                0,
791                                FALSE,
792                                NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS,
793                                error))
794                 return FALSE;
795
796         return TRUE;
797 }
798
799 /******************************************************************/
800
801 static void
802 nm_setting_dcb_init (NMSettingDcb *setting)
803 {
804 }
805
806 static inline void
807 set_uint_array (const GValue *v, uint *a, size_t len)
808 {
809         GArray *src = g_value_get_boxed (v);
810         const guint total_len = len * sizeof (a[0]);
811
812         memset (a, 0, total_len);
813         if (src) {
814                 g_return_if_fail (g_array_get_element_size (src) == sizeof (a[0]));
815                 g_return_if_fail (src->len == len);
816                 memcpy (a, src->data, total_len);
817         }
818 }
819 #define SET_UINT_ARRAY(v, a)  set_uint_array (v, a, G_N_ELEMENTS (a))
820
821 static void
822 set_property (GObject *object, guint prop_id,
823               const GValue *value, GParamSpec *pspec)
824 {
825         NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object);
826
827         switch (prop_id) {
828         case PROP_APP_FCOE_FLAGS:
829                 priv->app_fcoe_flags = g_value_get_uint (value);
830                 break;
831         case PROP_APP_FCOE_PRIORITY:
832                 priv->app_fcoe_priority = g_value_get_int (value);
833                 break;
834         case PROP_APP_FCOE_MODE:
835                 g_free (priv->app_fcoe_mode);
836                 priv->app_fcoe_mode = g_value_dup_string (value);
837                 break;
838         case PROP_APP_ISCSI_FLAGS:
839                 priv->app_iscsi_flags = g_value_get_uint (value);
840                 break;
841         case PROP_APP_ISCSI_PRIORITY:
842                 priv->app_iscsi_priority = g_value_get_int (value);
843                 break;
844         case PROP_APP_FIP_FLAGS:
845                 priv->app_fip_flags = g_value_get_uint (value);
846                 break;
847         case PROP_APP_FIP_PRIORITY:
848                 priv->app_fip_priority = g_value_get_int (value);
849                 break;
850         case PROP_PFC_FLAGS:
851                 priv->pfc_flags = g_value_get_uint (value);
852                 break;
853         case PROP_PFC:
854                 SET_UINT_ARRAY (value, priv->pfc);
855                 break;
856         case PROP_PRIORITY_GROUP_FLAGS:
857                 priv->priority_group_flags = g_value_get_uint (value);
858                 break;
859         case PROP_PRIORITY_GROUP_ID:
860                 SET_UINT_ARRAY (value, priv->priority_group_id);
861                 break;
862         case PROP_PRIORITY_GROUP_BANDWIDTH:
863                 SET_UINT_ARRAY (value, priv->priority_group_bandwidth);
864                 break;
865         case PROP_PRIORITY_BANDWIDTH:
866                 SET_UINT_ARRAY (value, priv->priority_bandwidth);
867                 break;
868         case PROP_PRIORITY_STRICT:
869                 SET_UINT_ARRAY (value, priv->priority_strict);
870                 break;
871         case PROP_PRIORITY_TRAFFIC_CLASS:
872                 SET_UINT_ARRAY (value, priv->priority_traffic_class);
873                 break;
874         default:
875                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
876                 break;
877         }
878 }
879
880 #define TAKE_UINT_ARRAY(v, a) \
881 { \
882         guint len = G_N_ELEMENTS (a); \
883         GArray *dst = g_array_sized_new (FALSE, TRUE, sizeof (guint), len); \
884         g_array_append_vals (dst, (a), len); \
885         g_value_take_boxed (v, dst); \
886 }
887
888 static void
889 get_property (GObject *object, guint prop_id,
890               GValue *value, GParamSpec *pspec)
891 {
892         NMSettingDcb *setting = NM_SETTING_DCB (object);
893         NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting);
894
895         switch (prop_id) {
896         case PROP_APP_FCOE_FLAGS:
897                 g_value_set_uint (value, priv->app_fcoe_flags);
898                 break;
899         case PROP_APP_FCOE_PRIORITY:
900                 g_value_set_int (value, priv->app_fcoe_priority);
901                 break;
902         case PROP_APP_FCOE_MODE:
903                 g_value_set_string (value, priv->app_fcoe_mode);
904                 break;
905         case PROP_APP_ISCSI_FLAGS:
906                 g_value_set_uint (value, priv->app_iscsi_flags);
907                 break;
908         case PROP_APP_ISCSI_PRIORITY:
909                 g_value_set_int (value, priv->app_iscsi_priority);
910                 break;
911         case PROP_APP_FIP_FLAGS:
912                 g_value_set_uint (value, priv->app_fip_flags);
913                 break;
914         case PROP_APP_FIP_PRIORITY:
915                 g_value_set_int (value, priv->app_fip_priority);
916                 break;
917         case PROP_PFC_FLAGS:
918                 g_value_set_uint (value, priv->pfc_flags);
919                 break;
920         case PROP_PFC:
921                 TAKE_UINT_ARRAY (value, priv->pfc);
922                 break;
923         case PROP_PRIORITY_GROUP_FLAGS:
924                 g_value_set_uint (value, priv->priority_group_flags);
925                 break;
926         case PROP_PRIORITY_GROUP_ID:
927                 TAKE_UINT_ARRAY (value, priv->priority_group_id);
928                 break;
929         case PROP_PRIORITY_GROUP_BANDWIDTH:
930                 TAKE_UINT_ARRAY (value, priv->priority_group_bandwidth);
931                 break;
932         case PROP_PRIORITY_BANDWIDTH:
933                 TAKE_UINT_ARRAY (value, priv->priority_bandwidth);
934                 break;
935         case PROP_PRIORITY_STRICT:
936                 TAKE_UINT_ARRAY (value, priv->priority_strict);
937                 break;
938         case PROP_PRIORITY_TRAFFIC_CLASS:
939                 TAKE_UINT_ARRAY (value, priv->priority_traffic_class);
940                 break;
941         default:
942                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
943                 break;
944         }
945 }
946
947 static void
948 finalize (GObject *object)
949 {
950         NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object);
951
952         g_free (priv->app_fcoe_mode);
953
954         G_OBJECT_CLASS (nm_setting_dcb_parent_class)->finalize (object);
955 }
956
957 static void
958 nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
959 {
960         GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
961         NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
962
963         g_type_class_add_private (setting_class, sizeof (NMSettingDcbPrivate));
964
965         /* virtual methods */
966         object_class->set_property = set_property;
967         object_class->get_property = get_property;
968         object_class->finalize = finalize;
969         parent_class->verify       = verify;
970
971         /* Properties */
972         /**
973          * NMSettingDcb:app-fcoe-flags:
974          *
975          * Specifies the #NMSettingDcbFlags for the DCB FCoE application.  Flags may
976          * be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
977          * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
978          *
979          * Since: 0.9.10
980          **/
981         g_object_class_install_property
982                 (object_class, PROP_APP_FCOE_FLAGS,
983                  g_param_spec_uint (NM_SETTING_DCB_APP_FCOE_FLAGS, "", "",
984                                     0, DCB_FLAGS_ALL, 0,
985                                     G_PARAM_READWRITE |
986                                     G_PARAM_STATIC_STRINGS));
987
988         /**
989          * NMSettingDcb:app-fcoe-priority:
990          *
991          * The highest User Priority (0 - 7) which FCoE frames should use, or -1 for
992          * default priority.  Only used when the #NMSettingDcb:app-fcoe-flags
993          * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
994          *
995          * Since: 0.9.10
996          **/
997         g_object_class_install_property
998                 (object_class, PROP_APP_FCOE_PRIORITY,
999                  g_param_spec_int (NM_SETTING_DCB_APP_FCOE_PRIORITY, "", "",
1000                                    -1, 7, -1,
1001                                    G_PARAM_READWRITE |
1002                                    G_PARAM_CONSTRUCT |
1003                                    G_PARAM_STATIC_STRINGS));
1004
1005         /**
1006          * NMSettingDcb:app-fcoe-mode:
1007          *
1008          * The FCoE controller mode; either %NM_SETTING_DCB_FCOE_MODE_FABRIC
1009          * (default) or %NM_SETTING_DCB_FCOE_MODE_VN2VN.
1010          *
1011          * Since: 0.9.10
1012          **/
1013         g_object_class_install_property
1014                 (object_class, PROP_APP_FCOE_MODE,
1015                  g_param_spec_string (NM_SETTING_DCB_APP_FCOE_MODE, "", "",
1016                                       NM_SETTING_DCB_FCOE_MODE_FABRIC,
1017                                       G_PARAM_READWRITE |
1018                                       G_PARAM_CONSTRUCT |
1019                                       G_PARAM_STATIC_STRINGS));
1020
1021         /**
1022          * NMSettingDcb:app-iscsi-flags:
1023          *
1024          * Specifies the #NMSettingDcbFlags for the DCB iSCSI application.  Flags
1025          * may be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
1026          * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1027          *
1028          * Since: 0.9.10
1029          **/
1030         g_object_class_install_property
1031                 (object_class, PROP_APP_ISCSI_FLAGS,
1032                  g_param_spec_uint (NM_SETTING_DCB_APP_ISCSI_FLAGS, "", "",
1033                                     0, DCB_FLAGS_ALL, 0,
1034                                     G_PARAM_READWRITE |
1035                                     G_PARAM_STATIC_STRINGS));
1036
1037         /**
1038          * NMSettingDcb:app-iscsi-priority:
1039          *
1040          * The highest User Priority (0 - 7) which iSCSI frames should use, or -1
1041          * for default priority. Only used when the #NMSettingDcb:app-iscsi-flags
1042          * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
1043          *
1044          * Since: 0.9.10
1045          **/
1046         g_object_class_install_property
1047                 (object_class, PROP_APP_ISCSI_PRIORITY,
1048                  g_param_spec_int (NM_SETTING_DCB_APP_ISCSI_PRIORITY, "", "",
1049                                    -1, 7, -1,
1050                                    G_PARAM_READWRITE |
1051                                    G_PARAM_CONSTRUCT |
1052                                    G_PARAM_STATIC_STRINGS));
1053
1054         /**
1055          * NMSettingDcb:app-fip-flags:
1056          *
1057          * Specifies the #NMSettingDcbFlags for the DCB FIP application.  Flags may
1058          * be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
1059          * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1060          *
1061          * Since: 0.9.10
1062          **/
1063         g_object_class_install_property
1064                 (object_class, PROP_APP_FIP_FLAGS,
1065                  g_param_spec_uint (NM_SETTING_DCB_APP_FIP_FLAGS, "", "",
1066                                     0, DCB_FLAGS_ALL, 0,
1067                                     G_PARAM_READWRITE |
1068                                     G_PARAM_STATIC_STRINGS));
1069
1070         /**
1071          * NMSettingDcb:app-fip-priority:
1072          *
1073          * The highest User Priority (0 - 7) which FIP frames should use, or -1 for
1074          * default priority.  Only used when the #NMSettingDcb:app-fip-flags
1075          * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
1076          *
1077          * Since: 0.9.10
1078          **/
1079         g_object_class_install_property
1080                 (object_class, PROP_APP_FIP_PRIORITY,
1081                  g_param_spec_int (NM_SETTING_DCB_APP_FIP_PRIORITY, "", "",
1082                                    -1, 7, -1,
1083                                    G_PARAM_READWRITE |
1084                                    G_PARAM_CONSTRUCT |
1085                                    G_PARAM_STATIC_STRINGS));
1086
1087         /**
1088          * NMSettingDcb:priority-flow-control-flags:
1089          *
1090          * Specifies the #NMSettingDcbFlags for DCB Priority Flow Control (PFC).
1091          * Flags may be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
1092          * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1093          *
1094          * Since: 0.9.10
1095          **/
1096         g_object_class_install_property
1097                 (object_class, PROP_PFC_FLAGS,
1098                  g_param_spec_uint (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, "", "",
1099                                     0, DCB_FLAGS_ALL, 0,
1100                                     G_PARAM_READWRITE |
1101                                     G_PARAM_STATIC_STRINGS));
1102
1103         /**
1104          * NMSettingDcb:priority-flow-control:
1105          *
1106          * An array of 8 uint values, where the array index corresponds to the User
1107          * Priority (0 - 7) and the value indicates whether or not the corresponding
1108          * priority should transmit priority pause.  Allowed values are 0 (do not
1109          * transmit pause) and 1 (transmit pause).
1110          *
1111          * Since: 0.9.10
1112          **/
1113         g_object_class_install_property
1114                 (object_class, PROP_PFC,
1115                  _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, "", "",
1116                                              DBUS_TYPE_G_UINT_ARRAY,
1117                                              G_PARAM_READWRITE |
1118                                              G_PARAM_STATIC_STRINGS));
1119
1120         /**
1121          * NMSettingDcb:priority-group-flags:
1122          *
1123          * Specifies the #NMSettingDcbFlags for DCB Priority Groups.  Flags may be
1124          * any combination of %NM_SETTING_DCB_FLAG_ENABLE,
1125          * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1126          *
1127          * Since: 0.9.10
1128          **/
1129         g_object_class_install_property
1130                 (object_class, PROP_PRIORITY_GROUP_FLAGS,
1131                  g_param_spec_uint (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, "", "",
1132                                     0, DCB_FLAGS_ALL, 0,
1133                                     G_PARAM_READWRITE |
1134                                     G_PARAM_STATIC_STRINGS));
1135
1136         /**
1137          * NMSettingDcb:priority-group-id:
1138          *
1139          * An array of 8 uint values, where the array index corresponds to the User
1140          * Priority (0 - 7) and the value indicates the Priority Group ID.  Allowed
1141          * Priority Group ID values are 0 - 7 or 15 for the unrestricted group.
1142          *
1143          * Since: 0.9.10
1144          **/
1145         g_object_class_install_property
1146                 (object_class, PROP_PRIORITY_GROUP_ID,
1147                  _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_ID, "", "",
1148                                              DBUS_TYPE_G_UINT_ARRAY,
1149                                              G_PARAM_READWRITE |
1150                                              G_PARAM_STATIC_STRINGS));
1151
1152         /**
1153          * NMSettingDcb:priority-group-bandwidth:
1154          *
1155          * An array of 8 uint values, where the array index corresponds to the
1156          * Priority Group ID (0 - 7) and the value indicates the percentage of link
1157          * bandwidth allocated to that group.  Allowed values are 0 - 100, and the
1158          * sum of all values must total 100 percent.
1159          *
1160          * Since: 0.9.10
1161          **/
1162         g_object_class_install_property
1163                 (object_class, PROP_PRIORITY_GROUP_BANDWIDTH,
1164                  _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, "", "",
1165                                              DBUS_TYPE_G_UINT_ARRAY,
1166                                              G_PARAM_READWRITE |
1167                                              G_PARAM_STATIC_STRINGS));
1168
1169         /**
1170          * NMSettingDcb:priority-bandwidth:
1171          *
1172          * An array of 8 uint values, where the array index corresponds to the User
1173          * Priority (0 - 7) and the value indicates the percentage of bandwidth of
1174          * the priority's assigned group that the priority may use.  The sum of all
1175          * percentages for priorities which belong to the same group must total 100
1176          * percent.
1177          *
1178          * Since: 0.9.10
1179          **/
1180         g_object_class_install_property
1181                 (object_class, PROP_PRIORITY_BANDWIDTH,
1182                  _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_BANDWIDTH, "", "",
1183                                              DBUS_TYPE_G_UINT_ARRAY,
1184                                              G_PARAM_READWRITE |
1185                                              G_PARAM_STATIC_STRINGS));
1186
1187         /**
1188          * NMSettingDcb:priority-strict-bandwidth:
1189          *
1190          * An array of 8 uint values, where the array index corresponds to the User
1191          * Priority (0 - 7) and the value indicates whether or not the priority may
1192          * use all of the bandwidth allocated to its assigned group.  Allowed values
1193          * are 0 (the priority may not utilize all bandwidth) or 1 (the priority may
1194          * utilize all bandwidth).
1195          *
1196          * Since: 0.9.10
1197          **/
1198         g_object_class_install_property
1199                 (object_class, PROP_PRIORITY_STRICT,
1200                  _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, "", "",
1201                                              DBUS_TYPE_G_UINT_ARRAY,
1202                                              G_PARAM_READWRITE |
1203                                              G_PARAM_STATIC_STRINGS));
1204
1205         /**
1206          * NMSettingDcb:priority-traffic-class:
1207          *
1208          * An array of 8 uint values, where the array index corresponds to the User
1209          * Priority (0 - 7) and the value indicates the traffic class (0 - 7) to
1210          * which the priority is mapped.
1211          *
1212          * Since: 0.9.10
1213          **/
1214         g_object_class_install_property
1215                 (object_class, PROP_PRIORITY_TRAFFIC_CLASS,
1216                  _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, "", "",
1217                                              DBUS_TYPE_G_UINT_ARRAY,
1218                                              G_PARAM_READWRITE |
1219                                              G_PARAM_STATIC_STRINGS));
1220 }