java.lang.Object
net.i2p.router.crypto.ratchet.RatchetPayload.Block
Direct Known Subclasses:
RatchetPayload.AckBlock, RatchetPayload.AckRequestBlock, RatchetPayload.DateTimeBlock, RatchetPayload.GarlicBlock, RatchetPayload.NextKeyBlock, RatchetPayload.OptionsBlock, RatchetPayload.PaddingBlock, RatchetPayload.PNBlock, RatchetPayload.TerminationBlock
Enclosing class:
RatchetPayload

public abstract static class RatchetPayload.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
    Type of the block being read or written.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    abstract int
    Data size of the block.
    int
    Total size of the block.
    A debug string naming the block type and length.
    int
    write(byte[] tgt, int off)
    Writes the block header and data to the target.
    abstract int
    writeData(byte[] tgt, int off)
    Write the block data.

    Methods inherited from class Object

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

    • type

      private final int type
      Type of the block being read or written.
  • Constructor Details

    • Block

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

    • write

      public int write(byte[] tgt, int off)
      Writes the block header and data to the target.
      Parameters:
      tgt - the buffer the 3 byte header and the block data are written into
      off - the offset in tgt where the header starts
      Returns:
      the offset just past the block data written to tgt
    • getTotalLength

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

      public abstract int getDataLength()
      Data size of the block.
      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.
      Parameters:
      tgt - the target buffer
      off - the offset in tgt where the block data starts
      Returns:
      the offset just past the data written to tgt
    • toString

      public String toString()
      A debug string naming the block type and length.
      Overrides:
      toString in class Object
      Returns:
      the debug text