org.jnetpcap.nio
Class JStruct

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JStruct
Direct Known Subclasses:
Debug, JFlowKey, JHeader.State, JPacket.State, JScan, JScanner, PcapHeader, WinPcapSendQueue

public class JStruct
extends JMemory

Base class for peered pure structure classes. This class purposely does not extend JBuffer to allow structure fields to be read out generically as that is not portable accross platforms and architectures. Most structures are written specifically for local machine architecture and OS, unlike network protocols which can be usually read by use of generic JBuffer. Therefore as a general requirement each JStruct has to implement its own native methods to read and write fields into the structure.

As a convention, each subclass of JStruct implements a static method sizeof() which returns the length of the structure, if the structure is static in length. If not, then no requirement to implement the static method sizeof() exists.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory
JMemory.Type
 
Field Summary
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER
 
Constructor Summary
JStruct(java.lang.String structName, java.nio.ByteBuffer peer)
          Creates a new structure object peered with the supplied object.
JStruct(java.lang.String structName, int size)
          Creates a new structure object of specified size.
JStruct(java.lang.String structName, JMemory.Type type)
          Creates a new structure object.
JStruct(java.lang.String structName, JMemory peer)
          Creates a new structure object.
 
Method Summary
 java.lang.String getStructName()
          Gets the name of the native structure
 java.lang.String toString()
          Debug information.
 
Methods inherited from class org.jnetpcap.nio.JMemory
availableDirectMemory, check, cleanup, createReference, isInitialized, isJMemoryBasedOwner, isOwner, maxDirectMemory, peer, peer, peer, reservedDirectMemory, setSize, size, softDirectMemory, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JStruct

public JStruct(java.lang.String structName,
               JMemory.Type type)
Creates a new structure object.

Parameters:
structName - name of the native structure
type - memory model

JStruct

public JStruct(java.lang.String structName,
               java.nio.ByteBuffer peer)
Creates a new structure object peered with the supplied object.

Parameters:
structName - name of the native structure
peer - buffer to peer with

JStruct

public JStruct(java.lang.String structName,
               int size)
Creates a new structure object of specified size.

Parameters:
structName - name of the native structure
size - size in bytes for this new structure object

JStruct

public JStruct(java.lang.String structName,
               JMemory peer)
Creates a new structure object.

Parameters:
structName - name of the native structure
peer - memory to peer with
Method Detail

getStructName

public final java.lang.String getStructName()
Gets the name of the native structure

Returns:
name of the structure

toString

public java.lang.String toString()
Debug information.

Overrides:
toString in class java.lang.Object
Returns:
debug info