blob: 3fb73a39f8e54f09489f98c0aa21264c30531339 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/**
* Copyright (c) 2010,2011 - RZ Uni Freiburg
* Copyright (c) 2010,2011 - OpenSLX Project
*
* This program/file is free software distributed under the GPL version 2.
* See http://openslx.org/COPYING
*
* If you have any feedback please consult http://openslx.org/feedback and
* send your feedback to feedback@openslx.org
*
* General information about OpenSLX can be found under http://openslx.org
*/
#ifndef NetworkDiscovery_H
#define NetworkDiscovery_H
#include <QtNetwork>
#include <QtCore>
#include <arpa/inet.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
#include <sysfs/libsysfs.h>
#include "interfaceconfiguration.h"
#include "networkmanager.h"
#include "dhcp.h"
#include "globals.h"
#include "../common/fbgui.h"
class NetworkDiscovery: public QObject {
Q_OBJECT
public:
NetworkDiscovery(QObject *parent = 0);
~NetworkDiscovery();
void init(QStringList* args = NULL);
bool checkConnectivity(QString ifName);
bool checkConnectivityViaTcp();
int ip4_setManualConfiguration(QVariantMap result);
void tryAgain();
void prepareTryAgain();
// Public member access
const QList<QString>& getIfConnectedList();
const QList<QString>& getIfUpList();
InterfaceConfiguration* getInterfaceConfig(QString ifName);
const QString& getErrorStr();
public slots:
void readyForRun();
void checkForIsRunning();
void handleNewConnection();
void handleClientDisconnect();
void handleNewInput();
void handleNewInputLine(QLocalSocket * client, QString data);
void handleProcessStarted();
void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void activateUserChoice();
signals:
void updateStatus(QString status);
void addInterface(const QString &ifName);
void updateIfStatus(QString ifName, QString status);
void changeProgressBarValue(const QString & ifName, const int $newValue);
void allProcessesFinished(bool userChoice);
void continueBootWithoutCheck(QString ifName);
void abortBoot(QString msg);
private:
void run();
void getListOfNetworkInterfaces();
void getListOfNetworkInterfacesWithAutoUp();
bool checkBlackList(QString i);
bool checkConnectivityViaTcp(QString server);
void runDHCPCD(QList<QString> &interfaces);
void runDHCPCD(QString interface);
void killDHCPCD();
void handleNewInput(QLocalSocket * client);
QLocalServer *_server;
QLocalSocket *_client;
QMap<QLocalSocket*, QLocalSocket*> _clients;
QMap<QString, QLocalSocket*> _ifNameToClient;
QMap<QProcess*, QString> _clientProcessToIfNameMap;
//QList<Q_PID> _pidsList;
bool _userChoice;
bool _blocked;
QTimer*_timer;
QList<QString> _ifUpList;
QList<QString> _ifDownList;
QList<QString> _ifConnectedList;
int _ifUpCountdown;
int _numberOfProcesses;
QStringList _dhcpcdArguments;
NetworkManager* _networkManager;
QMap<QString, InterfaceConfiguration*> _ifcMap;
QString _errorStr;
};
#endif // NetworkDiscovery_H
|