net.i2p.router.transport
Interface Transport

All Known Implementing Classes:
NTCPTransport, TransportImpl, UDPTransport

public interface Transport

Defines a way to send a message to another peer and start listening for messages. To implement a new or pluggable I2P transport, implement this interface, and add it to TransportManager.startListening().


Nested Class Summary
static class Transport.AddressSource
           
 
Method Summary
 TransportBid bid(RouterInfo toAddress, long dataSize)
           
 int countActivePeers()
           
 int countActiveSendPeers()
           
 int countPeers()
           
 void externalAddressReceived(Transport.AddressSource source, byte[] ip, int port)
          Notify a transport of an external address change.
 void externalAddressRemoved(Transport.AddressSource source, boolean ipv6)
          Notify a transport of an external address change.
 void forwardPortStatus(byte[] ip, int port, int externalPort, boolean success, String reason)
          Notify a transport of the results of trying to forward a port.
 Vector<Long> getClockSkews()
           
 List<RouterAddress> getCurrentAddresses()
          What addresses are we currently listening to? Replaces getCurrentAddress()
 List<String> getMostRecentErrorMessages()
           
 CommSystemFacade.Status getReachabilityStatus()
          Previously returned short, now enum as of 0.9.20
 int getRequestedPort()
          What INTERNAL port would the transport like to have forwarded by UPnP.
 String getStyle()
          The unique identity of this Transport
 boolean hasCurrentAddress()
          Do we have any current address?
 boolean haveCapacity()
           
 boolean haveCapacity(int pct)
           
 boolean isBacklogged(Hash peer)
           
 boolean isEstablished(Hash peer)
           
 boolean isUnreachable(Hash peer)
           
 void recheckReachability()
          Deprecated. unused
 void renderStatusHTML(Writer out, String urlBase, int sortFlags)
           
 void send(OutNetMessage msg)
          Asynchronously send the message as requested in the message and, if the send is successful, queue up any msg.getOnSendJob job, and register it with the OutboundMessageRegistry (if it has a reply selector).
 void setListener(TransportEventListener listener)
          Who to notify on message availability
 void startListening()
           
 void stopListening()
           
 List<RouterAddress> updateAddress()
          Ask the transport to update its addresses based on current information and return them
 boolean wasUnreachable(Hash peer)
          Was the peer UNreachable (outbound only) the last time we tried it? This is NOT reset if the peer contacts us and it is never expired.
 

Method Detail

bid

TransportBid bid(RouterInfo toAddress,
                 long dataSize)

send

void send(OutNetMessage msg)
Asynchronously send the message as requested in the message and, if the send is successful, queue up any msg.getOnSendJob job, and register it with the OutboundMessageRegistry (if it has a reply selector). If the send fails, queue up any msg.getOnFailedSendJob


startListening

void startListening()

stopListening

void stopListening()

getCurrentAddresses

List<RouterAddress> getCurrentAddresses()
What addresses are we currently listening to? Replaces getCurrentAddress()

Returns:
all addresses, non-null
Since:
IPv6

hasCurrentAddress

boolean hasCurrentAddress()
Do we have any current address?

Since:
IPv6

updateAddress

List<RouterAddress> updateAddress()
Ask the transport to update its addresses based on current information and return them

Returns:
all addresses, non-null

externalAddressReceived

void externalAddressReceived(Transport.AddressSource source,
                             byte[] ip,
                             int port)
Notify a transport of an external address change. This may be from a local interface, UPnP, a config change, etc. This should not be called if the ip didn't change (from that source's point of view), or is a local address. May be called multiple times for IPv4 or IPv6. The transport should also do its own checking on whether to accept notifications from this source. This can be called before startListening() to set an initial address, or after the transport is running.

Parameters:
source - defined in Transport.java
ip - typ. IPv4 or IPv6 non-local; may be null to indicate IPv4 failure or port info only
port - 0 for unknown or unchanged

externalAddressRemoved

void externalAddressRemoved(Transport.AddressSource source,
                            boolean ipv6)
Notify a transport of an external address change. This may be from a local interface, UPnP, a config change, etc. This should not be called if the ip didn't change (from that source's point of view), or is a local address. May be called multiple times for IPv4 or IPv6. The transport should also do its own checking on whether to accept notifications from this source. This can be called after the transport is running. TODO externalAddressRemoved(source, ip, port)

Parameters:
source - defined in Transport.java
Since:
0.9.20

forwardPortStatus

void forwardPortStatus(byte[] ip,
                       int port,
                       int externalPort,
                       boolean success,
                       String reason)
Notify a transport of the results of trying to forward a port.

Parameters:
ip - may be null
port - the internal port
externalPort - the external port, which for now should always be the same as the internal port if the forwarding was successful.

getRequestedPort

int getRequestedPort()
What INTERNAL port would the transport like to have forwarded by UPnP. This can't be passed via getCurrentAddress(), as we have to open the port before we can publish the address, and that's the external port anyway.

Returns:
port or -1 for none or 0 for any

setListener

void setListener(TransportEventListener listener)
Who to notify on message availability


getStyle

String getStyle()
The unique identity of this Transport


countPeers

int countPeers()

countActivePeers

int countActivePeers()

countActiveSendPeers

int countActiveSendPeers()

haveCapacity

boolean haveCapacity()

haveCapacity

boolean haveCapacity(int pct)

getClockSkews

Vector<Long> getClockSkews()

getMostRecentErrorMessages

List<String> getMostRecentErrorMessages()

renderStatusHTML

void renderStatusHTML(Writer out,
                      String urlBase,
                      int sortFlags)
                      throws IOException
Throws:
IOException

getReachabilityStatus

CommSystemFacade.Status getReachabilityStatus()
Previously returned short, now enum as of 0.9.20


recheckReachability

void recheckReachability()
Deprecated. unused


isBacklogged

boolean isBacklogged(Hash peer)

wasUnreachable

boolean wasUnreachable(Hash peer)
Was the peer UNreachable (outbound only) the last time we tried it? This is NOT reset if the peer contacts us and it is never expired.


isUnreachable

boolean isUnreachable(Hash peer)

isEstablished

boolean isEstablished(Hash peer)