Interface I2NPMessage

All Known Implementing Classes:
DatabaseLookupMessage, DatabaseSearchReplyMessage, DatabaseStoreMessage, DataMessage, DeliveryStatusMessage, FastI2NPMessageImpl, GarlicMessage, I2NPMessageImpl, OutboundTunnelBuildReplyMessage, ShortTunnelBuildMessage, ShortTunnelBuildReplyMessage, TunnelBuildMessage, TunnelBuildMessageBase, TunnelBuildReplyMessage, TunnelDataMessage, TunnelGatewayMessage, UnknownI2NPMessage, VariableTunnelBuildMessage, VariableTunnelBuildReplyMessage

public interface I2NPMessage
Base interface for all I2NP messages Note: No longer extends DataStructure as of 0.9.48
Author:
jrandom
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    4 bytes unsigned
    static final int
    Nominal limit, actual max is much less.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Date after which the message should be dropped (and the associated uniqueId forgotten)
    int
    How large the message is, including any checksums, i.e.
    int
    How large the raw message is with the short 5 byte header
    int
    Return the unique identifier for this type of I2NP message, as defined in the I2NP spec
    long
    Replay resistant message ID
    int
    readBytes(byte[] data, int type, int offset)
    Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification
    int
    readBytes(byte[] data, int type, int offset, int maxLen)
    Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification
    void
    readMessage(byte[] data, int offset, int dataSize, int type)
    Read the body into the data structures, after the initial type byte and the uniqueId / expiration, using the current class's format as defined by the I2NP specification
    void
    readMessage(byte[] data, int offset, int dataSize, int type, I2NPMessageHandler handler)
     
    void
     
    void
    setUniqueId(long id)
     
    byte[]
     
    int
    toByteArray(byte[] buffer)
    Write the message to the buffer, returning the new offset (NOT the length).
    int
    toByteArray(byte[] buffer, int off)
    Write the message to the buffer, returning the new offset (NOT the length).
    int
    toRawByteArray(byte[] buffer)
    Write the message to the buffer, returning the new offset (NOT the length).
    int
    toRawByteArrayNTCP2(byte[] buffer, int off)
    Write the message to the buffer, returning the new offset (NOT the length).
  • Field Details

    • MAX_ID_VALUE

      static final long MAX_ID_VALUE
      4 bytes unsigned
      See Also:
    • MAX_SIZE

      static final int MAX_SIZE
      Nominal limit, actual max is much less. See website docs for further restrictions due to various overhead and limitations in encryption, fragmentation, and the transports.
      See Also:
  • Method Details

    • readBytes

      int readBytes(byte[] data, int type, int offset) throws I2NPMessageException
      Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification
      Parameters:
      data - the data
      type - I2NP message type. If less than zero, read the type from data
      offset - where to start starting at type if type is < 0 (16 byte header) starting at ID if type is >= 0 (15 byte header)
      Returns:
      size of the message read (including headers)
      Throws:
      I2NPMessageException - if there is no valid message
    • readBytes

      int readBytes(byte[] data, int type, int offset, int maxLen) throws I2NPMessageException
      Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification
      Parameters:
      data - the data, may or may not include the type
      type - I2NP message type. If less than zero, read the type from data
      offset - where to start starting at type if type is < 0 (16 byte header) starting at ID if type is >= 0 (15 byte header)
      maxLen - read no more than this many bytes from data starting at offset, even if it is longer This includes the type byte only if type < 0
      Returns:
      size of the message read (including headers)
      Throws:
      I2NPMessageException - if there is no valid message
      Since:
      0.8.12
    • readMessage

      void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException
      Read the body into the data structures, after the initial type byte and the uniqueId / expiration, using the current class's format as defined by the I2NP specification
      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.
    • readMessage

      void readMessage(byte[] data, int offset, int dataSize, int type, I2NPMessageHandler handler) throws I2NPMessageException
      Throws:
      I2NPMessageException
    • getType

      int getType()
      Return the unique identifier for this type of I2NP message, as defined in the I2NP spec
    • getUniqueId

      long getUniqueId()
      Replay resistant message ID
    • setUniqueId

      void setUniqueId(long id)
    • getMessageExpiration

      long getMessageExpiration()
      Date after which the message should be dropped (and the associated uniqueId forgotten)
    • setMessageExpiration

      void setMessageExpiration(long exp)
    • getMessageSize

      int getMessageSize()
      How large the message is, including any checksums, i.e. full 16 byte header
    • getRawMessageSize

      int getRawMessageSize()
      How large the raw message is with the short 5 byte header
    • toByteArray

      byte[] toByteArray()
      Since:
      0.9.48 from DataStructure
    • toByteArray

      int toByteArray(byte[] buffer)
      Write the message to the buffer, returning the new offset (NOT the length). the data is formatted so as to be self contained, with the type, size, expiration, unique id, as well as a checksum bundled along. Full 16 byte header for NTCP 1.
      Returns:
      the new offset (NOT the length)
    • toByteArray

      int toByteArray(byte[] buffer, int off)
      Write the message to the buffer, returning the new offset (NOT the length). the data is formatted so as to be self contained, with the type, size, expiration, unique id, as well as a checksum bundled along. Full 16 byte header for NTCP 1.
      Parameters:
      off - the offset to start writing at
      Returns:
      the new offset (NOT the length)
      Since:
      0.9.36
    • toRawByteArray

      int toRawByteArray(byte[] buffer)
      Write the message to the buffer, returning the new offset (NOT the length). the data is is not self contained - it does not include the size, unique id, or any checksum, but does include the type and expiration. Short 5 byte header for SSU.
      Returns:
      the length written
    • toRawByteArrayNTCP2

      int toRawByteArrayNTCP2(byte[] buffer, int off)
      Write the message to the buffer, returning the new offset (NOT the length). the data is is not self contained - it does not include the size, unique id, or any checksum, but does include the type and expiration. Short 9 byte header for NTCP 2.
      Parameters:
      off - the offset to start writing at
      Returns:
      the new offset (NOT the length)
      Since:
      0.9.36