All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class nodeos.FlowHandle

java.lang.Object
   |
   +----nodeos.Linkable
           |
           +----nodeos.FlowHandle

public abstract class FlowHandle
extends Linkable
implements FlowDispatcher
A handle on a flow of packets.

Flow handles serve three purposes, each of which is optional.

Uses Linkable for convenience. (XXX)

See Also:
FlowDispatcher

Variable Index

 o lastHeaderLength
will contain the number of bytes to skip to get to the payload.

Method Index

 o addBuffer(Buffer)
Adds a buffer to the handle's free list.
 o addBuffers(Buffer[])
Adds an array of buffers to the handle's free list.
 o addBuffers(int, int)
Allocates buffers and adds them to the free list.
 o addBufferToReceiveQueue(Buffer)
Adds a buffer to the handle's receive queue.
 o checkBuffer(Buffer, int)
Checks data in buffer.
 o dispatchBuffer(Buffer, int)
Dispatch a given buffer.
 o getName()
 o getQueueLength()
Return number of packets in receive queue.
 o merge(FlowHandle)
Merge two flow handles into one This function appends the other flow handle's receive queue to our receive queue.
 o receive()
Receives a packet from that flow.
 o reclaimBuffer()
Reclaims a buffer from the free queue.
 o setName(String)
 o setPayloadDispatcher(FlowDispatcher)
Sets a dispatcher for that flow.
 o toString()
Convert to a String.

Variables

 o lastHeaderLength
 public int lastHeaderLength
will contain the number of bytes to skip to get to the payload.
This must be set by checkBuffer. This is a hack to avoid having checkBuffer return a pair (boolean, int).

Methods

 o checkBuffer
 public abstract boolean checkBuffer(Buffer b,
                                     int offset)
Checks data in buffer.

Checks whether the data in that buffer, starting at offset, may be identified as belonging to that flow.

Sets lastHeaderLength to the number of bytes in the header needed for identification.

 o getName
 public String getName()
 o setName
 public void setName(String name)
 o getQueueLength
 public int getQueueLength()
Return number of packets in receive queue.

 o setPayloadDispatcher
 public void setPayloadDispatcher(FlowDispatcher flowDispatcher)
Sets a dispatcher for that flow.

This has the effect that all packets presented to that flow handle will be presented to the payload dispatcher for dispatch.

Parameters:
flowDispatcher - new payload dispatcher for that flow.
 o dispatchBuffer
 public Buffer dispatchBuffer(Buffer buf,
                              int offset)
Dispatch a given buffer.

If free buffers are available, a free buffer is taken from the free queue. If buf.exchanged is false, this buffer is returned and the buffer that is passed in is enqueued in the receive queue.

Otherwise, the free buffer is made a dependent of the buffer passed in, and it is enqueued in the receive queue.

If a payload dispatcher is given, the packet is dispatched to it, adding lastHeaderLength to the offset.

See FlowDispatch for a description of the parameters.

See Also:
dispatchBuffer
 o addBufferToReceiveQueue
 public void addBufferToReceiveQueue(Buffer p)
Adds a buffer to the handle's receive queue.

 o addBuffer
 public void addBuffer(Buffer p)
Adds a buffer to the handle's free list.

 o addBuffers
 public void addBuffers(Buffer p[])
Adds an array of buffers to the handle's free list.

 o addBuffers
 public void addBuffers(int packets,
                        int size)
Allocates buffers and adds them to the free list.

Parameters:
packets - number of packets to be allocated
size - size of each packet in bytes
 o reclaimBuffer
 public Buffer reclaimBuffer()
Reclaims a buffer from the free queue. This removes a buffer from the free queue of the handle, effectively reducing the flow handle's capacity.

Returns:
free buffer
 o receive
 public Buffer receive()
Receives a packet from that flow.

The buffer in which the packet is contained is made independent. (XXX) let the application do that, unless there's security concerns.

 o merge
 public void merge(FlowHandle other)
Merge two flow handles into one This function appends the other flow handle's receive queue to our receive queue.

 o toString
 public String toString()
Convert to a String.

Returns:
statistics about that flow handle
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index