[Click] Errors trying to get arguments in my element

Fabrice Schuler fabrice.schuler at inrialpes.fr
Thu Mar 24 12:35:40 EDT 2011


  Hello,

I'm writing a basic element, which I'd like to get 2 elements, unsigned 
int to be precised. I had a look to the doxygen and to ipencap.xx and 
etherencap.xx files, but I'm facing problems with the handlers...
Could anyone give me some clues about my mistakes ?

My first problem is that I could not successfully write a function 
read_handler that would return an unsigned int.
And probably some other problems, but I could not find them. I think the 
configure function is right (thanks to documentation), but even that I'm 
not sure.

Here is the configure function (ip_src and ip_dst are private unsigned) : |
|
int
XorEncap::configure (Vector<String> &conf, ErrorHandler *errh)
{
     int return_value;

     if (cp_va_kparse (conf, this, errh,
                 "SRC", cpkM+cpkP, cpUnsigned, &ip_src,
                 "DST", cpkM+cpkP, cpUnsigned, &ip_dst,
                 cpEnd) < 0)
     {
         return_value = -1;
     }
     else
     {
         return_value = 0;
     }
     return return_value;
}


And here are my problems with the handlers :

String
XorEncap::read_handler(Element *e, void *thunk)
{
     XorEncap *xe = static_cast<XorEncap *>(e);

         std::cout << "in read_handler \n" ;

     switch ((intptr_t)thunk)
     {
         case 0:  return (xe->ip_src);
         case 1:  return (xe->ip_dst);
         default: return "<error>";
     }
}

     void
XorEncap::add_handlers(void)
{
         std::cout << "in add_handler \n" ;

     add_read_handler("src", read_handler, (void*)0);
     add_write_handler("src", reconfigure_keyword_handler, "1 SRC");
     add_read_handler("dst", read_handler, (void*)1);
     add_write_handler("dst", reconfigure_keyword_handler, "2 DST");
}



Thanks for your answers,
Fabrice





More information about the click mailing list