Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		bool Clock::isExpired(const dtn::data::Timestamp &timestamp, 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);
		}
Exemplo n.º 3
0
		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);
		}
Exemplo n.º 4
0
		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);
		}
Exemplo n.º 5
0
		dtn::data::Timestamp Clock::getExpireTime(const dtn::data::Number &lifetime)
		{
			return __getExpireTime(getTime(), lifetime);
		}
Exemplo n.º 6
0
		size_t Clock::getExpireTime(size_t lifetime)
		{
			return __getExpireTime(getTime(), lifetime);
		}
Exemplo n.º 7
0
		size_t Clock::getExpireTime(size_t timestamp, size_t lifetime)
		{
			return __getExpireTime(timestamp, lifetime);
		}