[Click] Elements handlers

Eddie Kohler kohler at cs.ucla.edu
Mon Mar 14 14:44:32 EST 2005


Hi Rafael,

We use the "doc/mkwebdoc.pl" script, checked in to the CVS repo (but  
not distributed), to generate the HTML tree visible under  
www.pdos.lcs.mit.edu/click/doc.  Maybe that will be useful.  It in turn  
depends on a "man2html" script, also checked in under doc/.

Eddie


On Mar 13, 2005, at 12:46 PM, Rafael Paoliello Guimaraes wrote:

> Hello again,
>
> I have just did a "make install-doc" and I was able to generate man  
> pages for my new elements. However, I still don't know how to generate  
> the HTML pages... How can I do it?
>
> Cheers,
>
> ===========================================
>  Rafael Paoliello Guimaraes
>  PhD Student - Computer Networking Group
>  Department of Computer Architecture (DAC)
>  Polytechnic University of Catalonia (UPC)
>  Phone: +34-934017187   Fax: +34-934017055
>  URL: http://people.ac.upc.es/rpaoliel
> ===========================================
>
>
> Rafael Paoliello Guimaraes wrote:
>> That works perfectly! Thank you very much...
>> But I still have one doubt about generating documentation for new  
>> elements. I have written all the documentation according to  
>> elementdoc manpage, however, I don't know how to generate the HTML  
>> pages from that. I have tried to use the "click-elem2man" script but  
>> I had no success. This is what I have tried:
>> click-elem2man -f ../elements/local/myelement.hh
>> click-elem2man -d ../elements/local -f myelement.hh
>> click-elem2man -d ../elements/local
>> But with any of the above options, I always get the following error:
>> Use of uninitialized value in concatenation (.) or string at  
>> /usr/local/bin/click-elem2man line 640.
>> What am I doing wrong?
>> Cheers,
>> ===========================================
>>  Rafael Paoliello Guimaraes
>>  PhD Student - Computer Networking Group
>>  Department of Computer Architecture (DAC)
>>  Polytechnic University of Catalonia (UPC)
>>  Phone: +34-934017187   Fax: +34-934017055
>>  URL: http://people.ac.upc.es/rpaoliel
>> ===========================================
>> Marko Zec wrote:
>>> On Friday 11 March 2005 14:24, Rafael Paoliello Guimaraes wrote:
>>>> Ok... But this will just print the result. And I want to return the
>>>> result, not to print it. Just like what it is done by read
>>>> handlers... But the only difference with respect to read handlers is
>>>> that I want to pass some arguments to this handler.
>>>
>>>
>>> Hi Rafael,
>>>
>>> can you try the attached patch, it introduces the "readparam"  
>>> handler access method for the userspace click.  It should allow you  
>>> to do things like this:
>>>
>>> tpx30% telnet localhost 4444
>>> ...
>>> Click::ControlSocket/1.1
>>> readparam rt.lookup 1.2.3.5
>>> 200 Read handler 'rt.lookup' OK
>>> DATA 10
>>> 3 5.6.7.8
>>>
>>> Take a look at lookup_handler() in elements/ip/iproutetable.cc as an  
>>> example on how to implement read handlers that accept arguments.   
>>> OTOH, I'm not sure if/how we could support such a "parameterized"  
>>> read model in the kernel-space click using the filesystem  
>>> interface...
>>>
>>> Hope this helps,
>>>
>>> Marko
>>>
>>>
>>>
>>>> Cheers,
>>>>
>>>> ===========================================
>>>>  Rafael Paoliello Guimaraes
>>>>  PhD Student - Computer Networking Group
>>>>  Department of Computer Architecture (DAC)
>>>>  Polytechnic University of Catalonia (UPC)
>>>>  Phone: +34-934017187   Fax: +34-934017055
>>>>  URL: http://people.ac.upc.es/rpaoliel
>>>> ===========================================
>>>>
>>>> Beyers Cronje wrote:
>>>>> PS When I say "return the results" I meant via click_chatter().
>>>>>
>>>>> -----Original Message-----
>>>>> From: Beyers Cronje
>>>>> Sent: Friday, March 11, 2005 3:09 PM
>>>>> To: 'Rafael Paoliello Guimaraes'
>>>>> Cc: click at amsterdam.lcs.mit.edu
>>>>> Subject: RE: [Click] Elements handlers
>>>>>
>>>>>
>>>>> Hi Rafael,
>>>>>
>>>>> A standard Write handler should do the trick. Just pass the
>>>>> argument the your "routes" handler and do the neccesary lookups
>>>>> inside your handler routine and return the results.
>>>>>
>>>>> Beyers
>>>>>
>>>>> -----Original Message-----
>>>>> From: click-bounces at amsterdam.lcs.mit.edu
>>>>> [mailto:click-bounces at amsterdam.lcs.mit.edu]On Behalf Of Rafael
>>>>> Paoliello Guimaraes
>>>>> Sent: Friday, March 11, 2005 2:31 PM
>>>>> To: Marko Zec
>>>>> Cc: click at amsterdam.lcs.mit.edu
>>>>> Subject: Re: [Click] Elements handlers
>>>>>
>>>>>
>>>>> Ok, I know this. I have done this with read handlers and write
>>>>> handlers... I have even read that if I want a read/write handler, I
>>>>> should register two handlers with the same name, one for write and
>>>>> one for read. But my case is different. I want to register a
>>>>> handler that is read and write at the same time. For example, in
>>>>> the LinearIPLookup table there is a read handler called "table"
>>>>> that simply returns the routing table. Well, suppose I wanted to
>>>>> provide an additional handler (routes) that given a destination
>>>>> address, would return the entries on the routing table that could
>>>>> be use to route data to this address... How thid could be done?
>>>>>
>>>>> Example:
>>>>>
>>>>> if the routing table is:
>>>>>
>>>>> DST           OUT
>>>>> 10.0.2.0/24   1
>>>>> 20.7.4.0/24   2
>>>>> 10.0.0.0/16   1
>>>>>
>>>>> if I called this new handler like this: routes(10.0.2.1)
>>>>> it would return me the following string:
>>>>>
>>>>> 10.0.2.0/24   1
>>>>> 10.0.0.0/16   1
>>>>>
>>>>> Is it possible to be implemented (or is there any alternative way
>>>>> to do this), or would I have to modify the Element class?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> ===========================================
>>>>>  Rafael Paoliello Guimaraes
>>>>>  PhD Student - Computer Networking Group
>>>>>  Department of Computer Architecture (DAC)
>>>>>  Polytechnic University of Catalonia (UPC)
>>>>>  Phone: +34-934017187   Fax: +34-934017055
>>>>>  URL: http://people.ac.upc.es/rpaoliel
>>>>> ===========================================
>>>>>
>>>>> Marko Zec wrote:
>>>>>> On Thursday 10 March 2005 21:22, Rafael Paoliello Guimaraes wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am writing some new Click elements and I have a doubt  
>>>>>>> concerning
>>>>>>> the handlers of an element. I have seen read handler and write
>>>>>>> handlers implemented, but I have not seen any read/write handler.
>>>>>>> Is there this possibility? I want the handler to return me a
>>>>>>> string based on some arguments I introduce.
>>>>>>>
>>>>>>> I have implemented the following handler:
>>>>>>>
>>>>>>> String
>>>>>>> MyElement::thehandler_handler(const String &conf_in, Element *e,
>>>>>>> void *thunk, ErrorHandler *errh)
>>>>>>>
>>>>>>>
>>>>>>> But I don't know how to add it to the element? Is this right? How
>>>>>>> should I do it?
>>>>>> The Element class provides the add_handlers() virtual function
>>>>>> which you may override to explicitely export custom handler hooks.
>>>>>> Just grep through existing elements for add_handlers...
>>>>>>
>>>>>> Marko
>>>>> _______________________________________________
>>>>> click mailing list
>>>>> click at amsterdam.lcs.mit.edu
>>>>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>>>> This is an email from Bytes Technology Group. It is confidential to
>>>>> the ordinary user of the email address to which it is addressed and
>>>>> may contain copyright and/or legally privileged information. No one
>>>>> else may read, print, store, copy, forward or act in reliance upon
>>>>> all or any part of it or its attachments. If you received this
>>>>> email in error please notify its sender.
>>>> _______________________________________________
>>>> click mailing list
>>>> click at amsterdam.lcs.mit.edu
>>>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>>
>>>
>>>
>>> --------------------------------------------------------------------- 
>>> ---
>>>
>>> diff --exclude CVS -rup  
>>> cvs/click/elements/userlevel/controlsocket.cc  
>>> click/elements/userlevel/controlsocket.cc
>>> --- cvs/click/elements/userlevel/controlsocket.cc    Thu Feb 24  
>>> 18:21:40 2005
>>> +++ click/elements/userlevel/controlsocket.cc    Sat Mar 12 02:10:29  
>>> 2005
>>> @@ -396,7 +396,7 @@ ControlSocket::parse_handler(int fd, con
>>>  }
>>>   int
>>> -ControlSocket::read_command(int fd, const String &handlername)
>>> +ControlSocket::read_command(int fd, const String &handlername,  
>>> const String &param)
>>>  {
>>>    Element *e;
>>>    const Handler* h = parse_handler(fd, handlername, &e);
>>> @@ -410,7 +410,11 @@ ControlSocket::read_command(int fd, cons
>>>    _proxied_handler = h->name();
>>>    _proxied_errh = &errh;
>>>    -  String data = h->call_read(e);
>>> +  String data;
>>> +  if (param)
>>> +    data = h->call_read(e, param);
>>> +  else
>>> +    data = h->call_read(e);
>>>     // did we get an error message?
>>>    if (errh.nerrors() > 0)
>>> @@ -587,7 +591,15 @@ ControlSocket::parse_command(int fd, con
>>>    if (command == "READ" || command == "GET") {
>>>      if (words.size() != 2)
>>>        return message(fd, CSERR_SYNTAX, "Wrong number of arguments");
>>> -    return read_command(fd, words[1]);
>>> +    return read_command(fd, words[1], NULL);
>>> +    +  } else if (command == "READPARAM" || command == "GETPARAM") {
>>> +    if (words.size() < 2)
>>> +      return message(fd, CSERR_SYNTAX, "Wrong number of arguments");
>>> +    String data;
>>> +    for (int i = 2; i < words.size(); i++)
>>> +      data += (i == 2 ? "" : " ") + words[i];
>>> +    return read_command(fd, words[1], data);
>>>         } else if (command == "WRITE" || command == "SET") {
>>>      if (words.size() < 2)
>>> diff --exclude CVS -rup  
>>> cvs/click/elements/userlevel/controlsocket.hh  
>>> click/elements/userlevel/controlsocket.hh
>>> --- cvs/click/elements/userlevel/controlsocket.hh    Thu Feb 24  
>>> 18:21:40 2005
>>> +++ click/elements/userlevel/controlsocket.hh    Sat Mar 12 02:00:19  
>>> 2005
>>> @@ -246,7 +246,7 @@ class ControlSocket : public Element { p
>>>       String proxied_handler_name(const String &) const;
>>>    const Handler* parse_handler(int fd, const String &, Element **);
>>> -  int read_command(int fd, const String &);
>>> +  int read_command(int fd, const String &, const String &);
>>>    int write_command(int fd, const String &, const String &);
>>>    int check_command(int fd, const String &, bool write);
>>>    int llrpc_command(int fd, const String &, String);
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click



More information about the click mailing list