-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eddie Kohler wrote:
> Hi Harald,
>
> Click elements don't know what element(s) are connected to a push input
> port, or a pull output port. This is because it is valid for one or
> more elements to connect there.
>
> So if e->input_is_push(i), then e->input(i).element() == 0.
>
> To find the element or elements connected to a push input port, use
> Router functions to traverse the element graph. I've just checked in a
> rework of this functionality that should help you. On current mainline,
> you could say:
>
> #include <click/routervisitor.hh>
> ...
> ElementNeighborTracker tracker(router());
> router()->visit_upstream(this, 0, &tracker);
> tracker.elements() // is a vector containing exactly those elements
> // that are connected to [0]this
>
> Does this make sense?
Thanks a lot, works and makes perfect sense.
attached a small patch that I found very useful when using that stuff...
Harald
- --
Harald Schiöberg
Technische Universität Berlin | T-Laboratories | FG INET
www: http://www.net.t-labs.tu-berlin.de
Phone: +49-(0)30-8353-58476 | Fax: +49-(0)391 534 783 47
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFK9/kNy8wrZ9OvkU0RAhdPAJ9AsxLZpBnJGxxcZ7lbj7AiDcy6NQCgvliE
B0JdVik2y+79tH655btbJBI=
=zGnz
-----END PGP SIGNATURE-----
diff --git a/include/click/routervisitor.hh b/include/click/routervisitor.hh
index 47ccda9..15bf8ff 100644
--- a/include/click/routervisitor.hh
+++ b/include/click/routervisitor.hh
@@ -105,7 +105,10 @@ class ElementTracker : public RouterVisitor { public:
_elements.push_back(e);
}
}
-
+ /** @brief Remove all elements from the tracker
+ @return the number of elements previously in the tracker
+ */
+ int clear();
private:
Bitvector _reached;
diff --git a/lib/routervisitor.cc b/lib/routervisitor.cc
index b2a8864..c10553d 100644
--- a/lib/routervisitor.cc
+++ b/lib/routervisitor.cc
@@ -31,6 +31,16 @@ RouterVisitor::visit(Element *, bool, int, Element *, int, int)
return true;
}
+int
+ElementTracker::clear(){
+
+ int retval = _elements.size();
+ _elements.clear();
+ _reached.clear();
+ return retval;
+}
+
+
ElementTracker::ElementTracker(Router *router)
: _reached(router->nelements(), false)
{
_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click