00001 /* 00002 * Copyright 2004-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 _BUNDLE_ROUTER_H_ 00018 #define _BUNDLE_ROUTER_H_ 00019 00020 #include <vector> 00021 #include <oasys/debug/Logger.h> 00022 #include <oasys/thread/Thread.h> 00023 #include <oasys/util/StringUtils.h> 00024 00025 #include "bundling/BundleEvent.h" 00026 #include "bundling/BundleEventHandler.h" 00027 #include "naming/EndpointID.h" 00028 00029 namespace dtn { 00030 00031 class BundleActions; 00032 class BundleRouter; 00033 class StringBuffer; 00034 00038 typedef std::vector<BundleRouter*> BundleRouterList; 00039 00060 class BundleRouter : public BundleEventHandler { 00061 public: 00066 static BundleRouter* create_router(const char* type); 00067 00072 static struct Config { 00073 Config(); 00074 00076 std::string type_; 00077 00080 bool add_nexthop_routes_; 00081 00084 bool open_discovered_links_; 00085 00087 int default_priority_; 00088 00091 int max_route_to_chain_; 00092 00094 u_int64_t storage_quota_; 00095 00098 u_int subscription_timeout_; 00099 00100 } config_; 00101 00105 virtual ~BundleRouter(); 00106 00107 /* 00108 * called after all the global data structures are set up 00109 */ 00110 virtual void initialize(); 00111 00116 virtual void handle_event(BundleEvent* event) = 0; 00117 00128 virtual bool accept_bundle(Bundle* bundle, int* errp); 00129 00137 virtual bool can_delete_bundle(const BundleRef& bundle); 00138 00144 virtual void delete_bundle(const BundleRef& bundle); 00145 00149 virtual void get_routing_state(oasys::StringBuffer* buf) = 0; 00150 00158 virtual bool should_fwd(const Bundle* bundle, const LinkRef& link, 00159 ForwardingInfo::action_t action = ForwardingInfo::COPY_ACTION); 00160 00174 virtual void tcl_dump_state(oasys::StringBuffer* buf); 00175 00180 virtual void recompute_routes(); 00181 00185 virtual void shutdown(); 00186 00187 protected: 00191 BundleRouter(const char* classname, const std::string& name); 00192 00194 std::string name_; 00195 00197 BundleList* pending_bundles_; 00198 00200 BundleList* custody_bundles_; 00201 00204 BundleActions* actions_; 00205 00206 }; 00207 00208 } // namespace dtn 00209 00210 #endif /* _BUNDLE_ROUTER_H_ */