IBR-DTN  1.0.0
NeighborRoutingExtension.h
Go to the documentation of this file.
1 /*
2  * NeighborRoutingExtension.h
3  *
4  * Copyright (C) 2011 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 
22 #ifndef NEIGHBORROUTINGEXTENSION_H_
23 #define NEIGHBORROUTINGEXTENSION_H_
24 
25 #include "storage/BundleResult.h"
28 #include "core/Node.h"
29 #include "net/ConnectionManager.h"
30 
31 #include <ibrdtn/data/MetaBundle.h>
32 #include "ibrdtn/data/EID.h"
33 #include <ibrcommon/thread/Queue.h>
34 #include <list>
35 #include <map>
36 #include <queue>
37 
38 namespace dtn
39 {
40  namespace routing
41  {
42  class NeighborRoutingExtension : public RoutingExtension, public ibrcommon::JoinableThread
43  {
44  static const std::string TAG;
45 
46  public:
48  virtual ~NeighborRoutingExtension();
49 
50  virtual const std::string getTag() const throw ();
51 
52  virtual void eventDataChanged(const dtn::data::EID &peer) throw ();
53 
54  virtual void eventBundleQueued(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta) throw ();
55 
56  void componentUp() throw ();
57  void componentDown() throw ();
58 
59  protected:
60  void run() throw ();
61  void __cancellation() throw ();
62 
63  private:
64  class Task
65  {
66  public:
67  virtual ~Task() {};
68  virtual std::string toString() = 0;
69  };
70 
71  class SearchNextBundleTask : public Task
72  {
73  public:
74  SearchNextBundleTask(const dtn::data::EID &eid);
75  virtual ~SearchNextBundleTask();
76 
77  virtual std::string toString();
78 
79  const dtn::data::EID eid;
80  };
81 
82  class ProcessBundleTask : public Task
83  {
84  public:
85  ProcessBundleTask(const dtn::data::MetaBundle &meta, const dtn::data::EID &origin, const dtn::data::EID &nexthop);
86  virtual ~ProcessBundleTask();
87 
88  virtual std::string toString();
89 
90  const dtn::data::MetaBundle bundle;
91  const dtn::data::EID origin;
92  const dtn::data::EID nexthop;
93  };
94 
95  std::pair<bool, dtn::core::Node::Protocol> shouldRouteTo(const dtn::data::MetaBundle &meta, const NeighborDatabase::NeighborEntry &n, const dtn::net::ConnectionManager::protocol_list &plist) const;
96 
100  ibrcommon::Queue<NeighborRoutingExtension::Task* > _taskqueue;
101  };
102  }
103 }
104 
105 #endif /* NEIGHBORROUTINGEXTENSION_H_ */
std::list< dtn::core::Node::Protocol > protocol_list
virtual const std::string getTag() const
virtual void eventBundleQueued(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta)
virtual void eventDataChanged(const dtn::data::EID &peer)