|
IBR-DTNSuite 0.6
|
00001 /* 00002 * MetaBundle.cpp 00003 * 00004 * Created on: 16.02.2010 00005 * Author: morgenro 00006 */ 00007 00008 #ifndef METABUNDLE_CPP_ 00009 #define METABUNDLE_CPP_ 00010 00011 #include "ibrdtn/data/MetaBundle.h" 00012 #include "ibrdtn/utils/Clock.h" 00013 #include "ibrdtn/data/ScopeControlHopLimitBlock.h" 00014 #include <limits> 00015 00016 namespace dtn 00017 { 00018 namespace data 00019 { 00020 MetaBundle::MetaBundle() 00021 : BundleID(), received(), lifetime(0), destination(), reportto(), 00022 custodian(), appdatalength(0), procflags(0), expiretime(0), hopcount(std::numeric_limits<std::size_t>::max()) 00023 { 00024 } 00025 00026 MetaBundle::MetaBundle(const dtn::data::BundleID &id) 00027 : BundleID(id), received(), lifetime(0), destination(), reportto(), 00028 custodian(), appdatalength(0), procflags(0), expiretime(0), hopcount(std::numeric_limits<std::size_t>::max()) 00029 { 00030 } 00031 00032 MetaBundle::MetaBundle(const dtn::data::Bundle &b) 00033 : BundleID(b), lifetime(b._lifetime), destination(b._destination), reportto(b._reportto), 00034 custodian(b._custodian), appdatalength(b._appdatalength), procflags(b._procflags), expiretime(0), hopcount(std::numeric_limits<std::size_t>::max()) 00035 { 00036 expiretime = dtn::utils::Clock::getExpireTime(b); 00037 00041 try { 00042 const dtn::data::ScopeControlHopLimitBlock &schl = b.getBlock<const dtn::data::ScopeControlHopLimitBlock>(); 00043 hopcount = schl.getHopsToLive(); 00044 } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { }; 00045 } 00046 00047 MetaBundle::~MetaBundle() 00048 {} 00049 00050 int MetaBundle::getPriority() const 00051 { 00052 // read priority 00053 if (procflags & dtn::data::Bundle::PRIORITY_BIT1) 00054 { 00055 return 0; 00056 } 00057 00058 if (procflags & dtn::data::Bundle::PRIORITY_BIT2) 00059 { 00060 return 1; 00061 } 00062 00063 return -1; 00064 } 00065 00066 bool MetaBundle::get(dtn::data::PrimaryBlock::FLAGS flag) const 00067 { 00068 return (procflags & flag); 00069 } 00070 } 00071 } 00072 00073 #endif /* METABUNDLE_CPP_ */