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 "NeighborhoodRouter.h" 00029 00030 namespace dtn { 00031 00032 NeighborhoodRouter::NeighborhoodRouter() 00033 : TableBasedRouter("NeighborhoodRouter", "neighborhood") 00034 { 00035 log_info("Initializing NeighborhoodRouter"); 00036 } 00037 00038 void 00039 NeighborhoodRouter::handle_contact_up(ContactUpEvent* event) 00040 { 00041 TableBasedRouter::handle_contact_up(event); 00042 00043 log_info("Contact Up: *%p adding route", event->contact_.object()); 00044 00045 char eidstring[255]; 00046 sprintf(eidstring, "dtn://%s", event->contact_->link()->nexthop()); 00047 00048 // By default, we add a route for all the next hops we have around. 00049 RouteEntry* entry = new RouteEntry(EndpointIDPattern(eidstring), 00050 event->contact_->link()); 00051 entry->action_ = ForwardingInfo::FORWARD_ACTION; 00052 add_route(entry); 00053 } 00054 00055 void 00056 NeighborhoodRouter::handle_contact_down(ContactDownEvent* event) 00057 { 00058 route_table_->del_entries_for_nexthop(event->contact_->link()); 00059 00060 TableBasedRouter::handle_contact_down(event); 00061 } 00062 00063 } // namespace dtn