Interface PortMapping

All Known Implementing Classes:
NatPmpPortMapping, PcpPortMapping, UpnpIgdPortMapping

public interface PortMapping
Represents a method for creating port forwarding (e.g., PCP, NAT-PMP, or UPnP-IGD).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    acceptMessage(InetSocketAddress sender, io.netty.buffer.ByteBuf msg)
    Is called for incoming messages and returns true if the message should be consumed and removed from the pipeline.
    void
    handleMessage(io.netty.channel.ChannelHandlerContext ctx, InetSocketAddress sender, io.netty.buffer.ByteBuf msg)
    Is called for incoming messages and thus enables this method to react to relevant messages.
    void
    start(io.netty.channel.ChannelHandlerContext ctx, int port, Runnable onFailure)
    Tells the method to create a port forwarding and renew it independently.
    void
    stop(io.netty.channel.ChannelHandlerContext ctx)
    Shall remove any existing port forwarding again.
  • Method Details

    • start

      void start(io.netty.channel.ChannelHandlerContext ctx, int port, Runnable onFailure)
      Tells the method to create a port forwarding and renew it independently. If no forwarding can be created, onFailure must be called once.
      Parameters:
      ctx - the handler context
      port - the UdpServer.UdpServerBound port
      onFailure - will be called once on failure
    • stop

      void stop(io.netty.channel.ChannelHandlerContext ctx)
      Shall remove any existing port forwarding again.
      Parameters:
      ctx - the handler context
    • handleMessage

      void handleMessage(io.netty.channel.ChannelHandlerContext ctx, InetSocketAddress sender, io.netty.buffer.ByteBuf msg)
      Is called for incoming messages and thus enables this method to react to relevant messages.

      ReferenceCounted.release() ownership of msg is transferred to this PartialReadMessage.

      Parameters:
      ctx - the handler context
      sender - the sender of the message
      msg - the message
    • acceptMessage

      boolean acceptMessage(InetSocketAddress sender, io.netty.buffer.ByteBuf msg)
      Is called for incoming messages and returns true if the message should be consumed and removed from the pipeline.
      Parameters:
      sender - the sender of the message
      msg - the message
      Returns:
      true if the message is relevant for the current port forwarding method. Otherwise false