00001 /* 00002 * Copyright 2005-2006 Intel Corporation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef _TABLE_BASED_ROUTER_H_ 00018 #define _TABLE_BASED_ROUTER_H_ 00019 00020 #include "BundleRouter.h" 00021 00022 namespace dtn { 00023 00024 class RouteTable; 00025 00030 class TableBasedRouter : public BundleRouter { 00031 protected: 00036 TableBasedRouter(const char* classname, const std::string& name); 00037 00041 virtual ~TableBasedRouter(); 00042 00048 virtual void handle_event(BundleEvent* event); 00049 00054 virtual void handle_bundle_received(BundleReceivedEvent* event); 00055 00059 virtual void handle_bundle_transmit_failed(BundleTransmitFailedEvent* event); 00060 00068 virtual void handle_route_add(RouteAddEvent* event); 00069 00074 virtual void handle_route_del(RouteDelEvent* event); 00075 00080 virtual void handle_contact_up(ContactUpEvent* event); 00081 00085 virtual void handle_link_available(LinkAvailableEvent* event); 00086 00090 virtual void handle_link_created(LinkCreatedEvent* event); 00091 00095 virtual void handle_custody_timeout(CustodyTimeoutEvent* event); 00096 00100 void get_routing_state(oasys::StringBuffer* buf); 00101 00105 void add_route(RouteEntry *entry); 00106 00110 void del_route(const EndpointIDPattern& id); 00111 00115 virtual void fwd_to_nexthop(Bundle* bundle, RouteEntry* route); 00116 00124 virtual bool should_fwd(const Bundle* bundle, RouteEntry* route); 00125 00137 virtual int fwd_to_matching(Bundle* bundle, Link* this_link_only = NULL); 00138 00147 virtual void check_next_hop(Link* next_hop); 00148 00150 RouteTable* route_table_; 00151 }; 00152 00153 } // namespace dtn 00154 00155 #endif /* _TABLE_BASED_ROUTER_H_ */