summaryrefslogtreecommitdiffstats
path: root/LogReceiver/routemanager.cpp
diff options
context:
space:
mode:
authorNiklas2011-09-26 12:15:40 +0200
committerNiklas2011-09-26 12:15:40 +0200
commit5a76512a347f5e728e6c0fa2c34fbd9b46645208 (patch)
treec958e9cf6467a476daa050403eadf433f428c8a8 /LogReceiver/routemanager.cpp
parentadded some comments to the new bringInterfaceUpDown function in routemanager(... (diff)
downloadfbgui-5a76512a347f5e728e6c0fa2c34fbd9b46645208.tar.gz
fbgui-5a76512a347f5e728e6c0fa2c34fbd9b46645208.tar.xz
fbgui-5a76512a347f5e728e6c0fa2c34fbd9b46645208.zip
renamed routemanager to networkmanager
Diffstat (limited to 'LogReceiver/routemanager.cpp')
-rw-r--r--LogReceiver/routemanager.cpp177
1 files changed, 0 insertions, 177 deletions
diff --git a/LogReceiver/routemanager.cpp b/LogReceiver/routemanager.cpp
deleted file mode 100644
index aa12fa3..0000000
--- a/LogReceiver/routemanager.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * routemanager.cpp
- *
- * Created on: Sep 5, 2011
- * Author: niklas
- */
-
-#include "routemanager.h"
-
-routemanager::routemanager() {
- // TODO Auto-generated constructor stub
-
-}
-
-routemanager::~routemanager() {
- // TODO Auto-generated destructor stub
-}
-
-/**
- * This method adds /replaces the default route.
- * This method adds /replaces the default route.
- * To keep it modular, it is possible
- * to specify an ip address family.
- *
- * @param ifName
- * the interface name
- *
- * @param gateway
- * the gateway address (e.g: 192.168.0.254)
- * @param mss
- * the mss.
- * @param af
- * specify the family type of the ip address.
- * possible values are: AF_INET for an IPv4 address
- * AF_INET6 for an IPv6 address
- *
-
- * @return
- * return -1 if an error happened.
- * return 0 if everything was ok.
- */
-int routemanager::replaceDefaultRoute(QString ifname, QString gateway,
- int mss, int af) {
- struct nl_cache *cache;
- struct nl_handle* rtsock;
- struct nl_addr * gw;
- struct rtnl_route * route;
- int retval, iface_idx;
-
- QByteArray ba_ifn = ifname.toAscii();
- char * ifn = ba_ifn.data();
-
- QByteArray ba_gw = gateway.toAscii();
- char * gwaddr = ba_gw.data();
-
- qDebug() << "---doRoute() gwaddr" << gwaddr;
-
- if (!(gw = nl_addr_parse(gwaddr, af))) {
- qDebug() << "Invalid router address given: %s\n", gwaddr;
- return -1;
- }
-
- rtsock = nl_handle_alloc();
- nl_connect(rtsock, NETLINK_ROUTE);
-
- if ((cache = rtnl_link_alloc_cache(rtsock)) == NULL) {
- qDebug() << "error with link cache alloc \n";
- }
-
- iface_idx = rtnl_link_name2i(cache, ifn);
-
- route = rtnl_route_alloc();
- rtnl_route_set_scope(route, RT_SCOPE_UNIVERSE);
- rtnl_route_set_gateway(route, gw);
- rtnl_route_set_oif(route, iface_idx);
-
- if (mss > 0) {
- rtnl_route_set_metric(route, RTAX_ADVMSS, mss);
- }
-
- retval = rtnl_route_add(rtsock, route, NLM_F_REPLACE);
- qDebug() << "return value:" << retval << ":" << strerror(-retval);
-
- rtnl_route_put(route);
- nl_addr_put(gw);
- nl_handle_destroy(rtsock);
-
- return retval;
-}
-/**
- * This method brings an interface up or down.
- *
- * @param ifname
- * is a string which contains the interface name which is going down or up.
- *
- * @param up
- * is a bool. true means. we bring the interface up.
- * false meand. we bring the interface down.
- * @return
- * 0 if everything is ok
- * else an error
- */
-int routemanager::bringInterfaceUpDown(QString ifname, bool up) {
- struct nl_cache *cache;
- struct nl_handle* rtsock;
- struct rtnl_link* request = NULL;
- struct rtnl_link* old = NULL;
- int retval;
-
- QByteArray ba_ifn = ifname.toAscii();
- char * ifn = ba_ifn.data();
-
- if(!(request = rtnl_link_alloc())) {
- qDebug() << "error. couldn't allocate a rtnl link";
- return -1;
- }
-
- rtsock = nl_handle_alloc();
- nl_connect(rtsock, NETLINK_ROUTE);
-
- if(up) {
- rtnl_link_set_flags(request,IFF_UP);
- } else {
- rtnl_link_unset_flags(request, IFF_UP);
- }
-
- if ((cache = rtnl_link_alloc_cache(rtsock)) == NULL) {
- qDebug() << "error with link cache alloc ";
- }
-
- old = rtnl_link_get_by_name(cache,ifn);
- if (old) {
- qDebug() << "change link";
- rtnl_link_change(rtsock, old, request, 0);
- } else {
- qDebug() << "change failed";
- }
-
- retval = 0;
-
- rtnl_link_put(old);
- rtnl_link_put(request);
- nl_handle_destroy(rtsock);
-
- return retval;
-}
-
-/**
- * This method adds or deletes a route.
- * This method adds or deletes a route. According to the action,
- * you can delete a route or add a route from/to the
- * main routing table. In most cases, this method will be used for deleting
- * or adding a default rout. To keep it modular, it is possible
- * to specify an ip address family.
- *
- * @param ifName
- * the interface name.
- * @param destination
- * the destination address (e.g: 0.0.0.0)
- *
- * @param gateway
- * the gateway address (e.g: 192.168.0.254)
- *
- * @param af
- * specify the family type of the ip address.
- * possible values are: AF_INET for an IPv4 address
- * AF_INET6 for an IPv6 address
- *
- * @param action
- * possible values are: 0: perform add route
- * 1: perform delete route
- *
- * @return
- * return 1 if an error happened.
- * return 0 if everything was ok.
- */
-int routemanager::doRoute(QString ifName, QString destination, QString gateway, int af, int action) {return 0;}