java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.HostReplyMessage
All Implemented Interfaces:
I2CPMessage

public class HostReplyMessageextends I2CPMessageImpl
Response to HostLookupMessage. Replaces DestReplyMessage.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      The I2CP message type number for this message.
      See Also:
    • _dest

      private Destination _dest
      The destination being replied with.
    • _reqID

      private long _reqID
      The request this answers, as a number.
    • _code

      private int _code
      Result of the lookup.
    • _sessionId

      private SessionId _sessionId
      The session the reply belongs to.
    • _options

      private Properties _options
      Options for opening the session.
    • RESULT_SUCCESS

      public static final int RESULT_SUCCESS
      The reply succeeded and the destination was accepted.
      See Also:
    • RESULT_FAILURE

      public static final int RESULT_FAILURE
      Generic fail, other codes TBD.
      See Also:
    • RESULT_SECRET_REQUIRED

      public static final int RESULT_SECRET_REQUIRED
      Request secret required result code.
      See Also:
    • RESULT_KEY_REQUIRED

      public static final int RESULT_KEY_REQUIRED
      Request key required result code.
      See Also:
    • RESULT_SECRET_AND_KEY_REQUIRED

      public static final int RESULT_SECRET_AND_KEY_REQUIRED
      Request secret and key required result code.
      See Also:
    • RESULT_DECRYPTION_FAILURE

      public static final int RESULT_DECRYPTION_FAILURE
      Decryption failure result code.
      See Also:
    • RESULT_LEASESET_LOOKUP_FAILURE

      public static final int RESULT_LEASESET_LOOKUP_FAILURE
      LeaseSet lookup failure result code.
      See Also:
    • RESULT_LOOKUP_TYPE_UNSUPPORTED

      public static final int RESULT_LOOKUP_TYPE_UNSUPPORTED
      Unsupported lookup type result code.
      See Also:
    • MAX_INT

      private static final long MAX_INT
      Largest request id that fits on the wire.
      See Also:
  • Constructor Details

    • HostReplyMessage

      public HostReplyMessage()
      Create an empty reply to be filled in by the reader.
    • HostReplyMessage

      public HostReplyMessage(SessionId id, Destination d, long reqID, Properties options)
      A message with RESULT_SUCCESS and a non-null Destination.
      Parameters:
      id - the session id
      d - non-null
      reqID - 0 to 2**32 - 1
      options - for replies to lookup types 2-4, may be null, see proposal 167
    • HostReplyMessage

      public HostReplyMessage(SessionId id, int failureCode, long reqID)
      A message with a failure code and no Destination.
      Parameters:
      id - the session id
      failureCode - 1-255
      reqID - from the HostLookup 0 to 2**32 - 1
  • Method Details

    • getSessionId

      public SessionId getSessionId()
      Session the reply belongs to.
      Returns:
      the session id, null until set or read
    • sessionId

      public SessionId sessionId()
      Return the SessionId for this message.
      Specified by:
      sessionId in interface I2CPMessage
      Overrides:
      sessionId in class I2CPMessageImpl
      Returns:
      null always. Extending classes with a SessionId must override.
    • getReqID

      public long getReqID()
      The ID of the request this message answers.
      Returns:
      0 to 2**32 - 1
    • getResultCode

      public int getResultCode()
      Why the host accepted or rejected the request.
      Returns:
      0 on success, 1-255 on failure
    • getDestination

      public Destination getDestination()
      The destination the host accepted, which the client now owns.
      Returns:
      non-null only if result code is zero
    • getOptions

      public Properties getOptions()
      Session config overrides carried by the reply.
      Returns:
      non-null only if result code is zero and options are present
    • doReadMessage

      protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException
      Read the message body from the input stream.
      Specified by:
      doReadMessage in class I2CPMessageImpl
      Parameters:
      in - positioned just past the 4 byte size and 1 byte type header
      size - how many payload bytes remain to be read
      Throws:
      I2CPMessageException - if the message format is invalid
      IOException - if there's an error reading from the stream
    • doWriteMessage

      protected byte[] doWriteMessage() throws I2CPMessageException, IOException
      Write the message body to the output stream.
      Specified by:
      doWriteMessage in class I2CPMessageImpl
      Returns:
      byte array
      Throws:
      I2CPMessageException - if the message cannot be written
      IOException - if there's an error writing to the stream
    • getType

      public int getType()
      Returns this message's I2CP type ID.
      Returns:
      the I2CP message type ID, MESSAGE_TYPE
    • toString

      public String toString()
      Returns a string representation of this message.
      Overrides:
      toString in class Object