IBR-DTN  1.0.0
BundleCore.cpp
Go to the documentation of this file.
1 /*
2  * BundleCore.cpp
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 #include "config.h"
23 #include "Configuration.h"
24 #include "core/EventDispatcher.h"
25 #include "core/BundleCore.h"
26 #include "core/GlobalEvent.h"
27 #include "core/BundleEvent.h"
28 #include "core/FragmentManager.h"
32 
33 #include <ibrcommon/data/BLOB.h>
36 #include <ibrdtn/data/MetaBundle.h>
37 #include <ibrdtn/data/Exceptions.h>
38 #include <ibrdtn/data/EID.h>
39 #include <ibrdtn/utils/Clock.h>
40 #include <ibrcommon/Logger.h>
41 #include <ibrcommon/thread/RWLock.h>
42 #include <ibrcommon/thread/MutexLock.h>
43 
44 #include "core/filter/LogFilter.h"
46 
47 #include "limits.h"
48 #include <iostream>
49 #include <typeinfo>
50 #include <stdint.h>
51 
52 #include <ibrdtn/ibrdtn.h>
53 
54 #ifdef IBRDTN_SUPPORT_BSP
57 #endif
58 
59 #ifdef IBRDTN_SUPPORT_COMPRESSION
61 #endif
62 
63 using namespace dtn::data;
64 using namespace dtn::utils;
65 using namespace std;
66 
67 namespace dtn
68 {
69  namespace core
70  {
71  const std::string BundleCore::TAG = "BundleCore";
72  dtn::data::EID BundleCore::local;
73 
74  dtn::data::Length BundleCore::blocksizelimit = 0;
75  dtn::data::Length BundleCore::foreign_blocksizelimit = 0;
76  dtn::data::Length BundleCore::max_lifetime = 0;
77  dtn::data::Length BundleCore::max_timestamp_future = 0;
78  dtn::data::Size BundleCore::max_bundles_in_transit = 5;
79 
80  bool BundleCore::forwarding = true;
81 
82  BundleCore& BundleCore::getInstance()
83  {
84  static BundleCore instance;
85  return instance;
86  }
87 
88  BundleCore::BundleCore()
89  : _clock(1), _storage(NULL), _seeker(NULL), _router(NULL), _globally_connected(false)
90  {
95  }
96 
97  BundleCore::~BundleCore()
98  {
103  }
104 
105  void BundleCore::componentUp() throw ()
106  {
107  // routine checked for throw() on 15.02.2013
109 
110  // initialize connection manager
111  _connectionmanager.initialize();
112 
113  // initialize wall clock
114  _clock.initialize();
115 
116  // initialize discovery agent
117  _disco_agent.initialize();
118 
119  // start a clock
120  _clock.startup();
121 
122  // start discovery agent
123  _disco_agent.startup();
124  }
125 
127  {
128  ibrcommon::LinkManager::getInstance().removeEventListener(this);
129 
130  // terminate discovery agent
131  _disco_agent.terminate();
132 
133  // terminate connection manager
134  _connectionmanager.terminate();
135 
136  // terminate wall clock
137  _clock.terminate();
138  }
139 
141  {
142  // set local eid
143  dtn::core::BundleCore::local = config.getNodename();
144  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Local node name: " << config.getNodename() << IBRCOMMON_LOGGER_ENDL;
145 
146  // set block size limit
147  dtn::core::BundleCore::blocksizelimit = config.getLimit("blocksize");
149  {
150  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Block size limited to " << dtn::core::BundleCore::blocksizelimit << " bytes" << IBRCOMMON_LOGGER_ENDL;
151  }
152 
153  // set block size limit
154  dtn::core::BundleCore::foreign_blocksizelimit = config.getLimit("foreign_blocksize");
156  {
157  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Block size of foreign bundles limited to " << dtn::core::BundleCore::foreign_blocksizelimit << " bytes" << IBRCOMMON_LOGGER_ENDL;
158  }
159 
160  // set the lifetime limit
161  dtn::core::BundleCore::max_lifetime = config.getLimit("lifetime");
163  {
164  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Lifetime limited to " << dtn::core::BundleCore::max_lifetime << " seconds" << IBRCOMMON_LOGGER_ENDL;
165  }
166 
167  // set the timestamp limit
168  dtn::core::BundleCore::max_timestamp_future = config.getLimit("predated_timestamp");
170  {
171  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Pre-dated timestamp limited to " << dtn::core::BundleCore::max_timestamp_future << " seconds in the future" << IBRCOMMON_LOGGER_ENDL;
172  }
173 
174  // set the maximum count of bundles in transit (bundles to send to the CL queue)
175  dtn::data::Size transit_limit = config.getLimit("bundles_in_transit");
176  if (transit_limit > 0)
177  {
179  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Limit the number of bundles in transit to " << dtn::core::BundleCore::max_bundles_in_transit << IBRCOMMON_LOGGER_ENDL;
180  }
181 
182  // enable or disable forwarding of bundles
183  if (config.getNetwork().doForwarding())
184  {
185  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Forwarding of bundles enabled." << IBRCOMMON_LOGGER_ENDL;
186  BundleCore::forwarding = true;
187  }
188  else
189  {
190  IBRCOMMON_LOGGER_TAG(BundleCore::TAG, info) << "Forwarding of bundles disabled." << IBRCOMMON_LOGGER_ENDL;
191  BundleCore::forwarding = false;
192  }
193 
194  const std::set<ibrcommon::vinterface> &global_nets = config.getNetwork().getInternetDevices();
195 
196  // remove myself from all listeners
197  ibrcommon::LinkManager::getInstance().removeEventListener(this);
198 
199  // add all listener in the configuration
200  for (std::set<ibrcommon::vinterface>::const_iterator iter = global_nets.begin(); iter != global_nets.end(); ++iter)
201  {
202  ibrcommon::LinkManager::getInstance().addEventListener(*iter, this);
203  }
204 
205  // check connection state
206  check_connection_state();
207 
208  // reload all tables
209  reload_filter_tables();
210  }
211 
213  {
214  _storage = storage;
215  }
216 
218  {
219  _seeker = seeker;
220  }
221 
223  {
224  _router = router;
225  }
226 
228  {
229  if (_router == NULL)
230  {
231  throw ibrcommon::Exception("router not set");
232  }
233 
234  return *_router;
235  }
236 
238  {
239  if (_storage == NULL)
240  {
241  throw ibrcommon::Exception("No bundle storage is set! Use BundleCore::setStorage() to set a storage.");
242  }
243  return *_storage;
244  }
245 
247  {
248  if (_seeker == NULL)
249  {
250  throw ibrcommon::Exception("No bundle seeker is set! Use BundleCore::setSeeker() to set a seeker.");
251  }
252  return *_seeker;
253  }
254 
256  {
257  return _clock;
258  }
259 
261  {
262  return _connectionmanager;
263  }
264 
266  {
267  return _disco_agent;
268  }
269 
270  void BundleCore::addRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop, const dtn::data::Timeout timeout)
271  {
273  }
274 
275  void BundleCore::removeRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop)
276  {
278  }
279 
281  {
282  return _globally_connected;
283  }
284 
286  {
287  try {
288  // get reference to the meta data of the bundle
289  const dtn::data::MetaBundle &meta = queued.bundle;
290 
291  // ignore fragments
292  if (meta.isFragment()) return;
293 
294  // if the destination is equal this node...
295  if (meta.destination == local)
296  {
297  // if the delivered variable is still false at the end of this block,
298  // we discard the bundle
299  bool delivered = false;
300 
301  // process this bundle locally
302  const dtn::data::Bundle bundle = getStorage().get(meta);
303 
305  try {
306  // check for a custody signal
307  const dtn::data::PayloadBlock &payload = bundle.find<dtn::data::PayloadBlock>();
308 
309  CustodySignalBlock custody;
310  custody.read(payload);
311 
312  getStorage().releaseCustody(bundle.source, custody.bundleid);
313 
314  IBRCOMMON_LOGGER_DEBUG_TAG("BundleCore", 5) << "custody released for " << bundle.toString() << IBRCOMMON_LOGGER_ENDL;
315 
316  delivered = true;
318  // no custody signal available
320  // no payload block available
321  }
322 
323  if (delivered)
324  {
325  // gen a report
327  }
328  else
329  {
330  // gen a report
332  }
333 
335  {
336  // delete the bundle
338  }
339  }
340  } catch (const dtn::storage::NoBundleFoundException&) {
341  }
342  }
343 
345  {
346  const dtn::data::MetaBundle &meta = completed.getBundle();
347  const dtn::data::EID &peer = completed.getPeer();
348 
349  if ((meta.destination.sameHost(peer))
351  {
352  // bundle has been delivered to its destination
353  // delete it from our storage
355 
356  IBRCOMMON_LOGGER_TAG("BundleCore", notice) << "singleton bundle delivered: " << meta.toString() << IBRCOMMON_LOGGER_ENDL;
357 
358  // gen a report
360  }
361  }
362 
364  {
365  if (aborted.reason != dtn::net::TransferAbortedEvent::REASON_REFUSED) return;
366 
367  const dtn::data::EID &peer = aborted.getPeer();
368  const dtn::data::BundleID &id = aborted.getBundleID();
369 
370  try {
371  // create meta bundle for futher processing
372  const dtn::data::MetaBundle meta = getStorage().info(id);
373 
375 
376  // if the bundle has been sent by this module delete it
377  if (meta.destination.sameHost(peer))
378  {
379  // bundle is not deliverable
381  }
382  } catch (const dtn::storage::NoBundleFoundException&) { };
383  }
384 
386  {
387  // get the global storage
389 
390  try {
391  // delete the bundle
392  storage.remove(purge.bundle);
393  } catch (const dtn::storage::NoBundleFoundException&) { };
394  }
395 
397  {
398  if (dtn::utils::Clock::isExpired(obj)) {
399  // ... bundle is expired
400  IBRCOMMON_LOGGER_DEBUG_TAG("BundleCore", 35) << "bundle rejected: bundle has expired (" << obj.toString() << ")" << IBRCOMMON_LOGGER_ENDL;
401  throw dtn::data::Validator::RejectedException("bundle is expired");
402  }
403 
404  // check if the lifetime of the bundle is too long
405  if (BundleCore::max_lifetime > 0)
406  {
407  if (obj.lifetime > BundleCore::max_lifetime)
408  {
409  // ... we reject bundles with such a long lifetime
410  IBRCOMMON_LOGGER_DEBUG_TAG("BundleCore", 35) << "lifetime of bundle rejected: " << obj.toString() << IBRCOMMON_LOGGER_ENDL;
411  throw dtn::data::Validator::RejectedException("lifetime of the bundle is too long");
412  }
413  }
414 
415  // check if the timestamp is in the future
416  if ((BundleCore::max_timestamp_future > 0) && (obj.timestamp != 0))
417  {
418  // first check if the local clock is reliable
420  // then check the timestamp
422  {
423  // ... we reject bundles with a timestamp so far in the future
424  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "timestamp of bundle rejected: " << obj.toString() << IBRCOMMON_LOGGER_ENDL;
425  throw dtn::data::Validator::RejectedException("timestamp is too far in the future");
426  }
427  }
428 
429  // use validation filter for further evaluation
430  dtn::core::FilterContext context;
431  context.setMetaBundle(obj);
432 
433  ibrcommon::MutexLock l(_filter_mutex);
434  if (_table_validation.evaluate(context) != BundleFilter::ACCEPT)
435  throw dtn::data::Validator::RejectedException("rejected by filter");
436  }
437 
439  {
440  // check if the bundle is expired
441  if (dtn::utils::Clock::isExpired(p.timestamp, p.lifetime))
442  {
443  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "bundle rejected: bundle has expired (" << p.toString() << ")" << IBRCOMMON_LOGGER_ENDL;
444  throw dtn::data::Validator::RejectedException("bundle is expired");
445  }
446 
447  // if we do not forward bundles
449  {
450  if (!p.destination.sameHost(BundleCore::local))
451  {
452  // ... we reject all non-local bundles.
453  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "non-local bundle rejected: " << p.toString() << IBRCOMMON_LOGGER_ENDL;
454  throw dtn::data::Validator::RejectedException("bundle is not local");
455  }
456  }
457 
458  // check if the lifetime of the bundle is too long
459  if (BundleCore::max_lifetime > 0)
460  {
461  if (p.lifetime > BundleCore::max_lifetime)
462  {
463  // ... we reject bundles with such a long lifetime
464  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "lifetime of bundle rejected: " << p.toString() << IBRCOMMON_LOGGER_ENDL;
465  throw dtn::data::Validator::RejectedException("lifetime of the bundle is too long");
466  }
467  }
468 
469  // check if the timestamp is in the future
470  if ((BundleCore::max_timestamp_future > 0) && (p.timestamp != 0))
471  {
472  // first check if the local clock is reliable
474  // then check the timestamp
476  {
477  // ... we reject bundles with a timestamp so far in the future
478  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "timestamp of bundle rejected: " << p.toString() << IBRCOMMON_LOGGER_ENDL;
479  throw dtn::data::Validator::RejectedException("timestamp is too far in the future");
480  }
481  }
482 
483  // check for duplicates
484  if (getRouter().isKnown(p))
485  {
486  throw dtn::data::Validator::RejectedException("duplicate detected");
487  }
488 
489  // use validation filter for further evaluation
490  dtn::core::FilterContext context;
491  context.setPrimaryBlock(p);
492 
493  ibrcommon::MutexLock l(_filter_mutex);
494  if (_table_validation.evaluate(context) != BundleFilter::ACCEPT)
495  throw dtn::data::Validator::RejectedException("rejected by filter");
496  }
497 
499  {
500  // check for the size of the block
501  // reject a block if it exceeds the payload limit
503  {
504  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "bundle rejected: block size of " << size.toString() << " is too big" << IBRCOMMON_LOGGER_ENDL;
505  throw dtn::data::Validator::RejectedException("block size is too big");
506  }
507 
508  // use validation filter for further evaluation
509  dtn::core::FilterContext context;
510  context.setBlock(block, size);
511 
512  ibrcommon::MutexLock l(_filter_mutex);
513  if (_table_validation.evaluate(context) != BundleFilter::ACCEPT)
514  throw dtn::data::Validator::RejectedException("rejected by filter");
515  }
516 
517  void BundleCore::validate(const dtn::data::PrimaryBlock &bundle, const dtn::data::Block& block, const dtn::data::Number& size) const throw (RejectedException)
518  {
519  // check for the size of the foreign block
520  // reject a block if it exceeds the payload limit
523  if (!bundle.source.sameHost(dtn::core::BundleCore::local)) {
524  if (!bundle.destination.sameHost(dtn::core::BundleCore::local)) {
525  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "foreign bundle " << bundle.toString() << " rejected: block size of " << size.toString() << " is too big" << IBRCOMMON_LOGGER_ENDL;
526  throw dtn::data::Validator::RejectedException("foreign block size is too big");
527  }
528  }
529  }
530  }
531 
532  // check for the size of the block
533  // reject a block if it exceeds the payload limit
535  {
536  if (size > BundleCore::blocksizelimit)
537  {
538  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "bundle " << bundle.toString() << " rejected: block size of " << size.toString() << " is too big" << IBRCOMMON_LOGGER_ENDL;
539  throw dtn::data::Validator::RejectedException("block size is too big");
540  }
541  }
542 
543  // use validation filter for further evaluation
544  dtn::core::FilterContext context;
545  context.setPrimaryBlock(bundle);
546  context.setBlock(block, size);
547 
548  ibrcommon::MutexLock l(_filter_mutex);
549  if (_table_validation.evaluate(context) != BundleFilter::ACCEPT)
550  throw dtn::data::Validator::RejectedException("rejected by filter");
551  }
552 
554  {
555  // reject bundles without destination
556  if (b.destination.isNone())
557  {
558  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "bundle rejected: the destination is null" << IBRCOMMON_LOGGER_ENDL;
559  throw dtn::data::Validator::RejectedException("bundle destination is none");
560  }
561 
562  // check bundle expiration again for bundles with age block
563  if ((b.timestamp == 0) && dtn::utils::Clock::isExpired(b))
564  {
565  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "bundle rejected: bundle has expired (" << b.toString() << ")" << IBRCOMMON_LOGGER_ENDL;
566  throw dtn::data::Validator::RejectedException("bundle is expired");
567  }
568 
569  // check for invalid blocks
570  for (dtn::data::Bundle::const_iterator iter = b.begin(); iter != b.end(); ++iter)
571  {
572  try {
573  const dtn::data::ExtensionBlock &e = dynamic_cast<const dtn::data::ExtensionBlock&>(**iter);
574 
576  {
577  // reject the hole bundle
578  throw dtn::data::Validator::RejectedException("bundle contains unintelligible blocks");
579  }
580 
582  {
583  // transmit status report, because we can not process this block
585  }
586  } catch (const std::bad_cast&) { }
587  }
588 
589  // use validation filter for further evaluation
590  dtn::core::FilterContext context;
591  context.setBundle(b);
592 
593  ibrcommon::MutexLock l(_filter_mutex);
594  if (_table_validation.evaluate(context) != BundleFilter::ACCEPT)
595  throw dtn::data::Validator::RejectedException("rejected by filter");
596  }
597 
599  {
600  ibrcommon::MutexLock l(_filter_mutex);
601 
602  switch (table)
603  {
604  case BundleFilter::INPUT:
605  return _table_input.filter(context, bundle);
606 
608  return _table_output.filter(context, bundle);
609 
611  return _table_routing.filter(context, bundle);
612  }
613 
614  return BundleFilter::ACCEPT;
615  }
616 
618  {
619  ibrcommon::MutexLock l(_filter_mutex);
620 
621  switch (table)
622  {
623  case BundleFilter::INPUT:
624  return _table_input.evaluate(context);
625 
627  return _table_output.evaluate(context);
628 
630  return _table_routing.evaluate(context);
631  }
632 
633  return BundleFilter::ACCEPT;
634  }
635 
636  const std::string BundleCore::getName() const
637  {
638  return "BundleCore";
639  }
640 
642  {
643  bool restart = true;
644 
645  // loop as long as necessary over all blocks
646  while (restart)
647  {
648  // disable restart
649  restart = false;
650 
651  // walk through the block and process them when needed
652  for (dtn::data::Bundle::iterator iter = b.begin(); iter != b.end(); ++iter)
653  {
654  const dtn::data::Block &block = (**iter);
655 
656 #ifdef IBRDTN_SUPPORT_BSP
658  {
659  // try to decrypt the bundle
660  try {
663  // decrypt needed, but no key is available
664  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "No key available for decryption of bundle." << IBRCOMMON_LOGGER_ENDL;
665  throw;
666  } catch (const dtn::security::DecryptException &ex) {
667  // decrypt failed
668  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "Decryption of bundle failed: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
669  throw;
670  }
671 
672  // bundle has been altered - proceed from the first block
673  restart = true;
674  break;
675  }
676 #endif
677 
678 #ifdef IBRDTN_SUPPORT_COMPRESSION
680  {
681  // try to decompress the bundle
682  try {
684  } catch (const ibrcommon::Exception &ex) {
685  IBRCOMMON_LOGGER_TAG("BundleCore", warning) << "Decompression of bundle failed: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
686  throw;
687  }
688 
689  // bundle has been altered - proceed from the first block
690  restart = true;
691  break;
692  }
693 #endif
694  }
695  }
696  }
697 
698  void BundleCore::eventNotify(const ibrcommon::LinkEvent &evt)
699  {
700  const std::set<ibrcommon::vinterface> &global_nets = dtn::daemon::Configuration::getInstance().getNetwork().getInternetDevices();
701  if (global_nets.find(evt.getInterface()) != global_nets.end()) {
702  check_connection_state();
703  }
704  }
705 
707  {
708  // modify TrackingBlock
709  try {
713 
714 #ifdef IBRDTN_SUPPORT_COMPRESSION
715  // if the compression bit is set, then compress the bundle
717  {
718  try {
720 
722  } catch (const ibrcommon::Exception &ex) {
723  IBRCOMMON_LOGGER_TAG(TAG, warning) << "compression of bundle failed: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
724  };
725  }
726 #endif
727 
728 #ifdef IBRDTN_SUPPORT_BSP
729  // if the encrypt bit is set, then try to encrypt the bundle
731  {
732  try {
734 
737  // sign requested, but no key is available
738  IBRCOMMON_LOGGER_TAG(TAG, warning) << "No key available for encrypt process." << IBRCOMMON_LOGGER_ENDL;
739  } catch (const dtn::security::EncryptException&) {
740  IBRCOMMON_LOGGER_TAG(TAG, warning) << "Encryption of bundle failed." << IBRCOMMON_LOGGER_ENDL;
741  }
742  }
743 
744  // if the sign bit is set, then try to sign the bundle
746  {
747  try {
749 
752  // sign requested, but no key is available
753  IBRCOMMON_LOGGER_TAG(TAG, warning) << "No key available for sign process." << IBRCOMMON_LOGGER_ENDL;
754  }
755  }
756 #endif
757 
758  // get the payload size maximum
759  size_t maxPayloadLength = dtn::daemon::Configuration::getInstance().getLimit("payload");
760 
761  // check if fragmentation is enabled
762  // do not try pro-active fragmentation if the payload length is not limited
763  if (dtn::daemon::Configuration::getInstance().getNetwork().doFragmentation() && (maxPayloadLength > 0))
764  {
765  try {
766  std::list<dtn::data::Bundle> fragments;
767 
768  dtn::core::FragmentManager::split(bundle, maxPayloadLength, fragments);
769 
770  // for each fragment raise bundle received event
771  for (std::list<dtn::data::Bundle>::iterator it = fragments.begin(); it != fragments.end(); ++it)
772  {
773  // raise default bundle received event
774  dtn::net::BundleReceivedEvent::raise(source, *it, true);
775  }
776 
777  return;
778  } catch (const FragmentationProhibitedException&) {
779  } catch (const FragmentationNotNecessaryException&) {
780  } catch (const FragmentationAbortedException&) {
781  // drop the bundle
782  return;
783  }
784  }
785 
786  // raise default bundle received event
787  dtn::net::BundleReceivedEvent::raise(source, bundle, true);
788  }
789 
791  {
792  if (val == _globally_connected) return;
793 
794  if (val) {
796  } else {
798  }
799 
800  _globally_connected = val;
801  }
802 
803  void BundleCore::check_connection_state() throw ()
804  {
805  const std::set<ibrcommon::vinterface> &global_nets = dtn::daemon::Configuration::getInstance().getNetwork().getInternetDevices();
806 
807  if (!global_nets.empty()) {
808  bool found = false;
809  for (std::set<ibrcommon::vinterface>::const_iterator iter = global_nets.begin(); iter != global_nets.end(); ++iter)
810  {
811  const ibrcommon::vinterface &iface = (*iter);
812  if (!iface.getAddresses(ibrcommon::vaddress::SCOPE_GLOBAL).empty()) {
813  found = true;
814  }
815  }
816  setGloballyConnected(found);
817  }
818  }
819 
820  void BundleCore::reload_filter_tables() throw ()
821  {
822  ibrcommon::RWLock l(_filter_mutex);
823 
824  _table_input.clear();
825  _table_output.clear();
826  _table_routing.clear();
827  _table_validation.clear();
828 
833 
835  {
836  _table_validation.append(
838  (new LogFilter(ibrcommon::LogLevel::warning, "bundle rejected due to missing authentication"))->append(
839  (new RejectFilter())
840  )));
841 
842  _table_output.append(
844  (new LogFilter(ibrcommon::LogLevel::warning, "can not apply authentication due to missing key"))
845  ));
846  }
847 
849  {
850  _table_validation.append(
852  (new LogFilter(ibrcommon::LogLevel::warning, "bundle rejected due to missing signature"))->append(
853  (new RejectFilter())
854  )));
855  }
856 
858  {
859  _table_validation.append(
861  (new LogFilter(ibrcommon::LogLevel::warning, "bundle rejected due to missing encryption"))->append(
862  (new RejectFilter())
863  )));
864  }
865 
869  _table_input.append(
871  (new LogFilter(ibrcommon::LogLevel::warning, "bundle rejected due to invalid authentication"))->append(
872  (new RejectFilter())
873  )));
874 
875  _table_input.append(
877  (new LogFilter(ibrcommon::LogLevel::warning, "bundle rejected due to invalid signature"))->append(
878  (new RejectFilter())
879  )));
880  }
881  }
882 }
static Configuration & getInstance(bool reset=false)
std::string toString() const
Definition: BundleID.cpp:190
static void inject(const dtn::data::EID &source, dtn::data::Bundle &bundle)
Definition: BundleCore.cpp:706
virtual ACTION evaluate(const FilterContext &context) const
virtual const std::string getName() const
Definition: BundleCore.cpp:636
static dtn::data::Length foreign_blocksizelimit
Definition: BundleCore.h:159
static dtn::data::Length max_timestamp_future
Definition: BundleCore.h:169
void raiseEvent(const dtn::routing::QueueBundleEvent &evt)
Definition: BundleCore.cpp:285
static dtn::data::EID local
Definition: BundleCore.h:79
const Configuration::Security & getSecurity() const
bool get(dtn::data::PrimaryBlock::FLAGS flag) const
Definition: MetaBundle.cpp:160
static void add(EventReceiver< E > *receiver)
bool get(ProcFlags flag) const
Definition: Block.cpp:82
static void split(const dtn::data::Bundle &bundle, const dtn::data::Length &maxPayloadLength, std::list< dtn::data::Bundle > &fragments)
virtual void read(const dtn::data::PayloadBlock &p)
bool sameHost(const std::string &other) const
Definition: EID.cpp:322
virtual void componentDown()
Definition: BundleCore.cpp:126
dtn::routing::BaseRouter & getRouter() const
Definition: BundleCore.cpp:227
void setSeeker(dtn::storage::BundleSeeker *seeker)
Definition: BundleCore.cpp:217
void setGloballyConnected(bool val)
Definition: BundleCore.cpp:790
size_t Length
Definition: Number.h:33
void setBundle(const dtn::data::Bundle &data)
static void extract(dtn::data::Bundle &b)
static void remove(const EventReceiver< E > *receiver)
void addRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop, const dtn::data::Timeout timeout=0)
Definition: BundleCore.cpp:270
static const dtn::data::block_t BLOCK_TYPE
void setRouter(dtn::routing::BaseRouter *router)
Definition: BundleCore.cpp:222
virtual void componentUp()
Definition: BundleCore.cpp:105
void sign(dtn::data::Bundle &bundle) const
dtn::net::ConnectionManager & getConnectionManager()
Definition: BundleCore.cpp:260
static void raiseEvent(CHANGE_TYPE type)
iterator begin()
Definition: Bundle.cpp:49
bool isGloballyConnected() const
Definition: BundleCore.cpp:280
dtn::net::DiscoveryAgent & getDiscoveryAgent()
Definition: BundleCore.cpp:265
BundleFilter::ACTION filter(BundleFilter::TABLE table, const FilterContext &context, dtn::data::Bundle &bundle) const
Definition: BundleCore.cpp:598
static dtn::data::Length blocksizelimit
Definition: BundleCore.h:153
BundleFilter::ACTION evaluate(BundleFilter::TABLE table, const FilterContext &context) const
Definition: BundleCore.cpp:617
dtn::storage::BundleSeeker & getSeeker()
Definition: BundleCore.cpp:246
const Configuration::Network & getNetwork() const
virtual void remove(const dtn::data::BundleID &id)=0
bool get(FLAGS flag) const
static bool forwarding
Definition: BundleCore.h:174
dtn::data::Size getLimit(const std::string &) const
void eventNotify(const ibrcommon::LinkEvent &evt)
Definition: BundleCore.cpp:698
virtual void validate(const dtn::data::PrimaryBlock &obj) const
Definition: BundleCore.cpp:438
const std::string TAG
Definition: dtnoutbox.cpp:62
static void compress(dtn::data::Bundle &b, COMPRESS_ALGS alg)
void append(const dtn::data::EID &eid)
static dtn::data::Size max_bundles_in_transit
Definition: BundleCore.h:179
static void raise(const Action a)
Definition: GlobalEvent.cpp:79
block_list::const_iterator const_iterator
Definition: Bundle.h:77
static SecurityManager & getInstance()
size_t Timeout
Definition: Number.h:35
void setMetaBundle(const dtn::data::MetaBundle &data)
void append(BundleFilter *filter)
bool isFragment() const
Definition: MetaBundle.cpp:165
void setBlock(const dtn::data::Block &block, const dtn::data::Number &size)
static dtn::data::Timestamp getTime()
Definition: Clock.cpp:167
dtn::data::EID destination
Definition: MetaBundle.h:60
static const dtn::data::block_t BLOCK_TYPE
block_list::iterator iterator
Definition: Bundle.h:76
void removeRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop)
Definition: BundleCore.cpp:275
void setStorage(dtn::storage::BundleStorage *storage)
Definition: BundleCore.cpp:212
void encrypt(dtn::data::Bundle &bundle) const
static void processBlocks(dtn::data::Bundle &b)
Definition: BundleCore.cpp:641
Bitset< dtn::data::PrimaryBlock::FLAGS > procflags
Definition: MetaBundle.h:64
size_t Size
Definition: Number.h:34
virtual void onConfigurationChanged(const dtn::daemon::Configuration &conf)
Definition: BundleCore.cpp:140
virtual ACTION filter(const FilterContext &context, dtn::data::Bundle &bundle) const
static double getRating()
Definition: Clock.cpp:59
iterator find(block_t blocktype)
Definition: Bundle.cpp:307
static void raise(const dtn::data::MetaBundle &bundle, EventBundleAction action, dtn::data::StatusReportBlock::REASON_CODE reason=dtn::data::StatusReportBlock::NO_ADDITIONAL_INFORMATION)
Definition: BundleEvent.cpp:78
static MetaBundle create(const dtn::data::BundleID &id)
Definition: MetaBundle.cpp:34
static void raise(const dtn::data::MetaBundle &meta, REASON_CODE reason=DELIVERED)
dtn::storage::BundleStorage & getStorage()
Definition: BundleCore.cpp:237
const block_t & getType() const
Definition: Block.h:73
iterator end()
Definition: Bundle.cpp:54
WallClock & getClock()
Definition: BundleCore.cpp:255
static dtn::data::Length max_lifetime
Definition: BundleCore.h:164
static bool isExpired(const dtn::data::Timestamp &timestamp, const dtn::data::Number &lifetime)
Definition: Clock.cpp:155
void decrypt(dtn::data::Bundle &bundle) const
void set(FLAGS flag, bool value)
dtn::data::EID source
Definition: BundleID.h:53
static void raise(const dtn::data::EID &peer, const dtn::data::Bundle &bundle, const bool local=false)
static BundleCore & getInstance()
Definition: BundleCore.cpp:82
void setPrimaryBlock(const dtn::data::PrimaryBlock &data)
std::set< ibrcommon::vinterface > getInternetDevices() const