[PC-BSD Commits] r6960 - in pcbsd: current/pcbsd-netmanager/src/ethernetconfig stable/pcbsd-netmanager/src/ethernetconfig
svn at pcbsd.org
svn at pcbsd.org
Wed Jun 16 08:21:07 PDT 2010
Author: kris
Date: 2010-06-16 08:21:07 -0700 (Wed, 16 Jun 2010)
New Revision: 6960
Modified:
pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp
pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h
pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp
pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h
Log:
Improve ethernet manager, don't bother with "lagg" device if not on a system with wifi cards, its unnecessary in that case
Modified: pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp
===================================================================
--- pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp 2010-06-16 14:48:31 UTC (rev 6959)
+++ pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp 2010-06-16 15:21:07 UTC (rev 6960)
@@ -55,9 +55,17 @@
void ethernetconfig::slot_close()
{
-
exit(0);
+}
+// Function to check if we have wlan devices on this system
+bool ethernetconfig::isWifiEnabled() {
+ QString command = "ifconfig -l";
+ QString inputLine = getLineFromCommandOutput(command);
+ if ( inputLine.indexOf("wlan") != -1 )
+ return true;
+ else
+ return false;
}
bool ethernetconfig::checkRange(QString IP)
@@ -185,15 +193,19 @@
saveValue( "/etc/rc.conf", "ipv6_ifconfig_" + DeviceName + "=", "ipv6_ifconfig_" + DeviceName + "=\"" + lineIPv6Address->text() + "\"", -1);
}
- saveLaggLine(DeviceName, ifConfigLine);
+ // Check if we are doing lagg for wifi failover
+ if ( isWifiEnabled() ) {
+ saveLaggLine(DeviceName, ifConfigLine);
+ runCommand("ifconfig lagg0 destroy");
+ } else {
+ saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName + "=", "ifconfig_" + DeviceName + "=\"" + ifConfigLine + "\"", -1);
+ }
+ getLineFromCommandOutput("sync");
+ getLineFromCommandOutput("route -n flush");
+ getLineFromCommandOutput("/etc/rc.d/netif restart");
+ getLineFromCommandOutput("/etc/rc.d/routing restart");
- runCommand("sync");
- runCommand("ifconfig lagg0 destroy");
- runCommand("route -n flush");
- runCommand("/etc/rc.d/netif start");
- runCommand("/etc/rc.d/routing start");
-
// Done, now set the apply button to off
buttonApply->setEnabled(FALSE);
}
@@ -460,13 +472,16 @@
textInfoName->setText(tmp);
}
+ QString fDev = DeviceName ;
+ if ( useLagg )
+ fDev = "lagg0" ;
- textIP->setText(getIpForIdent("lagg0") );
- textNetmask->setText(getNetmaskForIdent( "lagg0" ) );
+ textIP->setText(getIpForIdent(fDev) );
+ textNetmask->setText(getNetmaskForIdent(fDev) );
textMac->setText(getMacForIdent( DeviceName ) );
textStatus->setText(getStatusForIdent( DeviceName ) );
textIPv6->setText(getIPv6ForIdent( DeviceName) );
- textGateway->setText(getGatewayForIdent("lagg0") );
+ textGateway->setText(getGatewayForIdent(fDev) );
tmp = getMediaForIdent(DeviceName);
tmp.truncate(20);
textMedia->setText(tmp);
@@ -563,17 +578,20 @@
void ethernetconfig::slotFinishLoad()
{
+ QString tmp, tmp2;
+ useLagg = true;
+ // Start loading the device information, first lagg0, then DeviceName
+ tmp = getValue( "/etc/rc.conf", "ifconfig_lagg0=", 1 );
+ if ( tmp.isEmpty() ) {
+ tmp = getValue( "/etc/rc.conf", "ifconfig_" + DeviceName + "=", 1 );
+ useLagg = false;
+ }
+ if ( tmp.isEmpty() ) {
+ checkDisableNetwork->setChecked(TRUE);
+ tabMainWidget->setEnabled(FALSE);
+ } else if ( tmp.indexOf("DHCP") != -1 ) {
- QString tmp, tmp2;
- // Start loading the device information
- tmp = getValue( "/etc/rc.conf", "ifconfig_lagg0=", 1 );
- if ( tmp.isEmpty() )
- {
- checkDisableNetwork->setChecked(TRUE);
- tabMainWidget->setEnabled(FALSE);
- } else if ( tmp.indexOf("DHCP") != -1 )
- {
checkDHCP->setChecked(TRUE);
lineNetmask->setText("255.255.255.0");
slotIPCheckbox();
@@ -593,12 +611,17 @@
} else {
// Look for an IP configuration
tmp2 = tmp;
- tmp2.remove(0, tmp2.lastIndexOf("laggport") + 9);
- tmp2 = tmp2.simplified();
- tmp2.remove(0, tmp2.indexOf(" "));
- tmp2 = tmp2.simplified();
- tmp2.truncate(tmp2.indexOf(" "));
+ // Using the lagg port
+ if ( useLagg ) {
+ tmp2.remove(0, tmp2.lastIndexOf("laggport") + 9);
+ tmp2 = tmp2.simplified();
+ tmp2.remove(0, tmp2.indexOf(" "));
+ }
+
+ tmp2 = tmp2.simplified();
+ tmp2.truncate(tmp2.indexOf(" "));
+
if ( ! tmp2.isEmpty())
{
lineIP->setText(tmp2);
Modified: pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h
===================================================================
--- pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h 2010-06-16 14:48:31 UTC (rev 6959)
+++ pcbsd/current/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h 2010-06-16 15:21:07 UTC (rev 6960)
@@ -71,8 +71,10 @@
virtual QString getGatewayForIdent(QString ident);
virtual QString getIPv6ForIdent(QString ident);
virtual QString getMediaForIdent( QString ident );
+ virtual bool isWifiEnabled();
void saveLaggLine(QString dev, QString config);
void setupEthLagg(QString dev);
+ bool useLagg;
Modified: pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp
===================================================================
--- pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp 2010-06-16 14:48:31 UTC (rev 6959)
+++ pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.cpp 2010-06-16 15:21:07 UTC (rev 6960)
@@ -55,9 +55,17 @@
void ethernetconfig::slot_close()
{
-
exit(0);
+}
+// Function to check if we have wlan devices on this system
+bool ethernetconfig::isWifiEnabled() {
+ QString command = "ifconfig -l";
+ QString inputLine = getLineFromCommandOutput(command);
+ if ( inputLine.indexOf("wlan") != -1 )
+ return true;
+ else
+ return false;
}
bool ethernetconfig::checkRange(QString IP)
@@ -185,15 +193,19 @@
saveValue( "/etc/rc.conf", "ipv6_ifconfig_" + DeviceName + "=", "ipv6_ifconfig_" + DeviceName + "=\"" + lineIPv6Address->text() + "\"", -1);
}
- saveLaggLine(DeviceName, ifConfigLine);
+ // Check if we are doing lagg for wifi failover
+ if ( isWifiEnabled() ) {
+ saveLaggLine(DeviceName, ifConfigLine);
+ runCommand("ifconfig lagg0 destroy");
+ } else {
+ saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName + "=", "ifconfig_" + DeviceName + "=\"" + ifConfigLine + "\"", -1);
+ }
+ getLineFromCommandOutput("sync");
+ getLineFromCommandOutput("route -n flush");
+ getLineFromCommandOutput("/etc/rc.d/netif restart");
+ getLineFromCommandOutput("/etc/rc.d/routing restart");
- runCommand("sync");
- runCommand("ifconfig lagg0 destroy");
- runCommand("route -n flush");
- runCommand("/etc/rc.d/netif start");
- runCommand("/etc/rc.d/routing start");
-
// Done, now set the apply button to off
buttonApply->setEnabled(FALSE);
}
@@ -460,13 +472,16 @@
textInfoName->setText(tmp);
}
+ QString fDev = DeviceName ;
+ if ( useLagg )
+ fDev = "lagg0" ;
- textIP->setText(getIpForIdent("lagg0") );
- textNetmask->setText(getNetmaskForIdent( "lagg0" ) );
+ textIP->setText(getIpForIdent(fDev) );
+ textNetmask->setText(getNetmaskForIdent(fDev) );
textMac->setText(getMacForIdent( DeviceName ) );
textStatus->setText(getStatusForIdent( DeviceName ) );
textIPv6->setText(getIPv6ForIdent( DeviceName) );
- textGateway->setText(getGatewayForIdent("lagg0") );
+ textGateway->setText(getGatewayForIdent(fDev) );
tmp = getMediaForIdent(DeviceName);
tmp.truncate(20);
textMedia->setText(tmp);
@@ -563,17 +578,20 @@
void ethernetconfig::slotFinishLoad()
{
+ QString tmp, tmp2;
+ useLagg = true;
+ // Start loading the device information, first lagg0, then DeviceName
+ tmp = getValue( "/etc/rc.conf", "ifconfig_lagg0=", 1 );
+ if ( tmp.isEmpty() ) {
+ tmp = getValue( "/etc/rc.conf", "ifconfig_" + DeviceName + "=", 1 );
+ useLagg = false;
+ }
+ if ( tmp.isEmpty() ) {
+ checkDisableNetwork->setChecked(TRUE);
+ tabMainWidget->setEnabled(FALSE);
+ } else if ( tmp.indexOf("DHCP") != -1 ) {
- QString tmp, tmp2;
- // Start loading the device information
- tmp = getValue( "/etc/rc.conf", "ifconfig_lagg0=", 1 );
- if ( tmp.isEmpty() )
- {
- checkDisableNetwork->setChecked(TRUE);
- tabMainWidget->setEnabled(FALSE);
- } else if ( tmp.indexOf("DHCP") != -1 )
- {
checkDHCP->setChecked(TRUE);
lineNetmask->setText("255.255.255.0");
slotIPCheckbox();
@@ -593,12 +611,17 @@
} else {
// Look for an IP configuration
tmp2 = tmp;
- tmp2.remove(0, tmp2.lastIndexOf("laggport") + 9);
- tmp2 = tmp2.simplified();
- tmp2.remove(0, tmp2.indexOf(" "));
- tmp2 = tmp2.simplified();
- tmp2.truncate(tmp2.indexOf(" "));
+ // Using the lagg port
+ if ( useLagg ) {
+ tmp2.remove(0, tmp2.lastIndexOf("laggport") + 9);
+ tmp2 = tmp2.simplified();
+ tmp2.remove(0, tmp2.indexOf(" "));
+ }
+
+ tmp2 = tmp2.simplified();
+ tmp2.truncate(tmp2.indexOf(" "));
+
if ( ! tmp2.isEmpty())
{
lineIP->setText(tmp2);
Modified: pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h
===================================================================
--- pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h 2010-06-16 14:48:31 UTC (rev 6959)
+++ pcbsd/stable/pcbsd-netmanager/src/ethernetconfig/ethernetconfig.h 2010-06-16 15:21:07 UTC (rev 6960)
@@ -71,8 +71,10 @@
virtual QString getGatewayForIdent(QString ident);
virtual QString getIPv6ForIdent(QString ident);
virtual QString getMediaForIdent( QString ident );
+ virtual bool isWifiEnabled();
void saveLaggLine(QString dev, QString config);
void setupEthLagg(QString dev);
+ bool useLagg;
More information about the Commits
mailing list