FloodBundleRouter.cc

Go to the documentation of this file.
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 
00018 #include "BundleRouter.h"
00019 #include "RouteTable.h"
00020 #include "bundling/Bundle.h"
00021 #include "bundling/BundleActions.h"
00022 #include "bundling/BundleDaemon.h"
00023 #include "bundling/BundleList.h"
00024 #include "contacts/Contact.h"
00025 #include "reg/Registration.h"
00026 #include <stdlib.h>
00027 
00028 #include "FloodBundleRouter.h"
00029 
00030 namespace dtn {
00031 
00032 //----------------------------------------------------------------------
00033 FloodBundleRouter::FloodBundleRouter()
00034     : TableBasedRouter("FloodBundleRouter", "flood"),
00035       all_bundles_("FloodBundleRouter::all_bundles"),
00036       all_eids_("*:*")
00037 {
00038     log_info("FloodBundleRouter initialized");
00039     ASSERT(all_eids_.valid());
00040 }
00041 
00042 //----------------------------------------------------------------------
00043 void
00044 FloodBundleRouter::handle_bundle_received(BundleReceivedEvent* event)
00045 {
00046     Bundle* bundle = event->bundleref_.object();
00047     log_debug("bundle received *%p", bundle);
00048     all_bundles_.push_back(bundle);
00049     fwd_to_matching(bundle);
00050 }
00051 
00052 //----------------------------------------------------------------------
00053 void
00054 FloodBundleRouter::handle_link_created(LinkCreatedEvent* event)
00055 {
00056     Link* link = event->link_;
00057     ASSERT(link != NULL);
00058     log_debug("link_created *%p", link);
00059 
00060     RouteEntry* entry = new RouteEntry(all_eids_, link);
00061     entry->action_ = ForwardingInfo::COPY_ACTION;
00062 
00063     // adds the route to the table and checks for bundles that may
00064     // need to be sent to the new link
00065     add_route(entry);
00066 }
00067 
00068 //----------------------------------------------------------------------
00069 void
00070 FloodBundleRouter::handle_bundle_expired(BundleExpiredEvent* event)
00071 {
00072     Bundle* bundle = event->bundleref_.object();
00073     log_debug("bundle_expired *%p", bundle);
00074     all_bundles_.erase(bundle);
00075 }
00076 
00077 } // namespace dtn

Generated on Thu Jun 7 12:54:27 2007 for DTN Reference Implementation by  doxygen 1.5.1