IBR-DTNSuite  0.12
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 #include "net/DiscoveryAgent.h"
37 
38 #include <ibrdtn/data/Serializer.h>
39 #include <ibrdtn/data/EID.h>
40 
42 
43 #include <vector>
44 #include <set>
45 #include <map>
46 
47 using namespace dtn::data;
48 
49 namespace dtn
50 {
51  namespace core
52  {
54  {
55  public:
56  P2PDialupException(string what = "No path known except of dial-up connections.") throw() : Exception(what)
57  {
58  };
59  };
60 
65  {
66  static const std::string TAG;
67 
68  public:
70 
71  static BundleCore& getInstance();
72 
73  WallClock& getClock();
74 
75  virtual void onConfigurationChanged(const dtn::daemon::Configuration &conf) throw ();
76 
77  void setStorage(dtn::storage::BundleStorage *storage);
78  dtn::storage::BundleStorage& getStorage();
79 
80  void setSeeker(dtn::storage::BundleSeeker *seeker);
81  dtn::storage::BundleSeeker& getSeeker();
82 
83  void setRouter(dtn::routing::BaseRouter *router);
84  dtn::routing::BaseRouter& getRouter() const;
85 
90  dtn::net::ConnectionManager& getConnectionManager();
91 
95  dtn::net::DiscoveryAgent& getDiscoveryAgent();
96 
103  void addRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop, const dtn::data::Timeout timeout = 0);
104 
110  void removeRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop);
111 
116  bool isGloballyConnected() const;
117 
118  void raiseEvent(const dtn::core::Event *evt) throw ();
119 
120  virtual void validate(const dtn::data::PrimaryBlock &obj) const throw (RejectedException);
121  virtual void validate(const dtn::data::Block &obj, const dtn::data::Number&) const throw (RejectedException);
122  virtual void validate(const dtn::data::PrimaryBlock &bundle, const dtn::data::Block &obj, const dtn::data::Number&) const throw (RejectedException);
123  virtual void validate(const dtn::data::Bundle &obj) const throw (RejectedException);
124  virtual void validate(const dtn::data::MetaBundle &obj) const throw (RejectedException);
125 
129  static dtn::data::Length blocksizelimit;
130 
135  static dtn::data::Length foreign_blocksizelimit;
136 
140  static dtn::data::Length max_lifetime;
141 
145  static dtn::data::Length max_timestamp_future;
146 
150  static bool forwarding;
151 
155  static dtn::data::Size max_bundles_in_transit;
156 
160  virtual const std::string getName() const;
161 
162  static void processBlocks(dtn::data::Bundle &b);
163 
164  void setGloballyConnected(bool val);
165 
166  void eventNotify(const ibrcommon::LinkEvent &evt);
167 
168  protected:
169  virtual void componentUp() throw ();
170  virtual void componentDown() throw ();
171 
172  private:
176  BundleCore();
177 
181  virtual ~BundleCore();
182 
186  void check_connection_state() throw ();
187 
191  BundleCore operator=(const BundleCore &k)
192  { return k; };
193 
197  WallClock _clock;
198 
199  dtn::storage::BundleStorage *_storage;
201  dtn::routing::BaseRouter *_router;
202 
203  // generator for statusreports
204  StatusReportGenerator _statusreportgen;
205 
206  // manager class for connections
207  dtn::net::ConnectionManager _connectionmanager;
208 
209  // discovery agent handling all the discovery stuff
210  dtn::net::DiscoveryAgent _disco_agent;
211 
216  bool _globally_connected;
217  };
218  }
219 }
220 
221 #endif /*BUNDLECORE_H_*/
222