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.
- Packet buffering. Every flow is associated with a queue of free
buffers and a queue of already received, but undelivered packets.
Packets cannot be buffered unless free buffers are available.
It is the responsibility of the user of the handle to provide
it with buffers beforehand.
- Payload dispatch. A flow handle may be associated with a dispatcher.
In this case, the payload of all packets dispatched to the handle
will be dispatched to that dispatcher as well.
This is used to implement protocol layering.
Before dispatching, the flow handle will add its own header length
to the dispatch offset.
- Packet identification. A flow handle may be used to determine
whether a certain packet belongs to a certain flow. This is
done by analyzing the packet data.
Uses Linkable for convenience. (XXX)
- See Also:
- FlowDispatcher
-
lastHeaderLength
-
will contain the number of bytes to skip to get to the payload.
-
addBuffer(Buffer)
- Adds a buffer to the handle's free list.
-
addBuffers(Buffer[])
- Adds an array of buffers to the handle's free list.
-
addBuffers(int, int)
- Allocates buffers and adds them to the free list.
-
addBufferToReceiveQueue(Buffer)
- Adds a buffer to the handle's receive queue.
-
checkBuffer(Buffer, int)
- Checks data in buffer.
-
dispatchBuffer(Buffer, int)
- Dispatch a given buffer.
-
getName()
-
-
getQueueLength()
- Return number of packets in receive queue.
-
merge(FlowHandle)
- Merge two flow handles into one
This function appends the other flow handle's receive queue to
our receive queue.
-
receive()
- Receives a packet from that flow.
-
reclaimBuffer()
- Reclaims a buffer from the free queue.
-
setName(String)
-
-
setPayloadDispatcher(FlowDispatcher)
- Sets a dispatcher for that flow.
-
toString()
- Convert to a String.
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).
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.
getName
public String getName()
setName
public void setName(String name)
getQueueLength
public int getQueueLength()
- Return number of packets in receive queue.
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.
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
addBufferToReceiveQueue
public void addBufferToReceiveQueue(Buffer p)
- Adds a buffer to the handle's receive queue.
addBuffer
public void addBuffer(Buffer p)
- Adds a buffer to the handle's free list.
addBuffers
public void addBuffers(Buffer p[])
- Adds an array of buffers to the handle's free list.
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
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
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.
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.
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