java.lang.Object
net.i2p.router.transport.udp.SSU2Payload.Block
Direct Known Subclasses:
SSU2Payload.AckBlock, SSU2Payload.AddressBlock, SSU2Payload.DateTimeBlock, SSU2Payload.FirstFragBlock, SSU2Payload.FollowFragBlock, SSU2Payload.I2NPBlock, SSU2Payload.NewTokenBlock, SSU2Payload.OptionsBlock, SSU2Payload.PaddingBlock, SSU2Payload.PathChallengeBlock, SSU2Payload.PathResponseBlock, SSU2Payload.PeerTestBlock, SSU2Payload.RelayIntroBlock, SSU2Payload.RelayRequestBlock, SSU2Payload.RelayResponseBlock, SSU2Payload.RelayTagBlock, SSU2Payload.RelayTagRequestBlock, SSU2Payload.RIBlock, SSU2Payload.TerminationBlock
Enclosing class:
SSU2Payload

public abstract static class SSU2Payload.Blockextends Object
Base class for blocks to be transmitted. Not used for receive; we use callbacks instead.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The payload block type number.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Block(int ttype)
    Create a new block of the given type.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract int
    Return the size of the block data, excluding the 3 byte header.
    int
    Return the total size of the block, including the 3 byte header.
    int
    The block type.
    String representation of this block.
    int
    write(byte[] tgt, int off)
    Write the block to the target array, returning the new offset.
    abstract int
    writeData(byte[] tgt, int off)
    Write the block data to the target array, returning the new offset.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • type

      private final int type
      The payload block type number.
  • Constructor Details

    • Block

      public Block(int ttype)
      Create a new block of the given type.
      Parameters:
      ttype - the block type identifier
  • Method Details

    • getType

      public int getType()
      The block type.
      Returns:
      the block type code this block was parsed from
    • write

      public int write(byte[] tgt, int off)
      Write the block to the target array, returning the new offset.
      Parameters:
      tgt - target array to write to
      off - offset in the target array
      Returns:
      the new offset after writing
    • getTotalLength

      public int getTotalLength()
      Return the total size of the block, including the 3 byte header.
      Returns:
      the size of the block, including the 3 byte header (type and size)
    • getDataLength

      public abstract int getDataLength()
      Return the size of the block data, excluding the 3 byte header.
      Returns:
      the size of the block, NOT including the 3 byte header (type and size)
    • writeData

      public abstract int writeData(byte[] tgt, int off)
      Write the block data to the target array, returning the new offset.
      Parameters:
      tgt - target array to write to
      off - offset in the target array
      Returns:
      the new offset after writing
    • toString

      public String toString()
      String representation of this block.
      Overrides:
      toString in class Object