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 | |
18 | namespace NetworkManager |
19 | { |
20 | enum WirelessSecurityType { |
21 | UnknownSecurity = -1, |
22 | NoneSecurity, |
23 | StaticWep, |
24 | DynamicWep, |
25 | Leap, |
26 | WpaPsk, |
27 | WpaEap, |
28 | Wpa2Psk, |
29 | Wpa2Eap, |
30 | SAE, |
31 | Wpa3SuiteB192, |
32 | }; |
33 | |
34 | /** |
35 | * @return QHostAddress representation of an ipv6 address |
36 | * @param address byte array containing the binary representation of the address |
37 | */ |
38 | NETWORKMANAGERQT_EXPORT QHostAddress ipv6AddressAsHostAddress(const QByteArray &address); |
39 | |
40 | /** |
41 | * @return binary representation of an ipv6 address |
42 | * @param address qhostaddress containing the address |
43 | */ |
44 | NETWORKMANAGERQT_EXPORT QByteArray ipv6AddressFromHostAddress(const QHostAddress &address); |
45 | |
46 | /** |
47 | * @return String representation of a mac address. |
48 | * @param ba byte array containing the binary repesentation of the address |
49 | */ |
50 | NETWORKMANAGERQT_EXPORT QString macAddressAsString(const QByteArray &ba); |
51 | |
52 | /** |
53 | * @return binary repesentation of a mac address. |
54 | * @param s string representation of the address |
55 | */ |
56 | NETWORKMANAGERQT_EXPORT QByteArray macAddressFromString(const QString &s); |
57 | |
58 | NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QString &macAddress); |
59 | NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QByteArray &macAddress); |
60 | |
61 | /** |
62 | * @param freq frequency of a wireless network |
63 | * @return The frequency channel. |
64 | */ |
65 | NETWORKMANAGERQT_EXPORT int findChannel(int freq); |
66 | |
67 | NETWORKMANAGERQT_EXPORT NetworkManager::WirelessSetting::FrequencyBand findFrequencyBand(int freq); |
68 | |
69 | NETWORKMANAGERQT_EXPORT bool |
70 | deviceSupportsApCiphers(NetworkManager::WirelessDevice::Capabilities, NetworkManager::AccessPoint::WpaFlags ciphers, WirelessSecurityType type); |
71 | |
72 | NETWORKMANAGERQT_EXPORT bool securityIsValid(WirelessSecurityType type, |
73 | NetworkManager::WirelessDevice::Capabilities interfaceCaps, |
74 | bool haveAp, |
75 | bool adHoc, |
76 | NetworkManager::AccessPoint::Capabilities apCaps, |
77 | NetworkManager::AccessPoint::WpaFlags apWpa, |
78 | NetworkManager::AccessPoint::WpaFlags apRsn); |
79 | |
80 | NETWORKMANAGERQT_EXPORT WirelessSecurityType findBestWirelessSecurity(NetworkManager::WirelessDevice::Capabilities, |
81 | bool haveAp, |
82 | bool adHoc, |
83 | NetworkManager::AccessPoint::Capabilities apCaps, |
84 | NetworkManager::AccessPoint::WpaFlags apWpa, |
85 | NetworkManager::AccessPoint::WpaFlags apRsn); |
86 | |
87 | NETWORKMANAGERQT_EXPORT bool wepKeyIsValid(const QString &key, NetworkManager::WirelessSecuritySetting::WepKeyType type); |
88 | |
89 | NETWORKMANAGERQT_EXPORT bool wpaPskIsValid(const QString &psk); |
90 | |
91 | NETWORKMANAGERQT_EXPORT WirelessSecurityType securityTypeFromConnectionSetting(const NetworkManager::ConnectionSettings::Ptr &settings); |
92 | |
93 | NETWORKMANAGERQT_EXPORT QList<QPair<int, int>> getBFreqs(); |
94 | NETWORKMANAGERQT_EXPORT QList<QPair<int, int>> getAFreqs(); |
95 | |
96 | NETWORKMANAGERQT_EXPORT QDateTime clockBootTimeToDateTime(qlonglong clockBootime); |
97 | } |
98 | |
99 | #endif // NETWORKMANAGERQT_UTILS_H |
100 | |