[Click] Help! - Logging packets to /proc

Praveen Balasubramanian praveen_b at mail.utexas.edu
Thu Nov 23 19:01:05 EST 2006


Hi,

Thanks for the reply.

The following is what I have done (badly!)-

I have done the buffering in a custom queue inside the element.
The following is my handler:
add_read_handler("toproc_dump", read_handler, (void *)0);

In the push(int, Packet *p) method of my element, I buffer the pointers to the
packets.

Then in the read_handler() I am doing:
return String((const char *)p->data());
where p is one of the buffered pointers.

But when I try to cat /proc/myelement/toproc_dump, the output is empty string.
Am I missing something here, or p->data() cannot be cast to a String?

Thanks & Regards,
Praveen


Quoting Beyers Cronje <bcronje at gmail.com>:

> I have to note /click or /proc/click is merely an interface to the element,
> so 'logging' of packets will be a problem as your element will need to
> buffer the packets until a read is made on the handler.
>
> On 11/23/06, Beyers Cronje <bcronje at gmail.com> wrote:
> >
> > Hi Praveen,
> >
> > You can use read_handler. The first argument of your read handler is a
> > pointer to the element. As an example look at IPRouteTable element:
> >
> > String
> > IPRouteTable::table_handler(Element *e, void *)
> > {
> >     IPRouteTable *r = static_cast<IPRouteTable*>(e);
> >     return r->dump_routes();
> > }
> >
> > void
> > IPRouteTable::add_handlers()
> > {
> >     add_write_handler("add", add_route_handler, 0);
> >     add_write_handler("set", add_route_handler, (void*) 1);
> >     add_write_handler("remove", remove_route_handler, 0);
> >     add_write_handler("ctrl", ctrl_handler, 0);
> >     add_read_handler("table", table_handler, 0);
> >     set_handler("lookup", Handler::OP_READ | Handler::READ_PARAM |
> > Handler::ONE_HOOK, lookup_handler);
> > }
> >
> >
> > On 11/23/06, Praveen Balasubramanian <praveen_b at mail.utexas.edu> wrote:
> > >
> > > Hi all,
> > >
> > > I am using a Click router configuration in kernel mode.
> > > I want to add an element that logs packets in /proc. I tried using
> > > read_handler function (add_read_handler), but that is static and hence
> > > can't be used by multiple element instances.
> > > Should I add /proc handling code to the element or is there any way to
> > > use an existing Click interface to do the same?
> > >
> > > Regards,
> > > Praveen
> > > _______________________________________________
> > > click mailing list
> > > click at amsterdam.lcs.mit.edu
> > > https://amsterdam.lcs.mit.edu/mailman/listinfo/click
> > >
> >
> >
>





More information about the click mailing list