All Implemented Interfaces:
I2NPMessage

public class OutboundTunnelBuildReplyMessageextends TunnelBuildReplyMessage
Sent from the OBEP to the tunnel creator via an inbound tunnel. Contains a variable number of encrypted records. This message must be garlic-encrypted to hide the contents from the OBGW.

Preliminary, see proposal 157.

  • Field Details

  • Constructor Details

    • OutboundTunnelBuildReplyMessage

      public OutboundTunnelBuildReplyMessage(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
    • OutboundTunnelBuildReplyMessage

      public OutboundTunnelBuildReplyMessage(I2PAppContext context, int records)
      Creates a reply holding the given number of encrypted records.
      Parameters:
      context - the I2P app context
      records - the number of encrypted records to allocate
  • Method Details

    • setRecord

      public void setRecord(int index, EncryptedBuildRecord record)
      Store a build record, checking its length.
      Overrides:
      setRecord in class TunnelBuildMessageBase
      Parameters:
      index - the zero-based position of the record in the record array
      record - must be ShortEncryptedBuildRecord or null
      Throws:
      IllegalArgumentException - on bad slot or record length.
    • calculateWrittenLength

      protected int calculateWrittenLength()
      Written length of the message body: one record count byte plus the records.
      Overrides:
      calculateWrittenLength in class TunnelBuildMessageBase
      Returns:
      the number of bytes the body will occupy once serialized
    • getType

      public int getType()
      I2NP message type of an outbound tunnel build reply.
      Specified by:
      getType in interface I2NPMessage
      Overrides:
      getType in class TunnelBuildReplyMessage
      Returns:
      the I2NP message type ID, always MESSAGE_TYPE
    • readMessage

      public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException
      Read the records from a byte array.
      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 the records to the output array, starting at the given index.
      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()
      String form for debugging, showing the id and record count.
      Overrides:
      toString in class TunnelBuildReplyMessage