All Implemented Interfaces:
I2NPMessage

public class ShortTunnelBuildMessageextends TunnelBuildMessage
Variable size, small records. Preliminary, see proposal 157.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2NP message type ID for a short tunnel build request.
      See Also:
    • SHORT_RECORD_SIZE

      public static final int SHORT_RECORD_SIZE
      Maximum build record size in bytes for this message type.
      See Also:
  • Constructor Details

    • ShortTunnelBuildMessage

      public ShortTunnelBuildMessage(I2PAppContext context)
      Zero record count, will be set with readMessage(byte[], int, int, int).
      Parameters:
      context - the context to use for the message
    • ShortTunnelBuildMessage

      public ShortTunnelBuildMessage(I2PAppContext context, int records)
      Create the message preallocated for the given number of build records.
      Parameters:
      context - the context to use for the message
      records - the number of build records to reserve room for
  • 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
    • 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 a short tunnel build message.
      Specified by:
      getType in interface I2NPMessage
      Overrides:
      getType in class TunnelBuildMessage
      Returns:
      the I2NP message type number, for dispatch
    • 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 TunnelBuildMessage