IBR-DTNSuite  0.10
BundleCore.h
Go to the documentation of this file.
1 /*
2  * BundleCore.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 BUNDLECORE_H_
23 #define BUNDLECORE_H_
24 
25 #include "Component.h"
26 #include "Configuration.h"
27 
28 #include "core/EventReceiver.h"
30 #include "storage/BundleStorage.h"
31 #include "core/WallClock.h"
32 #include "routing/BaseRouter.h"
33 
34 #include "net/ConnectionManager.h"
35 #include "net/ConvergenceLayer.h"
36 
37 #include <ibrdtn/data/Serializer.h>
38 #include <ibrdtn/data/EID.h>
39 
41 
42 #include <vector>
43 #include <set>
44 #include <map>
45 
46 using namespace dtn::data;
47 
48 namespace dtn
49 {
50  namespace core
51  {
53  {
54  public:
55  P2PDialupException(string what = "No path known except of dial-up connections.") throw() : Exception(what)
56  {
57  };
58  };
59 
64  {
65  public:
66  static const std::string TAG;
67 
69 
70  static BundleCore& getInstance();
71 
72  WallClock& getClock();
73 
74  virtual void onConfigurationChanged(const dtn::daemon::Configuration &conf) throw ();
75 
76  void setStorage(dtn::storage::BundleStorage *storage);
77  dtn::storage::BundleStorage& getStorage();
78 
79  void setSeeker(dtn::storage::BundleSeeker *seeker);
80  dtn::storage::BundleSeeker& getSeeker();
81 
82  void setRouter(dtn::routing::BaseRouter *router);
83  dtn::routing::BaseRouter& getRouter() const;
84 
85  void transferTo(dtn::net::BundleTransfer &transfer) throw (P2PDialupException);
86 
91  dtn::net::ConnectionManager& getConnectionManager();
92 
99  void addRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop, const dtn::data::Timeout timeout = 0);
100 
106  void removeRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop);
107 
112  bool isGloballyConnected() const;
113 
114  void raiseEvent(const dtn::core::Event *evt) throw ();
115 
116  virtual void validate(const dtn::data::PrimaryBlock &obj) const throw (RejectedException);
117  virtual void validate(const dtn::data::Block &obj, const dtn::data::Number&) const throw (RejectedException);
118  virtual void validate(const dtn::data::PrimaryBlock &bundle, const dtn::data::Block &obj, const dtn::data::Number&) const throw (RejectedException);
119  virtual void validate(const dtn::data::Bundle &obj) const throw (RejectedException);
120  virtual void validate(const dtn::data::MetaBundle &obj) const throw (RejectedException);
121 
125  static dtn::data::Length blocksizelimit;
126 
131  static dtn::data::Length foreign_blocksizelimit;
132 
136  static dtn::data::Length max_lifetime;
137 
141  static dtn::data::Length max_timestamp_future;
142 
146  static bool forwarding;
147 
148 
152  static dtn::data::Size max_bundles_in_transit;
153 
157  virtual const std::string getName() const;
158 
159  static void processBlocks(dtn::data::Bundle &b);
160 
161  void setGloballyConnected(bool val);
162 
163  void eventNotify(const ibrcommon::LinkEvent &evt);
164 
165  protected:
166  virtual void componentUp() throw ();
167  virtual void componentDown() throw ();
168 
169  private:
173  BundleCore();
174 
178  virtual ~BundleCore();
179 
183  void check_connection_state() throw ();
184 
188  BundleCore operator=(const BundleCore &k)
189  { return k; };
190 
194  WallClock _clock;
195 
196  dtn::storage::BundleStorage *_storage;
198  dtn::routing::BaseRouter *_router;
199 
200  // generator for statusreports
201  StatusReportGenerator _statusreportgen;
202 
203  // manager class for connections
204  dtn::net::ConnectionManager _connectionmanager;
205 
210  bool _globally_connected;
211  };
212  }
213 }
214 
215 #endif /*BUNDLECORE_H_*/
216