예제 #1
0
		bool ForwardingStrategy::isBackrouteValid(const DeliveryPredictabilityMap& neighbor_dpm, const dtn::data::EID& source) const
		{
			ibrcommon::MutexLock dpm_lock(_prophet_router->_deliveryPredictabilityMap);

			// check if we know a way to the source
			try {
				if (_prophet_router->_deliveryPredictabilityMap.get(source.getNode()) > 0.0) return true;
			} catch (const dtn::routing::DeliveryPredictabilityMap::ValueNotFoundException&) { }

			// check if the peer know a way to the source
			try {
				if (neighbor_dpm.get(source.getNode()) > 0.0) return true;
			} catch (const dtn::routing::DeliveryPredictabilityMap::ValueNotFoundException&) { }

			return false;
		}
예제 #2
0
		bool ForwardingStrategy::neighborDPIsGreater(const DeliveryPredictabilityMap& neighbor_dpm, const dtn::data::EID& destination) const
		{
			const dtn::data::EID destnode = destination.getNode();

			try {
				float local_pv = 0.0f;

				// get the local value
				{
					ibrcommon::MutexLock dpm_lock(_prophet_router->_deliveryPredictabilityMap);
					const DeliveryPredictabilityMap& dp_map = _prophet_router->_deliveryPredictabilityMap;
					local_pv = dp_map.get(destnode);
				}

				try {
					// retrieve the value from the DeliveryPredictabilityMap of the neighbor
					float foreign_pv = neighbor_dpm.get(destnode);

					return (foreign_pv > local_pv);
				} catch (const DeliveryPredictabilityMap::ValueNotFoundException&) {
					// if the foreign router has no entry for the destination
					// then compare the local value with a fictitious initial value
					return (_prophet_router->_p_first_threshold > local_pv);
				}
			} catch (const DeliveryPredictabilityMap::ValueNotFoundException&) {
				// always forward if the destination is not in our own predictability map
			}

			return false;
		}
		KeyExchangeSession::KeyExchangeSession(int protocol, const dtn::data::EID &peer, unsigned int uniqueId, SessionState *state)
		: _protocol(protocol), _unique_id(uniqueId), _peer(peer.getNode()), _state(state), _expiration(0)
		{
			// generate session key
			_session_key = getSessionKey(_peer, _unique_id);

			// set a expiration time (10 minutes)
			_expiration = dtn::utils::Clock::getMonotonicTimestamp() + 600;
		}
		dtn::security::SecurityKey SecurityKeyManager::get(const dtn::data::EID &ref, const dtn::security::SecurityKey::KeyType type) const throw (SecurityKey::KeyNotFoundException)
		{
			dtn::security::SecurityKey keydata;
			keydata.reference = ref.getNode();
			keydata.type = type;
			keydata.file = getKeyFile(keydata.reference, type);

			// load security key
			load(keydata);

			return keydata;
		}
void dtn::dht::DHTNameService::lookup(const dtn::data::EID &eid) {
	if (!dtn::core::BundleCore::local.sameHost(eid)) {
		if (this->_announced) {
			std::string eid_ = eid.getNode().getString();
			IBRCOMMON_LOGGER_DEBUG_TAG("DHTNameService", 30) << "DHT Lookup: " << eid_
						<< IBRCOMMON_LOGGER_ENDL;
			ibrcommon::MutexLock l(this->_libmutex);
			dtn_dht_lookup(&_context, eid_.c_str(), eid_.size());
		} else {
			this->cachedLookups.push_front(eid);
		}
	}
}
예제 #6
0
		void KeyExchangeEvent::raise(const dtn::data::EID &eid, const dtn::security::KeyExchangeData &data)
		{
			// raise the new event
			dtn::core::EventDispatcher<KeyExchangeEvent>::queue( new KeyExchangeEvent(eid.getNode(), data) );
		}