Package org.linphone.core

# Interface NatPolicy

public interface NatPolicy
Policy to use to pass through NATs/firewalls.

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
Clear a NAT policy (deactivate all protocols and unset the STUN server).
`NatPolicy`
`clone()`
Clone an existing `NatPolicy` object.
`Core`
`getCore()`
Returns the `Core` object managing this nat policy, if any.
`long`
`getNativePointer()`
Gets the native pointer used by this class to make native method calls.
`String`
`getNatV4Address()`
Get the mandatory v4 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
`String`
`getNatV6Address()`
Get the mandatory v6 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
`String`
`getStunServer()`
Get the STUN/TURN server to use with this NAT policy.
`String`
`getStunServerUsername()`
Get the username used to authenticate with the STUN/TURN server.
`String`
`getTurnConfigurationEndpoint()`
Get the TURN configuration endpoint.
`Object`
`getUserData()`
Gets the object stored in this object user's data
`boolean`
`isIceEnabled()`
Tell whether ICE is enabled.
`boolean`
`isStunEnabled()`
Tell whether STUN is enabled.
`boolean`
`isTcpTurnTransportEnabled()`
Tells whether TCP TURN transport is enabled.
`boolean`
`isTlsTurnTransportEnabled()`
Tells whether TLS TURN transport is enabled.
`boolean`
`isTurnEnabled()`
Tell whether TURN is enabled.
`boolean`
`isUdpTurnTransportEnabled()`
Tells whether UDP TURN transport is enabled.
`boolean`
`isUpnpEnabled()`
Tell whether uPnP is enabled.
`void`
`resolveStunServer()`
Start a STUN server DNS resolution.
`void`
`setIceEnabled(boolean enable)`
Enable ICE.
`void`
`setNatV4Address(String v4Address)`
Set the mandatory v4 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
`void`
`setNatV6Address(String v4Address)`
Set the mandatory v6 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
`void`
`setStunEnabled(boolean enable)`
Enable STUN.
`void`
`setStunServer(String stunServer)`
Set the STUN/TURN server to use with this NAT policy.
`void`
`setStunServerUsername(String username)`
Set the username used to authenticate with the STUN/TURN server.
`void`
`setTcpTurnTransportEnabled(boolean enable)`
Enable TCP TURN transport.
`void`
`setTlsTurnTransportEnabled(boolean enable)`
Enable TLS TURN transport.
`void`
`setTurnConfigurationEndpoint(String endpoint)`
Set the TURN configuration endpoint.
`void`
`setTurnEnabled(boolean enable)`
Enable TURN.
`void`
`setUdpTurnTransportEnabled(boolean enable)`
Enable UDP TURN transport.
`void`
`setUpnpEnabled(boolean enable)`
Enable uPnP.
`void`
`setUserData(Object data)`
Sets the object to store in this object user's data
`String`
`toString()`

## Method Details

### getCore

@NonNull Core getCore()
Returns the `Core` object managing this nat policy, if any.

Returns:
  the `Core` object associated.

### isIceEnabled

boolean isIceEnabled()
Tell whether ICE is enabled.

Returns:
  Boolean value telling whether ICE is enabled.

### setIceEnabled

void setIceEnabled(boolean enable)
Enable ICE.
ICE can be enabled without STUN/TURN, in which case only the local candidates
will be used.

Parameters:
  `enable` - Boolean value telling whether to enable ICE.

### getNatV4Address

@Nullable String getNatV4Address()
Get the mandatory v4 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
Used when STUN or TURN are enabled.

Returns:
  the nat v4 address.

### setNatV4Address

void setNatV4Address(@Nullable String v4Address)
Set the mandatory v4 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
The IP address is used only if no stun server is set for server-reflexive
candidate gathering. Using this method is useful when Liblinphone is used in a
server product, when the server does not own the public IP address. Used when
STUN or TURN are enabled.

Parameters:
  `v4Address` - The STUN server to use with this NAT policy.

### getNatV6Address

@Nullable String getNatV6Address()
Get the mandatory v6 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
Used when STUN or TURN are enabled.

Returns:
  the nat v4 address.

### setNatV6Address

void setNatV6Address(@Nullable String v4Address)
Set the mandatory v6 IP address to use with this NAT policy as server-reflexive
candidate for ICE.
The IP address is used only if no stun server is set for server-reflexive
candidate gathering. Using this method is useful when Liblinphone is used in a
server product, when the server does not own the public IP address. Used when
STUN or TURN are enabled.

Parameters:
  `v4Address` - The STUN server to use with this NAT policy.

### isStunEnabled

boolean isStunEnabled()
Tell whether STUN is enabled.

Returns:
  Boolean value telling whether STUN is enabled.

### setStunEnabled

void setStunEnabled(boolean enable)
Enable STUN.
If TURN is also enabled, TURN will be used instead of STUN.

Parameters:
  `enable` - Boolean value telling whether to enable STUN.

### getStunServer

@Nullable String getStunServer()
Get the STUN/TURN server to use with this NAT policy.
Used when STUN or TURN are enabled.

Returns:
  The STUN server used by this NAT policy.

### setStunServer

void setStunServer(@Nullable String stunServer)
Set the STUN/TURN server to use with this NAT policy.
Used when STUN or TURN are enabled.

Parameters:
  `stunServer` - The STUN server to use with this NAT policy.

### getStunServerUsername

@Nullable String getStunServerUsername()
Get the username used to authenticate with the STUN/TURN server.
The authentication will search for a `AuthInfo` with this username. If it
is not set the username of the currently used `ProxyConfig` is used to
search for a LinphoneAuthInfo.

Returns:
  The username used to authenticate with the STUN/TURN server.

### setStunServerUsername

void setStunServerUsername(@Nullable String username)
Set the username used to authenticate with the STUN/TURN server.
The authentication will search for a `AuthInfo` with this username. If it
is not set the username of the currently used `ProxyConfig` is used to
search for a LinphoneAuthInfo.

Parameters:
  `username` - The username used to authenticate with the STUN/TURN server.

### isTcpTurnTransportEnabled

boolean isTcpTurnTransportEnabled()
Tells whether TCP TURN transport is enabled.
Used when TURN is enabled.

Returns:
  Boolean value telling whether TCP TURN transport is enabled.

### setTcpTurnTransportEnabled

void setTcpTurnTransportEnabled(boolean enable)
Enable TCP TURN transport.
Used when TURN is enabled.

Parameters:
  `enable` - Boolean value telling whether to enable TCP TURN transport.

### isTlsTurnTransportEnabled

boolean isTlsTurnTransportEnabled()
Tells whether TLS TURN transport is enabled.
Used when TURN is enabled.

Returns:
  Boolean value telling whether TLS TURN transport is enabled.

### setTlsTurnTransportEnabled

void setTlsTurnTransportEnabled(boolean enable)
Enable TLS TURN transport.
Used when TURN is enabled.

Parameters:
  `enable` - Boolean value telling whether to enable TLS TURN transport.

### getTurnConfigurationEndpoint

@Nullable String getTurnConfigurationEndpoint()
Get the TURN configuration endpoint.

Returns:
  The TURN configuration endpoint used by this NAT policy.

### setTurnConfigurationEndpoint

void setTurnConfigurationEndpoint(@Nullable String endpoint)
Set the TURN configuration endpoint.

Parameters:
  `endpoint` - The TURN configuration endpoint to use with this NAT policy.

### isTurnEnabled

boolean isTurnEnabled()
Tell whether TURN is enabled.

Returns:
  Boolean value telling whether TURN is enabled.

### setTurnEnabled

void setTurnEnabled(boolean enable)
Enable TURN.
If STUN is also enabled, it is ignored and TURN is used.

Parameters:
  `enable` - Boolean value telling whether to enable TURN.

### isUdpTurnTransportEnabled

boolean isUdpTurnTransportEnabled()
Tells whether UDP TURN transport is enabled.
Used when TURN is enabled.

Returns:
  Boolean value telling whether UDP TURN transport is enabled.

### setUdpTurnTransportEnabled

void setUdpTurnTransportEnabled(boolean enable)
Enable UDP TURN transport.
Used when TURN is enabled.

Parameters:
  `enable` - Boolean value telling whether to enable UDP TURN transport.

### isUpnpEnabled

boolean isUpnpEnabled()
Tell whether uPnP is enabled.

Returns:
  Boolean value telling whether uPnP is enabled.

### setUpnpEnabled

void setUpnpEnabled(boolean enable)
Enable uPnP.
This has the effect to disable every other policies (ICE, STUN and TURN).

Parameters:
  `enable` - Boolean value telling whether to enable uPnP.

### clear

void clear()
Clear a NAT policy (deactivate all protocols and unset the STUN server).

### clone

@NonNull NatPolicy clone()
Clone an existing `NatPolicy` object.

Returns:
  A clone of the original `NatPolicy` object.

### resolveStunServer

void resolveStunServer()
Start a STUN server DNS resolution.

### setUserData

void setUserData(Object data)
Sets the object to store in this object user's data

Parameters:
  `data` - the object to store

### getUserData

Object getUserData()
Gets the object stored in this object user's data

Returns:
  the object store if any, null otherwise

### getNativePointer

long getNativePointer()
Gets the native pointer used by this class to make native method calls.

Returns:
  the nativer pointer, as long

### toString

String toString()

Overrides:
  `toString` in class `Object`