dtn::data::Timestamp Clock::getExpireTime(const dtn::data::Bundle &b) { if ((b.timestamp == 0) || dtn::utils::Clock::isBad()) { // use the AgeBlock to verify the age try { const dtn::data::AgeBlock &agebl = b.find<const dtn::data::AgeBlock>(); dtn::data::Number seconds_left = 0; if (b.lifetime > agebl.getSeconds()) { seconds_left = b.lifetime - agebl.getSeconds(); } return getTime() + seconds_left; } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { }; return __getExpireTime(getTime(), b.lifetime); } return __getExpireTime(b.timestamp, b.lifetime); }
bool Clock::isExpired(const dtn::data::Timestamp ×tamp, const dtn::data::Number &lifetime) { // can not check invalid timestamp // assume bundle has an age block and trust on later checks if (timestamp == 0) return false; // disable expiration if clock rating is too bad if (getRating() == 0.0) return false; return Clock::getTime() > __getExpireTime(timestamp, lifetime); }
size_t Clock::getExpireTime(const dtn::data::Bundle &b) { if ((b._timestamp == 0) || dtn::utils::Clock::badclock) { // use the AgeBlock to verify the age try { const dtn::data::AgeBlock &agebl = b.getBlock<const dtn::data::AgeBlock>(); size_t seconds_left = b._lifetime - agebl.getSeconds(); return getTime() + seconds_left; } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { }; } return __getExpireTime(b._timestamp, b._lifetime); }
dtn::data::Timestamp Clock::getExpireTime(const dtn::data::Bundle &b) { if (b.timestamp == 0) { try { // use the AgeBlock to verify the age const dtn::data::AgeBlock &agebl = b.find<dtn::data::AgeBlock>(); dtn::data::Number seconds_left = 0; if (b.lifetime > agebl.getSeconds()) { seconds_left = b.lifetime - agebl.getSeconds(); } return getTime() + seconds_left; } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { // if there is no AgeBlock this bundle is not valid return 0; } } return __getExpireTime(b.timestamp, b.lifetime); }
dtn::data::Timestamp Clock::getExpireTime(const dtn::data::Number &lifetime) { return __getExpireTime(getTime(), lifetime); }
size_t Clock::getExpireTime(size_t lifetime) { return __getExpireTime(getTime(), lifetime); }
size_t Clock::getExpireTime(size_t timestamp, size_t lifetime) { return __getExpireTime(timestamp, lifetime); }