Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:11.4
NetworkManager-kde4
fix-bssid-bko238046.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-bssid-bko238046.diff of Package NetworkManager-kde4
Index: libs/ui/802_11_wirelesswidget.cpp =================================================================== --- libs/ui/802_11_wirelesswidget.cpp (revision 1175103) +++ libs/ui/802_11_wirelesswidget.cpp (working copy) @@ -128,6 +128,8 @@ void Wireless80211Widget::writeConfig() if (d->ui.bssid->text() != QString::fromLatin1(":::::")) { d->setting->setBssid(d->ui.bssid->text().toAscii()); + } else { + d->setting->setBssid(QByteArray()); } d->setting->setMtu(d->ui.mtu->value()); } Index: backends/NetworkManager/settingdbus.h =================================================================== --- backends/NetworkManager/settingdbus.h (revision 1175103) +++ backends/NetworkManager/settingdbus.h (working copy) @@ -39,6 +39,10 @@ class SettingDbus virtual void fromMap(const QVariantMap &) = 0; virtual QVariantMap toMap() = 0; virtual QVariantMap toSecretsMap() = 0; + + // static methods to convert between binary and hex string MAC representation + static QByteArray macHex2Bin(const QByteArray & hexMac); + static QByteArray macBin2Hex(const QByteArray & binMac); protected: static void insertIfTrue(QVariantMap& map, const char * key, bool value); static void insertIfNonZero(QVariantMap& map, const char * key, uint value); Index: backends/NetworkManager/settings/802-11-wirelessdbus.cpp =================================================================== --- backends/NetworkManager/settings/802-11-wirelessdbus.cpp (revision 1175103) +++ backends/NetworkManager/settings/802-11-wirelessdbus.cpp (working copy) @@ -29,7 +29,7 @@ void WirelessDbus::fromMap(const QVariantMap & map setting->setChannel(map.value("channel").value<uint>()); } if (map.contains("bssid")) { - setting->setBssid(map.value("bssid").value<QByteArray>()); + setting->setBssid(SettingDbus::macBin2Hex(map.value("bssid").value<QByteArray>())); } if (map.contains("rate")) { setting->setRate(map.value("rate").value<uint>()); @@ -38,7 +38,7 @@ void WirelessDbus::fromMap(const QVariantMap & map setting->setTxpower(map.value(QLatin1String(NM_SETTING_WIRELESS_TX_POWER)).value<uint>()); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS))) { - setting->setMacaddress(map.value(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS)).value<QByteArray>()); + setting->setMacaddress(SettingDbus::macBin2Hex(map.value(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS)).value<QByteArray>())); } if (map.contains("mtu")) { setting->setMtu(map.value("mtu").value<uint>()); @@ -77,12 +77,12 @@ QVariantMap WirelessDbus::toMap() #endif //map.insert("channel", setting->channel()); if (!setting->bssid().isEmpty()) { - map.insert("bssid", setting->bssid()); + map.insert("bssid", SettingDbus::macHex2Bin(setting->bssid())); } //map.insert("rate", setting->rate()); //map.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), setting->txpower()); if (!setting->macaddress().isEmpty()) { - map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), setting->macaddress()); + map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), SettingDbus::macHex2Bin(setting->macaddress())); } if (setting->mtu() > 0 ) map.insert("mtu", setting->mtu()); Index: backends/NetworkManager/settings/802-3-ethernetdbus.cpp =================================================================== --- backends/NetworkManager/settings/802-3-ethernetdbus.cpp (revision 1175103) +++ backends/NetworkManager/settings/802-3-ethernetdbus.cpp (working copy) @@ -29,7 +29,7 @@ void WiredDbus::fromMap(const QVariantMap & map) setting->setAutonegotiate(map.value(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE)).value<bool>()); } if (map.contains(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS))) { - setting->setMacaddress(map.value(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS)).value<QByteArray>()); + setting->setMacaddress(SettingDbus::macBin2Hex(map.value(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS)).value<QByteArray>())); } if (map.contains("mtu")) { setting->setMtu(map.value("mtu").value<uint>()); @@ -67,10 +67,10 @@ QVariantMap WiredDbus::toMap() } map.insert(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE), setting->autonegotiate()); #endif - // broken - //QString mac = setting->macaddress(); - //map.insert(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS), mac.remove(':').toAscii()); - if (setting->mtu() > 0 ) { + if (!setting->macaddress().isEmpty()) { + map.insert(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS), SettingDbus::macHex2Bin(setting->macaddress())); + } + if (setting->mtu() > 0) { map.insert("mtu", setting->mtu()); } return map; Index: backends/NetworkManager/settingdbus.cpp =================================================================== --- backends/NetworkManager/settingdbus.cpp (revision 1175103) +++ backends/NetworkManager/settingdbus.cpp (working copy) @@ -18,6 +18,8 @@ You should have received a copy of the GNU Lesser License along with this library. If not, see <http://www.gnu.org/licenses/>. */ +#include "ctype.h" + #include "settingdbus.h" using namespace Knm; @@ -33,6 +35,53 @@ SettingDbus::~SettingDbus() } +// convert MAC from hex string to binary +// e.g. 00:11:22:dd:ee:ff -> 6-byte array +QByteArray SettingDbus::macHex2Bin(const QByteArray & hexMac) +{ + const int MAC_STR_LEN = 17; + QByteArray ba = hexMac; + + if (ba.isEmpty()) return ba; + + // Check the MAC first and correct it. + // Although fromHex() ignores invalid characters, it scans the array from + // the end; so add missing zeroes to have even number of characters. + for (int i = 0; i < MAC_STR_LEN; i++) { + char ch = i < ba.size() ? ba.at(i) : ':'; + int mod = i%3; + if (mod != 2) { + if (ch == ':') ba.insert(i-mod, "0"); + else if (!isxdigit(ch)) ba[i] = '0'; + } else { + if (ch != ':') ba.insert(i, ":"); + } + } + ba.resize(MAC_STR_LEN); + + return QByteArray::fromHex(ba); +} + +// convert binary MAC to hex string (human readable) +// e.g. 6-byte array -> 00:11:22:dd:ee:ff +QByteArray SettingDbus::macBin2Hex(const QByteArray & binMac) +{ + const int MAC_STR_LEN = 17; + QByteArray ba = binMac; + + if (ba.isEmpty()) return ba; + + ba = ba.toHex().toUpper(); + ba.insert(2, ':'); + ba.insert(5, ':'); + ba.insert(8, ':'); + ba.insert(11, ':'); + ba.insert(14, ':'); + ba.resize(MAC_STR_LEN); + + return ba; +} + void SettingDbus::insertIfTrue(QVariantMap& map, const char * key, bool setting) { if (setting) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor