public class MapRequestMessage extends Message
NatPmpDevice
. It is important to remove the mapping before shutdown
of the NatPmpDevice
. Refer to the parameters of
#MapRequestMessage(boolean, int, int, long, com.hoodcomputing.natpmp.MessageResponseInterface)
for details of how to perform this.Constructor and Description |
---|
MapRequestMessage(boolean isTCP,
int internalPort,
int requestedExternalPort,
int requestedPortMappingLifetime,
MessageResponseInterface listener)
Constructs a new
MapRequestMessage . |
Modifier and Type | Method and Description |
---|---|
Integer |
getExternalPort()
Gets the external port that was assigned.
|
int |
getInternalPort()
Gets the internal port on which mapped data will arrive.
|
Integer |
getPortMappingLifetime()
Gets the assigned port mapping lifetime.
|
int |
getRequestedExternalPort()
Get sthe external port that was requested.
|
int |
getRequestedPortMappingLifetime()
Gets the requested port mapping lifetime.
|
getResponseException, getResultCode, getSecondsSinceEpoch
public MapRequestMessage(boolean isTCP, int internalPort, int requestedExternalPort, int requestedPortMappingLifetime, MessageResponseInterface listener)
MapRequestMessage
. If
requestedPortMappingLifetime is zero, an existing port mapping is
removed. If both internalPort and requestedPortMappingLifetime are zero,
then all mappings for this host are removed.isTCP
- A value of true indicates that this is a TCP mapping. A value
of false indicates that this is a UDP mapping.internalPort
- The port on which this client is listening. A value of zero,
along with a lifetime of zero indicates that all port mappings
for this client are to be removed.requestedExternalPort
- The external port to request. This port may not be available.
Always check the result of the Message to determine which
external port is assigned. A value of zero indicates that the
NAT-PMP Gateway should choose a port on its own.requestedPortMappingLifetime
- The time, in seconds, to request the mapping for. A value of
zero requests that this mapping is removed. Always check the
result of the Message to determine the actual lifetime that
was assigned, as it may be different than the requested. The
recommended port mapping lifetime is 3600 seconds. The
protocol specifies an unsigned integer for this parameter,
however Java will not support that as a data type. Therefore,
the parameter is given as a long. Do not assign values larger
than an unsigned int can handle to this parameter.listener
- The MessageResponseInterface
that will respond to the
message result.public int getInternalPort()
public int getRequestedExternalPort()
public Integer getExternalPort() throws NatPmpException
NatPmpException
- Thrown if there was an exception generated during the parsing
of the respnse.public int getRequestedPortMappingLifetime()
public Integer getPortMappingLifetime() throws NatPmpException
NatPmpException
- Thrown if there was an exception generated during the parsing
of the respnse.Copyright © 2013. All Rights Reserved.