From 46da51f8701747376999dcca8f034e41eeb206e0 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 29 Sep 2011 14:24:48 +0200 Subject: did some refactoring. added a user choice screen which is shown 2 seconds before the magic begins. (press F5 to get a choice) --- LogReceiver/networkmanager.cpp | 74 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'LogReceiver/networkmanager.cpp') 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 nameServer) { + QString broadcast, QString gateway, int metric, int af, QString pathToResolvConf, QList 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; -- cgit v1.2.3-55-g7522