net.i2p.router.transport.udp

## Class SSU2Payload

- java.lang.Object
- - net.i2p.router.transport.udp.SSU2Payload

-     class SSU2Payload
      extends Object

  SSU2 Payload generation and parsing utilities.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SSU2Payload.AckBlock` Block containing acknowledgment data.
    `static class` | `SSU2Payload.AddressBlock` Block containing IP address and port information.
    `static class` | `SSU2Payload.Block` Base class for blocks to be transmitted.
    `static class` | `SSU2Payload.DateTimeBlock` Block containing the current date and time.
    `static class` | `SSU2Payload.FirstFragBlock` Same format as I2NPBlock
    `static class` | `SSU2Payload.FollowFragBlock` Follow-on fragment block for SSU2 payload.
    `static class` | `SSU2Payload.I2NPBlock` Block containing I2NP message data.
    `static class` | `SSU2Payload.NewTokenBlock` Block containing a new session token.
    `static class` | `SSU2Payload.OptionsBlock` Block containing session options.
    `static class` | `SSU2Payload.PaddingBlock` Block containing padding data.
    `static class` | `SSU2Payload.PathChallengeBlock` Path challenge block for SSU2 payload.
    `static class` | `SSU2Payload.PathResponseBlock` Path response block for SSU2 payload.
    `static interface` | `SSU2Payload.PayloadCallback` For all callbacks, recommend throwing exceptions only from the handshake.
    `static class` | `SSU2Payload.PeerTestBlock` Block containing peer test data.
    `static class` | `SSU2Payload.RelayIntroBlock` Block containing relay introduction data.
    `static class` | `SSU2Payload.RelayRequestBlock` Block containing relay request data.
    `static class` | `SSU2Payload.RelayResponseBlock` Block containing relay response data.
    `static class` | `SSU2Payload.RelayTagBlock` Block containing relay tag data.
    `static class` | `SSU2Payload.RelayTagRequestBlock` Block containing relay tag request data.
    `static class` | `SSU2Payload.RIBlock` Block containing router information data.
    `static class` | `SSU2Payload.TerminationBlock` Block containing session termination data.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BLOCK_HEADER_SIZE`
    `static int` | `BLOCK_TERMINATION`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SSU2Payload()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `processPayload(I2PAppContext ctx, SSU2Payload.PayloadCallback cb, byte[] payload, int off, int length, boolean isHandshake, RemoteHostId from)` Incoming payload.
    `static int` | `writePayload(byte[] payload, int off, List<SSU2Payload.Block> blocks)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BLOCK_HEADER_SIZE

          public static final int BLOCK_HEADER_SIZE

      See Also:
        Constant Field Values

    - #### BLOCK_TERMINATION

          public static final int BLOCK_TERMINATION

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SSU2Payload

          SSU2Payload()

  - ### Method Detail

    - #### processPayload

          public static int processPayload(I2PAppContext ctx,
                                           SSU2Payload.PayloadCallback cb,
                                           byte[] payload,
                                           int off,
                                           int length,
                                           boolean isHandshake,
                                           RemoteHostId from)
                                    throws IOException,
                                           DataFormatException,
                                           I2NPMessageException

      Incoming payload. Calls the callback for each received block.
      Parameters:
        `isHandshake` - true for Token Req, Retry, Sess Req, Sess Created; false for Sess Confirmed
        `from` - for path challenge/response only, may be null
      Returns:
        number of blocks processed
      Throws:
        `IOException` - on major errors
        `DataFormatException` - on parsing of individual blocks
        `I2NPMessageException` - on parsing of I2NP block

    - #### writePayload

          public static int writePayload(byte[] payload,
                                         int off,
                                         List<SSU2Payload.Block> blocks)

      Parameters:
        `payload` - writes to it starting at off
      Returns:
        the new offset