|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.protocols.icmpd.MessageHeader
The base message class for communications with the icmp daemon. The basic message begins with an eight byte header. The header consist of a type, code, sequence number, length, and reserved field
+--------+--------+----------------+ | Type | Code | Sequence # | +--------+--------+----------------+ | Length | Reserved | +-----------------+----------------+
Field Summary | |
protected byte |
m_code
The class code |
protected short |
m_length
The total length of the message. |
protected short |
m_reserved
Reserved for use by different messages. |
protected short |
m_sequence
The class sequence |
protected byte |
m_type
The class type |
private static short |
sm_seq
|
static byte |
TYPE_CONTROL
|
static byte |
TYPE_DATA
|
Constructor Summary | |
(package private) |
MessageHeader()
Creates a default message header |
(package private) |
MessageHeader(MessageHeader hdr)
Creates a duplicate of the passed header. |
Method Summary | |
static int |
align4(int sz)
Aligns the number by making sure the number is divisable by four. |
byte |
getCode()
Returns the code for the object. |
int |
getLength()
returns the current length of the entire message. |
short |
getSequence()
Returns the current sequence of the object. |
byte |
getType()
Returns the type for the object. |
static int |
makeInt(byte a,
byte b,
byte c,
byte d)
Converts the four passed bytes into a single 32-bit value. |
static short |
makeShort(byte a,
byte b)
Converts two eight bit bytes to a sixteen bit short. |
static short |
nextSequenceId()
Returns the next sequence identitifer for the class. |
(package private) void |
read(InputStream istream)
Reads in the first 8 bytes of the message. |
short |
setSequence(short seq)
sets the current sequence of the object |
(package private) void |
write(OutputStream ostream)
Write the header to the output stream, effectively seralizing the object for the icmp daemon. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected byte m_type
protected byte m_code
protected short m_sequence
protected short m_length
protected short m_reserved
private static short sm_seq
public static final byte TYPE_CONTROL
public static final byte TYPE_DATA
Constructor Detail |
MessageHeader()
MessageHeader(MessageHeader hdr)
hdr
- The header object to duplicate.Method Detail |
public static short nextSequenceId()
public static int align4(int sz)
sz
- The number to alignpublic static short makeShort(byte a, byte b)
a
- The high order byte.b
- The lo order byte.public static int makeInt(byte a, byte b, byte c, byte d)
a
- The high order byte, bit position 31-24b
- Bit positions 23-16.c
- Bit positions 15-8.d
- The lo order byte, bit position 7-0.void write(OutputStream ostream) throws IOException
ostream
- The output streamIOException
- Thrown if an error occurs with ostream.void read(InputStream istream) throws IOException
istream
- The input stream contain the "seralized" object.IOException
- Thrown if an error occurs with ostream.public byte getType()
public byte getCode()
public short getSequence()
public short setSequence(short seq)
public int getLength()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |