|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.protocols.ip.IPHeader
This class defines a loaded IP header object. It does not allow the user of the class to set any of the values. Nor can a default object be constructed. A copy of an existing header can be created or one can be loaded from a collection of bytes. For more information on the IP header see the book "TCP/IP Illustrated, Volume 1: The Protocols" by W. Richard Stevens.
Nested Class Summary | |
static class |
IPHeader.EndOfOptions
This class is used to represent the End-Of-Option list in the IP header. |
static class |
IPHeader.LooseSourceRouteOption
This class represents the loose source routing options that may be part of an IP header. |
static class |
IPHeader.Option
The Option class is used as the base class for any options that are at the end of the IP header. |
static class |
IPHeader.RouteOption
This class represents routing options that may be part of an IP header. |
static class |
IPHeader.RouteRecordOption
This class represents the route record option that may be part of an IP header. |
static class |
IPHeader.StrictSourceRouteOption
This class represents the strict source routing options that may be part of an IP header. |
Field Summary | |
static int |
FLAGS_DONT_FRAGMENT
Don't fragment datagrams field |
static int |
FLAGS_MASK
The mask of the flags in the fragment field of the IP header |
static int |
FLAGS_MORE_FRAGMENTS
More fragments are necessary to reassemble this packet |
static int |
IP_VERSION
The supported version of the IP header |
private short |
m_checksum
One's compliment 16-bit checksum of the header only. |
private int |
m_dstAddr
Destination address of the IP datagram |
private byte |
m_flags
The fragmentation flags tha occupy the upper 3 bits of the fragment offset field |
private short |
m_fragOffset
The fragment offset of this packet |
private byte |
m_hdrlen
The length of the IP header in 32-bit words |
private short |
m_identity
The identity of the IP dagagram. |
private short |
m_length
The total length of the IP datagram and it's payload |
private byte[] |
m_options
any option data in the datagram |
private byte |
m_protocol
The protocol encapuslated by this packet |
private int |
m_srcAddr
Source address of the IP datagram |
private byte |
m_tos
the Type-Of-Service defined for the IP datagram |
private byte |
m_ttl
The Time-To-Live for this IP packet |
private byte |
m_version
The IP version |
static int |
OPTION_CLASS_MASK
The option class mask |
static int |
OPTION_COPY_MASK
The bit(s) that define if the optiosn are copied to each datagram when (or if) it is fragmented. |
static int |
OPTION_ID_EOO
Option identifier for the End Of Options List option. |
static int |
OPTION_ID_LOOSE_SOURCE_ROUTING
Option identifier for the loose source routing option |
static int |
OPTION_ID_ROUTE_RECORD
Option identifier for the route record option |
static int |
OPTION_ID_STRICT_SOURCE_ROUTING
Option identifer for the the strict source routing option |
static int |
OPTION_NUMBER_MASK
The option number mask |
static int |
TOS_DELAY_LOW
Minimize the delay when handling packets. |
static int |
TOS_DELAY_MASK
TOS delay mask as defined by RFC 791. |
static int |
TOS_DELAY_NORMAL
Normal packet handling |
static int |
TOS_PRECEDENCE_CRITICAL_ECP
Critical/ECP TOS. |
static int |
TOS_PRECEDENCE_FLASH
Flash TOS. |
static int |
TOS_PRECEDENCE_FLASH_OVERRIDE
Flash Override TOS. |
static int |
TOS_PRECEDENCE_IMMEDIATE
Immediate TOS. |
static int |
TOS_PRECEDENCE_INTERNETWORK_CONTROL
Internetworking Control TOS. |
static int |
TOS_PRECEDENCE_MASK
The Type-Of-Service mask. |
static int |
TOS_PRECEDENCE_NETWORK_CRITICAL
Network Critical TOS. |
static int |
TOS_PRECEDENCE_PRIORITY
Priority TOS. |
static int |
TOS_PRECEDENCE_ROUTINE
Routine TOS. |
static int |
TOS_RELIBILITY_HIGH
High Reliability requested. |
static int |
TOS_RELIBILITY_MASK
Packet reliablity mask. |
static int |
TOS_RELIBILITY_NORMAL
Normal reliability requrested |
static int |
TOS_RESERVED_MASK
Mask of the reseered bits. |
static int |
TOS_THROUGHPUT_HIGH
High throughput requested |
static int |
TOS_THROUGHPUT_MASK
TOS Throughput mask |
static int |
TOS_THROUGHPUT_NORMAL
Normal throughput requested |
Constructor Summary | |
IPHeader()
Constructs a basic IP header, but the header is not valid until a large part of the information is configured. |
|
IPHeader(byte[] header,
int offset)
Constructs a new IPHeader object from the passed data buffer. |
|
IPHeader(IPHeader second)
Constructs a new IP Header object that is identical to the passed IPHeader. |
Method Summary | |
void |
addOption(IPHeader.Option opt)
Adds an option to the IP header. |
static java.lang.String |
addressToString(byte[] buf)
Converts the passed IPv4 address buffer to a dotted decimal IP address string. |
static java.lang.String |
addressToString(int ipv4Addr)
Converts the passed 32-bit IPv4 address to a dotted decimal IP address string. |
private static int |
byteToInt(byte b)
Converts a byte to an integer, treating the byte as unsigned. |
private static short |
byteToShort(byte b)
Converts a byte to a short, treating the byte as unsigned. |
private byte[] |
dup(byte[] src)
Duplicates the array of bytes. |
short |
getChecksum()
Gets the 16-bit ones compliment checksum for the IP header. |
int |
getDestinationAddress()
Returns the dotted decimal string address of the destination IP address. |
boolean |
getFlag(int bit)
Used to get an individual flag from the flags field. |
byte |
getFlags()
Used to get the 3-bit flags from the header. |
short |
getFragmentOffset()
Returns the 13-bit fragment offset field from the IP header. |
int |
getHeaderLength()
Used to get the current length of the IP Header. |
short |
getIdentity()
Used to retreive the 16-bit identity of the header. |
byte[] |
getOptionData()
Retrieves the IP header options from the header. |
java.util.List |
getOptions()
Returns a list of options that are associated with the IP header. |
int |
getPacketLength()
Returns the length of the IP packet, including the header, in bytes. |
byte |
getProtocol()
Gets the protocol for the IP datagram. |
int |
getSourceAddress()
Returns the dotted decimal string address of the source IP address. |
byte |
getTTL()
Gets the 8-bit Time To Live (TTL) of the packet. |
byte |
getTypeOfService()
Retreives the current TOS field from the header. |
boolean |
getTypeOfService(int bit)
Use to test individual bits in the TOS fields. |
byte |
getVersion()
Used to retreive the current version of the IP Header. |
void |
setChecksum(short sum)
Sets the checksum for the IP header. |
void |
setDestinationAddress(int addr)
Sets the IP headers destination address. |
void |
setFlags(byte flags)
Sets the flags contained in the upper 3 bits of the short value for the fragmentation offset. |
void |
setFragmentOffset(short offset)
Sets the fragmentation index for this packet |
void |
setIdentity(short ident)
Sets the identity of the IP header |
void |
setOptionData(byte[] options)
Sets the current option data for the header. |
void |
setPacketLength(short length)
Sets the length for IP packet, including the header. |
void |
setProtocol(byte protocol)
Sets the protocol for the IP header. |
void |
setSourceAddr(int addr)
Sets the IP headers source address. |
void |
setTTL(byte ttl)
Sets the time to live for the IP header |
void |
setTypeOfService(byte tos)
Sets the TOS flags for the IP header. |
private static int |
shortToInt(short s)
Converts a short to an integer, treating the short as unsigned. |
int |
writeBytes(byte[] data,
int offset)
Stores the IP header as an array of bytes into the passed data buffer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int IP_VERSION
public static final int TOS_PRECEDENCE_MASK
public static final int TOS_PRECEDENCE_NETWORK_CRITICAL
public static final int TOS_PRECEDENCE_INTERNETWORK_CONTROL
public static final int TOS_PRECEDENCE_CRITICAL_ECP
public static final int TOS_PRECEDENCE_FLASH_OVERRIDE
public static final int TOS_PRECEDENCE_FLASH
public static final int TOS_PRECEDENCE_IMMEDIATE
public static final int TOS_PRECEDENCE_PRIORITY
public static final int TOS_PRECEDENCE_ROUTINE
public static final int TOS_DELAY_MASK
public static final int TOS_DELAY_LOW
public static final int TOS_DELAY_NORMAL
public static final int TOS_THROUGHPUT_MASK
public static final int TOS_THROUGHPUT_HIGH
public static final int TOS_THROUGHPUT_NORMAL
public static final int TOS_RELIBILITY_MASK
public static final int TOS_RELIBILITY_HIGH
public static final int TOS_RELIBILITY_NORMAL
public static final int TOS_RESERVED_MASK
public static final int FLAGS_MASK
public static final int FLAGS_DONT_FRAGMENT
public static final int FLAGS_MORE_FRAGMENTS
public static final int OPTION_COPY_MASK
public static final int OPTION_CLASS_MASK
public static final int OPTION_NUMBER_MASK
public static final int OPTION_ID_EOO
public static final int OPTION_ID_LOOSE_SOURCE_ROUTING
public static final int OPTION_ID_STRICT_SOURCE_ROUTING
public static final int OPTION_ID_ROUTE_RECORD
private byte m_version
private byte m_hdrlen
private byte m_tos
private short m_length
private short m_identity
private byte m_flags
private short m_fragOffset
private byte m_ttl
private byte m_protocol
private short m_checksum
private int m_srcAddr
private int m_dstAddr
private byte[] m_options
Constructor Detail |
public IPHeader()
public IPHeader(IPHeader second)
second
- The object to duplicate.public IPHeader(byte[] header, int offset)
header
- The buffer containing the headeroffset
- The offset into the buffer where the IP header is located.
java.lang.IndexOutOfBoundsException
- This exception is thrown if the minimum number of bytes
are not present to represent an IPHeader object.
UnknownIPVersionException
- Thrown if the format of the version is unknown.Method Detail |
private byte[] dup(byte[] src)
src
- The source bytes to duplicate.
private static short byteToShort(byte b)
b
- The byte to convert.
private static int byteToInt(byte b)
b
- The byte to convert.
private static int shortToInt(short s)
s
- The short to convert.
public byte getVersion()
public int getHeaderLength()
public byte getTypeOfService()
public void setTypeOfService(byte tos)
tos
- The new TOS for the IP headerpublic boolean getTypeOfService(int bit)
bit
- The bit to validate. Valid values are 0 - 7.
public int getPacketLength()
public void setPacketLength(short length)
length
- The length of the IP header plus the data contained withinpublic short getIdentity()
public void setIdentity(short ident)
ident
- The new identity of the IP headerpublic byte getFlags()
public void setFlags(byte flags)
flags
- The flag bits, set in the lower 3 bits of the value.public boolean getFlag(int bit)
bit
- The flag to retreive.
public short getFragmentOffset()
public void setFragmentOffset(short offset)
public byte getTTL()
public void setTTL(byte ttl)
public byte getProtocol()
public void setProtocol(byte protocol)
protocol
- The IP protocol.public short getChecksum()
public void setChecksum(short sum)
sum
- The IP header checksum.public int getSourceAddress()
public void setSourceAddr(int addr)
addr
- The soruce address for the header.public int getDestinationAddress()
public void setDestinationAddress(int addr)
addr
- The destination addresspublic byte[] getOptionData()
public void setOptionData(byte[] options)
options
- The new options data.public java.util.List getOptions() throws java.lang.InstantiationException
java.lang.InstantiationException
public void addOption(IPHeader.Option opt)
opt
- The option to add to the header.public int writeBytes(byte[] data, int offset)
data
- The location to write the dataoffset
- The offset to start storing information.
public static java.lang.String addressToString(int ipv4Addr)
ipv4Addr
- The 32-bit address
public static java.lang.String addressToString(byte[] buf)
buf
- The 4 byte buffer
java.lang.IllegalArgumentException
- Thrown if the buffer is not exactly 4 bytes in length.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |