[Click] How to call handlers of elements declared in a .click file from another element.

Beyers Cronje bcronje at gmail.com
Sun Jun 16 16:49:12 EDT 2013


Hi,

I think you can only call router()->find() from the initialize and later
state, so you are probably calling this during constructor or configure
phase?

The are a number of ways to gain access to other elements inside your code:

1) Use Router::find() or Router::visit_upstream() or
Router::visit_downstream(). Here are a couple of examples how this is used,
see the initialize functions:
https://github.com/kohler/click/blob/5c0455ad6400007ae7eaa41d689918f5635ff79a/elements/local/tcpconn.cc
https://github.com/kohler/click/blob/5c0455ad6400007ae7eaa41d689918f5635ff79a/etc/ron/discardnotify.cc

2) You can pass an element as an argument inside you click configuration
file to another element. You read this argument in the configure() function
and get a pointer to the element. Use ElementArg(). See following for
example of cp_element:
https://github.com/kohler/click/blob/5c0455ad6400007ae7eaa41d689918f5635ff79a/elements/analysis/aggregateipflows.cc

3) Pass in the handler as configuration argument. Use HandlerCall class:
https://github.com/kohler/click/blob/5c0455ad6400007ae7eaa41d689918f5635ff79a/include/click/handlercall.hh

Hope this helps.

Beyers



On Sun, Jun 16, 2013 at 8:05 PM, Momina Khan <momina.azam at gmail.com> wrote:

> Hi,
>
> I need to call live_reconfigure handlers of elements A and B (to
> differentiate) declared in my configuration file from inside another
> element C.
>
> element C has to call live_reconfigure on elements A and C periodically
> after every timescale x. However i cannot seem to find a way to give the
> references of classes A and B to class C. Since all are independently
> declared in the .click configuration file.
>
> I tried element->router() and thought that if i got the router reference
> pointer i could find other elements registered with the same router using
> the router->find() method but element->router() returns a NULL.
> If i am thinking in the wrong direction plz correct me.
>
> thank you!
> momina
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list