simple_action() function
Brecht Vermeulen
brecht.vermeulen at rug.ac.be
Tue Mar 26 09:21:38 EST 2002
Hi Juan Luis,
I don't know where it is written in the documentation, but looking in
the source code (the ultimate manual :-) )
in lib/element.cc (Element is base class of each element)
void
Element::push(int, Packet *p)
{
p = simple_action(p);
if (p) output(0).push(p);
}
Packet *
Element::pull(int)
{
Packet *p = input(0).pull();
if (p) p = simple_action(p);
return p;
}
Packet *
Element::simple_action(Packet *p)
{
return p;
}
so, you see exactly what happens if you only implement simple_action and
then a push or pull is called on your element. It is mostly used indeed
for agnostic elements with only 1 input and 1 output port and it doesn't
matter if a push or a pull is called then on that element. The default
action for simple_action is just returning the same packet.
So, in a simple_action, you just do something with the packet and return
it (don't push it e.g. to another port, except when that is an *extra*
push which has to be done always). Look e.g. at the counter element or
other examples.
regards,
Brecht
Juan Luis Baptiste wrote:
>
> Hi,
>
> Looking at the programming manual at Element Runtime chapter I see that there's another method for packet transfer, simple_action, but there's no description. For what is it? because FtpPortMapper uses it instead of pull or push methods. I think I read somewhere that it's used for agnostic proccessing but I'm not sure, and I can't remember where I read it.
>
> Bye
>
> Juan Luis
> --
>
> Get your free email from www.linuxmail.org
>
> Powered by Outblaze
More information about the click
mailing list