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
|
#ifndef LOGRECEIVER_H
#define LOGRECEIVER_H
#include <QMap>
#include <QtNetwork>
#include <QProcess>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
#include <sysfs/libsysfs.h>
#include "interfaceconfiguration.h"
//#include <qlocalserver.h>
//#include <qlocalsocket.h>
#include "status.h"
#include "dhcp.h"
#include "interface.h"
//#include <QProcess>
//#include <QLocalSocket>
//#include <QLocalServer>
//#include <QTcpSocket>
//#include <QSsl>
//#include <QNetworkConfigurationManager>
//#include <QNetworkAccessManager>
#include <QWidget>
#define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default"
#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/customdhcpcd/src/customdhcpcd"
#define DEFAULT_GATEWAY_INFO_LOCATION "/var/tmp/gateways_"
#define ACK_SIZE 4
class LogReceiver: public QObject {
Q_OBJECT
public:
LogReceiver(QObject *parent=0);
~LogReceiver();
void initAndRun(QString serverPath = DEFAULT_QTSOCKETADDRESS,
QString pathToExe = DEFAULT_PATHTODHCPCDEXE,
QStringList* args = NULL);
private slots:
void handleNewConnection();
void handleNewInput();
void handleNewInputLine(QLocalSocket * client, QString data);
void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void handleProcessStarted();
void handleClientDisconnect();
signals:
void addNewInterface(QString ifName);
void changeProgressBarValue(QString ifName, int newValue);
void connectionEstablished(QString ifName, QString gateway);
void abortBoot(QString msg);
void updateStatusLabel(QString ifName, QString status);
void allProcessesFinished();
private:
QLocalServer *server;
quint16 blockSize;
//QMap<int, QNetworkInterface > interfacesMap;
//QMap<QString, int> indexToIfaceNameMap;
QMap<QLocalSocket *, QLocalSocket *> clients;
QLocalSocket * client;
QMap<QString, QLocalSocket*> ifNameToClient;
QMap<QProcess*, QString> clientProcessToIfNameMap;
QString pathToDhcpcdExe;
QStringList dhcpcdArguments;
QNetworkConfigurationManager configurationManager;
QNetworkAccessManager *accessManager;
int numberOfProcesses;
//const char ack[ACK_SIZE];
void handleNewInput(QLocalSocket * client);
void runDHCPCD(QList<QString> &interfaces);
void runDHCPCD(QString interface);
QList<QString>checkCarrierState(QList<QString> &interfaces);
bool checkCarrierState(QString interface);
void checkInternetConnection(QString ifName);
void checkInternetConnection(QList<QString> &interfaces);
void checkInternetConnectionViaTCP(QString ifName);
void checkConnectivity(QString ifName);
QList<QString> getListOfNetworkInterfaces();
bool checkBlackList(QString i);
};
#endif // LOGRECEIVER_H
|