00001 // Copyright (C) 2003, 2004, 2005 Laboratoire de Recherche en Informatique 00002 00003 // This file is part of Qolyester. 00004 00005 // Qolyester is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 00010 // Qolyester is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 00019 # include "net/interface.hh" 00020 # include "msg/hna.hh" 00021 00022 #ifndef QOLYESTER_DAEMON_SCH_EVENTS_HH 00023 # define QOLYESTER_DAEMON_SCH_EVENTS_HH 1 00024 00025 # include "msg/hello.hh" 00026 # include "msg/mid.hh" 00027 # include "msg/tc.hh" 00028 # include "pkt/packet.hh" 00029 # include "sch/scheduler.hh" 00030 00031 namespace olsr { 00032 00033 namespace sch { 00034 00035 namespace internal { 00036 00037 template <class M> 00038 struct sender_traits {}; 00039 00040 # define SENDER_TRAITS(Msg, Id) \ 00041 template <> struct sender_traits<msg::Msg ## Message> { \ 00042 static const timeval_t& interval; \ 00043 static const timeval_t in_jitter; \ 00044 static const timeval_t& maxjitter; \ 00045 static const std::string name; \ 00046 } 00047 00048 SENDER_TRAITS(HELLO, hello); 00049 SENDER_TRAITS(TC, tc); 00050 SENDER_TRAITS(MID, mid); 00051 SENDER_TRAITS(HNA, hna); 00052 00053 # undef SENDER_TRAITS 00054 00055 } // namespace internal 00056 00057 template <class M> 00058 class MessageSender : public JitteredEvent { 00059 typedef MessageSender<M> This; 00060 typedef JitteredEvent Super; 00061 public: 00062 MessageSender(); 00063 virtual void handle(); 00064 }; 00065 00066 template <> 00067 class MessageSender<msg::TCMessage> : public JitteredEvent { 00068 typedef MessageSender<msg::TCMessage> This; 00069 typedef JitteredEvent Super; 00070 public: 00071 MessageSender(); 00072 virtual void handle(); 00073 }; 00074 00075 class MessageForwarder : public TimedEvent { 00076 typedef MessageForwarder This; 00077 typedef TimedEvent Super; 00078 MessageForwarder(const This&); 00079 public: 00080 MessageForwarder(const timeval_t& n, const msg::UnknownMessage& m); 00081 ~MessageForwarder(); 00082 virtual void handle(); 00083 private: 00084 msg::UnknownMessage* message_; 00085 }; 00086 00087 class StatePrinter : public PeriodicEvent { 00088 typedef StatePrinter This; 00089 typedef PeriodicEvent Super; 00090 public: 00091 StatePrinter(); 00092 virtual void handle(); 00093 }; 00094 00095 class PacketSender : public IOEvent { 00096 typedef PacketSender This; 00097 typedef IOEvent Super; 00098 public: 00099 PacketSender(iface_t* i, const pkt::Packet& p); 00100 virtual void handle(); 00101 private: 00102 iface_t* iface_; 00103 pkt::Packet packet_; 00104 }; 00105 00106 class PacketReceiver : public IOEvent { 00107 typedef PacketReceiver This; 00108 typedef IOEvent Super; 00109 public: 00110 PacketReceiver(iface_t* i); 00111 virtual void handle(); 00112 private: 00113 iface_t* iface_; 00114 }; 00115 00116 class QolyesterLoopHandler : public LoopHandler { 00117 typedef QolyesterLoopHandler This; 00118 typedef LoopHandler Super; 00119 public: 00120 virtual bool operator()() const; 00121 private: 00122 }; 00123 00124 void remove_routes(); 00125 00126 } // namespace sch 00127 00128 } // namespace olsr 00129 00130 # ifndef QOLYESTER_DONTINCLUDE_HXX 00131 # include "events.hxx" 00132 # endif 00133 00134 #endif // !QOLYESTER_DAEMON_SCH_EVENTS_HH