All Implemented Interfaces:
I2NPMessage

public class VariableTunnelBuildMessageextends TunnelBuildMessage
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

    • VariableTunnelBuildMessage

      public VariableTunnelBuildMessage(I2PAppContext context)
      Zero record count, will be set with readMessage().
      Parameters:
      context - the router context, used for I2P globals while reading and writing records
    • VariableTunnelBuildMessage

      public VariableTunnelBuildMessage(I2PAppContext context, int records)
      Constructor with the given number of build records.
      Parameters:
      context - the router context, used for I2P globals while reading and writing records
      records - the number of build records this message carries, 1 through MAX_RECORD_COUNT (8)
  • 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 23 for variable-record tunnel build requests.
      Specified by:
      getType in interface I2NPMessage
      Overrides:
      getType in class TunnelBuildMessage
      Returns:
      the message type constant, 23
    • 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 TunnelBuildMessage