jist.swans.net
Class NetMessage.Ip

java.lang.Object
  extended by jist.swans.net.NetMessage
      extended by jist.swans.net.NetMessage.Ip
All Implemented Interfaces:
java.lang.Cloneable, JistAPI.Timeless, Message
Enclosing class:
NetMessage

public static class NetMessage.Ip
extends NetMessage

IPv4 network packet.


Nested Class Summary
 
Nested classes/interfaces inherited from class jist.swans.net.NetMessage
NetMessage.Ip, NetMessage.IpOption, NetMessage.IpOptionSourceRoute
 
Field Summary
static int BASE_SIZE
          Fixed IP packet size.
 
Fields inherited from interface jist.swans.misc.Message
NULL
 
Constructor Summary
NetMessage.Ip(Message payload, NetAddress src, NetAddress dst, short protocol, byte priority, byte ttl)
          Create new IPv4 packet with default id.
NetMessage.Ip(Message payload, NetAddress src, NetAddress dst, short protocol, byte priority, byte ttl, short id, short fragOffset)
          Create new IPv4 packet.
 
Method Summary
 NetMessage.Ip copy()
          Make copy of packet, usually in order to modify it.
 void decTTL()
          Create indentical packet with decremented TTL.
 NetMessage.Ip freeze()
          Render packet immutable.
 void getBytes(byte[] b, int offset)
          Store packet into byte array.
 NetAddress getDst()
          Return packet destination.
 short getFragOffset()
          Return packet fragmentation offset.
 short getId()
          Return packet identification.
 Message getPayload()
          Return packet payload.
 byte getPriority()
          Return packet priority.
 short getProtocol()
          Return packet protocol.
 int getSize()
          Return packet size or Constants.ZERO_WIRE_SIZE.
 NetAddress[] getSourceRoute()
          Return source route.
 int getSourceRoutePointer()
          Return source route pointer.
 NetAddress getSrc()
          Return packet source.
 byte getTTL()
          Return packet time-to-live.
 boolean hasSourceRoute()
          Returns whether packet contains source route.
 boolean isFrozen()
          Whether packet is immutable.
 void setSourceRoute(NetMessage.IpOptionSourceRoute srcRoute)
          Set source route.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_SIZE

public static final int BASE_SIZE
Fixed IP packet size.

See Also:
Constant Field Values
Constructor Detail

NetMessage.Ip

public NetMessage.Ip(Message payload,
                     NetAddress src,
                     NetAddress dst,
                     short protocol,
                     byte priority,
                     byte ttl,
                     short id,
                     short fragOffset)
Create new IPv4 packet.

Parameters:
payload - packet payload
src - packet source address
dst - packet destination address
protocol - packet protocol
priority - packet priority
ttl - packet time-to-live
id - packet identification
fragOffset - packet fragmentation offset

NetMessage.Ip

public NetMessage.Ip(Message payload,
                     NetAddress src,
                     NetAddress dst,
                     short protocol,
                     byte priority,
                     byte ttl)
Create new IPv4 packet with default id.

Parameters:
payload - packet payload
src - packet source address
dst - packet destination address
protocol - packet protocol
priority - packet priority
ttl - packet time-to-live
Method Detail

freeze

public NetMessage.Ip freeze()
Render packet immutable.

Returns:
immutable packet, possibly intern()ed

isFrozen

public boolean isFrozen()
Whether packet is immutable.

Returns:
whether packet is immutable

copy

public NetMessage.Ip copy()
Make copy of packet, usually in order to modify it.

Returns:
mutable copy of packet.

getSrc

public NetAddress getSrc()
Return packet source.

Returns:
packet source

getDst

public NetAddress getDst()
Return packet destination.

Returns:
packet destination

getPayload

public Message getPayload()
Return packet payload.

Returns:
packet payload

getPriority

public byte getPriority()
Return packet priority.

Returns:
packet priority

getProtocol

public short getProtocol()
Return packet protocol.

Returns:
packet protocol

getId

public short getId()
Return packet identification.

Returns:
packet identification

getFragOffset

public short getFragOffset()
Return packet fragmentation offset.

Returns:
packet fragmentation offset

getTTL

public byte getTTL()
Return packet time-to-live.

Returns:
time-to-live

decTTL

public void decTTL()
Create indentical packet with decremented TTL.


hasSourceRoute

public boolean hasSourceRoute()
Returns whether packet contains source route.

Returns:
whether packet contains source route

getSourceRoute

public NetAddress[] getSourceRoute()
Return source route. (do not modify)

Returns:
source route (do not modify)

getSourceRoutePointer

public int getSourceRoutePointer()
Return source route pointer.

Returns:
source route pointer

setSourceRoute

public void setSourceRoute(NetMessage.IpOptionSourceRoute srcRoute)
Set source route.

Parameters:
srcRoute - source route

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getSize

public int getSize()
Return packet size or Constants.ZERO_WIRE_SIZE.

Returns:
packet size [in bytes]

getBytes

public void getBytes(byte[] b,
                     int offset)
Store packet into byte array.

Parameters:
b - destination byte array
offset - byte array starting offset