org.savarese.vserv.ipq
Class NetlinkMessage

java.lang.Object
  extended by org.savarese.vserv.ipq.NetlinkMessage

public class NetlinkMessage
extends java.lang.Object

NetlinkMessage encapsulates a Linux netlink datagram. Linux netlink provides the ability to communicate between kernel modules and user space processes. NetlinkMessage is used in conjunction with IPQHandle.read(org.savarese.vserv.ipq.NetlinkMessage, int) to read from the user space queue netlink messages containing network packets. Only NetlinkMessage instances of type TYPE_PACKET contain packets. No support is provided for accessing other types of netlink messages, such as netlink error messages.

Author:
Daniel F. Savarese

Field Summary
static int TYPE_BASE
          An unused constant from which the MODE, VERDICT, and PACKET types are derived.
static int TYPE_DONE
          End of netlink dump.
static int TYPE_ERROR
          An netlink error message type to be ignored.
static int TYPE_MODE
          An IPQ mode request message.
static int TYPE_NOOP
          A noop message type to be ignored.
static int TYPE_OVERRUN
          Indication of loss of data.
static int TYPE_PACKET
          An IPQ packet message.
static int TYPE_VERDICT
          An IPQ verdict setting message.
 
Constructor Summary
NetlinkMessage()
          Same as NetlinkMessage(2048);
NetlinkMessage(int maxLength)
          Initializes a netlink message with a given maximum length.
 
Method Summary
protected  void finalize()
          Frees the memory allocated for the netlink message buffer.
 int getError()
           
 int getFlags()
           
 int getLength()
           
 int getMaxLength()
           
 void getPacket(NetfilterPacket packet)
          Retrieves a NetfilterPacket from netlink messages of type TYPE_PACKET.
 int getSendingProcessID()
           
 int getSequenceNumber()
           
 int getType()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_BASE

public static final int TYPE_BASE
An unused constant from which the MODE, VERDICT, and PACKET types are derived.

See Also:
Constant Field Values

TYPE_MODE

public static final int TYPE_MODE
An IPQ mode request message.

See Also:
Constant Field Values

TYPE_VERDICT

public static final int TYPE_VERDICT
An IPQ verdict setting message.

See Also:
Constant Field Values

TYPE_PACKET

public static final int TYPE_PACKET
An IPQ packet message.

See Also:
Constant Field Values

TYPE_NOOP

public static final int TYPE_NOOP
A noop message type to be ignored.

See Also:
Constant Field Values

TYPE_ERROR

public static final int TYPE_ERROR
An netlink error message type to be ignored.

See Also:
Constant Field Values

TYPE_DONE

public static final int TYPE_DONE
End of netlink dump.

See Also:
Constant Field Values

TYPE_OVERRUN

public static final int TYPE_OVERRUN
Indication of loss of data.

See Also:
Constant Field Values
Constructor Detail

NetlinkMessage

public NetlinkMessage()
Same as NetlinkMessage(2048);


NetlinkMessage

public NetlinkMessage(int maxLength)
Initializes a netlink message with a given maximum length.

Parameters:
maxLength - The maximum number of bytes that this netlink message can store.
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Frees the memory allocated for the netlink message buffer. Do not override this method without calling super.finalize().

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getMaxLength

public int getMaxLength()
Returns:
The maximum length of this netlink message.

getError

public int getError()
Returns:
The error number resulting from a TYPE_ERROR netlink message. No special support is provided to interpret the value, but it corresponds to platform-specific errno values.

getLength

public int getLength()
Returns:
The length of the entire netlink message, including the header.

getType

public int getType()
Returns:
The type of the netlink message, corresponding to one of the TYPE_ constants.

getFlags

public int getFlags()
Returns:
Additional netlink flags. No special support is provided to interpret them.

getSequenceNumber

public int getSequenceNumber()
Returns:
The sequence number of the netlink message.

getSendingProcessID

public int getSendingProcessID()
Returns:
The process id of the process sending the netlink message.

getPacket

public void getPacket(NetfilterPacket packet)
Retrieves a NetfilterPacket from netlink messages of type TYPE_PACKET.

Parameters:
packet - The object in which to store the netfilter packet data.