Class UpnpIgdPortMapping

  • All Implemented Interfaces:
    PortMapping

    public class UpnpIgdPortMapping
    extends Object
    implements PortMapping
    Port Forwarding on NAT-enabled routers via UPnP-IGD.

    This methods requires the following steps:

    • SSDP: do a discovery to find internet gateway devices
    • UPnP: request service information from each discovered gateway
    • UPnP: check if device is connected and has an external ip address
    • UPnP: check for existing port mapping and reuse it
    • UPnP: if there is no port mapping, create a new one
    • Field Detail

      • TIMEOUT

        public static final Duration TIMEOUT
    • Constructor Detail

      • UpnpIgdPortMapping

        public UpnpIgdPortMapping()
    • Method Detail

      • start

        public void start​(HandlerContext ctx,
                          NodeUpEvent event,
                          Runnable onFailure)
        Description copied from interface: PortMapping
        Tells the method to create a port forwarding and renew it independently. If no forwarding can be created, onFailure must be called once.
        Specified by:
        start in interface PortMapping
        Parameters:
        ctx - the handler context
        event - the node up event
        onFailure - will be called once on failure
      • stop

        public void stop​(HandlerContext ctx)
        Description copied from interface: PortMapping
        Shall remove any existing port forwarding again.
        Specified by:
        stop in interface PortMapping
        Parameters:
        ctx - the handler context
      • acceptMessage

        public boolean acceptMessage​(AddressedByteBuf msg)
        Description copied from interface: PortMapping
        Is called for incoming messages and returns true if the message should be consumed and removed from the pipeline.
        Specified by:
        acceptMessage in interface PortMapping
        Parameters:
        msg - the message
        Returns:
        true if the message is relevant for the current port forwarding method. Otherwise false
      • handleMessage

        public void handleMessage​(HandlerContext ctx,
                                  AddressedByteBuf msg)
        Description copied from interface: PortMapping
        Is called for incoming messages and thus enables this method to react to relevant messages.
        Specified by:
        handleMessage in interface PortMapping
        Parameters:
        ctx - the handler context
        msg - the message