[Click] Elements handlers

Eddie Kohler kohler at cs.ucla.edu
Mon Mar 14 15:00:51 EST 2005


Marko,

THis was a great idea.  Thanks for the patch!  But I just made it so 
the regular old READ argument could take optional parameters.  Checked 
in.

E


On Mar 11, 2005, at 5:36 PM, 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
>
>
> <readparam.diff>_______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click



More information about the click mailing list