net.i2p.router.transport
Class UPnP

java.lang.Object
  extended by org.cybergarage.upnp.ControlPoint
      extended by net.i2p.router.transport.UPnP
All Implemented Interfaces:
HTTPRequestListener, DeviceChangeListener, EventListener

public class UPnP
extends ControlPoint
implements DeviceChangeListener, EventListener

This (and all in org/freenet, org/cybergarage, org/xmlpull) grabbed from freenet SVN, mid-February 2009 by zzz. This file modded somewhat to remove freenet-specific stuff, but most of the glue to I2P is in UPnPManager (which was written from scratch and is not the Limewire one referred to below). ================== This plugin implements UP&P support on a Freenet node.

Author:
Florent Daignière <nextgens@freenetproject.org> some code has been borrowed from Limewire : @see com.limegroup.gnutella.UPnPManager
See Also:
"http://www.upnp.org/", "http://en.wikipedia.org/wiki/Universal_Plug_and_Play"

Constructor Summary
UPnP(I2PAppContext context)
           
 
Method Summary
 void deviceAdded(Device dev)
           
 void deviceRemoved(Device dev)
           
 void eventNotifyReceived(java.lang.String uuid, long seq, java.lang.String varName, java.lang.String value)
          event callback - unused for now - how many devices support events?
 DetectedIP[] getAddress()
           
 int getDownstreamMaxBitRate()
           
 java.lang.String getNATAddress()
           
 int getUpstreamMaxBitRate()
           
 boolean isNATPresent()
           
static void main(java.lang.String[] args)
           
 void onChangePublicPorts(java.util.Set<ForwardPort> ports, ForwardPortCallback cb)
          non-blocking
 java.lang.String renderStatusHTML()
          warning - slow
 boolean runPlugin()
           
 void terminate()
           
 boolean tryAddMapping(java.lang.String protocol, int port, java.lang.String description, ForwardPort fp)
           
 void unregisterPortMappings()
           
 
Methods inherited from class org.cybergarage.upnp.ControlPoint
addDeviceChangeListener, addEventListener, addNotifyListener, addSearchResponseListener, finalize, getDevice, getDeviceDisposer, getDeviceList, getEventSubURI, getExpiredDeviceMonitoringInterval, getHTTPPort, getRenewSubscriber, getSearchMx, getSSDPPort, getSubscriberService, hasDevice, httpRequestRecieved, isNMPRMode, isSubscribed, lock, notifyReceived, performAddDeviceListener, performEventListener, performNotifyListener, performRemoveDeviceListener, performSearchResponseListener, print, removeDeviceChangeListener, removeEventListener, removeExpiredDevices, removeNotifyListener, removeSearchResponseListener, renewSubscriberService, renewSubscriberService, renewSubscriberService, search, search, search, searchResponseReceived, setDeviceDisposer, setEventSubURI, setExpiredDeviceMonitoringInterval, setHTTPPort, setNMPRMode, setRenewSubscriber, setSearchMx, setSSDPPort, start, start, start, stop, subscribe, subscribe, subscribe, subscribe, unlock, unsubscribe, unsubscribe, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UPnP

public UPnP(I2PAppContext context)
Method Detail

runPlugin

public boolean runPlugin()

terminate

public void terminate()

getAddress

public DetectedIP[] getAddress()

deviceAdded

public void deviceAdded(Device dev)
Specified by:
deviceAdded in interface DeviceChangeListener

tryAddMapping

public boolean tryAddMapping(java.lang.String protocol,
                             int port,
                             java.lang.String description,
                             ForwardPort fp)

unregisterPortMappings

public void unregisterPortMappings()

deviceRemoved

public void deviceRemoved(Device dev)
Specified by:
deviceRemoved in interface DeviceChangeListener

eventNotifyReceived

public void eventNotifyReceived(java.lang.String uuid,
                                long seq,
                                java.lang.String varName,
                                java.lang.String value)
event callback - unused for now - how many devices support events?

Specified by:
eventNotifyReceived in interface EventListener

isNATPresent

public boolean isNATPresent()
Returns:
whether we are behind an UPnP-enabled NAT/router

getNATAddress

public java.lang.String getNATAddress()
Returns:
the external address the NAT thinks we have. Blocking. null if we can't find it.

getUpstreamMaxBitRate

public int getUpstreamMaxBitRate()
Returns:
the reported upstream bit rate in bits per second. -1 if it's not available. Blocking.

getDownstreamMaxBitRate

public int getDownstreamMaxBitRate()
Returns:
the reported downstream bit rate in bits per second. -1 if it's not available. Blocking.

renderStatusHTML

public java.lang.String renderStatusHTML()
warning - slow


onChangePublicPorts

public void onChangePublicPorts(java.util.Set<ForwardPort> ports,
                                ForwardPortCallback cb)
non-blocking


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception