net.clackrouter.packets
Class IPPacket

java.lang.Object
  extended by net.clackrouter.protocol.data.VNSData
      extended by net.clackrouter.packets.VNSPacket
          extended by net.clackrouter.packets.IPPacket

public class IPPacket
extends VNSPacket

Encapsulates an Internet Protocol packet. Defined in RFC 791.


Nested Class Summary
 class IPPacket.Header
          Encapsulates IP packet header.
 
Field Summary
static byte PPROTO_ENCAP
           
static byte PPROTO_HELLO
           
static byte PROTO_AH
           
static byte PROTO_CLACK_OSPF
           
static byte PROTO_CLACK_RIP
           
static byte PROTO_DSTOPTS
           
static byte PROTO_EGP
           
static byte PROTO_EON
           
static byte PROTO_ESP
           
static byte PROTO_FRAGMENT
           
static byte PROTO_GGP
           
static byte PROTO_HOPOPTS
           
static byte PROTO_ICMP
           
static byte PROTO_ICMPV6
           
static byte PROTO_IDP
           
static byte PROTO_IGMP
           
static byte PROTO_IP
          Protocols
static byte PROTO_IPV6
           
static byte PROTO_ND
           
static byte PROTO_NONE
           
static byte PROTO_PIM
           
static byte PROTO_PUP
           
static byte PROTO_ROUTING
           
static byte PROTO_RSVP
           
static byte PROTO_TCP
           
static byte PROTO_UDP
           
 
Fields inherited from class net.clackrouter.packets.VNSPacket
m_inputInterfaceName, m_length, m_level2Type, m_local_packet, m_nextHopIPAddr, m_nextHopMacAddr, m_outputInterfaceName, m_packetByteBuffer, mParentHeader
 
Constructor Summary
IPPacket(java.nio.ByteBuffer packetByteBuffer)
          Constucts an IP packet given valid bytes representing an IP packet, consisting of an IP header and the payload (body).
 
Method Summary
 java.nio.ByteBuffer getBodyBuffer()
          Returns the byte buffer containing the body of an IP packet.
 byte[] getBodyBytes()
          Returns a byte array that contains the payload of an IP packet.
 int getBodyLength()
          Returns length, in bytes, of an IP packet's body.
 java.net.InetAddress getDestinationAddress()
           
 IPPacket.Header getHeader()
          Returns the header of the IP packet.
 VNSPacket getPayload()
           
 byte getProtocol()
           
 java.net.InetAddress getSourceAddress()
           
 void pack()
           
 void setBodyBuffer(java.nio.ByteBuffer new_bb)
           
 java.lang.String toString()
          Represents an IP packet in a readable format, by field.
static IPPacket wrap(VNSPacket packet, byte protocol, java.nio.ByteBuffer srcAddr, java.nio.ByteBuffer dstAddr)
          Creates an IP packet by using the supplied packet as a payload.
static IPPacket wrap(VNSPacket packet, byte protocol, java.net.InetAddress srcAddr, java.net.InetAddress destAddr)
           
 
Methods inherited from class net.clackrouter.packets.VNSPacket
addToPath, get16bit, get32bit, getByteBuffer, getInputInterfaceName, getLength, getLevel2Type, getNextHopIPAddress, getNextHopMacAddress, getOutputInterfaceName, getParentHeader, getStringBuffer, isPacket, needsSourceAddress, setByteBuffer, setInputInterfaceName, setLevel2Type, setNeedsSourceAddress, setNextHopIPAddress, setNextHopMacAddress, setOutputInterfaceName, setParentHeader
 
Methods inherited from class net.clackrouter.protocol.data.VNSData
isBanner, isClose, isHWInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTO_IP

public static final byte PROTO_IP
Protocols

See Also:
Constant Field Values

PROTO_HOPOPTS

public static final byte PROTO_HOPOPTS
See Also:
Constant Field Values

PROTO_ICMP

public static final byte PROTO_ICMP
See Also:
Constant Field Values

PROTO_IGMP

public static final byte PROTO_IGMP
See Also:
Constant Field Values

PROTO_GGP

public static final byte PROTO_GGP
See Also:
Constant Field Values

PPROTO_ENCAP

public static final byte PPROTO_ENCAP
See Also:
Constant Field Values

PROTO_TCP

public static final byte PROTO_TCP
See Also:
Constant Field Values

PROTO_EGP

public static final byte PROTO_EGP
See Also:
Constant Field Values

PROTO_PUP

public static final byte PROTO_PUP
See Also:
Constant Field Values

PROTO_UDP

public static final byte PROTO_UDP
See Also:
Constant Field Values

PROTO_IDP

public static final byte PROTO_IDP
See Also:
Constant Field Values

PROTO_IPV6

public static final byte PROTO_IPV6
See Also:
Constant Field Values

PROTO_ROUTING

public static final byte PROTO_ROUTING
See Also:
Constant Field Values

PROTO_FRAGMENT

public static final byte PROTO_FRAGMENT
See Also:
Constant Field Values

PROTO_RSVP

public static final byte PROTO_RSVP
See Also:
Constant Field Values

PROTO_ESP

public static final byte PROTO_ESP
See Also:
Constant Field Values

PROTO_AH

public static final byte PROTO_AH
See Also:
Constant Field Values

PROTO_ICMPV6

public static final byte PROTO_ICMPV6
See Also:
Constant Field Values

PROTO_NONE

public static final byte PROTO_NONE
See Also:
Constant Field Values

PROTO_DSTOPTS

public static final byte PROTO_DSTOPTS
See Also:
Constant Field Values

PPROTO_HELLO

public static final byte PPROTO_HELLO
See Also:
Constant Field Values

PROTO_ND

public static final byte PROTO_ND
See Also:
Constant Field Values

PROTO_EON

public static final byte PROTO_EON
See Also:
Constant Field Values

PROTO_PIM

public static final byte PROTO_PIM
See Also:
Constant Field Values

PROTO_CLACK_RIP

public static final byte PROTO_CLACK_RIP
See Also:
Constant Field Values

PROTO_CLACK_OSPF

public static final byte PROTO_CLACK_OSPF
See Also:
Constant Field Values
Constructor Detail

IPPacket

public IPPacket(java.nio.ByteBuffer packetByteBuffer)
Constucts an IP packet given valid bytes representing an IP packet, consisting of an IP header and the payload (body).

Parameters:
packetByteBuffer - Byte buffer containing the IP packet
Method Detail

setBodyBuffer

public void setBodyBuffer(java.nio.ByteBuffer new_bb)

pack

public void pack()

getHeader

public IPPacket.Header getHeader()
Returns the header of the IP packet.

Returns:
Header of the IP packet
See Also:
IPPacket.Header

getBodyBuffer

public java.nio.ByteBuffer getBodyBuffer()
Returns the byte buffer containing the body of an IP packet.

Returns:
Byte buffer containing the body of an IP packet

getPayload

public VNSPacket getPayload()

getBodyLength

public int getBodyLength()
Returns length, in bytes, of an IP packet's body.

Returns:
Length of an IP packet's body

getBodyBytes

public byte[] getBodyBytes()
Returns a byte array that contains the payload of an IP packet.

Returns:
Array of bytes containing the body of an IP packet

wrap

public static IPPacket wrap(VNSPacket packet,
                            byte protocol,
                            java.net.InetAddress srcAddr,
                            java.net.InetAddress destAddr)
                     throws VNSInvalidPacketException
Throws:
VNSInvalidPacketException

wrap

public static IPPacket wrap(VNSPacket packet,
                            byte protocol,
                            java.nio.ByteBuffer srcAddr,
                            java.nio.ByteBuffer dstAddr)
                     throws VNSInvalidPacketException
Creates an IP packet by using the supplied packet as a payload. If a supplied packet is another IP packet, a VRInvalidPacketException is thrown. Default values are used for header fields not listed in this method's formal parameter list.

Parameters:
packet - Any packet, except IP packet
protocol - Protocol
srcAddr - Source IP address
dstAddr - Destination IP address
Throws:
VNSInvalidPacketException

toString

public java.lang.String toString()
Represents an IP packet in a readable format, by field. It is equivalent to calling toString() on the header of the packet.

Overrides:
toString in class VNSPacket
Returns:
Packet in readable format

getSourceAddress

public java.net.InetAddress getSourceAddress()

getDestinationAddress

public java.net.InetAddress getDestinationAddress()

getProtocol

public byte getProtocol()