IBR-DTN  1.0.0
Debugger.cpp
Go to the documentation of this file.
1 /*
2  * Debugger.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 "Debugger.h"
23 #include <ibrcommon/Logger.h>
24 #include <sstream>
25 
26 namespace dtn
27 {
28  namespace daemon
29  {
31  {
32  // do not print anything if debugging is disabled
33  if (ibrcommon::Logger::getVerbosity() < 1) return;
34 
35  std::stringstream ss_blocks;
36 
37  for (dtn::data::Bundle::const_iterator iter = b.begin(); iter != b.end(); ++iter)
38  {
39  const dtn::data::Block &block = (**iter);
40  ss_blocks << "[T=" << (unsigned int)block.getType() << ";F=" << block.getProcessingFlags().get<size_t>() << ";LEN=" << block.getLength() << ";]";
41  }
42 
43  IBRCOMMON_LOGGER_DEBUG_TAG("Debugger", 1) << "F=" << b.procflags.get<size_t>() <<
44  ";SRC=" << b.source.getString() <<
45  ";DST=" << b.destination.getString() <<
46  ";RPT=" << b.reportto.getString() <<
47  ";CSD=" << b.custodian.getString() <<
48  ";TS=" << b.timestamp.get<size_t>() <<
49  ";SQ=" << b.sequencenumber.get<size_t>() <<
50  ";LT=" << b.lifetime.get<size_t>() <<
51  ";FO=" << b.fragmentoffset.get<size_t>() <<
52  ";AL=" << b.appdatalength.get<size_t>() <<
53  ";" << ss_blocks.str() <<
54  IBRCOMMON_LOGGER_ENDL;
55  }
56  }
57 }
Bitset< FLAGS > procflags
Definition: PrimaryBlock.h:118
void callbackBundleReceived(const Bundle &b)
Definition: Debugger.cpp:30
dtn::data::Timestamp timestamp
Definition: BundleID.h:54
iterator begin()
Definition: Bundle.cpp:49
dtn::data::Number sequencenumber
Definition: BundleID.h:55
block_list::const_iterator const_iterator
Definition: Bundle.h:77
T get() const
Definition: SDNV.h:113
virtual Length getLength() const =0
std::string getString() const
Definition: EID.cpp:374
const Bitset< ProcFlags > & getProcessingFlags() const
Definition: Block.cpp:87
const block_t & getType() const
Definition: Block.h:73
iterator end()
Definition: Bundle.cpp:54
dtn::data::Number fragmentoffset
Definition: BundleID.h:57
dtn::data::EID source
Definition: BundleID.h:53