Class NrpePacket


  • public class NrpePacket
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_PADDING
      Constant DEFAULT_PADDING=2
      static java.lang.String HELLO_COMMAND
      Constant HELLO_COMMAND="_NRPE_CHECK"
      static int MAX_PACKETBUFFER_LENGTH
      Constant MAX_PACKETBUFFER_LENGTH=1024
      static int PACKET_SIZE
      Constant PACKET_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
      Constant PACKET_VERSION_2=2
      static short QUERY_PACKET
      Constant QUERY_PACKET=1
      static short RESPONSE_PACKET
      Constant RESPONSE_PACKET=2
    • Constructor Summary

      Constructors 
      Constructor Description
      NrpePacket()
      Constructor for NrpePacket.
      NrpePacket​(short type, short resultCode, java.lang.String buffer)
      Constructor for NrpePacket.
    • Field Detail

      • QUERY_PACKET

        public static final short QUERY_PACKET
        Constant QUERY_PACKET=1
        See Also:
        Constant Field Values
      • RESPONSE_PACKET

        public static final short RESPONSE_PACKET
        Constant RESPONSE_PACKET=2
        See Also:
        Constant Field Values
      • HELLO_COMMAND

        public static final java.lang.String HELLO_COMMAND
        Constant HELLO_COMMAND="_NRPE_CHECK"
        See Also:
        Constant Field Values
      • PACKET_VERSION_2

        public static final short PACKET_VERSION_2
        Constant PACKET_VERSION_2=2
        See Also:
        Constant Field Values
      • MAX_PACKETBUFFER_LENGTH

        public static final int MAX_PACKETBUFFER_LENGTH
        Constant MAX_PACKETBUFFER_LENGTH=1024
        See Also:
        Constant Field Values
      • PACKET_SIZE

        public static final int PACKET_SIZE
        Constant PACKET_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
        Constant DEFAULT_PADDING=2
        See Also:
        Constant Field Values
    • Constructor Detail

      • NrpePacket

        public NrpePacket()

        Constructor for NrpePacket.

      • NrpePacket

        public NrpePacket​(short type,
                          short resultCode,
                          java.lang.String buffer)

        Constructor for NrpePacket.

        Parameters:
        type - a short.
        resultCode - a short.
        buffer - a String object.
    • 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 - a String object.
      • receivePacket

        public static NrpePacket receivePacket​(java.io.InputStream i,
                                               int padding)
                                        throws NrpeException,
                                               java.io.IOException

        receivePacket

        Parameters:
        i - a InputStream 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 class java.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 - a SecureRandom object.
        Returns:
        an array of byte.