All Implemented Interfaces:
I2NPMessage

public class VariableTunnelBuildReplyMessageextends TunnelBuildReplyMessage
Transmitted from the new outbound endpoint to the creator through a reply tunnel. Variable number of records.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      Message type ID for this I2NP message.
      See Also:
  • Constructor Details

    • VariableTunnelBuildReplyMessage

      public VariableTunnelBuildReplyMessage(I2PAppContext context)
      Zero record count, will be set with readMessage(byte[], int, int, int).
      Parameters:
      context - the I2P app context used to read and write the message
    • VariableTunnelBuildReplyMessage

      public VariableTunnelBuildReplyMessage(I2PAppContext context, int records)
      Constructor with the given number of build reply records.
      Parameters:
      context - the I2P app context used to read and write the message
      records - how many encrypted build reply records to allocate
  • Method Details

    • calculateWrittenLength

      protected int calculateWrittenLength()
      Length including record count byte plus all encrypted records.
      Overrides:
      calculateWrittenLength in class TunnelBuildMessageBase
      Returns:
      the number of bytes the body will occupy once serialized
    • getType

      public int getType()
      I2NP message type 24 for variable-record tunnel build replies.
      Specified by:
      getType in interface I2NPMessage
      Overrides:
      getType in class TunnelBuildReplyMessage
      Returns:
      the message type constant, 24
    • readMessage

      public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException
      Parse record count from first byte, then delegate to parent for record data.
      Specified by:
      readMessage in interface I2NPMessage
      Overrides:
      readMessage in class TunnelBuildMessageBase
      Parameters:
      data - data to read from
      offset - where to start in the data array
      dataSize - how long into the data to read
      type - I2NP message type
      Throws:
      I2NPMessageException - if the stream doesn't contain a valid message that this class can read.
    • writeMessageBody

      protected int writeMessageBody(byte[] out, int curIndex) throws I2NPMessageException
      Write record count byte followed by all encrypted build records.
      Overrides:
      writeMessageBody in class TunnelBuildMessageBase
      Parameters:
      out - the buffer to serialize the body into
      curIndex - the offset into out at which to begin writing; leave room for the signature where the header format calls for one
      Returns:
      the index into the array after the last byte written (NOT the length)
      Throws:
      I2NPMessageException - if the body cannot be serialized into out, because it is too small or a field is unserializable
    • toString

      public String toString()
      Label with unique ID and record count for logging.
      Overrides:
      toString in class TunnelBuildReplyMessage