Class NrpePacket
- java.lang.Object
-
- org.opennms.netmgt.provision.support.nrpe.NrpePacket
-
public class NrpePacket extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PADDING
ConstantDEFAULT_PADDING=2
static java.lang.String
HELLO_COMMAND
ConstantHELLO_COMMAND="_NRPE_CHECK"
static int
MAX_PACKETBUFFER_LENGTH
ConstantMAX_PACKETBUFFER_LENGTH=1024
static int
PACKET_SIZE
ConstantPACKET_SIZE=2 + // packet version, 16 bit integer 2 + // packet type, 16 bit integer 4 + // crc32, 32 bit unsigned integer 2 + // result code MAX_PACKETBUFFER_LENGTH
static short
PACKET_VERSION_2
ConstantPACKET_VERSION_2=2
static short
QUERY_PACKET
ConstantQUERY_PACKET=1
static short
RESPONSE_PACKET
ConstantRESPONSE_PACKET=2
-
Constructor Summary
Constructors Constructor Description NrpePacket()
Constructor for NrpePacket.NrpePacket(short type, short resultCode, java.lang.String buffer)
Constructor for NrpePacket.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
buildPacket(int padding)
buildPacketbyte[]
buildPacket(int padding, java.security.SecureRandom random)
buildPacketjava.lang.String
getBuffer()
getBuffershort
getResultCode()
getResultCodeshort
getType()
getTypeshort
getVersion()
getVersionstatic int
positive(byte b)
positivestatic NrpePacket
receivePacket(java.io.InputStream i, int padding)
receivePacketvoid
setBuffer(java.lang.String buffer)
setBuffervoid
setResultCode(short resultCode)
setResultCodevoid
setType(short type)
setTypevoid
setVersion(short version)
setVersionjava.lang.String
toString()
toString
-
-
-
Field Detail
-
QUERY_PACKET
public static final short QUERY_PACKET
ConstantQUERY_PACKET=1
- See Also:
- Constant Field Values
-
RESPONSE_PACKET
public static final short RESPONSE_PACKET
ConstantRESPONSE_PACKET=2
- See Also:
- Constant Field Values
-
HELLO_COMMAND
public static final java.lang.String HELLO_COMMAND
ConstantHELLO_COMMAND="_NRPE_CHECK"
- See Also:
- Constant Field Values
-
PACKET_VERSION_2
public static final short PACKET_VERSION_2
ConstantPACKET_VERSION_2=2
- See Also:
- Constant Field Values
-
MAX_PACKETBUFFER_LENGTH
public static final int MAX_PACKETBUFFER_LENGTH
ConstantMAX_PACKETBUFFER_LENGTH=1024
- See Also:
- Constant Field Values
-
PACKET_SIZE
public static final int PACKET_SIZE
ConstantPACKET_SIZE=2 + // packet version, 16 bit integer 2 + // packet type, 16 bit integer 4 + // crc32, 32 bit unsigned integer 2 + // result code MAX_PACKETBUFFER_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_PADDING
public static final int DEFAULT_PADDING
ConstantDEFAULT_PADDING=2
- See Also:
- Constant Field Values
-
-
Method Detail
-
getVersion
public short getVersion()
getVersion
- Returns:
- a short.
-
setVersion
public void setVersion(short version)
setVersion
- Parameters:
version
- a short.
-
getType
public short getType()
getType
- Returns:
- a short.
-
setType
public void setType(short type)
setType
- Parameters:
type
- a short.
-
getResultCode
public short getResultCode()
getResultCode
- Returns:
- a short.
-
setResultCode
public void setResultCode(short resultCode)
setResultCode
- Parameters:
resultCode
- a short.
-
getBuffer
public java.lang.String getBuffer()
getBuffer
- Returns:
- a
String
object.
-
setBuffer
public void setBuffer(java.lang.String buffer)
setBuffer
- Parameters:
buffer
- aString
object.
-
receivePacket
public static NrpePacket receivePacket(java.io.InputStream i, int padding) throws NrpeException, java.io.IOException
receivePacket
- Parameters:
i
- aInputStream
object.padding
- a int.- Returns:
- a
NrpePacket
object. - Throws:
NrpeException
- if any.java.io.IOException
- if any.
-
positive
public static int positive(byte b)
positive
- Parameters:
b
- a byte.- Returns:
- a int.
-
toString
public java.lang.String toString()
toString
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
object.
-
buildPacket
public byte[] buildPacket(int padding)
buildPacket
- Parameters:
padding
- a int.- Returns:
- an array of byte.
-
buildPacket
public byte[] buildPacket(int padding, java.security.SecureRandom random)
buildPacket
- Parameters:
padding
- a int.random
- aSecureRandom
object.- Returns:
- an array of byte.
-
-