00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "config.hh"
00021
00022 #ifndef QOLYESTER_ENABLE_VIRTUAL
00023
00024 # ifndef QOLYESTER_DAEMON_SYS_LINUX_ROUTINGSOCKET_HH
00025 # define QOLYESTER_DAEMON_SYS_LINUX_ROUTINGSOCKET_HH 1
00026
00027 # include "net/ipaddress.hh"
00028 # include "sys/linux/interfacedesc.hh"
00029 # include "sys/linux/netlink.hh"
00030
00031 namespace olsr {
00032
00033 namespace sys {
00034
00035 class RealInterfaceInfo;
00036
00037 # ifdef DEBUG
00038
00039 namespace netlink {
00040
00041 class RoutingTableVisitor : public DefaultVisitor {
00042 typedef RoutingTableVisitor This;
00043 public:
00044 RoutingTableVisitor(std::ostream& os);
00045 virtual ~RoutingTableVisitor();
00046
00047 virtual void visit(const NLError& e);
00048 virtual void visit(const NLNewRoute& e);
00049 virtual void visit(const NLRouteAttrDestination& e);
00050 virtual void visit(const NLRouteAttrGateway& e);
00051 virtual void visit(const NLRouteAttrOutInterface& e);
00052 private:
00053 std::ostream& os_;
00054 address_t dst_;
00055 address_t via_;
00056 bool is_via_;
00057 unsigned index_;
00058 bool is_index_;
00059 };
00060
00061 }
00062
00063 # endif // !DEBUG
00064
00065 namespace internal {
00066
00067 class RoutingSocket {
00068 public:
00069 void print_kernel_routes();
00070 void remove_old_routes();
00071 void add_local_route(const address_t& d, unsigned p,
00072 const sys::RealInterfaceInfo& i);
00073 void add_remote_route(const address_t& d, unsigned p,
00074 const address_t& n);
00075 void remove_local_route(const address_t& d, unsigned p,
00076 const sys::RealInterfaceInfo& i);
00077 void remove_remote_route(const address_t& d, unsigned p,
00078 const address_t& n);
00079 void add_addr(unsigned i, const InterfaceAddress& a);
00080 void del_addr(unsigned i, const InterfaceAddress& a);
00081 private:
00082 netlink::NLSocket _s;
00083 };
00084
00085 }
00086
00087 }
00088
00089 }
00090
00091 # include "routingsocket.hxx"
00092
00093 # endif // ! QOLYESTER_DAEMON_SYS_LINUX_ROUTINGSOCKET_HH
00094
00095 #endif // ! QOLYESTER_ENABLE_VIRTUAL