50 const std::string StaticRoutingExtension::TAG =
"StaticRoutingExtension";
62 for (std::list<StaticRoute*>::iterator iter = _routes.begin();
63 iter != _routes.end(); ++iter)
81 : _entry(entry), _routes(routes)
84 virtual ~BundleFilter() {};
86 virtual dtn::data::Size limit()
const throw () {
return _entry.getFreeTransferSlots(); };
125 if (_entry.has(meta))
131 for (std::list<const StaticRoute*>::const_iterator iter = _routes.begin();
132 iter != _routes.end(); ++iter)
147 const std::list<const StaticRoute*> &_routes;
153 for (std::multimap<std::string, std::string>::const_iterator iter = routes.begin(); iter != routes.end(); ++iter)
164 std::list<const StaticRoute*> routes;
167 Task *t = _taskqueue.getnpop(
true);
168 std::auto_ptr<Task> killer(t);
173 SearchNextBundleTask &task =
dynamic_cast<SearchNextBundleTask&
>(*t);
179 for (std::list<StaticRoute*>::const_iterator iter = _routes.begin();
180 iter != _routes.end(); ++iter)
186 routes.push_back(route);
203 BundleFilter filter(entry, routes);
210 (**this).getSeeker().get(filter, list);
214 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
225 }
catch (
const std::bad_cast&) { };
228 const ProcessBundleTask &task =
dynamic_cast<ProcessBundleTask&
>(*t);
232 for (std::list<StaticRoute*>::const_iterator iter = _routes.begin();
233 iter != _routes.end(); ++iter)
238 if (route.
match(task.bundle.destination))
248 }
catch (
const std::bad_cast&) { };
251 const RouteChangeTask &task =
dynamic_cast<RouteChangeTask&
>(*t);
254 for (std::list<StaticRoute*>::iterator iter = _routes.begin();
255 iter != _routes.end();)
258 if (route->
toString() == task.route->toString())
261 _routes.erase(iter++);
269 if (task.type == RouteChangeTask::ROUTE_ADD)
271 _routes.push_back(task.route);
272 _taskqueue.push(
new SearchNextBundleTask(task.route->getDestination()) );
275 if (next_expire > task.route->getExpiration())
277 next_expire = task.route->getExpiration();
288 }
catch (
const bad_cast&) { };
291 dynamic_cast<ClearRoutesTask&
>(*t);
294 for (std::list<StaticRoute*>::iterator iter = _routes.begin();
295 iter != _routes.end(); ++iter)
304 }
catch (
const bad_cast&) { };
307 const ExpireTask &task =
dynamic_cast<ExpireTask&
>(*t);
313 for (std::list<StaticRoute*>::iterator iter = _routes.begin();
314 iter != _routes.end();)
321 _routes.erase(iter++);
325 if ((next_expire == 0) || (next_expire > route->
getExpiration()))
333 }
catch (
const bad_cast&) { };
335 }
catch (
const std::exception &ex) {
348 _taskqueue.push(
new ProcessBundleTask(queued.
bundle, queued.
origin) );
350 }
catch (
const std::bad_cast&) { };
358 _taskqueue.push(
new SearchNextBundleTask(n.
getEID()) );
362 _taskqueue.push(
new SearchNextBundleTask( n.
getEID() ) );
366 }
catch (
const std::bad_cast&) { };
374 _taskqueue.push(
new SearchNextBundleTask(ce.
peer) );
377 }
catch (
const std::bad_cast&) { };
382 _taskqueue.push(
new SearchNextBundleTask(aborted.
getPeer()) );
384 }
catch (
const std::bad_cast&) { };
389 _taskqueue.push(
new SearchNextBundleTask(completed.
getPeer()) );
391 }
catch (
const std::bad_cast&) { };
403 }
catch (
const bad_cast&) { };
411 _taskqueue.push(
new ClearRoutesTask() );
417 if (route.
pattern.length() > 0)
435 _taskqueue.push(
new RouteChangeTask( RouteChangeTask::ROUTE_ADD, r ) );
439 _taskqueue.push(
new RouteChangeTask( RouteChangeTask::ROUTE_DEL, r ) );
447 }
catch (
const bad_cast&) { };
477 : _nexthop(nexthop), _match(match), expiretime(et)
481 StaticRoutingExtension::EIDRoute::~EIDRoute()
485 bool StaticRoutingExtension::EIDRoute::match(
const dtn::data::EID &eid)
const
487 return (_match == eid.
getNode());
490 const dtn::data::EID& StaticRoutingExtension::EIDRoute::getDestination()
const
499 const std::string StaticRoutingExtension::EIDRoute::toString()
const
501 std::stringstream ss;
502 ss << _match.
getString() <<
" => " << _nexthop.getString();
513 StaticRoutingExtension::SearchNextBundleTask::SearchNextBundleTask(
const dtn::data::EID &e)
517 StaticRoutingExtension::SearchNextBundleTask::~SearchNextBundleTask()
520 std::string StaticRoutingExtension::SearchNextBundleTask::toString()
522 return "SearchNextBundleTask: " + eid.
getString();
528 : bundle(meta), origin(o)
531 StaticRoutingExtension::ProcessBundleTask::~ProcessBundleTask()
534 std::string StaticRoutingExtension::ProcessBundleTask::toString()
536 return "ProcessBundleTask: " + bundle.toString();
541 StaticRoutingExtension::ClearRoutesTask::ClearRoutesTask()
545 StaticRoutingExtension::ClearRoutesTask::~ClearRoutesTask()
549 std::string StaticRoutingExtension::ClearRoutesTask::toString()
551 return "ClearRoutesTask";
556 StaticRoutingExtension::RouteChangeTask::RouteChangeTask(CHANGE_TYPE t, StaticRoute *r)
562 StaticRoutingExtension::RouteChangeTask::~RouteChangeTask()
567 std::string StaticRoutingExtension::RouteChangeTask::toString()
569 return "RouteChangeTask: " + (*route).toString();
580 StaticRoutingExtension::ExpireTask::~ExpireTask()
585 std::string StaticRoutingExtension::ExpireTask::toString()
587 std::stringstream ss;
588 ss <<
"ExpireTask: " << timestamp.toString();