00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00028
00029 #include "config.hh"
00030
00031 #ifndef QOLYESTER_ENABLE_VIRTUAL
00032
00033
00034 # include "sys/realinterfaceinfo.hh"
00035 # include "pkt/packet.hh"
00036
00037 # ifndef QOLYESTER_DAEMON_NET_REALINTERFACE_HH
00038 # define QOLYESTER_DAEMON_NET_REALINTERFACE_HH 1
00039
00040 # include <set>
00041
00042 # include "net/ipaddress.hh"
00043 # include "sch/scheduler.hh"
00044 # include "sys/socket.hh"
00045 # include "utl/stampable.hh"
00046
00047 namespace olsr {
00048
00049 namespace net {
00050
00055 class RealInterface : public utl::MultiStampable<1, address_t> {
00056 typedef RealInterface This;
00057 typedef utl::MultiStampable<1, address_t> Super;
00058 typedef std::set<sch::IOEvent*> events_t;
00065 explicit RealInterface();
00066 public:
00067
00072 RealInterface(const sys::RealInterfaceInfo& info);
00073
00074 RealInterface(const sys::RealInterfaceInfo& info, const address_t& addr);
00075
00079 RealInterface(const This& other);
00080
00084 ~RealInterface();
00085
00090 const address_t& addr() const { return addr_; }
00091
00096 unsigned mtu() const;
00097
00098 unsigned prefix() const { return prefix_; }
00099
00100 sch::IOEvent::p_t recv_p() const;
00101
00102 sch::IOEvent::p_t send_p() const;
00103
00104 void insert_event(sch::IOEvent* e);
00105 void erase_event(sch::IOEvent* e);
00106
00107 void destroy_all_events();
00108
00113 const sys::RealInterfaceInfo& info() const { return info_; }
00114
00119 pkt::Packet receive() const;
00120
00125 void send(const pkt::Packet& p) const;
00126
00131 bool operator<(const This& rhs) const;
00132
00138 static This& make_key(const address_t& a);
00139
00140 inline void configure();
00141 inline void unconfigure();
00142 private:
00143
00144 const sys::RealInterfaceInfo info_;
00145 const address_t addr_;
00146 unsigned prefix_;
00147 # ifdef QOLYESTER_TWO_SOCKETS
00148 sys::Socket insock_;
00149 sys::Socket outsock_;
00150 # else // !QOLYESTER_TWO_SOCKETS
00151 sys::Socket sock_;
00152 # endif
00153
00154 events_t events_;
00155 unsigned* usecount_;
00156 sys::RealInterfaceInfo::config_t* config_;
00157
00158 static This dummy_for_find_;
00159 };
00160
00161 }
00162
00163 }
00164
00165 # ifndef QOLYESTER_DONTINCLUDE_HXX
00166 # include "realinterface.hxx"
00167 # endif
00168
00169 # endif // ! QOLYESTER_DAEMON_NET_REALINTERFACE_HH
00170
00171 #endif // ! QOLYESTER_ENABLE_VIRTUAL