net.i2p.router.transport.udp
Class OutboundEstablishState

java.lang.Object
  extended by net.i2p.router.transport.udp.OutboundEstablishState

 class OutboundEstablishState
extends Object

Data for a new connection being established, where we initiated the connection with a remote peer. In other words, we are Alice and they are Bob.


Nested Class Summary
static class OutboundEstablishState.OutboundState
           
 
Constructor Summary
OutboundEstablishState(RouterContext ctx, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, SessionKey introKey, UDPAddress addr, DHSessionKeyBuilder.Factory dh)
           
 
Method Summary
 void addMessage(OutNetMessage msg)
          Queue a message to be sent after the session is established.
 boolean complete()
           
 void confirmedPacketsSent()
          note that we just sent the SessionConfirmed packet
 void dataReceived()
          we have received a real data packet, so we're done establishing
 void fail()
          The SessionCreated validation failed
 SessionKey getCipherKey()
           
(package private)  RemoteHostId getClaimedAddress()
          This will never be a hash-based address.
 long getConfirmedSentTime()
           
 long getEstablishBeginTime()
           
 SessionKey getIntroKey()
           
 long getIntroNonce()
           
 long getIntroSentTime()
           
 long getLifetime()
          how long have we been trying to establish this session?
 SessionKey getMACKey()
           
 OutNetMessage getNextQueuedMessage()
           
 long getNextSendTime()
           
 byte[] getReceivedIP()
           
 int getReceivedPort()
           
 long getReceivedRelayTag()
           
 long getReceivedSignedOnTime()
           
 UDPAddress getRemoteAddress()
           
(package private)  RemoteHostId getRemoteHostId()
          This should be what the state is currently indexed by in the _outboundStates table.
 RouterIdentity getRemoteIdentity()
           
 long getRequestSentTime()
           
 byte[] getSentIP()
          The remote side (Bob) - note that in some places he's called Charlie.
 int getSentPort()
          The remote side (Bob) - note that in some places he's called Charlie.
 Signature getSentSignature()
           
 long getSentSignedOnTime()
           
 byte[] getSentX()
           
 OutboundEstablishState.OutboundState getState()
           
 void introduced(byte[] bobIP, int bobPort)
          This changes the remoteHostId from a hash-based one or possibly incorrect IP/port to what the introducer told us.
 void introductionFailed()
           
 void introSent()
          note that we just sent the RelayRequest packet
 void prepareSessionConfirmed()
          Let's sign everything so we can fragment properly.
 void receiveSessionCreated(UDPPacketReader.SessionCreatedReader reader)
           
 void requestSent()
          note that we just sent the SessionRequest packet
 void setIntroNonce(long nonce)
           
 String toString()
           
 boolean validateSessionCreated()
          Blocking call (run in the establisher thread) to determine if the session was created properly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OutboundEstablishState

public OutboundEstablishState(RouterContext ctx,
                              RemoteHostId claimedAddress,
                              RemoteHostId remoteHostId,
                              RouterIdentity remotePeer,
                              SessionKey introKey,
                              UDPAddress addr,
                              DHSessionKeyBuilder.Factory dh)
Parameters:
claimedAddress - an IP/port based RemoteHostId, or null if unknown
remoteHostId - non-null, == claimedAddress if direct, or a hash-based one if indirect
addr - non-null
Method Detail

getState

public OutboundEstablishState.OutboundState getState()

complete

public boolean complete()
Returns:
if previously complete

getRemoteAddress

public UDPAddress getRemoteAddress()
Returns:
non-null

setIntroNonce

public void setIntroNonce(long nonce)

getIntroNonce

public long getIntroNonce()
Returns:
-1 if unset

addMessage

public void addMessage(OutNetMessage msg)
Queue a message to be sent after the session is established.


getNextQueuedMessage

public OutNetMessage getNextQueuedMessage()
Returns:
null if none

getRemoteIdentity

public RouterIdentity getRemoteIdentity()

getIntroKey

public SessionKey getIntroKey()

getSentX

public byte[] getSentX()

getSentIP

public byte[] getSentIP()
The remote side (Bob) - note that in some places he's called Charlie. Warning - may change after introduction. May be null before introduction.


getSentPort

public int getSentPort()
The remote side (Bob) - note that in some places he's called Charlie. Warning - may change after introduction. May be -1 before introduction.


receiveSessionCreated

public void receiveSessionCreated(UDPPacketReader.SessionCreatedReader reader)

validateSessionCreated

public boolean validateSessionCreated()
Blocking call (run in the establisher thread) to determine if the session was created properly. If it wasn't, all the SessionCreated remnants are dropped (perhaps they were spoofed, etc) so that we can receive another one Generates session key and mac key.

Returns:
true if valid

fail

public void fail()
The SessionCreated validation failed


getCipherKey

public SessionKey getCipherKey()

getMACKey

public SessionKey getMACKey()

getReceivedRelayTag

public long getReceivedRelayTag()

getSentSignedOnTime

public long getSentSignedOnTime()

getReceivedSignedOnTime

public long getReceivedSignedOnTime()

getReceivedIP

public byte[] getReceivedIP()

getReceivedPort

public int getReceivedPort()

prepareSessionConfirmed

public void prepareSessionConfirmed()
Let's sign everything so we can fragment properly. Note that while a SessionConfirmed could in theory be fragmented, in practice a RouterIdentity is 387 bytes and a single fragment is 512 bytes max, so it will never be fragmented.


getSentSignature

public Signature getSentSignature()

confirmedPacketsSent

public void confirmedPacketsSent()
note that we just sent the SessionConfirmed packet


getConfirmedSentTime

public long getConfirmedSentTime()
Returns:
when we sent the first SessionConfirmed packet, or 0
Since:
0.9.2

requestSent

public void requestSent()
note that we just sent the SessionRequest packet


getRequestSentTime

public long getRequestSentTime()
Returns:
when we sent the first SessionRequest packet, or 0
Since:
0.9.2

introSent

public void introSent()
note that we just sent the RelayRequest packet


getIntroSentTime

public long getIntroSentTime()
Returns:
when we sent the first RelayRequest packet, or 0
Since:
0.9.2

introductionFailed

public void introductionFailed()

introduced

public void introduced(byte[] bobIP,
                       int bobPort)
This changes the remoteHostId from a hash-based one or possibly incorrect IP/port to what the introducer told us. All params are for the remote end (NOT the introducer) and must have been validated already.


getLifetime

public long getLifetime()
how long have we been trying to establish this session?


getEstablishBeginTime

public long getEstablishBeginTime()

getNextSendTime

public long getNextSendTime()

getRemoteHostId

RemoteHostId getRemoteHostId()
This should be what the state is currently indexed by in the _outboundStates table. Beware - During introduction, this is a router hash. After introduced() is called, this is set to the IP/port the introducer told us.

Returns:
non-null

getClaimedAddress

RemoteHostId getClaimedAddress()
This will never be a hash-based address. This is the 'claimed' (unverified) address from the netdb, or null. It is not changed after introduction. Use getRemoteHostId() for the verified address.

Returns:
may be null

dataReceived

public void dataReceived()
we have received a real data packet, so we're done establishing


toString

public String toString()
Overrides:
toString in class Object
Since:
0.8.9