net.i2p.router.transport

## Class UPnP

- java.lang.Object
- - org.cybergarage.upnp.ControlPoint
  - - 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.
  See Also:
    "http://www.upnp.org/", "http://en.wikipedia.org/wiki/Universal_Plug_and_Play"

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `UPnP.IPv6ForwardPort` IPv6-specific port forwarding configuration.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `LEASE_TIME_SECONDS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UPnP(I2PAppContext context, int ssdpPort, int httpPort, InetAddress[] binds)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `deviceAdded(Device dev)` DeviceChangeListener
    `void` | `deviceRemoved(Device dev)` DeviceChangeListener
    `void` | `eventNotifyReceived(String uuid, long seq, String varName, String value)` EventListener callback - unused for now - supported in miniupnpd as of 1.1
    `DetectedIP[]` | `getAddress()` As we only support a single active IGD, and we don't currently have any way to get any IPv6 addresses, this will return at most one IPv4 address.
    `static Set<String>` | `getLocalAddresses()` Get the addresses we want to bind to
    `static void` | `main(String[] args)` Dumps out device info in semi-HTML format
    `void` | `onChangePublicPorts(Set<ForwardPort> ports, ForwardPortCallback cb)` Registers a callback when the given ports change.
    `String` | `renderStatusHTML()` warning - slow
    `boolean` | `runPlugin()`
    `void` | `search()` We override search() to update the SSDPSearchResponseSocketList, SSDPNotifySocketList, and HTTPServerList every time.
    `void` | `terminate()` WARNING - Blocking up to 2 seconds
    `void` | `unregisterPortMappings()`

    - ### Methods inherited from class org.cybergarage.upnp.ControlPoint

      `addDeviceChangeListener, addEventListener, addNotifyListener, addSearchResponseListener, finalize, getDevice, getDeviceDisposer, getDeviceList, getEventSubURI, getExpiredDeviceMonitoringInterval, getHTTPPort, getHTTPServerList, getRenewSubscriber, getSearchMx, getSSDPNotifySocketList, getSSDPPort, getSSDPSearchResponseSocketList, getSubscriberService, getUserData, hasDevice, httpRequestRecieved, isNMPRMode, isSubscribed, lock, notifyReceived, performAddDeviceListener, performEventListener, performNotifyListener, performRemoveDeviceListener, performSearchResponseListener, print, removeDevice, removeDevice, removeDeviceChangeListener, removeEventListener, removeExpiredDevices, removeNotifyListener, removeSearchResponseListener, renewSubscriberService, renewSubscriberService, renewSubscriberService, search, search, searchResponseReceived, setDeviceDisposer, setEventSubURI, setExpiredDeviceMonitoringInterval, setHTTPPort, setNMPRMode, setRenewSubscriber, setSearchMx, setSSDPPort, setUserData, 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`

- - ### Field Detail

    - #### LEASE_TIME_SECONDS

          public static final int LEASE_TIME_SECONDS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### UPnP

          public UPnP(I2PAppContext context,
                      int ssdpPort,
                      int httpPort,
                      InetAddress[] binds)

  - ### Method Detail

    - #### deviceAdded

          public void deviceAdded(Device dev)

      DeviceChangeListener
      Specified by:
        `deviceAdded` in interface `DeviceChangeListener`
      Parameters:
        `dev` - the device that was added

    - #### deviceRemoved

          public void deviceRemoved(Device dev)

      DeviceChangeListener
      Specified by:
        `deviceRemoved` in interface `DeviceChangeListener`
      Parameters:
        `dev` - the device that was removed

    - #### eventNotifyReceived

          public void eventNotifyReceived(String uuid,
                                          long seq,
                                          String varName,
                                          String value)

      EventListener callback - unused for now - supported in miniupnpd as of 1.1
      Specified by:
        `eventNotifyReceived` in interface `EventListener`
      Parameters:
        `uuid` - the subscription UUID identifying the subscription
        `seq` - the sequence number of this event notification
        `varName` - the name of the state variable that changed
        `value` - the new value of the state variable

    - #### getAddress

          public DetectedIP[] getAddress()

      As we only support a single active IGD, and we don't currently have any way to get any IPv6 addresses, this will return at most one IPv4 address. Blocking!!!
      Returns:
        array of length 1 containing an IPv4 address, or null

    - #### getLocalAddresses

          public static Set<String> getLocalAddresses()

      Get the addresses we want to bind to

    - #### main

          public static void main(String[] args)
                           throws Exception

      Dumps out device info in semi-HTML format
      Throws:
        `Exception`

    - #### onChangePublicPorts

          public void onChangePublicPorts(Set<ForwardPort> ports,
                                          ForwardPortCallback cb)

      Registers a callback when the given ports change. non-blocking
      Parameters:
        `ports` - non-null
        `cb` - in UPnPManager

    - #### renderStatusHTML

          public String renderStatusHTML()

      warning - slow

    - #### runPlugin

          public boolean runPlugin()

    - #### search

          public void search()

      We override search() to update the SSDPSearchResponseSocketList, SSDPNotifySocketList, and HTTPServerList every time. Otherwise, we are just listening on the interfaces that were present when started.
      Overrides:
        `search` in class `ControlPoint`

    - #### terminate

          public void terminate()

      WARNING - Blocking up to 2 seconds

    - #### unregisterPortMappings

          public void unregisterPortMappings()