Add VLAN settings

pull/16/head
Timothy Pearson 12 years ago
parent 575b2aeee7
commit aae14103d5

@ -235,6 +235,9 @@ TDENetworkConnectionType::TDENetworkConnectionType nmConnectionTypeToTDEConnecti
else if (nm.lower() == "wimax") { else if (nm.lower() == "wimax") {
ret = TDENetworkConnectionType::WiMax; ret = TDENetworkConnectionType::WiMax;
} }
else if (nm.lower() == "vlan") {
ret = TDENetworkConnectionType::VLAN;
}
return ret; return ret;
} }
@ -257,6 +260,9 @@ TQString tdeConnectionTypeToNMConnectionType(TDENetworkConnectionType::TDENetwor
else if (type == TDENetworkConnectionType::WiMax) { else if (type == TDENetworkConnectionType::WiMax) {
ret = "wimax"; ret = "wimax";
} }
else if (type == TDENetworkConnectionType::VLAN) {
ret = "vlan";
}
return ret; return ret;
} }
@ -684,6 +690,38 @@ unsigned int tdePasswordFlagsToNMPasswordFlags(TDENetworkPasswordHandlingFlags::
return ret; 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 nmWepKeyTypeToTDEWepKeyType(unsigned int nm) {
TDENetworkWepKeyType::TDENetworkWepKeyType ret = TDENetworkWepKeyType::Hexadecimal; TDENetworkWepKeyType::TDENetworkWepKeyType ret = TDENetworkWepKeyType::Hexadecimal;
@ -1124,6 +1162,7 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
TDEWiFiConnection* wiFiConnection = NULL; TDEWiFiConnection* wiFiConnection = NULL;
TDEVPNConnection* vpnConnection = NULL; TDEVPNConnection* vpnConnection = NULL;
TDEWiMaxConnection* wiMaxConnection = NULL; TDEWiMaxConnection* wiMaxConnection = NULL;
TDEVLANConnection* vlanConnection = NULL;
TDENetworkConnectionType::TDENetworkConnectionType connType = connectionType((*it)); TDENetworkConnectionType::TDENetworkConnectionType connType = connectionType((*it));
if (connType == TDENetworkConnectionType::WiredEthernet) { if (connType == TDENetworkConnectionType::WiredEthernet) {
connection = ethernetConnection = new TDEWiredEthernetConnection; connection = ethernetConnection = new TDEWiredEthernetConnection;
@ -1140,6 +1179,9 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
else if (connType == TDENetworkConnectionType::WiMax) { else if (connType == TDENetworkConnectionType::WiMax) {
connection = wiMaxConnection = new TDEWiMaxConnection; connection = wiMaxConnection = new TDEWiMaxConnection;
} }
else if (connType == TDENetworkConnectionType::VLAN) {
connection = vlanConnection = new TDEVLANConnection;
}
else { else {
connection = new TDENetworkConnection; connection = new TDENetworkConnection;
} }
@ -1619,6 +1661,38 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
wiMaxConnection->networkServiceProvider = dataValue2.toString(); 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") { else if (outerKeyValue.lower() == "ipv4") {
if (keyValue.lower() == "addresses") { if (keyValue.lower() == "addresses") {
TQT_DBusDataValueList valueList = dataValue2.toTQValueList(); TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
@ -2119,6 +2193,7 @@ bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection*
TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection); TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection);
TDEVPNConnection* vpnConnection = dynamic_cast<TDEVPNConnection*>(connection); TDEVPNConnection* vpnConnection = dynamic_cast<TDEVPNConnection*>(connection);
TDEWiMaxConnection* wiMaxConnection = dynamic_cast<TDEWiMaxConnection*>(connection); TDEWiMaxConnection* wiMaxConnection = dynamic_cast<TDEWiMaxConnection*>(connection);
TDEVLANConnection* vlanConnection = dynamic_cast<TDEVLANConnection*>(connection);
TQT_DBusObjectPath existingConnection; TQT_DBusObjectPath existingConnection;
TQT_DBusError error; TQT_DBusError error;
bool ret; bool ret;
@ -2175,6 +2250,7 @@ bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection*
else if (wiFiConnection) type = "802-11-wireless"; else if (wiFiConnection) type = "802-11-wireless";
else if (vpnConnection) type = "vpn"; else if (vpnConnection) type = "vpn";
else if (wiMaxConnection) type = "wimax"; else if (wiMaxConnection) type = "wimax";
else if (vlanConnection) type = "vlan";
if (!type.isNull()) settingsMap["type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(type)); if (!type.isNull()) settingsMap["type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(type));
} }
settingsMap["uuid"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->UUID)); 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"); 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"]; dbusData = outerMap["ipv4"];
{ {
TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap(); TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();

@ -104,6 +104,10 @@
#define NM_WEP_TYPE_HEXADECIMAL 1 #define NM_WEP_TYPE_HEXADECIMAL 1
#define NM_WEP_TYPE_PASSPHRASE 2 #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; class TDENetworkConnectionManager_BackendNMPrivate;

@ -458,6 +458,18 @@ TDEWiMaxConnection::~TDEWiMaxConnection() {
// //
} }
/*================================================================================================*/
/* TDEVLANConnection */
/*================================================================================================*/
TDEVLANConnection::TDEVLANConnection() : TDENetworkConnection() {
//
}
TDEVLANConnection::~TDEVLANConnection() {
//
}
/*================================================================================================*/ /*================================================================================================*/
/* TDEWiFiConnection */ /* TDEWiFiConnection */
/*================================================================================================*/ /*================================================================================================*/

@ -59,6 +59,7 @@
typedef TQValueList<TQ_UINT8> TDENetworkByteList; typedef TQValueList<TQ_UINT8> TDENetworkByteList;
typedef TQValueList<TQHostAddress> TDENetworkAddressList; typedef TQValueList<TQHostAddress> TDENetworkAddressList;
typedef TQMap<TQString, TQString> TDENetworkSettingsMap; typedef TQMap<TQString, TQString> TDENetworkSettingsMap;
typedef TQMap<TQ_UINT32, TQ_UINT32> TDENetworkPriorityMap;
namespace TDENetworkDeviceType { namespace TDENetworkDeviceType {
enum 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; typedef TQValueList<TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher> TDENetworkWiFiConnectionCipherList;
namespace TDENetworkWiFiKeyType { namespace TDENetworkWiFiKeyType {
@ -679,6 +691,21 @@ class TDECORE_EXPORT TDEWiMaxConnection : public TDENetworkConnection
TQString networkServiceProvider; 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; typedef TQPtrList< TDENetworkConnection > TDENetworkConnectionList;
class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject

Loading…
Cancel
Save