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 virtual int fwd_to_matching(Bundle* bundle, const LinkRef& next_hop);
00090 virtual int fwd_to_matching(Bundle* bundle) {
00091 LinkRef link("TcaRouter::fwd_to_matching: null");
00092 return fwd_to_matching(bundle, link);
00093 }
00094
00095
00096
00097 virtual int fwd_to_matching_r(Bundle* bundle, const LinkRef& next_hop,
00098 ForwardingRule fwd_rule);
00099
00100 bool on_coa_transmitted(Bundle* b, const TcaControlBundle& cb);
00101 bool on_ask_transmitted(Bundle* b, const TcaControlBundle& cb);
00102 bool on_adv_transmitted(Bundle* b, const TcaControlBundle& cb);
00103
00104
00105 bool handle_register(Bundle* b);
00106 bool handle_coa(Bundle* b);
00107
00108
00109 bool handle_anonymous_bundle(Bundle* b);
00110
00111 bool handle_ask(Bundle* b, const TcaControlBundle& cb);
00112
00113
00114 bool handle_bl_control_bundle(Bundle* b);
00115
00116 bool handle_bl_ask(Bundle* b, const TcaControlBundle& cb);
00117 bool handle_get_routes(Bundle* b, const TcaControlBundle& cb);
00118 bool handle_add_route(Bundle* b, const TcaControlBundle& cb);
00119 bool handle_del_route(Bundle* b, const TcaControlBundle& cb);
00120
00121
00122 bool handle_tca_unbound_bundle(Bundle* bundle);
00123
00124 bool on_route_unbound_bundle(Bundle* bundle);
00125 bool on_gate_unbound_bundle(Bundle* bundle);
00126
00127
00128 bool is_local_source(Bundle* b);
00129
00130 ForwardingRule get_forwarding_rule(Bundle* b);
00131
00132
00133 LinkRef create_link(const std::string& link_addr);
00134
00135
00136 RouteEntry* create_route(const std::string& pattern, const LinkRef& p_link);
00137
00138
00139
00140 bool create_route(const std::string& pattern,
00141 const std::string& link_addr);
00142
00143
00144
00145
00146 bool post_bundle(const EndpointID& src, const EndpointID& dest,
00147 const std::string& payload);
00148
00149
00150
00151 bool push_wrapped_bundle(const std::string& code,
00152 const EndpointID& src,
00153 const EndpointID& dest,
00154 const std::string& bsp);
00155
00156 };
00157
00158 }
00159
00160 #endif