ndgui/NetworkDiscovery

NetworkDiscovery Class Reference

the logic behind the NetworkDiscovery. More...

#include <networkdiscovery.h>

Collaboration diagram for NetworkDiscovery:

List of all members.

Public Slots

void handleNewConnection ()
void handleNewInput ()
void handleNewInputLine (QLocalSocket *client, QString data)
void handleProcessFinished (int exitCode, QProcess::ExitStatus exitStatus)
void handleProcessStarted ()
void handleClientDisconnect ()
void slotReadyForRun ()
void checkForIsRunning ()

Signals

void addInterface (const QString &ifName)
void changeProgressBarValue (const QString &ifName, const int $newValue)
void connectionEstablished (QString ifName)
void abortBoot (QString msg)
void updateIfStatus (QString ifName, QString status)
void updateStatus (QString status)
void allProcessesFinished ()
void continueBoot (QString ifName)
void continueBootWithoutCheck (QString ifName)
void setManualConfInterfaces (QString jsonArr)
void readyForRun ()

Public Member Functions

 NetworkDiscovery (QObject *parent=0)
 ~NetworkDiscovery ()
void initAndRun (QString serverIp, bool userChoice, bool autoUp, QString pathToLogFile, QString serverPath=DEFAULT_QTSOCKETADDRESS, QString pathToExe=DEFAULT_PATHTODHCPCDEXE, QStringList *args=NULL)
int ip4_replaceDefaultRoute (QString ifName, QString gateway, int mss)
QString getGatewayForInterface (QString ifName)
int ip4_setManualConfiguration (QVariantMap result)
QString readLogFile ()
void tryAgain ()
void prepareTryAgain ()
bool checkConnectivity (QString ifName)
bool checkConnectivityViaTcp ()
QVariantMap getInterfaceConfig (QString ifName)
QString GetErrorStr ()

Detailed Description

the logic behind the NetworkDiscovery.

This class holds all the logic of the NetworkDiscovery. It's main task is to search for usable interfaces, check if they are wired (in Running state) and start a cdhcpcd process for each interface. It also sends signals to the ndgui class for presenting notifications to the user.


Constructor & Destructor Documentation

NetworkDiscovery::NetworkDiscovery ( QObject *  parent = 0)

constructor

NetworkDiscovery::~NetworkDiscovery ( )

destructor


Member Function Documentation

void NetworkDiscovery::abortBoot ( QString  msg) [signal]

Here is the caller graph for this function:

void NetworkDiscovery::addInterface ( const QString &  ifName) [signal]

Here is the caller graph for this function:

void NetworkDiscovery::allProcessesFinished ( ) [signal]

Here is the caller graph for this function:

void NetworkDiscovery::changeProgressBarValue ( const QString &  ifName,
const int $  newValue 
) [signal]

Here is the caller graph for this function:

bool NetworkDiscovery::checkConnectivity ( QString  ifName)

checks the connectivity. tries to open a TCP connection to the server (see _serverIp). For this it adjusts the routing table. (sets the gateway of the interface as default gateway) Gateway is written into the dhcpcd config file of this interface. (see DEFAULT_INTERFACE_CONF_LOCATION "/var/tmp/conf_")

Parameters:
ifNamename of a interface.
Returns:
true: connection is possible false: connection not possible

Here is the call graph for this function:

Here is the caller graph for this function:

bool NetworkDiscovery::checkConnectivityViaTcp ( )

Here is the caller graph for this function:

void NetworkDiscovery::checkForIsRunning ( ) [slot]

only called if autoUp == true. check the IsRunning flag of each interface in the _ifDownList. connected to the timeout signal of the timer.

Here is the call graph for this function:

void NetworkDiscovery::connectionEstablished ( QString  ifName) [signal]

Here is the caller graph for this function:

void NetworkDiscovery::continueBoot ( QString  ifName) [signal]
void NetworkDiscovery::continueBootWithoutCheck ( QString  ifName) [signal]

Here is the caller graph for this function:

QString NetworkDiscovery::GetErrorStr ( )

Here is the caller graph for this function:

QString NetworkDiscovery::getGatewayForInterface ( QString  ifName)

returns the gateway address, written into the dhcp config file.

Parameters:
ifNamename of the interface.
Returns:
gateway address as string. or empty string if no interface config was found.

Here is the call graph for this function:

QVariantMap NetworkDiscovery::getInterfaceConfig ( QString  ifName)

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::handleClientDisconnect ( ) [slot]

called when a client disconnects.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::handleNewConnection ( ) [slot]

connected to the new client arrived signal. connects the client readyRead signal with the handleNewInput slot.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::handleNewInput ( ) [slot]

This method is connected to the readyRead Signal of the QLocalSocket client. send an ACK to the client with every received message.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::handleNewInputLine ( QLocalSocket *  client,
QString  data 
) [slot]

This Method processes the send messages.

This Method processes the send messages. It splits the line into several components. Those components are: interface: interface name ==> indicates the process who send the message s_state: is the number representation of syslog.h LOG levels s_subState: is the number representation of the dhcp.c DHCP states (1 - 8) plus the status. h states (9 - ..) msg: is a message which can contain additional informations

According to the s_state and s_subState we emit the changeProgressBarValue() signal with different values.

Parameters:
clientthe client who send the message
datathe message. (format <interfaceName>;<state>;<subState>;<msg> )

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::handleProcessFinished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
) [slot]

This Method is called when a process is finished.

This Method is called when a process is finished. This slot is connected with the signal finished() of the QProcess class. If the process finishes, it will be checked if the process exited normal or if an unexpected error occurred. For this, we determine the sender (which is a QProcess), get the corresponding interface (which is stored in a map), and check the exitCode. Further actions are taken according to the exitCode check. Normal exit: emit changeProgressBar() to 100% emit updateIfStatus() to check connection checkConnectivity()

See also:
NetworkDiscovery::checkConnectivity() Unexpected exit: emit updateIfStatus() to process exited unexpected
Parameters:
exitCode
exitStatus
Returns:
bool returns true: if the interface name i starts with a letter in the blacklist.

returns false: else

See also:
NetworkDiscovery::getListOfNetworkInterfaces()

Here is the call graph for this function:

void NetworkDiscovery::handleProcessStarted ( ) [slot]

This Method is called when a process is started.

This Method is called when a process is started. It prints the message: "process started for interface: <interfaceName>".

void NetworkDiscovery::initAndRun ( QString  serverIp,
bool  userChoice,
bool  autoUp,
QString  pathToLogFile,
QString  serverPath = DEFAULT_QTSOCKETADDRESS,
QString  pathToExe = DEFAULT_PATHTODHCPCDEXE,
QStringList *  args = NULL 
)

initialize all important class members and start the main work.

Parameters:
serverIpthe ip of the server with which we are testing the connectivity.
userChoicetrue if the user wishes to have a user choice. true: the chooseInterfaceDialog will be showed.
autoUptrue if we want to "auto Up" all down interfaces.
pathToLogFilethe path to the log file.
serverPaththe path to the server socket (default value: DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default")
pathToExethe path to the customdhcpcd exe. (default value: #define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default")
argsadditional arguments for the customdhcpcd client. (default value: NULL)

Here is the call graph for this function:

Here is the caller graph for this function:

int NetworkDiscovery::ip4_replaceDefaultRoute ( QString  ifName,
QString  gateway,
int  mss 
)

replace the default route. sets af automatically to AF_INET

Parameters:
ifNameinterface name
gatewaygateway address
mssmss value (i think this is the metric. in most cases this value is 0)

Here is the call graph for this function:

int NetworkDiscovery::ip4_setManualConfiguration ( QVariantMap  result)

replace the dhcp configuration with the manual config, entered by the user. if we can not establish a connection with the entered values, reset to the old dhcp values.

Parameters:
resulta json object formated string.
Returns:
0 if everything ok

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::prepareTryAgain ( )

Here is the caller graph for this function:

QString NetworkDiscovery::readLogFile ( )

reads the log file.

Returns:
the log file as one string.

Here is the caller graph for this function:

void NetworkDiscovery::readyForRun ( ) [signal]

Here is the caller graph for this function:

void NetworkDiscovery::setManualConfInterfaces ( QString  jsonArr) [signal]
void NetworkDiscovery::slotReadyForRun ( ) [slot]

emits the addInterface signal for each interface name in _ifUpList and calls the runDHCPCD method. if the _ifUpList is empty, this method emits an abortBoot signal. connected to the readyForRun signal.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkDiscovery::tryAgain ( )

Here is the call graph for this function:

void NetworkDiscovery::updateIfStatus ( QString  ifName,
QString  status 
) [signal]

Here is the caller graph for this function:

void NetworkDiscovery::updateStatus ( QString  status) [signal]

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines