net.i2p.router.transport.udp

## Class PeerStateDestroyed

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

- All Implemented Interfaces:
    SSU2Payload.PayloadCallback, SSU2Sender

      class PeerStateDestroyed
      extends Object
      implements SSU2Payload.PayloadCallback, SSU2Sender

  Small, stub version of PeerState2, for handling destroy acks with possible tokens in them. This is the "closing state" as defined in QUIC RFC-9000 section 10.2.1. Unlike in QUIC, we do increment the packet number for every sent destroy packet. Also, we retain the header and body decryption keys, and we do process any tokens received. We only respond when receiving data or a termination with a non-ack reason. Does not extend PeerState2 or PeerState.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `_wantACKSendSince`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PeerStateDestroyed(RouterContext ctx, UDPTransport transport, PeerState2 peer)` This must be called after the first termination or termination ack was sent from PeerState2, so the next packet number is correct.
    `PeerStateDestroyed(RouterContext ctx, UDPTransport transport, RemoteHostId id, long sendID, long rcvID, CipherState sendCha, CipherState rcvCha, byte[] sendKey1, byte[] sendKey2, byte[] rcvKey2, int reason)` Direct from IES2, there was never a PS2.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `fragmentsSent(long pktNum, int length, List<PacketBuilder.Fragment> fragments)`
    `SSU2Bitfield` | `getAckedMessages()`
    `byte` | `getFlags()`
    `int` | `getMTU()`
    `long` | `getNextPacketNumber()`
    `(package private) long` | `getRcvConnID()`
    `SSU2Bitfield` | `getReceivedMessages()`
    `RemoteHostId` | `getRemoteHostId()`
    `InetAddress` | `getRemoteIPAddress()`
    `int` | `getRemotePort()`
    `CipherState` | `getSendCipher()`
    `long` | `getSendConnID()`
    `byte[]` | `getSendHeaderEncryptKey1()`
    `byte[]` | `getSendHeaderEncryptKey2()`
    `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 count)`
    `void` | `gotToken(long token, long expires)`
    `boolean` | `isIPv6()`
    `void` | `kill()` Call at transport shutdown or cache eviction
    `(package private) void` | `receivePacket(RemoteHostId from, UDPPacket packet)`
    `(package private) void` | `receivePacket(UDPPacket packet)`
    `void` | `setDestroyReason(int reason)`
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### _wantACKSendSince

          protected volatile long _wantACKSendSince

  - ### Constructor Detail

    - #### PeerStateDestroyed

          public PeerStateDestroyed(RouterContext ctx,
                                    UDPTransport transport,
                                    PeerState2 peer)

      This must be called after the first termination or termination ack was sent from PeerState2, so the next packet number is correct.
      Parameters:
        `peer` - that just sent (or received and sent) a termination

    - #### PeerStateDestroyed

          public PeerStateDestroyed(RouterContext ctx,
                                    UDPTransport transport,
                                    RemoteHostId id,
                                    long sendID,
                                    long rcvID,
                                    CipherState sendCha,
                                    CipherState rcvCha,
                                    byte[] sendKey1,
                                    byte[] sendKey2,
                                    byte[] rcvKey2,
                                    int reason)

      Direct from IES2, there was never a PS2. Caller must send termination after creating.

  - ### Method Detail

    - #### fragmentsSent

          public void fragmentsSent(long pktNum,
                                    int length,
                                    List<PacketBuilder.Fragment> fragments)

      Specified by:
        `fragmentsSent` in interface `SSU2Sender`

    - #### getAckedMessages

          public SSU2Bitfield getAckedMessages()

      Specified by:
        `getAckedMessages` in interface `SSU2Sender`
      Returns:
        null always, we don't care what was acked

    - #### getFlags

          public byte getFlags()

      Specified by:
        `getFlags` in interface `SSU2Sender`

    - #### getMTU

          public int getMTU()

      Specified by:
        `getMTU` in interface `SSU2Sender`

    - #### getNextPacketNumber

          public long getNextPacketNumber()

      Specified by:
        `getNextPacketNumber` in interface `SSU2Sender`

    - #### getRcvConnID

          long getRcvConnID()

    - #### getReceivedMessages

          public SSU2Bitfield getReceivedMessages()

      Specified by:
        `getReceivedMessages` in interface `SSU2Sender`

    - #### getRemoteHostId

          public RemoteHostId getRemoteHostId()

      Specified by:
        `getRemoteHostId` in interface `SSU2Sender`

    - #### getRemoteIPAddress

          public InetAddress getRemoteIPAddress()

      Specified by:
        `getRemoteIPAddress` in interface `SSU2Sender`

    - #### getRemotePort

          public int getRemotePort()

      Specified by:
        `getRemotePort` in interface `SSU2Sender`

    - #### getSendCipher

          public CipherState getSendCipher()

      Specified by:
        `getSendCipher` in interface `SSU2Sender`

    - #### getSendConnID

          public long getSendConnID()

      Specified by:
        `getSendConnID` in interface `SSU2Sender`

    - #### getSendHeaderEncryptKey1

          public byte[] getSendHeaderEncryptKey1()

      Specified by:
        `getSendHeaderEncryptKey1` in interface `SSU2Sender`

    - #### getSendHeaderEncryptKey2

          public byte[] getSendHeaderEncryptKey2()

      Specified by:
        `getSendHeaderEncryptKey2` in interface `SSU2Sender`

    - #### gotACK

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

      Specified by:
        `gotACK` in interface `SSU2Payload.PayloadCallback`
        `ranges` - null if none

    - #### gotAddress

          public void gotAddress(byte[] ip,
                                 int port)

      Specified by:
        `gotAddress` in interface `SSU2Payload.PayloadCallback`

    - #### gotDateTime

          public void gotDateTime(long time)

      Specified by:
        `gotDateTime` in interface `SSU2Payload.PayloadCallback`

    - #### gotFragment

          public void gotFragment(byte[] data,
                                  int off,
                                  int len,
                                  long messageId,
                                  int frag,
                                  boolean isLast)

      Description copied from interface: `SSU2Payload.PayloadCallback`
      Data must be copied out in this method. Data starts at the 9 byte header for fragment 0.
      Specified by:
        `gotFragment` in interface `SSU2Payload.PayloadCallback`
        `off` - offset in data
        `len` - length of data to copy

    - #### gotI2NP

          public void gotI2NP(I2NPMessage msg)

      Specified by:
        `gotI2NP` in interface `SSU2Payload.PayloadCallback`

    - #### gotOptions

          public void gotOptions(byte[] options,
                                 boolean isHandshake)

      Specified by:
        `gotOptions` in interface `SSU2Payload.PayloadCallback`
        `isHandshake` - true only for message 3 part 2

    - #### gotPathChallenge

          public void gotPathChallenge(RemoteHostId from,
                                       byte[] data)

      Specified by:
        `gotPathChallenge` in interface `SSU2Payload.PayloadCallback`
      Parameters:
        `from` - null if unknown

    - #### gotPathResponse

          public void gotPathResponse(RemoteHostId from,
                                      byte[] data)

      Specified by:
        `gotPathResponse` in interface `SSU2Payload.PayloadCallback`
      Parameters:
        `from` - null if unknown

    - #### gotPeerTest

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

      Specified by:
        `gotPeerTest` in interface `SSU2Payload.PayloadCallback`
      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

          public void gotRelayIntro(Hash aliceHash,
                                    byte[] data)

      Specified by:
        `gotRelayIntro` in interface `SSU2Payload.PayloadCallback`
        `data` - excludes flag, includes signature

    - #### gotRelayRequest

          public void gotRelayRequest(byte[] data)

      Specified by:
        `gotRelayRequest` in interface `SSU2Payload.PayloadCallback`
      Parameters:
        `data` - excludes flag, includes signature

    - #### gotRelayResponse

          public void gotRelayResponse(int status,
                                       byte[] data)

      Specified by:
        `gotRelayResponse` in interface `SSU2Payload.PayloadCallback`
      Parameters:
        `status` - 0 = accept, 1-255 = reject
        `data` - excludes flag, includes signature

    - #### gotRelayTag

          public void gotRelayTag(long tag)

      Specified by:
        `gotRelayTag` in interface `SSU2Payload.PayloadCallback`

    - #### gotRelayTagRequest

          public void gotRelayTagRequest()

      Specified by:
        `gotRelayTagRequest` in interface `SSU2Payload.PayloadCallback`

    - #### gotRI

          public void gotRI(RouterInfo ri,
                            boolean isHandshake,
                            boolean flood)

      Specified by:
        `gotRI` in interface `SSU2Payload.PayloadCallback`
      Parameters:
        `ri` - will already be validated
        `isHandshake` - true only for message 3 part 2

    - #### gotRIFragment

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

      Specified by:
        `gotRIFragment` in interface `SSU2Payload.PayloadCallback`
      Parameters:
        `data` - is first gzipped and then fragmented
        `isHandshake` - true only for message 3 part 2

    - #### gotTermination

          public void gotTermination(int reason,
                                     long count)

      Specified by:
        `gotTermination` in interface `SSU2Payload.PayloadCallback`
        `count` - in theory could wrap around to negative, but very unlikely

    - #### gotToken

          public void gotToken(long token,
                               long expires)

      Specified by:
        `gotToken` in interface `SSU2Payload.PayloadCallback`

    - #### isIPv6

          public boolean isIPv6()

      Specified by:
        `isIPv6` in interface `SSU2Sender`

    - #### kill

          public void kill()

      Call at transport shutdown or cache eviction

    - #### receivePacket

          void receivePacket(RemoteHostId from,
                             UDPPacket packet)

      Parameters:
        `from` - source address
        `packet` - fully encrypted, header and body decryption will be done here

    - #### receivePacket

          void receivePacket(UDPPacket packet)

      Parameters:
        `packet` - fully encrypted, header and body decryption will be done here

    - #### setDestroyReason

          public void setDestroyReason(int reason)

      Specified by:
        `setDestroyReason` in interface `SSU2Sender`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`