summaryrefslogblamecommitdiffstats
path: root/src/fbgui/networkmanager.h
blob: 2ef6ff8b4f1855117d4dfffc8b214cabe7e9dbb1 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                                            
  






                                                                          

   

 















                                   


                                    

       

                            
 

                                                                        
 

                                         
 



                                                                                                                                              
 



                                                                            
 
                                                                               

        


                                                           
 

                                                              
 



                                                                                
 



                              
/**
 * Copyright (c) 2010,2011 - RZ Uni Freiburg
 * Copyright (c) 2010,2011 - OpenSLX Project
 *
 * This program/file is free software distributed under the GPL version 2.
 * See http://openslx.org/COPYING
 *
 * If you have any feedback please consult http://openslx.org/feedback and
 * send your feedback to feedback@openslx.org
 *
 * General information about OpenSLX can be found under http://openslx.org
 */



#ifndef NETWORKMANAGER_H_
#define NETWORKMANAGER_H_

#include <arpa/inet.h>
#include <net/if.h>
#include <netlink/netlink.h>
#include <netlink/netlink-kernel.h>
#include <netlink/route/addr.h>
#include <netlink/route/rtnl.h>
#include <netlink/route/route.h>
#include <netlink/route/link.h>

#include <errno.h>
#include <QtCore>
#include <QNetworkAddressEntry>

class NetworkManager: public QObject
{
  Q_OBJECT

public:
  NetworkManager();
  virtual ~NetworkManager();

  int	replaceDefaultRoute(QString ifname, QString gateway, int metric,
                          int af);

  int bringInterfaceUP(QString ifname);
  int bringInterfaceDown(QString ifname);

  int ip4_setManualConfiguration(QString ifname, QString ipAddress, QString netmask,
                                 QString broadcast, QString gateway, int metric, int af, QString pathToResolvConf, QList<QString> nameServer);
  int ip4_configureInterface(QString ifname, QString ipAddress,
                             QString broadcast, QString netmask, int af);

  int ip6_addRoute(const char *iface,
                   const struct in6_addr *ip6_dest, int ip6_prefix,
                   const struct in6_addr *ip6_gateway, int metric, int mss);
  int ip6_addAddress(struct ip6_addr* ip6Addr, const char *iface);

  int writeResolvConf(QString path, QString ifname, QList<QString> nameServer);

private:
  QString _tag;
  int bringInterfaceUpDown(QString ifname, bool up);
  int ip4_netmaskToPrefix(QString ipAddr, QString netmask);

  int sync_address(const char *iface, int ifindex, int family,
                   struct rtnl_addr *addr);

  struct rtnl_route* create_route (int iface_idx, int mss);
  struct nl_addr* ip6AddrToNlAddr (const struct ip6_addr* ip6Addr);
  int nlAddrToRtnlAddr (const struct ip6_addr* ip6Addr, struct rtnl_addr* addr);
  struct rtnl_addr* ip6AddrToRtnlAddr(struct ip6_addr* ip6Addr);


};

#endif /* NETWORKMANAGER_H_ */