All Implemented Interfaces:
I2NPMessage

public class UnknownI2NPMessageextends FastI2NPMessageImpl
This is similar to DataMessage or GarlicMessage but with a variable message type. This is defined so routers can route messages they don't know about. We don't extend those classes so that any code that does (instanceof foo) won't return true for this type. Load tests use DataMessage, for example. Also, those classes include an additional length field that we can't use here. See InboundMessageDistributor.

There is no setData() method, the only way to create one of these is to read it with readMessage(byte[], int, int, int) (i.e., it came from some other router)

As of 0.8.12 this class is working. It is used at the IBGW to reduce the processing required. For zero-hop IB tunnels, the convert() method is used to reconstitute a standard message class.

  • Field Details

    • _data

      private byte[] _data
      The message contents, as read from the wire.
    • _type

      private final int _type
      The message type number.
  • Constructor Details

    • UnknownI2NPMessage

      public UnknownI2NPMessage(I2PAppContext context, int type)
      Message with the given type, unknown to the router.
      Parameters:
      context - the app context for the message
      type - 0-255
  • Method Details

    • readMessage

      public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException
      Raw message data; may only be set once.
      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:
      IllegalStateException - if data previously set, to protect saved checksum
      I2NPMessageException - if the stream doesn't contain a valid message that this class can read.
    • calculateWrittenLength

      protected int calculateWrittenLength()
      Calculate the message body's length (not including the header and footer).
      Specified by:
      calculateWrittenLength in class I2NPMessageImpl
      Returns:
      the number of bytes the body will occupy once serialized
    • writeMessageBody

      protected int writeMessageBody(byte[] out, int curIndex)
      Write the message body to the output array, starting at the given index.
      Specified by:
      writeMessageBody in class I2NPMessageImpl
      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)
    • getType

      public int getType()
      Note that this returns the "true" type, so that the IBGW can correctly make drop decisions.
      Returns:
      0-255
    • convert

      public I2NPMessage convert() throws I2NPMessageException
      Attempt to convert this message to a known message class. This does the delayed verification using the saved checksum.

      Used by TunnelGatewayZeroHop.

      Returns:
      the message as its known subclass, verified against the saved checksum
      Throws:
      I2NPMessageException - if the conversion fails
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object