[Click] Questions using click read/write handlers

betamaz betamaz at gmail.com
Thu Jun 2 17:03:45 EDT 2005


Hi,

I have created an linuxmodule element with a handler called "traffic" that 
is both read and write. I successfully write some data using read handler to 
traffic_handler. How do I read that data back out using the handlers? All 
the elements I've looked at never read data out of these click-made 
handlers. They just access/set the global variables of the classes element. 
My goal is to read and write data to a click-created file or to a user 
defined file. 

Below is a piece of what the element. For now, the read_handler gets one ip 
address from get_ips() . The ip gets written to "traffic". It doesnt seem to 
me that click's handlers can be used to read data from the created virtual 
files. If so, what other method can I user? 

String
UDPTrafficFlows::get_ips() const
{
StringAccum sa;
Entry e;
e.addr = _sipaddr;
sa << e << '\n';
return sa.take_string();
}

static String 
UDPTrafficFlows_traffic_handler
(Element *e, void *)
{
UDPTrafficFlows *u = static_cast <UDPTrafficFlows*>(e);
String str = u->get_ips();
return str;
}

void
UDPTrafficFlows::add_handlers()
{
. . .
. . .
add_read_handler("traffic", UDPTrafficFlows_traffic_handler, 0);
add_write_handler("traffic", UDPTrafficFlows_traffic_handler, 0);
}

Thank you,
Bita.


More information about the click mailing list