org.jnetstream.protocol.codec
Interface Scanner.Scandec

All Known Subinterfaces:
ProtocolInfo.Binding
Enclosing interface:
Scanner

public static interface Scanner.Scandec

Scanner's Decoder or Scandec for short. Is deceptively simple interface that accomplishes several tasks. Scandecs are deployed along with protocol bindings and are a merger of a protocol binding information any NPL header length formulas. In addition any assert conditions within the NPL definition are applied as well.

The primary task of a Scandec is to determine if all the conditions of a scandec are met and the header that the scandec represents exists. The second task is to return the length of the header. If length returned by a Scandec is greater then -1, that means that the header exists or was found to exist and the value is the actual length of the header in bits. A lenth of 0 actually means that that the match was on a ProtocolGroup and its not a physical header that exists.

Scandecs read data directly from raw buffers and do not rely on HeaderCodecs or java Protocol classes. The Scandecs may be autogenerated or custom written in java or BPF byte code. They do not instantiate any objects and are really fast at runtime to execute.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Method Summary
 int getLength(com.slytechs.utils.memory.BitBuffer buffer, int source, int sink)
           Returns the length of the sink header for which this scandec was built.
 

Method Detail

getLength

int getLength(com.slytechs.utils.memory.BitBuffer buffer,
              int source,
              int sink)

Returns the length of the sink header for which this scandec was built. A length of -1 means that the header does not exist in the packet buffer or that 1 or more assert conditions originally defined within the source NPL definition did not pass, evaluate to true.

Parameters:
buffer - packet runtime environment used to access the raw buffer and possibly some static properties; it is not used to access codecs or other decoded headers
source - offset of the source header in bits from the start of the raw buffer
sink - bit offset into the buffer of the sink protocol under evaluation
Returns:
length of the header in bits or 0 if the header doesn't exist or pass assert conditions