diff options
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.cpp | 106 | ||||
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.h | 4 | ||||
-rw-r--r-- | tdecore/tdenetworkconnections.cpp | 12 | ||||
-rw-r--r-- | tdecore/tdenetworkconnections.h | 27 |
4 files changed, 149 insertions, 0 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp index 1a4de260a..1b95d5d09 100644 --- a/tdecore/networkbackends/network-manager/network-manager.cpp +++ b/tdecore/networkbackends/network-manager/network-manager.cpp @@ -235,6 +235,9 @@ TDENetworkConnectionType::TDENetworkConnectionType nmConnectionTypeToTDEConnecti else if (nm.lower() == "wimax") { ret = TDENetworkConnectionType::WiMax; } + else if (nm.lower() == "vlan") { + ret = TDENetworkConnectionType::VLAN; + } return ret; } @@ -257,6 +260,9 @@ TQString tdeConnectionTypeToNMConnectionType(TDENetworkConnectionType::TDENetwor else if (type == TDENetworkConnectionType::WiMax) { ret = "wimax"; } + else if (type == TDENetworkConnectionType::VLAN) { + ret = "vlan"; + } return ret; } @@ -684,6 +690,38 @@ unsigned int tdePasswordFlagsToNMPasswordFlags(TDENetworkPasswordHandlingFlags:: return ret; } +TDENetworkVLANFlags::TDENetworkVLANFlags nmVLANFlagsToTDEVLANFlags(unsigned int nm) { + TDENetworkVLANFlags::TDENetworkVLANFlags ret = TDENetworkVLANFlags::None; + + if (nm & NM_VLAN_REORDER_PACKET_HEADERS) { + ret |= TDENetworkVLANFlags::ReorderPacketHeaders; + } + if (nm & NM_VLAN_USE_GVRP) { + ret |= TDENetworkVLANFlags::UseGVRP; + } + if (nm & NM_VLAN_LOOSE_BINDING) { + ret |= TDENetworkVLANFlags::LooseBinding; + } + + return ret; +} + +unsigned int tdeVLANFlagsToNMVLANFlags(TDENetworkVLANFlags::TDENetworkVLANFlags flags) { + unsigned int ret = 0; + + if (flags & TDENetworkVLANFlags::ReorderPacketHeaders) { + ret |= NM_VLAN_REORDER_PACKET_HEADERS; + } + if (flags & TDENetworkVLANFlags::UseGVRP) { + ret |= NM_VLAN_USE_GVRP; + } + if (flags & TDENetworkVLANFlags::LooseBinding) { + ret |= NM_VLAN_LOOSE_BINDING; + } + + return ret; +} + TDENetworkWepKeyType::TDENetworkWepKeyType nmWepKeyTypeToTDEWepKeyType(unsigned int nm) { TDENetworkWepKeyType::TDENetworkWepKeyType ret = TDENetworkWepKeyType::Hexadecimal; @@ -1124,6 +1162,7 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() { TDEWiFiConnection* wiFiConnection = NULL; TDEVPNConnection* vpnConnection = NULL; TDEWiMaxConnection* wiMaxConnection = NULL; + TDEVLANConnection* vlanConnection = NULL; TDENetworkConnectionType::TDENetworkConnectionType connType = connectionType((*it)); if (connType == TDENetworkConnectionType::WiredEthernet) { connection = ethernetConnection = new TDEWiredEthernetConnection; @@ -1140,6 +1179,9 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() { else if (connType == TDENetworkConnectionType::WiMax) { connection = wiMaxConnection = new TDEWiMaxConnection; } + else if (connType == TDENetworkConnectionType::VLAN) { + connection = vlanConnection = new TDEVLANConnection; + } else { connection = new TDENetworkConnection; } @@ -1619,6 +1661,38 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() { wiMaxConnection->networkServiceProvider = dataValue2.toString(); } } + else if (outerKeyValue.lower() == "vlan") { + if (keyValue.lower() == "interface-name") { + vlanConnection->kernelName = dataValue2.toString(); + } + else if (keyValue.lower() == "parent") { + vlanConnection->parentConnectionUUID = dataValue2.toString(); + } + else if (keyValue.lower() == "id") { + vlanConnection->vlanID = dataValue2.toUInt32(); + } + else if (keyValue.lower() == "flags") { + vlanConnection->vlanFlags = nmVLANFlagsToTDEVLANFlags(dataValue2.toUInt32()); + } + else if (keyValue.lower() == "ingress-priority-map") { + TQT_DBusDataValueList valueList = dataValue2.toTQValueList(); + TQT_DBusDataValueList::const_iterator it4; + for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) { + TQT_DBusData innerDataValue = *it4; + TQStringList pieces = TQStringList::split(":", innerDataValue.toString(), TRUE); + vlanConnection->ingressPriorityMap[pieces[0].toUInt()] = pieces[1].toUInt();; + } + } + else if (keyValue.lower() == "egress-priority-map") { + TQT_DBusDataValueList valueList = dataValue2.toTQValueList(); + TQT_DBusDataValueList::const_iterator it4; + for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) { + TQT_DBusData innerDataValue = *it4; + TQStringList pieces = TQStringList::split(":", innerDataValue.toString(), TRUE); + vlanConnection->egressPriorityMap[pieces[0].toUInt()] = pieces[1].toUInt();; + } + } + } else if (outerKeyValue.lower() == "ipv4") { if (keyValue.lower() == "addresses") { TQT_DBusDataValueList valueList = dataValue2.toTQValueList(); @@ -2119,6 +2193,7 @@ bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection* TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection); TDEVPNConnection* vpnConnection = dynamic_cast<TDEVPNConnection*>(connection); TDEWiMaxConnection* wiMaxConnection = dynamic_cast<TDEWiMaxConnection*>(connection); + TDEVLANConnection* vlanConnection = dynamic_cast<TDEVLANConnection*>(connection); TQT_DBusObjectPath existingConnection; TQT_DBusError error; bool ret; @@ -2175,6 +2250,7 @@ bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection* else if (wiFiConnection) type = "802-11-wireless"; else if (vpnConnection) type = "vpn"; else if (wiMaxConnection) type = "wimax"; + else if (vlanConnection) type = "vlan"; if (!type.isNull()) settingsMap["type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(type)); } settingsMap["uuid"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->UUID)); @@ -2750,6 +2826,36 @@ bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection* } if (groupValid) outerMap.insert("wimax", dbusData, TRUE); else outerMap.remove("wimax"); + dbusData = outerMap["vlan"]; + { + TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap(); + { + UPDATE_STRING_SETTING_IF_VALID(vlanConnection->kernelName, "interface-name", settingsMap) + UPDATE_STRING_SETTING_IF_VALID(vlanConnection->parentConnectionUUID, "parent", settingsMap) + settingsMap["id"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(vlanConnection->vlanID)); + settingsMap["flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdeVLANFlagsToNMVLANFlags(vlanConnection->vlanFlags))); + { + TQT_DBusDataValueList valueList; + TDENetworkPriorityMap::const_iterator it; + for (it = vlanConnection->ingressPriorityMap.begin(); it != vlanConnection->ingressPriorityMap.end(); ++it) { + valueList.append(TQT_DBusData::fromString(TQString("%1:%2").arg(it.key()).arg(it.data()))); + } + if (valueList.count() > 0) settingsMap["ingress-priority-map"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList)); + } + { + TQT_DBusDataValueList valueList; + TDENetworkPriorityMap::const_iterator it; + for (it = vlanConnection->egressPriorityMap.begin(); it != vlanConnection->egressPriorityMap.end(); ++it) { + valueList.append(TQT_DBusData::fromString(TQString("%1:%2").arg(it.key()).arg(it.data()))); + } + if (valueList.count() > 0) settingsMap["egress-priority-map"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList)); + } + } + dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap)); + groupValid = (settingsMap.count() > 0); + } + if (groupValid) outerMap.insert("vlan", dbusData, TRUE); else outerMap.remove("vlan"); + dbusData = outerMap["ipv4"]; { TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap(); diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h index c992a0899..9faaf67f3 100644 --- a/tdecore/networkbackends/network-manager/network-manager.h +++ b/tdecore/networkbackends/network-manager/network-manager.h @@ -104,6 +104,10 @@ #define NM_WEP_TYPE_HEXADECIMAL 1 #define NM_WEP_TYPE_PASSPHRASE 2 //==================================================================================================== +#define NM_VLAN_REORDER_PACKET_HEADERS 0x01 +#define NM_VLAN_USE_GVRP 0x02 +#define NM_VLAN_LOOSE_BINDING 0x04 +//==================================================================================================== class TDENetworkConnectionManager_BackendNMPrivate; diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp index cda8e191e..4aa246578 100644 --- a/tdecore/tdenetworkconnections.cpp +++ b/tdecore/tdenetworkconnections.cpp @@ -459,6 +459,18 @@ TDEWiMaxConnection::~TDEWiMaxConnection() { } /*================================================================================================*/ +/* TDEVLANConnection */ +/*================================================================================================*/ + +TDEVLANConnection::TDEVLANConnection() : TDENetworkConnection() { + // +} + +TDEVLANConnection::~TDEVLANConnection() { + // +} + +/*================================================================================================*/ /* TDEWiFiConnection */ /*================================================================================================*/ diff --git a/tdecore/tdenetworkconnections.h b/tdecore/tdenetworkconnections.h index 5b80058aa..1e81cd851 100644 --- a/tdecore/tdenetworkconnections.h +++ b/tdecore/tdenetworkconnections.h @@ -59,6 +59,7 @@ typedef TQValueList<TQ_UINT8> TDENetworkByteList; typedef TQValueList<TQHostAddress> TDENetworkAddressList; typedef TQMap<TQString, TQString> TDENetworkSettingsMap; +typedef TQMap<TQ_UINT32, TQ_UINT32> TDENetworkPriorityMap; namespace TDENetworkDeviceType { enum TDENetworkDeviceType { @@ -211,6 +212,17 @@ namespace TDENetworkWepKeyType { }; }; +namespace TDENetworkVLANFlags { + enum TDENetworkVLANFlags { + None = 0x00000000, + ReorderPacketHeaders = 0x00000001, + UseGVRP = 0x00000002, + LooseBinding = 0x00000004 + }; + + CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkVLANFlags) +}; + typedef TQValueList<TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher> TDENetworkWiFiConnectionCipherList; namespace TDENetworkWiFiKeyType { @@ -679,6 +691,21 @@ class TDECORE_EXPORT TDEWiMaxConnection : public TDENetworkConnection TQString networkServiceProvider; }; +class TDECORE_EXPORT TDEVLANConnection : public TDENetworkConnection +{ + public: + TDEVLANConnection(); + virtual ~TDEVLANConnection(); + + public: + TQString kernelName; + TQString parentConnectionUUID; + TQ_UINT32 vlanID; + TDENetworkVLANFlags::TDENetworkVLANFlags vlanFlags; + TDENetworkPriorityMap ingressPriorityMap; + TDENetworkPriorityMap egressPriorityMap; +}; + typedef TQPtrList< TDENetworkConnection > TDENetworkConnectionList; class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject |