Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Element::Port Class Reference

An Element's ports. More...

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)
 

Detailed Description

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:

output(i).push(p);
void push(Packet *p) const
Push packet p over this port.
Definition element.hh:765
const Port & output(int port) const
Return one of the element's output ports.
Definition element.hh:591

And second, to pull a packet p from pull input port i:

Packet *p = input(i).pull();
Packet * pull() const
Pull a packet over this port and return it.
Definition element.hh:841
const Port & input(int port) const
Return one of the element's input ports.
Definition element.hh:579
A network packet.
Definition packet.hh:68
See also
Element::checked_output_push()

Member Function Documentation

◆ active()

bool Element::Port::active ( ) const
inline

Returns whether this port is active (a push output or a pull input).

See also
Element::port_active

◆ element()

Element * Element::Port::element ( ) const
inline

Returns the element connected to this active port.

Returns 0 if this port is not active().

◆ port()

int Element::Port::port ( ) const
inline

Returns the port number of the port connected to this active port.

Returns < 0 if this port is not active().

◆ push()

void Element::Port::push ( Packet *  p) const
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:

output(i).element()->push(output(i).port(), p);
int port() const
Returns the port number of the port connected to this active port.
Definition element.hh:738
Element * element() const
Returns the element connected to this active port.
Definition element.hh:729
virtual void push(int port, Packet *p)
Push packet p onto push input port.
Definition element.cc:3142

◆ pull()

Packet * Element::Port::pull ( ) const
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:

virtual Packet * pull(int port)
Pull a packet from pull output port.
Definition element.cc:3162

The documentation for this class was generated from the following file: