1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
|
// SPDX-License-Identifier: LGPL-2.1+
/*
* Copyright (C) 2017 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-device-macsec.h"
#include "nm-device-private.h"
#include "nm-object-private.h"
#include "nm-utils.h"
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT,
PROP_SCI,
PROP_CIPHER_SUITE,
PROP_ICV_LENGTH,
PROP_WINDOW,
PROP_ENCODING_SA,
PROP_ENCRYPT,
PROP_PROTECT,
PROP_INCLUDE_SCI,
PROP_ES,
PROP_SCB,
PROP_REPLAY_PROTECT,
PROP_VALIDATION, );
typedef struct {
NMLDBusPropertyO parent;
char * validation;
guint64 sci;
guint64 cipher_suite;
guint32 window;
guint8 icv_length;
guint8 encoding_sa;
bool encrypt;
bool protect;
bool include_sci;
bool es;
bool scb;
bool replay_protect;
} NMDeviceMacsecPrivate;
struct _NMDeviceMacsec {
NMDevice parent;
NMDeviceMacsecPrivate _priv;
};
struct _NMDeviceMacsecClass {
NMDeviceClass parent;
};
G_DEFINE_TYPE(NMDeviceMacsec, nm_device_macsec, NM_TYPE_DEVICE)
#define NM_DEVICE_MACSEC_GET_PRIVATE(self) \
_NM_GET_PRIVATE(self, NMDeviceMacsec, NM_IS_DEVICE_MACSEC, NMObject, NMDevice)
/*****************************************************************************/
/**
* nm_device_macsec_get_parent:
* @device: a #NMDeviceMacsec
*
* Returns: (transfer none): the device's parent device
*
* Since: 1.6
**/
NMDevice *
nm_device_macsec_get_parent(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), NULL);
return nml_dbus_property_o_get_obj(&NM_DEVICE_MACSEC_GET_PRIVATE(device)->parent);
}
/**
* nm_device_macsec_get_hw_address: (skip)
* @device: a #NMDeviceMacsec
*
* Gets the hardware (MAC) address of the #NMDeviceMacsec
*
* Returns: the hardware address. This is the internal string used by the
* device, and must not be modified.
*
* Since: 1.6
*
* Deprecated: 1.24: Use nm_device_get_hw_address() instead.
**/
const char *
nm_device_macsec_get_hw_address(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), NULL);
return nm_device_get_hw_address(NM_DEVICE(device));
}
/**
* nm_device_macsec_get_sci:
* @device: a #NMDeviceMacsec
*
* Gets the Secure Channel Identifier in use
*
* Returns: the SCI
*
* Since: 1.6
**/
guint64
nm_device_macsec_get_sci(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), 0);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->sci;
}
/**
* nm_device_macsec_get_icv_length:
* @device: a #NMDeviceMacsec
*
* Gets the length of ICV (Integrity Check Value)
*
* Returns: the length of ICV
*
* Since: 1.6
**/
guint8
nm_device_macsec_get_icv_length(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), 0);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->icv_length;
}
/**
* nm_device_macsec_get_cipher_suite:
* @device: a #NMDeviceMacsec
*
* Gets the set of cryptographic algorithms in use
*
* Returns: the set of cryptographic algorithms in use
*
* Since: 1.6
**/
guint64
nm_device_macsec_get_cipher_suite(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), 0);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->cipher_suite;
}
/**
* nm_device_macsec_get_window:
* @device: a #NMDeviceMacsec
*
* Gets the size of the replay window
*
* Returns: size of the replay window
*
* Since: 1.6
**/
guint
nm_device_macsec_get_window(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), 0);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->window;
}
/**
* nm_device_macsec_get_encoding_sa:
* @device: a #NMDeviceMacsec
*
* Gets the value of the Association Number (0..3) for the Security
* Association in use.
*
* Returns: the current Security Association
*
* Since: 1.6
**/
guint8
nm_device_macsec_get_encoding_sa(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), 0);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->encoding_sa;
}
/**
* nm_device_macsec_get_validation:
* @device: a #NMDeviceMacsec
*
* Gets the validation mode for incoming packets (strict, check,
* disabled)
*
* Returns: the validation mode
*
* Since: 1.6
**/
const char *
nm_device_macsec_get_validation(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), NULL);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->validation;
}
/**
* nm_device_macsec_get_encrypt:
* @device: a #NMDeviceMacsec
*
* Gets whether encryption of transmitted frames is enabled
*
* Returns: whether encryption is enabled
*
* Since: 1.6
**/
gboolean
nm_device_macsec_get_encrypt(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), FALSE);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->encrypt;
}
/**
* nm_device_macsec_get_protect:
* @device: a #NMDeviceMacsec
*
* Gets whether protection of transmitted frames is enabled
*
* Returns: whether protection is enabled
*
* Since: 1.6
**/
gboolean
nm_device_macsec_get_protect(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), FALSE);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->protect;
}
/**
* nm_device_macsec_get_include_sci:
* @device: a #NMDeviceMacsec
*
* Gets whether the SCI is always included in SecTAG for transmitted
* frames
*
* Returns: whether the SCI is always included
*
* Since: 1.6
**/
gboolean
nm_device_macsec_get_include_sci(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), FALSE);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->include_sci;
}
/**
* nm_device_macsec_get_es:
* @device: a #NMDeviceMacsec
*
* Gets whether the ES (End station) bit is enabled in SecTAG for
* transmitted frames
*
* Returns: whether the ES (End station) bit is enabled
*
* Since: 1.6
**/
gboolean
nm_device_macsec_get_es(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), FALSE);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->es;
}
/**
* nm_device_macsec_get_scb:
* @device: a #NMDeviceMacsec
*
* Gets whether the SCB (Single Copy Broadcast) bit is enabled in
* SecTAG for transmitted frames
*
* Returns: whether the SCB (Single Copy Broadcast) bit is enabled
*
* Since: 1.6
**/
gboolean
nm_device_macsec_get_scb(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), FALSE);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->scb;
}
/**
* nm_device_macsec_get_replay_protect:
* @device: a #NMDeviceMacsec
*
* Gets whether replay protection is enabled
*
* Returns: whether replay protection is enabled
*
* Since: 1.6
**/
gboolean
nm_device_macsec_get_replay_protect(NMDeviceMacsec *device)
{
g_return_val_if_fail(NM_IS_DEVICE_MACSEC(device), FALSE);
return NM_DEVICE_MACSEC_GET_PRIVATE(device)->replay_protect;
}
/***********************************************************/
static void
nm_device_macsec_init(NMDeviceMacsec *device)
{}
static void
finalize(GObject *object)
{
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE(object);
g_free(priv->validation);
G_OBJECT_CLASS(nm_device_macsec_parent_class)->finalize(object);
}
static void
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
NMDeviceMacsec *device = NM_DEVICE_MACSEC(object);
switch (prop_id) {
case PROP_PARENT:
g_value_set_object(value, nm_device_macsec_get_parent(device));
break;
case PROP_SCI:
g_value_set_uint64(value, nm_device_macsec_get_sci(device));
break;
case PROP_ICV_LENGTH:
g_value_set_uchar(value, nm_device_macsec_get_icv_length(device));
break;
case PROP_CIPHER_SUITE:
g_value_set_uint64(value, nm_device_macsec_get_cipher_suite(device));
break;
case PROP_WINDOW:
g_value_set_uint(value, nm_device_macsec_get_window(device));
break;
case PROP_ENCODING_SA:
g_value_set_uchar(value, nm_device_macsec_get_encoding_sa(device));
break;
case PROP_VALIDATION:
g_value_set_string(value, nm_device_macsec_get_validation(device));
break;
case PROP_ENCRYPT:
g_value_set_boolean(value, nm_device_macsec_get_encrypt(device));
break;
case PROP_PROTECT:
g_value_set_boolean(value, nm_device_macsec_get_protect(device));
break;
case PROP_INCLUDE_SCI:
g_value_set_boolean(value, nm_device_macsec_get_include_sci(device));
break;
case PROP_ES:
g_value_set_boolean(value, nm_device_macsec_get_es(device));
break;
case PROP_SCB:
g_value_set_boolean(value, nm_device_macsec_get_scb(device));
break;
case PROP_REPLAY_PROTECT:
g_value_set_boolean(value, nm_device_macsec_get_replay_protect(device));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_macsec = NML_DBUS_META_IFACE_INIT_PROP(
NM_DBUS_INTERFACE_DEVICE_MACSEC,
nm_device_macsec_get_type,
NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH,
NML_DBUS_META_IFACE_DBUS_PROPERTIES(
NML_DBUS_META_PROPERTY_INIT_T("CipherSuite",
PROP_CIPHER_SUITE,
NMDeviceMacsec,
_priv.cipher_suite),
NML_DBUS_META_PROPERTY_INIT_Y("EncodingSa",
PROP_ENCODING_SA,
NMDeviceMacsec,
_priv.encoding_sa),
NML_DBUS_META_PROPERTY_INIT_B("Encrypt", PROP_ENCRYPT, NMDeviceMacsec, _priv.encrypt),
NML_DBUS_META_PROPERTY_INIT_B("Es", PROP_ES, NMDeviceMacsec, _priv.es),
NML_DBUS_META_PROPERTY_INIT_Y("IcvLength",
PROP_ICV_LENGTH,
NMDeviceMacsec,
_priv.icv_length),
NML_DBUS_META_PROPERTY_INIT_B("IncludeSci",
PROP_INCLUDE_SCI,
NMDeviceMacsec,
_priv.include_sci),
NML_DBUS_META_PROPERTY_INIT_O_PROP("Parent",
PROP_PARENT,
NMDeviceMacsec,
_priv.parent,
nm_device_get_type),
NML_DBUS_META_PROPERTY_INIT_B("Protect", PROP_PROTECT, NMDeviceMacsec, _priv.protect),
NML_DBUS_META_PROPERTY_INIT_B("ReplayProtect",
PROP_REPLAY_PROTECT,
NMDeviceMacsec,
_priv.replay_protect),
NML_DBUS_META_PROPERTY_INIT_B("Scb", PROP_SCB, NMDeviceMacsec, _priv.scb),
NML_DBUS_META_PROPERTY_INIT_T("Sci", PROP_SCI, NMDeviceMacsec, _priv.sci),
NML_DBUS_META_PROPERTY_INIT_S("Validation",
PROP_VALIDATION,
NMDeviceMacsec,
_priv.validation),
NML_DBUS_META_PROPERTY_INIT_U("Window", PROP_WINDOW, NMDeviceMacsec, _priv.window), ), );
static void
nm_device_macsec_class_init(NMDeviceMacsecClass *klass)
{
GObjectClass * object_class = G_OBJECT_CLASS(klass);
NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass);
object_class->get_property = get_property;
object_class->finalize = finalize;
_NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceMacsec);
_NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceMacsecPrivate, parent);
/**
* NMDeviceMacsec:parent:
*
* The devices's parent device.
*
* Since: 1.6
**/
obj_properties[PROP_PARENT] = g_param_spec_object(NM_DEVICE_MACSEC_PARENT,
"",
"",
NM_TYPE_DEVICE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:sci:
*
* The Secure Channel Identifier in use.
*
* Since: 1.6
**/
obj_properties[PROP_SCI] = g_param_spec_uint64(NM_DEVICE_MACSEC_SCI,
"",
"",
0,
G_MAXUINT64,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:icv-length:
*
* The length of ICV (Integrity Check Value).
*
* Since: 1.6
**/
obj_properties[PROP_ICV_LENGTH] = g_param_spec_uchar(NM_DEVICE_MACSEC_ICV_LENGTH,
"",
"",
0,
G_MAXUINT8,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:cipher-suite:
*
* The set of cryptographic algorithms in use.
*
* Since: 1.6
**/
obj_properties[PROP_CIPHER_SUITE] =
g_param_spec_uint64(NM_DEVICE_MACSEC_CIPHER_SUITE,
"",
"",
0,
G_MAXUINT64,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:window:
*
* The size of the replay window.
*
* Since: 1.6
**/
obj_properties[PROP_WINDOW] = g_param_spec_uint(NM_DEVICE_MACSEC_WINDOW,
"",
"",
0,
G_MAXUINT32,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:encoding-sa:
*
* The value of the Association Number (0..3) for the Security
* Association in use.
*
* Since: 1.6
**/
obj_properties[PROP_ENCODING_SA] =
g_param_spec_uchar(NM_DEVICE_MACSEC_ENCODING_SA,
"",
"",
0,
G_MAXUINT8,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:validation:
*
* The validation mode for incoming packets (strict, check,
* disabled).
*
* Since: 1.6
**/
obj_properties[PROP_VALIDATION] =
g_param_spec_string(NM_DEVICE_MACSEC_VALIDATION,
"",
"",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:encrypt:
*
* Whether encryption of transmitted frames is enabled.
*
* Since: 1.6
**/
obj_properties[PROP_ENCRYPT] = g_param_spec_boolean(NM_DEVICE_MACSEC_ENCRYPT,
"",
"",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:protect:
*
* Whether protection of transmitted frames is enabled.
*
* Since: 1.6
**/
obj_properties[PROP_PROTECT] = g_param_spec_boolean(NM_DEVICE_MACSEC_PROTECT,
"",
"",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:include-sci:
*
* Whether the SCI is always included in SecTAG for transmitted
* frames.
*
* Since: 1.6
**/
obj_properties[PROP_INCLUDE_SCI] =
g_param_spec_boolean(NM_DEVICE_MACSEC_INCLUDE_SCI,
"",
"",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:es:
*
* Whether the ES (End station) bit is enabled in SecTAG for
* transmitted frames.
*
* Since: 1.6
**/
obj_properties[PROP_ES] = g_param_spec_boolean(NM_DEVICE_MACSEC_ES,
"",
"",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:scb:
*
* Whether the SCB (Single Copy Broadcast) bit is enabled in
* SecTAG for transmitted frames.
*
* Since: 1.6
**/
obj_properties[PROP_SCB] = g_param_spec_boolean(NM_DEVICE_MACSEC_SCB,
"",
"",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMDeviceMacsec:replay-protect:
*
* Whether replay protection is enabled.
*
* Since: 1.6
**/
obj_properties[PROP_REPLAY_PROTECT] =
g_param_spec_boolean(NM_DEVICE_MACSEC_REPLAY_PROTECT,
"",
"",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
_nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_macsec);
}
|