IBR-DTNSuite  0.12
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 
37  { }
38 
40  { }
41 
43  {
45  }
46 
53  {
54  // acquire the transfer of this bundle, could throw already in transit or no resource left exception
55  {
56  // lock the list of neighbors
57  ibrcommon::MutexLock l((**this).getNeighborDB());
58 
59  // get the neighbor entry for the next hop
60  NeighborDatabase::NeighborEntry &entry = (**this).getNeighborDB().get(destination, true);
61 
62  // acquire the transfer, could throw already in transit or no resource left exception
63  entry.acquireTransfer(meta);
64  }
65 
66  try {
67  // create a new bundle transfer object
68  dtn::net::BundleTransfer transfer(destination, meta);
69 
70  // transfer the bundle to the next hop
72 
73  IBRCOMMON_LOGGER_DEBUG_TAG(RoutingExtension::TAG, 20) << "bundle " << meta.toString() << " queued for " << destination.getString() << IBRCOMMON_LOGGER_ENDL;
74  } catch (const dtn::core::P2PDialupException&) {
75  // the bundle transfer queues the bundle for retransmission, thus abort the query here
77  } catch (const ibrcommon::Exception &e) {
78  // ignore any other error
79  }
80  }
81 
82  } /* namespace routing */
83 } /* namespace dtn */