Class PcpPortMapping
java.lang.Object
org.drasyl.handler.remote.portmapper.PcpPortMapping
- All Implemented Interfaces:
PortMapping
Port Forwarding on NAT-enabled routers via PCP.
This methods requires the following steps:
- identify own default network gateway
- send mapping request to gateway for every local network address
- gateway should only create mapping for local network address it belongs to
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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
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.toString()
-
Field Details
-
TIMEOUT
-
-
Constructor Details
-
PcpPortMapping
public PcpPortMapping()
-
-
Method Details
-
start
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 interfacePortMapping
- Parameters:
ctx
- the handler contextport
- theUdpServer.UdpServerBound
portonFailure
- will be called once on failure
-
stop
public void stop(io.netty.channel.ChannelHandlerContext ctx) Description copied from interface:PortMapping
Shall remove any existing port forwarding again.- Specified by:
stop
in interfacePortMapping
- Parameters:
ctx
- the handler context
-
acceptMessage
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 interfacePortMapping
- Parameters:
sender
- the sender of the messagemsg
- the message- Returns:
true
if 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:PortMapping
Is called for incoming messages and thus enables this method to react to relevant messages.ReferenceCounted.release()
ownership ofmsg
is transferred to thisPartialReadMessage
.- Specified by:
handleMessage
in interfacePortMapping
- Parameters:
ctx
- the handler contextsender
- the sender of the messagemsg
- the message
-
toString
-