00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef QOLYESTER_DAEMON_SET_HNA_HH
00020 # define QOLYESTER_DAEMON_SET_HNA_HH 1
00021
00022 # include <set>
00023 # include "sch/scheduler.hh"
00024 # include "utl/timeval.hh"
00025 # include "utl/set.hh"
00026 # include "net/ipaddress.hh"
00027
00028 namespace olsr {
00029
00030 namespace sch {
00031
00032 class StatePrinter;
00033
00034 }
00035
00036 namespace set {
00037
00038 class HNAEntry {
00039 typedef HNAEntry This;
00040
00041 HNAEntry();
00042 public:
00043 HNAEntry(const address_t& gaddr,
00044 const address_t& naddr,
00045 unsigned prefix,
00046 const timeval_t& v);
00047
00048 virtual ~HNAEntry() {}
00049
00050 const address_t& gw_addr() const { return g_addr_; }
00051 const address_t& net_addr() const { return n_addr_; }
00052 unsigned prefix() const { return prefix_; }
00053 bool is_valid() const;
00054 void set_time(const timeval_t& t);
00055 const timeval_t& time() const { return time_; }
00056
00057 bool operator<(const This& rhs) const;
00058 static This make_key(const address_t& gaddr,
00059 const address_t& naddr,
00060 unsigned prefix);
00061 private:
00062 const address_t g_addr_;
00063 const address_t n_addr_;
00064 const unsigned prefix_;
00065 timeval_t time_;
00066
00067 static This dummy_for_find_;
00068
00069 friend class sch::StatePrinter;
00070 };
00071
00072 class HNASet {
00073 typedef HNASet This;
00074 typedef sch::Updatable<HNAEntry> elem_t;
00075 typedef std::set<elem_t> hset_t;
00076 typedef sch::upd::SetEraser<This, hset_t::iterator> eraser_t;
00077 typedef sch::UpdateEvent<eraser_t> updater_t;
00078
00079 typedef utl::Subset<hset_t,
00080 utl::NoAction<This, hset_t::iterator>,
00081 utl::DefaultPredicate<This, hset_t::iterator>,
00082 This> val_hset_t;
00083 public:
00084 typedef val_hset_t hnaset_t;
00085
00086 hnaset_t& hnaset() { return hnaset_; }
00087
00088 HNASet();
00089
00090 void insert(const HNAEntry& x);
00091 void erase(const hset_t::iterator& pos);
00092 private:
00093 hset_t hset_;
00094 hnaset_t hnaset_;
00095
00096 friend class sch::StatePrinter;
00097 };
00098
00099 }
00100
00101 typedef set::HNASet hnaset_t;
00102
00103 }
00104
00105 # ifndef QOLYESTER_DONTINCLUDE_HXX
00106 # include "hna.hxx"
00107 # endif
00108
00109 #endif // ! QOLYESTER_DAEMON_SET_HNA_HH