Package net.i2p.router.transport.udp
Class InboundEstablishState2
- java.lang.Object
-
- net.i2p.router.transport.udp.InboundEstablishState
-
- net.i2p.router.transport.udp.InboundEstablishState2
-
- All Implemented Interfaces:
SSU2Payload.PayloadCallback
class InboundEstablishState2 extends InboundEstablishState implements SSU2Payload.PayloadCallback
Data for a new connection being established, where the remote peer has initiated the connection with us. In other words, they are Alice and we are Bob. SSU2 only.- Since:
- 0.9.54
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.i2p.router.transport.udp.InboundEstablishState
InboundEstablishState.InboundState
-
-
Field Summary
-
Fields inherited from class net.i2p.router.transport.udp.InboundEstablishState
_aliceIP, _alicePort, _bobIP, _bobPort, _context, _createdSentCount, _currentState, _establishBegin, _introductionRequested, _lastSend, _log, _nextSend, _receivedConfirmedIdentity, _receivedUnconfirmedIdentity, _remoteHostId, _rtt, _sentRelayTag, MAX_DELAY, RETRANSMIT_DELAY
-
-
Constructor Summary
Constructors Constructor Description InboundEstablishState2(RouterContext ctx, UDPTransport transport, UDPPacket packet)
Start a new handshake with the given incoming packet, which must be a Session Request or Token Request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createdPacketSent()
note that we just sent a SessionCreated packetvoid
createdPacketSent(DatagramPacket pkt)
note that we just sent the SessionCreated packet and save it for retransmissionvoid
generateSessionKey()
Generates session key and mac key.HandshakeState
getHandshakeState()
EstablishmentManager.Token
getNextToken()
PeerState2
getPeerState()
long
getRcvConnID()
byte[]
getRcvHeaderEncryptKey1()
byte[]
getRcvHeaderEncryptKey2()
UDPPacket
getRetransmitSessionCreatedPacket()
long
getSendConnID()
byte[]
getSendHeaderEncryptKey1()
byte[]
getSendHeaderEncryptKey2()
InetSocketAddress
getSentAddress()
long
getToken()
int
getVersion()
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
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)
void
queuePossibleDataPacket(UDPPacket packet)
PeerState2
receiveSessionConfirmed(UDPPacket packet)
Receive the last messages in the handshake, and create the PeerState.void
receiveSessionRequestAfterRetry(UDPPacket packet)
void
retryPacketSent()
note that we just sent a Retry packetString
toString()
-
Methods inherited from class net.i2p.router.transport.udp.InboundEstablishState
addMessage, complete, confirmedFullyReceived, fail, getCipherKey, getConfirmedIdentity, getEstablishBeginTime, getLifetime, getMACKey, getNextQueuedMessage, getNextSendTime, getReceivedOurIP, getReceivedX, getRemoteHostId, getRTT, getSentIP, getSentPort, getSentRelayTag, getSentSignature, getSentSignedOnTime, getSentY, getState, isComplete, isIntroductionRequested, packetReceived, prepareSessionCreated, receiveSessionConfirmed, receiveSessionRequest, sessionRequestReceived, setSentRelayTag
-
-
-
-
Constructor Detail
-
InboundEstablishState2
public InboundEstablishState2(RouterContext ctx, UDPTransport transport, UDPPacket packet) throws GeneralSecurityException
Start a new handshake with the given incoming packet, which must be a Session Request or Token Request. Caller must then check getState() and build a Retry or Session Created in response.- Parameters:
packet
- with all header encryption removed, either a SessionRequest OR a TokenRequest.- Throws:
GeneralSecurityException
-
-
Method Detail
-
getVersion
public int getVersion()
- Overrides:
getVersion
in classInboundEstablishState
-
gotDateTime
public void gotDateTime(long time)
- Specified by:
gotDateTime
in interfaceSSU2Payload.PayloadCallback
-
gotOptions
public void gotOptions(byte[] options, boolean isHandshake)
- Specified by:
gotOptions
in interfaceSSU2Payload.PayloadCallback
isHandshake
- true only for message 3 part 2
-
gotRI
public void gotRI(RouterInfo ri, boolean isHandshake, boolean flood) throws DataFormatException
- Specified by:
gotRI
in interfaceSSU2Payload.PayloadCallback
- Parameters:
ri
- will already be validatedisHandshake
- true only for message 3 part 2- Throws:
DataFormatException
-
gotRIFragment
public void gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags)
- Specified by:
gotRIFragment
in interfaceSSU2Payload.PayloadCallback
- Parameters:
data
- is first gzipped and then fragmentedisHandshake
- true only for message 3 part 2
-
gotAddress
public void gotAddress(byte[] ip, int port)
- Specified by:
gotAddress
in interfaceSSU2Payload.PayloadCallback
-
gotRelayTagRequest
public void gotRelayTagRequest()
- Specified by:
gotRelayTagRequest
in interfaceSSU2Payload.PayloadCallback
-
gotRelayTag
public void gotRelayTag(long tag)
- Specified by:
gotRelayTag
in interfaceSSU2Payload.PayloadCallback
-
gotRelayRequest
public void gotRelayRequest(byte[] data)
- Specified by:
gotRelayRequest
in interfaceSSU2Payload.PayloadCallback
- Parameters:
data
- excludes flag, includes signature
-
gotRelayResponse
public void gotRelayResponse(int status, byte[] data)
- Specified by:
gotRelayResponse
in interfaceSSU2Payload.PayloadCallback
- Parameters:
status
- 0 = accept, 1-255 = rejectdata
- excludes flag, includes signature
-
gotRelayIntro
public void gotRelayIntro(Hash aliceHash, byte[] data)
- Specified by:
gotRelayIntro
in interfaceSSU2Payload.PayloadCallback
data
- excludes flag, includes signature
-
gotPeerTest
public void gotPeerTest(int msg, int status, Hash h, byte[] data)
- Specified by:
gotPeerTest
in interfaceSSU2Payload.PayloadCallback
- Parameters:
msg
- 1-7status
- 0 = accept, 1-255 = rejecth
- Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7data
- excludes flag, includes signature
-
gotToken
public void gotToken(long token, long expires)
- Specified by:
gotToken
in interfaceSSU2Payload.PayloadCallback
-
gotI2NP
public void gotI2NP(I2NPMessage msg)
- Specified by:
gotI2NP
in interfaceSSU2Payload.PayloadCallback
-
gotFragment
public void gotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast) throws DataFormatException
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 interfaceSSU2Payload.PayloadCallback
off
- offset in datalen
- length of data to copy- Throws:
DataFormatException
-
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges)
- Specified by:
gotACK
in interfaceSSU2Payload.PayloadCallback
ranges
- null if none
-
gotTermination
public void gotTermination(int reason, long count)
- Specified by:
gotTermination
in interfaceSSU2Payload.PayloadCallback
count
- in theory could wrap around to negative, but very unlikely
-
generateSessionKey
public void generateSessionKey()
Description copied from class:InboundEstablishState
Generates session key and mac key.- Overrides:
generateSessionKey
in classInboundEstablishState
-
getSendConnID
public long getSendConnID()
-
getRcvConnID
public long getRcvConnID()
-
getToken
public long getToken()
-
getNextToken
public EstablishmentManager.Token getNextToken()
-
getHandshakeState
public HandshakeState getHandshakeState()
-
getSendHeaderEncryptKey1
public byte[] getSendHeaderEncryptKey1()
-
getRcvHeaderEncryptKey1
public byte[] getRcvHeaderEncryptKey1()
-
getSendHeaderEncryptKey2
public byte[] getSendHeaderEncryptKey2()
-
getRcvHeaderEncryptKey2
public byte[] getRcvHeaderEncryptKey2()
-
getSentAddress
public InetSocketAddress getSentAddress()
-
createdPacketSent
public void createdPacketSent()
Description copied from class:InboundEstablishState
note that we just sent a SessionCreated packet- Overrides:
createdPacketSent
in classInboundEstablishState
-
retryPacketSent
public void retryPacketSent()
note that we just sent a Retry packet
-
receiveSessionRequestAfterRetry
public void receiveSessionRequestAfterRetry(UDPPacket packet) throws GeneralSecurityException
- Throws:
GeneralSecurityException
-
receiveSessionConfirmed
public PeerState2 receiveSessionConfirmed(UDPPacket packet) throws GeneralSecurityException
Receive the last messages in the handshake, and create the PeerState. If the message is fragmented, store the data for reassembly and return, unless this was the last one.- Returns:
- the new PeerState2 if are done, may also be retrieved from getPeerState(), or null if more fragments to go
- Throws:
GeneralSecurityException
-
createdPacketSent
public void createdPacketSent(DatagramPacket pkt)
note that we just sent the SessionCreated packet and save it for retransmission
-
getRetransmitSessionCreatedPacket
public UDPPacket getRetransmitSessionCreatedPacket()
- Returns:
- null if not sent or already got the session confirmed
-
getPeerState
public PeerState2 getPeerState()
- Returns:
- null if we have not received the session confirmed
-
queuePossibleDataPacket
public void queuePossibleDataPacket(UDPPacket packet)
- Parameters:
packet
- with header still encrypted
-
toString
public String toString()
- Overrides:
toString
in classInboundEstablishState
-
-