|
Click
|
Public Member Functions | |
| bool | active () const |
| Returns whether this port is active (a push output or a pull input). | |
| Element * | element () const |
| Returns the element connected to this active port. | |
| int | port () const |
| Returns the port number of the port connected to this active port. | |
| void | push (Packet *p) const |
| Push packet p over this port. | |
| Packet * | pull () const |
| Pull a packet over this port and return it. | |
| void | assign_peer (bool isoutput, Element *e, int port, bool unstack=false) |
An Element's ports.
Each of an element's ports has an associated Port object, accessible via the Element::port(), Element::input(), and Element::output() functions. Each active port knows, and can transfer a packet with, the single complementary port to which it is connected. Thus, each push output knows its connected input, and can push a packet there; and each pull input can pull a packet from its connected output. Inactive ports – push inputs and pull outputs – can be connected multiple times. Their corresponding Port objects have very little functionality.
Element authors generally encounter Port objects only in two stylized formulations. First, to push a packet p out on push output port i:
And second, to pull a packet p from pull input port i:
|
inline |
Returns whether this port is active (a push output or a pull input).
|
inline |
Returns the element connected to this active port.
Returns 0 if this port is not active().
|
inline |
Returns the port number of the port connected to this active port.
Returns < 0 if this port is not active().
|
inline |
Push packet p over this port.
Pushes packet p downstream through the router configuration by passing it to the next element's push() function. Returns when the rest of the router finishes processing p.
This port must be an active() push output port. Usually called from element code like output(i) .push(p).
When element code calls Element::Port::push(p), it relinquishes control of packet p. When push() returns, p may have been altered or even freed by downstream elements. Thus, you must not use p after pushing it downstream. To push a copy and keep a copy, see Packet::clone().
output(i).push(p) basically behaves like the following code, although it maintains additional statistics depending on how CLICK_STATS is defined:
|
inline |
Pull a packet over this port and return it.
Pulls a packet from upstream in the router configuration by calling the previous element's pull() function. When the router finishes processing, returns the result.
This port must be an active() pull input port. Usually called from element code like input(i) .pull().
input(i).pull() basically behaves like the following code, although it maintains additional statistics depending on how CLICK_STATS is defined: