From cd677b247532305ca67b1459bafe74a19cead7ad Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 2 Feb 2015 10:51:22 +0100 Subject: Add support for hidden SSIDs Wifi access points may be configured not to broadcast its SSID, connecting to such networks requires a SSID-specific probe request. Add new property to WifiConfiguration for describing this type of networks. Change-Id: I068ac53936a860e3752e31b8151b87ba4308c510 Task-number: QTEE-816 Reviewed-by: Laszlo Agocs --- src/wifi/qwificonfiguration.cpp | 24 ++++++++++++++++++++++++ src/wifi/qwificonfiguration.h | 3 +++ src/wifi/qwifimanager.cpp | 8 ++++++++ 3 files changed, 35 insertions(+) (limited to 'src/wifi') diff --git a/src/wifi/qwificonfiguration.cpp b/src/wifi/qwificonfiguration.cpp index 42196a2..b532620 100644 --- a/src/wifi/qwificonfiguration.cpp +++ b/src/wifi/qwificonfiguration.cpp @@ -31,10 +31,12 @@ public: QString m_ssid; QString m_psk; QString m_protocol; + bool m_ssidHidden; }; QWifiConfigurationPrivate::QWifiConfigurationPrivate(QWifiConfiguration *config) : q_ptr(config) + , m_ssidHidden(false) { } @@ -119,4 +121,26 @@ void QWifiConfiguration::setProtocol(const QString &protocol) d->m_protocol = protocol; } +/*! + \property QWifiConfiguration::ssidHidden + \brief Holds whether a Wifi access point broadcasts its SSID + + If a Wifi access point does not broadcast its SSID, setting this + property to \c true ensures that the Wifi backend can detect the + specified network. + + By default this property is set to \c false. +*/ +bool QWifiConfiguration::isSsidHidden() const +{ + Q_D(const QWifiConfiguration); + return d->m_ssidHidden; +} + +void QWifiConfiguration::setSsidHidden(bool hidden) +{ + Q_D(QWifiConfiguration); + d->m_ssidHidden = hidden; +} + QT_END_NAMESPACE diff --git a/src/wifi/qwificonfiguration.h b/src/wifi/qwificonfiguration.h index 9b03c9e..cdeb453 100644 --- a/src/wifi/qwificonfiguration.h +++ b/src/wifi/qwificonfiguration.h @@ -32,6 +32,7 @@ class Q_DECL_EXPORT QWifiConfiguration : public QObject Q_PROPERTY(QString ssid READ ssid WRITE setSsid) Q_PROPERTY(QString passphrase READ passphrase WRITE setPassphrase) Q_PROPERTY(QString protocol READ protocol WRITE setProtocol) + Q_PROPERTY(bool ssidHidden READ isSsidHidden WRITE setSsidHidden) public: explicit QWifiConfiguration(QObject *parent = 0); virtual ~QWifiConfiguration(); @@ -42,6 +43,8 @@ public: QString passphrase() const; void setProtocol(const QString &protocol); QString protocol() const; + void setSsidHidden(bool hidden); + bool isSsidHidden() const; private: Q_DISABLE_COPY(QWifiConfiguration) diff --git a/src/wifi/qwifimanager.cpp b/src/wifi/qwifimanager.cpp index 319c9d9..d60ec13 100644 --- a/src/wifi/qwifimanager.cpp +++ b/src/wifi/qwifimanager.cpp @@ -506,7 +506,11 @@ bool QWifiManager::connect(QWifiConfiguration *config) QString key_mgmt; QString protocol = config->protocol().toUpper(); QString psk = config->passphrase(); + + // --------------------- configure network ------------------------------ // ref: http://w1.fi/cgit/hostap/plain/wpa_supplicant/wpa_supplicant.conf + // ref: https://www.freebsd.org/cgi/man.cgi?wpa_supplicant.conf + // ---------------------------------------------------------------------- if (protocol.isEmpty() || protocol.contains(QStringLiteral("WPA"))) { // ### todo - password length has limits (see IEEE 802.11), we need to check // for those limits here. Supplicant gives only a meaningless "fail" message. @@ -520,6 +524,10 @@ bool QWifiManager::connect(QWifiConfiguration *config) // open network key_mgmt = QLatin1String("NONE"); } + + if (config->isSsidHidden()) + ok = ok && d->checkedCall(setNetworkCommand + QLatin1String(" scan_ssid 1")); + ok = ok && d->checkedCall(setNetworkCommand + QLatin1String(" key_mgmt ") + key_mgmt); if (!ok) { if (!networkKnown) -- cgit v1.2.3