net.i2p.router.transport.udp

## Interface SSU2Payload.PayloadCallback

- All Known Implementing Classes:
    InboundEstablishState2, OutboundEstablishState2, PeerState2, PeerStateDestroyed
  Enclosing class:
    SSU2Payload

      public static interface SSU2Payload.PayloadCallback

  For all callbacks, recommend throwing exceptions only from the handshake. Exceptions will get thrown out of processPayload() and prevent processing of succeeding blocks.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `gotACK(long ackThru, int acks, byte[] ranges)`
    `void` | `gotAddress(byte[] ip, int port)`
    `void` | `gotDateTime(long time)`
    `void` | `gotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast)` Data must be copied out in this method.
    `void` | `gotI2NP(I2NPMessage msg)`
    `void` | `gotOptions(byte[] options, boolean isHandshake)`
    `void` | `gotPathChallenge(RemoteHostId from, byte[] data)`
    `void` | `gotPathResponse(RemoteHostId from, byte[] data)`
    `void` | `gotPeerTest(int msg, int status, Hash h, byte[] data)`
    `void` | `gotRelayIntro(Hash aliceHash, byte[] data)`
    `void` | `gotRelayRequest(byte[] data)`
    `void` | `gotRelayResponse(int status, byte[] data)`
    `void` | `gotRelayTag(long tag)`
    `void` | `gotRelayTagRequest()`
    `void` | `gotRI(RouterInfo ri, boolean isHandshake, boolean flood)`
    `void` | `gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags)`
    `void` | `gotTermination(int reason, long lastReceived)`
    `void` | `gotToken(long token, long expires)`

- - ### Method Detail

    - #### gotACK

          void gotACK(long ackThru,
                      int acks,
                      byte[] ranges)

      Parameters:
        `ranges` - null if none

    - #### gotAddress

          void gotAddress(byte[] ip,
                          int port)

    - #### gotDateTime

          void gotDateTime(long time)
                    throws DataFormatException

      Throws:
        `DataFormatException`

    - #### gotFragment

          void gotFragment(byte[] data,
                           int off,
                           int len,
                           long messageID,
                           int frag,
                           boolean isLast)
                    throws DataFormatException

      Data must be copied out in this method. Data starts at the 9 byte header for fragment 0.
      Parameters:
        `off` - offset in data
        `len` - length of data to copy
      Throws:
        `DataFormatException`

    - #### gotI2NP

          void gotI2NP(I2NPMessage msg)
                throws I2NPMessageException

      Throws:
        `I2NPMessageException`

    - #### gotOptions

          void gotOptions(byte[] options,
                          boolean isHandshake)
                   throws DataFormatException

      Parameters:
        `isHandshake` - true only for message 3 part 2
      Throws:
        `DataFormatException`

    - #### gotPathChallenge

          void gotPathChallenge(RemoteHostId from,
                                byte[] data)

      Parameters:
        `from` - null if unknown

    - #### gotPathResponse

          void gotPathResponse(RemoteHostId from,
                               byte[] data)

      Parameters:
        `from` - null if unknown

    - #### gotPeerTest

          void gotPeerTest(int msg,
                           int status,
                           Hash h,
                           byte[] data)

      Parameters:
        `msg` - 1-7
        `status` - 0 = accept, 1-255 = reject
        `h` - Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7
        `data` - excludes flag, includes signature

    - #### gotRelayIntro

          void gotRelayIntro(Hash aliceHash,
                             byte[] data)

      Parameters:
        `data` - excludes flag, includes signature

    - #### gotRelayRequest

          void gotRelayRequest(byte[] data)

      Parameters:
        `data` - excludes flag, includes signature

    - #### gotRelayResponse

          void gotRelayResponse(int status,
                                byte[] data)

      Parameters:
        `status` - 0 = accept, 1-255 = reject
        `data` - excludes flag, includes signature

    - #### gotRelayTag

          void gotRelayTag(long tag)

    - #### gotRelayTagRequest

          void gotRelayTagRequest()

    - #### gotRI

          void gotRI(RouterInfo ri,
                     boolean isHandshake,
                     boolean flood)
              throws DataFormatException

      Parameters:
        `ri` - will already be validated
        `isHandshake` - true only for message 3 part 2
      Throws:
        `DataFormatException`

    - #### gotRIFragment

          void gotRIFragment(byte[] data,
                             boolean isHandshake,
                             boolean flood,
                             boolean isGzipped,
                             int frag,
                             int totalFrags)

      Parameters:
        `data` - is first gzipped and then fragmented
        `isHandshake` - true only for message 3 part 2

    - #### gotTermination

          void gotTermination(int reason,
                              long lastReceived)

      Parameters:
        `lastReceived` - in theory could wrap around to negative, but very unlikely

    - #### gotToken

          void gotToken(long token,
                        long expires)