00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _PROPHET_CONTROLLER_H_
00018 #define _PROPHET_CONTROLLER_H_
00019
00020 #include <string>
00021 #include <list>
00022
00023 #include "Link.h"
00024 #include "Bundle.h"
00025 #include "Alarm.h"
00026 #include "Oracle.h"
00027 #include "BundleCore.h"
00028 #include "Encounter.h"
00029
00030 namespace prophet
00031 {
00032
00033 class Controller : public Oracle,
00034 public ExpirationHandler
00035 {
00036 public:
00037 typedef std::list<Encounter*> List;
00038
00042 Controller(BundleCore* core, Repository* repository,
00043 ProphetParams* params);
00044
00048 virtual ~Controller();
00049
00053 void new_neighbor(const Link* link);
00054
00058 void neighbor_gone(const Link* link);
00059
00063 bool accept_bundle(const Bundle* bundle);
00064
00068 void handle_bundle_received(const Bundle* b, const Link* link);
00069
00073 void handle_bundle_transmitted(const Bundle* b, const Link* link);
00074
00078 void ack(const Bundle* b);
00079
00083 void set_queue_policy();
00084
00089 void set_hello_interval();
00090
00095 void set_max_route();
00096
00100 void shutdown();
00101
00103 const ProphetParams* params() const { return params_; }
00104 Stats* stats() { return &stats_; }
00105 Table* nodes() { return &nodes_; }
00106 AckList* acks() { return &acks_; }
00107 BundleCore* core() { return core_; }
00109
00111 const List::const_iterator begin() const { return list_.begin(); }
00112 const List::const_iterator end() const { return list_.end(); }
00114
00116 size_t size() { return list_.size(); }
00117 bool empty() { return list_.empty(); }
00119
00123 void handle_timeout();
00124
00125 protected:
00126
00130 bool find(const Link* link, List::iterator& i);
00131
00135 bool is_prophet_control(const Bundle* b) const;
00136
00137 BundleCore* core_;
00138 ProphetParams* params_;
00139 Stats stats_;
00140 u_int max_route_;
00141 Table nodes_;
00142 AckList acks_;
00143 u_int16_t next_instance_;
00144
00145 Alarm* alarm_;
00146 u_int timeout_;
00147
00148 Repository* repository_;
00149 List list_;
00150 };
00151
00152 };
00153
00154 #endif // _PROPHET_CONTROLLER_H_