00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _TCA_ROUTER_H_
00019 #define _TCA_ROUTER_H_
00020
00021 #include "naming/EndpointID.h"
00022 #include "TableBasedRouter.h"
00023
00024 #define SERVLIB 1
00025
00026 #include "TcaEndpointID.h"
00027 #include "TcaControlBundle.h"
00028
00029
00030 namespace dtn {
00031
00032
00049 class TcaRouter : public TableBasedRouter {
00050
00051 public:
00052
00053 enum Role { TCA_MOBILE, TCA_ROUTER, TCA_GATEWAY };
00054
00055
00056
00057
00058 enum ForwardingRule {
00059 FWD_NEVER,
00060 FWD_UDR_EXCLUSIVELY,
00061 FWD_UDR_NEVER,
00062 FWD_UDR_IFNECESSARY,
00063
00064 FWD_UDR_ALWAYS
00065 };
00066
00067 TcaRouter(Role role);
00068
00069 protected:
00070
00071 Role role_;
00072
00073 TcaEndpointID admin_app_;
00074
00075 std::string get_role_str() const;
00076
00077
00078 virtual void handle_bundle_received(BundleReceivedEvent* event);
00079 virtual void handle_bundle_transmitted(BundleTransmittedEvent* event);
00080 virtual void handle_contact_up(ContactUpEvent* event);
00081 virtual void handle_contact_down(ContactDownEvent* event);
00082 virtual void handle_link_available(LinkAvailableEvent* event);
00083 virtual void handle_link_unavailable(LinkUnavailableEvent* event);
00084 virtual void handle_shutdown_request(ShutdownRequest* event);
00085
00086
00087 virtual int fwd_to_all(Bundle* bundle);
00088
00089
00090 virtual int fwd_to_matching(Bundle* bundle, Link* next_hop = NULL);
00091
00092
00093
00094 virtual int fwd_to_matching_r(Bundle* bundle, Link* next_hop,
00095 ForwardingRule fwd_rule);
00096
00097 bool on_coa_transmitted(Bundle* b, const TcaControlBundle& cb);
00098 bool on_ask_transmitted(Bundle* b, const TcaControlBundle& cb);
00099 bool on_adv_transmitted(Bundle* b, const TcaControlBundle& cb);
00100
00101
00102 bool handle_register(Bundle* b);
00103 bool handle_coa(Bundle* b);
00104
00105
00106 bool handle_anonymous_bundle(Bundle* b);
00107
00108 bool handle_ask(Bundle* b, const TcaControlBundle& cb);
00109
00110
00111 bool handle_bl_control_bundle(Bundle* b);
00112
00113 bool handle_bl_ask(Bundle* b, const TcaControlBundle& cb);
00114 bool handle_get_routes(Bundle* b, const TcaControlBundle& cb);
00115 bool handle_add_route(Bundle* b, const TcaControlBundle& cb);
00116 bool handle_del_route(Bundle* b, const TcaControlBundle& cb);
00117
00118
00119 bool handle_tca_unbound_bundle(Bundle* bundle);
00120
00121 bool on_route_unbound_bundle(Bundle* bundle);
00122 bool on_gate_unbound_bundle(Bundle* bundle);
00123
00124
00125 bool is_local_source(Bundle* b);
00126
00127 ForwardingRule get_forwarding_rule(Bundle* b);
00128
00129
00130 Link* create_link(const std::string& link_addr);
00131
00132
00133 RouteEntry* create_route(const std::string& pattern, Link* p_link);
00134
00135
00136
00137 bool create_route(const std::string& pattern,
00138 const std::string& link_addr);
00139
00140
00141
00142
00143 bool post_bundle(const EndpointID& src, const EndpointID& dest,
00144 const std::string& payload);
00145
00146
00147
00148 bool push_wrapped_bundle(const std::string& code,
00149 const EndpointID& src,
00150 const EndpointID& dest,
00151 const std::string& bsp);
00152
00153 };
00154
00155 }
00156
00157 #endif