Class UpnpIgdPortMapping
java.lang.Object
org.drasyl.handler.remote.portmapper.UpnpIgdPortMapping
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptMessage(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.voidhandleMessage(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.voidTells the method to create a port forwarding and renew it independently.voidstop(io.netty.channel.ChannelHandlerContext ctx) Shall remove any existing port forwarding again.toString()
-
Field Details
-
TIMEOUT
-
-
Constructor Details
-
UpnpIgdPortMapping
public UpnpIgdPortMapping()
-
-
Method Details
-
start
Description copied from interface:PortMappingTells the method to create a port forwarding and renew it independently. If no forwarding can be created,onFailuremust be called once.- Specified by:
startin interfacePortMapping- Parameters:
ctx- the handler contextport- theUdpServer.PortportonFailure- will be called once on failure
-
stop
public void stop(io.netty.channel.ChannelHandlerContext ctx) Description copied from interface:PortMappingShall remove any existing port forwarding again.- Specified by:
stopin interfacePortMapping- Parameters:
ctx- the handler context
-
acceptMessage
Description copied from interface:PortMappingIs called for incoming messages and returns true if the message should be consumed and removed from the pipeline.- Specified by:
acceptMessagein interfacePortMapping- Parameters:
sender- the sender of the messagemsg- the message- Returns:
trueif the message is relevant for the current port forwarding method. Otherwisefalse
-
handleMessage
public void handleMessage(io.netty.channel.ChannelHandlerContext ctx, InetSocketAddress sender, io.netty.buffer.ByteBuf msg) Description copied from interface:PortMappingIs called for incoming messages and thus enables this method to react to relevant messages.ReferenceCounted.release()ownership ofmsgis transferred to thisPartialReadMessage.- Specified by:
handleMessagein interfacePortMapping- Parameters:
ctx- the handler contextsender- the sender of the messagemsg- the message
-
toString
-