1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef NETWORKMANAGERQT_UTILS_H
8#define NETWORKMANAGERQT_UTILS_H
9
10#include <QHostAddress>
11#include <QPair>
12
13#include "wirelessdevice.h"
14#include "wirelesssecuritysetting.h"
15#include "wirelesssetting.h"
16#include <networkmanagerqt/networkmanagerqt_export.h>
17
18namespace NetworkManager
19{
20/*!
21 *
22 * Capabilities to pass to secret agents
23 *
24 * \value UnknownSecurity
25 * \value NoneSecurity
26 * \value StaticWep
27 * \value DynamicWep
28 * \value Leap
29 * \value WpaPsk
30 * \value WpaEap
31 * \value Wpa2Psk
32 * \value Wpa2Eap
33 * \value SAE
34 * \value Wpa3SuiteB192
35 * \value OWE
36 */
37enum WirelessSecurityType {
38 UnknownSecurity = -1,
39 NoneSecurity,
40 StaticWep,
41 DynamicWep,
42 Leap,
43 WpaPsk,
44 WpaEap,
45 Wpa2Psk,
46 Wpa2Eap,
47 SAE,
48 Wpa3SuiteB192,
49 OWE,
50};
51
52/*!
53 * Returns QHostAddress representation of an ipv6 address
54 *
55 * \a address byte array containing the binary representation of the address
56 */
57NETWORKMANAGERQT_EXPORT QHostAddress ipv6AddressAsHostAddress(const QByteArray &address);
58
59/*!
60 * Returns binary representation of an ipv6 address
61 *
62 * \a address qhostaddress containing the address
63 */
64NETWORKMANAGERQT_EXPORT QByteArray ipv6AddressFromHostAddress(const QHostAddress &address);
65
66/*!
67 * Returns String representation of a mac address.
68 *
69 * \a ba byte array containing the binary repesentation of the address
70 */
71NETWORKMANAGERQT_EXPORT QString macAddressAsString(const QByteArray &ba);
72
73/*!
74 * Returns binary repesentation of a mac address.
75 *
76 * \a s string representation of the address
77 */
78NETWORKMANAGERQT_EXPORT QByteArray macAddressFromString(const QString &s);
79
80/*!
81 */
82NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QString &macAddress);
83/*!
84 */
85NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QByteArray &macAddress);
86
87/*!
88 * \a freq frequency of a wireless network
89 *
90 * Returns The frequency channel.
91 */
92NETWORKMANAGERQT_EXPORT int findChannel(int freq);
93
94/*!
95 */
96NETWORKMANAGERQT_EXPORT NetworkManager::WirelessSetting::FrequencyBand findFrequencyBand(int freq);
97
98/*!
99 */
100NETWORKMANAGERQT_EXPORT bool
101deviceSupportsApCiphers(NetworkManager::WirelessDevice::Capabilities, NetworkManager::AccessPoint::WpaFlags ciphers, WirelessSecurityType type);
102
103/*!
104 */
105NETWORKMANAGERQT_EXPORT bool securityIsValid(WirelessSecurityType type,
106 NetworkManager::WirelessDevice::Capabilities interfaceCaps,
107 bool haveAp,
108 bool adHoc,
109 NetworkManager::AccessPoint::Capabilities apCaps,
110 NetworkManager::AccessPoint::WpaFlags apWpa,
111 NetworkManager::AccessPoint::WpaFlags apRsn);
112
113/*!
114 */
115NETWORKMANAGERQT_EXPORT WirelessSecurityType findBestWirelessSecurity(NetworkManager::WirelessDevice::Capabilities,
116 bool haveAp,
117 bool adHoc,
118 NetworkManager::AccessPoint::Capabilities apCaps,
119 NetworkManager::AccessPoint::WpaFlags apWpa,
120 NetworkManager::AccessPoint::WpaFlags apRsn);
121
122/*!
123 */
124NETWORKMANAGERQT_EXPORT bool wepKeyIsValid(const QString &key, NetworkManager::WirelessSecuritySetting::WepKeyType type);
125
126/*!
127 */
128NETWORKMANAGERQT_EXPORT bool wpaPskIsValid(const QString &psk);
129
130/*!
131 */
132NETWORKMANAGERQT_EXPORT WirelessSecurityType securityTypeFromConnectionSetting(const NetworkManager::ConnectionSettings::Ptr &settings);
133
134/*!
135 */
136NETWORKMANAGERQT_EXPORT QList<QPair<int, int>> getBFreqs();
137/*!
138 */
139NETWORKMANAGERQT_EXPORT QList<QPair<int, int>> getAFreqs();
140
141/*!
142 */
143NETWORKMANAGERQT_EXPORT QDateTime clockBootTimeToDateTime(qlonglong clockBootime);
144}
145
146#endif // NETWORKMANAGERQT_UTILS_H
147

source code of networkmanager-qt/src/utils.h