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