summaryrefslogtreecommitdiffstats
path: root/LogReceiver/networkdiscovery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LogReceiver/networkdiscovery.cpp')
-rw-r--r--LogReceiver/networkdiscovery.cpp81
1 files changed, 60 insertions, 21 deletions
diff --git a/LogReceiver/networkdiscovery.cpp b/LogReceiver/networkdiscovery.cpp
index 159321d..7255095 100644
--- a/LogReceiver/networkdiscovery.cpp
+++ b/LogReceiver/networkdiscovery.cpp
@@ -43,10 +43,9 @@ void NetworkDiscovery::initAndRun(QString serverPath, QString pathToExe,
QFileInfo fInfo(pathToDhcpcdExe);
if (!fInfo.exists()) {
qDebug()
- << "couldn't find customdhcpcd exe. Please check the path to this file.";
- emit
- abortBoot(
- "couldn't find customdhcpcd exe. Please check the path to this file.");
+ << "could not find customdhcpcd exe. Please check the path to this file.";
+ emit abortBoot(
+ "could not find customdhcpcd exe. Please check the path to this file.");
return;
}
@@ -71,9 +70,8 @@ void NetworkDiscovery::initAndRun(QString serverPath, QString pathToExe,
numberOfProcesses = list.size();
runDHCPCD(list);
} else {
- qDebug() << "list is empty. Haven't found usable interface.";
- emit
- abortBoot("Haven't found usable interface");
+ qDebug() << "list is empty. Have not found usable interface.";
+ emit abortBoot("Haven not found usable interface");
return;
}
@@ -98,7 +96,15 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
//}
QList<QString> dns;
dns.append(result["dns"].toString());
- return networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
+ qDebug() << result["ifname"].toString();
+ qDebug() << result["ipaddr"].toString();
+ qDebug() << result["netmask"].toString();
+ qDebug() << result["broadcast"].toString();
+ qDebug() << result["gateway"].toString();
+ qDebug() << dns;
+
+
+ networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
result["ipaddr"].toString(),
result["netmask"].toString(),
result["broadcast"].toString(),
@@ -108,6 +114,30 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
true,
"/etc/",
dns);
+
+ qDebug() << "set man conf. test connectivity";
+
+ if (!checkConnectivityViaTcp(QString("74.125.39.99"))) {
+ qDebug() << "no connectivity. reset conf.";
+ interfaceconfiguration * ifc = _ifcMap.value(result["ifname"].toString(), NULL);
+ if(ifc != NULL) {
+ QList<QString> dns = ifc->getDnsservers().trimmed().split(" ");
+ networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
+ ifc->getIpAddress(),
+ ifc->getNetmask(),
+ ifc->getBroadcast(),
+ ifc->getGateway(),
+ 0,
+ AF_INET,
+ true,
+ "/etc/",
+ dns);
+ }
+
+ return 0;
+ }
+ emit continueBoot(result["ifname"].toString(), 0);
+ return 0;
}
QString NetworkDiscovery::getGatewayForInterface(QString ifName) {
@@ -231,20 +261,13 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) {
_ifcMap.insert(ifName, ifConf);
// replace default route
- qDebug() << networkManager.replaceDefaultRoute(ifName, ifConf->getGateway(), 0, AF_INET);
+ qDebug() << networkManager.replaceDefaultRoute(ifName,
+ ifConf->getGateway(), 0, AF_INET);
- // check connectivity via tcp connection
- QTcpSocket *tcpSocket = new QTcpSocket(this);
- tcpSocket->connectToHost(QString("209.85.148.105"), 80);
- if (!tcpSocket->waitForConnected(500)) {
- qDebug() << "no internet connection with interface" << ifName;
- qDebug() << tcpSocket->errorString();
- emit
- updateStatusLabel(ifName, "connection not possible");
- return false;
- } else {
+ if (checkConnectivityViaTcp("209.85.148.105")) {
qDebug() << "internet: check passed! for interface" << ifName;
- emit updateStatusLabel(ifName, "connection possible");
+ emit
+ updateStatusLabel(ifName, "connection possible");
if (!_userChoice) {
// blockiere jeden weiteren check
// emite continueBoot
@@ -253,8 +276,24 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) {
} else {
emit connectionEstablished(ifName);
}
- return true;
+ } else {
+ qDebug() << "no internet connection with interface" << ifName;
+ emit
+ updateStatusLabel(ifName, "connection not possible");
}
+
+}
+
+bool NetworkDiscovery::checkConnectivityViaTcp(QString server) {
+ // check connectivity via tcp connection
+ QTcpSocket *tcpSocket = new QTcpSocket(this);
+ tcpSocket->connectToHost(server, 80);
+ if (!tcpSocket->waitForConnected(500)) {
+ qDebug() << tcpSocket->errorString();
+ return false;
+ } else {
+ return true;
+ }
}
/**