summaryrefslogtreecommitdiffstats
path: root/LogReceiver/networkmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LogReceiver/networkmanager.cpp')
-rw-r--r--LogReceiver/networkmanager.cpp74
1 files changed, 72 insertions, 2 deletions
diff --git a/LogReceiver/networkmanager.cpp b/LogReceiver/networkmanager.cpp
index 80aa8a1..55fd475 100644
--- a/LogReceiver/networkmanager.cpp
+++ b/LogReceiver/networkmanager.cpp
@@ -87,6 +87,34 @@ int NetworkManager::replaceDefaultRoute(QString ifname, QString gateway,
return retval;
}
+
+/**
+ * The method brings an interface up.
+ *
+ * @param ifname
+ * the name of the interface
+ *
+ * @return
+ * 0 -> success
+ * -1 -> error
+ */
+int NetworkManager::bringInterfaceUP(QString ifname) {
+ return bringInterfaceUpDown(ifname, true);
+}
+
+/**
+ * The method brings an interface down.
+ *
+ * @param ifname
+ * the name of the interface
+ *
+ * @return
+ * 0 -> success
+ * -1 -> error
+ */
+int NetworkManager::bringInterfaceDown(QString ifname) {
+ return bringInterfaceUpDown(ifname, false);
+}
/**
* This method brings an interface up or down.
*
@@ -145,11 +173,42 @@ int NetworkManager::bringInterfaceUpDown(QString ifname, bool up) {
return retval;
}
+/**
+ * This method is used when the manual configuration is needed.
+ *
+ * This method is used when the manual configuration is needed.
+ * First we bring up the interface. Than we configure the interface with
+ * our manual entered configuration dates.
+ * After that we replace the old default route with the new and
+ * write a resolv.conf.
+ *
+ * @param ifname
+ * name of the interface which we are about to configure.
+ *
+ * @param ipAddress
+ * the new IP-Address.
+ *
+ * @param netmask
+ * the netmask of the IP-Address.
+ *
+ * @param broadcast
+ * the broadcast address.
+ * @param gateway
+ * the gateway address.
+ * @param metric
+ * do not exactly know why we need this. in most cases this should be 0.
+ * @param af
+ * the address type. Either AF_INET for IPv4 or AF_INET6 for IPv6.
+ * @param pathToResolvConf
+ * the path to the resolf.conf file. in most cases "/etc/".
+ * @param nameServer
+ * the name server addresses.
+ */
int NetworkManager::ip4_setManualConfiguration(QString ifname, QString ipAddress, QString netmask,
- QString broadcast, QString gateway, int metric, int af, bool up, QString pathToResolvConf, QList<QString> nameServer) {
+ QString broadcast, QString gateway, int metric, int af, QString pathToResolvConf, QList<QString> nameServer) {
//bring the interface up
- bringInterfaceUpDown(ifname, up);
+ bringInterfaceUP(ifname);
//set configuration
ip4_configureInterface(ifname, ipAddress, broadcast, netmask,af);
//set default route
@@ -223,6 +282,17 @@ int NetworkManager::ip4_configureInterface(QString ifname, QString ipAddress,
return retval;
}
+/**
+ * This Method returns the length of the IP-Address netmask prefix.
+ *
+ * @param ipAddr
+ * the IP-address
+ *
+ * @param netmask
+ * the netmask of the IP-address.
+ * @return
+ * the length of the IP-Address netmask prefix
+ */
int NetworkManager::ip4_netmaskToPrefix(QString ipAddr, QString netmask) {
int retval = -1;
QNetworkAddressEntry nae;