IBR-DTN  1.0.0
RoutingExtension.cpp
Go to the documentation of this file.
1 /*
2  * RoutingExtension.cpp
3  *
4  * Copyright (C) 2013 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
23 #include "routing/BaseRouter.h"
24 #include "core/BundleCore.h"
25 #include <ibrcommon/Logger.h>
26 
27 namespace dtn
28 {
29  namespace routing
30  {
31  const std::string RoutingExtension::TAG = "RoutingExtension";
32 
34  {
35  }
36 
38  {
39  }
40 
41  void RoutingResult::put(const dtn::data::MetaBundle &bundle) throw ()
42  {
44  }
45 
47  {
48  push_back(make_pair(bundle, p));
49  }
50 
55  { }
56 
58  { }
59 
61  {
63  }
64 
71  {
72  // acquire the transfer of this bundle, could throw already in transit or no resource left exception
73  {
74  // lock the list of neighbors
75  ibrcommon::MutexLock l((**this).getNeighborDB());
76 
77  // get the neighbor entry for the next hop
78  NeighborDatabase::NeighborEntry &entry = (**this).getNeighborDB().get(destination, true);
79 
80  // acquire the transfer, could throw already in transit or no resource left exception
81  entry.acquireTransfer(meta);
82  }
83  try{
84  //create the transfer object
85  dtn::net::BundleTransfer transfer(destination, meta, p);
86 
87  // transfer the bundle to the next hop
89 
90  IBRCOMMON_LOGGER_DEBUG_TAG(RoutingExtension::TAG, 20) << "bundle " << meta.toString() << " queued by " << getTag() << " for " << destination.getString() << " via protocol " << dtn::core::Node::toString(p) << IBRCOMMON_LOGGER_ENDL;
91  } catch (const dtn::core::P2PDialupException&) {
92  // the bundle transfer queues the bundle for retransmission, thus abort the query here
94  } catch (const ibrcommon::Exception &e) {
95  // ignore any other error
96  }
97  }
98 
99  } /* namespace routing */
100 } /* namespace dtn */
std::string toString() const
Definition: BundleID.cpp:190
virtual const std::string getTag() const
virtual void put(const dtn::data::MetaBundle &bundle)
dtn::routing::BaseRouter & getRouter() const
Definition: BundleCore.cpp:227
dtn::net::ConnectionManager & getConnectionManager()
Definition: BundleCore.cpp:260
void acquireTransfer(const dtn::data::BundleID &id)
void queue(dtn::net::BundleTransfer &job)
void transferTo(const dtn::data::EID &destination, const dtn::data::MetaBundle &meta, const dtn::core::Node::Protocol)
std::string getString() const
Definition: EID.cpp:374
std::string toString() const
Definition: Node.cpp:510
static BundleCore & getInstance()
Definition: BundleCore.cpp:82