[Click] using handlers

Eddie Kohler kohler at cs.ucla.edu
Mon Mar 27 11:31:56 EST 2006


Hi,

> String rate_str = HandlerCall::call_read(Element *ComparePackets,"diffs",
> errh);

This is not correct C++ code.  You are mixing declaration syntax and normal code.

If you really want to look for an upstream ComparePackets element, take a look 
at the elements/aqm/red.cc element's initialize() mehtod.  You will want to 
call something like:

#include <click/elemfilter.hh>

...

   CastElementFilter filter("ComparePackets");
   Vector<Element *> results;
   int ok = router()->upstream_elements(this, 0, &filter, results);
   if (ok < 0)
      /* return error */;
   filter.filter(results);
   if (results.size() != 1)
      /* return error */;
   ComparePackets *what_you_want = (ComparePackets *) results[0];

   // now call the handler
   String rate_str = HandlerCall::call_read(what_you_want, "diffs", errh);

But the other approach, of requiring the user to name the element, works too.

Another potential issue: You cannot call handlers in the configure() method; 
they don't exist yet.  Call them in the initialize() method at the earliest.

Eddie


> unsigned different;
> (void) cp_unsigned(cp_uncomment(rate_str), &different);
> 
> .....
> 
> I have put this code in the configure part of my element. However I keep
> recieving the below error when tryin to compile the element.
> 
> 
> tosunqueue.cc: In member function `virtual int
>    TOSUnqueue::configure(Vector<String>&, ErrorHandler*)':
> tosunqueue.cc:51: error: parse error before `*' token
> make: *** [tosunqueue.uo] Error 1
> 
> Can anyone help me with this error?
> 
> It is quite urgent i get this working as quickly as possibe so a quick
> response would be greatly appreciated.
> 
> Thanks
> 
> Ian
> 
> 
> 
> 
> 
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click


More information about the click mailing list