7#include "macsecsetting.h"
8#include "macsecsetting_p.h"
12#if !NM_CHECK_VERSION(1, 6, 0)
13#define NM_SETTING_MACSEC_SETTING_NAME "macsec"
15#define NM_SETTING_MACSEC_PARENT "parent"
16#define NM_SETTING_MACSEC_MODE "mode"
17#define NM_SETTING_MACSEC_ENCRYPT "encrypt"
18#define NM_SETTING_MACSEC_MKA_CAK "mka-cak"
19#define NM_SETTING_MACSEC_MKA_CAK_FLAGS "mka-cak-flags"
20#define NM_SETTING_MACSEC_MKA_CKN "mka-ckn"
21#define NM_SETTING_MACSEC_PORT "port"
22#define NM_SETTING_MACSEC_VALIDATION "validation"
25#if !NM_CHECK_VERSION(1, 12, 0)
26#define NM_SETTING_MACSEC_SEND_SCI "send-sci"
29NetworkManager::MacsecSettingPrivate::MacsecSettingPrivate()
30 : name(NM_SETTING_MACSEC_SETTING_NAME)
39NetworkManager::MacsecSetting::MacsecSetting()
40 : Setting(Setting::Macsec)
41 , d_ptr(new MacsecSettingPrivate())
45NetworkManager::MacsecSetting::MacsecSetting(
const Ptr &other)
47 , d_ptr(new MacsecSettingPrivate())
49 setEncrypt(other->encrypt());
50 setMkaCak(other->mkaCak());
51 setMkaCkn(other->mkaCkn());
52 setMode(other->mode());
53 setParent(other->parent());
54 setPort(other->port());
55 setSendSci(other->sendSci());
56 setValidation(other->validation());
57 setMkaCakFlags(other->mkaCakFlags());
60NetworkManager::MacsecSetting::~MacsecSetting()
72void NetworkManager::MacsecSetting::setEncrypt(
bool encrypt)
79bool NetworkManager::MacsecSetting::encrypt()
const
81 Q_D(
const MacsecSetting);
86void NetworkManager::MacsecSetting::setMkaCak(
const QString &mkaCak)
93QString NetworkManager::MacsecSetting::mkaCak()
const
95 Q_D(
const MacsecSetting);
100void NetworkManager::MacsecSetting::setMkaCkn(
const QString &mkaCkn)
107QString NetworkManager::MacsecSetting::mkaCkn()
const
109 Q_D(
const MacsecSetting);
114void NetworkManager::MacsecSetting::setMode(Mode mode)
121NetworkManager::MacsecSetting::Mode NetworkManager::MacsecSetting::mode()
const
123 Q_D(
const MacsecSetting);
128void NetworkManager::MacsecSetting::setParent(
const QString &parent)
135QString NetworkManager::MacsecSetting::parent()
const
137 Q_D(
const MacsecSetting);
142void NetworkManager::MacsecSetting::setPort(qint32 port)
149qint32 NetworkManager::MacsecSetting::port()
const
151 Q_D(
const MacsecSetting);
156void NetworkManager::MacsecSetting::setSendSci(
bool sendSci)
160 d->sendSci = sendSci;
163bool NetworkManager::MacsecSetting::sendSci()
const
165 Q_D(
const MacsecSetting);
170void NetworkManager::MacsecSetting::setValidation(Validation validation)
174 d->validation = validation;
177NetworkManager::MacsecSetting::Validation NetworkManager::MacsecSetting::validation()
const
179 Q_D(
const MacsecSetting);
181 return d->validation;
188 d->mkaCakFlags = flags;
193 Q_D(
const MacsecSetting);
195 return d->mkaCakFlags;
198QStringList NetworkManager::MacsecSetting::needSecrets(
bool requestNew)
const
202 if ((mkaCak().isEmpty() || requestNew) && !mkaCakFlags().testFlag(Setting::NotRequired)) {
209void NetworkManager::MacsecSetting::secretsFromMap(
const QVariantMap &secrets)
211 if (secrets.contains(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK))) {
216QVariantMap NetworkManager::MacsecSetting::secretsToMap()
const
220 if (!mkaCak().isEmpty()) {
221 secrets.insert(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK), mkaCak());
229 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_ENCRYPT))) {
230 setEncrypt(setting.value(
QLatin1String(NM_SETTING_MACSEC_ENCRYPT)).toBool());
233 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK))) {
234 setMkaCak(setting.value(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK)).toString());
237 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_MKA_CKN))) {
238 setMkaCkn(setting.value(
QLatin1String(NM_SETTING_MACSEC_MKA_CKN)).toString());
241 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_MODE))) {
242 setMode((Mode)setting.value(
QLatin1String(NM_SETTING_MACSEC_MODE)).toInt());
245 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_PARENT))) {
246 setParent(setting.value(
QLatin1String(NM_SETTING_MACSEC_PARENT)).toString());
249 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_PORT))) {
250 setPort(setting.value(
QLatin1String(NM_SETTING_MACSEC_PORT)).toInt());
253 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_SEND_SCI))) {
254 setSendSci(setting.value(
QLatin1String(NM_SETTING_MACSEC_SEND_SCI)).toBool());
257 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_VALIDATION))) {
258 setValidation((Validation)setting.value(
QLatin1String(NM_SETTING_MACSEC_VALIDATION)).toInt());
261 if (setting.contains(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK_FLAGS))) {
271 setting.insert(
QLatin1String(NM_SETTING_MACSEC_ENCRYPT), encrypt());
274 if (!mkaCak().isEmpty()) {
275 setting.insert(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK), mkaCak());
278 if (!mkaCkn().isEmpty()) {
279 setting.insert(
QLatin1String(NM_SETTING_MACSEC_MKA_CKN), mkaCkn());
282 if (mode() > NetworkManager::MacsecSetting::Psk) {
283 setting.insert(
QLatin1String(NM_SETTING_MACSEC_MODE), (
int)mode());
286 if (!parent().isEmpty()) {
287 setting.insert(
QLatin1String(NM_SETTING_MACSEC_PARENT), parent());
291 setting.insert(
QLatin1String(NM_SETTING_MACSEC_PORT), port());
295 setting.insert(
QLatin1String(NM_SETTING_MACSEC_SEND_SCI), sendSci());
298 if (validation() != NetworkManager::MacsecSetting::Strict) {
299 setting.insert(
QLatin1String(NM_SETTING_MACSEC_VALIDATION), (
int)validation());
302 setting.insert(
QLatin1String(NM_SETTING_MACSEC_MKA_CAK_FLAGS), (
int)mkaCakFlags());
309 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
310 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
312 dbg.
nospace() << NM_SETTING_MACSEC_ENCRYPT <<
": " << setting.encrypt() <<
'\n';
313 dbg.
nospace() << NM_SETTING_MACSEC_MKA_CAK <<
": " << setting.mkaCak() <<
'\n';
314 dbg.
nospace() << NM_SETTING_MACSEC_MKA_CKN <<
": " << setting.mkaCkn() <<
'\n';
315 dbg.
nospace() << NM_SETTING_MACSEC_MODE <<
": " << setting.mode() <<
'\n';
316 dbg.
nospace() << NM_SETTING_MACSEC_PARENT <<
": " << setting.parent() <<
'\n';
317 dbg.
nospace() << NM_SETTING_MACSEC_PORT <<
": " << setting.port() <<
'\n';
318 dbg.
nospace() << NM_SETTING_MACSEC_SEND_SCI <<
": " << setting.sendSci() <<
'\n';
319 dbg.
nospace() << NM_SETTING_MACSEC_VALIDATION <<
": " << setting.validation() <<
'\n';
320 dbg.
nospace() << NM_SETTING_MACSEC_MKA_CAK_FLAGS <<
": " << setting.mkaCakFlags() <<
'\n';
Represents Macsec setting.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
char * toString(const EngineQuery &query)
This class allows querying the underlying system to discover the available network interfaces and rea...