All Known Implementing Classes:
InboundEstablishState, NTCPConnection.NTCP2ReadState
Enclosing class:
NTCP2Payload

public static interface NTCP2Payload.PayloadCallback
For all callbacks, recommend throwing exceptions only from the handshake. Exceptions will get thrown out of NTCP2Payload.processPayload(I2PAppContext, NTCP2Payload.PayloadCallback, byte[], int, int, boolean) and prevent processing of succeeding blocks.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    gotDateTime(long time)
    Receive the data/time block.
    void
    Receive an I2NP message block.
    void
    gotOptions(byte[] options, boolean isHandshake)
    Receive an options block, the peer's padding negotiation parameters.
    void
    gotPadding(int paddingLength, int frameLength)
    For stats.
    void
    gotRI(RouterInfo ri, boolean isHandshake, boolean flood)
    Receive a RouterInfo block.
    void
    gotTermination(int reason, long lastReceived)
    Receive a termination block, the peer is closing the connection.
    void
    gotUnknown(int type, int len)
    Receive an unknown block type.
  • Method Details

    • gotDateTime

      void gotDateTime(long time) throws DataFormatException
      Receive the data/time block.
      Parameters:
      time - milliseconds since the epoch, as sent in the block
      Throws:
      DataFormatException - if the callback cannot process the block
    • gotI2NP

      void gotI2NP(I2NPMessage msg) throws I2NPMessageException
      Receive an I2NP message block.
      Parameters:
      msg - the message, already deserialized out of the frame
      Throws:
      I2NPMessageException - if the callback cannot process the message
    • gotOptions

      void gotOptions(byte[] options, boolean isHandshake) throws DataFormatException
      Receive an options block, the peer's padding negotiation parameters.
      Parameters:
      options - the option bytes, copied out of the frame
      isHandshake - true only for message 3 part 2
      Throws:
      DataFormatException - if the callback cannot process the block
    • gotRI

      void gotRI(RouterInfo ri, boolean isHandshake, boolean flood) throws DataFormatException
      Receive a RouterInfo block.
      Parameters:
      ri - will already be validated
      isHandshake - true only for message 3 part 2
      flood - true if the flag byte asks the receiver to flood this RouterInfo
      Throws:
      DataFormatException - if the RouterInfo is rejected, e.g. an unpublished date
    • gotTermination

      void gotTermination(int reason, long lastReceived)
      Receive a termination block, the peer is closing the connection.
      Parameters:
      reason - the termination reason code
      lastReceived - in theory could wrap around to negative, but very unlikely
    • gotPadding

      void gotPadding(int paddingLength, int frameLength)
      For stats.
      Parameters:
      paddingLength - the number of padding bytes, not including the 3-byte block header
      frameLength - the total size of the frame, including all blocks and block headers
    • gotUnknown

      void gotUnknown(int type, int len)
      Receive an unknown block type.
      Parameters:
      type - the block type byte from the block header
      len - the block length in bytes, not counting the 3-byte header