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{
20enum 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 */
38NETWORKMANAGERQT_EXPORT QHostAddress ipv6AddressAsHostAddress(const QByteArray &address);
39
40/**
41 * @return binary representation of an ipv6 address
42 * @param address qhostaddress containing the address
43 */
44NETWORKMANAGERQT_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 */
50NETWORKMANAGERQT_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 */
56NETWORKMANAGERQT_EXPORT QByteArray macAddressFromString(const QString &s);
57
58NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QString &macAddress);
59NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QByteArray &macAddress);
60
61/**
62 * @param freq frequency of a wireless network
63 * @return The frequency channel.
64 */
65NETWORKMANAGERQT_EXPORT int findChannel(int freq);
66
67NETWORKMANAGERQT_EXPORT NetworkManager::WirelessSetting::FrequencyBand findFrequencyBand(int freq);
68
69NETWORKMANAGERQT_EXPORT bool
70deviceSupportsApCiphers(NetworkManager::WirelessDevice::Capabilities, NetworkManager::AccessPoint::WpaFlags ciphers, WirelessSecurityType type);
71
72NETWORKMANAGERQT_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
80NETWORKMANAGERQT_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
87NETWORKMANAGERQT_EXPORT bool wepKeyIsValid(const QString &key, NetworkManager::WirelessSecuritySetting::WepKeyType type);
88
89NETWORKMANAGERQT_EXPORT bool wpaPskIsValid(const QString &psk);
90
91NETWORKMANAGERQT_EXPORT WirelessSecurityType securityTypeFromConnectionSetting(const NetworkManager::ConnectionSettings::Ptr &settings);
92
93NETWORKMANAGERQT_EXPORT QList<QPair<int, int>> getBFreqs();
94NETWORKMANAGERQT_EXPORT QList<QPair<int, int>> getAFreqs();
95
96NETWORKMANAGERQT_EXPORT QDateTime clockBootTimeToDateTime(qlonglong clockBootime);
97}
98
99#endif // NETWORKMANAGERQT_UTILS_H
100

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