|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.clackrouter.packets.IPPacket.Header
public class IPPacket.Header
Encapsulates IP packet header.
Field Summary | |
---|---|
static int |
ADDR_LEN
|
static int |
CHECKSUM_LEN
|
static int |
FLAGS_AND_FRAG_OFFSET_LEN
|
static int |
FLAGS_BIT_LEN
|
static int |
FRAG_OFFSET_BIT_LEN
|
static int |
ID_LEN
|
static int |
IHL_BIT_LEN
|
static int |
PROTOCOL_LEN
|
static int |
TOS_LEN
|
static int |
TOTAL_LENGTH_LEN
|
static int |
TTL_LEN
|
static int |
VERSION_AND_IHL_LEN
|
static int |
VERSION_BIT_LEN
|
Constructor Summary | |
---|---|
IPPacket.Header(java.nio.ByteBuffer headerBuffer)
Constructs IP packet header. |
|
IPPacket.Header(byte version,
byte ihl,
byte tos,
short totalLength,
short identification,
short flags,
short fragmentOffset,
byte ttl,
byte protocol,
java.nio.ByteBuffer srcAddr,
java.nio.ByteBuffer dstAddr)
Constructs an IP header from given parameters. |
Method Summary | |
---|---|
short |
calculateChecksum()
Calculates IP header checksum. |
java.nio.ByteBuffer |
getByteBuffer()
Returns a byte buffer containing the header. |
byte[] |
getBytes()
Returns an array of bytes representing the header. |
short |
getChecksum()
Returns the packet's checksum field value. |
java.nio.ByteBuffer |
getDestinationAddress()
Returns the destination address in the IP header. |
int |
getLength()
Returns the length of the header, in bytes. |
int |
getPacketLength()
|
byte |
getProtocol()
Returns the packet's Protocol field value. |
java.nio.ByteBuffer |
getSourceAddress()
Returns the source address in the IP header. |
int |
getTTL()
Returns the packet's Time-To-Live field value. |
byte |
getVIHL()
|
void |
pack()
Write all header fields to the internal buffer. |
void |
setChecksum()
Sets the checksum to the value calculated by the method calculateChecksum. |
void |
setChecksum(short checksum)
Sets the checksum to the supplied value. |
void |
setDestAddr(java.nio.ByteBuffer dst)
|
void |
setSrcAddr(java.nio.ByteBuffer src)
|
void |
setTTL(int newTTL)
Sets the packet's Time-To-Live field value. |
java.lang.String |
toString()
Represents the header in readable format, by field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int VERSION_BIT_LEN
public static final int IHL_BIT_LEN
public static final int FLAGS_BIT_LEN
public static final int FRAG_OFFSET_BIT_LEN
public static final int VERSION_AND_IHL_LEN
public static final int TOS_LEN
public static final int TOTAL_LENGTH_LEN
public static final int ID_LEN
public static final int FLAGS_AND_FRAG_OFFSET_LEN
public static final int TTL_LEN
public static final int PROTOCOL_LEN
public static final int CHECKSUM_LEN
public static final int ADDR_LEN
Constructor Detail |
---|
public IPPacket.Header(java.nio.ByteBuffer headerBuffer)
headerBuffer
- Byte buffer containing the header of an IP packetpublic IPPacket.Header(byte version, byte ihl, byte tos, short totalLength, short identification, short flags, short fragmentOffset, byte ttl, byte protocol, java.nio.ByteBuffer srcAddr, java.nio.ByteBuffer dstAddr)
version
- IP version; only 4 least significant bits are usedihl
- Internet header length; only 4 least significant
bits are usedtos
- Type of servicetotalLength
- Total length of a packet, in bytesidentification
- Identificationflags
- Control flags; only 3 least significant bits are
usedfragmentOffset
- Fragmentation offset; only 13 least
significant bits are usedttl
- Time-To-Liveprotocol
- ProtocolsrcAddr
- Source IP addressdstAddr
- Destination IP addressMethod Detail |
---|
public void pack()
public void setChecksum(short checksum)
checksum
- Checksumpublic void setChecksum()
calculateChecksum()
public int getPacketLength()
public java.nio.ByteBuffer getByteBuffer()
public int getLength()
public byte[] getBytes()
public java.nio.ByteBuffer getSourceAddress()
public java.nio.ByteBuffer getDestinationAddress()
public short calculateChecksum()
public short getChecksum()
public int getTTL()
public void setTTL(int newTTL)
newTTL
- Time-To-Livepublic void setSrcAddr(java.nio.ByteBuffer src)
public void setDestAddr(java.nio.ByteBuffer dst)
public byte getProtocol()
public java.lang.String toString()
toString
in class java.lang.Object
public byte getVIHL()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |